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BAEhG,IAAI,YAAY,EAAE;wBAChB,aAAa,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;wBACjC,YAAY,CAAC,YAAY,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;qBACjF;iBACF;qBAAM;oBACL,YAAY,CAAC,YAAY,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;iBAChD;aACF;SACF;QAED,KAA2B,UAAa,EAAb,+BAAa,EAAb,2BAAa,EAAb,IAAa,EAAE;YAArC,IAAM,YAAY,sBAAA;YACrB,IAAI,YAAY,EAAE;gBAChB,oCAAiB,CAAC,YAAY,QAAE,OAAO,0CAAE,qBAAqB,CAAC,CAAC;aACjE;SACF;QAED,OAAO,YAAmB,CAAC;IAC7B,CAAC;IA/CD,oCA+CC","sourcesContent":["import { concatStyleSets } from './concatStyleSets';\nimport { extractStyleParts } from './extractStyleParts';\nimport { IStyle } from './IStyle';\nimport { IStyleOptions } from './IStyleOptions';\nimport { IConcatenatedStyleSet, IProcessedStyleSet, IStyleSet } from './IStyleSet';\nimport { getStyleOptions } from './StyleOptionsState';\nimport { applyRegistration, styleToRegistration } from './styleToClassName';\nimport { ObjectOnly } from './ObjectOnly';\n\n/**\n * Takes in one or more style set objects, each consisting of a set of areas,\n * each which will produce a class name. Using this is analogous to calling\n * `mergeStyles` for each property in the object, but ensures we maintain the\n * set ordering when multiple style sets are merged.\n *\n * @param styleSet - The first style set to be merged and reigstered.\n */\nexport function mergeStyleSets<TStyleSet>(\n styleSet: TStyleSet | false | null | undefined,\n): IProcessedStyleSet<ObjectOnly<TStyleSet>>;\n\n/**\n * Takes in one or more style set objects, each consisting of a set of areas,\n * each which will produce a class name. Using this is analogous to calling\n * `mergeStyles` for each property in the object, but ensures we maintain the\n * set ordering when multiple style sets are merged.\n *\n * @param styleSet1 - The first style set to be merged.\n * @param styleSet2 - The second style set to be merged.\n */\nexport function mergeStyleSets<TStyleSet1, TStyleSet2>(\n styleSet1: TStyleSet1 | false | null | undefined,\n styleSet2: TStyleSet2 | false | null | undefined,\n): IProcessedStyleSet<ObjectOnly<TStyleSet1> & ObjectOnly<TStyleSet2>>;\n\n/**\n * Takes in one or more style set objects, each consisting of a set of areas,\n * each which will produce a class name. Using this is analogous to calling\n * `mergeStyles` for each property in the object, but ensures we maintain the\n * set ordering when multiple style sets are merged.\n *\n * @param styleSet1 - The first style set to be merged.\n * @param styleSet2 - The second style set to be merged.\n * @param styleSet3 - The third style set to be merged.\n */\nexport function mergeStyleSets<TStyleSet1, TStyleSet2, TStyleSet3>(\n styleSet1: TStyleSet1 | false | null | undefined,\n styleSet2: TStyleSet2 | false | null | undefined,\n styleSet3: TStyleSet3 | false | null | undefined,\n): IProcessedStyleSet<ObjectOnly<TStyleSet1> & ObjectOnly<TStyleSet2> & ObjectOnly<TStyleSet3>>;\n\n/**\n * Takes in one or more style set objects, each consisting of a set of areas,\n * each which will produce a class name. Using this is analogous to calling\n * `mergeStyles` for each property in the object, but ensures we maintain the\n * set ordering when multiple style sets are merged.\n *\n * @param styleSet1 - The first style set to be merged.\n * @param styleSet2 - The second style set to be merged.\n * @param styleSet3 - The third style set to be merged.\n * @param styleSet4 - The fourth style set to be merged.\n */\nexport function mergeStyleSets<TStyleSet1, TStyleSet2, TStyleSet3, TStyleSet4>(\n styleSet1: TStyleSet1 | false | null | undefined,\n styleSet2: TStyleSet2 | false | null | undefined,\n styleSet3: TStyleSet3 | false | null | undefined,\n styleSet4: TStyleSet4 | false | null | undefined,\n): IProcessedStyleSet<\n ObjectOnly<TStyleSet1> & ObjectOnly<TStyleSet2> & ObjectOnly<TStyleSet3> & ObjectOnly<TStyleSet4>\n>;\n\n/**\n * Takes in one or more style set objects, each consisting of a set of areas,\n * each which will produce a class name. Using this is analogous to calling\n * `mergeStyles` for each property in the object, but ensures we maintain the\n * set ordering when multiple style sets are merged.\n *\n * @param styleSets - One or more style sets to be merged.\n */\nexport function mergeStyleSets(...styleSets: Array<IStyleSet | undefined | false | null>): IProcessedStyleSet<any>;\n\n/**\n * Takes in one or more style set objects, each consisting of a set of areas,\n * each which will produce a class name. Using this is analogous to calling\n * `mergeStyles` for each property in the object, but ensures we maintain the\n * set ordering when multiple style sets are merged.\n *\n * @param styleSets - One or more style sets to be merged.\n */\nexport function mergeStyleSets(...styleSets: Array<IStyleSet | undefined | false | null>): IProcessedStyleSet<any> {\n return mergeCssSets(styleSets as any, getStyleOptions());\n}\n\n/**\n * Takes in one or more style set objects, each1consisting of a set of areas,\n * each which will produce a class name. Using this is analogous to calling\n * `mergeCss` for each property in the object, but ensures we maintain the\n * set ordering when multiple style sets are merged.\n *\n * @param styleSets - One or more style sets to be merged.\n * @param options - (optional) Options to use when creating rules.\n */\nexport function mergeCssSets<TStyleSet>(\n styleSets: [TStyleSet | false | null | undefined],\n options?: IStyleOptions,\n): IProcessedStyleSet<TStyleSet>;\n\n/**\n * Takes in one or more style set objects, each1consisting of a set of areas,\n * each which will produce a class name. Using this is analogous to calling\n * `mergeCss` for each property in the object, but ensures we maintain the\n * set ordering when multiple style sets are merged.\n *\n * @param styleSets - One or more style sets to be merged.\n * @param options - (optional) Options to use when creating rules.\n */\nexport function mergeCssSets<TStyleSet1, TStyleSet2>(\n styleSets: [TStyleSet1 | false | null | undefined, TStyleSet2 | false | null | undefined],\n options?: IStyleOptions,\n): IProcessedStyleSet<TStyleSet1 & TStyleSet2>;\n\n/**\n * Takes in one or more style set objects, each1consisting of a set of areas,\n * each which will produce a class name. Using this is analogous to calling\n * `mergeCss` for each property in the object, but ensures we maintain the\n * set ordering when multiple style sets are merged.\n *\n * @param styleSets - One or more style sets to be merged.\n * @param options - (optional) Options to use when creating rules.\n */\nexport function mergeCssSets<TStyleSet1, TStyleSet2, TStyleSet3>(\n styleSets: [\n TStyleSet1 | false | null | undefined,\n TStyleSet2 | false | null | undefined,\n TStyleSet3 | false | null | undefined,\n ],\n options?: IStyleOptions,\n): IProcessedStyleSet<TStyleSet1 & TStyleSet2 & TStyleSet3>;\n\n/**\n * Takes in one or more style set objects, each1consisting of a set of areas,\n * each which will produce a class name. Using this is analogous to calling\n * `mergeCss` for each property in the object, but ensures we maintain the\n * set ordering when multiple style sets are merged.\n *\n * @param styleSets - One or more style sets to be merged.\n * @param options - (optional) Options to use when creating rules.\n */\nexport function mergeCssSets<TStyleSet1, TStyleSet2, TStyleSet3, TStyleSet4>(\n styleSets: [\n TStyleSet1 | false | null | undefined,\n TStyleSet2 | false | null | undefined,\n TStyleSet3 | false | null | undefined,\n TStyleSet4 | false | null | undefined,\n ],\n options?: IStyleOptions,\n): IProcessedStyleSet<\n ObjectOnly<TStyleSet1> & ObjectOnly<TStyleSet2> & ObjectOnly<TStyleSet3> & ObjectOnly<TStyleSet4>\n>;\n\n/**\n * Takes in one or more style set objects, each1consisting of a set of areas,\n * each which will produce a class name. Using this is analogous to calling\n * `mergeCss` for each property in the object, but ensures we maintain the\n * set ordering when multiple style sets are merged.\n *\n * @param styleSets - One or more style sets to be merged.\n * @param options - (optional) Options to use when creating rules.\n */\nexport function mergeCssSets<TStyleSet>(\n styleSet: [TStyleSet | false | null | undefined],\n options?: IStyleOptions,\n): IProcessedStyleSet<TStyleSet>;\n\n/**\n * Takes in one or more style set objects, each1consisting of a set of areas,\n * each which will produce a class name. Using this is analogous to calling\n * `mergeCss` for each property in the object, but ensures the\n * set ordering when multiple style sets are merged.\n *\n * @param styleSets - One or more style sets to be merged.\n * @param options - (optional) Options to use when creating rules.\n */\nexport function mergeCssSets(\n styleSets: Array<IStyleSet | undefined | false | null>,\n options?: IStyleOptions,\n): IProcessedStyleSet<any> {\n const classNameSet: IProcessedStyleSet<any> = { subComponentStyles: {} };\n\n const styleSet = styleSets[0];\n\n if (!styleSet && styleSets.length <= 1) {\n return { subComponentStyles: {} } as any;\n }\n\n const concatenatedStyleSet = concatStyleSets(...styleSets);\n\n const registrations = [];\n\n for (const styleSetArea in concatenatedStyleSet) {\n if (concatenatedStyleSet.hasOwnProperty(styleSetArea)) {\n if (styleSetArea === 'subComponentStyles') {\n classNameSet.subComponentStyles = (concatenatedStyleSet as IConcatenatedStyleSet<any>).subComponentStyles || {};\n continue;\n }\n\n const styles: IStyle = (concatenatedStyleSet as any)[styleSetArea];\n\n const { classes, objects } = extractStyleParts(styles);\n\n if (objects?.length) {\n const registration = styleToRegistration(options || {}, { displayName: styleSetArea }, objects);\n\n if (registration) {\n registrations.push(registration);\n classNameSet[styleSetArea] = classes.concat([registration.className]).join(' ');\n }\n } else {\n classNameSet[styleSetArea] = classes.join(' ');\n }\n }\n }\n\n for (const registration of registrations) {\n if (registration) {\n applyRegistration(registration, options?.specificityMultiplier);\n }\n }\n\n return classNameSet as any;\n}\n"]}
\No newline at end of file