@quantaroute/checkout 1.7.0 → 1.7.1

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.
@@ -91,12 +91,15 @@ W(r),K(r.length>0)}catch(e){H(e instanceof Error?e.message:"Search failed"),W([]
91
91
  te(e.coordinates.latitude,e.coordinates.longitude),R(""),W([]),K(!1),null==(r=Q.current)||r.blur()},[te]),le=i(e=>{"Escape"===e.key&&(W([]),K(!1),R(""))},[])
92
92
  s(()=>{if(!v.current)return
93
93
  const e=p?fetch(p).then(e=>e.ok?e.json():null).catch(()=>null):Promise.resolve(null),r=C?18:9,a=new u.Map({container:v.current,style:"https://basemaps.cartocdn.com/gl/positron-gl-style/style.json",center:[k,w],zoom:r,minZoom:6,attributionControl:!1,touchZoomRotate:!0})
94
- return a.addControl(new u.AttributionControl({compact:!0,customAttribution:'© <a href="https://www.openstreetmap.org/copyright" target="_blank" rel="noopener">OpenStreetMap</a> contributors &nbsp;© <a href="https://carto.com/attributions" target="_blank" rel="noopener">CARTO</a>'}),"bottom-right"),a.addControl(new u.NavigationControl({showCompass:!1}),"top-right"),a.on("load",()=>{U(!0),e.then(e=>{if(e&&a.isStyleLoaded())try{a.addSource("india-boundary",{type:"geojson",data:e}),a.addLayer({id:"india-boundary-line",type:"line",source:"india-boundary",paint:{"line-color":"#94a3b8","line-width":1.5,"line-opacity":.65}})}catch{}})
95
- const r=function(e=D){const r=document.createElement("div")
96
- return r.className="qr-pin",r.setAttribute("aria-label","Drag to adjust your location"),r.style.width="40px",r.style.height="52px",r.innerHTML=`\n <svg\n class="qr-pin__svg"\n width="40"\n height="52"\n viewBox="0 0 40 52"\n overflow="visible"\n fill="none"\n xmlns="http://www.w3.org/2000/svg"\n aria-hidden="true"\n >\n <defs>\n \x3c!--\n The filter region must be generous enough to contain the shadow blur.\n stdDeviation=3 → ~9px blur radius; our region extends 50% on each side.\n overflow="visible" on the <svg> lets it paint outside the viewport.\n --\x3e\n <filter id="qr-pin-shadow" x="-60%" y="-40%" width="220%" height="220%">\n <feDropShadow dx="0" dy="3" stdDeviation="3.5"\n flood-color="#000" flood-opacity="0.28"/>\n </filter>\n </defs>\n\n \x3c!-- Teardrop body — tip is at (20, 52) = bottom-center of the SVG --\x3e\n <path\n d="M20 0C9.402 0 0 9.402 0 20C0 34 20 52 20 52S40 34 40 20C40 9.402 30.598 0 20 0Z"\n fill="${e}"\n filter="url(#qr-pin-shadow)"\n />\n \x3c!-- Dot inside the pin --\x3e\n <circle cx="20" cy="20" r="9" fill="white"/>\n <circle cx="20" cy="20" r="5" fill="${e}"/>\n </svg>\n\n \x3c!--\n Pulse ring — position: absolute inside .qr-pin (position: relative).\n bottom: -(height/2) → bottom: -10px centres the 20×20 circle\n exactly at y = PIN_H = 52px = the pin tip coordinate.\n --\x3e\n <div class="qr-pin__pulse" aria-hidden="true"></div>\n `,r}(b),n=new u.Marker({element:r,draggable:!0,anchor:"bottom"}).setLngLat([k,w]).addTo(a)
97
- n.on("drag",()=>{const e=n.getLngLat()
98
- E(e.lat),L(e.lng),ne(e.lat,e.lng)}),n.on("dragend",()=>{const e=n.getLngLat()
99
- a.easeTo({center:[e.lng,e.lat],duration:250})}),q.current=n}),a.on("click",e=>{var r
94
+ return a.addControl(new u.AttributionControl({compact:!0,customAttribution:'© <a href="https://www.openstreetmap.org/copyright" target="_blank" rel="noopener">OpenStreetMap</a> contributors &nbsp;© <a href="https://carto.com/attributions" target="_blank" rel="noopener">CARTO</a>'}),"bottom-right"),a.addControl(new u.NavigationControl({showCompass:!1}),"top-right"),a.on("load",()=>{var r
95
+ U(!0)
96
+ const n=null==(r=v.current)?void 0:r.querySelector(".maplibregl-ctrl-attrib.maplibregl-compact")
97
+ n instanceof HTMLElement&&(n.classList.remove("maplibregl-compact-show"),n.setAttribute("open","")),e.then(e=>{if(e&&a.isStyleLoaded())try{a.addSource("india-boundary",{type:"geojson",data:e}),a.addLayer({id:"india-boundary-line",type:"line",source:"india-boundary",paint:{"line-color":"#94a3b8","line-width":1.5,"line-opacity":.65}})}catch{}})
98
+ const t=function(e=D){const r=document.createElement("div")
99
+ return r.className="qr-pin",r.setAttribute("aria-label","Drag to adjust your location"),r.style.width="40px",r.style.height="52px",r.innerHTML=`\n <svg\n class="qr-pin__svg"\n width="40"\n height="52"\n viewBox="0 0 40 52"\n overflow="visible"\n fill="none"\n xmlns="http://www.w3.org/2000/svg"\n aria-hidden="true"\n >\n <defs>\n \x3c!--\n The filter region must be generous enough to contain the shadow blur.\n stdDeviation=3 → ~9px blur radius; our region extends 50% on each side.\n overflow="visible" on the <svg> lets it paint outside the viewport.\n --\x3e\n <filter id="qr-pin-shadow" x="-60%" y="-40%" width="220%" height="220%">\n <feDropShadow dx="0" dy="3" stdDeviation="3.5"\n flood-color="#000" flood-opacity="0.28"/>\n </filter>\n </defs>\n\n \x3c!-- Teardrop body — tip is at (20, 52) = bottom-center of the SVG --\x3e\n <path\n d="M20 0C9.402 0 0 9.402 0 20C0 34 20 52 20 52S40 34 40 20C40 9.402 30.598 0 20 0Z"\n fill="${e}"\n filter="url(#qr-pin-shadow)"\n />\n \x3c!-- Dot inside the pin --\x3e\n <circle cx="20" cy="20" r="9" fill="white"/>\n <circle cx="20" cy="20" r="5" fill="${e}"/>\n </svg>\n\n \x3c!--\n Pulse ring — position: absolute inside .qr-pin (position: relative).\n bottom: -(height/2) → bottom: -10px centres the 20×20 circle\n exactly at y = PIN_H = 52px = the pin tip coordinate.\n --\x3e\n <div class="qr-pin__pulse" aria-hidden="true"></div>\n `,r}(b),i=new u.Marker({element:t,draggable:!0,anchor:"bottom"}).setLngLat([k,w]).addTo(a)
100
+ i.on("drag",()=>{const e=i.getLngLat()
101
+ E(e.lat),L(e.lng),ne(e.lat,e.lng)}),i.on("dragend",()=>{const e=i.getLngLat()
102
+ a.easeTo({center:[e.lng,e.lat],duration:250})}),q.current=i}),a.on("click",e=>{var r
100
103
  const n=e.lngLat
101
104
  null==(r=q.current)||r.setLngLat([n.lng,n.lat]),E(n.lat),L(n.lng),ne(n.lat,n.lng),a.easeTo({center:[n.lng,n.lat],duration:200})}),_.current=a,()=>{a.remove(),_.current=null,q.current=null}},[])
102
105
  const se=i(()=>{ae(),re((e,r)=>{var a
@@ -123,33 +126,35 @@ return i}async function Q(e,r,a,n){const t={action:"cod_eligibility",pincode:a}
123
126
  void 0!==n&&(t.cart_total_paise=n)
124
127
  const i=await fetch(`${e.functionBaseUrl}/checkout-addresses`,{method:"POST",headers:R(r),body:JSON.stringify(t)}),o=await i.json().catch(()=>({}))
125
128
  if(!i.ok||!o.success)throw new Error(o.error??"Failed to check COD eligibility.")
126
- return o.data}async function Z(e,r,a,n){const t=await fetch(`${e.functionBaseUrl}/checkout-addresses`,{method:"POST",headers:R(r),body:JSON.stringify({action:"serviceability_check",pincode:a,...void 0!==(null==n?void 0:n.lat)?{lat:n.lat}:{},...void 0!==(null==n?void 0:n.lng)?{lng:n.lng}:{}})}),i=await t.json().catch(()=>({}))
129
+ return o.data}async function Z(e,r,a){const n=await fetch(`${e.functionBaseUrl}/checkout-addresses`,{method:"POST",headers:R(r),body:JSON.stringify({action:"address_risk",data:a})}),t=await n.json().catch(()=>({}))
130
+ if(!n.ok||!t.success)throw new Error(t.error??"Failed to score address risk.")
131
+ return t.data}async function X(e,r,a,n){const t=await fetch(`${e.functionBaseUrl}/checkout-addresses`,{method:"POST",headers:R(r),body:JSON.stringify({action:"serviceability_check",pincode:a,...void 0!==(null==n?void 0:n.lat)?{lat:n.lat}:{},...void 0!==(null==n?void 0:n.lng)?{lng:n.lng}:{}})}),i=await t.json().catch(()=>({}))
127
132
  if(!t.ok||!i.success)throw new Error(i.error??"Failed to check delivery serviceability.")
128
- return i.data}async function X(e,r,a){try{const n={"Content-Type":"application/json"}
129
- a&&(n["x-session-token"]=a),await fetch(`${e.functionBaseUrl}/checkout-funnel-events`,{method:"POST",headers:n,body:JSON.stringify({merchant_id:e.merchantId,...r})})}catch{}}async function ee(e,r,a){try{await fetch(`${e.functionBaseUrl}/checkout-addresses`,{method:"POST",headers:R(r),body:JSON.stringify({action:"abandon",last_step:a})})}catch{}}async function re(e,r){const a=await fetch(`${e.functionBaseUrl}/checkout-offers`,{method:"GET",headers:R(r)}),n=await a.json().catch(()=>({}))
130
- return a.ok&&n.success?n.data??null:null}async function ae(e,r,a){const n=await fetch(`${e.functionBaseUrl}/checkout-payment`,{method:"POST",headers:R(r),body:JSON.stringify({action:"create_order",amount_paise:a})}),t=await n.json().catch(()=>({}))
133
+ return i.data}async function ee(e,r,a){try{const n={"Content-Type":"application/json"}
134
+ a&&(n["x-session-token"]=a),await fetch(`${e.functionBaseUrl}/checkout-funnel-events`,{method:"POST",headers:n,body:JSON.stringify({merchant_id:e.merchantId,...r})})}catch{}}async function re(e,r,a){try{await fetch(`${e.functionBaseUrl}/checkout-addresses`,{method:"POST",headers:R(r),body:JSON.stringify({action:"abandon",last_step:a})})}catch{}}async function ae(e,r){const a=await fetch(`${e.functionBaseUrl}/checkout-offers`,{method:"GET",headers:R(r)}),n=await a.json().catch(()=>({}))
135
+ return a.ok&&n.success?n.data??null:null}async function ne(e,r,a){const n=await fetch(`${e.functionBaseUrl}/checkout-payment`,{method:"POST",headers:R(r),body:JSON.stringify({action:"create_order",amount_paise:a})}),t=await n.json().catch(()=>({}))
131
136
  if(!n.ok||!t.success)throw new Error(t.error??"Failed to create payment order.")
132
- return t.data}async function ne(e,r,a){const n=await fetch(`${e.functionBaseUrl}/checkout-payment`,{method:"POST",headers:R(r),body:JSON.stringify({action:"verify",...a})}),t=await n.json().catch(()=>({}))
137
+ return t.data}async function te(e,r,a){const n=await fetch(`${e.functionBaseUrl}/checkout-payment`,{method:"POST",headers:R(r),body:JSON.stringify({action:"verify",...a})}),t=await n.json().catch(()=>({}))
133
138
  if(!n.ok||!t.success)throw new Error(t.error??"Payment verification failed.")
134
- return{payment_method:t.payment_method,razorpay_order_id:t.razorpay_order_id,razorpay_payment_id:t.razorpay_payment_id}}async function te(e,r){const a=await fetch(`${e.functionBaseUrl}/checkout-payment`,{method:"POST",headers:R(r),body:JSON.stringify({action:"record_cod"})}),n=await a.json().catch(()=>({}))
139
+ return{payment_method:t.payment_method,razorpay_order_id:t.razorpay_order_id,razorpay_payment_id:t.razorpay_payment_id}}async function ie(e,r){const a=await fetch(`${e.functionBaseUrl}/checkout-payment`,{method:"POST",headers:R(r),body:JSON.stringify({action:"record_cod"})}),n=await a.json().catch(()=>({}))
135
140
  if(!a.ok||!n.success)throw new Error(n.error??"Failed to record COD selection.")
136
- return{payment_method:n.payment_method}}async function ie(e,r){const a=await fetch(`${e}/checkout-admin?action=cod_config`,{headers:{"x-api-key":r}}),n=await a.json().catch(()=>({}))
137
- return a.ok&&n.success?{prepaid_nudge_copy:n.data.prepaid_nudge_copy,prepaid_nudge_cta_url:n.data.prepaid_nudge_cta_url}:null}const oe=/\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
138
- function le(e){return e.replace(oe,"").replace(/\s+/g," ").trim()}function se(e){return le(e).toLowerCase()}function de({label:a,className:n}){const t={className:n,"aria-hidden":!0,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}
141
+ return{payment_method:n.payment_method}}async function oe(e,r){const a=await fetch(`${e}/checkout-admin?action=cod_config`,{headers:{"x-api-key":r}}),n=await a.json().catch(()=>({}))
142
+ return a.ok&&n.success?{prepaid_nudge_copy:n.data.prepaid_nudge_copy,prepaid_nudge_cta_url:n.data.prepaid_nudge_cta_url}:null}const le=/\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
143
+ function se(e){return e.replace(le,"").replace(/\s+/g," ").trim()}function de(e){return se(e).toLowerCase()}function ce({label:a,className:n}){const t={className:n,"aria-hidden":!0,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}
139
144
  switch(a){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"})]})
140
145
  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"})]})
141
- 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 ce={flatNumber:"",floorNumber:"",buildingName:"",streetName:""}
142
- function ue(e,r){var a
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 ue={flatNumber:"",floorNumber:"",buildingName:"",streetName:""}
147
+ function he(e,r){var a
143
148
  switch(r.type){case"LOAD_START":return{status:"loading"}
144
149
  case"LOAD_SUCCESS":{const e=function(e){const r={}
145
150
  e.name?r.buildingName=e.name:e.building_name?r.buildingName=e.building_name:e.addr_housename&&(r.buildingName=e.addr_housename)
146
151
  const a=[]
147
- return e.road&&a.push(e.road),e.suburb&&a.push(e.suburb),a.length>0&&(r.streetName=a.join(", ")),r}(r.addressComponents),n=r.initialValues,t={...ce,...e,...void 0!==(null==n?void 0:n.flatNumber)?{flatNumber:n.flatNumber}:{},...void 0!==(null==n?void 0:n.floorNumber)?{floorNumber:n.floorNumber}:{},...void 0!==(null==n?void 0:n.buildingName)?{buildingName:n.buildingName}:{},...void 0!==(null==n?void 0:n.streetName)?{streetName:n.streetName}:{}},i=function(e,r=[]){const a=new Set,n=[],t=e=>{const r=se(e)
148
- r&&!a.has(r)&&(a.add(r),n.push(le(e)))}
152
+ return e.road&&a.push(e.road),e.suburb&&a.push(e.suburb),a.length>0&&(r.streetName=a.join(", ")),r}(r.addressComponents),n=r.initialValues,t={...ue,...e,...void 0!==(null==n?void 0:n.flatNumber)?{flatNumber:n.flatNumber}:{},...void 0!==(null==n?void 0:n.floorNumber)?{floorNumber:n.floorNumber}:{},...void 0!==(null==n?void 0:n.buildingName)?{buildingName:n.buildingName}:{},...void 0!==(null==n?void 0:n.streetName)?{streetName:n.streetName}:{}},i=function(e,r=[]){const a=new Set,n=[],t=e=>{const r=de(e)
153
+ r&&!a.has(r)&&(a.add(r),n.push(se(e)))}
149
154
  t(e.locality)
150
155
  for(const e of r)t(e.name)
151
- const i=le(e.locality),o=se(e.locality),l=r.map(e=>({...e,name:le(e.name)})).filter(e=>{const r=se(e.name)
152
- return r&&r!==o}).filter((e,r,a)=>a.findIndex(r=>se(r.name)===se(e.name))===r)
156
+ const i=se(e.locality),o=de(e.locality),l=r.map(e=>({...e,name:se(e.name)})).filter(e=>{const r=de(e.name)
157
+ return r&&r!==o}).filter((e,r,a)=>a.findIndex(r=>de(r.name)===de(e.name))===r)
153
158
  return{adminInfo:{...e,locality:i},alternatives:l,localityOptions:n,selectedLocality:i}}(r.adminInfo,r.alternatives||[])
154
159
  let o=i.localityOptions,l=i.selectedLocality
155
160
  if(null==(a=null==n?void 0:n.locality)?void 0:a.trim()){const e=n.locality.trim()
@@ -161,8 +166,8 @@ case"SET_LABEL":return"ready"!==e.status?e:{...e,selectedLabel:r.label,labelText
161
166
  case"SET_LABEL_TEXT":return"ready"!==e.status?e:{...e,labelText:r.value.slice(0,64)}
162
167
  case"SUBMIT_START":return"ready"!==e.status?e:{...e,submitting:!0}
163
168
  case"SUBMIT_END":return"ready"!==e.status?e:{...e,submitting:!1}
164
- default:return e}}const he=({digipin:n,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
165
- const[x,E]=d(ue,{status:"loading"}),P=i(async()=>{var e
169
+ default:return e}}const pe=({digipin:n,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
170
+ const[x,E]=d(he,{status:"loading"}),P=i(async()=>{var e
166
171
  E({type:"LOAD_START"})
167
172
  try{const[r,a]=await Promise.all([S(t,o,l,c),A(n,l,c)]),i=(null==(e=r.data.administrative_info.pincode)?void 0:e.replace(/\D/g,"").slice(0,6))??""
168
173
  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")))
@@ -170,7 +175,7 @@ const s=await L(i,l,c)
170
175
  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")))
171
176
  const d=I(s.offices)
172
177
  let u=null
173
- if(f&&(null==m?void 0:m.functionBaseUrl)&&m.merchantId&&y)try{u=await Z(m,y,i,{lat:t,lng:o}),null==_||_(u)}catch{}E({type:"LOAD_SUCCESS",adminInfo:r.data.administrative_info,alternatives:r.data.alternatives||[],addressComponents:a.data.addressComponents,pincodeHasDelivery:d,serviceabilityResult:u,initialValues:g})}catch(e){const r=e instanceof Error?e.message:"Failed to fetch address data."
178
+ if(f&&(null==m?void 0:m.functionBaseUrl)&&m.merchantId&&y)try{u=await X(m,y,i,{lat:t,lng:o}),null==_||_(u)}catch{}E({type:"LOAD_SUCCESS",adminInfo:r.data.administrative_info,alternatives:r.data.alternatives||[],addressComponents:a.data.addressComponents,pincodeHasDelivery:d,serviceabilityResult:u,initialValues:g})}catch(e){const r=e instanceof Error?e.message:"Failed to fetch address data."
174
179
  E({type:"LOAD_ERROR",message:r}),null==p||p(e instanceof Error?e:new Error(r))}},[n,t,o,l,c,p,m,y,f,_,g])
175
180
  s(()=>{P()},[P])
176
181
  const T=i(e=>{var r
@@ -181,13 +186,13 @@ if((null==(r=x.serviceabilityResult)?void 0:r.checked)&&!1===x.serviceabilityRes
181
186
  const c=[d.flatNumber,d.floorNumber?`Floor ${d.floorNumber}`:"",d.buildingName,d.streetName,i,a.district,a.state,a.pincode].filter(Boolean),h={digipin:n,lat:t,lng:o,state:a.state,district:a.district,division:a.division,locality:i,pincode:a.pincode,delivery:a.delivery,country:a.country??"India",...d,formattedAddress:c.join(", "),label:l,..."other"===l?{labelText:s.trim()}:{}}
182
187
  E({type:"SUBMIT_START"})
183
188
  try{u(h)}finally{E({type:"SUBMIT_END"})}},[x,n,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,$="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)
184
- 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:n})]}),"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.")})]})]}),$&&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:a,title:n})=>e("button",{type:"button",role:"radio","aria-checked":x.selectedLabel===a,className:"qr-label-picker__option"+(x.selectedLabel===a?" qr-label-picker__option--active":""),onClick:()=>E({type:"SET_LABEL",label:a}),children:[r("span",{className:"qr-label-picker__icon",children:r(de,{label:a})}),r("span",{children:n})]},a))}),"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(a,{children:[r("span",{className:"qr-spinner qr-spinner--sm","aria-hidden":"true"}),"Saving…"]}):e(a,{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"})})]})})]})]})]})},pe=({onOtpSent:n,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
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:n})]}),"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.")})]})]}),$&&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:a,title:n})=>e("button",{type:"button",role:"radio","aria-checked":x.selectedLabel===a,className:"qr-label-picker__option"+(x.selectedLabel===a?" qr-label-picker__option--active":""),onClick:()=>E({type:"SET_LABEL",label:a}),children:[r("span",{className:"qr-label-picker__icon",children:r(ce,{label:a})}),r("span",{children:n})]},a))}),"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(a,{children:[r("span",{className:"qr-spinner qr-spinner--sm","aria-hidden":"true"}),"Saving…"]}):e(a,{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"})})]})})]})]})]})},me=({onOtpSent:n,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
185
190
  if(e.preventDefault(),10!==c.length)return y("Enter a valid 10-digit mobile number."),void(null==(r=f.current)||r.focus())
186
191
  p(!0),y(null)
187
192
  try{await U({functionBaseUrl:s,merchantId:d},`+91${c}`),n(`+91${c}`)}catch(e){y(e instanceof Error?e.message:"Failed to send OTP. Please try again.")}finally{p(!1)}},[c,s,d,n])
