import { computed, ref, reactive, watch, unref, getCurrentScope, onScopeDispose } from "vue";
const D = typeof window < "u";
var pt;
D && ((pt = window == null ? void 0 : window.navigator) != null && pt.userAgent) && /iP(ad|hone|od)/.test(window.navigator.userAgent);
function Be(e) {
  return e != null;
}
function P() {
}
const xn = Object.freeze({
  aliceblue: "f0f8ff",
  antiquewhite: "faebd7",
  aqua: "0ff",
  aquamarine: "7fffd4",
  azure: "f0ffff",
  beige: "f5f5dc",
  bisque: "ffe4c4",
  black: "000",
  blanchedalmond: "ffebcd",
  blue: "00f",
  blueviolet: "8a2be2",
  brown: "a52a2a",
  burlywood: "deb887",
  burntsienna: "ea7e5d",
  cadetblue: "5f9ea0",
  chartreuse: "7fff00",
  chocolate: "d2691e",
  coral: "ff7f50",
  cornflowerblue: "6495ed",
  cornsilk: "fff8dc",
  crimson: "dc143c",
  cyan: "0ff",
  darkblue: "00008b",
  darkcyan: "008b8b",
  darkgoldenrod: "b8860b",
  darkgray: "a9a9a9",
  darkgreen: "006400",
  darkgrey: "a9a9a9",
  darkkhaki: "bdb76b",
  darkmagenta: "8b008b",
  darkolivegreen: "556b2f",
  darkorange: "ff8c00",
  darkorchid: "9932cc",
  darkred: "8b0000",
  darksalmon: "e9967a",
  darkseagreen: "8fbc8f",
  darkslateblue: "483d8b",
  darkslategray: "2f4f4f",
  darkslategrey: "2f4f4f",
  darkturquoise: "00ced1",
  darkviolet: "9400d3",
  deeppink: "ff1493",
  deepskyblue: "00bfff",
  dimgray: "696969",
  dimgrey: "696969",
  dodgerblue: "1e90ff",
  firebrick: "b22222",
  floralwhite: "fffaf0",
  forestgreen: "228b22",
  fuchsia: "f0f",
  gainsboro: "dcdcdc",
  ghostwhite: "f8f8ff",
  gold: "ffd700",
  goldenrod: "daa520",
  gray: "808080",
  green: "008000",
  greenyellow: "adff2f",
  grey: "808080",
  honeydew: "f0fff0",
  hotpink: "ff69b4",
  indianred: "cd5c5c",
  indigo: "4b0082",
  ivory: "fffff0",
  khaki: "f0e68c",
  lavender: "e6e6fa",
  lavenderblush: "fff0f5",
  lawngreen: "7cfc00",
  lemonchiffon: "fffacd",
  lightblue: "add8e6",
  lightcoral: "f08080",
  lightcyan: "e0ffff",
  lightgoldenrodyellow: "fafad2",
  lightgray: "d3d3d3",
  lightgreen: "90ee90",
  lightgrey: "d3d3d3",
  lightpink: "ffb6c1",
  lightsalmon: "ffa07a",
  lightseagreen: "20b2aa",
  lightskyblue: "87cefa",
  lightslategray: "789",
  lightslategrey: "789",
  lightsteelblue: "b0c4de",
  lightyellow: "ffffe0",
  lime: "0f0",
  limegreen: "32cd32",
  linen: "faf0e6",
  magenta: "f0f",
  maroon: "800000",
  mediumaquamarine: "66cdaa",
  mediumblue: "0000cd",
  mediumorchid: "ba55d3",
  mediumpurple: "9370db",
  mediumseagreen: "3cb371",
  mediumslateblue: "7b68ee",
  mediumspringgreen: "00fa9a",
  mediumturquoise: "48d1cc",
  mediumvioletred: "c71585",
  midnightblue: "191970",
  mintcream: "f5fffa",
  mistyrose: "ffe4e1",
  moccasin: "ffe4b5",
  navajowhite: "ffdead",
  navy: "000080",
  oldlace: "fdf5e6",
  olive: "808000",
  olivedrab: "6b8e23",
  orange: "ffa500",
  orangered: "ff4500",
  orchid: "da70d6",
  palegoldenrod: "eee8aa",
  palegreen: "98fb98",
  paleturquoise: "afeeee",
  palevioletred: "db7093",
  papayawhip: "ffefd5",
  peachpuff: "ffdab9",
  peru: "cd853f",
  pink: "ffc0cb",
  plum: "dda0dd",
  powderblue: "b0e0e6",
  purple: "800080",
  rebeccapurple: "663399",
  red: "f00",
  rosybrown: "bc8f8f",
  royalblue: "4169e1",
  saddlebrown: "8b4513",
  salmon: "fa8072",
  sandybrown: "f4a460",
  seagreen: "2e8b57",
  seashell: "fff5ee",
  sienna: "a0522d",
  silver: "c0c0c0",
  skyblue: "87ceeb",
  slateblue: "6a5acd",
  slategray: "708090",
  slategrey: "708090",
  snow: "fffafa",
  springgreen: "00ff7f",
  steelblue: "4682b4",
  tan: "d2b48c",
  teal: "008080",
  thistle: "d8bfd8",
  tomato: "ff6347",
  turquoise: "40e0d0",
  violet: "ee82ee",
  wheat: "f5deb3",
  white: "fff",
  whitesmoke: "f5f5f5",
  yellow: "ff0",
  yellowgreen: "9acd32"
});
Object.freeze(new Set(Object.keys(xn)));
const Tn = D && ("ontouchstart" in window || On() > 0), Sn = Tn ? "pointerdown" : "click";
function On() {
  return typeof navigator < "u" && (navigator.maxTouchPoints || navigator.msMaxTouchPoints) || 0;
}
function zn(e, t, n = window.Event) {
  const { type: r, bubbles: o = false, cancelable: i = false, ...s } = t;
  if (!Be(r) || r === "") return false;
  let c;
  return Be(n) ? c = new n(r, { bubbles: o, cancelable: i }) : (c = document.createEvent("HTMLEvents"), c.initEvent(r, o, i)), Object.assign(c, s), e.dispatchEvent(c);
}
const qt = "clickoutside", Ue = /* @__PURE__ */ new Set();
D && document.addEventListener(
  Sn,
  (e) => {
    const t = e.target, n = e.composedPath && e.composedPath();
    Ue.forEach((r) => {
      r !== t && (n ? !n.includes(r) : !r.contains(t)) && (!r.__transferElement || r.__transferElement !== t && !r.__transferElement.contains(t)) && zn(r, { type: qt });
    });
  },
  true
);
const Ln = [
  [
    "requestFullscreen",
    "exitFullscreen",
    "fullscreenElement",
    "fullscreenEnabled",
    "fullscreenchange",
    "fullscreenerror"
  ],
  // New WebKit
  [
    "webkitRequestFullscreen",
    "webkitExitFullscreen",
    "webkitFullscreenElement",
    "webkitFullscreenEnabled",
    "webkitfullscreenchange",
    "webkitfullscreenerror"
  ],
  // Old WebKit
  [
    "webkitRequestFullScreen",
    "webkitCancelFullScreen",
    "webkitCurrentFullScreenElement",
    "webkitCancelFullScreen",
    "webkitfullscreenchange",
    "webkitfullscreenerror"
  ],
  [
    "mozRequestFullScreen",
    "mozCancelFullScreen",
    "mozFullScreenElement",
    "mozFullScreenEnabled",
    "mozfullscreenchange",
    "mozfullscreenerror"
  ],
  [
    "msRequestFullscreen",
    "msExitFullscreen",
    "msFullscreenElement",
    "msFullscreenEnabled",
    "MSFullscreenChange",
    "MSFullscreenError"
  ]
];
let ae;
if (D) {
  for (const e of Ln)
    if (e[1] in document) {
      ae = e;
      break;
    }
}
({
  full: computed(() => false)
});
const Xt = /* @__PURE__ */ new Set(), Je = /* @__PURE__ */ new WeakMap();
if (D && ae) {
  const e = ae[2], t = ae[4];
  document.addEventListener(
    t,
    () => {
      if (Xt.forEach((n) => {
        n.value = false;
      }), document[e]) {
        const n = Je.get(document[e]);
        n && (n.value = true);
      }
    },
    false
  );
}
const Z = /* @__PURE__ */ new Map();
Z.set("x", 0);
Z.set("y", 0);
var re = [], Or = function() {
  return re.some(function(e) {
    return e.activeTargets.length > 0;
  });
}, zr = function() {
  return re.some(function(e) {
    return e.skippedTargets.length > 0;
  });
}, Ot = "ResizeObserver loop completed with undelivered notifications.", kr = function() {
  var e;
  typeof ErrorEvent == "function" ? e = new ErrorEvent("error", {
    message: Ot
  }) : (e = document.createEvent("Event"), e.initEvent("error", false, false), e.message = Ot), window.dispatchEvent(e);
}, we;
(function(e) {
  e.BORDER_BOX = "border-box", e.CONTENT_BOX = "content-box", e.DEVICE_PIXEL_CONTENT_BOX = "device-pixel-content-box";
})(we || (we = {}));
var oe = function(e) {
  return Object.freeze(e);
}, Ar = /* @__PURE__ */ function() {
  function e(t, n) {
    this.inlineSize = t, this.blockSize = n, oe(this);
  }
  return e;
}(), on = function() {
  function e(t, n, r, o) {
    return this.x = t, this.y = n, this.width = r, this.height = o, this.top = this.y, this.left = this.x, this.bottom = this.top + this.height, this.right = this.left + this.width, oe(this);
  }
  return e.prototype.toJSON = function() {
    var t = this, n = t.x, r = t.y, o = t.top, i = t.right, s = t.bottom, c = t.left, a = t.width, l = t.height;
    return { x: n, y: r, top: o, right: i, bottom: s, left: c, width: a, height: l };
  }, e.fromRect = function(t) {
    return new e(t.x, t.y, t.width, t.height);
  }, e;
}(), dt = function(e) {
  return e instanceof SVGElement && "getBBox" in e;
}, sn = function(e) {
  if (dt(e)) {
    var t = e.getBBox(), n = t.width, r = t.height;
    return !n && !r;
  }
  var o = e, i = o.offsetWidth, s = o.offsetHeight;
  return !(i || s || e.getClientRects().length);
}, zt = function(e) {
  var t;
  if (e instanceof Element)
    return true;
  var n = (t = e == null ? void 0 : e.ownerDocument) === null || t === void 0 ? void 0 : t.defaultView;
  return !!(n && e instanceof n.Element);
}, Cr = function(e) {
  switch (e.tagName) {
    case "INPUT":
      if (e.type !== "image")
        break;
    case "VIDEO":
    case "AUDIO":
    case "EMBED":
    case "OBJECT":
    case "CANVAS":
    case "IFRAME":
    case "IMG":
      return true;
  }
  return false;
}, ge = typeof window < "u" ? window : {}, ke = /* @__PURE__ */ new WeakMap(), kt = /auto|scroll/, Mr = /^tb|vertical/, Lr = /msie|trident/i.test(ge.navigator && ge.navigator.userAgent), X = function(e) {
  return parseFloat(e || "0");
}, fe = function(e, t, n) {
  return e === void 0 && (e = 0), t === void 0 && (t = 0), n === void 0 && (n = false), new Ar((n ? t : e) || 0, (n ? e : t) || 0);
}, At = oe({
  devicePixelContentBoxSize: fe(),
  borderBoxSize: fe(),
  contentBoxSize: fe(),
  contentRect: new on(0, 0, 0, 0)
}), cn = function(e, t) {
  if (t === void 0 && (t = false), ke.has(e) && !t)
    return ke.get(e);
  if (sn(e))
    return ke.set(e, At), At;
  var n = getComputedStyle(e), r = dt(e) && e.ownerSVGElement && e.getBBox(), o = !Lr && n.boxSizing === "border-box", i = Mr.test(n.writingMode || ""), s = !r && kt.test(n.overflowY || ""), c = !r && kt.test(n.overflowX || ""), a = r ? 0 : X(n.paddingTop), l = r ? 0 : X(n.paddingRight), f = r ? 0 : X(n.paddingBottom), d = r ? 0 : X(n.paddingLeft), v = r ? 0 : X(n.borderTopWidth), m = r ? 0 : X(n.borderRightWidth), b = r ? 0 : X(n.borderBottomWidth), g = r ? 0 : X(n.borderLeftWidth), p = d + l, h = a + f, u = g + m, y = v + b, O = c ? e.offsetHeight - y - e.clientHeight : 0, T = s ? e.offsetWidth - u - e.clientWidth : 0, S = o ? p + u : 0, C = o ? h + y : 0, k = r ? r.width : X(n.width) - S - T, M = r ? r.height : X(n.height) - C - O, L = k + p + T + u, $ = M + h + O + y, _ = oe({
    devicePixelContentBoxSize: fe(Math.round(k * devicePixelRatio), Math.round(M * devicePixelRatio), i),
    borderBoxSize: fe(L, $, i),
    contentBoxSize: fe(k, M, i),
    contentRect: new on(d, a, k, M)
  });
  return ke.set(e, _), _;
}, an = function(e, t, n) {
  var r = cn(e, n), o = r.borderBoxSize, i = r.contentBoxSize, s = r.devicePixelContentBoxSize;
  switch (t) {
    case we.DEVICE_PIXEL_CONTENT_BOX:
      return s;
    case we.BORDER_BOX:
      return o;
    default:
      return i;
  }
}, Br = /* @__PURE__ */ function() {
  function e(t) {
    var n = cn(t);
    this.target = t, this.contentRect = n.contentRect, this.borderBoxSize = oe([n.borderBoxSize]), this.contentBoxSize = oe([n.contentBoxSize]), this.devicePixelContentBoxSize = oe([n.devicePixelContentBoxSize]);
  }
  return e;
}(), ln = function(e) {
  if (sn(e))
    return 1 / 0;
  for (var t = 0, n = e.parentNode; n; )
    t += 1, n = n.parentNode;
  return t;
}, Pr = function() {
  var e = 1 / 0, t = [];
  re.forEach(function(s) {
    if (s.activeTargets.length !== 0) {
      var c = [];
      s.activeTargets.forEach(function(l) {
        var f = new Br(l.target), d = ln(l.target);
        c.push(f), l.lastReportedSize = an(l.target, l.observedBox), d < e && (e = d);
      }), t.push(function() {
        s.callback.call(s.observer, c, s.observer);
      }), s.activeTargets.splice(0, s.activeTargets.length);
    }
  });
  for (var n = 0, r = t; n < r.length; n++) {
    var o = r[n];
    o();
  }
  return e;
}, Ct = function(e) {
  re.forEach(function(n) {
    n.activeTargets.splice(0, n.activeTargets.length), n.skippedTargets.splice(0, n.skippedTargets.length), n.observationTargets.forEach(function(o) {
      o.isActive() && (ln(o.target) > e ? n.activeTargets.push(o) : n.skippedTargets.push(o));
    });
  });
}, Fr = function() {
  var e = 0;
  for (Ct(e); Or(); )
    e = Pr(), Ct(e);
  return zr() && kr(), e > 0;
}, je, fn = [], Dr = function() {
  return fn.splice(0).forEach(function(e) {
    return e();
  });
}, _r = function(e) {
  if (!je) {
    var t = 0, n = document.createTextNode(""), r = { characterData: true };
    new MutationObserver(function() {
      return Dr();
    }).observe(n, r), je = function() {
      n.textContent = "".concat(t ? t-- : t++);
    };
  }
  fn.push(e), je();
}, Nr = function(e) {
  _r(function() {
    requestAnimationFrame(e);
  });
}, Me = 0, Wr = function() {
  return !!Me;
}, Ir = 250, Hr = { attributes: true, characterData: true, childList: true, subtree: true }, Mt = [
  "resize",
  "load",
  "transitionend",
  "animationend",
  "animationstart",
  "animationiteration",
  "keyup",
  "keydown",
  "mouseup",
  "mousedown",
  "mouseover",
  "mouseout",
  "blur",
  "focus"
], Lt = function(e) {
  return e === void 0 && (e = 0), Date.now() + e;
}, Ye = false, $r = function() {
  function e() {
    var t = this;
    this.stopped = true, this.listener = function() {
      return t.schedule();
    };
  }
  return e.prototype.run = function(t) {
    var n = this;
    if (t === void 0 && (t = Ir), !Ye) {
      Ye = true;
      var r = Lt(t);
      Nr(function() {
        var o = false;
        try {
          o = Fr();
        } finally {
          if (Ye = false, t = r - Lt(), !Wr())
            return;
          o ? n.run(1e3) : t > 0 ? n.run(t) : n.start();
        }
      });
    }
  }, e.prototype.schedule = function() {
    this.stop(), this.run();
  }, e.prototype.observe = function() {
    var t = this, n = function() {
      return t.observer && t.observer.observe(document.body, Hr);
    };
    document.body ? n() : ge.addEventListener("DOMContentLoaded", n);
  }, e.prototype.start = function() {
    var t = this;
    this.stopped && (this.stopped = false, this.observer = new MutationObserver(this.listener), this.observe(), Mt.forEach(function(n) {
      return ge.addEventListener(n, t.listener, true);
    }));
  }, e.prototype.stop = function() {
    var t = this;
    this.stopped || (this.observer && this.observer.disconnect(), Mt.forEach(function(n) {
      return ge.removeEventListener(n, t.listener, true);
    }), this.stopped = true);
  }, e;
}(), tt = new $r(), Bt = function(e) {
  !Me && e > 0 && tt.start(), Me += e, !Me && tt.stop();
}, qr = function(e) {
  return !dt(e) && !Cr(e) && getComputedStyle(e).display === "inline";
}, Vr = function() {
  function e(t, n) {
    this.target = t, this.observedBox = n || we.CONTENT_BOX, this.lastReportedSize = {
      inlineSize: 0,
      blockSize: 0
    };
  }
  return e.prototype.isActive = function() {
    var t = an(this.target, this.observedBox, true);
    return qr(this.target) && (this.lastReportedSize = t), this.lastReportedSize.inlineSize !== t.inlineSize || this.lastReportedSize.blockSize !== t.blockSize;
  }, e;
}(), Xr = /* @__PURE__ */ function() {
  function e(t, n) {
    this.activeTargets = [], this.skippedTargets = [], this.observationTargets = [], this.observer = t, this.callback = n;
  }
  return e;
}(), Ae = /* @__PURE__ */ new WeakMap(), Pt = function(e, t) {
  for (var n = 0; n < e.length; n += 1)
    if (e[n].target === t)
      return n;
  return -1;
}, Ce = function() {
  function e() {
  }
  return e.connect = function(t, n) {
    var r = new Xr(t, n);
    Ae.set(t, r);
  }, e.observe = function(t, n, r) {
    var o = Ae.get(t), i = o.observationTargets.length === 0;
    Pt(o.observationTargets, n) < 0 && (i && re.push(o), o.observationTargets.push(new Vr(n, r && r.box)), Bt(1), tt.schedule());
  }, e.unobserve = function(t, n) {
    var r = Ae.get(t), o = Pt(r.observationTargets, n), i = r.observationTargets.length === 1;
    o >= 0 && (i && re.splice(re.indexOf(r), 1), r.observationTargets.splice(o, 1), Bt(-1));
  }, e.disconnect = function(t) {
    var n = this, r = Ae.get(t);
    r.observationTargets.slice().forEach(function(o) {
      return n.unobserve(t, o.target);
    }), r.activeTargets.splice(0, r.activeTargets.length);
  }, e;
}(), Ft = function() {
  function e(t) {
    if (arguments.length === 0)
      throw new TypeError("Failed to construct 'ResizeObserver': 1 argument required, but only 0 present.");
    if (typeof t != "function")
      throw new TypeError("Failed to construct 'ResizeObserver': The callback provided as parameter 1 is not a function.");
    Ce.connect(this, t);
  }
  return e.prototype.observe = function(t, n) {
    if (arguments.length === 0)
      throw new TypeError("Failed to execute 'observe' on 'ResizeObserver': 1 argument required, but only 0 present.");
    if (!zt(t))
      throw new TypeError("Failed to execute 'observe' on 'ResizeObserver': parameter 1 is not of type 'Element");
    Ce.observe(this, t, n);
  }, e.prototype.unobserve = function(t) {
    if (arguments.length === 0)
      throw new TypeError("Failed to execute 'unobserve' on 'ResizeObserver': 1 argument required, but only 0 present.");
    if (!zt(t))
      throw new TypeError("Failed to execute 'unobserve' on 'ResizeObserver': parameter 1 is not of type 'Element");
    Ce.unobserve(this, t);
  }, e.prototype.disconnect = function() {
    Ce.disconnect(this);
  }, e.toString = function() {
    return "function ResizeObserver () { [polyfill code] }";
  }, e;
}();
const Ne = /* @__PURE__ */ new WeakMap();
function jr(e) {
  var t;
  for (let n = 0, r = e.length; n < r; ++n) {
    const o = e[n], i = Ne.get(o.target);
    if (typeof i == "function") {
      const { inlineSize: s, blockSize: c } = ((t = o.borderBoxSize) == null ? void 0 : t[0]) ?? {}, { offsetWidth: a, offsetHeight: l } = o.target;
      i(
        Object.assign(o, {
          offsetWidth: a,
          offsetHeight: l,
          width: s ?? a,
          height: c ?? l
        })
      );
    }
  }
}
const un = new (D && window.ResizeObserver || Ft)(
  jr
);
function xe(e, t) {
  Ne.set(e, t), un.observe(e);
}
function nt(e) {
  Ne.has(e) && (un.unobserve(e), Ne.delete(e));
}
function wo(e = {}) {
  let t = P;
  const n = watch(
    () => unref(e.target),
    (o) => {
      t(), !(!o || typeof e.onResize != "function") && (xe(o, e.onResize), t = () => {
        nt(o), t = P;
      });
    },
    { immediate: true }
  ), r = () => {
    n(), t();
  };
  return getCurrentScope() && onScopeDispose(r), {
    /**
     * @deprecated Will be removed in next major version, please directly use `observeResize` from imports.
     */
    observeResize: xe,
    /**
     * @deprecated Will be removed in next major version, please directly use `unobserveResize` from imports.
     */
    unobserveResize: nt,
    unobserve: r
  };
}
const dn = ref(false);
computed(() => dn.value);
const Dt = "__theme_style__", Le = "__theme_observer__";
const We = reactive(/* @__PURE__ */ new Map()), rt = /* @__PURE__ */ new Map();
watch(We, () => {
  if (!D) return;
  rt.clear();
  const e = document.head.querySelector(`#${Dt}`);
  e && document.head.removeChild(e);
  const t = document.createElement("style");
  let n = `.${Le} { width: 1px }`, r = 1;
  for (const [o, [i, s]] of We.entries())
    n += ` html.${i} .${Le}, .${s} .${Le} { width: ${++r}px }`, rt.set(r, o);
  t.textContent = n, t.id = Dt, document.head.appendChild(t);
});
export {
  qt as CLICK_OUTSIDE,
  xe as observeResize,
  nt as unobserveResize,
  wo as useResize
};
