import { aB as throttle, n as normalizeComponent } from "./index.js";
var render = function() {
  var _vm = this;
  var _h = _vm.$createElement;
  var _c = _vm._self._c || _h;
  return _c("div", {
    staticClass: "em-watermark"
  });
};
var staticRenderFns = [];
const __vue2_script = {
  name: "em-watermark",
  props: {
    watermarkUrl: {
      type: String,
      default: ""
    }
  },
  data() {
    return {
      watermarkStyle: ""
    };
  },
  mounted() {
    this.watermarkStyle = `
                position: absolute;
                left: 0;
                top: 0;
                width: 100%;
                height: 100%;
                background-repeat: repeat;
                pointer-events: none;
                z-index: 1;
                background-image: url(${this.watermarkUrl});
            `;
    this.$el.style = this.watermarkStyle;
    this.observerWatermark();
  },
  methods: {
    observerWatermark() {
      const parentNode = this.$el.parentNode;
      const targetNode = this.$el;
      parentNode._ob = new MutationObserver(() => {
        this.observerCallback(parentNode, targetNode);
      });
      parentNode._ob.observe(parentNode, {
        childList: true
      });
      targetNode._ob = new MutationObserver(() => {
        this.observerCallback(parentNode, targetNode, true);
      });
      targetNode._ob.observe(targetNode, {
        attributes: true
      });
    },
    observerCallback: throttle(function(parentNode, targetNode, byAttributes = false) {
      if (byAttributes) {
        targetNode.style = this.watermarkStyle;
        return;
      }
      if (!targetNode || targetNode.parentNode !== parentNode) {
        parentNode.appendChild(targetNode);
      }
    }, 50, {
      trailing: false
    })
  }
};
const __cssModules = {};
var __component__ = /* @__PURE__ */ normalizeComponent(__vue2_script, render, staticRenderFns, false, __vue2_injectStyles, null, null, null);
function __vue2_injectStyles(context) {
  for (let o in __cssModules) {
    this[o] = __cssModules[o];
  }
}
var Watermark = /* @__PURE__ */ function() {
  return __component__.exports;
}();
export { Watermark as W };
