{"version":3,"file":"StyleSheet.cjs","sources":["../src/StyleSheet.js"],"sourcesContent":["import isObject from './utils/isObject.js';\nimport __DEV__ from './utils/dev.js';\n\nconst camelizedToDashed = str => str.replace(/([A-Z])/g, (g) => `-${g[0].toLowerCase()}`);\nconst compose = fns => fns.reduce((f, g) => (...args) => f(g(...args)));\n\nconst styleSheetOptions = ['prefix', 'generateUid', 'generateClassName', 'shouldAttachToDOM', 'attributes', 'renderers'];\n\n/**\n * The StyleSheet class is responsible for creating and managing a CSS stylesheet.\n * It takes a styles object and an optional options object as input, processes the styles, \n * and generates a CSS stylesheet that can be attached to the DOM, destroyed, or \n * rendered as a string for server-side rendering.\n * \n * @module\n * @class\n * @param {Object} styles - The styles object. This is an object where keys represent \n * CSS selectors and values are style objects. The styles object is processed through \n * the renderers to generate the final CSS string. It is stored in the instance as `this.styles`.\n * @param {Object} [options={}] - Configuration options. The following options are assigned to the instance (`this`):\n * `prefix`, `generateUid`, `generateClassName`, `shouldAttachToDOM`, `attributes`, `renderers`.\n * @param {String} [options.prefix='fun'] - Prefix for generating unique identifiers and data attributes.\n * @param {Function} [options.generateUid] - Custom function to generate the unique identifier.\n * @param {Function} [options.generateClassName] - Custom function to generate unique class names.\n * @param {Object} [options.attributes] - Attributes to be added to the `<style>` element.\n * @param {Array} [options.renderers=['parseStyles', 'renderStyles']] - Array of renderer functions or method names.\n * Renderers are composed in sequence. Strings or functions are automatically bound to `this`.\n * @param {Function} [options.shouldAttachToDOM] - Custom function to determine whether the StyleSheet should be added to the DOM.\n * \n * @example\n * // Create a new StyleSheet instance with a styles object.\n * const instance = new StyleSheet({\n *     root: {\n *         color: 'black'\n *     }\n * });\n * \n * // Attach the StyleSheet instance to the DOM.\n * instance.attach();\n * \n * // Retrieve the generated classes object from the instance.\n * const { classes } = instance;\n * \n * // Use the generated class name in your component.\n * function Header() {\n *     return <h1 className={classes.root}>Hello World</h1>;\n * }\n * \n * @property {Object} classes - Object mapping original class names to generated unique class names.\n * @property {Object} styles - The original styles object provided to the instance.\n * @property {String} uid - Unique identifier for the StyleSheet instance, generated using `this.generateUid`.\n * @property {String} prefix - Prefix for generating unique identifiers. Set via options or subclass.\n * @property {Object} attributes - Attributes to be added to the `<style>` element. Set via options or subclass.\n * @property {Array} renderers - Array of renderer functions or method names used to process the styles object. Set via options or subclass.\n * @property {HTMLElement} el - Reference to the `<style>` element in the DOM. Created when the instance is attached to the DOM.\n */\nclass StyleSheet {\n    constructor(styles, options = {}) {\n        // Styles object.\n        this.styles = styles;\n        // Original class names object.\n        this.classes = {};\n        // Set options on the instance.\n        styleSheetOptions.forEach(key => {\n            if (key in options) this[key] = options[key];\n        });\n        // Set default renderers.\n        if (!this.renderers) this.renderers = [this.renderStyles, this.parseStyles];\n        // Set default prefix.\n        if (!this.prefix) this.prefix = StyleSheet.prefix;\n        // Generate the `StyleSheet` unique identifier.\n        this.uid = this.generateUid();\n        // Generate class names. Only generate class names for top-level selectors.\n        let counter = 0;\n        Object.keys(styles).forEach(selector => {\n            if (selector.match(StyleSheet.classRegex)) {\n                this.classes[selector] = this.generateClassName(selector, ++counter);\n            }\n        });\n    }\n\n    /**\n     * Generate a stable unique identifier.\n     * May be overridden by `options.generateUid`.\n     * @returns {String} The unique identifier.\n     */\n    generateUid() {\n        const styles = JSON.stringify(this.styles);\n        // FNV-1a 32-bit offset basis.\n        let hash = 2166136261;\n        for (let i = 0; i < styles.length; i++) {\n            // XOR with the byte value.\n            hash ^= styles.charCodeAt(i);\n            // Multiply by FNV prime and ensure 32-bit unsigned integer.\n            hash = (hash * 16777619) >>> 0;\n        }\n        // Convert the hash to a shorter base-36 string.\n        return hash.toString(36);\n    }\n\n    /**\n     * Generate a unique class name.\n     * Transform local selectors that are classes to unique class names\n     * to be used as class names in the styles object.\n     * May be overridden by `options.generateClassName` or by extending the class.\n     * @param {String} className - The class name.\n     * @param {Number} index - The index of the class name.\n     * @returns {String} The unique class name.\n     */\n    generateClassName(className, index) {\n        return __DEV__ && StyleSheet.debug ?\n            `${this.prefix}-${this.uid}-${className}` :\n            `${this.prefix[0]}-${this.uid}-${index}`;\n    }\n\n    /**\n     * Apply the renderers to the styles object.\n     * It will return a string ready to be added to the style element.\n     * @returns {String} The styles object as a string.\n     */\n    render() {\n        const renderers = this.renderers.map(\n            renderer => (typeof renderer === 'string' ? this[renderer] : renderer).bind(this)\n        );\n\n        return compose(renderers)(this.styles);\n    }\n\n    /**\n     * Render the styles object as a string.\n     * Its one of the default renderers.\n     * It will return a string ready to be added to the `style` element.\n     * @param {Object} styles - The styles object.\n     * @param {Number} level - The level of indentation. Used for debugging.\n     * @returns {String} The styles object as a string.\n     * @private\n     */\n    renderStyles(styles, level = 1) {\n        return Object.keys(styles).reduce((acc, key) => {\n            const value = styles[key];\n            let indent = '', nl = '', whitespace = '';\n            // Format the CSS string.\n            if (__DEV__ && StyleSheet.debug) {\n                indent = StyleSheet.indent.repeat(level);\n                nl = '\\n';\n                whitespace = ' ';\n            }\n            // Add the styles to the accumulator recursively.\n            if (isObject(value)) {\n                if (Object.keys(value).length > 0) {\n                    const renderedStyles = this.renderStyles(value, level + 1);\n                    // Add rules to the accumulator.\n                    acc.push(`${indent}${key}${whitespace}{${nl}${renderedStyles}${indent}}${nl}`);\n                }\n            } else if (typeof value !== 'undefined' && value !== null) {\n                // Add the style to the accumulator.\n                acc.push(`${indent}${key}:${whitespace}${value};${nl}`);\n            }\n\n            return acc;\n        }, []).join('');\n    }\n\n    /**\n     * Parse the styles object and transform it.  \n     * Expand nested styles, parse global styles, generate selectors, replace selector references \n     * and convert camelized keys to dashed-case.\n     * Its one of the default renderers.\n     * It will return an object ready to be rendered as string by `renderStyles`.\n     * @param {Object} styles - The styles object.\n     * @param {Object} parent - The parent object. Used for nested styles.\n     * @param {String} parentSelector - The parent selector. Used for nested styles.\n     * @param {Boolean} isGlobal - If true, the styles are global styles.\n     * @returns {Object} The styles object.\n     * @private\n     */\n    parseStyles(styles, parent, parentSelector, isGlobal) {\n        const fromClasses = selector => selector in this.classes ? `.${this.classes[selector]}` : selector;\n        // Parse the key and generate a selector.\n        const generateKey = key => {\n            if (isGlobal && parentSelector) {\n                // Nested global selectors.\n                return `${parentSelector} ${key}`;\n            }\n            if (key.match(StyleSheet.globalPrefixRegex)) {\n                // Global prefix and nested global prefix.\n                return `${parentSelector ? `${parentSelector} ` : ''}${key.replace(StyleSheet.globalPrefixRegex, '')}`;\n            }\n            // Nested, references and replace class names with created ones.\n            return fromClasses(key)\n                .replace(StyleSheet.referenceRegex, (match, ref) => fromClasses(ref))\n                .replace(StyleSheet.nestedRegex, parentSelector);\n        };\n\n        const result = Object.keys(styles).reduce((acc, key) => {\n            const value = styles[key];\n            // Parse styles recursively.\n            if (isObject(value)) {\n                if (key.match(StyleSheet.globalRegex)) {\n                    // Global and nested global styles.\n                    Object.assign(parent || acc, this.parseStyles(value, acc, parentSelector, true));\n                } else if ((key.match(StyleSheet.nestedRegex) || key.match(StyleSheet.globalPrefixRegex)) && parent) {\n                    const selector = generateKey(key);\n                    parent[selector] = {};\n                    // Nested global prefix and nested styles with reference.\n                    Object.assign(parent[selector], this.parseStyles(value, parent, selector));\n                } else {\n                    const selector = generateKey(key);\n                    acc[selector] = {};\n                    // Don't expand at-rules.\n                    const args = selector.match(/@/) ? [] : [acc, selector];\n                    // Regular styles.\n                    Object.assign(acc[selector], this.parseStyles(value, ...args));\n                }\n            } else if (typeof value !== 'undefined' && value !== null) {\n                // Add style rules.\n                // Convert camelCase to dashed-case.\n                // Only convert if the key doesn't already contain a dash.\n                // Allows css vars to contain camelCase parts between dashes.\n                acc[key.match(/-/) ? key : camelizedToDashed(key)] = value;\n            }\n\n            return acc;\n        }, {});\n\n        return result;\n    }\n\n    /**\n     * Get the attributes object.\n     * The attributes object will be used to set the attributes on the style element.\n     * The attributes object will be merged with the `this.attributes` object.\n     * The `data-fun-uid` attribute will be added to the attributes object.\n     * @returns {Object} The attributes object.\n     * @private\n     */\n    getAttributes() {\n        const attributes = Object.assign({}, this.attributes);\n        attributes[`data-${this.prefix}-uid`] = this.uid;\n        return attributes;\n    }\n\n    /**\n     * Render the StyleSheet as a style element string.\n     * Used for server-side rendering.\n     * @returns {String} The instance as a string.\n     */\n    toString() {\n        const attributes = this.getAttributes();\n        const attributesHtml = Object.keys(attributes).map(key => ` ${key}=\"${attributes[key]}\"`).join('');\n        const nl = (__DEV__ && StyleSheet.debug) ? '\\n' : '';\n        return `<style${attributesHtml}>${nl}${this.render()}</style>${nl}`;\n    }\n\n    /**\n     * Check if the StyleSheet should be added to the DOM.\n     * By default, it returns true if running in a browser environment and no style element\n     * with the same `data-fun-uid` attribute exists in the DOM.\n     * This prevents duplicate style elements and ensures proper behavior for server-side rendering.\n     * May be overridden by `options.shouldAttachToDOM`.\n     * @returns {Boolean} True if the StyleSheet should be added to the DOM, false otherwise.\n     */\n    shouldAttachToDOM() {\n        return typeof document !== 'undefined' && !document.querySelector(`style[data-${this.prefix}-uid=\"${this.uid}\"]`);\n    }\n\n    /**\n     * Add the instance to the registry and if we are in the browser, \n     * attach it to the DOM.\n     * @returns {StyleSheet} The instance.\n     */\n    attach() {\n        // Add the instance to the registry if it's not already there.\n        if (!StyleSheet.registry.some(({ uid }) => uid === this.uid)) {\n            StyleSheet.registry.push(this);\n        }\n        // If we're in the browser and the style element doesn't exist, create it.\n        if (this.shouldAttachToDOM()) {\n            // Create the style element.\n            this.el = document.createElement('style');\n\n            const attributes = this.getAttributes();\n            // Set the attributes on the style element.\n            Object.keys(attributes).forEach(key => {\n                this.el.setAttribute(key, attributes[key]);\n            });\n            // Render the styles and set the text content of the style element.\n            this.el.textContent = this.render();\n            // Append the style element to the head.\n            document.head.appendChild(this.el);\n        }\n\n        return this;\n    }\n\n    /**\n     * Destroy the instance and remove it from the registry and \n     * from the DOM, if it's present.\n     * @returns {StyleSheet} The instance.\n     */\n    destroy() {\n        const index = StyleSheet.registry.indexOf(this);\n        // Remove the instance from the registry.\n        if (index > -1) {\n            StyleSheet.registry.splice(index, 1);\n        }\n\n        if (this.el) {\n            // Remove the style element from the DOM.\n            if (this.el.parentNode) {\n                this.el.parentNode.removeChild(this.el);\n            }\n            // Remove the reference to the style element.\n            this.el = null;\n        }\n\n        return this;\n    }\n\n    /**\n     * Render all instances in the registry as a string, including the style tags.\n     * Can be used to insert style tags in an HTML template for server-side rendering.\n     * @returns {string} All instances in the registry as a string.\n     * @static\n     */\n    static toString() {\n        return StyleSheet.registry.join('');\n    }\n\n    /**\n     * Render all instances in the registry as CSS string.\n     * Can be used to generate an external CSS file.\n     * @returns {string} All instances in the registry rendered as CSS string.\n     * @static\n     */\n    static toCSS() {\n        return StyleSheet.registry.map(instance => instance.render()).join('');\n    }\n\n    /**\n     * Destroy all instances in the registry and remove them from \n     * it and from the DOM.\n     * @static\n     */\n    static destroy() {\n        StyleSheet.registry.slice().forEach(instance => instance.destroy());\n    }\n}\n\n/**\n * Regular expressions to match class names.\n * @static\n * @private\n */\nStyleSheet.classRegex = /^\\w+$/;\n\n/**\n * Regular expression to match global styles.\n * @static\n * @private\n */\nStyleSheet.globalRegex = /^@global$/;\n\n/**\n * Regular expression to match global styles with a prefix.\n * @static\n * @private\n */\nStyleSheet.globalPrefixRegex = /^@global\\s+/;\n\n/**\n * Regular expression to match references to other class names.\n * @static\n * @private\n */\nStyleSheet.referenceRegex = /\\$(\\w+)/g;\n\n/**\n * Regular expression to match nested styles.\n * @static\n * @private\n */\nStyleSheet.nestedRegex = /&/g;\n\n/**\n * @static\n * @property {String} prefix - The class prefix. Used to generate unique class names.\n * @default fun\n */\nStyleSheet.prefix = 'fun';\n\n/**\n * @static\n * @property {String} indent - The indent string. Used to format text when debug is enabled. \n * @default '    '\n */\nStyleSheet.indent = '    ';\n\n/**\n * @static\n * @property {Array} registry - The registry array. StyleSheet instances \n * will be added to this array.\n */\nStyleSheet.registry = [];\n\n/**\n * @static\n * @property {Boolean} debug - The debug flag. If true, the styles will be formatted with\n * indentation and new lines.\n * @default __DEV__\n */\nStyleSheet.debug = __DEV__;\n\nexport default StyleSheet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