188
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(a,{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"})]})}
189
- function me(e){const r=e.replace(/\D/g,"")
190
- return r.length<4?e:`+91 ${r.slice(2,7)} **${r.slice(-3)}`}const ye=({mobile:a,onVerified:n,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)
194
+ function ye(e){const r=e.replace(/\D/g,"")
195
+ return r.length<4?e:`+91 ${r.slice(2,7)} **${r.slice(-3)}`}const fe=({mobile:a,onVerified:n,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)
191
196
  s(()=>(N.current=setInterval(()=>{_(e=>e<=1?(clearInterval(N.current),0):e-1)},1e3),()=>{N.current&&clearInterval(N.current)}),[])
192
197
  const k=e=>{var r
193
198
  null==(r=w.current[e])||r.focus()},C=i((e,r)=>{const a=r.replace(/\D/g,"").slice(-1)
@@ -204,11 +209,11 @@ n(e.session_token,e.buyer_id,e.session_id)}catch(e){b(e instanceof Error?e.messa
204
209
  s(()=>{L&&!m&&I()},[L])
205
210
  const P=i(async()=>{if(!(v>0||g)){q(!0),b(null),p(Array(6).fill(""))
206
211
  try{await U({functionBaseUrl:d,merchantId:c},a),_(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,a])
207
- 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:me(a)})]}),r("div",{className:"qr-otp-boxes",role:"group","aria-label":"Enter one-time password",children:h.map((e,a)=>r("input",{ref:e=>{w.current[a]=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(a,e.target.value),onKeyDown:e=>x(a,e),onPaste:E,onFocus:e=>e.target.select(),"aria-label":`OTP digit ${a+1}`,disabled:m,autoComplete:0===a?"one-time-code":"off"},a))}),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"})})]})},fe=()=>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"})]}),be=()=>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"})]}),ve=()=>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"})]})
208
- function _e({label:e}){return r("home"===e?fe:"work"===e?be:ve,{})}function ge(e){var r
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:ye(a)})]}),r("div",{className:"qr-otp-boxes",role:"group","aria-label":"Enter one-time password",children:h.map((e,a)=>r("input",{ref:e=>{w.current[a]=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(a,e.target.value),onKeyDown:e=>x(a,e),onPaste:E,onFocus:e=>e.target.select(),"aria-label":`OTP digit ${a+1}`,disabled:m,autoComplete:0===a?"one-time-code":"off"},a))}),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"})})]})},be=()=>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"})]}),ve=()=>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"})]}),_e=()=>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"})]})
213
+ function ge({label:e}){return r("home"===e?be:"work"===e?ve:_e,{})}function qe(e){var r
209
214
  const a=null==(r=e.label_text)?void 0:r.trim()
210
- return"other"===e.label&&a?a:e.label.charAt(0).toUpperCase()+e.label.slice(1)}function qe({address:n,onUse:t,onDelete:i,onSetDefault:o,deleting:l}){const s=[n.flat_number,n.building_name,n.street_name,n.locality,n.district,n.state,n.pincode].filter(Boolean),d=[n.flat_number,n.building_name,n.street_name].filter(Boolean).join(", "),c=[n.locality,n.district].filter(Boolean).join(", "),u=[n.state,n.pincode].filter(Boolean).join(" – "),h=s.length>0?void 0:n.locality||n.district||n.state
211
- return e("div",{className:"qr-addr-card"+(n.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(_e,{label:n.label})}),r("span",{className:"qr-addr-card__label",children:ge(n)}),n.is_default&&r("span",{className:"qr-addr-card__default-badge",children:"Default"}),e("div",{className:"qr-addr-card__actions",children:[!n.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(a,{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:[n.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:n.digipin})]}):r("span",{className:"qr-addr-card__pending-pin",children:"Pin confirmation needed"}),n.saved_at_brand&&e("span",{className:"qr-addr-card__brand-chip",title:`First saved at ${n.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"})}),n.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 we=({sessionToken:a,functionBaseUrl:n,merchantId:o,onSelectAddress:l,onAddNew:d})=>{const[c,u]=t([]),[h,p]=t(!0),[m,y]=t(null),[f,b]=t(null),v={functionBaseUrl:n,merchantId:o},_=i(async()=>{p(!0),y(null)
215
+ return"other"===e.label&&a?a:e.label.charAt(0).toUpperCase()+e.label.slice(1)}function we({address:n,onUse:t,onDelete:i,onSetDefault:o,deleting:l}){const s=[n.flat_number,n.building_name,n.street_name,n.locality,n.district,n.state,n.pincode].filter(Boolean),d=[n.flat_number,n.building_name,n.street_name].filter(Boolean).join(", "),c=[n.locality,n.district].filter(Boolean).join(", "),u=[n.state,n.pincode].filter(Boolean).join(" – "),h=s.length>0?void 0:n.locality||n.district||n.state
216
+ return e("div",{className:"qr-addr-card"+(n.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(ge,{label:n.label})}),r("span",{className:"qr-addr-card__label",children:qe(n)}),n.is_default&&r("span",{className:"qr-addr-card__default-badge",children:"Default"}),e("div",{className:"qr-addr-card__actions",children:[!n.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(a,{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:[n.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:n.digipin})]}):r("span",{className:"qr-addr-card__pending-pin",children:"Pin confirmation needed"}),n.saved_at_brand&&e("span",{className:"qr-addr-card__brand-chip",title:`First saved at ${n.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"})}),n.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 Ne=({sessionToken:a,functionBaseUrl:n,merchantId:o,onSelectAddress:l,onAddNew:d})=>{const[c,u]=t([]),[h,p]=t(!0),[m,y]=t(null),[f,b]=t(null),v={functionBaseUrl:n,merchantId:o},_=i(async()=>{p(!0),y(null)
212
217
  try{const e=await j(v,a)
213
218
  if(0===e.length)return void d()
214
219
  u(e)}catch(e){y(e instanceof Error?e.message:"Failed to load addresses.")}finally{p(!1)}},[a])
@@ -216,7 +221,7 @@ s(()=>{_()},[_])
216
221
  const g=i(async e=>{b(e)
217
222
  try{await z(v,a,e),u(r=>{const a=r.filter(r=>r.id!==e)
218
223
  return 0===a.length&&d(),a})}catch(e){y(e instanceof Error?e.message:"Failed to delete address.")}finally{b(null)}},[a,d]),q=i(async e=>{try{await V(v,a,e),u(r=>r.map(r=>({...r,is_default:r.id===e})))}catch(e){y(e instanceof Error?e.message:"Failed to set default.")}},[a])
219
- 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(qe,{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"]})]})},Ne=({checkoutConfig:a,sessionToken:n,pincode:i,cartTotalPaise:o,theme:l="light",onCodAllowedChange:d})=>{const[c,u]=t("loading"),[h,p]=t(!1),[m,y]=t()
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(we,{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"]})]})},ke=({checkoutConfig:a,sessionToken:n,pincode:i,cartTotalPaise:o,theme:l="light",onCodAllowedChange:d})=>{const[c,u]=t("loading"),[h,p]=t(!1),[m,y]=t()
220
225
  return s(()=>{let e=!1
221
226
  return u("loading"),(async()=>{try{const r=await Q(a,n,i,o)
222
227
  if(e)return
@@ -224,27 +229,27 @@ p(r.cod_allowed),null==d||d(r.cod_allowed),y(r.cod_allowed?void 0:r.reason?funct
224
229
  case"pincode_blocked":return"COD is not available for this pincode."
225
230
  case"cart_value_exceeded":return"COD is not available for this order value."
226
231
  case"invalid_pincode":return"Enter a valid pincode to check COD."
227
- 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,n,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})]})},ke=({copy:a,ctaUrl:n,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:a}),n?r("a",{href:n,className:"qr-btn qr-btn--primary qr-btn--sm qr-prepaid-nudge__cta",target:"_blank",rel:"noopener noreferrer",children:"Pay online instead"}):null]}),Ce="https://checkout.razorpay.com/v1/checkout.js",xe=({checkoutConfig:a,sessionToken:n,sessionId:i,amountPaise:o,enableCod:l=!1,codAllowed:d=!1,theme:c="light",onComplete:u,onBack:h,onEvent:p,orderConfirmationUrl:m})=>{const[y,f]=t(!1),[b,v]=t(null),_="dark"===c
228
- s(()=>{null==p||p("payment_step_viewed")},[p])
229
- const g=`₹${(o/100).toLocaleString("en-IN")}`
230
- return e("div",{className:"qr-payment-step"+(_?" qr-payment-step--dark":""),children:[h?r("button",{type:"button",className:"qr-back-btn qr-back-btn--auth",onClick:h,disabled:y,children:"← Back"}):null,r("h3",{className:"qr-auth-step__title",children:"Choose payment"}),e("p",{className:"qr-auth-step__sub",children:["Order total: ",r("strong",{children:g})]}),b?r("p",{className:"qr-auth-step__error",role:"alert",children:b}):null,e("button",{type:"button",className:"qr-payment-option qr-payment-option--primary",onClick:async()=>{f(!0),v(null)
231
- try{await(window.Razorpay?Promise.resolve():new Promise((e,r)=>{const a=document.querySelector(`script[src="${Ce}"]`)
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,n,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})]})},Ce=({copy:a,ctaUrl:n,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:a}),n?r("a",{href:n,className:"qr-btn qr-btn--primary qr-btn--sm qr-prepaid-nudge__cta",target:"_blank",rel:"noopener noreferrer",children:"Pay online instead"}):null]}),xe="https://checkout.razorpay.com/v1/checkout.js",Ee=({checkoutConfig:a,sessionToken:n,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
+ s(()=>{null==m||m("payment_step_viewed")},[m])
234
+ 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
+ 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 a=document.querySelector(`script[src="${xe}"]`)
232
237
  if(a)return void a.addEventListener("load",()=>e())
233
238
  const n=document.createElement("script")
234
- n.src=Ce,n.async=!0,n.onload=()=>e(),n.onerror=()=>r(new Error("Failed to load Razorpay")),document.body.appendChild(n)}))
235
- const e=await ae(a,n,o)
236
- 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 ne(a,n,{razorpay_order_id:e.razorpay_order_id,razorpay_payment_id:e.razorpay_payment_id,razorpay_signature:e.razorpay_signature,payment_method:"prepaid"})
237
- if(null==p||p("payment_method_selected",t.payment_method),u({paymentMethod:t.payment_method,razorpayOrderId:t.razorpay_order_id,razorpayPaymentId:t.razorpay_payment_id}),m){const e=m.replace("{{sessionId}}",i??"")
238
- window.location.href=e}r()}catch(e){t(e)}},modal:{ondismiss:()=>t(new Error("Payment cancelled"))}}).open():t(new Error("Razorpay unavailable"))})}catch(e){v(e instanceof Error?e.message:"Payment failed")}finally{f(!1)}},disabled:y,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:y?"Processing...":"Pay online"}),r("span",{className:"qr-payment-option__sub",children:"UPI, cards, wallets"})]}),r("strong",{className:"qr-payment-option__amount",children:g})]}),l&&d?e("button",{type:"button",className:"qr-payment-option qr-payment-option--secondary",onClick:async()=>{f(!0),v(null)
239
- try{const e=await te(a,n)
240
- null==p||p("payment_method_selected",e.payment_method),u({paymentMethod:e.payment_method})}catch(e){v(e instanceof Error?e.message:"Failed to select COD")}finally{f(!1)}},disabled:y,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]})},Ee=({onOtpSent:n,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
239
+ n.src=xe,n.async=!0,n.onload=()=>e(),n.onerror=()=>r(new Error("Failed to load Razorpay")),document.body.appendChild(n)}))
240
+ const e=await ne(a,n,o)
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 te(a,n,{razorpay_order_id:e.razorpay_order_id,razorpay_payment_id:e.razorpay_payment_id,razorpay_signature:e.razorpay_signature,payment_method:"prepaid"})
242
+ 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
+ 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 ie(a,n)
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]})},Se=({onOtpSent:n,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
241
246
  if(e.preventDefault(),!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(c))return y("Enter a valid email address."),void(null==(r=f.current)||r.focus())
242
247
  p(!0),y(null)
243
248
  try{const{reused:e}=await K({functionBaseUrl:s,merchantId:d},c)
244
249
  n(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,n])
245
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(a,{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"})]})}
246
- function Se(e){const[r,a]=e.split("@")
247
- return!a||r.length<=1?e:`${r[0]}***@${a}`}const Le=({email:n,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)
251
+ function Le(e){const[r,a]=e.split("@")
252
+ return!a||r.length<=1?e:`${r[0]}***@${a}`}const Ie=({email:n,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)
248
253
  s(()=>(C.current=setInterval(()=>{q(e=>e<=1?(clearInterval(C.current),0):e-1)},1e3),()=>{C.current&&clearInterval(C.current)}),[])
249
254
  const x=e=>{var r
250
255
  return null==(r=k.current[e])?void 0:r.focus()},E=i((e,r)=>{const a=r.replace(/\D/g,"").slice(-1)
@@ -261,40 +266,44 @@ d(e.session_token,e.buyer_id,e.session_id)}catch(e){_(e instanceof Error?e.messa
261
266
  s(()=>{P&&!f&&T()},[P])
262
267
  const B=i(async()=>{if(!(g>0||w)){N(!0),_(null),y(Array(6).fill(""))
263
268
  try{await K({functionBaseUrl:u,merchantId:h},n),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,n])
264
- 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(a,{children:"Use the code we sent earlier — it's still valid for your next checkout."}):e(a,{children:["6-digit code sent to ",r("strong",{children:Se(n)})]})}),r("div",{className:"qr-otp-boxes",role:"group","aria-label":"Enter verification code",children:m.map((e,a)=>r("input",{ref:e=>{k.current[a]=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(a,e.target.value),onKeyDown:e=>S(a,e),onPaste:L,onFocus:e=>e.target.select(),"aria-label":`Code digit ${a+1}`,disabled:f,autoComplete:0===a?"one-time-code":"off"},a))}),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"})})]})}
265
- function Ie(e){if("undefined"!=typeof window){const e=window.innerWidth
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(a,{children:"Use the code we sent earlier — it's still valid for your next checkout."}):e(a,{children:["6-digit code sent to ",r("strong",{children:Le(n)})]})}),r("div",{className:"qr-otp-boxes",role:"group","aria-label":"Enter verification code",children:m.map((e,a)=>r("input",{ref:e=>{k.current[a]=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(a,e.target.value),onKeyDown:e=>S(a,e),onPaste:L,onFocus:e=>e.target.select(),"aria-label":`Code digit ${a+1}`,disabled:f,autoComplete:0===a?"one-time-code":"off"},a))}),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"})})]})}
270
+ function Pe(e){if("undefined"!=typeof window){const e=window.innerWidth
266
271
  return e<768?"mobile":e<1024?"tablet":"desktop"}const r=(e??"").toLowerCase()
267
- return/ipad|tablet/.test(r)?"tablet":/mobile|iphone|android/.test(r)?"mobile":"desktop"}function Pe(){return"web"}function Te(){const e=function(){if("undefined"!=typeof navigator&&navigator.userAgent)return navigator.userAgent.slice(0,512)}()
268
- return{deviceType:Ie(e),platform:"web",userAgent:e}}const Be=["utm_source","utm_medium","utm_campaign"]
269
- function Ae(e){try{const r=new URL(e??("undefined"!=typeof window?window.location.href:"")),a={}
270
- for(const e of Be){const n=r.searchParams.get(e)
271
- n&&(a[e]=n.slice(0,256))}return a}catch{return{}}}function Oe(e){return Boolean(e.utm_source||e.utm_medium||e.utm_campaign)}const $e=({address:a,onEditAddress:n})=>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:a.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:a.digipin})]})}),r("button",{type:"button",className:"qr-btn qr-btn--ghost qr-btn--sm",onClick:n,children:"Change Address"})]}),De=({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,enablePhoneAuth:k=!1,merchantId:C="",supabaseFunctionBaseUrl:x="",brandColor:E,logoUrl:S,headerBanner:L,onCheckoutEvent:I,enableCod:P=!1,enableServiceabilityCheck:T=!1,showIndiaPostDeliveryWarning:B=!1,serviceabilityBlockCheckout:A,codCartTotalPaise:O,codSessionToken:$="",enableEmailAuth:D=!1,variant:U,utmParams:F,enablePayment:R=!1,paymentAmountPaise:j,onPaymentComplete:z,enablePrepaidNudge:V=!1,prepaidNudgeCopy:K,prepaidNudgeCtaUrl:Y,registerController:Q,orderConfirmationUrl:Z})=>{var ae
272
- const ne=k?"phone":D?"email":"none",te="phone"===ne?"phone":"email"===ne?"email":"map",ie=Boolean(R&&j&&x),[oe,le]=t(te),[se,de]=t(null),[ce,ue]=t(null),[me,fe]=t(null),[be,ve]=t(""),[_e,ge]=t(!1),[qe,Ce]=t(!1),[Se,Ie]=t(null),[Pe,Be]=t(null),[Oe,De]=t(null),[Me,Ue]=t("form"),Fe=o(oe),Re=c(()=>F??Ae(),[F]),je=c(()=>Te(),[]),We=c(()=>({utm_source:Re.utm_source,utm_medium:Re.utm_medium,utm_campaign:Re.utm_campaign,device_type:je.deviceType,platform:je.platform,user_agent:je.userAgent,experiment_variant:U}),[Re,je,U]),ze={functionBaseUrl:x,merchantId:C},Ve=(null==me?void 0:me.sessionToken)||$
273
- s(()=>{Fe.current=oe},[oe])
274
- const Je=i(e=>{const r={...e,sessionId:e.sessionId??(null==me?void 0:me.sessionId),buyerId:e.buyerId??(null==me?void 0:me.buyerId),authChannel:e.authChannel??("phone"===ne?"phone":"email"===ne?"email":"none"),deviceType:e.deviceType??je.deviceType,platform:e.platform??je.platform,userAgent:e.userAgent??je.userAgent,experimentVariant:e.experimentVariant??U,timestamp:(new Date).toISOString()}
275
- if(I)try{I(r)}catch{}C&&x&&X(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==me?void 0:me.sessionToken).catch(()=>{})},[me,ne,je,U,I,C,x,ze])
272
+ return/ipad|tablet/.test(r)?"tablet":/mobile|iphone|android/.test(r)?"mobile":"desktop"}function Te(){return"web"}function Be(){const e=function(){if("undefined"!=typeof navigator&&navigator.userAgent)return navigator.userAgent.slice(0,512)}()
273
+ return{deviceType:Pe(e),platform:"web",userAgent:e}}const Ae=["utm_source","utm_medium","utm_campaign"]
274
+ function Oe(e){try{const r=new URL(e??("undefined"!=typeof window?window.location.href:"")),a={}
275
+ for(const e of Ae){const n=r.searchParams.get(e)
276
+ n&&(a[e]=n.slice(0,256))}return a}catch{return{}}}function $e(e){return Boolean(e.utm_source||e.utm_medium||e.utm_campaign)}const De=({address:a,onEditAddress:n})=>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:a.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:a.digipin})]})}),r("button",{type:"button",className:"qr-btn qr-btn--ghost qr-btn--sm",onClick:n,children:"Change Address"})]}),Me=({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,enablePhoneAuth:k=!1,merchantId:C="",supabaseFunctionBaseUrl:x="",brandColor:E,logoUrl:S,headerBanner:L,onCheckoutEvent:I,enableCod:P=!1,enableServiceabilityCheck:T=!1,enableAddressIntelligence:B=!1,showIndiaPostDeliveryWarning:A=!1,serviceabilityBlockCheckout:O,codCartTotalPaise:$,codSessionToken:D="",enableEmailAuth:U=!1,variant:F,utmParams:R,enablePayment:j=!1,paymentAmountPaise:z,onPaymentComplete:V,enablePrepaidNudge:K=!1,prepaidNudgeCopy:Y,prepaidNudgeCtaUrl:Q,registerController:X,orderConfirmationUrl:ne})=>{var te
277
+ const ie=k?"phone":U?"email":"none",oe="phone"===ie?"phone":"email"===ie?"email":"map",le=Boolean(j&&z&&x),[se,de]=t(oe),[ce,ue]=t(null),[he,ye]=t(null),[be,ve]=t(null),[_e,ge]=t(""),[qe,we]=t(!1),[xe,Le]=t(!1),[Pe,Te]=t(null),[Ae,$e]=t(null),[Me,Ue]=t(null),[Fe,Re]=t(null),[je,We]=t("form"),ze=o(se),Ve=c(()=>R??Oe(),[R]),Je=c(()=>Be(),[]),He=c(()=>({utm_source:Ve.utm_source,utm_medium:Ve.utm_medium,utm_campaign:Ve.utm_campaign,device_type:Je.deviceType,platform:Je.platform,user_agent:Je.userAgent,experiment_variant:F}),[Ve,Je,F]),Ge={functionBaseUrl:x,merchantId:C},Ke=(null==be?void 0:be.sessionToken)||D
278
+ s(()=>{ze.current=se},[se])
279
+ const Ye=i(e=>{const r={...e,sessionId:e.sessionId??(null==be?void 0:be.sessionId),buyerId:e.buyerId??(null==be?void 0:be.buyerId),authChannel:e.authChannel??("phone"===ie?"phone":"email"===ie?"email":"none"),deviceType:e.deviceType??Je.deviceType,platform:e.platform??Je.platform,userAgent:e.userAgent??Je.userAgent,experimentVariant:e.experimentVariant??F,timestamp:(new Date).toISOString()}
280
+ if(I)try{I(r)}catch{}C&&x&&ee(Ge,{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==be?void 0:be.sessionToken).catch(()=>{})},[be,ie,Je,F,I,C,x,Ge])
276
281
  s(()=>{if(!C||!x)return
277
- const e=()=>{"done"!==Fe.current&&(null==me?void 0:me.sessionToken)&&(ee(ze,me.sessionToken,Fe.current).catch(()=>{}),Je({type:"session_abandoned",step:Fe.current}))}
278
- return window.addEventListener("pagehide",e),()=>window.removeEventListener("pagehide",e)},[null==me?void 0:me.sessionToken,C,x,ze,Je]),s(()=>{(null==me?void 0:me.sessionToken)&&C&&x&&re(ze,me.sessionToken).then(Ie).catch(()=>Ie(null))},[null==me?void 0:me.sessionToken,C,x,ze])
279
- const He=c(()=>function(e,r){const a=null==r?void 0:r.trim()
282
+ const e=()=>{"done"!==ze.current&&(null==be?void 0:be.sessionToken)&&(re(Ge,be.sessionToken,ze.current).catch(()=>{}),Ye({type:"session_abandoned",step:ze.current}))}
283
+ return window.addEventListener("pagehide",e),()=>window.removeEventListener("pagehide",e)},[null==be?void 0:be.sessionToken,C,x,Ge,Ye]),s(()=>{(null==be?void 0:be.sessionToken)&&C&&x&&ae(Ge,be.sessionToken).then(Te).catch(()=>Te(null))},[null==be?void 0:be.sessionToken,C,x,Ge])
284
+ const Qe=c(()=>function(e,r){const a=null==r?void 0:r.trim()
280
285
  if(!a)return e
281
286
  const n={"--qr-primary":a,"--qr-primary-dark":a,"--qr-border-focus":a,"--qr-primary-light":`color-mix(in srgb, ${a} 18%, white)`}
282
- return e?{...e,...n}:n}(b,E),[b,E]),Ge=()=>{Je({type:"auth_skipped",step:"map"}),le("map")},Ke=(e,r,a)=>{de({lat:e,lng:r,digipin:a}),Je({type:"location_confirmed",step:"form",digipin:a,buyerId:null==me?void 0:me.buyerId}),le("form")},Ye=async(e,r)=>{var a
283
- if(ue(e),Ue((null==r?void 0:r.paymentBackStep)??"form"),Je({type:"address_completed",step:ie?"payment":"done",digipin:e.digipin,buyerId:null==me?void 0:me.buyerId}),(null==me?void 0:me.sessionToken)&&(G(ze,me.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{await W(ze,me.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==(a=e.labelText)?void 0:a.trim())||null,is_default:!1})}catch{}if(ie&&Ve)le("payment")
284
- else{if(ie&&!Ve)return null==h||h(new Error("enablePayment requires phone/email auth or a codSessionToken prop.")),le("done"),void u(e)
285
- le("done"),u(e)}},Qe=()=>"form"===oe?(le(Oe?"verify-address":"map"),!0):"verify-address"===oe?(De(null),de(null),le("saved"),!0):"map"===oe&&(null==me?void 0:me.sessionToken)?(le("saved"),!0):"email-otp"===oe?(le("email"),!0):"otp"===oe?(le("phone"),!0):"payment"===oe&&(le(Me),!0)
286
- s(()=>{Q&&Q({goBack:()=>{const e=Fe.current
287
- return"form"===e?(le(Oe?"verify-address":"map"),!0):"verify-address"===e?(De(null),de(null),le("saved"),!0):"map"===e&&(null==me?void 0:me.sessionToken)?(le("saved"),!0):"email-otp"===e?(le("email"),!0):"otp"===e?(le("phone"),!0):"payment"===e&&(le(Me),!0)},getStep:()=>Fe.current})},[Q,null==me?void 0:me.sessionToken,Oe,Me]),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"}[oe]
288
- e&&Je({type:e,step:oe,buyerId:null==me?void 0:me.buyerId})},[oe]),s(()=>{D&&"email"===ne&&(C&&x||null==h||h(new Error("enableEmailAuth requires merchantId and supabaseFunctionBaseUrl on CheckoutWidget.")))},[D,ne,C,x,h])
289
- const Ze=function(e,r,a){const n="verify-address"===e?"map":e
287
+ return e?{...e,...n}:n}(b,E),[b,E]),Ze=()=>{Ye({type:"auth_skipped",step:"map"}),de("map")},Xe=(e,r,a)=>{ue({lat:e,lng:r,digipin:a}),Ye({type:"location_confirmed",step:"form",digipin:a,buyerId:null==be?void 0:be.buyerId}),de("form")},er=async(e,r)=>{var a
288
+ let n=e
289
+ if(ye(n),We((null==r?void 0:r.paymentBackStep)??"form"),(null==be?void 0:be.sessionToken)&&(G(Ge,be.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 W(Ge,be.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==(a=e.labelText)?void 0:a.trim())||null,is_default:!1})
290
+ n={...n,addressId:r.id},ye(n)}catch{}if(B&&C&&x&&Ke)try{const e=await Z(Ge,Ke,{address_id:n.addressId,digipin:n.digipin,lat:n.lat,lng:n.lng,state:n.state,district:n.district,locality:n.locality,pincode:n.pincode,delivery_status:n.delivery,flat_number:n.flatNumber,floor_number:n.floorNumber,building_name:n.buildingName,street_name:n.streetName})
291
+ $e(e),n={...n,addressRisk:e},ye(n),Ye({type:"address_risk_scored",step:le?"payment":"done",digipin:n.digipin,buyerId:null==be?void 0:be.buyerId,addressRiskLevel:e.level,addressRiskScore:e.score})}catch{$e(null)}else $e(null)
292
+ if(Ye({type:"address_completed",step:le?"payment":"done",digipin:n.digipin,buyerId:null==be?void 0:be.buyerId}),le&&Ke)de("payment")
293
+ else{if(le&&!Ke)return null==h||h(new Error("enablePayment requires phone/email auth or a codSessionToken prop.")),de("done"),void u(n)
294
+ de("done"),u(n)}},rr=()=>"form"===se?(de(Fe?"verify-address":"map"),!0):"verify-address"===se?(Re(null),ue(null),de("saved"),!0):"map"===se&&(null==be?void 0:be.sessionToken)?(de("saved"),!0):"email-otp"===se?(de("email"),!0):"otp"===se?(de("phone"),!0):"payment"===se&&(de(je),!0)
295
+ s(()=>{X&&X({goBack:()=>{const e=ze.current
296
+ return"form"===e?(de(Fe?"verify-address":"map"),!0):"verify-address"===e?(Re(null),ue(null),de("saved"),!0):"map"===e&&(null==be?void 0:be.sessionToken)?(de("saved"),!0):"email-otp"===e?(de("email"),!0):"otp"===e?(de("phone"),!0):"payment"===e&&(de(je),!0)},getStep:()=>ze.current})},[X,null==be?void 0:be.sessionToken,Fe,je]),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"}[se]
297
+ e&&Ye({type:e,step:se,buyerId:null==be?void 0:be.buyerId})},[se]),s(()=>{U&&"email"===ie&&(C&&x||null==h||h(new Error("enableEmailAuth requires merchantId and supabaseFunctionBaseUrl on CheckoutWidget.")))},[U,ie,C,x,h])
298
+ const ar=function(e,r,a){const n="verify-address"===e?"map":e
290
299
  if("none"===r){if(a){const e=["map","form","payment","done"].indexOf(n)
291
300
  return-1===e?0:e}return"map"===n?0:"form"===n?1:2}const t=("email"===r?a?["email","email-otp","saved","map","form","payment","done"]:["email","email-otp","saved","map","form","done"]:a?["phone","otp","saved","map","form","payment","done"]:["phone","otp","saved","map","form","done"]).indexOf(n)
292
- return-1===t?0:t}(oe,ne,ie),Xe=function(e,r){return"none"===e?r?3:2:r?6:5}(ne,ie),er="payment"===oe?"payment":"phone"===oe||"otp"===oe||"email"===oe||"email-otp"===oe?"auth":"address",rr=(null==q?void 0:q.auth)??("email"===ne?"Email":"Mobile"),ar=[..."none"===ne?[]:[{id:"auth",label:rr,status:"auth"===er?"active":"complete"}],{id:"address",label:(null==q?void 0:q.address)??"Address",status:"address"===er?"active":"payment"===er?"complete":"pending"},...ie?[{id:"payment",label:(null==q?void 0:q.payment)??"Pay",status:"payment"===er?"active":"pending"}]:[]]
293
- return e("div",{className:`qr-checkout qr-checkout--${y} qr-checkout--mobile-${g} ${f}`,style:He,"data-testid":"quantaroute-checkout",children:["done"!==oe&&e(a,{children:[e("div",{className:"qr-header",children:[e("div",{className:"qr-header__brand",children:[S?r("img",{src:S,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 a=Array.from({length:Xe+1},(e,r)=>r)
294
- return r("div",{className:"qr-progress",role:"progressbar","aria-valuenow":Ze+1,"aria-valuemin":1,"aria-valuemax":Xe+1,"aria-label":`Step ${Ze+1} of ${Xe+1}`,children:a.map(a=>e(n.Fragment,{children:[r("div",{className:"qr-progress__dot"+(Ze>=a?" qr-progress__dot--active":"")}),a<Xe&&r("div",{className:"qr-progress__line"+(Ze>a?" qr-progress__line--active":"")})]},a))})})()})]}),r("div",{className:"qr-header__progress-mobile",children:r("div",{className:"qr-mobile-stepper",role:"list","aria-label":"Checkout progress",children:ar.map((a,t)=>e(n.Fragment,{children:[e("div",{className:`qr-mobile-stepper__item qr-mobile-stepper__item--${a.status}`,role:"listitem","aria-current":"active"===a.status?"step":void 0,children:[r("span",{className:"qr-mobile-stepper__mark","aria-hidden":"true",children:"complete"===a.status?"✓":t+1}),r("span",{className:"qr-mobile-stepper__label",children:a.label})]}),t<ar.length-1?r("span",{className:"qr-mobile-stepper__rail","aria-hidden":"true"}):null]},a.id))})}),L?r("div",{className:"qr-header-banner",role:"region","aria-label":"Merchant message",children:L}):null,Se?e("div",{className:"qr-offer-banner",role:"region","aria-label":"Special offer",children:[Se.banner_copy,Se.banner_cta_url?e(a,{children:[" ",r("a",{href:Se.banner_cta_url,target:"_blank",rel:"noopener noreferrer",children:"Learn more"})]}):null]}):null]}),"email"===oe&&D&&r(Ee,{onOtpSent:(e,r)=>{ve(e),ge(Boolean(null==r?void 0:r.reused)),Je({type:"email_otp_sent",step:"email-otp",mobile:e}),le("email-otp")},onSkip:Ge,functionBaseUrl:x,merchantId:C}),"email-otp"===oe&&D&&be&&r(Le,{email:be,codeReused:_e,onVerified:(e,r,a)=>{fe({mobile:be,sessionToken:e,sessionId:a??"",buyerId:r}),Je({type:"email_verified",step:"saved",buyerId:r,sessionId:a}),le("saved")},onBack:Qe,functionBaseUrl:x,merchantId:C,sessionContext:We}),"phone"===oe&&k&&r(pe,{onOtpSent:e=>{fe(r=>({mobile:e,sessionToken:"",sessionId:"",buyerId:(null==r?void 0:r.buyerId)??""})),Je({type:"otp_sent",step:"otp",mobile:e}),le("otp")},onSkip:Ge,functionBaseUrl:x,merchantId:C}),"otp"===oe&&me&&r(ye,{mobile:me.mobile,onVerified:(e,r,a)=>{fe({mobile:(null==me?void 0:me.mobile)??"",sessionToken:e,sessionId:a??"",buyerId:r}),Je({type:"phone_verified",step:"saved",buyerId:r,sessionId:a}),le("saved")},onBack:Qe,functionBaseUrl:x,merchantId:C,sessionContext:We}),"saved"===oe&&(null==me?void 0:me.sessionToken)&&r(we,{sessionToken:me.sessionToken,functionBaseUrl:x,merchantId:C,onSelectAddress:async e=>{if(null==me?void 0:me.sessionToken){try{await J(ze,me.sessionToken,e.id)}catch(e){return void(null==h||h(e instanceof Error?e:new Error("Failed to select address.")))}if(!e.digipin)return De(e),Je({type:"saved_address_selected",step:"verify-address",buyerId:me.buyerId}),void le("verify-address")
295
- Je({type:"saved_address_selected",step:ie?"payment":"done",buyerId:me.buyerId,digipin:e.digipin}),G(ze,me.sessionToken,{pincode:e.pincode,digipin:e.digipin,state:e.state,district:e.district,locality:e.locality}).catch(()=>{}),await Ye(function(e){var r
296
- 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:()=>{De(null),de(null),le("map")}}),"verify-address"===oe&&Oe&&e(a,{children:[r("div",{className:"qr-order-lock-banner",role:"status",children:"Confirm your delivery pin to complete this order"}),r(M,{onLocationConfirm:Ke,defaultLat:Oe.lat??p,defaultLng:Oe.lng??m,mapHeight:v,theme:y,indiaBoundaryUrl:w,enableSearch:N,apiKey:l,apiBaseUrl:d,brandColor:E})]}),"map"===oe&&r(M,{onLocationConfirm:Ke,defaultLat:p,defaultLng:m,mapHeight:v,theme:y,indiaBoundaryUrl:w,enableSearch:N,apiKey:l,apiBaseUrl:d,brandColor:E}),"form"===oe&&se&&r(he,{digipin:se.digipin,lat:se.lat,lng:se.lng,apiKey:l,apiBaseUrl:d,onAddressComplete:async e=>{if(Oe&&(null==me?void 0:me.sessionToken))try{await H(ze,me.sessionToken,Oe.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})
297
- const r={...e,addressId:Oe.id}
298
- De(null),await Ye(r,{skipCreate:!0})}catch(e){null==h||h(e instanceof Error?e:new Error("Failed to verify delivery pin."))}else await Ye(e)},onBack:Qe,onError:h,theme:y,checkoutConfig:ze,serviceabilitySessionToken:Ve,enableServiceabilityCheck:T,showIndiaPostDeliveryWarning:B,serviceabilityBlockCheckout:A,initialValues:Oe?{flatNumber:Oe.flat_number,floorNumber:Oe.floor_number,buildingName:Oe.building_name,streetName:Oe.street_name,locality:Oe.locality,label:"work"===Oe.label||"other"===Oe.label?Oe.label:"home",labelText:(null==(ae=Oe.label_text)?void 0:ae.trim())||void 0}:void 0,submitLabel:Oe?"Confirm delivery pin":void 0}),"payment"===oe&&ie&&Ve&&j&&r(xe,{checkoutConfig:ze,sessionToken:Ve,sessionId:null==me?void 0:me.sessionId,amountPaise:j,enableCod:P,codAllowed:qe,theme:y,onComplete:({paymentMethod:e,razorpayOrderId:r,razorpayPaymentId:a})=>{Be(e),Je({type:"payment_method_selected",step:"done",paymentMethod:e}),le("done"),ce&&u(ce),null==z||z({paymentMethod:e,sessionId:null==me?void 0:me.sessionId,razorpayOrderId:r,razorpayPaymentId:a})},onBack:Qe,onEvent:(e,r)=>Je({type:e,step:"payment",paymentMethod:r,buyerId:null==me?void 0:me.buyerId}),orderConfirmationUrl:Z}),"done"===oe&&ce&&e(a,{children:[r($e,{address:ce,onEditAddress:()=>{Je({type:"widget_reset",step:te}),le(te),de(null),ue(null),De(null)}}),Pe?e("p",{className:"qr-cod-banner__text qr-cod-banner__text--ok",style:{textAlign:"center",margin:"8px 16px"},children:["Paid via ","cod"===Pe?"Cash on Delivery":"online payment"]}):null,P&&C&&x&&Ve?e(a,{children:[r(Ne,{checkoutConfig:ze,sessionToken:Ve,pincode:ce.pincode,cartTotalPaise:O??j,theme:y,onCodAllowedChange:Ce}),V&&qe?r(ke,{copy:K??"Save more when you pay online — faster delivery & exclusive offers.",ctaUrl:Y,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:"🇮🇳"})]})]})}
299
- function Me(e,r){return c(()=>{if(!C(e,r))return null
300
- try{return w(e,r)}catch{return null}},[e,r])}export{he as AddressForm,De as CheckoutWidget,Ne as CodAvailabilityBanner,p as DIGIPIN_BOUNDS,Le as EmailOtpStep,Ee as EmailStep,M as MapPinSelector,ye as OtpStep,xe as PaymentStep,pe as PhoneStep,ke as PrepaidNudge,we as SavedAddressStep,B as autocompleteAddress,Ae as captureUtmFromUrl,Q as checkCodEligibility,Z as checkServiceability,T as couldBeDigiPinInput,W as createAddress,ae as createPaymentOrder,De as default,z as deleteAddress,Ie as detectDeviceType,Pe as detectPlatform,ie as fetchPrepaidNudgeConfig,re as fetchSessionOffer,g as formatDigiPin,w as getDigiPin,N as getLatLngFromDigiPin,Te as getWebDeviceContext,Oe as hasUtmParams,q as isCompleteDigiPinInput,_ as isPotentialDigiPinInput,k as isValidDigiPin,C as isWithinIndia,j as listAddresses,X as logFunnelEvent,P as looksLikeDigiPin,S as lookupLocation,v as normalizeDigiPinInput,G as notifyAddressCompleted,ee as notifySessionAbandoned,I as pincodeHasDeliveryOffice,te as recordCodPayment,A as reverseGeocode,J as selectAddress,K as sendEmailOtp,U as sendOtp,V as setDefaultAddress,Me as useDigiPin,O as useGeolocation,L as validatePincode,H as verifyDigipin,Y as verifyEmailOtp,F as verifyOtp,ne as verifyPayment}
301
+ return-1===t?0:t}(se,ie,le),nr=function(e,r){return"none"===e?r?3:2:r?6:5}(ie,le),tr="payment"===se?"payment":"phone"===se||"otp"===se||"email"===se||"email-otp"===se?"auth":"address",ir=(null==q?void 0:q.auth)??("email"===ie?"Email":"Mobile"),or=[..."none"===ie?[]:[{id:"auth",label:ir,status:"auth"===tr?"active":"complete"}],{id:"address",label:(null==q?void 0:q.address)??"Address",status:"address"===tr?"active":"payment"===tr?"complete":"pending"},...le?[{id:"payment",label:(null==q?void 0:q.payment)??"Pay",status:"payment"===tr?"active":"pending"}]:[]]
302
+ return e("div",{className:`qr-checkout qr-checkout--${y} qr-checkout--mobile-${g} ${f}`,style:Qe,"data-testid":"quantaroute-checkout",children:["done"!==se&&e(a,{children:[e("div",{className:"qr-header",children:[e("div",{className:"qr-header__brand",children:[S?r("img",{src:S,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 a=Array.from({length:nr+1},(e,r)=>r)
303
+ return r("div",{className:"qr-progress",role:"progressbar","aria-valuenow":ar+1,"aria-valuemin":1,"aria-valuemax":nr+1,"aria-label":`Step ${ar+1} of ${nr+1}`,children:a.map(a=>e(n.Fragment,{children:[r("div",{className:"qr-progress__dot"+(ar>=a?" qr-progress__dot--active":"")}),a<nr&&r("div",{className:"qr-progress__line"+(ar>a?" qr-progress__line--active":"")})]},a))})})()})]}),r("div",{className:"qr-header__progress-mobile",children:r("div",{className:"qr-mobile-stepper",role:"list","aria-label":"Checkout progress",children:or.map((a,t)=>e(n.Fragment,{children:[e("div",{className:`qr-mobile-stepper__item qr-mobile-stepper__item--${a.status}`,role:"listitem","aria-current":"active"===a.status?"step":void 0,children:[r("span",{className:"qr-mobile-stepper__mark","aria-hidden":"true",children:"complete"===a.status?"✓":t+1}),r("span",{className:"qr-mobile-stepper__label",children:a.label})]}),t<or.length-1?r("span",{className:"qr-mobile-stepper__rail","aria-hidden":"true"}):null]},a.id))})}),L?r("div",{className:"qr-header-banner",role:"region","aria-label":"Merchant message",children:L}):null,Pe?e("div",{className:"qr-offer-banner",role:"region","aria-label":"Special offer",children:[Pe.banner_copy,Pe.banner_cta_url?e(a,{children:[" ",r("a",{href:Pe.banner_cta_url,target:"_blank",rel:"noopener noreferrer",children:"Learn more"})]}):null]}):null]}),"email"===se&&U&&r(Se,{onOtpSent:(e,r)=>{ge(e),we(Boolean(null==r?void 0:r.reused)),Ye({type:"email_otp_sent",step:"email-otp",mobile:e}),de("email-otp")},onSkip:Ze,functionBaseUrl:x,merchantId:C}),"email-otp"===se&&U&&_e&&r(Ie,{email:_e,codeReused:qe,onVerified:(e,r,a)=>{ve({mobile:_e,sessionToken:e,sessionId:a??"",buyerId:r}),Ye({type:"email_verified",step:"saved",buyerId:r,sessionId:a}),de("saved")},onBack:rr,functionBaseUrl:x,merchantId:C,sessionContext:He}),"phone"===se&&k&&r(me,{onOtpSent:e=>{ve(r=>({mobile:e,sessionToken:"",sessionId:"",buyerId:(null==r?void 0:r.buyerId)??""})),Ye({type:"otp_sent",step:"otp",mobile:e}),de("otp")},onSkip:Ze,functionBaseUrl:x,merchantId:C}),"otp"===se&&be&&r(fe,{mobile:be.mobile,onVerified:(e,r,a)=>{ve({mobile:(null==be?void 0:be.mobile)??"",sessionToken:e,sessionId:a??"",buyerId:r}),Ye({type:"phone_verified",step:"saved",buyerId:r,sessionId:a}),de("saved")},onBack:rr,functionBaseUrl:x,merchantId:C,sessionContext:He}),"saved"===se&&(null==be?void 0:be.sessionToken)&&r(Ne,{sessionToken:be.sessionToken,functionBaseUrl:x,merchantId:C,onSelectAddress:async e=>{if(null==be?void 0:be.sessionToken){try{await J(Ge,be.sessionToken,e.id)}catch(e){return void(null==h||h(e instanceof Error?e:new Error("Failed to select address.")))}if(!e.digipin)return Re(e),Ye({type:"saved_address_selected",step:"verify-address",buyerId:be.buyerId}),void de("verify-address")
304
+ Ye({type:"saved_address_selected",step:le?"payment":"done",buyerId:be.buyerId,digipin:e.digipin}),G(Ge,be.sessionToken,{pincode:e.pincode,digipin:e.digipin,state:e.state,district:e.district,locality:e.locality}).catch(()=>{}),await er(function(e){var r
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:()=>{Re(null),ue(null),de("map")}}),"verify-address"===se&&Fe&&e(a,{children:[r("div",{className:"qr-order-lock-banner",role:"status",children:"Confirm your delivery pin to complete this order"}),r(M,{onLocationConfirm:Xe,defaultLat:Fe.lat??p,defaultLng:Fe.lng??m,mapHeight:v,theme:y,indiaBoundaryUrl:w,enableSearch:N,apiKey:l,apiBaseUrl:d,brandColor:E})]}),"map"===se&&r(M,{onLocationConfirm:Xe,defaultLat:p,defaultLng:m,mapHeight:v,theme:y,indiaBoundaryUrl:w,enableSearch:N,apiKey:l,apiBaseUrl:d,brandColor:E}),"form"===se&&ce&&r(pe,{digipin:ce.digipin,lat:ce.lat,lng:ce.lng,apiKey:l,apiBaseUrl:d,onAddressComplete:async e=>{if(Fe&&(null==be?void 0:be.sessionToken))try{await H(Ge,be.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
+ const r={...e,addressId:Fe.id}
307
+ Re(null),await er(r,{skipCreate:!0})}catch(e){null==h||h(e instanceof Error?e:new Error("Failed to verify delivery pin."))}else await er(e)},onBack:rr,onError:h,theme:y,checkoutConfig:Ge,serviceabilitySessionToken:Ke,enableServiceabilityCheck:T,showIndiaPostDeliveryWarning:A,serviceabilityBlockCheckout:O,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==(te=Fe.label_text)?void 0:te.trim())||void 0}:void 0,submitLabel:Fe?"Confirm delivery pin":void 0}),"payment"===se&&le&&Ke&&z&&r(Ee,{checkoutConfig:Ge,sessionToken:Ke,sessionId:null==be?void 0:be.sessionId,amountPaise:z,enableCod:P,codAllowed:xe&&!(null==Ae?void 0:Ae.interventions.includes("hide_cod")),addressRisk:Ae,theme:y,onComplete:({paymentMethod:e,razorpayOrderId:r,razorpayPaymentId:a})=>{Ue(e),Ye({type:"payment_method_selected",step:"done",paymentMethod:e}),de("done"),he&&u(he),null==V||V({paymentMethod:e,sessionId:null==be?void 0:be.sessionId,razorpayOrderId:r,razorpayPaymentId:a})},onBack:rr,onEvent:(e,r)=>Ye({type:e,step:"payment",paymentMethod:r,buyerId:null==be?void 0:be.buyerId}),orderConfirmationUrl:ne}),"done"===se&&he&&e(a,{children:[r(De,{address:he,onEditAddress:()=>{Ye({type:"widget_reset",step:oe}),de(oe),ue(null),ye(null),$e(null),Re(null)}}),Me?e("p",{className:"qr-cod-banner__text qr-cod-banner__text--ok",style:{textAlign:"center",margin:"8px 16px"},children:["Paid via ","cod"===Me?"Cash on Delivery":"online payment"]}):null,P&&C&&x&&Ke?e(a,{children:[r(ke,{checkoutConfig:Ge,sessionToken:Ke,pincode:he.pincode,cartTotalPaise:$??z,theme:y,onCodAllowedChange:Le}),K&&xe?r(Ce,{copy:Y??"Save more when you pay online — faster delivery & exclusive offers.",ctaUrl:Q,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:"🇮🇳"})]})]})}
308
+ function Ue(e,r){return c(()=>{if(!C(e,r))return null
309
+ try{return w(e,r)}catch{return null}},[e,r])}export{pe as AddressForm,Me as CheckoutWidget,ke as CodAvailabilityBanner,p as DIGIPIN_BOUNDS,Ie as EmailOtpStep,Se as EmailStep,M as MapPinSelector,fe as OtpStep,Ee as PaymentStep,me as PhoneStep,Ce as PrepaidNudge,Ne as SavedAddressStep,B as autocompleteAddress,Oe as captureUtmFromUrl,Q as checkCodEligibility,X as checkServiceability,T as couldBeDigiPinInput,W as createAddress,ne as createPaymentOrder,Me as default,z as deleteAddress,Pe as detectDeviceType,Te as detectPlatform,oe as fetchPrepaidNudgeConfig,ae as fetchSessionOffer,g as formatDigiPin,w as getDigiPin,N as getLatLngFromDigiPin,Be as getWebDeviceContext,$e as hasUtmParams,q as isCompleteDigiPinInput,_ as isPotentialDigiPinInput,k as isValidDigiPin,C as isWithinIndia,j as listAddresses,ee as logFunnelEvent,P as looksLikeDigiPin,S as lookupLocation,v as normalizeDigiPinInput,G as notifyAddressCompleted,re as notifySessionAbandoned,I as pincodeHasDeliveryOffice,ie as recordCodPayment,A as reverseGeocode,Z as scoreAddressRisk,J as selectAddress,K as sendEmailOtp,U as sendOtp,V as setDefaultAddress,Ue as useDigiPin,O as useGeolocation,L as validatePincode,H as verifyDigipin,Y as verifyEmailOtp,F as verifyOtp,te as verifyPayment}