Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
require("../../chunk-BN4qSVkS.cjs");
const require_utils_strings = require("../strings.cjs");
const require_utils_toReactNodes_nodes = require("./nodes.cjs");
const require_utils_toReactNodes_toReactNodes = require("./toReactNodes.cjs");
let _lightsparkdev_core = require("@lightsparkdev/core");
//#region src/utils/toReactNodes/setReactNodesTypography.tsx
function isNonTypographicReactNode(node) {
	return typeof node === "undefined" || node === null || require_utils_toReactNodes_nodes.isIconNode(node);
}
function setReactNodesTypography(nodesArg, typography, replaceExistingTypography = true) {
	const nodes = (0, _lightsparkdev_core.ensureArray)(nodesArg);
	const typographyMap = {
		link: typography.link || typography.default,
		text: typography.text || typography.default,
		nextLink: typography.nextLink || typography.default,
		currencyAmount: typography.currencyAmount || typography.default,
		clipboardTextField: typography.clipboardTextField || typography.default
	};
	return nodes.map((node) => {
		if (isNonTypographicReactNode(node)) return node;
		else if (require_utils_toReactNodes_nodes.isLinkNode(node) && typographyMap.link) return { link: {
			...node.link,
			typography: replaceExistingTypography ? typographyMap.link : node.link.typography || typographyMap.link
		} };
		else if (require_utils_toReactNodes_nodes.isNextLinkNode(node) && typographyMap.nextLink) return { nextLink: {
			...node.nextLink,
			typography: replaceExistingTypography ? typographyMap.nextLink : node.nextLink.typography || typographyMap.nextLink
		} };
		else if (require_utils_toReactNodes_nodes.isCurrencyAmountNode(node) && typographyMap.currencyAmount) return { currencyAmount: {
			...node.currencyAmount,
			typography: typographyMap.currencyAmount
		} };
		else if (require_utils_toReactNodes_nodes.isClipboardTextFieldNode(node) && typographyMap.clipboardTextField) return { clipboardTextField: {
			...node.clipboardTextField,
			typography: typographyMap.clipboardTextField
		} };
		else if ((require_utils_toReactNodes_nodes.isTextNode(node) || require_utils_strings.isString(node)) && typographyMap.text) return setTextNodeTypography(node, typographyMap.text, replaceExistingTypography);
		return node;
	});
}
function setTextNodeTypography(node, typography, replaceExistingTypography = true) {
	if (require_utils_strings.isString(node)) return {
		text: node,
		typography
	};
	const useExistingTypography = !replaceExistingTypography && "typography" in node ? node.typography : void 0;
	return {
		...node,
		typography: useExistingTypography || typography
	};
}
function toReactNodesWithTypographyMap(nodesArg, nodesTypographyMap, replaceExistingTypography = true) {
	if (!nodesArg) return null;
	return require_utils_toReactNodes_toReactNodes.toReactNodes(setReactNodesTypography(nodesArg, nodesTypographyMap, replaceExistingTypography));
}
function setDefaultReactNodesTypography(nodesArg, setDefaultReactNodesTypographyArg) {
	return setReactNodesTypography(nodesArg, setDefaultReactNodesTypographyArg, false);
}
//#endregion
exports.isNonTypographicReactNode = isNonTypographicReactNode;
exports.setDefaultReactNodesTypography = setDefaultReactNodesTypography;
exports.setReactNodesTypography = setReactNodesTypography;
exports.toReactNodesWithTypographyMap = toReactNodesWithTypographyMap;
