@quantaroute/checkout 1.3.0 → 1.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @quantaroute/checkout v1.2.0
2
+ * @quantaroute/checkout v1.3.2
3
3
  * (c) 2026 QuantaRoute – https://quantaroute.com
4
4
  * Released under the MIT License.
5
5
  *
@@ -19,7 +19,7 @@
19
19
  * expo-location >= 17.0.0
20
20
  */
21
21
  import { jsxs, jsx, Fragment } from "react/jsx-runtime";
22
- import { useState, useCallback, useRef, useEffect, useReducer, useMemo } from "react";
22
+ import { useState, useCallback, useRef, useId, useEffect, useReducer, useMemo } from "react";
23
23
  import maplibregl from "maplibre-gl";
24
24
  const DIGIPIN_GRID = [
25
25
  ["F", "C", "9", "8"],
@@ -122,6 +122,127 @@ function isValidDigiPin(digiPin) {
122
122
  function isWithinIndia(lat, lon) {
123
123
  return lat >= BOUNDS.minLat && lat <= BOUNDS.maxLat && lon >= BOUNDS.minLon && lon <= BOUNDS.maxLon;
124
124
  }
125
+ const DEFAULT_BASE_URL = "https://api.quantaroute.com";
126
+ const DIGIPIN_PATTERN = /^[FC98J327K456LMPT]{3}-[FC98J327K456LMPT]{3}-[FC98J327K456LMPT]{4}$/i;
127
+ function makeTimeoutSignal(ms) {
128
+ if (typeof AbortSignal !== "undefined" && typeof AbortSignal.timeout === "function") {
129
+ return AbortSignal.timeout(ms);
130
+ }
131
+ const ctrl = new AbortController();
132
+ setTimeout(() => ctrl.abort(), ms);
133
+ return ctrl.signal;
134
+ }
135
+ async function lookupLocation(lat, lng, apiKey, baseUrl = DEFAULT_BASE_URL) {
136
+ const url = `${baseUrl.replace(/\/$/, "")}/v1/location/lookup`;
137
+ let res;
138
+ try {
139
+ res = await fetch(url, {
140
+ method: "POST",
141
+ headers: {
142
+ "Content-Type": "application/json",
143
+ "x-api-key": apiKey
144
+ },
145
+ body: JSON.stringify({ latitude: lat, longitude: lng }),
146
+ signal: makeTimeoutSignal(15e3)
147
+ });
148
+ } catch (err) {
149
+ if (err instanceof Error && (err.name === "TimeoutError" || err.name === "AbortError")) {
150
+ throw new Error("Request timed out. Check your internet connection.");
151
+ }
152
+ throw new Error(`Network error: ${err instanceof Error ? err.message : String(err)}`);
153
+ }
154
+ if (!res.ok) {
155
+ let body = "";
156
+ try {
157
+ body = await res.text();
158
+ } catch {
159
+ }
160
+ if (res.status === 401 || res.status === 403) {
161
+ throw new Error("Invalid API key. Check your QuantaRoute API key.");
162
+ }
163
+ if (res.status === 429) {
164
+ throw new Error("Rate limit exceeded. Upgrade your plan or try again later.");
165
+ }
166
+ throw new Error(`API error ${res.status}: ${body || res.statusText}`);
167
+ }
168
+ const data = await res.json();
169
+ if (!data.success) {
170
+ throw new Error(data.message ?? "Location lookup failed");
171
+ }
172
+ return data;
173
+ }
174
+ function looksLikeDigiPin(input) {
175
+ return DIGIPIN_PATTERN.test(input.trim().toUpperCase());
176
+ }
177
+ async function autocompleteAddress(query, apiKey, baseUrl = DEFAULT_BASE_URL, limit = 5, userLat, userLng) {
178
+ let url = `${baseUrl.replace(/\/$/, "")}/v1/digipin/autocomplete?q=${encodeURIComponent(query.trim())}&limit=${Math.min(limit, 10)}`;
179
+ if (typeof userLat === "number" && typeof userLng === "number") {
180
+ url += `&lat=${userLat.toFixed(6)}&lng=${userLng.toFixed(6)}`;
181
+ }
182
+ let res;
183
+ try {
184
+ res = await fetch(url, {
185
+ method: "GET",
186
+ headers: { "x-api-key": apiKey },
187
+ signal: makeTimeoutSignal(8e3)
188
+ });
189
+ } catch (err) {
190
+ if (err instanceof Error && (err.name === "TimeoutError" || err.name === "AbortError")) {
191
+ throw new Error("Autocomplete request timed out.");
192
+ }
193
+ throw new Error(`Network error: ${err instanceof Error ? err.message : String(err)}`);
194
+ }
195
+ if (!res.ok) {
196
+ if (res.status === 401 || res.status === 403) {
197
+ throw new Error("Invalid API key.");
198
+ }
199
+ if (res.status === 429) {
200
+ throw new Error("Rate limit exceeded.");
201
+ }
202
+ return [];
203
+ }
204
+ const data = await res.json();
205
+ return data.success ? data.data ?? [] : [];
206
+ }
207
+ async function reverseGeocode(digipin, apiKey, baseUrl = DEFAULT_BASE_URL) {
208
+ const url = `${baseUrl.replace(/\/$/, "")}/v1/digipin/reverse`;
209
+ let res;
210
+ try {
211
+ res = await fetch(url, {
212
+ method: "POST",
213
+ headers: {
214
+ "Content-Type": "application/json",
215
+ "x-api-key": apiKey
216
+ },
217
+ body: JSON.stringify({ digipin }),
218
+ signal: makeTimeoutSignal(15e3)
219
+ });
220
+ } catch (err) {
221
+ if (err instanceof Error && (err.name === "TimeoutError" || err.name === "AbortError")) {
222
+ throw new Error("Request timed out. Check your internet connection.");
223
+ }
224
+ throw new Error(`Network error: ${err instanceof Error ? err.message : String(err)}`);
225
+ }
226
+ if (!res.ok) {
227
+ let body = "";
228
+ try {
229
+ body = await res.text();
230
+ } catch {
231
+ }
232
+ if (res.status === 401 || res.status === 403) {
233
+ throw new Error("Invalid API key. Check your QuantaRoute API key.");
234
+ }
235
+ if (res.status === 429) {
236
+ throw new Error("Rate limit exceeded. Upgrade your plan or try again later.");
237
+ }
238
+ throw new Error(`API error ${res.status}: ${body || res.statusText}`);
239
+ }
240
+ const data = await res.json();
241
+ if (!data.success) {
242
+ throw new Error(data.message ?? "Reverse geocoding failed");
243
+ }
244
+ return data;
245
+ }
125
246
  function useGeolocation() {
126
247
  const [state, setState] = useState({ loading: false, error: null });
127
248
  const locate = useCallback((onSuccess) => {
@@ -154,49 +275,11 @@ function useGeolocation() {
154
275
  }, []);
155
276
  return { ...state, locate, clearError };
156
277
  }
157
- const STYLE_REGISTRY = {
158
- "carto-positron": {
159
- url: "https://basemaps.cartocdn.com/gl/positron-gl-style/style.json",
160
- attributionHtml: '© <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>',
161
- attributionPlain: "© OpenStreetMap contributors © CARTO"
162
- },
163
- "openfreemap-liberty": {
164
- url: "https://tiles.openfreemap.org/styles/liberty",
165
- attributionHtml: '© <a href="https://www.openstreetmap.org/copyright" target="_blank" rel="noopener">OpenStreetMap</a> contributors &nbsp;© <a href="https://openmaptiles.org" target="_blank" rel="noopener">OpenMapTiles</a> &nbsp;<a href="https://openfreemap.org" target="_blank" rel="noopener">OpenFreeMap</a>',
166
- attributionPlain: "© OpenStreetMap contributors © OpenMapTiles · OpenFreeMap"
167
- },
168
- "openfreemap-positron": {
169
- url: "https://tiles.openfreemap.org/styles/positron",
170
- attributionHtml: '© <a href="https://www.openstreetmap.org/copyright" target="_blank" rel="noopener">OpenStreetMap</a> contributors &nbsp;© <a href="https://openmaptiles.org" target="_blank" rel="noopener">OpenMapTiles</a> &nbsp;<a href="https://openfreemap.org" target="_blank" rel="noopener">OpenFreeMap</a>',
171
- attributionPlain: "© OpenStreetMap contributors © OpenMapTiles · OpenFreeMap"
172
- },
173
- "openfreemap-bright": {
174
- url: "https://tiles.openfreemap.org/styles/bright",
175
- attributionHtml: '© <a href="https://www.openstreetmap.org/copyright" target="_blank" rel="noopener">OpenStreetMap</a> contributors &nbsp;© <a href="https://openmaptiles.org" target="_blank" rel="noopener">OpenMapTiles</a> &nbsp;<a href="https://openfreemap.org" target="_blank" rel="noopener">OpenFreeMap</a>',
176
- attributionPlain: "© OpenStreetMap contributors © OpenMapTiles · OpenFreeMap"
177
- }
178
- };
179
- const DEFAULT_STYLE = "carto-positron";
180
- function isBuiltIn(value) {
181
- return value in STYLE_REGISTRY;
182
- }
183
- function resolveMapStyle(mapStyle) {
184
- if (!mapStyle || mapStyle === DEFAULT_STYLE) {
185
- return STYLE_REGISTRY[DEFAULT_STYLE];
186
- }
187
- if (isBuiltIn(mapStyle)) {
188
- return STYLE_REGISTRY[mapStyle];
189
- }
190
- return {
191
- url: mapStyle,
192
- attributionHtml: '© <a href="https://www.openstreetmap.org/copyright" target="_blank" rel="noopener">OpenStreetMap</a> contributors',
193
- attributionPlain: "© OpenStreetMap contributors"
194
- };
195
- }
196
278
  const INDIA_CENTER = { lat: 13.00427, lng: 77.589291 };
197
279
  const MIN_ZOOM = 6;
198
280
  const OVERVIEW_ZOOM = 9;
199
281
  const STREET_ZOOM = 18;
282
+ const CARTO_STYLE_URL = "https://basemaps.cartocdn.com/gl/positron-gl-style/style.json";
200
283
  const PIN_W = 40;
201
284
  const PIN_H = 52;
202
285
  function computeDigiPinSafe(la, lo) {
@@ -262,9 +345,10 @@ const MapPinSelector = ({
262
345
  defaultLng,
263
346
  mapHeight = "380px",
264
347
  theme: _theme = "light",
265
- // kept for future dark-mode pin tint; unused for now
266
- mapStyle,
267
- indiaBoundaryUrl
348
+ indiaBoundaryUrl,
349
+ enableSearch = true,
350
+ apiKey,
351
+ apiBaseUrl
268
352
  }) => {
269
353
  const containerRef = useRef(null);
270
354
  const mapRef = useRef(null);
@@ -278,18 +362,97 @@ const MapPinSelector = ({
278
362
  () => computeDigiPinSafe(initLat, initLng)
279
363
  );
280
364
  const [mapLoaded, setMapLoaded] = useState(false);
365
+ const [searchQuery, setSearchQuery] = useState("");
366
+ const [suggestions, setSuggestions] = useState([]);
367
+ const [searchLoading, setSearchLoading] = useState(false);
368
+ const [searchError, setSearchError] = useState(null);
369
+ const [dropdownOpen, setDropdownOpen] = useState(false);
370
+ const debounceRef = useRef(null);
371
+ const searchInputRef = useRef(null);
372
+ const listboxId = useId();
281
373
  const { loading: geoLoading, error: geoError, locate, clearError } = useGeolocation();
282
374
  const refreshDigipin = useCallback((la, lo) => {
283
375
  setDigipin(computeDigiPinSafe(la, lo));
284
376
  }, []);
377
+ const flyToCoord = useCallback((la, lo) => {
378
+ var _a;
379
+ setLat(la);
380
+ setLng(lo);
381
+ refreshDigipin(la, lo);
382
+ if (mapRef.current) {
383
+ mapRef.current.flyTo({ center: [lo, la], zoom: STREET_ZOOM, duration: 900, essential: true });
384
+ }
385
+ (_a = markerRef.current) == null ? void 0 : _a.setLngLat([lo, la]);
386
+ }, [refreshDigipin]);
387
+ const handleSearchChange = useCallback((e) => {
388
+ const value = e.target.value;
389
+ setSearchQuery(value);
390
+ setSearchError(null);
391
+ if (debounceRef.current) clearTimeout(debounceRef.current);
392
+ const trimmed = value.trim();
393
+ if (!trimmed) {
394
+ setSuggestions([]);
395
+ setDropdownOpen(false);
396
+ setSearchLoading(false);
397
+ return;
398
+ }
399
+ if (looksLikeDigiPin(trimmed)) {
400
+ try {
401
+ const coords = getLatLngFromDigiPin(trimmed.toUpperCase());
402
+ const la = parseFloat(coords.latitude);
403
+ const lo = parseFloat(coords.longitude);
404
+ flyToCoord(la, lo);
405
+ setSuggestions([]);
406
+ setDropdownOpen(false);
407
+ setSearchQuery(trimmed.toUpperCase());
408
+ } catch {
409
+ setSearchError("Invalid DigiPin code");
410
+ }
411
+ return;
412
+ }
413
+ if (trimmed.length < 3) {
414
+ setSuggestions([]);
415
+ setDropdownOpen(false);
416
+ return;
417
+ }
418
+ setSearchLoading(true);
419
+ debounceRef.current = setTimeout(async () => {
420
+ try {
421
+ const key = apiKey ?? "";
422
+ const results = await autocompleteAddress(trimmed, key, apiBaseUrl, 5, lat, lng);
423
+ setSuggestions(results);
424
+ setDropdownOpen(results.length > 0);
425
+ } catch (err) {
426
+ setSearchError(err instanceof Error ? err.message : "Search failed");
427
+ setSuggestions([]);
428
+ setDropdownOpen(false);
429
+ } finally {
430
+ setSearchLoading(false);
431
+ }
432
+ }, 400);
433
+ }, [apiKey, apiBaseUrl, flyToCoord]);
434
+ const handleSuggestionSelect = useCallback((s) => {
435
+ var _a;
436
+ flyToCoord(s.coordinates.latitude, s.coordinates.longitude);
437
+ setSearchQuery("");
438
+ setSuggestions([]);
439
+ setDropdownOpen(false);
440
+ (_a = searchInputRef.current) == null ? void 0 : _a.blur();
441
+ }, [flyToCoord]);
442
+ const handleSearchKeyDown = useCallback((e) => {
443
+ if (e.key === "Escape") {
444
+ setSuggestions([]);
445
+ setDropdownOpen(false);
446
+ setSearchQuery("");
447
+ }
448
+ }, []);
285
449
  useEffect(() => {
286
450
  if (!containerRef.current) return;
287
451
  const boundaryPromise = indiaBoundaryUrl ? fetch(indiaBoundaryUrl).then((r) => r.ok ? r.json() : null).catch(() => null) : Promise.resolve(null);
288
452
  const initZoom = hasDefault ? STREET_ZOOM : OVERVIEW_ZOOM;
289
- const { url: styleUrl, attributionHtml } = resolveMapStyle(mapStyle);
290
453
  const map = new maplibregl.Map({
291
454
  container: containerRef.current,
292
- style: styleUrl,
455
+ style: CARTO_STYLE_URL,
293
456
  center: [initLng, initLat],
294
457
  zoom: initZoom,
295
458
  minZoom: MIN_ZOOM,
@@ -301,7 +464,7 @@ const MapPinSelector = ({
301
464
  map.addControl(
302
465
  new maplibregl.AttributionControl({
303
466
  compact: true,
304
- customAttribution: attributionHtml
467
+ 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>'
305
468
  }),
306
469
  "bottom-right"
307
470
  );
@@ -400,6 +563,114 @@ const MapPinSelector = ({
400
563
  /* @__PURE__ */ jsx("span", { className: "qr-step-sub", children: "Tap the map or drag the pin to your exact home / office" })
401
564
  ] })
402
565
  ] }),
566
+ enableSearch && /* @__PURE__ */ jsxs("div", { className: "qr-search-bar", role: "search", children: [
567
+ /* @__PURE__ */ jsxs("div", { className: "qr-search-bar__input-wrap", children: [
568
+ /* @__PURE__ */ jsxs(
569
+ "svg",
570
+ {
571
+ className: "qr-search-bar__icon",
572
+ "aria-hidden": "true",
573
+ viewBox: "0 0 24 24",
574
+ fill: "none",
575
+ stroke: "currentColor",
576
+ strokeWidth: "2",
577
+ strokeLinecap: "round",
578
+ strokeLinejoin: "round",
579
+ children: [
580
+ /* @__PURE__ */ jsx("circle", { cx: "11", cy: "11", r: "8" }),
581
+ /* @__PURE__ */ jsx("path", { d: "M21 21l-4.35-4.35" })
582
+ ]
583
+ }
584
+ ),
585
+ /* @__PURE__ */ jsx(
586
+ "input",
587
+ {
588
+ ref: searchInputRef,
589
+ type: "search",
590
+ className: "qr-search-bar__input",
591
+ placeholder: "Search address, 'pharmacy near me', or DigiPin…",
592
+ value: searchQuery,
593
+ onChange: handleSearchChange,
594
+ onKeyDown: handleSearchKeyDown,
595
+ autoComplete: "off",
596
+ autoCorrect: "off",
597
+ autoCapitalize: "characters",
598
+ spellCheck: false,
599
+ "aria-label": "Search address or DigiPin",
600
+ "aria-autocomplete": "list",
601
+ "aria-controls": dropdownOpen ? listboxId : void 0,
602
+ "aria-expanded": dropdownOpen
603
+ }
604
+ ),
605
+ searchLoading && /* @__PURE__ */ jsx("span", { className: "qr-search-bar__spinner qr-spinner qr-spinner--sm", "aria-hidden": "true" }),
606
+ searchQuery && !searchLoading && /* @__PURE__ */ jsx(
607
+ "button",
608
+ {
609
+ type: "button",
610
+ className: "qr-search-bar__clear",
611
+ onClick: () => {
612
+ setSearchQuery("");
613
+ setSuggestions([]);
614
+ setDropdownOpen(false);
615
+ setSearchError(null);
616
+ },
617
+ "aria-label": "Clear search",
618
+ tabIndex: -1,
619
+ children: "×"
620
+ }
621
+ )
622
+ ] }),
623
+ searchError && /* @__PURE__ */ jsx("p", { className: "qr-search-bar__error", role: "alert", children: searchError }),
624
+ dropdownOpen && suggestions.length > 0 && /* @__PURE__ */ jsx(
625
+ "ul",
626
+ {
627
+ id: listboxId,
628
+ className: "qr-search-bar__dropdown",
629
+ role: "listbox",
630
+ "aria-label": "Address suggestions",
631
+ children: suggestions.map((s, i) => /* @__PURE__ */ jsxs(
632
+ "li",
633
+ {
634
+ className: "qr-search-bar__suggestion",
635
+ role: "option",
636
+ "aria-selected": "false",
637
+ onMouseDown: (e) => {
638
+ e.preventDefault();
639
+ handleSuggestionSelect(s);
640
+ },
641
+ children: [
642
+ /* @__PURE__ */ jsxs(
643
+ "svg",
644
+ {
645
+ className: "qr-search-bar__suggestion-icon",
646
+ "aria-hidden": "true",
647
+ viewBox: "0 0 24 24",
648
+ fill: "none",
649
+ stroke: "currentColor",
650
+ strokeWidth: "1.8",
651
+ strokeLinecap: "round",
652
+ strokeLinejoin: "round",
653
+ children: [
654
+ /* @__PURE__ */ jsx("path", { d: "M12 2C8.134 2 5 5.134 5 9c0 5.25 7 13 7 13s7-7.75 7-13c0-3.866-3.134-7-7-7z" }),
655
+ /* @__PURE__ */ jsx("circle", { cx: "12", cy: "9", r: "2.5" })
656
+ ]
657
+ }
658
+ ),
659
+ /* @__PURE__ */ jsxs("div", { className: "qr-search-bar__suggestion-text", children: [
660
+ /* @__PURE__ */ jsx("span", { className: "qr-search-bar__suggestion-name", children: s.displayName }),
661
+ s.address && s.address !== s.displayName && /* @__PURE__ */ jsx("span", { className: "qr-search-bar__suggestion-sub", children: s.address })
662
+ ] })
663
+ ]
664
+ },
665
+ i
666
+ ))
667
+ }
668
+ ),
669
+ /* @__PURE__ */ jsxs("p", { className: "qr-search-bar__hint", children: [
670
+ /* @__PURE__ */ jsx("span", { className: "qr-search-bar__hint-chip", children: "DigiPin" }),
671
+ "Type your DigiPin code for instant offline lookup — no API call"
672
+ ] })
673
+ ] }),
403
674
  /* @__PURE__ */ jsxs("div", { className: "qr-map-outer", style: { height: mapHeight }, children: [
404
675
  /* @__PURE__ */ jsx("div", { ref: containerRef, className: "qr-map-canvas" }),
405
676
  digipin && /* @__PURE__ */ jsxs("div", { className: "qr-digipin-badge", "aria-live": "polite", "aria-label": `DigiPin: ${digipin}`, children: [
@@ -490,93 +761,6 @@ const MapPinSelector = ({
490
761
  ] })
491
762
  ] });
492
763
  };
493
- const DEFAULT_BASE_URL = "https://api.quantaroute.com";
494
- function makeTimeoutSignal(ms) {
495
- if (typeof AbortSignal !== "undefined" && typeof AbortSignal.timeout === "function") {
496
- return AbortSignal.timeout(ms);
497
- }
498
- const ctrl = new AbortController();
499
- setTimeout(() => ctrl.abort(), ms);
500
- return ctrl.signal;
501
- }
502
- async function lookupLocation(lat, lng, apiKey, baseUrl = DEFAULT_BASE_URL) {
503
- const url = `${baseUrl.replace(/\/$/, "")}/v1/location/lookup`;
504
- let res;
505
- try {
506
- res = await fetch(url, {
507
- method: "POST",
508
- headers: {
509
- "Content-Type": "application/json",
510
- "x-api-key": apiKey
511
- },
512
- body: JSON.stringify({ latitude: lat, longitude: lng }),
513
- signal: makeTimeoutSignal(15e3)
514
- });
515
- } catch (err) {
516
- if (err instanceof Error && (err.name === "TimeoutError" || err.name === "AbortError")) {
517
- throw new Error("Request timed out. Check your internet connection.");
518
- }
519
- throw new Error(`Network error: ${err instanceof Error ? err.message : String(err)}`);
520
- }
521
- if (!res.ok) {
522
- let body = "";
523
- try {
524
- body = await res.text();
525
- } catch {
526
- }
527
- if (res.status === 401 || res.status === 403) {
528
- throw new Error("Invalid API key. Check your QuantaRoute API key.");
529
- }
530
- if (res.status === 429) {
531
- throw new Error("Rate limit exceeded. Upgrade your plan or try again later.");
532
- }
533
- throw new Error(`API error ${res.status}: ${body || res.statusText}`);
534
- }
535
- const data = await res.json();
536
- if (!data.success) {
537
- throw new Error(data.message ?? "Location lookup failed");
538
- }
539
- return data;
540
- }
541
- async function reverseGeocode(digipin, apiKey, baseUrl = DEFAULT_BASE_URL) {
542
- const url = `${baseUrl.replace(/\/$/, "")}/v1/digipin/reverse`;
543
- let res;
544
- try {
545
- res = await fetch(url, {
546
- method: "POST",
547
- headers: {
548
- "Content-Type": "application/json",
549
- "x-api-key": apiKey
550
- },
551
- body: JSON.stringify({ digipin }),
552
- signal: makeTimeoutSignal(15e3)
553
- });
554
- } catch (err) {
555
- if (err instanceof Error && (err.name === "TimeoutError" || err.name === "AbortError")) {
556
- throw new Error("Request timed out. Check your internet connection.");
557
- }
558
- throw new Error(`Network error: ${err instanceof Error ? err.message : String(err)}`);
559
- }
560
- if (!res.ok) {
561
- let body = "";
562
- try {
563
- body = await res.text();
564
- } catch {
565
- }
566
- if (res.status === 401 || res.status === 403) {
567
- throw new Error("Invalid API key. Check your QuantaRoute API key.");
568
- }
569
- if (res.status === 429) {
570
- throw new Error("Rate limit exceeded. Upgrade your plan or try again later.");
571
- }
572
- throw new Error(`API error ${res.status}: ${body || res.statusText}`);
573
- }
574
- const data = await res.json();
575
- if (!data.success) {
576
- throw new Error(data.message ?? "Reverse geocoding failed");
577
- }
578
- return data;
579
- }
580
764
  const INITIAL_FIELDS = {
581
765
  flatNumber: "",
582
766
  floorNumber: "",
@@ -986,8 +1170,8 @@ const CheckoutWidget = ({
986
1170
  style,
987
1171
  mapHeight = "380px",
988
1172
  title = "Add Delivery Address",
989
- mapStyle,
990
- indiaBoundaryUrl
1173
+ indiaBoundaryUrl,
1174
+ enableSearch = true
991
1175
  }) => {
992
1176
  const [step, setStep] = useState("map");
993
1177
  const [confirmedLocation, setConfirmedLocation] = useState(null);
@@ -1052,8 +1236,10 @@ const CheckoutWidget = ({
1052
1236
  defaultLng,
1053
1237
  mapHeight,
1054
1238
  theme,
1055
- mapStyle,
1056
- indiaBoundaryUrl
1239
+ indiaBoundaryUrl,
1240
+ enableSearch,
1241
+ apiKey,
1242
+ apiBaseUrl
1057
1243
  }
1058
1244
  ),
1059
1245
  step === "form" && confirmedLocation && /* @__PURE__ */ jsx(
@@ -1104,11 +1290,13 @@ export {
1104
1290
  CheckoutWidget,
1105
1291
  BOUNDS as DIGIPIN_BOUNDS,
1106
1292
  MapPinSelector,
1293
+ autocompleteAddress,
1107
1294
  CheckoutWidget as default,
1108
1295
  getDigiPin,
1109
1296
  getLatLngFromDigiPin,
1110
1297
  isValidDigiPin,
1111
1298
  isWithinIndia,
1299
+ looksLikeDigiPin,
1112
1300
  lookupLocation,
1113
1301
  reverseGeocode,
1114
1302
  useDigiPin,