'a'
mh-two-thousand-and-two
2024-04-12 44d2c92345cd156a59fc327b3060292a282d2893
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
"use strict";
 
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = applyDecs2305;
var _checkInRHS = require("./checkInRHS.js");
var _setFunctionName = require("./setFunctionName.js");
var _toPropertyKey = require("./toPropertyKey.js");
function applyDecs2305(targetClass, memberDecs, classDecs, classDecsHaveThis, instanceBrand, parentClass) {
  function _bindPropCall(obj, name, before) {
    return function (_this, value) {
      if (before) {
        before(_this);
      }
      return obj[name].call(_this, value);
    };
  }
  function runInitializers(initializers, value) {
    for (var i = 0; i < initializers.length; i++) {
      initializers[i].call(value);
    }
    return value;
  }
  function assertCallable(fn, hint1, hint2, throwUndefined) {
    if (typeof fn !== "function") {
      if (throwUndefined || fn !== void 0) {
        throw new TypeError(hint1 + " must " + (hint2 || "be") + " a function" + (throwUndefined ? "" : " or undefined"));
      }
    }
    return fn;
  }
  function applyDec(Class, decInfo, decoratorsHaveThis, name, kind, metadata, initializers, ret, isStatic, isPrivate, isField, isAccessor, hasPrivateBrand) {
    function assertInstanceIfPrivate(target) {
      if (!hasPrivateBrand(target)) {
        throw new TypeError("Attempted to access private element on non-instance");
      }
    }
    var decs = decInfo[0],
      decVal = decInfo[3],
      _,
      isClass = !ret;
    if (!isClass) {
      if (!decoratorsHaveThis && !Array.isArray(decs)) {
        decs = [decs];
      }
      var desc = {},
        init = [],
        key = kind === 3 ? "get" : kind === 4 || isAccessor ? "set" : "value";
      if (isPrivate) {
        if (isField || isAccessor) {
          desc = {
            get: (0, _setFunctionName.default)(function () {
              return decVal(this);
            }, name, "get"),
            set: function (value) {
              decInfo[4](this, value);
            }
          };
        } else {
          desc[key] = decVal;
        }
        if (!isField) {
          (0, _setFunctionName.default)(desc[key], name, kind === 2 ? "" : key);
        }
      } else if (!isField) {
        desc = Object.getOwnPropertyDescriptor(Class, name);
      }
    }
    var newValue = Class;
    for (var i = decs.length - 1; i >= 0; i -= decoratorsHaveThis ? 2 : 1) {
      var dec = decs[i],
        decThis = decoratorsHaveThis ? decs[i - 1] : void 0;
      var decoratorFinishedRef = {};
      var ctx = {
        kind: ["field", "accessor", "method", "getter", "setter", "class"][kind],
        name: name,
        metadata: metadata,
        addInitializer: function (decoratorFinishedRef, initializer) {
          if (decoratorFinishedRef.v) {
            throw new Error("attempted to call addInitializer after decoration was finished");
          }
          assertCallable(initializer, "An initializer", "be", true);
          initializers.push(initializer);
        }.bind(null, decoratorFinishedRef)
      };
      try {
        if (isClass) {
          if (_ = assertCallable(dec.call(decThis, newValue, ctx), "class decorators", "return")) {
            newValue = _;
          }
        } else {
          ctx.static = isStatic;
          ctx.private = isPrivate;
          var get, set;
          if (!isPrivate) {
            get = function (target) {
              return target[name];
            };
            if (kind < 2 || kind === 4) {
              set = function (target, v) {
                target[name] = v;
              };
            }
          } else if (kind === 2) {
            get = function (_this) {
              assertInstanceIfPrivate(_this);
              return desc.value;
            };
          } else {
            if (kind < 4) {
              get = _bindPropCall(desc, "get", assertInstanceIfPrivate);
            }
            if (kind !== 3) {
              set = _bindPropCall(desc, "set", assertInstanceIfPrivate);
            }
          }
          var access = ctx.access = {
            has: isPrivate ? hasPrivateBrand.bind() : function (target) {
              return name in target;
            }
          };
          if (get) access.get = get;
          if (set) access.set = set;
          newValue = dec.call(decThis, isAccessor ? {
            get: desc.get,
            set: desc.set
          } : desc[key], ctx);
          if (isAccessor) {
            if (typeof newValue === "object" && newValue) {
              if (_ = assertCallable(newValue.get, "accessor.get")) {
                desc.get = _;
              }
              if (_ = assertCallable(newValue.set, "accessor.set")) {
                desc.set = _;
              }
              if (_ = assertCallable(newValue.init, "accessor.init")) {
                init.push(_);
              }
            } else if (newValue !== void 0) {
              throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
            }
          } else if (assertCallable(newValue, (isField ? "field" : "method") + " decorators", "return")) {
            if (isField) {
              init.push(newValue);
            } else {
              desc[key] = newValue;
            }
          }
        }
      } finally {
        decoratorFinishedRef.v = true;
      }
    }
    if (isField || isAccessor) {
      ret.push(function (instance, value) {
        for (var i = init.length - 1; i >= 0; i--) {
          value = init[i].call(instance, value);
        }
        return value;
      });
    }
    if (!isField && !isClass) {
      if (isPrivate) {
        if (isAccessor) {
          ret.push(_bindPropCall(desc, "get"), _bindPropCall(desc, "set"));
        } else {
          ret.push(kind === 2 ? desc[key] : _bindPropCall.call.bind(desc[key]));
        }
      } else {
        Object.defineProperty(Class, name, desc);
      }
    }
    return newValue;
  }
  function applyMemberDecs(Class, decInfos, instanceBrand, metadata) {
    var ret = [];
    var protoInitializers;
    var staticInitializers;
    var staticBrand = function (_) {
      return (0, _checkInRHS.default)(_) === Class;
    };
    var existingNonFields = new Map();
    function pushInitializers(initializers) {
      if (initializers) {
        ret.push(runInitializers.bind(null, initializers));
      }
    }
    for (var i = 0; i < decInfos.length; i++) {
      var decInfo = decInfos[i];
      if (!Array.isArray(decInfo)) continue;
      var kind = decInfo[1];
      var name = decInfo[2];
      var isPrivate = decInfo.length > 3;
      var decoratorsHaveThis = kind & 16;
      var isStatic = !!(kind & 8);
      kind &= 7;
      var isField = kind === 0;
      var key = name + "/" + isStatic;
      if (!isField && !isPrivate) {
        var existingKind = existingNonFields.get(key);
        if (existingKind === true || existingKind === 3 && kind !== 4 || existingKind === 4 && kind !== 3) {
          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: " + name);
        }
        existingNonFields.set(key, kind > 2 ? kind : true);
      }
      applyDec(isStatic ? Class : Class.prototype, decInfo, decoratorsHaveThis, isPrivate ? "#" + name : (0, _toPropertyKey.default)(name), kind, metadata, isStatic ? staticInitializers = staticInitializers || [] : protoInitializers = protoInitializers || [], ret, isStatic, isPrivate, isField, kind === 1, isStatic && isPrivate ? staticBrand : instanceBrand);
    }
    pushInitializers(protoInitializers);
    pushInitializers(staticInitializers);
    return ret;
  }
  function defineMetadata(Class, metadata) {
    return Object.defineProperty(Class, Symbol.metadata || Symbol.for("Symbol.metadata"), {
      configurable: true,
      enumerable: true,
      value: metadata
    });
  }
  if (arguments.length >= 6) {
    var parentMetadata = parentClass[Symbol.metadata || Symbol.for("Symbol.metadata")];
  }
  var metadata = Object.create(parentMetadata == null ? null : parentMetadata);
  var e = applyMemberDecs(targetClass, memberDecs, instanceBrand, metadata);
  if (!classDecs.length) defineMetadata(targetClass, metadata);
  return {
    e: e,
    get c() {
      var initializers = [];
      return classDecs.length && [defineMetadata(applyDec(targetClass, [classDecs], classDecsHaveThis, targetClass.name, 5, metadata, initializers), metadata), runInitializers.bind(null, initializers, targetClass)];
    }
  };
}
 
//# sourceMappingURL=applyDecs2305.js.map