/* eslint-disable @typescript-eslint/no-explicit-any */
import { FC, memo } from "react";
import ScaleSquare from "@/page/App/components/scaleSquare";
import { ComponentParserProps } from "./interface";
import { useSelector } from "react-redux";
import { getComponentMap } from "@/redux/currentApp/executionTree/executionSelector";
import { Platform } from "react-native";

export const ComponentParser: FC<ComponentParserProps> = (props) => {
  const { displayName, unitW, parentNodeDisplayName, columnNumber } = props;
  const componentMap = useSelector(getComponentMap);
  const widgetType = componentMap[displayName].type;
  if (Platform.OS === "web") {
    return (
      <ScaleSquare
        displayName={displayName}
        widgetType={widgetType}
        unitW={unitW}
        parentNodeDisplayName={parentNodeDisplayName}
        columnNumber={columnNumber}
      />
    );
  }
  return (
    <ScaleSquare
      displayName={displayName}
      widgetType={widgetType}
      unitW={unitW}
      parentNodeDisplayName={parentNodeDisplayName}
      columnNumber={columnNumber}
    />
  );
};

ComponentParser.displayName = "ComponentParser";

export default memo(ComponentParser);



