
import { BannerInnerShadowOption, ElevationAlias, ShadowVariant, ShadowVariantConfig, ShadowVariantWithInvert } from "../../../types/dist/index.js";
import { ArbitraryFixtures, InferArbitraryType } from "../../../fixtures/dist/index.js";
import { AllPossibleProperties, ComponentConfig, ComponentStateConfig, LayerConfig, PossibleStates, VariantConfig, VariantConfigWithComponentStates, VariantConfigWithProperties } from "../types/ComponentConfig.js";
import { SchemaStateValue } from "../types/ConfigSchema.js";
import { ConfigurablePropertiesName, SelectedConfigurableProperty } from "../properties.js";
import { OmitIndexSignature, SimplifyDeep, UnionToIntersection, WritableDeep } from "type-fest";

//#region ../automated-config/dist/utils/buildConfigSchema.d.ts
//#region src/utils/buildConfigSchema.d.ts
/** Infers default option values from all component variants */
type InferredDefaults<C extends ComponentConfig> = (C['variants'] extends NonNullable<ComponentConfig['variants']> ? { [VarKey in keyof C['variants']]: C['variants'][VarKey]['options'][number] } : {}) & (C['subComponents'] extends NonNullable<ComponentConfig['subComponents']> ? UnionToIntersection<{ [SubCompKey in keyof C['subComponents']]: { [VarKey in keyof C['subComponents'][SubCompKey]['variants']]: C['subComponents'][SubCompKey]['variants'][VarKey]['options'][number] } }[keyof C['subComponents']]> : {});
/** Infers type-safe schema value structure for a configurable property */
type InferredPropertySchema<Prop extends SelectedConfigurableProperty<ConfigurablePropertiesName, string>> = {
  type: Prop['typeOfFixture'][number];
  valueType: 'alias' | 'custom';
  value: Prop['name'] extends 'shadow' ? ShadowVariant | ShadowVariantConfig | ElevationAlias : Prop['name'] extends 'insetShadow' ? ShadowVariantWithInvert | ShadowVariantConfig : Prop['name'] extends 'bannerInnerShadow' ? BannerInnerShadowOption : Prop['values'][number][number] | (Extract<Prop['typeOfFixture'][number], ArbitraryFixtures> extends never ? never : InferArbitraryType<Extract<Prop['typeOfFixture'][number], ArbitraryFixtures>>);
};
/** Infers state-to-schema mappings for a property (rest, hover, pressed, focus, etc.) */
type InferredPropertyStates<Prop extends SelectedConfigurableProperty<ConfigurablePropertiesName, string>> = (Prop['skipRestState'] extends true ? {} : {
  rest: InferredPropertySchema<Prop>;
}) & (Prop extends {
  pseudoStates: infer PS extends PossibleStates[];
} ? { [K in PS[number]]: InferredPropertySchema<Prop> } : {});
type GetExcludedPseudoStatesForOption<StateConfig extends ComponentStateConfig, StateOption extends string> = StateConfig extends {
  excludePseudoStatesForOptions?: infer Exclusions extends Partial<Record<string, readonly PossibleStates[]>>;
} ? StateOption extends keyof Exclusions ? Exclusions[StateOption] : undefined : undefined;
/** Property states after applying per-option pseudo-state exclusions */
type InferredPropertyStatesForOption<Prop extends SelectedConfigurableProperty<ConfigurablePropertiesName, string>, ExcludedPseudoStates extends readonly PossibleStates[] | undefined> = (Prop['skipRestState'] extends true ? {} : {
  rest: InferredPropertySchema<Prop>;
}) & (Prop extends {
  pseudoStates: infer PS extends PossibleStates[];
} ? { [K in Exclude<PS[number], ExcludedPseudoStates extends readonly PossibleStates[] ? ExcludedPseudoStates[number] : never>]: InferredPropertySchema<Prop> } : {});
/** Infers property-to-states mappings for a layer's properties */
type InferredLayerProperties<Layer> = Layer extends LayerConfig ? Layer extends {
  properties: infer Props extends LayerConfig['properties'];
} ? { [PropKey in keyof Props]: InferredPropertyStates<Props[PropKey]> } : {} : {};
type InferredLayerPropertiesForOption<Layer, ExcludedPseudoStates extends readonly PossibleStates[] | undefined> = Layer extends LayerConfig ? Layer extends {
  properties: infer Props extends LayerConfig['properties'];
} ? { [PropKey in keyof Props]: InferredPropertyStatesForOption<Props[PropKey], ExcludedPseudoStates> } : {} : {};
/** Generates schema key → properties mappings for a variant's layers or component states */
type InferredSchemaMap<VarKey extends string, VarConfig extends VariantConfig, LayersOrStates extends NonNullable<VariantConfigWithComponentStates['componentStates']> | NonNullable<VariantConfigWithProperties['layers']>, Prefix extends string = ''> = LayersOrStates extends NonNullable<VariantConfigWithComponentStates['componentStates']> ? UnionToIntersection<{ [StateKey in keyof OmitIndexSignature<LayersOrStates>]: UnionToIntersection<{ [StateOption in LayersOrStates[StateKey]['options'][number]]: { [LayerKey in keyof OmitIndexSignature<LayersOrStates[StateKey]['layers']> as `${Prefix}${VarKey}/${VarConfig['options'][number]}/${StateKey & string}/${StateOption}/${LayerKey & string}`]: InferredLayerPropertiesForOption<LayersOrStates[StateKey]['layers'][LayerKey], GetExcludedPseudoStatesForOption<LayersOrStates[StateKey], StateOption>> } }[LayersOrStates[StateKey]['options'][number]]> }[keyof OmitIndexSignature<LayersOrStates>]> : { [LayerKey in keyof OmitIndexSignature<LayersOrStates> as `${Prefix}${VarKey}/${VarConfig['options'][number]}/${LayerKey & string}`]: InferredLayerProperties<LayersOrStates[LayerKey]> };
type InferredVariantLevelProperties<Props extends Record<string, SelectedConfigurableProperty<ConfigurablePropertiesName, string>>> = { [PropKey in keyof Props]: InferredPropertyStates<Props[PropKey]> };
type InferredVariantPropertiesMap<VarKey extends string, VarConfig extends VariantConfigWithProperties, Prefix extends string = ''> = VarConfig extends {
  variantProperties: infer Props extends Record<string, SelectedConfigurableProperty<ConfigurablePropertiesName, string>>;
} ? { [Option in VarConfig['options'][number] as `${Prefix}${VarKey}/${Option}`]: InferredVariantLevelProperties<Props> } : {};
/** Routes to appropriate schema map generator based on variant configuration type */
type InferredVariablesFilter<VarKey extends string, VarConfig extends VariantConfig, Prefix extends string = ''> = VarConfig extends VariantConfigWithComponentStates ? InferredSchemaMap<VarKey, VarConfig, VarConfig['componentStates'], Prefix> : VarConfig extends VariantConfigWithProperties ? InferredSchemaMap<VarKey, VarConfig, VarConfig['layers'], Prefix> & InferredVariantPropertiesMap<VarKey, VarConfig, Prefix> : {};
/** Collects all schema mappings from component variants and subComponents */
type InferredVariables<C extends ComponentConfig> = (C['variants'] extends NonNullable<ComponentConfig['variants']> ? UnionToIntersection<{ [VarKey in keyof C['variants']]: InferredVariablesFilter<VarKey & string, C['variants'][VarKey]> }[keyof C['variants']]> : {}) & (C['subComponents'] extends NonNullable<ComponentConfig['subComponents']> ? UnionToIntersection<{ [SubCompKey in keyof C['subComponents']]: UnionToIntersection<{ [VarKey in keyof C['subComponents'][SubCompKey]['variants']]: InferredVariablesFilter<VarKey & string, C['subComponents'][SubCompKey]['variants'][VarKey], `${SubCompKey & string}/`> }[keyof C['subComponents'][SubCompKey]['variants']]> }[keyof C['subComponents']]> : {});
/** Component schema with inferred defaults and variable schema mappings */
type ComponentSchema<C extends ComponentConfig> = SimplifyDeep<WritableDeep<{
  defaults: InferredDefaults<C>;
  variables: InferredVariables<C>;
}>>;
/** Resolves the fixture type by finding which value set contains the given value */
declare function findFixtureTypeForValue(property: SelectedConfigurableProperty<ConfigurablePropertiesName, string>, value: string | number): AllPossibleProperties;
/** Resolves the fixture type for a property's variant by finding which value set contains the default value */
declare function findFixtureType(property: SelectedConfigurableProperty<ConfigurablePropertiesName, string>, variantKey: string): AllPossibleProperties;
/** Builds component schema from ComponentConfig at runtime */
declare function buildConfigSchema<C extends ComponentConfig>(config: C): ComponentSchema<C>; //#endregion
//#endregion
export { type ComponentSchema, buildConfigSchema, findFixtureType, findFixtureTypeForValue };