/**
 * @typedef {Object} StringCaserOptions
 * @property {"space" | String} separator - define what separates each word, undefined returns no separation - passing "space" separates the words by a space
 * @property {"uppercase" | "lowercase" | "capitalize" | "camelCase" | "PascalCase"} casetype - text case type, uppercase, lowercase of capitalized
 */

/**
 *
 * @param {String} string - text to convert
 * @param {StringCaserOptions} options - options
 * @returns
 */
const StringCaser = (string, { separator, casetype }) => {
  if (!string) return null;
  const removedSpecialCharacters = string.replace(/[^a-zA-Z0-9]/g, " ");
  let casedText = [];
  const splitWords = removedSpecialCharacters.split(" ").filter(Boolean);

  if (casetype === "capitalize") {
    casedText = splitWords.map(
      (/** @type {string} */ dt) => `${dt[0].toUpperCase()}${dt.substring(1)}`
    );
  }
  if (casetype === "uppercase") {
    casedText = splitWords.map((/** @type {string} */ dt) => dt.toUpperCase());
  }
  if (casetype === "lowercase") {
    casedText = splitWords.map((/** @type {string} */ dt) => dt.toLowerCase());
  }
  if (casetype === "camelCase") {
    casedText = splitWords.map((/** @type {string} */ dt, index) =>
      index === 0
        ? dt.toLowerCase()
        : `${dt[0].toUpperCase()}${dt.substring(1)}`
    );
  }
  if (casetype === "PascalCase") {
    casedText = splitWords.map(
      (/** @type {string} */ dt) => `${dt[0].toUpperCase()}${dt.substring(1)}`
    );
  }

  if (separator) {
    if (separator === "space") {
      return casedText.join(" ");
    } else {
      return casedText.join(separator);
    }
  } else {
    return casedText.join("");
  }
};
androidConfig = {
  name: "Manaknight",
  packageName: "com.manaknight.app",
  baseUrl: "https://mkdlabs.com",
  projectId: "manaknight",
  secret: "secret",
  isGoogleMap: false,
  isImage: false,
  isVideo: false,
  isGoogleLogin: false,
  isAppleLogin: false,
  isFacebookLogin: false,
  isInappPurchase: false,
  navigationType: "bottomBar",
  constants: [],
  enums: [],
  libraries: [],
  api: [],
  activity: [
    {
      name: "main",
      type: "",
      layout: "ConstraintLayout",
      components: [
        {
          type: "layout",
          name: "LinearLayoutCompat",
          children: [
            {
              type: "layout",
              name: "LinearLayoutCompat",
              children: [
                {
                  type: "element",
                  name: "text",
                  children: [],
                  props: {
                    text: "The Text in main",
                  },
                },
              ],
              props: {},
            },
          ],
          props: {},
        },
      ],
    },
  ],
  fragment: [
    {
      name: "home",
      type: "",
      layout: "ConstraintLayout",
      startDestination: true,
      actions: [
        {
          destination: "login",
        },
        {
          destination: "reset password",
        },
        {
          destination: "registration",
        },
      ],
      components: [
        {
          type: "element",
          name: "text",
          children: [
            {
              type: "layout",
              name: "LinearLayoutCompat",
              children: [
                {
                  type: "element",
                  name: "text",
                  children: [],
                  props: {
                    text: "The Text in home fragment 3",
                  },
                },
              ],
              props: {},
            },
          ],
          props: { text: "The Text in home fragment 2" },
        },
        {
          type: "element",
          name: "image",
          children: [
            {
              type: "layout",
              name: "LinearLayoutCompat",
              children: [
                {
                  type: "element",
                  name: "text",
                  children: [],
                  props: {
                    text: "The Text in home fragment 1",
                  },
                },
              ],
              props: {},
            },
          ],
          props: { src: "The Text in home fragment" },
        },
      ],
    },
  ],
  navigation: [],
};

function extractTextProperties(fragments) {
  let textProperties = [];
  for (const fragment of fragments) {
    const strings = fragment.components.flatMap((component) => {
      if (component.children.length) {
        return component.props.text
          ? getTextFromChildren(component.children).concat(component.props.text)
          : getTextFromChildren(component.children);
      } else {
        return component.props.text;
      }
    });

    textProperties = textProperties.concat(strings);
  }
  return textProperties;
}
const getTextFromChildren = (children) => {
  return children.flatMap((child) => {
    if (child.children.length) {
      return child.props.text
        ? getTextFromChildren(child.children).concat(child.props.text)
        : getTextFromChildren(child.children);
    } else {
      return child.props.text;
    }
  });
};

