@depict-ai/ui 4.3.1 → 4.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +1,8 @@
1
1
  var $3hooq$depictaiutilishared = require("@depict-ai/utilishared/ES10");
2
2
  var $3hooq$solidjsweb = require("solid-js/web");
3
3
  var $3hooq$solidjs = require("solid-js");
4
- var $3hooq$depictaiutilisharedlatest = require("@depict-ai/utilishared/ES10");
5
4
  var $3hooq$babelruntimehelpersdefineProperty = require("@babel/runtime/helpers/defineProperty");
5
+ var $3hooq$depictaiutilisharedlatest = require("@depict-ai/utilishared/ES10");
6
6
  var $3hooq$babelruntimehelpersclassPrivateFieldSet = require("@babel/runtime/helpers/classPrivateFieldSet");
7
7
  var $3hooq$babelruntimehelpersclassPrivateFieldGet = require("@babel/runtime/helpers/classPrivateFieldGet");
8
8
  var $3hooq$solidjsstore = require("solid-js/store");
@@ -100,7 +100,7 @@ $parcel$export(module.exports, "BreadCrumbs", () => $335c02c1241a9ca8$export$5b7
100
100
  $parcel$export(module.exports, "QuickLinks", () => $335c02c1241a9ca8$export$de035477d6fef996);
101
101
  $parcel$export(module.exports, "CategoryPage", () => $c10e33c4681f8c9b$export$e2bf8ce7779e827e);
102
102
  /*! Depict.ai search and product listing SDK */
103
- const $aa1938dec50d6c12$export$83d89fbfd8236492 = "4.3.1";
103
+ const $aa1938dec50d6c12$export$83d89fbfd8236492 = "4.3.2";
104
104
  const $5401a6698b0c0658$var$transform_elements = sorted_cols_at_size => {
105
105
  const cols_at_size = [];
106
106
  for (let i = 0; i < sorted_cols_at_size.length; i++) {
@@ -1009,7 +1009,7 @@ function $858fdcf73148519f$export$6e5611bc7e57e477(props) {
1009
1009
  });
1010
1010
  // Work around https://github.com/solidjs/solid/issues/1828
1011
1011
  const img = new Image(); // Need to use new Image or browser might not start loading image before it's in the DOM
1012
- const [, otherAttributes] = $3hooq$solidjs.splitProps(props, ["resolutions", "size", "src", "srcSet", "loading", "customUrls" // Can't have properties ending on underscore because the property name mangling will get confused by this <-
1012
+ const [, otherAttributes] = $3hooq$solidjs.splitProps(props, ["resolutions", "size", "src", "srcSet", "loading", "keyRatioUpdating", "customUrls" // Can't have properties ending on underscore because the property name mangling will get confused by this <-
1013
1013
  ]);
1014
1014
 
1015
1015
  const [hasSetSize, setHasSetSize] = $3hooq$solidjs.createSignal(false);
@@ -1065,13 +1065,18 @@ function $858fdcf73148519f$export$6e5611bc7e57e477(props) {
1065
1065
  let hasDecodedFastPath = false;
1066
1066
  let timeoutSet = false;
1067
1067
  let gotCleanedUp = false;
1068
+ let srcJustChanged = true;
1068
1069
  img.classList.add("s-responsive-image");
1069
1070
  if (listingContext) {
1070
1071
  let prevValue;
1071
1072
  const aspectRatios = listingContext[$858fdcf73148519f$export$f8945274f08a3105] || (listingContext[$858fdcf73148519f$export$f8945274f08a3105] = new Set());
1072
1073
  const [, setMostPrevalentAspectRatio] = listingContext[$858fdcf73148519f$export$6066eb417ed2e9f7] || (listingContext[$858fdcf73148519f$export$6066eb417ed2e9f7] = $3hooq$solidjs.createSignal());
1073
1074
  img.addEventListener("load", $3hooq$depictaiutilishared.catchify(() => {
1074
- // Save our aspect ratio whenever it changes, so that we can base the containers on the most dominant aspect ratio, used in SearchModalV2
1075
+ if (props.keyRatioUpdating) {
1076
+ if (!srcJustChanged) return;
1077
+ srcJustChanged = false;
1078
+ }
1079
+ // Save our aspect ratio whenever it changes, so that we can base the containers on the most dominant aspect ratio, used in SearchModalV2 and LookItem
1075
1080
  const aspectRatio_ = img.naturalWidth / img.naturalHeight;
1076
1081
  if (prevValue) aspectRatios.delete(prevValue);
1077
1082
  const newValue = !isNaN(aspectRatio_) ? {
@@ -1093,6 +1098,10 @@ function $858fdcf73148519f$export$6e5611bc7e57e477(props) {
1093
1098
  }
1094
1099
  $3hooq$solidjs.onCleanup(() => gotCleanedUp = true);
1095
1100
  $3hooq$solidjsweb.spread(img, $3hooq$solidjs.mergeProps(modifiedOtherAttributes), false, true);
1101
+ $3hooq$solidjs.createRenderEffect(() => {
1102
+ props.src;
1103
+ srcJustChanged = true;
1104
+ });
1096
1105
  $3hooq$solidjs.createEffect(() => {
1097
1106
  if (!props.size()) return; // wait until we have a size, run every time the size changes
1098
1107
  if (timeoutSet) return;
@@ -1160,48 +1169,22 @@ function $28535bb7671c63d1$export$e4b984597b71e989(props) {
1160
1169
  context[$28535bb7671c63d1$export$d7b7ab832c20e2f4] = $3hooq$solidjs.createSignal();
1161
1170
  const [currentImageSize, setCurrentImageSize] = (context === null || context === void 0 ? void 0 : context[$28535bb7671c63d1$export$d7b7ab832c20e2f4]) || $28535bb7671c63d1$var$backupSizeSignal; // use global fallback signal (might lead to blurry images) if no context is available
1162
1171
  const [mostPrevalentAspectRatio] = context ? context[(0, $858fdcf73148519f$export$6066eb417ed2e9f7)] || (context[(0, $858fdcf73148519f$export$6066eb417ed2e9f7)] = $3hooq$solidjs.createSignal()) : [];
1163
- const [aspectRatio, setAspectRatio] = $3hooq$solidjs.createSignal($3hooq$solidjs.untrack(() => props.aspectRatio));
1164
1172
  const container = $ce467edb5343cfcd$export$94026ee33dbabc26({
1165
1173
  // Write getters manually instead of using JSX, so we can do more complex logic in the aspectRatio getter without increasing bundle size
1166
1174
  get class() {
1167
1175
  return props.class;
1168
1176
  },
1169
1177
  get aspectRatio() {
1170
- return aspectRatio();
1178
+ if (props.autoAdjustAspectRatio) {
1179
+ const targetRatio = mostPrevalentAspectRatio === null || mostPrevalentAspectRatio === void 0 ? void 0 : mostPrevalentAspectRatio();
1180
+ if (targetRatio != undefined) return "var(".concat((0, $c0cf6af094336798$export$8a2234b5b1a5ebd4), ", ").concat(targetRatio, ")");
1181
+ }
1182
+ return props.aspectRatio;
1171
1183
  }
1172
1184
  });
1173
1185
  const owner = $3hooq$solidjs.getOwner();
1174
1186
  let createdSizeAccessor = false;
1175
1187
  let wasCleanedUp = false;
1176
- let timeout;
1177
- $3hooq$solidjs.createEffect(() => {
1178
- const {
1179
- autoAdjustAspectRatio: autoAdjustAspectRatio
1180
- } = props;
1181
- if (autoAdjustAspectRatio) {
1182
- const targetRatio = mostPrevalentAspectRatio === null || mostPrevalentAspectRatio === void 0 ? void 0 : mostPrevalentAspectRatio();
1183
- if (targetRatio != undefined) {
1184
- const targetValue = "var(".concat((0, $c0cf6af094336798$export$8a2234b5b1a5ebd4), ", ").concat(targetRatio, ")");
1185
- const updateAspectRatio = $3hooq$depictaiutilishared.catchify(() => setAspectRatio(targetValue));
1186
- if (autoAdjustAspectRatio === "smoothed") {
1187
- if (!timeout)
1188
- // If we don't have a timeout yet, also update instantly. This is so that the aspect ratio does get set at the start of a transition, if it changes (when using smoothing).
1189
- updateAspectRatio();
1190
- clearTimeout(timeout);
1191
- timeout = setTimeout(() => {
1192
- timeout = undefined;
1193
- updateAspectRatio();
1194
- }, 500);
1195
- return;
1196
- }
1197
- return updateAspectRatio();
1198
- }
1199
- } else {
1200
- clearTimeout(timeout);
1201
- timeout = undefined;
1202
- }
1203
- setAspectRatio(props.aspectRatio);
1204
- });
1205
1188
  $3hooq$solidjs.createEffect(() => {
1206
1189
  if (currentImageSize() || wasCleanedUp) return; // We get into the effect when onCleanup is called if we don't have wasCleanedUp
1207
1190
  // ensure we always have a size accessor
@@ -1251,6 +1234,12 @@ function $f3db423dc84bc35d$export$9d4a4b669b1929ab(props) {
1251
1234
  }
1252
1235
  }));
1253
1236
  }
1237
+ function $f38f2e64ebe2da86$export$a71e92cfbb498adc(props) {
1238
+ return $3hooq$solidjs.createMemo(() => {
1239
+ const price_formatting = props.price_formatting_;
1240
+ return $3hooq$depictaiutilishared.standard_price_format(props.price_, price_formatting.places_after_comma_, price_formatting.decimal_places_delimiter_, price_formatting.thousands_delimiter_);
1241
+ });
1242
+ }
1254
1243
  var $d66c35b5a6d6d926$var$_tmpl$ = ["<div", ' class="img-wrapper">', "</div>"],
1255
1244
  $d66c35b5a6d6d926$var$_tmpl$2 = ["<span", ' class="d-price original">', "</span>"],
1256
1245
  $d66c35b5a6d6d926$var$_tmpl$3 = ["<div", ' class="right-part"><div class="text-container"><span class="d-title line-clamp">', '</span><span class="', '">', "</span><!--$-->", "<!--/--></div><!--$-->", "<!--/--></div>"];
@@ -1261,7 +1250,9 @@ function $d66c35b5a6d6d926$export$b73ed90f0ee50dc3(_ref) {
1261
1250
  isExpanded_: isExpanded_,
1262
1251
  textFadeInAnimationRunning_: textFadeInAnimationRunning_,
1263
1252
  outerRef_: outerRef_,
1264
- animationDuration_: animationDuration_
1253
+ animationDuration_: animationDuration_,
1254
+ priceFormatting_: priceFormatting_,
1255
+ pseudoRouter_: pseudoRouter_
1265
1256
  } = _ref;
1266
1257
  const variantToUse = $3hooq$solidjs.createMemo(() => {
1267
1258
  const display = display_();
@@ -1282,16 +1273,18 @@ function $d66c35b5a6d6d926$export$b73ed90f0ee50dc3(_ref) {
1282
1273
  var _variantToUse3;
1283
1274
  return (_variantToUse3 = variantToUse()) === null || _variantToUse3 === void 0 ? void 0 : _variantToUse3.original_price;
1284
1275
  });
1285
- const isOnSale = $3hooq$solidjs.createMemo(() => salePrice.latest !== originalPrice.latest); // .latest doesn't trigger suspense
1276
+ const isOnSale = $3hooq$solidjs.createMemo(() => !salePrice.loading && !originalPrice.loading && salePrice.latest !== originalPrice.latest); // .latest doesn't trigger suspense after the initial load
1277
+ const enableLink = $3hooq$solidjs.createMemo(() => isExpanded_() && !animationIsRunning());
1278
+ const href = $3hooq$solidjs.createMemo(() => {
1279
+ var _variantToUse4;
1280
+ return (_variantToUse4 = variantToUse()) === null || _variantToUse4 === void 0 ? void 0 : _variantToUse4.page_url;
1281
+ });
1286
1282
  const FavoriteButton = FavoriteButton_; // Just to get rid of the type error - TS doesn't understand <Show>
1287
1283
  return $3hooq$solidjsweb.ssrElement("a", $3hooq$solidjsweb.mergeProps({
1288
1284
  "class": "look-item"
1289
- }, () => {
1290
- var _variantToUse4;
1291
- return isExpanded_() && !animationIsRunning() ? {
1292
- href: (_variantToUse4 = variantToUse()) === null || _variantToUse4 === void 0 ? void 0 : _variantToUse4.page_url
1293
- } : {};
1294
- }), () => ["<!--$-->", $3hooq$solidjsweb.escape($3hooq$solidjsweb.createComponent((0, $3hooq$solidjs.Show), {
1285
+ }, () => enableLink() ? {
1286
+ href: href()
1287
+ } : {}), () => ["<!--$-->", $3hooq$solidjsweb.escape($3hooq$solidjsweb.createComponent((0, $3hooq$solidjs.Show), {
1295
1288
  when: imageUrl,
1296
1289
  get fallback() {
1297
1290
  return $3hooq$solidjsweb.createComponent((0, $b8a8d61b3ec5f5ac$export$3f37af283f8fb843), {
@@ -1317,7 +1310,10 @@ function $d66c35b5a6d6d926$export$b73ed90f0ee50dc3(_ref) {
1317
1310
  return isExpanded_() ? 0.75 : 1;
1318
1311
  },
1319
1312
  get autoAdjustAspectRatio() {
1320
- return isExpanded_() ? "smoothed" : false;
1313
+ return isExpanded_();
1314
+ },
1315
+ imgProps: {
1316
+ keyRatioUpdating: true
1321
1317
  }
1322
1318
  });
1323
1319
  }
@@ -1332,18 +1328,66 @@ function $d66c35b5a6d6d926$export$b73ed90f0ee50dc3(_ref) {
1332
1328
  return $3hooq$solidjsweb.ssr($d66c35b5a6d6d926$var$_tmpl$3, $3hooq$solidjsweb.ssrHydrationKey(), (_$escape2 = $3hooq$solidjsweb.escape((_variantToUse5 = variantToUse()) === null || _variantToUse5 === void 0 ? void 0 : _variantToUse5.title)) !== null && _$escape2 !== void 0 ? _$escape2 : $3hooq$solidjsweb.escape($3hooq$solidjsweb.createComponent((0, $a7f7d416e6f61504$export$89c6019e4baa40b1), {
1333
1329
  height: "1em",
1334
1330
  width: "20ch"
1335
- })), "d-price ".concat(isOnSale() ? "sale" : ""), !variantToUse() || salePrice.loading ? $3hooq$solidjsweb.escape($3hooq$solidjsweb.createComponent((0, $a7f7d416e6f61504$export$89c6019e4baa40b1), {
1336
- height: "1em",
1337
- width: "20ch"
1338
- })) : $3hooq$solidjsweb.escape(salePrice()), $3hooq$solidjsweb.escape($3hooq$solidjsweb.createComponent((0, $3hooq$solidjs.Show), {
1331
+ })), "d-price ".concat(isOnSale() ? "sale" : ""), $3hooq$solidjsweb.escape($3hooq$solidjsweb.createComponent((0, $3hooq$solidjs.Show), {
1339
1332
  get when() {
1340
- return isOnSale();
1333
+ return variantToUse() && !salePrice.loading;
1341
1334
  },
1342
- get children() {
1343
- return $3hooq$solidjsweb.ssr($d66c35b5a6d6d926$var$_tmpl$2, $3hooq$solidjsweb.ssrHydrationKey(), !variantToUse() || originalPrice.loading ? $3hooq$solidjsweb.escape($3hooq$solidjsweb.createComponent((0, $a7f7d416e6f61504$export$89c6019e4baa40b1), {
1335
+ get fallback() {
1336
+ return $3hooq$solidjsweb.createComponent((0, $a7f7d416e6f61504$export$89c6019e4baa40b1), {
1344
1337
  height: "1em",
1345
1338
  width: "20ch"
1346
- })) : $3hooq$solidjsweb.escape(originalPrice()));
1339
+ });
1340
+ },
1341
+ get children() {
1342
+ return $3hooq$solidjsweb.createComponent((0, $3hooq$solidjs.Show), {
1343
+ get when() {
1344
+ return salePrice.latest;
1345
+ },
1346
+ get children() {
1347
+ return [priceFormatting_().pre_, $3hooq$solidjsweb.createComponent((0, $f38f2e64ebe2da86$export$a71e92cfbb498adc), {
1348
+ get price_() {
1349
+ return salePrice();
1350
+ },
1351
+ get price_formatting_() {
1352
+ return priceFormatting_();
1353
+ }
1354
+ }), priceFormatting_().post_];
1355
+ }
1356
+ });
1357
+ }
1358
+ })), $3hooq$solidjsweb.escape($3hooq$solidjsweb.createComponent((0, $3hooq$solidjs.Show), {
1359
+ get when() {
1360
+ return isOnSale();
1361
+ },
1362
+ get children() {
1363
+ return $3hooq$solidjsweb.ssr($d66c35b5a6d6d926$var$_tmpl$2, $3hooq$solidjsweb.ssrHydrationKey(), $3hooq$solidjsweb.escape($3hooq$solidjsweb.createComponent((0, $3hooq$solidjs.Show), {
1364
+ get when() {
1365
+ return variantToUse() && !originalPrice.loading;
1366
+ },
1367
+ get fallback() {
1368
+ return $3hooq$solidjsweb.createComponent((0, $a7f7d416e6f61504$export$89c6019e4baa40b1), {
1369
+ height: "1em",
1370
+ width: "20ch"
1371
+ });
1372
+ },
1373
+ get children() {
1374
+ return $3hooq$solidjsweb.createComponent((0, $3hooq$solidjs.Show), {
1375
+ get when() {
1376
+ return salePrice.latest;
1377
+ },
1378
+ get children() {
1379
+ return [priceFormatting_().pre_, $3hooq$solidjsweb.createComponent((0, $f38f2e64ebe2da86$export$a71e92cfbb498adc), {
1380
+ get price_() {
1381
+ return originalPrice();
1382
+ },
1383
+ get price_formatting_() {
1384
+ return priceFormatting_();
1385
+ }
1386
+ }), priceFormatting_().post_];
1387
+ }
1388
+ });
1389
+ }
1390
+ })));
1347
1391
  }
1348
1392
  })), $3hooq$solidjsweb.escape($3hooq$solidjsweb.createComponent((0, $3hooq$solidjs.Show), {
1349
1393
  when: FavoriteButton_,
@@ -1414,7 +1458,9 @@ function $e0b3f1f332b6863b$export$ebf0b1d4f90c09ae(_ref) {
1414
1458
  userWantsExpandedSignal_: [userWantsExpanded, setUserWantsExpanded],
1415
1459
  containerWidth_: containerWidth_,
1416
1460
  animationDuration_: animationDuration_,
1417
- supportsHover_: supportsHover_
1461
+ supportsHover_: supportsHover_,
1462
+ priceFormatting_: priceFormatting_,
1463
+ pseudoRouter_: pseudoRouter_
1418
1464
  } = _ref;
1419
1465
  let isAffectedByChromeBug = false;
1420
1466
  // If the user requests the drawer to be expanded or not
@@ -1445,11 +1491,13 @@ function $e0b3f1f332b6863b$export$ebf0b1d4f90c09ae(_ref) {
1445
1491
  },
1446
1492
  children: (display, index) => {
1447
1493
  return $3hooq$solidjsweb.createComponent((0, $d66c35b5a6d6d926$export$b73ed90f0ee50dc3), {
1494
+ pseudoRouter_: pseudoRouter_,
1448
1495
  animationDuration_: animationDuration_,
1449
1496
  display_: display,
1450
1497
  FavoriteButton_: FavoriteButton_,
1451
1498
  isExpanded_: userWantsExpanded,
1452
1499
  textFadeInAnimationRunning_: textFadeInAnimationRunning,
1500
+ priceFormatting_: priceFormatting_,
1453
1501
  outerRef_: el => $3hooq$solidjs.createEffect(() => {
1454
1502
  if (index !== 0) return;
1455
1503
  const resizeObserver = new ResizeObserver($3hooq$depictaiutilishared.catchify(records => setLookItemHeight(records.at(-1).contentRect.height)));
@@ -1491,10 +1539,10 @@ function $47e3c3102c78121b$export$44809a8a3e867e30(_ref) {
1491
1539
  expandedLooksSignal_: [expandedLooks_, setExpandedLooks],
1492
1540
  FavoriteButton_: FavoriteButton_,
1493
1541
  placeholderImageAspectRatio_: placeholderImageAspectRatio_,
1494
- animationDuration_: animationDuration_
1542
+ animationDuration_: animationDuration_,
1543
+ priceFormatting_: priceFormatting_,
1544
+ pseudoRouter_: pseudoRouter_
1495
1545
  } = _ref;
1496
- // TODO: shopify, run displayTransformers to get dynamic prices
1497
- // TODO: format prices
1498
1546
  const [coverImage] = (display_ === null || display_ === void 0 ? void 0 : display_.image_urls) || [];
1499
1547
  const useWantsExpandedSignal_ = $3hooq$solidjs.createSignal(false);
1500
1548
  const [userWantsExpanded, setUserWantsExpanded] = useWantsExpandedSignal_;
@@ -1527,7 +1575,7 @@ function $47e3c3102c78121b$export$44809a8a3e867e30(_ref) {
1527
1575
  when: display_,
1528
1576
  get fallback() {
1529
1577
  return $3hooq$solidjsweb.createComponent((0, $b8a8d61b3ec5f5ac$export$3f37af283f8fb843), {
1530
- aspectRatio: placeholderImageAspectRatio_
1578
+ aspectRatio: "var(".concat((0, $c0cf6af094336798$export$8a2234b5b1a5ebd4), ", ").concat(placeholderImageAspectRatio_, ")")
1531
1579
  });
1532
1580
  },
1533
1581
  get children() {
@@ -1545,10 +1593,136 @@ function $47e3c3102c78121b$export$44809a8a3e867e30(_ref) {
1545
1593
  containerWidth_: containerWidth_,
1546
1594
  animationDuration_: animationDuration_,
1547
1595
  supportsHover_: supportsHover_,
1548
- FavoriteButton_: FavoriteButton_
1596
+ FavoriteButton_: FavoriteButton_,
1597
+ priceFormatting_: priceFormatting_,
1598
+ pseudoRouter_: pseudoRouter_
1549
1599
  })]);
1550
1600
  return container;
1551
1601
  }
1602
+
1603
+ /**
1604
+ * This function is used to determine if the user is trying to open a link in a new tab or window, and we therefore should not single page navigate
1605
+ * @param clickEvent The click event that triggered the navigation
1606
+ */
1607
+ function $9ca08bcacbc598ce$export$29d28dadc2d6b631(clickEvent) {
1608
+ return (clickEvent === null || clickEvent === void 0 ? void 0 : clickEvent.button) || (clickEvent === null || clickEvent === void 0 ? void 0 : clickEvent.metaKey) || (clickEvent === null || clickEvent === void 0 ? void 0 : clickEvent.ctrlKey) || (clickEvent === null || clickEvent === void 0 ? void 0 : clickEvent.shiftKey // if true, shift button on windows, linux or macOS which opens in a new window
1609
+ );
1610
+ }
1611
+
1612
+ function $73014ff36186a4dd$var$_classPrivateMethodInitSpec(obj, privateSet) {
1613
+ $73014ff36186a4dd$var$_checkPrivateRedeclaration(obj, privateSet);
1614
+ privateSet.add(obj);
1615
+ }
1616
+ function $73014ff36186a4dd$var$_checkPrivateRedeclaration(obj, privateCollection) {
1617
+ if (privateCollection.has(obj)) throw new TypeError("Cannot initialize the same private elements twice on an object");
1618
+ }
1619
+ function $73014ff36186a4dd$var$_classPrivateMethodGet(receiver, privateSet, fn) {
1620
+ if (!privateSet.has(receiver)) throw new TypeError("attempted to get private field on non-instance");
1621
+ return fn;
1622
+ }
1623
+ var $73014ff36186a4dd$var$_throwing_on_navigation = /*#__PURE__*/new WeakSet();
1624
+ var $73014ff36186a4dd$var$_get_navigation_happened_promise = /*#__PURE__*/new WeakSet();
1625
+ class $73014ff36186a4dd$export$7e1297a3a19f10d8 {
1626
+ /**
1627
+ * Function that will be called when we want to navigate, or a string saying it's not an SPA. You can change this OTG
1628
+ */ /**
1629
+ * We store listing_id in history.state and do operate on this both here and in js-ui, this is the key to be used which js-ui provides
1630
+ */ /**
1631
+ * Vue has async router that needs to be awaited (it navigates after a microtask)
1632
+ * This standardises waiting for all kinds of routers
1633
+ */
1634
+ constructor(on_navigation, listing_query_state_key) {
1635
+ $73014ff36186a4dd$var$_classPrivateMethodInitSpec(this, $73014ff36186a4dd$var$_get_navigation_happened_promise);
1636
+ $73014ff36186a4dd$var$_classPrivateMethodInitSpec(this, $73014ff36186a4dd$var$_throwing_on_navigation);
1637
+ $parcel$interopDefault($3hooq$babelruntimehelpersdefineProperty)(this, "on_navigation_", void 0);
1638
+ $parcel$interopDefault($3hooq$babelruntimehelpersdefineProperty)(this, "listing_query_state_key", void 0);
1639
+ $parcel$interopDefault($3hooq$babelruntimehelpersdefineProperty)(this, "navigate_", {
1640
+ /**
1641
+ * Call this if you *just* want to replace the state object in history.state
1642
+ */
1643
+ replace_state_: new_state => {
1644
+ var _globalThis$history;
1645
+ // This doesn't break any router, so we just do this directly for now, since many don't expose an interface for changing the state
1646
+ globalThis === null || globalThis === void 0 || (_globalThis$history = globalThis.history) === null || _globalThis$history === void 0 || _globalThis$history.replaceState(new_state, "");
1647
+ },
1648
+ /**
1649
+ * Call this to change the URL
1650
+ * @param new_url_ new URL to go to
1651
+ * @param event_ event if you have this in a click handler, will not do anything on cmd/ctrl or non-left click then
1652
+ * @param force_spa_navigation_ if you want to force SPA navigation even if on_navigation_ is set to "hard_navigation". You should only set this to true for inter-SDK-page navigations
1653
+ * @param is_replace_ if you want to replace the current URL in history instead of pushing a new one
1654
+ * @param listing_id_ If you are navigating to a category and know the listing_id of, please provide it. This is for making a better devEx in js-ui
1655
+ */
1656
+ go_to_: $3hooq$depictaiutilishared.catchify(async _ref => {
1657
+ let {
1658
+ new_url_: raw_new_url,
1659
+ event_: event_,
1660
+ force_spa_navigation_: force_spa_navigation_,
1661
+ is_replace_: is_replace_,
1662
+ listing_query_: listing_query_,
1663
+ scroll = true
1664
+ } = _ref;
1665
+ const new_url_ = raw_new_url instanceof URL ? raw_new_url : new URL(raw_new_url, location.origin);
1666
+ const wants_hard_navigation = this.on_navigation_ === "hard_navigation";
1667
+ if ($9ca08bcacbc598ce$export$29d28dadc2d6b631(event_)) return;
1668
+ const different_origin = new_url_.origin !== location.origin;
1669
+ if (wants_hard_navigation && (!force_spa_navigation_ || different_origin)) {
1670
+ if (force_spa_navigation_ && different_origin)
1671
+ // If we call history.pushState on a different origin, it will throw an error, so fallback to hard navigations
1672
+ $3hooq$depictaiutilishared.dwarn("Can't single page navigate to", new_url_.href, "due to different origin, this MIGHT mean you should fix the URLs");
1673
+ if (!event_)
1674
+ // If we haven't gotten an event, nothing will happen by not calling prevent default, so we need to change the URL
1675
+ location.assign(new_url_);
1676
+ return;
1677
+ }
1678
+ event_ === null || event_ === void 0 || event_.preventDefault();
1679
+ const promise = $73014ff36186a4dd$var$_classPrivateMethodGet(this, $73014ff36186a4dd$var$_get_navigation_happened_promise, $73014ff36186a4dd$var$_get_navigation_happened_promise2).call(this, true);
1680
+ if (force_spa_navigation_ && wants_hard_navigation) {
1681
+ // Don't allow hard navigation if we're forcing SPA navigation, which we do for things where PageReplacer can be used for performance
1682
+ const new_state = history.state;
1683
+ if (listing_query_) {
1684
+ // In JS-UI we need to know the listing_id of the current category, therefore push it into state
1685
+ if (!this.listing_query_state_key) $3hooq$depictaiutilishared.report(new Error("listing_query_state_key is not set"), "error");
1686
+ new_state[this.listing_query_state_key] = listing_query_;
1687
+ }
1688
+ history[is_replace_ ? "replaceState" : "pushState"](new_state, "", new_url_);
1689
+ } else $73014ff36186a4dd$var$_classPrivateMethodGet(this, $73014ff36186a4dd$var$_throwing_on_navigation, $73014ff36186a4dd$var$_throwing_on_navigation2).call(this, {
1690
+ is_replace: is_replace_,
1691
+ new_url: new_url_ instanceof URL ? new_url_ : new URL(new_url_, location.origin),
1692
+ scroll: scroll
1693
+ });
1694
+ await promise;
1695
+ })
1696
+ });
1697
+ this.listing_query_state_key = listing_query_state_key;
1698
+ this.on_navigation_ = on_navigation;
1699
+ }
1700
+ }
1701
+ function $73014ff36186a4dd$var$_throwing_on_navigation2() {
1702
+ const {
1703
+ on_navigation_: on_navigation_
1704
+ } = this;
1705
+ if (typeof on_navigation_ !== "function") throw new Error("on_navigation_ is not a function");
1706
+ // make sure that we don't accidentally catchify if the SDK consumer has fucked up
1707
+ try {
1708
+ return on_navigation_(...arguments);
1709
+ } catch (e) {
1710
+ queueMicrotask(() => {
1711
+ throw e;
1712
+ });
1713
+ }
1714
+ }
1715
+ function $73014ff36186a4dd$var$_get_navigation_happened_promise2(is_replace) {
1716
+ return new Promise(resolve => {
1717
+ const handler = what_happened => {
1718
+ if (what_happened === (is_replace ? "replaceState" : "pushState")) {
1719
+ resolve();
1720
+ (0, $3hooq$depictaiutilishared.instant_exec_on_suspect_history_change).delete(handler);
1721
+ }
1722
+ };
1723
+ (0, $3hooq$depictaiutilishared.instant_exec_on_suspect_history_change).add(handler);
1724
+ });
1725
+ }
1552
1726
  var $8446f782881fa12e$var$_tmpl$ = ["<div", ' class="depict recommendations looks" style="', '">', "</div>"];
1553
1727
  let $8446f782881fa12e$var$expandedLooksSignal_;
1554
1728
  function $8446f782881fa12e$export$1935e6bdfc5ed8ce(props) {
@@ -1557,6 +1731,7 @@ function $8446f782881fa12e$export$1935e6bdfc5ed8ce(props) {
1557
1731
  equals: false
1558
1732
  }));
1559
1733
  const expandingAnimationDuration = 240;
1734
+ const pseudoRouter = new (0, $73014ff36186a4dd$export$7e1297a3a19f10d8)("hard_navigation");
1560
1735
  const grid_spacing_override = $3hooq$solidjs.createMemo(() => {
1561
1736
  const {
1562
1737
  gridSpacing_: gridSpacing_
@@ -1584,19 +1759,35 @@ function $8446f782881fa12e$export$1935e6bdfc5ed8ce(props) {
1584
1759
  });
1585
1760
  const decoded = await (response === null || response === void 0 ? void 0 : (_json = (_ref2 = response).json) === null || _json === void 0 ? void 0 : _json.call(_ref2).catch(() => false));
1586
1761
  if (!decoded)
1587
- // If network fails, make sure to return empty array adn SolidRecommendationSlider will remove its elements
1762
+ // If network fails, make sure to return empty array and SolidRecommendationSlider will remove its elements
1588
1763
  return [];
1589
- return decoded.listings;
1764
+ const {
1765
+ listings: listings
1766
+ } = decoded;
1767
+ const baseData = {
1768
+ merchant: merchant,
1769
+ market: market,
1770
+ locale: locale
1771
+ };
1772
+ return $8446f782881fa12e$var$runDisplayTransformersForLooks(baseData, listings, props.displayTransformers_);
1773
+ });
1774
+ $3hooq$solidjs.createEffect(() => {
1775
+ const {
1776
+ onNavigation_: onNavigation_
1777
+ } = props;
1778
+ if (onNavigation_) pseudoRouter.on_navigation_ = onNavigation_;
1590
1779
  });
1591
1780
  return $3hooq$solidjsweb.ssr($8446f782881fa12e$var$_tmpl$, $3hooq$solidjsweb.ssrHydrationKey(), $3hooq$solidjsweb.ssrStyle("--animation-duration: ".concat(expandingAnimationDuration, "ms")), $3hooq$solidjsweb.escape($3hooq$solidjsweb.createComponent((0, $d067f3a30f047b41$export$e68cff63f76bd15b), {
1592
1781
  get children() {
1593
1782
  return $236a257ee52e5414$export$d41d19e89346fa2({
1594
- product_card_template_: (display, info) => $47e3c3102c78121b$export$44809a8a3e867e30({
1783
+ product_card_template_: display => $47e3c3102c78121b$export$44809a8a3e867e30({
1595
1784
  display_: display,
1596
1785
  FavoriteButton_: props.FavoriteButton_,
1597
1786
  placeholderImageAspectRatio_: props.imagePlaceholderAspectRatio_,
1598
1787
  animationDuration_: expandingAnimationDuration,
1599
- expandedLooksSignal_: $8446f782881fa12e$var$expandedLooksSignal_
1788
+ expandedLooksSignal_: $8446f782881fa12e$var$expandedLooksSignal_,
1789
+ priceFormatting_: () => props.priceFormatting_,
1790
+ pseudoRouter_: pseudoRouter
1600
1791
  }),
1601
1792
  recommendations_resource_: looksResource,
1602
1793
  title_: () => props.title_,
@@ -1609,6 +1800,58 @@ function $8446f782881fa12e$export$1935e6bdfc5ed8ce(props) {
1609
1800
  })));
1610
1801
  }, "LookSlider failed");
1611
1802
  }
1803
+ async function $8446f782881fa12e$var$runDisplayTransformersForLooks(baseData, listings, displayTransformers) {
1804
+ try {
1805
+ const {
1806
+ products: productTransformer,
1807
+ categories: providedListingTransformer
1808
+ } = displayTransformers || {};
1809
+ if (!productTransformer && !providedListingTransformer) return listings;
1810
+ const listingTransformer = providedListingTransformer || (_ref3 => {
1811
+ let {
1812
+ data: data
1813
+ } = _ref3;
1814
+ return data;
1815
+ });
1816
+ const displaysToTransform = [];
1817
+ const displayIdsPerListingId = {};
1818
+ const transformedListingsPromise = listingTransformer({
1819
+ ...baseData,
1820
+ data: listings.map(_ref4 => {
1821
+ let {
1822
+ displays: displays,
1823
+ ...listing
1824
+ } = _ref4;
1825
+ // Populate our displays by id and displayIdToListings object in the .map where we add ancestors to the listings, for peak efficiency
1826
+ for (let i = 0; i < displays.length; i++) {
1827
+ var _listing$listing_id;
1828
+ const display = displays[i];
1829
+ const uniqueIdOfDisplay = $b85edfec41cd3989$export$548d053aba053d79(display);
1830
+ displaysToTransform.push(display);
1831
+ (displayIdsPerListingId[_listing$listing_id = listing.listing_id] || (displayIdsPerListingId[_listing$listing_id] = [])).push(uniqueIdOfDisplay);
1832
+ }
1833
+ return {
1834
+ ...listing,
1835
+ ancestors: []
1836
+ };
1837
+ })
1838
+ });
1839
+ // This allows the person providing the displayTransformer to re-order and remove displays
1840
+ const transformedProducts = productTransformer ? await productTransformer({
1841
+ ...baseData,
1842
+ displays: displaysToTransform
1843
+ }) : displaysToTransform;
1844
+ const transformedListings = await transformedListingsPromise;
1845
+ const transformedDisplayById = Object.fromEntries(transformedProducts.map(display => [$b85edfec41cd3989$export$548d053aba053d79(display), display]));
1846
+ return transformedListings.map(listing => $3hooq$solidjs.mergeProps(listing, {
1847
+ // use mergeProps because in preview browser we add getters in this object, that would be called too early otherwise
1848
+ displays: (displayIdsPerListingId[listing.listing_id] || []).map(displayId => transformedDisplayById[displayId]).filter(v => v)
1849
+ }));
1850
+ } catch (e) {
1851
+ $3hooq$depictaiutilishared.dwarn("Displaytransformers threw", e);
1852
+ return [];
1853
+ }
1854
+ }
1612
1855
  const $cfcd56242923775d$export$3064e1e8c6513da3 = new Set();
1613
1856
  let $cfcd56242923775d$var$has_ran = false;
1614
1857
  function $cfcd56242923775d$export$5162a71f252e6122() {
@@ -1650,15 +1893,6 @@ function $cfcd56242923775d$var$starts_with_any_prefix(key) {
1650
1893
  }
1651
1894
  }
1652
1895
 
1653
- /**
1654
- * This function is used to determine if the user is trying to open a link in a new tab or window, and we therefore should not single page navigate
1655
- * @param clickEvent The click event that triggered the navigation
1656
- */
1657
- function $9ca08bcacbc598ce$export$29d28dadc2d6b631(clickEvent) {
1658
- return (clickEvent === null || clickEvent === void 0 ? void 0 : clickEvent.button) || (clickEvent === null || clickEvent === void 0 ? void 0 : clickEvent.metaKey) || (clickEvent === null || clickEvent === void 0 ? void 0 : clickEvent.ctrlKey) || (clickEvent === null || clickEvent === void 0 ? void 0 : clickEvent.shiftKey // if true, shift button on windows, linux or macOS which opens in a new window
1659
- );
1660
- }
1661
-
1662
1896
  /**
1663
1897
  * Symbol used to identify the version of a SearchModal function. Values right now: 1 = 1st gen classic modal, 2 = second gen modal
1664
1898
  */
@@ -1699,12 +1933,6 @@ function $bdea39a75c454f4f$export$f50b88e2a00918b5(fn) {
1699
1933
  }
1700
1934
  };
1701
1935
  }
1702
- function $f38f2e64ebe2da86$export$a71e92cfbb498adc(props) {
1703
- return $3hooq$solidjs.createMemo(() => {
1704
- const price_formatting = props.price_formatting_;
1705
- return $3hooq$depictaiutilishared.standard_price_format(props.price_, price_formatting.places_after_comma_, price_formatting.decimal_places_delimiter_, price_formatting.thousands_delimiter_);
1706
- });
1707
- }
1708
1936
  function $b0f8d9f49e018db9$export$fb40a80c530e5f2b(selectedIndex, groupIndex, indexInGroup) {
1709
1937
  const isSelected = $3hooq$solidjs.createMemo(() => {
1710
1938
  const selectedValue = selectedIndex();
@@ -4254,120 +4482,6 @@ function $367b536a2a94d24e$var$history_state_change(signals, entries, state) {
4254
4482
  }
4255
4483
  });
4256
4484
  }
4257
- function $73014ff36186a4dd$var$_classPrivateMethodInitSpec(obj, privateSet) {
4258
- $73014ff36186a4dd$var$_checkPrivateRedeclaration(obj, privateSet);
4259
- privateSet.add(obj);
4260
- }
4261
- function $73014ff36186a4dd$var$_checkPrivateRedeclaration(obj, privateCollection) {
4262
- if (privateCollection.has(obj)) throw new TypeError("Cannot initialize the same private elements twice on an object");
4263
- }
4264
- function $73014ff36186a4dd$var$_classPrivateMethodGet(receiver, privateSet, fn) {
4265
- if (!privateSet.has(receiver)) throw new TypeError("attempted to get private field on non-instance");
4266
- return fn;
4267
- }
4268
- var $73014ff36186a4dd$var$_throwing_on_navigation = /*#__PURE__*/new WeakSet();
4269
- var $73014ff36186a4dd$var$_get_navigation_happened_promise = /*#__PURE__*/new WeakSet();
4270
- class $73014ff36186a4dd$export$7e1297a3a19f10d8 {
4271
- /**
4272
- * Function that will be called when we want to navigate, or a string saying it's not an SPA. You can change this OTG
4273
- */ /**
4274
- * We store listing_id in history.state and do operate on this both here and in js-ui, this is the key to be used which js-ui provides
4275
- */ /**
4276
- * Vue has async router that needs to be awaited (it navigates after a microtask)
4277
- * This standardises waiting for all kinds of routers
4278
- */
4279
- constructor(on_navigation, listing_query_state_key) {
4280
- $73014ff36186a4dd$var$_classPrivateMethodInitSpec(this, $73014ff36186a4dd$var$_get_navigation_happened_promise);
4281
- $73014ff36186a4dd$var$_classPrivateMethodInitSpec(this, $73014ff36186a4dd$var$_throwing_on_navigation);
4282
- $parcel$interopDefault($3hooq$babelruntimehelpersdefineProperty)(this, "on_navigation_", void 0);
4283
- $parcel$interopDefault($3hooq$babelruntimehelpersdefineProperty)(this, "listing_query_state_key", void 0);
4284
- $parcel$interopDefault($3hooq$babelruntimehelpersdefineProperty)(this, "navigate_", {
4285
- /**
4286
- * Call this if you *just* want to replace the state object in history.state
4287
- */
4288
- replace_state_: new_state => {
4289
- var _globalThis$history;
4290
- // This doesn't break any router, so we just do this directly for now, since many don't expose an interface for changing the state
4291
- globalThis === null || globalThis === void 0 || (_globalThis$history = globalThis.history) === null || _globalThis$history === void 0 || _globalThis$history.replaceState(new_state, "");
4292
- },
4293
- /**
4294
- * Call this to change the URL
4295
- * @param new_url_ new URL to go to
4296
- * @param event_ event if you have this in a click handler, will not do anything on cmd/ctrl or non-left click then
4297
- * @param force_spa_navigation_ if you want to force SPA navigation even if on_navigation_ is set to "hard_navigation". You should only set this to true for inter-SDK-page navigations
4298
- * @param is_replace_ if you want to replace the current URL in history instead of pushing a new one
4299
- * @param listing_id_ If you are navigating to a category and know the listing_id of, please provide it. This is for making a better devEx in js-ui
4300
- */
4301
- go_to_: $3hooq$depictaiutilishared.catchify(async _ref => {
4302
- let {
4303
- new_url_: raw_new_url,
4304
- event_: event_,
4305
- force_spa_navigation_: force_spa_navigation_,
4306
- is_replace_: is_replace_,
4307
- listing_query_: listing_query_,
4308
- scroll = true
4309
- } = _ref;
4310
- const new_url_ = raw_new_url instanceof URL ? raw_new_url : new URL(raw_new_url, location.origin);
4311
- const wants_hard_navigation = this.on_navigation_ === "hard_navigation";
4312
- if ($9ca08bcacbc598ce$export$29d28dadc2d6b631(event_)) return;
4313
- const different_origin = new_url_.origin !== location.origin;
4314
- if (wants_hard_navigation && (!force_spa_navigation_ || different_origin)) {
4315
- if (force_spa_navigation_ && different_origin)
4316
- // If we call history.pushState on a different origin, it will throw an error, so fallback to hard navigations
4317
- $3hooq$depictaiutilishared.dwarn("Can't single page navigate to", new_url_.href, "due to different origin, this MIGHT mean you should fix the URLs");
4318
- if (!event_)
4319
- // If we haven't gotten an event, nothing will happen by not calling prevent default, so we need to change the URL
4320
- location.assign(new_url_);
4321
- return;
4322
- }
4323
- event_ === null || event_ === void 0 || event_.preventDefault();
4324
- const promise = $73014ff36186a4dd$var$_classPrivateMethodGet(this, $73014ff36186a4dd$var$_get_navigation_happened_promise, $73014ff36186a4dd$var$_get_navigation_happened_promise2).call(this, true);
4325
- if (force_spa_navigation_ && wants_hard_navigation) {
4326
- // Don't allow hard navigation if we're forcing SPA navigation, which we do for things where PageReplacer can be used for performance
4327
- const new_state = history.state;
4328
- if (listing_query_) {
4329
- // In JS-UI we need to know the listing_id of the current category, therefore push it into state
4330
- if (!this.listing_query_state_key) $3hooq$depictaiutilishared.report(new Error("listing_query_state_key is not set"), "error");
4331
- new_state[this.listing_query_state_key] = listing_query_;
4332
- }
4333
- history[is_replace_ ? "replaceState" : "pushState"](new_state, "", new_url_);
4334
- } else $73014ff36186a4dd$var$_classPrivateMethodGet(this, $73014ff36186a4dd$var$_throwing_on_navigation, $73014ff36186a4dd$var$_throwing_on_navigation2).call(this, {
4335
- is_replace: is_replace_,
4336
- new_url: new_url_ instanceof URL ? new_url_ : new URL(new_url_, location.origin),
4337
- scroll: scroll
4338
- });
4339
- await promise;
4340
- })
4341
- });
4342
- this.listing_query_state_key = listing_query_state_key;
4343
- this.on_navigation_ = on_navigation;
4344
- }
4345
- }
4346
- function $73014ff36186a4dd$var$_throwing_on_navigation2() {
4347
- const {
4348
- on_navigation_: on_navigation_
4349
- } = this;
4350
- if (typeof on_navigation_ !== "function") throw new Error("on_navigation_ is not a function");
4351
- // make sure that we don't accidentally catchify if the SDK consumer has fucked up
4352
- try {
4353
- return on_navigation_(...arguments);
4354
- } catch (e) {
4355
- queueMicrotask(() => {
4356
- throw e;
4357
- });
4358
- }
4359
- }
4360
- function $73014ff36186a4dd$var$_get_navigation_happened_promise2(is_replace) {
4361
- return new Promise(resolve => {
4362
- const handler = what_happened => {
4363
- if (what_happened === (is_replace ? "replaceState" : "pushState")) {
4364
- resolve();
4365
- (0, $3hooq$depictaiutilishared.instant_exec_on_suspect_history_change).delete(handler);
4366
- }
4367
- };
4368
- (0, $3hooq$depictaiutilishared.instant_exec_on_suspect_history_change).add(handler);
4369
- });
4370
- }
4371
4485
  var $c8e3c11062d8380b$var$_tmpl$ = ["<div", ' class="image-container">', "</div>"];
4372
4486
  function $c8e3c11062d8380b$export$41e1a079d40a0d58(props) {
4373
4487
  const [display] = $3hooq$solidjs.createResource(() => ({