// This file was generated by build-components.mjs
// ANY EDITS WILL BE OVERWRITTEN!

import {
  ProviderIcon as PreactProviderIcon,
  type ProviderIconProps,
} from '@uppy/components'
import { h as preactH, render as preactRender } from '@uppy/core/utils/preact'
import { defineComponent, h, onMounted, ref, watch } from 'vue'
import { useUppyContext } from '../useUppyContext.js'

export default defineComponent({
  name: 'ProviderIcon',
  props: ['provider', 'fill'],
  setup(props) {
    const containerRef = ref<HTMLElement | null>(null)
    const ctx = useUppyContext()

    function renderProviderIcon() {
      if (containerRef.value) {
        preactRender(
          preactH(PreactProviderIcon, {
            ...props,
            ctx,
          } satisfies ProviderIconProps),
          containerRef.value,
        )
      }
    }

    onMounted(() => {
      renderProviderIcon()
    })

    watch(ctx, () => {
      renderProviderIcon()
    })

    watch(
      () => props,
      () => {
        renderProviderIcon()
      },
      { deep: true },
    )

    return () => h('div', { ref: containerRef })
  },
})
