import { __extends as c } from "./index-tslib.es6.js";
import { isFunction as a } from "./index-isFunction.js";
import { isSubscription as l, Subscription as f } from "./index-Subscription.js";
import { reportUnhandledError as h } from "./index-reportUnhandledError.js";
import { noop as u } from "./index-noop.js";
var d = (function(e) {
  c(r, e);
  function r(t) {
    var i = e.call(this) || this;
    return i.isStopped = !1, t ? (i.destination = t, l(t) && t.add(i)) : i.destination = y, i;
  }
  return r.create = function(t, i, n) {
    return new m(t, i, n);
  }, r.prototype.next = function(t) {
    this.isStopped || this._next(t);
  }, r.prototype.error = function(t) {
    this.isStopped || (this.isStopped = !0, this._error(t));
  }, r.prototype.complete = function() {
    this.isStopped || (this.isStopped = !0, this._complete());
  }, r.prototype.unsubscribe = function() {
    this.closed || (this.isStopped = !0, e.prototype.unsubscribe.call(this), this.destination = null);
  }, r.prototype._next = function(t) {
    this.destination.next(t);
  }, r.prototype._error = function(t) {
    try {
      this.destination.error(t);
    } finally {
      this.unsubscribe();
    }
  }, r.prototype._complete = function() {
    try {
      this.destination.complete();
    } finally {
      this.unsubscribe();
    }
  }, r;
})(f), b = (function() {
  function e(r) {
    this.partialObserver = r;
  }
  return e.prototype.next = function(r) {
    var t = this.partialObserver;
    if (t.next)
      try {
        t.next(r);
      } catch (i) {
        o(i);
      }
  }, e.prototype.error = function(r) {
    var t = this.partialObserver;
    if (t.error)
      try {
        t.error(r);
      } catch (i) {
        o(i);
      }
    else
      o(r);
  }, e.prototype.complete = function() {
    var r = this.partialObserver;
    if (r.complete)
      try {
        r.complete();
      } catch (t) {
        o(t);
      }
  }, e;
})(), m = (function(e) {
  c(r, e);
  function r(t, i, n) {
    var p = e.call(this) || this, s;
    return a(t) || !t ? s = {
      next: t ?? void 0,
      error: i ?? void 0,
      complete: n ?? void 0
    } : s = t, p.destination = new b(s), p;
  }
  return r;
})(d);
function o(e) {
  h(e);
}
function v(e) {
  throw e;
}
var y = {
  closed: !0,
  next: u,
  error: v,
  complete: u
};
export {
  y as EMPTY_OBSERVER,
  m as SafeSubscriber,
  d as Subscriber
};
