import { defineComponent as h, reactive as E, computed as u, onMounted as w, nextTick as I, openBlock as p, createElementBlock as m, withModifiers as _, normalizeClass as d, createElementVNode as r, renderSlot as x, createCommentVNode as H } from "vue";
import { C as t } from "./base-PQGakkrl.js";
import B from "../Element/__provide__/Clipboard.js";
const M = { class: "clipboard-btn" }, g = {
  key: 0,
  class: "clipboard-operate-result"
}, L = /* @__PURE__ */ h({
  name: "ClClipboard",
  __name: "Index",
  props: {
    // 必填属性
    textLabel: {
      type: [String, Function],
      required: !0
    },
    // 简单属性（无默认值、非必填、无需验证）
    className: String,
    iconColorClass: String,
    isUseSuccess: Boolean
  },
  emits: ["onCopySuccess", "onCopyError"],
  setup(i, { emit: C }) {
    const c = i, n = C, s = E({
      isHover: !1,
      isShowSuccess: !1
    });
    let l = null;
    const f = u(() => {
      const o = {
        "panel-clipboard": !0
      }, { className: e } = c;
      return e && !t.isEmpty(e) && e.split(" ").forEach((a) => {
        t.isEmpty(a) || (o[a] = !0);
      }), o;
    }), S = u(() => {
      const o = {
        clIconFont: !0,
        "clIcon-copy": !0
      }, { iconColorClass: e } = c;
      return e && !t.isEmpty(e) && (o[e] = !0), o;
    }), y = () => {
      l = B();
    };
    w(() => {
      I(() => {
        y();
      });
    });
    const b = () => {
      let o = "";
      const { textLabel: e } = c;
      if (e)
        switch (typeof e) {
          case "function":
            o = e();
            break;
          case "string":
            o = e;
            break;
        }
      t.isEmpty(o) ? n("onCopyError", o) : l.copy({
        text: o,
        successCallback: () => {
          s.isShowSuccess = !0, n("onCopySuccess");
        },
        errorCallback: () => {
          s.isShowSuccess = !1, n("onCopyError", o);
        }
      });
    }, v = () => {
      s.isHover = !0;
    }, k = () => {
      s.isShowSuccess = !1, s.isHover = !1;
    };
    return (o, e) => (p(), m("div", {
      class: d(f.value),
      onMouseenter: v,
      onMouseleave: k,
      onClick: _(b, ["stop"])
    }, [
      r("div", M, [
        x(o.$slots, "default", {}, () => [
          r("i", {
            class: d(S.value),
            title: "复制"
          }, null, 2)
        ])
      ]),
      i.isUseSuccess && s.isHover && s.isShowSuccess ? (p(), m("div", g, [...e[0] || (e[0] = [
        r("i", { class: "clIconFont clIcon-check" }, null, -1)
      ])])) : H("", !0)
    ], 34));
  }
});
export {
  L as _
};
//# sourceMappingURL=Index.vue_vue_type_script_setup_true_lang-DKAxas3I.js.map
