{"map":"{\"version\":3,\"file\":\"_debounce.js\",\"sourceRoot\":\"\",\"sources\":[\"../../../../src/operators/foundation/_debounce.ts\"],\"names\":[],\"mappings\":\"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EACL,SAAS,GACV,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,gBAAgB,GACjB,MAAM,2BAA2B,CAAC;AAmBnC,MAAM,uBAAwE,UAAa;IAEzF,MAAM,CAAC,KAAM,SAAQ,UAAU;QAC7B;;;;;;;;WAQG;QACH,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,EAAE,EAAE,GAAG,EAAE;YACrC,MAAM,CAAC,IAAI,gBAAgB,CACzB,CAAC,QAAqB;gBACpB,IAAI,YAAY,GAAG,KAAK,CAAC;gBACzB,IAAI,SAAY,CAAC;gBAEjB,MAAM,iBAAiB,GAAG,IAAI,CAAC,SAAS,CACtC,CAAC,KAAQ;oBACP,SAAS,GAAG,KAAK,CAAC;oBAClB,YAAY,GAAG,IAAI,CAAC;gBACtB,CAAC,CACF,CAAC;gBAEF,MAAM,iBAAiB,GAAG,MAAM,CAAC,SAAS,CACxC;oBACE,EAAE,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC;wBACjB,YAAY,GAAG,KAAK,CAAC;wBACrB,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;oBAC3B,CAAC;gBACH,CAAC,CACF,CAAC;gBAEF,MAAM,CAAC;oBACL,iBAAiB,CAAC,WAAW,EAAE,CAAC;oBAChC,iBAAiB,CAAC,WAAW,EAAE,CAAC;gBAClC,CAAC,CAAC;YACJ,CAAC,CACF,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC\"}","code":"/** @license\r\n *  Copyright 2016 - present The Material Motion Authors. All Rights Reserved.\r\n *\r\n *  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\r\n *  use this file except in compliance with the License. You may obtain a copy\r\n *  of the License at\r\n *\r\n *      http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n *  Unless required by applicable law or agreed to in writing, software\r\n *  distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\r\n *  WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\r\n *  License for the specific language governing permissions and limitations\r\n *  under the License.\r\n */\r\nimport { getFrame$, } from '../../getFrame$';\r\nimport { MotionObservable, } from '../../observables/proxies';\r\nexport function withDebounce(superclass) {\r\n    return class extends superclass {\r\n        /**\r\n         * Throttles the upstream subscription to emit its latest value whenever\r\n         * `pulse$` emits.  If more than one value is received whilst awaiting\r\n         * the pulse, the most recent value is emitted and the intermediaries are\r\n         * forgotten.\r\n         *\r\n         * By default, it will throttle to the framerate using\r\n         * `requestAnimationFrame`.\r\n         */\r\n        _debounce({ pulse$ = getFrame$() } = {}) {\r\n            return new MotionObservable((observer) => {\r\n                let awaitingEmit = false;\r\n                let lastValue;\r\n                const valueSubscription = this.subscribe((value) => {\r\n                    lastValue = value;\r\n                    awaitingEmit = true;\r\n                });\r\n                const pulseSubscription = pulse$.subscribe(() => {\r\n                    if (awaitingEmit) {\r\n                        awaitingEmit = false;\r\n                        observer.next(lastValue);\r\n                    }\r\n                });\r\n                return () => {\r\n                    valueSubscription.unsubscribe();\r\n                    pulseSubscription.unsubscribe();\r\n                };\r\n            });\r\n        }\r\n    };\r\n}\r\n//# sourceMappingURL=_debounce.js.map","dts":{"name":"/Users/brentons/Projects/material-motion-js/packages/core/operators/foundation/_debounce.d.ts","text":"import { Constructor, MotionNextOperable, Observable, ObservableWithMotionOperators } from '../../types';\r\nexport declare type _DebounceArgs = {\r\n    pulse$?: Observable<any>;\r\n};\r\nexport interface MotionDebounceable<T> {\r\n    _debounce(kwargs?: _DebounceArgs): ObservableWithMotionOperators<T>;\r\n}\r\nexport declare function withDebounce<T, S extends Constructor<MotionNextOperable<T>>>(superclass: S): S & Constructor<MotionDebounceable<T>>;\r\n"}}
