const p = ({ name: o, children: t, from: s }) => {
  const e = (Array.isArray(s) ? s : [s]).find((r) => r?.props?.slot === o);
  return e?.type === "template" ? e.props.children : e ?? t;
}, u = (o, t) => (Array.isArray(t) ? t : [t]).some((s) => s?.props?.slot === o), S = (o, t, { throws: s, inComponent: e }) => {
  if (process.env.NODE_ENV !== "development" || o === void 0) return;
  const r = [], l = Array.isArray(o) ? o : [o], i = e ? `, defined in '${e.name}',` : "", d = `Valid slot names are: ${t.join(", ")} 
`, c = (a) => {
    if (s) throw new Error(a);
    console.error("%c [named-slots]", "color: #56b9c8", a);
  };
  l.forEach((a) => {
    const n = a.props?.slot;
    n ? t.includes(n) || c(`Slot '${n}'${i} is not valid. ${d}`) : c(`A Slot${i} received children missing a slot attribute.${d}`), r.includes(n) && c(`Slot '${n}'${i} has been used more than once.
Each named-slot can be defined and used only once.`), r.push(n);
  });
}, $ = (o, t, s) => (S(o, t, {}), {
  Slot: ({ name: l, children: i }) => p({
    name: l,
    children: i,
    from: o
  }),
  hasSlot: (l) => u(l, o)
});
export {
  $ as defineSlots
};
