{"version":3,"file":"use-computed-data.mjs","names":[],"sources":["../../../../../../../packages/components/transfer/src/composables/use-computed-data.ts"],"sourcesContent":["import { computed } from 'vue'\nimport { usePropsAlias } from './use-props-alias'\n\nimport type { TransferDataItem, TransferKey, TransferProps } from '../transfer'\n\nexport const useComputedData = (\n  props: Required<\n    Omit<TransferProps, 'filterPlaceholder' | 'filterMethod' | 'renderContent'>\n  >\n) => {\n  const propsAlias = usePropsAlias(props)\n\n  const dataObj = computed(() =>\n    props.data.reduce((o, cur) => (o[cur[propsAlias.value.key]] = cur) && o, {})\n  )\n\n  const sourceData = computed(() =>\n    props.data.filter(\n      (item) => !props.modelValue.includes(item[propsAlias.value.key])\n    )\n  )\n\n  const targetData = computed(() => {\n    if (props.targetOrder === 'original') {\n      return props.data.filter((item) =>\n        props.modelValue.includes(item[propsAlias.value.key])\n      )\n    } else {\n      return props.modelValue.reduce(\n        (arr: TransferDataItem[], cur: TransferKey) => {\n          const val = dataObj.value[cur]\n          if (val) {\n            arr.push(val)\n          }\n          return arr\n        },\n        []\n      )\n    }\n  })\n\n  return {\n    sourceData,\n    targetData,\n  }\n}\n"],"mappings":";;;;AAKA,MAAa,mBACX,UAGG;CACH,MAAM,aAAa,cAAc,MAAM;CAEvC,MAAM,UAAU,eACd,MAAM,KAAK,QAAQ,GAAG,SAAS,EAAE,IAAI,WAAW,MAAM,QAAQ,QAAQ,GAAG,EAAE,CAAC,CAC7E;AA2BD,QAAO;EACL,YA1BiB,eACjB,MAAM,KAAK,QACR,SAAS,CAAC,MAAM,WAAW,SAAS,KAAK,WAAW,MAAM,KAAK,CACjE,CACF;EAuBC,YArBiB,eAAe;AAChC,OAAI,MAAM,gBAAgB,WACxB,QAAO,MAAM,KAAK,QAAQ,SACxB,MAAM,WAAW,SAAS,KAAK,WAAW,MAAM,KAAK,CACtD;OAED,QAAO,MAAM,WAAW,QACrB,KAAyB,QAAqB;IAC7C,MAAM,MAAM,QAAQ,MAAM;AAC1B,QAAI,IACF,KAAI,KAAK,IAAI;AAEf,WAAO;MAET,EAAE,CACH;IAEH;EAKD"}