{"version":3,"file":"color.mjs","sources":["../../../../../packages/utils/vue/color.ts"],"sourcesContent":["import { computed, getCurrentInstance } from 'vue'\nimport { useAttrs } from '@vuesax-alpha/hooks'\nimport { componentColors } from '@vuesax-alpha/constants'\nimport { getVsColor } from '../color'\nimport { debugWarn } from '../error'\n\nexport const getComponentColor = () => {\n  const instance = getCurrentInstance()\n  if (!instance) {\n    debugWarn(\n      'use-attrs',\n      'getCurrentInstance() returned null. getComponentColor() must be called at the top of a setup function'\n    )\n    return computed(() => null)\n  }\n\n  const attrs = useAttrs({ excludeListeners: true })\n\n  return computed(() => {\n    const propColor = componentColors.find(\n      (color) => attrs.value[color] === true\n    )\n    if (propColor) return propColor\n\n    const hasColorString = attrs.value['color'] as string | undefined\n    if (!hasColorString) return null\n\n    return getVsColor(hasColorString)\n  })\n}\n"],"names":[],"mappings":";;;;;;;;AAMO,MAAM,oBAAoB,MAAM;AACrC,EAAA,MAAM,WAAW,kBAAmB,EAAA,CAAA;AACpC,EAAA,IAAI,CAAC,QAAU,EAAA;AACb,IAAA,SAAA;AAAA,MACE,WAAA;AAAA,MACA,uGAAA;AAAA,KACF,CAAA;AACA,IAAO,OAAA,QAAA,CAAS,MAAM,IAAI,CAAA,CAAA;AAAA,GAC5B;AAEA,EAAA,MAAM,KAAQ,GAAA,QAAA,CAAS,EAAE,gBAAA,EAAkB,MAAM,CAAA,CAAA;AAEjD,EAAA,OAAO,SAAS,MAAM;AACpB,IAAA,MAAM,YAAY,eAAgB,CAAA,IAAA;AAAA,MAChC,CAAC,KAAA,KAAU,KAAM,CAAA,KAAA,CAAM,KAAW,CAAA,KAAA,IAAA;AAAA,KACpC,CAAA;AACA,IAAI,IAAA,SAAA;AAAW,MAAO,OAAA,SAAA,CAAA;AAEtB,IAAM,MAAA,cAAA,GAAiB,MAAM,KAAM,CAAA,OAAA,CAAA,CAAA;AACnC,IAAA,IAAI,CAAC,cAAA;AAAgB,MAAO,OAAA,IAAA,CAAA;AAE5B,IAAA,OAAO,WAAW,cAAc,CAAA,CAAA;AAAA,GACjC,CAAA,CAAA;AACH;;;;"}