@vehiclehistory/property-lib 0.0.7 → 0.0.9

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.
Files changed (33) hide show
  1. package/dist/components/Loading/LoadingBar.d.ts +0 -1
  2. package/dist/property-lib.js +2339 -0
  3. package/package.json +1 -2
  4. package/dist/assets/LoadingBar.css +0 -1
  5. package/dist/components/Accordion/Accordion.js +0 -69
  6. package/dist/components/Alert/Alert.js +0 -66
  7. package/dist/components/Autocomplete/Autocomplete.js +0 -173
  8. package/dist/components/Badge/Badge.js +0 -25
  9. package/dist/components/Button/Button.js +0 -43
  10. package/dist/components/ButtonGroup/ButtonGroup.js +0 -6
  11. package/dist/components/Card/Card.js +0 -32
  12. package/dist/components/Checkbox/Checkbox.js +0 -44
  13. package/dist/components/Container/Container.js +0 -33
  14. package/dist/components/Dialog/Dialog.js +0 -88
  15. package/dist/components/Dialog/DialogOld.js +0 -109
  16. package/dist/components/Dots/Dots.js +0 -15
  17. package/dist/components/Icon/Icon.js +0 -32
  18. package/dist/components/Icon/icons.js +0 -475
  19. package/dist/components/Loading/LoadingBar.js +0 -48
  20. package/dist/components/Loading/Spinner.js +0 -18
  21. package/dist/components/Popover/Popover.js +0 -57
  22. package/dist/components/Progress/ProgressBar.js +0 -50
  23. package/dist/components/Radio/Radio.js +0 -46
  24. package/dist/components/Select/Select.js +0 -61
  25. package/dist/components/Skeleton/Skeleton.js +0 -20
  26. package/dist/components/Slider/Slider.js +0 -58
  27. package/dist/components/Stars/Stars.js +0 -23
  28. package/dist/components/Swiper/Swiper.js +0 -107
  29. package/dist/components/Text/TextArea.js +0 -53
  30. package/dist/components/Text/Textbox.js +0 -78
  31. package/dist/components/index.js +0 -50
  32. package/dist/main.js +0 -52
  33. package/dist/scripts/index.js +0 -764
