{"version":3,"file":"steps.js","sources":["../../../../../../packages/components/tour/src/steps.ts"],"sourcesContent":["import { defineComponent } from 'vue'\nimport { flattedChildren, isArray } from '@element-plus/utils'\nimport type { FlattenVNodes } from '@element-plus/utils'\nimport type { Component, VNode } from 'vue'\n\nexport default defineComponent({\n name: 'ElTourSteps',\n props: {\n current: {\n type: Number,\n default: 0,\n },\n },\n emits: ['update-total'],\n setup(props, { slots, emit }) {\n let cacheTotal = 0\n\n return () => {\n const children = slots.default?.()!\n const result: VNode[] = []\n let total = 0\n\n function filterSteps(children?: FlattenVNodes) {\n if (!isArray(children)) return\n ;(children as VNode[]).forEach((item) => {\n const name = ((item?.type || {}) as Component)?.name\n\n if (name === 'ElTourStep') {\n result.push(item)\n total += 1\n }\n })\n }\n\n if (children.length) {\n filterSteps(flattedChildren(children![0]?.children))\n }\n\n if (cacheTotal !== total) {\n cacheTotal = total\n emit('update-total', total)\n }\n\n if (result.length) {\n return result[props.current]\n }\n return null\n }\n },\n})\n"],"names":["defineComponent","isArray","flattedChildren"],"mappings":";;;;;;;;;AAEA,kBAAeA,mBAAe,CAAC;AAC/B,EAAE,IAAI,EAAE,aAAa;AACrB,EAAE,KAAK,EAAE;AACT,IAAI,OAAO,EAAE;AACb,MAAM,IAAI,EAAE,MAAM;AAClB,MAAM,OAAO,EAAE,CAAC;AAChB,KAAK;AACL,GAAG;AACH,EAAE,KAAK,EAAE,CAAC,cAAc,CAAC;AACzB,EAAE,KAAK,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;AAChC,IAAI,IAAI,UAAU,GAAG,CAAC,CAAC;AACvB,IAAI,OAAO,MAAM;AACjB,MAAM,IAAI,EAAE,EAAE,EAAE,CAAC;AACjB,MAAM,MAAM,QAAQ,GAAG,CAAC,EAAE,GAAG,KAAK,CAAC,OAAO,KAAK,IAAI,GAAG,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAC9E,MAAM,MAA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