import { StyleMapping as OptimizedMapping , TemplateTypes } from "@opticss/template-api" ; import { Analysis } from "../Analyzer" ; import { ElementAnalysis } from "../Analyzer" ; import { Block , Style } from "../BlockTree" ; import { ResolvedConfiguration } from "../configuration" ; import { IndexedClassRewrite } from "./ClassRewrite" ; import { IndexedClassMapping , RewriteMapping } from "./RewriteMapping" ; export class StyleMapping < T extends keyof TemplateTypes > { /** The analyses that were used to create this mapping. */ analyses : Array < Analysis < T > > | undefined ; /** The blocks that were used to create this mapping. */ blocks : Set < Block > ; private configuration : ResolvedConfiguration ; private optimizedMap : OptimizedMapping ; constructor ( optimizedMap , blocks , configuration , analyses ? ) { this . configuration = configuration ; this . optimizedMap = optimizedMap ; this . blocks = new Set ( blocks ) ; this . analyses = analyses ; } simpleRewriteMapping < B , S , T > ( element ) { let [ optimizedElementInfo , classMap ] = element . forOptimizer ( this . configuration ) ; let classRewrite = this . optimizedMap . rewriteMapping ( optimizedElementInfo ) ; return IndexedClassMapping . fromOptimizer ( classRewrite , classMap ) ; } rewriteMapping < B , S , T > ( element ) { let [ optimizedElementInfo , classMap ] = element . forOptimizer ( this . configuration ) ; let classRewrite = this . optimizedMap . rewriteMapping ( optimizedElementInfo ) ; return RewriteMapping . fromOptimizer ( classRewrite , classMap ) ; } }