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D,IAAA,8BAAgD,EAA9C,oBAAO,EAAE,oBAAqC,CAAC;YAEvD,UAAI,OAAO,0CAAE,MAAM,EAAE;gBACnB,IAAM,YAAY,GAAG,mBAAmB,CAAC,OAAO,IAAI,EAAE,EAAE,EAAE,WAAW,EAAE,YAAY,EAAE,EAAE,OAAO,CAAC,CAAC;gBAEhG,IAAI,YAAY,EAAE;oBAChB,aAAa,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;oBACjC,YAAY,CAAC,YAAY,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;iBACjF;aACF;iBAAM;gBACL,YAAY,CAAC,YAAY,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;aAChD;SACF;KACF;IAED,KAA2B,UAAa,EAAb,+BAAa,EAAb,2BAAa,EAAb,IAAa,EAAE;QAArC,IAAM,YAAY,sBAAA;QACrB,IAAI,YAAY,EAAE;YAChB,iBAAiB,CAAC,YAAY,QAAE,OAAO,0CAAE,qBAAqB,CAAC,CAAC;SACjE;KACF;IAED,OAAO,YAAmB,CAAC;AAC7B,CAAC","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