import _typeof from "./typeof.js"; function old_createMetadataMethodsForProperty(e, t, a, r) { return { getMetadata: function getMetadata(o) { old_assertNotFinished(r, "getMetadata"), old_assertMetadataKey(o); var i = e[o]; if (void 0 !== i) if (1 === t) { var n = i["public"]; if (void 0 !== n) return n[a]; } else if (2 === t) { var l = i["private"]; if (void 0 !== l) return l.get(a); } else if (Object.hasOwnProperty.call(i, "constructor")) return i.constructor; }, setMetadata: function setMetadata(o, i) { old_assertNotFinished(r, "setMetadata"), old_assertMetadataKey(o); var n = e[o]; if (void 0 === n && (n = e[o] = {}), 1 === t) { var l = n["public"]; void 0 === l && (l = n["public"] = {}), l[a] = i; } else if (2 === t) { var s = n.priv; void 0 === s && (s = n["private"] = new Map()), s.set(a, i); } else n.constructor = i; } }; } function old_convertMetadataMapToFinal(e, t) { var a = e[Symbol.metadata || Symbol["for"]("Symbol.metadata")], r = Object.getOwnPropertySymbols(t); if (0 !== r.length) { for (var o = 0; o < r.length; o++) { var i = r[o], n = t[i], l = a ? a[i] : null, s = n["public"], c = l ? l["public"] : null; s && c && Object.setPrototypeOf(s, c); var d = n["private"]; if (d) { var u = Array.from(d.values()), f = l ? l["private"] : null; f && (u = u.concat(f)), n["private"] = u; } l && Object.setPrototypeOf(n, l); } a && Object.setPrototypeOf(t, a), e[Symbol.metadata || Symbol["for"]("Symbol.metadata")] = t; } } function old_createAddInitializerMethod(e, t) { return function (a) { old_assertNotFinished(t, "addInitializer"), old_assertCallable(a, "An initializer"), e.push(a); }; } function old_memberDec(e, t, a, r, o, i, n, l, s) { var c; switch (i) { case 1: c = "accessor"; break; case 2: c = "method"; break; case 3: c = "getter"; break; case 4: c = "setter"; break; default: c = "field"; } var d, u, f = { kind: c, name: l ? "#" + t : t, isStatic: n, isPrivate: l }, p = { v: !1 }; if (0 !== i && (f.addInitializer = old_createAddInitializerMethod(o, p)), l) { d = 2, u = Symbol(t); var v = {}; 0 === i ? (v.get = a.get, v.set = a.set) : 2 === i ? v.get = function () { return a.value; } : (1 !== i && 3 !== i || (v.get = function () { return a.get.call(this); }), 1 !== i && 4 !== i || (v.set = function (e) { a.set.call(this, e); })), f.access = v; } else d = 1, u = t; try { return e(s, Object.assign(f, old_createMetadataMethodsForProperty(r, d, u, p))); } finally { p.v = !0; } } function old_assertNotFinished(e, t) { if (e.v) throw new Error("attempted to call " + t + " after decoration was finished"); } function old_assertMetadataKey(e) { if ("symbol" != _typeof(e)) throw new TypeError("Metadata keys must be symbols, received: " + e); } function old_assertCallable(e, t) { if ("function" != typeof e) throw new TypeError(t + " must be a function"); } function old_assertValidReturnValue(e, t) { var a = _typeof(t); if (1 === e) { if ("object" !== a || null === t) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0"); void 0 !== t.get && old_assertCallable(t.get, "accessor.get"), void 0 !== t.set && old_assertCallable(t.set, "accessor.set"), void 0 !== t.init && old_assertCallable(t.init, "accessor.init"), void 0 !== t.initializer && old_assertCallable(t.initializer, "accessor.initializer"); } else if ("function" !== a) { var r; throw r = 0 === e ? "field" : 10 === e ? "class" : "method", new TypeError(r + " decorators must return a function or void 0"); } } function old_getInit(e) { var t; return null == (t = e.init) && (t = e.initializer) && "undefined" != typeof console && console.warn(".initializer has been renamed to .init as of March 2022"), t; } function old_applyMemberDec(e, t, a, r, o, i, n, l, s) { var c, d, u, f, p, v, h = a[0]; if (n ? c = 0 === o || 1 === o ? { get: a[3], set: a[4] } : 3 === o ? { get: a[3] } : 4 === o ? { set: a[3] } : { value: a[3] } : 0 !== o && (c = Object.getOwnPropertyDescriptor(t, r)), 1 === o ? u = { get: c.get, set: c.set } : 2 === o ? u = c.value : 3 === o ? u = c.get : 4 === o && (u = c.set), "function" == typeof h) void 0 !== (f = old_memberDec(h, r, c, l, s, o, i, n, u)) && (old_assertValidReturnValue(o, f), 0 === o ? d = f : 1 === o ? (d = old_getInit(f), p = f.get || u.get, v = f.set || u.set, u = { get: p, set: v }) : u = f);else for (var y = h.length - 1; y >= 0; y--) { var b; if (void 0 !== (f = old_memberDec(h[y], r, c, l, s, o, i, n, u))) old_assertValidReturnValue(o, f), 0 === o ? b = f : 1 === o ? (b = old_getInit(f), p = f.get || u.get, v = f.set || u.set, u = { get: p, set: v }) : u = f, void 0 !== b && (void 0 === d ? d = b : "function" == typeof d ? d = [d, b] : d.push(b)); } if (0 === o || 1 === o) { if (void 0 === d) d = function d(e, t) { return t; };else if ("function" != typeof d) { var g = d; d = function d(e, t) { for (var a = t, r = 0; r < g.length; r++) a = g[r].call(e, a); return a; }; } else { var m = d; d = function d(e, t) { return m.call(e, t); }; } e.push(d); } 0 !== o && (1 === o ? (c.get = u.get, c.set = u.set) : 2 === o ? c.value = u : 3 === o ? c.get = u : 4 === o && (c.set = u), n ? 1 === o ? (e.push(function (e, t) { return u.get.call(e, t); }), e.push(function (e, t) { return u.set.call(e, t); })) : 2 === o ? e.push(u) : e.push(function (e, t) { return u.call(e, t); }) : Object.defineProperty(t, r, c)); } function old_applyMemberDecs(e, t, a, r, o) { for (var i, n, l = new Map(), s = new Map(), c = 0; c < o.length; c++) { var d = o[c]; if (Array.isArray(d)) { var u, f, p, v = d[1], h = d[2], y = d.length > 3, b = v >= 5; if (b ? (u = t, f = r, 0 !== (v -= 5) && (p = n = n || [])) : (u = t.prototype, f = a, 0 !== v && (p = i = i || [])), 0 !== v && !y) { var g = b ? s : l, m = g.get(h) || 0; if (!0 === m || 3 === m && 4 !== v || 4 === m && 3 !== v) throw new Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + h); !m && v > 2 ? g.set(h, v) : g.set(h, !0); } old_applyMemberDec(e, u, d, h, v, b, y, f, p); } } old_pushInitializers(e, i), old_pushInitializers(e, n); } function old_pushInitializers(e, t) { t && e.push(function (e) { for (var a = 0; a < t.length; a++) t[a].call(e); return e; }); } function old_applyClassDecs(e, t, a, r) { if (r.length > 0) { for (var o = [], i = t, n = t.name, l = r.length - 1; l >= 0; l--) { var s = { v: !1 }; try { var c = Object.assign({ kind: "class", name: n, addInitializer: old_createAddInitializerMethod(o, s) }, old_createMetadataMethodsForProperty(a, 0, n, s)), d = r[l](i, c); } finally { s.v = !0; } void 0 !== d && (old_assertValidReturnValue(10, d), i = d); } e.push(i, function () { for (var e = 0; e < o.length; e++) o[e].call(i); }); } } export default function applyDecs(e, t, a) { var r = [], o = {}, i = {}; return old_applyMemberDecs(r, e, i, o, t), old_convertMetadataMapToFinal(e.prototype, i), old_applyClassDecs(r, e, o, a), old_convertMetadataMapToFinal(e, o), r; }