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B,EAAgB,GAAK,EAKrB,EAAoB,cAAN,EAAoB,QAAU,GAAK,CAEzD,CACA,OAAO,EAAM,cAAc,WAAW,EAAM,GAAS,EACzD,EAEJ,MAAM,EAAiB,EAAM,YAAW,CAAC,EAAO,IAAQ,EAAM,cAAc,EAAgB,OAAO,OAAO,OAAO,OAAO,CAAC,EAAG,GAAQ,CAAE,eAAgB,IAAQ,aAAqC,EAAS,EAAM,YAMlN,OALK,cAAc,IAAI,IACnB,cAAc,IAAI,EAAM,IAAI,KAGhC,cAAc,IAAI,GAAM,IAA2B,QAAtB,EAAK,EAAO,YAAyB,IAAP,EAAgB,EAnLxD,WAmLiF,GAC7F,CACX,EACe,SA5GE,CACb,QAAA,CAAS,KAAc,GACnB,EAAc,SAAQ,GAAK,EAAE,SAAS,KAAc,KACpD,EAAgB,EACpB,GAyGR","file":"/npm/@microsoft/fast-react-wrapper@0.3.25/dist/esm/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.19.2.\n * Original file: /npm/@microsoft/fast-react-wrapper@0.3.25/dist/esm/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","import { FASTElementDefinition, Observable, } from \"@microsoft/fast-element\";\nimport { FoundationElementRegistry, } from \"@microsoft/fast-foundation\";\nconst reservedReactProperties = new Set([\n    \"children\",\n    \"localName\",\n    \"ref\",\n    \"style\",\n    \"className\",\n]);\nconst emptyProps = Object.freeze(Object.create(null));\nconst DEFAULT_CACHE_NAME = \"_default\";\n// This will be a two levels cache Map<type, Map<name, ReactWrapper>>\n// to distinguish components of same type but different tag name.\n// Default name: '_default'\nconst wrappersCache = new Map();\n// There are 2 kinds of refs and there's no built in React API to set one.\nfunction setRef(ref, value) {\n    if (typeof ref === \"function\") {\n        ref(value);\n    }\n    else {\n        ref.current = value;\n    }\n}\nfunction getTagName(type, config) {\n    if (!config.name) {\n        /* eslint-disable-next-line @typescript-eslint/no-non-null-assertion */\n        const definition = FASTElementDefinition.forType(type);\n        if (definition) {\n            config.name = definition.name;\n        }\n        else {\n            throw new Error(\"React wrappers must wrap a FASTElement or be configured with a name.\");\n        }\n    }\n    return config.name;\n}\nfunction getElementEvents(config) {\n    return config.events || (config.events = {});\n}\nfunction keyIsValid(type, config, name) {\n    if (reservedReactProperties.has(name)) {\n        console.warn(`${getTagName(type, config)} contains property ${name} which is a React ` +\n            `reserved property. It will be used by React and not set on ` +\n            `the element.`);\n        return false;\n    }\n    return true;\n}\nfunction getElementKeys(type, config) {\n    if (!config.keys) {\n        if (config.properties) {\n            config.keys = new Set(config.properties.concat(Object.keys(getElementEvents(config))));\n        }\n        else {\n            const keys = new Set(Object.keys(getElementEvents(config)));\n            const accessors = Observable.getAccessors(type.prototype);\n            if (accessors.length > 0) {\n                for (const a of accessors) {\n                    if (keyIsValid(type, config, a.name)) {\n                        keys.add(a.name);\n                    }\n                }\n            }\n            else {\n                for (const p in type.prototype) {\n                    if (!(p in HTMLElement.prototype) && keyIsValid(type, config, p)) {\n                        keys.add(p);\n                    }\n                }\n            }\n            config.keys = keys;\n        }\n    }\n    return config.keys;\n}\n/**\n * @param React - The React module, typically imported from the `react` npm\n * package\n * @param designSystem - A design system to register the components with.\n * @public\n */\nexport function provideReactWrapper(React, designSystem) {\n    let registrations = [];\n    const registry = {\n        register(container, ...rest) {\n            registrations.forEach(x => x.register(container, ...rest));\n            registrations = [];\n        },\n    };\n    function wrap(type, config = {}) {\n        var _a, _b;\n        if (type instanceof FoundationElementRegistry) {\n            if (designSystem) {\n                designSystem.register(type);\n            }\n            else {\n                registrations.push(type);\n            }\n            type = type.type;\n        }\n        const cachedCandidates = wrappersCache.get(type);\n        if (cachedCandidates) {\n            const cachedWrapper = cachedCandidates.get((_a = config.name) !== null && _a !== void 0 ? _a : DEFAULT_CACHE_NAME);\n            if (cachedWrapper) {\n                return cachedWrapper;\n            }\n        }\n        class ReactComponent extends React.Component {\n            constructor() {\n                super(...arguments);\n                this._element = null;\n            }\n            _updateElement(oldProps) {\n                const element = this._element;\n                if (element === null) {\n                    return;\n                }\n                const currentProps = this.props;\n                const previousProps = oldProps || emptyProps;\n                const events = getElementEvents(config);\n                for (const key in this._elementProps) {\n                    const newValue = currentProps[key];\n                    const event = events[key];\n                    if (event === undefined) {\n                        element[key] = newValue;\n                    }\n                    else {\n                        const oldValue = previousProps[key];\n                        if (newValue === oldValue) {\n                            continue;\n                        }\n                        if (oldValue !== undefined) {\n                            element.removeEventListener(event, oldValue);\n                        }\n                        if (newValue !== undefined) {\n                            element.addEventListener(event, newValue);\n                        }\n                    }\n                }\n            }\n            componentDidMount() {\n                this._updateElement();\n            }\n            componentDidUpdate(old) {\n                this._updateElement(old);\n            }\n            render() {\n                // Since refs only get fulfilled once, pass a new one if the user's\n                // ref changed. This allows refs to be fulfilled as expected, going from\n                // having a value to null.\n                const userRef = this.props.__forwardedRef;\n                if (this._ref === undefined || this._userRef !== userRef) {\n                    this._ref = (value) => {\n                        if (this._element === null) {\n                            this._element = value;\n                        }\n                        if (userRef !== null) {\n                            setRef(userRef, value);\n                        }\n                        this._userRef = userRef;\n                    };\n                }\n                // Filter class properties and pass the remaining attributes to React.\n                // This allows attributes to use framework rules\n                // for setting attributes and render correctly under SSR.\n                const newReactProps = { ref: this._ref };\n                const newElementProps = (this._elementProps = {});\n                const elementKeys = getElementKeys(type, config);\n                const currentProps = this.props;\n                for (const k in currentProps) {\n                    const v = currentProps[k];\n                    if (elementKeys.has(k)) {\n                        newElementProps[k] = v;\n                    }\n                    else {\n                        // React does *not* handle `className` for custom elements so\n                        // coerce it to `class` so it's handled correctly.\n                        newReactProps[k === \"className\" ? \"class\" : k] = v;\n                    }\n                }\n                return React.createElement(getTagName(type, config), newReactProps);\n            }\n        }\n        const reactComponent = React.forwardRef((props, ref) => React.createElement(ReactComponent, Object.assign(Object.assign({}, props), { __forwardedRef: ref }), props === null || props === void 0 ? void 0 : props.children));\n        if (!wrappersCache.has(type)) {\n            wrappersCache.set(type, new Map());\n        }\n        // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n        wrappersCache.get(type).set((_b = config.name) !== null && _b !== void 0 ? _b : DEFAULT_CACHE_NAME, reactComponent);\n        return reactComponent;\n    }\n    return { wrap, registry };\n}\n"]}