{"version":3,"file":"use-lifecycle.mjs","names":[],"sources":["../../../../../../../packages/components/slider/src/composables/use-lifecycle.ts"],"sourcesContent":["import { nextTick, onMounted, ref } from 'vue'\nimport { useEventListener } from '@vueuse/core'\nimport { isArray, isNumber } from '@element-plus/utils'\n\nimport type { SliderInitData, SliderProps } from '../slider'\n\nexport const useLifecycle = (\n  props: SliderProps,\n  initData: SliderInitData,\n  resetSize: () => void\n) => {\n  const sliderWrapper = ref<HTMLElement>()\n\n  onMounted(async () => {\n    if (props.range) {\n      if (isArray(props.modelValue)) {\n        initData.firstValue = Math.max(props.min, props.modelValue[0])\n        initData.secondValue = Math.min(props.max, props.modelValue[1])\n      } else {\n        initData.firstValue = props.min\n        initData.secondValue = props.max\n      }\n      initData.oldValue = [initData.firstValue, initData.secondValue]\n    } else {\n      if (!isNumber(props.modelValue) || Number.isNaN(props.modelValue)) {\n        initData.firstValue = props.min\n      } else {\n        initData.firstValue = Math.min(\n          props.max,\n          Math.max(props.min, props.modelValue)\n        )\n      }\n      initData.oldValue = initData.firstValue\n    }\n\n    useEventListener(window, 'resize', resetSize)\n\n    await nextTick()\n    resetSize()\n  })\n\n  return {\n    sliderWrapper,\n  }\n}\n"],"mappings":";;;;;AAMA,MAAa,gBACX,OACA,UACA,cACG;CACH,MAAM,gBAAgB,KAAkB;AAExC,WAAU,YAAY;AACpB,MAAI,MAAM,OAAO;AACf,OAAI,QAAQ,MAAM,WAAW,EAAE;AAC7B,aAAS,aAAa,KAAK,IAAI,MAAM,KAAK,MAAM,WAAW,GAAG;AAC9D,aAAS,cAAc,KAAK,IAAI,MAAM,KAAK,MAAM,WAAW,GAAG;UAC1D;AACL,aAAS,aAAa,MAAM;AAC5B,aAAS,cAAc,MAAM;;AAE/B,YAAS,WAAW,CAAC,SAAS,YAAY,SAAS,YAAY;SAC1D;AACL,OAAI,CAAC,SAAS,MAAM,WAAW,IAAI,OAAO,MAAM,MAAM,WAAW,CAC/D,UAAS,aAAa,MAAM;OAE5B,UAAS,aAAa,KAAK,IACzB,MAAM,KACN,KAAK,IAAI,MAAM,KAAK,MAAM,WAAW,CACtC;AAEH,YAAS,WAAW,SAAS;;AAG/B,mBAAiB,QAAQ,UAAU,UAAU;AAE7C,QAAM,UAAU;AAChB,aAAW;GACX;AAEF,QAAO,EACL,eACD"}