{"version":3,"file":"style.mjs","names":["React","STATIC_COMPONENT","sstyled","STYLES_CONTEXT","Symbol","STYLES_SELF","Enhancement","childComponents","Context","condition","Component","Boolean","style","init","props","WrapperComponent","styles","merge","_styles","context","Object","keys","length","asProps","wrapperProps","useContext"],"sources":["../../src/enhancement/style.tsx"],"sourcesContent":["import React from 'react';\n\nimport { STATIC_COMPONENT } from './staticChildren';\nimport { sstyled } from '../styled/index';\n\nexport const STYLES_CONTEXT = Symbol('STYLES_CONTEXT');\nconst STYLES_SELF = Symbol('STYLES_SELF');\n\nfunction Enhancement(childComponents: any, Context: any) {\n  return {\n    condition: function (Component: any) {\n      return Boolean(Component.style || Component[STATIC_COMPONENT]);\n    },\n    init: function (this: any, props: any, WrapperComponent: any) {\n      if (props.styles) {\n        this[STYLES_SELF] = props.styles;\n      }\n      if (WrapperComponent.style) {\n        this[STYLES_SELF] = sstyled.merge(WrapperComponent.style, props._styles);\n      }\n    },\n    context: function (this: any, context: any): any {\n      // Optimization: if has no children there is no need to create new context (by lsroman)\n      if (!this[STYLES_SELF] || !Object.keys(childComponents).length) {\n        return context;\n      }\n      return {\n        ...context,\n        [STYLES_CONTEXT]: this[STYLES_SELF],\n      };\n    },\n\n    asProps: function (this: any, { _styles, styles, ...props }: any) {\n      return {\n        ...props,\n        styles: this[STYLES_SELF],\n      };\n    },\n    wrapperProps: function (this: any, { styles, ...props }: any) {\n      const context: any = React.useContext(Context);\n      return {\n        ...props,\n        _styles: styles,\n        styles: context[STYLES_CONTEXT],\n      };\n    },\n  };\n}\n\nexport default Enhancement;\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AAEzB,SAASC,gBAAgB,QAAQ,sBAAkB;AACnD,SAASC,OAAO,QAAQ,qBAAiB;AAEzC,OAAO,MAAMC,cAAc,GAAGC,MAAM,CAAC,gBAAgB,CAAC;AACtD,MAAMC,WAAW,GAAGD,MAAM,CAAC,aAAa,CAAC;AAEzC,SAASE,WAAWA,CAACC,eAAoB,EAAE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