{"version":3,"file":"useEntities.cjs","sources":["../../../../../../../packages/vue-components/vc-cascader/src/hooks/useEntities.ts"],"sourcesContent":["import type { Ref } from 'vue';\nimport type { DataEntity } from '../../../vc-tree/src/interface';\nimport type { DefaultOptionType, InternalFieldNames } from '../Cascader';\nimport { computed } from 'vue';\nimport { convertDataToEntities } from '../../../vc-tree/src/utils/treeUtil';\nimport { VALUE_SPLIT } from '../utils/commonUtil';\n\nexport interface OptionsInfo {\n  keyEntities: Record<string, DataEntity>;\n  pathKeyEntities: Record<string, DataEntity>;\n}\n\n/** Lazy parse options data into conduct-able info to avoid perf issue in single mode */\nexport default (options: Ref<DefaultOptionType[]>, fieldNames: Ref<InternalFieldNames>) => {\n  const entities = computed(() => {\n    return (\n      convertDataToEntities(options.value as any, {\n        fieldNames: fieldNames.value,\n        initWrapper: wrapper => ({\n          ...wrapper,\n          pathKeyEntities: {},\n        }),\n        processEntity: (entity, wrapper: any) => {\n          const pathKey = entity.nodes.map(node => node[fieldNames.value.value]).join(VALUE_SPLIT);\n\n          wrapper.pathKeyEntities[pathKey] = entity;\n\n          // Overwrite origin key.\n          // this is very hack but we need let conduct logic work with connect path\n          entity.key = pathKey;\n        },\n      }) as any\n    ).pathKeyEntities;\n  });\n  return entities;\n};\n"],"names":["computed","convertDataToEntities","VALUE_SPLIT"],"mappings":";;;;;;;;AAaA,kBAAe,CAAC,SAAmC,UAAwC,KAAA;AACzF,EAAM,MAAA,QAAA,GAAWA,aAAS,MAAM;AAC9B,IACE,OAAAC,8BAAA,CAAsB,QAAQ,KAAc,EAAA;AAAA,MAC1C,YAAY,UAAW,CAAA,KAAA;AAAA,MACvB,aAAa,CAAY,OAAA,MAAA;AAAA,QACvB,GAAG,OAAA;AAAA,QACH,iBAAiB,EAAC;AAAA,OACpB,CAAA;AAAA,MACA,aAAA,EAAe,CAAC,MAAA,EAAQ,OAAiB,KAAA;AACvC,QAAA,MAAM,OAAU,GAAA,MAAA,CAAO,KAAM,CAAA,GAAA,CAAI,CAAQ,IAAA,KAAA,IAAA,CAAK,UAAW,CAAA,KAAA,CAAM,KAAK,CAAC,CAAE,CAAA,IAAA,CAAKC,sBAAW,CAAA,CAAA;AAEvF,QAAQ,OAAA,CAAA,eAAA,CAAgB,OAAO,CAAI,GAAA,MAAA,CAAA;AAInC,QAAA,MAAA,CAAO,GAAM,GAAA,OAAA,CAAA;AAAA,OACf;AAAA,KACD,CACD,CAAA,eAAA,CAAA;AAAA,GACH,CAAA,CAAA;AACD,EAAO,OAAA,QAAA,CAAA;AACT,CAAA;;;;"}