import "../styles/reset.css";
import "./badge.less";
import { PropTypes as __WEBPACK_EXTERNAL_MODULE_bkui_vue_lib_shared_edbdfb03_PropTypes__, classes as __WEBPACK_EXTERNAL_MODULE_bkui_vue_lib_shared_edbdfb03_classes__, withInstall as __WEBPACK_EXTERNAL_MODULE_bkui_vue_lib_shared_edbdfb03_withInstall__ } from "../shared";
import { computed as __WEBPACK_EXTERNAL_MODULE_vue_computed__, createVNode as __WEBPACK_EXTERNAL_MODULE_vue_createVNode__, defineComponent as __WEBPACK_EXTERNAL_MODULE_vue_defineComponent__ } from "vue";
import { usePrefix as __WEBPACK_EXTERNAL_MODULE_bkui_vue_lib_config_provider_fe8577a3_usePrefix__ } from "../config-provider";

;// external "../shared"

;// external "vue"

;// ../../node_modules/@babel/runtime/helpers/esm/typeof.js
function _typeof(o) {
  "@babel/helpers - typeof";

  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
    return typeof o;
  } : function (o) {
    return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
  }, _typeof(o);
}

;// ../../node_modules/@babel/runtime/helpers/esm/toPrimitive.js

function toPrimitive(t, r) {
  if ("object" != _typeof(t) || !t) return t;
  var e = t[Symbol.toPrimitive];
  if (void 0 !== e) {
    var i = e.call(t, r || "default");
    if ("object" != _typeof(i)) return i;
    throw new TypeError("@@toPrimitive must return a primitive value.");
  }
  return ("string" === r ? String : Number)(t);
}

;// ../../node_modules/@babel/runtime/helpers/esm/toPropertyKey.js


function toPropertyKey(t) {
  var i = toPrimitive(t, "string");
  return "symbol" == _typeof(i) ? i : i + "";
}

;// ../../node_modules/@babel/runtime/helpers/esm/defineProperty.js

function _defineProperty(e, r, t) {
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
    value: t,
    enumerable: !0,
    configurable: !0,
    writable: !0
  }) : e[r] = t, e;
}

;// external "../config-provider"

;// ../../packages/badge/src/badge.tsx


/*
 * Tencent is pleased to support the open source community by making
 * 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) available.
 *
 * Copyright (C) 2025 Tencent.  All rights reserved.
 *
 * 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) is licensed under the MIT License.
 *
 * License for 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition):
 *
 * ---------------------------------------------------
 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
 * documentation files (the "Software"), to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
 * to permit persons to whom the Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all copies or substantial portions of
 * the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
 * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
 * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 * IN THE SOFTWARE.
 */



