@depict-ai/ui 4.10.32 → 4.10.34
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/ES10/index.cjs +1201 -20
- package/ES10/index.d.ts +112 -13
- package/ES10/index.js +1201 -22
- package/latest/index.cjs +1090 -18
- package/latest/index.d.ts +112 -13
- package/latest/index.js +1090 -20
- package/locales/index.d.ts +1 -2
- package/package.json +5 -4
- package/server/ES10/index.cjs +1201 -20
- package/server/ES10/index.d.ts +112 -13
- package/server/ES10/index.js +1201 -22
- package/server/latest/index.cjs +1090 -18
- package/server/latest/index.d.ts +112 -13
- package/server/latest/index.js +1090 -20
package/ES10/index.cjs
CHANGED
|
@@ -4,8 +4,8 @@ var $52FdA$solidjs = require("solid-js");
|
|
|
4
4
|
var $52FdA$depictaiutilisharedlatest = require("@depict-ai/utilishared/ES10");
|
|
5
5
|
var $52FdA$solidjsstore = require("solid-js/store");
|
|
6
6
|
var $52FdA$babelruntimehelpersdefineProperty = require("@babel/runtime/helpers/defineProperty");
|
|
7
|
-
var $52FdA$babelruntimehelpersclassPrivateFieldSet = require("@babel/runtime/helpers/classPrivateFieldSet");
|
|
8
7
|
var $52FdA$babelruntimehelpersclassPrivateFieldGet = require("@babel/runtime/helpers/classPrivateFieldGet");
|
|
8
|
+
var $52FdA$babelruntimehelpersclassPrivateFieldSet = require("@babel/runtime/helpers/classPrivateFieldSet");
|
|
9
9
|
require("../multi_import_deduplicator.cjs").register_es_version("ui", "ES10");
|
|
10
10
|
function $parcel$export(e, n, v, s) {
|
|
11
11
|
Object.defineProperty(e, n, {
|
|
@@ -97,6 +97,8 @@ $parcel$export(module.exports, "styles_to_valid_css_string", () => $498967813349
|
|
|
97
97
|
$parcel$export(module.exports, "disable_scrolling", () => $8c2e68c6d458169b$export$fe334901e8bebd57);
|
|
98
98
|
$parcel$export(module.exports, "open_search_with_shift_slash", () => $f8c268e298d2d5fe$export$d0596b5cae35ad4);
|
|
99
99
|
$parcel$export(module.exports, "DepictAPI", () => $e270e9f953fcbc58$export$e015ed2f2950f2e3);
|
|
100
|
+
$parcel$export(module.exports, "NativeDepictAPI", () => $5f20a6104f835562$export$721afe49a594bed);
|
|
101
|
+
$parcel$export(module.exports, "create_depict_api", () => $5f20a6104f835562$export$6d972e6af9de09f0);
|
|
100
102
|
$parcel$export(module.exports, "media_query_to_accessor", () => $3e17e871e9d0911d$export$d9f36cf74e24d595);
|
|
101
103
|
$parcel$export(module.exports, "setup_fast_leave", () => $27a1a8144c190980$export$689e204eadb33baf);
|
|
102
104
|
$parcel$export(module.exports, "show_toast", () => $5909f8d84b7b4c30$export$5196e4c01fa56fcb);
|
|
@@ -115,7 +117,7 @@ $parcel$export(module.exports, "BreadCrumbs", () => $335c02c1241a9ca8$export$5b7
|
|
|
115
117
|
$parcel$export(module.exports, "QuickLinks", () => $335c02c1241a9ca8$export$de035477d6fef996);
|
|
116
118
|
$parcel$export(module.exports, "CategoryPage", () => $c10e33c4681f8c9b$export$e2bf8ce7779e827e);
|
|
117
119
|
/*! Depict.ai search and product listing SDK */
|
|
118
|
-
const $aa1938dec50d6c12$export$83d89fbfd8236492 = "4.10.
|
|
120
|
+
const $aa1938dec50d6c12$export$83d89fbfd8236492 = "4.10.34";
|
|
119
121
|
function $3e17e871e9d0911d$export$d9f36cf74e24d595(media_query) {
|
|
120
122
|
const signal = $52FdA$solidjs.createSignal(false);
|
|
121
123
|
$52FdA$solidjs.onCleanup($52FdA$depictaiutilishared.javascript_media_query(media_query, _ref => {
|
|
@@ -14059,12 +14061,845 @@ function $39cca429fb71d8ff$export$f091cbac892643a4(obj) {
|
|
|
14059
14061
|
return Object.fromEntries(mapped_stuff); // FUCK TYPESCRIPT, WHY CAN'T YOU DO THIS CORRECTLY???
|
|
14060
14062
|
}
|
|
14061
14063
|
|
|
14064
|
+
/** One try and at most two retries: a 503 burst from V4 shouldn't be multiplied by fetch_retry's default of 10. */
|
|
14065
|
+
const $8ad8c4b4b26ba277$var$NATIVE_MAX_TRIES = 3;
|
|
14066
|
+
function $8ad8c4b4b26ba277$export$b6dad15503f66988(merchant, path) {
|
|
14067
|
+
return "".concat((0, $52FdA$depictaiutilishared.base_url), "/v4/").concat(encodeURIComponent(merchant)).concat(path);
|
|
14068
|
+
}
|
|
14069
|
+
async function $8ad8c4b4b26ba277$export$88d793e3827f3436(url) {
|
|
14070
|
+
return (await $8ad8c4b4b26ba277$export$f035610fd74c541a(url)).body_;
|
|
14071
|
+
}
|
|
14072
|
+
async function $8ad8c4b4b26ba277$export$f035610fd74c541a(url) {
|
|
14073
|
+
var _error, _error2, _error3;
|
|
14074
|
+
const response = await $52FdA$depictaiutilishared.fetch_retry(url, {
|
|
14075
|
+
method: "GET"
|
|
14076
|
+
}, $8ad8c4b4b26ba277$var$NATIVE_MAX_TRIES);
|
|
14077
|
+
if (!response) {
|
|
14078
|
+
$52FdA$depictaiutilishared.dwarn("[NativeDepictAPI] no response from", url);
|
|
14079
|
+
return {};
|
|
14080
|
+
}
|
|
14081
|
+
if (response.status === 200)
|
|
14082
|
+
// A 200 that isn't JSON (a proxy's HTML page, a cut-off body) is a failed read like any other, so callers fall
|
|
14083
|
+
// back instead of rejecting: get_recommendation_types then forgets the read rather than keeping it in flight.
|
|
14084
|
+
try {
|
|
14085
|
+
return {
|
|
14086
|
+
body_: await response.json()
|
|
14087
|
+
};
|
|
14088
|
+
} catch (e) {
|
|
14089
|
+
$52FdA$depictaiutilishared.dwarn("[NativeDepictAPI] 200 without a JSON body from", url, e);
|
|
14090
|
+
return {};
|
|
14091
|
+
}
|
|
14092
|
+
let error;
|
|
14093
|
+
try {
|
|
14094
|
+
error = (await response.json()).error;
|
|
14095
|
+
} catch {
|
|
14096
|
+
// not V4's error body
|
|
14097
|
+
}
|
|
14098
|
+
$52FdA$depictaiutilishared.dwarn("[NativeDepictAPI]", response.status, (_error = error) === null || _error === void 0 ? void 0 : _error.code, (_error2 = error) === null || _error2 === void 0 ? void 0 : _error2.message, (_error3 = error) === null || _error3 === void 0 ? void 0 : _error3.request_id, url);
|
|
14099
|
+
if (response.status >= 500) {
|
|
14100
|
+
var _error$code, _error4, _error5, _error$request_id, _error6;
|
|
14101
|
+
$52FdA$depictaiutilishared.report([new Error("V4 ".concat(response.status, " ").concat((_error$code = (_error4 = error) === null || _error4 === void 0 ? void 0 : _error4.code) !== null && _error$code !== void 0 ? _error$code : "")), "Native V4 request failed"], "warning", {
|
|
14102
|
+
url: url,
|
|
14103
|
+
status: response.status,
|
|
14104
|
+
code: (_error5 = error) === null || _error5 === void 0 ? void 0 : _error5.code,
|
|
14105
|
+
request_id: (_error$request_id = (_error6 = error) === null || _error6 === void 0 ? void 0 : _error6.request_id) !== null && _error$request_id !== void 0 ? _error$request_id : response.headers.get("x-depict-request-id")
|
|
14106
|
+
});
|
|
14107
|
+
}
|
|
14108
|
+
return {
|
|
14109
|
+
error_: error
|
|
14110
|
+
};
|
|
14111
|
+
}
|
|
14112
|
+
const $294cf81de92da757$export$8e79752841e7cdb4 = 900000;
|
|
14113
|
+
const $294cf81de92da757$var$storage_key = merchant => "depict_v4_recommendation_types_".concat(merchant);
|
|
14114
|
+
/** One read per merchant and CONTEXT_TTL_MS in this page; a failed read is forgotten so the next caller tries again. */
|
|
14115
|
+
const $294cf81de92da757$var$in_flight = new Map();
|
|
14116
|
+
function $294cf81de92da757$var$from_storage(merchant, now) {
|
|
14117
|
+
try {
|
|
14118
|
+
var _localStorage$getItem;
|
|
14119
|
+
const stored = JSON.parse((_localStorage$getItem = localStorage.getItem($294cf81de92da757$var$storage_key(merchant))) !== null && _localStorage$getItem !== void 0 ? _localStorage$getItem : "null");
|
|
14120
|
+
if (!stored || !Array.isArray(stored.types) || !(now - stored.fetched_at < $294cf81de92da757$export$8e79752841e7cdb4)) return undefined;
|
|
14121
|
+
return $294cf81de92da757$var$to_map(stored.types);
|
|
14122
|
+
} catch {
|
|
14123
|
+
return undefined;
|
|
14124
|
+
}
|
|
14125
|
+
}
|
|
14126
|
+
function $294cf81de92da757$var$to_storage(merchant, types, now) {
|
|
14127
|
+
try {
|
|
14128
|
+
localStorage.setItem($294cf81de92da757$var$storage_key(merchant), JSON.stringify({
|
|
14129
|
+
fetched_at: now,
|
|
14130
|
+
types: types
|
|
14131
|
+
}));
|
|
14132
|
+
} catch {
|
|
14133
|
+
// localStorage unavailable or full: read /context again on the next page.
|
|
14134
|
+
}
|
|
14135
|
+
}
|
|
14136
|
+
const $294cf81de92da757$var$to_map = types => new Map(types.map(_ref => {
|
|
14137
|
+
let {
|
|
14138
|
+
type: type,
|
|
14139
|
+
inputs: inputs
|
|
14140
|
+
} = _ref;
|
|
14141
|
+
return [type, inputs];
|
|
14142
|
+
}));
|
|
14143
|
+
function $294cf81de92da757$export$869eb14d6f85ac51(merchant) {
|
|
14144
|
+
let now = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Date.now();
|
|
14145
|
+
const pending = $294cf81de92da757$var$in_flight.get(merchant);
|
|
14146
|
+
if (pending && now - pending.started_at < $294cf81de92da757$export$8e79752841e7cdb4) return pending.read;
|
|
14147
|
+
const stored = $294cf81de92da757$var$from_storage(merchant, now);
|
|
14148
|
+
if (stored) return Promise.resolve(stored);
|
|
14149
|
+
const read = $8ad8c4b4b26ba277$export$88d793e3827f3436($8ad8c4b4b26ba277$export$b6dad15503f66988(merchant, "/context")).then(context => {
|
|
14150
|
+
var _context$recommendati;
|
|
14151
|
+
if (!context) {
|
|
14152
|
+
var _in_flight$get;
|
|
14153
|
+
if (((_in_flight$get = $294cf81de92da757$var$in_flight.get(merchant)) === null || _in_flight$get === void 0 ? void 0 : _in_flight$get.read) === read) $294cf81de92da757$var$in_flight.delete(merchant);
|
|
14154
|
+
return undefined;
|
|
14155
|
+
}
|
|
14156
|
+
const types = (_context$recommendati = context.recommendation_types) !== null && _context$recommendati !== void 0 ? _context$recommendati : [];
|
|
14157
|
+
$294cf81de92da757$var$to_storage(merchant, types, now);
|
|
14158
|
+
return $294cf81de92da757$var$to_map(types);
|
|
14159
|
+
});
|
|
14160
|
+
$294cf81de92da757$var$in_flight.set(merchant, {
|
|
14161
|
+
started_at: now,
|
|
14162
|
+
read: read
|
|
14163
|
+
});
|
|
14164
|
+
return read;
|
|
14165
|
+
}
|
|
14166
|
+
function $294cf81de92da757$export$6cde5c31239dec47() {
|
|
14167
|
+
$294cf81de92da757$var$in_flight.clear();
|
|
14168
|
+
}
|
|
14169
|
+
|
|
14170
|
+
/**
|
|
14171
|
+
* The shopper's recently viewed products, kept in the browser for the native V4 API's history-based recommendations.
|
|
14172
|
+
*
|
|
14173
|
+
* v3 kept this history on the server, per session. V4 content requests carry no session, so a surface that reads
|
|
14174
|
+
* history gets it in the request (`recent_views`), and the SDK keeps the list. It holds product ids and view times
|
|
14175
|
+
* only (no session, user or page data), bounded in size and age, in localStorage per merchant; when localStorage
|
|
14176
|
+
* can't be used (private mode, blocked, full) it lives in memory for the page load.
|
|
14177
|
+
*
|
|
14178
|
+
* A view is recorded when a native product-anchored recommendation request resolves its anchor, as v3's facade records
|
|
14179
|
+
* a resolved anchor as a view; the product being viewed is in the list from the next request on.
|
|
14180
|
+
*/ /** recs-wasm reads the newest 20 views (V4 `recent_views` docs), so more would never be read. */
|
|
14181
|
+
const $3bfd3f1d3eb46898$export$3d684435158adda6 = 20;
|
|
14182
|
+
const $3bfd3f1d3eb46898$export$5eb0a366a50fa99e = 2592000000;
|
|
14183
|
+
/** V4's longest product id (`ProductRef`); a longer one is never a product it knows. */
|
|
14184
|
+
const $3bfd3f1d3eb46898$var$MAX_ID_LENGTH = 500;
|
|
14185
|
+
const $3bfd3f1d3eb46898$var$storage_key = merchant => "depict_v4_recent_views_".concat(merchant);
|
|
14186
|
+
/** The list per merchant as last written, which reads use when localStorage can't hold it. */
|
|
14187
|
+
const $3bfd3f1d3eb46898$var$in_memory = new Map();
|
|
14188
|
+
/** Merchants whose last write to localStorage failed, so localStorage holds an older list than memory. */
|
|
14189
|
+
const $3bfd3f1d3eb46898$var$unstored = new Set();
|
|
14190
|
+
/** `views` as a valid list: well-formed entries, newest first, one per id, not older than the age bound or too many. */
|
|
14191
|
+
function $3bfd3f1d3eb46898$var$bounded(views, now) {
|
|
14192
|
+
if (!Array.isArray(views)) return [];
|
|
14193
|
+
const seen = new Set();
|
|
14194
|
+
const kept = [];
|
|
14195
|
+
for (const item of views) {
|
|
14196
|
+
if (!item || typeof item !== "object") continue;
|
|
14197
|
+
const {
|
|
14198
|
+
id: id,
|
|
14199
|
+
at: at
|
|
14200
|
+
} = item;
|
|
14201
|
+
if (typeof id !== "string" || !id || id.length > $3bfd3f1d3eb46898$var$MAX_ID_LENGTH || typeof at !== "string") continue;
|
|
14202
|
+
const time = Date.parse(at);
|
|
14203
|
+
if (Number.isNaN(time) || now - time > $3bfd3f1d3eb46898$export$5eb0a366a50fa99e) continue;
|
|
14204
|
+
kept.push({
|
|
14205
|
+
view: {
|
|
14206
|
+
id: id,
|
|
14207
|
+
at: new Date(time).toISOString()
|
|
14208
|
+
},
|
|
14209
|
+
time: time
|
|
14210
|
+
});
|
|
14211
|
+
}
|
|
14212
|
+
kept.sort((a, b) => b.time - a.time);
|
|
14213
|
+
const newest = [];
|
|
14214
|
+
for (const {
|
|
14215
|
+
view: view
|
|
14216
|
+
} of kept) {
|
|
14217
|
+
if (seen.has(view.id)) continue;
|
|
14218
|
+
seen.add(view.id);
|
|
14219
|
+
newest.push(view);
|
|
14220
|
+
if (newest.length === $3bfd3f1d3eb46898$export$3d684435158adda6) break;
|
|
14221
|
+
}
|
|
14222
|
+
return newest;
|
|
14223
|
+
}
|
|
14224
|
+
function $3bfd3f1d3eb46898$var$read_stored(merchant) {
|
|
14225
|
+
if ($3bfd3f1d3eb46898$var$unstored.has(merchant)) return $3bfd3f1d3eb46898$var$in_memory.get(merchant);
|
|
14226
|
+
try {
|
|
14227
|
+
const stored = localStorage.getItem($3bfd3f1d3eb46898$var$storage_key(merchant));
|
|
14228
|
+
return stored === null ? [] : JSON.parse(stored);
|
|
14229
|
+
} catch {
|
|
14230
|
+
var _in_memory$get;
|
|
14231
|
+
return (_in_memory$get = $3bfd3f1d3eb46898$var$in_memory.get(merchant)) !== null && _in_memory$get !== void 0 ? _in_memory$get : [];
|
|
14232
|
+
}
|
|
14233
|
+
}
|
|
14234
|
+
function $3bfd3f1d3eb46898$export$2d7138f47b625a04(merchant) {
|
|
14235
|
+
let now = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Date.now();
|
|
14236
|
+
return $3bfd3f1d3eb46898$var$bounded($3bfd3f1d3eb46898$var$read_stored(merchant), now);
|
|
14237
|
+
}
|
|
14238
|
+
function $3bfd3f1d3eb46898$export$6379943de8f8af08(merchant, product_id) {
|
|
14239
|
+
let now = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : Date.now();
|
|
14240
|
+
const views = $3bfd3f1d3eb46898$var$bounded([{
|
|
14241
|
+
id: product_id,
|
|
14242
|
+
at: new Date(now).toISOString()
|
|
14243
|
+
}, ...$3bfd3f1d3eb46898$export$2d7138f47b625a04(merchant, now)], now);
|
|
14244
|
+
$3bfd3f1d3eb46898$var$in_memory.set(merchant, views);
|
|
14245
|
+
try {
|
|
14246
|
+
localStorage.setItem($3bfd3f1d3eb46898$var$storage_key(merchant), JSON.stringify(views));
|
|
14247
|
+
$3bfd3f1d3eb46898$var$unstored.delete(merchant);
|
|
14248
|
+
} catch {
|
|
14249
|
+
// localStorage unavailable or full: the in-memory list serves this page load.
|
|
14250
|
+
$3bfd3f1d3eb46898$var$unstored.add(merchant);
|
|
14251
|
+
}
|
|
14252
|
+
}
|
|
14253
|
+
|
|
14254
|
+
/** V4's largest `limit`, and the most ids `cart` and `exclude` take. */
|
|
14255
|
+
const $e8c6cfefe84af5d7$export$f112abad09998fa8 = 100;
|
|
14256
|
+
const $e8c6cfefe84af5d7$var$MAX_IDS = 100;
|
|
14257
|
+
/** The most products V4's `recent_views` takes. */
|
|
14258
|
+
const $e8c6cfefe84af5d7$var$MAX_VIEWS = 50;
|
|
14259
|
+
/** What a v3 recommendations call names, as fetchDepictRecommendations takes it. */
|
|
14260
|
+
const $e8c6cfefe84af5d7$var$distinct = ids => [...new Set(ids.filter(id => typeof id === "string" && id.length > 0))];
|
|
14261
|
+
function $e8c6cfefe84af5d7$export$17493dc1a89b34e6(call, inputs, recent_views) {
|
|
14262
|
+
var _call$productIds;
|
|
14263
|
+
const reads = input => inputs ? inputs.includes(input) : input === "anchor";
|
|
14264
|
+
const product_ids = $e8c6cfefe84af5d7$var$distinct((_call$productIds = call.productIds) !== null && _call$productIds !== void 0 ? _call$productIds : []);
|
|
14265
|
+
const request = {
|
|
14266
|
+
market: call.market,
|
|
14267
|
+
...(call.locale ? {
|
|
14268
|
+
locale: call.locale
|
|
14269
|
+
} : {}),
|
|
14270
|
+
type: call.type
|
|
14271
|
+
};
|
|
14272
|
+
if (reads("anchor")) {
|
|
14273
|
+
if (call.categoryId) request.anchor = {
|
|
14274
|
+
type: "category",
|
|
14275
|
+
id: call.categoryId
|
|
14276
|
+
};else if (call.productId) request.anchor = {
|
|
14277
|
+
type: "product",
|
|
14278
|
+
id: call.productId
|
|
14279
|
+
};else if (product_ids.length) {
|
|
14280
|
+
const [first, ...rest] = product_ids;
|
|
14281
|
+
request.anchor = {
|
|
14282
|
+
type: "product",
|
|
14283
|
+
id: first
|
|
14284
|
+
};
|
|
14285
|
+
if (rest.length) request.exclude = rest.slice(0, $e8c6cfefe84af5d7$var$MAX_IDS);
|
|
14286
|
+
}
|
|
14287
|
+
}
|
|
14288
|
+
if (reads("cart") && product_ids.length) request.cart = product_ids.slice(0, $e8c6cfefe84af5d7$var$MAX_IDS);
|
|
14289
|
+
if (reads("recent_views") && recent_views.length) request.recent_views = recent_views.slice(0, $e8c6cfefe84af5d7$var$MAX_VIEWS);
|
|
14290
|
+
if (call.limit) request.limit = Math.min(Math.max(1, Math.floor(call.limit)), $e8c6cfefe84af5d7$export$f112abad09998fa8);
|
|
14291
|
+
request.include = ["attributes"];
|
|
14292
|
+
const anchor_only = (inputs === null || inputs === void 0 ? void 0 : inputs.length) === 1 && inputs[0] === "anchor";
|
|
14293
|
+
if (anchor_only && !request.anchor) return undefined;
|
|
14294
|
+
return request;
|
|
14295
|
+
}
|
|
14296
|
+
/** `encodeURIComponent`, as V4's own encoder writes a value (`+` would mean a space). */
|
|
14297
|
+
const $e8c6cfefe84af5d7$var$encode = value => encodeURIComponent(value);
|
|
14298
|
+
function $e8c6cfefe84af5d7$export$fc756666ac777d0(request) {
|
|
14299
|
+
var _request$recent_views;
|
|
14300
|
+
const pairs = [];
|
|
14301
|
+
const add = (key, value) => value !== undefined && pairs.push("".concat(key, "=").concat(value));
|
|
14302
|
+
const list = values => values === null || values === void 0 ? void 0 : values.map($e8c6cfefe84af5d7$var$encode).join(",");
|
|
14303
|
+
add("market", $e8c6cfefe84af5d7$var$encode(request.market));
|
|
14304
|
+
add("locale", request.locale === undefined ? undefined : $e8c6cfefe84af5d7$var$encode(request.locale));
|
|
14305
|
+
add("type", $e8c6cfefe84af5d7$var$encode(request.type));
|
|
14306
|
+
add("anchor", request.anchor && "".concat($e8c6cfefe84af5d7$var$encode(request.anchor.type), ":").concat($e8c6cfefe84af5d7$var$encode(request.anchor.id)));
|
|
14307
|
+
add("cart", list(request.cart));
|
|
14308
|
+
add("recent_views", (_request$recent_views = request.recent_views) === null || _request$recent_views === void 0 ? void 0 : _request$recent_views.map(view => "".concat($e8c6cfefe84af5d7$var$encode(view.id), "@").concat($e8c6cfefe84af5d7$var$encode(view.at))).join(","));
|
|
14309
|
+
add("query", request.query === undefined ? undefined : $e8c6cfefe84af5d7$var$encode(request.query));
|
|
14310
|
+
add("exclude", list(request.exclude));
|
|
14311
|
+
add("limit", request.limit === undefined ? undefined : String(request.limit));
|
|
14312
|
+
add("include", list(request.include));
|
|
14313
|
+
return pairs.join("&");
|
|
14314
|
+
}
|
|
14315
|
+
const $e8c6cfefe84af5d7$export$89962366050887f7 = product => {
|
|
14316
|
+
var _product$variants$pro, _product$variants$pro2;
|
|
14317
|
+
return (_product$variants$pro = (_product$variants$pro2 = product.variants[product.selected]) === null || _product$variants$pro2 === void 0 ? void 0 : _product$variants$pro2.product_id) !== null && _product$variants$pro !== void 0 ? _product$variants$pro : product.group_id;
|
|
14318
|
+
};
|
|
14319
|
+
function $e8c6cfefe84af5d7$export$afe6aeae61a7aa58(hits, scope, type) {
|
|
14320
|
+
const anchors = hits.slice(0, type === "search" ? 10 : 1);
|
|
14321
|
+
return anchors.map((anchor, at) => {
|
|
14322
|
+
const exclude = hits.filter((_, index) => index !== at).map($e8c6cfefe84af5d7$export$89962366050887f7);
|
|
14323
|
+
return {
|
|
14324
|
+
market: scope.market,
|
|
14325
|
+
...(scope.locale ? {
|
|
14326
|
+
locale: scope.locale
|
|
14327
|
+
} : {}),
|
|
14328
|
+
type: type,
|
|
14329
|
+
anchor: {
|
|
14330
|
+
type: "product",
|
|
14331
|
+
id: $e8c6cfefe84af5d7$export$89962366050887f7(anchor)
|
|
14332
|
+
},
|
|
14333
|
+
...(exclude.length ? {
|
|
14334
|
+
exclude: exclude.slice(0, $e8c6cfefe84af5d7$var$MAX_IDS)
|
|
14335
|
+
} : {}),
|
|
14336
|
+
include: ["attributes"]
|
|
14337
|
+
};
|
|
14338
|
+
});
|
|
14339
|
+
}
|
|
14340
|
+
function $e8c6cfefe84af5d7$export$9af50be6508dcd00(lists, limit) {
|
|
14341
|
+
const merged = [];
|
|
14342
|
+
const taken = new Set();
|
|
14343
|
+
const depth = Math.max(0, ...lists.map(list => list.length));
|
|
14344
|
+
for (let index = 0; index < depth; index++) for (const list of lists) {
|
|
14345
|
+
const product = list[index];
|
|
14346
|
+
if (product === undefined || taken.has(product.group_id)) continue;
|
|
14347
|
+
taken.add(product.group_id);
|
|
14348
|
+
merged.push(product);
|
|
14349
|
+
if (merged.length >= limit) return merged;
|
|
14350
|
+
}
|
|
14351
|
+
return merged;
|
|
14352
|
+
}
|
|
14353
|
+
|
|
14354
|
+
/** Which v3 result id a card's `tracking_id` goes in; the d1 id it carries says the same (`d1.s.…`, `d1.l.…`). */ /** A bare 3/4/6/8-digit hex, as fi stores a computed `color_hex`; v3 serves it with its `#`. */
|
|
14355
|
+
const $7516809707c75ea7$var$BARE_HEX = /^(?:[0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})$/i;
|
|
14356
|
+
function $7516809707c75ea7$export$7abfb7bc025aaea8(product, tracking_key) {
|
|
14357
|
+
var _product$attributes;
|
|
14358
|
+
const product_attributes = (_product$attributes = product.attributes) !== null && _product$attributes !== void 0 ? _product$attributes : {};
|
|
14359
|
+
return {
|
|
14360
|
+
variant_index: product.selected,
|
|
14361
|
+
variant_displays: product.variants.map(variant => {
|
|
14362
|
+
var _variant$price, _variant$color, _ref, _variant$attributes$m, _variant$attributes, _variant$title, _price$compare_at, _variant$slug;
|
|
14363
|
+
// A variant carries its own main image only when it differs from the card's; it has no gallery of its own.
|
|
14364
|
+
const image_urls = variant.image ? [variant.image] : [...product.images];
|
|
14365
|
+
const price = (_variant$price = variant.price) !== null && _variant$price !== void 0 ? _variant$price : product.price;
|
|
14366
|
+
const color = (_variant$color = variant.color) !== null && _variant$color !== void 0 ? _variant$color : product.color;
|
|
14367
|
+
const display = {
|
|
14368
|
+
...product_attributes,
|
|
14369
|
+
// The merchant's variant attributes under their own keys (`add_to_cart_id`, `item_group_id`, …); the card
|
|
14370
|
+
// fields below win over a same-named attribute, as on v3.
|
|
14371
|
+
...variant.attributes,
|
|
14372
|
+
product_id: variant.product_id,
|
|
14373
|
+
main_product_id: (_ref = (_variant$attributes$m = (_variant$attributes = variant.attributes) === null || _variant$attributes === void 0 ? void 0 : _variant$attributes.main_product_id) !== null && _variant$attributes$m !== void 0 ? _variant$attributes$m : variant.group_id) !== null && _ref !== void 0 ? _ref : product.group_id,
|
|
14374
|
+
title: (_variant$title = variant.title) !== null && _variant$title !== void 0 ? _variant$title : product.title,
|
|
14375
|
+
image_urls: image_urls,
|
|
14376
|
+
sale_price: price.amount,
|
|
14377
|
+
original_price: (_price$compare_at = price.compare_at) !== null && _price$compare_at !== void 0 ? _price$compare_at : price.amount,
|
|
14378
|
+
...(price.lowest !== undefined ? {
|
|
14379
|
+
lowest_price: price.lowest
|
|
14380
|
+
} : {}),
|
|
14381
|
+
in_stock: variant.in_stock,
|
|
14382
|
+
...(color ? {
|
|
14383
|
+
color_name: color.name
|
|
14384
|
+
} : {}),
|
|
14385
|
+
uri: (_variant$slug = variant.slug) !== null && _variant$slug !== void 0 ? _variant$slug : product.slug
|
|
14386
|
+
};
|
|
14387
|
+
const hex = display.color_hex;
|
|
14388
|
+
if (typeof hex === "string" && $7516809707c75ea7$var$BARE_HEX.test(hex)) display.color_hex = "#".concat(hex);
|
|
14389
|
+
return display;
|
|
14390
|
+
}),
|
|
14391
|
+
[tracking_key]: product.tracking_id
|
|
14392
|
+
};
|
|
14393
|
+
}
|
|
14394
|
+
function $744a9d695dd21ed2$var$_classPrivateFieldInitSpec(obj, privateMap, value) {
|
|
14395
|
+
$744a9d695dd21ed2$var$_checkPrivateRedeclaration(obj, privateMap);
|
|
14396
|
+
privateMap.set(obj, value);
|
|
14397
|
+
}
|
|
14398
|
+
function $744a9d695dd21ed2$var$_checkPrivateRedeclaration(obj, privateCollection) {
|
|
14399
|
+
if (privateCollection.has(obj)) throw new TypeError("Cannot initialize the same private elements twice on an object");
|
|
14400
|
+
}
|
|
14401
|
+
class $744a9d695dd21ed2$export$f5ea4d073ddb4bdb extends Error {}
|
|
14402
|
+
/** v3's names for V4's built-in fields, both ways. */
|
|
14403
|
+
const $744a9d695dd21ed2$var$V3_FIELD = {
|
|
14404
|
+
price: "sale_price"
|
|
14405
|
+
};
|
|
14406
|
+
const $744a9d695dd21ed2$var$V4_FIELD = {
|
|
14407
|
+
sale_price: "price"
|
|
14408
|
+
};
|
|
14409
|
+
const $744a9d695dd21ed2$var$V3_SORT = {
|
|
14410
|
+
relevance: "_relevance",
|
|
14411
|
+
price: "sale_price",
|
|
14412
|
+
newest: "product_timestamp"
|
|
14413
|
+
};
|
|
14414
|
+
const $744a9d695dd21ed2$var$V4_SORT = Object.fromEntries(Object.entries($744a9d695dd21ed2$var$V3_SORT).map(_ref => {
|
|
14415
|
+
let [v4, v3] = _ref;
|
|
14416
|
+
return [v3, v4];
|
|
14417
|
+
}));
|
|
14418
|
+
/** V4's public filter field syntax (`FilterField` in the contract). */
|
|
14419
|
+
const $744a9d695dd21ed2$var$PUBLIC_FIELD = /^[A-Za-z0-9_-]+(\.[A-Za-z0-9_-]+)*$/;
|
|
14420
|
+
/**
|
|
14421
|
+
* Fields that are never a lowercased group title: v3's toggles carry no group title, and `sale_price` is v3's own
|
|
14422
|
+
* name for V4's price. A reserved V4 field (`price`, `brand`, `category`) is not among them: iciw's category tree is
|
|
14423
|
+
* titled "Category", so `category` from a link may name `product_scollection_category_hierarchy`.
|
|
14424
|
+
*/
|
|
14425
|
+
const $744a9d695dd21ed2$var$NEVER_A_TITLE = new Set(["in_stock", "on_sale", "sale_price"]);
|
|
14426
|
+
/** fi's enriched colour fields: their values are names, never a `<name>;#<hex>` composite. */
|
|
14427
|
+
const $744a9d695dd21ed2$var$FI_COLOUR_FIELDS = new Set(["colors", "color_details"]);
|
|
14428
|
+
/** The colour template's field, which indexes the composite itself. */
|
|
14429
|
+
const $744a9d695dd21ed2$var$V3_TEMPLATE_COLOUR = "color_with_hex_list";
|
|
14430
|
+
/** Legacy's colour pill composite suffix (`Green;#9ea386`). */
|
|
14431
|
+
const $744a9d695dd21ed2$var$HEX_SUFFIX = /;#[0-9a-fA-F]{3,8}\s*$/;
|
|
14432
|
+
const $744a9d695dd21ed2$var$NUMERIC = /^-?\d+(\.\d+)?$/;
|
|
14433
|
+
/** realtime's separator between the levels of a hierarchical facet value (`Shop # Woman`). */
|
|
14434
|
+
const $744a9d695dd21ed2$var$HIERARCHY_SEPARATOR = " # ";
|
|
14435
|
+
/** The features realtime's category tree is built on. */
|
|
14436
|
+
const $744a9d695dd21ed2$var$CATEGORY_TREE_FIELDS = new Set(["product_category_hierarchy", "product_scollection_category_hierarchy"]);
|
|
14437
|
+
/** V4's public name for the discount template's field (realtime `v4/worker/src/search/fields.ts`). */
|
|
14438
|
+
const $744a9d695dd21ed2$var$DISCOUNT_FIELD = "discount";
|
|
14439
|
+
/** The fields of V4's toggle facets (the `on_sale` and `in_stock` templates). */
|
|
14440
|
+
const $744a9d695dd21ed2$var$V3_TOGGLES = new Set(["on_sale", "in_stock"]);
|
|
14441
|
+
var $744a9d695dd21ed2$var$_by_key = /*#__PURE__*/new WeakMap();
|
|
14442
|
+
class $744a9d695dd21ed2$export$8d488bcc71d07ffb {
|
|
14443
|
+
constructor() {
|
|
14444
|
+
$744a9d695dd21ed2$var$_classPrivateFieldInitSpec(this, $744a9d695dd21ed2$var$_by_key, {
|
|
14445
|
+
writable: true,
|
|
14446
|
+
value: new Map()
|
|
14447
|
+
});
|
|
14448
|
+
}
|
|
14449
|
+
/** Adds the facets of one browse response. */
|
|
14450
|
+
learn_(facets) {
|
|
14451
|
+
for (const facet of facets !== null && facets !== void 0 ? facets : []) {
|
|
14452
|
+
const info = {
|
|
14453
|
+
field_: facet.field,
|
|
14454
|
+
checkbox_: facet.type === "checkbox" && !$744a9d695dd21ed2$var$is_toggle(facet),
|
|
14455
|
+
colour_: $744a9d695dd21ed2$var$FI_COLOUR_FIELDS.has(facet.field) || facet.type === "swatch" && facet.field !== $744a9d695dd21ed2$var$V3_TEMPLATE_COLOUR
|
|
14456
|
+
};
|
|
14457
|
+
$parcel$interopDefault($52FdA$babelruntimehelpersclassPrivateFieldGet)(this, $744a9d695dd21ed2$var$_by_key).set(facet.field, info);
|
|
14458
|
+
const v3_field = $744a9d695dd21ed2$var$V3_FIELD[facet.field];
|
|
14459
|
+
if (v3_field) $parcel$interopDefault($52FdA$babelruntimehelpersclassPrivateFieldGet)(this, $744a9d695dd21ed2$var$_by_key).set(v3_field, info);
|
|
14460
|
+
if (facet.title) $parcel$interopDefault($52FdA$babelruntimehelpersclassPrivateFieldGet)(this, $744a9d695dd21ed2$var$_by_key).set(facet.title.toLowerCase(), info);
|
|
14461
|
+
}
|
|
14462
|
+
}
|
|
14463
|
+
/** The field a v3 filter field names, when a served facet has it as its field or its title. */
|
|
14464
|
+
get_(field) {
|
|
14465
|
+
const bare = field.replace(/#$/, "");
|
|
14466
|
+
const direct = $parcel$interopDefault($52FdA$babelruntimehelpersclassPrivateFieldGet)(this, $744a9d695dd21ed2$var$_by_key).get(bare);
|
|
14467
|
+
if (direct) return direct;
|
|
14468
|
+
let wanted;
|
|
14469
|
+
try {
|
|
14470
|
+
wanted = decodeURIComponent(bare).toLowerCase();
|
|
14471
|
+
} catch {
|
|
14472
|
+
wanted = bare.toLowerCase();
|
|
14473
|
+
}
|
|
14474
|
+
return $parcel$interopDefault($52FdA$babelruntimehelpersclassPrivateFieldGet)(this, $744a9d695dd21ed2$var$_by_key).get(wanted);
|
|
14475
|
+
}
|
|
14476
|
+
}
|
|
14477
|
+
function $744a9d695dd21ed2$export$3b6ba2422a5e0aa0(field, index) {
|
|
14478
|
+
return !!index.get_(field) || $744a9d695dd21ed2$var$NEVER_A_TITLE.has(field.replace(/#$/, ""));
|
|
14479
|
+
}
|
|
14480
|
+
function $744a9d695dd21ed2$var$is_empty(data) {
|
|
14481
|
+
return data === undefined || data === null || data === "" || Array.isArray(data) && !data.length;
|
|
14482
|
+
}
|
|
14483
|
+
function $744a9d695dd21ed2$var$literal(value, field) {
|
|
14484
|
+
const text = String(value);
|
|
14485
|
+
if (text.includes("`")) throw new $744a9d695dd21ed2$export$f5ea4d073ddb4bdb("filters: a value of ".concat(field, " contains a backtick"));
|
|
14486
|
+
// A boolean-looking string is written bare, as realtime's filter writer does for every field.
|
|
14487
|
+
if (/^(true|True|false|False)$/.test(text)) return text.toLowerCase();
|
|
14488
|
+
if (field === "price" && $744a9d695dd21ed2$var$NUMERIC.test(text)) return text;
|
|
14489
|
+
return typeof value === "string" ? "`".concat(text, "`") : text;
|
|
14490
|
+
}
|
|
14491
|
+
function $744a9d695dd21ed2$var$lax_number(value) {
|
|
14492
|
+
if (typeof value === "number") return value;
|
|
14493
|
+
if (typeof value !== "string" || value.trim() === "") return undefined;
|
|
14494
|
+
const number = Number(value);
|
|
14495
|
+
return Number.isFinite(number) ? number : undefined;
|
|
14496
|
+
}
|
|
14497
|
+
function $744a9d695dd21ed2$export$c17bb5d2ead3e8f3(filter, index) {
|
|
14498
|
+
var _ref2, _info$field_;
|
|
14499
|
+
if ($744a9d695dd21ed2$var$is_empty(filter.data)) return undefined;
|
|
14500
|
+
const info = index.get_(filter.field);
|
|
14501
|
+
const bare = filter.field.replace(/#$/, "");
|
|
14502
|
+
const field = (_ref2 = (_info$field_ = info === null || info === void 0 ? void 0 : info.field_) !== null && _info$field_ !== void 0 ? _info$field_ : $744a9d695dd21ed2$var$V4_FIELD[bare]) !== null && _ref2 !== void 0 ? _ref2 : bare;
|
|
14503
|
+
if (!$744a9d695dd21ed2$var$PUBLIC_FIELD.test(field)) throw new $744a9d695dd21ed2$export$f5ea4d073ddb4bdb("Invalid filter field `".concat(filter.field, "`"));
|
|
14504
|
+
const clause = text => ({
|
|
14505
|
+
field_: field,
|
|
14506
|
+
clause_: text
|
|
14507
|
+
});
|
|
14508
|
+
const colour = $744a9d695dd21ed2$var$FI_COLOUR_FIELDS.has(field) || !!(info !== null && info !== void 0 && info.colour_);
|
|
14509
|
+
const data = filter.data;
|
|
14510
|
+
const values = (Array.isArray(data) ? data : [data]).map(value => !Array.isArray(value) ? colour && typeof value === "string" ? value.replace($744a9d695dd21ed2$var$HEX_SUFFIX, "").trim() || value : value : field === "category" ? value[value.length - 1] : value.map(String).join($744a9d695dd21ed2$var$HIERARCHY_SEPARATOR));
|
|
14511
|
+
const list = () => "[".concat(values.map(value => $744a9d695dd21ed2$var$literal(value, field)).join(","), "]");
|
|
14512
|
+
// V4's discount filter (the discount template's "X% or more" radio) is a threshold, so `in` or `eq` on it means
|
|
14513
|
+
// "this discount or more", as on the facade since realtime#2181: a link with no operator decodes as `in`, and a
|
|
14514
|
+
// shop may send `in ["0.2"]` itself. Several values take the largest, as `geq` does.
|
|
14515
|
+
const op = (filter.op === "in" || filter.op === "eq") && field === $744a9d695dd21ed2$var$DISCOUNT_FIELD ? "geq" : filter.op;
|
|
14516
|
+
// A configured checkbox keeps in/nin; every other op on it becomes in.
|
|
14517
|
+
if (op !== "in" && op !== "nin" && info !== null && info !== void 0 && info.checkbox_) return clause("".concat(field, ":=").concat(list()));
|
|
14518
|
+
const one = () => {
|
|
14519
|
+
if (values.length !== 1) throw new $744a9d695dd21ed2$export$f5ea4d073ddb4bdb("filters: ".concat(op, " takes one value"));
|
|
14520
|
+
return $744a9d695dd21ed2$var$literal(values[0], field);
|
|
14521
|
+
};
|
|
14522
|
+
// A comparison takes a number, also one sent as a string; of several numbers `geq` takes the largest.
|
|
14523
|
+
const bound = () => {
|
|
14524
|
+
const numbers = values.map(value => typeof value === "number" || typeof value === "string" && $744a9d695dd21ed2$var$NUMERIC.test(value) ? Number(value) : undefined);
|
|
14525
|
+
if (numbers.length === 0 || numbers.some(number => number === undefined)) return one();
|
|
14526
|
+
if (numbers.length > 1 && op !== "geq") return one();
|
|
14527
|
+
return String(Math.max(...numbers));
|
|
14528
|
+
};
|
|
14529
|
+
switch (op) {
|
|
14530
|
+
case "eq":
|
|
14531
|
+
return clause("".concat(field, ":=").concat(one()));
|
|
14532
|
+
case "neq":
|
|
14533
|
+
return clause("".concat(field, ":!=").concat(one()));
|
|
14534
|
+
case "in":
|
|
14535
|
+
return clause("".concat(field, ":=").concat(list()));
|
|
14536
|
+
case "nin":
|
|
14537
|
+
return clause("".concat(field, ":!=").concat(list()));
|
|
14538
|
+
case "leq":
|
|
14539
|
+
return clause("".concat(field, ":<=").concat(bound()));
|
|
14540
|
+
case "geq":
|
|
14541
|
+
return clause("".concat(field, ":>=").concat(bound()));
|
|
14542
|
+
case "inrange":
|
|
14543
|
+
{
|
|
14544
|
+
const [min, max] = values.map($744a9d695dd21ed2$var$lax_number);
|
|
14545
|
+
if (min === undefined || max === undefined || values.length !== 2) throw new $744a9d695dd21ed2$export$f5ea4d073ddb4bdb("filters: inrange takes [min, max]");
|
|
14546
|
+
return clause("".concat(field, ":[").concat(min, "..").concat(max, "]"));
|
|
14547
|
+
}
|
|
14548
|
+
default:
|
|
14549
|
+
throw new $744a9d695dd21ed2$export$f5ea4d073ddb4bdb("filters: unknown op ".concat(op));
|
|
14550
|
+
}
|
|
14551
|
+
}
|
|
14552
|
+
function $744a9d695dd21ed2$export$407f30f25da13cc7(filters, index) {
|
|
14553
|
+
const clauses = filters.flatMap(filter => {
|
|
14554
|
+
var _v3_filter_to_clause$, _v3_filter_to_clause;
|
|
14555
|
+
return (_v3_filter_to_clause$ = (_v3_filter_to_clause = $744a9d695dd21ed2$export$c17bb5d2ead3e8f3(filter, index)) === null || _v3_filter_to_clause === void 0 ? void 0 : _v3_filter_to_clause.clause_) !== null && _v3_filter_to_clause$ !== void 0 ? _v3_filter_to_clause$ : [];
|
|
14556
|
+
});
|
|
14557
|
+
return clauses.length ? clauses.join(" && ") : undefined;
|
|
14558
|
+
}
|
|
14559
|
+
function $744a9d695dd21ed2$export$c38de645260a41ed(error, clauses) {
|
|
14560
|
+
var _match, _error$message;
|
|
14561
|
+
if (!error || !clauses.length) return [];
|
|
14562
|
+
const named = (_match = ((_error$message = error.message) !== null && _error$message !== void 0 ? _error$message : "").match(/"([A-Za-z0-9_.-]+)/)) === null || _match === void 0 ? void 0 : _match[1];
|
|
14563
|
+
if (error.code === "unknown_filter_field") {
|
|
14564
|
+
if (error.allowed) {
|
|
14565
|
+
const allowed = new Set(error.allowed);
|
|
14566
|
+
return clauses.filter(clause => !allowed.has(clause.field_));
|
|
14567
|
+
}
|
|
14568
|
+
return clauses.filter(clause => clause.field_ === named);
|
|
14569
|
+
}
|
|
14570
|
+
if (error.code === "invalid_filter") {
|
|
14571
|
+
const on_field = clauses.filter(clause => clause.field_ === named);
|
|
14572
|
+
return on_field.length ? on_field : [...clauses];
|
|
14573
|
+
}
|
|
14574
|
+
return [];
|
|
14575
|
+
}
|
|
14576
|
+
function $744a9d695dd21ed2$export$78eb8e636d89ff30(sort) {
|
|
14577
|
+
var _V4_SORT$sort$field;
|
|
14578
|
+
if (!sort || sort.field === "_relevance") return undefined;
|
|
14579
|
+
return {
|
|
14580
|
+
field: (_V4_SORT$sort$field = $744a9d695dd21ed2$var$V4_SORT[sort.field]) !== null && _V4_SORT$sort$field !== void 0 ? _V4_SORT$sort$field : sort.field,
|
|
14581
|
+
order: sort.order
|
|
14582
|
+
};
|
|
14583
|
+
}
|
|
14584
|
+
function $744a9d695dd21ed2$export$cd08b64be5110ce2(sorts) {
|
|
14585
|
+
return sorts.map(sort => {
|
|
14586
|
+
var _V3_SORT$sort$field;
|
|
14587
|
+
return {
|
|
14588
|
+
field: (_V3_SORT$sort$field = $744a9d695dd21ed2$var$V3_SORT[sort.field]) !== null && _V3_SORT$sort$field !== void 0 ? _V3_SORT$sort$field : sort.field,
|
|
14589
|
+
order: sort.order,
|
|
14590
|
+
meta: {
|
|
14591
|
+
title: sort.title,
|
|
14592
|
+
values: [sort.order],
|
|
14593
|
+
names: [sort.title]
|
|
14594
|
+
}
|
|
14595
|
+
};
|
|
14596
|
+
});
|
|
14597
|
+
}
|
|
14598
|
+
const $744a9d695dd21ed2$var$V3_VALUES_TYPE = {
|
|
14599
|
+
checkbox: "checkbox",
|
|
14600
|
+
radio: "radio",
|
|
14601
|
+
swatch: "checkbox-color",
|
|
14602
|
+
hierarchy: "checkbox-hierarchical",
|
|
14603
|
+
grid: "checkbox-grid"
|
|
14604
|
+
};
|
|
14605
|
+
/** A toggle is a template facet's one `true` value. */
|
|
14606
|
+
function $744a9d695dd21ed2$var$is_toggle(facet) {
|
|
14607
|
+
return $744a9d695dd21ed2$var$V3_TOGGLES.has(facet.field) && facet.type === "checkbox" && facet.values.length === 1 && facet.values[0].value === "true";
|
|
14608
|
+
}
|
|
14609
|
+
function $744a9d695dd21ed2$var$category_path(value) {
|
|
14610
|
+
return value.split("#").map(level => level.trim()).filter(Boolean);
|
|
14611
|
+
}
|
|
14612
|
+
function $744a9d695dd21ed2$export$da9af372695714ef(facets, currency) {
|
|
14613
|
+
return facets.filter(facet => facet.type === "range" || facet.values.length > 0).map(facet => {
|
|
14614
|
+
var _V3_FIELD$facet$field, _V3_VALUES_TYPE$facet;
|
|
14615
|
+
const field = (_V3_FIELD$facet$field = $744a9d695dd21ed2$var$V3_FIELD[facet.field]) !== null && _V3_FIELD$facet$field !== void 0 ? _V3_FIELD$facet$field : facet.field;
|
|
14616
|
+
if (facet.type === "range") return {
|
|
14617
|
+
field: field,
|
|
14618
|
+
op: "inrange",
|
|
14619
|
+
data: [facet.min, facet.max],
|
|
14620
|
+
meta: {
|
|
14621
|
+
group_title: facet.title,
|
|
14622
|
+
type: "range",
|
|
14623
|
+
min: facet.min,
|
|
14624
|
+
max: facet.max,
|
|
14625
|
+
...(facet.field === "price" && currency ? {
|
|
14626
|
+
currency: currency
|
|
14627
|
+
} : {})
|
|
14628
|
+
},
|
|
14629
|
+
id: "".concat(field, "1")
|
|
14630
|
+
};
|
|
14631
|
+
const hierarchy = facet.type === "hierarchy";
|
|
14632
|
+
const path = value => $744a9d695dd21ed2$var$CATEGORY_TREE_FIELDS.has(facet.field) ? $744a9d695dd21ed2$var$category_path(value) : value.split($744a9d695dd21ed2$var$HIERARCHY_SEPARATOR);
|
|
14633
|
+
if ($744a9d695dd21ed2$var$is_toggle(facet)) return {
|
|
14634
|
+
field: field,
|
|
14635
|
+
op: "eq",
|
|
14636
|
+
meta: {
|
|
14637
|
+
type: "checkbox",
|
|
14638
|
+
values: facet.values.map(value => value.value),
|
|
14639
|
+
counts: facet.values.map(value => value.count),
|
|
14640
|
+
names: facet.values.map(value => value.label)
|
|
14641
|
+
},
|
|
14642
|
+
id: "".concat(field, "1")
|
|
14643
|
+
};
|
|
14644
|
+
// Two spellings of one category path are one row in the tree.
|
|
14645
|
+
const seen = new Set();
|
|
14646
|
+
const values = $744a9d695dd21ed2$var$CATEGORY_TREE_FIELDS.has(facet.field) ? facet.values.filter(_ref3 => {
|
|
14647
|
+
let {
|
|
14648
|
+
value: value
|
|
14649
|
+
} = _ref3;
|
|
14650
|
+
const levels = path(value);
|
|
14651
|
+
const key = JSON.stringify(levels);
|
|
14652
|
+
if (levels.length === 0 || seen.has(key)) return false;
|
|
14653
|
+
seen.add(key);
|
|
14654
|
+
return true;
|
|
14655
|
+
}) : facet.values;
|
|
14656
|
+
return {
|
|
14657
|
+
field: field,
|
|
14658
|
+
op: facet.field === "discount" ? "geq" : "in",
|
|
14659
|
+
meta: {
|
|
14660
|
+
group_title: facet.title,
|
|
14661
|
+
type: (_V3_VALUES_TYPE$facet = $744a9d695dd21ed2$var$V3_VALUES_TYPE[facet.type]) !== null && _V3_VALUES_TYPE$facet !== void 0 ? _V3_VALUES_TYPE$facet : "checkbox",
|
|
14662
|
+
values: values.map(value => hierarchy ? path(value.value) : value.value),
|
|
14663
|
+
counts: values.map(value => value.count),
|
|
14664
|
+
names: values.map(value => hierarchy ? path(value.value).slice(-1)[0] : value.label),
|
|
14665
|
+
// The colour template sends swatches only with one to paint; a colour filter always sends them.
|
|
14666
|
+
...(facet.type === "swatch" && (facet.field !== $744a9d695dd21ed2$var$V3_TEMPLATE_COLOUR || facet.values.some(value => value.swatch)) ? {
|
|
14667
|
+
swatches: facet.values.map(value => {
|
|
14668
|
+
var _value$swatch;
|
|
14669
|
+
return (_value$swatch = value.swatch) !== null && _value$swatch !== void 0 ? _value$swatch : null;
|
|
14670
|
+
})
|
|
14671
|
+
} : {})
|
|
14672
|
+
},
|
|
14673
|
+
id: "".concat(field, "1")
|
|
14674
|
+
};
|
|
14675
|
+
});
|
|
14676
|
+
}
|
|
14677
|
+
function $744a9d695dd21ed2$export$b84a41a5163c4fce(content) {
|
|
14678
|
+
return content.map(hit => {
|
|
14679
|
+
var _hit$highlights;
|
|
14680
|
+
return {
|
|
14681
|
+
type: "content_link",
|
|
14682
|
+
title: hit.title,
|
|
14683
|
+
...(hit.description !== undefined ? {
|
|
14684
|
+
description: hit.description
|
|
14685
|
+
} : {}),
|
|
14686
|
+
...(hit.image_url !== undefined ? {
|
|
14687
|
+
image_url: hit.image_url
|
|
14688
|
+
} : {}),
|
|
14689
|
+
page_url: hit.url,
|
|
14690
|
+
highlights: (_hit$highlights = hit.highlights) !== null && _hit$highlights !== void 0 ? _hit$highlights : []
|
|
14691
|
+
};
|
|
14692
|
+
});
|
|
14693
|
+
}
|
|
14694
|
+
function $14bc537adeeadca4$export$efb7dd882d411dd4(response, door, offset) {
|
|
14695
|
+
var _response$total, _response$sorts, _response$facets, _response$content;
|
|
14696
|
+
const tracking_key = door === "search" ? "search_result_id" : "product_listing_result_id";
|
|
14697
|
+
return {
|
|
14698
|
+
n_hits: (_response$total = response.total) !== null && _response$total !== void 0 ? _response$total : offset + response.products.length,
|
|
14699
|
+
sorts: $744a9d695dd21ed2$export$cd08b64be5110ce2((_response$sorts = response.sorts) !== null && _response$sorts !== void 0 ? _response$sorts : []),
|
|
14700
|
+
filters: $744a9d695dd21ed2$export$da9af372695714ef((_response$facets = response.facets) !== null && _response$facets !== void 0 ? _response$facets : [], response.currency),
|
|
14701
|
+
...(door === "search" ? {
|
|
14702
|
+
search_request_id: response.request_id,
|
|
14703
|
+
content_search_links: $744a9d695dd21ed2$export$b84a41a5163c4fce((_response$content = response.content) !== null && _response$content !== void 0 ? _response$content : []),
|
|
14704
|
+
is_fallback: null
|
|
14705
|
+
} : {
|
|
14706
|
+
product_listing_request_id: response.request_id
|
|
14707
|
+
}),
|
|
14708
|
+
...(response.cursor !== undefined ? {
|
|
14709
|
+
cursor: response.cursor
|
|
14710
|
+
} : {}),
|
|
14711
|
+
displays: response.products.map(product => $7516809707c75ea7$export$7abfb7bc025aaea8(product, tracking_key))
|
|
14712
|
+
};
|
|
14713
|
+
}
|
|
14714
|
+
function $14bc537adeeadca4$var$listing_ref_to_v3(ref, listing_type, show) {
|
|
14715
|
+
return {
|
|
14716
|
+
listing_id: ref.id,
|
|
14717
|
+
...(ref.external_id !== undefined ? {
|
|
14718
|
+
external_id: ref.external_id
|
|
14719
|
+
} : {}),
|
|
14720
|
+
listing_type: listing_type,
|
|
14721
|
+
...show,
|
|
14722
|
+
image_urls: [],
|
|
14723
|
+
title: ref.title,
|
|
14724
|
+
...(ref.slug !== undefined ? {
|
|
14725
|
+
slug: ref.slug
|
|
14726
|
+
} : {})
|
|
14727
|
+
};
|
|
14728
|
+
}
|
|
14729
|
+
function $14bc537adeeadca4$export$996f2b1e66d9b5af(listing) {
|
|
14730
|
+
const listing_type = listing.type;
|
|
14731
|
+
const quick_links_are_siblings = listing.quick_links.some(link => link.id === listing.id);
|
|
14732
|
+
const quick_links = listing.quick_links.map(link => $14bc537adeeadca4$var$listing_ref_to_v3(link, listing_type, {
|
|
14733
|
+
show_in_breadcrumbs: true,
|
|
14734
|
+
show_in_quicklinks: true
|
|
14735
|
+
}));
|
|
14736
|
+
return {
|
|
14737
|
+
listing_id: listing.id,
|
|
14738
|
+
...(listing.external_id !== undefined ? {
|
|
14739
|
+
external_id: listing.external_id
|
|
14740
|
+
} : {}),
|
|
14741
|
+
listing_type: listing_type,
|
|
14742
|
+
show_in_breadcrumbs: listing.show_in_breadcrumbs,
|
|
14743
|
+
show_in_quicklinks: true,
|
|
14744
|
+
image_urls: listing.images,
|
|
14745
|
+
title: listing.title,
|
|
14746
|
+
...(listing.slug !== undefined ? {
|
|
14747
|
+
slug: listing.slug
|
|
14748
|
+
} : {}),
|
|
14749
|
+
ancestors: listing.breadcrumbs.map(ref => $14bc537adeeadca4$var$listing_ref_to_v3(ref, "category", {
|
|
14750
|
+
show_in_breadcrumbs: true,
|
|
14751
|
+
show_in_quicklinks: true
|
|
14752
|
+
})),
|
|
14753
|
+
siblings: quick_links_are_siblings ? quick_links : [],
|
|
14754
|
+
children: quick_links_are_siblings ? [] : quick_links,
|
|
14755
|
+
content_blocks: listing.content_blocks
|
|
14756
|
+
};
|
|
14757
|
+
}
|
|
14758
|
+
function $14bc537adeeadca4$export$76d96892da63b395(tree) {
|
|
14759
|
+
const by_id = new Map();
|
|
14760
|
+
const walk = (nodes, chain) => {
|
|
14761
|
+
for (const node of nodes) {
|
|
14762
|
+
if (!by_id.has(node.id)) by_id.set(node.id, chain);
|
|
14763
|
+
walk(node.children, [...chain, $14bc537adeeadca4$var$listing_ref_to_v3(node, node.type, {
|
|
14764
|
+
show_in_breadcrumbs: true,
|
|
14765
|
+
show_in_quicklinks: true
|
|
14766
|
+
})]);
|
|
14767
|
+
}
|
|
14768
|
+
};
|
|
14769
|
+
walk(tree, []);
|
|
14770
|
+
return listing_id => by_id.get(listing_id);
|
|
14771
|
+
}
|
|
14772
|
+
function $14bc537adeeadca4$export$2860125b419015f8(response, ancestors_of) {
|
|
14773
|
+
return {
|
|
14774
|
+
suggestions_request_id: response.request_id,
|
|
14775
|
+
suggestions: response.suggestions.map(suggestion => {
|
|
14776
|
+
if (suggestion.type === "query") return {
|
|
14777
|
+
type: "query",
|
|
14778
|
+
query: suggestion.query,
|
|
14779
|
+
suggestions_result_id: ""
|
|
14780
|
+
};
|
|
14781
|
+
const from_tree = ancestors_of === null || ancestors_of === void 0 ? void 0 : ancestors_of(suggestion.listing.id);
|
|
14782
|
+
const ancestors = from_tree && $14bc537adeeadca4$var$same_titles(from_tree, suggestion.path) ? from_tree : [];
|
|
14783
|
+
return {
|
|
14784
|
+
type: "listing",
|
|
14785
|
+
listing_id: suggestion.listing.id,
|
|
14786
|
+
...(suggestion.listing.external_id !== undefined ? {
|
|
14787
|
+
external_id: suggestion.listing.external_id
|
|
14788
|
+
} : {}),
|
|
14789
|
+
listing_type: suggestion.listing.type,
|
|
14790
|
+
show_in_breadcrumbs: true,
|
|
14791
|
+
show_in_quicklinks: true,
|
|
14792
|
+
image_urls: suggestion.listing.images,
|
|
14793
|
+
title: suggestion.listing.title,
|
|
14794
|
+
...(suggestion.listing.slug !== undefined ? {
|
|
14795
|
+
slug: suggestion.listing.slug
|
|
14796
|
+
} : {}),
|
|
14797
|
+
suggestions_result_id: "",
|
|
14798
|
+
ancestors: ancestors
|
|
14799
|
+
};
|
|
14800
|
+
})
|
|
14801
|
+
};
|
|
14802
|
+
}
|
|
14803
|
+
const $14bc537adeeadca4$var$same_titles = (ancestors, path) => ancestors.length === path.length && ancestors.every((ancestor, index) => ancestor.title === path[index]);
|
|
14804
|
+
/** `encodeURIComponent`, as V4's own encoder writes a value (`+` would mean a space). */
|
|
14805
|
+
const $14bc537adeeadca4$var$encode = value => encodeURIComponent(value);
|
|
14806
|
+
function $14bc537adeeadca4$export$7659319cdb555579(request) {
|
|
14807
|
+
var _request$include;
|
|
14808
|
+
const pairs = ["market=".concat($14bc537adeeadca4$var$encode(request.market))];
|
|
14809
|
+
const add = (key, value) => value !== undefined && pairs.push("".concat(key, "=").concat(value));
|
|
14810
|
+
add("locale", request.locale === undefined ? undefined : $14bc537adeeadca4$var$encode(request.locale));
|
|
14811
|
+
add("query", request.query === undefined ? undefined : $14bc537adeeadca4$var$encode(request.query));
|
|
14812
|
+
if (request.listing && "id" in request.listing) add("listing", $14bc537adeeadca4$var$encode(request.listing.id));else if (request.listing) add("listing_external_id", $14bc537adeeadca4$var$encode(request.listing.external_id));
|
|
14813
|
+
add("filter_by", request.filter_by === undefined ? undefined : $14bc537adeeadca4$var$encode(request.filter_by));
|
|
14814
|
+
if (request.sort) add("sort", "".concat($14bc537adeeadca4$var$encode(request.sort.field), ".").concat(request.sort.order));
|
|
14815
|
+
add("include", (_request$include = request.include) === null || _request$include === void 0 ? void 0 : _request$include.join(","));
|
|
14816
|
+
add("cursor", request.cursor);
|
|
14817
|
+
add("limit", request.limit === undefined ? undefined : String(request.limit));
|
|
14818
|
+
return pairs.join("&");
|
|
14819
|
+
}
|
|
14820
|
+
function $14bc537adeeadca4$export$fec3e4b5adfcea2c(params) {
|
|
14821
|
+
return params.filter(pair => pair[1] !== undefined).map(_ref => {
|
|
14822
|
+
let [key, value] = _ref;
|
|
14823
|
+
return "".concat(key, "=").concat($14bc537adeeadca4$var$encode(value));
|
|
14824
|
+
}).join("&");
|
|
14825
|
+
}
|
|
14826
|
+
function $14bc537adeeadca4$export$eb90c08da400512d(locale) {
|
|
14827
|
+
return locale ? locale.replace(/_/g, "-") : undefined;
|
|
14828
|
+
}
|
|
14829
|
+
|
|
14830
|
+
/** realtime's related search page: the hits related recommendations anchor on and never repeat. */
|
|
14831
|
+
const $2573fc0c2eb12a79$var$RELATED_SEARCH_PAGE = 100;
|
|
14832
|
+
const $2573fc0c2eb12a79$var$get_recommendations = (merchant, request) => $8ad8c4b4b26ba277$export$88d793e3827f3436($8ad8c4b4b26ba277$export$b6dad15503f66988(merchant, "/recommendations") + "?" + $e8c6cfefe84af5d7$export$fc756666ac777d0(request));
|
|
14833
|
+
const $2573fc0c2eb12a79$var$to_displays = products => products.map(product => $7516809707c75ea7$export$7abfb7bc025aaea8(product, "recommendation_id"));
|
|
14834
|
+
async function $2573fc0c2eb12a79$export$656ee5c46d5d1eda(call) {
|
|
14835
|
+
var _response$used_inputs;
|
|
14836
|
+
const {
|
|
14837
|
+
merchant: merchant
|
|
14838
|
+
} = call;
|
|
14839
|
+
const types = await $294cf81de92da757$export$869eb14d6f85ac51(merchant);
|
|
14840
|
+
const inputs = types === null || types === void 0 ? void 0 : types.get(call.type);
|
|
14841
|
+
if (types && !inputs) {
|
|
14842
|
+
$52FdA$depictaiutilishared.dwarn("[NativeDepictAPI] V4 serves ".concat(merchant, ' no recommendation type "').concat(call.type, '"; known:'), [...types.keys()]);
|
|
14843
|
+
return [];
|
|
14844
|
+
}
|
|
14845
|
+
const request = $e8c6cfefe84af5d7$export$17493dc1a89b34e6({
|
|
14846
|
+
...call,
|
|
14847
|
+
locale: $14bc537adeeadca4$export$eb90c08da400512d(call.locale)
|
|
14848
|
+
}, inputs, inputs !== null && inputs !== void 0 && inputs.includes("recent_views") ? $3bfd3f1d3eb46898$export$2d7138f47b625a04(merchant) : []);
|
|
14849
|
+
if (!request) return [];
|
|
14850
|
+
const response = await $2573fc0c2eb12a79$var$get_recommendations(merchant, request);
|
|
14851
|
+
if (!response) return [];
|
|
14852
|
+
const anchor = (_response$used_inputs = response.used_inputs) === null || _response$used_inputs === void 0 ? void 0 : _response$used_inputs.anchor;
|
|
14853
|
+
if (call.productId && (anchor === null || anchor === void 0 ? void 0 : anchor.type) === "product") $3bfd3f1d3eb46898$export$6379943de8f8af08(merchant, anchor.id);
|
|
14854
|
+
return $2573fc0c2eb12a79$var$to_displays(response.products);
|
|
14855
|
+
}
|
|
14856
|
+
async function $2573fc0c2eb12a79$export$bd5f8a7d3e47a43d(call) {
|
|
14857
|
+
var _types$get, _types$get2, _call$query;
|
|
14858
|
+
const {
|
|
14859
|
+
merchant: merchant,
|
|
14860
|
+
market: market
|
|
14861
|
+
} = call;
|
|
14862
|
+
const types = await $294cf81de92da757$export$869eb14d6f85ac51(merchant);
|
|
14863
|
+
if (!types) return undefined;
|
|
14864
|
+
const type = (_types$get = types.get("search")) !== null && _types$get !== void 0 && _types$get.includes("anchor") ? "search" : (_types$get2 = types.get("similar")) !== null && _types$get2 !== void 0 && _types$get2.includes("anchor") ? "similar" : undefined;
|
|
14865
|
+
if (!type) {
|
|
14866
|
+
$52FdA$depictaiutilishared.dwarn("[NativeDepictAPI] V4 serves ".concat(merchant, " no search or similar recommendations for related products"));
|
|
14867
|
+
return [];
|
|
14868
|
+
}
|
|
14869
|
+
const locale = $14bc537adeeadca4$export$eb90c08da400512d(call.locale);
|
|
14870
|
+
const query = ((_call$query = call.query) === null || _call$query === void 0 ? void 0 : _call$query.trim()) || undefined;
|
|
14871
|
+
const searched = await $8ad8c4b4b26ba277$export$88d793e3827f3436($8ad8c4b4b26ba277$export$b6dad15503f66988(merchant, "/browse") + "?" + $14bc537adeeadca4$export$7659319cdb555579({
|
|
14872
|
+
market: market,
|
|
14873
|
+
...(locale ? {
|
|
14874
|
+
locale: locale
|
|
14875
|
+
} : {}),
|
|
14876
|
+
...(query ? {
|
|
14877
|
+
query: query
|
|
14878
|
+
} : {}),
|
|
14879
|
+
limit: $2573fc0c2eb12a79$var$RELATED_SEARCH_PAGE
|
|
14880
|
+
}));
|
|
14881
|
+
if (!searched) return undefined;
|
|
14882
|
+
const asked = $e8c6cfefe84af5d7$export$afe6aeae61a7aa58(searched.products, {
|
|
14883
|
+
market: market,
|
|
14884
|
+
...(locale ? {
|
|
14885
|
+
locale: locale
|
|
14886
|
+
} : {})
|
|
14887
|
+
}, type);
|
|
14888
|
+
if (!asked.length) return [];
|
|
14889
|
+
const answers = await Promise.all(asked.map(request => $2573fc0c2eb12a79$var$get_recommendations(merchant, request)));
|
|
14890
|
+
const lists = answers.filter(answer => !!answer).map(answer => answer.products);
|
|
14891
|
+
if (!lists.length) return undefined;
|
|
14892
|
+
const products = lists.length > 1 ? $e8c6cfefe84af5d7$export$9af50be6508dcd00(lists, Math.max(...lists.map(list => list.length))) : lists[0];
|
|
14893
|
+
return $2573fc0c2eb12a79$var$to_displays(products);
|
|
14894
|
+
}
|
|
14062
14895
|
async function $087d5425868835e3$export$58e808b1db15d3bc(options) {
|
|
14896
|
+
if (options.api === "v4") return await $087d5425868835e3$var$fetch_native(options);
|
|
14063
14897
|
const headers = options.headers;
|
|
14064
14898
|
const product_id = options.productId || options.product_id; // Second fallback here is just because there was very little missing to make this work with snake_case input and in case someone puts in snake case'd stuff already (preview browser did) we can easily not break it
|
|
14065
14899
|
const cleaned_up_options = $52FdA$depictaiutilishared.snakeCasifyObject(options);
|
|
14066
14900
|
delete cleaned_up_options.headers;
|
|
14067
14901
|
delete cleaned_up_options.product_id;
|
|
14902
|
+
delete cleaned_up_options.api;
|
|
14068
14903
|
cleaned_up_options.session_id || (cleaned_up_options.session_id = $52FdA$depictaiutilishared.get_session_id());
|
|
14069
14904
|
if (product_id && !cleaned_up_options.product_ids) cleaned_up_options.product_ids = [product_id];
|
|
14070
14905
|
const options_to_send = cleaned_up_options;
|
|
@@ -14087,6 +14922,33 @@ async function $087d5425868835e3$export$58e808b1db15d3bc(options) {
|
|
|
14087
14922
|
return ((_decoded = decoded) === null || _decoded === void 0 ? void 0 : _decoded.displays) || [];
|
|
14088
14923
|
});
|
|
14089
14924
|
}
|
|
14925
|
+
async function $087d5425868835e3$var$fetch_native(options) {
|
|
14926
|
+
const {
|
|
14927
|
+
merchant: merchant,
|
|
14928
|
+
market: market,
|
|
14929
|
+
locale: locale,
|
|
14930
|
+
type: type,
|
|
14931
|
+
headers: headers,
|
|
14932
|
+
categoryId: categoryId,
|
|
14933
|
+
productIds: productIds
|
|
14934
|
+
} = options;
|
|
14935
|
+
if (headers) $52FdA$depictaiutilishared.dwarn("fetchDepictRecommendations: headers aren't sent to the native V4 API", headers);
|
|
14936
|
+
try {
|
|
14937
|
+
return await $2573fc0c2eb12a79$export$656ee5c46d5d1eda({
|
|
14938
|
+
merchant: merchant,
|
|
14939
|
+
market: market,
|
|
14940
|
+
locale: locale,
|
|
14941
|
+
type: type,
|
|
14942
|
+
categoryId: categoryId,
|
|
14943
|
+
productId: options.productId || options.product_id,
|
|
14944
|
+
productIds: productIds,
|
|
14945
|
+
limit: options.limit
|
|
14946
|
+
});
|
|
14947
|
+
} catch (e) {
|
|
14948
|
+
$52FdA$depictaiutilishared.dlog("fetch_native_recommendations threw", e);
|
|
14949
|
+
return [];
|
|
14950
|
+
}
|
|
14951
|
+
}
|
|
14090
14952
|
var $0c91ea7c14692db9$var$_tmpl$ = /*#__PURE__*/$52FdA$solidjsweb.template(`<div class="sort-and-filter-buttons fake"aria-hidden=true style=position:absolute;z-index:-1;pointer-events:none;opacity:0><div class=outer><div class=inner><!$><!/><!$><!/><!$><!/>`);
|
|
14091
14953
|
const $0c91ea7c14692db9$export$824dde41348efed1 = /*@__PURE__*/(() => {
|
|
14092
14954
|
const actual_function = _ref => {
|
|
@@ -14395,6 +15257,11 @@ function $e270e9f953fcbc58$var$_classPrivateMethodGet(receiver, privateSet, fn)
|
|
|
14395
15257
|
}
|
|
14396
15258
|
const $e270e9f953fcbc58$var$v3_base_url = (0, $52FdA$depictaiutilishared.base_url) + "/v3/";
|
|
14397
15259
|
const $e270e9f953fcbc58$var$search_base_url = $e270e9f953fcbc58$var$v3_base_url + "search/";
|
|
15260
|
+
/**
|
|
15261
|
+
* One read DepictAPI makes, as the transport sees it. `request_` is the v3 request as DepictAPI would send it (with
|
|
15262
|
+
* session_id and metadata added), `body_` its JSON. A transport answers with the v3-shaped JSON response, or undefined
|
|
15263
|
+
* when the request failed (DepictAPI then serves its fallback response).
|
|
15264
|
+
*/
|
|
14398
15265
|
var $e270e9f953fcbc58$var$_supports_finalization_registry = /*#__PURE__*/new WeakMap();
|
|
14399
15266
|
var $e270e9f953fcbc58$var$_cache_objs = /*#__PURE__*/new WeakMap();
|
|
14400
15267
|
var $e270e9f953fcbc58$var$_get_cache_obj_for_endpoint = /*#__PURE__*/new WeakSet();
|
|
@@ -14409,7 +15276,29 @@ class $e270e9f953fcbc58$export$e015ed2f2950f2e3 {
|
|
|
14409
15276
|
* Runs the displayTransformer for the suggest endpoints results
|
|
14410
15277
|
*/ /**
|
|
14411
15278
|
* rest = everything except query suggestions
|
|
14412
|
-
*/
|
|
15279
|
+
*/ /**
|
|
15280
|
+
* The network step of every read: sends `call` to the v3 API and returns the decoded JSON, or undefined when the
|
|
15281
|
+
* request failed. NativeDepictAPI overrides this to read the native V4 API instead and map its answers to v3 shapes,
|
|
15282
|
+
* so caching, display transformers and fallbacks stay the same for both.
|
|
15283
|
+
*/ // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
15284
|
+
async request_raw_(call) {
|
|
15285
|
+
const {
|
|
15286
|
+
endpoint_: endpoint_,
|
|
15287
|
+
method_: method_,
|
|
15288
|
+
request_: request_,
|
|
15289
|
+
body_: body_
|
|
15290
|
+
} = call;
|
|
15291
|
+
const is_post = method_ === "POST";
|
|
15292
|
+
const url_to_request = is_post ? endpoint_ : $52FdA$depictaiutilishared.make_url_with_query_params(endpoint_, request_);
|
|
15293
|
+
const api_response = await $52FdA$depictaiutilishared.fetch_retry($52FdA$depictaiutilishared.add_version_query_params(url_to_request), {
|
|
15294
|
+
method: method_,
|
|
15295
|
+
...(is_post ? {
|
|
15296
|
+
body: body_
|
|
15297
|
+
} : {})
|
|
15298
|
+
});
|
|
15299
|
+
if (!api_response || call.kind_ !== "suggest" && api_response.status !== 200) return undefined;
|
|
15300
|
+
return await api_response.json();
|
|
15301
|
+
}
|
|
14413
15302
|
constructor(options) {
|
|
14414
15303
|
$e270e9f953fcbc58$var$_classPrivateMethodInitSpec(this, $e270e9f953fcbc58$var$_cached_request);
|
|
14415
15304
|
$e270e9f953fcbc58$var$_classPrivateMethodInitSpec(this, $e270e9f953fcbc58$var$_run_display_transformers_for_rest);
|
|
@@ -14459,11 +15348,13 @@ class $e270e9f953fcbc58$export$e015ed2f2950f2e3 {
|
|
|
14459
15348
|
const request = metaData ? Object.assign(with_ids, {
|
|
14460
15349
|
metadata: JSON.stringify(metaData)
|
|
14461
15350
|
}) : with_ids;
|
|
14462
|
-
const url = $52FdA$depictaiutilishared.make_url_with_query_params($e270e9f953fcbc58$var$search_base_url + "suggestions", request);
|
|
14463
|
-
const results = await $52FdA$depictaiutilishared.fetch_retry($52FdA$depictaiutilishared.add_version_query_params(url));
|
|
14464
15351
|
attempt_to_return_api_response: {
|
|
14465
|
-
|
|
14466
|
-
|
|
15352
|
+
const decoded_json = await this.request_raw_({
|
|
15353
|
+
kind_: "suggest",
|
|
15354
|
+
endpoint_: $e270e9f953fcbc58$var$search_base_url + "suggestions",
|
|
15355
|
+
method_: "GET",
|
|
15356
|
+
request_: request
|
|
15357
|
+
});
|
|
14467
15358
|
if (!Array.isArray(decoded_json === null || decoded_json === void 0 ? void 0 : decoded_json.suggestions)) break attempt_to_return_api_response;
|
|
14468
15359
|
try {
|
|
14469
15360
|
return await $e270e9f953fcbc58$var$_classPrivateMethodGet(this, $e270e9f953fcbc58$var$_run_url_creator_for_suggest, $e270e9f953fcbc58$var$_run_url_creator_for_suggest2).call(this, input_req.merchant, input_req.market, input_req.locale, decoded_json);
|
|
@@ -14480,6 +15371,7 @@ class $e270e9f953fcbc58$export$e015ed2f2950f2e3 {
|
|
|
14480
15371
|
async query(input_req) {
|
|
14481
15372
|
return await $e270e9f953fcbc58$var$_classPrivateMethodGet(this, $e270e9f953fcbc58$var$_cached_request, $e270e9f953fcbc58$var$_cached_request2).call(this, {
|
|
14482
15373
|
endpoint_: $e270e9f953fcbc58$var$search_base_url + "results",
|
|
15374
|
+
kind_: "search",
|
|
14483
15375
|
input_req_: input_req,
|
|
14484
15376
|
fallback_response_: () => ({
|
|
14485
15377
|
"n_hits": 0,
|
|
@@ -14500,6 +15392,9 @@ class $e270e9f953fcbc58$export$e015ed2f2950f2e3 {
|
|
|
14500
15392
|
return await $e270e9f953fcbc58$var$_classPrivateMethodGet(this, $e270e9f953fcbc58$var$_cached_request, $e270e9f953fcbc58$var$_cached_request2).call(this, {
|
|
14501
15393
|
endpoint_: $e270e9f953fcbc58$var$v3_base_url + "listings/" + (id_type_ === $c3739e86187f2054$export$5aae649db1b959fc ? "external_id/" : "") + encodeURIComponent(id_to_query_for_),
|
|
14502
15394
|
input_req_: input_req,
|
|
15395
|
+
kind_: "listing",
|
|
15396
|
+
id_to_query_for_: id_to_query_for_,
|
|
15397
|
+
id_type_: id_type_,
|
|
14503
15398
|
fallback_response_: () => ({
|
|
14504
15399
|
listing_id: "",
|
|
14505
15400
|
listing_type: "category",
|
|
@@ -14527,6 +15422,9 @@ class $e270e9f953fcbc58$export$e015ed2f2950f2e3 {
|
|
|
14527
15422
|
endpoint_: $e270e9f953fcbc58$var$v3_base_url + "listings/" + (id_type_ === $c3739e86187f2054$export$5aae649db1b959fc ? "external_id/" : "") + encodeURIComponent(id_to_query_for_) + "/products",
|
|
14528
15423
|
input_req_: input_req_,
|
|
14529
15424
|
currentListingForTransformer_: currentListingForTransformer_,
|
|
15425
|
+
kind_: "listing_products",
|
|
15426
|
+
id_to_query_for_: id_to_query_for_,
|
|
15427
|
+
id_type_: id_type_,
|
|
14530
15428
|
fallback_response_: () => ({
|
|
14531
15429
|
"n_hits": 0,
|
|
14532
15430
|
"displays": [],
|
|
@@ -14540,6 +15438,7 @@ class $e270e9f953fcbc58$export$e015ed2f2950f2e3 {
|
|
|
14540
15438
|
async get_recommended(input_req) {
|
|
14541
15439
|
return await $e270e9f953fcbc58$var$_classPrivateMethodGet(this, $e270e9f953fcbc58$var$_cached_request, $e270e9f953fcbc58$var$_cached_request2).call(this, {
|
|
14542
15440
|
endpoint_: $e270e9f953fcbc58$var$search_base_url + "related",
|
|
15441
|
+
kind_: "related",
|
|
14543
15442
|
input_req_: input_req,
|
|
14544
15443
|
fallback_response_: () => ({
|
|
14545
15444
|
displays: []
|
|
@@ -14654,7 +15553,10 @@ async function $e270e9f953fcbc58$var$_cached_request2(_ref4) {
|
|
|
14654
15553
|
input_req_: input_req_,
|
|
14655
15554
|
fallback_response_: fallback_response_,
|
|
14656
15555
|
method_ = "POST",
|
|
14657
|
-
currentListingForTransformer_: currentListingForTransformer_
|
|
15556
|
+
currentListingForTransformer_: currentListingForTransformer_,
|
|
15557
|
+
kind_: kind_,
|
|
15558
|
+
id_to_query_for_: id_to_query_for_,
|
|
15559
|
+
id_type_: id_type_
|
|
14658
15560
|
} = _ref4;
|
|
14659
15561
|
const cache_obj = $e270e9f953fcbc58$var$_classPrivateMethodGet(this, $e270e9f953fcbc58$var$_get_cache_obj_for_endpoint, $e270e9f953fcbc58$var$_get_cache_obj_for_endpoint2).call(this, endpoint_);
|
|
14660
15562
|
const with_ids = $parcel$interopDefault($52FdA$babelruntimehelpersclassPrivateFieldGet)(this, $e270e9f953fcbc58$var$_add_ids_to_request).call(this, input_req_);
|
|
@@ -14671,19 +15573,19 @@ async function $e270e9f953fcbc58$var$_cached_request2(_ref4) {
|
|
|
14671
15573
|
let resolve_in_progress;
|
|
14672
15574
|
cache_obj.in_progress_[body] = new Promise(r => resolve_in_progress = r);
|
|
14673
15575
|
try {
|
|
14674
|
-
const is_post = method_ === "POST";
|
|
14675
|
-
const url_to_request = is_post ? endpoint_ : $52FdA$depictaiutilishared.make_url_with_query_params(endpoint_, sorted_request);
|
|
14676
|
-
const api_response = await $52FdA$depictaiutilishared.fetch_retry($52FdA$depictaiutilishared.add_version_query_params(url_to_request), {
|
|
14677
|
-
method: method_,
|
|
14678
|
-
...(is_post ? {
|
|
14679
|
-
body: body
|
|
14680
|
-
} : {})
|
|
14681
|
-
});
|
|
14682
15576
|
return_successfully: {
|
|
14683
|
-
if (!api_response || api_response.status !== 200) break return_successfully;
|
|
14684
15577
|
let result;
|
|
14685
15578
|
try {
|
|
14686
|
-
const unmodified_result = await
|
|
15579
|
+
const unmodified_result = await this.request_raw_({
|
|
15580
|
+
kind_: kind_,
|
|
15581
|
+
endpoint_: endpoint_,
|
|
15582
|
+
method_: method_,
|
|
15583
|
+
request_: sorted_request,
|
|
15584
|
+
body_: body,
|
|
15585
|
+
id_to_query_for_: id_to_query_for_,
|
|
15586
|
+
id_type_: id_type_
|
|
15587
|
+
});
|
|
15588
|
+
if (unmodified_result === undefined) break return_successfully;
|
|
14687
15589
|
result = await $e270e9f953fcbc58$var$_classPrivateMethodGet(this, $e270e9f953fcbc58$var$_run_display_transformers_for_rest, $e270e9f953fcbc58$var$_run_display_transformers_for_rest2).call(this, input_req_.merchant, input_req_.market, input_req_.locale, unmodified_result, currentListingForTransformer_);
|
|
14688
15590
|
} catch (e) {
|
|
14689
15591
|
$52FdA$depictaiutilishared.dwarn("displayTransformer or json decoding failed", e);
|
|
@@ -14711,6 +15613,283 @@ async function $e270e9f953fcbc58$var$_cached_request2(_ref4) {
|
|
|
14711
15613
|
delete cache_obj.in_progress_[body];
|
|
14712
15614
|
}
|
|
14713
15615
|
}
|
|
15616
|
+
function $5f20a6104f835562$var$_classPrivateMethodInitSpec(obj, privateSet) {
|
|
15617
|
+
$5f20a6104f835562$var$_checkPrivateRedeclaration(obj, privateSet);
|
|
15618
|
+
privateSet.add(obj);
|
|
15619
|
+
}
|
|
15620
|
+
function $5f20a6104f835562$var$_classPrivateFieldInitSpec(obj, privateMap, value) {
|
|
15621
|
+
$5f20a6104f835562$var$_checkPrivateRedeclaration(obj, privateMap);
|
|
15622
|
+
privateMap.set(obj, value);
|
|
15623
|
+
}
|
|
15624
|
+
function $5f20a6104f835562$var$_checkPrivateRedeclaration(obj, privateCollection) {
|
|
15625
|
+
if (privateCollection.has(obj)) throw new TypeError("Cannot initialize the same private elements twice on an object");
|
|
15626
|
+
}
|
|
15627
|
+
function $5f20a6104f835562$var$_classPrivateMethodGet(receiver, privateSet, fn) {
|
|
15628
|
+
if (!privateSet.has(receiver)) throw new TypeError("attempted to get private field on non-instance");
|
|
15629
|
+
return fn;
|
|
15630
|
+
}
|
|
15631
|
+
/** V4 browse's largest page; a bigger v3 page is V4's pages chained by their cursors, as the facade does. */
|
|
15632
|
+
const $5f20a6104f835562$var$BROWSE_MAX_LIMIT = 100;
|
|
15633
|
+
/** V4 browse's page size without a limit, and v3's. */
|
|
15634
|
+
const $5f20a6104f835562$var$DEFAULT_LIMIT = 24;
|
|
15635
|
+
/** A query with no letter or digit browses the catalogue instead of returning an empty grid, as on v3. */
|
|
15636
|
+
const $5f20a6104f835562$var$HAS_LETTER_OR_DIGIT = /[0-9A-Za-z\xAA\xB2\xB3\xB5\xB9\xBA\xBC-\xBE\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u0660-\u0669\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07C0-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u0870-\u0887\u0889-\u088E\u08A0-\u08C9\u0904-\u0939\u093D\u0950\u0958-\u0961\u0966-\u096F\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09E6-\u09F1\u09F4-\u09F9\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A66-\u0A6F\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AE6-\u0AEF\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B66-\u0B6F\u0B71-\u0B77\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0BE6-\u0BF2\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C5D\u0C60\u0C61\u0C66-\u0C6F\u0C78-\u0C7E\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDD\u0CDE\u0CE0\u0CE1\u0CE6-\u0CEF\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D58-\u0D61\u0D66-\u0D78\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DE6-\u0DEF\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F20-\u0F33\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F-\u1049\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u1090-\u1099\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1369-\u137C\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u17E0-\u17E9\u17F0-\u17F9\u1810-\u1819\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19DA\u1A00-\u1A16\u1A20-\u1A54\u1A80-\u1A89\u1A90-\u1A99\u1AA7\u1B05-\u1B33\u1B45-\u1B4C\u1B50-\u1B59\u1B83-\u1BA0\u1BAE-\u1BE5\u1C00-\u1C23\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2070\u2071\u2074-\u2079\u207F-\u2089\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2150-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2C00-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2CFD\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u3192-\u3195\u31A0-\u31BF\u31F0-\u31FF\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7CA\uA7D0\uA7D1\uA7D3\uA7D5-\uA7D9\uA7F2-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA830-\uA835\uA840-\uA873\uA882-\uA8B3\uA8D0-\uA8D9\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA900-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF-\uA9D9\uA9E0-\uA9E4\uA9E6-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA50-\uAA59\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC\u{10000}-\u{1000B}\u{1000D}-\u{10026}\u{10028}-\u{1003A}\u{1003C}\u{1003D}\u{1003F}-\u{1004D}\u{10050}-\u{1005D}\u{10080}-\u{100FA}\u{10107}-\u{10133}\u{10140}-\u{10178}\u{1018A}\u{1018B}\u{10280}-\u{1029C}\u{102A0}-\u{102D0}\u{102E1}-\u{102FB}\u{10300}-\u{10323}\u{1032D}-\u{1034A}\u{10350}-\u{10375}\u{10380}-\u{1039D}\u{103A0}-\u{103C3}\u{103C8}-\u{103CF}\u{103D1}-\u{103D5}\u{10400}-\u{1049D}\u{104A0}-\u{104A9}\u{104B0}-\u{104D3}\u{104D8}-\u{104FB}\u{10500}-\u{10527}\u{10530}-\u{10563}\u{10570}-\u{1057A}\u{1057C}-\u{1058A}\u{1058C}-\u{10592}\u{10594}\u{10595}\u{10597}-\u{105A1}\u{105A3}-\u{105B1}\u{105B3}-\u{105B9}\u{105BB}\u{105BC}\u{10600}-\u{10736}\u{10740}-\u{10755}\u{10760}-\u{10767}\u{10780}-\u{10785}\u{10787}-\u{107B0}\u{107B2}-\u{107BA}\u{10800}-\u{10805}\u{10808}\u{1080A}-\u{10835}\u{10837}\u{10838}\u{1083C}\u{1083F}-\u{10855}\u{10858}-\u{10876}\u{10879}-\u{1089E}\u{108A7}-\u{108AF}\u{108E0}-\u{108F2}\u{108F4}\u{108F5}\u{108FB}-\u{1091B}\u{10920}-\u{10939}\u{10980}-\u{109B7}\u{109BC}-\u{109CF}\u{109D2}-\u{10A00}\u{10A10}-\u{10A13}\u{10A15}-\u{10A17}\u{10A19}-\u{10A35}\u{10A40}-\u{10A48}\u{10A60}-\u{10A7E}\u{10A80}-\u{10A9F}\u{10AC0}-\u{10AC7}\u{10AC9}-\u{10AE4}\u{10AEB}-\u{10AEF}\u{10B00}-\u{10B35}\u{10B40}-\u{10B55}\u{10B58}-\u{10B72}\u{10B78}-\u{10B91}\u{10BA9}-\u{10BAF}\u{10C00}-\u{10C48}\u{10C80}-\u{10CB2}\u{10CC0}-\u{10CF2}\u{10CFA}-\u{10D23}\u{10D30}-\u{10D39}\u{10E60}-\u{10E7E}\u{10E80}-\u{10EA9}\u{10EB0}\u{10EB1}\u{10F00}-\u{10F27}\u{10F30}-\u{10F45}\u{10F51}-\u{10F54}\u{10F70}-\u{10F81}\u{10FB0}-\u{10FCB}\u{10FE0}-\u{10FF6}\u{11003}-\u{11037}\u{11052}-\u{1106F}\u{11071}\u{11072}\u{11075}\u{11083}-\u{110AF}\u{110D0}-\u{110E8}\u{110F0}-\u{110F9}\u{11103}-\u{11126}\u{11136}-\u{1113F}\u{11144}\u{11147}\u{11150}-\u{11172}\u{11176}\u{11183}-\u{111B2}\u{111C1}-\u{111C4}\u{111D0}-\u{111DA}\u{111DC}\u{111E1}-\u{111F4}\u{11200}-\u{11211}\u{11213}-\u{1122B}\u{1123F}\u{11240}\u{11280}-\u{11286}\u{11288}\u{1128A}-\u{1128D}\u{1128F}-\u{1129D}\u{1129F}-\u{112A8}\u{112B0}-\u{112DE}\u{112F0}-\u{112F9}\u{11305}-\u{1130C}\u{1130F}\u{11310}\u{11313}-\u{11328}\u{1132A}-\u{11330}\u{11332}\u{11333}\u{11335}-\u{11339}\u{1133D}\u{11350}\u{1135D}-\u{11361}\u{11400}-\u{11434}\u{11447}-\u{1144A}\u{11450}-\u{11459}\u{1145F}-\u{11461}\u{11480}-\u{114AF}\u{114C4}\u{114C5}\u{114C7}\u{114D0}-\u{114D9}\u{11580}-\u{115AE}\u{115D8}-\u{115DB}\u{11600}-\u{1162F}\u{11644}\u{11650}-\u{11659}\u{11680}-\u{116AA}\u{116B8}\u{116C0}-\u{116C9}\u{11700}-\u{1171A}\u{11730}-\u{1173B}\u{11740}-\u{11746}\u{11800}-\u{1182B}\u{118A0}-\u{118F2}\u{118FF}-\u{11906}\u{11909}\u{1190C}-\u{11913}\u{11915}\u{11916}\u{11918}-\u{1192F}\u{1193F}\u{11941}\u{11950}-\u{11959}\u{119A0}-\u{119A7}\u{119AA}-\u{119D0}\u{119E1}\u{119E3}\u{11A00}\u{11A0B}-\u{11A32}\u{11A3A}\u{11A50}\u{11A5C}-\u{11A89}\u{11A9D}\u{11AB0}-\u{11AF8}\u{11C00}-\u{11C08}\u{11C0A}-\u{11C2E}\u{11C40}\u{11C50}-\u{11C6C}\u{11C72}-\u{11C8F}\u{11D00}-\u{11D06}\u{11D08}\u{11D09}\u{11D0B}-\u{11D30}\u{11D46}\u{11D50}-\u{11D59}\u{11D60}-\u{11D65}\u{11D67}\u{11D68}\u{11D6A}-\u{11D89}\u{11D98}\u{11DA0}-\u{11DA9}\u{11EE0}-\u{11EF2}\u{11F02}\u{11F04}-\u{11F10}\u{11F12}-\u{11F33}\u{11F50}-\u{11F59}\u{11FB0}\u{11FC0}-\u{11FD4}\u{12000}-\u{12399}\u{12400}-\u{1246E}\u{12480}-\u{12543}\u{12F90}-\u{12FF0}\u{13000}-\u{1342F}\u{13441}-\u{13446}\u{14400}-\u{14646}\u{16800}-\u{16A38}\u{16A40}-\u{16A5E}\u{16A60}-\u{16A69}\u{16A70}-\u{16ABE}\u{16AC0}-\u{16AC9}\u{16AD0}-\u{16AED}\u{16B00}-\u{16B2F}\u{16B40}-\u{16B43}\u{16B50}-\u{16B59}\u{16B5B}-\u{16B61}\u{16B63}-\u{16B77}\u{16B7D}-\u{16B8F}\u{16E40}-\u{16E96}\u{16F00}-\u{16F4A}\u{16F50}\u{16F93}-\u{16F9F}\u{16FE0}\u{16FE1}\u{16FE3}\u{17000}-\u{187F7}\u{18800}-\u{18CD5}\u{18D00}-\u{18D08}\u{1AFF0}-\u{1AFF3}\u{1AFF5}-\u{1AFFB}\u{1AFFD}\u{1AFFE}\u{1B000}-\u{1B122}\u{1B132}\u{1B150}-\u{1B152}\u{1B155}\u{1B164}-\u{1B167}\u{1B170}-\u{1B2FB}\u{1BC00}-\u{1BC6A}\u{1BC70}-\u{1BC7C}\u{1BC80}-\u{1BC88}\u{1BC90}-\u{1BC99}\u{1D2C0}-\u{1D2D3}\u{1D2E0}-\u{1D2F3}\u{1D360}-\u{1D378}\u{1D400}-\u{1D454}\u{1D456}-\u{1D49C}\u{1D49E}\u{1D49F}\u{1D4A2}\u{1D4A5}\u{1D4A6}\u{1D4A9}-\u{1D4AC}\u{1D4AE}-\u{1D4B9}\u{1D4BB}\u{1D4BD}-\u{1D4C3}\u{1D4C5}-\u{1D505}\u{1D507}-\u{1D50A}\u{1D50D}-\u{1D514}\u{1D516}-\u{1D51C}\u{1D51E}-\u{1D539}\u{1D53B}-\u{1D53E}\u{1D540}-\u{1D544}\u{1D546}\u{1D54A}-\u{1D550}\u{1D552}-\u{1D6A5}\u{1D6A8}-\u{1D6C0}\u{1D6C2}-\u{1D6DA}\u{1D6DC}-\u{1D6FA}\u{1D6FC}-\u{1D714}\u{1D716}-\u{1D734}\u{1D736}-\u{1D74E}\u{1D750}-\u{1D76E}\u{1D770}-\u{1D788}\u{1D78A}-\u{1D7A8}\u{1D7AA}-\u{1D7C2}\u{1D7C4}-\u{1D7CB}\u{1D7CE}-\u{1D7FF}\u{1DF00}-\u{1DF1E}\u{1DF25}-\u{1DF2A}\u{1E030}-\u{1E06D}\u{1E100}-\u{1E12C}\u{1E137}-\u{1E13D}\u{1E140}-\u{1E149}\u{1E14E}\u{1E290}-\u{1E2AD}\u{1E2C0}-\u{1E2EB}\u{1E2F0}-\u{1E2F9}\u{1E4D0}-\u{1E4EB}\u{1E4F0}-\u{1E4F9}\u{1E7E0}-\u{1E7E6}\u{1E7E8}-\u{1E7EB}\u{1E7ED}\u{1E7EE}\u{1E7F0}-\u{1E7FE}\u{1E800}-\u{1E8C4}\u{1E8C7}-\u{1E8CF}\u{1E900}-\u{1E943}\u{1E94B}\u{1E950}-\u{1E959}\u{1EC71}-\u{1ECAB}\u{1ECAD}-\u{1ECAF}\u{1ECB1}-\u{1ECB4}\u{1ED01}-\u{1ED2D}\u{1ED2F}-\u{1ED3D}\u{1EE00}-\u{1EE03}\u{1EE05}-\u{1EE1F}\u{1EE21}\u{1EE22}\u{1EE24}\u{1EE27}\u{1EE29}-\u{1EE32}\u{1EE34}-\u{1EE37}\u{1EE39}\u{1EE3B}\u{1EE42}\u{1EE47}\u{1EE49}\u{1EE4B}\u{1EE4D}-\u{1EE4F}\u{1EE51}\u{1EE52}\u{1EE54}\u{1EE57}\u{1EE59}\u{1EE5B}\u{1EE5D}\u{1EE5F}\u{1EE61}\u{1EE62}\u{1EE64}\u{1EE67}-\u{1EE6A}\u{1EE6C}-\u{1EE72}\u{1EE74}-\u{1EE77}\u{1EE79}-\u{1EE7C}\u{1EE7E}\u{1EE80}-\u{1EE89}\u{1EE8B}-\u{1EE9B}\u{1EEA1}-\u{1EEA3}\u{1EEA5}-\u{1EEA9}\u{1EEAB}-\u{1EEBB}\u{1F100}-\u{1F10C}\u{1FBF0}-\u{1FBF9}\u{20000}-\u{2A6DF}\u{2A700}-\u{2B739}\u{2B740}-\u{2B81D}\u{2B820}-\u{2CEA1}\u{2CEB0}-\u{2EBE0}\u{2F800}-\u{2FA1D}\u{30000}-\u{3134A}\u{31350}-\u{323AF}]/u;
|
|
15637
|
+
/** Which API an SDK reads: `v3` (the default) or the native V4 API (`https://api.depict.ai/v4/{merchant}/…`). */
|
|
15638
|
+
var $5f20a6104f835562$var$_facet_indices = /*#__PURE__*/new WeakMap();
|
|
15639
|
+
var $5f20a6104f835562$var$_learned = /*#__PURE__*/new WeakMap();
|
|
15640
|
+
var $5f20a6104f835562$var$_cursor_offsets = /*#__PURE__*/new WeakMap();
|
|
15641
|
+
var $5f20a6104f835562$var$_ancestor_lookups = /*#__PURE__*/new WeakMap();
|
|
15642
|
+
var $5f20a6104f835562$var$_rejected = /*#__PURE__*/new WeakMap();
|
|
15643
|
+
var $5f20a6104f835562$var$_merchant_url = /*#__PURE__*/new WeakSet();
|
|
15644
|
+
var $5f20a6104f835562$var$_get_json = /*#__PURE__*/new WeakSet();
|
|
15645
|
+
var $5f20a6104f835562$var$_get_answer = /*#__PURE__*/new WeakSet();
|
|
15646
|
+
var $5f20a6104f835562$var$_facet_index = /*#__PURE__*/new WeakSet();
|
|
15647
|
+
var $5f20a6104f835562$var$_browse_page = /*#__PURE__*/new WeakSet();
|
|
15648
|
+
var $5f20a6104f835562$var$_browse_answer = /*#__PURE__*/new WeakSet();
|
|
15649
|
+
var $5f20a6104f835562$var$_rejected_clauses = /*#__PURE__*/new WeakSet();
|
|
15650
|
+
var $5f20a6104f835562$var$_browse = /*#__PURE__*/new WeakSet();
|
|
15651
|
+
var $5f20a6104f835562$var$_listing = /*#__PURE__*/new WeakSet();
|
|
15652
|
+
var $5f20a6104f835562$var$_suggest = /*#__PURE__*/new WeakSet();
|
|
15653
|
+
var $5f20a6104f835562$var$_ancestors = /*#__PURE__*/new WeakSet();
|
|
15654
|
+
class $5f20a6104f835562$export$721afe49a594bed extends (0, $e270e9f953fcbc58$export$e015ed2f2950f2e3) {
|
|
15655
|
+
/** Facets served so far, per merchant, market and locale, to resolve v3 filter fields (group titles) to V4 fields. */ /** Browses whose facets were read only to resolve filter fields, so each is read at most once. */ /** How many products came before each cursor V4 handed out, for the lower-bound count when `total` is absent. */ /** Each listing's ancestors from the listing tree, per merchant, market and locale, read once a page load. */ /** Filter clauses V4 refused (`unknown_filter_field`, `invalid_filter`), per merchant, market and locale. */constructor(options) {
|
|
15656
|
+
super(options);
|
|
15657
|
+
$5f20a6104f835562$var$_classPrivateMethodInitSpec(this, $5f20a6104f835562$var$_ancestors);
|
|
15658
|
+
$5f20a6104f835562$var$_classPrivateMethodInitSpec(this, $5f20a6104f835562$var$_suggest);
|
|
15659
|
+
$5f20a6104f835562$var$_classPrivateMethodInitSpec(this, $5f20a6104f835562$var$_listing);
|
|
15660
|
+
$5f20a6104f835562$var$_classPrivateMethodInitSpec(this, $5f20a6104f835562$var$_browse);
|
|
15661
|
+
$5f20a6104f835562$var$_classPrivateMethodInitSpec(this, $5f20a6104f835562$var$_rejected_clauses);
|
|
15662
|
+
$5f20a6104f835562$var$_classPrivateMethodInitSpec(this, $5f20a6104f835562$var$_browse_answer);
|
|
15663
|
+
$5f20a6104f835562$var$_classPrivateMethodInitSpec(this, $5f20a6104f835562$var$_browse_page);
|
|
15664
|
+
$5f20a6104f835562$var$_classPrivateMethodInitSpec(this, $5f20a6104f835562$var$_facet_index);
|
|
15665
|
+
$5f20a6104f835562$var$_classPrivateMethodInitSpec(this, $5f20a6104f835562$var$_get_answer);
|
|
15666
|
+
$5f20a6104f835562$var$_classPrivateMethodInitSpec(this, $5f20a6104f835562$var$_get_json);
|
|
15667
|
+
$5f20a6104f835562$var$_classPrivateMethodInitSpec(this, $5f20a6104f835562$var$_merchant_url);
|
|
15668
|
+
$5f20a6104f835562$var$_classPrivateFieldInitSpec(this, $5f20a6104f835562$var$_facet_indices, {
|
|
15669
|
+
writable: true,
|
|
15670
|
+
value: new Map()
|
|
15671
|
+
});
|
|
15672
|
+
$5f20a6104f835562$var$_classPrivateFieldInitSpec(this, $5f20a6104f835562$var$_learned, {
|
|
15673
|
+
writable: true,
|
|
15674
|
+
value: new Set()
|
|
15675
|
+
});
|
|
15676
|
+
$5f20a6104f835562$var$_classPrivateFieldInitSpec(this, $5f20a6104f835562$var$_cursor_offsets, {
|
|
15677
|
+
writable: true,
|
|
15678
|
+
value: new Map()
|
|
15679
|
+
});
|
|
15680
|
+
$5f20a6104f835562$var$_classPrivateFieldInitSpec(this, $5f20a6104f835562$var$_ancestor_lookups, {
|
|
15681
|
+
writable: true,
|
|
15682
|
+
value: new Map()
|
|
15683
|
+
});
|
|
15684
|
+
$5f20a6104f835562$var$_classPrivateFieldInitSpec(this, $5f20a6104f835562$var$_rejected, {
|
|
15685
|
+
writable: true,
|
|
15686
|
+
value: new Map()
|
|
15687
|
+
});
|
|
15688
|
+
$52FdA$depictaiutilishared.set_event_api("v4");
|
|
15689
|
+
}
|
|
15690
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
15691
|
+
async request_raw_(call) {
|
|
15692
|
+
switch (call.kind_) {
|
|
15693
|
+
case "search":
|
|
15694
|
+
return await $5f20a6104f835562$var$_classPrivateMethodGet(this, $5f20a6104f835562$var$_browse, $5f20a6104f835562$var$_browse2).call(this, "search", call.request_);
|
|
15695
|
+
case "listing_products":
|
|
15696
|
+
return await $5f20a6104f835562$var$_classPrivateMethodGet(this, $5f20a6104f835562$var$_browse, $5f20a6104f835562$var$_browse2).call(this, "listing", call.request_, {
|
|
15697
|
+
[call.id_type_ === $c3739e86187f2054$export$5aae649db1b959fc ? "external_id" : "id"]: call.id_to_query_for_
|
|
15698
|
+
});
|
|
15699
|
+
case "listing":
|
|
15700
|
+
return await $5f20a6104f835562$var$_classPrivateMethodGet(this, $5f20a6104f835562$var$_listing, $5f20a6104f835562$var$_listing2).call(this, call);
|
|
15701
|
+
case "suggest":
|
|
15702
|
+
return await $5f20a6104f835562$var$_classPrivateMethodGet(this, $5f20a6104f835562$var$_suggest, $5f20a6104f835562$var$_suggest2).call(this, call.request_);
|
|
15703
|
+
case "related":
|
|
15704
|
+
{
|
|
15705
|
+
const {
|
|
15706
|
+
merchant: merchant,
|
|
15707
|
+
market: market,
|
|
15708
|
+
locale: locale,
|
|
15709
|
+
query: query
|
|
15710
|
+
} = call.request_;
|
|
15711
|
+
const displays = await $2573fc0c2eb12a79$export$bd5f8a7d3e47a43d({
|
|
15712
|
+
merchant: merchant,
|
|
15713
|
+
market: market,
|
|
15714
|
+
locale: locale,
|
|
15715
|
+
query: query
|
|
15716
|
+
});
|
|
15717
|
+
return displays && {
|
|
15718
|
+
displays: displays
|
|
15719
|
+
};
|
|
15720
|
+
}
|
|
15721
|
+
}
|
|
15722
|
+
}
|
|
15723
|
+
}
|
|
15724
|
+
/** The v3 search or listing-products request DepictAPI hands its transport. */
|
|
15725
|
+
function $5f20a6104f835562$var$_merchant_url2(merchant, path) {
|
|
15726
|
+
return $8ad8c4b4b26ba277$export$b6dad15503f66988(merchant, path);
|
|
15727
|
+
}
|
|
15728
|
+
async function $5f20a6104f835562$var$_get_json2(url) {
|
|
15729
|
+
return (await $5f20a6104f835562$var$_classPrivateMethodGet(this, $5f20a6104f835562$var$_get_answer, $5f20a6104f835562$var$_get_answer2).call(this, url)).body_;
|
|
15730
|
+
}
|
|
15731
|
+
async function $5f20a6104f835562$var$_get_answer2(url) {
|
|
15732
|
+
return await $8ad8c4b4b26ba277$export$f035610fd74c541a(url);
|
|
15733
|
+
}
|
|
15734
|
+
function $5f20a6104f835562$var$_facet_index2(merchant, market, locale) {
|
|
15735
|
+
const key = JSON.stringify([merchant, market, locale]);
|
|
15736
|
+
let index = $parcel$interopDefault($52FdA$babelruntimehelpersclassPrivateFieldGet)(this, $5f20a6104f835562$var$_facet_indices).get(key);
|
|
15737
|
+
if (!index) $parcel$interopDefault($52FdA$babelruntimehelpersclassPrivateFieldGet)(this, $5f20a6104f835562$var$_facet_indices).set(key, index = new (0, $744a9d695dd21ed2$export$8d488bcc71d07ffb)());
|
|
15738
|
+
return index;
|
|
15739
|
+
}
|
|
15740
|
+
async function $5f20a6104f835562$var$_browse_page2(merchant, request) {
|
|
15741
|
+
return (await $5f20a6104f835562$var$_classPrivateMethodGet(this, $5f20a6104f835562$var$_browse_answer, $5f20a6104f835562$var$_browse_answer2).call(this, merchant, request)).body_;
|
|
15742
|
+
}
|
|
15743
|
+
async function $5f20a6104f835562$var$_browse_answer2(merchant, request) {
|
|
15744
|
+
return await $5f20a6104f835562$var$_classPrivateMethodGet(this, $5f20a6104f835562$var$_get_answer, $5f20a6104f835562$var$_get_answer2).call(this, $5f20a6104f835562$var$_classPrivateMethodGet(this, $5f20a6104f835562$var$_merchant_url, $5f20a6104f835562$var$_merchant_url2).call(this, merchant, "/browse") + "?" + $14bc537adeeadca4$export$7659319cdb555579(request));
|
|
15745
|
+
}
|
|
15746
|
+
function $5f20a6104f835562$var$_rejected_clauses2(merchant, market, locale) {
|
|
15747
|
+
const key = JSON.stringify([merchant, market, locale]);
|
|
15748
|
+
let rejected = $parcel$interopDefault($52FdA$babelruntimehelpersclassPrivateFieldGet)(this, $5f20a6104f835562$var$_rejected).get(key);
|
|
15749
|
+
if (!rejected) $parcel$interopDefault($52FdA$babelruntimehelpersclassPrivateFieldGet)(this, $5f20a6104f835562$var$_rejected).set(key, rejected = new Set());
|
|
15750
|
+
return rejected;
|
|
15751
|
+
}
|
|
15752
|
+
async function $5f20a6104f835562$var$_browse2(door, v3_request, listing) {
|
|
15753
|
+
var _v3_request$filters, _v3_request$limit;
|
|
15754
|
+
const {
|
|
15755
|
+
merchant: merchant,
|
|
15756
|
+
market: market
|
|
15757
|
+
} = v3_request;
|
|
15758
|
+
const locale = $14bc537adeeadca4$export$eb90c08da400512d(v3_request.locale);
|
|
15759
|
+
const query = door === "search" && v3_request.query && $5f20a6104f835562$var$HAS_LETTER_OR_DIGIT.test(v3_request.query) ? v3_request.query : undefined;
|
|
15760
|
+
const base = {
|
|
15761
|
+
market: market,
|
|
15762
|
+
...(locale ? {
|
|
15763
|
+
locale: locale
|
|
15764
|
+
} : {}),
|
|
15765
|
+
...(query ? {
|
|
15766
|
+
query: query
|
|
15767
|
+
} : {}),
|
|
15768
|
+
...(listing ? {
|
|
15769
|
+
listing: listing
|
|
15770
|
+
} : {})
|
|
15771
|
+
};
|
|
15772
|
+
const index = $5f20a6104f835562$var$_classPrivateMethodGet(this, $5f20a6104f835562$var$_facet_index, $5f20a6104f835562$var$_facet_index2).call(this, merchant, market, locale);
|
|
15773
|
+
const filters = (_v3_request$filters = v3_request.filters) !== null && _v3_request$filters !== void 0 ? _v3_request$filters : [];
|
|
15774
|
+
// depict-ui sends a filter's lowercased group title as its field. A page opened from a link with filters in it
|
|
15775
|
+
// comes before any facets, so read this browse's facets once to learn which field each title names.
|
|
15776
|
+
const learn_key = JSON.stringify([merchant, base]);
|
|
15777
|
+
if (filters.some(filter => filter.data != null && !$744a9d695dd21ed2$export$3b6ba2422a5e0aa0(filter.field, index)) && !$parcel$interopDefault($52FdA$babelruntimehelpersclassPrivateFieldGet)(this, $5f20a6104f835562$var$_learned).has(learn_key)) {
|
|
15778
|
+
var _await$_classPrivateM;
|
|
15779
|
+
$parcel$interopDefault($52FdA$babelruntimehelpersclassPrivateFieldGet)(this, $5f20a6104f835562$var$_learned).add(learn_key);
|
|
15780
|
+
index.learn_((_await$_classPrivateM = await $5f20a6104f835562$var$_classPrivateMethodGet(this, $5f20a6104f835562$var$_browse_page, $5f20a6104f835562$var$_browse_page2).call(this, merchant, {
|
|
15781
|
+
...base,
|
|
15782
|
+
include: ["facets"],
|
|
15783
|
+
limit: 1
|
|
15784
|
+
})) === null || _await$_classPrivateM === void 0 ? void 0 : _await$_classPrivateM.facets);
|
|
15785
|
+
}
|
|
15786
|
+
// A filter V4 can't take must not cost the shopper the page: a link can outlive its filter (one removed from the
|
|
15787
|
+
// store, a hand-written value). One the adapter can't write is left out here; one V4 rejects is left out and the
|
|
15788
|
+
// page asked again, and remembered for this page load so later pages don't ask with it.
|
|
15789
|
+
const rejected = $5f20a6104f835562$var$_classPrivateMethodGet(this, $5f20a6104f835562$var$_rejected_clauses, $5f20a6104f835562$var$_rejected_clauses2).call(this, merchant, market, locale);
|
|
15790
|
+
let clauses = [];
|
|
15791
|
+
for (const filter of filters) try {
|
|
15792
|
+
const clause = $744a9d695dd21ed2$export$c17bb5d2ead3e8f3(filter, index);
|
|
15793
|
+
if (clause) clauses.push(clause);
|
|
15794
|
+
} catch (e) {
|
|
15795
|
+
if (!(e instanceof (0, $744a9d695dd21ed2$export$f5ea4d073ddb4bdb))) throw e;
|
|
15796
|
+
$52FdA$depictaiutilishared.dwarn("[NativeDepictAPI] leaving out a filter V4 can't take:", e.message, filter);
|
|
15797
|
+
}
|
|
15798
|
+
clauses = clauses.filter(clause => !rejected.has(clause.clause_));
|
|
15799
|
+
const sort = $744a9d695dd21ed2$export$78eb8e636d89ff30(v3_request.sort);
|
|
15800
|
+
const include = door === "search" ? ["facets", "sorts", "content", "attributes"] : ["facets", "sorts", "attributes"];
|
|
15801
|
+
const want = (_v3_request$limit = v3_request.limit) !== null && _v3_request$limit !== void 0 ? _v3_request$limit : $5f20a6104f835562$var$DEFAULT_LIMIT;
|
|
15802
|
+
const offset = v3_request.cursor && $parcel$interopDefault($52FdA$babelruntimehelpersclassPrivateFieldGet)(this, $5f20a6104f835562$var$_cursor_offsets).get(v3_request.cursor) || 0;
|
|
15803
|
+
const request_with = sent => ({
|
|
15804
|
+
...base,
|
|
15805
|
+
...(sent.length ? {
|
|
15806
|
+
filter_by: sent.map(clause => clause.clause_).join(" && ")
|
|
15807
|
+
} : {}),
|
|
15808
|
+
...(sort ? {
|
|
15809
|
+
sort: sort
|
|
15810
|
+
} : {}),
|
|
15811
|
+
...(v3_request.cursor ? {
|
|
15812
|
+
cursor: v3_request.cursor
|
|
15813
|
+
} : {}),
|
|
15814
|
+
include: include,
|
|
15815
|
+
...(want !== $5f20a6104f835562$var$DEFAULT_LIMIT ? {
|
|
15816
|
+
limit: Math.min(want, $5f20a6104f835562$var$BROWSE_MAX_LIMIT)
|
|
15817
|
+
} : {})
|
|
15818
|
+
});
|
|
15819
|
+
let request = request_with(clauses);
|
|
15820
|
+
let answer = await $5f20a6104f835562$var$_classPrivateMethodGet(this, $5f20a6104f835562$var$_browse_answer, $5f20a6104f835562$var$_browse_answer2).call(this, merchant, request);
|
|
15821
|
+
// Each retry leaves out at least one more clause, so this ends.
|
|
15822
|
+
while (!answer.body_) {
|
|
15823
|
+
var _answer$error_;
|
|
15824
|
+
const refused = $744a9d695dd21ed2$export$c38de645260a41ed(answer.error_, clauses);
|
|
15825
|
+
if (!refused.length) return undefined;
|
|
15826
|
+
$52FdA$depictaiutilishared.dwarn("[NativeDepictAPI] leaving out filters V4 refused:", refused.map(clause => clause.clause_), (_answer$error_ = answer.error_) === null || _answer$error_ === void 0 ? void 0 : _answer$error_.message);
|
|
15827
|
+
for (const clause of refused) rejected.add(clause.clause_);
|
|
15828
|
+
clauses = clauses.filter(clause => !refused.includes(clause));
|
|
15829
|
+
request = request_with(clauses);
|
|
15830
|
+
answer = await $5f20a6104f835562$var$_classPrivateMethodGet(this, $5f20a6104f835562$var$_browse_answer, $5f20a6104f835562$var$_browse_answer2).call(this, merchant, request);
|
|
15831
|
+
}
|
|
15832
|
+
let response = answer.body_;
|
|
15833
|
+
// A page over V4's largest is its pages chained by their cursors; later pages ask for products alone.
|
|
15834
|
+
while (want > $5f20a6104f835562$var$BROWSE_MAX_LIMIT && response.products.length < want && response.cursor !== undefined) {
|
|
15835
|
+
const page = await $5f20a6104f835562$var$_classPrivateMethodGet(this, $5f20a6104f835562$var$_browse_page, $5f20a6104f835562$var$_browse_page2).call(this, merchant, {
|
|
15836
|
+
...request,
|
|
15837
|
+
cursor: response.cursor,
|
|
15838
|
+
limit: Math.min(want - response.products.length, $5f20a6104f835562$var$BROWSE_MAX_LIMIT),
|
|
15839
|
+
include: ["attributes"]
|
|
15840
|
+
});
|
|
15841
|
+
if (!page) return undefined;
|
|
15842
|
+
if (!page.products.length) break;
|
|
15843
|
+
response = {
|
|
15844
|
+
...response,
|
|
15845
|
+
products: [...response.products, ...page.products],
|
|
15846
|
+
...(page.cursor !== undefined ? {
|
|
15847
|
+
cursor: page.cursor
|
|
15848
|
+
} : {
|
|
15849
|
+
cursor: undefined
|
|
15850
|
+
})
|
|
15851
|
+
};
|
|
15852
|
+
}
|
|
15853
|
+
if (response.cursor === undefined) delete response.cursor;
|
|
15854
|
+
index.learn_(response.facets);
|
|
15855
|
+
if (response.cursor !== undefined) $parcel$interopDefault($52FdA$babelruntimehelpersclassPrivateFieldGet)(this, $5f20a6104f835562$var$_cursor_offsets).set(response.cursor, offset + response.products.length);
|
|
15856
|
+
return $14bc537adeeadca4$export$efb7dd882d411dd4(response, door, offset);
|
|
15857
|
+
}
|
|
15858
|
+
async function $5f20a6104f835562$var$_listing2(call) {
|
|
15859
|
+
const {
|
|
15860
|
+
merchant: merchant,
|
|
15861
|
+
market: market
|
|
15862
|
+
} = call.request_;
|
|
15863
|
+
const locale = $14bc537adeeadca4$export$eb90c08da400512d(call.request_.locale);
|
|
15864
|
+
const by_external_id = call.id_type_ === $c3739e86187f2054$export$5aae649db1b959fc;
|
|
15865
|
+
const path = by_external_id ? "/listings" : "/listings/" + encodeURIComponent(call.id_to_query_for_);
|
|
15866
|
+
const response = await $5f20a6104f835562$var$_classPrivateMethodGet(this, $5f20a6104f835562$var$_get_json, $5f20a6104f835562$var$_get_json2).call(this, $5f20a6104f835562$var$_classPrivateMethodGet(this, $5f20a6104f835562$var$_merchant_url, $5f20a6104f835562$var$_merchant_url2).call(this, merchant, path) + "?" + $14bc537adeeadca4$export$fec3e4b5adfcea2c([["market", market], ["locale", locale], ["external_id", by_external_id ? call.id_to_query_for_ : undefined]]));
|
|
15867
|
+
return response && $14bc537adeeadca4$export$996f2b1e66d9b5af(response.listing);
|
|
15868
|
+
}
|
|
15869
|
+
async function $5f20a6104f835562$var$_suggest2(v3_request) {
|
|
15870
|
+
var _v3_request$query;
|
|
15871
|
+
const {
|
|
15872
|
+
merchant: merchant,
|
|
15873
|
+
market: market
|
|
15874
|
+
} = v3_request;
|
|
15875
|
+
const locale = $14bc537adeeadca4$export$eb90c08da400512d(v3_request.locale);
|
|
15876
|
+
const response = await $5f20a6104f835562$var$_classPrivateMethodGet(this, $5f20a6104f835562$var$_get_json, $5f20a6104f835562$var$_get_json2).call(this, $5f20a6104f835562$var$_classPrivateMethodGet(this, $5f20a6104f835562$var$_merchant_url, $5f20a6104f835562$var$_merchant_url2).call(this, merchant, "/suggest") + "?" + $14bc537adeeadca4$export$fec3e4b5adfcea2c([["market", market], ["locale", locale], ["query", (_v3_request$query = v3_request.query) !== null && _v3_request$query !== void 0 ? _v3_request$query : ""]]));
|
|
15877
|
+
if (!response) return undefined;
|
|
15878
|
+
const needs_ancestors = response.suggestions.some(suggestion => suggestion.type === "listing" && suggestion.path.length > 0);
|
|
15879
|
+
return $14bc537adeeadca4$export$2860125b419015f8(response, needs_ancestors ? await $5f20a6104f835562$var$_classPrivateMethodGet(this, $5f20a6104f835562$var$_ancestors, $5f20a6104f835562$var$_ancestors2).call(this, merchant, market, locale) : undefined);
|
|
15880
|
+
}
|
|
15881
|
+
function $5f20a6104f835562$var$_ancestors2(merchant, market, locale) {
|
|
15882
|
+
const key = JSON.stringify([merchant, market, locale]);
|
|
15883
|
+
let lookup = $parcel$interopDefault($52FdA$babelruntimehelpersclassPrivateFieldGet)(this, $5f20a6104f835562$var$_ancestor_lookups).get(key);
|
|
15884
|
+
if (!lookup) {
|
|
15885
|
+
lookup = $5f20a6104f835562$var$_classPrivateMethodGet(this, $5f20a6104f835562$var$_get_json, $5f20a6104f835562$var$_get_json2).call(this, $5f20a6104f835562$var$_classPrivateMethodGet(this, $5f20a6104f835562$var$_merchant_url, $5f20a6104f835562$var$_merchant_url2).call(this, merchant, "/listings") + "?" + $14bc537adeeadca4$export$fec3e4b5adfcea2c([["market", market], ["locale", locale]])).then(tree => tree && $14bc537adeeadca4$export$76d96892da63b395(tree.listings));
|
|
15886
|
+
$parcel$interopDefault($52FdA$babelruntimehelpersclassPrivateFieldGet)(this, $5f20a6104f835562$var$_ancestor_lookups).set(key, lookup);
|
|
15887
|
+
}
|
|
15888
|
+
return lookup;
|
|
15889
|
+
}
|
|
15890
|
+
function $5f20a6104f835562$export$6d972e6af9de09f0(version, options) {
|
|
15891
|
+
return version === "v4" ? new $5f20a6104f835562$export$721afe49a594bed(options) : new (0, $e270e9f953fcbc58$export$e015ed2f2950f2e3)(options);
|
|
15892
|
+
}
|
|
14714
15893
|
function $5dd9d0d3ea82e2dd$export$477caf01aecaeb2a(options) {
|
|
14715
15894
|
var _globalThis$location$, _globalThis$location;
|
|
14716
15895
|
const router_ = options.router_;
|
|
@@ -15020,8 +16199,9 @@ class $9cbefc32b9dab36d$export$f34314aa9505732e {
|
|
|
15020
16199
|
quicklinks_signal_: $52FdA$solidjs.createSignal(),
|
|
15021
16200
|
i18n_: i18n_,
|
|
15022
16201
|
reset_history_state_: reset_history_state_,
|
|
16202
|
+
depict_api_: typeof api === "object" && api ? api :
|
|
15023
16203
|
// @ts-ignore
|
|
15024
|
-
|
|
16204
|
+
$5f20a6104f835562$export$6d972e6af9de09f0(api, {
|
|
15025
16205
|
display_transformers: display_transformers
|
|
15026
16206
|
}),
|
|
15027
16207
|
router_: $parcel$interopDefault($52FdA$babelruntimehelpersclassPrivateFieldGet)(this, $9cbefc32b9dab36d$var$_router),
|
|
@@ -16726,8 +17906,9 @@ class $ddd39c5f36f49703$export$ac6237957a15b3f0 {
|
|
|
16726
17906
|
const get_search_query_ = $52FdA$solidjs.createMemo(previous_value => {
|
|
16727
17907
|
if (get_search_query_updating_blocked()) return previous_value;else return raw_search_query_accessor();
|
|
16728
17908
|
});
|
|
17909
|
+
const depict_api_ = typeof api === "object" && api ? api :
|
|
16729
17910
|
// @ts-ignore
|
|
16730
|
-
|
|
17911
|
+
$5f20a6104f835562$export$6d972e6af9de09f0(api, {
|
|
16731
17912
|
display_transformers: display_transformers
|
|
16732
17913
|
});
|
|
16733
17914
|
const previous_searches = $cfeb65948dbdcaab$export$84bba84a7b837187(get_search_query_);
|