import { useMemo } from 'react';
export default function useHeadSlots(slotOptions = []) {
  return useMemo(() => {
    const slots = {
      before: [],
      afterMeta: [],
      afterSocial: [],
      afterCompliance: []
    };
    slotOptions.forEach(item => {
      if (React.isValidElement(item)) {
        slots.afterCompliance.push(item);
      } else if (typeof item === 'object' && item !== null) {
        const {
          slot,
          node
        } = item;
        switch (slot) {
          case 'before':
            slots.before.push(node);
            break;
          case 'after-meta':
            slots.afterMeta.push(node);
            break;
          case 'after-social':
            slots.afterSocial.push(node);
            break;
          case 'after-compliance':
            slots.afterCompliance.push(node);
            break;
          default:
            // If the slot is unrecognized, default to afterCompliance.
            slots.afterCompliance.push(node);
            break;
        }
      }
    });
    return slots;
  }, [slotOptions]);
}