@quantaroute/checkout 1.4.3 → 1.4.4

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