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