@quantaroute/checkout 1.4.4 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @quantaroute/checkout v1.4.4
2
+ * @quantaroute/checkout v1.4.5
3
3
  * (c) 2026 QuantaRoute – https://quantaroute.com
4
4
  * Released under the MIT License.
5
5
  *
@@ -21,9 +21,9 @@
21
21
  import{jsxs as e,jsx as r,Fragment as n}from"react/jsx-runtime"
22
22
  import a,{useState as t,useCallback as i,useRef as o,useId as l,useEffect as s,useReducer as d,useMemo as c}from"react"
23
23
  import u from"maplibre-gl"
24
- const h=[["F","C","9","8"],["J","3","2","7"],["K","4","5","6"],["L","M","P","T"]],p={minLat:2.5,maxLat:38.5,minLon:63.5,maxLon:99.5},m="FC98J327K456LMPT",f=new RegExp(`^[${m}]{10}$`,"i"),b=new RegExp(`^[${m}]{1,10}$`,"i"),y=/[\s\-_\u2010-\u2015\u2212.]/g
25
- function v(e){return e.trim().toUpperCase().replace(y,"")}function _(e){const r=v(e)
26
- return r.length>0&&r.length<=10&&b.test(r)}function g(e){const r=v(e)
24
+ const h=[["F","C","9","8"],["J","3","2","7"],["K","4","5","6"],["L","M","P","T"]],p={minLat:2.5,maxLat:38.5,minLon:63.5,maxLon:99.5},m="FC98J327K456LMPT",f=new RegExp(`^[${m}]{10}$`,"i"),y=new RegExp(`^[${m}]{1,10}$`,"i"),b=/[\s\-_\u2010-\u2015\u2212.]/g
25
+ function v(e){return e.trim().toUpperCase().replace(b,"")}function _(e){const r=v(e)
26
+ return r.length>0&&r.length<=10&&y.test(r)}function g(e){const r=v(e)
27
27
  return 10!==r.length?e.trim().toUpperCase():`${r.slice(0,3)}-${r.slice(3,6)}-${r.slice(6)}`}function q(e){const r=v(e)
28
28
  return 10===r.length&&f.test(r)}function w(e,r){if(e<p.minLat||e>p.maxLat)throw new Error(`Latitude ${e} out of range. Must be between ${p.minLat} and ${p.maxLat}`)
29
29
  if(r<p.minLon||r>p.maxLon)throw new Error(`Longitude ${r} out of range. Must be between ${p.minLon} and ${p.maxLon}`)
@@ -40,10 +40,10 @@ break}if(l)break}if(!l)throw new Error(`Invalid character in DIGIPIN: '${o}'`)
40
40
  const c=(a-n)/4,u=(i-t)/4,p=t+u*(d+1)
41
41
  n=a-c*(s+1),a-=c*s,t+=u*d,i=p}return{latitude:((n+a)/2).toFixed(6),longitude:((t+i)/2).toFixed(6)}}function k(e){if(!e||"string"!=typeof e)return!1
42
42
  if(!q(e))return!1
43
- try{return N(e),!0}catch{return!1}}function x(e,r){return e>=p.minLat&&e<=p.maxLat&&r>=p.minLon&&r<=p.maxLon}const C="https://api.quantaroute.com"
43
+ try{return N(e),!0}catch{return!1}}function C(e,r){return e>=p.minLat&&e<=p.maxLat&&r>=p.minLon&&r<=p.maxLon}const x="https://api.quantaroute.com"
44
44
  function E(e){if("undefined"!=typeof AbortSignal&&"function"==typeof AbortSignal.timeout)return AbortSignal.timeout(e)
45
45
  const r=new AbortController
46
- return setTimeout(()=>r.abort(),e),r.signal}async function S(e,r,n,a=C){const t=`${a.replace(/\/$/,"")}/v1/location/lookup`
46
+ return setTimeout(()=>r.abort(),e),r.signal}async function S(e,r,n,a=x){const t=`${a.replace(/\/$/,"")}/v1/location/lookup`
47
47
  let i
48
48
  try{i=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json","x-api-key":n},body:JSON.stringify({latitude:e,longitude:r}),signal:E(15e3)})}catch(e){if(e instanceof Error&&("TimeoutError"===e.name||"AbortError"===e.name))throw new Error("Request timed out. Check your internet connection.")
49
49
  throw new Error(`Network error: ${e instanceof Error?e.message:String(e)}`)}if(!i.ok){let e=""
@@ -51,7 +51,7 @@ try{e=await i.text()}catch{}if(401===i.status||403===i.status)throw new Error("I
51
51
  if(429===i.status)throw new Error("Rate limit exceeded. Upgrade your plan or try again later.")
52
52
  throw new Error(`API error ${i.status}: ${e||i.statusText}`)}const o=await i.json()
53
53
  if(!o.success)throw new Error(o.message??"Location lookup failed")
54
- return o}async function L(e,r,n=C){const a=e.replace(/\D/g,"").slice(0,6)
54
+ return o}async function L(e,r,n=x){const a=e.replace(/\D/g,"").slice(0,6)
55
55
  if(!/^[1-9][0-9]{5}$/.test(a))throw new Error("Pincode must be a 6-digit number starting with 1–9.")
56
56
  const t=`${n.replace(/\/$/,"")}/v1/pincode/validate/${a}`
57
57
  let i
@@ -61,13 +61,13 @@ if(429===i.status)throw new Error("Rate limit exceeded.")
61
61
  let e=""
62
62
  try{e=await i.text()}catch{}throw new Error(`Pincode validation failed (${i.status}): ${e||i.statusText}`)}const o=await i.json()
63
63
  if(!o.success||!o.data)throw new Error(o.message??"Pincode validation failed.")
64
- return o.data}function T(e){return e.some(e=>"delivery"===(e.delivery??"").trim().toLowerCase())}function I(e){return q(e)}function P(e){return _(e)}async function A(e,r,n=C,a=5,t,i){let o,l=`${n.replace(/\/$/,"")}/v1/digipin/autocomplete?q=${encodeURIComponent(e.trim())}&limit=${Math.min(a,10)}`
64
+ return o.data}function T(e){return e.some(e=>"delivery"===(e.delivery??"").trim().toLowerCase())}function I(e){return q(e)}function P(e){return _(e)}async function B(e,r,n=x,a=5,t,i){let o,l=`${n.replace(/\/$/,"")}/v1/digipin/autocomplete?q=${encodeURIComponent(e.trim())}&limit=${Math.min(a,10)}`
65
65
  "number"==typeof t&&"number"==typeof i&&(l+=`&lat=${t.toFixed(6)}&lng=${i.toFixed(6)}`)
66
66
  try{o=await fetch(l,{method:"GET",headers:{"x-api-key":r},signal:E(8e3)})}catch(e){if(e instanceof Error&&("TimeoutError"===e.name||"AbortError"===e.name))throw new Error("Autocomplete request timed out.")
67
67
  throw new Error(`Network error: ${e instanceof Error?e.message:String(e)}`)}if(!o.ok){if(401===o.status||403===o.status)throw new Error("Invalid API key.")
68
68
  if(429===o.status)throw new Error("Rate limit exceeded.")
69
69
  return[]}const s=await o.json()
70
- return s.success?s.data??[]:[]}async function B(e,r,n=C){const a=`${n.replace(/\/$/,"")}/v1/digipin/reverse`
70
+ return s.success?s.data??[]:[]}async function A(e,r,n=x){const a=`${n.replace(/\/$/,"")}/v1/digipin/reverse`
71
71
  let t
72
72
  try{t=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json","x-api-key":r},body:JSON.stringify({digipin:e}),signal:E(15e3)})}catch(e){if(e instanceof Error&&("TimeoutError"===e.name||"AbortError"===e.name))throw new Error("Request timed out. Check your internet connection.")
73
73
  throw new Error(`Network error: ${e instanceof Error?e.message:String(e)}`)}if(!t.ok){let e=""
@@ -75,201 +75,216 @@ try{e=await t.text()}catch{}if(401===t.status||403===t.status)throw new Error("I
75
75
  if(429===t.status)throw new Error("Rate limit exceeded. Upgrade your plan or try again later.")
76
76
  throw new Error(`API error ${t.status}: ${e||t.statusText}`)}const i=await t.json()
77
77
  if(!i.success)throw new Error(i.message??"Reverse geocoding failed")
78
- return i}function $(){const[e,r]=t({loading:!1,error:null})
78
+ return i}function O(){const[e,r]=t({loading:!1,error:null})
79
79
  return{...e,locate:i(e=>{navigator.geolocation?(r({loading:!0,error:null}),navigator.geolocation.getCurrentPosition(({coords:n})=>{r({loading:!1,error:null}),e(n.latitude,n.longitude)},e=>{let n="Unable to get location."
80
- e.code===e.PERMISSION_DENIED?n="Location permission denied. Please enable it in browser settings.":e.code===e.POSITION_UNAVAILABLE?n="Location unavailable. Try again or place the pin manually.":e.code===e.TIMEOUT&&(n="Location request timed out. Try again."),r({loading:!1,error:n})},{enableHighAccuracy:!0,timeout:12e3,maximumAge:0})):r({loading:!1,error:"Geolocation is not supported by your browser."})},[]),clearError:i(()=>{r(e=>({...e,error:null}))},[])}}function M(e,r){if(!x(e,r))return null
81
- try{return w(e,r)}catch{return null}}const D="#0ea5e9",O=({onLocationConfirm:n,defaultLat:a,defaultLng:d,mapHeight:c="380px",theme:h="light",indiaBoundaryUrl:p,enableSearch:m=!0,apiKey:f,apiBaseUrl:b,brandColor:y=D})=>{const v=o(null),_=o(null),q=o(null),w=a??13.00427,k=d??77.589291,x=void 0!==a&&void 0!==d,[C,E]=t(w),[S,L]=t(k),[T,B]=t(()=>M(w,k)),[O,U]=t(!1),[F,R]=t(""),[j,W]=t([]),[V,z]=t(!1),[J,H]=t(null),[G,K]=t(!1),Y=o(null),Q=o(null),Z=l(),{loading:X,error:ee,locate:re,clearError:ne}=$(),ae=i((e,r)=>{B(M(e,r))},[]),te=i((e,r)=>{var n
80
+ e.code===e.PERMISSION_DENIED?n="Location permission denied. Please enable it in browser settings.":e.code===e.POSITION_UNAVAILABLE?n="Location unavailable. Try again or place the pin manually.":e.code===e.TIMEOUT&&(n="Location request timed out. Try again."),r({loading:!1,error:n})},{enableHighAccuracy:!0,timeout:12e3,maximumAge:0})):r({loading:!1,error:"Geolocation is not supported by your browser."})},[]),clearError:i(()=>{r(e=>({...e,error:null}))},[])}}function D(e,r){if(!C(e,r))return null
81
+ try{return w(e,r)}catch{return null}}const $="#0ea5e9",M=({onLocationConfirm:n,defaultLat:a,defaultLng:d,mapHeight:c="380px",theme:h="light",indiaBoundaryUrl:p,enableSearch:m=!0,apiKey:f,apiBaseUrl:y,brandColor:b=$})=>{const v=o(null),_=o(null),q=o(null),w=a??13.00427,k=d??77.589291,C=void 0!==a&&void 0!==d,[x,E]=t(w),[S,L]=t(k),[T,A]=t(()=>D(w,k)),[M,U]=t(!1),[F,R]=t(""),[j,W]=t([]),[z,V]=t(!1),[J,H]=t(null),[G,K]=t(!1),Y=o(null),Q=o(null),Z=l(),{loading:X,error:ee,locate:re,clearError:ne}=O(),ae=i((e,r)=>{A(D(e,r))},[]),te=i((e,r)=>{var n
82
82
  E(e),L(r),ae(e,r),_.current&&_.current.flyTo({center:[r,e],zoom:18,duration:900,essential:!0}),null==(n=q.current)||n.setLngLat([r,e])},[ae]),ie=i(e=>{const r=e.target.value
83
83
  R(r),H(null),Y.current&&clearTimeout(Y.current)
84
84
  const n=r.trim()
85
- if(!n)return W([]),K(!1),void z(!1)
85
+ if(!n)return W([]),K(!1),void V(!1)
86
86
  if(I(n))try{const e=N(n),r=parseFloat(e.latitude),a=parseFloat(e.longitude)
87
- te(r,a),W([]),K(!1),R(g(n))}catch{H("Invalid DigiPin code")}else{if(P(n))return W([]),K(!1),void z(!1)
87
+ te(r,a),W([]),K(!1),R(g(n))}catch{H("Invalid DigiPin code")}else{if(P(n))return W([]),K(!1),void V(!1)
88
88
  if(n.length<3)return W([]),void K(!1)
89
- z(!0),Y.current=setTimeout(async()=>{try{const e=f??"",r=await A(n,e,b,5,C,S)
90
- W(r),K(r.length>0)}catch(e){H(e instanceof Error?e.message:"Search failed"),W([]),K(!1)}finally{z(!1)}},400)}},[f,b,te]),oe=i(e=>{var r
89
+ V(!0),Y.current=setTimeout(async()=>{try{const e=f??"",r=await B(n,e,y,5,x,S)
90
+ W(r),K(r.length>0)}catch(e){H(e instanceof Error?e.message:"Search failed"),W([]),K(!1)}finally{V(!1)}},400)}},[f,y,te]),oe=i(e=>{var r
91
91
  te(e.coordinates.latitude,e.coordinates.longitude),R(""),W([]),K(!1),null==(r=Q.current)||r.blur()},[te]),le=i(e=>{"Escape"===e.key&&(W([]),K(!1),R(""))},[])
92
92
  s(()=>{if(!v.current)return
93
- const e=p?fetch(p).then(e=>e.ok?e.json():null).catch(()=>null):Promise.resolve(null),r=x?18:9,n=new u.Map({container:v.current,style:"https://basemaps.cartocdn.com/gl/positron-gl-style/style.json",center:[k,w],zoom:r,minZoom:6,attributionControl:!1,touchZoomRotate:!0})
93
+ const e=p?fetch(p).then(e=>e.ok?e.json():null).catch(()=>null):Promise.resolve(null),r=C?18:9,n=new u.Map({container:v.current,style:"https://basemaps.cartocdn.com/gl/positron-gl-style/style.json",center:[k,w],zoom:r,minZoom:6,attributionControl:!1,touchZoomRotate:!0})
94
94
  return n.addControl(new u.AttributionControl({compact:!0,customAttribution:'© <a href="https://www.openstreetmap.org/copyright" target="_blank" rel="noopener">OpenStreetMap</a> contributors &nbsp;© <a href="https://carto.com/attributions" target="_blank" rel="noopener">CARTO</a>'}),"bottom-right"),n.addControl(new u.NavigationControl({showCompass:!1}),"top-right"),n.on("load",()=>{U(!0),e.then(e=>{if(e&&n.isStyleLoaded())try{n.addSource("india-boundary",{type:"geojson",data:e}),n.addLayer({id:"india-boundary-line",type:"line",source:"india-boundary",paint:{"line-color":"#94a3b8","line-width":1.5,"line-opacity":.65}})}catch{}})
95
- const r=function(e=D){const r=document.createElement("div")
96
- return r.className="qr-pin",r.setAttribute("aria-label","Drag to adjust your location"),r.style.width="40px",r.style.height="52px",r.innerHTML=`\n <svg\n class="qr-pin__svg"\n width="40"\n height="52"\n viewBox="0 0 40 52"\n overflow="visible"\n fill="none"\n xmlns="http://www.w3.org/2000/svg"\n aria-hidden="true"\n >\n <defs>\n \x3c!--\n The filter region must be generous enough to contain the shadow blur.\n stdDeviation=3 → ~9px blur radius; our region extends 50% on each side.\n overflow="visible" on the <svg> lets it paint outside the viewport.\n --\x3e\n <filter id="qr-pin-shadow" x="-60%" y="-40%" width="220%" height="220%">\n <feDropShadow dx="0" dy="3" stdDeviation="3.5"\n flood-color="#000" flood-opacity="0.28"/>\n </filter>\n </defs>\n\n \x3c!-- Teardrop body — tip is at (20, 52) = bottom-center of the SVG --\x3e\n <path\n d="M20 0C9.402 0 0 9.402 0 20C0 34 20 52 20 52S40 34 40 20C40 9.402 30.598 0 20 0Z"\n fill="${e}"\n filter="url(#qr-pin-shadow)"\n />\n \x3c!-- Dot inside the pin --\x3e\n <circle cx="20" cy="20" r="9" fill="white"/>\n <circle cx="20" cy="20" r="5" fill="${e}"/>\n </svg>\n\n \x3c!--\n Pulse ring — position: absolute inside .qr-pin (position: relative).\n bottom: -(height/2) → bottom: -10px centres the 20×20 circle\n exactly at y = PIN_H = 52px = the pin tip coordinate.\n --\x3e\n <div class="qr-pin__pulse" aria-hidden="true"></div>\n `,r}(y),a=new u.Marker({element:r,draggable:!0,anchor:"bottom"}).setLngLat([k,w]).addTo(n)
95
+ const r=function(e=$){const r=document.createElement("div")
96
+ return r.className="qr-pin",r.setAttribute("aria-label","Drag to adjust your location"),r.style.width="40px",r.style.height="52px",r.innerHTML=`\n <svg\n class="qr-pin__svg"\n width="40"\n height="52"\n viewBox="0 0 40 52"\n overflow="visible"\n fill="none"\n xmlns="http://www.w3.org/2000/svg"\n aria-hidden="true"\n >\n <defs>\n \x3c!--\n The filter region must be generous enough to contain the shadow blur.\n stdDeviation=3 → ~9px blur radius; our region extends 50% on each side.\n overflow="visible" on the <svg> lets it paint outside the viewport.\n --\x3e\n <filter id="qr-pin-shadow" x="-60%" y="-40%" width="220%" height="220%">\n <feDropShadow dx="0" dy="3" stdDeviation="3.5"\n flood-color="#000" flood-opacity="0.28"/>\n </filter>\n </defs>\n\n \x3c!-- Teardrop body — tip is at (20, 52) = bottom-center of the SVG --\x3e\n <path\n d="M20 0C9.402 0 0 9.402 0 20C0 34 20 52 20 52S40 34 40 20C40 9.402 30.598 0 20 0Z"\n fill="${e}"\n filter="url(#qr-pin-shadow)"\n />\n \x3c!-- Dot inside the pin --\x3e\n <circle cx="20" cy="20" r="9" fill="white"/>\n <circle cx="20" cy="20" r="5" fill="${e}"/>\n </svg>\n\n \x3c!--\n Pulse ring — position: absolute inside .qr-pin (position: relative).\n bottom: -(height/2) → bottom: -10px centres the 20×20 circle\n exactly at y = PIN_H = 52px = the pin tip coordinate.\n --\x3e\n <div class="qr-pin__pulse" aria-hidden="true"></div>\n `,r}(b),a=new u.Marker({element:r,draggable:!0,anchor:"bottom"}).setLngLat([k,w]).addTo(n)
97
97
  a.on("drag",()=>{const e=a.getLngLat()
98
98
  E(e.lat),L(e.lng),ae(e.lat,e.lng)}),a.on("dragend",()=>{const e=a.getLngLat()
99
99
  n.easeTo({center:[e.lng,e.lat],duration:250})}),q.current=a}),n.on("click",e=>{var r
100
100
  const a=e.lngLat
101
101
  null==(r=q.current)||r.setLngLat([a.lng,a.lat]),E(a.lat),L(a.lng),ae(a.lat,a.lng),n.easeTo({center:[a.lng,a.lat],duration:200})}),_.current=n,()=>{n.remove(),_.current=null,q.current=null}},[])
