@cartbot/vehicle-search-beta 3.0.20 → 3.0.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/js/vehicle-search.es.js +214 -201
- package/dist/js/vehicle-search.js +15 -15
- package/package.json +1 -1
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { jsx as a, jsxs as
|
|
2
|
-
import { useState as
|
|
3
|
-
import
|
|
4
|
-
import
|
|
1
|
+
import { jsx as a, jsxs as E, Fragment as $e } from "react/jsx-runtime";
|
|
2
|
+
import { useState as A, useEffect as B, useRef as Z, useCallback as N, useMemo as mt } from "react";
|
|
3
|
+
import ft from "react-dom";
|
|
4
|
+
import Ke from "js-cookie";
|
|
5
5
|
import { Combobox as gt, ComboboxInput as bt, ComboboxButton as wt, ComboboxOptions as yt, ComboboxOption as xt } from "@headlessui/react";
|
|
6
6
|
import kt from "fuzzysearch";
|
|
7
|
-
import
|
|
7
|
+
import Qe from "pluralize";
|
|
8
8
|
import ne from "clsx";
|
|
9
|
-
import { MeiliSearch as
|
|
9
|
+
import { MeiliSearch as We } from "meilisearch";
|
|
10
10
|
import Ct from "lodash/debounce.js";
|
|
11
11
|
import _t from "tinycolor2";
|
|
12
12
|
import Be from "posthog-js";
|
|
@@ -23,7 +23,7 @@ function St({ className: b }) {
|
|
|
23
23
|
width: "auto",
|
|
24
24
|
height: "100%"
|
|
25
25
|
},
|
|
26
|
-
children: /* @__PURE__ */
|
|
26
|
+
children: /* @__PURE__ */ E("g", { children: [
|
|
27
27
|
/* @__PURE__ */ a(
|
|
28
28
|
"rect",
|
|
29
29
|
{
|
|
@@ -117,58 +117,58 @@ function X({
|
|
|
117
117
|
label: b,
|
|
118
118
|
items: v,
|
|
119
119
|
selected: p,
|
|
120
|
-
refine:
|
|
120
|
+
refine: F,
|
|
121
121
|
showPopular: I,
|
|
122
122
|
bgDark: R,
|
|
123
123
|
sortOptions: P = !0,
|
|
124
|
-
showLabel:
|
|
124
|
+
showLabel: T = !1,
|
|
125
125
|
isMobile: _ = !1,
|
|
126
126
|
loading: V = !1,
|
|
127
|
-
shouldBeActive:
|
|
127
|
+
shouldBeActive: O = !1
|
|
128
128
|
// True when parent fields are selected and this field tried to load
|
|
129
129
|
}) {
|
|
130
|
-
const [re, u] =
|
|
131
|
-
C(
|
|
132
|
-
}, ee = (
|
|
133
|
-
|
|
130
|
+
const [re, u] = A(""), [y, C] = A(p || null), q = (l) => {
|
|
131
|
+
C(l), u(""), !(l && l.value === (p == null ? void 0 : p.value)) && F(l);
|
|
132
|
+
}, ee = (l) => {
|
|
133
|
+
l.preventDefault(), l.stopPropagation(), u(""), C(null), F("");
|
|
134
134
|
};
|
|
135
135
|
B(() => {
|
|
136
136
|
u(""), C(p || null);
|
|
137
137
|
}, [p, v]);
|
|
138
138
|
let G = /* @__PURE__ */ new Set(), f = [];
|
|
139
|
-
v && (v.forEach((
|
|
140
|
-
String(
|
|
139
|
+
v && (v.forEach((l) => {
|
|
140
|
+
String(l.value).split(/,(?![^(]*\))/).forEach((z) => {
|
|
141
141
|
z = z.trim(), z && kt(re, z.toLowerCase()) && !G.has(z.toLowerCase()) && (G.add(z.toLowerCase()), f.push({
|
|
142
|
-
...
|
|
142
|
+
...l,
|
|
143
143
|
value: z,
|
|
144
|
-
refinement:
|
|
144
|
+
refinement: l.value
|
|
145
145
|
}));
|
|
146
146
|
});
|
|
147
147
|
}), f.length === 0 && (f = v));
|
|
148
|
-
const D = f.filter((
|
|
148
|
+
const D = f.filter((l) => l.popularity > 0).slice(0, 11);
|
|
149
149
|
P && (f = f.filter(
|
|
150
|
-
(
|
|
150
|
+
(l) => !D.includes(l)
|
|
151
151
|
), f.sort(
|
|
152
|
-
(
|
|
152
|
+
(l, U) => l.value.localeCompare(U.value, "en", { numeric: !0 })
|
|
153
153
|
), f = D.concat(f));
|
|
154
154
|
const g = !f || f.length === 0;
|
|
155
|
-
return /* @__PURE__ */
|
|
156
|
-
|
|
155
|
+
return /* @__PURE__ */ E("div", { className: "vs:relative vs:flex vs:flex-col", children: [
|
|
156
|
+
T && /* @__PURE__ */ a(
|
|
157
157
|
"span",
|
|
158
158
|
{
|
|
159
159
|
className: `${R ? "vs:text-white" : "vs:text-black"} vs:mb-1 vs:block vs:text-(length:--partbot-font-size) vs:leading-[calc(var(--partbot-font-size)*1.5)] vs:font-medium vs:font-(family-name:--partbot-font-family)`,
|
|
160
160
|
children: b
|
|
161
161
|
}
|
|
162
162
|
),
|
|
163
|
-
_ && /* @__PURE__ */
|
|
164
|
-
/* @__PURE__ */
|
|
163
|
+
_ && /* @__PURE__ */ E("div", { className: "vs:relative vs:flex vs:flex-col", children: [
|
|
164
|
+
/* @__PURE__ */ E(
|
|
165
165
|
"select",
|
|
166
166
|
{
|
|
167
|
-
onChange: (
|
|
168
|
-
const
|
|
169
|
-
(z) => z.value.toString() ===
|
|
167
|
+
onChange: (l) => {
|
|
168
|
+
const U = f.find(
|
|
169
|
+
(z) => z.value.toString() === l.target.value.toString()
|
|
170
170
|
);
|
|
171
|
-
|
|
171
|
+
U && q(U);
|
|
172
172
|
},
|
|
173
173
|
className: "vehicle-search-select vs:relative vs:w-full vs:cursor-default vs:overflow-hidden vs:rounded-(--partbot-button-border-radius) partbot-input-border vs:bg-white vs:py-(--partbot-padding) vs:pl-[calc(var(--partbot-padding)*1.3)] vs:pr-10 vs:text-left vs:shadow-(--partbot-input-shadow) vs:focus:border-[rgb(var(--partbot-theme))] vs:focus:outline-none vs:focus:ring-1 vs:focus:ring-[rgb(var(--partbot-theme))] vs:disabled:opacity-100! vs:disabled:text-stone-400! vs:sm:text-(length:--partbot-font-size) vs:font-(family-name:--partbot-font-family) vs:text-(length:--partbot-font-size) vs:leading-[calc(var(--partbot-font-size)*1.5)]",
|
|
174
174
|
tabIndex: -1,
|
|
@@ -176,14 +176,14 @@ function X({
|
|
|
176
176
|
value: y ? y.value : "",
|
|
177
177
|
children: [
|
|
178
178
|
/* @__PURE__ */ a("option", { value: "", disabled: !0, children: b }),
|
|
179
|
-
D.length > 0 ? /* @__PURE__ */
|
|
180
|
-
/* @__PURE__ */ a("optgroup", { label: `Popular ${
|
|
181
|
-
/* @__PURE__ */ a("optgroup", { label: `All ${
|
|
182
|
-
(
|
|
183
|
-
(
|
|
179
|
+
D.length > 0 ? /* @__PURE__ */ E($e, { children: [
|
|
180
|
+
/* @__PURE__ */ a("optgroup", { label: `Popular ${Qe(b)}`, children: D.map((l) => /* @__PURE__ */ a("option", { value: l.refinement, children: l.value }, l.value)) }),
|
|
181
|
+
/* @__PURE__ */ a("optgroup", { label: `All ${Qe(b)}`, children: f.filter(
|
|
182
|
+
(l) => !D.some(
|
|
183
|
+
(U) => U.value === l.value
|
|
184
184
|
)
|
|
185
|
-
).map((
|
|
186
|
-
] }) : f.map((
|
|
185
|
+
).map((l) => /* @__PURE__ */ a("option", { value: l.refinement, children: l.value }, l.value)) })
|
|
186
|
+
] }) : f.map((l) => /* @__PURE__ */ a("option", { value: l.refinement, children: l.value }, l.value))
|
|
187
187
|
]
|
|
188
188
|
}
|
|
189
189
|
),
|
|
@@ -209,7 +209,7 @@ function X({
|
|
|
209
209
|
}
|
|
210
210
|
)
|
|
211
211
|
] }),
|
|
212
|
-
!_ && /* @__PURE__ */
|
|
212
|
+
!_ && /* @__PURE__ */ E(
|
|
213
213
|
gt,
|
|
214
214
|
{
|
|
215
215
|
value: y || null,
|
|
@@ -218,20 +218,20 @@ function X({
|
|
|
218
218
|
disabled: g,
|
|
219
219
|
immediate: !0,
|
|
220
220
|
children: [
|
|
221
|
-
/* @__PURE__ */
|
|
221
|
+
/* @__PURE__ */ E("div", { className: "vs:flex vs:h-full", children: [
|
|
222
222
|
/* @__PURE__ */ a(
|
|
223
223
|
bt,
|
|
224
224
|
{
|
|
225
225
|
autoComplete: "off",
|
|
226
226
|
spellCheck: "false",
|
|
227
|
-
placeholder: g &&
|
|
227
|
+
placeholder: g && O && !V ? "N/A" : b,
|
|
228
228
|
className: "vs:w-full vs:cursor-default vs:rounded-(--partbot-button-border-radius) partbot-input-border vs:bg-white vs:py-(--partbot-padding) vs:pl-[calc(var(--partbot-padding)*1.3)] vs:pr-10 vs:text-left vs:shadow-(--partbot-input-shadow) vs:focus:border-[rgb(var(--partbot-theme))] vs:focus:outline-none vs:focus:ring-1 vs:focus:ring-[rgb(var(--partbot-theme))] vs:text-(length:--partbot-font-size) vs:leading-[calc(var(--partbot-font-size)*1.5)] vs:font-(family-name:--partbot-font-family) vs:text-stone-900 vs:placeholder:text-stone-600 vs:disabled:placeholder:text-stone-400 vs:disabled:cursor-not-allowed",
|
|
229
|
-
displayValue: (
|
|
230
|
-
onChange: (
|
|
229
|
+
displayValue: (l) => (l == null ? void 0 : l.value) || "",
|
|
230
|
+
onChange: (l) => u(l.target.value),
|
|
231
231
|
title: b
|
|
232
232
|
}
|
|
233
233
|
),
|
|
234
|
-
/* @__PURE__ */
|
|
234
|
+
/* @__PURE__ */ E("div", { className: "vs:absolute vs:pointer-events-none vs:h-full vs:right-0 vs:flex vs:space-x-[calc(var(--partbot-padding)*0.25)] vs:items-center", children: [
|
|
235
235
|
(y == null ? void 0 : y.value) && /* @__PURE__ */ a(
|
|
236
236
|
"button",
|
|
237
237
|
{
|
|
@@ -272,31 +272,31 @@ function X({
|
|
|
272
272
|
portal: !0,
|
|
273
273
|
anchor: "bottom start",
|
|
274
274
|
className: "vs:w-(--input-width) vs:z-99999! vs:max-h-60! vs:overflow-auto vs:rounded-[min(var(--partbot-button-border-radius),0.89rem)] vs:bg-white vs:py-1 vs:text-base vs:shadow-lg vs:ring-1 vs:ring-stone-200 vs:focus:outline-none vs:sm:text-(length:--partbot-font-size) empty:vs:invisible vs:mt-2",
|
|
275
|
-
children: ({ option:
|
|
276
|
-
const
|
|
277
|
-
(z) => z.value ===
|
|
275
|
+
children: ({ option: l }) => {
|
|
276
|
+
const U = l && D.some(
|
|
277
|
+
(z) => z.value === l.value
|
|
278
278
|
);
|
|
279
279
|
return /* @__PURE__ */ a(
|
|
280
280
|
xt,
|
|
281
281
|
{
|
|
282
|
-
value:
|
|
282
|
+
value: l,
|
|
283
283
|
className: ({ focus: z }) => ne(
|
|
284
284
|
"vs:group vs:relative vs:w-full vs:cursor-default vs:py-(--partbot-padding) vs:px-[calc(var(--partbot-padding)*1.3)] vs:text-left vs:border-none",
|
|
285
285
|
z ? "vs:bg-[rgb(var(--partbot-theme))] vs:text-[rgb(var(--partbot-button-label-color))]" : "vs:bg-white vs:text-stone-900 vs:hover:bg-theme vs:hover:text-button-label",
|
|
286
|
-
|
|
286
|
+
U && "vs:font-bold!"
|
|
287
287
|
),
|
|
288
|
-
children: ({ selected: z }) => /* @__PURE__ */
|
|
288
|
+
children: ({ selected: z }) => /* @__PURE__ */ E("div", { className: "vs:flex vs:w-full vs:items-center vs:justify-between", children: [
|
|
289
289
|
/* @__PURE__ */ a(
|
|
290
290
|
"span",
|
|
291
291
|
{
|
|
292
292
|
className: ne(
|
|
293
|
-
|
|
293
|
+
l.value === (p == null ? void 0 : p.value) ? "vs:font-semibold" : "vs:font-normal",
|
|
294
294
|
"vs:block vs:font-(family-name:--partbot-font-family) vs:whitespace-pre-wrap vs:text-left vs:text-(length:--partbot-font-size) vs:leading-none"
|
|
295
295
|
),
|
|
296
|
-
children:
|
|
296
|
+
children: l.value
|
|
297
297
|
}
|
|
298
298
|
),
|
|
299
|
-
|
|
299
|
+
l.value === (p == null ? void 0 : p.value) && /* @__PURE__ */ a(
|
|
300
300
|
"span",
|
|
301
301
|
{
|
|
302
302
|
className: ne(
|
|
@@ -328,39 +328,39 @@ function X({
|
|
|
328
328
|
)
|
|
329
329
|
] });
|
|
330
330
|
}
|
|
331
|
-
const $t = "3.0.
|
|
331
|
+
const $t = "3.0.22";
|
|
332
332
|
console.info(
|
|
333
333
|
`Vehicle Search v${$t} powered by Partbot https://mmyvs.partbot.io`
|
|
334
334
|
);
|
|
335
335
|
function Se(b = [], v = []) {
|
|
336
336
|
const p = [];
|
|
337
|
-
return b.forEach((
|
|
338
|
-
const [I, ...R] =
|
|
337
|
+
return b.forEach((F) => {
|
|
338
|
+
const [I, ...R] = F.split(":"), P = R.join(":");
|
|
339
339
|
if (P.includes(" > ")) {
|
|
340
|
-
const
|
|
341
|
-
if (I !== "make" &&
|
|
342
|
-
const V =
|
|
340
|
+
const T = P.split(" > "), _ = T[T.length - 1].trim();
|
|
341
|
+
if (I !== "make" && T.length >= 2) {
|
|
342
|
+
const V = T[0].trim();
|
|
343
343
|
p.push(`make = "${V}"`);
|
|
344
344
|
}
|
|
345
345
|
p.push(`${I} = "${_}"`);
|
|
346
346
|
} else
|
|
347
347
|
p.push(`${I} = "${P}"`);
|
|
348
|
-
}), v.forEach((
|
|
349
|
-
p.push(
|
|
348
|
+
}), v.forEach((F) => {
|
|
349
|
+
p.push(F);
|
|
350
350
|
}), p.length > 0 ? p.join(" AND ") : null;
|
|
351
351
|
}
|
|
352
352
|
function Mt({
|
|
353
353
|
apiKey: b,
|
|
354
354
|
makes: v = "",
|
|
355
355
|
models: p = "",
|
|
356
|
-
callbackUrl:
|
|
356
|
+
callbackUrl: F = "",
|
|
357
357
|
layout: I = "row",
|
|
358
358
|
fields: R,
|
|
359
359
|
fieldPrefix: P = "",
|
|
360
|
-
showBranding:
|
|
360
|
+
showBranding: T = !0,
|
|
361
361
|
showLabels: _ = !1,
|
|
362
362
|
mobileFullWidthButton: V = !0,
|
|
363
|
-
mobileDrawer:
|
|
363
|
+
mobileDrawer: O = !0,
|
|
364
364
|
modifyQueryString: re = !0,
|
|
365
365
|
onChange: u,
|
|
366
366
|
buttonLabel: y = "Search",
|
|
@@ -374,10 +374,10 @@ function Mt({
|
|
|
374
374
|
// Use api.cartbot.io instead of api.partbot.io
|
|
375
375
|
yearOptional: g = !1,
|
|
376
376
|
// Make year selection optional, only requiring make + model
|
|
377
|
-
mobileButtonLabel:
|
|
377
|
+
mobileButtonLabel: l = "Select Vehicle"
|
|
378
378
|
// Label for mobile drawer trigger button
|
|
379
379
|
}) {
|
|
380
|
-
const
|
|
380
|
+
const U = Z(null), z = Z(null), ie = Z(null), S = Z(null), K = Z(null), j = Z(null), Q = Z(null), w = Z(null), W = Z(null), M = Z(!1), x = f === "YMM", [le, ve] = A([]), [fe, ce] = A([]), [de, he] = A([]), [Le, ge] = A([]), [Ie, be] = A([]), [Ve, we] = A([]), [De, ye] = A([]), [Ue, xe] = A([]), Xe = Z([]), [se, ke] = A([]), [e, Y] = A({
|
|
381
381
|
make: null,
|
|
382
382
|
model: null,
|
|
383
383
|
year: null,
|
|
@@ -386,21 +386,21 @@ function Mt({
|
|
|
386
386
|
variant: null,
|
|
387
387
|
engine: null,
|
|
388
388
|
engine_capacity: null
|
|
389
|
-
}), [
|
|
389
|
+
}), [Ge, Me] = A(!1), Fe = Z([
|
|
390
390
|
"body",
|
|
391
391
|
"series",
|
|
392
392
|
"variant",
|
|
393
393
|
"engine",
|
|
394
394
|
"engine_capacity"
|
|
395
395
|
]), Ce = Z(
|
|
396
|
-
R && R.length &&
|
|
396
|
+
R && R.length && Fe.current ? R.split(",").filter((t) => {
|
|
397
397
|
var r;
|
|
398
|
-
return (r =
|
|
398
|
+
return (r = Fe.current) == null ? void 0 : r.includes(t);
|
|
399
399
|
}) : null
|
|
400
|
-
), [J,
|
|
400
|
+
), [J, et] = A(!1);
|
|
401
401
|
B(() => {
|
|
402
402
|
const t = navigator.userAgent;
|
|
403
|
-
|
|
403
|
+
et(
|
|
404
404
|
/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(
|
|
405
405
|
t
|
|
406
406
|
)
|
|
@@ -412,7 +412,7 @@ function Mt({
|
|
|
412
412
|
disable_session_recording: !1
|
|
413
413
|
});
|
|
414
414
|
}, []);
|
|
415
|
-
const [oe,
|
|
415
|
+
const [oe, tt] = A({}), [Nt, rt] = A(""), Re = N(async () => {
|
|
416
416
|
if (!b)
|
|
417
417
|
return;
|
|
418
418
|
const r = `${D ? "https://api.cartbot.io" : "https://api.partbot.io"}/v1/vehicles/auth`;
|
|
@@ -435,7 +435,7 @@ function Mt({
|
|
|
435
435
|
throw new Error(`Error: ${i.status} ${i.statusText}`);
|
|
436
436
|
const {
|
|
437
437
|
merchant: o,
|
|
438
|
-
vehicle_makes:
|
|
438
|
+
vehicle_makes: s,
|
|
439
439
|
vehicle_models: n,
|
|
440
440
|
meilisearch_search_key: c,
|
|
441
441
|
meilisearch_index_name: d,
|
|
@@ -449,15 +449,15 @@ function Mt({
|
|
|
449
449
|
store_popular_models: h
|
|
450
450
|
// Object mapping makes to popular models: { "TOYOTA": ["HILUX", "LANDCRUISER"], ... }
|
|
451
451
|
} = await i.json();
|
|
452
|
-
z.current = o, ie.current = (
|
|
452
|
+
z.current = o, ie.current = (s || []).map((m) => ({
|
|
453
453
|
...m,
|
|
454
454
|
refinement: m.value
|
|
455
|
-
})), G && n ? typeof n == "object" && !Array.isArray(n) ? S.current = n : Array.isArray(n) ? S.current = n.map((m) => m && m.value ? String(m.value).trim() : "").filter(Boolean) : S.current = [] : S.current = [], K.current = Array.isArray(ae) ? ae.map((m) => String(m).trim().toUpperCase()) : null,
|
|
455
|
+
})), G && n ? typeof n == "object" && !Array.isArray(n) ? S.current = n : Array.isArray(n) ? S.current = n.map((m) => m && m.value ? String(m.value).trim() : "").filter(Boolean) : S.current = [] : S.current = [], K.current = Array.isArray(ae) ? ae.map((m) => String(m).trim().toUpperCase()) : null, j.current = h || null, tt({
|
|
456
456
|
searchKey: "eeace38b64f52bf56ebb4fe8bd5837b3cd6c0ff9d7e272f76449d94b80cba86b",
|
|
457
457
|
indexName: "otto_v1_vehicles_production"
|
|
458
458
|
});
|
|
459
459
|
} catch (i) {
|
|
460
|
-
console.error("[VehicleSearch] Auth failed:", i),
|
|
460
|
+
console.error("[VehicleSearch] Auth failed:", i), rt(i);
|
|
461
461
|
}
|
|
462
462
|
}, [b, ee, G, D]);
|
|
463
463
|
B(() => {
|
|
@@ -465,11 +465,11 @@ function Mt({
|
|
|
465
465
|
}, [Re]), B(() => {
|
|
466
466
|
if (oe.searchKey) {
|
|
467
467
|
try {
|
|
468
|
-
Q.current = new
|
|
468
|
+
Q.current = new We({
|
|
469
469
|
host: "https://search.partbot.io",
|
|
470
470
|
apiKey: oe.searchKey
|
|
471
471
|
}), w.current = Q.current.index(oe.indexName);
|
|
472
|
-
const t = new
|
|
472
|
+
const t = new We({
|
|
473
473
|
host: "https://partbot-meilisearch-cache.partbot.workers.dev",
|
|
474
474
|
// Cloudflare Worker endpoint
|
|
475
475
|
apiKey: oe.searchKey
|
|
@@ -483,7 +483,7 @@ function Mt({
|
|
|
483
483
|
};
|
|
484
484
|
}
|
|
485
485
|
}, [oe.searchKey, b]);
|
|
486
|
-
const [H,
|
|
486
|
+
const [H, ot] = A(!1), Te = N(() => {
|
|
487
487
|
function t(n) {
|
|
488
488
|
if (!n) return "rgba(0,0,0,1)";
|
|
489
489
|
var c = r(), d = window.getComputedStyle(n).backgroundColor;
|
|
@@ -497,9 +497,9 @@ function Mt({
|
|
|
497
497
|
}
|
|
498
498
|
const i = document.querySelector("vehicle-search");
|
|
499
499
|
let o;
|
|
500
|
-
i ? o = t(i) : o = t(
|
|
501
|
-
const
|
|
502
|
-
|
|
500
|
+
i ? o = t(i) : o = t(U.current);
|
|
501
|
+
const s = _t(o).isDark();
|
|
502
|
+
ot(s);
|
|
503
503
|
}, []);
|
|
504
504
|
B(() => {
|
|
505
505
|
async function t() {
|
|
@@ -516,13 +516,13 @@ function Mt({
|
|
|
516
516
|
), e.series && r.push(`series:${e.series.refinement}`), e.engine && r.push(`engine:${e.engine.refinement}`), e.engine_capacity && r.push(
|
|
517
517
|
`engine_capacity:${e.engine_capacity.refinement}`
|
|
518
518
|
);
|
|
519
|
-
let
|
|
519
|
+
let s = (await w.current.search("", {
|
|
520
520
|
filter: Se(r, i),
|
|
521
521
|
attributesToRetrieve: ["otto_id"],
|
|
522
522
|
limit: 500
|
|
523
523
|
// Reduced from 1000 for faster queries
|
|
524
524
|
})).hits.map((d) => d.otto_id);
|
|
525
|
-
ke(
|
|
525
|
+
ke(s);
|
|
526
526
|
let c = {
|
|
527
527
|
...Object.fromEntries(
|
|
528
528
|
Object.entries(e || {}).map(([d, $]) => [d, $ && $.value || null]).filter(([d, $]) => $ !== null)
|
|
@@ -533,7 +533,7 @@ function Mt({
|
|
|
533
533
|
}
|
|
534
534
|
t();
|
|
535
535
|
}, [e, w, g]);
|
|
536
|
-
const Ae = (t) => P ? `${P}${t}` : t,
|
|
536
|
+
const Ae = (t) => P ? `${P}${t}` : t, at = (t) => P ? t.replace(new RegExp(`^${P}`), "") : t, nt = N(() => {
|
|
537
537
|
const t = new URL(window.location.href).searchParams, r = [
|
|
538
538
|
"make",
|
|
539
539
|
"model",
|
|
@@ -543,7 +543,7 @@ function Mt({
|
|
|
543
543
|
"engine",
|
|
544
544
|
"engine_capacity"
|
|
545
545
|
].map(Ae), i = Object.fromEntries(
|
|
546
|
-
[...t.entries()].filter(([o]) => r.includes(o)).map(([o,
|
|
546
|
+
[...t.entries()].filter(([o]) => r.includes(o)).map(([o, s]) => [at(o), { value: s, refinement: s }])
|
|
547
547
|
);
|
|
548
548
|
Y(i);
|
|
549
549
|
}, []), L = N(({ query: t, value: r, remove: i }) => {
|
|
@@ -552,10 +552,10 @@ function Mt({
|
|
|
552
552
|
t = Ae(t), t && r && o.set(t, r), t && !r && o.delete(t), i && i.forEach((n) => {
|
|
553
553
|
n = Ae(n), o.delete(n);
|
|
554
554
|
});
|
|
555
|
-
const
|
|
556
|
-
window.history.pushState(null, "",
|
|
555
|
+
const s = window.location.pathname + "?" + o.toString();
|
|
556
|
+
window.history.pushState(null, "", s);
|
|
557
557
|
}
|
|
558
|
-
}, []),
|
|
558
|
+
}, []), it = N(() => {
|
|
559
559
|
var i;
|
|
560
560
|
const t = {
|
|
561
561
|
vehicle_ids: se,
|
|
@@ -568,38 +568,38 @@ function Mt({
|
|
|
568
568
|
window.dispatchEvent(r), document.dispatchEvent(r), setTimeout(() => {
|
|
569
569
|
Me(!1);
|
|
570
570
|
}, 900);
|
|
571
|
-
}, [se, q]),
|
|
572
|
-
var i, o,
|
|
571
|
+
}, [se, q]), Oe = N(() => {
|
|
572
|
+
var i, o, s, n, c, d, $, te, pe;
|
|
573
573
|
const t = {
|
|
574
574
|
vehicle_ids: se,
|
|
575
575
|
vehicle: (i = e == null ? void 0 : e.make) != null && i.value ? e : {},
|
|
576
|
-
userSelected:
|
|
576
|
+
userSelected: M.current
|
|
577
577
|
// Flag to indicate if user actively selected
|
|
578
578
|
};
|
|
579
579
|
u && u(t);
|
|
580
580
|
const r = new CustomEvent("vehicle-search-change", {
|
|
581
581
|
detail: t
|
|
582
582
|
});
|
|
583
|
-
if (
|
|
583
|
+
if (M.current === !0) {
|
|
584
584
|
localStorage.removeItem("partbot_plate_details");
|
|
585
585
|
const ae = JSON.stringify({
|
|
586
|
-
description: `${((o = e.make) == null ? void 0 : o.value) || ""} ${((
|
|
586
|
+
description: `${((o = e.make) == null ? void 0 : o.value) || ""} ${((s = e.model) == null ? void 0 : s.value) || ""} ${((n = e.year) == null ? void 0 : n.value) || ""} ${((c = e.body) == null ? void 0 : c.value) || ""} ${((d = e.series) == null ? void 0 : d.value) || ""} ${(($ = e.variant) == null ? void 0 : $.value) || ""} ${((te = e.engine) == null ? void 0 : te.value) || ""} ${((pe = e.engine_capacity) == null ? void 0 : pe.value) || ""}`.trim(),
|
|
587
587
|
vehicle_ids: se,
|
|
588
588
|
vehicle: e ? Object.entries(e).reduce((h, [m, k]) => (h[m] = k != null && k.value ? k.value : {}, h), {}) : {}
|
|
589
589
|
});
|
|
590
590
|
localStorage.setItem(
|
|
591
591
|
"partbot_selected_vehicle",
|
|
592
592
|
ae
|
|
593
|
-
),
|
|
593
|
+
), Ke.set("partbot_selected_vehicle", ae, {
|
|
594
594
|
secure: !0
|
|
595
595
|
});
|
|
596
596
|
}
|
|
597
|
-
window.dispatchEvent(r), document.dispatchEvent(r),
|
|
597
|
+
window.dispatchEvent(r), document.dispatchEvent(r), Xe.current = se, setTimeout(() => {
|
|
598
598
|
Me(!1);
|
|
599
599
|
}, 900);
|
|
600
|
-
}, [se, u]), _e =
|
|
601
|
-
() => Ct(
|
|
602
|
-
[
|
|
600
|
+
}, [se, u]), _e = mt(
|
|
601
|
+
() => Ct(Oe, 100),
|
|
602
|
+
[Oe]
|
|
603
603
|
);
|
|
604
604
|
B(() => {
|
|
605
605
|
_e();
|
|
@@ -607,7 +607,20 @@ function Mt({
|
|
|
607
607
|
_e.cancel();
|
|
608
608
|
}, [_e]), B(() => {
|
|
609
609
|
const t = () => {
|
|
610
|
-
|
|
610
|
+
M.current = !1, localStorage.removeItem("partbot_selected_vehicle"), Ke.remove("partbot_selected_vehicle");
|
|
611
|
+
const r = new URL(window.location.href), i = [
|
|
612
|
+
"make",
|
|
613
|
+
"model",
|
|
614
|
+
"year",
|
|
615
|
+
"body",
|
|
616
|
+
"series",
|
|
617
|
+
"variant",
|
|
618
|
+
"engine"
|
|
619
|
+
];
|
|
620
|
+
let o = !1;
|
|
621
|
+
i.forEach((s) => {
|
|
622
|
+
r.searchParams.has(s) && (r.searchParams.delete(s), o = !0);
|
|
623
|
+
}), o && window.history.replaceState(null, "", r.toString()), Y({
|
|
611
624
|
make: null,
|
|
612
625
|
model: null,
|
|
613
626
|
year: null,
|
|
@@ -625,14 +638,14 @@ function Mt({
|
|
|
625
638
|
);
|
|
626
639
|
};
|
|
627
640
|
}, []), B(() => {
|
|
628
|
-
oe.searchKey && (x ||
|
|
641
|
+
oe.searchKey && (x || vt(), nt());
|
|
629
642
|
}, [oe.searchKey, x]), B(() => {
|
|
630
643
|
x && w.current && de.length === 0 && !e.year && w.current.search("", {
|
|
631
644
|
attributesToRetrieve: ["year_from", "year_to"],
|
|
632
645
|
limit: 1e4
|
|
633
646
|
}).then(({ hits: t }) => {
|
|
634
|
-
const r = t.map((c) => c.year_from).filter(Boolean), i = t.map((c) => c.year_to).filter(Boolean), o = Math.min(...r),
|
|
635
|
-
{ length:
|
|
647
|
+
const r = t.map((c) => c.year_from).filter(Boolean), i = t.map((c) => c.year_to).filter(Boolean), o = Math.min(...r), s = Math.max(...i), n = Array.from(
|
|
648
|
+
{ length: s - o + 1 },
|
|
636
649
|
(c, d) => ({ value: o + d, refinement: o + d })
|
|
637
650
|
).reverse();
|
|
638
651
|
he(n);
|
|
@@ -640,11 +653,11 @@ function Mt({
|
|
|
640
653
|
console.error("[VehicleSearch] Error loading year range:", t);
|
|
641
654
|
});
|
|
642
655
|
}, [x, oe.searchKey, de.length, e.year]), B(() => {
|
|
643
|
-
typeof document > "u" ||
|
|
644
|
-
}, [
|
|
656
|
+
typeof document > "u" || Te();
|
|
657
|
+
}, [Te]);
|
|
645
658
|
const Ze = N(
|
|
646
659
|
(t) => {
|
|
647
|
-
|
|
660
|
+
M.current = !0, ce([]), !x && !g && he([]), ge([]), be([]), we([]), xe([]), ye([]), Y((r) => ({
|
|
648
661
|
make: t,
|
|
649
662
|
year: x || g ? r.year : null
|
|
650
663
|
})), L({
|
|
@@ -671,7 +684,7 @@ function Mt({
|
|
|
671
684
|
[L, x, g]
|
|
672
685
|
), Ye = N(
|
|
673
686
|
(t) => {
|
|
674
|
-
|
|
687
|
+
M.current = !0, Y((r) => ({
|
|
675
688
|
...r,
|
|
676
689
|
model: t !== "" ? t : null,
|
|
677
690
|
year: x || g ? r.year : null,
|
|
@@ -697,7 +710,7 @@ function Mt({
|
|
|
697
710
|
[L, x, g]
|
|
698
711
|
), He = N(
|
|
699
712
|
(t) => {
|
|
700
|
-
|
|
713
|
+
M.current = !0, x ? (ve([]), ce([]), Y({
|
|
701
714
|
year: t !== "" ? t : null
|
|
702
715
|
}), (!t || t === "") && he([])) : Y(g ? (r) => ({
|
|
703
716
|
...r,
|
|
@@ -725,9 +738,9 @@ function Mt({
|
|
|
725
738
|
}), !g && (!t || t === "") && ke([]);
|
|
726
739
|
},
|
|
727
740
|
[L, x, g]
|
|
728
|
-
),
|
|
741
|
+
), st = N(
|
|
729
742
|
(t) => {
|
|
730
|
-
|
|
743
|
+
M.current = !0, Y((r) => ({
|
|
731
744
|
...r,
|
|
732
745
|
body: t !== "" ? t : null
|
|
733
746
|
})), L({
|
|
@@ -736,9 +749,9 @@ function Mt({
|
|
|
736
749
|
});
|
|
737
750
|
},
|
|
738
751
|
[L]
|
|
739
|
-
),
|
|
752
|
+
), lt = N(
|
|
740
753
|
(t) => {
|
|
741
|
-
|
|
754
|
+
M.current = !0, Y((r) => ({
|
|
742
755
|
...r,
|
|
743
756
|
series: t !== "" ? t : null
|
|
744
757
|
})), L({
|
|
@@ -747,9 +760,9 @@ function Mt({
|
|
|
747
760
|
});
|
|
748
761
|
},
|
|
749
762
|
[L]
|
|
750
|
-
),
|
|
763
|
+
), ct = N(
|
|
751
764
|
(t) => {
|
|
752
|
-
|
|
765
|
+
M.current = !0, Y((r) => ({
|
|
753
766
|
...r,
|
|
754
767
|
variant: t !== "" ? t : null
|
|
755
768
|
})), L({
|
|
@@ -758,9 +771,9 @@ function Mt({
|
|
|
758
771
|
});
|
|
759
772
|
},
|
|
760
773
|
[L]
|
|
761
|
-
),
|
|
774
|
+
), dt = N(
|
|
762
775
|
(t) => {
|
|
763
|
-
|
|
776
|
+
M.current = !0, Y((r) => ({
|
|
764
777
|
...r,
|
|
765
778
|
engine: t !== "" ? t : null
|
|
766
779
|
})), L({
|
|
@@ -769,9 +782,9 @@ function Mt({
|
|
|
769
782
|
});
|
|
770
783
|
},
|
|
771
784
|
[L]
|
|
772
|
-
),
|
|
785
|
+
), pt = N(
|
|
773
786
|
(t) => {
|
|
774
|
-
|
|
787
|
+
M.current = !0, Y((r) => ({
|
|
775
788
|
...r,
|
|
776
789
|
engine_capacity: t !== "" ? t : null
|
|
777
790
|
})), L({
|
|
@@ -797,9 +810,9 @@ function Mt({
|
|
|
797
810
|
});
|
|
798
811
|
});
|
|
799
812
|
let o = Array.from(i.values());
|
|
800
|
-
const
|
|
801
|
-
|
|
802
|
-
const d =
|
|
813
|
+
const s = new Set(K.current || []);
|
|
814
|
+
s.size > 0 ? o.sort((n, c) => {
|
|
815
|
+
const d = s.has(n.value), $ = s.has(c.value);
|
|
803
816
|
return d && !$ ? -1 : !d && $ ? 1 : d && $ ? K.current.indexOf(n.value) - K.current.indexOf(c.value) : n.value.localeCompare(c.value);
|
|
804
817
|
}) : o.sort(
|
|
805
818
|
(n, c) => c.popularity === n.popularity ? n.value.localeCompare(c.value) : c.popularity - n.popularity
|
|
@@ -809,7 +822,7 @@ function Mt({
|
|
|
809
822
|
}
|
|
810
823
|
})();
|
|
811
824
|
}, [x, e.year]);
|
|
812
|
-
const
|
|
825
|
+
const vt = N(() => {
|
|
813
826
|
(async () => {
|
|
814
827
|
let r = [];
|
|
815
828
|
if (ie.current && ie.current.length)
|
|
@@ -820,11 +833,11 @@ function Mt({
|
|
|
820
833
|
attributesToRetrieve: ["make", "make_popularity"],
|
|
821
834
|
limit: 1e3
|
|
822
835
|
}), o = /* @__PURE__ */ new Map();
|
|
823
|
-
i.hits.forEach((
|
|
824
|
-
|
|
825
|
-
value:
|
|
826
|
-
refinement:
|
|
827
|
-
popularity:
|
|
836
|
+
i.hits.forEach((s) => {
|
|
837
|
+
s.make && !o.has(s.make) && o.set(s.make, {
|
|
838
|
+
value: s.make.toUpperCase(),
|
|
839
|
+
refinement: s.make.toUpperCase(),
|
|
840
|
+
popularity: s.make_popularity || 0
|
|
828
841
|
});
|
|
829
842
|
}), r = Array.from(o.values());
|
|
830
843
|
} catch (i) {
|
|
@@ -838,9 +851,9 @@ function Mt({
|
|
|
838
851
|
}
|
|
839
852
|
if (K.current && K.current.length > 0) {
|
|
840
853
|
const i = new Set(K.current);
|
|
841
|
-
r.sort((o,
|
|
842
|
-
const n = i.has(o.value), c = i.has(
|
|
843
|
-
return n && !c ? -1 : !n && c ? 1 : n && c ? K.current.indexOf(o.value) - K.current.indexOf(
|
|
854
|
+
r.sort((o, s) => {
|
|
855
|
+
const n = i.has(o.value), c = i.has(s.value);
|
|
856
|
+
return n && !c ? -1 : !n && c ? 1 : n && c ? K.current.indexOf(o.value) - K.current.indexOf(s.value) : o.value.localeCompare(s.value);
|
|
844
857
|
});
|
|
845
858
|
} else
|
|
846
859
|
r.sort((i, o) => i.popularity === o.popularity ? i.value.localeCompare(o.value) : o.popularity - i.popularity);
|
|
@@ -853,26 +866,26 @@ function Mt({
|
|
|
853
866
|
const r = e.make.refinement;
|
|
854
867
|
if (G && typeof S.current == "object" && !Array.isArray(S.current) && S.current[r]) {
|
|
855
868
|
const i = S.current[r].map(
|
|
856
|
-
(
|
|
857
|
-
value:
|
|
858
|
-
refinement:
|
|
869
|
+
(s) => ({
|
|
870
|
+
value: s,
|
|
871
|
+
refinement: s,
|
|
859
872
|
popularity: 0
|
|
860
873
|
// Popularity will be used from PostHog for sorting
|
|
861
874
|
})
|
|
862
|
-
), o = (t =
|
|
875
|
+
), o = (t = j.current) == null ? void 0 : t[r];
|
|
863
876
|
if (o && Array.isArray(o)) {
|
|
864
|
-
const
|
|
877
|
+
const s = new Map(
|
|
865
878
|
o.map((n, c) => [
|
|
866
879
|
n.toUpperCase(),
|
|
867
880
|
o.length - c
|
|
868
881
|
])
|
|
869
882
|
);
|
|
870
883
|
i.sort((n, c) => {
|
|
871
|
-
const d =
|
|
884
|
+
const d = s.get(n.value.toUpperCase()) || 0, $ = s.get(c.value.toUpperCase()) || 0;
|
|
872
885
|
return d !== $ ? $ - d : n.value.localeCompare(c.value);
|
|
873
886
|
});
|
|
874
887
|
} else
|
|
875
|
-
i.sort((
|
|
888
|
+
i.sort((s, n) => s.value.localeCompare(n.value));
|
|
876
889
|
ce(i);
|
|
877
890
|
return;
|
|
878
891
|
}
|
|
@@ -885,9 +898,9 @@ function Mt({
|
|
|
885
898
|
}).then((i) => {
|
|
886
899
|
var pe, ae;
|
|
887
900
|
const { hits: o } = i;
|
|
888
|
-
let
|
|
889
|
-
o.length > 0 && o[0].models && (
|
|
890
|
-
let n =
|
|
901
|
+
let s = [];
|
|
902
|
+
o.length > 0 && o[0].models && (s = o[0].models);
|
|
903
|
+
let n = s.map((h) => ({
|
|
891
904
|
model: `${e.make.refinement} > ${h.name}`,
|
|
892
905
|
model_popularity: h.popularity || 0
|
|
893
906
|
})), c = [];
|
|
@@ -924,7 +937,7 @@ function Mt({
|
|
|
924
937
|
refinement: h.model.match(/[^>]*$/)[0].trim(),
|
|
925
938
|
popularity: h.model_popularity
|
|
926
939
|
}));
|
|
927
|
-
const $ = (pe = e.make) == null ? void 0 : pe.refinement, te = (ae =
|
|
940
|
+
const $ = (pe = e.make) == null ? void 0 : pe.refinement, te = (ae = j.current) == null ? void 0 : ae[$];
|
|
928
941
|
if (te && Array.isArray(te) && te.length > 0) {
|
|
929
942
|
const h = new Set(
|
|
930
943
|
te.map((m) => String(m).trim().toUpperCase())
|
|
@@ -935,7 +948,7 @@ function Mt({
|
|
|
935
948
|
if (!je && Ne) return 1;
|
|
936
949
|
if (je && Ne) {
|
|
937
950
|
const qe = te.map(
|
|
938
|
-
(
|
|
951
|
+
(ut) => String(ut).trim().toUpperCase()
|
|
939
952
|
);
|
|
940
953
|
return qe.indexOf(m.value) - qe.indexOf(k.value);
|
|
941
954
|
}
|
|
@@ -971,7 +984,7 @@ function Mt({
|
|
|
971
984
|
limit: 200
|
|
972
985
|
// Reduced from 1000 for faster queries
|
|
973
986
|
}).then(({ hits: r }) => {
|
|
974
|
-
const i = r.map((d) => d.year_from), o = Math.min(...i),
|
|
987
|
+
const i = r.map((d) => d.year_from), o = Math.min(...i), s = r.map((d) => d.year_to), n = Math.max(...s);
|
|
975
988
|
let c = Array.apply(null, {
|
|
976
989
|
length: n + 1 - o
|
|
977
990
|
}).map(function(d, $) {
|
|
@@ -1015,13 +1028,13 @@ function Mt({
|
|
|
1015
1028
|
}, [e.year, e.make, e.model, g]);
|
|
1016
1029
|
const ue = N(({ hits: t, attribute: r, stateCallback: i }) => {
|
|
1017
1030
|
let o = [
|
|
1018
|
-
...new Map(t.map((
|
|
1019
|
-
].map((
|
|
1020
|
-
value:
|
|
1021
|
-
refinement:
|
|
1022
|
-
})).filter((
|
|
1031
|
+
...new Map(t.map((s) => [s[r], s])).values()
|
|
1032
|
+
].map((s) => ({
|
|
1033
|
+
value: s[r].match(/[^|]*$/)[0].trim(),
|
|
1034
|
+
refinement: s[r].match(/[^|]*$/)[0].trim()
|
|
1035
|
+
})).filter((s) => s.refinement);
|
|
1023
1036
|
i(o);
|
|
1024
|
-
}, []),
|
|
1037
|
+
}, []), ht = N(() => {
|
|
1025
1038
|
const t = Ce.current ? Ce.current.length + 3 : 3, r = C ? t + 1 : t;
|
|
1026
1039
|
return `vs:lg:grid-cols-${r > 8 ? 8 : r}`;
|
|
1027
1040
|
}, [C]);
|
|
@@ -1084,14 +1097,14 @@ function Mt({
|
|
|
1084
1097
|
e.year,
|
|
1085
1098
|
g
|
|
1086
1099
|
]);
|
|
1087
|
-
const [ze, Ee] =
|
|
1100
|
+
const [ze, Ee] = A(!1);
|
|
1088
1101
|
return B(() => {
|
|
1089
|
-
if (
|
|
1102
|
+
if (O)
|
|
1090
1103
|
return ze ? document.body.style.overflow = "hidden" : document.body.style.overflow = "", () => {
|
|
1091
1104
|
document.body.style.overflow = "";
|
|
1092
1105
|
};
|
|
1093
|
-
}, [ze,
|
|
1094
|
-
|
|
1106
|
+
}, [ze, O]), /* @__PURE__ */ E($e, { children: [
|
|
1107
|
+
O && /* @__PURE__ */ a(
|
|
1095
1108
|
"button",
|
|
1096
1109
|
{
|
|
1097
1110
|
onClick: () => Ee(!0),
|
|
@@ -1100,10 +1113,10 @@ function Mt({
|
|
|
1100
1113
|
"vehicle-search-btn vs:md:hidden!",
|
|
1101
1114
|
V ? "vs:w-full! vs:flex! vs:shrink-0!" : "vs:w-auto! vs:inline-flex! vs:shrink!"
|
|
1102
1115
|
),
|
|
1103
|
-
children: /* @__PURE__ */ a("span", { children:
|
|
1116
|
+
children: /* @__PURE__ */ a("span", { children: l })
|
|
1104
1117
|
}
|
|
1105
1118
|
),
|
|
1106
|
-
|
|
1119
|
+
O && /* @__PURE__ */ a(
|
|
1107
1120
|
"div",
|
|
1108
1121
|
{
|
|
1109
1122
|
onClick: () => Ee(!1),
|
|
@@ -1113,18 +1126,18 @@ function Mt({
|
|
|
1113
1126
|
)
|
|
1114
1127
|
}
|
|
1115
1128
|
),
|
|
1116
|
-
/* @__PURE__ */
|
|
1129
|
+
/* @__PURE__ */ E(
|
|
1117
1130
|
"div",
|
|
1118
1131
|
{
|
|
1119
1132
|
className: ne(
|
|
1120
1133
|
"partbot-mmyvs-container",
|
|
1121
|
-
|
|
1134
|
+
O && ze && "active",
|
|
1122
1135
|
"w-full"
|
|
1123
1136
|
),
|
|
1124
1137
|
children: [
|
|
1125
|
-
|
|
1138
|
+
O && /* @__PURE__ */ E("div", { className: "vs:flex vs:justify-between vs:items-center vs:pb-4 vs:font-bold vs:text-white vs:md:hidden", children: [
|
|
1126
1139
|
/* @__PURE__ */ a("span", { children: "Select Vehicle" }),
|
|
1127
|
-
/* @__PURE__ */
|
|
1140
|
+
/* @__PURE__ */ E(
|
|
1128
1141
|
"button",
|
|
1129
1142
|
{
|
|
1130
1143
|
onClick: () => Ee(!1),
|
|
@@ -1146,17 +1159,17 @@ function Mt({
|
|
|
1146
1159
|
}
|
|
1147
1160
|
)
|
|
1148
1161
|
] }),
|
|
1149
|
-
/* @__PURE__ */
|
|
1162
|
+
/* @__PURE__ */ E(
|
|
1150
1163
|
"div",
|
|
1151
1164
|
{
|
|
1152
|
-
ref:
|
|
1165
|
+
ref: U,
|
|
1153
1166
|
className: ne(
|
|
1154
1167
|
"vs:grid vs:gap-3",
|
|
1155
|
-
I === "row" ? `${
|
|
1168
|
+
I === "row" ? `${ht()} vs:grid-cols-1 vs:md:grid-cols-3` : "vs:grid-cols-1 vs:md:max-w-[400px] vs:md:gap-5",
|
|
1156
1169
|
"vs:w-full vs:transition vs:lg:mx-auto"
|
|
1157
1170
|
),
|
|
1158
1171
|
children: [
|
|
1159
|
-
x ? /* @__PURE__ */
|
|
1172
|
+
x ? /* @__PURE__ */ E($e, { children: [
|
|
1160
1173
|
/* @__PURE__ */ a(
|
|
1161
1174
|
X,
|
|
1162
1175
|
{
|
|
@@ -1204,7 +1217,7 @@ function Mt({
|
|
|
1204
1217
|
shouldBeActive: !!e.make
|
|
1205
1218
|
}
|
|
1206
1219
|
)
|
|
1207
|
-
] }) : /* @__PURE__ */
|
|
1220
|
+
] }) : /* @__PURE__ */ E($e, { children: [
|
|
1208
1221
|
/* @__PURE__ */ a(
|
|
1209
1222
|
X,
|
|
1210
1223
|
{
|
|
@@ -1262,7 +1275,7 @@ function Mt({
|
|
|
1262
1275
|
{
|
|
1263
1276
|
label: "Body",
|
|
1264
1277
|
items: Le,
|
|
1265
|
-
refine:
|
|
1278
|
+
refine: st,
|
|
1266
1279
|
selected: e.body,
|
|
1267
1280
|
bgDark: H,
|
|
1268
1281
|
showLabel: _,
|
|
@@ -1279,7 +1292,7 @@ function Mt({
|
|
|
1279
1292
|
{
|
|
1280
1293
|
label: "Series",
|
|
1281
1294
|
items: Ie,
|
|
1282
|
-
refine:
|
|
1295
|
+
refine: lt,
|
|
1283
1296
|
selected: e.series,
|
|
1284
1297
|
bgDark: H,
|
|
1285
1298
|
showLabel: _,
|
|
@@ -1296,7 +1309,7 @@ function Mt({
|
|
|
1296
1309
|
{
|
|
1297
1310
|
label: "Variant",
|
|
1298
1311
|
items: Ve,
|
|
1299
|
-
refine:
|
|
1312
|
+
refine: ct,
|
|
1300
1313
|
selected: e.variant,
|
|
1301
1314
|
bgDark: H,
|
|
1302
1315
|
showLabel: _,
|
|
@@ -1312,13 +1325,13 @@ function Mt({
|
|
|
1312
1325
|
X,
|
|
1313
1326
|
{
|
|
1314
1327
|
label: "Engine Capacity",
|
|
1315
|
-
items:
|
|
1316
|
-
refine:
|
|
1328
|
+
items: Ue,
|
|
1329
|
+
refine: pt,
|
|
1317
1330
|
selected: e.engine_capacity,
|
|
1318
1331
|
bgDark: H,
|
|
1319
1332
|
showLabel: _,
|
|
1320
1333
|
isMobile: J,
|
|
1321
|
-
loading: !!(e.make && e.model && e.year) &&
|
|
1334
|
+
loading: !!(e.make && e.model && e.year) && Ue.length === 0,
|
|
1322
1335
|
shouldBeActive: !!(e.make && e.model && e.year)
|
|
1323
1336
|
},
|
|
1324
1337
|
"engine_capacity"
|
|
@@ -1330,7 +1343,7 @@ function Mt({
|
|
|
1330
1343
|
{
|
|
1331
1344
|
label: "Engine",
|
|
1332
1345
|
items: De,
|
|
1333
|
-
refine:
|
|
1346
|
+
refine: dt,
|
|
1334
1347
|
selected: e.engine,
|
|
1335
1348
|
bgDark: H,
|
|
1336
1349
|
showLabel: _,
|
|
@@ -1344,23 +1357,23 @@ function Mt({
|
|
|
1344
1357
|
}
|
|
1345
1358
|
return r;
|
|
1346
1359
|
}),
|
|
1347
|
-
C && /* @__PURE__ */ a("div", { className: "vs:flex vs:h-full vs:flex-col vs:justify-end vs:md:col-span-3 vs:lg:col-span-1", children: /* @__PURE__ */
|
|
1360
|
+
C && /* @__PURE__ */ a("div", { className: "vs:flex vs:h-full vs:flex-col vs:justify-end vs:md:col-span-3 vs:lg:col-span-1", children: /* @__PURE__ */ E(
|
|
1348
1361
|
"button",
|
|
1349
1362
|
{
|
|
1350
1363
|
className: "vehicle-search-btn",
|
|
1351
1364
|
onClick: () => {
|
|
1352
|
-
Me(!0),
|
|
1365
|
+
Me(!0), F && !q ? window.location.href = F + window.location.search : it();
|
|
1353
1366
|
},
|
|
1354
1367
|
children: [
|
|
1355
1368
|
/* @__PURE__ */ a("span", { children: y }),
|
|
1356
|
-
|
|
1369
|
+
Ge && /* @__PURE__ */ a(Pe, { className: "vs:w-[calc(var(--partbot-font-size)*0.9)]! vs:h-[calc(var(--partbot-font-size)*0.9)]! vs:animate-spin" })
|
|
1357
1370
|
]
|
|
1358
1371
|
}
|
|
1359
1372
|
) })
|
|
1360
1373
|
]
|
|
1361
1374
|
}
|
|
1362
1375
|
),
|
|
1363
|
-
|
|
1376
|
+
T && /* @__PURE__ */ a(
|
|
1364
1377
|
"div",
|
|
1365
1378
|
{
|
|
1366
1379
|
className: ne(
|
|
@@ -1368,7 +1381,7 @@ function Mt({
|
|
|
1368
1381
|
I === "row" ? "vs:md:items-end vs:md:justify-end" : "vs:md:justify-center",
|
|
1369
1382
|
"vs:mt-4 vs:md:mt-3 vs:md:pr-1.5"
|
|
1370
1383
|
),
|
|
1371
|
-
children: /* @__PURE__ */
|
|
1384
|
+
children: /* @__PURE__ */ E(
|
|
1372
1385
|
"a",
|
|
1373
1386
|
{
|
|
1374
1387
|
href: `https://use.partbot.io/?ref=${// append referrer to url, just the top level domain
|
|
@@ -1389,9 +1402,9 @@ function Mt({
|
|
|
1389
1402
|
)
|
|
1390
1403
|
] });
|
|
1391
1404
|
}
|
|
1392
|
-
let
|
|
1405
|
+
let Je = !1, me = !1;
|
|
1393
1406
|
function At(b) {
|
|
1394
|
-
var
|
|
1407
|
+
var O, re;
|
|
1395
1408
|
const v = b.shadowRoot;
|
|
1396
1409
|
if (!v) {
|
|
1397
1410
|
console.error("[ShadowDOMPatch] No shadow root found");
|
|
@@ -1425,12 +1438,12 @@ function At(b) {
|
|
|
1425
1438
|
}).observe(p, {
|
|
1426
1439
|
childList: !0,
|
|
1427
1440
|
subtree: !0
|
|
1428
|
-
}),
|
|
1441
|
+
}), Je)
|
|
1429
1442
|
return;
|
|
1430
|
-
const R = (
|
|
1443
|
+
const R = (O = Object.getOwnPropertyDescriptor(
|
|
1431
1444
|
Document.prototype,
|
|
1432
1445
|
"activeElement"
|
|
1433
|
-
)) == null ? void 0 :
|
|
1446
|
+
)) == null ? void 0 : O.get;
|
|
1434
1447
|
Object.defineProperty(Document.prototype, "activeElement", {
|
|
1435
1448
|
get: function() {
|
|
1436
1449
|
const u = R == null ? void 0 : R.call(this);
|
|
@@ -1447,7 +1460,7 @@ function At(b) {
|
|
|
1447
1460
|
return u === b ? this.composedPath()[0] : u;
|
|
1448
1461
|
}
|
|
1449
1462
|
});
|
|
1450
|
-
const
|
|
1463
|
+
const T = (u) => {
|
|
1451
1464
|
try {
|
|
1452
1465
|
return document.body && u === document.body.style;
|
|
1453
1466
|
} catch {
|
|
@@ -1455,7 +1468,7 @@ function At(b) {
|
|
|
1455
1468
|
}
|
|
1456
1469
|
}, _ = CSSStyleDeclaration.prototype.setProperty;
|
|
1457
1470
|
CSSStyleDeclaration.prototype.setProperty = function(u, y, C) {
|
|
1458
|
-
if (!(
|
|
1471
|
+
if (!(T(this) && u === "overflow" && y === "hidden" && me))
|
|
1459
1472
|
return _.call(this, u, y, C);
|
|
1460
1473
|
};
|
|
1461
1474
|
const V = Object.getOwnPropertyDescriptor(
|
|
@@ -1467,30 +1480,30 @@ function At(b) {
|
|
|
1467
1480
|
return V.get.call(this);
|
|
1468
1481
|
},
|
|
1469
1482
|
set: function(u) {
|
|
1470
|
-
if (!(
|
|
1483
|
+
if (!(T(this) && u === "hidden" && me))
|
|
1471
1484
|
return V.set.call(this, u);
|
|
1472
1485
|
}
|
|
1473
|
-
}),
|
|
1486
|
+
}), Je = !0;
|
|
1474
1487
|
}
|
|
1475
1488
|
const Et = "/css/vehicle-search.css", Yt = Et;
|
|
1476
1489
|
class jt extends HTMLElement {
|
|
1477
1490
|
connectedCallback() {
|
|
1478
1491
|
if (!document.getElementById("vehicle-search-inter-font")) {
|
|
1479
|
-
const
|
|
1480
|
-
|
|
1492
|
+
const j = document.createElement("link");
|
|
1493
|
+
j.id = "vehicle-search-inter-font", j.rel = "stylesheet", j.href = "https://fonts.googleapis.com/css2?family=Inter:wght@400;500;700&display=swap", document.head.appendChild(j);
|
|
1481
1494
|
}
|
|
1482
1495
|
let v = document.createElement("style");
|
|
1483
1496
|
v.textContent = zt;
|
|
1484
|
-
const p = document.createElement("div"),
|
|
1497
|
+
const p = document.createElement("div"), F = this.attachShadow({ mode: "open" }), I = (j, Q, w) => {
|
|
1485
1498
|
let W;
|
|
1486
1499
|
if (this.hasAttribute(Q)) {
|
|
1487
|
-
const
|
|
1488
|
-
if (/^#[0-9A-F]{6}$/i.test(
|
|
1489
|
-
const x = parseInt(
|
|
1500
|
+
const M = this.getAttribute(Q);
|
|
1501
|
+
if (/^#[0-9A-F]{6}$/i.test(M)) {
|
|
1502
|
+
const x = parseInt(M.slice(1, 3), 16), le = parseInt(M.slice(3, 5), 16), ve = parseInt(M.slice(5, 7), 16);
|
|
1490
1503
|
W = `${x} ${le} ${ve}`;
|
|
1491
1504
|
}
|
|
1492
1505
|
}
|
|
1493
|
-
return W = W || w, `:host { --${
|
|
1506
|
+
return W = W || w, `:host { --${j}: ${W}; } .partbot-mmyvs-container { --${j}: ${W}; }`;
|
|
1494
1507
|
};
|
|
1495
1508
|
let R = I(
|
|
1496
1509
|
"partbot-theme",
|
|
@@ -1500,7 +1513,7 @@ class jt extends HTMLElement {
|
|
|
1500
1513
|
"partbot-button-color",
|
|
1501
1514
|
"data-button-color",
|
|
1502
1515
|
"0 0 0"
|
|
1503
|
-
),
|
|
1516
|
+
), T = I(
|
|
1504
1517
|
"partbot-button-hover-color",
|
|
1505
1518
|
"data-button-hover-color",
|
|
1506
1519
|
"0 0 0"
|
|
@@ -1512,7 +1525,7 @@ class jt extends HTMLElement {
|
|
|
1512
1525
|
"partbot-button-hover-label-color",
|
|
1513
1526
|
"data-button-hover-label-color",
|
|
1514
1527
|
"255 255 255"
|
|
1515
|
-
),
|
|
1528
|
+
), O = I(
|
|
1516
1529
|
"partbot-mobile-background-color",
|
|
1517
1530
|
"data-mobile-background-color",
|
|
1518
1531
|
"0 0 0"
|
|
@@ -1523,29 +1536,29 @@ class jt extends HTMLElement {
|
|
|
1523
1536
|
let D = "229 231 235";
|
|
1524
1537
|
if (f)
|
|
1525
1538
|
if (/^#[0-9A-F]{6}$/i.test(f)) {
|
|
1526
|
-
const
|
|
1527
|
-
D = `${
|
|
1539
|
+
const j = parseInt(f.slice(1, 3), 16), Q = parseInt(f.slice(3, 5), 16), w = parseInt(f.slice(5, 7), 16);
|
|
1540
|
+
D = `${j} ${Q} ${w}`;
|
|
1528
1541
|
} else /^\d+\s+\d+\s+\d+$/.test(f) && (D = f);
|
|
1529
1542
|
let g = `:host { --partbot-input-border-color: ${D}; } .partbot-mmyvs-container { --partbot-input-border-color: ${D}; }`;
|
|
1530
|
-
const
|
|
1531
|
-
let
|
|
1532
|
-
v.textContent += R, v.textContent += P, v.textContent +=
|
|
1543
|
+
const l = this.getAttribute("data-input-border-width") || "1px";
|
|
1544
|
+
let U = `:host { --partbot-input-border-width: ${l}; } .partbot-mmyvs-container { --partbot-input-border-width: ${l}; }`;
|
|
1545
|
+
v.textContent += R, v.textContent += P, v.textContent += T, v.textContent += _, v.textContent += V, v.textContent += O, v.textContent += re, v.textContent += u, v.textContent += y, v.textContent += C, v.textContent += G, v.textContent += g, v.textContent += U, F.appendChild(v), F.appendChild(p);
|
|
1533
1546
|
const z = this.getAttribute("data-api-key");
|
|
1534
1547
|
if (!z) {
|
|
1535
1548
|
console.warn("Missing attributes: " + (z ? "" : "data-api-key "));
|
|
1536
1549
|
return;
|
|
1537
1550
|
}
|
|
1538
1551
|
const ie = this.attributes, S = {};
|
|
1539
|
-
for (let
|
|
1540
|
-
const { name: Q, value: w } = ie[
|
|
1552
|
+
for (let j = 0; j < ie.length; j++) {
|
|
1553
|
+
const { name: Q, value: w } = ie[j];
|
|
1541
1554
|
if (Q.startsWith("data-")) {
|
|
1542
|
-
const W = Q.slice(5).replace(/-([a-z])/g, (
|
|
1555
|
+
const W = Q.slice(5).replace(/-([a-z])/g, (M) => M[1].toUpperCase());
|
|
1543
1556
|
S[W] = w === "true" ? !0 : w === "false" ? !1 : w;
|
|
1544
1557
|
}
|
|
1545
1558
|
}
|
|
1546
1559
|
At(this);
|
|
1547
1560
|
const K = /* @__PURE__ */ a(Mt, { ...S });
|
|
1548
|
-
|
|
1561
|
+
ft.render(K, p);
|
|
1549
1562
|
}
|
|
1550
1563
|
}
|
|
1551
1564
|
customElements.define("vehicle-search", jt);
|