
/**
 *   VERSION: 2.240.0-alpha.1
 *   BUILD_TIMESTAMP: 1780360168537
 *   BUILD_DATE: Tue Jun 02 2026 00:29:28 GMT+0000 (Coordinated Universal Time)
 *   BUILD_COMMIT: 758cedd37e00f49a728d704d9ed36884f0f12d79
 */
import { r as s, j as r, aw as _e, R as ee, ax as ne, ay as Te, az as De, aA as oe, aB as S, aC as Je, aD as Ae, aE as Vt, aF as Ht, aG as ke, aH as Ze, aI as Wt, aJ as qt, aK as Yt, aL as Xt, aM as Qt, aN as Jt, aO as Zt, aP as en, aQ as et, a6 as ae, ag as tt, H as tn, E as ue, e as le, l as J, aR as nn, J as on, F as te, aS as rn, aT as He, K as sn, i as nt, aU as an, T as Q, s as cn, aV as Oe, d as ye, w as be, f as un } from "../sheerid.js";
import { F as ln, g as dn } from "./FormFieldLayout-DEVPpEyA.js";
import { u as Ne } from "./downshift.esm-drVP4Tic.js";
import { u as ot, M as X } from "./useMetrics-D11A9UPA.js";
import { i as fn } from "./FormFieldText-CPwStdCx.js";
const rt = s.createContext({
  showOverlay: !1,
  setShowOverlay: () => {
  }
}), pn = () => s.useContext(rt), st = s.createContext(null), Le = () => s.useContext(st);
function mn() {
  const [e, t] = s.useState(null), [n, o] = s.useState(null), [a, c] = s.useState(!1), i = s.useCallback(() => (c(!0), o(null), new Promise((l, p) => {
    navigator.geolocation.getCurrentPosition(
      (f) => {
        const u = {
          latitude: f.coords.latitude,
          longitude: f.coords.longitude
        };
        t(u), c(!1), l(u);
      },
      (f) => {
        const u = { code: f.code, message: f.message };
        o(u), c(!1), p(u);
      }
    );
  })), []);
  return {
    location: e,
    error: n,
    loading: a,
    requestLocation: i
  };
}
const hn = ({ children: e }) => {
  const [t, n] = s.useState("relevance"), [o, a] = s.useState(null), [c, i] = s.useState(!1), l = mn(), p = s.useCallback(async () => {
    try {
      const u = await l.requestLocation();
      return a(u), i(!1), u;
    } catch {
      throw i(!0), new Error("Location denied");
    }
  }, [l]), f = s.useMemo(
    () => ({
      sortMode: t,
      userLocation: o,
      locationDenied: c,
      setSortMode: n,
      requestLocation: p
    }),
    [t, o, c, p]
  );
  return /* @__PURE__ */ r.jsx(st.Provider, { value: f, children: e });
}, gn = 'button, a[href], input, select, textarea, [tabindex]:not([tabindex="-1"])', vn = ({
  children: e,
  enabled: t,
  closeSectionLabel: n
}) => {
  const [o, a] = s.useState(!1), c = s.useRef(null), i = t && o, l = s.useRef(0), p = (f) => {
    if (!t) return;
    const u = window !== window.top;
    if (f && o === !1) {
      if (l.current = window.scrollY, document.body.style.overflow = "hidden", document.body.style.backgroundColor = "rgba(0,0,0,.1)", window.scrollTo({ top: 0 }), u) {
        const d = window.screen.availHeight - 80, g = document.body.clientHeight;
        document.body.style.height = `${Math.min(g, d)}px`;
      }
      c.current && setTimeout(() => {
        c.current.scrollIntoView();
      }, 0);
    }
    f || (document.body.style.overflow = "unset", document.body.style.backgroundColor = "unset", window.scrollTo({ top: l.current }), u && (document.body.style.height = "unset")), a(f);
  };
  return s.useEffect(() => {
    if (!i) return;
    const f = (u) => {
      if (u.key !== "Tab") return;
      const d = c.current;
      if (!d) return;
      const g = d.querySelectorAll(gn), C = g[0], w = g[g.length - 1];
      u.shiftKey && document.activeElement === C ? (u.preventDefault(), w?.focus()) : !u.shiftKey && document.activeElement === w && (u.preventDefault(), C?.focus());
    };
    return document.addEventListener("keydown", f, !0), () => document.removeEventListener("keydown", f, !0);
  }, [i]), t ? /* @__PURE__ */ r.jsx(rt.Provider, { value: { showOverlay: i, setShowOverlay: p }, children: /* @__PURE__ */ r.jsx(hn, { children: /* @__PURE__ */ r.jsx("div", { className: i && "sid-search-overlay__overlay", children: /* @__PURE__ */ r.jsxs("div", { className: i && "sid-search-overlay__container", ref: c, children: [
    i && /* @__PURE__ */ r.jsx("button", { className: "sid-search-overlay__close", onClick: () => p(!1), children: n }),
    e
  ] }) }) }) }) : /* @__PURE__ */ r.jsx(r.Fragment, { children: e });
}, wn = ({ org: e, onClear: t, clearSelectionLabel: n, labelId: o }) => {
  const a = s.useRef(null), c = [e.city, e.state].filter(Boolean).join(", "), i = [e.name, c].filter(Boolean).join(", ");
  return s.useEffect(() => {
    a.current?.focus();
  }, []), /* @__PURE__ */ r.jsxs("div", { className: "sid-selected-org__wrapper", children: [
    /* @__PURE__ */ r.jsx(
      "input",
      {
        ref: a,
        className: "sid-h-screen-reader-only",
        type: "text",
        readOnly: !0,
        "aria-labelledby": o,
        "aria-expanded": !1,
        value: i
      }
    ),
    /* @__PURE__ */ r.jsxs("div", { className: "sid-selected-org__container", children: [
      /* @__PURE__ */ r.jsxs("div", { className: "sid-selected-org__name", "aria-hidden": "true", children: [
        e.name,
        c && /* @__PURE__ */ r.jsx("span", { className: "sid-selected-org__location", children: c })
      ] }),
      /* @__PURE__ */ r.jsx(
        "button",
        {
          className: "sid-selected-org__clear",
          "aria-label": n,
          onClick: t,
          children: "✕"
        }
      )
    ] })
  ] });
}, xn = 6371;
function _n(e, t, n, o) {
  const a = (f) => f * Math.PI / 180, c = a(n - e), i = a(o - t), l = Math.sin(c / 2) * Math.sin(c / 2) + Math.cos(a(e)) * Math.cos(a(n)) * Math.sin(i / 2) * Math.sin(i / 2), p = 2 * Math.atan2(Math.sqrt(l), Math.sqrt(1 - l));
  return xn * p;
}
const Mn = ["en-us", "en-gb"];
function Rn(e) {
  return Mn.includes(e.toLowerCase()) ? "miles" : "kilometers";
}
function Cn(e, t) {
  const n = t === "miles" ? "mi" : "km", o = t === "miles" ? e * 0.621371 : e, a = Math.round(o * 10) / 10;
  return a >= 10 ? `${Math.round(o)} ${n}` : `${a} ${n}`;
}
function at(e) {
  const t = e + "CollectionProvider", [n, o] = _e(t), [a, c] = n(
    t,
    { collectionRef: { current: null }, itemMap: /* @__PURE__ */ new Map() }
  ), i = (v) => {
    const { scope: m, children: x } = v, y = ee.useRef(null), _ = ee.useRef(/* @__PURE__ */ new Map()).current;
    return /* @__PURE__ */ r.jsx(a, { scope: m, itemMap: _, collectionRef: y, children: x });
  };
  i.displayName = t;
  const l = e + "CollectionSlot", p = Te(l), f = ee.forwardRef(
    (v, m) => {
      const { scope: x, children: y } = v, _ = c(l, x), R = ne(m, _.collectionRef);
      return /* @__PURE__ */ r.jsx(p, { ref: R, children: y });
    }
  );
  f.displayName = l;
  const u = e + "CollectionItemSlot", d = "data-radix-collection-item", g = Te(u), C = ee.forwardRef(
    (v, m) => {
      const { scope: x, children: y, ..._ } = v, R = ee.useRef(null), T = ne(m, R), j = c(u, x);
      return ee.useEffect(() => (j.itemMap.set(R, { ref: R, ..._ }), () => {
        j.itemMap.delete(R);
      })), /* @__PURE__ */ r.jsx(g, { [d]: "", ref: T, children: y });
    }
  );
  C.displayName = u;
  function w(v) {
    const m = c(e + "CollectionConsumer", v);
    return ee.useCallback(() => {
      const y = m.collectionRef.current;
      if (!y) return [];
      const _ = Array.from(y.querySelectorAll(`[${d}]`));
      return Array.from(m.itemMap.values()).sort(
        (j, E) => _.indexOf(j.ref.current) - _.indexOf(E.ref.current)
      );
    }, [m.collectionRef, m.itemMap]);
  }
  return [
    { Provider: i, Slot: f, ItemSlot: C },
    w,
    o
  ];
}
var Sn = s.createContext(void 0);
function ct(e) {
  const t = s.useContext(Sn);
  return e || t || "ltr";
}
var Ee = "rovingFocusGroup.onEntryFocus", yn = { bubbles: !1, cancelable: !0 }, pe = "RovingFocusGroup", [je, it, bn] = at(pe), [En, ut] = _e(
  pe,
  [bn]
), [In, Tn] = En(pe), lt = s.forwardRef(
  (e, t) => /* @__PURE__ */ r.jsx(je.Provider, { scope: e.__scopeRovingFocusGroup, children: /* @__PURE__ */ r.jsx(je.Slot, { scope: e.__scopeRovingFocusGroup, children: /* @__PURE__ */ r.jsx(Dn, { ...e, ref: t }) }) })
);
lt.displayName = pe;
var Dn = s.forwardRef((e, t) => {
  const {
    __scopeRovingFocusGroup: n,
    orientation: o,
    loop: a = !1,
    dir: c,
    currentTabStopId: i,
    defaultCurrentTabStopId: l,
    onCurrentTabStopIdChange: p,
    onEntryFocus: f,
    preventScrollOnEntryFocus: u = !1,
    ...d
  } = e, g = s.useRef(null), C = ne(t, g), w = ct(c), [v, m] = Je({
    prop: i,
    defaultProp: l ?? null,
    onChange: p,
    caller: pe
  }), [x, y] = s.useState(!1), _ = Ae(f), R = it(n), T = s.useRef(!1), [j, E] = s.useState(0);
  return s.useEffect(() => {
    const b = g.current;
    if (b)
      return b.addEventListener(Ee, _), () => b.removeEventListener(Ee, _);
  }, [_]), /* @__PURE__ */ r.jsx(
    In,
    {
      scope: n,
      orientation: o,
      dir: w,
      loop: a,
      currentTabStopId: v,
      onItemFocus: s.useCallback(
        (b) => m(b),
        [m]
      ),
      onItemShiftTab: s.useCallback(() => y(!0), []),
      onFocusableItemAdd: s.useCallback(
        () => E((b) => b + 1),
        []
      ),
      onFocusableItemRemove: s.useCallback(
        () => E((b) => b - 1),
        []
      ),
      children: /* @__PURE__ */ r.jsx(
        oe.div,
        {
          tabIndex: x || j === 0 ? -1 : 0,
          "data-orientation": o,
          ...d,
          ref: C,
          style: { outline: "none", ...e.style },
          onMouseDown: S(e.onMouseDown, () => {
            T.current = !0;
          }),
          onFocus: S(e.onFocus, (b) => {
            const L = !T.current;
            if (b.target === b.currentTarget && L && !x) {
              const I = new CustomEvent(Ee, yn);
              if (b.currentTarget.dispatchEvent(I), !I.defaultPrevented) {
                const V = R().filter((D) => D.focusable), O = V.find((D) => D.active), q = V.find((D) => D.id === v), K = [O, q, ...V].filter(
                  Boolean
                ).map((D) => D.ref.current);
                pt(K, u);
              }
            }
            T.current = !1;
          }),
          onBlur: S(e.onBlur, () => y(!1))
        }
      )
    }
  );
}), dt = "RovingFocusGroupItem", ft = s.forwardRef(
  (e, t) => {
    const {
      __scopeRovingFocusGroup: n,
      focusable: o = !0,
      active: a = !1,
      tabStopId: c,
      children: i,
      ...l
    } = e, p = De(), f = c || p, u = Tn(dt, n), d = u.currentTabStopId === f, g = it(n), { onFocusableItemAdd: C, onFocusableItemRemove: w, currentTabStopId: v } = u;
    return s.useEffect(() => {
      if (o)
        return C(), () => w();
    }, [o, C, w]), /* @__PURE__ */ r.jsx(
      je.ItemSlot,
      {
        scope: n,
        id: f,
        focusable: o,
        active: a,
        children: /* @__PURE__ */ r.jsx(
          oe.span,
          {
            tabIndex: d ? 0 : -1,
            "data-orientation": u.orientation,
            ...l,
            ref: t,
            onMouseDown: S(e.onMouseDown, (m) => {
              o ? u.onItemFocus(f) : m.preventDefault();
            }),
            onFocus: S(e.onFocus, () => u.onItemFocus(f)),
            onKeyDown: S(e.onKeyDown, (m) => {
              if (m.key === "Tab" && m.shiftKey) {
                u.onItemShiftTab();
                return;
              }
              if (m.target !== m.currentTarget) return;
              const x = jn(m, u.orientation, u.dir);
              if (x !== void 0) {
                if (m.metaKey || m.ctrlKey || m.altKey || m.shiftKey) return;
                m.preventDefault();
                let _ = g().filter((R) => R.focusable).map((R) => R.ref.current);
                if (x === "last") _.reverse();
                else if (x === "prev" || x === "next") {
                  x === "prev" && _.reverse();
                  const R = _.indexOf(m.currentTarget);
                  _ = u.loop ? Pn(_, R + 1) : _.slice(R + 1);
                }
                setTimeout(() => pt(_));
              }
            }),
            children: typeof i == "function" ? i({ isCurrentTabStop: d, hasTabStop: v != null }) : i
          }
        )
      }
    );
  }
);
ft.displayName = dt;
var On = {
  ArrowLeft: "prev",
  ArrowUp: "prev",
  ArrowRight: "next",
  ArrowDown: "next",
  PageUp: "first",
  Home: "first",
  PageDown: "last",
  End: "last"
};
function Nn(e, t) {
  return t !== "rtl" ? e : e === "ArrowLeft" ? "ArrowRight" : e === "ArrowRight" ? "ArrowLeft" : e;
}
function jn(e, t, n) {
  const o = Nn(e.key, n);
  if (!(t === "vertical" && ["ArrowLeft", "ArrowRight"].includes(o)) && !(t === "horizontal" && ["ArrowUp", "ArrowDown"].includes(o)))
    return On[o];
}
function pt(e, t = !1) {
  const n = document.activeElement;
  for (const o of e)
    if (o === n || (o.focus({ preventScroll: t }), document.activeElement !== n)) return;
}
function Pn(e, t) {
  return e.map((n, o) => e[(t + o) % e.length]);
}
var An = lt, kn = ft, Pe = ["Enter", " "], Ln = ["ArrowDown", "PageUp", "Home"], mt = ["ArrowUp", "PageDown", "End"], Fn = [...Ln, ...mt], Gn = {
  ltr: [...Pe, "ArrowRight"],
  rtl: [...Pe, "ArrowLeft"]
}, Bn = {
  ltr: ["ArrowLeft"],
  rtl: ["ArrowRight"]
}, me = "Menu", [de, Kn, Un] = at(me), [se, ht] = _e(me, [
  Un,
  Ze,
  ut
]), Me = Ze(), gt = ut(), [$n, ce] = se(me), [zn, he] = se(me), vt = (e) => {
  const { __scopeMenu: t, open: n = !1, children: o, dir: a, onOpenChange: c, modal: i = !0 } = e, l = Me(t), [p, f] = s.useState(null), u = s.useRef(!1), d = Ae(c), g = ct(a);
  return s.useEffect(() => {
    const C = () => {
      u.current = !0, document.addEventListener("pointerdown", w, { capture: !0, once: !0 }), document.addEventListener("pointermove", w, { capture: !0, once: !0 });
    }, w = () => u.current = !1;
    return document.addEventListener("keydown", C, { capture: !0 }), () => {
      document.removeEventListener("keydown", C, { capture: !0 }), document.removeEventListener("pointerdown", w, { capture: !0 }), document.removeEventListener("pointermove", w, { capture: !0 });
    };
  }, []), /* @__PURE__ */ r.jsx(Vt, { ...l, children: /* @__PURE__ */ r.jsx(
    $n,
    {
      scope: t,
      open: n,
      onOpenChange: d,
      content: p,
      onContentChange: f,
      children: /* @__PURE__ */ r.jsx(
        zn,
        {
          scope: t,
          onClose: s.useCallback(() => d(!1), [d]),
          isUsingKeyboardRef: u,
          dir: g,
          modal: i,
          children: o
        }
      )
    }
  ) });
};
vt.displayName = me;
var Vn = "MenuAnchor", Fe = s.forwardRef(
  (e, t) => {
    const { __scopeMenu: n, ...o } = e, a = Me(n);
    return /* @__PURE__ */ r.jsx(Ht, { ...a, ...o, ref: t });
  }
);
Fe.displayName = Vn;
var Hn = "MenuPortal", [Cr, wt] = se(Hn, {
  forceMount: void 0
}), z = "MenuContent", [Wn, Ge] = se(z), xt = s.forwardRef(
  (e, t) => {
    const n = wt(z, e.__scopeMenu), { forceMount: o = n.forceMount, ...a } = e, c = ce(z, e.__scopeMenu), i = he(z, e.__scopeMenu);
    return /* @__PURE__ */ r.jsx(de.Provider, { scope: e.__scopeMenu, children: /* @__PURE__ */ r.jsx(ke, { present: o || c.open, children: /* @__PURE__ */ r.jsx(de.Slot, { scope: e.__scopeMenu, children: i.modal ? /* @__PURE__ */ r.jsx(qn, { ...a, ref: t }) : /* @__PURE__ */ r.jsx(Yn, { ...a, ref: t }) }) }) });
  }
), qn = s.forwardRef(
  (e, t) => {
    const n = ce(z, e.__scopeMenu), o = s.useRef(null), a = ne(t, o);
    return s.useEffect(() => {
      const c = o.current;
      if (c) return Wt(c);
    }, []), /* @__PURE__ */ r.jsx(
      Be,
      {
        ...e,
        ref: a,
        trapFocus: n.open,
        disableOutsidePointerEvents: n.open,
        disableOutsideScroll: !0,
        onFocusOutside: S(
          e.onFocusOutside,
          (c) => c.preventDefault(),
          { checkForDefaultPrevented: !1 }
        ),
        onDismiss: () => n.onOpenChange(!1)
      }
    );
  }
), Yn = s.forwardRef((e, t) => {
  const n = ce(z, e.__scopeMenu);
  return /* @__PURE__ */ r.jsx(
    Be,
    {
      ...e,
      ref: t,
      trapFocus: !1,
      disableOutsidePointerEvents: !1,
      disableOutsideScroll: !1,
      onDismiss: () => n.onOpenChange(!1)
    }
  );
}), Xn = Te("MenuContent.ScrollLock"), Be = s.forwardRef(
  (e, t) => {
    const {
      __scopeMenu: n,
      loop: o = !1,
      trapFocus: a,
      onOpenAutoFocus: c,
      onCloseAutoFocus: i,
      disableOutsidePointerEvents: l,
      onEntryFocus: p,
      onEscapeKeyDown: f,
      onPointerDownOutside: u,
      onFocusOutside: d,
      onInteractOutside: g,
      onDismiss: C,
      disableOutsideScroll: w,
      ...v
    } = e, m = ce(z, n), x = he(z, n), y = Me(n), _ = gt(n), R = Kn(n), [T, j] = s.useState(null), E = s.useRef(null), b = ne(t, E, m.onContentChange), L = s.useRef(0), I = s.useRef(""), V = s.useRef(0), O = s.useRef(null), q = s.useRef("right"), F = s.useRef(0), K = w ? Xt : s.Fragment, D = w ? { as: Xn, allowPinchZoom: !0 } : void 0, U = (h) => {
      const G = I.current + h, k = R().filter((P) => !P.disabled), A = document.activeElement, H = k.find((P) => P.ref.current === A)?.textValue, $ = k.map((P) => P.textValue), Y = io($, G, H), W = k.find((P) => P.textValue === Y)?.ref.current;
      (function P(ge) {
        I.current = ge, window.clearTimeout(L.current), ge !== "" && (L.current = window.setTimeout(() => P(""), 1e3));
      })(G), W && setTimeout(() => W.focus());
    };
    s.useEffect(() => () => window.clearTimeout(L.current), []), Yt();
    const N = s.useCallback((h) => q.current === O.current?.side && lo(h, O.current?.area), []);
    return /* @__PURE__ */ r.jsx(
      Wn,
      {
        scope: n,
        searchRef: I,
        onItemEnter: s.useCallback(
          (h) => {
            N(h) && h.preventDefault();
          },
          [N]
        ),
        onItemLeave: s.useCallback(
          (h) => {
            N(h) || (E.current?.focus(), j(null));
          },
          [N]
        ),
        onTriggerLeave: s.useCallback(
          (h) => {
            N(h) && h.preventDefault();
          },
          [N]
        ),
        pointerGraceTimerRef: V,
        onPointerGraceIntentChange: s.useCallback((h) => {
          O.current = h;
        }, []),
        children: /* @__PURE__ */ r.jsx(K, { ...D, children: /* @__PURE__ */ r.jsx(
          Qt,
          {
            asChild: !0,
            trapped: a,
            onMountAutoFocus: S(c, (h) => {
              h.preventDefault(), E.current?.focus({ preventScroll: !0 });
            }),
            onUnmountAutoFocus: i,
            children: /* @__PURE__ */ r.jsx(
              Jt,
              {
                asChild: !0,
                disableOutsidePointerEvents: l,
                onEscapeKeyDown: f,
                onPointerDownOutside: u,
                onFocusOutside: d,
                onInteractOutside: g,
                onDismiss: C,
                children: /* @__PURE__ */ r.jsx(
                  An,
                  {
                    asChild: !0,
                    ..._,
                    dir: x.dir,
                    orientation: "vertical",
                    loop: o,
                    currentTabStopId: T,
                    onCurrentTabStopIdChange: j,
                    onEntryFocus: S(p, (h) => {
                      x.isUsingKeyboardRef.current || h.preventDefault();
                    }),
                    preventScrollOnEntryFocus: !0,
                    children: /* @__PURE__ */ r.jsx(
                      Zt,
                      {
                        role: "menu",
                        "aria-orientation": "vertical",
                        "data-state": At(m.open),
                        "data-radix-menu-content": "",
                        dir: x.dir,
                        ...y,
                        ...v,
                        ref: b,
                        style: { outline: "none", ...v.style },
                        onKeyDown: S(v.onKeyDown, (h) => {
                          const k = h.target.closest("[data-radix-menu-content]") === h.currentTarget, A = h.ctrlKey || h.altKey || h.metaKey, H = h.key.length === 1;
                          k && (h.key === "Tab" && h.preventDefault(), !A && H && U(h.key));
                          const $ = E.current;
                          if (h.target !== $ || !Fn.includes(h.key)) return;
                          h.preventDefault();
                          const W = R().filter((P) => !P.disabled).map((P) => P.ref.current);
                          mt.includes(h.key) && W.reverse(), ao(W);
                        }),
                        onBlur: S(e.onBlur, (h) => {
                          h.currentTarget.contains(h.target) || (window.clearTimeout(L.current), I.current = "");
                        }),
                        onPointerMove: S(
                          e.onPointerMove,
                          fe((h) => {
                            const G = h.target, k = F.current !== h.clientX;
                            if (h.currentTarget.contains(G) && k) {
                              const A = h.clientX > F.current ? "right" : "left";
                              q.current = A, F.current = h.clientX;
                            }
                          })
                        )
                      }
                    )
                  }
                )
              }
            )
          }
        ) })
      }
    );
  }
);
xt.displayName = z;
var Qn = "MenuGroup", Ke = s.forwardRef(
  (e, t) => {
    const { __scopeMenu: n, ...o } = e;
    return /* @__PURE__ */ r.jsx(oe.div, { role: "group", ...o, ref: t });
  }
);
Ke.displayName = Qn;
var Jn = "MenuLabel", _t = s.forwardRef(
  (e, t) => {
    const { __scopeMenu: n, ...o } = e;
    return /* @__PURE__ */ r.jsx(oe.div, { ...o, ref: t });
  }
);
_t.displayName = Jn;
var we = "MenuItem", We = "menu.itemSelect", Re = s.forwardRef(
  (e, t) => {
    const { disabled: n = !1, onSelect: o, ...a } = e, c = s.useRef(null), i = he(we, e.__scopeMenu), l = Ge(we, e.__scopeMenu), p = ne(t, c), f = s.useRef(!1), u = () => {
      const d = c.current;
      if (!n && d) {
        const g = new CustomEvent(We, { bubbles: !0, cancelable: !0 });
        d.addEventListener(We, (C) => o?.(C), { once: !0 }), qt(d, g), g.defaultPrevented ? f.current = !1 : i.onClose();
      }
    };
    return /* @__PURE__ */ r.jsx(
      Mt,
      {
        ...a,
        ref: p,
        disabled: n,
        onClick: S(e.onClick, u),
        onPointerDown: (d) => {
          e.onPointerDown?.(d), f.current = !0;
        },
        onPointerUp: S(e.onPointerUp, (d) => {
          f.current || d.currentTarget?.click();
        }),
        onKeyDown: S(e.onKeyDown, (d) => {
          const g = l.searchRef.current !== "";
          n || g && d.key === " " || Pe.includes(d.key) && (d.currentTarget.click(), d.preventDefault());
        })
      }
    );
  }
);
Re.displayName = we;
var Mt = s.forwardRef(
  (e, t) => {
    const { __scopeMenu: n, disabled: o = !1, textValue: a, ...c } = e, i = Ge(we, n), l = gt(n), p = s.useRef(null), f = ne(t, p), [u, d] = s.useState(!1), [g, C] = s.useState("");
    return s.useEffect(() => {
      const w = p.current;
      w && C((w.textContent ?? "").trim());
    }, [c.children]), /* @__PURE__ */ r.jsx(
      de.ItemSlot,
      {
        scope: n,
        disabled: o,
        textValue: a ?? g,
        children: /* @__PURE__ */ r.jsx(kn, { asChild: !0, ...l, focusable: !o, children: /* @__PURE__ */ r.jsx(
          oe.div,
          {
            role: "menuitem",
            "data-highlighted": u ? "" : void 0,
            "aria-disabled": o || void 0,
            "data-disabled": o ? "" : void 0,
            ...c,
            ref: f,
            onPointerMove: S(
              e.onPointerMove,
              fe((w) => {
                o ? i.onItemLeave(w) : (i.onItemEnter(w), w.defaultPrevented || w.currentTarget.focus({ preventScroll: !0 }));
              })
            ),
            onPointerLeave: S(
              e.onPointerLeave,
              fe((w) => i.onItemLeave(w))
            ),
            onFocus: S(e.onFocus, () => d(!0)),
            onBlur: S(e.onBlur, () => d(!1))
          }
        ) })
      }
    );
  }
), Zn = "MenuCheckboxItem", Rt = s.forwardRef(
  (e, t) => {
    const { checked: n = !1, onCheckedChange: o, ...a } = e;
    return /* @__PURE__ */ r.jsx(Et, { scope: e.__scopeMenu, checked: n, children: /* @__PURE__ */ r.jsx(
      Re,
      {
        role: "menuitemcheckbox",
        "aria-checked": xe(n) ? "mixed" : n,
        ...a,
        ref: t,
        "data-state": $e(n),
        onSelect: S(
          a.onSelect,
          () => o?.(xe(n) ? !0 : !n),
          { checkForDefaultPrevented: !1 }
        )
      }
    ) });
  }
);
Rt.displayName = Zn;
var Ct = "MenuRadioGroup", [eo, to] = se(
  Ct,
  { value: void 0, onValueChange: () => {
  } }
), St = s.forwardRef(
  (e, t) => {
    const { value: n, onValueChange: o, ...a } = e, c = Ae(o);
    return /* @__PURE__ */ r.jsx(eo, { scope: e.__scopeMenu, value: n, onValueChange: c, children: /* @__PURE__ */ r.jsx(Ke, { ...a, ref: t }) });
  }
);
St.displayName = Ct;
var yt = "MenuRadioItem", bt = s.forwardRef(
  (e, t) => {
    const { value: n, ...o } = e, a = to(yt, e.__scopeMenu), c = n === a.value;
    return /* @__PURE__ */ r.jsx(Et, { scope: e.__scopeMenu, checked: c, children: /* @__PURE__ */ r.jsx(
      Re,
      {
        role: "menuitemradio",
        "aria-checked": c,
        ...o,
        ref: t,
        "data-state": $e(c),
        onSelect: S(
          o.onSelect,
          () => a.onValueChange?.(n),
          { checkForDefaultPrevented: !1 }
        )
      }
    ) });
  }
);
bt.displayName = yt;
var Ue = "MenuItemIndicator", [Et, no] = se(
  Ue,
  { checked: !1 }
), It = s.forwardRef(
  (e, t) => {
    const { __scopeMenu: n, forceMount: o, ...a } = e, c = no(Ue, n);
    return /* @__PURE__ */ r.jsx(
      ke,
      {
        present: o || xe(c.checked) || c.checked === !0,
        children: /* @__PURE__ */ r.jsx(
          oe.span,
          {
            ...a,
            ref: t,
            "data-state": $e(c.checked)
          }
        )
      }
    );
  }
);
It.displayName = Ue;
var oo = "MenuSeparator", Tt = s.forwardRef(
  (e, t) => {
    const { __scopeMenu: n, ...o } = e;
    return /* @__PURE__ */ r.jsx(
      oe.div,
      {
        role: "separator",
        "aria-orientation": "horizontal",
        ...o,
        ref: t
      }
    );
  }
);
Tt.displayName = oo;
var ro = "MenuArrow", Dt = s.forwardRef(
  (e, t) => {
    const { __scopeMenu: n, ...o } = e, a = Me(n);
    return /* @__PURE__ */ r.jsx(en, { ...a, ...o, ref: t });
  }
);
Dt.displayName = ro;
var so = "MenuSub", [Sr, Ot] = se(so), ie = "MenuSubTrigger", Nt = s.forwardRef(
  (e, t) => {
    const n = ce(ie, e.__scopeMenu), o = he(ie, e.__scopeMenu), a = Ot(ie, e.__scopeMenu), c = Ge(ie, e.__scopeMenu), i = s.useRef(null), { pointerGraceTimerRef: l, onPointerGraceIntentChange: p } = c, f = { __scopeMenu: e.__scopeMenu }, u = s.useCallback(() => {
      i.current && window.clearTimeout(i.current), i.current = null;
    }, []);
    return s.useEffect(() => u, [u]), s.useEffect(() => {
      const d = l.current;
      return () => {
        window.clearTimeout(d), p(null);
      };
    }, [l, p]), /* @__PURE__ */ r.jsx(Fe, { asChild: !0, ...f, children: /* @__PURE__ */ r.jsx(
      Mt,
      {
        id: a.triggerId,
        "aria-haspopup": "menu",
        "aria-expanded": n.open,
        "aria-controls": a.contentId,
        "data-state": At(n.open),
        ...e,
        ref: et(t, a.onTriggerChange),
        onClick: (d) => {
          e.onClick?.(d), !(e.disabled || d.defaultPrevented) && (d.currentTarget.focus(), n.open || n.onOpenChange(!0));
        },
        onPointerMove: S(
          e.onPointerMove,
          fe((d) => {
            c.onItemEnter(d), !d.defaultPrevented && !e.disabled && !n.open && !i.current && (c.onPointerGraceIntentChange(null), i.current = window.setTimeout(() => {
              n.onOpenChange(!0), u();
            }, 100));
          })
        ),
        onPointerLeave: S(
          e.onPointerLeave,
          fe((d) => {
            u();
            const g = n.content?.getBoundingClientRect();
            if (g) {
              const C = n.content?.dataset.side, w = C === "right", v = w ? -5 : 5, m = g[w ? "left" : "right"], x = g[w ? "right" : "left"];
              c.onPointerGraceIntentChange({
                area: [
                  // Apply a bleed on clientX to ensure that our exit point is
                  // consistently within polygon bounds
                  { x: d.clientX + v, y: d.clientY },
                  { x: m, y: g.top },
                  { x, y: g.top },
                  { x, y: g.bottom },
                  { x: m, y: g.bottom }
                ],
                side: C
              }), window.clearTimeout(l.current), l.current = window.setTimeout(
                () => c.onPointerGraceIntentChange(null),
                300
              );
            } else {
              if (c.onTriggerLeave(d), d.defaultPrevented) return;
              c.onPointerGraceIntentChange(null);
            }
          })
        ),
        onKeyDown: S(e.onKeyDown, (d) => {
          const g = c.searchRef.current !== "";
          e.disabled || g && d.key === " " || Gn[o.dir].includes(d.key) && (n.onOpenChange(!0), n.content?.focus(), d.preventDefault());
        })
      }
    ) });
  }
);
Nt.displayName = ie;
var jt = "MenuSubContent", Pt = s.forwardRef(
  (e, t) => {
    const n = wt(z, e.__scopeMenu), { forceMount: o = n.forceMount, ...a } = e, c = ce(z, e.__scopeMenu), i = he(z, e.__scopeMenu), l = Ot(jt, e.__scopeMenu), p = s.useRef(null), f = ne(t, p);
    return /* @__PURE__ */ r.jsx(de.Provider, { scope: e.__scopeMenu, children: /* @__PURE__ */ r.jsx(ke, { present: o || c.open, children: /* @__PURE__ */ r.jsx(de.Slot, { scope: e.__scopeMenu, children: /* @__PURE__ */ r.jsx(
      Be,
      {
        id: l.contentId,
        "aria-labelledby": l.triggerId,
        ...a,
        ref: f,
        align: "start",
        side: i.dir === "rtl" ? "left" : "right",
        disableOutsidePointerEvents: !1,
        disableOutsideScroll: !1,
        trapFocus: !1,
        onOpenAutoFocus: (u) => {
          i.isUsingKeyboardRef.current && p.current?.focus(), u.preventDefault();
        },
        onCloseAutoFocus: (u) => u.preventDefault(),
        onFocusOutside: S(e.onFocusOutside, (u) => {
          u.target !== l.trigger && c.onOpenChange(!1);
        }),
        onEscapeKeyDown: S(e.onEscapeKeyDown, (u) => {
          i.onClose(), u.preventDefault();
        }),
        onKeyDown: S(e.onKeyDown, (u) => {
          const d = u.currentTarget.contains(u.target), g = Bn[i.dir].includes(u.key);
          d && g && (c.onOpenChange(!1), l.trigger?.focus(), u.preventDefault());
        })
      }
    ) }) }) });
  }
);
Pt.displayName = jt;
function At(e) {
  return e ? "open" : "closed";
}
function xe(e) {
  return e === "indeterminate";
}
function $e(e) {
  return xe(e) ? "indeterminate" : e ? "checked" : "unchecked";
}
function ao(e) {
  const t = document.activeElement;
  for (const n of e)
    if (n === t || (n.focus(), document.activeElement !== t)) return;
}
function co(e, t) {
  return e.map((n, o) => e[(t + o) % e.length]);
}
function io(e, t, n) {
  const a = t.length > 1 && Array.from(t).every((f) => f === t[0]) ? t[0] : t, c = n ? e.indexOf(n) : -1;
  let i = co(e, Math.max(c, 0));
  a.length === 1 && (i = i.filter((f) => f !== n));
  const p = i.find(
    (f) => f.toLowerCase().startsWith(a.toLowerCase())
  );
  return p !== n ? p : void 0;
}
function uo(e, t) {
  const { x: n, y: o } = e;
  let a = !1;
  for (let c = 0, i = t.length - 1; c < t.length; i = c++) {
    const l = t[c], p = t[i], f = l.x, u = l.y, d = p.x, g = p.y;
    u > o != g > o && n < (d - f) * (o - u) / (g - u) + f && (a = !a);
  }
  return a;
}
function lo(e, t) {
  if (!t) return !1;
  const n = { x: e.clientX, y: e.clientY };
  return uo(n, t);
}
function fe(e) {
  return (t) => t.pointerType === "mouse" ? e(t) : void 0;
}
var fo = vt, po = Fe, mo = xt, ho = Ke, go = _t, vo = Re, wo = Rt, xo = St, _o = bt, Mo = It, Ro = Tt, Co = Dt, So = Nt, yo = Pt, Ce = "DropdownMenu", [bo] = _e(
  Ce,
  [ht]
), B = ht(), [Eo, kt] = bo(Ce), Lt = (e) => {
  const {
    __scopeDropdownMenu: t,
    children: n,
    dir: o,
    open: a,
    defaultOpen: c,
    onOpenChange: i,
    modal: l = !0
  } = e, p = B(t), f = s.useRef(null), [u, d] = Je({
    prop: a,
    defaultProp: c ?? !1,
    onChange: i,
    caller: Ce
  });
  return /* @__PURE__ */ r.jsx(
    Eo,
    {
      scope: t,
      triggerId: De(),
      triggerRef: f,
      contentId: De(),
      open: u,
      onOpenChange: d,
      onOpenToggle: s.useCallback(() => d((g) => !g), [d]),
      modal: l,
      children: /* @__PURE__ */ r.jsx(fo, { ...p, open: u, onOpenChange: d, dir: o, modal: l, children: n })
    }
  );
};
Lt.displayName = Ce;
var Ft = "DropdownMenuTrigger", Gt = s.forwardRef(
  (e, t) => {
    const { __scopeDropdownMenu: n, disabled: o = !1, ...a } = e, c = kt(Ft, n), i = B(n);
    return /* @__PURE__ */ r.jsx(po, { asChild: !0, ...i, children: /* @__PURE__ */ r.jsx(
      oe.button,
      {
        type: "button",
        id: c.triggerId,
        "aria-haspopup": "menu",
        "aria-expanded": c.open,
        "aria-controls": c.open ? c.contentId : void 0,
        "data-state": c.open ? "open" : "closed",
        "data-disabled": o ? "" : void 0,
        disabled: o,
        ...a,
        ref: et(t, c.triggerRef),
        onPointerDown: S(e.onPointerDown, (l) => {
          !o && l.button === 0 && l.ctrlKey === !1 && (c.onOpenToggle(), c.open || l.preventDefault());
        }),
        onKeyDown: S(e.onKeyDown, (l) => {
          o || (["Enter", " "].includes(l.key) && c.onOpenToggle(), l.key === "ArrowDown" && c.onOpenChange(!0), ["Enter", " ", "ArrowDown"].includes(l.key) && l.preventDefault());
        })
      }
    ) });
  }
);
Gt.displayName = Ft;
var Bt = "DropdownMenuContent", Kt = s.forwardRef(
  (e, t) => {
    const { __scopeDropdownMenu: n, ...o } = e, a = kt(Bt, n), c = B(n), i = s.useRef(!1);
    return /* @__PURE__ */ r.jsx(
      mo,
      {
        id: a.contentId,
        "aria-labelledby": a.triggerId,
        ...c,
        ...o,
        ref: t,
        onCloseAutoFocus: S(e.onCloseAutoFocus, (l) => {
          i.current || a.triggerRef.current?.focus(), i.current = !1, l.preventDefault();
        }),
        onInteractOutside: S(e.onInteractOutside, (l) => {
          const p = l.detail.originalEvent, f = p.button === 0 && p.ctrlKey === !0, u = p.button === 2 || f;
          (!a.modal || u) && (i.current = !0);
        }),
        style: {
          ...e.style,
          "--radix-dropdown-menu-content-transform-origin": "var(--radix-popper-transform-origin)",
          "--radix-dropdown-menu-content-available-width": "var(--radix-popper-available-width)",
          "--radix-dropdown-menu-content-available-height": "var(--radix-popper-available-height)",
          "--radix-dropdown-menu-trigger-width": "var(--radix-popper-anchor-width)",
          "--radix-dropdown-menu-trigger-height": "var(--radix-popper-anchor-height)"
        }
      }
    );
  }
);
Kt.displayName = Bt;
var Io = "DropdownMenuGroup", To = s.forwardRef(
  (e, t) => {
    const { __scopeDropdownMenu: n, ...o } = e, a = B(n);
    return /* @__PURE__ */ r.jsx(ho, { ...a, ...o, ref: t });
  }
);
To.displayName = Io;
var Do = "DropdownMenuLabel", Oo = s.forwardRef(
  (e, t) => {
    const { __scopeDropdownMenu: n, ...o } = e, a = B(n);
    return /* @__PURE__ */ r.jsx(go, { ...a, ...o, ref: t });
  }
);
Oo.displayName = Do;
var No = "DropdownMenuItem", Ut = s.forwardRef(
  (e, t) => {
    const { __scopeDropdownMenu: n, ...o } = e, a = B(n);
    return /* @__PURE__ */ r.jsx(vo, { ...a, ...o, ref: t });
  }
);
Ut.displayName = No;
var jo = "DropdownMenuCheckboxItem", Po = s.forwardRef((e, t) => {
  const { __scopeDropdownMenu: n, ...o } = e, a = B(n);
  return /* @__PURE__ */ r.jsx(wo, { ...a, ...o, ref: t });
});
Po.displayName = jo;
var Ao = "DropdownMenuRadioGroup", ko = s.forwardRef((e, t) => {
  const { __scopeDropdownMenu: n, ...o } = e, a = B(n);
  return /* @__PURE__ */ r.jsx(xo, { ...a, ...o, ref: t });
});
ko.displayName = Ao;
var Lo = "DropdownMenuRadioItem", Fo = s.forwardRef((e, t) => {
  const { __scopeDropdownMenu: n, ...o } = e, a = B(n);
  return /* @__PURE__ */ r.jsx(_o, { ...a, ...o, ref: t });
});
Fo.displayName = Lo;
var Go = "DropdownMenuItemIndicator", Bo = s.forwardRef((e, t) => {
  const { __scopeDropdownMenu: n, ...o } = e, a = B(n);
  return /* @__PURE__ */ r.jsx(Mo, { ...a, ...o, ref: t });
});
Bo.displayName = Go;
var Ko = "DropdownMenuSeparator", Uo = s.forwardRef((e, t) => {
  const { __scopeDropdownMenu: n, ...o } = e, a = B(n);
  return /* @__PURE__ */ r.jsx(Ro, { ...a, ...o, ref: t });
});
Uo.displayName = Ko;
var $o = "DropdownMenuArrow", zo = s.forwardRef(
  (e, t) => {
    const { __scopeDropdownMenu: n, ...o } = e, a = B(n);
    return /* @__PURE__ */ r.jsx(Co, { ...a, ...o, ref: t });
  }
);
zo.displayName = $o;
var Vo = "DropdownMenuSubTrigger", Ho = s.forwardRef((e, t) => {
  const { __scopeDropdownMenu: n, ...o } = e, a = B(n);
  return /* @__PURE__ */ r.jsx(So, { ...a, ...o, ref: t });
});
Ho.displayName = Vo;
var Wo = "DropdownMenuSubContent", qo = s.forwardRef((e, t) => {
  const { __scopeDropdownMenu: n, ...o } = e, a = B(n);
  return /* @__PURE__ */ r.jsx(
    yo,
    {
      ...a,
      ...o,
      ref: t,
      style: {
        ...e.style,
        "--radix-dropdown-menu-content-transform-origin": "var(--radix-popper-transform-origin)",
        "--radix-dropdown-menu-content-available-width": "var(--radix-popper-available-width)",
        "--radix-dropdown-menu-content-available-height": "var(--radix-popper-available-height)",
        "--radix-dropdown-menu-trigger-width": "var(--radix-popper-anchor-width)",
        "--radix-dropdown-menu-trigger-height": "var(--radix-popper-anchor-height)"
      }
    }
  );
});
qo.displayName = Wo;
var Yo = Lt, Xo = Gt, Qo = Kt, qe = Ut;
function Jo({
  title: e,
  titleId: t,
  ...n
}, o) {
  return /* @__PURE__ */ s.createElement("svg", Object.assign({
    xmlns: "http://www.w3.org/2000/svg",
    fill: "none",
    viewBox: "0 0 24 24",
    strokeWidth: 1.5,
    stroke: "currentColor",
    "aria-hidden": "true",
    "data-slot": "icon",
    ref: o,
    "aria-labelledby": t
  }, n), e ? /* @__PURE__ */ s.createElement("title", {
    id: t
  }, e) : null, /* @__PURE__ */ s.createElement("path", {
    strokeLinecap: "round",
    strokeLinejoin: "round",
    d: "M3 4.5h14.25M3 9h9.75M3 13.5h9.75m4.5-4.5v12m0 0-3.75-3.75M17.25 21 21 17.25"
  }));
}
const Zo = /* @__PURE__ */ s.forwardRef(Jo), er = ({
  sortByRelevanceLabel: e,
  sortByDistanceLabel: t,
  accessibilityLabel: n,
  on: o = () => {
  }
  // default no-op
}) => {
  const a = Le();
  if (!a)
    throw new Error("SortDropdown must be used within a SearchRankingProvider");
  const { sortMode: c, setSortMode: i, requestLocation: l, locationDenied: p } = a, f = () => {
    i("relevance"), o("sortRelevance");
  }, u = async () => {
    if (!p)
      try {
        await l(), i("distance"), o("sortDistance");
      } catch {
      }
  };
  return /* @__PURE__ */ r.jsxs(Yo, { onOpenChange: (d) => d && o("openSortMenu"), children: [
    /* @__PURE__ */ r.jsx(Xo, { asChild: !0, children: /* @__PURE__ */ r.jsx(
      "button",
      {
        type: "button",
        className: "sid-sort-dropdown__trigger",
        "aria-label": n,
        children: /* @__PURE__ */ r.jsx(Zo, { className: "sid-sort-dropdown__icon" })
      }
    ) }),
    /* @__PURE__ */ r.jsxs(
      Qo,
      {
        className: "sid-sort-dropdown__content",
        sideOffset: 0,
        collisionPadding: 10,
        align: "end",
        children: [
          /* @__PURE__ */ r.jsx(
            qe,
            {
              className: "sid-sort-dropdown__item",
              onSelect: f,
              "data-active": c === "relevance" ? "" : void 0,
              children: e
            }
          ),
          /* @__PURE__ */ r.jsx(
            qe,
            {
              className: "sid-sort-dropdown__item",
              onSelect: u,
              disabled: p,
              "data-active": c === "distance" ? "" : void 0,
              children: t
            }
          )
        ]
      }
    )
  ] });
};
var Ie, Ye;
function tr() {
  if (Ye) return Ie;
  Ye = 1;
  function e(t, n, o) {
    var a, c, i, l, p;
    n == null && (n = 100);
    function f() {
      var d = Date.now() - l;
      d < n && d >= 0 ? a = setTimeout(f, n - d) : (a = null, o || (p = t.apply(i, c), i = c = null));
    }
    var u = function() {
      i = this, c = arguments, l = Date.now();
      var d = o && !a;
      return a || (a = setTimeout(f, n)), d && (p = t.apply(i, c), i = c = null), p;
    };
    return u.clear = function() {
      a && (clearTimeout(a), a = null);
    }, u.flush = function() {
      a && (p = t.apply(i, c), i = c = null, clearTimeout(a), a = null);
    }, u;
  }
  return e.debounce = e, Ie = e, Ie;
}
var nr = tr();
const or = 42, rr = 26, sr = ({
  getItemProps: e,
  highlightedIndex: t,
  organizations: n,
  itemToString: o,
  children: a,
  maxItemsToDisplay: c = rr
}) => {
  const i = s.Children.count(a), l = (n.length + i) * or, p = {}, f = ae("org-search-overlay") === "overlay", u = Le(), d = tt(), g = s.useMemo(() => Rn(d), [d]), C = (v) => {
    if (!u?.userLocation || v.latitude == null || v.longitude == null) return null;
    const m = _n(
      u.userLocation.latitude,
      u.userLocation.longitude,
      v.latitude,
      v.longitude
    );
    return Cn(m, g);
  };
  s.useEffect(() => {
    const v = document.getElementsByClassName("sid-organization-list__item--highlighted").item(0);
    v && ("scrollIntoViewIfNeeded" in v && typeof v.scrollIntoViewIfNeeded == "function" ? v.scrollIntoViewIfNeeded(!0) : v.scrollIntoView({ behavior: "instant", block: "center" }));
  }, [t]);
  const w = (v, m) => {
    const x = [v.city, v.state].filter(Boolean).join(", "), y = C(v);
    return /* @__PURE__ */ r.jsxs(
      "div",
      {
        className: `sid-organization-list__item ${t === m ? "sid-organization-list__item--highlighted" : ""}`,
        role: "option",
        "aria-selected": t === m,
        ...e({
          index: m,
          item: v
        }),
        ref: p[t],
        children: [
          /* @__PURE__ */ r.jsx("span", { className: "sid-organization-list__name", children: o(v) }),
          f && x && /* @__PURE__ */ r.jsx("span", { className: "sid-organization-list__location", children: x }),
          y && /* @__PURE__ */ r.jsx("span", { className: "sid-organization-list__distance", "data-testid": "org-distance", children: y })
        ]
      },
      m
    );
  };
  return /* @__PURE__ */ r.jsx(
    "div",
    {
      id: "sid-org-list-menu",
      className: "sid-organization-list__menu",
      tabIndex: -1,
      role: "listbox",
      children: /* @__PURE__ */ r.jsxs("div", { style: { height: Math.min(l, 280) }, children: [
        n.filter((v, m) => m <= c - 1).map((v, m) => w(v, m)),
        a
      ] })
    }
  );
}, ar = sr, cr = ({ className: e }) => /* @__PURE__ */ r.jsx(
  "svg",
  {
    xmlns: "http://www.w3.org/2000/svg",
    fill: "none",
    viewBox: "0 0 24 24",
    strokeWidth: 1.5,
    stroke: "currentColor",
    className: e,
    children: /* @__PURE__ */ r.jsx(
      "path",
      {
        strokeLinecap: "round",
        strokeLinejoin: "round",
        d: "M12 18v-5.25m0 0a6.01 6.01 0 0 0 1.5-.189m-1.5.189a6.01 6.01 0 0 1-1.5-.189m3.75 7.478a12.06 12.06 0 0 1-4.5 0m3.75 2.383a14.406 14.406 0 0 1-3 0M14.25 18v-.192c0-.983.658-1.823 1.508-2.316a7.5 7.5 0 1 0-7.517 0c.85.493 1.509 1.333 1.509 2.316V18"
      }
    )
  }
), Xe = ({
  urlAddSchoolForm: e,
  programId: t,
  locale: n = sn,
  onClick: o = () => {
  },
  onTipsShown: a
}) => {
  const [c, i] = ee.useState(!1), { trackEvent: l } = ot({ programId: t }), p = () => {
    le({
      eventName: ue.ASR_TIPS_SHOWN,
      params: { programId: t, locale: n }
    }), l(X.AsrTipsShown), a?.(), i(!0);
  };
  return c ? /* @__PURE__ */ r.jsxs("div", { className: "sid-organization-list__add-school-tips", children: [
    /* @__PURE__ */ r.jsxs("div", { className: "sid-organization-list__tips", children: [
      /* @__PURE__ */ r.jsx("div", { children: /* @__PURE__ */ r.jsx(cr, { className: "sid-organization-list__tips-icon" }) }),
      /* @__PURE__ */ r.jsxs("div", { className: "sid-organization-list__tips-text", children: [
        /* @__PURE__ */ r.jsx(
          te,
          {
            id: "multipleLocationsTips",
            defaultMessage: "If your academic institution has multiple locations and you didn't see yours, enter the main location."
          }
        ),
        /* @__PURE__ */ r.jsx(
          te,
          {
            id: "tryFullNameTips",
            defaultMessage: "Try typing the full name of the academic institution rather than using acronyms or abbreviations."
          }
        )
      ] })
    ] }),
    /* @__PURE__ */ r.jsx(
      He,
      {
        onClick: o,
        className: "sid-organization-list__item sid-organization-list__request-school sid-link",
        href: `${e}?pid=${t}&locale=${n}`,
        children: /* @__PURE__ */ r.jsx(
          te,
          {
            id: "requestSchool",
            defaultMessage: "Don't see your school? Request to have it added"
          }
        )
      }
    )
  ] }) : /* @__PURE__ */ r.jsx(
    He,
    {
      onClick: p,
      className: "sid-organization-list__item sid-organization-list__request-school sid-link",
      children: /* @__PURE__ */ r.jsx(
        te,
        {
          id: "cantFindYourSchool",
          defaultMessage: "Can't find your school? Click to show tips"
        }
      )
    }
  );
}, Qe = (e) => rn("name", e) || "", ir = (e) => e && e.find((n) => n.source === "PLACE") ? /* @__PURE__ */ r.jsx(
  "img",
  {
    className: "sid-organization-list__attribution-logo",
    src: "https://developers.google.com/static/maps/documentation/images/google_on_white.png",
    alt: "Google"
  }
) : null, ur = (e, t, n) => {
  if (!t && !n)
    return e;
  if (!e)
    return J.error("Expected orgSearchUrl"), e;
  try {
    const o = new URL(e), { origin: a, pathname: c, search: i } = o, l = new URLSearchParams(i);
    return t && l.set("name", t), n && Object.entries(n).forEach(([p, f]) => {
      l.set(p, f);
    }), l.sort(), `${a}${c}?${l.toString()}`;
  } catch (o) {
    J.error(o);
  }
}, lr = ({
  getItemProps: e,
  getMenuProps: t,
  highlightedIndex: n,
  itemToString: o,
  minimumSearchValueLength: a,
  onLoaded: c,
  programId: i,
  orgSearchUrl: l,
  locale: p,
  urlAddSchoolForm: f,
  openOrgSearchEnabled: u,
  onClickAddSchool: d,
  onTipsShown: g,
  searchUrlParams: C,
  searchValue: w
}) => {
  const [v, m] = s.useState(!1), [x, y] = s.useState(null), [_, R] = s.useState(null), T = s.useRef(!1), j = s.useRef(null), E = Le(), b = s.useRef({ orgSearchUrl: l, searchValue: w, searchUrlParams: C, onLoaded: c });
  b.current = { orgSearchUrl: l, searchValue: w, searchUrlParams: C, onLoaded: c };
  const L = s.useRef(E);
  L.current = E;
  const I = w || Qe(l) || "", V = s.useCallback(async () => {
    if (!T.current)
      return;
    const {
      orgSearchUrl: U,
      searchValue: N,
      searchUrlParams: h,
      onLoaded: G
    } = b.current;
    let k = h;
    const A = L.current;
    A && A.sortMode === "distance" && A.userLocation && (k = {
      ...h,
      lat: String(A.userLocation.latitude),
      long: String(A.userLocation.longitude)
    });
    const H = Date.now(), $ = await tn(
      ur(U, N, k)
    );
    if (T.current) {
      $ && (G($), y($), m(!1));
      try {
        const Y = N || Qe(U) || "", W = {
          eventName: ue.ORGS_DISPLAYED,
          params: {
            queryLength: Y.length,
            eventDuration: Date.now() - H,
            numberOfResults: $?.length
          }
        };
        le(W);
      } catch (Y) {
        J.error(Y);
      }
    }
  }, []), O = s.useRef(null);
  O.current || (O.current = nr.debounce(V, nn)), s.useEffect(() => (T.current = !0, () => {
    T.current = !1, O.current && O.current.clear();
  }), []), s.useEffect(() => {
    const U = j.current;
    U !== I && (I.length >= a ? (R(null), m(!0), y(null), O.current && O.current()) : (R(null), m(!1), y(null), U !== null ? J.info(
      `No organizations fetched. Search searchTterm "${I}" is less than ${a} characters.`
    ) : I.length > 0 && J.info(
      `No organizations fetched. Search searchTerm "${I}" is less than ${a} characters.`
    ))), j.current = I;
  }, [I, a]);
  const q = E?.sortMode, F = E?.userLocation?.latitude, K = E?.userLocation?.longitude;
  s.useEffect(() => {
    I.length >= a && (R(null), m(!0), y(null), O.current?.());
  }, [q, F, K, I, a]);
  const D = ir(x);
  return v ? /* @__PURE__ */ r.jsx("div", { className: "sid-organization-list__menu", children: /* @__PURE__ */ r.jsx("div", { className: "sid-organization-list__message sid-organization-list__spinner-container", children: /* @__PURE__ */ r.jsx("div", { id: "sid-spinner-container", children: /* @__PURE__ */ r.jsx(on, {}) }) }) }) : _ ? /* @__PURE__ */ r.jsx("div", { className: "sid-organization-list__menu", children: /* @__PURE__ */ r.jsx("div", { className: "sid-organization-list__message", children: /* @__PURE__ */ r.jsx(
    te,
    {
      id: "errorId.unknownError",
      defaultMessage: "An unknown error occurred"
    }
  ) }) }) : x && x.length > 0 ? /* @__PURE__ */ r.jsxs(r.Fragment, { children: [
    D && /* @__PURE__ */ r.jsx("div", { className: "sid-organization-list__attribution", children: D }),
    /* @__PURE__ */ r.jsx(
      ar,
      {
        getItemProps: e,
        getMenuProps: t,
        highlightedIndex: n,
        itemToString: o,
        organizations: x,
        children: I && !u && f && (!x || x.length < 26) && /* @__PURE__ */ r.jsx(
          Xe,
          {
            onClick: d,
            onTipsShown: g,
            urlAddSchoolForm: f,
            programId: i,
            locale: p
          }
        )
      }
    )
  ] }) : I && !u && f && (!x || x.length === 0) ? /* @__PURE__ */ r.jsx("div", { className: "sid-organization-list__menu", children: /* @__PURE__ */ r.jsx(
    Xe,
    {
      onClick: d,
      onTipsShown: g,
      urlAddSchoolForm: f,
      programId: i,
      locale: p
    }
  ) }) : null;
}, dr = lr, fr = (e, t, n) => {
  if (e.type === Ne.stateChangeTypes.FunctionSelectItem) {
    const { selectedItem: o } = e;
    t(o);
  } else e.type === Ne.stateChangeTypes.InputBlur && !n.openOrgSearchEnabled && !n._searchOverlayEnabled && t({
    id: void 0,
    name: ""
  });
}, pr = ({
  id: e,
  onMouseDown: t,
  disabled: n,
  onKeyDown: o,
  handleOnBlur: a
}) => /* @__PURE__ */ r.jsx(
  "button",
  {
    id: e,
    type: "button",
    onMouseDown: t,
    onKeyDown: o,
    onBlur: a,
    className: `sid-input-clear-button ${n ? "sid-input-clear-button--disabled" : ""}`,
    "aria-label": "clear text",
    "aria-disabled": n,
    tabIndex: 0,
    children: /* @__PURE__ */ r.jsx(
      "svg",
      {
        viewBox: "0 0 24 24",
        preserveAspectRatio: "none",
        width: 28,
        fill: "none",
        stroke: n ? "#B6B6B6" : "#8E95A4",
        strokeWidth: "1.1",
        children: /* @__PURE__ */ r.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M6 18L18 6M6 6l12 12" })
      }
    )
  }
), mr = pr, hr = ({
  onChange: e,
  programId: t,
  className: n,
  countryCode: o,
  disabled: a,
  minimumSearchValueLength: c,
  placeholder: i,
  value: l,
  inputHtmlId: p,
  openOrgSearchEnabled: f,
  orgSearchUrl: u,
  isRequired: d,
  locale: g,
  urlAddSchoolForm: C,
  isErrored: w,
  ariaDescribedBy: v,
  autoFocus: m = !1,
  onBlur: x = () => {
  },
  intl: y
}) => {
  const [_, R] = s.useState(l ? l.name : ""), [T, j] = s.useState([]), E = s.useRef(0), b = s.useRef(0), L = s.useRef(!1), I = s.useRef(!1), [V, O] = s.useState(!1), [q, F] = s.useState(!1), { recordNumericMetric: K, trackEvent: D } = ot({ programId: t }), U = ae("org-search-overlay") === "overlay", { showOverlay: N, setShowOverlay: h } = pn();
  an(e);
  const G = (M) => M ? M.name : "", { isOpen: k, highlightedIndex: A, getMenuProps: H, getItemProps: $, getInputProps: Y } = Ne({
    itemToString: G,
    id: p,
    items: T,
    inputValue: _,
    onStateChange: (M) => fr(M, e, {
      openOrgSearchEnabled: f,
      _searchOverlayEnabled: N
    }),
    selectedItem: l,
    onSelectedItemChange: ({ selectedItem: M }) => {
      if (!M) {
        R(""), h(!1), e({
          id: 0,
          name: ""
        });
        return;
      }
      R(G(M));
      const Z = T.findIndex((re) => re.id === M.id) + 1, ve = Date.now() - b.current;
      try {
        const re = {
          eventName: ue.ORG_SELECTED,
          params: {
            [Q.QUERY_LENGTH]: _.length,
            [Q.NUMBER_REWORKS]: E.current,
            [Q.SELECTED_RESULT_RANK]: Z,
            [Q.EVENT_DURATION]: ve,
            [Q.NUMBER_OF_RESULTS]: T.length
          }
        };
        le(re);
      } catch (re) {
        J.error(re);
      }
      try {
        K(X.OrgSearchNumReworks, E.current), K(X.OrgSearchQueryLength, _.length), K(X.OrgSearchResultRank, Z), K(X.OrgSearchTimeUntilSelection, ve);
      } catch (re) {
        J.error(re);
      }
      b.current = 0, E.current = 0, h(!1), e(M);
    }
  }), W = () => {
    try {
      const M = {
        eventName: ue.ASR_SELECTED,
        params: {
          [Q.QUERY_LENGTH]: _.length,
          [Q.NUMBER_REWORKS]: E.current,
          [Q.EVENT_DURATION]: Date.now() - b.current,
          [Q.NUMBER_OF_RESULTS]: T.length
        }
      };
      le(M), D(X.AsrClickThrough);
    } catch (M) {
      J.error(M);
    }
  }, P = () => {
    L.current = !0;
  }, ge = (M) => {
    const Z = M.target.value;
    F(!Z);
    try {
      b.current === 0 && (b.current = Date.now()), Z.length < _.length && (E.current += 1), L.current && !I.current && Z && (I.current = !0, le({
        eventName: ue.ASR_SEARCH_AFTER_TIPS,
        params: { programId: t }
      }), D(X.AsrSearchAfterTips));
    } catch (ve) {
      J.error(ve);
    }
    R(Z), e({
      id: 0,
      name: Z
    });
  }, Se = s.useRef(null);
  s.useEffect(() => {
    cn("organization", Se.current);
  });
  const zt = (M) => {
    O(!0), M.currentTarget.value ? (F(!1), h(!0)) : F(!0);
  }, ze = (M) => {
    M.relatedTarget?.id !== `${p}-clear-button` && (O(!1), x());
  }, Ve = (M) => {
    (M.type === "mousedown" || "key" in M && M.key === "Enter") && (R(""), e({
      id: void 0,
      name: ""
    }), Se.current.focus());
  };
  return /* @__PURE__ */ r.jsxs("div", { className: "sid-organization-list", children: [
    /* @__PURE__ */ r.jsxs("div", { className: "sid-text-input__wrapper", children: [
      /* @__PURE__ */ r.jsx(
        "input",
        {
          ...Y({
            ref: Se,
            onChange: ge,
            onFocus: (M) => zt(M),
            onBlur: (M) => ze(M),
            onKeyDown: (M) => {
              M.key !== "Tab" && M.key !== "Escape" && h(!0);
            }
          }),
          className: `sid-l-full-width sid-hidden-placeholder sid-text-input ${n}`,
          disabled: a,
          id: p,
          autoFocus: m,
          placeholder: i,
          "aria-required": d,
          "aria-controls": "sid-org-list-menu",
          "aria-describedby": v,
          "aria-invalid": w,
          "aria-labelledby": `${p}-label`
        }
      ),
      N && /* @__PURE__ */ r.jsx(
        er,
        {
          sortByRelevanceLabel: y.formatMessage({
            id: "orgSearchSortByRelevance",
            defaultMessage: "Sort by Relevance"
          }),
          sortByDistanceLabel: y.formatMessage({
            id: "orgSearchSortByDistance",
            defaultMessage: "Sort by Distance"
          }),
          accessibilityLabel: y.formatMessage({
            id: "orgSearchSortAccessibilityLabel",
            defaultMessage: "Sort search results"
          }),
          on: (M) => {
            switch (M) {
              case "openSortMenu":
                D(X.OrgSearchOpenSortMenu);
                break;
              case "sortDistance":
                D(X.OrgSearchSortDistance);
                break;
              case "sortRelevance":
                D(X.OrgSearchSortRelevance);
                break;
            }
          }
        }
      )
    ] }),
    V && !N ? /* @__PURE__ */ r.jsx(
      mr,
      {
        id: `${p}-clear-button`,
        disabled: q,
        onMouseDown: Ve,
        onKeyDown: Ve,
        handleOnBlur: ze
      }
    ) : null,
    /* @__PURE__ */ r.jsx("div", { ...H(), className: "sid-organization-list__menu-wrapper", children: _ && k || N && _ ? /* @__PURE__ */ r.jsx(
      dr,
      {
        countryCode: o,
        getItemProps: $,
        highlightedIndex: A,
        itemToString: G,
        minimumSearchValueLength: c,
        onLoaded: (M) => j(M),
        programId: t,
        orgSearchUrl: u,
        locale: g,
        urlAddSchoolForm: C,
        onClickAddSchool: W,
        onTipsShown: P,
        openOrgSearchEnabled: f,
        searchUrlParams: U ? { format: "detailed" } : void 0
      }
    ) : null })
  ] });
}, gr = nt(hr), $t = (e) => Oe(() => e.id) === 0 && Oe(() => e.name, "").length > 0, yr = (e, t) => Oe(() => e.openOrgSearchEnabled) && $t(t.organization), vr = ({
  fieldId: e,
  value: t,
  verificationService: n,
  onChange: o,
  placeholder: a,
  label: c,
  errorMessage: i,
  warningMessage: l,
  helperMessage: p,
  showPlaceholderAndHideLabel: f = !1,
  isRequired: u = !0,
  explanation: d = "",
  orgSearchUrl: g,
  urlAddSchoolForm: C,
  disabled: w = !1,
  intl: v
}) => {
  const m = `sid-${ye(e)}`, x = `sid-${ye(e)}-error`, y = `sid-${ye(e)}-warning`, { programId: _, programTheme: R, verificationResponse: T, viewModel: j } = n, E = be(() => j.countryChoice.value), b = fn(R, E), L = tt(j, T), [I, V] = s.useState(!1), O = ae("org-search-overlay") === "overlay", q = O || ae("org-selected-display") === "box-display", F = ae("hc-open-org-warning") === "warning-orange", K = ae("hc-open-org-warning") === "warning-gray", D = F || K, [U, N] = s.useState(!1), h = be(() => R.openOrgSearchEnabled), G = () => {
    h && $t(t) ? N(!0) : N(!1);
  }, k = (P) => {
    U && N(!1), o(P);
  }, A = U && D && /* @__PURE__ */ r.jsx(
    te,
    {
      id: "warningId.openOrganization",
      defaultMessage: "We couldn't find a match for that name in our database. Please double-check the spelling, if it's correct, feel free to continue!"
    }
  ), H = l || F && A, $ = p || K && A, Y = () => i ? "sid-text-input--error" : H ? "sid-text-input--warning" : "", W = () => {
    if (i) return x;
    if (H) return y;
  };
  return /* @__PURE__ */ r.jsx(
    vn,
    {
      enabled: O,
      closeSectionLabel: /* @__PURE__ */ r.jsx(te, { id: "closeSection", defaultMessage: "Close Section" }),
      children: /* @__PURE__ */ r.jsx(
        ln,
        {
          fieldId: e,
          label: c,
          errorMessage: i,
          warningMessage: H,
          helperMessage: $,
          showPlaceholderAndHideLabel: f,
          isRequired: u || b,
          explanation: b ? /* @__PURE__ */ r.jsx(
            te,
            {
              id: "chooseCountry",
              defaultMessage: "Choose a country before searching"
            }
          ) : d,
          containerId: `${m}-id`,
          children: q && t.id ? /* @__PURE__ */ r.jsx(
            wn,
            {
              org: t,
              onClear: () => {
                k(void 0), V(!0);
              },
              clearSelectionLabel: v.formatMessage({
                id: "clearSelection",
                defaultMessage: "Clear selection"
              }),
              labelId: dn(e)
            }
          ) : /* @__PURE__ */ r.jsx(
            gr,
            {
              className: Y(),
              disabled: b || w,
              countryCode: E,
              minimumSearchValueLength: un().minimumOrganizationSearchLength,
              onChange: k,
              placeholder: a,
              programId: _,
              value: t,
              inputHtmlId: m,
              openOrgSearchEnabled: R.openOrgSearchEnabled,
              locale: L,
              orgSearchUrl: g || be(() => R.config.orgSearchUrl),
              urlAddSchoolForm: C,
              isRequired: u,
              isErrored: !!i,
              ariaDescribedBy: W(),
              autoFocus: I,
              onBlur: G
            }
          )
        }
      )
    }
  );
}, br = nt(vr);
export {
  br as F,
  yr as s
};