@@ -1,764 +0,0 @@
1
- class u {
2
- static calcCrow(e, t, n, s) {
3
- const r = u.toRad(n - e), a = u.toRad(s - t);
4
- e = u.toRad(e), n = u.toRad(n);
5
- const o = Math.sin(r / 2) * Math.sin(r / 2) + Math.sin(a / 2) * Math.sin(a / 2) * Math.cos(e) * Math.cos(n);
6
- return 6371 * (2 * Math.atan2(Math.sqrt(o), Math.sqrt(1 - o)));
7
- }
8
- static cleanupAddress(e) {
9
- return e.split(" ").map((n) => n.split("-")[0]).join(" ").trim();
10
- }
11
- static clearBounds(e = "bounds") {
12
- localStorage.setItem(e, JSON.stringify([]));
13
- }
14
- static clickTrack(e = !0) {
15
- if (e !== !0)
16
- return;
17
- window.dataLayer = window.dataLayer || [];
18
- const t = document.querySelectorAll("[data-div-track]");
19
- typeof u == "function" && t.forEach((n) => {
20
- n.addEventListener("click", () => {
21
- u.clickTrackEvent(n.dataset.divTrack);
22
- });
23
- });
24
- }
25
- static clickTrackEvent(e) {
26
- window.dataLayer.push({
27
- event: "click_tracking",
28
- click_value: e
29
- });
30
- }
31
- /* TODO: Not sure if this or PRECS is more correct */
32
- static async createData(e, t = null, n = !0) {
33
- if (options.isBot || !t)
34
- return null;
35
- const { tolken: s = null, ip: i = null } = await u.getHeaders(), r = n === !1 ? "" : "&tolken=" + s + "&ip=" + i, a = e + r, o = typeof t == "string" ? t : JSON.stringify(t);
36
- try {
37
- const l = await fetch(a, {
38
- method: "POST",
39
- body: o === "null" ? null : o,
40
- headers: {
41
- website: u.getWebsiteHeaderName()
42
- }
43
- }), h = l.headers.get("content-type");
44
- if (h && h.indexOf("application/json") !== -1)
45
- return l.json();
46
- const p = await l.text();
47
- return p ? p.replace("__next", "") : null;
48
- } catch (l) {
49
- console.error("createData", l);
50
- }
51
- return null;
52
- }
53
- static dataLayer({ type: e = null, data: t = null }) {
54
- typeof dataLayer.push > "u" || typeof dataLayer.push > "u" || (e === "custom" && t && this.dlvCustom(t), e === "login" && t && this.dlvUserLogin(t), e === "userData" && t && this.dlvUserData(t));
55
- }
56
- static async deleteSearchValue(e = "recsSearchValue") {
57
- try {
58
- return await u.createData(`/api/cookie/remove?name=${e}`);
59
- } catch (t) {
60
- console.error("deleteSearchValue", t.message);
61
- }
62
- return null;
63
- }
64
- static detectMouseMovement(e, t = null) {
65
- const n = document.querySelector("body");
66
- let s = !1;
67
- n.addEventListener("mousemove", () => {
68
- s || (s = !0, e(t));
69
- }), n.addEventListener("touchmove", () => {
70
- s || (s = !0, e(t));
71
- });
72
- }
73
- static dlvCustom(e) {
74
- console.info("dlvCustom", JSON.stringify(e)), dataLayer.push(e);
75
- }
76
- static dlvUserLogin(e) {
77
- dataLayer.push({
78
- event: "login",
79
- userId: e == null ? void 0 : e.uuid
80
- });
81
- }
82
- static dlvUserData(e) {
83
- dataLayer.push({
84
- event: "userData",
85
- userId: e == null ? void 0 : e.uuid,
86
- uuid: e == null ? void 0 : e.uuid,
87
- email: e == null ? void 0 : e.email,
88
- name: e == null ? void 0 : e.name
89
- });
90
- }
91
- static documentLoaded(e, t = 0) {
92
- document.addEventListener("DOMContentLoaded", async function() {
93
- t ? setTimeout(() => e(), t) : e();
94
- });
95
- }
96
- static elementScrollTop() {
97
- setTimeout(() => {
98
- document.body.scrollTop = document.documentElement.scrollTop = 0;
99
- }, 100);
100
- }
101
- static eventListenerOnce(e, t, n) {
102
- e == null || e.addEventListener(t, n, {
103
- once: !0
104
- });
105
- }
106
- static async fetchData(e, t = !1, n = !0) {
107
- if (options.isBot)
108
- return null;
109
- const { tolken: s = null, ip: i = null } = await u.getHeaders(), a = e.replace("#", "").replace("%23", "") + "&tolken=" + s + "&ip=" + i;
110
- try {
111
- const o = await fetch(a, { method: "GET" });
112
- if (t === !0) {
113
- const h = await o.text();
114
- return h ? h.replace("__next", "") : null;
115
- }
116
- const l = o.headers.get("content-type");
117
- return l && l.indexOf("application/json") !== -1 ? o.json() : null;
118
- } catch (o) {
119
- console.error("fetchData", o, e);
120
- }
121
- return null;
122
- }
123
- static findAncestor(e, t) {
124
- let n = e.parentElement;
125
- return n.tagName.toLowerCase() === t || (n = e.parentElement.parentElement, n.tagName.toLowerCase() === t) || (n = e.parentElement.parentElement.parentElement, n.tagName.toLowerCase() === t) ? n : null;
126
- }
127
- static formatDate(e = null) {
128
- return e ? (e = new Date(e), [
129
- u.padTo2Digits(e.getMonth() + 1),
130
- u.padTo2Digits(e.getDate()),
131
- e.getFullYear()
132
- ].join("-")) : null;
133
- }
134
- static getBoundsEntries(e = "bounds") {
135
- const t = localStorage.getItem(e);
136
- return t ? JSON.parse(t) : [];
137
- }
138
- static getBounds(e, t = null, n = null) {
139
- if (!e)
140
- return console.error("no map", e), {
141
- swLat: 0,
142
- neLng: 0,
143
- neLat: 0,
144
- swLng: 0
145
- };
146
- const s = e.getBounds();
147
- let i = s.getSouth(), r = s.getEast(), a = s.getNorth(), o = s.getWest();
148
- return n && (i = i - n, r = r + n, a = a + n, o = o - n), t && (i = i.toFixed(t), r = r.toFixed(t), a = a.toFixed(t), o = o.toFixed(t)), {
149
- swLat: i,
150
- neLng: r,
151
- neLat: a,
152
- swLng: o
153
- };
154
- }
155
- static getFirstN(e, t = 5) {
156
- return e === null ? null : e.length === 0 ? [] : e.filter((n, s) => s < t);
157
- }
158
- static getFormUrl(e = null) {
159
- const { name: t = null, isOptOut: n = !1 } = e ?? {};
160
- if (!t || t === "address")
161
- return n === !0 ? "/opt-out/address" : "/";
162
- if (t === "background-check")
163
- return "/report/background-check";
164
- if (t === "background-check-search")
165
- return n === !0 ? "/opt-out/records" : "/report/background-check/search";
166
- if (t === "dmv-records")
167
- return "/report/dmv-records";
168
- if (t === "dmv-records-search")
169
- return n === !0 ? "/opt-out/records" : "/report/dmv-records/search";
170
- if (t === "phone")
171
- return "/report/phone";
172
- if (t === "phone-search")
173
- return n === !0 ? "/opt-out/records" : "/report/phone/search";
174
- if (t === "vin")
175
- return "/report/vin";
176
- if (t === "license" || t === "license-plate")
177
- return "/report/license-plate";
178
- }
179
- static async getHeaders(e = 300) {
180
- const {
181
- userAgent: t = null,
182
- userAgentData: n = null,
183
- platform: s = null
184
- } = navigator || {}, i = (n == null ? void 0 : n.platform) ?? s, r = {
185
- tolken: null,
186
- ip: null,
187
- userAgent: t,
188
- platform: i
189
- };
190
- if (options && options.isBot || typeof window.localStorage > "u")
191
- return r;
192
- const a = localStorage.getItem("headerTolken");
193
- if (a) {
194
- const o = JSON.parse(a), l = (/* @__PURE__ */ new Date()).getTime();
195
- return o.expire - l < 0 && localStorage.removeItem("headerTolken"), {
196
- tolken: o.tolken,
197
- ip: o.ip,
198
- userAgent: t,
199
- platform: i
200
- };
201
- }
202
- try {
203
- const l = await (await fetch("/api/headers")).json(), h = (l == null ? void 0 : l.token) ?? null, p = (l == null ? void 0 : l.ip) ?? null;
204
- return localStorage.setItem(
205
- "headerTolken",
206
- JSON.stringify({
207
- tolken: h,
208
- ip: p,
209
- expire: (/* @__PURE__ */ new Date()).getTime() + e * 1e3
210
- })
211
- ), { tolken: h, ip: p, userAgent: t, platform: i };
212
- } catch (o) {
213
- console.error("getHeaders", o);
214
- }
215
- return r;
216
- }
217
- static getLayerTitle(e) {
218
- return {
219
- hybrid: "https://{s}.google.com/vt/lyrs=s&x={x}&y={y}&z={z}",
220
- roadmap: "https://{s}.google.com/vt/lyrs=m&x={x}&y={y}&z={z}"
221
- }[e];
222
- }
223
- static async getLocationData(e) {
224
- const { swLat: t, neLng: n, neLat: s, swLng: i } = u.getBounds(e, 3, 0.05), r = "zip-location&swLat=" + t + "&neLng=" + n + "&neLat=" + s + "&swLng=" + i;
225
- return await u.fetchData("/api/client?query=" + r);
226
- }
227
- static getReportUrl(e, t = null) {
228
- var o, l, h;
229
- const n = ((o = e == null ? void 0 : e.state) == null ? void 0 : o.slug) ?? null, s = ((l = e == null ? void 0 : e.city) == null ? void 0 : l.slug) ?? null, i = ((h = e == null ? void 0 : e.name) == null ? void 0 : h.slug) ?? null, r = (e == null ? void 0 : e.zip) ?? null;
230
- t = t || ((e == null ? void 0 : e.id) ?? null);
231
- const a = [r, "-piq", t].filter((p) => p).join("");
232
- return "/" + [n, s, i].filter((p) => p).map((p) => u.toSlug(p)).join("/") + "/" + a;
233
- }
234
- static async getSearchValue(e = "recsSearchValue") {
235
- try {
236
- return await u.createData(`/api/cookie/fetch?name=${e}`);
237
- } catch (t) {
238
- console.error("getSearchValue", t.message);
239
- }
240
- return null;
241
- }
242
- static getSearchValueClient(e = "recsSearchValue") {
243
- const t = localStorage.getItem(e);
244
- return t ? JSON.parse(t) : null;
245
- }
246
- static getStates() {
247
- return [
248
- { name: "Alabama", id: "al", slug: "alabama", short: "AL" },
249
- { name: "Alaska", id: "ak", slug: "alaska", short: "AK" },
250
- { name: "Arizona", id: "az", slug: "arizona", short: "AZ" },
251
- { name: "Arkansas", id: "ar", slug: "arkansas", short: "AR" },
252
- { name: "California", id: "ca", slug: "california", short: "CA" },
253
- { name: "Colorado", id: "co", slug: "colorado", short: "CO" },
254
- {
255
- name: "Connecticut",
256
- id: "ct",
257
- slug: "connecticut",
258
- short: "CT"
259
- },
260
- { name: "Delaware", id: "de", slug: "delaware", short: "DE" },
261
- {
262
- name: "District Of Columbia",
263
- id: "dc",
264
- slug: "district-of-columbia",
265
- short: "DC"
266
- },
267
- { name: "Florida", id: "fl", slug: "florida", short: "FL" },
268
- { name: "Georgia", id: "ga", slug: "georgia", short: "GA" },
269
- { name: "Hawaii", id: "hi", slug: "hawaii", short: "HI" },
270
- { name: "Idaho", id: "id", slug: "idaho", short: "ID" },
271
- { name: "Illinois", id: "il", slug: "illinois", short: "IL" },
272
- {
273
- name: "Indiana",
274
- id: "in",
275
- slug: "indiana",
276
- short: "IN"
277
- },
278
- { name: "Iowa", id: "ia", slug: "iowa", short: "IA" },
279
- { name: "Kansas", id: "ks", slug: "kansas", short: "KS" },
280
- { name: "Kentucky", id: "ky", slug: "kentucky", short: "KY" },
281
- { name: "Louisiana", id: "la", slug: "louisiana", short: "LA" },
282
- { name: "Maine", id: "me", slug: "maine", short: "ME" },
283
- { name: "Maryland", id: "md", slug: "maryland", short: "MD" },
284
- {
285
- name: "Massachusetts",
286
- id: "ma",
287
- slug: "massachusetts",
288
- short: "MA"
289
- },
290
- { name: "Michigan", id: "mi", slug: "michigan", short: "MI" },
291
- { name: "Minnesota", id: "mn", slug: "minnesota", short: "MN" },
292
- { name: "Mississippi", id: "ms", slug: "mississippi", short: "MS" },
293
- { name: "Missouri", id: "mo", slug: "missouri", short: "MO" },
294
- { name: "Montana", id: "mt", slug: "montana", short: "MT" },
295
- { name: "Nebraska", id: "ne", slug: "nebraska", short: "NE" },
296
- {
297
- name: "Nevada",
298
- id: "nv",
299
- slug: "nevada",
300
- short: "NV"
301
- },
302
- { name: "New Hampshire", id: "nh", slug: "new-hampshire", short: "NH" },
303
- { name: "New Jersey", id: "nj", slug: "new-jersey", short: "NJ" },
304
- { name: "New Mexico", id: "nm", slug: "new-mexico", short: "NM" },
305
- { name: "New York", id: "ny", slug: "new-york", short: "NY" },
306
- { name: "North Carolina", id: "nc", slug: "north-carolina", short: "NC" },
307
- { name: "North Dakota", id: "nd", slug: "north-dakota", short: "ND" },
308
- {
309
- name: "Ohio",
310
- id: "oh",
311
- slug: "ohio",
312
- short: "OH"
313
- },
314
- { name: "Oklahoma", id: "ok", slug: "oklahoma", short: "OK" },
315
- { name: "Oregon", id: "or", slug: "oregon", short: "OR" },
316
- { name: "Pennsylvania", id: "pa", slug: "pennsylvania", short: "PA" },
317
- { name: "Rhode Island", id: "ri", slug: "rhode-island", short: "RI" },
318
- { name: "South Carolina", id: "sc", slug: "south-carolina", short: "SC" },
319
- { name: "South Dakota", id: "sd", slug: "south-dakota", short: "SD" },
320
- {
321
- name: "Tennessee",
322
- id: "tn",
323
- slug: "tennessee",
324
- short: "TN"
325
- },
326
- { name: "Texas", id: "tx", slug: "texas", short: "TX" },
327
- { name: "Utah", id: "ut", slug: "utah", short: "UT" },
328
- { name: "Vermont", id: "vt", slug: "vermont", short: "VT" },
329
- { name: "Virginia", id: "va", slug: "virginia", short: "VA" },
330
- { name: "Washington", id: "wa", slug: "washington", short: "WA" },
331
- { name: "West Virginia", id: "wv", slug: "west-virginia", short: "WV" },
332
- {
333
- name: "Wisconsin",
334
- id: "wi",
335
- slug: "wisconsin",
336
- short: "WI"
337
- },
338
- { name: "Wyoming", id: "wy", slug: "wyoming", short: "WY" }
339
- ];
340
- }
341
- static getTrackingData(e) {
342
- const [t, ...n] = e.split("|"), s = n.join("|").trim(), i = [
343
- "[pageType::" + t.trim() + "]",
344
- "[name::" + s + "]"
345
- ].join(" ");
346
- return {
347
- value: i,
348
- dataLayer: {
349
- event: "clickTrack",
350
- value: i
351
- }
352
- };
353
- }
354
- static async getUser() {
355
- if (typeof window < "u") {
356
- const { user: e = null } = (window == null ? void 0 : window.options) ?? {};
357
- if (e)
358
- return e;
359
- }
360
- try {
361
- return await u.createData("/api/cookie/fetch?name=odrUser");
362
- } catch (e) {
363
- console.error("getUser", e.message);
364
- }
365
- return null;
366
- }
367
- static async getUserHistory(e = null) {
368
- const { uuid: t = null } = e ?? {};
369
- if (!t)
370
- return { data: null };
371
- const n = JSON.stringify({
372
- limit: 1,
373
- where: {
374
- uuid: t
375
- }
376
- });
377
- return await u.makeSearchFetchCall(
378
- `/api/client?query=user-get-history&filter=${n}`
379
- );
380
- }
381
- static getWebsiteHeaderName() {
382
- const e = "onlinedatareports.com", t = "propertyrecs.com", n = typeof window < "u" ? window.location.host : e;
383
- return n && n.includes(t) ? t : e;
384
- }
385
- static getGridBounds({ map: e, tileSize: t, coords: n }) {
386
- const s = n.scaleBy(t), i = s.add(t);
387
- return {
388
- nw: e.unproject(s, n.z),
389
- se: e.unproject(i, n.z)
390
- };
391
- }
392
- static gridTest(e, t, n = 1500) {
393
- const s = this;
394
- L.GridLayer.GridDebug = L.GridLayer.extend({
395
- createTile: function(i, r) {
396
- const a = document.createElement("div");
397
- return setTimeout(() => {
398
- r(null, a);
399
- const { se: o, nw: l } = s.getGridBounds({
400
- map: e,
401
- tileSize: this.getTileSize(),
402
- coords: i
403
- });
404
- t({
405
- swLat: o.lat,
406
- neLng: o.lng,
407
- neLat: l.lat,
408
- swLng: l.lng,
409
- coords: i,
410
- key: i.z + "-" + i.x + "-" + i.y
411
- });
412
- }, n), a;
413
- }
414
- }), L.gridLayer.gridDebug = function(i) {
415
- return new L.GridLayer.GridDebug(i);
416
- }, e.addLayer(L.gridLayer.gridDebug());
417
- }
418
- /**
419
- * Handle Native Dialogs
420
- * @type {function} handleDialog
421
- * @param {string|null} target - Selector that open the dialog
422
- * @param {string} id - Unique dialog id
423
- * @param {function|null} onOpen - Callback function called when dialog is opened
424
- * @param {function|null} onClose - Callback function called when dialog is closed
425
- * @param {boolean} disableOutsideClick - Disable dialog closing when clicking outside the dialog
426
- * @returns {{activators: NodeListOf<Element>, handleOpen: {function}, handleClose: {function}, ref: HTMLDialogElement}}
427
- */
428
- static handleDialog({
429
- target: e = null,
430
- id: t = "",
431
- onOpen: n = null,
432
- onClose: s = null,
433
- disableOutsideClick: i = !1
434
- }) {
435
- const r = e ? document.querySelectorAll(e) : [], a = document.getElementById(t + "-dialog"), o = document.querySelectorAll("[data-dialog-close]"), l = ["closing", "closed", "opening", "opened", "removed"].reduce(
436
- (c, d) => ({
437
- ...c,
438
- [d]: new Event(d)
439
- }),
440
- {}
441
- ), h = new MutationObserver((c, d) => {
442
- c.forEach(async (k) => {
443
- if (k.attributeName === "open") {
444
- const m = k.target;
445
- if (!(m == null ? void 0 : m.hasAttribute("open"))) return;
446
- m == null || m.removeAttribute("inert"), m == null || m.dispatchEvent(l.opening), m && await y(m), m == null || m.dispatchEvent(l.opened);
447
- }
448
- });
449
- }), p = new MutationObserver((c, d) => {
450
- c.forEach((k) => {
451
- k.removedNodes.forEach((m) => {
452
- m.nodeName === "DIALOG" && (m.removeEventListener("click", w), m.removeEventListener("close", f), m.dispatchEvent(l.removed), p == null || p.disconnect(), h == null || h.disconnect());
453
- });
454
- });
455
- });
456
- a && (h.observe(a, {
457
- attributes: !0
458
- }), p.observe(document.body, {
459
- attributes: !1,
460
- subtree: !1,
461
- childList: !0
462
- }));
463
- const g = () => {
464
- a == null || a.showModal();
465
- }, f = async ({ target: c }) => {
466
- c == null || c.classList.add("closing"), c == null || c.setAttribute("inert", ""), c == null || c.dispatchEvent(l.closing), c && await y(c), c == null || c.classList.remove("closing"), c == null || c.dispatchEvent(l.closed);
467
- }, w = async ({ target: c }) => {
468
- (c == null ? void 0 : c.nodeName) === "DIALOG" && (a == null || a.close("outside"));
469
- }, y = (c) => Promise.allSettled(
470
- c == null ? void 0 : c.getAnimations().map((d) => d == null ? void 0 : d.finished)
471
- );
472
- return !i && (a == null || a.addEventListener("click", w)), a == null || a.addEventListener("close", f), r == null || r.forEach((c) => {
473
- c.addEventListener("click", (d) => {
474
- g(), n && n(d, a);
475
- });
476
- }), o == null || o.forEach((c) => {
477
- c.addEventListener("click", async (d) => {
478
- a == null || a.close("close"), s && s(d, a);
479
- });
480
- }), {
481
- activators: r,
482
- ref: a,
483
- handleOpen: g,
484
- handleClose: f
485
- };
486
- }
487
- static hasBoundsEntry(e, t = "bounds") {
488
- return u.getBoundsEntries(t).includes(e);
489
- }
490
- static initObserver(e, t, n = null) {
491
- if (!e)
492
- return;
493
- const s = (n == null ? void 0 : n.useBounding) ?? !1;
494
- new IntersectionObserver(async (r, a) => {
495
- s ? (r[0].isIntersecting || r[0].boundingClientRect.y < 0) && t({ obs: a, entry: r[0], entries: r }) : r[0].isIntersecting && t({ obs: a, entry: r[0], entries: r });
496
- }, n).observe(e);
497
- }
498
- static injectLink({ href: e, id: t }) {
499
- const n = document.createElement("link");
500
- n.href = e, n.type = "text/css", n.rel = "stylesheet", t && (n.id = t), document.getElementsByTagName("head")[0].appendChild(n);
501
- }
502
- static injectScript({ src: e, id: t = null, async: n = !0, module: s = !1 }) {
503
- return new Promise(function(i, r) {
504
- let a = document.getElementById(t);
505
- if (t && a && a.dataset.loaded === "true")
506
- return i({ alreadyLoaded: !0, id: t });
507
- a || (a = document.createElement("script"), a.src = e, a.dataset.loaded = "false", t && (a.id = t), a.type = s ? "module" : "text/javascript", a.async = n, document.body.appendChild(a), a.onload = () => (a.dataset.loaded = "true", i({ alreadyLoaded: !1, id: t })), a.onerror = () => r(!1));
508
- });
509
- }
510
- static isMobile({ selector: e = null, width: t = 640 } = {}) {
511
- var s;
512
- const n = document.querySelector(e);
513
- return ((s = n == null ? void 0 : n.getBoundingClientRect()) == null ? void 0 : s.width) ?? 0 < t;
514
- }
515
- static isMobileAndTablet() {
516
- return window.mobileAndTabletCheck = function() {
517
- let e = !1;
518
- return function(t) {
519
- (/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(
520
- t
521
- ) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(
522
- t.substr(0, 4)
523
- )) && (e = !0);
524
- }(navigator.userAgent || navigator.vendor || window.opera), e;
525
- }, window.mobileAndTabletCheck();
526
- }
527
- static isNameCompany(e = null) {
528
- if (!e)
529
- return !1;
530
- const t = e.trim().toLowerCase();
531
- return t.includes("unknown") || t.includes("institute") || t.includes("bldg") || t.includes("llc") || t.includes("l l c") || t.includes(" inc") || t.includes(" co") || t.includes("univ") || t.includes("unvi") || t.includes(" fund") || t.includes(" union") || t.includes(" assoc") || t.includes(" corp") || t.includes("service") || t.includes("members") || t.includes("properties") || t.includes("management") || t.includes("investment") || t.includes("enterprise") || t.includes(" group") || t.includes(" group") || t.includes(" rent") || t.includes(" home") || t.includes(" cu") || t.includes(" inc") || t.includes("laborator") || t.includes("pharma") || t.includes("holding") || t.includes("worship") || t.includes("bank") || t.includes("agent") || t.includes("title") || t.includes("city ") || t.includes("technolo") || t.includes("estate") || t.includes("capital") || t.includes(" of ") || t.includes("trust");
532
- }
533
- static kFormat(e, t = 0) {
534
- if (!e)
535
- return null;
536
- const n = Math.abs(e), s = Math.sign(e);
537
- return n > 999999 ? s * (n / 1e6).toFixed(1) + "m" : n > 999 ? s * (n / 1e3).toFixed(t) + "k" : s * n;
538
- }
539
- static async logRequest(e = null, t = null, n = null, s = null, i = null) {
540
- const r = {
541
- name: e,
542
- uuid: t,
543
- ip: n,
544
- url: s,
545
- data: i
546
- };
547
- return await u.createData("/api/client?query=log/save&method=POST", r), null;
548
- }
549
- static loadAds() {
550
- window.dataLayer = window.dataLayer || [];
551
- const e = document.querySelectorAll(".adsbygoogle");
552
- window.ezstandalone = window.ezstandalone || {}, ezstandalone.cmd = ezstandalone.cmd || [];
553
- const t = [];
554
- for (let n = 0; n < e.length; n++)
555
- t.push(parseInt(e[n].dataset.adSlot));
556
- console.info("loadAds", t), t.length && ezstandalone.cmd.push(function() {
557
- ezstandalone.define(...t), ezstandalone.enable(), ezstandalone.display();
558
- });
559
- }
560
- static async loadCustomScript({ name: e = null, id: t = "", module: n = !1 } = {}) {
561
- if (e) {
562
- const s = "/scripts/" + e + ".js?v=100.0.5";
563
- try {
564
- return await u.injectScript({
565
- src: s,
566
- id: t || e,
567
- async: !1,
568
- module: n
569
- });
570
- } catch (i) {
571
- console.error("loadCustomScript", i);
572
- }
573
- }
574
- return null;
575
- }
576
- static async loadGoogleMapApi() {
577
- if (window.options.googleMapsLoaded === !0)
578
- return;
579
- const e = "https://maps.googleapis.com/maps/api/js", t = window.options.googleApiKey, n = e + "?key=" + t + "&libraries=marker&v=beta&callback=mapCb";
580
- await u.injectScript({ src: n, id: "googleapis", async: !1 });
581
- }
582
- static async loadLeafletApi() {
583
- const e = "https://unpkg.com/leaflet@1.9.3/dist", t = e + "/leaflet.js", n = e + "/leaflet.css", s = "//unpkg.com/leaflet-gesture-handling", i = "//unpkg.com/leaflet-gesture-handling/dist/leaflet-gesture-handling.min.css";
584
- await u.injectLink({ href: n, id: "leafletCss" }), await u.injectLink({ href: i, id: "gestureCss" }), await u.injectScript({ src: t, id: "leafletJs", async: !1 }), await u.injectScript({
585
- src: s,
586
- id: "gestureJs",
587
- async: !1
588
- });
589
- }
590
- static loadLiveChat() {
591
- const e = document.querySelectorAll(".live-chat"), t = document.getElementById("live-chat-btn");
592
- for (const n of e)
593
- n.addEventListener("click", () => {
594
- typeof LiveChatWidget < "u" && (LiveChatWidget.call("maximize"), t == null || t.remove());
595
- });
596
- }
597
- static async loadSwiper() {
598
- const e = "https://cdn.jsdelivr.net/npm", t = `${e}/swiper@9/swiper-bundle.min.js`, n = `${e}/swiper@9/swiper-bundle.min.css`;
599
- await u.injectLink({ href: n, id: "swiperCss" }), await u.injectScript({ src: t, id: "swiperJs", async: !1 });
600
- }
601
- static async makeSearchFetchCall(e) {
602
- try {
603
- return (await fetch(e, {
604
- method: "GET",
605
- headers: { "Content-Type": "application/json" }
606
- })).json();
607
- } catch (t) {
608
- console.error("performSearch", t, { url: e });
609
- }
610
- return [];
611
- }
612
- static money(e, t = "", n = 0) {
613
- return e === null ? t : Intl ? new Intl.NumberFormat("en-US", {
614
- style: "currency",
615
- currency: "USD",
616
- minimumFractionDigits: n,
617
- maximumFractionDigits: n
618
- }).format(e) : e;
619
- }
620
- static number(e, t = "", n = 0) {
621
- return e === null ? t : Intl ? new Intl.NumberFormat("en-US", {
622
- minimumFractionDigits: n,
623
- maximumFractionDigits: n
624
- }).format(e) : e;
625
- }
626
- static objToQp(e) {
627
- const {
628
- name: t = null,
629
- first: n = null,
630
- middle: s = null,
631
- last: i = null,
632
- min: r = null,
633
- max: a = null,
634
- city: o = null,
635
- state: l = null,
636
- vin: h = null,
637
- license: p = null,
638
- token: g = null,
639
- phone: f = null
640
- } = e || {}, w = t && t !== "", y = r && r !== "" && r !== "18", c = a && a !== "" && r !== "99";
641
- let d = [];
642
- return t && t !== "" && d.push("name=" + t), w || (n && n !== "" && d.push("first=" + n), s && s !== "" && d.push("middle=" + s), i && i !== "" && d.push("last=" + i)), y && c ? parseInt(r) > parseInt(a) ? (d.push("min=" + a), d.push("max=" + r)) : (d.push("min=" + r), d.push("max=" + a)) : (y && d.push("min=" + r), c && d.push("max=" + a)), f && f !== "" && d.push("phone=" + f), o && o !== "" && d.push("city=" + o), p && p !== "" && d.push("license=" + p), h && h !== "" && d.push("vin=" + h), l && l !== "" && d.push("state=" + l), g && g !== "" && d.push("token=" + g), d.join("&");
643
- }
644
- static padTo2Digits(e) {
645
- return e.toString().padStart(2, "0");
646
- }
647
- static async performSearch(e = null, t = {}) {
648
- if (!e)
649
- return [];
650
- if (1 > e.trim().length)
651
- return [];
652
- const {
653
- addressesOnly: n = !1,
654
- useCitySearch: s = !1,
655
- useCityStateSearch: i = !1,
656
- useSearch: r = !1,
657
- useLocation: a = !0,
658
- state: o = ""
659
- } = t ?? {}, { tolken: l = null, ip: h = null } = await u.getHeaders(), g = [
660
- "query=" + encodeURIComponent(this.cleanupAddress(e)),
661
- "addressesOnly=" + n,
662
- "useSearch=" + r,
663
- "useCitySearch=" + s,
664
- "useCityStateSearch=" + i,
665
- "useLocation=" + a
666
- ];
667
- o && o !== "" && !i && g.push("state=" + o), l && l !== "" && g.push("tolken=" + l), h && h !== "" && g.push("ip=" + h);
668
- const f = g.join("&"), y = (s || i ? "/api/autocomplete-city" : "/api/autocomplete") + "?" + f;
669
- return await u.makeSearchFetchCall(y);
670
- }
671
- static removeElements(e) {
672
- document.querySelectorAll(e).forEach((t) => t == null ? void 0 : t.remove());
673
- }
674
- static removeNullFromObject(e) {
675
- return Object.keys(e).filter((t) => e[t]).reduce((t, n) => (t[n] = e[n], t), {});
676
- }
677
- static s(e) {
678
- return Math.round(e) > 1 ? "s" : "";
679
- }
680
- static scrollWheelZoom(e) {
681
- e.scrollWheelZoom.disable(), e.on("focus", () => {
682
- e.scrollWheelZoom.enable();
683
- }), e.on("blur", () => {
684
- e.scrollWheelZoom.disable();
685
- });
686
- }
687
- static searchInStates(e) {
688
- const t = u.getStates(), n = e.toLowerCase();
689
- let s = t.find((i) => i.short.toLowerCase() === n) ?? null;
690
- return s || (s = t.find((i) => i.name.toLowerCase() === n) ?? null), s;
691
- }
692
- static sendWoopraEvent(e, t) {
693
- typeof woopra == "object" && woopra.track(e, t);
694
- }
695
- static setBoundsEntries(e, t = "bounds") {
696
- const n = u.getBoundsEntries(t);
697
- n.push(e), localStorage.setItem(t, JSON.stringify(n));
698
- }
699
- static async setCityState(e = null) {
700
- let { cityState: t = null } = e ?? {};
701
- if (!t)
702
- return e;
703
- t = t.toLowerCase().replace(" usa", "").replace("city or state", "").replace(" state", "").trim();
704
- let [n = null, s = null] = t.split(",").map((i) => i.trim());
705
- if (u.getStates(), n && !s) {
706
- const i = this.searchInStates(n);
707
- i && (n = null, s = i.short);
708
- }
709
- if (!s && n) {
710
- const i = this.searchInStates(n);
711
- i && (s = i.short);
712
- }
713
- if (n && !s) {
714
- const i = n.split(" "), r = i[i.length - 1];
715
- if (r.length) {
716
- const a = this.searchInStates(r);
717
- a && (s = a.short, n = i.slice(0, -1).join(" "));
718
- }
719
- }
720
- return n && s && n.toLowerCase() === s.toLowerCase() && (n = null), e.city = n, e.state = s ? s.toUpperCase() : null, e;
721
- }
722
- static async setSearchValueClient(e, t = "recsSearchValue") {
723
- localStorage.setItem(t, JSON.stringify(e)), await u.createData(`/api/cookie/create?name=${t}`, e);
724
- }
725
- static stickyHeader(e = ".nav") {
726
- const t = document.querySelector(e);
727
- if (!t)
728
- return;
729
- new IntersectionObserver(
730
- ([s]) => {
731
- s && (s.intersectionRatio < 1 ? t.classList.add("intersecting") : t.classList.remove("intersecting"));
732
- },
733
- { threshold: 1 }
734
- ).observe(t);
735
- }
736
- // Converts numeric degrees to radians
737
- static toRad(e) {
738
- return e * Math.PI / 180;
739
- }
740
- static toSlug(e) {
741
- return e.toString().trim().toLowerCase().split(":").join("-").split("'").join("").replace("‘", "");
742
- }
743
- static ucFirst(e = null) {
744
- if (!e)
745
- return null;
746
- const t = e.toLowerCase();
747
- return t.charAt(0).toUpperCase() + t.slice(1);
748
- }
749
- static useLayerTitle(e, t) {
750
- const n = u.getLayerTitle(e);
751
- L.tileLayer(n, {
752
- maxNativeZoom: 19,
753
- maxZoom: 25,
754
- subdomains: ["mt0", "mt1", "mt2", "mt3"],
755
- attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a>'
756
- }).addTo(t);
757
- }
758
- static ucWords(e) {
759
- return e ? e.toString().split(" ").map((t) => u.ucFirst(t)).join(" ") : null;
760
- }
761
- }
762
- export {
763
- u as Common
764
- };