const androidComponentList = [
  {
    type: "layout",
    name: "LINEAR_LAYOUT",
    icon: "https://cdn-icons-png.flaticon.com/128/2781/2781931.png",
    order: -1,
    components: [],
  },
  {
    type: "layout",
    name: "RELATIVE_LAYOUT",
    icon: "https://cdn-icons-png.flaticon.com/128/2781/2781931.png",
    order: -1,
    components: [],
  },
  {
    type: "layout",
    name: "CONSTRAINT_LAYOUT",
    icon: "https://cdn-icons-png.flaticon.com/128/2781/2781931.png",
    order: -1,
    components: [],
  },
  {
    type: "layout",
    name: "FRAME_LAYOUT",
    icon: "https://cdn-icons-png.flaticon.com/128/2781/2781931.png",
    order: -1,
    components: [],
  },
  {
    type: "layout",
    name: "TABLE_LAYOUT",
    icon: "https://cdn-icons-png.flaticon.com/128/2781/2781931.png",
    order: -1,
    components: [],
  },
  {
    type: "layout",
    name: "TABLE_ROW",
    icon: "https://cdn-icons-png.flaticon.com/128/2781/2781931.png",
    order: -1,
    components: [],
  },
  {
    type: "layout",
    name: "Scroll_View",
    icon: "https://cdn-icons-png.flaticon.com/128/2781/2781931.png",
    order: -1,
    components: [],
  },
  {
    type: "element",
    name: "EDIT_TEXT",
    icon: "https://cdn-icons-png.flaticon.com/128/2781/2781931.png",
    order: -1,
    components: [],
  },
  {
    type: "layout",
    name: "TEXT_VIEW",
    icon: "https://cdn-icons-png.flaticon.com/128/2781/2781931.png",
    order: -1,
    components: [],
  },
  {
    type: "layout",
    name: "CHECKBOX",
    icon: "https://cdn-icons-png.flaticon.com/128/2781/2781931.png",
    order: -1,
    components: [],
  },
  {
    type: "layout",
    name: "RADIO_BUTTON",
    icon: "https://cdn-icons-png.flaticon.com/128/2781/2781931.png",
    order: -1,
    components: [],
  },
  {
    type: "layout",
    name: "SWITCH",
    icon: "https://cdn-icons-png.flaticon.com/128/2781/2781931.png",
    order: -1,
    components: [],
  },
  {
    type: "layout",
    name: "DATE_PICKER",
    icon: "https://cdn-icons-png.flaticon.com/128/2781/2781931.png",
    order: -1,
    components: [],
  },
  {
    type: "layout",
    name: "TIME_PICKER",
    icon: "https://cdn-icons-png.flaticon.com/128/2781/2781931.png",
    order: -1,
    components: [],
  },
  {
    type: "layout",
    name: "PROGRESS_BAR",
    icon: "https://cdn-icons-png.flaticon.com/128/2781/2781931.png",
    order: -1,
    components: [],
  },
];

