import { __commonJSMin as e } from "../../../../_virtual/_rolldown/runtime.js";
import { require_ral as t } from "./ral.js";
import { require_is as n } from "./is.js";
import { require_events as r } from "./events.js";
//#region ../../node_modules/vscode-jsonrpc/lib/common/cancellation.js
var i = /* @__PURE__ */ e(((e) => {
	Object.defineProperty(e, "__esModule", { value: !0 }), e.CancellationTokenSource = e.CancellationToken = void 0;
	var i = t(), a = n(), o = r(), s;
	(function(e) {
		e.None = Object.freeze({
			isCancellationRequested: !1,
			onCancellationRequested: o.Event.None
		}), e.Cancelled = Object.freeze({
			isCancellationRequested: !0,
			onCancellationRequested: o.Event.None
		});
		function t(t) {
			let n = t;
			return n && (n === e.None || n === e.Cancelled || a.boolean(n.isCancellationRequested) && !!n.onCancellationRequested);
		}
		e.is = t;
	})(s || (e.CancellationToken = s = {}));
	var c = Object.freeze(function(e, t) {
		let n = (0, i.default)().timer.setTimeout(e.bind(t), 0);
		return { dispose() {
			n.dispose();
		} };
	}), l = class {
		constructor() {
			this._isCancelled = !1;
		}
		cancel() {
			this._isCancelled || (this._isCancelled = !0, this._emitter && (this._emitter.fire(void 0), this.dispose()));
		}
		get isCancellationRequested() {
			return this._isCancelled;
		}
		get onCancellationRequested() {
			return this._isCancelled ? c : (this._emitter ||= new o.Emitter(), this._emitter.event);
		}
		dispose() {
			this._emitter &&= (this._emitter.dispose(), void 0);
		}
	};
	e.CancellationTokenSource = class {
		get token() {
			return this._token ||= new l(), this._token;
		}
		cancel() {
			this._token ? this._token.cancel() : this._token = s.Cancelled;
		}
		dispose() {
			this._token ? this._token instanceof l && this._token.dispose() : this._token = s.None;
		}
	};
}));
//#endregion
export default i();
export { i as require_cancellation };