102
102
  const se=i(()=>{ne(),re((e,r)=>{var n
103
- E(e),L(r),ae(e,r),_.current&&_.current.flyTo({center:[r,e],zoom:18,duration:1400,essential:!0}),null==(n=q.current)||n.setLngLat([r,e])})},[re,ne,ae]),de=i(()=>{T&&n(C,S,T)},[C,S,T,n]),ce=null!==T,ue=ce&&O
104
- return e("div",{className:"qr-map-wrapper",children:[e("div",{className:"qr-step-header",children:[r("div",{className:"qr-step-badge",children:"1"}),e("div",{className:"qr-step-text",children:[r("span",{className:"qr-step-title",children:"Pin Your Location"}),r("span",{className:"qr-step-sub",children:"Tap the map or drag the pin to your exact home / office"})]})]}),m&&e("div",{className:"qr-search-bar",role:"search",children:[e("div",{className:"qr-search-bar__input-wrap",children:[e("svg",{className:"qr-search-bar__icon","aria-hidden":"true",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r("circle",{cx:"11",cy:"11",r:"8"}),r("path",{d:"M21 21l-4.35-4.35"})]}),r("input",{ref:Q,type:"search",className:"qr-search-bar__input",placeholder:"Search address, 'pharmacy near me', or DigiPin…",value:F,onChange:ie,onKeyDown:le,autoComplete:"off",autoCorrect:"off",autoCapitalize:"characters",spellCheck:!1,"aria-label":"Search address or DigiPin","aria-autocomplete":"list","aria-controls":G?Z:void 0,"aria-expanded":G}),V&&r("span",{className:"qr-search-bar__spinner qr-spinner qr-spinner--sm","aria-hidden":"true"}),F&&!V&&r("button",{type:"button",className:"qr-search-bar__clear",onClick:()=>{R(""),W([]),K(!1),H(null)},"aria-label":"Clear search",tabIndex:-1,children:"×"})]}),J&&r("p",{className:"qr-search-bar__error",role:"alert",children:J}),G&&j.length>0&&r("ul",{id:Z,className:"qr-search-bar__dropdown",role:"listbox","aria-label":"Address suggestions",children:j.map((n,a)=>e("li",{className:"qr-search-bar__suggestion",role:"option","aria-selected":"false",onMouseDown:e=>{e.preventDefault(),oe(n)},children:[e("svg",{className:"qr-search-bar__suggestion-icon","aria-hidden":"true",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[r("path",{d:"M12 2C8.134 2 5 5.134 5 9c0 5.25 7 13 7 13s7-7.75 7-13c0-3.866-3.134-7-7-7z"}),r("circle",{cx:"12",cy:"9",r:"2.5"})]}),e("div",{className:"qr-search-bar__suggestion-text",children:[r("span",{className:"qr-search-bar__suggestion-name",children:n.displayName}),n.address&&n.address!==n.displayName&&r("span",{className:"qr-search-bar__suggestion-sub",children:n.address})]})]},a))}),e("p",{className:"qr-search-bar__hint",children:[r("span",{className:"qr-search-bar__hint-chip",children:"DigiPin"}),"Type your DigiPin code for instant offline lookup — no API call"]})]}),e("div",{className:"qr-map-outer",style:{height:c},children:[r("div",{ref:v,className:"qr-map-canvas"}),T&&e("div",{className:"qr-digipin-badge","aria-live":"polite","aria-label":`DigiPin: ${T}`,children:[r("span",{className:"qr-digipin-badge__label",children:"DigiPin"}),r("span",{className:"qr-digipin-badge__code",children:T})]}),!ce&&O&&r("div",{className:"qr-map-notice",role:"status",children:"Move map to India to get a DigiPin"}),r("button",{className:"qr-locate-btn"+(X?" qr-locate-btn--loading":""),onClick:se,disabled:X,title:"Use my current location","aria-label":"Use my current location",type:"button",children:X?r("span",{className:"qr-spinner","aria-hidden":"true"}):e("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r("circle",{cx:"12",cy:"12",r:"3",fill:"currentColor",stroke:"none"}),r("circle",{cx:"12",cy:"12",r:"7"}),r("path",{d:"M12 2v3M12 19v3M2 12h3M19 12h3"})]})}),ee&&e("div",{className:"qr-geo-error",role:"alert",children:[r("span",{children:ee}),r("button",{type:"button",className:"qr-geo-error__dismiss",onClick:ne,"aria-label":"Dismiss error",children:"×"})]})]}),O&&e("div",{className:"qr-coords-strip","aria-label":"Current pin coordinates",children:[e("span",{children:[C.toFixed(5),"° N"]}),r("span",{className:"qr-coords-sep",children:"·"}),e("span",{children:[S.toFixed(5),"° E"]})]}),e("div",{className:"qr-map-actions",children:[e("button",{type:"button",className:"qr-btn qr-btn--primary qr-btn--full",onClick:de,disabled:!ue,children:["Confirm Location",r("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:r("path",{d:"M5 12h14M12 5l7 7-7 7"})})]}),!ce&&O&&r("p",{className:"qr-map-hint",children:"Move the pin to a location in India to continue"})]})]})}
105
- function U({label:n,className:a}){const t={className:a,"aria-hidden":!0,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}
103
+ E(e),L(r),ae(e,r),_.current&&_.current.flyTo({center:[r,e],zoom:18,duration:1400,essential:!0}),null==(n=q.current)||n.setLngLat([r,e])})},[re,ne,ae]),de=i(()=>{T&&n(x,S,T)},[x,S,T,n]),ce=null!==T,ue=ce&&M
104
+ return e("div",{className:"qr-map-wrapper",children:[e("div",{className:"qr-step-header",children:[r("div",{className:"qr-step-badge",children:"1"}),e("div",{className:"qr-step-text",children:[r("span",{className:"qr-step-title",children:"Pin Your Location"}),r("span",{className:"qr-step-sub",children:"Tap the map or drag the pin to your exact home / office"})]})]}),m&&e("div",{className:"qr-search-bar",role:"search",children:[e("div",{className:"qr-search-bar__input-wrap",children:[e("svg",{className:"qr-search-bar__icon","aria-hidden":"true",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r("circle",{cx:"11",cy:"11",r:"8"}),r("path",{d:"M21 21l-4.35-4.35"})]}),r("input",{ref:Q,type:"search",className:"qr-search-bar__input",placeholder:"Search address, 'pharmacy near me', or DigiPin…",value:F,onChange:ie,onKeyDown:le,autoComplete:"off",autoCorrect:"off",autoCapitalize:"characters",spellCheck:!1,"aria-label":"Search address or DigiPin","aria-autocomplete":"list","aria-controls":G?Z:void 0,"aria-expanded":G}),z&&r("span",{className:"qr-search-bar__spinner qr-spinner qr-spinner--sm","aria-hidden":"true"}),F&&!z&&r("button",{type:"button",className:"qr-search-bar__clear",onClick:()=>{R(""),W([]),K(!1),H(null)},"aria-label":"Clear search",tabIndex:-1,children:"×"})]}),J&&r("p",{className:"qr-search-bar__error",role:"alert",children:J}),G&&j.length>0&&r("ul",{id:Z,className:"qr-search-bar__dropdown",role:"listbox","aria-label":"Address suggestions",children:j.map((n,a)=>e("li",{className:"qr-search-bar__suggestion",role:"option","aria-selected":"false",onMouseDown:e=>{e.preventDefault(),oe(n)},children:[e("svg",{className:"qr-search-bar__suggestion-icon","aria-hidden":"true",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[r("path",{d:"M12 2C8.134 2 5 5.134 5 9c0 5.25 7 13 7 13s7-7.75 7-13c0-3.866-3.134-7-7-7z"}),r("circle",{cx:"12",cy:"9",r:"2.5"})]}),e("div",{className:"qr-search-bar__suggestion-text",children:[r("span",{className:"qr-search-bar__suggestion-name",children:n.displayName}),n.address&&n.address!==n.displayName&&r("span",{className:"qr-search-bar__suggestion-sub",children:n.address})]})]},a))}),e("p",{className:"qr-search-bar__hint",children:[r("span",{className:"qr-search-bar__hint-chip",children:"DigiPin"}),"Type your DigiPin code for instant offline lookup — no API call"]})]}),e("div",{className:"qr-map-outer",style:{height:c},children:[r("div",{ref:v,className:"qr-map-canvas"}),T&&e("div",{className:"qr-digipin-badge","aria-live":"polite","aria-label":`DigiPin: ${T}`,children:[r("span",{className:"qr-digipin-badge__label",children:"DigiPin"}),r("span",{className:"qr-digipin-badge__code",children:T})]}),!ce&&M&&r("div",{className:"qr-map-notice",role:"status",children:"Move map to India to get a DigiPin"}),r("button",{className:"qr-locate-btn"+(X?" qr-locate-btn--loading":""),onClick:se,disabled:X,title:"Use my current location","aria-label":"Use my current location",type:"button",children:X?r("span",{className:"qr-spinner","aria-hidden":"true"}):e("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r("circle",{cx:"12",cy:"12",r:"3",fill:"currentColor",stroke:"none"}),r("circle",{cx:"12",cy:"12",r:"7"}),r("path",{d:"M12 2v3M12 19v3M2 12h3M19 12h3"})]})}),ee&&e("div",{className:"qr-geo-error",role:"alert",children:[r("span",{children:ee}),r("button",{type:"button",className:"qr-geo-error__dismiss",onClick:ne,"aria-label":"Dismiss error",children:"×"})]})]}),M&&e("div",{className:"qr-coords-strip","aria-label":"Current pin coordinates",children:[e("span",{children:[x.toFixed(5),"° N"]}),r("span",{className:"qr-coords-sep",children:"·"}),e("span",{children:[S.toFixed(5),"° E"]})]}),e("div",{className:"qr-map-actions",children:[e("button",{type:"button",className:"qr-btn qr-btn--primary qr-btn--full",onClick:de,disabled:!ue,children:["Confirm Location",r("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:r("path",{d:"M5 12h14M12 5l7 7-7 7"})})]}),!ce&&M&&r("p",{className:"qr-map-hint",children:"Move the pin to a location in India to continue"})]})]})}
105
+ async function U(e,r){const n=await fetch(`${e.functionBaseUrl}/checkout-otp`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"send",mobile:r,merchant_id:e.merchantId})}),a=await n.json().catch(()=>({}))
106
+ if(!n.ok||!a.success)throw new Error(a.error??"Failed to send OTP. Please try again.")}async function F(e,r,n,a){const t=await fetch(`${e.functionBaseUrl}/checkout-otp`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"verify",mobile:r,otp:n,merchant_id:e.merchantId,...a})}),i=await t.json().catch(()=>({}))
107
+ if(!t.ok||!i.success)throw new Error(i.error??"Invalid or expired OTP.")
108
+ return i}function R(e){return{"Content-Type":"application/json","x-session-token":e}}async function j(e,r){const n=await fetch(`${e.functionBaseUrl}/checkout-addresses`,{method:"POST",headers:R(r),body:JSON.stringify({action:"list"})}),a=await n.json().catch(()=>({}))
109
+ if(!n.ok||!a.success)throw new Error(a.error??"Failed to load saved addresses.")
110
+ return a.data??[]}async function W(e,r,n){const a=await fetch(`${e.functionBaseUrl}/checkout-addresses`,{method:"POST",headers:R(r),body:JSON.stringify({action:"create",address:n})}),t=await a.json().catch(()=>({}))
111
+ if(!a.ok||!t.success)throw new Error(t.error??"Failed to save address.")
112
+ return t.data}async function z(e,r,n){const a=await fetch(`${e.functionBaseUrl}/checkout-addresses`,{method:"POST",headers:R(r),body:JSON.stringify({action:"delete",address_id:n})}),t=await a.json().catch(()=>({}))
113
+ if(!a.ok||!t.success)throw new Error(t.error??"Failed to delete address.")}async function V(e,r,n){const a=await fetch(`${e.functionBaseUrl}/checkout-addresses`,{method:"POST",headers:R(r),body:JSON.stringify({action:"set_default",address_id:n})}),t=await a.json().catch(()=>({}))
114
+ if(!a.ok||!t.success)throw new Error(t.error??"Failed to set default address.")}async function J(e,r,n){const a=await fetch(`${e.functionBaseUrl}/checkout-addresses`,{method:"POST",headers:R(r),body:JSON.stringify({action:"address_completed",data:n})}),t=await a.json().catch(()=>({}))
115
+ !a.ok||t.success}async function H(e,r){const n=await fetch(`${e.functionBaseUrl}/checkout-email-otp`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"send",email:r,merchant_id:e.merchantId})}),a=await n.json().catch(()=>({}))
116
+ if(!n.ok||!a.success)throw new Error(a.error??"Failed to send OTP. Please try again.")
117
+ return{reused:Boolean(a.reused)}}async function G(e,r,n,a){const t=await fetch(`${e.functionBaseUrl}/checkout-email-otp`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"verify",email:r,code:n,merchant_id:e.merchantId,...a})}),i=await t.json().catch(()=>({}))
118
+ if(!t.ok||!i.success)throw new Error(i.error??"Invalid or expired code.")
119
+ return i}async function K(e,r,n,a){const t={action:"cod_eligibility",pincode:n}
120
+ void 0!==a&&(t.cart_total_paise=a)
121
+ const i=await fetch(`${e.functionBaseUrl}/checkout-addresses`,{method:"POST",headers:R(r),body:JSON.stringify(t)}),o=await i.json().catch(()=>({}))
122
+ if(!i.ok||!o.success)throw new Error(o.error??"Failed to check COD eligibility.")
123
+ return o.data}async function Y(e,r,n,a){const t=await fetch(`${e.functionBaseUrl}/checkout-addresses`,{method:"POST",headers:R(r),body:JSON.stringify({action:"serviceability_check",pincode:n,...void 0!==(null==a?void 0:a.lat)?{lat:a.lat}:{},...void 0!==(null==a?void 0:a.lng)?{lng:a.lng}:{}})}),i=await t.json().catch(()=>({}))
124
+ if(!t.ok||!i.success)throw new Error(i.error??"Failed to check delivery serviceability.")
125
+ return i.data}async function Q(e,r,n){try{const a={"Content-Type":"application/json"}
126
+ n&&(a["x-session-token"]=n),await fetch(`${e.functionBaseUrl}/checkout-funnel-events`,{method:"POST",headers:a,body:JSON.stringify({merchant_id:e.merchantId,...r})})}catch{}}async function Z(e,r,n){try{await fetch(`${e.functionBaseUrl}/checkout-addresses`,{method:"POST",headers:R(r),body:JSON.stringify({action:"abandon",last_step:n})})}catch{}}async function X(e,r){const n=await fetch(`${e.functionBaseUrl}/checkout-offers`,{method:"GET",headers:R(r)}),a=await n.json().catch(()=>({}))
127
+ return n.ok&&a.success?a.data??null:null}async function ee(e,r,n){const a=await fetch(`${e.functionBaseUrl}/checkout-payment`,{method:"POST",headers:R(r),body:JSON.stringify({action:"create_order",amount_paise:n})}),t=await a.json().catch(()=>({}))
128
+ if(!a.ok||!t.success)throw new Error(t.error??"Failed to create payment order.")
129
+ return t.data}async function re(e,r,n){const a=await fetch(`${e.functionBaseUrl}/checkout-payment`,{method:"POST",headers:R(r),body:JSON.stringify({action:"verify",...n})}),t=await a.json().catch(()=>({}))
130
+ if(!a.ok||!t.success)throw new Error(t.error??"Payment verification failed.")
131
+ return{payment_method:t.payment_method,razorpay_order_id:t.razorpay_order_id,razorpay_payment_id:t.razorpay_payment_id}}async function ne(e,r){const n=await fetch(`${e.functionBaseUrl}/checkout-payment`,{method:"POST",headers:R(r),body:JSON.stringify({action:"record_cod"})}),a=await n.json().catch(()=>({}))
132
+ if(!n.ok||!a.success)throw new Error(a.error??"Failed to record COD selection.")
133
+ return{payment_method:a.payment_method}}async function ae(e,r){const n=await fetch(`${e}/checkout-admin?action=cod_config`,{headers:{"x-api-key":r}}),a=await n.json().catch(()=>({}))
134
+ return n.ok&&a.success?{prepaid_nudge_copy:a.data.prepaid_nudge_copy,prepaid_nudge_cta_url:a.data.prepaid_nudge_cta_url}:null}const te=/\s+(?:B\.?\s*O\.?|S\.?\s*O\.?|H\.?\s*O\.?|P\.?\s*O\.?|D\.?\s*S\.?\s*O\.?|S\.?\s*D\.?\s*O\.?|S\.?\s*B\.?\s*C\.?|C\.?\s*P\.?\s*C\.?|M\.?\s*D\.?\s*G\.?)\.?\s*$/i
135
+ function ie(e){return e.replace(te,"").replace(/\s+/g," ").trim()}function oe(e){return ie(e).toLowerCase()}function le({label:n,className:a}){const t={className:a,"aria-hidden":!0,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}
106
136
  switch(n){case"home":return e("svg",{...t,children:[r("path",{d:"M3 9.5L12 3l9 6.5V20a1 1 0 01-1 1H5a1 1 0 01-1-1V9.5z"}),r("path",{d:"M9 21V12h6v9"})]})
107
137
  case"work":return e("svg",{...t,children:[r("rect",{x:"2",y:"7",width:"20",height:"14",rx:"2"}),r("path",{d:"M16 7V5a2 2 0 00-2-2h-4a2 2 0 00-2 2v2"})]})
108
- case"other":return e("svg",{...t,children:[r("path",{d:"M21 10c0 7-9 13-9 13S3 17 3 10a9 9 0 0118 0z"}),r("circle",{cx:"12",cy:"10",r:"3"})]})}}const F={flatNumber:"",floorNumber:"",buildingName:"",streetName:""}
109
- function R(e,r){switch(r.type){case"LOAD_START":return{status:"loading"}
138
+ case"other":return e("svg",{...t,children:[r("path",{d:"M21 10c0 7-9 13-9 13S3 17 3 10a9 9 0 0118 0z"}),r("circle",{cx:"12",cy:"10",r:"3"})]})}}const se={flatNumber:"",floorNumber:"",buildingName:"",streetName:""}
139
+ function de(e,r){switch(r.type){case"LOAD_START":return{status:"loading"}
110
140
  case"LOAD_SUCCESS":{const e=function(e){const r={}
111
141
  e.name?r.buildingName=e.name:e.building_name?r.buildingName=e.building_name:e.addr_housename&&(r.buildingName=e.addr_housename)
112
142
  const n=[]
113
- return e.road&&n.push(e.road),e.suburb&&n.push(e.suburb),n.length>0&&(r.streetName=n.join(", ")),r}(r.addressComponents)
114
- return{status:"ready",adminInfo:r.adminInfo,alternatives:r.alternatives||[],selectedLocality:r.adminInfo.locality,selectedLabel:"home",labelText:"",fields:{...F,...e},submitting:!1,pincodeHasDelivery:r.pincodeHasDelivery}}case"LOAD_ERROR":return{status:"error",message:r.message}
143
+ return e.road&&n.push(e.road),e.suburb&&n.push(e.suburb),n.length>0&&(r.streetName=n.join(", ")),r}(r.addressComponents),n=function(e,r=[]){const n=new Set,a=[],t=e=>{const r=oe(e)
144
+ r&&!n.has(r)&&(n.add(r),a.push(ie(e)))}
145
+ t(e.locality)
146
+ for(const e of r)t(e.name)
147
+ const i=ie(e.locality),o=oe(e.locality),l=r.map(e=>({...e,name:ie(e.name)})).filter(e=>{const r=oe(e.name)
148
+ return r&&r!==o}).filter((e,r,n)=>n.findIndex(r=>oe(r.name)===oe(e.name))===r)
149
+ return{adminInfo:{...e,locality:i},alternatives:l,localityOptions:a,selectedLocality:i}}(r.adminInfo,r.alternatives||[])
150
+ return{status:"ready",adminInfo:n.adminInfo,alternatives:n.alternatives,localityOptions:n.localityOptions,selectedLocality:n.selectedLocality,selectedLabel:"home",labelText:"",fields:{...se,...e},submitting:!1,pincodeHasDelivery:r.pincodeHasDelivery,serviceabilityResult:r.serviceabilityResult}}case"LOAD_ERROR":return{status:"error",message:r.message}
115
151
  case"SET_FIELD":return"ready"!==e.status?e:{...e,fields:{...e.fields,[r.key]:r.value}}
