UNPKG

@sherpahow/sherpa-sdk

Version:

Sherpa JavaScript SDK for in-app help and product tours. Built with TypeScript, Lit web components, and Nano Stores.

3,068 lines 172 kB
var __freeze = Object.freeze;
var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a2, b2) => {
  for (var prop in b2 || (b2 = {}))
    if (__hasOwnProp.call(b2, prop))
      __defNormalProp(a2, prop, b2[prop]);
  if (__getOwnPropSymbols)
    for (var prop of __getOwnPropSymbols(b2)) {
      if (__propIsEnum.call(b2, prop))
        __defNormalProp(a2, prop, b2[prop]);
    }
  return a2;
};
var __spreadProps = (a2, b2) => __defProps(a2, __getOwnPropDescs(b2));
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
var __template = (cooked, raw) => __freeze(__defProp(cooked, "raw", { value: __freeze(raw || cooked.slice()) }));
var __async = (__this, __arguments, generator) => {
  return new Promise((resolve, reject) => {
    var fulfilled = (value) => {
      try {
        step(generator.next(value));
      } catch (e2) {
        reject(e2);
      }
    };
    var rejected = (value) => {
      try {
        step(generator.throw(value));
      } catch (e2) {
        reject(e2);
      }
    };
    var step = (x2) => x2.done ? resolve(x2.value) : Promise.resolve(x2.value).then(fulfilled, rejected);
    step((generator = generator.apply(__this, __arguments)).next());
  });
};
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I;
function t(t2) {
  return t2 instanceof HTMLInputElement || t2 instanceof HTMLTextAreaElement || t2 instanceof HTMLSelectElement ? t2.value : t2.hasAttribute("contenteditable") && t2.textContent || void 0;
}
function e(t2) {
  var _a2;
  const e2 = (_a2 = t2.textContent) == null ? void 0 : _a2.trim();
  return e2 || void 0;
}
function r(t2) {
  const e2 = t2.getBoundingClientRect(), r2 = window.getComputedStyle(t2);
  return e2.width > 0 && e2.height > 0 && "hidden" !== r2.visibility && "none" !== r2.display && "0" !== r2.opacity;
}
function n(t2) {
  const e2 = {};
  for (let r2 = 0; t2.attributes.length > r2; r2++) {
    const n2 = t2.attributes[r2];
    e2[n2.name] = n2.value;
  }
  return e2;
}
function i(t2) {
  return (s(t2) || a(t2) || c(t2) || u(t2) || p(t2) || m(t2) || o(t2)) && b(t2);
}
function s(t2) {
  return t2 instanceof HTMLInputElement || t2 instanceof HTMLTextAreaElement || t2 instanceof HTMLSelectElement;
}
function o(t2) {
  return "button" === t2.tagName.toLowerCase();
}
function a(t2) {
  return "textarea" === t2.tagName.toLowerCase() || "textbox" === t2.getAttribute("role") || t2.hasAttribute("contenteditable");
}
function c(t2) {
  if (t2 instanceof HTMLSelectElement) return 1;
  const e2 = t2.getAttribute("role");
  if ("combobox" === e2 || "listbox" === e2) return 1;
  if (t2.hasAttribute("aria-haspopup")) {
    const e3 = t2.getAttribute("aria-haspopup");
    if ("dialog" === e3 || "listbox" === e3 || "menu" === e3) return 1;
  }
  return l(t2) ? 1 : 0;
}
function l(t2) {
  var _a2, _b2;
  if (!t2 || "function" != typeof t2.hasAttribute) return 0;
  if (t2.hasAttribute("data-radix-select-trigger") || t2.hasAttribute("data-radix-select-content") || t2.hasAttribute("data-radix-select-item") || t2.hasAttribute("data-radix-select-value") || t2.hasAttribute("data-radix-select-viewport")) return 1;
  const e2 = t2.getAttribute("role");
  return "combobox" === e2 && t2.hasAttribute("data-state") || "combobox" === e2 && (t2.hasAttribute("aria-expanded") || t2.hasAttribute("data-placeholder")) || t2.closest("[data-radix-select-content]") || t2.closest("[data-radix-select-trigger]") || t2.closest("[data-radix-popper-content-wrapper]") || ((_a2 = t2.id) == null ? void 0 : _a2.includes("radix-")) && ((_b2 = t2.id) == null ? void 0 : _b2.includes("select")) ? 1 : Array.from(t2.attributes).some((t3) => t3.name.startsWith("data-radix-") && t3.name.includes("select"));
}
function u(t2) {
  return d(t2) || h(t2);
}
function d(t2) {
  return "input" === t2.tagName.toLowerCase() ? "checkbox" === t2.type : "checkbox" === t2.getAttribute("role") || "switch" === t2.getAttribute("role") || "menuitemcheckbox" === t2.getAttribute("role") ? 1 : 0;
}
function h(t2) {
  return t2 instanceof HTMLInputElement && "radio" === t2.type || "radio" === t2.getAttribute("role");
}
function p(t2) {
  return ["aria-pressed", "aria-checked", "aria-selected", "aria-haspopup"].some((e2) => t2.hasAttribute(e2));
}
function f(t2) {
  var _a2, _b2, _c2;
  if (t2.id) {
    const e3 = document.querySelector('label[for="'.concat(t2.id, '"]'));
    if (e3) return ((_a2 = e3.textContent) == null ? void 0 : _a2.trim()) || null;
  }
  const e2 = t2.closest("label");
  if (e2) return ((_b2 = e2.textContent) == null ? void 0 : _b2.trim()) || null;
  const r2 = t2.parentElement;
  if (r2) {
    const t3 = (_c2 = r2.textContent) == null ? void 0 : _c2.trim();
    if (t3 && 50 > t3.length) return t3;
  }
  return null;
}
function m(t2) {
  if (t2.hasAttribute("data-value")) return 1;
  const e2 = t2.getAttribute("role");
  return "option" === e2 || "menuitem" === e2 || t2.closest('[role="dialog"], [role="listbox"], [role="menu"]') && ("pointer" === window.getComputedStyle(t2).cursor || t2.classList.contains("cursor-pointer")) ? 1 : 0;
}
function b(t2) {
  if (!(t2 instanceof HTMLElement && r(t2))) return 0;
  if (t2 instanceof HTMLInputElement && "hidden" === t2.type) return 1;
  const e2 = window.getComputedStyle(t2);
  return "none" === e2.display || "hidden" === e2.visibility || "0" === e2.opacity || "true" === t2.getAttribute("aria-disabled") || (t2 instanceof HTMLInputElement || t2 instanceof HTMLTextAreaElement || t2 instanceof HTMLSelectElement) && t2.disabled ? 0 : 1;
}
function y(t2) {
  return d(t2) ? "checkbox" : h(t2) ? "radio" : c(t2) || E(t2) ? "select" : "input";
}
function g(t2) {
  return s(t2) || a(t2) || u(t2) || c(t2) || E(t2) || t2 instanceof HTMLInputElement && "file" !== t2.type ? 1 : 0;
}
function v(t2) {
  var _a2, _b2, _c2, _d2;
  if (t2.hasAttribute("data-radix-select-item") || t2.hasAttribute("data-radix-collection-item")) {
    const e3 = t2.getAttribute("aria-label");
    if (e3) return e3;
    const r3 = (_a2 = t2.textContent) == null ? void 0 : _a2.trim();
    if (r3) return r3;
    const n3 = t2.getAttribute("data-value");
    if (n3) return n3;
  }
  if (t2 instanceof HTMLInputElement) {
    const e3 = f(t2);
    if (e3) return e3;
  }
  const e2 = t2.getAttribute("aria-label");
  if (e2) return e2;
  const r2 = t2.getAttribute("title");
  if (r2) return r2;
  const n2 = (_b2 = t2.textContent) == null ? void 0 : _b2.trim();
  if (n2) return n2;
  if (t2 instanceof HTMLInputElement) return t2.placeholder || t2.name || t2.type || "Input";
  if (t2 instanceof HTMLSelectElement) return t2.name || "Select";
  if (t2 instanceof HTMLOptionElement) return t2.label || t2.text || t2.value || "Option";
  const i2 = (_c2 = t2.parentElement) == null ? void 0 : _c2.children;
  if (i2) for (const s2 of i2) {
    const t3 = (_d2 = s2.textContent) == null ? void 0 : _d2.trim();
    if (t3 && t3.length > 0) return t3;
  }
  return t2.tagName.toLowerCase();
}
function x(t2) {
  var _a2, _b2;
  if (t2.hasAttribute("data-radix-select-item") || t2.hasAttribute("data-radix-collection-item")) {
    const e2 = t2.getAttribute("data-value");
    if (e2) return e2;
    const r2 = (_a2 = t2.textContent) == null ? void 0 : _a2.trim();
    if (r2) return r2;
  }
  return t2 instanceof HTMLInputElement || t2 instanceof HTMLSelectElement || t2 instanceof HTMLTextAreaElement ? t2.value || "" : t2 instanceof HTMLOptionElement ? t2.value || t2.text || "" : t2.getAttribute("data-value") || t2.getAttribute("value") || ((_b2 = t2.textContent) == null ? void 0 : _b2.trim()) || "";
}
function w(t2) {
  var _a2, _b2;
  if (t2.hasAttribute("data-radix-select-item") || t2.hasAttribute("data-radix-collection-item")) {
    if ("checked" === t2.getAttribute("data-state")) return 1;
    if ("true" === t2.getAttribute("aria-selected")) return 1;
    if (t2.hasAttribute("data-selected")) return 1;
    const e3 = document.querySelector('[data-radix-select-trigger][aria-expanded="false"]');
    if (e3) {
      const r3 = e3.getAttribute("data-value") || ((_a2 = e3.textContent) == null ? void 0 : _a2.trim()), n3 = t2.getAttribute("data-value") || ((_b2 = t2.textContent) == null ? void 0 : _b2.trim());
      if (r3 && n3 && r3 === n3) return 1;
    }
  }
  if (t2 instanceof HTMLInputElement && ("checkbox" === t2.type || "radio" === t2.type)) return t2.checked;
  if (t2 instanceof HTMLOptionElement) return t2.selected;
  const e2 = t2.getAttribute("aria-selected");
  if (e2) return "true" === e2;
  const r2 = t2.getAttribute("aria-checked");
  if (r2) return "true" === r2;
  const n2 = t2.getAttribute("data-state");
  return n2 ? "checked" === n2 || "selected" === n2 || "active" === n2 : 0;
}
function k(t2) {
  return d(t2) ? "checkbox" : h(t2) ? "radio" : c(t2) || E(t2) ? "select" : a(t2) ? "textarea" : s(t2) ? "input" : "none";
}
function S(t2) {
  const e2 = [];
  if (t2 instanceof HTMLSelectElement) return e2.push(...Array.from(t2.options)), e2;
  if (l(t2)) {
    const t3 = document.querySelector("[data-radix-select-content]");
    if (t3) {
      const r3 = t3.querySelectorAll("[data-radix-select-item]");
      e2.push(...Array.from(r3));
    }
    const r2 = document.querySelectorAll("[data-radix-collection-item]");
    e2.push(...Array.from(r2));
  }
  if (t2.classList.contains("MuiSelect-root") || t2.querySelector(".MuiSelect-select")) {
    const t3 = document.querySelector(".MuiMenu-root .MuiMenu-list");
    if (t3) {
      const r2 = t3.querySelectorAll(".MuiMenuItem-root");
      e2.push(...Array.from(r2));
    }
  }
  if (t2.hasAttribute("data-chakra-select") || t2.closest("[data-chakra-select]")) {
    const t3 = document.querySelector("[data-chakra-menu-list]");
    if (t3) {
      const r2 = t3.querySelectorAll('[role="menuitem"]');
      e2.push(...Array.from(r2));
    }
  }
  if (t2.classList.contains("ant-select") || t2.closest(".ant-select")) {
    const t3 = document.querySelector(".ant-select-dropdown:not(.ant-select-dropdown-hidden)");
    if (t3) {
      const r2 = t3.querySelectorAll(".ant-select-item-option");
      e2.push(...Array.from(r2));
    }
  }
  const n2 = ((t3) => {
    const e3 = [], r2 = t3.getAttribute("aria-controls");
    if (r2) {
      const t4 = document.getElementById(r2);
      if (t4 && "listbox" === t4.getAttribute("role")) {
        const r3 = t4.querySelectorAll('[role="option"]');
        e3.push(...Array.from(r3));
      }
    }
    if (t3.hasAttribute("aria-haspopup")) {
      const r3 = t3.getAttribute("aria-haspopup");
      if ("listbox" === r3 || "menu" === r3) {
        const t4 = document.querySelector('[role="listbox"]:not([aria-hidden="true"])'), r4 = document.querySelector('[role="menu"]:not([aria-hidden="true"])');
        if (t4) {
          const r5 = t4.querySelectorAll('[role="option"]');
          e3.push(...Array.from(r5));
        }
        if (r4) {
          const t5 = r4.querySelectorAll('[role="menuitem"]');
          e3.push(...Array.from(t5));
        }
      }
    }
    return e3;
  })(t2);
  e2.push(...n2);
  const i2 = (() => {
    const t3 = [];
    return [".dropdown-menu .dropdown-item", ".select-dropdown .select-option", ".popup-content .popup-option", "[data-dropdown-menu] [data-dropdown-item]", "[data-select-content] [data-select-item]", "[data-value]"].forEach((e3) => {
      try {
        const n3 = document.querySelectorAll(e3), i3 = Array.from(n3).filter((t4) => r(t4));
        t3.push(...i3);
      } catch (n3) {
      }
    }), t3;
  })();
  return e2.push(...i2), Array.from(new Set(e2));
}
function E(t2) {
  return t2 instanceof HTMLSelectElement ? 1 : ["combobox" === t2.getAttribute("role"), "button" === t2.getAttribute("role") && t2.hasAttribute("aria-haspopup"), t2.hasAttribute("aria-haspopup"), t2.hasAttribute("aria-expanded"), t2.hasAttribute("aria-controls"), t2.hasAttribute("data-radix-select-trigger"), t2.hasAttribute("data-chakra-select"), t2.classList.contains("MuiSelect-root"), t2.classList.contains("ant-select-selector"), t2.classList.contains("select-trigger"), t2.classList.contains("dropdown-trigger"), t2.tagName.toLowerCase().includes("select")].some(Boolean);
}
var T, $, A, I, L, M, C, H, R;
import { g as z, i as _, x as D, s as F, a as O, n as N, r as P, e as B, t as j } from "./sherpa-guide-components-0.0.13.BkF4XA9G.min.js";
let U = [], V = (t2, e2) => {
  let r2 = [], n2 = { get() {
    return n2.lc || n2.listen(() => {
    })(), n2.value;
  }, l: e2 || 0, lc: 0, listen(t3, e3) {
    return n2.lc = r2.push(t3, e3 || n2.l) / 2, () => {
      let e4 = r2.indexOf(t3);
      ~e4 && (r2.splice(e4, 2), --n2.lc || n2.off());
    };
  }, notify(t3, e3) {
    let i2 = !U.length;
    for (let s2 = 0; r2.length > s2; s2 += 2) U.push(r2[s2], r2[s2 + 1], n2.value, t3, e3);
    if (i2) {
      for (let t4 = 0; U.length > t4; t4 += 5) {
        let e4;
        for (let r3 = t4 + 1; !e4 && (r3 += 5) < U.length; ) U[t4 + 1] > U[r3] && (e4 = U.push(U[t4], U[t4 + 1], U[t4 + 2], U[t4 + 3], U[t4 + 4]));
        e4 || U[t4](U[t4 + 2], U[t4 + 3], U[t4 + 4]);
      }
      U.length = 0;
    }
  }, off() {
  }, set(t3) {
    let e3 = n2.value;
    e3 !== t3 && (n2.value = t3, n2.notify(e3));
  }, subscribe(t3, e3) {
    let r3 = n2.listen(t3, e3);
    return t3(n2.value), r3;
  }, value: t2 };
  return n2;
}, q = (t2, e2) => ((t3, e3) => {
  let r2;
  Array.isArray(t3) || (t3 = [t3]);
  let n2 = 0, i2 = () => {
    let i3 = t3.map((t4) => t4.get());
    if (void 0 === r2 || i3.some((t4, e4) => t4 !== r2[e4])) {
      let t4 = ++n2;
      r2 = i3;
      let o3 = e3(...i3);
      o3 && o3.then && o3.t ? o3.then((e4) => {
        t4 === n2 && s2.set(e4);
      }) : s2.set(o3);
    }
  }, s2 = V(void 0, Math.max(...t3.map((t4) => t4.l)) + 1), o2 = i2;
  var a2, c2, l2, u2, d2;
  return c2 = () => {
    let e4 = t3.map((t4) => t4.listen(o2, -1 / s2.l));
    return i2(), () => {
      for (let t4 of e4) t4();
    };
  }, u2 = () => {
    let t4 = c2();
    t4 && a2.events[6].push(t4);
  }, d2 = (t4) => {
    let e4 = a2.listen;
    a2.listen = (...r4) => (a2.lc || a2.active || (a2.active = 1, t4()), e4(...r4));
    let r3 = a2.off;
    return a2.events[6] = [], a2.off = () => {
      r3(), setTimeout(() => {
        if (a2.active && !a2.lc) {
          a2.active = 0;
          for (let t5 of a2.events[6]) t5();
          a2.events[6] = [];
        }
      }, 1e3);
    }, () => {
      a2.listen = e4, a2.off = r3;
    };
  }, (l2 = a2 = s2).events = l2.events || {}, l2.events[15] || (l2.events[15] = d2((t4) => {
    l2.events[5].reduceRight((t5, e4) => (e4(t5), t5), __spreadValues({ shared: {} }, t4));
  })), l2.events[5] = l2.events[5] || [], l2.events[5].push(u2), () => {
    let t4 = l2.events[5], e4 = t4.indexOf(u2);
    t4.splice(e4, 1), t4.length || (delete l2.events[5], l2.events[15](), delete l2.events[15]);
  }, s2;
})(t2, e2);
const Z = V({ isActive: 0, currentStepIndex: 0, steps: [], personalizedSteps: void 0, context: void 0, metadata: void 0, tour: void 0 }), Q = q(Z, (t2) => t2.isActive && t2.steps && 0 !== t2.steps.length && t2.steps[t2.currentStepIndex] || null), G = q(Z, (t2) => 0 === t2.currentStepIndex), X = q(Z, (t2) => t2.steps ? t2.currentStepIndex === t2.steps.length - 1 : 0), W = q(Z, (t2) => t2.steps && 0 !== t2.steps.length ? (t2.currentStepIndex + 1) / t2.steps.length * 100 : 0);
q(Z, (t2) => t2.steps ? t2.steps.length : 0);
const Y = { startTour(t2, e2, r2, n2) {
  Z.set({ isActive: 1, tour: t2, tourId: t2.id, currentStepIndex: 0, steps: e2, personalizedSteps: void 0, context: r2, metadata: n2 });
}, endTour() {
  Z.set({ isActive: 0, tourId: void 0, currentStepIndex: 0, steps: [], personalizedSteps: void 0, context: void 0, metadata: void 0, tour: void 0 });
}, nextStep() {
  const t2 = Z.get();
  return t2.steps && t2.steps.length - 1 > t2.currentStepIndex ? (Z.set(__spreadProps(__spreadValues({}, t2), { currentStepIndex: t2.currentStepIndex + 1 })), 1) : 0;
}, previousStep() {
  const t2 = Z.get();
  return t2.steps ? t2.currentStepIndex > 0 ? (Z.set(__spreadProps(__spreadValues({}, t2), { currentStepIndex: t2.currentStepIndex - 1 })), 1) : (Y.endTour(), 0) : 0;
}, goToStep(t2) {
  const e2 = Z.get();
  return e2.steps && t2 >= 0 && e2.steps.length > t2 ? (Z.set(__spreadProps(__spreadValues({}, e2), { currentStepIndex: t2 })), 1) : 0;
}, setPersonalizedSteps(t2) {
  const e2 = Z.get();
  Z.set(__spreadProps(__spreadValues({}, e2), { personalizedSteps: t2 }));
}, updateStepMetadata(t2, e2) {
  const r2 = Z.get();
  if (r2.steps && t2 >= 0 && r2.steps.length > t2) {
    const n2 = [...r2.steps];
    n2[t2] = __spreadProps(__spreadValues({}, n2[t2]), { metadata: __spreadValues(__spreadValues({}, n2[t2].metadata), e2) }), Z.set(__spreadProps(__spreadValues({}, r2), { steps: n2 }));
  }
} }, K = V({ searchVisible: 0, controlPanelVisible: 0, currentTooltip: void 0, currentBeacon: void 0 }), J = { showSearch() {
  const t2 = K.get();
  K.set(__spreadProps(__spreadValues({}, t2), { searchVisible: 1 }));
}, hideSearch() {
  const t2 = K.get();
  K.set(__spreadProps(__spreadValues({}, t2), { searchVisible: 0 }));
}, showControlPanel() {
  const t2 = K.get();
  K.set(__spreadProps(__spreadValues({}, t2), { controlPanelVisible: 1 }));
}, hideControlPanel() {
  const t2 = K.get();
  K.set(__spreadProps(__spreadValues({}, t2), { controlPanelVisible: 0 })), J.showSearch();
}, showTooltip(t2, e2, r2, n2) {
  const i2 = K.get();
  K.set(__spreadProps(__spreadValues({}, i2), { currentTooltip: { stepId: t2, element: e2, guide: r2, isPersonalizing: n2 } }));
}, hideTooltip() {
  const t2 = K.get();
  K.set(__spreadProps(__spreadValues({}, t2), { currentTooltip: void 0 }));
}, showBeacon(t2, e2) {
  const r2 = K.get();
  K.set(__spreadProps(__spreadValues({}, r2), { currentBeacon: { stepId: t2, element: e2 } }));
}, hideBeacon() {
  const t2 = K.get();
  K.set(__spreadProps(__spreadValues({}, t2), { currentBeacon: void 0 }));
}, reset() {
  K.set({ searchVisible: 0, controlPanelVisible: 0, currentTooltip: void 0, currentBeacon: void 0 }), J.showSearch();
}, updateTooltipPersonalizingState(t2) {
  const e2 = K.get();
  e2.currentTooltip && K.set(__spreadProps(__spreadValues({}, e2), { currentTooltip: __spreadProps(__spreadValues({}, e2.currentTooltip), { isPersonalizing: t2 }) }));
} };
class tt {
  constructor(t2) {
    __publicField(this, "config");
    this.config = t2;
  }
  triggerChangeEvents(t2) {
    t2 instanceof HTMLElement && "function" == typeof t2.focus && t2.focus();
    const e2 = [new Event("input", { bubbles: 1, cancelable: 1 }), new Event("change", { bubbles: 1, cancelable: 1 }), new Event("blur", { bubbles: 1, cancelable: 1 })];
    e2.forEach((e3) => {
      t2.dispatchEvent(e3);
    }), e2.forEach((e3, r2) => {
      setTimeout(() => {
        t2.dispatchEvent(new Event(e3.type, { bubbles: 1, cancelable: 1 }));
      }, r2 * this.config.frameworkEventDelay);
    }), this.triggerReactEvents(t2), this.triggerVueEvents(t2), this.triggerAngularEvents(t2), this.triggerAccessibilityEvents(t2);
  }
  triggerReactEvents(t2) {
    Object.keys(t2).find((t3) => t3.startsWith("__reactProps") || t3.startsWith("__reactEventHandlers") || t3.startsWith("__reactInternalInstance")) && (setTimeout(() => {
      t2.dispatchEvent(new Event("input", { bubbles: 1 })), t2.dispatchEvent(new Event("change", { bubbles: 1 }));
    }, this.config.frameworkEventDelay), setTimeout(() => {
      t2.dispatchEvent(new Event("input", { bubbles: 1 }));
    }, 2 * this.config.frameworkEventDelay));
  }
  triggerVueEvents(t2) {
    Object.keys(t2).find((t3) => t3.startsWith("__vue") || t3.startsWith("_vue")) && setTimeout(() => {
      t2.dispatchEvent(new Event("input", { bubbles: 1 })), t2.dispatchEvent(new Event("change", { bubbles: 1 }));
    }, this.config.frameworkEventDelay);
  }
  triggerAngularEvents(t2) {
    (t2.hasAttribute("ng-reflect-model") || ("" + t2.classList).includes("ng-") || void 0 !== window.ng) && setTimeout(() => {
      t2.dispatchEvent(new Event("input", { bubbles: 1 })), t2.dispatchEvent(new Event("change", { bubbles: 1 })), t2.dispatchEvent(new Event("focus", { bubbles: 1 })), t2.dispatchEvent(new Event("blur", { bubbles: 1 }));
    }, this.config.frameworkEventDelay);
  }
  triggerAccessibilityEvents(t2) {
    const e2 = document.querySelectorAll("[aria-live]");
    for (const r2 of Array.from(e2)) if (r2.contains(t2) || t2.contains(r2)) {
      const t3 = r2.textContent;
      setTimeout(() => {
        r2.textContent = t3 + " ", setTimeout(() => {
          r2.textContent = t3;
        }, 10);
      }, this.config.frameworkEventDelay);
    }
  }
}
class et {
  resolve(t2) {
    return this.resolveWithFallbacks(t2);
  }
  calculateDistance(t2, e2) {
    const r2 = t2.getBoundingClientRect(), n2 = e2.getBoundingClientRect(), i2 = r2.top + r2.height / 2, s2 = n2.top + n2.height / 2;
    return Math.sqrt(Math.pow(r2.left + r2.width / 2 - (n2.left + n2.width / 2), 2) + Math.pow(i2 - s2, 2));
  }
  findClosestElement(t2, e2) {
    if (0 === t2.length) return null;
    if (1 === t2.length) return t2[0];
    if (!e2) return t2[0];
    let r2 = t2[0], n2 = this.calculateDistance(e2, r2);
    for (let i2 = 1; t2.length > i2; i2++) {
      const s2 = this.calculateDistance(e2, t2[i2]);
      n2 > s2 && (n2 = s2, r2 = t2[i2]);
    }
    return r2;
  }
  scoreElementMatches(t2, e2) {
    let r2 = 0;
    for (const { selector: i2, weight: s2, type: o2 } of e2) try {
      if ("xpath" === o2) {
        const e3 = document.evaluate(i2, document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
        for (let n2 = 0; e3.snapshotLength > n2; n2++) if (e3.snapshotItem(n2) === t2) {
          r2 += s2;
          break;
        }
      } else if ("dsl" === o2) this.executeDSLQuery(i2).includes(t2) && (r2 += s2);
      else {
        const e3 = document.querySelectorAll(i2);
        Array.from(e3).includes(t2) && (r2 += s2);
      }
    } catch (n2) {
    }
    return r2;
  }
  resolveByTextContent(t2, e2) {
    try {
      const r2 = document.querySelectorAll(t2), n2 = Array.from(r2);
      if (!e2) return n2;
      const i2 = n2.filter((t3) => {
        var _a2;
        const r3 = (_a2 = t3.textContent) == null ? void 0 : _a2.trim();
        if (r3 === e2) return 1;
        if (r3 == null ? void 0 : r3.includes(e2)) return 1;
        if (Array.from(t3.children).some((t4) => {
          var _a3;
          const r4 = (_a3 = t4.textContent) == null ? void 0 : _a3.trim();
          return r4 === e2 || (r4 == null ? void 0 : r4.includes(e2));
        })) return 1;
        const n3 = t3.querySelectorAll("span, div, p, h1, h2, h3, h4, h5, h6");
        return Array.from(n3).some((t4) => {
          var _a3;
          const r4 = (_a3 = t4.textContent) == null ? void 0 : _a3.trim();
          return r4 === e2 || (r4 == null ? void 0 : r4.includes(e2));
        });
      });
      return i2.length > 0 ? i2 : n2;
    } catch (r2) {
      return [];
    }
  }
  resolveXPathWithTextContent(t2) {
    try {
      const e2 = document.evaluate(t2, document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null), r2 = [];
      for (let t3 = 0; e2.snapshotLength > t3; t3++) {
        const n2 = e2.snapshotItem(t3);
        n2 && r2.push(n2);
      }
      return r2;
    } catch (e2) {
      return [];
    }
  }
  extractExpectedTextFromSelector(t2) {
    var _a2;
    if ((_a2 = t2.fallback) == null ? void 0 : _a2.xpath) {
      const e2 = t2.fallback.xpath, r2 = e2.match(/normalize-space\(text\(\)\)="([^"]+)"/);
      if (r2) return r2[1].replace(/&apos;/g, "'").replace(/&quot;/g, '"');
      const n2 = e2.match(/contains\(normalize-space\(\.\), "([^"]+)"\)/);
      if (n2) return n2[1].replace(/&apos;/g, "'").replace(/&quot;/g, '"');
      const i2 = e2.match(/text\(\)="([^"]+)"/);
      if (i2) return i2[1].replace(/&apos;/g, "'").replace(/&quot;/g, '"');
      const s2 = e2.match(/\w+\[normalize-space\(text\(\)\)="([^"]+)"\]/);
      if (s2) return s2[1].replace(/&apos;/g, "'").replace(/&quot;/g, '"');
    }
  }
  resolveWithFallbacks(t2, e2) {
    var _a2, _b2, _c2, _d2, _e2, _f2, _g2;
    const r2 = t2.primary, n2 = t2.fallback, i2 = this.extractExpectedTextFromSelector(t2), s2 = [], o2 = ((_a2 = n2 == null ? void 0 : n2.xpath) == null ? void 0 : _a2.includes("text()")) || ((_b2 = n2 == null ? void 0 : n2.query) == null ? void 0 : _b2.includes("text:")) || ((_c2 = n2 == null ? void 0 : n2.query) == null ? void 0 : _c2.includes("contains:")), a2 = r2.includes("nth-child") || r2.includes("nth-of-type") || r2.includes(">");
    o2 && a2 ? (s2.push({ selector: r2, weight: 6, type: "css" }), ((_d2 = n2 == null ? void 0 : n2.xpath) == null ? void 0 : _d2.includes("text()")) && s2.push({ selector: n2.xpath, weight: 10, type: "xpath" }), (((_e2 = n2 == null ? void 0 : n2.query) == null ? void 0 : _e2.includes("text:")) || ((_f2 = n2 == null ? void 0 : n2.query) == null ? void 0 : _f2.includes("contains:"))) && s2.push({ selector: n2.query, weight: 9, type: "dsl" }), (n2 == null ? void 0 : n2.css) && s2.push({ selector: n2.css, weight: 7, type: "css" })) : (s2.push({ selector: r2, weight: 10, type: "css" }), (n2 == null ? void 0 : n2.css) && s2.push({ selector: n2.css, weight: 8, type: "css" }), (n2 == null ? void 0 : n2.xpath) && s2.push({ selector: n2.xpath, weight: 8, type: "xpath" }), (n2 == null ? void 0 : n2.query) && s2.push({ selector: n2.query, weight: 4, type: "dsl" }));
    const c2 = /* @__PURE__ */ new Set();
    for (const { selector: f2, type: m2 } of s2) {
      let t3 = [];
      try {
        "css" === m2 ? t3 = this.resolveByTextContent(f2, i2) : "xpath" === m2 ? t3 = this.resolveXPathWithTextContent(f2) : "dsl" === m2 && (t3 = this.executeDSLQuery(f2)), t3.forEach((t4) => c2.add(t4));
      } catch (p2) {
      }
    }
    const l2 = Array.from(c2);
    if (0 === l2.length) return null;
    if (1 === l2.length) return l2[0];
    const u2 = l2.map((t3) => ({ element: t3, score: this.scoreElementMatches(t3, s2) }));
    u2.sort((t3, e3) => t3.score !== e3.score ? e3.score - t3.score : l2.indexOf(t3.element) - l2.indexOf(e3.element));
    const d2 = ((_g2 = u2[0]) == null ? void 0 : _g2.score) || 0, h2 = u2.filter(({ score: t3 }) => t3 === d2).map(({ element: t3 }) => t3);
    if (1 === h2.length) return h2[0];
    if (h2.length > 1) {
      if (i2) {
        const t4 = h2.filter((t5) => {
          var _a3;
          const e3 = (_a3 = t5.textContent) == null ? void 0 : _a3.trim();
          return e3 === i2 || (e3 == null ? void 0 : e3.includes(i2));
        });
        if (1 === t4.length) return t4[0];
        if (t4.length > 1) return this.selectBestFromCandidates(t4, e2);
      }
      const t3 = this.findMostSpecificElement(h2);
      if (t3) return t3;
      if (e2) {
        const t4 = this.findClosestElement(h2, e2);
        if (t4) return t4;
      }
      return h2[0];
    }
    return this.selectBestFromCandidates(l2, e2);
  }
  selectBestFromCandidates(t2, e2) {
    if (1 === t2.length) return t2[0];
    const r2 = this.findMostSpecificElement(t2);
    if (r2) return r2;
    if (e2) {
      const r3 = this.findClosestElement(t2, e2);
      if (r3) return r3;
    }
    return t2[0];
  }
  findMostSpecificElement(t2) {
    var _a2;
    if (1 >= t2.length) return t2[0] || null;
    const e2 = t2.map((t3) => {
      let e3 = 0;
      t3.id && 1 === document.querySelectorAll("#" + CSS.escape(t3.id)).length && (e3 += 100);
      const r3 = t3.getAttribute("href");
      if (r3) {
        const t4 = document.querySelectorAll('[href="'.concat(CSS.escape(r3), '"]'));
        1 === t4.length ? e3 += 50 : t4.length > 3 || (e3 += 25);
      }
      if (t3.className) {
        const r4 = t3.className.split(/\s+/).filter(Boolean);
        if (r4.length > 0) {
          const t4 = r4.map((t5) => "." + CSS.escape(t5)).join(""), n2 = document.querySelectorAll(t4);
          1 === n2.length ? e3 += 30 : n2.length > 3 || (e3 += 15);
        }
      }
      return e3 += 5 * Array.from(t3.attributes).filter((t4) => t4.name.startsWith("data-")).length, e3 += 3 * Array.from(t3.attributes).filter((t4) => t4.name.startsWith("aria-")).length, { element: t3, specificity: e3 };
    });
    e2.sort((t3, e3) => e3.specificity - t3.specificity);
    const r2 = ((_a2 = e2[0]) == null ? void 0 : _a2.specificity) || 0;
    return e2.filter(({ specificity: t3 }) => t3 === r2).map(({ element: t3 }) => t3)[0] || null;
  }
  waitForElement(t2, e2 = 1e4) {
    return new Promise((r2, n2) => {
      const i2 = this.resolve(t2);
      if (i2) return r2(i2), void 0;
      let s2, o2;
      const a2 = () => {
        s2 && clearTimeout(s2), o2 && o2.disconnect();
      };
      s2 = window.setTimeout(() => {
        a2(), n2(Error("Element not found within timeout: " + t2.primary));
      }, e2), o2 = new MutationObserver(() => {
        Promise.resolve().then(() => {
          let e3 = this.resolve(t2);
          if (e3) return a2(), r2(e3), void 0;
          setTimeout(() => {
            e3 = this.resolve(t2), e3 && (a2(), r2(e3));
          }, 20);
        });
      }), o2.observe(document.body, { childList: 1, subtree: 1, attributes: 1 });
    });
  }
  getElementInfo(t2) {
    var _a2, _b2, _c2;
    const e2 = t2.getBoundingClientRect(), r2 = {};
    for (let u2 = 0; t2.attributes.length > u2; u2++) {
      const e3 = t2.attributes[u2];
      r2[e3.name] = e3.value;
    }
    const n2 = {};
    for (const [u2, d2] of Object.entries(r2)) u2.startsWith("aria-") && (n2[u2.substring(5)] = d2);
    const i2 = {};
    if (t2 instanceof HTMLElement) for (const [u2, d2] of Object.entries(t2.dataset)) void 0 !== d2 && (i2[u2] = d2);
    let s2, o2;
    if (t2 instanceof HTMLInputElement && t2.id) {
      const e3 = document.querySelector('label[for="'.concat(t2.id, '"]'));
      e3 && (s2 = { text: (_a2 = e3.textContent) == null ? void 0 : _a2.trim(), htmlFor: t2.id, selector: 'label[for="'.concat(t2.id, '"]') });
    }
    const a2 = t2.closest("form"), c2 = t2.closest("fieldset");
    if ((a2 || c2) && (o2 = {}, (a2 == null ? void 0 : a2.id) && (o2.formId = a2.id), c2)) {
      const t3 = c2.querySelector("legend");
      t3 && (o2.fieldsetLegend = (_b2 = t3.textContent) == null ? void 0 : _b2.trim());
    }
    const l2 = { tagName: t2.tagName, id: t2.id || "", classList: Array.from(t2.classList), attributes: r2, aria: Object.keys(n2).length > 0 ? n2 : {}, dataset: Object.keys(i2).length > 0 ? i2 : {}, textContent: ((_c2 = t2.textContent) == null ? void 0 : _c2.trim()) || void 0, innerHTML: t2.innerHTML || void 0, outerHTML: t2.outerHTML || void 0, boundingRect: { x: e2.x, y: e2.y, width: e2.width, height: e2.height }, label: s2, formContext: o2 };
    return t2 instanceof HTMLInputElement ? (l2.type = t2.type, l2.name = t2.name || "", l2.placeholder = t2.placeholder || void 0, l2.value = t2.value || void 0) : t2 instanceof HTMLSelectElement ? (l2.name = t2.name || "", l2.value = t2.value || void 0) : t2 instanceof HTMLTextAreaElement ? (l2.name = t2.name || "", l2.placeholder = t2.placeholder || void 0, l2.value = t2.value || void 0) : t2 instanceof HTMLButtonElement && (l2.name = t2.name || ""), l2;
  }
  static createElementSelector(t2, e2) {
    let r2;
    return r2 = "string" == typeof e2 ? { css: e2 } : e2 || {}, { primary: t2, fallback: r2 };
  }
  static toElementEntity(t2, e2) {
    return __spreadProps(__spreadValues({}, e2), { selector: t2 });
  }
  executeDSLQuery(t2) {
    try {
      if (!this.isDSLQuery(t2)) return Array.from(document.querySelectorAll(t2));
      const e2 = this.parseDSLQuery(t2);
      let r2 = { elements: Array.from(document.querySelectorAll("*")), originalQuery: t2 };
      for (let t3 = 0; e2.length > t3; t3++) {
        const n2 = e2[t3], i2 = e2[t3 + 1];
        if ("and" !== n2.type) {
          if ("or" !== n2.type) {
            if (r2.elements = this.applyDSLToken(r2, n2), 0 === r2.elements.length) break;
          } else if (i2) {
            const e3 = this.applyDSLToken(r2, i2);
            r2.elements = [.../* @__PURE__ */ new Set([...r2.elements, ...e3])], t3++;
          }
        }
      }
      return r2.elements;
    } catch (e2) {
      try {
        return Array.from(document.querySelectorAll(t2));
      } catch (r2) {
        return void 0, [];
      }
    }
  }
  isDSLQuery(t2) {
    return [/text:/, /contains:/, /attr:/, /tag:/, /parent:/, /child:/, /sibling:/, /nth:/, /\bvisible\b/, /\benabled\b/, /\band\b/, /\bor\b/].some((e2) => e2.test(t2));
  }
  parseDSLQuery(t2) {
    const e2 = [], r2 = t2.split(/\s+(and|or)\s+/);
    for (let n2 = 0; r2.length > n2; n2++) {
      const t3 = r2[n2].trim();
      if ("and" === t3 || "or" === t3) {
        e2.push({ type: t3 });
        continue;
      }
      const i2 = this.parseQueryPart(t3);
      e2.push(...i2);
    }
    return e2;
  }
  parseQueryPart(t2) {
    const e2 = [];
    if (t2.startsWith("text:")) {
      const r3 = this.extractQuotedValue(t2, "text:");
      return e2.push({ type: "text", value: r3 }), e2;
    }
    if (t2.startsWith("contains:")) {
      const r3 = this.extractQuotedValue(t2, "contains:");
      return e2.push({ type: "contains", value: r3 }), e2;
    }
    if (t2.startsWith("attr:")) {
      const r3 = this.parseAttributeQuery(t2);
      return r3 && e2.push(r3), e2;
    }
    if (t2.startsWith("tag:")) {
      const r3 = t2.substring(4);
      return e2.push({ type: "tag", value: r3 }), e2;
    }
    if (t2.startsWith("class:")) {
      const r3 = t2.substring(6);
      return e2.push({ type: "class", value: r3 }), e2;
    }
    if (t2.startsWith("id:")) {
      const r3 = t2.substring(3);
      return e2.push({ type: "id", value: r3 }), e2;
    }
    if (t2.startsWith("parent:")) {
      const r3 = t2.substring(7);
      return e2.push({ type: "parent", value: r3 }), e2;
    }
    if (t2.startsWith("child:")) {
      const r3 = t2.substring(6);
      return e2.push({ type: "child", value: r3 }), e2;
    }
    if (t2.startsWith("sibling:")) {
      const r3 = t2.substring(8);
      return e2.push({ type: "sibling", value: r3 }), e2;
    }
    if (t2.startsWith("nth:")) {
      const r3 = t2.substring(4);
      return e2.push({ type: "nth", value: r3 }), e2;
    }
    if ("visible" === t2) return e2.push({ type: "visible" }), e2;
    if ("enabled" === t2) return e2.push({ type: "enabled" }), e2;
    const r2 = t2.match(/^([^[\]]+)(?:\[([^\]]+)\])?$/);
    if (r2) {
      const [, t3, n2] = r2;
      if (t3 && "visible" !== t3 && "enabled" !== t3 && !this.isDSLQuery(t3) && e2.push({ type: "selector", value: t3 }), n2) {
        const t4 = this.parseBracketedQuery(n2);
        e2.push(...t4);
      }
      "visible" === t3 ? e2.push({ type: "visible" }) : "enabled" === t3 && e2.push({ type: "enabled" });
    }
    return e2;
  }
  parseBracketedQuery(t2) {
    const e2 = [];
    if (t2.startsWith("text:")) {
      const r2 = this.extractQuotedValue(t2, "text:");
      e2.push({ type: "text", value: r2 });
    } else if (t2.startsWith("contains:")) {
      const r2 = this.extractQuotedValue(t2, "contains:");
      e2.push({ type: "contains", value: r2 });
    } else if (t2.startsWith("attr:")) {
      const r2 = this.parseAttributeQuery(t2);
      r2 && e2.push(r2);
    }
    return e2;
  }
  extractQuotedValue(t2, e2) {
    const r2 = t2.substring(e2.length), n2 = r2.match(/^"([^"]*)"$|^'([^']*)'$|^(.*)$/);
    return n2 ? n2[1] || n2[2] || n2[3] || "" : r2;
  }
  parseAttributeQuery(t2) {
    const e2 = t2.substring(5).match(/^([^=!*^$]+)(=|!=|\*=|\^=|\$=)"?([^"]*)"?$/);
    if (e2) {
      const [, t3, r2, n2] = e2;
      return { type: "attr", attribute: t3.trim(), operator: r2, value: n2.trim() };
    }
    return null;
  }
  applyDSLToken(t2, e2) {
    const { elements: r2 } = t2;
    switch (e2.type) {
      case "selector":
        if (!e2.value) return r2;
        try {
          const t3 = Array.from(document.querySelectorAll(e2.value));
          return r2.filter((e3) => t3.includes(e3));
        } catch (n2) {
          return r2;
        }
      case "text":
        return r2.filter((t3) => {
          var _a2, _b2;
          const r3 = (_a2 = t3.textContent) == null ? void 0 : _a2.trim(), n2 = (_b2 = e2.value) == null ? void 0 : _b2.trim(), i2 = r3 == null ? void 0 : r3.replace(/\s+/g, " "), s2 = n2 == null ? void 0 : n2.replace(/\s+/g, " ");
          return i2 === s2 || r3 === n2;
        });
      case "contains":
        return r2.filter((t3) => {
          var _a2, _b2;
          const r3 = (_a2 = t3.textContent) == null ? void 0 : _a2.trim(), n2 = (_b2 = e2.value) == null ? void 0 : _b2.trim();
          if (!r3 || !n2) return 0;
          const i2 = r3.replace(/\s+/g, " "), s2 = n2.replace(/\s+/g, " ");
          return r3.includes(n2) || i2.includes(s2);
        });
      case "attr":
        return r2.filter((t3) => {
          if (!e2.attribute || !e2.operator) return 0;
          const r3 = t3.getAttribute(e2.attribute);
          if (null === r3) return 0;
          switch (e2.operator) {
            case "=":
              return r3 === e2.value;
            case "!=":
              return r3 !== e2.value;
            case "*=":
              return e2.value ? r3.includes(e2.value) : 0;
            case "^=":
              return e2.value ? r3.startsWith(e2.value) : 0;
            case "$=":
              return e2.value ? r3.endsWith(e2.value) : 0;
            default:
              return 0;
          }
        });
      case "tag":
        return r2.filter((t3) => {
          var _a2;
          return t3.tagName.toLowerCase() === ((_a2 = e2.value) == null ? void 0 : _a2.toLowerCase());
        });
      case "class":
        return r2.filter((t3) => e2.value ? t3.classList.contains(e2.value) : 0);
      case "id":
        return r2.filter((t3) => t3.id === e2.value);
      case "parent":
        return r2.filter((t3) => {
          const r3 = t3.parentElement;
          return r3 && e2.value ? e2.value.startsWith(".") ? r3.classList.contains(e2.value.substring(1)) : e2.value.startsWith("#") ? r3.id === e2.value.substring(1) : r3.tagName.toLowerCase() === e2.value.toLowerCase() : 0;
        });
      case "child":
        return r2.filter((t3) => {
          if (!e2.value) return 0;
          let r3 = e2.value;
          r3.startsWith(".") || r3.startsWith("#") || r3.includes("[") || (r3 = r3.toLowerCase());
          try {
            return null !== t3.querySelector(r3);
          } catch (n2) {
            return Array.from(t3.children).some((t4) => {
              var _a2;
              return t4.tagName.toLowerCase() === ((_a2 = e2.value) == null ? void 0 : _a2.toLowerCase());
            });
          }
        });
      case "sibling":
        return r2.filter((t3) => {
          const r3 = t3.parentElement;
          return r3 && e2.value ? Array.from(r3.children).filter((e3) => e3 !== t3).some((t4) => e2.value.startsWith(".") ? t4.classList.contains(e2.value.substring(1)) : e2.value.startsWith("#") ? t4.id === e2.value.substring(1) : t4.tagName.toLowerCase() === e2.value.toLowerCase()) : 0;
        });
      case "nth":
        return r2.filter((t3) => {
          const r3 = t3.parentElement;
          return r3 && e2.value ? Array.from(r3.children).indexOf(t3) + 1 === parseInt(e2.value, 10) : 0;
        });
      case "visible":
        return r2.filter((t3) => {
          var _a2, _b2, _c2, _d2;
          try {
            const e3 = window.getComputedStyle(t3), r3 = t3;
            return "undefined" != typeof window && (((_b2 = (_a2 = window.navigator) == null ? void 0 : _a2.userAgent) == null ? void 0 : _b2.includes("jsdom")) || !((_d2 = (_c2 = window.HTMLElement) == null ? void 0 : _c2.prototype) == null ? void 0 : _d2.getBoundingClientRect) || void 0 !== globalThis.global && globalThis.global.window === window) ? "none" !== e3.display && "hidden" !== e3.visibility : "none" !== e3.display && "hidden" !== e3.visibility && "0" !== e3.opacity && r3.offsetWidth > 0 && r3.offsetHeight > 0;
          } catch (n2) {
            return 1;
          }
        });
      case "enabled":
        return r2.filter((t3) => t3 instanceof HTMLInputElement || t3 instanceof HTMLButtonElement || t3 instanceof HTMLSelectElement || t3 instanceof HTMLTextAreaElement ? !t3.disabled : !t3.hasAttribute("disabled") && "true" !== t3.getAttribute("aria-disabled"));
      default:
        return r2;
    }
  }
}
const rt = new et(), nt = Object.freeze({ __proto__: null, ElementResolver: et, elementResolver: rt });
class it {
  findTargetElement(t2) {
    const { inputSelector: e2 } = t2;
    return rt.resolve(e2) || this.findElementBySmartFallback(t2) || null;
  }
  findElementBySmartFallback(t2) {
    var _a2, _b2;
    const { type: e2, value: r2 } = t2;
    if ("input" === e2 || "select" === e2 || "checkbox" === e2 || "radio" === e2) {
      const t3 = (_a2 = r2[0]) == null ? void 0 : _a2.toLowerCase().trim();
      if (t3) {
        const r3 = document.querySelectorAll("label");
        for (const n2 of r3) {
          const r4 = (_b2 = n2.textContent) == null ? void 0 : _b2.toLowerCase().trim();
          if (r4 == null ? void 0 : r4.includes(t3)) {
            if (n2.htmlFor) {
              const t5 = document.getElementById(n2.htmlFor);
              if (t5 && this.canApplyByType(e2, t5)) return t5;
            }
            const t4 = n2.querySelector('input[type="'.concat(e2, '"], select, textarea'));
            if (t4 && this.canApplyByType(e2, t4)) return t4;
          }
        }
      }
    }
    if ("input" === e2 && r2[0]) {
      const t3 = r2[0].toLowerCase().trim(), e3 = document.querySelector('input[placeholder*="'.concat(t3, '" i], textarea[placeholder*="').concat(t3, '" i]'));
      if (e3 && this.canApplyToInput(e3)) return e3;
    }
    if (r2[0]) {
      const t3 = r2[0].toLowerCase().replace(/\s+/g, "_"), n2 = document.querySelector('input[name*="'.concat(t3, '"], select[name*="').concat(t3, '"], textarea[name*="').concat(t3, '"]'));
      if (n2 && this.canApplyByType(e2, n2)) return n2;
    }
    return null;
  }
  canApplyByType(t2, e2) {
    switch (t2) {
      case "input":
        return this.canApplyToInput(e2);
      case "select":
        return this.canApplyToSelect(e2);
      case "checkbox":
        return this.canApplyToCheckbox(e2);
      case "radio":
        return this.canApplyToRadio(e2);
      default:
        return 0;
    }
  }
  findElementByMultipleStrategies(t2, e2, r2) {
    const n2 = r2 || document;
    for (const s2 of t2) try {
      const t3 = n2.querySelector(s2);
      if (t3 && this.isInteractable(t3) && (!e2 || this.canApplyByType(e2, t3))) return t3;
    } catch (i2) {
    }
    return null;
  }
  findSimilarElements(t2, e2) {
    const r2 = v(t2), n2 = x(t2), i2 = t2.tagName.toLowerCase(), s2 = t2.getAttribute("type");
    return e2.map((t3) => ({ element: t3, score: this.calculateSimilarityScore({ label: r2, value: n2, tagName: i2, type: s2 }, { label: v(t3), value: x(t3), tagName: t3.tagName.toLowerCase(), type: t3.getAttribute("type") }) })).filter((t3) => t3.score > 0.3).sort((t3, e3) => e3.score - t3.score).map((t3) => t3.element);
  }
  calculateSimilarityScore(t2, e2) {
    let r2 = 0;
    return t2.tagName === e2.tagName && (r2 += 0.4), t2.type && e2.type && t2.type === e2.type && (r2 += 0.3), t2.label && e2.label && (r2 += 0.2 * this.calculateTextSimilarity(t2.label, e2.label)), t2.value && e2.value && (r2 += 0.1 * this.calculateTextSimilarity(t2.value, e2.value)), Math.min(r2, 1);
  }
  calculateTextSimilarity(t2, e2) {
    if (!t2 || !e2) return 0;
    const r2 = t2.toLowerCase().trim(), n2 = e2.toLowerCase().trim();
    if (r2 === n2) return 1;
    if (r2.includes(n2) || n2.includes(r2)) return 0.8;
    const i2 = r2.split(/\s+/), s2 = n2.split(/\s+/), o2 = i2.filter((t3) => s2.includes(t3));
    return 0 === o2.length ? 0 : o2.length / Math.max(i2.length, s2.length);
  }
  isInteractable(t2) {
    return b(t2);
  }
  canApplyToInput(t2) {
    return t2 instanceof HTMLInputElement ? "file" === t2.type ? 0 : 1 : t2 instanceof HTMLTextAreaElement || a(t2) ? 1 : 0;
  }
  canApplyToSelect(t2) {
    return c(t2);
  }
  canApplyToCheckbox(t2) {
    return u(t2) && t2 instanceof HTMLInputElement && "checkbox" === t2.type || "checkbox" === t2.getAttribute("role") || "switch" === t2.getAttribute("role");
  }
  canApplyToRadio(t2) {
    return u(t2) && t2 instanceof HTMLInputElement && "radio" === t2.type || "radio" === t2.getAttribute("role");
  }
  canApply(t2, e2) {
    if (!t2 || !e2) return 0;
    const { type: r2 } = t2;
    if (!this.isInteractable(e2)) return 0;
    switch (r2) {
      case "input":
        return this.canApplyToInput(e2);
      case "select":
        return this.canApplyToSelect(e2);
      case "checkbox":
        return this.canApplyToCheckbox(e2);
      case "radio":
        return this.canApplyToRadio(e2);
      default:
        return 1;
    }
  }
  findElementsInContainer(t2, e2, r2) {
    return Array.from(t2.querySelectorAll(e2)).filter((t3) => this.isInteractable(t3) ? r2 && !r2(t3) ? 0 : 1 : 0);
  }
  getElementValidationDetails(t2) {
    return { isVisible: r(t2), isInteractable: this.isInteractable(t2), canApplyToInput: this.canApplyToInput(t2), canApplyToSelect: this.canApplyToSelect(t2), canApplyToCheckbox: this.canApplyToCheckbox(t2), canApplyToRadio: this.canApplyToRadio(t2), elementInfo: { tagName: t2.tagName.toLowerCase(), type: t2.getAttribute("type"), role: t2.getAttribute("role"), id: t2.id, className: t2.className } };
  }
}
const st = { CONTAINER: "sherpa-container", INPUT_TARGET: "sherpa-input-target", DYNAMIC_LABEL: "sherpa-dynamic-label", VISUAL_FEEDBACK_STYLES: "sherpa-visual-feedback-styles" };
class ot {
  static shouldExcludeId(t2) {
    return t2.startsWith(this.SHERPA_PREFIX) || this.SHERPA_IDS.includes(t2);
  }
  static shouldExcludeClass(t2) {
    return t2.startsWith(this.SHERPA_PREFIX) || this.SHERPA_CLASSES.includes(t2);
  }
  static filterSherpaClasses(t2) {
    return t2.filter((t3) => !this.shouldExcludeClass(t3));
  }
  static getCleanClassList(t2) {
    if (!t2.className) return [];
    const e2 = t2.classList.value.split(/\s+/).filter(Boolean);
    return this.filterSherpaClasses(e2);
  }
  static generateTextContentSelector(t2) {
    var _a2;
    const e2 = (_a2 = t2.textContent) == null ? void 0 : _a2.trim();
    if (!e2 || e2.length > 50) return null;
    const r2 = t2.tagName.toLowerCase();
    if (!["button", "a", "span", "div", "p", "h1", "h2", "h3", "h4", "h5", "h6", "li", "td", "th"].includes(r2)) return null;
    const n2 = t2.parentElement;
    if (!n2) return null;
    const i2 = this.getCleanClassList(n2);
    let s2 = n2.tagName.toLowerCase();
    i2.length > 0 && (s2 += "." + i2[0]);
    const o2 = ["".concat(s2, " ").concat(r2), r2];
    for (const a2 of o2) {
      const r3 = document.querySelectorAll(a2), n3 = Array.from(r3).filter((t3) => {
        var _a3;
        return ((_a3 = t3.textContent) == null ? void 0 : _a3.trim()) === e2;
      });
      if (1 === n3.length && n3[0] === t2) return a2;
    }
    return null;
  }
  static generateAdvancedTextBasedSelector(t2) {
    var _a2;
    const e2 = (_a2 = t2.textContent) == null ? void 0 : _a2.trim();
    if (!e2) return null;
    const r2 = t2.tagName.toLowerCase(), n2 = this.generateTextBasedSelector(t2);
    if (n2) return n2;
    const i2 = t2.parentElement;
    if (!i2) return null;
    const s2 = i2.tagName.toLowerCase(), o2 = this.getCleanClassList(i2);
    let a2 = s2;
    o2.length > 0 && (a2 += "." + CSS.escape(o2[0]));
    const c2 = Array.from(i2.children).indexOf(t2) + 1, l2 = ["".concat(a2, " > ").concat(r2, ":nth-child(").concat(c2, ")"), "".concat(a2, " ").concat(r2, ":nth-child(").concat(c2, ")")];
    for (const d2 of l2) try {
      const e3 = document.querySelectorAll(d2);
      if (1 === e3.length && e3[0] === t2) return d2;
    } catch (u2) {
      continue;
    }
    return null;
  }
  static generateElementSelector(t2) {
    const e2 = this.generatePrimarySelector(t2), r2 = /* @__PURE__ */ new Set([e2]);
    let n2 = this.generateAdvancedTextBasedSelector(t2) || void 0;
    n2 && !r2.has(n2) || (n2 = this.generateFallbackSelectors(t2));
    const i2 = n2 && !r2.has(n2) ? n2 : void 0;
    i2 && r2.add(i2);
    const s2 = this.generateEnhancedXPath(t2).trim(), o2 = s2 && !r2.has(s2) ? s2 : void 0;
    o2 && r2.add(o2);
    const a2 = this.generateAlternativeSelectors(t2, e2).find((t3) => !r2.has(t3));
    return a2 && r2.add(a2), { primary: e2, fallback: { css: i2, xpath: o2, query: a2 } };
  }
  static generateEnhancedXPath(t2) {
    var _a2, _b2, _c2;
    if (t2.id && !this.shouldExcludeId(t2.id)) return '//*[@id="'.concat(t2.id, '"]');
    const e2 = (_a2 = t2.textContent) == null ? void 0 : _a2.trim(), r2 = t2.tagName.toLowerCase();
    if (e2 && e2.length > 0 && 50 >= e2.length) {
      const n3 = document.querySelectorAll(r2), i2 = Array.from(n3).filter((t3) => {
        var _a3;
        return ((_a3 = t3.textContent) == null ? void 0 : _a3.trim()) === e2;
      });
      if (1 === i2.length && i2[0] === t2) {
        const t3 = e2.replace(/'/g, "&apos;").replace(/"/g, "&quot;");
        return "//".concat(r2, '[normalize-space(text())="').concat(t3, '"]');
      }
      const s2 = Array.from(n3).filter((t3) => {
        var _a3;
        const r3 = (_a3 = t3.textContent) == null ? void 0 : _a3.trim();
        return r3 && r3.includes(e2);
      });
      if (1 === s2.length && s2[0] === t2) {
        const t3 = e2.replace(/'/g, "&apos;").replace(/"/g, "&quot;");
        return "//".concat(r2, '[contains(normalize-space(.), "').concat(t3, '")]');
      }
    }
    const n2 = Array.from(t2.children).find((t3) => {
      var _a3;
      const e3 = (_a3 = t3.textContent) == null ? void 0 : _a3.trim();
      return e3 && e3.length > 0 && 30 >= e3.length;
    });
    if (n2) {
      const e3 = (_b2 = n2.textContent) == null ? void 0 : _b2.trim(), i2 = n2.tagName.toLowerCase();
      if (e3 && 1 === Array.from(((_c2 = t2.parentElement) == null ? void 0 : _c2.children) || []).filter((t3) => {
        var _a3;
        if (t3.tagName.toLowerCase() !== r2) return 0;
        const n3 = Array.from(t3.children).find((t4) => t4.tagName.toLowerCase() === i2);
        return ((_a3 = n3 == null ? void 0 : n3.textContent) == null ? void 0 : _a3.trim()) === e3;
      }).length) {
        const t3 = e3.replace(/'/g, "&apos;").replace(/"/g, "&quot;");
        return "//".concat(r2, "[").concat(i2, '[normalize-space(text())="').concat(t3, '"]]');
      }
    }
    return this.generateXPath(t2);
  }
  static generateFallbackSelectors(t2) {
    var _a2, _b2;
    const e2 = this.generatePrimarySelector(t2);
    let r2 = null;
    return e2.startsWith("#"), r2 = (_b2 = (_a2 = this.findUniqueClassSelector(t2)) != null ? _a2 : this.findUniqueDataSelector(t2)) != null ? _b2 : this.generateAdvancedTextBasedSelector(t2), r2 = r2 != null ? r2 : this.generateNthChildSelector(t2), r2 && r2 !== e2 ? r2 : void 0;
  }
  static generatePrimarySelector(t2) {
    var _a2;
    if (t2.id && !this.shouldExcludeId(t2.id)) {
      const e3 = "#" + CSS.escape(t2.id);
      if (1 === document.querySelectorAll(e3).length) return e3;
    }
    const e2 = this.findUniqueDataSelector(t2);
    if (e2) return e2;
    const r2 = this.generateUniqueAttributeSelector(t2);
    if (r2) return r2;
    const n2 = (_a2 = t2.textContent) == null ? void 0 : _a2.trim();
    if (n2 && n2.length > 0 && 50 >= n2.length) {
      const e3 = t2.tagName.toLowerCase();
      if (["button", "a", "span", "div", "p", "h1", "h2", "h3", "h4", "h5", "h6", "li", "td", "th"].includes(e3)) {
        const r3 = t2.parentElement;
        if (r3) {
          const i3 = Array.from(r3.children).filter((t3) => t3.tagName.toLowerCase() === e3);
          if (i3.length > 1 && i3.filter((t3) => {
            var _a3;
            const e4 = (_a3 = t3.textContent) == null ? void 0 : _a3.trim();
            return e4 !== n2 && e4 && e4.length > 0;
          }).length > 0) {
            const e4 = this.generateAdvancedTextBasedSelector(t2);
            if (e4) return e4;
          }
        }
      }
    }
    const i2 = this.generateAdvancedTextBasedSelector(t2);
    if (i2) return i2;
    const s2 = this.generateStructuralSelector(t2);
    try {
      document.querySelectorAll(s2);
    } catch (o2) {
      return void 0, t2.tagName.toLowerCase();
    }
    return s2;
  }
  static generateUniqueAttributeSelector(t2) {
    const e2 = t2.tagName.toLowerCase(), r2 = ["href", "src", "action", "name", "for", "aria-describedby", "aria-labelledby", "aria-controls"];
    for (const i2 of r2) {
      const r3 = t2.getAttribute(i2);
      if (r3) {
        const t3 = "".concat(e2, "[").concat(i2, '="').concat(CSS.escape(r3), '"]');
        if (1 === document.querySelectorAll(t3).length) return t3;
      }
    }
    const n2 = Array.from(t2.attributes).filter((t3) => !t3.name.startsWith("aria-") || ["aria-label", "aria-describedby", "aria-labelledby", "aria-controls"].includes(t3.name)).filter((t3) => !t3.name.startsWith("data-") && "class" !== t3.name && "id" !== t3.name).slice(0, 3);
    if (n2.length >= 2) {
      const t3 = "".concat(e2).concat(n2.map((t4) => "[".concat(t4.name, '="').concat(CSS.escape(t4.value), '"]')).join(""));
      if (1 === document.querySelectorAll(t3).length) return t3;
    }
    return null;
  }
  static generateDSLQuery(t2) {
    var _a2;
    const e2 = (_a2 = t2.textContent) == null ? void 0 : _a2.trim(), r2 = t2.tagName.toLowerCase(), n2 = [], i2 = ["button", "a", "input", "select", "textarea", "span", "div", "p", "h1", "h2", "h3", "h4", "h5", "h6", "li", "td", "th"];
    if (i2.includes(r2) && n2.push("tag:" + r2), e2 && e2.length > 0 && 100 >= e2.length) {
      const t3 = e2.replace(/\s+/g, " ").trim();
      if (t3.length > 50) {
        const e3 = t3.split(/\s+/).filter((t4) => t4.length >= 4);
        if (e3.length > 0) {
          const t4 = e3.find((t5) => 5 >= Array.from(document.querySelectorAll("*")).filter((e4) => {
            var _a3;
            return (_a3 = e4.textContent) == null ? void 0 : _a3.trim().includes(t5);
          }).length) || e3[0];
          t4 && n2.push('contains:"'.concat(t4.replace(/"/g, '\\"'), '"'));
        }
      } else if (Array.from(document.querySelectorAll("*")).filter((e3) => {
        var _a3;
        const r3 = (_a3 = e3.textContent) == null ? void 0 : _a3.trim().replace(/\s+/g, " ");
        return r3 === t3;
      }).length > 3) {
        const e3 = t3.split(/\s+/).filter((t4) => t4.length >= 3);
        if (e3.length > 0) {
          const t4 = e3.find((t5) => 5 >= Array.from(document.querySelectorAll("*")).filter((e4) => {
            var _a3;
            return (_a3 = e4.textContent) == null ? void 0 : _a3.trim().includes(t5);
          }).length) || e3[0];
          t4 && n2.push('contains:"'.concat(t4.replace(/"/g, '\\"'), '"'));
        }
      } else n2.push('text:"'.concat(t3.replace(/"/g, '\\"'), '"'));
    }
    const s2 = this.getCleanClassList(t2);
    s2.length > 0 && n2.push("class:" + s2[0]);
    const o2 = ["data-testid", "data-id", "aria-label", "name", "id", "href", "src", "alt"];
    for (const c2 of o2) {
      const e3 = t2.getAttribute(c2);
      if (e3 && !this.shouldExcludeId(e3) && 100 > e3.length) {
        n2.push("attr:".concat(c2, '="').concat(e3, '"'));
        break;
      }
    }
    const a2 = t2.parentElement;
    if (a2 && 1 === n2.length) {
      const t3 = this.getCleanClassList(a2);
      if (t3.length > 0) n2.push("parent:." + t3[0]);
      else {
        const t4 = a2.tagName.toLowerCase();
        i2.includes(t4) && n2.push("parent:" + t4);
      }
    }
    return ["button", "a", "input", "select", "textarea"].includes(r2) && (n2.push("visible"), n2.push("enabled")), 1 > n2.length ? null : n2.join(" and ");
  }
  static generateAlternativeSelectors(t2, e2) {
    const r2 = [], n2 = this.generateDSLQuery(t2);
    n2 && n2 !== e2 && r2.push(n2);
    const i2 = [this.findUniqueClassSelector(t2), this.generateUniqueAttributeSelector(t2), this.findUniqueDataSelector(t2), this.generateAdvancedTextBasedSelector(t2), this.generateNthChildSelector(t2), this.generateTextContentSelector(t2)].filter((t3) => null != t3 && t3 !== e2);
    return r2.push(...i2), Array.from(new Set(r2));
  }
  static findUniqueClassSelector(t2) {
    const e2 = this.getCleanClassList(t2);
    if (0 === e2.length) return null;
    const r2 = t2.tagName.toLowerCase();
    for (const n2 of e2) {
      const t3 = "".concat(r2, ".").concat(CSS.escape(n2));
      if (1 === document.querySelectorAll(t3).length) return t3;
    }
    if (e2.length > 1) {
      const t3 = "".concat(r2).concat(e2.map((t4) => "." + CSS.escape(t4)).join(""));
      if (1 === document.querySelectorAll(t3).length) return t3;
      for (let n2 = 2; Math.min(e2.length, 3) >= n2; n2++) for (let t4 = 0; e2.length - n2 >= t4; t4++) {
        const i2 = "".concat(r2).concat(e2.slice(t4, t4 + n2).map((t5) => "." + CSS.escape(t5)).join(""));
        if (1 === document.querySelectorAll(i2).length) return i2;
      }
    }
    return null;
  }
  static findUniqueDataSelector(t2) {
    const e2 = Array.from(t2.attributes).filter((t3) => t3.name.startsWith("data-")).map((t3) => ({ name: t3.name, value: t3.value }));
    if (0 === e2.length) return null;
    const r2 = t2.tagName.toLowerCase();
    for (const n2 of e2) {
      const t3 = "".concat(r2, "[").concat(n2.name, '="').concat(CSS.escape(n2.value), '"]');
      if (1 === document.querySelectorAll(t3).length) return t3;
    }
    return null;
  }
  static generateTextBasedSelector(t2) {
    var _a2;
    const e2 = (_a2 = t2.textContent) == null ? void 0 : _a2.trim();
    if (!e2) return null;
    const r2 = t2.tagName.toLowerCase();
    if (t2 instanceof HTMLInputElement) {
      if (t2.placeholder) {
        const e3 = "".concat(r2, '[placeholder="').concat(CSS.escape(t2.placeholder), '"]');
        if (1 === document.querySelectorAll(e3).length) return e3;
      }
      if (t2.name) {
        const e3 = "".concat(r2, '[name="').concat(CSS.escape(t2.name), '"]');
        if (1 === document.querySelectorAll(e3).length) return e3;
      }
    }
    const n2 = t2.getAttribute("aria-label");
    if (n2) {
      const t3 = "".concat(r2, '[aria-label="').concat(CSS.escape(n2), '"]');
      if (1 === document.querySelectorAll(t3).length) return t3;
    }
    const i2 = t2.getAttribute("title");
    if (i2) {
      const t3 = "".concat(r2, '[title="').concat(CSS.escape(i2), '"]');
      if (1 === document.querySelectorAll(t3).length) return t3;
    }
    if ("button" === r2 || "input" === r2 && "button" === t2.getAttribute("type")) {
      const e3 = t2.getAttribute("value");
      if (e3) {
        const t3 = "".concat(r2, '[value="').concat(CSS.escape(e3), '"]');
        if (1 === document.querySelectorAll(t3).length) return t3;
      }
    }
    return null;
  }
  static generateNthChildSelector(t2) {
    const e2 = t2.parentElement;
    if (!e2) return t2.tagName.toLowerCase();
    const r2 = Array.from(e2.children).indexOf(t2) + 1, n2 = t2.tagName.toLowerCase();
    return "".concat(e2.tagName.toLowerCase(), " > ").concat(n2, ":nth-child(").concat(r2, ")");
  }
  static generateXPath(t2) {
    if (t2.id && !this.shouldExcludeId(t2.id)) return '//*[@id="'.concat(t2.id, '"]');
    const e2 = [];
    let r2 = t2;
    for (; r2 && r2 !== document.documentElement; ) {
      const t3 = r2.tagName.toLowerCase(), n2 = r2.parentElement;
      if (n2) {
        const i2 = Array.from(n2.children).filter((e3) => e3.tagName.toLowerCase() === t3);
        if (1 === i2.length) e2.unshift(t3);
        else {
          const n3 = i2.indexOf(r2) + 1;
          e2.unshift("".concat(t3, "[").concat(n3, "]"));
        }
      } else e2.unshift(t3);
      r2 = n2;
    }
    return "/" + e2.join("/");
  }
  static generateStructuralSelector(t2) {
    const e2 = [];
    let r2 = t2;
    for (; r2 && r2 !== document.documentElement; ) {
      const t3 = r2.tagName.toLowerCase(), n2 = r2.parentElement;
      if (n2) {
        const i2 = Array.from(n2.children).filter((e3) => e3.tagName.toLowerCase() === t3);
        if (1 === i2.length) e2.unshift(t3);
        else {
          const n3 = i2.indexOf(r2) + 1;
          e2.unshift("".concat(t3, ":nth-of-type(").concat(n3, ")"));
        }
      } else e2.unshift(t3);
      if (r2 = n2, e2.length >= 5) break;
    }
    return e2.join(" > ");
  }
}
__publicField(ot, "SHERPA_CLASSES", Object.values(st));
__publicField(ot, "SHERPA_IDS", [st.VISUAL_FEEDBACK_STYLES]);
__publicField(ot, "SHERPA_PREFIX", "sherpa-");
class at {
  extractElementInfo(r2) {
    if (!r2) throw Error("No element provided for analysis");
    const i2 = r2.getBoundingClientRect(), s2 = r2.tagName.toLowerCase(), o2 = t(r2), a2 = e(r2), c2 = ot.generateElementSelector(r2), l2 = n(r2), u2 = {}, d2 = {};
    Object.keys(l2).forEach((t2) => {
      t2.startsWith("aria-") && (u2[t2] = l2[t2]);
    }), r2 instanceof HTMLElement && Object.keys(r2.dataset).forEach((t2) => {
      d2[t2] = r2.dataset[t2] || "";
    });
    const h2 = (t2) => t2.replace(/\n/g, "").replace(/\s+/g, " ");
    return { tagName: s2, type: r2.getAttribute("type") || void 0, id: r2.id || void 0, name: r2.getAttribute("name") || void 0, placeholder: r2.getAttribute("placeholder") || void 0, value: o2, textContent: a2, innerHTML: h2(r2.innerHTML), outerHTML: h2(r2.outerHTML), attributes: l2, aria: u2, dataset: d2, classList: Array.from(r2.classList), boundingRect: { x: i2.x, y: i2.y, width: i2.width, height: i2.height }, selector: c2 };
  }
  findInteractiveChildren(t2) {
    if (!t2) return [];
    const e2 = [], r2 = document.createTreeWalker(t2, NodeFilter.SHOW_ELEMENT, { acceptNode: (t3) => i(t3) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP });
    let n2;
    for (; n2 = r2.nextNode(); ) e2.push(n2);
    return e2;
  }
  getElementHierarchy(t2, e2 = 5) {
    const r2 = [];
    let n2 = t2, i2 = 0;
    for (; n2 && e2 > i2; ) try {
      r2.push(this.extractElementInfo(n2)), n2 = n2.parentElement, i2++;
    } catch (s2) {
      break;
    }
    return r2;
  }
  findNearestInteractiveAncestor(t2, e2 = 5) {
    let r2 = t2.parentElement, n2 = 0;
    for (; r2 && e2 > n2; ) {
      if (i(r2)) return r2;
      if (r2.parentElement) r2 = r2.parentElement;
      else if (r2.getRootNode() instanceof ShadowRoot) {
        const t3 = r2.getRootNode();
        r2 = t3.host;
      } else r2 = null;
      n2++;
    }
    return null;
  }
  hasDescriptiveText(t2) {
    var _a2;
    if (!t2) return 0;
    const e2 = t2.querySelectorAll("label");
    if (e2.length > 0) return Array.from(e2).some((t3) => t3.textContent && t3.textContent.trim().length > 0);
    const r2 = ["[data-label]", "[data-description]", ".label", ".description", ".field-label", ".input-label", ".form-label", ".help-text", ".hint", ".placeholder"];
    for (const i2 of r2) {
      const e3 = t2.querySelectorAll(i2);
      if (e3.length > 0) return Array.from(e3).some((t3) => t3.textContent && t3.textContent.trim().length > 0);
    }
    const n2 = ((_a2 = t2.textContent) == null ? void 0 : _a2.trim()) || "";
    return n2.length > 2 && !n2.match(/^\s*$/);
  }
  getElementPosition(t2) {
    try {
      const e2 = document.createTreeWalker(document.body, NodeFilter.SHOW_ELEMENT, null);
      let r2, n2 = 0;
      for (; r2 = e2.nextNode(); ) {
        if (r2 === t2) return n2;
        n2++;
      }
      return n2;
    } catch (e2) {
      return 0;
    }
  }
  isLabeledFormField(t2) {
    var _a2, _b2;
    if (!t2 || !(t2 instanceof HTMLInputElement || t2 instanceof HTMLTextAreaElement || t2 instanceof HTMLSelectElement)) return 0;
    if (t2.id) {
      const e3 = document.querySelector('label[for="'.concat(t2.id, '"]'));
      if (e3 && ((_a2 = e3.textContent) == null ? void 0 : _a2.trim())) return 1;
    }
    const e2 = t2.closest("label");
    return e2 && ((_b2 = e2.textContent) == null ? void 0 : _b2.trim()) ? 1 : 0;
  }
  calculateElementDistance(t2, e2) {
    try {
      const r2 = this.getElementPosition(t2), n2 = t2.getBoundingClientRect(), i2 = this.getElementPosition(e2), s2 = Math.abs(i2 - r2), o2 = e2.getBoundingClientRect();
      let a2 = 0;
      if (n2.width > 0 && n2.height > 0 && o2.width > 0 && o2.height > 0) {
        const t3 = o2.left + o2.width / 2 - (n2.left + n2.width / 2), e3 = o2.top + o2.height / 2 - (n2.top + n2.height / 2);
        a2 = Math.sqrt(t3 * t3 + e3 * e3);
      }
      const c2 = s2 / 100;
      return 0 === a2 ? c2 : 0.3 * c2 + 0.7 * a2;
    } catch (r2) {
      const n2 = this.getElementPosition(t2), i2 = this.getElementPosition(e2);
      return Math.abs(i2 - n2);
    }
  }
  findSimilarElements(t2, e2) {
    const r2 = this.extractElementInfo(t2);
    return e2.map((t3) => ({ element: t3, score: this.calculateSimilarityScore(r2, this.extractElementInfo(t3)) })).filter((t3) => t3.score > 0.5).sort((t3, e3) => e3.score - t3.score).map((t3) => t3.element);
  }
  calculateSimilarityScore(t2, e2) {
    let r2 = 0;
    t2.tagName === e2.tagName && (r2 += 0.3), t2.type && e2.type && t2.type === e2.type && (r2 += 0.2);
    const n2 = t2.classList.filter((t3) => e2.classList.includes(t3));
    n2.length > 0 && (r2 += n2.length / Math.max(t2.classList.length, e2.classList.length) * 0.2);
    const i2 = Object.keys(t2.attributes).filter((r3) => e2.attributes[r3] === t2.attributes[r3]);
    i2.length > 0 && (r2 += i2.length / Math.max(Object.keys(t2.attributes).length, Object.keys(e2.attributes).length) * 0.15);
    const s2 = Object.keys(t2.aria).filter((r3) => e2.aria[r3] === t2.aria[r3]);
    return s2.length > 0 && (r2 += s2.length / Math.max(Object.keys(t2.aria).length, Object.keys(e2.aria).length) * 0.15), Math.min(r2, 1);
  }
}
const ct = ['[role="dialog"]', '[role="listbox"]', '[role="menu"]', "[data-radix-select-content]", "[data-radix-dropdown-menu-content]", "[data-radix-popover-content]", ".dropdown-menu", ".select-dropdown", ".popup-content"], lt = ['[role="option"]', '[role="menuitem"]', "[data-value]", "[data-radix-select-item]", "[data-radix-collection-item]", ".select-option", ".dropdown-option", ".menu-item"];
class ut {
  constructor() {
    __publicField(this, "domAnalyzer");
    this.domAnalyzer = new at();
  }
  findRecommendedElements(t2) {
    try {
      const r2 = k(t2), n2 = [];
      if ("select" === r2) {
        const e2 = S(t2);
        return e2.length > 0 ? e2 : [t2];
      }
      try {
        const e2 = this.findNestedRecommendationTargets(t2);
        n2.push(...e2);
      } catch (e2) {
      }
      try {
        g(t2) && n2.push(t2);
      } catch (e2) {
      }
      return this.deduplicateAndValidate(n2);
    } catch (e2) {
      return void 0, [];
    }
  }
  findNestedRecommendationTargets(t2) {
    const e2 = [];
    if (g(t2)) {
      if (c(t2) || E(t2)) {
        const e3 = S(t2);
        if (e3.length > 0) return e3.filter((t3) => b(t3));
      }
      return [t2];
    }
    const r2 = this.domAnalyzer.findInteractiveChildren(t2).filter(g), n2 = this.groupElementsByRole(r2), i2 = Object.keys(n2).filter((t3) => n2[t3].length > 0 && "none" !== t3);
    if (1 === i2.length) {
      const t3 = i2[0], r3 = n2[t3];
      if ("select" === t3) {
        const t4 = [];
        r3.forEach((e3) => {
          const r4 = S(e3);
          t4.push(...r4.filter((t5) => b(t5)));
        }), t4.length > 0 ? e2.push(...t4) : e2.push(...r3);
      } else r3.length > 1 ? this.shouldIncludeMultipleElements(t3) ? e2.push(...r3) : e2.push(r3[0]) : e2.push(...r3);
    }
    return this.handleDropdownContainers(t2, e2), e2;
  }
  groupElementsByRole(t2) {
    const e2 = { checkbox: [], radio: [], select: [], textarea: [], input: [], none: [] };
    return t2.forEach((t3) => {
      const r2 = k(t3);
      e2[r2].push(t3);
    }), e2;
  }
  shouldIncludeMultipleElements(t2) {
    return "checkbox" === t2 || "radio" === t2 || "select" === t2;
  }
  handleDropdownContainers(t2, e2) {
    t2.querySelectorAll(ct.join(", ")).forEach((t3) => {
      t3.querySelectorAll(lt.join(", ")).forEach((t4) => {
        b(t4) && m(t4) && e2.push(t4);
      });
    });
  }
  deduplicateAndValidate(t2) {
    return Array.from(new Set(t2.reverse())).filter(g);
  }
  findSimilarElements(t2, e2) {
    const r2 = e2 || document.body, n2 = this.domAnalyzer.findInteractiveChildren(r2);
    return this.domAnalyzer.findSimilarElements(t2, n2).filter(g);
  }
  getRecommendationStats(t2) {
    const e2 = this.domAnalyzer.findInteractiveChildren(t2), r2 = e2.filter(g), n2 = {};
    return r2.forEach((t3) => {
      const e3 = y(t3);
      n2[e3] = (n2[e3] || 0) + 1;
    }), { totalInteractive: e2.length, totalRecommendationTargets: r2.length, byType: n2 };
  }
}
class dt {
  constructor(t2) {
    __publicField(this, "eventTrigger");
    this.eventTrigger = t2;
  }
  apply(t2, e2) {
    const r2 = Array.isArray(e2) ? e2[0] || "" : e2;
    return t2 instanceof HTMLInputElement || t2 instanceof HTMLTextAreaElement ? t2 instanceof HTMLInputElement ? "file" === t2.type ? 0 : this.applyInputValue(t2, r2) : t2 instanceof HTMLTextAreaElement ? this.applyTextAreaValue(t2, r2) : 0 : 0;
  }
  canApply(t2) {
    return t2 instanceof HTMLInputElement ? "file" === t2.type || t2.disabled || t2.readOnly ? 0 : 1 : t2 instanceof HTMLTextAreaElement ? t2.disabled || t2.readOnly ? 0 : 1 : t2.hasAttribute("contenteditable") || "textbox" === t2.getAttribute("role");
  }
  applyInputValue(t2, e2) {
    if (t2.disabled || t2.readOnly) return 0;
    switch (t2.type) {
      case "text":
      case "email":
      case "password":
      case "search":
      case "tel":
      case "url":
        return this.applyTextInputValue(t2, e2);
      case "number":
        return this.applyNumberInputValue(t2, e2);
      case "date":
      case "datetime-local":
      case "time":
      case "month":
      case "week":
        return this.applyDateTimeInputValue(t2, e2);
      case "range":
        return this.applyRangeInputValue(t2, e2);
      case "color":
        return this.applyColorInputValue(t2, e2);
      case "hidden":
        return this.applyHiddenInputValue(t2, e2);
      default:
        return this.applyGenericInputValue(t2, e2);
    }
  }
  applyTextInputValue(t2, e2) {
    let r2 = e2;
    if (t2.maxLength > 0 && e2.length > t2.maxLength && (r2 = e2.substring(0, t2.maxLength)), t2.pattern) try {
      !RegExp(t2.pattern).test(r2);
    } catch (n2) {
    }
    return t2.value = r2, this.eventTrigger.triggerChangeEvents(t2), 1;
  }
  applyNumberInputValue(t2, e2) {
    const r2 = parseFloat(e2);
    if (isNaN(r2)) return 0;
    let n2 = r2;
    if (t2.min && parseFloat(t2.min) > r2 && (n2 = parseFloat(t2.min)), t2.max && r2 > parseFloat(t2.max) && (n2 = parseFloat(t2.max)), t2.step && "any" !== t2.step) {
      const e3 = parseFloat(t2.step);
      if (e3 > 0) {
        const r3 = parseFloat(t2.min) || 0, i2 = Math.round((n2 - r3) / e3) * e3 + r3;
        Math.abs(i2 - n2) > 1e-4 && (n2 = parseFloat(i2.toFixed(10)));
      }
    }
    return t2.value = "" + n2, this.eventTrigger.triggerChangeEvents(t2), 1;
  }
  applyDateTimeInputValue(t2, e2) {
    if ("week" === t2.type) return /^\d{4}-W\d{2}$/.test(e2) ? (t2.value = e2, this.eventTrigger.triggerChangeEvents(t2), 1) : 0;
    if ("time" === t2.type) {
      if (e2.includes("T")) t2.value = e2.split("T")[1].slice(0, 5);
      else if (e2.match(/^\d{1,2}:\d{2}$/)) t2.value = e2;
      else try {
        const r3 = new Date(e2);
        if (isNaN(r3.getTime())) return 0;
        t2.value = r3.toTimeString().slice(0, 5);
      } catch (e3) {
        return 0;
      }
      return this.eventTrigger.triggerChangeEvents(t2), 1;
    }
    let r2 = e2;
    try {
      const n2 = new Date(e2);
      if (isNaN(n2.getTime())) return 0;
      if ("date" === t2.type && e2.match(/^\d{4}-\d{2}-\d{2}$/)) {
        const [t3, r3, i2] = e2.split("-").map(Number);
        if (n2.getFullYear() !== t3 || n2.getMonth() + 1 !== r3 || n2.getDate() !== i2) return 0;
      }
      switch (t2.type) {
        case "date":
          r2 = n2.toISOString().split("T")[0];
          break;
        case "datetime-local":
          r2 = !e2.includes("T") || e2.includes("Z") || e2.includes("+") || e2.includes("-", 10) ? e2.endsWith("Z") ? e2.slice(0, 16) : new Date(n2.getTime() - 6e4 * n2.getTimezoneOffset()).toISOString().slice(0, 16) : e2.slice(0, 16);
          break;
        case "month":
          r2 = n2.toISOString().slice(0, 7);
      }
      return t2.value = r2, this.eventTrigger.triggerChangeEvents(t2), 1;
    } catch (n2) {
      return void 0, 0;
    }
  }
  applyRangeInputValue(t2, e2) {
    const r2 = parseFloat(e2);
    return isNaN(r2) ? 0 : (t2.value = "" + Math.max(parseFloat(t2.min) || 0, Math.min(parseFloat(t2.max) || 100, r2)), this.eventTrigger.triggerChangeEvents(t2), 1);
  }
  applyColorInputValue(t2, e2) {
    let r2 = e2.toLowerCase().trim();
    if (r2.startsWith("#") || (r2 = "#" + r2), !r2.match(/^#[0-9a-f]{6}$/)) {
      if (!r2.match(/^#[0-9a-f]{3}$/)) return 0;
      r2 = "#" + r2[1] + r2[1] + r2[2] + r2[2] + r2[3] + r2[3];
    }
    return t2.value = r2, this.eventTrigger.triggerChangeEvents(t2), 1;
  }
  applyHiddenInputValue(t2, e2) {
    return t2.value = e2, this.eventTrigger.triggerChangeEvents(t2), 1;
  }
  applyGenericInputValue(t2, e2) {
    return t2.value = e2, this.eventTrigger.triggerChangeEvents(t2), 1;
  }
  applyTextAreaValue(t2, e2) {
    if (t2.disabled || t2.readOnly) return 0;
    let r2 = e2;
    return t2.maxLength > 0 && e2.length > t2.maxLength && (r2 = e2.substring(0, t2.maxLength)), t2.value = r2, this.eventTrigger.triggerChangeEvents(t2), 1;
  }
}
class ht {
  constructor(t2) {
    __publicField(this, "eventTrigger");
    this.eventTrigger = t2;
  }
  apply(t2, e2, r2) {
    const n2 = Array.isArray(e2) ? e2[0] || "" : e2;
    return t2 instanceof HTMLSelectElement || this.canApply(t2) ? t2 instanceof HTMLSelectElement ? t2.disabled ? 0 : "combobox" === t2.getAttribute("role") || t2.hasAttribute("aria-autocomplete") ? this.applyComboboxValue(t2, n2, r2) : t2.multiple ? this.applyMultiSelectValue(t2, n2, r2) : this.applySingleSelectValue(t2, n2) : this.applySingleSelectValue(t2, n2) : 0;
  }
  canApply(t2) {
    return c(t2) || E(t2);
  }
  applySingleSelectValue(t2, e2) {
    const r2 = e2.toLowerCase().trim(), n2 = S(t2);
    if (0 === n2.length) return 0;
    for (let i2 = 0; n2.length > i2; i2++) {
      const r3 = n2[i2];
      if ((r3 instanceof HTMLOptionElement ? r3.value : r3.getAttribute("value") || "") === e2) return this.selectOption(t2, r3, i2), 1;
    }
    for (let i2 = 0; n2.length > i2; i2++) {
      const r3 = n2[i2];
      if ((r3.textContent || r3.getAttribute("textContent") || "").trim() === e2) return this.selectOption(t2, r3, i2), 1;
    }
    for (let i2 = 0; n2.length > i2; i2++) {
      const e3 = n2[i2], s2 = (e3.textContent || e3.getAttribute("textContent") || "").trim().toLowerCase(), o2 = (e3 instanceof HTMLOptionElement ? e3.value : e3.getAttribute("value") || "").toLowerCase();
      if (s2 === r2 || o2 === r2) return this.selectOption(t2, e3, i2), 1;
    }
    for (let i2 = 0; n2.length > i2; i2++) {
      const r3 = n2[i2], s2 = (r3.textContent || r3.getAttribute("textContent") || "").trim(), o2 = r3 instanceof HTMLOptionElement ? r3.value : r3.getAttribute("value") || "", a2 = document.createElement("div");
      a2.innerHTML = e2;
      const c2 = a2.textContent || a2.innerText || "";
      if (s2.toLowerCase() === c2.toLowerCase() || o2.toLowerCase() === c2.toLowerCase()) return this.selectOption(t2, r3, i2), 1;
      if (a2.innerHTML = o2, (a2.textContent || a2.innerText || "").toLowerCase() === e2.toLowerCase()) return this.selectOption(t2, r3, i2), 1;
      const l2 = document.createElement("div");
      if (l2.textContent = e2, o2 === l2.innerHTML) return this.selectOption(t2, r3, i2), 1;
    }
    for (let i2 = 0; n2.length > i2; i2++) {
      const e3 = n2[i2], s2 = (e3.textContent || e3.getAttribute("textContent") || "").trim().toLowerCase(), o2 = (e3 instanceof HTMLOptionElement ? e3.value : e3.getAttribute("value") || "").toLowerCase();
      if (s2.includes(r2) || o2.includes(r2) || r2.includes(s2)) return this.selectOption(t2, e3, i2), 1;
    }
    return 0;
  }
  selectOption(t2, e2, r2) {
    if (t2 instanceof HTMLSelectElement && e2 instanceof HTMLOptionElement) {
      t2.selectedIndex = r2;
      const n2 = e2.getAttribute("value");
      n2 && n2.includes("&") && (t2.value = n2);
    } else {
      e2.dispatchEvent(new MouseEvent("click", { bubbles: 1 }));
      const r3 = e2.getAttribute("value") || e2.textContent || "";
      t2.setAttribute("value", r3), e2.setAttribute("selected", "true");
      const n2 = t2.querySelectorAll('mat-option, [role="option"], option');
      for (const t3 of Array.from(n2)) t3 !== e2 && t3.removeAttribute("selected");
    }
    this.eventTrigger.triggerChangeEvents(t2);
  }
  applyMultiSelectValue(t2, e2, r2) {
    const n2 = r2 || e2.split(",").map((t3) => t3.trim());
    let i2 = 0;
    for (let s2 = 0; t2.options.length > s2; s2++) t2.options[s2].selected = 0;
    for (const s2 of n2) for (let e3 = 0; t2.options.length > e3; e3++) {
      const r3 = t2.options[e3], n3 = (r3.textContent || r3.innerText || "").trim();
      if (r3.value === s2 || n3 === s2 || r3.value.toLowerCase() === s2.toLowerCase() || n3.toLowerCase() === s2.toLowerCase()) {
        r3.selected = 1, i2++;
        break;
      }
    }
    return i2 > 0 ? (this.eventTrigger.triggerChangeEvents(t2), 1) : 0;
  }
  applyComboboxValue(t2, e2, r2) {
    const n2 = this.findComboboxInput(t2);
    return n2 && n2 instanceof HTMLInputElement ? (n2.value = "", n2.focus(), this.typeValueGradually(n2, e2), setTimeout(() => {
      this.selectComboboxOption(t2, e2, r2);
    }, 200), 1) : this.applySingleSelectValue(t2, e2);
  }
  findComboboxInput(t2) {
    var _a2;
    const e2 = t2.querySelector("input");
    if (e2 instanceof HTMLInputElement) return e2;
    const r2 = (_a2 = t2.parentElement) == null ? void 0 : _a2.querySelector("input");
    if (r2 instanceof HTMLInputElement) return r2;
    if (t2.id) {
      const e3 = document.querySelector('input[aria-controls="'.concat(t2.id, '"]'));
      if (e3 instanceof HTMLInputElement) return e3;
    }
    const n2 = t2.closest(".select-wrapper, .combobox-wrapper, .dropdown-wrapper");
    if (n2) {
      const t3 = n2.querySelector("input");
      if (t3 instanceof HTMLInputElement) return t3;
    }
    return null;
  }
  typeValueGradually(t2, e2) {
    t2.value = "", this.eventTrigger.triggerChangeEvents(t2);
    for (let r2 = 0; e2.length >= r2; r2++) setTimeout(() => {
      t2.value = e2.substring(0, r2), this.eventTrigger.triggerChangeEvents(t2);
    }, 50 * r2);
  }
  selectComboboxOption(t2, e2, r2) {
    const n2 = document.querySelectorAll('\n      [role="option"],\n      .select-option,\n      .dropdown-option,\n      .combobox-option\n    ');
    for (const i2 of Array.from(n2)) {
      const t3 = (i2.textContent || "").trim(), r3 = i2.getAttribute("data-value") || i2.getAttribute("value") || "";
      if (t3 === e2 || r3 === e2 || t3.toLowerCase() === e2.toLowerCase()) return i2.dispatchEvent(new MouseEvent("click", { bubbles: 1 })), 1;
    }
    return 0;
  }
}
class pt {
  constructor(t2) {
    __publicField(this, "eventTrigger");
    this.eventTrigger = t2;
  }
  apply(t2, e2) {
    return t2 instanceof HTMLInputElement && "checkbox" === t2.type ? t2.disabled ? 0 : e2 && 0 !== e2.length ? this.shouldUseGroupSelection(e2, t2) ? this.applyToGroup(t2, e2) : this.applyToSingle(t2, e2) : 0 : 0;
  }
  shouldUseGroupSelection(t2, e2) {
    return t2.length > 1 ? 1 : 0;
  }
  applyToGroup(t2, e2) {
    const r2 = this.getCheckboxGroup(t2);
    let n2 = 0;
    for (const i2 of Array.from(r2)) {
      const t3 = i2, r3 = t3.value;
      t3.disabled || r3 && e2.includes(r3) && this.applyToSingleCheckbox(t3, 1) && (n2 = 1);
    }
    if (!n2) {
      const r3 = this.parseBooleanValue(e2[0]);
      return this.applyToSingleCheckbox(t2, r3);
    }
    return n2;
  }
  applyToSingle(t2, e2) {
    const r2 = t2.value;
    let n2;
    return n2 = r2 && e2.includes(r2) ? 1 : this.parseBooleanValue(e2[0]), this.applyToSingleCheckbox(t2, n2);
  }
  canApply(t2) {
    return t2 instanceof HTMLInputElement && "checkbox" === t2.type ? 1 : "checkbox" === t2.getAttribute("role") || "switch" === t2.getAttribute("role");
  }
  getCheckboxGroup(t2) {
    if (t2.name) {
      const e3 = t2.closest("form");
      return e3 ? e3.querySelectorAll('input[type="checkbox"][name="'.concat(t2.name, '"]')) : document.querySelectorAll('input[type="checkbox"][name="'.concat(t2.name, '"]'));
    }
    const e2 = [t2];
    return e2.length = 1, e2.item = (e3) => 0 === e3 ? t2 : null, e2;
  }
  parseBooleanValue(t2) {
    const e2 = t2.toLowerCase().trim();
    if (["true", "checked", "1", "yes", "on", "enabled"].includes(e2)) return 1;
    if (["false", "unchecked", "0", "no", "off", "disabled"].includes(e2)) return 0;
    {
      const e3 = parseFloat(t2);
      return isNaN(e3) ? 1 : 0 !== e3;
    }
  }
  applyToSingleCheckbox(t2, e2) {
    return t2.indeterminate = 0, t2.checked = e2, t2.setAttribute("aria-checked", "" + e2), this.eventTrigger.triggerChangeEvents(t2), 1;
  }
}
class ft {
  constructor(t2) {
    __publicField(this, "eventTrigger");
    this.eventTrigger = t2;
  }
  apply(t2, e2) {
    const r2 = Array.isArray(e2) ? e2[0] || "" : e2;
    if (!(t2 instanceof HTMLInputElement) || "radio" !== t2.type) return 0;
    if (t2.disabled) return 0;
    const n2 = this.getRadioGroup(t2), i2 = r2.toLowerCase().trim();
    for (const s2 of Array.from(n2)) if (s2.value === r2) return this.selectRadio(s2), 1;
    for (const s2 of Array.from(n2)) if (s2.getAttribute("data-value") === r2) return this.selectRadio(s2), 1;
    for (const s2 of Array.from(n2)) if (this.getRadioLabel(s2) === r2) return this.selectRadio(s2), 1;
    for (const s2 of Array.from(n2)) {
      const t3 = this.getRadioLabel(s2), e3 = s2.value;
      if ((t3 == null ? void 0 : t3.toLowerCase()) === i2 || e3.toLowerCase() === i2) return this.selectRadio(s2), 1;
    }
    for (const s2 of Array.from(n2)) {
      const t3 = this.getRadioLabel(s2);
      if (t3 && t3.length > 0 && i2.length > 0) {
        const e3 = t3.toLowerCase();
        if (e3.includes(i2) || i2.includes(e3)) return this.selectRadio(s2), 1;
      }
    }
    return 0;
  }
  canApply(t2) {
    return t2 instanceof HTMLInputElement && "radio" === t2.type ? 1 : "radio" === t2.getAttribute("role");
  }
  getRadioGroup(t2) {
    if (t2.name) {
      const e3 = t2.closest("form");
      return e3 ? e3.querySelectorAll('input[type="radio"][name="'.concat(t2.name, '"]')) : document.querySelectorAll('input[type="radio"][name="'.concat(t2.name, '"]'));
    }
    const e2 = document.createDocumentFragment(), r2 = t2.cloneNode(1);
    e2.appendChild(r2);
    const n2 = [t2];
    return n2.length = 1, n2.item = (e3) => 0 === e3 ? t2 : null, n2;
  }
  selectRadio(t2) {
    const e2 = this.getRadioGroup(t2);
    for (const r2 of Array.from(e2)) {
      const t3 = r2;
      t3.checked = 0, t3.setAttribute("aria-checked", "false");
    }
    t2.checked = 1, t2.setAttribute("aria-checked", "true"), this.eventTrigger.triggerChangeEvents(t2);
  }
  getRadioLabel(t2) {
    var _a2;
    if (t2.id) {
      const e3 = document.querySelector('label[for="'.concat(t2.id, '"]'));
      if (e3) return this.extractTextContent(e3);
    }
    const e2 = t2.closest("label");
    if (e2) return this.extractTextContent(e2, t2);
    const r2 = t2.getAttribute("aria-label");
    if (r2) return r2.trim();
    const n2 = t2.getAttribute("aria-labelledby");
    if (n2) {
      const t3 = n2.trim().split(/\s+/), e3 = [];
      for (const r3 of t3) {
        const t4 = document.getElementById(r3);
        if (t4) {
          const r4 = this.extractTextContent(t4);
          r4 && e3.push(r4);
        }
      }
      if (e3.length > 0) return e3.join(" ");
    }
    const i2 = t2.nextSibling;
    if (i2 && i2.nodeType === Node.TEXT_NODE) {
      const t3 = (_a2 = i2.textContent) == null ? void 0 : _a2.trim();
      if (t3) return t3;
    }
    const s2 = t2.nextElementSibling;
    if (s2 && ("SPAN" === s2.tagName || "DIV" === s2.tagName || s2.classList.contains("radio-label"))) return this.extractTextContent(s2);
    const o2 = t2.parentElement;
    return o2 ? this.extractTextContent(o2, t2) : null;
  }
  extractTextContent(t2, e2) {
    var _a2;
    if (!t2) return null;
    const r2 = t2.cloneNode(1);
    if (e2) {
      const t3 = r2.querySelector('[type="'.concat(e2.getAttribute("type"), '"]'));
      t3 == null ? void 0 : t3.remove();
    }
    const n2 = r2.querySelectorAll("input, button, svg, img, .icon");
    for (const s2 of Array.from(n2)) s2.remove();
    const i2 = (_a2 = r2.textContent) == null ? void 0 : _a2.trim();
    return i2 && i2.length > 0 ? i2 : null;
  }
}
const mt = Object.freeze({ __proto__: null, CheckboxHandler: pt, DOMAnalyzerService: at, ElementFinderService: it, EventService: tt, InputHandler: dt, RadioHandler: ft, RecommendationApplier: class {
  constructor(t2) {
    __publicField(this, "config");
    __publicField(this, "eventService");
    __publicField(this, "elementFinder");
    __publicField(this, "domAnalyzer");
    __publicField(this, "recommendationEngine");
    __publicField(this, "inputHandler");
    __publicField(this, "selectHandler");
    __publicField(this, "checkboxHandler");
    __publicField(this, "radioHandler");
    this.config = __spreadValues({ debounceDelay: 50, maxRetryAttempts: 3, frameworkEventDelay: 10 }, t2), this.eventService = new tt(this.config), this.elementFinder = new it(), this.domAnalyzer = new at(), this.recommendationEngine = new ut(), this.inputHandler = new dt(this.eventService), this.selectHandler = new ht(this.eventService), this.checkboxHandler = new pt(this.eventService), this.radioHandler = new ft(this.eventService);
  }
  apply(t2, e2) {
    if (!t2) return 0;
    let r2 = e2;
    if (!r2) {
      const e3 = this.findTargetElement(t2);
      if (!e3) return 0;
      r2 = e3;
    }
    if (!(r2 instanceof Element)) return 0;
    const { type: n2, value: i2 } = t2;
    if (!this.canApply(t2, r2)) return 0;
    try {
      switch (n2) {
        case "input":
          return this.inputHandler.apply(r2, i2[0] || "");
        case "select":
          return this.selectHandler.apply(r2, i2[0] || "");
        case "checkbox":
          return this.checkboxHandler.apply(r2, i2);
        case "radio":
          return this.radioHandler.apply(r2, i2[0] || "");
        default:
          return 0;
      }
    } catch (s2) {
      return void 0, 0;
    }
  }
  applyBatch(t2) {
    const e2 = t2.map(({ recommendation: t3, element: e3 }) => {
      try {
        return { success: this.apply(t3, e3), recommendation: t3 };
      } catch (r2) {
        return { success: 0, recommendation: t3, error: r2 instanceof Error ? r2.message : "Unknown error" };
      }
    });
    return { success: e2.every((t3) => t3.success), results: e2 };
  }
  getAugmentedInteraction(t2) {
    try {
      let e2 = t2;
      if (!i(e2)) {
        if ("label" === e2.tagName.toLowerCase()) try {
          if (e2.htmlFor) {
            const t3 = document.getElementById(e2.htmlFor);
            t3 instanceof Element && i(t3) && (e2 = t3);
          }
        } catch (B2) {
        }
        if (!i(e2)) {
          const t3 = this.domAnalyzer.findNearestInteractiveAncestor(e2, 5);
          t3 && (e2 = t3);
        }
      }
      if (g(e2)) return this.createAugmentedInteraction(e2);
      if (i(e2)) return { selector: this.domAnalyzer.extractElementInfo(e2).selector, type: "interactive" };
      if (this.domAnalyzer.findInteractiveChildren(e2).filter((t3) => g(t3)).length > 0) return { selector: this.domAnalyzer.extractElementInfo(t2).selector, type: "none" };
      const r2 = this.findNearestSiblingRecommendationTarget(e2);
      return r2 ? this.getAugmentedInteraction(r2) : { selector: this.domAnalyzer.extractElementInfo(t2).selector, type: "none" };
    } catch (e2) {
      return void 0, { selector: this.domAnalyzer.extractElementInfo(t2).selector, type: "none" };
    }
  }
  createAugmentedInteraction(t2) {
    var _a2;
    try {
      if (!t2) throw Error("No element provided for analysis");
      const e2 = k(t2), r2 = this.findRecommendationContainer(t2, e2) || t2;
      if ("select" === e2) {
        const e3 = this.recommendationEngine.findRecommendedElements(t2);
        if (e3.length > 0) {
          const n3 = e3.map((t3) => ({ type: "multi-options", label: v(t3), value: x(t3), selected: w(t3), selector: this.domAnalyzer.extractElementInfo(t3).selector, inputType: "select" }));
          return { selector: this.domAnalyzer.extractElementInfo(r2).selector, type: "group", recommendationSelector: this.domAnalyzer.extractElementInfo(t2).selector, recommendations: n3 };
        }
        return { selector: this.domAnalyzer.extractElementInfo(t2).selector, type: "interactive" };
      }
      const n2 = this.recommendationEngine.shouldIncludeMultipleElements(e2) ? this.recommendationEngine.findRecommendedElements(r2) : [t2];
      let i2;
      return n2.length > 0 ? (i2 = n2.map((t3) => {
        const e3 = v(t3), r3 = x(t3), n3 = w(t3), i3 = this.domAnalyzer.extractElementInfo(t3).selector, s2 = y(t3);
        return "checkbox" === s2 || "radio" === s2 || "select" === s2 ? { type: "multi-options", label: e3, value: r3, selected: n3, selector: i3, inputType: s2 } : { type: "single-option", label: e3, value: r3, selected: n3, selector: i3, inputType: s2 };
      }), { selector: this.domAnalyzer.extractElementInfo(r2).selector, type: "group", recommendationSelector: (_a2 = i2[0]) == null ? void 0 : _a2.selector, recommendations: i2 }) : { selector: this.domAnalyzer.extractElementInfo(t2).selector, type: "interactive" };
    } catch (e2) {
      return void 0, { selector: this.domAnalyzer.extractElementInfo(t2).selector, type: "interactive" };
    }
  }
  findRecommendationContainer(t2, e2) {
    let r2 = t2, n2 = 0;
    for (; r2.parentElement && 3 > n2; ) {
      if (this.domAnalyzer.findInteractiveChildren(r2.parentElement).filter((t3) => g(t3)).length > 1) return ["checkbox", "radio"].includes(e2) ? r2.parentElement : r2;
      r2 = r2.parentElement, n2++;
    }
    return t2;
  }
  findNearestSiblingRecommendationTarget(t2) {
    const e2 = t2.parentElement;
    if (!e2) return null;
    const r2 = Array.from(e2.children).filter((e3) => e3 !== t2);
    for (const n2 of r2) {
      if (g(n2)) return n2;
      const t3 = n2.querySelectorAll("*");
      for (const e3 of t3) if (g(e3)) return e3;
    }
    return null;
  }
  findTargetElement(t2) {
    return this.elementFinder.findTargetElement(t2);
  }
  findSimilarElements(t2, e2) {
    return this.recommendationEngine.findSimilarElements(t2, e2);
  }
  canApply(t2, e2) {
    if (!t2 || !e2) return 0;
    const { type: r2 } = t2;
    if (!this.elementFinder.isInteractable(e2)) return 0;
    switch (r2) {
      case "input":
        return this.inputHandler.canApply(e2);
      case "select":
        return this.selectHandler.canApply(e2);
      case "checkbox":
        return this.checkboxHandler.canApply(e2);
      case "radio":
        return this.radioHandler.canApply(e2);
      default:
        return 1;
    }
  }
  extractElementInfo(t2) {
    return this.domAnalyzer.extractElementInfo(t2);
  }
  getRecommendationStats(t2 = document.body) {
    return this.recommendationEngine.getRecommendationStats(t2);
  }
  getElementValidationDetails(t2) {
    return this.elementFinder.getElementValidationDetails(t2);
  }
  createRecommendationFromElement(t2) {
    try {
      const e2 = this.extractElementInfo(t2), r2 = y(t2);
      let n2 = [];
      return e2.value ? n2 = [e2.value] : w(t2) && (n2 = [x(t2) || "true"]), { type: r2, value: n2, inputSelector: e2.selector };
    } catch (e2) {
      return void 0, null;
    }
  }
}, RecommendationEngineService: ut, SelectHandler: ht, extractElementLabel: v, extractElementValue: x, findLabelForInput: f, findSelectOptions: S, getElementAttributes: n, getElementText: e, getElementValue: t, getInputType: y, getRecommendationElementRole: k, hasAriaInteraction: p, isButtonElement: o, isCheckbox: d, isCheckboxOrRadio: u, isDropdownOption: m, isElementSelected: w, isElementVisible: r, isInteractable: b, isInteractiveElement: i, isInvalidEventTarget: (t2) => null === t2 || t2 === document.documentElement || t2 === document.body || t2 instanceof Element && ("HTML" === t2.tagName || "BODY" === t2.tagName), isNormalInputElement: s, isRadio: h, isRecommendationTarget: g, isSelectElement: c, isSelectTrigger: E, isTextAreaElement: a });
class bt {
  constructor() {
    this.elementResolver = null, this.recommendationApplier = null, this.api = z(), this.personalizedStepsPromise = null, this.routerAdapter = null, this.i = (t2) => __async(this, null, function* () {
      var _a2;
      const e2 = t2.target;
      if (!e2) return;
      const r2 = Z.get();
      if (!r2.isActive || !r2.steps) return;
      const n2 = r2.steps[r2.currentStepIndex];
      if (!n2 || "beacon" !== n2.guide.type) return;
      const i2 = (_a2 = this.elementResolver) == null ? void 0 : _a2.resolve(n2.selector);
      (i2 === e2 || (i2 == null ? void 0 : i2.contains(e2)) || "sherpa-beacon" === e2.tagName.toLowerCase()) && (yield this.nextStep()), yield this.checkAllStepSelectorRedirects();
    }), this.resolversPromise = this.ensureResolvers();
  }
  static getInstance() {
    return bt.instance || (bt.instance = new bt()), bt.instance;
  }
  setRouterAdapter(t2) {
    this.routerAdapter = t2;
  }
  getRouterAdapter() {
    return this.routerAdapter;
  }
  autoDetectRouter() {
    return __async(this, null, function* () {
      if (!this.routerAdapter) try {
        const { UniversalRouterAdapter: t2 } = yield import("./sherpa-index-0.0.13.BiH_CAvz.min.js").then((t3) => t3.u), e2 = new t2();
        e2.canHandle(window.location.href) && (this.routerAdapter = e2);
      } catch (t2) {
      }
    });
  }
  ensureResolvers() {
    return __async(this, null, function* () {
      if (this.elementResolver && this.recommendationApplier) return;
      const [{ elementResolver: t2 }, { RecommendationApplier: e2 }] = yield Promise.all([Promise.resolve().then(() => nt), Promise.resolve().then(() => mt)]);
      this.elementResolver = t2, this.recommendationApplier = new e2();
    });
  }
  waitForResolvers() {
    return __async(this, null, function* () {
      yield this.resolversPromise;
    });
  }
  startTour(t2, e2, r2) {
    return __async(this, null, function* () {
      try {
        this.personalizedStepsPromise = 1 == (r2 == null ? void 0 : r2.skipPersonalization) ? null : this.api.personalize({ tourId: t2, context: e2 }).then((t3) => (Y.setPersonalizedSteps(t3.data), t3.data)), yield this.waitForResolvers(), yield this.autoDetectRouter();
        const n2 = (yield this.api.getTourById(t2)).data;
        if (!n2) throw Error("Tour not found: " + t2);
        if (yield this.checkAndNavigateToTourUrl(n2.buildUrl)) return this.storeTourStartParameters(t2, e2, r2), void 0;
        Y.startTour(n2, n2.steps, e2, r2), J.showControlPanel(), this.setupNavigationDetection(), yield Promise.all([this.setupInputFocusListeners(), this.setupInputClickListeners(), this.setupBeaconClickListeners(), this.setupStepInputListeners(), this.setupDragListeners()]), yield this.executeCurrentStep(), yield this.api.track({ eventName: "tour_started", properties: { tourId: t2, context: e2, metadata: r2, hasPersonalization: !!this.personalizedStepsPromise, isDirect: (r2 == null ? void 0 : r2.isDirect) || 0, skipPersonalization: (r2 == null ? void 0 : r2.skipPersonalization) || 0 }, timestamp: Date.now(), sessionId: this.generateSessionId() });
      } catch (n2) {
        throw n2;
      }
    });
  }
  containsWildcard(t2) {
    if (!t2 || "string" != typeof t2) return 1;
    if (t2.includes("*")) return 1;
    try {
      let e2;
      if (t2.startsWith("http://") || t2.startsWith("https://")) e2 = new URL(t2).pathname;
      else if (t2.startsWith("/")) e2 = t2.split("?")[0].split("#")[0];
      else {
        if (t2.includes("://")) return 1;
        const r2 = window.location.origin + window.location.pathname;
        e2 = new URL(t2, r2).pathname;
      }
      return e2.includes("*");
    } catch (e2) {
      return 1;
    }
  }
  matchesWildcardUrl(t2, e2) {
    try {
      if (e2.startsWith("http://") || e2.startsWith("https://")) {
        const r3 = new URL(t2), n3 = new URL(e2);
        if (r3.origin !== n3.origin) return 0;
        const i3 = r3.pathname, s2 = n3.pathname.replace(/\*/g, "__WILDCARD_PLACEHOLDER__").replace(/[.+?^${}()|[\]\\]/g, "\\$&").replace(/__WILDCARD_PLACEHOLDER__/g, ".*");
        return RegExp("^".concat(s2, "$")).test(i3);
      }
      let r2, n2;
      if (r2 = t2.startsWith("http://") || t2.startsWith("https://") ? new URL(t2).pathname : t2.split("?")[0].split("#")[0], e2.startsWith("/")) n2 = e2.split("?")[0].split("#")[0];
      else {
        const t3 = window.location.origin + window.location.pathname;
        n2 = new URL(e2, t3).pathname;
      }
      const i2 = n2.replace(/\*/g, "__WILDCARD_PLACEHOLDER__").replace(/[.+?^${}()|[\]\\]/g, "\\$&").replace(/__WILDCARD_PLACEHOLDER__/g, ".*");
      return RegExp("^".concat(i2, "$")).test(r2);
    } catch (r2) {
      return 0;
    }
  }
  checkAndNavigateToTourUrl(t2) {
    return __async(this, null, function* () {
      var _a2;
      const e2 = ((_a2 = this.routerAdapter) == null ? void 0 : _a2.getCurrentUrl()) || window.location.href, r2 = window.location.pathname + window.location.search + window.location.hash;
      if (this.containsWildcard(t2)) return this.matchesWildcardUrl(e2, t2), 0;
      const n2 = this.normalizeUrls(t2, e2, r2);
      if (!n2) return 0;
      const { targetUrl: i2, targetPath: s2, urlsMatch: o2 } = n2;
      return o2 ? 0 : (yield this.api.track({ eventName: "tour_navigation", properties: { fromUrl: e2, toUrl: i2, buildUrl: t2, navigationType: this.getNavigationType() }, timestamp: Date.now(), sessionId: this.generateSessionId() }), yield this.attemptNavigation(i2, s2));
    });
  }
  normalizeUrls(t2, e2, r2) {
    try {
      let n2, i2;
      if (t2.startsWith("http://") || t2.startsWith("https://")) {
        const e3 = new URL(t2);
        n2 = t2, i2 = e3.pathname + e3.search + e3.hash;
      } else if (t2.startsWith("/")) {
        const e3 = window.location.origin;
        n2 = new URL(t2, e3).href, i2 = t2;
      } else {
        const e3 = window.location.origin + window.location.pathname;
        n2 = new URL(t2, e3).href, i2 = new URL(t2, e3).pathname + new URL(t2, e3).search + new URL(t2, e3).hash;
      }
      return { targetUrl: n2, targetPath: i2, urlsMatch: this.checkUrlMatch(e2, r2, n2, i2) };
    } catch (n2) {
      return null;
    }
  }
  checkUrlMatch(t2, e2, r2, n2) {
    if (this.containsWildcard(r2) || this.containsWildcard(n2)) return this.matchesWildcardUrl(t2, r2);
    if (t2 === r2) return 1;
    if (e2 === n2) return 1;
    const i2 = (t3) => t3.replace(/\/+$/, "") || "/";
    if (i2(e2) === i2(n2)) return 1;
    const s2 = e2.split("?")[0].split("#")[0], o2 = n2.split("?")[0].split("#")[0];
    return i2(s2) === i2(o2) ? 1 : 0;
  }
  getNavigationType() {
    return this.routerAdapter ? "spa" : this.detectSPAFramework() ? "spa_detected" : "full_page";
  }
  detectSPAFramework() {
    return [() => !!window.React || document.querySelector("[data-reactroot]") || document.querySelector("#root"), () => !!window.Vue || document.querySelector("[data-v-]") || document.querySelector("#app"), () => !!window.ng || document.querySelector("[ng-app]") || document.querySelector("app-root"), () => !!window.__NEXT_DATA__ || document.querySelector("#__next"), () => !!window.__NUXT__ || document.querySelector("#__nuxt"), () => document.querySelector("[data-sveltekit-hydrate]") || document.querySelector("#svelte"), () => !!document.querySelector("[data-spa]") || !!document.querySelector("[data-app]"), () => window.history.length > 1 && !!window.history.pushState].some((t2) => {
      try {
        return t2();
      } catch (e2) {
        return 0;
      }
    });
  }
  attemptNavigation(t2, e2) {
    return __async(this, null, function* () {
      const r2 = [() => this.tryRouterAdapterNavigation(t2, e2), () => this.tryAutoDetectedSPANavigation(t2, e2), () => this.tryHistoryAPINavigation(t2, e2), () => this.tryFullPageNavigation(t2)];
      for (const i2 of r2) try {
        const t3 = yield i2();
        if (null !== t3) return t3;
      } catch (n2) {
        continue;
      }
      return window.location.href = t2, 1;
    });
  }
  tryRouterAdapterNavigation(t2, e2) {
    return __async(this, null, function* () {
      if (!this.routerAdapter || !this.routerAdapter.canHandle(t2)) return null;
      try {
        const r2 = this.capturePageState();
        return yield this.routerAdapter.navigate(t2), (yield this.verifyNavigationSuccess(t2, e2, r2, "spa")) ? 0 : null;
      } catch (r2) {
        return null;
      }
    });
  }
  tryAutoDetectedSPANavigation(t2, e2) {
    return __async(this, null, function* () {
      if (!this.detectSPAFramework()) return null;
      const r2 = this.getFrameworkNavigation();
      if (r2) try {
        const n2 = this.capturePageState();
        if (yield r2(e2), yield this.verifyNavigationSuccess(t2, e2, n2, "spa")) return 0;
      } catch (n2) {
      }
      return null;
    });
  }
  getFrameworkNavigation() {
    var _a2;
    if (window.__NEXT_DATA__ && ((_a2 = window.next) == null ? void 0 : _a2.router)) return (t3) => __async(this, null, function* () {
      yield window.next.router.push(t3);
    });
    const t2 = [window.router, window.$router, window.Router, window.__router__];
    for (const e2 of t2) {
      if (e2 && "function" == typeof e2.push) return (t3) => __async(this, null, function* () {
        yield e2.push(t3);
      });
      if (e2 && "function" == typeof e2.navigate) return (t3) => __async(this, null, function* () {
        yield e2.navigate(t3);
      });
    }
    return null;
  }
  tryHistoryAPINavigation(t2, e2) {
    return __async(this, null, function* () {
      try {
        if (new URL(t2).origin !== window.location.origin) return null;
      } catch (e3) {
        return null;
      }
      try {
        const r2 = this.capturePageState();
        return window.history.pushState({}, "", t2), window.dispatchEvent(new PopStateEvent("popstate", { state: {} })), window.dispatchEvent(new CustomEvent("sherpa:navigation", { detail: { url: t2, path: e2 } })), (yield this.verifyNavigationSuccess(t2, e2, r2, "history-api")) ? 0 : (window.history.back(), null);
      } catch (r2) {
        return null;
      }
    });
  }
  tryFullPageNavigation(t2) {
    return __async(this, null, function* () {
      return window.location.href = t2, 1;
    });
  }
  storeTourStartParameters(t2, e2, r2) {
    const n2 = { tourId: t2, context: e2, metadata: r2, timestamp: Date.now() };
    try {
      sessionStorage.setItem("sherpa_pending_tour", JSON.stringify(n2));
    } catch (i2) {
    }
  }
  capturePageState() {
    return { url: window.location.href, path: window.location.pathname + window.location.search + window.location.hash, title: document.title, bodyHash: this.generateContentHash(document.body), timestamp: Date.now() };
  }
  generateContentHash(t2) {
    const e2 = t2.textContent || "", r2 = t2.querySelectorAll("*").length, n2 = t2.querySelectorAll("script").length, i2 = t2.querySelectorAll("a").length, s2 = "".concat(e2.length, "-").concat(r2, "-").concat(n2, "-").concat(i2);
    let o2 = 0;
    for (let a2 = 0; s2.length > a2; a2++) o2 = (o2 << 5) - o2 + s2.charCodeAt(a2), o2 &= o2;
    return "" + o2;
  }
  verifyNavigationSuccess(t2, e2, r2, n2) {
    return __async(this, null, function* () {
      const i2 = "spa" === n2 ? 20 : 40, s2 = "spa" === n2 ? 150 : 250;
      for (let a2 = 0; i2 > a2; a2++) {
        yield this.delay(s2);
        const i3 = this.capturePageState();
        if (this.checkUrlMatch(i3.url, i3.path, t2, e2)) if ("spa" === n2) {
          if (i3.bodyHash !== r2.bodyHash || i3.title !== r2.title || 3 > a2) return 1;
        } else {
          if (i3.bodyHash !== r2.bodyHash || i3.title !== r2.title) return 1;
          if (a2 > 10 && (yield this.checkForNewContent(r2))) return 1;
        }
      }
      const o2 = this.capturePageState();
      return this.checkUrlMatch(o2.url, o2.path, t2, e2) && "spa" === n2 ? 1 : 0;
    });
  }
  checkForNewContent(t2) {
    return __async(this, null, function* () {
      yield this.delay(500);
      const e2 = this.capturePageState();
      return [e2.bodyHash !== t2.bodyHash, e2.title !== t2.title, document.querySelectorAll("*").length != document.querySelectorAll("*").length, !document.querySelector('.loading, .spinner, [data-loading="true"]'), !!document.querySelector('main, [role="main"], .main-content, #main, #content')].some((t3) => t3);
    });
  }
  static checkAndStartPendingTour() {
    return __async(this, null, function* () {
      try {
        const t2 = sessionStorage.getItem("sherpa_pending_tour");
        if (!t2) return;
        const e2 = JSON.parse(t2), { tourId: r2, context: n2, metadata: i2, timestamp: s2 } = e2, o2 = 3e5;
        if (Date.now() - s2 > o2) return sessionStorage.removeItem("sherpa_pending_tour"), void 0;
        sessionStorage.removeItem("sherpa_pending_tour");
        const a2 = bt.getInstance();
        yield a2.startTour(r2, n2, i2);
      } catch (t2) {
        try {
          sessionStorage.removeItem("sherpa_pending_tour");
        } catch (e2) {
        }
      }
    });
  }
  endTour() {
    return __async(this, null, function* () {
      const t2 = Z.get();
      if (t2.isActive) try {
        yield this.api.track({ eventName: "tour_ended", properties: { tourId: t2.tourId, stepId: t2.currentStepIndex, completed: t2.steps ? t2.currentStepIndex >= t2.steps.length - 1 : 0 }, timestamp: Date.now(), sessionId: this.generateSessionId() }), J.hideControlPanel(), J.hideTooltip(), J.hideBeacon(), this.cleanup(), Y.endTour(), J.showSearch();
      } catch (e2) {
      }
    });
  }
  nextStep() {
    return __async(this, null, function* () {
      const t2 = Z.get();
      if (!t2.isActive || !t2.steps) return 0;
      if (!t2.steps[t2.currentStepIndex]) return 0;
      const e2 = Y.nextStep();
      return e2 ? yield this.executeCurrentStep() : yield this.endTour(), e2;
    });
  }
  previousStep() {
    return __async(this, null, function* () {
      const t2 = Z.get();
      if (!t2.isActive || !t2.steps) return 0;
      if (!t2.steps[t2.currentStepIndex]) return 0;
      const e2 = Y.previousStep();
      return e2 && (yield this.executeCurrentStep()), e2;
    });
  }
  goToStep(t2) {
    return __async(this, null, function* () {
      if (!Z.get().isActive) return 0;
      const e2 = Y.goToStep(t2);
      return e2 && (yield this.executeCurrentStep()), e2;
    });
  }
  executeCurrentStep() {
    return __async(this, null, function* () {
      yield this.waitForResolvers();
      const t2 = Z.get();
      if (!t2.isActive || !t2.steps) return;
      const e2 = t2.steps[t2.currentStepIndex];
      if (e2) try {
        e2.delayMs && (yield this.delay(e2.delayMs)), yield this.checkAllStepSelectorRedirects();
        const r2 = Z.get();
        if (!r2.isActive || !r2.steps || r2.currentStepIndex !== t2.currentStepIndex) return;
        if (!(yield this.evaluateStepLogic(e2))) return;
        let n2 = yield this.findGuideElement(e2);
        if (!n2 && (yield this.handleMissingGuideElement(e2), n2 = yield this.findGuideElement(e2), !n2)) return this.endTour(), void 0;
        this.scrollElementIntoView(n2), yield this.executeStepGuide(e2, n2), "input" === e2.actionType && (yield this.setupInputFocusListener(e2, n2));
      } catch (r2) {
        yield this.handleStepError(e2, r2);
      }
    });
  }
  scrollElementIntoView(t2) {
    if ("function" == typeof t2.scrollIntoView) try {
      t2.scrollIntoView({ behavior: "smooth", block: "center", inline: "nearest" });
    } catch (e2) {
      try {
        t2.scrollIntoView(1);
      } catch (r2) {
      }
    }
  }
  evaluateStepLogic(t2) {
    return __async(this, null, function* () {
      const { logic: e2 } = t2;
      return e2.selector ? (yield this.findLogicElement(t2)) ? yield this.handleLogicCondition(t2, 1) : yield this.handleLogicCondition(t2, 0) : 1;
    });
  }
  handleLogicCondition(t2, e2) {
    return __async(this, null, function* () {
      const { condition: r2 } = t2.logic;
      if ("action" in r2 && "type" in r2 && "element-doesnt-exist" === r2.type && !e2) {
        if ("skip" === r2.action) return yield this.nextStep(), 0;
        if ("end" === r2.action) return yield this.endTour(), 0;
      }
      return 1;
    });
  }
  findGuideElement(t2) {
    return __async(this, null, function* () {
      if (yield this.waitForResolvers(), !t2.selector) return null;
      for (let e2 = 0; 10 > e2; e2++) {
        const e3 = this.elementResolver.resolve(t2.selector);
        if (e3) return e3;
        yield this.delay(500);
      }
      return null;
    });
  }
  findLogicElement(t2) {
    return __async(this, null, function* () {
      if (yield this.waitForResolvers(), !t2.logic.selector) return null;
      for (let e2 = 0; 3 > e2; e2++) {
        const e3 = this.elementResolver.resolve(t2.logic.selector);
        if (e3) return e3;
        yield this.delay(200);
      }
      return null;
    });
  }
  executeStepGuide(t2, e2) {
    return __async(this, null, function* () {
      const { guide: r2 } = t2;
      switch (J.hideTooltip(), J.hideBeacon(), r2.type) {
        case "tooltip":
          yield this.showTooltip(t2, e2, r2);
          break;
        case "beacon":
          J.showBeacon(t2.stepId, e2);
      }
    });
  }
  showTooltip(t2, e2, r2) {
    return __async(this, null, function* () {
      let n2 = r2.content, i2 = r2.recommendation;
      if (this.personalizedStepsPromise) try {
        J.showTooltip(t2.stepId, e2, r2, 1);
        const s3 = (yield this.personalizedStepsPromise)[t2.stepId];
        s3 && (n2 = s3.content, i2 && (i2 = __spreadProps(__spreadValues({}, i2), { value: s3.recommendationValue })));
      } catch (o2) {
      }
      const s2 = __spreadProps(__spreadValues({}, r2), { content: n2, recommendation: i2 });
      J.showTooltip(t2.stepId, e2, s2, 0);
    });
  }
  applyRecommendation(t2) {
    return __async(this, null, function* () {
      var _a2;
      yield this.waitForResolvers();
      const e2 = Z.get();
      if (!e2.steps) return 0;
      const r2 = e2.steps.find((e3) => e3.stepId === t2);
      if (!r2 || "tooltip" !== r2.guide.type || !r2.guide.recommendation) return 0;
      try {
        const t3 = this.recommendationApplier.findTargetElement(r2.guide.recommendation);
        if (!t3) return 0;
        const n2 = __spreadValues({}, r2.guide.recommendation), i2 = yield this.personalizedStepsPromise, s2 = (_a2 = Z.get().personalizedSteps) != null ? _a2 : i2, o2 = s2 == null ? void 0 : s2[r2.stepId];
        o2 && (n2.value = o2.recommendationValue);
        const a2 = this.recommendationApplier.apply(n2, t3);
        return a2 && (yield this.api.track({ eventName: "recommendation_applied", properties: { tourId: e2.tourId, stepId: r2.stepId, recommendationType: r2.guide.recommendation.type, recommendationValue: r2.guide.recommendation.value }, timestamp: Date.now(), sessionId: this.generateSessionId() }), setTimeout(() => this.nextStep(), 500)), a2;
      } catch (n2) {
        return 0;
      }
    });
  }
  handleMissingGuideElement(t2) {
    return __async(this, null, function* () {
      yield this.api.track({ eventName: "guide_element_missing", properties: { tourId: Z.get().tourId, stepId: Z.get().currentStepIndex }, timestamp: Date.now(), sessionId: this.generateSessionId() }), yield this.delay(500);
    });
  }
  handleStepError(t2, e2) {
    return __async(this, null, function* () {
      yield this.api.track({ eventName: "step_error", properties: { tourId: Z.get().tourId, stepId: t2.stepId, error: e2 instanceof Error ? e2.message : e2 + "" }, timestamp: Date.now(), sessionId: this.generateSessionId() });
    });
  }
  setupInputFocusListeners() {
    return __async(this, null, function* () {
      yield this.waitForResolvers();
      const t2 = (t3) => __async(this, null, function* () {
        var _a2;
        const e2 = t3.target;
        if (!e2 || !(e2 instanceof HTMLInputElement || e2 instanceof HTMLSelectElement || e2 instanceof HTMLTextAreaElement)) return;
        const r2 = Z.get();
        if (!r2.isActive || !r2.steps) return;
        yield this.checkAllStepSelectorRedirects();
        let n2 = -1;
        for (let i2 = 0; r2.steps.length > i2; i2++) {
          const t4 = r2.steps[i2];
          if (t4.selector && this.elementResolver.resolve(t4.selector) === e2) {
            n2 = i2;
            break;
          }
          if ("tooltip" === t4.guide.type && ((_a2 = t4.guide.recommendation) == null ? void 0 : _a2.inputSelector) && (yield this.isRelatedInputElement(e2, t4.guide.recommendation.inputSelector))) {
            n2 = i2;
            break;
          }
        }
        -1 !== n2 && n2 !== r2.currentStepIndex && (yield this.goToStep(n2));
      });
      document.addEventListener("focusin", t2, 1), this.inputFocusHandler = t2;
    });
  }
  generateSessionId() {
    return "session_".concat(Date.now(), "_").concat(Math.random().toString(36).substr(2, 9));
  }
  delay(t2) {
    return new Promise((e2) => setTimeout(e2, t2));
  }
  getTourState() {
    return Z.get();
  }
  isActive() {
    return Z.get().isActive;
  }
  isNextDisabled() {
    const t2 = Z.get();
    if (!t2.isActive || !t2.steps) return 1;
    const e2 = t2.steps[t2.currentStepIndex];
    return e2 ? e2.logic.disableNext ? 1 : t2.currentStepIndex >= t2.steps.length - 1 : 1;
  }
  isPreviousDisabled() {
    const t2 = Z.get();
    if (!t2.isActive || !t2.steps) return 1;
    const e2 = t2.steps[t2.currentStepIndex];
    return e2 ? e2.logic.disablePrev ? 1 : 0 >= t2.currentStepIndex : 1;
  }
  setupNavigationDetection() {
    const t2 = history.pushState, e2 = history.replaceState, r2 = () => {
      Z.get().isActive && this.handleSPANavigation();
    };
    history.pushState = (...e3) => {
      t2.apply(history, e3), r2();
    }, history.replaceState = (...t3) => {
      e2.apply(history, t3), r2();
    }, window.addEventListener("popstate", r2), this.setupDOMChangeDetection(), this.originalPushState = t2, this.originalReplaceState = e2, this.navigationHandler = r2;
  }
  setupDOMChangeDetection() {
    if (this.mutationObserver) return;
    let t2 = null;
    const e2 = () => {
      t2 && clearTimeout(t2), t2 = setTimeout(() => __async(this, null, function* () {
        Z.get().isActive && (yield this.checkAllStepSelectorRedirects());
      }), 500);
    };
    this.mutationObserver = new MutationObserver((t3) => {
      t3.some((t4) => "childList" === t4.type && (t4.addedNodes.length > 0 || t4.removedNodes.length > 0)) && e2();
    }), this.mutationObserver.observe(document.body, { childList: 1, subtree: 1, attributes: 0, attributeOldValue: 0, characterData: 0 });
  }
  handleSPANavigation() {
    const t2 = Z.get();
    if (!t2.isActive || !t2.steps) return;
    const e2 = window.location.href, r2 = window.location.pathname + window.location.search + window.location.hash, n2 = t2.currentStepIndex, i2 = t2.steps[n2];
    if (i2.logic.stepRedirects) for (const s2 of i2.logic.stepRedirects) if ("url-matched" === s2.type) {
      if (this.checkUrlMatchForRedirect(e2, r2, s2.data.url)) return this.goToStep(s2.stepId), void 0;
    } else "step-selector-matched" === s2.type && this.checkStepSelectorMatched(s2, n2);
  }
  checkAllStepSelectorRedirects() {
    return __async(this, null, function* () {
      const t2 = Z.get();
      if (yield this.delay(200), !t2.isActive || !t2.steps) return;
      const e2 = t2.currentStepIndex, r2 = t2.steps[e2];
      if (r2.logic.stepRedirects) for (const n2 of r2.logic.stepRedirects) "step-selector-matched" === n2.type && (yield this.checkStepSelectorMatched(n2, e2));
    });
  }
  checkStepSelectorMatched(t2, e2) {
    return __async(this, null, function* () {
      var _a2;
      yield this.waitForResolvers();
      const r2 = t2.stepId, n2 = Z.get();
      if (!n2.steps || n2.currentStepIndex === r2) return;
      const i2 = n2.steps.find((t3) => t3.stepId === r2);
      if (i2) try {
        this.elementResolver.resolve((_a2 = t2.selector) != null ? _a2 : i2.selector) && (yield this.goToStep(r2));
      } catch (s2) {
      }
    });
  }
  checkUrlMatchForRedirect(t2, e2, r2) {
    try {
      if (this.containsWildcard(r2)) return this.matchesWildcardUrl(t2, r2);
      if (r2.startsWith("http://") || r2.startsWith("https://")) return this.normalizeUrlForComparison(t2) === this.normalizeUrlForComparison(r2);
      if (r2.startsWith("/")) return this.normalizePathForComparison(e2) === this.normalizePathForComparison(r2);
      {
        const t3 = this.normalizePathForComparison(e2), n2 = this.normalizePathForComparison(r2);
        return t3.includes(n2) || t3.endsWith(n2);
      }
    } catch (n2) {
      return 0;
    }
  }
  normalizeUrlForComparison(t2) {
    try {
      const e2 = new URL(t2);
      return (e2.origin + e2.pathname + e2.search + e2.hash).toLowerCase().replace(/\/+$/, "");
    } catch (e2) {
      return t2.toLowerCase().replace(/\/+$/, "");
    }
  }
  normalizePathForComparison(t2) {
    return t2.toLowerCase().replace(/\/+$/, "").replace(/^\/+/, "/");
  }
  cleanup() {
    this.inputFocusHandler && (document.removeEventListener("focusin", this.inputFocusHandler, 1), this.inputFocusHandler = void 0), this.inputClickHandler && (document.removeEventListener("click", this.inputClickHandler, 1), this.inputClickHandler = void 0), document.removeEventListener("click", this.i, 1), this.dragStartHandler && (document.removeEventListener("dragstart", this.dragStartHandler, 1), this.dragStartHandler = void 0), this.originalPushState && (history.pushState = this.originalPushState, this.originalPushState = void 0), this.originalReplaceState && (history.replaceState = this.originalReplaceState, this.originalReplaceState = void 0), this.navigationHandler && (window.removeEventListener("popstate", this.navigationHandler), this.navigationHandler = void 0), this.mutationObserver && (this.mutationObserver.disconnect(), this.mutationObserver = void 0), this.personalizedStepsPromise = null;
  }
  setupStepInputListeners() {
    return __async(this, null, function* () {
      yield this.waitForResolvers();
      const t2 = Z.get();
      t2.steps && t2.steps.forEach((t3, e2) => {
        var _a2;
        "tooltip" === t3.guide.type && ((_a2 = t3.guide.recommendation) == null ? void 0 : _a2.inputSelector) && this.setupInputListenersForSelector(t3.guide.recommendation.inputSelector, e2);
      });
    });
  }
  setupInputListenersForSelector(t2, e2) {
    return __async(this, null, function* () {
      yield this.waitForResolvers();
      try {
        const r2 = this.elementResolver.resolve(t2);
        if (!r2) return;
        this.addInputElementListener(r2, e2), r2 instanceof HTMLInputElement && ("checkbox" === r2.type || "radio" === r2.type) && this.findRelatedInputElements(r2).forEach((t3) => {
          this.addInputElementListener(t3, e2);
        });
      } catch (r2) {
      }
    });
  }
  findRelatedInputElements(t2) {
    const e2 = [];
    if (t2.name && document.querySelectorAll('input[name="'.concat(t2.name, '"]')).forEach((r3) => {
      r3 !== t2 && e2.push(r3);
    }), t2.form) {
      const r3 = t2.form.querySelectorAll('input[type="checkbox"], input[type="radio"]'), n2 = Array.from(t2.classList), i2 = Array.from(t2.attributes).filter((t3) => t3.name.startsWith("data-")).map((t3) => t3.name);
      r3.forEach((r4) => {
        if (r4 === t2 || e2.includes(r4)) return;
        const s2 = Array.from(r4.classList).some((t3) => n2.includes(t3)), o2 = Array.from(r4.attributes).filter((t3) => t3.name.startsWith("data-")).map((t3) => t3.name).some((t3) => i2.includes(t3));
        (s2 || o2) && e2.push(r4);
      });
    }
    const r2 = t2.closest('fieldset, .form-group, .input-group, [role="group"]');
    return r2 && r2.querySelectorAll('input[type="checkbox"], input[type="radio"]').forEach((r3) => {
      r3 === t2 || e2.includes(r3) || e2.push(r3);
    }), e2;
  }
  addInputElementListener(t2, e2) {
    const r2 = () => __async(this, null, function* () {
      const t3 = Z.get();
      if (!t3.isActive || t3.currentStepIndex === e2) return;
      const r3 = Z.get();
      r3.isActive && r3.currentStepIndex !== e2 && (yield this.goToStep(e2));
    });
    t2.addEventListener("click", r2, { passive: 1 }), t2.addEventListener("focus", r2, { passive: 1 });
  }
  setupDragListeners() {
    return __async(this, null, function* () {
      yield this.waitForResolvers();
      const t2 = (t3) => __async(this, null, function* () {
        const e2 = t3.target;
        if (!e2) return;
        const r2 = Z.get();
        if (!r2.isActive || !r2.steps) return;
        const n2 = r2.steps.findIndex((t4) => {
          var _a2;
          if (t4.selector) {
            const r3 = this.elementResolver.resolve(t4.selector);
            if (r3 === e2 || (r3 == null ? void 0 : r3.contains(e2))) return 1;
          }
          if ("tooltip" === t4.guide.type && ((_a2 = t4.guide.recommendation) == null ? void 0 : _a2.inputSelector)) {
            const r3 = this.elementResolver.resolve(t4.guide.recommendation.inputSelector);
            if (r3 === e2 || (r3 == null ? void 0 : r3.contains(e2))) return 1;
          }
          return 0;
        });
        -1 === n2 || n2 === r2.currentStepIndex && K.get().currentTooltip || (yield this.api.track({ eventName: "drag_navigation", properties: { tourId: r2.tourId, fromStepIndex: r2.currentStepIndex, toStepIndex: n2, draggedElement: this.getElementDescription(e2) }, timestamp: Date.now(), sessionId: this.generateSessionId() }), yield this.goToStep(n2));
      });
      document.addEventListener("dragstart", t2, 1), this.dragStartHandler = t2;
    });
  }
  getElementDescription(t2) {
    return "".concat(t2.tagName.toLowerCase()).concat(t2.id ? "#" + t2.id : "").concat(t2.className ? "." + t2.className.split(" ").join(".") : "").substring(0, 100);
  }
  setupInputClickListeners() {
    return __async(this, null, function* () {
      yield this.waitForResolvers();
      const t2 = (t3) => __async(this, null, function* () {
        var _a2;
        const e2 = t3.target;
        if (yield this.checkAllStepSelectorRedirects(), !g(e2)) return;
        const r2 = Z.get();
        if (!r2.isActive || !r2.steps) return;
        let n2 = -1;
        for (let i2 = 0; r2.steps.length > i2; i2++) {
          const t4 = r2.steps[i2];
          if (t4.selector && this.elementResolver.resolve(t4.selector) === e2) {
            n2 = i2;
            break;
          }
          if ("tooltip" === t4.guide.type && ((_a2 = t4.guide.recommendation) == null ? void 0 : _a2.inputSelector) && (yield this.isRelatedInputElement(e2, t4.guide.recommendation.inputSelector))) {
            n2 = i2;
            break;
          }
        }
        -1 !== n2 && n2 !== r2.currentStepIndex && (yield this.goToStep(n2));
      });
      document.addEventListener("click", t2, 1), this.inputClickHandler = t2;
    });
  }
  isRelatedInputElement(t2, e2) {
    return __async(this, null, function* () {
      if (yield this.waitForResolvers(), this.elementResolver.resolve(e2) === t2) return 1;
      if (t2 instanceof HTMLInputElement && ("checkbox" === t2.type || "radio" === t2.type)) {
        const r2 = this.elementResolver.resolve(e2);
        if (r2 instanceof HTMLInputElement && ("checkbox" === r2.type || "radio" === r2.type)) {
          if (t2.name && r2.name && t2.name === r2.name) return 1;
          if (t2.form === r2.form && t2.form) {
            const e4 = Array.from(t2.classList), n3 = Array.from(r2.classList);
            if (e4.some((t3) => n3.includes(t3))) return 1;
            const i2 = Array.from(t2.attributes).filter((t3) => t3.name.startsWith("data-")).map((t3) => t3.name), s2 = Array.from(r2.attributes).filter((t3) => t3.name.startsWith("data-")).map((t3) => t3.name);
            if (i2.some((t3) => s2.includes(t3))) return 1;
          }
          const e3 = t2.closest('fieldset, .form-group, .input-group, [role="group"]'), n2 = r2.closest('fieldset, .form-group, .input-group, [role="group"]');
          if (e3 && n2 && e3 === n2) return 1;
        }
      }
      return 0;
    });
  }
  setupBeaconClickListeners() {
    return __async(this, null, function* () {
      yield this.waitForResolvers(), document.addEventListener("click", this.i, 1);
    });
  }
  setupInputFocusListener(t2, e2) {
    return __async(this, null, function* () {
      yield this.waitForResolvers(), e2.addEventListener("focus", () => __async(this, null, function* () {
        const e3 = Z.get();
        if (!e3.steps) return;
        const r2 = e3.steps.find((e4) => e4.id === t2.id), n2 = r2 == null ? void 0 : r2.stepId;
        -1 !== n2 && n2 !== e3.currentStepIndex && void 0 !== n2 && (yield this.goToStep(n2));
      }), { once: 1 });
    });
  }
  static resetInstance() {
    bt.instance && (bt.instance.isActive() && bt.instance.endTour().catch(() => {
    }), bt.instance = null);
  }
}
T = Object.defineProperty, $ = Object.getOwnPropertyDescriptor, A = (t2, e2, r2, n2) => {
  var i2, s2, o2 = n2 > 1 ? void 0 : n2 ? $(e2, r2) : e2;
  for (i2 = t2.length - 1; i2 >= 0; i2--) (s2 = t2[i2]) && (o2 = (n2 ? s2(e2, r2, o2) : s2(o2)) || o2);
  return n2 && o2 && T(e2, r2, o2), o2;
};
let yt = class extends _ {
  constructor() {
    super(...arguments), this.visible = 0, this.isExpanded = 0, this.isModalOpen = 0, this.isHovered = 0, this.isClicked = 0, this.searchQuery = "", this.comment = "", this.searchResults = null, this.isLoading = 0, this.recommendations = [], this.isLoadingRecommendations = 0, this.startingTourId = null, this.api = z();
  }
  connectedCallback() {
    super.connectedCallback(), this.unsubscribeUI = K.subscribe((t2) => {
      this.visible = t2.searchVisible, this.visible && 0 === this.recommendations.length && this.loadRecommendations();
    }), this.unsubscribeTour = Z.subscribe((t2) => {
      t2.isActive && (this.visible = 0);
    }), this.setupKeyboardShortcut();
  }
  disconnectedCallback() {
    var _a2, _b2;
    super.disconnectedCallback(), this.cleanupEventListeners(), (_a2 = this.unsubscribeUI) == null ? void 0 : _a2.call(this), (_b2 = this.unsubscribeTour) == null ? void 0 : _b2.call(this);
  }
  setupKeyboardShortcut() {
    this.keyboardHandler = (t2) => {
      (t2.metaKey || t2.ctrlKey) && "k" === t2.key ? (t2.preventDefault(), this.openModal()) : "Escape" === t2.key && (document.querySelector("sherpa-context-modal[visible]") || this.closeModal());
    }, document.addEventListener("keydown", this.keyboardHandler);
  }
  cleanupEventListeners() {
    this.keyboardHandler && document.removeEventListener("keydown", this.keyboardHandler);
  }
  loadRecommendations() {
    return __async(this, null, function* () {
      if (!this.isLoadingRecommendations) {
        this.isLoadingRecommendations = 1;
        try {
          const t2 = yield this.api.getRecommendations({ pathname: window.location.pathname, userId: void 0 });
          this.recommendations = t2.data || [];
        } catch (t2) {
          this.recommendations = [];
        } finally {
          this.isLoadingRecommendations = 0;
        }
      }
    });
  }
  openModal() {
    this.isClicked = 1, this.requestUpdate(), this.updateComplete.then(() => {
      requestAnimationFrame(() => {
        requestAnimationFrame(() => {
          this.isExpanded = 1, this.isClicked = 0, setTimeout(() => {
            this.isModalOpen = 1, this.focusSearchInput();
          }, 350);
        });
      });
    }), this.resetSearch();
  }
  closeModal() {
    requestAnimationFrame(() => {
      requestAnimationFrame(() => {
        this.isModalOpen = 0, setTimeout(() => {
          this.isExpanded = 0;
        }, 250);
      });
    }), this.resetSearch();
  }
  resetSearch() {
    this.searchQuery = "", this.searchResults = null, this.isLoading = 0, this.startingTourId = null;
  }
  focusSearchInput() {
    requestAnimationFrame(() => {
      setTimeout(() => {
        var _a2;
        (_a2 = this.searchInput) == null ? void 0 : _a2.focus(), this.searchInput && this.searchInput.setSelectionRange(this.searchInput.value.length, this.searchInput.value.length);
      }, 100);
    });
  }
  handleSearchBarClick() {
    this.isExpanded || this.openModal();
  }
  handleSearchBarMouseEnter() {
    this.isExpanded || (this.isHovered = 1);
  }
  handleSearchBarMouseLeave() {
    this.isHovered = 0;
  }
  handleInputChange(t2) {
    this.searchQuery = t2.target.value;
  }
  handleInputKeyDown(t2) {
    "Enter" !== t2.key || t2.shiftKey || (t2.preventDefault(), this.performSearch());
  }
  handleSearchButtonClick(t2) {
    if (!this.isExpanded) return t2.preventDefault(), void 0;
    t2.stopPropagation(), this.searchQuery.trim() && this.performSearch();
  }
  performSearch() {
    return __async(this, null, function* () {
      if (this.searchQuery.trim() && !this.isLoading) {
        this.isLoading = 1, this.searchResults = null;
        try {
          const t2 = yield this.api.search({ query: this.searchQuery, pathname: window.location.pathname, userId: void 0 });
          this.comment = t2.data.comment || "", this.searchResults = t2.data.results || [];
        } catch (t2) {
          this.searchResults = [];
        } finally {
          this.isLoading = 0;
        }
      }
    });
  }
  handleTourClick(t2) {
    "TOUR" === t2.type && t2.questions && t2.questions.length > 0 ? (this.dispatchEvent(new CustomEvent("open-context-modal", { detail: { tour: t2 }, bubbles: 1, composed: 1 })), this.closeModal()) : this.startTourDirectly(t2);
  }
  startTourDirectly(t2) {
    return __async(this, null, function* () {
      if (!this.startingTourId) {
        this.startingTourId = t2.id;
        try {
          this.dispatchEvent(new CustomEvent("start-tour", { detail: { tourId: t2.id, context: "", isDirect: 1, skipPersonalization: 1 }, bubbles: 1, composed: 1 }));
        } catch (e2) {
          this.startingTourId = null;
        }
      }
    });
  }
  handleDocsOpen(t2) {
    this.dispatchEvent(new CustomEvent("docs-open", { detail: { docs: t2 }, bubbles: 1, composed: 1 })), this.closeModal();
  }
  renderSearchIcon() {
    return D(_a || (_a = __template(['\n      <svg fill="none" stroke="currentColor" viewBox="0 0 24 24">\n        <path stroke-linecap="round" stroke-linejoin="round" d="M12 19V5M5 12l7-7 7 7" />\n      </svg>\n    '])));
  }
  renderPlayIcon() {
    return D(_b || (_b = __template(['\n      <svg fill="none" stroke="currentColor" viewBox="0 0 24 24">\n        <path stroke-linecap="round" stroke-linejoin="round" d="M5 3l14 9-14 9V3z" />\n      </svg>\n    '])));
  }
  renderDocsIcon() {
    return D(_c || (_c = __template(['\n      <svg\n        width="24"\n        height="24"\n        viewBox="0 0 24 24"\n        fill="none"\n        stroke="currentColor"\n        stroke-width="1.5"\n        stroke-linecap="round"\n        stroke-linejoin="round"\n        style="display: block"\n      >\n        <rect x="5" y="4" width="14" height="16" rx="2" />\n        <line x1="8" y1="9" x2="16" y2="9" />\n        <line x1="8" y1="13" x2="16" y2="13" />\n        <line x1="8" y1="17" x2="14" y2="17" />\n      </svg>\n    '])));
  }
  handleBackdropClick(t2) {
    t2.target === t2.currentTarget && this.closeModal();
  }
  render() {
    if (!this.visible) return D(_d || (_d = __template([""])));
    const t2 = ["search-bar", this.isExpanded && "expanded", this.isHovered && "hovered", this.isClicked && "clicked"].filter(Boolean).join(" "), e2 = ["search-container", this.isExpanded && "expanded"].filter(Boolean).join(" "), r2 = ["search-modal", this.isModalOpen && "visible"].filter(Boolean).join(" "), n2 = ["backdrop", this.isModalOpen && "modal-open"].filter(Boolean).join(" ");
    return D(_h || (_h = __template(["\n      ", '\n\n      <div class="', '">\n        <div\n          class="', '"\n          @click=', "\n          @mouseenter=", "\n          @mouseleave=", "\n        >\n          ", '\n\n          <button class="search-button" @click=', ' tabindex="-1">\n            ', '\n          </button>\n        </div>\n\n        <div class="', '" @click=', ">\n          ", "\n        </div>\n      </div>\n    "])), this.isModalOpen ? D(_e || (_e = __template(['<div class="', '" @click=', "></div>"])), n2, this.handleBackdropClick) : "", e2, t2, this.handleSearchBarClick, this.handleSearchBarMouseEnter, this.handleSearchBarMouseLeave, this.isExpanded ? D(_f || (_f = __template(['\n                <input\n                  class="search-input"\n                  type="text"\n                  placeholder="질문을 입력하세요..."\n                  .value=', "\n                  @input=", "\n                  @keydown=", "\n                />\n              "])), this.searchQuery, this.handleInputChange, this.handleInputKeyDown) : D(_g || (_g = __template([' <span class="search-placeholder">질문하기</span> ']))), this.handleSearchButtonClick, this.renderSearchIcon(), r2, (t3) => t3.stopPropagation(), this.renderModalContent());
  }
  renderModalContent() {
    return this.isLoading ? D(_i || (_i = __template(['\n        <div class="loading">\n          <div class="loading-spinner"></div>\n          <p>검색 중...</p>\n        </div>\n      ']))) : null !== this.searchResults ? this.renderSearchResults() : this.renderRecommendedContent();
  }
  renderSearchResults() {
    return this.searchResults && 0 !== this.searchResults.length ? D(_j || (_j = __template(['\n      <div class="modal-title">검색 결과</div>\n      <div class="comment">', '</div>\n      <div class="results-container">\n        ', "\n      </div>\n    "])), this.comment, this.searchResults.map((t2) => this.renderResultItem(t2))) : D(_k || (_k = __template(['\n        <div class="empty-state">\n          <div class="empty-title">검색 결과가 없습니다</div>\n          <div class="empty-description">다른 키워드로 검색해보세요</div>\n        </div>\n      '])));
  }
  renderResultItem(t2) {
    switch (t2.type) {
      case "DOCS":
        return this.renderDocsItem(t2);
      case "TOUR":
        return this.renderTourItem(t2);
      case "FAQ":
        return this.renderFAQItem(t2);
      default:
        return null;
    }
  }
  renderDocsItem(t2) {
    return D(_m || (_m = __template(['\n      <div\n        class="', '"\n        style="cursor: pointer;"\n        @click=', '\n      >\n        <div class="result-content">\n          <div class="result-title">', "</div>\n          ", '\n        </div>\n        <div class="result-action">\n          <button class="action-button docs" @click=', ">\n            ", ' <span class="action-button-text">문서</span>\n          </button>\n        </div>\n      </div>\n    '])), "result-item docs", () => this.handleDocsOpen(t2), t2.title, (t2 == null ? void 0 : t2.description) && D(_l || (_l = __template(['<div class="result-description">', "</div>"])), t2.description), () => this.handleDocsOpen(t2), this.renderDocsIcon());
  }
  renderTourItem(t2) {
    const e2 = this.startingTourId === t2.id;
    return D(_q || (_q = __template(['\n      <div\n        class="', '"\n        style="cursor: pointer;"\n        @click=', '\n      >\n        <div class="result-content">\n          <div class="result-title">', "</div>\n          ", '\n        </div>\n        <div class="result-action">\n          <button\n            class="action-button tour"\n            ?disabled=', "\n            @click=", "\n          >\n            ", "\n            ", "\n          </button>\n        </div>\n      </div>\n    "])), "result-item tour", () => this.handleTourClick(t2), t2.title, (t2 == null ? void 0 : t2.description) && D(_n || (_n = __template(['<div class="result-description">', "</div>"])), t2.description), e2, (e3) => {
      e3.stopPropagation(), this.handleTourClick(t2);
    }, e2 ? D(_o || (_o = __template(['<div class="loading-spinner-small"></div>']))) : this.renderPlayIcon(), e2 ? "" : D(_p || (_p = __template(['<span class="action-button-text">가이드</span>']))));
  }
  renderFAQItem(t2) {
    return D(_s || (_s = __template(['\n      <div class="', '" style="cursor: default; pointer-events: none; ">\n        <div class="result-content">\n          <div class="result-title" style="display: flex; align-items: center;">\n            <span class="', '" style="margin-right: 6px;;"> FAQ </span>\n            ', "\n          </div>\n          ", "\n        </div>\n      </div>\n    "])), "result-item faq", "type-badge faq", t2.title, (t2 == null ? void 0 : t2.description) && D(_r || (_r = __template(['<div class="result-description">', "</div>"])), t2.description));
  }
  renderRecommendedContent() {
    return D(_u || (_u = __template(['\n      <div class="recommended-section">\n        <div class="modal-title">추천 가이드</div>\n        ', "\n      </div>\n    "])), this.isLoadingRecommendations ? this.renderShimmerLoading() : D(_t || (_t = __template(['\n              <div class="results-container">\n                ', "\n              </div>\n            "])), this.recommendations.map((t2) => this.renderResultItem(t2))));
  }
  renderShimmerLoading() {
    return D(_w || (_w = __template(['\n      <div class="shimmer-container">\n        ', "\n      </div>\n    "])), [{ titleClass: "medium" }, { titleClass: "long" }, { titleClass: "short" }].map((t2) => D(_v || (_v = __template(['\n            <div class="shimmer-item">\n              <div class="shimmer-content">\n                <div class="shimmer-title ', '"></div>\n              </div>\n              <div class="shimmer-badge"></div>\n            </div>\n          '])), t2.titleClass)));
  }
  willUpdate(t2) {
    super.willUpdate(t2), t2.has("visible") && this.visible && 0 === this.recommendations.length && this.loadRecommendations(), t2.has("visible") && !this.visible && (this.startingTourId = null);
  }
};
yt.styles = O(_x || (_x = __template(["\n    ", "\n\n    :host {\n      --sherpa-primary: #3b82f6;\n      --sherpa-primary-hover: #2563eb;\n      --sherpa-success: #22c55e;\n      --sherpa-success-hover: #16a34a;\n      --sherpa-surface: rgba(31, 41, 55, 0.9);\n      --sherpa-surface-light: rgba(55, 65, 81, 0.9);\n      --sherpa-text: #ffffff;\n      --sherpa-text-muted: #d1d5db;\n      --sherpa-text-secondary: #9ca3af;\n      --sherpa-border: rgba(255, 255, 255, 0.2);\n      --sherpa-border-active: rgba(255, 255, 255, 0.4);\n      --sherpa-backdrop: rgba(0, 0, 0, 0.2);\n      --sherpa-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.4);\n\n      position: fixed;\n      top: 0;\n      left: 0;\n      right: 0;\n      bottom: 0;\n      z-index: 10000;\n      pointer-events: none;\n      font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n    }\n\n    .backdrop {\n      position: fixed;\n      inset: 0;\n      background: var(--sherpa-backdrop);\n      backdrop-filter: blur(4px);\n      -webkit-backdrop-filter: blur(4px);\n      opacity: 0;\n      visibility: hidden;\n      transition:\n        opacity 0.3s cubic-bezier(0.25, 0.8, 0.25, 1),\n        visibility 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);\n      -webkit-transition:\n        opacity 0.3s cubic-bezier(0.25, 0.8, 0.25, 1),\n        visibility 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);\n      pointer-events: none;\n      /* Force hardware acceleration for Safari */\n      will-change: opacity, visibility;\n      transform: translateZ(0);\n      -webkit-transform: translateZ(0);\n    }\n\n    /* Only show backdrop when modal is actually open, not just when search bar is visible */\n    .backdrop.modal-open {\n      opacity: 1;\n      visibility: visible;\n      pointer-events: auto;\n    }\n\n    .search-container {\n      position: fixed;\n      left: 50%;\n      transform: translateX(-50%) translateZ(0);\n      bottom: 1rem;\n      transition:\n        transform 0.4s cubic-bezier(0.25, 0.8, 0.25, 1),\n        bottom 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);\n      pointer-events: auto;\n      z-index: 10001;\n      /* Force hardware acceleration for Safari */\n      will-change: bottom, left;\n      -webkit-transform: translateX(-50%) translateZ(0);\n      -webkit-transition:\n        -webkit-transform 0.4s cubic-bezier(0.25, 0.8, 0.25, 1),\n        bottom 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);\n      /* Ensure Safari uses separate layer for container */\n      -webkit-backface-visibility: hidden;\n      backface-visibility: hidden;\n    }\n\n    .search-container.expanded {\n      bottom: 25%;\n      transform: translateX(-50%) translateY(50%) translateZ(0);\n      -webkit-transform: translateX(-50%) translateY(50%) translateZ(0);\n    }\n\n    .search-container.hidden {\n      opacity: 0;\n      visibility: hidden;\n      pointer-events: none;\n      transition:\n        opacity 0.3s cubic-bezier(0.25, 0.8, 0.25, 1),\n        visibility 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);\n      -webkit-transition:\n        opacity 0.3s cubic-bezier(0.25, 0.8, 0.25, 1),\n        visibility 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);\n    }\n\n    .search-bar {\n      display: flex;\n      align-items: center;\n      background: var(--sherpa-surface);\n      border: 1px solid var(--sherpa-border);\n      border-radius: 24px;\n      padding: 0 8px 0 24px;\n      backdrop-filter: blur(20px);\n      -webkit-backdrop-filter: blur(20px);\n      box-shadow: var(--sherpa-shadow);\n      transition:\n        width 0.35s cubic-bezier(0.25, 0.8, 0.25, 1),\n        transform 0.25s cubic-bezier(0.25, 0.8, 0.25, 1),\n        border-color 0.25s cubic-bezier(0.25, 0.8, 0.25, 1),\n        box-shadow 0.25s cubic-bezier(0.25, 0.8, 0.25, 1);\n      -webkit-transition:\n        width 0.35s cubic-bezier(0.25, 0.8, 0.25, 1),\n        -webkit-transform 0.25s cubic-bezier(0.25, 0.8, 0.25, 1),\n        border-color 0.25s cubic-bezier(0.25, 0.8, 0.25, 1),\n        box-shadow 0.25s cubic-bezier(0.25, 0.8, 0.25, 1);\n      min-height: 48px;\n      width: 200px;\n      cursor: pointer;\n      /* Force hardware acceleration for Safari */\n      will-change: width, border-color, box-shadow;\n      transform: translateZ(0);\n      -webkit-transform: translateZ(0);\n      /* Ensure Safari uses separate layer for search bar */\n      -webkit-backface-visibility: hidden;\n      backface-visibility: hidden;\n    }\n\n    .search-bar.expanded {\n      width: 500px;\n      cursor: text;\n      border-color: var(--sherpa-border-active);\n    }\n\n    .search-bar.hovered:not(.expanded) {\n      width: 220px;\n      transform: scale(1.02) translateZ(0);\n      -webkit-transform: scale(1.02) translateZ(0);\n      box-shadow: 0 20px 40px -12px rgba(0, 0, 0, 0.35);\n    }\n\n    .search-bar.clicked:not(.expanded) {\n      width: 190px;\n      transform: scale(0.98) translateZ(0);\n      -webkit-transform: scale(0.98) translateZ(0);\n    }\n\n    .search-input {\n      flex: 1;\n      background: transparent;\n      border: none;\n      outline: none;\n      color: var(--sherpa-text);\n      font-size: 16px;\n      font-weight: 500;\n      min-width: 0;\n    }\n\n    .search-input::placeholder {\n      color: var(--sherpa-text-secondary);\n    }\n\n    .search-placeholder {\n      color: var(--sherpa-text);\n      font-size: 16px;\n      font-weight: 500;\n      flex: 1;\n      min-width: 0;\n      user-select: none;\n    }\n\n    .search-button {\n      width: 32px;\n      height: 32px;\n      border-radius: 50%;\n      background: rgba(255, 255, 255, 0.2);\n      border: none;\n      display: flex;\n      align-items: center;\n      justify-content: center;\n      color: var(--sherpa-text);\n      cursor: pointer;\n      transition: all 0.2s ease;\n      margin-left: 12px;\n    }\n\n    .search-button:hover {\n      background: rgba(255, 255, 255, 0.3);\n    }\n\n    .search-button svg {\n      width: 20px;\n      height: 20px;\n      stroke-width: 2.5;\n    }\n\n    .search-modal {\n      position: absolute;\n      bottom: 100%;\n      left: 0;\n      right: 0;\n      margin-bottom: 20px;\n      background: var(--sherpa-surface);\n      backdrop-filter: blur(20px);\n      -webkit-backdrop-filter: blur(20px);\n      border: 1px solid var(--sherpa-border);\n      border-radius: 16px;\n      box-shadow: var(--sherpa-shadow);\n      padding: 32px;\n      max-height: 600px;\n      overflow-y: auto;\n      transform: translateY(-20px) translateZ(0);\n      -webkit-transform: translateY(-20px) translateZ(0);\n      opacity: 0;\n      visibility: hidden;\n      transition:\n        /* transform 0.2s cubic-bezier(0.25, 0.8, 0.25, 1), */\n        opacity 0.2s cubic-bezier(0.25, 0.8, 0.25, 1),\n        visibility 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);\n      -webkit-transition:\n        /* -webkit-transform 0.2s cubic-bezier(0.25, 0.8, 0.25, 1), */\n        opacity 0.2s cubic-bezier(0.25, 0.8, 0.25, 1),\n        visibility 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);\n      pointer-events: none;\n      /* Force hardware acceleration for Safari */\n      will-change: opacity, visibility;\n    }\n\n    .search-modal.visible {\n      transform: translateY(0) translateZ(0);\n      -webkit-transform: translateY(0) translateZ(0);\n      opacity: 1;\n      visibility: visible;\n      pointer-events: auto;\n    }\n\n    .modal-title {\n      color: var(--sherpa-text);\n      font-size: 20px;\n      font-weight: 600;\n      margin-bottom: 18px;\n    }\n\n    .comment {\n      color: var(--sherpa-text-muted);\n      font-size: 16px;\n      font-weight: 500;\n      margin-bottom: 24px;\n    }\n\n    .loading {\n      text-align: center;\n      padding: 48px 0;\n      color: var(--sherpa-text-muted);\n    }\n\n    .loading-spinner {\n      width: 32px;\n      height: 32px;\n      border: 2px solid var(--sherpa-text-secondary);\n      border-top: 2px solid var(--sherpa-primary);\n      border-radius: 50%;\n      animation: spin 1s linear infinite;\n      margin: 0 auto 16px;\n    }\n\n    .loading-spinner-small {\n      width: 16px;\n      height: 16px;\n      border: 2px solid var(--sherpa-text-secondary);\n      border-top: 2px solid var(--sherpa-primary);\n      border-radius: 50%;\n      animation: spin 1s linear infinite;\n    }\n\n    @keyframes spin {\n      0% {\n        transform: rotate(0deg);\n      }\n      100% {\n        transform: rotate(360deg);\n      }\n    }\n\n    .results-container {\n      display: flex;\n      flex-direction: column;\n      gap: 16px;\n      max-height: 400px;\n      overflow-y: auto;\n    }\n\n    .result-item {\n      display: flex;\n      align-items: center;\n      justify-content: space-between;\n      padding: 20px;\n      border: 2px solid var(--sherpa-border);\n      border-radius: 12px;\n      background: rgba(255, 255, 255, 0.05);\n      cursor: pointer;\n      transition: all 0.2s ease;\n    }\n\n    .result-item:hover {\n      background: rgba(255, 255, 255, 0.1);\n      border-color: var(--sherpa-border-active);\n    }\n\n    .result-item.tour {\n      border-color: rgba(59, 130, 246, 0.3);\n    }\n\n    .result-item.tour:hover {\n      border-color: rgba(59, 130, 246, 0.6);\n      background: rgba(59, 130, 246, 0.1);\n    }\n\n    .result-item.docs {\n      border-color: rgba(34, 197, 94, 0.3);\n    }\n\n    .result-item.docs:hover {\n      border-color: rgba(34, 197, 94, 0.6);\n      background: rgba(34, 197, 94, 0.1);\n    }\n\n    .result-item.faq {\n      border-color: rgba(168, 85, 247, 0.2);\n      background: rgba(168, 85, 247, 0.03);\n      cursor: default;\n      pointer-events: none;\n    }\n\n    .result-item.faq:hover {\n      border-color: rgba(168, 85, 247, 0.2);\n      background: rgba(168, 85, 247, 0.03);\n      transform: none;\n    }\n\n    .result-content {\n      flex: 1;\n    }\n\n    .result-title {\n      color: var(--sherpa-text);\n      font-size: 16px;\n      font-weight: 600;\n      margin-bottom: 8px;\n    }\n\n    .result-description {\n      color: var(--sherpa-text-muted);\n      font-size: 14px;\n      line-height: 1.5;\n    }\n\n    .result-action {\n      margin-left: 24px;\n    }\n\n    .action-button {\n      padding: 8px 16px;\n      border-radius: 8px;\n      border: none;\n      font-size: 14px;\n      font-weight: 600;\n      cursor: pointer;\n      transition: all 0.2s ease;\n      display: flex;\n      align-items: center;\n      gap: 8px;\n      justify-content: center;\n    }\n\n    .action-button.tour {\n      background: var(--sherpa-primary);\n      color: white;\n    }\n\n    .action-button.tour:hover {\n      background: var(--sherpa-primary-hover);\n    }\n\n    .action-button.docs {\n      background: var(--sherpa-success);\n      color: white;\n      gap: 7px;\n    }\n\n    .action-button.docs:hover {\n      background: var(--sherpa-success-hover);\n    }\n\n    .action-button svg {\n      width: 16px;\n      height: 16px;\n    }\n\n    .recommended-section {\n    }\n\n    .recommended-list {\n      display: flex;\n      flex-direction: column;\n      gap: 16px;\n    }\n\n    .recommended-item {\n      display: flex;\n      align-items: center;\n      justify-content: space-between;\n      padding: 16px;\n      border: 1px solid var(--sherpa-border);\n      border-radius: 12px;\n      background: rgba(255, 255, 255, 0.03);\n      cursor: pointer;\n      transition: all 0.2s ease;\n    }\n\n    .recommended-item:hover {\n      background: rgba(255, 255, 255, 0.08);\n    }\n\n    .recommended-title {\n      color: var(--sherpa-text);\n      font-size: 16px;\n      font-weight: 500;\n      flex: 1;\n    }\n\n    .type-badge {\n      display: inline-flex;\n      align-items: center;\n      gap: 4px;\n      padding: 4px 12px;\n      border-radius: 12px;\n      font-size: 12px;\n      font-weight: 600;\n      text-transform: uppercase;\n      border: 1px solid;\n    }\n\n    .type-badge.tour {\n      background: rgba(59, 130, 246, 0.2);\n      color: #93c5fd;\n      border-color: rgba(59, 130, 246, 0.4);\n    }\n\n    .type-badge.docs {\n      background: rgba(34, 197, 94, 0.2);\n      color: #86efac;\n      border-color: rgba(34, 197, 94, 0.4);\n    }\n\n    .type-badge.faq {\n      background: rgba(168, 85, 247, 0.1);\n      color: #a78bfa;\n      border-color: rgba(168, 85, 247, 0.25);\n      font-size: 11px;\n      padding: 2px 8px;\n      opacity: 0.8;\n    }\n\n    .type-badge svg {\n      width: 12px;\n      height: 12px;\n    }\n\n    .empty-state {\n      text-align: center;\n      padding: 48px 0;\n      color: var(--sherpa-text-muted);\n    }\n\n    .empty-title {\n      font-size: 18px;\n      font-weight: 600;\n      margin-bottom: 8px;\n    }\n\n    .empty-description {\n      font-size: 16px;\n    }\n\n    .example-section {\n      margin-top: 28px;\n      padding: 24px;\n      background: linear-gradient(135deg, rgba(59, 130, 246, 0.1), rgba(147, 197, 253, 0.1));\n      border: 1px solid rgba(59, 130, 246, 0.2);\n      border-radius: 12px;\n      backdrop-filter: blur(8px);\n    }\n\n    .example-text {\n      color: #93c5fd;\n      font-size: 16px;\n      line-height: 1.6;\n    }\n\n    .example-highlight {\n      color: #dbeafe;\n      font-weight: 600;\n    }\n\n    /* Shimmer loading styles */\n    .shimmer-container {\n      display: flex;\n      flex-direction: column;\n      gap: 16px;\n    }\n\n    .shimmer-item {\n      display: flex;\n      align-items: center;\n      justify-content: space-between;\n      padding: 16px;\n      border: 1px solid var(--sherpa-border);\n      border-radius: 12px;\n      background: rgba(255, 255, 255, 0.03);\n    }\n\n    .shimmer-content {\n      flex: 1;\n      display: flex;\n      flex-direction: column;\n      gap: 8px;\n    }\n\n    .action-button-text {\n      width: 39px;\n    }\n\n    .shimmer-title {\n      height: 20px;\n      background: linear-gradient(\n        90deg,\n        rgba(255, 255, 255, 0.1) 0%,\n        rgba(255, 255, 255, 0.2) 50%,\n        rgba(255, 255, 255, 0.1) 100%\n      );\n      border-radius: 4px;\n      animation: shimmer 1.5s ease-in-out infinite;\n    }\n\n    .shimmer-title.short {\n      width: 60%;\n    }\n\n    .shimmer-title.medium {\n      width: 80%;\n    }\n\n    .shimmer-title.long {\n      width: 90%;\n    }\n\n    .shimmer-badge {\n      width: 60px;\n      height: 24px;\n      background: linear-gradient(\n        90deg,\n        rgba(255, 255, 255, 0.1) 0%,\n        rgba(255, 255, 255, 0.2) 50%,\n        rgba(255, 255, 255, 0.1) 100%\n      );\n      border-radius: 12px;\n      animation: shimmer 1.5s ease-in-out infinite;\n    }\n\n    /* Custom Scrollbar for Windows (macOS-like) */\n    .search-modal::-webkit-scrollbar,\n    .results-container::-webkit-scrollbar {\n      width: 8px;\n    }\n\n    .search-modal::-webkit-scrollbar-track,\n    .results-container::-webkit-scrollbar-track {\n      background: transparent;\n    }\n\n    .search-modal::-webkit-scrollbar-thumb,\n    .results-container::-webkit-scrollbar-thumb {\n      background-color: transparent;\n      border-radius: 4px;\n      transition: background-color 0.2s ease-in-out;\n    }\n\n    .search-modal:hover::-webkit-scrollbar-thumb,\n    .results-container:hover::-webkit-scrollbar-thumb {\n      background-color: var(--sherpa-border-active);\n    }\n\n    /* For Firefox */\n    .search-modal,\n    .results-container {\n      scrollbar-width: thin;\n      scrollbar-color: transparent transparent;\n    }\n\n    .search-modal:hover,\n    .results-container:hover {\n      scrollbar-color: var(--sherpa-border-active) transparent;\n    }\n\n    @keyframes shimmer {\n      0% {\n        background-position: -200px 0;\n      }\n      100% {\n        background-position: calc(200px + 100%) 0;\n      }\n    }\n\n    .shimmer-title,\n    .shimmer-badge {\n      background-size: 200px 100%;\n    }\n\n    /* Safari-specific optimizations */\n    @supports (-webkit-backdrop-filter: blur(1px)) {\n      .search-bar,\n      .search-modal,\n      .backdrop {\n        /* Use webkit-backdrop-filter for better performance in Safari */\n        backdrop-filter: none;\n        -webkit-backdrop-filter: blur(20px);\n      }\n\n      .backdrop {\n        -webkit-backdrop-filter: blur(4px);\n      }\n    }\n\n    /* Prevent Safari scroll bouncing during animations */\n    @media screen and (-webkit-min-device-pixel-ratio: 0) {\n      :host {\n        -webkit-backface-visibility: hidden;\n        -webkit-perspective: 1000px;\n        -webkit-transform-style: preserve-3d;\n      }\n\n      .search-container,\n      .search-bar,\n      .search-modal {\n        -webkit-backface-visibility: hidden;\n        -webkit-perspective: 1000px;\n        -webkit-transform-style: preserve-3d;\n      }\n\n      /* Force separate compositing layers for smoother animations */\n      .search-container {\n        -webkit-isolation: isolate;\n        isolation: isolate;\n      }\n\n      .search-bar {\n        -webkit-isolation: isolate;\n        isolation: isolate;\n      }\n    }\n\n    @media (prefers-reduced-motion: reduce) {\n      * {\n        animation-duration: 0.01ms !important;\n        animation-iteration-count: 1 !important;\n        transition-duration: 0.01ms !important;\n        -webkit-transition-duration: 0.01ms !important;\n      }\n    }\n  "])), F), A([N({ type: Boolean })], yt.prototype, "visible", 2), A([P()], yt.prototype, "isExpanded", 2), A([P()], yt.prototype, "isModalOpen", 2), A([P()], yt.prototype, "isHovered", 2), A([P()], yt.prototype, "isClicked", 2), A([P()], yt.prototype, "searchQuery", 2), A([P()], yt.prototype, "comment", 2), A([P()], yt.prototype, "searchResults", 2), A([P()], yt.prototype, "isLoading", 2), A([P()], yt.prototype, "recommendations", 2), A([P()], yt.prototype, "isLoadingRecommendations", 2), A([P()], yt.prototype, "startingTourId", 2), A([B(".search-input")], yt.prototype, "searchInput", 2), yt = A([j("sherpa-search-modal")], yt), I = Object.defineProperty, L = Object.getOwnPropertyDescriptor, M = (t2, e2, r2, n2) => {
  var i2, s2, o2 = n2 > 1 ? void 0 : n2 ? L(e2, r2) : e2;
  for (i2 = t2.length - 1; i2 >= 0; i2--) (s2 = t2[i2]) && (o2 = (n2 ? s2(e2, r2, o2) : s2(o2)) || o2);
  return n2 && o2 && I(e2, r2, o2), o2;
};
let gt = class extends _ {
  constructor() {
    super(...arguments), this.visible = 0, this.context = "", this.isLoading = 0, this.keyboardHandler = (t2) => {
      "Escape" === t2.key ? this.handleClose() : "Enter" === t2.key && t2.ctrlKey && (t2.preventDefault(), this.handleStartTour());
    };
  }
  connectedCallback() {
    super.connectedCallback(), this.setupKeyboardHandlers();
  }
  disconnectedCallback() {
    super.disconnectedCallback(), this.cleanupKeyboardHandlers();
  }
  updated(t2) {
    super.updated(t2), t2.has("visible") && this.visible && this.focusTextarea();
  }
  setupKeyboardHandlers() {
    document.addEventListener("keydown", this.keyboardHandler);
  }
  cleanupKeyboardHandlers() {
    document.removeEventListener("keydown", this.keyboardHandler);
  }
  focusTextarea() {
    setTimeout(() => {
      var _a2;
      (_a2 = this.textarea) == null ? void 0 : _a2.focus();
    }, 200);
  }
  handleBackdropClick(t2) {
    t2.target === t2.currentTarget && this.handleClose();
  }
  handleInputChange(t2) {
    this.context = t2.target.value;
  }
  handleInputKeyDown(t2) {
    "Enter" === t2.key && t2.ctrlKey && (t2.preventDefault(), this.handleStartTour());
  }
  handleClose() {
    this.isLoading = 0, this.dispatchEvent(new CustomEvent("close-context-modal", { bubbles: 1, composed: 1 }));
  }
  handleStartTour() {
    var _a2;
    this.isLoading = 1, this.dispatchEvent(new CustomEvent("start-tour", { detail: { tourId: (_a2 = this.tourInfo) == null ? void 0 : _a2.id, context: this.context.trim(), isDirect: 0, skipPersonalization: 0 }, bubbles: 1, composed: 1 }));
  }
  resetLoading() {
    this.isLoading = 0;
  }
  renderPlayIcon() {
    return D(_y || (_y = __template(['\n      <svg fill="none" stroke="currentColor" viewBox="0 0 24 24">\n        <path stroke-linecap="round" stroke-linejoin="round" d="M5 3l14 9-14 9V3z" />\n      </svg>\n    '])));
  }
  renderChevronIcon() {
    return D(_z || (_z = __template(['\n      <svg fill="none" stroke="currentColor" viewBox="0 0 24 24">\n        <path stroke-linecap="round" stroke-linejoin="round" d="M9 5l7 7-7 7" />\n      </svg>\n    '])));
  }
  render() {
    return this.visible && this.tourInfo ? D(_E || (_E = __template(['\n      <div class="backdrop" @click=', '>\n        <div class="modal">\n          <div class="modal-header">\n            <div class="tour-icon">', '</div>\n            <div class="header-content">\n              <h2 class="modal-title">', '</h2>\n              <p class="modal-subtitle">투어 맞춤 설정</p>\n            </div>\n          </div>\n\n          <div class="modal-content">\n            <div class="guide-section">\n              <h3 class="guide-title">\n                💡 이런 정보를 알려주시면 더 맞춤형 가이드를 제공할 수 있어요\n              </h3>\n              <div class="guide-grid">\n                ', '\n              </div>\n            </div>\n\n            <div class="form-section">\n              <label class="form-label"> 상세 요청사항 (선택사항) </label>\n              <textarea\n                class="form-textarea"\n                .value=', "\n                @input=", "\n                @keydown=", '\n              ></textarea>\n              <p class="form-hint">Ctrl + Enter로 맞춤 투어를 시작할 수 있습니다</p>\n            </div>\n\n            <div class="modal-actions">\n              <button\n                class="action-button primary"\n                @click=', "\n                ?disabled=", "\n              >\n                ", "\n              </button>\n            </div>\n          </div>\n        </div>\n      </div>\n    "])), this.handleBackdropClick, this.renderPlayIcon(), this.tourInfo.title, this.tourInfo.questions && this.tourInfo.questions.length > 0 ? this.tourInfo.questions.map((t2) => D(_A || (_A = __template([' <div class="guide-item">• ', "</div> "])), t2)) : D(_B || (_B = __template(['\n                      <div class="guide-item">• 사용자 역할 (신입, 관리자, 팀장 등)</div>\n                      <div class="guide-item">• 부서 또는 팀 (인사팀, 회계팀 등)</div>\n                      <div class="guide-item">• 특별한 상황이나 요구사항</div>\n                      <div class="guide-item">• 중점적으로 알고 싶은 부분</div>\n                    ']))), this.context, this.handleInputChange, this.handleInputKeyDown, this.handleStartTour, this.isLoading, this.isLoading ? D(_C || (_C = __template(['<div class="loading-spinner"></div>\n                      로딩 중...']))) : D(_D || (_D = __template(["맞춤 투어 시작 ", ""])), this.renderChevronIcon())) : D(_F || (_F = __template([""])));
  }
};
gt.styles = O(_G || (_G = __template(["\n    ", "\n\n    :host {\n      --sherpa-primary: #3b82f6;\n      --sherpa-primary-hover: #2563eb;\n      --sherpa-surface: rgba(31, 41, 55, 0.95);\n      --sherpa-surface-light: rgba(59, 130, 246, 0.2);\n      --sherpa-text: #ffffff;\n      --sherpa-text-muted: #d1d5db;\n      --sherpa-text-secondary: #9ca3af;\n      --sherpa-border: rgba(255, 255, 255, 0.3);\n      --sherpa-border-active: rgba(255, 255, 255, 0.4);\n      --sherpa-backdrop: rgba(0, 0, 0, 0.5);\n      --sherpa-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);\n\n      position: fixed;\n      top: 0;\n      left: 0;\n      right: 0;\n      bottom: 0;\n      z-index: 20000;\n      display: flex;\n      align-items: center;\n      justify-content: center;\n      padding: 16px;\n      font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n    }\n\n    /* Enable pointer events when visible */\n    :host([visible]) {\n      pointer-events: auto;\n    }\n\n    .backdrop {\n      position: fixed;\n      inset: 0;\n      background: var(--sherpa-backdrop);\n      backdrop-filter: blur(4px);\n      animation: fadeIn 0.2s ease-out;\n      pointer-events: auto;\n    }\n\n    .modal {\n      left: 50%;\n      top: 50%;\n      transform: translateX(-50%) translateY(-50%);\n      position: relative;\n      background: var(--sherpa-surface);\n      backdrop-filter: blur(24px);\n      border: 1px solid var(--sherpa-border);\n      border-radius: 16px;\n      box-shadow: var(--sherpa-shadow);\n      width: 100%;\n      max-width: 672px;\n      padding: 32px;\n      pointer-events: auto;\n    }\n\n    .modal-header {\n      display: flex;\n      align-items: center;\n      gap: 12px;\n      margin-bottom: 24px;\n    }\n\n    .tour-icon {\n      width: 48px;\n      height: 48px;\n      border-radius: 50%;\n      background: var(--sherpa-surface-light);\n      display: flex;\n      align-items: center;\n      justify-content: center;\n      color: var(--sherpa-primary);\n    }\n\n    .tour-icon svg {\n      width: 24px;\n      height: 24px;\n    }\n\n    .header-content {\n      flex: 1;\n    }\n\n    .modal-title {\n      color: var(--sherpa-text);\n      font-size: 20px;\n      font-weight: 600;\n      margin-bottom: 4px;\n    }\n\n    .modal-subtitle {\n      color: var(--sherpa-text-secondary);\n      font-size: 14px;\n    }\n\n    .modal-content {\n      display: flex;\n      flex-direction: column;\n      gap: 24px;\n    }\n\n    .guide-section {\n      background: rgba(30, 58, 138, 0.2);\n      border: 1px solid rgba(59, 130, 246, 0.3);\n      border-radius: 12px;\n      padding: 16px;\n    }\n\n    .guide-title {\n      color: #93c5fd;\n      font-size: 14px;\n      font-weight: 500;\n      margin-top: 0;\n      margin-bottom: 12px;\n    }\n\n    .guide-grid {\n      display: grid;\n      grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));\n      gap: 8px;\n    }\n\n    .guide-item {\n      color: var(--sherpa-text-muted);\n      font-size: 14px;\n      line-height: 1.4;\n    }\n\n    .form-section {\n      display: flex;\n      flex-direction: column;\n    }\n\n    .form-label {\n      display: block;\n      color: var(--sherpa-text-muted);\n      font-size: 14px;\n      font-weight: 500;\n      margin-bottom: 12px;\n    }\n\n    .form-textarea {\n      height: 128px;\n      padding: 12px 16px;\n      background: rgba(255, 255, 255, 0.1);\n      border: 1px solid rgba(255, 255, 255, 0.2);\n      border-radius: 12px;\n      color: var(--sherpa-text);\n      font-size: 14px;\n      line-height: 1.5;\n      resize: none;\n      transition: all 0.2s ease;\n      font-family: inherit;\n    }\n\n    .form-textarea::placeholder {\n      color: #9ca3af;\n    }\n\n    .form-textarea:focus {\n      outline: none;\n      border-color: transparent;\n      box-shadow: 0 0 0 2px var(--sherpa-primary);\n    }\n\n    .form-hint {\n      color: #6b7280;\n      font-size: 12px;\n      margin-top: 8px;\n    }\n\n    .modal-actions {\n      display: flex;\n      gap: 12px;\n    }\n\n    .action-button {\n      flex: 1;\n      height: 48px;\n      border: none;\n      border-radius: 8px;\n      font-size: 14px;\n      font-weight: 600;\n      cursor: pointer;\n      transition: all 0.2s ease;\n      display: flex;\n      align-items: center;\n      justify-content: center;\n      gap: 8px;\n    }\n\n    .action-button:disabled {\n      opacity: 0.5;\n      cursor: not-allowed;\n    }\n\n    .action-button.secondary {\n      background: white;\n      color: black;\n      border: 1px solid #9ca3af;\n    }\n\n    .action-button.secondary:hover:not(:disabled) {\n      background: #f3f4f6;\n    }\n\n    .action-button.primary {\n      background: #2563eb;\n      color: white;\n    }\n\n    .action-button.primary:hover:not(:disabled) {\n      background: #1d4ed8;\n    }\n\n    .action-button svg {\n      width: 16px;\n      height: 16px;\n    }\n\n    .loading-spinner {\n      width: 16px;\n      height: 16px;\n      border: 2px solid transparent;\n      border-top: 2px solid currentColor;\n      border-radius: 50%;\n      animation: spin 1s linear infinite;\n    }\n\n    @keyframes spin {\n      0% {\n        transform: rotate(0deg);\n      }\n      100% {\n        transform: rotate(360deg);\n      }\n    }\n\n    @keyframes fadeIn {\n      from {\n        opacity: 0;\n      }\n      to {\n        opacity: 1;\n      }\n    }\n\n    @keyframes slideIn {\n      from {\n        opacity: 0;\n        transform: scale(0.95);\n      }\n      to {\n        opacity: 1;\n        transform: scale(1);\n      }\n    }\n\n    /* Hide when not visible */\n    :host(:not([visible])) {\n      display: none !important;\n    }\n\n    @media (max-width: 768px) {\n      .guide-grid {\n        grid-template-columns: 1fr;\n      }\n    }\n\n    @media (prefers-reduced-motion: reduce) {\n      .backdrop,\n      .modal {\n        animation: none;\n      }\n    }\n  "])), F), M([N({ type: Boolean, reflect: 1 })], gt.prototype, "visible", 2), M([N({ type: Object })], gt.prototype, "tourInfo", 2), M([P()], gt.prototype, "context", 2), M([P()], gt.prototype, "isLoading", 2), M([B(".form-textarea")], gt.prototype, "textarea", 2), gt = M([j("sherpa-context-modal")], gt), C = Object.defineProperty, H = Object.getOwnPropertyDescriptor, R = (t2, e2, r2, n2) => {
  var i2, s2, o2 = n2 > 1 ? void 0 : n2 ? H(e2, r2) : e2;
  for (i2 = t2.length - 1; i2 >= 0; i2--) (s2 = t2[i2]) && (o2 = (n2 ? s2(e2, r2, o2) : s2(o2)) || o2);
  return n2 && o2 && C(e2, r2, o2), o2;
};
let vt = class extends _ {
  constructor() {
    super(...arguments), this.visible = 0, this.showContextModal = 0, this.tourController = bt.getInstance(), this.handleContextModalOpen = (t2) => {
      const e2 = t2, { tour: r2 } = e2.detail;
      this.selectedTour = r2, this.showContextModal = 1;
    }, this.handleContextModalClose = () => {
      this.resetModals();
    }, this.handleStartTour = (t2) => __async(this, null, function* () {
      const e2 = t2, { tourId: r2, context: n2, isDirect: i2 = 0, skipPersonalization: s2 = 0 } = e2.detail;
      try {
        yield this.tourController.startTour(r2, n2, { startedFromSearch: 1, isDirect: i2, skipPersonalization: s2 }), this.resetModals(), J.hideSearch(), this.notifySearchModalTourStarted();
      } catch (o2) {
        this.notifySearchModalTourStarted();
      }
    });
  }
  connectedCallback() {
    super.connectedCallback(), this.unsubscribeUI = K.subscribe((t2) => {
      this.visible = t2.searchVisible, this.visible || this.resetModals();
    }), this.unsubscribeTour = Z.subscribe((t2) => {
      t2.isActive && this.visible && J.hideSearch();
    }), this.setupGlobalEventListeners();
  }
  disconnectedCallback() {
    var _a2, _b2;
    super.disconnectedCallback(), (_a2 = this.unsubscribeUI) == null ? void 0 : _a2.call(this), (_b2 = this.unsubscribeTour) == null ? void 0 : _b2.call(this), this.cleanupGlobalEventListeners();
  }
  setupGlobalEventListeners() {
    this.addEventListener("open-context-modal", this.handleContextModalOpen), this.addEventListener("close-context-modal", this.handleContextModalClose), this.addEventListener("start-tour", this.handleStartTour);
  }
  cleanupGlobalEventListeners() {
    this.removeEventListener("open-context-modal", this.handleContextModalOpen), this.removeEventListener("close-context-modal", this.handleContextModalClose), this.removeEventListener("start-tour", this.handleStartTour);
  }
  resetModals() {
    this.showContextModal = 0, this.selectedTour = void 0;
  }
  notifySearchModalTourStarted() {
    const t2 = this.querySelector("sherpa-search-modal");
    t2 && (t2.startingTourId = null, t2.closeModal());
  }
  render() {
    return D(_H || (_H = __template(["\n      <sherpa-search-modal .visible=", "></sherpa-search-modal>\n\n      <sherpa-context-modal\n        .visible=", "\n        .tourInfo=", "\n      ></sherpa-context-modal>\n    "])), this.visible, this.showContextModal, this.selectedTour);
  }
};
vt.styles = O(_I || (_I = __template(["\n    :host {\n      position: fixed;\n      top: 0;\n      left: 0;\n      width: 100%;\n      height: 100%;\n      pointer-events: none;\n      z-index: 999999;\n    }\n\n    sherpa-search-modal,\n    sherpa-context-modal,\n    sherpa-docs {\n      /* pointer-events: auto; */\n    }\n  "]))), R([N({ type: Boolean, reflect: 1 })], vt.prototype, "visible", 2), R([P()], vt.prototype, "showContextModal", 2), R([P()], vt.prototype, "selectedTour", 2), vt = R([j("sherpa-search")], vt);
const xt = Object.freeze({ __proto__: null, get SherpaSearch() {
  return vt;
}, get SherpaSearchModal() {
  return yt;
} });
export {
  bt as T,
  J as a,
  X as b,
  Q as c,
  W as d,
  Y as e,
  xt as f,
  G as i,
  Z as t,
  K as u
};