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AO,KAAK,KAAK,aAC5B,CAKA,YAAA,CAAa,GACT,OAAK,KAAK,aAAa,GAEhB,KAAK,aAAa,GAAY,QAD1B,EAEf,CAKA,KAAA,GACI,KAAK,aAAe,CAAC,EACrB,KAAK,kBAAoB,EAC7B,CAMA,OAAA,GACI,KAAK,OACT,EAEJ,QAAQ,QAAU","file":"/npm/vitest-matchmedia-mock@2.0.3/dist/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/vitest-matchmedia-mock@2.0.3/dist/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nclass MatchMediaMock {\n    constructor() {\n        this.mediaQueries = {};\n        Object.defineProperty(window, 'matchMedia', {\n            writable: true,\n            configurable: true,\n            value: (query) => {\n                this.mediaQueryList = {\n                    matches: query === this.currentMediaQuery,\n                    media: query,\n                    onchange: null,\n                    addListener: (listener) => {\n                        this.addListener(query, listener);\n                    },\n                    removeListener: (listener) => {\n                        this.removeListener(query, listener);\n                    },\n                    addEventListener: (type, listener) => {\n                        if (type !== 'change')\n                            return;\n                        this.addListener(query, listener);\n                    },\n                    removeEventListener: (type, listener) => {\n                        if (type !== 'change')\n                            return;\n                        this.removeListener(query, listener);\n                    },\n                };\n                return this.mediaQueryList;\n            },\n        });\n    }\n    /**\n     * Adds a new listener function for the specified media query\n     * @private\n     */\n    addListener(mediaQuery, listener) {\n        if (!this.mediaQueries[mediaQuery]) {\n            this.mediaQueries[mediaQuery] = [];\n        }\n        const query = this.mediaQueries[mediaQuery];\n        const listenerIndex = query.indexOf(listener);\n        if (listenerIndex !== -1)\n            return;\n        query.push(listener);\n    }\n    /**\n     * Removes a previously added listener function for the specified media query\n     * @private\n     */\n    removeListener(mediaQuery, listener) {\n        if (!this.mediaQueries[mediaQuery])\n            return;\n        const query = this.mediaQueries[mediaQuery];\n        const listenerIndex = query.indexOf(listener);\n        if (listenerIndex === -1)\n            return;\n        query.splice(listenerIndex, 1);\n    }\n    /**\n     * Updates the currently used media query,\n     * and calls previously added listener functions registered for this media query\n     * @public\n     */\n    useMediaQuery(mediaQuery) {\n        if (typeof mediaQuery !== 'string')\n            throw new Error('Media Query must be a string');\n        this.currentMediaQuery = mediaQuery;\n        if (!Object.entries(this.mediaQueries).length)\n            return;\n        const mqListEvent = this.mediaQueries[mediaQuery]\n            ? {\n                matches: true,\n                media: mediaQuery,\n            }\n            : {\n                matches: false,\n                media: mediaQuery,\n            };\n        Object.entries(this.mediaQueries).forEach(([_, value]) => {\n            value.forEach((listener) => {\n                listener.call(this.mediaQueryList, mqListEvent);\n            });\n        });\n    }\n    /**\n     * Returns an array listing the media queries for which the matchMedia has registered listeners\n     * @public\n     */\n    getMediaQueries() {\n        return Object.keys(this.mediaQueries);\n    }\n    /**\n     * Returns a copy of the array of listeners for the specified media query\n     * @public\n     */\n    getListeners(mediaQuery) {\n        if (!this.mediaQueries[mediaQuery])\n            return [];\n        return this.mediaQueries[mediaQuery].slice();\n    }\n    /**\n     * Clears all registered media queries and their listeners\n     * @public\n     */\n    clear() {\n        this.mediaQueries = {};\n        this.currentMediaQuery = '';\n    }\n    /**\n     * Clears all registered media queries and their listeners,\n     * and destroys the implementation of `window.matchMedia`\n     * @public\n     */\n    destroy() {\n        this.clear();\n    }\n}\nexports.default = MatchMediaMock;\n"]}