116
152
  case"SET_LOCALITY":return"ready"!==e.status?e:{...e,selectedLocality:r.locality}
117
153
  case"SET_LABEL":return"ready"!==e.status?e:{...e,selectedLabel:r.label,labelText:"other"===r.label?e.labelText:""}
118
154
  case"SET_LABEL_TEXT":return"ready"!==e.status?e:{...e,labelText:r.value.slice(0,64)}
119
155
  case"SUBMIT_START":return"ready"!==e.status?e:{...e,submitting:!0}
120
156
  case"SUBMIT_END":return"ready"!==e.status?e:{...e,submitting:!1}
121
- default:return e}}const j=({digipin:a,lat:t,lng:o,apiKey:l,apiBaseUrl:c,onAddressComplete:u,onBack:h,onError:p})=>{const[m,f]=d(R,{status:"loading"}),b=i(async()=>{var e
122
- f({type:"LOAD_START"})
123
- try{const[r,n]=await Promise.all([S(t,o,l,c),B(a,l,c)]),i=(null==(e=r.data.administrative_info.pincode)?void 0:e.replace(/\D/g,"").slice(0,6))??""
124
- if(6!==i.length)return f({type:"LOAD_ERROR",message:"Could not determine a valid 6-digit pincode for this location. Please adjust the map pin."}),void(null==p||p(new Error("Missing or invalid pincode")))
157
+ default:return e}}const ce=({digipin:a,lat:t,lng:o,apiKey:l,apiBaseUrl:c,onAddressComplete:u,onBack:h,onError:p,checkoutConfig:m,serviceabilitySessionToken:f,enableServiceabilityCheck:y=!1,showIndiaPostDeliveryWarning:b=!1,serviceabilityBlockCheckout:v,onServiceabilityResult:_})=>{var g,q,w,N
158
+ const[k,C]=d(de,{status:"loading"}),x=i(async()=>{var e
159
+ C({type:"LOAD_START"})
160
+ try{const[r,n]=await Promise.all([S(t,o,l,c),A(a,l,c)]),i=(null==(e=r.data.administrative_info.pincode)?void 0:e.replace(/\D/g,"").slice(0,6))??""
161
+ if(6!==i.length)return C({type:"LOAD_ERROR",message:"Could not determine a valid 6-digit pincode for this location. Please adjust the map pin."}),void(null==p||p(new Error("Missing or invalid pincode")))
125
162
  const s=await L(i,l,c)
126
- if(!s.isValid)return f({type:"LOAD_ERROR",message:"This location resolves to a pincode that is not in the India Post database. Please move the map pin to a valid address."}),void(null==p||p(new Error("Invalid pincode for location")))
163
+ if(!s.isValid)return C({type:"LOAD_ERROR",message:"This location resolves to a pincode that is not in the India Post database. Please move the map pin to a valid address."}),void(null==p||p(new Error("Invalid pincode for location")))
127
164
  const d=T(s.offices)
128
- f({type:"LOAD_SUCCESS",adminInfo:r.data.administrative_info,alternatives:r.data.alternatives||[],addressComponents:n.data.addressComponents,pincodeHasDelivery:d})}catch(e){const r=e instanceof Error?e.message:"Failed to fetch address data."
129
- f({type:"LOAD_ERROR",message:r}),null==p||p(e instanceof Error?e:new Error(r))}},[a,t,o,l,c,p])
130
- s(()=>{b()},[b])
131
- const y=i(e=>{if(e.preventDefault(),"ready"!==m.status)return
132
- const{adminInfo:r,selectedLocality:n,selectedLabel:i,labelText:l,fields:s}=m
133
- if("other"===i&&!l.trim())return
134
- const d=[s.flatNumber,s.floorNumber?`Floor ${s.floorNumber}`:"",s.buildingName,s.streetName,n,r.district,r.state,r.pincode].filter(Boolean),c={digipin:a,lat:t,lng:o,state:r.state,district:r.district,division:r.division,locality:n,pincode:r.pincode,delivery:r.delivery,country:r.country??"India",...s,formattedAddress:d.join(", "),label:i,..."other"===i?{labelText:l.trim()}:{}}
135
- f({type:"SUBMIT_START"})
136
- try{u(c)}finally{f({type:"SUBMIT_END"})}},[m,a,t,o,u])
137
- return e("div",{className:"qr-form-wrapper",children:[e("div",{className:"qr-step-header",children:[r("button",{type:"button",className:"qr-back-btn",onClick:h,"aria-label":"Back to map",children:r("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:r("path",{d:"M19 12H5M12 19l-7-7 7-7"})})}),r("div",{className:"qr-step-badge",children:"2"}),e("div",{className:"qr-step-text",children:[r("span",{className:"qr-step-title",children:"Add Address Details"}),r("span",{className:"qr-step-sub",children:"Flat number and building info"})]})]}),e("div",{className:"qr-form-digipin-strip",children:[e("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r("path",{d:"M21 10c0 7-9 13-9 13S3 17 3 10a9 9 0 0118 0z"}),r("circle",{cx:"12",cy:"10",r:"3"})]}),r("span",{className:"qr-form-digipin-strip__label",children:"DigiPin"}),r("span",{className:"qr-form-digipin-strip__code",children:a})]}),"loading"===m.status&&e("div",{className:"qr-loading-state","aria-busy":"true","aria-label":"Fetching address details",children:[r("div",{className:"qr-spinner qr-spinner--lg","aria-hidden":"true"}),r("p",{className:"qr-loading-state__text",children:"Fetching address details…"})]}),"error"===m.status&&e("div",{className:"qr-error-state",role:"alert",children:[r("div",{className:"qr-error-state__icon","aria-hidden":"true",children:"⚠"}),r("p",{className:"qr-error-state__msg",children:m.message}),r("button",{type:"button",className:"qr-btn qr-btn--secondary qr-btn--sm",onClick:()=>{b()},children:"Retry"})]}),"ready"===m.status&&e("form",{onSubmit:y,className:"qr-form",noValidate:!0,children:[e("fieldset",{className:"qr-fieldset",children:[e("legend",{className:"qr-fieldset__legend",children:[r("span",{className:"qr-fieldset__icon","aria-hidden":"true",children:"📍"}),"Auto-detected from your digipin"]}),e("div",{className:"qr-auto-grid",children:[e("div",{className:"qr-auto-row",children:[r("span",{className:"qr-auto-row__label",children:"State"}),r("span",{className:"qr-auto-row__value",children:m.adminInfo.state})]}),e("div",{className:"qr-auto-row",children:[r("span",{className:"qr-auto-row__label",children:"District"}),r("span",{className:"qr-auto-row__value",children:m.adminInfo.district})]}),e("div",{className:"qr-auto-row qr-auto-row--full",children:[r("span",{className:"qr-auto-row__label",children:"Locality"}),m.alternatives.length>0?e("select",{className:"qr-auto-row__select",value:m.selectedLocality,onChange:e=>f({type:"SET_LOCALITY",locality:e.target.value}),"aria-label":"Select locality",children:[r("option",{value:m.adminInfo.locality,children:m.adminInfo.locality}),m.alternatives.map((e,n)=>r("option",{value:e.name,children:e.name},n))]}):r("span",{className:"qr-auto-row__value",children:m.selectedLocality})]}),e("div",{className:"qr-auto-row",children:[r("span",{className:"qr-auto-row__label",children:"Pincode"}),r("span",{className:"qr-auto-row__value qr-auto-row__value--pin",children:m.adminInfo.pincode})]})]})]}),!m.pincodeHasDelivery&&e("div",{className:"qr-pincode-banner qr-pincode-banner--warning",role:"status","aria-live":"polite",children:[r("span",{className:"qr-pincode-banner__icon","aria-hidden":"true",children:"⚠"}),e("div",{className:"qr-pincode-banner__text",children:[r("strong",{children:"Non-delivery area"}),r("span",{children:"This pincode has no India Post home-delivery office. Courier delivery may be limited — confirm with your seller before placing the order."})]})]}),e("fieldset",{className:"qr-fieldset",children:[r("legend",{className:"qr-fieldset__legend qr-fieldset__legend--compact",children:"Save as"}),r("div",{className:"qr-label-picker",role:"radiogroup","aria-label":"Address label",children:[{value:"home",title:"Home"},{value:"work",title:"Work"},{value:"other",title:"Other"}].map(({value:n,title:a})=>e("button",{type:"button",role:"radio","aria-checked":m.selectedLabel===n,className:"qr-label-picker__option"+(m.selectedLabel===n?" qr-label-picker__option--active":""),onClick:()=>f({type:"SET_LABEL",label:n}),children:[r("span",{className:"qr-label-picker__icon",children:r(U,{label:n})}),r("span",{children:a})]},n))}),"other"===m.selectedLabel&&e("div",{className:"qr-label-text-field",children:[e("label",{className:"qr-field__label",htmlFor:"qr-labelText",children:["Label name",r("span",{className:"qr-required","aria-hidden":"true",children:"*"})]}),r("input",{id:"qr-labelText",type:"text",className:"qr-field__input",placeholder:"e.g. Friend's home, Gym",value:m.labelText,onChange:e=>f({type:"SET_LABEL_TEXT",value:e.target.value}),maxLength:64,required:!0,"aria-required":"true",autoComplete:"off"})]})]}),e("fieldset",{className:"qr-fieldset",children:[e("legend",{className:"qr-fieldset__legend",children:[r("span",{className:"qr-fieldset__icon","aria-hidden":"true",children:"🏠"}),"Your details"]}),e("div",{className:"qr-fields-grid",children:[e("div",{className:"qr-field qr-field--full",children:[e("label",{className:"qr-field__label",htmlFor:"qr-flatNumber",children:["Flat / House Number",r("span",{className:"qr-required","aria-hidden":"true",children:"*"})]}),r("input",{id:"qr-flatNumber",type:"text",className:"qr-field__input",placeholder:"e.g. 4B, Flat 201, House No. 12",value:m.fields.flatNumber,onChange:e=>f({type:"SET_FIELD",key:"flatNumber",value:e.target.value}),autoComplete:"address-line1",required:!0,"aria-required":"true"})]}),e("div",{className:"qr-field",children:[e("label",{className:"qr-field__label",htmlFor:"qr-floorNumber",children:["Floor",r("span",{className:"qr-optional",children:"optional"})]}),r("input",{id:"qr-floorNumber",type:"text",className:"qr-field__input",placeholder:"e.g. 3rd, Ground",value:m.fields.floorNumber,onChange:e=>f({type:"SET_FIELD",key:"floorNumber",value:e.target.value})})]}),e("div",{className:"qr-field",children:[e("label",{className:"qr-field__label",htmlFor:"qr-buildingName",children:["Building / Society",r("span",{className:"qr-optional",children:"optional"})]}),r("input",{id:"qr-buildingName",type:"text",className:"qr-field__input",placeholder:"e.g. Sunshine Apts, DDA Colony",value:m.fields.buildingName,onChange:e=>f({type:"SET_FIELD",key:"buildingName",value:e.target.value}),autoComplete:"address-line2"})]}),e("div",{className:"qr-field qr-field--full",children:[e("label",{className:"qr-field__label",htmlFor:"qr-streetName",children:["Street / Area",r("span",{className:"qr-optional",children:"optional"})]}),r("input",{id:"qr-streetName",type:"text",className:"qr-field__input",placeholder:"e.g. MG Road, Sector 12",value:m.fields.streetName,onChange:e=>f({type:"SET_FIELD",key:"streetName",value:e.target.value}),autoComplete:"address-level3"})]})]})]}),e("div",{className:"qr-form-actions",children:[e("button",{type:"button",className:"qr-btn qr-btn--ghost",onClick:h,children:[r("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:r("path",{d:"M19 12H5M12 19l-7-7 7-7"})}),"Adjust Pin"]}),r("button",{type:"submit",className:"qr-btn qr-btn--primary qr-btn--grow",disabled:m.submitting||!m.fields.flatNumber.trim()||"other"===m.selectedLabel&&!m.labelText.trim(),children:m.submitting?e(n,{children:[r("span",{className:"qr-spinner qr-spinner--sm","aria-hidden":"true"}),"Saving…"]}):e(n,{children:["Save Address",r("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:r("path",{d:"M20 6L9 17l-5-5"})})]})})]})]})]})}
138
- async function W(e,r){const n=await fetch(`${e.functionBaseUrl}/checkout-otp`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"send",mobile:r,merchant_id:e.merchantId})}),a=await n.json().catch(()=>({}))
139
- if(!n.ok||!a.success)throw new Error(a.error??"Failed to send OTP. Please try again.")}async function V(e,r,n,a){const t=await fetch(`${e.functionBaseUrl}/checkout-otp`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"verify",mobile:r,otp:n,merchant_id:e.merchantId,...a})}),i=await t.json().catch(()=>({}))
140
- if(!t.ok||!i.success)throw new Error(i.error??"Invalid or expired OTP.")
141
- return i}function z(e){return{"Content-Type":"application/json","x-session-token":e}}async function J(e,r){const n=await fetch(`${e.functionBaseUrl}/checkout-addresses`,{method:"POST",headers:z(r),body:JSON.stringify({action:"list"})}),a=await n.json().catch(()=>({}))
142
- if(!n.ok||!a.success)throw new Error(a.error??"Failed to load saved addresses.")
143
- return a.data??[]}async function H(e,r,n){const a=await fetch(`${e.functionBaseUrl}/checkout-addresses`,{method:"POST",headers:z(r),body:JSON.stringify({action:"create",address:n})}),t=await a.json().catch(()=>({}))
144
- if(!a.ok||!t.success)throw new Error(t.error??"Failed to save address.")
145
- return t.data}async function G(e,r,n){const a=await fetch(`${e.functionBaseUrl}/checkout-addresses`,{method:"POST",headers:z(r),body:JSON.stringify({action:"delete",address_id:n})}),t=await a.json().catch(()=>({}))
146
- if(!a.ok||!t.success)throw new Error(t.error??"Failed to delete address.")}async function K(e,r,n){const a=await fetch(`${e.functionBaseUrl}/checkout-addresses`,{method:"POST",headers:z(r),body:JSON.stringify({action:"set_default",address_id:n})}),t=await a.json().catch(()=>({}))
147
- if(!a.ok||!t.success)throw new Error(t.error??"Failed to set default address.")}async function Y(e,r,n){const a=await fetch(`${e.functionBaseUrl}/checkout-addresses`,{method:"POST",headers:z(r),body:JSON.stringify({action:"address_completed",data:n})}),t=await a.json().catch(()=>({}))
148
- !a.ok||t.success}async function Q(e,r){const n=await fetch(`${e.functionBaseUrl}/checkout-email-otp`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"send",email:r,merchant_id:e.merchantId})}),a=await n.json().catch(()=>({}))
149
- if(!n.ok||!a.success)throw new Error(a.error??"Failed to send OTP. Please try again.")
150
- return{reused:Boolean(a.reused)}}async function Z(e,r,n,a){const t=await fetch(`${e.functionBaseUrl}/checkout-email-otp`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"verify",email:r,code:n,merchant_id:e.merchantId,...a})}),i=await t.json().catch(()=>({}))
151
- if(!t.ok||!i.success)throw new Error(i.error??"Invalid or expired code.")
152
- return i}async function X(e,r,n,a){const t={action:"cod_eligibility",pincode:n}
153
- void 0!==a&&(t.cart_total_paise=a)
154
- const i=await fetch(`${e.functionBaseUrl}/checkout-addresses`,{method:"POST",headers:z(r),body:JSON.stringify(t)}),o=await i.json().catch(()=>({}))
155
- if(!i.ok||!o.success)throw new Error(o.error??"Failed to check COD eligibility.")
156
- return o.data}async function ee(e,r,n){try{const a={"Content-Type":"application/json"}
157
- n&&(a["x-session-token"]=n),await fetch(`${e.functionBaseUrl}/checkout-funnel-events`,{method:"POST",headers:a,body:JSON.stringify({merchant_id:e.merchantId,...r})})}catch{}}async function re(e,r,n){try{await fetch(`${e.functionBaseUrl}/checkout-addresses`,{method:"POST",headers:z(r),body:JSON.stringify({action:"abandon",last_step:n})})}catch{}}async function ne(e,r){const n=await fetch(`${e.functionBaseUrl}/checkout-offers`,{method:"GET",headers:z(r)}),a=await n.json().catch(()=>({}))
158
- return n.ok&&a.success?a.data??null:null}async function ae(e,r,n){const a=await fetch(`${e.functionBaseUrl}/checkout-payment`,{method:"POST",headers:z(r),body:JSON.stringify({action:"create_order",amount_paise:n})}),t=await a.json().catch(()=>({}))
159
- if(!a.ok||!t.success)throw new Error(t.error??"Failed to create payment order.")
160
- return t.data}async function te(e,r,n){const a=await fetch(`${e.functionBaseUrl}/checkout-payment`,{method:"POST",headers:z(r),body:JSON.stringify({action:"verify",...n})}),t=await a.json().catch(()=>({}))
161
- if(!a.ok||!t.success)throw new Error(t.error??"Payment verification failed.")
162
- return{payment_method:t.payment_method}}async function ie(e,r){const n=await fetch(`${e.functionBaseUrl}/checkout-payment`,{method:"POST",headers:z(r),body:JSON.stringify({action:"record_cod"})}),a=await n.json().catch(()=>({}))
163
- if(!n.ok||!a.success)throw new Error(a.error??"Failed to record COD selection.")
164
- return{payment_method:a.payment_method}}async function oe(e,r){const n=await fetch(`${e}/checkout-admin?action=cod_config`,{headers:{"x-api-key":r}}),a=await n.json().catch(()=>({}))
165
- return n.ok&&a.success?{prepaid_nudge_copy:a.data.prepaid_nudge_copy,prepaid_nudge_cta_url:a.data.prepaid_nudge_cta_url}:null}const le=({onOtpSent:a,onSkip:l,functionBaseUrl:s,merchantId:d})=>{const[c,u]=t(""),[h,p]=t(!1),[m,f]=t(null),b=o(null),y=i(e=>{u(e.target.value.replace(/\D/g,"").slice(0,10)),f(null)},[]),v=i(async e=>{var r
166
- if(e.preventDefault(),10!==c.length)return f("Enter a valid 10-digit mobile number."),void(null==(r=b.current)||r.focus())
165
+ let u=null
166
+ if(y&&(null==m?void 0:m.functionBaseUrl)&&m.merchantId&&f)try{u=await Y(m,f,i,{lat:t,lng:o}),null==_||_(u)}catch{}C({type:"LOAD_SUCCESS",adminInfo:r.data.administrative_info,alternatives:r.data.alternatives||[],addressComponents:n.data.addressComponents,pincodeHasDelivery:d,serviceabilityResult:u})}catch(e){const r=e instanceof Error?e.message:"Failed to fetch address data."
167
+ C({type:"LOAD_ERROR",message:r}),null==p||p(e instanceof Error?e:new Error(r))}},[a,t,o,l,c,p,m,f,y,_])
168
+ s(()=>{x()},[x])
169
+ const E=i(e=>{var r
170
+ if(e.preventDefault(),"ready"!==k.status)return
171
+ const{adminInfo:n,selectedLocality:i,selectedLabel:l,labelText:s,fields:d}=k
172
+ if("other"===l&&!s.trim())return
173
+ if((null==(r=k.serviceabilityResult)?void 0:r.checked)&&!1===k.serviceabilityResult.serviceable&&(v??k.serviceabilityResult.block_checkout))return
174
+ const c=[d.flatNumber,d.floorNumber?`Floor ${d.floorNumber}`:"",d.buildingName,d.streetName,i,n.district,n.state,n.pincode].filter(Boolean),h={digipin:a,lat:t,lng:o,state:n.state,district:n.district,division:n.division,locality:i,pincode:n.pincode,delivery:n.delivery,country:n.country??"India",...d,formattedAddress:c.join(", "),label:l,..."other"===l?{labelText:s.trim()}:{}}
175
+ C({type:"SUBMIT_START"})
176
+ try{u(h)}finally{C({type:"SUBMIT_END"})}},[k,a,t,o,u,v]),I="ready"===k.status&&(null==(g=k.serviceabilityResult)?void 0:g.checked)&&!1===k.serviceabilityResult.serviceable&&(v??k.serviceabilityResult.block_checkout),P="ready"===k.status&&(null==(q=k.serviceabilityResult)?void 0:q.checked)&&!1===k.serviceabilityResult.serviceable,B="ready"===k.status&&!k.pincodeHasDelivery&&!0!==(null==(w=k.serviceabilityResult)?void 0:w.serviceable)&&!P&&((null==(N=k.serviceabilityResult)?void 0:N.show_india_post_delivery_warning)??b)
177
+ return e("div",{className:"qr-form-wrapper",children:[e("div",{className:"qr-step-header",children:[r("button",{type:"button",className:"qr-back-btn",onClick:h,"aria-label":"Back to map",children:r("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:r("path",{d:"M19 12H5M12 19l-7-7 7-7"})})}),r("div",{className:"qr-step-badge",children:"2"}),e("div",{className:"qr-step-text",children:[r("span",{className:"qr-step-title",children:"Add Address Details"}),r("span",{className:"qr-step-sub",children:"Flat number and building info"})]})]}),e("div",{className:"qr-form-digipin-strip",children:[e("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r("path",{d:"M21 10c0 7-9 13-9 13S3 17 3 10a9 9 0 0118 0z"}),r("circle",{cx:"12",cy:"10",r:"3"})]}),r("span",{className:"qr-form-digipin-strip__label",children:"DigiPin"}),r("span",{className:"qr-form-digipin-strip__code",children:a})]}),"loading"===k.status&&e("div",{className:"qr-loading-state","aria-busy":"true","aria-label":"Fetching address details",children:[r("div",{className:"qr-spinner qr-spinner--lg","aria-hidden":"true"}),r("p",{className:"qr-loading-state__text",children:"Fetching address details…"})]}),"error"===k.status&&e("div",{className:"qr-error-state",role:"alert",children:[r("div",{className:"qr-error-state__icon","aria-hidden":"true",children:"⚠"}),r("p",{className:"qr-error-state__msg",children:k.message}),r("button",{type:"button",className:"qr-btn qr-btn--secondary qr-btn--sm",onClick:()=>{x()},children:"Retry"})]}),"ready"===k.status&&e("form",{onSubmit:E,className:"qr-form",noValidate:!0,children:[e("fieldset",{className:"qr-fieldset",children:[e("legend",{className:"qr-fieldset__legend",children:[r("span",{className:"qr-fieldset__icon","aria-hidden":"true",children:"📍"}),"Auto-detected from your digipin"]}),e("div",{className:"qr-auto-grid",children:[e("div",{className:"qr-auto-row",children:[r("span",{className:"qr-auto-row__label",children:"State"}),r("span",{className:"qr-auto-row__value",children:k.adminInfo.state})]}),e("div",{className:"qr-auto-row",children:[r("span",{className:"qr-auto-row__label",children:"District"}),r("span",{className:"qr-auto-row__value",children:k.adminInfo.district})]}),e("div",{className:"qr-auto-row qr-auto-row--full",children:[r("span",{className:"qr-auto-row__label",children:"Locality"}),k.localityOptions.length>1?r("select",{className:"qr-auto-row__select",value:k.selectedLocality,onChange:e=>C({type:"SET_LOCALITY",locality:e.target.value}),"aria-label":"Select locality",children:k.localityOptions.map(e=>r("option",{value:e,children:e},e))}):r("span",{className:"qr-auto-row__value",children:k.selectedLocality})]}),e("div",{className:"qr-auto-row",children:[r("span",{className:"qr-auto-row__label",children:"Pincode"}),r("span",{className:"qr-auto-row__value qr-auto-row__value--pin",children:k.adminInfo.pincode})]})]})]}),P&&k.serviceabilityResult&&e("div",{className:"qr-pincode-banner "+(I?"qr-pincode-banner--error":"qr-pincode-banner--warning"),role:I?"alert":"status","aria-live":"polite",children:[r("span",{className:"qr-pincode-banner__icon","aria-hidden":"true",children:I?"!":"⚠"}),e("div",{className:"qr-pincode-banner__text",children:[r("strong",{children:I?"Delivery unavailable":"Delivery may be limited"}),r("span",{children:k.serviceabilityResult.message??(I?"This seller does not currently deliver to this pincode.":"This seller recommends confirming delivery availability for this pincode.")})]})]}),B&&e("div",{className:"qr-pincode-banner qr-pincode-banner--info",role:"status","aria-live":"polite",children:[r("span",{className:"qr-pincode-banner__icon","aria-hidden":"true",children:"i"}),e("div",{className:"qr-pincode-banner__text",children:[r("strong",{children:"India Post: no home-delivery office"}),r("span",{children:"Courier partners may still deliver to this pincode."})]})]}),e("fieldset",{className:"qr-fieldset",children:[r("legend",{className:"qr-fieldset__legend qr-fieldset__legend--compact",children:"Save as"}),r("div",{className:"qr-label-picker",role:"radiogroup","aria-label":"Address label",children:[{value:"home",title:"Home"},{value:"work",title:"Work"},{value:"other",title:"Other"}].map(({value:n,title:a})=>e("button",{type:"button",role:"radio","aria-checked":k.selectedLabel===n,className:"qr-label-picker__option"+(k.selectedLabel===n?" qr-label-picker__option--active":""),onClick:()=>C({type:"SET_LABEL",label:n}),children:[r("span",{className:"qr-label-picker__icon",children:r(le,{label:n})}),r("span",{children:a})]},n))}),"other"===k.selectedLabel&&e("div",{className:"qr-label-text-field",children:[e("label",{className:"qr-field__label",htmlFor:"qr-labelText",children:["Label name",r("span",{className:"qr-required","aria-hidden":"true",children:"*"})]}),r("input",{id:"qr-labelText",type:"text",className:"qr-field__input",placeholder:"e.g. Friend's home, Gym",value:k.labelText,onChange:e=>C({type:"SET_LABEL_TEXT",value:e.target.value}),maxLength:64,required:!0,"aria-required":"true",autoComplete:"off"})]})]}),e("fieldset",{className:"qr-fieldset",children:[e("legend",{className:"qr-fieldset__legend",children:[r("span",{className:"qr-fieldset__icon","aria-hidden":"true",children:"🏠"}),"Your details"]}),e("div",{className:"qr-fields-grid",children:[e("div",{className:"qr-field qr-field--full",children:[e("label",{className:"qr-field__label",htmlFor:"qr-flatNumber",children:["Flat / House Number",r("span",{className:"qr-required","aria-hidden":"true",children:"*"})]}),r("input",{id:"qr-flatNumber",type:"text",className:"qr-field__input",placeholder:"e.g. 4B, Flat 201, House No. 12",value:k.fields.flatNumber,onChange:e=>C({type:"SET_FIELD",key:"flatNumber",value:e.target.value}),autoComplete:"address-line1",required:!0,"aria-required":"true"})]}),e("div",{className:"qr-field",children:[e("label",{className:"qr-field__label",htmlFor:"qr-floorNumber",children:["Floor",r("span",{className:"qr-optional",children:"optional"})]}),r("input",{id:"qr-floorNumber",type:"text",className:"qr-field__input",placeholder:"e.g. 3rd, Ground",value:k.fields.floorNumber,onChange:e=>C({type:"SET_FIELD",key:"floorNumber",value:e.target.value})})]}),e("div",{className:"qr-field",children:[e("label",{className:"qr-field__label",htmlFor:"qr-buildingName",children:["Building / Society",r("span",{className:"qr-optional",children:"optional"})]}),r("input",{id:"qr-buildingName",type:"text",className:"qr-field__input",placeholder:"e.g. Sunshine Apts, DDA Colony",value:k.fields.buildingName,onChange:e=>C({type:"SET_FIELD",key:"buildingName",value:e.target.value}),autoComplete:"address-line2"})]}),e("div",{className:"qr-field qr-field--full",children:[e("label",{className:"qr-field__label",htmlFor:"qr-streetName",children:["Street / Area",r("span",{className:"qr-optional",children:"optional"})]}),r("input",{id:"qr-streetName",type:"text",className:"qr-field__input",placeholder:"e.g. MG Road, Sector 12",value:k.fields.streetName,onChange:e=>C({type:"SET_FIELD",key:"streetName",value:e.target.value}),autoComplete:"address-level3"})]})]})]}),e("div",{className:"qr-form-actions",children:[e("button",{type:"button",className:"qr-btn qr-btn--ghost",onClick:h,children:[r("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:r("path",{d:"M19 12H5M12 19l-7-7 7-7"})}),"Adjust Pin"]}),r("button",{type:"submit",className:"qr-btn qr-btn--primary qr-btn--grow",disabled:k.submitting||!k.fields.flatNumber.trim()||"other"===k.selectedLabel&&!k.labelText.trim()||Boolean(I),children:k.submitting?e(n,{children:[r("span",{className:"qr-spinner qr-spinner--sm","aria-hidden":"true"}),"Saving…"]}):e(n,{children:["Save Address",r("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:r("path",{d:"M20 6L9 17l-5-5"})})]})})]})]})]})},ue=({onOtpSent:a,onSkip:l,functionBaseUrl:s,merchantId:d})=>{const[c,u]=t(""),[h,p]=t(!1),[m,f]=t(null),y=o(null),b=i(e=>{u(e.target.value.replace(/\D/g,"").slice(0,10)),f(null)},[]),v=i(async e=>{var r
178
+ if(e.preventDefault(),10!==c.length)return f("Enter a valid 10-digit mobile number."),void(null==(r=y.current)||r.focus())
167
179
  p(!0),f(null)
168
- try{await W({functionBaseUrl:s,merchantId:d},`+91${c}`),a(`+91${c}`)}catch(e){f(e instanceof Error?e.message:"Failed to send OTP. Please try again.")}finally{p(!1)}},[c,s,d,a])
169
- return e("div",{className:"qr-auth-step",children:[r("div",{className:"qr-auth-step__icon","aria-hidden":"true",children:e("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[r("circle",{cx:"24",cy:"24",r:"24",fill:"var(--qr-primary-light)"}),r("path",{d:"M16 14h4l2 5-2.5 1.5a11 11 0 005 5L26 23l5 2v4c0 1.1-.9 2-2 2A18 18 0 0114 16c0-1.1.9-2 2-2z",stroke:"var(--qr-primary)",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})]})}),r("h3",{className:"qr-auth-step__title",children:"Faster checkout"}),r("p",{className:"qr-auth-step__sub",children:"Enter your mobile to load saved addresses"}),e("form",{onSubmit:v,noValidate:!0,children:[e("div",{className:"qr-phone-field"+(m?" qr-phone-field--error":""),children:[r("span",{className:"qr-phone-field__prefix","aria-hidden":"true",children:"+91"}),r("input",{ref:b,type:"tel",inputMode:"numeric",className:"qr-phone-field__input",placeholder:"98765 43210",value:c,onChange:y,maxLength:10,autoComplete:"tel-national","aria-label":"Mobile number","aria-describedby":m?"qr-phone-error":void 0,"aria-invalid":!!m,disabled:h})]}),m&&r("p",{id:"qr-phone-error",className:"qr-auth-step__error",role:"alert",children:m}),r("button",{type:"submit",className:"qr-btn qr-btn--primary qr-btn--full",disabled:h||10!==c.length,children:h?r("span",{className:"qr-spinner qr-spinner--sm","aria-hidden":"true"}):e(n,{children:["Send OTP",r("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:r("path",{d:"M5 12h14M12 5l7 7-7 7"})})]})})]}),r("button",{type:"button",className:"qr-auth-step__skip",onClick:l,disabled:h,children:"Skip, enter address manually"})]})}
170
- function se(e){const r=e.replace(/\D/g,"")
171
- return r.length<4?e:`+91 ${r.slice(2,7)} **${r.slice(-3)}`}const de=({mobile:n,onVerified:a,onBack:l,functionBaseUrl:d,merchantId:c,sessionContext:u})=>{const[h,p]=t(Array(6).fill("")),[m,f]=t(!1),[b,y]=t(null),[v,_]=t(30),[g,q]=t(!1),w=o([]),N=o(null)
180
+ try{await U({functionBaseUrl:s,merchantId:d},`+91${c}`),a(`+91${c}`)}catch(e){f(e instanceof Error?e.message:"Failed to send OTP. Please try again.")}finally{p(!1)}},[c,s,d,a])
181
+ return e("div",{className:"qr-auth-step",children:[r("div",{className:"qr-auth-step__icon","aria-hidden":"true",children:e("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[r("circle",{cx:"24",cy:"24",r:"24",fill:"var(--qr-primary-light)"}),r("path",{d:"M16 14h4l2 5-2.5 1.5a11 11 0 005 5L26 23l5 2v4c0 1.1-.9 2-2 2A18 18 0 0114 16c0-1.1.9-2 2-2z",stroke:"var(--qr-primary)",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})]})}),r("h3",{className:"qr-auth-step__title",children:"Faster checkout"}),r("p",{className:"qr-auth-step__sub",children:"Enter your mobile to load saved addresses"}),e("form",{onSubmit:v,noValidate:!0,children:[e("div",{className:"qr-phone-field"+(m?" qr-phone-field--error":""),children:[r("span",{className:"qr-phone-field__prefix","aria-hidden":"true",children:"+91"}),r("input",{ref:y,type:"tel",inputMode:"numeric",className:"qr-phone-field__input",placeholder:"98765 43210",value:c,onChange:b,maxLength:10,autoComplete:"tel-national","aria-label":"Mobile number","aria-describedby":m?"qr-phone-error":void 0,"aria-invalid":!!m,disabled:h})]}),m&&r("p",{id:"qr-phone-error",className:"qr-auth-step__error",role:"alert",children:m}),r("button",{type:"submit",className:"qr-btn qr-btn--primary qr-btn--full",disabled:h||10!==c.length,children:h?r("span",{className:"qr-spinner qr-spinner--sm","aria-hidden":"true"}):e(n,{children:["Send OTP",r("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:r("path",{d:"M5 12h14M12 5l7 7-7 7"})})]})})]}),r("button",{type:"button",className:"qr-auth-step__skip",onClick:l,disabled:h,children:"Skip, enter address manually"})]})}
182
+ function he(e){const r=e.replace(/\D/g,"")
183
+ return r.length<4?e:`+91 ${r.slice(2,7)} **${r.slice(-3)}`}const pe=({mobile:n,onVerified:a,onBack:l,functionBaseUrl:d,merchantId:c,sessionContext:u})=>{const[h,p]=t(Array(6).fill("")),[m,f]=t(!1),[y,b]=t(null),[v,_]=t(30),[g,q]=t(!1),w=o([]),N=o(null)
172
184
  s(()=>(N.current=setInterval(()=>{_(e=>e<=1?(clearInterval(N.current),0):e-1)},1e3),()=>{N.current&&clearInterval(N.current)}),[])
173
185
  const k=e=>{var r
174
- null==(r=w.current[e])||r.focus()},x=i((e,r)=>{const n=r.replace(/\D/g,"").slice(-1)
175
- y(null),p(r=>{const a=[...r]
176
- return a[e]=n,a}),n&&e<5&&k(e+1)},[]),C=i((e,r)=>{"Backspace"===r.key?h[e]?p(r=>{const n=[...r]
186
+ null==(r=w.current[e])||r.focus()},C=i((e,r)=>{const n=r.replace(/\D/g,"").slice(-1)
187
+ b(null),p(r=>{const a=[...r]
188
+ return a[e]=n,a}),n&&e<5&&k(e+1)},[]),x=i((e,r)=>{"Backspace"===r.key?h[e]?p(r=>{const n=[...r]
177
189
  return n[e]="",n}):e>0&&(p(r=>{const n=[...r]
178
190
  return n[e-1]="",n}),k(e-1)):"ArrowLeft"===r.key&&e>0?k(e-1):"ArrowRight"===r.key&&e<5&&k(e+1)},[h]),E=i(e=>{e.preventDefault()
179
191
  const r=e.clipboardData.getData("text").replace(/\D/g,"").slice(0,6)
180
192
  if(!r)return
181
193
  const n=Array(6).fill("")
182
- r.split("").forEach((e,r)=>{n[r]=e}),p(n),y(null),k(Math.min(r.length,5))},[]),S=h.join(""),L=6===S.length&&!h.includes(""),T=i(async()=>{if(L){f(!0),y(null)
183
- try{const e=await V({functionBaseUrl:d,merchantId:c},n,S,u)
184
- a(e.session_token,e.buyer_id,e.session_id)}catch(e){y(e instanceof Error?e.message:"Verification failed. Please try again."),p(Array(6).fill("")),k(0)}finally{f(!1)}}},[L,S,n,d,c,a,u])
194
+ r.split("").forEach((e,r)=>{n[r]=e}),p(n),b(null),k(Math.min(r.length,5))},[]),S=h.join(""),L=6===S.length&&!h.includes(""),T=i(async()=>{if(L){f(!0),b(null)
195
+ try{const e=await F({functionBaseUrl:d,merchantId:c},n,S,u)
196
+ a(e.session_token,e.buyer_id,e.session_id)}catch(e){b(e instanceof Error?e.message:"Verification failed. Please try again."),p(Array(6).fill("")),k(0)}finally{f(!1)}}},[L,S,n,d,c,a,u])
185
197
  s(()=>{L&&!m&&T()},[L])
186
- const I=i(async()=>{if(!(v>0||g)){q(!0),y(null),p(Array(6).fill(""))
187
- try{await W({functionBaseUrl:d,merchantId:c},n),_(30),N.current=setInterval(()=>{_(e=>e<=1?(clearInterval(N.current),0):e-1)},1e3),k(0)}catch(e){y(e instanceof Error?e.message:"Failed to resend OTP.")}finally{q(!1)}}},[v,g,d,c,n])
188
- return e("div",{className:"qr-auth-step",children:[r("button",{type:"button",className:"qr-back-btn qr-back-btn--auth",onClick:l,disabled:m,children:r("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:r("path",{d:"M19 12H5M12 5l-7 7 7 7"})})}),r("div",{className:"qr-auth-step__icon","aria-hidden":"true",children:e("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[r("circle",{cx:"24",cy:"24",r:"24",fill:"var(--qr-primary-light)"}),r("rect",{x:"13",y:"16",width:"22",height:"16",rx:"2",stroke:"var(--qr-primary)",strokeWidth:"1.8",fill:"none"}),r("path",{d:"M13 22h22",stroke:"var(--qr-primary)",strokeWidth:"1.8"}),r("circle",{cx:"18",cy:"29",r:"1.5",fill:"var(--qr-primary)"}),r("circle",{cx:"24",cy:"29",r:"1.5",fill:"var(--qr-primary)"}),r("circle",{cx:"30",cy:"29",r:"1.5",fill:"var(--qr-primary)"})]})}),r("h3",{className:"qr-auth-step__title",children:"Enter OTP"}),e("p",{className:"qr-auth-step__sub",children:["Sent to ",r("strong",{children:se(n)})]}),r("div",{className:"qr-otp-boxes",role:"group","aria-label":"Enter one-time password",children:h.map((e,n)=>r("input",{ref:e=>{w.current[n]=e},type:"text",inputMode:"numeric",maxLength:1,className:`qr-otp-box${e?" qr-otp-box--filled":""}${b?" qr-otp-box--error":""}`,value:e,onChange:e=>x(n,e.target.value),onKeyDown:e=>C(n,e),onPaste:E,onFocus:e=>e.target.select(),"aria-label":`OTP digit ${n+1}`,disabled:m,autoComplete:0===n?"one-time-code":"off"},n))}),b&&r("p",{className:"qr-auth-step__error",role:"alert",children:b}),r("button",{type:"button",className:"qr-btn qr-btn--primary qr-btn--full",onClick:T,disabled:!L||m,children:m?r("span",{className:"qr-spinner qr-spinner--sm","aria-hidden":"true"}):"Verify OTP"}),r("p",{className:"qr-auth-step__resend",children:v>0?e("span",{children:["Resend OTP in ",v,"s"]}):r("button",{type:"button",className:"qr-link-btn",onClick:I,disabled:g,children:g?"Sending…":"Resend OTP"})})]})},ce=()=>e("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[r("path",{d:"M3 9.5L12 3l9 6.5V20a1 1 0 01-1 1H4a1 1 0 01-1-1V9.5z"}),r("path",{d:"M9 21V12h6v9"})]}),ue=()=>e("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[r("rect",{x:"2",y:"7",width:"20",height:"14",rx:"2"}),r("path",{d:"M16 7V5a2 2 0 00-2-2h-4a2 2 0 00-2 2v2"})]}),he=()=>e("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[r("path",{d:"M12 2C8.134 2 5 5.134 5 9c0 5.25 7 13 7 13s7-7.75 7-13c0-3.866-3.134-7-7-7z"}),r("circle",{cx:"12",cy:"9",r:"2.5"})]})
189
- function pe({label:e}){return r("home"===e?ce:"work"===e?ue:he,{})}function me(e){var r
198
+ const I=i(async()=>{if(!(v>0||g)){q(!0),b(null),p(Array(6).fill(""))
199
+ try{await U({functionBaseUrl:d,merchantId:c},n),_(30),N.current=setInterval(()=>{_(e=>e<=1?(clearInterval(N.current),0):e-1)},1e3),k(0)}catch(e){b(e instanceof Error?e.message:"Failed to resend OTP.")}finally{q(!1)}}},[v,g,d,c,n])
200
+ return e("div",{className:"qr-auth-step",children:[r("button",{type:"button",className:"qr-back-btn qr-back-btn--auth",onClick:l,disabled:m,children:r("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:r("path",{d:"M19 12H5M12 5l-7 7 7 7"})})}),r("div",{className:"qr-auth-step__icon","aria-hidden":"true",children:e("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[r("circle",{cx:"24",cy:"24",r:"24",fill:"var(--qr-primary-light)"}),r("rect",{x:"13",y:"16",width:"22",height:"16",rx:"2",stroke:"var(--qr-primary)",strokeWidth:"1.8",fill:"none"}),r("path",{d:"M13 22h22",stroke:"var(--qr-primary)",strokeWidth:"1.8"}),r("circle",{cx:"18",cy:"29",r:"1.5",fill:"var(--qr-primary)"}),r("circle",{cx:"24",cy:"29",r:"1.5",fill:"var(--qr-primary)"}),r("circle",{cx:"30",cy:"29",r:"1.5",fill:"var(--qr-primary)"})]})}),r("h3",{className:"qr-auth-step__title",children:"Enter OTP"}),e("p",{className:"qr-auth-step__sub",children:["Sent to ",r("strong",{children:he(n)})]}),r("div",{className:"qr-otp-boxes",role:"group","aria-label":"Enter one-time password",children:h.map((e,n)=>r("input",{ref:e=>{w.current[n]=e},type:"text",inputMode:"numeric",maxLength:1,className:`qr-otp-box${e?" qr-otp-box--filled":""}${y?" qr-otp-box--error":""}`,value:e,onChange:e=>C(n,e.target.value),onKeyDown:e=>x(n,e),onPaste:E,onFocus:e=>e.target.select(),"aria-label":`OTP digit ${n+1}`,disabled:m,autoComplete:0===n?"one-time-code":"off"},n))}),y&&r("p",{className:"qr-auth-step__error",role:"alert",children:y}),r("button",{type:"button",className:"qr-btn qr-btn--primary qr-btn--full",onClick:T,disabled:!L||m,children:m?r("span",{className:"qr-spinner qr-spinner--sm","aria-hidden":"true"}):"Verify OTP"}),r("p",{className:"qr-auth-step__resend",children:v>0?e("span",{children:["Resend OTP in ",v,"s"]}):r("button",{type:"button",className:"qr-link-btn",onClick:I,disabled:g,children:g?"Sending…":"Resend OTP"})})]})},me=()=>e("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[r("path",{d:"M3 9.5L12 3l9 6.5V20a1 1 0 01-1 1H4a1 1 0 01-1-1V9.5z"}),r("path",{d:"M9 21V12h6v9"})]}),fe=()=>e("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[r("rect",{x:"2",y:"7",width:"20",height:"14",rx:"2"}),r("path",{d:"M16 7V5a2 2 0 00-2-2h-4a2 2 0 00-2 2v2"})]}),ye=()=>e("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[r("path",{d:"M12 2C8.134 2 5 5.134 5 9c0 5.25 7 13 7 13s7-7.75 7-13c0-3.866-3.134-7-7-7z"}),r("circle",{cx:"12",cy:"9",r:"2.5"})]})
201
+ function be({label:e}){return r("home"===e?me:"work"===e?fe:ye,{})}function ve(e){var r
190
202
  const n=null==(r=e.label_text)?void 0:r.trim()
191
- return"other"===e.label&&n?n:e.label.charAt(0).toUpperCase()+e.label.slice(1)}function fe({address:a,onUse:t,onDelete:i,onSetDefault:o,deleting:l}){const s=[a.flat_number,a.building_name,a.street_name,a.locality,a.district,a.state,a.pincode].filter(Boolean),d=[a.flat_number,a.building_name,a.street_name].filter(Boolean).join(", "),c=[a.locality,a.district].filter(Boolean).join(", "),u=[a.state,a.pincode].filter(Boolean).join(" – "),h=s.length>0?void 0:a.locality||a.district||a.state
192
- return e("div",{className:"qr-addr-card"+(a.is_default?" qr-addr-card--default":""),children:[e("div",{className:"qr-addr-card__header",children:[r("div",{className:"qr-addr-card__label-icon",children:r(pe,{label:a.label})}),r("span",{className:"qr-addr-card__label",children:me(a)}),a.is_default&&r("span",{className:"qr-addr-card__default-badge",children:"Default"}),e("div",{className:"qr-addr-card__actions",children:[!a.is_default&&r("button",{type:"button",className:"qr-icon-btn",title:"Set as default",onClick:o,"aria-label":"Set as default address",children:r("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:r("polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"})})}),r("button",{type:"button",className:"qr-icon-btn qr-icon-btn--danger",title:"Delete address",onClick:i,disabled:l,"aria-label":"Delete address",children:l?r("span",{className:"qr-spinner qr-spinner--xs","aria-hidden":"true"}):e("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[r("polyline",{points:"3 6 5 6 21 6"}),r("path",{d:"M19 6l-1 14a2 2 0 01-2 2H8a2 2 0 01-2-2L5 6"}),r("path",{d:"M10 11v6M14 11v6"}),r("path",{d:"M9 6V4a1 1 0 011-1h4a1 1 0 011 1v2"})]})})]})]}),e("div",{className:"qr-addr-card__body",children:[h?r("p",{className:"qr-addr-card__line",children:h}):e(n,{children:[d&&r("p",{className:"qr-addr-card__line",children:d}),c&&r("p",{className:"qr-addr-card__line qr-addr-card__line--muted",children:c}),u&&r("p",{className:"qr-addr-card__line qr-addr-card__line--muted",children:u})]}),e("div",{className:"qr-addr-card__meta",children:[e("span",{className:"qr-digipin-badge qr-digipin-badge--inline qr-digipin-badge--sm",children:[r("span",{className:"qr-digipin-badge__label",children:"DigiPin"}),r("span",{className:"qr-digipin-badge__code",children:a.digipin})]}),a.saved_at_brand&&e("span",{className:"qr-addr-card__brand-chip",title:`First saved at ${a.saved_at_brand}`,children:[r("svg",{viewBox:"0 0 12 12",fill:"currentColor","aria-hidden":"true",children:r("path",{d:"M1 1h4.5l5.5 5.5-4.5 4.5L1 5.5V1zm2 1.5a.75.75 0 100 1.5.75.75 0 000-1.5z"})}),a.saved_at_brand]})]})]}),r("button",{type:"button",className:"qr-btn qr-btn--primary qr-btn--full qr-btn--sm",onClick:t,children:"Deliver here"})]})}const be=({sessionToken:n,functionBaseUrl:a,merchantId:o,onSelectAddress:l,onAddNew:d})=>{const[c,u]=t([]),[h,p]=t(!0),[m,f]=t(null),[b,y]=t(null),v={functionBaseUrl:a,merchantId:o},_=i(async()=>{p(!0),f(null)
193
- try{const e=await J(v,n)
203
+ return"other"===e.label&&n?n:e.label.charAt(0).toUpperCase()+e.label.slice(1)}function _e({address:a,onUse:t,onDelete:i,onSetDefault:o,deleting:l}){const s=[a.flat_number,a.building_name,a.street_name,a.locality,a.district,a.state,a.pincode].filter(Boolean),d=[a.flat_number,a.building_name,a.street_name].filter(Boolean).join(", "),c=[a.locality,a.district].filter(Boolean).join(", "),u=[a.state,a.pincode].filter(Boolean).join(" – "),h=s.length>0?void 0:a.locality||a.district||a.state
204
+ return e("div",{className:"qr-addr-card"+(a.is_default?" qr-addr-card--default":""),children:[e("div",{className:"qr-addr-card__header",children:[r("div",{className:"qr-addr-card__label-icon",children:r(be,{label:a.label})}),r("span",{className:"qr-addr-card__label",children:ve(a)}),a.is_default&&r("span",{className:"qr-addr-card__default-badge",children:"Default"}),e("div",{className:"qr-addr-card__actions",children:[!a.is_default&&r("button",{type:"button",className:"qr-icon-btn",title:"Set as default",onClick:o,"aria-label":"Set as default address",children:r("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:r("polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"})})}),r("button",{type:"button",className:"qr-icon-btn qr-icon-btn--danger",title:"Delete address",onClick:i,disabled:l,"aria-label":"Delete address",children:l?r("span",{className:"qr-spinner qr-spinner--xs","aria-hidden":"true"}):e("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[r("polyline",{points:"3 6 5 6 21 6"}),r("path",{d:"M19 6l-1 14a2 2 0 01-2 2H8a2 2 0 01-2-2L5 6"}),r("path",{d:"M10 11v6M14 11v6"}),r("path",{d:"M9 6V4a1 1 0 011-1h4a1 1 0 011 1v2"})]})})]})]}),e("div",{className:"qr-addr-card__body",children:[h?r("p",{className:"qr-addr-card__line",children:h}):e(n,{children:[d&&r("p",{className:"qr-addr-card__line",children:d}),c&&r("p",{className:"qr-addr-card__line qr-addr-card__line--muted",children:c}),u&&r("p",{className:"qr-addr-card__line qr-addr-card__line--muted",children:u})]}),e("div",{className:"qr-addr-card__meta",children:[e("span",{className:"qr-digipin-badge qr-digipin-badge--inline qr-digipin-badge--sm",children:[r("span",{className:"qr-digipin-badge__label",children:"DigiPin"}),r("span",{className:"qr-digipin-badge__code",children:a.digipin})]}),a.saved_at_brand&&e("span",{className:"qr-addr-card__brand-chip",title:`First saved at ${a.saved_at_brand}`,children:[r("svg",{viewBox:"0 0 12 12",fill:"currentColor","aria-hidden":"true",children:r("path",{d:"M1 1h4.5l5.5 5.5-4.5 4.5L1 5.5V1zm2 1.5a.75.75 0 100 1.5.75.75 0 000-1.5z"})}),a.saved_at_brand]})]})]}),r("button",{type:"button",className:"qr-btn qr-btn--primary qr-btn--full qr-btn--sm",onClick:t,children:"Deliver here"})]})}const ge=({sessionToken:n,functionBaseUrl:a,merchantId:o,onSelectAddress:l,onAddNew:d})=>{const[c,u]=t([]),[h,p]=t(!0),[m,f]=t(null),[y,b]=t(null),v={functionBaseUrl:a,merchantId:o},_=i(async()=>{p(!0),f(null)
205
+ try{const e=await j(v,n)
194
206
  if(0===e.length)return void d()
195
207
  u(e)}catch(e){f(e instanceof Error?e.message:"Failed to load addresses.")}finally{p(!1)}},[n])
196
208
  s(()=>{_()},[_])
197
- const g=i(async e=>{y(e)
198
- try{await G(v,n,e),u(r=>{const n=r.filter(r=>r.id!==e)
199
- return 0===n.length&&d(),n})}catch(e){f(e instanceof Error?e.message:"Failed to delete address.")}finally{y(null)}},[n,d]),q=i(async e=>{try{await K(v,n,e),u(r=>r.map(r=>({...r,is_default:r.id===e})))}catch(e){f(e instanceof Error?e.message:"Failed to set default.")}},[n])
200
- return h?r("div",{className:"qr-saved-step",children:r("div",{className:"qr-saved-step__loading","aria-live":"polite",children:r("span",{className:"qr-spinner","aria-label":"Loading addresses"})})}):m&&0===c.length?e("div",{className:"qr-saved-step",children:[r("p",{className:"qr-auth-step__error",role:"alert",children:m}),r("button",{type:"button",className:"qr-btn qr-btn--ghost qr-btn--full",onClick:_,children:"Retry"}),r("button",{type:"button",className:"qr-auth-step__skip",onClick:d,children:"Enter address manually"})]}):e("div",{className:"qr-saved-step",children:[e("div",{className:"qr-step-header",children:[r("div",{className:"qr-step-badge qr-step-badge--saved",children:e("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r("path",{d:"M12 2C8.134 2 5 5.134 5 9c0 5.25 7 13 7 13s7-7.75 7-13c0-3.866-3.134-7-7-7z"}),r("circle",{cx:"12",cy:"9",r:"2.5"})]})}),e("div",{className:"qr-step-text",children:[r("span",{className:"qr-step-title",children:"Saved Addresses"}),r("span",{className:"qr-step-sub",children:"Pick one or add a new location"})]})]}),m&&r("p",{className:"qr-auth-step__error",role:"alert",children:m}),r("div",{className:"qr-saved-step__list",children:c.map(e=>r(fe,{address:e,onUse:()=>l(e),onDelete:()=>g(e.id),onSetDefault:()=>q(e.id),deleting:b===e.id},e.id))}),e("button",{type:"button",className:"qr-btn qr-btn--ghost qr-btn--full",onClick:d,children:[r("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:r("path",{d:"M12 5v14M5 12h14"})}),"Add new address"]})]})},ye=({checkoutConfig:n,sessionToken:a,pincode:i,cartTotalPaise:o,theme:l="light",onCodAllowedChange:d})=>{const[c,u]=t("loading"),[h,p]=t(!1),[m,f]=t()
209
+ const g=i(async e=>{b(e)
210
+ try{await z(v,n,e),u(r=>{const n=r.filter(r=>r.id!==e)
211
+ return 0===n.length&&d(),n})}catch(e){f(e instanceof Error?e.message:"Failed to delete address.")}finally{b(null)}},[n,d]),q=i(async e=>{try{await V(v,n,e),u(r=>r.map(r=>({...r,is_default:r.id===e})))}catch(e){f(e instanceof Error?e.message:"Failed to set default.")}},[n])
212
+ return h?r("div",{className:"qr-saved-step",children:r("div",{className:"qr-saved-step__loading","aria-live":"polite",children:r("span",{className:"qr-spinner","aria-label":"Loading addresses"})})}):m&&0===c.length?e("div",{className:"qr-saved-step",children:[r("p",{className:"qr-auth-step__error",role:"alert",children:m}),r("button",{type:"button",className:"qr-btn qr-btn--ghost qr-btn--full",onClick:_,children:"Retry"}),r("button",{type:"button",className:"qr-auth-step__skip",onClick:d,children:"Enter address manually"})]}):e("div",{className:"qr-saved-step",children:[e("div",{className:"qr-step-header",children:[r("div",{className:"qr-step-badge qr-step-badge--saved",children:e("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r("path",{d:"M12 2C8.134 2 5 5.134 5 9c0 5.25 7 13 7 13s7-7.75 7-13c0-3.866-3.134-7-7-7z"}),r("circle",{cx:"12",cy:"9",r:"2.5"})]})}),e("div",{className:"qr-step-text",children:[r("span",{className:"qr-step-title",children:"Saved Addresses"}),r("span",{className:"qr-step-sub",children:"Pick one or add a new location"})]})]}),m&&r("p",{className:"qr-auth-step__error",role:"alert",children:m}),r("div",{className:"qr-saved-step__list",children:c.map(e=>r(_e,{address:e,onUse:()=>l(e),onDelete:()=>g(e.id),onSetDefault:()=>q(e.id),deleting:y===e.id},e.id))}),e("button",{type:"button",className:"qr-btn qr-btn--ghost qr-btn--full",onClick:d,children:[r("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:r("path",{d:"M12 5v14M5 12h14"})}),"Add new address"]})]})},qe=({checkoutConfig:n,sessionToken:a,pincode:i,cartTotalPaise:o,theme:l="light",onCodAllowedChange:d})=>{const[c,u]=t("loading"),[h,p]=t(!1),[m,f]=t()
201
213
  return s(()=>{let e=!1
202
- return u("loading"),(async()=>{try{const r=await X(n,a,i,o)
214
+ return u("loading"),(async()=>{try{const r=await K(n,a,i,o)
203
215
  if(e)return
204
216
  p(r.cod_allowed),null==d||d(r.cod_allowed),f(r.cod_allowed?void 0:r.reason?function(e){switch(e){case"cod_disabled":return"Cash on Delivery is not enabled for this store."
205
217
  case"pincode_blocked":return"COD is not available for this pincode."
206
218
  case"cart_value_exceeded":return"COD is not available for this order value."
207
219
  case"invalid_pincode":return"Enter a valid pincode to check COD."
208
- default:return"COD is not available."}}(r.reason):void 0),u("ready")}catch{e||(u("error"),p(!1),f("Could not verify COD. Try again."))}})(),()=>{e=!0}},[n,a,i,o]),e("div",{className:"qr-cod-banner"+("dark"===l?" qr-cod-banner--dark":""),role:"status","aria-live":"polite",children:[r("div",{className:"qr-cod-banner__title",children:"Cash on Delivery"}),"loading"===c&&r("p",{className:"qr-cod-banner__text qr-cod-banner__text--muted",children:"Checking availability…"}),"error"===c&&r("p",{className:"qr-cod-banner__text qr-cod-banner__text--warn",children:m}),"ready"===c&&h&&r("p",{className:"qr-cod-banner__text qr-cod-banner__text--ok",children:"Available for this address."}),"ready"===c&&!h&&m&&r("p",{className:"qr-cod-banner__text qr-cod-banner__text--muted",children:m})]})},ve=({copy:n,ctaUrl:a,theme:t="light"})=>e("div",{className:"qr-prepaid-nudge"+("dark"===t?" qr-prepaid-nudge--dark":""),role:"complementary","aria-label":"Prepaid offer",children:[r("p",{className:"qr-prepaid-nudge__copy",children:n}),a?r("a",{href:a,className:"qr-btn qr-btn--primary qr-btn--sm qr-prepaid-nudge__cta",target:"_blank",rel:"noopener noreferrer",children:"Pay online instead"}):null]}),_e="https://checkout.razorpay.com/v1/checkout.js",ge=({checkoutConfig:n,sessionToken:a,sessionId:i,amountPaise:o,enableCod:l=!1,codAllowed:d=!1,theme:c="light",onComplete:u,onBack:h,onEvent:p})=>{const[m,f]=t(!1),[b,y]=t(null),v="dark"===c
220
+ default:return"COD is not available."}}(r.reason):void 0),u("ready")}catch{e||(u("error"),p(!1),f("Could not verify COD. Try again."))}})(),()=>{e=!0}},[n,a,i,o]),e("div",{className:"qr-cod-banner"+("dark"===l?" qr-cod-banner--dark":""),role:"status","aria-live":"polite",children:[r("div",{className:"qr-cod-banner__title",children:"Cash on Delivery"}),"loading"===c&&r("p",{className:"qr-cod-banner__text qr-cod-banner__text--muted",children:"Checking availability…"}),"error"===c&&r("p",{className:"qr-cod-banner__text qr-cod-banner__text--warn",children:m}),"ready"===c&&h&&r("p",{className:"qr-cod-banner__text qr-cod-banner__text--ok",children:"Available for this address."}),"ready"===c&&!h&&m&&r("p",{className:"qr-cod-banner__text qr-cod-banner__text--muted",children:m})]})},we=({copy:n,ctaUrl:a,theme:t="light"})=>e("div",{className:"qr-prepaid-nudge"+("dark"===t?" qr-prepaid-nudge--dark":""),role:"complementary","aria-label":"Prepaid offer",children:[r("p",{className:"qr-prepaid-nudge__copy",children:n}),a?r("a",{href:a,className:"qr-btn qr-btn--primary qr-btn--sm qr-prepaid-nudge__cta",target:"_blank",rel:"noopener noreferrer",children:"Pay online instead"}):null]}),Ne="https://checkout.razorpay.com/v1/checkout.js",ke=({checkoutConfig:n,sessionToken:a,sessionId:i,amountPaise:o,enableCod:l=!1,codAllowed:d=!1,theme:c="light",onComplete:u,onBack:h,onEvent:p,orderConfirmationUrl:m})=>{const[f,y]=t(!1),[b,v]=t(null),_="dark"===c
209
221
  s(()=>{null==p||p("payment_step_viewed")},[p])
210
- const _=`₹${(o/100).toLocaleString("en-IN")}`
211
- return e("div",{className:"qr-payment-step"+(v?" qr-payment-step--dark":""),children:[h?r("button",{type:"button",className:"qr-back-btn qr-back-btn--auth",onClick:h,disabled:m,children:"← Back"}):null,r("h3",{className:"qr-auth-step__title",children:"Choose payment"}),e("p",{className:"qr-auth-step__sub",children:["Order total: ",r("strong",{children:_})]}),b?r("p",{className:"qr-auth-step__error",role:"alert",children:b}):null,r("button",{type:"button",className:"qr-btn qr-btn--primary qr-btn--full",onClick:async()=>{f(!0),y(null)
212
- try{await(window.Razorpay?Promise.resolve():new Promise((e,r)=>{const n=document.querySelector(`script[src="${_e}"]`)
222
+ const g=`₹${(o/100).toLocaleString("en-IN")}`
223
+ return e("div",{className:"qr-payment-step"+(_?" qr-payment-step--dark":""),children:[h?r("button",{type:"button",className:"qr-back-btn qr-back-btn--auth",onClick:h,disabled:f,children:"← Back"}):null,r("h3",{className:"qr-auth-step__title",children:"Choose payment"}),e("p",{className:"qr-auth-step__sub",children:["Order total: ",r("strong",{children:g})]}),b?r("p",{className:"qr-auth-step__error",role:"alert",children:b}):null,r("button",{type:"button",className:"qr-btn qr-btn--primary qr-btn--full",onClick:async()=>{y(!0),v(null)
224
+ try{await(window.Razorpay?Promise.resolve():new Promise((e,r)=>{const n=document.querySelector(`script[src="${Ne}"]`)
213
225
  if(n)return void n.addEventListener("load",()=>e())
214
226
  const a=document.createElement("script")
215
- a.src=_e,a.async=!0,a.onload=()=>e(),a.onerror=()=>r(new Error("Failed to load Razorpay")),document.body.appendChild(a)}))
216
- const e=await ae(n,a,o)
217
- await new Promise((r,t)=>{window.Razorpay?new window.Razorpay({key:e.razorpay_key_id,amount:e.amount_paise,currency:e.currency,order_id:e.razorpay_order_id,name:"Checkout",handler:async e=>{try{const t=await te(n,a,{razorpay_order_id:e.razorpay_order_id,razorpay_payment_id:e.razorpay_payment_id,razorpay_signature:e.razorpay_signature,payment_method:"prepaid"})
218
- null==p||p("payment_method_selected",t.payment_method),u(t.payment_method),r()}catch(e){t(e)}},modal:{ondismiss:()=>t(new Error("Payment cancelled"))}}).open():t(new Error("Razorpay unavailable"))})}catch(e){y(e instanceof Error?e.message:"Payment failed")}finally{f(!1)}},disabled:m,children:m?"Processing…":`Pay ${_} online`}),l&&d?r("button",{type:"button",className:"qr-btn qr-btn--ghost qr-btn--full",onClick:async()=>{f(!0),y(null)
219
- try{const e=await ie(n,a)
220
- null==p||p("payment_method_selected",e.payment_method),u(e.payment_method)}catch(e){y(e instanceof Error?e.message:"Failed to select COD")}finally{f(!1)}},disabled:m,style:{marginTop:8},children:"Cash on Delivery"}):null,i?e("p",{className:"qr-payment-step__meta",children:["Session ",i.slice(0,8),"…"]}):null]})},qe=({onOtpSent:a,onSkip:l,functionBaseUrl:s,merchantId:d})=>{const[c,u]=t(""),[h,p]=t(!1),[m,f]=t(null),b=o(null),y=i(e=>{u(e.target.value.trim()),f(null)},[]),v=i(async e=>{var r
221
- if(e.preventDefault(),!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(c))return f("Enter a valid email address."),void(null==(r=b.current)||r.focus())
227
+ a.src=Ne,a.async=!0,a.onload=()=>e(),a.onerror=()=>r(new Error("Failed to load Razorpay")),document.body.appendChild(a)}))
228
+ const e=await ee(n,a,o)
229
+ await new Promise((r,t)=>{window.Razorpay?new window.Razorpay({key:e.razorpay_key_id,amount:e.amount_paise,currency:e.currency,order_id:e.razorpay_order_id,name:"Checkout",handler:async e=>{try{const t=await re(n,a,{razorpay_order_id:e.razorpay_order_id,razorpay_payment_id:e.razorpay_payment_id,razorpay_signature:e.razorpay_signature,payment_method:"prepaid"})
230
+ if(null==p||p("payment_method_selected",t.payment_method),u({paymentMethod:t.payment_method,razorpayOrderId:t.razorpay_order_id,razorpayPaymentId:t.razorpay_payment_id}),m){const e=m.replace("{{sessionId}}",i??"")
231
+ window.location.href=e}r()}catch(e){t(e)}},modal:{ondismiss:()=>t(new Error("Payment cancelled"))}}).open():t(new Error("Razorpay unavailable"))})}catch(e){v(e instanceof Error?e.message:"Payment failed")}finally{y(!1)}},disabled:f,children:f?"Processing…":`Pay ${g} online`}),l&&d?r("button",{type:"button",className:"qr-btn qr-btn--ghost qr-btn--full",onClick:async()=>{y(!0),v(null)
232
+ try{const e=await ne(n,a)
233
+ null==p||p("payment_method_selected",e.payment_method),u({paymentMethod:e.payment_method})}catch(e){v(e instanceof Error?e.message:"Failed to select COD")}finally{y(!1)}},disabled:f,style:{marginTop:8},children:"Cash on Delivery"}):null,i?e("p",{className:"qr-payment-step__meta",children:["Session ",i.slice(0,8),"…"]}):null]})},Ce=({onOtpSent:a,onSkip:l,functionBaseUrl:s,merchantId:d})=>{const[c,u]=t(""),[h,p]=t(!1),[m,f]=t(null),y=o(null),b=i(e=>{u(e.target.value.trim()),f(null)},[]),v=i(async e=>{var r
234
+ if(e.preventDefault(),!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(c))return f("Enter a valid email address."),void(null==(r=y.current)||r.focus())
222
235
  p(!0),f(null)
223
- try{const{reused:e}=await Q({functionBaseUrl:s,merchantId:d},c)
236
+ try{const{reused:e}=await H({functionBaseUrl:s,merchantId:d},c)
224
237
  a(c.toLowerCase(),{reused:e})}catch(e){f(e instanceof Error?e.message:"Failed to send code. Please try again.")}finally{p(!1)}},[c,s,d,a])
225
- return e("div",{className:"qr-auth-step",children:[r("div",{className:"qr-auth-step__icon","aria-hidden":"true",children:e("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[r("circle",{cx:"24",cy:"24",r:"24",fill:"var(--qr-primary-light)"}),r("rect",{x:"11",y:"15",width:"26",height:"18",rx:"3",stroke:"var(--qr-primary)",strokeWidth:"1.8",fill:"none"}),r("path",{d:"M11 18l13 9 13-9",stroke:"var(--qr-primary)",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round"})]})}),r("h3",{className:"qr-auth-step__title",children:"Faster checkout"}),r("p",{className:"qr-auth-step__sub",children:"Enter your email to load saved addresses"}),e("form",{onSubmit:v,noValidate:!0,children:[r("div",{className:"qr-email-field"+(m?" qr-email-field--error":""),children:r("input",{ref:b,type:"email",inputMode:"email",className:"qr-email-field__input",placeholder:"you@example.com",value:c,onChange:y,autoComplete:"email","aria-label":"Email address","aria-describedby":m?"qr-email-error":void 0,"aria-invalid":!!m,disabled:h})}),m&&r("p",{id:"qr-email-error",className:"qr-auth-step__error",role:"alert",children:m}),r("button",{type:"submit",className:"qr-btn qr-btn--primary qr-btn--full",disabled:h||c.length<5,children:h?r("span",{className:"qr-spinner qr-spinner--sm","aria-hidden":"true"}):e(n,{children:["Send Code",r("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:r("path",{d:"M5 12h14M12 5l7 7-7 7"})})]})})]}),r("button",{type:"button",className:"qr-auth-step__skip",onClick:l,disabled:h,children:"Skip, enter address manually"})]})}
226
- function we(e){const[r,n]=e.split("@")
227
- return!n||r.length<=1?e:`${r[0]}***@${n}`}const Ne=({email:a,codeReused:l=!1,onVerified:d,onBack:c,functionBaseUrl:u,merchantId:h,sessionContext:p})=>{const[m,f]=t(Array(6).fill("")),[b,y]=t(!1),[v,_]=t(null),[g,q]=t(60),[w,N]=t(!1),k=o([]),x=o(null)
228
- s(()=>(x.current=setInterval(()=>{q(e=>e<=1?(clearInterval(x.current),0):e-1)},1e3),()=>{x.current&&clearInterval(x.current)}),[])
229
- const C=e=>{var r
238
+ return e("div",{className:"qr-auth-step",children:[r("div",{className:"qr-auth-step__icon","aria-hidden":"true",children:e("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[r("circle",{cx:"24",cy:"24",r:"24",fill:"var(--qr-primary-light)"}),r("rect",{x:"11",y:"15",width:"26",height:"18",rx:"3",stroke:"var(--qr-primary)",strokeWidth:"1.8",fill:"none"}),r("path",{d:"M11 18l13 9 13-9",stroke:"var(--qr-primary)",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round"})]})}),r("h3",{className:"qr-auth-step__title",children:"Faster checkout"}),r("p",{className:"qr-auth-step__sub",children:"Enter your email to load saved addresses"}),e("form",{onSubmit:v,noValidate:!0,children:[r("div",{className:"qr-email-field"+(m?" qr-email-field--error":""),children:r("input",{ref:y,type:"email",inputMode:"email",className:"qr-email-field__input",placeholder:"you@example.com",value:c,onChange:b,autoComplete:"email","aria-label":"Email address","aria-describedby":m?"qr-email-error":void 0,"aria-invalid":!!m,disabled:h})}),m&&r("p",{id:"qr-email-error",className:"qr-auth-step__error",role:"alert",children:m}),r("button",{type:"submit",className:"qr-btn qr-btn--primary qr-btn--full",disabled:h||c.length<5,children:h?r("span",{className:"qr-spinner qr-spinner--sm","aria-hidden":"true"}):e(n,{children:["Send Code",r("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:r("path",{d:"M5 12h14M12 5l7 7-7 7"})})]})})]}),r("button",{type:"button",className:"qr-auth-step__skip",onClick:l,disabled:h,children:"Skip, enter address manually"})]})}
239
+ function xe(e){const[r,n]=e.split("@")
240
+ return!n||r.length<=1?e:`${r[0]}***@${n}`}const Ee=({email:a,codeReused:l=!1,onVerified:d,onBack:c,functionBaseUrl:u,merchantId:h,sessionContext:p})=>{const[m,f]=t(Array(6).fill("")),[y,b]=t(!1),[v,_]=t(null),[g,q]=t(60),[w,N]=t(!1),k=o([]),C=o(null)
241
+ s(()=>(C.current=setInterval(()=>{q(e=>e<=1?(clearInterval(C.current),0):e-1)},1e3),()=>{C.current&&clearInterval(C.current)}),[])
242
+ const x=e=>{var r
230
243
  return null==(r=k.current[e])?void 0:r.focus()},E=i((e,r)=>{const n=r.replace(/\D/g,"").slice(-1)
231
244
  _(null),f(r=>{const a=[...r]
232
- return a[e]=n,a}),n&&e<5&&C(e+1)},[]),S=i((e,r)=>{"Backspace"===r.key?m[e]?f(r=>{const n=[...r]
245
+ return a[e]=n,a}),n&&e<5&&x(e+1)},[]),S=i((e,r)=>{"Backspace"===r.key?m[e]?f(r=>{const n=[...r]
233
246
  return n[e]="",n}):e>0&&(f(r=>{const n=[...r]
234
- return n[e-1]="",n}),C(e-1)):"ArrowLeft"===r.key&&e>0?C(e-1):"ArrowRight"===r.key&&e<5&&C(e+1)},[m]),L=i(e=>{e.preventDefault()
247
+ return n[e-1]="",n}),x(e-1)):"ArrowLeft"===r.key&&e>0?x(e-1):"ArrowRight"===r.key&&e<5&&x(e+1)},[m]),L=i(e=>{e.preventDefault()
235
248
  const r=e.clipboardData.getData("text").replace(/\D/g,"").slice(0,6)
236
249
  if(!r)return
237
250
  const n=Array(6).fill("")
238
- r.split("").forEach((e,r)=>{n[r]=e}),f(n),_(null),C(Math.min(r.length,5))},[]),T=m.join(""),I=6===T.length&&!m.includes(""),P=i(async()=>{if(I){y(!0),_(null)
239
- try{const e=await Z({functionBaseUrl:u,merchantId:h},a,T,p)
240
- d(e.session_token,e.buyer_id,e.session_id)}catch(e){_(e instanceof Error?e.message:"Verification failed. Please try again."),f(Array(6).fill("")),C(0)}finally{y(!1)}}},[I,T,a,u,h,d,p])
241
- s(()=>{I&&!b&&P()},[I])
242
- const A=i(async()=>{if(!(g>0||w)){N(!0),_(null),f(Array(6).fill(""))
243
- try{await Q({functionBaseUrl:u,merchantId:h},a),q(60),x.current=setInterval(()=>{q(e=>e<=1?(clearInterval(x.current),0):e-1)},1e3),C(0)}catch(e){_(e instanceof Error?e.message:"Failed to resend code.")}finally{N(!1)}}},[g,w,u,h,a])
244
- return e("div",{className:"qr-auth-step",children:[r("button",{type:"button",className:"qr-back-btn qr-back-btn--auth",onClick:c,disabled:b,children:r("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:r("path",{d:"M19 12H5M12 5l-7 7 7 7"})})}),r("div",{className:"qr-auth-step__icon","aria-hidden":"true",children:e("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[r("circle",{cx:"24",cy:"24",r:"24",fill:"var(--qr-primary-light)"}),r("rect",{x:"11",y:"15",width:"26",height:"18",rx:"3",stroke:"var(--qr-primary)",strokeWidth:"1.8",fill:"none"}),r("path",{d:"M11 18l13 9 13-9",stroke:"var(--qr-primary)",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round"})]})}),r("h3",{className:"qr-auth-step__title",children:"Check your email"}),r("p",{className:"qr-auth-step__sub",children:l?r(n,{children:"Use the code we sent earlier — it's still valid for your next checkout."}):e(n,{children:["6-digit code sent to ",r("strong",{children:we(a)})]})}),r("div",{className:"qr-otp-boxes",role:"group","aria-label":"Enter verification code",children:m.map((e,n)=>r("input",{ref:e=>{k.current[n]=e},type:"text",inputMode:"numeric",maxLength:1,className:`qr-otp-box${e?" qr-otp-box--filled":""}${v?" qr-otp-box--error":""}`,value:e,onChange:e=>E(n,e.target.value),onKeyDown:e=>S(n,e),onPaste:L,onFocus:e=>e.target.select(),"aria-label":`Code digit ${n+1}`,disabled:b,autoComplete:0===n?"one-time-code":"off"},n))}),v&&r("p",{className:"qr-auth-step__error",role:"alert",children:v}),r("button",{type:"button",className:"qr-btn qr-btn--primary qr-btn--full",onClick:P,disabled:!I||b,children:b?r("span",{className:"qr-spinner qr-spinner--sm","aria-hidden":"true"}):"Verify Code"}),r("p",{className:"qr-auth-step__resend",children:g>0?e("span",{children:["Resend code in ",g,"s"]}):r("button",{type:"button",className:"qr-link-btn",onClick:A,disabled:w,children:w?"Sending…":"Resend Code"})})]})}
245
- function ke(e){if("undefined"!=typeof window){const e=window.innerWidth
251
+ r.split("").forEach((e,r)=>{n[r]=e}),f(n),_(null),x(Math.min(r.length,5))},[]),T=m.join(""),I=6===T.length&&!m.includes(""),P=i(async()=>{if(I){b(!0),_(null)
252
+ try{const e=await G({functionBaseUrl:u,merchantId:h},a,T,p)
253
+ d(e.session_token,e.buyer_id,e.session_id)}catch(e){_(e instanceof Error?e.message:"Verification failed. Please try again."),f(Array(6).fill("")),x(0)}finally{b(!1)}}},[I,T,a,u,h,d,p])
254
+ s(()=>{I&&!y&&P()},[I])
255
+ const B=i(async()=>{if(!(g>0||w)){N(!0),_(null),f(Array(6).fill(""))
256
+ try{await H({functionBaseUrl:u,merchantId:h},a),q(60),C.current=setInterval(()=>{q(e=>e<=1?(clearInterval(C.current),0):e-1)},1e3),x(0)}catch(e){_(e instanceof Error?e.message:"Failed to resend code.")}finally{N(!1)}}},[g,w,u,h,a])
257
+ return e("div",{className:"qr-auth-step",children:[r("button",{type:"button",className:"qr-back-btn qr-back-btn--auth",onClick:c,disabled:y,children:r("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:r("path",{d:"M19 12H5M12 5l-7 7 7 7"})})}),r("div",{className:"qr-auth-step__icon","aria-hidden":"true",children:e("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[r("circle",{cx:"24",cy:"24",r:"24",fill:"var(--qr-primary-light)"}),r("rect",{x:"11",y:"15",width:"26",height:"18",rx:"3",stroke:"var(--qr-primary)",strokeWidth:"1.8",fill:"none"}),r("path",{d:"M11 18l13 9 13-9",stroke:"var(--qr-primary)",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round"})]})}),r("h3",{className:"qr-auth-step__title",children:"Check your email"}),r("p",{className:"qr-auth-step__sub",children:l?r(n,{children:"Use the code we sent earlier — it's still valid for your next checkout."}):e(n,{children:["6-digit code sent to ",r("strong",{children:xe(a)})]})}),r("div",{className:"qr-otp-boxes",role:"group","aria-label":"Enter verification code",children:m.map((e,n)=>r("input",{ref:e=>{k.current[n]=e},type:"text",inputMode:"numeric",maxLength:1,className:`qr-otp-box${e?" qr-otp-box--filled":""}${v?" qr-otp-box--error":""}`,value:e,onChange:e=>E(n,e.target.value),onKeyDown:e=>S(n,e),onPaste:L,onFocus:e=>e.target.select(),"aria-label":`Code digit ${n+1}`,disabled:y,autoComplete:0===n?"one-time-code":"off"},n))}),v&&r("p",{className:"qr-auth-step__error",role:"alert",children:v}),r("button",{type:"button",className:"qr-btn qr-btn--primary qr-btn--full",onClick:P,disabled:!I||y,children:y?r("span",{className:"qr-spinner qr-spinner--sm","aria-hidden":"true"}):"Verify Code"}),r("p",{className:"qr-auth-step__resend",children:g>0?e("span",{children:["Resend code in ",g,"s"]}):r("button",{type:"button",className:"qr-link-btn",onClick:B,disabled:w,children:w?"Sending…":"Resend Code"})})]})}
258
+ function Se(e){if("undefined"!=typeof window){const e=window.innerWidth
246
259
  return e<768?"mobile":e<1024?"tablet":"desktop"}const r=(e??"").toLowerCase()
247
- return/ipad|tablet/.test(r)?"tablet":/mobile|iphone|android/.test(r)?"mobile":"desktop"}function xe(){return"web"}function Ce(){const e=function(){if("undefined"!=typeof navigator&&navigator.userAgent)return navigator.userAgent.slice(0,512)}()
248
- return{deviceType:ke(e),platform:"web",userAgent:e}}const Ee=["utm_source","utm_medium","utm_campaign"]
249
- function Se(e){try{const r=new URL(e??("undefined"!=typeof window?window.location.href:"")),n={}
250
- for(const e of Ee){const a=r.searchParams.get(e)
251
- a&&(n[e]=a.slice(0,256))}return n}catch{return{}}}function Le(e){return Boolean(e.utm_source||e.utm_medium||e.utm_campaign)}const Te=({address:n,onEditAddress:a})=>e("div",{className:"qr-success",children:[r("div",{className:"qr-success__icon","aria-hidden":"true",children:e("svg",{viewBox:"0 0 52 52",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[r("circle",{cx:"26",cy:"26",r:"26",fill:"var(--qr-success, #10b981)",opacity:"0.12"}),r("circle",{cx:"26",cy:"26",r:"20",fill:"var(--qr-success, #10b981)"}),r("path",{d:"M15 26l8 8 14-16",stroke:"white",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round"})]})}),r("h3",{className:"qr-success__title",children:"Address Saved!"}),r("p",{className:"qr-success__address",children:n.formattedAddress}),r("div",{className:"qr-success__meta",children:e("span",{className:"qr-digipin-badge qr-digipin-badge--inline",children:[r("span",{className:"qr-digipin-badge__label",children:"DigiPin"}),r("span",{className:"qr-digipin-badge__code",children:n.digipin})]})}),r("button",{type:"button",className:"qr-btn qr-btn--ghost qr-btn--sm",onClick:a,children:"Change Address"})]}),Ie=({apiKey:l,apiBaseUrl:d="https://api.quantaroute.com",onComplete:u,onError:h,defaultLat:p,defaultLng:m,theme:f="light",className:b="",style:y,mapHeight:v="380px",title:_="Add Delivery Address",indiaBoundaryUrl:g,enableSearch:q=!0,enablePhoneAuth:w=!1,merchantId:N="",supabaseFunctionBaseUrl:k="",brandColor:x,logoUrl:C,headerBanner:E,onCheckoutEvent:S,enableCod:L=!1,codCartTotalPaise:T,codSessionToken:I="",enableEmailAuth:P=!1,variant:A,utmParams:B,enablePayment:$=!1,paymentAmountPaise:M,onPaymentComplete:D,enablePrepaidNudge:U=!1,prepaidNudgeCopy:F,prepaidNudgeCtaUrl:R,registerController:W})=>{const V=w?"phone":P?"email":"none",z="phone"===V?"phone":"email"===V?"email":"map",J=Boolean($&&M&&k),[G,K]=t(z),[Q,Z]=t(null),[X,ae]=t(null),[te,ie]=t(null),[oe,se]=t(""),[ce,ue]=t(!1),[he,pe]=t(!1),[me,fe]=t(null),[_e,we]=t(null),ke=o(G),xe=c(()=>B??Se(),[B]),Ee=c(()=>Ce(),[]),Le=c(()=>({utm_source:xe.utm_source,utm_medium:xe.utm_medium,utm_campaign:xe.utm_campaign,device_type:Ee.deviceType,platform:Ee.platform,user_agent:Ee.userAgent,experiment_variant:A}),[xe,Ee,A]),Ie={functionBaseUrl:k,merchantId:N},Pe=(null==te?void 0:te.sessionToken)||I
252
- s(()=>{ke.current=G},[G])
253
- const Ae=i(e=>{const r={...e,sessionId:e.sessionId??(null==te?void 0:te.sessionId),buyerId:e.buyerId??(null==te?void 0:te.buyerId),authChannel:e.authChannel??("phone"===V?"phone":"email"===V?"email":"none"),deviceType:e.deviceType??Ee.deviceType,platform:e.platform??Ee.platform,userAgent:e.userAgent??Ee.userAgent,experimentVariant:e.experimentVariant??A,timestamp:(new Date).toISOString()}
254
- if(S)try{S(r)}catch{}N&&k&&ee(Ie,{event_type:r.type,step:r.step,buyer_id:r.buyerId,auth_channel:r.authChannel,device_type:r.deviceType,platform:r.platform,user_agent:r.userAgent,payment_method:r.paymentMethod,experiment_variant:r.experimentVariant},null==te?void 0:te.sessionToken).catch(()=>{})},[te,V,Ee,A,S,N,k,Ie])
260
+ return/ipad|tablet/.test(r)?"tablet":/mobile|iphone|android/.test(r)?"mobile":"desktop"}function Le(){return"web"}function Te(){const e=function(){if("undefined"!=typeof navigator&&navigator.userAgent)return navigator.userAgent.slice(0,512)}()
261
+ return{deviceType:Se(e),platform:"web",userAgent:e}}const Ie=["utm_source","utm_medium","utm_campaign"]
262
+ function Pe(e){try{const r=new URL(e??("undefined"!=typeof window?window.location.href:"")),n={}
263
+ for(const e of Ie){const a=r.searchParams.get(e)
264
+ a&&(n[e]=a.slice(0,256))}return n}catch{return{}}}function Be(e){return Boolean(e.utm_source||e.utm_medium||e.utm_campaign)}const Ae=({address:n,onEditAddress:a})=>e("div",{className:"qr-success",children:[r("div",{className:"qr-success__icon","aria-hidden":"true",children:e("svg",{viewBox:"0 0 52 52",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[r("circle",{cx:"26",cy:"26",r:"26",fill:"var(--qr-success, #10b981)",opacity:"0.12"}),r("circle",{cx:"26",cy:"26",r:"20",fill:"var(--qr-success, #10b981)"}),r("path",{d:"M15 26l8 8 14-16",stroke:"white",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round"})]})}),r("h3",{className:"qr-success__title",children:"Address Saved!"}),r("p",{className:"qr-success__address",children:n.formattedAddress}),r("div",{className:"qr-success__meta",children:e("span",{className:"qr-digipin-badge qr-digipin-badge--inline",children:[r("span",{className:"qr-digipin-badge__label",children:"DigiPin"}),r("span",{className:"qr-digipin-badge__code",children:n.digipin})]})}),r("button",{type:"button",className:"qr-btn qr-btn--ghost qr-btn--sm",onClick:a,children:"Change Address"})]}),Oe=({apiKey:l,apiBaseUrl:d="https://api.quantaroute.com",onComplete:u,onError:h,defaultLat:p,defaultLng:m,theme:f="light",className:y="",style:b,mapHeight:v="380px",title:_="Add Delivery Address",indiaBoundaryUrl:g,enableSearch:q=!0,enablePhoneAuth:w=!1,merchantId:N="",supabaseFunctionBaseUrl:k="",brandColor:C,logoUrl:x,headerBanner:E,onCheckoutEvent:S,enableCod:L=!1,enableServiceabilityCheck:T=!1,showIndiaPostDeliveryWarning:I=!1,serviceabilityBlockCheckout:P,codCartTotalPaise:B,codSessionToken:A="",enableEmailAuth:O=!1,variant:D,utmParams:$,enablePayment:U=!1,paymentAmountPaise:F,onPaymentComplete:R,enablePrepaidNudge:j=!1,prepaidNudgeCopy:z,prepaidNudgeCtaUrl:V,registerController:H,orderConfirmationUrl:G})=>{const K=w?"phone":O?"email":"none",Y="phone"===K?"phone":"email"===K?"email":"map",ee=Boolean(U&&F&&k),[re,ne]=t(Y),[ae,te]=t(null),[ie,oe]=t(null),[le,se]=t(null),[de,he]=t(""),[me,fe]=t(!1),[ye,be]=t(!1),[ve,_e]=t(null),[Ne,xe]=t(null),Se=o(re),Le=c(()=>$??Pe(),[$]),Ie=c(()=>Te(),[]),Be=c(()=>({utm_source:Le.utm_source,utm_medium:Le.utm_medium,utm_campaign:Le.utm_campaign,device_type:Ie.deviceType,platform:Ie.platform,user_agent:Ie.userAgent,experiment_variant:D}),[Le,Ie,D]),Oe={functionBaseUrl:k,merchantId:N},De=(null==le?void 0:le.sessionToken)||A
265
+ s(()=>{Se.current=re},[re])
266
+ const $e=i(e=>{const r={...e,sessionId:e.sessionId??(null==le?void 0:le.sessionId),buyerId:e.buyerId??(null==le?void 0:le.buyerId),authChannel:e.authChannel??("phone"===K?"phone":"email"===K?"email":"none"),deviceType:e.deviceType??Ie.deviceType,platform:e.platform??Ie.platform,userAgent:e.userAgent??Ie.userAgent,experimentVariant:e.experimentVariant??D,timestamp:(new Date).toISOString()}
267
+ if(S)try{S(r)}catch{}N&&k&&Q(Oe,{event_type:r.type,step:r.step,buyer_id:r.buyerId,auth_channel:r.authChannel,device_type:r.deviceType,platform:r.platform,user_agent:r.userAgent,payment_method:r.paymentMethod,experiment_variant:r.experimentVariant},null==le?void 0:le.sessionToken).catch(()=>{})},[le,K,Ie,D,S,N,k,Oe])
255
268
  s(()=>{if(!N||!k)return
256
- const e=()=>{"done"!==ke.current&&(null==te?void 0:te.sessionToken)&&(re(Ie,te.sessionToken,ke.current).catch(()=>{}),Ae({type:"session_abandoned",step:ke.current}))}
257
- return window.addEventListener("pagehide",e),()=>window.removeEventListener("pagehide",e)},[null==te?void 0:te.sessionToken,N,k,Ie,Ae]),s(()=>{(null==te?void 0:te.sessionToken)&&N&&k&&ne(Ie,te.sessionToken).then(fe).catch(()=>fe(null))},[null==te?void 0:te.sessionToken,N,k,Ie])
258
- const Be=c(()=>function(e,r){const n=null==r?void 0:r.trim()
269
+ const e=()=>{"done"!==Se.current&&(null==le?void 0:le.sessionToken)&&(Z(Oe,le.sessionToken,Se.current).catch(()=>{}),$e({type:"session_abandoned",step:Se.current}))}
270
+ return window.addEventListener("pagehide",e),()=>window.removeEventListener("pagehide",e)},[null==le?void 0:le.sessionToken,N,k,Oe,$e]),s(()=>{(null==le?void 0:le.sessionToken)&&N&&k&&X(Oe,le.sessionToken).then(_e).catch(()=>_e(null))},[null==le?void 0:le.sessionToken,N,k,Oe])
271
+ const Me=c(()=>function(e,r){const n=null==r?void 0:r.trim()
259
272
  if(!n)return e
260
273
  const a={"--qr-primary":n,"--qr-primary-dark":n,"--qr-border-focus":n,"--qr-primary-light":`color-mix(in srgb, ${n} 18%, white)`}
261
- return e?{...e,...a}:a}(y,x),[y,x]),$e=()=>{Ae({type:"auth_skipped",step:"map"}),K("map")},Me=async e=>{var r
262
- if(ae(e),Ae({type:"address_completed",step:J?"payment":"done",digipin:e.digipin,buyerId:null==te?void 0:te.buyerId}),(null==te?void 0:te.sessionToken)&&(Y(Ie,te.sessionToken,{pincode:e.pincode,digipin:e.digipin,state:e.state,district:e.district,locality:e.locality}).catch(()=>{}),!e.addressId))try{await H(Ie,te.sessionToken,{digipin:e.digipin,lat:e.lat,lng:e.lng,state:e.state,district:e.district,locality:e.locality,pincode:e.pincode,delivery_status:e.delivery,flat_number:e.flatNumber,floor_number:e.floorNumber,building_name:e.buildingName,street_name:e.streetName,full_address_json:e,label:e.label??"home",label_text:"other"===e.label&&(null==(r=e.labelText)?void 0:r.trim())||null,is_default:!1})}catch{}J&&Pe?K("payment"):(K("done"),u(e))},De=()=>"form"===G?(K("map"),!0):"map"===G&&(null==te?void 0:te.sessionToken)?(K("saved"),!0):"email-otp"===G?(K("email"),!0):"otp"===G?(K("phone"),!0):"payment"===G&&(K("form"),!0)
263
- s(()=>{W&&W({goBack:()=>{const e=ke.current
264
- return"form"===e?(K("map"),!0):"map"===e&&(null==te?void 0:te.sessionToken)?(K("saved"),!0):"email-otp"===e?(K("email"),!0):"otp"===e?(K("phone"),!0):"payment"===e&&(K("form"),!0)},getStep:()=>ke.current})},[W,null==te?void 0:te.sessionToken]),s(()=>{const e={phone:"phone_step_viewed",email:"email_step_viewed",saved:"saved_addresses_viewed",map:"map_step_viewed",form:"form_step_viewed",payment:"payment_step_viewed"}[G]
265
- e&&Ae({type:e,step:G,buyerId:null==te?void 0:te.buyerId})},[G]),s(()=>{P&&"email"===V&&(N&&k||null==h||h(new Error("enableEmailAuth requires merchantId and supabaseFunctionBaseUrl on CheckoutWidget.")))},[P,V,N,k,h])
266
- const Oe=function(e,r,n){if("none"===r){if(n){const r=["map","form","payment","done"].indexOf(e)
274
+ return e?{...e,...a}:a}(b,C),[b,C]),Ue=()=>{$e({type:"auth_skipped",step:"map"}),ne("map")},Fe=async e=>{var r
275
+ if(oe(e),$e({type:"address_completed",step:ee?"payment":"done",digipin:e.digipin,buyerId:null==le?void 0:le.buyerId}),(null==le?void 0:le.sessionToken)&&(J(Oe,le.sessionToken,{pincode:e.pincode,digipin:e.digipin,state:e.state,district:e.district,locality:e.locality}).catch(()=>{}),!e.addressId))try{await W(Oe,le.sessionToken,{digipin:e.digipin,lat:e.lat,lng:e.lng,state:e.state,district:e.district,locality:e.locality,pincode:e.pincode,delivery_status:e.delivery,flat_number:e.flatNumber,floor_number:e.floorNumber,building_name:e.buildingName,street_name:e.streetName,full_address_json:e,label:e.label??"home",label_text:"other"===e.label&&(null==(r=e.labelText)?void 0:r.trim())||null,is_default:!1})}catch{}if(ee&&De)ne("payment")
276
+ else{if(ee&&!De)return null==h||h(new Error("enablePayment requires phone/email auth or a codSessionToken prop.")),ne("done"),void u(e)
277
+ ne("done"),u(e)}},Re=()=>"form"===re?(ne("map"),!0):"map"===re&&(null==le?void 0:le.sessionToken)?(ne("saved"),!0):"email-otp"===re?(ne("email"),!0):"otp"===re?(ne("phone"),!0):"payment"===re&&(ne("form"),!0)
278
+ s(()=>{H&&H({goBack:()=>{const e=Se.current
279
+ return"form"===e?(ne("map"),!0):"map"===e&&(null==le?void 0:le.sessionToken)?(ne("saved"),!0):"email-otp"===e?(ne("email"),!0):"otp"===e?(ne("phone"),!0):"payment"===e&&(ne("form"),!0)},getStep:()=>Se.current})},[H,null==le?void 0:le.sessionToken]),s(()=>{const e={phone:"phone_step_viewed",email:"email_step_viewed",saved:"saved_addresses_viewed",map:"map_step_viewed",form:"form_step_viewed",payment:"payment_step_viewed"}[re]
280
+ e&&$e({type:e,step:re,buyerId:null==le?void 0:le.buyerId})},[re]),s(()=>{O&&"email"===K&&(N&&k||null==h||h(new Error("enableEmailAuth requires merchantId and supabaseFunctionBaseUrl on CheckoutWidget.")))},[O,K,N,k,h])
281
+ const je=function(e,r,n){if("none"===r){if(n){const r=["map","form","payment","done"].indexOf(e)
267
282
  return-1===r?0:r}return"map"===e?0:"form"===e?1:2}const a=("email"===r?n?["email","email-otp","saved","map","form","payment","done"]:["email","email-otp","saved","map","form","done"]:n?["phone","otp","saved","map","form","payment","done"]:["phone","otp","saved","map","form","done"]).indexOf(e)
268
- return-1===a?0:a}(G,V,J),Ue=function(e,r){return"none"===e?r?3:2:r?6:5}(V,J)
269
- return e("div",{className:`qr-checkout qr-checkout--${f} ${b}`,style:Be,"data-testid":"quantaroute-checkout",children:["done"!==G&&e(n,{children:[e("div",{className:"qr-header",children:[e("div",{className:"qr-header__brand",children:[C?r("img",{src:C,alt:"",className:"qr-header__logo-img",width:28,height:28,decoding:"async"}):e("svg",{className:"qr-header__logo","aria-hidden":"true",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r("path",{d:"M21 10c0 7-9 13-9 13S3 17 3 10a9 9 0 0118 0z"}),r("circle",{cx:"12",cy:"10",r:"3"})]}),r("span",{className:"qr-header__title",children:_})]}),(()=>{const n=Array.from({length:Ue+1},(e,r)=>r)
270
- return r("div",{className:"qr-progress",role:"progressbar","aria-valuenow":Oe+1,"aria-valuemin":1,"aria-valuemax":Ue+1,"aria-label":`Step ${Oe+1} of ${Ue+1}`,children:n.map(n=>e(a.Fragment,{children:[r("div",{className:"qr-progress__dot"+(Oe>=n?" qr-progress__dot--active":"")}),n<Ue&&r("div",{className:"qr-progress__line"+(Oe>n?" qr-progress__line--active":"")})]},n))})})()]}),E?r("div",{className:"qr-header-banner",role:"region","aria-label":"Merchant message",children:E}):null,me?e("div",{className:"qr-offer-banner",role:"region","aria-label":"Special offer",children:[me.banner_copy,me.banner_cta_url?e(n,{children:[" ",r("a",{href:me.banner_cta_url,target:"_blank",rel:"noopener noreferrer",children:"Learn more"})]}):null]}):null]}),"email"===G&&P&&r(qe,{onOtpSent:(e,r)=>{se(e),ue(Boolean(null==r?void 0:r.reused)),Ae({type:"email_otp_sent",step:"email-otp",mobile:e}),K("email-otp")},onSkip:$e,functionBaseUrl:k,merchantId:N}),"email-otp"===G&&P&&oe&&r(Ne,{email:oe,codeReused:ce,onVerified:(e,r,n)=>{ie({mobile:oe,sessionToken:e,sessionId:n??"",buyerId:r}),Ae({type:"email_verified",step:"saved",buyerId:r,sessionId:n}),K("saved")},onBack:De,functionBaseUrl:k,merchantId:N,sessionContext:Le}),"phone"===G&&w&&r(le,{onOtpSent:e=>{ie(r=>({mobile:e,sessionToken:"",sessionId:"",buyerId:(null==r?void 0:r.buyerId)??""})),Ae({type:"otp_sent",step:"otp",mobile:e}),K("otp")},onSkip:$e,functionBaseUrl:k,merchantId:N}),"otp"===G&&te&&r(de,{mobile:te.mobile,onVerified:(e,r,n)=>{ie({mobile:(null==te?void 0:te.mobile)??"",sessionToken:e,sessionId:n??"",buyerId:r}),Ae({type:"phone_verified",step:"saved",buyerId:r,sessionId:n}),K("saved")},onBack:De,functionBaseUrl:k,merchantId:N,sessionContext:Le}),"saved"===G&&(null==te?void 0:te.sessionToken)&&r(be,{sessionToken:te.sessionToken,functionBaseUrl:k,merchantId:N,onSelectAddress:e=>{var r
271
- Ae({type:"saved_address_selected",step:J?"payment":"done",buyerId:null==te?void 0:te.buyerId,digipin:e.digipin}),(null==te?void 0:te.sessionToken)&&Y(Ie,te.sessionToken,{pincode:e.pincode,digipin:e.digipin,state:e.state,district:e.district,locality:e.locality}).catch(()=>{})
283
+ return-1===a?0:a}(re,K,ee),We=function(e,r){return"none"===e?r?3:2:r?6:5}(K,ee)
284
+ return e("div",{className:`qr-checkout qr-checkout--${f} ${y}`,style:Me,"data-testid":"quantaroute-checkout",children:["done"!==re&&e(n,{children:[e("div",{className:"qr-header",children:[e("div",{className:"qr-header__brand",children:[x?r("img",{src:x,alt:"",className:"qr-header__logo-img",width:28,height:28,decoding:"async"}):e("svg",{className:"qr-header__logo","aria-hidden":"true",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r("path",{d:"M21 10c0 7-9 13-9 13S3 17 3 10a9 9 0 0118 0z"}),r("circle",{cx:"12",cy:"10",r:"3"})]}),r("span",{className:"qr-header__title",children:_})]}),(()=>{const n=Array.from({length:We+1},(e,r)=>r)
285
+ return r("div",{className:"qr-progress",role:"progressbar","aria-valuenow":je+1,"aria-valuemin":1,"aria-valuemax":We+1,"aria-label":`Step ${je+1} of ${We+1}`,children:n.map(n=>e(a.Fragment,{children:[r("div",{className:"qr-progress__dot"+(je>=n?" qr-progress__dot--active":"")}),n<We&&r("div",{className:"qr-progress__line"+(je>n?" qr-progress__line--active":"")})]},n))})})()]}),E?r("div",{className:"qr-header-banner",role:"region","aria-label":"Merchant message",children:E}):null,ve?e("div",{className:"qr-offer-banner",role:"region","aria-label":"Special offer",children:[ve.banner_copy,ve.banner_cta_url?e(n,{children:[" ",r("a",{href:ve.banner_cta_url,target:"_blank",rel:"noopener noreferrer",children:"Learn more"})]}):null]}):null]}),"email"===re&&O&&r(Ce,{onOtpSent:(e,r)=>{he(e),fe(Boolean(null==r?void 0:r.reused)),$e({type:"email_otp_sent",step:"email-otp",mobile:e}),ne("email-otp")},onSkip:Ue,functionBaseUrl:k,merchantId:N}),"email-otp"===re&&O&&de&&r(Ee,{email:de,codeReused:me,onVerified:(e,r,n)=>{se({mobile:de,sessionToken:e,sessionId:n??"",buyerId:r}),$e({type:"email_verified",step:"saved",buyerId:r,sessionId:n}),ne("saved")},onBack:Re,functionBaseUrl:k,merchantId:N,sessionContext:Be}),"phone"===re&&w&&r(ue,{onOtpSent:e=>{se(r=>({mobile:e,sessionToken:"",sessionId:"",buyerId:(null==r?void 0:r.buyerId)??""})),$e({type:"otp_sent",step:"otp",mobile:e}),ne("otp")},onSkip:Ue,functionBaseUrl:k,merchantId:N}),"otp"===re&&le&&r(pe,{mobile:le.mobile,onVerified:(e,r,n)=>{se({mobile:(null==le?void 0:le.mobile)??"",sessionToken:e,sessionId:n??"",buyerId:r}),$e({type:"phone_verified",step:"saved",buyerId:r,sessionId:n}),ne("saved")},onBack:Re,functionBaseUrl:k,merchantId:N,sessionContext:Be}),"saved"===re&&(null==le?void 0:le.sessionToken)&&r(ge,{sessionToken:le.sessionToken,functionBaseUrl:k,merchantId:N,onSelectAddress:e=>{var r
286
+ $e({type:"saved_address_selected",step:ee?"payment":"done",buyerId:null==le?void 0:le.buyerId,digipin:e.digipin}),(null==le?void 0:le.sessionToken)&&J(Oe,le.sessionToken,{pincode:e.pincode,digipin:e.digipin,state:e.state,district:e.district,locality:e.locality}).catch(()=>{})
272
287
  const n={digipin:e.digipin,lat:e.lat,lng:e.lng,state:e.state,district:e.district,division:"",locality:e.locality,pincode:e.pincode,delivery:e.delivery_status,country:"India",flatNumber:e.flat_number,floorNumber:e.floor_number,buildingName:e.building_name,streetName:e.street_name,formattedAddress:[e.flat_number,e.building_name,e.street_name,e.locality,e.district,e.state,e.pincode].filter(Boolean).join(", "),label:"work"===e.label||"other"===e.label?e.label:"home",labelText:(null==(r=e.label_text)?void 0:r.trim())||void 0,addressId:e.id}
273
- Me(n)},onAddNew:()=>K("map")}),"map"===G&&r(O,{onLocationConfirm:(e,r,n)=>{Z({lat:e,lng:r,digipin:n}),Ae({type:"location_confirmed",step:"form",digipin:n,buyerId:null==te?void 0:te.buyerId}),K("form")},defaultLat:p,defaultLng:m,mapHeight:v,theme:f,indiaBoundaryUrl:g,enableSearch:q,apiKey:l,apiBaseUrl:d,brandColor:x}),"form"===G&&Q&&r(j,{digipin:Q.digipin,lat:Q.lat,lng:Q.lng,apiKey:l,apiBaseUrl:d,onAddressComplete:async e=>{await Me(e)},onBack:De,onError:h,theme:f}),"payment"===G&&J&&Pe&&M&&r(ge,{checkoutConfig:Ie,sessionToken:Pe,sessionId:null==te?void 0:te.sessionId,amountPaise:M,enableCod:L,codAllowed:he,theme:f,onComplete:e=>{we(e),Ae({type:"payment_method_selected",step:"done",paymentMethod:e}),K("done"),X&&u(X),null==D||D({paymentMethod:e,sessionId:null==te?void 0:te.sessionId})},onBack:De,onEvent:(e,r)=>Ae({type:e,step:"payment",paymentMethod:r,buyerId:null==te?void 0:te.buyerId})}),"done"===G&&X&&e(n,{children:[r(Te,{address:X,onEditAddress:()=>{Ae({type:"widget_reset",step:z}),K(z),Z(null),ae(null)}}),_e?e("p",{className:"qr-cod-banner__text qr-cod-banner__text--ok",style:{textAlign:"center",margin:"8px 16px"},children:["Paid via ","cod"===_e?"Cash on Delivery":"online payment"]}):null,L&&N&&k&&Pe?e(n,{children:[r(ye,{checkoutConfig:Ie,sessionToken:Pe,pincode:X.pincode,cartTotalPaise:T??M,theme:f,onCodAllowedChange:pe}),U&&he?r(ve,{copy:F??"Save more when you pay online — faster delivery & exclusive offers.",ctaUrl:R,theme:f}):null]}):null]}),e("div",{className:"qr-footer",children:[r("span",{children:"Powered by"}),r("a",{href:"https://quantaroute.com",target:"_blank",rel:"noopener noreferrer",className:"qr-footer__link",children:"QuantaRoute"}),r("span",{className:"qr-footer__flag","aria-label":"Made in India",children:"🇮🇳"})]})]})}
274
- function Pe(e,r){return c(()=>{if(!x(e,r))return null
275
- try{return w(e,r)}catch{return null}},[e,r])}export{j as AddressForm,Ie as CheckoutWidget,ye as CodAvailabilityBanner,p as DIGIPIN_BOUNDS,Ne as EmailOtpStep,qe as EmailStep,O as MapPinSelector,de as OtpStep,ge as PaymentStep,le as PhoneStep,ve as PrepaidNudge,be as SavedAddressStep,A as autocompleteAddress,Se as captureUtmFromUrl,X as checkCodEligibility,P as couldBeDigiPinInput,H as createAddress,ae as createPaymentOrder,Ie as default,G as deleteAddress,ke as detectDeviceType,xe as detectPlatform,oe as fetchPrepaidNudgeConfig,ne as fetchSessionOffer,g as formatDigiPin,w as getDigiPin,N as getLatLngFromDigiPin,Ce as getWebDeviceContext,Le as hasUtmParams,q as isCompleteDigiPinInput,_ as isPotentialDigiPinInput,k as isValidDigiPin,x as isWithinIndia,J as listAddresses,ee as logFunnelEvent,I as looksLikeDigiPin,S as lookupLocation,v as normalizeDigiPinInput,Y as notifyAddressCompleted,re as notifySessionAbandoned,T as pincodeHasDeliveryOffice,ie as recordCodPayment,B as reverseGeocode,Q as sendEmailOtp,W as sendOtp,K as setDefaultAddress,Pe as useDigiPin,$ as useGeolocation,L as validatePincode,Z as verifyEmailOtp,V as verifyOtp,te as verifyPayment}
288
+ Fe(n)},onAddNew:()=>ne("map")}),"map"===re&&r(M,{onLocationConfirm:(e,r,n)=>{te({lat:e,lng:r,digipin:n}),$e({type:"location_confirmed",step:"form",digipin:n,buyerId:null==le?void 0:le.buyerId}),ne("form")},defaultLat:p,defaultLng:m,mapHeight:v,theme:f,indiaBoundaryUrl:g,enableSearch:q,apiKey:l,apiBaseUrl:d,brandColor:C}),"form"===re&&ae&&r(ce,{digipin:ae.digipin,lat:ae.lat,lng:ae.lng,apiKey:l,apiBaseUrl:d,onAddressComplete:async e=>{await Fe(e)},onBack:Re,onError:h,theme:f,checkoutConfig:Oe,serviceabilitySessionToken:De,enableServiceabilityCheck:T,showIndiaPostDeliveryWarning:I,serviceabilityBlockCheckout:P}),"payment"===re&&ee&&De&&F&&r(ke,{checkoutConfig:Oe,sessionToken:De,sessionId:null==le?void 0:le.sessionId,amountPaise:F,enableCod:L,codAllowed:ye,theme:f,onComplete:({paymentMethod:e,razorpayOrderId:r,razorpayPaymentId:n})=>{xe(e),$e({type:"payment_method_selected",step:"done",paymentMethod:e}),ne("done"),ie&&u(ie),null==R||R({paymentMethod:e,sessionId:null==le?void 0:le.sessionId,razorpayOrderId:r,razorpayPaymentId:n})},onBack:Re,onEvent:(e,r)=>$e({type:e,step:"payment",paymentMethod:r,buyerId:null==le?void 0:le.buyerId}),orderConfirmationUrl:G}),"done"===re&&ie&&e(n,{children:[r(Ae,{address:ie,onEditAddress:()=>{$e({type:"widget_reset",step:Y}),ne(Y),te(null),oe(null)}}),Ne?e("p",{className:"qr-cod-banner__text qr-cod-banner__text--ok",style:{textAlign:"center",margin:"8px 16px"},children:["Paid via ","cod"===Ne?"Cash on Delivery":"online payment"]}):null,L&&N&&k&&De?e(n,{children:[r(qe,{checkoutConfig:Oe,sessionToken:De,pincode:ie.pincode,cartTotalPaise:B??F,theme:f,onCodAllowedChange:be}),j&&ye?r(we,{copy:z??"Save more when you pay online — faster delivery & exclusive offers.",ctaUrl:V,theme:f}):null]}):null]}),e("div",{className:"qr-footer",children:[r("span",{children:"Powered by"}),r("a",{href:"https://quantaroute.com",target:"_blank",rel:"noopener noreferrer",className:"qr-footer__link",children:"QuantaRoute"}),r("span",{className:"qr-footer__flag","aria-label":"Made in India",children:"🇮🇳"})]})]})}
289
+ function De(e,r){return c(()=>{if(!C(e,r))return null
290
+ try{return w(e,r)}catch{return null}},[e,r])}export{ce as AddressForm,Oe as CheckoutWidget,qe as CodAvailabilityBanner,p as DIGIPIN_BOUNDS,Ee as EmailOtpStep,Ce as EmailStep,M as MapPinSelector,pe as OtpStep,ke as PaymentStep,ue as PhoneStep,we as PrepaidNudge,ge as SavedAddressStep,B as autocompleteAddress,Pe as captureUtmFromUrl,K as checkCodEligibility,Y as checkServiceability,P as couldBeDigiPinInput,W as createAddress,ee as createPaymentOrder,Oe as default,z as deleteAddress,Se as detectDeviceType,Le as detectPlatform,ae as fetchPrepaidNudgeConfig,X as fetchSessionOffer,g as formatDigiPin,w as getDigiPin,N as getLatLngFromDigiPin,Te as getWebDeviceContext,Be as hasUtmParams,q as isCompleteDigiPinInput,_ as isPotentialDigiPinInput,k as isValidDigiPin,C as isWithinIndia,j as listAddresses,Q as logFunnelEvent,I as looksLikeDigiPin,S as lookupLocation,v as normalizeDigiPinInput,J as notifyAddressCompleted,Z as notifySessionAbandoned,T as pincodeHasDeliveryOffice,ne as recordCodPayment,A as reverseGeocode,H as sendEmailOtp,U as sendOtp,V as setDefaultAddress,De as useDigiPin,O as useGeolocation,L as validatePincode,G as verifyEmailOtp,F as verifyOtp,re as verifyPayment}