box-chrome-sdk
Version:
A Chrome App SDK for the Box V2 API
1 lines • 27.6 kB
JavaScript
(function(t){function e(){if(this.isDisposed)throw Error(A)}function n(t){var e=typeof t;return t&&("function"==e||"object"==e)||!1}function i(t){var e=[];if(!n(t))return e;G.nonEnumArgs&&t.length&&u(t)&&(t=U.call(t));var i=G.enumPrototypes&&"function"==typeof t,r=G.enumErrorProps&&(t===H||t instanceof Error);for(var s in t)i&&"prototype"==s||r&&("message"==s||"name"==s)||e.push(s);if(G.nonEnumShadows&&t!==L){var o=t.constructor,c=-1,h=K.length;if(t===(o&&o.prototype))var a=t===stringProto?M:t===H?N:F.call(t),l=Q[a];for(;h>++c;)s=K[c],l&&l[s]||!z.call(t,s)||e.push(s)}return e}function r(t,e,n){for(var i=-1,r=n(t),s=r.length;s>++i;){var o=r[i];if(e(t[o],o,t)===!1)break}return t}function s(t,e){return r(t,e,i)}function o(t){return"function"!=typeof t.toString&&"string"==typeof(t+"")}function u(t){return t&&"object"==typeof t?F.call(t)==j:!1}function c(t){return"function"==typeof t||!1}function h(e,n,i,r){if(e===n)return 0!==e||1/e==1/n;var a=typeof e,l=typeof n;if(e===e&&(null==e||null==n||"function"!=a&&"object"!=a&&"function"!=l&&"object"!=l))return!1;var p=F.call(e),f=F.call(n);if(p==j&&(p=T),f==j&&(f=T),p!=f)return!1;switch(p){case W:case P:return+e==+n;case k:return e!=+e?n!=+n:0==e?1/e==1/n:e==+n;case I:case M:return e==n+""}var d=p==C;if(!d){if(p!=T||!G.nodeClass&&(o(e)||o(n)))return!1;var v=!G.argsObject&&u(e)?Object:e.constructor,b=!G.argsObject&&u(n)?Object:n.constructor;if(!(v==b||z.call(e,"constructor")&&z.call(n,"constructor")||c(v)&&v instanceof v&&c(b)&&b instanceof b||!("constructor"in e&&"constructor"in n)))return!1}i||(i=[]),r||(r=[]);for(var y=i.length;y--;)if(i[y]==e)return r[y]==n;var m=0;if(result=!0,i.push(e),r.push(n),d){if(y=e.length,m=n.length,result=m==y)for(;m--;){var g=n[m];if(!(result=h(e[m],g,i,r)))break}}else s(n,function(n,s,o){return z.call(o,s)?(m++,result=z.call(e,s)&&h(e[s],n,i,r)):t}),result&&s(e,function(e,n,i){return z.call(i,n)?result=--m>-1:t});return i.pop(),r.pop(),result}function a(t,e){return 1===t.length&&Array.isArray(t[e])?t[e]:U.call(t)}function l(t,e){this.scheduler=t,this.disposable=e,this.isDisposed=!1}var p={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1},f=p[typeof window]&&window||this,d=p[typeof exports]&&exports&&!exports.nodeType&&exports,v=p[typeof module]&&module&&!module.nodeType&&module,b=v&&v.exports===d&&d,y=p[typeof global]&&global;!y||y.global!==y&&y.window!==y||(f=y);var m={internals:{},config:{Promise:f.Promise},helpers:{}},g=m.helpers.noop=function(){},w=m.helpers.identity=function(t){return t},S=(m.helpers.pluck=function(t){return function(e){return e[t]}},m.helpers.just=function(t){return function(){return t}},m.helpers.defaultNow=function(){return Date.now?Date.now:function(){return+new Date}}()),_=(m.helpers.defaultComparer=function(t,e){return J(t,e)},m.helpers.defaultSubComparer=function(t,e){return t>e?1:e>t?-1:0}),D=(m.helpers.defaultKeySerializer=function(t){return""+t},m.helpers.defaultError=function(t){throw t}),x=m.helpers.isPromise=function(t){return!!t&&"function"==typeof t.then&&t.then!==m.Observable.prototype.then};m.helpers.asArray=function(){return Array.prototype.slice.call(arguments)},m.helpers.not=function(t){return!t};var A="Object has been disposed",E="object"==typeof Symbol&&Symbol.iterator||"_es6shim_iterator_";f.Set&&"function"==typeof(new f.Set)["@@iterator"]&&(E="@@iterator");var O,R={done:!0,value:t},j="[object Arguments]",C="[object Array]",W="[object Boolean]",P="[object Date]",N="[object Error]",q="[object Function]",k="[object Number]",T="[object Object]",I="[object RegExp]",M="[object String]",F=Object.prototype.toString,z=Object.prototype.hasOwnProperty,V=F.call(arguments)==j,H=Error.prototype,L=Object.prototype,$=L.propertyIsEnumerable;try{O=!(F.call(document)==T&&!({toString:0}+""))}catch(B){O=!0}var K=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],Q={};Q[C]=Q[P]=Q[k]={constructor:!0,toLocaleString:!0,toString:!0,valueOf:!0},Q[W]=Q[M]={constructor:!0,toString:!0,valueOf:!0},Q[N]=Q[q]=Q[I]={constructor:!0,toString:!0},Q[T]={constructor:!0};var G={};(function(){var t=function(){this.x=1},e=[];t.prototype={valueOf:1,y:1};for(var n in new t)e.push(n);for(n in arguments);G.enumErrorProps=$.call(H,"message")||$.call(H,"name"),G.enumPrototypes=$.call(t,"prototype"),G.nonEnumArgs=0!=n,G.nonEnumShadows=!/valueOf/.test(e)})(1),V||(u=function(t){return t&&"object"==typeof t?z.call(t,"callee"):!1}),c(/x/)&&(c=function(t){return"function"==typeof t&&F.call(t)==q});var J=m.internals.isEqual=function(t,e){return h(t,e,[],[])},U=Array.prototype.slice;({}).hasOwnProperty;var X=this.inherits=m.internals.inherits=function(t,e){function n(){this.constructor=t}n.prototype=e.prototype,t.prototype=new n},Y=m.internals.addProperties=function(t){for(var e=U.call(arguments,1),n=0,i=e.length;i>n;n++){var r=e[n];for(var s in r)t[s]=r[s]}};m.internals.addRef=function(t,e){return new ke(function(n){return new re(e.getDisposable(),t.subscribe(n))})},Function.prototype.bind||(Function.prototype.bind=function(t){var e=this,n=U.call(arguments,1),i=function(){function r(){}if(this instanceof i){r.prototype=e.prototype;var s=new r,o=e.apply(s,n.concat(U.call(arguments)));return Object(o)===o?o:s}return e.apply(t,n.concat(U.call(arguments)))};return i});var Z=Object("a"),te="a"!=Z[0]||!(0 in Z);Array.prototype.every||(Array.prototype.every=function(t){var e=Object(this),n=te&&{}.toString.call(this)==M?this.split(""):e,i=n.length>>>0,r=arguments[1];if({}.toString.call(t)!=q)throw new TypeError(t+" is not a function");for(var s=0;i>s;s++)if(s in n&&!t.call(r,n[s],s,e))return!1;return!0}),Array.prototype.map||(Array.prototype.map=function(t){var e=Object(this),n=te&&{}.toString.call(this)==M?this.split(""):e,i=n.length>>>0,r=Array(i),s=arguments[1];if({}.toString.call(t)!=q)throw new TypeError(t+" is not a function");for(var o=0;i>o;o++)o in n&&(r[o]=t.call(s,n[o],o,e));return r}),Array.prototype.filter||(Array.prototype.filter=function(t){for(var e,n=[],i=Object(this),r=0,s=i.length>>>0;s>r;r++)e=i[r],r in i&&t.call(arguments[1],e,r,i)&&n.push(e);return n}),Array.isArray||(Array.isArray=function(t){return Object.prototype.toString.call(t)==C}),Array.prototype.indexOf||(Array.prototype.indexOf=function(t){var e=Object(this),n=e.length>>>0;if(0===n)return-1;var i=0;if(arguments.length>1&&(i=Number(arguments[1]),i!==i?i=0:0!==i&&1/0!=i&&i!==-1/0&&(i=(i>0||-1)*Math.floor(Math.abs(i)))),i>=n)return-1;for(var r=i>=0?i:Math.max(n-Math.abs(i),0);n>r;r++)if(r in e&&e[r]===t)return r;return-1});var ee=function(t,e){this.id=t,this.value=e};ee.prototype.compareTo=function(t){var e=this.value.compareTo(t.value);return 0===e&&(e=this.id-t.id),e};var ne=m.internals.PriorityQueue=function(t){this.items=Array(t),this.length=0},ie=ne.prototype;ie.isHigherPriority=function(t,e){return 0>this.items[t].compareTo(this.items[e])},ie.percolate=function(t){if(!(t>=this.length||0>t)){var e=t-1>>1;if(!(0>e||e===t)&&this.isHigherPriority(t,e)){var n=this.items[t];this.items[t]=this.items[e],this.items[e]=n,this.percolate(e)}}},ie.heapify=function(e){if(e===t&&(e=0),!(e>=this.length||0>e)){var n=2*e+1,i=2*e+2,r=e;if(this.length>n&&this.isHigherPriority(n,r)&&(r=n),this.length>i&&this.isHigherPriority(i,r)&&(r=i),r!==e){var s=this.items[e];this.items[e]=this.items[r],this.items[r]=s,this.heapify(r)}}},ie.peek=function(){return this.items[0].value},ie.removeAt=function(t){this.items[t]=this.items[--this.length],delete this.items[this.length],this.heapify()},ie.dequeue=function(){var t=this.peek();return this.removeAt(0),t},ie.enqueue=function(t){var e=this.length++;this.items[e]=new ee(ne.count++,t),this.percolate(e)},ie.remove=function(t){for(var e=0;this.length>e;e++)if(this.items[e].value===t)return this.removeAt(e),!0;return!1},ne.count=0;var re=m.CompositeDisposable=function(){this.disposables=a(arguments,0),this.isDisposed=!1,this.length=this.disposables.length},se=re.prototype;se.add=function(t){this.isDisposed?t.dispose():(this.disposables.push(t),this.length++)},se.remove=function(t){var e=!1;if(!this.isDisposed){var n=this.disposables.indexOf(t);-1!==n&&(e=!0,this.disposables.splice(n,1),this.length--,t.dispose())}return e},se.dispose=function(){if(!this.isDisposed){this.isDisposed=!0;var t=this.disposables.slice(0);this.disposables=[],this.length=0;for(var e=0,n=t.length;n>e;e++)t[e].dispose()}},se.clear=function(){var t=this.disposables.slice(0);this.disposables=[],this.length=0;for(var e=0,n=t.length;n>e;e++)t[e].dispose()},se.contains=function(t){return-1!==this.disposables.indexOf(t)},se.toArray=function(){return this.disposables.slice(0)};var oe=m.Disposable=function(t){this.isDisposed=!1,this.action=t||g};oe.prototype.dispose=function(){this.isDisposed||(this.action(),this.isDisposed=!0)};var ue=oe.create=function(t){return new oe(t)},ce=oe.empty={dispose:g},he=function(){function t(t){this.isSingle=t,this.isDisposed=!1,this.current=null}var e=t.prototype;return e.getDisposable=function(){return this.current},e.setDisposable=function(t){if(this.current&&this.isSingle)throw Error("Disposable has already been assigned");var e,n=this.isDisposed;n||(e=this.current,this.current=t),e&&e.dispose(),n&&t&&t.dispose()},e.dispose=function(){var t;this.isDisposed||(this.isDisposed=!0,t=this.current,this.current=null),t&&t.dispose()},t}(),ae=m.SingleAssignmentDisposable=function(t){function e(){t.call(this,!0)}return X(e,t),e}(he),le=m.SerialDisposable=function(t){function e(){t.call(this,!1)}return X(e,t),e}(he);m.RefCountDisposable=function(){function t(t){this.disposable=t,this.disposable.count++,this.isInnerDisposed=!1}function e(t){this.underlyingDisposable=t,this.isDisposed=!1,this.isPrimaryDisposed=!1,this.count=0}return t.prototype.dispose=function(){this.disposable.isDisposed||this.isInnerDisposed||(this.isInnerDisposed=!0,this.disposable.count--,0===this.disposable.count&&this.disposable.isPrimaryDisposed&&(this.disposable.isDisposed=!0,this.disposable.underlyingDisposable.dispose()))},e.prototype.dispose=function(){this.isDisposed||this.isPrimaryDisposed||(this.isPrimaryDisposed=!0,0===this.count&&(this.isDisposed=!0,this.underlyingDisposable.dispose()))},e.prototype.getDisposable=function(){return this.isDisposed?ce:new t(this)},e}(),l.prototype.dispose=function(){var t=this;this.scheduler.schedule(function(){t.isDisposed||(t.isDisposed=!0,t.disposable.dispose())})};var pe=m.internals.ScheduledItem=function(t,e,n,i,r){this.scheduler=t,this.state=e,this.action=n,this.dueTime=i,this.comparer=r||_,this.disposable=new ae};pe.prototype.invoke=function(){this.disposable.setDisposable(this.invokeCore())},pe.prototype.compareTo=function(t){return this.comparer(this.dueTime,t.dueTime)},pe.prototype.isCancelled=function(){return this.disposable.isDisposed},pe.prototype.invokeCore=function(){return this.action(this.scheduler,this.state)};var fe=m.Scheduler=function(){function t(t,e,n,i){this.now=t,this._schedule=e,this._scheduleRelative=n,this._scheduleAbsolute=i}function e(t,e){var n=e.first,i=e.second,r=new re,s=function(e){i(e,function(e){var n=!1,i=!1,o=t.scheduleWithState(e,function(t,e){return n?r.remove(o):i=!0,s(e),ce});i||(r.add(o),n=!0)})};return s(n),r}function n(t,e,n){var i=e.first,r=e.second,s=new re,o=function(e){r(e,function(e,i){var r=!1,u=!1,c=t[n].call(t,e,i,function(t,e){return r?s.remove(c):u=!0,o(e),ce});u||(s.add(c),r=!0)})};return o(i),s}function i(t,e){return e(),ce}var r=t.prototype;return r.catchException=r["catch"]=function(t){return new ge(this,t)},r.schedulePeriodic=function(t,e){return this.schedulePeriodicWithState(null,t,function(){e()})},r.schedulePeriodicWithState=function(t,e,n){var i=t,r=setInterval(function(){i=n(i)},e);return ue(function(){clearInterval(r)})},r.schedule=function(t){return this._schedule(t,i)},r.scheduleWithState=function(t,e){return this._schedule(t,e)},r.scheduleWithRelative=function(t,e){return this._scheduleRelative(e,t,i)},r.scheduleWithRelativeAndState=function(t,e,n){return this._scheduleRelative(t,e,n)},r.scheduleWithAbsolute=function(t,e){return this._scheduleAbsolute(e,t,i)},r.scheduleWithAbsoluteAndState=function(t,e,n){return this._scheduleAbsolute(t,e,n)},r.scheduleRecursive=function(t){return this.scheduleRecursiveWithState(t,function(t,e){t(function(){e(t)})})},r.scheduleRecursiveWithState=function(t,n){return this.scheduleWithState({first:t,second:n},function(t,n){return e(t,n)})},r.scheduleRecursiveWithRelative=function(t,e){return this.scheduleRecursiveWithRelativeAndState(e,t,function(t,e){t(function(n){e(t,n)})})},r.scheduleRecursiveWithRelativeAndState=function(t,e,i){return this._scheduleRelative({first:t,second:i},e,function(t,e){return n(t,e,"scheduleWithRelativeAndState")})},r.scheduleRecursiveWithAbsolute=function(t,e){return this.scheduleRecursiveWithAbsoluteAndState(e,t,function(t,e){t(function(n){e(t,n)})})},r.scheduleRecursiveWithAbsoluteAndState=function(t,e,i){return this._scheduleAbsolute({first:t,second:i},e,function(t,e){return n(t,e,"scheduleWithAbsoluteAndState")})},t.now=S,t.normalize=function(t){return 0>t&&(t=0),t},t}(),de=fe.normalize;m.internals.SchedulePeriodicRecursive=function(){function t(t,e){e(0,this._period);try{this._state=this._action(this._state)}catch(n){throw this._cancel.dispose(),n}}function e(t,e,n,i){this._scheduler=t,this._state=e,this._period=n,this._action=i}return e.prototype.start=function(){var e=new ae;return this._cancel=e,e.setDisposable(this._scheduler.scheduleRecursiveWithRelativeAndState(0,this._period,t.bind(this))),e},e}();var ve,be=fe.immediate=function(){function t(t,e){return e(this,t)}function e(t,e,n){for(var i=de(i);i-this.now()>0;);return n(this,t)}function n(t,e,n){return this.scheduleWithRelativeAndState(t,e-this.now(),n)}return new fe(S,t,e,n)}(),ye=fe.currentThread=function(){function t(t){for(var e;t.length>0;)if(e=t.dequeue(),!e.isCancelled()){for(;e.dueTime-fe.now()>0;);e.isCancelled()||e.invoke()}}function e(t,e){return this.scheduleWithRelativeAndState(t,0,e)}function n(e,n,i){var s=this.now()+fe.normalize(n),o=new pe(this,e,i,s);if(r)r.enqueue(o);else{r=new ne(4),r.enqueue(o);try{t(r)}catch(u){throw u}finally{r=null}}return o.disposable}function i(t,e,n){return this.scheduleWithRelativeAndState(t,e-this.now(),n)}var r,s=new fe(S,e,n,i);return s.scheduleRequired=function(){return null===r},s.ensureTrampoline=function(t){return null===r?this.schedule(t):t()},s}(),me=g;(function(){function t(){if(!f.postMessage||f.importScripts)return!1;var t=!1,e=f.onmessage;return f.onmessage=function(){t=!0},f.postMessage("","*"),f.onmessage=e,t}function e(t){if("string"==typeof t.data&&t.data.substring(0,s.length)===s){var e=t.data.substring(s.length),n=o[e];n(),delete o[e]}}var n=RegExp("^"+(F+"").replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/toString| for [^\]]+/g,".*?")+"$"),i="function"==typeof(i=y&&b&&y.setImmediate)&&!n.test(i)&&i,r="function"==typeof(r=y&&b&&y.clearImmediate)&&!n.test(r)&&r;if("undefined"!=typeof process&&"[object process]"==={}.toString.call(process))ve=process.nextTick;else if("function"==typeof i)ve=i,me=r;else if(t()){var s="ms.rx.schedule"+Math.random(),o={},u=0;f.addEventListener?f.addEventListener("message",e,!1):f.attachEvent("onmessage",e,!1),ve=function(t){var e=u++;o[e]=t,f.postMessage(s+e,"*")}}else if(f.MessageChannel){var c=new f.MessageChannel,h={},a=0;c.port1.onmessage=function(t){var e=t.data,n=h[e];n(),delete h[e]},ve=function(t){var e=a++;h[e]=t,c.port2.postMessage(e)}}else"document"in f&&"onreadystatechange"in f.document.createElement("script")?ve=function(t){var e=f.document.createElement("script");e.onreadystatechange=function(){t(),e.onreadystatechange=null,e.parentNode.removeChild(e),e=null},f.document.documentElement.appendChild(e)}:(ve=function(t){return setTimeout(t,0)},me=clearTimeout)})(),fe.timeout=function(){function t(t,e){var n=this,i=new ae,r=ve(function(){i.isDisposed||i.setDisposable(e(n,t))});return new re(i,ue(function(){me(r)}))}function e(t,e,n){var i=this,r=fe.normalize(e);if(0===r)return i.scheduleWithState(t,n);var s=new ae,o=setTimeout(function(){s.isDisposed||s.setDisposable(n(i,t))},r);return new re(s,ue(function(){clearTimeout(o)}))}function n(t,e,n){return this.scheduleWithRelativeAndState(t,e-this.now(),n)}return new fe(S,t,e,n)}();var ge=function(t){function e(){return this._scheduler.now()}function n(t,e){return this._scheduler.scheduleWithState(t,this._wrap(e))}function i(t,e,n){return this._scheduler.scheduleWithRelativeAndState(t,e,this._wrap(n))}function r(t,e,n){return this._scheduler.scheduleWithAbsoluteAndState(t,e,this._wrap(n))}function s(s,o){this._scheduler=s,this._handler=o,this._recursiveOriginal=null,this._recursiveWrapper=null,t.call(this,e,n,i,r)}return X(s,t),s.prototype._clone=function(t){return new s(t,this._handler)},s.prototype._wrap=function(t){var e=this;return function(n,i){try{return t(e._getRecursiveWrapper(n),i)}catch(r){if(!e._handler(r))throw r;return ce}}},s.prototype._getRecursiveWrapper=function(t){if(this._recursiveOriginal!==t){this._recursiveOriginal=t;var e=this._clone(t);e._recursiveOriginal=t,e._recursiveWrapper=e,this._recursiveWrapper=e}return this._recursiveWrapper},s.prototype.schedulePeriodicWithState=function(t,e,n){var i=this,r=!1,s=new ae;return s.setDisposable(this._scheduler.schedulePeriodicWithState(t,e,function(t){if(r)return null;try{return n(t)}catch(e){if(r=!0,!i._handler(e))throw e;return s.dispose(),null}})),s},s}(fe),we=m.Notification=function(){function t(t,e){this.hasValue=null==e?!1:e,this.kind=t}var e=t.prototype;return e.accept=function(t,e,n){return 1===arguments.length&&"object"==typeof t?this._acceptObservable(t):this._accept(t,e,n)},e.toObservable=function(t){var e=this;return t||(t=be),new ke(function(n){return t.schedule(function(){e._acceptObservable(n),"N"===e.kind&&n.onCompleted()})})},t}(),Se=we.createOnNext=function(){function t(t){return t(this.value)}function e(t){return t.onNext(this.value)}function n(){return"OnNext("+this.value+")"}return function(i){var r=new we("N",!0);return r.value=i,r._accept=t,r._acceptObservable=e,r.toString=n,r}}(),_e=we.createOnError=function(){function t(t,e){return e(this.exception)}function e(t){return t.onError(this.exception)}function n(){return"OnError("+this.exception+")"}return function(i){var r=new we("E");return r.exception=i,r._accept=t,r._acceptObservable=e,r.toString=n,r}}(),De=we.createOnCompleted=function(){function t(t,e,n){return n()}function e(t){return t.onCompleted()}function n(){return"OnCompleted()"}return function(){var i=new we("C");return i._accept=t,i._acceptObservable=e,i.toString=n,i}}(),xe=m.internals.Enumerator=function(t){this._next=t};xe.prototype.next=function(){return this._next()},xe.prototype[E]=function(){return this};var Ae=m.internals.Enumerable=function(t){this._iterator=t};Ae.prototype[E]=function(){return this._iterator()},Ae.prototype.concat=function(){var e=this;return new ke(function(n){var i;try{i=e[E]()}catch(r){return n.onError(),t}var s,o=new le,u=be.scheduleRecursive(function(e){var r;if(!s){try{r=i.next()}catch(u){return n.onError(u),t}if(r.done)return n.onCompleted(),t;var c=r.value;x(c)&&(c=observableFromPromise(c));var h=new ae;o.setDisposable(h),h.setDisposable(c.subscribe(n.onNext.bind(n),n.onError.bind(n),function(){e()}))}});return new re(o,u,ue(function(){s=!0}))})},Ae.prototype.catchException=function(){var e=this;return new ke(function(n){var i;try{i=e[E]()}catch(r){return n.onError(),t}var s,o,u=new le,c=be.scheduleRecursive(function(e){if(!s){var r;try{r=i.next()}catch(c){return n.onError(c),t}if(r.done)return o?n.onError(o):n.onCompleted(),t;var h=r.value;x(h)&&(h=observableFromPromise(h));var a=new ae;u.setDisposable(a),a.setDisposable(h.subscribe(n.onNext.bind(n),function(t){o=t,e()},n.onCompleted.bind(n)))}});return new re(u,c,ue(function(){s=!0}))})},Ae.repeat=function(t,e){return null==e&&(e=-1),new Ae(function(){var n=e;return new xe(function(){return 0===n?R:(n>0&&n--,{done:!1,value:t})})})},Ae.forEach=function(t,e,n){return e||(e=w),new Ae(function(){var i=-1;return new xe(function(){return++i<t.length?{done:!1,value:e.call(n,t[i],i,t)}:R})})};var Ee=m.Observer=function(){};Ee.prototype.toNotifier=function(){var t=this;return function(e){return e.accept(t)}},Ee.prototype.asObserver=function(){return new Ce(this.onNext.bind(this),this.onError.bind(this),this.onCompleted.bind(this))},Ee.prototype.checked=function(){return new We(this)};var Oe=Ee.create=function(t,e,n){return t||(t=g),e||(e=D),n||(n=g),new Ce(t,e,n)};Ee.fromNotifier=function(t){return new Ce(function(e){return t(Se(e))},function(e){return t(_e(e))},function(){return t(De())})},Ee.notifyOn=function(t){return new Ne(t,this)};var Re,je=m.internals.AbstractObserver=function(t){function e(){this.isStopped=!1,t.call(this)}return X(e,t),e.prototype.onNext=function(t){this.isStopped||this.next(t)},e.prototype.onError=function(t){this.isStopped||(this.isStopped=!0,this.error(t))},e.prototype.onCompleted=function(){this.isStopped||(this.isStopped=!0,this.completed())},e.prototype.dispose=function(){this.isStopped=!0},e.prototype.fail=function(t){return this.isStopped?!1:(this.isStopped=!0,this.error(t),!0)},e}(Ee),Ce=m.AnonymousObserver=function(t){function e(e,n,i){t.call(this),this._onNext=e,this._onError=n,this._onCompleted=i}return X(e,t),e.prototype.next=function(t){this._onNext(t)},e.prototype.error=function(t){this._onError(t)},e.prototype.completed=function(){this._onCompleted()},e}(je),We=function(t){function e(e){t.call(this),this._observer=e,this._state=0}X(e,t);var n=e.prototype;return n.onNext=function(t){this.checkAccess();try{this._observer.onNext(t)}catch(e){throw e}finally{this._state=0}},n.onError=function(t){this.checkAccess();try{this._observer.onError(t)}catch(e){throw e}finally{this._state=2}},n.onCompleted=function(){this.checkAccess();try{this._observer.onCompleted()}catch(t){throw t}finally{this._state=2}},n.checkAccess=function(){if(1===this._state)throw Error("Re-entrancy detected");if(2===this._state)throw Error("Observer completed");0===this._state&&(this._state=1)},e}(Ee),Pe=m.internals.ScheduledObserver=function(e){function n(t,n){e.call(this),this.scheduler=t,this.observer=n,this.isAcquired=!1,this.hasFaulted=!1,this.queue=[],this.disposable=new le}return X(n,e),n.prototype.next=function(t){var e=this;this.queue.push(function(){e.observer.onNext(t)})},n.prototype.error=function(t){var e=this;this.queue.push(function(){e.observer.onError(t)})},n.prototype.completed=function(){var t=this;this.queue.push(function(){t.observer.onCompleted()})},n.prototype.ensureActive=function(){var e=!1,n=this;!this.hasFaulted&&this.queue.length>0&&(e=!this.isAcquired,this.isAcquired=!0),e&&this.disposable.setDisposable(this.scheduler.scheduleRecursive(function(e){var i;if(!(n.queue.length>0))return n.isAcquired=!1,t;i=n.queue.shift();try{i()}catch(r){throw n.queue=[],n.hasFaulted=!0,r}e()}))},n.prototype.dispose=function(){e.prototype.dispose.call(this),this.disposable.dispose()},n}(je),Ne=function(t){function e(){t.apply(this,arguments)}return X(e,t),e.prototype.next=function(e){t.prototype.next.call(this,e),this.ensureActive()},e.prototype.error=function(e){t.prototype.error.call(this,e),this.ensureActive()},e.prototype.completed=function(){t.prototype.completed.call(this),this.ensureActive()},e}(Pe),qe=m.Observable=function(){function t(t){this._subscribe=t}return Re=t.prototype,Re.subscribe=Re.forEach=function(t,e,n){var i="object"==typeof t?t:Oe(t,e,n);return this._subscribe(i)},t}(),ke=m.AnonymousObservable=function(e){function n(e){return e===t?e=ce:"function"==typeof e&&(e=ue(e)),e}function i(r){function s(t){var e=new Te(t);if(ye.scheduleRequired())ye.schedule(function(){try{e.setDisposable(n(r(e)))}catch(t){if(!e.fail(t))throw t}});else try{e.setDisposable(n(r(e)))}catch(i){if(!e.fail(i))throw i}return e}return this instanceof i?(e.call(this,s),t):new i(r)}return X(i,e),i}(qe),Te=function(t){function e(e){t.call(this),this.observer=e,this.m=new ae}X(e,t);var n=e.prototype;return n.next=function(t){var e=!1;try{this.observer.onNext(t),e=!0}catch(n){throw n}finally{e||this.dispose()}},n.error=function(t){try{this.observer.onError(t)}catch(e){throw e}finally{this.dispose()}},n.completed=function(){try{this.observer.onCompleted()}catch(t){throw t}finally{this.dispose()}},n.setDisposable=function(t){this.m.setDisposable(t)},n.getDisposable=function(){return this.m.getDisposable()},n.disposable=function(t){return arguments.length?this.getDisposable():setDisposable(t)},n.dispose=function(){t.prototype.dispose.call(this),this.m.dispose()},e}(je);(function(t){function e(t){return this.underlyingObservable.subscribe(t)}function n(n,i,r){t.call(this,e),this.key=n,this.underlyingObservable=r?new ke(function(t){return new re(r.getDisposable(),i.subscribe(t))}):i}return X(n,t),n})(qe);var Ie=function(t,e){this.subject=t,this.observer=e};Ie.prototype.dispose=function(){if(!this.subject.isDisposed&&null!==this.observer){var t=this.subject.observers.indexOf(this.observer);this.subject.observers.splice(t,1),this.observer=null}},m.Subject=function(t){function n(t){return e.call(this),this.isStopped?this.exception?(t.onError(this.exception),ce):(t.onCompleted(),ce):(this.observers.push(t),new Ie(this,t))}function i(){t.call(this,n),this.isDisposed=!1,this.isStopped=!1,this.observers=[]}return X(i,t),Y(i.prototype,Ee,{hasObservers:function(){return this.observers.length>0},onCompleted:function(){if(e.call(this),!this.isStopped){var t=this.observers.slice(0);this.isStopped=!0;for(var n=0,i=t.length;i>n;n++)t[n].onCompleted();this.observers=[]}},onError:function(t){if(e.call(this),!this.isStopped){var n=this.observers.slice(0);this.isStopped=!0,this.exception=t;for(var i=0,r=n.length;r>i;i++)n[i].onError(t);this.observers=[]}},onNext:function(t){if(e.call(this),!this.isStopped)for(var n=this.observers.slice(0),i=0,r=n.length;r>i;i++)n[i].onNext(t)},dispose:function(){this.isDisposed=!0,this.observers=null}}),i.create=function(t,e){return new Me(t,e)},i}(qe),m.AsyncSubject=function(t){function n(t){if(e.call(this),!this.isStopped)return this.observers.push(t),new Ie(this,t);var n=this.exception,i=this.hasValue,r=this.value;return n?t.onError(n):i?(t.onNext(r),t.onCompleted()):t.onCompleted(),ce}function i(){t.call(this,n),this.isDisposed=!1,this.isStopped=!1,this.value=null,this.hasValue=!1,this.observers=[],this.exception=null}return X(i,t),Y(i.prototype,Ee,{hasObservers:function(){return e.call(this),this.observers.length>0},onCompleted:function(){var t,n,i;if(e.call(this),!this.isStopped){this.isStopped=!0;var r=this.observers.slice(0),s=this.value,o=this.hasValue;if(o)for(n=0,i=r.length;i>n;n++)t=r[n],t.onNext(s),t.onCompleted();else for(n=0,i=r.length;i>n;n++)r[n].onCompleted();this.observers=[]}},onError:function(t){if(e.call(this),!this.isStopped){var n=this.observers.slice(0);this.isStopped=!0,this.exception=t;for(var i=0,r=n.length;r>i;i++)n[i].onError(t);this.observers=[]}},onNext:function(t){e.call(this),this.isStopped||(this.value=t,this.hasValue=!0)},dispose:function(){this.isDisposed=!0,this.observers=null,this.exception=null,this.value=null}}),i}(qe);var Me=function(t){function e(t){return this.observable.subscribe(t)}function n(n,i){t.call(this,e),this.observer=n,this.observable=i}return X(n,t),Y(n.prototype,Ee,{onCompleted:function(){this.observer.onCompleted()},onError:function(t){this.observer.onError(t)},onNext:function(t){this.observer.onNext(t)}}),n}(qe);"function"==typeof define&&"object"==typeof define.amd&&define.amd?(f.Rx=m,define(function(){return m})):d&&v?b?(v.exports=m).Rx=m:d.Rx=m:f.Rx=m}).call(this);