/* harmony default export */ const badge = (__WEBPACK_EXTERNAL_MODULE_vue_defineComponent__({
  name: 'Badge',
  props: {
    /** badge theme */
    theme: __WEBPACK_EXTERNAL_MODULE_bkui_vue_lib_shared_edbdfb03_PropTypes__.string.def('primary'),
    /** Number to show in badge */
    count: __WEBPACK_EXTERNAL_MODULE_bkui_vue_lib_shared_edbdfb03_PropTypes__.oneOfType([String, Number]).def(1),
    position: __WEBPACK_EXTERNAL_MODULE_bkui_vue_lib_shared_edbdfb03_PropTypes__.string.def('top-right'),
    radius: __WEBPACK_EXTERNAL_MODULE_bkui_vue_lib_shared_edbdfb03_PropTypes__.string,
    valLength: __WEBPACK_EXTERNAL_MODULE_bkui_vue_lib_shared_edbdfb03_PropTypes__.number.def(3),
    /** Show capped numeric value */
    overflowCount: __WEBPACK_EXTERNAL_MODULE_bkui_vue_lib_shared_edbdfb03_PropTypes__.number.def(99),
    /** Whether to show red dots with no content */
    dot: __WEBPACK_EXTERNAL_MODULE_bkui_vue_lib_shared_edbdfb03_PropTypes__.bool.def(false),
    visible: __WEBPACK_EXTERNAL_MODULE_bkui_vue_lib_shared_edbdfb03_PropTypes__.bool.def(false),
    /** 外部设置的 class name */
    extCls: __WEBPACK_EXTERNAL_MODULE_bkui_vue_lib_shared_edbdfb03_PropTypes__.string
  },
  emits: ['hover', 'leave'],
  setup: function setup(props, _ref) {
    var emit = _ref.emit;
    var numberCount = __WEBPACK_EXTERNAL_MODULE_vue_computed__(function () {
      if (typeof props.count === 'string') {
        var valueText = props.count;
        valueText += '';
        var output = [];
        var count = 0;
        valueText.split('').forEach(function (_char) {
          if (count < Number(props.valLength)) {
            count += /[\u4e00-\u9fa5]/.test(_char) ? 2 : 1;
            output.push(_char);
          }
        });
        return output.join('');
      }
      return props.count > props.overflowCount ? "".concat(props.overflowCount, "+") : props.count;
    });
    var radiusStyle = __WEBPACK_EXTERNAL_MODULE_vue_computed__(function () {
      var isRadius = props.radius !== undefined && /^\d+(%|px|em|rem|vh|vw)?$/.test(props.radius);
      var radiusValue = isRadius && /^\d+$/.test(props.radius) && "".concat(props.radius, "px") || props.radius;
      return {
        borderRadius: radiusValue
      };
    });
    var handleHover = function handleHover() {
      /**
       * Hover event.
       * @event hover
       */
      emit('hover');
    };
    var handleLeave = function handleLeave() {
      /**
       * Leave event.
       * @event Leave
       */
      emit('leave');
    };
    var _usePrefix = __WEBPACK_EXTERNAL_MODULE_bkui_vue_lib_config_provider_fe8577a3_usePrefix__(),
      resolveClassName = _usePrefix.resolveClassName;
    return {
      numberCount: numberCount,
      handleHover: handleHover,
      handleLeave: handleLeave,
      radiusStyle: radiusStyle,
      resolveClassName: resolveClassName
    };
  },
  render: function render() {
    var _this$$slots$default, _this$$slots$default2, _this$$slots, _this$$slots$icon, _this$$slots$icon2, _this$$slots2;
    var wrapperClasses = __WEBPACK_EXTERNAL_MODULE_bkui_vue_lib_shared_edbdfb03_classes__(_defineProperty({}, "".concat(this.resolveClassName('badge-main')), true), this.$props.extCls);
    var badgeClass = __WEBPACK_EXTERNAL_MODULE_bkui_vue_lib_shared_edbdfb03_classes__(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, "".concat(this.resolveClassName('badge'), " ").concat(this.resolveClassName(this.$props.theme)), !!this.$props.theme), 'pinned ', this.$slots["default"]), 'dot', this.$props.dot), "".concat(this.$props.position), this.$slots["default"]), "".concat(this.resolveClassName('badge-icon'), " is-icon"), this.$slots.icon), '');
    var number = !this.$props.dot ? __WEBPACK_EXTERNAL_MODULE_vue_createVNode__("span", null, [this.numberCount]) : '';
    return __WEBPACK_EXTERNAL_MODULE_vue_createVNode__("div", {
      "class": wrapperClasses
    }, [(_this$$slots$default = (_this$$slots$default2 = (_this$$slots = this.$slots)["default"]) === null || _this$$slots$default2 === void 0 ? void 0 : _this$$slots$default2.call(_this$$slots)) !== null && _this$$slots$default !== void 0 ? _this$$slots$default : '', !this.$props.visible ? __WEBPACK_EXTERNAL_MODULE_vue_createVNode__("span", {
      "style": this.radiusStyle,
      "class": badgeClass,
      "onMouseenter": this.handleHover,
      "onMouseleave": this.handleLeave
    }, [(_this$$slots$icon = (_this$$slots$icon2 = (_this$$slots2 = this.$slots).icon) === null || _this$$slots$icon2 === void 0 ? void 0 : _this$$slots$icon2.call(_this$$slots2)) !== null && _this$$slots$icon !== void 0 ? _this$$slots$icon : number]) : '']);
  }
}));
;// ../../packages/badge/src/index.ts
/*
 * Tencent is pleased to support the open source community by making
 * 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) available.
 *
 * Copyright (C) 2025 Tencent.  All rights reserved.
 *
 * 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) is licensed under the MIT License.
 *
 * License for 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition):
 *
 * ---------------------------------------------------
 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
 * documentation files (the "Software"), to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
 * to permit persons to whom the Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all copies or substantial portions of
 * the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
 * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
 * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 * IN THE SOFTWARE.
 */


var BkBadge = __WEBPACK_EXTERNAL_MODULE_bkui_vue_lib_shared_edbdfb03_withInstall__(badge);
/* harmony default export */ const src = (BkBadge);
export { src as default };
