33 lines
989 B
JavaScript
33 lines
989 B
JavaScript
"use client";
|
|
import t from "react";
|
|
import { g as u } from "./chunks/feature-registry-B2iuEiEx.js";
|
|
function m({ children: p }) {
|
|
const o = [], s = [];
|
|
function i(r) {
|
|
t.Children.forEach(r, (e) => {
|
|
if (t.isValidElement(e) && e.type === t.Fragment) {
|
|
i(e.props.children);
|
|
return;
|
|
}
|
|
const a = u(e);
|
|
a ? o.push({ feature: a, props: e.props }) : s.push(e);
|
|
});
|
|
}
|
|
i(p), o.sort((r, e) => r.feature.priority - e.feature.priority);
|
|
const n = /* @__PURE__ */ new Set();
|
|
for (const { feature: r } of o) {
|
|
if (n.has(r.name))
|
|
throw new Error(`BiProvider: duplicate <${r.name} /> declaration.`);
|
|
n.add(r.name);
|
|
}
|
|
if (n.has("NextPagesRouter") && n.has("NextAppRouter"))
|
|
throw new Error("BiProvider: select only one Next.js router adapter.");
|
|
return o.reduceRight(
|
|
(r, { feature: e, props: a }) => t.createElement(e.Provider, a, r),
|
|
t.createElement(t.Fragment, null, ...s)
|
|
);
|
|
}
|
|
export {
|
|
m as BiProvider
|
|
};
|