@depict-ai/ui 4.10.19 → 4.10.21

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.
@@ -115,7 +115,7 @@ $parcel$export(module.exports, "BreadCrumbs", () => $335c02c1241a9ca8$export$5b7
115
115
  $parcel$export(module.exports, "QuickLinks", () => $335c02c1241a9ca8$export$de035477d6fef996);
116
116
  $parcel$export(module.exports, "CategoryPage", () => $c10e33c4681f8c9b$export$e2bf8ce7779e827e);
117
117
  /*! Depict.ai search and product listing SDK */
118
- const $aa1938dec50d6c12$export$83d89fbfd8236492 = "4.10.19";
118
+ const $aa1938dec50d6c12$export$83d89fbfd8236492 = "4.10.21";
119
119
  function $3e17e871e9d0911d$export$d9f36cf74e24d595(media_query) {
120
120
  const signal = $3hooq$solidjs.createSignal(false);
121
121
  $3hooq$solidjs.onCleanup($3hooq$depictaiutilishared.javascript_media_query(media_query, _ref => {
@@ -2218,6 +2218,63 @@ function $c5842bdb10e57229$export$fecbb157621501bd(_ref) {
2218
2218
  }));
2219
2219
  return outmost_element;
2220
2220
  }
2221
+
2222
+ /**
2223
+ * `HTMLElement.focus()` is a **silent no-op** on an element that is not being rendered
2224
+ * (`display: none`, `visibility: hidden`, a collapsed menu). Nothing throws, focus simply
2225
+ * stays where it was, so a caller that does not check believes it restored focus when it
2226
+ * left it on `<body>` — which puts the keyboard user back at the top of the document.
2227
+ *
2228
+ * That is reachable whenever the element which opened a modal stops being rendered while the
2229
+ * modal is open, and the common way for that to happen is the responsive-duplicate header:
2230
+ * a theme renders the same search trigger twice, once for desktop and once for mobile, and
2231
+ * hides one at the current breakpoint. Open the modal from the desktop trigger, cross the
2232
+ * breakpoint (rotate a tablet, resize a window), close the modal, and the remembered trigger
2233
+ * is still `isConnected` but no longer rendered. Verified against a live merchant storefront
2234
+ * on 4.10.19.
2235
+ *
2236
+ * So: verify that focus landed, and when it did not, look for a rendered twin of the same
2237
+ * control — the other half of the responsive pair — and use that instead.
2238
+ */ /**
2239
+ * An element can only take focus if it is actually being rendered.
2240
+ *
2241
+ * Injectable because it is the one part of this module that needs a layout engine: jsdom
2242
+ * reports no client rects for anything, so the specs pass their own predicate to exercise the
2243
+ * matching rules. The real predicate is only exercised in a browser.
2244
+ */
2245
+ const $1573c1a34371380a$export$e0652711c614c755 = element => !!element.getClientRects().length;
2246
+ /**
2247
+ * `document.activeElement` is the outermost shadow host when focus is inside a shadow tree,
2248
+ * so ask the element's own root rather than the document — matching how the rest of
2249
+ * modal_opener treats shadow-mounted modals.
2250
+ */
2251
+ const $1573c1a34371380a$var$has_focus = element => element.getRootNode().activeElement === element;
2252
+ /**
2253
+ * The accessible-name-ish identity we match twins on. Deliberately narrow: an explicit label
2254
+ * or the trimmed text. Two controls that share a tag and this string are the same control
2255
+ * rendered twice, which is exactly the responsive-duplicate case.
2256
+ */
2257
+ const $1573c1a34371380a$var$identity_of = element => (element.getAttribute("aria-label") || element.getAttribute("title") || element.textContent || "").trim().replace(/\s+/g, " ");
2258
+ function $1573c1a34371380a$export$5800d9d535a06e96(element) {
2259
+ let rendered = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : $1573c1a34371380a$export$e0652711c614c755;
2260
+ const identity = $1573c1a34371380a$var$identity_of(element);
2261
+ if (!identity) return; // nothing to match on — an icon-only button with no label
2262
+ const twins = [...element.ownerDocument.querySelectorAll(element.localName)].filter(candidate => candidate !== element && rendered(candidate) && $1573c1a34371380a$var$identity_of(candidate) === identity);
2263
+ return twins.length === 1 ? twins[0] : undefined;
2264
+ }
2265
+ function $1573c1a34371380a$export$51461d633c351649(element) {
2266
+ let rendered = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : $1573c1a34371380a$export$e0652711c614c755;
2267
+ element.focus({
2268
+ preventScroll: true
2269
+ });
2270
+ if ($1573c1a34371380a$var$has_focus(element)) return true;
2271
+ const twin = $1573c1a34371380a$export$5800d9d535a06e96(element, rendered);
2272
+ if (!twin) return false;
2273
+ twin.focus({
2274
+ preventScroll: true
2275
+ });
2276
+ return $1573c1a34371380a$var$has_focus(twin);
2277
+ }
2221
2278
  async function $4cf7d9829d60d844$export$79b1565500412d9b(search_modal, modal_fn_opts, parent) {
2222
2279
  const body = parent || document.body || (await (0, $3hooq$depictaiutilishared.observer).wait_for_element("body"));
2223
2280
  let dispose_and_remove;
@@ -2249,8 +2306,10 @@ async function $4cf7d9829d60d844$export$79b1565500412d9b(search_modal, modal_fn_
2249
2306
  const modal_els = $3hooq$solidjs.createRoot(dispose => {
2250
2307
  let closing_animation;
2251
2308
  let animation_started;
2309
+ let focus_target_after_close;
2252
2310
  dispose_and_remove = () => {
2253
2311
  const actually_close = () => {
2312
+ var _focus_target_after_c;
2254
2313
  dispose();
2255
2314
  on_dispose === null || on_dispose === void 0 || on_dispose();
2256
2315
  const {
@@ -2269,13 +2328,24 @@ async function $4cf7d9829d60d844$export$79b1565500412d9b(search_modal, modal_fn_
2269
2328
  }
2270
2329
  el.remove();
2271
2330
  });
2272
- if (should_restore_focus && element_focused_before_open !== null && element_focused_before_open !== void 0 && element_focused_before_open.isConnected) {
2331
+ const requested_focus_target = (_focus_target_after_c = focus_target_after_close) === null || _focus_target_after_c === void 0 ? void 0 : _focus_target_after_c();
2332
+ if (should_restore_focus && (requested_focus_target !== null && requested_focus_target !== void 0 && requested_focus_target.isConnected || element_focused_before_open !== null && element_focused_before_open !== void 0 && element_focused_before_open.isConnected)) {
2273
2333
  restoring_focus = true;
2274
2334
  try {
2275
2335
  // preventScroll so this can't re-introduce the safari page-jump the blur() above works around
2276
- element_focused_before_open.focus({
2277
- preventScroll: true
2278
- });
2336
+ let focused = false;
2337
+ if (requested_focus_target !== null && requested_focus_target !== void 0 && requested_focus_target.isConnected) {
2338
+ requested_focus_target.focus({
2339
+ preventScroll: true
2340
+ });
2341
+ focused = requested_focus_target.getRootNode().activeElement === requested_focus_target;
2342
+ }
2343
+ if (!focused && element_focused_before_open !== null && element_focused_before_open !== void 0 && element_focused_before_open.isConnected)
2344
+ // restore_focus_to rather than a bare focus(): the remembered trigger can be
2345
+ // connected but no longer rendered (a responsive-duplicate header whose other
2346
+ // half is showing now), and focus() on an unrendered element silently does
2347
+ // nothing, leaving the keyboard user at the top of the page.
2348
+ $1573c1a34371380a$export$51461d633c351649(element_focused_before_open);
2279
2349
  } finally {
2280
2350
  // Cleared on a task instead of synchronously in case a browser delivers the focus event async
2281
2351
  setTimeout(() => restoring_focus = false, 0);
@@ -2295,7 +2365,8 @@ async function $4cf7d9829d60d844$export$79b1565500412d9b(search_modal, modal_fn_
2295
2365
  ...extra_options_for_modal,
2296
2366
  close_modal_: close_modal_,
2297
2367
  open_modal_: open_modal_,
2298
- register_closing_animation_: animation => closing_animation = animation
2368
+ register_closing_animation_: animation => closing_animation = animation,
2369
+ set_focus_target_after_close_: get_target => focus_target_after_close = get_target
2299
2370
  });
2300
2371
  });
2301
2372
  body.append(...modal_els);
@@ -8033,20 +8104,28 @@ function $73014ff36186a4dd$var$_classPrivateMethodGet(receiver, privateSet, fn)
8033
8104
  }
8034
8105
  var $73014ff36186a4dd$var$_throwing_on_navigation = /*#__PURE__*/new WeakSet();
8035
8106
  var $73014ff36186a4dd$var$_get_navigation_happened_promise = /*#__PURE__*/new WeakSet();
8107
+ var $73014ff36186a4dd$var$_watch_for_navigation_to_same_href = /*#__PURE__*/new WeakSet();
8036
8108
  class $73014ff36186a4dd$export$7e1297a3a19f10d8 {
8037
8109
  /**
8038
8110
  * Function that will be called when we want to navigate, or a string saying it's not an SPA. You can change this OTG
8039
8111
  */ /**
8040
8112
  * 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
8041
8113
  */ /**
8042
- * Vue has async router that needs to be awaited (it navigates after a microtask)
8043
- * This standardises waiting for all kinds of routers
8044
- */
8114
+ * Called when a go_to_ didn't change location.href, for example when following a link to the page one is already on. href_change_ipns stays silent then, so whoever waits for a href change to react to a navigation has to listen here too
8115
+ */ /**
8116
+ * Vue has async router that needs to be awaited (it navigates after a microtask)
8117
+ * This standardises waiting for all kinds of routers
8118
+ */ /**
8119
+ * Calls navigation_to_same_href_listeners_ if the navigation we're about to request ends on the href we're already on
8120
+ * @returns function to stop watching, call it when the navigation failed
8121
+ */
8045
8122
  constructor(on_navigation, listing_query_state_key) {
8123
+ $73014ff36186a4dd$var$_classPrivateMethodInitSpec(this, $73014ff36186a4dd$var$_watch_for_navigation_to_same_href);
8046
8124
  $73014ff36186a4dd$var$_classPrivateMethodInitSpec(this, $73014ff36186a4dd$var$_get_navigation_happened_promise);
8047
8125
  $73014ff36186a4dd$var$_classPrivateMethodInitSpec(this, $73014ff36186a4dd$var$_throwing_on_navigation);
8048
8126
  $parcel$interopDefault($3hooq$babelruntimehelpersdefineProperty)(this, "on_navigation_", void 0);
8049
8127
  $parcel$interopDefault($3hooq$babelruntimehelpersdefineProperty)(this, "listing_query_state_key", void 0);
8128
+ $parcel$interopDefault($3hooq$babelruntimehelpersdefineProperty)(this, "navigation_to_same_href_listeners_", new Set());
8050
8129
  $parcel$interopDefault($3hooq$babelruntimehelpersdefineProperty)(this, "navigate_", {
8051
8130
  /**
8052
8131
  * Call this if you *just* want to replace the state object in history.state
@@ -8088,6 +8167,7 @@ class $73014ff36186a4dd$export$7e1297a3a19f10d8 {
8088
8167
  }
8089
8168
  event_ === null || event_ === void 0 || event_.preventDefault();
8090
8169
  const promise = $73014ff36186a4dd$var$_classPrivateMethodGet(this, $73014ff36186a4dd$var$_get_navigation_happened_promise, $73014ff36186a4dd$var$_get_navigation_happened_promise2).call(this, true);
8170
+ const stop_watching_for_same_href = $73014ff36186a4dd$var$_classPrivateMethodGet(this, $73014ff36186a4dd$var$_watch_for_navigation_to_same_href, $73014ff36186a4dd$var$_watch_for_navigation_to_same_href2).call(this, new_url_);
8091
8171
  if (force_spa_navigation_ && wants_hard_navigation) {
8092
8172
  // Don't allow hard navigation if we're forcing SPA navigation, which we do for things where PageReplacer can be used for performance
8093
8173
  const new_state = history.state;
@@ -8101,7 +8181,7 @@ class $73014ff36186a4dd$export$7e1297a3a19f10d8 {
8101
8181
  is_replace: is_replace_,
8102
8182
  new_url: new_url_ instanceof URL ? new_url_ : new URL(new_url_, location.href),
8103
8183
  scroll: scroll
8104
- });
8184
+ }, stop_watching_for_same_href);
8105
8185
  await promise;
8106
8186
  })
8107
8187
  });
@@ -8109,15 +8189,16 @@ class $73014ff36186a4dd$export$7e1297a3a19f10d8 {
8109
8189
  this.on_navigation_ = on_navigation;
8110
8190
  }
8111
8191
  }
8112
- function $73014ff36186a4dd$var$_throwing_on_navigation2() {
8192
+ function $73014ff36186a4dd$var$_throwing_on_navigation2(options, on_throw_) {
8113
8193
  const {
8114
8194
  on_navigation_: on_navigation_
8115
8195
  } = this;
8116
8196
  if (typeof on_navigation_ !== "function") throw new Error("on_navigation_ is not a function");
8117
8197
  // make sure that we don't accidentally catchify if the SDK consumer has fucked up
8118
8198
  try {
8119
- return on_navigation_(...arguments);
8199
+ return on_navigation_(options);
8120
8200
  } catch (e) {
8201
+ on_throw_ === null || on_throw_ === void 0 || on_throw_();
8121
8202
  queueMicrotask(() => {
8122
8203
  throw e;
8123
8204
  });
@@ -8134,6 +8215,24 @@ function $73014ff36186a4dd$var$_get_navigation_happened_promise2(is_replace) {
8134
8215
  (0, $3hooq$depictaiutilishared.instant_exec_on_suspect_history_change).add(handler);
8135
8216
  });
8136
8217
  }
8218
+ function $73014ff36186a4dd$var$_watch_for_navigation_to_same_href2(target_url) {
8219
+ const href_before = location.href;
8220
+ const stop_watching = () => {
8221
+ (0, $3hooq$depictaiutilishared.instant_exec_on_suspect_history_change).delete(on_history_change);
8222
+ clearTimeout(timeout);
8223
+ };
8224
+ const notify_if_href_unchanged = $3hooq$depictaiutilishared.catchify(() => {
8225
+ stop_watching();
8226
+ if (location.href !== href_before) return;
8227
+ this.navigation_to_same_href_listeners_.forEach(listener => $3hooq$depictaiutilishared.catchify(listener)());
8228
+ });
8229
+ // The router has acted once it touches history, if the href is still the same then it took us to the page we're on
8230
+ const on_history_change = () => notify_if_href_unchanged();
8231
+ // A router asked to go to the exact href we're on might not touch history at all, so don't wait longer than 500ms for it. For any other target we can't tell a slow navigation from one that goes nowhere, so only stop listening after a while
8232
+ const timeout = target_url.href === href_before ? setTimeout(notify_if_href_unchanged, 500) : setTimeout(stop_watching, 10000);
8233
+ (0, $3hooq$depictaiutilishared.instant_exec_on_suspect_history_change).add(on_history_change);
8234
+ return stop_watching;
8235
+ }
8137
8236
  var $2c920813c92d6987$var$_tmpl$ = ["<button", ' class="show-more major" type="button">', "</button>"],
8138
8237
  $2c920813c92d6987$var$_tmpl$2 = ["<h2", ' class="recs-title">', "</h2>"],
8139
8238
  $2c920813c92d6987$var$_tmpl$3 = ["<div", ' class="recommendation-grid"><!--$-->', "<!--/--><!--$-->", "<!--/--></div>"];
@@ -9383,6 +9482,7 @@ function $34934309832515dc$export$f7658c347b037c3f() {
9383
9482
  var $29e5dbeb69da7a36$var$_tmpl$ = ["<div", ' style="', '" class="spacer"></div>'],
9384
9483
  $29e5dbeb69da7a36$var$_tmpl$2 = ['<div class="field"><!--$-->', "<!--/-->", "<!--$-->", "<!--/--></div>"],
9385
9484
  $29e5dbeb69da7a36$var$_tmpl$3 = ["<button", ' class="submit major" type="button"', ">", "</button>"];
9485
+ const $29e5dbeb69da7a36$var$keys_not_opening_modal = new Set(["Tab", "Shift", "Control", "Alt", "AltGraph", "Meta", "CapsLock", "Escape", "ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight", "PageUp", "PageDown", "Home", "End", "Insert", "ContextMenu", "NumLock", "ScrollLock", "Pause", "PrintScreen"]);
9386
9486
  function $29e5dbeb69da7a36$export$b94867ecbd698f21(_ref) {
9387
9487
  let {
9388
9488
  search_field_value_: [searchFieldValue, setSearchFieldValue],
@@ -9505,11 +9605,17 @@ var $820f2920cc576f7e$var$_tmpl$ = ["<svg", ' xmlns="http://www.w3.org/2000/svg"
9505
9605
  function $820f2920cc576f7e$export$8d8893ffd8aca39a() {
9506
9606
  return $3hooq$solidjsweb.ssr($820f2920cc576f7e$var$_tmpl$, $3hooq$solidjsweb.ssrHydrationKey());
9507
9607
  }
9508
- function $4b71b4fabdee5753$export$93d9bfd0c9c1a5b8(close_modal, search_query_url_param_name_) {
9608
+ function $4b71b4fabdee5753$export$93d9bfd0c9c1a5b8(close_modal, search_query_url_param_name_, router_) {
9509
9609
  const [exit_iterable, exitable_iterable] = $3hooq$depictaiutilishared.make_asyncIterable_exiter((0, $3hooq$depictaiutilishared.href_change_ipns));
9610
+ const {
9611
+ navigation_to_same_href_listeners_: navigation_to_same_href_listeners_
9612
+ } = router_;
9510
9613
  let set_initial_values = false;
9511
9614
  let old_pathname;
9512
9615
  let old_param_value;
9616
+ // A card linking to the page one is already on doesn't change the href, close the modal anyway so the click does something
9617
+ navigation_to_same_href_listeners_.add(close_modal);
9618
+ $3hooq$solidjs.onCleanup(() => navigation_to_same_href_listeners_.delete(close_modal));
9513
9619
  $3hooq$solidjs.onCleanup($3hooq$depictaiutilishared.catchify(exit_iterable));
9514
9620
  $3hooq$depictaiutilishared.catchify(async () => {
9515
9621
  for await (const href of exitable_iterable) {
@@ -9528,6 +9634,33 @@ function $4b71b4fabdee5753$export$93d9bfd0c9c1a5b8(close_modal, search_query_url
9528
9634
  }
9529
9635
  })();
9530
9636
  }
9637
+ function $9ccac7b807fe6451$export$9e9e2ae069cf2fe1(_ref) {
9638
+ let {
9639
+ props_search_field_value_: props_search_field_value_,
9640
+ props_submit_query_: props_submit_query_,
9641
+ dont_sync_search_field_value_except_on_submit_: dont_sync_search_field_value_except_on_submit_,
9642
+ set_focus_target_after_close_: set_focus_target_after_close_,
9643
+ get_search_page_input_element_: get_search_page_input_element_
9644
+ } = _ref;
9645
+ const search_field_value_ = dont_sync_search_field_value_except_on_submit_ ? $3hooq$solidjs.createSignal("") : props_search_field_value_;
9646
+ let submits_in_flight = 0;
9647
+ const submit_query_ = async function () {
9648
+ let new_query = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : $3hooq$solidjs.untrack(search_field_value_[0]);
9649
+ submits_in_flight++;
9650
+ try {
9651
+ return await props_submit_query_(new_query, () => set_focus_target_after_close_(get_search_page_input_element_));
9652
+ } finally {
9653
+ submits_in_flight--;
9654
+ }
9655
+ };
9656
+ if (dont_sync_search_field_value_except_on_submit_) $3hooq$solidjs.createEffect($3hooq$solidjs.on(search_field_value_[0], value => submits_in_flight > 0 && props_search_field_value_[1](value), {
9657
+ defer: true
9658
+ }));
9659
+ return {
9660
+ search_field_value_: search_field_value_,
9661
+ submit_query_: submit_query_
9662
+ };
9663
+ }
9531
9664
  var $9035b24c2dbd3f36$var$_tmpl$ = ["<div", ' class="discover-more"><button class="major" type="button">', "</button></div>"],
9532
9665
  $9035b24c2dbd3f36$var$_tmpl$2 = ["<b", ">", "</b>"],
9533
9666
  $9035b24c2dbd3f36$var$_tmpl$3 = ["<div", ' class="', '"><div class="', '" role="search" aria-label="Search modal with search field, query suggestions and result preview"><!--$-->', '<!--/--><div id="depict-suggestions-and-result-preview" class="padded"><!--$-->', "<!--/--><!--$-->", "<!--/--><!--$-->", "<!--/--></div><!--$-->", "<!--/--></div><!--$-->", "<!--/--></div>"],
@@ -9542,6 +9675,8 @@ function $9035b24c2dbd3f36$var$RawClassicSearchModal(_ref) {
9542
9675
  search_query_url_param_name_: search_query_url_param_name_,
9543
9676
  previous_searches_: previous_searches_,
9544
9677
  close_modal_: close_modal_,
9678
+ set_focus_target_after_close_: set_focus_target_after_close_,
9679
+ get_search_page_input_element_: get_search_page_input_element_,
9545
9680
  depict_api_: depict_api_,
9546
9681
  merchant_: merchant_,
9547
9682
  market_: market_,
@@ -9566,15 +9701,16 @@ function $9035b24c2dbd3f36$var$RawClassicSearchModal(_ref) {
9566
9701
  // As per feedback from stronger we sometimes want a modal with the search field value disconnected from the one in the rest of the UI, see https://depictaiworkspace.slack.com/archives/C02J16R9XEH/p1679065878487709.
9567
9702
  // This is desired for when the modal is opened from a UI element that visually does not look connected with the search page or current query
9568
9703
  // Basically the UI signals that the button that opens the modal starts a new search.
9569
- const search_field_value_ = dont_sync_search_field_value_except_on_submit_ ? $3hooq$solidjs.createSignal("") : props_search_field_value;
9570
- const propagate_search_field_value_back = dont_sync_search_field_value_except_on_submit_ ? () => props_search_field_value[1]($3hooq$solidjs.untrack(search_field_value_[0])) // Set actual search field value to the throwaway internal one before submitting
9571
- : undefined;
9572
- const submit_query_ = function () {
9573
- // submit_query expects to read the current search field value which is why we have to write the current one to the signal before calling it
9574
- // It will write the old one back and then write the new one after submit
9575
- propagate_search_field_value_back === null || propagate_search_field_value_back === void 0 || propagate_search_field_value_back();
9576
- return props_submit_query(...arguments);
9577
- };
9704
+ const {
9705
+ search_field_value_: search_field_value_,
9706
+ submit_query_: submit_query_
9707
+ } = $9ccac7b807fe6451$export$9e9e2ae069cf2fe1({
9708
+ props_search_field_value_: props_search_field_value,
9709
+ props_submit_query_: props_submit_query,
9710
+ dont_sync_search_field_value_except_on_submit_: dont_sync_search_field_value_except_on_submit_,
9711
+ set_focus_target_after_close_: set_focus_target_after_close_,
9712
+ get_search_page_input_element_: get_search_page_input_element_
9713
+ });
9578
9714
  const [input_field, set_input_field] = $3hooq$solidjs.createSignal();
9579
9715
  const [get_search_field_value_] = search_field_value_;
9580
9716
  // Search field alignment unused in ClassicSearchModal since the search field spans the whole modal
@@ -9629,7 +9765,7 @@ function $9035b24c2dbd3f36$var$RawClassicSearchModal(_ref) {
9629
9765
  }
9630
9766
  })));
9631
9767
  if (disable_scrolling_) $8c2e68c6d458169b$export$fe334901e8bebd57();
9632
- $4b71b4fabdee5753$export$93d9bfd0c9c1a5b8(close_modal_, search_query_url_param_name_);
9768
+ $4b71b4fabdee5753$export$93d9bfd0c9c1a5b8(close_modal_, search_query_url_param_name_, router_);
9633
9769
  window.addEventListener("keydown", close_on_escape_handler);
9634
9770
  $3hooq$solidjs.onCleanup($3hooq$depictaiutilishared.catchify(() => window.removeEventListener("keydown", close_on_escape_handler)));
9635
9771
  if (closing_animation_) register_closing_animation_(closing_animation_);
@@ -10207,6 +10343,8 @@ function $43600b30502feeda$var$RawSearchModalV2(_ref) {
10207
10343
  search_query_url_param_name_: search_query_url_param_name_,
10208
10344
  previous_searches_: previous_searches_,
10209
10345
  close_modal_: close_modal_,
10346
+ set_focus_target_after_close_: set_focus_target_after_close_,
10347
+ get_search_page_input_element_: get_search_page_input_element_,
10210
10348
  alignmentSignals_: alignmentSignals_,
10211
10349
  depict_api_: depict_api_,
10212
10350
  merchant_: merchant_,
@@ -10237,15 +10375,16 @@ function $43600b30502feeda$var$RawSearchModalV2(_ref) {
10237
10375
  // As per feedback from stronger we sometimes want a modal with the search field value disconnected from the one in the rest of the UI, see https://depictaiworkspace.slack.com/archives/C02J16R9XEH/p1679065878487709.
10238
10376
  // This is desired for when the modal is opened from a UI element that visually does not look connected with the search page or current query
10239
10377
  // Basically the UI signals that the button that opens the modal starts a new search.
10240
- const search_field_value_ = dont_sync_search_field_value_except_on_submit_ ? $3hooq$solidjs.createSignal("") : props_search_field_value;
10241
- const propagate_search_field_value_back = dont_sync_search_field_value_except_on_submit_ ? () => props_search_field_value[1]($3hooq$solidjs.untrack(search_field_value_[0])) // Set actual search field value to the throwaway internal one before submitting
10242
- : undefined;
10243
- const submit_query_ = function () {
10244
- // submit_query expects to read the current search field value which is why we have to write the current one to the signal before calling it
10245
- // It will write the old one back and then write the new one after submit
10246
- propagate_search_field_value_back === null || propagate_search_field_value_back === void 0 || propagate_search_field_value_back();
10247
- return props_submit_query(...arguments);
10248
- };
10378
+ const {
10379
+ search_field_value_: search_field_value_,
10380
+ submit_query_: submit_query_
10381
+ } = $9ccac7b807fe6451$export$9e9e2ae069cf2fe1({
10382
+ props_search_field_value_: props_search_field_value,
10383
+ props_submit_query_: props_submit_query,
10384
+ dont_sync_search_field_value_except_on_submit_: dont_sync_search_field_value_except_on_submit_,
10385
+ set_focus_target_after_close_: set_focus_target_after_close_,
10386
+ get_search_page_input_element_: get_search_page_input_element_
10387
+ });
10249
10388
  const [input_field, set_input_field] = $3hooq$solidjs.createSignal();
10250
10389
  const [searching_for_value_, set_searching_for_value_] = $3hooq$solidjs.createSignal();
10251
10390
  const [show_stale_content_results_, set_show_stale_content_results_] = $3hooq$solidjs.createSignal(false);
@@ -10359,7 +10498,7 @@ function $43600b30502feeda$var$RawSearchModalV2(_ref) {
10359
10498
  return (((_get_modal_search_res5 = get_modal_search_results_()) === null || _get_modal_search_res5 === void 0 ? void 0 : _get_modal_search_res5.loading) === false && !suggestions_response_.loading || !!prev) && totalNumberResults() === 0 && previous_searches_matching_query().length === 0;
10360
10499
  });
10361
10500
  if (disable_scrolling_) $8c2e68c6d458169b$export$fe334901e8bebd57();
10362
- $4b71b4fabdee5753$export$93d9bfd0c9c1a5b8(close_modal_, search_query_url_param_name_);
10501
+ $4b71b4fabdee5753$export$93d9bfd0c9c1a5b8(close_modal_, search_query_url_param_name_, router_);
10363
10502
  addEventListener("keydown", close_on_escape_handler);
10364
10503
  $3hooq$solidjs.onCleanup(() => removeEventListener("keydown", close_on_escape_handler));
10365
10504
  $3hooq$solidjs.createEffect($3hooq$solidjs.on(get_search_field_value_, () => {
@@ -12254,11 +12393,12 @@ async function $7f680455a2aa1079$export$e16630ecb9644a1c(_ref) {
12254
12393
  let {
12255
12394
  on_submit_with_unchanged_value_: on_submit_with_unchanged_value_,
12256
12395
  search_param_name_: search_param_name_,
12257
- set_search_field_value_: set_search_field_value_,
12396
+ search_field_value_: search_field_value_,
12258
12397
  get_search_query_: get_search_query_,
12259
12398
  url_transformer_: url_transformer_,
12260
12399
  router_: router_,
12261
12400
  after_submit_: after_submit_,
12401
+ before_navigate_: before_navigate_,
12262
12402
  get_new_query: get_new_query
12263
12403
  } = _ref;
12264
12404
  const new_search_query = get_new_query();
@@ -12266,21 +12406,92 @@ async function $7f680455a2aa1079$export$e16630ecb9644a1c(_ref) {
12266
12406
  if (previous_query === new_search_query && new URLSearchParams(location.search).has(search_param_name_)) {
12267
12407
  // don't push a history entry / re-search if someone submits a search again
12268
12408
  // do close the modal though
12409
+ search_field_value_.settle_(new_search_query);
12269
12410
  on_submit_with_unchanged_value_ === null || on_submit_with_unchanged_value_ === void 0 || on_submit_with_unchanged_value_();
12270
- return;
12411
+ return false;
12271
12412
  }
12272
- set_search_field_value_(previous_query); // restore the value to the previous query since this one goes to the new history entry
12273
12413
  const target_url = new URL(location.href);
12274
12414
  url_transformer_ === null || url_transformer_ === void 0 || url_transformer_(target_url);
12275
12415
  target_url.searchParams.set(search_param_name_, new_search_query);
12276
- await router_.navigate_.go_to_({
12277
- new_url_: target_url,
12278
- is_replace_: false,
12279
- force_spa_navigation_: true
12280
- });
12281
- set_search_field_value_(new_search_query);
12416
+ const end_submit = search_field_value_.begin_submit_(new_search_query, previous_query);
12417
+ before_navigate_ === null || before_navigate_ === void 0 || before_navigate_();
12418
+ let landed;
12419
+ try {
12420
+ await router_.navigate_.go_to_({
12421
+ new_url_: target_url,
12422
+ is_replace_: false,
12423
+ force_spa_navigation_: true
12424
+ });
12425
+ } finally {
12426
+ landed = end_submit();
12427
+ }
12428
+ if (!landed) return false;
12282
12429
  scrollTo(0, 0);
12283
12430
  after_submit_ === null || after_submit_ === void 0 || after_submit_();
12431
+ return true;
12432
+ }
12433
+ function $24f1a81b790e371c$export$d13a185c53aa5edf(persisted_, get_search_query_) {
12434
+ const [get_persisted, set_persisted] = persisted_;
12435
+ const [get_submitting, set_submitting] = $3hooq$solidjs.createSignal();
12436
+ const get_value = $3hooq$solidjs.createMemo(() => {
12437
+ var _get_submitting;
12438
+ return (_get_submitting = get_submitting()) !== null && _get_submitting !== void 0 ? _get_submitting : get_persisted();
12439
+ });
12440
+ const set_value = value => {
12441
+ const new_value = typeof value === "function" ? value($3hooq$solidjs.untrack(get_value)) : value;
12442
+ if ($3hooq$solidjs.untrack(get_submitting) === undefined) set_persisted(new_value);else set_submitting(new_value);
12443
+ return new_value;
12444
+ };
12445
+ let current_submit;
12446
+ const end_submit = landed => {
12447
+ current_submit.landed_ = landed;
12448
+ current_submit = undefined;
12449
+ $3hooq$solidjs.batch(() => {
12450
+ const submitting = $3hooq$solidjs.untrack(get_submitting);
12451
+ set_submitting(undefined);
12452
+ if (landed && submitting !== undefined) set_persisted(submitting);
12453
+ });
12454
+ };
12455
+ const abort_on_popstate = what_happened => {
12456
+ if (what_happened === "popstate" && current_submit) end_submit(false);
12457
+ };
12458
+ (0, $3hooq$depictaiutilishared.instant_exec_on_suspect_history_change).add(abort_on_popstate);
12459
+ $3hooq$solidjs.onCleanup(() => (0, $3hooq$depictaiutilishared.instant_exec_on_suspect_history_change).delete(abort_on_popstate));
12460
+ $3hooq$solidjs.createEffect($3hooq$solidjs.on(get_search_query_, query => {
12461
+ const token = current_submit;
12462
+ if (!token || query !== token.query_) return;
12463
+ queueMicrotask(() => {
12464
+ if (current_submit === token) end_submit(true);
12465
+ });
12466
+ }, {
12467
+ defer: true
12468
+ }));
12469
+ const begin_submit_ = (submitted_query, query_of_current_history_entry) => {
12470
+ const token = current_submit = {
12471
+ query_: submitted_query,
12472
+ landed_: false
12473
+ };
12474
+ $3hooq$solidjs.batch(() => {
12475
+ set_submitting(submitted_query);
12476
+ set_persisted(query_of_current_history_entry);
12477
+ });
12478
+ return () => {
12479
+ if (current_submit === token) end_submit(true);
12480
+ return token.landed_;
12481
+ };
12482
+ };
12483
+ const settle_ = query => {
12484
+ if (current_submit) return;
12485
+ $3hooq$solidjs.batch(() => {
12486
+ set_submitting(undefined);
12487
+ set_persisted(query);
12488
+ });
12489
+ };
12490
+ return {
12491
+ value_: [get_value, set_value],
12492
+ begin_submit_: begin_submit_,
12493
+ settle_: settle_
12494
+ };
12284
12495
  }
12285
12496
  function $7a8e55af4ef13fae$export$181cceed5c91919e(callback, alsoRaF, passiveListener) {
12286
12497
  let aligned_this_microtask = false;
@@ -12954,6 +13165,7 @@ function $739c927cbecd26b0$export$a54ec244c8863715(_ref) {
12954
13165
  scroll_restoration_data_: scroll_restoration_data_,
12955
13166
  product_card_template_: product_card_template_,
12956
13167
  modalAlignmentSignalsRef_: modalAlignmentSignalsRef_,
13168
+ inputFieldRef_: inputFieldRef_,
12957
13169
  router_: router_,
12958
13170
  content_results_rows_: content_results_rows_,
12959
13171
  content_layout_options_: content_layout_options_,
@@ -13149,6 +13361,8 @@ function $739c927cbecd26b0$export$a54ec244c8863715(_ref) {
13149
13361
  if (!search_field) break add_input_field;
13150
13362
  setModalBodyStyle({});
13151
13363
  modalAlignmentSignalsRef_ === null || modalAlignmentSignalsRef_ === void 0 || modalAlignmentSignalsRef_(alignmentSignals_);
13364
+ inputFieldRef_ === null || inputFieldRef_ === void 0 || inputFieldRef_(input_element);
13365
+ $3hooq$solidjs.onCleanup(() => inputFieldRef_ === null || inputFieldRef_ === void 0 ? void 0 : inputFieldRef_(undefined));
13152
13366
  const [pollAlignment, setPollAlignment_] = $3hooq$solidjs.createSignal(false);
13153
13367
  const align_position = $3hooq$depictaiutilishared.catchify((0, $d6ed4dbb6507996d$export$b3ad617e9036868))(alignmentSignals_, search_field, (0, $d6ed4dbb6507996d$export$3f238c96c45e6cc6) | (0, $d6ed4dbb6507996d$export$7895aadd1956b1c7) | (modalVersionUsed_ === 1 ? (0, $d6ed4dbb6507996d$export$902f8b4a7dae5d78) : (0, $d6ed4dbb6507996d$export$6060bc6bee850eb6) | (0, $d6ed4dbb6507996d$export$5097308c5200105a)), true, pollAlignment);
13154
13368
  div_with_field_class.addEventListener("click", $3hooq$depictaiutilishared.catchify(e => {
@@ -13517,14 +13731,16 @@ class $ddd39c5f36f49703$export$ac6237957a15b3f0 {
13517
13731
  set_search_content_results_rows((0, $eab939d0b95b75ee$export$70ceae36059a1036));
13518
13732
  }; // do this every time after we have submitted a new query - otherwise there might already be a saved number of rows in the state
13519
13733
  const on_submit_with_unchanged_value_ = () => this.modal_open = false;
13520
- const [get_search_field_value_, set_search_field_value_] = state_.field_value;
13521
- const configured_submit_query_ = new_query => $7f680455a2aa1079$export$e16630ecb9644a1c({
13734
+ const search_field_value_ = $24f1a81b790e371c$export$d13a185c53aa5edf(state_.field_value, get_search_query_);
13735
+ const [get_search_field_value_] = search_field_value_.value_;
13736
+ const configured_submit_query_ = (new_query, before_navigate_) => $7f680455a2aa1079$export$e16630ecb9644a1c({
13522
13737
  on_submit_with_unchanged_value_: on_submit_with_unchanged_value_,
13523
- set_search_field_value_: set_search_field_value_,
13738
+ search_field_value_: search_field_value_,
13524
13739
  get_search_query_: get_search_query_,
13525
13740
  search_param_name_: search_query_url_param_name_,
13526
13741
  after_submit_: after_submit_,
13527
- get_new_query: () => new_query || $3hooq$solidjs.untrack(get_search_field_value_),
13742
+ before_navigate_: before_navigate_,
13743
+ get_new_query: () => new_query !== null && new_query !== void 0 ? new_query : $3hooq$solidjs.untrack(get_search_field_value_),
13528
13744
  url_transformer_: url_transformer,
13529
13745
  router_: $parcel$interopDefault($3hooq$babelruntimehelpersclassPrivateFieldGet)(this, $ddd39c5f36f49703$var$_router)
13530
13746
  });
@@ -13543,6 +13759,7 @@ class $ddd39c5f36f49703$export$ac6237957a15b3f0 {
13543
13759
  search_query_url_param_name_: search_query_url_param_name_,
13544
13760
  reset_history_state_: reset_history_state_,
13545
13761
  state_: state_,
13762
+ search_field_value_: search_field_value_.value_,
13546
13763
  router_: $parcel$interopDefault($3hooq$babelruntimehelpersclassPrivateFieldGet)(this, $ddd39c5f36f49703$var$_router),
13547
13764
  url_transformer_: url_transformer,
13548
13765
  depict_api_: depict_api_,
@@ -13566,7 +13783,11 @@ class $ddd39c5f36f49703$export$ac6237957a15b3f0 {
13566
13783
  $3hooq$solidjs.onCleanup(() => _this.modal_open = false);
13567
13784
  return searchModalComponent(...arguments);
13568
13785
  }, {
13569
- search_field_value_: state_.field_value,
13786
+ search_field_value_: search_field_value_.value_,
13787
+ get_search_page_input_element_: () => {
13788
+ var _privately_shared_pro2;
13789
+ return (_privately_shared_pro2 = $ddd39c5f36f49703$export$dde08b2dca8cc1ce.get(this)) === null || _privately_shared_pro2 === void 0 ? void 0 : _privately_shared_pro2.search_page_input_element_;
13790
+ },
13570
13791
  get_search_query_: get_search_query_,
13571
13792
  search_query_url_param_name_: search_query_url_param_name_,
13572
13793
  previous_searches_: previous_searches,
@@ -13731,6 +13952,7 @@ function $ddd39c5f36f49703$export$f2dc7e4e4aa11abb(props) {
13731
13952
  const {
13732
13953
  state_: state_
13733
13954
  } = shared_properties;
13955
+ let registered_input_element;
13734
13956
  const grid_spacing_override = $3hooq$solidjs.createMemo(() => {
13735
13957
  const {
13736
13958
  grid_spacing: grid_spacing
@@ -13762,7 +13984,7 @@ function $ddd39c5f36f49703$export$f2dc7e4e4aa11abb(props) {
13762
13984
  var _depict_search$enable;
13763
13985
  return (_depict_search$enable = depict_search.enable_content_search) !== null && _depict_search$enable !== void 0 ? _depict_search$enable : $ddd39c5f36f49703$var$content_search_default;
13764
13986
  },
13765
- search_field_value_: state_.field_value,
13987
+ search_field_value_: shared_properties.search_field_value_,
13766
13988
  get_search_query_: shared_properties.get_search_query_,
13767
13989
  clear_filters_on_next_submit_: shared_properties.clear_filters_on_next_submit_,
13768
13990
  open_modal_: function () {
@@ -13773,6 +13995,16 @@ function $ddd39c5f36f49703$export$f2dc7e4e4aa11abb(props) {
13773
13995
  modalVersionUsed_: shared_properties.modalVersionUsed_,
13774
13996
  showSliderArrow_: () => props.showSliderArrow_,
13775
13997
  i18n_: shared_properties.i18n_,
13998
+ inputFieldRef_: input_element => {
13999
+ const shared_info_right_now = $ddd39c5f36f49703$export$dde08b2dca8cc1ce.get(depict_search);
14000
+ if (!shared_info_right_now) return;
14001
+ if (input_element === undefined && shared_info_right_now.search_page_input_element_ !== registered_input_element) return;
14002
+ registered_input_element = input_element;
14003
+ $ddd39c5f36f49703$export$dde08b2dca8cc1ce.set(depict_search, {
14004
+ ...shared_info_right_now,
14005
+ search_page_input_element_: input_element
14006
+ });
14007
+ },
13776
14008
  modalAlignmentSignalsRef_: style => {
13777
14009
  const shared_info_right_now = $ddd39c5f36f49703$export$dde08b2dca8cc1ce.get(depict_search);
13778
14010
  if (!shared_info_right_now) return;
@@ -14219,7 +14451,7 @@ function $98aef9965764903d$export$316f6f283ae64765(props) {
14219
14451
  return shared_properties.BackIcon_;
14220
14452
  },
14221
14453
  get search_field_value_() {
14222
- return shared_properties.state_.field_value;
14454
+ return shared_properties.search_field_value_;
14223
14455
  },
14224
14456
  get submit_query_() {
14225
14457
  return shared_properties.configured_submit_query_;
@@ -14262,7 +14494,7 @@ function $98aef9965764903d$export$316f6f283ae64765(props) {
14262
14494
  return shared_properties.BackIcon_;
14263
14495
  },
14264
14496
  get search_field_value_() {
14265
- return shared_properties.state_.field_value;
14497
+ return shared_properties.search_field_value_;
14266
14498
  },
14267
14499
  get submit_query_() {
14268
14500
  return shared_properties.configured_submit_query_;