bundle.js 1.4 MB

12345678910
  1. !function(e){function n(t){if(r[t])return r[t].exports;var s=r[t]={exports:{},id:t,loaded:!1};return e[t].call(s.exports,s,s.exports,n),s.loaded=!0,s.exports}var r={};return n.m=e,n.c=r,n.p="/assets/",n(0)}([function(module,exports,__webpack_require__){eval("var Cycle = __webpack_require__(2);\nvar Rx = Cycle.Rx;\nvar RxDOM = __webpack_require__(117).DOM;\nvar h = Cycle.h;\n\nvar hashDriver = __webpack_require__(119);\nvar util = __webpack_require__(1);\nvar chat = __webpack_require__(120);\n\nvar nav = [\n {partial: 'about', name: 'About'},\n {partial: 'chatRoom', name: 'Chat'},\n {partial: 'contribute', name: 'Contribute'}\n];\n\nfunction intent(drivers) {\n var DOM = drivers.DOM;\n return {\n contribute: __webpack_require__(121)(drivers),\n route$: drivers.hash.map(function(route) {\n return route || 'about';\n }),\n chat$: DOM.get('#talk', 'input').map(function(ev) {\n return ev.target.value;\n }).startWith('').shareReplay(1),\n send$: DOM.get('#talk', 'keyup').filter(function(ev) {\n return ev.keyCode == 13 && ev.target.value.trim();\n }).shareReplay(1),\n disconnect$: DOM.get('#disconnect', 'click'),\n username$: DOM.get('#username', 'input').map(function(ev) {\n return ev.target.value;\n }),\n login$: DOM.get('#login-form', 'submit').map(function(ev) {\n ev.preventDefault();\n return true;\n })\n };\n}\n\nfunction model(actions) {\n var route$ = actions.route$.shareReplay(1);\n\n var username$ = actions.login$\n .withLatestFrom(actions.username$, function(submit, username) {\n return username;\n })\n .merge(actions.disconnect$.map(function() { return null; }))\n .startWith(null)\n .shareReplay(1)\n\n var room$ = route$\n .map(function(url) {\n if(url.startsWith('chatRoom/')) {\n return url.replace('chatRoom/', '');\n }\n else {\n return null;\n }\n })\n .startWith(null)\n .distinctUntilChanged();\n\n var outgoing$ = util.sync(actions.send$, actions.chat$)\n .map(function(msg) {\n return JSON.stringify({text: msg});\n })\n\n var results = chat.connect(username$, room$, outgoing$);\n\n var newRoute$ = results.details$\n .filter(function(params) {\n return params.username != null;\n })\n .map(function(params) {\n return 'chatRoom/'+params.room;\n })\n .distinctUntilChanged()\n\n var input$ = actions.chat$.merge(actions.send$.map(function() { return '' }));\n\n var messages$ = results.ws$\n .map(function(message) {\n if(message.kind === 'talk') {\n return message;\n }\n else if(message.kind == \"join\") {\n return {\n kind: 'join',\n user: message.user,\n message: ' has joined.'\n };\n }\n else if(message.kind == \"quit\") {\n return {\n kind: 'quit',\n user: message.user,\n message: ' has left.'\n };\n }\n else return null;\n })\n .filter(function(item) {\n return item != null;\n })\n .scan([], function(a, b) {\n a.push(b);\n return a;\n })\n .startWith([])\n\n return {\n hash: newRoute$,\n DOM: {\n username$: username$,\n room$: room$,\n details$: results.details$,\n route$: route$,\n status$: results.status$,\n error$: results.error$,\n chat$: input$,\n contribute$: actions.contribute.fields$\n }\n };\n}\n\nfunction renderLogin(props) {\n var isConnected = props.status === 'connected';\n var content;\n if(!isConnected) {\n content = [ h('a.navbar-link', {href: '#chatRoom'}, ['Play!']) ];\n }\n else {\n content = [\n \"Logged in as \"+props.username+\" — \",\n h('a.navbar-link#disconnect', ['Disconnect'])\n ];\n }\n return h('div', {className: 'navbar-right collapse navbar-collapse'}, [\n h('p.navbar-text', content)\n ]);\n}\n\nfunction renderNav(props) {\n return (\n h('nav', {className: 'navbar navbar-inverse navbar-static-top', role: 'navigation'}, [\n h('div.container', [\n h('div.navbar-header', [\n h('span.brand.navbar-brand', [\"Game 'n Chat\"])\n ]),\n h('ul', {className: 'nav navbar-nav collapse navbar-collapse'}, nav.map(function(item) {\n var link = '#'+item.partial;\n if(item.partial === 'chatRoom' && props.status === 'connected' && props.details.room) {\n link += '/' + props.details.room;\n }\n var className = '';\n if(item.partial == props.route) {\n className = 'active';\n }\n return h('li', {className: className}, [\n h('a', {href: link}, [ item.name ])\n ]);\n })),\n renderLogin(props)\n ]),\n ])\n )\n}\n\nfunction renderFooter() {\n return h('footer', [\n h('p', [\n h('a', {href: 'http://twitter.com/pleasantprog', target: '_blank'}, ['@pleasantprog'])\n ])\n ]);\n}\n\nfunction renderContainer(props) {\n var route = props.route.replace(/\\/.*/, '');\n var content = __webpack_require__(122)(\"./\"+route)(props);\n return h('div.container', [\n h('div.content', [content]),\n renderFooter()\n ]);\n}\n\nfunction view(model) {\n return {\n hash: model.hash,\n DOM:\n util.asObject(model.DOM).map(function(model) {\n return h('div', [\n renderNav(model),\n renderContainer(model)\n ]);\n })\n }\n}\n\nfunction main(drivers) {\n return view(model(intent(drivers)));\n}\n\nCycle.run(main, {\n DOM: Cycle.makeDOMDriver('body'),\n hash: hashDriver\n});\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./assets/index.js\n ** module id = 0\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./assets/index.js?")},function(module,exports,__webpack_require__){eval("var Rx = __webpack_require__(2).Rx;\nvar _ = __webpack_require__(116);\n\n\n// modified from https://github.com/JedWatson/classnames/blob/master/index.js\nfunction classNames () {\n\n var classes = '';\n\n for (var i = 0; i < arguments.length; i++) {\n var arg = arguments[i];\n if (!arg) continue;\n\n var argType = typeof arg;\n\n if ('string' === argType || 'number' === argType) {\n classes += '.' + arg;\n\n } else if (Array.isArray(arg)) {\n classes += '.' + classNames.apply(null, arg);\n\n } else if ('object' === argType) {\n for (var key in arg) {\n if (arg.hasOwnProperty(key) && arg[key]) {\n classes += '.' + key;\n }\n }\n }\n }\n\n return classes;\n}\n\nfunction log(label) {\n return _.bind(console.log, console, label);\n}\n\nfunction flatten(obj) {\n var ret = {};\n _.forEach(obj, function(val, key) {\n if(_.isPlainObject(val)) {\n var o = flatten(val);\n _.forEach(o, function(val, innerKey) {\n ret[key+'.'+innerKey] = val;\n });\n }\n else {\n ret[key] = val;\n }\n });\n return ret;\n}\n\nfunction _set(obj, key, val) {\n var pos = key.indexOf('.');\n if(pos < 0) {\n obj[key] = val;\n }\n else {\n var parent = key.substr(0, pos);\n if(!obj[parent]) {\n obj[parent] = {};\n }\n\n var rest = key.substr(pos+1);\n _set(obj[parent], rest, val);\n }\n}\n\nfunction unflatten(obj) {\n var ret = {};\n var set = _.bind(_set, null, ret);\n _.forEach(obj, function(val, key) {\n set(key, val);\n });\n return ret;\n}\n\nfunction asObject(params) {\n params = flatten(params);\n var keys = _.keys(params).map(function(key) {\n return key.replace(/\\$$/, '');\n });\n var vals = _.values(params);\n return Rx.Observable.combineLatest(vals, function() {\n return unflatten(_.zipObject(keys, arguments));\n });\n}\n\nfunction sync(trigger$, data$) {\n return trigger$.withLatestFrom(data$, function(a, b) {\n return b;\n });\n}\n\nfunction PropertyHook(fn) {\n this.fn = fn;\n}\nPropertyHook.prototype.hook = function() {\n this.fn.apply(this, arguments);\n}\n\nfunction propHook(fn) {\n return new PropertyHook(fn);\n}\n\nmodule.exports = {\n asObject: asObject,\n sync: sync,\n log: log,\n classNames: classNames,\n propHook: propHook\n};\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./assets/util.js\n ** module id = 1\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./assets/util.js?")},function(module,exports,__webpack_require__){eval('\'use strict\';\nvar VirtualDOM = __webpack_require__(7);\nvar svg = __webpack_require__(99);\nvar Rx = __webpack_require__(4);\n\nvar _require = __webpack_require__(3);\n\nvar makeDOMDriver = _require.makeDOMDriver;\n\nvar _require2 = __webpack_require__(102);\n\nvar makeHTMLDriver = _require2.makeHTMLDriver;\n\nvar run = __webpack_require__(115);\n\nvar Cycle = {\n /**\n * Takes an `app` function and circularly connects it to the given collection\n * of driver functions.\n *\n * The `app` function expects a collection of "driver response" Observables as\n * input, and should return a collection of "driver request" Observables.\n * A "collection of Observables" is a JavaScript object where\n * keys match the driver names registered by the `drivers` object, and values\n * are Observables or a collection of Observables.\n *\n * @param {Function} app a function that takes `responses` as input\n * and outputs a collection of `requests` Observables.\n * @param {Object} drivers an object where keys are driver names and values\n * are driver functions.\n * @return {Array} an array where the first object is the collection of driver\n * requests, and the second objet is the collection of driver responses, that\n * can be used for debugging or testing.\n * @function run\n */\n run: run,\n\n /**\n * A factory for the DOM driver function. Takes a `container` to define the\n * target on the existing DOM which this driver will operate on. All custom\n * elements which this driver can detect should be given as the second\n * parameter. The output of this driver is a collection of Observables queried\n * by a getter function: `domDriverOutput.get(selector, eventType)` returns an\n * Observable of events of `eventType` happening on the element determined by\n * `selector`. Also, `domDriverOutput.get(\':root\')` returns an Observable of\n * DOM element corresponding to the root (or container) of the app on the DOM.\n *\n * @param {(String|HTMLElement)} container the DOM selector for the element\n * (or the element itself) to contain the rendering of the VTrees.\n * @param {Object} customElements a collection of custom element definitions.\n * The key of each property should be the tag name of the custom element, and\n * the value should be a function defining the implementation of the custom\n * element. This function follows the same contract as the top-most `app`\n * function: input are driver responses, output are requests to drivers.\n * @return {Function} the DOM driver function. The function expects an\n * Observable of VTree as input, and outputs the response object for this\n * driver, containing functions `get()` and `dispose()` that can be used for\n * debugging and testing.\n * @function makeDOMDriver\n */\n makeDOMDriver: makeDOMDriver,\n\n /**\n * A factory for the HTML driver function. Takes the registry object of all\n * custom elements as the only parameter. The HTML driver function will use\n * the custom element registry to detect custom element on the VTree and apply\n * their implementations.\n *\n * @param {Object} customElements a collection of custom element definitions.\n * The key of each property should be the tag name of the custom element, and\n * the value should be a function defining the implementation of the custom\n * element. This function follows the same contract as the top-most `app`\n * function: input are driver responses, output are requests to drivers.\n * @return {Function} the HTML driver function. The function expects an\n * Observable of Virtual DOM elements as input, and outputs an Observable of\n * strings as the HTML renderization of the virtual DOM elements.\n * @function makeHTMLDriver\n */\n makeHTMLDriver: makeHTMLDriver,\n\n /**\n * A shortcut to the root object of\n * [RxJS](https://github.com/Reactive-Extensions/RxJS).\n * @name Rx\n */\n Rx: Rx,\n\n /**\n * A shortcut to [virtual-hyperscript](\n * https://github.com/Matt-Esch/virtual-dom/tree/master/virtual-hyperscript).\n * This is a helper for creating VTrees in Views.\n * @name h\n */\n h: VirtualDOM.h,\n\n /**\n * A shortcut to the svg hyperscript function.\n * @name svg\n */\n svg: svg\n};\n\nmodule.exports = Cycle;\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/lib/core/cycle.js\n ** module id = 2\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/lib/core/cycle.js?')},function(module,exports,__webpack_require__){eval("'use strict';\n\nfunction _slicedToArray(arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i['return']) _i['return'](); } finally { if (_d) throw _e; } } return _arr; } else { throw new TypeError('Invalid attempt to destructure non-iterable instance'); } }\n\nvar Rx = __webpack_require__(4);\nvar VDOM = {\n h: __webpack_require__(7).h,\n diff: __webpack_require__(21),\n patch: __webpack_require__(26)\n};\n\nvar _require = __webpack_require__(42);\n\nvar replaceCustomElementsWithSomething = _require.replaceCustomElementsWithSomething;\nvar makeCustomElementsRegistry = _require.makeCustomElementsRegistry;\n\nfunction isElement(obj) {\n return typeof HTMLElement === 'object' ? obj instanceof HTMLElement || obj instanceof DocumentFragment : //DOM2\n obj && typeof obj === 'object' && obj !== null && (obj.nodeType === 1 || obj.nodeType === 11) && typeof obj.nodeName === 'string';\n}\n\nfunction fixRootElem$(rawRootElem$, domContainer) {\n // Create rootElem stream and automatic className correction\n var originalClasses = (domContainer.className || '').trim().split(/\\s+/);\n //console.log('%coriginalClasses: ' + originalClasses, 'color: lightgray');\n return rawRootElem$.map(function fixRootElemClassName(rootElem) {\n var previousClasses = rootElem.className.trim().split(/\\s+/);\n var missingClasses = originalClasses.filter(function (clss) {\n return previousClasses.indexOf(clss) < 0;\n });\n //console.log('%cfixRootElemClassName(), missingClasses: ' +\n // missingClasses, 'color: lightgray');\n rootElem.className = previousClasses.concat(missingClasses).join(' ');\n //console.log('%c result: ' + rootElem.className, 'color: lightgray');\n //console.log('%cEmit rootElem$ ' + rootElem.tagName + '.' +\n // rootElem.className, 'color: #009988');\n return rootElem;\n }).replay(null, 1);\n}\n\nfunction isVTreeCustomElement(vtree) {\n return vtree.type === 'Widget' && vtree.isCustomElementWidget;\n}\n\nfunction makeReplaceCustomElementsWithWidgets(CERegistry, driverName) {\n return function replaceCustomElementsWithWidgets(vtree) {\n return replaceCustomElementsWithSomething(vtree, CERegistry, function (_vtree, WidgetClass) {\n return new WidgetClass(_vtree, CERegistry, driverName);\n });\n };\n}\n\nfunction getArrayOfAllWidgetFirstRootElem$(vtree) {\n if (vtree.type === 'Widget' && vtree.firstRootElem$) {\n return [vtree.firstRootElem$];\n }\n // Or replace children recursively\n var array = [];\n if (Array.isArray(vtree.children)) {\n for (var i = vtree.children.length - 1; i >= 0; i--) {\n array = array.concat(getArrayOfAllWidgetFirstRootElem$(vtree.children[i]));\n }\n }\n return array;\n}\n\nfunction checkRootVTreeNotCustomElement(vtree) {\n if (isVTreeCustomElement(vtree)) {\n throw new Error('Illegal to use a Cycle custom element as the root of ' + 'a View.');\n }\n}\n\nfunction makeDiffAndPatchToElement$(rootElem) {\n return function diffAndPatchToElement$(_ref) {\n var _ref2 = _slicedToArray(_ref, 2);\n\n var oldVTree = _ref2[0];\n var newVTree = _ref2[1];\n\n if (typeof newVTree === 'undefined') {\n return Rx.Observable.empty();\n }\n\n //let isCustomElement = !!rootElem.cycleCustomElementMetadata;\n //let k = isCustomElement ? ' is custom element ' : ' is top level';\n var waitForChildrenStreams = getArrayOfAllWidgetFirstRootElem$(newVTree);\n var rootElemAfterChildrenFirstRootElem$ = Rx.Observable.combineLatest(waitForChildrenStreams, function () {\n //console.log('%crawRootElem$ emits. (1)' + k, 'color: #008800');\n return rootElem;\n });\n var cycleCustomElementMetadata = rootElem.cycleCustomElementMetadata;\n //console.log('%cVDOM diff and patch START' + k, 'color: #636300');\n /* eslint-disable */\n rootElem = VDOM.patch(rootElem, VDOM.diff(oldVTree, newVTree));\n /* eslint-enable */\n //console.log('%cVDOM diff and patch END' + k, 'color: #636300');\n if (cycleCustomElementMetadata) {\n rootElem.cycleCustomElementMetadata = cycleCustomElementMetadata;\n }\n if (waitForChildrenStreams.length === 0) {\n //console.log('%crawRootElem$ emits. (2)' + k, 'color: #008800');\n return Rx.Observable.just(rootElem);\n } else {\n //console.log('%crawRootElem$ waiting children.' + k, 'color: #008800');\n return rootElemAfterChildrenFirstRootElem$;\n }\n };\n}\n\nfunction getRenderRootElem(domContainer) {\n var rootElem = undefined;\n if (/cycleCustomElement-[^\\b]+/.exec(domContainer.className) !== null) {\n rootElem = domContainer;\n } else {\n rootElem = document.createElement('div');\n domContainer.innerHTML = '';\n domContainer.appendChild(rootElem);\n }\n return rootElem;\n}\n\nfunction renderRawRootElem$(vtree$, domContainer, CERegistry, driverName) {\n var rootElem = getRenderRootElem(domContainer);\n var diffAndPatchToElement$ = makeDiffAndPatchToElement$(rootElem);\n return vtree$.startWith(VDOM.h()).map(makeReplaceCustomElementsWithWidgets(CERegistry, driverName)).doOnNext(checkRootVTreeNotCustomElement).pairwise().flatMap(diffAndPatchToElement$);\n}\n\nfunction makeRootElemToEvent$(selector, eventName) {\n return function rootElemToEvent$(rootElem) {\n if (!rootElem) {\n return Rx.Observable.empty();\n }\n //let isCustomElement = !!rootElem.cycleCustomElementMetadata;\n //console.log(`%cget('${selector}', '${eventName}') flatMapper` +\n // (isCustomElement ? ' for a custom element' : ' for top-level View'),\n // 'color: #0000BB');\n var klass = selector.replace('.', '');\n if (rootElem.className.search(new RegExp('\\\\b' + klass + '\\\\b')) >= 0) {\n //console.log('%c Good return. (A)', 'color:#0000BB');\n //console.log(rootElem);\n return Rx.Observable.fromEvent(rootElem, eventName);\n }\n var targetElements = rootElem.querySelectorAll(selector);\n if (targetElements && targetElements.length > 0) {\n //console.log('%c Good return. (B)', 'color:#0000BB');\n //console.log(targetElements);\n return Rx.Observable.fromEvent(targetElements, eventName);\n } else {\n //console.log('%c returning empty!', 'color: #0000BB');\n return Rx.Observable.empty();\n }\n };\n}\n\nfunction makeResponseGetter(rootElem$) {\n return function get(selector, eventName) {\n if (typeof selector !== 'string') {\n throw new Error('DOM driver\\'s get() expects first argument to be a ' + 'string as a CSS selector');\n }\n if (selector.trim() === ':root') {\n return rootElem$;\n }\n if (typeof eventName !== 'string') {\n throw new Error('DOM driver\\'s get() expects second argument to be a ' + 'string representing the event type to listen for.');\n }\n\n //console.log(`%cget(\"${selector}\", \"${eventName}\")`, 'color: #0000BB');\n return rootElem$.flatMapLatest(makeRootElemToEvent$(selector, eventName));\n };\n}\n\nfunction validateDOMDriverInput(vtree$) {\n if (!vtree$ || typeof vtree$.subscribe !== 'function') {\n throw new Error('The DOM driver function expects as input an ' + 'Observable of virtual DOM elements');\n }\n}\n\nfunction makeDOMDriverWithRegistry(container, CERegistry) {\n return function domDriver(vtree$, driverName) {\n validateDOMDriverInput(vtree$);\n var rawRootElem$ = renderRawRootElem$(vtree$, container, CERegistry, driverName);\n var rootElem$ = fixRootElem$(rawRootElem$, container);\n var disposable = rootElem$.connect();\n return {\n get: makeResponseGetter(rootElem$),\n dispose: disposable.dispose.bind(disposable)\n };\n };\n}\n\nfunction makeDOMDriver(container) {\n var customElementDefinitions = arguments[1] === undefined ? {} : arguments[1];\n\n // Find and prepare the container\n var domContainer = typeof container === 'string' ? document.querySelector(container) : container;\n // Check pre-conditions\n if (typeof container === 'string' && domContainer === null) {\n throw new Error('Cannot render into unknown element \\'' + container + '\\'');\n } else if (!isElement(domContainer)) {\n throw new Error('Given container is not a DOM element neither a selector ' + 'string.');\n }\n\n var registry = makeCustomElementsRegistry(customElementDefinitions);\n return makeDOMDriverWithRegistry(domContainer, registry);\n}\n\nmodule.exports = {\n isElement: isElement,\n fixRootElem$: fixRootElem$,\n isVTreeCustomElement: isVTreeCustomElement,\n makeReplaceCustomElementsWithWidgets: makeReplaceCustomElementsWithWidgets,\n getArrayOfAllWidgetFirstRootElem$: getArrayOfAllWidgetFirstRootElem$,\n checkRootVTreeNotCustomElement: checkRootVTreeNotCustomElement,\n makeDiffAndPatchToElement$: makeDiffAndPatchToElement$,\n getRenderRootElem: getRenderRootElem,\n renderRawRootElem$: renderRawRootElem$,\n makeResponseGetter: makeResponseGetter,\n validateDOMDriverInput: validateDOMDriverInput,\n makeDOMDriverWithRegistry: makeDOMDriverWithRegistry,\n\n makeDOMDriver: makeDOMDriver\n};\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/lib/web/render-dom.js\n ** module id = 3\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/lib/web/render-dom.js?")},function(module,exports,__webpack_require__){eval("var __WEBPACK_AMD_DEFINE_RESULT__;/* WEBPACK VAR INJECTION */(function(module, global, process) {// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.\n\r\n;(function (undefined) {\n\n var objectTypes = {\n 'boolean': false,\n 'function': true,\n 'object': true,\n 'number': false,\n 'string': false,\n 'undefined': false\n };\n\n var root = (objectTypes[typeof window] && window) || this,\n freeExports = objectTypes[typeof exports] && exports && !exports.nodeType && exports,\n freeModule = objectTypes[typeof module] && module && !module.nodeType && module,\n moduleExports = freeModule && freeModule.exports === freeExports && freeExports,\n freeGlobal = objectTypes[typeof global] && global;\n\n if (freeGlobal && (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal)) {\n root = freeGlobal;\n }\n\n var Rx = {\n internals: {},\n config: {\n Promise: root.Promise\n },\n helpers: { }\n };\n\r\n // Defaults\n var noop = Rx.helpers.noop = function () { },\n notDefined = Rx.helpers.notDefined = function (x) { return typeof x === 'undefined'; },\n identity = Rx.helpers.identity = function (x) { return x; },\n pluck = Rx.helpers.pluck = function (property) { return function (x) { return x[property]; }; },\n just = Rx.helpers.just = function (value) { return function () { return value; }; },\n defaultNow = Rx.helpers.defaultNow = Date.now,\n defaultComparer = Rx.helpers.defaultComparer = function (x, y) { return isEqual(x, y); },\n defaultSubComparer = Rx.helpers.defaultSubComparer = function (x, y) { return x > y ? 1 : (x < y ? -1 : 0); },\n defaultKeySerializer = Rx.helpers.defaultKeySerializer = function (x) { return x.toString(); },\n defaultError = Rx.helpers.defaultError = function (err) { throw err; },\n isPromise = Rx.helpers.isPromise = function (p) { return !!p && typeof p.subscribe !== 'function' && typeof p.then === 'function'; },\n asArray = Rx.helpers.asArray = function () { return Array.prototype.slice.call(arguments); },\n not = Rx.helpers.not = function (a) { return !a; },\n isFunction = Rx.helpers.isFunction = (function () {\n\n var isFn = function (value) {\n return typeof value == 'function' || false;\n }\n\n // fallback for older versions of Chrome and Safari\n if (isFn(/x/)) {\n isFn = function(value) {\n return typeof value == 'function' && toString.call(value) == '[object Function]';\n };\n }\n\n return isFn;\n }());\n\n function cloneArray(arr) { for(var a = [], i = 0, len = arr.length; i < len; i++) { a.push(arr[i]); } return a;}\n\r\n Rx.config.longStackSupport = false;\n var hasStacks = false;\n try {\n throw new Error();\n } catch (e) {\n hasStacks = !!e.stack;\n }\n\n // All code after this point will be filtered from stack traces reported by RxJS\n var rStartingLine = captureLine(), rFileName;\n\r\n var STACK_JUMP_SEPARATOR = \"From previous event:\";\n\n function makeStackTraceLong(error, observable) {\n // If possible, transform the error stack trace by removing Node and RxJS\n // cruft, then concatenating with the stack trace of `observable`.\n if (hasStacks &&\n observable.stack &&\n typeof error === \"object\" &&\n error !== null &&\n error.stack &&\n error.stack.indexOf(STACK_JUMP_SEPARATOR) === -1\n ) {\n var stacks = [];\n for (var o = observable; !!o; o = o.source) {\n if (o.stack) {\n stacks.unshift(o.stack);\n }\n }\n stacks.unshift(error.stack);\n\n var concatedStacks = stacks.join(\"\\n\" + STACK_JUMP_SEPARATOR + \"\\n\");\n error.stack = filterStackString(concatedStacks);\n }\n }\n\n function filterStackString(stackString) {\n var lines = stackString.split(\"\\n\"),\n desiredLines = [];\n for (var i = 0, len = lines.length; i < len; i++) {\n var line = lines[i];\n\n if (!isInternalFrame(line) && !isNodeFrame(line) && line) {\n desiredLines.push(line);\n }\n }\n return desiredLines.join(\"\\n\");\n }\n\n function isInternalFrame(stackLine) {\n var fileNameAndLineNumber = getFileNameAndLineNumber(stackLine);\n if (!fileNameAndLineNumber) {\n return false;\n }\n var fileName = fileNameAndLineNumber[0], lineNumber = fileNameAndLineNumber[1];\n\n return fileName === rFileName &&\n lineNumber >= rStartingLine &&\n lineNumber <= rEndingLine;\n }\n\n function isNodeFrame(stackLine) {\n return stackLine.indexOf(\"(module.js:\") !== -1 ||\n stackLine.indexOf(\"(node.js:\") !== -1;\n }\n\n function captureLine() {\n if (!hasStacks) { return; }\n\n try {\n throw new Error();\n } catch (e) {\n var lines = e.stack.split(\"\\n\");\n var firstLine = lines[0].indexOf(\"@\") > 0 ? lines[1] : lines[2];\n var fileNameAndLineNumber = getFileNameAndLineNumber(firstLine);\n if (!fileNameAndLineNumber) { return; }\n\n rFileName = fileNameAndLineNumber[0];\n return fileNameAndLineNumber[1];\n }\n }\n\n function getFileNameAndLineNumber(stackLine) {\n // Named functions: \"at functionName (filename:lineNumber:columnNumber)\"\n var attempt1 = /at .+ \\((.+):(\\d+):(?:\\d+)\\)$/.exec(stackLine);\n if (attempt1) { return [attempt1[1], Number(attempt1[2])]; }\n\n // Anonymous functions: \"at filename:lineNumber:columnNumber\"\n var attempt2 = /at ([^ ]+):(\\d+):(?:\\d+)$/.exec(stackLine);\n if (attempt2) { return [attempt2[1], Number(attempt2[2])]; }\n\n // Firefox style: \"function@filename:lineNumber or @filename:lineNumber\"\n var attempt3 = /.*@(.+):(\\d+)$/.exec(stackLine);\n if (attempt3) { return [attempt3[1], Number(attempt3[2])]; }\n }\n\r\n var EmptyError = Rx.EmptyError = function() {\n this.message = 'Sequence contains no elements.';\n Error.call(this);\n };\n EmptyError.prototype = Error.prototype;\n\n var ObjectDisposedError = Rx.ObjectDisposedError = function() {\n this.message = 'Object has been disposed';\n Error.call(this);\n };\n ObjectDisposedError.prototype = Error.prototype;\n\n var ArgumentOutOfRangeError = Rx.ArgumentOutOfRangeError = function () {\n this.message = 'Argument out of range';\n Error.call(this);\n };\n ArgumentOutOfRangeError.prototype = Error.prototype;\n\n var NotSupportedError = Rx.NotSupportedError = function (message) {\n this.message = message || 'This operation is not supported';\n Error.call(this);\n };\n NotSupportedError.prototype = Error.prototype;\n\n var NotImplementedError = Rx.NotImplementedError = function (message) {\n this.message = message || 'This operation is not implemented';\n Error.call(this);\n };\n NotImplementedError.prototype = Error.prototype;\n\n var notImplemented = Rx.helpers.notImplemented = function () {\n throw new NotImplementedError();\n };\n\n var notSupported = Rx.helpers.notSupported = function () {\n throw new NotSupportedError();\n };\n\r\n // Shim in iterator support\n var $iterator$ = (typeof Symbol === 'function' && Symbol.iterator) ||\n '_es6shim_iterator_';\n // Bug for mozilla version\n if (root.Set && typeof new root.Set()['@@iterator'] === 'function') {\n $iterator$ = '@@iterator';\n }\n\n var doneEnumerator = Rx.doneEnumerator = { done: true, value: undefined };\n\n var isIterable = Rx.helpers.isIterable = function (o) {\n return o[$iterator$] !== undefined;\n }\n\n var isArrayLike = Rx.helpers.isArrayLike = function (o) {\n return o && o.length !== undefined;\n }\n\n Rx.helpers.iterator = $iterator$;\n\r\n var bindCallback = Rx.internals.bindCallback = function (func, thisArg, argCount) {\n if (typeof thisArg === 'undefined') { return func; }\n switch(argCount) {\n case 0:\n return function() {\n return func.call(thisArg)\n };\n case 1:\n return function(arg) {\n return func.call(thisArg, arg);\n }\n case 2:\n return function(value, index) {\n return func.call(thisArg, value, index);\n };\n case 3:\n return function(value, index, collection) {\n return func.call(thisArg, value, index, collection);\n };\n }\n\n return function() {\n return func.apply(thisArg, arguments);\n };\n };\n\r\n /** Used to determine if values are of the language type Object */\n var dontEnums = ['toString',\n 'toLocaleString',\n 'valueOf',\n 'hasOwnProperty',\n 'isPrototypeOf',\n 'propertyIsEnumerable',\n 'constructor'],\n dontEnumsLength = dontEnums.length;\n\r\n /** `Object#toString` result shortcuts */\n var argsClass = '[object Arguments]',\n arrayClass = '[object Array]',\n boolClass = '[object Boolean]',\n dateClass = '[object Date]',\n errorClass = '[object Error]',\n funcClass = '[object Function]',\n numberClass = '[object Number]',\n objectClass = '[object Object]',\n regexpClass = '[object RegExp]',\n stringClass = '[object String]';\n\n var toString = Object.prototype.toString,\n hasOwnProperty = Object.prototype.hasOwnProperty,\n supportsArgsClass = toString.call(arguments) == argsClass, // For less <IE9 && FF<4\n supportNodeClass,\n errorProto = Error.prototype,\n objectProto = Object.prototype,\n stringProto = String.prototype,\n propertyIsEnumerable = objectProto.propertyIsEnumerable;\n\n try {\n supportNodeClass = !(toString.call(document) == objectClass && !({ 'toString': 0 } + ''));\n } catch (e) {\n supportNodeClass = true;\n }\n\n var nonEnumProps = {};\n nonEnumProps[arrayClass] = nonEnumProps[dateClass] = nonEnumProps[numberClass] = { 'constructor': true, 'toLocaleString': true, 'toString': true, 'valueOf': true };\n nonEnumProps[boolClass] = nonEnumProps[stringClass] = { 'constructor': true, 'toString': true, 'valueOf': true };\n nonEnumProps[errorClass] = nonEnumProps[funcClass] = nonEnumProps[regexpClass] = { 'constructor': true, 'toString': true };\n nonEnumProps[objectClass] = { 'constructor': true };\n\n var support = {};\n (function () {\n var ctor = function() { this.x = 1; },\n props = [];\n\n ctor.prototype = { 'valueOf': 1, 'y': 1 };\n for (var key in new ctor) { props.push(key); }\n for (key in arguments) { }\n\n // Detect if `name` or `message` properties of `Error.prototype` are enumerable by default.\n support.enumErrorProps = propertyIsEnumerable.call(errorProto, 'message') || propertyIsEnumerable.call(errorProto, 'name');\n\n // Detect if `prototype` properties are enumerable by default.\n support.enumPrototypes = propertyIsEnumerable.call(ctor, 'prototype');\n\n // Detect if `arguments` object indexes are non-enumerable\n support.nonEnumArgs = key != 0;\n\n // Detect if properties shadowing those on `Object.prototype` are non-enumerable.\n support.nonEnumShadows = !/valueOf/.test(props);\n }(1));\n\n var isObject = Rx.internals.isObject = function(value) {\n var type = typeof value;\n return value && (type == 'function' || type == 'object') || false;\n };\n\n function keysIn(object) {\n var result = [];\n if (!isObject(object)) {\n return result;\n }\n if (support.nonEnumArgs && object.length && isArguments(object)) {\n object = slice.call(object);\n }\n var skipProto = support.enumPrototypes && typeof object == 'function',\n skipErrorProps = support.enumErrorProps && (object === errorProto || object instanceof Error);\n\n for (var key in object) {\n if (!(skipProto && key == 'prototype') &&\n !(skipErrorProps && (key == 'message' || key == 'name'))) {\n result.push(key);\n }\n }\n\n if (support.nonEnumShadows && object !== objectProto) {\n var ctor = object.constructor,\n index = -1,\n length = dontEnumsLength;\n\n if (object === (ctor && ctor.prototype)) {\n var className = object === stringProto ? stringClass : object === errorProto ? errorClass : toString.call(object),\n nonEnum = nonEnumProps[className];\n }\n while (++index < length) {\n key = dontEnums[index];\n if (!(nonEnum && nonEnum[key]) && hasOwnProperty.call(object, key)) {\n result.push(key);\n }\n }\n }\n return result;\n }\n\n function internalFor(object, callback, keysFunc) {\n var index = -1,\n props = keysFunc(object),\n length = props.length;\n\n while (++index < length) {\n var key = props[index];\n if (callback(object[key], key, object) === false) {\n break;\n }\n }\n return object;\n }\n\n function internalForIn(object, callback) {\n return internalFor(object, callback, keysIn);\n }\n\n function isNode(value) {\n // IE < 9 presents DOM nodes as `Object` objects except they have `toString`\n // methods that are `typeof` \"string\" and still can coerce nodes to strings\n return typeof value.toString != 'function' && typeof (value + '') == 'string';\n }\n\n var isArguments = function(value) {\n return (value && typeof value == 'object') ? toString.call(value) == argsClass : false;\n }\n\n // fallback for browsers that can't detect `arguments` objects by [[Class]]\n if (!supportsArgsClass) {\n isArguments = function(value) {\n return (value && typeof value == 'object') ? hasOwnProperty.call(value, 'callee') : false;\n };\n }\n\n var isEqual = Rx.internals.isEqual = function (x, y) {\n return deepEquals(x, y, [], []);\n };\n\n /** @private\n * Used for deep comparison\n **/\n function deepEquals(a, b, stackA, stackB) {\n // exit early for identical values\n if (a === b) {\n // treat `+0` vs. `-0` as not equal\n return a !== 0 || (1 / a == 1 / b);\n }\n\n var type = typeof a,\n otherType = typeof b;\n\n // exit early for unlike primitive values\n if (a === a && (a == null || b == null ||\n (type != 'function' && type != 'object' && otherType != 'function' && otherType != 'object'))) {\n return false;\n }\n\n // compare [[Class]] names\n var className = toString.call(a),\n otherClass = toString.call(b);\n\n if (className == argsClass) {\n className = objectClass;\n }\n if (otherClass == argsClass) {\n otherClass = objectClass;\n }\n if (className != otherClass) {\n return false;\n }\n switch (className) {\n case boolClass:\n case dateClass:\n // coerce dates and booleans to numbers, dates to milliseconds and booleans\n // to `1` or `0` treating invalid dates coerced to `NaN` as not equal\n return +a == +b;\n\n case numberClass:\n // treat `NaN` vs. `NaN` as equal\n return (a != +a) ?\n b != +b :\n // but treat `-0` vs. `+0` as not equal\n (a == 0 ? (1 / a == 1 / b) : a == +b);\n\n case regexpClass:\n case stringClass:\n // coerce regexes to strings (http://es5.github.io/#x15.10.6.4)\n // treat string primitives and their corresponding object instances as equal\n return a == String(b);\n }\n var isArr = className == arrayClass;\n if (!isArr) {\n\n // exit for functions and DOM nodes\n if (className != objectClass || (!support.nodeClass && (isNode(a) || isNode(b)))) {\n return false;\n }\n // in older versions of Opera, `arguments` objects have `Array` constructors\n var ctorA = !support.argsObject && isArguments(a) ? Object : a.constructor,\n ctorB = !support.argsObject && isArguments(b) ? Object : b.constructor;\n\n // non `Object` object instances with different constructors are not equal\n if (ctorA != ctorB &&\n !(hasOwnProperty.call(a, 'constructor') && hasOwnProperty.call(b, 'constructor')) &&\n !(isFunction(ctorA) && ctorA instanceof ctorA && isFunction(ctorB) && ctorB instanceof ctorB) &&\n ('constructor' in a && 'constructor' in b)\n ) {\n return false;\n }\n }\n // assume cyclic structures are equal\n // the algorithm for detecting cyclic structures is adapted from ES 5.1\n // section 15.12.3, abstract operation `JO` (http://es5.github.io/#x15.12.3)\n var initedStack = !stackA;\n stackA || (stackA = []);\n stackB || (stackB = []);\n\n var length = stackA.length;\n while (length--) {\n if (stackA[length] == a) {\n return stackB[length] == b;\n }\n }\n var size = 0;\n var result = true;\n\n // add `a` and `b` to the stack of traversed objects\n stackA.push(a);\n stackB.push(b);\n\n // recursively compare objects and arrays (susceptible to call stack limits)\n if (isArr) {\n // compare lengths to determine if a deep comparison is necessary\n length = a.length;\n size = b.length;\n result = size == length;\n\n if (result) {\n // deep compare the contents, ignoring non-numeric properties\n while (size--) {\n var index = length,\n value = b[size];\n\n if (!(result = deepEquals(a[size], value, stackA, stackB))) {\n break;\n }\n }\n }\n }\n else {\n // deep compare objects using `forIn`, instead of `forOwn`, to avoid `Object.keys`\n // which, in this case, is more costly\n internalForIn(b, function(value, key, b) {\n if (hasOwnProperty.call(b, key)) {\n // count the number of properties.\n size++;\n // deep compare each property value.\n return (result = hasOwnProperty.call(a, key) && deepEquals(a[key], value, stackA, stackB));\n }\n });\n\n if (result) {\n // ensure both objects have the same number of properties\n internalForIn(a, function(value, key, a) {\n if (hasOwnProperty.call(a, key)) {\n // `size` will be `-1` if `a` has more properties than `b`\n return (result = --size > -1);\n }\n });\n }\n }\n stackA.pop();\n stackB.pop();\n\n return result;\n }\n\r\n var hasProp = {}.hasOwnProperty,\n slice = Array.prototype.slice;\n\n var inherits = this.inherits = Rx.internals.inherits = function (child, parent) {\n function __() { this.constructor = child; }\n __.prototype = parent.prototype;\n child.prototype = new __();\n };\n\n var addProperties = Rx.internals.addProperties = function (obj) {\n for(var sources = [], i = 1, len = arguments.length; i < len; i++) { sources.push(arguments[i]); }\n for (var idx = 0, ln = sources.length; idx < ln; idx++) {\n var source = sources[idx];\n for (var prop in source) {\n obj[prop] = source[prop];\n }\n }\n };\n\n // Rx Utils\n var addRef = Rx.internals.addRef = function (xs, r) {\n return new AnonymousObservable(function (observer) {\n return new CompositeDisposable(r.getDisposable(), xs.subscribe(observer));\n });\n };\n\n function arrayInitialize(count, factory) {\n var a = new Array(count);\n for (var i = 0; i < count; i++) {\n a[i] = factory();\n }\n return a;\n }\n\r\n var errorObj = {e: {}};\n var tryCatchTarget;\n function tryCatcher() {\n try {\n return tryCatchTarget.apply(this, arguments);\n } catch (e) {\n errorObj.e = e;\n return errorObj;\n }\n }\n function tryCatch(fn) {\n if (!isFunction(fn)) { throw new TypeError('fn must be a function'); }\n tryCatchTarget = fn;\n return tryCatcher;\n }\n function thrower(e) {\n throw e;\n }\n\r\n // Collections\n function IndexedItem(id, value) {\n this.id = id;\n this.value = value;\n }\n\n IndexedItem.prototype.compareTo = function (other) {\n var c = this.value.compareTo(other.value);\n c === 0 && (c = this.id - other.id);\n return c;\n };\n\n // Priority Queue for Scheduling\n var PriorityQueue = Rx.internals.PriorityQueue = function (capacity) {\n this.items = new Array(capacity);\n this.length = 0;\n };\n\n var priorityProto = PriorityQueue.prototype;\n priorityProto.isHigherPriority = function (left, right) {\n return this.items[left].compareTo(this.items[right]) < 0;\n };\n\n priorityProto.percolate = function (index) {\n if (index >= this.length || index < 0) { return; }\n var parent = index - 1 >> 1;\n if (parent < 0 || parent === index) { return; }\n if (this.isHigherPriority(index, parent)) {\n var temp = this.items[index];\n this.items[index] = this.items[parent];\n this.items[parent] = temp;\n this.percolate(parent);\n }\n };\n\n priorityProto.heapify = function (index) {\n +index || (index = 0);\n if (index >= this.length || index < 0) { return; }\n var left = 2 * index + 1,\n right = 2 * index + 2,\n first = index;\n if (left < this.length && this.isHigherPriority(left, first)) {\n first = left;\n }\n if (right < this.length && this.isHigherPriority(right, first)) {\n first = right;\n }\n if (first !== index) {\n var temp = this.items[index];\n this.items[index] = this.items[first];\n this.items[first] = temp;\n this.heapify(first);\n }\n };\n\n priorityProto.peek = function () { return this.items[0].value; };\n\n priorityProto.removeAt = function (index) {\n this.items[index] = this.items[--this.length];\n this.items[this.length] = undefined;\n this.heapify();\n };\n\n priorityProto.dequeue = function () {\n var result = this.peek();\n this.removeAt(0);\n return result;\n };\n\n priorityProto.enqueue = function (item) {\n var index = this.length++;\n this.items[index] = new IndexedItem(PriorityQueue.count++, item);\n this.percolate(index);\n };\n\n priorityProto.remove = function (item) {\n for (var i = 0; i < this.length; i++) {\n if (this.items[i].value === item) {\n this.removeAt(i);\n return true;\n }\n }\n return false;\n };\n PriorityQueue.count = 0;\n\r\n /**\n * Represents a group of disposable resources that are disposed together.\n * @constructor\n */\n var CompositeDisposable = Rx.CompositeDisposable = function () {\n var args = [], i, len;\n if (Array.isArray(arguments[0])) {\n args = arguments[0];\n len = args.length;\n } else {\n len = arguments.length;\n args = new Array(len);\n for(i = 0; i < len; i++) { args[i] = arguments[i]; }\n }\n for(i = 0; i < len; i++) {\n if (!isDisposable(args[i])) { throw new TypeError('Not a disposable'); }\n }\n this.disposables = args;\n this.isDisposed = false;\n this.length = args.length;\n };\n\n var CompositeDisposablePrototype = CompositeDisposable.prototype;\n\n /**\n * Adds a disposable to the CompositeDisposable or disposes the disposable if the CompositeDisposable is disposed.\n * @param {Mixed} item Disposable to add.\n */\n CompositeDisposablePrototype.add = function (item) {\n if (this.isDisposed) {\n item.dispose();\n } else {\n this.disposables.push(item);\n this.length++;\n }\n };\n\n /**\n * Removes and disposes the first occurrence of a disposable from the CompositeDisposable.\n * @param {Mixed} item Disposable to remove.\n * @returns {Boolean} true if found; false otherwise.\n */\n CompositeDisposablePrototype.remove = function (item) {\n var shouldDispose = false;\n if (!this.isDisposed) {\n var idx = this.disposables.indexOf(item);\n if (idx !== -1) {\n shouldDispose = true;\n this.disposables.splice(idx, 1);\n this.length--;\n item.dispose();\n }\n }\n return shouldDispose;\n };\n\n /**\n * Disposes all disposables in the group and removes them from the group.\n */\n CompositeDisposablePrototype.dispose = function () {\n if (!this.isDisposed) {\n this.isDisposed = true;\n var len = this.disposables.length, currentDisposables = new Array(len);\n for(var i = 0; i < len; i++) { currentDisposables[i] = this.disposables[i]; }\n this.disposables = [];\n this.length = 0;\n\n for (i = 0; i < len; i++) {\n currentDisposables[i].dispose();\n }\n }\n };\n\r\n /**\n * Provides a set of static methods for creating Disposables.\n * @param {Function} dispose Action to run during the first call to dispose. The action is guaranteed to be run at most once.\n */\n var Disposable = Rx.Disposable = function (action) {\n this.isDisposed = false;\n this.action = action || noop;\n };\n\n /** Performs the task of cleaning up resources. */\n Disposable.prototype.dispose = function () {\n if (!this.isDisposed) {\n this.action();\n this.isDisposed = true;\n }\n };\n\n /**\n * Creates a disposable object that invokes the specified action when disposed.\n * @param {Function} dispose Action to run during the first call to dispose. The action is guaranteed to be run at most once.\n * @return {Disposable} The disposable object that runs the given action upon disposal.\n */\n var disposableCreate = Disposable.create = function (action) { return new Disposable(action); };\n\n /**\n * Gets the disposable that does nothing when disposed.\n */\n var disposableEmpty = Disposable.empty = { dispose: noop };\n\n /**\n * Validates whether the given object is a disposable\n * @param {Object} Object to test whether it has a dispose method\n * @returns {Boolean} true if a disposable object, else false.\n */\n var isDisposable = Disposable.isDisposable = function (d) {\n return d && isFunction(d.dispose);\n };\n\n var checkDisposed = Disposable.checkDisposed = function (disposable) {\n if (disposable.isDisposed) { throw new ObjectDisposedError(); }\n };\n\r\n // Single assignment\n var SingleAssignmentDisposable = Rx.SingleAssignmentDisposable = function () {\n this.isDisposed = false;\n this.current = null;\n };\n SingleAssignmentDisposable.prototype.getDisposable = function () {\n return this.current;\n };\n SingleAssignmentDisposable.prototype.setDisposable = function (value) {\n if (this.current) { throw new Error('Disposable has already been assigned'); }\n var shouldDispose = this.isDisposed;\n !shouldDispose && (this.current = value);\n shouldDispose && value && value.dispose();\n };\n SingleAssignmentDisposable.prototype.dispose = function () {\n if (!this.isDisposed) {\n this.isDisposed = true;\n var old = this.current;\n this.current = null;\n }\n old && old.dispose();\n };\n\n // Multiple assignment disposable\n var SerialDisposable = Rx.SerialDisposable = function () {\n this.isDisposed = false;\n this.current = null;\n };\n SerialDisposable.prototype.getDisposable = function () {\n return this.current;\n };\n SerialDisposable.prototype.setDisposable = function (value) {\n var shouldDispose = this.isDisposed;\n if (!shouldDispose) {\n var old = this.current;\n this.current = value;\n }\n old && old.dispose();\n shouldDispose && value && value.dispose();\n };\n SerialDisposable.prototype.dispose = function () {\n if (!this.isDisposed) {\n this.isDisposed = true;\n var old = this.current;\n this.current = null;\n }\n old && old.dispose();\n };\n\r\n /**\n * Represents a disposable resource that only disposes its underlying disposable resource when all dependent disposable objects have been disposed.\n */\n var RefCountDisposable = Rx.RefCountDisposable = (function () {\n\n function InnerDisposable(disposable) {\n this.disposable = disposable;\n this.disposable.count++;\n this.isInnerDisposed = false;\n }\n\n InnerDisposable.prototype.dispose = function () {\n if (!this.disposable.isDisposed && !this.isInnerDisposed) {\n this.isInnerDisposed = true;\n this.disposable.count--;\n if (this.disposable.count === 0 && this.disposable.isPrimaryDisposed) {\n this.disposable.isDisposed = true;\n this.disposable.underlyingDisposable.dispose();\n }\n }\n };\n\n /**\n * Initializes a new instance of the RefCountDisposable with the specified disposable.\n * @constructor\n * @param {Disposable} disposable Underlying disposable.\n */\n function RefCountDisposable(disposable) {\n this.underlyingDisposable = disposable;\n this.isDisposed = false;\n this.isPrimaryDisposed = false;\n this.count = 0;\n }\n\n /**\n * Disposes the underlying disposable only when all dependent disposables have been disposed\n */\n RefCountDisposable.prototype.dispose = function () {\n if (!this.isDisposed && !this.isPrimaryDisposed) {\n this.isPrimaryDisposed = true;\n if (this.count === 0) {\n this.isDisposed = true;\n this.underlyingDisposable.dispose();\n }\n }\n };\n\n /**\n * Returns a dependent disposable that when disposed decreases the refcount on the underlying disposable.\n * @returns {Disposable} A dependent disposable contributing to the reference count that manages the underlying disposable's lifetime.\n */\n RefCountDisposable.prototype.getDisposable = function () {\n return this.isDisposed ? disposableEmpty : new InnerDisposable(this);\n };\n\n return RefCountDisposable;\n })();\n\r\n function ScheduledDisposable(scheduler, disposable) {\n this.scheduler = scheduler;\n this.disposable = disposable;\n this.isDisposed = false;\n }\n\n function scheduleItem(s, self) {\n if (!self.isDisposed) {\n self.isDisposed = true;\n self.disposable.dispose();\n }\n }\n\n ScheduledDisposable.prototype.dispose = function () {\n this.scheduler.scheduleWithState(this, scheduleItem);\n };\n\r\n var ScheduledItem = Rx.internals.ScheduledItem = function (scheduler, state, action, dueTime, comparer) {\n this.scheduler = scheduler;\n this.state = state;\n this.action = action;\n this.dueTime = dueTime;\n this.comparer = comparer || defaultSubComparer;\n this.disposable = new SingleAssignmentDisposable();\n }\n\n ScheduledItem.prototype.invoke = function () {\n this.disposable.setDisposable(this.invokeCore());\n };\n\n ScheduledItem.prototype.compareTo = function (other) {\n return this.comparer(this.dueTime, other.dueTime);\n };\n\n ScheduledItem.prototype.isCancelled = function () {\n return this.disposable.isDisposed;\n };\n\n ScheduledItem.prototype.invokeCore = function () {\n return this.action(this.scheduler, this.state);\n };\n\r\n /** Provides a set of static properties to access commonly used schedulers. */\n var Scheduler = Rx.Scheduler = (function () {\n\n function Scheduler(now, schedule, scheduleRelative, scheduleAbsolute) {\n this.now = now;\n this._schedule = schedule;\n this._scheduleRelative = scheduleRelative;\n this._scheduleAbsolute = scheduleAbsolute;\n }\n\n /** Determines whether the given object is a scheduler */\n Scheduler.isScheduler = function (s) {\n return s instanceof Scheduler;\n }\n\n function invokeAction(scheduler, action) {\n action();\n return disposableEmpty;\n }\n\n var schedulerProto = Scheduler.prototype;\n\n /**\n * Schedules an action to be executed.\n * @param {Function} action Action to execute.\n * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort).\n */\n schedulerProto.schedule = function (action) {\n return this._schedule(action, invokeAction);\n };\n\n /**\n * Schedules an action to be executed.\n * @param state State passed to the action to be executed.\n * @param {Function} action Action to be executed.\n * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort).\n */\n schedulerProto.scheduleWithState = function (state, action) {\n return this._schedule(state, action);\n };\n\n /**\n * Schedules an action to be executed after the specified relative due time.\n * @param {Function} action Action to execute.\n * @param {Number} dueTime Relative time after which to execute the action.\n * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort).\n */\n schedulerProto.scheduleWithRelative = function (dueTime, action) {\n return this._scheduleRelative(action, dueTime, invokeAction);\n };\n\n /**\n * Schedules an action to be executed after dueTime.\n * @param state State passed to the action to be executed.\n * @param {Function} action Action to be executed.\n * @param {Number} dueTime Relative time after which to execute the action.\n * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort).\n */\n schedulerProto.scheduleWithRelativeAndState = function (state, dueTime, action) {\n return this._scheduleRelative(state, dueTime, action);\n };\n\n /**\n * Schedules an action to be executed at the specified absolute due time.\n * @param {Function} action Action to execute.\n * @param {Number} dueTime Absolute time at which to execute the action.\n * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort).\n */\n schedulerProto.scheduleWithAbsolute = function (dueTime, action) {\n return this._scheduleAbsolute(action, dueTime, invokeAction);\n };\n\n /**\n * Schedules an action to be executed at dueTime.\n * @param {Mixed} state State passed to the action to be executed.\n * @param {Function} action Action to be executed.\n * @param {Number}dueTime Absolute time at which to execute the action.\n * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort).\n */\n schedulerProto.scheduleWithAbsoluteAndState = function (state, dueTime, action) {\n return this._scheduleAbsolute(state, dueTime, action);\n };\n\n /** Gets the current time according to the local machine's system clock. */\n Scheduler.now = defaultNow;\n\n /**\n * Normalizes the specified TimeSpan value to a positive value.\n * @param {Number} timeSpan The time span value to normalize.\n * @returns {Number} The specified TimeSpan value if it is zero or positive; otherwise, 0\n */\n Scheduler.normalize = function (timeSpan) {\n timeSpan < 0 && (timeSpan = 0);\n return timeSpan;\n };\n\n return Scheduler;\n }());\n\n var normalizeTime = Scheduler.normalize, isScheduler = Scheduler.isScheduler;\n\r\n (function (schedulerProto) {\n\n function invokeRecImmediate(scheduler, pair) {\n var state = pair[0], action = pair[1], group = new CompositeDisposable();\n\n function recursiveAction(state1) {\n action(state1, function (state2) {\n var isAdded = false, isDone = false,\n d = scheduler.scheduleWithState(state2, function (scheduler1, state3) {\n if (isAdded) {\n group.remove(d);\n } else {\n isDone = true;\n }\n recursiveAction(state3);\n return disposableEmpty;\n });\n if (!isDone) {\n group.add(d);\n isAdded = true;\n }\n });\n }\n recursiveAction(state);\n return group;\n }\n\n function invokeRecDate(scheduler, pair, method) {\n var state = pair[0], action = pair[1], group = new CompositeDisposable();\n function recursiveAction(state1) {\n action(state1, function (state2, dueTime1) {\n var isAdded = false, isDone = false,\n d = scheduler[method](state2, dueTime1, function (scheduler1, state3) {\n if (isAdded) {\n group.remove(d);\n } else {\n isDone = true;\n }\n recursiveAction(state3);\n return disposableEmpty;\n });\n if (!isDone) {\n group.add(d);\n isAdded = true;\n }\n });\n };\n recursiveAction(state);\n return group;\n }\n\n function scheduleInnerRecursive(action, self) {\n action(function(dt) { self(action, dt); });\n }\n\n /**\n * Schedules an action to be executed recursively.\n * @param {Function} action Action to execute recursively. The parameter passed to the action is used to trigger recursive scheduling of the action.\n * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort).\n */\n schedulerProto.scheduleRecursive = function (action) {\n return this.scheduleRecursiveWithState(action, scheduleInnerRecursive);\n };\n\n /**\n * Schedules an action to be executed recursively.\n * @param {Mixed} state State passed to the action to be executed.\n * @param {Function} action Action to execute recursively. The last parameter passed to the action is used to trigger recursive scheduling of the action, passing in recursive invocation state.\n * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort).\n */\n schedulerProto.scheduleRecursiveWithState = function (state, action) {\n return this.scheduleWithState([state, action], invokeRecImmediate);\n };\n\n /**\n * Schedules an action to be executed recursively after a specified relative due time.\n * @param {Function} action Action to execute recursively. The parameter passed to the action is used to trigger recursive scheduling of the action at the specified relative time.\n * @param {Number}dueTime Relative time after which to execute the action for the first time.\n * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort).\n */\n schedulerProto.scheduleRecursiveWithRelative = function (dueTime, action) {\n return this.scheduleRecursiveWithRelativeAndState(action, dueTime, scheduleInnerRecursive);\n };\n\n /**\n * Schedules an action to be executed recursively after a specified relative due time.\n * @param {Mixed} state State passed to the action to be executed.\n * @param {Function} action Action to execute recursively. The last parameter passed to the action is used to trigger recursive scheduling of the action, passing in the recursive due time and invocation state.\n * @param {Number}dueTime Relative time after which to execute the action for the first time.\n * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort).\n */\n schedulerProto.scheduleRecursiveWithRelativeAndState = function (state, dueTime, action) {\n return this._scheduleRelative([state, action], dueTime, function (s, p) {\n return invokeRecDate(s, p, 'scheduleWithRelativeAndState');\n });\n };\n\n /**\n * Schedules an action to be executed recursively at a specified absolute due time.\n * @param {Function} action Action to execute recursively. The parameter passed to the action is used to trigger recursive scheduling of the action at the specified absolute time.\n * @param {Number}dueTime Absolute time at which to execute the action for the first time.\n * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort).\n */\n schedulerProto.scheduleRecursiveWithAbsolute = function (dueTime, action) {\n return this.scheduleRecursiveWithAbsoluteAndState(action, dueTime, scheduleInnerRecursive);\n };\n\n /**\n * Schedules an action to be executed recursively at a specified absolute due time.\n * @param {Mixed} state State passed to the action to be executed.\n * @param {Function} action Action to execute recursively. The last parameter passed to the action is used to trigger recursive scheduling of the action, passing in the recursive due time and invocation state.\n * @param {Number}dueTime Absolute time at which to execute the action for the first time.\n * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort).\n */\n schedulerProto.scheduleRecursiveWithAbsoluteAndState = function (state, dueTime, action) {\n return this._scheduleAbsolute([state, action], dueTime, function (s, p) {\n return invokeRecDate(s, p, 'scheduleWithAbsoluteAndState');\n });\n };\n }(Scheduler.prototype));\n\r\n (function (schedulerProto) {\n\n /**\n * Schedules a periodic piece of work by dynamically discovering the scheduler's capabilities. The periodic task will be scheduled using window.setInterval for the base implementation.\n * @param {Number} period Period for running the work periodically.\n * @param {Function} action Action to be executed.\n * @returns {Disposable} The disposable object used to cancel the scheduled recurring action (best effort).\n */\n Scheduler.prototype.schedulePeriodic = function (period, action) {\n return this.schedulePeriodicWithState(null, period, action);\n };\n\n /**\n * Schedules a periodic piece of work by dynamically discovering the scheduler's capabilities. The periodic task will be scheduled using window.setInterval for the base implementation.\n * @param {Mixed} state Initial state passed to the action upon the first iteration.\n * @param {Number} period Period for running the work periodically.\n * @param {Function} action Action to be executed, potentially updating the state.\n * @returns {Disposable} The disposable object used to cancel the scheduled recurring action (best effort).\n */\n Scheduler.prototype.schedulePeriodicWithState = function(state, period, action) {\n if (typeof root.setInterval === 'undefined') { throw new NotSupportedError(); }\n period = normalizeTime(period);\n var s = state, id = root.setInterval(function () { s = action(s); }, period);\n return disposableCreate(function () { root.clearInterval(id); });\n };\n\n }(Scheduler.prototype));\n\r\n (function (schedulerProto) {\n /**\n * Returns a scheduler that wraps the original scheduler, adding exception handling for scheduled actions.\n * @param {Function} handler Handler that's run if an exception is caught. The exception will be rethrown if the handler returns false.\n * @returns {Scheduler} Wrapper around the original scheduler, enforcing exception handling.\n */\n schedulerProto.catchError = schedulerProto['catch'] = function (handler) {\n return new CatchScheduler(this, handler);\n };\n }(Scheduler.prototype));\n\r\n var SchedulePeriodicRecursive = Rx.internals.SchedulePeriodicRecursive = (function () {\n function tick(command, recurse) {\n recurse(0, this._period);\n try {\n this._state = this._action(this._state);\n } catch (e) {\n this._cancel.dispose();\n throw e;\n }\n }\n\n function SchedulePeriodicRecursive(scheduler, state, period, action) {\n this._scheduler = scheduler;\n this._state = state;\n this._period = period;\n this._action = action;\n }\n\n SchedulePeriodicRecursive.prototype.start = function () {\n var d = new SingleAssignmentDisposable();\n this._cancel = d;\n d.setDisposable(this._scheduler.scheduleRecursiveWithRelativeAndState(0, this._period, tick.bind(this)));\n\n return d;\n };\n\n return SchedulePeriodicRecursive;\n }());\n\r\n /** Gets a scheduler that schedules work immediately on the current thread. */\n var immediateScheduler = Scheduler.immediate = (function () {\n function scheduleNow(state, action) { return action(this, state); }\n return new Scheduler(defaultNow, scheduleNow, notSupported, notSupported);\n }());\n\r\n /**\n * Gets a scheduler that schedules work as soon as possible on the current thread.\n */\n var currentThreadScheduler = Scheduler.currentThread = (function () {\n var queue;\n\n function runTrampoline () {\n while (queue.length > 0) {\n var item = queue.dequeue();\n !item.isCancelled() && item.invoke();\n }\n }\n\n function scheduleNow(state, action) {\n var si = new ScheduledItem(this, state, action, this.now());\n\n if (!queue) {\n queue = new PriorityQueue(4);\n queue.enqueue(si);\n\n var result = tryCatch(runTrampoline)();\n queue = null;\n if (result === errorObj) { return thrower(result.e); }\n } else {\n queue.enqueue(si);\n }\n return si.disposable;\n }\n\n var currentScheduler = new Scheduler(defaultNow, scheduleNow, notSupported, notSupported);\n currentScheduler.scheduleRequired = function () { return !queue; };\n\n return currentScheduler;\n }());\n\r\n var scheduleMethod, clearMethod;\n\n var localTimer = (function () {\n var localSetTimeout, localClearTimeout = noop;\n if (!!root.setTimeout) {\n localSetTimeout = root.setTimeout;\n localClearTimeout = root.clearTimeout;\n } else if (!!root.WScript) {\n localSetTimeout = function (fn, time) {\n root.WScript.Sleep(time);\n fn();\n };\n } else {\n throw new NotSupportedError();\n }\n\n return {\n setTimeout: localSetTimeout,\n clearTimeout: localClearTimeout\n };\n }());\n var localSetTimeout = localTimer.setTimeout,\n localClearTimeout = localTimer.clearTimeout;\n\n (function () {\n\n var nextHandle = 1, tasksByHandle = {}, currentlyRunning = false;\n\n clearMethod = function (handle) {\n delete tasksByHandle[handle];\n };\n\n function runTask(handle) {\n if (currentlyRunning) {\n localSetTimeout(function () { runTask(handle) }, 0);\n } else {\n var task = tasksByHandle[handle];\n if (task) {\n currentlyRunning = true;\n var result = tryCatch(task)();\n clearMethod(handle);\n currentlyRunning = false;\n if (result === errorObj) { return thrower(result.e); }\n }\n }\n }\n\n var reNative = RegExp('^' +\n String(toString)\n .replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')\n .replace(/toString| for [^\\]]+/g, '.*?') + '$'\n );\n\n var setImmediate = typeof (setImmediate = freeGlobal && moduleExports && freeGlobal.setImmediate) == 'function' &&\n !reNative.test(setImmediate) && setImmediate;\n\n function postMessageSupported () {\n // Ensure not in a worker\n if (!root.postMessage || root.importScripts) { return false; }\n var isAsync = false, oldHandler = root.onmessage;\n // Test for async\n root.onmessage = function () { isAsync = true; };\n root.postMessage('', '*');\n root.onmessage = oldHandler;\n\n return isAsync;\n }\n\n // Use in order, setImmediate, nextTick, postMessage, MessageChannel, script readystatechanged, setTimeout\n if (isFunction(setImmediate)) {\n scheduleMethod = function (action) {\n var id = nextHandle++;\n tasksByHandle[id] = action;\n setImmediate(function () { runTask(id); });\n\n return id;\n };\n } else if (typeof process !== 'undefined' && {}.toString.call(process) === '[object process]') {\n scheduleMethod = function (action) {\n var id = nextHandle++;\n tasksByHandle[id] = action;\n process.nextTick(function () { runTask(id); });\n\n return id;\n };\n } else if (postMessageSupported()) {\n var MSG_PREFIX = 'ms.rx.schedule' + Math.random();\n\n function onGlobalPostMessage(event) {\n // Only if we're a match to avoid any other global events\n if (typeof event.data === 'string' && event.data.substring(0, MSG_PREFIX.length) === MSG_PREFIX) {\n runTask(event.data.substring(MSG_PREFIX.length));\n }\n }\n\n if (root.addEventListener) {\n root.addEventListener('message', onGlobalPostMessage, false);\n } else if (root.attachEvent) {\n root.attachEvent('onmessage', onGlobalPostMessage);\n } else {\n root.onmessage = onGlobalPostMessage;\n }\n\n scheduleMethod = function (action) {\n var id = nextHandle++;\n tasksByHandle[id] = action;\n root.postMessage(MSG_PREFIX + currentId, '*');\n return id;\n };\n } else if (!!root.MessageChannel) {\n var channel = new root.MessageChannel();\n\n channel.port1.onmessage = function (e) { runTask(e.data); };\n\n scheduleMethod = function (action) {\n var id = nextHandle++;\n tasksByHandle[id] = action;\n channel.port2.postMessage(id);\n return id;\n };\n } else if ('document' in root && 'onreadystatechange' in root.document.createElement('script')) {\n\n scheduleMethod = function (action) {\n var scriptElement = root.document.createElement('script');\n var id = nextHandle++;\n tasksByHandle[id] = action;\n\n scriptElement.onreadystatechange = function () {\n runTask(id);\n scriptElement.onreadystatechange = null;\n scriptElement.parentNode.removeChild(scriptElement);\n scriptElement = null;\n };\n root.document.documentElement.appendChild(scriptElement);\n return id;\n };\n\n } else {\n scheduleMethod = function (action) {\n var id = nextHandle++;\n tasksByHandle[id] = action;\n localSetTimeout(function () {\n runTask(id);\n }, 0);\n\n return id;\n };\n }\n }());\n\n /**\n * Gets a scheduler that schedules work via a timed callback based upon platform.\n */\n var timeoutScheduler = Scheduler.timeout = Scheduler['default'] = (function () {\n\n function scheduleNow(state, action) {\n var scheduler = this, disposable = new SingleAssignmentDisposable();\n var id = scheduleMethod(function () {\n !disposable.isDisposed && disposable.setDisposable(action(scheduler, state));\n });\n return new CompositeDisposable(disposable, disposableCreate(function () {\n clearMethod(id);\n }));\n }\n\n function scheduleRelative(state, dueTime, action) {\n var scheduler = this, dt = Scheduler.normalize(dueTime), disposable = new SingleAssignmentDisposable();\n if (dt === 0) { return scheduler.scheduleWithState(state, action); }\n var id = localSetTimeout(function () {\n !disposable.isDisposed && disposable.setDisposable(action(scheduler, state));\n }, dt);\n return new CompositeDisposable(disposable, disposableCreate(function () {\n localClearTimeout(id);\n }));\n }\n\n function scheduleAbsolute(state, dueTime, action) {\n return this.scheduleWithRelativeAndState(state, dueTime - this.now(), action);\n }\n\n return new Scheduler(defaultNow, scheduleNow, scheduleRelative, scheduleAbsolute);\n })();\n\r\n var CatchScheduler = (function (__super__) {\n\n function scheduleNow(state, action) {\n return this._scheduler.scheduleWithState(state, this._wrap(action));\n }\n\n function scheduleRelative(state, dueTime, action) {\n return this._scheduler.scheduleWithRelativeAndState(state, dueTime, this._wrap(action));\n }\n\n function scheduleAbsolute(state, dueTime, action) {\n return this._scheduler.scheduleWithAbsoluteAndState(state, dueTime, this._wrap(action));\n }\n\n inherits(CatchScheduler, __super__);\n\n function CatchScheduler(scheduler, handler) {\n this._scheduler = scheduler;\n this._handler = handler;\n this._recursiveOriginal = null;\n this._recursiveWrapper = null;\n __super__.call(this, this._scheduler.now.bind(this._scheduler), scheduleNow, scheduleRelative, scheduleAbsolute);\n }\n\n CatchScheduler.prototype._clone = function (scheduler) {\n return new CatchScheduler(scheduler, this._handler);\n };\n\n CatchScheduler.prototype._wrap = function (action) {\n var parent = this;\n return function (self, state) {\n try {\n return action(parent._getRecursiveWrapper(self), state);\n } catch (e) {\n if (!parent._handler(e)) { throw e; }\n return disposableEmpty;\n }\n };\n };\n\n CatchScheduler.prototype._getRecursiveWrapper = function (scheduler) {\n if (this._recursiveOriginal !== scheduler) {\n this._recursiveOriginal = scheduler;\n var wrapper = this._clone(scheduler);\n wrapper._recursiveOriginal = scheduler;\n wrapper._recursiveWrapper = wrapper;\n this._recursiveWrapper = wrapper;\n }\n return this._recursiveWrapper;\n };\n\n CatchScheduler.prototype.schedulePeriodicWithState = function (state, period, action) {\n var self = this, failed = false, d = new SingleAssignmentDisposable();\n\n d.setDisposable(this._scheduler.schedulePeriodicWithState(state, period, function (state1) {\n if (failed) { return null; }\n try {\n return action(state1);\n } catch (e) {\n failed = true;\n if (!self._handler(e)) { throw e; }\n d.dispose();\n return null;\n }\n }));\n\n return d;\n };\n\n return CatchScheduler;\n }(Scheduler));\n\r\n /**\n * Represents a notification to an observer.\n */\n var Notification = Rx.Notification = (function () {\n function Notification(kind, value, exception, accept, acceptObservable, toString) {\n this.kind = kind;\n this.value = value;\n this.exception = exception;\n this._accept = accept;\n this._acceptObservable = acceptObservable;\n this.toString = toString;\n }\n\n /**\n * Invokes the delegate corresponding to the notification or the observer's method corresponding to the notification and returns the produced result.\n *\n * @memberOf Notification\n * @param {Any} observerOrOnNext Delegate to invoke for an OnNext notification or Observer to invoke the notification on..\n * @param {Function} onError Delegate to invoke for an OnError notification.\n * @param {Function} onCompleted Delegate to invoke for an OnCompleted notification.\n * @returns {Any} Result produced by the observation.\n */\n Notification.prototype.accept = function (observerOrOnNext, onError, onCompleted) {\n return observerOrOnNext && typeof observerOrOnNext === 'object' ?\n this._acceptObservable(observerOrOnNext) :\n this._accept(observerOrOnNext, onError, onCompleted);\n };\n\n /**\n * Returns an observable sequence with a single notification.\n *\n * @memberOf Notifications\n * @param {Scheduler} [scheduler] Scheduler to send out the notification calls on.\n * @returns {Observable} The observable sequence that surfaces the behavior of the notification upon subscription.\n */\n Notification.prototype.toObservable = function (scheduler) {\n var self = this;\n isScheduler(scheduler) || (scheduler = immediateScheduler);\n return new AnonymousObservable(function (observer) {\n return scheduler.scheduleWithState(self, function (_, notification) {\n notification._acceptObservable(observer);\n notification.kind === 'N' && observer.onCompleted();\n });\n });\n };\n\n return Notification;\n })();\n\n /**\n * Creates an object that represents an OnNext notification to an observer.\n * @param {Any} value The value contained in the notification.\n * @returns {Notification} The OnNext notification containing the value.\n */\n var notificationCreateOnNext = Notification.createOnNext = (function () {\n function _accept(onNext) { return onNext(this.value); }\n function _acceptObservable(observer) { return observer.onNext(this.value); }\n function toString() { return 'OnNext(' + this.value + ')'; }\n\n return function (value) {\n return new Notification('N', value, null, _accept, _acceptObservable, toString);\n };\n }());\n\n /**\n * Creates an object that represents an OnError notification to an observer.\n * @param {Any} error The exception contained in the notification.\n * @returns {Notification} The OnError notification containing the exception.\n */\n var notificationCreateOnError = Notification.createOnError = (function () {\n function _accept (onNext, onError) { return onError(this.exception); }\n function _acceptObservable(observer) { return observer.onError(this.exception); }\n function toString () { return 'OnError(' + this.exception + ')'; }\n\n return function (e) {\n return new Notification('E', null, e, _accept, _acceptObservable, toString);\n };\n }());\n\n /**\n * Creates an object that represents an OnCompleted notification to an observer.\n * @returns {Notification} The OnCompleted notification.\n */\n var notificationCreateOnCompleted = Notification.createOnCompleted = (function () {\n function _accept (onNext, onError, onCompleted) { return onCompleted(); }\n function _acceptObservable(observer) { return observer.onCompleted(); }\n function toString () { return 'OnCompleted()'; }\n\n return function () {\n return new Notification('C', null, null, _accept, _acceptObservable, toString);\n };\n }());\n\r\n /**\n * Supports push-style iteration over an observable sequence.\n */\n var Observer = Rx.Observer = function () { };\n\n /**\n * Creates a notification callback from an observer.\n * @returns The action that forwards its input notification to the underlying observer.\n */\n Observer.prototype.toNotifier = function () {\n var observer = this;\n return function (n) { return n.accept(observer); };\n };\n\n /**\n * Hides the identity of an observer.\n * @returns An observer that hides the identity of the specified observer.\n */\n Observer.prototype.asObserver = function () {\n return new AnonymousObserver(this.onNext.bind(this), this.onError.bind(this), this.onCompleted.bind(this));\n };\n\n /**\n * Checks access to the observer for grammar violations. This includes checking for multiple OnError or OnCompleted calls, as well as reentrancy in any of the observer methods.\n * If a violation is detected, an Error is thrown from the offending observer method call.\n * @returns An observer that checks callbacks invocations against the observer grammar and, if the checks pass, forwards those to the specified observer.\n */\n Observer.prototype.checked = function () { return new CheckedObserver(this); };\n\n /**\n * Creates an observer from the specified OnNext, along with optional OnError, and OnCompleted actions.\n * @param {Function} [onNext] Observer's OnNext action implementation.\n * @param {Function} [onError] Observer's OnError action implementation.\n * @param {Function} [onCompleted] Observer's OnCompleted action implementation.\n * @returns {Observer} The observer object implemented using the given actions.\n */\n var observerCreate = Observer.create = function (onNext, onError, onCompleted) {\n onNext || (onNext = noop);\n onError || (onError = defaultError);\n onCompleted || (onCompleted = noop);\n return new AnonymousObserver(onNext, onError, onCompleted);\n };\n\n /**\n * Creates an observer from a notification callback.\n *\n * @static\n * @memberOf Observer\n * @param {Function} handler Action that handles a notification.\n * @returns The observer object that invokes the specified handler using a notification corresponding to each message it receives.\n */\n Observer.fromNotifier = function (handler, thisArg) {\n return new AnonymousObserver(function (x) {\n return handler.call(thisArg, notificationCreateOnNext(x));\n }, function (e) {\n return handler.call(thisArg, notificationCreateOnError(e));\n }, function () {\n return handler.call(thisArg, notificationCreateOnCompleted());\n });\n };\n\n /**\n * Schedules the invocation of observer methods on the given scheduler.\n * @param {Scheduler} scheduler Scheduler to schedule observer messages on.\n * @returns {Observer} Observer whose messages are scheduled on the given scheduler.\n */\n Observer.prototype.notifyOn = function (scheduler) {\n return new ObserveOnObserver(scheduler, this);\n };\n\n Observer.prototype.makeSafe = function(disposable) {\n return new AnonymousSafeObserver(this._onNext, this._onError, this._onCompleted, disposable);\n };\n\r\n /**\n * Abstract base class for implementations of the Observer class.\n * This base class enforces the grammar of observers where OnError and OnCompleted are terminal messages.\n */\n var AbstractObserver = Rx.internals.AbstractObserver = (function (__super__) {\n inherits(AbstractObserver, __super__);\n\n /**\n * Creates a new observer in a non-stopped state.\n */\n function AbstractObserver() {\n this.isStopped = false;\n __super__.call(this);\n }\n\n // Must be implemented by other observers\n AbstractObserver.prototype.next = notImplemented;\n AbstractObserver.prototype.error = notImplemented;\n AbstractObserver.prototype.completed = notImplemented;\n\n /**\n * Notifies the observer of a new element in the sequence.\n * @param {Any} value Next element in the sequence.\n */\n AbstractObserver.prototype.onNext = function (value) {\n if (!this.isStopped) { this.next(value); }\n };\n\n /**\n * Notifies the observer that an exception has occurred.\n * @param {Any} error The error that has occurred.\n */\n AbstractObserver.prototype.onError = function (error) {\n if (!this.isStopped) {\n this.isStopped = true;\n this.error(error);\n }\n };\n\n /**\n * Notifies the observer of the end of the sequence.\n */\n AbstractObserver.prototype.onCompleted = function () {\n if (!this.isStopped) {\n this.isStopped = true;\n this.completed();\n }\n };\n\n /**\n * Disposes the observer, causing it to transition to the stopped state.\n */\n AbstractObserver.prototype.dispose = function () {\n this.isStopped = true;\n };\n\n AbstractObserver.prototype.fail = function (e) {\n if (!this.isStopped) {\n this.isStopped = true;\n this.error(e);\n return true;\n }\n\n return false;\n };\n\n return AbstractObserver;\n }(Observer));\n\r\n /**\n * Class to create an Observer instance from delegate-based implementations of the on* methods.\n */\n var AnonymousObserver = Rx.AnonymousObserver = (function (__super__) {\n inherits(AnonymousObserver, __super__);\n\n /**\n * Creates an observer from the specified OnNext, OnError, and OnCompleted actions.\n * @param {Any} onNext Observer's OnNext action implementation.\n * @param {Any} onError Observer's OnError action implementation.\n * @param {Any} onCompleted Observer's OnCompleted action implementation.\n */\n function AnonymousObserver(onNext, onError, onCompleted) {\n __super__.call(this);\n this._onNext = onNext;\n this._onError = onError;\n this._onCompleted = onCompleted;\n }\n\n /**\n * Calls the onNext action.\n * @param {Any} value Next element in the sequence.\n */\n AnonymousObserver.prototype.next = function (value) {\n this._onNext(value);\n };\n\n /**\n * Calls the onError action.\n * @param {Any} error The error that has occurred.\n */\n AnonymousObserver.prototype.error = function (error) {\n this._onError(error);\n };\n\n /**\n * Calls the onCompleted action.\n */\n AnonymousObserver.prototype.completed = function () {\n this._onCompleted();\n };\n\n return AnonymousObserver;\n }(AbstractObserver));\n\r\n var CheckedObserver = (function (__super__) {\n inherits(CheckedObserver, __super__);\n\n function CheckedObserver(observer) {\n __super__.call(this);\n this._observer = observer;\n this._state = 0; // 0 - idle, 1 - busy, 2 - done\n }\n\n var CheckedObserverPrototype = CheckedObserver.prototype;\n\n CheckedObserverPrototype.onNext = function (value) {\n this.checkAccess();\n var res = tryCatch(this._observer.onNext).call(this._observer, value);\n this._state = 0;\n res === errorObj && thrower(res.e);\n };\n\n CheckedObserverPrototype.onError = function (err) {\n this.checkAccess();\n var res = tryCatch(this._observer.onError).call(this._observer, err);\n this._state = 2;\n res === errorObj && thrower(res.e);\n };\n\n CheckedObserverPrototype.onCompleted = function () {\n this.checkAccess();\n var res = tryCatch(this._observer.onCompleted).call(this._observer);\n this._state = 2;\n res === errorObj && thrower(res.e);\n };\n\n CheckedObserverPrototype.checkAccess = function () {\n if (this._state === 1) { throw new Error('Re-entrancy detected'); }\n if (this._state === 2) { throw new Error('Observer completed'); }\n if (this._state === 0) { this._state = 1; }\n };\n\n return CheckedObserver;\n }(Observer));\n\r\n var ScheduledObserver = Rx.internals.ScheduledObserver = (function (__super__) {\n inherits(ScheduledObserver, __super__);\n\n function ScheduledObserver(scheduler, observer) {\n __super__.call(this);\n this.scheduler = scheduler;\n this.observer = observer;\n this.isAcquired = false;\n this.hasFaulted = false;\n this.queue = [];\n this.disposable = new SerialDisposable();\n }\n\n ScheduledObserver.prototype.next = function (value) {\n var self = this;\n this.queue.push(function () { self.observer.onNext(value); });\n };\n\n ScheduledObserver.prototype.error = function (e) {\n var self = this;\n this.queue.push(function () { self.observer.onError(e); });\n };\n\n ScheduledObserver.prototype.completed = function () {\n var self = this;\n this.queue.push(function () { self.observer.onCompleted(); });\n };\n\n ScheduledObserver.prototype.ensureActive = function () {\n var isOwner = false, parent = this;\n if (!this.hasFaulted && this.queue.length > 0) {\n isOwner = !this.isAcquired;\n this.isAcquired = true;\n }\n if (isOwner) {\n this.disposable.setDisposable(this.scheduler.scheduleRecursive(function (self) {\n var work;\n if (parent.queue.length > 0) {\n work = parent.queue.shift();\n } else {\n parent.isAcquired = false;\n return;\n }\n try {\n work();\n } catch (ex) {\n parent.queue = [];\n parent.hasFaulted = true;\n throw ex;\n }\n self();\n }));\n }\n };\n\n ScheduledObserver.prototype.dispose = function () {\n __super__.prototype.dispose.call(this);\n this.disposable.dispose();\n };\n\n return ScheduledObserver;\n }(AbstractObserver));\n\r\n var ObserveOnObserver = (function (__super__) {\n inherits(ObserveOnObserver, __super__);\n\n function ObserveOnObserver(scheduler, observer, cancel) {\n __super__.call(this, scheduler, observer);\n this._cancel = cancel;\n }\n\n ObserveOnObserver.prototype.next = function (value) {\n __super__.prototype.next.call(this, value);\n this.ensureActive();\n };\n\n ObserveOnObserver.prototype.error = function (e) {\n __super__.prototype.error.call(this, e);\n this.ensureActive();\n };\n\n ObserveOnObserver.prototype.completed = function () {\n __super__.prototype.completed.call(this);\n this.ensureActive();\n };\n\n ObserveOnObserver.prototype.dispose = function () {\n __super__.prototype.dispose.call(this);\n this._cancel && this._cancel.dispose();\n this._cancel = null;\n };\n\n return ObserveOnObserver;\n })(ScheduledObserver);\n\r\n var observableProto;\n\n /**\n * Represents a push-style collection.\n */\n var Observable = Rx.Observable = (function () {\n\n function Observable(subscribe) {\n if (Rx.config.longStackSupport && hasStacks) {\n try {\n throw new Error();\n } catch (e) {\n this.stack = e.stack.substring(e.stack.indexOf(\"\\n\") + 1);\n }\n\n var self = this;\n this._subscribe = function (observer) {\n var oldOnError = observer.onError.bind(observer);\n\n observer.onError = function (err) {\n makeStackTraceLong(err, self);\n oldOnError(err);\n };\n\n return subscribe.call(self, observer);\n };\n } else {\n this._subscribe = subscribe;\n }\n }\n\n observableProto = Observable.prototype;\n\n /**\n * Subscribes an observer to the observable sequence.\n * @param {Mixed} [observerOrOnNext] The object that is to receive notifications or an action to invoke for each element in the observable sequence.\n * @param {Function} [onError] Action to invoke upon exceptional termination of the observable sequence.\n * @param {Function} [onCompleted] Action to invoke upon graceful termination of the observable sequence.\n * @returns {Diposable} A disposable handling the subscriptions and unsubscriptions.\n */\n observableProto.subscribe = observableProto.forEach = function (observerOrOnNext, onError, onCompleted) {\n return this._subscribe(typeof observerOrOnNext === 'object' ?\n observerOrOnNext :\n observerCreate(observerOrOnNext, onError, onCompleted));\n };\n\n /**\n * Subscribes to the next value in the sequence with an optional \"this\" argument.\n * @param {Function} onNext The function to invoke on each element in the observable sequence.\n * @param {Any} [thisArg] Object to use as this when executing callback.\n * @returns {Disposable} A disposable handling the subscriptions and unsubscriptions.\n */\n observableProto.subscribeOnNext = function (onNext, thisArg) {\n return this._subscribe(observerCreate(typeof thisArg !== 'undefined' ? function(x) { onNext.call(thisArg, x); } : onNext));\n };\n\n /**\n * Subscribes to an exceptional condition in the sequence with an optional \"this\" argument.\n * @param {Function} onError The function to invoke upon exceptional termination of the observable sequence.\n * @param {Any} [thisArg] Object to use as this when executing callback.\n * @returns {Disposable} A disposable handling the subscriptions and unsubscriptions.\n */\n observableProto.subscribeOnError = function (onError, thisArg) {\n return this._subscribe(observerCreate(null, typeof thisArg !== 'undefined' ? function(e) { onError.call(thisArg, e); } : onError));\n };\n\n /**\n * Subscribes to the next value in the sequence with an optional \"this\" argument.\n * @param {Function} onCompleted The function to invoke upon graceful termination of the observable sequence.\n * @param {Any} [thisArg] Object to use as this when executing callback.\n * @returns {Disposable} A disposable handling the subscriptions and unsubscriptions.\n */\n observableProto.subscribeOnCompleted = function (onCompleted, thisArg) {\n return this._subscribe(observerCreate(null, null, typeof thisArg !== 'undefined' ? function() { onCompleted.call(thisArg); } : onCompleted));\n };\n\n return Observable;\n })();\n\r\n var ObservableBase = Rx.ObservableBase = (function (__super__) {\n inherits(ObservableBase, __super__);\n\n function fixSubscriber(subscriber) {\n return subscriber && isFunction(subscriber.dispose) ? subscriber :\n isFunction(subscriber) ? disposableCreate(subscriber) : disposableEmpty;\n }\n\n function setDisposable(s, state) {\n var ado = state[0], self = state[1];\n var sub = tryCatch(self.subscribeCore).call(self, ado);\n\n if (sub === errorObj) {\n if(!ado.fail(errorObj.e)) { return thrower(errorObj.e); }\n }\n ado.setDisposable(fixSubscriber(sub));\n }\n\n function subscribe(observer) {\n var ado = new AutoDetachObserver(observer), state = [ado, this];\n\n if (currentThreadScheduler.scheduleRequired()) {\n currentThreadScheduler.scheduleWithState(state, setDisposable);\n } else {\n setDisposable(null, state);\n }\n return ado;\n }\n\n function ObservableBase() {\n __super__.call(this, subscribe);\n }\n\n ObservableBase.prototype.subscribeCore = notImplemented;\n\n return ObservableBase;\n }(Observable));\n\r\n var Enumerable = Rx.internals.Enumerable = function () { };\n\n var ConcatEnumerableObservable = (function(__super__) {\n inherits(ConcatEnumerableObservable, __super__);\n function ConcatEnumerableObservable(sources) {\n this.sources = sources;\n __super__.call(this);\n }\n \n ConcatEnumerableObservable.prototype.subscribeCore = function (o) {\n var isDisposed, subscription = new SerialDisposable();\n var cancelable = immediateScheduler.scheduleRecursiveWithState(this.sources[$iterator$](), function (e, self) {\n if (isDisposed) { return; }\n var currentItem = tryCatch(e.next).call(e);\n if (currentItem === errorObj) { return o.onError(currentItem.e); }\n\n if (currentItem.done) {\n return o.onCompleted();\n }\n\n // Check if promise\n var currentValue = currentItem.value;\n isPromise(currentValue) && (currentValue = observableFromPromise(currentValue));\n\n var d = new SingleAssignmentDisposable();\n subscription.setDisposable(d);\n d.setDisposable(currentValue.subscribe(new InnerObserver(o, self, e)));\n });\n\n return new CompositeDisposable(subscription, cancelable, disposableCreate(function () {\n isDisposed = true;\n }));\n };\n \n function InnerObserver(o, s, e) {\n this.o = o;\n this.s = s;\n this.e = e;\n this.isStopped = false;\n }\n InnerObserver.prototype.onNext = function (x) { if(!this.isStopped) { this.o.onNext(x); } };\n InnerObserver.prototype.onError = function (err) {\n if (!this.isStopped) {\n this.isStopped = true;\n this.o.onError(err);\n }\n };\n InnerObserver.prototype.onCompleted = function () {\n if (!this.isStopped) {\n this.isStopped = true;\n this.s(this.e);\n }\n };\n InnerObserver.prototype.dispose = function () { this.isStopped = true; };\n InnerObserver.prototype.fail = function (err) {\n if (!this.isStopped) {\n this.isStopped = true;\n this.o.onError(err);\n return true;\n }\n return false;\n };\n \n return ConcatEnumerableObservable;\n }(ObservableBase));\n\n Enumerable.prototype.concat = function () {\n return new ConcatEnumerableObservable(this);\n };\n \n var CatchErrorObservable = (function(__super__) {\n inherits(CatchErrorObservable, __super__);\n function CatchErrorObservable(sources) {\n this.sources = sources;\n __super__.call(this);\n }\n \n CatchErrorObservable.prototype.subscribeCore = function (o) {\n var e = this.sources[$iterator$]();\n\n var isDisposed, subscription = new SerialDisposable();\n var cancelable = immediateScheduler.scheduleRecursiveWithState(null, function (lastException, self) {\n if (isDisposed) { return; }\n var currentItem = tryCatch(e.next).call(e);\n if (currentItem === errorObj) { return o.onError(currentItem.e); }\n\n if (currentItem.done) {\n return lastException !== null ? o.onError(lastException) : o.onCompleted();\n }\n\n // Check if promise\n var currentValue = currentItem.value;\n isPromise(currentValue) && (currentValue = observableFromPromise(currentValue));\n\n var d = new SingleAssignmentDisposable();\n subscription.setDisposable(d);\n d.setDisposable(currentValue.subscribe(\n function(x) { o.onNext(x); },\n self,\n function() { o.onCompleted(); }));\n });\n return new CompositeDisposable(subscription, cancelable, disposableCreate(function () {\n isDisposed = true;\n }));\n };\n \n return CatchErrorObservable;\n }(ObservableBase));\n\n Enumerable.prototype.catchError = function () {\n return new CatchErrorObservable(this);\n };\n\n Enumerable.prototype.catchErrorWhen = function (notificationHandler) {\n var sources = this;\n return new AnonymousObservable(function (o) {\n var exceptions = new Subject(),\n notifier = new Subject(),\n handled = notificationHandler(exceptions),\n notificationDisposable = handled.subscribe(notifier);\n\n var e = sources[$iterator$]();\n\n var isDisposed,\n lastException,\n subscription = new SerialDisposable();\n var cancelable = immediateScheduler.scheduleRecursive(function (self) {\n if (isDisposed) { return; }\n var currentItem = tryCatch(e.next).call(e);\n if (currentItem === errorObj) { return o.onError(currentItem.e); }\n\n if (currentItem.done) {\n if (lastException) {\n o.onError(lastException);\n } else {\n o.onCompleted();\n }\n return;\n }\n\n // Check if promise\n var currentValue = currentItem.value;\n isPromise(currentValue) && (currentValue = observableFromPromise(currentValue));\n\n var outer = new SingleAssignmentDisposable();\n var inner = new SingleAssignmentDisposable();\n subscription.setDisposable(new CompositeDisposable(inner, outer));\n outer.setDisposable(currentValue.subscribe(\n function(x) { o.onNext(x); },\n function (exn) {\n inner.setDisposable(notifier.subscribe(self, function(ex) {\n o.onError(ex);\n }, function() {\n o.onCompleted();\n }));\n\n exceptions.onNext(exn);\n },\n function() { o.onCompleted(); }));\n });\n\n return new CompositeDisposable(notificationDisposable, subscription, cancelable, disposableCreate(function () {\n isDisposed = true;\n }));\n });\n };\n \n var RepeatEnumerable = (function (__super__) {\n inherits(RepeatEnumerable, __super__);\n \n function RepeatEnumerable(v, c) {\n this.v = v;\n this.c = c == null ? -1 : c;\n }\n RepeatEnumerable.prototype[$iterator$] = function () {\n return new RepeatEnumerator(this); \n };\n \n function RepeatEnumerator(p) {\n this.v = p.v;\n this.l = p.c;\n }\n RepeatEnumerator.prototype.next = function () {\n if (this.l === 0) { return doneEnumerator; }\n if (this.l > 0) { this.l--; }\n return { done: false, value: this.v }; \n };\n \n return RepeatEnumerable;\n }(Enumerable));\n\n var enumerableRepeat = Enumerable.repeat = function (value, repeatCount) {\n return new RepeatEnumerable(value, repeatCount);\n };\n \n var OfEnumerable = (function(__super__) {\n inherits(OfEnumerable, __super__);\n function OfEnumerable(s, fn, thisArg) {\n this.s = s;\n this.fn = fn ? bindCallback(fn, thisArg, 3) : null;\n }\n OfEnumerable.prototype[$iterator$] = function () {\n return new OfEnumerator(this);\n };\n \n function OfEnumerator(p) {\n this.i = -1;\n this.s = p.s;\n this.l = this.s.length;\n this.fn = p.fn;\n }\n OfEnumerator.prototype.next = function () {\n return ++this.i < this.l ?\n { done: false, value: !this.fn ? this.s[this.i] : this.fn(this.s[this.i], this.i, this.s) } :\n doneEnumerator; \n };\n \n return OfEnumerable;\n }(Enumerable));\n\n var enumerableOf = Enumerable.of = function (source, selector, thisArg) {\n return new OfEnumerable(source, selector, thisArg);\n };\n\r\n /**\n * Wraps the source sequence in order to run its observer callbacks on the specified scheduler.\n *\n * This only invokes observer callbacks on a scheduler. In case the subscription and/or unsubscription actions have side-effects\n * that require to be run on a scheduler, use subscribeOn.\n *\n * @param {Scheduler} scheduler Scheduler to notify observers on.\n * @returns {Observable} The source sequence whose observations happen on the specified scheduler.\n */\n observableProto.observeOn = function (scheduler) {\n var source = this;\n return new AnonymousObservable(function (observer) {\n return source.subscribe(new ObserveOnObserver(scheduler, observer));\n }, source);\n };\n\r\n /**\n * Wraps the source sequence in order to run its subscription and unsubscription logic on the specified scheduler. This operation is not commonly used;\n * see the remarks section for more information on the distinction between subscribeOn and observeOn.\n\n * This only performs the side-effects of subscription and unsubscription on the specified scheduler. In order to invoke observer\n * callbacks on a scheduler, use observeOn.\n\n * @param {Scheduler} scheduler Scheduler to perform subscription and unsubscription actions on.\n * @returns {Observable} The source sequence whose subscriptions and unsubscriptions happen on the specified scheduler.\n */\n observableProto.subscribeOn = function (scheduler) {\n var source = this;\n return new AnonymousObservable(function (observer) {\n var m = new SingleAssignmentDisposable(), d = new SerialDisposable();\n d.setDisposable(m);\n m.setDisposable(scheduler.schedule(function () {\n d.setDisposable(new ScheduledDisposable(scheduler, source.subscribe(observer)));\n }));\n return d;\n }, source);\n };\n\r\n var FromPromiseObservable = (function(__super__) {\n inherits(FromPromiseObservable, __super__);\n function FromPromiseObservable(p) {\n this.p = p;\n __super__.call(this);\n }\n \n FromPromiseObservable.prototype.subscribeCore = function(o) {\n this.p.then(function (data) {\n o.onNext(data);\n o.onCompleted();\n }, function (err) { o.onError(err); });\n return disposableEmpty; \n };\n \n return FromPromiseObservable;\n }(ObservableBase)); \n \n /**\n * Converts a Promise to an Observable sequence\n * @param {Promise} An ES6 Compliant promise.\n * @returns {Observable} An Observable sequence which wraps the existing promise success and failure.\n */\n var observableFromPromise = Observable.fromPromise = function (promise) {\n return new FromPromiseObservable(promise);\n };\r\n /*\n * Converts an existing observable sequence to an ES6 Compatible Promise\n * @example\n * var promise = Rx.Observable.return(42).toPromise(RSVP.Promise);\n *\n * // With config\n * Rx.config.Promise = RSVP.Promise;\n * var promise = Rx.Observable.return(42).toPromise();\n * @param {Function} [promiseCtor] The constructor of the promise. If not provided, it looks for it in Rx.config.Promise.\n * @returns {Promise} An ES6 compatible promise with the last value from the observable sequence.\n */\n observableProto.toPromise = function (promiseCtor) {\n promiseCtor || (promiseCtor = Rx.config.Promise);\n if (!promiseCtor) { throw new NotSupportedError('Promise type not provided nor in Rx.config.Promise'); }\n var source = this;\n return new promiseCtor(function (resolve, reject) {\n // No cancellation can be done\n var value, hasValue = false;\n source.subscribe(function (v) {\n value = v;\n hasValue = true;\n }, reject, function () {\n hasValue && resolve(value);\n });\n });\n };\n\r\n var ToArrayObservable = (function(__super__) {\n inherits(ToArrayObservable, __super__);\n function ToArrayObservable(source) {\n this.source = source;\n __super__.call(this);\n }\n\n ToArrayObservable.prototype.subscribeCore = function(o) {\n return this.source.subscribe(new InnerObserver(o));\n };\n\n function InnerObserver(o) {\n this.o = o;\n this.a = [];\n this.isStopped = false;\n }\n InnerObserver.prototype.onNext = function (x) { if(!this.isStopped) { this.a.push(x); } };\n InnerObserver.prototype.onError = function (e) {\n if (!this.isStopped) {\n this.isStopped = true;\n this.o.onError(e);\n }\n };\n InnerObserver.prototype.onCompleted = function () {\n if (!this.isStopped) {\n this.isStopped = true;\n this.o.onNext(this.a);\n this.o.onCompleted();\n }\n };\n InnerObserver.prototype.dispose = function () { this.isStopped = true; }\n InnerObserver.prototype.fail = function (e) {\n if (!this.isStopped) {\n this.isStopped = true;\n this.o.onError(e);\n return true;\n }\n \n return false;\n };\n\n return ToArrayObservable;\n }(ObservableBase));\n\n /**\n * Creates an array from an observable sequence.\n * @returns {Observable} An observable sequence containing a single element with a list containing all the elements of the source sequence.\n */\n observableProto.toArray = function () {\n return new ToArrayObservable(this);\n };\n\r\n /**\n * Creates an observable sequence from a specified subscribe method implementation.\n * @example\n * var res = Rx.Observable.create(function (observer) { return function () { } );\n * var res = Rx.Observable.create(function (observer) { return Rx.Disposable.empty; } );\n * var res = Rx.Observable.create(function (observer) { } );\n * @param {Function} subscribe Implementation of the resulting observable sequence's subscribe method, returning a function that will be wrapped in a Disposable.\n * @returns {Observable} The observable sequence with the specified implementation for the Subscribe method.\n */\n Observable.create = Observable.createWithDisposable = function (subscribe, parent) {\n return new AnonymousObservable(subscribe, parent);\n };\n\r\n /**\n * Returns an observable sequence that invokes the specified factory function whenever a new observer subscribes.\n *\n * @example\n * var res = Rx.Observable.defer(function () { return Rx.Observable.fromArray([1,2,3]); });\n * @param {Function} observableFactory Observable factory function to invoke for each observer that subscribes to the resulting sequence or Promise.\n * @returns {Observable} An observable sequence whose observers trigger an invocation of the given observable factory function.\n */\n var observableDefer = Observable.defer = function (observableFactory) {\n return new AnonymousObservable(function (observer) {\n var result;\n try {\n result = observableFactory();\n } catch (e) {\n return observableThrow(e).subscribe(observer);\n }\n isPromise(result) && (result = observableFromPromise(result));\n return result.subscribe(observer);\n });\n };\n\r\n var EmptyObservable = (function(__super__) {\n inherits(EmptyObservable, __super__);\n function EmptyObservable(scheduler) {\n this.scheduler = scheduler;\n __super__.call(this);\n }\n\n EmptyObservable.prototype.subscribeCore = function (observer) {\n var sink = new EmptySink(observer, this);\n return sink.run();\n };\n\n function EmptySink(observer, parent) {\n this.observer = observer;\n this.parent = parent;\n }\n\n function scheduleItem(s, state) {\n state.onCompleted();\n }\n\n EmptySink.prototype.run = function () {\n return this.parent.scheduler.scheduleWithState(this.observer, scheduleItem);\n };\n\n return EmptyObservable;\n }(ObservableBase));\n\n /**\n * Returns an empty observable sequence, using the specified scheduler to send out the single OnCompleted message.\n *\n * @example\n * var res = Rx.Observable.empty();\n * var res = Rx.Observable.empty(Rx.Scheduler.timeout);\n * @param {Scheduler} [scheduler] Scheduler to send the termination call on.\n * @returns {Observable} An observable sequence with no elements.\n */\n var observableEmpty = Observable.empty = function (scheduler) {\n isScheduler(scheduler) || (scheduler = immediateScheduler);\n return new EmptyObservable(scheduler);\n };\n\r\n var FromObservable = (function(__super__) {\n inherits(FromObservable, __super__);\n function FromObservable(iterable, mapper, scheduler) {\n this.iterable = iterable;\n this.mapper = mapper;\n this.scheduler = scheduler;\n __super__.call(this);\n }\n\n FromObservable.prototype.subscribeCore = function (observer) {\n var sink = new FromSink(observer, this);\n return sink.run();\n };\n\n return FromObservable;\n }(ObservableBase));\n\n var FromSink = (function () {\n function FromSink(observer, parent) {\n this.observer = observer;\n this.parent = parent;\n }\n\n FromSink.prototype.run = function () {\n var list = Object(this.parent.iterable),\n it = getIterable(list),\n observer = this.observer,\n mapper = this.parent.mapper;\n\n function loopRecursive(i, recurse) {\n try {\n var next = it.next();\n } catch (e) {\n return observer.onError(e);\n }\n if (next.done) {\n return observer.onCompleted();\n }\n\n var result = next.value;\n\n if (mapper) {\n try {\n result = mapper(result, i);\n } catch (e) {\n return observer.onError(e);\n }\n }\n\n observer.onNext(result);\n recurse(i + 1);\n }\n\n return this.parent.scheduler.scheduleRecursiveWithState(0, loopRecursive);\n };\n\n return FromSink;\n }());\n\n var maxSafeInteger = Math.pow(2, 53) - 1;\n\n function StringIterable(str) {\n this._s = s;\n }\n\n StringIterable.prototype[$iterator$] = function () {\n return new StringIterator(this._s);\n };\n\n function StringIterator(str) {\n this._s = s;\n this._l = s.length;\n this._i = 0;\n }\n\n StringIterator.prototype[$iterator$] = function () {\n return this;\n };\n\n StringIterator.prototype.next = function () {\n return this._i < this._l ? { done: false, value: this._s.charAt(this._i++) } : doneEnumerator;\n };\n\n function ArrayIterable(a) {\n this._a = a;\n }\n\n ArrayIterable.prototype[$iterator$] = function () {\n return new ArrayIterator(this._a);\n };\n\n function ArrayIterator(a) {\n this._a = a;\n this._l = toLength(a);\n this._i = 0;\n }\n\n ArrayIterator.prototype[$iterator$] = function () {\n return this;\n };\n\n ArrayIterator.prototype.next = function () {\n return this._i < this._l ? { done: false, value: this._a[this._i++] } : doneEnumerator;\n };\n\n function numberIsFinite(value) {\n return typeof value === 'number' && root.isFinite(value);\n }\n\n function isNan(n) {\n return n !== n;\n }\n\n function getIterable(o) {\n var i = o[$iterator$], it;\n if (!i && typeof o === 'string') {\n it = new StringIterable(o);\n return it[$iterator$]();\n }\n if (!i && o.length !== undefined) {\n it = new ArrayIterable(o);\n return it[$iterator$]();\n }\n if (!i) { throw new TypeError('Object is not iterable'); }\n return o[$iterator$]();\n }\n\n function sign(value) {\n var number = +value;\n if (number === 0) { return number; }\n if (isNaN(number)) { return number; }\n return number < 0 ? -1 : 1;\n }\n\n function toLength(o) {\n var len = +o.length;\n if (isNaN(len)) { return 0; }\n if (len === 0 || !numberIsFinite(len)) { return len; }\n len = sign(len) * Math.floor(Math.abs(len));\n if (len <= 0) { return 0; }\n if (len > maxSafeInteger) { return maxSafeInteger; }\n return len;\n }\n\n /**\n * This method creates a new Observable sequence from an array-like or iterable object.\n * @param {Any} arrayLike An array-like or iterable object to convert to an Observable sequence.\n * @param {Function} [mapFn] Map function to call on every element of the array.\n * @param {Any} [thisArg] The context to use calling the mapFn if provided.\n * @param {Scheduler} [scheduler] Optional scheduler to use for scheduling. If not provided, defaults to Scheduler.currentThread.\n */\n var observableFrom = Observable.from = function (iterable, mapFn, thisArg, scheduler) {\n if (iterable == null) {\n throw new Error('iterable cannot be null.')\n }\n if (mapFn && !isFunction(mapFn)) {\n throw new Error('mapFn when provided must be a function');\n }\n if (mapFn) {\n var mapper = bindCallback(mapFn, thisArg, 2);\n }\n isScheduler(scheduler) || (scheduler = currentThreadScheduler);\n return new FromObservable(iterable, mapper, scheduler);\n }\n\r\n var FromArrayObservable = (function(__super__) {\n inherits(FromArrayObservable, __super__);\n function FromArrayObservable(args, scheduler) {\n this.args = args;\n this.scheduler = scheduler;\n __super__.call(this);\n }\n\n FromArrayObservable.prototype.subscribeCore = function (observer) {\n var sink = new FromArraySink(observer, this);\n return sink.run();\n };\n\n return FromArrayObservable;\n }(ObservableBase));\n\n function FromArraySink(observer, parent) {\n this.observer = observer;\n this.parent = parent;\n }\n\n FromArraySink.prototype.run = function () {\n var observer = this.observer, args = this.parent.args, len = args.length;\n function loopRecursive(i, recurse) {\n if (i < len) {\n observer.onNext(args[i]);\n recurse(i + 1);\n } else {\n observer.onCompleted();\n }\n }\n\n return this.parent.scheduler.scheduleRecursiveWithState(0, loopRecursive);\n };\n\r\n /**\n * Converts an array to an observable sequence, using an optional scheduler to enumerate the array.\n * @deprecated use Observable.from or Observable.of\n * @param {Scheduler} [scheduler] Scheduler to run the enumeration of the input sequence on.\n * @returns {Observable} The observable sequence whose elements are pulled from the given enumerable sequence.\n */\n var observableFromArray = Observable.fromArray = function (array, scheduler) {\n isScheduler(scheduler) || (scheduler = currentThreadScheduler);\n return new FromArrayObservable(array, scheduler)\n };\n\r\n /**\n * Generates an observable sequence by running a state-driven loop producing the sequence's elements, using the specified scheduler to send out observer messages.\n *\n * @example\n * var res = Rx.Observable.generate(0, function (x) { return x < 10; }, function (x) { return x + 1; }, function (x) { return x; });\n * var res = Rx.Observable.generate(0, function (x) { return x < 10; }, function (x) { return x + 1; }, function (x) { return x; }, Rx.Scheduler.timeout);\n * @param {Mixed} initialState Initial state.\n * @param {Function} condition Condition to terminate generation (upon returning false).\n * @param {Function} iterate Iteration step function.\n * @param {Function} resultSelector Selector function for results produced in the sequence.\n * @param {Scheduler} [scheduler] Scheduler on which to run the generator loop. If not provided, defaults to Scheduler.currentThread.\n * @returns {Observable} The generated sequence.\n */\n Observable.generate = function (initialState, condition, iterate, resultSelector, scheduler) {\n isScheduler(scheduler) || (scheduler = currentThreadScheduler);\n return new AnonymousObservable(function (o) {\n var first = true;\n return scheduler.scheduleRecursiveWithState(initialState, function (state, self) {\n var hasResult, result;\n try {\n if (first) {\n first = false;\n } else {\n state = iterate(state);\n }\n hasResult = condition(state);\n hasResult && (result = resultSelector(state));\n } catch (e) {\n return o.onError(e);\n }\n if (hasResult) {\n o.onNext(result);\n self(state);\n } else {\n o.onCompleted();\n }\n });\n });\n };\n\r\n function observableOf (scheduler, array) {\n isScheduler(scheduler) || (scheduler = currentThreadScheduler);\n return new FromArrayObservable(array, scheduler);\n }\n\n /**\n * This method creates a new Observable instance with a variable number of arguments, regardless of number or type of the arguments.\n * @returns {Observable} The observable sequence whose elements are pulled from the given arguments.\n */\n Observable.of = function () {\n var len = arguments.length, args = new Array(len);\n for(var i = 0; i < len; i++) { args[i] = arguments[i]; }\n return new FromArrayObservable(args, currentThreadScheduler);\n };\n\n /**\n * This method creates a new Observable instance with a variable number of arguments, regardless of number or type of the arguments.\n * @param {Scheduler} scheduler A scheduler to use for scheduling the arguments.\n * @returns {Observable} The observable sequence whose elements are pulled from the given arguments.\n */\n Observable.ofWithScheduler = function (scheduler) {\n var len = arguments.length, args = new Array(len - 1);\n for(var i = 1; i < len; i++) { args[i - 1] = arguments[i]; }\n return new FromArrayObservable(args, scheduler);\n };\n\r\n /**\n * Creates an Observable sequence from changes to an array using Array.observe.\n * @param {Array} array An array to observe changes.\n * @returns {Observable} An observable sequence containing changes to an array from Array.observe.\n */\n Observable.ofArrayChanges = function(array) {\n if (!Array.isArray(array)) { throw new TypeError('Array.observe only accepts arrays.'); }\n if (typeof Array.observe !== 'function' && typeof Array.unobserve !== 'function') { throw new TypeError('Array.observe is not supported on your platform') }\n return new AnonymousObservable(function(observer) {\n function observerFn(changes) {\n for(var i = 0, len = changes.length; i < len; i++) {\n observer.onNext(changes[i]);\n }\n }\n \n Array.observe(array, observerFn);\n\n return function () {\n Array.unobserve(array, observerFn);\n };\n });\n };\n\r\n /**\n * Creates an Observable sequence from changes to an object using Object.observe.\n * @param {Object} obj An object to observe changes.\n * @returns {Observable} An observable sequence containing changes to an object from Object.observe.\n */\n Observable.ofObjectChanges = function(obj) {\n if (obj == null) { throw new TypeError('object must not be null or undefined.'); }\n if (typeof Object.observe !== 'function' && typeof Object.unobserve !== 'function') { throw new TypeError('Object.observe is not supported on your platform') }\n return new AnonymousObservable(function(observer) {\n function observerFn(changes) {\n for(var i = 0, len = changes.length; i < len; i++) {\n observer.onNext(changes[i]);\n }\n }\n\n Object.observe(obj, observerFn);\n\n return function () {\n Object.unobserve(obj, observerFn);\n };\n });\n };\n\r\n var NeverObservable = (function(__super__) {\n inherits(NeverObservable, __super__);\n function NeverObservable() {\n __super__.call(this);\n }\n\n NeverObservable.prototype.subscribeCore = function (observer) {\n return disposableEmpty;\n };\n\n return NeverObservable;\n }(ObservableBase));\n\n /**\n * Returns a non-terminating observable sequence, which can be used to denote an infinite duration (e.g. when using reactive joins).\n * @returns {Observable} An observable sequence whose observers will never get called.\n */\n var observableNever = Observable.never = function () {\n return new NeverObservable();\n };\n\r\n var PairsObservable = (function(__super__) {\n inherits(PairsObservable, __super__);\n function PairsObservable(obj, scheduler) {\n this.obj = obj;\n this.keys = Object.keys(obj);\n this.scheduler = scheduler;\n __super__.call(this);\n }\n\n PairsObservable.prototype.subscribeCore = function (observer) {\n var sink = new PairsSink(observer, this);\n return sink.run();\n };\n\n return PairsObservable;\n }(ObservableBase));\n\n function PairsSink(observer, parent) {\n this.observer = observer;\n this.parent = parent;\n }\n\n PairsSink.prototype.run = function () {\n var observer = this.observer, obj = this.parent.obj, keys = this.parent.keys, len = keys.length;\n function loopRecursive(i, recurse) {\n if (i < len) {\n var key = keys[i];\n observer.onNext([key, obj[key]]);\n recurse(i + 1);\n } else {\n observer.onCompleted();\n }\n }\n\n return this.parent.scheduler.scheduleRecursiveWithState(0, loopRecursive);\n };\n\n /**\n * Convert an object into an observable sequence of [key, value] pairs.\n * @param {Object} obj The object to inspect.\n * @param {Scheduler} [scheduler] Scheduler to run the enumeration of the input sequence on.\n * @returns {Observable} An observable sequence of [key, value] pairs from the object.\n */\n Observable.pairs = function (obj, scheduler) {\n scheduler || (scheduler = currentThreadScheduler);\n return new PairsObservable(obj, scheduler);\n };\n\r\n var RangeObservable = (function(__super__) {\n inherits(RangeObservable, __super__);\n function RangeObservable(start, count, scheduler) {\n this.start = start;\n this.rangeCount = count;\n this.scheduler = scheduler;\n __super__.call(this);\n }\n\n RangeObservable.prototype.subscribeCore = function (observer) {\n var sink = new RangeSink(observer, this);\n return sink.run();\n };\n\n return RangeObservable;\n }(ObservableBase));\n\n var RangeSink = (function () {\n function RangeSink(observer, parent) {\n this.observer = observer;\n this.parent = parent;\n }\n\n RangeSink.prototype.run = function () {\n var start = this.parent.start, count = this.parent.rangeCount, observer = this.observer;\n function loopRecursive(i, recurse) {\n if (i < count) {\n observer.onNext(start + i);\n recurse(i + 1);\n } else {\n observer.onCompleted();\n }\n }\n\n return this.parent.scheduler.scheduleRecursiveWithState(0, loopRecursive);\n };\n\n return RangeSink;\n }());\n\n /**\n * Generates an observable sequence of integral numbers within a specified range, using the specified scheduler to send out observer messages.\n * @param {Number} start The value of the first integer in the sequence.\n * @param {Number} count The number of sequential integers to generate.\n * @param {Scheduler} [scheduler] Scheduler to run the generator loop on. If not specified, defaults to Scheduler.currentThread.\n * @returns {Observable} An observable sequence that contains a range of sequential integral numbers.\n */\n Observable.range = function (start, count, scheduler) {\n isScheduler(scheduler) || (scheduler = currentThreadScheduler);\n return new RangeObservable(start, count, scheduler);\n };\n\r\n var RepeatObservable = (function(__super__) {\n inherits(RepeatObservable, __super__);\n function RepeatObservable(value, repeatCount, scheduler) {\n this.value = value;\n this.repeatCount = repeatCount == null ? -1 : repeatCount;\n this.scheduler = scheduler;\n __super__.call(this);\n }\n\n RepeatObservable.prototype.subscribeCore = function (observer) {\n var sink = new RepeatSink(observer, this);\n return sink.run();\n };\n\n return RepeatObservable;\n }(ObservableBase));\n\n function RepeatSink(observer, parent) {\n this.observer = observer;\n this.parent = parent;\n }\n\n RepeatSink.prototype.run = function () {\n var observer = this.observer, value = this.parent.value;\n function loopRecursive(i, recurse) {\n if (i === -1 || i > 0) {\n observer.onNext(value);\n i > 0 && i--;\n }\n if (i === 0) { return observer.onCompleted(); }\n recurse(i);\n }\n\n return this.parent.scheduler.scheduleRecursiveWithState(this.parent.repeatCount, loopRecursive);\n };\n\n /**\n * Generates an observable sequence that repeats the given element the specified number of times, using the specified scheduler to send out observer messages.\n * @param {Mixed} value Element to repeat.\n * @param {Number} repeatCount [Optiona] Number of times to repeat the element. If not specified, repeats indefinitely.\n * @param {Scheduler} scheduler Scheduler to run the producer loop on. If not specified, defaults to Scheduler.immediate.\n * @returns {Observable} An observable sequence that repeats the given element the specified number of times.\n */\n Observable.repeat = function (value, repeatCount, scheduler) {\n isScheduler(scheduler) || (scheduler = currentThreadScheduler);\n return new RepeatObservable(value, repeatCount, scheduler);\n };\n\r\n var JustObservable = (function(__super__) {\n inherits(JustObservable, __super__);\n function JustObservable(value, scheduler) {\n this.value = value;\n this.scheduler = scheduler;\n __super__.call(this);\n }\n\n JustObservable.prototype.subscribeCore = function (observer) {\n var sink = new JustSink(observer, this);\n return sink.run();\n };\n\n function JustSink(observer, parent) {\n this.observer = observer;\n this.parent = parent;\n }\n\n function scheduleItem(s, state) {\n var value = state[0], observer = state[1];\n observer.onNext(value);\n observer.onCompleted();\n }\n\n JustSink.prototype.run = function () {\n return this.parent.scheduler.scheduleWithState([this.parent.value, this.observer], scheduleItem);\n };\n\n return JustObservable;\n }(ObservableBase));\n\n /**\n * Returns an observable sequence that contains a single element, using the specified scheduler to send out observer messages.\n * There is an alias called 'just' or browsers <IE9.\n * @param {Mixed} value Single element in the resulting observable sequence.\n * @param {Scheduler} scheduler Scheduler to send the single element on. If not specified, defaults to Scheduler.immediate.\n * @returns {Observable} An observable sequence containing the single specified element.\n */\n var observableReturn = Observable['return'] = Observable.just = Observable.returnValue = function (value, scheduler) {\n isScheduler(scheduler) || (scheduler = immediateScheduler);\n return new JustObservable(value, scheduler);\n };\n\r\n var ThrowObservable = (function(__super__) {\n inherits(ThrowObservable, __super__);\n function ThrowObservable(error, scheduler) {\n this.error = error;\n this.scheduler = scheduler;\n __super__.call(this);\n }\n\n ThrowObservable.prototype.subscribeCore = function (o) {\n var sink = new ThrowSink(o, this);\n return sink.run();\n };\n\n function ThrowSink(o, p) {\n this.o = o;\n this.p = p;\n }\n\n function scheduleItem(s, state) {\n var e = state[0], o = state[1];\n o.onError(e);\n }\n\n ThrowSink.prototype.run = function () {\n return this.p.scheduler.scheduleWithState([this.p.error, this.o], scheduleItem);\n };\n\n return ThrowObservable;\n }(ObservableBase));\n\n /**\n * Returns an observable sequence that terminates with an exception, using the specified scheduler to send out the single onError message.\n * There is an alias to this method called 'throwError' for browsers <IE9.\n * @param {Mixed} error An object used for the sequence's termination.\n * @param {Scheduler} scheduler Scheduler to send the exceptional termination call on. If not specified, defaults to Scheduler.immediate.\n * @returns {Observable} The observable sequence that terminates exceptionally with the specified exception object.\n */\n var observableThrow = Observable['throw'] = Observable.throwError = Observable.throwException = function (error, scheduler) {\n isScheduler(scheduler) || (scheduler = immediateScheduler);\n return new ThrowObservable(error, scheduler);\n };\n\r\n /**\n * Constructs an observable sequence that depends on a resource object, whose lifetime is tied to the resulting observable sequence's lifetime.\n * @param {Function} resourceFactory Factory function to obtain a resource object.\n * @param {Function} observableFactory Factory function to obtain an observable sequence that depends on the obtained resource.\n * @returns {Observable} An observable sequence whose lifetime controls the lifetime of the dependent resource object.\n */\n Observable.using = function (resourceFactory, observableFactory) {\n return new AnonymousObservable(function (observer) {\n var disposable = disposableEmpty, resource, source;\n try {\n resource = resourceFactory();\n resource && (disposable = resource);\n source = observableFactory(resource);\n } catch (exception) {\n return new CompositeDisposable(observableThrow(exception).subscribe(observer), disposable);\n }\n return new CompositeDisposable(source.subscribe(observer), disposable);\n });\n };\n\r\n /**\n * Propagates the observable sequence or Promise that reacts first.\n * @param {Observable} rightSource Second observable sequence or Promise.\n * @returns {Observable} {Observable} An observable sequence that surfaces either of the given sequences, whichever reacted first.\n */\n observableProto.amb = function (rightSource) {\n var leftSource = this;\n return new AnonymousObservable(function (observer) {\n var choice,\n leftChoice = 'L', rightChoice = 'R',\n leftSubscription = new SingleAssignmentDisposable(),\n rightSubscription = new SingleAssignmentDisposable();\n\n isPromise(rightSource) && (rightSource = observableFromPromise(rightSource));\n\n function choiceL() {\n if (!choice) {\n choice = leftChoice;\n rightSubscription.dispose();\n }\n }\n\n function choiceR() {\n if (!choice) {\n choice = rightChoice;\n leftSubscription.dispose();\n }\n }\n\n leftSubscription.setDisposable(leftSource.subscribe(function (left) {\n choiceL();\n choice === leftChoice && observer.onNext(left);\n }, function (err) {\n choiceL();\n choice === leftChoice && observer.onError(err);\n }, function () {\n choiceL();\n choice === leftChoice && observer.onCompleted();\n }));\n\n rightSubscription.setDisposable(rightSource.subscribe(function (right) {\n choiceR();\n choice === rightChoice && observer.onNext(right);\n }, function (err) {\n choiceR();\n choice === rightChoice && observer.onError(err);\n }, function () {\n choiceR();\n choice === rightChoice && observer.onCompleted();\n }));\n\n return new CompositeDisposable(leftSubscription, rightSubscription);\n });\n };\n\r\n /**\n * Propagates the observable sequence or Promise that reacts first.\n *\n * @example\n * var = Rx.Observable.amb(xs, ys, zs);\n * @returns {Observable} An observable sequence that surfaces any of the given sequences, whichever reacted first.\n */\n Observable.amb = function () {\n var acc = observableNever(), items = [];\n if (Array.isArray(arguments[0])) {\n items = arguments[0];\n } else {\n for(var i = 0, len = arguments.length; i < len; i++) { items.push(arguments[i]); }\n }\n\n function func(previous, current) {\n return previous.amb(current);\n }\n for (var i = 0, len = items.length; i < len; i++) {\n acc = func(acc, items[i]);\n }\n return acc;\n };\n\r\n function observableCatchHandler(source, handler) {\n return new AnonymousObservable(function (o) {\n var d1 = new SingleAssignmentDisposable(), subscription = new SerialDisposable();\n subscription.setDisposable(d1);\n d1.setDisposable(source.subscribe(function (x) { o.onNext(x); }, function (e) {\n try {\n var result = handler(e);\n } catch (ex) {\n return o.onError(ex);\n }\n isPromise(result) && (result = observableFromPromise(result));\n\n var d = new SingleAssignmentDisposable();\n subscription.setDisposable(d);\n d.setDisposable(result.subscribe(o));\n }, function (x) { o.onCompleted(x); }));\n\n return subscription;\n }, source);\n }\n\n /**\n * Continues an observable sequence that is terminated by an exception with the next observable sequence.\n * @example\n * 1 - xs.catchException(ys)\n * 2 - xs.catchException(function (ex) { return ys(ex); })\n * @param {Mixed} handlerOrSecond Exception handler function that returns an observable sequence given the error that occurred in the first sequence, or a second observable sequence used to produce results when an error occurred in the first sequence.\n * @returns {Observable} An observable sequence containing the first sequence's elements, followed by the elements of the handler sequence in case an exception occurred.\n */\n observableProto['catch'] = observableProto.catchError = observableProto.catchException = function (handlerOrSecond) {\n return typeof handlerOrSecond === 'function' ?\n observableCatchHandler(this, handlerOrSecond) :\n observableCatch([this, handlerOrSecond]);\n };\n\r\n /**\n * Continues an observable sequence that is terminated by an exception with the next observable sequence.\n * @param {Array | Arguments} args Arguments or an array to use as the next sequence if an error occurs.\n * @returns {Observable} An observable sequence containing elements from consecutive source sequences until a source sequence terminates successfully.\n */\n var observableCatch = Observable.catchError = Observable['catch'] = Observable.catchException = function () {\n var items = [];\n if (Array.isArray(arguments[0])) {\n items = arguments[0];\n } else {\n for(var i = 0, len = arguments.length; i < len; i++) { items.push(arguments[i]); }\n }\n return enumerableOf(items).catchError();\n };\n\r\n /**\n * Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences or Promises produces an element.\n * This can be in the form of an argument list of observables or an array.\n *\n * @example\n * 1 - obs = observable.combineLatest(obs1, obs2, obs3, function (o1, o2, o3) { return o1 + o2 + o3; });\n * 2 - obs = observable.combineLatest([obs1, obs2, obs3], function (o1, o2, o3) { return o1 + o2 + o3; });\n * @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function.\n */\n observableProto.combineLatest = function () {\n var len = arguments.length, args = new Array(len);\n for(var i = 0; i < len; i++) { args[i] = arguments[i]; }\n if (Array.isArray(args[0])) {\n args[0].unshift(this);\n } else {\n args.unshift(this);\n }\n return combineLatest.apply(this, args);\n };\n\r\n /**\n * Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences or Promises produces an element.\n *\n * @example\n * 1 - obs = Rx.Observable.combineLatest(obs1, obs2, obs3, function (o1, o2, o3) { return o1 + o2 + o3; });\n * 2 - obs = Rx.Observable.combineLatest([obs1, obs2, obs3], function (o1, o2, o3) { return o1 + o2 + o3; });\n * @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function.\n */\n var combineLatest = Observable.combineLatest = function () {\n var len = arguments.length, args = new Array(len);\n for(var i = 0; i < len; i++) { args[i] = arguments[i]; }\n var resultSelector = args.pop();\n Array.isArray(args[0]) && (args = args[0]);\n\n return new AnonymousObservable(function (o) {\n var n = args.length,\n falseFactory = function () { return false; },\n hasValue = arrayInitialize(n, falseFactory),\n hasValueAll = false,\n isDone = arrayInitialize(n, falseFactory),\n values = new Array(n);\n\n function next(i) {\n hasValue[i] = true;\n if (hasValueAll || (hasValueAll = hasValue.every(identity))) {\n try {\n var res = resultSelector.apply(null, values);\n } catch (e) {\n return o.onError(e);\n }\n o.onNext(res);\n } else if (isDone.filter(function (x, j) { return j !== i; }).every(identity)) {\n o.onCompleted();\n }\n }\n\n function done (i) {\n isDone[i] = true;\n isDone.every(identity) && o.onCompleted();\n }\n\n var subscriptions = new Array(n);\n for (var idx = 0; idx < n; idx++) {\n (function (i) {\n var source = args[i], sad = new SingleAssignmentDisposable();\n isPromise(source) && (source = observableFromPromise(source));\n sad.setDisposable(source.subscribe(function (x) {\n values[i] = x;\n next(i);\n },\n function(e) { o.onError(e); },\n function () { done(i); }\n ));\n subscriptions[i] = sad;\n }(idx));\n }\n\n return new CompositeDisposable(subscriptions);\n }, this);\n };\n\r\n /**\n * Concatenates all the observable sequences. This takes in either an array or variable arguments to concatenate.\n * @returns {Observable} An observable sequence that contains the elements of each given sequence, in sequential order.\n */\n observableProto.concat = function () {\n for(var args = [], i = 0, len = arguments.length; i < len; i++) { args.push(arguments[i]); }\n args.unshift(this);\n return observableConcat.apply(null, args);\n };\n\r\n var ConcatObservable = (function(__super__) {\r\n inherits(ConcatObservable, __super__);\r\n function ConcatObservable(sources) {\r\n this.sources = sources;\r\n __super__.call(this);\r\n }\r\n \r\n ConcatObservable.prototype.subscribeCore = function(o) {\r\n var sink = new ConcatSink(this.sources, o);\r\n return sink.run();\r\n };\r\n \r\n function ConcatSink(sources, o) {\r\n this.sources = sources;\r\n this.o = o;\r\n }\r\n ConcatSink.prototype.run = function () {\r\n var isDisposed, subscription = new SerialDisposable(), sources = this.sources, length = sources.length, o = this.o;\r\n var cancelable = immediateScheduler.scheduleRecursiveWithState(0, function (i, self) {\r\n if (isDisposed) { return; }\r\n if (i === length) {\r\n return o.onCompleted();\r\n }\r\n \r\n // Check if promise\r\n var currentValue = sources[i];\r\n isPromise(currentValue) && (currentValue = observableFromPromise(currentValue));\r\n\r\n var d = new SingleAssignmentDisposable();\r\n subscription.setDisposable(d);\r\n d.setDisposable(currentValue.subscribe(\r\n function (x) { o.onNext(x); },\r\n function (e) { o.onError(e); },\r\n function () { self(i + 1); }\r\n ));\r\n });\r\n\r\n return new CompositeDisposable(subscription, cancelable, disposableCreate(function () {\r\n isDisposed = true;\r\n }));\r\n };\r\n \r\n \r\n return ConcatObservable;\r\n }(ObservableBase));\r\n \r\n /**\r\n * Concatenates all the observable sequences.\r\n * @param {Array | Arguments} args Arguments or an array to concat to the observable sequence.\r\n * @returns {Observable} An observable sequence that contains the elements of each given sequence, in sequential order.\r\n */\r\n var observableConcat = Observable.concat = function () {\r\n var args;\r\n if (Array.isArray(arguments[0])) {\r\n args = arguments[0];\r\n } else {\r\n args = new Array(arguments.length);\r\n for(var i = 0, len = arguments.length; i < len; i++) { args[i] = arguments[i]; }\r\n }\r\n return new ConcatObservable(args);\r\n };\r\n\r\n /**\n * Concatenates an observable sequence of observable sequences.\n * @returns {Observable} An observable sequence that contains the elements of each observed inner sequence, in sequential order.\n */\n observableProto.concatAll = observableProto.concatObservable = function () {\n return this.merge(1);\n };\n\r\n var MergeObservable = (function (__super__) {\n inherits(MergeObservable, __super__);\n\n function MergeObservable(source, maxConcurrent) {\n this.source = source;\n this.maxConcurrent = maxConcurrent;\n __super__.call(this);\n }\n\n MergeObservable.prototype.subscribeCore = function(observer) {\n var g = new CompositeDisposable();\n g.add(this.source.subscribe(new MergeObserver(observer, this.maxConcurrent, g)));\n return g;\n };\n\n return MergeObservable;\n\n }(ObservableBase));\n\n var MergeObserver = (function () {\n function MergeObserver(o, max, g) {\n this.o = o;\n this.max = max;\n this.g = g;\n this.done = false;\n this.q = [];\n this.activeCount = 0;\n this.isStopped = false;\n }\n MergeObserver.prototype.handleSubscribe = function (xs) {\n var sad = new SingleAssignmentDisposable();\n this.g.add(sad);\n isPromise(xs) && (xs = observableFromPromise(xs));\n sad.setDisposable(xs.subscribe(new InnerObserver(this, sad)));\n };\n MergeObserver.prototype.onNext = function (innerSource) {\n if (this.isStopped) { return; }\n if(this.activeCount < this.max) {\n this.activeCount++;\n this.handleSubscribe(innerSource);\n } else {\n this.q.push(innerSource);\n }\n };\n MergeObserver.prototype.onError = function (e) {\n if (!this.isStopped) {\n this.isStopped = true;\n this.o.onError(e);\n }\n };\n MergeObserver.prototype.onCompleted = function () {\n if (!this.isStopped) {\n this.isStopped = true;\n this.done = true;\n this.activeCount === 0 && this.o.onCompleted();\n }\n };\n MergeObserver.prototype.dispose = function() { this.isStopped = true; };\n MergeObserver.prototype.fail = function (e) {\n if (!this.isStopped) {\n this.isStopped = true;\n this.o.onError(e);\n return true;\n }\n\n return false;\n };\n\n function InnerObserver(parent, sad) {\n this.parent = parent;\n this.sad = sad;\n this.isStopped = false;\n }\n InnerObserver.prototype.onNext = function (x) { if(!this.isStopped) { this.parent.o.onNext(x); } };\n InnerObserver.prototype.onError = function (e) {\n if (!this.isStopped) {\n this.isStopped = true;\n this.parent.o.onError(e);\n }\n };\n InnerObserver.prototype.onCompleted = function () {\n if(!this.isStopped) {\n this.isStopped = true;\n var parent = this.parent;\n parent.g.remove(this.sad);\n if (parent.q.length > 0) {\n parent.handleSubscribe(parent.q.shift());\n } else {\n parent.activeCount--;\n parent.done && parent.activeCount === 0 && parent.o.onCompleted();\n }\n }\n };\n InnerObserver.prototype.dispose = function() { this.isStopped = true; };\n InnerObserver.prototype.fail = function (e) {\n if (!this.isStopped) {\n this.isStopped = true;\n this.parent.o.onError(e);\n return true;\n }\n\n return false;\n };\n\n return MergeObserver;\n }());\n\n\n\n\n\n /**\n * Merges an observable sequence of observable sequences into an observable sequence, limiting the number of concurrent subscriptions to inner sequences.\n * Or merges two observable sequences into a single observable sequence.\n *\n * @example\n * 1 - merged = sources.merge(1);\n * 2 - merged = source.merge(otherSource);\n * @param {Mixed} [maxConcurrentOrOther] Maximum number of inner observable sequences being subscribed to concurrently or the second observable sequence.\n * @returns {Observable} The observable sequence that merges the elements of the inner sequences.\n */\n observableProto.merge = function (maxConcurrentOrOther) {\n return typeof maxConcurrentOrOther !== 'number' ?\n observableMerge(this, maxConcurrentOrOther) :\n new MergeObservable(this, maxConcurrentOrOther);\n };\n\r\n /**\n * Merges all the observable sequences into a single observable sequence.\n * The scheduler is optional and if not specified, the immediate scheduler is used.\n * @returns {Observable} The observable sequence that merges the elements of the observable sequences.\n */\n var observableMerge = Observable.merge = function () {\n var scheduler, sources = [], i, len = arguments.length;\n if (!arguments[0]) {\n scheduler = immediateScheduler;\n for(i = 1; i < len; i++) { sources.push(arguments[i]); }\n } else if (isScheduler(arguments[0])) {\n scheduler = arguments[0];\n for(i = 1; i < len; i++) { sources.push(arguments[i]); }\n } else {\n scheduler = immediateScheduler;\n for(i = 0; i < len; i++) { sources.push(arguments[i]); }\n }\n if (Array.isArray(sources[0])) {\n sources = sources[0];\n }\n return observableOf(scheduler, sources).mergeAll();\n };\n\r\n var MergeAllObservable = (function (__super__) {\n inherits(MergeAllObservable, __super__);\n\n function MergeAllObservable(source) {\n this.source = source;\n __super__.call(this);\n }\n\n MergeAllObservable.prototype.subscribeCore = function (observer) {\n var g = new CompositeDisposable(), m = new SingleAssignmentDisposable();\n g.add(m);\n m.setDisposable(this.source.subscribe(new MergeAllObserver(observer, g)));\n return g;\n };\n \n function MergeAllObserver(o, g) {\n this.o = o;\n this.g = g;\n this.isStopped = false;\n this.done = false;\n }\n MergeAllObserver.prototype.onNext = function(innerSource) {\n if(this.isStopped) { return; }\n var sad = new SingleAssignmentDisposable();\n this.g.add(sad);\n\n isPromise(innerSource) && (innerSource = observableFromPromise(innerSource));\n\n sad.setDisposable(innerSource.subscribe(new InnerObserver(this, this.g, sad)));\n };\n MergeAllObserver.prototype.onError = function (e) {\n if(!this.isStopped) {\n this.isStopped = true;\n this.o.onError(e);\n }\n };\n MergeAllObserver.prototype.onCompleted = function () {\n if(!this.isStopped) {\n this.isStopped = true;\n this.done = true;\n this.g.length === 1 && this.o.onCompleted();\n }\n };\n MergeAllObserver.prototype.dispose = function() { this.isStopped = true; };\n MergeAllObserver.prototype.fail = function (e) {\n if (!this.isStopped) {\n this.isStopped = true;\n this.o.onError(e);\n return true;\n }\n\n return false;\n };\n\n function InnerObserver(parent, g, sad) {\n this.parent = parent;\n this.g = g;\n this.sad = sad;\n this.isStopped = false;\n }\n InnerObserver.prototype.onNext = function (x) { if (!this.isStopped) { this.parent.o.onNext(x); } };\n InnerObserver.prototype.onError = function (e) {\n if(!this.isStopped) {\n this.isStopped = true;\n this.parent.o.onError(e);\n }\n };\n InnerObserver.prototype.onCompleted = function () {\n if(!this.isStopped) {\n var parent = this.parent;\n this.isStopped = true;\n parent.g.remove(this.sad);\n parent.done && parent.g.length === 1 && parent.o.onCompleted();\n }\n };\n InnerObserver.prototype.dispose = function() { this.isStopped = true; };\n InnerObserver.prototype.fail = function (e) {\n if (!this.isStopped) {\n this.isStopped = true;\n this.parent.o.onError(e);\n return true;\n }\n\n return false;\n };\n\n return MergeAllObservable;\n }(ObservableBase));\n\n /**\n * Merges an observable sequence of observable sequences into an observable sequence.\n * @returns {Observable} The observable sequence that merges the elements of the inner sequences.\n */\n observableProto.mergeAll = observableProto.mergeObservable = function () {\n return new MergeAllObservable(this);\n };\n\r\n var CompositeError = Rx.CompositeError = function(errors) {\n this.name = \"NotImplementedError\";\n this.innerErrors = errors;\n this.message = 'This contains multiple errors. Check the innerErrors';\n Error.call(this);\n }\n CompositeError.prototype = Error.prototype;\n\n /**\n * Flattens an Observable that emits Observables into one Observable, in a way that allows an Observer to\n * receive all successfully emitted items from all of the source Observables without being interrupted by\n * an error notification from one of them.\n *\n * This behaves like Observable.prototype.mergeAll except that if any of the merged Observables notify of an\n * error via the Observer's onError, mergeDelayError will refrain from propagating that\n * error notification until all of the merged Observables have finished emitting items.\n * @param {Array | Arguments} args Arguments or an array to merge.\n * @returns {Observable} an Observable that emits all of the items emitted by the Observables emitted by the Observable\n */\n Observable.mergeDelayError = function() {\n var args;\n if (Array.isArray(arguments[0])) {\n args = arguments[0];\n } else {\n var len = arguments.length;\n args = new Array(len);\n for(var i = 0; i < len; i++) { args[i] = arguments[i]; }\n }\n var source = observableOf(null, args);\n\n return new AnonymousObservable(function (o) {\n var group = new CompositeDisposable(),\n m = new SingleAssignmentDisposable(),\n isStopped = false,\n errors = [];\n\n function setCompletion() {\n if (errors.length === 0) {\n o.onCompleted();\n } else if (errors.length === 1) {\n o.onError(errors[0]);\n } else {\n o.onError(new CompositeError(errors));\n }\n }\n\n group.add(m);\n\n m.setDisposable(source.subscribe(\n function (innerSource) {\n var innerSubscription = new SingleAssignmentDisposable();\n group.add(innerSubscription);\n\n // Check for promises support\n isPromise(innerSource) && (innerSource = observableFromPromise(innerSource));\n\n innerSubscription.setDisposable(innerSource.subscribe(\n function (x) { o.onNext(x); },\n function (e) {\n errors.push(e);\n group.remove(innerSubscription);\n isStopped && group.length === 1 && setCompletion();\n },\n function () {\n group.remove(innerSubscription);\n isStopped && group.length === 1 && setCompletion();\n }));\n },\n function (e) {\n errors.push(e);\n isStopped = true;\n group.length === 1 && setCompletion();\n },\n function () {\n isStopped = true;\n group.length === 1 && setCompletion();\n }));\n return group;\n });\n };\n\r\n /**\n * Continues an observable sequence that is terminated normally or by an exception with the next observable sequence.\n * @param {Observable} second Second observable sequence used to produce results after the first sequence terminates.\n * @returns {Observable} An observable sequence that concatenates the first and second sequence, even if the first sequence terminates exceptionally.\n */\n observableProto.onErrorResumeNext = function (second) {\n if (!second) { throw new Error('Second observable is required'); }\n return onErrorResumeNext([this, second]);\n };\n\r\n /**\n * Continues an observable sequence that is terminated normally or by an exception with the next observable sequence.\n *\n * @example\n * 1 - res = Rx.Observable.onErrorResumeNext(xs, ys, zs);\n * 1 - res = Rx.Observable.onErrorResumeNext([xs, ys, zs]);\n * @returns {Observable} An observable sequence that concatenates the source sequences, even if a sequence terminates exceptionally.\n */\n var onErrorResumeNext = Observable.onErrorResumeNext = function () {\n var sources = [];\n if (Array.isArray(arguments[0])) {\n sources = arguments[0];\n } else {\n for(var i = 0, len = arguments.length; i < len; i++) { sources.push(arguments[i]); }\n }\n return new AnonymousObservable(function (observer) {\n var pos = 0, subscription = new SerialDisposable(),\n cancelable = immediateScheduler.scheduleRecursive(function (self) {\n var current, d;\n if (pos < sources.length) {\n current = sources[pos++];\n isPromise(current) && (current = observableFromPromise(current));\n d = new SingleAssignmentDisposable();\n subscription.setDisposable(d);\n d.setDisposable(current.subscribe(observer.onNext.bind(observer), self, self));\n } else {\n observer.onCompleted();\n }\n });\n return new CompositeDisposable(subscription, cancelable);\n });\n };\n\r\n /**\n * Returns the values from the source observable sequence only after the other observable sequence produces a value.\n * @param {Observable | Promise} other The observable sequence or Promise that triggers propagation of elements of the source sequence.\n * @returns {Observable} An observable sequence containing the elements of the source sequence starting from the point the other sequence triggered propagation.\n */\n observableProto.skipUntil = function (other) {\n var source = this;\n return new AnonymousObservable(function (o) {\n var isOpen = false;\n var disposables = new CompositeDisposable(source.subscribe(function (left) {\n isOpen && o.onNext(left);\n }, function (e) { o.onError(e); }, function () {\n isOpen && o.onCompleted();\n }));\n\n isPromise(other) && (other = observableFromPromise(other));\n\n var rightSubscription = new SingleAssignmentDisposable();\n disposables.add(rightSubscription);\n rightSubscription.setDisposable(other.subscribe(function () {\n isOpen = true;\n rightSubscription.dispose();\n }, function (e) { o.onError(e); }, function () {\n rightSubscription.dispose();\n }));\n\n return disposables;\n }, source);\n };\n\r\n var SwitchObservable = (function(__super__) {\n inherits(SwitchObservable, __super__);\n function SwitchObservable(source) {\n this.source = source;\n __super__.call(this);\n }\n\n SwitchObservable.prototype.subscribeCore = function (o) {\n var inner = new SerialDisposable(), s = this.source.subscribe(new SwitchObserver(o, inner));\n return new CompositeDisposable(s, inner);\n };\n\n function SwitchObserver(o, inner) {\n this.o = o;\n this.inner = inner;\n this.stopped = false;\n this.latest = 0;\n this.hasLatest = false;\n this.isStopped = false;\n }\n SwitchObserver.prototype.onNext = function (innerSource) {\n if (this.isStopped) { return; }\n var d = new SingleAssignmentDisposable(), id = ++this.latest;\n this.hasLatest = true;\n this.inner.setDisposable(d);\n isPromise(innerSource) && (innerSource = observableFromPromise(innerSource));\n d.setDisposable(innerSource.subscribe(new InnerObserver(this, id)));\n };\n SwitchObserver.prototype.onError = function (e) {\n if (!this.isStopped) {\n this.isStopped = true;\n this.o.onError(e);\n }\n };\n SwitchObserver.prototype.onCompleted = function () {\n if (!this.isStopped) {\n this.isStopped = true;\n this.stopped = true;\n !this.hasLatest && this.o.onCompleted();\n }\n };\n SwitchObserver.prototype.dispose = function () { this.isStopped = true; };\n SwitchObserver.prototype.fail = function (e) {\n if(!this.isStopped) {\n this.isStopped = true;\n this.o.onError(e);\n return true;\n }\n return false;\n };\n\n function InnerObserver(parent, id) {\n this.parent = parent;\n this.id = id;\n this.isStopped = false;\n }\n InnerObserver.prototype.onNext = function (x) {\n if (this.isStopped) { return; }\n this.parent.latest === this.id && this.parent.o.onNext(x);\n };\n InnerObserver.prototype.onError = function (e) {\n if (!this.isStopped) {\n this.isStopped = true;\n this.parent.latest === this.id && this.parent.o.onError(e);\n }\n };\n InnerObserver.prototype.onCompleted = function () {\n if (!this.isStopped) {\n this.isStopped = true;\n if (this.parent.latest === this.id) {\n this.parent.hasLatest = false;\n this.parent.isStopped && this.parent.o.onCompleted();\n }\n }\n };\n InnerObserver.prototype.dispose = function () { this.isStopped = true; }\n InnerObserver.prototype.fail = function (e) {\n if(!this.isStopped) {\n this.isStopped = true;\n this.parent.o.onError(e);\n return true;\n }\n return false;\n };\n\n return SwitchObservable;\n }(ObservableBase));\n\n /**\n * Transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence.\n * @returns {Observable} The observable sequence that at any point in time produces the elements of the most recent inner observable sequence that has been received.\n */\n observableProto['switch'] = observableProto.switchLatest = function () {\n return new SwitchObservable(this);\n };\n\r\n var TakeUntilObservable = (function(__super__) {\n inherits(TakeUntilObservable, __super__);\n\n function TakeUntilObservable(source, other) {\n this.source = source;\n this.other = isPromise(other) ? observableFromPromise(other) : other;\n __super__.call(this);\n }\n\n TakeUntilObservable.prototype.subscribeCore = function(o) {\n return new CompositeDisposable(\n this.source.subscribe(o),\n this.other.subscribe(new InnerObserver(o))\n );\n };\n\n function InnerObserver(o) {\n this.o = o;\n this.isStopped = false;\n }\n InnerObserver.prototype.onNext = function (x) {\n if (this.isStopped) { return; }\n this.o.onCompleted();\n };\n InnerObserver.prototype.onError = function (err) {\n if (!this.isStopped) {\n this.isStopped = true;\n this.o.onError(err);\n }\n };\n InnerObserver.prototype.onCompleted = function () {\n !this.isStopped && (this.isStopped = true);\n };\n InnerObserver.prototype.dispose = function() { this.isStopped = true; };\n InnerObserver.prototype.fail = function (e) {\n if (!this.isStopped) {\n this.isStopped = true;\n this.o.onError(e);\n return true;\n }\n return false;\n };\n\n return TakeUntilObservable;\n }(ObservableBase));\n\n /**\n * Returns the values from the source observable sequence until the other observable sequence produces a value.\n * @param {Observable | Promise} other Observable sequence or Promise that terminates propagation of elements of the source sequence.\n * @returns {Observable} An observable sequence containing the elements of the source sequence up to the point the other sequence interrupted further propagation.\n */\n observableProto.takeUntil = function (other) {\n return new TakeUntilObservable(this, other);\n };\n\r\n function falseFactory() { return false; }\n\n /**\n * Merges the specified observable sequences into one observable sequence by using the selector function only when the (first) source observable sequence produces an element.\n * @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function.\n */\n observableProto.withLatestFrom = function () {\n var len = arguments.length, args = new Array(len)\n for(var i = 0; i < len; i++) { args[i] = arguments[i]; }\n var resultSelector = args.pop(), source = this;\n Array.isArray(args[0]) && (args = args[0]);\n\n return new AnonymousObservable(function (observer) {\n var n = args.length,\n hasValue = arrayInitialize(n, falseFactory),\n hasValueAll = false,\n values = new Array(n);\n\n var subscriptions = new Array(n + 1);\n for (var idx = 0; idx < n; idx++) {\n (function (i) {\n var other = args[i], sad = new SingleAssignmentDisposable();\n isPromise(other) && (other = observableFromPromise(other));\n sad.setDisposable(other.subscribe(function (x) {\n values[i] = x;\n hasValue[i] = true;\n hasValueAll = hasValue.every(identity);\n }, function (e) { observer.onError(e); }, noop));\n subscriptions[i] = sad;\n }(idx));\n }\n\n var sad = new SingleAssignmentDisposable();\n sad.setDisposable(source.subscribe(function (x) {\n var allValues = [x].concat(values);\n if (!hasValueAll) { return; }\n var res = tryCatch(resultSelector).apply(null, allValues);\n if (res === errorObj) { return observer.onError(res.e); }\n observer.onNext(res);\n }, function (e) { observer.onError(e); }, function () {\n observer.onCompleted();\n }));\n subscriptions[n] = sad;\n\n return new CompositeDisposable(subscriptions);\n }, this);\n };\n\r\n function zipArray(second, resultSelector) {\n var first = this;\n return new AnonymousObservable(function (o) {\n var index = 0, len = second.length;\n return first.subscribe(function (left) {\n if (index < len) {\n var right = second[index++], res = tryCatch(resultSelector)(left, right);\n if (res === errorObj) { return o.onError(res.e); }\n o.onNext(res);\n } else {\n o.onCompleted();\n }\n }, function (e) { o.onError(e); }, function () { o.onCompleted(); });\n }, first);\n }\n\n function falseFactory() { return false; }\n function emptyArrayFactory() { return []; }\n\n /**\n * Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences or an array have produced an element at a corresponding index.\n * The last element in the arguments must be a function to invoke for each series of elements at corresponding indexes in the args.\n * @returns {Observable} An observable sequence containing the result of combining elements of the args using the specified result selector function.\n */\n observableProto.zip = function () {\n if (Array.isArray(arguments[0])) { return zipArray.apply(this, arguments); }\n var len = arguments.length, args = new Array(len);\n for(var i = 0; i < len; i++) { args[i] = arguments[i]; }\n\n var parent = this, resultSelector = args.pop();\n args.unshift(parent);\n return new AnonymousObservable(function (o) {\n var n = args.length,\n queues = arrayInitialize(n, emptyArrayFactory),\n isDone = arrayInitialize(n, falseFactory);\n\n var subscriptions = new Array(n);\n for (var idx = 0; idx < n; idx++) {\n (function (i) {\n var source = args[i], sad = new SingleAssignmentDisposable();\n isPromise(source) && (source = observableFromPromise(source));\n sad.setDisposable(source.subscribe(function (x) {\n queues[i].push(x);\n if (queues.every(function (x) { return x.length > 0; })) {\n var queuedValues = queues.map(function (x) { return x.shift(); }),\n res = tryCatch(resultSelector).apply(parent, queuedValues);\n if (res === errorObj) { return o.onError(res.e); }\n o.onNext(res);\n } else if (isDone.filter(function (x, j) { return j !== i; }).every(identity)) {\n o.onCompleted();\n }\n }, function (e) { o.onError(e); }, function () {\n isDone[i] = true;\n isDone.every(identity) && o.onCompleted();\n }));\n subscriptions[i] = sad;\n })(idx);\n }\n\n return new CompositeDisposable(subscriptions);\n }, parent);\n };\n\r\n /**\n * Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index.\n * @param arguments Observable sources.\n * @param {Function} resultSelector Function to invoke for each series of elements at corresponding indexes in the sources.\n * @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function.\n */\n Observable.zip = function () {\n var len = arguments.length, args = new Array(len);\n for(var i = 0; i < len; i++) { args[i] = arguments[i]; }\n var first = args.shift();\n return first.zip.apply(first, args);\n };\n\r\n function falseFactory() { return false; }\n function arrayFactory() { return []; }\n\n /**\n * Merges the specified observable sequences into one observable sequence by emitting a list with the elements of the observable sequences at corresponding indexes.\n * @param arguments Observable sources.\n * @returns {Observable} An observable sequence containing lists of elements at corresponding indexes.\n */\n Observable.zipArray = function () {\n var sources;\n if (Array.isArray(arguments[0])) {\n sources = arguments[0];\n } else {\n var len = arguments.length;\n sources = new Array(len);\n for(var i = 0; i < len; i++) { sources[i] = arguments[i]; }\n }\n return new AnonymousObservable(function (o) {\n var n = sources.length,\n queues = arrayInitialize(n, arrayFactory),\n isDone = arrayInitialize(n, falseFactory);\n\n var subscriptions = new Array(n);\n for (var idx = 0; idx < n; idx++) {\n (function (i) {\n subscriptions[i] = new SingleAssignmentDisposable();\n subscriptions[i].setDisposable(sources[i].subscribe(function (x) {\n queues[i].push(x);\n if (queues.every(function (x) { return x.length > 0; })) {\n var res = queues.map(function (x) { return x.shift(); });\n o.onNext(res);\n } else if (isDone.filter(function (x, j) { return j !== i; }).every(identity)) {\n return o.onCompleted();\n }\n }, function (e) { o.onError(e); }, function () {\n isDone[i] = true;\n isDone.every(identity) && o.onCompleted();\n }));\n })(idx);\n }\n\n return new CompositeDisposable(subscriptions);\n });\n };\n\r\n /**\n * Hides the identity of an observable sequence.\n * @returns {Observable} An observable sequence that hides the identity of the source sequence.\n */\n observableProto.asObservable = function () {\n var source = this;\n return new AnonymousObservable(function (o) { return source.subscribe(o); }, source);\n };\n\r\n /**\n * Projects each element of an observable sequence into zero or more buffers which are produced based on element count information.\n *\n * @example\n * var res = xs.bufferWithCount(10);\n * var res = xs.bufferWithCount(10, 1);\n * @param {Number} count Length of each buffer.\n * @param {Number} [skip] Number of elements to skip between creation of consecutive buffers. If not provided, defaults to the count.\n * @returns {Observable} An observable sequence of buffers.\n */\n observableProto.bufferWithCount = function (count, skip) {\n if (typeof skip !== 'number') {\n skip = count;\n }\n return this.windowWithCount(count, skip).selectMany(function (x) {\n return x.toArray();\n }).where(function (x) {\n return x.length > 0;\n });\n };\n\r\n /**\n * Dematerializes the explicit notification values of an observable sequence as implicit notifications.\n * @returns {Observable} An observable sequence exhibiting the behavior corresponding to the source sequence's notification values.\n */\n observableProto.dematerialize = function () {\n var source = this;\n return new AnonymousObservable(function (o) {\n return source.subscribe(function (x) { return x.accept(o); }, function(e) { o.onError(e); }, function () { o.onCompleted(); });\n }, this);\n };\n\r\n /**\n * Returns an observable sequence that contains only distinct contiguous elements according to the keySelector and the comparer.\n *\n * var obs = observable.distinctUntilChanged();\n * var obs = observable.distinctUntilChanged(function (x) { return x.id; });\n * var obs = observable.distinctUntilChanged(function (x) { return x.id; }, function (x, y) { return x === y; });\n *\n * @param {Function} [keySelector] A function to compute the comparison key for each element. If not provided, it projects the value.\n * @param {Function} [comparer] Equality comparer for computed key values. If not provided, defaults to an equality comparer function.\n * @returns {Observable} An observable sequence only containing the distinct contiguous elements, based on a computed key value, from the source sequence.\n */\n observableProto.distinctUntilChanged = function (keySelector, comparer) {\n var source = this;\n comparer || (comparer = defaultComparer);\n return new AnonymousObservable(function (o) {\n var hasCurrentKey = false, currentKey;\n return source.subscribe(function (value) {\n var key = value;\n if (keySelector) {\n key = tryCatch(keySelector)(value);\n if (key === errorObj) { return o.onError(key.e); }\n }\n if (hasCurrentKey) {\n var comparerEquals = tryCatch(comparer)(currentKey, key);\n if (comparerEquals === errorObj) { return o.onError(comparerEquals.e); }\n }\n if (!hasCurrentKey || !comparerEquals) {\n hasCurrentKey = true;\n currentKey = key;\n o.onNext(value);\n }\n }, function (e) { o.onError(e); }, function () { o.onCompleted(); });\n }, this);\n };\n\r\n var TapObservable = (function(__super__) {\n inherits(TapObservable,__super__);\n function TapObservable(source, observerOrOnNext, onError, onCompleted) {\n this.source = source;\n this.t = !observerOrOnNext || isFunction(observerOrOnNext) ?\n observerCreate(observerOrOnNext || noop, onError || noop, onCompleted || noop) :\n observerOrOnNext;\n __super__.call(this);\n }\n\n TapObservable.prototype.subscribeCore = function(o) {\n return this.source.subscribe(new InnerObserver(o, this.t));\n };\n\n function InnerObserver(o, t) {\n this.o = o;\n this.t = t;\n this.isStopped = false;\n }\n InnerObserver.prototype.onNext = function(x) {\n if (this.isStopped) { return; }\n var res = tryCatch(this.t.onNext).call(this.t, x);\n if (res === errorObj) { this.o.onError(res.e); }\n this.o.onNext(x);\n };\n InnerObserver.prototype.onError = function(err) {\n if (!this.isStopped) {\n this.isStopped = true;\n var res = tryCatch(this.t.onError).call(this.t, err);\n if (res === errorObj) { return this.o.onError(res.e); }\n this.o.onError(err);\n }\n };\n InnerObserver.prototype.onCompleted = function() {\n if (!this.isStopped) {\n this.isStopped = true;\n var res = tryCatch(this.t.onCompleted).call(this.t);\n if (res === errorObj) { return this.o.onError(res.e); }\n this.o.onCompleted();\n }\n };\n InnerObserver.prototype.dispose = function() { this.isStopped = true; };\n InnerObserver.prototype.fail = function (e) {\n if (!this.isStopped) {\n this.isStopped = true;\n this.o.onError(e);\n return true;\n }\n return false;\n };\n\n return TapObservable;\n }(ObservableBase));\n\n /**\n * Invokes an action for each element in the observable sequence and invokes an action upon graceful or exceptional termination of the observable sequence.\n * This method can be used for debugging, logging, etc. of query behavior by intercepting the message stream to run arbitrary actions for messages on the pipeline.\n * @param {Function | Observer} observerOrOnNext Action to invoke for each element in the observable sequence or an o.\n * @param {Function} [onError] Action to invoke upon exceptional termination of the observable sequence. Used if only the observerOrOnNext parameter is also a function.\n * @param {Function} [onCompleted] Action to invoke upon graceful termination of the observable sequence. Used if only the observerOrOnNext parameter is also a function.\n * @returns {Observable} The source sequence with the side-effecting behavior applied.\n */\n observableProto['do'] = observableProto.tap = observableProto.doAction = function (observerOrOnNext, onError, onCompleted) {\n return new TapObservable(this, observerOrOnNext, onError, onCompleted);\n };\n\n /**\n * Invokes an action for each element in the observable sequence.\n * This method can be used for debugging, logging, etc. of query behavior by intercepting the message stream to run arbitrary actions for messages on the pipeline.\n * @param {Function} onNext Action to invoke for each element in the observable sequence.\n * @param {Any} [thisArg] Object to use as this when executing callback.\n * @returns {Observable} The source sequence with the side-effecting behavior applied.\n */\n observableProto.doOnNext = observableProto.tapOnNext = function (onNext, thisArg) {\n return this.tap(typeof thisArg !== 'undefined' ? function (x) { onNext.call(thisArg, x); } : onNext);\n };\n\n /**\n * Invokes an action upon exceptional termination of the observable sequence.\n * This method can be used for debugging, logging, etc. of query behavior by intercepting the message stream to run arbitrary actions for messages on the pipeline.\n * @param {Function} onError Action to invoke upon exceptional termination of the observable sequence.\n * @param {Any} [thisArg] Object to use as this when executing callback.\n * @returns {Observable} The source sequence with the side-effecting behavior applied.\n */\n observableProto.doOnError = observableProto.tapOnError = function (onError, thisArg) {\n return this.tap(noop, typeof thisArg !== 'undefined' ? function (e) { onError.call(thisArg, e); } : onError);\n };\n\n /**\n * Invokes an action upon graceful termination of the observable sequence.\n * This method can be used for debugging, logging, etc. of query behavior by intercepting the message stream to run arbitrary actions for messages on the pipeline.\n * @param {Function} onCompleted Action to invoke upon graceful termination of the observable sequence.\n * @param {Any} [thisArg] Object to use as this when executing callback.\n * @returns {Observable} The source sequence with the side-effecting behavior applied.\n */\n observableProto.doOnCompleted = observableProto.tapOnCompleted = function (onCompleted, thisArg) {\n return this.tap(noop, null, typeof thisArg !== 'undefined' ? function () { onCompleted.call(thisArg); } : onCompleted);\n };\n\r\n /**\n * Invokes a specified action after the source observable sequence terminates gracefully or exceptionally.\n * @param {Function} finallyAction Action to invoke after the source observable sequence terminates.\n * @returns {Observable} Source sequence with the action-invoking termination behavior applied.\n */\n observableProto['finally'] = observableProto.ensure = function (action) {\n var source = this;\n return new AnonymousObservable(function (observer) {\n var subscription;\n try {\n subscription = source.subscribe(observer);\n } catch (e) {\n action();\n throw e;\n }\n return disposableCreate(function () {\n try {\n subscription.dispose();\n } catch (e) {\n throw e;\n } finally {\n action();\n }\n });\n }, this);\n };\n\n /**\n * @deprecated use #finally or #ensure instead.\n */\n observableProto.finallyAction = function (action) {\n //deprecate('finallyAction', 'finally or ensure');\n return this.ensure(action);\n };\n\r\n var IgnoreElementsObservable = (function(__super__) {\n inherits(IgnoreElementsObservable, __super__);\n\n function IgnoreElementsObservable(source) {\n this.source = source;\n __super__.call(this);\n }\n\n IgnoreElementsObservable.prototype.subscribeCore = function (o) {\n return this.source.subscribe(new InnerObserver(o));\n };\n\n function InnerObserver(o) {\n this.o = o;\n this.isStopped = false;\n }\n InnerObserver.prototype.onNext = noop;\n InnerObserver.prototype.onError = function (err) {\n if(!this.isStopped) {\n this.isStopped = true;\n this.o.onError(err);\n }\n };\n InnerObserver.prototype.onCompleted = function () {\n if(!this.isStopped) {\n this.isStopped = true;\n this.o.onCompleted();\n }\n };\n InnerObserver.prototype.dispose = function() { this.isStopped = true; };\n InnerObserver.prototype.fail = function (e) {\n if (!this.isStopped) {\n this.isStopped = true;\n this.observer.onError(e);\n return true;\n }\n\n return false;\n };\n\n return IgnoreElementsObservable;\n }(ObservableBase));\n\n /**\n * Ignores all elements in an observable sequence leaving only the termination messages.\n * @returns {Observable} An empty observable sequence that signals termination, successful or exceptional, of the source sequence.\n */\n observableProto.ignoreElements = function () {\n return new IgnoreElementsObservable(this);\n };\n\r\n /**\n * Materializes the implicit notifications of an observable sequence as explicit notification values.\n * @returns {Observable} An observable sequence containing the materialized notification values from the source sequence.\n */\n observableProto.materialize = function () {\n var source = this;\n return new AnonymousObservable(function (observer) {\n return source.subscribe(function (value) {\n observer.onNext(notificationCreateOnNext(value));\n }, function (e) {\n observer.onNext(notificationCreateOnError(e));\n observer.onCompleted();\n }, function () {\n observer.onNext(notificationCreateOnCompleted());\n observer.onCompleted();\n });\n }, source);\n };\n\r\n /**\n * Repeats the observable sequence a specified number of times. If the repeat count is not specified, the sequence repeats indefinitely.\n * @param {Number} [repeatCount] Number of times to repeat the sequence. If not provided, repeats the sequence indefinitely.\n * @returns {Observable} The observable sequence producing the elements of the given sequence repeatedly.\n */\n observableProto.repeat = function (repeatCount) {\n return enumerableRepeat(this, repeatCount).concat();\n };\n\r\n /**\n * Repeats the source observable sequence the specified number of times or until it successfully terminates. If the retry count is not specified, it retries indefinitely.\n * Note if you encounter an error and want it to retry once, then you must use .retry(2);\n *\n * @example\n * var res = retried = retry.repeat();\n * var res = retried = retry.repeat(2);\n * @param {Number} [retryCount] Number of times to retry the sequence. If not provided, retry the sequence indefinitely.\n * @returns {Observable} An observable sequence producing the elements of the given sequence repeatedly until it terminates successfully.\n */\n observableProto.retry = function (retryCount) {\n return enumerableRepeat(this, retryCount).catchError();\n };\n\r\n /**\n * Repeats the source observable sequence upon error each time the notifier emits or until it successfully terminates. \n * if the notifier completes, the observable sequence completes.\n *\n * @example\n * var timer = Observable.timer(500);\n * var source = observable.retryWhen(timer);\n * @param {Observable} [notifier] An observable that triggers the retries or completes the observable with onNext or onCompleted respectively.\n * @returns {Observable} An observable sequence producing the elements of the given sequence repeatedly until it terminates successfully.\n */\n observableProto.retryWhen = function (notifier) {\n return enumerableRepeat(this).catchErrorWhen(notifier);\n };\r\n var ScanObservable = (function(__super__) {\n inherits(ScanObservable, __super__);\n function ScanObservable(source, accumulator, hasSeed, seed) {\n this.source = source;\n this.accumulator = accumulator;\n this.hasSeed = hasSeed;\n this.seed = seed;\n __super__.call(this);\n }\n\n ScanObservable.prototype.subscribeCore = function(observer) {\n return this.source.subscribe(new ScanObserver(observer,this));\n };\n\n return ScanObservable;\n }(ObservableBase));\n\n function ScanObserver(observer, parent) {\n this.observer = observer;\n this.accumulator = parent.accumulator;\n this.hasSeed = parent.hasSeed;\n this.seed = parent.seed;\n this.hasAccumulation = false;\n this.accumulation = null;\n this.hasValue = false;\n this.isStopped = false;\n }\n ScanObserver.prototype.onNext = function (x) {\n if (this.isStopped) { return; }\n !this.hasValue && (this.hasValue = true);\n try {\n if (this.hasAccumulation) {\n this.accumulation = this.accumulator(this.accumulation, x);\n } else {\n this.accumulation = this.hasSeed ? this.accumulator(this.seed, x) : x;\n this.hasAccumulation = true;\n }\n } catch (e) {\n return this.observer.onError(e);\n }\n this.observer.onNext(this.accumulation);\n };\n ScanObserver.prototype.onError = function (e) { \n if (!this.isStopped) {\n this.isStopped = true;\n this.observer.onError(e);\n }\n };\n ScanObserver.prototype.onCompleted = function () {\n if (!this.isStopped) {\n this.isStopped = true;\n !this.hasValue && this.hasSeed && this.observer.onNext(this.seed);\n this.observer.onCompleted();\n }\n };\n ScanObserver.prototype.dispose = function() { this.isStopped = true; };\n ScanObserver.prototype.fail = function (e) {\n if (!this.isStopped) {\n this.isStopped = true;\n this.observer.onError(e);\n return true;\n }\n return false;\n };\n\n /**\n * Applies an accumulator function over an observable sequence and returns each intermediate result. The optional seed value is used as the initial accumulator value.\n * For aggregation behavior with no intermediate results, see Observable.aggregate.\n * @param {Mixed} [seed] The initial accumulator value.\n * @param {Function} accumulator An accumulator function to be invoked on each element.\n * @returns {Observable} An observable sequence containing the accumulated values.\n */\n observableProto.scan = function () {\n var hasSeed = false, seed, accumulator, source = this;\n if (arguments.length === 2) {\n hasSeed = true;\n seed = arguments[0];\n accumulator = arguments[1];\n } else {\n accumulator = arguments[0];\n }\n return new ScanObservable(this, accumulator, hasSeed, seed);\n };\n\r\n /**\n * Bypasses a specified number of elements at the end of an observable sequence.\n * @description\n * This operator accumulates a queue with a length enough to store the first `count` elements. As more elements are\n * received, elements are taken from the front of the queue and produced on the result sequence. This causes elements to be delayed.\n * @param count Number of elements to bypass at the end of the source sequence.\n * @returns {Observable} An observable sequence containing the source sequence elements except for the bypassed ones at the end.\n */\n observableProto.skipLast = function (count) {\n if (count < 0) { throw new ArgumentOutOfRangeError(); }\n var source = this;\n return new AnonymousObservable(function (o) {\n var q = [];\n return source.subscribe(function (x) {\n q.push(x);\n q.length > count && o.onNext(q.shift());\n }, function (e) { o.onError(e); }, function () { o.onCompleted(); });\n }, source);\n };\n\r\n /**\n * Prepends a sequence of values to an observable sequence with an optional scheduler and an argument list of values to prepend.\n * @example\n * var res = source.startWith(1, 2, 3);\n * var res = source.startWith(Rx.Scheduler.timeout, 1, 2, 3);\n * @param {Arguments} args The specified values to prepend to the observable sequence\n * @returns {Observable} The source sequence prepended with the specified values.\n */\n observableProto.startWith = function () {\n var values, scheduler, start = 0;\n if (!!arguments.length && isScheduler(arguments[0])) {\n scheduler = arguments[0];\n start = 1;\n } else {\n scheduler = immediateScheduler;\n }\n for(var args = [], i = start, len = arguments.length; i < len; i++) { args.push(arguments[i]); }\n return enumerableOf([observableFromArray(args, scheduler), this]).concat();\n };\n\r\n /**\n * Returns a specified number of contiguous elements from the end of an observable sequence.\n * @description\n * This operator accumulates a buffer with a length enough to store elements count elements. Upon completion of\n * the source sequence, this buffer is drained on the result sequence. This causes the elements to be delayed.\n * @param {Number} count Number of elements to take from the end of the source sequence.\n * @returns {Observable} An observable sequence containing the specified number of elements from the end of the source sequence.\n */\n observableProto.takeLast = function (count) {\n if (count < 0) { throw new ArgumentOutOfRangeError(); }\n var source = this;\n return new AnonymousObservable(function (o) {\n var q = [];\n return source.subscribe(function (x) {\n q.push(x);\n q.length > count && q.shift();\n }, function (e) { o.onError(e); }, function () {\n while (q.length > 0) { o.onNext(q.shift()); }\n o.onCompleted();\n });\n }, source);\n };\n\r\n /**\n * Returns an array with the specified number of contiguous elements from the end of an observable sequence.\n *\n * @description\n * This operator accumulates a buffer with a length enough to store count elements. Upon completion of the\n * source sequence, this buffer is produced on the result sequence.\n * @param {Number} count Number of elements to take from the end of the source sequence.\n * @returns {Observable} An observable sequence containing a single array with the specified number of elements from the end of the source sequence.\n */\n observableProto.takeLastBuffer = function (count) {\n var source = this;\n return new AnonymousObservable(function (o) {\n var q = [];\n return source.subscribe(function (x) {\n q.push(x);\n q.length > count && q.shift();\n }, function (e) { o.onError(e); }, function () {\n o.onNext(q);\n o.onCompleted();\n });\n }, source);\n };\n\r\n /**\n * Projects each element of an observable sequence into zero or more windows which are produced based on element count information.\n *\n * var res = xs.windowWithCount(10);\n * var res = xs.windowWithCount(10, 1);\n * @param {Number} count Length of each window.\n * @param {Number} [skip] Number of elements to skip between creation of consecutive windows. If not specified, defaults to the count.\n * @returns {Observable} An observable sequence of windows.\n */\n observableProto.windowWithCount = function (count, skip) {\n var source = this;\n +count || (count = 0);\n Math.abs(count) === Infinity && (count = 0);\n if (count <= 0) { throw new ArgumentOutOfRangeError(); }\n skip == null && (skip = count);\n +skip || (skip = 0);\n Math.abs(skip) === Infinity && (skip = 0);\n\n if (skip <= 0) { throw new ArgumentOutOfRangeError(); }\n return new AnonymousObservable(function (observer) {\n var m = new SingleAssignmentDisposable(),\n refCountDisposable = new RefCountDisposable(m),\n n = 0,\n q = [];\n\n function createWindow () {\n var s = new Subject();\n q.push(s);\n observer.onNext(addRef(s, refCountDisposable));\n }\n\n createWindow();\n\n m.setDisposable(source.subscribe(\n function (x) {\n for (var i = 0, len = q.length; i < len; i++) { q[i].onNext(x); }\n var c = n - count + 1;\n c >= 0 && c % skip === 0 && q.shift().onCompleted();\n ++n % skip === 0 && createWindow();\n },\n function (e) {\n while (q.length > 0) { q.shift().onError(e); }\n observer.onError(e);\n },\n function () {\n while (q.length > 0) { q.shift().onCompleted(); }\n observer.onCompleted();\n }\n ));\n return refCountDisposable;\n }, source);\n };\n\r\n function concatMap(source, selector, thisArg) {\n var selectorFunc = bindCallback(selector, thisArg, 3);\n return source.map(function (x, i) {\n var result = selectorFunc(x, i, source);\n isPromise(result) && (result = observableFromPromise(result));\n (isArrayLike(result) || isIterable(result)) && (result = observableFrom(result));\n return result;\n }).concatAll();\n }\n\n /**\n * One of the Following:\n * Projects each element of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence.\n *\n * @example\n * var res = source.concatMap(function (x) { return Rx.Observable.range(0, x); });\n * Or:\n * Projects each element of an observable sequence to an observable sequence, invokes the result selector for the source element and each of the corresponding inner sequence's elements, and merges the results into one observable sequence.\n *\n * var res = source.concatMap(function (x) { return Rx.Observable.range(0, x); }, function (x, y) { return x + y; });\n * Or:\n * Projects each element of the source observable sequence to the other observable sequence and merges the resulting observable sequences into one observable sequence.\n *\n * var res = source.concatMap(Rx.Observable.fromArray([1,2,3]));\n * @param {Function} selector A transform function to apply to each element or an observable sequence to project each element from the\n * source sequence onto which could be either an observable or Promise.\n * @param {Function} [resultSelector] A transform function to apply to each element of the intermediate sequence.\n * @returns {Observable} An observable sequence whose elements are the result of invoking the one-to-many transform function collectionSelector on each element of the input sequence and then mapping each of those sequence elements and their corresponding source element to a result element.\n */\n observableProto.selectConcat = observableProto.concatMap = function (selector, resultSelector, thisArg) {\n if (isFunction(selector) && isFunction(resultSelector)) {\n return this.concatMap(function (x, i) {\n var selectorResult = selector(x, i);\n isPromise(selectorResult) && (selectorResult = observableFromPromise(selectorResult));\n (isArrayLike(selectorResult) || isIterable(selectorResult)) && (selectorResult = observableFrom(selectorResult));\n\n return selectorResult.map(function (y, i2) {\n return resultSelector(x, y, i, i2);\n });\n });\n }\n return isFunction(selector) ?\n concatMap(this, selector, thisArg) :\n concatMap(this, function () { return selector; });\n };\n\r\n /**\n * Projects each notification of an observable sequence to an observable sequence and concats the resulting observable sequences into one observable sequence.\n * @param {Function} onNext A transform function to apply to each element; the second parameter of the function represents the index of the source element.\n * @param {Function} onError A transform function to apply when an error occurs in the source sequence.\n * @param {Function} onCompleted A transform function to apply when the end of the source sequence is reached.\n * @param {Any} [thisArg] An optional \"this\" to use to invoke each transform.\n * @returns {Observable} An observable sequence whose elements are the result of invoking the one-to-many transform function corresponding to each notification in the input sequence.\n */\n observableProto.concatMapObserver = observableProto.selectConcatObserver = function(onNext, onError, onCompleted, thisArg) {\n var source = this,\n onNextFunc = bindCallback(onNext, thisArg, 2),\n onErrorFunc = bindCallback(onError, thisArg, 1),\n onCompletedFunc = bindCallback(onCompleted, thisArg, 0);\n return new AnonymousObservable(function (observer) {\n var index = 0;\n return source.subscribe(\n function (x) {\n var result;\n try {\n result = onNextFunc(x, index++);\n } catch (e) {\n observer.onError(e);\n return;\n }\n isPromise(result) && (result = observableFromPromise(result));\n observer.onNext(result);\n },\n function (err) {\n var result;\n try {\n result = onErrorFunc(err);\n } catch (e) {\n observer.onError(e);\n return;\n }\n isPromise(result) && (result = observableFromPromise(result));\n observer.onNext(result);\n observer.onCompleted();\n },\n function () {\n var result;\n try {\n result = onCompletedFunc();\n } catch (e) {\n observer.onError(e);\n return;\n }\n isPromise(result) && (result = observableFromPromise(result));\n observer.onNext(result);\n observer.onCompleted();\n });\n }, this).concatAll();\n };\n\r\n /**\n * Returns the elements of the specified sequence or the specified value in a singleton sequence if the sequence is empty.\n *\n * var res = obs = xs.defaultIfEmpty();\n * 2 - obs = xs.defaultIfEmpty(false);\n *\n * @memberOf Observable#\n * @param defaultValue The value to return if the sequence is empty. If not provided, this defaults to null.\n * @returns {Observable} An observable sequence that contains the specified default value if the source is empty; otherwise, the elements of the source itself.\n */\n observableProto.defaultIfEmpty = function (defaultValue) {\n var source = this;\n defaultValue === undefined && (defaultValue = null);\n return new AnonymousObservable(function (observer) {\n var found = false;\n return source.subscribe(function (x) {\n found = true;\n observer.onNext(x);\n },\n function (e) { observer.onError(e); }, \n function () {\n !found && observer.onNext(defaultValue);\n observer.onCompleted();\n });\n }, source);\n };\n\r\n // Swap out for Array.findIndex\n function arrayIndexOfComparer(array, item, comparer) {\n for (var i = 0, len = array.length; i < len; i++) {\n if (comparer(array[i], item)) { return i; }\n }\n return -1;\n }\n\n function HashSet(comparer) {\n this.comparer = comparer;\n this.set = [];\n }\n HashSet.prototype.push = function(value) {\n var retValue = arrayIndexOfComparer(this.set, value, this.comparer) === -1;\n retValue && this.set.push(value);\n return retValue;\n };\n\n /**\n * Returns an observable sequence that contains only distinct elements according to the keySelector and the comparer.\n * Usage of this operator should be considered carefully due to the maintenance of an internal lookup structure which can grow large.\n *\n * @example\n * var res = obs = xs.distinct();\n * 2 - obs = xs.distinct(function (x) { return x.id; });\n * 2 - obs = xs.distinct(function (x) { return x.id; }, function (a,b) { return a === b; });\n * @param {Function} [keySelector] A function to compute the comparison key for each element.\n * @param {Function} [comparer] Used to compare items in the collection.\n * @returns {Observable} An observable sequence only containing the distinct elements, based on a computed key value, from the source sequence.\n */\n observableProto.distinct = function (keySelector, comparer) {\n var source = this;\n comparer || (comparer = defaultComparer);\n return new AnonymousObservable(function (o) {\n var hashSet = new HashSet(comparer);\n return source.subscribe(function (x) {\n var key = x;\n\n if (keySelector) {\n try {\n key = keySelector(x);\n } catch (e) {\n o.onError(e);\n return;\n }\n }\n hashSet.push(key) && o.onNext(x);\n },\n function (e) { o.onError(e); }, function () { o.onCompleted(); });\n }, this);\n };\n\r\n /**\n * Groups the elements of an observable sequence according to a specified key selector function and comparer and selects the resulting elements by using a specified function.\n *\n * @example\n * var res = observable.groupBy(function (x) { return x.id; });\n * 2 - observable.groupBy(function (x) { return x.id; }), function (x) { return x.name; });\n * 3 - observable.groupBy(function (x) { return x.id; }), function (x) { return x.name; }, function (x) { return x.toString(); });\n * @param {Function} keySelector A function to extract the key for each element.\n * @param {Function} [elementSelector] A function to map each source element to an element in an observable group.\n * @param {Function} [comparer] Used to determine whether the objects are equal.\n * @returns {Observable} A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.\n */\n observableProto.groupBy = function (keySelector, elementSelector, comparer) {\n return this.groupByUntil(keySelector, elementSelector, observableNever, comparer);\n };\n\r\n /**\n * Groups the elements of an observable sequence according to a specified key selector function.\n * A duration selector function is used to control the lifetime of groups. When a group expires, it receives an OnCompleted notification. When a new element with the same\n * key value as a reclaimed group occurs, the group will be reborn with a new lifetime request.\n *\n * @example\n * var res = observable.groupByUntil(function (x) { return x.id; }, null, function () { return Rx.Observable.never(); });\n * 2 - observable.groupBy(function (x) { return x.id; }), function (x) { return x.name; }, function () { return Rx.Observable.never(); });\n * 3 - observable.groupBy(function (x) { return x.id; }), function (x) { return x.name; }, function () { return Rx.Observable.never(); }, function (x) { return x.toString(); });\n * @param {Function} keySelector A function to extract the key for each element.\n * @param {Function} durationSelector A function to signal the expiration of a group.\n * @param {Function} [comparer] Used to compare objects. When not specified, the default comparer is used.\n * @returns {Observable}\n * A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.\n * If a group's lifetime expires, a new group with the same key value can be created once an element with such a key value is encoutered.\n *\n */\n observableProto.groupByUntil = function (keySelector, elementSelector, durationSelector, comparer) {\n var source = this;\n elementSelector || (elementSelector = identity);\n comparer || (comparer = defaultComparer);\n return new AnonymousObservable(function (observer) {\n function handleError(e) { return function (item) { item.onError(e); }; }\n var map = new Dictionary(0, comparer),\n groupDisposable = new CompositeDisposable(),\n refCountDisposable = new RefCountDisposable(groupDisposable);\n\n groupDisposable.add(source.subscribe(function (x) {\n var key;\n try {\n key = keySelector(x);\n } catch (e) {\n map.getValues().forEach(handleError(e));\n observer.onError(e);\n return;\n }\n\n var fireNewMapEntry = false,\n writer = map.tryGetValue(key);\n if (!writer) {\n writer = new Subject();\n map.set(key, writer);\n fireNewMapEntry = true;\n }\n\n if (fireNewMapEntry) {\n var group = new GroupedObservable(key, writer, refCountDisposable),\n durationGroup = new GroupedObservable(key, writer);\n try {\n duration = durationSelector(durationGroup);\n } catch (e) {\n map.getValues().forEach(handleError(e));\n observer.onError(e);\n return;\n }\n\n observer.onNext(group);\n\n var md = new SingleAssignmentDisposable();\n groupDisposable.add(md);\n\n var expire = function () {\n map.remove(key) && writer.onCompleted();\n groupDisposable.remove(md);\n };\n\n md.setDisposable(duration.take(1).subscribe(\n noop,\n function (exn) {\n map.getValues().forEach(handleError(exn));\n observer.onError(exn);\n },\n expire)\n );\n }\n\n var element;\n try {\n element = elementSelector(x);\n } catch (e) {\n map.getValues().forEach(handleError(e));\n observer.onError(e);\n return;\n }\n\n writer.onNext(element);\n }, function (ex) {\n map.getValues().forEach(handleError(ex));\n observer.onError(ex);\n }, function () {\n map.getValues().forEach(function (item) { item.onCompleted(); });\n observer.onCompleted();\n }));\n\n return refCountDisposable;\n }, source);\n };\n\r\n var MapObservable = (function (__super__) {\n inherits(MapObservable, __super__);\n\n function MapObservable(source, selector, thisArg) {\n this.source = source;\n this.selector = bindCallback(selector, thisArg, 3);\n __super__.call(this);\n }\n \n function innerMap(selector, self) {\n return function (x, i, o) { return selector.call(this, self.selector(x, i, o), i, o); }\n }\n\n MapObservable.prototype.internalMap = function (selector, thisArg) {\n return new MapObservable(this.source, innerMap(selector, this), thisArg);\n };\n\n MapObservable.prototype.subscribeCore = function (o) {\n return this.source.subscribe(new InnerObserver(o, this.selector, this));\n };\n \n function InnerObserver(o, selector, source) {\n this.o = o;\n this.selector = selector;\n this.source = source;\n this.i = 0;\n this.isStopped = false;\n }\n \n InnerObserver.prototype.onNext = function(x) {\n if (this.isStopped) { return; }\n var result = tryCatch(this.selector)(x, this.i++, this.source);\n if (result === errorObj) {\n return this.o.onError(result.e);\n }\n this.o.onNext(result);\n };\n InnerObserver.prototype.onError = function (e) {\n if(!this.isStopped) { this.isStopped = true; this.o.onError(e); }\n };\n InnerObserver.prototype.onCompleted = function () {\n if(!this.isStopped) { this.isStopped = true; this.o.onCompleted(); }\n };\n InnerObserver.prototype.dispose = function() { this.isStopped = true; };\n InnerObserver.prototype.fail = function (e) {\n if (!this.isStopped) {\n this.isStopped = true;\n this.o.onError(e);\n return true;\n }\n \n return false;\n };\n\n return MapObservable;\n\n }(ObservableBase));\n\n /**\n * Projects each element of an observable sequence into a new form by incorporating the element's index.\n * @param {Function} selector A transform function to apply to each source element; the second parameter of the function represents the index of the source element.\n * @param {Any} [thisArg] Object to use as this when executing callback.\n * @returns {Observable} An observable sequence whose elements are the result of invoking the transform function on each element of source.\n */\n observableProto.map = observableProto.select = function (selector, thisArg) {\n var selectorFn = typeof selector === 'function' ? selector : function () { return selector; };\n return this instanceof MapObservable ?\n this.internalMap(selectorFn, thisArg) :\n new MapObservable(this, selectorFn, thisArg);\n };\n\r\n /**\n * Retrieves the value of a specified nested property from all elements in\n * the Observable sequence.\n * @param {Arguments} arguments The nested properties to pluck.\n * @returns {Observable} Returns a new Observable sequence of property values.\n */\n observableProto.pluck = function () {\n var args = arguments, len = arguments.length;\n if (len === 0) { throw new Error('List of properties cannot be empty.'); }\n return this.map(function (x) {\n var currentProp = x;\n for (var i = 0; i < len; i++) {\n var p = currentProp[args[i]];\n if (typeof p !== 'undefined') {\n currentProp = p;\n } else {\n return undefined;\n }\n }\n return currentProp;\n });\n };\n\r\n function flatMap(source, selector, thisArg) {\n var selectorFunc = bindCallback(selector, thisArg, 3);\n return source.map(function (x, i) {\n var result = selectorFunc(x, i, source);\n isPromise(result) && (result = observableFromPromise(result));\n (isArrayLike(result) || isIterable(result)) && (result = observableFrom(result));\n return result;\n }).mergeAll();\n }\n\n /**\n * One of the Following:\n * Projects each element of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence.\n *\n * @example\n * var res = source.selectMany(function (x) { return Rx.Observable.range(0, x); });\n * Or:\n * Projects each element of an observable sequence to an observable sequence, invokes the result selector for the source element and each of the corresponding inner sequence's elements, and merges the results into one observable sequence.\n *\n * var res = source.selectMany(function (x) { return Rx.Observable.range(0, x); }, function (x, y) { return x + y; });\n * Or:\n * Projects each element of the source observable sequence to the other observable sequence and merges the resulting observable sequences into one observable sequence.\n *\n * var res = source.selectMany(Rx.Observable.fromArray([1,2,3]));\n * @param {Function} selector A transform function to apply to each element or an observable sequence to project each element from the source sequence onto which could be either an observable or Promise.\n * @param {Function} [resultSelector] A transform function to apply to each element of the intermediate sequence.\n * @param {Any} [thisArg] Object to use as this when executing callback.\n * @returns {Observable} An observable sequence whose elements are the result of invoking the one-to-many transform function collectionSelector on each element of the input sequence and then mapping each of those sequence elements and their corresponding source element to a result element.\n */\n observableProto.selectMany = observableProto.flatMap = function (selector, resultSelector, thisArg) {\n if (isFunction(selector) && isFunction(resultSelector)) {\n return this.flatMap(function (x, i) {\n var selectorResult = selector(x, i);\n isPromise(selectorResult) && (selectorResult = observableFromPromise(selectorResult));\n (isArrayLike(selectorResult) || isIterable(selectorResult)) && (selectorResult = observableFrom(selectorResult));\n\n return selectorResult.map(function (y, i2) {\n return resultSelector(x, y, i, i2);\n });\n }, thisArg);\n }\n return isFunction(selector) ?\n flatMap(this, selector, thisArg) :\n flatMap(this, function () { return selector; });\n };\n\r\n /**\n * Projects each notification of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence.\n * @param {Function} onNext A transform function to apply to each element; the second parameter of the function represents the index of the source element.\n * @param {Function} onError A transform function to apply when an error occurs in the source sequence.\n * @param {Function} onCompleted A transform function to apply when the end of the source sequence is reached.\n * @param {Any} [thisArg] An optional \"this\" to use to invoke each transform.\n * @returns {Observable} An observable sequence whose elements are the result of invoking the one-to-many transform function corresponding to each notification in the input sequence.\n */\n observableProto.flatMapObserver = observableProto.selectManyObserver = function (onNext, onError, onCompleted, thisArg) {\n var source = this;\n return new AnonymousObservable(function (observer) {\n var index = 0;\n\n return source.subscribe(\n function (x) {\n var result;\n try {\n result = onNext.call(thisArg, x, index++);\n } catch (e) {\n observer.onError(e);\n return;\n }\n isPromise(result) && (result = observableFromPromise(result));\n observer.onNext(result);\n },\n function (err) {\n var result;\n try {\n result = onError.call(thisArg, err);\n } catch (e) {\n observer.onError(e);\n return;\n }\n isPromise(result) && (result = observableFromPromise(result));\n observer.onNext(result);\n observer.onCompleted();\n },\n function () {\n var result;\n try {\n result = onCompleted.call(thisArg);\n } catch (e) {\n observer.onError(e);\n return;\n }\n isPromise(result) && (result = observableFromPromise(result));\n observer.onNext(result);\n observer.onCompleted();\n });\n }, source).mergeAll();\n };\n\r\n /**\n * Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then\n * transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence.\n * @param {Function} selector A transform function to apply to each source element; the second parameter of the function represents the index of the source element.\n * @param {Any} [thisArg] Object to use as this when executing callback.\n * @returns {Observable} An observable sequence whose elements are the result of invoking the transform function on each element of source producing an Observable of Observable sequences\n * and that at any point in time produces the elements of the most recent inner observable sequence that has been received.\n */\n observableProto.selectSwitch = observableProto.flatMapLatest = observableProto.switchMap = function (selector, thisArg) {\n return this.select(selector, thisArg).switchLatest();\n };\n\r\n var SkipObservable = (function(__super__) {\n inherits(SkipObservable, __super__);\n function SkipObservable(source, count) {\n this.source = source;\n this.skipCount = count;\n __super__.call(this);\n }\n \n SkipObservable.prototype.subscribeCore = function (o) {\n return this.source.subscribe(new InnerObserver(o, this.skipCount));\n };\n \n function InnerObserver(o, c) {\n this.c = c;\n this.r = c;\n this.o = o;\n this.isStopped = false;\n }\n InnerObserver.prototype.onNext = function (x) {\n if (this.isStopped) { return; }\n if (this.r <= 0) { \n this.o.onNext(x);\n } else {\n this.r--;\n }\n };\n InnerObserver.prototype.onError = function(e) {\n if (!this.isStopped) { this.isStopped = true; this.o.onError(e); }\n };\n InnerObserver.prototype.onCompleted = function() {\n if (!this.isStopped) { this.isStopped = true; this.o.onCompleted(); }\n };\n InnerObserver.prototype.dispose = function() { this.isStopped = true; };\n InnerObserver.prototype.fail = function(e) {\n if (!this.isStopped) {\n this.isStopped = true;\n this.o.onError(e);\n return true;\n }\n return false;\n };\n \n return SkipObservable;\n }(ObservableBase)); \n \n /**\n * Bypasses a specified number of elements in an observable sequence and then returns the remaining elements.\n * @param {Number} count The number of elements to skip before returning the remaining elements.\n * @returns {Observable} An observable sequence that contains the elements that occur after the specified index in the input sequence.\n */\n observableProto.skip = function (count) {\n if (count < 0) { throw new ArgumentOutOfRangeError(); }\n return new SkipObservable(this, count);\n };\r\n /**\n * Bypasses elements in an observable sequence as long as a specified condition is true and then returns the remaining elements.\n * The element's index is used in the logic of the predicate function.\n *\n * var res = source.skipWhile(function (value) { return value < 10; });\n * var res = source.skipWhile(function (value, index) { return value < 10 || index < 10; });\n * @param {Function} predicate A function to test each element for a condition; the second parameter of the function represents the index of the source element.\n * @param {Any} [thisArg] Object to use as this when executing callback.\n * @returns {Observable} An observable sequence that contains the elements from the input sequence starting at the first element in the linear series that does not pass the test specified by predicate.\n */\n observableProto.skipWhile = function (predicate, thisArg) {\n var source = this,\n callback = bindCallback(predicate, thisArg, 3);\n return new AnonymousObservable(function (o) {\n var i = 0, running = false;\n return source.subscribe(function (x) {\n if (!running) {\n try {\n running = !callback(x, i++, source);\n } catch (e) {\n o.onError(e);\n return;\n }\n }\n running && o.onNext(x);\n }, function (e) { o.onError(e); }, function () { o.onCompleted(); });\n }, source);\n };\n\r\n /**\n * Returns a specified number of contiguous elements from the start of an observable sequence, using the specified scheduler for the edge case of take(0).\n *\n * var res = source.take(5);\n * var res = source.take(0, Rx.Scheduler.timeout);\n * @param {Number} count The number of elements to return.\n * @param {Scheduler} [scheduler] Scheduler used to produce an OnCompleted message in case <paramref name=\"count count</paramref> is set to 0.\n * @returns {Observable} An observable sequence that contains the specified number of elements from the start of the input sequence.\n */\n observableProto.take = function (count, scheduler) {\n if (count < 0) { throw new ArgumentOutOfRangeError(); }\n if (count === 0) { return observableEmpty(scheduler); }\n var source = this;\n return new AnonymousObservable(function (o) {\n var remaining = count;\n return source.subscribe(function (x) {\n if (remaining-- > 0) {\n o.onNext(x);\n remaining <= 0 && o.onCompleted();\n }\n }, function (e) { o.onError(e); }, function () { o.onCompleted(); });\n }, source);\n };\n\r\n /**\n * Returns elements from an observable sequence as long as a specified condition is true.\n * The element's index is used in the logic of the predicate function.\n * @param {Function} predicate A function to test each element for a condition; the second parameter of the function represents the index of the source element.\n * @param {Any} [thisArg] Object to use as this when executing callback.\n * @returns {Observable} An observable sequence that contains the elements from the input sequence that occur before the element at which the test no longer passes.\n */\n observableProto.takeWhile = function (predicate, thisArg) {\n var source = this,\n callback = bindCallback(predicate, thisArg, 3);\n return new AnonymousObservable(function (o) {\n var i = 0, running = true;\n return source.subscribe(function (x) {\n if (running) {\n try {\n running = callback(x, i++, source);\n } catch (e) {\n o.onError(e);\n return;\n }\n if (running) {\n o.onNext(x);\n } else {\n o.onCompleted();\n }\n }\n }, function (e) { o.onError(e); }, function () { o.onCompleted(); });\n }, source);\n };\n\r\n var FilterObservable = (function (__super__) {\n inherits(FilterObservable, __super__);\n\n function FilterObservable(source, predicate, thisArg) {\n this.source = source;\n this.predicate = bindCallback(predicate, thisArg, 3);\n __super__.call(this);\n }\n\n FilterObservable.prototype.subscribeCore = function (o) {\n return this.source.subscribe(new InnerObserver(o, this.predicate, this));\n };\n \n function innerPredicate(predicate, self) {\n return function(x, i, o) { return self.predicate(x, i, o) && predicate.call(this, x, i, o); }\n }\n\n FilterObservable.prototype.internalFilter = function(predicate, thisArg) {\n return new FilterObservable(this.source, innerPredicate(predicate, this), thisArg);\n };\n \n function InnerObserver(o, predicate, source) {\n this.o = o;\n this.predicate = predicate;\n this.source = source;\n this.i = 0;\n this.isStopped = false;\n }\n \n InnerObserver.prototype.onNext = function(x) {\n if (this.isStopped) { return; }\n var shouldYield = tryCatch(this.predicate)(x, this.i++, this.source);\n if (shouldYield === errorObj) {\n return this.o.onError(shouldYield.e);\n }\n shouldYield && this.o.onNext(x);\n };\n InnerObserver.prototype.onError = function (e) {\n if(!this.isStopped) { this.isStopped = true; this.o.onError(e); }\n };\n InnerObserver.prototype.onCompleted = function () {\n if(!this.isStopped) { this.isStopped = true; this.o.onCompleted(); }\n };\n InnerObserver.prototype.dispose = function() { this.isStopped = true; };\n InnerObserver.prototype.fail = function (e) {\n if (!this.isStopped) {\n this.isStopped = true;\n this.o.onError(e);\n return true;\n }\n return false;\n };\n\n return FilterObservable;\n\n }(ObservableBase));\n\n /**\n * Filters the elements of an observable sequence based on a predicate by incorporating the element's index.\n * @param {Function} predicate A function to test each source element for a condition; the second parameter of the function represents the index of the source element.\n * @param {Any} [thisArg] Object to use as this when executing callback.\n * @returns {Observable} An observable sequence that contains elements from the input sequence that satisfy the condition.\n */\n observableProto.filter = observableProto.where = function (predicate, thisArg) {\n return this instanceof FilterObservable ? this.internalFilter(predicate, thisArg) :\n new FilterObservable(this, predicate, thisArg);\n };\n\r\n function extremaBy(source, keySelector, comparer) {\n return new AnonymousObservable(function (o) {\n var hasValue = false, lastKey = null, list = [];\n return source.subscribe(function (x) {\n var comparison, key;\n try {\n key = keySelector(x);\n } catch (ex) {\n o.onError(ex);\n return;\n }\n comparison = 0;\n if (!hasValue) {\n hasValue = true;\n lastKey = key;\n } else {\n try {\n comparison = comparer(key, lastKey);\n } catch (ex1) {\n o.onError(ex1);\n return;\n }\n }\n if (comparison > 0) {\n lastKey = key;\n list = [];\n }\n if (comparison >= 0) { list.push(x); }\n }, function (e) { o.onError(e); }, function () {\n o.onNext(list);\n o.onCompleted();\n });\n }, source);\n }\n\r\n function firstOnly(x) {\n if (x.length === 0) { throw new EmptyError(); }\n return x[0];\n }\n\r\n /**\n * Applies an accumulator function over an observable sequence, returning the result of the aggregation as a single element in the result sequence. The specified seed value is used as the initial accumulator value.\n * For aggregation behavior with incremental intermediate results, see Observable.scan.\n * @deprecated Use #reduce instead\n * @param {Mixed} [seed] The initial accumulator value.\n * @param {Function} accumulator An accumulator function to be invoked on each element.\n * @returns {Observable} An observable sequence containing a single element with the final accumulator value.\n */\n observableProto.aggregate = function () {\n var hasSeed = false, accumulator, seed, source = this;\n if (arguments.length === 2) {\n hasSeed = true;\n seed = arguments[0];\n accumulator = arguments[1];\n } else {\n accumulator = arguments[0];\n }\n return new AnonymousObservable(function (o) {\n var hasAccumulation, accumulation, hasValue;\n return source.subscribe (\n function (x) {\n !hasValue && (hasValue = true);\n try {\n if (hasAccumulation) {\n accumulation = accumulator(accumulation, x);\n } else {\n accumulation = hasSeed ? accumulator(seed, x) : x;\n hasAccumulation = true;\n }\n } catch (e) {\n return o.onError(e);\n }\n },\n function (e) { o.onError(e); },\n function () {\n hasValue && o.onNext(accumulation);\n !hasValue && hasSeed && o.onNext(seed);\n !hasValue && !hasSeed && o.onError(new EmptyError());\n o.onCompleted();\n }\n );\n }, source);\n };\n\r\n var ReduceObservable = (function(__super__) {\n inherits(ReduceObservable, __super__);\n function ReduceObservable(source, acc, hasSeed, seed) {\n this.source = source;\n this.acc = acc;\n this.hasSeed = hasSeed;\n this.seed = seed;\n __super__.call(this);\n }\n\n ReduceObservable.prototype.subscribeCore = function(observer) {\n return this.source.subscribe(new InnerObserver(observer,this));\n };\n\n function InnerObserver(o, parent) {\n this.o = o;\n this.acc = parent.acc;\n this.hasSeed = parent.hasSeed;\n this.seed = parent.seed;\n this.hasAccumulation = false;\n this.result = null;\n this.hasValue = false;\n this.isStopped = false;\n }\n InnerObserver.prototype.onNext = function (x) {\n if (this.isStopped) { return; }\n !this.hasValue && (this.hasValue = true);\n if (this.hasAccumulation) {\n this.result = tryCatch(this.acc)(this.result, x);\n } else {\n this.result = this.hasSeed ? tryCatch(this.acc)(this.seed, x) : x;\n this.hasAccumulation = true;\n }\n if (this.result === errorObj) { this.o.onError(this.result.e); }\n };\n InnerObserver.prototype.onError = function (e) { \n if (!this.isStopped) { this.isStopped = true; this.o.onError(e); } \n };\n InnerObserver.prototype.onCompleted = function () {\n if (!this.isStopped) {\n this.isStopped = true;\n this.hasValue && this.o.onNext(this.result);\n !this.hasValue && this.hasSeed && this.o.onNext(this.seed);\n !this.hasValue && !this.hasSeed && this.o.onError(new EmptyError());\n this.o.onCompleted();\n }\n };\n InnerObserver.prototype.dispose = function () { this.isStopped = true; };\n InnerObserver.prototype.fail = function(e) {\n if (!this.isStopped) {\n this.isStopped = true;\n this.o.onError(e);\n return true;\n }\n return false;\n };\n\n return ReduceObservable;\n }(ObservableBase));\n\n /**\n * Applies an accumulator function over an observable sequence, returning the result of the aggregation as a single element in the result sequence. The specified seed value is used as the initial accumulator value.\n * For aggregation behavior with incremental intermediate results, see Observable.scan.\n * @param {Function} accumulator An accumulator function to be invoked on each element.\n * @param {Any} [seed] The initial accumulator value.\n * @returns {Observable} An observable sequence containing a single element with the final accumulator value.\n */\n observableProto.reduce = function (accumulator) {\n var hasSeed = false;\n if (arguments.length === 2) {\n hasSeed = true;\n var seed = arguments[1];\n }\n return new ReduceObservable(this, accumulator, hasSeed, seed);\n };\n\r\n /**\n * Determines whether any element of an observable sequence satisfies a condition if present, else if any items are in the sequence.\n * @param {Function} [predicate] A function to test each element for a condition.\n * @returns {Observable} An observable sequence containing a single element determining whether any elements in the source sequence pass the test in the specified predicate if given, else if any items are in the sequence.\n */\n observableProto.some = function (predicate, thisArg) {\n var source = this;\n return predicate ?\n source.filter(predicate, thisArg).some() :\n new AnonymousObservable(function (observer) {\n return source.subscribe(function () {\n observer.onNext(true);\n observer.onCompleted();\n }, function (e) { observer.onError(e); }, function () {\n observer.onNext(false);\n observer.onCompleted();\n });\n }, source);\n };\n\n /** @deprecated use #some instead */\n observableProto.any = function () {\n //deprecate('any', 'some');\n return this.some.apply(this, arguments);\n };\n\r\n /**\n * Determines whether an observable sequence is empty.\n * @returns {Observable} An observable sequence containing a single element determining whether the source sequence is empty.\n */\n observableProto.isEmpty = function () {\n return this.any().map(not);\n };\n\r\n /**\n * Determines whether all elements of an observable sequence satisfy a condition.\n * @param {Function} [predicate] A function to test each element for a condition.\n * @param {Any} [thisArg] Object to use as this when executing callback.\n * @returns {Observable} An observable sequence containing a single element determining whether all elements in the source sequence pass the test in the specified predicate.\n */\n observableProto.every = function (predicate, thisArg) {\n return this.filter(function (v) { return !predicate(v); }, thisArg).some().map(not);\n };\n\n /** @deprecated use #every instead */\n observableProto.all = function () {\n //deprecate('all', 'every');\n return this.every.apply(this, arguments);\n };\n\r\n /**\n * Determines whether an observable sequence includes a specified element with an optional equality comparer.\n * @param searchElement The value to locate in the source sequence.\n * @param {Number} [fromIndex] An equality comparer to compare elements.\n * @returns {Observable} An observable sequence containing a single element determining whether the source sequence includes an element that has the specified value from the given index.\n */\n observableProto.includes = function (searchElement, fromIndex) {\n var source = this;\n function comparer(a, b) {\n return (a === 0 && b === 0) || (a === b || (isNaN(a) && isNaN(b)));\n }\n return new AnonymousObservable(function (o) {\n var i = 0, n = +fromIndex || 0;\n Math.abs(n) === Infinity && (n = 0);\n if (n < 0) {\n o.onNext(false);\n o.onCompleted();\n return disposableEmpty;\n }\n return source.subscribe(\n function (x) {\n if (i++ >= n && comparer(x, searchElement)) {\n o.onNext(true);\n o.onCompleted();\n }\n },\n function (e) { o.onError(e); },\n function () {\n o.onNext(false);\n o.onCompleted();\n });\n }, this);\n };\n\n /**\n * @deprecated use #includes instead.\n */\n observableProto.contains = function (searchElement, fromIndex) {\n //deprecate('contains', 'includes');\n observableProto.includes(searchElement, fromIndex);\n };\n\r\n /**\n * Returns an observable sequence containing a value that represents how many elements in the specified observable sequence satisfy a condition if provided, else the count of items.\n * @example\n * res = source.count();\n * res = source.count(function (x) { return x > 3; });\n * @param {Function} [predicate]A function to test each element for a condition.\n * @param {Any} [thisArg] Object to use as this when executing callback.\n * @returns {Observable} An observable sequence containing a single element with a number that represents how many elements in the input sequence satisfy the condition in the predicate function if provided, else the count of items in the sequence.\n */\n observableProto.count = function (predicate, thisArg) {\n return predicate ?\n this.filter(predicate, thisArg).count() :\n this.reduce(function (count) { return count + 1; }, 0);\n };\n\r\n /**\n * Returns the first index at which a given element can be found in the observable sequence, or -1 if it is not present.\n * @param {Any} searchElement Element to locate in the array.\n * @param {Number} [fromIndex] The index to start the search. If not specified, defaults to 0.\n * @returns {Observable} And observable sequence containing the first index at which a given element can be found in the observable sequence, or -1 if it is not present.\n */\n observableProto.indexOf = function(searchElement, fromIndex) {\n var source = this;\n return new AnonymousObservable(function (o) {\n var i = 0, n = +fromIndex || 0;\n Math.abs(n) === Infinity && (n = 0);\n if (n < 0) {\n o.onNext(-1);\n o.onCompleted();\n return disposableEmpty;\n }\n return source.subscribe(\n function (x) {\n if (i >= n && x === searchElement) {\n o.onNext(i);\n o.onCompleted();\n }\n i++;\n },\n function (e) { o.onError(e); },\n function () {\n o.onNext(-1);\n o.onCompleted();\n });\n }, source);\n };\n\r\n /**\n * Computes the sum of a sequence of values that are obtained by invoking an optional transform function on each element of the input sequence, else if not specified computes the sum on each item in the sequence.\n * @param {Function} [selector] A transform function to apply to each element.\n * @param {Any} [thisArg] Object to use as this when executing callback.\n * @returns {Observable} An observable sequence containing a single element with the sum of the values in the source sequence.\n */\n observableProto.sum = function (keySelector, thisArg) {\n return keySelector && isFunction(keySelector) ?\n this.map(keySelector, thisArg).sum() :\n this.reduce(function (prev, curr) { return prev + curr; }, 0);\n };\n\r\n /**\n * Returns the elements in an observable sequence with the minimum key value according to the specified comparer.\n * @example\n * var res = source.minBy(function (x) { return x.value; });\n * var res = source.minBy(function (x) { return x.value; }, function (x, y) { return x - y; });\n * @param {Function} keySelector Key selector function.\n * @param {Function} [comparer] Comparer used to compare key values.\n * @returns {Observable} An observable sequence containing a list of zero or more elements that have a minimum key value.\n */\n observableProto.minBy = function (keySelector, comparer) {\n comparer || (comparer = defaultSubComparer);\n return extremaBy(this, keySelector, function (x, y) { return comparer(x, y) * -1; });\n };\n\r\n /**\n * Returns the minimum element in an observable sequence according to the optional comparer else a default greater than less than check.\n * @example\n * var res = source.min();\n * var res = source.min(function (x, y) { return x.value - y.value; });\n * @param {Function} [comparer] Comparer used to compare elements.\n * @returns {Observable} An observable sequence containing a single element with the minimum element in the source sequence.\n */\n observableProto.min = function (comparer) {\n return this.minBy(identity, comparer).map(function (x) { return firstOnly(x); });\n };\n\r\n /**\n * Returns the elements in an observable sequence with the maximum key value according to the specified comparer.\n * @example\n * var res = source.maxBy(function (x) { return x.value; });\n * var res = source.maxBy(function (x) { return x.value; }, function (x, y) { return x - y;; });\n * @param {Function} keySelector Key selector function.\n * @param {Function} [comparer] Comparer used to compare key values.\n * @returns {Observable} An observable sequence containing a list of zero or more elements that have a maximum key value.\n */\n observableProto.maxBy = function (keySelector, comparer) {\n comparer || (comparer = defaultSubComparer);\n return extremaBy(this, keySelector, comparer);\n };\n\r\n /**\n * Returns the maximum value in an observable sequence according to the specified comparer.\n * @example\n * var res = source.max();\n * var res = source.max(function (x, y) { return x.value - y.value; });\n * @param {Function} [comparer] Comparer used to compare elements.\n * @returns {Observable} An observable sequence containing a single element with the maximum element in the source sequence.\n */\n observableProto.max = function (comparer) {\n return this.maxBy(identity, comparer).map(function (x) { return firstOnly(x); });\n };\n\r\n /**\n * Computes the average of an observable sequence of values that are in the sequence or obtained by invoking a transform function on each element of the input sequence if present.\n * @param {Function} [selector] A transform function to apply to each element.\n * @param {Any} [thisArg] Object to use as this when executing callback.\n * @returns {Observable} An observable sequence containing a single element with the average of the sequence of values.\n */\n observableProto.average = function (keySelector, thisArg) {\n return keySelector && isFunction(keySelector) ?\n this.map(keySelector, thisArg).average() :\n this.reduce(function (prev, cur) {\n return {\n sum: prev.sum + cur,\n count: prev.count + 1\n };\n }, {sum: 0, count: 0 }).map(function (s) {\n if (s.count === 0) { throw new EmptyError(); }\n return s.sum / s.count;\n });\n };\n\r\n /**\n * Determines whether two sequences are equal by comparing the elements pairwise using a specified equality comparer.\n *\n * @example\n * var res = res = source.sequenceEqual([1,2,3]);\n * var res = res = source.sequenceEqual([{ value: 42 }], function (x, y) { return x.value === y.value; });\n * 3 - res = source.sequenceEqual(Rx.Observable.returnValue(42));\n * 4 - res = source.sequenceEqual(Rx.Observable.returnValue({ value: 42 }), function (x, y) { return x.value === y.value; });\n * @param {Observable} second Second observable sequence or array to compare.\n * @param {Function} [comparer] Comparer used to compare elements of both sequences.\n * @returns {Observable} An observable sequence that contains a single element which indicates whether both sequences are of equal length and their corresponding elements are equal according to the specified equality comparer.\n */\n observableProto.sequenceEqual = function (second, comparer) {\n var first = this;\n comparer || (comparer = defaultComparer);\n return new AnonymousObservable(function (o) {\n var donel = false, doner = false, ql = [], qr = [];\n var subscription1 = first.subscribe(function (x) {\n var equal, v;\n if (qr.length > 0) {\n v = qr.shift();\n try {\n equal = comparer(v, x);\n } catch (e) {\n o.onError(e);\n return;\n }\n if (!equal) {\n o.onNext(false);\n o.onCompleted();\n }\n } else if (doner) {\n o.onNext(false);\n o.onCompleted();\n } else {\n ql.push(x);\n }\n }, function(e) { o.onError(e); }, function () {\n donel = true;\n if (ql.length === 0) {\n if (qr.length > 0) {\n o.onNext(false);\n o.onCompleted();\n } else if (doner) {\n o.onNext(true);\n o.onCompleted();\n }\n }\n });\n\n (isArrayLike(second) || isIterable(second)) && (second = observableFrom(second));\n isPromise(second) && (second = observableFromPromise(second));\n var subscription2 = second.subscribe(function (x) {\n var equal;\n if (ql.length > 0) {\n var v = ql.shift();\n try {\n equal = comparer(v, x);\n } catch (exception) {\n o.onError(exception);\n return;\n }\n if (!equal) {\n o.onNext(false);\n o.onCompleted();\n }\n } else if (donel) {\n o.onNext(false);\n o.onCompleted();\n } else {\n qr.push(x);\n }\n }, function(e) { o.onError(e); }, function () {\n doner = true;\n if (qr.length === 0) {\n if (ql.length > 0) {\n o.onNext(false);\n o.onCompleted();\n } else if (donel) {\n o.onNext(true);\n o.onCompleted();\n }\n }\n });\n return new CompositeDisposable(subscription1, subscription2);\n }, first);\n };\n\r\n function elementAtOrDefault(source, index, hasDefault, defaultValue) {\n if (index < 0) { throw new ArgumentOutOfRangeError(); }\n return new AnonymousObservable(function (o) {\n var i = index;\n return source.subscribe(function (x) {\n if (i-- === 0) {\n o.onNext(x);\n o.onCompleted();\n }\n }, function (e) { o.onError(e); }, function () {\n if (!hasDefault) {\n o.onError(new ArgumentOutOfRangeError());\n } else {\n o.onNext(defaultValue);\n o.onCompleted();\n }\n });\n }, source);\n }\n\r\n /**\n * Returns the element at a specified index in a sequence.\n * @example\n * var res = source.elementAt(5);\n * @param {Number} index The zero-based index of the element to retrieve.\n * @returns {Observable} An observable sequence that produces the element at the specified position in the source sequence.\n */\n observableProto.elementAt = function (index) {\n return elementAtOrDefault(this, index, false);\n };\n\r\n /**\n * Returns the element at a specified index in a sequence or a default value if the index is out of range.\n * @example\n * var res = source.elementAtOrDefault(5);\n * var res = source.elementAtOrDefault(5, 0);\n * @param {Number} index The zero-based index of the element to retrieve.\n * @param [defaultValue] The default value if the index is outside the bounds of the source sequence.\n * @returns {Observable} An observable sequence that produces the element at the specified position in the source sequence, or a default value if the index is outside the bounds of the source sequence.\n */\n observableProto.elementAtOrDefault = function (index, defaultValue) {\n return elementAtOrDefault(this, index, true, defaultValue);\n };\n\r\n function singleOrDefaultAsync(source, hasDefault, defaultValue) {\n return new AnonymousObservable(function (o) {\n var value = defaultValue, seenValue = false;\n return source.subscribe(function (x) {\n if (seenValue) {\n o.onError(new Error('Sequence contains more than one element'));\n } else {\n value = x;\n seenValue = true;\n }\n }, function (e) { o.onError(e); }, function () {\n if (!seenValue && !hasDefault) {\n o.onError(new EmptyError());\n } else {\n o.onNext(value);\n o.onCompleted();\n }\n });\n }, source);\n }\n\r\n /**\n * Returns the only element of an observable sequence that satisfies the condition in the optional predicate, and reports an exception if there is not exactly one element in the observable sequence.\n * @param {Function} [predicate] A predicate function to evaluate for elements in the source sequence.\n * @param {Any} [thisArg] Object to use as `this` when executing the predicate.\n * @returns {Observable} Sequence containing the single element in the observable sequence that satisfies the condition in the predicate.\n */\n observableProto.single = function (predicate, thisArg) {\n return predicate && isFunction(predicate) ?\n this.where(predicate, thisArg).single() :\n singleOrDefaultAsync(this, false);\n };\n\r\n /**\n * Returns the only element of an observable sequence that matches the predicate, or a default value if no such element exists; this method reports an exception if there is more than one element in the observable sequence.\n * @example\n * var res = res = source.singleOrDefault();\n * var res = res = source.singleOrDefault(function (x) { return x === 42; });\n * res = source.singleOrDefault(function (x) { return x === 42; }, 0);\n * res = source.singleOrDefault(null, 0);\n * @memberOf Observable#\n * @param {Function} predicate A predicate function to evaluate for elements in the source sequence.\n * @param [defaultValue] The default value if the index is outside the bounds of the source sequence.\n * @param {Any} [thisArg] Object to use as `this` when executing the predicate.\n * @returns {Observable} Sequence containing the single element in the observable sequence that satisfies the condition in the predicate, or a default value if no such element exists.\n */\n observableProto.singleOrDefault = function (predicate, defaultValue, thisArg) {\n return predicate && isFunction(predicate) ?\n this.filter(predicate, thisArg).singleOrDefault(null, defaultValue) :\n singleOrDefaultAsync(this, true, defaultValue);\n };\n\r\n function firstOrDefaultAsync(source, hasDefault, defaultValue) {\n return new AnonymousObservable(function (o) {\n return source.subscribe(function (x) {\n o.onNext(x);\n o.onCompleted();\n }, function (e) { o.onError(e); }, function () {\n if (!hasDefault) {\n o.onError(new EmptyError());\n } else {\n o.onNext(defaultValue);\n o.onCompleted();\n }\n });\n }, source);\n }\n\r\n /**\n * Returns the first element of an observable sequence that satisfies the condition in the predicate if present else the first item in the sequence.\n * @example\n * var res = res = source.first();\n * var res = res = source.first(function (x) { return x > 3; });\n * @param {Function} [predicate] A predicate function to evaluate for elements in the source sequence.\n * @param {Any} [thisArg] Object to use as `this` when executing the predicate.\n * @returns {Observable} Sequence containing the first element in the observable sequence that satisfies the condition in the predicate if provided, else the first item in the sequence.\n */\n observableProto.first = function (predicate, thisArg) {\n return predicate ?\n this.where(predicate, thisArg).first() :\n firstOrDefaultAsync(this, false);\n };\n\r\n /**\n * Returns the first element of an observable sequence that satisfies the condition in the predicate, or a default value if no such element exists.\n * @param {Function} [predicate] A predicate function to evaluate for elements in the source sequence.\n * @param {Any} [defaultValue] The default value if no such element exists. If not specified, defaults to null.\n * @param {Any} [thisArg] Object to use as `this` when executing the predicate.\n * @returns {Observable} Sequence containing the first element in the observable sequence that satisfies the condition in the predicate, or a default value if no such element exists.\n */\n observableProto.firstOrDefault = function (predicate, defaultValue, thisArg) {\n return predicate ?\n this.where(predicate).firstOrDefault(null, defaultValue) :\n firstOrDefaultAsync(this, true, defaultValue);\n };\n\r\n function lastOrDefaultAsync(source, hasDefault, defaultValue) {\n return new AnonymousObservable(function (o) {\n var value = defaultValue, seenValue = false;\n return source.subscribe(function (x) {\n value = x;\n seenValue = true;\n }, function (e) { o.onError(e); }, function () {\n if (!seenValue && !hasDefault) {\n o.onError(new EmptyError());\n } else {\n o.onNext(value);\n o.onCompleted();\n }\n });\n }, source);\n }\n\r\n /**\n * Returns the last element of an observable sequence that satisfies the condition in the predicate if specified, else the last element.\n * @param {Function} [predicate] A predicate function to evaluate for elements in the source sequence.\n * @param {Any} [thisArg] Object to use as `this` when executing the predicate.\n * @returns {Observable} Sequence containing the last element in the observable sequence that satisfies the condition in the predicate.\n */\n observableProto.last = function (predicate, thisArg) {\n return predicate ?\n this.where(predicate, thisArg).last() :\n lastOrDefaultAsync(this, false);\n };\n\r\n /**\n * Returns the last element of an observable sequence that satisfies the condition in the predicate, or a default value if no such element exists.\n * @param {Function} [predicate] A predicate function to evaluate for elements in the source sequence.\n * @param [defaultValue] The default value if no such element exists. If not specified, defaults to null.\n * @param {Any} [thisArg] Object to use as `this` when executing the predicate.\n * @returns {Observable} Sequence containing the last element in the observable sequence that satisfies the condition in the predicate, or a default value if no such element exists.\n */\n observableProto.lastOrDefault = function (predicate, defaultValue, thisArg) {\n return predicate ?\n this.where(predicate, thisArg).lastOrDefault(null, defaultValue) :\n lastOrDefaultAsync(this, true, defaultValue);\n };\n\r\n function findValue (source, predicate, thisArg, yieldIndex) {\n var callback = bindCallback(predicate, thisArg, 3);\n return new AnonymousObservable(function (o) {\n var i = 0;\n return source.subscribe(function (x) {\n var shouldRun;\n try {\n shouldRun = callback(x, i, source);\n } catch (e) {\n o.onError(e);\n return;\n }\n if (shouldRun) {\n o.onNext(yieldIndex ? i : x);\n o.onCompleted();\n } else {\n i++;\n }\n }, function (e) { o.onError(e); }, function () {\n o.onNext(yieldIndex ? -1 : undefined);\n o.onCompleted();\n });\n }, source);\n }\n\r\n /**\n * Searches for an element that matches the conditions defined by the specified predicate, and returns the first occurrence within the entire Observable sequence.\n * @param {Function} predicate The predicate that defines the conditions of the element to search for.\n * @param {Any} [thisArg] Object to use as `this` when executing the predicate.\n * @returns {Observable} An Observable sequence with the first element that matches the conditions defined by the specified predicate, if found; otherwise, undefined.\n */\n observableProto.find = function (predicate, thisArg) {\n return findValue(this, predicate, thisArg, false);\n };\n\r\n /**\n * Searches for an element that matches the conditions defined by the specified predicate, and returns\n * an Observable sequence with the zero-based index of the first occurrence within the entire Observable sequence.\n * @param {Function} predicate The predicate that defines the conditions of the element to search for.\n * @param {Any} [thisArg] Object to use as `this` when executing the predicate.\n * @returns {Observable} An Observable sequence with the zero-based index of the first occurrence of an element that matches the conditions defined by match, if found; otherwise, –1.\n */\n observableProto.findIndex = function (predicate, thisArg) {\n return findValue(this, predicate, thisArg, true);\n };\n\r\n /**\n * Converts the observable sequence to a Set if it exists.\n * @returns {Observable} An observable sequence with a single value of a Set containing the values from the observable sequence.\n */\n observableProto.toSet = function () {\n if (typeof root.Set === 'undefined') { throw new TypeError(); }\n var source = this;\n return new AnonymousObservable(function (o) {\n var s = new root.Set();\n return source.subscribe(\n function (x) { s.add(x); },\n function (e) { o.onError(e); },\n function () {\n o.onNext(s);\n o.onCompleted();\n });\n }, source);\n };\n\r\n /**\n * Converts the observable sequence to a Map if it exists.\n * @param {Function} keySelector A function which produces the key for the Map.\n * @param {Function} [elementSelector] An optional function which produces the element for the Map. If not present, defaults to the value from the observable sequence.\n * @returns {Observable} An observable sequence with a single value of a Map containing the values from the observable sequence.\n */\n observableProto.toMap = function (keySelector, elementSelector) {\n if (typeof root.Map === 'undefined') { throw new TypeError(); }\n var source = this;\n return new AnonymousObservable(function (o) {\n var m = new root.Map();\n return source.subscribe(\n function (x) {\n var key;\n try {\n key = keySelector(x);\n } catch (e) {\n o.onError(e);\n return;\n }\n\n var element = x;\n if (elementSelector) {\n try {\n element = elementSelector(x);\n } catch (e) {\n o.onError(e);\n return;\n }\n }\n\n m.set(key, element);\n },\n function (e) { o.onError(e); },\n function () {\n o.onNext(m);\n o.onCompleted();\n });\n }, source);\n };\n\r\n var fnString = 'function',\n throwString = 'throw',\n isObject = Rx.internals.isObject;\n\n function toThunk(obj, ctx) {\n if (Array.isArray(obj)) { return objectToThunk.call(ctx, obj); }\n if (isGeneratorFunction(obj)) { return observableSpawn(obj.call(ctx)); }\n if (isGenerator(obj)) { return observableSpawn(obj); }\n if (isObservable(obj)) { return observableToThunk(obj); }\n if (isPromise(obj)) { return promiseToThunk(obj); }\n if (typeof obj === fnString) { return obj; }\n if (isObject(obj) || Array.isArray(obj)) { return objectToThunk.call(ctx, obj); }\n\n return obj;\n }\n\n function objectToThunk(obj) {\n var ctx = this;\n\n return function (done) {\n var keys = Object.keys(obj),\n pending = keys.length,\n results = new obj.constructor(),\n finished;\n\n if (!pending) {\n timeoutScheduler.schedule(function () { done(null, results); });\n return;\n }\n\n for (var i = 0, len = keys.length; i < len; i++) {\n run(obj[keys[i]], keys[i]);\n }\n\n function run(fn, key) {\n if (finished) { return; }\n try {\n fn = toThunk(fn, ctx);\n\n if (typeof fn !== fnString) {\n results[key] = fn;\n return --pending || done(null, results);\n }\n\n fn.call(ctx, function(err, res) {\n if (finished) { return; }\n\n if (err) {\n finished = true;\n return done(err);\n }\n\n results[key] = res;\n --pending || done(null, results);\n });\n } catch (e) {\n finished = true;\n done(e);\n }\n }\n }\n }\n\n function observableToThunk(observable) {\n return function (fn) {\n var value, hasValue = false;\n observable.subscribe(\n function (v) {\n value = v;\n hasValue = true;\n },\n fn,\n function () {\n hasValue && fn(null, value);\n });\n }\n }\n\n function promiseToThunk(promise) {\n return function(fn) {\n promise.then(function(res) {\n fn(null, res);\n }, fn);\n }\n }\n\n function isObservable(obj) {\n return obj && typeof obj.subscribe === fnString;\n }\n\n function isGeneratorFunction(obj) {\n return obj && obj.constructor && obj.constructor.name === 'GeneratorFunction';\n }\n\n function isGenerator(obj) {\n return obj && typeof obj.next === fnString && typeof obj[throwString] === fnString;\n }\n\n /*\n * Spawns a generator function which allows for Promises, Observable sequences, Arrays, Objects, Generators and functions.\n * @param {Function} The spawning function.\n * @returns {Function} a function which has a done continuation.\n */\n var observableSpawn = Rx.spawn = function (fn) {\n var isGenFun = isGeneratorFunction(fn);\n\n return function (done) {\n var ctx = this,\n gen = fn;\n\n if (isGenFun) {\n for(var args = [], i = 0, len = arguments.length; i < len; i++) { args.push(arguments[i]); }\n var len = args.length,\n hasCallback = len && typeof args[len - 1] === fnString;\n\n done = hasCallback ? args.pop() : handleError;\n gen = fn.apply(this, args);\n } else {\n done = done || handleError;\n }\n\n next();\n\n function exit(err, res) {\n timeoutScheduler.schedule(done.bind(ctx, err, res));\n }\n\n function next(err, res) {\n var ret;\n\n // multiple args\n if (arguments.length > 2) {\n for(var res = [], i = 1, len = arguments.length; i < len; i++) { res.push(arguments[i]); }\n }\n\n if (err) {\n try {\n ret = gen[throwString](err);\n } catch (e) {\n return exit(e);\n }\n }\n\n if (!err) {\n try {\n ret = gen.next(res);\n } catch (e) {\n return exit(e);\n }\n }\n\n if (ret.done) {\n return exit(null, ret.value);\n }\n\n ret.value = toThunk(ret.value, ctx);\n\n if (typeof ret.value === fnString) {\n var called = false;\n try {\n ret.value.call(ctx, function() {\n if (called) {\n return;\n }\n\n called = true;\n next.apply(ctx, arguments);\n });\n } catch (e) {\n timeoutScheduler.schedule(function () {\n if (called) {\n return;\n }\n\n called = true;\n next.call(ctx, e);\n });\n }\n return;\n }\n\n // Not supported\n next(new TypeError('Rx.spawn only supports a function, Promise, Observable, Object or Array.'));\n }\n }\n };\n\n function handleError(err) {\n if (!err) { return; }\n timeoutScheduler.schedule(function() {\n throw err;\n });\n }\n\r\n /**\n * Invokes the specified function asynchronously on the specified scheduler, surfacing the result through an observable sequence.\n *\n * @example\n * var res = Rx.Observable.start(function () { console.log('hello'); });\n * var res = Rx.Observable.start(function () { console.log('hello'); }, Rx.Scheduler.timeout);\n * var res = Rx.Observable.start(function () { this.log('hello'); }, Rx.Scheduler.timeout, console);\n *\n * @param {Function} func Function to run asynchronously.\n * @param {Scheduler} [scheduler] Scheduler to run the function on. If not specified, defaults to Scheduler.timeout.\n * @param [context] The context for the func parameter to be executed. If not specified, defaults to undefined.\n * @returns {Observable} An observable sequence exposing the function's result value, or an exception.\n *\n * Remarks\n * * The function is called immediately, not during the subscription of the resulting sequence.\n * * Multiple subscriptions to the resulting sequence can observe the function's result.\n */\n Observable.start = function (func, context, scheduler) {\n return observableToAsync(func, context, scheduler)();\n };\n\r\n /**\n * Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function on the specified scheduler.\n * @param {Function} function Function to convert to an asynchronous function.\n * @param {Scheduler} [scheduler] Scheduler to run the function on. If not specified, defaults to Scheduler.timeout.\n * @param {Mixed} [context] The context for the func parameter to be executed. If not specified, defaults to undefined.\n * @returns {Function} Asynchronous function.\n */\n var observableToAsync = Observable.toAsync = function (func, context, scheduler) {\n isScheduler(scheduler) || (scheduler = timeoutScheduler);\n return function () {\n var args = arguments,\n subject = new AsyncSubject();\n\n scheduler.schedule(function () {\n var result;\n try {\n result = func.apply(context, args);\n } catch (e) {\n subject.onError(e);\n return;\n }\n subject.onNext(result);\n subject.onCompleted();\n });\n return subject.asObservable();\n };\n };\n\r\n /**\n * Converts a callback function to an observable sequence.\n *\n * @param {Function} function Function with a callback as the last parameter to convert to an Observable sequence.\n * @param {Mixed} [context] The context for the func parameter to be executed. If not specified, defaults to undefined.\n * @param {Function} [selector] A selector which takes the arguments from the callback to produce a single item to yield on next.\n * @returns {Function} A function, when executed with the required parameters minus the callback, produces an Observable sequence with a single value of the arguments to the callback as an array.\n */\n Observable.fromCallback = function (func, context, selector) {\n return function () {\n var len = arguments.length, args = new Array(len)\n for(var i = 0; i < len; i++) { args[i] = arguments[i]; }\n\n return new AnonymousObservable(function (observer) {\n function handler() {\n var len = arguments.length, results = new Array(len);\n for(var i = 0; i < len; i++) { results[i] = arguments[i]; }\n\n if (selector) {\n try {\n results = selector.apply(context, results);\n } catch (e) {\n return observer.onError(e);\n }\n\n observer.onNext(results);\n } else {\n if (results.length <= 1) {\n observer.onNext.apply(observer, results);\n } else {\n observer.onNext(results);\n }\n }\n\n observer.onCompleted();\n }\n\n args.push(handler);\n func.apply(context, args);\n }).publishLast().refCount();\n };\n };\n\r\n /**\n * Converts a Node.js callback style function to an observable sequence. This must be in function (err, ...) format.\n * @param {Function} func The function to call\n * @param {Mixed} [context] The context for the func parameter to be executed. If not specified, defaults to undefined.\n * @param {Function} [selector] A selector which takes the arguments from the callback minus the error to produce a single item to yield on next.\n * @returns {Function} An async function which when applied, returns an observable sequence with the callback arguments as an array.\n */\n Observable.fromNodeCallback = function (func, context, selector) {\n return function () {\n var len = arguments.length, args = new Array(len);\n for(var i = 0; i < len; i++) { args[i] = arguments[i]; }\n\n return new AnonymousObservable(function (observer) {\n function handler(err) {\n if (err) {\n observer.onError(err);\n return;\n }\n\n var len = arguments.length, results = [];\n for(var i = 1; i < len; i++) { results[i - 1] = arguments[i]; }\n\n if (selector) {\n try {\n results = selector.apply(context, results);\n } catch (e) {\n return observer.onError(e);\n }\n observer.onNext(results);\n } else {\n if (results.length <= 1) {\n observer.onNext.apply(observer, results);\n } else {\n observer.onNext(results);\n }\n }\n\n observer.onCompleted();\n }\n\n args.push(handler);\n func.apply(context, args);\n }).publishLast().refCount();\n };\n };\n\r\n function createListener (element, name, handler) {\n if (element.addEventListener) {\n element.addEventListener(name, handler, false);\n return disposableCreate(function () {\n element.removeEventListener(name, handler, false);\n });\n }\n throw new Error('No listener found');\n }\n\n function createEventListener (el, eventName, handler) {\n var disposables = new CompositeDisposable();\n\n // Asume NodeList or HTMLCollection\n var toStr = Object.prototype.toString;\n if (toStr.call(el) === '[object NodeList]' || toStr.call(el) === '[object HTMLCollection]') {\n for (var i = 0, len = el.length; i < len; i++) {\n disposables.add(createEventListener(el.item(i), eventName, handler));\n }\n } else if (el) {\n disposables.add(createListener(el, eventName, handler));\n }\n\n return disposables;\n }\n\n /**\n * Configuration option to determine whether to use native events only\n */\n Rx.config.useNativeEvents = false;\n\n /**\n * Creates an observable sequence by adding an event listener to the matching DOMElement or each item in the NodeList.\n *\n * @example\n * var source = Rx.Observable.fromEvent(element, 'mouseup');\n *\n * @param {Object} element The DOMElement or NodeList to attach a listener.\n * @param {String} eventName The event name to attach the observable sequence.\n * @param {Function} [selector] A selector which takes the arguments from the event handler to produce a single item to yield on next.\n * @returns {Observable} An observable sequence of events from the specified element and the specified event.\n */\n Observable.fromEvent = function (element, eventName, selector) {\n // Node.js specific\n if (element.addListener) {\n return fromEventPattern(\n function (h) { element.addListener(eventName, h); },\n function (h) { element.removeListener(eventName, h); },\n selector);\n }\n\n // Use only if non-native events are allowed\n if (!Rx.config.useNativeEvents) {\n // Handles jq, Angular.js, Zepto, Marionette, Ember.js\n if (typeof element.on === 'function' && typeof element.off === 'function') {\n return fromEventPattern(\n function (h) { element.on(eventName, h); },\n function (h) { element.off(eventName, h); },\n selector);\n }\n }\n return new AnonymousObservable(function (observer) {\n return createEventListener(\n element,\n eventName,\n function handler (e) {\n var results = e;\n\n if (selector) {\n try {\n results = selector(arguments);\n } catch (err) {\n return observer.onError(err);\n }\n }\n\n observer.onNext(results);\n });\n }).publish().refCount();\n };\n\r\n /**\n * Creates an observable sequence from an event emitter via an addHandler/removeHandler pair.\n * @param {Function} addHandler The function to add a handler to the emitter.\n * @param {Function} [removeHandler] The optional function to remove a handler from an emitter.\n * @param {Function} [selector] A selector which takes the arguments from the event handler to produce a single item to yield on next.\n * @returns {Observable} An observable sequence which wraps an event from an event emitter\n */\n var fromEventPattern = Observable.fromEventPattern = function (addHandler, removeHandler, selector) {\n return new AnonymousObservable(function (observer) {\n function innerHandler (e) {\n var result = e;\n if (selector) {\n try {\n result = selector(arguments);\n } catch (err) {\n return observer.onError(err);\n }\n }\n observer.onNext(result);\n }\n\n var returnValue = addHandler(innerHandler);\n return disposableCreate(function () {\n if (removeHandler) {\n removeHandler(innerHandler, returnValue);\n }\n });\n }).publish().refCount();\n };\n\r\n /**\n * Invokes the asynchronous function, surfacing the result through an observable sequence.\n * @param {Function} functionAsync Asynchronous function which returns a Promise to run.\n * @returns {Observable} An observable sequence exposing the function's result value, or an exception.\n */\n Observable.startAsync = function (functionAsync) {\n var promise;\n try {\n promise = functionAsync();\n } catch (e) {\n return observableThrow(e);\n }\n return observableFromPromise(promise);\n }\n\r\n var PausableObservable = (function (__super__) {\n\n inherits(PausableObservable, __super__);\n\n function subscribe(observer) {\n var conn = this.source.publish(),\n subscription = conn.subscribe(observer),\n connection = disposableEmpty;\n\n var pausable = this.pauser.distinctUntilChanged().subscribe(function (b) {\n if (b) {\n connection = conn.connect();\n } else {\n connection.dispose();\n connection = disposableEmpty;\n }\n });\n\n return new CompositeDisposable(subscription, connection, pausable);\n }\n\n function PausableObservable(source, pauser) {\n this.source = source;\n this.controller = new Subject();\n\n if (pauser && pauser.subscribe) {\n this.pauser = this.controller.merge(pauser);\n } else {\n this.pauser = this.controller;\n }\n\n __super__.call(this, subscribe, source);\n }\n\n PausableObservable.prototype.pause = function () {\n this.controller.onNext(false);\n };\n\n PausableObservable.prototype.resume = function () {\n this.controller.onNext(true);\n };\n\n return PausableObservable;\n\n }(Observable));\n\n /**\n * Pauses the underlying observable sequence based upon the observable sequence which yields true/false.\n * @example\n * var pauser = new Rx.Subject();\n * var source = Rx.Observable.interval(100).pausable(pauser);\n * @param {Observable} pauser The observable sequence used to pause the underlying sequence.\n * @returns {Observable} The observable sequence which is paused based upon the pauser.\n */\n observableProto.pausable = function (pauser) {\n return new PausableObservable(this, pauser);\n };\n\r\n function combineLatestSource(source, subject, resultSelector) {\n return new AnonymousObservable(function (o) {\n var hasValue = [false, false],\n hasValueAll = false,\n isDone = false,\n values = new Array(2),\n err;\n\n function next(x, i) {\n values[i] = x\n hasValue[i] = true;\n if (hasValueAll || (hasValueAll = hasValue.every(identity))) {\n if (err) { return o.onError(err); }\n var res = tryCatch(resultSelector).apply(null, values);\n if (res === errorObj) { return o.onError(res.e); }\n o.onNext(res);\n }\n isDone && values[1] && o.onCompleted();\n }\n\n return new CompositeDisposable(\n source.subscribe(\n function (x) {\n next(x, 0);\n },\n function (e) {\n if (values[1]) {\n o.onError(e);\n } else {\n err = e;\n }\n },\n function () {\n isDone = true;\n values[1] && o.onCompleted();\n }),\n subject.subscribe(\n function (x) {\n next(x, 1);\n },\n function (e) { o.onError(e); },\n function () {\n isDone = true;\n next(true, 1);\n })\n );\n }, source);\n }\n\n var PausableBufferedObservable = (function (__super__) {\n\n inherits(PausableBufferedObservable, __super__);\n\n function subscribe(o) {\n var q = [], previousShouldFire;\n\n function drainQueue() { while (q.length > 0) { o.onNext(q.shift()); } }\n\n var subscription =\n combineLatestSource(\n this.source,\n this.pauser.distinctUntilChanged().startWith(false),\n function (data, shouldFire) {\n return { data: data, shouldFire: shouldFire };\n })\n .subscribe(\n function (results) {\n if (previousShouldFire !== undefined && results.shouldFire != previousShouldFire) {\n previousShouldFire = results.shouldFire;\n // change in shouldFire\n if (results.shouldFire) { drainQueue(); }\n } else {\n previousShouldFire = results.shouldFire;\n // new data\n if (results.shouldFire) {\n o.onNext(results.data);\n } else {\n q.push(results.data);\n }\n }\n },\n function (err) {\n drainQueue();\n o.onError(err);\n },\n function () {\n drainQueue();\n o.onCompleted();\n }\n );\n return subscription;\n }\n\n function PausableBufferedObservable(source, pauser) {\n this.source = source;\n this.controller = new Subject();\n\n if (pauser && pauser.subscribe) {\n this.pauser = this.controller.merge(pauser);\n } else {\n this.pauser = this.controller;\n }\n\n __super__.call(this, subscribe, source);\n }\n\n PausableBufferedObservable.prototype.pause = function () {\n this.controller.onNext(false);\n };\n\n PausableBufferedObservable.prototype.resume = function () {\n this.controller.onNext(true);\n };\n\n return PausableBufferedObservable;\n\n }(Observable));\n\n /**\n * Pauses the underlying observable sequence based upon the observable sequence which yields true/false,\n * and yields the values that were buffered while paused.\n * @example\n * var pauser = new Rx.Subject();\n * var source = Rx.Observable.interval(100).pausableBuffered(pauser);\n * @param {Observable} pauser The observable sequence used to pause the underlying sequence.\n * @returns {Observable} The observable sequence which is paused based upon the pauser.\n */\n observableProto.pausableBuffered = function (subject) {\n return new PausableBufferedObservable(this, subject);\n };\n\r\n var ControlledObservable = (function (__super__) {\n\n inherits(ControlledObservable, __super__);\n\n function subscribe (observer) {\n return this.source.subscribe(observer);\n }\n\n function ControlledObservable (source, enableQueue, scheduler) {\n __super__.call(this, subscribe, source);\n this.subject = new ControlledSubject(enableQueue, scheduler);\n this.source = source.multicast(this.subject).refCount();\n }\n\n ControlledObservable.prototype.request = function (numberOfItems) {\n return this.subject.request(numberOfItems == null ? -1 : numberOfItems);\n };\n\n return ControlledObservable;\n\n }(Observable));\n\n var ControlledSubject = (function (__super__) {\n\n function subscribe (observer) {\n return this.subject.subscribe(observer);\n }\n\n inherits(ControlledSubject, __super__);\n\n function ControlledSubject(enableQueue, scheduler) {\n enableQueue == null && (enableQueue = true);\n\n __super__.call(this, subscribe);\n this.subject = new Subject();\n this.enableQueue = enableQueue;\n this.queue = enableQueue ? [] : null;\n this.requestedCount = 0;\n this.requestedDisposable = disposableEmpty;\n this.error = null;\n this.hasFailed = false;\n this.hasCompleted = false;\n this.scheduler = scheduler || currentThreadScheduler;\n }\n\n addProperties(ControlledSubject.prototype, Observer, {\n onCompleted: function () {\n this.hasCompleted = true;\n if (!this.enableQueue || this.queue.length === 0) {\n this.subject.onCompleted();\n } else {\n this.queue.push(Notification.createOnCompleted());\n }\n },\n onError: function (error) {\n this.hasFailed = true;\n this.error = error;\n if (!this.enableQueue || this.queue.length === 0) {\n this.subject.onError(error);\n } else {\n this.queue.push(Notification.createOnError(error));\n }\n },\n onNext: function (value) {\n var hasRequested = false;\n\n if (this.requestedCount === 0) {\n this.enableQueue && this.queue.push(Notification.createOnNext(value));\n } else {\n (this.requestedCount !== -1 && this.requestedCount-- === 0) && this.disposeCurrentRequest();\n hasRequested = true;\n }\n hasRequested && this.subject.onNext(value);\n },\n _processRequest: function (numberOfItems) {\n if (this.enableQueue) {\n while ((this.queue.length >= numberOfItems && numberOfItems > 0) ||\n (this.queue.length > 0 && this.queue[0].kind !== 'N')) {\n var first = this.queue.shift();\n first.accept(this.subject);\n if (first.kind === 'N') {\n numberOfItems--;\n } else {\n this.disposeCurrentRequest();\n this.queue = [];\n }\n }\n\n return { numberOfItems : numberOfItems, returnValue: this.queue.length !== 0};\n }\n\n return { numberOfItems: numberOfItems, returnValue: false };\n },\n request: function (number) {\n this.disposeCurrentRequest();\n var self = this;\n\n this.requestedDisposable = this.scheduler.scheduleWithState(number,\n function(s, i) {\n var r = self._processRequest(i), remaining = r.numberOfItems;\n if (!r.returnValue) {\n self.requestedCount = remaining;\n self.requestedDisposable = disposableCreate(function () {\n self.requestedCount = 0;\n });\n }\n });\n\n return this.requestedDisposable;\n },\n disposeCurrentRequest: function () {\n this.requestedDisposable.dispose();\n this.requestedDisposable = disposableEmpty;\n }\n });\n\n return ControlledSubject;\n }(Observable));\n\n /**\n * Attaches a controller to the observable sequence with the ability to queue.\n * @example\n * var source = Rx.Observable.interval(100).controlled();\n * source.request(3); // Reads 3 values\n * @param {bool} enableQueue truthy value to determine if values should be queued pending the next request\n * @param {Scheduler} scheduler determines how the requests will be scheduled\n * @returns {Observable} The observable sequence which only propagates values on request.\n */\n observableProto.controlled = function (enableQueue, scheduler) {\n\n if (enableQueue && isScheduler(enableQueue)) {\n scheduler = enableQueue;\n enableQueue = true;\n }\n\n if (enableQueue == null) { enableQueue = true; }\n return new ControlledObservable(this, enableQueue, scheduler);\n };\n\r\n var StopAndWaitObservable = (function (__super__) {\n\n function subscribe (observer) {\n this.subscription = this.source.subscribe(new StopAndWaitObserver(observer, this, this.subscription));\n\n var self = this;\n timeoutScheduler.schedule(function () { self.source.request(1); });\n\n return this.subscription;\n }\n\n inherits(StopAndWaitObservable, __super__);\n\n function StopAndWaitObservable (source) {\n __super__.call(this, subscribe, source);\n this.source = source;\n }\n\n var StopAndWaitObserver = (function (__sub__) {\n\n inherits(StopAndWaitObserver, __sub__);\n\n function StopAndWaitObserver (observer, observable, cancel) {\n __sub__.call(this);\n this.observer = observer;\n this.observable = observable;\n this.cancel = cancel;\n }\n\n var stopAndWaitObserverProto = StopAndWaitObserver.prototype;\n\n stopAndWaitObserverProto.completed = function () {\n this.observer.onCompleted();\n this.dispose();\n };\n\n stopAndWaitObserverProto.error = function (error) {\n this.observer.onError(error);\n this.dispose();\n }\n\n stopAndWaitObserverProto.next = function (value) {\n this.observer.onNext(value);\n\n var self = this;\n timeoutScheduler.schedule(function () {\n self.observable.source.request(1);\n });\n };\n\n stopAndWaitObserverProto.dispose = function () {\n this.observer = null;\n if (this.cancel) {\n this.cancel.dispose();\n this.cancel = null;\n }\n __sub__.prototype.dispose.call(this);\n };\n\n return StopAndWaitObserver;\n }(AbstractObserver));\n\n return StopAndWaitObservable;\n }(Observable));\n\n\n /**\n * Attaches a stop and wait observable to the current observable.\n * @returns {Observable} A stop and wait observable.\n */\n ControlledObservable.prototype.stopAndWait = function () {\n return new StopAndWaitObservable(this);\n };\n\r\n var WindowedObservable = (function (__super__) {\n\n function subscribe (observer) {\n this.subscription = this.source.subscribe(new WindowedObserver(observer, this, this.subscription));\n\n var self = this;\n timeoutScheduler.schedule(function () {\n self.source.request(self.windowSize);\n });\n\n return this.subscription;\n }\n\n inherits(WindowedObservable, __super__);\n\n function WindowedObservable(source, windowSize) {\n __super__.call(this, subscribe, source);\n this.source = source;\n this.windowSize = windowSize;\n }\n\n var WindowedObserver = (function (__sub__) {\n\n inherits(WindowedObserver, __sub__);\n\n function WindowedObserver(observer, observable, cancel) {\n this.observer = observer;\n this.observable = observable;\n this.cancel = cancel;\n this.received = 0;\n }\n\n var windowedObserverPrototype = WindowedObserver.prototype;\n\n windowedObserverPrototype.completed = function () {\n this.observer.onCompleted();\n this.dispose();\n };\n\n windowedObserverPrototype.error = function (error) {\n this.observer.onError(error);\n this.dispose();\n };\n\n windowedObserverPrototype.next = function (value) {\n this.observer.onNext(value);\n\n this.received = ++this.received % this.observable.windowSize;\n if (this.received === 0) {\n var self = this;\n timeoutScheduler.schedule(function () {\n self.observable.source.request(self.observable.windowSize);\n });\n }\n };\n\n windowedObserverPrototype.dispose = function () {\n this.observer = null;\n if (this.cancel) {\n this.cancel.dispose();\n this.cancel = null;\n }\n __sub__.prototype.dispose.call(this);\n };\n\n return WindowedObserver;\n }(AbstractObserver));\n\n return WindowedObservable;\n }(Observable));\n\n /**\n * Creates a sliding windowed observable based upon the window size.\n * @param {Number} windowSize The number of items in the window\n * @returns {Observable} A windowed observable based upon the window size.\n */\n ControlledObservable.prototype.windowed = function (windowSize) {\n return new WindowedObservable(this, windowSize);\n };\n\r\n /**\n * Pipes the existing Observable sequence into a Node.js Stream.\n * @param {Stream} dest The destination Node.js stream.\n * @returns {Stream} The destination stream.\n */\n observableProto.pipe = function (dest) {\n var source = this.pausableBuffered();\n\n function onDrain() {\n source.resume();\n }\n\n dest.addListener('drain', onDrain);\n\n source.subscribe(\n function (x) {\n !dest.write(String(x)) && source.pause();\n },\n function (err) {\n dest.emit('error', err);\n },\n function () {\n // Hack check because STDIO is not closable\n !dest._isStdio && dest.end();\n dest.removeListener('drain', onDrain);\n });\n\n source.resume();\n\n return dest;\n };\n\r\n /**\n * Multicasts the source sequence notifications through an instantiated subject into all uses of the sequence within a selector function. Each\n * subscription to the resulting sequence causes a separate multicast invocation, exposing the sequence resulting from the selector function's\n * invocation. For specializations with fixed subject types, see Publish, PublishLast, and Replay.\n *\n * @example\n * 1 - res = source.multicast(observable);\n * 2 - res = source.multicast(function () { return new Subject(); }, function (x) { return x; });\n *\n * @param {Function|Subject} subjectOrSubjectSelector\n * Factory function to create an intermediate subject through which the source sequence's elements will be multicast to the selector function.\n * Or:\n * Subject to push source elements into.\n *\n * @param {Function} [selector] Optional selector function which can use the multicasted source sequence subject to the policies enforced by the created subject. Specified only if <paramref name=\"subjectOrSubjectSelector\" is a factory function.\n * @returns {Observable} An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.\n */\n observableProto.multicast = function (subjectOrSubjectSelector, selector) {\n var source = this;\n return typeof subjectOrSubjectSelector === 'function' ?\n new AnonymousObservable(function (observer) {\n var connectable = source.multicast(subjectOrSubjectSelector());\n return new CompositeDisposable(selector(connectable).subscribe(observer), connectable.connect());\n }, source) :\n new ConnectableObservable(source, subjectOrSubjectSelector);\n };\n\r\n /**\n * Returns an observable sequence that is the result of invoking the selector on a connectable observable sequence that shares a single subscription to the underlying sequence.\n * This operator is a specialization of Multicast using a regular Subject.\n *\n * @example\n * var resres = source.publish();\n * var res = source.publish(function (x) { return x; });\n *\n * @param {Function} [selector] Selector function which can use the multicasted source sequence as many times as needed, without causing multiple subscriptions to the source sequence. Subscribers to the given source will receive all notifications of the source from the time of the subscription on.\n * @returns {Observable} An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.\n */\n observableProto.publish = function (selector) {\n return selector && isFunction(selector) ?\n this.multicast(function () { return new Subject(); }, selector) :\n this.multicast(new Subject());\n };\n\r\n /**\n * Returns an observable sequence that shares a single subscription to the underlying sequence.\n * This operator is a specialization of publish which creates a subscription when the number of observers goes from zero to one, then shares that subscription with all subsequent observers until the number of observers returns to zero, at which point the subscription is disposed.\n * @returns {Observable} An observable sequence that contains the elements of a sequence produced by multicasting the source sequence.\n */\n observableProto.share = function () {\n return this.publish().refCount();\n };\n\r\n /**\n * Returns an observable sequence that is the result of invoking the selector on a connectable observable sequence that shares a single subscription to the underlying sequence containing only the last notification.\n * This operator is a specialization of Multicast using a AsyncSubject.\n *\n * @example\n * var res = source.publishLast();\n * var res = source.publishLast(function (x) { return x; });\n *\n * @param selector [Optional] Selector function which can use the multicasted source sequence as many times as needed, without causing multiple subscriptions to the source sequence. Subscribers to the given source will only receive the last notification of the source.\n * @returns {Observable} An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.\n */\n observableProto.publishLast = function (selector) {\n return selector && isFunction(selector) ?\n this.multicast(function () { return new AsyncSubject(); }, selector) :\n this.multicast(new AsyncSubject());\n };\n\r\n /**\n * Returns an observable sequence that is the result of invoking the selector on a connectable observable sequence that shares a single subscription to the underlying sequence and starts with initialValue.\n * This operator is a specialization of Multicast using a BehaviorSubject.\n *\n * @example\n * var res = source.publishValue(42);\n * var res = source.publishValue(function (x) { return x.select(function (y) { return y * y; }) }, 42);\n *\n * @param {Function} [selector] Optional selector function which can use the multicasted source sequence as many times as needed, without causing multiple subscriptions to the source sequence. Subscribers to the given source will receive immediately receive the initial value, followed by all notifications of the source from the time of the subscription on.\n * @param {Mixed} initialValue Initial value received by observers upon subscription.\n * @returns {Observable} An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.\n */\n observableProto.publishValue = function (initialValueOrSelector, initialValue) {\n return arguments.length === 2 ?\n this.multicast(function () {\n return new BehaviorSubject(initialValue);\n }, initialValueOrSelector) :\n this.multicast(new BehaviorSubject(initialValueOrSelector));\n };\n\r\n /**\n * Returns an observable sequence that shares a single subscription to the underlying sequence and starts with an initialValue.\n * This operator is a specialization of publishValue which creates a subscription when the number of observers goes from zero to one, then shares that subscription with all subsequent observers until the number of observers returns to zero, at which point the subscription is disposed.\n * @param {Mixed} initialValue Initial value received by observers upon subscription.\n * @returns {Observable} An observable sequence that contains the elements of a sequence produced by multicasting the source sequence.\n */\n observableProto.shareValue = function (initialValue) {\n return this.publishValue(initialValue).refCount();\n };\n\r\n /**\n * Returns an observable sequence that is the result of invoking the selector on a connectable observable sequence that shares a single subscription to the underlying sequence replaying notifications subject to a maximum time length for the replay buffer.\n * This operator is a specialization of Multicast using a ReplaySubject.\n *\n * @example\n * var res = source.replay(null, 3);\n * var res = source.replay(null, 3, 500);\n * var res = source.replay(null, 3, 500, scheduler);\n * var res = source.replay(function (x) { return x.take(6).repeat(); }, 3, 500, scheduler);\n *\n * @param selector [Optional] Selector function which can use the multicasted source sequence as many times as needed, without causing multiple subscriptions to the source sequence. Subscribers to the given source will receive all the notifications of the source subject to the specified replay buffer trimming policy.\n * @param bufferSize [Optional] Maximum element count of the replay buffer.\n * @param windowSize [Optional] Maximum time length of the replay buffer.\n * @param scheduler [Optional] Scheduler where connected observers within the selector function will be invoked on.\n * @returns {Observable} An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.\n */\n observableProto.replay = function (selector, bufferSize, windowSize, scheduler) {\n return selector && isFunction(selector) ?\n this.multicast(function () { return new ReplaySubject(bufferSize, windowSize, scheduler); }, selector) :\n this.multicast(new ReplaySubject(bufferSize, windowSize, scheduler));\n };\n\r\n /**\n * Returns an observable sequence that shares a single subscription to the underlying sequence replaying notifications subject to a maximum time length for the replay buffer.\n * This operator is a specialization of replay which creates a subscription when the number of observers goes from zero to one, then shares that subscription with all subsequent observers until the number of observers returns to zero, at which point the subscription is disposed.\n *\n * @example\n * var res = source.shareReplay(3);\n * var res = source.shareReplay(3, 500);\n * var res = source.shareReplay(3, 500, scheduler);\n *\n\n * @param bufferSize [Optional] Maximum element count of the replay buffer.\n * @param window [Optional] Maximum time length of the replay buffer.\n * @param scheduler [Optional] Scheduler where connected observers within the selector function will be invoked on.\n * @returns {Observable} An observable sequence that contains the elements of a sequence produced by multicasting the source sequence.\n */\n observableProto.shareReplay = function (bufferSize, windowSize, scheduler) {\n return this.replay(null, bufferSize, windowSize, scheduler).refCount();\n };\n\r\n var InnerSubscription = function (subject, observer) {\n this.subject = subject;\n this.observer = observer;\n };\n\n InnerSubscription.prototype.dispose = function () {\n if (!this.subject.isDisposed && this.observer !== null) {\n var idx = this.subject.observers.indexOf(this.observer);\n this.subject.observers.splice(idx, 1);\n this.observer = null;\n }\n };\n\r\n /**\n * Represents a value that changes over time.\n * Observers can subscribe to the subject to receive the last (or initial) value and all subsequent notifications.\n */\n var BehaviorSubject = Rx.BehaviorSubject = (function (__super__) {\n function subscribe(observer) {\n checkDisposed(this);\n if (!this.isStopped) {\n this.observers.push(observer);\n observer.onNext(this.value);\n return new InnerSubscription(this, observer);\n }\n if (this.hasError) {\n observer.onError(this.error);\n } else {\n observer.onCompleted();\n }\n return disposableEmpty;\n }\n\n inherits(BehaviorSubject, __super__);\n\n /**\n * Initializes a new instance of the BehaviorSubject class which creates a subject that caches its last value and starts with the specified value.\n * @param {Mixed} value Initial value sent to observers when no other value has been received by the subject yet.\n */\n function BehaviorSubject(value) {\n __super__.call(this, subscribe);\n this.value = value,\n this.observers = [],\n this.isDisposed = false,\n this.isStopped = false,\n this.hasError = false;\n }\n\n addProperties(BehaviorSubject.prototype, Observer, {\n /**\n * Gets the current value or throws an exception.\n * Value is frozen after onCompleted is called.\n * After onError is called always throws the specified exception.\n * An exception is always thrown after dispose is called.\n * @returns {Mixed} The initial value passed to the constructor until onNext is called; after which, the last value passed to onNext.\n */\n getValue: function () {\n checkDisposed(this);\n if (this.hasError) {\n throw this.error;\n }\n return this.value;\n },\n /**\n * Indicates whether the subject has observers subscribed to it.\n * @returns {Boolean} Indicates whether the subject has observers subscribed to it.\n */\n hasObservers: function () { return this.observers.length > 0; },\n /**\n * Notifies all subscribed observers about the end of the sequence.\n */\n onCompleted: function () {\n checkDisposed(this);\n if (this.isStopped) { return; }\n this.isStopped = true;\n for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) {\n os[i].onCompleted();\n }\n\n this.observers.length = 0;\n },\n /**\n * Notifies all subscribed observers about the exception.\n * @param {Mixed} error The exception to send to all observers.\n */\n onError: function (error) {\n checkDisposed(this);\n if (this.isStopped) { return; }\n this.isStopped = true;\n this.hasError = true;\n this.error = error;\n\n for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) {\n os[i].onError(error);\n }\n\n this.observers.length = 0;\n },\n /**\n * Notifies all subscribed observers about the arrival of the specified element in the sequence.\n * @param {Mixed} value The value to send to all observers.\n */\n onNext: function (value) {\n checkDisposed(this);\n if (this.isStopped) { return; }\n this.value = value;\n for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) {\n os[i].onNext(value);\n }\n },\n /**\n * Unsubscribe all observers and release resources.\n */\n dispose: function () {\n this.isDisposed = true;\n this.observers = null;\n this.value = null;\n this.exception = null;\n }\n });\n\n return BehaviorSubject;\n }(Observable));\n\r\n /**\n * Represents an object that is both an observable sequence as well as an observer.\n * Each notification is broadcasted to all subscribed and future observers, subject to buffer trimming policies.\n */\n var ReplaySubject = Rx.ReplaySubject = (function (__super__) {\n\n var maxSafeInteger = Math.pow(2, 53) - 1;\n\n function createRemovableDisposable(subject, observer) {\n return disposableCreate(function () {\n observer.dispose();\n !subject.isDisposed && subject.observers.splice(subject.observers.indexOf(observer), 1);\n });\n }\n\n function subscribe(observer) {\n var so = new ScheduledObserver(this.scheduler, observer),\n subscription = createRemovableDisposable(this, so);\n checkDisposed(this);\n this._trim(this.scheduler.now());\n this.observers.push(so);\n\n for (var i = 0, len = this.q.length; i < len; i++) {\n so.onNext(this.q[i].value);\n }\n\n if (this.hasError) {\n so.onError(this.error);\n } else if (this.isStopped) {\n so.onCompleted();\n }\n\n so.ensureActive();\n return subscription;\n }\n\n inherits(ReplaySubject, __super__);\n\n /**\n * Initializes a new instance of the ReplaySubject class with the specified buffer size, window size and scheduler.\n * @param {Number} [bufferSize] Maximum element count of the replay buffer.\n * @param {Number} [windowSize] Maximum time length of the replay buffer.\n * @param {Scheduler} [scheduler] Scheduler the observers are invoked on.\n */\n function ReplaySubject(bufferSize, windowSize, scheduler) {\n this.bufferSize = bufferSize == null ? maxSafeInteger : bufferSize;\n this.windowSize = windowSize == null ? maxSafeInteger : windowSize;\n this.scheduler = scheduler || currentThreadScheduler;\n this.q = [];\n this.observers = [];\n this.isStopped = false;\n this.isDisposed = false;\n this.hasError = false;\n this.error = null;\n __super__.call(this, subscribe);\n }\n\n addProperties(ReplaySubject.prototype, Observer.prototype, {\n /**\n * Indicates whether the subject has observers subscribed to it.\n * @returns {Boolean} Indicates whether the subject has observers subscribed to it.\n */\n hasObservers: function () {\n return this.observers.length > 0;\n },\n _trim: function (now) {\n while (this.q.length > this.bufferSize) {\n this.q.shift();\n }\n while (this.q.length > 0 && (now - this.q[0].interval) > this.windowSize) {\n this.q.shift();\n }\n },\n /**\n * Notifies all subscribed observers about the arrival of the specified element in the sequence.\n * @param {Mixed} value The value to send to all observers.\n */\n onNext: function (value) {\n checkDisposed(this);\n if (this.isStopped) { return; }\n var now = this.scheduler.now();\n this.q.push({ interval: now, value: value });\n this._trim(now);\n\n for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) {\n var observer = os[i];\n observer.onNext(value);\n observer.ensureActive();\n }\n },\n /**\n * Notifies all subscribed observers about the exception.\n * @param {Mixed} error The exception to send to all observers.\n */\n onError: function (error) {\n checkDisposed(this);\n if (this.isStopped) { return; }\n this.isStopped = true;\n this.error = error;\n this.hasError = true;\n var now = this.scheduler.now();\n this._trim(now);\n for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) {\n var observer = os[i];\n observer.onError(error);\n observer.ensureActive();\n }\n this.observers.length = 0;\n },\n /**\n * Notifies all subscribed observers about the end of the sequence.\n */\n onCompleted: function () {\n checkDisposed(this);\n if (this.isStopped) { return; }\n this.isStopped = true;\n var now = this.scheduler.now();\n this._trim(now);\n for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) {\n var observer = os[i];\n observer.onCompleted();\n observer.ensureActive();\n }\n this.observers.length = 0;\n },\n /**\n * Unsubscribe all observers and release resources.\n */\n dispose: function () {\n this.isDisposed = true;\n this.observers = null;\n }\n });\n\n return ReplaySubject;\n }(Observable));\n\r\n var ConnectableObservable = Rx.ConnectableObservable = (function (__super__) {\n inherits(ConnectableObservable, __super__);\n\n function ConnectableObservable(source, subject) {\n var hasSubscription = false,\n subscription,\n sourceObservable = source.asObservable();\n\n this.connect = function () {\n if (!hasSubscription) {\n hasSubscription = true;\n subscription = new CompositeDisposable(sourceObservable.subscribe(subject), disposableCreate(function () {\n hasSubscription = false;\n }));\n }\n return subscription;\n };\n\n __super__.call(this, function (o) { return subject.subscribe(o); });\n }\n\n ConnectableObservable.prototype.refCount = function () {\n var connectableSubscription, count = 0, source = this;\n return new AnonymousObservable(function (observer) {\n var shouldConnect = ++count === 1,\n subscription = source.subscribe(observer);\n shouldConnect && (connectableSubscription = source.connect());\n return function () {\n subscription.dispose();\n --count === 0 && connectableSubscription.dispose();\n };\n });\n };\n\n return ConnectableObservable;\n }(Observable));\n\r\n /**\n * Returns an observable sequence that shares a single subscription to the underlying sequence. This observable sequence\n * can be resubscribed to, even if all prior subscriptions have ended. (unlike `.publish().refCount()`)\n * @returns {Observable} An observable sequence that contains the elements of a sequence produced by multicasting the source.\n */\n observableProto.singleInstance = function() {\n var source = this, hasObservable = false, observable;\n\n function getObservable() {\n if (!hasObservable) {\n hasObservable = true;\n observable = source.finally(function() { hasObservable = false; }).publish().refCount();\n }\n return observable;\n };\n\n return new AnonymousObservable(function(o) {\n return getObservable().subscribe(o);\n });\n };\n\r\n var Dictionary = (function () {\n\n var primes = [1, 3, 7, 13, 31, 61, 127, 251, 509, 1021, 2039, 4093, 8191, 16381, 32749, 65521, 131071, 262139, 524287, 1048573, 2097143, 4194301, 8388593, 16777213, 33554393, 67108859, 134217689, 268435399, 536870909, 1073741789, 2147483647],\n noSuchkey = \"no such key\",\n duplicatekey = \"duplicate key\";\n\n function isPrime(candidate) {\n if ((candidate & 1) === 0) { return candidate === 2; }\n var num1 = Math.sqrt(candidate),\n num2 = 3;\n while (num2 <= num1) {\n if (candidate % num2 === 0) { return false; }\n num2 += 2;\n }\n return true;\n }\n\n function getPrime(min) {\n var index, num, candidate;\n for (index = 0; index < primes.length; ++index) {\n num = primes[index];\n if (num >= min) { return num; }\n }\n candidate = min | 1;\n while (candidate < primes[primes.length - 1]) {\n if (isPrime(candidate)) { return candidate; }\n candidate += 2;\n }\n return min;\n }\n\n function stringHashFn(str) {\n var hash = 757602046;\n if (!str.length) { return hash; }\n for (var i = 0, len = str.length; i < len; i++) {\n var character = str.charCodeAt(i);\n hash = ((hash << 5) - hash) + character;\n hash = hash & hash;\n }\n return hash;\n }\n\n function numberHashFn(key) {\n var c2 = 0x27d4eb2d;\n key = (key ^ 61) ^ (key >>> 16);\n key = key + (key << 3);\n key = key ^ (key >>> 4);\n key = key * c2;\n key = key ^ (key >>> 15);\n return key;\n }\n\n var getHashCode = (function () {\n var uniqueIdCounter = 0;\n\n return function (obj) {\n if (obj == null) { throw new Error(noSuchkey); }\n\n // Check for built-ins before tacking on our own for any object\n if (typeof obj === 'string') { return stringHashFn(obj); }\n if (typeof obj === 'number') { return numberHashFn(obj); }\n if (typeof obj === 'boolean') { return obj === true ? 1 : 0; }\n if (obj instanceof Date) { return numberHashFn(obj.valueOf()); }\n if (obj instanceof RegExp) { return stringHashFn(obj.toString()); }\n if (typeof obj.valueOf === 'function') {\n // Hack check for valueOf\n var valueOf = obj.valueOf();\n if (typeof valueOf === 'number') { return numberHashFn(valueOf); }\n if (typeof valueOf === 'string') { return stringHashFn(valueOf); }\n }\n if (obj.hashCode) { return obj.hashCode(); }\n\n var id = 17 * uniqueIdCounter++;\n obj.hashCode = function () { return id; };\n return id;\n };\n }());\n\n function newEntry() {\n return { key: null, value: null, next: 0, hashCode: 0 };\n }\n\n function Dictionary(capacity, comparer) {\n if (capacity < 0) { throw new ArgumentOutOfRangeError(); }\n if (capacity > 0) { this._initialize(capacity); }\n\n this.comparer = comparer || defaultComparer;\n this.freeCount = 0;\n this.size = 0;\n this.freeList = -1;\n }\n\n var dictionaryProto = Dictionary.prototype;\n\n dictionaryProto._initialize = function (capacity) {\n var prime = getPrime(capacity), i;\n this.buckets = new Array(prime);\n this.entries = new Array(prime);\n for (i = 0; i < prime; i++) {\n this.buckets[i] = -1;\n this.entries[i] = newEntry();\n }\n this.freeList = -1;\n };\n\n dictionaryProto.add = function (key, value) {\n this._insert(key, value, true);\n };\n\n dictionaryProto._insert = function (key, value, add) {\n if (!this.buckets) { this._initialize(0); }\n var index3,\n num = getHashCode(key) & 2147483647,\n index1 = num % this.buckets.length;\n for (var index2 = this.buckets[index1]; index2 >= 0; index2 = this.entries[index2].next) {\n if (this.entries[index2].hashCode === num && this.comparer(this.entries[index2].key, key)) {\n if (add) { throw new Error(duplicatekey); }\n this.entries[index2].value = value;\n return;\n }\n }\n if (this.freeCount > 0) {\n index3 = this.freeList;\n this.freeList = this.entries[index3].next;\n --this.freeCount;\n } else {\n if (this.size === this.entries.length) {\n this._resize();\n index1 = num % this.buckets.length;\n }\n index3 = this.size;\n ++this.size;\n }\n this.entries[index3].hashCode = num;\n this.entries[index3].next = this.buckets[index1];\n this.entries[index3].key = key;\n this.entries[index3].value = value;\n this.buckets[index1] = index3;\n };\n\n dictionaryProto._resize = function () {\n var prime = getPrime(this.size * 2),\n numArray = new Array(prime);\n for (index = 0; index < numArray.length; ++index) { numArray[index] = -1; }\n var entryArray = new Array(prime);\n for (index = 0; index < this.size; ++index) { entryArray[index] = this.entries[index]; }\n for (var index = this.size; index < prime; ++index) { entryArray[index] = newEntry(); }\n for (var index1 = 0; index1 < this.size; ++index1) {\n var index2 = entryArray[index1].hashCode % prime;\n entryArray[index1].next = numArray[index2];\n numArray[index2] = index1;\n }\n this.buckets = numArray;\n this.entries = entryArray;\n };\n\n dictionaryProto.remove = function (key) {\n if (this.buckets) {\n var num = getHashCode(key) & 2147483647,\n index1 = num % this.buckets.length,\n index2 = -1;\n for (var index3 = this.buckets[index1]; index3 >= 0; index3 = this.entries[index3].next) {\n if (this.entries[index3].hashCode === num && this.comparer(this.entries[index3].key, key)) {\n if (index2 < 0) {\n this.buckets[index1] = this.entries[index3].next;\n } else {\n this.entries[index2].next = this.entries[index3].next;\n }\n this.entries[index3].hashCode = -1;\n this.entries[index3].next = this.freeList;\n this.entries[index3].key = null;\n this.entries[index3].value = null;\n this.freeList = index3;\n ++this.freeCount;\n return true;\n } else {\n index2 = index3;\n }\n }\n }\n return false;\n };\n\n dictionaryProto.clear = function () {\n var index, len;\n if (this.size <= 0) { return; }\n for (index = 0, len = this.buckets.length; index < len; ++index) {\n this.buckets[index] = -1;\n }\n for (index = 0; index < this.size; ++index) {\n this.entries[index] = newEntry();\n }\n this.freeList = -1;\n this.size = 0;\n };\n\n dictionaryProto._findEntry = function (key) {\n if (this.buckets) {\n var num = getHashCode(key) & 2147483647;\n for (var index = this.buckets[num % this.buckets.length]; index >= 0; index = this.entries[index].next) {\n if (this.entries[index].hashCode === num && this.comparer(this.entries[index].key, key)) {\n return index;\n }\n }\n }\n return -1;\n };\n\n dictionaryProto.count = function () {\n return this.size - this.freeCount;\n };\n\n dictionaryProto.tryGetValue = function (key) {\n var entry = this._findEntry(key);\n return entry >= 0 ?\n this.entries[entry].value :\n undefined;\n };\n\n dictionaryProto.getValues = function () {\n var index = 0, results = [];\n if (this.entries) {\n for (var index1 = 0; index1 < this.size; index1++) {\n if (this.entries[index1].hashCode >= 0) {\n results[index++] = this.entries[index1].value;\n }\n }\n }\n return results;\n };\n\n dictionaryProto.get = function (key) {\n var entry = this._findEntry(key);\n if (entry >= 0) { return this.entries[entry].value; }\n throw new Error(noSuchkey);\n };\n\n dictionaryProto.set = function (key, value) {\n this._insert(key, value, false);\n };\n\n dictionaryProto.containskey = function (key) {\n return this._findEntry(key) >= 0;\n };\n\n return Dictionary;\n }());\n\r\n /**\n * Correlates the elements of two sequences based on overlapping durations.\n *\n * @param {Observable} right The right observable sequence to join elements for.\n * @param {Function} leftDurationSelector A function to select the duration (expressed as an observable sequence) of each element of the left observable sequence, used to determine overlap.\n * @param {Function} rightDurationSelector A function to select the duration (expressed as an observable sequence) of each element of the right observable sequence, used to determine overlap.\n * @param {Function} resultSelector A function invoked to compute a result element for any two overlapping elements of the left and right observable sequences. The parameters passed to the function correspond with the elements from the left and right source sequences for which overlap occurs.\n * @returns {Observable} An observable sequence that contains result elements computed from source elements that have an overlapping duration.\n */\n observableProto.join = function (right, leftDurationSelector, rightDurationSelector, resultSelector) {\n var left = this;\n return new AnonymousObservable(function (observer) {\n var group = new CompositeDisposable();\n var leftDone = false, rightDone = false;\n var leftId = 0, rightId = 0;\n var leftMap = new Dictionary(), rightMap = new Dictionary();\n\n group.add(left.subscribe(\n function (value) {\n var id = leftId++;\n var md = new SingleAssignmentDisposable();\n\n leftMap.add(id, value);\n group.add(md);\n\n var expire = function () {\n leftMap.remove(id) && leftMap.count() === 0 && leftDone && observer.onCompleted();\n group.remove(md);\n };\n\n var duration;\n try {\n duration = leftDurationSelector(value);\n } catch (e) {\n observer.onError(e);\n return;\n }\n\n md.setDisposable(duration.take(1).subscribe(noop, observer.onError.bind(observer), expire));\n\n rightMap.getValues().forEach(function (v) {\n var result;\n try {\n result = resultSelector(value, v);\n } catch (exn) {\n observer.onError(exn);\n return;\n }\n\n observer.onNext(result);\n });\n },\n observer.onError.bind(observer),\n function () {\n leftDone = true;\n (rightDone || leftMap.count() === 0) && observer.onCompleted();\n })\n );\n\n group.add(right.subscribe(\n function (value) {\n var id = rightId++;\n var md = new SingleAssignmentDisposable();\n\n rightMap.add(id, value);\n group.add(md);\n\n var expire = function () {\n rightMap.remove(id) && rightMap.count() === 0 && rightDone && observer.onCompleted();\n group.remove(md);\n };\n\n var duration;\n try {\n duration = rightDurationSelector(value);\n } catch (e) {\n observer.onError(e);\n return;\n }\n\n md.setDisposable(duration.take(1).subscribe(noop, observer.onError.bind(observer), expire));\n\n leftMap.getValues().forEach(function (v) {\n var result;\n try {\n result = resultSelector(v, value);\n } catch (exn) {\n observer.onError(exn);\n return;\n }\n\n observer.onNext(result);\n });\n },\n observer.onError.bind(observer),\n function () {\n rightDone = true;\n (leftDone || rightMap.count() === 0) && observer.onCompleted();\n })\n );\n return group;\n }, left);\n };\n\r\n /**\n * Correlates the elements of two sequences based on overlapping durations, and groups the results.\n *\n * @param {Observable} right The right observable sequence to join elements for.\n * @param {Function} leftDurationSelector A function to select the duration (expressed as an observable sequence) of each element of the left observable sequence, used to determine overlap.\n * @param {Function} rightDurationSelector A function to select the duration (expressed as an observable sequence) of each element of the right observable sequence, used to determine overlap.\n * @param {Function} resultSelector A function invoked to compute a result element for any element of the left sequence with overlapping elements from the right observable sequence. The first parameter passed to the function is an element of the left sequence. The second parameter passed to the function is an observable sequence with elements from the right sequence that overlap with the left sequence's element.\n * @returns {Observable} An observable sequence that contains result elements computed from source elements that have an overlapping duration.\n */\n observableProto.groupJoin = function (right, leftDurationSelector, rightDurationSelector, resultSelector) {\n var left = this;\n return new AnonymousObservable(function (observer) {\n var group = new CompositeDisposable();\n var r = new RefCountDisposable(group);\n var leftMap = new Dictionary(), rightMap = new Dictionary();\n var leftId = 0, rightId = 0;\n\n function handleError(e) { return function (v) { v.onError(e); }; };\n\n group.add(left.subscribe(\n function (value) {\n var s = new Subject();\n var id = leftId++;\n leftMap.add(id, s);\n\n var result;\n try {\n result = resultSelector(value, addRef(s, r));\n } catch (e) {\n leftMap.getValues().forEach(handleError(e));\n observer.onError(e);\n return;\n }\n observer.onNext(result);\n\n rightMap.getValues().forEach(function (v) { s.onNext(v); });\n\n var md = new SingleAssignmentDisposable();\n group.add(md);\n\n var expire = function () {\n leftMap.remove(id) && s.onCompleted();\n group.remove(md);\n };\n\n var duration;\n try {\n duration = leftDurationSelector(value);\n } catch (e) {\n leftMap.getValues().forEach(handleError(e));\n observer.onError(e);\n return;\n }\n\n md.setDisposable(duration.take(1).subscribe(\n noop,\n function (e) {\n leftMap.getValues().forEach(handleError(e));\n observer.onError(e);\n },\n expire)\n );\n },\n function (e) {\n leftMap.getValues().forEach(handleError(e));\n observer.onError(e);\n },\n observer.onCompleted.bind(observer))\n );\n\n group.add(right.subscribe(\n function (value) {\n var id = rightId++;\n rightMap.add(id, value);\n\n var md = new SingleAssignmentDisposable();\n group.add(md);\n\n var expire = function () {\n rightMap.remove(id);\n group.remove(md);\n };\n\n var duration;\n try {\n duration = rightDurationSelector(value);\n } catch (e) {\n leftMap.getValues().forEach(handleError(e));\n observer.onError(e);\n return;\n }\n md.setDisposable(duration.take(1).subscribe(\n noop,\n function (e) {\n leftMap.getValues().forEach(handleError(e));\n observer.onError(e);\n },\n expire)\n );\n\n leftMap.getValues().forEach(function (v) { v.onNext(value); });\n },\n function (e) {\n leftMap.getValues().forEach(handleError(e));\n observer.onError(e);\n })\n );\n\n return r;\n }, left);\n };\n\r\n /**\n * Projects each element of an observable sequence into zero or more buffers.\n *\n * @param {Mixed} bufferOpeningsOrClosingSelector Observable sequence whose elements denote the creation of new windows, or, a function invoked to define the boundaries of the produced windows (a new window is started when the previous one is closed, resulting in non-overlapping windows).\n * @param {Function} [bufferClosingSelector] A function invoked to define the closing of each produced window. If a closing selector function is specified for the first parameter, this parameter is ignored.\n * @returns {Observable} An observable sequence of windows.\n */\n observableProto.buffer = function (bufferOpeningsOrClosingSelector, bufferClosingSelector) {\n return this.window.apply(this, arguments).selectMany(function (x) { return x.toArray(); });\n };\n\r\n /**\n * Projects each element of an observable sequence into zero or more windows.\n *\n * @param {Mixed} windowOpeningsOrClosingSelector Observable sequence whose elements denote the creation of new windows, or, a function invoked to define the boundaries of the produced windows (a new window is started when the previous one is closed, resulting in non-overlapping windows).\n * @param {Function} [windowClosingSelector] A function invoked to define the closing of each produced window. If a closing selector function is specified for the first parameter, this parameter is ignored.\n * @returns {Observable} An observable sequence of windows.\n */\n observableProto.window = function (windowOpeningsOrClosingSelector, windowClosingSelector) {\n if (arguments.length === 1 && typeof arguments[0] !== 'function') {\n return observableWindowWithBoundaries.call(this, windowOpeningsOrClosingSelector);\n }\n return typeof windowOpeningsOrClosingSelector === 'function' ?\n observableWindowWithClosingSelector.call(this, windowOpeningsOrClosingSelector) :\n observableWindowWithOpenings.call(this, windowOpeningsOrClosingSelector, windowClosingSelector);\n };\n\n function observableWindowWithOpenings(windowOpenings, windowClosingSelector) {\n return windowOpenings.groupJoin(this, windowClosingSelector, observableEmpty, function (_, win) {\n return win;\n });\n }\n\n function observableWindowWithBoundaries(windowBoundaries) {\n var source = this;\n return new AnonymousObservable(function (observer) {\n var win = new Subject(),\n d = new CompositeDisposable(),\n r = new RefCountDisposable(d);\n\n observer.onNext(addRef(win, r));\n\n d.add(source.subscribe(function (x) {\n win.onNext(x);\n }, function (err) {\n win.onError(err);\n observer.onError(err);\n }, function () {\n win.onCompleted();\n observer.onCompleted();\n }));\n\n isPromise(windowBoundaries) && (windowBoundaries = observableFromPromise(windowBoundaries));\n\n d.add(windowBoundaries.subscribe(function (w) {\n win.onCompleted();\n win = new Subject();\n observer.onNext(addRef(win, r));\n }, function (err) {\n win.onError(err);\n observer.onError(err);\n }, function () {\n win.onCompleted();\n observer.onCompleted();\n }));\n\n return r;\n }, source);\n }\n\n function observableWindowWithClosingSelector(windowClosingSelector) {\n var source = this;\n return new AnonymousObservable(function (observer) {\n var m = new SerialDisposable(),\n d = new CompositeDisposable(m),\n r = new RefCountDisposable(d),\n win = new Subject();\n observer.onNext(addRef(win, r));\n d.add(source.subscribe(function (x) {\n win.onNext(x);\n }, function (err) {\n win.onError(err);\n observer.onError(err);\n }, function () {\n win.onCompleted();\n observer.onCompleted();\n }));\n\n function createWindowClose () {\n var windowClose;\n try {\n windowClose = windowClosingSelector();\n } catch (e) {\n observer.onError(e);\n return;\n }\n\n isPromise(windowClose) && (windowClose = observableFromPromise(windowClose));\n\n var m1 = new SingleAssignmentDisposable();\n m.setDisposable(m1);\n m1.setDisposable(windowClose.take(1).subscribe(noop, function (err) {\n win.onError(err);\n observer.onError(err);\n }, function () {\n win.onCompleted();\n win = new Subject();\n observer.onNext(addRef(win, r));\n createWindowClose();\n }));\n }\n\n createWindowClose();\n return r;\n }, source);\n }\n\r\n /**\n * Returns a new observable that triggers on the second and subsequent triggerings of the input observable.\n * The Nth triggering of the input observable passes the arguments from the N-1th and Nth triggering as a pair.\n * The argument passed to the N-1th triggering is held in hidden internal state until the Nth triggering occurs.\n * @returns {Observable} An observable that triggers on successive pairs of observations from the input observable as an array.\n */\n observableProto.pairwise = function () {\n var source = this;\n return new AnonymousObservable(function (observer) {\n var previous, hasPrevious = false;\n return source.subscribe(\n function (x) {\n if (hasPrevious) {\n observer.onNext([previous, x]);\n } else {\n hasPrevious = true;\n }\n previous = x;\n },\n observer.onError.bind(observer),\n observer.onCompleted.bind(observer));\n }, source);\n };\n\r\n /**\n * Returns two observables which partition the observations of the source by the given function.\n * The first will trigger observations for those values for which the predicate returns true.\n * The second will trigger observations for those values where the predicate returns false.\n * The predicate is executed once for each subscribed observer.\n * Both also propagate all error observations arising from the source and each completes\n * when the source completes.\n * @param {Function} predicate\n * The function to determine which output Observable will trigger a particular observation.\n * @returns {Array}\n * An array of observables. The first triggers when the predicate returns true,\n * and the second triggers when the predicate returns false.\n */\n observableProto.partition = function(predicate, thisArg) {\n return [\n this.filter(predicate, thisArg),\n this.filter(function (x, i, o) { return !predicate.call(thisArg, x, i, o); })\n ];\n };\n\r\n var WhileEnumerable = (function(__super__) {\n inherits(WhileEnumerable, __super__);\n function WhileEnumerable(c, s) {\n this.c = c;\n this.s = s;\n }\n WhileEnumerable.prototype[$iterator$] = function () {\n var self = this;\n return {\n next: function () {\n return self.c() ?\n { done: false, value: self.s } :\n { done: true, value: void 0 };\n }\n };\n };\n return WhileEnumerable;\n }(Enumerable));\n \n function enumerableWhile(condition, source) {\n return new WhileEnumerable(condition, source);\n } \n\r\n /**\n * Returns an observable sequence that is the result of invoking the selector on the source sequence, without sharing subscriptions.\n * This operator allows for a fluent style of writing queries that use the same sequence multiple times.\n *\n * @param {Function} selector Selector function which can use the source sequence as many times as needed, without sharing subscriptions to the source sequence.\n * @returns {Observable} An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.\n */\n observableProto.letBind = observableProto['let'] = function (func) {\n return func(this);\n };\n\r\n /**\n * Determines whether an observable collection contains values. There is an alias for this method called 'ifThen' for browsers <IE9\n *\n * @example\n * 1 - res = Rx.Observable.if(condition, obs1);\n * 2 - res = Rx.Observable.if(condition, obs1, obs2);\n * 3 - res = Rx.Observable.if(condition, obs1, scheduler);\n * @param {Function} condition The condition which determines if the thenSource or elseSource will be run.\n * @param {Observable} thenSource The observable sequence or Promise that will be run if the condition function returns true.\n * @param {Observable} [elseSource] The observable sequence or Promise that will be run if the condition function returns false. If this is not provided, it defaults to Rx.Observabe.Empty with the specified scheduler.\n * @returns {Observable} An observable sequence which is either the thenSource or elseSource.\n */\n Observable['if'] = Observable.ifThen = function (condition, thenSource, elseSourceOrScheduler) {\n return observableDefer(function () {\n elseSourceOrScheduler || (elseSourceOrScheduler = observableEmpty());\n\n isPromise(thenSource) && (thenSource = observableFromPromise(thenSource));\n isPromise(elseSourceOrScheduler) && (elseSourceOrScheduler = observableFromPromise(elseSourceOrScheduler));\n\n // Assume a scheduler for empty only\n typeof elseSourceOrScheduler.now === 'function' && (elseSourceOrScheduler = observableEmpty(elseSourceOrScheduler));\n return condition() ? thenSource : elseSourceOrScheduler;\n });\n };\n\r\n /**\n * Concatenates the observable sequences obtained by running the specified result selector for each element in source.\n * There is an alias for this method called 'forIn' for browsers <IE9\n * @param {Array} sources An array of values to turn into an observable sequence.\n * @param {Function} resultSelector A function to apply to each item in the sources array to turn it into an observable sequence.\n * @returns {Observable} An observable sequence from the concatenated observable sequences.\n */\n Observable['for'] = Observable.forIn = function (sources, resultSelector, thisArg) {\n return enumerableOf(sources, resultSelector, thisArg).concat();\n };\n\r\n /**\n * Repeats source as long as condition holds emulating a while loop.\n * There is an alias for this method called 'whileDo' for browsers <IE9\n *\n * @param {Function} condition The condition which determines if the source will be repeated.\n * @param {Observable} source The observable sequence that will be run if the condition function returns true.\n * @returns {Observable} An observable sequence which is repeated as long as the condition holds.\n */\n var observableWhileDo = Observable['while'] = Observable.whileDo = function (condition, source) {\n isPromise(source) && (source = observableFromPromise(source));\n return enumerableWhile(condition, source).concat();\n };\n\r\n /**\n * Repeats source as long as condition holds emulating a do while loop.\n *\n * @param {Function} condition The condition which determines if the source will be repeated.\n * @param {Observable} source The observable sequence that will be run if the condition function returns true.\n * @returns {Observable} An observable sequence which is repeated as long as the condition holds.\n */\n observableProto.doWhile = function (condition) {\n return observableConcat([this, observableWhileDo(condition, this)]);\n };\n\r\n /**\n * Uses selector to determine which source in sources to use.\n * There is an alias 'switchCase' for browsers <IE9.\n *\n * @example\n * 1 - res = Rx.Observable.case(selector, { '1': obs1, '2': obs2 });\n * 1 - res = Rx.Observable.case(selector, { '1': obs1, '2': obs2 }, obs0);\n * 1 - res = Rx.Observable.case(selector, { '1': obs1, '2': obs2 }, scheduler);\n *\n * @param {Function} selector The function which extracts the value for to test in a case statement.\n * @param {Array} sources A object which has keys which correspond to the case statement labels.\n * @param {Observable} [elseSource] The observable sequence or Promise that will be run if the sources are not matched. If this is not provided, it defaults to Rx.Observabe.empty with the specified scheduler.\n *\n * @returns {Observable} An observable sequence which is determined by a case statement.\n */\n Observable['case'] = Observable.switchCase = function (selector, sources, defaultSourceOrScheduler) {\n return observableDefer(function () {\n isPromise(defaultSourceOrScheduler) && (defaultSourceOrScheduler = observableFromPromise(defaultSourceOrScheduler));\n defaultSourceOrScheduler || (defaultSourceOrScheduler = observableEmpty());\n\n typeof defaultSourceOrScheduler.now === 'function' && (defaultSourceOrScheduler = observableEmpty(defaultSourceOrScheduler));\n\n var result = sources[selector()];\n isPromise(result) && (result = observableFromPromise(result));\n\n return result || defaultSourceOrScheduler;\n });\n };\n\r\n /**\n * Expands an observable sequence by recursively invoking selector.\n *\n * @param {Function} selector Selector function to invoke for each produced element, resulting in another sequence to which the selector will be invoked recursively again.\n * @param {Scheduler} [scheduler] Scheduler on which to perform the expansion. If not provided, this defaults to the current thread scheduler.\n * @returns {Observable} An observable sequence containing all the elements produced by the recursive expansion.\n */\n observableProto.expand = function (selector, scheduler) {\n isScheduler(scheduler) || (scheduler = immediateScheduler);\n var source = this;\n return new AnonymousObservable(function (observer) {\n var q = [],\n m = new SerialDisposable(),\n d = new CompositeDisposable(m),\n activeCount = 0,\n isAcquired = false;\n\n var ensureActive = function () {\n var isOwner = false;\n if (q.length > 0) {\n isOwner = !isAcquired;\n isAcquired = true;\n }\n if (isOwner) {\n m.setDisposable(scheduler.scheduleRecursive(function (self) {\n var work;\n if (q.length > 0) {\n work = q.shift();\n } else {\n isAcquired = false;\n return;\n }\n var m1 = new SingleAssignmentDisposable();\n d.add(m1);\n m1.setDisposable(work.subscribe(function (x) {\n observer.onNext(x);\n var result = null;\n try {\n result = selector(x);\n } catch (e) {\n observer.onError(e);\n }\n q.push(result);\n activeCount++;\n ensureActive();\n }, observer.onError.bind(observer), function () {\n d.remove(m1);\n activeCount--;\n if (activeCount === 0) {\n observer.onCompleted();\n }\n }));\n self();\n }));\n }\n };\n\n q.push(source);\n activeCount++;\n ensureActive();\n return d;\n }, this);\n };\n\r\n /**\n * Runs all observable sequences in parallel and collect their last elements.\n *\n * @example\n * 1 - res = Rx.Observable.forkJoin([obs1, obs2]);\n * 1 - res = Rx.Observable.forkJoin(obs1, obs2, ...);\n * @returns {Observable} An observable sequence with an array collecting the last elements of all the input sequences.\n */\n Observable.forkJoin = function () {\n var allSources = [];\n if (Array.isArray(arguments[0])) {\n allSources = arguments[0];\n } else {\n for(var i = 0, len = arguments.length; i < len; i++) { allSources.push(arguments[i]); }\n }\n return new AnonymousObservable(function (subscriber) {\n var count = allSources.length;\n if (count === 0) {\n subscriber.onCompleted();\n return disposableEmpty;\n }\n var group = new CompositeDisposable(),\n finished = false,\n hasResults = new Array(count),\n hasCompleted = new Array(count),\n results = new Array(count);\n\n for (var idx = 0; idx < count; idx++) {\n (function (i) {\n var source = allSources[i];\n isPromise(source) && (source = observableFromPromise(source));\n group.add(\n source.subscribe(\n function (value) {\n if (!finished) {\n hasResults[i] = true;\n results[i] = value;\n }\n },\n function (e) {\n finished = true;\n subscriber.onError(e);\n group.dispose();\n },\n function () {\n if (!finished) {\n if (!hasResults[i]) {\n subscriber.onCompleted();\n return;\n }\n hasCompleted[i] = true;\n for (var ix = 0; ix < count; ix++) {\n if (!hasCompleted[ix]) { return; }\n }\n finished = true;\n subscriber.onNext(results);\n subscriber.onCompleted();\n }\n }));\n })(idx);\n }\n\n return group;\n });\n };\n\r\n /**\n * Runs two observable sequences in parallel and combines their last elemenets.\n *\n * @param {Observable} second Second observable sequence.\n * @param {Function} resultSelector Result selector function to invoke with the last elements of both sequences.\n * @returns {Observable} An observable sequence with the result of calling the selector function with the last elements of both input sequences.\n */\n observableProto.forkJoin = function (second, resultSelector) {\n var first = this;\n return new AnonymousObservable(function (observer) {\n var leftStopped = false, rightStopped = false,\n hasLeft = false, hasRight = false,\n lastLeft, lastRight,\n leftSubscription = new SingleAssignmentDisposable(), rightSubscription = new SingleAssignmentDisposable();\n\n isPromise(second) && (second = observableFromPromise(second));\n\n leftSubscription.setDisposable(\n first.subscribe(function (left) {\n hasLeft = true;\n lastLeft = left;\n }, function (err) {\n rightSubscription.dispose();\n observer.onError(err);\n }, function () {\n leftStopped = true;\n if (rightStopped) {\n if (!hasLeft) {\n observer.onCompleted();\n } else if (!hasRight) {\n observer.onCompleted();\n } else {\n var result;\n try {\n result = resultSelector(lastLeft, lastRight);\n } catch (e) {\n observer.onError(e);\n return;\n }\n observer.onNext(result);\n observer.onCompleted();\n }\n }\n })\n );\n\n rightSubscription.setDisposable(\n second.subscribe(function (right) {\n hasRight = true;\n lastRight = right;\n }, function (err) {\n leftSubscription.dispose();\n observer.onError(err);\n }, function () {\n rightStopped = true;\n if (leftStopped) {\n if (!hasLeft) {\n observer.onCompleted();\n } else if (!hasRight) {\n observer.onCompleted();\n } else {\n var result;\n try {\n result = resultSelector(lastLeft, lastRight);\n } catch (e) {\n observer.onError(e);\n return;\n }\n observer.onNext(result);\n observer.onCompleted();\n }\n }\n })\n );\n\n return new CompositeDisposable(leftSubscription, rightSubscription);\n }, first);\n };\n\r\n /**\n * Comonadic bind operator.\n * @param {Function} selector A transform function to apply to each element.\n * @param {Object} scheduler Scheduler used to execute the operation. If not specified, defaults to the ImmediateScheduler.\n * @returns {Observable} An observable sequence which results from the comonadic bind operation.\n */\n observableProto.manySelect = observableProto.extend = function (selector, scheduler) {\n isScheduler(scheduler) || (scheduler = immediateScheduler);\n var source = this;\n return observableDefer(function () {\n var chain;\n\n return source\n .map(function (x) {\n var curr = new ChainObservable(x);\n\n chain && chain.onNext(x);\n chain = curr;\n\n return curr;\n })\n .tap(\n noop,\n function (e) { chain && chain.onError(e); },\n function () { chain && chain.onCompleted(); }\n )\n .observeOn(scheduler)\n .map(selector);\n }, source);\n };\n\n var ChainObservable = (function (__super__) {\n\n function subscribe (observer) {\n var self = this, g = new CompositeDisposable();\n g.add(currentThreadScheduler.schedule(function () {\n observer.onNext(self.head);\n g.add(self.tail.mergeAll().subscribe(observer));\n }));\n\n return g;\n }\n\n inherits(ChainObservable, __super__);\n\n function ChainObservable(head) {\n __super__.call(this, subscribe);\n this.head = head;\n this.tail = new AsyncSubject();\n }\n\n addProperties(ChainObservable.prototype, Observer, {\n onCompleted: function () {\n this.onNext(Observable.empty());\n },\n onError: function (e) {\n this.onNext(Observable.throwError(e));\n },\n onNext: function (v) {\n this.tail.onNext(v);\n this.tail.onCompleted();\n }\n });\n\n return ChainObservable;\n\n }(Observable));\n\r\n /** @private */\n var Map = root.Map || (function () {\n\n function Map() {\n this._keys = [];\n this._values = [];\n }\n\n Map.prototype.get = function (key) {\n var i = this._keys.indexOf(key);\n return i !== -1 ? this._values[i] : undefined;\n };\n\n Map.prototype.set = function (key, value) {\n var i = this._keys.indexOf(key);\n i !== -1 && (this._values[i] = value);\n this._values[this._keys.push(key) - 1] = value;\n };\n\n Map.prototype.forEach = function (callback, thisArg) {\n for (var i = 0, len = this._keys.length; i < len; i++) {\n callback.call(thisArg, this._values[i], this._keys[i]);\n }\n };\n\n return Map;\n }());\n\r\n /**\n * @constructor\n * Represents a join pattern over observable sequences.\n */\n function Pattern(patterns) {\n this.patterns = patterns;\n }\n\n /**\n * Creates a pattern that matches the current plan matches and when the specified observable sequences has an available value.\n * @param other Observable sequence to match in addition to the current pattern.\n * @return {Pattern} Pattern object that matches when all observable sequences in the pattern have an available value.\n */\n Pattern.prototype.and = function (other) {\n return new Pattern(this.patterns.concat(other));\n };\n\n /**\n * Matches when all observable sequences in the pattern (specified using a chain of and operators) have an available value and projects the values.\n * @param {Function} selector Selector that will be invoked with available values from the source sequences, in the same order of the sequences in the pattern.\n * @return {Plan} Plan that produces the projected values, to be fed (with other plans) to the when operator.\n */\n Pattern.prototype.thenDo = function (selector) {\n return new Plan(this, selector);\n };\n\r\n function Plan(expression, selector) {\n this.expression = expression;\n this.selector = selector;\n }\n\n Plan.prototype.activate = function (externalSubscriptions, observer, deactivate) {\n var self = this;\n var joinObservers = [];\n for (var i = 0, len = this.expression.patterns.length; i < len; i++) {\n joinObservers.push(planCreateObserver(externalSubscriptions, this.expression.patterns[i], observer.onError.bind(observer)));\n }\n var activePlan = new ActivePlan(joinObservers, function () {\n var result;\n try {\n result = self.selector.apply(self, arguments);\n } catch (e) {\n observer.onError(e);\n return;\n }\n observer.onNext(result);\n }, function () {\n for (var j = 0, jlen = joinObservers.length; j < jlen; j++) {\n joinObservers[j].removeActivePlan(activePlan);\n }\n deactivate(activePlan);\n });\n for (i = 0, len = joinObservers.length; i < len; i++) {\n joinObservers[i].addActivePlan(activePlan);\n }\n return activePlan;\n };\n\n function planCreateObserver(externalSubscriptions, observable, onError) {\n var entry = externalSubscriptions.get(observable);\n if (!entry) {\n var observer = new JoinObserver(observable, onError);\n externalSubscriptions.set(observable, observer);\n return observer;\n }\n return entry;\n }\n\r\n function ActivePlan(joinObserverArray, onNext, onCompleted) {\n this.joinObserverArray = joinObserverArray;\n this.onNext = onNext;\n this.onCompleted = onCompleted;\n this.joinObservers = new Map();\n for (var i = 0, len = this.joinObserverArray.length; i < len; i++) {\n var joinObserver = this.joinObserverArray[i];\n this.joinObservers.set(joinObserver, joinObserver);\n }\n }\n\n ActivePlan.prototype.dequeue = function () {\n this.joinObservers.forEach(function (v) { v.queue.shift(); });\n };\n\n ActivePlan.prototype.match = function () {\n var i, len, hasValues = true;\n for (i = 0, len = this.joinObserverArray.length; i < len; i++) {\n if (this.joinObserverArray[i].queue.length === 0) {\n hasValues = false;\n break;\n }\n }\n if (hasValues) {\n var firstValues = [],\n isCompleted = false;\n for (i = 0, len = this.joinObserverArray.length; i < len; i++) {\n firstValues.push(this.joinObserverArray[i].queue[0]);\n this.joinObserverArray[i].queue[0].kind === 'C' && (isCompleted = true);\n }\n if (isCompleted) {\n this.onCompleted();\n } else {\n this.dequeue();\n var values = [];\n for (i = 0, len = firstValues.length; i < firstValues.length; i++) {\n values.push(firstValues[i].value);\n }\n this.onNext.apply(this, values);\n }\n }\n };\n\r\n var JoinObserver = (function (__super__) {\n inherits(JoinObserver, __super__);\n\n function JoinObserver(source, onError) {\n __super__.call(this);\n this.source = source;\n this.onError = onError;\n this.queue = [];\n this.activePlans = [];\n this.subscription = new SingleAssignmentDisposable();\n this.isDisposed = false;\n }\n\n var JoinObserverPrototype = JoinObserver.prototype;\n\n JoinObserverPrototype.next = function (notification) {\n if (!this.isDisposed) {\n if (notification.kind === 'E') {\n return this.onError(notification.exception);\n }\n this.queue.push(notification);\n var activePlans = this.activePlans.slice(0);\n for (var i = 0, len = activePlans.length; i < len; i++) {\n activePlans[i].match();\n }\n }\n };\n\n JoinObserverPrototype.error = noop;\n JoinObserverPrototype.completed = noop;\n\n JoinObserverPrototype.addActivePlan = function (activePlan) {\n this.activePlans.push(activePlan);\n };\n\n JoinObserverPrototype.subscribe = function () {\n this.subscription.setDisposable(this.source.materialize().subscribe(this));\n };\n\n JoinObserverPrototype.removeActivePlan = function (activePlan) {\n this.activePlans.splice(this.activePlans.indexOf(activePlan), 1);\n this.activePlans.length === 0 && this.dispose();\n };\n\n JoinObserverPrototype.dispose = function () {\n __super__.prototype.dispose.call(this);\n if (!this.isDisposed) {\n this.isDisposed = true;\n this.subscription.dispose();\n }\n };\n\n return JoinObserver;\n } (AbstractObserver));\n\r\n /**\n * Creates a pattern that matches when both observable sequences have an available value.\n *\n * @param right Observable sequence to match with the current sequence.\n * @return {Pattern} Pattern object that matches when both observable sequences have an available value.\n */\n observableProto.and = function (right) {\n return new Pattern([this, right]);\n };\n\r\n /**\n * Matches when the observable sequence has an available value and projects the value.\n *\n * @param {Function} selector Selector that will be invoked for values in the source sequence.\n * @returns {Plan} Plan that produces the projected values, to be fed (with other plans) to the when operator.\n */\n observableProto.thenDo = function (selector) {\n return new Pattern([this]).thenDo(selector);\n };\n\r\n /**\n * Joins together the results from several patterns.\n *\n * @param plans A series of plans (specified as an Array of as a series of arguments) created by use of the Then operator on patterns.\n * @returns {Observable} Observable sequence with the results form matching several patterns.\n */\n Observable.when = function () {\n var len = arguments.length, plans;\n if (Array.isArray(arguments[0])) {\n plans = arguments[0];\n } else {\n plans = new Array(len);\n for(var i = 0; i < len; i++) { plans[i] = arguments[i]; }\n }\n return new AnonymousObservable(function (o) {\n var activePlans = [],\n externalSubscriptions = new Map();\n var outObserver = observerCreate(\n function (x) { o.onNext(x); },\n function (err) {\n externalSubscriptions.forEach(function (v) { v.onError(err); });\n o.onError(err);\n },\n function (x) { o.onCompleted(); }\n );\n try {\n for (var i = 0, len = plans.length; i < len; i++) {\n activePlans.push(plans[i].activate(externalSubscriptions, outObserver, function (activePlan) {\n var idx = activePlans.indexOf(activePlan);\n activePlans.splice(idx, 1);\n activePlans.length === 0 && o.onCompleted();\n }));\n }\n } catch (e) {\n observableThrow(e).subscribe(o);\n }\n var group = new CompositeDisposable();\n externalSubscriptions.forEach(function (joinObserver) {\n joinObserver.subscribe();\n group.add(joinObserver);\n });\n\n return group;\n });\n };\n\r\n function observableTimerDate(dueTime, scheduler) {\n return new AnonymousObservable(function (observer) {\n return scheduler.scheduleWithAbsolute(dueTime, function () {\n observer.onNext(0);\n observer.onCompleted();\n });\n });\n }\n\r\n function observableTimerDateAndPeriod(dueTime, period, scheduler) {\n return new AnonymousObservable(function (observer) {\n var d = dueTime, p = normalizeTime(period);\n return scheduler.scheduleRecursiveWithAbsoluteAndState(0, d, function (count, self) {\n if (p > 0) {\n var now = scheduler.now();\n d = d + p;\n d <= now && (d = now + p);\n }\n observer.onNext(count);\n self(count + 1, d);\n });\n });\n }\n\r\n function observableTimerTimeSpan(dueTime, scheduler) {\n return new AnonymousObservable(function (observer) {\n return scheduler.scheduleWithRelative(normalizeTime(dueTime), function () {\n observer.onNext(0);\n observer.onCompleted();\n });\n });\n }\n\r\n function observableTimerTimeSpanAndPeriod(dueTime, period, scheduler) {\n return dueTime === period ?\n new AnonymousObservable(function (observer) {\n return scheduler.schedulePeriodicWithState(0, period, function (count) {\n observer.onNext(count);\n return count + 1;\n });\n }) :\n observableDefer(function () {\n return observableTimerDateAndPeriod(scheduler.now() + dueTime, period, scheduler);\n });\n }\n\r\n /**\n * Returns an observable sequence that produces a value after each period.\n *\n * @example\n * 1 - res = Rx.Observable.interval(1000);\n * 2 - res = Rx.Observable.interval(1000, Rx.Scheduler.timeout);\n *\n * @param {Number} period Period for producing the values in the resulting sequence (specified as an integer denoting milliseconds).\n * @param {Scheduler} [scheduler] Scheduler to run the timer on. If not specified, Rx.Scheduler.timeout is used.\n * @returns {Observable} An observable sequence that produces a value after each period.\n */\n var observableinterval = Observable.interval = function (period, scheduler) {\n return observableTimerTimeSpanAndPeriod(period, period, isScheduler(scheduler) ? scheduler : timeoutScheduler);\n };\n\r\n /**\n * Returns an observable sequence that produces a value after dueTime has elapsed and then after each period.\n * @param {Number} dueTime Absolute (specified as a Date object) or relative time (specified as an integer denoting milliseconds) at which to produce the first value.\n * @param {Mixed} [periodOrScheduler] Period to produce subsequent values (specified as an integer denoting milliseconds), or the scheduler to run the timer on. If not specified, the resulting timer is not recurring.\n * @param {Scheduler} [scheduler] Scheduler to run the timer on. If not specified, the timeout scheduler is used.\n * @returns {Observable} An observable sequence that produces a value after due time has elapsed and then each period.\n */\n var observableTimer = Observable.timer = function (dueTime, periodOrScheduler, scheduler) {\n var period;\n isScheduler(scheduler) || (scheduler = timeoutScheduler);\n if (periodOrScheduler !== undefined && typeof periodOrScheduler === 'number') {\n period = periodOrScheduler;\n } else if (isScheduler(periodOrScheduler)) {\n scheduler = periodOrScheduler;\n }\n if (dueTime instanceof Date && period === undefined) {\n return observableTimerDate(dueTime.getTime(), scheduler);\n }\n if (dueTime instanceof Date && period !== undefined) {\n period = periodOrScheduler;\n return observableTimerDateAndPeriod(dueTime.getTime(), period, scheduler);\n }\n return period === undefined ?\n observableTimerTimeSpan(dueTime, scheduler) :\n observableTimerTimeSpanAndPeriod(dueTime, period, scheduler);\n };\n\r\n function observableDelayTimeSpan(source, dueTime, scheduler) {\n return new AnonymousObservable(function (observer) {\n var active = false,\n cancelable = new SerialDisposable(),\n exception = null,\n q = [],\n running = false,\n subscription;\n subscription = source.materialize().timestamp(scheduler).subscribe(function (notification) {\n var d, shouldRun;\n if (notification.value.kind === 'E') {\n q = [];\n q.push(notification);\n exception = notification.value.exception;\n shouldRun = !running;\n } else {\n q.push({ value: notification.value, timestamp: notification.timestamp + dueTime });\n shouldRun = !active;\n active = true;\n }\n if (shouldRun) {\n if (exception !== null) {\n observer.onError(exception);\n } else {\n d = new SingleAssignmentDisposable();\n cancelable.setDisposable(d);\n d.setDisposable(scheduler.scheduleRecursiveWithRelative(dueTime, function (self) {\n var e, recurseDueTime, result, shouldRecurse;\n if (exception !== null) {\n return;\n }\n running = true;\n do {\n result = null;\n if (q.length > 0 && q[0].timestamp - scheduler.now() <= 0) {\n result = q.shift().value;\n }\n if (result !== null) {\n result.accept(observer);\n }\n } while (result !== null);\n shouldRecurse = false;\n recurseDueTime = 0;\n if (q.length > 0) {\n shouldRecurse = true;\n recurseDueTime = Math.max(0, q[0].timestamp - scheduler.now());\n } else {\n active = false;\n }\n e = exception;\n running = false;\n if (e !== null) {\n observer.onError(e);\n } else if (shouldRecurse) {\n self(recurseDueTime);\n }\n }));\n }\n }\n });\n return new CompositeDisposable(subscription, cancelable);\n }, source);\n }\n\n function observableDelayDate(source, dueTime, scheduler) {\n return observableDefer(function () {\n return observableDelayTimeSpan(source, dueTime - scheduler.now(), scheduler);\n });\n }\n\n /**\n * Time shifts the observable sequence by dueTime. The relative time intervals between the values are preserved.\n *\n * @example\n * 1 - res = Rx.Observable.delay(new Date());\n * 2 - res = Rx.Observable.delay(new Date(), Rx.Scheduler.timeout);\n *\n * 3 - res = Rx.Observable.delay(5000);\n * 4 - res = Rx.Observable.delay(5000, 1000, Rx.Scheduler.timeout);\n * @memberOf Observable#\n * @param {Number} dueTime Absolute (specified as a Date object) or relative time (specified as an integer denoting milliseconds) by which to shift the observable sequence.\n * @param {Scheduler} [scheduler] Scheduler to run the delay timers on. If not specified, the timeout scheduler is used.\n * @returns {Observable} Time-shifted sequence.\n */\n observableProto.delay = function (dueTime, scheduler) {\n isScheduler(scheduler) || (scheduler = timeoutScheduler);\n return dueTime instanceof Date ?\n observableDelayDate(this, dueTime.getTime(), scheduler) :\n observableDelayTimeSpan(this, dueTime, scheduler);\n };\n\r\n /**\n * Ignores values from an observable sequence which are followed by another value before dueTime.\n * @param {Number} dueTime Duration of the debounce period for each value (specified as an integer denoting milliseconds).\n * @param {Scheduler} [scheduler] Scheduler to run the debounce timers on. If not specified, the timeout scheduler is used.\n * @returns {Observable} The debounced sequence.\n */\n observableProto.debounce = observableProto.throttleWithTimeout = function (dueTime, scheduler) {\n isScheduler(scheduler) || (scheduler = timeoutScheduler);\n var source = this;\n return new AnonymousObservable(function (observer) {\n var cancelable = new SerialDisposable(), hasvalue = false, value, id = 0;\n var subscription = source.subscribe(\n function (x) {\n hasvalue = true;\n value = x;\n id++;\n var currentId = id,\n d = new SingleAssignmentDisposable();\n cancelable.setDisposable(d);\n d.setDisposable(scheduler.scheduleWithRelative(dueTime, function () {\n hasvalue && id === currentId && observer.onNext(value);\n hasvalue = false;\n }));\n },\n function (e) {\n cancelable.dispose();\n observer.onError(e);\n hasvalue = false;\n id++;\n },\n function () {\n cancelable.dispose();\n hasvalue && observer.onNext(value);\n observer.onCompleted();\n hasvalue = false;\n id++;\n });\n return new CompositeDisposable(subscription, cancelable);\n }, this);\n };\n\n /**\n * @deprecated use #debounce or #throttleWithTimeout instead.\n */\n observableProto.throttle = function(dueTime, scheduler) {\n //deprecate('throttle', 'debounce or throttleWithTimeout');\n return this.debounce(dueTime, scheduler);\n };\n\r\n /**\n * Projects each element of an observable sequence into zero or more windows which are produced based on timing information.\n * @param {Number} timeSpan Length of each window (specified as an integer denoting milliseconds).\n * @param {Mixed} [timeShiftOrScheduler] Interval between creation of consecutive windows (specified as an integer denoting milliseconds), or an optional scheduler parameter. If not specified, the time shift corresponds to the timeSpan parameter, resulting in non-overlapping adjacent windows.\n * @param {Scheduler} [scheduler] Scheduler to run windowing timers on. If not specified, the timeout scheduler is used.\n * @returns {Observable} An observable sequence of windows.\n */\n observableProto.windowWithTime = function (timeSpan, timeShiftOrScheduler, scheduler) {\n var source = this, timeShift;\n timeShiftOrScheduler == null && (timeShift = timeSpan);\n isScheduler(scheduler) || (scheduler = timeoutScheduler);\n if (typeof timeShiftOrScheduler === 'number') {\n timeShift = timeShiftOrScheduler;\n } else if (isScheduler(timeShiftOrScheduler)) {\n timeShift = timeSpan;\n scheduler = timeShiftOrScheduler;\n }\n return new AnonymousObservable(function (observer) {\n var groupDisposable,\n nextShift = timeShift,\n nextSpan = timeSpan,\n q = [],\n refCountDisposable,\n timerD = new SerialDisposable(),\n totalTime = 0;\n groupDisposable = new CompositeDisposable(timerD),\n refCountDisposable = new RefCountDisposable(groupDisposable);\n\n function createTimer () {\n var m = new SingleAssignmentDisposable(),\n isSpan = false,\n isShift = false;\n timerD.setDisposable(m);\n if (nextSpan === nextShift) {\n isSpan = true;\n isShift = true;\n } else if (nextSpan < nextShift) {\n isSpan = true;\n } else {\n isShift = true;\n }\n var newTotalTime = isSpan ? nextSpan : nextShift,\n ts = newTotalTime - totalTime;\n totalTime = newTotalTime;\n if (isSpan) {\n nextSpan += timeShift;\n }\n if (isShift) {\n nextShift += timeShift;\n }\n m.setDisposable(scheduler.scheduleWithRelative(ts, function () {\n if (isShift) {\n var s = new Subject();\n q.push(s);\n observer.onNext(addRef(s, refCountDisposable));\n }\n isSpan && q.shift().onCompleted();\n createTimer();\n }));\n };\n q.push(new Subject());\n observer.onNext(addRef(q[0], refCountDisposable));\n createTimer();\n groupDisposable.add(source.subscribe(\n function (x) {\n for (var i = 0, len = q.length; i < len; i++) { q[i].onNext(x); }\n },\n function (e) {\n for (var i = 0, len = q.length; i < len; i++) { q[i].onError(e); }\n observer.onError(e);\n },\n function () {\n for (var i = 0, len = q.length; i < len; i++) { q[i].onCompleted(); }\n observer.onCompleted();\n }\n ));\n return refCountDisposable;\n }, source);\n };\n\r\n /**\n * Projects each element of an observable sequence into a window that is completed when either it's full or a given amount of time has elapsed.\n * @param {Number} timeSpan Maximum time length of a window.\n * @param {Number} count Maximum element count of a window.\n * @param {Scheduler} [scheduler] Scheduler to run windowing timers on. If not specified, the timeout scheduler is used.\n * @returns {Observable} An observable sequence of windows.\n */\n observableProto.windowWithTimeOrCount = function (timeSpan, count, scheduler) {\n var source = this;\n isScheduler(scheduler) || (scheduler = timeoutScheduler);\n return new AnonymousObservable(function (observer) {\n var timerD = new SerialDisposable(),\n groupDisposable = new CompositeDisposable(timerD),\n refCountDisposable = new RefCountDisposable(groupDisposable),\n n = 0,\n windowId = 0,\n s = new Subject();\n\n function createTimer(id) {\n var m = new SingleAssignmentDisposable();\n timerD.setDisposable(m);\n m.setDisposable(scheduler.scheduleWithRelative(timeSpan, function () {\n if (id !== windowId) { return; }\n n = 0;\n var newId = ++windowId;\n s.onCompleted();\n s = new Subject();\n observer.onNext(addRef(s, refCountDisposable));\n createTimer(newId);\n }));\n }\n\n observer.onNext(addRef(s, refCountDisposable));\n createTimer(0);\n\n groupDisposable.add(source.subscribe(\n function (x) {\n var newId = 0, newWindow = false;\n s.onNext(x);\n if (++n === count) {\n newWindow = true;\n n = 0;\n newId = ++windowId;\n s.onCompleted();\n s = new Subject();\n observer.onNext(addRef(s, refCountDisposable));\n }\n newWindow && createTimer(newId);\n },\n function (e) {\n s.onError(e);\n observer.onError(e);\n }, function () {\n s.onCompleted();\n observer.onCompleted();\n }\n ));\n return refCountDisposable;\n }, source);\n };\n\r\n /**\n * Projects each element of an observable sequence into zero or more buffers which are produced based on timing information.\n *\n * @example\n * 1 - res = xs.bufferWithTime(1000, scheduler); // non-overlapping segments of 1 second\n * 2 - res = xs.bufferWithTime(1000, 500, scheduler; // segments of 1 second with time shift 0.5 seconds\n *\n * @param {Number} timeSpan Length of each buffer (specified as an integer denoting milliseconds).\n * @param {Mixed} [timeShiftOrScheduler] Interval between creation of consecutive buffers (specified as an integer denoting milliseconds), or an optional scheduler parameter. If not specified, the time shift corresponds to the timeSpan parameter, resulting in non-overlapping adjacent buffers.\n * @param {Scheduler} [scheduler] Scheduler to run buffer timers on. If not specified, the timeout scheduler is used.\n * @returns {Observable} An observable sequence of buffers.\n */\n observableProto.bufferWithTime = function (timeSpan, timeShiftOrScheduler, scheduler) {\n return this.windowWithTime.apply(this, arguments).selectMany(function (x) { return x.toArray(); });\n };\n\r\n /**\n * Projects each element of an observable sequence into a buffer that is completed when either it's full or a given amount of time has elapsed.\n *\n * @example\n * 1 - res = source.bufferWithTimeOrCount(5000, 50); // 5s or 50 items in an array\n * 2 - res = source.bufferWithTimeOrCount(5000, 50, scheduler); // 5s or 50 items in an array\n *\n * @param {Number} timeSpan Maximum time length of a buffer.\n * @param {Number} count Maximum element count of a buffer.\n * @param {Scheduler} [scheduler] Scheduler to run bufferin timers on. If not specified, the timeout scheduler is used.\n * @returns {Observable} An observable sequence of buffers.\n */\n observableProto.bufferWithTimeOrCount = function (timeSpan, count, scheduler) {\n return this.windowWithTimeOrCount(timeSpan, count, scheduler).selectMany(function (x) {\n return x.toArray();\n });\n };\n\r\n /**\n * Records the time interval between consecutive values in an observable sequence.\n *\n * @example\n * 1 - res = source.timeInterval();\n * 2 - res = source.timeInterval(Rx.Scheduler.timeout);\n *\n * @param [scheduler] Scheduler used to compute time intervals. If not specified, the timeout scheduler is used.\n * @returns {Observable} An observable sequence with time interval information on values.\n */\n observableProto.timeInterval = function (scheduler) {\n var source = this;\n isScheduler(scheduler) || (scheduler = timeoutScheduler);\n return observableDefer(function () {\n var last = scheduler.now();\n return source.map(function (x) {\n var now = scheduler.now(), span = now - last;\n last = now;\n return { value: x, interval: span };\n });\n });\n };\n\r\n /**\n * Records the timestamp for each value in an observable sequence.\n *\n * @example\n * 1 - res = source.timestamp(); // produces { value: x, timestamp: ts }\n * 2 - res = source.timestamp(Rx.Scheduler.default);\n *\n * @param {Scheduler} [scheduler] Scheduler used to compute timestamps. If not specified, the default scheduler is used.\n * @returns {Observable} An observable sequence with timestamp information on values.\n */\n observableProto.timestamp = function (scheduler) {\n isScheduler(scheduler) || (scheduler = timeoutScheduler);\n return this.map(function (x) {\n return { value: x, timestamp: scheduler.now() };\n });\n };\n\r\n function sampleObservable(source, sampler) {\n return new AnonymousObservable(function (o) {\n var atEnd = false, value, hasValue = false;\n\n function sampleSubscribe() {\n if (hasValue) {\n hasValue = false;\n o.onNext(value);\n }\n atEnd && o.onCompleted();\n }\n\n var sourceSubscription = new SingleAssignmentDisposable();\n sourceSubscription.setDisposable(source.subscribe(\n function (newValue) {\n hasValue = true;\n value = newValue;\n },\n function (e) { o.onError(e); },\n function () {\n atEnd = true;\n sourceSubscription.dispose(); \n }\n ));\n\n return new CompositeDisposable(\n sourceSubscription,\n sampler.subscribe(sampleSubscribe, function (e) { o.onError(e); }, sampleSubscribe)\n );\n }, source);\n }\n\n /**\n * Samples the observable sequence at each interval.\n *\n * @example\n * 1 - res = source.sample(sampleObservable); // Sampler tick sequence\n * 2 - res = source.sample(5000); // 5 seconds\n * 2 - res = source.sample(5000, Rx.Scheduler.timeout); // 5 seconds\n *\n * @param {Mixed} intervalOrSampler Interval at which to sample (specified as an integer denoting milliseconds) or Sampler Observable.\n * @param {Scheduler} [scheduler] Scheduler to run the sampling timer on. If not specified, the timeout scheduler is used.\n * @returns {Observable} Sampled observable sequence.\n */\n observableProto.sample = observableProto.throttleLatest = function (intervalOrSampler, scheduler) {\n isScheduler(scheduler) || (scheduler = timeoutScheduler);\n return typeof intervalOrSampler === 'number' ?\n sampleObservable(this, observableinterval(intervalOrSampler, scheduler)) :\n sampleObservable(this, intervalOrSampler);\n };\n\r\n /**\n * Returns the source observable sequence or the other observable sequence if dueTime elapses.\n * @param {Number} dueTime Absolute (specified as a Date object) or relative time (specified as an integer denoting milliseconds) when a timeout occurs.\n * @param {Observable} [other] Sequence to return in case of a timeout. If not specified, a timeout error throwing sequence will be used.\n * @param {Scheduler} [scheduler] Scheduler to run the timeout timers on. If not specified, the timeout scheduler is used.\n * @returns {Observable} The source sequence switching to the other sequence in case of a timeout.\n */\n observableProto.timeout = function (dueTime, other, scheduler) {\n (other == null || typeof other === 'string') && (other = observableThrow(new Error(other || 'Timeout')));\n isScheduler(scheduler) || (scheduler = timeoutScheduler);\n\n var source = this, schedulerMethod = dueTime instanceof Date ?\n 'scheduleWithAbsolute' :\n 'scheduleWithRelative';\n\n return new AnonymousObservable(function (observer) {\n var id = 0,\n original = new SingleAssignmentDisposable(),\n subscription = new SerialDisposable(),\n switched = false,\n timer = new SerialDisposable();\n\n subscription.setDisposable(original);\n\n function createTimer() {\n var myId = id;\n timer.setDisposable(scheduler[schedulerMethod](dueTime, function () {\n if (id === myId) {\n isPromise(other) && (other = observableFromPromise(other));\n subscription.setDisposable(other.subscribe(observer));\n }\n }));\n }\n\n createTimer();\n\n original.setDisposable(source.subscribe(function (x) {\n if (!switched) {\n id++;\n observer.onNext(x);\n createTimer();\n }\n }, function (e) {\n if (!switched) {\n id++;\n observer.onError(e);\n }\n }, function () {\n if (!switched) {\n id++;\n observer.onCompleted();\n }\n }));\n return new CompositeDisposable(subscription, timer);\n }, source);\n };\n\r\n /**\n * Generates an observable sequence by iterating a state from an initial state until the condition fails.\n *\n * @example\n * res = source.generateWithAbsoluteTime(0,\n * function (x) { return return true; },\n * function (x) { return x + 1; },\n * function (x) { return x; },\n * function (x) { return new Date(); }\n * });\n *\n * @param {Mixed} initialState Initial state.\n * @param {Function} condition Condition to terminate generation (upon returning false).\n * @param {Function} iterate Iteration step function.\n * @param {Function} resultSelector Selector function for results produced in the sequence.\n * @param {Function} timeSelector Time selector function to control the speed of values being produced each iteration, returning Date values.\n * @param {Scheduler} [scheduler] Scheduler on which to run the generator loop. If not specified, the timeout scheduler is used.\n * @returns {Observable} The generated sequence.\n */\n Observable.generateWithAbsoluteTime = function (initialState, condition, iterate, resultSelector, timeSelector, scheduler) {\n isScheduler(scheduler) || (scheduler = timeoutScheduler);\n return new AnonymousObservable(function (observer) {\n var first = true,\n hasResult = false;\n return scheduler.scheduleRecursiveWithAbsoluteAndState(initialState, scheduler.now(), function (state, self) {\n hasResult && observer.onNext(state);\n\n try {\n if (first) {\n first = false;\n } else {\n state = iterate(state);\n }\n hasResult = condition(state);\n if (hasResult) {\n var result = resultSelector(state);\n var time = timeSelector(state);\n }\n } catch (e) {\n observer.onError(e);\n return;\n }\n if (hasResult) {\n self(result, time);\n } else {\n observer.onCompleted();\n }\n });\n });\n };\n\r\n /**\n * Generates an observable sequence by iterating a state from an initial state until the condition fails.\n *\n * @example\n * res = source.generateWithRelativeTime(0,\n * function (x) { return return true; },\n * function (x) { return x + 1; },\n * function (x) { return x; },\n * function (x) { return 500; }\n * );\n *\n * @param {Mixed} initialState Initial state.\n * @param {Function} condition Condition to terminate generation (upon returning false).\n * @param {Function} iterate Iteration step function.\n * @param {Function} resultSelector Selector function for results produced in the sequence.\n * @param {Function} timeSelector Time selector function to control the speed of values being produced each iteration, returning integer values denoting milliseconds.\n * @param {Scheduler} [scheduler] Scheduler on which to run the generator loop. If not specified, the timeout scheduler is used.\n * @returns {Observable} The generated sequence.\n */\n Observable.generateWithRelativeTime = function (initialState, condition, iterate, resultSelector, timeSelector, scheduler) {\n isScheduler(scheduler) || (scheduler = timeoutScheduler);\n return new AnonymousObservable(function (observer) {\n var first = true,\n hasResult = false;\n return scheduler.scheduleRecursiveWithRelativeAndState(initialState, 0, function (state, self) {\n hasResult && observer.onNext(state);\n\n try {\n if (first) {\n first = false;\n } else {\n state = iterate(state);\n }\n hasResult = condition(state);\n if (hasResult) {\n var result = resultSelector(state);\n var time = timeSelector(state);\n }\n } catch (e) {\n observer.onError(e);\n return;\n }\n if (hasResult) {\n self(result, time);\n } else {\n observer.onCompleted();\n }\n });\n });\n };\n\r\n /**\n * Time shifts the observable sequence by delaying the subscription with the specified relative time duration, using the specified scheduler to run timers.\n *\n * @example\n * 1 - res = source.delaySubscription(5000); // 5s\n * 2 - res = source.delaySubscription(5000, Rx.Scheduler.default); // 5 seconds\n *\n * @param {Number} dueTime Relative or absolute time shift of the subscription.\n * @param {Scheduler} [scheduler] Scheduler to run the subscription delay timer on. If not specified, the timeout scheduler is used.\n * @returns {Observable} Time-shifted sequence.\n */\n observableProto.delaySubscription = function (dueTime, scheduler) {\n var scheduleMethod = dueTime instanceof Date ? 'scheduleWithAbsolute' : 'scheduleWithRelative';\n var source = this;\n isScheduler(scheduler) || (scheduler = timeoutScheduler);\n return new AnonymousObservable(function (o) {\n var d = new SerialDisposable();\n\n d.setDisposable(scheduler[scheduleMethod](dueTime, function() {\n d.setDisposable(source.subscribe(o));\n }));\n\n return d;\n }, this);\n };\n\r\n /**\n * Time shifts the observable sequence based on a subscription delay and a delay selector function for each element.\n *\n * @example\n * 1 - res = source.delayWithSelector(function (x) { return Rx.Scheduler.timer(5000); }); // with selector only\n * 1 - res = source.delayWithSelector(Rx.Observable.timer(2000), function (x) { return Rx.Observable.timer(x); }); // with delay and selector\n *\n * @param {Observable} [subscriptionDelay] Sequence indicating the delay for the subscription to the source.\n * @param {Function} delayDurationSelector Selector function to retrieve a sequence indicating the delay for each given element.\n * @returns {Observable} Time-shifted sequence.\n */\n observableProto.delayWithSelector = function (subscriptionDelay, delayDurationSelector) {\n var source = this, subDelay, selector;\n if (isFunction(subscriptionDelay)) {\n selector = subscriptionDelay;\n } else {\n subDelay = subscriptionDelay;\n selector = delayDurationSelector;\n }\n return new AnonymousObservable(function (observer) {\n var delays = new CompositeDisposable(), atEnd = false, subscription = new SerialDisposable();\n\n function start() {\n subscription.setDisposable(source.subscribe(\n function (x) {\n var delay = tryCatch(selector)(x);\n if (delay === errorObj) { return observer.onError(delay.e); }\n var d = new SingleAssignmentDisposable();\n delays.add(d);\n d.setDisposable(delay.subscribe(\n function () {\n observer.onNext(x);\n delays.remove(d);\n done();\n },\n function (e) { observer.onError(e); },\n function () {\n observer.onNext(x);\n delays.remove(d);\n done();\n }\n ))\n },\n function (e) { observer.onError(e); },\n function () {\n atEnd = true;\n subscription.dispose();\n done();\n }\n ))\n }\n\n function done () {\n atEnd && delays.length === 0 && observer.onCompleted();\n }\n\n if (!subDelay) {\n start();\n } else {\n subscription.setDisposable(subDelay.subscribe(start, function (e) { observer.onError(e); }, start));\n }\n\n return new CompositeDisposable(subscription, delays);\n }, this);\n };\n\r\n /**\n * Returns the source observable sequence, switching to the other observable sequence if a timeout is signaled.\n * @param {Observable} [firstTimeout] Observable sequence that represents the timeout for the first element. If not provided, this defaults to Observable.never().\n * @param {Function} timeoutDurationSelector Selector to retrieve an observable sequence that represents the timeout between the current element and the next element.\n * @param {Observable} [other] Sequence to return in case of a timeout. If not provided, this is set to Observable.throwException().\n * @returns {Observable} The source sequence switching to the other sequence in case of a timeout.\n */\n observableProto.timeoutWithSelector = function (firstTimeout, timeoutdurationSelector, other) {\n if (arguments.length === 1) {\n timeoutdurationSelector = firstTimeout;\n firstTimeout = observableNever();\n }\n other || (other = observableThrow(new Error('Timeout')));\n var source = this;\n return new AnonymousObservable(function (observer) {\n var subscription = new SerialDisposable(), timer = new SerialDisposable(), original = new SingleAssignmentDisposable();\n\n subscription.setDisposable(original);\n\n var id = 0, switched = false;\n\n function setTimer(timeout) {\n var myId = id;\n\n function timerWins () {\n return id === myId;\n }\n\n var d = new SingleAssignmentDisposable();\n timer.setDisposable(d);\n d.setDisposable(timeout.subscribe(function () {\n timerWins() && subscription.setDisposable(other.subscribe(observer));\n d.dispose();\n }, function (e) {\n timerWins() && observer.onError(e);\n }, function () {\n timerWins() && subscription.setDisposable(other.subscribe(observer));\n }));\n };\n\n setTimer(firstTimeout);\n\n function observerWins() {\n var res = !switched;\n if (res) { id++; }\n return res;\n }\n\n original.setDisposable(source.subscribe(function (x) {\n if (observerWins()) {\n observer.onNext(x);\n var timeout;\n try {\n timeout = timeoutdurationSelector(x);\n } catch (e) {\n observer.onError(e);\n return;\n }\n setTimer(isPromise(timeout) ? observableFromPromise(timeout) : timeout);\n }\n }, function (e) {\n observerWins() && observer.onError(e);\n }, function () {\n observerWins() && observer.onCompleted();\n }));\n return new CompositeDisposable(subscription, timer);\n }, source);\n };\n\r\n /**\n * Ignores values from an observable sequence which are followed by another value within a computed throttle duration.\n * @param {Function} durationSelector Selector function to retrieve a sequence indicating the throttle duration for each given element.\n * @returns {Observable} The debounced sequence.\n */\n observableProto.debounceWithSelector = function (durationSelector) {\n var source = this;\n return new AnonymousObservable(function (observer) {\n var value, hasValue = false, cancelable = new SerialDisposable(), id = 0;\n var subscription = source.subscribe(function (x) {\n var throttle;\n try {\n throttle = durationSelector(x);\n } catch (e) {\n observer.onError(e);\n return;\n }\n\n isPromise(throttle) && (throttle = observableFromPromise(throttle));\n\n hasValue = true;\n value = x;\n id++;\n var currentid = id, d = new SingleAssignmentDisposable();\n cancelable.setDisposable(d);\n d.setDisposable(throttle.subscribe(function () {\n hasValue && id === currentid && observer.onNext(value);\n hasValue = false;\n d.dispose();\n }, observer.onError.bind(observer), function () {\n hasValue && id === currentid && observer.onNext(value);\n hasValue = false;\n d.dispose();\n }));\n }, function (e) {\n cancelable.dispose();\n observer.onError(e);\n hasValue = false;\n id++;\n }, function () {\n cancelable.dispose();\n hasValue && observer.onNext(value);\n observer.onCompleted();\n hasValue = false;\n id++;\n });\n return new CompositeDisposable(subscription, cancelable);\n }, source);\n };\n\n /**\n * @deprecated use #debounceWithSelector instead.\n */\n observableProto.throttleWithSelector = function (durationSelector) {\n //deprecate('throttleWithSelector', 'debounceWithSelector');\n return this.debounceWithSelector(durationSelector);\n };\n\r\n /**\n * Skips elements for the specified duration from the end of the observable source sequence, using the specified scheduler to run timers.\n *\n * 1 - res = source.skipLastWithTime(5000);\n * 2 - res = source.skipLastWithTime(5000, scheduler);\n *\n * @description\n * This operator accumulates a queue with a length enough to store elements received during the initial duration window.\n * As more elements are received, elements older than the specified duration are taken from the queue and produced on the\n * result sequence. This causes elements to be delayed with duration.\n * @param {Number} duration Duration for skipping elements from the end of the sequence.\n * @param {Scheduler} [scheduler] Scheduler to run the timer on. If not specified, defaults to Rx.Scheduler.timeout\n * @returns {Observable} An observable sequence with the elements skipped during the specified duration from the end of the source sequence.\n */\n observableProto.skipLastWithTime = function (duration, scheduler) {\n isScheduler(scheduler) || (scheduler = timeoutScheduler);\n var source = this;\n return new AnonymousObservable(function (o) {\n var q = [];\n return source.subscribe(function (x) {\n var now = scheduler.now();\n q.push({ interval: now, value: x });\n while (q.length > 0 && now - q[0].interval >= duration) {\n o.onNext(q.shift().value);\n }\n }, function (e) { o.onError(e); }, function () {\n var now = scheduler.now();\n while (q.length > 0 && now - q[0].interval >= duration) {\n o.onNext(q.shift().value);\n }\n o.onCompleted();\n });\n }, source);\n };\n\r\n /**\n * Returns elements within the specified duration from the end of the observable source sequence, using the specified schedulers to run timers and to drain the collected elements.\n * @description\n * This operator accumulates a queue with a length enough to store elements received during the initial duration window.\n * As more elements are received, elements older than the specified duration are taken from the queue and produced on the\n * result sequence. This causes elements to be delayed with duration.\n * @param {Number} duration Duration for taking elements from the end of the sequence.\n * @param {Scheduler} [scheduler] Scheduler to run the timer on. If not specified, defaults to Rx.Scheduler.timeout.\n * @returns {Observable} An observable sequence with the elements taken during the specified duration from the end of the source sequence.\n */\n observableProto.takeLastWithTime = function (duration, scheduler) {\n var source = this;\n isScheduler(scheduler) || (scheduler = timeoutScheduler);\n return new AnonymousObservable(function (o) {\n var q = [];\n return source.subscribe(function (x) {\n var now = scheduler.now();\n q.push({ interval: now, value: x });\n while (q.length > 0 && now - q[0].interval >= duration) {\n q.shift();\n }\n }, function (e) { o.onError(e); }, function () {\n var now = scheduler.now();\n while (q.length > 0) {\n var next = q.shift();\n if (now - next.interval <= duration) { o.onNext(next.value); }\n }\n o.onCompleted();\n });\n }, source);\n };\n\r\n /**\n * Returns an array with the elements within the specified duration from the end of the observable source sequence, using the specified scheduler to run timers.\n * @description\n * This operator accumulates a queue with a length enough to store elements received during the initial duration window.\n * As more elements are received, elements older than the specified duration are taken from the queue and produced on the\n * result sequence. This causes elements to be delayed with duration.\n * @param {Number} duration Duration for taking elements from the end of the sequence.\n * @param {Scheduler} scheduler Scheduler to run the timer on. If not specified, defaults to Rx.Scheduler.timeout.\n * @returns {Observable} An observable sequence containing a single array with the elements taken during the specified duration from the end of the source sequence.\n */\n observableProto.takeLastBufferWithTime = function (duration, scheduler) {\n var source = this;\n isScheduler(scheduler) || (scheduler = timeoutScheduler);\n return new AnonymousObservable(function (o) {\n var q = [];\n return source.subscribe(function (x) {\n var now = scheduler.now();\n q.push({ interval: now, value: x });\n while (q.length > 0 && now - q[0].interval >= duration) {\n q.shift();\n }\n }, function (e) { o.onError(e); }, function () {\n var now = scheduler.now(), res = [];\n while (q.length > 0) {\n var next = q.shift();\n now - next.interval <= duration && res.push(next.value);\n }\n o.onNext(res);\n o.onCompleted();\n });\n }, source);\n };\n\r\n /**\n * Takes elements for the specified duration from the start of the observable source sequence, using the specified scheduler to run timers.\n *\n * @example\n * 1 - res = source.takeWithTime(5000, [optional scheduler]);\n * @description\n * This operator accumulates a queue with a length enough to store elements received during the initial duration window.\n * As more elements are received, elements older than the specified duration are taken from the queue and produced on the\n * result sequence. This causes elements to be delayed with duration.\n * @param {Number} duration Duration for taking elements from the start of the sequence.\n * @param {Scheduler} scheduler Scheduler to run the timer on. If not specified, defaults to Rx.Scheduler.timeout.\n * @returns {Observable} An observable sequence with the elements taken during the specified duration from the start of the source sequence.\n */\n observableProto.takeWithTime = function (duration, scheduler) {\n var source = this;\n isScheduler(scheduler) || (scheduler = timeoutScheduler);\n return new AnonymousObservable(function (o) {\n return new CompositeDisposable(scheduler.scheduleWithRelative(duration, function () { o.onCompleted(); }), source.subscribe(o));\n }, source);\n };\n\r\n /**\n * Skips elements for the specified duration from the start of the observable source sequence, using the specified scheduler to run timers.\n *\n * @example\n * 1 - res = source.skipWithTime(5000, [optional scheduler]);\n *\n * @description\n * Specifying a zero value for duration doesn't guarantee no elements will be dropped from the start of the source sequence.\n * This is a side-effect of the asynchrony introduced by the scheduler, where the action that causes callbacks from the source sequence to be forwarded\n * may not execute immediately, despite the zero due time.\n *\n * Errors produced by the source sequence are always forwarded to the result sequence, even if the error occurs before the duration.\n * @param {Number} duration Duration for skipping elements from the start of the sequence.\n * @param {Scheduler} scheduler Scheduler to run the timer on. If not specified, defaults to Rx.Scheduler.timeout.\n * @returns {Observable} An observable sequence with the elements skipped during the specified duration from the start of the source sequence.\n */\n observableProto.skipWithTime = function (duration, scheduler) {\n var source = this;\n isScheduler(scheduler) || (scheduler = timeoutScheduler);\n return new AnonymousObservable(function (observer) {\n var open = false;\n return new CompositeDisposable(\n scheduler.scheduleWithRelative(duration, function () { open = true; }),\n source.subscribe(function (x) { open && observer.onNext(x); }, observer.onError.bind(observer), observer.onCompleted.bind(observer)));\n }, source);\n };\n\r\n /**\n * Skips elements from the observable source sequence until the specified start time, using the specified scheduler to run timers.\n * Errors produced by the source sequence are always forwarded to the result sequence, even if the error occurs before the start time.\n *\n * @examples\n * 1 - res = source.skipUntilWithTime(new Date(), [scheduler]);\n * 2 - res = source.skipUntilWithTime(5000, [scheduler]);\n * @param {Date|Number} startTime Time to start taking elements from the source sequence. If this value is less than or equal to Date(), no elements will be skipped.\n * @param {Scheduler} [scheduler] Scheduler to run the timer on. If not specified, defaults to Rx.Scheduler.timeout.\n * @returns {Observable} An observable sequence with the elements skipped until the specified start time.\n */\n observableProto.skipUntilWithTime = function (startTime, scheduler) {\n isScheduler(scheduler) || (scheduler = timeoutScheduler);\n var source = this, schedulerMethod = startTime instanceof Date ?\n 'scheduleWithAbsolute' :\n 'scheduleWithRelative';\n return new AnonymousObservable(function (o) {\n var open = false;\n\n return new CompositeDisposable(\n scheduler[schedulerMethod](startTime, function () { open = true; }),\n source.subscribe(\n function (x) { open && o.onNext(x); },\n function (e) { o.onError(e); }, function () { o.onCompleted(); }));\n }, source);\n };\n\r\n /**\n * Takes elements for the specified duration until the specified end time, using the specified scheduler to run timers.\n * @param {Number | Date} endTime Time to stop taking elements from the source sequence. If this value is less than or equal to new Date(), the result stream will complete immediately.\n * @param {Scheduler} [scheduler] Scheduler to run the timer on.\n * @returns {Observable} An observable sequence with the elements taken until the specified end time.\n */\n observableProto.takeUntilWithTime = function (endTime, scheduler) {\n isScheduler(scheduler) || (scheduler = timeoutScheduler);\n var source = this, schedulerMethod = endTime instanceof Date ?\n 'scheduleWithAbsolute' :\n 'scheduleWithRelative';\n return new AnonymousObservable(function (o) {\n return new CompositeDisposable(\n scheduler[schedulerMethod](endTime, function () { o.onCompleted(); }),\n source.subscribe(o));\n }, source);\n };\n\r\n /**\n * Returns an Observable that emits only the first item emitted by the source Observable during sequential time windows of a specified duration.\n * @param {Number} windowDuration time to wait before emitting another item after emitting the last item\n * @param {Scheduler} [scheduler] the Scheduler to use internally to manage the timers that handle timeout for each item. If not provided, defaults to Scheduler.timeout.\n * @returns {Observable} An Observable that performs the throttle operation.\n */\n observableProto.throttleFirst = function (windowDuration, scheduler) {\n isScheduler(scheduler) || (scheduler = timeoutScheduler);\n var duration = +windowDuration || 0;\n if (duration <= 0) { throw new RangeError('windowDuration cannot be less or equal zero.'); }\n var source = this;\n return new AnonymousObservable(function (o) {\n var lastOnNext = 0;\n return source.subscribe(\n function (x) {\n var now = scheduler.now();\n if (lastOnNext === 0 || now - lastOnNext >= duration) {\n lastOnNext = now;\n o.onNext(x);\n }\n },function (e) { o.onError(e); }, function () { o.onCompleted(); }\n );\n }, source);\n };\n\r\n /**\n * Executes a transducer to transform the observable sequence\n * @param {Transducer} transducer A transducer to execute\n * @returns {Observable} An Observable sequence containing the results from the transducer.\n */\n observableProto.transduce = function(transducer) {\n var source = this;\n\n function transformForObserver(o) {\n return {\n '@@transducer/init': function() {\n return o;\n },\n '@@transducer/step': function(obs, input) {\n return obs.onNext(input);\n },\n '@@transducer/result': function(obs) {\n return obs.onCompleted();\n }\n };\n }\n\n return new AnonymousObservable(function(o) {\n var xform = transducer(transformForObserver(o));\n return source.subscribe(\n function(v) {\n try {\n xform['@@transducer/step'](o, v);\n } catch (e) {\n o.onError(e);\n }\n },\n function (e) { o.onError(e); },\n function() { xform['@@transducer/result'](o); }\n );\n }, source);\n };\n\r\n /*\n * Performs a exclusive waiting for the first to finish before subscribing to another observable.\n * Observables that come in between subscriptions will be dropped on the floor.\n * @returns {Observable} A exclusive observable with only the results that happen when subscribed.\n */\n observableProto.exclusive = function () {\n var sources = this;\n return new AnonymousObservable(function (observer) {\n var hasCurrent = false,\n isStopped = false,\n m = new SingleAssignmentDisposable(),\n g = new CompositeDisposable();\n\n g.add(m);\n\n m.setDisposable(sources.subscribe(\n function (innerSource) {\n if (!hasCurrent) {\n hasCurrent = true;\n\n isPromise(innerSource) && (innerSource = observableFromPromise(innerSource));\n\n var innerSubscription = new SingleAssignmentDisposable();\n g.add(innerSubscription);\n\n innerSubscription.setDisposable(innerSource.subscribe(\n observer.onNext.bind(observer),\n observer.onError.bind(observer),\n function () {\n g.remove(innerSubscription);\n hasCurrent = false;\n if (isStopped && g.length === 1) {\n observer.onCompleted();\n }\n }));\n }\n },\n observer.onError.bind(observer),\n function () {\n isStopped = true;\n if (!hasCurrent && g.length === 1) {\n observer.onCompleted();\n }\n }));\n\n return g;\n }, this);\n };\n\r\n /*\n * Performs a exclusive map waiting for the first to finish before subscribing to another observable.\n * Observables that come in between subscriptions will be dropped on the floor.\n * @param {Function} selector Selector to invoke for every item in the current subscription.\n * @param {Any} [thisArg] An optional context to invoke with the selector parameter.\n * @returns {Observable} An exclusive observable with only the results that happen when subscribed.\n */\n observableProto.exclusiveMap = function (selector, thisArg) {\n var sources = this,\n selectorFunc = bindCallback(selector, thisArg, 3);\n return new AnonymousObservable(function (observer) {\n var index = 0,\n hasCurrent = false,\n isStopped = true,\n m = new SingleAssignmentDisposable(),\n g = new CompositeDisposable();\n\n g.add(m);\n\n m.setDisposable(sources.subscribe(\n function (innerSource) {\n\n if (!hasCurrent) {\n hasCurrent = true;\n\n innerSubscription = new SingleAssignmentDisposable();\n g.add(innerSubscription);\n\n isPromise(innerSource) && (innerSource = observableFromPromise(innerSource));\n\n innerSubscription.setDisposable(innerSource.subscribe(\n function (x) {\n var result;\n try {\n result = selectorFunc(x, index++, innerSource);\n } catch (e) {\n observer.onError(e);\n return;\n }\n\n observer.onNext(result);\n },\n function (e) { observer.onError(e); },\n function () {\n g.remove(innerSubscription);\n hasCurrent = false;\n\n if (isStopped && g.length === 1) {\n observer.onCompleted();\n }\n }));\n }\n },\n function (e) { observer.onError(e); },\n function () {\n isStopped = true;\n if (g.length === 1 && !hasCurrent) {\n observer.onCompleted();\n }\n }));\n return g;\n }, this);\n };\n\r\n /** Provides a set of extension methods for virtual time scheduling. */\n Rx.VirtualTimeScheduler = (function (__super__) {\n\n function localNow() {\n return this.toDateTimeOffset(this.clock);\n }\n\n function scheduleNow(state, action) {\n return this.scheduleAbsoluteWithState(state, this.clock, action);\n }\n\n function scheduleRelative(state, dueTime, action) {\n return this.scheduleRelativeWithState(state, this.toRelative(dueTime), action);\n }\n\n function scheduleAbsolute(state, dueTime, action) {\n return this.scheduleRelativeWithState(state, this.toRelative(dueTime - this.now()), action);\n }\n\n function invokeAction(scheduler, action) {\n action();\n return disposableEmpty;\n }\n\n inherits(VirtualTimeScheduler, __super__);\n\n /**\n * Creates a new virtual time scheduler with the specified initial clock value and absolute time comparer.\n *\n * @constructor\n * @param {Number} initialClock Initial value for the clock.\n * @param {Function} comparer Comparer to determine causality of events based on absolute time.\n */\n function VirtualTimeScheduler(initialClock, comparer) {\n this.clock = initialClock;\n this.comparer = comparer;\n this.isEnabled = false;\n this.queue = new PriorityQueue(1024);\n __super__.call(this, localNow, scheduleNow, scheduleRelative, scheduleAbsolute);\n }\n\n var VirtualTimeSchedulerPrototype = VirtualTimeScheduler.prototype;\n\n /**\n * Adds a relative time value to an absolute time value.\n * @param {Number} absolute Absolute virtual time value.\n * @param {Number} relative Relative virtual time value to add.\n * @return {Number} Resulting absolute virtual time sum value.\n */\n VirtualTimeSchedulerPrototype.add = notImplemented;\n\n /**\n * Converts an absolute time to a number\n * @param {Any} The absolute time.\n * @returns {Number} The absolute time in ms\n */\n VirtualTimeSchedulerPrototype.toDateTimeOffset = notImplemented;\n\n /**\n * Converts the TimeSpan value to a relative virtual time value.\n * @param {Number} timeSpan TimeSpan value to convert.\n * @return {Number} Corresponding relative virtual time value.\n */\n VirtualTimeSchedulerPrototype.toRelative = notImplemented;\n\n /**\n * Schedules a periodic piece of work by dynamically discovering the scheduler's capabilities. The periodic task will be emulated using recursive scheduling.\n * @param {Mixed} state Initial state passed to the action upon the first iteration.\n * @param {Number} period Period for running the work periodically.\n * @param {Function} action Action to be executed, potentially updating the state.\n * @returns {Disposable} The disposable object used to cancel the scheduled recurring action (best effort).\n */\n VirtualTimeSchedulerPrototype.schedulePeriodicWithState = function (state, period, action) {\n var s = new SchedulePeriodicRecursive(this, state, period, action);\n return s.start();\n };\n\n /**\n * Schedules an action to be executed after dueTime.\n * @param {Mixed} state State passed to the action to be executed.\n * @param {Number} dueTime Relative time after which to execute the action.\n * @param {Function} action Action to be executed.\n * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort).\n */\n VirtualTimeSchedulerPrototype.scheduleRelativeWithState = function (state, dueTime, action) {\n var runAt = this.add(this.clock, dueTime);\n return this.scheduleAbsoluteWithState(state, runAt, action);\n };\n\n /**\n * Schedules an action to be executed at dueTime.\n * @param {Number} dueTime Relative time after which to execute the action.\n * @param {Function} action Action to be executed.\n * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort).\n */\n VirtualTimeSchedulerPrototype.scheduleRelative = function (dueTime, action) {\n return this.scheduleRelativeWithState(action, dueTime, invokeAction);\n };\n\n /**\n * Starts the virtual time scheduler.\n */\n VirtualTimeSchedulerPrototype.start = function () {\n if (!this.isEnabled) {\n this.isEnabled = true;\n do {\n var next = this.getNext();\n if (next !== null) {\n this.comparer(next.dueTime, this.clock) > 0 && (this.clock = next.dueTime);\n next.invoke();\n } else {\n this.isEnabled = false;\n }\n } while (this.isEnabled);\n }\n };\n\n /**\n * Stops the virtual time scheduler.\n */\n VirtualTimeSchedulerPrototype.stop = function () {\n this.isEnabled = false;\n };\n\n /**\n * Advances the scheduler's clock to the specified time, running all work till that point.\n * @param {Number} time Absolute time to advance the scheduler's clock to.\n */\n VirtualTimeSchedulerPrototype.advanceTo = function (time) {\n var dueToClock = this.comparer(this.clock, time);\n if (this.comparer(this.clock, time) > 0) { throw new ArgumentOutOfRangeError(); }\n if (dueToClock === 0) { return; }\n if (!this.isEnabled) {\n this.isEnabled = true;\n do {\n var next = this.getNext();\n if (next !== null && this.comparer(next.dueTime, time) <= 0) {\n this.comparer(next.dueTime, this.clock) > 0 && (this.clock = next.dueTime);\n next.invoke();\n } else {\n this.isEnabled = false;\n }\n } while (this.isEnabled);\n this.clock = time;\n }\n };\n\n /**\n * Advances the scheduler's clock by the specified relative time, running all work scheduled for that timespan.\n * @param {Number} time Relative time to advance the scheduler's clock by.\n */\n VirtualTimeSchedulerPrototype.advanceBy = function (time) {\n var dt = this.add(this.clock, time),\n dueToClock = this.comparer(this.clock, dt);\n if (dueToClock > 0) { throw new ArgumentOutOfRangeError(); }\n if (dueToClock === 0) { return; }\n\n this.advanceTo(dt);\n };\n\n /**\n * Advances the scheduler's clock by the specified relative time.\n * @param {Number} time Relative time to advance the scheduler's clock by.\n */\n VirtualTimeSchedulerPrototype.sleep = function (time) {\n var dt = this.add(this.clock, time);\n if (this.comparer(this.clock, dt) >= 0) { throw new ArgumentOutOfRangeError(); }\n\n this.clock = dt;\n };\n\n /**\n * Gets the next scheduled item to be executed.\n * @returns {ScheduledItem} The next scheduled item.\n */\n VirtualTimeSchedulerPrototype.getNext = function () {\n while (this.queue.length > 0) {\n var next = this.queue.peek();\n if (next.isCancelled()) {\n this.queue.dequeue();\n } else {\n return next;\n }\n }\n return null;\n };\n\n /**\n * Schedules an action to be executed at dueTime.\n * @param {Scheduler} scheduler Scheduler to execute the action on.\n * @param {Number} dueTime Absolute time at which to execute the action.\n * @param {Function} action Action to be executed.\n * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort).\n */\n VirtualTimeSchedulerPrototype.scheduleAbsolute = function (dueTime, action) {\n return this.scheduleAbsoluteWithState(action, dueTime, invokeAction);\n };\n\n /**\n * Schedules an action to be executed at dueTime.\n * @param {Mixed} state State passed to the action to be executed.\n * @param {Number} dueTime Absolute time at which to execute the action.\n * @param {Function} action Action to be executed.\n * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort).\n */\n VirtualTimeSchedulerPrototype.scheduleAbsoluteWithState = function (state, dueTime, action) {\n var self = this;\n\n function run(scheduler, state1) {\n self.queue.remove(si);\n return action(scheduler, state1);\n }\n\n var si = new ScheduledItem(this, state, run, dueTime, this.comparer);\n this.queue.enqueue(si);\n\n return si.disposable;\n };\n\n return VirtualTimeScheduler;\n }(Scheduler));\n\r\n /** Provides a virtual time scheduler that uses Date for absolute time and number for relative time. */\n Rx.HistoricalScheduler = (function (__super__) {\n inherits(HistoricalScheduler, __super__);\n\n /**\n * Creates a new historical scheduler with the specified initial clock value.\n * @constructor\n * @param {Number} initialClock Initial value for the clock.\n * @param {Function} comparer Comparer to determine causality of events based on absolute time.\n */\n function HistoricalScheduler(initialClock, comparer) {\n var clock = initialClock == null ? 0 : initialClock;\n var cmp = comparer || defaultSubComparer;\n __super__.call(this, clock, cmp);\n }\n\n var HistoricalSchedulerProto = HistoricalScheduler.prototype;\n\n /**\n * Adds a relative time value to an absolute time value.\n * @param {Number} absolute Absolute virtual time value.\n * @param {Number} relative Relative virtual time value to add.\n * @return {Number} Resulting absolute virtual time sum value.\n */\n HistoricalSchedulerProto.add = function (absolute, relative) {\n return absolute + relative;\n };\n\n HistoricalSchedulerProto.toDateTimeOffset = function (absolute) {\n return new Date(absolute).getTime();\n };\n\n /**\n * Converts the TimeSpan value to a relative virtual time value.\n * @memberOf HistoricalScheduler\n * @param {Number} timeSpan TimeSpan value to convert.\n * @return {Number} Corresponding relative virtual time value.\n */\n HistoricalSchedulerProto.toRelative = function (timeSpan) {\n return timeSpan;\n };\n\n return HistoricalScheduler;\n }(Rx.VirtualTimeScheduler));\n\r\n var AnonymousObservable = Rx.AnonymousObservable = (function (__super__) {\n inherits(AnonymousObservable, __super__);\n\n // Fix subscriber to check for undefined or function returned to decorate as Disposable\n function fixSubscriber(subscriber) {\n return subscriber && isFunction(subscriber.dispose) ? subscriber :\n isFunction(subscriber) ? disposableCreate(subscriber) : disposableEmpty;\n }\n\n function setDisposable(s, state) {\n var ado = state[0], subscribe = state[1];\n var sub = tryCatch(subscribe)(ado);\n\n if (sub === errorObj) {\n if(!ado.fail(errorObj.e)) { return thrower(errorObj.e); }\n }\n ado.setDisposable(fixSubscriber(sub));\n }\n\n function AnonymousObservable(subscribe, parent) {\n this.source = parent;\n\n function s(observer) {\n var ado = new AutoDetachObserver(observer), state = [ado, subscribe];\n\n if (currentThreadScheduler.scheduleRequired()) {\n currentThreadScheduler.scheduleWithState(state, setDisposable);\n } else {\n setDisposable(null, state);\n }\n return ado;\n }\n\n __super__.call(this, s);\n }\n\n return AnonymousObservable;\n\n }(Observable));\n\r\n var AutoDetachObserver = (function (__super__) {\n inherits(AutoDetachObserver, __super__);\n\n function AutoDetachObserver(observer) {\n __super__.call(this);\n this.observer = observer;\n this.m = new SingleAssignmentDisposable();\n }\n\n var AutoDetachObserverPrototype = AutoDetachObserver.prototype;\n\n AutoDetachObserverPrototype.next = function (value) {\n var result = tryCatch(this.observer.onNext).call(this.observer, value);\n if (result === errorObj) {\n this.dispose();\n thrower(result.e);\n }\n };\n\n AutoDetachObserverPrototype.error = function (err) {\n var result = tryCatch(this.observer.onError).call(this.observer, err);\n this.dispose();\n result === errorObj && thrower(result.e);\n };\n\n AutoDetachObserverPrototype.completed = function () {\n var result = tryCatch(this.observer.onCompleted).call(this.observer);\n this.dispose();\n result === errorObj && thrower(result.e);\n };\n\n AutoDetachObserverPrototype.setDisposable = function (value) { this.m.setDisposable(value); };\n AutoDetachObserverPrototype.getDisposable = function () { return this.m.getDisposable(); };\n\n AutoDetachObserverPrototype.dispose = function () {\n __super__.prototype.dispose.call(this);\n this.m.dispose();\n };\n\n return AutoDetachObserver;\n }(AbstractObserver));\n\r\n var GroupedObservable = (function (__super__) {\n inherits(GroupedObservable, __super__);\n\n function subscribe(observer) {\n return this.underlyingObservable.subscribe(observer);\n }\n\n function GroupedObservable(key, underlyingObservable, mergedDisposable) {\n __super__.call(this, subscribe);\n this.key = key;\n this.underlyingObservable = !mergedDisposable ?\n underlyingObservable :\n new AnonymousObservable(function (observer) {\n return new CompositeDisposable(mergedDisposable.getDisposable(), underlyingObservable.subscribe(observer));\n });\n }\n\n return GroupedObservable;\n }(Observable));\n\r\n /**\n * Represents an object that is both an observable sequence as well as an observer.\n * Each notification is broadcasted to all subscribed observers.\n */\n var Subject = Rx.Subject = (function (__super__) {\n function subscribe(observer) {\n checkDisposed(this);\n if (!this.isStopped) {\n this.observers.push(observer);\n return new InnerSubscription(this, observer);\n }\n if (this.hasError) {\n observer.onError(this.error);\n return disposableEmpty;\n }\n observer.onCompleted();\n return disposableEmpty;\n }\n\n inherits(Subject, __super__);\n\n /**\n * Creates a subject.\n */\n function Subject() {\n __super__.call(this, subscribe);\n this.isDisposed = false,\n this.isStopped = false,\n this.observers = [];\n this.hasError = false;\n }\n\n addProperties(Subject.prototype, Observer.prototype, {\n /**\n * Indicates whether the subject has observers subscribed to it.\n * @returns {Boolean} Indicates whether the subject has observers subscribed to it.\n */\n hasObservers: function () { return this.observers.length > 0; },\n /**\n * Notifies all subscribed observers about the end of the sequence.\n */\n onCompleted: function () {\n checkDisposed(this);\n if (!this.isStopped) {\n this.isStopped = true;\n for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) {\n os[i].onCompleted();\n }\n\n this.observers.length = 0;\n }\n },\n /**\n * Notifies all subscribed observers about the exception.\n * @param {Mixed} error The exception to send to all observers.\n */\n onError: function (error) {\n checkDisposed(this);\n if (!this.isStopped) {\n this.isStopped = true;\n this.error = error;\n this.hasError = true;\n for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) {\n os[i].onError(error);\n }\n\n this.observers.length = 0;\n }\n },\n /**\n * Notifies all subscribed observers about the arrival of the specified element in the sequence.\n * @param {Mixed} value The value to send to all observers.\n */\n onNext: function (value) {\n checkDisposed(this);\n if (!this.isStopped) {\n for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) {\n os[i].onNext(value);\n }\n }\n },\n /**\n * Unsubscribe all observers and release resources.\n */\n dispose: function () {\n this.isDisposed = true;\n this.observers = null;\n }\n });\n\n /**\n * Creates a subject from the specified observer and observable.\n * @param {Observer} observer The observer used to send messages to the subject.\n * @param {Observable} observable The observable used to subscribe to messages sent from the subject.\n * @returns {Subject} Subject implemented using the given observer and observable.\n */\n Subject.create = function (observer, observable) {\n return new AnonymousSubject(observer, observable);\n };\n\n return Subject;\n }(Observable));\n\r\n /**\n * Represents the result of an asynchronous operation.\n * The last value before the OnCompleted notification, or the error received through OnError, is sent to all subscribed observers.\n */\n var AsyncSubject = Rx.AsyncSubject = (function (__super__) {\n\n function subscribe(observer) {\n checkDisposed(this);\n\n if (!this.isStopped) {\n this.observers.push(observer);\n return new InnerSubscription(this, observer);\n }\n\n if (this.hasError) {\n observer.onError(this.error);\n } else if (this.hasValue) {\n observer.onNext(this.value);\n observer.onCompleted();\n } else {\n observer.onCompleted();\n }\n\n return disposableEmpty;\n }\n\n inherits(AsyncSubject, __super__);\n\n /**\n * Creates a subject that can only receive one value and that value is cached for all future observations.\n * @constructor\n */\n function AsyncSubject() {\n __super__.call(this, subscribe);\n\n this.isDisposed = false;\n this.isStopped = false;\n this.hasValue = false;\n this.observers = [];\n this.hasError = false;\n }\n\n addProperties(AsyncSubject.prototype, Observer, {\n /**\n * Indicates whether the subject has observers subscribed to it.\n * @returns {Boolean} Indicates whether the subject has observers subscribed to it.\n */\n hasObservers: function () {\n checkDisposed(this);\n return this.observers.length > 0;\n },\n /**\n * Notifies all subscribed observers about the end of the sequence, also causing the last received value to be sent out (if any).\n */\n onCompleted: function () {\n var i, len;\n checkDisposed(this);\n if (!this.isStopped) {\n this.isStopped = true;\n var os = cloneArray(this.observers), len = os.length;\n\n if (this.hasValue) {\n for (i = 0; i < len; i++) {\n var o = os[i];\n o.onNext(this.value);\n o.onCompleted();\n }\n } else {\n for (i = 0; i < len; i++) {\n os[i].onCompleted();\n }\n }\n\n this.observers.length = 0;\n }\n },\n /**\n * Notifies all subscribed observers about the error.\n * @param {Mixed} error The Error to send to all observers.\n */\n onError: function (error) {\n checkDisposed(this);\n if (!this.isStopped) {\n this.isStopped = true;\n this.hasError = true;\n this.error = error;\n\n for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) {\n os[i].onError(error);\n }\n\n this.observers.length = 0;\n }\n },\n /**\n * Sends a value to the subject. The last value received before successful termination will be sent to all subscribed and future observers.\n * @param {Mixed} value The value to store in the subject.\n */\n onNext: function (value) {\n checkDisposed(this);\n if (this.isStopped) { return; }\n this.value = value;\n this.hasValue = true;\n },\n /**\n * Unsubscribe all observers and release resources.\n */\n dispose: function () {\n this.isDisposed = true;\n this.observers = null;\n this.exception = null;\n this.value = null;\n }\n });\n\n return AsyncSubject;\n }(Observable));\n\r\n var AnonymousSubject = Rx.AnonymousSubject = (function (__super__) {\n inherits(AnonymousSubject, __super__);\n\n function subscribe(observer) {\n return this.observable.subscribe(observer);\n }\n\n function AnonymousSubject(observer, observable) {\n this.observer = observer;\n this.observable = observable;\n __super__.call(this, subscribe);\n }\n\n addProperties(AnonymousSubject.prototype, Observer.prototype, {\n onCompleted: function () {\n this.observer.onCompleted();\n },\n onError: function (error) {\n this.observer.onError(error);\n },\n onNext: function (value) {\n this.observer.onNext(value);\n }\n });\n\n return AnonymousSubject;\n }(Observable));\n\r\n /**\n * Used to pause and resume streams.\n */\n Rx.Pauser = (function (__super__) {\n inherits(Pauser, __super__);\n\n function Pauser() {\n __super__.call(this);\n }\n\n /**\n * Pauses the underlying sequence.\n */\n Pauser.prototype.pause = function () { this.onNext(false); };\n\n /**\n * Resumes the underlying sequence.\n */\n Pauser.prototype.resume = function () { this.onNext(true); };\n\n return Pauser;\n }(Subject));\n\r\n if (true) {\n root.Rx = Rx;\n\n !(__WEBPACK_AMD_DEFINE_RESULT__ = function() {\n return Rx;\n }.call(exports, __webpack_require__, exports, module), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));\n } else if (freeExports && freeModule) {\n // in Node.js or RingoJS\n if (moduleExports) {\n (freeModule.exports = Rx).Rx = Rx;\n } else {\n freeExports.Rx = Rx;\n }\n } else {\n // in a browser or Rhino\n root.Rx = Rx;\n }\n\r\n // All code before this point will be filtered from stack traces.\n var rEndingLine = captureLine();\n\r\n}.call(this));\n\n/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(5)(module), (function() { return this; }()), __webpack_require__(6)))\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/rx/dist/rx.all.js\n ** module id = 4\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/rx/dist/rx.all.js?");
  2. },function(module,exports){eval("module.exports = function(module) {\r\n if(!module.webpackPolyfill) {\r\n module.deprecate = function() {};\r\n module.paths = [];\r\n // module.parent = undefined by default\r\n module.children = [];\r\n module.webpackPolyfill = 1;\r\n }\r\n return module;\r\n}\r\n\n\n/*****************\n ** WEBPACK FOOTER\n ** (webpack)/buildin/module.js\n ** module id = 5\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///(webpack)/buildin/module.js?")},function(module,exports){eval("// shim for using process in browser\n\nvar process = module.exports = {};\nvar queue = [];\nvar draining = false;\nvar currentQueue;\nvar queueIndex = -1;\n\nfunction cleanUpNextTick() {\n draining = false;\n if (currentQueue.length) {\n queue = currentQueue.concat(queue);\n } else {\n queueIndex = -1;\n }\n if (queue.length) {\n drainQueue();\n }\n}\n\nfunction drainQueue() {\n if (draining) {\n return;\n }\n var timeout = setTimeout(cleanUpNextTick);\n draining = true;\n\n var len = queue.length;\n while(len) {\n currentQueue = queue;\n queue = [];\n while (++queueIndex < len) {\n currentQueue[queueIndex].run();\n }\n queueIndex = -1;\n len = queue.length;\n }\n currentQueue = null;\n draining = false;\n clearTimeout(timeout);\n}\n\nprocess.nextTick = function (fun) {\n var args = new Array(arguments.length - 1);\n if (arguments.length > 1) {\n for (var i = 1; i < arguments.length; i++) {\n args[i - 1] = arguments[i];\n }\n }\n queue.push(new Item(fun, args));\n if (queue.length === 1 && !draining) {\n setTimeout(drainQueue, 0);\n }\n};\n\n// v8 likes predictible objects\nfunction Item(fun, array) {\n this.fun = fun;\n this.array = array;\n}\nItem.prototype.run = function () {\n this.fun.apply(null, this.array);\n};\nprocess.title = 'browser';\nprocess.browser = true;\nprocess.env = {};\nprocess.argv = [];\nprocess.version = ''; // empty string to avoid regexp issues\nprocess.versions = {};\n\nfunction noop() {}\n\nprocess.on = noop;\nprocess.addListener = noop;\nprocess.once = noop;\nprocess.off = noop;\nprocess.removeListener = noop;\nprocess.removeAllListeners = noop;\nprocess.emit = noop;\n\nprocess.binding = function (name) {\n throw new Error('process.binding is not supported');\n};\n\n// TODO(shtylman)\nprocess.cwd = function () { return '/' };\nprocess.chdir = function (dir) {\n throw new Error('process.chdir is not supported');\n};\nprocess.umask = function() { return 0; };\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/node-libs-browser/~/process/browser.js\n ** module id = 6\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/node-libs-browser/~/process/browser.js?")},function(module,exports,__webpack_require__){eval("var diff = __webpack_require__(21)\r\nvar patch = __webpack_require__(26)\r\nvar h = __webpack_require__(31)\r\nvar create = __webpack_require__(8)\r\nvar VNode = __webpack_require__(33)\r\nvar VText = __webpack_require__(34)\r\n\r\nmodule.exports = {\r\n diff: diff,\r\n patch: patch,\r\n h: h,\r\n create: create,\r\n VNode: VNode,\r\n VText: VText\r\n}\r\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/virtual-dom/index.js\n ** module id = 7\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/virtual-dom/index.js?")},function(module,exports,__webpack_require__){eval("var createElement = __webpack_require__(9)\n\nmodule.exports = createElement\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/virtual-dom/create-element.js\n ** module id = 8\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/virtual-dom/create-element.js?")},function(module,exports,__webpack_require__){eval('var document = __webpack_require__(12)\n\nvar applyProperties = __webpack_require__(14)\n\nvar isVNode = __webpack_require__(17)\nvar isVText = __webpack_require__(10)\nvar isWidget = __webpack_require__(18)\nvar handleThunk = __webpack_require__(19)\n\nmodule.exports = createElement\n\nfunction createElement(vnode, opts) {\n var doc = opts ? opts.document || document : document\n var warn = opts ? opts.warn : null\n\n vnode = handleThunk(vnode).a\n\n if (isWidget(vnode)) {\n return vnode.init()\n } else if (isVText(vnode)) {\n return doc.createTextNode(vnode.text)\n } else if (!isVNode(vnode)) {\n if (warn) {\n warn("Item is not a valid virtual dom node", vnode)\n }\n return null\n }\n\n var node = (vnode.namespace === null) ?\n doc.createElement(vnode.tagName) :\n doc.createElementNS(vnode.namespace, vnode.tagName)\n\n var props = vnode.properties\n applyProperties(node, props)\n\n var children = vnode.children\n\n for (var i = 0; i < children.length; i++) {\n var childNode = createElement(children[i], opts)\n if (childNode) {\n node.appendChild(childNode)\n }\n }\n\n return node\n}\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/virtual-dom/vdom/create-element.js\n ** module id = 9\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/virtual-dom/vdom/create-element.js?')},function(module,exports,__webpack_require__){eval('var version = __webpack_require__(11)\n\nmodule.exports = isVirtualText\n\nfunction isVirtualText(x) {\n return x && x.type === "VirtualText" && x.version === version\n}\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/virtual-dom/vnode/is-vtext.js\n ** module id = 10\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/virtual-dom/vnode/is-vtext.js?')},function(module,exports){eval('module.exports = "2"\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/virtual-dom/vnode/version.js\n ** module id = 11\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/virtual-dom/vnode/version.js?')},function(module,exports,__webpack_require__){eval("/* WEBPACK VAR INJECTION */(function(global) {var topLevel = typeof global !== 'undefined' ? global :\n typeof window !== 'undefined' ? window : {}\nvar minDoc = __webpack_require__(13);\n\nif (typeof document !== 'undefined') {\n module.exports = document;\n} else {\n var doccy = topLevel['__GLOBAL_DOCUMENT_CACHE@4'];\n\n if (!doccy) {\n doccy = topLevel['__GLOBAL_DOCUMENT_CACHE@4'] = minDoc;\n }\n\n module.exports = doccy;\n}\n\n/* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }())))\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/virtual-dom/~/global/document.js\n ** module id = 12\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/virtual-dom/~/global/document.js?")},function(module,exports){eval("/* (ignored) */\n\n/*****************\n ** WEBPACK FOOTER\n ** min-document (ignored)\n ** module id = 13\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///min-document_(ignored)?")},function(module,exports,__webpack_require__){eval('var isObject = __webpack_require__(15)\nvar isHook = __webpack_require__(16)\n\nmodule.exports = applyProperties\n\nfunction applyProperties(node, props, previous) {\n for (var propName in props) {\n var propValue = props[propName]\n\n if (propValue === undefined) {\n removeProperty(node, propName, propValue, previous);\n } else if (isHook(propValue)) {\n removeProperty(node, propName, propValue, previous)\n if (propValue.hook) {\n propValue.hook(node,\n propName,\n previous ? previous[propName] : undefined)\n }\n } else {\n if (isObject(propValue)) {\n patchObject(node, props, previous, propName, propValue);\n } else {\n node[propName] = propValue\n }\n }\n }\n}\n\nfunction removeProperty(node, propName, propValue, previous) {\n if (previous) {\n var previousValue = previous[propName]\n\n if (!isHook(previousValue)) {\n if (propName === "attributes") {\n for (var attrName in previousValue) {\n node.removeAttribute(attrName)\n }\n } else if (propName === "style") {\n for (var i in previousValue) {\n node.style[i] = ""\n }\n } else if (typeof previousValue === "string") {\n node[propName] = ""\n } else {\n node[propName] = null\n }\n } else if (previousValue.unhook) {\n previousValue.unhook(node, propName, propValue)\n }\n }\n}\n\nfunction patchObject(node, props, previous, propName, propValue) {\n var previousValue = previous ? previous[propName] : undefined\n\n // Set attributes\n if (propName === "attributes") {\n for (var attrName in propValue) {\n var attrValue = propValue[attrName]\n\n if (attrValue === undefined) {\n node.removeAttribute(attrName)\n } else {\n node.setAttribute(attrName, attrValue)\n }\n }\n\n return\n }\n\n if(previousValue && isObject(previousValue) &&\n getPrototype(previousValue) !== getPrototype(propValue)) {\n node[propName] = propValue\n return\n }\n\n if (!isObject(node[propName])) {\n node[propName] = {}\n }\n\n var replacer = propName === "style" ? "" : undefined\n\n for (var k in propValue) {\n var value = propValue[k]\n node[propName][k] = (value === undefined) ? replacer : value\n }\n}\n\nfunction getPrototype(value) {\n if (Object.getPrototypeOf) {\n return Object.getPrototypeOf(value)\n } else if (value.__proto__) {\n return value.__proto__\n } else if (value.constructor) {\n return value.constructor.prototype\n }\n}\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/virtual-dom/vdom/apply-properties.js\n ** module id = 14\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/virtual-dom/vdom/apply-properties.js?')},function(module,exports){eval('"use strict";\n\nmodule.exports = function isObject(x) {\n return typeof x === "object" && x !== null;\n};\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/virtual-dom/~/is-object/index.js\n ** module id = 15\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/virtual-dom/~/is-object/index.js?')},function(module,exports){eval('module.exports = isHook\n\nfunction isHook(hook) {\n return hook &&\n (typeof hook.hook === "function" && !hook.hasOwnProperty("hook") ||\n typeof hook.unhook === "function" && !hook.hasOwnProperty("unhook"))\n}\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/virtual-dom/vnode/is-vhook.js\n ** module id = 16\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/virtual-dom/vnode/is-vhook.js?')},function(module,exports,__webpack_require__){eval('var version = __webpack_require__(11)\n\nmodule.exports = isVirtualNode\n\nfunction isVirtualNode(x) {\n return x && x.type === "VirtualNode" && x.version === version\n}\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/virtual-dom/vnode/is-vnode.js\n ** module id = 17\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/virtual-dom/vnode/is-vnode.js?')},function(module,exports){eval('module.exports = isWidget\n\nfunction isWidget(w) {\n return w && w.type === "Widget"\n}\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/virtual-dom/vnode/is-widget.js\n ** module id = 18\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/virtual-dom/vnode/is-widget.js?')},function(module,exports,__webpack_require__){eval('var isVNode = __webpack_require__(17)\nvar isVText = __webpack_require__(10)\nvar isWidget = __webpack_require__(18)\nvar isThunk = __webpack_require__(20)\n\nmodule.exports = handleThunk\n\nfunction handleThunk(a, b) {\n var renderedA = a\n var renderedB = b\n\n if (isThunk(b)) {\n renderedB = renderThunk(b, a)\n }\n\n if (isThunk(a)) {\n renderedA = renderThunk(a, null)\n }\n\n return {\n a: renderedA,\n b: renderedB\n }\n}\n\nfunction renderThunk(thunk, previous) {\n var renderedThunk = thunk.vnode\n\n if (!renderedThunk) {\n renderedThunk = thunk.vnode = thunk.render(previous)\n }\n\n if (!(isVNode(renderedThunk) ||\n isVText(renderedThunk) ||\n isWidget(renderedThunk))) {\n throw new Error("thunk did not return a valid node");\n }\n\n return renderedThunk\n}\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/virtual-dom/vnode/handle-thunk.js\n ** module id = 19\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/virtual-dom/vnode/handle-thunk.js?')},function(module,exports){eval('module.exports = isThunk\r\n\r\nfunction isThunk(t) {\r\n return t && t.type === "Thunk"\r\n}\r\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/virtual-dom/vnode/is-thunk.js\n ** module id = 20\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/virtual-dom/vnode/is-thunk.js?')},function(module,exports,__webpack_require__){eval("var diff = __webpack_require__(22)\n\nmodule.exports = diff\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/virtual-dom/diff.js\n ** module id = 21\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/virtual-dom/diff.js?")},function(module,exports,__webpack_require__){eval('var isArray = __webpack_require__(23)\n\nvar VPatch = __webpack_require__(24)\nvar isVNode = __webpack_require__(17)\nvar isVText = __webpack_require__(10)\nvar isWidget = __webpack_require__(18)\nvar isThunk = __webpack_require__(20)\nvar handleThunk = __webpack_require__(19)\n\nvar diffProps = __webpack_require__(25)\n\nmodule.exports = diff\n\nfunction diff(a, b) {\n var patch = { a: a }\n walk(a, b, patch, 0)\n return patch\n}\n\nfunction walk(a, b, patch, index) {\n if (a === b) {\n return\n }\n\n var apply = patch[index]\n var applyClear = false\n\n if (isThunk(a) || isThunk(b)) {\n thunks(a, b, patch, index)\n } else if (b == null) {\n\n // If a is a widget we will add a remove patch for it\n // Otherwise any child widgets/hooks must be destroyed.\n // This prevents adding two remove patches for a widget.\n if (!isWidget(a)) {\n clearState(a, patch, index)\n apply = patch[index]\n }\n\n apply = appendPatch(apply, new VPatch(VPatch.REMOVE, a, b))\n } else if (isVNode(b)) {\n if (isVNode(a)) {\n if (a.tagName === b.tagName &&\n a.namespace === b.namespace &&\n a.key === b.key) {\n var propsPatch = diffProps(a.properties, b.properties)\n if (propsPatch) {\n apply = appendPatch(apply,\n new VPatch(VPatch.PROPS, a, propsPatch))\n }\n apply = diffChildren(a, b, patch, apply, index)\n } else {\n apply = appendPatch(apply, new VPatch(VPatch.VNODE, a, b))\n applyClear = true\n }\n } else {\n apply = appendPatch(apply, new VPatch(VPatch.VNODE, a, b))\n applyClear = true\n }\n } else if (isVText(b)) {\n if (!isVText(a)) {\n apply = appendPatch(apply, new VPatch(VPatch.VTEXT, a, b))\n applyClear = true\n } else if (a.text !== b.text) {\n apply = appendPatch(apply, new VPatch(VPatch.VTEXT, a, b))\n }\n } else if (isWidget(b)) {\n if (!isWidget(a)) {\n applyClear = true\n }\n\n apply = appendPatch(apply, new VPatch(VPatch.WIDGET, a, b))\n }\n\n if (apply) {\n patch[index] = apply\n }\n\n if (applyClear) {\n clearState(a, patch, index)\n }\n}\n\nfunction diffChildren(a, b, patch, apply, index) {\n var aChildren = a.children\n var orderedSet = reorder(aChildren, b.children)\n var bChildren = orderedSet.children\n\n var aLen = aChildren.length\n var bLen = bChildren.length\n var len = aLen > bLen ? aLen : bLen\n\n for (var i = 0; i < len; i++) {\n var leftNode = aChildren[i]\n var rightNode = bChildren[i]\n index += 1\n\n if (!leftNode) {\n if (rightNode) {\n // Excess nodes in b need to be added\n apply = appendPatch(apply,\n new VPatch(VPatch.INSERT, null, rightNode))\n }\n } else {\n walk(leftNode, rightNode, patch, index)\n }\n\n if (isVNode(leftNode) && leftNode.count) {\n index += leftNode.count\n }\n }\n\n if (orderedSet.moves) {\n // Reorder nodes last\n apply = appendPatch(apply, new VPatch(\n VPatch.ORDER,\n a,\n orderedSet.moves\n ))\n }\n\n return apply\n}\n\nfunction clearState(vNode, patch, index) {\n // TODO: Make this a single walk, not two\n unhook(vNode, patch, index)\n destroyWidgets(vNode, patch, index)\n}\n\n// Patch records for all destroyed widgets must be added because we need\n// a DOM node reference for the destroy function\nfunction destroyWidgets(vNode, patch, index) {\n if (isWidget(vNode)) {\n if (typeof vNode.destroy === "function") {\n patch[index] = appendPatch(\n patch[index],\n new VPatch(VPatch.REMOVE, vNode, null)\n )\n }\n } else if (isVNode(vNode) && (vNode.hasWidgets || vNode.hasThunks)) {\n var children = vNode.children\n var len = children.length\n for (var i = 0; i < len; i++) {\n var child = children[i]\n index += 1\n\n destroyWidgets(child, patch, index)\n\n if (isVNode(child) && child.count) {\n index += child.count\n }\n }\n } else if (isThunk(vNode)) {\n thunks(vNode, null, patch, index)\n }\n}\n\n// Create a sub-patch for thunks\nfunction thunks(a, b, patch, index) {\n var nodes = handleThunk(a, b)\n var thunkPatch = diff(nodes.a, nodes.b)\n if (hasPatches(thunkPatch)) {\n patch[index] = new VPatch(VPatch.THUNK, null, thunkPatch)\n }\n}\n\nfunction hasPatches(patch) {\n for (var index in patch) {\n if (index !== "a") {\n return true\n }\n }\n\n return false\n}\n\n// Execute hooks when two nodes are identical\nfunction unhook(vNode, patch, index) {\n if (isVNode(vNode)) {\n if (vNode.hooks) {\n patch[index] = appendPatch(\n patch[index],\n new VPatch(\n VPatch.PROPS,\n vNode,\n undefinedKeys(vNode.hooks)\n )\n )\n }\n\n if (vNode.descendantHooks || vNode.hasThunks) {\n var children = vNode.children\n var len = children.length\n for (var i = 0; i < len; i++) {\n var child = children[i]\n index += 1\n\n unhook(child, patch, index)\n\n if (isVNode(child) && child.count) {\n index += child.count\n }\n }\n }\n } else if (isThunk(vNode)) {\n thunks(vNode, null, patch, index)\n }\n}\n\nfunction undefinedKeys(obj) {\n var result = {}\n\n for (var key in obj) {\n result[key] = undefined\n }\n\n return result\n}\n\n// List diff, naive left to right reordering\nfunction reorder(aChildren, bChildren) {\n // O(M) time, O(M) memory\n var bChildIndex = keyIndex(bChildren)\n var bKeys = bChildIndex.keys\n var bFree = bChildIndex.free\n\n if (bFree.length === bChildren.length) {\n return {\n children: bChildren,\n moves: null\n }\n }\n\n // O(N) time, O(N) memory\n var aChildIndex = keyIndex(aChildren)\n var aKeys = aChildIndex.keys\n var aFree = aChildIndex.free\n\n if (aFree.length === aChildren.length) {\n return {\n children: bChildren,\n moves: null\n }\n }\n\n // O(MAX(N, M)) memory\n var newChildren = []\n\n var freeIndex = 0\n var freeCount = bFree.length\n var deletedItems = 0\n\n // Iterate through a and match a node in b\n // O(N) time,\n for (var i = 0 ; i < aChildren.length; i++) {\n var aItem = aChildren[i]\n var itemIndex\n\n if (aItem.key) {\n if (bKeys.hasOwnProperty(aItem.key)) {\n // Match up the old keys\n itemIndex = bKeys[aItem.key]\n newChildren.push(bChildren[itemIndex])\n\n } else {\n // Remove old keyed items\n itemIndex = i - deletedItems++\n newChildren.push(null)\n }\n } else {\n // Match the item in a with the next free item in b\n if (freeIndex < freeCount) {\n itemIndex = bFree[freeIndex++]\n newChildren.push(bChildren[itemIndex])\n } else {\n // There are no free items in b to match with\n // the free items in a, so the extra free nodes\n // are deleted.\n itemIndex = i - deletedItems++\n newChildren.push(null)\n }\n }\n }\n\n var lastFreeIndex = freeIndex >= bFree.length ?\n bChildren.length :\n bFree[freeIndex]\n\n // Iterate through b and append any new keys\n // O(M) time\n for (var j = 0; j < bChildren.length; j++) {\n var newItem = bChildren[j]\n\n if (newItem.key) {\n if (!aKeys.hasOwnProperty(newItem.key)) {\n // Add any new keyed items\n // We are adding new items to the end and then sorting them\n // in place. In future we should insert new items in place.\n newChildren.push(newItem)\n }\n } else if (j >= lastFreeIndex) {\n // Add any leftover non-keyed items\n newChildren.push(newItem)\n }\n }\n\n var simulate = newChildren.slice()\n var simulateIndex = 0\n var removes = []\n var inserts = []\n var simulateItem\n\n for (var k = 0; k < bChildren.length;) {\n var wantedItem = bChildren[k]\n simulateItem = simulate[simulateIndex]\n\n // remove items\n while (simulateItem === null && simulate.length) {\n removes.push(remove(simulate, simulateIndex, null))\n simulateItem = simulate[simulateIndex]\n }\n\n if (!simulateItem || simulateItem.key !== wantedItem.key) {\n // if we need a key in this position...\n if (wantedItem.key) {\n if (simulateItem && simulateItem.key) {\n // if an insert doesn\'t put this key in place, it needs to move\n if (bKeys[simulateItem.key] !== k + 1) {\n removes.push(remove(simulate, simulateIndex, simulateItem.key))\n simulateItem = simulate[simulateIndex]\n // if the remove didn\'t put the wanted item in place, we need to insert it\n if (!simulateItem || simulateItem.key !== wantedItem.key) {\n inserts.push({key: wantedItem.key, to: k})\n }\n // items are matching, so skip ahead\n else {\n simulateIndex++\n }\n }\n else {\n inserts.push({key: wantedItem.key, to: k})\n }\n }\n else {\n inserts.push({key: wantedItem.key, to: k})\n }\n k++\n }\n // a key in simulate has no matching wanted key, remove it\n else if (simulateItem && simulateItem.key) {\n removes.push(remove(simulate, simulateIndex, simulateItem.key))\n }\n }\n else {\n simulateIndex++\n k++\n }\n }\n\n // remove all the remaining nodes from simulate\n while(simulateIndex < simulate.length) {\n simulateItem = simulate[simulateIndex]\n removes.push(remove(simulate, simulateIndex, simulateItem && simulateItem.key))\n }\n\n // If the only moves we have are deletes then we can just\n // let the delete patch remove these items.\n if (removes.length === deletedItems && !inserts.length) {\n return {\n children: newChildren,\n moves: null\n }\n }\n\n return {\n children: newChildren,\n moves: {\n removes: removes,\n inserts: inserts\n }\n }\n}\n\nfunction remove(arr, index, key) {\n arr.splice(index, 1)\n\n return {\n from: index,\n key: key\n }\n}\n\nfunction keyIndex(children) {\n var keys = {}\n var free = []\n var length = children.length\n\n for (var i = 0; i < length; i++) {\n var child = children[i]\n\n if (child.key) {\n keys[child.key] = i\n } else {\n free.push(i)\n }\n }\n\n return {\n keys: keys, // A hash of key name to index\n free: free, // An array of unkeyed item indices\n }\n}\n\nfunction appendPatch(apply, patch) {\n if (apply) {\n if (isArray(apply)) {\n apply.push(patch)\n } else {\n apply = [apply, patch]\n }\n\n return apply\n } else {\n return patch\n }\n}\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/virtual-dom/vtree/diff.js\n ** module id = 22\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/virtual-dom/vtree/diff.js?')},function(module,exports){eval('var nativeIsArray = Array.isArray\nvar toString = Object.prototype.toString\n\nmodule.exports = nativeIsArray || isArray\n\nfunction isArray(obj) {\n return toString.call(obj) === "[object Array]"\n}\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/virtual-dom/~/x-is-array/index.js\n ** module id = 23\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/virtual-dom/~/x-is-array/index.js?')},function(module,exports,__webpack_require__){eval('var version = __webpack_require__(11)\n\nVirtualPatch.NONE = 0\nVirtualPatch.VTEXT = 1\nVirtualPatch.VNODE = 2\nVirtualPatch.WIDGET = 3\nVirtualPatch.PROPS = 4\nVirtualPatch.ORDER = 5\nVirtualPatch.INSERT = 6\nVirtualPatch.REMOVE = 7\nVirtualPatch.THUNK = 8\n\nmodule.exports = VirtualPatch\n\nfunction VirtualPatch(type, vNode, patch) {\n this.type = Number(type)\n this.vNode = vNode\n this.patch = patch\n}\n\nVirtualPatch.prototype.version = version\nVirtualPatch.prototype.type = "VirtualPatch"\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/virtual-dom/vnode/vpatch.js\n ** module id = 24\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/virtual-dom/vnode/vpatch.js?')},function(module,exports,__webpack_require__){eval("var isObject = __webpack_require__(15)\nvar isHook = __webpack_require__(16)\n\nmodule.exports = diffProps\n\nfunction diffProps(a, b) {\n var diff\n\n for (var aKey in a) {\n if (!(aKey in b)) {\n diff = diff || {}\n diff[aKey] = undefined\n }\n\n var aValue = a[aKey]\n var bValue = b[aKey]\n\n if (aValue === bValue) {\n continue\n } else if (isObject(aValue) && isObject(bValue)) {\n if (getPrototype(bValue) !== getPrototype(aValue)) {\n diff = diff || {}\n diff[aKey] = bValue\n } else if (isHook(bValue)) {\n diff = diff || {}\n diff[aKey] = bValue\n } else {\n var objectDiff = diffProps(aValue, bValue)\n if (objectDiff) {\n diff = diff || {}\n diff[aKey] = objectDiff\n }\n }\n } else {\n diff = diff || {}\n diff[aKey] = bValue\n }\n }\n\n for (var bKey in b) {\n if (!(bKey in a)) {\n diff = diff || {}\n diff[bKey] = b[bKey]\n }\n }\n\n return diff\n}\n\nfunction getPrototype(value) {\n if (Object.getPrototypeOf) {\n return Object.getPrototypeOf(value)\n } else if (value.__proto__) {\n return value.__proto__\n } else if (value.constructor) {\n return value.constructor.prototype\n }\n}\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/virtual-dom/vtree/diff-props.js\n ** module id = 25\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/virtual-dom/vtree/diff-props.js?")},function(module,exports,__webpack_require__){eval("var patch = __webpack_require__(27)\n\nmodule.exports = patch\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/virtual-dom/patch.js\n ** module id = 26\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/virtual-dom/patch.js?")},function(module,exports,__webpack_require__){eval('var document = __webpack_require__(12)\nvar isArray = __webpack_require__(23)\n\nvar domIndex = __webpack_require__(28)\nvar patchOp = __webpack_require__(29)\nmodule.exports = patch\n\nfunction patch(rootNode, patches) {\n return patchRecursive(rootNode, patches)\n}\n\nfunction patchRecursive(rootNode, patches, renderOptions) {\n var indices = patchIndices(patches)\n\n if (indices.length === 0) {\n return rootNode\n }\n\n var index = domIndex(rootNode, patches.a, indices)\n var ownerDocument = rootNode.ownerDocument\n\n if (!renderOptions) {\n renderOptions = { patch: patchRecursive }\n if (ownerDocument !== document) {\n renderOptions.document = ownerDocument\n }\n }\n\n for (var i = 0; i < indices.length; i++) {\n var nodeIndex = indices[i]\n rootNode = applyPatch(rootNode,\n index[nodeIndex],\n patches[nodeIndex],\n renderOptions)\n }\n\n return rootNode\n}\n\nfunction applyPatch(rootNode, domNode, patchList, renderOptions) {\n if (!domNode) {\n return rootNode\n }\n\n var newNode\n\n if (isArray(patchList)) {\n for (var i = 0; i < patchList.length; i++) {\n newNode = patchOp(patchList[i], domNode, renderOptions)\n\n if (domNode === rootNode) {\n rootNode = newNode\n }\n }\n } else {\n newNode = patchOp(patchList, domNode, renderOptions)\n\n if (domNode === rootNode) {\n rootNode = newNode\n }\n }\n\n return rootNode\n}\n\nfunction patchIndices(patches) {\n var indices = []\n\n for (var key in patches) {\n if (key !== "a") {\n indices.push(Number(key))\n }\n }\n\n return indices\n}\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/virtual-dom/vdom/patch.js\n ** module id = 27\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/virtual-dom/vdom/patch.js?')},function(module,exports){eval("// Maps a virtual DOM tree onto a real DOM tree in an efficient manner.\n// We don't want to read all of the DOM nodes in the tree so we use\n// the in-order tree indexing to eliminate recursion down certain branches.\n// We only recurse into a DOM node if we know that it contains a child of\n// interest.\n\nvar noChild = {}\n\nmodule.exports = domIndex\n\nfunction domIndex(rootNode, tree, indices, nodes) {\n if (!indices || indices.length === 0) {\n return {}\n } else {\n indices.sort(ascending)\n return recurse(rootNode, tree, indices, nodes, 0)\n }\n}\n\nfunction recurse(rootNode, tree, indices, nodes, rootIndex) {\n nodes = nodes || {}\n\n\n if (rootNode) {\n if (indexInRange(indices, rootIndex, rootIndex)) {\n nodes[rootIndex] = rootNode\n }\n\n var vChildren = tree.children\n\n if (vChildren) {\n\n var childNodes = rootNode.childNodes\n\n for (var i = 0; i < tree.children.length; i++) {\n rootIndex += 1\n\n var vChild = vChildren[i] || noChild\n var nextIndex = rootIndex + (vChild.count || 0)\n\n // skip recursion down the tree if there are no nodes down here\n if (indexInRange(indices, rootIndex, nextIndex)) {\n recurse(childNodes[i], vChild, indices, nodes, rootIndex)\n }\n\n rootIndex = nextIndex\n }\n }\n }\n\n return nodes\n}\n\n// Binary search for an index in the interval [left, right]\nfunction indexInRange(indices, left, right) {\n if (indices.length === 0) {\n return false\n }\n\n var minIndex = 0\n var maxIndex = indices.length - 1\n var currentIndex\n var currentItem\n\n while (minIndex <= maxIndex) {\n currentIndex = ((maxIndex + minIndex) / 2) >> 0\n currentItem = indices[currentIndex]\n\n if (minIndex === maxIndex) {\n return currentItem >= left && currentItem <= right\n } else if (currentItem < left) {\n minIndex = currentIndex + 1\n } else if (currentItem > right) {\n maxIndex = currentIndex - 1\n } else {\n return true\n }\n }\n\n return false;\n}\n\nfunction ascending(a, b) {\n return a > b ? 1 : -1\n}\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/virtual-dom/vdom/dom-index.js\n ** module id = 28\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/virtual-dom/vdom/dom-index.js?");
  3. },function(module,exports,__webpack_require__){eval('var applyProperties = __webpack_require__(14)\n\nvar isWidget = __webpack_require__(18)\nvar VPatch = __webpack_require__(24)\n\nvar render = __webpack_require__(9)\nvar updateWidget = __webpack_require__(30)\n\nmodule.exports = applyPatch\n\nfunction applyPatch(vpatch, domNode, renderOptions) {\n var type = vpatch.type\n var vNode = vpatch.vNode\n var patch = vpatch.patch\n\n switch (type) {\n case VPatch.REMOVE:\n return removeNode(domNode, vNode)\n case VPatch.INSERT:\n return insertNode(domNode, patch, renderOptions)\n case VPatch.VTEXT:\n return stringPatch(domNode, vNode, patch, renderOptions)\n case VPatch.WIDGET:\n return widgetPatch(domNode, vNode, patch, renderOptions)\n case VPatch.VNODE:\n return vNodePatch(domNode, vNode, patch, renderOptions)\n case VPatch.ORDER:\n reorderChildren(domNode, patch)\n return domNode\n case VPatch.PROPS:\n applyProperties(domNode, patch, vNode.properties)\n return domNode\n case VPatch.THUNK:\n return replaceRoot(domNode,\n renderOptions.patch(domNode, patch, renderOptions))\n default:\n return domNode\n }\n}\n\nfunction removeNode(domNode, vNode) {\n var parentNode = domNode.parentNode\n\n if (parentNode) {\n parentNode.removeChild(domNode)\n }\n\n destroyWidget(domNode, vNode);\n\n return null\n}\n\nfunction insertNode(parentNode, vNode, renderOptions) {\n var newNode = render(vNode, renderOptions)\n\n if (parentNode) {\n parentNode.appendChild(newNode)\n }\n\n return parentNode\n}\n\nfunction stringPatch(domNode, leftVNode, vText, renderOptions) {\n var newNode\n\n if (domNode.nodeType === 3) {\n domNode.replaceData(0, domNode.length, vText.text)\n newNode = domNode\n } else {\n var parentNode = domNode.parentNode\n newNode = render(vText, renderOptions)\n\n if (parentNode && newNode !== domNode) {\n parentNode.replaceChild(newNode, domNode)\n }\n }\n\n return newNode\n}\n\nfunction widgetPatch(domNode, leftVNode, widget, renderOptions) {\n var updating = updateWidget(leftVNode, widget)\n var newNode\n\n if (updating) {\n newNode = widget.update(leftVNode, domNode) || domNode\n } else {\n newNode = render(widget, renderOptions)\n }\n\n var parentNode = domNode.parentNode\n\n if (parentNode && newNode !== domNode) {\n parentNode.replaceChild(newNode, domNode)\n }\n\n if (!updating) {\n destroyWidget(domNode, leftVNode)\n }\n\n return newNode\n}\n\nfunction vNodePatch(domNode, leftVNode, vNode, renderOptions) {\n var parentNode = domNode.parentNode\n var newNode = render(vNode, renderOptions)\n\n if (parentNode && newNode !== domNode) {\n parentNode.replaceChild(newNode, domNode)\n }\n\n return newNode\n}\n\nfunction destroyWidget(domNode, w) {\n if (typeof w.destroy === "function" && isWidget(w)) {\n w.destroy(domNode)\n }\n}\n\nfunction reorderChildren(domNode, moves) {\n var childNodes = domNode.childNodes\n var keyMap = {}\n var node\n var remove\n var insert\n\n for (var i = 0; i < moves.removes.length; i++) {\n remove = moves.removes[i]\n node = childNodes[remove.from]\n if (remove.key) {\n keyMap[remove.key] = node\n }\n domNode.removeChild(node)\n }\n\n var length = childNodes.length\n for (var j = 0; j < moves.inserts.length; j++) {\n insert = moves.inserts[j]\n node = keyMap[insert.key]\n // this is the weirdest bug i\'ve ever seen in webkit\n domNode.insertBefore(node, insert.to >= length++ ? null : childNodes[insert.to])\n }\n}\n\nfunction replaceRoot(oldRoot, newRoot) {\n if (oldRoot && newRoot && oldRoot !== newRoot && oldRoot.parentNode) {\n oldRoot.parentNode.replaceChild(newRoot, oldRoot)\n }\n\n return newRoot;\n}\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/virtual-dom/vdom/patch-op.js\n ** module id = 29\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/virtual-dom/vdom/patch-op.js?')},function(module,exports,__webpack_require__){eval('var isWidget = __webpack_require__(18)\n\nmodule.exports = updateWidget\n\nfunction updateWidget(a, b) {\n if (isWidget(a) && isWidget(b)) {\n if ("name" in a && "name" in b) {\n return a.id === b.id\n } else {\n return a.init === b.init\n }\n }\n\n return false\n}\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/virtual-dom/vdom/update-widget.js\n ** module id = 30\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/virtual-dom/vdom/update-widget.js?')},function(module,exports,__webpack_require__){eval("var h = __webpack_require__(32)\n\nmodule.exports = h\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/virtual-dom/h.js\n ** module id = 31\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/virtual-dom/h.js?")},function(module,exports,__webpack_require__){eval("'use strict';\n\nvar isArray = __webpack_require__(23);\n\nvar VNode = __webpack_require__(33);\nvar VText = __webpack_require__(34);\nvar isVNode = __webpack_require__(17);\nvar isVText = __webpack_require__(10);\nvar isWidget = __webpack_require__(18);\nvar isHook = __webpack_require__(16);\nvar isVThunk = __webpack_require__(20);\n\nvar parseTag = __webpack_require__(35);\nvar softSetHook = __webpack_require__(37);\nvar evHook = __webpack_require__(38);\n\nmodule.exports = h;\n\nfunction h(tagName, properties, children) {\n var childNodes = [];\n var tag, props, key, namespace;\n\n if (!children && isChildren(properties)) {\n children = properties;\n props = {};\n }\n\n props = props || properties || {};\n tag = parseTag(tagName, props);\n\n // support keys\n if (props.hasOwnProperty('key')) {\n key = props.key;\n props.key = undefined;\n }\n\n // support namespace\n if (props.hasOwnProperty('namespace')) {\n namespace = props.namespace;\n props.namespace = undefined;\n }\n\n // fix cursor bug\n if (tag === 'INPUT' &&\n !namespace &&\n props.hasOwnProperty('value') &&\n props.value !== undefined &&\n !isHook(props.value)\n ) {\n props.value = softSetHook(props.value);\n }\n\n transformProperties(props);\n\n if (children !== undefined && children !== null) {\n addChild(children, childNodes, tag, props);\n }\n\n\n return new VNode(tag, props, childNodes, key, namespace);\n}\n\nfunction addChild(c, childNodes, tag, props) {\n if (typeof c === 'string') {\n childNodes.push(new VText(c));\n } else if (isChild(c)) {\n childNodes.push(c);\n } else if (isArray(c)) {\n for (var i = 0; i < c.length; i++) {\n addChild(c[i], childNodes, tag, props);\n }\n } else if (c === null || c === undefined) {\n return;\n } else {\n throw UnexpectedVirtualElement({\n foreignObject: c,\n parentVnode: {\n tagName: tag,\n properties: props\n }\n });\n }\n}\n\nfunction transformProperties(props) {\n for (var propName in props) {\n if (props.hasOwnProperty(propName)) {\n var value = props[propName];\n\n if (isHook(value)) {\n continue;\n }\n\n if (propName.substr(0, 3) === 'ev-') {\n // add ev-foo support\n props[propName] = evHook(value);\n }\n }\n }\n}\n\nfunction isChild(x) {\n return isVNode(x) || isVText(x) || isWidget(x) || isVThunk(x);\n}\n\nfunction isChildren(x) {\n return typeof x === 'string' || isArray(x) || isChild(x);\n}\n\nfunction UnexpectedVirtualElement(data) {\n var err = new Error();\n\n err.type = 'virtual-hyperscript.unexpected.virtual-element';\n err.message = 'Unexpected virtual child passed to h().\\n' +\n 'Expected a VNode / Vthunk / VWidget / string but:\\n' +\n 'got:\\n' +\n errorString(data.foreignObject) +\n '.\\n' +\n 'The parent vnode is:\\n' +\n errorString(data.parentVnode)\n '\\n' +\n 'Suggested fix: change your `h(..., [ ... ])` callsite.';\n err.foreignObject = data.foreignObject;\n err.parentVnode = data.parentVnode;\n\n return err;\n}\n\nfunction errorString(obj) {\n try {\n return JSON.stringify(obj, null, ' ');\n } catch (e) {\n return String(obj);\n }\n}\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/virtual-dom/virtual-hyperscript/index.js\n ** module id = 32\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/virtual-dom/virtual-hyperscript/index.js?")},function(module,exports,__webpack_require__){eval('var version = __webpack_require__(11)\nvar isVNode = __webpack_require__(17)\nvar isWidget = __webpack_require__(18)\nvar isThunk = __webpack_require__(20)\nvar isVHook = __webpack_require__(16)\n\nmodule.exports = VirtualNode\n\nvar noProperties = {}\nvar noChildren = []\n\nfunction VirtualNode(tagName, properties, children, key, namespace) {\n this.tagName = tagName\n this.properties = properties || noProperties\n this.children = children || noChildren\n this.key = key != null ? String(key) : undefined\n this.namespace = (typeof namespace === "string") ? namespace : null\n\n var count = (children && children.length) || 0\n var descendants = 0\n var hasWidgets = false\n var hasThunks = false\n var descendantHooks = false\n var hooks\n\n for (var propName in properties) {\n if (properties.hasOwnProperty(propName)) {\n var property = properties[propName]\n if (isVHook(property) && property.unhook) {\n if (!hooks) {\n hooks = {}\n }\n\n hooks[propName] = property\n }\n }\n }\n\n for (var i = 0; i < count; i++) {\n var child = children[i]\n if (isVNode(child)) {\n descendants += child.count || 0\n\n if (!hasWidgets && child.hasWidgets) {\n hasWidgets = true\n }\n\n if (!hasThunks && child.hasThunks) {\n hasThunks = true\n }\n\n if (!descendantHooks && (child.hooks || child.descendantHooks)) {\n descendantHooks = true\n }\n } else if (!hasWidgets && isWidget(child)) {\n if (typeof child.destroy === "function") {\n hasWidgets = true\n }\n } else if (!hasThunks && isThunk(child)) {\n hasThunks = true;\n }\n }\n\n this.count = count + descendants\n this.hasWidgets = hasWidgets\n this.hasThunks = hasThunks\n this.hooks = hooks\n this.descendantHooks = descendantHooks\n}\n\nVirtualNode.prototype.version = version\nVirtualNode.prototype.type = "VirtualNode"\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/virtual-dom/vnode/vnode.js\n ** module id = 33\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/virtual-dom/vnode/vnode.js?')},function(module,exports,__webpack_require__){eval('var version = __webpack_require__(11)\n\nmodule.exports = VirtualText\n\nfunction VirtualText(text) {\n this.text = String(text)\n}\n\nVirtualText.prototype.version = version\nVirtualText.prototype.type = "VirtualText"\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/virtual-dom/vnode/vtext.js\n ** module id = 34\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/virtual-dom/vnode/vtext.js?')},function(module,exports,__webpack_require__){eval("'use strict';\n\nvar split = __webpack_require__(36);\n\nvar classIdSplit = /([\\.#]?[a-zA-Z0-9_:-]+)/;\nvar notClassId = /^\\.|#/;\n\nmodule.exports = parseTag;\n\nfunction parseTag(tag, props) {\n if (!tag) {\n return 'DIV';\n }\n\n var noId = !(props.hasOwnProperty('id'));\n\n var tagParts = split(tag, classIdSplit);\n var tagName = null;\n\n if (notClassId.test(tagParts[1])) {\n tagName = 'DIV';\n }\n\n var classes, part, type, i;\n\n for (i = 0; i < tagParts.length; i++) {\n part = tagParts[i];\n\n if (!part) {\n continue;\n }\n\n type = part.charAt(0);\n\n if (!tagName) {\n tagName = part;\n } else if (type === '.') {\n classes = classes || [];\n classes.push(part.substring(1, part.length));\n } else if (type === '#' && noId) {\n props.id = part.substring(1, part.length);\n }\n }\n\n if (classes) {\n if (props.className) {\n classes.push(props.className);\n }\n\n props.className = classes.join(' ');\n }\n\n return props.namespace ? tagName : tagName.toUpperCase();\n}\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/virtual-dom/virtual-hyperscript/parse-tag.js\n ** module id = 35\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/virtual-dom/virtual-hyperscript/parse-tag.js?")},function(module,exports){eval("/*!\n * Cross-Browser Split 1.1.1\n * Copyright 2007-2012 Steven Levithan <stevenlevithan.com>\n * Available under the MIT License\n * ECMAScript compliant, uniform cross-browser split method\n */\n\n/**\n * Splits a string into an array of strings using a regex or string separator. Matches of the\n * separator are not included in the result array. However, if `separator` is a regex that contains\n * capturing groups, backreferences are spliced into the result each time `separator` is matched.\n * Fixes browser bugs compared to the native `String.prototype.split` and can be used reliably\n * cross-browser.\n * @param {String} str String to split.\n * @param {RegExp|String} separator Regex or string to use for separating the string.\n * @param {Number} [limit] Maximum number of items to include in the result array.\n * @returns {Array} Array of substrings.\n * @example\n *\n * // Basic use\n * split('a b c d', ' ');\n * // -> ['a', 'b', 'c', 'd']\n *\n * // With limit\n * split('a b c d', ' ', 2);\n * // -> ['a', 'b']\n *\n * // Backreferences in result array\n * split('..word1 word2..', /([a-z]+)(\\d+)/i);\n * // -> ['..', 'word', '1', ' ', 'word', '2', '..']\n */\nmodule.exports = (function split(undef) {\n\n var nativeSplit = String.prototype.split,\n compliantExecNpcg = /()??/.exec(\"\")[1] === undef,\n // NPCG: nonparticipating capturing group\n self;\n\n self = function(str, separator, limit) {\n // If `separator` is not a regex, use `nativeSplit`\n if (Object.prototype.toString.call(separator) !== \"[object RegExp]\") {\n return nativeSplit.call(str, separator, limit);\n }\n var output = [],\n flags = (separator.ignoreCase ? \"i\" : \"\") + (separator.multiline ? \"m\" : \"\") + (separator.extended ? \"x\" : \"\") + // Proposed for ES6\n (separator.sticky ? \"y\" : \"\"),\n // Firefox 3+\n lastLastIndex = 0,\n // Make `global` and avoid `lastIndex` issues by working with a copy\n separator = new RegExp(separator.source, flags + \"g\"),\n separator2, match, lastIndex, lastLength;\n str += \"\"; // Type-convert\n if (!compliantExecNpcg) {\n // Doesn't need flags gy, but they don't hurt\n separator2 = new RegExp(\"^\" + separator.source + \"$(?!\\\\s)\", flags);\n }\n /* Values for `limit`, per the spec:\n * If undefined: 4294967295 // Math.pow(2, 32) - 1\n * If 0, Infinity, or NaN: 0\n * If positive number: limit = Math.floor(limit); if (limit > 4294967295) limit -= 4294967296;\n * If negative number: 4294967296 - Math.floor(Math.abs(limit))\n * If other: Type-convert, then use the above rules\n */\n limit = limit === undef ? -1 >>> 0 : // Math.pow(2, 32) - 1\n limit >>> 0; // ToUint32(limit)\n while (match = separator.exec(str)) {\n // `separator.lastIndex` is not reliable cross-browser\n lastIndex = match.index + match[0].length;\n if (lastIndex > lastLastIndex) {\n output.push(str.slice(lastLastIndex, match.index));\n // Fix browsers whose `exec` methods don't consistently return `undefined` for\n // nonparticipating capturing groups\n if (!compliantExecNpcg && match.length > 1) {\n match[0].replace(separator2, function() {\n for (var i = 1; i < arguments.length - 2; i++) {\n if (arguments[i] === undef) {\n match[i] = undef;\n }\n }\n });\n }\n if (match.length > 1 && match.index < str.length) {\n Array.prototype.push.apply(output, match.slice(1));\n }\n lastLength = match[0].length;\n lastLastIndex = lastIndex;\n if (output.length >= limit) {\n break;\n }\n }\n if (separator.lastIndex === match.index) {\n separator.lastIndex++; // Avoid an infinite loop\n }\n }\n if (lastLastIndex === str.length) {\n if (lastLength || !separator.test(\"\")) {\n output.push(\"\");\n }\n } else {\n output.push(str.slice(lastLastIndex));\n }\n return output.length > limit ? output.slice(0, limit) : output;\n };\n\n return self;\n})();\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/virtual-dom/~/browser-split/index.js\n ** module id = 36\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/virtual-dom/~/browser-split/index.js?")},function(module,exports){eval("'use strict';\n\nmodule.exports = SoftSetHook;\n\nfunction SoftSetHook(value) {\n if (!(this instanceof SoftSetHook)) {\n return new SoftSetHook(value);\n }\n\n this.value = value;\n}\n\nSoftSetHook.prototype.hook = function (node, propertyName) {\n if (node[propertyName] !== this.value) {\n node[propertyName] = this.value;\n }\n};\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/virtual-dom/virtual-hyperscript/hooks/soft-set-hook.js\n ** module id = 37\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/virtual-dom/virtual-hyperscript/hooks/soft-set-hook.js?")},function(module,exports,__webpack_require__){eval("'use strict';\n\nvar EvStore = __webpack_require__(39);\n\nmodule.exports = EvHook;\n\nfunction EvHook(value) {\n if (!(this instanceof EvHook)) {\n return new EvHook(value);\n }\n\n this.value = value;\n}\n\nEvHook.prototype.hook = function (node, propertyName) {\n var es = EvStore(node);\n var propName = propertyName.substr(3);\n\n es[propName] = this.value;\n};\n\nEvHook.prototype.unhook = function(node, propertyName) {\n var es = EvStore(node);\n var propName = propertyName.substr(3);\n\n es[propName] = undefined;\n};\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/virtual-dom/virtual-hyperscript/hooks/ev-hook.js\n ** module id = 38\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/virtual-dom/virtual-hyperscript/hooks/ev-hook.js?")},function(module,exports,__webpack_require__){eval("'use strict';\n\nvar OneVersionConstraint = __webpack_require__(40);\n\nvar MY_VERSION = '7';\nOneVersionConstraint('ev-store', MY_VERSION);\n\nvar hashKey = '__EV_STORE_KEY@' + MY_VERSION;\n\nmodule.exports = EvStore;\n\nfunction EvStore(elem) {\n var hash = elem[hashKey];\n\n if (!hash) {\n hash = elem[hashKey] = {};\n }\n\n return hash;\n}\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/virtual-dom/~/ev-store/index.js\n ** module id = 39\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/virtual-dom/~/ev-store/index.js?")},function(module,exports,__webpack_require__){eval("'use strict';\n\nvar Individual = __webpack_require__(41);\n\nmodule.exports = OneVersion;\n\nfunction OneVersion(moduleName, version, defaultValue) {\n var key = '__INDIVIDUAL_ONE_VERSION_' + moduleName;\n var enforceKey = key + '_ENFORCE_SINGLETON';\n\n var versionValue = Individual(enforceKey, version);\n\n if (versionValue !== version) {\n throw new Error('Can only have one copy of ' +\n moduleName + '.\\n' +\n 'You already have version ' + versionValue +\n ' installed.\\n' +\n 'This means you cannot install version ' + version);\n }\n\n return Individual(key, defaultValue);\n}\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/virtual-dom/~/ev-store/~/individual/one-version.js\n ** module id = 40\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/virtual-dom/~/ev-store/~/individual/one-version.js?")},function(module,exports){eval("/* WEBPACK VAR INJECTION */(function(global) {'use strict';\n\n/*global window, global*/\n\nvar root = typeof window !== 'undefined' ?\n window : typeof global !== 'undefined' ?\n global : {};\n\nmodule.exports = Individual;\n\nfunction Individual(key, value) {\n if (key in root) {\n return root[key];\n }\n\n root[key] = value;\n\n return value;\n}\n\n/* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }())))\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/virtual-dom/~/ev-store/~/individual/index.js\n ** module id = 41\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/virtual-dom/~/ev-store/~/individual/index.js?")},function(module,exports,__webpack_require__){eval("'use strict';\n\nvar _require = __webpack_require__(43);\n\nvar makeWidgetClass = _require.makeWidgetClass;\n\nvar Map = Map || __webpack_require__(44); // eslint-disable-line no-native-reassign\n\nfunction replaceCustomElementsWithSomething(vtree, registry, toSomethingFn) {\n // Silently ignore corner cases\n if (!vtree) {\n return vtree;\n }\n var tagName = (vtree.tagName || '').toUpperCase();\n // Replace vtree itself\n if (tagName && registry.has(tagName)) {\n var WidgetClass = registry.get(tagName);\n return toSomethingFn(vtree, WidgetClass);\n }\n // Or replace children recursively\n if (Array.isArray(vtree.children)) {\n for (var i = vtree.children.length - 1; i >= 0; i--) {\n vtree.children[i] = replaceCustomElementsWithSomething(vtree.children[i], registry, toSomethingFn);\n }\n }\n return vtree;\n}\n\nfunction makeCustomElementsRegistry(definitions) {\n var registry = new Map();\n for (var tagName in definitions) {\n if (definitions.hasOwnProperty(tagName)) {\n registry.set(tagName.toUpperCase(), makeWidgetClass(tagName, definitions[tagName]));\n }\n }\n return registry;\n}\n\nmodule.exports = {\n replaceCustomElementsWithSomething: replaceCustomElementsWithSomething,\n makeCustomElementsRegistry: makeCustomElementsRegistry\n};\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/lib/web/custom-elements.js\n ** module id = 42\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/lib/web/custom-elements.js?")},function(module,exports,__webpack_require__){eval("'use strict';\n\nfunction _defineProperty(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); }\n\nvar Rx = __webpack_require__(4);\nvar ALL_PROPS = '*';\nvar PROPS_DRIVER_NAME = 'props';\nvar EVENTS_SINK_NAME = 'events';\n\nfunction makeDispatchFunction(element, eventName) {\n return function dispatchCustomEvent(evData) {\n //console.log('%cdispatchCustomEvent ' + eventName,\n // 'background-color: #CCCCFF; color: black');\n var event = undefined;\n try {\n event = new Event(eventName);\n } catch (err) {\n event = document.createEvent('Event');\n event.initEvent(eventName, true, true);\n }\n event.detail = evData;\n element.dispatchEvent(event);\n };\n}\n\nfunction subscribeDispatchers(element) {\n var customEvents = element.cycleCustomElementMetadata.customEvents;\n\n var disposables = new Rx.CompositeDisposable();\n for (var _name in customEvents) {\n if (customEvents.hasOwnProperty(_name)) {\n if (typeof customEvents[_name].subscribe === 'function') {\n var disposable = customEvents[_name].subscribe(makeDispatchFunction(element, _name));\n disposables.add(disposable);\n }\n }\n }\n return disposables;\n}\n\nfunction subscribeDispatchersWhenRootChanges(metadata) {\n return metadata.rootElem$.distinctUntilChanged(Rx.helpers.identity, function (x, y) {\n return x && y && x.isEqualNode && x.isEqualNode(y);\n }).subscribe(function resubscribeDispatchers(rootElem) {\n if (metadata.eventDispatchingSubscription) {\n metadata.eventDispatchingSubscription.dispose();\n }\n metadata.eventDispatchingSubscription = subscribeDispatchers(rootElem);\n });\n}\n\nfunction subscribeEventDispatchingSink(element, widget) {\n element.cycleCustomElementMetadata.eventDispatchingSubscription = subscribeDispatchers(element);\n widget.disposables.add(element.cycleCustomElementMetadata.eventDispatchingSubscription);\n widget.disposables.add(subscribeDispatchersWhenRootChanges(element.cycleCustomElementMetadata));\n}\n\nfunction makePropertiesDriver() {\n var propertiesDriver = {};\n var defaultComparer = Rx.helpers.defaultComparer;\n Object.defineProperty(propertiesDriver, 'type', {\n enumerable: false,\n value: 'PropertiesDriver'\n });\n Object.defineProperty(propertiesDriver, 'get', {\n enumerable: false,\n value: function get(streamKey) {\n var comparer = arguments[1] === undefined ? defaultComparer : arguments[1];\n\n if (typeof streamKey === 'undefined') {\n throw new Error('Custom element driver `props.get()` expects an ' + 'argument in the getter.');\n }\n if (typeof this[streamKey] === 'undefined') {\n this[streamKey] = new Rx.ReplaySubject(1);\n }\n return this[streamKey].distinctUntilChanged(Rx.helpers.identity, comparer);\n }\n });\n Object.defineProperty(propertiesDriver, 'getAll', {\n enumerable: false,\n value: function getAll() {\n return this.get(ALL_PROPS);\n }\n });\n return propertiesDriver;\n}\n\nfunction createContainerElement(tagName, vtreeProperties) {\n var element = document.createElement('div');\n element.id = vtreeProperties.id || '';\n element.className = vtreeProperties.className || '';\n element.className += ' cycleCustomElement-' + tagName.toUpperCase();\n return element;\n}\n\nfunction warnIfVTreeHasNoKey(vtree) {\n if (typeof vtree.key === 'undefined') {\n console.warn('Missing `key` property for Cycle custom element ' + vtree.tagName);\n }\n}\n\nfunction throwIfVTreeHasPropertyChildren(vtree) {\n if (typeof vtree.properties.children !== 'undefined') {\n throw new Error('Custom element should not have property `children`. ' + 'It is reserved for children elements nested into this custom element.');\n }\n}\n\nfunction makeCustomElementInput(domOutput, propertiesDriver, domDriverName) {\n var _ref;\n\n return (_ref = {}, _defineProperty(_ref, domDriverName, domOutput), _defineProperty(_ref, PROPS_DRIVER_NAME, propertiesDriver), _ref);\n}\n\nfunction makeConstructor() {\n return function customElementConstructor(vtree, CERegistry, driverName) {\n //console.log('%cnew (constructor) custom element ' + vtree.tagName,\n // 'color: #880088');\n warnIfVTreeHasNoKey(vtree);\n throwIfVTreeHasPropertyChildren(vtree);\n this.type = 'Widget';\n this.properties = vtree.properties;\n this.properties.children = vtree.children;\n this.key = vtree.key;\n this.isCustomElementWidget = true;\n this.customElementsRegistry = CERegistry;\n this.driverName = driverName;\n this.firstRootElem$ = new Rx.ReplaySubject(1);\n this.disposables = new Rx.CompositeDisposable();\n };\n}\n\nfunction validateDefFnOutput(defFnOutput, domDriverName, tagName) {\n if (typeof defFnOutput !== 'object') {\n throw new Error('Custom element definition function for \\'' + tagName + '\\' ' + ' should output an object.');\n }\n if (typeof defFnOutput[domDriverName] === 'undefined') {\n throw new Error('Custom element definition function for \\'' + tagName + '\\' ' + ('should output an object containing \\'' + domDriverName + '\\'.'));\n }\n if (typeof defFnOutput[domDriverName].subscribe !== 'function') {\n throw new Error('Custom element definition function for \\'' + tagName + '\\' ' + 'should output an object containing an Observable of VTree, named ' + ('\\'' + domDriverName + '\\'.'));\n }\n for (var _name2 in defFnOutput) {\n if (defFnOutput.hasOwnProperty(_name2)) {\n if (_name2 !== domDriverName && _name2 !== EVENTS_SINK_NAME) {\n throw new Error('Unknown \\'' + _name2 + '\\' found on custom element ' + ('\\'' + tagName + '\\'s definition function\\'s output.'));\n }\n }\n }\n}\n\nfunction makeInit(tagName, definitionFn) {\n var _require = __webpack_require__(3);\n\n var makeDOMDriverWithRegistry = _require.makeDOMDriverWithRegistry;\n\n return function initCustomElement() {\n //console.log('%cInit() custom element ' + tagName, 'color: #880088');\n var widget = this;\n var driverName = widget.driverName;\n var registry = widget.customElementsRegistry;\n var element = createContainerElement(tagName, widget.properties);\n var proxyVTree$$ = new Rx.AsyncSubject();\n var domDriver = makeDOMDriverWithRegistry(element, registry);\n var propertiesDriver = makePropertiesDriver();\n var domResponse = domDriver(proxyVTree$$.mergeAll(), driverName);\n var rootElem$ = domResponse.get(':root');\n var defFnInput = makeCustomElementInput(domResponse, propertiesDriver, driverName);\n var requests = definitionFn(defFnInput);\n validateDefFnOutput(requests, driverName, tagName);\n proxyVTree$$.onNext(requests[driverName].shareReplay(1));\n proxyVTree$$.onCompleted();\n rootElem$.subscribe(widget.firstRootElem$.asObserver());\n element.cycleCustomElementMetadata = {\n propertiesDriver: propertiesDriver,\n rootElem$: rootElem$,\n customEvents: requests.events,\n eventDispatchingSubscription: false\n };\n subscribeEventDispatchingSink(element, widget);\n widget.disposables.add(widget.firstRootElem$);\n widget.disposables.add(proxyVTree$$);\n widget.disposables.add(domResponse);\n widget.update(null, element);\n return element;\n };\n}\n\nfunction validatePropertiesDriverInMetadata(element, fnName) {\n if (!element) {\n throw new Error('Missing DOM element when calling ' + fnName + ' on custom ' + 'element Widget.');\n }\n if (!element.cycleCustomElementMetadata) {\n throw new Error('Missing custom element metadata on DOM element when ' + 'calling ' + fnName + ' on custom element Widget.');\n }\n var metadata = element.cycleCustomElementMetadata;\n if (metadata.propertiesDriver.type !== 'PropertiesDriver') {\n throw new Error('Custom element metadata\\'s propertiesDriver type is ' + 'invalid: ' + metadata.propertiesDriver.type + '.');\n }\n}\n\nfunction updateCustomElement(previous, element) {\n if (previous) {\n this.disposables = previous.disposables;\n this.firstRootElem$.onNext(0);\n this.firstRootElem$.onCompleted();\n }\n validatePropertiesDriverInMetadata(element, 'update()');\n\n //console.log(`%cupdate() ${element.className}`, 'color: #880088');\n var propsDriver = element.cycleCustomElementMetadata.propertiesDriver;\n if (propsDriver.hasOwnProperty(ALL_PROPS)) {\n propsDriver[ALL_PROPS].onNext(this.properties);\n }\n for (var prop in propsDriver) {\n if (propsDriver.hasOwnProperty(prop)) {\n if (this.properties.hasOwnProperty(prop)) {\n propsDriver[prop].onNext(this.properties[prop]);\n }\n }\n }\n}\n\nfunction destroyCustomElement(element) {\n //console.log(`%cdestroy() custom el ${element.className}`, 'color: #808');\n // Dispose propertiesDriver\n var propsDriver = element.cycleCustomElementMetadata.propertiesDriver;\n for (var prop in propsDriver) {\n if (propsDriver.hasOwnProperty(prop)) {\n this.disposables.add(propsDriver[prop]);\n }\n }\n if (element.cycleCustomElementMetadata.eventDispatchingSubscription) {\n // This subscription has to be disposed.\n // Because disposing subscribeDispatchersWhenRootChanges only\n // is not enough.\n this.disposables.add(element.cycleCustomElementMetadata.eventDispatchingSubscription);\n }\n this.disposables.dispose();\n}\n\nfunction makeWidgetClass(tagName, definitionFn) {\n if (typeof definitionFn !== 'function') {\n throw new Error('A custom element definition given to the DOM driver ' + 'should be a function.');\n }\n\n var WidgetClass = makeConstructor();\n WidgetClass.definitionFn = definitionFn; // needed by renderAsHTML\n WidgetClass.prototype.init = makeInit(tagName, definitionFn);\n WidgetClass.prototype.update = updateCustomElement;\n WidgetClass.prototype.destroy = destroyCustomElement;\n return WidgetClass;\n}\n\nmodule.exports = {\n makeDispatchFunction: makeDispatchFunction,\n subscribeDispatchers: subscribeDispatchers,\n subscribeDispatchersWhenRootChanges: subscribeDispatchersWhenRootChanges,\n makePropertiesDriver: makePropertiesDriver,\n createContainerElement: createContainerElement,\n warnIfVTreeHasNoKey: warnIfVTreeHasNoKey,\n throwIfVTreeHasPropertyChildren: throwIfVTreeHasPropertyChildren,\n makeConstructor: makeConstructor,\n makeInit: makeInit,\n updateCustomElement: updateCustomElement,\n destroyCustomElement: destroyCustomElement,\n\n ALL_PROPS: ALL_PROPS,\n makeCustomElementInput: makeCustomElementInput,\n makeWidgetClass: makeWidgetClass\n};\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/lib/web/custom-element-widget.js\n ** module id = 43\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/lib/web/custom-element-widget.js?");
  4. },function(module,exports,__webpack_require__){eval("'use strict';\n\nmodule.exports = __webpack_require__(45)() ? Map : __webpack_require__(46);\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/es6-map/index.js\n ** module id = 44\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/es6-map/index.js?")},function(module,exports){eval("'use strict';\n\nmodule.exports = function () {\n var map, iterator, result;\n if (typeof Map !== 'function') return false;\n try {\n // WebKit doesn't support arguments and crashes\n map = new Map([['raz', 'one'], ['dwa', 'two'], ['trzy', 'three']]);\n } catch (e) {\n return false;\n }\n if (map.size !== 3) return false;\n if (typeof map.clear !== 'function') return false;\n if (typeof map.delete !== 'function') return false;\n if (typeof map.entries !== 'function') return false;\n if (typeof map.forEach !== 'function') return false;\n if (typeof map.get !== 'function') return false;\n if (typeof map.has !== 'function') return false;\n if (typeof map.keys !== 'function') return false;\n if (typeof map.set !== 'function') return false;\n if (typeof map.values !== 'function') return false;\n\n iterator = map.entries();\n result = iterator.next();\n if (result.done !== false) return false;\n if (!result.value) return false;\n if (result.value[0] !== 'raz') return false;\n if (result.value[1] !== 'one') return false;\n return true;\n};\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/es6-map/is-implemented.js\n ** module id = 45\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/es6-map/is-implemented.js?")},function(module,exports,__webpack_require__){eval("'use strict';\n\nvar clear = __webpack_require__(62)\n , eIndexOf = __webpack_require__(63)\n , setPrototypeOf = __webpack_require__(69)\n , callable = __webpack_require__(61)\n , validValue = __webpack_require__(55)\n , d = __webpack_require__(48)\n , ee = __webpack_require__(47)\n , Symbol = __webpack_require__(74)\n , iterator = __webpack_require__(77)\n , forOf = __webpack_require__(85)\n , Iterator = __webpack_require__(95)\n , isNative = __webpack_require__(98)\n\n , call = Function.prototype.call, defineProperties = Object.defineProperties\n , MapPoly;\n\nmodule.exports = MapPoly = function (/*iterable*/) {\n var iterable = arguments[0], keys, values;\n if (!(this instanceof MapPoly)) return new MapPoly(iterable);\n if (this.__mapKeysData__ !== undefined) {\n throw new TypeError(this + \" cannot be reinitialized\");\n }\n if (iterable != null) iterator(iterable);\n defineProperties(this, {\n __mapKeysData__: d('c', keys = []),\n __mapValuesData__: d('c', values = [])\n });\n if (!iterable) return;\n forOf(iterable, function (value) {\n var key = validValue(value)[0];\n value = value[1];\n if (eIndexOf.call(keys, key) !== -1) return;\n keys.push(key);\n values.push(value);\n }, this);\n};\n\nif (isNative) {\n if (setPrototypeOf) setPrototypeOf(MapPoly, Map);\n MapPoly.prototype = Object.create(Map.prototype, {\n constructor: d(MapPoly)\n });\n}\n\nee(defineProperties(MapPoly.prototype, {\n clear: d(function () {\n if (!this.__mapKeysData__.length) return;\n clear.call(this.__mapKeysData__);\n clear.call(this.__mapValuesData__);\n this.emit('_clear');\n }),\n delete: d(function (key) {\n var index = eIndexOf.call(this.__mapKeysData__, key);\n if (index === -1) return false;\n this.__mapKeysData__.splice(index, 1);\n this.__mapValuesData__.splice(index, 1);\n this.emit('_delete', index, key);\n return true;\n }),\n entries: d(function () { return new Iterator(this, 'key+value'); }),\n forEach: d(function (cb/*, thisArg*/) {\n var thisArg = arguments[1], iterator, result;\n callable(cb);\n iterator = this.entries();\n result = iterator._next();\n while (result !== undefined) {\n call.call(cb, thisArg, this.__mapValuesData__[result],\n this.__mapKeysData__[result], this);\n result = iterator._next();\n }\n }),\n get: d(function (key) {\n var index = eIndexOf.call(this.__mapKeysData__, key);\n if (index === -1) return;\n return this.__mapValuesData__[index];\n }),\n has: d(function (key) {\n return (eIndexOf.call(this.__mapKeysData__, key) !== -1);\n }),\n keys: d(function () { return new Iterator(this, 'key'); }),\n set: d(function (key, value) {\n var index = eIndexOf.call(this.__mapKeysData__, key), emit;\n if (index === -1) {\n index = this.__mapKeysData__.push(key) - 1;\n emit = true;\n }\n this.__mapValuesData__[index] = value;\n if (emit) this.emit('_add', index, key);\n return this;\n }),\n size: d.gs(function () { return this.__mapKeysData__.length; }),\n values: d(function () { return new Iterator(this, 'value'); }),\n toString: d(function () { return '[object Map]'; })\n}));\nObject.defineProperty(MapPoly.prototype, Symbol.iterator, d(function () {\n return this.entries();\n}));\nObject.defineProperty(MapPoly.prototype, Symbol.toStringTag, d('c', 'Map'));\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/es6-map/polyfill.js\n ** module id = 46\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/es6-map/polyfill.js?")},function(module,exports,__webpack_require__){eval("'use strict';\n\nvar d = __webpack_require__(48)\n , callable = __webpack_require__(61)\n\n , apply = Function.prototype.apply, call = Function.prototype.call\n , create = Object.create, defineProperty = Object.defineProperty\n , defineProperties = Object.defineProperties\n , hasOwnProperty = Object.prototype.hasOwnProperty\n , descriptor = { configurable: true, enumerable: false, writable: true }\n\n , on, once, off, emit, methods, descriptors, base;\n\non = function (type, listener) {\n var data;\n\n callable(listener);\n\n if (!hasOwnProperty.call(this, '__ee__')) {\n data = descriptor.value = create(null);\n defineProperty(this, '__ee__', descriptor);\n descriptor.value = null;\n } else {\n data = this.__ee__;\n }\n if (!data[type]) data[type] = listener;\n else if (typeof data[type] === 'object') data[type].push(listener);\n else data[type] = [data[type], listener];\n\n return this;\n};\n\nonce = function (type, listener) {\n var once, self;\n\n callable(listener);\n self = this;\n on.call(this, type, once = function () {\n off.call(self, type, once);\n apply.call(listener, this, arguments);\n });\n\n once.__eeOnceListener__ = listener;\n return this;\n};\n\noff = function (type, listener) {\n var data, listeners, candidate, i;\n\n callable(listener);\n\n if (!hasOwnProperty.call(this, '__ee__')) return this;\n data = this.__ee__;\n if (!data[type]) return this;\n listeners = data[type];\n\n if (typeof listeners === 'object') {\n for (i = 0; (candidate = listeners[i]); ++i) {\n if ((candidate === listener) ||\n (candidate.__eeOnceListener__ === listener)) {\n if (listeners.length === 2) data[type] = listeners[i ? 0 : 1];\n else listeners.splice(i, 1);\n }\n }\n } else {\n if ((listeners === listener) ||\n (listeners.__eeOnceListener__ === listener)) {\n delete data[type];\n }\n }\n\n return this;\n};\n\nemit = function (type) {\n var i, l, listener, listeners, args;\n\n if (!hasOwnProperty.call(this, '__ee__')) return;\n listeners = this.__ee__[type];\n if (!listeners) return;\n\n if (typeof listeners === 'object') {\n l = arguments.length;\n args = new Array(l - 1);\n for (i = 1; i < l; ++i) args[i - 1] = arguments[i];\n\n listeners = listeners.slice();\n for (i = 0; (listener = listeners[i]); ++i) {\n apply.call(listener, this, args);\n }\n } else {\n switch (arguments.length) {\n case 1:\n call.call(listeners, this);\n break;\n case 2:\n call.call(listeners, this, arguments[1]);\n break;\n case 3:\n call.call(listeners, this, arguments[1], arguments[2]);\n break;\n default:\n l = arguments.length;\n args = new Array(l - 1);\n for (i = 1; i < l; ++i) {\n args[i - 1] = arguments[i];\n }\n apply.call(listeners, this, args);\n }\n }\n};\n\nmethods = {\n on: on,\n once: once,\n off: off,\n emit: emit\n};\n\ndescriptors = {\n on: d(on),\n once: d(once),\n off: d(off),\n emit: d(emit)\n};\n\nbase = defineProperties({}, descriptors);\n\nmodule.exports = exports = function (o) {\n return (o == null) ? create(base) : defineProperties(Object(o), descriptors);\n};\nexports.methods = methods;\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/es6-map/~/event-emitter/index.js\n ** module id = 47\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/es6-map/~/event-emitter/index.js?")},function(module,exports,__webpack_require__){eval("'use strict';\n\nvar assign = __webpack_require__(49)\n , normalizeOpts = __webpack_require__(56)\n , isCallable = __webpack_require__(57)\n , contains = __webpack_require__(58)\n\n , d;\n\nd = module.exports = function (dscr, value/*, options*/) {\n var c, e, w, options, desc;\n if ((arguments.length < 2) || (typeof dscr !== 'string')) {\n options = value;\n value = dscr;\n dscr = null;\n } else {\n options = arguments[2];\n }\n if (dscr == null) {\n c = w = true;\n e = false;\n } else {\n c = contains.call(dscr, 'c');\n e = contains.call(dscr, 'e');\n w = contains.call(dscr, 'w');\n }\n\n desc = { value: value, configurable: c, enumerable: e, writable: w };\n return !options ? desc : assign(normalizeOpts(options), desc);\n};\n\nd.gs = function (dscr, get, set/*, options*/) {\n var c, e, options, desc;\n if (typeof dscr !== 'string') {\n options = set;\n set = get;\n get = dscr;\n dscr = null;\n } else {\n options = arguments[3];\n }\n if (get == null) {\n get = undefined;\n } else if (!isCallable(get)) {\n options = get;\n get = set = undefined;\n } else if (set == null) {\n set = undefined;\n } else if (!isCallable(set)) {\n options = set;\n set = undefined;\n }\n if (dscr == null) {\n c = true;\n e = false;\n } else {\n c = contains.call(dscr, 'c');\n e = contains.call(dscr, 'e');\n }\n\n desc = { get: get, set: set, configurable: c, enumerable: e };\n return !options ? desc : assign(normalizeOpts(options), desc);\n};\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/es6-map/~/d/index.js\n ** module id = 48\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/es6-map/~/d/index.js?")},function(module,exports,__webpack_require__){eval("'use strict';\n\nmodule.exports = __webpack_require__(50)()\n ? Object.assign\n : __webpack_require__(51);\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/es6-map/~/es5-ext/object/assign/index.js\n ** module id = 49\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/es6-map/~/es5-ext/object/assign/index.js?")},function(module,exports){eval("'use strict';\n\nmodule.exports = function () {\n var assign = Object.assign, obj;\n if (typeof assign !== 'function') return false;\n obj = { foo: 'raz' };\n assign(obj, { bar: 'dwa' }, { trzy: 'trzy' });\n return (obj.foo + obj.bar + obj.trzy) === 'razdwatrzy';\n};\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/es6-map/~/es5-ext/object/assign/is-implemented.js\n ** module id = 50\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/es6-map/~/es5-ext/object/assign/is-implemented.js?")},function(module,exports,__webpack_require__){eval("'use strict';\n\nvar keys = __webpack_require__(52)\n , value = __webpack_require__(55)\n\n , max = Math.max;\n\nmodule.exports = function (dest, src/*, …srcn*/) {\n var error, i, l = max(arguments.length, 2), assign;\n dest = Object(value(dest));\n assign = function (key) {\n try { dest[key] = src[key]; } catch (e) {\n if (!error) error = e;\n }\n };\n for (i = 1; i < l; ++i) {\n src = arguments[i];\n keys(src).forEach(assign);\n }\n if (error !== undefined) throw error;\n return dest;\n};\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/es6-map/~/es5-ext/object/assign/shim.js\n ** module id = 51\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/es6-map/~/es5-ext/object/assign/shim.js?")},function(module,exports,__webpack_require__){eval("'use strict';\n\nmodule.exports = __webpack_require__(53)()\n ? Object.keys\n : __webpack_require__(54);\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/es6-map/~/es5-ext/object/keys/index.js\n ** module id = 52\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/es6-map/~/es5-ext/object/keys/index.js?")},function(module,exports){eval("'use strict';\n\nmodule.exports = function () {\n try {\n Object.keys('primitive');\n return true;\n } catch (e) { return false; }\n};\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/es6-map/~/es5-ext/object/keys/is-implemented.js\n ** module id = 53\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/es6-map/~/es5-ext/object/keys/is-implemented.js?")},function(module,exports){eval("'use strict';\n\nvar keys = Object.keys;\n\nmodule.exports = function (object) {\n return keys(object == null ? object : Object(object));\n};\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/es6-map/~/es5-ext/object/keys/shim.js\n ** module id = 54\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/es6-map/~/es5-ext/object/keys/shim.js?")},function(module,exports){eval("'use strict';\n\nmodule.exports = function (value) {\n if (value == null) throw new TypeError(\"Cannot use null or undefined\");\n return value;\n};\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/es6-map/~/es5-ext/object/valid-value.js\n ** module id = 55\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/es6-map/~/es5-ext/object/valid-value.js?")},function(module,exports){eval("'use strict';\n\nvar forEach = Array.prototype.forEach, create = Object.create;\n\nvar process = function (src, obj) {\n var key;\n for (key in src) obj[key] = src[key];\n};\n\nmodule.exports = function (options/*, …options*/) {\n var result = create(null);\n forEach.call(arguments, function (options) {\n if (options == null) return;\n process(Object(options), result);\n });\n return result;\n};\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/es6-map/~/es5-ext/object/normalize-options.js\n ** module id = 56\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/es6-map/~/es5-ext/object/normalize-options.js?")},function(module,exports){eval("// Deprecated\n\n'use strict';\n\nmodule.exports = function (obj) { return typeof obj === 'function'; };\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/es6-map/~/es5-ext/object/is-callable.js\n ** module id = 57\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/es6-map/~/es5-ext/object/is-callable.js?")},function(module,exports,__webpack_require__){eval("'use strict';\n\nmodule.exports = __webpack_require__(59)()\n ? String.prototype.contains\n : __webpack_require__(60);\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/es6-map/~/es5-ext/string/#/contains/index.js\n ** module id = 58\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/es6-map/~/es5-ext/string/#/contains/index.js?")},function(module,exports){eval("'use strict';\n\nvar str = 'razdwatrzy';\n\nmodule.exports = function () {\n if (typeof str.contains !== 'function') return false;\n return ((str.contains('dwa') === true) && (str.contains('foo') === false));\n};\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/es6-map/~/es5-ext/string/#/contains/is-implemented.js\n ** module id = 59\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/es6-map/~/es5-ext/string/#/contains/is-implemented.js?")},function(module,exports){eval("'use strict';\n\nvar indexOf = String.prototype.indexOf;\n\nmodule.exports = function (searchString/*, position*/) {\n return indexOf.call(this, searchString, arguments[1]) > -1;\n};\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/es6-map/~/es5-ext/string/#/contains/shim.js\n ** module id = 60\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/es6-map/~/es5-ext/string/#/contains/shim.js?")},function(module,exports){eval("'use strict';\n\nmodule.exports = function (fn) {\n if (typeof fn !== 'function') throw new TypeError(fn + \" is not a function\");\n return fn;\n};\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/es6-map/~/es5-ext/object/valid-callable.js\n ** module id = 61\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/es6-map/~/es5-ext/object/valid-callable.js?")},function(module,exports,__webpack_require__){eval("// Inspired by Google Closure:\n// http://closure-library.googlecode.com/svn/docs/\n// closure_goog_array_array.js.html#goog.array.clear\n\n'use strict';\n\nvar value = __webpack_require__(55);\n\nmodule.exports = function () {\n value(this).length = 0;\n return this;\n};\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/es6-map/~/es5-ext/array/#/clear.js\n ** module id = 62\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/es6-map/~/es5-ext/array/#/clear.js?")},function(module,exports,__webpack_require__){eval("'use strict';\n\nvar toPosInt = __webpack_require__(64)\n , value = __webpack_require__(55)\n\n , indexOf = Array.prototype.indexOf\n , hasOwnProperty = Object.prototype.hasOwnProperty\n , abs = Math.abs, floor = Math.floor;\n\nmodule.exports = function (searchElement/*, fromIndex*/) {\n var i, l, fromIndex, val;\n if (searchElement === searchElement) { //jslint: ignore\n return indexOf.apply(this, arguments);\n }\n\n l = toPosInt(value(this).length);\n fromIndex = arguments[1];\n if (isNaN(fromIndex)) fromIndex = 0;\n else if (fromIndex >= 0) fromIndex = floor(fromIndex);\n else fromIndex = toPosInt(this.length) - floor(abs(fromIndex));\n\n for (i = fromIndex; i < l; ++i) {\n if (hasOwnProperty.call(this, i)) {\n val = this[i];\n if (val !== val) return i; //jslint: ignore\n }\n }\n return -1;\n};\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/es6-map/~/es5-ext/array/#/e-index-of.js\n ** module id = 63\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/es6-map/~/es5-ext/array/#/e-index-of.js?")},function(module,exports,__webpack_require__){eval("'use strict';\n\nvar toInteger = __webpack_require__(65)\n\n , max = Math.max;\n\nmodule.exports = function (value) { return max(0, toInteger(value)); };\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/es6-map/~/es5-ext/number/to-pos-integer.js\n ** module id = 64\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/es6-map/~/es5-ext/number/to-pos-integer.js?")},function(module,exports,__webpack_require__){eval("'use strict';\n\nvar sign = __webpack_require__(66)\n\n , abs = Math.abs, floor = Math.floor;\n\nmodule.exports = function (value) {\n if (isNaN(value)) return 0;\n value = Number(value);\n if ((value === 0) || !isFinite(value)) return value;\n return sign(value) * floor(abs(value));\n};\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/es6-map/~/es5-ext/number/to-integer.js\n ** module id = 65\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/es6-map/~/es5-ext/number/to-integer.js?")},function(module,exports,__webpack_require__){eval("'use strict';\n\nmodule.exports = __webpack_require__(67)()\n ? Math.sign\n : __webpack_require__(68);\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/es6-map/~/es5-ext/math/sign/index.js\n ** module id = 66\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/es6-map/~/es5-ext/math/sign/index.js?")},function(module,exports){eval("'use strict';\n\nmodule.exports = function () {\n var sign = Math.sign;\n if (typeof sign !== 'function') return false;\n return ((sign(10) === 1) && (sign(-20) === -1));\n};\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/es6-map/~/es5-ext/math/sign/is-implemented.js\n ** module id = 67\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/es6-map/~/es5-ext/math/sign/is-implemented.js?")},function(module,exports){eval("'use strict';\n\nmodule.exports = function (value) {\n value = Number(value);\n if (isNaN(value) || (value === 0)) return value;\n return (value > 0) ? 1 : -1;\n};\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/es6-map/~/es5-ext/math/sign/shim.js\n ** module id = 68\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/es6-map/~/es5-ext/math/sign/shim.js?")},function(module,exports,__webpack_require__){eval("'use strict';\n\nmodule.exports = __webpack_require__(70)()\n ? Object.setPrototypeOf\n : __webpack_require__(71);\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/es6-map/~/es5-ext/object/set-prototype-of/index.js\n ** module id = 69\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/es6-map/~/es5-ext/object/set-prototype-of/index.js?")},function(module,exports){eval("'use strict';\n\nvar create = Object.create, getPrototypeOf = Object.getPrototypeOf\n , x = {};\n\nmodule.exports = function (/*customCreate*/) {\n var setPrototypeOf = Object.setPrototypeOf\n , customCreate = arguments[0] || create;\n if (typeof setPrototypeOf !== 'function') return false;\n return getPrototypeOf(setPrototypeOf(customCreate(null), x)) === x;\n};\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/es6-map/~/es5-ext/object/set-prototype-of/is-implemented.js\n ** module id = 70\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/es6-map/~/es5-ext/object/set-prototype-of/is-implemented.js?")},function(module,exports,__webpack_require__){eval("// Big thanks to @WebReflection for sorting this out\n// https://gist.github.com/WebReflection/5593554\n\n'use strict';\n\nvar isObject = __webpack_require__(72)\n , value = __webpack_require__(55)\n\n , isPrototypeOf = Object.prototype.isPrototypeOf\n , defineProperty = Object.defineProperty\n , nullDesc = { configurable: true, enumerable: false, writable: true,\n value: undefined }\n , validate;\n\nvalidate = function (obj, prototype) {\n value(obj);\n if ((prototype === null) || isObject(prototype)) return obj;\n throw new TypeError('Prototype must be null or an object');\n};\n\nmodule.exports = (function (status) {\n var fn, set;\n if (!status) return null;\n if (status.level === 2) {\n if (status.set) {\n set = status.set;\n fn = function (obj, prototype) {\n set.call(validate(obj, prototype), prototype);\n return obj;\n };\n } else {\n fn = function (obj, prototype) {\n validate(obj, prototype).__proto__ = prototype;\n return obj;\n };\n }\n } else {\n fn = function self(obj, prototype) {\n var isNullBase;\n validate(obj, prototype);\n isNullBase = isPrototypeOf.call(self.nullPolyfill, obj);\n if (isNullBase) delete self.nullPolyfill.__proto__;\n if (prototype === null) prototype = self.nullPolyfill;\n obj.__proto__ = prototype;\n if (isNullBase) defineProperty(self.nullPolyfill, '__proto__', nullDesc);\n return obj;\n };\n }\n return Object.defineProperty(fn, 'level', { configurable: false,\n enumerable: false, writable: false, value: status.level });\n}((function () {\n var x = Object.create(null), y = {}, set\n , desc = Object.getOwnPropertyDescriptor(Object.prototype, '__proto__');\n\n if (desc) {\n try {\n set = desc.set; // Opera crashes at this point\n set.call(x, y);\n } catch (ignore) { }\n if (Object.getPrototypeOf(x) === y) return { set: set, level: 2 };\n }\n\n x.__proto__ = y;\n if (Object.getPrototypeOf(x) === y) return { level: 2 };\n\n x = {};\n x.__proto__ = y;\n if (Object.getPrototypeOf(x) === y) return { level: 1 };\n\n return false;\n}())));\n\n__webpack_require__(73);\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/es6-map/~/es5-ext/object/set-prototype-of/shim.js\n ** module id = 71\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/es6-map/~/es5-ext/object/set-prototype-of/shim.js?")},function(module,exports){eval("'use strict';\n\nvar map = { function: true, object: true };\n\nmodule.exports = function (x) {\n return ((x != null) && map[typeof x]) || false;\n};\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/es6-map/~/es5-ext/object/is-object.js\n ** module id = 72\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/es6-map/~/es5-ext/object/is-object.js?")},function(module,exports,__webpack_require__){eval("// Workaround for http://code.google.com/p/v8/issues/detail?id=2804\n\n'use strict';\n\nvar create = Object.create, shim;\n\nif (!__webpack_require__(70)()) {\n shim = __webpack_require__(71);\n}\n\nmodule.exports = (function () {\n var nullObject, props, desc;\n if (!shim) return create;\n if (shim.level !== 1) return create;\n\n nullObject = {};\n props = {};\n desc = { configurable: false, enumerable: false, writable: true,\n value: undefined };\n Object.getOwnPropertyNames(Object.prototype).forEach(function (name) {\n if (name === '__proto__') {\n props[name] = { configurable: true, enumerable: false, writable: true,\n value: undefined };\n return;\n }\n props[name] = desc;\n });\n Object.defineProperties(nullObject, props);\n\n Object.defineProperty(shim, 'nullPolyfill', { configurable: false,\n enumerable: false, writable: false, value: nullObject });\n\n return function (prototype, props) {\n return create((prototype === null) ? nullObject : prototype, props);\n };\n}());\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/es6-map/~/es5-ext/object/create.js\n ** module id = 73\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/es6-map/~/es5-ext/object/create.js?")},function(module,exports,__webpack_require__){eval("'use strict';\n\nmodule.exports = __webpack_require__(75)() ? Symbol : __webpack_require__(76);\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/es6-map/~/es6-symbol/index.js\n ** module id = 74\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/es6-map/~/es6-symbol/index.js?")},function(module,exports){eval("'use strict';\n\nmodule.exports = function () {\n var symbol;\n if (typeof Symbol !== 'function') return false;\n symbol = Symbol('test symbol');\n try { String(symbol); } catch (e) { return false; }\n if (typeof Symbol.iterator === 'symbol') return true;\n\n // Return 'true' for polyfills\n if (typeof Symbol.isConcatSpreadable !== 'object') return false;\n if (typeof Symbol.isRegExp !== 'object') return false;\n if (typeof Symbol.iterator !== 'object') return false;\n if (typeof Symbol.toPrimitive !== 'object') return false;\n if (typeof Symbol.toStringTag !== 'object') return false;\n if (typeof Symbol.unscopables !== 'object') return false;\n\n return true;\n};\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/es6-map/~/es6-symbol/is-implemented.js\n ** module id = 75\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/es6-map/~/es6-symbol/is-implemented.js?")},function(module,exports,__webpack_require__){eval("'use strict';\n\nvar d = __webpack_require__(48)\n\n , create = Object.create, defineProperties = Object.defineProperties\n , generateName, Symbol;\n\ngenerateName = (function () {\n var created = create(null);\n return function (desc) {\n var postfix = 0;\n while (created[desc + (postfix || '')]) ++postfix;\n desc += (postfix || '');\n created[desc] = true;\n return '@@' + desc;\n };\n}());\n\nmodule.exports = Symbol = function (description) {\n var symbol;\n if (this instanceof Symbol) {\n throw new TypeError('TypeError: Symbol is not a constructor');\n }\n symbol = create(Symbol.prototype);\n description = (description === undefined ? '' : String(description));\n return defineProperties(symbol, {\n __description__: d('', description),\n __name__: d('', generateName(description))\n });\n};\n\nObject.defineProperties(Symbol, {\n create: d('', Symbol('create')),\n hasInstance: d('', Symbol('hasInstance')),\n isConcatSpreadable: d('', Symbol('isConcatSpreadable')),\n isRegExp: d('', Symbol('isRegExp')),\n iterator: d('', Symbol('iterator')),\n toPrimitive: d('', Symbol('toPrimitive')),\n toStringTag: d('', Symbol('toStringTag')),\n unscopables: d('', Symbol('unscopables'))\n});\n\ndefineProperties(Symbol.prototype, {\n properToString: d(function () {\n return 'Symbol (' + this.__description__ + ')';\n }),\n toString: d('', function () { return this.__name__; })\n});\nObject.defineProperty(Symbol.prototype, Symbol.toPrimitive, d('',\n function (hint) {\n throw new TypeError(\"Conversion of symbol objects is not allowed\");\n }));\nObject.defineProperty(Symbol.prototype, Symbol.toStringTag, d('c', 'Symbol'));\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/es6-map/~/es6-symbol/polyfill.js\n ** module id = 76\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/es6-map/~/es6-symbol/polyfill.js?")},function(module,exports,__webpack_require__){eval("'use strict';\n\nvar isIterable = __webpack_require__(78);\n\nmodule.exports = function (value) {\n if (!isIterable(value)) throw new TypeError(value + \" is not iterable\");\n return value;\n};\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/es6-map/~/es6-iterator/valid-iterable.js\n ** module id = 77\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/es6-map/~/es6-iterator/valid-iterable.js?")},function(module,exports,__webpack_require__){eval("'use strict';\n\nvar isString = __webpack_require__(79)\n , iteratorSymbol = __webpack_require__(80).iterator\n\n , isArray = Array.isArray;\n\nmodule.exports = function (value) {\n if (value == null) return false;\n if (isArray(value)) return true;\n if (isString(value)) return true;\n return (typeof value[iteratorSymbol] === 'function');\n};\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/es6-map/~/es6-iterator/is-iterable.js\n ** module id = 78\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/es6-map/~/es6-iterator/is-iterable.js?")},function(module,exports){eval("'use strict';\n\nvar toString = Object.prototype.toString\n\n , id = toString.call('');\n\nmodule.exports = function (x) {\n return (typeof x === 'string') || (x && (typeof x === 'object') &&\n ((x instanceof String) || (toString.call(x) === id))) || false;\n};\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/es6-map/~/es5-ext/string/is-string.js\n ** module id = 79\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/es6-map/~/es5-ext/string/is-string.js?")},function(module,exports,__webpack_require__){eval("'use strict';\n\nmodule.exports = __webpack_require__(81)() ? Symbol : __webpack_require__(82);\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/es6-map/~/es6-iterator/~/es6-symbol/index.js\n ** module id = 80\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/es6-map/~/es6-iterator/~/es6-symbol/index.js?")},function(module,exports){eval("'use strict';\n\nmodule.exports = function () {\n var symbol;\n if (typeof Symbol !== 'function') return false;\n symbol = Symbol('test symbol');\n try { String(symbol); } catch (e) { return false; }\n if (typeof Symbol.iterator === 'symbol') return true;\n\n // Return 'true' for polyfills\n if (typeof Symbol.isConcatSpreadable !== 'object') return false;\n if (typeof Symbol.iterator !== 'object') return false;\n if (typeof Symbol.toPrimitive !== 'object') return false;\n if (typeof Symbol.toStringTag !== 'object') return false;\n if (typeof Symbol.unscopables !== 'object') return false;\n\n return true;\n};\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/es6-map/~/es6-iterator/~/es6-symbol/is-implemented.js\n ** module id = 81\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/es6-map/~/es6-iterator/~/es6-symbol/is-implemented.js?")},function(module,exports,__webpack_require__){eval("'use strict';\n\nvar d = __webpack_require__(48)\n , validateSymbol = __webpack_require__(83)\n\n , create = Object.create, defineProperties = Object.defineProperties\n , defineProperty = Object.defineProperty, objPrototype = Object.prototype\n , Symbol, HiddenSymbol, globalSymbols = create(null);\n\nvar generateName = (function () {\n var created = create(null);\n return function (desc) {\n var postfix = 0, name;\n while (created[desc + (postfix || '')]) ++postfix;\n desc += (postfix || '');\n created[desc] = true;\n name = '@@' + desc;\n defineProperty(objPrototype, name, d.gs(null, function (value) {\n defineProperty(this, name, d(value));\n }));\n return name;\n };\n}());\n\nHiddenSymbol = function Symbol(description) {\n if (this instanceof HiddenSymbol) throw new TypeError('TypeError: Symbol is not a constructor');\n return Symbol(description);\n};\nmodule.exports = Symbol = function Symbol(description) {\n var symbol;\n if (this instanceof Symbol) throw new TypeError('TypeError: Symbol is not a constructor');\n symbol = create(HiddenSymbol.prototype);\n description = (description === undefined ? '' : String(description));\n return defineProperties(symbol, {\n __description__: d('', description),\n __name__: d('', generateName(description))\n });\n};\ndefineProperties(Symbol, {\n for: d(function (key) {\n if (globalSymbols[key]) return globalSymbols[key];\n return (globalSymbols[key] = Symbol(String(key)));\n }),\n keyFor: d(function (s) {\n var key;\n validateSymbol(s);\n for (key in globalSymbols) if (globalSymbols[key] === s) return key;\n }),\n hasInstance: d('', Symbol('hasInstance')),\n isConcatSpreadable: d('', Symbol('isConcatSpreadable')),\n iterator: d('', Symbol('iterator')),\n match: d('', Symbol('match')),\n replace: d('', Symbol('replace')),\n search: d('', Symbol('search')),\n species: d('', Symbol('species')),\n split: d('', Symbol('split')),\n toPrimitive: d('', Symbol('toPrimitive')),\n toStringTag: d('', Symbol('toStringTag')),\n unscopables: d('', Symbol('unscopables'))\n});\ndefineProperties(HiddenSymbol.prototype, {\n constructor: d(Symbol),\n toString: d('', function () { return this.__name__; })\n});\n\ndefineProperties(Symbol.prototype, {\n toString: d(function () { return 'Symbol (' + validateSymbol(this).__description__ + ')'; }),\n valueOf: d(function () { return validateSymbol(this); })\n});\ndefineProperty(Symbol.prototype, Symbol.toPrimitive, d('',\n function () { return validateSymbol(this); }));\ndefineProperty(Symbol.prototype, Symbol.toStringTag, d('c', 'Symbol'));\n\ndefineProperty(HiddenSymbol.prototype, Symbol.toPrimitive,\n d('c', Symbol.prototype[Symbol.toPrimitive]));\ndefineProperty(HiddenSymbol.prototype, Symbol.toStringTag,\n d('c', Symbol.prototype[Symbol.toStringTag]));\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/es6-map/~/es6-iterator/~/es6-symbol/polyfill.js\n ** module id = 82\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/es6-map/~/es6-iterator/~/es6-symbol/polyfill.js?");
  5. },function(module,exports,__webpack_require__){eval("'use strict';\n\nvar isSymbol = __webpack_require__(84);\n\nmodule.exports = function (value) {\n if (!isSymbol(value)) throw new TypeError(value + \" is not a symbol\");\n return value;\n};\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/es6-map/~/es6-iterator/~/es6-symbol/validate-symbol.js\n ** module id = 83\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/es6-map/~/es6-iterator/~/es6-symbol/validate-symbol.js?")},function(module,exports){eval("'use strict';\n\nmodule.exports = function (x) {\n return (x && ((typeof x === 'symbol') || (x['@@toStringTag'] === 'Symbol'))) || false;\n};\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/es6-map/~/es6-iterator/~/es6-symbol/is-symbol.js\n ** module id = 84\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/es6-map/~/es6-iterator/~/es6-symbol/is-symbol.js?")},function(module,exports,__webpack_require__){eval("'use strict';\n\nvar callable = __webpack_require__(61)\n , isString = __webpack_require__(79)\n , get = __webpack_require__(86)\n\n , isArray = Array.isArray, call = Function.prototype.call;\n\nmodule.exports = function (iterable, cb/*, thisArg*/) {\n var mode, thisArg = arguments[2], result, doBreak, broken, i, l, char, code;\n if (isArray(iterable)) mode = 'array';\n else if (isString(iterable)) mode = 'string';\n else iterable = get(iterable);\n\n callable(cb);\n doBreak = function () { broken = true; };\n if (mode === 'array') {\n iterable.some(function (value) {\n call.call(cb, thisArg, value, doBreak);\n if (broken) return true;\n });\n return;\n }\n if (mode === 'string') {\n l = iterable.length;\n for (i = 0; i < l; ++i) {\n char = iterable[i];\n if ((i + 1) < l) {\n code = char.charCodeAt(0);\n if ((code >= 0xD800) && (code <= 0xDBFF)) char += iterable[++i];\n }\n call.call(cb, thisArg, char, doBreak);\n if (broken) break;\n }\n return;\n }\n result = iterable.next();\n\n while (!result.done) {\n call.call(cb, thisArg, result.value, doBreak);\n if (broken) return;\n result = iterable.next();\n }\n};\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/es6-map/~/es6-iterator/for-of.js\n ** module id = 85\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/es6-map/~/es6-iterator/for-of.js?")},function(module,exports,__webpack_require__){eval("'use strict';\n\nvar isString = __webpack_require__(79)\n , ArrayIterator = __webpack_require__(87)\n , StringIterator = __webpack_require__(94)\n , iterable = __webpack_require__(77)\n , iteratorSymbol = __webpack_require__(80).iterator;\n\nmodule.exports = function (obj) {\n if (typeof iterable(obj)[iteratorSymbol] === 'function') return obj[iteratorSymbol]();\n if (isString(obj)) return new StringIterator(obj);\n return new ArrayIterator(obj);\n};\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/es6-map/~/es6-iterator/get.js\n ** module id = 86\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/es6-map/~/es6-iterator/get.js?")},function(module,exports,__webpack_require__){eval("'use strict';\n\nvar setPrototypeOf = __webpack_require__(69)\n , contains = __webpack_require__(58)\n , d = __webpack_require__(48)\n , Iterator = __webpack_require__(88)\n\n , defineProperty = Object.defineProperty\n , ArrayIterator;\n\nArrayIterator = module.exports = function (arr, kind) {\n if (!(this instanceof ArrayIterator)) return new ArrayIterator(arr, kind);\n Iterator.call(this, arr);\n if (!kind) kind = 'value';\n else if (contains.call(kind, 'key+value')) kind = 'key+value';\n else if (contains.call(kind, 'key')) kind = 'key';\n else kind = 'value';\n defineProperty(this, '__kind__', d('', kind));\n};\nif (setPrototypeOf) setPrototypeOf(ArrayIterator, Iterator);\n\nArrayIterator.prototype = Object.create(Iterator.prototype, {\n constructor: d(ArrayIterator),\n _resolve: d(function (i) {\n if (this.__kind__ === 'value') return this.__list__[i];\n if (this.__kind__ === 'key+value') return [i, this.__list__[i]];\n return i;\n }),\n toString: d(function () { return '[object Array Iterator]'; })\n});\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/es6-map/~/es6-iterator/array.js\n ** module id = 87\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/es6-map/~/es6-iterator/array.js?")},function(module,exports,__webpack_require__){eval("'use strict';\n\nvar clear = __webpack_require__(62)\n , assign = __webpack_require__(49)\n , callable = __webpack_require__(61)\n , value = __webpack_require__(55)\n , d = __webpack_require__(48)\n , autoBind = __webpack_require__(89)\n , Symbol = __webpack_require__(80)\n\n , defineProperty = Object.defineProperty\n , defineProperties = Object.defineProperties\n , Iterator;\n\nmodule.exports = Iterator = function (list, context) {\n if (!(this instanceof Iterator)) return new Iterator(list, context);\n defineProperties(this, {\n __list__: d('w', value(list)),\n __context__: d('w', context),\n __nextIndex__: d('w', 0)\n });\n if (!context) return;\n callable(context.on);\n context.on('_add', this._onAdd);\n context.on('_delete', this._onDelete);\n context.on('_clear', this._onClear);\n};\n\ndefineProperties(Iterator.prototype, assign({\n constructor: d(Iterator),\n _next: d(function () {\n var i;\n if (!this.__list__) return;\n if (this.__redo__) {\n i = this.__redo__.shift();\n if (i !== undefined) return i;\n }\n if (this.__nextIndex__ < this.__list__.length) return this.__nextIndex__++;\n this._unBind();\n }),\n next: d(function () { return this._createResult(this._next()); }),\n _createResult: d(function (i) {\n if (i === undefined) return { done: true, value: undefined };\n return { done: false, value: this._resolve(i) };\n }),\n _resolve: d(function (i) { return this.__list__[i]; }),\n _unBind: d(function () {\n this.__list__ = null;\n delete this.__redo__;\n if (!this.__context__) return;\n this.__context__.off('_add', this._onAdd);\n this.__context__.off('_delete', this._onDelete);\n this.__context__.off('_clear', this._onClear);\n this.__context__ = null;\n }),\n toString: d(function () { return '[object Iterator]'; })\n}, autoBind({\n _onAdd: d(function (index) {\n if (index >= this.__nextIndex__) return;\n ++this.__nextIndex__;\n if (!this.__redo__) {\n defineProperty(this, '__redo__', d('c', [index]));\n return;\n }\n this.__redo__.forEach(function (redo, i) {\n if (redo >= index) this.__redo__[i] = ++redo;\n }, this);\n this.__redo__.push(index);\n }),\n _onDelete: d(function (index) {\n var i;\n if (index >= this.__nextIndex__) return;\n --this.__nextIndex__;\n if (!this.__redo__) return;\n i = this.__redo__.indexOf(index);\n if (i !== -1) this.__redo__.splice(i, 1);\n this.__redo__.forEach(function (redo, i) {\n if (redo > index) this.__redo__[i] = --redo;\n }, this);\n }),\n _onClear: d(function () {\n if (this.__redo__) clear.call(this.__redo__);\n this.__nextIndex__ = 0;\n })\n})));\n\ndefineProperty(Iterator.prototype, Symbol.iterator, d(function () {\n return this;\n}));\ndefineProperty(Iterator.prototype, Symbol.toStringTag, d('', 'Iterator'));\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/es6-map/~/es6-iterator/index.js\n ** module id = 88\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/es6-map/~/es6-iterator/index.js?")},function(module,exports,__webpack_require__){eval("'use strict';\n\nvar copy = __webpack_require__(90)\n , map = __webpack_require__(91)\n , callable = __webpack_require__(61)\n , validValue = __webpack_require__(55)\n\n , bind = Function.prototype.bind, defineProperty = Object.defineProperty\n , hasOwnProperty = Object.prototype.hasOwnProperty\n , define;\n\ndefine = function (name, desc, bindTo) {\n var value = validValue(desc) && callable(desc.value), dgs;\n dgs = copy(desc);\n delete dgs.writable;\n delete dgs.value;\n dgs.get = function () {\n if (hasOwnProperty.call(this, name)) return value;\n desc.value = bind.call(value, (bindTo == null) ? this : this[bindTo]);\n defineProperty(this, name, desc);\n return this[name];\n };\n return dgs;\n};\n\nmodule.exports = function (props/*, bindTo*/) {\n var bindTo = arguments[1];\n return map(props, function (desc, name) {\n return define(name, desc, bindTo);\n });\n};\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/es6-map/~/d/auto-bind.js\n ** module id = 89\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/es6-map/~/d/auto-bind.js?")},function(module,exports,__webpack_require__){eval("'use strict';\n\nvar assign = __webpack_require__(49)\n , value = __webpack_require__(55);\n\nmodule.exports = function (obj) {\n var copy = Object(value(obj));\n if (copy !== obj) return copy;\n return assign({}, obj);\n};\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/es6-map/~/es5-ext/object/copy.js\n ** module id = 90\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/es6-map/~/es5-ext/object/copy.js?")},function(module,exports,__webpack_require__){eval("'use strict';\n\nvar callable = __webpack_require__(61)\n , forEach = __webpack_require__(92)\n\n , call = Function.prototype.call;\n\nmodule.exports = function (obj, cb/*, thisArg*/) {\n var o = {}, thisArg = arguments[2];\n callable(cb);\n forEach(obj, function (value, key, obj, index) {\n o[key] = call.call(cb, thisArg, value, key, obj, index);\n });\n return o;\n};\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/es6-map/~/es5-ext/object/map.js\n ** module id = 91\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/es6-map/~/es5-ext/object/map.js?")},function(module,exports,__webpack_require__){eval("'use strict';\n\nmodule.exports = __webpack_require__(93)('forEach');\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/es6-map/~/es5-ext/object/for-each.js\n ** module id = 92\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/es6-map/~/es5-ext/object/for-each.js?")},function(module,exports,__webpack_require__){eval("// Internal method, used by iteration functions.\n// Calls a function for each key-value pair found in object\n// Optionally takes compareFn to iterate object in specific order\n\n'use strict';\n\nvar isCallable = __webpack_require__(57)\n , callable = __webpack_require__(61)\n , value = __webpack_require__(55)\n\n , call = Function.prototype.call, keys = Object.keys\n , propertyIsEnumerable = Object.prototype.propertyIsEnumerable;\n\nmodule.exports = function (method, defVal) {\n return function (obj, cb/*, thisArg, compareFn*/) {\n var list, thisArg = arguments[2], compareFn = arguments[3];\n obj = Object(value(obj));\n callable(cb);\n\n list = keys(obj);\n if (compareFn) {\n list.sort(isCallable(compareFn) ? compareFn.bind(obj) : undefined);\n }\n return list[method](function (key, index) {\n if (!propertyIsEnumerable.call(obj, key)) return defVal;\n return call.call(cb, thisArg, obj[key], key, obj, index);\n });\n };\n};\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/es6-map/~/es5-ext/object/_iterate.js\n ** module id = 93\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/es6-map/~/es5-ext/object/_iterate.js?")},function(module,exports,__webpack_require__){eval("// Thanks @mathiasbynens\n// http://mathiasbynens.be/notes/javascript-unicode#iterating-over-symbols\n\n'use strict';\n\nvar setPrototypeOf = __webpack_require__(69)\n , d = __webpack_require__(48)\n , Iterator = __webpack_require__(88)\n\n , defineProperty = Object.defineProperty\n , StringIterator;\n\nStringIterator = module.exports = function (str) {\n if (!(this instanceof StringIterator)) return new StringIterator(str);\n str = String(str);\n Iterator.call(this, str);\n defineProperty(this, '__length__', d('', str.length));\n\n};\nif (setPrototypeOf) setPrototypeOf(StringIterator, Iterator);\n\nStringIterator.prototype = Object.create(Iterator.prototype, {\n constructor: d(StringIterator),\n _next: d(function () {\n if (!this.__list__) return;\n if (this.__nextIndex__ < this.__length__) return this.__nextIndex__++;\n this._unBind();\n }),\n _resolve: d(function (i) {\n var char = this.__list__[i], code;\n if (this.__nextIndex__ === this.__length__) return char;\n code = char.charCodeAt(0);\n if ((code >= 0xD800) && (code <= 0xDBFF)) return char + this.__list__[this.__nextIndex__++];\n return char;\n }),\n toString: d(function () { return '[object String Iterator]'; })\n});\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/es6-map/~/es6-iterator/string.js\n ** module id = 94\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/es6-map/~/es6-iterator/string.js?")},function(module,exports,__webpack_require__){eval("'use strict';\n\nvar setPrototypeOf = __webpack_require__(69)\n , d = __webpack_require__(48)\n , Iterator = __webpack_require__(88)\n , toStringTagSymbol = __webpack_require__(74).toStringTag\n , kinds = __webpack_require__(96)\n\n , defineProperties = Object.defineProperties\n , unBind = Iterator.prototype._unBind\n , MapIterator;\n\nMapIterator = module.exports = function (map, kind) {\n if (!(this instanceof MapIterator)) return new MapIterator(map, kind);\n Iterator.call(this, map.__mapKeysData__, map);\n if (!kind || !kinds[kind]) kind = 'key+value';\n defineProperties(this, {\n __kind__: d('', kind),\n __values__: d('w', map.__mapValuesData__)\n });\n};\nif (setPrototypeOf) setPrototypeOf(MapIterator, Iterator);\n\nMapIterator.prototype = Object.create(Iterator.prototype, {\n constructor: d(MapIterator),\n _resolve: d(function (i) {\n if (this.__kind__ === 'value') return this.__values__[i];\n if (this.__kind__ === 'key') return this.__list__[i];\n return [this.__list__[i], this.__values__[i]];\n }),\n _unBind: d(function () {\n this.__values__ = null;\n unBind.call(this);\n }),\n toString: d(function () { return '[object Map Iterator]'; })\n});\nObject.defineProperty(MapIterator.prototype, toStringTagSymbol,\n d('c', 'Map Iterator'));\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/es6-map/lib/iterator.js\n ** module id = 95\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/es6-map/lib/iterator.js?")},function(module,exports,__webpack_require__){eval("'use strict';\n\nmodule.exports = __webpack_require__(97)('key',\n 'value', 'key+value');\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/es6-map/lib/iterator-kinds.js\n ** module id = 96\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/es6-map/lib/iterator-kinds.js?")},function(module,exports){eval("'use strict';\n\nvar forEach = Array.prototype.forEach, create = Object.create;\n\nmodule.exports = function (arg/*, …args*/) {\n var set = create(null);\n forEach.call(arguments, function (name) { set[name] = true; });\n return set;\n};\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/es6-map/~/es5-ext/object/primitive-set.js\n ** module id = 97\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/es6-map/~/es5-ext/object/primitive-set.js?")},function(module,exports){eval("// Exports true if environment provides native `Map` implementation,\n// whatever that is.\n\n'use strict';\n\nmodule.exports = (function () {\n if (typeof Map === 'undefined') return false;\n return (Object.prototype.toString.call(Map.prototype) === '[object Map]');\n}());\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/es6-map/is-native-implemented.js\n ** module id = 98\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/es6-map/is-native-implemented.js?")},function(module,exports,__webpack_require__){eval("'use strict';\n\nvar isArray = __webpack_require__(23);\n\nvar h = __webpack_require__(32);\n\n\nvar SVGAttributeNamespace = __webpack_require__(100);\nvar attributeHook = __webpack_require__(101);\n\nvar SVG_NAMESPACE = 'http://www.w3.org/2000/svg';\n\nmodule.exports = svg;\n\nfunction svg(tagName, properties, children) {\n if (!children && isChildren(properties)) {\n children = properties;\n properties = {};\n }\n\n properties = properties || {};\n\n // set namespace for svg\n properties.namespace = SVG_NAMESPACE;\n\n var attributes = properties.attributes || (properties.attributes = {});\n\n for (var key in properties) {\n if (!properties.hasOwnProperty(key)) {\n continue;\n }\n\n var namespace = SVGAttributeNamespace(key);\n\n if (namespace === undefined) { // not a svg attribute\n continue;\n }\n\n var value = properties[key];\n\n if (typeof value !== 'string' &&\n typeof value !== 'number' &&\n typeof value !== 'boolean'\n ) {\n continue;\n }\n\n if (namespace !== null) { // namespaced attribute\n properties[key] = attributeHook(namespace, value);\n continue;\n }\n\n attributes[key] = value\n properties[key] = undefined\n }\n\n return h(tagName, properties, children);\n}\n\nfunction isChildren(x) {\n return typeof x === 'string' || isArray(x);\n}\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/virtual-dom/virtual-hyperscript/svg.js\n ** module id = 99\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/virtual-dom/virtual-hyperscript/svg.js?")},function(module,exports){eval("'use strict';\n\nvar DEFAULT_NAMESPACE = null;\nvar EV_NAMESPACE = 'http://www.w3.org/2001/xml-events';\nvar XLINK_NAMESPACE = 'http://www.w3.org/1999/xlink';\nvar XML_NAMESPACE = 'http://www.w3.org/XML/1998/namespace';\n\n// http://www.w3.org/TR/SVGTiny12/attributeTable.html\n// http://www.w3.org/TR/SVG/attindex.html\nvar SVG_PROPERTIES = {\n 'about': DEFAULT_NAMESPACE,\n 'accent-height': DEFAULT_NAMESPACE,\n 'accumulate': DEFAULT_NAMESPACE,\n 'additive': DEFAULT_NAMESPACE,\n 'alignment-baseline': DEFAULT_NAMESPACE,\n 'alphabetic': DEFAULT_NAMESPACE,\n 'amplitude': DEFAULT_NAMESPACE,\n 'arabic-form': DEFAULT_NAMESPACE,\n 'ascent': DEFAULT_NAMESPACE,\n 'attributeName': DEFAULT_NAMESPACE,\n 'attributeType': DEFAULT_NAMESPACE,\n 'azimuth': DEFAULT_NAMESPACE,\n 'bandwidth': DEFAULT_NAMESPACE,\n 'baseFrequency': DEFAULT_NAMESPACE,\n 'baseProfile': DEFAULT_NAMESPACE,\n 'baseline-shift': DEFAULT_NAMESPACE,\n 'bbox': DEFAULT_NAMESPACE,\n 'begin': DEFAULT_NAMESPACE,\n 'bias': DEFAULT_NAMESPACE,\n 'by': DEFAULT_NAMESPACE,\n 'calcMode': DEFAULT_NAMESPACE,\n 'cap-height': DEFAULT_NAMESPACE,\n 'class': DEFAULT_NAMESPACE,\n 'clip': DEFAULT_NAMESPACE,\n 'clip-path': DEFAULT_NAMESPACE,\n 'clip-rule': DEFAULT_NAMESPACE,\n 'clipPathUnits': DEFAULT_NAMESPACE,\n 'color': DEFAULT_NAMESPACE,\n 'color-interpolation': DEFAULT_NAMESPACE,\n 'color-interpolation-filters': DEFAULT_NAMESPACE,\n 'color-profile': DEFAULT_NAMESPACE,\n 'color-rendering': DEFAULT_NAMESPACE,\n 'content': DEFAULT_NAMESPACE,\n 'contentScriptType': DEFAULT_NAMESPACE,\n 'contentStyleType': DEFAULT_NAMESPACE,\n 'cursor': DEFAULT_NAMESPACE,\n 'cx': DEFAULT_NAMESPACE,\n 'cy': DEFAULT_NAMESPACE,\n 'd': DEFAULT_NAMESPACE,\n 'datatype': DEFAULT_NAMESPACE,\n 'defaultAction': DEFAULT_NAMESPACE,\n 'descent': DEFAULT_NAMESPACE,\n 'diffuseConstant': DEFAULT_NAMESPACE,\n 'direction': DEFAULT_NAMESPACE,\n 'display': DEFAULT_NAMESPACE,\n 'divisor': DEFAULT_NAMESPACE,\n 'dominant-baseline': DEFAULT_NAMESPACE,\n 'dur': DEFAULT_NAMESPACE,\n 'dx': DEFAULT_NAMESPACE,\n 'dy': DEFAULT_NAMESPACE,\n 'edgeMode': DEFAULT_NAMESPACE,\n 'editable': DEFAULT_NAMESPACE,\n 'elevation': DEFAULT_NAMESPACE,\n 'enable-background': DEFAULT_NAMESPACE,\n 'end': DEFAULT_NAMESPACE,\n 'ev:event': EV_NAMESPACE,\n 'event': DEFAULT_NAMESPACE,\n 'exponent': DEFAULT_NAMESPACE,\n 'externalResourcesRequired': DEFAULT_NAMESPACE,\n 'fill': DEFAULT_NAMESPACE,\n 'fill-opacity': DEFAULT_NAMESPACE,\n 'fill-rule': DEFAULT_NAMESPACE,\n 'filter': DEFAULT_NAMESPACE,\n 'filterRes': DEFAULT_NAMESPACE,\n 'filterUnits': DEFAULT_NAMESPACE,\n 'flood-color': DEFAULT_NAMESPACE,\n 'flood-opacity': DEFAULT_NAMESPACE,\n 'focusHighlight': DEFAULT_NAMESPACE,\n 'focusable': DEFAULT_NAMESPACE,\n 'font-family': DEFAULT_NAMESPACE,\n 'font-size': DEFAULT_NAMESPACE,\n 'font-size-adjust': DEFAULT_NAMESPACE,\n 'font-stretch': DEFAULT_NAMESPACE,\n 'font-style': DEFAULT_NAMESPACE,\n 'font-variant': DEFAULT_NAMESPACE,\n 'font-weight': DEFAULT_NAMESPACE,\n 'format': DEFAULT_NAMESPACE,\n 'from': DEFAULT_NAMESPACE,\n 'fx': DEFAULT_NAMESPACE,\n 'fy': DEFAULT_NAMESPACE,\n 'g1': DEFAULT_NAMESPACE,\n 'g2': DEFAULT_NAMESPACE,\n 'glyph-name': DEFAULT_NAMESPACE,\n 'glyph-orientation-horizontal': DEFAULT_NAMESPACE,\n 'glyph-orientation-vertical': DEFAULT_NAMESPACE,\n 'glyphRef': DEFAULT_NAMESPACE,\n 'gradientTransform': DEFAULT_NAMESPACE,\n 'gradientUnits': DEFAULT_NAMESPACE,\n 'handler': DEFAULT_NAMESPACE,\n 'hanging': DEFAULT_NAMESPACE,\n 'height': DEFAULT_NAMESPACE,\n 'horiz-adv-x': DEFAULT_NAMESPACE,\n 'horiz-origin-x': DEFAULT_NAMESPACE,\n 'horiz-origin-y': DEFAULT_NAMESPACE,\n 'id': DEFAULT_NAMESPACE,\n 'ideographic': DEFAULT_NAMESPACE,\n 'image-rendering': DEFAULT_NAMESPACE,\n 'in': DEFAULT_NAMESPACE,\n 'in2': DEFAULT_NAMESPACE,\n 'initialVisibility': DEFAULT_NAMESPACE,\n 'intercept': DEFAULT_NAMESPACE,\n 'k': DEFAULT_NAMESPACE,\n 'k1': DEFAULT_NAMESPACE,\n 'k2': DEFAULT_NAMESPACE,\n 'k3': DEFAULT_NAMESPACE,\n 'k4': DEFAULT_NAMESPACE,\n 'kernelMatrix': DEFAULT_NAMESPACE,\n 'kernelUnitLength': DEFAULT_NAMESPACE,\n 'kerning': DEFAULT_NAMESPACE,\n 'keyPoints': DEFAULT_NAMESPACE,\n 'keySplines': DEFAULT_NAMESPACE,\n 'keyTimes': DEFAULT_NAMESPACE,\n 'lang': DEFAULT_NAMESPACE,\n 'lengthAdjust': DEFAULT_NAMESPACE,\n 'letter-spacing': DEFAULT_NAMESPACE,\n 'lighting-color': DEFAULT_NAMESPACE,\n 'limitingConeAngle': DEFAULT_NAMESPACE,\n 'local': DEFAULT_NAMESPACE,\n 'marker-end': DEFAULT_NAMESPACE,\n 'marker-mid': DEFAULT_NAMESPACE,\n 'marker-start': DEFAULT_NAMESPACE,\n 'markerHeight': DEFAULT_NAMESPACE,\n 'markerUnits': DEFAULT_NAMESPACE,\n 'markerWidth': DEFAULT_NAMESPACE,\n 'mask': DEFAULT_NAMESPACE,\n 'maskContentUnits': DEFAULT_NAMESPACE,\n 'maskUnits': DEFAULT_NAMESPACE,\n 'mathematical': DEFAULT_NAMESPACE,\n 'max': DEFAULT_NAMESPACE,\n 'media': DEFAULT_NAMESPACE,\n 'mediaCharacterEncoding': DEFAULT_NAMESPACE,\n 'mediaContentEncodings': DEFAULT_NAMESPACE,\n 'mediaSize': DEFAULT_NAMESPACE,\n 'mediaTime': DEFAULT_NAMESPACE,\n 'method': DEFAULT_NAMESPACE,\n 'min': DEFAULT_NAMESPACE,\n 'mode': DEFAULT_NAMESPACE,\n 'name': DEFAULT_NAMESPACE,\n 'nav-down': DEFAULT_NAMESPACE,\n 'nav-down-left': DEFAULT_NAMESPACE,\n 'nav-down-right': DEFAULT_NAMESPACE,\n 'nav-left': DEFAULT_NAMESPACE,\n 'nav-next': DEFAULT_NAMESPACE,\n 'nav-prev': DEFAULT_NAMESPACE,\n 'nav-right': DEFAULT_NAMESPACE,\n 'nav-up': DEFAULT_NAMESPACE,\n 'nav-up-left': DEFAULT_NAMESPACE,\n 'nav-up-right': DEFAULT_NAMESPACE,\n 'numOctaves': DEFAULT_NAMESPACE,\n 'observer': DEFAULT_NAMESPACE,\n 'offset': DEFAULT_NAMESPACE,\n 'opacity': DEFAULT_NAMESPACE,\n 'operator': DEFAULT_NAMESPACE,\n 'order': DEFAULT_NAMESPACE,\n 'orient': DEFAULT_NAMESPACE,\n 'orientation': DEFAULT_NAMESPACE,\n 'origin': DEFAULT_NAMESPACE,\n 'overflow': DEFAULT_NAMESPACE,\n 'overlay': DEFAULT_NAMESPACE,\n 'overline-position': DEFAULT_NAMESPACE,\n 'overline-thickness': DEFAULT_NAMESPACE,\n 'panose-1': DEFAULT_NAMESPACE,\n 'path': DEFAULT_NAMESPACE,\n 'pathLength': DEFAULT_NAMESPACE,\n 'patternContentUnits': DEFAULT_NAMESPACE,\n 'patternTransform': DEFAULT_NAMESPACE,\n 'patternUnits': DEFAULT_NAMESPACE,\n 'phase': DEFAULT_NAMESPACE,\n 'playbackOrder': DEFAULT_NAMESPACE,\n 'pointer-events': DEFAULT_NAMESPACE,\n 'points': DEFAULT_NAMESPACE,\n 'pointsAtX': DEFAULT_NAMESPACE,\n 'pointsAtY': DEFAULT_NAMESPACE,\n 'pointsAtZ': DEFAULT_NAMESPACE,\n 'preserveAlpha': DEFAULT_NAMESPACE,\n 'preserveAspectRatio': DEFAULT_NAMESPACE,\n 'primitiveUnits': DEFAULT_NAMESPACE,\n 'propagate': DEFAULT_NAMESPACE,\n 'property': DEFAULT_NAMESPACE,\n 'r': DEFAULT_NAMESPACE,\n 'radius': DEFAULT_NAMESPACE,\n 'refX': DEFAULT_NAMESPACE,\n 'refY': DEFAULT_NAMESPACE,\n 'rel': DEFAULT_NAMESPACE,\n 'rendering-intent': DEFAULT_NAMESPACE,\n 'repeatCount': DEFAULT_NAMESPACE,\n 'repeatDur': DEFAULT_NAMESPACE,\n 'requiredExtensions': DEFAULT_NAMESPACE,\n 'requiredFeatures': DEFAULT_NAMESPACE,\n 'requiredFonts': DEFAULT_NAMESPACE,\n 'requiredFormats': DEFAULT_NAMESPACE,\n 'resource': DEFAULT_NAMESPACE,\n 'restart': DEFAULT_NAMESPACE,\n 'result': DEFAULT_NAMESPACE,\n 'rev': DEFAULT_NAMESPACE,\n 'role': DEFAULT_NAMESPACE,\n 'rotate': DEFAULT_NAMESPACE,\n 'rx': DEFAULT_NAMESPACE,\n 'ry': DEFAULT_NAMESPACE,\n 'scale': DEFAULT_NAMESPACE,\n 'seed': DEFAULT_NAMESPACE,\n 'shape-rendering': DEFAULT_NAMESPACE,\n 'slope': DEFAULT_NAMESPACE,\n 'snapshotTime': DEFAULT_NAMESPACE,\n 'spacing': DEFAULT_NAMESPACE,\n 'specularConstant': DEFAULT_NAMESPACE,\n 'specularExponent': DEFAULT_NAMESPACE,\n 'spreadMethod': DEFAULT_NAMESPACE,\n 'startOffset': DEFAULT_NAMESPACE,\n 'stdDeviation': DEFAULT_NAMESPACE,\n 'stemh': DEFAULT_NAMESPACE,\n 'stemv': DEFAULT_NAMESPACE,\n 'stitchTiles': DEFAULT_NAMESPACE,\n 'stop-color': DEFAULT_NAMESPACE,\n 'stop-opacity': DEFAULT_NAMESPACE,\n 'strikethrough-position': DEFAULT_NAMESPACE,\n 'strikethrough-thickness': DEFAULT_NAMESPACE,\n 'string': DEFAULT_NAMESPACE,\n 'stroke': DEFAULT_NAMESPACE,\n 'stroke-dasharray': DEFAULT_NAMESPACE,\n 'stroke-dashoffset': DEFAULT_NAMESPACE,\n 'stroke-linecap': DEFAULT_NAMESPACE,\n 'stroke-linejoin': DEFAULT_NAMESPACE,\n 'stroke-miterlimit': DEFAULT_NAMESPACE,\n 'stroke-opacity': DEFAULT_NAMESPACE,\n 'stroke-width': DEFAULT_NAMESPACE,\n 'surfaceScale': DEFAULT_NAMESPACE,\n 'syncBehavior': DEFAULT_NAMESPACE,\n 'syncBehaviorDefault': DEFAULT_NAMESPACE,\n 'syncMaster': DEFAULT_NAMESPACE,\n 'syncTolerance': DEFAULT_NAMESPACE,\n 'syncToleranceDefault': DEFAULT_NAMESPACE,\n 'systemLanguage': DEFAULT_NAMESPACE,\n 'tableValues': DEFAULT_NAMESPACE,\n 'target': DEFAULT_NAMESPACE,\n 'targetX': DEFAULT_NAMESPACE,\n 'targetY': DEFAULT_NAMESPACE,\n 'text-anchor': DEFAULT_NAMESPACE,\n 'text-decoration': DEFAULT_NAMESPACE,\n 'text-rendering': DEFAULT_NAMESPACE,\n 'textLength': DEFAULT_NAMESPACE,\n 'timelineBegin': DEFAULT_NAMESPACE,\n 'title': DEFAULT_NAMESPACE,\n 'to': DEFAULT_NAMESPACE,\n 'transform': DEFAULT_NAMESPACE,\n 'transformBehavior': DEFAULT_NAMESPACE,\n 'type': DEFAULT_NAMESPACE,\n 'typeof': DEFAULT_NAMESPACE,\n 'u1': DEFAULT_NAMESPACE,\n 'u2': DEFAULT_NAMESPACE,\n 'underline-position': DEFAULT_NAMESPACE,\n 'underline-thickness': DEFAULT_NAMESPACE,\n 'unicode': DEFAULT_NAMESPACE,\n 'unicode-bidi': DEFAULT_NAMESPACE,\n 'unicode-range': DEFAULT_NAMESPACE,\n 'units-per-em': DEFAULT_NAMESPACE,\n 'v-alphabetic': DEFAULT_NAMESPACE,\n 'v-hanging': DEFAULT_NAMESPACE,\n 'v-ideographic': DEFAULT_NAMESPACE,\n 'v-mathematical': DEFAULT_NAMESPACE,\n 'values': DEFAULT_NAMESPACE,\n 'version': DEFAULT_NAMESPACE,\n 'vert-adv-y': DEFAULT_NAMESPACE,\n 'vert-origin-x': DEFAULT_NAMESPACE,\n 'vert-origin-y': DEFAULT_NAMESPACE,\n 'viewBox': DEFAULT_NAMESPACE,\n 'viewTarget': DEFAULT_NAMESPACE,\n 'visibility': DEFAULT_NAMESPACE,\n 'width': DEFAULT_NAMESPACE,\n 'widths': DEFAULT_NAMESPACE,\n 'word-spacing': DEFAULT_NAMESPACE,\n 'writing-mode': DEFAULT_NAMESPACE,\n 'x': DEFAULT_NAMESPACE,\n 'x-height': DEFAULT_NAMESPACE,\n 'x1': DEFAULT_NAMESPACE,\n 'x2': DEFAULT_NAMESPACE,\n 'xChannelSelector': DEFAULT_NAMESPACE,\n 'xlink:actuate': XLINK_NAMESPACE,\n 'xlink:arcrole': XLINK_NAMESPACE,\n 'xlink:href': XLINK_NAMESPACE,\n 'xlink:role': XLINK_NAMESPACE,\n 'xlink:show': XLINK_NAMESPACE,\n 'xlink:title': XLINK_NAMESPACE,\n 'xlink:type': XLINK_NAMESPACE,\n 'xml:base': XML_NAMESPACE,\n 'xml:id': XML_NAMESPACE,\n 'xml:lang': XML_NAMESPACE,\n 'xml:space': XML_NAMESPACE,\n 'y': DEFAULT_NAMESPACE,\n 'y1': DEFAULT_NAMESPACE,\n 'y2': DEFAULT_NAMESPACE,\n 'yChannelSelector': DEFAULT_NAMESPACE,\n 'z': DEFAULT_NAMESPACE,\n 'zoomAndPan': DEFAULT_NAMESPACE\n};\n\nmodule.exports = SVGAttributeNamespace;\n\nfunction SVGAttributeNamespace(value) {\n if (SVG_PROPERTIES.hasOwnProperty(value)) {\n return SVG_PROPERTIES[value];\n }\n}\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/virtual-dom/virtual-hyperscript/svg-attribute-namespace.js\n ** module id = 100\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/virtual-dom/virtual-hyperscript/svg-attribute-namespace.js?")},function(module,exports){eval("'use strict';\n\nmodule.exports = AttributeHook;\n\nfunction AttributeHook(namespace, value) {\n if (!(this instanceof AttributeHook)) {\n return new AttributeHook(namespace, value);\n }\n\n this.namespace = namespace;\n this.value = value;\n}\n\nAttributeHook.prototype.hook = function (node, prop, prev) {\n if (prev && prev.type === 'AttributeHook' &&\n prev.value === this.value &&\n prev.namespace === this.namespace) {\n return;\n }\n\n node.setAttributeNS(this.namespace, prop, this.value);\n};\n\nAttributeHook.prototype.unhook = function (node, prop, next) {\n if (next && next.type === 'AttributeHook' &&\n next.namespace === this.namespace) {\n return;\n }\n\n var colonPosition = prop.indexOf(':');\n var localName = colonPosition > -1 ? prop.substr(colonPosition + 1) : prop;\n node.removeAttributeNS(this.namespace, localName);\n};\n\nAttributeHook.prototype.type = 'AttributeHook';\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/virtual-dom/virtual-hyperscript/hooks/attribute-hook.js\n ** module id = 101\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/virtual-dom/virtual-hyperscript/hooks/attribute-hook.js?")},function(module,exports,__webpack_require__){eval("'use strict';\nvar Rx = __webpack_require__(4);\nvar toHTML = __webpack_require__(103);\n\nvar _require = __webpack_require__(42);\n\nvar replaceCustomElementsWithSomething = _require.replaceCustomElementsWithSomething;\nvar makeCustomElementsRegistry = _require.makeCustomElementsRegistry;\n\nvar _require2 = __webpack_require__(43);\n\nvar makeCustomElementInput = _require2.makeCustomElementInput;\nvar ALL_PROPS = _require2.ALL_PROPS;\n\nfunction makePropertiesDriverFromVTree(vtree) {\n return {\n get: function get(propertyName) {\n if (propertyName === ALL_PROPS) {\n return Rx.Observable.just(vtree.properties);\n } else {\n return Rx.Observable.just(vtree.properties[propertyName]);\n }\n }\n };\n}\n\n/**\n * Converts a tree of VirtualNode|Observable<VirtualNode> into\n * Observable<VirtualNode>.\n */\nfunction transposeVTree(vtree) {\n if (typeof vtree.subscribe === 'function') {\n return vtree;\n } else if (vtree.type === 'VirtualText') {\n return Rx.Observable.just(vtree);\n } else if (vtree.type === 'VirtualNode' && Array.isArray(vtree.children) && vtree.children.length > 0) {\n return Rx.Observable.combineLatest(vtree.children.map(transposeVTree), function () {\n for (var _len = arguments.length, arr = Array(_len), _key = 0; _key < _len; _key++) {\n arr[_key] = arguments[_key];\n }\n\n vtree.children = arr;\n return vtree;\n });\n } else if (vtree.type === 'VirtualNode') {\n return Rx.Observable.just(vtree);\n } else {\n throw new Error('Unhandled case in transposeVTree()');\n }\n}\n\nfunction makeReplaceCustomElementsWithVTree$(CERegistry, driverName) {\n return function replaceCustomElementsWithVTree$(vtree) {\n return replaceCustomElementsWithSomething(vtree, CERegistry, function toVTree$(_vtree, WidgetClass) {\n var interactions = { get: function get() {\n return Rx.Observable.empty();\n } };\n var props = makePropertiesDriverFromVTree(_vtree);\n var input = makeCustomElementInput(interactions, props);\n var output = WidgetClass.definitionFn(input);\n var vtree$ = output[driverName].last();\n /*eslint-disable no-use-before-define */\n return convertCustomElementsToVTree(vtree$, CERegistry, driverName);\n /*eslint-enable no-use-before-define */\n });\n };\n}\n\nfunction convertCustomElementsToVTree(vtree$, CERegistry, driverName) {\n return vtree$.map(makeReplaceCustomElementsWithVTree$(CERegistry, driverName)).flatMap(transposeVTree);\n}\n\nfunction makeResponseGetter() {\n return function get(selector) {\n if (selector === ':root') {\n return this;\n } else {\n return Rx.Observable.empty();\n }\n };\n}\n\nfunction makeHTMLDriver() {\n var customElementDefinitions = arguments[0] === undefined ? {} : arguments[0];\n\n var registry = makeCustomElementsRegistry(customElementDefinitions);\n return function htmlDriver(vtree$, driverName) {\n var vtreeLast$ = vtree$.last();\n var output$ = convertCustomElementsToVTree(vtreeLast$, registry, driverName).map(function (vtree) {\n return toHTML(vtree);\n });\n output$.get = makeResponseGetter();\n return output$;\n };\n}\n\nmodule.exports = {\n makePropertiesDriverFromVTree: makePropertiesDriverFromVTree,\n makeReplaceCustomElementsWithVTree$: makeReplaceCustomElementsWithVTree$,\n convertCustomElementsToVTree: convertCustomElementsToVTree,\n\n makeHTMLDriver: makeHTMLDriver\n};\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/lib/web/render-html.js\n ** module id = 102\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/lib/web/render-html.js?");
  6. },function(module,exports,__webpack_require__){eval("var escape = __webpack_require__(104);\nvar extend = __webpack_require__(105);\nvar isVNode = __webpack_require__(17);\nvar isVText = __webpack_require__(10);\nvar isThunk = __webpack_require__(20);\nvar isWidget = __webpack_require__(18);\nvar softHook = __webpack_require__(37);\nvar attrHook = __webpack_require__(101);\nvar paramCase = __webpack_require__(106);\nvar createAttribute = __webpack_require__(112);\nvar voidElements = __webpack_require__(114);\n\nmodule.exports = toHTML;\n\nfunction toHTML(node, parent) {\n if (!node) return '';\n\n if (isThunk(node)) {\n node = node.render();\n }\n\n if (isWidget(node) && node.render) {\n node = node.render();\n }\n\n if (isVNode(node)) {\n return openTag(node) + tagContent(node) + closeTag(node);\n } else if (isVText(node)) {\n if (parent && parent.tagName.toLowerCase() === 'script') return String(node.text);\n return escape(String(node.text));\n }\n\n return '';\n}\n\nfunction openTag(node) {\n var props = node.properties;\n var ret = '<' + node.tagName.toLowerCase();\n\n for (var name in props) {\n var value = props[name];\n if (value == null) continue;\n\n if (name == 'attributes') {\n value = extend({}, value);\n for (var attrProp in value) {\n ret += ' ' + createAttribute(attrProp, value[attrProp], true);\n }\n continue;\n }\n\n if (name == 'style') {\n var css = '';\n value = extend({}, value);\n for (var styleProp in value) {\n css += paramCase(styleProp) + ': ' + value[styleProp] + '; ';\n }\n value = css.trim();\n }\n\n if (value instanceof softHook || value instanceof attrHook) {\n ret += ' ' + createAttribute(name, value.value, true);\n continue;\n }\n\n var attr = createAttribute(name, value);\n if (attr) ret += ' ' + attr;\n }\n\n return ret + '>';\n}\n\nfunction tagContent(node) {\n var innerHTML = node.properties.innerHTML;\n if (innerHTML != null) return innerHTML;\n else {\n var ret = '';\n if (node.children && node.children.length) {\n for (var i = 0, l = node.children.length; i<l; i++) {\n var child = node.children[i];\n ret += toHTML(child, node);\n }\n }\n return ret;\n }\n}\n\nfunction closeTag(node) {\n var tag = node.tagName.toLowerCase();\n return voidElements[tag] ? '' : '</' + tag + '>';\n}\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/vdom-to-html/index.js\n ** module id = 103\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/vdom-to-html/index.js?")},function(module,exports){eval("/*!\n * escape-html\n * Copyright(c) 2012-2013 TJ Holowaychuk\n * MIT Licensed\n */\n\n/**\n * Module exports.\n * @public\n */\n\nmodule.exports = escapeHtml;\n\n/**\n * Escape special characters in the given string of html.\n *\n * @param {string} str The string to escape for inserting into HTML\n * @return {string}\n * @public\n */\n\nfunction escapeHtml(html) {\n return String(html)\n .replace(/&/g, '&amp;')\n .replace(/\"/g, '&quot;')\n .replace(/'/g, '&#39;')\n .replace(/</g, '&lt;')\n .replace(/>/g, '&gt;');\n}\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/vdom-to-html/~/escape-html/index.js\n ** module id = 104\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/vdom-to-html/~/escape-html/index.js?")},function(module,exports){eval("module.exports = extend\n\nfunction extend() {\n var target = {}\n\n for (var i = 0; i < arguments.length; i++) {\n var source = arguments[i]\n\n for (var key in source) {\n if (source.hasOwnProperty(key)) {\n target[key] = source[key]\n }\n }\n }\n\n return target\n}\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/vdom-to-html/~/xtend/immutable.js\n ** module id = 105\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/vdom-to-html/~/xtend/immutable.js?")},function(module,exports,__webpack_require__){eval("var sentenceCase = __webpack_require__(107);\n\n/**\n * Param case a string.\n *\n * @param {String} string\n * @param {String} [locale]\n * @return {String}\n */\nmodule.exports = function (string, locale) {\n return sentenceCase(string, locale, '-');\n};\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/vdom-to-html/~/param-case/param-case.js\n ** module id = 106\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/vdom-to-html/~/param-case/param-case.js?")},function(module,exports,__webpack_require__){eval("var lowerCase = __webpack_require__(108)\n\nvar NON_WORD_REGEXP = __webpack_require__(109)\nvar CAMEL_CASE_REGEXP = __webpack_require__(110)\nvar TRAILING_DIGIT_REGEXP = __webpack_require__(111)\n\n/**\n * Sentence case a string.\n *\n * @param {String} str\n * @param {String} locale\n * @param {String} replacement\n * @return {String}\n */\nmodule.exports = function (str, locale, replacement) {\n if (str == null) {\n return ''\n }\n\n replacement = replacement || ' '\n\n function replace (match, index, string) {\n if (index === 0 || index === (string.length - match.length)) {\n return ''\n }\n\n return replacement\n }\n\n str = String(str)\n // Support camel case (\"camelCase\" -> \"camel Case\").\n .replace(CAMEL_CASE_REGEXP, '$1 $2')\n // Support digit groups (\"test2012\" -> \"test 2012\").\n .replace(TRAILING_DIGIT_REGEXP, '$1 $2')\n // Remove all non-word characters and replace with a single space.\n .replace(NON_WORD_REGEXP, replace)\n\n // Lower case the entire string.\n return lowerCase(str, locale)\n}\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/vdom-to-html/~/param-case/~/sentence-case/sentence-case.js\n ** module id = 107\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/vdom-to-html/~/param-case/~/sentence-case/sentence-case.js?")},function(module,exports){eval("/**\n * Special language-specific overrides.\n *\n * Source: ftp://ftp.unicode.org/Public/UCD/latest/ucd/SpecialCasing.txt\n *\n * @type {Object}\n */\nvar LANGUAGES = {\n tr: {\n regexp: /\\u0130|\\u0049|\\u0049\\u0307/g,\n map: {\n '\\u0130': '\\u0069',\n '\\u0049': '\\u0131',\n '\\u0049\\u0307': '\\u0069'\n }\n },\n az: {\n regexp: /[\\u0130]/g,\n map: {\n '\\u0130': '\\u0069',\n '\\u0049': '\\u0131',\n '\\u0049\\u0307': '\\u0069'\n }\n },\n lt: {\n regexp: /[\\u0049\\u004A\\u012E\\u00CC\\u00CD\\u0128]/g,\n map: {\n '\\u0049': '\\u0069\\u0307',\n '\\u004A': '\\u006A\\u0307',\n '\\u012E': '\\u012F\\u0307',\n '\\u00CC': '\\u0069\\u0307\\u0300',\n '\\u00CD': '\\u0069\\u0307\\u0301',\n '\\u0128': '\\u0069\\u0307\\u0303'\n }\n }\n}\n\n/**\n * Lowercase a string.\n *\n * @param {String} str\n * @return {String}\n */\nmodule.exports = function (str, locale) {\n var lang = LANGUAGES[locale]\n\n str = str == null ? '' : String(str)\n\n if (lang) {\n str = str.replace(lang.regexp, function (m) { return lang.map[m] })\n }\n\n return str.toLowerCase()\n}\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/vdom-to-html/~/param-case/~/sentence-case/~/lower-case/lower-case.js\n ** module id = 108\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/vdom-to-html/~/param-case/~/sentence-case/~/lower-case/lower-case.js?")},function(module,exports){eval("module.exports = /[^\\u0041-\\u005A\\u0061-\\u007A\\u00AA\\u00B5\\u00BA\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02C1\\u02C6-\\u02D1\\u02E0-\\u02E4\\u02EC\\u02EE\\u0370-\\u0374\\u0376\\u0377\\u037A-\\u037D\\u0386\\u0388-\\u038A\\u038C\\u038E-\\u03A1\\u03A3-\\u03F5\\u03F7-\\u0481\\u048A-\\u0527\\u0531-\\u0556\\u0559\\u0561-\\u0587\\u05D0-\\u05EA\\u05F0-\\u05F2\\u0620-\\u064A\\u066E\\u066F\\u0671-\\u06D3\\u06D5\\u06E5\\u06E6\\u06EE\\u06EF\\u06FA-\\u06FC\\u06FF\\u0710\\u0712-\\u072F\\u074D-\\u07A5\\u07B1\\u07CA-\\u07EA\\u07F4\\u07F5\\u07FA\\u0800-\\u0815\\u081A\\u0824\\u0828\\u0840-\\u0858\\u08A0\\u08A2-\\u08AC\\u0904-\\u0939\\u093D\\u0950\\u0958-\\u0961\\u0971-\\u0977\\u0979-\\u097F\\u0985-\\u098C\\u098F\\u0990\\u0993-\\u09A8\\u09AA-\\u09B0\\u09B2\\u09B6-\\u09B9\\u09BD\\u09CE\\u09DC\\u09DD\\u09DF-\\u09E1\\u09F0\\u09F1\\u0A05-\\u0A0A\\u0A0F\\u0A10\\u0A13-\\u0A28\\u0A2A-\\u0A30\\u0A32\\u0A33\\u0A35\\u0A36\\u0A38\\u0A39\\u0A59-\\u0A5C\\u0A5E\\u0A72-\\u0A74\\u0A85-\\u0A8D\\u0A8F-\\u0A91\\u0A93-\\u0AA8\\u0AAA-\\u0AB0\\u0AB2\\u0AB3\\u0AB5-\\u0AB9\\u0ABD\\u0AD0\\u0AE0\\u0AE1\\u0B05-\\u0B0C\\u0B0F\\u0B10\\u0B13-\\u0B28\\u0B2A-\\u0B30\\u0B32\\u0B33\\u0B35-\\u0B39\\u0B3D\\u0B5C\\u0B5D\\u0B5F-\\u0B61\\u0B71\\u0B83\\u0B85-\\u0B8A\\u0B8E-\\u0B90\\u0B92-\\u0B95\\u0B99\\u0B9A\\u0B9C\\u0B9E\\u0B9F\\u0BA3\\u0BA4\\u0BA8-\\u0BAA\\u0BAE-\\u0BB9\\u0BD0\\u0C05-\\u0C0C\\u0C0E-\\u0C10\\u0C12-\\u0C28\\u0C2A-\\u0C33\\u0C35-\\u0C39\\u0C3D\\u0C58\\u0C59\\u0C60\\u0C61\\u0C85-\\u0C8C\\u0C8E-\\u0C90\\u0C92-\\u0CA8\\u0CAA-\\u0CB3\\u0CB5-\\u0CB9\\u0CBD\\u0CDE\\u0CE0\\u0CE1\\u0CF1\\u0CF2\\u0D05-\\u0D0C\\u0D0E-\\u0D10\\u0D12-\\u0D3A\\u0D3D\\u0D4E\\u0D60\\u0D61\\u0D7A-\\u0D7F\\u0D85-\\u0D96\\u0D9A-\\u0DB1\\u0DB3-\\u0DBB\\u0DBD\\u0DC0-\\u0DC6\\u0E01-\\u0E30\\u0E32\\u0E33\\u0E40-\\u0E46\\u0E81\\u0E82\\u0E84\\u0E87\\u0E88\\u0E8A\\u0E8D\\u0E94-\\u0E97\\u0E99-\\u0E9F\\u0EA1-\\u0EA3\\u0EA5\\u0EA7\\u0EAA\\u0EAB\\u0EAD-\\u0EB0\\u0EB2\\u0EB3\\u0EBD\\u0EC0-\\u0EC4\\u0EC6\\u0EDC-\\u0EDF\\u0F00\\u0F40-\\u0F47\\u0F49-\\u0F6C\\u0F88-\\u0F8C\\u1000-\\u102A\\u103F\\u1050-\\u1055\\u105A-\\u105D\\u1061\\u1065\\u1066\\u106E-\\u1070\\u1075-\\u1081\\u108E\\u10A0-\\u10C5\\u10C7\\u10CD\\u10D0-\\u10FA\\u10FC-\\u1248\\u124A-\\u124D\\u1250-\\u1256\\u1258\\u125A-\\u125D\\u1260-\\u1288\\u128A-\\u128D\\u1290-\\u12B0\\u12B2-\\u12B5\\u12B8-\\u12BE\\u12C0\\u12C2-\\u12C5\\u12C8-\\u12D6\\u12D8-\\u1310\\u1312-\\u1315\\u1318-\\u135A\\u1380-\\u138F\\u13A0-\\u13F4\\u1401-\\u166C\\u166F-\\u167F\\u1681-\\u169A\\u16A0-\\u16EA\\u1700-\\u170C\\u170E-\\u1711\\u1720-\\u1731\\u1740-\\u1751\\u1760-\\u176C\\u176E-\\u1770\\u1780-\\u17B3\\u17D7\\u17DC\\u1820-\\u1877\\u1880-\\u18A8\\u18AA\\u18B0-\\u18F5\\u1900-\\u191C\\u1950-\\u196D\\u1970-\\u1974\\u1980-\\u19AB\\u19C1-\\u19C7\\u1A00-\\u1A16\\u1A20-\\u1A54\\u1AA7\\u1B05-\\u1B33\\u1B45-\\u1B4B\\u1B83-\\u1BA0\\u1BAE\\u1BAF\\u1BBA-\\u1BE5\\u1C00-\\u1C23\\u1C4D-\\u1C4F\\u1C5A-\\u1C7D\\u1CE9-\\u1CEC\\u1CEE-\\u1CF1\\u1CF5\\u1CF6\\u1D00-\\u1DBF\\u1E00-\\u1F15\\u1F18-\\u1F1D\\u1F20-\\u1F45\\u1F48-\\u1F4D\\u1F50-\\u1F57\\u1F59\\u1F5B\\u1F5D\\u1F5F-\\u1F7D\\u1F80-\\u1FB4\\u1FB6-\\u1FBC\\u1FBE\\u1FC2-\\u1FC4\\u1FC6-\\u1FCC\\u1FD0-\\u1FD3\\u1FD6-\\u1FDB\\u1FE0-\\u1FEC\\u1FF2-\\u1FF4\\u1FF6-\\u1FFC\\u2071\\u207F\\u2090-\\u209C\\u2102\\u2107\\u210A-\\u2113\\u2115\\u2119-\\u211D\\u2124\\u2126\\u2128\\u212A-\\u212D\\u212F-\\u2139\\u213C-\\u213F\\u2145-\\u2149\\u214E\\u2183\\u2184\\u2C00-\\u2C2E\\u2C30-\\u2C5E\\u2C60-\\u2CE4\\u2CEB-\\u2CEE\\u2CF2\\u2CF3\\u2D00-\\u2D25\\u2D27\\u2D2D\\u2D30-\\u2D67\\u2D6F\\u2D80-\\u2D96\\u2DA0-\\u2DA6\\u2DA8-\\u2DAE\\u2DB0-\\u2DB6\\u2DB8-\\u2DBE\\u2DC0-\\u2DC6\\u2DC8-\\u2DCE\\u2DD0-\\u2DD6\\u2DD8-\\u2DDE\\u2E2F\\u3005\\u3006\\u3031-\\u3035\\u303B\\u303C\\u3041-\\u3096\\u309D-\\u309F\\u30A1-\\u30FA\\u30FC-\\u30FF\\u3105-\\u312D\\u3131-\\u318E\\u31A0-\\u31BA\\u31F0-\\u31FF\\u3400-\\u4DB5\\u4E00-\\u9FCC\\uA000-\\uA48C\\uA4D0-\\uA4FD\\uA500-\\uA60C\\uA610-\\uA61F\\uA62A\\uA62B\\uA640-\\uA66E\\uA67F-\\uA697\\uA6A0-\\uA6E5\\uA717-\\uA71F\\uA722-\\uA788\\uA78B-\\uA78E\\uA790-\\uA793\\uA7A0-\\uA7AA\\uA7F8-\\uA801\\uA803-\\uA805\\uA807-\\uA80A\\uA80C-\\uA822\\uA840-\\uA873\\uA882-\\uA8B3\\uA8F2-\\uA8F7\\uA8FB\\uA90A-\\uA925\\uA930-\\uA946\\uA960-\\uA97C\\uA984-\\uA9B2\\uA9CF\\uAA00-\\uAA28\\uAA40-\\uAA42\\uAA44-\\uAA4B\\uAA60-\\uAA76\\uAA7A\\uAA80-\\uAAAF\\uAAB1\\uAAB5\\uAAB6\\uAAB9-\\uAABD\\uAAC0\\uAAC2\\uAADB-\\uAADD\\uAAE0-\\uAAEA\\uAAF2-\\uAAF4\\uAB01-\\uAB06\\uAB09-\\uAB0E\\uAB11-\\uAB16\\uAB20-\\uAB26\\uAB28-\\uAB2E\\uABC0-\\uABE2\\uAC00-\\uD7A3\\uD7B0-\\uD7C6\\uD7CB-\\uD7FB\\uF900-\\uFA6D\\uFA70-\\uFAD9\\uFB00-\\uFB06\\uFB13-\\uFB17\\uFB1D\\uFB1F-\\uFB28\\uFB2A-\\uFB36\\uFB38-\\uFB3C\\uFB3E\\uFB40\\uFB41\\uFB43\\uFB44\\uFB46-\\uFBB1\\uFBD3-\\uFD3D\\uFD50-\\uFD8F\\uFD92-\\uFDC7\\uFDF0-\\uFDFB\\uFE70-\\uFE74\\uFE76-\\uFEFC\\uFF21-\\uFF3A\\uFF41-\\uFF5A\\uFF66-\\uFFBE\\uFFC2-\\uFFC7\\uFFCA-\\uFFCF\\uFFD2-\\uFFD7\\uFFDA-\\uFFDC\\u0030-\\u0039\\u00B2\\u00B3\\u00B9\\u00BC-\\u00BE\\u0660-\\u0669\\u06F0-\\u06F9\\u07C0-\\u07C9\\u0966-\\u096F\\u09E6-\\u09EF\\u09F4-\\u09F9\\u0A66-\\u0A6F\\u0AE6-\\u0AEF\\u0B66-\\u0B6F\\u0B72-\\u0B77\\u0BE6-\\u0BF2\\u0C66-\\u0C6F\\u0C78-\\u0C7E\\u0CE6-\\u0CEF\\u0D66-\\u0D75\\u0E50-\\u0E59\\u0ED0-\\u0ED9\\u0F20-\\u0F33\\u1040-\\u1049\\u1090-\\u1099\\u1369-\\u137C\\u16EE-\\u16F0\\u17E0-\\u17E9\\u17F0-\\u17F9\\u1810-\\u1819\\u1946-\\u194F\\u19D0-\\u19DA\\u1A80-\\u1A89\\u1A90-\\u1A99\\u1B50-\\u1B59\\u1BB0-\\u1BB9\\u1C40-\\u1C49\\u1C50-\\u1C59\\u2070\\u2074-\\u2079\\u2080-\\u2089\\u2150-\\u2182\\u2185-\\u2189\\u2460-\\u249B\\u24EA-\\u24FF\\u2776-\\u2793\\u2CFD\\u3007\\u3021-\\u3029\\u3038-\\u303A\\u3192-\\u3195\\u3220-\\u3229\\u3248-\\u324F\\u3251-\\u325F\\u3280-\\u3289\\u32B1-\\u32BF\\uA620-\\uA629\\uA6E6-\\uA6EF\\uA830-\\uA835\\uA8D0-\\uA8D9\\uA900-\\uA909\\uA9D0-\\uA9D9\\uAA50-\\uAA59\\uABF0-\\uABF9\\uFF10-\\uFF19]+/g\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/vdom-to-html/~/param-case/~/sentence-case/vendor/non-word-regexp.js\n ** module id = 109\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/vdom-to-html/~/param-case/~/sentence-case/vendor/non-word-regexp.js?")},function(module,exports){eval("module.exports = /([\\u0061-\\u007A\\u00B5\\u00DF-\\u00F6\\u00F8-\\u00FF\\u0101\\u0103\\u0105\\u0107\\u0109\\u010B\\u010D\\u010F\\u0111\\u0113\\u0115\\u0117\\u0119\\u011B\\u011D\\u011F\\u0121\\u0123\\u0125\\u0127\\u0129\\u012B\\u012D\\u012F\\u0131\\u0133\\u0135\\u0137\\u0138\\u013A\\u013C\\u013E\\u0140\\u0142\\u0144\\u0146\\u0148\\u0149\\u014B\\u014D\\u014F\\u0151\\u0153\\u0155\\u0157\\u0159\\u015B\\u015D\\u015F\\u0161\\u0163\\u0165\\u0167\\u0169\\u016B\\u016D\\u016F\\u0171\\u0173\\u0175\\u0177\\u017A\\u017C\\u017E-\\u0180\\u0183\\u0185\\u0188\\u018C\\u018D\\u0192\\u0195\\u0199-\\u019B\\u019E\\u01A1\\u01A3\\u01A5\\u01A8\\u01AA\\u01AB\\u01AD\\u01B0\\u01B4\\u01B6\\u01B9\\u01BA\\u01BD-\\u01BF\\u01C6\\u01C9\\u01CC\\u01CE\\u01D0\\u01D2\\u01D4\\u01D6\\u01D8\\u01DA\\u01DC\\u01DD\\u01DF\\u01E1\\u01E3\\u01E5\\u01E7\\u01E9\\u01EB\\u01ED\\u01EF\\u01F0\\u01F3\\u01F5\\u01F9\\u01FB\\u01FD\\u01FF\\u0201\\u0203\\u0205\\u0207\\u0209\\u020B\\u020D\\u020F\\u0211\\u0213\\u0215\\u0217\\u0219\\u021B\\u021D\\u021F\\u0221\\u0223\\u0225\\u0227\\u0229\\u022B\\u022D\\u022F\\u0231\\u0233-\\u0239\\u023C\\u023F\\u0240\\u0242\\u0247\\u0249\\u024B\\u024D\\u024F-\\u0293\\u0295-\\u02AF\\u0371\\u0373\\u0377\\u037B-\\u037D\\u0390\\u03AC-\\u03CE\\u03D0\\u03D1\\u03D5-\\u03D7\\u03D9\\u03DB\\u03DD\\u03DF\\u03E1\\u03E3\\u03E5\\u03E7\\u03E9\\u03EB\\u03ED\\u03EF-\\u03F3\\u03F5\\u03F8\\u03FB\\u03FC\\u0430-\\u045F\\u0461\\u0463\\u0465\\u0467\\u0469\\u046B\\u046D\\u046F\\u0471\\u0473\\u0475\\u0477\\u0479\\u047B\\u047D\\u047F\\u0481\\u048B\\u048D\\u048F\\u0491\\u0493\\u0495\\u0497\\u0499\\u049B\\u049D\\u049F\\u04A1\\u04A3\\u04A5\\u04A7\\u04A9\\u04AB\\u04AD\\u04AF\\u04B1\\u04B3\\u04B5\\u04B7\\u04B9\\u04BB\\u04BD\\u04BF\\u04C2\\u04C4\\u04C6\\u04C8\\u04CA\\u04CC\\u04CE\\u04CF\\u04D1\\u04D3\\u04D5\\u04D7\\u04D9\\u04DB\\u04DD\\u04DF\\u04E1\\u04E3\\u04E5\\u04E7\\u04E9\\u04EB\\u04ED\\u04EF\\u04F1\\u04F3\\u04F5\\u04F7\\u04F9\\u04FB\\u04FD\\u04FF\\u0501\\u0503\\u0505\\u0507\\u0509\\u050B\\u050D\\u050F\\u0511\\u0513\\u0515\\u0517\\u0519\\u051B\\u051D\\u051F\\u0521\\u0523\\u0525\\u0527\\u0561-\\u0587\\u1D00-\\u1D2B\\u1D6B-\\u1D77\\u1D79-\\u1D9A\\u1E01\\u1E03\\u1E05\\u1E07\\u1E09\\u1E0B\\u1E0D\\u1E0F\\u1E11\\u1E13\\u1E15\\u1E17\\u1E19\\u1E1B\\u1E1D\\u1E1F\\u1E21\\u1E23\\u1E25\\u1E27\\u1E29\\u1E2B\\u1E2D\\u1E2F\\u1E31\\u1E33\\u1E35\\u1E37\\u1E39\\u1E3B\\u1E3D\\u1E3F\\u1E41\\u1E43\\u1E45\\u1E47\\u1E49\\u1E4B\\u1E4D\\u1E4F\\u1E51\\u1E53\\u1E55\\u1E57\\u1E59\\u1E5B\\u1E5D\\u1E5F\\u1E61\\u1E63\\u1E65\\u1E67\\u1E69\\u1E6B\\u1E6D\\u1E6F\\u1E71\\u1E73\\u1E75\\u1E77\\u1E79\\u1E7B\\u1E7D\\u1E7F\\u1E81\\u1E83\\u1E85\\u1E87\\u1E89\\u1E8B\\u1E8D\\u1E8F\\u1E91\\u1E93\\u1E95-\\u1E9D\\u1E9F\\u1EA1\\u1EA3\\u1EA5\\u1EA7\\u1EA9\\u1EAB\\u1EAD\\u1EAF\\u1EB1\\u1EB3\\u1EB5\\u1EB7\\u1EB9\\u1EBB\\u1EBD\\u1EBF\\u1EC1\\u1EC3\\u1EC5\\u1EC7\\u1EC9\\u1ECB\\u1ECD\\u1ECF\\u1ED1\\u1ED3\\u1ED5\\u1ED7\\u1ED9\\u1EDB\\u1EDD\\u1EDF\\u1EE1\\u1EE3\\u1EE5\\u1EE7\\u1EE9\\u1EEB\\u1EED\\u1EEF\\u1EF1\\u1EF3\\u1EF5\\u1EF7\\u1EF9\\u1EFB\\u1EFD\\u1EFF-\\u1F07\\u1F10-\\u1F15\\u1F20-\\u1F27\\u1F30-\\u1F37\\u1F40-\\u1F45\\u1F50-\\u1F57\\u1F60-\\u1F67\\u1F70-\\u1F7D\\u1F80-\\u1F87\\u1F90-\\u1F97\\u1FA0-\\u1FA7\\u1FB0-\\u1FB4\\u1FB6\\u1FB7\\u1FBE\\u1FC2-\\u1FC4\\u1FC6\\u1FC7\\u1FD0-\\u1FD3\\u1FD6\\u1FD7\\u1FE0-\\u1FE7\\u1FF2-\\u1FF4\\u1FF6\\u1FF7\\u210A\\u210E\\u210F\\u2113\\u212F\\u2134\\u2139\\u213C\\u213D\\u2146-\\u2149\\u214E\\u2184\\u2C30-\\u2C5E\\u2C61\\u2C65\\u2C66\\u2C68\\u2C6A\\u2C6C\\u2C71\\u2C73\\u2C74\\u2C76-\\u2C7B\\u2C81\\u2C83\\u2C85\\u2C87\\u2C89\\u2C8B\\u2C8D\\u2C8F\\u2C91\\u2C93\\u2C95\\u2C97\\u2C99\\u2C9B\\u2C9D\\u2C9F\\u2CA1\\u2CA3\\u2CA5\\u2CA7\\u2CA9\\u2CAB\\u2CAD\\u2CAF\\u2CB1\\u2CB3\\u2CB5\\u2CB7\\u2CB9\\u2CBB\\u2CBD\\u2CBF\\u2CC1\\u2CC3\\u2CC5\\u2CC7\\u2CC9\\u2CCB\\u2CCD\\u2CCF\\u2CD1\\u2CD3\\u2CD5\\u2CD7\\u2CD9\\u2CDB\\u2CDD\\u2CDF\\u2CE1\\u2CE3\\u2CE4\\u2CEC\\u2CEE\\u2CF3\\u2D00-\\u2D25\\u2D27\\u2D2D\\uA641\\uA643\\uA645\\uA647\\uA649\\uA64B\\uA64D\\uA64F\\uA651\\uA653\\uA655\\uA657\\uA659\\uA65B\\uA65D\\uA65F\\uA661\\uA663\\uA665\\uA667\\uA669\\uA66B\\uA66D\\uA681\\uA683\\uA685\\uA687\\uA689\\uA68B\\uA68D\\uA68F\\uA691\\uA693\\uA695\\uA697\\uA723\\uA725\\uA727\\uA729\\uA72B\\uA72D\\uA72F-\\uA731\\uA733\\uA735\\uA737\\uA739\\uA73B\\uA73D\\uA73F\\uA741\\uA743\\uA745\\uA747\\uA749\\uA74B\\uA74D\\uA74F\\uA751\\uA753\\uA755\\uA757\\uA759\\uA75B\\uA75D\\uA75F\\uA761\\uA763\\uA765\\uA767\\uA769\\uA76B\\uA76D\\uA76F\\uA771-\\uA778\\uA77A\\uA77C\\uA77F\\uA781\\uA783\\uA785\\uA787\\uA78C\\uA78E\\uA791\\uA793\\uA7A1\\uA7A3\\uA7A5\\uA7A7\\uA7A9\\uA7FA\\uFB00-\\uFB06\\uFB13-\\uFB17\\uFF41-\\uFF5A])([\\u0041-\\u005A\\u00C0-\\u00D6\\u00D8-\\u00DE\\u0100\\u0102\\u0104\\u0106\\u0108\\u010A\\u010C\\u010E\\u0110\\u0112\\u0114\\u0116\\u0118\\u011A\\u011C\\u011E\\u0120\\u0122\\u0124\\u0126\\u0128\\u012A\\u012C\\u012E\\u0130\\u0132\\u0134\\u0136\\u0139\\u013B\\u013D\\u013F\\u0141\\u0143\\u0145\\u0147\\u014A\\u014C\\u014E\\u0150\\u0152\\u0154\\u0156\\u0158\\u015A\\u015C\\u015E\\u0160\\u0162\\u0164\\u0166\\u0168\\u016A\\u016C\\u016E\\u0170\\u0172\\u0174\\u0176\\u0178\\u0179\\u017B\\u017D\\u0181\\u0182\\u0184\\u0186\\u0187\\u0189-\\u018B\\u018E-\\u0191\\u0193\\u0194\\u0196-\\u0198\\u019C\\u019D\\u019F\\u01A0\\u01A2\\u01A4\\u01A6\\u01A7\\u01A9\\u01AC\\u01AE\\u01AF\\u01B1-\\u01B3\\u01B5\\u01B7\\u01B8\\u01BC\\u01C4\\u01C7\\u01CA\\u01CD\\u01CF\\u01D1\\u01D3\\u01D5\\u01D7\\u01D9\\u01DB\\u01DE\\u01E0\\u01E2\\u01E4\\u01E6\\u01E8\\u01EA\\u01EC\\u01EE\\u01F1\\u01F4\\u01F6-\\u01F8\\u01FA\\u01FC\\u01FE\\u0200\\u0202\\u0204\\u0206\\u0208\\u020A\\u020C\\u020E\\u0210\\u0212\\u0214\\u0216\\u0218\\u021A\\u021C\\u021E\\u0220\\u0222\\u0224\\u0226\\u0228\\u022A\\u022C\\u022E\\u0230\\u0232\\u023A\\u023B\\u023D\\u023E\\u0241\\u0243-\\u0246\\u0248\\u024A\\u024C\\u024E\\u0370\\u0372\\u0376\\u0386\\u0388-\\u038A\\u038C\\u038E\\u038F\\u0391-\\u03A1\\u03A3-\\u03AB\\u03CF\\u03D2-\\u03D4\\u03D8\\u03DA\\u03DC\\u03DE\\u03E0\\u03E2\\u03E4\\u03E6\\u03E8\\u03EA\\u03EC\\u03EE\\u03F4\\u03F7\\u03F9\\u03FA\\u03FD-\\u042F\\u0460\\u0462\\u0464\\u0466\\u0468\\u046A\\u046C\\u046E\\u0470\\u0472\\u0474\\u0476\\u0478\\u047A\\u047C\\u047E\\u0480\\u048A\\u048C\\u048E\\u0490\\u0492\\u0494\\u0496\\u0498\\u049A\\u049C\\u049E\\u04A0\\u04A2\\u04A4\\u04A6\\u04A8\\u04AA\\u04AC\\u04AE\\u04B0\\u04B2\\u04B4\\u04B6\\u04B8\\u04BA\\u04BC\\u04BE\\u04C0\\u04C1\\u04C3\\u04C5\\u04C7\\u04C9\\u04CB\\u04CD\\u04D0\\u04D2\\u04D4\\u04D6\\u04D8\\u04DA\\u04DC\\u04DE\\u04E0\\u04E2\\u04E4\\u04E6\\u04E8\\u04EA\\u04EC\\u04EE\\u04F0\\u04F2\\u04F4\\u04F6\\u04F8\\u04FA\\u04FC\\u04FE\\u0500\\u0502\\u0504\\u0506\\u0508\\u050A\\u050C\\u050E\\u0510\\u0512\\u0514\\u0516\\u0518\\u051A\\u051C\\u051E\\u0520\\u0522\\u0524\\u0526\\u0531-\\u0556\\u10A0-\\u10C5\\u10C7\\u10CD\\u1E00\\u1E02\\u1E04\\u1E06\\u1E08\\u1E0A\\u1E0C\\u1E0E\\u1E10\\u1E12\\u1E14\\u1E16\\u1E18\\u1E1A\\u1E1C\\u1E1E\\u1E20\\u1E22\\u1E24\\u1E26\\u1E28\\u1E2A\\u1E2C\\u1E2E\\u1E30\\u1E32\\u1E34\\u1E36\\u1E38\\u1E3A\\u1E3C\\u1E3E\\u1E40\\u1E42\\u1E44\\u1E46\\u1E48\\u1E4A\\u1E4C\\u1E4E\\u1E50\\u1E52\\u1E54\\u1E56\\u1E58\\u1E5A\\u1E5C\\u1E5E\\u1E60\\u1E62\\u1E64\\u1E66\\u1E68\\u1E6A\\u1E6C\\u1E6E\\u1E70\\u1E72\\u1E74\\u1E76\\u1E78\\u1E7A\\u1E7C\\u1E7E\\u1E80\\u1E82\\u1E84\\u1E86\\u1E88\\u1E8A\\u1E8C\\u1E8E\\u1E90\\u1E92\\u1E94\\u1E9E\\u1EA0\\u1EA2\\u1EA4\\u1EA6\\u1EA8\\u1EAA\\u1EAC\\u1EAE\\u1EB0\\u1EB2\\u1EB4\\u1EB6\\u1EB8\\u1EBA\\u1EBC\\u1EBE\\u1EC0\\u1EC2\\u1EC4\\u1EC6\\u1EC8\\u1ECA\\u1ECC\\u1ECE\\u1ED0\\u1ED2\\u1ED4\\u1ED6\\u1ED8\\u1EDA\\u1EDC\\u1EDE\\u1EE0\\u1EE2\\u1EE4\\u1EE6\\u1EE8\\u1EEA\\u1EEC\\u1EEE\\u1EF0\\u1EF2\\u1EF4\\u1EF6\\u1EF8\\u1EFA\\u1EFC\\u1EFE\\u1F08-\\u1F0F\\u1F18-\\u1F1D\\u1F28-\\u1F2F\\u1F38-\\u1F3F\\u1F48-\\u1F4D\\u1F59\\u1F5B\\u1F5D\\u1F5F\\u1F68-\\u1F6F\\u1FB8-\\u1FBB\\u1FC8-\\u1FCB\\u1FD8-\\u1FDB\\u1FE8-\\u1FEC\\u1FF8-\\u1FFB\\u2102\\u2107\\u210B-\\u210D\\u2110-\\u2112\\u2115\\u2119-\\u211D\\u2124\\u2126\\u2128\\u212A-\\u212D\\u2130-\\u2133\\u213E\\u213F\\u2145\\u2183\\u2C00-\\u2C2E\\u2C60\\u2C62-\\u2C64\\u2C67\\u2C69\\u2C6B\\u2C6D-\\u2C70\\u2C72\\u2C75\\u2C7E-\\u2C80\\u2C82\\u2C84\\u2C86\\u2C88\\u2C8A\\u2C8C\\u2C8E\\u2C90\\u2C92\\u2C94\\u2C96\\u2C98\\u2C9A\\u2C9C\\u2C9E\\u2CA0\\u2CA2\\u2CA4\\u2CA6\\u2CA8\\u2CAA\\u2CAC\\u2CAE\\u2CB0\\u2CB2\\u2CB4\\u2CB6\\u2CB8\\u2CBA\\u2CBC\\u2CBE\\u2CC0\\u2CC2\\u2CC4\\u2CC6\\u2CC8\\u2CCA\\u2CCC\\u2CCE\\u2CD0\\u2CD2\\u2CD4\\u2CD6\\u2CD8\\u2CDA\\u2CDC\\u2CDE\\u2CE0\\u2CE2\\u2CEB\\u2CED\\u2CF2\\uA640\\uA642\\uA644\\uA646\\uA648\\uA64A\\uA64C\\uA64E\\uA650\\uA652\\uA654\\uA656\\uA658\\uA65A\\uA65C\\uA65E\\uA660\\uA662\\uA664\\uA666\\uA668\\uA66A\\uA66C\\uA680\\uA682\\uA684\\uA686\\uA688\\uA68A\\uA68C\\uA68E\\uA690\\uA692\\uA694\\uA696\\uA722\\uA724\\uA726\\uA728\\uA72A\\uA72C\\uA72E\\uA732\\uA734\\uA736\\uA738\\uA73A\\uA73C\\uA73E\\uA740\\uA742\\uA744\\uA746\\uA748\\uA74A\\uA74C\\uA74E\\uA750\\uA752\\uA754\\uA756\\uA758\\uA75A\\uA75C\\uA75E\\uA760\\uA762\\uA764\\uA766\\uA768\\uA76A\\uA76C\\uA76E\\uA779\\uA77B\\uA77D\\uA77E\\uA780\\uA782\\uA784\\uA786\\uA78B\\uA78D\\uA790\\uA792\\uA7A0\\uA7A2\\uA7A4\\uA7A6\\uA7A8\\uA7AA\\uFF21-\\uFF3A\\u0030-\\u0039\\u00B2\\u00B3\\u00B9\\u00BC-\\u00BE\\u0660-\\u0669\\u06F0-\\u06F9\\u07C0-\\u07C9\\u0966-\\u096F\\u09E6-\\u09EF\\u09F4-\\u09F9\\u0A66-\\u0A6F\\u0AE6-\\u0AEF\\u0B66-\\u0B6F\\u0B72-\\u0B77\\u0BE6-\\u0BF2\\u0C66-\\u0C6F\\u0C78-\\u0C7E\\u0CE6-\\u0CEF\\u0D66-\\u0D75\\u0E50-\\u0E59\\u0ED0-\\u0ED9\\u0F20-\\u0F33\\u1040-\\u1049\\u1090-\\u1099\\u1369-\\u137C\\u16EE-\\u16F0\\u17E0-\\u17E9\\u17F0-\\u17F9\\u1810-\\u1819\\u1946-\\u194F\\u19D0-\\u19DA\\u1A80-\\u1A89\\u1A90-\\u1A99\\u1B50-\\u1B59\\u1BB0-\\u1BB9\\u1C40-\\u1C49\\u1C50-\\u1C59\\u2070\\u2074-\\u2079\\u2080-\\u2089\\u2150-\\u2182\\u2185-\\u2189\\u2460-\\u249B\\u24EA-\\u24FF\\u2776-\\u2793\\u2CFD\\u3007\\u3021-\\u3029\\u3038-\\u303A\\u3192-\\u3195\\u3220-\\u3229\\u3248-\\u324F\\u3251-\\u325F\\u3280-\\u3289\\u32B1-\\u32BF\\uA620-\\uA629\\uA6E6-\\uA6EF\\uA830-\\uA835\\uA8D0-\\uA8D9\\uA900-\\uA909\\uA9D0-\\uA9D9\\uAA50-\\uAA59\\uABF0-\\uABF9\\uFF10-\\uFF19])/g\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/vdom-to-html/~/param-case/~/sentence-case/vendor/camel-case-regexp.js\n ** module id = 110\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/vdom-to-html/~/param-case/~/sentence-case/vendor/camel-case-regexp.js?")},function(module,exports){eval("module.exports = /([\\u0030-\\u0039\\u00B2\\u00B3\\u00B9\\u00BC-\\u00BE\\u0660-\\u0669\\u06F0-\\u06F9\\u07C0-\\u07C9\\u0966-\\u096F\\u09E6-\\u09EF\\u09F4-\\u09F9\\u0A66-\\u0A6F\\u0AE6-\\u0AEF\\u0B66-\\u0B6F\\u0B72-\\u0B77\\u0BE6-\\u0BF2\\u0C66-\\u0C6F\\u0C78-\\u0C7E\\u0CE6-\\u0CEF\\u0D66-\\u0D75\\u0E50-\\u0E59\\u0ED0-\\u0ED9\\u0F20-\\u0F33\\u1040-\\u1049\\u1090-\\u1099\\u1369-\\u137C\\u16EE-\\u16F0\\u17E0-\\u17E9\\u17F0-\\u17F9\\u1810-\\u1819\\u1946-\\u194F\\u19D0-\\u19DA\\u1A80-\\u1A89\\u1A90-\\u1A99\\u1B50-\\u1B59\\u1BB0-\\u1BB9\\u1C40-\\u1C49\\u1C50-\\u1C59\\u2070\\u2074-\\u2079\\u2080-\\u2089\\u2150-\\u2182\\u2185-\\u2189\\u2460-\\u249B\\u24EA-\\u24FF\\u2776-\\u2793\\u2CFD\\u3007\\u3021-\\u3029\\u3038-\\u303A\\u3192-\\u3195\\u3220-\\u3229\\u3248-\\u324F\\u3251-\\u325F\\u3280-\\u3289\\u32B1-\\u32BF\\uA620-\\uA629\\uA6E6-\\uA6EF\\uA830-\\uA835\\uA8D0-\\uA8D9\\uA900-\\uA909\\uA9D0-\\uA9D9\\uAA50-\\uAA59\\uABF0-\\uABF9\\uFF10-\\uFF19])([^\\u0030-\\u0039\\u00B2\\u00B3\\u00B9\\u00BC-\\u00BE\\u0660-\\u0669\\u06F0-\\u06F9\\u07C0-\\u07C9\\u0966-\\u096F\\u09E6-\\u09EF\\u09F4-\\u09F9\\u0A66-\\u0A6F\\u0AE6-\\u0AEF\\u0B66-\\u0B6F\\u0B72-\\u0B77\\u0BE6-\\u0BF2\\u0C66-\\u0C6F\\u0C78-\\u0C7E\\u0CE6-\\u0CEF\\u0D66-\\u0D75\\u0E50-\\u0E59\\u0ED0-\\u0ED9\\u0F20-\\u0F33\\u1040-\\u1049\\u1090-\\u1099\\u1369-\\u137C\\u16EE-\\u16F0\\u17E0-\\u17E9\\u17F0-\\u17F9\\u1810-\\u1819\\u1946-\\u194F\\u19D0-\\u19DA\\u1A80-\\u1A89\\u1A90-\\u1A99\\u1B50-\\u1B59\\u1BB0-\\u1BB9\\u1C40-\\u1C49\\u1C50-\\u1C59\\u2070\\u2074-\\u2079\\u2080-\\u2089\\u2150-\\u2182\\u2185-\\u2189\\u2460-\\u249B\\u24EA-\\u24FF\\u2776-\\u2793\\u2CFD\\u3007\\u3021-\\u3029\\u3038-\\u303A\\u3192-\\u3195\\u3220-\\u3229\\u3248-\\u324F\\u3251-\\u325F\\u3280-\\u3289\\u32B1-\\u32BF\\uA620-\\uA629\\uA6E6-\\uA6EF\\uA830-\\uA835\\uA8D0-\\uA8D9\\uA900-\\uA909\\uA9D0-\\uA9D9\\uAA50-\\uAA59\\uABF0-\\uABF9\\uFF10-\\uFF19])/g\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/vdom-to-html/~/param-case/~/sentence-case/vendor/trailing-digit-regexp.js\n ** module id = 111\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/vdom-to-html/~/param-case/~/sentence-case/vendor/trailing-digit-regexp.js?")},function(module,exports,__webpack_require__){eval("var escape = __webpack_require__(104);\nvar propConfig = __webpack_require__(113);\nvar types = propConfig.attributeTypes;\nvar properties = propConfig.properties;\nvar attributeNames = propConfig.attributeNames;\n\nvar prefixAttribute = memoizeString(function (name) {\n return escape(name) + '=\"';\n});\n\nmodule.exports = createAttribute;\n\n/**\n * Create attribute string.\n *\n * @param {String} name The name of the property or attribute\n * @param {*} value The value\n * @param {Boolean} [isAttribute] Denotes whether `name` is an attribute.\n * @return {?String} Attribute string || null if not a valid property or custom attribute.\n */\n\nfunction createAttribute(name, value, isAttribute) {\n if (properties.hasOwnProperty(name)) {\n if (shouldSkip(name, value)) return '';\n name = (attributeNames[name] || name).toLowerCase();\n var attrType = properties[name];\n // for BOOLEAN `value` only has to be truthy\n // for OVERLOADED_BOOLEAN `value` has to be === true\n if ((attrType === types.BOOLEAN) ||\n (attrType === types.OVERLOADED_BOOLEAN && value === true)) {\n return escape(name);\n }\n return prefixAttribute(name) + escape(value) + '\"';\n } else if (isAttribute) {\n if (value == null) return '';\n return prefixAttribute(name) + escape(value) + '\"';\n }\n // return null if `name` is neither a valid property nor an attribute\n return null;\n}\n\n/**\n * Should skip false boolean attributes.\n */\n\nfunction shouldSkip(name, value) {\n var attrType = properties[name];\n return value == null ||\n (attrType === types.BOOLEAN && !value) ||\n (attrType === types.OVERLOADED_BOOLEAN && value === false);\n}\n\n/**\n * Memoizes the return value of a function that accepts one string argument.\n *\n * @param {function} callback\n * @return {function}\n */\n\nfunction memoizeString(callback) {\n var cache = {};\n return function(string) {\n if (cache.hasOwnProperty(string)) {\n return cache[string];\n } else {\n return cache[string] = callback.call(this, string);\n }\n };\n}\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/vdom-to-html/create-attribute.js\n ** module id = 112\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/vdom-to-html/create-attribute.js?")},function(module,exports){eval("/**\n * Attribute types.\n */\n\nvar types = {\n BOOLEAN: 1,\n OVERLOADED_BOOLEAN: 2\n};\n\n/**\n * Properties.\n *\n * Taken from https://github.com/facebook/react/blob/847357e42e5267b04dd6e297219eaa125ab2f9f4/src/browser/ui/dom/HTMLDOMPropertyConfig.js\n *\n */\n\nvar properties = {\n /**\n * Standard Properties\n */\n accept: true,\n acceptCharset: true,\n accessKey: true,\n action: true,\n allowFullScreen: types.BOOLEAN,\n allowTransparency: true,\n alt: true,\n async: types.BOOLEAN,\n autocomplete: true,\n autofocus: types.BOOLEAN,\n autoplay: types.BOOLEAN,\n cellPadding: true,\n cellSpacing: true,\n charset: true,\n checked: types.BOOLEAN,\n classID: true,\n className: true,\n cols: true,\n colSpan: true,\n content: true,\n contentEditable: true,\n contextMenu: true,\n controls: types.BOOLEAN,\n coords: true,\n crossOrigin: true,\n data: true, // For `<object />` acts as `src`.\n dateTime: true,\n defer: types.BOOLEAN,\n dir: true,\n disabled: types.BOOLEAN,\n download: types.OVERLOADED_BOOLEAN,\n draggable: true,\n enctype: true,\n form: true,\n formAction: true,\n formEncType: true,\n formMethod: true,\n formNoValidate: types.BOOLEAN,\n formTarget: true,\n frameBorder: true,\n headers: true,\n height: true,\n hidden: types.BOOLEAN,\n href: true,\n hreflang: true,\n htmlFor: true,\n httpEquiv: true,\n icon: true,\n id: true,\n label: true,\n lang: true,\n list: true,\n loop: types.BOOLEAN,\n manifest: true,\n marginHeight: true,\n marginWidth: true,\n max: true,\n maxLength: true,\n media: true,\n mediaGroup: true,\n method: true,\n min: true,\n multiple: types.BOOLEAN,\n muted: types.BOOLEAN,\n name: true,\n noValidate: types.BOOLEAN,\n open: true,\n pattern: true,\n placeholder: true,\n poster: true,\n preload: true,\n radiogroup: true,\n readOnly: types.BOOLEAN,\n rel: true,\n required: types.BOOLEAN,\n role: true,\n rows: true,\n rowSpan: true,\n sandbox: true,\n scope: true,\n scrolling: true,\n seamless: types.BOOLEAN,\n selected: types.BOOLEAN,\n shape: true,\n size: true,\n sizes: true,\n span: true,\n spellcheck: true,\n src: true,\n srcdoc: true,\n srcset: true,\n start: true,\n step: true,\n style: true,\n tabIndex: true,\n target: true,\n title: true,\n type: true,\n useMap: true,\n value: true,\n width: true,\n wmode: true,\n\n /**\n * Non-standard Properties\n */\n // autoCapitalize and autoCorrect are supported in Mobile Safari for\n // keyboard hints.\n autocapitalize: true,\n autocorrect: true,\n // itemProp, itemScope, itemType are for Microdata support. See\n // http://schema.org/docs/gs.html\n itemProp: true,\n itemScope: types.BOOLEAN,\n itemType: true,\n // property is supported for OpenGraph in meta tags.\n property: true\n};\n\n/**\n * Properties to attributes mapping.\n *\n * The ones not here are simply converted to lower case.\n */\n\nvar attributeNames = {\n acceptCharset: 'accept-charset',\n className: 'class',\n htmlFor: 'for',\n httpEquiv: 'http-equiv'\n};\n\n/**\n * Exports.\n */\n\nmodule.exports = {\n attributeTypes: types,\n properties: properties,\n attributeNames: attributeNames\n};\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/vdom-to-html/property-config.js\n ** module id = 113\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/vdom-to-html/property-config.js?")},function(module,exports){eval("\n/**\n * Void elements.\n *\n * https://github.com/facebook/react/blob/v0.12.0/src/browser/ui/ReactDOMComponent.js#L99\n */\n\nmodule.exports = {\n 'area': true,\n 'base': true,\n 'br': true,\n 'col': true,\n 'embed': true,\n 'hr': true,\n 'img': true,\n 'input': true,\n 'keygen': true,\n 'link': true,\n 'meta': true,\n 'param': true,\n 'source': true,\n 'track': true,\n 'wbr': true\n};\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/~/vdom-to-html/void-elements.js\n ** module id = 114\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/~/vdom-to-html/void-elements.js?");
  7. },function(module,exports,__webpack_require__){eval("'use strict';\nvar Rx = __webpack_require__(4);\n\nfunction makeRequestProxies(drivers) {\n var requestProxies = {};\n for (var _name in drivers) {\n if (drivers.hasOwnProperty(_name)) {\n requestProxies[_name] = new Rx.ReplaySubject(1);\n }\n }\n return requestProxies;\n}\n\nfunction callDrivers(drivers, requestProxies) {\n var responses = {};\n for (var _name2 in drivers) {\n if (drivers.hasOwnProperty(_name2)) {\n responses[_name2] = drivers[_name2](requestProxies[_name2], _name2);\n }\n }\n return responses;\n}\n\nfunction makeDispose(requestProxies, rawResponses) {\n return function dispose() {\n for (var x in requestProxies) {\n if (requestProxies.hasOwnProperty(x)) {\n requestProxies[x].dispose();\n }\n }\n for (var _name3 in rawResponses) {\n if (rawResponses.hasOwnProperty(_name3) && typeof rawResponses[_name3].dispose === 'function') {\n rawResponses[_name3].dispose();\n }\n }\n };\n}\n\nfunction makeAppInput(requestProxies, rawResponses) {\n Object.defineProperty(rawResponses, 'dispose', {\n enumerable: false,\n value: makeDispose(requestProxies, rawResponses)\n });\n return rawResponses;\n}\n\nfunction replicateMany(original, imitators) {\n for (var _name4 in original) {\n if (original.hasOwnProperty(_name4)) {\n if (imitators.hasOwnProperty(_name4) && !imitators[_name4].isDisposed) {\n original[_name4].subscribe(imitators[_name4].asObserver());\n }\n }\n }\n}\n\nfunction isObjectEmpty(obj) {\n for (var key in obj) {\n if (obj.hasOwnProperty(key)) {\n return false;\n }\n }\n return true;\n}\n\nfunction run(app, drivers) {\n if (typeof app !== 'function') {\n throw new Error('First argument given to Cycle.run() must be the `app` ' + 'function.');\n }\n if (typeof drivers !== 'object' || drivers === null) {\n throw new Error('Second argument given to Cycle.run() must be an object ' + 'with driver functions as properties.');\n }\n if (isObjectEmpty(drivers)) {\n throw new Error('Second argument given to Cycle.run() must be an object ' + 'with at least one driver function declared as a property.');\n }\n\n var requestProxies = makeRequestProxies(drivers);\n var rawResponses = callDrivers(drivers, requestProxies);\n var responses = makeAppInput(requestProxies, rawResponses);\n var requests = app(responses);\n setTimeout(function () {\n return replicateMany(requests, requestProxies);\n }, 1);\n return [requests, responses];\n}\n\nmodule.exports = run;\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/cyclejs/lib/core/run.js\n ** module id = 115\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/cyclejs/lib/core/run.js?")},function(module,exports,__webpack_require__){eval("var __WEBPACK_AMD_DEFINE_RESULT__;/* WEBPACK VAR INJECTION */(function(module, global) {/**\n * @license\n * lodash 3.10.0 (Custom Build) <https://lodash.com/>\n * Build: `lodash modern -d -o ./index.js`\n * Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>\n * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>\n * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors\n * Available under MIT license <https://lodash.com/license>\n */\n;(function() {\n\n /** Used as a safe reference for `undefined` in pre-ES5 environments. */\n var undefined;\n\n /** Used as the semantic version number. */\n var VERSION = '3.10.0';\n\n /** Used to compose bitmasks for wrapper metadata. */\n var BIND_FLAG = 1,\n BIND_KEY_FLAG = 2,\n CURRY_BOUND_FLAG = 4,\n CURRY_FLAG = 8,\n CURRY_RIGHT_FLAG = 16,\n PARTIAL_FLAG = 32,\n PARTIAL_RIGHT_FLAG = 64,\n ARY_FLAG = 128,\n REARG_FLAG = 256;\n\n /** Used as default options for `_.trunc`. */\n var DEFAULT_TRUNC_LENGTH = 30,\n DEFAULT_TRUNC_OMISSION = '...';\n\n /** Used to detect when a function becomes hot. */\n var HOT_COUNT = 150,\n HOT_SPAN = 16;\n\n /** Used as the size to enable large array optimizations. */\n var LARGE_ARRAY_SIZE = 200;\n\n /** Used to indicate the type of lazy iteratees. */\n var LAZY_FILTER_FLAG = 1,\n LAZY_MAP_FLAG = 2;\n\n /** Used as the `TypeError` message for \"Functions\" methods. */\n var FUNC_ERROR_TEXT = 'Expected a function';\n\n /** Used as the internal argument placeholder. */\n var PLACEHOLDER = '__lodash_placeholder__';\n\n /** `Object#toString` result references. */\n var argsTag = '[object Arguments]',\n arrayTag = '[object Array]',\n boolTag = '[object Boolean]',\n dateTag = '[object Date]',\n errorTag = '[object Error]',\n funcTag = '[object Function]',\n mapTag = '[object Map]',\n numberTag = '[object Number]',\n objectTag = '[object Object]',\n regexpTag = '[object RegExp]',\n setTag = '[object Set]',\n stringTag = '[object String]',\n weakMapTag = '[object WeakMap]';\n\n var arrayBufferTag = '[object ArrayBuffer]',\n float32Tag = '[object Float32Array]',\n float64Tag = '[object Float64Array]',\n int8Tag = '[object Int8Array]',\n int16Tag = '[object Int16Array]',\n int32Tag = '[object Int32Array]',\n uint8Tag = '[object Uint8Array]',\n uint8ClampedTag = '[object Uint8ClampedArray]',\n uint16Tag = '[object Uint16Array]',\n uint32Tag = '[object Uint32Array]';\n\n /** Used to match empty string literals in compiled template source. */\n var reEmptyStringLeading = /\\b__p \\+= '';/g,\n reEmptyStringMiddle = /\\b(__p \\+=) '' \\+/g,\n reEmptyStringTrailing = /(__e\\(.*?\\)|\\b__t\\)) \\+\\n'';/g;\n\n /** Used to match HTML entities and HTML characters. */\n var reEscapedHtml = /&(?:amp|lt|gt|quot|#39|#96);/g,\n reUnescapedHtml = /[&<>\"'`]/g,\n reHasEscapedHtml = RegExp(reEscapedHtml.source),\n reHasUnescapedHtml = RegExp(reUnescapedHtml.source);\n\n /** Used to match template delimiters. */\n var reEscape = /<%-([\\s\\S]+?)%>/g,\n reEvaluate = /<%([\\s\\S]+?)%>/g,\n reInterpolate = /<%=([\\s\\S]+?)%>/g;\n\n /** Used to match property names within property paths. */\n var reIsDeepProp = /\\.|\\[(?:[^[\\]]*|([\"'])(?:(?!\\1)[^\\n\\\\]|\\\\.)*?\\1)\\]/,\n reIsPlainProp = /^\\w*$/,\n rePropName = /[^.[\\]]+|\\[(?:(-?\\d+(?:\\.\\d+)?)|([\"'])((?:(?!\\2)[^\\n\\\\]|\\\\.)*?)\\2)\\]/g;\n\n /**\n * Used to match `RegExp` [syntax characters](http://ecma-international.org/ecma-262/6.0/#sec-patterns)\n * and those outlined by [`EscapeRegExpPattern`](http://ecma-international.org/ecma-262/6.0/#sec-escaperegexppattern).\n */\n var reRegExpChars = /^[:!,]|[\\\\^$.*+?()[\\]{}|\\/]|(^[0-9a-fA-Fnrtuvx])|([\\n\\r\\u2028\\u2029])/g,\n reHasRegExpChars = RegExp(reRegExpChars.source);\n\n /** Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks). */\n var reComboMark = /[\\u0300-\\u036f\\ufe20-\\ufe23]/g;\n\n /** Used to match backslashes in property paths. */\n var reEscapeChar = /\\\\(\\\\)?/g;\n\n /** Used to match [ES template delimiters](http://ecma-international.org/ecma-262/6.0/#sec-template-literal-lexical-components). */\n var reEsTemplate = /\\$\\{([^\\\\}]*(?:\\\\.[^\\\\}]*)*)\\}/g;\n\n /** Used to match `RegExp` flags from their coerced string values. */\n var reFlags = /\\w*$/;\n\n /** Used to detect hexadecimal string values. */\n var reHasHexPrefix = /^0[xX]/;\n\n /** Used to detect host constructors (Safari > 5). */\n var reIsHostCtor = /^\\[object .+?Constructor\\]$/;\n\n /** Used to detect unsigned integer values. */\n var reIsUint = /^\\d+$/;\n\n /** Used to match latin-1 supplementary letters (excluding mathematical operators). */\n var reLatin1 = /[\\xc0-\\xd6\\xd8-\\xde\\xdf-\\xf6\\xf8-\\xff]/g;\n\n /** Used to ensure capturing order of template delimiters. */\n var reNoMatch = /($^)/;\n\n /** Used to match unescaped characters in compiled string literals. */\n var reUnescapedString = /['\\n\\r\\u2028\\u2029\\\\]/g;\n\n /** Used to match words to create compound words. */\n var reWords = (function() {\n var upper = '[A-Z\\\\xc0-\\\\xd6\\\\xd8-\\\\xde]',\n lower = '[a-z\\\\xdf-\\\\xf6\\\\xf8-\\\\xff]+';\n\n return RegExp(upper + '+(?=' + upper + lower + ')|' + upper + '?' + lower + '|' + upper + '+|[0-9]+', 'g');\n }());\n\n /** Used to assign default `context` object properties. */\n var contextProps = [\n 'Array', 'ArrayBuffer', 'Date', 'Error', 'Float32Array', 'Float64Array',\n 'Function', 'Int8Array', 'Int16Array', 'Int32Array', 'Math', 'Number',\n 'Object', 'RegExp', 'Set', 'String', '_', 'clearTimeout', 'isFinite',\n 'parseFloat', 'parseInt', 'setTimeout', 'TypeError', 'Uint8Array',\n 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'WeakMap'\n ];\n\n /** Used to make template sourceURLs easier to identify. */\n var templateCounter = -1;\n\n /** Used to identify `toStringTag` values of typed arrays. */\n var typedArrayTags = {};\n typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =\n typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =\n typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =\n typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =\n typedArrayTags[uint32Tag] = true;\n typedArrayTags[argsTag] = typedArrayTags[arrayTag] =\n typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =\n typedArrayTags[dateTag] = typedArrayTags[errorTag] =\n typedArrayTags[funcTag] = typedArrayTags[mapTag] =\n typedArrayTags[numberTag] = typedArrayTags[objectTag] =\n typedArrayTags[regexpTag] = typedArrayTags[setTag] =\n typedArrayTags[stringTag] = typedArrayTags[weakMapTag] = false;\n\n /** Used to identify `toStringTag` values supported by `_.clone`. */\n var cloneableTags = {};\n cloneableTags[argsTag] = cloneableTags[arrayTag] =\n cloneableTags[arrayBufferTag] = cloneableTags[boolTag] =\n cloneableTags[dateTag] = cloneableTags[float32Tag] =\n cloneableTags[float64Tag] = cloneableTags[int8Tag] =\n cloneableTags[int16Tag] = cloneableTags[int32Tag] =\n cloneableTags[numberTag] = cloneableTags[objectTag] =\n cloneableTags[regexpTag] = cloneableTags[stringTag] =\n cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] =\n cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true;\n cloneableTags[errorTag] = cloneableTags[funcTag] =\n cloneableTags[mapTag] = cloneableTags[setTag] =\n cloneableTags[weakMapTag] = false;\n\n /** Used to map latin-1 supplementary letters to basic latin letters. */\n var deburredLetters = {\n '\\xc0': 'A', '\\xc1': 'A', '\\xc2': 'A', '\\xc3': 'A', '\\xc4': 'A', '\\xc5': 'A',\n '\\xe0': 'a', '\\xe1': 'a', '\\xe2': 'a', '\\xe3': 'a', '\\xe4': 'a', '\\xe5': 'a',\n '\\xc7': 'C', '\\xe7': 'c',\n '\\xd0': 'D', '\\xf0': 'd',\n '\\xc8': 'E', '\\xc9': 'E', '\\xca': 'E', '\\xcb': 'E',\n '\\xe8': 'e', '\\xe9': 'e', '\\xea': 'e', '\\xeb': 'e',\n '\\xcC': 'I', '\\xcd': 'I', '\\xce': 'I', '\\xcf': 'I',\n '\\xeC': 'i', '\\xed': 'i', '\\xee': 'i', '\\xef': 'i',\n '\\xd1': 'N', '\\xf1': 'n',\n '\\xd2': 'O', '\\xd3': 'O', '\\xd4': 'O', '\\xd5': 'O', '\\xd6': 'O', '\\xd8': 'O',\n '\\xf2': 'o', '\\xf3': 'o', '\\xf4': 'o', '\\xf5': 'o', '\\xf6': 'o', '\\xf8': 'o',\n '\\xd9': 'U', '\\xda': 'U', '\\xdb': 'U', '\\xdc': 'U',\n '\\xf9': 'u', '\\xfa': 'u', '\\xfb': 'u', '\\xfc': 'u',\n '\\xdd': 'Y', '\\xfd': 'y', '\\xff': 'y',\n '\\xc6': 'Ae', '\\xe6': 'ae',\n '\\xde': 'Th', '\\xfe': 'th',\n '\\xdf': 'ss'\n };\n\n /** Used to map characters to HTML entities. */\n var htmlEscapes = {\n '&': '&amp;',\n '<': '&lt;',\n '>': '&gt;',\n '\"': '&quot;',\n \"'\": '&#39;',\n '`': '&#96;'\n };\n\n /** Used to map HTML entities to characters. */\n var htmlUnescapes = {\n '&amp;': '&',\n '&lt;': '<',\n '&gt;': '>',\n '&quot;': '\"',\n '&#39;': \"'\",\n '&#96;': '`'\n };\n\n /** Used to determine if values are of the language type `Object`. */\n var objectTypes = {\n 'function': true,\n 'object': true\n };\n\n /** Used to escape characters for inclusion in compiled regexes. */\n var regexpEscapes = {\n '0': 'x30', '1': 'x31', '2': 'x32', '3': 'x33', '4': 'x34',\n '5': 'x35', '6': 'x36', '7': 'x37', '8': 'x38', '9': 'x39',\n 'A': 'x41', 'B': 'x42', 'C': 'x43', 'D': 'x44', 'E': 'x45', 'F': 'x46',\n 'a': 'x61', 'b': 'x62', 'c': 'x63', 'd': 'x64', 'e': 'x65', 'f': 'x66',\n 'n': 'x6e', 'r': 'x72', 't': 'x74', 'u': 'x75', 'v': 'x76', 'x': 'x78'\n };\n\n /** Used to escape characters for inclusion in compiled string literals. */\n var stringEscapes = {\n '\\\\': '\\\\',\n \"'\": \"'\",\n '\\n': 'n',\n '\\r': 'r',\n '\\u2028': 'u2028',\n '\\u2029': 'u2029'\n };\n\n /** Detect free variable `exports`. */\n var freeExports = objectTypes[typeof exports] && exports && !exports.nodeType && exports;\n\n /** Detect free variable `module`. */\n var freeModule = objectTypes[typeof module] && module && !module.nodeType && module;\n\n /** Detect free variable `global` from Node.js. */\n var freeGlobal = freeExports && freeModule && typeof global == 'object' && global && global.Object && global;\n\n /** Detect free variable `self`. */\n var freeSelf = objectTypes[typeof self] && self && self.Object && self;\n\n /** Detect free variable `window`. */\n var freeWindow = objectTypes[typeof window] && window && window.Object && window;\n\n /** Detect the popular CommonJS extension `module.exports`. */\n var moduleExports = freeModule && freeModule.exports === freeExports && freeExports;\n\n /**\n * Used as a reference to the global object.\n *\n * The `this` value is used if it's the global object to avoid Greasemonkey's\n * restricted `window` object, otherwise the `window` object is used.\n */\n var root = freeGlobal || ((freeWindow !== (this && this.window)) && freeWindow) || freeSelf || this;\n\n /*--------------------------------------------------------------------------*/\n\n /**\n * The base implementation of `compareAscending` which compares values and\n * sorts them in ascending order without guaranteeing a stable sort.\n *\n * @private\n * @param {*} value The value to compare.\n * @param {*} other The other value to compare.\n * @returns {number} Returns the sort order indicator for `value`.\n */\n function baseCompareAscending(value, other) {\n if (value !== other) {\n var valIsNull = value === null,\n valIsUndef = value === undefined,\n valIsReflexive = value === value;\n\n var othIsNull = other === null,\n othIsUndef = other === undefined,\n othIsReflexive = other === other;\n\n if ((value > other && !othIsNull) || !valIsReflexive ||\n (valIsNull && !othIsUndef && othIsReflexive) ||\n (valIsUndef && othIsReflexive)) {\n return 1;\n }\n if ((value < other && !valIsNull) || !othIsReflexive ||\n (othIsNull && !valIsUndef && valIsReflexive) ||\n (othIsUndef && valIsReflexive)) {\n return -1;\n }\n }\n return 0;\n }\n\n /**\n * The base implementation of `_.findIndex` and `_.findLastIndex` without\n * support for callback shorthands and `this` binding.\n *\n * @private\n * @param {Array} array The array to search.\n * @param {Function} predicate The function invoked per iteration.\n * @param {boolean} [fromRight] Specify iterating from right to left.\n * @returns {number} Returns the index of the matched value, else `-1`.\n */\n function baseFindIndex(array, predicate, fromRight) {\n var length = array.length,\n index = fromRight ? length : -1;\n\n while ((fromRight ? index-- : ++index < length)) {\n if (predicate(array[index], index, array)) {\n return index;\n }\n }\n return -1;\n }\n\n /**\n * The base implementation of `_.indexOf` without support for binary searches.\n *\n * @private\n * @param {Array} array The array to search.\n * @param {*} value The value to search for.\n * @param {number} fromIndex The index to search from.\n * @returns {number} Returns the index of the matched value, else `-1`.\n */\n function baseIndexOf(array, value, fromIndex) {\n if (value !== value) {\n return indexOfNaN(array, fromIndex);\n }\n var index = fromIndex - 1,\n length = array.length;\n\n while (++index < length) {\n if (array[index] === value) {\n return index;\n }\n }\n return -1;\n }\n\n /**\n * The base implementation of `_.isFunction` without support for environments\n * with incorrect `typeof` results.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.\n */\n function baseIsFunction(value) {\n // Avoid a Chakra JIT bug in compatibility modes of IE 11.\n // See https://github.com/jashkenas/underscore/issues/1621 for more details.\n return typeof value == 'function' || false;\n }\n\n /**\n * Converts `value` to a string if it's not one. An empty string is returned\n * for `null` or `undefined` values.\n *\n * @private\n * @param {*} value The value to process.\n * @returns {string} Returns the string.\n */\n function baseToString(value) {\n return value == null ? '' : (value + '');\n }\n\n /**\n * Used by `_.trim` and `_.trimLeft` to get the index of the first character\n * of `string` that is not found in `chars`.\n *\n * @private\n * @param {string} string The string to inspect.\n * @param {string} chars The characters to find.\n * @returns {number} Returns the index of the first character not found in `chars`.\n */\n function charsLeftIndex(string, chars) {\n var index = -1,\n length = string.length;\n\n while (++index < length && chars.indexOf(string.charAt(index)) > -1) {}\n return index;\n }\n\n /**\n * Used by `_.trim` and `_.trimRight` to get the index of the last character\n * of `string` that is not found in `chars`.\n *\n * @private\n * @param {string} string The string to inspect.\n * @param {string} chars The characters to find.\n * @returns {number} Returns the index of the last character not found in `chars`.\n */\n function charsRightIndex(string, chars) {\n var index = string.length;\n\n while (index-- && chars.indexOf(string.charAt(index)) > -1) {}\n return index;\n }\n\n /**\n * Used by `_.sortBy` to compare transformed elements of a collection and stable\n * sort them in ascending order.\n *\n * @private\n * @param {Object} object The object to compare.\n * @param {Object} other The other object to compare.\n * @returns {number} Returns the sort order indicator for `object`.\n */\n function compareAscending(object, other) {\n return baseCompareAscending(object.criteria, other.criteria) || (object.index - other.index);\n }\n\n /**\n * Used by `_.sortByOrder` to compare multiple properties of a value to another\n * and stable sort them.\n *\n * If `orders` is unspecified, all valuess are sorted in ascending order. Otherwise,\n * a value is sorted in ascending order if its corresponding order is \"asc\", and\n * descending if \"desc\".\n *\n * @private\n * @param {Object} object The object to compare.\n * @param {Object} other The other object to compare.\n * @param {boolean[]} orders The order to sort by for each property.\n * @returns {number} Returns the sort order indicator for `object`.\n */\n function compareMultiple(object, other, orders) {\n var index = -1,\n objCriteria = object.criteria,\n othCriteria = other.criteria,\n length = objCriteria.length,\n ordersLength = orders.length;\n\n while (++index < length) {\n var result = baseCompareAscending(objCriteria[index], othCriteria[index]);\n if (result) {\n if (index >= ordersLength) {\n return result;\n }\n var order = orders[index];\n return result * ((order === 'asc' || order === true) ? 1 : -1);\n }\n }\n // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications\n // that causes it, under certain circumstances, to provide the same value for\n // `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247\n // for more details.\n //\n // This also ensures a stable sort in V8 and other engines.\n // See https://code.google.com/p/v8/issues/detail?id=90 for more details.\n return object.index - other.index;\n }\n\n /**\n * Used by `_.deburr` to convert latin-1 supplementary letters to basic latin letters.\n *\n * @private\n * @param {string} letter The matched letter to deburr.\n * @returns {string} Returns the deburred letter.\n */\n function deburrLetter(letter) {\n return deburredLetters[letter];\n }\n\n /**\n * Used by `_.escape` to convert characters to HTML entities.\n *\n * @private\n * @param {string} chr The matched character to escape.\n * @returns {string} Returns the escaped character.\n */\n function escapeHtmlChar(chr) {\n return htmlEscapes[chr];\n }\n\n /**\n * Used by `_.escapeRegExp` to escape characters for inclusion in compiled regexes.\n *\n * @private\n * @param {string} chr The matched character to escape.\n * @param {string} leadingChar The capture group for a leading character.\n * @param {string} whitespaceChar The capture group for a whitespace character.\n * @returns {string} Returns the escaped character.\n */\n function escapeRegExpChar(chr, leadingChar, whitespaceChar) {\n if (leadingChar) {\n chr = regexpEscapes[chr];\n } else if (whitespaceChar) {\n chr = stringEscapes[chr];\n }\n return '\\\\' + chr;\n }\n\n /**\n * Used by `_.template` to escape characters for inclusion in compiled string literals.\n *\n * @private\n * @param {string} chr The matched character to escape.\n * @returns {string} Returns the escaped character.\n */\n function escapeStringChar(chr) {\n return '\\\\' + stringEscapes[chr];\n }\n\n /**\n * Gets the index at which the first occurrence of `NaN` is found in `array`.\n *\n * @private\n * @param {Array} array The array to search.\n * @param {number} fromIndex The index to search from.\n * @param {boolean} [fromRight] Specify iterating from right to left.\n * @returns {number} Returns the index of the matched `NaN`, else `-1`.\n */\n function indexOfNaN(array, fromIndex, fromRight) {\n var length = array.length,\n index = fromIndex + (fromRight ? 0 : -1);\n\n while ((fromRight ? index-- : ++index < length)) {\n var other = array[index];\n if (other !== other) {\n return index;\n }\n }\n return -1;\n }\n\n /**\n * Checks if `value` is object-like.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is object-like, else `false`.\n */\n function isObjectLike(value) {\n return !!value && typeof value == 'object';\n }\n\n /**\n * Used by `trimmedLeftIndex` and `trimmedRightIndex` to determine if a\n * character code is whitespace.\n *\n * @private\n * @param {number} charCode The character code to inspect.\n * @returns {boolean} Returns `true` if `charCode` is whitespace, else `false`.\n */\n function isSpace(charCode) {\n return ((charCode <= 160 && (charCode >= 9 && charCode <= 13) || charCode == 32 || charCode == 160) || charCode == 5760 || charCode == 6158 ||\n (charCode >= 8192 && (charCode <= 8202 || charCode == 8232 || charCode == 8233 || charCode == 8239 || charCode == 8287 || charCode == 12288 || charCode == 65279)));\n }\n\n /**\n * Replaces all `placeholder` elements in `array` with an internal placeholder\n * and returns an array of their indexes.\n *\n * @private\n * @param {Array} array The array to modify.\n * @param {*} placeholder The placeholder to replace.\n * @returns {Array} Returns the new array of placeholder indexes.\n */\n function replaceHolders(array, placeholder) {\n var index = -1,\n length = array.length,\n resIndex = -1,\n result = [];\n\n while (++index < length) {\n if (array[index] === placeholder) {\n array[index] = PLACEHOLDER;\n result[++resIndex] = index;\n }\n }\n return result;\n }\n\n /**\n * An implementation of `_.uniq` optimized for sorted arrays without support\n * for callback shorthands and `this` binding.\n *\n * @private\n * @param {Array} array The array to inspect.\n * @param {Function} [iteratee] The function invoked per iteration.\n * @returns {Array} Returns the new duplicate-value-free array.\n */\n function sortedUniq(array, iteratee) {\n var seen,\n index = -1,\n length = array.length,\n resIndex = -1,\n result = [];\n\n while (++index < length) {\n var value = array[index],\n computed = iteratee ? iteratee(value, index, array) : value;\n\n if (!index || seen !== computed) {\n seen = computed;\n result[++resIndex] = value;\n }\n }\n return result;\n }\n\n /**\n * Used by `_.trim` and `_.trimLeft` to get the index of the first non-whitespace\n * character of `string`.\n *\n * @private\n * @param {string} string The string to inspect.\n * @returns {number} Returns the index of the first non-whitespace character.\n */\n function trimmedLeftIndex(string) {\n var index = -1,\n length = string.length;\n\n while (++index < length && isSpace(string.charCodeAt(index))) {}\n return index;\n }\n\n /**\n * Used by `_.trim` and `_.trimRight` to get the index of the last non-whitespace\n * character of `string`.\n *\n * @private\n * @param {string} string The string to inspect.\n * @returns {number} Returns the index of the last non-whitespace character.\n */\n function trimmedRightIndex(string) {\n var index = string.length;\n\n while (index-- && isSpace(string.charCodeAt(index))) {}\n return index;\n }\n\n /**\n * Used by `_.unescape` to convert HTML entities to characters.\n *\n * @private\n * @param {string} chr The matched character to unescape.\n * @returns {string} Returns the unescaped character.\n */\n function unescapeHtmlChar(chr) {\n return htmlUnescapes[chr];\n }\n\n /*--------------------------------------------------------------------------*/\n\n /**\n * Create a new pristine `lodash` function using the given `context` object.\n *\n * @static\n * @memberOf _\n * @category Utility\n * @param {Object} [context=root] The context object.\n * @returns {Function} Returns a new `lodash` function.\n * @example\n *\n * _.mixin({ 'foo': _.constant('foo') });\n *\n * var lodash = _.runInContext();\n * lodash.mixin({ 'bar': lodash.constant('bar') });\n *\n * _.isFunction(_.foo);\n * // => true\n * _.isFunction(_.bar);\n * // => false\n *\n * lodash.isFunction(lodash.foo);\n * // => false\n * lodash.isFunction(lodash.bar);\n * // => true\n *\n * // using `context` to mock `Date#getTime` use in `_.now`\n * var mock = _.runInContext({\n * 'Date': function() {\n * return { 'getTime': getTimeMock };\n * }\n * });\n *\n * // or creating a suped-up `defer` in Node.js\n * var defer = _.runInContext({ 'setTimeout': setImmediate }).defer;\n */\n function runInContext(context) {\n // Avoid issues with some ES3 environments that attempt to use values, named\n // after built-in constructors like `Object`, for the creation of literals.\n // ES5 clears this up by stating that literals must use built-in constructors.\n // See https://es5.github.io/#x11.1.5 for more details.\n context = context ? _.defaults(root.Object(), context, _.pick(root, contextProps)) : root;\n\n /** Native constructor references. */\n var Array = context.Array,\n Date = context.Date,\n Error = context.Error,\n Function = context.Function,\n Math = context.Math,\n Number = context.Number,\n Object = context.Object,\n RegExp = context.RegExp,\n String = context.String,\n TypeError = context.TypeError;\n\n /** Used for native method references. */\n var arrayProto = Array.prototype,\n objectProto = Object.prototype,\n stringProto = String.prototype;\n\n /** Used to resolve the decompiled source of functions. */\n var fnToString = Function.prototype.toString;\n\n /** Used to check objects for own properties. */\n var hasOwnProperty = objectProto.hasOwnProperty;\n\n /** Used to generate unique IDs. */\n var idCounter = 0;\n\n /**\n * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)\n * of values.\n */\n var objToString = objectProto.toString;\n\n /** Used to restore the original `_` reference in `_.noConflict`. */\n var oldDash = root._;\n\n /** Used to detect if a method is native. */\n var reIsNative = RegExp('^' +\n fnToString.call(hasOwnProperty).replace(/[\\\\^$.*+?()[\\]{}|]/g, '\\\\$&')\n .replace(/hasOwnProperty|(function).*?(?=\\\\\\()| for .+?(?=\\\\\\])/g, '$1.*?') + '$'\n );\n\n /** Native method references. */\n var ArrayBuffer = context.ArrayBuffer,\n clearTimeout = context.clearTimeout,\n parseFloat = context.parseFloat,\n pow = Math.pow,\n propertyIsEnumerable = objectProto.propertyIsEnumerable,\n Set = getNative(context, 'Set'),\n setTimeout = context.setTimeout,\n splice = arrayProto.splice,\n Uint8Array = context.Uint8Array,\n WeakMap = getNative(context, 'WeakMap');\n\n /* Native method references for those with the same name as other `lodash` methods. */\n var nativeCeil = Math.ceil,\n nativeCreate = getNative(Object, 'create'),\n nativeFloor = Math.floor,\n nativeIsArray = getNative(Array, 'isArray'),\n nativeIsFinite = context.isFinite,\n nativeKeys = getNative(Object, 'keys'),\n nativeMax = Math.max,\n nativeMin = Math.min,\n nativeNow = getNative(Date, 'now'),\n nativeParseInt = context.parseInt,\n nativeRandom = Math.random;\n\n /** Used as references for `-Infinity` and `Infinity`. */\n var NEGATIVE_INFINITY = Number.NEGATIVE_INFINITY,\n POSITIVE_INFINITY = Number.POSITIVE_INFINITY;\n\n /** Used as references for the maximum length and index of an array. */\n var MAX_ARRAY_LENGTH = 4294967295,\n MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1,\n HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1;\n\n /**\n * Used as the [maximum length](http://ecma-international.org/ecma-262/6.0/#sec-number.max_safe_integer)\n * of an array-like value.\n */\n var MAX_SAFE_INTEGER = 9007199254740991;\n\n /** Used to store function metadata. */\n var metaMap = WeakMap && new WeakMap;\n\n /** Used to lookup unminified function names. */\n var realNames = {};\n\n /*------------------------------------------------------------------------*/\n\n /**\n * Creates a `lodash` object which wraps `value` to enable implicit chaining.\n * Methods that operate on and return arrays, collections, and functions can\n * be chained together. Methods that retrieve a single value or may return a\n * primitive value will automatically end the chain returning the unwrapped\n * value. Explicit chaining may be enabled using `_.chain`. The execution of\n * chained methods is lazy, that is, execution is deferred until `_#value`\n * is implicitly or explicitly called.\n *\n * Lazy evaluation allows several methods to support shortcut fusion. Shortcut\n * fusion is an optimization strategy which merge iteratee calls; this can help\n * to avoid the creation of intermediate data structures and greatly reduce the\n * number of iteratee executions.\n *\n * Chaining is supported in custom builds as long as the `_#value` method is\n * directly or indirectly included in the build.\n *\n * In addition to lodash methods, wrappers have `Array` and `String` methods.\n *\n * The wrapper `Array` methods are:\n * `concat`, `join`, `pop`, `push`, `reverse`, `shift`, `slice`, `sort`,\n * `splice`, and `unshift`\n *\n * The wrapper `String` methods are:\n * `replace` and `split`\n *\n * The wrapper methods that support shortcut fusion are:\n * `compact`, `drop`, `dropRight`, `dropRightWhile`, `dropWhile`, `filter`,\n * `first`, `initial`, `last`, `map`, `pluck`, `reject`, `rest`, `reverse`,\n * `slice`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, `toArray`,\n * and `where`\n *\n * The chainable wrapper methods are:\n * `after`, `ary`, `assign`, `at`, `before`, `bind`, `bindAll`, `bindKey`,\n * `callback`, `chain`, `chunk`, `commit`, `compact`, `concat`, `constant`,\n * `countBy`, `create`, `curry`, `debounce`, `defaults`, `defaultsDeep`,\n * `defer`, `delay`, `difference`, `drop`, `dropRight`, `dropRightWhile`,\n * `dropWhile`, `fill`, `filter`, `flatten`, `flattenDeep`, `flow`, `flowRight`,\n * `forEach`, `forEachRight`, `forIn`, `forInRight`, `forOwn`, `forOwnRight`,\n * `functions`, `groupBy`, `indexBy`, `initial`, `intersection`, `invert`,\n * `invoke`, `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`,\n * `matchesProperty`, `memoize`, `merge`, `method`, `methodOf`, `mixin`,\n * `modArgs`, `negate`, `omit`, `once`, `pairs`, `partial`, `partialRight`,\n * `partition`, `pick`, `plant`, `pluck`, `property`, `propertyOf`, `pull`,\n * `pullAt`, `push`, `range`, `rearg`, `reject`, `remove`, `rest`, `restParam`,\n * `reverse`, `set`, `shuffle`, `slice`, `sort`, `sortBy`, `sortByAll`,\n * `sortByOrder`, `splice`, `spread`, `take`, `takeRight`, `takeRightWhile`,\n * `takeWhile`, `tap`, `throttle`, `thru`, `times`, `toArray`, `toPlainObject`,\n * `transform`, `union`, `uniq`, `unshift`, `unzip`, `unzipWith`, `values`,\n * `valuesIn`, `where`, `without`, `wrap`, `xor`, `zip`, `zipObject`, `zipWith`\n *\n * The wrapper methods that are **not** chainable by default are:\n * `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clone`, `cloneDeep`,\n * `deburr`, `endsWith`, `escape`, `escapeRegExp`, `every`, `find`, `findIndex`,\n * `findKey`, `findLast`, `findLastIndex`, `findLastKey`, `findWhere`, `first`,\n * `floor`, `get`, `gt`, `gte`, `has`, `identity`, `includes`, `indexOf`,\n * `inRange`, `isArguments`, `isArray`, `isBoolean`, `isDate`, `isElement`,\n * `isEmpty`, `isEqual`, `isError`, `isFinite` `isFunction`, `isMatch`,\n * `isNative`, `isNaN`, `isNull`, `isNumber`, `isObject`, `isPlainObject`,\n * `isRegExp`, `isString`, `isUndefined`, `isTypedArray`, `join`, `kebabCase`,\n * `last`, `lastIndexOf`, `lt`, `lte`, `max`, `min`, `noConflict`, `noop`,\n * `now`, `pad`, `padLeft`, `padRight`, `parseInt`, `pop`, `random`, `reduce`,\n * `reduceRight`, `repeat`, `result`, `round`, `runInContext`, `shift`, `size`,\n * `snakeCase`, `some`, `sortedIndex`, `sortedLastIndex`, `startCase`,\n * `startsWith`, `sum`, `template`, `trim`, `trimLeft`, `trimRight`, `trunc`,\n * `unescape`, `uniqueId`, `value`, and `words`\n *\n * The wrapper method `sample` will return a wrapped value when `n` is provided,\n * otherwise an unwrapped value is returned.\n *\n * @name _\n * @constructor\n * @category Chain\n * @param {*} value The value to wrap in a `lodash` instance.\n * @returns {Object} Returns the new `lodash` wrapper instance.\n * @example\n *\n * var wrapped = _([1, 2, 3]);\n *\n * // returns an unwrapped value\n * wrapped.reduce(function(total, n) {\n * return total + n;\n * });\n * // => 6\n *\n * // returns a wrapped value\n * var squares = wrapped.map(function(n) {\n * return n * n;\n * });\n *\n * _.isArray(squares);\n * // => false\n *\n * _.isArray(squares.value());\n * // => true\n */\n function lodash(value) {\n if (isObjectLike(value) && !isArray(value) && !(value instanceof LazyWrapper)) {\n if (value instanceof LodashWrapper) {\n return value;\n }\n if (hasOwnProperty.call(value, '__chain__') && hasOwnProperty.call(value, '__wrapped__')) {\n return wrapperClone(value);\n }\n }\n return new LodashWrapper(value);\n }\n\n /**\n * The function whose prototype all chaining wrappers inherit from.\n *\n * @private\n */\n function baseLodash() {\n // No operation performed.\n }\n\n /**\n * The base constructor for creating `lodash` wrapper objects.\n *\n * @private\n * @param {*} value The value to wrap.\n * @param {boolean} [chainAll] Enable chaining for all wrapper methods.\n * @param {Array} [actions=[]] Actions to peform to resolve the unwrapped value.\n */\n function LodashWrapper(value, chainAll, actions) {\n this.__wrapped__ = value;\n this.__actions__ = actions || [];\n this.__chain__ = !!chainAll;\n }\n\n /**\n * An object environment feature flags.\n *\n * @static\n * @memberOf _\n * @type Object\n */\n var support = lodash.support = {};\n\n /**\n * By default, the template delimiters used by lodash are like those in\n * embedded Ruby (ERB). Change the following template settings to use\n * alternative delimiters.\n *\n * @static\n * @memberOf _\n * @type Object\n */\n lodash.templateSettings = {\n\n /**\n * Used to detect `data` property values to be HTML-escaped.\n *\n * @memberOf _.templateSettings\n * @type RegExp\n */\n 'escape': reEscape,\n\n /**\n * Used to detect code to be evaluated.\n *\n * @memberOf _.templateSettings\n * @type RegExp\n */\n 'evaluate': reEvaluate,\n\n /**\n * Used to detect `data` property values to inject.\n *\n * @memberOf _.templateSettings\n * @type RegExp\n */\n 'interpolate': reInterpolate,\n\n /**\n * Used to reference the data object in the template text.\n *\n * @memberOf _.templateSettings\n * @type string\n */\n 'variable': '',\n\n /**\n * Used to import variables into the compiled template.\n *\n * @memberOf _.templateSettings\n * @type Object\n */\n 'imports': {\n\n /**\n * A reference to the `lodash` function.\n *\n * @memberOf _.templateSettings.imports\n * @type Function\n */\n '_': lodash\n }\n };\n\n /*------------------------------------------------------------------------*/\n\n /**\n * Creates a lazy wrapper object which wraps `value` to enable lazy evaluation.\n *\n * @private\n * @param {*} value The value to wrap.\n */\n function LazyWrapper(value) {\n this.__wrapped__ = value;\n this.__actions__ = [];\n this.__dir__ = 1;\n this.__filtered__ = false;\n this.__iteratees__ = [];\n this.__takeCount__ = POSITIVE_INFINITY;\n this.__views__ = [];\n }\n\n /**\n * Creates a clone of the lazy wrapper object.\n *\n * @private\n * @name clone\n * @memberOf LazyWrapper\n * @returns {Object} Returns the cloned `LazyWrapper` object.\n */\n function lazyClone() {\n var result = new LazyWrapper(this.__wrapped__);\n result.__actions__ = arrayCopy(this.__actions__);\n result.__dir__ = this.__dir__;\n result.__filtered__ = this.__filtered__;\n result.__iteratees__ = arrayCopy(this.__iteratees__);\n result.__takeCount__ = this.__takeCount__;\n result.__views__ = arrayCopy(this.__views__);\n return result;\n }\n\n /**\n * Reverses the direction of lazy iteration.\n *\n * @private\n * @name reverse\n * @memberOf LazyWrapper\n * @returns {Object} Returns the new reversed `LazyWrapper` object.\n */\n function lazyReverse() {\n if (this.__filtered__) {\n var result = new LazyWrapper(this);\n result.__dir__ = -1;\n result.__filtered__ = true;\n } else {\n result = this.clone();\n result.__dir__ *= -1;\n }\n return result;\n }\n\n /**\n * Extracts the unwrapped value from its lazy wrapper.\n *\n * @private\n * @name value\n * @memberOf LazyWrapper\n * @returns {*} Returns the unwrapped value.\n */\n function lazyValue() {\n var array = this.__wrapped__.value(),\n dir = this.__dir__,\n isArr = isArray(array),\n isRight = dir < 0,\n arrLength = isArr ? array.length : 0,\n view = getView(0, arrLength, this.__views__),\n start = view.start,\n end = view.end,\n length = end - start,\n index = isRight ? end : (start - 1),\n iteratees = this.__iteratees__,\n iterLength = iteratees.length,\n resIndex = 0,\n takeCount = nativeMin(length, this.__takeCount__);\n\n if (!isArr || arrLength < LARGE_ARRAY_SIZE || (arrLength == length && takeCount == length)) {\n return baseWrapperValue((isRight && isArr) ? array.reverse() : array, this.__actions__);\n }\n var result = [];\n\n outer:\n while (length-- && resIndex < takeCount) {\n index += dir;\n\n var iterIndex = -1,\n value = array[index];\n\n while (++iterIndex < iterLength) {\n var data = iteratees[iterIndex],\n iteratee = data.iteratee,\n type = data.type,\n computed = iteratee(value);\n\n if (type == LAZY_MAP_FLAG) {\n value = computed;\n } else if (!computed) {\n if (type == LAZY_FILTER_FLAG) {\n continue outer;\n } else {\n break outer;\n }\n }\n }\n result[resIndex++] = value;\n }\n return result;\n }\n\n /*------------------------------------------------------------------------*/\n\n /**\n * Creates a cache object to store key/value pairs.\n *\n * @private\n * @static\n * @name Cache\n * @memberOf _.memoize\n */\n function MapCache() {\n this.__data__ = {};\n }\n\n /**\n * Removes `key` and its value from the cache.\n *\n * @private\n * @name delete\n * @memberOf _.memoize.Cache\n * @param {string} key The key of the value to remove.\n * @returns {boolean} Returns `true` if the entry was removed successfully, else `false`.\n */\n function mapDelete(key) {\n return this.has(key) && delete this.__data__[key];\n }\n\n /**\n * Gets the cached value for `key`.\n *\n * @private\n * @name get\n * @memberOf _.memoize.Cache\n * @param {string} key The key of the value to get.\n * @returns {*} Returns the cached value.\n */\n function mapGet(key) {\n return key == '__proto__' ? undefined : this.__data__[key];\n }\n\n /**\n * Checks if a cached value for `key` exists.\n *\n * @private\n * @name has\n * @memberOf _.memoize.Cache\n * @param {string} key The key of the entry to check.\n * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.\n */\n function mapHas(key) {\n return key != '__proto__' && hasOwnProperty.call(this.__data__, key);\n }\n\n /**\n * Sets `value` to `key` of the cache.\n *\n * @private\n * @name set\n * @memberOf _.memoize.Cache\n * @param {string} key The key of the value to cache.\n * @param {*} value The value to cache.\n * @returns {Object} Returns the cache object.\n */\n function mapSet(key, value) {\n if (key != '__proto__') {\n this.__data__[key] = value;\n }\n return this;\n }\n\n /*------------------------------------------------------------------------*/\n\n /**\n *\n * Creates a cache object to store unique values.\n *\n * @private\n * @param {Array} [values] The values to cache.\n */\n function SetCache(values) {\n var length = values ? values.length : 0;\n\n this.data = { 'hash': nativeCreate(null), 'set': new Set };\n while (length--) {\n this.push(values[length]);\n }\n }\n\n /**\n * Checks if `value` is in `cache` mimicking the return signature of\n * `_.indexOf` by returning `0` if the value is found, else `-1`.\n *\n * @private\n * @param {Object} cache The cache to search.\n * @param {*} value The value to search for.\n * @returns {number} Returns `0` if `value` is found, else `-1`.\n */\n function cacheIndexOf(cache, value) {\n var data = cache.data,\n result = (typeof value == 'string' || isObject(value)) ? data.set.has(value) : data.hash[value];\n\n return result ? 0 : -1;\n }\n\n /**\n * Adds `value` to the cache.\n *\n * @private\n * @name push\n * @memberOf SetCache\n * @param {*} value The value to cache.\n */\n function cachePush(value) {\n var data = this.data;\n if (typeof value == 'string' || isObject(value)) {\n data.set.add(value);\n } else {\n data.hash[value] = true;\n }\n }\n\n /*------------------------------------------------------------------------*/\n\n /**\n * Creates a new array joining `array` with `other`.\n *\n * @private\n * @param {Array} array The array to join.\n * @param {Array} other The other array to join.\n * @returns {Array} Returns the new concatenated array.\n */\n function arrayConcat(array, other) {\n var index = -1,\n length = array.length,\n othIndex = -1,\n othLength = other.length,\n result = Array(length + othLength);\n\n while (++index < length) {\n result[index] = array[index];\n }\n while (++othIndex < othLength) {\n result[index++] = other[othIndex];\n }\n return result;\n }\n\n /**\n * Copies the values of `source` to `array`.\n *\n * @private\n * @param {Array} source The array to copy values from.\n * @param {Array} [array=[]] The array to copy values to.\n * @returns {Array} Returns `array`.\n */\n function arrayCopy(source, array) {\n var index = -1,\n length = source.length;\n\n array || (array = Array(length));\n while (++index < length) {\n array[index] = source[index];\n }\n return array;\n }\n\n /**\n * A specialized version of `_.forEach` for arrays without support for callback\n * shorthands and `this` binding.\n *\n * @private\n * @param {Array} array The array to iterate over.\n * @param {Function} iteratee The function invoked per iteration.\n * @returns {Array} Returns `array`.\n */\n function arrayEach(array, iteratee) {\n var index = -1,\n length = array.length;\n\n while (++index < length) {\n if (iteratee(array[index], index, array) === false) {\n break;\n }\n }\n return array;\n }\n\n /**\n * A specialized version of `_.forEachRight` for arrays without support for\n * callback shorthands and `this` binding.\n *\n * @private\n * @param {Array} array The array to iterate over.\n * @param {Function} iteratee The function invoked per iteration.\n * @returns {Array} Returns `array`.\n */\n function arrayEachRight(array, iteratee) {\n var length = array.length;\n\n while (length--) {\n if (iteratee(array[length], length, array) === false) {\n break;\n }\n }\n return array;\n }\n\n /**\n * A specialized version of `_.every` for arrays without support for callback\n * shorthands and `this` binding.\n *\n * @private\n * @param {Array} array The array to iterate over.\n * @param {Function} predicate The function invoked per iteration.\n * @returns {boolean} Returns `true` if all elements pass the predicate check,\n * else `false`.\n */\n function arrayEvery(array, predicate) {\n var index = -1,\n length = array.length;\n\n while (++index < length) {\n if (!predicate(array[index], index, array)) {\n return false;\n }\n }\n return true;\n }\n\n /**\n * A specialized version of `baseExtremum` for arrays which invokes `iteratee`\n * with one argument: (value).\n *\n * @private\n * @param {Array} array The array to iterate over.\n * @param {Function} iteratee The function invoked per iteration.\n * @param {Function} comparator The function used to compare values.\n * @param {*} exValue The initial extremum value.\n * @returns {*} Returns the extremum value.\n */\n function arrayExtremum(array, iteratee, comparator, exValue) {\n var index = -1,\n length = array.length,\n computed = exValue,\n result = computed;\n\n while (++index < length) {\n var value = array[index],\n current = +iteratee(value);\n\n if (comparator(current, computed)) {\n computed = current;\n result = value;\n }\n }\n return result;\n }\n\n /**\n * A specialized version of `_.filter` for arrays without support for callback\n * shorthands and `this` binding.\n *\n * @private\n * @param {Array} array The array to iterate over.\n * @param {Function} predicate The function invoked per iteration.\n * @returns {Array} Returns the new filtered array.\n */\n function arrayFilter(array, predicate) {\n var index = -1,\n length = array.length,\n resIndex = -1,\n result = [];\n\n while (++index < length) {\n var value = array[index];\n if (predicate(value, index, array)) {\n result[++resIndex] = value;\n }\n }\n return result;\n }\n\n /**\n * A specialized version of `_.map` for arrays without support for callback\n * shorthands and `this` binding.\n *\n * @private\n * @param {Array} array The array to iterate over.\n * @param {Function} iteratee The function invoked per iteration.\n * @returns {Array} Returns the new mapped array.\n */\n function arrayMap(array, iteratee) {\n var index = -1,\n length = array.length,\n result = Array(length);\n\n while (++index < length) {\n result[index] = iteratee(array[index], index, array);\n }\n return result;\n }\n\n /**\n * Appends the elements of `values` to `array`.\n *\n * @private\n * @param {Array} array The array to modify.\n * @param {Array} values The values to append.\n * @returns {Array} Returns `array`.\n */\n function arrayPush(array, values) {\n var index = -1,\n length = values.length,\n offset = array.length;\n\n while (++index < length) {\n array[offset + index] = values[index];\n }\n return array;\n }\n\n /**\n * A specialized version of `_.reduce` for arrays without support for callback\n * shorthands and `this` binding.\n *\n * @private\n * @param {Array} array The array to iterate over.\n * @param {Function} iteratee The function invoked per iteration.\n * @param {*} [accumulator] The initial value.\n * @param {boolean} [initFromArray] Specify using the first element of `array`\n * as the initial value.\n * @returns {*} Returns the accumulated value.\n */\n function arrayReduce(array, iteratee, accumulator, initFromArray) {\n var index = -1,\n length = array.length;\n\n if (initFromArray && length) {\n accumulator = array[++index];\n }\n while (++index < length) {\n accumulator = iteratee(accumulator, array[index], index, array);\n }\n return accumulator;\n }\n\n /**\n * A specialized version of `_.reduceRight` for arrays without support for\n * callback shorthands and `this` binding.\n *\n * @private\n * @param {Array} array The array to iterate over.\n * @param {Function} iteratee The function invoked per iteration.\n * @param {*} [accumulator] The initial value.\n * @param {boolean} [initFromArray] Specify using the last element of `array`\n * as the initial value.\n * @returns {*} Returns the accumulated value.\n */\n function arrayReduceRight(array, iteratee, accumulator, initFromArray) {\n var length = array.length;\n if (initFromArray && length) {\n accumulator = array[--length];\n }\n while (length--) {\n accumulator = iteratee(accumulator, array[length], length, array);\n }\n return accumulator;\n }\n\n /**\n * A specialized version of `_.some` for arrays without support for callback\n * shorthands and `this` binding.\n *\n * @private\n * @param {Array} array The array to iterate over.\n * @param {Function} predicate The function invoked per iteration.\n * @returns {boolean} Returns `true` if any element passes the predicate check,\n * else `false`.\n */\n function arraySome(array, predicate) {\n var index = -1,\n length = array.length;\n\n while (++index < length) {\n if (predicate(array[index], index, array)) {\n return true;\n }\n }\n return false;\n }\n\n /**\n * A specialized version of `_.sum` for arrays without support for callback\n * shorthands and `this` binding..\n *\n * @private\n * @param {Array} array The array to iterate over.\n * @param {Function} iteratee The function invoked per iteration.\n * @returns {number} Returns the sum.\n */\n function arraySum(array, iteratee) {\n var length = array.length,\n result = 0;\n\n while (length--) {\n result += +iteratee(array[length]) || 0;\n }\n return result;\n }\n\n /**\n * Used by `_.defaults` to customize its `_.assign` use.\n *\n * @private\n * @param {*} objectValue The destination object property value.\n * @param {*} sourceValue The source object property value.\n * @returns {*} Returns the value to assign to the destination object.\n */\n function assignDefaults(objectValue, sourceValue) {\n return objectValue === undefined ? sourceValue : objectValue;\n }\n\n /**\n * Used by `_.template` to customize its `_.assign` use.\n *\n * **Note:** This function is like `assignDefaults` except that it ignores\n * inherited property values when checking if a property is `undefined`.\n *\n * @private\n * @param {*} objectValue The destination object property value.\n * @param {*} sourceValue The source object property value.\n * @param {string} key The key associated with the object and source values.\n * @param {Object} object The destination object.\n * @returns {*} Returns the value to assign to the destination object.\n */\n function assignOwnDefaults(objectValue, sourceValue, key, object) {\n return (objectValue === undefined || !hasOwnProperty.call(object, key))\n ? sourceValue\n : objectValue;\n }\n\n /**\n * A specialized version of `_.assign` for customizing assigned values without\n * support for argument juggling, multiple sources, and `this` binding `customizer`\n * functions.\n *\n * @private\n * @param {Object} object The destination object.\n * @param {Object} source The source object.\n * @param {Function} customizer The function to customize assigned values.\n * @returns {Object} Returns `object`.\n */\n function assignWith(object, source, customizer) {\n var index = -1,\n props = keys(source),\n length = props.length;\n\n while (++index < length) {\n var key = props[index],\n value = object[key],\n result = customizer(value, source[key], key, object, source);\n\n if ((result === result ? (result !== value) : (value === value)) ||\n (value === undefined && !(key in object))) {\n object[key] = result;\n }\n }\n return object;\n }\n\n /**\n * The base implementation of `_.assign` without support for argument juggling,\n * multiple sources, and `customizer` functions.\n *\n * @private\n * @param {Object} object The destination object.\n * @param {Object} source The source object.\n * @returns {Object} Returns `object`.\n */\n function baseAssign(object, source) {\n return source == null\n ? object\n : baseCopy(source, keys(source), object);\n }\n\n /**\n * The base implementation of `_.at` without support for string collections\n * and individual key arguments.\n *\n * @private\n * @param {Array|Object} collection The collection to iterate over.\n * @param {number[]|string[]} props The property names or indexes of elements to pick.\n * @returns {Array} Returns the new array of picked elements.\n */\n function baseAt(collection, props) {\n var index = -1,\n isNil = collection == null,\n isArr = !isNil && isArrayLike(collection),\n length = isArr ? collection.length : 0,\n propsLength = props.length,\n result = Array(propsLength);\n\n while(++index < propsLength) {\n var key = props[index];\n if (isArr) {\n result[index] = isIndex(key, length) ? collection[key] : undefined;\n } else {\n result[index] = isNil ? undefined : collection[key];\n }\n }\n return result;\n }\n\n /**\n * Copies properties of `source` to `object`.\n *\n * @private\n * @param {Object} source The object to copy properties from.\n * @param {Array} props The property names to copy.\n * @param {Object} [object={}] The object to copy properties to.\n * @returns {Object} Returns `object`.\n */\n function baseCopy(source, props, object) {\n object || (object = {});\n\n var index = -1,\n length = props.length;\n\n while (++index < length) {\n var key = props[index];\n object[key] = source[key];\n }\n return object;\n }\n\n /**\n * The base implementation of `_.callback` which supports specifying the\n * number of arguments to provide to `func`.\n *\n * @private\n * @param {*} [func=_.identity] The value to convert to a callback.\n * @param {*} [thisArg] The `this` binding of `func`.\n * @param {number} [argCount] The number of arguments to provide to `func`.\n * @returns {Function} Returns the callback.\n */\n function baseCallback(func, thisArg, argCount) {\n var type = typeof func;\n if (type == 'function') {\n return thisArg === undefined\n ? func\n : bindCallback(func, thisArg, argCount);\n }\n if (func == null) {\n return identity;\n }\n if (type == 'object') {\n return baseMatches(func);\n }\n return thisArg === undefined\n ? property(func)\n : baseMatchesProperty(func, thisArg);\n }\n\n /**\n * The base implementation of `_.clone` without support for argument juggling\n * and `this` binding `customizer` functions.\n *\n * @private\n * @param {*} value The value to clone.\n * @param {boolean} [isDeep] Specify a deep clone.\n * @param {Function} [customizer] The function to customize cloning values.\n * @param {string} [key] The key of `value`.\n * @param {Object} [object] The object `value` belongs to.\n * @param {Array} [stackA=[]] Tracks traversed source objects.\n * @param {Array} [stackB=[]] Associates clones with source counterparts.\n * @returns {*} Returns the cloned value.\n */\n function baseClone(value, isDeep, customizer, key, object, stackA, stackB) {\n var result;\n if (customizer) {\n result = object ? customizer(value, key, object) : customizer(value);\n }\n if (result !== undefined) {\n return result;\n }\n if (!isObject(value)) {\n return value;\n }\n var isArr = isArray(value);\n if (isArr) {\n result = initCloneArray(value);\n if (!isDeep) {\n return arrayCopy(value, result);\n }\n } else {\n var tag = objToString.call(value),\n isFunc = tag == funcTag;\n\n if (tag == objectTag || tag == argsTag || (isFunc && !object)) {\n result = initCloneObject(isFunc ? {} : value);\n if (!isDeep) {\n return baseAssign(result, value);\n }\n } else {\n return cloneableTags[tag]\n ? initCloneByTag(value, tag, isDeep)\n : (object ? value : {});\n }\n }\n // Check for circular references and return its corresponding clone.\n stackA || (stackA = []);\n stackB || (stackB = []);\n\n var length = stackA.length;\n while (length--) {\n if (stackA[length] == value) {\n return stackB[length];\n }\n }\n // Add the source value to the stack of traversed objects and associate it with its clone.\n stackA.push(value);\n stackB.push(result);\n\n // Recursively populate clone (susceptible to call stack limits).\n (isArr ? arrayEach : baseForOwn)(value, function(subValue, key) {\n result[key] = baseClone(subValue, isDeep, customizer, key, value, stackA, stackB);\n });\n return result;\n }\n\n /**\n * The base implementation of `_.create` without support for assigning\n * properties to the created object.\n *\n * @private\n * @param {Object} prototype The object to inherit from.\n * @returns {Object} Returns the new object.\n */\n var baseCreate = (function() {\n function object() {}\n return function(prototype) {\n if (isObject(prototype)) {\n object.prototype = prototype;\n var result = new object;\n object.prototype = undefined;\n }\n return result || {};\n };\n }());\n\n /**\n * The base implementation of `_.delay` and `_.defer` which accepts an index\n * of where to slice the arguments to provide to `func`.\n *\n * @private\n * @param {Function} func The function to delay.\n * @param {number} wait The number of milliseconds to delay invocation.\n * @param {Object} args The arguments provide to `func`.\n * @returns {number} Returns the timer id.\n */\n function baseDelay(func, wait, args) {\n if (typeof func != 'function') {\n throw new TypeError(FUNC_ERROR_TEXT);\n }\n return setTimeout(function() { func.apply(undefined, args); }, wait);\n }\n\n /**\n * The base implementation of `_.difference` which accepts a single array\n * of values to exclude.\n *\n * @private\n * @param {Array} array The array to inspect.\n * @param {Array} values The values to exclude.\n * @returns {Array} Returns the new array of filtered values.\n */\n function baseDifference(array, values) {\n var length = array ? array.length : 0,\n result = [];\n\n if (!length) {\n return result;\n }\n var index = -1,\n indexOf = getIndexOf(),\n isCommon = indexOf == baseIndexOf,\n cache = (isCommon && values.length >= LARGE_ARRAY_SIZE) ? createCache(values) : null,\n valuesLength = values.length;\n\n if (cache) {\n indexOf = cacheIndexOf;\n isCommon = false;\n values = cache;\n }\n outer:\n while (++index < length) {\n var value = array[index];\n\n if (isCommon && value === value) {\n var valuesIndex = valuesLength;\n while (valuesIndex--) {\n if (values[valuesIndex] === value) {\n continue outer;\n }\n }\n result.push(value);\n }\n else if (indexOf(values, value, 0) < 0) {\n result.push(value);\n }\n }\n return result;\n }\n\n /**\n * The base implementation of `_.forEach` without support for callback\n * shorthands and `this` binding.\n *\n * @private\n * @param {Array|Object|string} collection The collection to iterate over.\n * @param {Function} iteratee The function invoked per iteration.\n * @returns {Array|Object|string} Returns `collection`.\n */\n var baseEach = createBaseEach(baseForOwn);\n\n /**\n * The base implementation of `_.forEachRight` without support for callback\n * shorthands and `this` binding.\n *\n * @private\n * @param {Array|Object|string} collection The collection to iterate over.\n * @param {Function} iteratee The function invoked per iteration.\n * @returns {Array|Object|string} Returns `collection`.\n */\n var baseEachRight = createBaseEach(baseForOwnRight, true);\n\n /**\n * The base implementation of `_.every` without support for callback\n * shorthands and `this` binding.\n *\n * @private\n * @param {Array|Object|string} collection The collection to iterate over.\n * @param {Function} predicate The function invoked per iteration.\n * @returns {boolean} Returns `true` if all elements pass the predicate check,\n * else `false`\n */\n function baseEvery(collection, predicate) {\n var result = true;\n baseEach(collection, function(value, index, collection) {\n result = !!predicate(value, index, collection);\n return result;\n });\n return result;\n }\n\n /**\n * Gets the extremum value of `collection` invoking `iteratee` for each value\n * in `collection` to generate the criterion by which the value is ranked.\n * The `iteratee` is invoked with three arguments: (value, index|key, collection).\n *\n * @private\n * @param {Array|Object|string} collection The collection to iterate over.\n * @param {Function} iteratee The function invoked per iteration.\n * @param {Function} comparator The function used to compare values.\n * @param {*} exValue The initial extremum value.\n * @returns {*} Returns the extremum value.\n */\n function baseExtremum(collection, iteratee, comparator, exValue) {\n var computed = exValue,\n result = computed;\n\n baseEach(collection, function(value, index, collection) {\n var current = +iteratee(value, index, collection);\n if (comparator(current, computed) || (current === exValue && current === result)) {\n computed = current;\n result = value;\n }\n });\n return result;\n }\n\n /**\n * The base implementation of `_.fill` without an iteratee call guard.\n *\n * @private\n * @param {Array} array The array to fill.\n * @param {*} value The value to fill `array` with.\n * @param {number} [start=0] The start position.\n * @param {number} [end=array.length] The end position.\n * @returns {Array} Returns `array`.\n */\n function baseFill(array, value, start, end) {\n var length = array.length;\n\n start = start == null ? 0 : (+start || 0);\n if (start < 0) {\n start = -start > length ? 0 : (length + start);\n }\n end = (end === undefined || end > length) ? length : (+end || 0);\n if (end < 0) {\n end += length;\n }\n length = start > end ? 0 : (end >>> 0);\n start >>>= 0;\n\n while (start < length) {\n array[start++] = value;\n }\n return array;\n }\n\n /**\n * The base implementation of `_.filter` without support for callback\n * shorthands and `this` binding.\n *\n * @private\n * @param {Array|Object|string} collection The collection to iterate over.\n * @param {Function} predicate The function invoked per iteration.\n * @returns {Array} Returns the new filtered array.\n */\n function baseFilter(collection, predicate) {\n var result = [];\n baseEach(collection, function(value, index, collection) {\n if (predicate(value, index, collection)) {\n result.push(value);\n }\n });\n return result;\n }\n\n /**\n * The base implementation of `_.find`, `_.findLast`, `_.findKey`, and `_.findLastKey`,\n * without support for callback shorthands and `this` binding, which iterates\n * over `collection` using the provided `eachFunc`.\n *\n * @private\n * @param {Array|Object|string} collection The collection to search.\n * @param {Function} predicate The function invoked per iteration.\n * @param {Function} eachFunc The function to iterate over `collection`.\n * @param {boolean} [retKey] Specify returning the key of the found element\n * instead of the element itself.\n * @returns {*} Returns the found element or its key, else `undefined`.\n */\n function baseFind(collection, predicate, eachFunc, retKey) {\n var result;\n eachFunc(collection, function(value, key, collection) {\n if (predicate(value, key, collection)) {\n result = retKey ? key : value;\n return false;\n }\n });\n return result;\n }\n\n /**\n * The base implementation of `_.flatten` with added support for restricting\n * flattening and specifying the start index.\n *\n * @private\n * @param {Array} array The array to flatten.\n * @param {boolean} [isDeep] Specify a deep flatten.\n * @param {boolean} [isStrict] Restrict flattening to arrays-like objects.\n * @param {Array} [result=[]] The initial result value.\n * @returns {Array} Returns the new flattened array.\n */\n function baseFlatten(array, isDeep, isStrict, result) {\n result || (result = []);\n\n var index = -1,\n length = array.length;\n\n while (++index < length) {\n var value = array[index];\n if (isObjectLike(value) && isArrayLike(value) &&\n (isStrict || isArray(value) || isArguments(value))) {\n if (isDeep) {\n // Recursively flatten arrays (susceptible to call stack limits).\n baseFlatten(value, isDeep, isStrict, result);\n } else {\n arrayPush(result, value);\n }\n } else if (!isStrict) {\n result[result.length] = value;\n }\n }\n return result;\n }\n\n /**\n * The base implementation of `baseForIn` and `baseForOwn` which iterates\n * over `object` properties returned by `keysFunc` invoking `iteratee` for\n * each property. Iteratee functions may exit iteration early by explicitly\n * returning `false`.\n *\n * @private\n * @param {Object} object The object to iterate over.\n * @param {Function} iteratee The function invoked per iteration.\n * @param {Function} keysFunc The function to get the keys of `object`.\n * @returns {Object} Returns `object`.\n */\n var baseFor = createBaseFor();\n\n /**\n * This function is like `baseFor` except that it iterates over properties\n * in the opposite order.\n *\n * @private\n * @param {Object} object The object to iterate over.\n * @param {Function} iteratee The function invoked per iteration.\n * @param {Function} keysFunc The function to get the keys of `object`.\n * @returns {Object} Returns `object`.\n */\n var baseForRight = createBaseFor(true);\n\n /**\n * The base implementation of `_.forIn` without support for callback\n * shorthands and `this` binding.\n *\n * @private\n * @param {Object} object The object to iterate over.\n * @param {Function} iteratee The function invoked per iteration.\n * @returns {Object} Returns `object`.\n */\n function baseForIn(object, iteratee) {\n return baseFor(object, iteratee, keysIn);\n }\n\n /**\n * The base implementation of `_.forOwn` without support for callback\n * shorthands and `this` binding.\n *\n * @private\n * @param {Object} object The object to iterate over.\n * @param {Function} iteratee The function invoked per iteration.\n * @returns {Object} Returns `object`.\n */\n function baseForOwn(object, iteratee) {\n return baseFor(object, iteratee, keys);\n }\n\n /**\n * The base implementation of `_.forOwnRight` without support for callback\n * shorthands and `this` binding.\n *\n * @private\n * @param {Object} object The object to iterate over.\n * @param {Function} iteratee The function invoked per iteration.\n * @returns {Object} Returns `object`.\n */\n function baseForOwnRight(object, iteratee) {\n return baseForRight(object, iteratee, keys);\n }\n\n /**\n * The base implementation of `_.functions` which creates an array of\n * `object` function property names filtered from those provided.\n *\n * @private\n * @param {Object} object The object to inspect.\n * @param {Array} props The property names to filter.\n * @returns {Array} Returns the new array of filtered property names.\n */\n function baseFunctions(object, props) {\n var index = -1,\n length = props.length,\n resIndex = -1,\n result = [];\n\n while (++index < length) {\n var key = props[index];\n if (isFunction(object[key])) {\n result[++resIndex] = key;\n }\n }\n return result;\n }\n\n /**\n * The base implementation of `get` without support for string paths\n * and default values.\n *\n * @private\n * @param {Object} object The object to query.\n * @param {Array} path The path of the property to get.\n * @param {string} [pathKey] The key representation of path.\n * @returns {*} Returns the resolved value.\n */\n function baseGet(object, path, pathKey) {\n if (object == null) {\n return;\n }\n if (pathKey !== undefined && pathKey in toObject(object)) {\n path = [pathKey];\n }\n var index = 0,\n length = path.length;\n\n while (object != null && index < length) {\n object = object[path[index++]];\n }\n return (index && index == length) ? object : undefined;\n }\n\n /**\n * The base implementation of `_.isEqual` without support for `this` binding\n * `customizer` functions.\n *\n * @private\n * @param {*} value The value to compare.\n * @param {*} other The other value to compare.\n * @param {Function} [customizer] The function to customize comparing values.\n * @param {boolean} [isLoose] Specify performing partial comparisons.\n * @param {Array} [stackA] Tracks traversed `value` objects.\n * @param {Array} [stackB] Tracks traversed `other` objects.\n * @returns {boolean} Returns `true` if the values are equivalent, else `false`.\n */\n function baseIsEqual(value, other, customizer, isLoose, stackA, stackB) {\n if (value === other) {\n return true;\n }\n if (value == null || other == null || (!isObject(value) && !isObjectLike(other))) {\n return value !== value && other !== other;\n }\n return baseIsEqualDeep(value, other, baseIsEqual, customizer, isLoose, stackA, stackB);\n }\n\n /**\n * A specialized version of `baseIsEqual` for arrays and objects which performs\n * deep comparisons and tracks traversed objects enabling objects with circular\n * references to be compared.\n *\n * @private\n * @param {Object} object The object to compare.\n * @param {Object} other The other object to compare.\n * @param {Function} equalFunc The function to determine equivalents of values.\n * @param {Function} [customizer] The function to customize comparing objects.\n * @param {boolean} [isLoose] Specify performing partial comparisons.\n * @param {Array} [stackA=[]] Tracks traversed `value` objects.\n * @param {Array} [stackB=[]] Tracks traversed `other` objects.\n * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.\n */\n function baseIsEqualDeep(object, other, equalFunc, customizer, isLoose, stackA, stackB) {\n var objIsArr = isArray(object),\n othIsArr = isArray(other),\n objTag = arrayTag,\n othTag = arrayTag;\n\n if (!objIsArr) {\n objTag = objToString.call(object);\n if (objTag == argsTag) {\n objTag = objectTag;\n } else if (objTag != objectTag) {\n objIsArr = isTypedArray(object);\n }\n }\n if (!othIsArr) {\n othTag = objToString.call(other);\n if (othTag == argsTag) {\n othTag = objectTag;\n } else if (othTag != objectTag) {\n othIsArr = isTypedArray(other);\n }\n }\n var objIsObj = objTag == objectTag,\n othIsObj = othTag == objectTag,\n isSameTag = objTag == othTag;\n\n if (isSameTag && !(objIsArr || objIsObj)) {\n return equalByTag(object, other, objTag);\n }\n if (!isLoose) {\n var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),\n othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');\n\n if (objIsWrapped || othIsWrapped) {\n return equalFunc(objIsWrapped ? object.value() : object, othIsWrapped ? other.value() : other, customizer, isLoose, stackA, stackB);\n }\n }\n if (!isSameTag) {\n return false;\n }\n // Assume cyclic values are equal.\n // For more information on detecting circular references see https://es5.github.io/#JO.\n stackA || (stackA = []);\n stackB || (stackB = []);\n\n var length = stackA.length;\n while (length--) {\n if (stackA[length] == object) {\n return stackB[length] == other;\n }\n }\n // Add `object` and `other` to the stack of traversed objects.\n stackA.push(object);\n stackB.push(other);\n\n var result = (objIsArr ? equalArrays : equalObjects)(object, other, equalFunc, customizer, isLoose, stackA, stackB);\n\n stackA.pop();\n stackB.pop();\n\n return result;\n }\n\n /**\n * The base implementation of `_.isMatch` without support for callback\n * shorthands and `this` binding.\n *\n * @private\n * @param {Object} object The object to inspect.\n * @param {Array} matchData The propery names, values, and compare flags to match.\n * @param {Function} [customizer] The function to customize comparing objects.\n * @returns {boolean} Returns `true` if `object` is a match, else `false`.\n */\n function baseIsMatch(object, matchData, customizer) {\n var index = matchData.length,\n length = index,\n noCustomizer = !customizer;\n\n if (object == null) {\n return !length;\n }\n object = toObject(object);\n while (index--) {\n var data = matchData[index];\n if ((noCustomizer && data[2])\n ? data[1] !== object[data[0]]\n : !(data[0] in object)\n ) {\n return false;\n }\n }\n while (++index < length) {\n data = matchData[index];\n var key = data[0],\n objValue = object[key],\n srcValue = data[1];\n\n if (noCustomizer && data[2]) {\n if (objValue === undefined && !(key in object)) {\n return false;\n }\n } else {\n var result = customizer ? customizer(objValue, srcValue, key) : undefined;\n if (!(result === undefined ? baseIsEqual(srcValue, objValue, customizer, true) : result)) {\n return false;\n }\n }\n }\n return true;\n }\n\n /**\n * The base implementation of `_.map` without support for callback shorthands\n * and `this` binding.\n *\n * @private\n * @param {Array|Object|string} collection The collection to iterate over.\n * @param {Function} iteratee The function invoked per iteration.\n * @returns {Array} Returns the new mapped array.\n */\n function baseMap(collection, iteratee) {\n var index = -1,\n result = isArrayLike(collection) ? Array(collection.length) : [];\n\n baseEach(collection, function(value, key, collection) {\n result[++index] = iteratee(value, key, collection);\n });\n return result;\n }\n\n /**\n * The base implementation of `_.matches` which does not clone `source`.\n *\n * @private\n * @param {Object} source The object of property values to match.\n * @returns {Function} Returns the new function.\n */\n function baseMatches(source) {\n var matchData = getMatchData(source);\n if (matchData.length == 1 && matchData[0][2]) {\n var key = matchData[0][0],\n value = matchData[0][1];\n\n return function(object) {\n if (object == null) {\n return false;\n }\n return object[key] === value && (value !== undefined || (key in toObject(object)));\n };\n }\n return function(object) {\n return baseIsMatch(object, matchData);\n };\n }\n\n /**\n * The base implementation of `_.matchesProperty` which does not clone `srcValue`.\n *\n * @private\n * @param {string} path The path of the property to get.\n * @param {*} srcValue The value to compare.\n * @returns {Function} Returns the new function.\n */\n function baseMatchesProperty(path, srcValue) {\n var isArr = isArray(path),\n isCommon = isKey(path) && isStrictComparable(srcValue),\n pathKey = (path + '');\n\n path = toPath(path);\n return function(object) {\n if (object == null) {\n return false;\n }\n var key = pathKey;\n object = toObject(object);\n if ((isArr || !isCommon) && !(key in object)) {\n object = path.length == 1 ? object : baseGet(object, baseSlice(path, 0, -1));\n if (object == null) {\n return false;\n }\n key = last(path);\n object = toObject(object);\n }\n return object[key] === srcValue\n ? (srcValue !== undefined || (key in object))\n : baseIsEqual(srcValue, object[key], undefined, true);\n };\n }\n\n /**\n * The base implementation of `_.merge` without support for argument juggling,\n * multiple sources, and `this` binding `customizer` functions.\n *\n * @private\n * @param {Object} object The destination object.\n * @param {Object} source The source object.\n * @param {Function} [customizer] The function to customize merged values.\n * @param {Array} [stackA=[]] Tracks traversed source objects.\n * @param {Array} [stackB=[]] Associates values with source counterparts.\n * @returns {Object} Returns `object`.\n */\n function baseMerge(object, source, customizer, stackA, stackB) {\n if (!isObject(object)) {\n return object;\n }\n var isSrcArr = isArrayLike(source) && (isArray(source) || isTypedArray(source)),\n props = isSrcArr ? undefined : keys(source);\n\n arrayEach(props || source, function(srcValue, key) {\n if (props) {\n key = srcValue;\n srcValue = source[key];\n }\n if (isObjectLike(srcValue)) {\n stackA || (stackA = []);\n stackB || (stackB = []);\n baseMergeDeep(object, source, key, baseMerge, customizer, stackA, stackB);\n }\n else {\n var value = object[key],\n result = customizer ? customizer(value, srcValue, key, object, source) : undefined,\n isCommon = result === undefined;\n\n if (isCommon) {\n result = srcValue;\n }\n if ((result !== undefined || (isSrcArr && !(key in object))) &&\n (isCommon || (result === result ? (result !== value) : (value === value)))) {\n object[key] = result;\n }\n }\n });\n return object;\n }\n\n /**\n * A specialized version of `baseMerge` for arrays and objects which performs\n * deep merges and tracks traversed objects enabling objects with circular\n * references to be merged.\n *\n * @private\n * @param {Object} object The destination object.\n * @param {Object} source The source object.\n * @param {string} key The key of the value to merge.\n * @param {Function} mergeFunc The function to merge values.\n * @param {Function} [customizer] The function to customize merged values.\n * @param {Array} [stackA=[]] Tracks traversed source objects.\n * @param {Array} [stackB=[]] Associates values with source counterparts.\n * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.\n */\n function baseMergeDeep(object, source, key, mergeFunc, customizer, stackA, stackB) {\n var length = stackA.length,\n srcValue = source[key];\n\n while (length--) {\n if (stackA[length] == srcValue) {\n object[key] = stackB[length];\n return;\n }\n }\n var value = object[key],\n result = customizer ? customizer(value, srcValue, key, object, source) : undefined,\n isCommon = result === undefined;\n\n if (isCommon) {\n result = srcValue;\n if (isArrayLike(srcValue) && (isArray(srcValue) || isTypedArray(srcValue))) {\n result = isArray(value)\n ? value\n : (isArrayLike(value) ? arrayCopy(value) : []);\n }\n else if (isPlainObject(srcValue) || isArguments(srcValue)) {\n result = isArguments(value)\n ? toPlainObject(value)\n : (isPlainObject(value) ? value : {});\n }\n else {\n isCommon = false;\n }\n }\n // Add the source value to the stack of traversed objects and associate\n // it with its merged value.\n stackA.push(srcValue);\n stackB.push(result);\n\n if (isCommon) {\n // Recursively merge objects and arrays (susceptible to call stack limits).\n object[key] = mergeFunc(result, srcValue, customizer, stackA, stackB);\n } else if (result === result ? (result !== value) : (value === value)) {\n object[key] = result;\n }\n }\n\n /**\n * The base implementation of `_.property` without support for deep paths.\n *\n * @private\n * @param {string} key The key of the property to get.\n * @returns {Function} Returns the new function.\n */\n function baseProperty(key) {\n return function(object) {\n return object == null ? undefined : object[key];\n };\n }\n\n /**\n * A specialized version of `baseProperty` which supports deep paths.\n *\n * @private\n * @param {Array|string} path The path of the property to get.\n * @returns {Function} Returns the new function.\n */\n function basePropertyDeep(path) {\n var pathKey = (path + '');\n path = toPath(path);\n return function(object) {\n return baseGet(object, path, pathKey);\n };\n }\n\n /**\n * The base implementation of `_.pullAt` without support for individual\n * index arguments and capturing the removed elements.\n *\n * @private\n * @param {Array} array The array to modify.\n * @param {number[]} indexes The indexes of elements to remove.\n * @returns {Array} Returns `array`.\n */\n function basePullAt(array, indexes) {\n var length = array ? indexes.length : 0;\n while (length--) {\n var index = indexes[length];\n if (index != previous && isIndex(index)) {\n var previous = index;\n splice.call(array, index, 1);\n }\n }\n return array;\n }\n\n /**\n * The base implementation of `_.random` without support for argument juggling\n * and returning floating-point numbers.\n *\n * @private\n * @param {number} min The minimum possible value.\n * @param {number} max The maximum possible value.\n * @returns {number} Returns the random number.\n */\n function baseRandom(min, max) {\n return min + nativeFloor(nativeRandom() * (max - min + 1));\n }\n\n /**\n * The base implementation of `_.reduce` and `_.reduceRight` without support\n * for callback shorthands and `this` binding, which iterates over `collection`\n * using the provided `eachFunc`.\n *\n * @private\n * @param {Array|Object|string} collection The collection to iterate over.\n * @param {Function} iteratee The function invoked per iteration.\n * @param {*} accumulator The initial value.\n * @param {boolean} initFromCollection Specify using the first or last element\n * of `collection` as the initial value.\n * @param {Function} eachFunc The function to iterate over `collection`.\n * @returns {*} Returns the accumulated value.\n */\n function baseReduce(collection, iteratee, accumulator, initFromCollection, eachFunc) {\n eachFunc(collection, function(value, index, collection) {\n accumulator = initFromCollection\n ? (initFromCollection = false, value)\n : iteratee(accumulator, value, index, collection);\n });\n return accumulator;\n }\n\n /**\n * The base implementation of `setData` without support for hot loop detection.\n *\n * @private\n * @param {Function} func The function to associate metadata with.\n * @param {*} data The metadata.\n * @returns {Function} Returns `func`.\n */\n var baseSetData = !metaMap ? identity : function(func, data) {\n metaMap.set(func, data);\n return func;\n };\n\n /**\n * The base implementation of `_.slice` without an iteratee call guard.\n *\n * @private\n * @param {Array} array The array to slice.\n * @param {number} [start=0] The start position.\n * @param {number} [end=array.length] The end position.\n * @returns {Array} Returns the slice of `array`.\n */\n function baseSlice(array, start, end) {\n var index = -1,\n length = array.length;\n\n start = start == null ? 0 : (+start || 0);\n if (start < 0) {\n start = -start > length ? 0 : (length + start);\n }\n end = (end === undefined || end > length) ? length : (+end || 0);\n if (end < 0) {\n end += length;\n }\n length = start > end ? 0 : ((end - start) >>> 0);\n start >>>= 0;\n\n var result = Array(length);\n while (++index < length) {\n result[index] = array[index + start];\n }\n return result;\n }\n\n /**\n * The base implementation of `_.some` without support for callback shorthands\n * and `this` binding.\n *\n * @private\n * @param {Array|Object|string} collection The collection to iterate over.\n * @param {Function} predicate The function invoked per iteration.\n * @returns {boolean} Returns `true` if any element passes the predicate check,\n * else `false`.\n */\n function baseSome(collection, predicate) {\n var result;\n\n baseEach(collection, function(value, index, collection) {\n result = predicate(value, index, collection);\n return !result;\n });\n return !!result;\n }\n\n /**\n * The base implementation of `_.sortBy` which uses `comparer` to define\n * the sort order of `array` and replaces criteria objects with their\n * corresponding values.\n *\n * @private\n * @param {Array} array The array to sort.\n * @param {Function} comparer The function to define sort order.\n * @returns {Array} Returns `array`.\n */\n function baseSortBy(array, comparer) {\n var length = array.length;\n\n array.sort(comparer);\n while (length--) {\n array[length] = array[length].value;\n }\n return array;\n }\n\n /**\n * The base implementation of `_.sortByOrder` without param guards.\n *\n * @private\n * @param {Array|Object|string} collection The collection to iterate over.\n * @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by.\n * @param {boolean[]} orders The sort orders of `iteratees`.\n * @returns {Array} Returns the new sorted array.\n */\n function baseSortByOrder(collection, iteratees, orders) {\n var callback = getCallback(),\n index = -1;\n\n iteratees = arrayMap(iteratees, function(iteratee) { return callback(iteratee); });\n\n var result = baseMap(collection, function(value) {\n var criteria = arrayMap(iteratees, function(iteratee) { return iteratee(value); });\n return { 'criteria': criteria, 'index': ++index, 'value': value };\n });\n\n return baseSortBy(result, function(object, other) {\n return compareMultiple(object, other, orders);\n });\n }\n\n /**\n * The base implementation of `_.sum` without support for callback shorthands\n * and `this` binding.\n *\n * @private\n * @param {Array|Object|string} collection The collection to iterate over.\n * @param {Function} iteratee The function invoked per iteration.\n * @returns {number} Returns the sum.\n */\n function baseSum(collection, iteratee) {\n var result = 0;\n baseEach(collection, function(value, index, collection) {\n result += +iteratee(value, index, collection) || 0;\n });\n return result;\n }\n\n /**\n * The base implementation of `_.uniq` without support for callback shorthands\n * and `this` binding.\n *\n * @private\n * @param {Array} array The array to inspect.\n * @param {Function} [iteratee] The function invoked per iteration.\n * @returns {Array} Returns the new duplicate-value-free array.\n */\n function baseUniq(array, iteratee) {\n var index = -1,\n indexOf = getIndexOf(),\n length = array.length,\n isCommon = indexOf == baseIndexOf,\n isLarge = isCommon && length >= LARGE_ARRAY_SIZE,\n seen = isLarge ? createCache() : null,\n result = [];\n\n if (seen) {\n indexOf = cacheIndexOf;\n isCommon = false;\n } else {\n isLarge = false;\n seen = iteratee ? [] : result;\n }\n outer:\n while (++index < length) {\n var value = array[index],\n computed = iteratee ? iteratee(value, index, array) : value;\n\n if (isCommon && value === value) {\n var seenIndex = seen.length;\n while (seenIndex--) {\n if (seen[seenIndex] === computed) {\n continue outer;\n }\n }\n if (iteratee) {\n seen.push(computed);\n }\n result.push(value);\n }\n else if (indexOf(seen, computed, 0) < 0) {\n if (iteratee || isLarge) {\n seen.push(computed);\n }\n result.push(value);\n }\n }\n return result;\n }\n\n /**\n * The base implementation of `_.values` and `_.valuesIn` which creates an\n * array of `object` property values corresponding to the property names\n * of `props`.\n *\n * @private\n * @param {Object} object The object to query.\n * @param {Array} props The property names to get values for.\n * @returns {Object} Returns the array of property values.\n */\n function baseValues(object, props) {\n var index = -1,\n length = props.length,\n result = Array(length);\n\n while (++index < length) {\n result[index] = object[props[index]];\n }\n return result;\n }\n\n /**\n * The base implementation of `_.dropRightWhile`, `_.dropWhile`, `_.takeRightWhile`,\n * and `_.takeWhile` without support for callback shorthands and `this` binding.\n *\n * @private\n * @param {Array} array The array to query.\n * @param {Function} predicate The function invoked per iteration.\n * @param {boolean} [isDrop] Specify dropping elements instead of taking them.\n * @param {boolean} [fromRight] Specify iterating from right to left.\n * @returns {Array} Returns the slice of `array`.\n */\n function baseWhile(array, predicate, isDrop, fromRight) {\n var length = array.length,\n index = fromRight ? length : -1;\n\n while ((fromRight ? index-- : ++index < length) && predicate(array[index], index, array)) {}\n return isDrop\n ? baseSlice(array, (fromRight ? 0 : index), (fromRight ? index + 1 : length))\n : baseSlice(array, (fromRight ? index + 1 : 0), (fromRight ? length : index));\n }\n\n /**\n * The base implementation of `wrapperValue` which returns the result of\n * performing a sequence of actions on the unwrapped `value`, where each\n * successive action is supplied the return value of the previous.\n *\n * @private\n * @param {*} value The unwrapped value.\n * @param {Array} actions Actions to peform to resolve the unwrapped value.\n * @returns {*} Returns the resolved value.\n */\n function baseWrapperValue(value, actions) {\n var result = value;\n if (result instanceof LazyWrapper) {\n result = result.value();\n }\n var index = -1,\n length = actions.length;\n\n while (++index < length) {\n var action = actions[index];\n result = action.func.apply(action.thisArg, arrayPush([result], action.args));\n }\n return result;\n }\n\n /**\n * Performs a binary search of `array` to determine the index at which `value`\n * should be inserted into `array` in order to maintain its sort order.\n *\n * @private\n * @param {Array} array The sorted array to inspect.\n * @param {*} value The value to evaluate.\n * @param {boolean} [retHighest] Specify returning the highest qualified index.\n * @returns {number} Returns the index at which `value` should be inserted\n * into `array`.\n */\n function binaryIndex(array, value, retHighest) {\n var low = 0,\n high = array ? array.length : low;\n\n if (typeof value == 'number' && value === value && high <= HALF_MAX_ARRAY_LENGTH) {\n while (low < high) {\n var mid = (low + high) >>> 1,\n computed = array[mid];\n\n if ((retHighest ? (computed <= value) : (computed < value)) && computed !== null) {\n low = mid + 1;\n } else {\n high = mid;\n }\n }\n return high;\n }\n return binaryIndexBy(array, value, identity, retHighest);\n }\n\n /**\n * This function is like `binaryIndex` except that it invokes `iteratee` for\n * `value` and each element of `array` to compute their sort ranking. The\n * iteratee is invoked with one argument; (value).\n *\n * @private\n * @param {Array} array The sorted array to inspect.\n * @param {*} value The value to evaluate.\n * @param {Function} iteratee The function invoked per iteration.\n * @param {boolean} [retHighest] Specify returning the highest qualified index.\n * @returns {number} Returns the index at which `value` should be inserted\n * into `array`.\n */\n function binaryIndexBy(array, value, iteratee, retHighest) {\n value = iteratee(value);\n\n var low = 0,\n high = array ? array.length : 0,\n valIsNaN = value !== value,\n valIsNull = value === null,\n valIsUndef = value === undefined;\n\n while (low < high) {\n var mid = nativeFloor((low + high) / 2),\n computed = iteratee(array[mid]),\n isDef = computed !== undefined,\n isReflexive = computed === computed;\n\n if (valIsNaN) {\n var setLow = isReflexive || retHighest;\n } else if (valIsNull) {\n setLow = isReflexive && isDef && (retHighest || computed != null);\n } else if (valIsUndef) {\n setLow = isReflexive && (retHighest || isDef);\n } else if (computed == null) {\n setLow = false;\n } else {\n setLow = retHighest ? (computed <= value) : (computed < value);\n }\n if (setLow) {\n low = mid + 1;\n } else {\n high = mid;\n }\n }\n return nativeMin(high, MAX_ARRAY_INDEX);\n }\n\n /**\n * A specialized version of `baseCallback` which only supports `this` binding\n * and specifying the number of arguments to provide to `func`.\n *\n * @private\n * @param {Function} func The function to bind.\n * @param {*} thisArg The `this` binding of `func`.\n * @param {number} [argCount] The number of arguments to provide to `func`.\n * @returns {Function} Returns the callback.\n */\n function bindCallback(func, thisArg, argCount) {\n if (typeof func != 'function') {\n return identity;\n }\n if (thisArg === undefined) {\n return func;\n }\n switch (argCount) {\n case 1: return function(value) {\n return func.call(thisArg, value);\n };\n case 3: return function(value, index, collection) {\n return func.call(thisArg, value, index, collection);\n };\n case 4: return function(accumulator, value, index, collection) {\n return func.call(thisArg, accumulator, value, index, collection);\n };\n case 5: return function(value, other, key, object, source) {\n return func.call(thisArg, value, other, key, object, source);\n };\n }\n return function() {\n return func.apply(thisArg, arguments);\n };\n }\n\n /**\n * Creates a clone of the given array buffer.\n *\n * @private\n * @param {ArrayBuffer} buffer The array buffer to clone.\n * @returns {ArrayBuffer} Returns the cloned array buffer.\n */\n function bufferClone(buffer) {\n var result = new ArrayBuffer(buffer.byteLength),\n view = new Uint8Array(result);\n\n view.set(new Uint8Array(buffer));\n return result;\n }\n\n /**\n * Creates an array that is the composition of partially applied arguments,\n * placeholders, and provided arguments into a single array of arguments.\n *\n * @private\n * @param {Array|Object} args The provided arguments.\n * @param {Array} partials The arguments to prepend to those provided.\n * @param {Array} holders The `partials` placeholder indexes.\n * @returns {Array} Returns the new array of composed arguments.\n */\n function composeArgs(args, partials, holders) {\n var holdersLength = holders.length,\n argsIndex = -1,\n argsLength = nativeMax(args.length - holdersLength, 0),\n leftIndex = -1,\n leftLength = partials.length,\n result = Array(leftLength + argsLength);\n\n while (++leftIndex < leftLength) {\n result[leftIndex] = partials[leftIndex];\n }\n while (++argsIndex < holdersLength) {\n result[holders[argsIndex]] = args[argsIndex];\n }\n while (argsLength--) {\n result[leftIndex++] = args[argsIndex++];\n }\n return result;\n }\n\n /**\n * This function is like `composeArgs` except that the arguments composition\n * is tailored for `_.partialRight`.\n *\n * @private\n * @param {Array|Object} args The provided arguments.\n * @param {Array} partials The arguments to append to those provided.\n * @param {Array} holders The `partials` placeholder indexes.\n * @returns {Array} Returns the new array of composed arguments.\n */\n function composeArgsRight(args, partials, holders) {\n var holdersIndex = -1,\n holdersLength = holders.length,\n argsIndex = -1,\n argsLength = nativeMax(args.length - holdersLength, 0),\n rightIndex = -1,\n rightLength = partials.length,\n result = Array(argsLength + rightLength);\n\n while (++argsIndex < argsLength) {\n result[argsIndex] = args[argsIndex];\n }\n var offset = argsIndex;\n while (++rightIndex < rightLength) {\n result[offset + rightIndex] = partials[rightIndex];\n }\n while (++holdersIndex < holdersLength) {\n result[offset + holders[holdersIndex]] = args[argsIndex++];\n }\n return result;\n }\n\n /**\n * Creates a `_.countBy`, `_.groupBy`, `_.indexBy`, or `_.partition` function.\n *\n * @private\n * @param {Function} setter The function to set keys and values of the accumulator object.\n * @param {Function} [initializer] The function to initialize the accumulator object.\n * @returns {Function} Returns the new aggregator function.\n */\n function createAggregator(setter, initializer) {\n return function(collection, iteratee, thisArg) {\n var result = initializer ? initializer() : {};\n iteratee = getCallback(iteratee, thisArg, 3);\n\n if (isArray(collection)) {\n var index = -1,\n length = collection.length;\n\n while (++index < length) {\n var value = collection[index];\n setter(result, value, iteratee(value, index, collection), collection);\n }\n } else {\n baseEach(collection, function(value, key, collection) {\n setter(result, value, iteratee(value, key, collection), collection);\n });\n }\n return result;\n };\n }\n\n /**\n * Creates a `_.assign`, `_.defaults`, or `_.merge` function.\n *\n * @private\n * @param {Function} assigner The function to assign values.\n * @returns {Function} Returns the new assigner function.\n */\n function createAssigner(assigner) {\n return restParam(function(object, sources) {\n var index = -1,\n length = object == null ? 0 : sources.length,\n customizer = length > 2 ? sources[length - 2] : undefined,\n guard = length > 2 ? sources[2] : undefined,\n thisArg = length > 1 ? sources[length - 1] : undefined;\n\n if (typeof customizer == 'function') {\n customizer = bindCallback(customizer, thisArg, 5);\n length -= 2;\n } else {\n customizer = typeof thisArg == 'function' ? thisArg : undefined;\n length -= (customizer ? 1 : 0);\n }\n if (guard && isIterateeCall(sources[0], sources[1], guard)) {\n customizer = length < 3 ? undefined : customizer;\n length = 1;\n }\n while (++index < length) {\n var source = sources[index];\n if (source) {\n assigner(object, source, customizer);\n }\n }\n return object;\n });\n }\n\n /**\n * Creates a `baseEach` or `baseEachRight` function.\n *\n * @private\n * @param {Function} eachFunc The function to iterate over a collection.\n * @param {boolean} [fromRight] Specify iterating from right to left.\n * @returns {Function} Returns the new base function.\n */\n function createBaseEach(eachFunc, fromRight) {\n return function(collection, iteratee) {\n var length = collection ? getLength(collection) : 0;\n if (!isLength(length)) {\n return eachFunc(collection, iteratee);\n }\n var index = fromRight ? length : -1,\n iterable = toObject(collection);\n\n while ((fromRight ? index-- : ++index < length)) {\n if (iteratee(iterable[index], index, iterable) === false) {\n break;\n }\n }\n return collection;\n };\n }\n\n /**\n * Creates a base function for `_.forIn` or `_.forInRight`.\n *\n * @private\n * @param {boolean} [fromRight] Specify iterating from right to left.\n * @returns {Function} Returns the new base function.\n */\n function createBaseFor(fromRight) {\n return function(object, iteratee, keysFunc) {\n var iterable = toObject(object),\n props = keysFunc(object),\n length = props.length,\n index = fromRight ? length : -1;\n\n while ((fromRight ? index-- : ++index < length)) {\n var key = props[index];\n if (iteratee(iterable[key], key, iterable) === false) {\n break;\n }\n }\n return object;\n };\n }\n\n /**\n * Creates a function that wraps `func` and invokes it with the `this`\n * binding of `thisArg`.\n *\n * @private\n * @param {Function} func The function to bind.\n * @param {*} [thisArg] The `this` binding of `func`.\n * @returns {Function} Returns the new bound function.\n */\n function createBindWrapper(func, thisArg) {\n var Ctor = createCtorWrapper(func);\n\n function wrapper() {\n var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;\n return fn.apply(thisArg, arguments);\n }\n return wrapper;\n }\n\n /**\n * Creates a `Set` cache object to optimize linear searches of large arrays.\n *\n * @private\n * @param {Array} [values] The values to cache.\n * @returns {null|Object} Returns the new cache object if `Set` is supported, else `null`.\n */\n function createCache(values) {\n return (nativeCreate && Set) ? new SetCache(values) : null;\n }\n\n /**\n * Creates a function that produces compound words out of the words in a\n * given string.\n *\n * @private\n * @param {Function} callback The function to combine each word.\n * @returns {Function} Returns the new compounder function.\n */\n function createCompounder(callback) {\n return function(string) {\n var index = -1,\n array = words(deburr(string)),\n length = array.length,\n result = '';\n\n while (++index < length) {\n result = callback(result, array[index], index);\n }\n return result;\n };\n }\n\n /**\n * Creates a function that produces an instance of `Ctor` regardless of\n * whether it was invoked as part of a `new` expression or by `call` or `apply`.\n *\n * @private\n * @param {Function} Ctor The constructor to wrap.\n * @returns {Function} Returns the new wrapped function.\n */\n function createCtorWrapper(Ctor) {\n return function() {\n // Use a `switch` statement to work with class constructors.\n // See http://ecma-international.org/ecma-262/6.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist\n // for more details.\n var args = arguments;\n switch (args.length) {\n case 0: return new Ctor;\n case 1: return new Ctor(args[0]);\n case 2: return new Ctor(args[0], args[1]);\n case 3: return new Ctor(args[0], args[1], args[2]);\n case 4: return new Ctor(args[0], args[1], args[2], args[3]);\n case 5: return new Ctor(args[0], args[1], args[2], args[3], args[4]);\n case 6: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5]);\n case 7: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);\n }\n var thisBinding = baseCreate(Ctor.prototype),\n result = Ctor.apply(thisBinding, args);\n\n // Mimic the constructor's `return` behavior.\n // See https://es5.github.io/#x13.2.2 for more details.\n return isObject(result) ? result : thisBinding;\n };\n }\n\n /**\n * Creates a `_.curry` or `_.curryRight` function.\n *\n * @private\n * @param {boolean} flag The curry bit flag.\n * @returns {Function} Returns the new curry function.\n */\n function createCurry(flag) {\n function curryFunc(func, arity, guard) {\n if (guard && isIterateeCall(func, arity, guard)) {\n arity = undefined;\n }\n var result = createWrapper(func, flag, undefined, undefined, undefined, undefined, undefined, arity);\n result.placeholder = curryFunc.placeholder;\n return result;\n }\n return curryFunc;\n }\n\n /**\n * Creates a `_.defaults` or `_.defaultsDeep` function.\n *\n * @private\n * @param {Function} assigner The function to assign values.\n * @param {Function} customizer The function to customize assigned values.\n * @returns {Function} Returns the new defaults function.\n */\n function createDefaults(assigner, customizer) {\n return restParam(function(args) {\n var object = args[0];\n if (object == null) {\n return object;\n }\n args.push(customizer);\n return assigner.apply(undefined, args);\n });\n }\n\n /**\n * Creates a `_.max` or `_.min` function.\n *\n * @private\n * @param {Function} comparator The function used to compare values.\n * @param {*} exValue The initial extremum value.\n * @returns {Function} Returns the new extremum function.\n */\n function createExtremum(comparator, exValue) {\n return function(collection, iteratee, thisArg) {\n if (thisArg && isIterateeCall(collection, iteratee, thisArg)) {\n iteratee = undefined;\n }\n iteratee = getCallback(iteratee, thisArg, 3);\n if (iteratee.length == 1) {\n collection = isArray(collection) ? collection : toIterable(collection);\n var result = arrayExtremum(collection, iteratee, comparator, exValue);\n if (!(collection.length && result === exValue)) {\n return result;\n }\n }\n return baseExtremum(collection, iteratee, comparator, exValue);\n };\n }\n\n /**\n * Creates a `_.find` or `_.findLast` function.\n *\n * @private\n * @param {Function} eachFunc The function to iterate over a collection.\n * @param {boolean} [fromRight] Specify iterating from right to left.\n * @returns {Function} Returns the new find function.\n */\n function createFind(eachFunc, fromRight) {\n return function(collection, predicate, thisArg) {\n predicate = getCallback(predicate, thisArg, 3);\n if (isArray(collection)) {\n var index = baseFindIndex(collection, predicate, fromRight);\n return index > -1 ? collection[index] : undefined;\n }\n return baseFind(collection, predicate, eachFunc);\n };\n }\n\n /**\n * Creates a `_.findIndex` or `_.findLastIndex` function.\n *\n * @private\n * @param {boolean} [fromRight] Specify iterating from right to left.\n * @returns {Function} Returns the new find function.\n */\n function createFindIndex(fromRight) {\n return function(array, predicate, thisArg) {\n if (!(array && array.length)) {\n return -1;\n }\n predicate = getCallback(predicate, thisArg, 3);\n return baseFindIndex(array, predicate, fromRight);\n };\n }\n\n /**\n * Creates a `_.findKey` or `_.findLastKey` function.\n *\n * @private\n * @param {Function} objectFunc The function to iterate over an object.\n * @returns {Function} Returns the new find function.\n */\n function createFindKey(objectFunc) {\n return function(object, predicate, thisArg) {\n predicate = getCallback(predicate, thisArg, 3);\n return baseFind(object, predicate, objectFunc, true);\n };\n }\n\n /**\n * Creates a `_.flow` or `_.flowRight` function.\n *\n * @private\n * @param {boolean} [fromRight] Specify iterating from right to left.\n * @returns {Function} Returns the new flow function.\n */\n function createFlow(fromRight) {\n return function() {\n var wrapper,\n length = arguments.length,\n index = fromRight ? length : -1,\n leftIndex = 0,\n funcs = Array(length);\n\n while ((fromRight ? index-- : ++index < length)) {\n var func = funcs[leftIndex++] = arguments[index];\n if (typeof func != 'function') {\n throw new TypeError(FUNC_ERROR_TEXT);\n }\n if (!wrapper && LodashWrapper.prototype.thru && getFuncName(func) == 'wrapper') {\n wrapper = new LodashWrapper([], true);\n }\n }\n index = wrapper ? -1 : length;\n while (++index < length) {\n func = funcs[index];\n\n var funcName = getFuncName(func),\n data = funcName == 'wrapper' ? getData(func) : undefined;\n\n if (data && isLaziable(data[0]) && data[1] == (ARY_FLAG | CURRY_FLAG | PARTIAL_FLAG | REARG_FLAG) && !data[4].length && data[9] == 1) {\n wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]);\n } else {\n wrapper = (func.length == 1 && isLaziable(func)) ? wrapper[funcName]() : wrapper.thru(func);\n }\n }\n return function() {\n var args = arguments,\n value = args[0];\n\n if (wrapper && args.length == 1 && isArray(value) && value.length >= LARGE_ARRAY_SIZE) {\n return wrapper.plant(value).value();\n }\n var index = 0,\n result = length ? funcs[index].apply(this, args) : value;\n\n while (++index < length) {\n result = funcs[index].call(this, result);\n }\n return result;\n };\n };\n }\n\n /**\n * Creates a function for `_.forEach` or `_.forEachRight`.\n *\n * @private\n * @param {Function} arrayFunc The function to iterate over an array.\n * @param {Function} eachFunc The function to iterate over a collection.\n * @returns {Function} Returns the new each function.\n */\n function createForEach(arrayFunc, eachFunc) {\n return function(collection, iteratee, thisArg) {\n return (typeof iteratee == 'function' && thisArg === undefined && isArray(collection))\n ? arrayFunc(collection, iteratee)\n : eachFunc(collection, bindCallback(iteratee, thisArg, 3));\n };\n }\n\n /**\n * Creates a function for `_.forIn` or `_.forInRight`.\n *\n * @private\n * @param {Function} objectFunc The function to iterate over an object.\n * @returns {Function} Returns the new each function.\n */\n function createForIn(objectFunc) {\n return function(object, iteratee, thisArg) {\n if (typeof iteratee != 'function' || thisArg !== undefined) {\n iteratee = bindCallback(iteratee, thisArg, 3);\n }\n return objectFunc(object, iteratee, keysIn);\n };\n }\n\n /**\n * Creates a function for `_.forOwn` or `_.forOwnRight`.\n *\n * @private\n * @param {Function} objectFunc The function to iterate over an object.\n * @returns {Function} Returns the new each function.\n */\n function createForOwn(objectFunc) {\n return function(object, iteratee, thisArg) {\n if (typeof iteratee != 'function' || thisArg !== undefined) {\n iteratee = bindCallback(iteratee, thisArg, 3);\n }\n return objectFunc(object, iteratee);\n };\n }\n\n /**\n * Creates a function for `_.mapKeys` or `_.mapValues`.\n *\n * @private\n * @param {boolean} [isMapKeys] Specify mapping keys instead of values.\n * @returns {Function} Returns the new map function.\n */\n function createObjectMapper(isMapKeys) {\n return function(object, iteratee, thisArg) {\n var result = {};\n iteratee = getCallback(iteratee, thisArg, 3);\n\n baseForOwn(object, function(value, key, object) {\n var mapped = iteratee(value, key, object);\n key = isMapKeys ? mapped : key;\n value = isMapKeys ? value : mapped;\n result[key] = value;\n });\n return result;\n };\n }\n\n /**\n * Creates a function for `_.padLeft` or `_.padRight`.\n *\n * @private\n * @param {boolean} [fromRight] Specify padding from the right.\n * @returns {Function} Returns the new pad function.\n */\n function createPadDir(fromRight) {\n return function(string, length, chars) {\n string = baseToString(string);\n return (fromRight ? string : '') + createPadding(string, length, chars) + (fromRight ? '' : string);\n };\n }\n\n /**\n * Creates a `_.partial` or `_.partialRight` function.\n *\n * @private\n * @param {boolean} flag The partial bit flag.\n * @returns {Function} Returns the new partial function.\n */\n function createPartial(flag) {\n var partialFunc = restParam(function(func, partials) {\n var holders = replaceHolders(partials, partialFunc.placeholder);\n return createWrapper(func, flag, undefined, partials, holders);\n });\n return partialFunc;\n }\n\n /**\n * Creates a function for `_.reduce` or `_.reduceRight`.\n *\n * @private\n * @param {Function} arrayFunc The function to iterate over an array.\n * @param {Function} eachFunc The function to iterate over a collection.\n * @returns {Function} Returns the new each function.\n */\n function createReduce(arrayFunc, eachFunc) {\n return function(collection, iteratee, accumulator, thisArg) {\n var initFromArray = arguments.length < 3;\n return (typeof iteratee == 'function' && thisArg === undefined && isArray(collection))\n ? arrayFunc(collection, iteratee, accumulator, initFromArray)\n : baseReduce(collection, getCallback(iteratee, thisArg, 4), accumulator, initFromArray, eachFunc);\n };\n }\n\n /**\n * Creates a function that wraps `func` and invokes it with optional `this`\n * binding of, partial application, and currying.\n *\n * @private\n * @param {Function|string} func The function or method name to reference.\n * @param {number} bitmask The bitmask of flags. See `createWrapper` for more details.\n * @param {*} [thisArg] The `this` binding of `func`.\n * @param {Array} [partials] The arguments to prepend to those provided to the new function.\n * @param {Array} [holders] The `partials` placeholder indexes.\n * @param {Array} [partialsRight] The arguments to append to those provided to the new function.\n * @param {Array} [holdersRight] The `partialsRight` placeholder indexes.\n * @param {Array} [argPos] The argument positions of the new function.\n * @param {number} [ary] The arity cap of `func`.\n * @param {number} [arity] The arity of `func`.\n * @returns {Function} Returns the new wrapped function.\n */\n function createHybridWrapper(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity) {\n var isAry = bitmask & ARY_FLAG,\n isBind = bitmask & BIND_FLAG,\n isBindKey = bitmask & BIND_KEY_FLAG,\n isCurry = bitmask & CURRY_FLAG,\n isCurryBound = bitmask & CURRY_BOUND_FLAG,\n isCurryRight = bitmask & CURRY_RIGHT_FLAG,\n Ctor = isBindKey ? undefined : createCtorWrapper(func);\n\n function wrapper() {\n // Avoid `arguments` object use disqualifying optimizations by\n // converting it to an array before providing it to other functions.\n var length = arguments.length,\n index = length,\n args = Array(length);\n\n while (index--) {\n args[index] = arguments[index];\n }\n if (partials) {\n args = composeArgs(args, partials, holders);\n }\n if (partialsRight) {\n args = composeArgsRight(args, partialsRight, holdersRight);\n }\n if (isCurry || isCurryRight) {\n var placeholder = wrapper.placeholder,\n argsHolders = replaceHolders(args, placeholder);\n\n length -= argsHolders.length;\n if (length < arity) {\n var newArgPos = argPos ? arrayCopy(argPos) : undefined,\n newArity = nativeMax(arity - length, 0),\n newsHolders = isCurry ? argsHolders : undefined,\n newHoldersRight = isCurry ? undefined : argsHolders,\n newPartials = isCurry ? args : undefined,\n newPartialsRight = isCurry ? undefined : args;\n\n bitmask |= (isCurry ? PARTIAL_FLAG : PARTIAL_RIGHT_FLAG);\n bitmask &= ~(isCurry ? PARTIAL_RIGHT_FLAG : PARTIAL_FLAG);\n\n if (!isCurryBound) {\n bitmask &= ~(BIND_FLAG | BIND_KEY_FLAG);\n }\n var newData = [func, bitmask, thisArg, newPartials, newsHolders, newPartialsRight, newHoldersRight, newArgPos, ary, newArity],\n result = createHybridWrapper.apply(undefined, newData);\n\n if (isLaziable(func)) {\n setData(result, newData);\n }\n result.placeholder = placeholder;\n return result;\n }\n }\n var thisBinding = isBind ? thisArg : this,\n fn = isBindKey ? thisBinding[func] : func;\n\n if (argPos) {\n args = reorder(args, argPos);\n }\n if (isAry && ary < args.length) {\n args.length = ary;\n }\n if (this && this !== root && this instanceof wrapper) {\n fn = Ctor || createCtorWrapper(func);\n }\n return fn.apply(thisBinding, args);\n }\n return wrapper;\n }\n\n /**\n * Creates the padding required for `string` based on the given `length`.\n * The `chars` string is truncated if the number of characters exceeds `length`.\n *\n * @private\n * @param {string} string The string to create padding for.\n * @param {number} [length=0] The padding length.\n * @param {string} [chars=' '] The string used as padding.\n * @returns {string} Returns the pad for `string`.\n */\n function createPadding(string, length, chars) {\n var strLength = string.length;\n length = +length;\n\n if (strLength >= length || !nativeIsFinite(length)) {\n return '';\n }\n var padLength = length - strLength;\n chars = chars == null ? ' ' : (chars + '');\n return repeat(chars, nativeCeil(padLength / chars.length)).slice(0, padLength);\n }\n\n /**\n * Creates a function that wraps `func` and invokes it with the optional `this`\n * binding of `thisArg` and the `partials` prepended to those provided to\n * the wrapper.\n *\n * @private\n * @param {Function} func The function to partially apply arguments to.\n * @param {number} bitmask The bitmask of flags. See `createWrapper` for more details.\n * @param {*} thisArg The `this` binding of `func`.\n * @param {Array} partials The arguments to prepend to those provided to the new function.\n * @returns {Function} Returns the new bound function.\n */\n function createPartialWrapper(func, bitmask, thisArg, partials) {\n var isBind = bitmask & BIND_FLAG,\n Ctor = createCtorWrapper(func);\n\n function wrapper() {\n // Avoid `arguments` object use disqualifying optimizations by\n // converting it to an array before providing it `func`.\n var argsIndex = -1,\n argsLength = arguments.length,\n leftIndex = -1,\n leftLength = partials.length,\n args = Array(leftLength + argsLength);\n\n while (++leftIndex < leftLength) {\n args[leftIndex] = partials[leftIndex];\n }\n while (argsLength--) {\n args[leftIndex++] = arguments[++argsIndex];\n }\n var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;\n return fn.apply(isBind ? thisArg : this, args);\n }\n return wrapper;\n }\n\n /**\n * Creates a `_.ceil`, `_.floor`, or `_.round` function.\n *\n * @private\n * @param {string} methodName The name of the `Math` method to use when rounding.\n * @returns {Function} Returns the new round function.\n */\n function createRound(methodName) {\n var func = Math[methodName];\n return function(number, precision) {\n precision = precision === undefined ? 0 : (+precision || 0);\n if (precision) {\n precision = pow(10, precision);\n return func(number * precision) / precision;\n }\n return func(number);\n };\n }\n\n /**\n * Creates a `_.sortedIndex` or `_.sortedLastIndex` function.\n *\n * @private\n * @param {boolean} [retHighest] Specify returning the highest qualified index.\n * @returns {Function} Returns the new index function.\n */\n function createSortedIndex(retHighest) {\n return function(array, value, iteratee, thisArg) {\n var callback = getCallback(iteratee);\n return (iteratee == null && callback === baseCallback)\n ? binaryIndex(array, value, retHighest)\n : binaryIndexBy(array, value, callback(iteratee, thisArg, 1), retHighest);\n };\n }\n\n /**\n * Creates a function that either curries or invokes `func` with optional\n * `this` binding and partially applied arguments.\n *\n * @private\n * @param {Function|string} func The function or method name to reference.\n * @param {number} bitmask The bitmask of flags.\n * The bitmask may be composed of the following flags:\n * 1 - `_.bind`\n * 2 - `_.bindKey`\n * 4 - `_.curry` or `_.curryRight` of a bound function\n * 8 - `_.curry`\n * 16 - `_.curryRight`\n * 32 - `_.partial`\n * 64 - `_.partialRight`\n * 128 - `_.rearg`\n * 256 - `_.ary`\n * @param {*} [thisArg] The `this` binding of `func`.\n * @param {Array} [partials] The arguments to be partially applied.\n * @param {Array} [holders] The `partials` placeholder indexes.\n * @param {Array} [argPos] The argument positions of the new function.\n * @param {number} [ary] The arity cap of `func`.\n * @param {number} [arity] The arity of `func`.\n * @returns {Function} Returns the new wrapped function.\n */\n function createWrapper(func, bitmask, thisArg, partials, holders, argPos, ary, arity) {\n var isBindKey = bitmask & BIND_KEY_FLAG;\n if (!isBindKey && typeof func != 'function') {\n throw new TypeError(FUNC_ERROR_TEXT);\n }\n var length = partials ? partials.length : 0;\n if (!length) {\n bitmask &= ~(PARTIAL_FLAG | PARTIAL_RIGHT_FLAG);\n partials = holders = undefined;\n }\n length -= (holders ? holders.length : 0);\n if (bitmask & PARTIAL_RIGHT_FLAG) {\n var partialsRight = partials,\n holdersRight = holders;\n\n partials = holders = undefined;\n }\n var data = isBindKey ? undefined : getData(func),\n newData = [func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity];\n\n if (data) {\n mergeData(newData, data);\n bitmask = newData[1];\n arity = newData[9];\n }\n newData[9] = arity == null\n ? (isBindKey ? 0 : func.length)\n : (nativeMax(arity - length, 0) || 0);\n\n if (bitmask == BIND_FLAG) {\n var result = createBindWrapper(newData[0], newData[2]);\n } else if ((bitmask == PARTIAL_FLAG || bitmask == (BIND_FLAG | PARTIAL_FLAG)) && !newData[4].length) {\n result = createPartialWrapper.apply(undefined, newData);\n } else {\n result = createHybridWrapper.apply(undefined, newData);\n }\n var setter = data ? baseSetData : setData;\n return setter(result, newData);\n }\n\n /**\n * A specialized version of `baseIsEqualDeep` for arrays with support for\n * partial deep comparisons.\n *\n * @private\n * @param {Array} array The array to compare.\n * @param {Array} other The other array to compare.\n * @param {Function} equalFunc The function to determine equivalents of values.\n * @param {Function} [customizer] The function to customize comparing arrays.\n * @param {boolean} [isLoose] Specify performing partial comparisons.\n * @param {Array} [stackA] Tracks traversed `value` objects.\n * @param {Array} [stackB] Tracks traversed `other` objects.\n * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.\n */\n function equalArrays(array, other, equalFunc, customizer, isLoose, stackA, stackB) {\n var index = -1,\n arrLength = array.length,\n othLength = other.length;\n\n if (arrLength != othLength && !(isLoose && othLength > arrLength)) {\n return false;\n }\n // Ignore non-index properties.\n while (++index < arrLength) {\n var arrValue = array[index],\n othValue = other[index],\n result = customizer ? customizer(isLoose ? othValue : arrValue, isLoose ? arrValue : othValue, index) : undefined;\n\n if (result !== undefined) {\n if (result) {\n continue;\n }\n return false;\n }\n // Recursively compare arrays (susceptible to call stack limits).\n if (isLoose) {\n if (!arraySome(other, function(othValue) {\n return arrValue === othValue || equalFunc(arrValue, othValue, customizer, isLoose, stackA, stackB);\n })) {\n return false;\n }\n } else if (!(arrValue === othValue || equalFunc(arrValue, othValue, customizer, isLoose, stackA, stackB))) {\n return false;\n }\n }\n return true;\n }\n\n /**\n * A specialized version of `baseIsEqualDeep` for comparing objects of\n * the same `toStringTag`.\n *\n * **Note:** This function only supports comparing values with tags of\n * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.\n *\n * @private\n * @param {Object} object The object to compare.\n * @param {Object} other The other object to compare.\n * @param {string} tag The `toStringTag` of the objects to compare.\n * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.\n */\n function equalByTag(object, other, tag) {\n switch (tag) {\n case boolTag:\n case dateTag:\n // Coerce dates and booleans to numbers, dates to milliseconds and booleans\n // to `1` or `0` treating invalid dates coerced to `NaN` as not equal.\n return +object == +other;\n\n case errorTag:\n return object.name == other.name && object.message == other.message;\n\n case numberTag:\n // Treat `NaN` vs. `NaN` as equal.\n return (object != +object)\n ? other != +other\n : object == +other;\n\n case regexpTag:\n case stringTag:\n // Coerce regexes to strings and treat strings primitives and string\n // objects as equal. See https://es5.github.io/#x15.10.6.4 for more details.\n return object == (other + '');\n }\n return false;\n }\n\n /**\n * A specialized version of `baseIsEqualDeep` for objects with support for\n * partial deep comparisons.\n *\n * @private\n * @param {Object} object The object to compare.\n * @param {Object} other The other object to compare.\n * @param {Function} equalFunc The function to determine equivalents of values.\n * @param {Function} [customizer] The function to customize comparing values.\n * @param {boolean} [isLoose] Specify performing partial comparisons.\n * @param {Array} [stackA] Tracks traversed `value` objects.\n * @param {Array} [stackB] Tracks traversed `other` objects.\n * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.\n */\n function equalObjects(object, other, equalFunc, customizer, isLoose, stackA, stackB) {\n var objProps = keys(object),\n objLength = objProps.length,\n othProps = keys(other),\n othLength = othProps.length;\n\n if (objLength != othLength && !isLoose) {\n return false;\n }\n var index = objLength;\n while (index--) {\n var key = objProps[index];\n if (!(isLoose ? key in other : hasOwnProperty.call(other, key))) {\n return false;\n }\n }\n var skipCtor = isLoose;\n while (++index < objLength) {\n key = objProps[index];\n var objValue = object[key],\n othValue = other[key],\n result = customizer ? customizer(isLoose ? othValue : objValue, isLoose? objValue : othValue, key) : undefined;\n\n // Recursively compare objects (susceptible to call stack limits).\n if (!(result === undefined ? equalFunc(objValue, othValue, customizer, isLoose, stackA, stackB) : result)) {\n return false;\n }\n skipCtor || (skipCtor = key == 'constructor');\n }\n if (!skipCtor) {\n var objCtor = object.constructor,\n othCtor = other.constructor;\n\n // Non `Object` object instances with different constructors are not equal.\n if (objCtor != othCtor &&\n ('constructor' in object && 'constructor' in other) &&\n !(typeof objCtor == 'function' && objCtor instanceof objCtor &&\n typeof othCtor == 'function' && othCtor instanceof othCtor)) {\n return false;\n }\n }\n return true;\n }\n\n /**\n * Gets the appropriate \"callback\" function. If the `_.callback` method is\n * customized this function returns the custom method, otherwise it returns\n * the `baseCallback` function. If arguments are provided the chosen function\n * is invoked with them and its result is returned.\n *\n * @private\n * @returns {Function} Returns the chosen function or its result.\n */\n function getCallback(func, thisArg, argCount) {\n var result = lodash.callback || callback;\n result = result === callback ? baseCallback : result;\n return argCount ? result(func, thisArg, argCount) : result;\n }\n\n /**\n * Gets metadata for `func`.\n *\n * @private\n * @param {Function} func The function to query.\n * @returns {*} Returns the metadata for `func`.\n */\n var getData = !metaMap ? noop : function(func) {\n return metaMap.get(func);\n };\n\n /**\n * Gets the name of `func`.\n *\n * @private\n * @param {Function} func The function to query.\n * @returns {string} Returns the function name.\n */\n function getFuncName(func) {\n var result = func.name,\n array = realNames[result],\n length = array ? array.length : 0;\n\n while (length--) {\n var data = array[length],\n otherFunc = data.func;\n if (otherFunc == null || otherFunc == func) {\n return data.name;\n }\n }\n return result;\n }\n\n /**\n * Gets the appropriate \"indexOf\" function. If the `_.indexOf` method is\n * customized this function returns the custom method, otherwise it returns\n * the `baseIndexOf` function. If arguments are provided the chosen function\n * is invoked with them and its result is returned.\n *\n * @private\n * @returns {Function|number} Returns the chosen function or its result.\n */\n function getIndexOf(collection, target, fromIndex) {\n var result = lodash.indexOf || indexOf;\n result = result === indexOf ? baseIndexOf : result;\n return collection ? result(collection, target, fromIndex) : result;\n }\n\n /**\n * Gets the \"length\" property value of `object`.\n *\n * **Note:** This function is used to avoid a [JIT bug](https://bugs.webkit.org/show_bug.cgi?id=142792)\n * that affects Safari on at least iOS 8.1-8.3 ARM64.\n *\n * @private\n * @param {Object} object The object to query.\n * @returns {*} Returns the \"length\" value.\n */\n var getLength = baseProperty('length');\n\n /**\n * Gets the propery names, values, and compare flags of `object`.\n *\n * @private\n * @param {Object} object The object to query.\n * @returns {Array} Returns the match data of `object`.\n */\n function getMatchData(object) {\n var result = pairs(object),\n length = result.length;\n\n while (length--) {\n result[length][2] = isStrictComparable(result[length][1]);\n }\n return result;\n }\n\n /**\n * Gets the native function at `key` of `object`.\n *\n * @private\n * @param {Object} object The object to query.\n * @param {string} key The key of the method to get.\n * @returns {*} Returns the function if it's native, else `undefined`.\n */\n function getNative(object, key) {\n var value = object == null ? undefined : object[key];\n return isNative(value) ? value : undefined;\n }\n\n /**\n * Gets the view, applying any `transforms` to the `start` and `end` positions.\n *\n * @private\n * @param {number} start The start of the view.\n * @param {number} end The end of the view.\n * @param {Array} transforms The transformations to apply to the view.\n * @returns {Object} Returns an object containing the `start` and `end`\n * positions of the view.\n */\n function getView(start, end, transforms) {\n var index = -1,\n length = transforms.length;\n\n while (++index < length) {\n var data = transforms[index],\n size = data.size;\n\n switch (data.type) {\n case 'drop': start += size; break;\n case 'dropRight': end -= size; break;\n case 'take': end = nativeMin(end, start + size); break;\n case 'takeRight': start = nativeMax(start, end - size); break;\n }\n }\n return { 'start': start, 'end': end };\n }\n\n /**\n * Initializes an array clone.\n *\n * @private\n * @param {Array} array The array to clone.\n * @returns {Array} Returns the initialized clone.\n */\n function initCloneArray(array) {\n var length = array.length,\n result = new array.constructor(length);\n\n // Add array properties assigned by `RegExp#exec`.\n if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) {\n result.index = array.index;\n result.input = array.input;\n }\n return result;\n }\n\n /**\n * Initializes an object clone.\n *\n * @private\n * @param {Object} object The object to clone.\n * @returns {Object} Returns the initialized clone.\n */\n function initCloneObject(object) {\n var Ctor = object.constructor;\n if (!(typeof Ctor == 'function' && Ctor instanceof Ctor)) {\n Ctor = Object;\n }\n return new Ctor;\n }\n\n /**\n * Initializes an object clone based on its `toStringTag`.\n *\n * **Note:** This function only supports cloning values with tags of\n * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.\n *\n * @private\n * @param {Object} object The object to clone.\n * @param {string} tag The `toStringTag` of the object to clone.\n * @param {boolean} [isDeep] Specify a deep clone.\n * @returns {Object} Returns the initialized clone.\n */\n function initCloneByTag(object, tag, isDeep) {\n var Ctor = object.constructor;\n switch (tag) {\n case arrayBufferTag:\n return bufferClone(object);\n\n case boolTag:\n case dateTag:\n return new Ctor(+object);\n\n case float32Tag: case float64Tag:\n case int8Tag: case int16Tag: case int32Tag:\n case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag:\n var buffer = object.buffer;\n return new Ctor(isDeep ? bufferClone(buffer) : buffer, object.byteOffset, object.length);\n\n case numberTag:\n case stringTag:\n return new Ctor(object);\n\n case regexpTag:\n var result = new Ctor(object.source, reFlags.exec(object));\n result.lastIndex = object.lastIndex;\n }\n return result;\n }\n\n /**\n * Invokes the method at `path` on `object`.\n *\n * @private\n * @param {Object} object The object to query.\n * @param {Array|string} path The path of the method to invoke.\n * @param {Array} args The arguments to invoke the method with.\n * @returns {*} Returns the result of the invoked method.\n */\n function invokePath(object, path, args) {\n if (object != null && !isKey(path, object)) {\n path = toPath(path);\n object = path.length == 1 ? object : baseGet(object, baseSlice(path, 0, -1));\n path = last(path);\n }\n var func = object == null ? object : object[path];\n return func == null ? undefined : func.apply(object, args);\n }\n\n /**\n * Checks if `value` is array-like.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is array-like, else `false`.\n */\n function isArrayLike(value) {\n return value != null && isLength(getLength(value));\n }\n\n /**\n * Checks if `value` is a valid array-like index.\n *\n * @private\n * @param {*} value The value to check.\n * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.\n * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.\n */\n function isIndex(value, length) {\n value = (typeof value == 'number' || reIsUint.test(value)) ? +value : -1;\n length = length == null ? MAX_SAFE_INTEGER : length;\n return value > -1 && value % 1 == 0 && value < length;\n }\n\n /**\n * Checks if the provided arguments are from an iteratee call.\n *\n * @private\n * @param {*} value The potential iteratee value argument.\n * @param {*} index The potential iteratee index or key argument.\n * @param {*} object The potential iteratee object argument.\n * @returns {boolean} Returns `true` if the arguments are from an iteratee call, else `false`.\n */\n function isIterateeCall(value, index, object) {\n if (!isObject(object)) {\n return false;\n }\n var type = typeof index;\n if (type == 'number'\n ? (isArrayLike(object) && isIndex(index, object.length))\n : (type == 'string' && index in object)) {\n var other = object[index];\n return value === value ? (value === other) : (other !== other);\n }\n return false;\n }\n\n /**\n * Checks if `value` is a property name and not a property path.\n *\n * @private\n * @param {*} value The value to check.\n * @param {Object} [object] The object to query keys on.\n * @returns {boolean} Returns `true` if `value` is a property name, else `false`.\n */\n function isKey(value, object) {\n var type = typeof value;\n if ((type == 'string' && reIsPlainProp.test(value)) || type == 'number') {\n return true;\n }\n if (isArray(value)) {\n return false;\n }\n var result = !reIsDeepProp.test(value);\n return result || (object != null && value in toObject(object));\n }\n\n /**\n * Checks if `func` has a lazy counterpart.\n *\n * @private\n * @param {Function} func The function to check.\n * @returns {boolean} Returns `true` if `func` has a lazy counterpart, else `false`.\n */\n function isLaziable(func) {\n var funcName = getFuncName(func);\n if (!(funcName in LazyWrapper.prototype)) {\n return false;\n }\n var other = lodash[funcName];\n if (func === other) {\n return true;\n }\n var data = getData(other);\n return !!data && func === data[0];\n }\n\n /**\n * Checks if `value` is a valid array-like length.\n *\n * **Note:** This function is based on [`ToLength`](http://ecma-international.org/ecma-262/6.0/#sec-tolength).\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.\n */\n function isLength(value) {\n return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;\n }\n\n /**\n * Checks if `value` is suitable for strict equality comparisons, i.e. `===`.\n *\n * @private\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` if suitable for strict\n * equality comparisons, else `false`.\n */\n function isStrictComparable(value) {\n return value === value && !isObject(value);\n }\n\n /**\n * Merges the function metadata of `source` into `data`.\n *\n * Merging metadata reduces the number of wrappers required to invoke a function.\n * This is possible because methods like `_.bind`, `_.curry`, and `_.partial`\n * may be applied regardless of execution order. Methods like `_.ary` and `_.rearg`\n * augment function arguments, making the order in which they are executed important,\n * preventing the merging of metadata. However, we make an exception for a safe\n * common case where curried functions have `_.ary` and or `_.rearg` applied.\n *\n * @private\n * @param {Array} data The destination metadata.\n * @param {Array} source The source metadata.\n * @returns {Array} Returns `data`.\n */\n function mergeData(data, source) {\n var bitmask = data[1],\n srcBitmask = source[1],\n newBitmask = bitmask | srcBitmask,\n isCommon = newBitmask < ARY_FLAG;\n\n var isCombo =\n (srcBitmask == ARY_FLAG && bitmask == CURRY_FLAG) ||\n (srcBitmask == ARY_FLAG && bitmask == REARG_FLAG && data[7].length <= source[8]) ||\n (srcBitmask == (ARY_FLAG | REARG_FLAG) && bitmask == CURRY_FLAG);\n\n // Exit early if metadata can't be merged.\n if (!(isCommon || isCombo)) {\n return data;\n }\n // Use source `thisArg` if available.\n if (srcBitmask & BIND_FLAG) {\n data[2] = source[2];\n // Set when currying a bound function.\n newBitmask |= (bitmask & BIND_FLAG) ? 0 : CURRY_BOUND_FLAG;\n }\n // Compose partial arguments.\n var value = source[3];\n if (value) {\n var partials = data[3];\n data[3] = partials ? composeArgs(partials, value, source[4]) : arrayCopy(value);\n data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : arrayCopy(source[4]);\n }\n // Compose partial right arguments.\n value = source[5];\n if (value) {\n partials = data[5];\n data[5] = partials ? composeArgsRight(partials, value, source[6]) : arrayCopy(value);\n data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : arrayCopy(source[6]);\n }\n // Use source `argPos` if available.\n value = source[7];\n if (value) {\n data[7] = arrayCopy(value);\n }\n // Use source `ary` if it's smaller.\n if (srcBitmask & ARY_FLAG) {\n data[8] = data[8] == null ? source[8] : nativeMin(data[8], source[8]);\n }\n // Use source `arity` if one is not provided.\n if (data[9] == null) {\n data[9] = source[9];\n }\n // Use source `func` and merge bitmasks.\n data[0] = source[0];\n data[1] = newBitmask;\n\n return data;\n }\n\n /**\n * Used by `_.defaultsDeep` to customize its `_.merge` use.\n *\n * @private\n * @param {*} objectValue The destination object property value.\n * @param {*} sourceValue The source object property value.\n * @returns {*} Returns the value to assign to the destination object.\n */\n function mergeDefaults(objectValue, sourceValue) {\n return objectValue === undefined ? sourceValue : merge(objectValue, sourceValue, mergeDefaults);\n }\n\n /**\n * A specialized version of `_.pick` which picks `object` properties specified\n * by `props`.\n *\n * @private\n * @param {Object} object The source object.\n * @param {string[]} props The property names to pick.\n * @returns {Object} Returns the new object.\n */\n function pickByArray(object, props) {\n object = toObject(object);\n\n var index = -1,\n length = props.length,\n result = {};\n\n while (++index < length) {\n var key = props[index];\n if (key in object) {\n result[key] = object[key];\n }\n }\n return result;\n }\n\n /**\n * A specialized version of `_.pick` which picks `object` properties `predicate`\n * returns truthy for.\n *\n * @private\n * @param {Object} object The source object.\n * @param {Function} predicate The function invoked per iteration.\n * @returns {Object} Returns the new object.\n */\n function pickByCallback(object, predicate) {\n var result = {};\n baseForIn(object, function(value, key, object) {\n if (predicate(value, key, object)) {\n result[key] = value;\n }\n });\n return result;\n }\n\n /**\n * Reorder `array` according to the specified indexes where the element at\n * the first index is assigned as the first element, the element at\n * the second index is assigned as the second element, and so on.\n *\n * @private\n * @param {Array} array The array to reorder.\n * @param {Array} indexes The arranged array indexes.\n * @returns {Array} Returns `array`.\n */\n function reorder(array, indexes) {\n var arrLength = array.length,\n length = nativeMin(indexes.length, arrLength),\n oldArray = arrayCopy(array);\n\n while (length--) {\n var index = indexes[length];\n array[length] = isIndex(index, arrLength) ? oldArray[index] : undefined;\n }\n return array;\n }\n\n /**\n * Sets metadata for `func`.\n *\n * **Note:** If this function becomes hot, i.e. is invoked a lot in a short\n * period of time, it will trip its breaker and transition to an identity function\n * to avoid garbage collection pauses in V8. See [V8 issue 2070](https://code.google.com/p/v8/issues/detail?id=2070)\n * for more details.\n *\n * @private\n * @param {Function} func The function to associate metadata with.\n * @param {*} data The metadata.\n * @returns {Function} Returns `func`.\n */\n var setData = (function() {\n var count = 0,\n lastCalled = 0;\n\n return function(key, value) {\n var stamp = now(),\n remaining = HOT_SPAN - (stamp - lastCalled);\n\n lastCalled = stamp;\n if (remaining > 0) {\n if (++count >= HOT_COUNT) {\n return key;\n }\n } else {\n count = 0;\n }\n return baseSetData(key, value);\n };\n }());\n\n /**\n * A fallback implementation of `Object.keys` which creates an array of the\n * own enumerable property names of `object`.\n *\n * @private\n * @param {Object} object The object to query.\n * @returns {Array} Returns the array of property names.\n */\n function shimKeys(object) {\n var props = keysIn(object),\n propsLength = props.length,\n length = propsLength && object.length;\n\n var allowIndexes = !!length && isLength(length) &&\n (isArray(object) || isArguments(object));\n\n var index = -1,\n result = [];\n\n while (++index < propsLength) {\n var key = props[index];\n if ((allowIndexes && isIndex(key, length)) || hasOwnProperty.call(object, key)) {\n result.push(key);\n }\n }\n return result;\n }\n\n /**\n * Converts `value` to an array-like object if it's not one.\n *\n * @private\n * @param {*} value The value to process.\n * @returns {Array|Object} Returns the array-like object.\n */\n function toIterable(value) {\n if (value == null) {\n return [];\n }\n if (!isArrayLike(value)) {\n return values(value);\n }\n return isObject(value) ? value : Object(value);\n }\n\n /**\n * Converts `value` to an object if it's not one.\n *\n * @private\n * @param {*} value The value to process.\n * @returns {Object} Returns the object.\n */\n function toObject(value) {\n return isObject(value) ? value : Object(value);\n }\n\n /**\n * Converts `value` to property path array if it's not one.\n *\n * @private\n * @param {*} value The value to process.\n * @returns {Array} Returns the property path array.\n */\n function toPath(value) {\n if (isArray(value)) {\n return value;\n }\n var result = [];\n baseToString(value).replace(rePropName, function(match, number, quote, string) {\n result.push(quote ? string.replace(reEscapeChar, '$1') : (number || match));\n });\n return result;\n }\n\n /**\n * Creates a clone of `wrapper`.\n *\n * @private\n * @param {Object} wrapper The wrapper to clone.\n * @returns {Object} Returns the cloned wrapper.\n */\n function wrapperClone(wrapper) {\n return wrapper instanceof LazyWrapper\n ? wrapper.clone()\n : new LodashWrapper(wrapper.__wrapped__, wrapper.__chain__, arrayCopy(wrapper.__actions__));\n }\n\n /*------------------------------------------------------------------------*/\n\n /**\n * Creates an array of elements split into groups the length of `size`.\n * If `collection` can't be split evenly, the final chunk will be the remaining\n * elements.\n *\n * @static\n * @memberOf _\n * @category Array\n * @param {Array} array The array to process.\n * @param {number} [size=1] The length of each chunk.\n * @param- {Object} [guard] Enables use as a callback for functions like `_.map`.\n * @returns {Array} Returns the new array containing chunks.\n * @example\n *\n * _.chunk(['a', 'b', 'c', 'd'], 2);\n * // => [['a', 'b'], ['c', 'd']]\n *\n * _.chunk(['a', 'b', 'c', 'd'], 3);\n * // => [['a', 'b', 'c'], ['d']]\n */\n function chunk(array, size, guard) {\n if (guard ? isIterateeCall(array, size, guard) : size == null) {\n size = 1;\n } else {\n size = nativeMax(nativeFloor(size) || 1, 1);\n }\n var index = 0,\n length = array ? array.length : 0,\n resIndex = -1,\n result = Array(nativeCeil(length / size));\n\n while (index < length) {\n result[++resIndex] = baseSlice(array, index, (index += size));\n }\n return result;\n }\n\n /**\n * Creates an array with all falsey values removed. The values `false`, `null`,\n * `0`, `\"\"`, `undefined`, and `NaN` are falsey.\n *\n * @static\n * @memberOf _\n * @category Array\n * @param {Array} array The array to compact.\n * @returns {Array} Returns the new array of filtered values.\n * @example\n *\n * _.compact([0, 1, false, 2, '', 3]);\n * // => [1, 2, 3]\n */\n function compact(array) {\n var index = -1,\n length = array ? array.length : 0,\n resIndex = -1,\n result = [];\n\n while (++index < length) {\n var value = array[index];\n if (value) {\n result[++resIndex] = value;\n }\n }\n return result;\n }\n\n /**\n * Creates an array of unique `array` values not included in the other\n * provided arrays using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero)\n * for equality comparisons.\n *\n * @static\n * @memberOf _\n * @category Array\n * @param {Array} array The array to inspect.\n * @param {...Array} [values] The arrays of values to exclude.\n * @returns {Array} Returns the new array of filtered values.\n * @example\n *\n * _.difference([1, 2, 3], [4, 2]);\n * // => [1, 3]\n */\n var difference = restParam(function(array, values) {\n return (isObjectLike(array) && isArrayLike(array))\n ? baseDifference(array, baseFlatten(values, false, true))\n : [];\n });\n\n /**\n * Creates a slice of `array` with `n` elements dropped from the beginning.\n *\n * @static\n * @memberOf _\n * @category Array\n * @param {Array} array The array to query.\n * @param {number} [n=1] The number of elements to drop.\n * @param- {Object} [guard] Enables use as a callback for functions like `_.map`.\n * @returns {Array} Returns the slice of `array`.\n * @example\n *\n * _.drop([1, 2, 3]);\n * // => [2, 3]\n *\n * _.drop([1, 2, 3], 2);\n * // => [3]\n *\n * _.drop([1, 2, 3], 5);\n * // => []\n *\n * _.drop([1, 2, 3], 0);\n * // => [1, 2, 3]\n */\n function drop(array, n, guard) {\n var length = array ? array.length : 0;\n if (!length) {\n return [];\n }\n if (guard ? isIterateeCall(array, n, guard) : n == null) {\n n = 1;\n }\n return baseSlice(array, n < 0 ? 0 : n);\n }\n\n /**\n * Creates a slice of `array` with `n` elements dropped from the end.\n *\n * @static\n * @memberOf _\n * @category Array\n * @param {Array} array The array to query.\n * @param {number} [n=1] The number of elements to drop.\n * @param- {Object} [guard] Enables use as a callback for functions like `_.map`.\n * @returns {Array} Returns the slice of `array`.\n * @example\n *\n * _.dropRight([1, 2, 3]);\n * // => [1, 2]\n *\n * _.dropRight([1, 2, 3], 2);\n * // => [1]\n *\n * _.dropRight([1, 2, 3], 5);\n * // => []\n *\n * _.dropRight([1, 2, 3], 0);\n * // => [1, 2, 3]\n */\n function dropRight(array, n, guard) {\n var length = array ? array.length : 0;\n if (!length) {\n return [];\n }\n if (guard ? isIterateeCall(array, n, guard) : n == null) {\n n = 1;\n }\n n = length - (+n || 0);\n return baseSlice(array, 0, n < 0 ? 0 : n);\n }\n\n /**\n * Creates a slice of `array` excluding elements dropped from the end.\n * Elements are dropped until `predicate` returns falsey. The predicate is\n * bound to `thisArg` and invoked with three arguments: (value, index, array).\n *\n * If a property name is provided for `predicate` the created `_.property`\n * style callback returns the property value of the given element.\n *\n * If a value is also provided for `thisArg` the created `_.matchesProperty`\n * style callback returns `true` for elements that have a matching property\n * value, else `false`.\n *\n * If an object is provided for `predicate` the created `_.matches` style\n * callback returns `true` for elements that match the properties of the given\n * object, else `false`.\n *\n * @static\n * @memberOf _\n * @category Array\n * @param {Array} array The array to query.\n * @param {Function|Object|string} [predicate=_.identity] The function invoked\n * per iteration.\n * @param {*} [thisArg] The `this` binding of `predicate`.\n * @returns {Array} Returns the slice of `array`.\n * @example\n *\n * _.dropRightWhile([1, 2, 3], function(n) {\n * return n > 1;\n * });\n * // => [1]\n *\n * var users = [\n * { 'user': 'barney', 'active': true },\n * { 'user': 'fred', 'active': false },\n * { 'user': 'pebbles', 'active': false }\n * ];\n *\n * // using the `_.matches` callback shorthand\n * _.pluck(_.dropRightWhile(users, { 'user': 'pebbles', 'active': false }), 'user');\n * // => ['barney', 'fred']\n *\n * // using the `_.matchesProperty` callback shorthand\n * _.pluck(_.dropRightWhile(users, 'active', false), 'user');\n * // => ['barney']\n *\n * // using the `_.property` callback shorthand\n * _.pluck(_.dropRightWhile(users, 'active'), 'user');\n * // => ['barney', 'fred', 'pebbles']\n */\n function dropRightWhile(array, predicate, thisArg) {\n return (array && array.length)\n ? baseWhile(array, getCallback(predicate, thisArg, 3), true, true)\n : [];\n }\n\n /**\n * Creates a slice of `array` excluding elements dropped from the beginning.\n * Elements are dropped until `predicate` returns falsey. The predicate is\n * bound to `thisArg` and invoked with three arguments: (value, index, array).\n *\n * If a property name is provided for `predicate` the created `_.property`\n * style callback returns the property value of the given element.\n *\n * If a value is also provided for `thisArg` the created `_.matchesProperty`\n * style callback returns `true` for elements that have a matching property\n * value, else `false`.\n *\n * If an object is provided for `predicate` the created `_.matches` style\n * callback returns `true` for elements that have the properties of the given\n * object, else `false`.\n *\n * @static\n * @memberOf _\n * @category Array\n * @param {Array} array The array to query.\n * @param {Function|Object|string} [predicate=_.identity] The function invoked\n * per iteration.\n * @param {*} [thisArg] The `this` binding of `predicate`.\n * @returns {Array} Returns the slice of `array`.\n * @example\n *\n * _.dropWhile([1, 2, 3], function(n) {\n * return n < 3;\n * });\n * // => [3]\n *\n * var users = [\n * { 'user': 'barney', 'active': false },\n * { 'user': 'fred', 'active': false },\n * { 'user': 'pebbles', 'active': true }\n * ];\n *\n * // using the `_.matches` callback shorthand\n * _.pluck(_.dropWhile(users, { 'user': 'barney', 'active': false }), 'user');\n * // => ['fred', 'pebbles']\n *\n * // using the `_.matchesProperty` callback shorthand\n * _.pluck(_.dropWhile(users, 'active', false), 'user');\n * // => ['pebbles']\n *\n * // using the `_.property` callback shorthand\n * _.pluck(_.dropWhile(users, 'active'), 'user');\n * // => ['barney', 'fred', 'pebbles']\n */\n function dropWhile(array, predicate, thisArg) {\n return (array && array.length)\n ? baseWhile(array, getCallback(predicate, thisArg, 3), true)\n : [];\n }\n\n /**\n * Fills elements of `array` with `value` from `start` up to, but not\n * including, `end`.\n *\n * **Note:** This method mutates `array`.\n *\n * @static\n * @memberOf _\n * @category Array\n * @param {Array} array The array to fill.\n * @param {*} value The value to fill `array` with.\n * @param {number} [start=0] The start position.\n * @param {number} [end=array.length] The end position.\n * @returns {Array} Returns `array`.\n * @example\n *\n * var array = [1, 2, 3];\n *\n * _.fill(array, 'a');\n * console.log(array);\n * // => ['a', 'a', 'a']\n *\n * _.fill(Array(3), 2);\n * // => [2, 2, 2]\n *\n * _.fill([4, 6, 8], '*', 1, 2);\n * // => [4, '*', 8]\n */\n function fill(array, value, start, end) {\n var length = array ? array.length : 0;\n if (!length) {\n return [];\n }\n if (start && typeof start != 'number' && isIterateeCall(array, value, start)) {\n start = 0;\n end = length;\n }\n return baseFill(array, value, start, end);\n }\n\n /**\n * This method is like `_.find` except that it returns the index of the first\n * element `predicate` returns truthy for instead of the element itself.\n *\n * If a property name is provided for `predicate` the created `_.property`\n * style callback returns the property value of the given element.\n *\n * If a value is also provided for `thisArg` the created `_.matchesProperty`\n * style callback returns `true` for elements that have a matching property\n * value, else `false`.\n *\n * If an object is provided for `predicate` the created `_.matches` style\n * callback returns `true` for elements that have the properties of the given\n * object, else `false`.\n *\n * @static\n * @memberOf _\n * @category Array\n * @param {Array} array The array to search.\n * @param {Function|Object|string} [predicate=_.identity] The function invoked\n * per iteration.\n * @param {*} [thisArg] The `this` binding of `predicate`.\n * @returns {number} Returns the index of the found element, else `-1`.\n * @example\n *\n * var users = [\n * { 'user': 'barney', 'active': false },\n * { 'user': 'fred', 'active': false },\n * { 'user': 'pebbles', 'active': true }\n * ];\n *\n * _.findIndex(users, function(chr) {\n * return chr.user == 'barney';\n * });\n * // => 0\n *\n * // using the `_.matches` callback shorthand\n * _.findIndex(users, { 'user': 'fred', 'active': false });\n * // => 1\n *\n * // using the `_.matchesProperty` callback shorthand\n * _.findIndex(users, 'active', false);\n * // => 0\n *\n * // using the `_.property` callback shorthand\n * _.findIndex(users, 'active');\n * // => 2\n */\n var findIndex = createFindIndex();\n\n /**\n * This method is like `_.findIndex` except that it iterates over elements\n * of `collection` from right to left.\n *\n * If a property name is provided for `predicate` the created `_.property`\n * style callback returns the property value of the given element.\n *\n * If a value is also provided for `thisArg` the created `_.matchesProperty`\n * style callback returns `true` for elements that have a matching property\n * value, else `false`.\n *\n * If an object is provided for `predicate` the created `_.matches` style\n * callback returns `true` for elements that have the properties of the given\n * object, else `false`.\n *\n * @static\n * @memberOf _\n * @category Array\n * @param {Array} array The array to search.\n * @param {Function|Object|string} [predicate=_.identity] The function invoked\n * per iteration.\n * @param {*} [thisArg] The `this` binding of `predicate`.\n * @returns {number} Returns the index of the found element, else `-1`.\n * @example\n *\n * var users = [\n * { 'user': 'barney', 'active': true },\n * { 'user': 'fred', 'active': false },\n * { 'user': 'pebbles', 'active': false }\n * ];\n *\n * _.findLastIndex(users, function(chr) {\n * return chr.user == 'pebbles';\n * });\n * // => 2\n *\n * // using the `_.matches` callback shorthand\n * _.findLastIndex(users, { 'user': 'barney', 'active': true });\n * // => 0\n *\n * // using the `_.matchesProperty` callback shorthand\n * _.findLastIndex(users, 'active', false);\n * // => 2\n *\n * // using the `_.property` callback shorthand\n * _.findLastIndex(users, 'active');\n * // => 0\n */\n var findLastIndex = createFindIndex(true);\n\n /**\n * Gets the first element of `array`.\n *\n * @static\n * @memberOf _\n * @alias head\n * @category Array\n * @param {Array} array The array to query.\n * @returns {*} Returns the first element of `array`.\n * @example\n *\n * _.first([1, 2, 3]);\n * // => 1\n *\n * _.first([]);\n * // => undefined\n */\n function first(array) {\n return array ? array[0] : undefined;\n }\n\n /**\n * Flattens a nested array. If `isDeep` is `true` the array is recursively\n * flattened, otherwise it is only flattened a single level.\n *\n * @static\n * @memberOf _\n * @category Array\n * @param {Array} array The array to flatten.\n * @param {boolean} [isDeep] Specify a deep flatten.\n * @param- {Object} [guard] Enables use as a callback for functions like `_.map`.\n * @returns {Array} Returns the new flattened array.\n * @example\n *\n * _.flatten([1, [2, 3, [4]]]);\n * // => [1, 2, 3, [4]]\n *\n * // using `isDeep`\n * _.flatten([1, [2, 3, [4]]], true);\n * // => [1, 2, 3, 4]\n */\n function flatten(array, isDeep, guard) {\n var length = array ? array.length : 0;\n if (guard && isIterateeCall(array, isDeep, guard)) {\n isDeep = false;\n }\n return length ? baseFlatten(array, isDeep) : [];\n }\n\n /**\n * Recursively flattens a nested array.\n *\n * @static\n * @memberOf _\n * @category Array\n * @param {Array} array The array to recursively flatten.\n * @returns {Array} Returns the new flattened array.\n * @example\n *\n * _.flattenDeep([1, [2, 3, [4]]]);\n * // => [1, 2, 3, 4]\n */\n function flattenDeep(array) {\n var length = array ? array.length : 0;\n return length ? baseFlatten(array, true) : [];\n }\n\n /**\n * Gets the index at which the first occurrence of `value` is found in `array`\n * using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero)\n * for equality comparisons. If `fromIndex` is negative, it is used as the offset\n * from the end of `array`. If `array` is sorted providing `true` for `fromIndex`\n * performs a faster binary search.\n *\n * @static\n * @memberOf _\n * @category Array\n * @param {Array} array The array to search.\n * @param {*} value The value to search for.\n * @param {boolean|number} [fromIndex=0] The index to search from or `true`\n * to perform a binary search on a sorted array.\n * @returns {number} Returns the index of the matched value, else `-1`.\n * @example\n *\n * _.indexOf([1, 2, 1, 2], 2);\n * // => 1\n *\n * // using `fromIndex`\n * _.indexOf([1, 2, 1, 2], 2, 2);\n * // => 3\n *\n * // performing a binary search\n * _.indexOf([1, 1, 2, 2], 2, true);\n * // => 2\n */\n function indexOf(array, value, fromIndex) {\n var length = array ? array.length : 0;\n if (!length) {\n return -1;\n }\n if (typeof fromIndex == 'number') {\n fromIndex = fromIndex < 0 ? nativeMax(length + fromIndex, 0) : fromIndex;\n } else if (fromIndex) {\n var index = binaryIndex(array, value);\n if (index < length &&\n (value === value ? (value === array[index]) : (array[index] !== array[index]))) {\n return index;\n }\n return -1;\n }\n return baseIndexOf(array, value, fromIndex || 0);\n }\n\n /**\n * Gets all but the last element of `array`.\n *\n * @static\n * @memberOf _\n * @category Array\n * @param {Array} array The array to query.\n * @returns {Array} Returns the slice of `array`.\n * @example\n *\n * _.initial([1, 2, 3]);\n * // => [1, 2]\n */\n function initial(array) {\n return dropRight(array, 1);\n }\n\n /**\n * Creates an array of unique values that are included in all of the provided\n * arrays using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero)\n * for equality comparisons.\n *\n * @static\n * @memberOf _\n * @category Array\n * @param {...Array} [arrays] The arrays to inspect.\n * @returns {Array} Returns the new array of shared values.\n * @example\n * _.intersection([1, 2], [4, 2], [2, 1]);\n * // => [2]\n */\n var intersection = restParam(function(arrays) {\n var othLength = arrays.length,\n othIndex = othLength,\n caches = Array(length),\n indexOf = getIndexOf(),\n isCommon = indexOf == baseIndexOf,\n result = [];\n\n while (othIndex--) {\n var value = arrays[othIndex] = isArrayLike(value = arrays[othIndex]) ? value : [];\n caches[othIndex] = (isCommon && value.length >= 120) ? createCache(othIndex && value) : null;\n }\n var array = arrays[0],\n index = -1,\n length = array ? array.length : 0,\n seen = caches[0];\n\n outer:\n while (++index < length) {\n value = array[index];\n if ((seen ? cacheIndexOf(seen, value) : indexOf(result, value, 0)) < 0) {\n var othIndex = othLength;\n while (--othIndex) {\n var cache = caches[othIndex];\n if ((cache ? cacheIndexOf(cache, value) : indexOf(arrays[othIndex], value, 0)) < 0) {\n continue outer;\n }\n }\n if (seen) {\n seen.push(value);\n }\n result.push(value);\n }\n }\n return result;\n });\n\n /**\n * Gets the last element of `array`.\n *\n * @static\n * @memberOf _\n * @category Array\n * @param {Array} array The array to query.\n * @returns {*} Returns the last element of `array`.\n * @example\n *\n * _.last([1, 2, 3]);\n * // => 3\n */\n function last(array) {\n var length = array ? array.length : 0;\n return length ? array[length - 1] : undefined;\n }\n\n /**\n * This method is like `_.indexOf` except that it iterates over elements of\n * `array` from right to left.\n *\n * @static\n * @memberOf _\n * @category Array\n * @param {Array} array The array to search.\n * @param {*} value The value to search for.\n * @param {boolean|number} [fromIndex=array.length-1] The index to search from\n * or `true` to perform a binary search on a sorted array.\n * @returns {number} Returns the index of the matched value, else `-1`.\n * @example\n *\n * _.lastIndexOf([1, 2, 1, 2], 2);\n * // => 3\n *\n * // using `fromIndex`\n * _.lastIndexOf([1, 2, 1, 2], 2, 2);\n * // => 1\n *\n * // performing a binary search\n * _.lastIndexOf([1, 1, 2, 2], 2, true);\n * // => 3\n */\n function lastIndexOf(array, value, fromIndex) {\n var length = array ? array.length : 0;\n if (!length) {\n return -1;\n }\n var index = length;\n if (typeof fromIndex == 'number') {\n index = (fromIndex < 0 ? nativeMax(length + fromIndex, 0) : nativeMin(fromIndex || 0, length - 1)) + 1;\n } else if (fromIndex) {\n index = binaryIndex(array, value, true) - 1;\n var other = array[index];\n if (value === value ? (value === other) : (other !== other)) {\n return index;\n }\n return -1;\n }\n if (value !== value) {\n return indexOfNaN(array, index, true);\n }\n while (index--) {\n if (array[index] === value) {\n return index;\n }\n }\n return -1;\n }\n\n /**\n * Removes all provided values from `array` using\n * [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero)\n * for equality comparisons.\n *\n * **Note:** Unlike `_.without`, this method mutates `array`.\n *\n * @static\n * @memberOf _\n * @category Array\n * @param {Array} array The array to modify.\n * @param {...*} [values] The values to remove.\n * @returns {Array} Returns `array`.\n * @example\n *\n * var array = [1, 2, 3, 1, 2, 3];\n *\n * _.pull(array, 2, 3);\n * console.log(array);\n * // => [1, 1]\n */\n function pull() {\n var args = arguments,\n array = args[0];\n\n if (!(array && array.length)) {\n return array;\n }\n var index = 0,\n indexOf = getIndexOf(),\n length = args.length;\n\n while (++index < length) {\n var fromIndex = 0,\n value = args[index];\n\n while ((fromIndex = indexOf(array, value, fromIndex)) > -1) {\n splice.call(array, fromIndex, 1);\n }\n }\n return array;\n }\n\n /**\n * Removes elements from `array` corresponding to the given indexes and returns\n * an array of the removed elements. Indexes may be specified as an array of\n * indexes or as individual arguments.\n *\n * **Note:** Unlike `_.at`, this method mutates `array`.\n *\n * @static\n * @memberOf _\n * @category Array\n * @param {Array} array The array to modify.\n * @param {...(number|number[])} [indexes] The indexes of elements to remove,\n * specified as individual indexes or arrays of indexes.\n * @returns {Array} Returns the new array of removed elements.\n * @example\n *\n * var array = [5, 10, 15, 20];\n * var evens = _.pullAt(array, 1, 3);\n *\n * console.log(array);\n * // => [5, 15]\n *\n * console.log(evens);\n * // => [10, 20]\n */\n var pullAt = restParam(function(array, indexes) {\n indexes = baseFlatten(indexes);\n\n var result = baseAt(array, indexes);\n basePullAt(array, indexes.sort(baseCompareAscending));\n return result;\n });\n\n /**\n * Removes all elements from `array` that `predicate` returns truthy for\n * and returns an array of the removed elements. The predicate is bound to\n * `thisArg` and invoked with three arguments: (value, index, array).\n *\n * If a property name is provided for `predicate` the created `_.property`\n * style callback returns the property value of the given element.\n *\n * If a value is also provided for `thisArg` the created `_.matchesProperty`\n * style callback returns `true` for elements that have a matching property\n * value, else `false`.\n *\n * If an object is provided for `predicate` the created `_.matches` style\n * callback returns `true` for elements that have the properties of the given\n * object, else `false`.\n *\n * **Note:** Unlike `_.filter`, this method mutates `array`.\n *\n * @static\n * @memberOf _\n * @category Array\n * @param {Array} array The array to modify.\n * @param {Function|Object|string} [predicate=_.identity] The function invoked\n * per iteration.\n * @param {*} [thisArg] The `this` binding of `predicate`.\n * @returns {Array} Returns the new array of removed elements.\n * @example\n *\n * var array = [1, 2, 3, 4];\n * var evens = _.remove(array, function(n) {\n * return n % 2 == 0;\n * });\n *\n * console.log(array);\n * // => [1, 3]\n *\n * console.log(evens);\n * // => [2, 4]\n */\n function remove(array, predicate, thisArg) {\n var result = [];\n if (!(array && array.length)) {\n return result;\n }\n var index = -1,\n indexes = [],\n length = array.length;\n\n predicate = getCallback(predicate, thisArg, 3);\n while (++index < length) {\n var value = array[index];\n if (predicate(value, index, array)) {\n result.push(value);\n indexes.push(index);\n }\n }\n basePullAt(array, indexes);\n return result;\n }\n\n /**\n * Gets all but the first element of `array`.\n *\n * @static\n * @memberOf _\n * @alias tail\n * @category Array\n * @param {Array} array The array to query.\n * @returns {Array} Returns the slice of `array`.\n * @example\n *\n * _.rest([1, 2, 3]);\n * // => [2, 3]\n */\n function rest(array) {\n return drop(array, 1);\n }\n\n /**\n * Creates a slice of `array` from `start` up to, but not including, `end`.\n *\n * **Note:** This method is used instead of `Array#slice` to support node\n * lists in IE < 9 and to ensure dense arrays are returned.\n *\n * @static\n * @memberOf _\n * @category Array\n * @param {Array} array The array to slice.\n * @param {number} [start=0] The start position.\n * @param {number} [end=array.length] The end position.\n * @returns {Array} Returns the slice of `array`.\n */\n function slice(array, start, end) {\n var length = array ? array.length : 0;\n if (!length) {\n return [];\n }\n if (end && typeof end != 'number' && isIterateeCall(array, start, end)) {\n start = 0;\n end = length;\n }\n return baseSlice(array, start, end);\n }\n\n /**\n * Uses a binary search to determine the lowest index at which `value` should\n * be inserted into `array` in order to maintain its sort order. If an iteratee\n * function is provided it is invoked for `value` and each element of `array`\n * to compute their sort ranking. The iteratee is bound to `thisArg` and\n * invoked with one argument; (value).\n *\n * If a property name is provided for `iteratee` the created `_.property`\n * style callback returns the property value of the given element.\n *\n * If a value is also provided for `thisArg` the created `_.matchesProperty`\n * style callback returns `true` for elements that have a matching property\n * value, else `false`.\n *\n * If an object is provided for `iteratee` the created `_.matches` style\n * callback returns `true` for elements that have the properties of the given\n * object, else `false`.\n *\n * @static\n * @memberOf _\n * @category Array\n * @param {Array} array The sorted array to inspect.\n * @param {*} value The value to evaluate.\n * @param {Function|Object|string} [iteratee=_.identity] The function invoked\n * per iteration.\n * @param {*} [thisArg] The `this` binding of `iteratee`.\n * @returns {number} Returns the index at which `value` should be inserted\n * into `array`.\n * @example\n *\n * _.sortedIndex([30, 50], 40);\n * // => 1\n *\n * _.sortedIndex([4, 4, 5, 5], 5);\n * // => 2\n *\n * var dict = { 'data': { 'thirty': 30, 'forty': 40, 'fifty': 50 } };\n *\n * // using an iteratee function\n * _.sortedIndex(['thirty', 'fifty'], 'forty', function(word) {\n * return this.data[word];\n * }, dict);\n * // => 1\n *\n * // using the `_.property` callback shorthand\n * _.sortedIndex([{ 'x': 30 }, { 'x': 50 }], { 'x': 40 }, 'x');\n * // => 1\n */\n var sortedIndex = createSortedIndex();\n\n /**\n * This method is like `_.sortedIndex` except that it returns the highest\n * index at which `value` should be inserted into `array` in order to\n * maintain its sort order.\n *\n * @static\n * @memberOf _\n * @category Array\n * @param {Array} array The sorted array to inspect.\n * @param {*} value The value to evaluate.\n * @param {Function|Object|string} [iteratee=_.identity] The function invoked\n * per iteration.\n * @param {*} [thisArg] The `this` binding of `iteratee`.\n * @returns {number} Returns the index at which `value` should be inserted\n * into `array`.\n * @example\n *\n * _.sortedLastIndex([4, 4, 5, 5], 5);\n * // => 4\n */\n var sortedLastIndex = createSortedIndex(true);\n\n /**\n * Creates a slice of `array` with `n` elements taken from the beginning.\n *\n * @static\n * @memberOf _\n * @category Array\n * @param {Array} array The array to query.\n * @param {number} [n=1] The number of elements to take.\n * @param- {Object} [guard] Enables use as a callback for functions like `_.map`.\n * @returns {Array} Returns the slice of `array`.\n * @example\n *\n * _.take([1, 2, 3]);\n * // => [1]\n *\n * _.take([1, 2, 3], 2);\n * // => [1, 2]\n *\n * _.take([1, 2, 3], 5);\n * // => [1, 2, 3]\n *\n * _.take([1, 2, 3], 0);\n * // => []\n */\n function take(array, n, guard) {\n var length = array ? array.length : 0;\n if (!length) {\n return [];\n }\n if (guard ? isIterateeCall(array, n, guard) : n == null) {\n n = 1;\n }\n return baseSlice(array, 0, n < 0 ? 0 : n);\n }\n\n /**\n * Creates a slice of `array` with `n` elements taken from the end.\n *\n * @static\n * @memberOf _\n * @category Array\n * @param {Array} array The array to query.\n * @param {number} [n=1] The number of elements to take.\n * @param- {Object} [guard] Enables use as a callback for functions like `_.map`.\n * @returns {Array} Returns the slice of `array`.\n * @example\n *\n * _.takeRight([1, 2, 3]);\n * // => [3]\n *\n * _.takeRight([1, 2, 3], 2);\n * // => [2, 3]\n *\n * _.takeRight([1, 2, 3], 5);\n * // => [1, 2, 3]\n *\n * _.takeRight([1, 2, 3], 0);\n * // => []\n */\n function takeRight(array, n, guard) {\n var length = array ? array.length : 0;\n if (!length) {\n return [];\n }\n if (guard ? isIterateeCall(array, n, guard) : n == null) {\n n = 1;\n }\n n = length - (+n || 0);\n return baseSlice(array, n < 0 ? 0 : n);\n }\n\n /**\n * Creates a slice of `array` with elements taken from the end. Elements are\n * taken until `predicate` returns falsey. The predicate is bound to `thisArg`\n * and invoked with three arguments: (value, index, array).\n *\n * If a property name is provided for `predicate` the created `_.property`\n * style callback returns the property value of the given element.\n *\n * If a value is also provided for `thisArg` the created `_.matchesProperty`\n * style callback returns `true` for elements that have a matching property\n * value, else `false`.\n *\n * If an object is provided for `predicate` the created `_.matches` style\n * callback returns `true` for elements that have the properties of the given\n * object, else `false`.\n *\n * @static\n * @memberOf _\n * @category Array\n * @param {Array} array The array to query.\n * @param {Function|Object|string} [predicate=_.identity] The function invoked\n * per iteration.\n * @param {*} [thisArg] The `this` binding of `predicate`.\n * @returns {Array} Returns the slice of `array`.\n * @example\n *\n * _.takeRightWhile([1, 2, 3], function(n) {\n * return n > 1;\n * });\n * // => [2, 3]\n *\n * var users = [\n * { 'user': 'barney', 'active': true },\n * { 'user': 'fred', 'active': false },\n * { 'user': 'pebbles', 'active': false }\n * ];\n *\n * // using the `_.matches` callback shorthand\n * _.pluck(_.takeRightWhile(users, { 'user': 'pebbles', 'active': false }), 'user');\n * // => ['pebbles']\n *\n * // using the `_.matchesProperty` callback shorthand\n * _.pluck(_.takeRightWhile(users, 'active', false), 'user');\n * // => ['fred', 'pebbles']\n *\n * // using the `_.property` callback shorthand\n * _.pluck(_.takeRightWhile(users, 'active'), 'user');\n * // => []\n */\n function takeRightWhile(array, predicate, thisArg) {\n return (array && array.length)\n ? baseWhile(array, getCallback(predicate, thisArg, 3), false, true)\n : [];\n }\n\n /**\n * Creates a slice of `array` with elements taken from the beginning. Elements\n * are taken until `predicate` returns falsey. The predicate is bound to\n * `thisArg` and invoked with three arguments: (value, index, array).\n *\n * If a property name is provided for `predicate` the created `_.property`\n * style callback returns the property value of the given element.\n *\n * If a value is also provided for `thisArg` the created `_.matchesProperty`\n * style callback returns `true` for elements that have a matching property\n * value, else `false`.\n *\n * If an object is provided for `predicate` the created `_.matches` style\n * callback returns `true` for elements that have the properties of the given\n * object, else `false`.\n *\n * @static\n * @memberOf _\n * @category Array\n * @param {Array} array The array to query.\n * @param {Function|Object|string} [predicate=_.identity] The function invoked\n * per iteration.\n * @param {*} [thisArg] The `this` binding of `predicate`.\n * @returns {Array} Returns the slice of `array`.\n * @example\n *\n * _.takeWhile([1, 2, 3], function(n) {\n * return n < 3;\n * });\n * // => [1, 2]\n *\n * var users = [\n * { 'user': 'barney', 'active': false },\n * { 'user': 'fred', 'active': false},\n * { 'user': 'pebbles', 'active': true }\n * ];\n *\n * // using the `_.matches` callback shorthand\n * _.pluck(_.takeWhile(users, { 'user': 'barney', 'active': false }), 'user');\n * // => ['barney']\n *\n * // using the `_.matchesProperty` callback shorthand\n * _.pluck(_.takeWhile(users, 'active', false), 'user');\n * // => ['barney', 'fred']\n *\n * // using the `_.property` callback shorthand\n * _.pluck(_.takeWhile(users, 'active'), 'user');\n * // => []\n */\n function takeWhile(array, predicate, thisArg) {\n return (array && array.length)\n ? baseWhile(array, getCallback(predicate, thisArg, 3))\n : [];\n }\n\n /**\n * Creates an array of unique values, in order, from all of the provided arrays\n * using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero)\n * for equality comparisons.\n *\n * @static\n * @memberOf _\n * @category Array\n * @param {...Array} [arrays] The arrays to inspect.\n * @returns {Array} Returns the new array of combined values.\n * @example\n *\n * _.union([1, 2], [4, 2], [2, 1]);\n * // => [1, 2, 4]\n */\n var union = restParam(function(arrays) {\n return baseUniq(baseFlatten(arrays, false, true));\n });\n\n /**\n * Creates a duplicate-free version of an array, using\n * [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero)\n * for equality comparisons, in which only the first occurence of each element\n * is kept. Providing `true` for `isSorted` performs a faster search algorithm\n * for sorted arrays. If an iteratee function is provided it is invoked for\n * each element in the array to generate the criterion by which uniqueness\n * is computed. The `iteratee` is bound to `thisArg` and invoked with three\n * arguments: (value, index, array).\n *\n * If a property name is provided for `iteratee` the created `_.property`\n * style callback returns the property value of the given element.\n *\n * If a value is also provided for `thisArg` the created `_.matchesProperty`\n * style callback returns `true` for elements that have a matching property\n * value, else `false`.\n *\n * If an object is provided for `iteratee` the created `_.matches` style\n * callback returns `true` for elements that have the properties of the given\n * object, else `false`.\n *\n * @static\n * @memberOf _\n * @alias unique\n * @category Array\n * @param {Array} array The array to inspect.\n * @param {boolean} [isSorted] Specify the array is sorted.\n * @param {Function|Object|string} [iteratee] The function invoked per iteration.\n * @param {*} [thisArg] The `this` binding of `iteratee`.\n * @returns {Array} Returns the new duplicate-value-free array.\n * @example\n *\n * _.uniq([2, 1, 2]);\n * // => [2, 1]\n *\n * // using `isSorted`\n * _.uniq([1, 1, 2], true);\n * // => [1, 2]\n *\n * // using an iteratee function\n * _.uniq([1, 2.5, 1.5, 2], function(n) {\n * return this.floor(n);\n * }, Math);\n * // => [1, 2.5]\n *\n * // using the `_.property` callback shorthand\n * _.uniq([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x');\n * // => [{ 'x': 1 }, { 'x': 2 }]\n */\n function uniq(array, isSorted, iteratee, thisArg) {\n var length = array ? array.length : 0;\n if (!length) {\n return [];\n }\n if (isSorted != null && typeof isSorted != 'boolean') {\n thisArg = iteratee;\n iteratee = isIterateeCall(array, isSorted, thisArg) ? undefined : isSorted;\n isSorted = false;\n }\n var callback = getCallback();\n if (!(iteratee == null && callback === baseCallback)) {\n iteratee = callback(iteratee, thisArg, 3);\n }\n return (isSorted && getIndexOf() == baseIndexOf)\n ? sortedUniq(array, iteratee)\n : baseUniq(array, iteratee);\n }\n\n /**\n * This method is like `_.zip` except that it accepts an array of grouped\n * elements and creates an array regrouping the elements to their pre-zip\n * configuration.\n *\n * @static\n * @memberOf _\n * @category Array\n * @param {Array} array The array of grouped elements to process.\n * @returns {Array} Returns the new array of regrouped elements.\n * @example\n *\n * var zipped = _.zip(['fred', 'barney'], [30, 40], [true, false]);\n * // => [['fred', 30, true], ['barney', 40, false]]\n *\n * _.unzip(zipped);\n * // => [['fred', 'barney'], [30, 40], [true, false]]\n */\n function unzip(array) {\n if (!(array && array.length)) {\n return [];\n }\n var index = -1,\n length = 0;\n\n array = arrayFilter(array, function(group) {\n if (isArrayLike(group)) {\n length = nativeMax(group.length, length);\n return true;\n }\n });\n var result = Array(length);\n while (++index < length) {\n result[index] = arrayMap(array, baseProperty(index));\n }\n return result;\n }\n\n /**\n * This method is like `_.unzip` except that it accepts an iteratee to specify\n * how regrouped values should be combined. The `iteratee` is bound to `thisArg`\n * and invoked with four arguments: (accumulator, value, index, group).\n *\n * @static\n * @memberOf _\n * @category Array\n * @param {Array} array The array of grouped elements to process.\n * @param {Function} [iteratee] The function to combine regrouped values.\n * @param {*} [thisArg] The `this` binding of `iteratee`.\n * @returns {Array} Returns the new array of regrouped elements.\n * @example\n *\n * var zipped = _.zip([1, 2], [10, 20], [100, 200]);\n * // => [[1, 10, 100], [2, 20, 200]]\n *\n * _.unzipWith(zipped, _.add);\n * // => [3, 30, 300]\n */\n function unzipWith(array, iteratee, thisArg) {\n var length = array ? array.length : 0;\n if (!length) {\n return [];\n }\n var result = unzip(array);\n if (iteratee == null) {\n return result;\n }\n iteratee = bindCallback(iteratee, thisArg, 4);\n return arrayMap(result, function(group) {\n return arrayReduce(group, iteratee, undefined, true);\n });\n }\n\n /**\n * Creates an array excluding all provided values using\n * [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero)\n * for equality comparisons.\n *\n * @static\n * @memberOf _\n * @category Array\n * @param {Array} array The array to filter.\n * @param {...*} [values] The values to exclude.\n * @returns {Array} Returns the new array of filtered values.\n * @example\n *\n * _.without([1, 2, 1, 3], 1, 2);\n * // => [3]\n */\n var without = restParam(function(array, values) {\n return isArrayLike(array)\n ? baseDifference(array, values)\n : [];\n });\n\n /**\n * Creates an array of unique values that is the [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference)\n * of the provided arrays.\n *\n * @static\n * @memberOf _\n * @category Array\n * @param {...Array} [arrays] The arrays to inspect.\n * @returns {Array} Returns the new array of values.\n * @example\n *\n * _.xor([1, 2], [4, 2]);\n * // => [1, 4]\n */\n function xor() {\n var index = -1,\n length = arguments.length;\n\n while (++index < length) {\n var array = arguments[index];\n if (isArrayLike(array)) {\n var result = result\n ? arrayPush(baseDifference(result, array), baseDifference(array, result))\n : array;\n }\n }\n return result ? baseUniq(result) : [];\n }\n\n /**\n * Creates an array of grouped elements, the first of which contains the first\n * elements of the given arrays, the second of which contains the second elements\n * of the given arrays, and so on.\n *\n * @static\n * @memberOf _\n * @category Array\n * @param {...Array} [arrays] The arrays to process.\n * @returns {Array} Returns the new array of grouped elements.\n * @example\n *\n * _.zip(['fred', 'barney'], [30, 40], [true, false]);\n * // => [['fred', 30, true], ['barney', 40, false]]\n */\n var zip = restParam(unzip);\n\n /**\n * The inverse of `_.pairs`; this method returns an object composed from arrays\n * of property names and values. Provide either a single two dimensional array,\n * e.g. `[[key1, value1], [key2, value2]]` or two arrays, one of property names\n * and one of corresponding values.\n *\n * @static\n * @memberOf _\n * @alias object\n * @category Array\n * @param {Array} props The property names.\n * @param {Array} [values=[]] The property values.\n * @returns {Object} Returns the new object.\n * @example\n *\n * _.zipObject([['fred', 30], ['barney', 40]]);\n * // => { 'fred': 30, 'barney': 40 }\n *\n * _.zipObject(['fred', 'barney'], [30, 40]);\n * // => { 'fred': 30, 'barney': 40 }\n */\n function zipObject(props, values) {\n var index = -1,\n length = props ? props.length : 0,\n result = {};\n\n if (length && !values && !isArray(props[0])) {\n values = [];\n }\n while (++index < length) {\n var key = props[index];\n if (values) {\n result[key] = values[index];\n } else if (key) {\n result[key[0]] = key[1];\n }\n }\n return result;\n }\n\n /**\n * This method is like `_.zip` except that it accepts an iteratee to specify\n * how grouped values should be combined. The `iteratee` is bound to `thisArg`\n * and invoked with four arguments: (accumulator, value, index, group).\n *\n * @static\n * @memberOf _\n * @category Array\n * @param {...Array} [arrays] The arrays to process.\n * @param {Function} [iteratee] The function to combine grouped values.\n * @param {*} [thisArg] The `this` binding of `iteratee`.\n * @returns {Array} Returns the new array of grouped elements.\n * @example\n *\n * _.zipWith([1, 2], [10, 20], [100, 200], _.add);\n * // => [111, 222]\n */\n var zipWith = restParam(function(arrays) {\n var length = arrays.length,\n iteratee = length > 2 ? arrays[length - 2] : undefined,\n thisArg = length > 1 ? arrays[length - 1] : undefined;\n\n if (length > 2 && typeof iteratee == 'function') {\n length -= 2;\n } else {\n iteratee = (length > 1 && typeof thisArg == 'function') ? (--length, thisArg) : undefined;\n thisArg = undefined;\n }\n arrays.length = length;\n return unzipWith(arrays, iteratee, thisArg);\n });\n\n /*------------------------------------------------------------------------*/\n\n /**\n * Creates a `lodash` object that wraps `value` with explicit method\n * chaining enabled.\n *\n * @static\n * @memberOf _\n * @category Chain\n * @param {*} value The value to wrap.\n * @returns {Object} Returns the new `lodash` wrapper instance.\n * @example\n *\n * var users = [\n * { 'user': 'barney', 'age': 36 },\n * { 'user': 'fred', 'age': 40 },\n * { 'user': 'pebbles', 'age': 1 }\n * ];\n *\n * var youngest = _.chain(users)\n * .sortBy('age')\n * .map(function(chr) {\n * return chr.user + ' is ' + chr.age;\n * })\n * .first()\n * .value();\n * // => 'pebbles is 1'\n */\n function chain(value) {\n var result = lodash(value);\n result.__chain__ = true;\n return result;\n }\n\n /**\n * This method invokes `interceptor` and returns `value`. The interceptor is\n * bound to `thisArg` and invoked with one argument; (value). The purpose of\n * this method is to \"tap into\" a method chain in order to perform operations\n * on intermediate results within the chain.\n *\n * @static\n * @memberOf _\n * @category Chain\n * @param {*} value The value to provide to `interceptor`.\n * @param {Function} interceptor The function to invoke.\n * @param {*} [thisArg] The `this` binding of `interceptor`.\n * @returns {*} Returns `value`.\n * @example\n *\n * _([1, 2, 3])\n * .tap(function(array) {\n * array.pop();\n * })\n * .reverse()\n * .value();\n * // => [2, 1]\n */\n function tap(value, interceptor, thisArg) {\n interceptor.call(thisArg, value);\n return value;\n }\n\n /**\n * This method is like `_.tap` except that it returns the result of `interceptor`.\n *\n * @static\n * @memberOf _\n * @category Chain\n * @param {*} value The value to provide to `interceptor`.\n * @param {Function} interceptor The function to invoke.\n * @param {*} [thisArg] The `this` binding of `interceptor`.\n * @returns {*} Returns the result of `interceptor`.\n * @example\n *\n * _(' abc ')\n * .chain()\n * .trim()\n * .thru(function(value) {\n * return [value];\n * })\n * .value();\n * // => ['abc']\n */\n function thru(value, interceptor, thisArg) {\n return interceptor.call(thisArg, value);\n }\n\n /**\n * Enables explicit method chaining on the wrapper object.\n *\n * @name chain\n * @memberOf _\n * @category Chain\n * @returns {Object} Returns the new `lodash` wrapper instance.\n * @example\n *\n * var users = [\n * { 'user': 'barney', 'age': 36 },\n * { 'user': 'fred', 'age': 40 }\n * ];\n *\n * // without explicit chaining\n * _(users).first();\n * // => { 'user': 'barney', 'age': 36 }\n *\n * // with explicit chaining\n * _(users).chain()\n * .first()\n * .pick('user')\n * .value();\n * // => { 'user': 'barney' }\n */\n function wrapperChain() {\n return chain(this);\n }\n\n /**\n * Executes the chained sequence and returns the wrapped result.\n *\n * @name commit\n * @memberOf _\n * @category Chain\n * @returns {Object} Returns the new `lodash` wrapper instance.\n * @example\n *\n * var array = [1, 2];\n * var wrapped = _(array).push(3);\n *\n * console.log(array);\n * // => [1, 2]\n *\n * wrapped = wrapped.commit();\n * console.log(array);\n * // => [1, 2, 3]\n *\n * wrapped.last();\n * // => 3\n *\n * console.log(array);\n * // => [1, 2, 3]\n */\n function wrapperCommit() {\n return new LodashWrapper(this.value(), this.__chain__);\n }\n\n /**\n * Creates a new array joining a wrapped array with any additional arrays\n * and/or values.\n *\n * @name concat\n * @memberOf _\n * @category Chain\n * @param {...*} [values] The values to concatenate.\n * @returns {Array} Returns the new concatenated array.\n * @example\n *\n * var array = [1];\n * var wrapped = _(array).concat(2, [3], [[4]]);\n *\n * console.log(wrapped.value());\n * // => [1, 2, 3, [4]]\n *\n * console.log(array);\n * // => [1]\n */\n var wrapperConcat = restParam(function(values) {\n values = baseFlatten(values);\n return this.thru(function(array) {\n return arrayConcat(isArray(array) ? array : [toObject(array)], values);\n });\n });\n\n /**\n * Creates a clone of the chained sequence planting `value` as the wrapped value.\n *\n * @name plant\n * @memberOf _\n * @category Chain\n * @returns {Object} Returns the new `lodash` wrapper instance.\n * @example\n *\n * var array = [1, 2];\n * var wrapped = _(array).map(function(value) {\n * return Math.pow(value, 2);\n * });\n *\n * var other = [3, 4];\n * var otherWrapped = wrapped.plant(other);\n *\n * otherWrapped.value();\n * // => [9, 16]\n *\n * wrapped.value();\n * // => [1, 4]\n */\n function wrapperPlant(value) {\n var result,\n parent = this;\n\n while (parent instanceof baseLodash) {\n var clone = wrapperClone(parent);\n if (result) {\n previous.__wrapped__ = clone;\n } else {\n result = clone;\n }\n var previous = clone;\n parent = parent.__wrapped__;\n }\n previous.__wrapped__ = value;\n return result;\n }\n\n /**\n * Reverses the wrapped array so the first element becomes the last, the\n * second element becomes the second to last, and so on.\n *\n * **Note:** This method mutates the wrapped array.\n *\n * @name reverse\n * @memberOf _\n * @category Chain\n * @returns {Object} Returns the new reversed `lodash` wrapper instance.\n * @example\n *\n * var array = [1, 2, 3];\n *\n * _(array).reverse().value()\n * // => [3, 2, 1]\n *\n * console.log(array);\n * // => [3, 2, 1]\n */\n function wrapperReverse() {\n var value = this.__wrapped__;\n\n var interceptor = function(value) {\n return (wrapped && wrapped.__dir__ < 0) ? value : value.reverse();\n };\n if (value instanceof LazyWrapper) {\n var wrapped = value;\n if (this.__actions__.length) {\n wrapped = new LazyWrapper(this);\n }\n wrapped = wrapped.reverse();\n wrapped.__actions__.push({ 'func': thru, 'args': [interceptor], 'thisArg': undefined });\n return new LodashWrapper(wrapped, this.__chain__);\n }\n return this.thru(interceptor);\n }\n\n /**\n * Produces the result of coercing the unwrapped value to a string.\n *\n * @name toString\n * @memberOf _\n * @category Chain\n * @returns {string} Returns the coerced string value.\n * @example\n *\n * _([1, 2, 3]).toString();\n * // => '1,2,3'\n */\n function wrapperToString() {\n return (this.value() + '');\n }\n\n /**\n * Executes the chained sequence to extract the unwrapped value.\n *\n * @name value\n * @memberOf _\n * @alias run, toJSON, valueOf\n * @category Chain\n * @returns {*} Returns the resolved unwrapped value.\n * @example\n *\n * _([1, 2, 3]).value();\n * // => [1, 2, 3]\n */\n function wrapperValue() {\n return baseWrapperValue(this.__wrapped__, this.__actions__);\n }\n\n /*------------------------------------------------------------------------*/\n\n /**\n * Creates an array of elements corresponding to the given keys, or indexes,\n * of `collection`. Keys may be specified as individual arguments or as arrays\n * of keys.\n *\n * @static\n * @memberOf _\n * @category Collection\n * @param {Array|Object|string} collection The collection to iterate over.\n * @param {...(number|number[]|string|string[])} [props] The property names\n * or indexes of elements to pick, specified individually or in arrays.\n * @returns {Array} Returns the new array of picked elements.\n * @example\n *\n * _.at(['a', 'b', 'c'], [0, 2]);\n * // => ['a', 'c']\n *\n * _.at(['barney', 'fred', 'pebbles'], 0, 2);\n * // => ['barney', 'pebbles']\n */\n var at = restParam(function(collection, props) {\n return baseAt(collection, baseFlatten(props));\n });\n\n /**\n * Creates an object composed of keys generated from the results of running\n * each element of `collection` through `iteratee`. The corresponding value\n * of each key is the number of times the key was returned by `iteratee`.\n * The `iteratee` is bound to `thisArg` and invoked with three arguments:\n * (value, index|key, collection).\n *\n * If a property name is provided for `iteratee` the created `_.property`\n * style callback returns the property value of the given element.\n *\n * If a value is also provided for `thisArg` the created `_.matchesProperty`\n * style callback returns `true` for elements that have a matching property\n * value, else `false`.\n *\n * If an object is provided for `iteratee` the created `_.matches` style\n * callback returns `true` for elements that have the properties of the given\n * object, else `false`.\n *\n * @static\n * @memberOf _\n * @category Collection\n * @param {Array|Object|string} collection The collection to iterate over.\n * @param {Function|Object|string} [iteratee=_.identity] The function invoked\n * per iteration.\n * @param {*} [thisArg] The `this` binding of `iteratee`.\n * @returns {Object} Returns the composed aggregate object.\n * @example\n *\n * _.countBy([4.3, 6.1, 6.4], function(n) {\n * return Math.floor(n);\n * });\n * // => { '4': 1, '6': 2 }\n *\n * _.countBy([4.3, 6.1, 6.4], function(n) {\n * return this.floor(n);\n * }, Math);\n * // => { '4': 1, '6': 2 }\n *\n * _.countBy(['one', 'two', 'three'], 'length');\n * // => { '3': 2, '5': 1 }\n */\n var countBy = createAggregator(function(result, value, key) {\n hasOwnProperty.call(result, key) ? ++result[key] : (result[key] = 1);\n });\n\n /**\n * Checks if `predicate` returns truthy for **all** elements of `collection`.\n * The predicate is bound to `thisArg` and invoked with three arguments:\n * (value, index|key, collection).\n *\n * If a property name is provided for `predicate` the created `_.property`\n * style callback returns the property value of the given element.\n *\n * If a value is also provided for `thisArg` the created `_.matchesProperty`\n * style callback returns `true` for elements that have a matching property\n * value, else `false`.\n *\n * If an object is provided for `predicate` the created `_.matches` style\n * callback returns `true` for elements that have the properties of the given\n * object, else `false`.\n *\n * @static\n * @memberOf _\n * @alias all\n * @category Collection\n * @param {Array|Object|string} collection The collection to iterate over.\n * @param {Function|Object|string} [predicate=_.identity] The function invoked\n * per iteration.\n * @param {*} [thisArg] The `this` binding of `predicate`.\n * @returns {boolean} Returns `true` if all elements pass the predicate check,\n * else `false`.\n * @example\n *\n * _.every([true, 1, null, 'yes'], Boolean);\n * // => false\n *\n * var users = [\n * { 'user': 'barney', 'active': false },\n * { 'user': 'fred', 'active': false }\n * ];\n *\n * // using the `_.matches` callback shorthand\n * _.every(users, { 'user': 'barney', 'active': false });\n * // => false\n *\n * // using the `_.matchesProperty` callback shorthand\n * _.every(users, 'active', false);\n * // => true\n *\n * // using the `_.property` callback shorthand\n * _.every(users, 'active');\n * // => false\n */\n function every(collection, predicate, thisArg) {\n var func = isArray(collection) ? arrayEvery : baseEvery;\n if (thisArg && isIterateeCall(collection, predicate, thisArg)) {\n predicate = undefined;\n }\n if (typeof predicate != 'function' || thisArg !== undefined) {\n predicate = getCallback(predicate, thisArg, 3);\n }\n return func(collection, predicate);\n }\n\n /**\n * Iterates over elements of `collection`, returning an array of all elements\n * `predicate` returns truthy for. The predicate is bound to `thisArg` and\n * invoked with three arguments: (value, index|key, collection).\n *\n * If a property name is provided for `predicate` the created `_.property`\n * style callback returns the property value of the given element.\n *\n * If a value is also provided for `thisArg` the created `_.matchesProperty`\n * style callback returns `true` for elements that have a matching property\n * value, else `false`.\n *\n * If an object is provided for `predicate` the created `_.matches` style\n * callback returns `true` for elements that have the properties of the given\n * object, else `false`.\n *\n * @static\n * @memberOf _\n * @alias select\n * @category Collection\n * @param {Array|Object|string} collection The collection to iterate over.\n * @param {Function|Object|string} [predicate=_.identity] The function invoked\n * per iteration.\n * @param {*} [thisArg] The `this` binding of `predicate`.\n * @returns {Array} Returns the new filtered array.\n * @example\n *\n * _.filter([4, 5, 6], function(n) {\n * return n % 2 == 0;\n * });\n * // => [4, 6]\n *\n * var users = [\n * { 'user': 'barney', 'age': 36, 'active': true },\n * { 'user': 'fred', 'age': 40, 'active': false }\n * ];\n *\n * // using the `_.matches` callback shorthand\n * _.pluck(_.filter(users, { 'age': 36, 'active': true }), 'user');\n * // => ['barney']\n *\n * // using the `_.matchesProperty` callback shorthand\n * _.pluck(_.filter(users, 'active', false), 'user');\n * // => ['fred']\n *\n * // using the `_.property` callback shorthand\n * _.pluck(_.filter(users, 'active'), 'user');\n * // => ['barney']\n */\n function filter(collection, predicate, thisArg) {\n var func = isArray(collection) ? arrayFilter : baseFilter;\n predicate = getCallback(predicate, thisArg, 3);\n return func(collection, predicate);\n }\n\n /**\n * Iterates over elements of `collection`, returning the first element\n * `predicate` returns truthy for. The predicate is bound to `thisArg` and\n * invoked with three arguments: (value, index|key, collection).\n *\n * If a property name is provided for `predicate` the created `_.property`\n * style callback returns the property value of the given element.\n *\n * If a value is also provided for `thisArg` the created `_.matchesProperty`\n * style callback returns `true` for elements that have a matching property\n * value, else `false`.\n *\n * If an object is provided for `predicate` the created `_.matches` style\n * callback returns `true` for elements that have the properties of the given\n * object, else `false`.\n *\n * @static\n * @memberOf _\n * @alias detect\n * @category Collection\n * @param {Array|Object|string} collection The collection to search.\n * @param {Function|Object|string} [predicate=_.identity] The function invoked\n * per iteration.\n * @param {*} [thisArg] The `this` binding of `predicate`.\n * @returns {*} Returns the matched element, else `undefined`.\n * @example\n *\n * var users = [\n * { 'user': 'barney', 'age': 36, 'active': true },\n * { 'user': 'fred', 'age': 40, 'active': false },\n * { 'user': 'pebbles', 'age': 1, 'active': true }\n * ];\n *\n * _.result(_.find(users, function(chr) {\n * return chr.age < 40;\n * }), 'user');\n * // => 'barney'\n *\n * // using the `_.matches` callback shorthand\n * _.result(_.find(users, { 'age': 1, 'active': true }), 'user');\n * // => 'pebbles'\n *\n * // using the `_.matchesProperty` callback shorthand\n * _.result(_.find(users, 'active', false), 'user');\n * // => 'fred'\n *\n * // using the `_.property` callback shorthand\n * _.result(_.find(users, 'active'), 'user');\n * // => 'barney'\n */\n var find = createFind(baseEach);\n\n /**\n * This method is like `_.find` except that it iterates over elements of\n * `collection` from right to left.\n *\n * @static\n * @memberOf _\n * @category Collection\n * @param {Array|Object|string} collection The collection to search.\n * @param {Function|Object|string} [predicate=_.identity] The function invoked\n * per iteration.\n * @param {*} [thisArg] The `this` binding of `predicate`.\n * @returns {*} Returns the matched element, else `undefined`.\n * @example\n *\n * _.findLast([1, 2, 3, 4], function(n) {\n * return n % 2 == 1;\n * });\n * // => 3\n */\n var findLast = createFind(baseEachRight, true);\n\n /**\n * Performs a deep comparison between each element in `collection` and the\n * source object, returning the first element that has equivalent property\n * values.\n *\n * **Note:** This method supports comparing arrays, booleans, `Date` objects,\n * numbers, `Object` objects, regexes, and strings. Objects are compared by\n * their own, not inherited, enumerable properties. For comparing a single\n * own or inherited property value see `_.matchesProperty`.\n *\n * @static\n * @memberOf _\n * @category Collection\n * @param {Array|Object|string} collection The collection to search.\n * @param {Object} source The object of property values to match.\n * @returns {*} Returns the matched element, else `undefined`.\n * @example\n *\n * var users = [\n * { 'user': 'barney', 'age': 36, 'active': true },\n * { 'user': 'fred', 'age': 40, 'active': false }\n * ];\n *\n * _.result(_.findWhere(users, { 'age': 36, 'active': true }), 'user');\n * // => 'barney'\n *\n * _.result(_.findWhere(users, { 'age': 40, 'active': false }), 'user');\n * // => 'fred'\n */\n function findWhere(collection, source) {\n return find(collection, baseMatches(source));\n }\n\n /**\n * Iterates over elements of `collection` invoking `iteratee` for each element.\n * The `iteratee` is bound to `thisArg` and invoked with three arguments:\n * (value, index|key, collection). Iteratee functions may exit iteration early\n * by explicitly returning `false`.\n *\n * **Note:** As with other \"Collections\" methods, objects with a \"length\" property\n * are iterated like arrays. To avoid this behavior `_.forIn` or `_.forOwn`\n * may be used for object iteration.\n *\n * @static\n * @memberOf _\n * @alias each\n * @category Collection\n * @param {Array|Object|string} collection The collection to iterate over.\n * @param {Function} [iteratee=_.identity] The function invoked per iteration.\n * @param {*} [thisArg] The `this` binding of `iteratee`.\n * @returns {Array|Object|string} Returns `collection`.\n * @example\n *\n * _([1, 2]).forEach(function(n) {\n * console.log(n);\n * }).value();\n * // => logs each value from left to right and returns the array\n *\n * _.forEach({ 'a': 1, 'b': 2 }, function(n, key) {\n * console.log(n, key);\n * });\n * // => logs each value-key pair and returns the object (iteration order is not guaranteed)\n */\n var forEach = createForEach(arrayEach, baseEach);\n\n /**\n * This method is like `_.forEach` except that it iterates over elements of\n * `collection` from right to left.\n *\n * @static\n * @memberOf _\n * @alias eachRight\n * @category Collection\n * @param {Array|Object|string} collection The collection to iterate over.\n * @param {Function} [iteratee=_.identity] The function invoked per iteration.\n * @param {*} [thisArg] The `this` binding of `iteratee`.\n * @returns {Array|Object|string} Returns `collection`.\n * @example\n *\n * _([1, 2]).forEachRight(function(n) {\n * console.log(n);\n * }).value();\n * // => logs each value from right to left and returns the array\n */\n var forEachRight = createForEach(arrayEachRight, baseEachRight);\n\n /**\n * Creates an object composed of keys generated from the results of running\n * each element of `collection` through `iteratee`. The corresponding value\n * of each key is an array of the elements responsible for generating the key.\n * The `iteratee` is bound to `thisArg` and invoked with three arguments:\n * (value, index|key, collection).\n *\n * If a property name is provided for `iteratee` the created `_.property`\n * style callback returns the property value of the given element.\n *\n * If a value is also provided for `thisArg` the created `_.matchesProperty`\n * style callback returns `true` for elements that have a matching property\n * value, else `false`.\n *\n * If an object is provided for `iteratee` the created `_.matches` style\n * callback returns `true` for elements that have the properties of the given\n * object, else `false`.\n *\n * @static\n * @memberOf _\n * @category Collection\n * @param {Array|Object|string} collection The collection to iterate over.\n * @param {Function|Object|string} [iteratee=_.identity] The function invoked\n * per iteration.\n * @param {*} [thisArg] The `this` binding of `iteratee`.\n * @returns {Object} Returns the composed aggregate object.\n * @example\n *\n * _.groupBy([4.2, 6.1, 6.4], function(n) {\n * return Math.floor(n);\n * });\n * // => { '4': [4.2], '6': [6.1, 6.4] }\n *\n * _.groupBy([4.2, 6.1, 6.4], function(n) {\n * return this.floor(n);\n * }, Math);\n * // => { '4': [4.2], '6': [6.1, 6.4] }\n *\n * // using the `_.property` callback shorthand\n * _.groupBy(['one', 'two', 'three'], 'length');\n * // => { '3': ['one', 'two'], '5': ['three'] }\n */\n var groupBy = createAggregator(function(result, value, key) {\n if (hasOwnProperty.call(result, key)) {\n result[key].push(value);\n } else {\n result[key] = [value];\n }\n });\n\n /**\n * Checks if `value` is in `collection` using\n * [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero)\n * for equality comparisons. If `fromIndex` is negative, it is used as the offset\n * from the end of `collection`.\n *\n * @static\n * @memberOf _\n * @alias contains, include\n * @category Collection\n * @param {Array|Object|string} collection The collection to search.\n * @param {*} target The value to search for.\n * @param {number} [fromIndex=0] The index to search from.\n * @param- {Object} [guard] Enables use as a callback for functions like `_.reduce`.\n * @returns {boolean} Returns `true` if a matching element is found, else `false`.\n * @example\n *\n * _.includes([1, 2, 3], 1);\n * // => true\n *\n * _.includes([1, 2, 3], 1, 2);\n * // => false\n *\n * _.includes({ 'user': 'fred', 'age': 40 }, 'fred');\n * // => true\n *\n * _.includes('pebbles', 'eb');\n * // => true\n */\n function includes(collection, target, fromIndex, guard) {\n var length = collection ? getLength(collection) : 0;\n if (!isLength(length)) {\n collection = values(collection);\n length = collection.length;\n }\n if (typeof fromIndex != 'number' || (guard && isIterateeCall(target, fromIndex, guard))) {\n fromIndex = 0;\n } else {\n fromIndex = fromIndex < 0 ? nativeMax(length + fromIndex, 0) : (fromIndex || 0);\n }\n return (typeof collection == 'string' || !isArray(collection) && isString(collection))\n ? (fromIndex <= length && collection.indexOf(target, fromIndex) > -1)\n : (!!length && getIndexOf(collection, target, fromIndex) > -1);\n }\n\n /**\n * Creates an object composed of keys generated from the results of running\n * each element of `collection` through `iteratee`. The corresponding value\n * of each key is the last element responsible for generating the key. The\n * iteratee function is bound to `thisArg` and invoked with three arguments:\n * (value, index|key, collection).\n *\n * If a property name is provided for `iteratee` the created `_.property`\n * style callback returns the property value of the given element.\n *\n * If a value is also provided for `thisArg` the created `_.matchesProperty`\n * style callback returns `true` for elements that have a matching property\n * value, else `false`.\n *\n * If an object is provided for `iteratee` the created `_.matches` style\n * callback returns `true` for elements that have the properties of the given\n * object, else `false`.\n *\n * @static\n * @memberOf _\n * @category Collection\n * @param {Array|Object|string} collection The collection to iterate over.\n * @param {Function|Object|string} [iteratee=_.identity] The function invoked\n * per iteration.\n * @param {*} [thisArg] The `this` binding of `iteratee`.\n * @returns {Object} Returns the composed aggregate object.\n * @example\n *\n * var keyData = [\n * { 'dir': 'left', 'code': 97 },\n * { 'dir': 'right', 'code': 100 }\n * ];\n *\n * _.indexBy(keyData, 'dir');\n * // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } }\n *\n * _.indexBy(keyData, function(object) {\n * return String.fromCharCode(object.code);\n * });\n * // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } }\n *\n * _.indexBy(keyData, function(object) {\n * return this.fromCharCode(object.code);\n * }, String);\n * // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } }\n */\n var indexBy = createAggregator(function(result, value, key) {\n result[key] = value;\n });\n\n /**\n * Invokes the method at `path` of each element in `collection`, returning\n * an array of the results of each invoked method. Any additional arguments\n * are provided to each invoked method. If `methodName` is a function it is\n * invoked for, and `this` bound to, each element in `collection`.\n *\n * @static\n * @memberOf _\n * @category Collection\n * @param {Array|Object|string} collection The collection to iterate over.\n * @param {Array|Function|string} path The path of the method to invoke or\n * the function invoked per iteration.\n * @param {...*} [args] The arguments to invoke the method with.\n * @returns {Array} Returns the array of results.\n * @example\n *\n * _.invoke([[5, 1, 7], [3, 2, 1]], 'sort');\n * // => [[1, 5, 7], [1, 2, 3]]\n *\n * _.invoke([123, 456], String.prototype.split, '');\n * // => [['1', '2', '3'], ['4', '5', '6']]\n */\n var invoke = restParam(function(collection, path, args) {\n var index = -1,\n isFunc = typeof path == 'function',\n isProp = isKey(path),\n result = isArrayLike(collection) ? Array(collection.length) : [];\n\n baseEach(collection, function(value) {\n var func = isFunc ? path : ((isProp && value != null) ? value[path] : undefined);\n result[++index] = func ? func.apply(value, args) : invokePath(value, path, args);\n });\n return result;\n });\n\n /**\n * Creates an array of values by running each element in `collection` through\n * `iteratee`. The `iteratee` is bound to `thisArg` and invoked with three\n * arguments: (value, index|key, collection).\n *\n * If a property name is provided for `iteratee` the created `_.property`\n * style callback returns the property value of the given element.\n *\n * If a value is also provided for `thisArg` the created `_.matchesProperty`\n * style callback returns `true` for elements that have a matching property\n * value, else `false`.\n *\n * If an object is provided for `iteratee` the created `_.matches` style\n * callback returns `true` for elements that have the properties of the given\n * object, else `false`.\n *\n * Many lodash methods are guarded to work as iteratees for methods like\n * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`.\n *\n * The guarded methods are:\n * `ary`, `callback`, `chunk`, `clone`, `create`, `curry`, `curryRight`,\n * `drop`, `dropRight`, `every`, `fill`, `flatten`, `invert`, `max`, `min`,\n * `parseInt`, `slice`, `sortBy`, `take`, `takeRight`, `template`, `trim`,\n * `trimLeft`, `trimRight`, `trunc`, `random`, `range`, `sample`, `some`,\n * `sum`, `uniq`, and `words`\n *\n * @static\n * @memberOf _\n * @alias collect\n * @category Collection\n * @param {Array|Object|string} collection The collection to iterate over.\n * @param {Function|Object|string} [iteratee=_.identity] The function invoked\n * per iteration.\n * @param {*} [thisArg] The `this` binding of `iteratee`.\n * @returns {Array} Returns the new mapped array.\n * @example\n *\n * function timesThree(n) {\n * return n * 3;\n * }\n *\n * _.map([1, 2], timesThree);\n * // => [3, 6]\n *\n * _.map({ 'a': 1, 'b': 2 }, timesThree);\n * // => [3, 6] (iteration order is not guaranteed)\n *\n * var users = [\n * { 'user': 'barney' },\n * { 'user': 'fred' }\n * ];\n *\n * // using the `_.property` callback shorthand\n * _.map(users, 'user');\n * // => ['barney', 'fred']\n */\n function map(collection, iteratee, thisArg) {\n var func = isArray(collection) ? arrayMap : baseMap;\n iteratee = getCallback(iteratee, thisArg, 3);\n return func(collection, iteratee);\n }\n\n /**\n * Creates an array of elements split into two groups, the first of which\n * contains elements `predicate` returns truthy for, while the second of which\n * contains elements `predicate` returns falsey for. The predicate is bound\n * to `thisArg` and invoked with three arguments: (value, index|key, collection).\n *\n * If a property name is provided for `predicate` the created `_.property`\n * style callback returns the property value of the given element.\n *\n * If a value is also provided for `thisArg` the created `_.matchesProperty`\n * style callback returns `true` for elements that have a matching property\n * value, else `false`.\n *\n * If an object is provided for `predicate` the created `_.matches` style\n * callback returns `true` for elements that have the properties of the given\n * object, else `false`.\n *\n * @static\n * @memberOf _\n * @category Collection\n * @param {Array|Object|string} collection The collection to iterate over.\n * @param {Function|Object|string} [predicate=_.identity] The function invoked\n * per iteration.\n * @param {*} [thisArg] The `this` binding of `predicate`.\n * @returns {Array} Returns the array of grouped elements.\n * @example\n *\n * _.partition([1, 2, 3], function(n) {\n * return n % 2;\n * });\n * // => [[1, 3], [2]]\n *\n * _.partition([1.2, 2.3, 3.4], function(n) {\n * return this.floor(n) % 2;\n * }, Math);\n * // => [[1.2, 3.4], [2.3]]\n *\n * var users = [\n * { 'user': 'barney', 'age': 36, 'active': false },\n * { 'user': 'fred', 'age': 40, 'active': true },\n * { 'user': 'pebbles', 'age': 1, 'active': false }\n * ];\n *\n * var mapper = function(array) {\n * return _.pluck(array, 'user');\n * };\n *\n * // using the `_.matches` callback shorthand\n * _.map(_.partition(users, { 'age': 1, 'active': false }), mapper);\n * // => [['pebbles'], ['barney', 'fred']]\n *\n * // using the `_.matchesProperty` callback shorthand\n * _.map(_.partition(users, 'active', false), mapper);\n * // => [['barney', 'pebbles'], ['fred']]\n *\n * // using the `_.property` callback shorthand\n * _.map(_.partition(users, 'active'), mapper);\n * // => [['fred'], ['barney', 'pebbles']]\n */\n var partition = createAggregator(function(result, value, key) {\n result[key ? 0 : 1].push(value);\n }, function() { return [[], []]; });\n\n /**\n * Gets the property value of `path` from all elements in `collection`.\n *\n * @static\n * @memberOf _\n * @category Collection\n * @param {Array|Object|string} collection The collection to iterate over.\n * @param {Array|string} path The path of the property to pluck.\n * @returns {Array} Returns the property values.\n * @example\n *\n * var users = [\n * { 'user': 'barney', 'age': 36 },\n * { 'user': 'fred', 'age': 40 }\n * ];\n *\n * _.pluck(users, 'user');\n * // => ['barney', 'fred']\n *\n * var userIndex = _.indexBy(users, 'user');\n * _.pluck(userIndex, 'age');\n * // => [36, 40] (iteration order is not guaranteed)\n */\n function pluck(collection, path) {\n return map(collection, property(path));\n }\n\n /**\n * Reduces `collection` to a value which is the accumulated result of running\n * each element in `collection` through `iteratee`, where each successive\n * invocation is supplied the return value of the previous. If `accumulator`\n * is not provided the first element of `collection` is used as the initial\n * value. The `iteratee` is bound to `thisArg` and invoked with four arguments:\n * (accumulator, value, index|key, collection).\n *\n * Many lodash methods are guarded to work as iteratees for methods like\n * `_.reduce`, `_.reduceRight`, and `_.transform`.\n *\n * The guarded methods are:\n * `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `sortByAll`,\n * and `sortByOrder`\n *\n * @static\n * @memberOf _\n * @alias foldl, inject\n * @category Collection\n * @param {Array|Object|string} collection The collection to iterate over.\n * @param {Function} [iteratee=_.identity] The function invoked per iteration.\n * @param {*} [accumulator] The initial value.\n * @param {*} [thisArg] The `this` binding of `iteratee`.\n * @returns {*} Returns the accumulated value.\n * @example\n *\n * _.reduce([1, 2], function(total, n) {\n * return total + n;\n * });\n * // => 3\n *\n * _.reduce({ 'a': 1, 'b': 2 }, function(result, n, key) {\n * result[key] = n * 3;\n * return result;\n * }, {});\n * // => { 'a': 3, 'b': 6 } (iteration order is not guaranteed)\n */\n var reduce = createReduce(arrayReduce, baseEach);\n\n /**\n * This method is like `_.reduce` except that it iterates over elements of\n * `collection` from right to left.\n *\n * @static\n * @memberOf _\n * @alias foldr\n * @category Collection\n * @param {Array|Object|string} collection The collection to iterate over.\n * @param {Function} [iteratee=_.identity] The function invoked per iteration.\n * @param {*} [accumulator] The initial value.\n * @param {*} [thisArg] The `this` binding of `iteratee`.\n * @returns {*} Returns the accumulated value.\n * @example\n *\n * var array = [[0, 1], [2, 3], [4, 5]];\n *\n * _.reduceRight(array, function(flattened, other) {\n * return flattened.concat(other);\n * }, []);\n * // => [4, 5, 2, 3, 0, 1]\n */\n var reduceRight = createReduce(arrayReduceRight, baseEachRight);\n\n /**\n * The opposite of `_.filter`; this method returns the elements of `collection`\n * that `predicate` does **not** return truthy for.\n *\n * @static\n * @memberOf _\n * @category Collection\n * @param {Array|Object|string} collection The collection to iterate over.\n * @param {Function|Object|string} [predicate=_.identity] The function invoked\n * per iteration.\n * @param {*} [thisArg] The `this` binding of `predicate`.\n * @returns {Array} Returns the new filtered array.\n * @example\n *\n * _.reject([1, 2, 3, 4], function(n) {\n * return n % 2 == 0;\n * });\n * // => [1, 3]\n *\n * var users = [\n * { 'user': 'barney', 'age': 36, 'active': false },\n * { 'user': 'fred', 'age': 40, 'active': true }\n * ];\n *\n * // using the `_.matches` callback shorthand\n * _.pluck(_.reject(users, { 'age': 40, 'active': true }), 'user');\n * // => ['barney']\n *\n * // using the `_.matchesProperty` callback shorthand\n * _.pluck(_.reject(users, 'active', false), 'user');\n * // => ['fred']\n *\n * // using the `_.property` callback shorthand\n * _.pluck(_.reject(users, 'active'), 'user');\n * // => ['barney']\n */\n function reject(collection, predicate, thisArg) {\n var func = isArray(collection) ? arrayFilter : baseFilter;\n predicate = getCallback(predicate, thisArg, 3);\n return func(collection, function(value, index, collection) {\n return !predicate(value, index, collection);\n });\n }\n\n /**\n * Gets a random element or `n` random elements from a collection.\n *\n * @static\n * @memberOf _\n * @category Collection\n * @param {Array|Object|string} collection The collection to sample.\n * @param {number} [n] The number of elements to sample.\n * @param- {Object} [guard] Enables use as a callback for functions like `_.map`.\n * @returns {*} Returns the random sample(s).\n * @example\n *\n * _.sample([1, 2, 3, 4]);\n * // => 2\n *\n * _.sample([1, 2, 3, 4], 2);\n * // => [3, 1]\n */\n function sample(collection, n, guard) {\n if (guard ? isIterateeCall(collection, n, guard) : n == null) {\n collection = toIterable(collection);\n var length = collection.length;\n return length > 0 ? collection[baseRandom(0, length - 1)] : undefined;\n }\n var index = -1,\n result = toArray(collection),\n length = result.length,\n lastIndex = length - 1;\n\n n = nativeMin(n < 0 ? 0 : (+n || 0), length);\n while (++index < n) {\n var rand = baseRandom(index, lastIndex),\n value = result[rand];\n\n result[rand] = result[index];\n result[index] = value;\n }\n result.length = n;\n return result;\n }\n\n /**\n * Creates an array of shuffled values, using a version of the\n * [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle).\n *\n * @static\n * @memberOf _\n * @category Collection\n * @param {Array|Object|string} collection The collection to shuffle.\n * @returns {Array} Returns the new shuffled array.\n * @example\n *\n * _.shuffle([1, 2, 3, 4]);\n * // => [4, 1, 3, 2]\n */\n function shuffle(collection) {\n return sample(collection, POSITIVE_INFINITY);\n }\n\n /**\n * Gets the size of `collection` by returning its length for array-like\n * values or the number of own enumerable properties for objects.\n *\n * @static\n * @memberOf _\n * @category Collection\n * @param {Array|Object|string} collection The collection to inspect.\n * @returns {number} Returns the size of `collection`.\n * @example\n *\n * _.size([1, 2, 3]);\n * // => 3\n *\n * _.size({ 'a': 1, 'b': 2 });\n * // => 2\n *\n * _.size('pebbles');\n * // => 7\n */\n function size(collection) {\n var length = collection ? getLength(collection) : 0;\n return isLength(length) ? length : keys(collection).length;\n }\n\n /**\n * Checks if `predicate` returns truthy for **any** element of `collection`.\n * The function returns as soon as it finds a passing value and does not iterate\n * over the entire collection. The predicate is bound to `thisArg` and invoked\n * with three arguments: (value, index|key, collection).\n *\n * If a property name is provided for `predicate` the created `_.property`\n * style callback returns the property value of the given element.\n *\n * If a value is also provided for `thisArg` the created `_.matchesProperty`\n * style callback returns `true` for elements that have a matching property\n * value, else `false`.\n *\n * If an object is provided for `predicate` the created `_.matches` style\n * callback returns `true` for elements that have the properties of the given\n * object, else `false`.\n *\n * @static\n * @memberOf _\n * @alias any\n * @category Collection\n * @param {Array|Object|string} collection The collection to iterate over.\n * @param {Function|Object|string} [predicate=_.identity] The function invoked\n * per iteration.\n * @param {*} [thisArg] The `this` binding of `predicate`.\n * @returns {boolean} Returns `true` if any element passes the predicate check,\n * else `false`.\n * @example\n *\n * _.some([null, 0, 'yes', false], Boolean);\n * // => true\n *\n * var users = [\n * { 'user': 'barney', 'active': true },\n * { 'user': 'fred', 'active': false }\n * ];\n *\n * // using the `_.matches` callback shorthand\n * _.some(users, { 'user': 'barney', 'active': false });\n * // => false\n *\n * // using the `_.matchesProperty` callback shorthand\n * _.some(users, 'active', false);\n * // => true\n *\n * // using the `_.property` callback shorthand\n * _.some(users, 'active');\n * // => true\n */\n function some(collection, predicate, thisArg) {\n var func = isArray(collection) ? arraySome : baseSome;\n if (thisArg && isIterateeCall(collection, predicate, thisArg)) {\n predicate = undefined;\n }\n if (typeof predicate != 'function' || thisArg !== undefined) {\n predicate = getCallback(predicate, thisArg, 3);\n }\n return func(collection, predicate);\n }\n\n /**\n * Creates an array of elements, sorted in ascending order by the results of\n * running each element in a collection through `iteratee`. This method performs\n * a stable sort, that is, it preserves the original sort order of equal elements.\n * The `iteratee` is bound to `thisArg` and invoked with three arguments:\n * (value, index|key, collection).\n *\n * If a property name is provided for `iteratee` the created `_.property`\n * style callback returns the property value of the given element.\n *\n * If a value is also provided for `thisArg` the created `_.matchesProperty`\n * style callback returns `true` for elements that have a matching property\n * value, else `false`.\n *\n * If an object is provided for `iteratee` the created `_.matches` style\n * callback returns `true` for elements that have the properties of the given\n * object, else `false`.\n *\n * @static\n * @memberOf _\n * @category Collection\n * @param {Array|Object|string} collection The collection to iterate over.\n * @param {Function|Object|string} [iteratee=_.identity] The function invoked\n * per iteration.\n * @param {*} [thisArg] The `this` binding of `iteratee`.\n * @returns {Array} Returns the new sorted array.\n * @example\n *\n * _.sortBy([1, 2, 3], function(n) {\n * return Math.sin(n);\n * });\n * // => [3, 1, 2]\n *\n * _.sortBy([1, 2, 3], function(n) {\n * return this.sin(n);\n * }, Math);\n * // => [3, 1, 2]\n *\n * var users = [\n * { 'user': 'fred' },\n * { 'user': 'pebbles' },\n * { 'user': 'barney' }\n * ];\n *\n * // using the `_.property` callback shorthand\n * _.pluck(_.sortBy(users, 'user'), 'user');\n * // => ['barney', 'fred', 'pebbles']\n */\n function sortBy(collection, iteratee, thisArg) {\n if (collection == null) {\n return [];\n }\n if (thisArg && isIterateeCall(collection, iteratee, thisArg)) {\n iteratee = undefined;\n }\n var index = -1;\n iteratee = getCallback(iteratee, thisArg, 3);\n\n var result = baseMap(collection, function(value, key, collection) {\n return { 'criteria': iteratee(value, key, collection), 'index': ++index, 'value': value };\n });\n return baseSortBy(result, compareAscending);\n }\n\n /**\n * This method is like `_.sortBy` except that it can sort by multiple iteratees\n * or property names.\n *\n * If a property name is provided for an iteratee the created `_.property`\n * style callback returns the property value of the given element.\n *\n * If an object is provided for an iteratee the created `_.matches` style\n * callback returns `true` for elements that have the properties of the given\n * object, else `false`.\n *\n * @static\n * @memberOf _\n * @category Collection\n * @param {Array|Object|string} collection The collection to iterate over.\n * @param {...(Function|Function[]|Object|Object[]|string|string[])} iteratees\n * The iteratees to sort by, specified as individual values or arrays of values.\n * @returns {Array} Returns the new sorted array.\n * @example\n *\n * var users = [\n * { 'user': 'fred', 'age': 48 },\n * { 'user': 'barney', 'age': 36 },\n * { 'user': 'fred', 'age': 42 },\n * { 'user': 'barney', 'age': 34 }\n * ];\n *\n * _.map(_.sortByAll(users, ['user', 'age']), _.values);\n * // => [['barney', 34], ['barney', 36], ['fred', 42], ['fred', 48]]\n *\n * _.map(_.sortByAll(users, 'user', function(chr) {\n * return Math.floor(chr.age / 10);\n * }), _.values);\n * // => [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 42]]\n */\n var sortByAll = restParam(function(collection, iteratees) {\n if (collection == null) {\n return [];\n }\n var guard = iteratees[2];\n if (guard && isIterateeCall(iteratees[0], iteratees[1], guard)) {\n iteratees.length = 1;\n }\n return baseSortByOrder(collection, baseFlatten(iteratees), []);\n });\n\n /**\n * This method is like `_.sortByAll` except that it allows specifying the\n * sort orders of the iteratees to sort by. If `orders` is unspecified, all\n * values are sorted in ascending order. Otherwise, a value is sorted in\n * ascending order if its corresponding order is \"asc\", and descending if \"desc\".\n *\n * If a property name is provided for an iteratee the created `_.property`\n * style callback returns the property value of the given element.\n *\n * If an object is provided for an iteratee the created `_.matches` style\n * callback returns `true` for elements that have the properties of the given\n * object, else `false`.\n *\n * @static\n * @memberOf _\n * @category Collection\n * @param {Array|Object|string} collection The collection to iterate over.\n * @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by.\n * @param {boolean[]} [orders] The sort orders of `iteratees`.\n * @param- {Object} [guard] Enables use as a callback for functions like `_.reduce`.\n * @returns {Array} Returns the new sorted array.\n * @example\n *\n * var users = [\n * { 'user': 'fred', 'age': 48 },\n * { 'user': 'barney', 'age': 34 },\n * { 'user': 'fred', 'age': 42 },\n * { 'user': 'barney', 'age': 36 }\n * ];\n *\n * // sort by `user` in ascending order and by `age` in descending order\n * _.map(_.sortByOrder(users, ['user', 'age'], ['asc', 'desc']), _.values);\n * // => [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 42]]\n */\n function sortByOrder(collection, iteratees, orders, guard) {\n if (collection == null) {\n return [];\n }\n if (guard && isIterateeCall(iteratees, orders, guard)) {\n orders = undefined;\n }\n if (!isArray(iteratees)) {\n iteratees = iteratees == null ? [] : [iteratees];\n }\n if (!isArray(orders)) {\n orders = orders == null ? [] : [orders];\n }\n return baseSortByOrder(collection, iteratees, orders);\n }\n\n /**\n * Performs a deep comparison between each element in `collection` and the\n * source object, returning an array of all elements that have equivalent\n * property values.\n *\n * **Note:** This method supports comparing arrays, booleans, `Date` objects,\n * numbers, `Object` objects, regexes, and strings. Objects are compared by\n * their own, not inherited, enumerable properties. For comparing a single\n * own or inherited property value see `_.matchesProperty`.\n *\n * @static\n * @memberOf _\n * @category Collection\n * @param {Array|Object|string} collection The collection to search.\n * @param {Object} source The object of property values to match.\n * @returns {Array} Returns the new filtered array.\n * @example\n *\n * var users = [\n * { 'user': 'barney', 'age': 36, 'active': false, 'pets': ['hoppy'] },\n * { 'user': 'fred', 'age': 40, 'active': true, 'pets': ['baby puss', 'dino'] }\n * ];\n *\n * _.pluck(_.where(users, { 'age': 36, 'active': false }), 'user');\n * // => ['barney']\n *\n * _.pluck(_.where(users, { 'pets': ['dino'] }), 'user');\n * // => ['fred']\n */\n function where(collection, source) {\n return filter(collection, baseMatches(source));\n }\n\n /*------------------------------------------------------------------------*/\n\n /**\n * Gets the number of milliseconds that have elapsed since the Unix epoch\n * (1 January 1970 00:00:00 UTC).\n *\n * @static\n * @memberOf _\n * @category Date\n * @example\n *\n * _.defer(function(stamp) {\n * console.log(_.now() - stamp);\n * }, _.now());\n * // => logs the number of milliseconds it took for the deferred function to be invoked\n */\n var now = nativeNow || function() {\n return new Date().getTime();\n };\n\n /*------------------------------------------------------------------------*/\n\n /**\n * The opposite of `_.before`; this method creates a function that invokes\n * `func` once it is called `n` or more times.\n *\n * @static\n * @memberOf _\n * @category Function\n * @param {number} n The number of calls before `func` is invoked.\n * @param {Function} func The function to restrict.\n * @returns {Function} Returns the new restricted function.\n * @example\n *\n * var saves = ['profile', 'settings'];\n *\n * var done = _.after(saves.length, function() {\n * console.log('done saving!');\n * });\n *\n * _.forEach(saves, function(type) {\n * asyncSave({ 'type': type, 'complete': done });\n * });\n * // => logs 'done saving!' after the two async saves have completed\n */\n function after(n, func) {\n if (typeof func != 'function') {\n if (typeof n == 'function') {\n var temp = n;\n n = func;\n func = temp;\n } else {\n throw new TypeError(FUNC_ERROR_TEXT);\n }\n }\n n = nativeIsFinite(n = +n) ? n : 0;\n return function() {\n if (--n < 1) {\n return func.apply(this, arguments);\n }\n };\n }\n\n /**\n * Creates a function that accepts up to `n` arguments ignoring any\n * additional arguments.\n *\n * @static\n * @memberOf _\n * @category Function\n * @param {Function} func The function to cap arguments for.\n * @param {number} [n=func.length] The arity cap.\n * @param- {Object} [guard] Enables use as a callback for functions like `_.map`.\n * @returns {Function} Returns the new function.\n * @example\n *\n * _.map(['6', '8', '10'], _.ary(parseInt, 1));\n * // => [6, 8, 10]\n */\n function ary(func, n, guard) {\n if (guard && isIterateeCall(func, n, guard)) {\n n = undefined;\n }\n n = (func && n == null) ? func.length : nativeMax(+n || 0, 0);\n return createWrapper(func, ARY_FLAG, undefined, undefined, undefined, undefined, n);\n }\n\n /**\n * Creates a function that invokes `func`, with the `this` binding and arguments\n * of the created function, while it is called less than `n` times. Subsequent\n * calls to the created function return the result of the last `func` invocation.\n *\n * @static\n * @memberOf _\n * @category Function\n * @param {number} n The number of calls at which `func` is no longer invoked.\n * @param {Function} func The function to restrict.\n * @returns {Function} Returns the new restricted function.\n * @example\n *\n * jQuery('#add').on('click', _.before(5, addContactToList));\n * // => allows adding up to 4 contacts to the list\n */\n function before(n, func) {\n var result;\n if (typeof func != 'function') {\n if (typeof n == 'function') {\n var temp = n;\n n = func;\n func = temp;\n } else {\n throw new TypeError(FUNC_ERROR_TEXT);\n }\n }\n return function() {\n if (--n > 0) {\n result = func.apply(this, arguments);\n }\n if (n <= 1) {\n func = undefined;\n }\n return result;\n };\n }\n\n /**\n * Creates a function that invokes `func` with the `this` binding of `thisArg`\n * and prepends any additional `_.bind` arguments to those provided to the\n * bound function.\n *\n * The `_.bind.placeholder` value, which defaults to `_` in monolithic builds,\n * may be used as a placeholder for partially applied arguments.\n *\n * **Note:** Unlike native `Function#bind` this method does not set the \"length\"\n * property of bound functions.\n *\n * @static\n * @memberOf _\n * @category Function\n * @param {Function} func The function to bind.\n * @param {*} thisArg The `this` binding of `func`.\n * @param {...*} [partials] The arguments to be partially applied.\n * @returns {Function} Returns the new bound function.\n * @example\n *\n * var greet = function(greeting, punctuation) {\n * return greeting + ' ' + this.user + punctuation;\n * };\n *\n * var object = { 'user': 'fred' };\n *\n * var bound = _.bind(greet, object, 'hi');\n * bound('!');\n * // => 'hi fred!'\n *\n * // using placeholders\n * var bound = _.bind(greet, object, _, '!');\n * bound('hi');\n * // => 'hi fred!'\n */\n var bind = restParam(function(func, thisArg, partials) {\n var bitmask = BIND_FLAG;\n if (partials.length) {\n var holders = replaceHolders(partials, bind.placeholder);\n bitmask |= PARTIAL_FLAG;\n }\n return createWrapper(func, bitmask, thisArg, partials, holders);\n });\n\n /**\n * Binds methods of an object to the object itself, overwriting the existing\n * method. Method names may be specified as individual arguments or as arrays\n * of method names. If no method names are provided all enumerable function\n * properties, own and inherited, of `object` are bound.\n *\n * **Note:** This method does not set the \"length\" property of bound functions.\n *\n * @static\n * @memberOf _\n * @category Function\n * @param {Object} object The object to bind and assign the bound methods to.\n * @param {...(string|string[])} [methodNames] The object method names to bind,\n * specified as individual method names or arrays of method names.\n * @returns {Object} Returns `object`.\n * @example\n *\n * var view = {\n * 'label': 'docs',\n * 'onClick': function() {\n * console.log('clicked ' + this.label);\n * }\n * };\n *\n * _.bindAll(view);\n * jQuery('#docs').on('click', view.onClick);\n * // => logs 'clicked docs' when the element is clicked\n */\n var bindAll = restParam(function(object, methodNames) {\n methodNames = methodNames.length ? baseFlatten(methodNames) : functions(object);\n\n var index = -1,\n length = methodNames.length;\n\n while (++index < length) {\n var key = methodNames[index];\n object[key] = createWrapper(object[key], BIND_FLAG, object);\n }\n return object;\n });\n\n /**\n * Creates a function that invokes the method at `object[key]` and prepends\n * any additional `_.bindKey` arguments to those provided to the bound function.\n *\n * This method differs from `_.bind` by allowing bound functions to reference\n * methods that may be redefined or don't yet exist.\n * See [Peter Michaux's article](http://peter.michaux.ca/articles/lazy-function-definition-pattern)\n * for more details.\n *\n * The `_.bindKey.placeholder` value, which defaults to `_` in monolithic\n * builds, may be used as a placeholder for partially applied arguments.\n *\n * @static\n * @memberOf _\n * @category Function\n * @param {Object} object The object the method belongs to.\n * @param {string} key The key of the method.\n * @param {...*} [partials] The arguments to be partially applied.\n * @returns {Function} Returns the new bound function.\n * @example\n *\n * var object = {\n * 'user': 'fred',\n * 'greet': function(greeting, punctuation) {\n * return greeting + ' ' + this.user + punctuation;\n * }\n * };\n *\n * var bound = _.bindKey(object, 'greet', 'hi');\n * bound('!');\n * // => 'hi fred!'\n *\n * object.greet = function(greeting, punctuation) {\n * return greeting + 'ya ' + this.user + punctuation;\n * };\n *\n * bound('!');\n * // => 'hiya fred!'\n *\n * // using placeholders\n * var bound = _.bindKey(object, 'greet', _, '!');\n * bound('hi');\n * // => 'hiya fred!'\n */\n var bindKey = restParam(function(object, key, partials) {\n var bitmask = BIND_FLAG | BIND_KEY_FLAG;\n if (partials.length) {\n var holders = replaceHolders(partials, bindKey.placeholder);\n bitmask |= PARTIAL_FLAG;\n }\n return createWrapper(key, bitmask, object, partials, holders);\n });\n\n /**\n * Creates a function that accepts one or more arguments of `func` that when\n * called either invokes `func` returning its result, if all `func` arguments\n * have been provided, or returns a function that accepts one or more of the\n * remaining `func` arguments, and so on. The arity of `func` may be specified\n * if `func.length` is not sufficient.\n *\n * The `_.curry.placeholder` value, which defaults to `_` in monolithic builds,\n * may be used as a placeholder for provided arguments.\n *\n * **Note:** This method does not set the \"length\" property of curried functions.\n *\n * @static\n * @memberOf _\n * @category Function\n * @param {Function} func The function to curry.\n * @param {number} [arity=func.length] The arity of `func`.\n * @param- {Object} [guard] Enables use as a callback for functions like `_.map`.\n * @returns {Function} Returns the new curried function.\n * @example\n *\n * var abc = function(a, b, c) {\n * return [a, b, c];\n * };\n *\n * var curried = _.curry(abc);\n *\n * curried(1)(2)(3);\n * // => [1, 2, 3]\n *\n * curried(1, 2)(3);\n * // => [1, 2, 3]\n *\n * curried(1, 2, 3);\n * // => [1, 2, 3]\n *\n * // using placeholders\n * curried(1)(_, 3)(2);\n * // => [1, 2, 3]\n */\n var curry = createCurry(CURRY_FLAG);\n\n /**\n * This method is like `_.curry` except that arguments are applied to `func`\n * in the manner of `_.partialRight` instead of `_.partial`.\n *\n * The `_.curryRight.placeholder` value, which defaults to `_` in monolithic\n * builds, may be used as a placeholder for provided arguments.\n *\n * **Note:** This method does not set the \"length\" property of curried functions.\n *\n * @static\n * @memberOf _\n * @category Function\n * @param {Function} func The function to curry.\n * @param {number} [arity=func.length] The arity of `func`.\n * @param- {Object} [guard] Enables use as a callback for functions like `_.map`.\n * @returns {Function} Returns the new curried function.\n * @example\n *\n * var abc = function(a, b, c) {\n * return [a, b, c];\n * };\n *\n * var curried = _.curryRight(abc);\n *\n * curried(3)(2)(1);\n * // => [1, 2, 3]\n *\n * curried(2, 3)(1);\n * // => [1, 2, 3]\n *\n * curried(1, 2, 3);\n * // => [1, 2, 3]\n *\n * // using placeholders\n * curried(3)(1, _)(2);\n * // => [1, 2, 3]\n */\n var curryRight = createCurry(CURRY_RIGHT_FLAG);\n\n /**\n * Creates a debounced function that delays invoking `func` until after `wait`\n * milliseconds have elapsed since the last time the debounced function was\n * invoked. The debounced function comes with a `cancel` method to cancel\n * delayed invocations. Provide an options object to indicate that `func`\n * should be invoked on the leading and/or trailing edge of the `wait` timeout.\n * Subsequent calls to the debounced function return the result of the last\n * `func` invocation.\n *\n * **Note:** If `leading` and `trailing` options are `true`, `func` is invoked\n * on the trailing edge of the timeout only if the the debounced function is\n * invoked more than once during the `wait` timeout.\n *\n * See [David Corbacho's article](http://drupalmotion.com/article/debounce-and-throttle-visual-explanation)\n * for details over the differences between `_.debounce` and `_.throttle`.\n *\n * @static\n * @memberOf _\n * @category Function\n * @param {Function} func The function to debounce.\n * @param {number} [wait=0] The number of milliseconds to delay.\n * @param {Object} [options] The options object.\n * @param {boolean} [options.leading=false] Specify invoking on the leading\n * edge of the timeout.\n * @param {number} [options.maxWait] The maximum time `func` is allowed to be\n * delayed before it is invoked.\n * @param {boolean} [options.trailing=true] Specify invoking on the trailing\n * edge of the timeout.\n * @returns {Function} Returns the new debounced function.\n * @example\n *\n * // avoid costly calculations while the window size is in flux\n * jQuery(window).on('resize', _.debounce(calculateLayout, 150));\n *\n * // invoke `sendMail` when the click event is fired, debouncing subsequent calls\n * jQuery('#postbox').on('click', _.debounce(sendMail, 300, {\n * 'leading': true,\n * 'trailing': false\n * }));\n *\n * // ensure `batchLog` is invoked once after 1 second of debounced calls\n * var source = new EventSource('/stream');\n * jQuery(source).on('message', _.debounce(batchLog, 250, {\n * 'maxWait': 1000\n * }));\n *\n * // cancel a debounced call\n * var todoChanges = _.debounce(batchLog, 1000);\n * Object.observe(models.todo, todoChanges);\n *\n * Object.observe(models, function(changes) {\n * if (_.find(changes, { 'user': 'todo', 'type': 'delete'})) {\n * todoChanges.cancel();\n * }\n * }, ['delete']);\n *\n * // ...at some point `models.todo` is changed\n * models.todo.completed = true;\n *\n * // ...before 1 second has passed `models.todo` is deleted\n * // which cancels the debounced `todoChanges` call\n * delete models.todo;\n */\n function debounce(func, wait, options) {\n var args,\n maxTimeoutId,\n result,\n stamp,\n thisArg,\n timeoutId,\n trailingCall,\n lastCalled = 0,\n maxWait = false,\n trailing = true;\n\n if (typeof func != 'function') {\n throw new TypeError(FUNC_ERROR_TEXT);\n }\n wait = wait < 0 ? 0 : (+wait || 0);\n if (options === true) {\n var leading = true;\n trailing = false;\n } else if (isObject(options)) {\n leading = !!options.leading;\n maxWait = 'maxWait' in options && nativeMax(+options.maxWait || 0, wait);\n trailing = 'trailing' in options ? !!options.trailing : trailing;\n }\n\n function cancel() {\n if (timeoutId) {\n clearTimeout(timeoutId);\n }\n if (maxTimeoutId) {\n clearTimeout(maxTimeoutId);\n }\n lastCalled = 0;\n maxTimeoutId = timeoutId = trailingCall = undefined;\n }\n\n function complete(isCalled, id) {\n if (id) {\n clearTimeout(id);\n }\n maxTimeoutId = timeoutId = trailingCall = undefined;\n if (isCalled) {\n lastCalled = now();\n result = func.apply(thisArg, args);\n if (!timeoutId && !maxTimeoutId) {\n args = thisArg = undefined;\n }\n }\n }\n\n function delayed() {\n var remaining = wait - (now() - stamp);\n if (remaining <= 0 || remaining > wait) {\n complete(trailingCall, maxTimeoutId);\n } else {\n timeoutId = setTimeout(delayed, remaining);\n }\n }\n\n function maxDelayed() {\n complete(trailing, timeoutId);\n }\n\n function debounced() {\n args = arguments;\n stamp = now();\n thisArg = this;\n trailingCall = trailing && (timeoutId || !leading);\n\n if (maxWait === false) {\n var leadingCall = leading && !timeoutId;\n } else {\n if (!maxTimeoutId && !leading) {\n lastCalled = stamp;\n }\n var remaining = maxWait - (stamp - lastCalled),\n isCalled = remaining <= 0 || remaining > maxWait;\n\n if (isCalled) {\n if (maxTimeoutId) {\n maxTimeoutId = clearTimeout(maxTimeoutId);\n }\n lastCalled = stamp;\n result = func.apply(thisArg, args);\n }\n else if (!maxTimeoutId) {\n maxTimeoutId = setTimeout(maxDelayed, remaining);\n }\n }\n if (isCalled && timeoutId) {\n timeoutId = clearTimeout(timeoutId);\n }\n else if (!timeoutId && wait !== maxWait) {\n timeoutId = setTimeout(delayed, wait);\n }\n if (leadingCall) {\n isCalled = true;\n result = func.apply(thisArg, args);\n }\n if (isCalled && !timeoutId && !maxTimeoutId) {\n args = thisArg = undefined;\n }\n return result;\n }\n debounced.cancel = cancel;\n return debounced;\n }\n\n /**\n * Defers invoking the `func` until the current call stack has cleared. Any\n * additional arguments are provided to `func` when it is invoked.\n *\n * @static\n * @memberOf _\n * @category Function\n * @param {Function} func The function to defer.\n * @param {...*} [args] The arguments to invoke the function with.\n * @returns {number} Returns the timer id.\n * @example\n *\n * _.defer(function(text) {\n * console.log(text);\n * }, 'deferred');\n * // logs 'deferred' after one or more milliseconds\n */\n var defer = restParam(function(func, args) {\n return baseDelay(func, 1, args);\n });\n\n /**\n * Invokes `func` after `wait` milliseconds. Any additional arguments are\n * provided to `func` when it is invoked.\n *\n * @static\n * @memberOf _\n * @category Function\n * @param {Function} func The function to delay.\n * @param {number} wait The number of milliseconds to delay invocation.\n * @param {...*} [args] The arguments to invoke the function with.\n * @returns {number} Returns the timer id.\n * @example\n *\n * _.delay(function(text) {\n * console.log(text);\n * }, 1000, 'later');\n * // => logs 'later' after one second\n */\n var delay = restParam(function(func, wait, args) {\n return baseDelay(func, wait, args);\n });\n\n /**\n * Creates a function that returns the result of invoking the provided\n * functions with the `this` binding of the created function, where each\n * successive invocation is supplied the return value of the previous.\n *\n * @static\n * @memberOf _\n * @category Function\n * @param {...Function} [funcs] Functions to invoke.\n * @returns {Function} Returns the new function.\n * @example\n *\n * function square(n) {\n * return n * n;\n * }\n *\n * var addSquare = _.flow(_.add, square);\n * addSquare(1, 2);\n * // => 9\n */\n var flow = createFlow();\n\n /**\n * This method is like `_.flow` except that it creates a function that\n * invokes the provided functions from right to left.\n *\n * @static\n * @memberOf _\n * @alias backflow, compose\n * @category Function\n * @param {...Function} [funcs] Functions to invoke.\n * @returns {Function} Returns the new function.\n * @example\n *\n * function square(n) {\n * return n * n;\n * }\n *\n * var addSquare = _.flowRight(square, _.add);\n * addSquare(1, 2);\n * // => 9\n */\n var flowRight = createFlow(true);\n\n /**\n * Creates a function that memoizes the result of `func`. If `resolver` is\n * provided it determines the cache key for storing the result based on the\n * arguments provided to the memoized function. By default, the first argument\n * provided to the memoized function is coerced to a string and used as the\n * cache key. The `func` is invoked with the `this` binding of the memoized\n * function.\n *\n * **Note:** The cache is exposed as the `cache` property on the memoized\n * function. Its creation may be customized by replacing the `_.memoize.Cache`\n * constructor with one whose instances implement the [`Map`](http://ecma-international.org/ecma-262/6.0/#sec-properties-of-the-map-prototype-object)\n * method interface of `get`, `has`, and `set`.\n *\n * @static\n * @memberOf _\n * @category Function\n * @param {Function} func The function to have its output memoized.\n * @param {Function} [resolver] The function to resolve the cache key.\n * @returns {Function} Returns the new memoizing function.\n * @example\n *\n * var upperCase = _.memoize(function(string) {\n * return string.toUpperCase();\n * });\n *\n * upperCase('fred');\n * // => 'FRED'\n *\n * // modifying the result cache\n * upperCase.cache.set('fred', 'BARNEY');\n * upperCase('fred');\n * // => 'BARNEY'\n *\n * // replacing `_.memoize.Cache`\n * var object = { 'user': 'fred' };\n * var other = { 'user': 'barney' };\n * var identity = _.memoize(_.identity);\n *\n * identity(object);\n * // => { 'user': 'fred' }\n * identity(other);\n * // => { 'user': 'fred' }\n *\n * _.memoize.Cache = WeakMap;\n * var identity = _.memoize(_.identity);\n *\n * identity(object);\n * // => { 'user': 'fred' }\n * identity(other);\n * // => { 'user': 'barney' }\n */\n function memoize(func, resolver) {\n if (typeof func != 'function' || (resolver && typeof resolver != 'function')) {\n throw new TypeError(FUNC_ERROR_TEXT);\n }\n var memoized = function() {\n var args = arguments,\n key = resolver ? resolver.apply(this, args) : args[0],\n cache = memoized.cache;\n\n if (cache.has(key)) {\n return cache.get(key);\n }\n var result = func.apply(this, args);\n memoized.cache = cache.set(key, result);\n return result;\n };\n memoized.cache = new memoize.Cache;\n return memoized;\n }\n\n /**\n * Creates a function that runs each argument through a corresponding\n * transform function.\n *\n * @static\n * @memberOf _\n * @category Function\n * @param {Function} func The function to wrap.\n * @param {...(Function|Function[])} [transforms] The functions to transform\n * arguments, specified as individual functions or arrays of functions.\n * @returns {Function} Returns the new function.\n * @example\n *\n * function doubled(n) {\n * return n * 2;\n * }\n *\n * function square(n) {\n * return n * n;\n * }\n *\n * var modded = _.modArgs(function(x, y) {\n * return [x, y];\n * }, square, doubled);\n *\n * modded(1, 2);\n * // => [1, 4]\n *\n * modded(5, 10);\n * // => [25, 20]\n */\n var modArgs = restParam(function(func, transforms) {\n transforms = baseFlatten(transforms);\n if (typeof func != 'function' || !arrayEvery(transforms, baseIsFunction)) {\n throw new TypeError(FUNC_ERROR_TEXT);\n }\n var length = transforms.length;\n return restParam(function(args) {\n var index = nativeMin(args.length, length);\n while (index--) {\n args[index] = transforms[index](args[index]);\n }\n return func.apply(this, args);\n });\n });\n\n /**\n * Creates a function that negates the result of the predicate `func`. The\n * `func` predicate is invoked with the `this` binding and arguments of the\n * created function.\n *\n * @static\n * @memberOf _\n * @category Function\n * @param {Function} predicate The predicate to negate.\n * @returns {Function} Returns the new function.\n * @example\n *\n * function isEven(n) {\n * return n % 2 == 0;\n * }\n *\n * _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven));\n * // => [1, 3, 5]\n */\n function negate(predicate) {\n if (typeof predicate != 'function') {\n throw new TypeError(FUNC_ERROR_TEXT);\n }\n return function() {\n return !predicate.apply(this, arguments);\n };\n }\n\n /**\n * Creates a function that is restricted to invoking `func` once. Repeat calls\n * to the function return the value of the first call. The `func` is invoked\n * with the `this` binding and arguments of the created function.\n *\n * @static\n * @memberOf _\n * @category Function\n * @param {Function} func The function to restrict.\n * @returns {Function} Returns the new restricted function.\n * @example\n *\n * var initialize = _.once(createApplication);\n * initialize();\n * initialize();\n * // `initialize` invokes `createApplication` once\n */\n function once(func) {\n return before(2, func);\n }\n\n /**\n * Creates a function that invokes `func` with `partial` arguments prepended\n * to those provided to the new function. This method is like `_.bind` except\n * it does **not** alter the `this` binding.\n *\n * The `_.partial.placeholder` value, which defaults to `_` in monolithic\n * builds, may be used as a placeholder for partially applied arguments.\n *\n * **Note:** This method does not set the \"length\" property of partially\n * applied functions.\n *\n * @static\n * @memberOf _\n * @category Function\n * @param {Function} func The function to partially apply arguments to.\n * @param {...*} [partials] The arguments to be partially applied.\n * @returns {Function} Returns the new partially applied function.\n * @example\n *\n * var greet = function(greeting, name) {\n * return greeting + ' ' + name;\n * };\n *\n * var sayHelloTo = _.partial(greet, 'hello');\n * sayHelloTo('fred');\n * // => 'hello fred'\n *\n * // using placeholders\n * var greetFred = _.partial(greet, _, 'fred');\n * greetFred('hi');\n * // => 'hi fred'\n */\n var partial = createPartial(PARTIAL_FLAG);\n\n /**\n * This method is like `_.partial` except that partially applied arguments\n * are appended to those provided to the new function.\n *\n * The `_.partialRight.placeholder` value, which defaults to `_` in monolithic\n * builds, may be used as a placeholder for partially applied arguments.\n *\n * **Note:** This method does not set the \"length\" property of partially\n * applied functions.\n *\n * @static\n * @memberOf _\n * @category Function\n * @param {Function} func The function to partially apply arguments to.\n * @param {...*} [partials] The arguments to be partially applied.\n * @returns {Function} Returns the new partially applied function.\n * @example\n *\n * var greet = function(greeting, name) {\n * return greeting + ' ' + name;\n * };\n *\n * var greetFred = _.partialRight(greet, 'fred');\n * greetFred('hi');\n * // => 'hi fred'\n *\n * // using placeholders\n * var sayHelloTo = _.partialRight(greet, 'hello', _);\n * sayHelloTo('fred');\n * // => 'hello fred'\n */\n var partialRight = createPartial(PARTIAL_RIGHT_FLAG);\n\n /**\n * Creates a function that invokes `func` with arguments arranged according\n * to the specified indexes where the argument value at the first index is\n * provided as the first argument, the argument value at the second index is\n * provided as the second argument, and so on.\n *\n * @static\n * @memberOf _\n * @category Function\n * @param {Function} func The function to rearrange arguments for.\n * @param {...(number|number[])} indexes The arranged argument indexes,\n * specified as individual indexes or arrays of indexes.\n * @returns {Function} Returns the new function.\n * @example\n *\n * var rearged = _.rearg(function(a, b, c) {\n * return [a, b, c];\n * }, 2, 0, 1);\n *\n * rearged('b', 'c', 'a')\n * // => ['a', 'b', 'c']\n *\n * var map = _.rearg(_.map, [1, 0]);\n * map(function(n) {\n * return n * 3;\n * }, [1, 2, 3]);\n * // => [3, 6, 9]\n */\n var rearg = restParam(function(func, indexes) {\n return createWrapper(func, REARG_FLAG, undefined, undefined, undefined, baseFlatten(indexes));\n });\n\n /**\n * Creates a function that invokes `func` with the `this` binding of the\n * created function and arguments from `start` and beyond provided as an array.\n *\n * **Note:** This method is based on the [rest parameter](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/rest_parameters).\n *\n * @static\n * @memberOf _\n * @category Function\n * @param {Function} func The function to apply a rest parameter to.\n * @param {number} [start=func.length-1] The start position of the rest parameter.\n * @returns {Function} Returns the new function.\n * @example\n *\n * var say = _.restParam(function(what, names) {\n * return what + ' ' + _.initial(names).join(', ') +\n * (_.size(names) > 1 ? ', & ' : '') + _.last(names);\n * });\n *\n * say('hello', 'fred', 'barney', 'pebbles');\n * // => 'hello fred, barney, & pebbles'\n */\n function restParam(func, start) {\n if (typeof func != 'function') {\n throw new TypeError(FUNC_ERROR_TEXT);\n }\n start = nativeMax(start === undefined ? (func.length - 1) : (+start || 0), 0);\n return function() {\n var args = arguments,\n index = -1,\n length = nativeMax(args.length - start, 0),\n rest = Array(length);\n\n while (++index < length) {\n rest[index] = args[start + index];\n }\n switch (start) {\n case 0: return func.call(this, rest);\n case 1: return func.call(this, args[0], rest);\n case 2: return func.call(this, args[0], args[1], rest);\n }\n var otherArgs = Array(start + 1);\n index = -1;\n while (++index < start) {\n otherArgs[index] = args[index];\n }\n otherArgs[start] = rest;\n return func.apply(this, otherArgs);\n };\n }\n\n /**\n * Creates a function that invokes `func` with the `this` binding of the created\n * function and an array of arguments much like [`Function#apply`](https://es5.github.io/#x15.3.4.3).\n *\n * **Note:** This method is based on the [spread operator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_operator).\n *\n * @static\n * @memberOf _\n * @category Function\n * @param {Function} func The function to spread arguments over.\n * @returns {Function} Returns the new function.\n * @example\n *\n * var say = _.spread(function(who, what) {\n * return who + ' says ' + what;\n * });\n *\n * say(['fred', 'hello']);\n * // => 'fred says hello'\n *\n * // with a Promise\n * var numbers = Promise.all([\n * Promise.resolve(40),\n * Promise.resolve(36)\n * ]);\n *\n * numbers.then(_.spread(function(x, y) {\n * return x + y;\n * }));\n * // => a Promise of 76\n */\n function spread(func) {\n if (typeof func != 'function') {\n throw new TypeError(FUNC_ERROR_TEXT);\n }\n return function(array) {\n return func.apply(this, array);\n };\n }\n\n /**\n * Creates a throttled function that only invokes `func` at most once per\n * every `wait` milliseconds. The throttled function comes with a `cancel`\n * method to cancel delayed invocations. Provide an options object to indicate\n * that `func` should be invoked on the leading and/or trailing edge of the\n * `wait` timeout. Subsequent calls to the throttled function return the\n * result of the last `func` call.\n *\n * **Note:** If `leading` and `trailing` options are `true`, `func` is invoked\n * on the trailing edge of the timeout only if the the throttled function is\n * invoked more than once during the `wait` timeout.\n *\n * See [David Corbacho's article](http://drupalmotion.com/article/debounce-and-throttle-visual-explanation)\n * for details over the differences between `_.throttle` and `_.debounce`.\n *\n * @static\n * @memberOf _\n * @category Function\n * @param {Function} func The function to throttle.\n * @param {number} [wait=0] The number of milliseconds to throttle invocations to.\n * @param {Object} [options] The options object.\n * @param {boolean} [options.leading=true] Specify invoking on the leading\n * edge of the timeout.\n * @param {boolean} [options.trailing=true] Specify invoking on the trailing\n * edge of the timeout.\n * @returns {Function} Returns the new throttled function.\n * @example\n *\n * // avoid excessively updating the position while scrolling\n * jQuery(window).on('scroll', _.throttle(updatePosition, 100));\n *\n * // invoke `renewToken` when the click event is fired, but not more than once every 5 minutes\n * jQuery('.interactive').on('click', _.throttle(renewToken, 300000, {\n * 'trailing': false\n * }));\n *\n * // cancel a trailing throttled call\n * jQuery(window).on('popstate', throttled.cancel);\n */\n function throttle(func, wait, options) {\n var leading = true,\n trailing = true;\n\n if (typeof func != 'function') {\n throw new TypeError(FUNC_ERROR_TEXT);\n }\n if (options === false) {\n leading = false;\n } else if (isObject(options)) {\n leading = 'leading' in options ? !!options.leading : leading;\n trailing = 'trailing' in options ? !!options.trailing : trailing;\n }\n return debounce(func, wait, { 'leading': leading, 'maxWait': +wait, 'trailing': trailing });\n }\n\n /**\n * Creates a function that provides `value` to the wrapper function as its\n * first argument. Any additional arguments provided to the function are\n * appended to those provided to the wrapper function. The wrapper is invoked\n * with the `this` binding of the created function.\n *\n * @static\n * @memberOf _\n * @category Function\n * @param {*} value The value to wrap.\n * @param {Function} wrapper The wrapper function.\n * @returns {Function} Returns the new function.\n * @example\n *\n * var p = _.wrap(_.escape, function(func, text) {\n * return '<p>' + func(text) + '</p>';\n * });\n *\n * p('fred, barney, & pebbles');\n * // => '<p>fred, barney, &amp; pebbles</p>'\n */\n function wrap(value, wrapper) {\n wrapper = wrapper == null ? identity : wrapper;\n return createWrapper(wrapper, PARTIAL_FLAG, undefined, [value], []);\n }\n\n /*------------------------------------------------------------------------*/\n\n /**\n * Creates a clone of `value`. If `isDeep` is `true` nested objects are cloned,\n * otherwise they are assigned by reference. If `customizer` is provided it is\n * invoked to produce the cloned values. If `customizer` returns `undefined`\n * cloning is handled by the method instead. The `customizer` is bound to\n * `thisArg` and invoked with two argument; (value [, index|key, object]).\n *\n * **Note:** This method is loosely based on the\n * [structured clone algorithm](http://www.w3.org/TR/html5/infrastructure.html#internal-structured-cloning-algorithm).\n * The enumerable properties of `arguments` objects and objects created by\n * constructors other than `Object` are cloned to plain `Object` objects. An\n * empty object is returned for uncloneable values such as functions, DOM nodes,\n * Maps, Sets, and WeakMaps.\n *\n * @static\n * @memberOf _\n * @category Lang\n * @param {*} value The value to clone.\n * @param {boolean} [isDeep] Specify a deep clone.\n * @param {Function} [customizer] The function to customize cloning values.\n * @param {*} [thisArg] The `this` binding of `customizer`.\n * @returns {*} Returns the cloned value.\n * @example\n *\n * var users = [\n * { 'user': 'barney' },\n * { 'user': 'fred' }\n * ];\n *\n * var shallow = _.clone(users);\n * shallow[0] === users[0];\n * // => true\n *\n * var deep = _.clone(users, true);\n * deep[0] === users[0];\n * // => false\n *\n * // using a customizer callback\n * var el = _.clone(document.body, function(value) {\n * if (_.isElement(value)) {\n * return value.cloneNode(false);\n * }\n * });\n *\n * el === document.body\n * // => false\n * el.nodeName\n * // => BODY\n * el.childNodes.length;\n * // => 0\n */\n function clone(value, isDeep, customizer, thisArg) {\n if (isDeep && typeof isDeep != 'boolean' && isIterateeCall(value, isDeep, customizer)) {\n isDeep = false;\n }\n else if (typeof isDeep == 'function') {\n thisArg = customizer;\n customizer = isDeep;\n isDeep = false;\n }\n return typeof customizer == 'function'\n ? baseClone(value, isDeep, bindCallback(customizer, thisArg, 1))\n : baseClone(value, isDeep);\n }\n\n /**\n * Creates a deep clone of `value`. If `customizer` is provided it is invoked\n * to produce the cloned values. If `customizer` returns `undefined` cloning\n * is handled by the method instead. The `customizer` is bound to `thisArg`\n * and invoked with two argument; (value [, index|key, object]).\n *\n * **Note:** This method is loosely based on the\n * [structured clone algorithm](http://www.w3.org/TR/html5/infrastructure.html#internal-structured-cloning-algorithm).\n * The enumerable properties of `arguments` objects and objects created by\n * constructors other than `Object` are cloned to plain `Object` objects. An\n * empty object is returned for uncloneable values such as functions, DOM nodes,\n * Maps, Sets, and WeakMaps.\n *\n * @static\n * @memberOf _\n * @category Lang\n * @param {*} value The value to deep clone.\n * @param {Function} [customizer] The function to customize cloning values.\n * @param {*} [thisArg] The `this` binding of `customizer`.\n * @returns {*} Returns the deep cloned value.\n * @example\n *\n * var users = [\n * { 'user': 'barney' },\n * { 'user': 'fred' }\n * ];\n *\n * var deep = _.cloneDeep(users);\n * deep[0] === users[0];\n * // => false\n *\n * // using a customizer callback\n * var el = _.cloneDeep(document.body, function(value) {\n * if (_.isElement(value)) {\n * return value.cloneNode(true);\n * }\n * });\n *\n * el === document.body\n * // => false\n * el.nodeName\n * // => BODY\n * el.childNodes.length;\n * // => 20\n */\n function cloneDeep(value, customizer, thisArg) {\n return typeof customizer == 'function'\n ? baseClone(value, true, bindCallback(customizer, thisArg, 1))\n : baseClone(value, true);\n }\n\n /**\n * Checks if `value` is greater than `other`.\n *\n * @static\n * @memberOf _\n * @category Lang\n * @param {*} value The value to compare.\n * @param {*} other The other value to compare.\n * @returns {boolean} Returns `true` if `value` is greater than `other`, else `false`.\n * @example\n *\n * _.gt(3, 1);\n * // => true\n *\n * _.gt(3, 3);\n * // => false\n *\n * _.gt(1, 3);\n * // => false\n */\n function gt(value, other) {\n return value > other;\n }\n\n /**\n * Checks if `value` is greater than or equal to `other`.\n *\n * @static\n * @memberOf _\n * @category Lang\n * @param {*} value The value to compare.\n * @param {*} other The other value to compare.\n * @returns {boolean} Returns `true` if `value` is greater than or equal to `other`, else `false`.\n * @example\n *\n * _.gte(3, 1);\n * // => true\n *\n * _.gte(3, 3);\n * // => true\n *\n * _.gte(1, 3);\n * // => false\n */\n function gte(value, other) {\n return value >= other;\n }\n\n /**\n * Checks if `value` is classified as an `arguments` object.\n *\n * @static\n * @memberOf _\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.\n * @example\n *\n * _.isArguments(function() { return arguments; }());\n * // => true\n *\n * _.isArguments([1, 2, 3]);\n * // => false\n */\n function isArguments(value) {\n return isObjectLike(value) && isArrayLike(value) &&\n hasOwnProperty.call(value, 'callee') && !propertyIsEnumerable.call(value, 'callee');\n }\n\n /**\n * Checks if `value` is classified as an `Array` object.\n *\n * @static\n * @memberOf _\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.\n * @example\n *\n * _.isArray([1, 2, 3]);\n * // => true\n *\n * _.isArray(function() { return arguments; }());\n * // => false\n */\n var isArray = nativeIsArray || function(value) {\n return isObjectLike(value) && isLength(value.length) && objToString.call(value) == arrayTag;\n };\n\n /**\n * Checks if `value` is classified as a boolean primitive or object.\n *\n * @static\n * @memberOf _\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.\n * @example\n *\n * _.isBoolean(false);\n * // => true\n *\n * _.isBoolean(null);\n * // => false\n */\n function isBoolean(value) {\n return value === true || value === false || (isObjectLike(value) && objToString.call(value) == boolTag);\n }\n\n /**\n * Checks if `value` is classified as a `Date` object.\n *\n * @static\n * @memberOf _\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.\n * @example\n *\n * _.isDate(new Date);\n * // => true\n *\n * _.isDate('Mon April 23 2012');\n * // => false\n */\n function isDate(value) {\n return isObjectLike(value) && objToString.call(value) == dateTag;\n }\n\n /**\n * Checks if `value` is a DOM element.\n *\n * @static\n * @memberOf _\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a DOM element, else `false`.\n * @example\n *\n * _.isElement(document.body);\n * // => true\n *\n * _.isElement('<body>');\n * // => false\n */\n function isElement(value) {\n return !!value && value.nodeType === 1 && isObjectLike(value) && !isPlainObject(value);\n }\n\n /**\n * Checks if `value` is empty. A value is considered empty unless it is an\n * `arguments` object, array, string, or jQuery-like collection with a length\n * greater than `0` or an object with own enumerable properties.\n *\n * @static\n * @memberOf _\n * @category Lang\n * @param {Array|Object|string} value The value to inspect.\n * @returns {boolean} Returns `true` if `value` is empty, else `false`.\n * @example\n *\n * _.isEmpty(null);\n * // => true\n *\n * _.isEmpty(true);\n * // => true\n *\n * _.isEmpty(1);\n * // => true\n *\n * _.isEmpty([1, 2, 3]);\n * // => false\n *\n * _.isEmpty({ 'a': 1 });\n * // => false\n */\n function isEmpty(value) {\n if (value == null) {\n return true;\n }\n if (isArrayLike(value) && (isArray(value) || isString(value) || isArguments(value) ||\n (isObjectLike(value) && isFunction(value.splice)))) {\n return !value.length;\n }\n return !keys(value).length;\n }\n\n /**\n * Performs a deep comparison between two values to determine if they are\n * equivalent. If `customizer` is provided it is invoked to compare values.\n * If `customizer` returns `undefined` comparisons are handled by the method\n * instead. The `customizer` is bound to `thisArg` and invoked with three\n * arguments: (value, other [, index|key]).\n *\n * **Note:** This method supports comparing arrays, booleans, `Date` objects,\n * numbers, `Object` objects, regexes, and strings. Objects are compared by\n * their own, not inherited, enumerable properties. Functions and DOM nodes\n * are **not** supported. Provide a customizer function to extend support\n * for comparing other values.\n *\n * @static\n * @memberOf _\n * @alias eq\n * @category Lang\n * @param {*} value The value to compare.\n * @param {*} other The other value to compare.\n * @param {Function} [customizer] The function to customize value comparisons.\n * @param {*} [thisArg] The `this` binding of `customizer`.\n * @returns {boolean} Returns `true` if the values are equivalent, else `false`.\n * @example\n *\n * var object = { 'user': 'fred' };\n * var other = { 'user': 'fred' };\n *\n * object == other;\n * // => false\n *\n * _.isEqual(object, other);\n * // => true\n *\n * // using a customizer callback\n * var array = ['hello', 'goodbye'];\n * var other = ['hi', 'goodbye'];\n *\n * _.isEqual(array, other, function(value, other) {\n * if (_.every([value, other], RegExp.prototype.test, /^h(?:i|ello)$/)) {\n * return true;\n * }\n * });\n * // => true\n */\n function isEqual(value, other, customizer, thisArg) {\n customizer = typeof customizer == 'function' ? bindCallback(customizer, thisArg, 3) : undefined;\n var result = customizer ? customizer(value, other) : undefined;\n return result === undefined ? baseIsEqual(value, other, customizer) : !!result;\n }\n\n /**\n * Checks if `value` is an `Error`, `EvalError`, `RangeError`, `ReferenceError`,\n * `SyntaxError`, `TypeError`, or `URIError` object.\n *\n * @static\n * @memberOf _\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an error object, else `false`.\n * @example\n *\n * _.isError(new Error);\n * // => true\n *\n * _.isError(Error);\n * // => false\n */\n function isError(value) {\n return isObjectLike(value) && typeof value.message == 'string' && objToString.call(value) == errorTag;\n }\n\n /**\n * Checks if `value` is a finite primitive number.\n *\n * **Note:** This method is based on [`Number.isFinite`](http://ecma-international.org/ecma-262/6.0/#sec-number.isfinite).\n *\n * @static\n * @memberOf _\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a finite number, else `false`.\n * @example\n *\n * _.isFinite(10);\n * // => true\n *\n * _.isFinite('10');\n * // => false\n *\n * _.isFinite(true);\n * // => false\n *\n * _.isFinite(Object(10));\n * // => false\n *\n * _.isFinite(Infinity);\n * // => false\n */\n function isFinite(value) {\n return typeof value == 'number' && nativeIsFinite(value);\n }\n\n /**\n * Checks if `value` is classified as a `Function` object.\n *\n * @static\n * @memberOf _\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.\n * @example\n *\n * _.isFunction(_);\n * // => true\n *\n * _.isFunction(/abc/);\n * // => false\n */\n function isFunction(value) {\n // The use of `Object#toString` avoids issues with the `typeof` operator\n // in older versions of Chrome and Safari which return 'function' for regexes\n // and Safari 8 equivalents which return 'object' for typed array constructors.\n return isObject(value) && objToString.call(value) == funcTag;\n }\n\n /**\n * Checks if `value` is the [language type](https://es5.github.io/#x8) of `Object`.\n * (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)\n *\n * @static\n * @memberOf _\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an object, else `false`.\n * @example\n *\n * _.isObject({});\n * // => true\n *\n * _.isObject([1, 2, 3]);\n * // => true\n *\n * _.isObject(1);\n * // => false\n */\n function isObject(value) {\n // Avoid a V8 JIT bug in Chrome 19-20.\n // See https://code.google.com/p/v8/issues/detail?id=2291 for more details.\n var type = typeof value;\n return !!value && (type == 'object' || type == 'function');\n }\n\n /**\n * Performs a deep comparison between `object` and `source` to determine if\n * `object` contains equivalent property values. If `customizer` is provided\n * it is invoked to compare values. If `customizer` returns `undefined`\n * comparisons are handled by the method instead. The `customizer` is bound\n * to `thisArg` and invoked with three arguments: (value, other, index|key).\n *\n * **Note:** This method supports comparing properties of arrays, booleans,\n * `Date` objects, numbers, `Object` objects, regexes, and strings. Functions\n * and DOM nodes are **not** supported. Provide a customizer function to extend\n * support for comparing other values.\n *\n * @static\n * @memberOf _\n * @category Lang\n * @param {Object} object The object to inspect.\n * @param {Object} source The object of property values to match.\n * @param {Function} [customizer] The function to customize value comparisons.\n * @param {*} [thisArg] The `this` binding of `customizer`.\n * @returns {boolean} Returns `true` if `object` is a match, else `false`.\n * @example\n *\n * var object = { 'user': 'fred', 'age': 40 };\n *\n * _.isMatch(object, { 'age': 40 });\n * // => true\n *\n * _.isMatch(object, { 'age': 36 });\n * // => false\n *\n * // using a customizer callback\n * var object = { 'greeting': 'hello' };\n * var source = { 'greeting': 'hi' };\n *\n * _.isMatch(object, source, function(value, other) {\n * return _.every([value, other], RegExp.prototype.test, /^h(?:i|ello)$/) || undefined;\n * });\n * // => true\n */\n function isMatch(object, source, customizer, thisArg) {\n customizer = typeof customizer == 'function' ? bindCallback(customizer, thisArg, 3) : undefined;\n return baseIsMatch(object, getMatchData(source), customizer);\n }\n\n /**\n * Checks if `value` is `NaN`.\n *\n * **Note:** This method is not the same as [`isNaN`](https://es5.github.io/#x15.1.2.4)\n * which returns `true` for `undefined` and other non-numeric values.\n *\n * @static\n * @memberOf _\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.\n * @example\n *\n * _.isNaN(NaN);\n * // => true\n *\n * _.isNaN(new Number(NaN));\n * // => true\n *\n * isNaN(undefined);\n * // => true\n *\n * _.isNaN(undefined);\n * // => false\n */\n function isNaN(value) {\n // An `NaN` primitive is the only value that is not equal to itself.\n // Perform the `toStringTag` check first to avoid errors with some host objects in IE.\n return isNumber(value) && value != +value;\n }\n\n /**\n * Checks if `value` is a native function.\n *\n * @static\n * @memberOf _\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a native function, else `false`.\n * @example\n *\n * _.isNative(Array.prototype.push);\n * // => true\n *\n * _.isNative(_);\n * // => false\n */\n function isNative(value) {\n if (value == null) {\n return false;\n }\n if (isFunction(value)) {\n return reIsNative.test(fnToString.call(value));\n }\n return isObjectLike(value) && reIsHostCtor.test(value);\n }\n\n /**\n * Checks if `value` is `null`.\n *\n * @static\n * @memberOf _\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is `null`, else `false`.\n * @example\n *\n * _.isNull(null);\n * // => true\n *\n * _.isNull(void 0);\n * // => false\n */\n function isNull(value) {\n return value === null;\n }\n\n /**\n * Checks if `value` is classified as a `Number` primitive or object.\n *\n * **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are classified\n * as numbers, use the `_.isFinite` method.\n *\n * @static\n * @memberOf _\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.\n * @example\n *\n * _.isNumber(8.4);\n * // => true\n *\n * _.isNumber(NaN);\n * // => true\n *\n * _.isNumber('8.4');\n * // => false\n */\n function isNumber(value) {\n return typeof value == 'number' || (isObjectLike(value) && objToString.call(value) == numberTag);\n }\n\n /**\n * Checks if `value` is a plain object, that is, an object created by the\n * `Object` constructor or one with a `[[Prototype]]` of `null`.\n *\n * **Note:** This method assumes objects created by the `Object` constructor\n * have no inherited enumerable properties.\n *\n * @static\n * @memberOf _\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.\n * @example\n *\n * function Foo() {\n * this.a = 1;\n * }\n *\n * _.isPlainObject(new Foo);\n * // => false\n *\n * _.isPlainObject([1, 2, 3]);\n * // => false\n *\n * _.isPlainObject({ 'x': 0, 'y': 0 });\n * // => true\n *\n * _.isPlainObject(Object.create(null));\n * // => true\n */\n function isPlainObject(value) {\n var Ctor;\n\n // Exit early for non `Object` objects.\n if (!(isObjectLike(value) && objToString.call(value) == objectTag && !isArguments(value)) ||\n (!hasOwnProperty.call(value, 'constructor') && (Ctor = value.constructor, typeof Ctor == 'function' && !(Ctor instanceof Ctor)))) {\n return false;\n }\n // IE < 9 iterates inherited properties before own properties. If the first\n // iterated property is an object's own property then there are no inherited\n // enumerable properties.\n var result;\n // In most environments an object's own properties are iterated before\n // its inherited properties. If the last iterated property is an object's\n // own property then there are no inherited enumerable properties.\n baseForIn(value, function(subValue, key) {\n result = key;\n });\n return result === undefined || hasOwnProperty.call(value, result);\n }\n\n /**\n * Checks if `value` is classified as a `RegExp` object.\n *\n * @static\n * @memberOf _\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.\n * @example\n *\n * _.isRegExp(/abc/);\n * // => true\n *\n * _.isRegExp('/abc/');\n * // => false\n */\n function isRegExp(value) {\n return isObject(value) && objToString.call(value) == regexpTag;\n }\n\n /**\n * Checks if `value` is classified as a `String` primitive or object.\n *\n * @static\n * @memberOf _\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.\n * @example\n *\n * _.isString('abc');\n * // => true\n *\n * _.isString(1);\n * // => false\n */\n function isString(value) {\n return typeof value == 'string' || (isObjectLike(value) && objToString.call(value) == stringTag);\n }\n\n /**\n * Checks if `value` is classified as a typed array.\n *\n * @static\n * @memberOf _\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.\n * @example\n *\n * _.isTypedArray(new Uint8Array);\n * // => true\n *\n * _.isTypedArray([]);\n * // => false\n */\n function isTypedArray(value) {\n return isObjectLike(value) && isLength(value.length) && !!typedArrayTags[objToString.call(value)];\n }\n\n /**\n * Checks if `value` is `undefined`.\n *\n * @static\n * @memberOf _\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`.\n * @example\n *\n * _.isUndefined(void 0);\n * // => true\n *\n * _.isUndefined(null);\n * // => false\n */\n function isUndefined(value) {\n return value === undefined;\n }\n\n /**\n * Checks if `value` is less than `other`.\n *\n * @static\n * @memberOf _\n * @category Lang\n * @param {*} value The value to compare.\n * @param {*} other The other value to compare.\n * @returns {boolean} Returns `true` if `value` is less than `other`, else `false`.\n * @example\n *\n * _.lt(1, 3);\n * // => true\n *\n * _.lt(3, 3);\n * // => false\n *\n * _.lt(3, 1);\n * // => false\n */\n function lt(value, other) {\n return value < other;\n }\n\n /**\n * Checks if `value` is less than or equal to `other`.\n *\n * @static\n * @memberOf _\n * @category Lang\n * @param {*} value The value to compare.\n * @param {*} other The other value to compare.\n * @returns {boolean} Returns `true` if `value` is less than or equal to `other`, else `false`.\n * @example\n *\n * _.lte(1, 3);\n * // => true\n *\n * _.lte(3, 3);\n * // => true\n *\n * _.lte(3, 1);\n * // => false\n */\n function lte(value, other) {\n return value <= other;\n }\n\n /**\n * Converts `value` to an array.\n *\n * @static\n * @memberOf _\n * @category Lang\n * @param {*} value The value to convert.\n * @returns {Array} Returns the converted array.\n * @example\n *\n * (function() {\n * return _.toArray(arguments).slice(1);\n * }(1, 2, 3));\n * // => [2, 3]\n */\n function toArray(value) {\n var length = value ? getLength(value) : 0;\n if (!isLength(length)) {\n return values(value);\n }\n if (!length) {\n return [];\n }\n return arrayCopy(value);\n }\n\n /**\n * Converts `value` to a plain object flattening inherited enumerable\n * properties of `value` to own properties of the plain object.\n *\n * @static\n * @memberOf _\n * @category Lang\n * @param {*} value The value to convert.\n * @returns {Object} Returns the converted plain object.\n * @example\n *\n * function Foo() {\n * this.b = 2;\n * }\n *\n * Foo.prototype.c = 3;\n *\n * _.assign({ 'a': 1 }, new Foo);\n * // => { 'a': 1, 'b': 2 }\n *\n * _.assign({ 'a': 1 }, _.toPlainObject(new Foo));\n * // => { 'a': 1, 'b': 2, 'c': 3 }\n */\n function toPlainObject(value) {\n return baseCopy(value, keysIn(value));\n }\n\n /*------------------------------------------------------------------------*/\n\n /**\n * Recursively merges own enumerable properties of the source object(s), that\n * don't resolve to `undefined` into the destination object. Subsequent sources\n * overwrite property assignments of previous sources. If `customizer` is\n * provided it is invoked to produce the merged values of the destination and\n * source properties. If `customizer` returns `undefined` merging is handled\n * by the method instead. The `customizer` is bound to `thisArg` and invoked\n * with five arguments: (objectValue, sourceValue, key, object, source).\n *\n * @static\n * @memberOf _\n * @category Object\n * @param {Object} object The destination object.\n * @param {...Object} [sources] The source objects.\n * @param {Function} [customizer] The function to customize assigned values.\n * @param {*} [thisArg] The `this` binding of `customizer`.\n * @returns {Object} Returns `object`.\n * @example\n *\n * var users = {\n * 'data': [{ 'user': 'barney' }, { 'user': 'fred' }]\n * };\n *\n * var ages = {\n * 'data': [{ 'age': 36 }, { 'age': 40 }]\n * };\n *\n * _.merge(users, ages);\n * // => { 'data': [{ 'user': 'barney', 'age': 36 }, { 'user': 'fred', 'age': 40 }] }\n *\n * // using a customizer callback\n * var object = {\n * 'fruits': ['apple'],\n * 'vegetables': ['beet']\n * };\n *\n * var other = {\n * 'fruits': ['banana'],\n * 'vegetables': ['carrot']\n * };\n *\n * _.merge(object, other, function(a, b) {\n * if (_.isArray(a)) {\n * return a.concat(b);\n * }\n * });\n * // => { 'fruits': ['apple', 'banana'], 'vegetables': ['beet', 'carrot'] }\n */\n var merge = createAssigner(baseMerge);\n\n /**\n * Assigns own enumerable properties of source object(s) to the destination\n * object. Subsequent sources overwrite property assignments of previous sources.\n * If `customizer` is provided it is invoked to produce the assigned values.\n * The `customizer` is bound to `thisArg` and invoked with five arguments:\n * (objectValue, sourceValue, key, object, source).\n *\n * **Note:** This method mutates `object` and is based on\n * [`Object.assign`](http://ecma-international.org/ecma-262/6.0/#sec-object.assign).\n *\n * @static\n * @memberOf _\n * @alias extend\n * @category Object\n * @param {Object} object The destination object.\n * @param {...Object} [sources] The source objects.\n * @param {Function} [customizer] The function to customize assigned values.\n * @param {*} [thisArg] The `this` binding of `customizer`.\n * @returns {Object} Returns `object`.\n * @example\n *\n * _.assign({ 'user': 'barney' }, { 'age': 40 }, { 'user': 'fred' });\n * // => { 'user': 'fred', 'age': 40 }\n *\n * // using a customizer callback\n * var defaults = _.partialRight(_.assign, function(value, other) {\n * return _.isUndefined(value) ? other : value;\n * });\n *\n * defaults({ 'user': 'barney' }, { 'age': 36 }, { 'user': 'fred' });\n * // => { 'user': 'barney', 'age': 36 }\n */\n var assign = createAssigner(function(object, source, customizer) {\n return customizer\n ? assignWith(object, source, customizer)\n : baseAssign(object, source);\n });\n\n /**\n * Creates an object that inherits from the given `prototype` object. If a\n * `properties` object is provided its own enumerable properties are assigned\n * to the created object.\n *\n * @static\n * @memberOf _\n * @category Object\n * @param {Object} prototype The object to inherit from.\n * @param {Object} [properties] The properties to assign to the object.\n * @param- {Object} [guard] Enables use as a callback for functions like `_.map`.\n * @returns {Object} Returns the new object.\n * @example\n *\n * function Shape() {\n * this.x = 0;\n * this.y = 0;\n * }\n *\n * function Circle() {\n * Shape.call(this);\n * }\n *\n * Circle.prototype = _.create(Shape.prototype, {\n * 'constructor': Circle\n * });\n *\n * var circle = new Circle;\n * circle instanceof Circle;\n * // => true\n *\n * circle instanceof Shape;\n * // => true\n */\n function create(prototype, properties, guard) {\n var result = baseCreate(prototype);\n if (guard && isIterateeCall(prototype, properties, guard)) {\n properties = undefined;\n }\n return properties ? baseAssign(result, properties) : result;\n }\n\n /**\n * Assigns own enumerable properties of source object(s) to the destination\n * object for all destination properties that resolve to `undefined`. Once a\n * property is set, additional values of the same property are ignored.\n *\n * **Note:** This method mutates `object`.\n *\n * @static\n * @memberOf _\n * @category Object\n * @param {Object} object The destination object.\n * @param {...Object} [sources] The source objects.\n * @returns {Object} Returns `object`.\n * @example\n *\n * _.defaults({ 'user': 'barney' }, { 'age': 36 }, { 'user': 'fred' });\n * // => { 'user': 'barney', 'age': 36 }\n */\n var defaults = createDefaults(assign, assignDefaults);\n\n /**\n * This method is like `_.defaults` except that it recursively assigns\n * default properties.\n *\n * **Note:** This method mutates `object`.\n *\n * @static\n * @memberOf _\n * @category Object\n * @param {Object} object The destination object.\n * @param {...Object} [sources] The source objects.\n * @returns {Object} Returns `object`.\n * @example\n *\n * _.defaultsDeep({ 'user': { 'name': 'barney' } }, { 'user': { 'name': 'fred', 'age': 36 } });\n * // => { 'user': { 'name': 'barney', 'age': 36 } }\n *\n */\n var defaultsDeep = createDefaults(merge, mergeDefaults);\n\n /**\n * This method is like `_.find` except that it returns the key of the first\n * element `predicate` returns truthy for instead of the element itself.\n *\n * If a property name is provided for `predicate` the created `_.property`\n * style callback returns the property value of the given element.\n *\n * If a value is also provided for `thisArg` the created `_.matchesProperty`\n * style callback returns `true` for elements that have a matching property\n * value, else `false`.\n *\n * If an object is provided for `predicate` the created `_.matches` style\n * callback returns `true` for elements that have the properties of the given\n * object, else `false`.\n *\n * @static\n * @memberOf _\n * @category Object\n * @param {Object} object The object to search.\n * @param {Function|Object|string} [predicate=_.identity] The function invoked\n * per iteration.\n * @param {*} [thisArg] The `this` binding of `predicate`.\n * @returns {string|undefined} Returns the key of the matched element, else `undefined`.\n * @example\n *\n * var users = {\n * 'barney': { 'age': 36, 'active': true },\n * 'fred': { 'age': 40, 'active': false },\n * 'pebbles': { 'age': 1, 'active': true }\n * };\n *\n * _.findKey(users, function(chr) {\n * return chr.age < 40;\n * });\n * // => 'barney' (iteration order is not guaranteed)\n *\n * // using the `_.matches` callback shorthand\n * _.findKey(users, { 'age': 1, 'active': true });\n * // => 'pebbles'\n *\n * // using the `_.matchesProperty` callback shorthand\n * _.findKey(users, 'active', false);\n * // => 'fred'\n *\n * // using the `_.property` callback shorthand\n * _.findKey(users, 'active');\n * // => 'barney'\n */\n var findKey = createFindKey(baseForOwn);\n\n /**\n * This method is like `_.findKey` except that it iterates over elements of\n * a collection in the opposite order.\n *\n * If a property name is provided for `predicate` the created `_.property`\n * style callback returns the property value of the given element.\n *\n * If a value is also provided for `thisArg` the created `_.matchesProperty`\n * style callback returns `true` for elements that have a matching property\n * value, else `false`.\n *\n * If an object is provided for `predicate` the created `_.matches` style\n * callback returns `true` for elements that have the properties of the given\n * object, else `false`.\n *\n * @static\n * @memberOf _\n * @category Object\n * @param {Object} object The object to search.\n * @param {Function|Object|string} [predicate=_.identity] The function invoked\n * per iteration.\n * @param {*} [thisArg] The `this` binding of `predicate`.\n * @returns {string|undefined} Returns the key of the matched element, else `undefined`.\n * @example\n *\n * var users = {\n * 'barney': { 'age': 36, 'active': true },\n * 'fred': { 'age': 40, 'active': false },\n * 'pebbles': { 'age': 1, 'active': true }\n * };\n *\n * _.findLastKey(users, function(chr) {\n * return chr.age < 40;\n * });\n * // => returns `pebbles` assuming `_.findKey` returns `barney`\n *\n * // using the `_.matches` callback shorthand\n * _.findLastKey(users, { 'age': 36, 'active': true });\n * // => 'barney'\n *\n * // using the `_.matchesProperty` callback shorthand\n * _.findLastKey(users, 'active', false);\n * // => 'fred'\n *\n * // using the `_.property` callback shorthand\n * _.findLastKey(users, 'active');\n * // => 'pebbles'\n */\n var findLastKey = createFindKey(baseForOwnRight);\n\n /**\n * Iterates over own and inherited enumerable properties of an object invoking\n * `iteratee` for each property. The `iteratee` is bound to `thisArg` and invoked\n * with three arguments: (value, key, object). Iteratee functions may exit\n * iteration early by explicitly returning `false`.\n *\n * @static\n * @memberOf _\n * @category Object\n * @param {Object} object The object to iterate over.\n * @param {Function} [iteratee=_.identity] The function invoked per iteration.\n * @param {*} [thisArg] The `this` binding of `iteratee`.\n * @returns {Object} Returns `object`.\n * @example\n *\n * function Foo() {\n * this.a = 1;\n * this.b = 2;\n * }\n *\n * Foo.prototype.c = 3;\n *\n * _.forIn(new Foo, function(value, key) {\n * console.log(key);\n * });\n * // => logs 'a', 'b', and 'c' (iteration order is not guaranteed)\n */\n var forIn = createForIn(baseFor);\n\n /**\n * This method is like `_.forIn` except that it iterates over properties of\n * `object` in the opposite order.\n *\n * @static\n * @memberOf _\n * @category Object\n * @param {Object} object The object to iterate over.\n * @param {Function} [iteratee=_.identity] The function invoked per iteration.\n * @param {*} [thisArg] The `this` binding of `iteratee`.\n * @returns {Object} Returns `object`.\n * @example\n *\n * function Foo() {\n * this.a = 1;\n * this.b = 2;\n * }\n *\n * Foo.prototype.c = 3;\n *\n * _.forInRight(new Foo, function(value, key) {\n * console.log(key);\n * });\n * // => logs 'c', 'b', and 'a' assuming `_.forIn ` logs 'a', 'b', and 'c'\n */\n var forInRight = createForIn(baseForRight);\n\n /**\n * Iterates over own enumerable properties of an object invoking `iteratee`\n * for each property. The `iteratee` is bound to `thisArg` and invoked with\n * three arguments: (value, key, object). Iteratee functions may exit iteration\n * early by explicitly returning `false`.\n *\n * @static\n * @memberOf _\n * @category Object\n * @param {Object} object The object to iterate over.\n * @param {Function} [iteratee=_.identity] The function invoked per iteration.\n * @param {*} [thisArg] The `this` binding of `iteratee`.\n * @returns {Object} Returns `object`.\n * @example\n *\n * function Foo() {\n * this.a = 1;\n * this.b = 2;\n * }\n *\n * Foo.prototype.c = 3;\n *\n * _.forOwn(new Foo, function(value, key) {\n * console.log(key);\n * });\n * // => logs 'a' and 'b' (iteration order is not guaranteed)\n */\n var forOwn = createForOwn(baseForOwn);\n\n /**\n * This method is like `_.forOwn` except that it iterates over properties of\n * `object` in the opposite order.\n *\n * @static\n * @memberOf _\n * @category Object\n * @param {Object} object The object to iterate over.\n * @param {Function} [iteratee=_.identity] The function invoked per iteration.\n * @param {*} [thisArg] The `this` binding of `iteratee`.\n * @returns {Object} Returns `object`.\n * @example\n *\n * function Foo() {\n * this.a = 1;\n * this.b = 2;\n * }\n *\n * Foo.prototype.c = 3;\n *\n * _.forOwnRight(new Foo, function(value, key) {\n * console.log(key);\n * });\n * // => logs 'b' and 'a' assuming `_.forOwn` logs 'a' and 'b'\n */\n var forOwnRight = createForOwn(baseForOwnRight);\n\n /**\n * Creates an array of function property names from all enumerable properties,\n * own and inherited, of `object`.\n *\n * @static\n * @memberOf _\n * @alias methods\n * @category Object\n * @param {Object} object The object to inspect.\n * @returns {Array} Returns the new array of property names.\n * @example\n *\n * _.functions(_);\n * // => ['after', 'ary', 'assign', ...]\n */\n function functions(object) {\n return baseFunctions(object, keysIn(object));\n }\n\n /**\n * Gets the property value at `path` of `object`. If the resolved value is\n * `undefined` the `defaultValue` is used in its place.\n *\n * @static\n * @memberOf _\n * @category Object\n * @param {Object} object The object to query.\n * @param {Array|string} path The path of the property to get.\n * @param {*} [defaultValue] The value returned if the resolved value is `undefined`.\n * @returns {*} Returns the resolved value.\n * @example\n *\n * var object = { 'a': [{ 'b': { 'c': 3 } }] };\n *\n * _.get(object, 'a[0].b.c');\n * // => 3\n *\n * _.get(object, ['a', '0', 'b', 'c']);\n * // => 3\n *\n * _.get(object, 'a.b.c', 'default');\n * // => 'default'\n */\n function get(object, path, defaultValue) {\n var result = object == null ? undefined : baseGet(object, toPath(path), path + '');\n return result === undefined ? defaultValue : result;\n }\n\n /**\n * Checks if `path` is a direct property.\n *\n * @static\n * @memberOf _\n * @category Object\n * @param {Object} object The object to query.\n * @param {Array|string} path The path to check.\n * @returns {boolean} Returns `true` if `path` is a direct property, else `false`.\n * @example\n *\n * var object = { 'a': { 'b': { 'c': 3 } } };\n *\n * _.has(object, 'a');\n * // => true\n *\n * _.has(object, 'a.b.c');\n * // => true\n *\n * _.has(object, ['a', 'b', 'c']);\n * // => true\n */\n function has(object, path) {\n if (object == null) {\n return false;\n }\n var result = hasOwnProperty.call(object, path);\n if (!result && !isKey(path)) {\n path = toPath(path);\n object = path.length == 1 ? object : baseGet(object, baseSlice(path, 0, -1));\n if (object == null) {\n return false;\n }\n path = last(path);\n result = hasOwnProperty.call(object, path);\n }\n return result || (isLength(object.length) && isIndex(path, object.length) &&\n (isArray(object) || isArguments(object)));\n }\n\n /**\n * Creates an object composed of the inverted keys and values of `object`.\n * If `object` contains duplicate values, subsequent values overwrite property\n * assignments of previous values unless `multiValue` is `true`.\n *\n * @static\n * @memberOf _\n * @category Object\n * @param {Object} object The object to invert.\n * @param {boolean} [multiValue] Allow multiple values per key.\n * @param- {Object} [guard] Enables use as a callback for functions like `_.map`.\n * @returns {Object} Returns the new inverted object.\n * @example\n *\n * var object = { 'a': 1, 'b': 2, 'c': 1 };\n *\n * _.invert(object);\n * // => { '1': 'c', '2': 'b' }\n *\n * // with `multiValue`\n * _.invert(object, true);\n * // => { '1': ['a', 'c'], '2': ['b'] }\n */\n function invert(object, multiValue, guard) {\n if (guard && isIterateeCall(object, multiValue, guard)) {\n multiValue = undefined;\n }\n var index = -1,\n props = keys(object),\n length = props.length,\n result = {};\n\n while (++index < length) {\n var key = props[index],\n value = object[key];\n\n if (multiValue) {\n if (hasOwnProperty.call(result, value)) {\n result[value].push(key);\n } else {\n result[value] = [key];\n }\n }\n else {\n result[value] = key;\n }\n }\n return result;\n }\n\n /**\n * Creates an array of the own enumerable property names of `object`.\n *\n * **Note:** Non-object values are coerced to objects. See the\n * [ES spec](http://ecma-international.org/ecma-262/6.0/#sec-object.keys)\n * for more details.\n *\n * @static\n * @memberOf _\n * @category Object\n * @param {Object} object The object to query.\n * @returns {Array} Returns the array of property names.\n * @example\n *\n * function Foo() {\n * this.a = 1;\n * this.b = 2;\n * }\n *\n * Foo.prototype.c = 3;\n *\n * _.keys(new Foo);\n * // => ['a', 'b'] (iteration order is not guaranteed)\n *\n * _.keys('hi');\n * // => ['0', '1']\n */\n var keys = !nativeKeys ? shimKeys : function(object) {\n var Ctor = object == null ? undefined : object.constructor;\n if ((typeof Ctor == 'function' && Ctor.prototype === object) ||\n (typeof object != 'function' && isArrayLike(object))) {\n return shimKeys(object);\n }\n return isObject(object) ? nativeKeys(object) : [];\n };\n\n /**\n * Creates an array of the own and inherited enumerable property names of `object`.\n *\n * **Note:** Non-object values are coerced to objects.\n *\n * @static\n * @memberOf _\n * @category Object\n * @param {Object} object The object to query.\n * @returns {Array} Returns the array of property names.\n * @example\n *\n * function Foo() {\n * this.a = 1;\n * this.b = 2;\n * }\n *\n * Foo.prototype.c = 3;\n *\n * _.keysIn(new Foo);\n * // => ['a', 'b', 'c'] (iteration order is not guaranteed)\n */\n function keysIn(object) {\n if (object == null) {\n return [];\n }\n if (!isObject(object)) {\n object = Object(object);\n }\n var length = object.length;\n length = (length && isLength(length) &&\n (isArray(object) || isArguments(object)) && length) || 0;\n\n var Ctor = object.constructor,\n index = -1,\n isProto = typeof Ctor == 'function' && Ctor.prototype === object,\n result = Array(length),\n skipIndexes = length > 0;\n\n while (++index < length) {\n result[index] = (index + '');\n }\n for (var key in object) {\n if (!(skipIndexes && isIndex(key, length)) &&\n !(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {\n result.push(key);\n }\n }\n return result;\n }\n\n /**\n * The opposite of `_.mapValues`; this method creates an object with the\n * same values as `object` and keys generated by running each own enumerable\n * property of `object` through `iteratee`.\n *\n * @static\n * @memberOf _\n * @category Object\n * @param {Object} object The object to iterate over.\n * @param {Function|Object|string} [iteratee=_.identity] The function invoked\n * per iteration.\n * @param {*} [thisArg] The `this` binding of `iteratee`.\n * @returns {Object} Returns the new mapped object.\n * @example\n *\n * _.mapKeys({ 'a': 1, 'b': 2 }, function(value, key) {\n * return key + value;\n * });\n * // => { 'a1': 1, 'b2': 2 }\n */\n var mapKeys = createObjectMapper(true);\n\n /**\n * Creates an object with the same keys as `object` and values generated by\n * running each own enumerable property of `object` through `iteratee`. The\n * iteratee function is bound to `thisArg` and invoked with three arguments:\n * (value, key, object).\n *\n * If a property name is provided for `iteratee` the created `_.property`\n * style callback returns the property value of the given element.\n *\n * If a value is also provided for `thisArg` the created `_.matchesProperty`\n * style callback returns `true` for elements that have a matching property\n * value, else `false`.\n *\n * If an object is provided for `iteratee` the created `_.matches` style\n * callback returns `true` for elements that have the properties of the given\n * object, else `false`.\n *\n * @static\n * @memberOf _\n * @category Object\n * @param {Object} object The object to iterate over.\n * @param {Function|Object|string} [iteratee=_.identity] The function invoked\n * per iteration.\n * @param {*} [thisArg] The `this` binding of `iteratee`.\n * @returns {Object} Returns the new mapped object.\n * @example\n *\n * _.mapValues({ 'a': 1, 'b': 2 }, function(n) {\n * return n * 3;\n * });\n * // => { 'a': 3, 'b': 6 }\n *\n * var users = {\n * 'fred': { 'user': 'fred', 'age': 40 },\n * 'pebbles': { 'user': 'pebbles', 'age': 1 }\n * };\n *\n * // using the `_.property` callback shorthand\n * _.mapValues(users, 'age');\n * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)\n */\n var mapValues = createObjectMapper();\n\n /**\n * The opposite of `_.pick`; this method creates an object composed of the\n * own and inherited enumerable properties of `object` that are not omitted.\n *\n * @static\n * @memberOf _\n * @category Object\n * @param {Object} object The source object.\n * @param {Function|...(string|string[])} [predicate] The function invoked per\n * iteration or property names to omit, specified as individual property\n * names or arrays of property names.\n * @param {*} [thisArg] The `this` binding of `predicate`.\n * @returns {Object} Returns the new object.\n * @example\n *\n * var object = { 'user': 'fred', 'age': 40 };\n *\n * _.omit(object, 'age');\n * // => { 'user': 'fred' }\n *\n * _.omit(object, _.isNumber);\n * // => { 'user': 'fred' }\n */\n var omit = restParam(function(object, props) {\n if (object == null) {\n return {};\n }\n if (typeof props[0] != 'function') {\n var props = arrayMap(baseFlatten(props), String);\n return pickByArray(object, baseDifference(keysIn(object), props));\n }\n var predicate = bindCallback(props[0], props[1], 3);\n return pickByCallback(object, function(value, key, object) {\n return !predicate(value, key, object);\n });\n });\n\n /**\n * Creates a two dimensional array of the key-value pairs for `object`,\n * e.g. `[[key1, value1], [key2, value2]]`.\n *\n * @static\n * @memberOf _\n * @category Object\n * @param {Object} object The object to query.\n * @returns {Array} Returns the new array of key-value pairs.\n * @example\n *\n * _.pairs({ 'barney': 36, 'fred': 40 });\n * // => [['barney', 36], ['fred', 40]] (iteration order is not guaranteed)\n */\n function pairs(object) {\n object = toObject(object);\n\n var index = -1,\n props = keys(object),\n length = props.length,\n result = Array(length);\n\n while (++index < length) {\n var key = props[index];\n result[index] = [key, object[key]];\n }\n return result;\n }\n\n /**\n * Creates an object composed of the picked `object` properties. Property\n * names may be specified as individual arguments or as arrays of property\n * names. If `predicate` is provided it is invoked for each property of `object`\n * picking the properties `predicate` returns truthy for. The predicate is\n * bound to `thisArg` and invoked with three arguments: (value, key, object).\n *\n * @static\n * @memberOf _\n * @category Object\n * @param {Object} object The source object.\n * @param {Function|...(string|string[])} [predicate] The function invoked per\n * iteration or property names to pick, specified as individual property\n * names or arrays of property names.\n * @param {*} [thisArg] The `this` binding of `predicate`.\n * @returns {Object} Returns the new object.\n * @example\n *\n * var object = { 'user': 'fred', 'age': 40 };\n *\n * _.pick(object, 'user');\n * // => { 'user': 'fred' }\n *\n * _.pick(object, _.isString);\n * // => { 'user': 'fred' }\n */\n var pick = restParam(function(object, props) {\n if (object == null) {\n return {};\n }\n return typeof props[0] == 'function'\n ? pickByCallback(object, bindCallback(props[0], props[1], 3))\n : pickByArray(object, baseFlatten(props));\n });\n\n /**\n * This method is like `_.get` except that if the resolved value is a function\n * it is invoked with the `this` binding of its parent object and its result\n * is returned.\n *\n * @static\n * @memberOf _\n * @category Object\n * @param {Object} object The object to query.\n * @param {Array|string} path The path of the property to resolve.\n * @param {*} [defaultValue] The value returned if the resolved value is `undefined`.\n * @returns {*} Returns the resolved value.\n * @example\n *\n * var object = { 'a': [{ 'b': { 'c1': 3, 'c2': _.constant(4) } }] };\n *\n * _.result(object, 'a[0].b.c1');\n * // => 3\n *\n * _.result(object, 'a[0].b.c2');\n * // => 4\n *\n * _.result(object, 'a.b.c', 'default');\n * // => 'default'\n *\n * _.result(object, 'a.b.c', _.constant('default'));\n * // => 'default'\n */\n function result(object, path, defaultValue) {\n var result = object == null ? undefined : object[path];\n if (result === undefined) {\n if (object != null && !isKey(path, object)) {\n path = toPath(path);\n object = path.length == 1 ? object : baseGet(object, baseSlice(path, 0, -1));\n result = object == null ? undefined : object[last(path)];\n }\n result = result === undefined ? defaultValue : result;\n }\n return isFunction(result) ? result.call(object) : result;\n }\n\n /**\n * Sets the property value of `path` on `object`. If a portion of `path`\n * does not exist it is created.\n *\n * @static\n * @memberOf _\n * @category Object\n * @param {Object} object The object to augment.\n * @param {Array|string} path The path of the property to set.\n * @param {*} value The value to set.\n * @returns {Object} Returns `object`.\n * @example\n *\n * var object = { 'a': [{ 'b': { 'c': 3 } }] };\n *\n * _.set(object, 'a[0].b.c', 4);\n * console.log(object.a[0].b.c);\n * // => 4\n *\n * _.set(object, 'x[0].y.z', 5);\n * console.log(object.x[0].y.z);\n * // => 5\n */\n function set(object, path, value) {\n if (object == null) {\n return object;\n }\n var pathKey = (path + '');\n path = (object[pathKey] != null || isKey(path, object)) ? [pathKey] : toPath(path);\n\n var index = -1,\n length = path.length,\n lastIndex = length - 1,\n nested = object;\n\n while (nested != null && ++index < length) {\n var key = path[index];\n if (isObject(nested)) {\n if (index == lastIndex) {\n nested[key] = value;\n } else if (nested[key] == null) {\n nested[key] = isIndex(path[index + 1]) ? [] : {};\n }\n }\n nested = nested[key];\n }\n return object;\n }\n\n /**\n * An alternative to `_.reduce`; this method transforms `object` to a new\n * `accumulator` object which is the result of running each of its own enumerable\n * properties through `iteratee`, with each invocation potentially mutating\n * the `accumulator` object. The `iteratee` is bound to `thisArg` and invoked\n * with four arguments: (accumulator, value, key, object). Iteratee functions\n * may exit iteration early by explicitly returning `false`.\n *\n * @static\n * @memberOf _\n * @category Object\n * @param {Array|Object} object The object to iterate over.\n * @param {Function} [iteratee=_.identity] The function invoked per iteration.\n * @param {*} [accumulator] The custom accumulator value.\n * @param {*} [thisArg] The `this` binding of `iteratee`.\n * @returns {*} Returns the accumulated value.\n * @example\n *\n * _.transform([2, 3, 4], function(result, n) {\n * result.push(n *= n);\n * return n % 2 == 0;\n * });\n * // => [4, 9]\n *\n * _.transform({ 'a': 1, 'b': 2 }, function(result, n, key) {\n * result[key] = n * 3;\n * });\n * // => { 'a': 3, 'b': 6 }\n */\n function transform(object, iteratee, accumulator, thisArg) {\n var isArr = isArray(object) || isTypedArray(object);\n iteratee = getCallback(iteratee, thisArg, 4);\n\n if (accumulator == null) {\n if (isArr || isObject(object)) {\n var Ctor = object.constructor;\n if (isArr) {\n accumulator = isArray(object) ? new Ctor : [];\n } else {\n accumulator = baseCreate(isFunction(Ctor) ? Ctor.prototype : undefined);\n }\n } else {\n accumulator = {};\n }\n }\n (isArr ? arrayEach : baseForOwn)(object, function(value, index, object) {\n return iteratee(accumulator, value, index, object);\n });\n return accumulator;\n }\n\n /**\n * Creates an array of the own enumerable property values of `object`.\n *\n * **Note:** Non-object values are coerced to objects.\n *\n * @static\n * @memberOf _\n * @category Object\n * @param {Object} object The object to query.\n * @returns {Array} Returns the array of property values.\n * @example\n *\n * function Foo() {\n * this.a = 1;\n * this.b = 2;\n * }\n *\n * Foo.prototype.c = 3;\n *\n * _.values(new Foo);\n * // => [1, 2] (iteration order is not guaranteed)\n *\n * _.values('hi');\n * // => ['h', 'i']\n */\n function values(object) {\n return baseValues(object, keys(object));\n }\n\n /**\n * Creates an array of the own and inherited enumerable property values\n * of `object`.\n *\n * **Note:** Non-object values are coerced to objects.\n *\n * @static\n * @memberOf _\n * @category Object\n * @param {Object} object The object to query.\n * @returns {Array} Returns the array of property values.\n * @example\n *\n * function Foo() {\n * this.a = 1;\n * this.b = 2;\n * }\n *\n * Foo.prototype.c = 3;\n *\n * _.valuesIn(new Foo);\n * // => [1, 2, 3] (iteration order is not guaranteed)\n */\n function valuesIn(object) {\n return baseValues(object, keysIn(object));\n }\n\n /*------------------------------------------------------------------------*/\n\n /**\n * Checks if `n` is between `start` and up to but not including, `end`. If\n * `end` is not specified it is set to `start` with `start` then set to `0`.\n *\n * @static\n * @memberOf _\n * @category Number\n * @param {number} n The number to check.\n * @param {number} [start=0] The start of the range.\n * @param {number} end The end of the range.\n * @returns {boolean} Returns `true` if `n` is in the range, else `false`.\n * @example\n *\n * _.inRange(3, 2, 4);\n * // => true\n *\n * _.inRange(4, 8);\n * // => true\n *\n * _.inRange(4, 2);\n * // => false\n *\n * _.inRange(2, 2);\n * // => false\n *\n * _.inRange(1.2, 2);\n * // => true\n *\n * _.inRange(5.2, 4);\n * // => false\n */\n function inRange(value, start, end) {\n start = +start || 0;\n if (end === undefined) {\n end = start;\n start = 0;\n } else {\n end = +end || 0;\n }\n return value >= nativeMin(start, end) && value < nativeMax(start, end);\n }\n\n /**\n * Produces a random number between `min` and `max` (inclusive). If only one\n * argument is provided a number between `0` and the given number is returned.\n * If `floating` is `true`, or either `min` or `max` are floats, a floating-point\n * number is returned instead of an integer.\n *\n * @static\n * @memberOf _\n * @category Number\n * @param {number} [min=0] The minimum possible value.\n * @param {number} [max=1] The maximum possible value.\n * @param {boolean} [floating] Specify returning a floating-point number.\n * @returns {number} Returns the random number.\n * @example\n *\n * _.random(0, 5);\n * // => an integer between 0 and 5\n *\n * _.random(5);\n * // => also an integer between 0 and 5\n *\n * _.random(5, true);\n * // => a floating-point number between 0 and 5\n *\n * _.random(1.2, 5.2);\n * // => a floating-point number between 1.2 and 5.2\n */\n function random(min, max, floating) {\n if (floating && isIterateeCall(min, max, floating)) {\n max = floating = undefined;\n }\n var noMin = min == null,\n noMax = max == null;\n\n if (floating == null) {\n if (noMax && typeof min == 'boolean') {\n floating = min;\n min = 1;\n }\n else if (typeof max == 'boolean') {\n floating = max;\n noMax = true;\n }\n }\n if (noMin && noMax) {\n max = 1;\n noMax = false;\n }\n min = +min || 0;\n if (noMax) {\n max = min;\n min = 0;\n } else {\n max = +max || 0;\n }\n if (floating || min % 1 || max % 1) {\n var rand = nativeRandom();\n return nativeMin(min + (rand * (max - min + parseFloat('1e-' + ((rand + '').length - 1)))), max);\n }\n return baseRandom(min, max);\n }\n\n /*------------------------------------------------------------------------*/\n\n /**\n * Converts `string` to [camel case](https://en.wikipedia.org/wiki/CamelCase).\n *\n * @static\n * @memberOf _\n * @category String\n * @param {string} [string=''] The string to convert.\n * @returns {string} Returns the camel cased string.\n * @example\n *\n * _.camelCase('Foo Bar');\n * // => 'fooBar'\n *\n * _.camelCase('--foo-bar');\n * // => 'fooBar'\n *\n * _.camelCase('__foo_bar__');\n * // => 'fooBar'\n */\n var camelCase = createCompounder(function(result, word, index) {\n word = word.toLowerCase();\n return result + (index ? (word.charAt(0).toUpperCase() + word.slice(1)) : word);\n });\n\n /**\n * Capitalizes the first character of `string`.\n *\n * @static\n * @memberOf _\n * @category String\n * @param {string} [string=''] The string to capitalize.\n * @returns {string} Returns the capitalized string.\n * @example\n *\n * _.capitalize('fred');\n * // => 'Fred'\n */\n function capitalize(string) {\n string = baseToString(string);\n return string && (string.charAt(0).toUpperCase() + string.slice(1));\n }\n\n /**\n * Deburrs `string` by converting [latin-1 supplementary letters](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table)\n * to basic latin letters and removing [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks).\n *\n * @static\n * @memberOf _\n * @category String\n * @param {string} [string=''] The string to deburr.\n * @returns {string} Returns the deburred string.\n * @example\n *\n * _.deburr('déjà vu');\n * // => 'deja vu'\n */\n function deburr(string) {\n string = baseToString(string);\n return string && string.replace(reLatin1, deburrLetter).replace(reComboMark, '');\n }\n\n /**\n * Checks if `string` ends with the given target string.\n *\n * @static\n * @memberOf _\n * @category String\n * @param {string} [string=''] The string to search.\n * @param {string} [target] The string to search for.\n * @param {number} [position=string.length] The position to search from.\n * @returns {boolean} Returns `true` if `string` ends with `target`, else `false`.\n * @example\n *\n * _.endsWith('abc', 'c');\n * // => true\n *\n * _.endsWith('abc', 'b');\n * // => false\n *\n * _.endsWith('abc', 'b', 2);\n * // => true\n */\n function endsWith(string, target, position) {\n string = baseToString(string);\n target = (target + '');\n\n var length = string.length;\n position = position === undefined\n ? length\n : nativeMin(position < 0 ? 0 : (+position || 0), length);\n\n position -= target.length;\n return position >= 0 && string.indexOf(target, position) == position;\n }\n\n /**\n * Converts the characters \"&\", \"<\", \">\", '\"', \"'\", and \"\\`\", in `string` to\n * their corresponding HTML entities.\n *\n * **Note:** No other characters are escaped. To escape additional characters\n * use a third-party library like [_he_](https://mths.be/he).\n *\n * Though the \">\" character is escaped for symmetry, characters like\n * \">\" and \"/\" don't need escaping in HTML and have no special meaning\n * unless they're part of a tag or unquoted attribute value.\n * See [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands)\n * (under \"semi-related fun fact\") for more details.\n *\n * Backticks are escaped because in Internet Explorer < 9, they can break out\n * of attribute values or HTML comments. See [#59](https://html5sec.org/#59),\n * [#102](https://html5sec.org/#102), [#108](https://html5sec.org/#108), and\n * [#133](https://html5sec.org/#133) of the [HTML5 Security Cheatsheet](https://html5sec.org/)\n * for more details.\n *\n * When working with HTML you should always [quote attribute values](http://wonko.com/post/html-escaping)\n * to reduce XSS vectors.\n *\n * @static\n * @memberOf _\n * @category String\n * @param {string} [string=''] The string to escape.\n * @returns {string} Returns the escaped string.\n * @example\n *\n * _.escape('fred, barney, & pebbles');\n * // => 'fred, barney, &amp; pebbles'\n */\n function escape(string) {\n // Reset `lastIndex` because in IE < 9 `String#replace` does not.\n string = baseToString(string);\n return (string && reHasUnescapedHtml.test(string))\n ? string.replace(reUnescapedHtml, escapeHtmlChar)\n : string;\n }\n\n /**\n * Escapes the `RegExp` special characters \"\\\", \"/\", \"^\", \"$\", \".\", \"|\", \"?\",\n * \"*\", \"+\", \"(\", \")\", \"[\", \"]\", \"{\" and \"}\" in `string`.\n *\n * @static\n * @memberOf _\n * @category String\n * @param {string} [string=''] The string to escape.\n * @returns {string} Returns the escaped string.\n * @example\n *\n * _.escapeRegExp('[lodash](https://lodash.com/)');\n * // => '\\[lodash\\]\\(https:\\/\\/lodash\\.com\\/\\)'\n */\n function escapeRegExp(string) {\n string = baseToString(string);\n return (string && reHasRegExpChars.test(string))\n ? string.replace(reRegExpChars, escapeRegExpChar)\n : (string || '(?:)');\n }\n\n /**\n * Converts `string` to [kebab case](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles).\n *\n * @static\n * @memberOf _\n * @category String\n * @param {string} [string=''] The string to convert.\n * @returns {string} Returns the kebab cased string.\n * @example\n *\n * _.kebabCase('Foo Bar');\n * // => 'foo-bar'\n *\n * _.kebabCase('fooBar');\n * // => 'foo-bar'\n *\n * _.kebabCase('__foo_bar__');\n * // => 'foo-bar'\n */\n var kebabCase = createCompounder(function(result, word, index) {\n return result + (index ? '-' : '') + word.toLowerCase();\n });\n\n /**\n * Pads `string` on the left and right sides if it's shorter than `length`.\n * Padding characters are truncated if they can't be evenly divided by `length`.\n *\n * @static\n * @memberOf _\n * @category String\n * @param {string} [string=''] The string to pad.\n * @param {number} [length=0] The padding length.\n * @param {string} [chars=' '] The string used as padding.\n * @returns {string} Returns the padded string.\n * @example\n *\n * _.pad('abc', 8);\n * // => ' abc '\n *\n * _.pad('abc', 8, '_-');\n * // => '_-abc_-_'\n *\n * _.pad('abc', 3);\n * // => 'abc'\n */\n function pad(string, length, chars) {\n string = baseToString(string);\n length = +length;\n\n var strLength = string.length;\n if (strLength >= length || !nativeIsFinite(length)) {\n return string;\n }\n var mid = (length - strLength) / 2,\n leftLength = nativeFloor(mid),\n rightLength = nativeCeil(mid);\n\n chars = createPadding('', rightLength, chars);\n return chars.slice(0, leftLength) + string + chars;\n }\n\n /**\n * Pads `string` on the left side if it's shorter than `length`. Padding\n * characters are truncated if they exceed `length`.\n *\n * @static\n * @memberOf _\n * @category String\n * @param {string} [string=''] The string to pad.\n * @param {number} [length=0] The padding length.\n * @param {string} [chars=' '] The string used as padding.\n * @returns {string} Returns the padded string.\n * @example\n *\n * _.padLeft('abc', 6);\n * // => ' abc'\n *\n * _.padLeft('abc', 6, '_-');\n * // => '_-_abc'\n *\n * _.padLeft('abc', 3);\n * // => 'abc'\n */\n var padLeft = createPadDir();\n\n /**\n * Pads `string` on the right side if it's shorter than `length`. Padding\n * characters are truncated if they exceed `length`.\n *\n * @static\n * @memberOf _\n * @category String\n * @param {string} [string=''] The string to pad.\n * @param {number} [length=0] The padding length.\n * @param {string} [chars=' '] The string used as padding.\n * @returns {string} Returns the padded string.\n * @example\n *\n * _.padRight('abc', 6);\n * // => 'abc '\n *\n * _.padRight('abc', 6, '_-');\n * // => 'abc_-_'\n *\n * _.padRight('abc', 3);\n * // => 'abc'\n */\n var padRight = createPadDir(true);\n\n /**\n * Converts `string` to an integer of the specified radix. If `radix` is\n * `undefined` or `0`, a `radix` of `10` is used unless `value` is a hexadecimal,\n * in which case a `radix` of `16` is used.\n *\n * **Note:** This method aligns with the [ES5 implementation](https://es5.github.io/#E)\n * of `parseInt`.\n *\n * @static\n * @memberOf _\n * @category String\n * @param {string} string The string to convert.\n * @param {number} [radix] The radix to interpret `value` by.\n * @param- {Object} [guard] Enables use as a callback for functions like `_.map`.\n * @returns {number} Returns the converted integer.\n * @example\n *\n * _.parseInt('08');\n * // => 8\n *\n * _.map(['6', '08', '10'], _.parseInt);\n * // => [6, 8, 10]\n */\n function parseInt(string, radix, guard) {\n // Firefox < 21 and Opera < 15 follow ES3 for `parseInt`.\n // Chrome fails to trim leading <BOM> whitespace characters.\n // See https://code.google.com/p/v8/issues/detail?id=3109 for more details.\n if (guard ? isIterateeCall(string, radix, guard) : radix == null) {\n radix = 0;\n } else if (radix) {\n radix = +radix;\n }\n string = trim(string);\n return nativeParseInt(string, radix || (reHasHexPrefix.test(string) ? 16 : 10));\n }\n\n /**\n * Repeats the given string `n` times.\n *\n * @static\n * @memberOf _\n * @category String\n * @param {string} [string=''] The string to repeat.\n * @param {number} [n=0] The number of times to repeat the string.\n * @returns {string} Returns the repeated string.\n * @example\n *\n * _.repeat('*', 3);\n * // => '***'\n *\n * _.repeat('abc', 2);\n * // => 'abcabc'\n *\n * _.repeat('abc', 0);\n * // => ''\n */\n function repeat(string, n) {\n var result = '';\n string = baseToString(string);\n n = +n;\n if (n < 1 || !string || !nativeIsFinite(n)) {\n return result;\n }\n // Leverage the exponentiation by squaring algorithm for a faster repeat.\n // See https://en.wikipedia.org/wiki/Exponentiation_by_squaring for more details.\n do {\n if (n % 2) {\n result += string;\n }\n n = nativeFloor(n / 2);\n string += string;\n } while (n);\n\n return result;\n }\n\n /**\n * Converts `string` to [snake case](https://en.wikipedia.org/wiki/Snake_case).\n *\n * @static\n * @memberOf _\n * @category String\n * @param {string} [string=''] The string to convert.\n * @returns {string} Returns the snake cased string.\n * @example\n *\n * _.snakeCase('Foo Bar');\n * // => 'foo_bar'\n *\n * _.snakeCase('fooBar');\n * // => 'foo_bar'\n *\n * _.snakeCase('--foo-bar');\n * // => 'foo_bar'\n */\n var snakeCase = createCompounder(function(result, word, index) {\n return result + (index ? '_' : '') + word.toLowerCase();\n });\n\n /**\n * Converts `string` to [start case](https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage).\n *\n * @static\n * @memberOf _\n * @category String\n * @param {string} [string=''] The string to convert.\n * @returns {string} Returns the start cased string.\n * @example\n *\n * _.startCase('--foo-bar');\n * // => 'Foo Bar'\n *\n * _.startCase('fooBar');\n * // => 'Foo Bar'\n *\n * _.startCase('__foo_bar__');\n * // => 'Foo Bar'\n */\n var startCase = createCompounder(function(result, word, index) {\n return result + (index ? ' ' : '') + (word.charAt(0).toUpperCase() + word.slice(1));\n });\n\n /**\n * Checks if `string` starts with the given target string.\n *\n * @static\n * @memberOf _\n * @category String\n * @param {string} [string=''] The string to search.\n * @param {string} [target] The string to search for.\n * @param {number} [position=0] The position to search from.\n * @returns {boolean} Returns `true` if `string` starts with `target`, else `false`.\n * @example\n *\n * _.startsWith('abc', 'a');\n * // => true\n *\n * _.startsWith('abc', 'b');\n * // => false\n *\n * _.startsWith('abc', 'b', 1);\n * // => true\n */\n function startsWith(string, target, position) {\n string = baseToString(string);\n position = position == null\n ? 0\n : nativeMin(position < 0 ? 0 : (+position || 0), string.length);\n\n return string.lastIndexOf(target, position) == position;\n }\n\n /**\n * Creates a compiled template function that can interpolate data properties\n * in \"interpolate\" delimiters, HTML-escape interpolated data properties in\n * \"escape\" delimiters, and execute JavaScript in \"evaluate\" delimiters. Data\n * properties may be accessed as free variables in the template. If a setting\n * object is provided it takes precedence over `_.templateSettings` values.\n *\n * **Note:** In the development build `_.template` utilizes\n * [sourceURLs](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl)\n * for easier debugging.\n *\n * For more information on precompiling templates see\n * [lodash's custom builds documentation](https://lodash.com/custom-builds).\n *\n * For more information on Chrome extension sandboxes see\n * [Chrome's extensions documentation](https://developer.chrome.com/extensions/sandboxingEval).\n *\n * @static\n * @memberOf _\n * @category String\n * @param {string} [string=''] The template string.\n * @param {Object} [options] The options object.\n * @param {RegExp} [options.escape] The HTML \"escape\" delimiter.\n * @param {RegExp} [options.evaluate] The \"evaluate\" delimiter.\n * @param {Object} [options.imports] An object to import into the template as free variables.\n * @param {RegExp} [options.interpolate] The \"interpolate\" delimiter.\n * @param {string} [options.sourceURL] The sourceURL of the template's compiled source.\n * @param {string} [options.variable] The data object variable name.\n * @param- {Object} [otherOptions] Enables the legacy `options` param signature.\n * @returns {Function} Returns the compiled template function.\n * @example\n *\n * // using the \"interpolate\" delimiter to create a compiled template\n * var compiled = _.template('hello <%= user %>!');\n * compiled({ 'user': 'fred' });\n * // => 'hello fred!'\n *\n * // using the HTML \"escape\" delimiter to escape data property values\n * var compiled = _.template('<b><%- value %></b>');\n * compiled({ 'value': '<script>' });\n * // => '<b>&lt;script&gt;</b>'\n *\n * // using the \"evaluate\" delimiter to execute JavaScript and generate HTML\n * var compiled = _.template('<% _.forEach(users, function(user) { %><li><%- user %></li><% }); %>');\n * compiled({ 'users': ['fred', 'barney'] });\n * // => '<li>fred</li><li>barney</li>'\n *\n * // using the internal `print` function in \"evaluate\" delimiters\n * var compiled = _.template('<% print(\"hello \" + user); %>!');\n * compiled({ 'user': 'barney' });\n * // => 'hello barney!'\n *\n * // using the ES delimiter as an alternative to the default \"interpolate\" delimiter\n * var compiled = _.template('hello ${ user }!');\n * compiled({ 'user': 'pebbles' });\n * // => 'hello pebbles!'\n *\n * // using custom template delimiters\n * _.templateSettings.interpolate = /{{([\\s\\S]+?)}}/g;\n * var compiled = _.template('hello {{ user }}!');\n * compiled({ 'user': 'mustache' });\n * // => 'hello mustache!'\n *\n * // using backslashes to treat delimiters as plain text\n * var compiled = _.template('<%= \"\\\\<%- value %\\\\>\" %>');\n * compiled({ 'value': 'ignored' });\n * // => '<%- value %>'\n *\n * // using the `imports` option to import `jQuery` as `jq`\n * var text = '<% jq.each(users, function(user) { %><li><%- user %></li><% }); %>';\n * var compiled = _.template(text, { 'imports': { 'jq': jQuery } });\n * compiled({ 'users': ['fred', 'barney'] });\n * // => '<li>fred</li><li>barney</li>'\n *\n * // using the `sourceURL` option to specify a custom sourceURL for the template\n * var compiled = _.template('hello <%= user %>!', { 'sourceURL': '/basic/greeting.jst' });\n * compiled(data);\n * // => find the source of \"greeting.jst\" under the Sources tab or Resources panel of the web inspector\n *\n * // using the `variable` option to ensure a with-statement isn't used in the compiled template\n * var compiled = _.template('hi <%= data.user %>!', { 'variable': 'data' });\n * compiled.source;\n * // => function(data) {\n * // var __t, __p = '';\n * // __p += 'hi ' + ((__t = ( data.user )) == null ? '' : __t) + '!';\n * // return __p;\n * // }\n *\n * // using the `source` property to inline compiled templates for meaningful\n * // line numbers in error messages and a stack trace\n * fs.writeFileSync(path.join(cwd, 'jst.js'), '\\\n * var JST = {\\\n * \"main\": ' + _.template(mainText).source + '\\\n * };\\\n * ');\n */\n function template(string, options, otherOptions) {\n // Based on John Resig's `tmpl` implementation (http://ejohn.org/blog/javascript-micro-templating/)\n // and Laura Doktorova's doT.js (https://github.com/olado/doT).\n var settings = lodash.templateSettings;\n\n if (otherOptions && isIterateeCall(string, options, otherOptions)) {\n options = otherOptions = undefined;\n }\n string = baseToString(string);\n options = assignWith(baseAssign({}, otherOptions || options), settings, assignOwnDefaults);\n\n var imports = assignWith(baseAssign({}, options.imports), settings.imports, assignOwnDefaults),\n importsKeys = keys(imports),\n importsValues = baseValues(imports, importsKeys);\n\n var isEscaping,\n isEvaluating,\n index = 0,\n interpolate = options.interpolate || reNoMatch,\n source = \"__p += '\";\n\n // Compile the regexp to match each delimiter.\n var reDelimiters = RegExp(\n (options.escape || reNoMatch).source + '|' +\n interpolate.source + '|' +\n (interpolate === reInterpolate ? reEsTemplate : reNoMatch).source + '|' +\n (options.evaluate || reNoMatch).source + '|$'\n , 'g');\n\n // Use a sourceURL for easier debugging.\n var sourceURL = '//# sourceURL=' +\n ('sourceURL' in options\n ? options.sourceURL\n : ('lodash.templateSources[' + (++templateCounter) + ']')\n ) + '\\n';\n\n string.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset) {\n interpolateValue || (interpolateValue = esTemplateValue);\n\n // Escape characters that can't be included in string literals.\n source += string.slice(index, offset).replace(reUnescapedString, escapeStringChar);\n\n // Replace delimiters with snippets.\n if (escapeValue) {\n isEscaping = true;\n source += \"' +\\n__e(\" + escapeValue + \") +\\n'\";\n }\n if (evaluateValue) {\n isEvaluating = true;\n source += \"';\\n\" + evaluateValue + \";\\n__p += '\";\n }\n if (interpolateValue) {\n source += \"' +\\n((__t = (\" + interpolateValue + \")) == null ? '' : __t) +\\n'\";\n }\n index = offset + match.length;\n\n // The JS engine embedded in Adobe products requires returning the `match`\n // string in order to produce the correct `offset` value.\n return match;\n });\n\n source += \"';\\n\";\n\n // If `variable` is not specified wrap a with-statement around the generated\n // code to add the data object to the top of the scope chain.\n var variable = options.variable;\n if (!variable) {\n source = 'with (obj) {\\n' + source + '\\n}\\n';\n }\n // Cleanup code by stripping empty strings.\n source = (isEvaluating ? source.replace(reEmptyStringLeading, '') : source)\n .replace(reEmptyStringMiddle, '$1')\n .replace(reEmptyStringTrailing, '$1;');\n\n // Frame code as the function body.\n source = 'function(' + (variable || 'obj') + ') {\\n' +\n (variable\n ? ''\n : 'obj || (obj = {});\\n'\n ) +\n \"var __t, __p = ''\" +\n (isEscaping\n ? ', __e = _.escape'\n : ''\n ) +\n (isEvaluating\n ? ', __j = Array.prototype.join;\\n' +\n \"function print() { __p += __j.call(arguments, '') }\\n\"\n : ';\\n'\n ) +\n source +\n 'return __p\\n}';\n\n var result = attempt(function() {\n return Function(importsKeys, sourceURL + 'return ' + source).apply(undefined, importsValues);\n });\n\n // Provide the compiled function's source by its `toString` method or\n // the `source` property as a convenience for inlining compiled templates.\n result.source = source;\n if (isError(result)) {\n throw result;\n }\n return result;\n }\n\n /**\n * Removes leading and trailing whitespace or specified characters from `string`.\n *\n * @static\n * @memberOf _\n * @category String\n * @param {string} [string=''] The string to trim.\n * @param {string} [chars=whitespace] The characters to trim.\n * @param- {Object} [guard] Enables use as a callback for functions like `_.map`.\n * @returns {string} Returns the trimmed string.\n * @example\n *\n * _.trim(' abc ');\n * // => 'abc'\n *\n * _.trim('-_-abc-_-', '_-');\n * // => 'abc'\n *\n * _.map([' foo ', ' bar '], _.trim);\n * // => ['foo', 'bar']\n */\n function trim(string, chars, guard) {\n var value = string;\n string = baseToString(string);\n if (!string) {\n return string;\n }\n if (guard ? isIterateeCall(value, chars, guard) : chars == null) {\n return string.slice(trimmedLeftIndex(string), trimmedRightIndex(string) + 1);\n }\n chars = (chars + '');\n return string.slice(charsLeftIndex(string, chars), charsRightIndex(string, chars) + 1);\n }\n\n /**\n * Removes leading whitespace or specified characters from `string`.\n *\n * @static\n * @memberOf _\n * @category String\n * @param {string} [string=''] The string to trim.\n * @param {string} [chars=whitespace] The characters to trim.\n * @param- {Object} [guard] Enables use as a callback for functions like `_.map`.\n * @returns {string} Returns the trimmed string.\n * @example\n *\n * _.trimLeft(' abc ');\n * // => 'abc '\n *\n * _.trimLeft('-_-abc-_-', '_-');\n * // => 'abc-_-'\n */\n function trimLeft(string, chars, guard) {\n var value = string;\n string = baseToString(string);\n if (!string) {\n return string;\n }\n if (guard ? isIterateeCall(value, chars, guard) : chars == null) {\n return string.slice(trimmedLeftIndex(string));\n }\n return string.slice(charsLeftIndex(string, (chars + '')));\n }\n\n /**\n * Removes trailing whitespace or specified characters from `string`.\n *\n * @static\n * @memberOf _\n * @category String\n * @param {string} [string=''] The string to trim.\n * @param {string} [chars=whitespace] The characters to trim.\n * @param- {Object} [guard] Enables use as a callback for functions like `_.map`.\n * @returns {string} Returns the trimmed string.\n * @example\n *\n * _.trimRight(' abc ');\n * // => ' abc'\n *\n * _.trimRight('-_-abc-_-', '_-');\n * // => '-_-abc'\n */\n function trimRight(string, chars, guard) {\n var value = string;\n string = baseToString(string);\n if (!string) {\n return string;\n }\n if (guard ? isIterateeCall(value, chars, guard) : chars == null) {\n return string.slice(0, trimmedRightIndex(string) + 1);\n }\n return string.slice(0, charsRightIndex(string, (chars + '')) + 1);\n }\n\n /**\n * Truncates `string` if it's longer than the given maximum string length.\n * The last characters of the truncated string are replaced with the omission\n * string which defaults to \"...\".\n *\n * @static\n * @memberOf _\n * @category String\n * @param {string} [string=''] The string to truncate.\n * @param {Object|number} [options] The options object or maximum string length.\n * @param {number} [options.length=30] The maximum string length.\n * @param {string} [options.omission='...'] The string to indicate text is omitted.\n * @param {RegExp|string} [options.separator] The separator pattern to truncate to.\n * @param- {Object} [guard] Enables use as a callback for functions like `_.map`.\n * @returns {string} Returns the truncated string.\n * @example\n *\n * _.trunc('hi-diddly-ho there, neighborino');\n * // => 'hi-diddly-ho there, neighbo...'\n *\n * _.trunc('hi-diddly-ho there, neighborino', 24);\n * // => 'hi-diddly-ho there, n...'\n *\n * _.trunc('hi-diddly-ho there, neighborino', {\n * 'length': 24,\n * 'separator': ' '\n * });\n * // => 'hi-diddly-ho there,...'\n *\n * _.trunc('hi-diddly-ho there, neighborino', {\n * 'length': 24,\n * 'separator': /,? +/\n * });\n * // => 'hi-diddly-ho there...'\n *\n * _.trunc('hi-diddly-ho there, neighborino', {\n * 'omission': ' [...]'\n * });\n * // => 'hi-diddly-ho there, neig [...]'\n */\n function trunc(string, options, guard) {\n if (guard && isIterateeCall(string, options, guard)) {\n options = undefined;\n }\n var length = DEFAULT_TRUNC_LENGTH,\n omission = DEFAULT_TRUNC_OMISSION;\n\n if (options != null) {\n if (isObject(options)) {\n var separator = 'separator' in options ? options.separator : separator;\n length = 'length' in options ? (+options.length || 0) : length;\n omission = 'omission' in options ? baseToString(options.omission) : omission;\n } else {\n length = +options || 0;\n }\n }\n string = baseToString(string);\n if (length >= string.length) {\n return string;\n }\n var end = length - omission.length;\n if (end < 1) {\n return omission;\n }\n var result = string.slice(0, end);\n if (separator == null) {\n return result + omission;\n }\n if (isRegExp(separator)) {\n if (string.slice(end).search(separator)) {\n var match,\n newEnd,\n substring = string.slice(0, end);\n\n if (!separator.global) {\n separator = RegExp(separator.source, (reFlags.exec(separator) || '') + 'g');\n }\n separator.lastIndex = 0;\n while ((match = separator.exec(substring))) {\n newEnd = match.index;\n }\n result = result.slice(0, newEnd == null ? end : newEnd);\n }\n } else if (string.indexOf(separator, end) != end) {\n var index = result.lastIndexOf(separator);\n if (index > -1) {\n result = result.slice(0, index);\n }\n }\n return result + omission;\n }\n\n /**\n * The inverse of `_.escape`; this method converts the HTML entities\n * `&amp;`, `&lt;`, `&gt;`, `&quot;`, `&#39;`, and `&#96;` in `string` to their\n * corresponding characters.\n *\n * **Note:** No other HTML entities are unescaped. To unescape additional HTML\n * entities use a third-party library like [_he_](https://mths.be/he).\n *\n * @static\n * @memberOf _\n * @category String\n * @param {string} [string=''] The string to unescape.\n * @returns {string} Returns the unescaped string.\n * @example\n *\n * _.unescape('fred, barney, &amp; pebbles');\n * // => 'fred, barney, & pebbles'\n */\n function unescape(string) {\n string = baseToString(string);\n return (string && reHasEscapedHtml.test(string))\n ? string.replace(reEscapedHtml, unescapeHtmlChar)\n : string;\n }\n\n /**\n * Splits `string` into an array of its words.\n *\n * @static\n * @memberOf _\n * @category String\n * @param {string} [string=''] The string to inspect.\n * @param {RegExp|string} [pattern] The pattern to match words.\n * @param- {Object} [guard] Enables use as a callback for functions like `_.map`.\n * @returns {Array} Returns the words of `string`.\n * @example\n *\n * _.words('fred, barney, & pebbles');\n * // => ['fred', 'barney', 'pebbles']\n *\n * _.words('fred, barney, & pebbles', /[^, ]+/g);\n * // => ['fred', 'barney', '&', 'pebbles']\n */\n function words(string, pattern, guard) {\n if (guard && isIterateeCall(string, pattern, guard)) {\n pattern = undefined;\n }\n string = baseToString(string);\n return string.match(pattern || reWords) || [];\n }\n\n /*------------------------------------------------------------------------*/\n\n /**\n * Attempts to invoke `func`, returning either the result or the caught error\n * object. Any additional arguments are provided to `func` when it is invoked.\n *\n * @static\n * @memberOf _\n * @category Utility\n * @param {Function} func The function to attempt.\n * @returns {*} Returns the `func` result or error object.\n * @example\n *\n * // avoid throwing errors for invalid selectors\n * var elements = _.attempt(function(selector) {\n * return document.querySelectorAll(selector);\n * }, '>_>');\n *\n * if (_.isError(elements)) {\n * elements = [];\n * }\n */\n var attempt = restParam(function(func, args) {\n try {\n return func.apply(undefined, args);\n } catch(e) {\n return isError(e) ? e : new Error(e);\n }\n });\n\n /**\n * Creates a function that invokes `func` with the `this` binding of `thisArg`\n * and arguments of the created function. If `func` is a property name the\n * created callback returns the property value for a given element. If `func`\n * is an object the created callback returns `true` for elements that contain\n * the equivalent object properties, otherwise it returns `false`.\n *\n * @static\n * @memberOf _\n * @alias iteratee\n * @category Utility\n * @param {*} [func=_.identity] The value to convert to a callback.\n * @param {*} [thisArg] The `this` binding of `func`.\n * @param- {Object} [guard] Enables use as a callback for functions like `_.map`.\n * @returns {Function} Returns the callback.\n * @example\n *\n * var users = [\n * { 'user': 'barney', 'age': 36 },\n * { 'user': 'fred', 'age': 40 }\n * ];\n *\n * // wrap to create custom callback shorthands\n * _.callback = _.wrap(_.callback, function(callback, func, thisArg) {\n * var match = /^(.+?)__([gl]t)(.+)$/.exec(func);\n * if (!match) {\n * return callback(func, thisArg);\n * }\n * return function(object) {\n * return match[2] == 'gt'\n * ? object[match[1]] > match[3]\n * : object[match[1]] < match[3];\n * };\n * });\n *\n * _.filter(users, 'age__gt36');\n * // => [{ 'user': 'fred', 'age': 40 }]\n */\n function callback(func, thisArg, guard) {\n if (guard && isIterateeCall(func, thisArg, guard)) {\n thisArg = undefined;\n }\n return isObjectLike(func)\n ? matches(func)\n : baseCallback(func, thisArg);\n }\n\n /**\n * Creates a function that returns `value`.\n *\n * @static\n * @memberOf _\n * @category Utility\n * @param {*} value The value to return from the new function.\n * @returns {Function} Returns the new function.\n * @example\n *\n * var object = { 'user': 'fred' };\n * var getter = _.constant(object);\n *\n * getter() === object;\n * // => true\n */\n function constant(value) {\n return function() {\n return value;\n };\n }\n\n /**\n * This method returns the first argument provided to it.\n *\n * @static\n * @memberOf _\n * @category Utility\n * @param {*} value Any value.\n * @returns {*} Returns `value`.\n * @example\n *\n * var object = { 'user': 'fred' };\n *\n * _.identity(object) === object;\n * // => true\n */\n function identity(value) {\n return value;\n }\n\n /**\n * Creates a function that performs a deep comparison between a given object\n * and `source`, returning `true` if the given object has equivalent property\n * values, else `false`.\n *\n * **Note:** This method supports comparing arrays, booleans, `Date` objects,\n * numbers, `Object` objects, regexes, and strings. Objects are compared by\n * their own, not inherited, enumerable properties. For comparing a single\n * own or inherited property value see `_.matchesProperty`.\n *\n * @static\n * @memberOf _\n * @category Utility\n * @param {Object} source The object of property values to match.\n * @returns {Function} Returns the new function.\n * @example\n *\n * var users = [\n * { 'user': 'barney', 'age': 36, 'active': true },\n * { 'user': 'fred', 'age': 40, 'active': false }\n * ];\n *\n * _.filter(users, _.matches({ 'age': 40, 'active': false }));\n * // => [{ 'user': 'fred', 'age': 40, 'active': false }]\n */\n function matches(source) {\n return baseMatches(baseClone(source, true));\n }\n\n /**\n * Creates a function that compares the property value of `path` on a given\n * object to `value`.\n *\n * **Note:** This method supports comparing arrays, booleans, `Date` objects,\n * numbers, `Object` objects, regexes, and strings. Objects are compared by\n * their own, not inherited, enumerable properties.\n *\n * @static\n * @memberOf _\n * @category Utility\n * @param {Array|string} path The path of the property to get.\n * @param {*} srcValue The value to match.\n * @returns {Function} Returns the new function.\n * @example\n *\n * var users = [\n * { 'user': 'barney' },\n * { 'user': 'fred' }\n * ];\n *\n * _.find(users, _.matchesProperty('user', 'fred'));\n * // => { 'user': 'fred' }\n */\n function matchesProperty(path, srcValue) {\n return baseMatchesProperty(path, baseClone(srcValue, true));\n }\n\n /**\n * Creates a function that invokes the method at `path` on a given object.\n * Any additional arguments are provided to the invoked method.\n *\n * @static\n * @memberOf _\n * @category Utility\n * @param {Array|string} path The path of the method to invoke.\n * @param {...*} [args] The arguments to invoke the method with.\n * @returns {Function} Returns the new function.\n * @example\n *\n * var objects = [\n * { 'a': { 'b': { 'c': _.constant(2) } } },\n * { 'a': { 'b': { 'c': _.constant(1) } } }\n * ];\n *\n * _.map(objects, _.method('a.b.c'));\n * // => [2, 1]\n *\n * _.invoke(_.sortBy(objects, _.method(['a', 'b', 'c'])), 'a.b.c');\n * // => [1, 2]\n */\n var method = restParam(function(path, args) {\n return function(object) {\n return invokePath(object, path, args);\n };\n });\n\n /**\n * The opposite of `_.method`; this method creates a function that invokes\n * the method at a given path on `object`. Any additional arguments are\n * provided to the invoked method.\n *\n * @static\n * @memberOf _\n * @category Utility\n * @param {Object} object The object to query.\n * @param {...*} [args] The arguments to invoke the method with.\n * @returns {Function} Returns the new function.\n * @example\n *\n * var array = _.times(3, _.constant),\n * object = { 'a': array, 'b': array, 'c': array };\n *\n * _.map(['a[2]', 'c[0]'], _.methodOf(object));\n * // => [2, 0]\n *\n * _.map([['a', '2'], ['c', '0']], _.methodOf(object));\n * // => [2, 0]\n */\n var methodOf = restParam(function(object, args) {\n return function(path) {\n return invokePath(object, path, args);\n };\n });\n\n /**\n * Adds all own enumerable function properties of a source object to the\n * destination object. If `object` is a function then methods are added to\n * its prototype as well.\n *\n * **Note:** Use `_.runInContext` to create a pristine `lodash` function to\n * avoid conflicts caused by modifying the original.\n *\n * @static\n * @memberOf _\n * @category Utility\n * @param {Function|Object} [object=lodash] The destination object.\n * @param {Object} source The object of functions to add.\n * @param {Object} [options] The options object.\n * @param {boolean} [options.chain=true] Specify whether the functions added\n * are chainable.\n * @returns {Function|Object} Returns `object`.\n * @example\n *\n * function vowels(string) {\n * return _.filter(string, function(v) {\n * return /[aeiou]/i.test(v);\n * });\n * }\n *\n * _.mixin({ 'vowels': vowels });\n * _.vowels('fred');\n * // => ['e']\n *\n * _('fred').vowels().value();\n * // => ['e']\n *\n * _.mixin({ 'vowels': vowels }, { 'chain': false });\n * _('fred').vowels();\n * // => ['e']\n */\n function mixin(object, source, options) {\n if (options == null) {\n var isObj = isObject(source),\n props = isObj ? keys(source) : undefined,\n methodNames = (props && props.length) ? baseFunctions(source, props) : undefined;\n\n if (!(methodNames ? methodNames.length : isObj)) {\n methodNames = false;\n options = source;\n source = object;\n object = this;\n }\n }\n if (!methodNames) {\n methodNames = baseFunctions(source, keys(source));\n }\n var chain = true,\n index = -1,\n isFunc = isFunction(object),\n length = methodNames.length;\n\n if (options === false) {\n chain = false;\n } else if (isObject(options) && 'chain' in options) {\n chain = options.chain;\n }\n while (++index < length) {\n var methodName = methodNames[index],\n func = source[methodName];\n\n object[methodName] = func;\n if (isFunc) {\n object.prototype[methodName] = (function(func) {\n return function() {\n var chainAll = this.__chain__;\n if (chain || chainAll) {\n var result = object(this.__wrapped__),\n actions = result.__actions__ = arrayCopy(this.__actions__);\n\n actions.push({ 'func': func, 'args': arguments, 'thisArg': object });\n result.__chain__ = chainAll;\n return result;\n }\n return func.apply(object, arrayPush([this.value()], arguments));\n };\n }(func));\n }\n }\n return object;\n }\n\n /**\n * Reverts the `_` variable to its previous value and returns a reference to\n * the `lodash` function.\n *\n * @static\n * @memberOf _\n * @category Utility\n * @returns {Function} Returns the `lodash` function.\n * @example\n *\n * var lodash = _.noConflict();\n */\n function noConflict() {\n root._ = oldDash;\n return this;\n }\n\n /**\n * A no-operation function that returns `undefined` regardless of the\n * arguments it receives.\n *\n * @static\n * @memberOf _\n * @category Utility\n * @example\n *\n * var object = { 'user': 'fred' };\n *\n * _.noop(object) === undefined;\n * // => true\n */\n function noop() {\n // No operation performed.\n }\n\n /**\n * Creates a function that returns the property value at `path` on a\n * given object.\n *\n * @static\n * @memberOf _\n * @category Utility\n * @param {Array|string} path The path of the property to get.\n * @returns {Function} Returns the new function.\n * @example\n *\n * var objects = [\n * { 'a': { 'b': { 'c': 2 } } },\n * { 'a': { 'b': { 'c': 1 } } }\n * ];\n *\n * _.map(objects, _.property('a.b.c'));\n * // => [2, 1]\n *\n * _.pluck(_.sortBy(objects, _.property(['a', 'b', 'c'])), 'a.b.c');\n * // => [1, 2]\n */\n function property(path) {\n return isKey(path) ? baseProperty(path) : basePropertyDeep(path);\n }\n\n /**\n * The opposite of `_.property`; this method creates a function that returns\n * the property value at a given path on `object`.\n *\n * @static\n * @memberOf _\n * @category Utility\n * @param {Object} object The object to query.\n * @returns {Function} Returns the new function.\n * @example\n *\n * var array = [0, 1, 2],\n * object = { 'a': array, 'b': array, 'c': array };\n *\n * _.map(['a[2]', 'c[0]'], _.propertyOf(object));\n * // => [2, 0]\n *\n * _.map([['a', '2'], ['c', '0']], _.propertyOf(object));\n * // => [2, 0]\n */\n function propertyOf(object) {\n return function(path) {\n return baseGet(object, toPath(path), path + '');\n };\n }\n\n /**\n * Creates an array of numbers (positive and/or negative) progressing from\n * `start` up to, but not including, `end`. If `end` is not specified it is\n * set to `start` with `start` then set to `0`. If `end` is less than `start`\n * a zero-length range is created unless a negative `step` is specified.\n *\n * @static\n * @memberOf _\n * @category Utility\n * @param {number} [start=0] The start of the range.\n * @param {number} end The end of the range.\n * @param {number} [step=1] The value to increment or decrement by.\n * @returns {Array} Returns the new array of numbers.\n * @example\n *\n * _.range(4);\n * // => [0, 1, 2, 3]\n *\n * _.range(1, 5);\n * // => [1, 2, 3, 4]\n *\n * _.range(0, 20, 5);\n * // => [0, 5, 10, 15]\n *\n * _.range(0, -4, -1);\n * // => [0, -1, -2, -3]\n *\n * _.range(1, 4, 0);\n * // => [1, 1, 1]\n *\n * _.range(0);\n * // => []\n */\n function range(start, end, step) {\n if (step && isIterateeCall(start, end, step)) {\n end = step = undefined;\n }\n start = +start || 0;\n step = step == null ? 1 : (+step || 0);\n\n if (end == null) {\n end = start;\n start = 0;\n } else {\n end = +end || 0;\n }\n // Use `Array(length)` so engines like Chakra and V8 avoid slower modes.\n // See https://youtu.be/XAqIpGU8ZZk#t=17m25s for more details.\n var index = -1,\n length = nativeMax(nativeCeil((end - start) / (step || 1)), 0),\n result = Array(length);\n\n while (++index < length) {\n result[index] = start;\n start += step;\n }\n return result;\n }\n\n /**\n * Invokes the iteratee function `n` times, returning an array of the results\n * of each invocation. The `iteratee` is bound to `thisArg` and invoked with\n * one argument; (index).\n *\n * @static\n * @memberOf _\n * @category Utility\n * @param {number} n The number of times to invoke `iteratee`.\n * @param {Function} [iteratee=_.identity] The function invoked per iteration.\n * @param {*} [thisArg] The `this` binding of `iteratee`.\n * @returns {Array} Returns the array of results.\n * @example\n *\n * var diceRolls = _.times(3, _.partial(_.random, 1, 6, false));\n * // => [3, 6, 4]\n *\n * _.times(3, function(n) {\n * mage.castSpell(n);\n * });\n * // => invokes `mage.castSpell(n)` three times with `n` of `0`, `1`, and `2`\n *\n * _.times(3, function(n) {\n * this.cast(n);\n * }, mage);\n * // => also invokes `mage.castSpell(n)` three times\n */\n function times(n, iteratee, thisArg) {\n n = nativeFloor(n);\n\n // Exit early to avoid a JSC JIT bug in Safari 8\n // where `Array(0)` is treated as `Array(1)`.\n if (n < 1 || !nativeIsFinite(n)) {\n return [];\n }\n var index = -1,\n result = Array(nativeMin(n, MAX_ARRAY_LENGTH));\n\n iteratee = bindCallback(iteratee, thisArg, 1);\n while (++index < n) {\n if (index < MAX_ARRAY_LENGTH) {\n result[index] = iteratee(index);\n } else {\n iteratee(index);\n }\n }\n return result;\n }\n\n /**\n * Generates a unique ID. If `prefix` is provided the ID is appended to it.\n *\n * @static\n * @memberOf _\n * @category Utility\n * @param {string} [prefix] The value to prefix the ID with.\n * @returns {string} Returns the unique ID.\n * @example\n *\n * _.uniqueId('contact_');\n * // => 'contact_104'\n *\n * _.uniqueId();\n * // => '105'\n */\n function uniqueId(prefix) {\n var id = ++idCounter;\n return baseToString(prefix) + id;\n }\n\n /*------------------------------------------------------------------------*/\n\n /**\n * Adds two numbers.\n *\n * @static\n * @memberOf _\n * @category Math\n * @param {number} augend The first number to add.\n * @param {number} addend The second number to add.\n * @returns {number} Returns the sum.\n * @example\n *\n * _.add(6, 4);\n * // => 10\n */\n function add(augend, addend) {\n return (+augend || 0) + (+addend || 0);\n }\n\n /**\n * Calculates `n` rounded up to `precision`.\n *\n * @static\n * @memberOf _\n * @category Math\n * @param {number} n The number to round up.\n * @param {number} [precision=0] The precision to round up to.\n * @returns {number} Returns the rounded up number.\n * @example\n *\n * _.ceil(4.006);\n * // => 5\n *\n * _.ceil(6.004, 2);\n * // => 6.01\n *\n * _.ceil(6040, -2);\n * // => 6100\n */\n var ceil = createRound('ceil');\n\n /**\n * Calculates `n` rounded down to `precision`.\n *\n * @static\n * @memberOf _\n * @category Math\n * @param {number} n The number to round down.\n * @param {number} [precision=0] The precision to round down to.\n * @returns {number} Returns the rounded down number.\n * @example\n *\n * _.floor(4.006);\n * // => 4\n *\n * _.floor(0.046, 2);\n * // => 0.04\n *\n * _.floor(4060, -2);\n * // => 4000\n */\n var floor = createRound('floor');\n\n /**\n * Gets the maximum value of `collection`. If `collection` is empty or falsey\n * `-Infinity` is returned. If an iteratee function is provided it is invoked\n * for each value in `collection` to generate the criterion by which the value\n * is ranked. The `iteratee` is bound to `thisArg` and invoked with three\n * arguments: (value, index, collection).\n *\n * If a property name is provided for `iteratee` the created `_.property`\n * style callback returns the property value of the given element.\n *\n * If a value is also provided for `thisArg` the created `_.matchesProperty`\n * style callback returns `true` for elements that have a matching property\n * value, else `false`.\n *\n * If an object is provided for `iteratee` the created `_.matches` style\n * callback returns `true` for elements that have the properties of the given\n * object, else `false`.\n *\n * @static\n * @memberOf _\n * @category Math\n * @param {Array|Object|string} collection The collection to iterate over.\n * @param {Function|Object|string} [iteratee] The function invoked per iteration.\n * @param {*} [thisArg] The `this` binding of `iteratee`.\n * @returns {*} Returns the maximum value.\n * @example\n *\n * _.max([4, 2, 8, 6]);\n * // => 8\n *\n * _.max([]);\n * // => -Infinity\n *\n * var users = [\n * { 'user': 'barney', 'age': 36 },\n * { 'user': 'fred', 'age': 40 }\n * ];\n *\n * _.max(users, function(chr) {\n * return chr.age;\n * });\n * // => { 'user': 'fred', 'age': 40 }\n *\n * // using the `_.property` callback shorthand\n * _.max(users, 'age');\n * // => { 'user': 'fred', 'age': 40 }\n */\n var max = createExtremum(gt, NEGATIVE_INFINITY);\n\n /**\n * Gets the minimum value of `collection`. If `collection` is empty or falsey\n * `Infinity` is returned. If an iteratee function is provided it is invoked\n * for each value in `collection` to generate the criterion by which the value\n * is ranked. The `iteratee` is bound to `thisArg` and invoked with three\n * arguments: (value, index, collection).\n *\n * If a property name is provided for `iteratee` the created `_.property`\n * style callback returns the property value of the given element.\n *\n * If a value is also provided for `thisArg` the created `_.matchesProperty`\n * style callback returns `true` for elements that have a matching property\n * value, else `false`.\n *\n * If an object is provided for `iteratee` the created `_.matches` style\n * callback returns `true` for elements that have the properties of the given\n * object, else `false`.\n *\n * @static\n * @memberOf _\n * @category Math\n * @param {Array|Object|string} collection The collection to iterate over.\n * @param {Function|Object|string} [iteratee] The function invoked per iteration.\n * @param {*} [thisArg] The `this` binding of `iteratee`.\n * @returns {*} Returns the minimum value.\n * @example\n *\n * _.min([4, 2, 8, 6]);\n * // => 2\n *\n * _.min([]);\n * // => Infinity\n *\n * var users = [\n * { 'user': 'barney', 'age': 36 },\n * { 'user': 'fred', 'age': 40 }\n * ];\n *\n * _.min(users, function(chr) {\n * return chr.age;\n * });\n * // => { 'user': 'barney', 'age': 36 }\n *\n * // using the `_.property` callback shorthand\n * _.min(users, 'age');\n * // => { 'user': 'barney', 'age': 36 }\n */\n var min = createExtremum(lt, POSITIVE_INFINITY);\n\n /**\n * Calculates `n` rounded to `precision`.\n *\n * @static\n * @memberOf _\n * @category Math\n * @param {number} n The number to round.\n * @param {number} [precision=0] The precision to round to.\n * @returns {number} Returns the rounded number.\n * @example\n *\n * _.round(4.006);\n * // => 4\n *\n * _.round(4.006, 2);\n * // => 4.01\n *\n * _.round(4060, -2);\n * // => 4100\n */\n var round = createRound('round');\n\n /**\n * Gets the sum of the values in `collection`.\n *\n * @static\n * @memberOf _\n * @category Math\n * @param {Array|Object|string} collection The collection to iterate over.\n * @param {Function|Object|string} [iteratee] The function invoked per iteration.\n * @param {*} [thisArg] The `this` binding of `iteratee`.\n * @returns {number} Returns the sum.\n * @example\n *\n * _.sum([4, 6]);\n * // => 10\n *\n * _.sum({ 'a': 4, 'b': 6 });\n * // => 10\n *\n * var objects = [\n * { 'n': 4 },\n * { 'n': 6 }\n * ];\n *\n * _.sum(objects, function(object) {\n * return object.n;\n * });\n * // => 10\n *\n * // using the `_.property` callback shorthand\n * _.sum(objects, 'n');\n * // => 10\n */\n function sum(collection, iteratee, thisArg) {\n if (thisArg && isIterateeCall(collection, iteratee, thisArg)) {\n iteratee = undefined;\n }\n iteratee = getCallback(iteratee, thisArg, 3);\n return iteratee.length == 1\n ? arraySum(isArray(collection) ? collection : toIterable(collection), iteratee)\n : baseSum(collection, iteratee);\n }\n\n /*------------------------------------------------------------------------*/\n\n // Ensure wrappers are instances of `baseLodash`.\n lodash.prototype = baseLodash.prototype;\n\n LodashWrapper.prototype = baseCreate(baseLodash.prototype);\n LodashWrapper.prototype.constructor = LodashWrapper;\n\n LazyWrapper.prototype = baseCreate(baseLodash.prototype);\n LazyWrapper.prototype.constructor = LazyWrapper;\n\n // Add functions to the `Map` cache.\n MapCache.prototype['delete'] = mapDelete;\n MapCache.prototype.get = mapGet;\n MapCache.prototype.has = mapHas;\n MapCache.prototype.set = mapSet;\n\n // Add functions to the `Set` cache.\n SetCache.prototype.push = cachePush;\n\n // Assign cache to `_.memoize`.\n memoize.Cache = MapCache;\n\n // Add functions that return wrapped values when chaining.\n lodash.after = after;\n lodash.ary = ary;\n lodash.assign = assign;\n lodash.at = at;\n lodash.before = before;\n lodash.bind = bind;\n lodash.bindAll = bindAll;\n lodash.bindKey = bindKey;\n lodash.callback = callback;\n lodash.chain = chain;\n lodash.chunk = chunk;\n lodash.compact = compact;\n lodash.constant = constant;\n lodash.countBy = countBy;\n lodash.create = create;\n lodash.curry = curry;\n lodash.curryRight = curryRight;\n lodash.debounce = debounce;\n lodash.defaults = defaults;\n lodash.defaultsDeep = defaultsDeep;\n lodash.defer = defer;\n lodash.delay = delay;\n lodash.difference = difference;\n lodash.drop = drop;\n lodash.dropRight = dropRight;\n lodash.dropRightWhile = dropRightWhile;\n lodash.dropWhile = dropWhile;\n lodash.fill = fill;\n lodash.filter = filter;\n lodash.flatten = flatten;\n lodash.flattenDeep = flattenDeep;\n lodash.flow = flow;\n lodash.flowRight = flowRight;\n lodash.forEach = forEach;\n lodash.forEachRight = forEachRight;\n lodash.forIn = forIn;\n lodash.forInRight = forInRight;\n lodash.forOwn = forOwn;\n lodash.forOwnRight = forOwnRight;\n lodash.functions = functions;\n lodash.groupBy = groupBy;\n lodash.indexBy = indexBy;\n lodash.initial = initial;\n lodash.intersection = intersection;\n lodash.invert = invert;\n lodash.invoke = invoke;\n lodash.keys = keys;\n lodash.keysIn = keysIn;\n lodash.map = map;\n lodash.mapKeys = mapKeys;\n lodash.mapValues = mapValues;\n lodash.matches = matches;\n lodash.matchesProperty = matchesProperty;\n lodash.memoize = memoize;\n lodash.merge = merge;\n lodash.method = method;\n lodash.methodOf = methodOf;\n lodash.mixin = mixin;\n lodash.modArgs = modArgs;\n lodash.negate = negate;\n lodash.omit = omit;\n lodash.once = once;\n lodash.pairs = pairs;\n lodash.partial = partial;\n lodash.partialRight = partialRight;\n lodash.partition = partition;\n lodash.pick = pick;\n lodash.pluck = pluck;\n lodash.property = property;\n lodash.propertyOf = propertyOf;\n lodash.pull = pull;\n lodash.pullAt = pullAt;\n lodash.range = range;\n lodash.rearg = rearg;\n lodash.reject = reject;\n lodash.remove = remove;\n lodash.rest = rest;\n lodash.restParam = restParam;\n lodash.set = set;\n lodash.shuffle = shuffle;\n lodash.slice = slice;\n lodash.sortBy = sortBy;\n lodash.sortByAll = sortByAll;\n lodash.sortByOrder = sortByOrder;\n lodash.spread = spread;\n lodash.take = take;\n lodash.takeRight = takeRight;\n lodash.takeRightWhile = takeRightWhile;\n lodash.takeWhile = takeWhile;\n lodash.tap = tap;\n lodash.throttle = throttle;\n lodash.thru = thru;\n lodash.times = times;\n lodash.toArray = toArray;\n lodash.toPlainObject = toPlainObject;\n lodash.transform = transform;\n lodash.union = union;\n lodash.uniq = uniq;\n lodash.unzip = unzip;\n lodash.unzipWith = unzipWith;\n lodash.values = values;\n lodash.valuesIn = valuesIn;\n lodash.where = where;\n lodash.without = without;\n lodash.wrap = wrap;\n lodash.xor = xor;\n lodash.zip = zip;\n lodash.zipObject = zipObject;\n lodash.zipWith = zipWith;\n\n // Add aliases.\n lodash.backflow = flowRight;\n lodash.collect = map;\n lodash.compose = flowRight;\n lodash.each = forEach;\n lodash.eachRight = forEachRight;\n lodash.extend = assign;\n lodash.iteratee = callback;\n lodash.methods = functions;\n lodash.object = zipObject;\n lodash.select = filter;\n lodash.tail = rest;\n lodash.unique = uniq;\n\n // Add functions to `lodash.prototype`.\n mixin(lodash, lodash);\n\n /*------------------------------------------------------------------------*/\n\n // Add functions that return unwrapped values when chaining.\n lodash.add = add;\n lodash.attempt = attempt;\n lodash.camelCase = camelCase;\n lodash.capitalize = capitalize;\n lodash.ceil = ceil;\n lodash.clone = clone;\n lodash.cloneDeep = cloneDeep;\n lodash.deburr = deburr;\n lodash.endsWith = endsWith;\n lodash.escape = escape;\n lodash.escapeRegExp = escapeRegExp;\n lodash.every = every;\n lodash.find = find;\n lodash.findIndex = findIndex;\n lodash.findKey = findKey;\n lodash.findLast = findLast;\n lodash.findLastIndex = findLastIndex;\n lodash.findLastKey = findLastKey;\n lodash.findWhere = findWhere;\n lodash.first = first;\n lodash.floor = floor;\n lodash.get = get;\n lodash.gt = gt;\n lodash.gte = gte;\n lodash.has = has;\n lodash.identity = identity;\n lodash.includes = includes;\n lodash.indexOf = indexOf;\n lodash.inRange = inRange;\n lodash.isArguments = isArguments;\n lodash.isArray = isArray;\n lodash.isBoolean = isBoolean;\n lodash.isDate = isDate;\n lodash.isElement = isElement;\n lodash.isEmpty = isEmpty;\n lodash.isEqual = isEqual;\n lodash.isError = isError;\n lodash.isFinite = isFinite;\n lodash.isFunction = isFunction;\n lodash.isMatch = isMatch;\n lodash.isNaN = isNaN;\n lodash.isNative = isNative;\n lodash.isNull = isNull;\n lodash.isNumber = isNumber;\n lodash.isObject = isObject;\n lodash.isPlainObject = isPlainObject;\n lodash.isRegExp = isRegExp;\n lodash.isString = isString;\n lodash.isTypedArray = isTypedArray;\n lodash.isUndefined = isUndefined;\n lodash.kebabCase = kebabCase;\n lodash.last = last;\n lodash.lastIndexOf = lastIndexOf;\n lodash.lt = lt;\n lodash.lte = lte;\n lodash.max = max;\n lodash.min = min;\n lodash.noConflict = noConflict;\n lodash.noop = noop;\n lodash.now = now;\n lodash.pad = pad;\n lodash.padLeft = padLeft;\n lodash.padRight = padRight;\n lodash.parseInt = parseInt;\n lodash.random = random;\n lodash.reduce = reduce;\n lodash.reduceRight = reduceRight;\n lodash.repeat = repeat;\n lodash.result = result;\n lodash.round = round;\n lodash.runInContext = runInContext;\n lodash.size = size;\n lodash.snakeCase = snakeCase;\n lodash.some = some;\n lodash.sortedIndex = sortedIndex;\n lodash.sortedLastIndex = sortedLastIndex;\n lodash.startCase = startCase;\n lodash.startsWith = startsWith;\n lodash.sum = sum;\n lodash.template = template;\n lodash.trim = trim;\n lodash.trimLeft = trimLeft;\n lodash.trimRight = trimRight;\n lodash.trunc = trunc;\n lodash.unescape = unescape;\n lodash.uniqueId = uniqueId;\n lodash.words = words;\n\n // Add aliases.\n lodash.all = every;\n lodash.any = some;\n lodash.contains = includes;\n lodash.eq = isEqual;\n lodash.detect = find;\n lodash.foldl = reduce;\n lodash.foldr = reduceRight;\n lodash.head = first;\n lodash.include = includes;\n lodash.inject = reduce;\n\n mixin(lodash, (function() {\n var source = {};\n baseForOwn(lodash, function(func, methodName) {\n if (!lodash.prototype[methodName]) {\n source[methodName] = func;\n }\n });\n return source;\n }()), false);\n\n /*------------------------------------------------------------------------*/\n\n // Add functions capable of returning wrapped and unwrapped values when chaining.\n lodash.sample = sample;\n\n lodash.prototype.sample = function(n) {\n if (!this.__chain__ && n == null) {\n return sample(this.value());\n }\n return this.thru(function(value) {\n return sample(value, n);\n });\n };\n\n /*------------------------------------------------------------------------*/\n\n /**\n * The semantic version number.\n *\n * @static\n * @memberOf _\n * @type string\n */\n lodash.VERSION = VERSION;\n\n // Assign default placeholders.\n arrayEach(['bind', 'bindKey', 'curry', 'curryRight', 'partial', 'partialRight'], function(methodName) {\n lodash[methodName].placeholder = lodash;\n });\n\n // Add `LazyWrapper` methods for `_.drop` and `_.take` variants.\n arrayEach(['drop', 'take'], function(methodName, index) {\n LazyWrapper.prototype[methodName] = function(n) {\n var filtered = this.__filtered__;\n if (filtered && !index) {\n return new LazyWrapper(this);\n }\n n = n == null ? 1 : nativeMax(nativeFloor(n) || 0, 0);\n\n var result = this.clone();\n if (filtered) {\n result.__takeCount__ = nativeMin(result.__takeCount__, n);\n } else {\n result.__views__.push({ 'size': n, 'type': methodName + (result.__dir__ < 0 ? 'Right' : '') });\n }\n return result;\n };\n\n LazyWrapper.prototype[methodName + 'Right'] = function(n) {\n return this.reverse()[methodName](n).reverse();\n };\n });\n\n // Add `LazyWrapper` methods that accept an `iteratee` value.\n arrayEach(['filter', 'map', 'takeWhile'], function(methodName, index) {\n var type = index + 1,\n isFilter = type != LAZY_MAP_FLAG;\n\n LazyWrapper.prototype[methodName] = function(iteratee, thisArg) {\n var result = this.clone();\n result.__iteratees__.push({ 'iteratee': getCallback(iteratee, thisArg, 1), 'type': type });\n result.__filtered__ = result.__filtered__ || isFilter;\n return result;\n };\n });\n\n // Add `LazyWrapper` methods for `_.first` and `_.last`.\n arrayEach(['first', 'last'], function(methodName, index) {\n var takeName = 'take' + (index ? 'Right' : '');\n\n LazyWrapper.prototype[methodName] = function() {\n return this[takeName](1).value()[0];\n };\n });\n\n // Add `LazyWrapper` methods for `_.initial` and `_.rest`.\n arrayEach(['initial', 'rest'], function(methodName, index) {\n var dropName = 'drop' + (index ? '' : 'Right');\n\n LazyWrapper.prototype[methodName] = function() {\n return this.__filtered__ ? new LazyWrapper(this) : this[dropName](1);\n };\n });\n\n // Add `LazyWrapper` methods for `_.pluck` and `_.where`.\n arrayEach(['pluck', 'where'], function(methodName, index) {\n var operationName = index ? 'filter' : 'map',\n createCallback = index ? baseMatches : property;\n\n LazyWrapper.prototype[methodName] = function(value) {\n return this[operationName](createCallback(value));\n };\n });\n\n LazyWrapper.prototype.compact = function() {\n return this.filter(identity);\n };\n\n LazyWrapper.prototype.reject = function(predicate, thisArg) {\n predicate = getCallback(predicate, thisArg, 1);\n return this.filter(function(value) {\n return !predicate(value);\n });\n };\n\n LazyWrapper.prototype.slice = function(start, end) {\n start = start == null ? 0 : (+start || 0);\n\n var result = this;\n if (result.__filtered__ && (start > 0 || end < 0)) {\n return new LazyWrapper(result);\n }\n if (start < 0) {\n result = result.takeRight(-start);\n } else if (start) {\n result = result.drop(start);\n }\n if (end !== undefined) {\n end = (+end || 0);\n result = end < 0 ? result.dropRight(-end) : result.take(end - start);\n }\n return result;\n };\n\n LazyWrapper.prototype.takeRightWhile = function(predicate, thisArg) {\n return this.reverse().takeWhile(predicate, thisArg).reverse();\n };\n\n LazyWrapper.prototype.toArray = function() {\n return this.take(POSITIVE_INFINITY);\n };\n\n // Add `LazyWrapper` methods to `lodash.prototype`.\n baseForOwn(LazyWrapper.prototype, function(func, methodName) {\n var checkIteratee = /^(?:filter|map|reject)|While$/.test(methodName),\n retUnwrapped = /^(?:first|last)$/.test(methodName),\n lodashFunc = lodash[retUnwrapped ? ('take' + (methodName == 'last' ? 'Right' : '')) : methodName];\n\n if (!lodashFunc) {\n return;\n }\n lodash.prototype[methodName] = function() {\n var args = retUnwrapped ? [1] : arguments,\n chainAll = this.__chain__,\n value = this.__wrapped__,\n isHybrid = !!this.__actions__.length,\n isLazy = value instanceof LazyWrapper,\n iteratee = args[0],\n useLazy = isLazy || isArray(value);\n\n if (useLazy && checkIteratee && typeof iteratee == 'function' && iteratee.length != 1) {\n // Avoid lazy use if the iteratee has a \"length\" value other than `1`.\n isLazy = useLazy = false;\n }\n var interceptor = function(value) {\n return (retUnwrapped && chainAll)\n ? lodashFunc(value, 1)[0]\n : lodashFunc.apply(undefined, arrayPush([value], args));\n };\n\n var action = { 'func': thru, 'args': [interceptor], 'thisArg': undefined },\n onlyLazy = isLazy && !isHybrid;\n\n if (retUnwrapped && !chainAll) {\n if (onlyLazy) {\n value = value.clone();\n value.__actions__.push(action);\n return func.call(value);\n }\n return lodashFunc.call(undefined, this.value())[0];\n }\n if (!retUnwrapped && useLazy) {\n value = onlyLazy ? value : new LazyWrapper(this);\n var result = func.apply(value, args);\n result.__actions__.push(action);\n return new LodashWrapper(result, chainAll);\n }\n return this.thru(interceptor);\n };\n });\n\n // Add `Array` and `String` methods to `lodash.prototype`.\n arrayEach(['join', 'pop', 'push', 'replace', 'shift', 'sort', 'splice', 'split', 'unshift'], function(methodName) {\n var func = (/^(?:replace|split)$/.test(methodName) ? stringProto : arrayProto)[methodName],\n chainName = /^(?:push|sort|unshift)$/.test(methodName) ? 'tap' : 'thru',\n retUnwrapped = /^(?:join|pop|replace|shift)$/.test(methodName);\n\n lodash.prototype[methodName] = function() {\n var args = arguments;\n if (retUnwrapped && !this.__chain__) {\n return func.apply(this.value(), args);\n }\n return this[chainName](function(value) {\n return func.apply(value, args);\n });\n };\n });\n\n // Map minified function names to their real names.\n baseForOwn(LazyWrapper.prototype, function(func, methodName) {\n var lodashFunc = lodash[methodName];\n if (lodashFunc) {\n var key = lodashFunc.name,\n names = realNames[key] || (realNames[key] = []);\n\n names.push({ 'name': methodName, 'func': lodashFunc });\n }\n });\n\n realNames[createHybridWrapper(undefined, BIND_KEY_FLAG).name] = [{ 'name': 'wrapper', 'func': undefined }];\n\n // Add functions to the lazy wrapper.\n LazyWrapper.prototype.clone = lazyClone;\n LazyWrapper.prototype.reverse = lazyReverse;\n LazyWrapper.prototype.value = lazyValue;\n\n // Add chaining functions to the `lodash` wrapper.\n lodash.prototype.chain = wrapperChain;\n lodash.prototype.commit = wrapperCommit;\n lodash.prototype.concat = wrapperConcat;\n lodash.prototype.plant = wrapperPlant;\n lodash.prototype.reverse = wrapperReverse;\n lodash.prototype.toString = wrapperToString;\n lodash.prototype.run = lodash.prototype.toJSON = lodash.prototype.valueOf = lodash.prototype.value = wrapperValue;\n\n // Add function aliases to the `lodash` wrapper.\n lodash.prototype.collect = lodash.prototype.map;\n lodash.prototype.head = lodash.prototype.first;\n lodash.prototype.select = lodash.prototype.filter;\n lodash.prototype.tail = lodash.prototype.rest;\n\n return lodash;\n }\n\n /*--------------------------------------------------------------------------*/\n\n // Export lodash.\n var _ = runInContext();\n\n // Some AMD build optimizers like r.js check for condition patterns like the following:\n if (true) {\n // Expose lodash to the global object when an AMD loader is present to avoid\n // errors in cases where lodash is loaded by a script tag and not intended\n // as an AMD module. See http://requirejs.org/docs/errors.html#mismatch for\n // more details.\n root._ = _;\n\n // Define as an anonymous module so, through path mapping, it can be\n // referenced as the \"underscore\" module.\n !(__WEBPACK_AMD_DEFINE_RESULT__ = function() {\n return _;\n }.call(exports, __webpack_require__, exports, module), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));\n }\n // Check for `exports` after `define` in case a build optimizer adds an `exports` object.\n else if (freeExports && freeModule) {\n // Export for Node.js or RingoJS.\n if (moduleExports) {\n (freeModule.exports = _)._ = _;\n }\n // Export for Rhino with CommonJS support.\n else {\n freeExports._ = _;\n }\n }\n else {\n // Export for a browser or Rhino.\n root._ = _;\n }\n}.call(this));\n\n/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(5)(module), (function() { return this; }())))\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/lodash/index.js\n ** module id = 116\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/lodash/index.js?");
  8. },function(module,exports,__webpack_require__){eval("var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/* WEBPACK VAR INJECTION */(function(module, global) {// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.\n\r\n;(function (factory) {\n var objectTypes = {\n 'boolean': false,\n 'function': true,\n 'object': true,\n 'number': false,\n 'string': false,\n 'undefined': false\n };\n\n var root = (objectTypes[typeof window] && window) || this,\n freeExports = objectTypes[typeof exports] && exports && !exports.nodeType && exports,\n freeModule = objectTypes[typeof module] && module && !module.nodeType && module,\n moduleExports = freeModule && freeModule.exports === freeExports && freeExports,\n freeGlobal = objectTypes[typeof global] && global;\n\n if (freeGlobal && (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal)) {\n root = freeGlobal;\n }\n\n // Because of build optimizers\n if (true) {\n !(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(118), exports], __WEBPACK_AMD_DEFINE_RESULT__ = function (Rx, exports) {\n root.Rx = factory(root, exports, Rx);\n return root.Rx;\n }.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));\n } else if (typeof module === 'object' && module && module.exports === freeExports) {\n module.exports = factory(root, module.exports, require('rx'));\n } else {\n root.Rx = factory(root, {}, root.Rx);\n }\n}.call(this, function (root, exp, Rx, undefined) {\n\r\n var Observable = Rx.Observable,\n observableProto = Observable.prototype,\n AnonymousObservable = Rx.AnonymousObservable,\n observerCreate = Rx.Observer.create,\n disposableCreate = Rx.Disposable.create,\n CompositeDisposable = Rx.CompositeDisposable,\n SingleAssignmentDisposable = Rx.SingleAssignmentDisposable,\n AsyncSubject = Rx.AsyncSubject,\n Subject = Rx.Subject,\n Scheduler = Rx.Scheduler,\n defaultNow = (function () { return !!Date.now ? Date.now : function () { return +new Date; }; }()),\n dom = Rx.DOM = {},\n hasOwnProperty = {}.hasOwnProperty,\n noop = Rx.helpers.noop,\n isFunction = Rx.helpers.isFunction;\n\r\n function createListener (element, name, handler, useCapture) {\n if (element.addEventListener) {\n element.addEventListener(name, handler, useCapture);\n return disposableCreate(function () {\n element.removeEventListener(name, handler, useCapture);\n });\n }\n throw new Error('No listener found');\n }\n\n function createEventListener (el, eventName, handler, useCapture) {\n var disposables = new CompositeDisposable();\n\n // Asume NodeList or HTMLCollection\n var toStr = Object.prototype.toString;\n if (toStr.call(el) === '[object NodeList]' || toStr.call(el) === '[object HTMLCollection]') {\n for (var i = 0, len = el.length; i < len; i++) {\n disposables.add(createEventListener(el.item(i), eventName, handler, useCapture));\n }\n } else if (el) {\n disposables.add(createListener(el, eventName, handler, useCapture));\n }\n return disposables;\n }\n\n /**\n * Creates an observable sequence by adding an event listener to the matching DOMElement or each item in the NodeList.\n * @param {Object} element The DOMElement or NodeList to attach a listener.\n * @param {String} eventName The event name to attach the observable sequence.\n * @param {Function} [selector] A selector which takes the arguments from the event handler to produce a single item to yield on next.\n * @param {Boolean} [useCapture] If true, useCapture indicates that the user wishes to initiate capture. After initiating capture, all events of the specified type will be dispatched to the registered listener before being dispatched to any EventTarget beneath it in the DOM tree. Events which are bubbling upward through the tree will not trigger a listener designated to use capture\n * @returns {Observable} An observable sequence of events from the specified element and the specified event.\n */\n var fromEvent = dom.fromEvent = function (element, eventName, selector, useCapture) {\n var selectorFn = isFunction(selector) ? selector : null;\n typeof selector === 'boolean' && (useCapture = selector);\n typeof useCapture === 'undefined' && (useCapture = false);\n return new AnonymousObservable(function (observer) {\n return createEventListener(\n element,\n eventName,\n function handler () {\n var results = arguments[0];\n\n if (selectorFn) {\n var results = tryCatch(selectorFn).apply(null, arguments);\n if (results === errorObj) { return observer.onError(results.e); }\n }\n\n observer.onNext(results);\n },\n useCapture);\n }).publish().refCount();\n };\n\r\n (function () {\n var events = \"blur focus focusin focusout load resize scroll unload click dblclick \" +\n \"mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave \" +\n \"change select submit keydown keypress keyup error contextmenu\";\n\n if (root.PointerEvent) {\n events += \" pointerdown pointerup pointermove pointerover pointerout pointerenter pointerleave\";\n }\n\n if (root.TouchEvent) {\n events += \" touchstart touchend touchmove touchcancel\";\n }\n\n events = events.split(' ');\n\n for(var i = 0, len = events.length; i < len; i++) {\n (function (e) {\n dom[e] = function (element, selector, useCapture) {\n return fromEvent(element, e, selector, useCapture);\n };\n }(events[i]))\n }\n }());\n\r\n /**\n * Creates an observable sequence when the DOM is loaded\n * @returns {Observable} An observable sequence fired when the DOM is loaded\n */\n dom.ready = function () {\n return new AnonymousObservable(function (observer) {\n var addedHandlers = false;\n\n function handler () {\n observer.onNext();\n observer.onCompleted();\n }\n\n if (document.readyState === 'complete') {\n setTimeout(handler, 0);\n } else {\n addedHandlers = true;\n document.addEventListener( 'DOMContentLoaded', handler, false );\n root.addEventListener( 'load', handler, false );\n }\n\n return function () {\n if (!addedHandlers) { return; }\n document.removeEventListener( 'DOMContentLoaded', handler, false );\n root.removeEventListener( 'load', handler, false );\n };\n });\n };\n\r\n\n // Gets the proper XMLHttpRequest for support for older IE\n function getXMLHttpRequest() {\n if (root.XMLHttpRequest) {\n return new root.XMLHttpRequest();\n } else {\n var progId;\n try {\n var progIds = ['Msxml2.XMLHTTP', 'Microsoft.XMLHTTP', 'Msxml2.XMLHTTP.4.0'];\n for(var i = 0; i < 3; i++) {\n try {\n progId = progIds[i];\n if (new root.ActiveXObject(progId)) {\n break;\n }\n } catch(e) { }\n }\n return new root.ActiveXObject(progId);\n } catch (e) {\n throw new Error('XMLHttpRequest is not supported by your browser');\n }\n }\n }\n\n // Get CORS support even for older IE\n function getCORSRequest() {\n var xhr = new root.XMLHttpRequest();\n if ('withCredentials' in xhr) {\n return xhr;\n } else if (!!root.XDomainRequest) {\n return new XDomainRequest();\n } else {\n throw new Error('CORS is not supported by your browser');\n }\n }\n\nfunction normalizeAjaxLoadEvent(e, xhr, settings) {\n var response = ('response' in xhr) ? xhr.response : xhr.responseText;\n response = settings.responseType === 'json' ? JSON.parse(response) : response;\n return {\n response: response,\n status: xhr.status,\n responseType: xhr.responseType,\n xhr: xhr,\n originalEvent: e\n };\n }\n\n function normalizeAjaxErrorEvent(e, xhr, type) {\n return {\n type: type,\n status: xhr.status,\n xhr: xhr,\n originalEvent: e\n };\n }\n\n /**\n * Creates an observable for an Ajax request with either a settings object with url, headers, etc or a string for a URL.\n *\n * @example\n * source = Rx.DOM.ajax('/products');\n * source = Rx.DOM.ajax( url: 'products', method: 'GET' });\n *\n * @param {Object} settings Can be one of the following:\n *\n * A string of the URL to make the Ajax call.\n * An object with the following properties\n * - url: URL of the request\n * - body: The body of the request\n * - method: Method of the request, such as GET, POST, PUT, PATCH, DELETE\n * - async: Whether the request is async\n * - headers: Optional headers\n * - crossDomain: true if a cross domain request, else false\n *\n * @returns {Observable} An observable sequence containing the XMLHttpRequest.\n */\n var ajaxRequest = dom.ajax = function (options) {\n var settings = {\n method: 'GET',\n crossDomain: false,\n contentType: 'application/x-www-form-urlencoded; charset=UTF-8',\n async: true,\n headers: {},\n responseType: 'text'\n };\n\n if(typeof options === 'string') {\n settings.url = options;\n } else {\n for(var prop in options) {\n if(hasOwnProperty.call(options, prop)) {\n settings[prop] = options[prop];\n }\n }\n }\n\n if (!settings.crossDomain && !settings.headers['X-Requested-With']) {\n settings.headers['X-Requested-With'] = 'XMLHttpRequest';\n }\n settings.hasContent = settings.body !== undefined;\n\n return new AnonymousObservable(function (observer) {\n var isDone = false;\n\n try {\n var xhr = settings.crossDomain ? getCORSRequest() : getXMLHttpRequest();\n } catch (err) {\n observer.onError(err);\n }\n\n try {\n if (settings.user) {\n xhr.open(settings.method, settings.url, settings.async, settings.user, settings.password);\n } else {\n xhr.open(settings.method, settings.url, settings.async);\n }\n\n var headers = settings.headers;\n for (var header in headers) {\n if (hasOwnProperty.call(headers, header)) {\n xhr.setRequestHeader(header, headers[header]);\n }\n }\n\n if(!!xhr.upload || (!('withCredentials' in xhr) && !!root.XDomainRequest)) {\n xhr.onload = function(e) {\n if(settings.progressObserver) {\n settings.progressObserver.onNext(e);\n settings.progressObserver.onCompleted();\n }\n observer.onNext(normalizeAjaxLoadEvent(e, xhr, settings));\n observer.onCompleted();\n isDone = true;\n };\n\n if(settings.progressObserver) {\n xhr.onprogress = function(e) {\n settings.progressObserver.onNext(e);\n };\n }\n\n xhr.onerror = function(e) {\n settings.progressObserver && settings.progressObserver.onError(e);\n observer.onError(normalizeAjaxErrorEvent(e, xhr, 'error'));\n isDone = true;\n };\n\n xhr.onabort = function(e) {\n settings.progressObserver && settings.progressObserver.onError(e);\n observer.onError(normalizeAjaxErrorEvent(e, xhr, 'abort'));\n isDone = true;\n };\n } else {\n\n xhr.onreadystatechange = function (e) {\n if (xhr.readyState === 4) {\n var status = xhr.status == 1223 ? 204 : xhr.status;\n if ((status >= 200 && status <= 300) || status === 0 || status === '') {\n observer.onNext(normalizeAjaxLoadEvent(e, xhr, settings));\n observer.onCompleted();\n } else {\n observer.onError(normalizeAjaxErrorEvent(e, xhr, 'error'));\n }\n isDone = true;\n }\n };\n }\n\n xhr.send(settings.hasContent && settings.body || null);\n } catch (e) {\n observer.onError(e);\n }\n\n return function () {\n if (!isDone && xhr.readyState !== 4) { xhr.abort(); }\n };\n });\n };\n\n /**\n * Creates an observable sequence from an Ajax POST Request with the body.\n *\n * @param {String} url The URL to POST\n * @param {Object} body The body to POST\n * @returns {Observable} The observable sequence which contains the response from the Ajax POST.\n */\n dom.post = function (url, body) {\n return ajaxRequest({ url: url, body: body, method: 'POST' });\n };\n\n /**\n * Creates an observable sequence from an Ajax GET Request with the body.\n *\n * @param {String} url The URL to GET\n * @returns {Observable} The observable sequence which contains the response from the Ajax GET.\n */\n var observableGet = dom.get = function (url) {\n return ajaxRequest({ url: url });\n };\n\n /**\n * Creates an observable sequence from JSON from an Ajax request\n *\n * @param {String} url The URL to GET\n * @returns {Observable} The observable sequence which contains the parsed JSON.\n */\n dom.getJSON = function (url) {\n if (!root.JSON && typeof root.JSON.parse !== 'function') { throw new TypeError('JSON is not supported in your runtime.'); }\n return ajaxRequest({url: url, responseType: 'json'}).map(function (x) {\n return x.response;\n });\n };\n\r\n /** @private\n * Destroys the current element\n */\n var destroy = (function () {\n var trash = document.createElement('div');\n return function (element) {\n trash.appendChild(element);\n trash.innerHTML = '';\n };\n })();\n\n /**\n * Creates an observable JSONP Request with the specified settings.\n * @param {Object} settings Can be one of the following:\n *\n * A string of the URL to make the JSONP call with the JSONPCallback=? in the url.\n * An object with the following properties\n * - url: URL of the request\n * - jsonp: The named callback parameter for the JSONP call\n * - jsonpCallback: Callback to execute. For when the JSONP callback can't be changed\n *\n * @returns {Observable} A cold observable containing the results from the JSONP call.\n */\n dom.jsonpRequest = (function() {\n var id = 0;\n\n return function(options) {\n return new AnonymousObservable(function(observer) {\n\n var callbackId = 'callback_' + (id++).toString(36);\n\n var settings = {\n jsonp: 'JSONPCallback',\n async: true,\n jsonpCallback: 'rxjsjsonpCallbacks' + callbackId\n };\n\n if(typeof options === 'string') {\n settings.url = options;\n } else {\n for(var prop in options) {\n if(hasOwnProperty.call(options, prop)) {\n settings[prop] = options[prop];\n }\n }\n }\n\n var script = document.createElement('script');\n script.type = 'text/javascript';\n script.async = settings.async;\n script.src = settings.url.replace(settings.jsonp, settings.jsonpCallback);\n\n root[settings.jsonpCallback] = function(data) {\n root[settings.jsonpCallback].called = true;\n root[settings.jsonpCallback].data = data;\n };\n\n var handler = function(e) {\n if(e.type === 'load' && !root[settings.jsonpCallback].called) {\n e = { type: 'error' };\n }\n var status = e.type === 'error' ? 400 : 200;\n var data = root[settings.jsonpCallback].data;\n\n if(status === 200) {\n observer.onNext({\n status: status,\n responseType: 'jsonp',\n response: data,\n originalEvent: e\n });\n\n observer.onCompleted();\n }\n else {\n observer.onError({\n type: 'error',\n status: status,\n originalEvent: e\n });\n }\n };\n\n script.onload = script.onreadystatechanged = script.onerror = handler;\n\n var head = document.getElementsByTagName('head')[0] || document.documentElement;\n head.insertBefore(script, head.firstChild);\n\n return function() {\n script.onload = script.onreadystatechanged = script.onerror = null;\n destroy(script);\n script = null;\n };\n });\n }\n }());\n\r\n /**\n * Creates a WebSocket Subject with a given URL, protocol and an optional observer for the open event.\n *\n * @example\n * var socket = Rx.DOM.fromWebSocket('http://localhost:8080', 'stock-protocol', openObserver, closingObserver);\n *\n * @param {String} url The URL of the WebSocket.\n * @param {String} protocol The protocol of the WebSocket.\n * @param {Observer} [openObserver] An optional Observer to capture the open event.\n * @param {Observer} [closingObserver] An optional Observer to capture the moment before the underlying socket is closed.\n * @returns {Subject} An observable sequence wrapping a WebSocket.\n */\n dom.fromWebSocket = function (url, protocol, openObserver, closingObserver) {\n if (!WebSocket) { throw new TypeError('WebSocket not implemented in your runtime.'); }\n\n var socket;\n\n function socketClose(code, reason) {\n if (socket) {\n if (closingObserver) {\n closingObserver.onNext();\n closingObserver.onCompleted();\n }\n if (!code) {\n socket.close();\n } else {\n socket.close(code, reason);\n }\n }\n }\n\n var observable = new AnonymousObservable(function (obs) {\n socket = protocol ? new WebSocket(url, protocol) : new WebSocket(url);\n\n function openHandler(e) {\n openObserver.onNext(e);\n openObserver.onCompleted();\n socket.removeEventListener('open', openHandler, false);\n }\n function messageHandler(e) { obs.onNext(e); }\n function errHandler(e) { obs.onError(e); }\n function closeHandler(e) {\n if (e.code !== 1000 || !e.wasClean) { return obs.onError(e); }\n obs.onCompleted();\n }\n\n openObserver && socket.addEventListener('open', openHandler, false);\n socket.addEventListener('message', messageHandler, false);\n socket.addEventListener('error', errHandler, false);\n socket.addEventListener('close', closeHandler, false);\n\n return function () {\n socketClose();\n\n socket.removeEventListener('message', messageHandler, false);\n socket.removeEventListener('error', errHandler, false);\n socket.removeEventListener('close', closeHandler, false);\n };\n });\n\n var observer = observerCreate(\n function (data) {\n socket && socket.readyState === WebSocket.OPEN && socket.send(data);\n },\n function(e) {\n if (!e.code) {\n throw new Error('no code specified. be sure to pass { code: ###, reason: \"\" } to onError()');\n }\n socketClose(e.code, e.reason || '');\n },\n function() {\n socketClose(1000, '');\n }\n );\n\n return Subject.create(observer, observable);\n };\n\r\n /**\n * Creates a Web Worker with a given URL as a Subject.\n *\n * @example\n * var worker = Rx.DOM.fromWebWorker('worker.js');\n *\n * @param {String} url The URL of the Web Worker.\n * @returns {Subject} A Subject wrapping the Web Worker.\n */\n dom.fromWebWorker = function (url) {\n if (!root.Worker) { throw new TypeError('Worker not implemented in your runtime.'); }\n var worker = new root.Worker(url);\n\n var observable = new AnonymousObservable(function (obs) {\n\n function messageHandler(data) { obs.onNext(data); }\n function errHandler(err) { obs.onError(err); }\n\n worker.addEventListener('message', messageHandler, false);\n worker.addEventListener('error', errHandler, false);\n\n return function () {\n worker.close();\n worker.removeEventListener('message', messageHandler, false);\n worker.removeEventListener('error', errHandler, false);\n };\n });\n\n var observer = observerCreate(function (data) {\n worker.postMessage(data);\n });\n\n return Subject.create(observer, observable);\n };\n\r\n /**\n * This method wraps an EventSource as an observable sequence.\n * @param {String} url The url of the server-side script.\n * @param {Observer} [openObserver] An optional observer for the 'open' event for the server side event.\n * @returns {Observable} An observable sequence which represents the data from a server-side event.\n */\n dom.fromEventSource = function (url, openObserver) {\n if (!root.EventSource) { throw new TypeError('EventSource not implemented in your runtime.'); }\n return new AnonymousObservable(function (observer) {\n var source = new root.EventSource(url);\n\n function onOpen(e) {\n openObserver.onNext(e);\n openObserver.onCompleted();\n source.removeEventListener('open', onOpen, false);\n }\n\n function onError(e) {\n if (e.readyState === EventSource.CLOSED) {\n observer.onCompleted();\n } else {\n observer.onError(e);\n }\n }\n\n function onMessage(e) {\n observer.onNext(e);\n }\n\n openObserver && source.addEventListener('open', onOpen, false);\n source.addEventListener('error', onError, false);\n source.addEventListener('message', onMessage, false);\n\n return function () {\n source.removeEventListener('error', onError, false);\n source.removeEventListener('message', onMessage, false);\n source.close();\n };\n });\n };\n\r\n /**\n * Creates an observable sequence from a Mutation Observer.\n * MutationObserver provides developers a way to react to changes in a DOM.\n * @example\n * Rx.DOM.fromMutationObserver(document.getElementById('foo'), { attributes: true, childList: true, characterData: true });\n *\n * @param {Object} target The Node on which to obserave DOM mutations.\n * @param {Object} options A MutationObserverInit object, specifies which DOM mutations should be reported.\n * @returns {Observable} An observable sequence which contains mutations on the given DOM target.\n */\n dom.fromMutationObserver = function (target, options) {\n var BrowserMutationObserver = root.MutationObserver || root.WebKitMutationObserver;\n if (!BrowserMutationObserver) { throw new TypeError('MutationObserver not implemented in your runtime.'); }\n return observableCreate(function (observer) {\n var mutationObserver = new BrowserMutationObserver(observer.onNext.bind(observer));\n mutationObserver.observe(target, options);\n\n return mutationObserver.disconnect.bind(mutationObserver);\n });\n };\n\r\n // Get the right animation frame method\n var requestAnimFrame, cancelAnimFrame;\n if (root.requestAnimationFrame) {\n requestAnimFrame = root.requestAnimationFrame;\n cancelAnimFrame = root.cancelAnimationFrame;\n } else if (root.mozRequestAnimationFrame) {\n requestAnimFrame = root.mozRequestAnimationFrame;\n cancelAnimFrame = root.mozCancelAnimationFrame;\n } else if (root.webkitRequestAnimationFrame) {\n requestAnimFrame = root.webkitRequestAnimationFrame;\n cancelAnimFrame = root.webkitCancelAnimationFrame;\n } else if (root.msRequestAnimationFrame) {\n requestAnimFrame = root.msRequestAnimationFrame;\n cancelAnimFrame = root.msCancelAnimationFrame;\n } else if (root.oRequestAnimationFrame) {\n requestAnimFrame = root.oRequestAnimationFrame;\n cancelAnimFrame = root.oCancelAnimationFrame;\n } else {\n requestAnimFrame = function(cb) { root.setTimeout(cb, 1000 / 60); };\n cancelAnimFrame = root.clearTimeout;\n }\n\n /**\n * Gets a scheduler that schedules schedules work on the requestAnimationFrame for immediate actions.\n */\n Scheduler.requestAnimationFrame = (function () {\n\n function scheduleNow(state, action) {\n var scheduler = this,\n disposable = new SingleAssignmentDisposable();\n var id = requestAnimFrame(function () {\n !disposable.isDisposed && (disposable.setDisposable(action(scheduler, state)));\n });\n return new CompositeDisposable(disposable, disposableCreate(function () {\n cancelAnimFrame(id);\n }));\n }\n\n function scheduleRelative(state, dueTime, action) {\n var scheduler = this, dt = Scheduler.normalize(dueTime);\n if (dt === 0) { return scheduler.scheduleWithState(state, action); }\n var disposable = new SingleAssignmentDisposable();\n var id = root.setTimeout(function () {\n if (!disposable.isDisposed) {\n disposable.setDisposable(action(scheduler, state));\n }\n }, dt);\n return new CompositeDisposable(disposable, disposableCreate(function () {\n root.clearTimeout(id);\n }));\n }\n\n function scheduleAbsolute(state, dueTime, action) {\n return this.scheduleWithRelativeAndState(state, dueTime - this.now(), action);\n }\n\n return new Scheduler(defaultNow, scheduleNow, scheduleRelative, scheduleAbsolute);\n\n }());\n\r\n /**\n * Scheduler that uses a MutationObserver changes as the scheduling mechanism\n */\n Scheduler.microtask = (function () {\n\n var nextHandle = 1, tasksByHandle = {}, currentlyRunning = false, scheduleMethod;\n\n function clearMethod(handle) {\n delete tasksByHandle[handle];\n }\n\n function runTask(handle) {\n if (currentlyRunning) {\n root.setTimeout(function () { runTask(handle) }, 0);\n } else {\n var task = tasksByHandle[handle];\n if (task) {\n currentlyRunning = true;\n try {\n task();\n } catch (e) {\n throw e;\n } finally {\n clearMethod(handle);\n currentlyRunning = false;\n }\n }\n }\n }\n\n function postMessageSupported () {\n // Ensure not in a worker\n if (!root.postMessage || root.importScripts) { return false; }\n var isAsync = false, oldHandler = root.onmessage;\n // Test for async\n root.onmessage = function () { isAsync = true; };\n root.postMessage('', '*');\n root.onmessage = oldHandler;\n\n return isAsync;\n }\n\n // Use in order, setImmediate, nextTick, postMessage, MessageChannel, script readystatechanged, setTimeout\n var BrowserMutationObserver = root.MutationObserver || root.WebKitMutationObserver;\n if (!!BrowserMutationObserver) {\n\n var PREFIX = 'drainqueue_';\n\n var observer = new BrowserMutationObserver(function(mutations) {\n mutations.forEach(function (mutation) {\n runTask(mutation.attributeName.substring(PREFIX.length));\n })\n });\n\n var element = document.createElement('div');\n observer.observe(element, { attributes: true });\n\n // Prevent leaks\n root.addEventListener('unload', function () {\n observer.disconnect();\n observer = null;\n }, false);\n\n scheduleMethod = function (action) {\n var id = nextHandle++;\n tasksByHandle[id] = action;\n element.setAttribute(PREFIX + id, 'drainQueue');\n return id;\n };\n } else if (typeof root.setImmediate === 'function') {\n scheduleMethod = function (action) {\n var id = nextHandle++;\n tasksByHandle[id] = action;\n root.setImmediate(function () {\n runTask(id);\n });\n\n return id;\n };\n } else if (postMessageSupported()) {\n var MSG_PREFIX = 'ms.rx.schedule' + Math.random();\n\n function onGlobalPostMessage(event) {\n // Only if we're a match to avoid any other global events\n if (typeof event.data === 'string' && event.data.substring(0, MSG_PREFIX.length) === MSG_PREFIX) {\n runTask(event.data.substring(MSG_PREFIX.length));\n }\n }\n\n if (root.addEventListener) {\n root.addEventListener('message', onGlobalPostMessage, false);\n } else if (root.attachEvent){\n root.attachEvent('onmessage', onGlobalPostMessage);\n }\n\n scheduleMethod = function (action) {\n var id = nextHandle++;\n tasksByHandle[currentId] = action;\n root.postMessage(MSG_PREFIX + currentId, '*');\n return id;\n };\n } else if (!!root.MessageChannel) {\n var channel = new root.MessageChannel();\n\n channel.port1.onmessage = function (event) {\n runTask(event.data);\n };\n\n scheduleMethod = function (action) {\n var id = nextHandle++;\n tasksByHandle[id] = action;\n channel.port2.postMessage(id);\n return id;\n };\n } else if ('document' in root && 'onreadystatechange' in root.document.createElement('script')) {\n\n scheduleMethod = function (action) {\n var scriptElement = root.document.createElement('script');\n var id = nextHandle++;\n tasksByHandle[id] = action;\n\n scriptElement.onreadystatechange = function () {\n runTask(id);\n scriptElement.onreadystatechange = null;\n scriptElement.parentNode.removeChild(scriptElement);\n scriptElement = null;\n };\n root.document.documentElement.appendChild(scriptElement);\n\n return id;\n };\n\n } else {\n scheduleMethod = function (action) {\n var id = nextHandle++;\n tasksByHandle[id] = action;\n root.setTimeout(function () {\n runTask(id);\n }, 0);\n\n return id;\n };\n }\n\n function scheduleNow(state, action) {\n\n var scheduler = this,\n disposable = new SingleAssignmentDisposable();\n\n var id = scheduleMethod(function () {\n !disposable.isDisposed && (disposable.setDisposable(action(scheduler, state)));\n });\n\n return new CompositeDisposable(disposable, disposableCreate(function () {\n clearMethod(id);\n }));\n }\n\n function scheduleRelative(state, dueTime, action) {\n var scheduler = this, dt = Scheduler.normalize(dueTime);\n if (dt === 0) { return scheduler.scheduleWithState(state, action); }\n var disposable = new SingleAssignmentDisposable();\n var id = root.setTimeout(function () {\n if (!disposable.isDisposed) {\n disposable.setDisposable(action(scheduler, state));\n }\n }, dt);\n return new CompositeDisposable(disposable, disposableCreate(function () {\n root.clearTimeout(id);\n }));\n }\n\n function scheduleAbsolute(state, dueTime, action) {\n return this.scheduleWithRelativeAndState(state, dueTime - this.now(), action);\n }\n\n return new Scheduler(defaultNow, scheduleNow, scheduleRelative, scheduleAbsolute);\n }());\n\r\n Rx.DOM.geolocation = {\n /**\n * Obtains the geographic position, in terms of latitude and longitude coordinates, of the device.\n * @param {Object} [geolocationOptions] An object literal to specify one or more of the following attributes and desired values:\n * - enableHighAccuracy: Specify true to obtain the most accurate position possible, or false to optimize in favor of performance and power consumption.\n * - timeout: An Integer value that indicates the time, in milliseconds, allowed for obtaining the position.\n * If timeout is Infinity, (the default value) the location request will not time out.\n * If timeout is zero (0) or negative, the results depend on the behavior of the location provider.\n * - maximumAge: An Integer value indicating the maximum age, in milliseconds, of cached position information.\n * If maximumAge is non-zero, and a cached position that is no older than maximumAge is available, the cached position is used instead of obtaining an updated location.\n * If maximumAge is zero (0), watchPosition always tries to obtain an updated position, even if a cached position is already available.\n * If maximumAge is Infinity, any cached position is used, regardless of its age, and watchPosition only tries to obtain an updated position if no cached position data exists.\n * @returns {Observable} An observable sequence with the geographical location of the device running the client.\n */\n getCurrentPosition: function (geolocationOptions) {\n if (!root.navigator && !root.navigation.geolocation) { throw new TypeError('geolocation not available'); }\n\n return new AnonymousObservable(function (observer) {\n root.navigator.geolocation.getCurrentPosition(\n function (data) {\n observer.onNext(data);\n observer.onCompleted();\n },\n observer.onError.bind(observer),\n geolocationOptions);\n });\n },\n\n /**\n * Begins listening for updates to the current geographical location of the device running the client.\n * @param {Object} [geolocationOptions] An object literal to specify one or more of the following attributes and desired values:\n * - enableHighAccuracy: Specify true to obtain the most accurate position possible, or false to optimize in favor of performance and power consumption.\n * - timeout: An Integer value that indicates the time, in milliseconds, allowed for obtaining the position.\n * If timeout is Infinity, (the default value) the location request will not time out.\n * If timeout is zero (0) or negative, the results depend on the behavior of the location provider.\n * - maximumAge: An Integer value indicating the maximum age, in milliseconds, of cached position information.\n * If maximumAge is non-zero, and a cached position that is no older than maximumAge is available, the cached position is used instead of obtaining an updated location.\n * If maximumAge is zero (0), watchPosition always tries to obtain an updated position, even if a cached position is already available.\n * If maximumAge is Infinity, any cached position is used, regardless of its age, and watchPosition only tries to obtain an updated position if no cached position data exists.\n * @returns {Observable} An observable sequence with the current geographical location of the device running the client.\n */\n watchPosition: function (geolocationOptions) {\n if (!root.navigator && !root.navigation.geolocation) { throw new TypeError('geolocation not available'); }\n\n return new AnonymousObservable(function (observer) {\n var watchId = root.navigator.geolocation.watchPosition(\n observer.onNext.bind(observer),\n observer.onError.bind(observer),\n geolocationOptions);\n\n return function () {\n root.navigator.geolocation.clearWatch(watchId);\n };\n }).publish().refCount();\n }\n };\n\r\n /**\n * The FileReader object lets web applications asynchronously read the contents of\n * files (or raw data buffers) stored on the user's computer, using File or Blob objects\n * to specify the file or data to read as an observable sequence.\n * @param {String} file The file to read.\n * @param {Observer} An observer to watch for progress.\n * @returns {Object} An object which contains methods for reading the data.\n */\n dom.fromReader = function(file, progressObserver) {\n if (!root.FileReader) { throw new TypeError('FileReader not implemented in your runtime.'); }\n\n function _fromReader(readerFn, file, encoding) {\n return new AnonymousObservable(function(observer) {\n var reader = new root.FileReader();\n var subject = new AsyncSubject();\n\n function loadHandler(e) {\n progressObserver && progressObserver.onCompleted();\n subject.onNext(e.target.result);\n subject.onCompleted();\n }\n\n function errorHandler(e) { subject.onError(e.target.error); }\n function progressHandler(e) { progressObserver.onNext(e); }\n\n reader.addEventListener('load', loadHandler, false);\n reader.addEventListener('error', errorHandler, false);\n progressObserver && reader.addEventListener('progress', progressHandler, false);\n\n reader[readerFn](file, encoding);\n\n return new CompositeDisposable(subject.subscribe(observer), disposableCreate(function () {\n reader.readyState == root.FileReader.LOADING && reader.abort();\n reader.removeEventListener('load', loadHandler, false);\n reader.removeEventListener('error', errorHandler, false);\n progressObserver && reader.removeEventListener('progress', progressHandler, false);\n }));\n });\n }\n\n return {\n /**\n * This method is used to read the file as an ArrayBuffer as an Observable stream.\n * @returns {Observable} An observable stream of an ArrayBuffer\n */\n asArrayBuffer : function() {\n return _fromReader('readAsArrayBuffer', file);\n },\n /**\n * This method is used to read the file as a binary data string as an Observable stream.\n * @returns {Observable} An observable stream of a binary data string.\n */\n asBinaryString : function() {\n return _fromReader('readAsBinaryString', file);\n },\n /**\n * This method is used to read the file as a URL of the file's data as an Observable stream.\n * @returns {Observable} An observable stream of a URL representing the file's data.\n */\n asDataURL : function() {\n return _fromReader('readAsDataURL', file);\n },\n /**\n * This method is used to read the file as a string as an Observable stream.\n * @returns {Observable} An observable stream of the string contents of the file.\n */\n asText : function(encoding) {\n return _fromReader('readAsText', file, encoding);\n }\n };\n };\n\r\n return Rx;\n}));\n/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(5)(module), (function() { return this; }())))\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/rx-dom/dist/rx.dom.js\n ** module id = 117\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/rx-dom/dist/rx.dom.js?");
  9. },function(module,exports,__webpack_require__){eval("var __WEBPACK_AMD_DEFINE_RESULT__;/* WEBPACK VAR INJECTION */(function(module, global, process) {// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.\n\r\n;(function (undefined) {\n\n var objectTypes = {\n 'boolean': false,\n 'function': true,\n 'object': true,\n 'number': false,\n 'string': false,\n 'undefined': false\n };\n\n var root = (objectTypes[typeof window] && window) || this,\n freeExports = objectTypes[typeof exports] && exports && !exports.nodeType && exports,\n freeModule = objectTypes[typeof module] && module && !module.nodeType && module,\n moduleExports = freeModule && freeModule.exports === freeExports && freeExports,\n freeGlobal = objectTypes[typeof global] && global;\n\n if (freeGlobal && (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal)) {\n root = freeGlobal;\n }\n\n var Rx = {\n internals: {},\n config: {\n Promise: root.Promise\n },\n helpers: { }\n };\n\r\n // Defaults\n var noop = Rx.helpers.noop = function () { },\n notDefined = Rx.helpers.notDefined = function (x) { return typeof x === 'undefined'; },\n identity = Rx.helpers.identity = function (x) { return x; },\n pluck = Rx.helpers.pluck = function (property) { return function (x) { return x[property]; }; },\n just = Rx.helpers.just = function (value) { return function () { return value; }; },\n defaultNow = Rx.helpers.defaultNow = Date.now,\n defaultComparer = Rx.helpers.defaultComparer = function (x, y) { return isEqual(x, y); },\n defaultSubComparer = Rx.helpers.defaultSubComparer = function (x, y) { return x > y ? 1 : (x < y ? -1 : 0); },\n defaultKeySerializer = Rx.helpers.defaultKeySerializer = function (x) { return x.toString(); },\n defaultError = Rx.helpers.defaultError = function (err) { throw err; },\n isPromise = Rx.helpers.isPromise = function (p) { return !!p && typeof p.subscribe !== 'function' && typeof p.then === 'function'; },\n asArray = Rx.helpers.asArray = function () { return Array.prototype.slice.call(arguments); },\n not = Rx.helpers.not = function (a) { return !a; },\n isFunction = Rx.helpers.isFunction = (function () {\n\n var isFn = function (value) {\n return typeof value == 'function' || false;\n }\n\n // fallback for older versions of Chrome and Safari\n if (isFn(/x/)) {\n isFn = function(value) {\n return typeof value == 'function' && toString.call(value) == '[object Function]';\n };\n }\n\n return isFn;\n }());\n\n function cloneArray(arr) { for(var a = [], i = 0, len = arr.length; i < len; i++) { a.push(arr[i]); } return a;}\n\r\n Rx.config.longStackSupport = false;\n var hasStacks = false;\n try {\n throw new Error();\n } catch (e) {\n hasStacks = !!e.stack;\n }\n\n // All code after this point will be filtered from stack traces reported by RxJS\n var rStartingLine = captureLine(), rFileName;\n\r\n var STACK_JUMP_SEPARATOR = \"From previous event:\";\n\n function makeStackTraceLong(error, observable) {\n // If possible, transform the error stack trace by removing Node and RxJS\n // cruft, then concatenating with the stack trace of `observable`.\n if (hasStacks &&\n observable.stack &&\n typeof error === \"object\" &&\n error !== null &&\n error.stack &&\n error.stack.indexOf(STACK_JUMP_SEPARATOR) === -1\n ) {\n var stacks = [];\n for (var o = observable; !!o; o = o.source) {\n if (o.stack) {\n stacks.unshift(o.stack);\n }\n }\n stacks.unshift(error.stack);\n\n var concatedStacks = stacks.join(\"\\n\" + STACK_JUMP_SEPARATOR + \"\\n\");\n error.stack = filterStackString(concatedStacks);\n }\n }\n\n function filterStackString(stackString) {\n var lines = stackString.split(\"\\n\"),\n desiredLines = [];\n for (var i = 0, len = lines.length; i < len; i++) {\n var line = lines[i];\n\n if (!isInternalFrame(line) && !isNodeFrame(line) && line) {\n desiredLines.push(line);\n }\n }\n return desiredLines.join(\"\\n\");\n }\n\n function isInternalFrame(stackLine) {\n var fileNameAndLineNumber = getFileNameAndLineNumber(stackLine);\n if (!fileNameAndLineNumber) {\n return false;\n }\n var fileName = fileNameAndLineNumber[0], lineNumber = fileNameAndLineNumber[1];\n\n return fileName === rFileName &&\n lineNumber >= rStartingLine &&\n lineNumber <= rEndingLine;\n }\n\n function isNodeFrame(stackLine) {\n return stackLine.indexOf(\"(module.js:\") !== -1 ||\n stackLine.indexOf(\"(node.js:\") !== -1;\n }\n\n function captureLine() {\n if (!hasStacks) { return; }\n\n try {\n throw new Error();\n } catch (e) {\n var lines = e.stack.split(\"\\n\");\n var firstLine = lines[0].indexOf(\"@\") > 0 ? lines[1] : lines[2];\n var fileNameAndLineNumber = getFileNameAndLineNumber(firstLine);\n if (!fileNameAndLineNumber) { return; }\n\n rFileName = fileNameAndLineNumber[0];\n return fileNameAndLineNumber[1];\n }\n }\n\n function getFileNameAndLineNumber(stackLine) {\n // Named functions: \"at functionName (filename:lineNumber:columnNumber)\"\n var attempt1 = /at .+ \\((.+):(\\d+):(?:\\d+)\\)$/.exec(stackLine);\n if (attempt1) { return [attempt1[1], Number(attempt1[2])]; }\n\n // Anonymous functions: \"at filename:lineNumber:columnNumber\"\n var attempt2 = /at ([^ ]+):(\\d+):(?:\\d+)$/.exec(stackLine);\n if (attempt2) { return [attempt2[1], Number(attempt2[2])]; }\n\n // Firefox style: \"function@filename:lineNumber or @filename:lineNumber\"\n var attempt3 = /.*@(.+):(\\d+)$/.exec(stackLine);\n if (attempt3) { return [attempt3[1], Number(attempt3[2])]; }\n }\n\r\n var EmptyError = Rx.EmptyError = function() {\n this.message = 'Sequence contains no elements.';\n Error.call(this);\n };\n EmptyError.prototype = Error.prototype;\n\n var ObjectDisposedError = Rx.ObjectDisposedError = function() {\n this.message = 'Object has been disposed';\n Error.call(this);\n };\n ObjectDisposedError.prototype = Error.prototype;\n\n var ArgumentOutOfRangeError = Rx.ArgumentOutOfRangeError = function () {\n this.message = 'Argument out of range';\n Error.call(this);\n };\n ArgumentOutOfRangeError.prototype = Error.prototype;\n\n var NotSupportedError = Rx.NotSupportedError = function (message) {\n this.message = message || 'This operation is not supported';\n Error.call(this);\n };\n NotSupportedError.prototype = Error.prototype;\n\n var NotImplementedError = Rx.NotImplementedError = function (message) {\n this.message = message || 'This operation is not implemented';\n Error.call(this);\n };\n NotImplementedError.prototype = Error.prototype;\n\n var notImplemented = Rx.helpers.notImplemented = function () {\n throw new NotImplementedError();\n };\n\n var notSupported = Rx.helpers.notSupported = function () {\n throw new NotSupportedError();\n };\n\r\n // Shim in iterator support\n var $iterator$ = (typeof Symbol === 'function' && Symbol.iterator) ||\n '_es6shim_iterator_';\n // Bug for mozilla version\n if (root.Set && typeof new root.Set()['@@iterator'] === 'function') {\n $iterator$ = '@@iterator';\n }\n\n var doneEnumerator = Rx.doneEnumerator = { done: true, value: undefined };\n\n var isIterable = Rx.helpers.isIterable = function (o) {\n return o[$iterator$] !== undefined;\n }\n\n var isArrayLike = Rx.helpers.isArrayLike = function (o) {\n return o && o.length !== undefined;\n }\n\n Rx.helpers.iterator = $iterator$;\n\r\n var bindCallback = Rx.internals.bindCallback = function (func, thisArg, argCount) {\n if (typeof thisArg === 'undefined') { return func; }\n switch(argCount) {\n case 0:\n return function() {\n return func.call(thisArg)\n };\n case 1:\n return function(arg) {\n return func.call(thisArg, arg);\n }\n case 2:\n return function(value, index) {\n return func.call(thisArg, value, index);\n };\n case 3:\n return function(value, index, collection) {\n return func.call(thisArg, value, index, collection);\n };\n }\n\n return function() {\n return func.apply(thisArg, arguments);\n };\n };\n\r\n /** Used to determine if values are of the language type Object */\n var dontEnums = ['toString',\n 'toLocaleString',\n 'valueOf',\n 'hasOwnProperty',\n 'isPrototypeOf',\n 'propertyIsEnumerable',\n 'constructor'],\n dontEnumsLength = dontEnums.length;\n\r\n /** `Object#toString` result shortcuts */\n var argsClass = '[object Arguments]',\n arrayClass = '[object Array]',\n boolClass = '[object Boolean]',\n dateClass = '[object Date]',\n errorClass = '[object Error]',\n funcClass = '[object Function]',\n numberClass = '[object Number]',\n objectClass = '[object Object]',\n regexpClass = '[object RegExp]',\n stringClass = '[object String]';\n\n var toString = Object.prototype.toString,\n hasOwnProperty = Object.prototype.hasOwnProperty,\n supportsArgsClass = toString.call(arguments) == argsClass, // For less <IE9 && FF<4\n supportNodeClass,\n errorProto = Error.prototype,\n objectProto = Object.prototype,\n stringProto = String.prototype,\n propertyIsEnumerable = objectProto.propertyIsEnumerable;\n\n try {\n supportNodeClass = !(toString.call(document) == objectClass && !({ 'toString': 0 } + ''));\n } catch (e) {\n supportNodeClass = true;\n }\n\n var nonEnumProps = {};\n nonEnumProps[arrayClass] = nonEnumProps[dateClass] = nonEnumProps[numberClass] = { 'constructor': true, 'toLocaleString': true, 'toString': true, 'valueOf': true };\n nonEnumProps[boolClass] = nonEnumProps[stringClass] = { 'constructor': true, 'toString': true, 'valueOf': true };\n nonEnumProps[errorClass] = nonEnumProps[funcClass] = nonEnumProps[regexpClass] = { 'constructor': true, 'toString': true };\n nonEnumProps[objectClass] = { 'constructor': true };\n\n var support = {};\n (function () {\n var ctor = function() { this.x = 1; },\n props = [];\n\n ctor.prototype = { 'valueOf': 1, 'y': 1 };\n for (var key in new ctor) { props.push(key); }\n for (key in arguments) { }\n\n // Detect if `name` or `message` properties of `Error.prototype` are enumerable by default.\n support.enumErrorProps = propertyIsEnumerable.call(errorProto, 'message') || propertyIsEnumerable.call(errorProto, 'name');\n\n // Detect if `prototype` properties are enumerable by default.\n support.enumPrototypes = propertyIsEnumerable.call(ctor, 'prototype');\n\n // Detect if `arguments` object indexes are non-enumerable\n support.nonEnumArgs = key != 0;\n\n // Detect if properties shadowing those on `Object.prototype` are non-enumerable.\n support.nonEnumShadows = !/valueOf/.test(props);\n }(1));\n\n var isObject = Rx.internals.isObject = function(value) {\n var type = typeof value;\n return value && (type == 'function' || type == 'object') || false;\n };\n\n function keysIn(object) {\n var result = [];\n if (!isObject(object)) {\n return result;\n }\n if (support.nonEnumArgs && object.length && isArguments(object)) {\n object = slice.call(object);\n }\n var skipProto = support.enumPrototypes && typeof object == 'function',\n skipErrorProps = support.enumErrorProps && (object === errorProto || object instanceof Error);\n\n for (var key in object) {\n if (!(skipProto && key == 'prototype') &&\n !(skipErrorProps && (key == 'message' || key == 'name'))) {\n result.push(key);\n }\n }\n\n if (support.nonEnumShadows && object !== objectProto) {\n var ctor = object.constructor,\n index = -1,\n length = dontEnumsLength;\n\n if (object === (ctor && ctor.prototype)) {\n var className = object === stringProto ? stringClass : object === errorProto ? errorClass : toString.call(object),\n nonEnum = nonEnumProps[className];\n }\n while (++index < length) {\n key = dontEnums[index];\n if (!(nonEnum && nonEnum[key]) && hasOwnProperty.call(object, key)) {\n result.push(key);\n }\n }\n }\n return result;\n }\n\n function internalFor(object, callback, keysFunc) {\n var index = -1,\n props = keysFunc(object),\n length = props.length;\n\n while (++index < length) {\n var key = props[index];\n if (callback(object[key], key, object) === false) {\n break;\n }\n }\n return object;\n }\n\n function internalForIn(object, callback) {\n return internalFor(object, callback, keysIn);\n }\n\n function isNode(value) {\n // IE < 9 presents DOM nodes as `Object` objects except they have `toString`\n // methods that are `typeof` \"string\" and still can coerce nodes to strings\n return typeof value.toString != 'function' && typeof (value + '') == 'string';\n }\n\n var isArguments = function(value) {\n return (value && typeof value == 'object') ? toString.call(value) == argsClass : false;\n }\n\n // fallback for browsers that can't detect `arguments` objects by [[Class]]\n if (!supportsArgsClass) {\n isArguments = function(value) {\n return (value && typeof value == 'object') ? hasOwnProperty.call(value, 'callee') : false;\n };\n }\n\n var isEqual = Rx.internals.isEqual = function (x, y) {\n return deepEquals(x, y, [], []);\n };\n\n /** @private\n * Used for deep comparison\n **/\n function deepEquals(a, b, stackA, stackB) {\n // exit early for identical values\n if (a === b) {\n // treat `+0` vs. `-0` as not equal\n return a !== 0 || (1 / a == 1 / b);\n }\n\n var type = typeof a,\n otherType = typeof b;\n\n // exit early for unlike primitive values\n if (a === a && (a == null || b == null ||\n (type != 'function' && type != 'object' && otherType != 'function' && otherType != 'object'))) {\n return false;\n }\n\n // compare [[Class]] names\n var className = toString.call(a),\n otherClass = toString.call(b);\n\n if (className == argsClass) {\n className = objectClass;\n }\n if (otherClass == argsClass) {\n otherClass = objectClass;\n }\n if (className != otherClass) {\n return false;\n }\n switch (className) {\n case boolClass:\n case dateClass:\n // coerce dates and booleans to numbers, dates to milliseconds and booleans\n // to `1` or `0` treating invalid dates coerced to `NaN` as not equal\n return +a == +b;\n\n case numberClass:\n // treat `NaN` vs. `NaN` as equal\n return (a != +a) ?\n b != +b :\n // but treat `-0` vs. `+0` as not equal\n (a == 0 ? (1 / a == 1 / b) : a == +b);\n\n case regexpClass:\n case stringClass:\n // coerce regexes to strings (http://es5.github.io/#x15.10.6.4)\n // treat string primitives and their corresponding object instances as equal\n return a == String(b);\n }\n var isArr = className == arrayClass;\n if (!isArr) {\n\n // exit for functions and DOM nodes\n if (className != objectClass || (!support.nodeClass && (isNode(a) || isNode(b)))) {\n return false;\n }\n // in older versions of Opera, `arguments` objects have `Array` constructors\n var ctorA = !support.argsObject && isArguments(a) ? Object : a.constructor,\n ctorB = !support.argsObject && isArguments(b) ? Object : b.constructor;\n\n // non `Object` object instances with different constructors are not equal\n if (ctorA != ctorB &&\n !(hasOwnProperty.call(a, 'constructor') && hasOwnProperty.call(b, 'constructor')) &&\n !(isFunction(ctorA) && ctorA instanceof ctorA && isFunction(ctorB) && ctorB instanceof ctorB) &&\n ('constructor' in a && 'constructor' in b)\n ) {\n return false;\n }\n }\n // assume cyclic structures are equal\n // the algorithm for detecting cyclic structures is adapted from ES 5.1\n // section 15.12.3, abstract operation `JO` (http://es5.github.io/#x15.12.3)\n var initedStack = !stackA;\n stackA || (stackA = []);\n stackB || (stackB = []);\n\n var length = stackA.length;\n while (length--) {\n if (stackA[length] == a) {\n return stackB[length] == b;\n }\n }\n var size = 0;\n var result = true;\n\n // add `a` and `b` to the stack of traversed objects\n stackA.push(a);\n stackB.push(b);\n\n // recursively compare objects and arrays (susceptible to call stack limits)\n if (isArr) {\n // compare lengths to determine if a deep comparison is necessary\n length = a.length;\n size = b.length;\n result = size == length;\n\n if (result) {\n // deep compare the contents, ignoring non-numeric properties\n while (size--) {\n var index = length,\n value = b[size];\n\n if (!(result = deepEquals(a[size], value, stackA, stackB))) {\n break;\n }\n }\n }\n }\n else {\n // deep compare objects using `forIn`, instead of `forOwn`, to avoid `Object.keys`\n // which, in this case, is more costly\n internalForIn(b, function(value, key, b) {\n if (hasOwnProperty.call(b, key)) {\n // count the number of properties.\n size++;\n // deep compare each property value.\n return (result = hasOwnProperty.call(a, key) && deepEquals(a[key], value, stackA, stackB));\n }\n });\n\n if (result) {\n // ensure both objects have the same number of properties\n internalForIn(a, function(value, key, a) {\n if (hasOwnProperty.call(a, key)) {\n // `size` will be `-1` if `a` has more properties than `b`\n return (result = --size > -1);\n }\n });\n }\n }\n stackA.pop();\n stackB.pop();\n\n return result;\n }\n\r\n var hasProp = {}.hasOwnProperty,\n slice = Array.prototype.slice;\n\n var inherits = this.inherits = Rx.internals.inherits = function (child, parent) {\n function __() { this.constructor = child; }\n __.prototype = parent.prototype;\n child.prototype = new __();\n };\n\n var addProperties = Rx.internals.addProperties = function (obj) {\n for(var sources = [], i = 1, len = arguments.length; i < len; i++) { sources.push(arguments[i]); }\n for (var idx = 0, ln = sources.length; idx < ln; idx++) {\n var source = sources[idx];\n for (var prop in source) {\n obj[prop] = source[prop];\n }\n }\n };\n\n // Rx Utils\n var addRef = Rx.internals.addRef = function (xs, r) {\n return new AnonymousObservable(function (observer) {\n return new CompositeDisposable(r.getDisposable(), xs.subscribe(observer));\n });\n };\n\n function arrayInitialize(count, factory) {\n var a = new Array(count);\n for (var i = 0; i < count; i++) {\n a[i] = factory();\n }\n return a;\n }\n\r\n var errorObj = {e: {}};\n var tryCatchTarget;\n function tryCatcher() {\n try {\n return tryCatchTarget.apply(this, arguments);\n } catch (e) {\n errorObj.e = e;\n return errorObj;\n }\n }\n function tryCatch(fn) {\n if (!isFunction(fn)) { throw new TypeError('fn must be a function'); }\n tryCatchTarget = fn;\n return tryCatcher;\n }\n function thrower(e) {\n throw e;\n }\n\r\n // Collections\n function IndexedItem(id, value) {\n this.id = id;\n this.value = value;\n }\n\n IndexedItem.prototype.compareTo = function (other) {\n var c = this.value.compareTo(other.value);\n c === 0 && (c = this.id - other.id);\n return c;\n };\n\n // Priority Queue for Scheduling\n var PriorityQueue = Rx.internals.PriorityQueue = function (capacity) {\n this.items = new Array(capacity);\n this.length = 0;\n };\n\n var priorityProto = PriorityQueue.prototype;\n priorityProto.isHigherPriority = function (left, right) {\n return this.items[left].compareTo(this.items[right]) < 0;\n };\n\n priorityProto.percolate = function (index) {\n if (index >= this.length || index < 0) { return; }\n var parent = index - 1 >> 1;\n if (parent < 0 || parent === index) { return; }\n if (this.isHigherPriority(index, parent)) {\n var temp = this.items[index];\n this.items[index] = this.items[parent];\n this.items[parent] = temp;\n this.percolate(parent);\n }\n };\n\n priorityProto.heapify = function (index) {\n +index || (index = 0);\n if (index >= this.length || index < 0) { return; }\n var left = 2 * index + 1,\n right = 2 * index + 2,\n first = index;\n if (left < this.length && this.isHigherPriority(left, first)) {\n first = left;\n }\n if (right < this.length && this.isHigherPriority(right, first)) {\n first = right;\n }\n if (first !== index) {\n var temp = this.items[index];\n this.items[index] = this.items[first];\n this.items[first] = temp;\n this.heapify(first);\n }\n };\n\n priorityProto.peek = function () { return this.items[0].value; };\n\n priorityProto.removeAt = function (index) {\n this.items[index] = this.items[--this.length];\n this.items[this.length] = undefined;\n this.heapify();\n };\n\n priorityProto.dequeue = function () {\n var result = this.peek();\n this.removeAt(0);\n return result;\n };\n\n priorityProto.enqueue = function (item) {\n var index = this.length++;\n this.items[index] = new IndexedItem(PriorityQueue.count++, item);\n this.percolate(index);\n };\n\n priorityProto.remove = function (item) {\n for (var i = 0; i < this.length; i++) {\n if (this.items[i].value === item) {\n this.removeAt(i);\n return true;\n }\n }\n return false;\n };\n PriorityQueue.count = 0;\n\r\n /**\n * Represents a group of disposable resources that are disposed together.\n * @constructor\n */\n var CompositeDisposable = Rx.CompositeDisposable = function () {\n var args = [], i, len;\n if (Array.isArray(arguments[0])) {\n args = arguments[0];\n len = args.length;\n } else {\n len = arguments.length;\n args = new Array(len);\n for(i = 0; i < len; i++) { args[i] = arguments[i]; }\n }\n for(i = 0; i < len; i++) {\n if (!isDisposable(args[i])) { throw new TypeError('Not a disposable'); }\n }\n this.disposables = args;\n this.isDisposed = false;\n this.length = args.length;\n };\n\n var CompositeDisposablePrototype = CompositeDisposable.prototype;\n\n /**\n * Adds a disposable to the CompositeDisposable or disposes the disposable if the CompositeDisposable is disposed.\n * @param {Mixed} item Disposable to add.\n */\n CompositeDisposablePrototype.add = function (item) {\n if (this.isDisposed) {\n item.dispose();\n } else {\n this.disposables.push(item);\n this.length++;\n }\n };\n\n /**\n * Removes and disposes the first occurrence of a disposable from the CompositeDisposable.\n * @param {Mixed} item Disposable to remove.\n * @returns {Boolean} true if found; false otherwise.\n */\n CompositeDisposablePrototype.remove = function (item) {\n var shouldDispose = false;\n if (!this.isDisposed) {\n var idx = this.disposables.indexOf(item);\n if (idx !== -1) {\n shouldDispose = true;\n this.disposables.splice(idx, 1);\n this.length--;\n item.dispose();\n }\n }\n return shouldDispose;\n };\n\n /**\n * Disposes all disposables in the group and removes them from the group.\n */\n CompositeDisposablePrototype.dispose = function () {\n if (!this.isDisposed) {\n this.isDisposed = true;\n var len = this.disposables.length, currentDisposables = new Array(len);\n for(var i = 0; i < len; i++) { currentDisposables[i] = this.disposables[i]; }\n this.disposables = [];\n this.length = 0;\n\n for (i = 0; i < len; i++) {\n currentDisposables[i].dispose();\n }\n }\n };\n\r\n /**\n * Provides a set of static methods for creating Disposables.\n * @param {Function} dispose Action to run during the first call to dispose. The action is guaranteed to be run at most once.\n */\n var Disposable = Rx.Disposable = function (action) {\n this.isDisposed = false;\n this.action = action || noop;\n };\n\n /** Performs the task of cleaning up resources. */\n Disposable.prototype.dispose = function () {\n if (!this.isDisposed) {\n this.action();\n this.isDisposed = true;\n }\n };\n\n /**\n * Creates a disposable object that invokes the specified action when disposed.\n * @param {Function} dispose Action to run during the first call to dispose. The action is guaranteed to be run at most once.\n * @return {Disposable} The disposable object that runs the given action upon disposal.\n */\n var disposableCreate = Disposable.create = function (action) { return new Disposable(action); };\n\n /**\n * Gets the disposable that does nothing when disposed.\n */\n var disposableEmpty = Disposable.empty = { dispose: noop };\n\n /**\n * Validates whether the given object is a disposable\n * @param {Object} Object to test whether it has a dispose method\n * @returns {Boolean} true if a disposable object, else false.\n */\n var isDisposable = Disposable.isDisposable = function (d) {\n return d && isFunction(d.dispose);\n };\n\n var checkDisposed = Disposable.checkDisposed = function (disposable) {\n if (disposable.isDisposed) { throw new ObjectDisposedError(); }\n };\n\r\n // Single assignment\n var SingleAssignmentDisposable = Rx.SingleAssignmentDisposable = function () {\n this.isDisposed = false;\n this.current = null;\n };\n SingleAssignmentDisposable.prototype.getDisposable = function () {\n return this.current;\n };\n SingleAssignmentDisposable.prototype.setDisposable = function (value) {\n if (this.current) { throw new Error('Disposable has already been assigned'); }\n var shouldDispose = this.isDisposed;\n !shouldDispose && (this.current = value);\n shouldDispose && value && value.dispose();\n };\n SingleAssignmentDisposable.prototype.dispose = function () {\n if (!this.isDisposed) {\n this.isDisposed = true;\n var old = this.current;\n this.current = null;\n }\n old && old.dispose();\n };\n\n // Multiple assignment disposable\n var SerialDisposable = Rx.SerialDisposable = function () {\n this.isDisposed = false;\n this.current = null;\n };\n SerialDisposable.prototype.getDisposable = function () {\n return this.current;\n };\n SerialDisposable.prototype.setDisposable = function (value) {\n var shouldDispose = this.isDisposed;\n if (!shouldDispose) {\n var old = this.current;\n this.current = value;\n }\n old && old.dispose();\n shouldDispose && value && value.dispose();\n };\n SerialDisposable.prototype.dispose = function () {\n if (!this.isDisposed) {\n this.isDisposed = true;\n var old = this.current;\n this.current = null;\n }\n old && old.dispose();\n };\n\r\n /**\n * Represents a disposable resource that only disposes its underlying disposable resource when all dependent disposable objects have been disposed.\n */\n var RefCountDisposable = Rx.RefCountDisposable = (function () {\n\n function InnerDisposable(disposable) {\n this.disposable = disposable;\n this.disposable.count++;\n this.isInnerDisposed = false;\n }\n\n InnerDisposable.prototype.dispose = function () {\n if (!this.disposable.isDisposed && !this.isInnerDisposed) {\n this.isInnerDisposed = true;\n this.disposable.count--;\n if (this.disposable.count === 0 && this.disposable.isPrimaryDisposed) {\n this.disposable.isDisposed = true;\n this.disposable.underlyingDisposable.dispose();\n }\n }\n };\n\n /**\n * Initializes a new instance of the RefCountDisposable with the specified disposable.\n * @constructor\n * @param {Disposable} disposable Underlying disposable.\n */\n function RefCountDisposable(disposable) {\n this.underlyingDisposable = disposable;\n this.isDisposed = false;\n this.isPrimaryDisposed = false;\n this.count = 0;\n }\n\n /**\n * Disposes the underlying disposable only when all dependent disposables have been disposed\n */\n RefCountDisposable.prototype.dispose = function () {\n if (!this.isDisposed && !this.isPrimaryDisposed) {\n this.isPrimaryDisposed = true;\n if (this.count === 0) {\n this.isDisposed = true;\n this.underlyingDisposable.dispose();\n }\n }\n };\n\n /**\n * Returns a dependent disposable that when disposed decreases the refcount on the underlying disposable.\n * @returns {Disposable} A dependent disposable contributing to the reference count that manages the underlying disposable's lifetime.\n */\n RefCountDisposable.prototype.getDisposable = function () {\n return this.isDisposed ? disposableEmpty : new InnerDisposable(this);\n };\n\n return RefCountDisposable;\n })();\n\r\n function ScheduledDisposable(scheduler, disposable) {\n this.scheduler = scheduler;\n this.disposable = disposable;\n this.isDisposed = false;\n }\n\n function scheduleItem(s, self) {\n if (!self.isDisposed) {\n self.isDisposed = true;\n self.disposable.dispose();\n }\n }\n\n ScheduledDisposable.prototype.dispose = function () {\n this.scheduler.scheduleWithState(this, scheduleItem);\n };\n\r\n var ScheduledItem = Rx.internals.ScheduledItem = function (scheduler, state, action, dueTime, comparer) {\n this.scheduler = scheduler;\n this.state = state;\n this.action = action;\n this.dueTime = dueTime;\n this.comparer = comparer || defaultSubComparer;\n this.disposable = new SingleAssignmentDisposable();\n }\n\n ScheduledItem.prototype.invoke = function () {\n this.disposable.setDisposable(this.invokeCore());\n };\n\n ScheduledItem.prototype.compareTo = function (other) {\n return this.comparer(this.dueTime, other.dueTime);\n };\n\n ScheduledItem.prototype.isCancelled = function () {\n return this.disposable.isDisposed;\n };\n\n ScheduledItem.prototype.invokeCore = function () {\n return this.action(this.scheduler, this.state);\n };\n\r\n /** Provides a set of static properties to access commonly used schedulers. */\n var Scheduler = Rx.Scheduler = (function () {\n\n function Scheduler(now, schedule, scheduleRelative, scheduleAbsolute) {\n this.now = now;\n this._schedule = schedule;\n this._scheduleRelative = scheduleRelative;\n this._scheduleAbsolute = scheduleAbsolute;\n }\n\n /** Determines whether the given object is a scheduler */\n Scheduler.isScheduler = function (s) {\n return s instanceof Scheduler;\n }\n\n function invokeAction(scheduler, action) {\n action();\n return disposableEmpty;\n }\n\n var schedulerProto = Scheduler.prototype;\n\n /**\n * Schedules an action to be executed.\n * @param {Function} action Action to execute.\n * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort).\n */\n schedulerProto.schedule = function (action) {\n return this._schedule(action, invokeAction);\n };\n\n /**\n * Schedules an action to be executed.\n * @param state State passed to the action to be executed.\n * @param {Function} action Action to be executed.\n * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort).\n */\n schedulerProto.scheduleWithState = function (state, action) {\n return this._schedule(state, action);\n };\n\n /**\n * Schedules an action to be executed after the specified relative due time.\n * @param {Function} action Action to execute.\n * @param {Number} dueTime Relative time after which to execute the action.\n * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort).\n */\n schedulerProto.scheduleWithRelative = function (dueTime, action) {\n return this._scheduleRelative(action, dueTime, invokeAction);\n };\n\n /**\n * Schedules an action to be executed after dueTime.\n * @param state State passed to the action to be executed.\n * @param {Function} action Action to be executed.\n * @param {Number} dueTime Relative time after which to execute the action.\n * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort).\n */\n schedulerProto.scheduleWithRelativeAndState = function (state, dueTime, action) {\n return this._scheduleRelative(state, dueTime, action);\n };\n\n /**\n * Schedules an action to be executed at the specified absolute due time.\n * @param {Function} action Action to execute.\n * @param {Number} dueTime Absolute time at which to execute the action.\n * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort).\n */\n schedulerProto.scheduleWithAbsolute = function (dueTime, action) {\n return this._scheduleAbsolute(action, dueTime, invokeAction);\n };\n\n /**\n * Schedules an action to be executed at dueTime.\n * @param {Mixed} state State passed to the action to be executed.\n * @param {Function} action Action to be executed.\n * @param {Number}dueTime Absolute time at which to execute the action.\n * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort).\n */\n schedulerProto.scheduleWithAbsoluteAndState = function (state, dueTime, action) {\n return this._scheduleAbsolute(state, dueTime, action);\n };\n\n /** Gets the current time according to the local machine's system clock. */\n Scheduler.now = defaultNow;\n\n /**\n * Normalizes the specified TimeSpan value to a positive value.\n * @param {Number} timeSpan The time span value to normalize.\n * @returns {Number} The specified TimeSpan value if it is zero or positive; otherwise, 0\n */\n Scheduler.normalize = function (timeSpan) {\n timeSpan < 0 && (timeSpan = 0);\n return timeSpan;\n };\n\n return Scheduler;\n }());\n\n var normalizeTime = Scheduler.normalize, isScheduler = Scheduler.isScheduler;\n\r\n (function (schedulerProto) {\n\n function invokeRecImmediate(scheduler, pair) {\n var state = pair[0], action = pair[1], group = new CompositeDisposable();\n\n function recursiveAction(state1) {\n action(state1, function (state2) {\n var isAdded = false, isDone = false,\n d = scheduler.scheduleWithState(state2, function (scheduler1, state3) {\n if (isAdded) {\n group.remove(d);\n } else {\n isDone = true;\n }\n recursiveAction(state3);\n return disposableEmpty;\n });\n if (!isDone) {\n group.add(d);\n isAdded = true;\n }\n });\n }\n recursiveAction(state);\n return group;\n }\n\n function invokeRecDate(scheduler, pair, method) {\n var state = pair[0], action = pair[1], group = new CompositeDisposable();\n function recursiveAction(state1) {\n action(state1, function (state2, dueTime1) {\n var isAdded = false, isDone = false,\n d = scheduler[method](state2, dueTime1, function (scheduler1, state3) {\n if (isAdded) {\n group.remove(d);\n } else {\n isDone = true;\n }\n recursiveAction(state3);\n return disposableEmpty;\n });\n if (!isDone) {\n group.add(d);\n isAdded = true;\n }\n });\n };\n recursiveAction(state);\n return group;\n }\n\n function scheduleInnerRecursive(action, self) {\n action(function(dt) { self(action, dt); });\n }\n\n /**\n * Schedules an action to be executed recursively.\n * @param {Function} action Action to execute recursively. The parameter passed to the action is used to trigger recursive scheduling of the action.\n * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort).\n */\n schedulerProto.scheduleRecursive = function (action) {\n return this.scheduleRecursiveWithState(action, scheduleInnerRecursive);\n };\n\n /**\n * Schedules an action to be executed recursively.\n * @param {Mixed} state State passed to the action to be executed.\n * @param {Function} action Action to execute recursively. The last parameter passed to the action is used to trigger recursive scheduling of the action, passing in recursive invocation state.\n * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort).\n */\n schedulerProto.scheduleRecursiveWithState = function (state, action) {\n return this.scheduleWithState([state, action], invokeRecImmediate);\n };\n\n /**\n * Schedules an action to be executed recursively after a specified relative due time.\n * @param {Function} action Action to execute recursively. The parameter passed to the action is used to trigger recursive scheduling of the action at the specified relative time.\n * @param {Number}dueTime Relative time after which to execute the action for the first time.\n * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort).\n */\n schedulerProto.scheduleRecursiveWithRelative = function (dueTime, action) {\n return this.scheduleRecursiveWithRelativeAndState(action, dueTime, scheduleInnerRecursive);\n };\n\n /**\n * Schedules an action to be executed recursively after a specified relative due time.\n * @param {Mixed} state State passed to the action to be executed.\n * @param {Function} action Action to execute recursively. The last parameter passed to the action is used to trigger recursive scheduling of the action, passing in the recursive due time and invocation state.\n * @param {Number}dueTime Relative time after which to execute the action for the first time.\n * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort).\n */\n schedulerProto.scheduleRecursiveWithRelativeAndState = function (state, dueTime, action) {\n return this._scheduleRelative([state, action], dueTime, function (s, p) {\n return invokeRecDate(s, p, 'scheduleWithRelativeAndState');\n });\n };\n\n /**\n * Schedules an action to be executed recursively at a specified absolute due time.\n * @param {Function} action Action to execute recursively. The parameter passed to the action is used to trigger recursive scheduling of the action at the specified absolute time.\n * @param {Number}dueTime Absolute time at which to execute the action for the first time.\n * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort).\n */\n schedulerProto.scheduleRecursiveWithAbsolute = function (dueTime, action) {\n return this.scheduleRecursiveWithAbsoluteAndState(action, dueTime, scheduleInnerRecursive);\n };\n\n /**\n * Schedules an action to be executed recursively at a specified absolute due time.\n * @param {Mixed} state State passed to the action to be executed.\n * @param {Function} action Action to execute recursively. The last parameter passed to the action is used to trigger recursive scheduling of the action, passing in the recursive due time and invocation state.\n * @param {Number}dueTime Absolute time at which to execute the action for the first time.\n * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort).\n */\n schedulerProto.scheduleRecursiveWithAbsoluteAndState = function (state, dueTime, action) {\n return this._scheduleAbsolute([state, action], dueTime, function (s, p) {\n return invokeRecDate(s, p, 'scheduleWithAbsoluteAndState');\n });\n };\n }(Scheduler.prototype));\n\r\n (function (schedulerProto) {\n\n /**\n * Schedules a periodic piece of work by dynamically discovering the scheduler's capabilities. The periodic task will be scheduled using window.setInterval for the base implementation.\n * @param {Number} period Period for running the work periodically.\n * @param {Function} action Action to be executed.\n * @returns {Disposable} The disposable object used to cancel the scheduled recurring action (best effort).\n */\n Scheduler.prototype.schedulePeriodic = function (period, action) {\n return this.schedulePeriodicWithState(null, period, action);\n };\n\n /**\n * Schedules a periodic piece of work by dynamically discovering the scheduler's capabilities. The periodic task will be scheduled using window.setInterval for the base implementation.\n * @param {Mixed} state Initial state passed to the action upon the first iteration.\n * @param {Number} period Period for running the work periodically.\n * @param {Function} action Action to be executed, potentially updating the state.\n * @returns {Disposable} The disposable object used to cancel the scheduled recurring action (best effort).\n */\n Scheduler.prototype.schedulePeriodicWithState = function(state, period, action) {\n if (typeof root.setInterval === 'undefined') { throw new NotSupportedError(); }\n period = normalizeTime(period);\n var s = state, id = root.setInterval(function () { s = action(s); }, period);\n return disposableCreate(function () { root.clearInterval(id); });\n };\n\n }(Scheduler.prototype));\n\r\n (function (schedulerProto) {\n /**\n * Returns a scheduler that wraps the original scheduler, adding exception handling for scheduled actions.\n * @param {Function} handler Handler that's run if an exception is caught. The exception will be rethrown if the handler returns false.\n * @returns {Scheduler} Wrapper around the original scheduler, enforcing exception handling.\n */\n schedulerProto.catchError = schedulerProto['catch'] = function (handler) {\n return new CatchScheduler(this, handler);\n };\n }(Scheduler.prototype));\n\r\n var SchedulePeriodicRecursive = Rx.internals.SchedulePeriodicRecursive = (function () {\n function tick(command, recurse) {\n recurse(0, this._period);\n try {\n this._state = this._action(this._state);\n } catch (e) {\n this._cancel.dispose();\n throw e;\n }\n }\n\n function SchedulePeriodicRecursive(scheduler, state, period, action) {\n this._scheduler = scheduler;\n this._state = state;\n this._period = period;\n this._action = action;\n }\n\n SchedulePeriodicRecursive.prototype.start = function () {\n var d = new SingleAssignmentDisposable();\n this._cancel = d;\n d.setDisposable(this._scheduler.scheduleRecursiveWithRelativeAndState(0, this._period, tick.bind(this)));\n\n return d;\n };\n\n return SchedulePeriodicRecursive;\n }());\n\r\n /** Gets a scheduler that schedules work immediately on the current thread. */\n var immediateScheduler = Scheduler.immediate = (function () {\n function scheduleNow(state, action) { return action(this, state); }\n return new Scheduler(defaultNow, scheduleNow, notSupported, notSupported);\n }());\n\r\n /**\n * Gets a scheduler that schedules work as soon as possible on the current thread.\n */\n var currentThreadScheduler = Scheduler.currentThread = (function () {\n var queue;\n\n function runTrampoline () {\n while (queue.length > 0) {\n var item = queue.dequeue();\n !item.isCancelled() && item.invoke();\n }\n }\n\n function scheduleNow(state, action) {\n var si = new ScheduledItem(this, state, action, this.now());\n\n if (!queue) {\n queue = new PriorityQueue(4);\n queue.enqueue(si);\n\n var result = tryCatch(runTrampoline)();\n queue = null;\n if (result === errorObj) { return thrower(result.e); }\n } else {\n queue.enqueue(si);\n }\n return si.disposable;\n }\n\n var currentScheduler = new Scheduler(defaultNow, scheduleNow, notSupported, notSupported);\n currentScheduler.scheduleRequired = function () { return !queue; };\n\n return currentScheduler;\n }());\n\r\n var scheduleMethod, clearMethod;\n\n var localTimer = (function () {\n var localSetTimeout, localClearTimeout = noop;\n if (!!root.setTimeout) {\n localSetTimeout = root.setTimeout;\n localClearTimeout = root.clearTimeout;\n } else if (!!root.WScript) {\n localSetTimeout = function (fn, time) {\n root.WScript.Sleep(time);\n fn();\n };\n } else {\n throw new NotSupportedError();\n }\n\n return {\n setTimeout: localSetTimeout,\n clearTimeout: localClearTimeout\n };\n }());\n var localSetTimeout = localTimer.setTimeout,\n localClearTimeout = localTimer.clearTimeout;\n\n (function () {\n\n var nextHandle = 1, tasksByHandle = {}, currentlyRunning = false;\n\n clearMethod = function (handle) {\n delete tasksByHandle[handle];\n };\n\n function runTask(handle) {\n if (currentlyRunning) {\n localSetTimeout(function () { runTask(handle) }, 0);\n } else {\n var task = tasksByHandle[handle];\n if (task) {\n currentlyRunning = true;\n var result = tryCatch(task)();\n clearMethod(handle);\n currentlyRunning = false;\n if (result === errorObj) { return thrower(result.e); }\n }\n }\n }\n\n var reNative = RegExp('^' +\n String(toString)\n .replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')\n .replace(/toString| for [^\\]]+/g, '.*?') + '$'\n );\n\n var setImmediate = typeof (setImmediate = freeGlobal && moduleExports && freeGlobal.setImmediate) == 'function' &&\n !reNative.test(setImmediate) && setImmediate;\n\n function postMessageSupported () {\n // Ensure not in a worker\n if (!root.postMessage || root.importScripts) { return false; }\n var isAsync = false, oldHandler = root.onmessage;\n // Test for async\n root.onmessage = function () { isAsync = true; };\n root.postMessage('', '*');\n root.onmessage = oldHandler;\n\n return isAsync;\n }\n\n // Use in order, setImmediate, nextTick, postMessage, MessageChannel, script readystatechanged, setTimeout\n if (isFunction(setImmediate)) {\n scheduleMethod = function (action) {\n var id = nextHandle++;\n tasksByHandle[id] = action;\n setImmediate(function () { runTask(id); });\n\n return id;\n };\n } else if (typeof process !== 'undefined' && {}.toString.call(process) === '[object process]') {\n scheduleMethod = function (action) {\n var id = nextHandle++;\n tasksByHandle[id] = action;\n process.nextTick(function () { runTask(id); });\n\n return id;\n };\n } else if (postMessageSupported()) {\n var MSG_PREFIX = 'ms.rx.schedule' + Math.random();\n\n function onGlobalPostMessage(event) {\n // Only if we're a match to avoid any other global events\n if (typeof event.data === 'string' && event.data.substring(0, MSG_PREFIX.length) === MSG_PREFIX) {\n runTask(event.data.substring(MSG_PREFIX.length));\n }\n }\n\n if (root.addEventListener) {\n root.addEventListener('message', onGlobalPostMessage, false);\n } else if (root.attachEvent) {\n root.attachEvent('onmessage', onGlobalPostMessage);\n } else {\n root.onmessage = onGlobalPostMessage;\n }\n\n scheduleMethod = function (action) {\n var id = nextHandle++;\n tasksByHandle[id] = action;\n root.postMessage(MSG_PREFIX + currentId, '*');\n return id;\n };\n } else if (!!root.MessageChannel) {\n var channel = new root.MessageChannel();\n\n channel.port1.onmessage = function (e) { runTask(e.data); };\n\n scheduleMethod = function (action) {\n var id = nextHandle++;\n tasksByHandle[id] = action;\n channel.port2.postMessage(id);\n return id;\n };\n } else if ('document' in root && 'onreadystatechange' in root.document.createElement('script')) {\n\n scheduleMethod = function (action) {\n var scriptElement = root.document.createElement('script');\n var id = nextHandle++;\n tasksByHandle[id] = action;\n\n scriptElement.onreadystatechange = function () {\n runTask(id);\n scriptElement.onreadystatechange = null;\n scriptElement.parentNode.removeChild(scriptElement);\n scriptElement = null;\n };\n root.document.documentElement.appendChild(scriptElement);\n return id;\n };\n\n } else {\n scheduleMethod = function (action) {\n var id = nextHandle++;\n tasksByHandle[id] = action;\n localSetTimeout(function () {\n runTask(id);\n }, 0);\n\n return id;\n };\n }\n }());\n\n /**\n * Gets a scheduler that schedules work via a timed callback based upon platform.\n */\n var timeoutScheduler = Scheduler.timeout = Scheduler['default'] = (function () {\n\n function scheduleNow(state, action) {\n var scheduler = this, disposable = new SingleAssignmentDisposable();\n var id = scheduleMethod(function () {\n !disposable.isDisposed && disposable.setDisposable(action(scheduler, state));\n });\n return new CompositeDisposable(disposable, disposableCreate(function () {\n clearMethod(id);\n }));\n }\n\n function scheduleRelative(state, dueTime, action) {\n var scheduler = this, dt = Scheduler.normalize(dueTime), disposable = new SingleAssignmentDisposable();\n if (dt === 0) { return scheduler.scheduleWithState(state, action); }\n var id = localSetTimeout(function () {\n !disposable.isDisposed && disposable.setDisposable(action(scheduler, state));\n }, dt);\n return new CompositeDisposable(disposable, disposableCreate(function () {\n localClearTimeout(id);\n }));\n }\n\n function scheduleAbsolute(state, dueTime, action) {\n return this.scheduleWithRelativeAndState(state, dueTime - this.now(), action);\n }\n\n return new Scheduler(defaultNow, scheduleNow, scheduleRelative, scheduleAbsolute);\n })();\n\r\n var CatchScheduler = (function (__super__) {\n\n function scheduleNow(state, action) {\n return this._scheduler.scheduleWithState(state, this._wrap(action));\n }\n\n function scheduleRelative(state, dueTime, action) {\n return this._scheduler.scheduleWithRelativeAndState(state, dueTime, this._wrap(action));\n }\n\n function scheduleAbsolute(state, dueTime, action) {\n return this._scheduler.scheduleWithAbsoluteAndState(state, dueTime, this._wrap(action));\n }\n\n inherits(CatchScheduler, __super__);\n\n function CatchScheduler(scheduler, handler) {\n this._scheduler = scheduler;\n this._handler = handler;\n this._recursiveOriginal = null;\n this._recursiveWrapper = null;\n __super__.call(this, this._scheduler.now.bind(this._scheduler), scheduleNow, scheduleRelative, scheduleAbsolute);\n }\n\n CatchScheduler.prototype._clone = function (scheduler) {\n return new CatchScheduler(scheduler, this._handler);\n };\n\n CatchScheduler.prototype._wrap = function (action) {\n var parent = this;\n return function (self, state) {\n try {\n return action(parent._getRecursiveWrapper(self), state);\n } catch (e) {\n if (!parent._handler(e)) { throw e; }\n return disposableEmpty;\n }\n };\n };\n\n CatchScheduler.prototype._getRecursiveWrapper = function (scheduler) {\n if (this._recursiveOriginal !== scheduler) {\n this._recursiveOriginal = scheduler;\n var wrapper = this._clone(scheduler);\n wrapper._recursiveOriginal = scheduler;\n wrapper._recursiveWrapper = wrapper;\n this._recursiveWrapper = wrapper;\n }\n return this._recursiveWrapper;\n };\n\n CatchScheduler.prototype.schedulePeriodicWithState = function (state, period, action) {\n var self = this, failed = false, d = new SingleAssignmentDisposable();\n\n d.setDisposable(this._scheduler.schedulePeriodicWithState(state, period, function (state1) {\n if (failed) { return null; }\n try {\n return action(state1);\n } catch (e) {\n failed = true;\n if (!self._handler(e)) { throw e; }\n d.dispose();\n return null;\n }\n }));\n\n return d;\n };\n\n return CatchScheduler;\n }(Scheduler));\n\r\n /**\n * Represents a notification to an observer.\n */\n var Notification = Rx.Notification = (function () {\n function Notification(kind, value, exception, accept, acceptObservable, toString) {\n this.kind = kind;\n this.value = value;\n this.exception = exception;\n this._accept = accept;\n this._acceptObservable = acceptObservable;\n this.toString = toString;\n }\n\n /**\n * Invokes the delegate corresponding to the notification or the observer's method corresponding to the notification and returns the produced result.\n *\n * @memberOf Notification\n * @param {Any} observerOrOnNext Delegate to invoke for an OnNext notification or Observer to invoke the notification on..\n * @param {Function} onError Delegate to invoke for an OnError notification.\n * @param {Function} onCompleted Delegate to invoke for an OnCompleted notification.\n * @returns {Any} Result produced by the observation.\n */\n Notification.prototype.accept = function (observerOrOnNext, onError, onCompleted) {\n return observerOrOnNext && typeof observerOrOnNext === 'object' ?\n this._acceptObservable(observerOrOnNext) :\n this._accept(observerOrOnNext, onError, onCompleted);\n };\n\n /**\n * Returns an observable sequence with a single notification.\n *\n * @memberOf Notifications\n * @param {Scheduler} [scheduler] Scheduler to send out the notification calls on.\n * @returns {Observable} The observable sequence that surfaces the behavior of the notification upon subscription.\n */\n Notification.prototype.toObservable = function (scheduler) {\n var self = this;\n isScheduler(scheduler) || (scheduler = immediateScheduler);\n return new AnonymousObservable(function (observer) {\n return scheduler.scheduleWithState(self, function (_, notification) {\n notification._acceptObservable(observer);\n notification.kind === 'N' && observer.onCompleted();\n });\n });\n };\n\n return Notification;\n })();\n\n /**\n * Creates an object that represents an OnNext notification to an observer.\n * @param {Any} value The value contained in the notification.\n * @returns {Notification} The OnNext notification containing the value.\n */\n var notificationCreateOnNext = Notification.createOnNext = (function () {\n function _accept(onNext) { return onNext(this.value); }\n function _acceptObservable(observer) { return observer.onNext(this.value); }\n function toString() { return 'OnNext(' + this.value + ')'; }\n\n return function (value) {\n return new Notification('N', value, null, _accept, _acceptObservable, toString);\n };\n }());\n\n /**\n * Creates an object that represents an OnError notification to an observer.\n * @param {Any} error The exception contained in the notification.\n * @returns {Notification} The OnError notification containing the exception.\n */\n var notificationCreateOnError = Notification.createOnError = (function () {\n function _accept (onNext, onError) { return onError(this.exception); }\n function _acceptObservable(observer) { return observer.onError(this.exception); }\n function toString () { return 'OnError(' + this.exception + ')'; }\n\n return function (e) {\n return new Notification('E', null, e, _accept, _acceptObservable, toString);\n };\n }());\n\n /**\n * Creates an object that represents an OnCompleted notification to an observer.\n * @returns {Notification} The OnCompleted notification.\n */\n var notificationCreateOnCompleted = Notification.createOnCompleted = (function () {\n function _accept (onNext, onError, onCompleted) { return onCompleted(); }\n function _acceptObservable(observer) { return observer.onCompleted(); }\n function toString () { return 'OnCompleted()'; }\n\n return function () {\n return new Notification('C', null, null, _accept, _acceptObservable, toString);\n };\n }());\n\r\n /**\n * Supports push-style iteration over an observable sequence.\n */\n var Observer = Rx.Observer = function () { };\n\n /**\n * Creates a notification callback from an observer.\n * @returns The action that forwards its input notification to the underlying observer.\n */\n Observer.prototype.toNotifier = function () {\n var observer = this;\n return function (n) { return n.accept(observer); };\n };\n\n /**\n * Hides the identity of an observer.\n * @returns An observer that hides the identity of the specified observer.\n */\n Observer.prototype.asObserver = function () {\n return new AnonymousObserver(this.onNext.bind(this), this.onError.bind(this), this.onCompleted.bind(this));\n };\n\n /**\n * Checks access to the observer for grammar violations. This includes checking for multiple OnError or OnCompleted calls, as well as reentrancy in any of the observer methods.\n * If a violation is detected, an Error is thrown from the offending observer method call.\n * @returns An observer that checks callbacks invocations against the observer grammar and, if the checks pass, forwards those to the specified observer.\n */\n Observer.prototype.checked = function () { return new CheckedObserver(this); };\n\n /**\n * Creates an observer from the specified OnNext, along with optional OnError, and OnCompleted actions.\n * @param {Function} [onNext] Observer's OnNext action implementation.\n * @param {Function} [onError] Observer's OnError action implementation.\n * @param {Function} [onCompleted] Observer's OnCompleted action implementation.\n * @returns {Observer} The observer object implemented using the given actions.\n */\n var observerCreate = Observer.create = function (onNext, onError, onCompleted) {\n onNext || (onNext = noop);\n onError || (onError = defaultError);\n onCompleted || (onCompleted = noop);\n return new AnonymousObserver(onNext, onError, onCompleted);\n };\n\n /**\n * Creates an observer from a notification callback.\n *\n * @static\n * @memberOf Observer\n * @param {Function} handler Action that handles a notification.\n * @returns The observer object that invokes the specified handler using a notification corresponding to each message it receives.\n */\n Observer.fromNotifier = function (handler, thisArg) {\n return new AnonymousObserver(function (x) {\n return handler.call(thisArg, notificationCreateOnNext(x));\n }, function (e) {\n return handler.call(thisArg, notificationCreateOnError(e));\n }, function () {\n return handler.call(thisArg, notificationCreateOnCompleted());\n });\n };\n\n /**\n * Schedules the invocation of observer methods on the given scheduler.\n * @param {Scheduler} scheduler Scheduler to schedule observer messages on.\n * @returns {Observer} Observer whose messages are scheduled on the given scheduler.\n */\n Observer.prototype.notifyOn = function (scheduler) {\n return new ObserveOnObserver(scheduler, this);\n };\n\n Observer.prototype.makeSafe = function(disposable) {\n return new AnonymousSafeObserver(this._onNext, this._onError, this._onCompleted, disposable);\n };\n\r\n /**\n * Abstract base class for implementations of the Observer class.\n * This base class enforces the grammar of observers where OnError and OnCompleted are terminal messages.\n */\n var AbstractObserver = Rx.internals.AbstractObserver = (function (__super__) {\n inherits(AbstractObserver, __super__);\n\n /**\n * Creates a new observer in a non-stopped state.\n */\n function AbstractObserver() {\n this.isStopped = false;\n __super__.call(this);\n }\n\n // Must be implemented by other observers\n AbstractObserver.prototype.next = notImplemented;\n AbstractObserver.prototype.error = notImplemented;\n AbstractObserver.prototype.completed = notImplemented;\n\n /**\n * Notifies the observer of a new element in the sequence.\n * @param {Any} value Next element in the sequence.\n */\n AbstractObserver.prototype.onNext = function (value) {\n if (!this.isStopped) { this.next(value); }\n };\n\n /**\n * Notifies the observer that an exception has occurred.\n * @param {Any} error The error that has occurred.\n */\n AbstractObserver.prototype.onError = function (error) {\n if (!this.isStopped) {\n this.isStopped = true;\n this.error(error);\n }\n };\n\n /**\n * Notifies the observer of the end of the sequence.\n */\n AbstractObserver.prototype.onCompleted = function () {\n if (!this.isStopped) {\n this.isStopped = true;\n this.completed();\n }\n };\n\n /**\n * Disposes the observer, causing it to transition to the stopped state.\n */\n AbstractObserver.prototype.dispose = function () {\n this.isStopped = true;\n };\n\n AbstractObserver.prototype.fail = function (e) {\n if (!this.isStopped) {\n this.isStopped = true;\n this.error(e);\n return true;\n }\n\n return false;\n };\n\n return AbstractObserver;\n }(Observer));\n\r\n /**\n * Class to create an Observer instance from delegate-based implementations of the on* methods.\n */\n var AnonymousObserver = Rx.AnonymousObserver = (function (__super__) {\n inherits(AnonymousObserver, __super__);\n\n /**\n * Creates an observer from the specified OnNext, OnError, and OnCompleted actions.\n * @param {Any} onNext Observer's OnNext action implementation.\n * @param {Any} onError Observer's OnError action implementation.\n * @param {Any} onCompleted Observer's OnCompleted action implementation.\n */\n function AnonymousObserver(onNext, onError, onCompleted) {\n __super__.call(this);\n this._onNext = onNext;\n this._onError = onError;\n this._onCompleted = onCompleted;\n }\n\n /**\n * Calls the onNext action.\n * @param {Any} value Next element in the sequence.\n */\n AnonymousObserver.prototype.next = function (value) {\n this._onNext(value);\n };\n\n /**\n * Calls the onError action.\n * @param {Any} error The error that has occurred.\n */\n AnonymousObserver.prototype.error = function (error) {\n this._onError(error);\n };\n\n /**\n * Calls the onCompleted action.\n */\n AnonymousObserver.prototype.completed = function () {\n this._onCompleted();\n };\n\n return AnonymousObserver;\n }(AbstractObserver));\n\r\n var CheckedObserver = (function (__super__) {\n inherits(CheckedObserver, __super__);\n\n function CheckedObserver(observer) {\n __super__.call(this);\n this._observer = observer;\n this._state = 0; // 0 - idle, 1 - busy, 2 - done\n }\n\n var CheckedObserverPrototype = CheckedObserver.prototype;\n\n CheckedObserverPrototype.onNext = function (value) {\n this.checkAccess();\n var res = tryCatch(this._observer.onNext).call(this._observer, value);\n this._state = 0;\n res === errorObj && thrower(res.e);\n };\n\n CheckedObserverPrototype.onError = function (err) {\n this.checkAccess();\n var res = tryCatch(this._observer.onError).call(this._observer, err);\n this._state = 2;\n res === errorObj && thrower(res.e);\n };\n\n CheckedObserverPrototype.onCompleted = function () {\n this.checkAccess();\n var res = tryCatch(this._observer.onCompleted).call(this._observer);\n this._state = 2;\n res === errorObj && thrower(res.e);\n };\n\n CheckedObserverPrototype.checkAccess = function () {\n if (this._state === 1) { throw new Error('Re-entrancy detected'); }\n if (this._state === 2) { throw new Error('Observer completed'); }\n if (this._state === 0) { this._state = 1; }\n };\n\n return CheckedObserver;\n }(Observer));\n\r\n var ScheduledObserver = Rx.internals.ScheduledObserver = (function (__super__) {\n inherits(ScheduledObserver, __super__);\n\n function ScheduledObserver(scheduler, observer) {\n __super__.call(this);\n this.scheduler = scheduler;\n this.observer = observer;\n this.isAcquired = false;\n this.hasFaulted = false;\n this.queue = [];\n this.disposable = new SerialDisposable();\n }\n\n ScheduledObserver.prototype.next = function (value) {\n var self = this;\n this.queue.push(function () { self.observer.onNext(value); });\n };\n\n ScheduledObserver.prototype.error = function (e) {\n var self = this;\n this.queue.push(function () { self.observer.onError(e); });\n };\n\n ScheduledObserver.prototype.completed = function () {\n var self = this;\n this.queue.push(function () { self.observer.onCompleted(); });\n };\n\n ScheduledObserver.prototype.ensureActive = function () {\n var isOwner = false, parent = this;\n if (!this.hasFaulted && this.queue.length > 0) {\n isOwner = !this.isAcquired;\n this.isAcquired = true;\n }\n if (isOwner) {\n this.disposable.setDisposable(this.scheduler.scheduleRecursive(function (self) {\n var work;\n if (parent.queue.length > 0) {\n work = parent.queue.shift();\n } else {\n parent.isAcquired = false;\n return;\n }\n try {\n work();\n } catch (ex) {\n parent.queue = [];\n parent.hasFaulted = true;\n throw ex;\n }\n self();\n }));\n }\n };\n\n ScheduledObserver.prototype.dispose = function () {\n __super__.prototype.dispose.call(this);\n this.disposable.dispose();\n };\n\n return ScheduledObserver;\n }(AbstractObserver));\n\r\n var ObserveOnObserver = (function (__super__) {\n inherits(ObserveOnObserver, __super__);\n\n function ObserveOnObserver(scheduler, observer, cancel) {\n __super__.call(this, scheduler, observer);\n this._cancel = cancel;\n }\n\n ObserveOnObserver.prototype.next = function (value) {\n __super__.prototype.next.call(this, value);\n this.ensureActive();\n };\n\n ObserveOnObserver.prototype.error = function (e) {\n __super__.prototype.error.call(this, e);\n this.ensureActive();\n };\n\n ObserveOnObserver.prototype.completed = function () {\n __super__.prototype.completed.call(this);\n this.ensureActive();\n };\n\n ObserveOnObserver.prototype.dispose = function () {\n __super__.prototype.dispose.call(this);\n this._cancel && this._cancel.dispose();\n this._cancel = null;\n };\n\n return ObserveOnObserver;\n })(ScheduledObserver);\n\r\n var observableProto;\n\n /**\n * Represents a push-style collection.\n */\n var Observable = Rx.Observable = (function () {\n\n function Observable(subscribe) {\n if (Rx.config.longStackSupport && hasStacks) {\n try {\n throw new Error();\n } catch (e) {\n this.stack = e.stack.substring(e.stack.indexOf(\"\\n\") + 1);\n }\n\n var self = this;\n this._subscribe = function (observer) {\n var oldOnError = observer.onError.bind(observer);\n\n observer.onError = function (err) {\n makeStackTraceLong(err, self);\n oldOnError(err);\n };\n\n return subscribe.call(self, observer);\n };\n } else {\n this._subscribe = subscribe;\n }\n }\n\n observableProto = Observable.prototype;\n\n /**\n * Subscribes an observer to the observable sequence.\n * @param {Mixed} [observerOrOnNext] The object that is to receive notifications or an action to invoke for each element in the observable sequence.\n * @param {Function} [onError] Action to invoke upon exceptional termination of the observable sequence.\n * @param {Function} [onCompleted] Action to invoke upon graceful termination of the observable sequence.\n * @returns {Diposable} A disposable handling the subscriptions and unsubscriptions.\n */\n observableProto.subscribe = observableProto.forEach = function (observerOrOnNext, onError, onCompleted) {\n return this._subscribe(typeof observerOrOnNext === 'object' ?\n observerOrOnNext :\n observerCreate(observerOrOnNext, onError, onCompleted));\n };\n\n /**\n * Subscribes to the next value in the sequence with an optional \"this\" argument.\n * @param {Function} onNext The function to invoke on each element in the observable sequence.\n * @param {Any} [thisArg] Object to use as this when executing callback.\n * @returns {Disposable} A disposable handling the subscriptions and unsubscriptions.\n */\n observableProto.subscribeOnNext = function (onNext, thisArg) {\n return this._subscribe(observerCreate(typeof thisArg !== 'undefined' ? function(x) { onNext.call(thisArg, x); } : onNext));\n };\n\n /**\n * Subscribes to an exceptional condition in the sequence with an optional \"this\" argument.\n * @param {Function} onError The function to invoke upon exceptional termination of the observable sequence.\n * @param {Any} [thisArg] Object to use as this when executing callback.\n * @returns {Disposable} A disposable handling the subscriptions and unsubscriptions.\n */\n observableProto.subscribeOnError = function (onError, thisArg) {\n return this._subscribe(observerCreate(null, typeof thisArg !== 'undefined' ? function(e) { onError.call(thisArg, e); } : onError));\n };\n\n /**\n * Subscribes to the next value in the sequence with an optional \"this\" argument.\n * @param {Function} onCompleted The function to invoke upon graceful termination of the observable sequence.\n * @param {Any} [thisArg] Object to use as this when executing callback.\n * @returns {Disposable} A disposable handling the subscriptions and unsubscriptions.\n */\n observableProto.subscribeOnCompleted = function (onCompleted, thisArg) {\n return this._subscribe(observerCreate(null, null, typeof thisArg !== 'undefined' ? function() { onCompleted.call(thisArg); } : onCompleted));\n };\n\n return Observable;\n })();\n\r\n var ObservableBase = Rx.ObservableBase = (function (__super__) {\n inherits(ObservableBase, __super__);\n\n function fixSubscriber(subscriber) {\n return subscriber && isFunction(subscriber.dispose) ? subscriber :\n isFunction(subscriber) ? disposableCreate(subscriber) : disposableEmpty;\n }\n\n function setDisposable(s, state) {\n var ado = state[0], self = state[1];\n var sub = tryCatch(self.subscribeCore).call(self, ado);\n\n if (sub === errorObj) {\n if(!ado.fail(errorObj.e)) { return thrower(errorObj.e); }\n }\n ado.setDisposable(fixSubscriber(sub));\n }\n\n function subscribe(observer) {\n var ado = new AutoDetachObserver(observer), state = [ado, this];\n\n if (currentThreadScheduler.scheduleRequired()) {\n currentThreadScheduler.scheduleWithState(state, setDisposable);\n } else {\n setDisposable(null, state);\n }\n return ado;\n }\n\n function ObservableBase() {\n __super__.call(this, subscribe);\n }\n\n ObservableBase.prototype.subscribeCore = notImplemented;\n\n return ObservableBase;\n }(Observable));\n\r\n var Enumerable = Rx.internals.Enumerable = function () { };\n\n var ConcatEnumerableObservable = (function(__super__) {\n inherits(ConcatEnumerableObservable, __super__);\n function ConcatEnumerableObservable(sources) {\n this.sources = sources;\n __super__.call(this);\n }\n \n ConcatEnumerableObservable.prototype.subscribeCore = function (o) {\n var isDisposed, subscription = new SerialDisposable();\n var cancelable = immediateScheduler.scheduleRecursiveWithState(this.sources[$iterator$](), function (e, self) {\n if (isDisposed) { return; }\n var currentItem = tryCatch(e.next).call(e);\n if (currentItem === errorObj) { return o.onError(currentItem.e); }\n\n if (currentItem.done) {\n return o.onCompleted();\n }\n\n // Check if promise\n var currentValue = currentItem.value;\n isPromise(currentValue) && (currentValue = observableFromPromise(currentValue));\n\n var d = new SingleAssignmentDisposable();\n subscription.setDisposable(d);\n d.setDisposable(currentValue.subscribe(new InnerObserver(o, self, e)));\n });\n\n return new CompositeDisposable(subscription, cancelable, disposableCreate(function () {\n isDisposed = true;\n }));\n };\n \n function InnerObserver(o, s, e) {\n this.o = o;\n this.s = s;\n this.e = e;\n this.isStopped = false;\n }\n InnerObserver.prototype.onNext = function (x) { if(!this.isStopped) { this.o.onNext(x); } };\n InnerObserver.prototype.onError = function (err) {\n if (!this.isStopped) {\n this.isStopped = true;\n this.o.onError(err);\n }\n };\n InnerObserver.prototype.onCompleted = function () {\n if (!this.isStopped) {\n this.isStopped = true;\n this.s(this.e);\n }\n };\n InnerObserver.prototype.dispose = function () { this.isStopped = true; };\n InnerObserver.prototype.fail = function (err) {\n if (!this.isStopped) {\n this.isStopped = true;\n this.o.onError(err);\n return true;\n }\n return false;\n };\n \n return ConcatEnumerableObservable;\n }(ObservableBase));\n\n Enumerable.prototype.concat = function () {\n return new ConcatEnumerableObservable(this);\n };\n \n var CatchErrorObservable = (function(__super__) {\n inherits(CatchErrorObservable, __super__);\n function CatchErrorObservable(sources) {\n this.sources = sources;\n __super__.call(this);\n }\n \n CatchErrorObservable.prototype.subscribeCore = function (o) {\n var e = this.sources[$iterator$]();\n\n var isDisposed, subscription = new SerialDisposable();\n var cancelable = immediateScheduler.scheduleRecursiveWithState(null, function (lastException, self) {\n if (isDisposed) { return; }\n var currentItem = tryCatch(e.next).call(e);\n if (currentItem === errorObj) { return o.onError(currentItem.e); }\n\n if (currentItem.done) {\n return lastException !== null ? o.onError(lastException) : o.onCompleted();\n }\n\n // Check if promise\n var currentValue = currentItem.value;\n isPromise(currentValue) && (currentValue = observableFromPromise(currentValue));\n\n var d = new SingleAssignmentDisposable();\n subscription.setDisposable(d);\n d.setDisposable(currentValue.subscribe(\n function(x) { o.onNext(x); },\n self,\n function() { o.onCompleted(); }));\n });\n return new CompositeDisposable(subscription, cancelable, disposableCreate(function () {\n isDisposed = true;\n }));\n };\n \n return CatchErrorObservable;\n }(ObservableBase));\n\n Enumerable.prototype.catchError = function () {\n return new CatchErrorObservable(this);\n };\n\n Enumerable.prototype.catchErrorWhen = function (notificationHandler) {\n var sources = this;\n return new AnonymousObservable(function (o) {\n var exceptions = new Subject(),\n notifier = new Subject(),\n handled = notificationHandler(exceptions),\n notificationDisposable = handled.subscribe(notifier);\n\n var e = sources[$iterator$]();\n\n var isDisposed,\n lastException,\n subscription = new SerialDisposable();\n var cancelable = immediateScheduler.scheduleRecursive(function (self) {\n if (isDisposed) { return; }\n var currentItem = tryCatch(e.next).call(e);\n if (currentItem === errorObj) { return o.onError(currentItem.e); }\n\n if (currentItem.done) {\n if (lastException) {\n o.onError(lastException);\n } else {\n o.onCompleted();\n }\n return;\n }\n\n // Check if promise\n var currentValue = currentItem.value;\n isPromise(currentValue) && (currentValue = observableFromPromise(currentValue));\n\n var outer = new SingleAssignmentDisposable();\n var inner = new SingleAssignmentDisposable();\n subscription.setDisposable(new CompositeDisposable(inner, outer));\n outer.setDisposable(currentValue.subscribe(\n function(x) { o.onNext(x); },\n function (exn) {\n inner.setDisposable(notifier.subscribe(self, function(ex) {\n o.onError(ex);\n }, function() {\n o.onCompleted();\n }));\n\n exceptions.onNext(exn);\n },\n function() { o.onCompleted(); }));\n });\n\n return new CompositeDisposable(notificationDisposable, subscription, cancelable, disposableCreate(function () {\n isDisposed = true;\n }));\n });\n };\n \n var RepeatEnumerable = (function (__super__) {\n inherits(RepeatEnumerable, __super__);\n \n function RepeatEnumerable(v, c) {\n this.v = v;\n this.c = c == null ? -1 : c;\n }\n RepeatEnumerable.prototype[$iterator$] = function () {\n return new RepeatEnumerator(this); \n };\n \n function RepeatEnumerator(p) {\n this.v = p.v;\n this.l = p.c;\n }\n RepeatEnumerator.prototype.next = function () {\n if (this.l === 0) { return doneEnumerator; }\n if (this.l > 0) { this.l--; }\n return { done: false, value: this.v }; \n };\n \n return RepeatEnumerable;\n }(Enumerable));\n\n var enumerableRepeat = Enumerable.repeat = function (value, repeatCount) {\n return new RepeatEnumerable(value, repeatCount);\n };\n \n var OfEnumerable = (function(__super__) {\n inherits(OfEnumerable, __super__);\n function OfEnumerable(s, fn, thisArg) {\n this.s = s;\n this.fn = fn ? bindCallback(fn, thisArg, 3) : null;\n }\n OfEnumerable.prototype[$iterator$] = function () {\n return new OfEnumerator(this);\n };\n \n function OfEnumerator(p) {\n this.i = -1;\n this.s = p.s;\n this.l = this.s.length;\n this.fn = p.fn;\n }\n OfEnumerator.prototype.next = function () {\n return ++this.i < this.l ?\n { done: false, value: !this.fn ? this.s[this.i] : this.fn(this.s[this.i], this.i, this.s) } :\n doneEnumerator; \n };\n \n return OfEnumerable;\n }(Enumerable));\n\n var enumerableOf = Enumerable.of = function (source, selector, thisArg) {\n return new OfEnumerable(source, selector, thisArg);\n };\n\r\n /**\n * Wraps the source sequence in order to run its observer callbacks on the specified scheduler.\n *\n * This only invokes observer callbacks on a scheduler. In case the subscription and/or unsubscription actions have side-effects\n * that require to be run on a scheduler, use subscribeOn.\n *\n * @param {Scheduler} scheduler Scheduler to notify observers on.\n * @returns {Observable} The source sequence whose observations happen on the specified scheduler.\n */\n observableProto.observeOn = function (scheduler) {\n var source = this;\n return new AnonymousObservable(function (observer) {\n return source.subscribe(new ObserveOnObserver(scheduler, observer));\n }, source);\n };\n\r\n /**\n * Wraps the source sequence in order to run its subscription and unsubscription logic on the specified scheduler. This operation is not commonly used;\n * see the remarks section for more information on the distinction between subscribeOn and observeOn.\n\n * This only performs the side-effects of subscription and unsubscription on the specified scheduler. In order to invoke observer\n * callbacks on a scheduler, use observeOn.\n\n * @param {Scheduler} scheduler Scheduler to perform subscription and unsubscription actions on.\n * @returns {Observable} The source sequence whose subscriptions and unsubscriptions happen on the specified scheduler.\n */\n observableProto.subscribeOn = function (scheduler) {\n var source = this;\n return new AnonymousObservable(function (observer) {\n var m = new SingleAssignmentDisposable(), d = new SerialDisposable();\n d.setDisposable(m);\n m.setDisposable(scheduler.schedule(function () {\n d.setDisposable(new ScheduledDisposable(scheduler, source.subscribe(observer)));\n }));\n return d;\n }, source);\n };\n\r\n var FromPromiseObservable = (function(__super__) {\n inherits(FromPromiseObservable, __super__);\n function FromPromiseObservable(p) {\n this.p = p;\n __super__.call(this);\n }\n \n FromPromiseObservable.prototype.subscribeCore = function(o) {\n this.p.then(function (data) {\n o.onNext(data);\n o.onCompleted();\n }, function (err) { o.onError(err); });\n return disposableEmpty; \n };\n \n return FromPromiseObservable;\n }(ObservableBase)); \n \n /**\n * Converts a Promise to an Observable sequence\n * @param {Promise} An ES6 Compliant promise.\n * @returns {Observable} An Observable sequence which wraps the existing promise success and failure.\n */\n var observableFromPromise = Observable.fromPromise = function (promise) {\n return new FromPromiseObservable(promise);\n };\r\n /*\n * Converts an existing observable sequence to an ES6 Compatible Promise\n * @example\n * var promise = Rx.Observable.return(42).toPromise(RSVP.Promise);\n *\n * // With config\n * Rx.config.Promise = RSVP.Promise;\n * var promise = Rx.Observable.return(42).toPromise();\n * @param {Function} [promiseCtor] The constructor of the promise. If not provided, it looks for it in Rx.config.Promise.\n * @returns {Promise} An ES6 compatible promise with the last value from the observable sequence.\n */\n observableProto.toPromise = function (promiseCtor) {\n promiseCtor || (promiseCtor = Rx.config.Promise);\n if (!promiseCtor) { throw new NotSupportedError('Promise type not provided nor in Rx.config.Promise'); }\n var source = this;\n return new promiseCtor(function (resolve, reject) {\n // No cancellation can be done\n var value, hasValue = false;\n source.subscribe(function (v) {\n value = v;\n hasValue = true;\n }, reject, function () {\n hasValue && resolve(value);\n });\n });\n };\n\r\n var ToArrayObservable = (function(__super__) {\n inherits(ToArrayObservable, __super__);\n function ToArrayObservable(source) {\n this.source = source;\n __super__.call(this);\n }\n\n ToArrayObservable.prototype.subscribeCore = function(o) {\n return this.source.subscribe(new InnerObserver(o));\n };\n\n function InnerObserver(o) {\n this.o = o;\n this.a = [];\n this.isStopped = false;\n }\n InnerObserver.prototype.onNext = function (x) { if(!this.isStopped) { this.a.push(x); } };\n InnerObserver.prototype.onError = function (e) {\n if (!this.isStopped) {\n this.isStopped = true;\n this.o.onError(e);\n }\n };\n InnerObserver.prototype.onCompleted = function () {\n if (!this.isStopped) {\n this.isStopped = true;\n this.o.onNext(this.a);\n this.o.onCompleted();\n }\n };\n InnerObserver.prototype.dispose = function () { this.isStopped = true; }\n InnerObserver.prototype.fail = function (e) {\n if (!this.isStopped) {\n this.isStopped = true;\n this.o.onError(e);\n return true;\n }\n \n return false;\n };\n\n return ToArrayObservable;\n }(ObservableBase));\n\n /**\n * Creates an array from an observable sequence.\n * @returns {Observable} An observable sequence containing a single element with a list containing all the elements of the source sequence.\n */\n observableProto.toArray = function () {\n return new ToArrayObservable(this);\n };\n\r\n /**\n * Creates an observable sequence from a specified subscribe method implementation.\n * @example\n * var res = Rx.Observable.create(function (observer) { return function () { } );\n * var res = Rx.Observable.create(function (observer) { return Rx.Disposable.empty; } );\n * var res = Rx.Observable.create(function (observer) { } );\n * @param {Function} subscribe Implementation of the resulting observable sequence's subscribe method, returning a function that will be wrapped in a Disposable.\n * @returns {Observable} The observable sequence with the specified implementation for the Subscribe method.\n */\n Observable.create = Observable.createWithDisposable = function (subscribe, parent) {\n return new AnonymousObservable(subscribe, parent);\n };\n\r\n /**\n * Returns an observable sequence that invokes the specified factory function whenever a new observer subscribes.\n *\n * @example\n * var res = Rx.Observable.defer(function () { return Rx.Observable.fromArray([1,2,3]); });\n * @param {Function} observableFactory Observable factory function to invoke for each observer that subscribes to the resulting sequence or Promise.\n * @returns {Observable} An observable sequence whose observers trigger an invocation of the given observable factory function.\n */\n var observableDefer = Observable.defer = function (observableFactory) {\n return new AnonymousObservable(function (observer) {\n var result;\n try {\n result = observableFactory();\n } catch (e) {\n return observableThrow(e).subscribe(observer);\n }\n isPromise(result) && (result = observableFromPromise(result));\n return result.subscribe(observer);\n });\n };\n\r\n var EmptyObservable = (function(__super__) {\n inherits(EmptyObservable, __super__);\n function EmptyObservable(scheduler) {\n this.scheduler = scheduler;\n __super__.call(this);\n }\n\n EmptyObservable.prototype.subscribeCore = function (observer) {\n var sink = new EmptySink(observer, this);\n return sink.run();\n };\n\n function EmptySink(observer, parent) {\n this.observer = observer;\n this.parent = parent;\n }\n\n function scheduleItem(s, state) {\n state.onCompleted();\n }\n\n EmptySink.prototype.run = function () {\n return this.parent.scheduler.scheduleWithState(this.observer, scheduleItem);\n };\n\n return EmptyObservable;\n }(ObservableBase));\n\n /**\n * Returns an empty observable sequence, using the specified scheduler to send out the single OnCompleted message.\n *\n * @example\n * var res = Rx.Observable.empty();\n * var res = Rx.Observable.empty(Rx.Scheduler.timeout);\n * @param {Scheduler} [scheduler] Scheduler to send the termination call on.\n * @returns {Observable} An observable sequence with no elements.\n */\n var observableEmpty = Observable.empty = function (scheduler) {\n isScheduler(scheduler) || (scheduler = immediateScheduler);\n return new EmptyObservable(scheduler);\n };\n\r\n var FromObservable = (function(__super__) {\n inherits(FromObservable, __super__);\n function FromObservable(iterable, mapper, scheduler) {\n this.iterable = iterable;\n this.mapper = mapper;\n this.scheduler = scheduler;\n __super__.call(this);\n }\n\n FromObservable.prototype.subscribeCore = function (observer) {\n var sink = new FromSink(observer, this);\n return sink.run();\n };\n\n return FromObservable;\n }(ObservableBase));\n\n var FromSink = (function () {\n function FromSink(observer, parent) {\n this.observer = observer;\n this.parent = parent;\n }\n\n FromSink.prototype.run = function () {\n var list = Object(this.parent.iterable),\n it = getIterable(list),\n observer = this.observer,\n mapper = this.parent.mapper;\n\n function loopRecursive(i, recurse) {\n try {\n var next = it.next();\n } catch (e) {\n return observer.onError(e);\n }\n if (next.done) {\n return observer.onCompleted();\n }\n\n var result = next.value;\n\n if (mapper) {\n try {\n result = mapper(result, i);\n } catch (e) {\n return observer.onError(e);\n }\n }\n\n observer.onNext(result);\n recurse(i + 1);\n }\n\n return this.parent.scheduler.scheduleRecursiveWithState(0, loopRecursive);\n };\n\n return FromSink;\n }());\n\n var maxSafeInteger = Math.pow(2, 53) - 1;\n\n function StringIterable(str) {\n this._s = s;\n }\n\n StringIterable.prototype[$iterator$] = function () {\n return new StringIterator(this._s);\n };\n\n function StringIterator(str) {\n this._s = s;\n this._l = s.length;\n this._i = 0;\n }\n\n StringIterator.prototype[$iterator$] = function () {\n return this;\n };\n\n StringIterator.prototype.next = function () {\n return this._i < this._l ? { done: false, value: this._s.charAt(this._i++) } : doneEnumerator;\n };\n\n function ArrayIterable(a) {\n this._a = a;\n }\n\n ArrayIterable.prototype[$iterator$] = function () {\n return new ArrayIterator(this._a);\n };\n\n function ArrayIterator(a) {\n this._a = a;\n this._l = toLength(a);\n this._i = 0;\n }\n\n ArrayIterator.prototype[$iterator$] = function () {\n return this;\n };\n\n ArrayIterator.prototype.next = function () {\n return this._i < this._l ? { done: false, value: this._a[this._i++] } : doneEnumerator;\n };\n\n function numberIsFinite(value) {\n return typeof value === 'number' && root.isFinite(value);\n }\n\n function isNan(n) {\n return n !== n;\n }\n\n function getIterable(o) {\n var i = o[$iterator$], it;\n if (!i && typeof o === 'string') {\n it = new StringIterable(o);\n return it[$iterator$]();\n }\n if (!i && o.length !== undefined) {\n it = new ArrayIterable(o);\n return it[$iterator$]();\n }\n if (!i) { throw new TypeError('Object is not iterable'); }\n return o[$iterator$]();\n }\n\n function sign(value) {\n var number = +value;\n if (number === 0) { return number; }\n if (isNaN(number)) { return number; }\n return number < 0 ? -1 : 1;\n }\n\n function toLength(o) {\n var len = +o.length;\n if (isNaN(len)) { return 0; }\n if (len === 0 || !numberIsFinite(len)) { return len; }\n len = sign(len) * Math.floor(Math.abs(len));\n if (len <= 0) { return 0; }\n if (len > maxSafeInteger) { return maxSafeInteger; }\n return len;\n }\n\n /**\n * This method creates a new Observable sequence from an array-like or iterable object.\n * @param {Any} arrayLike An array-like or iterable object to convert to an Observable sequence.\n * @param {Function} [mapFn] Map function to call on every element of the array.\n * @param {Any} [thisArg] The context to use calling the mapFn if provided.\n * @param {Scheduler} [scheduler] Optional scheduler to use for scheduling. If not provided, defaults to Scheduler.currentThread.\n */\n var observableFrom = Observable.from = function (iterable, mapFn, thisArg, scheduler) {\n if (iterable == null) {\n throw new Error('iterable cannot be null.')\n }\n if (mapFn && !isFunction(mapFn)) {\n throw new Error('mapFn when provided must be a function');\n }\n if (mapFn) {\n var mapper = bindCallback(mapFn, thisArg, 2);\n }\n isScheduler(scheduler) || (scheduler = currentThreadScheduler);\n return new FromObservable(iterable, mapper, scheduler);\n }\n\r\n var FromArrayObservable = (function(__super__) {\n inherits(FromArrayObservable, __super__);\n function FromArrayObservable(args, scheduler) {\n this.args = args;\n this.scheduler = scheduler;\n __super__.call(this);\n }\n\n FromArrayObservable.prototype.subscribeCore = function (observer) {\n var sink = new FromArraySink(observer, this);\n return sink.run();\n };\n\n return FromArrayObservable;\n }(ObservableBase));\n\n function FromArraySink(observer, parent) {\n this.observer = observer;\n this.parent = parent;\n }\n\n FromArraySink.prototype.run = function () {\n var observer = this.observer, args = this.parent.args, len = args.length;\n function loopRecursive(i, recurse) {\n if (i < len) {\n observer.onNext(args[i]);\n recurse(i + 1);\n } else {\n observer.onCompleted();\n }\n }\n\n return this.parent.scheduler.scheduleRecursiveWithState(0, loopRecursive);\n };\n\r\n /**\n * Converts an array to an observable sequence, using an optional scheduler to enumerate the array.\n * @deprecated use Observable.from or Observable.of\n * @param {Scheduler} [scheduler] Scheduler to run the enumeration of the input sequence on.\n * @returns {Observable} The observable sequence whose elements are pulled from the given enumerable sequence.\n */\n var observableFromArray = Observable.fromArray = function (array, scheduler) {\n isScheduler(scheduler) || (scheduler = currentThreadScheduler);\n return new FromArrayObservable(array, scheduler)\n };\n\r\n /**\n * Generates an observable sequence by running a state-driven loop producing the sequence's elements, using the specified scheduler to send out observer messages.\n *\n * @example\n * var res = Rx.Observable.generate(0, function (x) { return x < 10; }, function (x) { return x + 1; }, function (x) { return x; });\n * var res = Rx.Observable.generate(0, function (x) { return x < 10; }, function (x) { return x + 1; }, function (x) { return x; }, Rx.Scheduler.timeout);\n * @param {Mixed} initialState Initial state.\n * @param {Function} condition Condition to terminate generation (upon returning false).\n * @param {Function} iterate Iteration step function.\n * @param {Function} resultSelector Selector function for results produced in the sequence.\n * @param {Scheduler} [scheduler] Scheduler on which to run the generator loop. If not provided, defaults to Scheduler.currentThread.\n * @returns {Observable} The generated sequence.\n */\n Observable.generate = function (initialState, condition, iterate, resultSelector, scheduler) {\n isScheduler(scheduler) || (scheduler = currentThreadScheduler);\n return new AnonymousObservable(function (o) {\n var first = true;\n return scheduler.scheduleRecursiveWithState(initialState, function (state, self) {\n var hasResult, result;\n try {\n if (first) {\n first = false;\n } else {\n state = iterate(state);\n }\n hasResult = condition(state);\n hasResult && (result = resultSelector(state));\n } catch (e) {\n return o.onError(e);\n }\n if (hasResult) {\n o.onNext(result);\n self(state);\n } else {\n o.onCompleted();\n }\n });\n });\n };\n\r\n function observableOf (scheduler, array) {\n isScheduler(scheduler) || (scheduler = currentThreadScheduler);\n return new FromArrayObservable(array, scheduler);\n }\n\n /**\n * This method creates a new Observable instance with a variable number of arguments, regardless of number or type of the arguments.\n * @returns {Observable} The observable sequence whose elements are pulled from the given arguments.\n */\n Observable.of = function () {\n var len = arguments.length, args = new Array(len);\n for(var i = 0; i < len; i++) { args[i] = arguments[i]; }\n return new FromArrayObservable(args, currentThreadScheduler);\n };\n\n /**\n * This method creates a new Observable instance with a variable number of arguments, regardless of number or type of the arguments.\n * @param {Scheduler} scheduler A scheduler to use for scheduling the arguments.\n * @returns {Observable} The observable sequence whose elements are pulled from the given arguments.\n */\n Observable.ofWithScheduler = function (scheduler) {\n var len = arguments.length, args = new Array(len - 1);\n for(var i = 1; i < len; i++) { args[i - 1] = arguments[i]; }\n return new FromArrayObservable(args, scheduler);\n };\n\r\n /**\n * Creates an Observable sequence from changes to an array using Array.observe.\n * @param {Array} array An array to observe changes.\n * @returns {Observable} An observable sequence containing changes to an array from Array.observe.\n */\n Observable.ofArrayChanges = function(array) {\n if (!Array.isArray(array)) { throw new TypeError('Array.observe only accepts arrays.'); }\n if (typeof Array.observe !== 'function' && typeof Array.unobserve !== 'function') { throw new TypeError('Array.observe is not supported on your platform') }\n return new AnonymousObservable(function(observer) {\n function observerFn(changes) {\n for(var i = 0, len = changes.length; i < len; i++) {\n observer.onNext(changes[i]);\n }\n }\n \n Array.observe(array, observerFn);\n\n return function () {\n Array.unobserve(array, observerFn);\n };\n });\n };\n\r\n /**\n * Creates an Observable sequence from changes to an object using Object.observe.\n * @param {Object} obj An object to observe changes.\n * @returns {Observable} An observable sequence containing changes to an object from Object.observe.\n */\n Observable.ofObjectChanges = function(obj) {\n if (obj == null) { throw new TypeError('object must not be null or undefined.'); }\n if (typeof Object.observe !== 'function' && typeof Object.unobserve !== 'function') { throw new TypeError('Object.observe is not supported on your platform') }\n return new AnonymousObservable(function(observer) {\n function observerFn(changes) {\n for(var i = 0, len = changes.length; i < len; i++) {\n observer.onNext(changes[i]);\n }\n }\n\n Object.observe(obj, observerFn);\n\n return function () {\n Object.unobserve(obj, observerFn);\n };\n });\n };\n\r\n var NeverObservable = (function(__super__) {\n inherits(NeverObservable, __super__);\n function NeverObservable() {\n __super__.call(this);\n }\n\n NeverObservable.prototype.subscribeCore = function (observer) {\n return disposableEmpty;\n };\n\n return NeverObservable;\n }(ObservableBase));\n\n /**\n * Returns a non-terminating observable sequence, which can be used to denote an infinite duration (e.g. when using reactive joins).\n * @returns {Observable} An observable sequence whose observers will never get called.\n */\n var observableNever = Observable.never = function () {\n return new NeverObservable();\n };\n\r\n var PairsObservable = (function(__super__) {\n inherits(PairsObservable, __super__);\n function PairsObservable(obj, scheduler) {\n this.obj = obj;\n this.keys = Object.keys(obj);\n this.scheduler = scheduler;\n __super__.call(this);\n }\n\n PairsObservable.prototype.subscribeCore = function (observer) {\n var sink = new PairsSink(observer, this);\n return sink.run();\n };\n\n return PairsObservable;\n }(ObservableBase));\n\n function PairsSink(observer, parent) {\n this.observer = observer;\n this.parent = parent;\n }\n\n PairsSink.prototype.run = function () {\n var observer = this.observer, obj = this.parent.obj, keys = this.parent.keys, len = keys.length;\n function loopRecursive(i, recurse) {\n if (i < len) {\n var key = keys[i];\n observer.onNext([key, obj[key]]);\n recurse(i + 1);\n } else {\n observer.onCompleted();\n }\n }\n\n return this.parent.scheduler.scheduleRecursiveWithState(0, loopRecursive);\n };\n\n /**\n * Convert an object into an observable sequence of [key, value] pairs.\n * @param {Object} obj The object to inspect.\n * @param {Scheduler} [scheduler] Scheduler to run the enumeration of the input sequence on.\n * @returns {Observable} An observable sequence of [key, value] pairs from the object.\n */\n Observable.pairs = function (obj, scheduler) {\n scheduler || (scheduler = currentThreadScheduler);\n return new PairsObservable(obj, scheduler);\n };\n\r\n var RangeObservable = (function(__super__) {\n inherits(RangeObservable, __super__);\n function RangeObservable(start, count, scheduler) {\n this.start = start;\n this.rangeCount = count;\n this.scheduler = scheduler;\n __super__.call(this);\n }\n\n RangeObservable.prototype.subscribeCore = function (observer) {\n var sink = new RangeSink(observer, this);\n return sink.run();\n };\n\n return RangeObservable;\n }(ObservableBase));\n\n var RangeSink = (function () {\n function RangeSink(observer, parent) {\n this.observer = observer;\n this.parent = parent;\n }\n\n RangeSink.prototype.run = function () {\n var start = this.parent.start, count = this.parent.rangeCount, observer = this.observer;\n function loopRecursive(i, recurse) {\n if (i < count) {\n observer.onNext(start + i);\n recurse(i + 1);\n } else {\n observer.onCompleted();\n }\n }\n\n return this.parent.scheduler.scheduleRecursiveWithState(0, loopRecursive);\n };\n\n return RangeSink;\n }());\n\n /**\n * Generates an observable sequence of integral numbers within a specified range, using the specified scheduler to send out observer messages.\n * @param {Number} start The value of the first integer in the sequence.\n * @param {Number} count The number of sequential integers to generate.\n * @param {Scheduler} [scheduler] Scheduler to run the generator loop on. If not specified, defaults to Scheduler.currentThread.\n * @returns {Observable} An observable sequence that contains a range of sequential integral numbers.\n */\n Observable.range = function (start, count, scheduler) {\n isScheduler(scheduler) || (scheduler = currentThreadScheduler);\n return new RangeObservable(start, count, scheduler);\n };\n\r\n var RepeatObservable = (function(__super__) {\n inherits(RepeatObservable, __super__);\n function RepeatObservable(value, repeatCount, scheduler) {\n this.value = value;\n this.repeatCount = repeatCount == null ? -1 : repeatCount;\n this.scheduler = scheduler;\n __super__.call(this);\n }\n\n RepeatObservable.prototype.subscribeCore = function (observer) {\n var sink = new RepeatSink(observer, this);\n return sink.run();\n };\n\n return RepeatObservable;\n }(ObservableBase));\n\n function RepeatSink(observer, parent) {\n this.observer = observer;\n this.parent = parent;\n }\n\n RepeatSink.prototype.run = function () {\n var observer = this.observer, value = this.parent.value;\n function loopRecursive(i, recurse) {\n if (i === -1 || i > 0) {\n observer.onNext(value);\n i > 0 && i--;\n }\n if (i === 0) { return observer.onCompleted(); }\n recurse(i);\n }\n\n return this.parent.scheduler.scheduleRecursiveWithState(this.parent.repeatCount, loopRecursive);\n };\n\n /**\n * Generates an observable sequence that repeats the given element the specified number of times, using the specified scheduler to send out observer messages.\n * @param {Mixed} value Element to repeat.\n * @param {Number} repeatCount [Optiona] Number of times to repeat the element. If not specified, repeats indefinitely.\n * @param {Scheduler} scheduler Scheduler to run the producer loop on. If not specified, defaults to Scheduler.immediate.\n * @returns {Observable} An observable sequence that repeats the given element the specified number of times.\n */\n Observable.repeat = function (value, repeatCount, scheduler) {\n isScheduler(scheduler) || (scheduler = currentThreadScheduler);\n return new RepeatObservable(value, repeatCount, scheduler);\n };\n\r\n var JustObservable = (function(__super__) {\n inherits(JustObservable, __super__);\n function JustObservable(value, scheduler) {\n this.value = value;\n this.scheduler = scheduler;\n __super__.call(this);\n }\n\n JustObservable.prototype.subscribeCore = function (observer) {\n var sink = new JustSink(observer, this);\n return sink.run();\n };\n\n function JustSink(observer, parent) {\n this.observer = observer;\n this.parent = parent;\n }\n\n function scheduleItem(s, state) {\n var value = state[0], observer = state[1];\n observer.onNext(value);\n observer.onCompleted();\n }\n\n JustSink.prototype.run = function () {\n return this.parent.scheduler.scheduleWithState([this.parent.value, this.observer], scheduleItem);\n };\n\n return JustObservable;\n }(ObservableBase));\n\n /**\n * Returns an observable sequence that contains a single element, using the specified scheduler to send out observer messages.\n * There is an alias called 'just' or browsers <IE9.\n * @param {Mixed} value Single element in the resulting observable sequence.\n * @param {Scheduler} scheduler Scheduler to send the single element on. If not specified, defaults to Scheduler.immediate.\n * @returns {Observable} An observable sequence containing the single specified element.\n */\n var observableReturn = Observable['return'] = Observable.just = Observable.returnValue = function (value, scheduler) {\n isScheduler(scheduler) || (scheduler = immediateScheduler);\n return new JustObservable(value, scheduler);\n };\n\r\n var ThrowObservable = (function(__super__) {\n inherits(ThrowObservable, __super__);\n function ThrowObservable(error, scheduler) {\n this.error = error;\n this.scheduler = scheduler;\n __super__.call(this);\n }\n\n ThrowObservable.prototype.subscribeCore = function (o) {\n var sink = new ThrowSink(o, this);\n return sink.run();\n };\n\n function ThrowSink(o, p) {\n this.o = o;\n this.p = p;\n }\n\n function scheduleItem(s, state) {\n var e = state[0], o = state[1];\n o.onError(e);\n }\n\n ThrowSink.prototype.run = function () {\n return this.p.scheduler.scheduleWithState([this.p.error, this.o], scheduleItem);\n };\n\n return ThrowObservable;\n }(ObservableBase));\n\n /**\n * Returns an observable sequence that terminates with an exception, using the specified scheduler to send out the single onError message.\n * There is an alias to this method called 'throwError' for browsers <IE9.\n * @param {Mixed} error An object used for the sequence's termination.\n * @param {Scheduler} scheduler Scheduler to send the exceptional termination call on. If not specified, defaults to Scheduler.immediate.\n * @returns {Observable} The observable sequence that terminates exceptionally with the specified exception object.\n */\n var observableThrow = Observable['throw'] = Observable.throwError = Observable.throwException = function (error, scheduler) {\n isScheduler(scheduler) || (scheduler = immediateScheduler);\n return new ThrowObservable(error, scheduler);\n };\n\r\n /**\n * Constructs an observable sequence that depends on a resource object, whose lifetime is tied to the resulting observable sequence's lifetime.\n * @param {Function} resourceFactory Factory function to obtain a resource object.\n * @param {Function} observableFactory Factory function to obtain an observable sequence that depends on the obtained resource.\n * @returns {Observable} An observable sequence whose lifetime controls the lifetime of the dependent resource object.\n */\n Observable.using = function (resourceFactory, observableFactory) {\n return new AnonymousObservable(function (observer) {\n var disposable = disposableEmpty, resource, source;\n try {\n resource = resourceFactory();\n resource && (disposable = resource);\n source = observableFactory(resource);\n } catch (exception) {\n return new CompositeDisposable(observableThrow(exception).subscribe(observer), disposable);\n }\n return new CompositeDisposable(source.subscribe(observer), disposable);\n });\n };\n\r\n /**\n * Propagates the observable sequence or Promise that reacts first.\n * @param {Observable} rightSource Second observable sequence or Promise.\n * @returns {Observable} {Observable} An observable sequence that surfaces either of the given sequences, whichever reacted first.\n */\n observableProto.amb = function (rightSource) {\n var leftSource = this;\n return new AnonymousObservable(function (observer) {\n var choice,\n leftChoice = 'L', rightChoice = 'R',\n leftSubscription = new SingleAssignmentDisposable(),\n rightSubscription = new SingleAssignmentDisposable();\n\n isPromise(rightSource) && (rightSource = observableFromPromise(rightSource));\n\n function choiceL() {\n if (!choice) {\n choice = leftChoice;\n rightSubscription.dispose();\n }\n }\n\n function choiceR() {\n if (!choice) {\n choice = rightChoice;\n leftSubscription.dispose();\n }\n }\n\n leftSubscription.setDisposable(leftSource.subscribe(function (left) {\n choiceL();\n choice === leftChoice && observer.onNext(left);\n }, function (err) {\n choiceL();\n choice === leftChoice && observer.onError(err);\n }, function () {\n choiceL();\n choice === leftChoice && observer.onCompleted();\n }));\n\n rightSubscription.setDisposable(rightSource.subscribe(function (right) {\n choiceR();\n choice === rightChoice && observer.onNext(right);\n }, function (err) {\n choiceR();\n choice === rightChoice && observer.onError(err);\n }, function () {\n choiceR();\n choice === rightChoice && observer.onCompleted();\n }));\n\n return new CompositeDisposable(leftSubscription, rightSubscription);\n });\n };\n\r\n /**\n * Propagates the observable sequence or Promise that reacts first.\n *\n * @example\n * var = Rx.Observable.amb(xs, ys, zs);\n * @returns {Observable} An observable sequence that surfaces any of the given sequences, whichever reacted first.\n */\n Observable.amb = function () {\n var acc = observableNever(), items = [];\n if (Array.isArray(arguments[0])) {\n items = arguments[0];\n } else {\n for(var i = 0, len = arguments.length; i < len; i++) { items.push(arguments[i]); }\n }\n\n function func(previous, current) {\n return previous.amb(current);\n }\n for (var i = 0, len = items.length; i < len; i++) {\n acc = func(acc, items[i]);\n }\n return acc;\n };\n\r\n function observableCatchHandler(source, handler) {\n return new AnonymousObservable(function (o) {\n var d1 = new SingleAssignmentDisposable(), subscription = new SerialDisposable();\n subscription.setDisposable(d1);\n d1.setDisposable(source.subscribe(function (x) { o.onNext(x); }, function (e) {\n try {\n var result = handler(e);\n } catch (ex) {\n return o.onError(ex);\n }\n isPromise(result) && (result = observableFromPromise(result));\n\n var d = new SingleAssignmentDisposable();\n subscription.setDisposable(d);\n d.setDisposable(result.subscribe(o));\n }, function (x) { o.onCompleted(x); }));\n\n return subscription;\n }, source);\n }\n\n /**\n * Continues an observable sequence that is terminated by an exception with the next observable sequence.\n * @example\n * 1 - xs.catchException(ys)\n * 2 - xs.catchException(function (ex) { return ys(ex); })\n * @param {Mixed} handlerOrSecond Exception handler function that returns an observable sequence given the error that occurred in the first sequence, or a second observable sequence used to produce results when an error occurred in the first sequence.\n * @returns {Observable} An observable sequence containing the first sequence's elements, followed by the elements of the handler sequence in case an exception occurred.\n */\n observableProto['catch'] = observableProto.catchError = observableProto.catchException = function (handlerOrSecond) {\n return typeof handlerOrSecond === 'function' ?\n observableCatchHandler(this, handlerOrSecond) :\n observableCatch([this, handlerOrSecond]);\n };\n\r\n /**\n * Continues an observable sequence that is terminated by an exception with the next observable sequence.\n * @param {Array | Arguments} args Arguments or an array to use as the next sequence if an error occurs.\n * @returns {Observable} An observable sequence containing elements from consecutive source sequences until a source sequence terminates successfully.\n */\n var observableCatch = Observable.catchError = Observable['catch'] = Observable.catchException = function () {\n var items = [];\n if (Array.isArray(arguments[0])) {\n items = arguments[0];\n } else {\n for(var i = 0, len = arguments.length; i < len; i++) { items.push(arguments[i]); }\n }\n return enumerableOf(items).catchError();\n };\n\r\n /**\n * Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences or Promises produces an element.\n * This can be in the form of an argument list of observables or an array.\n *\n * @example\n * 1 - obs = observable.combineLatest(obs1, obs2, obs3, function (o1, o2, o3) { return o1 + o2 + o3; });\n * 2 - obs = observable.combineLatest([obs1, obs2, obs3], function (o1, o2, o3) { return o1 + o2 + o3; });\n * @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function.\n */\n observableProto.combineLatest = function () {\n var len = arguments.length, args = new Array(len);\n for(var i = 0; i < len; i++) { args[i] = arguments[i]; }\n if (Array.isArray(args[0])) {\n args[0].unshift(this);\n } else {\n args.unshift(this);\n }\n return combineLatest.apply(this, args);\n };\n\r\n /**\n * Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences or Promises produces an element.\n *\n * @example\n * 1 - obs = Rx.Observable.combineLatest(obs1, obs2, obs3, function (o1, o2, o3) { return o1 + o2 + o3; });\n * 2 - obs = Rx.Observable.combineLatest([obs1, obs2, obs3], function (o1, o2, o3) { return o1 + o2 + o3; });\n * @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function.\n */\n var combineLatest = Observable.combineLatest = function () {\n var len = arguments.length, args = new Array(len);\n for(var i = 0; i < len; i++) { args[i] = arguments[i]; }\n var resultSelector = args.pop();\n Array.isArray(args[0]) && (args = args[0]);\n\n return new AnonymousObservable(function (o) {\n var n = args.length,\n falseFactory = function () { return false; },\n hasValue = arrayInitialize(n, falseFactory),\n hasValueAll = false,\n isDone = arrayInitialize(n, falseFactory),\n values = new Array(n);\n\n function next(i) {\n hasValue[i] = true;\n if (hasValueAll || (hasValueAll = hasValue.every(identity))) {\n try {\n var res = resultSelector.apply(null, values);\n } catch (e) {\n return o.onError(e);\n }\n o.onNext(res);\n } else if (isDone.filter(function (x, j) { return j !== i; }).every(identity)) {\n o.onCompleted();\n }\n }\n\n function done (i) {\n isDone[i] = true;\n isDone.every(identity) && o.onCompleted();\n }\n\n var subscriptions = new Array(n);\n for (var idx = 0; idx < n; idx++) {\n (function (i) {\n var source = args[i], sad = new SingleAssignmentDisposable();\n isPromise(source) && (source = observableFromPromise(source));\n sad.setDisposable(source.subscribe(function (x) {\n values[i] = x;\n next(i);\n },\n function(e) { o.onError(e); },\n function () { done(i); }\n ));\n subscriptions[i] = sad;\n }(idx));\n }\n\n return new CompositeDisposable(subscriptions);\n }, this);\n };\n\r\n /**\n * Concatenates all the observable sequences. This takes in either an array or variable arguments to concatenate.\n * @returns {Observable} An observable sequence that contains the elements of each given sequence, in sequential order.\n */\n observableProto.concat = function () {\n for(var args = [], i = 0, len = arguments.length; i < len; i++) { args.push(arguments[i]); }\n args.unshift(this);\n return observableConcat.apply(null, args);\n };\n\r\n var ConcatObservable = (function(__super__) {\r\n inherits(ConcatObservable, __super__);\r\n function ConcatObservable(sources) {\r\n this.sources = sources;\r\n __super__.call(this);\r\n }\r\n \r\n ConcatObservable.prototype.subscribeCore = function(o) {\r\n var sink = new ConcatSink(this.sources, o);\r\n return sink.run();\r\n };\r\n \r\n function ConcatSink(sources, o) {\r\n this.sources = sources;\r\n this.o = o;\r\n }\r\n ConcatSink.prototype.run = function () {\r\n var isDisposed, subscription = new SerialDisposable(), sources = this.sources, length = sources.length, o = this.o;\r\n var cancelable = immediateScheduler.scheduleRecursiveWithState(0, function (i, self) {\r\n if (isDisposed) { return; }\r\n if (i === length) {\r\n return o.onCompleted();\r\n }\r\n \r\n // Check if promise\r\n var currentValue = sources[i];\r\n isPromise(currentValue) && (currentValue = observableFromPromise(currentValue));\r\n\r\n var d = new SingleAssignmentDisposable();\r\n subscription.setDisposable(d);\r\n d.setDisposable(currentValue.subscribe(\r\n function (x) { o.onNext(x); },\r\n function (e) { o.onError(e); },\r\n function () { self(i + 1); }\r\n ));\r\n });\r\n\r\n return new CompositeDisposable(subscription, cancelable, disposableCreate(function () {\r\n isDisposed = true;\r\n }));\r\n };\r\n \r\n \r\n return ConcatObservable;\r\n }(ObservableBase));\r\n \r\n /**\r\n * Concatenates all the observable sequences.\r\n * @param {Array | Arguments} args Arguments or an array to concat to the observable sequence.\r\n * @returns {Observable} An observable sequence that contains the elements of each given sequence, in sequential order.\r\n */\r\n var observableConcat = Observable.concat = function () {\r\n var args;\r\n if (Array.isArray(arguments[0])) {\r\n args = arguments[0];\r\n } else {\r\n args = new Array(arguments.length);\r\n for(var i = 0, len = arguments.length; i < len; i++) { args[i] = arguments[i]; }\r\n }\r\n return new ConcatObservable(args);\r\n };\r\n\r\n /**\n * Concatenates an observable sequence of observable sequences.\n * @returns {Observable} An observable sequence that contains the elements of each observed inner sequence, in sequential order.\n */\n observableProto.concatAll = observableProto.concatObservable = function () {\n return this.merge(1);\n };\n\r\n var MergeObservable = (function (__super__) {\n inherits(MergeObservable, __super__);\n\n function MergeObservable(source, maxConcurrent) {\n this.source = source;\n this.maxConcurrent = maxConcurrent;\n __super__.call(this);\n }\n\n MergeObservable.prototype.subscribeCore = function(observer) {\n var g = new CompositeDisposable();\n g.add(this.source.subscribe(new MergeObserver(observer, this.maxConcurrent, g)));\n return g;\n };\n\n return MergeObservable;\n\n }(ObservableBase));\n\n var MergeObserver = (function () {\n function MergeObserver(o, max, g) {\n this.o = o;\n this.max = max;\n this.g = g;\n this.done = false;\n this.q = [];\n this.activeCount = 0;\n this.isStopped = false;\n }\n MergeObserver.prototype.handleSubscribe = function (xs) {\n var sad = new SingleAssignmentDisposable();\n this.g.add(sad);\n isPromise(xs) && (xs = observableFromPromise(xs));\n sad.setDisposable(xs.subscribe(new InnerObserver(this, sad)));\n };\n MergeObserver.prototype.onNext = function (innerSource) {\n if (this.isStopped) { return; }\n if(this.activeCount < this.max) {\n this.activeCount++;\n this.handleSubscribe(innerSource);\n } else {\n this.q.push(innerSource);\n }\n };\n MergeObserver.prototype.onError = function (e) {\n if (!this.isStopped) {\n this.isStopped = true;\n this.o.onError(e);\n }\n };\n MergeObserver.prototype.onCompleted = function () {\n if (!this.isStopped) {\n this.isStopped = true;\n this.done = true;\n this.activeCount === 0 && this.o.onCompleted();\n }\n };\n MergeObserver.prototype.dispose = function() { this.isStopped = true; };\n MergeObserver.prototype.fail = function (e) {\n if (!this.isStopped) {\n this.isStopped = true;\n this.o.onError(e);\n return true;\n }\n\n return false;\n };\n\n function InnerObserver(parent, sad) {\n this.parent = parent;\n this.sad = sad;\n this.isStopped = false;\n }\n InnerObserver.prototype.onNext = function (x) { if(!this.isStopped) { this.parent.o.onNext(x); } };\n InnerObserver.prototype.onError = function (e) {\n if (!this.isStopped) {\n this.isStopped = true;\n this.parent.o.onError(e);\n }\n };\n InnerObserver.prototype.onCompleted = function () {\n if(!this.isStopped) {\n this.isStopped = true;\n var parent = this.parent;\n parent.g.remove(this.sad);\n if (parent.q.length > 0) {\n parent.handleSubscribe(parent.q.shift());\n } else {\n parent.activeCount--;\n parent.done && parent.activeCount === 0 && parent.o.onCompleted();\n }\n }\n };\n InnerObserver.prototype.dispose = function() { this.isStopped = true; };\n InnerObserver.prototype.fail = function (e) {\n if (!this.isStopped) {\n this.isStopped = true;\n this.parent.o.onError(e);\n return true;\n }\n\n return false;\n };\n\n return MergeObserver;\n }());\n\n\n\n\n\n /**\n * Merges an observable sequence of observable sequences into an observable sequence, limiting the number of concurrent subscriptions to inner sequences.\n * Or merges two observable sequences into a single observable sequence.\n *\n * @example\n * 1 - merged = sources.merge(1);\n * 2 - merged = source.merge(otherSource);\n * @param {Mixed} [maxConcurrentOrOther] Maximum number of inner observable sequences being subscribed to concurrently or the second observable sequence.\n * @returns {Observable} The observable sequence that merges the elements of the inner sequences.\n */\n observableProto.merge = function (maxConcurrentOrOther) {\n return typeof maxConcurrentOrOther !== 'number' ?\n observableMerge(this, maxConcurrentOrOther) :\n new MergeObservable(this, maxConcurrentOrOther);\n };\n\r\n /**\n * Merges all the observable sequences into a single observable sequence.\n * The scheduler is optional and if not specified, the immediate scheduler is used.\n * @returns {Observable} The observable sequence that merges the elements of the observable sequences.\n */\n var observableMerge = Observable.merge = function () {\n var scheduler, sources = [], i, len = arguments.length;\n if (!arguments[0]) {\n scheduler = immediateScheduler;\n for(i = 1; i < len; i++) { sources.push(arguments[i]); }\n } else if (isScheduler(arguments[0])) {\n scheduler = arguments[0];\n for(i = 1; i < len; i++) { sources.push(arguments[i]); }\n } else {\n scheduler = immediateScheduler;\n for(i = 0; i < len; i++) { sources.push(arguments[i]); }\n }\n if (Array.isArray(sources[0])) {\n sources = sources[0];\n }\n return observableOf(scheduler, sources).mergeAll();\n };\n\r\n var MergeAllObservable = (function (__super__) {\n inherits(MergeAllObservable, __super__);\n\n function MergeAllObservable(source) {\n this.source = source;\n __super__.call(this);\n }\n\n MergeAllObservable.prototype.subscribeCore = function (observer) {\n var g = new CompositeDisposable(), m = new SingleAssignmentDisposable();\n g.add(m);\n m.setDisposable(this.source.subscribe(new MergeAllObserver(observer, g)));\n return g;\n };\n \n function MergeAllObserver(o, g) {\n this.o = o;\n this.g = g;\n this.isStopped = false;\n this.done = false;\n }\n MergeAllObserver.prototype.onNext = function(innerSource) {\n if(this.isStopped) { return; }\n var sad = new SingleAssignmentDisposable();\n this.g.add(sad);\n\n isPromise(innerSource) && (innerSource = observableFromPromise(innerSource));\n\n sad.setDisposable(innerSource.subscribe(new InnerObserver(this, this.g, sad)));\n };\n MergeAllObserver.prototype.onError = function (e) {\n if(!this.isStopped) {\n this.isStopped = true;\n this.o.onError(e);\n }\n };\n MergeAllObserver.prototype.onCompleted = function () {\n if(!this.isStopped) {\n this.isStopped = true;\n this.done = true;\n this.g.length === 1 && this.o.onCompleted();\n }\n };\n MergeAllObserver.prototype.dispose = function() { this.isStopped = true; };\n MergeAllObserver.prototype.fail = function (e) {\n if (!this.isStopped) {\n this.isStopped = true;\n this.o.onError(e);\n return true;\n }\n\n return false;\n };\n\n function InnerObserver(parent, g, sad) {\n this.parent = parent;\n this.g = g;\n this.sad = sad;\n this.isStopped = false;\n }\n InnerObserver.prototype.onNext = function (x) { if (!this.isStopped) { this.parent.o.onNext(x); } };\n InnerObserver.prototype.onError = function (e) {\n if(!this.isStopped) {\n this.isStopped = true;\n this.parent.o.onError(e);\n }\n };\n InnerObserver.prototype.onCompleted = function () {\n if(!this.isStopped) {\n var parent = this.parent;\n this.isStopped = true;\n parent.g.remove(this.sad);\n parent.done && parent.g.length === 1 && parent.o.onCompleted();\n }\n };\n InnerObserver.prototype.dispose = function() { this.isStopped = true; };\n InnerObserver.prototype.fail = function (e) {\n if (!this.isStopped) {\n this.isStopped = true;\n this.parent.o.onError(e);\n return true;\n }\n\n return false;\n };\n\n return MergeAllObservable;\n }(ObservableBase));\n\n /**\n * Merges an observable sequence of observable sequences into an observable sequence.\n * @returns {Observable} The observable sequence that merges the elements of the inner sequences.\n */\n observableProto.mergeAll = observableProto.mergeObservable = function () {\n return new MergeAllObservable(this);\n };\n\r\n var CompositeError = Rx.CompositeError = function(errors) {\n this.name = \"NotImplementedError\";\n this.innerErrors = errors;\n this.message = 'This contains multiple errors. Check the innerErrors';\n Error.call(this);\n }\n CompositeError.prototype = Error.prototype;\n\n /**\n * Flattens an Observable that emits Observables into one Observable, in a way that allows an Observer to\n * receive all successfully emitted items from all of the source Observables without being interrupted by\n * an error notification from one of them.\n *\n * This behaves like Observable.prototype.mergeAll except that if any of the merged Observables notify of an\n * error via the Observer's onError, mergeDelayError will refrain from propagating that\n * error notification until all of the merged Observables have finished emitting items.\n * @param {Array | Arguments} args Arguments or an array to merge.\n * @returns {Observable} an Observable that emits all of the items emitted by the Observables emitted by the Observable\n */\n Observable.mergeDelayError = function() {\n var args;\n if (Array.isArray(arguments[0])) {\n args = arguments[0];\n } else {\n var len = arguments.length;\n args = new Array(len);\n for(var i = 0; i < len; i++) { args[i] = arguments[i]; }\n }\n var source = observableOf(null, args);\n\n return new AnonymousObservable(function (o) {\n var group = new CompositeDisposable(),\n m = new SingleAssignmentDisposable(),\n isStopped = false,\n errors = [];\n\n function setCompletion() {\n if (errors.length === 0) {\n o.onCompleted();\n } else if (errors.length === 1) {\n o.onError(errors[0]);\n } else {\n o.onError(new CompositeError(errors));\n }\n }\n\n group.add(m);\n\n m.setDisposable(source.subscribe(\n function (innerSource) {\n var innerSubscription = new SingleAssignmentDisposable();\n group.add(innerSubscription);\n\n // Check for promises support\n isPromise(innerSource) && (innerSource = observableFromPromise(innerSource));\n\n innerSubscription.setDisposable(innerSource.subscribe(\n function (x) { o.onNext(x); },\n function (e) {\n errors.push(e);\n group.remove(innerSubscription);\n isStopped && group.length === 1 && setCompletion();\n },\n function () {\n group.remove(innerSubscription);\n isStopped && group.length === 1 && setCompletion();\n }));\n },\n function (e) {\n errors.push(e);\n isStopped = true;\n group.length === 1 && setCompletion();\n },\n function () {\n isStopped = true;\n group.length === 1 && setCompletion();\n }));\n return group;\n });\n };\n\r\n /**\n * Continues an observable sequence that is terminated normally or by an exception with the next observable sequence.\n * @param {Observable} second Second observable sequence used to produce results after the first sequence terminates.\n * @returns {Observable} An observable sequence that concatenates the first and second sequence, even if the first sequence terminates exceptionally.\n */\n observableProto.onErrorResumeNext = function (second) {\n if (!second) { throw new Error('Second observable is required'); }\n return onErrorResumeNext([this, second]);\n };\n\r\n /**\n * Continues an observable sequence that is terminated normally or by an exception with the next observable sequence.\n *\n * @example\n * 1 - res = Rx.Observable.onErrorResumeNext(xs, ys, zs);\n * 1 - res = Rx.Observable.onErrorResumeNext([xs, ys, zs]);\n * @returns {Observable} An observable sequence that concatenates the source sequences, even if a sequence terminates exceptionally.\n */\n var onErrorResumeNext = Observable.onErrorResumeNext = function () {\n var sources = [];\n if (Array.isArray(arguments[0])) {\n sources = arguments[0];\n } else {\n for(var i = 0, len = arguments.length; i < len; i++) { sources.push(arguments[i]); }\n }\n return new AnonymousObservable(function (observer) {\n var pos = 0, subscription = new SerialDisposable(),\n cancelable = immediateScheduler.scheduleRecursive(function (self) {\n var current, d;\n if (pos < sources.length) {\n current = sources[pos++];\n isPromise(current) && (current = observableFromPromise(current));\n d = new SingleAssignmentDisposable();\n subscription.setDisposable(d);\n d.setDisposable(current.subscribe(observer.onNext.bind(observer), self, self));\n } else {\n observer.onCompleted();\n }\n });\n return new CompositeDisposable(subscription, cancelable);\n });\n };\n\r\n /**\n * Returns the values from the source observable sequence only after the other observable sequence produces a value.\n * @param {Observable | Promise} other The observable sequence or Promise that triggers propagation of elements of the source sequence.\n * @returns {Observable} An observable sequence containing the elements of the source sequence starting from the point the other sequence triggered propagation.\n */\n observableProto.skipUntil = function (other) {\n var source = this;\n return new AnonymousObservable(function (o) {\n var isOpen = false;\n var disposables = new CompositeDisposable(source.subscribe(function (left) {\n isOpen && o.onNext(left);\n }, function (e) { o.onError(e); }, function () {\n isOpen && o.onCompleted();\n }));\n\n isPromise(other) && (other = observableFromPromise(other));\n\n var rightSubscription = new SingleAssignmentDisposable();\n disposables.add(rightSubscription);\n rightSubscription.setDisposable(other.subscribe(function () {\n isOpen = true;\n rightSubscription.dispose();\n }, function (e) { o.onError(e); }, function () {\n rightSubscription.dispose();\n }));\n\n return disposables;\n }, source);\n };\n\r\n var SwitchObservable = (function(__super__) {\n inherits(SwitchObservable, __super__);\n function SwitchObservable(source) {\n this.source = source;\n __super__.call(this);\n }\n\n SwitchObservable.prototype.subscribeCore = function (o) {\n var inner = new SerialDisposable(), s = this.source.subscribe(new SwitchObserver(o, inner));\n return new CompositeDisposable(s, inner);\n };\n\n function SwitchObserver(o, inner) {\n this.o = o;\n this.inner = inner;\n this.stopped = false;\n this.latest = 0;\n this.hasLatest = false;\n this.isStopped = false;\n }\n SwitchObserver.prototype.onNext = function (innerSource) {\n if (this.isStopped) { return; }\n var d = new SingleAssignmentDisposable(), id = ++this.latest;\n this.hasLatest = true;\n this.inner.setDisposable(d);\n isPromise(innerSource) && (innerSource = observableFromPromise(innerSource));\n d.setDisposable(innerSource.subscribe(new InnerObserver(this, id)));\n };\n SwitchObserver.prototype.onError = function (e) {\n if (!this.isStopped) {\n this.isStopped = true;\n this.o.onError(e);\n }\n };\n SwitchObserver.prototype.onCompleted = function () {\n if (!this.isStopped) {\n this.isStopped = true;\n this.stopped = true;\n !this.hasLatest && this.o.onCompleted();\n }\n };\n SwitchObserver.prototype.dispose = function () { this.isStopped = true; };\n SwitchObserver.prototype.fail = function (e) {\n if(!this.isStopped) {\n this.isStopped = true;\n this.o.onError(e);\n return true;\n }\n return false;\n };\n\n function InnerObserver(parent, id) {\n this.parent = parent;\n this.id = id;\n this.isStopped = false;\n }\n InnerObserver.prototype.onNext = function (x) {\n if (this.isStopped) { return; }\n this.parent.latest === this.id && this.parent.o.onNext(x);\n };\n InnerObserver.prototype.onError = function (e) {\n if (!this.isStopped) {\n this.isStopped = true;\n this.parent.latest === this.id && this.parent.o.onError(e);\n }\n };\n InnerObserver.prototype.onCompleted = function () {\n if (!this.isStopped) {\n this.isStopped = true;\n if (this.parent.latest === this.id) {\n this.parent.hasLatest = false;\n this.parent.isStopped && this.parent.o.onCompleted();\n }\n }\n };\n InnerObserver.prototype.dispose = function () { this.isStopped = true; }\n InnerObserver.prototype.fail = function (e) {\n if(!this.isStopped) {\n this.isStopped = true;\n this.parent.o.onError(e);\n return true;\n }\n return false;\n };\n\n return SwitchObservable;\n }(ObservableBase));\n\n /**\n * Transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence.\n * @returns {Observable} The observable sequence that at any point in time produces the elements of the most recent inner observable sequence that has been received.\n */\n observableProto['switch'] = observableProto.switchLatest = function () {\n return new SwitchObservable(this);\n };\n\r\n var TakeUntilObservable = (function(__super__) {\n inherits(TakeUntilObservable, __super__);\n\n function TakeUntilObservable(source, other) {\n this.source = source;\n this.other = isPromise(other) ? observableFromPromise(other) : other;\n __super__.call(this);\n }\n\n TakeUntilObservable.prototype.subscribeCore = function(o) {\n return new CompositeDisposable(\n this.source.subscribe(o),\n this.other.subscribe(new InnerObserver(o))\n );\n };\n\n function InnerObserver(o) {\n this.o = o;\n this.isStopped = false;\n }\n InnerObserver.prototype.onNext = function (x) {\n if (this.isStopped) { return; }\n this.o.onCompleted();\n };\n InnerObserver.prototype.onError = function (err) {\n if (!this.isStopped) {\n this.isStopped = true;\n this.o.onError(err);\n }\n };\n InnerObserver.prototype.onCompleted = function () {\n !this.isStopped && (this.isStopped = true);\n };\n InnerObserver.prototype.dispose = function() { this.isStopped = true; };\n InnerObserver.prototype.fail = function (e) {\n if (!this.isStopped) {\n this.isStopped = true;\n this.o.onError(e);\n return true;\n }\n return false;\n };\n\n return TakeUntilObservable;\n }(ObservableBase));\n\n /**\n * Returns the values from the source observable sequence until the other observable sequence produces a value.\n * @param {Observable | Promise} other Observable sequence or Promise that terminates propagation of elements of the source sequence.\n * @returns {Observable} An observable sequence containing the elements of the source sequence up to the point the other sequence interrupted further propagation.\n */\n observableProto.takeUntil = function (other) {\n return new TakeUntilObservable(this, other);\n };\n\r\n function falseFactory() { return false; }\n\n /**\n * Merges the specified observable sequences into one observable sequence by using the selector function only when the (first) source observable sequence produces an element.\n * @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function.\n */\n observableProto.withLatestFrom = function () {\n var len = arguments.length, args = new Array(len)\n for(var i = 0; i < len; i++) { args[i] = arguments[i]; }\n var resultSelector = args.pop(), source = this;\n Array.isArray(args[0]) && (args = args[0]);\n\n return new AnonymousObservable(function (observer) {\n var n = args.length,\n hasValue = arrayInitialize(n, falseFactory),\n hasValueAll = false,\n values = new Array(n);\n\n var subscriptions = new Array(n + 1);\n for (var idx = 0; idx < n; idx++) {\n (function (i) {\n var other = args[i], sad = new SingleAssignmentDisposable();\n isPromise(other) && (other = observableFromPromise(other));\n sad.setDisposable(other.subscribe(function (x) {\n values[i] = x;\n hasValue[i] = true;\n hasValueAll = hasValue.every(identity);\n }, function (e) { observer.onError(e); }, noop));\n subscriptions[i] = sad;\n }(idx));\n }\n\n var sad = new SingleAssignmentDisposable();\n sad.setDisposable(source.subscribe(function (x) {\n var allValues = [x].concat(values);\n if (!hasValueAll) { return; }\n var res = tryCatch(resultSelector).apply(null, allValues);\n if (res === errorObj) { return observer.onError(res.e); }\n observer.onNext(res);\n }, function (e) { observer.onError(e); }, function () {\n observer.onCompleted();\n }));\n subscriptions[n] = sad;\n\n return new CompositeDisposable(subscriptions);\n }, this);\n };\n\r\n function zipArray(second, resultSelector) {\n var first = this;\n return new AnonymousObservable(function (o) {\n var index = 0, len = second.length;\n return first.subscribe(function (left) {\n if (index < len) {\n var right = second[index++], res = tryCatch(resultSelector)(left, right);\n if (res === errorObj) { return o.onError(res.e); }\n o.onNext(res);\n } else {\n o.onCompleted();\n }\n }, function (e) { o.onError(e); }, function () { o.onCompleted(); });\n }, first);\n }\n\n function falseFactory() { return false; }\n function emptyArrayFactory() { return []; }\n\n /**\n * Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences or an array have produced an element at a corresponding index.\n * The last element in the arguments must be a function to invoke for each series of elements at corresponding indexes in the args.\n * @returns {Observable} An observable sequence containing the result of combining elements of the args using the specified result selector function.\n */\n observableProto.zip = function () {\n if (Array.isArray(arguments[0])) { return zipArray.apply(this, arguments); }\n var len = arguments.length, args = new Array(len);\n for(var i = 0; i < len; i++) { args[i] = arguments[i]; }\n\n var parent = this, resultSelector = args.pop();\n args.unshift(parent);\n return new AnonymousObservable(function (o) {\n var n = args.length,\n queues = arrayInitialize(n, emptyArrayFactory),\n isDone = arrayInitialize(n, falseFactory);\n\n var subscriptions = new Array(n);\n for (var idx = 0; idx < n; idx++) {\n (function (i) {\n var source = args[i], sad = new SingleAssignmentDisposable();\n isPromise(source) && (source = observableFromPromise(source));\n sad.setDisposable(source.subscribe(function (x) {\n queues[i].push(x);\n if (queues.every(function (x) { return x.length > 0; })) {\n var queuedValues = queues.map(function (x) { return x.shift(); }),\n res = tryCatch(resultSelector).apply(parent, queuedValues);\n if (res === errorObj) { return o.onError(res.e); }\n o.onNext(res);\n } else if (isDone.filter(function (x, j) { return j !== i; }).every(identity)) {\n o.onCompleted();\n }\n }, function (e) { o.onError(e); }, function () {\n isDone[i] = true;\n isDone.every(identity) && o.onCompleted();\n }));\n subscriptions[i] = sad;\n })(idx);\n }\n\n return new CompositeDisposable(subscriptions);\n }, parent);\n };\n\r\n /**\n * Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index.\n * @param arguments Observable sources.\n * @param {Function} resultSelector Function to invoke for each series of elements at corresponding indexes in the sources.\n * @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function.\n */\n Observable.zip = function () {\n var len = arguments.length, args = new Array(len);\n for(var i = 0; i < len; i++) { args[i] = arguments[i]; }\n var first = args.shift();\n return first.zip.apply(first, args);\n };\n\r\n function falseFactory() { return false; }\n function arrayFactory() { return []; }\n\n /**\n * Merges the specified observable sequences into one observable sequence by emitting a list with the elements of the observable sequences at corresponding indexes.\n * @param arguments Observable sources.\n * @returns {Observable} An observable sequence containing lists of elements at corresponding indexes.\n */\n Observable.zipArray = function () {\n var sources;\n if (Array.isArray(arguments[0])) {\n sources = arguments[0];\n } else {\n var len = arguments.length;\n sources = new Array(len);\n for(var i = 0; i < len; i++) { sources[i] = arguments[i]; }\n }\n return new AnonymousObservable(function (o) {\n var n = sources.length,\n queues = arrayInitialize(n, arrayFactory),\n isDone = arrayInitialize(n, falseFactory);\n\n var subscriptions = new Array(n);\n for (var idx = 0; idx < n; idx++) {\n (function (i) {\n subscriptions[i] = new SingleAssignmentDisposable();\n subscriptions[i].setDisposable(sources[i].subscribe(function (x) {\n queues[i].push(x);\n if (queues.every(function (x) { return x.length > 0; })) {\n var res = queues.map(function (x) { return x.shift(); });\n o.onNext(res);\n } else if (isDone.filter(function (x, j) { return j !== i; }).every(identity)) {\n return o.onCompleted();\n }\n }, function (e) { o.onError(e); }, function () {\n isDone[i] = true;\n isDone.every(identity) && o.onCompleted();\n }));\n })(idx);\n }\n\n return new CompositeDisposable(subscriptions);\n });\n };\n\r\n /**\n * Hides the identity of an observable sequence.\n * @returns {Observable} An observable sequence that hides the identity of the source sequence.\n */\n observableProto.asObservable = function () {\n var source = this;\n return new AnonymousObservable(function (o) { return source.subscribe(o); }, source);\n };\n\r\n /**\n * Projects each element of an observable sequence into zero or more buffers which are produced based on element count information.\n *\n * @example\n * var res = xs.bufferWithCount(10);\n * var res = xs.bufferWithCount(10, 1);\n * @param {Number} count Length of each buffer.\n * @param {Number} [skip] Number of elements to skip between creation of consecutive buffers. If not provided, defaults to the count.\n * @returns {Observable} An observable sequence of buffers.\n */\n observableProto.bufferWithCount = function (count, skip) {\n if (typeof skip !== 'number') {\n skip = count;\n }\n return this.windowWithCount(count, skip).selectMany(function (x) {\n return x.toArray();\n }).where(function (x) {\n return x.length > 0;\n });\n };\n\r\n /**\n * Dematerializes the explicit notification values of an observable sequence as implicit notifications.\n * @returns {Observable} An observable sequence exhibiting the behavior corresponding to the source sequence's notification values.\n */\n observableProto.dematerialize = function () {\n var source = this;\n return new AnonymousObservable(function (o) {\n return source.subscribe(function (x) { return x.accept(o); }, function(e) { o.onError(e); }, function () { o.onCompleted(); });\n }, this);\n };\n\r\n /**\n * Returns an observable sequence that contains only distinct contiguous elements according to the keySelector and the comparer.\n *\n * var obs = observable.distinctUntilChanged();\n * var obs = observable.distinctUntilChanged(function (x) { return x.id; });\n * var obs = observable.distinctUntilChanged(function (x) { return x.id; }, function (x, y) { return x === y; });\n *\n * @param {Function} [keySelector] A function to compute the comparison key for each element. If not provided, it projects the value.\n * @param {Function} [comparer] Equality comparer for computed key values. If not provided, defaults to an equality comparer function.\n * @returns {Observable} An observable sequence only containing the distinct contiguous elements, based on a computed key value, from the source sequence.\n */\n observableProto.distinctUntilChanged = function (keySelector, comparer) {\n var source = this;\n comparer || (comparer = defaultComparer);\n return new AnonymousObservable(function (o) {\n var hasCurrentKey = false, currentKey;\n return source.subscribe(function (value) {\n var key = value;\n if (keySelector) {\n key = tryCatch(keySelector)(value);\n if (key === errorObj) { return o.onError(key.e); }\n }\n if (hasCurrentKey) {\n var comparerEquals = tryCatch(comparer)(currentKey, key);\n if (comparerEquals === errorObj) { return o.onError(comparerEquals.e); }\n }\n if (!hasCurrentKey || !comparerEquals) {\n hasCurrentKey = true;\n currentKey = key;\n o.onNext(value);\n }\n }, function (e) { o.onError(e); }, function () { o.onCompleted(); });\n }, this);\n };\n\r\n var TapObservable = (function(__super__) {\n inherits(TapObservable,__super__);\n function TapObservable(source, observerOrOnNext, onError, onCompleted) {\n this.source = source;\n this.t = !observerOrOnNext || isFunction(observerOrOnNext) ?\n observerCreate(observerOrOnNext || noop, onError || noop, onCompleted || noop) :\n observerOrOnNext;\n __super__.call(this);\n }\n\n TapObservable.prototype.subscribeCore = function(o) {\n return this.source.subscribe(new InnerObserver(o, this.t));\n };\n\n function InnerObserver(o, t) {\n this.o = o;\n this.t = t;\n this.isStopped = false;\n }\n InnerObserver.prototype.onNext = function(x) {\n if (this.isStopped) { return; }\n var res = tryCatch(this.t.onNext).call(this.t, x);\n if (res === errorObj) { this.o.onError(res.e); }\n this.o.onNext(x);\n };\n InnerObserver.prototype.onError = function(err) {\n if (!this.isStopped) {\n this.isStopped = true;\n var res = tryCatch(this.t.onError).call(this.t, err);\n if (res === errorObj) { return this.o.onError(res.e); }\n this.o.onError(err);\n }\n };\n InnerObserver.prototype.onCompleted = function() {\n if (!this.isStopped) {\n this.isStopped = true;\n var res = tryCatch(this.t.onCompleted).call(this.t);\n if (res === errorObj) { return this.o.onError(res.e); }\n this.o.onCompleted();\n }\n };\n InnerObserver.prototype.dispose = function() { this.isStopped = true; };\n InnerObserver.prototype.fail = function (e) {\n if (!this.isStopped) {\n this.isStopped = true;\n this.o.onError(e);\n return true;\n }\n return false;\n };\n\n return TapObservable;\n }(ObservableBase));\n\n /**\n * Invokes an action for each element in the observable sequence and invokes an action upon graceful or exceptional termination of the observable sequence.\n * This method can be used for debugging, logging, etc. of query behavior by intercepting the message stream to run arbitrary actions for messages on the pipeline.\n * @param {Function | Observer} observerOrOnNext Action to invoke for each element in the observable sequence or an o.\n * @param {Function} [onError] Action to invoke upon exceptional termination of the observable sequence. Used if only the observerOrOnNext parameter is also a function.\n * @param {Function} [onCompleted] Action to invoke upon graceful termination of the observable sequence. Used if only the observerOrOnNext parameter is also a function.\n * @returns {Observable} The source sequence with the side-effecting behavior applied.\n */\n observableProto['do'] = observableProto.tap = observableProto.doAction = function (observerOrOnNext, onError, onCompleted) {\n return new TapObservable(this, observerOrOnNext, onError, onCompleted);\n };\n\n /**\n * Invokes an action for each element in the observable sequence.\n * This method can be used for debugging, logging, etc. of query behavior by intercepting the message stream to run arbitrary actions for messages on the pipeline.\n * @param {Function} onNext Action to invoke for each element in the observable sequence.\n * @param {Any} [thisArg] Object to use as this when executing callback.\n * @returns {Observable} The source sequence with the side-effecting behavior applied.\n */\n observableProto.doOnNext = observableProto.tapOnNext = function (onNext, thisArg) {\n return this.tap(typeof thisArg !== 'undefined' ? function (x) { onNext.call(thisArg, x); } : onNext);\n };\n\n /**\n * Invokes an action upon exceptional termination of the observable sequence.\n * This method can be used for debugging, logging, etc. of query behavior by intercepting the message stream to run arbitrary actions for messages on the pipeline.\n * @param {Function} onError Action to invoke upon exceptional termination of the observable sequence.\n * @param {Any} [thisArg] Object to use as this when executing callback.\n * @returns {Observable} The source sequence with the side-effecting behavior applied.\n */\n observableProto.doOnError = observableProto.tapOnError = function (onError, thisArg) {\n return this.tap(noop, typeof thisArg !== 'undefined' ? function (e) { onError.call(thisArg, e); } : onError);\n };\n\n /**\n * Invokes an action upon graceful termination of the observable sequence.\n * This method can be used for debugging, logging, etc. of query behavior by intercepting the message stream to run arbitrary actions for messages on the pipeline.\n * @param {Function} onCompleted Action to invoke upon graceful termination of the observable sequence.\n * @param {Any} [thisArg] Object to use as this when executing callback.\n * @returns {Observable} The source sequence with the side-effecting behavior applied.\n */\n observableProto.doOnCompleted = observableProto.tapOnCompleted = function (onCompleted, thisArg) {\n return this.tap(noop, null, typeof thisArg !== 'undefined' ? function () { onCompleted.call(thisArg); } : onCompleted);\n };\n\r\n /**\n * Invokes a specified action after the source observable sequence terminates gracefully or exceptionally.\n * @param {Function} finallyAction Action to invoke after the source observable sequence terminates.\n * @returns {Observable} Source sequence with the action-invoking termination behavior applied.\n */\n observableProto['finally'] = observableProto.ensure = function (action) {\n var source = this;\n return new AnonymousObservable(function (observer) {\n var subscription;\n try {\n subscription = source.subscribe(observer);\n } catch (e) {\n action();\n throw e;\n }\n return disposableCreate(function () {\n try {\n subscription.dispose();\n } catch (e) {\n throw e;\n } finally {\n action();\n }\n });\n }, this);\n };\n\n /**\n * @deprecated use #finally or #ensure instead.\n */\n observableProto.finallyAction = function (action) {\n //deprecate('finallyAction', 'finally or ensure');\n return this.ensure(action);\n };\n\r\n var IgnoreElementsObservable = (function(__super__) {\n inherits(IgnoreElementsObservable, __super__);\n\n function IgnoreElementsObservable(source) {\n this.source = source;\n __super__.call(this);\n }\n\n IgnoreElementsObservable.prototype.subscribeCore = function (o) {\n return this.source.subscribe(new InnerObserver(o));\n };\n\n function InnerObserver(o) {\n this.o = o;\n this.isStopped = false;\n }\n InnerObserver.prototype.onNext = noop;\n InnerObserver.prototype.onError = function (err) {\n if(!this.isStopped) {\n this.isStopped = true;\n this.o.onError(err);\n }\n };\n InnerObserver.prototype.onCompleted = function () {\n if(!this.isStopped) {\n this.isStopped = true;\n this.o.onCompleted();\n }\n };\n InnerObserver.prototype.dispose = function() { this.isStopped = true; };\n InnerObserver.prototype.fail = function (e) {\n if (!this.isStopped) {\n this.isStopped = true;\n this.observer.onError(e);\n return true;\n }\n\n return false;\n };\n\n return IgnoreElementsObservable;\n }(ObservableBase));\n\n /**\n * Ignores all elements in an observable sequence leaving only the termination messages.\n * @returns {Observable} An empty observable sequence that signals termination, successful or exceptional, of the source sequence.\n */\n observableProto.ignoreElements = function () {\n return new IgnoreElementsObservable(this);\n };\n\r\n /**\n * Materializes the implicit notifications of an observable sequence as explicit notification values.\n * @returns {Observable} An observable sequence containing the materialized notification values from the source sequence.\n */\n observableProto.materialize = function () {\n var source = this;\n return new AnonymousObservable(function (observer) {\n return source.subscribe(function (value) {\n observer.onNext(notificationCreateOnNext(value));\n }, function (e) {\n observer.onNext(notificationCreateOnError(e));\n observer.onCompleted();\n }, function () {\n observer.onNext(notificationCreateOnCompleted());\n observer.onCompleted();\n });\n }, source);\n };\n\r\n /**\n * Repeats the observable sequence a specified number of times. If the repeat count is not specified, the sequence repeats indefinitely.\n * @param {Number} [repeatCount] Number of times to repeat the sequence. If not provided, repeats the sequence indefinitely.\n * @returns {Observable} The observable sequence producing the elements of the given sequence repeatedly.\n */\n observableProto.repeat = function (repeatCount) {\n return enumerableRepeat(this, repeatCount).concat();\n };\n\r\n /**\n * Repeats the source observable sequence the specified number of times or until it successfully terminates. If the retry count is not specified, it retries indefinitely.\n * Note if you encounter an error and want it to retry once, then you must use .retry(2);\n *\n * @example\n * var res = retried = retry.repeat();\n * var res = retried = retry.repeat(2);\n * @param {Number} [retryCount] Number of times to retry the sequence. If not provided, retry the sequence indefinitely.\n * @returns {Observable} An observable sequence producing the elements of the given sequence repeatedly until it terminates successfully.\n */\n observableProto.retry = function (retryCount) {\n return enumerableRepeat(this, retryCount).catchError();\n };\n\r\n /**\n * Repeats the source observable sequence upon error each time the notifier emits or until it successfully terminates. \n * if the notifier completes, the observable sequence completes.\n *\n * @example\n * var timer = Observable.timer(500);\n * var source = observable.retryWhen(timer);\n * @param {Observable} [notifier] An observable that triggers the retries or completes the observable with onNext or onCompleted respectively.\n * @returns {Observable} An observable sequence producing the elements of the given sequence repeatedly until it terminates successfully.\n */\n observableProto.retryWhen = function (notifier) {\n return enumerableRepeat(this).catchErrorWhen(notifier);\n };\r\n var ScanObservable = (function(__super__) {\n inherits(ScanObservable, __super__);\n function ScanObservable(source, accumulator, hasSeed, seed) {\n this.source = source;\n this.accumulator = accumulator;\n this.hasSeed = hasSeed;\n this.seed = seed;\n __super__.call(this);\n }\n\n ScanObservable.prototype.subscribeCore = function(observer) {\n return this.source.subscribe(new ScanObserver(observer,this));\n };\n\n return ScanObservable;\n }(ObservableBase));\n\n function ScanObserver(observer, parent) {\n this.observer = observer;\n this.accumulator = parent.accumulator;\n this.hasSeed = parent.hasSeed;\n this.seed = parent.seed;\n this.hasAccumulation = false;\n this.accumulation = null;\n this.hasValue = false;\n this.isStopped = false;\n }\n ScanObserver.prototype.onNext = function (x) {\n if (this.isStopped) { return; }\n !this.hasValue && (this.hasValue = true);\n try {\n if (this.hasAccumulation) {\n this.accumulation = this.accumulator(this.accumulation, x);\n } else {\n this.accumulation = this.hasSeed ? this.accumulator(this.seed, x) : x;\n this.hasAccumulation = true;\n }\n } catch (e) {\n return this.observer.onError(e);\n }\n this.observer.onNext(this.accumulation);\n };\n ScanObserver.prototype.onError = function (e) { \n if (!this.isStopped) {\n this.isStopped = true;\n this.observer.onError(e);\n }\n };\n ScanObserver.prototype.onCompleted = function () {\n if (!this.isStopped) {\n this.isStopped = true;\n !this.hasValue && this.hasSeed && this.observer.onNext(this.seed);\n this.observer.onCompleted();\n }\n };\n ScanObserver.prototype.dispose = function() { this.isStopped = true; };\n ScanObserver.prototype.fail = function (e) {\n if (!this.isStopped) {\n this.isStopped = true;\n this.observer.onError(e);\n return true;\n }\n return false;\n };\n\n /**\n * Applies an accumulator function over an observable sequence and returns each intermediate result. The optional seed value is used as the initial accumulator value.\n * For aggregation behavior with no intermediate results, see Observable.aggregate.\n * @param {Mixed} [seed] The initial accumulator value.\n * @param {Function} accumulator An accumulator function to be invoked on each element.\n * @returns {Observable} An observable sequence containing the accumulated values.\n */\n observableProto.scan = function () {\n var hasSeed = false, seed, accumulator, source = this;\n if (arguments.length === 2) {\n hasSeed = true;\n seed = arguments[0];\n accumulator = arguments[1];\n } else {\n accumulator = arguments[0];\n }\n return new ScanObservable(this, accumulator, hasSeed, seed);\n };\n\r\n /**\n * Bypasses a specified number of elements at the end of an observable sequence.\n * @description\n * This operator accumulates a queue with a length enough to store the first `count` elements. As more elements are\n * received, elements are taken from the front of the queue and produced on the result sequence. This causes elements to be delayed.\n * @param count Number of elements to bypass at the end of the source sequence.\n * @returns {Observable} An observable sequence containing the source sequence elements except for the bypassed ones at the end.\n */\n observableProto.skipLast = function (count) {\n if (count < 0) { throw new ArgumentOutOfRangeError(); }\n var source = this;\n return new AnonymousObservable(function (o) {\n var q = [];\n return source.subscribe(function (x) {\n q.push(x);\n q.length > count && o.onNext(q.shift());\n }, function (e) { o.onError(e); }, function () { o.onCompleted(); });\n }, source);\n };\n\r\n /**\n * Prepends a sequence of values to an observable sequence with an optional scheduler and an argument list of values to prepend.\n * @example\n * var res = source.startWith(1, 2, 3);\n * var res = source.startWith(Rx.Scheduler.timeout, 1, 2, 3);\n * @param {Arguments} args The specified values to prepend to the observable sequence\n * @returns {Observable} The source sequence prepended with the specified values.\n */\n observableProto.startWith = function () {\n var values, scheduler, start = 0;\n if (!!arguments.length && isScheduler(arguments[0])) {\n scheduler = arguments[0];\n start = 1;\n } else {\n scheduler = immediateScheduler;\n }\n for(var args = [], i = start, len = arguments.length; i < len; i++) { args.push(arguments[i]); }\n return enumerableOf([observableFromArray(args, scheduler), this]).concat();\n };\n\r\n /**\n * Returns a specified number of contiguous elements from the end of an observable sequence.\n * @description\n * This operator accumulates a buffer with a length enough to store elements count elements. Upon completion of\n * the source sequence, this buffer is drained on the result sequence. This causes the elements to be delayed.\n * @param {Number} count Number of elements to take from the end of the source sequence.\n * @returns {Observable} An observable sequence containing the specified number of elements from the end of the source sequence.\n */\n observableProto.takeLast = function (count) {\n if (count < 0) { throw new ArgumentOutOfRangeError(); }\n var source = this;\n return new AnonymousObservable(function (o) {\n var q = [];\n return source.subscribe(function (x) {\n q.push(x);\n q.length > count && q.shift();\n }, function (e) { o.onError(e); }, function () {\n while (q.length > 0) { o.onNext(q.shift()); }\n o.onCompleted();\n });\n }, source);\n };\n\r\n /**\n * Returns an array with the specified number of contiguous elements from the end of an observable sequence.\n *\n * @description\n * This operator accumulates a buffer with a length enough to store count elements. Upon completion of the\n * source sequence, this buffer is produced on the result sequence.\n * @param {Number} count Number of elements to take from the end of the source sequence.\n * @returns {Observable} An observable sequence containing a single array with the specified number of elements from the end of the source sequence.\n */\n observableProto.takeLastBuffer = function (count) {\n var source = this;\n return new AnonymousObservable(function (o) {\n var q = [];\n return source.subscribe(function (x) {\n q.push(x);\n q.length > count && q.shift();\n }, function (e) { o.onError(e); }, function () {\n o.onNext(q);\n o.onCompleted();\n });\n }, source);\n };\n\r\n /**\n * Projects each element of an observable sequence into zero or more windows which are produced based on element count information.\n *\n * var res = xs.windowWithCount(10);\n * var res = xs.windowWithCount(10, 1);\n * @param {Number} count Length of each window.\n * @param {Number} [skip] Number of elements to skip between creation of consecutive windows. If not specified, defaults to the count.\n * @returns {Observable} An observable sequence of windows.\n */\n observableProto.windowWithCount = function (count, skip) {\n var source = this;\n +count || (count = 0);\n Math.abs(count) === Infinity && (count = 0);\n if (count <= 0) { throw new ArgumentOutOfRangeError(); }\n skip == null && (skip = count);\n +skip || (skip = 0);\n Math.abs(skip) === Infinity && (skip = 0);\n\n if (skip <= 0) { throw new ArgumentOutOfRangeError(); }\n return new AnonymousObservable(function (observer) {\n var m = new SingleAssignmentDisposable(),\n refCountDisposable = new RefCountDisposable(m),\n n = 0,\n q = [];\n\n function createWindow () {\n var s = new Subject();\n q.push(s);\n observer.onNext(addRef(s, refCountDisposable));\n }\n\n createWindow();\n\n m.setDisposable(source.subscribe(\n function (x) {\n for (var i = 0, len = q.length; i < len; i++) { q[i].onNext(x); }\n var c = n - count + 1;\n c >= 0 && c % skip === 0 && q.shift().onCompleted();\n ++n % skip === 0 && createWindow();\n },\n function (e) {\n while (q.length > 0) { q.shift().onError(e); }\n observer.onError(e);\n },\n function () {\n while (q.length > 0) { q.shift().onCompleted(); }\n observer.onCompleted();\n }\n ));\n return refCountDisposable;\n }, source);\n };\n\r\n function concatMap(source, selector, thisArg) {\n var selectorFunc = bindCallback(selector, thisArg, 3);\n return source.map(function (x, i) {\n var result = selectorFunc(x, i, source);\n isPromise(result) && (result = observableFromPromise(result));\n (isArrayLike(result) || isIterable(result)) && (result = observableFrom(result));\n return result;\n }).concatAll();\n }\n\n /**\n * One of the Following:\n * Projects each element of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence.\n *\n * @example\n * var res = source.concatMap(function (x) { return Rx.Observable.range(0, x); });\n * Or:\n * Projects each element of an observable sequence to an observable sequence, invokes the result selector for the source element and each of the corresponding inner sequence's elements, and merges the results into one observable sequence.\n *\n * var res = source.concatMap(function (x) { return Rx.Observable.range(0, x); }, function (x, y) { return x + y; });\n * Or:\n * Projects each element of the source observable sequence to the other observable sequence and merges the resulting observable sequences into one observable sequence.\n *\n * var res = source.concatMap(Rx.Observable.fromArray([1,2,3]));\n * @param {Function} selector A transform function to apply to each element or an observable sequence to project each element from the\n * source sequence onto which could be either an observable or Promise.\n * @param {Function} [resultSelector] A transform function to apply to each element of the intermediate sequence.\n * @returns {Observable} An observable sequence whose elements are the result of invoking the one-to-many transform function collectionSelector on each element of the input sequence and then mapping each of those sequence elements and their corresponding source element to a result element.\n */\n observableProto.selectConcat = observableProto.concatMap = function (selector, resultSelector, thisArg) {\n if (isFunction(selector) && isFunction(resultSelector)) {\n return this.concatMap(function (x, i) {\n var selectorResult = selector(x, i);\n isPromise(selectorResult) && (selectorResult = observableFromPromise(selectorResult));\n (isArrayLike(selectorResult) || isIterable(selectorResult)) && (selectorResult = observableFrom(selectorResult));\n\n return selectorResult.map(function (y, i2) {\n return resultSelector(x, y, i, i2);\n });\n });\n }\n return isFunction(selector) ?\n concatMap(this, selector, thisArg) :\n concatMap(this, function () { return selector; });\n };\n\r\n /**\n * Projects each notification of an observable sequence to an observable sequence and concats the resulting observable sequences into one observable sequence.\n * @param {Function} onNext A transform function to apply to each element; the second parameter of the function represents the index of the source element.\n * @param {Function} onError A transform function to apply when an error occurs in the source sequence.\n * @param {Function} onCompleted A transform function to apply when the end of the source sequence is reached.\n * @param {Any} [thisArg] An optional \"this\" to use to invoke each transform.\n * @returns {Observable} An observable sequence whose elements are the result of invoking the one-to-many transform function corresponding to each notification in the input sequence.\n */\n observableProto.concatMapObserver = observableProto.selectConcatObserver = function(onNext, onError, onCompleted, thisArg) {\n var source = this,\n onNextFunc = bindCallback(onNext, thisArg, 2),\n onErrorFunc = bindCallback(onError, thisArg, 1),\n onCompletedFunc = bindCallback(onCompleted, thisArg, 0);\n return new AnonymousObservable(function (observer) {\n var index = 0;\n return source.subscribe(\n function (x) {\n var result;\n try {\n result = onNextFunc(x, index++);\n } catch (e) {\n observer.onError(e);\n return;\n }\n isPromise(result) && (result = observableFromPromise(result));\n observer.onNext(result);\n },\n function (err) {\n var result;\n try {\n result = onErrorFunc(err);\n } catch (e) {\n observer.onError(e);\n return;\n }\n isPromise(result) && (result = observableFromPromise(result));\n observer.onNext(result);\n observer.onCompleted();\n },\n function () {\n var result;\n try {\n result = onCompletedFunc();\n } catch (e) {\n observer.onError(e);\n return;\n }\n isPromise(result) && (result = observableFromPromise(result));\n observer.onNext(result);\n observer.onCompleted();\n });\n }, this).concatAll();\n };\n\r\n /**\n * Returns the elements of the specified sequence or the specified value in a singleton sequence if the sequence is empty.\n *\n * var res = obs = xs.defaultIfEmpty();\n * 2 - obs = xs.defaultIfEmpty(false);\n *\n * @memberOf Observable#\n * @param defaultValue The value to return if the sequence is empty. If not provided, this defaults to null.\n * @returns {Observable} An observable sequence that contains the specified default value if the source is empty; otherwise, the elements of the source itself.\n */\n observableProto.defaultIfEmpty = function (defaultValue) {\n var source = this;\n defaultValue === undefined && (defaultValue = null);\n return new AnonymousObservable(function (observer) {\n var found = false;\n return source.subscribe(function (x) {\n found = true;\n observer.onNext(x);\n },\n function (e) { observer.onError(e); }, \n function () {\n !found && observer.onNext(defaultValue);\n observer.onCompleted();\n });\n }, source);\n };\n\r\n // Swap out for Array.findIndex\n function arrayIndexOfComparer(array, item, comparer) {\n for (var i = 0, len = array.length; i < len; i++) {\n if (comparer(array[i], item)) { return i; }\n }\n return -1;\n }\n\n function HashSet(comparer) {\n this.comparer = comparer;\n this.set = [];\n }\n HashSet.prototype.push = function(value) {\n var retValue = arrayIndexOfComparer(this.set, value, this.comparer) === -1;\n retValue && this.set.push(value);\n return retValue;\n };\n\n /**\n * Returns an observable sequence that contains only distinct elements according to the keySelector and the comparer.\n * Usage of this operator should be considered carefully due to the maintenance of an internal lookup structure which can grow large.\n *\n * @example\n * var res = obs = xs.distinct();\n * 2 - obs = xs.distinct(function (x) { return x.id; });\n * 2 - obs = xs.distinct(function (x) { return x.id; }, function (a,b) { return a === b; });\n * @param {Function} [keySelector] A function to compute the comparison key for each element.\n * @param {Function} [comparer] Used to compare items in the collection.\n * @returns {Observable} An observable sequence only containing the distinct elements, based on a computed key value, from the source sequence.\n */\n observableProto.distinct = function (keySelector, comparer) {\n var source = this;\n comparer || (comparer = defaultComparer);\n return new AnonymousObservable(function (o) {\n var hashSet = new HashSet(comparer);\n return source.subscribe(function (x) {\n var key = x;\n\n if (keySelector) {\n try {\n key = keySelector(x);\n } catch (e) {\n o.onError(e);\n return;\n }\n }\n hashSet.push(key) && o.onNext(x);\n },\n function (e) { o.onError(e); }, function () { o.onCompleted(); });\n }, this);\n };\n\r\n /**\n * Groups the elements of an observable sequence according to a specified key selector function and comparer and selects the resulting elements by using a specified function.\n *\n * @example\n * var res = observable.groupBy(function (x) { return x.id; });\n * 2 - observable.groupBy(function (x) { return x.id; }), function (x) { return x.name; });\n * 3 - observable.groupBy(function (x) { return x.id; }), function (x) { return x.name; }, function (x) { return x.toString(); });\n * @param {Function} keySelector A function to extract the key for each element.\n * @param {Function} [elementSelector] A function to map each source element to an element in an observable group.\n * @param {Function} [comparer] Used to determine whether the objects are equal.\n * @returns {Observable} A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.\n */\n observableProto.groupBy = function (keySelector, elementSelector, comparer) {\n return this.groupByUntil(keySelector, elementSelector, observableNever, comparer);\n };\n\r\n /**\n * Groups the elements of an observable sequence according to a specified key selector function.\n * A duration selector function is used to control the lifetime of groups. When a group expires, it receives an OnCompleted notification. When a new element with the same\n * key value as a reclaimed group occurs, the group will be reborn with a new lifetime request.\n *\n * @example\n * var res = observable.groupByUntil(function (x) { return x.id; }, null, function () { return Rx.Observable.never(); });\n * 2 - observable.groupBy(function (x) { return x.id; }), function (x) { return x.name; }, function () { return Rx.Observable.never(); });\n * 3 - observable.groupBy(function (x) { return x.id; }), function (x) { return x.name; }, function () { return Rx.Observable.never(); }, function (x) { return x.toString(); });\n * @param {Function} keySelector A function to extract the key for each element.\n * @param {Function} durationSelector A function to signal the expiration of a group.\n * @param {Function} [comparer] Used to compare objects. When not specified, the default comparer is used.\n * @returns {Observable}\n * A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.\n * If a group's lifetime expires, a new group with the same key value can be created once an element with such a key value is encoutered.\n *\n */\n observableProto.groupByUntil = function (keySelector, elementSelector, durationSelector, comparer) {\n var source = this;\n elementSelector || (elementSelector = identity);\n comparer || (comparer = defaultComparer);\n return new AnonymousObservable(function (observer) {\n function handleError(e) { return function (item) { item.onError(e); }; }\n var map = new Dictionary(0, comparer),\n groupDisposable = new CompositeDisposable(),\n refCountDisposable = new RefCountDisposable(groupDisposable);\n\n groupDisposable.add(source.subscribe(function (x) {\n var key;\n try {\n key = keySelector(x);\n } catch (e) {\n map.getValues().forEach(handleError(e));\n observer.onError(e);\n return;\n }\n\n var fireNewMapEntry = false,\n writer = map.tryGetValue(key);\n if (!writer) {\n writer = new Subject();\n map.set(key, writer);\n fireNewMapEntry = true;\n }\n\n if (fireNewMapEntry) {\n var group = new GroupedObservable(key, writer, refCountDisposable),\n durationGroup = new GroupedObservable(key, writer);\n try {\n duration = durationSelector(durationGroup);\n } catch (e) {\n map.getValues().forEach(handleError(e));\n observer.onError(e);\n return;\n }\n\n observer.onNext(group);\n\n var md = new SingleAssignmentDisposable();\n groupDisposable.add(md);\n\n var expire = function () {\n map.remove(key) && writer.onCompleted();\n groupDisposable.remove(md);\n };\n\n md.setDisposable(duration.take(1).subscribe(\n noop,\n function (exn) {\n map.getValues().forEach(handleError(exn));\n observer.onError(exn);\n },\n expire)\n );\n }\n\n var element;\n try {\n element = elementSelector(x);\n } catch (e) {\n map.getValues().forEach(handleError(e));\n observer.onError(e);\n return;\n }\n\n writer.onNext(element);\n }, function (ex) {\n map.getValues().forEach(handleError(ex));\n observer.onError(ex);\n }, function () {\n map.getValues().forEach(function (item) { item.onCompleted(); });\n observer.onCompleted();\n }));\n\n return refCountDisposable;\n }, source);\n };\n\r\n var MapObservable = (function (__super__) {\n inherits(MapObservable, __super__);\n\n function MapObservable(source, selector, thisArg) {\n this.source = source;\n this.selector = bindCallback(selector, thisArg, 3);\n __super__.call(this);\n }\n \n function innerMap(selector, self) {\n return function (x, i, o) { return selector.call(this, self.selector(x, i, o), i, o); }\n }\n\n MapObservable.prototype.internalMap = function (selector, thisArg) {\n return new MapObservable(this.source, innerMap(selector, this), thisArg);\n };\n\n MapObservable.prototype.subscribeCore = function (o) {\n return this.source.subscribe(new InnerObserver(o, this.selector, this));\n };\n \n function InnerObserver(o, selector, source) {\n this.o = o;\n this.selector = selector;\n this.source = source;\n this.i = 0;\n this.isStopped = false;\n }\n \n InnerObserver.prototype.onNext = function(x) {\n if (this.isStopped) { return; }\n var result = tryCatch(this.selector)(x, this.i++, this.source);\n if (result === errorObj) {\n return this.o.onError(result.e);\n }\n this.o.onNext(result);\n };\n InnerObserver.prototype.onError = function (e) {\n if(!this.isStopped) { this.isStopped = true; this.o.onError(e); }\n };\n InnerObserver.prototype.onCompleted = function () {\n if(!this.isStopped) { this.isStopped = true; this.o.onCompleted(); }\n };\n InnerObserver.prototype.dispose = function() { this.isStopped = true; };\n InnerObserver.prototype.fail = function (e) {\n if (!this.isStopped) {\n this.isStopped = true;\n this.o.onError(e);\n return true;\n }\n \n return false;\n };\n\n return MapObservable;\n\n }(ObservableBase));\n\n /**\n * Projects each element of an observable sequence into a new form by incorporating the element's index.\n * @param {Function} selector A transform function to apply to each source element; the second parameter of the function represents the index of the source element.\n * @param {Any} [thisArg] Object to use as this when executing callback.\n * @returns {Observable} An observable sequence whose elements are the result of invoking the transform function on each element of source.\n */\n observableProto.map = observableProto.select = function (selector, thisArg) {\n var selectorFn = typeof selector === 'function' ? selector : function () { return selector; };\n return this instanceof MapObservable ?\n this.internalMap(selectorFn, thisArg) :\n new MapObservable(this, selectorFn, thisArg);\n };\n\r\n /**\n * Retrieves the value of a specified nested property from all elements in\n * the Observable sequence.\n * @param {Arguments} arguments The nested properties to pluck.\n * @returns {Observable} Returns a new Observable sequence of property values.\n */\n observableProto.pluck = function () {\n var args = arguments, len = arguments.length;\n if (len === 0) { throw new Error('List of properties cannot be empty.'); }\n return this.map(function (x) {\n var currentProp = x;\n for (var i = 0; i < len; i++) {\n var p = currentProp[args[i]];\n if (typeof p !== 'undefined') {\n currentProp = p;\n } else {\n return undefined;\n }\n }\n return currentProp;\n });\n };\n\r\n function flatMap(source, selector, thisArg) {\n var selectorFunc = bindCallback(selector, thisArg, 3);\n return source.map(function (x, i) {\n var result = selectorFunc(x, i, source);\n isPromise(result) && (result = observableFromPromise(result));\n (isArrayLike(result) || isIterable(result)) && (result = observableFrom(result));\n return result;\n }).mergeAll();\n }\n\n /**\n * One of the Following:\n * Projects each element of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence.\n *\n * @example\n * var res = source.selectMany(function (x) { return Rx.Observable.range(0, x); });\n * Or:\n * Projects each element of an observable sequence to an observable sequence, invokes the result selector for the source element and each of the corresponding inner sequence's elements, and merges the results into one observable sequence.\n *\n * var res = source.selectMany(function (x) { return Rx.Observable.range(0, x); }, function (x, y) { return x + y; });\n * Or:\n * Projects each element of the source observable sequence to the other observable sequence and merges the resulting observable sequences into one observable sequence.\n *\n * var res = source.selectMany(Rx.Observable.fromArray([1,2,3]));\n * @param {Function} selector A transform function to apply to each element or an observable sequence to project each element from the source sequence onto which could be either an observable or Promise.\n * @param {Function} [resultSelector] A transform function to apply to each element of the intermediate sequence.\n * @param {Any} [thisArg] Object to use as this when executing callback.\n * @returns {Observable} An observable sequence whose elements are the result of invoking the one-to-many transform function collectionSelector on each element of the input sequence and then mapping each of those sequence elements and their corresponding source element to a result element.\n */\n observableProto.selectMany = observableProto.flatMap = function (selector, resultSelector, thisArg) {\n if (isFunction(selector) && isFunction(resultSelector)) {\n return this.flatMap(function (x, i) {\n var selectorResult = selector(x, i);\n isPromise(selectorResult) && (selectorResult = observableFromPromise(selectorResult));\n (isArrayLike(selectorResult) || isIterable(selectorResult)) && (selectorResult = observableFrom(selectorResult));\n\n return selectorResult.map(function (y, i2) {\n return resultSelector(x, y, i, i2);\n });\n }, thisArg);\n }\n return isFunction(selector) ?\n flatMap(this, selector, thisArg) :\n flatMap(this, function () { return selector; });\n };\n\r\n /**\n * Projects each notification of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence.\n * @param {Function} onNext A transform function to apply to each element; the second parameter of the function represents the index of the source element.\n * @param {Function} onError A transform function to apply when an error occurs in the source sequence.\n * @param {Function} onCompleted A transform function to apply when the end of the source sequence is reached.\n * @param {Any} [thisArg] An optional \"this\" to use to invoke each transform.\n * @returns {Observable} An observable sequence whose elements are the result of invoking the one-to-many transform function corresponding to each notification in the input sequence.\n */\n observableProto.flatMapObserver = observableProto.selectManyObserver = function (onNext, onError, onCompleted, thisArg) {\n var source = this;\n return new AnonymousObservable(function (observer) {\n var index = 0;\n\n return source.subscribe(\n function (x) {\n var result;\n try {\n result = onNext.call(thisArg, x, index++);\n } catch (e) {\n observer.onError(e);\n return;\n }\n isPromise(result) && (result = observableFromPromise(result));\n observer.onNext(result);\n },\n function (err) {\n var result;\n try {\n result = onError.call(thisArg, err);\n } catch (e) {\n observer.onError(e);\n return;\n }\n isPromise(result) && (result = observableFromPromise(result));\n observer.onNext(result);\n observer.onCompleted();\n },\n function () {\n var result;\n try {\n result = onCompleted.call(thisArg);\n } catch (e) {\n observer.onError(e);\n return;\n }\n isPromise(result) && (result = observableFromPromise(result));\n observer.onNext(result);\n observer.onCompleted();\n });\n }, source).mergeAll();\n };\n\r\n /**\n * Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then\n * transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence.\n * @param {Function} selector A transform function to apply to each source element; the second parameter of the function represents the index of the source element.\n * @param {Any} [thisArg] Object to use as this when executing callback.\n * @returns {Observable} An observable sequence whose elements are the result of invoking the transform function on each element of source producing an Observable of Observable sequences\n * and that at any point in time produces the elements of the most recent inner observable sequence that has been received.\n */\n observableProto.selectSwitch = observableProto.flatMapLatest = observableProto.switchMap = function (selector, thisArg) {\n return this.select(selector, thisArg).switchLatest();\n };\n\r\n var SkipObservable = (function(__super__) {\n inherits(SkipObservable, __super__);\n function SkipObservable(source, count) {\n this.source = source;\n this.skipCount = count;\n __super__.call(this);\n }\n \n SkipObservable.prototype.subscribeCore = function (o) {\n return this.source.subscribe(new InnerObserver(o, this.skipCount));\n };\n \n function InnerObserver(o, c) {\n this.c = c;\n this.r = c;\n this.o = o;\n this.isStopped = false;\n }\n InnerObserver.prototype.onNext = function (x) {\n if (this.isStopped) { return; }\n if (this.r <= 0) { \n this.o.onNext(x);\n } else {\n this.r--;\n }\n };\n InnerObserver.prototype.onError = function(e) {\n if (!this.isStopped) { this.isStopped = true; this.o.onError(e); }\n };\n InnerObserver.prototype.onCompleted = function() {\n if (!this.isStopped) { this.isStopped = true; this.o.onCompleted(); }\n };\n InnerObserver.prototype.dispose = function() { this.isStopped = true; };\n InnerObserver.prototype.fail = function(e) {\n if (!this.isStopped) {\n this.isStopped = true;\n this.o.onError(e);\n return true;\n }\n return false;\n };\n \n return SkipObservable;\n }(ObservableBase)); \n \n /**\n * Bypasses a specified number of elements in an observable sequence and then returns the remaining elements.\n * @param {Number} count The number of elements to skip before returning the remaining elements.\n * @returns {Observable} An observable sequence that contains the elements that occur after the specified index in the input sequence.\n */\n observableProto.skip = function (count) {\n if (count < 0) { throw new ArgumentOutOfRangeError(); }\n return new SkipObservable(this, count);\n };\r\n /**\n * Bypasses elements in an observable sequence as long as a specified condition is true and then returns the remaining elements.\n * The element's index is used in the logic of the predicate function.\n *\n * var res = source.skipWhile(function (value) { return value < 10; });\n * var res = source.skipWhile(function (value, index) { return value < 10 || index < 10; });\n * @param {Function} predicate A function to test each element for a condition; the second parameter of the function represents the index of the source element.\n * @param {Any} [thisArg] Object to use as this when executing callback.\n * @returns {Observable} An observable sequence that contains the elements from the input sequence starting at the first element in the linear series that does not pass the test specified by predicate.\n */\n observableProto.skipWhile = function (predicate, thisArg) {\n var source = this,\n callback = bindCallback(predicate, thisArg, 3);\n return new AnonymousObservable(function (o) {\n var i = 0, running = false;\n return source.subscribe(function (x) {\n if (!running) {\n try {\n running = !callback(x, i++, source);\n } catch (e) {\n o.onError(e);\n return;\n }\n }\n running && o.onNext(x);\n }, function (e) { o.onError(e); }, function () { o.onCompleted(); });\n }, source);\n };\n\r\n /**\n * Returns a specified number of contiguous elements from the start of an observable sequence, using the specified scheduler for the edge case of take(0).\n *\n * var res = source.take(5);\n * var res = source.take(0, Rx.Scheduler.timeout);\n * @param {Number} count The number of elements to return.\n * @param {Scheduler} [scheduler] Scheduler used to produce an OnCompleted message in case <paramref name=\"count count</paramref> is set to 0.\n * @returns {Observable} An observable sequence that contains the specified number of elements from the start of the input sequence.\n */\n observableProto.take = function (count, scheduler) {\n if (count < 0) { throw new ArgumentOutOfRangeError(); }\n if (count === 0) { return observableEmpty(scheduler); }\n var source = this;\n return new AnonymousObservable(function (o) {\n var remaining = count;\n return source.subscribe(function (x) {\n if (remaining-- > 0) {\n o.onNext(x);\n remaining <= 0 && o.onCompleted();\n }\n }, function (e) { o.onError(e); }, function () { o.onCompleted(); });\n }, source);\n };\n\r\n /**\n * Returns elements from an observable sequence as long as a specified condition is true.\n * The element's index is used in the logic of the predicate function.\n * @param {Function} predicate A function to test each element for a condition; the second parameter of the function represents the index of the source element.\n * @param {Any} [thisArg] Object to use as this when executing callback.\n * @returns {Observable} An observable sequence that contains the elements from the input sequence that occur before the element at which the test no longer passes.\n */\n observableProto.takeWhile = function (predicate, thisArg) {\n var source = this,\n callback = bindCallback(predicate, thisArg, 3);\n return new AnonymousObservable(function (o) {\n var i = 0, running = true;\n return source.subscribe(function (x) {\n if (running) {\n try {\n running = callback(x, i++, source);\n } catch (e) {\n o.onError(e);\n return;\n }\n if (running) {\n o.onNext(x);\n } else {\n o.onCompleted();\n }\n }\n }, function (e) { o.onError(e); }, function () { o.onCompleted(); });\n }, source);\n };\n\r\n var FilterObservable = (function (__super__) {\n inherits(FilterObservable, __super__);\n\n function FilterObservable(source, predicate, thisArg) {\n this.source = source;\n this.predicate = bindCallback(predicate, thisArg, 3);\n __super__.call(this);\n }\n\n FilterObservable.prototype.subscribeCore = function (o) {\n return this.source.subscribe(new InnerObserver(o, this.predicate, this));\n };\n \n function innerPredicate(predicate, self) {\n return function(x, i, o) { return self.predicate(x, i, o) && predicate.call(this, x, i, o); }\n }\n\n FilterObservable.prototype.internalFilter = function(predicate, thisArg) {\n return new FilterObservable(this.source, innerPredicate(predicate, this), thisArg);\n };\n \n function InnerObserver(o, predicate, source) {\n this.o = o;\n this.predicate = predicate;\n this.source = source;\n this.i = 0;\n this.isStopped = false;\n }\n \n InnerObserver.prototype.onNext = function(x) {\n if (this.isStopped) { return; }\n var shouldYield = tryCatch(this.predicate)(x, this.i++, this.source);\n if (shouldYield === errorObj) {\n return this.o.onError(shouldYield.e);\n }\n shouldYield && this.o.onNext(x);\n };\n InnerObserver.prototype.onError = function (e) {\n if(!this.isStopped) { this.isStopped = true; this.o.onError(e); }\n };\n InnerObserver.prototype.onCompleted = function () {\n if(!this.isStopped) { this.isStopped = true; this.o.onCompleted(); }\n };\n InnerObserver.prototype.dispose = function() { this.isStopped = true; };\n InnerObserver.prototype.fail = function (e) {\n if (!this.isStopped) {\n this.isStopped = true;\n this.o.onError(e);\n return true;\n }\n return false;\n };\n\n return FilterObservable;\n\n }(ObservableBase));\n\n /**\n * Filters the elements of an observable sequence based on a predicate by incorporating the element's index.\n * @param {Function} predicate A function to test each source element for a condition; the second parameter of the function represents the index of the source element.\n * @param {Any} [thisArg] Object to use as this when executing callback.\n * @returns {Observable} An observable sequence that contains elements from the input sequence that satisfy the condition.\n */\n observableProto.filter = observableProto.where = function (predicate, thisArg) {\n return this instanceof FilterObservable ? this.internalFilter(predicate, thisArg) :\n new FilterObservable(this, predicate, thisArg);\n };\n\r\n function extremaBy(source, keySelector, comparer) {\n return new AnonymousObservable(function (o) {\n var hasValue = false, lastKey = null, list = [];\n return source.subscribe(function (x) {\n var comparison, key;\n try {\n key = keySelector(x);\n } catch (ex) {\n o.onError(ex);\n return;\n }\n comparison = 0;\n if (!hasValue) {\n hasValue = true;\n lastKey = key;\n } else {\n try {\n comparison = comparer(key, lastKey);\n } catch (ex1) {\n o.onError(ex1);\n return;\n }\n }\n if (comparison > 0) {\n lastKey = key;\n list = [];\n }\n if (comparison >= 0) { list.push(x); }\n }, function (e) { o.onError(e); }, function () {\n o.onNext(list);\n o.onCompleted();\n });\n }, source);\n }\n\r\n function firstOnly(x) {\n if (x.length === 0) { throw new EmptyError(); }\n return x[0];\n }\n\r\n /**\n * Applies an accumulator function over an observable sequence, returning the result of the aggregation as a single element in the result sequence. The specified seed value is used as the initial accumulator value.\n * For aggregation behavior with incremental intermediate results, see Observable.scan.\n * @deprecated Use #reduce instead\n * @param {Mixed} [seed] The initial accumulator value.\n * @param {Function} accumulator An accumulator function to be invoked on each element.\n * @returns {Observable} An observable sequence containing a single element with the final accumulator value.\n */\n observableProto.aggregate = function () {\n var hasSeed = false, accumulator, seed, source = this;\n if (arguments.length === 2) {\n hasSeed = true;\n seed = arguments[0];\n accumulator = arguments[1];\n } else {\n accumulator = arguments[0];\n }\n return new AnonymousObservable(function (o) {\n var hasAccumulation, accumulation, hasValue;\n return source.subscribe (\n function (x) {\n !hasValue && (hasValue = true);\n try {\n if (hasAccumulation) {\n accumulation = accumulator(accumulation, x);\n } else {\n accumulation = hasSeed ? accumulator(seed, x) : x;\n hasAccumulation = true;\n }\n } catch (e) {\n return o.onError(e);\n }\n },\n function (e) { o.onError(e); },\n function () {\n hasValue && o.onNext(accumulation);\n !hasValue && hasSeed && o.onNext(seed);\n !hasValue && !hasSeed && o.onError(new EmptyError());\n o.onCompleted();\n }\n );\n }, source);\n };\n\r\n var ReduceObservable = (function(__super__) {\n inherits(ReduceObservable, __super__);\n function ReduceObservable(source, acc, hasSeed, seed) {\n this.source = source;\n this.acc = acc;\n this.hasSeed = hasSeed;\n this.seed = seed;\n __super__.call(this);\n }\n\n ReduceObservable.prototype.subscribeCore = function(observer) {\n return this.source.subscribe(new InnerObserver(observer,this));\n };\n\n function InnerObserver(o, parent) {\n this.o = o;\n this.acc = parent.acc;\n this.hasSeed = parent.hasSeed;\n this.seed = parent.seed;\n this.hasAccumulation = false;\n this.result = null;\n this.hasValue = false;\n this.isStopped = false;\n }\n InnerObserver.prototype.onNext = function (x) {\n if (this.isStopped) { return; }\n !this.hasValue && (this.hasValue = true);\n if (this.hasAccumulation) {\n this.result = tryCatch(this.acc)(this.result, x);\n } else {\n this.result = this.hasSeed ? tryCatch(this.acc)(this.seed, x) : x;\n this.hasAccumulation = true;\n }\n if (this.result === errorObj) { this.o.onError(this.result.e); }\n };\n InnerObserver.prototype.onError = function (e) { \n if (!this.isStopped) { this.isStopped = true; this.o.onError(e); } \n };\n InnerObserver.prototype.onCompleted = function () {\n if (!this.isStopped) {\n this.isStopped = true;\n this.hasValue && this.o.onNext(this.result);\n !this.hasValue && this.hasSeed && this.o.onNext(this.seed);\n !this.hasValue && !this.hasSeed && this.o.onError(new EmptyError());\n this.o.onCompleted();\n }\n };\n InnerObserver.prototype.dispose = function () { this.isStopped = true; };\n InnerObserver.prototype.fail = function(e) {\n if (!this.isStopped) {\n this.isStopped = true;\n this.o.onError(e);\n return true;\n }\n return false;\n };\n\n return ReduceObservable;\n }(ObservableBase));\n\n /**\n * Applies an accumulator function over an observable sequence, returning the result of the aggregation as a single element in the result sequence. The specified seed value is used as the initial accumulator value.\n * For aggregation behavior with incremental intermediate results, see Observable.scan.\n * @param {Function} accumulator An accumulator function to be invoked on each element.\n * @param {Any} [seed] The initial accumulator value.\n * @returns {Observable} An observable sequence containing a single element with the final accumulator value.\n */\n observableProto.reduce = function (accumulator) {\n var hasSeed = false;\n if (arguments.length === 2) {\n hasSeed = true;\n var seed = arguments[1];\n }\n return new ReduceObservable(this, accumulator, hasSeed, seed);\n };\n\r\n /**\n * Determines whether any element of an observable sequence satisfies a condition if present, else if any items are in the sequence.\n * @param {Function} [predicate] A function to test each element for a condition.\n * @returns {Observable} An observable sequence containing a single element determining whether any elements in the source sequence pass the test in the specified predicate if given, else if any items are in the sequence.\n */\n observableProto.some = function (predicate, thisArg) {\n var source = this;\n return predicate ?\n source.filter(predicate, thisArg).some() :\n new AnonymousObservable(function (observer) {\n return source.subscribe(function () {\n observer.onNext(true);\n observer.onCompleted();\n }, function (e) { observer.onError(e); }, function () {\n observer.onNext(false);\n observer.onCompleted();\n });\n }, source);\n };\n\n /** @deprecated use #some instead */\n observableProto.any = function () {\n //deprecate('any', 'some');\n return this.some.apply(this, arguments);\n };\n\r\n /**\n * Determines whether an observable sequence is empty.\n * @returns {Observable} An observable sequence containing a single element determining whether the source sequence is empty.\n */\n observableProto.isEmpty = function () {\n return this.any().map(not);\n };\n\r\n /**\n * Determines whether all elements of an observable sequence satisfy a condition.\n * @param {Function} [predicate] A function to test each element for a condition.\n * @param {Any} [thisArg] Object to use as this when executing callback.\n * @returns {Observable} An observable sequence containing a single element determining whether all elements in the source sequence pass the test in the specified predicate.\n */\n observableProto.every = function (predicate, thisArg) {\n return this.filter(function (v) { return !predicate(v); }, thisArg).some().map(not);\n };\n\n /** @deprecated use #every instead */\n observableProto.all = function () {\n //deprecate('all', 'every');\n return this.every.apply(this, arguments);\n };\n\r\n /**\n * Determines whether an observable sequence includes a specified element with an optional equality comparer.\n * @param searchElement The value to locate in the source sequence.\n * @param {Number} [fromIndex] An equality comparer to compare elements.\n * @returns {Observable} An observable sequence containing a single element determining whether the source sequence includes an element that has the specified value from the given index.\n */\n observableProto.includes = function (searchElement, fromIndex) {\n var source = this;\n function comparer(a, b) {\n return (a === 0 && b === 0) || (a === b || (isNaN(a) && isNaN(b)));\n }\n return new AnonymousObservable(function (o) {\n var i = 0, n = +fromIndex || 0;\n Math.abs(n) === Infinity && (n = 0);\n if (n < 0) {\n o.onNext(false);\n o.onCompleted();\n return disposableEmpty;\n }\n return source.subscribe(\n function (x) {\n if (i++ >= n && comparer(x, searchElement)) {\n o.onNext(true);\n o.onCompleted();\n }\n },\n function (e) { o.onError(e); },\n function () {\n o.onNext(false);\n o.onCompleted();\n });\n }, this);\n };\n\n /**\n * @deprecated use #includes instead.\n */\n observableProto.contains = function (searchElement, fromIndex) {\n //deprecate('contains', 'includes');\n observableProto.includes(searchElement, fromIndex);\n };\n\r\n /**\n * Returns an observable sequence containing a value that represents how many elements in the specified observable sequence satisfy a condition if provided, else the count of items.\n * @example\n * res = source.count();\n * res = source.count(function (x) { return x > 3; });\n * @param {Function} [predicate]A function to test each element for a condition.\n * @param {Any} [thisArg] Object to use as this when executing callback.\n * @returns {Observable} An observable sequence containing a single element with a number that represents how many elements in the input sequence satisfy the condition in the predicate function if provided, else the count of items in the sequence.\n */\n observableProto.count = function (predicate, thisArg) {\n return predicate ?\n this.filter(predicate, thisArg).count() :\n this.reduce(function (count) { return count + 1; }, 0);\n };\n\r\n /**\n * Returns the first index at which a given element can be found in the observable sequence, or -1 if it is not present.\n * @param {Any} searchElement Element to locate in the array.\n * @param {Number} [fromIndex] The index to start the search. If not specified, defaults to 0.\n * @returns {Observable} And observable sequence containing the first index at which a given element can be found in the observable sequence, or -1 if it is not present.\n */\n observableProto.indexOf = function(searchElement, fromIndex) {\n var source = this;\n return new AnonymousObservable(function (o) {\n var i = 0, n = +fromIndex || 0;\n Math.abs(n) === Infinity && (n = 0);\n if (n < 0) {\n o.onNext(-1);\n o.onCompleted();\n return disposableEmpty;\n }\n return source.subscribe(\n function (x) {\n if (i >= n && x === searchElement) {\n o.onNext(i);\n o.onCompleted();\n }\n i++;\n },\n function (e) { o.onError(e); },\n function () {\n o.onNext(-1);\n o.onCompleted();\n });\n }, source);\n };\n\r\n /**\n * Computes the sum of a sequence of values that are obtained by invoking an optional transform function on each element of the input sequence, else if not specified computes the sum on each item in the sequence.\n * @param {Function} [selector] A transform function to apply to each element.\n * @param {Any} [thisArg] Object to use as this when executing callback.\n * @returns {Observable} An observable sequence containing a single element with the sum of the values in the source sequence.\n */\n observableProto.sum = function (keySelector, thisArg) {\n return keySelector && isFunction(keySelector) ?\n this.map(keySelector, thisArg).sum() :\n this.reduce(function (prev, curr) { return prev + curr; }, 0);\n };\n\r\n /**\n * Returns the elements in an observable sequence with the minimum key value according to the specified comparer.\n * @example\n * var res = source.minBy(function (x) { return x.value; });\n * var res = source.minBy(function (x) { return x.value; }, function (x, y) { return x - y; });\n * @param {Function} keySelector Key selector function.\n * @param {Function} [comparer] Comparer used to compare key values.\n * @returns {Observable} An observable sequence containing a list of zero or more elements that have a minimum key value.\n */\n observableProto.minBy = function (keySelector, comparer) {\n comparer || (comparer = defaultSubComparer);\n return extremaBy(this, keySelector, function (x, y) { return comparer(x, y) * -1; });\n };\n\r\n /**\n * Returns the minimum element in an observable sequence according to the optional comparer else a default greater than less than check.\n * @example\n * var res = source.min();\n * var res = source.min(function (x, y) { return x.value - y.value; });\n * @param {Function} [comparer] Comparer used to compare elements.\n * @returns {Observable} An observable sequence containing a single element with the minimum element in the source sequence.\n */\n observableProto.min = function (comparer) {\n return this.minBy(identity, comparer).map(function (x) { return firstOnly(x); });\n };\n\r\n /**\n * Returns the elements in an observable sequence with the maximum key value according to the specified comparer.\n * @example\n * var res = source.maxBy(function (x) { return x.value; });\n * var res = source.maxBy(function (x) { return x.value; }, function (x, y) { return x - y;; });\n * @param {Function} keySelector Key selector function.\n * @param {Function} [comparer] Comparer used to compare key values.\n * @returns {Observable} An observable sequence containing a list of zero or more elements that have a maximum key value.\n */\n observableProto.maxBy = function (keySelector, comparer) {\n comparer || (comparer = defaultSubComparer);\n return extremaBy(this, keySelector, comparer);\n };\n\r\n /**\n * Returns the maximum value in an observable sequence according to the specified comparer.\n * @example\n * var res = source.max();\n * var res = source.max(function (x, y) { return x.value - y.value; });\n * @param {Function} [comparer] Comparer used to compare elements.\n * @returns {Observable} An observable sequence containing a single element with the maximum element in the source sequence.\n */\n observableProto.max = function (comparer) {\n return this.maxBy(identity, comparer).map(function (x) { return firstOnly(x); });\n };\n\r\n /**\n * Computes the average of an observable sequence of values that are in the sequence or obtained by invoking a transform function on each element of the input sequence if present.\n * @param {Function} [selector] A transform function to apply to each element.\n * @param {Any} [thisArg] Object to use as this when executing callback.\n * @returns {Observable} An observable sequence containing a single element with the average of the sequence of values.\n */\n observableProto.average = function (keySelector, thisArg) {\n return keySelector && isFunction(keySelector) ?\n this.map(keySelector, thisArg).average() :\n this.reduce(function (prev, cur) {\n return {\n sum: prev.sum + cur,\n count: prev.count + 1\n };\n }, {sum: 0, count: 0 }).map(function (s) {\n if (s.count === 0) { throw new EmptyError(); }\n return s.sum / s.count;\n });\n };\n\r\n /**\n * Determines whether two sequences are equal by comparing the elements pairwise using a specified equality comparer.\n *\n * @example\n * var res = res = source.sequenceEqual([1,2,3]);\n * var res = res = source.sequenceEqual([{ value: 42 }], function (x, y) { return x.value === y.value; });\n * 3 - res = source.sequenceEqual(Rx.Observable.returnValue(42));\n * 4 - res = source.sequenceEqual(Rx.Observable.returnValue({ value: 42 }), function (x, y) { return x.value === y.value; });\n * @param {Observable} second Second observable sequence or array to compare.\n * @param {Function} [comparer] Comparer used to compare elements of both sequences.\n * @returns {Observable} An observable sequence that contains a single element which indicates whether both sequences are of equal length and their corresponding elements are equal according to the specified equality comparer.\n */\n observableProto.sequenceEqual = function (second, comparer) {\n var first = this;\n comparer || (comparer = defaultComparer);\n return new AnonymousObservable(function (o) {\n var donel = false, doner = false, ql = [], qr = [];\n var subscription1 = first.subscribe(function (x) {\n var equal, v;\n if (qr.length > 0) {\n v = qr.shift();\n try {\n equal = comparer(v, x);\n } catch (e) {\n o.onError(e);\n return;\n }\n if (!equal) {\n o.onNext(false);\n o.onCompleted();\n }\n } else if (doner) {\n o.onNext(false);\n o.onCompleted();\n } else {\n ql.push(x);\n }\n }, function(e) { o.onError(e); }, function () {\n donel = true;\n if (ql.length === 0) {\n if (qr.length > 0) {\n o.onNext(false);\n o.onCompleted();\n } else if (doner) {\n o.onNext(true);\n o.onCompleted();\n }\n }\n });\n\n (isArrayLike(second) || isIterable(second)) && (second = observableFrom(second));\n isPromise(second) && (second = observableFromPromise(second));\n var subscription2 = second.subscribe(function (x) {\n var equal;\n if (ql.length > 0) {\n var v = ql.shift();\n try {\n equal = comparer(v, x);\n } catch (exception) {\n o.onError(exception);\n return;\n }\n if (!equal) {\n o.onNext(false);\n o.onCompleted();\n }\n } else if (donel) {\n o.onNext(false);\n o.onCompleted();\n } else {\n qr.push(x);\n }\n }, function(e) { o.onError(e); }, function () {\n doner = true;\n if (qr.length === 0) {\n if (ql.length > 0) {\n o.onNext(false);\n o.onCompleted();\n } else if (donel) {\n o.onNext(true);\n o.onCompleted();\n }\n }\n });\n return new CompositeDisposable(subscription1, subscription2);\n }, first);\n };\n\r\n function elementAtOrDefault(source, index, hasDefault, defaultValue) {\n if (index < 0) { throw new ArgumentOutOfRangeError(); }\n return new AnonymousObservable(function (o) {\n var i = index;\n return source.subscribe(function (x) {\n if (i-- === 0) {\n o.onNext(x);\n o.onCompleted();\n }\n }, function (e) { o.onError(e); }, function () {\n if (!hasDefault) {\n o.onError(new ArgumentOutOfRangeError());\n } else {\n o.onNext(defaultValue);\n o.onCompleted();\n }\n });\n }, source);\n }\n\r\n /**\n * Returns the element at a specified index in a sequence.\n * @example\n * var res = source.elementAt(5);\n * @param {Number} index The zero-based index of the element to retrieve.\n * @returns {Observable} An observable sequence that produces the element at the specified position in the source sequence.\n */\n observableProto.elementAt = function (index) {\n return elementAtOrDefault(this, index, false);\n };\n\r\n /**\n * Returns the element at a specified index in a sequence or a default value if the index is out of range.\n * @example\n * var res = source.elementAtOrDefault(5);\n * var res = source.elementAtOrDefault(5, 0);\n * @param {Number} index The zero-based index of the element to retrieve.\n * @param [defaultValue] The default value if the index is outside the bounds of the source sequence.\n * @returns {Observable} An observable sequence that produces the element at the specified position in the source sequence, or a default value if the index is outside the bounds of the source sequence.\n */\n observableProto.elementAtOrDefault = function (index, defaultValue) {\n return elementAtOrDefault(this, index, true, defaultValue);\n };\n\r\n function singleOrDefaultAsync(source, hasDefault, defaultValue) {\n return new AnonymousObservable(function (o) {\n var value = defaultValue, seenValue = false;\n return source.subscribe(function (x) {\n if (seenValue) {\n o.onError(new Error('Sequence contains more than one element'));\n } else {\n value = x;\n seenValue = true;\n }\n }, function (e) { o.onError(e); }, function () {\n if (!seenValue && !hasDefault) {\n o.onError(new EmptyError());\n } else {\n o.onNext(value);\n o.onCompleted();\n }\n });\n }, source);\n }\n\r\n /**\n * Returns the only element of an observable sequence that satisfies the condition in the optional predicate, and reports an exception if there is not exactly one element in the observable sequence.\n * @param {Function} [predicate] A predicate function to evaluate for elements in the source sequence.\n * @param {Any} [thisArg] Object to use as `this` when executing the predicate.\n * @returns {Observable} Sequence containing the single element in the observable sequence that satisfies the condition in the predicate.\n */\n observableProto.single = function (predicate, thisArg) {\n return predicate && isFunction(predicate) ?\n this.where(predicate, thisArg).single() :\n singleOrDefaultAsync(this, false);\n };\n\r\n /**\n * Returns the only element of an observable sequence that matches the predicate, or a default value if no such element exists; this method reports an exception if there is more than one element in the observable sequence.\n * @example\n * var res = res = source.singleOrDefault();\n * var res = res = source.singleOrDefault(function (x) { return x === 42; });\n * res = source.singleOrDefault(function (x) { return x === 42; }, 0);\n * res = source.singleOrDefault(null, 0);\n * @memberOf Observable#\n * @param {Function} predicate A predicate function to evaluate for elements in the source sequence.\n * @param [defaultValue] The default value if the index is outside the bounds of the source sequence.\n * @param {Any} [thisArg] Object to use as `this` when executing the predicate.\n * @returns {Observable} Sequence containing the single element in the observable sequence that satisfies the condition in the predicate, or a default value if no such element exists.\n */\n observableProto.singleOrDefault = function (predicate, defaultValue, thisArg) {\n return predicate && isFunction(predicate) ?\n this.filter(predicate, thisArg).singleOrDefault(null, defaultValue) :\n singleOrDefaultAsync(this, true, defaultValue);\n };\n\r\n function firstOrDefaultAsync(source, hasDefault, defaultValue) {\n return new AnonymousObservable(function (o) {\n return source.subscribe(function (x) {\n o.onNext(x);\n o.onCompleted();\n }, function (e) { o.onError(e); }, function () {\n if (!hasDefault) {\n o.onError(new EmptyError());\n } else {\n o.onNext(defaultValue);\n o.onCompleted();\n }\n });\n }, source);\n }\n\r\n /**\n * Returns the first element of an observable sequence that satisfies the condition in the predicate if present else the first item in the sequence.\n * @example\n * var res = res = source.first();\n * var res = res = source.first(function (x) { return x > 3; });\n * @param {Function} [predicate] A predicate function to evaluate for elements in the source sequence.\n * @param {Any} [thisArg] Object to use as `this` when executing the predicate.\n * @returns {Observable} Sequence containing the first element in the observable sequence that satisfies the condition in the predicate if provided, else the first item in the sequence.\n */\n observableProto.first = function (predicate, thisArg) {\n return predicate ?\n this.where(predicate, thisArg).first() :\n firstOrDefaultAsync(this, false);\n };\n\r\n /**\n * Returns the first element of an observable sequence that satisfies the condition in the predicate, or a default value if no such element exists.\n * @param {Function} [predicate] A predicate function to evaluate for elements in the source sequence.\n * @param {Any} [defaultValue] The default value if no such element exists. If not specified, defaults to null.\n * @param {Any} [thisArg] Object to use as `this` when executing the predicate.\n * @returns {Observable} Sequence containing the first element in the observable sequence that satisfies the condition in the predicate, or a default value if no such element exists.\n */\n observableProto.firstOrDefault = function (predicate, defaultValue, thisArg) {\n return predicate ?\n this.where(predicate).firstOrDefault(null, defaultValue) :\n firstOrDefaultAsync(this, true, defaultValue);\n };\n\r\n function lastOrDefaultAsync(source, hasDefault, defaultValue) {\n return new AnonymousObservable(function (o) {\n var value = defaultValue, seenValue = false;\n return source.subscribe(function (x) {\n value = x;\n seenValue = true;\n }, function (e) { o.onError(e); }, function () {\n if (!seenValue && !hasDefault) {\n o.onError(new EmptyError());\n } else {\n o.onNext(value);\n o.onCompleted();\n }\n });\n }, source);\n }\n\r\n /**\n * Returns the last element of an observable sequence that satisfies the condition in the predicate if specified, else the last element.\n * @param {Function} [predicate] A predicate function to evaluate for elements in the source sequence.\n * @param {Any} [thisArg] Object to use as `this` when executing the predicate.\n * @returns {Observable} Sequence containing the last element in the observable sequence that satisfies the condition in the predicate.\n */\n observableProto.last = function (predicate, thisArg) {\n return predicate ?\n this.where(predicate, thisArg).last() :\n lastOrDefaultAsync(this, false);\n };\n\r\n /**\n * Returns the last element of an observable sequence that satisfies the condition in the predicate, or a default value if no such element exists.\n * @param {Function} [predicate] A predicate function to evaluate for elements in the source sequence.\n * @param [defaultValue] The default value if no such element exists. If not specified, defaults to null.\n * @param {Any} [thisArg] Object to use as `this` when executing the predicate.\n * @returns {Observable} Sequence containing the last element in the observable sequence that satisfies the condition in the predicate, or a default value if no such element exists.\n */\n observableProto.lastOrDefault = function (predicate, defaultValue, thisArg) {\n return predicate ?\n this.where(predicate, thisArg).lastOrDefault(null, defaultValue) :\n lastOrDefaultAsync(this, true, defaultValue);\n };\n\r\n function findValue (source, predicate, thisArg, yieldIndex) {\n var callback = bindCallback(predicate, thisArg, 3);\n return new AnonymousObservable(function (o) {\n var i = 0;\n return source.subscribe(function (x) {\n var shouldRun;\n try {\n shouldRun = callback(x, i, source);\n } catch (e) {\n o.onError(e);\n return;\n }\n if (shouldRun) {\n o.onNext(yieldIndex ? i : x);\n o.onCompleted();\n } else {\n i++;\n }\n }, function (e) { o.onError(e); }, function () {\n o.onNext(yieldIndex ? -1 : undefined);\n o.onCompleted();\n });\n }, source);\n }\n\r\n /**\n * Searches for an element that matches the conditions defined by the specified predicate, and returns the first occurrence within the entire Observable sequence.\n * @param {Function} predicate The predicate that defines the conditions of the element to search for.\n * @param {Any} [thisArg] Object to use as `this` when executing the predicate.\n * @returns {Observable} An Observable sequence with the first element that matches the conditions defined by the specified predicate, if found; otherwise, undefined.\n */\n observableProto.find = function (predicate, thisArg) {\n return findValue(this, predicate, thisArg, false);\n };\n\r\n /**\n * Searches for an element that matches the conditions defined by the specified predicate, and returns\n * an Observable sequence with the zero-based index of the first occurrence within the entire Observable sequence.\n * @param {Function} predicate The predicate that defines the conditions of the element to search for.\n * @param {Any} [thisArg] Object to use as `this` when executing the predicate.\n * @returns {Observable} An Observable sequence with the zero-based index of the first occurrence of an element that matches the conditions defined by match, if found; otherwise, –1.\n */\n observableProto.findIndex = function (predicate, thisArg) {\n return findValue(this, predicate, thisArg, true);\n };\n\r\n /**\n * Converts the observable sequence to a Set if it exists.\n * @returns {Observable} An observable sequence with a single value of a Set containing the values from the observable sequence.\n */\n observableProto.toSet = function () {\n if (typeof root.Set === 'undefined') { throw new TypeError(); }\n var source = this;\n return new AnonymousObservable(function (o) {\n var s = new root.Set();\n return source.subscribe(\n function (x) { s.add(x); },\n function (e) { o.onError(e); },\n function () {\n o.onNext(s);\n o.onCompleted();\n });\n }, source);\n };\n\r\n /**\n * Converts the observable sequence to a Map if it exists.\n * @param {Function} keySelector A function which produces the key for the Map.\n * @param {Function} [elementSelector] An optional function which produces the element for the Map. If not present, defaults to the value from the observable sequence.\n * @returns {Observable} An observable sequence with a single value of a Map containing the values from the observable sequence.\n */\n observableProto.toMap = function (keySelector, elementSelector) {\n if (typeof root.Map === 'undefined') { throw new TypeError(); }\n var source = this;\n return new AnonymousObservable(function (o) {\n var m = new root.Map();\n return source.subscribe(\n function (x) {\n var key;\n try {\n key = keySelector(x);\n } catch (e) {\n o.onError(e);\n return;\n }\n\n var element = x;\n if (elementSelector) {\n try {\n element = elementSelector(x);\n } catch (e) {\n o.onError(e);\n return;\n }\n }\n\n m.set(key, element);\n },\n function (e) { o.onError(e); },\n function () {\n o.onNext(m);\n o.onCompleted();\n });\n }, source);\n };\n\r\n var fnString = 'function',\n throwString = 'throw',\n isObject = Rx.internals.isObject;\n\n function toThunk(obj, ctx) {\n if (Array.isArray(obj)) { return objectToThunk.call(ctx, obj); }\n if (isGeneratorFunction(obj)) { return observableSpawn(obj.call(ctx)); }\n if (isGenerator(obj)) { return observableSpawn(obj); }\n if (isObservable(obj)) { return observableToThunk(obj); }\n if (isPromise(obj)) { return promiseToThunk(obj); }\n if (typeof obj === fnString) { return obj; }\n if (isObject(obj) || Array.isArray(obj)) { return objectToThunk.call(ctx, obj); }\n\n return obj;\n }\n\n function objectToThunk(obj) {\n var ctx = this;\n\n return function (done) {\n var keys = Object.keys(obj),\n pending = keys.length,\n results = new obj.constructor(),\n finished;\n\n if (!pending) {\n timeoutScheduler.schedule(function () { done(null, results); });\n return;\n }\n\n for (var i = 0, len = keys.length; i < len; i++) {\n run(obj[keys[i]], keys[i]);\n }\n\n function run(fn, key) {\n if (finished) { return; }\n try {\n fn = toThunk(fn, ctx);\n\n if (typeof fn !== fnString) {\n results[key] = fn;\n return --pending || done(null, results);\n }\n\n fn.call(ctx, function(err, res) {\n if (finished) { return; }\n\n if (err) {\n finished = true;\n return done(err);\n }\n\n results[key] = res;\n --pending || done(null, results);\n });\n } catch (e) {\n finished = true;\n done(e);\n }\n }\n }\n }\n\n function observableToThunk(observable) {\n return function (fn) {\n var value, hasValue = false;\n observable.subscribe(\n function (v) {\n value = v;\n hasValue = true;\n },\n fn,\n function () {\n hasValue && fn(null, value);\n });\n }\n }\n\n function promiseToThunk(promise) {\n return function(fn) {\n promise.then(function(res) {\n fn(null, res);\n }, fn);\n }\n }\n\n function isObservable(obj) {\n return obj && typeof obj.subscribe === fnString;\n }\n\n function isGeneratorFunction(obj) {\n return obj && obj.constructor && obj.constructor.name === 'GeneratorFunction';\n }\n\n function isGenerator(obj) {\n return obj && typeof obj.next === fnString && typeof obj[throwString] === fnString;\n }\n\n /*\n * Spawns a generator function which allows for Promises, Observable sequences, Arrays, Objects, Generators and functions.\n * @param {Function} The spawning function.\n * @returns {Function} a function which has a done continuation.\n */\n var observableSpawn = Rx.spawn = function (fn) {\n var isGenFun = isGeneratorFunction(fn);\n\n return function (done) {\n var ctx = this,\n gen = fn;\n\n if (isGenFun) {\n for(var args = [], i = 0, len = arguments.length; i < len; i++) { args.push(arguments[i]); }\n var len = args.length,\n hasCallback = len && typeof args[len - 1] === fnString;\n\n done = hasCallback ? args.pop() : handleError;\n gen = fn.apply(this, args);\n } else {\n done = done || handleError;\n }\n\n next();\n\n function exit(err, res) {\n timeoutScheduler.schedule(done.bind(ctx, err, res));\n }\n\n function next(err, res) {\n var ret;\n\n // multiple args\n if (arguments.length > 2) {\n for(var res = [], i = 1, len = arguments.length; i < len; i++) { res.push(arguments[i]); }\n }\n\n if (err) {\n try {\n ret = gen[throwString](err);\n } catch (e) {\n return exit(e);\n }\n }\n\n if (!err) {\n try {\n ret = gen.next(res);\n } catch (e) {\n return exit(e);\n }\n }\n\n if (ret.done) {\n return exit(null, ret.value);\n }\n\n ret.value = toThunk(ret.value, ctx);\n\n if (typeof ret.value === fnString) {\n var called = false;\n try {\n ret.value.call(ctx, function() {\n if (called) {\n return;\n }\n\n called = true;\n next.apply(ctx, arguments);\n });\n } catch (e) {\n timeoutScheduler.schedule(function () {\n if (called) {\n return;\n }\n\n called = true;\n next.call(ctx, e);\n });\n }\n return;\n }\n\n // Not supported\n next(new TypeError('Rx.spawn only supports a function, Promise, Observable, Object or Array.'));\n }\n }\n };\n\n function handleError(err) {\n if (!err) { return; }\n timeoutScheduler.schedule(function() {\n throw err;\n });\n }\n\r\n /**\n * Invokes the specified function asynchronously on the specified scheduler, surfacing the result through an observable sequence.\n *\n * @example\n * var res = Rx.Observable.start(function () { console.log('hello'); });\n * var res = Rx.Observable.start(function () { console.log('hello'); }, Rx.Scheduler.timeout);\n * var res = Rx.Observable.start(function () { this.log('hello'); }, Rx.Scheduler.timeout, console);\n *\n * @param {Function} func Function to run asynchronously.\n * @param {Scheduler} [scheduler] Scheduler to run the function on. If not specified, defaults to Scheduler.timeout.\n * @param [context] The context for the func parameter to be executed. If not specified, defaults to undefined.\n * @returns {Observable} An observable sequence exposing the function's result value, or an exception.\n *\n * Remarks\n * * The function is called immediately, not during the subscription of the resulting sequence.\n * * Multiple subscriptions to the resulting sequence can observe the function's result.\n */\n Observable.start = function (func, context, scheduler) {\n return observableToAsync(func, context, scheduler)();\n };\n\r\n /**\n * Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function on the specified scheduler.\n * @param {Function} function Function to convert to an asynchronous function.\n * @param {Scheduler} [scheduler] Scheduler to run the function on. If not specified, defaults to Scheduler.timeout.\n * @param {Mixed} [context] The context for the func parameter to be executed. If not specified, defaults to undefined.\n * @returns {Function} Asynchronous function.\n */\n var observableToAsync = Observable.toAsync = function (func, context, scheduler) {\n isScheduler(scheduler) || (scheduler = timeoutScheduler);\n return function () {\n var args = arguments,\n subject = new AsyncSubject();\n\n scheduler.schedule(function () {\n var result;\n try {\n result = func.apply(context, args);\n } catch (e) {\n subject.onError(e);\n return;\n }\n subject.onNext(result);\n subject.onCompleted();\n });\n return subject.asObservable();\n };\n };\n\r\n /**\n * Converts a callback function to an observable sequence.\n *\n * @param {Function} function Function with a callback as the last parameter to convert to an Observable sequence.\n * @param {Mixed} [context] The context for the func parameter to be executed. If not specified, defaults to undefined.\n * @param {Function} [selector] A selector which takes the arguments from the callback to produce a single item to yield on next.\n * @returns {Function} A function, when executed with the required parameters minus the callback, produces an Observable sequence with a single value of the arguments to the callback as an array.\n */\n Observable.fromCallback = function (func, context, selector) {\n return function () {\n var len = arguments.length, args = new Array(len)\n for(var i = 0; i < len; i++) { args[i] = arguments[i]; }\n\n return new AnonymousObservable(function (observer) {\n function handler() {\n var len = arguments.length, results = new Array(len);\n for(var i = 0; i < len; i++) { results[i] = arguments[i]; }\n\n if (selector) {\n try {\n results = selector.apply(context, results);\n } catch (e) {\n return observer.onError(e);\n }\n\n observer.onNext(results);\n } else {\n if (results.length <= 1) {\n observer.onNext.apply(observer, results);\n } else {\n observer.onNext(results);\n }\n }\n\n observer.onCompleted();\n }\n\n args.push(handler);\n func.apply(context, args);\n }).publishLast().refCount();\n };\n };\n\r\n /**\n * Converts a Node.js callback style function to an observable sequence. This must be in function (err, ...) format.\n * @param {Function} func The function to call\n * @param {Mixed} [context] The context for the func parameter to be executed. If not specified, defaults to undefined.\n * @param {Function} [selector] A selector which takes the arguments from the callback minus the error to produce a single item to yield on next.\n * @returns {Function} An async function which when applied, returns an observable sequence with the callback arguments as an array.\n */\n Observable.fromNodeCallback = function (func, context, selector) {\n return function () {\n var len = arguments.length, args = new Array(len);\n for(var i = 0; i < len; i++) { args[i] = arguments[i]; }\n\n return new AnonymousObservable(function (observer) {\n function handler(err) {\n if (err) {\n observer.onError(err);\n return;\n }\n\n var len = arguments.length, results = [];\n for(var i = 1; i < len; i++) { results[i - 1] = arguments[i]; }\n\n if (selector) {\n try {\n results = selector.apply(context, results);\n } catch (e) {\n return observer.onError(e);\n }\n observer.onNext(results);\n } else {\n if (results.length <= 1) {\n observer.onNext.apply(observer, results);\n } else {\n observer.onNext(results);\n }\n }\n\n observer.onCompleted();\n }\n\n args.push(handler);\n func.apply(context, args);\n }).publishLast().refCount();\n };\n };\n\r\n function createListener (element, name, handler) {\n if (element.addEventListener) {\n element.addEventListener(name, handler, false);\n return disposableCreate(function () {\n element.removeEventListener(name, handler, false);\n });\n }\n throw new Error('No listener found');\n }\n\n function createEventListener (el, eventName, handler) {\n var disposables = new CompositeDisposable();\n\n // Asume NodeList or HTMLCollection\n var toStr = Object.prototype.toString;\n if (toStr.call(el) === '[object NodeList]' || toStr.call(el) === '[object HTMLCollection]') {\n for (var i = 0, len = el.length; i < len; i++) {\n disposables.add(createEventListener(el.item(i), eventName, handler));\n }\n } else if (el) {\n disposables.add(createListener(el, eventName, handler));\n }\n\n return disposables;\n }\n\n /**\n * Configuration option to determine whether to use native events only\n */\n Rx.config.useNativeEvents = false;\n\n /**\n * Creates an observable sequence by adding an event listener to the matching DOMElement or each item in the NodeList.\n *\n * @example\n * var source = Rx.Observable.fromEvent(element, 'mouseup');\n *\n * @param {Object} element The DOMElement or NodeList to attach a listener.\n * @param {String} eventName The event name to attach the observable sequence.\n * @param {Function} [selector] A selector which takes the arguments from the event handler to produce a single item to yield on next.\n * @returns {Observable} An observable sequence of events from the specified element and the specified event.\n */\n Observable.fromEvent = function (element, eventName, selector) {\n // Node.js specific\n if (element.addListener) {\n return fromEventPattern(\n function (h) { element.addListener(eventName, h); },\n function (h) { element.removeListener(eventName, h); },\n selector);\n }\n\n // Use only if non-native events are allowed\n if (!Rx.config.useNativeEvents) {\n // Handles jq, Angular.js, Zepto, Marionette, Ember.js\n if (typeof element.on === 'function' && typeof element.off === 'function') {\n return fromEventPattern(\n function (h) { element.on(eventName, h); },\n function (h) { element.off(eventName, h); },\n selector);\n }\n }\n return new AnonymousObservable(function (observer) {\n return createEventListener(\n element,\n eventName,\n function handler (e) {\n var results = e;\n\n if (selector) {\n try {\n results = selector(arguments);\n } catch (err) {\n return observer.onError(err);\n }\n }\n\n observer.onNext(results);\n });\n }).publish().refCount();\n };\n\r\n /**\n * Creates an observable sequence from an event emitter via an addHandler/removeHandler pair.\n * @param {Function} addHandler The function to add a handler to the emitter.\n * @param {Function} [removeHandler] The optional function to remove a handler from an emitter.\n * @param {Function} [selector] A selector which takes the arguments from the event handler to produce a single item to yield on next.\n * @returns {Observable} An observable sequence which wraps an event from an event emitter\n */\n var fromEventPattern = Observable.fromEventPattern = function (addHandler, removeHandler, selector) {\n return new AnonymousObservable(function (observer) {\n function innerHandler (e) {\n var result = e;\n if (selector) {\n try {\n result = selector(arguments);\n } catch (err) {\n return observer.onError(err);\n }\n }\n observer.onNext(result);\n }\n\n var returnValue = addHandler(innerHandler);\n return disposableCreate(function () {\n if (removeHandler) {\n removeHandler(innerHandler, returnValue);\n }\n });\n }).publish().refCount();\n };\n\r\n /**\n * Invokes the asynchronous function, surfacing the result through an observable sequence.\n * @param {Function} functionAsync Asynchronous function which returns a Promise to run.\n * @returns {Observable} An observable sequence exposing the function's result value, or an exception.\n */\n Observable.startAsync = function (functionAsync) {\n var promise;\n try {\n promise = functionAsync();\n } catch (e) {\n return observableThrow(e);\n }\n return observableFromPromise(promise);\n }\n\r\n var PausableObservable = (function (__super__) {\n\n inherits(PausableObservable, __super__);\n\n function subscribe(observer) {\n var conn = this.source.publish(),\n subscription = conn.subscribe(observer),\n connection = disposableEmpty;\n\n var pausable = this.pauser.distinctUntilChanged().subscribe(function (b) {\n if (b) {\n connection = conn.connect();\n } else {\n connection.dispose();\n connection = disposableEmpty;\n }\n });\n\n return new CompositeDisposable(subscription, connection, pausable);\n }\n\n function PausableObservable(source, pauser) {\n this.source = source;\n this.controller = new Subject();\n\n if (pauser && pauser.subscribe) {\n this.pauser = this.controller.merge(pauser);\n } else {\n this.pauser = this.controller;\n }\n\n __super__.call(this, subscribe, source);\n }\n\n PausableObservable.prototype.pause = function () {\n this.controller.onNext(false);\n };\n\n PausableObservable.prototype.resume = function () {\n this.controller.onNext(true);\n };\n\n return PausableObservable;\n\n }(Observable));\n\n /**\n * Pauses the underlying observable sequence based upon the observable sequence which yields true/false.\n * @example\n * var pauser = new Rx.Subject();\n * var source = Rx.Observable.interval(100).pausable(pauser);\n * @param {Observable} pauser The observable sequence used to pause the underlying sequence.\n * @returns {Observable} The observable sequence which is paused based upon the pauser.\n */\n observableProto.pausable = function (pauser) {\n return new PausableObservable(this, pauser);\n };\n\r\n function combineLatestSource(source, subject, resultSelector) {\n return new AnonymousObservable(function (o) {\n var hasValue = [false, false],\n hasValueAll = false,\n isDone = false,\n values = new Array(2),\n err;\n\n function next(x, i) {\n values[i] = x\n hasValue[i] = true;\n if (hasValueAll || (hasValueAll = hasValue.every(identity))) {\n if (err) { return o.onError(err); }\n var res = tryCatch(resultSelector).apply(null, values);\n if (res === errorObj) { return o.onError(res.e); }\n o.onNext(res);\n }\n isDone && values[1] && o.onCompleted();\n }\n\n return new CompositeDisposable(\n source.subscribe(\n function (x) {\n next(x, 0);\n },\n function (e) {\n if (values[1]) {\n o.onError(e);\n } else {\n err = e;\n }\n },\n function () {\n isDone = true;\n values[1] && o.onCompleted();\n }),\n subject.subscribe(\n function (x) {\n next(x, 1);\n },\n function (e) { o.onError(e); },\n function () {\n isDone = true;\n next(true, 1);\n })\n );\n }, source);\n }\n\n var PausableBufferedObservable = (function (__super__) {\n\n inherits(PausableBufferedObservable, __super__);\n\n function subscribe(o) {\n var q = [], previousShouldFire;\n\n function drainQueue() { while (q.length > 0) { o.onNext(q.shift()); } }\n\n var subscription =\n combineLatestSource(\n this.source,\n this.pauser.distinctUntilChanged().startWith(false),\n function (data, shouldFire) {\n return { data: data, shouldFire: shouldFire };\n })\n .subscribe(\n function (results) {\n if (previousShouldFire !== undefined && results.shouldFire != previousShouldFire) {\n previousShouldFire = results.shouldFire;\n // change in shouldFire\n if (results.shouldFire) { drainQueue(); }\n } else {\n previousShouldFire = results.shouldFire;\n // new data\n if (results.shouldFire) {\n o.onNext(results.data);\n } else {\n q.push(results.data);\n }\n }\n },\n function (err) {\n drainQueue();\n o.onError(err);\n },\n function () {\n drainQueue();\n o.onCompleted();\n }\n );\n return subscription;\n }\n\n function PausableBufferedObservable(source, pauser) {\n this.source = source;\n this.controller = new Subject();\n\n if (pauser && pauser.subscribe) {\n this.pauser = this.controller.merge(pauser);\n } else {\n this.pauser = this.controller;\n }\n\n __super__.call(this, subscribe, source);\n }\n\n PausableBufferedObservable.prototype.pause = function () {\n this.controller.onNext(false);\n };\n\n PausableBufferedObservable.prototype.resume = function () {\n this.controller.onNext(true);\n };\n\n return PausableBufferedObservable;\n\n }(Observable));\n\n /**\n * Pauses the underlying observable sequence based upon the observable sequence which yields true/false,\n * and yields the values that were buffered while paused.\n * @example\n * var pauser = new Rx.Subject();\n * var source = Rx.Observable.interval(100).pausableBuffered(pauser);\n * @param {Observable} pauser The observable sequence used to pause the underlying sequence.\n * @returns {Observable} The observable sequence which is paused based upon the pauser.\n */\n observableProto.pausableBuffered = function (subject) {\n return new PausableBufferedObservable(this, subject);\n };\n\r\n var ControlledObservable = (function (__super__) {\n\n inherits(ControlledObservable, __super__);\n\n function subscribe (observer) {\n return this.source.subscribe(observer);\n }\n\n function ControlledObservable (source, enableQueue, scheduler) {\n __super__.call(this, subscribe, source);\n this.subject = new ControlledSubject(enableQueue, scheduler);\n this.source = source.multicast(this.subject).refCount();\n }\n\n ControlledObservable.prototype.request = function (numberOfItems) {\n return this.subject.request(numberOfItems == null ? -1 : numberOfItems);\n };\n\n return ControlledObservable;\n\n }(Observable));\n\n var ControlledSubject = (function (__super__) {\n\n function subscribe (observer) {\n return this.subject.subscribe(observer);\n }\n\n inherits(ControlledSubject, __super__);\n\n function ControlledSubject(enableQueue, scheduler) {\n enableQueue == null && (enableQueue = true);\n\n __super__.call(this, subscribe);\n this.subject = new Subject();\n this.enableQueue = enableQueue;\n this.queue = enableQueue ? [] : null;\n this.requestedCount = 0;\n this.requestedDisposable = disposableEmpty;\n this.error = null;\n this.hasFailed = false;\n this.hasCompleted = false;\n this.scheduler = scheduler || currentThreadScheduler;\n }\n\n addProperties(ControlledSubject.prototype, Observer, {\n onCompleted: function () {\n this.hasCompleted = true;\n if (!this.enableQueue || this.queue.length === 0) {\n this.subject.onCompleted();\n } else {\n this.queue.push(Notification.createOnCompleted());\n }\n },\n onError: function (error) {\n this.hasFailed = true;\n this.error = error;\n if (!this.enableQueue || this.queue.length === 0) {\n this.subject.onError(error);\n } else {\n this.queue.push(Notification.createOnError(error));\n }\n },\n onNext: function (value) {\n var hasRequested = false;\n\n if (this.requestedCount === 0) {\n this.enableQueue && this.queue.push(Notification.createOnNext(value));\n } else {\n (this.requestedCount !== -1 && this.requestedCount-- === 0) && this.disposeCurrentRequest();\n hasRequested = true;\n }\n hasRequested && this.subject.onNext(value);\n },\n _processRequest: function (numberOfItems) {\n if (this.enableQueue) {\n while ((this.queue.length >= numberOfItems && numberOfItems > 0) ||\n (this.queue.length > 0 && this.queue[0].kind !== 'N')) {\n var first = this.queue.shift();\n first.accept(this.subject);\n if (first.kind === 'N') {\n numberOfItems--;\n } else {\n this.disposeCurrentRequest();\n this.queue = [];\n }\n }\n\n return { numberOfItems : numberOfItems, returnValue: this.queue.length !== 0};\n }\n\n return { numberOfItems: numberOfItems, returnValue: false };\n },\n request: function (number) {\n this.disposeCurrentRequest();\n var self = this;\n\n this.requestedDisposable = this.scheduler.scheduleWithState(number,\n function(s, i) {\n var r = self._processRequest(i), remaining = r.numberOfItems;\n if (!r.returnValue) {\n self.requestedCount = remaining;\n self.requestedDisposable = disposableCreate(function () {\n self.requestedCount = 0;\n });\n }\n });\n\n return this.requestedDisposable;\n },\n disposeCurrentRequest: function () {\n this.requestedDisposable.dispose();\n this.requestedDisposable = disposableEmpty;\n }\n });\n\n return ControlledSubject;\n }(Observable));\n\n /**\n * Attaches a controller to the observable sequence with the ability to queue.\n * @example\n * var source = Rx.Observable.interval(100).controlled();\n * source.request(3); // Reads 3 values\n * @param {bool} enableQueue truthy value to determine if values should be queued pending the next request\n * @param {Scheduler} scheduler determines how the requests will be scheduled\n * @returns {Observable} The observable sequence which only propagates values on request.\n */\n observableProto.controlled = function (enableQueue, scheduler) {\n\n if (enableQueue && isScheduler(enableQueue)) {\n scheduler = enableQueue;\n enableQueue = true;\n }\n\n if (enableQueue == null) { enableQueue = true; }\n return new ControlledObservable(this, enableQueue, scheduler);\n };\n\r\n var StopAndWaitObservable = (function (__super__) {\n\n function subscribe (observer) {\n this.subscription = this.source.subscribe(new StopAndWaitObserver(observer, this, this.subscription));\n\n var self = this;\n timeoutScheduler.schedule(function () { self.source.request(1); });\n\n return this.subscription;\n }\n\n inherits(StopAndWaitObservable, __super__);\n\n function StopAndWaitObservable (source) {\n __super__.call(this, subscribe, source);\n this.source = source;\n }\n\n var StopAndWaitObserver = (function (__sub__) {\n\n inherits(StopAndWaitObserver, __sub__);\n\n function StopAndWaitObserver (observer, observable, cancel) {\n __sub__.call(this);\n this.observer = observer;\n this.observable = observable;\n this.cancel = cancel;\n }\n\n var stopAndWaitObserverProto = StopAndWaitObserver.prototype;\n\n stopAndWaitObserverProto.completed = function () {\n this.observer.onCompleted();\n this.dispose();\n };\n\n stopAndWaitObserverProto.error = function (error) {\n this.observer.onError(error);\n this.dispose();\n }\n\n stopAndWaitObserverProto.next = function (value) {\n this.observer.onNext(value);\n\n var self = this;\n timeoutScheduler.schedule(function () {\n self.observable.source.request(1);\n });\n };\n\n stopAndWaitObserverProto.dispose = function () {\n this.observer = null;\n if (this.cancel) {\n this.cancel.dispose();\n this.cancel = null;\n }\n __sub__.prototype.dispose.call(this);\n };\n\n return StopAndWaitObserver;\n }(AbstractObserver));\n\n return StopAndWaitObservable;\n }(Observable));\n\n\n /**\n * Attaches a stop and wait observable to the current observable.\n * @returns {Observable} A stop and wait observable.\n */\n ControlledObservable.prototype.stopAndWait = function () {\n return new StopAndWaitObservable(this);\n };\n\r\n var WindowedObservable = (function (__super__) {\n\n function subscribe (observer) {\n this.subscription = this.source.subscribe(new WindowedObserver(observer, this, this.subscription));\n\n var self = this;\n timeoutScheduler.schedule(function () {\n self.source.request(self.windowSize);\n });\n\n return this.subscription;\n }\n\n inherits(WindowedObservable, __super__);\n\n function WindowedObservable(source, windowSize) {\n __super__.call(this, subscribe, source);\n this.source = source;\n this.windowSize = windowSize;\n }\n\n var WindowedObserver = (function (__sub__) {\n\n inherits(WindowedObserver, __sub__);\n\n function WindowedObserver(observer, observable, cancel) {\n this.observer = observer;\n this.observable = observable;\n this.cancel = cancel;\n this.received = 0;\n }\n\n var windowedObserverPrototype = WindowedObserver.prototype;\n\n windowedObserverPrototype.completed = function () {\n this.observer.onCompleted();\n this.dispose();\n };\n\n windowedObserverPrototype.error = function (error) {\n this.observer.onError(error);\n this.dispose();\n };\n\n windowedObserverPrototype.next = function (value) {\n this.observer.onNext(value);\n\n this.received = ++this.received % this.observable.windowSize;\n if (this.received === 0) {\n var self = this;\n timeoutScheduler.schedule(function () {\n self.observable.source.request(self.observable.windowSize);\n });\n }\n };\n\n windowedObserverPrototype.dispose = function () {\n this.observer = null;\n if (this.cancel) {\n this.cancel.dispose();\n this.cancel = null;\n }\n __sub__.prototype.dispose.call(this);\n };\n\n return WindowedObserver;\n }(AbstractObserver));\n\n return WindowedObservable;\n }(Observable));\n\n /**\n * Creates a sliding windowed observable based upon the window size.\n * @param {Number} windowSize The number of items in the window\n * @returns {Observable} A windowed observable based upon the window size.\n */\n ControlledObservable.prototype.windowed = function (windowSize) {\n return new WindowedObservable(this, windowSize);\n };\n\r\n /**\n * Pipes the existing Observable sequence into a Node.js Stream.\n * @param {Stream} dest The destination Node.js stream.\n * @returns {Stream} The destination stream.\n */\n observableProto.pipe = function (dest) {\n var source = this.pausableBuffered();\n\n function onDrain() {\n source.resume();\n }\n\n dest.addListener('drain', onDrain);\n\n source.subscribe(\n function (x) {\n !dest.write(String(x)) && source.pause();\n },\n function (err) {\n dest.emit('error', err);\n },\n function () {\n // Hack check because STDIO is not closable\n !dest._isStdio && dest.end();\n dest.removeListener('drain', onDrain);\n });\n\n source.resume();\n\n return dest;\n };\n\r\n /**\n * Multicasts the source sequence notifications through an instantiated subject into all uses of the sequence within a selector function. Each\n * subscription to the resulting sequence causes a separate multicast invocation, exposing the sequence resulting from the selector function's\n * invocation. For specializations with fixed subject types, see Publish, PublishLast, and Replay.\n *\n * @example\n * 1 - res = source.multicast(observable);\n * 2 - res = source.multicast(function () { return new Subject(); }, function (x) { return x; });\n *\n * @param {Function|Subject} subjectOrSubjectSelector\n * Factory function to create an intermediate subject through which the source sequence's elements will be multicast to the selector function.\n * Or:\n * Subject to push source elements into.\n *\n * @param {Function} [selector] Optional selector function which can use the multicasted source sequence subject to the policies enforced by the created subject. Specified only if <paramref name=\"subjectOrSubjectSelector\" is a factory function.\n * @returns {Observable} An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.\n */\n observableProto.multicast = function (subjectOrSubjectSelector, selector) {\n var source = this;\n return typeof subjectOrSubjectSelector === 'function' ?\n new AnonymousObservable(function (observer) {\n var connectable = source.multicast(subjectOrSubjectSelector());\n return new CompositeDisposable(selector(connectable).subscribe(observer), connectable.connect());\n }, source) :\n new ConnectableObservable(source, subjectOrSubjectSelector);\n };\n\r\n /**\n * Returns an observable sequence that is the result of invoking the selector on a connectable observable sequence that shares a single subscription to the underlying sequence.\n * This operator is a specialization of Multicast using a regular Subject.\n *\n * @example\n * var resres = source.publish();\n * var res = source.publish(function (x) { return x; });\n *\n * @param {Function} [selector] Selector function which can use the multicasted source sequence as many times as needed, without causing multiple subscriptions to the source sequence. Subscribers to the given source will receive all notifications of the source from the time of the subscription on.\n * @returns {Observable} An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.\n */\n observableProto.publish = function (selector) {\n return selector && isFunction(selector) ?\n this.multicast(function () { return new Subject(); }, selector) :\n this.multicast(new Subject());\n };\n\r\n /**\n * Returns an observable sequence that shares a single subscription to the underlying sequence.\n * This operator is a specialization of publish which creates a subscription when the number of observers goes from zero to one, then shares that subscription with all subsequent observers until the number of observers returns to zero, at which point the subscription is disposed.\n * @returns {Observable} An observable sequence that contains the elements of a sequence produced by multicasting the source sequence.\n */\n observableProto.share = function () {\n return this.publish().refCount();\n };\n\r\n /**\n * Returns an observable sequence that is the result of invoking the selector on a connectable observable sequence that shares a single subscription to the underlying sequence containing only the last notification.\n * This operator is a specialization of Multicast using a AsyncSubject.\n *\n * @example\n * var res = source.publishLast();\n * var res = source.publishLast(function (x) { return x; });\n *\n * @param selector [Optional] Selector function which can use the multicasted source sequence as many times as needed, without causing multiple subscriptions to the source sequence. Subscribers to the given source will only receive the last notification of the source.\n * @returns {Observable} An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.\n */\n observableProto.publishLast = function (selector) {\n return selector && isFunction(selector) ?\n this.multicast(function () { return new AsyncSubject(); }, selector) :\n this.multicast(new AsyncSubject());\n };\n\r\n /**\n * Returns an observable sequence that is the result of invoking the selector on a connectable observable sequence that shares a single subscription to the underlying sequence and starts with initialValue.\n * This operator is a specialization of Multicast using a BehaviorSubject.\n *\n * @example\n * var res = source.publishValue(42);\n * var res = source.publishValue(function (x) { return x.select(function (y) { return y * y; }) }, 42);\n *\n * @param {Function} [selector] Optional selector function which can use the multicasted source sequence as many times as needed, without causing multiple subscriptions to the source sequence. Subscribers to the given source will receive immediately receive the initial value, followed by all notifications of the source from the time of the subscription on.\n * @param {Mixed} initialValue Initial value received by observers upon subscription.\n * @returns {Observable} An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.\n */\n observableProto.publishValue = function (initialValueOrSelector, initialValue) {\n return arguments.length === 2 ?\n this.multicast(function () {\n return new BehaviorSubject(initialValue);\n }, initialValueOrSelector) :\n this.multicast(new BehaviorSubject(initialValueOrSelector));\n };\n\r\n /**\n * Returns an observable sequence that shares a single subscription to the underlying sequence and starts with an initialValue.\n * This operator is a specialization of publishValue which creates a subscription when the number of observers goes from zero to one, then shares that subscription with all subsequent observers until the number of observers returns to zero, at which point the subscription is disposed.\n * @param {Mixed} initialValue Initial value received by observers upon subscription.\n * @returns {Observable} An observable sequence that contains the elements of a sequence produced by multicasting the source sequence.\n */\n observableProto.shareValue = function (initialValue) {\n return this.publishValue(initialValue).refCount();\n };\n\r\n /**\n * Returns an observable sequence that is the result of invoking the selector on a connectable observable sequence that shares a single subscription to the underlying sequence replaying notifications subject to a maximum time length for the replay buffer.\n * This operator is a specialization of Multicast using a ReplaySubject.\n *\n * @example\n * var res = source.replay(null, 3);\n * var res = source.replay(null, 3, 500);\n * var res = source.replay(null, 3, 500, scheduler);\n * var res = source.replay(function (x) { return x.take(6).repeat(); }, 3, 500, scheduler);\n *\n * @param selector [Optional] Selector function which can use the multicasted source sequence as many times as needed, without causing multiple subscriptions to the source sequence. Subscribers to the given source will receive all the notifications of the source subject to the specified replay buffer trimming policy.\n * @param bufferSize [Optional] Maximum element count of the replay buffer.\n * @param windowSize [Optional] Maximum time length of the replay buffer.\n * @param scheduler [Optional] Scheduler where connected observers within the selector function will be invoked on.\n * @returns {Observable} An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.\n */\n observableProto.replay = function (selector, bufferSize, windowSize, scheduler) {\n return selector && isFunction(selector) ?\n this.multicast(function () { return new ReplaySubject(bufferSize, windowSize, scheduler); }, selector) :\n this.multicast(new ReplaySubject(bufferSize, windowSize, scheduler));\n };\n\r\n /**\n * Returns an observable sequence that shares a single subscription to the underlying sequence replaying notifications subject to a maximum time length for the replay buffer.\n * This operator is a specialization of replay which creates a subscription when the number of observers goes from zero to one, then shares that subscription with all subsequent observers until the number of observers returns to zero, at which point the subscription is disposed.\n *\n * @example\n * var res = source.shareReplay(3);\n * var res = source.shareReplay(3, 500);\n * var res = source.shareReplay(3, 500, scheduler);\n *\n\n * @param bufferSize [Optional] Maximum element count of the replay buffer.\n * @param window [Optional] Maximum time length of the replay buffer.\n * @param scheduler [Optional] Scheduler where connected observers within the selector function will be invoked on.\n * @returns {Observable} An observable sequence that contains the elements of a sequence produced by multicasting the source sequence.\n */\n observableProto.shareReplay = function (bufferSize, windowSize, scheduler) {\n return this.replay(null, bufferSize, windowSize, scheduler).refCount();\n };\n\r\n var InnerSubscription = function (subject, observer) {\n this.subject = subject;\n this.observer = observer;\n };\n\n InnerSubscription.prototype.dispose = function () {\n if (!this.subject.isDisposed && this.observer !== null) {\n var idx = this.subject.observers.indexOf(this.observer);\n this.subject.observers.splice(idx, 1);\n this.observer = null;\n }\n };\n\r\n /**\n * Represents a value that changes over time.\n * Observers can subscribe to the subject to receive the last (or initial) value and all subsequent notifications.\n */\n var BehaviorSubject = Rx.BehaviorSubject = (function (__super__) {\n function subscribe(observer) {\n checkDisposed(this);\n if (!this.isStopped) {\n this.observers.push(observer);\n observer.onNext(this.value);\n return new InnerSubscription(this, observer);\n }\n if (this.hasError) {\n observer.onError(this.error);\n } else {\n observer.onCompleted();\n }\n return disposableEmpty;\n }\n\n inherits(BehaviorSubject, __super__);\n\n /**\n * Initializes a new instance of the BehaviorSubject class which creates a subject that caches its last value and starts with the specified value.\n * @param {Mixed} value Initial value sent to observers when no other value has been received by the subject yet.\n */\n function BehaviorSubject(value) {\n __super__.call(this, subscribe);\n this.value = value,\n this.observers = [],\n this.isDisposed = false,\n this.isStopped = false,\n this.hasError = false;\n }\n\n addProperties(BehaviorSubject.prototype, Observer, {\n /**\n * Gets the current value or throws an exception.\n * Value is frozen after onCompleted is called.\n * After onError is called always throws the specified exception.\n * An exception is always thrown after dispose is called.\n * @returns {Mixed} The initial value passed to the constructor until onNext is called; after which, the last value passed to onNext.\n */\n getValue: function () {\n checkDisposed(this);\n if (this.hasError) {\n throw this.error;\n }\n return this.value;\n },\n /**\n * Indicates whether the subject has observers subscribed to it.\n * @returns {Boolean} Indicates whether the subject has observers subscribed to it.\n */\n hasObservers: function () { return this.observers.length > 0; },\n /**\n * Notifies all subscribed observers about the end of the sequence.\n */\n onCompleted: function () {\n checkDisposed(this);\n if (this.isStopped) { return; }\n this.isStopped = true;\n for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) {\n os[i].onCompleted();\n }\n\n this.observers.length = 0;\n },\n /**\n * Notifies all subscribed observers about the exception.\n * @param {Mixed} error The exception to send to all observers.\n */\n onError: function (error) {\n checkDisposed(this);\n if (this.isStopped) { return; }\n this.isStopped = true;\n this.hasError = true;\n this.error = error;\n\n for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) {\n os[i].onError(error);\n }\n\n this.observers.length = 0;\n },\n /**\n * Notifies all subscribed observers about the arrival of the specified element in the sequence.\n * @param {Mixed} value The value to send to all observers.\n */\n onNext: function (value) {\n checkDisposed(this);\n if (this.isStopped) { return; }\n this.value = value;\n for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) {\n os[i].onNext(value);\n }\n },\n /**\n * Unsubscribe all observers and release resources.\n */\n dispose: function () {\n this.isDisposed = true;\n this.observers = null;\n this.value = null;\n this.exception = null;\n }\n });\n\n return BehaviorSubject;\n }(Observable));\n\r\n /**\n * Represents an object that is both an observable sequence as well as an observer.\n * Each notification is broadcasted to all subscribed and future observers, subject to buffer trimming policies.\n */\n var ReplaySubject = Rx.ReplaySubject = (function (__super__) {\n\n var maxSafeInteger = Math.pow(2, 53) - 1;\n\n function createRemovableDisposable(subject, observer) {\n return disposableCreate(function () {\n observer.dispose();\n !subject.isDisposed && subject.observers.splice(subject.observers.indexOf(observer), 1);\n });\n }\n\n function subscribe(observer) {\n var so = new ScheduledObserver(this.scheduler, observer),\n subscription = createRemovableDisposable(this, so);\n checkDisposed(this);\n this._trim(this.scheduler.now());\n this.observers.push(so);\n\n for (var i = 0, len = this.q.length; i < len; i++) {\n so.onNext(this.q[i].value);\n }\n\n if (this.hasError) {\n so.onError(this.error);\n } else if (this.isStopped) {\n so.onCompleted();\n }\n\n so.ensureActive();\n return subscription;\n }\n\n inherits(ReplaySubject, __super__);\n\n /**\n * Initializes a new instance of the ReplaySubject class with the specified buffer size, window size and scheduler.\n * @param {Number} [bufferSize] Maximum element count of the replay buffer.\n * @param {Number} [windowSize] Maximum time length of the replay buffer.\n * @param {Scheduler} [scheduler] Scheduler the observers are invoked on.\n */\n function ReplaySubject(bufferSize, windowSize, scheduler) {\n this.bufferSize = bufferSize == null ? maxSafeInteger : bufferSize;\n this.windowSize = windowSize == null ? maxSafeInteger : windowSize;\n this.scheduler = scheduler || currentThreadScheduler;\n this.q = [];\n this.observers = [];\n this.isStopped = false;\n this.isDisposed = false;\n this.hasError = false;\n this.error = null;\n __super__.call(this, subscribe);\n }\n\n addProperties(ReplaySubject.prototype, Observer.prototype, {\n /**\n * Indicates whether the subject has observers subscribed to it.\n * @returns {Boolean} Indicates whether the subject has observers subscribed to it.\n */\n hasObservers: function () {\n return this.observers.length > 0;\n },\n _trim: function (now) {\n while (this.q.length > this.bufferSize) {\n this.q.shift();\n }\n while (this.q.length > 0 && (now - this.q[0].interval) > this.windowSize) {\n this.q.shift();\n }\n },\n /**\n * Notifies all subscribed observers about the arrival of the specified element in the sequence.\n * @param {Mixed} value The value to send to all observers.\n */\n onNext: function (value) {\n checkDisposed(this);\n if (this.isStopped) { return; }\n var now = this.scheduler.now();\n this.q.push({ interval: now, value: value });\n this._trim(now);\n\n for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) {\n var observer = os[i];\n observer.onNext(value);\n observer.ensureActive();\n }\n },\n /**\n * Notifies all subscribed observers about the exception.\n * @param {Mixed} error The exception to send to all observers.\n */\n onError: function (error) {\n checkDisposed(this);\n if (this.isStopped) { return; }\n this.isStopped = true;\n this.error = error;\n this.hasError = true;\n var now = this.scheduler.now();\n this._trim(now);\n for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) {\n var observer = os[i];\n observer.onError(error);\n observer.ensureActive();\n }\n this.observers.length = 0;\n },\n /**\n * Notifies all subscribed observers about the end of the sequence.\n */\n onCompleted: function () {\n checkDisposed(this);\n if (this.isStopped) { return; }\n this.isStopped = true;\n var now = this.scheduler.now();\n this._trim(now);\n for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) {\n var observer = os[i];\n observer.onCompleted();\n observer.ensureActive();\n }\n this.observers.length = 0;\n },\n /**\n * Unsubscribe all observers and release resources.\n */\n dispose: function () {\n this.isDisposed = true;\n this.observers = null;\n }\n });\n\n return ReplaySubject;\n }(Observable));\n\r\n var ConnectableObservable = Rx.ConnectableObservable = (function (__super__) {\n inherits(ConnectableObservable, __super__);\n\n function ConnectableObservable(source, subject) {\n var hasSubscription = false,\n subscription,\n sourceObservable = source.asObservable();\n\n this.connect = function () {\n if (!hasSubscription) {\n hasSubscription = true;\n subscription = new CompositeDisposable(sourceObservable.subscribe(subject), disposableCreate(function () {\n hasSubscription = false;\n }));\n }\n return subscription;\n };\n\n __super__.call(this, function (o) { return subject.subscribe(o); });\n }\n\n ConnectableObservable.prototype.refCount = function () {\n var connectableSubscription, count = 0, source = this;\n return new AnonymousObservable(function (observer) {\n var shouldConnect = ++count === 1,\n subscription = source.subscribe(observer);\n shouldConnect && (connectableSubscription = source.connect());\n return function () {\n subscription.dispose();\n --count === 0 && connectableSubscription.dispose();\n };\n });\n };\n\n return ConnectableObservable;\n }(Observable));\n\r\n /**\n * Returns an observable sequence that shares a single subscription to the underlying sequence. This observable sequence\n * can be resubscribed to, even if all prior subscriptions have ended. (unlike `.publish().refCount()`)\n * @returns {Observable} An observable sequence that contains the elements of a sequence produced by multicasting the source.\n */\n observableProto.singleInstance = function() {\n var source = this, hasObservable = false, observable;\n\n function getObservable() {\n if (!hasObservable) {\n hasObservable = true;\n observable = source.finally(function() { hasObservable = false; }).publish().refCount();\n }\n return observable;\n };\n\n return new AnonymousObservable(function(o) {\n return getObservable().subscribe(o);\n });\n };\n\r\n var Dictionary = (function () {\n\n var primes = [1, 3, 7, 13, 31, 61, 127, 251, 509, 1021, 2039, 4093, 8191, 16381, 32749, 65521, 131071, 262139, 524287, 1048573, 2097143, 4194301, 8388593, 16777213, 33554393, 67108859, 134217689, 268435399, 536870909, 1073741789, 2147483647],\n noSuchkey = \"no such key\",\n duplicatekey = \"duplicate key\";\n\n function isPrime(candidate) {\n if ((candidate & 1) === 0) { return candidate === 2; }\n var num1 = Math.sqrt(candidate),\n num2 = 3;\n while (num2 <= num1) {\n if (candidate % num2 === 0) { return false; }\n num2 += 2;\n }\n return true;\n }\n\n function getPrime(min) {\n var index, num, candidate;\n for (index = 0; index < primes.length; ++index) {\n num = primes[index];\n if (num >= min) { return num; }\n }\n candidate = min | 1;\n while (candidate < primes[primes.length - 1]) {\n if (isPrime(candidate)) { return candidate; }\n candidate += 2;\n }\n return min;\n }\n\n function stringHashFn(str) {\n var hash = 757602046;\n if (!str.length) { return hash; }\n for (var i = 0, len = str.length; i < len; i++) {\n var character = str.charCodeAt(i);\n hash = ((hash << 5) - hash) + character;\n hash = hash & hash;\n }\n return hash;\n }\n\n function numberHashFn(key) {\n var c2 = 0x27d4eb2d;\n key = (key ^ 61) ^ (key >>> 16);\n key = key + (key << 3);\n key = key ^ (key >>> 4);\n key = key * c2;\n key = key ^ (key >>> 15);\n return key;\n }\n\n var getHashCode = (function () {\n var uniqueIdCounter = 0;\n\n return function (obj) {\n if (obj == null) { throw new Error(noSuchkey); }\n\n // Check for built-ins before tacking on our own for any object\n if (typeof obj === 'string') { return stringHashFn(obj); }\n if (typeof obj === 'number') { return numberHashFn(obj); }\n if (typeof obj === 'boolean') { return obj === true ? 1 : 0; }\n if (obj instanceof Date) { return numberHashFn(obj.valueOf()); }\n if (obj instanceof RegExp) { return stringHashFn(obj.toString()); }\n if (typeof obj.valueOf === 'function') {\n // Hack check for valueOf\n var valueOf = obj.valueOf();\n if (typeof valueOf === 'number') { return numberHashFn(valueOf); }\n if (typeof valueOf === 'string') { return stringHashFn(valueOf); }\n }\n if (obj.hashCode) { return obj.hashCode(); }\n\n var id = 17 * uniqueIdCounter++;\n obj.hashCode = function () { return id; };\n return id;\n };\n }());\n\n function newEntry() {\n return { key: null, value: null, next: 0, hashCode: 0 };\n }\n\n function Dictionary(capacity, comparer) {\n if (capacity < 0) { throw new ArgumentOutOfRangeError(); }\n if (capacity > 0) { this._initialize(capacity); }\n\n this.comparer = comparer || defaultComparer;\n this.freeCount = 0;\n this.size = 0;\n this.freeList = -1;\n }\n\n var dictionaryProto = Dictionary.prototype;\n\n dictionaryProto._initialize = function (capacity) {\n var prime = getPrime(capacity), i;\n this.buckets = new Array(prime);\n this.entries = new Array(prime);\n for (i = 0; i < prime; i++) {\n this.buckets[i] = -1;\n this.entries[i] = newEntry();\n }\n this.freeList = -1;\n };\n\n dictionaryProto.add = function (key, value) {\n this._insert(key, value, true);\n };\n\n dictionaryProto._insert = function (key, value, add) {\n if (!this.buckets) { this._initialize(0); }\n var index3,\n num = getHashCode(key) & 2147483647,\n index1 = num % this.buckets.length;\n for (var index2 = this.buckets[index1]; index2 >= 0; index2 = this.entries[index2].next) {\n if (this.entries[index2].hashCode === num && this.comparer(this.entries[index2].key, key)) {\n if (add) { throw new Error(duplicatekey); }\n this.entries[index2].value = value;\n return;\n }\n }\n if (this.freeCount > 0) {\n index3 = this.freeList;\n this.freeList = this.entries[index3].next;\n --this.freeCount;\n } else {\n if (this.size === this.entries.length) {\n this._resize();\n index1 = num % this.buckets.length;\n }\n index3 = this.size;\n ++this.size;\n }\n this.entries[index3].hashCode = num;\n this.entries[index3].next = this.buckets[index1];\n this.entries[index3].key = key;\n this.entries[index3].value = value;\n this.buckets[index1] = index3;\n };\n\n dictionaryProto._resize = function () {\n var prime = getPrime(this.size * 2),\n numArray = new Array(prime);\n for (index = 0; index < numArray.length; ++index) { numArray[index] = -1; }\n var entryArray = new Array(prime);\n for (index = 0; index < this.size; ++index) { entryArray[index] = this.entries[index]; }\n for (var index = this.size; index < prime; ++index) { entryArray[index] = newEntry(); }\n for (var index1 = 0; index1 < this.size; ++index1) {\n var index2 = entryArray[index1].hashCode % prime;\n entryArray[index1].next = numArray[index2];\n numArray[index2] = index1;\n }\n this.buckets = numArray;\n this.entries = entryArray;\n };\n\n dictionaryProto.remove = function (key) {\n if (this.buckets) {\n var num = getHashCode(key) & 2147483647,\n index1 = num % this.buckets.length,\n index2 = -1;\n for (var index3 = this.buckets[index1]; index3 >= 0; index3 = this.entries[index3].next) {\n if (this.entries[index3].hashCode === num && this.comparer(this.entries[index3].key, key)) {\n if (index2 < 0) {\n this.buckets[index1] = this.entries[index3].next;\n } else {\n this.entries[index2].next = this.entries[index3].next;\n }\n this.entries[index3].hashCode = -1;\n this.entries[index3].next = this.freeList;\n this.entries[index3].key = null;\n this.entries[index3].value = null;\n this.freeList = index3;\n ++this.freeCount;\n return true;\n } else {\n index2 = index3;\n }\n }\n }\n return false;\n };\n\n dictionaryProto.clear = function () {\n var index, len;\n if (this.size <= 0) { return; }\n for (index = 0, len = this.buckets.length; index < len; ++index) {\n this.buckets[index] = -1;\n }\n for (index = 0; index < this.size; ++index) {\n this.entries[index] = newEntry();\n }\n this.freeList = -1;\n this.size = 0;\n };\n\n dictionaryProto._findEntry = function (key) {\n if (this.buckets) {\n var num = getHashCode(key) & 2147483647;\n for (var index = this.buckets[num % this.buckets.length]; index >= 0; index = this.entries[index].next) {\n if (this.entries[index].hashCode === num && this.comparer(this.entries[index].key, key)) {\n return index;\n }\n }\n }\n return -1;\n };\n\n dictionaryProto.count = function () {\n return this.size - this.freeCount;\n };\n\n dictionaryProto.tryGetValue = function (key) {\n var entry = this._findEntry(key);\n return entry >= 0 ?\n this.entries[entry].value :\n undefined;\n };\n\n dictionaryProto.getValues = function () {\n var index = 0, results = [];\n if (this.entries) {\n for (var index1 = 0; index1 < this.size; index1++) {\n if (this.entries[index1].hashCode >= 0) {\n results[index++] = this.entries[index1].value;\n }\n }\n }\n return results;\n };\n\n dictionaryProto.get = function (key) {\n var entry = this._findEntry(key);\n if (entry >= 0) { return this.entries[entry].value; }\n throw new Error(noSuchkey);\n };\n\n dictionaryProto.set = function (key, value) {\n this._insert(key, value, false);\n };\n\n dictionaryProto.containskey = function (key) {\n return this._findEntry(key) >= 0;\n };\n\n return Dictionary;\n }());\n\r\n /**\n * Correlates the elements of two sequences based on overlapping durations.\n *\n * @param {Observable} right The right observable sequence to join elements for.\n * @param {Function} leftDurationSelector A function to select the duration (expressed as an observable sequence) of each element of the left observable sequence, used to determine overlap.\n * @param {Function} rightDurationSelector A function to select the duration (expressed as an observable sequence) of each element of the right observable sequence, used to determine overlap.\n * @param {Function} resultSelector A function invoked to compute a result element for any two overlapping elements of the left and right observable sequences. The parameters passed to the function correspond with the elements from the left and right source sequences for which overlap occurs.\n * @returns {Observable} An observable sequence that contains result elements computed from source elements that have an overlapping duration.\n */\n observableProto.join = function (right, leftDurationSelector, rightDurationSelector, resultSelector) {\n var left = this;\n return new AnonymousObservable(function (observer) {\n var group = new CompositeDisposable();\n var leftDone = false, rightDone = false;\n var leftId = 0, rightId = 0;\n var leftMap = new Dictionary(), rightMap = new Dictionary();\n\n group.add(left.subscribe(\n function (value) {\n var id = leftId++;\n var md = new SingleAssignmentDisposable();\n\n leftMap.add(id, value);\n group.add(md);\n\n var expire = function () {\n leftMap.remove(id) && leftMap.count() === 0 && leftDone && observer.onCompleted();\n group.remove(md);\n };\n\n var duration;\n try {\n duration = leftDurationSelector(value);\n } catch (e) {\n observer.onError(e);\n return;\n }\n\n md.setDisposable(duration.take(1).subscribe(noop, observer.onError.bind(observer), expire));\n\n rightMap.getValues().forEach(function (v) {\n var result;\n try {\n result = resultSelector(value, v);\n } catch (exn) {\n observer.onError(exn);\n return;\n }\n\n observer.onNext(result);\n });\n },\n observer.onError.bind(observer),\n function () {\n leftDone = true;\n (rightDone || leftMap.count() === 0) && observer.onCompleted();\n })\n );\n\n group.add(right.subscribe(\n function (value) {\n var id = rightId++;\n var md = new SingleAssignmentDisposable();\n\n rightMap.add(id, value);\n group.add(md);\n\n var expire = function () {\n rightMap.remove(id) && rightMap.count() === 0 && rightDone && observer.onCompleted();\n group.remove(md);\n };\n\n var duration;\n try {\n duration = rightDurationSelector(value);\n } catch (e) {\n observer.onError(e);\n return;\n }\n\n md.setDisposable(duration.take(1).subscribe(noop, observer.onError.bind(observer), expire));\n\n leftMap.getValues().forEach(function (v) {\n var result;\n try {\n result = resultSelector(v, value);\n } catch (exn) {\n observer.onError(exn);\n return;\n }\n\n observer.onNext(result);\n });\n },\n observer.onError.bind(observer),\n function () {\n rightDone = true;\n (leftDone || rightMap.count() === 0) && observer.onCompleted();\n })\n );\n return group;\n }, left);\n };\n\r\n /**\n * Correlates the elements of two sequences based on overlapping durations, and groups the results.\n *\n * @param {Observable} right The right observable sequence to join elements for.\n * @param {Function} leftDurationSelector A function to select the duration (expressed as an observable sequence) of each element of the left observable sequence, used to determine overlap.\n * @param {Function} rightDurationSelector A function to select the duration (expressed as an observable sequence) of each element of the right observable sequence, used to determine overlap.\n * @param {Function} resultSelector A function invoked to compute a result element for any element of the left sequence with overlapping elements from the right observable sequence. The first parameter passed to the function is an element of the left sequence. The second parameter passed to the function is an observable sequence with elements from the right sequence that overlap with the left sequence's element.\n * @returns {Observable} An observable sequence that contains result elements computed from source elements that have an overlapping duration.\n */\n observableProto.groupJoin = function (right, leftDurationSelector, rightDurationSelector, resultSelector) {\n var left = this;\n return new AnonymousObservable(function (observer) {\n var group = new CompositeDisposable();\n var r = new RefCountDisposable(group);\n var leftMap = new Dictionary(), rightMap = new Dictionary();\n var leftId = 0, rightId = 0;\n\n function handleError(e) { return function (v) { v.onError(e); }; };\n\n group.add(left.subscribe(\n function (value) {\n var s = new Subject();\n var id = leftId++;\n leftMap.add(id, s);\n\n var result;\n try {\n result = resultSelector(value, addRef(s, r));\n } catch (e) {\n leftMap.getValues().forEach(handleError(e));\n observer.onError(e);\n return;\n }\n observer.onNext(result);\n\n rightMap.getValues().forEach(function (v) { s.onNext(v); });\n\n var md = new SingleAssignmentDisposable();\n group.add(md);\n\n var expire = function () {\n leftMap.remove(id) && s.onCompleted();\n group.remove(md);\n };\n\n var duration;\n try {\n duration = leftDurationSelector(value);\n } catch (e) {\n leftMap.getValues().forEach(handleError(e));\n observer.onError(e);\n return;\n }\n\n md.setDisposable(duration.take(1).subscribe(\n noop,\n function (e) {\n leftMap.getValues().forEach(handleError(e));\n observer.onError(e);\n },\n expire)\n );\n },\n function (e) {\n leftMap.getValues().forEach(handleError(e));\n observer.onError(e);\n },\n observer.onCompleted.bind(observer))\n );\n\n group.add(right.subscribe(\n function (value) {\n var id = rightId++;\n rightMap.add(id, value);\n\n var md = new SingleAssignmentDisposable();\n group.add(md);\n\n var expire = function () {\n rightMap.remove(id);\n group.remove(md);\n };\n\n var duration;\n try {\n duration = rightDurationSelector(value);\n } catch (e) {\n leftMap.getValues().forEach(handleError(e));\n observer.onError(e);\n return;\n }\n md.setDisposable(duration.take(1).subscribe(\n noop,\n function (e) {\n leftMap.getValues().forEach(handleError(e));\n observer.onError(e);\n },\n expire)\n );\n\n leftMap.getValues().forEach(function (v) { v.onNext(value); });\n },\n function (e) {\n leftMap.getValues().forEach(handleError(e));\n observer.onError(e);\n })\n );\n\n return r;\n }, left);\n };\n\r\n /**\n * Projects each element of an observable sequence into zero or more buffers.\n *\n * @param {Mixed} bufferOpeningsOrClosingSelector Observable sequence whose elements denote the creation of new windows, or, a function invoked to define the boundaries of the produced windows (a new window is started when the previous one is closed, resulting in non-overlapping windows).\n * @param {Function} [bufferClosingSelector] A function invoked to define the closing of each produced window. If a closing selector function is specified for the first parameter, this parameter is ignored.\n * @returns {Observable} An observable sequence of windows.\n */\n observableProto.buffer = function (bufferOpeningsOrClosingSelector, bufferClosingSelector) {\n return this.window.apply(this, arguments).selectMany(function (x) { return x.toArray(); });\n };\n\r\n /**\n * Projects each element of an observable sequence into zero or more windows.\n *\n * @param {Mixed} windowOpeningsOrClosingSelector Observable sequence whose elements denote the creation of new windows, or, a function invoked to define the boundaries of the produced windows (a new window is started when the previous one is closed, resulting in non-overlapping windows).\n * @param {Function} [windowClosingSelector] A function invoked to define the closing of each produced window. If a closing selector function is specified for the first parameter, this parameter is ignored.\n * @returns {Observable} An observable sequence of windows.\n */\n observableProto.window = function (windowOpeningsOrClosingSelector, windowClosingSelector) {\n if (arguments.length === 1 && typeof arguments[0] !== 'function') {\n return observableWindowWithBoundaries.call(this, windowOpeningsOrClosingSelector);\n }\n return typeof windowOpeningsOrClosingSelector === 'function' ?\n observableWindowWithClosingSelector.call(this, windowOpeningsOrClosingSelector) :\n observableWindowWithOpenings.call(this, windowOpeningsOrClosingSelector, windowClosingSelector);\n };\n\n function observableWindowWithOpenings(windowOpenings, windowClosingSelector) {\n return windowOpenings.groupJoin(this, windowClosingSelector, observableEmpty, function (_, win) {\n return win;\n });\n }\n\n function observableWindowWithBoundaries(windowBoundaries) {\n var source = this;\n return new AnonymousObservable(function (observer) {\n var win = new Subject(),\n d = new CompositeDisposable(),\n r = new RefCountDisposable(d);\n\n observer.onNext(addRef(win, r));\n\n d.add(source.subscribe(function (x) {\n win.onNext(x);\n }, function (err) {\n win.onError(err);\n observer.onError(err);\n }, function () {\n win.onCompleted();\n observer.onCompleted();\n }));\n\n isPromise(windowBoundaries) && (windowBoundaries = observableFromPromise(windowBoundaries));\n\n d.add(windowBoundaries.subscribe(function (w) {\n win.onCompleted();\n win = new Subject();\n observer.onNext(addRef(win, r));\n }, function (err) {\n win.onError(err);\n observer.onError(err);\n }, function () {\n win.onCompleted();\n observer.onCompleted();\n }));\n\n return r;\n }, source);\n }\n\n function observableWindowWithClosingSelector(windowClosingSelector) {\n var source = this;\n return new AnonymousObservable(function (observer) {\n var m = new SerialDisposable(),\n d = new CompositeDisposable(m),\n r = new RefCountDisposable(d),\n win = new Subject();\n observer.onNext(addRef(win, r));\n d.add(source.subscribe(function (x) {\n win.onNext(x);\n }, function (err) {\n win.onError(err);\n observer.onError(err);\n }, function () {\n win.onCompleted();\n observer.onCompleted();\n }));\n\n function createWindowClose () {\n var windowClose;\n try {\n windowClose = windowClosingSelector();\n } catch (e) {\n observer.onError(e);\n return;\n }\n\n isPromise(windowClose) && (windowClose = observableFromPromise(windowClose));\n\n var m1 = new SingleAssignmentDisposable();\n m.setDisposable(m1);\n m1.setDisposable(windowClose.take(1).subscribe(noop, function (err) {\n win.onError(err);\n observer.onError(err);\n }, function () {\n win.onCompleted();\n win = new Subject();\n observer.onNext(addRef(win, r));\n createWindowClose();\n }));\n }\n\n createWindowClose();\n return r;\n }, source);\n }\n\r\n /**\n * Returns a new observable that triggers on the second and subsequent triggerings of the input observable.\n * The Nth triggering of the input observable passes the arguments from the N-1th and Nth triggering as a pair.\n * The argument passed to the N-1th triggering is held in hidden internal state until the Nth triggering occurs.\n * @returns {Observable} An observable that triggers on successive pairs of observations from the input observable as an array.\n */\n observableProto.pairwise = function () {\n var source = this;\n return new AnonymousObservable(function (observer) {\n var previous, hasPrevious = false;\n return source.subscribe(\n function (x) {\n if (hasPrevious) {\n observer.onNext([previous, x]);\n } else {\n hasPrevious = true;\n }\n previous = x;\n },\n observer.onError.bind(observer),\n observer.onCompleted.bind(observer));\n }, source);\n };\n\r\n /**\n * Returns two observables which partition the observations of the source by the given function.\n * The first will trigger observations for those values for which the predicate returns true.\n * The second will trigger observations for those values where the predicate returns false.\n * The predicate is executed once for each subscribed observer.\n * Both also propagate all error observations arising from the source and each completes\n * when the source completes.\n * @param {Function} predicate\n * The function to determine which output Observable will trigger a particular observation.\n * @returns {Array}\n * An array of observables. The first triggers when the predicate returns true,\n * and the second triggers when the predicate returns false.\n */\n observableProto.partition = function(predicate, thisArg) {\n return [\n this.filter(predicate, thisArg),\n this.filter(function (x, i, o) { return !predicate.call(thisArg, x, i, o); })\n ];\n };\n\r\n var WhileEnumerable = (function(__super__) {\n inherits(WhileEnumerable, __super__);\n function WhileEnumerable(c, s) {\n this.c = c;\n this.s = s;\n }\n WhileEnumerable.prototype[$iterator$] = function () {\n var self = this;\n return {\n next: function () {\n return self.c() ?\n { done: false, value: self.s } :\n { done: true, value: void 0 };\n }\n };\n };\n return WhileEnumerable;\n }(Enumerable));\n \n function enumerableWhile(condition, source) {\n return new WhileEnumerable(condition, source);\n } \n\r\n /**\n * Returns an observable sequence that is the result of invoking the selector on the source sequence, without sharing subscriptions.\n * This operator allows for a fluent style of writing queries that use the same sequence multiple times.\n *\n * @param {Function} selector Selector function which can use the source sequence as many times as needed, without sharing subscriptions to the source sequence.\n * @returns {Observable} An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.\n */\n observableProto.letBind = observableProto['let'] = function (func) {\n return func(this);\n };\n\r\n /**\n * Determines whether an observable collection contains values. There is an alias for this method called 'ifThen' for browsers <IE9\n *\n * @example\n * 1 - res = Rx.Observable.if(condition, obs1);\n * 2 - res = Rx.Observable.if(condition, obs1, obs2);\n * 3 - res = Rx.Observable.if(condition, obs1, scheduler);\n * @param {Function} condition The condition which determines if the thenSource or elseSource will be run.\n * @param {Observable} thenSource The observable sequence or Promise that will be run if the condition function returns true.\n * @param {Observable} [elseSource] The observable sequence or Promise that will be run if the condition function returns false. If this is not provided, it defaults to Rx.Observabe.Empty with the specified scheduler.\n * @returns {Observable} An observable sequence which is either the thenSource or elseSource.\n */\n Observable['if'] = Observable.ifThen = function (condition, thenSource, elseSourceOrScheduler) {\n return observableDefer(function () {\n elseSourceOrScheduler || (elseSourceOrScheduler = observableEmpty());\n\n isPromise(thenSource) && (thenSource = observableFromPromise(thenSource));\n isPromise(elseSourceOrScheduler) && (elseSourceOrScheduler = observableFromPromise(elseSourceOrScheduler));\n\n // Assume a scheduler for empty only\n typeof elseSourceOrScheduler.now === 'function' && (elseSourceOrScheduler = observableEmpty(elseSourceOrScheduler));\n return condition() ? thenSource : elseSourceOrScheduler;\n });\n };\n\r\n /**\n * Concatenates the observable sequences obtained by running the specified result selector for each element in source.\n * There is an alias for this method called 'forIn' for browsers <IE9\n * @param {Array} sources An array of values to turn into an observable sequence.\n * @param {Function} resultSelector A function to apply to each item in the sources array to turn it into an observable sequence.\n * @returns {Observable} An observable sequence from the concatenated observable sequences.\n */\n Observable['for'] = Observable.forIn = function (sources, resultSelector, thisArg) {\n return enumerableOf(sources, resultSelector, thisArg).concat();\n };\n\r\n /**\n * Repeats source as long as condition holds emulating a while loop.\n * There is an alias for this method called 'whileDo' for browsers <IE9\n *\n * @param {Function} condition The condition which determines if the source will be repeated.\n * @param {Observable} source The observable sequence that will be run if the condition function returns true.\n * @returns {Observable} An observable sequence which is repeated as long as the condition holds.\n */\n var observableWhileDo = Observable['while'] = Observable.whileDo = function (condition, source) {\n isPromise(source) && (source = observableFromPromise(source));\n return enumerableWhile(condition, source).concat();\n };\n\r\n /**\n * Repeats source as long as condition holds emulating a do while loop.\n *\n * @param {Function} condition The condition which determines if the source will be repeated.\n * @param {Observable} source The observable sequence that will be run if the condition function returns true.\n * @returns {Observable} An observable sequence which is repeated as long as the condition holds.\n */\n observableProto.doWhile = function (condition) {\n return observableConcat([this, observableWhileDo(condition, this)]);\n };\n\r\n /**\n * Uses selector to determine which source in sources to use.\n * There is an alias 'switchCase' for browsers <IE9.\n *\n * @example\n * 1 - res = Rx.Observable.case(selector, { '1': obs1, '2': obs2 });\n * 1 - res = Rx.Observable.case(selector, { '1': obs1, '2': obs2 }, obs0);\n * 1 - res = Rx.Observable.case(selector, { '1': obs1, '2': obs2 }, scheduler);\n *\n * @param {Function} selector The function which extracts the value for to test in a case statement.\n * @param {Array} sources A object which has keys which correspond to the case statement labels.\n * @param {Observable} [elseSource] The observable sequence or Promise that will be run if the sources are not matched. If this is not provided, it defaults to Rx.Observabe.empty with the specified scheduler.\n *\n * @returns {Observable} An observable sequence which is determined by a case statement.\n */\n Observable['case'] = Observable.switchCase = function (selector, sources, defaultSourceOrScheduler) {\n return observableDefer(function () {\n isPromise(defaultSourceOrScheduler) && (defaultSourceOrScheduler = observableFromPromise(defaultSourceOrScheduler));\n defaultSourceOrScheduler || (defaultSourceOrScheduler = observableEmpty());\n\n typeof defaultSourceOrScheduler.now === 'function' && (defaultSourceOrScheduler = observableEmpty(defaultSourceOrScheduler));\n\n var result = sources[selector()];\n isPromise(result) && (result = observableFromPromise(result));\n\n return result || defaultSourceOrScheduler;\n });\n };\n\r\n /**\n * Expands an observable sequence by recursively invoking selector.\n *\n * @param {Function} selector Selector function to invoke for each produced element, resulting in another sequence to which the selector will be invoked recursively again.\n * @param {Scheduler} [scheduler] Scheduler on which to perform the expansion. If not provided, this defaults to the current thread scheduler.\n * @returns {Observable} An observable sequence containing all the elements produced by the recursive expansion.\n */\n observableProto.expand = function (selector, scheduler) {\n isScheduler(scheduler) || (scheduler = immediateScheduler);\n var source = this;\n return new AnonymousObservable(function (observer) {\n var q = [],\n m = new SerialDisposable(),\n d = new CompositeDisposable(m),\n activeCount = 0,\n isAcquired = false;\n\n var ensureActive = function () {\n var isOwner = false;\n if (q.length > 0) {\n isOwner = !isAcquired;\n isAcquired = true;\n }\n if (isOwner) {\n m.setDisposable(scheduler.scheduleRecursive(function (self) {\n var work;\n if (q.length > 0) {\n work = q.shift();\n } else {\n isAcquired = false;\n return;\n }\n var m1 = new SingleAssignmentDisposable();\n d.add(m1);\n m1.setDisposable(work.subscribe(function (x) {\n observer.onNext(x);\n var result = null;\n try {\n result = selector(x);\n } catch (e) {\n observer.onError(e);\n }\n q.push(result);\n activeCount++;\n ensureActive();\n }, observer.onError.bind(observer), function () {\n d.remove(m1);\n activeCount--;\n if (activeCount === 0) {\n observer.onCompleted();\n }\n }));\n self();\n }));\n }\n };\n\n q.push(source);\n activeCount++;\n ensureActive();\n return d;\n }, this);\n };\n\r\n /**\n * Runs all observable sequences in parallel and collect their last elements.\n *\n * @example\n * 1 - res = Rx.Observable.forkJoin([obs1, obs2]);\n * 1 - res = Rx.Observable.forkJoin(obs1, obs2, ...);\n * @returns {Observable} An observable sequence with an array collecting the last elements of all the input sequences.\n */\n Observable.forkJoin = function () {\n var allSources = [];\n if (Array.isArray(arguments[0])) {\n allSources = arguments[0];\n } else {\n for(var i = 0, len = arguments.length; i < len; i++) { allSources.push(arguments[i]); }\n }\n return new AnonymousObservable(function (subscriber) {\n var count = allSources.length;\n if (count === 0) {\n subscriber.onCompleted();\n return disposableEmpty;\n }\n var group = new CompositeDisposable(),\n finished = false,\n hasResults = new Array(count),\n hasCompleted = new Array(count),\n results = new Array(count);\n\n for (var idx = 0; idx < count; idx++) {\n (function (i) {\n var source = allSources[i];\n isPromise(source) && (source = observableFromPromise(source));\n group.add(\n source.subscribe(\n function (value) {\n if (!finished) {\n hasResults[i] = true;\n results[i] = value;\n }\n },\n function (e) {\n finished = true;\n subscriber.onError(e);\n group.dispose();\n },\n function () {\n if (!finished) {\n if (!hasResults[i]) {\n subscriber.onCompleted();\n return;\n }\n hasCompleted[i] = true;\n for (var ix = 0; ix < count; ix++) {\n if (!hasCompleted[ix]) { return; }\n }\n finished = true;\n subscriber.onNext(results);\n subscriber.onCompleted();\n }\n }));\n })(idx);\n }\n\n return group;\n });\n };\n\r\n /**\n * Runs two observable sequences in parallel and combines their last elemenets.\n *\n * @param {Observable} second Second observable sequence.\n * @param {Function} resultSelector Result selector function to invoke with the last elements of both sequences.\n * @returns {Observable} An observable sequence with the result of calling the selector function with the last elements of both input sequences.\n */\n observableProto.forkJoin = function (second, resultSelector) {\n var first = this;\n return new AnonymousObservable(function (observer) {\n var leftStopped = false, rightStopped = false,\n hasLeft = false, hasRight = false,\n lastLeft, lastRight,\n leftSubscription = new SingleAssignmentDisposable(), rightSubscription = new SingleAssignmentDisposable();\n\n isPromise(second) && (second = observableFromPromise(second));\n\n leftSubscription.setDisposable(\n first.subscribe(function (left) {\n hasLeft = true;\n lastLeft = left;\n }, function (err) {\n rightSubscription.dispose();\n observer.onError(err);\n }, function () {\n leftStopped = true;\n if (rightStopped) {\n if (!hasLeft) {\n observer.onCompleted();\n } else if (!hasRight) {\n observer.onCompleted();\n } else {\n var result;\n try {\n result = resultSelector(lastLeft, lastRight);\n } catch (e) {\n observer.onError(e);\n return;\n }\n observer.onNext(result);\n observer.onCompleted();\n }\n }\n })\n );\n\n rightSubscription.setDisposable(\n second.subscribe(function (right) {\n hasRight = true;\n lastRight = right;\n }, function (err) {\n leftSubscription.dispose();\n observer.onError(err);\n }, function () {\n rightStopped = true;\n if (leftStopped) {\n if (!hasLeft) {\n observer.onCompleted();\n } else if (!hasRight) {\n observer.onCompleted();\n } else {\n var result;\n try {\n result = resultSelector(lastLeft, lastRight);\n } catch (e) {\n observer.onError(e);\n return;\n }\n observer.onNext(result);\n observer.onCompleted();\n }\n }\n })\n );\n\n return new CompositeDisposable(leftSubscription, rightSubscription);\n }, first);\n };\n\r\n /**\n * Comonadic bind operator.\n * @param {Function} selector A transform function to apply to each element.\n * @param {Object} scheduler Scheduler used to execute the operation. If not specified, defaults to the ImmediateScheduler.\n * @returns {Observable} An observable sequence which results from the comonadic bind operation.\n */\n observableProto.manySelect = observableProto.extend = function (selector, scheduler) {\n isScheduler(scheduler) || (scheduler = immediateScheduler);\n var source = this;\n return observableDefer(function () {\n var chain;\n\n return source\n .map(function (x) {\n var curr = new ChainObservable(x);\n\n chain && chain.onNext(x);\n chain = curr;\n\n return curr;\n })\n .tap(\n noop,\n function (e) { chain && chain.onError(e); },\n function () { chain && chain.onCompleted(); }\n )\n .observeOn(scheduler)\n .map(selector);\n }, source);\n };\n\n var ChainObservable = (function (__super__) {\n\n function subscribe (observer) {\n var self = this, g = new CompositeDisposable();\n g.add(currentThreadScheduler.schedule(function () {\n observer.onNext(self.head);\n g.add(self.tail.mergeAll().subscribe(observer));\n }));\n\n return g;\n }\n\n inherits(ChainObservable, __super__);\n\n function ChainObservable(head) {\n __super__.call(this, subscribe);\n this.head = head;\n this.tail = new AsyncSubject();\n }\n\n addProperties(ChainObservable.prototype, Observer, {\n onCompleted: function () {\n this.onNext(Observable.empty());\n },\n onError: function (e) {\n this.onNext(Observable.throwError(e));\n },\n onNext: function (v) {\n this.tail.onNext(v);\n this.tail.onCompleted();\n }\n });\n\n return ChainObservable;\n\n }(Observable));\n\r\n /** @private */\n var Map = root.Map || (function () {\n\n function Map() {\n this._keys = [];\n this._values = [];\n }\n\n Map.prototype.get = function (key) {\n var i = this._keys.indexOf(key);\n return i !== -1 ? this._values[i] : undefined;\n };\n\n Map.prototype.set = function (key, value) {\n var i = this._keys.indexOf(key);\n i !== -1 && (this._values[i] = value);\n this._values[this._keys.push(key) - 1] = value;\n };\n\n Map.prototype.forEach = function (callback, thisArg) {\n for (var i = 0, len = this._keys.length; i < len; i++) {\n callback.call(thisArg, this._values[i], this._keys[i]);\n }\n };\n\n return Map;\n }());\n\r\n /**\n * @constructor\n * Represents a join pattern over observable sequences.\n */\n function Pattern(patterns) {\n this.patterns = patterns;\n }\n\n /**\n * Creates a pattern that matches the current plan matches and when the specified observable sequences has an available value.\n * @param other Observable sequence to match in addition to the current pattern.\n * @return {Pattern} Pattern object that matches when all observable sequences in the pattern have an available value.\n */\n Pattern.prototype.and = function (other) {\n return new Pattern(this.patterns.concat(other));\n };\n\n /**\n * Matches when all observable sequences in the pattern (specified using a chain of and operators) have an available value and projects the values.\n * @param {Function} selector Selector that will be invoked with available values from the source sequences, in the same order of the sequences in the pattern.\n * @return {Plan} Plan that produces the projected values, to be fed (with other plans) to the when operator.\n */\n Pattern.prototype.thenDo = function (selector) {\n return new Plan(this, selector);\n };\n\r\n function Plan(expression, selector) {\n this.expression = expression;\n this.selector = selector;\n }\n\n Plan.prototype.activate = function (externalSubscriptions, observer, deactivate) {\n var self = this;\n var joinObservers = [];\n for (var i = 0, len = this.expression.patterns.length; i < len; i++) {\n joinObservers.push(planCreateObserver(externalSubscriptions, this.expression.patterns[i], observer.onError.bind(observer)));\n }\n var activePlan = new ActivePlan(joinObservers, function () {\n var result;\n try {\n result = self.selector.apply(self, arguments);\n } catch (e) {\n observer.onError(e);\n return;\n }\n observer.onNext(result);\n }, function () {\n for (var j = 0, jlen = joinObservers.length; j < jlen; j++) {\n joinObservers[j].removeActivePlan(activePlan);\n }\n deactivate(activePlan);\n });\n for (i = 0, len = joinObservers.length; i < len; i++) {\n joinObservers[i].addActivePlan(activePlan);\n }\n return activePlan;\n };\n\n function planCreateObserver(externalSubscriptions, observable, onError) {\n var entry = externalSubscriptions.get(observable);\n if (!entry) {\n var observer = new JoinObserver(observable, onError);\n externalSubscriptions.set(observable, observer);\n return observer;\n }\n return entry;\n }\n\r\n function ActivePlan(joinObserverArray, onNext, onCompleted) {\n this.joinObserverArray = joinObserverArray;\n this.onNext = onNext;\n this.onCompleted = onCompleted;\n this.joinObservers = new Map();\n for (var i = 0, len = this.joinObserverArray.length; i < len; i++) {\n var joinObserver = this.joinObserverArray[i];\n this.joinObservers.set(joinObserver, joinObserver);\n }\n }\n\n ActivePlan.prototype.dequeue = function () {\n this.joinObservers.forEach(function (v) { v.queue.shift(); });\n };\n\n ActivePlan.prototype.match = function () {\n var i, len, hasValues = true;\n for (i = 0, len = this.joinObserverArray.length; i < len; i++) {\n if (this.joinObserverArray[i].queue.length === 0) {\n hasValues = false;\n break;\n }\n }\n if (hasValues) {\n var firstValues = [],\n isCompleted = false;\n for (i = 0, len = this.joinObserverArray.length; i < len; i++) {\n firstValues.push(this.joinObserverArray[i].queue[0]);\n this.joinObserverArray[i].queue[0].kind === 'C' && (isCompleted = true);\n }\n if (isCompleted) {\n this.onCompleted();\n } else {\n this.dequeue();\n var values = [];\n for (i = 0, len = firstValues.length; i < firstValues.length; i++) {\n values.push(firstValues[i].value);\n }\n this.onNext.apply(this, values);\n }\n }\n };\n\r\n var JoinObserver = (function (__super__) {\n inherits(JoinObserver, __super__);\n\n function JoinObserver(source, onError) {\n __super__.call(this);\n this.source = source;\n this.onError = onError;\n this.queue = [];\n this.activePlans = [];\n this.subscription = new SingleAssignmentDisposable();\n this.isDisposed = false;\n }\n\n var JoinObserverPrototype = JoinObserver.prototype;\n\n JoinObserverPrototype.next = function (notification) {\n if (!this.isDisposed) {\n if (notification.kind === 'E') {\n return this.onError(notification.exception);\n }\n this.queue.push(notification);\n var activePlans = this.activePlans.slice(0);\n for (var i = 0, len = activePlans.length; i < len; i++) {\n activePlans[i].match();\n }\n }\n };\n\n JoinObserverPrototype.error = noop;\n JoinObserverPrototype.completed = noop;\n\n JoinObserverPrototype.addActivePlan = function (activePlan) {\n this.activePlans.push(activePlan);\n };\n\n JoinObserverPrototype.subscribe = function () {\n this.subscription.setDisposable(this.source.materialize().subscribe(this));\n };\n\n JoinObserverPrototype.removeActivePlan = function (activePlan) {\n this.activePlans.splice(this.activePlans.indexOf(activePlan), 1);\n this.activePlans.length === 0 && this.dispose();\n };\n\n JoinObserverPrototype.dispose = function () {\n __super__.prototype.dispose.call(this);\n if (!this.isDisposed) {\n this.isDisposed = true;\n this.subscription.dispose();\n }\n };\n\n return JoinObserver;\n } (AbstractObserver));\n\r\n /**\n * Creates a pattern that matches when both observable sequences have an available value.\n *\n * @param right Observable sequence to match with the current sequence.\n * @return {Pattern} Pattern object that matches when both observable sequences have an available value.\n */\n observableProto.and = function (right) {\n return new Pattern([this, right]);\n };\n\r\n /**\n * Matches when the observable sequence has an available value and projects the value.\n *\n * @param {Function} selector Selector that will be invoked for values in the source sequence.\n * @returns {Plan} Plan that produces the projected values, to be fed (with other plans) to the when operator.\n */\n observableProto.thenDo = function (selector) {\n return new Pattern([this]).thenDo(selector);\n };\n\r\n /**\n * Joins together the results from several patterns.\n *\n * @param plans A series of plans (specified as an Array of as a series of arguments) created by use of the Then operator on patterns.\n * @returns {Observable} Observable sequence with the results form matching several patterns.\n */\n Observable.when = function () {\n var len = arguments.length, plans;\n if (Array.isArray(arguments[0])) {\n plans = arguments[0];\n } else {\n plans = new Array(len);\n for(var i = 0; i < len; i++) { plans[i] = arguments[i]; }\n }\n return new AnonymousObservable(function (o) {\n var activePlans = [],\n externalSubscriptions = new Map();\n var outObserver = observerCreate(\n function (x) { o.onNext(x); },\n function (err) {\n externalSubscriptions.forEach(function (v) { v.onError(err); });\n o.onError(err);\n },\n function (x) { o.onCompleted(); }\n );\n try {\n for (var i = 0, len = plans.length; i < len; i++) {\n activePlans.push(plans[i].activate(externalSubscriptions, outObserver, function (activePlan) {\n var idx = activePlans.indexOf(activePlan);\n activePlans.splice(idx, 1);\n activePlans.length === 0 && o.onCompleted();\n }));\n }\n } catch (e) {\n observableThrow(e).subscribe(o);\n }\n var group = new CompositeDisposable();\n externalSubscriptions.forEach(function (joinObserver) {\n joinObserver.subscribe();\n group.add(joinObserver);\n });\n\n return group;\n });\n };\n\r\n function observableTimerDate(dueTime, scheduler) {\n return new AnonymousObservable(function (observer) {\n return scheduler.scheduleWithAbsolute(dueTime, function () {\n observer.onNext(0);\n observer.onCompleted();\n });\n });\n }\n\r\n function observableTimerDateAndPeriod(dueTime, period, scheduler) {\n return new AnonymousObservable(function (observer) {\n var d = dueTime, p = normalizeTime(period);\n return scheduler.scheduleRecursiveWithAbsoluteAndState(0, d, function (count, self) {\n if (p > 0) {\n var now = scheduler.now();\n d = d + p;\n d <= now && (d = now + p);\n }\n observer.onNext(count);\n self(count + 1, d);\n });\n });\n }\n\r\n function observableTimerTimeSpan(dueTime, scheduler) {\n return new AnonymousObservable(function (observer) {\n return scheduler.scheduleWithRelative(normalizeTime(dueTime), function () {\n observer.onNext(0);\n observer.onCompleted();\n });\n });\n }\n\r\n function observableTimerTimeSpanAndPeriod(dueTime, period, scheduler) {\n return dueTime === period ?\n new AnonymousObservable(function (observer) {\n return scheduler.schedulePeriodicWithState(0, period, function (count) {\n observer.onNext(count);\n return count + 1;\n });\n }) :\n observableDefer(function () {\n return observableTimerDateAndPeriod(scheduler.now() + dueTime, period, scheduler);\n });\n }\n\r\n /**\n * Returns an observable sequence that produces a value after each period.\n *\n * @example\n * 1 - res = Rx.Observable.interval(1000);\n * 2 - res = Rx.Observable.interval(1000, Rx.Scheduler.timeout);\n *\n * @param {Number} period Period for producing the values in the resulting sequence (specified as an integer denoting milliseconds).\n * @param {Scheduler} [scheduler] Scheduler to run the timer on. If not specified, Rx.Scheduler.timeout is used.\n * @returns {Observable} An observable sequence that produces a value after each period.\n */\n var observableinterval = Observable.interval = function (period, scheduler) {\n return observableTimerTimeSpanAndPeriod(period, period, isScheduler(scheduler) ? scheduler : timeoutScheduler);\n };\n\r\n /**\n * Returns an observable sequence that produces a value after dueTime has elapsed and then after each period.\n * @param {Number} dueTime Absolute (specified as a Date object) or relative time (specified as an integer denoting milliseconds) at which to produce the first value.\n * @param {Mixed} [periodOrScheduler] Period to produce subsequent values (specified as an integer denoting milliseconds), or the scheduler to run the timer on. If not specified, the resulting timer is not recurring.\n * @param {Scheduler} [scheduler] Scheduler to run the timer on. If not specified, the timeout scheduler is used.\n * @returns {Observable} An observable sequence that produces a value after due time has elapsed and then each period.\n */\n var observableTimer = Observable.timer = function (dueTime, periodOrScheduler, scheduler) {\n var period;\n isScheduler(scheduler) || (scheduler = timeoutScheduler);\n if (periodOrScheduler !== undefined && typeof periodOrScheduler === 'number') {\n period = periodOrScheduler;\n } else if (isScheduler(periodOrScheduler)) {\n scheduler = periodOrScheduler;\n }\n if (dueTime instanceof Date && period === undefined) {\n return observableTimerDate(dueTime.getTime(), scheduler);\n }\n if (dueTime instanceof Date && period !== undefined) {\n period = periodOrScheduler;\n return observableTimerDateAndPeriod(dueTime.getTime(), period, scheduler);\n }\n return period === undefined ?\n observableTimerTimeSpan(dueTime, scheduler) :\n observableTimerTimeSpanAndPeriod(dueTime, period, scheduler);\n };\n\r\n function observableDelayTimeSpan(source, dueTime, scheduler) {\n return new AnonymousObservable(function (observer) {\n var active = false,\n cancelable = new SerialDisposable(),\n exception = null,\n q = [],\n running = false,\n subscription;\n subscription = source.materialize().timestamp(scheduler).subscribe(function (notification) {\n var d, shouldRun;\n if (notification.value.kind === 'E') {\n q = [];\n q.push(notification);\n exception = notification.value.exception;\n shouldRun = !running;\n } else {\n q.push({ value: notification.value, timestamp: notification.timestamp + dueTime });\n shouldRun = !active;\n active = true;\n }\n if (shouldRun) {\n if (exception !== null) {\n observer.onError(exception);\n } else {\n d = new SingleAssignmentDisposable();\n cancelable.setDisposable(d);\n d.setDisposable(scheduler.scheduleRecursiveWithRelative(dueTime, function (self) {\n var e, recurseDueTime, result, shouldRecurse;\n if (exception !== null) {\n return;\n }\n running = true;\n do {\n result = null;\n if (q.length > 0 && q[0].timestamp - scheduler.now() <= 0) {\n result = q.shift().value;\n }\n if (result !== null) {\n result.accept(observer);\n }\n } while (result !== null);\n shouldRecurse = false;\n recurseDueTime = 0;\n if (q.length > 0) {\n shouldRecurse = true;\n recurseDueTime = Math.max(0, q[0].timestamp - scheduler.now());\n } else {\n active = false;\n }\n e = exception;\n running = false;\n if (e !== null) {\n observer.onError(e);\n } else if (shouldRecurse) {\n self(recurseDueTime);\n }\n }));\n }\n }\n });\n return new CompositeDisposable(subscription, cancelable);\n }, source);\n }\n\n function observableDelayDate(source, dueTime, scheduler) {\n return observableDefer(function () {\n return observableDelayTimeSpan(source, dueTime - scheduler.now(), scheduler);\n });\n }\n\n /**\n * Time shifts the observable sequence by dueTime. The relative time intervals between the values are preserved.\n *\n * @example\n * 1 - res = Rx.Observable.delay(new Date());\n * 2 - res = Rx.Observable.delay(new Date(), Rx.Scheduler.timeout);\n *\n * 3 - res = Rx.Observable.delay(5000);\n * 4 - res = Rx.Observable.delay(5000, 1000, Rx.Scheduler.timeout);\n * @memberOf Observable#\n * @param {Number} dueTime Absolute (specified as a Date object) or relative time (specified as an integer denoting milliseconds) by which to shift the observable sequence.\n * @param {Scheduler} [scheduler] Scheduler to run the delay timers on. If not specified, the timeout scheduler is used.\n * @returns {Observable} Time-shifted sequence.\n */\n observableProto.delay = function (dueTime, scheduler) {\n isScheduler(scheduler) || (scheduler = timeoutScheduler);\n return dueTime instanceof Date ?\n observableDelayDate(this, dueTime.getTime(), scheduler) :\n observableDelayTimeSpan(this, dueTime, scheduler);\n };\n\r\n /**\n * Ignores values from an observable sequence which are followed by another value before dueTime.\n * @param {Number} dueTime Duration of the debounce period for each value (specified as an integer denoting milliseconds).\n * @param {Scheduler} [scheduler] Scheduler to run the debounce timers on. If not specified, the timeout scheduler is used.\n * @returns {Observable} The debounced sequence.\n */\n observableProto.debounce = observableProto.throttleWithTimeout = function (dueTime, scheduler) {\n isScheduler(scheduler) || (scheduler = timeoutScheduler);\n var source = this;\n return new AnonymousObservable(function (observer) {\n var cancelable = new SerialDisposable(), hasvalue = false, value, id = 0;\n var subscription = source.subscribe(\n function (x) {\n hasvalue = true;\n value = x;\n id++;\n var currentId = id,\n d = new SingleAssignmentDisposable();\n cancelable.setDisposable(d);\n d.setDisposable(scheduler.scheduleWithRelative(dueTime, function () {\n hasvalue && id === currentId && observer.onNext(value);\n hasvalue = false;\n }));\n },\n function (e) {\n cancelable.dispose();\n observer.onError(e);\n hasvalue = false;\n id++;\n },\n function () {\n cancelable.dispose();\n hasvalue && observer.onNext(value);\n observer.onCompleted();\n hasvalue = false;\n id++;\n });\n return new CompositeDisposable(subscription, cancelable);\n }, this);\n };\n\n /**\n * @deprecated use #debounce or #throttleWithTimeout instead.\n */\n observableProto.throttle = function(dueTime, scheduler) {\n //deprecate('throttle', 'debounce or throttleWithTimeout');\n return this.debounce(dueTime, scheduler);\n };\n\r\n /**\n * Projects each element of an observable sequence into zero or more windows which are produced based on timing information.\n * @param {Number} timeSpan Length of each window (specified as an integer denoting milliseconds).\n * @param {Mixed} [timeShiftOrScheduler] Interval between creation of consecutive windows (specified as an integer denoting milliseconds), or an optional scheduler parameter. If not specified, the time shift corresponds to the timeSpan parameter, resulting in non-overlapping adjacent windows.\n * @param {Scheduler} [scheduler] Scheduler to run windowing timers on. If not specified, the timeout scheduler is used.\n * @returns {Observable} An observable sequence of windows.\n */\n observableProto.windowWithTime = function (timeSpan, timeShiftOrScheduler, scheduler) {\n var source = this, timeShift;\n timeShiftOrScheduler == null && (timeShift = timeSpan);\n isScheduler(scheduler) || (scheduler = timeoutScheduler);\n if (typeof timeShiftOrScheduler === 'number') {\n timeShift = timeShiftOrScheduler;\n } else if (isScheduler(timeShiftOrScheduler)) {\n timeShift = timeSpan;\n scheduler = timeShiftOrScheduler;\n }\n return new AnonymousObservable(function (observer) {\n var groupDisposable,\n nextShift = timeShift,\n nextSpan = timeSpan,\n q = [],\n refCountDisposable,\n timerD = new SerialDisposable(),\n totalTime = 0;\n groupDisposable = new CompositeDisposable(timerD),\n refCountDisposable = new RefCountDisposable(groupDisposable);\n\n function createTimer () {\n var m = new SingleAssignmentDisposable(),\n isSpan = false,\n isShift = false;\n timerD.setDisposable(m);\n if (nextSpan === nextShift) {\n isSpan = true;\n isShift = true;\n } else if (nextSpan < nextShift) {\n isSpan = true;\n } else {\n isShift = true;\n }\n var newTotalTime = isSpan ? nextSpan : nextShift,\n ts = newTotalTime - totalTime;\n totalTime = newTotalTime;\n if (isSpan) {\n nextSpan += timeShift;\n }\n if (isShift) {\n nextShift += timeShift;\n }\n m.setDisposable(scheduler.scheduleWithRelative(ts, function () {\n if (isShift) {\n var s = new Subject();\n q.push(s);\n observer.onNext(addRef(s, refCountDisposable));\n }\n isSpan && q.shift().onCompleted();\n createTimer();\n }));\n };\n q.push(new Subject());\n observer.onNext(addRef(q[0], refCountDisposable));\n createTimer();\n groupDisposable.add(source.subscribe(\n function (x) {\n for (var i = 0, len = q.length; i < len; i++) { q[i].onNext(x); }\n },\n function (e) {\n for (var i = 0, len = q.length; i < len; i++) { q[i].onError(e); }\n observer.onError(e);\n },\n function () {\n for (var i = 0, len = q.length; i < len; i++) { q[i].onCompleted(); }\n observer.onCompleted();\n }\n ));\n return refCountDisposable;\n }, source);\n };\n\r\n /**\n * Projects each element of an observable sequence into a window that is completed when either it's full or a given amount of time has elapsed.\n * @param {Number} timeSpan Maximum time length of a window.\n * @param {Number} count Maximum element count of a window.\n * @param {Scheduler} [scheduler] Scheduler to run windowing timers on. If not specified, the timeout scheduler is used.\n * @returns {Observable} An observable sequence of windows.\n */\n observableProto.windowWithTimeOrCount = function (timeSpan, count, scheduler) {\n var source = this;\n isScheduler(scheduler) || (scheduler = timeoutScheduler);\n return new AnonymousObservable(function (observer) {\n var timerD = new SerialDisposable(),\n groupDisposable = new CompositeDisposable(timerD),\n refCountDisposable = new RefCountDisposable(groupDisposable),\n n = 0,\n windowId = 0,\n s = new Subject();\n\n function createTimer(id) {\n var m = new SingleAssignmentDisposable();\n timerD.setDisposable(m);\n m.setDisposable(scheduler.scheduleWithRelative(timeSpan, function () {\n if (id !== windowId) { return; }\n n = 0;\n var newId = ++windowId;\n s.onCompleted();\n s = new Subject();\n observer.onNext(addRef(s, refCountDisposable));\n createTimer(newId);\n }));\n }\n\n observer.onNext(addRef(s, refCountDisposable));\n createTimer(0);\n\n groupDisposable.add(source.subscribe(\n function (x) {\n var newId = 0, newWindow = false;\n s.onNext(x);\n if (++n === count) {\n newWindow = true;\n n = 0;\n newId = ++windowId;\n s.onCompleted();\n s = new Subject();\n observer.onNext(addRef(s, refCountDisposable));\n }\n newWindow && createTimer(newId);\n },\n function (e) {\n s.onError(e);\n observer.onError(e);\n }, function () {\n s.onCompleted();\n observer.onCompleted();\n }\n ));\n return refCountDisposable;\n }, source);\n };\n\r\n /**\n * Projects each element of an observable sequence into zero or more buffers which are produced based on timing information.\n *\n * @example\n * 1 - res = xs.bufferWithTime(1000, scheduler); // non-overlapping segments of 1 second\n * 2 - res = xs.bufferWithTime(1000, 500, scheduler; // segments of 1 second with time shift 0.5 seconds\n *\n * @param {Number} timeSpan Length of each buffer (specified as an integer denoting milliseconds).\n * @param {Mixed} [timeShiftOrScheduler] Interval between creation of consecutive buffers (specified as an integer denoting milliseconds), or an optional scheduler parameter. If not specified, the time shift corresponds to the timeSpan parameter, resulting in non-overlapping adjacent buffers.\n * @param {Scheduler} [scheduler] Scheduler to run buffer timers on. If not specified, the timeout scheduler is used.\n * @returns {Observable} An observable sequence of buffers.\n */\n observableProto.bufferWithTime = function (timeSpan, timeShiftOrScheduler, scheduler) {\n return this.windowWithTime.apply(this, arguments).selectMany(function (x) { return x.toArray(); });\n };\n\r\n /**\n * Projects each element of an observable sequence into a buffer that is completed when either it's full or a given amount of time has elapsed.\n *\n * @example\n * 1 - res = source.bufferWithTimeOrCount(5000, 50); // 5s or 50 items in an array\n * 2 - res = source.bufferWithTimeOrCount(5000, 50, scheduler); // 5s or 50 items in an array\n *\n * @param {Number} timeSpan Maximum time length of a buffer.\n * @param {Number} count Maximum element count of a buffer.\n * @param {Scheduler} [scheduler] Scheduler to run bufferin timers on. If not specified, the timeout scheduler is used.\n * @returns {Observable} An observable sequence of buffers.\n */\n observableProto.bufferWithTimeOrCount = function (timeSpan, count, scheduler) {\n return this.windowWithTimeOrCount(timeSpan, count, scheduler).selectMany(function (x) {\n return x.toArray();\n });\n };\n\r\n /**\n * Records the time interval between consecutive values in an observable sequence.\n *\n * @example\n * 1 - res = source.timeInterval();\n * 2 - res = source.timeInterval(Rx.Scheduler.timeout);\n *\n * @param [scheduler] Scheduler used to compute time intervals. If not specified, the timeout scheduler is used.\n * @returns {Observable} An observable sequence with time interval information on values.\n */\n observableProto.timeInterval = function (scheduler) {\n var source = this;\n isScheduler(scheduler) || (scheduler = timeoutScheduler);\n return observableDefer(function () {\n var last = scheduler.now();\n return source.map(function (x) {\n var now = scheduler.now(), span = now - last;\n last = now;\n return { value: x, interval: span };\n });\n });\n };\n\r\n /**\n * Records the timestamp for each value in an observable sequence.\n *\n * @example\n * 1 - res = source.timestamp(); // produces { value: x, timestamp: ts }\n * 2 - res = source.timestamp(Rx.Scheduler.default);\n *\n * @param {Scheduler} [scheduler] Scheduler used to compute timestamps. If not specified, the default scheduler is used.\n * @returns {Observable} An observable sequence with timestamp information on values.\n */\n observableProto.timestamp = function (scheduler) {\n isScheduler(scheduler) || (scheduler = timeoutScheduler);\n return this.map(function (x) {\n return { value: x, timestamp: scheduler.now() };\n });\n };\n\r\n function sampleObservable(source, sampler) {\n return new AnonymousObservable(function (o) {\n var atEnd = false, value, hasValue = false;\n\n function sampleSubscribe() {\n if (hasValue) {\n hasValue = false;\n o.onNext(value);\n }\n atEnd && o.onCompleted();\n }\n\n var sourceSubscription = new SingleAssignmentDisposable();\n sourceSubscription.setDisposable(source.subscribe(\n function (newValue) {\n hasValue = true;\n value = newValue;\n },\n function (e) { o.onError(e); },\n function () {\n atEnd = true;\n sourceSubscription.dispose(); \n }\n ));\n\n return new CompositeDisposable(\n sourceSubscription,\n sampler.subscribe(sampleSubscribe, function (e) { o.onError(e); }, sampleSubscribe)\n );\n }, source);\n }\n\n /**\n * Samples the observable sequence at each interval.\n *\n * @example\n * 1 - res = source.sample(sampleObservable); // Sampler tick sequence\n * 2 - res = source.sample(5000); // 5 seconds\n * 2 - res = source.sample(5000, Rx.Scheduler.timeout); // 5 seconds\n *\n * @param {Mixed} intervalOrSampler Interval at which to sample (specified as an integer denoting milliseconds) or Sampler Observable.\n * @param {Scheduler} [scheduler] Scheduler to run the sampling timer on. If not specified, the timeout scheduler is used.\n * @returns {Observable} Sampled observable sequence.\n */\n observableProto.sample = observableProto.throttleLatest = function (intervalOrSampler, scheduler) {\n isScheduler(scheduler) || (scheduler = timeoutScheduler);\n return typeof intervalOrSampler === 'number' ?\n sampleObservable(this, observableinterval(intervalOrSampler, scheduler)) :\n sampleObservable(this, intervalOrSampler);\n };\n\r\n /**\n * Returns the source observable sequence or the other observable sequence if dueTime elapses.\n * @param {Number} dueTime Absolute (specified as a Date object) or relative time (specified as an integer denoting milliseconds) when a timeout occurs.\n * @param {Observable} [other] Sequence to return in case of a timeout. If not specified, a timeout error throwing sequence will be used.\n * @param {Scheduler} [scheduler] Scheduler to run the timeout timers on. If not specified, the timeout scheduler is used.\n * @returns {Observable} The source sequence switching to the other sequence in case of a timeout.\n */\n observableProto.timeout = function (dueTime, other, scheduler) {\n (other == null || typeof other === 'string') && (other = observableThrow(new Error(other || 'Timeout')));\n isScheduler(scheduler) || (scheduler = timeoutScheduler);\n\n var source = this, schedulerMethod = dueTime instanceof Date ?\n 'scheduleWithAbsolute' :\n 'scheduleWithRelative';\n\n return new AnonymousObservable(function (observer) {\n var id = 0,\n original = new SingleAssignmentDisposable(),\n subscription = new SerialDisposable(),\n switched = false,\n timer = new SerialDisposable();\n\n subscription.setDisposable(original);\n\n function createTimer() {\n var myId = id;\n timer.setDisposable(scheduler[schedulerMethod](dueTime, function () {\n if (id === myId) {\n isPromise(other) && (other = observableFromPromise(other));\n subscription.setDisposable(other.subscribe(observer));\n }\n }));\n }\n\n createTimer();\n\n original.setDisposable(source.subscribe(function (x) {\n if (!switched) {\n id++;\n observer.onNext(x);\n createTimer();\n }\n }, function (e) {\n if (!switched) {\n id++;\n observer.onError(e);\n }\n }, function () {\n if (!switched) {\n id++;\n observer.onCompleted();\n }\n }));\n return new CompositeDisposable(subscription, timer);\n }, source);\n };\n\r\n /**\n * Generates an observable sequence by iterating a state from an initial state until the condition fails.\n *\n * @example\n * res = source.generateWithAbsoluteTime(0,\n * function (x) { return return true; },\n * function (x) { return x + 1; },\n * function (x) { return x; },\n * function (x) { return new Date(); }\n * });\n *\n * @param {Mixed} initialState Initial state.\n * @param {Function} condition Condition to terminate generation (upon returning false).\n * @param {Function} iterate Iteration step function.\n * @param {Function} resultSelector Selector function for results produced in the sequence.\n * @param {Function} timeSelector Time selector function to control the speed of values being produced each iteration, returning Date values.\n * @param {Scheduler} [scheduler] Scheduler on which to run the generator loop. If not specified, the timeout scheduler is used.\n * @returns {Observable} The generated sequence.\n */\n Observable.generateWithAbsoluteTime = function (initialState, condition, iterate, resultSelector, timeSelector, scheduler) {\n isScheduler(scheduler) || (scheduler = timeoutScheduler);\n return new AnonymousObservable(function (observer) {\n var first = true,\n hasResult = false;\n return scheduler.scheduleRecursiveWithAbsoluteAndState(initialState, scheduler.now(), function (state, self) {\n hasResult && observer.onNext(state);\n\n try {\n if (first) {\n first = false;\n } else {\n state = iterate(state);\n }\n hasResult = condition(state);\n if (hasResult) {\n var result = resultSelector(state);\n var time = timeSelector(state);\n }\n } catch (e) {\n observer.onError(e);\n return;\n }\n if (hasResult) {\n self(result, time);\n } else {\n observer.onCompleted();\n }\n });\n });\n };\n\r\n /**\n * Generates an observable sequence by iterating a state from an initial state until the condition fails.\n *\n * @example\n * res = source.generateWithRelativeTime(0,\n * function (x) { return return true; },\n * function (x) { return x + 1; },\n * function (x) { return x; },\n * function (x) { return 500; }\n * );\n *\n * @param {Mixed} initialState Initial state.\n * @param {Function} condition Condition to terminate generation (upon returning false).\n * @param {Function} iterate Iteration step function.\n * @param {Function} resultSelector Selector function for results produced in the sequence.\n * @param {Function} timeSelector Time selector function to control the speed of values being produced each iteration, returning integer values denoting milliseconds.\n * @param {Scheduler} [scheduler] Scheduler on which to run the generator loop. If not specified, the timeout scheduler is used.\n * @returns {Observable} The generated sequence.\n */\n Observable.generateWithRelativeTime = function (initialState, condition, iterate, resultSelector, timeSelector, scheduler) {\n isScheduler(scheduler) || (scheduler = timeoutScheduler);\n return new AnonymousObservable(function (observer) {\n var first = true,\n hasResult = false;\n return scheduler.scheduleRecursiveWithRelativeAndState(initialState, 0, function (state, self) {\n hasResult && observer.onNext(state);\n\n try {\n if (first) {\n first = false;\n } else {\n state = iterate(state);\n }\n hasResult = condition(state);\n if (hasResult) {\n var result = resultSelector(state);\n var time = timeSelector(state);\n }\n } catch (e) {\n observer.onError(e);\n return;\n }\n if (hasResult) {\n self(result, time);\n } else {\n observer.onCompleted();\n }\n });\n });\n };\n\r\n /**\n * Time shifts the observable sequence by delaying the subscription with the specified relative time duration, using the specified scheduler to run timers.\n *\n * @example\n * 1 - res = source.delaySubscription(5000); // 5s\n * 2 - res = source.delaySubscription(5000, Rx.Scheduler.default); // 5 seconds\n *\n * @param {Number} dueTime Relative or absolute time shift of the subscription.\n * @param {Scheduler} [scheduler] Scheduler to run the subscription delay timer on. If not specified, the timeout scheduler is used.\n * @returns {Observable} Time-shifted sequence.\n */\n observableProto.delaySubscription = function (dueTime, scheduler) {\n var scheduleMethod = dueTime instanceof Date ? 'scheduleWithAbsolute' : 'scheduleWithRelative';\n var source = this;\n isScheduler(scheduler) || (scheduler = timeoutScheduler);\n return new AnonymousObservable(function (o) {\n var d = new SerialDisposable();\n\n d.setDisposable(scheduler[scheduleMethod](dueTime, function() {\n d.setDisposable(source.subscribe(o));\n }));\n\n return d;\n }, this);\n };\n\r\n /**\n * Time shifts the observable sequence based on a subscription delay and a delay selector function for each element.\n *\n * @example\n * 1 - res = source.delayWithSelector(function (x) { return Rx.Scheduler.timer(5000); }); // with selector only\n * 1 - res = source.delayWithSelector(Rx.Observable.timer(2000), function (x) { return Rx.Observable.timer(x); }); // with delay and selector\n *\n * @param {Observable} [subscriptionDelay] Sequence indicating the delay for the subscription to the source.\n * @param {Function} delayDurationSelector Selector function to retrieve a sequence indicating the delay for each given element.\n * @returns {Observable} Time-shifted sequence.\n */\n observableProto.delayWithSelector = function (subscriptionDelay, delayDurationSelector) {\n var source = this, subDelay, selector;\n if (isFunction(subscriptionDelay)) {\n selector = subscriptionDelay;\n } else {\n subDelay = subscriptionDelay;\n selector = delayDurationSelector;\n }\n return new AnonymousObservable(function (observer) {\n var delays = new CompositeDisposable(), atEnd = false, subscription = new SerialDisposable();\n\n function start() {\n subscription.setDisposable(source.subscribe(\n function (x) {\n var delay = tryCatch(selector)(x);\n if (delay === errorObj) { return observer.onError(delay.e); }\n var d = new SingleAssignmentDisposable();\n delays.add(d);\n d.setDisposable(delay.subscribe(\n function () {\n observer.onNext(x);\n delays.remove(d);\n done();\n },\n function (e) { observer.onError(e); },\n function () {\n observer.onNext(x);\n delays.remove(d);\n done();\n }\n ))\n },\n function (e) { observer.onError(e); },\n function () {\n atEnd = true;\n subscription.dispose();\n done();\n }\n ))\n }\n\n function done () {\n atEnd && delays.length === 0 && observer.onCompleted();\n }\n\n if (!subDelay) {\n start();\n } else {\n subscription.setDisposable(subDelay.subscribe(start, function (e) { observer.onError(e); }, start));\n }\n\n return new CompositeDisposable(subscription, delays);\n }, this);\n };\n\r\n /**\n * Returns the source observable sequence, switching to the other observable sequence if a timeout is signaled.\n * @param {Observable} [firstTimeout] Observable sequence that represents the timeout for the first element. If not provided, this defaults to Observable.never().\n * @param {Function} timeoutDurationSelector Selector to retrieve an observable sequence that represents the timeout between the current element and the next element.\n * @param {Observable} [other] Sequence to return in case of a timeout. If not provided, this is set to Observable.throwException().\n * @returns {Observable} The source sequence switching to the other sequence in case of a timeout.\n */\n observableProto.timeoutWithSelector = function (firstTimeout, timeoutdurationSelector, other) {\n if (arguments.length === 1) {\n timeoutdurationSelector = firstTimeout;\n firstTimeout = observableNever();\n }\n other || (other = observableThrow(new Error('Timeout')));\n var source = this;\n return new AnonymousObservable(function (observer) {\n var subscription = new SerialDisposable(), timer = new SerialDisposable(), original = new SingleAssignmentDisposable();\n\n subscription.setDisposable(original);\n\n var id = 0, switched = false;\n\n function setTimer(timeout) {\n var myId = id;\n\n function timerWins () {\n return id === myId;\n }\n\n var d = new SingleAssignmentDisposable();\n timer.setDisposable(d);\n d.setDisposable(timeout.subscribe(function () {\n timerWins() && subscription.setDisposable(other.subscribe(observer));\n d.dispose();\n }, function (e) {\n timerWins() && observer.onError(e);\n }, function () {\n timerWins() && subscription.setDisposable(other.subscribe(observer));\n }));\n };\n\n setTimer(firstTimeout);\n\n function observerWins() {\n var res = !switched;\n if (res) { id++; }\n return res;\n }\n\n original.setDisposable(source.subscribe(function (x) {\n if (observerWins()) {\n observer.onNext(x);\n var timeout;\n try {\n timeout = timeoutdurationSelector(x);\n } catch (e) {\n observer.onError(e);\n return;\n }\n setTimer(isPromise(timeout) ? observableFromPromise(timeout) : timeout);\n }\n }, function (e) {\n observerWins() && observer.onError(e);\n }, function () {\n observerWins() && observer.onCompleted();\n }));\n return new CompositeDisposable(subscription, timer);\n }, source);\n };\n\r\n /**\n * Ignores values from an observable sequence which are followed by another value within a computed throttle duration.\n * @param {Function} durationSelector Selector function to retrieve a sequence indicating the throttle duration for each given element.\n * @returns {Observable} The debounced sequence.\n */\n observableProto.debounceWithSelector = function (durationSelector) {\n var source = this;\n return new AnonymousObservable(function (observer) {\n var value, hasValue = false, cancelable = new SerialDisposable(), id = 0;\n var subscription = source.subscribe(function (x) {\n var throttle;\n try {\n throttle = durationSelector(x);\n } catch (e) {\n observer.onError(e);\n return;\n }\n\n isPromise(throttle) && (throttle = observableFromPromise(throttle));\n\n hasValue = true;\n value = x;\n id++;\n var currentid = id, d = new SingleAssignmentDisposable();\n cancelable.setDisposable(d);\n d.setDisposable(throttle.subscribe(function () {\n hasValue && id === currentid && observer.onNext(value);\n hasValue = false;\n d.dispose();\n }, observer.onError.bind(observer), function () {\n hasValue && id === currentid && observer.onNext(value);\n hasValue = false;\n d.dispose();\n }));\n }, function (e) {\n cancelable.dispose();\n observer.onError(e);\n hasValue = false;\n id++;\n }, function () {\n cancelable.dispose();\n hasValue && observer.onNext(value);\n observer.onCompleted();\n hasValue = false;\n id++;\n });\n return new CompositeDisposable(subscription, cancelable);\n }, source);\n };\n\n /**\n * @deprecated use #debounceWithSelector instead.\n */\n observableProto.throttleWithSelector = function (durationSelector) {\n //deprecate('throttleWithSelector', 'debounceWithSelector');\n return this.debounceWithSelector(durationSelector);\n };\n\r\n /**\n * Skips elements for the specified duration from the end of the observable source sequence, using the specified scheduler to run timers.\n *\n * 1 - res = source.skipLastWithTime(5000);\n * 2 - res = source.skipLastWithTime(5000, scheduler);\n *\n * @description\n * This operator accumulates a queue with a length enough to store elements received during the initial duration window.\n * As more elements are received, elements older than the specified duration are taken from the queue and produced on the\n * result sequence. This causes elements to be delayed with duration.\n * @param {Number} duration Duration for skipping elements from the end of the sequence.\n * @param {Scheduler} [scheduler] Scheduler to run the timer on. If not specified, defaults to Rx.Scheduler.timeout\n * @returns {Observable} An observable sequence with the elements skipped during the specified duration from the end of the source sequence.\n */\n observableProto.skipLastWithTime = function (duration, scheduler) {\n isScheduler(scheduler) || (scheduler = timeoutScheduler);\n var source = this;\n return new AnonymousObservable(function (o) {\n var q = [];\n return source.subscribe(function (x) {\n var now = scheduler.now();\n q.push({ interval: now, value: x });\n while (q.length > 0 && now - q[0].interval >= duration) {\n o.onNext(q.shift().value);\n }\n }, function (e) { o.onError(e); }, function () {\n var now = scheduler.now();\n while (q.length > 0 && now - q[0].interval >= duration) {\n o.onNext(q.shift().value);\n }\n o.onCompleted();\n });\n }, source);\n };\n\r\n /**\n * Returns elements within the specified duration from the end of the observable source sequence, using the specified schedulers to run timers and to drain the collected elements.\n * @description\n * This operator accumulates a queue with a length enough to store elements received during the initial duration window.\n * As more elements are received, elements older than the specified duration are taken from the queue and produced on the\n * result sequence. This causes elements to be delayed with duration.\n * @param {Number} duration Duration for taking elements from the end of the sequence.\n * @param {Scheduler} [scheduler] Scheduler to run the timer on. If not specified, defaults to Rx.Scheduler.timeout.\n * @returns {Observable} An observable sequence with the elements taken during the specified duration from the end of the source sequence.\n */\n observableProto.takeLastWithTime = function (duration, scheduler) {\n var source = this;\n isScheduler(scheduler) || (scheduler = timeoutScheduler);\n return new AnonymousObservable(function (o) {\n var q = [];\n return source.subscribe(function (x) {\n var now = scheduler.now();\n q.push({ interval: now, value: x });\n while (q.length > 0 && now - q[0].interval >= duration) {\n q.shift();\n }\n }, function (e) { o.onError(e); }, function () {\n var now = scheduler.now();\n while (q.length > 0) {\n var next = q.shift();\n if (now - next.interval <= duration) { o.onNext(next.value); }\n }\n o.onCompleted();\n });\n }, source);\n };\n\r\n /**\n * Returns an array with the elements within the specified duration from the end of the observable source sequence, using the specified scheduler to run timers.\n * @description\n * This operator accumulates a queue with a length enough to store elements received during the initial duration window.\n * As more elements are received, elements older than the specified duration are taken from the queue and produced on the\n * result sequence. This causes elements to be delayed with duration.\n * @param {Number} duration Duration for taking elements from the end of the sequence.\n * @param {Scheduler} scheduler Scheduler to run the timer on. If not specified, defaults to Rx.Scheduler.timeout.\n * @returns {Observable} An observable sequence containing a single array with the elements taken during the specified duration from the end of the source sequence.\n */\n observableProto.takeLastBufferWithTime = function (duration, scheduler) {\n var source = this;\n isScheduler(scheduler) || (scheduler = timeoutScheduler);\n return new AnonymousObservable(function (o) {\n var q = [];\n return source.subscribe(function (x) {\n var now = scheduler.now();\n q.push({ interval: now, value: x });\n while (q.length > 0 && now - q[0].interval >= duration) {\n q.shift();\n }\n }, function (e) { o.onError(e); }, function () {\n var now = scheduler.now(), res = [];\n while (q.length > 0) {\n var next = q.shift();\n now - next.interval <= duration && res.push(next.value);\n }\n o.onNext(res);\n o.onCompleted();\n });\n }, source);\n };\n\r\n /**\n * Takes elements for the specified duration from the start of the observable source sequence, using the specified scheduler to run timers.\n *\n * @example\n * 1 - res = source.takeWithTime(5000, [optional scheduler]);\n * @description\n * This operator accumulates a queue with a length enough to store elements received during the initial duration window.\n * As more elements are received, elements older than the specified duration are taken from the queue and produced on the\n * result sequence. This causes elements to be delayed with duration.\n * @param {Number} duration Duration for taking elements from the start of the sequence.\n * @param {Scheduler} scheduler Scheduler to run the timer on. If not specified, defaults to Rx.Scheduler.timeout.\n * @returns {Observable} An observable sequence with the elements taken during the specified duration from the start of the source sequence.\n */\n observableProto.takeWithTime = function (duration, scheduler) {\n var source = this;\n isScheduler(scheduler) || (scheduler = timeoutScheduler);\n return new AnonymousObservable(function (o) {\n return new CompositeDisposable(scheduler.scheduleWithRelative(duration, function () { o.onCompleted(); }), source.subscribe(o));\n }, source);\n };\n\r\n /**\n * Skips elements for the specified duration from the start of the observable source sequence, using the specified scheduler to run timers.\n *\n * @example\n * 1 - res = source.skipWithTime(5000, [optional scheduler]);\n *\n * @description\n * Specifying a zero value for duration doesn't guarantee no elements will be dropped from the start of the source sequence.\n * This is a side-effect of the asynchrony introduced by the scheduler, where the action that causes callbacks from the source sequence to be forwarded\n * may not execute immediately, despite the zero due time.\n *\n * Errors produced by the source sequence are always forwarded to the result sequence, even if the error occurs before the duration.\n * @param {Number} duration Duration for skipping elements from the start of the sequence.\n * @param {Scheduler} scheduler Scheduler to run the timer on. If not specified, defaults to Rx.Scheduler.timeout.\n * @returns {Observable} An observable sequence with the elements skipped during the specified duration from the start of the source sequence.\n */\n observableProto.skipWithTime = function (duration, scheduler) {\n var source = this;\n isScheduler(scheduler) || (scheduler = timeoutScheduler);\n return new AnonymousObservable(function (observer) {\n var open = false;\n return new CompositeDisposable(\n scheduler.scheduleWithRelative(duration, function () { open = true; }),\n source.subscribe(function (x) { open && observer.onNext(x); }, observer.onError.bind(observer), observer.onCompleted.bind(observer)));\n }, source);\n };\n\r\n /**\n * Skips elements from the observable source sequence until the specified start time, using the specified scheduler to run timers.\n * Errors produced by the source sequence are always forwarded to the result sequence, even if the error occurs before the start time.\n *\n * @examples\n * 1 - res = source.skipUntilWithTime(new Date(), [scheduler]);\n * 2 - res = source.skipUntilWithTime(5000, [scheduler]);\n * @param {Date|Number} startTime Time to start taking elements from the source sequence. If this value is less than or equal to Date(), no elements will be skipped.\n * @param {Scheduler} [scheduler] Scheduler to run the timer on. If not specified, defaults to Rx.Scheduler.timeout.\n * @returns {Observable} An observable sequence with the elements skipped until the specified start time.\n */\n observableProto.skipUntilWithTime = function (startTime, scheduler) {\n isScheduler(scheduler) || (scheduler = timeoutScheduler);\n var source = this, schedulerMethod = startTime instanceof Date ?\n 'scheduleWithAbsolute' :\n 'scheduleWithRelative';\n return new AnonymousObservable(function (o) {\n var open = false;\n\n return new CompositeDisposable(\n scheduler[schedulerMethod](startTime, function () { open = true; }),\n source.subscribe(\n function (x) { open && o.onNext(x); },\n function (e) { o.onError(e); }, function () { o.onCompleted(); }));\n }, source);\n };\n\r\n /**\n * Takes elements for the specified duration until the specified end time, using the specified scheduler to run timers.\n * @param {Number | Date} endTime Time to stop taking elements from the source sequence. If this value is less than or equal to new Date(), the result stream will complete immediately.\n * @param {Scheduler} [scheduler] Scheduler to run the timer on.\n * @returns {Observable} An observable sequence with the elements taken until the specified end time.\n */\n observableProto.takeUntilWithTime = function (endTime, scheduler) {\n isScheduler(scheduler) || (scheduler = timeoutScheduler);\n var source = this, schedulerMethod = endTime instanceof Date ?\n 'scheduleWithAbsolute' :\n 'scheduleWithRelative';\n return new AnonymousObservable(function (o) {\n return new CompositeDisposable(\n scheduler[schedulerMethod](endTime, function () { o.onCompleted(); }),\n source.subscribe(o));\n }, source);\n };\n\r\n /**\n * Returns an Observable that emits only the first item emitted by the source Observable during sequential time windows of a specified duration.\n * @param {Number} windowDuration time to wait before emitting another item after emitting the last item\n * @param {Scheduler} [scheduler] the Scheduler to use internally to manage the timers that handle timeout for each item. If not provided, defaults to Scheduler.timeout.\n * @returns {Observable} An Observable that performs the throttle operation.\n */\n observableProto.throttleFirst = function (windowDuration, scheduler) {\n isScheduler(scheduler) || (scheduler = timeoutScheduler);\n var duration = +windowDuration || 0;\n if (duration <= 0) { throw new RangeError('windowDuration cannot be less or equal zero.'); }\n var source = this;\n return new AnonymousObservable(function (o) {\n var lastOnNext = 0;\n return source.subscribe(\n function (x) {\n var now = scheduler.now();\n if (lastOnNext === 0 || now - lastOnNext >= duration) {\n lastOnNext = now;\n o.onNext(x);\n }\n },function (e) { o.onError(e); }, function () { o.onCompleted(); }\n );\n }, source);\n };\n\r\n /**\n * Executes a transducer to transform the observable sequence\n * @param {Transducer} transducer A transducer to execute\n * @returns {Observable} An Observable sequence containing the results from the transducer.\n */\n observableProto.transduce = function(transducer) {\n var source = this;\n\n function transformForObserver(o) {\n return {\n '@@transducer/init': function() {\n return o;\n },\n '@@transducer/step': function(obs, input) {\n return obs.onNext(input);\n },\n '@@transducer/result': function(obs) {\n return obs.onCompleted();\n }\n };\n }\n\n return new AnonymousObservable(function(o) {\n var xform = transducer(transformForObserver(o));\n return source.subscribe(\n function(v) {\n try {\n xform['@@transducer/step'](o, v);\n } catch (e) {\n o.onError(e);\n }\n },\n function (e) { o.onError(e); },\n function() { xform['@@transducer/result'](o); }\n );\n }, source);\n };\n\r\n /*\n * Performs a exclusive waiting for the first to finish before subscribing to another observable.\n * Observables that come in between subscriptions will be dropped on the floor.\n * @returns {Observable} A exclusive observable with only the results that happen when subscribed.\n */\n observableProto.exclusive = function () {\n var sources = this;\n return new AnonymousObservable(function (observer) {\n var hasCurrent = false,\n isStopped = false,\n m = new SingleAssignmentDisposable(),\n g = new CompositeDisposable();\n\n g.add(m);\n\n m.setDisposable(sources.subscribe(\n function (innerSource) {\n if (!hasCurrent) {\n hasCurrent = true;\n\n isPromise(innerSource) && (innerSource = observableFromPromise(innerSource));\n\n var innerSubscription = new SingleAssignmentDisposable();\n g.add(innerSubscription);\n\n innerSubscription.setDisposable(innerSource.subscribe(\n observer.onNext.bind(observer),\n observer.onError.bind(observer),\n function () {\n g.remove(innerSubscription);\n hasCurrent = false;\n if (isStopped && g.length === 1) {\n observer.onCompleted();\n }\n }));\n }\n },\n observer.onError.bind(observer),\n function () {\n isStopped = true;\n if (!hasCurrent && g.length === 1) {\n observer.onCompleted();\n }\n }));\n\n return g;\n }, this);\n };\n\r\n /*\n * Performs a exclusive map waiting for the first to finish before subscribing to another observable.\n * Observables that come in between subscriptions will be dropped on the floor.\n * @param {Function} selector Selector to invoke for every item in the current subscription.\n * @param {Any} [thisArg] An optional context to invoke with the selector parameter.\n * @returns {Observable} An exclusive observable with only the results that happen when subscribed.\n */\n observableProto.exclusiveMap = function (selector, thisArg) {\n var sources = this,\n selectorFunc = bindCallback(selector, thisArg, 3);\n return new AnonymousObservable(function (observer) {\n var index = 0,\n hasCurrent = false,\n isStopped = true,\n m = new SingleAssignmentDisposable(),\n g = new CompositeDisposable();\n\n g.add(m);\n\n m.setDisposable(sources.subscribe(\n function (innerSource) {\n\n if (!hasCurrent) {\n hasCurrent = true;\n\n innerSubscription = new SingleAssignmentDisposable();\n g.add(innerSubscription);\n\n isPromise(innerSource) && (innerSource = observableFromPromise(innerSource));\n\n innerSubscription.setDisposable(innerSource.subscribe(\n function (x) {\n var result;\n try {\n result = selectorFunc(x, index++, innerSource);\n } catch (e) {\n observer.onError(e);\n return;\n }\n\n observer.onNext(result);\n },\n function (e) { observer.onError(e); },\n function () {\n g.remove(innerSubscription);\n hasCurrent = false;\n\n if (isStopped && g.length === 1) {\n observer.onCompleted();\n }\n }));\n }\n },\n function (e) { observer.onError(e); },\n function () {\n isStopped = true;\n if (g.length === 1 && !hasCurrent) {\n observer.onCompleted();\n }\n }));\n return g;\n }, this);\n };\n\r\n /** Provides a set of extension methods for virtual time scheduling. */\n Rx.VirtualTimeScheduler = (function (__super__) {\n\n function localNow() {\n return this.toDateTimeOffset(this.clock);\n }\n\n function scheduleNow(state, action) {\n return this.scheduleAbsoluteWithState(state, this.clock, action);\n }\n\n function scheduleRelative(state, dueTime, action) {\n return this.scheduleRelativeWithState(state, this.toRelative(dueTime), action);\n }\n\n function scheduleAbsolute(state, dueTime, action) {\n return this.scheduleRelativeWithState(state, this.toRelative(dueTime - this.now()), action);\n }\n\n function invokeAction(scheduler, action) {\n action();\n return disposableEmpty;\n }\n\n inherits(VirtualTimeScheduler, __super__);\n\n /**\n * Creates a new virtual time scheduler with the specified initial clock value and absolute time comparer.\n *\n * @constructor\n * @param {Number} initialClock Initial value for the clock.\n * @param {Function} comparer Comparer to determine causality of events based on absolute time.\n */\n function VirtualTimeScheduler(initialClock, comparer) {\n this.clock = initialClock;\n this.comparer = comparer;\n this.isEnabled = false;\n this.queue = new PriorityQueue(1024);\n __super__.call(this, localNow, scheduleNow, scheduleRelative, scheduleAbsolute);\n }\n\n var VirtualTimeSchedulerPrototype = VirtualTimeScheduler.prototype;\n\n /**\n * Adds a relative time value to an absolute time value.\n * @param {Number} absolute Absolute virtual time value.\n * @param {Number} relative Relative virtual time value to add.\n * @return {Number} Resulting absolute virtual time sum value.\n */\n VirtualTimeSchedulerPrototype.add = notImplemented;\n\n /**\n * Converts an absolute time to a number\n * @param {Any} The absolute time.\n * @returns {Number} The absolute time in ms\n */\n VirtualTimeSchedulerPrototype.toDateTimeOffset = notImplemented;\n\n /**\n * Converts the TimeSpan value to a relative virtual time value.\n * @param {Number} timeSpan TimeSpan value to convert.\n * @return {Number} Corresponding relative virtual time value.\n */\n VirtualTimeSchedulerPrototype.toRelative = notImplemented;\n\n /**\n * Schedules a periodic piece of work by dynamically discovering the scheduler's capabilities. The periodic task will be emulated using recursive scheduling.\n * @param {Mixed} state Initial state passed to the action upon the first iteration.\n * @param {Number} period Period for running the work periodically.\n * @param {Function} action Action to be executed, potentially updating the state.\n * @returns {Disposable} The disposable object used to cancel the scheduled recurring action (best effort).\n */\n VirtualTimeSchedulerPrototype.schedulePeriodicWithState = function (state, period, action) {\n var s = new SchedulePeriodicRecursive(this, state, period, action);\n return s.start();\n };\n\n /**\n * Schedules an action to be executed after dueTime.\n * @param {Mixed} state State passed to the action to be executed.\n * @param {Number} dueTime Relative time after which to execute the action.\n * @param {Function} action Action to be executed.\n * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort).\n */\n VirtualTimeSchedulerPrototype.scheduleRelativeWithState = function (state, dueTime, action) {\n var runAt = this.add(this.clock, dueTime);\n return this.scheduleAbsoluteWithState(state, runAt, action);\n };\n\n /**\n * Schedules an action to be executed at dueTime.\n * @param {Number} dueTime Relative time after which to execute the action.\n * @param {Function} action Action to be executed.\n * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort).\n */\n VirtualTimeSchedulerPrototype.scheduleRelative = function (dueTime, action) {\n return this.scheduleRelativeWithState(action, dueTime, invokeAction);\n };\n\n /**\n * Starts the virtual time scheduler.\n */\n VirtualTimeSchedulerPrototype.start = function () {\n if (!this.isEnabled) {\n this.isEnabled = true;\n do {\n var next = this.getNext();\n if (next !== null) {\n this.comparer(next.dueTime, this.clock) > 0 && (this.clock = next.dueTime);\n next.invoke();\n } else {\n this.isEnabled = false;\n }\n } while (this.isEnabled);\n }\n };\n\n /**\n * Stops the virtual time scheduler.\n */\n VirtualTimeSchedulerPrototype.stop = function () {\n this.isEnabled = false;\n };\n\n /**\n * Advances the scheduler's clock to the specified time, running all work till that point.\n * @param {Number} time Absolute time to advance the scheduler's clock to.\n */\n VirtualTimeSchedulerPrototype.advanceTo = function (time) {\n var dueToClock = this.comparer(this.clock, time);\n if (this.comparer(this.clock, time) > 0) { throw new ArgumentOutOfRangeError(); }\n if (dueToClock === 0) { return; }\n if (!this.isEnabled) {\n this.isEnabled = true;\n do {\n var next = this.getNext();\n if (next !== null && this.comparer(next.dueTime, time) <= 0) {\n this.comparer(next.dueTime, this.clock) > 0 && (this.clock = next.dueTime);\n next.invoke();\n } else {\n this.isEnabled = false;\n }\n } while (this.isEnabled);\n this.clock = time;\n }\n };\n\n /**\n * Advances the scheduler's clock by the specified relative time, running all work scheduled for that timespan.\n * @param {Number} time Relative time to advance the scheduler's clock by.\n */\n VirtualTimeSchedulerPrototype.advanceBy = function (time) {\n var dt = this.add(this.clock, time),\n dueToClock = this.comparer(this.clock, dt);\n if (dueToClock > 0) { throw new ArgumentOutOfRangeError(); }\n if (dueToClock === 0) { return; }\n\n this.advanceTo(dt);\n };\n\n /**\n * Advances the scheduler's clock by the specified relative time.\n * @param {Number} time Relative time to advance the scheduler's clock by.\n */\n VirtualTimeSchedulerPrototype.sleep = function (time) {\n var dt = this.add(this.clock, time);\n if (this.comparer(this.clock, dt) >= 0) { throw new ArgumentOutOfRangeError(); }\n\n this.clock = dt;\n };\n\n /**\n * Gets the next scheduled item to be executed.\n * @returns {ScheduledItem} The next scheduled item.\n */\n VirtualTimeSchedulerPrototype.getNext = function () {\n while (this.queue.length > 0) {\n var next = this.queue.peek();\n if (next.isCancelled()) {\n this.queue.dequeue();\n } else {\n return next;\n }\n }\n return null;\n };\n\n /**\n * Schedules an action to be executed at dueTime.\n * @param {Scheduler} scheduler Scheduler to execute the action on.\n * @param {Number} dueTime Absolute time at which to execute the action.\n * @param {Function} action Action to be executed.\n * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort).\n */\n VirtualTimeSchedulerPrototype.scheduleAbsolute = function (dueTime, action) {\n return this.scheduleAbsoluteWithState(action, dueTime, invokeAction);\n };\n\n /**\n * Schedules an action to be executed at dueTime.\n * @param {Mixed} state State passed to the action to be executed.\n * @param {Number} dueTime Absolute time at which to execute the action.\n * @param {Function} action Action to be executed.\n * @returns {Disposable} The disposable object used to cancel the scheduled action (best effort).\n */\n VirtualTimeSchedulerPrototype.scheduleAbsoluteWithState = function (state, dueTime, action) {\n var self = this;\n\n function run(scheduler, state1) {\n self.queue.remove(si);\n return action(scheduler, state1);\n }\n\n var si = new ScheduledItem(this, state, run, dueTime, this.comparer);\n this.queue.enqueue(si);\n\n return si.disposable;\n };\n\n return VirtualTimeScheduler;\n }(Scheduler));\n\r\n /** Provides a virtual time scheduler that uses Date for absolute time and number for relative time. */\n Rx.HistoricalScheduler = (function (__super__) {\n inherits(HistoricalScheduler, __super__);\n\n /**\n * Creates a new historical scheduler with the specified initial clock value.\n * @constructor\n * @param {Number} initialClock Initial value for the clock.\n * @param {Function} comparer Comparer to determine causality of events based on absolute time.\n */\n function HistoricalScheduler(initialClock, comparer) {\n var clock = initialClock == null ? 0 : initialClock;\n var cmp = comparer || defaultSubComparer;\n __super__.call(this, clock, cmp);\n }\n\n var HistoricalSchedulerProto = HistoricalScheduler.prototype;\n\n /**\n * Adds a relative time value to an absolute time value.\n * @param {Number} absolute Absolute virtual time value.\n * @param {Number} relative Relative virtual time value to add.\n * @return {Number} Resulting absolute virtual time sum value.\n */\n HistoricalSchedulerProto.add = function (absolute, relative) {\n return absolute + relative;\n };\n\n HistoricalSchedulerProto.toDateTimeOffset = function (absolute) {\n return new Date(absolute).getTime();\n };\n\n /**\n * Converts the TimeSpan value to a relative virtual time value.\n * @memberOf HistoricalScheduler\n * @param {Number} timeSpan TimeSpan value to convert.\n * @return {Number} Corresponding relative virtual time value.\n */\n HistoricalSchedulerProto.toRelative = function (timeSpan) {\n return timeSpan;\n };\n\n return HistoricalScheduler;\n }(Rx.VirtualTimeScheduler));\n\r\n var AnonymousObservable = Rx.AnonymousObservable = (function (__super__) {\n inherits(AnonymousObservable, __super__);\n\n // Fix subscriber to check for undefined or function returned to decorate as Disposable\n function fixSubscriber(subscriber) {\n return subscriber && isFunction(subscriber.dispose) ? subscriber :\n isFunction(subscriber) ? disposableCreate(subscriber) : disposableEmpty;\n }\n\n function setDisposable(s, state) {\n var ado = state[0], subscribe = state[1];\n var sub = tryCatch(subscribe)(ado);\n\n if (sub === errorObj) {\n if(!ado.fail(errorObj.e)) { return thrower(errorObj.e); }\n }\n ado.setDisposable(fixSubscriber(sub));\n }\n\n function AnonymousObservable(subscribe, parent) {\n this.source = parent;\n\n function s(observer) {\n var ado = new AutoDetachObserver(observer), state = [ado, subscribe];\n\n if (currentThreadScheduler.scheduleRequired()) {\n currentThreadScheduler.scheduleWithState(state, setDisposable);\n } else {\n setDisposable(null, state);\n }\n return ado;\n }\n\n __super__.call(this, s);\n }\n\n return AnonymousObservable;\n\n }(Observable));\n\r\n var AutoDetachObserver = (function (__super__) {\n inherits(AutoDetachObserver, __super__);\n\n function AutoDetachObserver(observer) {\n __super__.call(this);\n this.observer = observer;\n this.m = new SingleAssignmentDisposable();\n }\n\n var AutoDetachObserverPrototype = AutoDetachObserver.prototype;\n\n AutoDetachObserverPrototype.next = function (value) {\n var result = tryCatch(this.observer.onNext).call(this.observer, value);\n if (result === errorObj) {\n this.dispose();\n thrower(result.e);\n }\n };\n\n AutoDetachObserverPrototype.error = function (err) {\n var result = tryCatch(this.observer.onError).call(this.observer, err);\n this.dispose();\n result === errorObj && thrower(result.e);\n };\n\n AutoDetachObserverPrototype.completed = function () {\n var result = tryCatch(this.observer.onCompleted).call(this.observer);\n this.dispose();\n result === errorObj && thrower(result.e);\n };\n\n AutoDetachObserverPrototype.setDisposable = function (value) { this.m.setDisposable(value); };\n AutoDetachObserverPrototype.getDisposable = function () { return this.m.getDisposable(); };\n\n AutoDetachObserverPrototype.dispose = function () {\n __super__.prototype.dispose.call(this);\n this.m.dispose();\n };\n\n return AutoDetachObserver;\n }(AbstractObserver));\n\r\n var GroupedObservable = (function (__super__) {\n inherits(GroupedObservable, __super__);\n\n function subscribe(observer) {\n return this.underlyingObservable.subscribe(observer);\n }\n\n function GroupedObservable(key, underlyingObservable, mergedDisposable) {\n __super__.call(this, subscribe);\n this.key = key;\n this.underlyingObservable = !mergedDisposable ?\n underlyingObservable :\n new AnonymousObservable(function (observer) {\n return new CompositeDisposable(mergedDisposable.getDisposable(), underlyingObservable.subscribe(observer));\n });\n }\n\n return GroupedObservable;\n }(Observable));\n\r\n /**\n * Represents an object that is both an observable sequence as well as an observer.\n * Each notification is broadcasted to all subscribed observers.\n */\n var Subject = Rx.Subject = (function (__super__) {\n function subscribe(observer) {\n checkDisposed(this);\n if (!this.isStopped) {\n this.observers.push(observer);\n return new InnerSubscription(this, observer);\n }\n if (this.hasError) {\n observer.onError(this.error);\n return disposableEmpty;\n }\n observer.onCompleted();\n return disposableEmpty;\n }\n\n inherits(Subject, __super__);\n\n /**\n * Creates a subject.\n */\n function Subject() {\n __super__.call(this, subscribe);\n this.isDisposed = false,\n this.isStopped = false,\n this.observers = [];\n this.hasError = false;\n }\n\n addProperties(Subject.prototype, Observer.prototype, {\n /**\n * Indicates whether the subject has observers subscribed to it.\n * @returns {Boolean} Indicates whether the subject has observers subscribed to it.\n */\n hasObservers: function () { return this.observers.length > 0; },\n /**\n * Notifies all subscribed observers about the end of the sequence.\n */\n onCompleted: function () {\n checkDisposed(this);\n if (!this.isStopped) {\n this.isStopped = true;\n for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) {\n os[i].onCompleted();\n }\n\n this.observers.length = 0;\n }\n },\n /**\n * Notifies all subscribed observers about the exception.\n * @param {Mixed} error The exception to send to all observers.\n */\n onError: function (error) {\n checkDisposed(this);\n if (!this.isStopped) {\n this.isStopped = true;\n this.error = error;\n this.hasError = true;\n for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) {\n os[i].onError(error);\n }\n\n this.observers.length = 0;\n }\n },\n /**\n * Notifies all subscribed observers about the arrival of the specified element in the sequence.\n * @param {Mixed} value The value to send to all observers.\n */\n onNext: function (value) {\n checkDisposed(this);\n if (!this.isStopped) {\n for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) {\n os[i].onNext(value);\n }\n }\n },\n /**\n * Unsubscribe all observers and release resources.\n */\n dispose: function () {\n this.isDisposed = true;\n this.observers = null;\n }\n });\n\n /**\n * Creates a subject from the specified observer and observable.\n * @param {Observer} observer The observer used to send messages to the subject.\n * @param {Observable} observable The observable used to subscribe to messages sent from the subject.\n * @returns {Subject} Subject implemented using the given observer and observable.\n */\n Subject.create = function (observer, observable) {\n return new AnonymousSubject(observer, observable);\n };\n\n return Subject;\n }(Observable));\n\r\n /**\n * Represents the result of an asynchronous operation.\n * The last value before the OnCompleted notification, or the error received through OnError, is sent to all subscribed observers.\n */\n var AsyncSubject = Rx.AsyncSubject = (function (__super__) {\n\n function subscribe(observer) {\n checkDisposed(this);\n\n if (!this.isStopped) {\n this.observers.push(observer);\n return new InnerSubscription(this, observer);\n }\n\n if (this.hasError) {\n observer.onError(this.error);\n } else if (this.hasValue) {\n observer.onNext(this.value);\n observer.onCompleted();\n } else {\n observer.onCompleted();\n }\n\n return disposableEmpty;\n }\n\n inherits(AsyncSubject, __super__);\n\n /**\n * Creates a subject that can only receive one value and that value is cached for all future observations.\n * @constructor\n */\n function AsyncSubject() {\n __super__.call(this, subscribe);\n\n this.isDisposed = false;\n this.isStopped = false;\n this.hasValue = false;\n this.observers = [];\n this.hasError = false;\n }\n\n addProperties(AsyncSubject.prototype, Observer, {\n /**\n * Indicates whether the subject has observers subscribed to it.\n * @returns {Boolean} Indicates whether the subject has observers subscribed to it.\n */\n hasObservers: function () {\n checkDisposed(this);\n return this.observers.length > 0;\n },\n /**\n * Notifies all subscribed observers about the end of the sequence, also causing the last received value to be sent out (if any).\n */\n onCompleted: function () {\n var i, len;\n checkDisposed(this);\n if (!this.isStopped) {\n this.isStopped = true;\n var os = cloneArray(this.observers), len = os.length;\n\n if (this.hasValue) {\n for (i = 0; i < len; i++) {\n var o = os[i];\n o.onNext(this.value);\n o.onCompleted();\n }\n } else {\n for (i = 0; i < len; i++) {\n os[i].onCompleted();\n }\n }\n\n this.observers.length = 0;\n }\n },\n /**\n * Notifies all subscribed observers about the error.\n * @param {Mixed} error The Error to send to all observers.\n */\n onError: function (error) {\n checkDisposed(this);\n if (!this.isStopped) {\n this.isStopped = true;\n this.hasError = true;\n this.error = error;\n\n for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) {\n os[i].onError(error);\n }\n\n this.observers.length = 0;\n }\n },\n /**\n * Sends a value to the subject. The last value received before successful termination will be sent to all subscribed and future observers.\n * @param {Mixed} value The value to store in the subject.\n */\n onNext: function (value) {\n checkDisposed(this);\n if (this.isStopped) { return; }\n this.value = value;\n this.hasValue = true;\n },\n /**\n * Unsubscribe all observers and release resources.\n */\n dispose: function () {\n this.isDisposed = true;\n this.observers = null;\n this.exception = null;\n this.value = null;\n }\n });\n\n return AsyncSubject;\n }(Observable));\n\r\n var AnonymousSubject = Rx.AnonymousSubject = (function (__super__) {\n inherits(AnonymousSubject, __super__);\n\n function subscribe(observer) {\n return this.observable.subscribe(observer);\n }\n\n function AnonymousSubject(observer, observable) {\n this.observer = observer;\n this.observable = observable;\n __super__.call(this, subscribe);\n }\n\n addProperties(AnonymousSubject.prototype, Observer.prototype, {\n onCompleted: function () {\n this.observer.onCompleted();\n },\n onError: function (error) {\n this.observer.onError(error);\n },\n onNext: function (value) {\n this.observer.onNext(value);\n }\n });\n\n return AnonymousSubject;\n }(Observable));\n\r\n /**\n * Used to pause and resume streams.\n */\n Rx.Pauser = (function (__super__) {\n inherits(Pauser, __super__);\n\n function Pauser() {\n __super__.call(this);\n }\n\n /**\n * Pauses the underlying sequence.\n */\n Pauser.prototype.pause = function () { this.onNext(false); };\n\n /**\n * Resumes the underlying sequence.\n */\n Pauser.prototype.resume = function () { this.onNext(true); };\n\n return Pauser;\n }(Subject));\n\r\n if (true) {\n root.Rx = Rx;\n\n !(__WEBPACK_AMD_DEFINE_RESULT__ = function() {\n return Rx;\n }.call(exports, __webpack_require__, exports, module), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));\n } else if (freeExports && freeModule) {\n // in Node.js or RingoJS\n if (moduleExports) {\n (freeModule.exports = Rx).Rx = Rx;\n } else {\n freeExports.Rx = Rx;\n }\n } else {\n // in a browser or Rhino\n root.Rx = Rx;\n }\n\r\n // All code before this point will be filtered from stack traces.\n var rEndingLine = captureLine();\n\r\n}.call(this));\n\n/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(5)(module), (function() { return this; }()), __webpack_require__(6)))\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/rx-dom/~/rx/dist/rx.all.js\n ** module id = 118\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./~/rx-dom/~/rx/dist/rx.all.js?");
  10. },function(module,exports,__webpack_require__){eval("var Rx = __webpack_require__(2).Rx;\n\nmodule.exports = function(outgoing$) {\n outgoing$.subscribe(function(newHash) {\n window.location.hash = newHash;\n });\n return Rx.Observable.fromEvent(window, 'hashchange')\n .map(function(hashEvent) { return hashEvent.target.location.hash.replace('#', '') })\n .startWith(window.location.hash.replace('#', '') || '')\n}\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./assets/drivers/hashDriver.js\n ** module id = 119\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./assets/drivers/hashDriver.js?")},function(module,exports,__webpack_require__){eval("var RxDOM = __webpack_require__(117).DOM;\nvar _ = __webpack_require__(116);\nvar util = __webpack_require__(1);\n\nfunction byVal(val) {\n return function(msg) {\n return msg === val;\n }\n}\n\nfunction byKind(kind) {\n return function(msg) {\n return msg.kind === kind;\n }\n}\n\nfunction makeid() {\n var text = \"\";\n var possible = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789\";\n\n for( var i=0; i < 5; i++ )\n text += possible.charAt(Math.floor(Math.random() * possible.length));\n\n return text;\n}\n\nfunction connect(username$, room$, outgoing$) {\n var currRoom$ = room$.map(function(room) {\n return room || makeid();\n }).distinctUntilChanged().shareReplay(1);\n\n var details$ = username$.withLatestFrom(currRoom$, function(username, room) {\n return {\n username: username,\n room: room\n }\n });\n\n var nullSubject = Rx.Subject.create(Rx.Observer.create(), Rx.Observable.empty());\n\n var connection$ = details$\n .map(function(params) {\n if(params.username == null) {\n return { ws$: nullSubject, open$: nullSubject }\n }\n\n var url = jsRoutes.controllers.Application.chat(params.username, params.room).webSocketURL();\n var open = new Rx.Subject();\n return {\n ws$: RxDOM.fromWebSocket(url, 'chat', open.asObserver()),\n open$: open.map(function() { return 'connected' }).startWith('connecting')\n };\n }).share();\n\n var ws$ = connection$\n .flatMapLatest(function(conn) {\n return conn.ws$\n .map(function(ev) { return JSON.parse(ev.data) })\n .onErrorResumeNext(Rx.Observable.just({kind: 'disconnected'}));\n })\n .share();\n\n connection$.subscribe(function(conn) {\n outgoing$.subscribe(conn.ws$.asObserver());\n });\n\n var status$ = ws$\n .filter(byKind('disconnected'))\n .map(function() { return 'disconnected' })\n .merge(connection$.flatMapLatest(function(conn) { return conn.open$ }))\n .startWith('disconnected')\n .distinctUntilChanged()\n\n var error$ = ws$\n .map(function(msg) { return msg.error })\n .filter(_.isString)\n .merge(status$.filter(byVal('connecting')).map(function() { return '' }))\n .startWith('')\n\n return {\n ws$: ws$,\n details$: details$,\n status$: status$,\n error$: error$\n };\n}\n\nmodule.exports = {\n connect: connect\n}\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./assets/services/chat.js\n ** module id = 120\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./assets/services/chat.js?")},function(module,exports,__webpack_require__){eval("var _ = __webpack_require__(116);\nvar util = __webpack_require__(1);\n\nmodule.exports = function(drivers) {\n var DOM = drivers.DOM;\n\n function input(elem) {\n return DOM.get('#'+elem, 'input').map(function(ev) { return ev.target.value }).startWith('');\n }\n\n var labels = ['inputWord'].concat([0,1,2,3,4].map(function(item) { return 'taboo'+item }));\n var streams = labels.map(input);\n\n var textFields$ = util.asObject(_.zipObject(labels, streams));\n\n var submit$ = DOM.get('#cardForm', 'submit').doOnNext(function(ev) { ev.preventDefault() });\n var form$ = util.sync(submit$, textFields$);\n\n return {\n fields$: textFields$,\n form$: form$\n };\n}\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./assets/intents/contribute.js\n ** module id = 121\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./assets/intents/contribute.js?")},function(module,exports,__webpack_require__){eval('var map = {\n "./about": 123,\n "./about.js": 123,\n "./chatRoom": 124,\n "./chatRoom.js": 124,\n "./contribute": 125,\n "./contribute.js": 125\n};\nfunction webpackContext(req) {\n return __webpack_require__(webpackContextResolve(req));\n};\nfunction webpackContextResolve(req) {\n return map[req] || (function() { throw new Error("Cannot find module \'" + req + "\'.") }());\n};\nwebpackContext.keys = function webpackContextKeys() {\n return Object.keys(map);\n};\nwebpackContext.resolve = webpackContextResolve;\nmodule.exports = webpackContext;\nwebpackContext.id = 122;\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./assets/templates ^\\.\\/.*$\n ** module id = 122\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./assets/templates_^\\.\\/.*$?')},function(module,exports,__webpack_require__){eval('var h = __webpack_require__(2).h;\n\nmodule.exports = function() {\n\nreturn (\nh("div", [\n h("div.jumbotron", [\n h("h1", [ "Game n\' Chat" ]),\n h("p", [\n "Play games in a chatroom like it\'s the 2000s! Bringing IRC gaming to ",\n "Web 2.0!"\n ])\n ]),\n h("div.row", [\n h("div.col-md-8", [\n h("h2", [ "Taboo" ]),\n h("p", [\n "Taboo is a party game for around 4 to 10 people split into 2 teams. Each ",\n "round, a player from a team becomes the ", h("em", [ "giver" ]), " and the rest of the ",\n "team become ", h("em", [ "guessers" ]), ". The opposing team act as ", h("em", [ "monitors" ]), "."\n ]),\n h("p", [\n "The ", h("em", [ "giver" ]), " is given a card containing a word and 5 taboo words. The ",\n "giver must somehow tell the ", h("em", [ "guessers" ]), " about the word without mentioning ",\n "the word itself or any of the 5 taboo words. The ", h("em", [ "monitors" ]), " act as ",\n "judges to see if any of the words said are not allowed."\n ]),\n h("p", [\n "If a guesser gets the word right, the team earns a point. If the giver says ",\n "any taboo word, the team loses a point. The giver may also choose to pass ",\n "and the team also loses a point. The giver is then given another card and ",\n "this continues until the round time runs out."\n ]),\n h("h3", [ "Additional notes" ]),\n h("p", [\n "When there are enough players, the giver is announced and he can start the ",\n "game by pressing the Start button. Normally, taboo rounds are 1 minute long, ",\n "but we extend it to 2 minutes because of the time it takes to type things."\n ]),\n h("p", [\n "The system can rudimentarily act as a monitor itself. If the giver types out ",\n "any of the taboo words verbatim, the system immediately calls taboo on those. ",\n "It can also check if the word was guessed correctly assuming it was spelled ",\n "correctly. For all other cases, we will rely on the monitors and the giver ",\n "to act in good faith."\n ]),\n h("p", [\n "To facilitate faster playing, there are some command you can just type in:"\n ]),\n h("ul", [\n h("li", [ h("code", [ "/s" ]), " - Start the round" ]),\n h("li", [ h("code", [ "/p" ]), " - Pass" ]),\n h("li", [ h("code", [ "/c" ]), " - Correct (someone got the word)" ]),\n h("li", [ h("code", [ "/t" ]), " - Taboo" ])\n ])\n ]),\n h("div#main.col-md-4.sidebar", [\n h("h2", [ "What is this?" ]),\n h("p", [\n "Hi! This is just a side project I made where you can play Taboo online. ",\n "I liked playing it with my friends during our Christmas party and I wanted ",\n "to play a bit more."\n ]),\n h("p", [\n "Feature-wise, it\'s a bit sparse. There\'s no score tracking beyond a single ",\n "round, but it should at least have the core game mechanics ok. UI/UX could ",\n "also use a lot of work. I\'m also leaving the prospect of adding more games ",\n "open. Like maybe Pinoy Henyo or whatever."\n ]),\n h("p", [\n "Also, while the website is responsive now, you still can\'t play on mobile ",\n "because I don\'t know how to layout the game such that it works."\n ]),\n h("p", [\n "There aren\'t that many words yet, and I\'d greatly appreciate contributing ",\n "some for the game. There\'s also an API for accessing the word list in case ",\n "you want to build your own Taboo-like thing. ", h("code", [ "GET /cards" ]), " should ",\n "give you the entire card list, while ", h("code", [ "GET /cards/random" ]), " will ",\n "give you a random card each time."\n ]),\n h("p", [\n "Obligatory note, I do not own the rights to the Taboo board game. The card ",\n "data was made by me and any contributors. I did not use any of the Taboo cards ",\n "as a source for them."\n ])\n ])\n ])\n])\n);\n}\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./assets/templates/about.js\n ** module id = 123\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./assets/templates/about.js?')},function(module,exports,__webpack_require__){eval('var h = __webpack_require__(2).h;\nvar util = __webpack_require__(1);\nvar cx = util.classNames;\n\nfunction renderLogin(props) {\n var disconnected = props.status === \'disconnected\';\n var error = props.error;\n var hasRoom = props.room != null;\n return (\n h("div.row", [\n error ? h("div.alert.alert-danger", [\n h("strong", [ "Oops!" ]), \' \' + error + "."\n ]) : null,\n h("div#login", [\n disconnected ? h("form.form-inline#login-form", [\n h("input#username.form-control", {\n "name": "username",\n "type": "text",\n "placeholder": "Username"\n }),\n h("br"),\n h("br"),\n h("button.btn", { "type": "submit" }, [ hasRoom ? \'Join Room\' : \'Create New Room\' ])\n ]) : null\n ])\n ])\n )\n}\n\nfunction renderChat(props) {\n var height = window.innerHeight - 300;\n var element = document.getElementById(\'messages\');\n var scrollTop = util.propHook(function(node) {\n setTimeout(function() {\n node.scrollTop = node.scrollHeight;\n }, 100);\n });\n var messages = props.messages;\n return (\n h("div#main.col-md-9", [\n h("div#messages", { scrollTop: scrollTop, style: { height: height+\'px\' } }, [\n h("table", messages.map(function(message) {\n var classes = cx(\'message\', message.kind, {\n me: message.user === props.username\n });\n return h("tr"+classes, [\n h("td.user", [ message.user ]),\n h("td", [ message.message ])\n ]);\n }))\n ]),\n h("input#talk.form-control", {\n "type": "text",\n "value": props.chat\n })\n ])\n )\n}\n\nfunction renderSidebar() {\n return (\n h("div.col-md-3", {\n "ng-controller": "GameCtrl"\n }, [\n h("button.btn.btn-primary", {\n "ng-show": "game.pendingRound",\n "ng-click": "game.startRound()"\n }, [ "Start" ]),\n h("div", {\n "ng-if": "game.roundRunning()"\n }, [\n h("h2", [ h("ng-pluralize", {\n "count": "game.timer.count",\n "when": "{\'0\': \'Time\\\\\'s up!\', \'one\': \'1 second\', \'other\': \'{} seconds\'}"\n }) ]),\n h("h2", [ h("ng-pluralize", {\n "count": "game.points",\n "when": "{\'one\': \'1 point\', \'other\': \'{} points\'}"\n }) ]),\n h("hr")\n ]),\n h("div", {\n "ng-if": "game.roundRunning()"\n }, [\n h("h3", {\n "ng-show": "game.isPlayer()"\n }, [ "you are the giver" ]),\n h("h3", { "ng-show": "game.isMonitor()"\n }, [ "you are a monitor" ]),\n h("h3", {\n "ng-show": "game.isGuesser()"\n }, [ "you are a guesser" ]),\n h("button.btn.btn-warning", {\n "ng-show": "game.isPlayer()",\n "ng-click": "game.pass()"\n }, [ "Pass" ]),\n h("button.btn.btn-danger", {\n "ng-show": "game.isMonitor()",\n "ng-click": "game.taboo()"\n }, [ "Uh-uh!" ]),\n h("button.btn.btn-success", {\n "ng-show": "game.isMonitor() || game.isPlayer()",\n "ng-click": "game.correct()"\n }, [ "Correct" ])\n ]),\n h("div", {\n "ng-show": "game.card"\n }, [\n h("h2", [ "Card" ]),\n h("h3", [ "{{game.card.word}}" ]),\n h("ul.taboo", [\n h("li", {\n "ng-repeat": "word in game.card.taboo"\n }, [ "{{word}}" ])\n ])\n ]),\n h("h2", [ "Team A" ]),\n h("ul.members", [\n h("li", {\n "ng-repeat": "member in game.teamA.members"\n }, [ "{{member}}" ])\n ]),\n h("h2", [ "Team B" ]),\n h("ul.members", [\n h("li", {\n "ng-repeat": "member in game.teamB.members"\n }, [ "{{member}}" ])\n ])\n ])\n )\n}\n\nfunction renderMain(props) {\n return h("div.row", [\n renderChat(props)\n ])\n}\n\nmodule.exports = function(props) {\n var isConnected = props.status === \'connected\';\n return (\n h("div", [\n h("div.page-header", [\n h("h1", isConnected ?\n [ "Welcome ", h("small", [ "You are playing as "+props.username ]) ]\n :\n [ "Welcome ", h("small", [ "login to play" ]) ]\n )\n ]),\n isConnected ? renderMain(props) : renderLogin(props)\n ])\n );\n}\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./assets/templates/chatRoom.js\n ** module id = 124\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./assets/templates/chatRoom.js?')},function(module,exports,__webpack_require__){eval('var h = __webpack_require__(2).h;\n\nmodule.exports = function(props) {\n var submitting = false;\n var exists = false;\n var thanks = false;\n return (\nh("div", [\n h("div.page-header", [\n h("h1", [ "Contribute" ])\n ]),\n h("div.row", [\n h("div#main.col-md-8", [\n h("h3", [ "Add a card" ]),\n h("p", [\n "Help make the game! Contribute words and make the game better. Also, please ",\n "original work only. Don\'t just blindly copy a card from any of the Taboo games."\n ]),\n h("form#cardForm", { "role": "form" }, [\n h("div.form-group", [\n h("label", { "htmlFor": "inputWord" }, [ "Word" ]),\n h("input#inputWord.form-control", {\n "type": "text",\n "placeholder": "Word",\n "required": "true"\n }),\n exists ? h("span", [ "We already have this word" ]) : null\n ]),\n h("div.form-group",\n [ h("label", [ "Taboo Words" ]) ]\n .concat([0,1,2,3,4].map(function(item) {\n return h(\'input.form-control\', {\n id: \'taboo\'+item,\n type: \'text\',\n placeholder: \'Taboo Word\',\n value: props.contribute[\'taboo\'+item],\n required: true\n });\n }))\n ),\n h("input.btn.btn-primary", {\n "disabled": submitting,\n "type": "submit",\n "value": submitting ? \'Submitting...\' : \'Submit\'\n }),\n thanks ? h("span", [ "Thank you!" ]) : null\n ])\n ]),\n h("div.col-md-4.sidebar", [\n h("h3", [ "Help code" ]),\n h("p", [\n "Want to help code instead? Fork the ", h("a", {\n "href": "https://github.com/thatsmydoing/gamenchat"\n }, [ "repo" ]), " or submit ",\n "an ", h("a", {\n "href": "https://github.com/thatsmydoing/gamenchat/issues"\n }, [ "issue" ]), "."\n ]),\n h("h3", [ "Help design" ]),\n h("p", [\n "Yes, it\'s bootstrap. Not even custom colors. If you like it, maybe you can make it look nicer."\n ])\n ])\n ])\n])\n )\n}\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./assets/templates/contribute.js\n ** module id = 125\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./assets/templates/contribute.js?')}]);