/**
 * ldesign v0.2.14
 * (c) 2022/11/2 16:16 built by swimly
 * @license MIT
 */

import Vue from 'vue';
import { _ as _defineProperty } from '../../../chunks/defineProperty-838e4192.js';
import { s as setStyle } from '../../../chunks/set-style.js';
import { g as getIEVersion } from '../../../chunks/helper2.js';
import { PREFIX } from '../../../config.js';

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$getComputedSt, _window2, _window2$navigator;
  var basicStyle = {};
  if (!circleElem) return;
  var {
    color,
    fontSize
  } = (_window = window) === null || _window === void 0 ? void 0 : (_window$getComputedSt = _window.getComputedStyle) === null || _window$getComputedSt === void 0 ? void 0 : _window$getComputedSt.call(_window, circleElem);
  var ua = (_window2 = window) === null || _window2 === void 0 ? void 0 : (_window2$navigator = _window2.navigator) === null || _window2$navigator === void 0 ? void 0 : _window2$navigator.userAgent;
  var isSafari = /Safari/.test(ua) && !/Chrome/.test(ua);
  var isIosWechat = /(?=.*iPhone)[?=.*MicroMessenger]/.test(ua) && !/Chrome/.test(ua);
  var isMobile = /Mobile/.test(ua);
  if ((isSafari || isIosWechat) && !isMobile) {
    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: ""
    }));
  }
}

const name = `${PREFIX}-loading__gradient`;
const classname = `${PREFIX}-icon-loading`;
var GradientIcon = Vue.extend({
  name,
  mounted() {
    this.$nextTick(() => {
      this.updateColor();
    });
  },
  updated() {
    this.updateColor();
  },
  methods: {
    updateColor() {
      const circleElem = this.$refs.circle;
      circleAdapter(circleElem);
    }
  },
  render() {
    const h = arguments[0];
    const 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": `${name}-conic`,
      "ref": "circle"
    })])]);
  }
});

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