var __bare_os_bundle_exports__ = (() => { var __create = Object.create; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __getProtoOf = Object.getPrototypeOf; var __hasOwnProp = Object.prototype.hasOwnProperty; var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, { get: (a, b) => (typeof require !== "undefined" ? require : a)[b] }) : x)(function(x) { if (typeof require !== "undefined") return require.apply(this, arguments); throw Error('Dynamic require of "' + x + '" is not supported'); }); var __commonJS = (cb, mod) => function __require2() { return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; }; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( // If the importer is in node compatibility mode or this is not an ESM // file that has been converted to a CommonJS file using a Babel- // compatible transform (i.e. "__esModule" has not been set), then set // "default" to the CommonJS "module.exports" for node compatibility. isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod )); var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // ../../node_modules/bare-atomics/binding.js var require_binding = __commonJS({ "../../node_modules/bare-atomics/binding.js"(exports, module) { module.exports = __require.addon(); } }); // ../../node_modules/bare-atomics/index.js var require_bare_atomics = __commonJS({ "../../node_modules/bare-atomics/index.js"(exports) { var binding = require_binding(); exports.Mutex = class Mutex { constructor(opts = {}) { const { recursive = false, handle = binding.mutexInit(recursive) } = opts; this.handle = handle; this.recursive = recursive; this.held = false; } lock() { if (this.held && !this.recursive) throw new Error("cannot relock already held mutex"); binding.mutexLock(this.handle); this.held = true; } tryLock() { if (this.held && !this.recursive) throw new Error("cannot relock already held mutex"); return binding.mutexTryLock(this.handle); } unlock() { if (!this.held) throw new Error("cannot unlock unheld mutex"); binding.mutexUnlock(this.handle); this.held = false; } destroy() { if (this.held) throw new Error("cannot destroy held mutex"); binding.mutexDestroy(this.handle); } static from(handle, opts = {}) { return new Mutex({ ...opts, handle }); } }; exports.Semaphore = class Semaphore { constructor(value, opts = {}) { if (typeof value === "object") { opts = value; value = 0; } const { handle = binding.semaphoreInit(value) } = opts; this.handle = handle; } wait() { binding.semaphoreWait(this.handle); } tryWait() { return binding.semaphoreTryWait(this.handle); } post() { binding.semaphorePost(this.handle); } destroy() { binding.semaphoreDestroy(this.handle); } static from(handle, opts = {}) { return new Semaphore({ ...opts, handle }); } }; exports.Condition = class Condition { constructor(opts = {}) { const { handle = binding.conditionInit() } = opts; this.handle = handle; } wait(mutex, timeout = -1) { if (!mutex.held) throw new Error("cannot wait with unheld mutex"); return binding.conditionWait(this.handle, mutex.handle, timeout); } signal() { binding.conditionSignal(this.handle); } broadcast() { binding.conditionBroadcast(this.handle); } destroy() { binding.conditionDestroy(this.handle); } static from(handle, opts = {}) { return new Condition({ ...opts, handle }); } }; exports.Barrier = class Barrier { constructor(count, opts = {}) { if (typeof count === "object") { opts = count; count = 0; } const { handle = binding.barrierInit(count) } = opts; this.handle = handle; } wait() { return binding.barrierWait(this.handle); } destroy() { binding.barrierDestroy(this.handle); } static from(handle, opts = {}) { return new Barrier({ ...opts, handle }); } }; } }); // ../../bare-lib-entry-bareAtomics.js var bare_lib_entry_bareAtomics_exports = {}; __export(bare_lib_entry_bareAtomics_exports, { default: () => bare_lib_entry_bareAtomics_default }); var import_bare_atomics = __toESM(require_bare_atomics()); var bare_lib_entry_bareAtomics_default = import_bare_atomics.default; return __toCommonJS(bare_lib_entry_bareAtomics_exports); })(); ;(function(){var g=globalThis;var s="__bare_os_stdlib__";g[s]=g[s]||{};var e=typeof __bare_os_bundle_exports__!=="undefined"?__bare_os_bundle_exports__:void 0;var v=e!=null&&typeof e==="object"&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e;g[s]["bareAtomics"]=v;})();