{"version":3,"file":"progress2.mjs","sources":["../../../../../../packages/components/progress/src/progress.vue"],"sourcesContent":["<template>\n  <div\n    :class=\"[\n      ns.b(),\n      ns.m(type),\n      ns.is(status),\n      {\n        [ns.m('without-text')]: !showText,\n        [ns.m('text-inside')]: textInside,\n      },\n    ]\"\n    role=\"progressbar\"\n    :aria-valuenow=\"percentage\"\n    aria-valuemin=\"0\"\n    aria-valuemax=\"100\"\n  >\n    <div v-if=\"type === 'line'\" :class=\"ns.b('bar')\">\n      <div\n        :class=\"ns.be('bar', 'outer')\"\n        :style=\"{ height: `${strokeWidth}px` }\"\n      >\n        <div\n          :class=\"[\n            ns.be('bar', 'inner'),\n            { [ns.bem('bar', 'inner', 'indeterminate')]: indeterminate },\n          ]\"\n          :style=\"barStyle\"\n        >\n          <div\n            v-if=\"(showText || $slots.default) && textInside\"\n            :class=\"ns.be('bar', 'innerText')\"\n          >\n            <slot v-bind=\"slotData\">\n              <span>{{ content }}</span>\n            </slot>\n          </div>\n        </div>\n      </div>\n    </div>\n    <div\n      v-else\n      :class=\"ns.b('circle')\"\n      :style=\"{ height: `${width}px`, width: `${width}px` }\"\n    >\n      <svg viewBox=\"0 0 100 100\">\n        <path\n          :class=\"ns.be('circle', 'track')\"\n          :d=\"trackPath\"\n          stroke=\"#e5e9f2\"\n          :stroke-width=\"relativeStrokeWidth\"\n          fill=\"none\"\n          :style=\"trailPathStyle\"\n        />\n        <path\n          :class=\"ns.be('circle', 'path')\"\n          :d=\"trackPath\"\n          :stroke=\"stroke\"\n          fill=\"none\"\n          :stroke-linecap=\"strokeLinecap\"\n          :stroke-width=\"percentage ? relativeStrokeWidth : 0\"\n          :style=\"circlePathStyle\"\n        />\n      </svg>\n    </div>\n    <div\n      v-if=\"(showText || $slots.default) && !textInside\"\n      :class=\"ns.e('text')\"\n      :style=\"{ fontSize: `${progressTextSize}px` }\"\n    >\n      <slot v-bind=\"slotData\">\n        <span v-if=\"!status\">{{ content }}</span>\n        <el-icon v-else><component :is=\"statusIcon\" /></el-icon>\n      </slot>\n    </div>\n  </div>\n</template>\n\n<script lang=\"ts\">\nimport { computed, defineComponent } from 'vue'\nimport { ElIcon } from '@element-plus/components/icon'\nimport {\n  WarningFilled,\n  CircleCheck,\n  CircleClose,\n  Check,\n  Close,\n} from '@element-plus/icons-vue'\nimport { useNamespace } from '@element-plus/hooks'\nimport { progressProps } from './progress'\nimport type { CSSProperties } from 'vue'\n\nexport default defineComponent({\n  name: 'ElProgress',\n  components: {\n    ElIcon,\n    CircleCheck,\n    CircleClose,\n    Check,\n    Close,\n    WarningFilled,\n  },\n  props: progressProps,\n\n  setup(props) {\n    const ns = useNamespace('progress')\n\n    const barStyle = computed(\n      (): CSSProperties => ({\n        width: `${props.percentage}%`,\n        animationDuration: `${props.duration}s`,\n        backgroundColor: getCurrentColor(props.percentage),\n      })\n    )\n\n    const relativeStrokeWidth = computed(() =>\n      ((props.strokeWidth / props.width) * 100).toFixed(1)\n    )\n\n    const radius = computed(() => {\n      if (props.type === 'circle' || props.type === 'dashboard') {\n        return parseInt(`${50 - parseFloat(relativeStrokeWidth.value) / 2}`, 10)\n      } else {\n        return 0\n      }\n    })\n\n    const trackPath = computed(() => {\n      const r = radius.value\n      const isDashboard = props.type === 'dashboard'\n      return `\n          M 50 50\n          m 0 ${isDashboard ? '' : '-'}${r}\n          a ${r} ${r} 0 1 1 0 ${isDashboard ? '-' : ''}${r * 2}\n          a ${r} ${r} 0 1 1 0 ${isDashboard ? '' : '-'}${r * 2}\n          `\n    })\n\n    const perimeter = computed(() => 2 * Math.PI * radius.value)\n\n    const rate = computed(() => (props.type === 'dashboard' ? 0.75 : 1))\n\n    const strokeDashoffset = computed(() => {\n      const offset = (-1 * perimeter.value * (1 - rate.value)) / 2\n      return `${offset}px`\n    })\n\n    const trailPathStyle = computed(\n      (): CSSProperties => ({\n        strokeDasharray: `${perimeter.value * rate.value}px, ${\n          perimeter.value\n        }px`,\n        strokeDashoffset: strokeDashoffset.value,\n      })\n    )\n\n    const circlePathStyle = computed(\n      (): CSSProperties => ({\n        strokeDasharray: `${\n          perimeter.value * rate.value * (props.percentage / 100)\n        }px, ${perimeter.value}px`,\n        strokeDashoffset: strokeDashoffset.value,\n        transition: 'stroke-dasharray 0.6s ease 0s, stroke 0.6s ease',\n      })\n    )\n\n    const stroke = computed(() => {\n      let ret: string\n      if (props.color) {\n        ret = getCurrentColor(props.percentage)\n      } else {\n        switch (props.status) {\n          case 'success':\n            ret = '#13ce66'\n            break\n          case 'exception':\n            ret = '#ff4949'\n            break\n          case 'warning':\n            ret = '#e6a23c'\n            break\n          default:\n            ret = '#20a0ff'\n        }\n      }\n      return ret\n    })\n\n    const statusIcon = computed(() => {\n      if (props.status === 'warning') {\n        return WarningFilled\n      }\n      if (props.type === 'line') {\n        return props.status === 'success' ? CircleCheck : CircleClose\n      } else {\n        return props.status === 'success' ? Check : Close\n      }\n    })\n\n    const progressTextSize = computed(() => {\n      return props.type === 'line'\n        ? 12 + props.strokeWidth * 0.4\n        : props.width * 0.111111 + 2\n    })\n\n    const content = computed(() => props.format(props.percentage))\n\n    const getCurrentColor = (percentage: number) => {\n      const { color } = props\n      if (typeof color === 'function') {\n        return color(percentage)\n      } else if (typeof color === 'string') {\n        return color\n      } else {\n        const span = 100 / color.length\n        const seriesColors = color.map((seriesColor, index) => {\n          if (typeof seriesColor === 'string') {\n            return {\n              color: seriesColor,\n              percentage: (index + 1) * span,\n            }\n          }\n          return seriesColor\n        })\n        const colors = seriesColors.sort((a, b) => a.percentage - b.percentage)\n\n        for (const color of colors) {\n          if (color.percentage > percentage) return color.color\n        }\n        return colors[colors.length - 1]?.color\n      }\n    }\n\n    const slotData = computed(() => {\n      return {\n        percentage: props.percentage,\n      }\n    })\n\n    return {\n      ns,\n      barStyle,\n      relativeStrokeWidth,\n      radius,\n      trackPath,\n      perimeter,\n      rate,\n      strokeDashoffset,\n      trailPathStyle,\n      circlePathStyle,\n      stroke,\n      statusIcon,\n      progressTextSize,\n      content,\n      slotData,\n    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