import "../styles/reset.css";
import { PropTypes as __WEBPACK_EXTERNAL_MODULE_bkui_vue_lib_shared_edbdfb03_PropTypes__, 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__, onBeforeUnmount as __WEBPACK_EXTERNAL_MODULE_vue_onBeforeUnmount__, onMounted as __WEBPACK_EXTERNAL_MODULE_vue_onMounted__, ref as __WEBPACK_EXTERNAL_MODULE_vue_ref__, watch as __WEBPACK_EXTERNAL_MODULE_vue_watch__ } from "vue";

;// external "../shared"

;// external "vue"

;// ../../packages/animate-number/src/animate-number.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 animate_number = (__WEBPACK_EXTERNAL_MODULE_vue_defineComponent__({
  name: 'AnimateNumber',
  props: {
    value: __WEBPACK_EXTERNAL_MODULE_bkui_vue_lib_shared_edbdfb03_PropTypes__.number.def(0),
    digits: __WEBPACK_EXTERNAL_MODULE_bkui_vue_lib_shared_edbdfb03_PropTypes__.number.def(0)
  },
  setup: function setup(props) {
    var rafId = -1;
    var tweeningValue = __WEBPACK_EXTERNAL_MODULE_vue_ref__(0);
    var formatValue = __WEBPACK_EXTERNAL_MODULE_vue_computed__(function () {
      return Number(tweeningValue.value).toFixed(props.digits);
    });
    var tween = function tween(startValue, endValue) {
      // 错误数据返回0
      if (Number.isNaN(+endValue)) return 0;
      var dis = Math.abs(endValue - startValue);
      var isPositive = endValue - startValue > 0 ? 1 : -1;
      var ticDis = Math.ceil(dis / 30 * Math.pow(10, props.digits)) / Math.pow(10, props.digits);
      var ticTimes = Math.ceil(dis / ticDis);
      // 算出每次计算需要间隔的时间，保证动画的流畅
      var gapTime = 25 / ticTimes;
      var tickGap = 1;
      var _animate = function animate() {
        if (tickGap < gapTime) {
          rafId = requestAnimationFrame(_animate);
          tickGap = tickGap + 1;
          return;
        }
        tweeningValue.value += ticDis * isPositive;
        var isUnDone = isPositive === 1 ? tweeningValue.value < endValue : tweeningValue.value > endValue;
        if (isUnDone) {
          rafId = requestAnimationFrame(_animate);
          tickGap = 1;
        } else {
          tweeningValue.value = endValue;
        }
      };
      _animate();
    };
    __WEBPACK_EXTERNAL_MODULE_vue_watch__(function () {
      return props.value;
    }, function (newValue, oldValue) {
      tween(oldValue, newValue);
    });
    __WEBPACK_EXTERNAL_MODULE_vue_onMounted__(function () {
      tween(0, props.value);
    });
    __WEBPACK_EXTERNAL_MODULE_vue_onBeforeUnmount__(function () {
      cancelAnimationFrame(rafId);
    });
    return function () {
      return __WEBPACK_EXTERNAL_MODULE_vue_createVNode__("span", null, [formatValue.value]);
    };
  }
}));
;// ../../packages/animate-number/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 BkAnimateNumber = __WEBPACK_EXTERNAL_MODULE_bkui_vue_lib_shared_edbdfb03_withInstall__(animate_number);
/* harmony default export */ const src = (BkAnimateNumber);
export { src as default };
