{"version":3,"file":"compat.js","sources":["../src/util.js","../src/PureComponent.js","../src/memo.js","../src/forwardRef.js","../src/Children.js","../src/suspense.js","../src/suspense-list.js","../src/portals.js","../src/render.js","../src/index.js"],"sourcesContent":["/**\r\n * Assign properties from `props` to `obj`\r\n * @template O, P The obj and props types\r\n * @param {O} obj The object to copy properties to\r\n * @param {P} props The object to copy properties from\r\n * @returns {O & P}\r\n */\r\nexport function assign(obj, props) {\r\n\tfor (let i in props) obj[i] = props[i];\r\n\treturn /** @type {O & P} */ (obj);\r\n}\r\n\r\n/**\r\n * Check if two objects have a different shape\r\n * @param {object} a\r\n * @param {object} b\r\n * @returns {boolean}\r\n */\r\nexport function shallowDiffers(a, b) {\r\n\tfor (let i in a) if (i !== '__source' && !(i in b)) return true;\r\n\tfor (let i in b) if (i !== '__source' && a[i] !== b[i]) return true;\r\n\treturn false;\r\n}\r\n\r\nexport function removeNode(node) {\r\n\tlet parentNode = node.parentNode;\r\n\tif (parentNode) parentNode.removeChild(node);\r\n}\r\n","import { Component } from 'preact';\r\nimport { shallowDiffers } from './util';\r\n\r\n/**\r\n * Component class with a predefined `shouldComponentUpdate` implementation\r\n */\r\nexport function PureComponent(p) {\r\n\tthis.props = p;\r\n}\r\nPureComponent.prototype = new Component();\r\n// Some third-party libraries check if this property is present\r\nPureComponent.prototype.isPureReactComponent = true;\r\nPureComponent.prototype.shouldComponentUpdate = function(props, state) {\r\n\treturn shallowDiffers(this.props, props) || shallowDiffers(this.state, state);\r\n};\r\n","import { createElement } from 'preact';\r\nimport { shallowDiffers } from './util';\r\n\r\n/**\r\n * Memoize a component, so that it only updates when the props actually have\r\n * changed. This was previously known as `React.pure`.\r\n * @param {import('./internal').FunctionComponent} c functional component\r\n * @param {(prev: object, next: object) => boolean} [comparer] Custom equality function\r\n * @returns {import('./internal').FunctionComponent}\r\n */\r\nexport function memo(c, comparer) {\r\n\tfunction shouldUpdate(nextProps) {\r\n\t\tlet ref = this.props.ref;\r\n\t\tlet updateRef = ref == nextProps.ref;\r\n\t\tif (!updateRef && ref) {\r\n\t\t\tref.call ? ref(null) : (ref.current = null);\r\n\t\t}\r\n\r\n\t\tif (!comparer) {\r\n\t\t\treturn shallowDiffers(this.props, nextProps);\r\n\t\t}\r\n\r\n\t\treturn !comparer(this.props, nextProps) || !updateRef;\r\n\t}\r\n\r\n\tfunction Memoed(props) {\r\n\t\tthis.shouldComponentUpdate = shouldUpdate;\r\n\t\treturn createElement(c, props);\r\n\t}\r\n\tMemoed.displayName = 'Memo(' + (c.displayName || c.name) + ')';\r\n\tMemoed.prototype.isReactComponent = true;\r\n\tMemoed._forwarded = true;\r\n\treturn Memoed;\r\n}\r\n","import { options } from 'preact';\r\nimport { assign } from './util';\r\n\r\nlet oldDiffHook = options._diff;\r\noptions._diff = vnode => {\r\n\tif (vnode.type && vnode.type._forwarded && vnode.ref) {\r\n\t\tvnode.props.ref = vnode.ref;\r\n\t\tvnode.ref = null;\r\n\t}\r\n\tif (oldDiffHook) oldDiffHook(vnode);\r\n};\r\n\r\nexport const REACT_FORWARD_SYMBOL =\r\n\t(typeof Symbol != 'undefined' &&\r\n\t\tSymbol.for &&\r\n\t\tSymbol.for('react.forward_ref')) ||\r\n\t0xf47;\r\n\r\n/**\r\n * Pass ref down to a child. This is mainly used in libraries with HOCs that\r\n * wrap components. Using `forwardRef` there is an easy way to get a reference\r\n * of the wrapped component instead of one of the wrapper itself.\r\n * @param {import('./index').ForwardFn} fn\r\n * @returns {import('./internal').FunctionComponent}\r\n */\r\nexport function forwardRef(fn) {\r\n\t// We always have ref in props.ref, except for\r\n\t// mobx-react. It will call this function directly\r\n\t// and always pass ref as the second argument.\r\n\tfunction Forwarded(props, ref) {\r\n\t\tlet clone = assign({}, props);\r\n\t\tdelete clone.ref;\r\n\t\tref = props.ref || ref;\r\n\t\treturn fn(\r\n\t\t\tclone,\r\n\t\t\t!ref || (typeof ref === 'object' && !('current' in ref)) ? null : ref\r\n\t\t);\r\n\t}\r\n\r\n\t// mobx-react checks for this being present\r\n\tForwarded.$$typeof = REACT_FORWARD_SYMBOL;\r\n\t// mobx-react heavily relies on implementation details.\r\n\t// It expects an object here with a `render` property,\r\n\t// and prototype.render will fail. Without this\r\n\t// mobx-react throws.\r\n\tForwarded.render = Forwarded;\r\n\r\n\tForwarded.prototype.isReactComponent = Forwarded._forwarded = true;\r\n\tForwarded.displayName = 'ForwardRef(' + (fn.displayName || fn.name) + ')';\r\n\treturn Forwarded;\r\n}\r\n","import { toChildArray } from 'preact';\r\n\r\nconst mapFn = (children, fn) => {\r\n\tif (children == null) return null;\r\n\treturn toChildArray(toChildArray(children).map(fn));\r\n};\r\n\r\n// This API is completely unnecessary for Preact, so it's basically passthrough.\r\nexport const Children = {\r\n\tmap: mapFn,\r\n\tforEach: mapFn,\r\n\tcount(children) {\r\n\t\treturn children ? toChildArray(children).length : 0;\r\n\t},\r\n\tonly(children) {\r\n\t\tconst normalized = toChildArray(children);\r\n\t\tif (normalized.length !== 1) throw 'Children.only';\r\n\t\treturn normalized[0];\r\n\t},\r\n\ttoArray: toChildArray\r\n};\r\n","import { Component, createElement, options, Fragment } from 'preact';\r\nimport { assign } from './util';\r\n\r\nconst oldCatchError = options._catchError;\r\noptions._catchError = function(error, newVNode, oldVNode) {\r\n\tif (error.then) {\r\n\t\t/** @type {import('./internal').Component} */\r\n\t\tlet component;\r\n\t\tlet vnode = newVNode;\r\n\r\n\t\tfor (; (vnode = vnode._parent); ) {\r\n\t\t\tif ((component = vnode._component) && component._childDidSuspend) {\r\n\t\t\t\tif (newVNode._dom == null) {\r\n\t\t\t\t\tnewVNode._dom = oldVNode._dom;\r\n\t\t\t\t\tnewVNode._children = oldVNode._children;\r\n\t\t\t\t}\r\n\t\t\t\t// Don't call oldCatchError if we found a Suspense\r\n\t\t\t\treturn component._childDidSuspend(error, newVNode);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\toldCatchError(error, newVNode, oldVNode);\r\n};\r\n\r\nconst oldUnmount = options.unmount;\r\noptions.unmount = function(vnode) {\r\n\t/** @type {import('./internal').Component} */\r\n\tconst component = vnode._component;\r\n\tif (component && component._onResolve) {\r\n\t\tcomponent._onResolve();\r\n\t}\r\n\r\n\t// if the component is still hydrating\r\n\t// most likely it is because the component is suspended\r\n\t// we set the vnode.type as `null` so that it is not a typeof function\r\n\t// so the unmount will remove the vnode._dom\r\n\tif (component && vnode._hydrating === true) {\r\n\t\tvnode.type = null;\r\n\t}\r\n\r\n\tif (oldUnmount) oldUnmount(vnode);\r\n};\r\n\r\nfunction detachedClone(vnode, detachedParent, parentDom) {\r\n\tif (vnode) {\r\n\t\tif (vnode._component && vnode._component.__hooks) {\r\n\t\t\tvnode._component.__hooks._list.forEach(effect => {\r\n\t\t\t\tif (typeof effect._cleanup == 'function') effect._cleanup();\r\n\t\t\t});\r\n\r\n\t\t\tvnode._component.__hooks = null;\r\n\t\t}\r\n\r\n\t\tvnode = assign({}, vnode);\r\n\t\tif (vnode._component != null) {\r\n\t\t\tif (vnode._component._parentDom === parentDom) {\r\n\t\t\t\tvnode._component._parentDom = detachedParent;\r\n\t\t\t}\r\n\t\t\tvnode._component = null;\r\n\t\t}\r\n\r\n\t\tvnode._children =\r\n\t\t\tvnode._children &&\r\n\t\t\tvnode._children.map(child =>\r\n\t\t\t\tdetachedClone(child, detachedParent, parentDom)\r\n\t\t\t);\r\n\t}\r\n\r\n\treturn vnode;\r\n}\r\n\r\nfunction removeOriginal(vnode, detachedParent, originalParent) {\r\n\tif (vnode) {\r\n\t\tvnode._original = null;\r\n\t\tvnode._children =\r\n\t\t\tvnode._children &&\r\n\t\t\tvnode._children.map(child =>\r\n\t\t\t\tremoveOriginal(child, detachedParent, originalParent)\r\n\t\t\t);\r\n\r\n\t\tif (vnode._component) {\r\n\t\t\tif (vnode._component._parentDom === detachedParent) {\r\n\t\t\t\tif (vnode._dom) {\r\n\t\t\t\t\toriginalParent.insertBefore(vnode._dom, vnode._nextDom);\r\n\t\t\t\t}\r\n\t\t\t\tvnode._component._force = true;\r\n\t\t\t\tvnode._component._parentDom = originalParent;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\treturn vnode;\r\n}\r\n\r\n// having custom inheritance instead of a class here saves a lot of bytes\r\nexport function Suspense() {\r\n\t// we do not call super here to golf some bytes...\r\n\tthis._pendingSuspensionCount = 0;\r\n\tthis._suspenders = null;\r\n\tthis._detachOnNextRender = null;\r\n}\r\n\r\n// Things we do here to save some bytes but are not proper JS inheritance:\r\n// - call `new Component()` as the prototype\r\n// - do not set `Suspense.prototype.constructor` to `Suspense`\r\nSuspense.prototype = new Component();\r\n\r\n/**\r\n * @this {import('./internal').SuspenseComponent}\r\n * @param {Promise} promise The thrown promise\r\n * @param {import('./internal').VNode} suspendingVNode The suspending component\r\n */\r\nSuspense.prototype._childDidSuspend = function(promise, suspendingVNode) {\r\n\tconst suspendingComponent = suspendingVNode._component;\r\n\r\n\t/** @type {import('./internal').SuspenseComponent} */\r\n\tconst c = this;\r\n\r\n\tif (c._suspenders == null) {\r\n\t\tc._suspenders = [];\r\n\t}\r\n\tc._suspenders.push(suspendingComponent);\r\n\r\n\tconst resolve = suspended(c._vnode);\r\n\r\n\tlet resolved = false;\r\n\tconst onResolved = () => {\r\n\t\tif (resolved) return;\r\n\r\n\t\tresolved = true;\r\n\t\tsuspendingComponent._onResolve = null;\r\n\r\n\t\tif (resolve) {\r\n\t\t\tresolve(onSuspensionComplete);\r\n\t\t} else {\r\n\t\t\tonSuspensionComplete();\r\n\t\t}\r\n\t};\r\n\r\n\tsuspendingComponent._onResolve = onResolved;\r\n\r\n\tconst onSuspensionComplete = () => {\r\n\t\tif (!--c._pendingSuspensionCount) {\r\n\t\t\t// If the suspension was during hydration we don't need to restore the\r\n\t\t\t// suspended children into the _children array\r\n\t\t\tif (c.state._suspended) {\r\n\t\t\t\tconst suspendedVNode = c.state._suspended;\r\n\t\t\t\tc._vnode._children[0] = removeOriginal(\r\n\t\t\t\t\tsuspendedVNode,\r\n\t\t\t\t\tsuspendedVNode._component._parentDom,\r\n\t\t\t\t\tsuspendedVNode._component._originalParentDom\r\n\t\t\t\t);\r\n\t\t\t}\r\n\r\n\t\t\tc.setState({ _suspended: (c._detachOnNextRender = null) });\r\n\r\n\t\t\tlet suspended;\r\n\t\t\twhile ((suspended = c._suspenders.pop())) {\r\n\t\t\t\tsuspended.forceUpdate();\r\n\t\t\t}\r\n\t\t}\r\n\t};\r\n\r\n\t/**\r\n\t * We do not set `suspended: true` during hydration because we want the actual markup\r\n\t * to remain on screen and hydrate it when the suspense actually gets resolved.\r\n\t * While in non-hydration cases the usual fallback -> component flow would occour.\r\n\t */\r\n\tconst wasHydrating = suspendingVNode._hydrating === true;\r\n\tif (!c._pendingSuspensionCount++ && !wasHydrating) {\r\n\t\tc.setState({ _suspended: (c._detachOnNextRender = c._vnode._children[0]) });\r\n\t}\r\n\tpromise.then(onResolved, onResolved);\r\n};\r\n\r\nSuspense.prototype.componentWillUnmount = function() {\r\n\tthis._suspenders = [];\r\n};\r\n\r\n/**\r\n * @this {import('./internal').SuspenseComponent}\r\n * @param {import('./internal').SuspenseComponent[\"props\"]} props\r\n * @param {import('./internal').SuspenseState} state\r\n */\r\nSuspense.prototype.render = function(props, state) {\r\n\tif (this._detachOnNextRender) {\r\n\t\t// When the Suspense's _vnode was created by a call to createVNode\r\n\t\t// (i.e. due to a setState further up in the tree)\r\n\t\t// it's _children prop is null, in this case we \"forget\" about the parked vnodes to detach\r\n\t\tif (this._vnode._children) {\r\n\t\t\tconst detachedParent = document.createElement('div');\r\n\t\t\tconst detachedComponent = this._vnode._children[0]._component;\r\n\t\t\tthis._vnode._children[0] = detachedClone(\r\n\t\t\t\tthis._detachOnNextRender,\r\n\t\t\t\tdetachedParent,\r\n\t\t\t\t(detachedComponent._originalParentDom = detachedComponent._parentDom)\r\n\t\t\t);\r\n\t\t}\r\n\r\n\t\tthis._detachOnNextRender = null;\r\n\t}\r\n\r\n\t// Wrap fallback tree in a VNode that prevents itself from being marked as aborting mid-hydration:\r\n\t/** @type {import('./internal').VNode} */\r\n\tconst fallback =\r\n\t\tstate._suspended && createElement(Fragment, null, props.fallback);\r\n\tif (fallback) fallback._hydrating = null;\r\n\r\n\treturn [\r\n\t\tcreateElement(Fragment, null, state._suspended ? null : props.children),\r\n\t\tfallback\r\n\t];\r\n};\r\n\r\n/**\r\n * Checks and calls the parent component's _suspended method, passing in the\r\n * suspended vnode. This is a way for a parent (e.g. SuspenseList) to get notified\r\n * that one of its children/descendants suspended.\r\n *\r\n * The parent MAY return a callback. The callback will get called when the\r\n * suspension resolves, notifying the parent of the fact.\r\n * Moreover, the callback gets function `unsuspend` as a parameter. The resolved\r\n * child descendant will not actually get unsuspended until `unsuspend` gets called.\r\n * This is a way for the parent to delay unsuspending.\r\n *\r\n * If the parent does not return a callback then the resolved vnode\r\n * gets unsuspended immediately when it resolves.\r\n *\r\n * @param {import('./internal').VNode} vnode\r\n * @returns {((unsuspend: () => void) => void)?}\r\n */\r\nexport function suspended(vnode) {\r\n\t/** @type {import('./internal').Component} */\r\n\tlet component = vnode._parent._component;\r\n\treturn component && component._suspended && component._suspended(vnode);\r\n}\r\n\r\nexport function lazy(loader) {\r\n\tlet prom;\r\n\tlet component;\r\n\tlet error;\r\n\r\n\tfunction Lazy(props) {\r\n\t\tif (!prom) {\r\n\t\t\tprom = loader();\r\n\t\t\tprom.then(\r\n\t\t\t\texports => {\r\n\t\t\t\t\tcomponent = exports.default || exports;\r\n\t\t\t\t},\r\n\t\t\t\te => {\r\n\t\t\t\t\terror = e;\r\n\t\t\t\t}\r\n\t\t\t);\r\n\t\t}\r\n\r\n\t\tif (error) {\r\n\t\t\tthrow error;\r\n\t\t}\r\n\r\n\t\tif (!component) {\r\n\t\t\tthrow prom;\r\n\t\t}\r\n\r\n\t\treturn createElement(component, props);\r\n\t}\r\n\r\n\tLazy.displayName = 'Lazy';\r\n\tLazy._forwarded = true;\r\n\treturn Lazy;\r\n}\r\n","import { Component, toChildArray } from 'preact';\r\nimport { suspended } from './suspense.js';\r\n\r\n// Indexes to linked list nodes (nodes are stored as arrays to save bytes).\r\nconst SUSPENDED_COUNT = 0;\r\nconst RESOLVED_COUNT = 1;\r\nconst NEXT_NODE = 2;\r\n\r\n// Having custom inheritance instead of a class here saves a lot of bytes.\r\nexport function SuspenseList() {\r\n\tthis._next = null;\r\n\tthis._map = null;\r\n}\r\n\r\n// Mark one of child's earlier suspensions as resolved.\r\n// Some pending callbacks may become callable due to this\r\n// (e.g. the last suspended descendant gets resolved when\r\n// revealOrder === 'together'). Process those callbacks as well.\r\nconst resolve = (list, child, node) => {\r\n\tif (++node[RESOLVED_COUNT] === node[SUSPENDED_COUNT]) {\r\n\t\t// The number a child (or any of its descendants) has been suspended\r\n\t\t// matches the number of times it's been resolved. Therefore we\r\n\t\t// mark the child as completely resolved by deleting it from ._map.\r\n\t\t// This is used to figure out when *all* children have been completely\r\n\t\t// resolved when revealOrder is 'together'.\r\n\t\tlist._map.delete(child);\r\n\t}\r\n\r\n\t// If revealOrder is falsy then we can do an early exit, as the\r\n\t// callbacks won't get queued in the node anyway.\r\n\t// If revealOrder is 'together' then also do an early exit\r\n\t// if all suspended descendants have not yet been resolved.\r\n\tif (\r\n\t\t!list.props.revealOrder ||\r\n\t\t(list.props.revealOrder[0] === 't' && list._map.size)\r\n\t) {\r\n\t\treturn;\r\n\t}\r\n\r\n\t// Walk the currently suspended children in order, calling their\r\n\t// stored callbacks on the way. Stop if we encounter a child that\r\n\t// has not been completely resolved yet.\r\n\tnode = list._next;\r\n\twhile (node) {\r\n\t\twhile (node.length > 3) {\r\n\t\t\tnode.pop()();\r\n\t\t}\r\n\t\tif (node[RESOLVED_COUNT] < node[SUSPENDED_COUNT]) {\r\n\t\t\tbreak;\r\n\t\t}\r\n\t\tlist._next = node = node[NEXT_NODE];\r\n\t}\r\n};\r\n\r\n// Things we do here to save some bytes but are not proper JS inheritance:\r\n// - call `new Component()` as the prototype\r\n// - do not set `Suspense.prototype.constructor` to `Suspense`\r\nSuspenseList.prototype = new Component();\r\n\r\nSuspenseList.prototype._suspended = function(child) {\r\n\tconst list = this;\r\n\tconst delegated = suspended(list._vnode);\r\n\r\n\tlet node = list._map.get(child);\r\n\tnode[SUSPENDED_COUNT]++;\r\n\r\n\treturn unsuspend => {\r\n\t\tconst wrappedUnsuspend = () => {\r\n\t\t\tif (!list.props.revealOrder) {\r\n\t\t\t\t// Special case the undefined (falsy) revealOrder, as there\r\n\t\t\t\t// is no need to coordinate a specific order or unsuspends.\r\n\t\t\t\tunsuspend();\r\n\t\t\t} else {\r\n\t\t\t\tnode.push(unsuspend);\r\n\t\t\t\tresolve(list, child, node);\r\n\t\t\t}\r\n\t\t};\r\n\t\tif (delegated) {\r\n\t\t\tdelegated(wrappedUnsuspend);\r\n\t\t} else {\r\n\t\t\twrappedUnsuspend();\r\n\t\t}\r\n\t};\r\n};\r\n\r\nSuspenseList.prototype.render = function(props) {\r\n\tthis._next = null;\r\n\tthis._map = new Map();\r\n\r\n\tconst children = toChildArray(props.children);\r\n\tif (props.revealOrder && props.revealOrder[0] === 'b') {\r\n\t\t// If order === 'backwards' (or, well, anything starting with a 'b')\r\n\t\t// then flip the child list around so that the last child will be\r\n\t\t// the first in the linked list.\r\n\t\tchildren.reverse();\r\n\t}\r\n\t// Build the linked list. Iterate through the children in reverse order\r\n\t// so that `_next` points to the first linked list node to be resolved.\r\n\tfor (let i = children.length; i--; ) {\r\n\t\t// Create a new linked list node as an array of form:\r\n\t\t// \t[suspended_count, resolved_count, next_node]\r\n\t\t// where suspended_count and resolved_count are numeric counters for\r\n\t\t// keeping track how many times a node has been suspended and resolved.\r\n\t\t//\r\n\t\t// Note that suspended_count starts from 1 instead of 0, so we can block\r\n\t\t// processing callbacks until componentDidMount has been called. In a sense\r\n\t\t// node is suspended at least until componentDidMount gets called!\r\n\t\t//\r\n\t\t// Pending callbacks are added to the end of the node:\r\n\t\t// \t[suspended_count, resolved_count, next_node, callback_0, callback_1, ...]\r\n\t\tthis._map.set(children[i], (this._next = [1, 0, this._next]));\r\n\t}\r\n\treturn props.children;\r\n};\r\n\r\nSuspenseList.prototype.componentDidUpdate = SuspenseList.prototype.componentDidMount = function() {\r\n\t// Iterate through all children after mounting for two reasons:\r\n\t// 1. As each node[SUSPENDED_COUNT] starts from 1, this iteration increases\r\n\t// each node[RELEASED_COUNT] by 1, therefore balancing the counters.\r\n\t// The nodes can now be completely consumed from the linked list.\r\n\t// 2. Handle nodes that might have gotten resolved between render and\r\n\t// componentDidMount.\r\n\tthis._map.forEach((node, child) => {\r\n\t\tresolve(this, child, node);\r\n\t});\r\n};\r\n","import { createElement, render } from 'preact';\r\n\r\n/**\r\n * @param {import('../../src/index').RenderableProps<{ context: any }>} props\r\n */\r\nfunction ContextProvider(props) {\r\n\tthis.getChildContext = () => props.context;\r\n\treturn props.children;\r\n}\r\n\r\n/**\r\n * Portal component\r\n * @this {import('./internal').Component}\r\n * @param {object | null | undefined} props\r\n *\r\n * TODO: use createRoot() instead of fake root\r\n */\r\nfunction Portal(props) {\r\n\tconst _this = this;\r\n\tlet container = props._container;\r\n\r\n\t_this.componentWillUnmount = function() {\r\n\t\trender(null, _this._temp);\r\n\t\t_this._temp = null;\r\n\t\t_this._container = null;\r\n\t};\r\n\r\n\t// When we change container we should clear our old container and\r\n\t// indicate a new mount.\r\n\tif (_this._container && _this._container !== container) {\r\n\t\t_this.componentWillUnmount();\r\n\t}\r\n\r\n\t// When props.vnode is undefined/false/null we are dealing with some kind of\r\n\t// conditional vnode. This should not trigger a render.\r\n\tif (props._vnode) {\r\n\t\tif (!_this._temp) {\r\n\t\t\t_this._container = container;\r\n\r\n\t\t\t// Create a fake DOM parent node that manages a subset of `container`'s children:\r\n\t\t\t_this._temp = {\r\n\t\t\t\tnodeType: 1,\r\n\t\t\t\tparentNode: container,\r\n\t\t\t\tchildNodes: [],\r\n\t\t\t\tappendChild(child) {\r\n\t\t\t\t\tthis.childNodes.push(child);\r\n\t\t\t\t\t_this._container.appendChild(child);\r\n\t\t\t\t},\r\n\t\t\t\tinsertBefore(child, before) {\r\n\t\t\t\t\tthis.childNodes.push(child);\r\n\t\t\t\t\t_this._container.appendChild(child);\r\n\t\t\t\t},\r\n\t\t\t\tremoveChild(child) {\r\n\t\t\t\t\tthis.childNodes.splice(this.childNodes.indexOf(child) >>> 1, 1);\r\n\t\t\t\t\t_this._container.removeChild(child);\r\n\t\t\t\t}\r\n\t\t\t};\r\n\t\t}\r\n\r\n\t\t// Render our wrapping element into temp.\r\n\t\trender(\r\n\t\t\tcreateElement(ContextProvider, { context: _this.context }, props._vnode),\r\n\t\t\t_this._temp\r\n\t\t);\r\n\t}\r\n\t// When we come from a conditional render, on a mounted\r\n\t// portal we should clear the DOM.\r\n\telse if (_this._temp) {\r\n\t\t_this.componentWillUnmount();\r\n\t}\r\n}\r\n\r\n/**\r\n * Create a `Portal` to continue rendering the vnode tree at a different DOM node\r\n * @param {import('./internal').VNode} vnode The vnode to render\r\n * @param {import('./internal').PreactElement} container The DOM node to continue rendering in to.\r\n */\r\nexport function createPortal(vnode, container) {\r\n\treturn createElement(Portal, { _vnode: vnode, _container: container });\r\n}\r\n","import {\r\n\trender as preactRender,\r\n\thydrate as preactHydrate,\r\n\toptions,\r\n\ttoChildArray,\r\n\tComponent\r\n} from 'preact';\r\n\r\nexport const REACT_ELEMENT_TYPE =\r\n\t(typeof Symbol != 'undefined' && Symbol.for && Symbol.for('react.element')) ||\r\n\t0xeac7;\r\n\r\nconst CAMEL_PROPS = /^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|marker(?!H|W|U)|overline|paint|stop|strikethrough|stroke|text(?!L)|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/;\r\n\r\nconst IS_DOM = typeof document !== 'undefined';\r\n\r\n// Input types for which onchange should not be converted to oninput.\r\n// type=\"file|checkbox|radio\", plus \"range\" in IE11.\r\n// (IE11 doesn't support Symbol, which we use here to turn `rad` into `ra` which matches \"range\")\r\nconst onChangeInputType = type =>\r\n\t(typeof Symbol != 'undefined' && typeof Symbol() == 'symbol'\r\n\t\t? /fil|che|rad/i\r\n\t\t: /fil|che|ra/i\r\n\t).test(type);\r\n\r\n// Some libraries like `react-virtualized` explicitly check for this.\r\nComponent.prototype.isReactComponent = {};\r\n\r\n// `UNSAFE_*` lifecycle hooks\r\n// Preact only ever invokes the unprefixed methods.\r\n// Here we provide a base \"fallback\" implementation that calls any defined UNSAFE_ prefixed method.\r\n// - If a component defines its own `componentDidMount()` (including via defineProperty), use that.\r\n// - If a component defines `UNSAFE_componentDidMount()`, `componentDidMount` is the alias getter/setter.\r\n// - If anything assigns to an `UNSAFE_*` property, the assignment is forwarded to the unprefixed property.\r\n// See https://github.com/preactjs/preact/issues/1941\r\n[\r\n\t'componentWillMount',\r\n\t'componentWillReceiveProps',\r\n\t'componentWillUpdate'\r\n].forEach(key => {\r\n\tObject.defineProperty(Component.prototype, key, {\r\n\t\tconfigurable: true,\r\n\t\tget() {\r\n\t\t\treturn this['UNSAFE_' + key];\r\n\t\t},\r\n\t\tset(v) {\r\n\t\t\tObject.defineProperty(this, key, {\r\n\t\t\t\tconfigurable: true,\r\n\t\t\t\twritable: true,\r\n\t\t\t\tvalue: v\r\n\t\t\t});\r\n\t\t}\r\n\t});\r\n});\r\n\r\n/**\r\n * Proxy render() since React returns a Component reference.\r\n * @param {import('./internal').VNode} vnode VNode tree to render\r\n * @param {import('./internal').PreactElement} parent DOM node to render vnode tree into\r\n * @param {() => void} [callback] Optional callback that will be called after rendering\r\n * @returns {import('./internal').Component | null} The root component reference or null\r\n */\r\nexport function render(vnode, parent, callback) {\r\n\t// React destroys any existing DOM nodes, see #1727\r\n\t// ...but only on the first render, see #1828\r\n\tif (parent._children == null) {\r\n\t\tparent.textContent = '';\r\n\t}\r\n\r\n\tpreactRender(vnode, parent);\r\n\tif (typeof callback == 'function') callback();\r\n\r\n\treturn vnode ? vnode._component : null;\r\n}\r\n\r\nexport function hydrate(vnode, parent, callback) {\r\n\tpreactHydrate(vnode, parent);\r\n\tif (typeof callback == 'function') callback();\r\n\r\n\treturn vnode ? vnode._component : null;\r\n}\r\n\r\nlet oldEventHook = options.event;\r\noptions.event = e => {\r\n\tif (oldEventHook) e = oldEventHook(e);\r\n\te.persist = empty;\r\n\te.isPropagationStopped = isPropagationStopped;\r\n\te.isDefaultPrevented = isDefaultPrevented;\r\n\treturn (e.nativeEvent = e);\r\n};\r\n\r\nfunction empty() {}\r\n\r\nfunction isPropagationStopped() {\r\n\treturn this.cancelBubble;\r\n}\r\n\r\nfunction isDefaultPrevented() {\r\n\treturn this.defaultPrevented;\r\n}\r\n\r\nlet classNameDescriptor = {\r\n\tconfigurable: true,\r\n\tget() {\r\n\t\treturn this.class;\r\n\t}\r\n};\r\n\r\nlet oldVNodeHook = options.vnode;\r\noptions.vnode = vnode => {\r\n\tlet type = vnode.type;\r\n\tlet props = vnode.props;\r\n\tlet normalizedProps = props;\r\n\r\n\t// only normalize props on Element nodes\r\n\tif (typeof type === 'string') {\r\n\t\tconst nonCustomElement = type.indexOf('-') === -1;\r\n\t\tnormalizedProps = {};\r\n\r\n\t\tfor (let i in props) {\r\n\t\t\tlet value = props[i];\r\n\r\n\t\t\tif (IS_DOM && i === 'children' && type === 'noscript') {\r\n\t\t\t\t// Emulate React's behavior of not rendering the contents of noscript tags on the client.\r\n\t\t\t\tcontinue;\r\n\t\t\t}\r\n\t\t\telse if (i === 'value' && 'defaultValue' in props && value == null) {\r\n\t\t\t\t// Skip applying value if it is null/undefined and we already set\r\n\t\t\t\t// a default value\r\n\t\t\t\tcontinue;\r\n\t\t\t} else if (\r\n\t\t\t\ti === 'defaultValue' &&\r\n\t\t\t\t'value' in props &&\r\n\t\t\t\tprops.value == null\r\n\t\t\t) {\r\n\t\t\t\t// `defaultValue` is treated as a fallback `value` when a value prop is present but null/undefined.\r\n\t\t\t\t// `defaultValue` for Elements with no value prop is the same as the DOM defaultValue property.\r\n\t\t\t\ti = 'value';\r\n\t\t\t} else if (i === 'download' && value === true) {\r\n\t\t\t\t// Calling `setAttribute` with a truthy value will lead to it being\r\n\t\t\t\t// passed as a stringified value, e.g. `download=\"true\"`. React\r\n\t\t\t\t// converts it to an empty string instead, otherwise the attribute\r\n\t\t\t\t// value will be used as the file name and the file will be called\r\n\t\t\t\t// \"true\" upon downloading it.\r\n\t\t\t\tvalue = '';\r\n\t\t\t} else if (/ondoubleclick/i.test(i)) {\r\n\t\t\t\ti = 'ondblclick';\r\n\t\t\t} else if (\r\n\t\t\t\t/^onchange(textarea|input)/i.test(i + type) &&\r\n\t\t\t\t!onChangeInputType(props.type)\r\n\t\t\t) {\r\n\t\t\t\ti = 'oninput';\r\n\t\t\t} else if (/^onfocus$/i.test(i)) {\r\n\t\t\t\ti = 'onfocusin';\r\n\t\t\t} else if (/^onblur$/i.test(i)) {\r\n\t\t\t\ti = 'onfocusout';\r\n\t\t\t} else if (/^on(Ani|Tra|Tou|BeforeInp)/.test(i)) {\r\n\t\t\t\ti = i.toLowerCase();\r\n\t\t\t} else if (nonCustomElement && CAMEL_PROPS.test(i)) {\r\n\t\t\t\ti = i.replace(/[A-Z0-9]/, '-$&').toLowerCase();\r\n\t\t\t} else if (value === null) {\r\n\t\t\t\tvalue = undefined;\r\n\t\t\t}\r\n\r\n\t\t\tnormalizedProps[i] = value;\r\n\t\t}\r\n\r\n\t\t// Add support for array select values: