/* eslint-disable @typescript-eslint/no-explicit-any */
import { createSelector } from "@reduxjs/toolkit"
import { RootState } from "@/store"
import { Page } from "./interface"
export const getAllResources = (state: RootState) => state.resource
export const getController = (state: RootState) => state.currentApp.controller

export const getControllerIDMapResource = createSelector(
    [getAllResources],
    (allResource) => {
        const resourceIDMapResource: Record<string, any> = {}
        allResource.forEach((resource) => {
            resourceIDMapResource[resource.resourceID] = resource
        })
        return resourceIDMapResource
    },
)
export const getControllerRules = createSelector(
    [getController],
    (controller) => {
        return controller.rules
    },
)
export const getControllerRulesfunctions = createSelector(
    [getController],
    (controller) => {
        return controller.getRules
    },
)
export const getAllPagesList = createSelector(
    [getController],
    (controller) => {
        return controller.pages
    },
)
export const getControllerSetStyleFunctions = createSelector(
    [getController],
    (controller) => {
        return controller.setStyles
    },
)