const views = [
  {
    type: "layout",
    name: "LinearLayout",
    icon: "https://cdn-icons-png.flaticon.com/128/2781/2781931.png",
    order: -1,
    components: [],
  },
  {
    type: "layout",
    name: "RelativeLayout",
    icon: "https://cdn-icons-png.flaticon.com/128/2781/2781931.png",
    order: -1,
    components: [],
  },
  {
    type: "layout",
    name: "FrameLayout",
    icon: "https://cdn-icons-png.flaticon.com/128/2781/2781931.png",
    order: -1,
    components: [],
  },
  {
    type: "layout",
    name: "ConstraintLayout",
    icon: "https://cdn-icons-png.flaticon.com/128/2781/2781931.png",
    order: -1,
    components: [],
  },
  {
    type: "layout",
    name: "GridLayout",
    icon: "https://cdn-icons-png.flaticon.com/128/2781/2781931.png",
    order: -1,
    components: [],
  },
  {
    type: "layout",
    name: "TableLayout",
    icon: "https://cdn-icons-png.flaticon.com/128/2781/2781931.png",
    order: -1,
    components: [],
  },
  {
    type: "element",
    name: "TableRow",
    icon: "https://cdn-icons-png.flaticon.com/128/2781/2781931.png",
    order: -1,
    components: [],
  },
  {
    type: "layout",
    name: "ScrollView",
    icon: "https://cdn-icons-png.flaticon.com/128/2781/2781931.png",
    order: -1,
    components: [],
  },
  {
    type: "layout",
    name: "CardView",
    icon: "https://cdn-icons-png.flaticon.com/128/2781/2781931.png",
    order: -1,
    components: [],
  },
  {
    type: "element",
    name: "ListView",
    icon: "https://cdn-icons-png.flaticon.com/128/2781/2781931.png",
    order: -1,
    components: [],
  },
  {
    type: "element",
    name: "RecyclerView",
    icon: "https://cdn-icons-png.flaticon.com/128/2781/2781931.png",
    order: -1,
    components: [],
  },
  {
    type: "element",
    name: "CalendarView",
    icon: "https://cdn-icons-png.flaticon.com/128/2781/2781931.png",
    order: -1,
    components: [],
  },
  {
    type: "element",
    name: "RadioGroup",
    icon: "https://cdn-icons-png.flaticon.com/128/2781/2781931.png",
    order: -1,
    components: [],
  },
  {
    type: "element",
    name: "TextView",
    icon: "https://cdn-icons-png.flaticon.com/128/2781/2781931.png",
    order: -1,
    components: [],
  },
  {
    type: "element",
    name: "ImageView",
    icon: "https://cdn-icons-png.flaticon.com/128/2781/2781931.png",
    order: -1,
    components: [],
  },
  {
    type: "element",
    name: "Button",
    icon: "https://cdn-icons-png.flaticon.com/128/2781/2781931.png",
    order: -1,
    components: [],
  },
  {
    type: "element",
    name: "EditText",
    icon: "https://cdn-icons-png.flaticon.com/128/2781/2781931.png",
    order: -1,
    components: [],
  },
  {
    type: "element",
    name: "CheckBox",
    icon: "https://cdn-icons-png.flaticon.com/128/2781/2781931.png",
    order: -1,
    components: [],
  },
  {
    type: "element",
    name: "RadioButton",
    icon: "https://cdn-icons-png.flaticon.com/128/2781/2781931.png",
    order: -1,
    components: [],
  },
  {
    type: "element",
    name: "Switch",
    icon: "https://cdn-icons-png.flaticon.com/128/2781/2781931.png",
    order: -1,
    components: [],
  },
  {
    type: "element",
    name: "ToggleButton",
    icon: "https://cdn-icons-png.flaticon.com/128/2781/2781931.png",
    order: -1,
    components: [],
  },
  {
    type: "element",
    name: "SeekBar",
    icon: "https://cdn-icons-png.flaticon.com/128/2781/2781931.png",
    order: -1,
    components: [],
  },
  {
    type: "element",
    name: "ProgressBar",
    icon: "https://cdn-icons-png.flaticon.com/128/2781/2781931.png",
    order: -1,
    components: [],
  },
  {
    type: "element",
    name: "Spinner",
    icon: "https://cdn-icons-png.flaticon.com/128/2781/2781931.png",
    order: -1,
    components: [],
  },
  {
    type: "element",
    name: "DatePicker",
    icon: "https://cdn-icons-png.flaticon.com/128/2781/2781931.png",
    order: -1,
    components: [],
  },
  {
    type: "element",
    name: "TimePicker",
    icon: "https://cdn-icons-png.flaticon.com/128/2781/2781931.png",
    order: -1,
    components: [],
  },
  {
    type: "element",
    name: "RatingBar",
    icon: "https://cdn-icons-png.flaticon.com/128/2781/2781931.png",
    order: -1,
    components: [],
  },
  {
    type: "element",
    name: "SeekBar",
    icon: "https://cdn-icons-png.flaticon.com/128/2781/2781931.png",
    order: -1,
    components: [],
  },
  {
    type: "element",
    name: "WebView",
    icon: "https://cdn-icons-png.flaticon.com/128/2781/2781931.png",
    order: -1,
    components: [],
  },
  {
    type: "element",
    name: "VideoView",
    icon: "https://cdn-icons-png.flaticon.com/128/2781/2781931.png",
    order: -1,
    components: [],
  },
  {
    type: "element",
    name: "DatePickerDialog",
    icon: "https://cdn-icons-png.flaticon.com/128/2781/2781931.png",
    order: -1,
    components: [],
  },
  {
    type: "element",
    name: "TimePickerDialog",
    icon: "https://cdn-icons-png.flaticon.com/128/2781/2781931.png",
    order: -1,
    components: [],
  },
];

const stringname = [
  "LinearLayout",
  "RelativeLayout",
  "FrameLayout",
  "ConstraintLayout",
  "GridLayout",
  "TableLayout",
  "TableRow",
  "ScrollView",
  "CardView",

  "ListView",
  "RecyclerView",
  "CalendarView",
  "RadioGroup",
  "TextView",
  "ImageView",
  "Button",
  "EditText",
  "CheckBox",
  "RadioButton",
  "Switch",
  "ToggleButton",
  "SeekBar",
  "ProgressBar",
  "Spinner",
  "DatePicker",
  "TimePicker",
  "RatingBar",
  "SeekBar",
  "WebView",
  "VideoView",
  "DatePickerDialog",
  "TimePickerDialog",
];

