"use strict";Object.defineProperty(exports, "__esModule", {value: true});

var _chunkDDGSFIWAcjs = require('./chunk-DDGSFIWA.cjs');







var _chunkCH2PLO6Fcjs = require('./chunk-CH2PLO6F.cjs');


var _chunkJA7KZV3Qcjs = require('./chunk-JA7KZV3Q.cjs');



var _chunkZ6EUSUADcjs = require('./chunk-Z6EUSUAD.cjs');

// src/utils/toReactNodes/setReactNodesTypography.tsx
var _core = require('@lightsparkdev/core');
function isNonTypographicReactNode(node) {
  return typeof node === "undefined" || node === null || _chunkCH2PLO6Fcjs.isIconNode.call(void 0, node);
}
function setReactNodesTypography(nodesArg, typography, replaceExistingTypography = true) {
  const nodes = _core.ensureArray.call(void 0, 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
  };
  const nodesWithTypography = nodes.map((node) => {
    if (isNonTypographicReactNode(node)) {
      return node;
    } else if (_chunkCH2PLO6Fcjs.isLinkNode.call(void 0, node) && typographyMap.link) {
      return {
        link: _chunkZ6EUSUADcjs.__spreadProps.call(void 0, _chunkZ6EUSUADcjs.__spreadValues.call(void 0, {}, node.link), {
          typography: replaceExistingTypography ? typographyMap.link : node.link.typography || typographyMap.link
        })
      };
    } else if (_chunkCH2PLO6Fcjs.isNextLinkNode.call(void 0, node) && typographyMap.nextLink) {
      return {
        nextLink: _chunkZ6EUSUADcjs.__spreadProps.call(void 0, _chunkZ6EUSUADcjs.__spreadValues.call(void 0, {}, node.nextLink), {
          typography: replaceExistingTypography ? typographyMap.nextLink : node.nextLink.typography || typographyMap.nextLink
        })
      };
    } else if (_chunkCH2PLO6Fcjs.isCurrencyAmountNode.call(void 0, node) && typographyMap.currencyAmount) {
      return {
        currencyAmount: _chunkZ6EUSUADcjs.__spreadProps.call(void 0, _chunkZ6EUSUADcjs.__spreadValues.call(void 0, {}, node.currencyAmount), {
          typography: typographyMap.currencyAmount
        })
      };
    } else if (_chunkCH2PLO6Fcjs.isClipboardTextFieldNode.call(void 0, node) && typographyMap.clipboardTextField) {
      return {
        clipboardTextField: _chunkZ6EUSUADcjs.__spreadProps.call(void 0, _chunkZ6EUSUADcjs.__spreadValues.call(void 0, {}, node.clipboardTextField), {
          typography: typographyMap.clipboardTextField
        })
      };
    } else if ((_chunkCH2PLO6Fcjs.isTextNode.call(void 0, node) || _chunkJA7KZV3Qcjs.isString.call(void 0, node)) && typographyMap.text) {
      return setTextNodeTypography(
        node,
        typographyMap.text,
        replaceExistingTypography
      );
    }
    return node;
  });
  return nodesWithTypography;
}
function setTextNodeTypography(node, typography, replaceExistingTypography = true) {
  if (_chunkJA7KZV3Qcjs.isString.call(void 0, node)) {
    return {
      text: node,
      typography
    };
  }
  const useExistingTypography = !replaceExistingTypography && "typography" in node ? node.typography : void 0;
  return _chunkZ6EUSUADcjs.__spreadProps.call(void 0, _chunkZ6EUSUADcjs.__spreadValues.call(void 0, {}, node), {
    typography: useExistingTypography || typography
  });
}
function toReactNodesWithTypographyMap(nodesArg, nodesTypographyMap, replaceExistingTypography = true) {
  if (!nodesArg) {
    return null;
  }
  const nodesWithTypography = setReactNodesTypography(
    nodesArg,
    nodesTypographyMap,
    replaceExistingTypography
  );
  const nodes = _chunkDDGSFIWAcjs.toReactNodes.call(void 0, nodesWithTypography);
  return nodes;
}
function setDefaultReactNodesTypography(nodesArg, setDefaultReactNodesTypographyArg) {
  return setReactNodesTypography(
    nodesArg,
    setDefaultReactNodesTypographyArg,
    false
  );
}






exports.isNonTypographicReactNode = isNonTypographicReactNode; exports.setReactNodesTypography = setReactNodesTypography; exports.toReactNodesWithTypographyMap = toReactNodesWithTypographyMap; exports.setDefaultReactNodesTypography = setDefaultReactNodesTypography;
