{"version":3,"names":["_usingCtx","_disposeSuppressedError","SuppressedError","error","suppressed","err","Error","name","empty","stack","using","isAwait","value","Object","TypeError","dispose","Symbol","asyncDispose","for","push","v","d","a","e","u","bind","next","resource","pop","disposalResult","call","Promise","resolve","then"],"sources":["../../src/helpers/usingCtx.ts"],"sourcesContent":["/* @minVersion 7.23.9 */\n\ntype Stack = {\n v: any;\n d: () => any;\n a: boolean;\n};\n\nexport default function _usingCtx() {\n var _disposeSuppressedError =\n typeof SuppressedError === \"function\"\n ? // eslint-disable-next-line no-undef\n SuppressedError\n : (function (error: Error, suppressed: Error) {\n var err = new Error() as SuppressedError;\n err.name = \"SuppressedError\";\n err.suppressed = suppressed;\n err.error = error;\n return err;\n } as SuppressedErrorConstructor),\n empty = {},\n stack: Stack[] = [];\n function using(isAwait: boolean, value: any) {\n if (value != null) {\n if (Object(value) !== value) {\n throw new TypeError(\n \"using declarations can only be used with objects, functions, null, or undefined.\",\n );\n }\n // core-js-pure uses Symbol.for for polyfilling well-known symbols\n if (isAwait) {\n var dispose =\n value[Symbol.asyncDispose || Symbol.for(\"Symbol.asyncDispose\")];\n }\n if (dispose == null) {\n dispose = value[Symbol.dispose || Symbol.for(\"Symbol.dispose\")];\n }\n if (typeof dispose !== \"function\") {\n throw new TypeError(`Property [Symbol.dispose] is not a function.`);\n }\n stack.push({ v: value, d: dispose, a: isAwait });\n }\n return value;\n }\n return {\n // error\n e: empty,\n // using\n u: using.bind(null, false),\n // await using\n a: using.bind(null, true),\n // dispose\n d: function () {\n var error = this.e;\n\n function next(): any {\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n while ((resource = stack.pop())) {\n try {\n var resource,\n disposalResult = resource.d.call(resource.v);\n if (resource.a) {\n return Promise.resolve(disposalResult).then(next, err);\n }\n } catch (e) {\n return err(e);\n }\n }\n if (error !== empty) throw error;\n }\n\n function err(e: Error) {\n error = error !== empty ? new _disposeSuppressedError(error, e) : e;\n\n return next();\n }\n\n return next();\n },\n };\n}\n"],"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