/**
 * ldesign v0.2.2
 * (c) 2022年9月20日 swimly
 * @license MIT
 */

import Vue from 'vue';
import { _ as _defineProperty } from '../../../_chunks/dep-33b15d9d.js';
import { s as setStyle } from '../../../_chunks/dep-85e8b23b.js';
import { g as getIEVersion } from '../../../_chunks/dep-fc383775.js';
import { PREFIX } from '../../../config.js';
import '@babel/runtime/helpers/toConsumableArray';
import '@babel/runtime/helpers/slicedToArray';

/**
 * LDesignUtility v0.1.1
 * (c) 2022 undefined
 * @license MIT
 */

function ownKeys(object, enumerableOnly) {
  var keys = Object.keys(object);

  if (Object.getOwnPropertySymbols) {
    var symbols = Object.getOwnPropertySymbols(object);
    enumerableOnly && (symbols = symbols.filter(function (sym) {
      return Object.getOwnPropertyDescriptor(object, sym).enumerable;
    })), keys.push.apply(keys, symbols);
  }

  return keys;
}

function _objectSpread(target) {
  for (var i = 1; i < arguments.length; i++) {
    var source = null != arguments[i] ? arguments[i] : {};
    i % 2 ? ownKeys(Object(source), true).forEach(function (key) {
      _defineProperty(target, key, source[key]);
    }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
      Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
    });
  }

  return target;
}

function circleAdapter(circleElem) {
  var _window, _window$navigator;

  var basicStyle = {};
  var color;
  var fontSize;

  if (!circleElem) {
    return;
  }

  if (window && window.getComputedStyle) {
    var style = window.getComputedStyle(circleElem);
    color = style.color;
    fontSize = style.fontSize;
  }

  var ua = (_window = window) === null || _window === void 0 ? void 0 : (_window$navigator = _window.navigator) === null || _window$navigator === void 0 ? void 0 : _window$navigator.userAgent;
  var isSafari = /Safari/.test(ua) && !/Chrome/.test(ua);

  if (isSafari) {
    basicStyle = {
      transformOrigin: "-1px -1px",
      transform: "scale(".concat(parseInt(fontSize, 10) / 14, ")")
    };
  }

  if (color && getIEVersion() > 11) {
    var matched = color.match(/[\d.]+/g);
    var endColor = matched ? "rgba(".concat(matched[0], ", ").concat(matched[1], ", ").concat(matched[2], ", 0)") : "";
    setStyle(circleElem, _objectSpread(_objectSpread({}, basicStyle), {}, {
      background: "conic-gradient(from 90deg at 50% 50%,".concat(endColor, " 0deg, ").concat(color, " 360deg)")
    }));
  } else {
    setStyle(circleElem, _objectSpread(_objectSpread({}, basicStyle), {}, {
      background: ""
    }));
  }
}

var name = "".concat(PREFIX, "-loading__gradient");
var classname = "".concat(PREFIX, "-icon-loading");
var GradientIcon = Vue.extend({
  name: name,
  mounted: function mounted() {
    var _this = this;

    this.$nextTick(function () {
      _this.updateColor();
    });
  },
  updated: function updated() {
    this.updateColor();
  },
  methods: {
    updateColor: function updateColor() {
      var circleElem = this.$refs.circle;
      circleAdapter(circleElem);
    }
  },
  render: function render() {
    var h = arguments[0];
    var classes = [name, classname];
    return h("svg", {
      "class": classes,
      "attrs": {
        "viewBox": "0 0 14 14",
        "version": "1.1",
        "width": "1em",
        "height": "1em",
        "xmlns": "http://www.w3.org/2000/svg"
      }
    }, [h("foreignObject", {
      "attrs": {
        "x": "1",
        "y": "1",
        "width": "12",
        "height": "12"
      }
    }, [h("div", {
      "class": "".concat(name, "-conic"),
      "ref": "circle"
    })])]);
  }
});

export { GradientIcon as default };
//# sourceMappingURL=gradient.js.map
