{"version":3,"file":"option-group.js","sources":["../../../../../../packages/components/select/src/option-group.vue"],"sourcesContent":["<template>\n  <ul v-show=\"visible\" ref=\"groupRef\" :class=\"ns.be('group', 'wrap')\">\n    <li :class=\"ns.be('group', 'title')\">{{ label }}</li>\n    <li>\n      <ul :class=\"ns.b('group')\">\n        <slot />\n      </ul>\n    </li>\n  </ul>\n</template>\n\n<script lang=\"ts\">\n// @ts-nocheck\nimport {\n  computed,\n  defineComponent,\n  getCurrentInstance,\n  onMounted,\n  provide,\n  reactive,\n  ref,\n  toRefs,\n} from 'vue'\nimport { useMutationObserver } from '@vueuse/core'\nimport { ensureArray } from '@element-plus/utils'\nimport { useNamespace } from '@element-plus/hooks'\nimport { selectGroupKey } from './token'\n\nexport default defineComponent({\n  name: 'ElOptionGroup',\n  componentName: 'ElOptionGroup',\n\n  props: {\n    /**\n     * @description name of the group\n     */\n    label: String,\n    /**\n     * @description whether to disable all options in this group\n     */\n    disabled: Boolean,\n  },\n  setup(props) {\n    const ns = useNamespace('select')\n    const groupRef = ref(null)\n    const instance = getCurrentInstance()\n    const children = ref([])\n\n    provide(\n      selectGroupKey,\n      reactive({\n        ...toRefs(props),\n      })\n    )\n\n    const visible = computed(() =>\n      children.value.some((option) => option.visible === true)\n    )\n\n    const isOption = (node) =>\n      node.type?.name === 'ElOption' && !!node.component?.proxy\n\n    // get all instances of options\n    const flattedChildren = (node) => {\n      const Nodes = ensureArray(node)\n      const children = []\n\n      Nodes.forEach((child) => {\n        if (isOption(child)) {\n          children.push(child.component.proxy)\n        } else if (child.children?.length) {\n          children.push(...flattedChildren(child.children))\n        } else if (child.component?.subTree) {\n          children.push(...flattedChildren(child.component.subTree))\n        }\n      })\n\n      return children\n    }\n\n    const updateChildren = () => {\n      children.value = flattedChildren(instance.subTree)\n    }\n\n    onMounted(() => {\n      updateChildren()\n    })\n\n    useMutationObserver(groupRef, updateChildren, {\n      attributes: true,\n      subtree: true,\n      childList: true,\n    })\n\n    return {\n      groupRef,\n      visible,\n      ns,\n    }\n  },\n})\n</script>\n"],"names":["defineComponent","useNamespace","ref","getCurrentInstance","provide","selectGroupKey","reactive","toRefs","computed","ensureArray","onMounted","useMutationObserver","_withDirectives","_openBlock","_createElementBlock","_normalizeClass","_createElementVNode","_toDisplayString"],"mappings":";;;;;;;;;;;;;AA4BA,MAAK,YAAaA,mBAAa,CAAA;AAAA,EAC7B,IAAM,EAAA,eAAA;AAAA,EACN,aAAe,EAAA,eAAA;AAAA,EAEf,KAAO,EAAA;AAAA,IAIL,KAAO,EAAA,MAAA;AAAA,IAIP,QAAU,EAAA,OAAA;AAAA,GACZ;AAAA,EACA,MAAM,KAAO,EAAA;AACX,IAAM,MAAA,EAAA,GAAKC,mBAAa,QAAQ,CAAA,CAAA;AAChC,IAAM,MAAA,QAAA,GAAWC,QAAI,IAAI,CAAA,CAAA;AACzB,IAAA,MAAM,WAAWC,sBAAmB,EAAA,CAAA;AACpC,IAAM,MAAA,QAAA,GAAWD,OAAI,CAAA,EAAE,CAAA,CAAA;AAEvB,IAAAE,WAAA,CACEC,sBACAC,YAAS,CAAA;AAAA,MACP,GAAGC,WAAO,KAAK,CAAA;AAAA,KAChB,CACH,CAAA,CAAA;AAEA,IAAM,MAAA,OAAA,GAAUC,YAAS,CAAA,MACvB,QAAS,CAAA,KAAA,CAAM,IAAK,CAAA,CAAC,MAAW,KAAA,MAAA,CAAO,OAAY,KAAA,IAAI,CACzD,CAAA,CAAA;AAEA,IAAM,MAAA,QAAA,GAAW,CAAC,IAAA,KAChB;AAGF,MAAM,IAAA,EAAA,EAAA,EAAA,CAAA;AACJ,MAAM,OAAA,CAAA,CAAA,EAAA,GAAQ,cAAgB,IAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,IAAA,MAAA,UAAA,IAAA,CAAA,EAAA,CAAA,EAAA,GAAA,IAAA,CAAA,SAAA,KAAA,IAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,KAAA,CAAA,CAAA;AAC9B,KAAA,CAA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