@medplum/agent 3.1.2 → 3.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/cjs/index.cjs +392 -2619
  2. package/package.json +5 -5
@@ -12,13 +12,13 @@ var __export = (target, all) => {
12
12
  for (var name in all)
13
13
  __defProp(target, name, { get: all[name], enumerable: true });
14
14
  };
15
- var __copyProps = (to2, from, except, desc) => {
15
+ var __copyProps = (to, from, except, desc) => {
16
16
  if (from && typeof from === "object" || typeof from === "function") {
17
17
  for (let key of __getOwnPropNames(from))
18
- if (!__hasOwnProp.call(to2, key) && key !== except)
19
- __defProp(to2, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
+ if (!__hasOwnProp.call(to, key) && key !== except)
19
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
20
20
  }
21
- return to2;
21
+ return to;
22
22
  };
23
23
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
24
24
  // If the importer is in node compatibility mode or this is not an ESM
@@ -4128,12 +4128,12 @@ var require_dcmjs = __commonJS({
4128
4128
  if (_i2 == null)
4129
4129
  return;
4130
4130
  var _arr = [];
4131
- var _n2 = true;
4131
+ var _n = true;
4132
4132
  var _d = false;
4133
- var _s2, _e;
4133
+ var _s, _e;
4134
4134
  try {
4135
- for (_i2 = _i2.call(arr); !(_n2 = (_s2 = _i2.next()).done); _n2 = true) {
4136
- _arr.push(_s2.value);
4135
+ for (_i2 = _i2.call(arr); !(_n = (_s = _i2.next()).done); _n = true) {
4136
+ _arr.push(_s.value);
4137
4137
  if (i2 && _arr.length === i2)
4138
4138
  break;
4139
4139
  }
@@ -4142,7 +4142,7 @@ var require_dcmjs = __commonJS({
4142
4142
  _e = err2;
4143
4143
  } finally {
4144
4144
  try {
4145
- if (!_n2 && _i2["return"] != null)
4145
+ if (!_n && _i2["return"] != null)
4146
4146
  _i2["return"]();
4147
4147
  } finally {
4148
4148
  if (_d)
@@ -11191,13 +11191,13 @@ var require_dcmjs = __commonJS({
11191
11191
  key: "xyz2LAB",
11192
11192
  value: function xyz2LAB(xyz) {
11193
11193
  var whitePoint = Colors2.d65WhitePointXYZ();
11194
- var X2 = xyz[0] / whitePoint[0];
11194
+ var X = xyz[0] / whitePoint[0];
11195
11195
  var Y = xyz[1] / whitePoint[1];
11196
11196
  var Z2 = xyz[2] / whitePoint[2];
11197
- X2 = Colors2.labf(X2);
11197
+ X = Colors2.labf(X);
11198
11198
  Y = Colors2.labf(Y);
11199
11199
  Z2 = Colors2.labf(Z2);
11200
- return [116 * Y - 16, 500 * (X2 - Y), 200 * (Y - Z2)];
11200
+ return [116 * Y - 16, 500 * (X - Y), 200 * (Y - Z2)];
11201
11201
  }
11202
11202
  }, {
11203
11203
  key: "lab2RGB",
@@ -26544,17 +26544,17 @@ var require_node = __commonJS({
26544
26544
  }
26545
26545
  });
26546
26546
 
26547
- // ../../node_modules/winston-transport/node_modules/readable-stream/lib/internal/streams/stream.js
26547
+ // ../../node_modules/readable-stream/lib/internal/streams/stream.js
26548
26548
  var require_stream2 = __commonJS({
26549
- "../../node_modules/winston-transport/node_modules/readable-stream/lib/internal/streams/stream.js"(exports2, module2) {
26549
+ "../../node_modules/readable-stream/lib/internal/streams/stream.js"(exports2, module2) {
26550
26550
  "use strict";
26551
26551
  module2.exports = require("stream");
26552
26552
  }
26553
26553
  });
26554
26554
 
26555
- // ../../node_modules/winston-transport/node_modules/readable-stream/lib/internal/streams/destroy.js
26555
+ // ../../node_modules/readable-stream/lib/internal/streams/destroy.js
26556
26556
  var require_destroy = __commonJS({
26557
- "../../node_modules/winston-transport/node_modules/readable-stream/lib/internal/streams/destroy.js"(exports2, module2) {
26557
+ "../../node_modules/readable-stream/lib/internal/streams/destroy.js"(exports2, module2) {
26558
26558
  "use strict";
26559
26559
  function destroy(err, cb) {
26560
26560
  var _this = this;
@@ -26645,9 +26645,9 @@ var require_destroy = __commonJS({
26645
26645
  }
26646
26646
  });
26647
26647
 
26648
- // ../../node_modules/winston-transport/node_modules/readable-stream/errors.js
26648
+ // ../../node_modules/readable-stream/errors.js
26649
26649
  var require_errors2 = __commonJS({
26650
- "../../node_modules/winston-transport/node_modules/readable-stream/errors.js"(exports2, module2) {
26650
+ "../../node_modules/readable-stream/errors.js"(exports2, module2) {
26651
26651
  "use strict";
26652
26652
  var codes = {};
26653
26653
  function createErrorType(code, message, Base) {
@@ -26745,9 +26745,9 @@ var require_errors2 = __commonJS({
26745
26745
  }
26746
26746
  });
26747
26747
 
26748
- // ../../node_modules/winston-transport/node_modules/readable-stream/lib/internal/streams/state.js
26748
+ // ../../node_modules/readable-stream/lib/internal/streams/state.js
26749
26749
  var require_state = __commonJS({
26750
- "../../node_modules/winston-transport/node_modules/readable-stream/lib/internal/streams/state.js"(exports2, module2) {
26750
+ "../../node_modules/readable-stream/lib/internal/streams/state.js"(exports2, module2) {
26751
26751
  "use strict";
26752
26752
  var ERR_INVALID_OPT_VALUE = require_errors2().codes.ERR_INVALID_OPT_VALUE;
26753
26753
  function highWaterMarkFrom(options, isDuplex, duplexKey) {
@@ -26819,9 +26819,9 @@ var require_inherits = __commonJS({
26819
26819
  }
26820
26820
  });
26821
26821
 
26822
- // ../../node_modules/winston-transport/node_modules/readable-stream/lib/internal/streams/buffer_list.js
26822
+ // ../../node_modules/readable-stream/lib/internal/streams/buffer_list.js
26823
26823
  var require_buffer_list = __commonJS({
26824
- "../../node_modules/winston-transport/node_modules/readable-stream/lib/internal/streams/buffer_list.js"(exports2, module2) {
26824
+ "../../node_modules/readable-stream/lib/internal/streams/buffer_list.js"(exports2, module2) {
26825
26825
  "use strict";
26826
26826
  function ownKeys(object, enumerableOnly) {
26827
26827
  var keys = Object.keys(object);
@@ -27101,6 +27101,7 @@ var require_safe_buffer = __commonJS({
27101
27101
  function SafeBuffer(arg, encodingOrOffset, length) {
27102
27102
  return Buffer2(arg, encodingOrOffset, length);
27103
27103
  }
27104
+ SafeBuffer.prototype = Object.create(Buffer2.prototype);
27104
27105
  copyProps(Buffer2, SafeBuffer);
27105
27106
  SafeBuffer.from = function(arg, encodingOrOffset, length) {
27106
27107
  if (typeof arg === "number") {
@@ -27399,9 +27400,9 @@ var require_string_decoder = __commonJS({
27399
27400
  }
27400
27401
  });
27401
27402
 
27402
- // ../../node_modules/winston-transport/node_modules/readable-stream/lib/internal/streams/end-of-stream.js
27403
+ // ../../node_modules/readable-stream/lib/internal/streams/end-of-stream.js
27403
27404
  var require_end_of_stream = __commonJS({
27404
- "../../node_modules/winston-transport/node_modules/readable-stream/lib/internal/streams/end-of-stream.js"(exports2, module2) {
27405
+ "../../node_modules/readable-stream/lib/internal/streams/end-of-stream.js"(exports2, module2) {
27405
27406
  "use strict";
27406
27407
  var ERR_STREAM_PREMATURE_CLOSE = require_errors2().codes.ERR_STREAM_PREMATURE_CLOSE;
27407
27408
  function once(callback) {
@@ -27500,9 +27501,9 @@ var require_end_of_stream = __commonJS({
27500
27501
  }
27501
27502
  });
27502
27503
 
27503
- // ../../node_modules/winston-transport/node_modules/readable-stream/lib/internal/streams/async_iterator.js
27504
+ // ../../node_modules/readable-stream/lib/internal/streams/async_iterator.js
27504
27505
  var require_async_iterator = __commonJS({
27505
- "../../node_modules/winston-transport/node_modules/readable-stream/lib/internal/streams/async_iterator.js"(exports2, module2) {
27506
+ "../../node_modules/readable-stream/lib/internal/streams/async_iterator.js"(exports2, module2) {
27506
27507
  "use strict";
27507
27508
  var _Object$setPrototypeO;
27508
27509
  function _defineProperty(obj, key, value) {
@@ -27685,9 +27686,9 @@ var require_async_iterator = __commonJS({
27685
27686
  }
27686
27687
  });
27687
27688
 
27688
- // ../../node_modules/winston-transport/node_modules/readable-stream/lib/internal/streams/from.js
27689
+ // ../../node_modules/readable-stream/lib/internal/streams/from.js
27689
27690
  var require_from = __commonJS({
27690
- "../../node_modules/winston-transport/node_modules/readable-stream/lib/internal/streams/from.js"(exports2, module2) {
27691
+ "../../node_modules/readable-stream/lib/internal/streams/from.js"(exports2, module2) {
27691
27692
  "use strict";
27692
27693
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
27693
27694
  try {
@@ -27811,9 +27812,9 @@ var require_from = __commonJS({
27811
27812
  }
27812
27813
  });
27813
27814
 
27814
- // ../../node_modules/winston-transport/node_modules/readable-stream/lib/_stream_readable.js
27815
+ // ../../node_modules/readable-stream/lib/_stream_readable.js
27815
27816
  var require_stream_readable = __commonJS({
27816
- "../../node_modules/winston-transport/node_modules/readable-stream/lib/_stream_readable.js"(exports2, module2) {
27817
+ "../../node_modules/readable-stream/lib/_stream_readable.js"(exports2, module2) {
27817
27818
  "use strict";
27818
27819
  module2.exports = Readable;
27819
27820
  var Duplex;
@@ -28607,9 +28608,9 @@ var require_stream_readable = __commonJS({
28607
28608
  }
28608
28609
  });
28609
28610
 
28610
- // ../../node_modules/winston-transport/node_modules/readable-stream/lib/_stream_duplex.js
28611
+ // ../../node_modules/readable-stream/lib/_stream_duplex.js
28611
28612
  var require_stream_duplex = __commonJS({
28612
- "../../node_modules/winston-transport/node_modules/readable-stream/lib/_stream_duplex.js"(exports2, module2) {
28613
+ "../../node_modules/readable-stream/lib/_stream_duplex.js"(exports2, module2) {
28613
28614
  "use strict";
28614
28615
  var objectKeys = Object.keys || function(obj) {
28615
28616
  var keys2 = [];
@@ -28706,9 +28707,9 @@ var require_stream_duplex = __commonJS({
28706
28707
  }
28707
28708
  });
28708
28709
 
28709
- // ../../node_modules/winston-transport/node_modules/readable-stream/lib/_stream_writable.js
28710
+ // ../../node_modules/readable-stream/lib/_stream_writable.js
28710
28711
  var require_stream_writable = __commonJS({
28711
- "../../node_modules/winston-transport/node_modules/readable-stream/lib/_stream_writable.js"(exports2, module2) {
28712
+ "../../node_modules/readable-stream/lib/_stream_writable.js"(exports2, module2) {
28712
28713
  "use strict";
28713
28714
  module2.exports = Writable;
28714
28715
  function CorkedRequest(state) {
@@ -30049,2312 +30050,17 @@ var require_series = __commonJS({
30049
30050
  }
30050
30051
  });
30051
30052
 
30052
- // ../../node_modules/winston/node_modules/readable-stream/lib/internal/streams/stream.js
30053
- var require_stream3 = __commonJS({
30054
- "../../node_modules/winston/node_modules/readable-stream/lib/internal/streams/stream.js"(exports2, module2) {
30055
- "use strict";
30056
- module2.exports = require("stream");
30057
- }
30058
- });
30059
-
30060
- // ../../node_modules/winston/node_modules/readable-stream/lib/internal/streams/buffer_list.js
30061
- var require_buffer_list2 = __commonJS({
30062
- "../../node_modules/winston/node_modules/readable-stream/lib/internal/streams/buffer_list.js"(exports2, module2) {
30063
- "use strict";
30064
- function ownKeys(object, enumerableOnly) {
30065
- var keys = Object.keys(object);
30066
- if (Object.getOwnPropertySymbols) {
30067
- var symbols = Object.getOwnPropertySymbols(object);
30068
- enumerableOnly && (symbols = symbols.filter(function(sym) {
30069
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
30070
- })), keys.push.apply(keys, symbols);
30071
- }
30072
- return keys;
30073
- }
30074
- function _objectSpread(target) {
30075
- for (var i2 = 1; i2 < arguments.length; i2++) {
30076
- var source = null != arguments[i2] ? arguments[i2] : {};
30077
- i2 % 2 ? ownKeys(Object(source), true).forEach(function(key) {
30078
- _defineProperty(target, key, source[key]);
30079
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function(key) {
30080
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
30081
- });
30082
- }
30083
- return target;
30084
- }
30085
- function _defineProperty(obj, key, value) {
30086
- key = _toPropertyKey(key);
30087
- if (key in obj) {
30088
- Object.defineProperty(obj, key, { value, enumerable: true, configurable: true, writable: true });
30089
- } else {
30090
- obj[key] = value;
30091
- }
30092
- return obj;
30093
- }
30094
- function _classCallCheck(instance, Constructor) {
30095
- if (!(instance instanceof Constructor)) {
30096
- throw new TypeError("Cannot call a class as a function");
30097
- }
30098
- }
30099
- function _defineProperties(target, props) {
30100
- for (var i2 = 0; i2 < props.length; i2++) {
30101
- var descriptor = props[i2];
30102
- descriptor.enumerable = descriptor.enumerable || false;
30103
- descriptor.configurable = true;
30104
- if ("value" in descriptor)
30105
- descriptor.writable = true;
30106
- Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
30107
- }
30108
- }
30109
- function _createClass(Constructor, protoProps, staticProps) {
30110
- if (protoProps)
30111
- _defineProperties(Constructor.prototype, protoProps);
30112
- if (staticProps)
30113
- _defineProperties(Constructor, staticProps);
30114
- Object.defineProperty(Constructor, "prototype", { writable: false });
30115
- return Constructor;
30116
- }
30117
- function _toPropertyKey(arg) {
30118
- var key = _toPrimitive(arg, "string");
30119
- return typeof key === "symbol" ? key : String(key);
30120
- }
30121
- function _toPrimitive(input, hint) {
30122
- if (typeof input !== "object" || input === null)
30123
- return input;
30124
- var prim = input[Symbol.toPrimitive];
30125
- if (prim !== void 0) {
30126
- var res = prim.call(input, hint || "default");
30127
- if (typeof res !== "object")
30128
- return res;
30129
- throw new TypeError("@@toPrimitive must return a primitive value.");
30130
- }
30131
- return (hint === "string" ? String : Number)(input);
30132
- }
30133
- var _require = require("buffer");
30134
- var Buffer2 = _require.Buffer;
30135
- var _require2 = require("util");
30136
- var inspect = _require2.inspect;
30137
- var custom = inspect && inspect.custom || "inspect";
30138
- function copyBuffer(src, target, offset) {
30139
- Buffer2.prototype.copy.call(src, target, offset);
30140
- }
30141
- module2.exports = /* @__PURE__ */ function() {
30142
- function BufferList() {
30143
- _classCallCheck(this, BufferList);
30144
- this.head = null;
30145
- this.tail = null;
30146
- this.length = 0;
30147
- }
30148
- _createClass(BufferList, [{
30149
- key: "push",
30150
- value: function push(v2) {
30151
- var entry = {
30152
- data: v2,
30153
- next: null
30154
- };
30155
- if (this.length > 0)
30156
- this.tail.next = entry;
30157
- else
30158
- this.head = entry;
30159
- this.tail = entry;
30160
- ++this.length;
30161
- }
30162
- }, {
30163
- key: "unshift",
30164
- value: function unshift(v2) {
30165
- var entry = {
30166
- data: v2,
30167
- next: this.head
30168
- };
30169
- if (this.length === 0)
30170
- this.tail = entry;
30171
- this.head = entry;
30172
- ++this.length;
30173
- }
30174
- }, {
30175
- key: "shift",
30176
- value: function shift() {
30177
- if (this.length === 0)
30178
- return;
30179
- var ret = this.head.data;
30180
- if (this.length === 1)
30181
- this.head = this.tail = null;
30182
- else
30183
- this.head = this.head.next;
30184
- --this.length;
30185
- return ret;
30186
- }
30187
- }, {
30188
- key: "clear",
30189
- value: function clear() {
30190
- this.head = this.tail = null;
30191
- this.length = 0;
30192
- }
30193
- }, {
30194
- key: "join",
30195
- value: function join2(s) {
30196
- if (this.length === 0)
30197
- return "";
30198
- var p2 = this.head;
30199
- var ret = "" + p2.data;
30200
- while (p2 = p2.next)
30201
- ret += s + p2.data;
30202
- return ret;
30203
- }
30204
- }, {
30205
- key: "concat",
30206
- value: function concat(n) {
30207
- if (this.length === 0)
30208
- return Buffer2.alloc(0);
30209
- var ret = Buffer2.allocUnsafe(n >>> 0);
30210
- var p2 = this.head;
30211
- var i2 = 0;
30212
- while (p2) {
30213
- copyBuffer(p2.data, ret, i2);
30214
- i2 += p2.data.length;
30215
- p2 = p2.next;
30216
- }
30217
- return ret;
30218
- }
30219
- // Consumes a specified amount of bytes or characters from the buffered data.
30220
- }, {
30221
- key: "consume",
30222
- value: function consume(n, hasStrings) {
30223
- var ret;
30224
- if (n < this.head.data.length) {
30225
- ret = this.head.data.slice(0, n);
30226
- this.head.data = this.head.data.slice(n);
30227
- } else if (n === this.head.data.length) {
30228
- ret = this.shift();
30229
- } else {
30230
- ret = hasStrings ? this._getString(n) : this._getBuffer(n);
30231
- }
30232
- return ret;
30233
- }
30234
- }, {
30235
- key: "first",
30236
- value: function first() {
30237
- return this.head.data;
30238
- }
30239
- // Consumes a specified amount of characters from the buffered data.
30240
- }, {
30241
- key: "_getString",
30242
- value: function _getString(n) {
30243
- var p2 = this.head;
30244
- var c2 = 1;
30245
- var ret = p2.data;
30246
- n -= ret.length;
30247
- while (p2 = p2.next) {
30248
- var str = p2.data;
30249
- var nb = n > str.length ? str.length : n;
30250
- if (nb === str.length)
30251
- ret += str;
30252
- else
30253
- ret += str.slice(0, n);
30254
- n -= nb;
30255
- if (n === 0) {
30256
- if (nb === str.length) {
30257
- ++c2;
30258
- if (p2.next)
30259
- this.head = p2.next;
30260
- else
30261
- this.head = this.tail = null;
30262
- } else {
30263
- this.head = p2;
30264
- p2.data = str.slice(nb);
30265
- }
30266
- break;
30267
- }
30268
- ++c2;
30269
- }
30270
- this.length -= c2;
30271
- return ret;
30272
- }
30273
- // Consumes a specified amount of bytes from the buffered data.
30274
- }, {
30275
- key: "_getBuffer",
30276
- value: function _getBuffer(n) {
30277
- var ret = Buffer2.allocUnsafe(n);
30278
- var p2 = this.head;
30279
- var c2 = 1;
30280
- p2.data.copy(ret);
30281
- n -= p2.data.length;
30282
- while (p2 = p2.next) {
30283
- var buf = p2.data;
30284
- var nb = n > buf.length ? buf.length : n;
30285
- buf.copy(ret, ret.length - n, 0, nb);
30286
- n -= nb;
30287
- if (n === 0) {
30288
- if (nb === buf.length) {
30289
- ++c2;
30290
- if (p2.next)
30291
- this.head = p2.next;
30292
- else
30293
- this.head = this.tail = null;
30294
- } else {
30295
- this.head = p2;
30296
- p2.data = buf.slice(nb);
30297
- }
30298
- break;
30299
- }
30300
- ++c2;
30301
- }
30302
- this.length -= c2;
30303
- return ret;
30304
- }
30305
- // Make sure the linked list only shows the minimal necessary information.
30306
- }, {
30307
- key: custom,
30308
- value: function value(_2, options) {
30309
- return inspect(this, _objectSpread(_objectSpread({}, options), {}, {
30310
- // Only inspect one level.
30311
- depth: 0,
30312
- // It should not recurse.
30313
- customInspect: false
30314
- }));
30315
- }
30316
- }]);
30317
- return BufferList;
30318
- }();
30319
- }
30320
- });
30321
-
30322
- // ../../node_modules/winston/node_modules/readable-stream/lib/internal/streams/destroy.js
30323
- var require_destroy2 = __commonJS({
30324
- "../../node_modules/winston/node_modules/readable-stream/lib/internal/streams/destroy.js"(exports2, module2) {
30325
- "use strict";
30326
- function destroy(err, cb) {
30327
- var _this = this;
30328
- var readableDestroyed = this._readableState && this._readableState.destroyed;
30329
- var writableDestroyed = this._writableState && this._writableState.destroyed;
30330
- if (readableDestroyed || writableDestroyed) {
30331
- if (cb) {
30332
- cb(err);
30333
- } else if (err) {
30334
- if (!this._writableState) {
30335
- process.nextTick(emitErrorNT, this, err);
30336
- } else if (!this._writableState.errorEmitted) {
30337
- this._writableState.errorEmitted = true;
30338
- process.nextTick(emitErrorNT, this, err);
30339
- }
30340
- }
30341
- return this;
30342
- }
30343
- if (this._readableState) {
30344
- this._readableState.destroyed = true;
30345
- }
30346
- if (this._writableState) {
30347
- this._writableState.destroyed = true;
30348
- }
30349
- this._destroy(err || null, function(err2) {
30350
- if (!cb && err2) {
30351
- if (!_this._writableState) {
30352
- process.nextTick(emitErrorAndCloseNT, _this, err2);
30353
- } else if (!_this._writableState.errorEmitted) {
30354
- _this._writableState.errorEmitted = true;
30355
- process.nextTick(emitErrorAndCloseNT, _this, err2);
30356
- } else {
30357
- process.nextTick(emitCloseNT, _this);
30358
- }
30359
- } else if (cb) {
30360
- process.nextTick(emitCloseNT, _this);
30361
- cb(err2);
30362
- } else {
30363
- process.nextTick(emitCloseNT, _this);
30364
- }
30365
- });
30366
- return this;
30367
- }
30368
- function emitErrorAndCloseNT(self2, err) {
30369
- emitErrorNT(self2, err);
30370
- emitCloseNT(self2);
30371
- }
30372
- function emitCloseNT(self2) {
30373
- if (self2._writableState && !self2._writableState.emitClose)
30374
- return;
30375
- if (self2._readableState && !self2._readableState.emitClose)
30376
- return;
30377
- self2.emit("close");
30378
- }
30379
- function undestroy() {
30380
- if (this._readableState) {
30381
- this._readableState.destroyed = false;
30382
- this._readableState.reading = false;
30383
- this._readableState.ended = false;
30384
- this._readableState.endEmitted = false;
30385
- }
30386
- if (this._writableState) {
30387
- this._writableState.destroyed = false;
30388
- this._writableState.ended = false;
30389
- this._writableState.ending = false;
30390
- this._writableState.finalCalled = false;
30391
- this._writableState.prefinished = false;
30392
- this._writableState.finished = false;
30393
- this._writableState.errorEmitted = false;
30394
- }
30395
- }
30396
- function emitErrorNT(self2, err) {
30397
- self2.emit("error", err);
30398
- }
30399
- function errorOrDestroy(stream, err) {
30400
- var rState = stream._readableState;
30401
- var wState = stream._writableState;
30402
- if (rState && rState.autoDestroy || wState && wState.autoDestroy)
30403
- stream.destroy(err);
30404
- else
30405
- stream.emit("error", err);
30406
- }
30407
- module2.exports = {
30408
- destroy,
30409
- undestroy,
30410
- errorOrDestroy
30411
- };
30412
- }
30413
- });
30414
-
30415
- // ../../node_modules/winston/node_modules/readable-stream/errors.js
30416
- var require_errors3 = __commonJS({
30417
- "../../node_modules/winston/node_modules/readable-stream/errors.js"(exports2, module2) {
30418
- "use strict";
30419
- var codes = {};
30420
- function createErrorType(code, message, Base) {
30421
- if (!Base) {
30422
- Base = Error;
30423
- }
30424
- function getMessage(arg1, arg2, arg3) {
30425
- if (typeof message === "string") {
30426
- return message;
30427
- } else {
30428
- return message(arg1, arg2, arg3);
30429
- }
30430
- }
30431
- class NodeError extends Base {
30432
- constructor(arg1, arg2, arg3) {
30433
- super(getMessage(arg1, arg2, arg3));
30434
- }
30435
- }
30436
- NodeError.prototype.name = Base.name;
30437
- NodeError.prototype.code = code;
30438
- codes[code] = NodeError;
30439
- }
30440
- function oneOf(expected, thing) {
30441
- if (Array.isArray(expected)) {
30442
- const len = expected.length;
30443
- expected = expected.map((i2) => String(i2));
30444
- if (len > 2) {
30445
- return `one of ${thing} ${expected.slice(0, len - 1).join(", ")}, or ` + expected[len - 1];
30446
- } else if (len === 2) {
30447
- return `one of ${thing} ${expected[0]} or ${expected[1]}`;
30448
- } else {
30449
- return `of ${thing} ${expected[0]}`;
30450
- }
30451
- } else {
30452
- return `of ${thing} ${String(expected)}`;
30453
- }
30454
- }
30455
- function startsWith(str, search, pos) {
30456
- return str.substr(!pos || pos < 0 ? 0 : +pos, search.length) === search;
30457
- }
30458
- function endsWith(str, search, this_len) {
30459
- if (this_len === void 0 || this_len > str.length) {
30460
- this_len = str.length;
30461
- }
30462
- return str.substring(this_len - search.length, this_len) === search;
30463
- }
30464
- function includes(str, search, start) {
30465
- if (typeof start !== "number") {
30466
- start = 0;
30467
- }
30468
- if (start + search.length > str.length) {
30469
- return false;
30470
- } else {
30471
- return str.indexOf(search, start) !== -1;
30472
- }
30473
- }
30474
- createErrorType("ERR_INVALID_OPT_VALUE", function(name, value) {
30475
- return 'The value "' + value + '" is invalid for option "' + name + '"';
30476
- }, TypeError);
30477
- createErrorType("ERR_INVALID_ARG_TYPE", function(name, expected, actual) {
30478
- let determiner;
30479
- if (typeof expected === "string" && startsWith(expected, "not ")) {
30480
- determiner = "must not be";
30481
- expected = expected.replace(/^not /, "");
30482
- } else {
30483
- determiner = "must be";
30484
- }
30485
- let msg;
30486
- if (endsWith(name, " argument")) {
30487
- msg = `The ${name} ${determiner} ${oneOf(expected, "type")}`;
30488
- } else {
30489
- const type = includes(name, ".") ? "property" : "argument";
30490
- msg = `The "${name}" ${type} ${determiner} ${oneOf(expected, "type")}`;
30491
- }
30492
- msg += `. Received type ${typeof actual}`;
30493
- return msg;
30494
- }, TypeError);
30495
- createErrorType("ERR_STREAM_PUSH_AFTER_EOF", "stream.push() after EOF");
30496
- createErrorType("ERR_METHOD_NOT_IMPLEMENTED", function(name) {
30497
- return "The " + name + " method is not implemented";
30498
- });
30499
- createErrorType("ERR_STREAM_PREMATURE_CLOSE", "Premature close");
30500
- createErrorType("ERR_STREAM_DESTROYED", function(name) {
30501
- return "Cannot call " + name + " after a stream was destroyed";
30502
- });
30503
- createErrorType("ERR_MULTIPLE_CALLBACK", "Callback called multiple times");
30504
- createErrorType("ERR_STREAM_CANNOT_PIPE", "Cannot pipe, not readable");
30505
- createErrorType("ERR_STREAM_WRITE_AFTER_END", "write after end");
30506
- createErrorType("ERR_STREAM_NULL_VALUES", "May not write null values to stream", TypeError);
30507
- createErrorType("ERR_UNKNOWN_ENCODING", function(arg) {
30508
- return "Unknown encoding: " + arg;
30509
- }, TypeError);
30510
- createErrorType("ERR_STREAM_UNSHIFT_AFTER_END_EVENT", "stream.unshift() after end event");
30511
- module2.exports.codes = codes;
30512
- }
30513
- });
30514
-
30515
- // ../../node_modules/winston/node_modules/readable-stream/lib/internal/streams/state.js
30516
- var require_state2 = __commonJS({
30517
- "../../node_modules/winston/node_modules/readable-stream/lib/internal/streams/state.js"(exports2, module2) {
30518
- "use strict";
30519
- var ERR_INVALID_OPT_VALUE = require_errors3().codes.ERR_INVALID_OPT_VALUE;
30520
- function highWaterMarkFrom(options, isDuplex, duplexKey) {
30521
- return options.highWaterMark != null ? options.highWaterMark : isDuplex ? options[duplexKey] : null;
30522
- }
30523
- function getHighWaterMark(state, options, duplexKey, isDuplex) {
30524
- var hwm = highWaterMarkFrom(options, isDuplex, duplexKey);
30525
- if (hwm != null) {
30526
- if (!(isFinite(hwm) && Math.floor(hwm) === hwm) || hwm < 0) {
30527
- var name = isDuplex ? duplexKey : "highWaterMark";
30528
- throw new ERR_INVALID_OPT_VALUE(name, hwm);
30529
- }
30530
- return Math.floor(hwm);
30531
- }
30532
- return state.objectMode ? 16 : 16 * 1024;
30533
- }
30534
- module2.exports = {
30535
- getHighWaterMark
30536
- };
30537
- }
30538
- });
30539
-
30540
- // ../../node_modules/winston/node_modules/readable-stream/lib/_stream_writable.js
30541
- var require_stream_writable2 = __commonJS({
30542
- "../../node_modules/winston/node_modules/readable-stream/lib/_stream_writable.js"(exports2, module2) {
30543
- "use strict";
30544
- module2.exports = Writable;
30545
- function CorkedRequest(state) {
30546
- var _this = this;
30547
- this.next = null;
30548
- this.entry = null;
30549
- this.finish = function() {
30550
- onCorkedFinish(_this, state);
30551
- };
30552
- }
30553
- var Duplex;
30554
- Writable.WritableState = WritableState;
30555
- var internalUtil = {
30556
- deprecate: require_node()
30557
- };
30558
- var Stream = require_stream3();
30559
- var Buffer2 = require("buffer").Buffer;
30560
- var OurUint8Array = (typeof global !== "undefined" ? global : typeof window !== "undefined" ? window : typeof self !== "undefined" ? self : {}).Uint8Array || function() {
30561
- };
30562
- function _uint8ArrayToBuffer(chunk) {
30563
- return Buffer2.from(chunk);
30564
- }
30565
- function _isUint8Array(obj) {
30566
- return Buffer2.isBuffer(obj) || obj instanceof OurUint8Array;
30567
- }
30568
- var destroyImpl = require_destroy2();
30569
- var _require = require_state2();
30570
- var getHighWaterMark = _require.getHighWaterMark;
30571
- var _require$codes = require_errors3().codes;
30572
- var ERR_INVALID_ARG_TYPE = _require$codes.ERR_INVALID_ARG_TYPE;
30573
- var ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED;
30574
- var ERR_MULTIPLE_CALLBACK = _require$codes.ERR_MULTIPLE_CALLBACK;
30575
- var ERR_STREAM_CANNOT_PIPE = _require$codes.ERR_STREAM_CANNOT_PIPE;
30576
- var ERR_STREAM_DESTROYED = _require$codes.ERR_STREAM_DESTROYED;
30577
- var ERR_STREAM_NULL_VALUES = _require$codes.ERR_STREAM_NULL_VALUES;
30578
- var ERR_STREAM_WRITE_AFTER_END = _require$codes.ERR_STREAM_WRITE_AFTER_END;
30579
- var ERR_UNKNOWN_ENCODING = _require$codes.ERR_UNKNOWN_ENCODING;
30580
- var errorOrDestroy = destroyImpl.errorOrDestroy;
30581
- require_inherits()(Writable, Stream);
30582
- function nop() {
30583
- }
30584
- function WritableState(options, stream, isDuplex) {
30585
- Duplex = Duplex || require_stream_duplex2();
30586
- options = options || {};
30587
- if (typeof isDuplex !== "boolean")
30588
- isDuplex = stream instanceof Duplex;
30589
- this.objectMode = !!options.objectMode;
30590
- if (isDuplex)
30591
- this.objectMode = this.objectMode || !!options.writableObjectMode;
30592
- this.highWaterMark = getHighWaterMark(this, options, "writableHighWaterMark", isDuplex);
30593
- this.finalCalled = false;
30594
- this.needDrain = false;
30595
- this.ending = false;
30596
- this.ended = false;
30597
- this.finished = false;
30598
- this.destroyed = false;
30599
- var noDecode = options.decodeStrings === false;
30600
- this.decodeStrings = !noDecode;
30601
- this.defaultEncoding = options.defaultEncoding || "utf8";
30602
- this.length = 0;
30603
- this.writing = false;
30604
- this.corked = 0;
30605
- this.sync = true;
30606
- this.bufferProcessing = false;
30607
- this.onwrite = function(er2) {
30608
- onwrite(stream, er2);
30609
- };
30610
- this.writecb = null;
30611
- this.writelen = 0;
30612
- this.bufferedRequest = null;
30613
- this.lastBufferedRequest = null;
30614
- this.pendingcb = 0;
30615
- this.prefinished = false;
30616
- this.errorEmitted = false;
30617
- this.emitClose = options.emitClose !== false;
30618
- this.autoDestroy = !!options.autoDestroy;
30619
- this.bufferedRequestCount = 0;
30620
- this.corkedRequestsFree = new CorkedRequest(this);
30621
- }
30622
- WritableState.prototype.getBuffer = function getBuffer() {
30623
- var current = this.bufferedRequest;
30624
- var out = [];
30625
- while (current) {
30626
- out.push(current);
30627
- current = current.next;
30628
- }
30629
- return out;
30630
- };
30631
- (function() {
30632
- try {
30633
- Object.defineProperty(WritableState.prototype, "buffer", {
30634
- get: internalUtil.deprecate(function writableStateBufferGetter() {
30635
- return this.getBuffer();
30636
- }, "_writableState.buffer is deprecated. Use _writableState.getBuffer instead.", "DEP0003")
30637
- });
30638
- } catch (_2) {
30639
- }
30640
- })();
30641
- var realHasInstance;
30642
- if (typeof Symbol === "function" && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === "function") {
30643
- realHasInstance = Function.prototype[Symbol.hasInstance];
30644
- Object.defineProperty(Writable, Symbol.hasInstance, {
30645
- value: function value(object) {
30646
- if (realHasInstance.call(this, object))
30647
- return true;
30648
- if (this !== Writable)
30649
- return false;
30650
- return object && object._writableState instanceof WritableState;
30651
- }
30652
- });
30653
- } else {
30654
- realHasInstance = function realHasInstance2(object) {
30655
- return object instanceof this;
30656
- };
30657
- }
30658
- function Writable(options) {
30659
- Duplex = Duplex || require_stream_duplex2();
30660
- var isDuplex = this instanceof Duplex;
30661
- if (!isDuplex && !realHasInstance.call(Writable, this))
30662
- return new Writable(options);
30663
- this._writableState = new WritableState(options, this, isDuplex);
30664
- this.writable = true;
30665
- if (options) {
30666
- if (typeof options.write === "function")
30667
- this._write = options.write;
30668
- if (typeof options.writev === "function")
30669
- this._writev = options.writev;
30670
- if (typeof options.destroy === "function")
30671
- this._destroy = options.destroy;
30672
- if (typeof options.final === "function")
30673
- this._final = options.final;
30674
- }
30675
- Stream.call(this);
30676
- }
30677
- Writable.prototype.pipe = function() {
30678
- errorOrDestroy(this, new ERR_STREAM_CANNOT_PIPE());
30679
- };
30680
- function writeAfterEnd(stream, cb) {
30681
- var er2 = new ERR_STREAM_WRITE_AFTER_END();
30682
- errorOrDestroy(stream, er2);
30683
- process.nextTick(cb, er2);
30684
- }
30685
- function validChunk(stream, state, chunk, cb) {
30686
- var er2;
30687
- if (chunk === null) {
30688
- er2 = new ERR_STREAM_NULL_VALUES();
30689
- } else if (typeof chunk !== "string" && !state.objectMode) {
30690
- er2 = new ERR_INVALID_ARG_TYPE("chunk", ["string", "Buffer"], chunk);
30691
- }
30692
- if (er2) {
30693
- errorOrDestroy(stream, er2);
30694
- process.nextTick(cb, er2);
30695
- return false;
30696
- }
30697
- return true;
30698
- }
30699
- Writable.prototype.write = function(chunk, encoding, cb) {
30700
- var state = this._writableState;
30701
- var ret = false;
30702
- var isBuf = !state.objectMode && _isUint8Array(chunk);
30703
- if (isBuf && !Buffer2.isBuffer(chunk)) {
30704
- chunk = _uint8ArrayToBuffer(chunk);
30705
- }
30706
- if (typeof encoding === "function") {
30707
- cb = encoding;
30708
- encoding = null;
30709
- }
30710
- if (isBuf)
30711
- encoding = "buffer";
30712
- else if (!encoding)
30713
- encoding = state.defaultEncoding;
30714
- if (typeof cb !== "function")
30715
- cb = nop;
30716
- if (state.ending)
30717
- writeAfterEnd(this, cb);
30718
- else if (isBuf || validChunk(this, state, chunk, cb)) {
30719
- state.pendingcb++;
30720
- ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb);
30721
- }
30722
- return ret;
30723
- };
30724
- Writable.prototype.cork = function() {
30725
- this._writableState.corked++;
30726
- };
30727
- Writable.prototype.uncork = function() {
30728
- var state = this._writableState;
30729
- if (state.corked) {
30730
- state.corked--;
30731
- if (!state.writing && !state.corked && !state.bufferProcessing && state.bufferedRequest)
30732
- clearBuffer(this, state);
30733
- }
30734
- };
30735
- Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) {
30736
- if (typeof encoding === "string")
30737
- encoding = encoding.toLowerCase();
30738
- if (!(["hex", "utf8", "utf-8", "ascii", "binary", "base64", "ucs2", "ucs-2", "utf16le", "utf-16le", "raw"].indexOf((encoding + "").toLowerCase()) > -1))
30739
- throw new ERR_UNKNOWN_ENCODING(encoding);
30740
- this._writableState.defaultEncoding = encoding;
30741
- return this;
30742
- };
30743
- Object.defineProperty(Writable.prototype, "writableBuffer", {
30744
- // making it explicit this property is not enumerable
30745
- // because otherwise some prototype manipulation in
30746
- // userland will fail
30747
- enumerable: false,
30748
- get: function get() {
30749
- return this._writableState && this._writableState.getBuffer();
30750
- }
30751
- });
30752
- function decodeChunk(state, chunk, encoding) {
30753
- if (!state.objectMode && state.decodeStrings !== false && typeof chunk === "string") {
30754
- chunk = Buffer2.from(chunk, encoding);
30755
- }
30756
- return chunk;
30757
- }
30758
- Object.defineProperty(Writable.prototype, "writableHighWaterMark", {
30759
- // making it explicit this property is not enumerable
30760
- // because otherwise some prototype manipulation in
30761
- // userland will fail
30762
- enumerable: false,
30763
- get: function get() {
30764
- return this._writableState.highWaterMark;
30765
- }
30766
- });
30767
- function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) {
30768
- if (!isBuf) {
30769
- var newChunk = decodeChunk(state, chunk, encoding);
30770
- if (chunk !== newChunk) {
30771
- isBuf = true;
30772
- encoding = "buffer";
30773
- chunk = newChunk;
30774
- }
30775
- }
30776
- var len = state.objectMode ? 1 : chunk.length;
30777
- state.length += len;
30778
- var ret = state.length < state.highWaterMark;
30779
- if (!ret)
30780
- state.needDrain = true;
30781
- if (state.writing || state.corked) {
30782
- var last = state.lastBufferedRequest;
30783
- state.lastBufferedRequest = {
30784
- chunk,
30785
- encoding,
30786
- isBuf,
30787
- callback: cb,
30788
- next: null
30789
- };
30790
- if (last) {
30791
- last.next = state.lastBufferedRequest;
30792
- } else {
30793
- state.bufferedRequest = state.lastBufferedRequest;
30794
- }
30795
- state.bufferedRequestCount += 1;
30796
- } else {
30797
- doWrite(stream, state, false, len, chunk, encoding, cb);
30798
- }
30799
- return ret;
30800
- }
30801
- function doWrite(stream, state, writev, len, chunk, encoding, cb) {
30802
- state.writelen = len;
30803
- state.writecb = cb;
30804
- state.writing = true;
30805
- state.sync = true;
30806
- if (state.destroyed)
30807
- state.onwrite(new ERR_STREAM_DESTROYED("write"));
30808
- else if (writev)
30809
- stream._writev(chunk, state.onwrite);
30810
- else
30811
- stream._write(chunk, encoding, state.onwrite);
30812
- state.sync = false;
30813
- }
30814
- function onwriteError(stream, state, sync, er2, cb) {
30815
- --state.pendingcb;
30816
- if (sync) {
30817
- process.nextTick(cb, er2);
30818
- process.nextTick(finishMaybe, stream, state);
30819
- stream._writableState.errorEmitted = true;
30820
- errorOrDestroy(stream, er2);
30821
- } else {
30822
- cb(er2);
30823
- stream._writableState.errorEmitted = true;
30824
- errorOrDestroy(stream, er2);
30825
- finishMaybe(stream, state);
30826
- }
30827
- }
30828
- function onwriteStateUpdate(state) {
30829
- state.writing = false;
30830
- state.writecb = null;
30831
- state.length -= state.writelen;
30832
- state.writelen = 0;
30833
- }
30834
- function onwrite(stream, er2) {
30835
- var state = stream._writableState;
30836
- var sync = state.sync;
30837
- var cb = state.writecb;
30838
- if (typeof cb !== "function")
30839
- throw new ERR_MULTIPLE_CALLBACK();
30840
- onwriteStateUpdate(state);
30841
- if (er2)
30842
- onwriteError(stream, state, sync, er2, cb);
30843
- else {
30844
- var finished = needFinish(state) || stream.destroyed;
30845
- if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) {
30846
- clearBuffer(stream, state);
30847
- }
30848
- if (sync) {
30849
- process.nextTick(afterWrite, stream, state, finished, cb);
30850
- } else {
30851
- afterWrite(stream, state, finished, cb);
30852
- }
30853
- }
30854
- }
30855
- function afterWrite(stream, state, finished, cb) {
30856
- if (!finished)
30857
- onwriteDrain(stream, state);
30858
- state.pendingcb--;
30859
- cb();
30860
- finishMaybe(stream, state);
30861
- }
30862
- function onwriteDrain(stream, state) {
30863
- if (state.length === 0 && state.needDrain) {
30864
- state.needDrain = false;
30865
- stream.emit("drain");
30866
- }
30867
- }
30868
- function clearBuffer(stream, state) {
30869
- state.bufferProcessing = true;
30870
- var entry = state.bufferedRequest;
30871
- if (stream._writev && entry && entry.next) {
30872
- var l3 = state.bufferedRequestCount;
30873
- var buffer = new Array(l3);
30874
- var holder = state.corkedRequestsFree;
30875
- holder.entry = entry;
30876
- var count = 0;
30877
- var allBuffers = true;
30878
- while (entry) {
30879
- buffer[count] = entry;
30880
- if (!entry.isBuf)
30881
- allBuffers = false;
30882
- entry = entry.next;
30883
- count += 1;
30884
- }
30885
- buffer.allBuffers = allBuffers;
30886
- doWrite(stream, state, true, state.length, buffer, "", holder.finish);
30887
- state.pendingcb++;
30888
- state.lastBufferedRequest = null;
30889
- if (holder.next) {
30890
- state.corkedRequestsFree = holder.next;
30891
- holder.next = null;
30892
- } else {
30893
- state.corkedRequestsFree = new CorkedRequest(state);
30894
- }
30895
- state.bufferedRequestCount = 0;
30896
- } else {
30897
- while (entry) {
30898
- var chunk = entry.chunk;
30899
- var encoding = entry.encoding;
30900
- var cb = entry.callback;
30901
- var len = state.objectMode ? 1 : chunk.length;
30902
- doWrite(stream, state, false, len, chunk, encoding, cb);
30903
- entry = entry.next;
30904
- state.bufferedRequestCount--;
30905
- if (state.writing) {
30906
- break;
30907
- }
30908
- }
30909
- if (entry === null)
30910
- state.lastBufferedRequest = null;
30911
- }
30912
- state.bufferedRequest = entry;
30913
- state.bufferProcessing = false;
30914
- }
30915
- Writable.prototype._write = function(chunk, encoding, cb) {
30916
- cb(new ERR_METHOD_NOT_IMPLEMENTED("_write()"));
30917
- };
30918
- Writable.prototype._writev = null;
30919
- Writable.prototype.end = function(chunk, encoding, cb) {
30920
- var state = this._writableState;
30921
- if (typeof chunk === "function") {
30922
- cb = chunk;
30923
- chunk = null;
30924
- encoding = null;
30925
- } else if (typeof encoding === "function") {
30926
- cb = encoding;
30927
- encoding = null;
30928
- }
30929
- if (chunk !== null && chunk !== void 0)
30930
- this.write(chunk, encoding);
30931
- if (state.corked) {
30932
- state.corked = 1;
30933
- this.uncork();
30934
- }
30935
- if (!state.ending)
30936
- endWritable(this, state, cb);
30937
- return this;
30938
- };
30939
- Object.defineProperty(Writable.prototype, "writableLength", {
30940
- // making it explicit this property is not enumerable
30941
- // because otherwise some prototype manipulation in
30942
- // userland will fail
30943
- enumerable: false,
30944
- get: function get() {
30945
- return this._writableState.length;
30946
- }
30947
- });
30948
- function needFinish(state) {
30949
- return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing;
30950
- }
30951
- function callFinal(stream, state) {
30952
- stream._final(function(err) {
30953
- state.pendingcb--;
30954
- if (err) {
30955
- errorOrDestroy(stream, err);
30956
- }
30957
- state.prefinished = true;
30958
- stream.emit("prefinish");
30959
- finishMaybe(stream, state);
30960
- });
30961
- }
30962
- function prefinish(stream, state) {
30963
- if (!state.prefinished && !state.finalCalled) {
30964
- if (typeof stream._final === "function" && !state.destroyed) {
30965
- state.pendingcb++;
30966
- state.finalCalled = true;
30967
- process.nextTick(callFinal, stream, state);
30968
- } else {
30969
- state.prefinished = true;
30970
- stream.emit("prefinish");
30971
- }
30972
- }
30973
- }
30974
- function finishMaybe(stream, state) {
30975
- var need = needFinish(state);
30976
- if (need) {
30977
- prefinish(stream, state);
30978
- if (state.pendingcb === 0) {
30979
- state.finished = true;
30980
- stream.emit("finish");
30981
- if (state.autoDestroy) {
30982
- var rState = stream._readableState;
30983
- if (!rState || rState.autoDestroy && rState.endEmitted) {
30984
- stream.destroy();
30985
- }
30986
- }
30987
- }
30988
- }
30989
- return need;
30990
- }
30991
- function endWritable(stream, state, cb) {
30992
- state.ending = true;
30993
- finishMaybe(stream, state);
30994
- if (cb) {
30995
- if (state.finished)
30996
- process.nextTick(cb);
30997
- else
30998
- stream.once("finish", cb);
30999
- }
31000
- state.ended = true;
31001
- stream.writable = false;
31002
- }
31003
- function onCorkedFinish(corkReq, state, err) {
31004
- var entry = corkReq.entry;
31005
- corkReq.entry = null;
31006
- while (entry) {
31007
- var cb = entry.callback;
31008
- state.pendingcb--;
31009
- cb(err);
31010
- entry = entry.next;
31011
- }
31012
- state.corkedRequestsFree.next = corkReq;
31013
- }
31014
- Object.defineProperty(Writable.prototype, "destroyed", {
31015
- // making it explicit this property is not enumerable
31016
- // because otherwise some prototype manipulation in
31017
- // userland will fail
31018
- enumerable: false,
31019
- get: function get() {
31020
- if (this._writableState === void 0) {
31021
- return false;
31022
- }
31023
- return this._writableState.destroyed;
31024
- },
31025
- set: function set(value) {
31026
- if (!this._writableState) {
31027
- return;
31028
- }
31029
- this._writableState.destroyed = value;
31030
- }
31031
- });
31032
- Writable.prototype.destroy = destroyImpl.destroy;
31033
- Writable.prototype._undestroy = destroyImpl.undestroy;
31034
- Writable.prototype._destroy = function(err, cb) {
31035
- cb(err);
31036
- };
31037
- }
31038
- });
31039
-
31040
- // ../../node_modules/winston/node_modules/readable-stream/lib/_stream_duplex.js
31041
- var require_stream_duplex2 = __commonJS({
31042
- "../../node_modules/winston/node_modules/readable-stream/lib/_stream_duplex.js"(exports2, module2) {
31043
- "use strict";
31044
- var objectKeys = Object.keys || function(obj) {
31045
- var keys2 = [];
31046
- for (var key in obj)
31047
- keys2.push(key);
31048
- return keys2;
31049
- };
31050
- module2.exports = Duplex;
31051
- var Readable = require_stream_readable2();
31052
- var Writable = require_stream_writable2();
31053
- require_inherits()(Duplex, Readable);
31054
- {
31055
- keys = objectKeys(Writable.prototype);
31056
- for (v2 = 0; v2 < keys.length; v2++) {
31057
- method = keys[v2];
31058
- if (!Duplex.prototype[method])
31059
- Duplex.prototype[method] = Writable.prototype[method];
31060
- }
31061
- }
31062
- var keys;
31063
- var method;
31064
- var v2;
31065
- function Duplex(options) {
31066
- if (!(this instanceof Duplex))
31067
- return new Duplex(options);
31068
- Readable.call(this, options);
31069
- Writable.call(this, options);
31070
- this.allowHalfOpen = true;
31071
- if (options) {
31072
- if (options.readable === false)
31073
- this.readable = false;
31074
- if (options.writable === false)
31075
- this.writable = false;
31076
- if (options.allowHalfOpen === false) {
31077
- this.allowHalfOpen = false;
31078
- this.once("end", onend);
31079
- }
31080
- }
31081
- }
31082
- Object.defineProperty(Duplex.prototype, "writableHighWaterMark", {
31083
- // making it explicit this property is not enumerable
31084
- // because otherwise some prototype manipulation in
31085
- // userland will fail
31086
- enumerable: false,
31087
- get: function get() {
31088
- return this._writableState.highWaterMark;
31089
- }
31090
- });
31091
- Object.defineProperty(Duplex.prototype, "writableBuffer", {
31092
- // making it explicit this property is not enumerable
31093
- // because otherwise some prototype manipulation in
31094
- // userland will fail
31095
- enumerable: false,
31096
- get: function get() {
31097
- return this._writableState && this._writableState.getBuffer();
31098
- }
31099
- });
31100
- Object.defineProperty(Duplex.prototype, "writableLength", {
31101
- // making it explicit this property is not enumerable
31102
- // because otherwise some prototype manipulation in
31103
- // userland will fail
31104
- enumerable: false,
31105
- get: function get() {
31106
- return this._writableState.length;
31107
- }
31108
- });
31109
- function onend() {
31110
- if (this._writableState.ended)
31111
- return;
31112
- process.nextTick(onEndNT, this);
31113
- }
31114
- function onEndNT(self2) {
31115
- self2.end();
31116
- }
31117
- Object.defineProperty(Duplex.prototype, "destroyed", {
31118
- // making it explicit this property is not enumerable
31119
- // because otherwise some prototype manipulation in
31120
- // userland will fail
31121
- enumerable: false,
31122
- get: function get() {
31123
- if (this._readableState === void 0 || this._writableState === void 0) {
31124
- return false;
31125
- }
31126
- return this._readableState.destroyed && this._writableState.destroyed;
31127
- },
31128
- set: function set(value) {
31129
- if (this._readableState === void 0 || this._writableState === void 0) {
31130
- return;
31131
- }
31132
- this._readableState.destroyed = value;
31133
- this._writableState.destroyed = value;
31134
- }
31135
- });
31136
- }
31137
- });
31138
-
31139
- // ../../node_modules/winston/node_modules/readable-stream/lib/internal/streams/end-of-stream.js
31140
- var require_end_of_stream2 = __commonJS({
31141
- "../../node_modules/winston/node_modules/readable-stream/lib/internal/streams/end-of-stream.js"(exports2, module2) {
31142
- "use strict";
31143
- var ERR_STREAM_PREMATURE_CLOSE = require_errors3().codes.ERR_STREAM_PREMATURE_CLOSE;
31144
- function once(callback) {
31145
- var called = false;
31146
- return function() {
31147
- if (called)
31148
- return;
31149
- called = true;
31150
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
31151
- args[_key] = arguments[_key];
31152
- }
31153
- callback.apply(this, args);
31154
- };
31155
- }
31156
- function noop() {
31157
- }
31158
- function isRequest(stream) {
31159
- return stream.setHeader && typeof stream.abort === "function";
31160
- }
31161
- function eos(stream, opts, callback) {
31162
- if (typeof opts === "function")
31163
- return eos(stream, null, opts);
31164
- if (!opts)
31165
- opts = {};
31166
- callback = once(callback || noop);
31167
- var readable = opts.readable || opts.readable !== false && stream.readable;
31168
- var writable = opts.writable || opts.writable !== false && stream.writable;
31169
- var onlegacyfinish = function onlegacyfinish2() {
31170
- if (!stream.writable)
31171
- onfinish();
31172
- };
31173
- var writableEnded = stream._writableState && stream._writableState.finished;
31174
- var onfinish = function onfinish2() {
31175
- writable = false;
31176
- writableEnded = true;
31177
- if (!readable)
31178
- callback.call(stream);
31179
- };
31180
- var readableEnded = stream._readableState && stream._readableState.endEmitted;
31181
- var onend = function onend2() {
31182
- readable = false;
31183
- readableEnded = true;
31184
- if (!writable)
31185
- callback.call(stream);
31186
- };
31187
- var onerror = function onerror2(err) {
31188
- callback.call(stream, err);
31189
- };
31190
- var onclose = function onclose2() {
31191
- var err;
31192
- if (readable && !readableEnded) {
31193
- if (!stream._readableState || !stream._readableState.ended)
31194
- err = new ERR_STREAM_PREMATURE_CLOSE();
31195
- return callback.call(stream, err);
31196
- }
31197
- if (writable && !writableEnded) {
31198
- if (!stream._writableState || !stream._writableState.ended)
31199
- err = new ERR_STREAM_PREMATURE_CLOSE();
31200
- return callback.call(stream, err);
31201
- }
31202
- };
31203
- var onrequest = function onrequest2() {
31204
- stream.req.on("finish", onfinish);
31205
- };
31206
- if (isRequest(stream)) {
31207
- stream.on("complete", onfinish);
31208
- stream.on("abort", onclose);
31209
- if (stream.req)
31210
- onrequest();
31211
- else
31212
- stream.on("request", onrequest);
31213
- } else if (writable && !stream._writableState) {
31214
- stream.on("end", onlegacyfinish);
31215
- stream.on("close", onlegacyfinish);
31216
- }
31217
- stream.on("end", onend);
31218
- stream.on("finish", onfinish);
31219
- if (opts.error !== false)
31220
- stream.on("error", onerror);
31221
- stream.on("close", onclose);
31222
- return function() {
31223
- stream.removeListener("complete", onfinish);
31224
- stream.removeListener("abort", onclose);
31225
- stream.removeListener("request", onrequest);
31226
- if (stream.req)
31227
- stream.req.removeListener("finish", onfinish);
31228
- stream.removeListener("end", onlegacyfinish);
31229
- stream.removeListener("close", onlegacyfinish);
31230
- stream.removeListener("finish", onfinish);
31231
- stream.removeListener("end", onend);
31232
- stream.removeListener("error", onerror);
31233
- stream.removeListener("close", onclose);
31234
- };
31235
- }
31236
- module2.exports = eos;
31237
- }
31238
- });
31239
-
31240
- // ../../node_modules/winston/node_modules/readable-stream/lib/internal/streams/async_iterator.js
31241
- var require_async_iterator2 = __commonJS({
31242
- "../../node_modules/winston/node_modules/readable-stream/lib/internal/streams/async_iterator.js"(exports2, module2) {
31243
- "use strict";
31244
- var _Object$setPrototypeO;
31245
- function _defineProperty(obj, key, value) {
31246
- key = _toPropertyKey(key);
31247
- if (key in obj) {
31248
- Object.defineProperty(obj, key, { value, enumerable: true, configurable: true, writable: true });
31249
- } else {
31250
- obj[key] = value;
31251
- }
31252
- return obj;
31253
- }
31254
- function _toPropertyKey(arg) {
31255
- var key = _toPrimitive(arg, "string");
31256
- return typeof key === "symbol" ? key : String(key);
31257
- }
31258
- function _toPrimitive(input, hint) {
31259
- if (typeof input !== "object" || input === null)
31260
- return input;
31261
- var prim = input[Symbol.toPrimitive];
31262
- if (prim !== void 0) {
31263
- var res = prim.call(input, hint || "default");
31264
- if (typeof res !== "object")
31265
- return res;
31266
- throw new TypeError("@@toPrimitive must return a primitive value.");
31267
- }
31268
- return (hint === "string" ? String : Number)(input);
31269
- }
31270
- var finished = require_end_of_stream2();
31271
- var kLastResolve = Symbol("lastResolve");
31272
- var kLastReject = Symbol("lastReject");
31273
- var kError = Symbol("error");
31274
- var kEnded = Symbol("ended");
31275
- var kLastPromise = Symbol("lastPromise");
31276
- var kHandlePromise = Symbol("handlePromise");
31277
- var kStream = Symbol("stream");
31278
- function createIterResult(value, done) {
31279
- return {
31280
- value,
31281
- done
31282
- };
31283
- }
31284
- function readAndResolve(iter) {
31285
- var resolve = iter[kLastResolve];
31286
- if (resolve !== null) {
31287
- var data2 = iter[kStream].read();
31288
- if (data2 !== null) {
31289
- iter[kLastPromise] = null;
31290
- iter[kLastResolve] = null;
31291
- iter[kLastReject] = null;
31292
- resolve(createIterResult(data2, false));
31293
- }
31294
- }
31295
- }
31296
- function onReadable(iter) {
31297
- process.nextTick(readAndResolve, iter);
31298
- }
31299
- function wrapForNext(lastPromise, iter) {
31300
- return function(resolve, reject) {
31301
- lastPromise.then(function() {
31302
- if (iter[kEnded]) {
31303
- resolve(createIterResult(void 0, true));
31304
- return;
31305
- }
31306
- iter[kHandlePromise](resolve, reject);
31307
- }, reject);
31308
- };
31309
- }
31310
- var AsyncIteratorPrototype = Object.getPrototypeOf(function() {
31311
- });
31312
- var ReadableStreamAsyncIteratorPrototype = Object.setPrototypeOf((_Object$setPrototypeO = {
31313
- get stream() {
31314
- return this[kStream];
31315
- },
31316
- next: function next() {
31317
- var _this = this;
31318
- var error = this[kError];
31319
- if (error !== null) {
31320
- return Promise.reject(error);
31321
- }
31322
- if (this[kEnded]) {
31323
- return Promise.resolve(createIterResult(void 0, true));
31324
- }
31325
- if (this[kStream].destroyed) {
31326
- return new Promise(function(resolve, reject) {
31327
- process.nextTick(function() {
31328
- if (_this[kError]) {
31329
- reject(_this[kError]);
31330
- } else {
31331
- resolve(createIterResult(void 0, true));
31332
- }
31333
- });
31334
- });
31335
- }
31336
- var lastPromise = this[kLastPromise];
31337
- var promise;
31338
- if (lastPromise) {
31339
- promise = new Promise(wrapForNext(lastPromise, this));
31340
- } else {
31341
- var data2 = this[kStream].read();
31342
- if (data2 !== null) {
31343
- return Promise.resolve(createIterResult(data2, false));
31344
- }
31345
- promise = new Promise(this[kHandlePromise]);
31346
- }
31347
- this[kLastPromise] = promise;
31348
- return promise;
31349
- }
31350
- }, _defineProperty(_Object$setPrototypeO, Symbol.asyncIterator, function() {
31351
- return this;
31352
- }), _defineProperty(_Object$setPrototypeO, "return", function _return() {
31353
- var _this2 = this;
31354
- return new Promise(function(resolve, reject) {
31355
- _this2[kStream].destroy(null, function(err) {
31356
- if (err) {
31357
- reject(err);
31358
- return;
31359
- }
31360
- resolve(createIterResult(void 0, true));
31361
- });
31362
- });
31363
- }), _Object$setPrototypeO), AsyncIteratorPrototype);
31364
- var createReadableStreamAsyncIterator = function createReadableStreamAsyncIterator2(stream) {
31365
- var _Object$create;
31366
- var iterator = Object.create(ReadableStreamAsyncIteratorPrototype, (_Object$create = {}, _defineProperty(_Object$create, kStream, {
31367
- value: stream,
31368
- writable: true
31369
- }), _defineProperty(_Object$create, kLastResolve, {
31370
- value: null,
31371
- writable: true
31372
- }), _defineProperty(_Object$create, kLastReject, {
31373
- value: null,
31374
- writable: true
31375
- }), _defineProperty(_Object$create, kError, {
31376
- value: null,
31377
- writable: true
31378
- }), _defineProperty(_Object$create, kEnded, {
31379
- value: stream._readableState.endEmitted,
31380
- writable: true
31381
- }), _defineProperty(_Object$create, kHandlePromise, {
31382
- value: function value(resolve, reject) {
31383
- var data2 = iterator[kStream].read();
31384
- if (data2) {
31385
- iterator[kLastPromise] = null;
31386
- iterator[kLastResolve] = null;
31387
- iterator[kLastReject] = null;
31388
- resolve(createIterResult(data2, false));
31389
- } else {
31390
- iterator[kLastResolve] = resolve;
31391
- iterator[kLastReject] = reject;
31392
- }
31393
- },
31394
- writable: true
31395
- }), _Object$create));
31396
- iterator[kLastPromise] = null;
31397
- finished(stream, function(err) {
31398
- if (err && err.code !== "ERR_STREAM_PREMATURE_CLOSE") {
31399
- var reject = iterator[kLastReject];
31400
- if (reject !== null) {
31401
- iterator[kLastPromise] = null;
31402
- iterator[kLastResolve] = null;
31403
- iterator[kLastReject] = null;
31404
- reject(err);
31405
- }
31406
- iterator[kError] = err;
31407
- return;
31408
- }
31409
- var resolve = iterator[kLastResolve];
31410
- if (resolve !== null) {
31411
- iterator[kLastPromise] = null;
31412
- iterator[kLastResolve] = null;
31413
- iterator[kLastReject] = null;
31414
- resolve(createIterResult(void 0, true));
31415
- }
31416
- iterator[kEnded] = true;
31417
- });
31418
- stream.on("readable", onReadable.bind(null, iterator));
31419
- return iterator;
31420
- };
31421
- module2.exports = createReadableStreamAsyncIterator;
31422
- }
31423
- });
31424
-
31425
- // ../../node_modules/winston/node_modules/readable-stream/lib/internal/streams/from.js
31426
- var require_from2 = __commonJS({
31427
- "../../node_modules/winston/node_modules/readable-stream/lib/internal/streams/from.js"(exports2, module2) {
31428
- "use strict";
31429
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
31430
- try {
31431
- var info = gen[key](arg);
31432
- var value = info.value;
31433
- } catch (error) {
31434
- reject(error);
31435
- return;
31436
- }
31437
- if (info.done) {
31438
- resolve(value);
31439
- } else {
31440
- Promise.resolve(value).then(_next, _throw);
31441
- }
31442
- }
31443
- function _asyncToGenerator(fn) {
31444
- return function() {
31445
- var self2 = this, args = arguments;
31446
- return new Promise(function(resolve, reject) {
31447
- var gen = fn.apply(self2, args);
31448
- function _next(value) {
31449
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
31450
- }
31451
- function _throw(err) {
31452
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
31453
- }
31454
- _next(void 0);
31455
- });
31456
- };
31457
- }
31458
- function ownKeys(object, enumerableOnly) {
31459
- var keys = Object.keys(object);
31460
- if (Object.getOwnPropertySymbols) {
31461
- var symbols = Object.getOwnPropertySymbols(object);
31462
- enumerableOnly && (symbols = symbols.filter(function(sym) {
31463
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
31464
- })), keys.push.apply(keys, symbols);
31465
- }
31466
- return keys;
31467
- }
31468
- function _objectSpread(target) {
31469
- for (var i2 = 1; i2 < arguments.length; i2++) {
31470
- var source = null != arguments[i2] ? arguments[i2] : {};
31471
- i2 % 2 ? ownKeys(Object(source), true).forEach(function(key) {
31472
- _defineProperty(target, key, source[key]);
31473
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function(key) {
31474
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
31475
- });
31476
- }
31477
- return target;
31478
- }
31479
- function _defineProperty(obj, key, value) {
31480
- key = _toPropertyKey(key);
31481
- if (key in obj) {
31482
- Object.defineProperty(obj, key, { value, enumerable: true, configurable: true, writable: true });
31483
- } else {
31484
- obj[key] = value;
31485
- }
31486
- return obj;
31487
- }
31488
- function _toPropertyKey(arg) {
31489
- var key = _toPrimitive(arg, "string");
31490
- return typeof key === "symbol" ? key : String(key);
31491
- }
31492
- function _toPrimitive(input, hint) {
31493
- if (typeof input !== "object" || input === null)
31494
- return input;
31495
- var prim = input[Symbol.toPrimitive];
31496
- if (prim !== void 0) {
31497
- var res = prim.call(input, hint || "default");
31498
- if (typeof res !== "object")
31499
- return res;
31500
- throw new TypeError("@@toPrimitive must return a primitive value.");
31501
- }
31502
- return (hint === "string" ? String : Number)(input);
31503
- }
31504
- var ERR_INVALID_ARG_TYPE = require_errors3().codes.ERR_INVALID_ARG_TYPE;
31505
- function from(Readable, iterable, opts) {
31506
- var iterator;
31507
- if (iterable && typeof iterable.next === "function") {
31508
- iterator = iterable;
31509
- } else if (iterable && iterable[Symbol.asyncIterator])
31510
- iterator = iterable[Symbol.asyncIterator]();
31511
- else if (iterable && iterable[Symbol.iterator])
31512
- iterator = iterable[Symbol.iterator]();
31513
- else
31514
- throw new ERR_INVALID_ARG_TYPE("iterable", ["Iterable"], iterable);
31515
- var readable = new Readable(_objectSpread({
31516
- objectMode: true
31517
- }, opts));
31518
- var reading = false;
31519
- readable._read = function() {
31520
- if (!reading) {
31521
- reading = true;
31522
- next();
31523
- }
31524
- };
31525
- function next() {
31526
- return _next2.apply(this, arguments);
31527
- }
31528
- function _next2() {
31529
- _next2 = _asyncToGenerator(function* () {
31530
- try {
31531
- var _yield$iterator$next = yield iterator.next(), value = _yield$iterator$next.value, done = _yield$iterator$next.done;
31532
- if (done) {
31533
- readable.push(null);
31534
- } else if (readable.push(yield value)) {
31535
- next();
31536
- } else {
31537
- reading = false;
31538
- }
31539
- } catch (err) {
31540
- readable.destroy(err);
31541
- }
31542
- });
31543
- return _next2.apply(this, arguments);
31544
- }
31545
- return readable;
31546
- }
31547
- module2.exports = from;
31548
- }
31549
- });
31550
-
31551
- // ../../node_modules/winston/node_modules/readable-stream/lib/_stream_readable.js
31552
- var require_stream_readable2 = __commonJS({
31553
- "../../node_modules/winston/node_modules/readable-stream/lib/_stream_readable.js"(exports2, module2) {
31554
- "use strict";
31555
- module2.exports = Readable;
31556
- var Duplex;
31557
- Readable.ReadableState = ReadableState;
31558
- var EE = require("events").EventEmitter;
31559
- var EElistenerCount = function EElistenerCount2(emitter, type) {
31560
- return emitter.listeners(type).length;
31561
- };
31562
- var Stream = require_stream3();
31563
- var Buffer2 = require("buffer").Buffer;
31564
- var OurUint8Array = (typeof global !== "undefined" ? global : typeof window !== "undefined" ? window : typeof self !== "undefined" ? self : {}).Uint8Array || function() {
31565
- };
31566
- function _uint8ArrayToBuffer(chunk) {
31567
- return Buffer2.from(chunk);
31568
- }
31569
- function _isUint8Array(obj) {
31570
- return Buffer2.isBuffer(obj) || obj instanceof OurUint8Array;
31571
- }
31572
- var debugUtil = require("util");
31573
- var debug;
31574
- if (debugUtil && debugUtil.debuglog) {
31575
- debug = debugUtil.debuglog("stream");
31576
- } else {
31577
- debug = function debug2() {
31578
- };
31579
- }
31580
- var BufferList = require_buffer_list2();
31581
- var destroyImpl = require_destroy2();
31582
- var _require = require_state2();
31583
- var getHighWaterMark = _require.getHighWaterMark;
31584
- var _require$codes = require_errors3().codes;
31585
- var ERR_INVALID_ARG_TYPE = _require$codes.ERR_INVALID_ARG_TYPE;
31586
- var ERR_STREAM_PUSH_AFTER_EOF = _require$codes.ERR_STREAM_PUSH_AFTER_EOF;
31587
- var ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED;
31588
- var ERR_STREAM_UNSHIFT_AFTER_END_EVENT = _require$codes.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;
31589
- var StringDecoder;
31590
- var createReadableStreamAsyncIterator;
31591
- var from;
31592
- require_inherits()(Readable, Stream);
31593
- var errorOrDestroy = destroyImpl.errorOrDestroy;
31594
- var kProxyEvents = ["error", "close", "destroy", "pause", "resume"];
31595
- function prependListener(emitter, event, fn) {
31596
- if (typeof emitter.prependListener === "function")
31597
- return emitter.prependListener(event, fn);
31598
- if (!emitter._events || !emitter._events[event])
31599
- emitter.on(event, fn);
31600
- else if (Array.isArray(emitter._events[event]))
31601
- emitter._events[event].unshift(fn);
31602
- else
31603
- emitter._events[event] = [fn, emitter._events[event]];
31604
- }
31605
- function ReadableState(options, stream, isDuplex) {
31606
- Duplex = Duplex || require_stream_duplex2();
31607
- options = options || {};
31608
- if (typeof isDuplex !== "boolean")
31609
- isDuplex = stream instanceof Duplex;
31610
- this.objectMode = !!options.objectMode;
31611
- if (isDuplex)
31612
- this.objectMode = this.objectMode || !!options.readableObjectMode;
31613
- this.highWaterMark = getHighWaterMark(this, options, "readableHighWaterMark", isDuplex);
31614
- this.buffer = new BufferList();
31615
- this.length = 0;
31616
- this.pipes = null;
31617
- this.pipesCount = 0;
31618
- this.flowing = null;
31619
- this.ended = false;
31620
- this.endEmitted = false;
31621
- this.reading = false;
31622
- this.sync = true;
31623
- this.needReadable = false;
31624
- this.emittedReadable = false;
31625
- this.readableListening = false;
31626
- this.resumeScheduled = false;
31627
- this.paused = true;
31628
- this.emitClose = options.emitClose !== false;
31629
- this.autoDestroy = !!options.autoDestroy;
31630
- this.destroyed = false;
31631
- this.defaultEncoding = options.defaultEncoding || "utf8";
31632
- this.awaitDrain = 0;
31633
- this.readingMore = false;
31634
- this.decoder = null;
31635
- this.encoding = null;
31636
- if (options.encoding) {
31637
- if (!StringDecoder)
31638
- StringDecoder = require_string_decoder().StringDecoder;
31639
- this.decoder = new StringDecoder(options.encoding);
31640
- this.encoding = options.encoding;
31641
- }
31642
- }
31643
- function Readable(options) {
31644
- Duplex = Duplex || require_stream_duplex2();
31645
- if (!(this instanceof Readable))
31646
- return new Readable(options);
31647
- var isDuplex = this instanceof Duplex;
31648
- this._readableState = new ReadableState(options, this, isDuplex);
31649
- this.readable = true;
31650
- if (options) {
31651
- if (typeof options.read === "function")
31652
- this._read = options.read;
31653
- if (typeof options.destroy === "function")
31654
- this._destroy = options.destroy;
31655
- }
31656
- Stream.call(this);
31657
- }
31658
- Object.defineProperty(Readable.prototype, "destroyed", {
31659
- // making it explicit this property is not enumerable
31660
- // because otherwise some prototype manipulation in
31661
- // userland will fail
31662
- enumerable: false,
31663
- get: function get() {
31664
- if (this._readableState === void 0) {
31665
- return false;
31666
- }
31667
- return this._readableState.destroyed;
31668
- },
31669
- set: function set(value) {
31670
- if (!this._readableState) {
31671
- return;
31672
- }
31673
- this._readableState.destroyed = value;
31674
- }
31675
- });
31676
- Readable.prototype.destroy = destroyImpl.destroy;
31677
- Readable.prototype._undestroy = destroyImpl.undestroy;
31678
- Readable.prototype._destroy = function(err, cb) {
31679
- cb(err);
31680
- };
31681
- Readable.prototype.push = function(chunk, encoding) {
31682
- var state = this._readableState;
31683
- var skipChunkCheck;
31684
- if (!state.objectMode) {
31685
- if (typeof chunk === "string") {
31686
- encoding = encoding || state.defaultEncoding;
31687
- if (encoding !== state.encoding) {
31688
- chunk = Buffer2.from(chunk, encoding);
31689
- encoding = "";
31690
- }
31691
- skipChunkCheck = true;
31692
- }
31693
- } else {
31694
- skipChunkCheck = true;
31695
- }
31696
- return readableAddChunk(this, chunk, encoding, false, skipChunkCheck);
31697
- };
31698
- Readable.prototype.unshift = function(chunk) {
31699
- return readableAddChunk(this, chunk, null, true, false);
31700
- };
31701
- function readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) {
31702
- debug("readableAddChunk", chunk);
31703
- var state = stream._readableState;
31704
- if (chunk === null) {
31705
- state.reading = false;
31706
- onEofChunk(stream, state);
31707
- } else {
31708
- var er2;
31709
- if (!skipChunkCheck)
31710
- er2 = chunkInvalid(state, chunk);
31711
- if (er2) {
31712
- errorOrDestroy(stream, er2);
31713
- } else if (state.objectMode || chunk && chunk.length > 0) {
31714
- if (typeof chunk !== "string" && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer2.prototype) {
31715
- chunk = _uint8ArrayToBuffer(chunk);
31716
- }
31717
- if (addToFront) {
31718
- if (state.endEmitted)
31719
- errorOrDestroy(stream, new ERR_STREAM_UNSHIFT_AFTER_END_EVENT());
31720
- else
31721
- addChunk(stream, state, chunk, true);
31722
- } else if (state.ended) {
31723
- errorOrDestroy(stream, new ERR_STREAM_PUSH_AFTER_EOF());
31724
- } else if (state.destroyed) {
31725
- return false;
31726
- } else {
31727
- state.reading = false;
31728
- if (state.decoder && !encoding) {
31729
- chunk = state.decoder.write(chunk);
31730
- if (state.objectMode || chunk.length !== 0)
31731
- addChunk(stream, state, chunk, false);
31732
- else
31733
- maybeReadMore(stream, state);
31734
- } else {
31735
- addChunk(stream, state, chunk, false);
31736
- }
31737
- }
31738
- } else if (!addToFront) {
31739
- state.reading = false;
31740
- maybeReadMore(stream, state);
31741
- }
31742
- }
31743
- return !state.ended && (state.length < state.highWaterMark || state.length === 0);
31744
- }
31745
- function addChunk(stream, state, chunk, addToFront) {
31746
- if (state.flowing && state.length === 0 && !state.sync) {
31747
- state.awaitDrain = 0;
31748
- stream.emit("data", chunk);
31749
- } else {
31750
- state.length += state.objectMode ? 1 : chunk.length;
31751
- if (addToFront)
31752
- state.buffer.unshift(chunk);
31753
- else
31754
- state.buffer.push(chunk);
31755
- if (state.needReadable)
31756
- emitReadable(stream);
31757
- }
31758
- maybeReadMore(stream, state);
31759
- }
31760
- function chunkInvalid(state, chunk) {
31761
- var er2;
31762
- if (!_isUint8Array(chunk) && typeof chunk !== "string" && chunk !== void 0 && !state.objectMode) {
31763
- er2 = new ERR_INVALID_ARG_TYPE("chunk", ["string", "Buffer", "Uint8Array"], chunk);
31764
- }
31765
- return er2;
31766
- }
31767
- Readable.prototype.isPaused = function() {
31768
- return this._readableState.flowing === false;
31769
- };
31770
- Readable.prototype.setEncoding = function(enc) {
31771
- if (!StringDecoder)
31772
- StringDecoder = require_string_decoder().StringDecoder;
31773
- var decoder = new StringDecoder(enc);
31774
- this._readableState.decoder = decoder;
31775
- this._readableState.encoding = this._readableState.decoder.encoding;
31776
- var p2 = this._readableState.buffer.head;
31777
- var content = "";
31778
- while (p2 !== null) {
31779
- content += decoder.write(p2.data);
31780
- p2 = p2.next;
31781
- }
31782
- this._readableState.buffer.clear();
31783
- if (content !== "")
31784
- this._readableState.buffer.push(content);
31785
- this._readableState.length = content.length;
31786
- return this;
31787
- };
31788
- var MAX_HWM = 1073741824;
31789
- function computeNewHighWaterMark(n) {
31790
- if (n >= MAX_HWM) {
31791
- n = MAX_HWM;
31792
- } else {
31793
- n--;
31794
- n |= n >>> 1;
31795
- n |= n >>> 2;
31796
- n |= n >>> 4;
31797
- n |= n >>> 8;
31798
- n |= n >>> 16;
31799
- n++;
31800
- }
31801
- return n;
31802
- }
31803
- function howMuchToRead(n, state) {
31804
- if (n <= 0 || state.length === 0 && state.ended)
31805
- return 0;
31806
- if (state.objectMode)
31807
- return 1;
31808
- if (n !== n) {
31809
- if (state.flowing && state.length)
31810
- return state.buffer.head.data.length;
31811
- else
31812
- return state.length;
31813
- }
31814
- if (n > state.highWaterMark)
31815
- state.highWaterMark = computeNewHighWaterMark(n);
31816
- if (n <= state.length)
31817
- return n;
31818
- if (!state.ended) {
31819
- state.needReadable = true;
31820
- return 0;
31821
- }
31822
- return state.length;
31823
- }
31824
- Readable.prototype.read = function(n) {
31825
- debug("read", n);
31826
- n = parseInt(n, 10);
31827
- var state = this._readableState;
31828
- var nOrig = n;
31829
- if (n !== 0)
31830
- state.emittedReadable = false;
31831
- if (n === 0 && state.needReadable && ((state.highWaterMark !== 0 ? state.length >= state.highWaterMark : state.length > 0) || state.ended)) {
31832
- debug("read: emitReadable", state.length, state.ended);
31833
- if (state.length === 0 && state.ended)
31834
- endReadable(this);
31835
- else
31836
- emitReadable(this);
31837
- return null;
31838
- }
31839
- n = howMuchToRead(n, state);
31840
- if (n === 0 && state.ended) {
31841
- if (state.length === 0)
31842
- endReadable(this);
31843
- return null;
31844
- }
31845
- var doRead = state.needReadable;
31846
- debug("need readable", doRead);
31847
- if (state.length === 0 || state.length - n < state.highWaterMark) {
31848
- doRead = true;
31849
- debug("length less than watermark", doRead);
31850
- }
31851
- if (state.ended || state.reading) {
31852
- doRead = false;
31853
- debug("reading or ended", doRead);
31854
- } else if (doRead) {
31855
- debug("do read");
31856
- state.reading = true;
31857
- state.sync = true;
31858
- if (state.length === 0)
31859
- state.needReadable = true;
31860
- this._read(state.highWaterMark);
31861
- state.sync = false;
31862
- if (!state.reading)
31863
- n = howMuchToRead(nOrig, state);
31864
- }
31865
- var ret;
31866
- if (n > 0)
31867
- ret = fromList(n, state);
31868
- else
31869
- ret = null;
31870
- if (ret === null) {
31871
- state.needReadable = state.length <= state.highWaterMark;
31872
- n = 0;
31873
- } else {
31874
- state.length -= n;
31875
- state.awaitDrain = 0;
31876
- }
31877
- if (state.length === 0) {
31878
- if (!state.ended)
31879
- state.needReadable = true;
31880
- if (nOrig !== n && state.ended)
31881
- endReadable(this);
31882
- }
31883
- if (ret !== null)
31884
- this.emit("data", ret);
31885
- return ret;
31886
- };
31887
- function onEofChunk(stream, state) {
31888
- debug("onEofChunk");
31889
- if (state.ended)
31890
- return;
31891
- if (state.decoder) {
31892
- var chunk = state.decoder.end();
31893
- if (chunk && chunk.length) {
31894
- state.buffer.push(chunk);
31895
- state.length += state.objectMode ? 1 : chunk.length;
31896
- }
31897
- }
31898
- state.ended = true;
31899
- if (state.sync) {
31900
- emitReadable(stream);
31901
- } else {
31902
- state.needReadable = false;
31903
- if (!state.emittedReadable) {
31904
- state.emittedReadable = true;
31905
- emitReadable_(stream);
31906
- }
31907
- }
31908
- }
31909
- function emitReadable(stream) {
31910
- var state = stream._readableState;
31911
- debug("emitReadable", state.needReadable, state.emittedReadable);
31912
- state.needReadable = false;
31913
- if (!state.emittedReadable) {
31914
- debug("emitReadable", state.flowing);
31915
- state.emittedReadable = true;
31916
- process.nextTick(emitReadable_, stream);
31917
- }
31918
- }
31919
- function emitReadable_(stream) {
31920
- var state = stream._readableState;
31921
- debug("emitReadable_", state.destroyed, state.length, state.ended);
31922
- if (!state.destroyed && (state.length || state.ended)) {
31923
- stream.emit("readable");
31924
- state.emittedReadable = false;
31925
- }
31926
- state.needReadable = !state.flowing && !state.ended && state.length <= state.highWaterMark;
31927
- flow(stream);
31928
- }
31929
- function maybeReadMore(stream, state) {
31930
- if (!state.readingMore) {
31931
- state.readingMore = true;
31932
- process.nextTick(maybeReadMore_, stream, state);
31933
- }
31934
- }
31935
- function maybeReadMore_(stream, state) {
31936
- while (!state.reading && !state.ended && (state.length < state.highWaterMark || state.flowing && state.length === 0)) {
31937
- var len = state.length;
31938
- debug("maybeReadMore read 0");
31939
- stream.read(0);
31940
- if (len === state.length)
31941
- break;
31942
- }
31943
- state.readingMore = false;
31944
- }
31945
- Readable.prototype._read = function(n) {
31946
- errorOrDestroy(this, new ERR_METHOD_NOT_IMPLEMENTED("_read()"));
31947
- };
31948
- Readable.prototype.pipe = function(dest, pipeOpts) {
31949
- var src = this;
31950
- var state = this._readableState;
31951
- switch (state.pipesCount) {
31952
- case 0:
31953
- state.pipes = dest;
31954
- break;
31955
- case 1:
31956
- state.pipes = [state.pipes, dest];
31957
- break;
31958
- default:
31959
- state.pipes.push(dest);
31960
- break;
31961
- }
31962
- state.pipesCount += 1;
31963
- debug("pipe count=%d opts=%j", state.pipesCount, pipeOpts);
31964
- var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr;
31965
- var endFn = doEnd ? onend : unpipe;
31966
- if (state.endEmitted)
31967
- process.nextTick(endFn);
31968
- else
31969
- src.once("end", endFn);
31970
- dest.on("unpipe", onunpipe);
31971
- function onunpipe(readable, unpipeInfo) {
31972
- debug("onunpipe");
31973
- if (readable === src) {
31974
- if (unpipeInfo && unpipeInfo.hasUnpiped === false) {
31975
- unpipeInfo.hasUnpiped = true;
31976
- cleanup();
31977
- }
31978
- }
31979
- }
31980
- function onend() {
31981
- debug("onend");
31982
- dest.end();
31983
- }
31984
- var ondrain = pipeOnDrain(src);
31985
- dest.on("drain", ondrain);
31986
- var cleanedUp = false;
31987
- function cleanup() {
31988
- debug("cleanup");
31989
- dest.removeListener("close", onclose);
31990
- dest.removeListener("finish", onfinish);
31991
- dest.removeListener("drain", ondrain);
31992
- dest.removeListener("error", onerror);
31993
- dest.removeListener("unpipe", onunpipe);
31994
- src.removeListener("end", onend);
31995
- src.removeListener("end", unpipe);
31996
- src.removeListener("data", ondata);
31997
- cleanedUp = true;
31998
- if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain))
31999
- ondrain();
32000
- }
32001
- src.on("data", ondata);
32002
- function ondata(chunk) {
32003
- debug("ondata");
32004
- var ret = dest.write(chunk);
32005
- debug("dest.write", ret);
32006
- if (ret === false) {
32007
- if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) {
32008
- debug("false write response, pause", state.awaitDrain);
32009
- state.awaitDrain++;
32010
- }
32011
- src.pause();
32012
- }
32013
- }
32014
- function onerror(er2) {
32015
- debug("onerror", er2);
32016
- unpipe();
32017
- dest.removeListener("error", onerror);
32018
- if (EElistenerCount(dest, "error") === 0)
32019
- errorOrDestroy(dest, er2);
32020
- }
32021
- prependListener(dest, "error", onerror);
32022
- function onclose() {
32023
- dest.removeListener("finish", onfinish);
32024
- unpipe();
32025
- }
32026
- dest.once("close", onclose);
32027
- function onfinish() {
32028
- debug("onfinish");
32029
- dest.removeListener("close", onclose);
32030
- unpipe();
32031
- }
32032
- dest.once("finish", onfinish);
32033
- function unpipe() {
32034
- debug("unpipe");
32035
- src.unpipe(dest);
32036
- }
32037
- dest.emit("pipe", src);
32038
- if (!state.flowing) {
32039
- debug("pipe resume");
32040
- src.resume();
32041
- }
32042
- return dest;
32043
- };
32044
- function pipeOnDrain(src) {
32045
- return function pipeOnDrainFunctionResult() {
32046
- var state = src._readableState;
32047
- debug("pipeOnDrain", state.awaitDrain);
32048
- if (state.awaitDrain)
32049
- state.awaitDrain--;
32050
- if (state.awaitDrain === 0 && EElistenerCount(src, "data")) {
32051
- state.flowing = true;
32052
- flow(src);
32053
- }
32054
- };
32055
- }
32056
- Readable.prototype.unpipe = function(dest) {
32057
- var state = this._readableState;
32058
- var unpipeInfo = {
32059
- hasUnpiped: false
32060
- };
32061
- if (state.pipesCount === 0)
32062
- return this;
32063
- if (state.pipesCount === 1) {
32064
- if (dest && dest !== state.pipes)
32065
- return this;
32066
- if (!dest)
32067
- dest = state.pipes;
32068
- state.pipes = null;
32069
- state.pipesCount = 0;
32070
- state.flowing = false;
32071
- if (dest)
32072
- dest.emit("unpipe", this, unpipeInfo);
32073
- return this;
32074
- }
32075
- if (!dest) {
32076
- var dests = state.pipes;
32077
- var len = state.pipesCount;
32078
- state.pipes = null;
32079
- state.pipesCount = 0;
32080
- state.flowing = false;
32081
- for (var i2 = 0; i2 < len; i2++)
32082
- dests[i2].emit("unpipe", this, {
32083
- hasUnpiped: false
32084
- });
32085
- return this;
32086
- }
32087
- var index = indexOf(state.pipes, dest);
32088
- if (index === -1)
32089
- return this;
32090
- state.pipes.splice(index, 1);
32091
- state.pipesCount -= 1;
32092
- if (state.pipesCount === 1)
32093
- state.pipes = state.pipes[0];
32094
- dest.emit("unpipe", this, unpipeInfo);
32095
- return this;
32096
- };
32097
- Readable.prototype.on = function(ev, fn) {
32098
- var res = Stream.prototype.on.call(this, ev, fn);
32099
- var state = this._readableState;
32100
- if (ev === "data") {
32101
- state.readableListening = this.listenerCount("readable") > 0;
32102
- if (state.flowing !== false)
32103
- this.resume();
32104
- } else if (ev === "readable") {
32105
- if (!state.endEmitted && !state.readableListening) {
32106
- state.readableListening = state.needReadable = true;
32107
- state.flowing = false;
32108
- state.emittedReadable = false;
32109
- debug("on readable", state.length, state.reading);
32110
- if (state.length) {
32111
- emitReadable(this);
32112
- } else if (!state.reading) {
32113
- process.nextTick(nReadingNextTick, this);
32114
- }
32115
- }
32116
- }
32117
- return res;
32118
- };
32119
- Readable.prototype.addListener = Readable.prototype.on;
32120
- Readable.prototype.removeListener = function(ev, fn) {
32121
- var res = Stream.prototype.removeListener.call(this, ev, fn);
32122
- if (ev === "readable") {
32123
- process.nextTick(updateReadableListening, this);
32124
- }
32125
- return res;
32126
- };
32127
- Readable.prototype.removeAllListeners = function(ev) {
32128
- var res = Stream.prototype.removeAllListeners.apply(this, arguments);
32129
- if (ev === "readable" || ev === void 0) {
32130
- process.nextTick(updateReadableListening, this);
32131
- }
32132
- return res;
32133
- };
32134
- function updateReadableListening(self2) {
32135
- var state = self2._readableState;
32136
- state.readableListening = self2.listenerCount("readable") > 0;
32137
- if (state.resumeScheduled && !state.paused) {
32138
- state.flowing = true;
32139
- } else if (self2.listenerCount("data") > 0) {
32140
- self2.resume();
32141
- }
32142
- }
32143
- function nReadingNextTick(self2) {
32144
- debug("readable nexttick read 0");
32145
- self2.read(0);
32146
- }
32147
- Readable.prototype.resume = function() {
32148
- var state = this._readableState;
32149
- if (!state.flowing) {
32150
- debug("resume");
32151
- state.flowing = !state.readableListening;
32152
- resume(this, state);
32153
- }
32154
- state.paused = false;
32155
- return this;
32156
- };
32157
- function resume(stream, state) {
32158
- if (!state.resumeScheduled) {
32159
- state.resumeScheduled = true;
32160
- process.nextTick(resume_, stream, state);
32161
- }
32162
- }
32163
- function resume_(stream, state) {
32164
- debug("resume", state.reading);
32165
- if (!state.reading) {
32166
- stream.read(0);
32167
- }
32168
- state.resumeScheduled = false;
32169
- stream.emit("resume");
32170
- flow(stream);
32171
- if (state.flowing && !state.reading)
32172
- stream.read(0);
32173
- }
32174
- Readable.prototype.pause = function() {
32175
- debug("call pause flowing=%j", this._readableState.flowing);
32176
- if (this._readableState.flowing !== false) {
32177
- debug("pause");
32178
- this._readableState.flowing = false;
32179
- this.emit("pause");
32180
- }
32181
- this._readableState.paused = true;
32182
- return this;
32183
- };
32184
- function flow(stream) {
32185
- var state = stream._readableState;
32186
- debug("flow", state.flowing);
32187
- while (state.flowing && stream.read() !== null)
32188
- ;
32189
- }
32190
- Readable.prototype.wrap = function(stream) {
32191
- var _this = this;
32192
- var state = this._readableState;
32193
- var paused = false;
32194
- stream.on("end", function() {
32195
- debug("wrapped end");
32196
- if (state.decoder && !state.ended) {
32197
- var chunk = state.decoder.end();
32198
- if (chunk && chunk.length)
32199
- _this.push(chunk);
32200
- }
32201
- _this.push(null);
32202
- });
32203
- stream.on("data", function(chunk) {
32204
- debug("wrapped data");
32205
- if (state.decoder)
32206
- chunk = state.decoder.write(chunk);
32207
- if (state.objectMode && (chunk === null || chunk === void 0))
32208
- return;
32209
- else if (!state.objectMode && (!chunk || !chunk.length))
32210
- return;
32211
- var ret = _this.push(chunk);
32212
- if (!ret) {
32213
- paused = true;
32214
- stream.pause();
32215
- }
32216
- });
32217
- for (var i2 in stream) {
32218
- if (this[i2] === void 0 && typeof stream[i2] === "function") {
32219
- this[i2] = /* @__PURE__ */ function methodWrap(method) {
32220
- return function methodWrapReturnFunction() {
32221
- return stream[method].apply(stream, arguments);
32222
- };
32223
- }(i2);
32224
- }
32225
- }
32226
- for (var n = 0; n < kProxyEvents.length; n++) {
32227
- stream.on(kProxyEvents[n], this.emit.bind(this, kProxyEvents[n]));
32228
- }
32229
- this._read = function(n2) {
32230
- debug("wrapped _read", n2);
32231
- if (paused) {
32232
- paused = false;
32233
- stream.resume();
32234
- }
32235
- };
32236
- return this;
32237
- };
32238
- if (typeof Symbol === "function") {
32239
- Readable.prototype[Symbol.asyncIterator] = function() {
32240
- if (createReadableStreamAsyncIterator === void 0) {
32241
- createReadableStreamAsyncIterator = require_async_iterator2();
32242
- }
32243
- return createReadableStreamAsyncIterator(this);
32244
- };
32245
- }
32246
- Object.defineProperty(Readable.prototype, "readableHighWaterMark", {
32247
- // making it explicit this property is not enumerable
32248
- // because otherwise some prototype manipulation in
32249
- // userland will fail
32250
- enumerable: false,
32251
- get: function get() {
32252
- return this._readableState.highWaterMark;
32253
- }
32254
- });
32255
- Object.defineProperty(Readable.prototype, "readableBuffer", {
32256
- // making it explicit this property is not enumerable
32257
- // because otherwise some prototype manipulation in
32258
- // userland will fail
32259
- enumerable: false,
32260
- get: function get() {
32261
- return this._readableState && this._readableState.buffer;
32262
- }
32263
- });
32264
- Object.defineProperty(Readable.prototype, "readableFlowing", {
32265
- // making it explicit this property is not enumerable
32266
- // because otherwise some prototype manipulation in
32267
- // userland will fail
32268
- enumerable: false,
32269
- get: function get() {
32270
- return this._readableState.flowing;
32271
- },
32272
- set: function set(state) {
32273
- if (this._readableState) {
32274
- this._readableState.flowing = state;
32275
- }
32276
- }
32277
- });
32278
- Readable._fromList = fromList;
32279
- Object.defineProperty(Readable.prototype, "readableLength", {
32280
- // making it explicit this property is not enumerable
32281
- // because otherwise some prototype manipulation in
32282
- // userland will fail
32283
- enumerable: false,
32284
- get: function get() {
32285
- return this._readableState.length;
32286
- }
32287
- });
32288
- function fromList(n, state) {
32289
- if (state.length === 0)
32290
- return null;
32291
- var ret;
32292
- if (state.objectMode)
32293
- ret = state.buffer.shift();
32294
- else if (!n || n >= state.length) {
32295
- if (state.decoder)
32296
- ret = state.buffer.join("");
32297
- else if (state.buffer.length === 1)
32298
- ret = state.buffer.first();
32299
- else
32300
- ret = state.buffer.concat(state.length);
32301
- state.buffer.clear();
32302
- } else {
32303
- ret = state.buffer.consume(n, state.decoder);
32304
- }
32305
- return ret;
32306
- }
32307
- function endReadable(stream) {
32308
- var state = stream._readableState;
32309
- debug("endReadable", state.endEmitted);
32310
- if (!state.endEmitted) {
32311
- state.ended = true;
32312
- process.nextTick(endReadableNT, state, stream);
32313
- }
32314
- }
32315
- function endReadableNT(state, stream) {
32316
- debug("endReadableNT", state.endEmitted, state.length);
32317
- if (!state.endEmitted && state.length === 0) {
32318
- state.endEmitted = true;
32319
- stream.readable = false;
32320
- stream.emit("end");
32321
- if (state.autoDestroy) {
32322
- var wState = stream._writableState;
32323
- if (!wState || wState.autoDestroy && wState.finished) {
32324
- stream.destroy();
32325
- }
32326
- }
32327
- }
32328
- }
32329
- if (typeof Symbol === "function") {
32330
- Readable.from = function(iterable, opts) {
32331
- if (from === void 0) {
32332
- from = require_from2();
32333
- }
32334
- return from(Readable, iterable, opts);
32335
- };
32336
- }
32337
- function indexOf(xs2, x2) {
32338
- for (var i2 = 0, l3 = xs2.length; i2 < l3; i2++) {
32339
- if (xs2[i2] === x2)
32340
- return i2;
32341
- }
32342
- return -1;
32343
- }
32344
- }
32345
- });
32346
-
32347
- // ../../node_modules/winston/node_modules/readable-stream/lib/_stream_transform.js
30053
+ // ../../node_modules/readable-stream/lib/_stream_transform.js
32348
30054
  var require_stream_transform = __commonJS({
32349
- "../../node_modules/winston/node_modules/readable-stream/lib/_stream_transform.js"(exports2, module2) {
30055
+ "../../node_modules/readable-stream/lib/_stream_transform.js"(exports2, module2) {
32350
30056
  "use strict";
32351
30057
  module2.exports = Transform;
32352
- var _require$codes = require_errors3().codes;
30058
+ var _require$codes = require_errors2().codes;
32353
30059
  var ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED;
32354
30060
  var ERR_MULTIPLE_CALLBACK = _require$codes.ERR_MULTIPLE_CALLBACK;
32355
30061
  var ERR_TRANSFORM_ALREADY_TRANSFORMING = _require$codes.ERR_TRANSFORM_ALREADY_TRANSFORMING;
32356
30062
  var ERR_TRANSFORM_WITH_LENGTH_0 = _require$codes.ERR_TRANSFORM_WITH_LENGTH_0;
32357
- var Duplex = require_stream_duplex2();
30063
+ var Duplex = require_stream_duplex();
32358
30064
  require_inherits()(Transform, Duplex);
32359
30065
  function afterTransform(er2, data2) {
32360
30066
  var ts = this._transformState;
@@ -32368,10 +30074,10 @@ var require_stream_transform = __commonJS({
32368
30074
  if (data2 != null)
32369
30075
  this.push(data2);
32370
30076
  cb(er2);
32371
- var rs = this._readableState;
32372
- rs.reading = false;
32373
- if (rs.needReadable || rs.length < rs.highWaterMark) {
32374
- this._read(rs.highWaterMark);
30077
+ var rs2 = this._readableState;
30078
+ rs2.reading = false;
30079
+ if (rs2.needReadable || rs2.length < rs2.highWaterMark) {
30080
+ this._read(rs2.highWaterMark);
32375
30081
  }
32376
30082
  }
32377
30083
  function Transform(options) {
@@ -32419,9 +30125,9 @@ var require_stream_transform = __commonJS({
32419
30125
  ts.writechunk = chunk;
32420
30126
  ts.writeencoding = encoding;
32421
30127
  if (!ts.transforming) {
32422
- var rs = this._readableState;
32423
- if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark)
32424
- this._read(rs.highWaterMark);
30128
+ var rs2 = this._readableState;
30129
+ if (ts.needTransform || rs2.needReadable || rs2.length < rs2.highWaterMark)
30130
+ this._read(rs2.highWaterMark);
32425
30131
  }
32426
30132
  };
32427
30133
  Transform.prototype._read = function(n) {
@@ -32452,9 +30158,9 @@ var require_stream_transform = __commonJS({
32452
30158
  }
32453
30159
  });
32454
30160
 
32455
- // ../../node_modules/winston/node_modules/readable-stream/lib/_stream_passthrough.js
30161
+ // ../../node_modules/readable-stream/lib/_stream_passthrough.js
32456
30162
  var require_stream_passthrough = __commonJS({
32457
- "../../node_modules/winston/node_modules/readable-stream/lib/_stream_passthrough.js"(exports2, module2) {
30163
+ "../../node_modules/readable-stream/lib/_stream_passthrough.js"(exports2, module2) {
32458
30164
  "use strict";
32459
30165
  module2.exports = PassThrough;
32460
30166
  var Transform = require_stream_transform();
@@ -32470,9 +30176,9 @@ var require_stream_passthrough = __commonJS({
32470
30176
  }
32471
30177
  });
32472
30178
 
32473
- // ../../node_modules/winston/node_modules/readable-stream/lib/internal/streams/pipeline.js
30179
+ // ../../node_modules/readable-stream/lib/internal/streams/pipeline.js
32474
30180
  var require_pipeline = __commonJS({
32475
- "../../node_modules/winston/node_modules/readable-stream/lib/internal/streams/pipeline.js"(exports2, module2) {
30181
+ "../../node_modules/readable-stream/lib/internal/streams/pipeline.js"(exports2, module2) {
32476
30182
  "use strict";
32477
30183
  var eos;
32478
30184
  function once(callback) {
@@ -32484,7 +30190,7 @@ var require_pipeline = __commonJS({
32484
30190
  callback.apply(void 0, arguments);
32485
30191
  };
32486
30192
  }
32487
- var _require$codes = require_errors3().codes;
30193
+ var _require$codes = require_errors2().codes;
32488
30194
  var ERR_MISSING_ARGS = _require$codes.ERR_MISSING_ARGS;
32489
30195
  var ERR_STREAM_DESTROYED = _require$codes.ERR_STREAM_DESTROYED;
32490
30196
  function noop(err) {
@@ -32501,7 +30207,7 @@ var require_pipeline = __commonJS({
32501
30207
  closed = true;
32502
30208
  });
32503
30209
  if (eos === void 0)
32504
- eos = require_end_of_stream2();
30210
+ eos = require_end_of_stream();
32505
30211
  eos(stream, {
32506
30212
  readable: reading,
32507
30213
  writable: writing
@@ -32528,8 +30234,8 @@ var require_pipeline = __commonJS({
32528
30234
  function call(fn) {
32529
30235
  fn();
32530
30236
  }
32531
- function pipe(from, to2) {
32532
- return from.pipe(to2);
30237
+ function pipe(from, to) {
30238
+ return from.pipe(to);
32533
30239
  }
32534
30240
  function popCallback(streams) {
32535
30241
  if (!streams.length)
@@ -32569,9 +30275,9 @@ var require_pipeline = __commonJS({
32569
30275
  }
32570
30276
  });
32571
30277
 
32572
- // ../../node_modules/winston/node_modules/readable-stream/readable.js
30278
+ // ../../node_modules/readable-stream/readable.js
32573
30279
  var require_readable = __commonJS({
32574
- "../../node_modules/winston/node_modules/readable-stream/readable.js"(exports2, module2) {
30280
+ "../../node_modules/readable-stream/readable.js"(exports2, module2) {
32575
30281
  "use strict";
32576
30282
  var Stream = require("stream");
32577
30283
  if (process.env.READABLE_STREAM === "disable" && Stream) {
@@ -32579,14 +30285,14 @@ var require_readable = __commonJS({
32579
30285
  Object.assign(module2.exports, Stream);
32580
30286
  module2.exports.Stream = Stream;
32581
30287
  } else {
32582
- exports2 = module2.exports = require_stream_readable2();
30288
+ exports2 = module2.exports = require_stream_readable();
32583
30289
  exports2.Stream = Stream || exports2;
32584
30290
  exports2.Readable = exports2;
32585
- exports2.Writable = require_stream_writable2();
32586
- exports2.Duplex = require_stream_duplex2();
30291
+ exports2.Writable = require_stream_writable();
30292
+ exports2.Duplex = require_stream_duplex();
32587
30293
  exports2.Transform = require_stream_transform();
32588
30294
  exports2.PassThrough = require_stream_passthrough();
32589
- exports2.finished = require_end_of_stream2();
30295
+ exports2.finished = require_end_of_stream();
32590
30296
  exports2.pipeline = require_pipeline();
32591
30297
  }
32592
30298
  }
@@ -32920,25 +30626,25 @@ var require_color_string = __commonJS({
32920
30626
  }
32921
30627
  }
32922
30628
  var name;
32923
- var cs2 = module2.exports = {
30629
+ var cs = module2.exports = {
32924
30630
  to: {},
32925
30631
  get: {}
32926
30632
  };
32927
- cs2.get = function(string) {
30633
+ cs.get = function(string) {
32928
30634
  var prefix = string.substring(0, 3).toLowerCase();
32929
30635
  var val;
32930
30636
  var model;
32931
30637
  switch (prefix) {
32932
30638
  case "hsl":
32933
- val = cs2.get.hsl(string);
30639
+ val = cs.get.hsl(string);
32934
30640
  model = "hsl";
32935
30641
  break;
32936
30642
  case "hwb":
32937
- val = cs2.get.hwb(string);
30643
+ val = cs.get.hwb(string);
32938
30644
  model = "hwb";
32939
30645
  break;
32940
30646
  default:
32941
- val = cs2.get.rgb(string);
30647
+ val = cs.get.rgb(string);
32942
30648
  model = "rgb";
32943
30649
  break;
32944
30650
  }
@@ -32947,7 +30653,7 @@ var require_color_string = __commonJS({
32947
30653
  }
32948
30654
  return { model, value: val };
32949
30655
  };
32950
- cs2.get.rgb = function(string) {
30656
+ cs.get.rgb = function(string) {
32951
30657
  if (!string) {
32952
30658
  return null;
32953
30659
  }
@@ -33020,7 +30726,7 @@ var require_color_string = __commonJS({
33020
30726
  rgb[3] = clamp(rgb[3], 0, 1);
33021
30727
  return rgb;
33022
30728
  };
33023
- cs2.get.hsl = function(string) {
30729
+ cs.get.hsl = function(string) {
33024
30730
  if (!string) {
33025
30731
  return null;
33026
30732
  }
@@ -33036,7 +30742,7 @@ var require_color_string = __commonJS({
33036
30742
  }
33037
30743
  return null;
33038
30744
  };
33039
- cs2.get.hwb = function(string) {
30745
+ cs.get.hwb = function(string) {
33040
30746
  if (!string) {
33041
30747
  return null;
33042
30748
  }
@@ -33052,26 +30758,26 @@ var require_color_string = __commonJS({
33052
30758
  }
33053
30759
  return null;
33054
30760
  };
33055
- cs2.to.hex = function() {
30761
+ cs.to.hex = function() {
33056
30762
  var rgba = swizzle(arguments);
33057
30763
  return "#" + hexDouble(rgba[0]) + hexDouble(rgba[1]) + hexDouble(rgba[2]) + (rgba[3] < 1 ? hexDouble(Math.round(rgba[3] * 255)) : "");
33058
30764
  };
33059
- cs2.to.rgb = function() {
30765
+ cs.to.rgb = function() {
33060
30766
  var rgba = swizzle(arguments);
33061
30767
  return rgba.length < 4 || rgba[3] === 1 ? "rgb(" + Math.round(rgba[0]) + ", " + Math.round(rgba[1]) + ", " + Math.round(rgba[2]) + ")" : "rgba(" + Math.round(rgba[0]) + ", " + Math.round(rgba[1]) + ", " + Math.round(rgba[2]) + ", " + rgba[3] + ")";
33062
30768
  };
33063
- cs2.to.rgb.percent = function() {
30769
+ cs.to.rgb.percent = function() {
33064
30770
  var rgba = swizzle(arguments);
33065
30771
  var r4 = Math.round(rgba[0] / 255 * 100);
33066
30772
  var g2 = Math.round(rgba[1] / 255 * 100);
33067
30773
  var b2 = Math.round(rgba[2] / 255 * 100);
33068
30774
  return rgba.length < 4 || rgba[3] === 1 ? "rgb(" + r4 + "%, " + g2 + "%, " + b2 + "%)" : "rgba(" + r4 + "%, " + g2 + "%, " + b2 + "%, " + rgba[3] + ")";
33069
30775
  };
33070
- cs2.to.hsl = function() {
30776
+ cs.to.hsl = function() {
33071
30777
  var hsla = swizzle(arguments);
33072
30778
  return hsla.length < 4 || hsla[3] === 1 ? "hsl(" + hsla[0] + ", " + hsla[1] + "%, " + hsla[2] + "%)" : "hsla(" + hsla[0] + ", " + hsla[1] + "%, " + hsla[2] + "%, " + hsla[3] + ")";
33073
30779
  };
33074
- cs2.to.hwb = function() {
30780
+ cs.to.hwb = function() {
33075
30781
  var hwba = swizzle(arguments);
33076
30782
  var a = "";
33077
30783
  if (hwba.length >= 4 && hwba[3] !== 1) {
@@ -33079,7 +30785,7 @@ var require_color_string = __commonJS({
33079
30785
  }
33080
30786
  return "hwb(" + hwba[0] + ", " + hwba[1] + "%, " + hwba[2] + "%" + a + ")";
33081
30787
  };
33082
- cs2.to.keyword = function(rgb) {
30788
+ cs.to.keyword = function(rgb) {
33083
30789
  return reverseNames[rgb.slice(0, 3)];
33084
30790
  };
33085
30791
  function clamp(num, min, max) {
@@ -34000,9 +31706,9 @@ var require_route = __commonJS({
34000
31706
  }
34001
31707
  return graph;
34002
31708
  }
34003
- function link(from, to2) {
31709
+ function link(from, to) {
34004
31710
  return function(args) {
34005
- return to2(from(args));
31711
+ return to(from(args));
34006
31712
  };
34007
31713
  }
34008
31714
  function wrapConversion(toModel, graph) {
@@ -35602,7 +33308,7 @@ var require_is_stream = __commonJS({
35602
33308
  });
35603
33309
 
35604
33310
  // ../../node_modules/winston/lib/winston/transports/stream.js
35605
- var require_stream4 = __commonJS({
33311
+ var require_stream3 = __commonJS({
35606
33312
  "../../node_modules/winston/lib/winston/transports/stream.js"(exports2, module2) {
35607
33313
  "use strict";
35608
33314
  var isStream = require_is_stream();
@@ -35679,7 +33385,7 @@ var require_transports = __commonJS({
35679
33385
  configurable: true,
35680
33386
  enumerable: true,
35681
33387
  get() {
35682
- return require_stream4();
33388
+ return require_stream3();
35683
33389
  }
35684
33390
  });
35685
33391
  }
@@ -39421,17 +37127,17 @@ var qe = "created";
39421
37127
  var Ft = "not-modified";
39422
37128
  var _t = "not-found";
39423
37129
  var je = "accepted";
39424
- var _r = { resourceType: "OperationOutcome", id: _t, issue: [{ severity: "error", code: "not-found", details: { text: "Not found" } }] };
37130
+ var Lr = { resourceType: "OperationOutcome", id: _t, issue: [{ severity: "error", code: "not-found", details: { text: "Not found" } }] };
39425
37131
  function R(r4, e) {
39426
37132
  return { resourceType: "OperationOutcome", issue: [{ severity: "error", code: "invalid", details: { text: r4 }, expression: e ? [e] : void 0 }] };
39427
37133
  }
39428
37134
  function m(r4) {
39429
37135
  return { resourceType: "OperationOutcome", issue: [{ severity: "error", code: "structure", details: { text: r4 } }] };
39430
37136
  }
39431
- function Lr(r4) {
37137
+ function Ur(r4) {
39432
37138
  return { resourceType: "OperationOutcome", issue: [{ severity: "error", code: "exception", details: { text: "Internal server error" }, diagnostics: r4.toString() }] };
39433
37139
  }
39434
- function le(r4) {
37140
+ function pe(r4) {
39435
37141
  return typeof r4 == "object" && r4 !== null && r4.resourceType === "OperationOutcome";
39436
37142
  }
39437
37143
  function Lt(r4) {
@@ -39439,43 +37145,43 @@ function Lt(r4) {
39439
37145
  }
39440
37146
  var d = class extends Error {
39441
37147
  constructor(e, t) {
39442
- super(Ur(e)), this.outcome = e, this.cause = t;
37148
+ super(Br(e)), this.outcome = e, this.cause = t;
39443
37149
  }
39444
37150
  };
39445
37151
  function $e(r4) {
39446
- return r4 instanceof d ? r4.outcome : le(r4) ? r4 : R(yi(r4));
37152
+ return r4 instanceof d ? r4.outcome : pe(r4) ? r4 : R(vi(r4));
39447
37153
  }
39448
- function yi(r4) {
39449
- return r4 ? typeof r4 == "string" ? r4 : r4 instanceof Error ? r4.message : le(r4) ? Ur(r4) : typeof r4 == "object" && "code" in r4 && typeof r4.code == "string" ? r4.code : JSON.stringify(r4) : "Unknown error";
37154
+ function vi(r4) {
37155
+ return r4 ? typeof r4 == "string" ? r4 : r4 instanceof Error ? r4.message : pe(r4) ? Br(r4) : typeof r4 == "object" && "code" in r4 && typeof r4.code == "string" ? r4.code : JSON.stringify(r4) : "Unknown error";
39450
37156
  }
39451
- function Ur(r4) {
39452
- let e = r4.issue?.map(gi) ?? [];
37157
+ function Br(r4) {
37158
+ let e = r4.issue?.map(Ti) ?? [];
39453
37159
  return e.length > 0 ? e.join("; ") : "Unknown error";
39454
37160
  }
39455
- function gi(r4) {
37161
+ function Ti(r4) {
39456
37162
  let e;
39457
37163
  return r4.details?.text ? r4.diagnostics ? e = `${r4.details.text} (${r4.diagnostics})` : e = r4.details.text : r4.diagnostics ? e = r4.diagnostics : e = "Unknown error", r4.expression?.length && (e += ` (${r4.expression.join(", ")})`), e;
39458
37164
  }
39459
- function vi(r4, e) {
37165
+ function Ei(r4, e) {
39460
37166
  let t = e.max && e.max === Number.MAX_SAFE_INTEGER ? Number.POSITIVE_INFINITY : e.max;
39461
37167
  return { path: r4, description: "", type: e.type ?? [], min: e.min ?? 0, max: t ?? 1, isArray: !!t && t > 1, constraints: [] };
39462
37168
  }
39463
- function jr(r4) {
37169
+ function $r(r4) {
39464
37170
  let e = /* @__PURE__ */ Object.create(null);
39465
37171
  for (let [t, n] of Object.entries(r4))
39466
- e[t] = { name: t, elements: Object.fromEntries(Object.entries(n.elements).map(([i2, o]) => [i2, vi(i2, o)])), constraints: [], innerTypes: [] };
37172
+ e[t] = { name: t, elements: Object.fromEntries(Object.entries(n.elements).map(([i2, o]) => [i2, Ei(i2, o)])), constraints: [], innerTypes: [] };
39467
37173
  return e;
39468
37174
  }
39469
- var $r = { Element: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] } } }, BackboneElement: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] } } }, Address: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, use: { type: [{ code: "code" }] }, type: { type: [{ code: "code" }] }, text: { type: [{ code: "string" }] }, line: { max: 9007199254740991, type: [{ code: "string" }] }, city: { type: [{ code: "string" }] }, district: { type: [{ code: "string" }] }, state: { type: [{ code: "string" }] }, postalCode: { type: [{ code: "string" }] }, country: { type: [{ code: "string" }] }, period: { type: [{ code: "Period" }] } } }, Age: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, comparator: { type: [{ code: "code" }] }, unit: { type: [{ code: "string" }] }, system: { type: [{ code: "uri" }] }, code: { type: [{ code: "code" }] } } }, Annotation: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, "author[x]": { type: [{ code: "Reference", targetProfile: ["http://hl7.org/fhir/StructureDefinition/Practitioner", "http://hl7.org/fhir/StructureDefinition/Patient", "http://hl7.org/fhir/StructureDefinition/RelatedPerson", "http://hl7.org/fhir/StructureDefinition/Organization"] }, { code: "string" }] }, time: { type: [{ code: "dateTime" }] }, text: { min: 1, type: [{ code: "markdown" }] } } }, Attachment: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, contentType: { type: [{ code: "code" }] }, language: { type: [{ code: "code" }] }, data: { type: [{ code: "base64Binary" }] }, url: { type: [{ code: "url" }] }, size: { type: [{ code: "unsignedInt" }] }, hash: { type: [{ code: "base64Binary" }] }, title: { type: [{ code: "string" }] }, creation: { type: [{ code: "dateTime" }] } } }, CodeableConcept: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, coding: { max: 9007199254740991, type: [{ code: "Coding" }] }, text: { type: [{ code: "string" }] } } }, Coding: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, system: { type: [{ code: "uri" }] }, version: { type: [{ code: "string" }] }, code: { type: [{ code: "code" }] }, display: { type: [{ code: "string" }] }, userSelected: { type: [{ code: "boolean" }] } } }, ContactDetail: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, name: { type: [{ code: "string" }] }, telecom: { max: 9007199254740991, type: [{ code: "ContactPoint" }] } } }, ContactPoint: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, system: { type: [{ code: "code" }] }, value: { type: [{ code: "string" }] }, use: { type: [{ code: "code" }] }, rank: { type: [{ code: "positiveInt" }] }, period: { type: [{ code: "Period" }] } } }, Contributor: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, type: { min: 1, type: [{ code: "code" }] }, name: { min: 1, type: [{ code: "string" }] }, contact: { max: 9007199254740991, type: [{ code: "ContactDetail" }] } } }, Count: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, comparator: { type: [{ code: "code" }] }, unit: { type: [{ code: "string" }] }, system: { type: [{ code: "uri" }] }, code: { type: [{ code: "code" }] } } }, DataRequirement: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, type: { min: 1, type: [{ code: "code" }] }, profile: { max: 9007199254740991, type: [{ code: "canonical", targetProfile: ["http://hl7.org/fhir/StructureDefinition/StructureDefinition"] }] }, "subject[x]": { type: [{ code: "CodeableConcept" }, { code: "Reference", targetProfile: ["http://hl7.org/fhir/StructureDefinition/Group"] }] }, mustSupport: { max: 9007199254740991, type: [{ code: "string" }] }, codeFilter: { max: 9007199254740991, type: [{ code: "DataRequirementCodeFilter" }] }, dateFilter: { max: 9007199254740991, type: [{ code: "DataRequirementDateFilter" }] }, limit: { type: [{ code: "positiveInt" }] }, sort: { max: 9007199254740991, type: [{ code: "DataRequirementSort" }] } } }, Distance: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, comparator: { type: [{ code: "code" }] }, unit: { type: [{ code: "string" }] }, system: { type: [{ code: "uri" }] }, code: { type: [{ code: "code" }] } } }, Dosage: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, sequence: { type: [{ code: "integer" }] }, text: { type: [{ code: "string" }] }, additionalInstruction: { max: 9007199254740991, type: [{ code: "CodeableConcept" }] }, patientInstruction: { type: [{ code: "string" }] }, timing: { type: [{ code: "Timing" }] }, "asNeeded[x]": { type: [{ code: "boolean" }, { code: "CodeableConcept" }] }, site: { type: [{ code: "CodeableConcept" }] }, route: { type: [{ code: "CodeableConcept" }] }, method: { type: [{ code: "CodeableConcept" }] }, doseAndRate: { max: 9007199254740991, type: [{ code: "DosageDoseAndRate" }] }, maxDosePerPeriod: { type: [{ code: "Ratio" }] }, maxDosePerAdministration: { type: [{ code: "Quantity", profile: ["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"] }] }, maxDosePerLifetime: { type: [{ code: "Quantity", profile: ["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"] }] } } }, Duration: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, comparator: { type: [{ code: "code" }] }, unit: { type: [{ code: "string" }] }, system: { type: [{ code: "uri" }] }, code: { type: [{ code: "code" }] } } }, ElementDefinition: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, path: { min: 1, type: [{ code: "string" }] }, representation: { max: 9007199254740991, type: [{ code: "code" }] }, sliceName: { type: [{ code: "string" }] }, sliceIsConstraining: { type: [{ code: "boolean" }] }, label: { type: [{ code: "string" }] }, code: { max: 9007199254740991, type: [{ code: "Coding" }] }, slicing: { type: [{ code: "ElementDefinitionSlicing" }] }, short: { type: [{ code: "string" }] }, definition: { type: [{ code: "markdown" }] }, comment: { type: [{ code: "markdown" }] }, requirements: { type: [{ code: "markdown" }] }, alias: { max: 9007199254740991, type: [{ code: "string" }] }, min: { type: [{ code: "unsignedInt" }] }, max: { type: [{ code: "string" }] }, base: { type: [{ code: "ElementDefinitionBase" }] }, contentReference: { type: [{ code: "uri" }] }, type: { max: 9007199254740991, type: [{ code: "ElementDefinitionType" }] }, "defaultValue[x]": { type: [{ code: "base64Binary" }, { code: "boolean" }, { code: "canonical" }, { code: "code" }, { code: "date" }, { code: "dateTime" }, { code: "decimal" }, { code: "id" }, { code: "instant" }, { code: "integer" }, { code: "markdown" }, { code: "oid" }, { code: "positiveInt" }, { code: "string" }, { code: "time" }, { code: "unsignedInt" }, { code: "uri" }, { code: "url" }, { code: "uuid" }, { code: "Address" }, { code: "Age" }, { code: "Annotation" }, { code: "Attachment" }, { code: "CodeableConcept" }, { code: "Coding" }, { code: "ContactPoint" }, { code: "Count" }, { code: "Distance" }, { code: "Duration" }, { code: "HumanName" }, { code: "Identifier" }, { code: "Money" }, { code: "Period" }, { code: "Quantity" }, { code: "Range" }, { code: "Ratio" }, { code: "Reference" }, { code: "SampledData" }, { code: "Signature" }, { code: "Timing" }, { code: "ContactDetail" }, { code: "Contributor" }, { code: "DataRequirement" }, { code: "Expression" }, { code: "ParameterDefinition" }, { code: "RelatedArtifact" }, { code: "TriggerDefinition" }, { code: "UsageContext" }, { code: "Dosage" }, { code: "Meta" }] }, meaningWhenMissing: { type: [{ code: "markdown" }] }, orderMeaning: { type: [{ code: "string" }] }, "fixed[x]": { type: [{ code: "base64Binary" }, { code: "boolean" }, { code: "canonical" }, { code: "code" }, { code: "date" }, { code: "dateTime" }, { code: "decimal" }, { code: "id" }, { code: "instant" }, { code: "integer" }, { code: "markdown" }, { code: "oid" }, { code: "positiveInt" }, { code: "string" }, { code: "time" }, { code: "unsignedInt" }, { code: "uri" }, { code: "url" }, { code: "uuid" }, { code: "Address" }, { code: "Age" }, { code: "Annotation" }, { code: "Attachment" }, { code: "CodeableConcept" }, { code: "Coding" }, { code: "ContactPoint" }, { code: "Count" }, { code: "Distance" }, { code: "Duration" }, { code: "HumanName" }, { code: "Identifier" }, { code: "Money" }, { code: "Period" }, { code: "Quantity" }, { code: "Range" }, { code: "Ratio" }, { code: "Reference" }, { code: "SampledData" }, { code: "Signature" }, { code: "Timing" }, { code: "ContactDetail" }, { code: "Contributor" }, { code: "DataRequirement" }, { code: "Expression" }, { code: "ParameterDefinition" }, { code: "RelatedArtifact" }, { code: "TriggerDefinition" }, { code: "UsageContext" }, { code: "Dosage" }, { code: "Meta" }] }, "pattern[x]": { type: [{ code: "base64Binary" }, { code: "boolean" }, { code: "canonical" }, { code: "code" }, { code: "date" }, { code: "dateTime" }, { code: "decimal" }, { code: "id" }, { code: "instant" }, { code: "integer" }, { code: "markdown" }, { code: "oid" }, { code: "positiveInt" }, { code: "string" }, { code: "time" }, { code: "unsignedInt" }, { code: "uri" }, { code: "url" }, { code: "uuid" }, { code: "Address" }, { code: "Age" }, { code: "Annotation" }, { code: "Attachment" }, { code: "CodeableConcept" }, { code: "Coding" }, { code: "ContactPoint" }, { code: "Count" }, { code: "Distance" }, { code: "Duration" }, { code: "HumanName" }, { code: "Identifier" }, { code: "Money" }, { code: "Period" }, { code: "Quantity" }, { code: "Range" }, { code: "Ratio" }, { code: "Reference" }, { code: "SampledData" }, { code: "Signature" }, { code: "Timing" }, { code: "ContactDetail" }, { code: "Contributor" }, { code: "DataRequirement" }, { code: "Expression" }, { code: "ParameterDefinition" }, { code: "RelatedArtifact" }, { code: "TriggerDefinition" }, { code: "UsageContext" }, { code: "Dosage" }, { code: "Meta" }] }, example: { max: 9007199254740991, type: [{ code: "ElementDefinitionExample" }] }, "minValue[x]": { type: [{ code: "date" }, { code: "dateTime" }, { code: "instant" }, { code: "time" }, { code: "decimal" }, { code: "integer" }, { code: "positiveInt" }, { code: "unsignedInt" }, { code: "Quantity" }] }, "maxValue[x]": { type: [{ code: "date" }, { code: "dateTime" }, { code: "instant" }, { code: "time" }, { code: "decimal" }, { code: "integer" }, { code: "positiveInt" }, { code: "unsignedInt" }, { code: "Quantity" }] }, maxLength: { type: [{ code: "integer" }] }, condition: { max: 9007199254740991, type: [{ code: "id" }] }, constraint: { max: 9007199254740991, type: [{ code: "ElementDefinitionConstraint" }] }, mustSupport: { type: [{ code: "boolean" }] }, isModifier: { type: [{ code: "boolean" }] }, isModifierReason: { type: [{ code: "string" }] }, isSummary: { type: [{ code: "boolean" }] }, binding: { type: [{ code: "ElementDefinitionBinding" }] }, mapping: { max: 9007199254740991, type: [{ code: "ElementDefinitionMapping" }] } } }, Expression: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, description: { type: [{ code: "string" }] }, name: { type: [{ code: "id" }] }, language: { min: 1, type: [{ code: "code" }] }, expression: { type: [{ code: "string" }] }, reference: { type: [{ code: "uri" }] } } }, Extension: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, url: { min: 1, type: [{ code: "uri" }] }, "value[x]": { type: [{ code: "base64Binary" }, { code: "boolean" }, { code: "canonical" }, { code: "code" }, { code: "date" }, { code: "dateTime" }, { code: "decimal" }, { code: "id" }, { code: "instant" }, { code: "integer" }, { code: "markdown" }, { code: "oid" }, { code: "positiveInt" }, { code: "string" }, { code: "time" }, { code: "unsignedInt" }, { code: "uri" }, { code: "url" }, { code: "uuid" }, { code: "Address" }, { code: "Age" }, { code: "Annotation" }, { code: "Attachment" }, { code: "CodeableConcept" }, { code: "Coding" }, { code: "ContactPoint" }, { code: "Count" }, { code: "Distance" }, { code: "Duration" }, { code: "HumanName" }, { code: "Identifier" }, { code: "Money" }, { code: "Period" }, { code: "Quantity" }, { code: "Range" }, { code: "Ratio" }, { code: "Reference" }, { code: "SampledData" }, { code: "Signature" }, { code: "Timing" }, { code: "ContactDetail" }, { code: "Contributor" }, { code: "DataRequirement" }, { code: "Expression" }, { code: "ParameterDefinition" }, { code: "RelatedArtifact" }, { code: "TriggerDefinition" }, { code: "UsageContext" }, { code: "Dosage" }, { code: "Meta" }] } } }, HumanName: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, use: { type: [{ code: "code" }] }, text: { type: [{ code: "string" }] }, family: { type: [{ code: "string" }] }, given: { max: 9007199254740991, type: [{ code: "string" }] }, prefix: { max: 9007199254740991, type: [{ code: "string" }] }, suffix: { max: 9007199254740991, type: [{ code: "string" }] }, period: { type: [{ code: "Period" }] } } }, Identifier: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, use: { type: [{ code: "code" }] }, type: { type: [{ code: "CodeableConcept" }] }, system: { type: [{ code: "uri" }] }, value: { type: [{ code: "string" }] }, period: { type: [{ code: "Period" }] }, assigner: { type: [{ code: "Reference", targetProfile: ["http://hl7.org/fhir/StructureDefinition/Organization"] }] } } }, MarketingStatus: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, country: { min: 1, type: [{ code: "CodeableConcept" }] }, jurisdiction: { type: [{ code: "CodeableConcept" }] }, status: { min: 1, type: [{ code: "CodeableConcept" }] }, dateRange: { min: 1, type: [{ code: "Period" }] }, restoreDate: { type: [{ code: "dateTime" }] } } }, Meta: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, versionId: { type: [{ code: "id" }] }, lastUpdated: { type: [{ code: "instant" }] }, source: { type: [{ code: "uri" }] }, profile: { max: 9007199254740991, type: [{ code: "canonical", targetProfile: ["http://hl7.org/fhir/StructureDefinition/StructureDefinition"] }] }, security: { max: 9007199254740991, type: [{ code: "Coding" }] }, tag: { max: 9007199254740991, type: [{ code: "Coding" }] }, project: { type: [{ code: "uri" }] }, author: { type: [{ code: "Reference" }] }, account: { type: [{ code: "Reference" }] }, compartment: { max: 9007199254740991, type: [{ code: "Reference" }] } } }, Money: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, currency: { type: [{ code: "code" }] } } }, Narrative: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, status: { min: 1, type: [{ code: "code" }] }, div: { min: 1, type: [{ code: "xhtml" }] } } }, ParameterDefinition: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, name: { type: [{ code: "code" }] }, use: { min: 1, type: [{ code: "code" }] }, min: { type: [{ code: "integer" }] }, max: { type: [{ code: "string" }] }, documentation: { type: [{ code: "string" }] }, type: { min: 1, type: [{ code: "code" }] }, profile: { type: [{ code: "canonical", targetProfile: ["http://hl7.org/fhir/StructureDefinition/StructureDefinition"] }] } } }, Period: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, start: { type: [{ code: "dateTime" }] }, end: { type: [{ code: "dateTime" }] } } }, Population: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, "age[x]": { type: [{ code: "Range" }, { code: "CodeableConcept" }] }, gender: { type: [{ code: "CodeableConcept" }] }, race: { type: [{ code: "CodeableConcept" }] }, physiologicalCondition: { type: [{ code: "CodeableConcept" }] } } }, ProdCharacteristic: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, height: { type: [{ code: "Quantity" }] }, width: { type: [{ code: "Quantity" }] }, depth: { type: [{ code: "Quantity" }] }, weight: { type: [{ code: "Quantity" }] }, nominalVolume: { type: [{ code: "Quantity" }] }, externalDiameter: { type: [{ code: "Quantity" }] }, shape: { type: [{ code: "string" }] }, color: { max: 9007199254740991, type: [{ code: "string" }] }, imprint: { max: 9007199254740991, type: [{ code: "string" }] }, image: { max: 9007199254740991, type: [{ code: "Attachment" }] }, scoring: { type: [{ code: "CodeableConcept" }] } } }, ProductShelfLife: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, identifier: { type: [{ code: "Identifier" }] }, type: { min: 1, type: [{ code: "CodeableConcept" }] }, period: { min: 1, type: [{ code: "Quantity" }] }, specialPrecautionsForStorage: { max: 9007199254740991, type: [{ code: "CodeableConcept" }] } } }, Quantity: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, comparator: { type: [{ code: "code" }] }, unit: { type: [{ code: "string" }] }, system: { type: [{ code: "uri" }] }, code: { type: [{ code: "code" }] } } }, Range: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, low: { type: [{ code: "Quantity", profile: ["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"] }] }, high: { type: [{ code: "Quantity", profile: ["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"] }] } } }, Ratio: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, numerator: { type: [{ code: "Quantity" }] }, denominator: { type: [{ code: "Quantity" }] } } }, Reference: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, reference: { type: [{ code: "string" }] }, type: { type: [{ code: "uri" }] }, identifier: { type: [{ code: "Identifier" }] }, display: { type: [{ code: "string" }] } } }, RelatedArtifact: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, type: { min: 1, type: [{ code: "code" }] }, label: { type: [{ code: "string" }] }, display: { type: [{ code: "string" }] }, citation: { type: [{ code: "markdown" }] }, url: { type: [{ code: "url" }] }, document: { type: [{ code: "Attachment" }] }, resource: { type: [{ code: "canonical", targetProfile: ["http://hl7.org/fhir/StructureDefinition/Resource"] }] } } }, SampledData: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, origin: { min: 1, type: [{ code: "Quantity", profile: ["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"] }] }, period: { min: 1, type: [{ code: "decimal" }] }, factor: { type: [{ code: "decimal" }] }, lowerLimit: { type: [{ code: "decimal" }] }, upperLimit: { type: [{ code: "decimal" }] }, dimensions: { min: 1, type: [{ code: "positiveInt" }] }, data: { type: [{ code: "string" }] } } }, Signature: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, type: { min: 1, max: 9007199254740991, type: [{ code: "Coding" }] }, when: { min: 1, type: [{ code: "instant" }] }, who: { min: 1, type: [{ code: "Reference", targetProfile: ["http://hl7.org/fhir/StructureDefinition/Practitioner", "http://hl7.org/fhir/StructureDefinition/PractitionerRole", "http://hl7.org/fhir/StructureDefinition/RelatedPerson", "http://hl7.org/fhir/StructureDefinition/Patient", "http://hl7.org/fhir/StructureDefinition/Device", "http://hl7.org/fhir/StructureDefinition/Organization"] }] }, onBehalfOf: { type: [{ code: "Reference", targetProfile: ["http://hl7.org/fhir/StructureDefinition/Practitioner", "http://hl7.org/fhir/StructureDefinition/PractitionerRole", "http://hl7.org/fhir/StructureDefinition/RelatedPerson", "http://hl7.org/fhir/StructureDefinition/Patient", "http://hl7.org/fhir/StructureDefinition/Device", "http://hl7.org/fhir/StructureDefinition/Organization"] }] }, targetFormat: { type: [{ code: "code" }] }, sigFormat: { type: [{ code: "code" }] }, data: { type: [{ code: "base64Binary" }] } } }, SubstanceAmount: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, "amount[x]": { type: [{ code: "Quantity" }, { code: "Range" }, { code: "string" }] }, amountType: { type: [{ code: "CodeableConcept" }] }, amountText: { type: [{ code: "string" }] }, referenceRange: { type: [{ code: "SubstanceAmountReferenceRange" }] } } }, Timing: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, event: { max: 9007199254740991, type: [{ code: "dateTime" }] }, repeat: { type: [{ code: "TimingRepeat" }] }, code: { type: [{ code: "CodeableConcept" }] } } }, TriggerDefinition: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, type: { min: 1, type: [{ code: "code" }] }, name: { type: [{ code: "string" }] }, "timing[x]": { type: [{ code: "Timing" }, { code: "Reference", targetProfile: ["http://hl7.org/fhir/StructureDefinition/Schedule"] }, { code: "date" }, { code: "dateTime" }] }, data: { max: 9007199254740991, type: [{ code: "DataRequirement" }] }, condition: { type: [{ code: "Expression" }] } } }, UsageContext: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, code: { min: 1, type: [{ code: "Coding" }] }, "value[x]": { min: 1, type: [{ code: "CodeableConcept" }, { code: "Quantity" }, { code: "Range" }, { code: "Reference", targetProfile: ["http://hl7.org/fhir/StructureDefinition/PlanDefinition", "http://hl7.org/fhir/StructureDefinition/ResearchStudy", "http://hl7.org/fhir/StructureDefinition/InsurancePlan", "http://hl7.org/fhir/StructureDefinition/HealthcareService", "http://hl7.org/fhir/StructureDefinition/Group", "http://hl7.org/fhir/StructureDefinition/Location", "http://hl7.org/fhir/StructureDefinition/Organization"] }] } } }, MoneyQuantity: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, comparator: { type: [{ code: "code" }] }, unit: { type: [{ code: "string" }] }, system: { type: [{ code: "uri" }] }, code: { type: [{ code: "code" }] } } }, SimpleQuantity: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, comparator: { max: 0, type: [{ code: "code" }] }, unit: { type: [{ code: "string" }] }, system: { type: [{ code: "uri" }] }, code: { type: [{ code: "code" }] } } }, MetadataResource: { elements: { id: { type: [{ code: "string" }] }, meta: { type: [{ code: "Meta" }] }, implicitRules: { type: [{ code: "uri" }] }, language: { type: [{ code: "code" }] }, text: { type: [{ code: "Narrative" }] }, contained: { max: 9007199254740991, type: [{ code: "Resource" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, url: { type: [{ code: "uri" }] }, version: { type: [{ code: "string" }] }, name: { type: [{ code: "string" }] }, title: { type: [{ code: "string" }] }, status: { min: 1, type: [{ code: "code" }] }, experimental: { type: [{ code: "boolean" }] }, date: { type: [{ code: "dateTime" }] }, publisher: { type: [{ code: "string" }] }, contact: { max: 9007199254740991, type: [{ code: "ContactDetail" }] }, description: { type: [{ code: "markdown" }] }, useContext: { max: 9007199254740991, type: [{ code: "UsageContext" }] }, jurisdiction: { max: 9007199254740991, type: [{ code: "CodeableConcept" }] } } }, IdentityProvider: { elements: { authorizeUrl: { min: 1, type: [{ code: "string" }] }, tokenUrl: { min: 1, type: [{ code: "string" }] }, tokenAuthMethod: { type: [{ code: "code" }] }, userInfoUrl: { min: 1, type: [{ code: "string" }] }, clientId: { min: 1, type: [{ code: "string" }] }, clientSecret: { min: 1, type: [{ code: "string" }] }, usePkce: { type: [{ code: "boolean" }] }, useSubject: { type: [{ code: "boolean" }] } } } };
37175
+ var Wr = { Element: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] } } }, BackboneElement: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] } } }, Address: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, use: { type: [{ code: "code" }] }, type: { type: [{ code: "code" }] }, text: { type: [{ code: "string" }] }, line: { max: 9007199254740991, type: [{ code: "string" }] }, city: { type: [{ code: "string" }] }, district: { type: [{ code: "string" }] }, state: { type: [{ code: "string" }] }, postalCode: { type: [{ code: "string" }] }, country: { type: [{ code: "string" }] }, period: { type: [{ code: "Period" }] } } }, Age: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, comparator: { type: [{ code: "code" }] }, unit: { type: [{ code: "string" }] }, system: { type: [{ code: "uri" }] }, code: { type: [{ code: "code" }] } } }, Annotation: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, "author[x]": { type: [{ code: "Reference", targetProfile: ["http://hl7.org/fhir/StructureDefinition/Practitioner", "http://hl7.org/fhir/StructureDefinition/Patient", "http://hl7.org/fhir/StructureDefinition/RelatedPerson", "http://hl7.org/fhir/StructureDefinition/Organization"] }, { code: "string" }] }, time: { type: [{ code: "dateTime" }] }, text: { min: 1, type: [{ code: "markdown" }] } } }, Attachment: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, contentType: { type: [{ code: "code" }] }, language: { type: [{ code: "code" }] }, data: { type: [{ code: "base64Binary" }] }, url: { type: [{ code: "url" }] }, size: { type: [{ code: "unsignedInt" }] }, hash: { type: [{ code: "base64Binary" }] }, title: { type: [{ code: "string" }] }, creation: { type: [{ code: "dateTime" }] } } }, CodeableConcept: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, coding: { max: 9007199254740991, type: [{ code: "Coding" }] }, text: { type: [{ code: "string" }] } } }, Coding: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, system: { type: [{ code: "uri" }] }, version: { type: [{ code: "string" }] }, code: { type: [{ code: "code" }] }, display: { type: [{ code: "string" }] }, userSelected: { type: [{ code: "boolean" }] } } }, ContactDetail: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, name: { type: [{ code: "string" }] }, telecom: { max: 9007199254740991, type: [{ code: "ContactPoint" }] } } }, ContactPoint: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, system: { type: [{ code: "code" }] }, value: { type: [{ code: "string" }] }, use: { type: [{ code: "code" }] }, rank: { type: [{ code: "positiveInt" }] }, period: { type: [{ code: "Period" }] } } }, Contributor: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, type: { min: 1, type: [{ code: "code" }] }, name: { min: 1, type: [{ code: "string" }] }, contact: { max: 9007199254740991, type: [{ code: "ContactDetail" }] } } }, Count: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, comparator: { type: [{ code: "code" }] }, unit: { type: [{ code: "string" }] }, system: { type: [{ code: "uri" }] }, code: { type: [{ code: "code" }] } } }, DataRequirement: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, type: { min: 1, type: [{ code: "code" }] }, profile: { max: 9007199254740991, type: [{ code: "canonical", targetProfile: ["http://hl7.org/fhir/StructureDefinition/StructureDefinition"] }] }, "subject[x]": { type: [{ code: "CodeableConcept" }, { code: "Reference", targetProfile: ["http://hl7.org/fhir/StructureDefinition/Group"] }] }, mustSupport: { max: 9007199254740991, type: [{ code: "string" }] }, codeFilter: { max: 9007199254740991, type: [{ code: "DataRequirementCodeFilter" }] }, dateFilter: { max: 9007199254740991, type: [{ code: "DataRequirementDateFilter" }] }, limit: { type: [{ code: "positiveInt" }] }, sort: { max: 9007199254740991, type: [{ code: "DataRequirementSort" }] } } }, Distance: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, comparator: { type: [{ code: "code" }] }, unit: { type: [{ code: "string" }] }, system: { type: [{ code: "uri" }] }, code: { type: [{ code: "code" }] } } }, Dosage: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, sequence: { type: [{ code: "integer" }] }, text: { type: [{ code: "string" }] }, additionalInstruction: { max: 9007199254740991, type: [{ code: "CodeableConcept" }] }, patientInstruction: { type: [{ code: "string" }] }, timing: { type: [{ code: "Timing" }] }, "asNeeded[x]": { type: [{ code: "boolean" }, { code: "CodeableConcept" }] }, site: { type: [{ code: "CodeableConcept" }] }, route: { type: [{ code: "CodeableConcept" }] }, method: { type: [{ code: "CodeableConcept" }] }, doseAndRate: { max: 9007199254740991, type: [{ code: "DosageDoseAndRate" }] }, maxDosePerPeriod: { type: [{ code: "Ratio" }] }, maxDosePerAdministration: { type: [{ code: "Quantity", profile: ["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"] }] }, maxDosePerLifetime: { type: [{ code: "Quantity", profile: ["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"] }] } } }, Duration: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, comparator: { type: [{ code: "code" }] }, unit: { type: [{ code: "string" }] }, system: { type: [{ code: "uri" }] }, code: { type: [{ code: "code" }] } } }, ElementDefinition: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, path: { min: 1, type: [{ code: "string" }] }, representation: { max: 9007199254740991, type: [{ code: "code" }] }, sliceName: { type: [{ code: "string" }] }, sliceIsConstraining: { type: [{ code: "boolean" }] }, label: { type: [{ code: "string" }] }, code: { max: 9007199254740991, type: [{ code: "Coding" }] }, slicing: { type: [{ code: "ElementDefinitionSlicing" }] }, short: { type: [{ code: "string" }] }, definition: { type: [{ code: "markdown" }] }, comment: { type: [{ code: "markdown" }] }, requirements: { type: [{ code: "markdown" }] }, alias: { max: 9007199254740991, type: [{ code: "string" }] }, min: { type: [{ code: "unsignedInt" }] }, max: { type: [{ code: "string" }] }, base: { type: [{ code: "ElementDefinitionBase" }] }, contentReference: { type: [{ code: "uri" }] }, type: { max: 9007199254740991, type: [{ code: "ElementDefinitionType" }] }, "defaultValue[x]": { type: [{ code: "base64Binary" }, { code: "boolean" }, { code: "canonical" }, { code: "code" }, { code: "date" }, { code: "dateTime" }, { code: "decimal" }, { code: "id" }, { code: "instant" }, { code: "integer" }, { code: "markdown" }, { code: "oid" }, { code: "positiveInt" }, { code: "string" }, { code: "time" }, { code: "unsignedInt" }, { code: "uri" }, { code: "url" }, { code: "uuid" }, { code: "Address" }, { code: "Age" }, { code: "Annotation" }, { code: "Attachment" }, { code: "CodeableConcept" }, { code: "Coding" }, { code: "ContactPoint" }, { code: "Count" }, { code: "Distance" }, { code: "Duration" }, { code: "HumanName" }, { code: "Identifier" }, { code: "Money" }, { code: "Period" }, { code: "Quantity" }, { code: "Range" }, { code: "Ratio" }, { code: "Reference" }, { code: "SampledData" }, { code: "Signature" }, { code: "Timing" }, { code: "ContactDetail" }, { code: "Contributor" }, { code: "DataRequirement" }, { code: "Expression" }, { code: "ParameterDefinition" }, { code: "RelatedArtifact" }, { code: "TriggerDefinition" }, { code: "UsageContext" }, { code: "Dosage" }, { code: "Meta" }] }, meaningWhenMissing: { type: [{ code: "markdown" }] }, orderMeaning: { type: [{ code: "string" }] }, "fixed[x]": { type: [{ code: "base64Binary" }, { code: "boolean" }, { code: "canonical" }, { code: "code" }, { code: "date" }, { code: "dateTime" }, { code: "decimal" }, { code: "id" }, { code: "instant" }, { code: "integer" }, { code: "markdown" }, { code: "oid" }, { code: "positiveInt" }, { code: "string" }, { code: "time" }, { code: "unsignedInt" }, { code: "uri" }, { code: "url" }, { code: "uuid" }, { code: "Address" }, { code: "Age" }, { code: "Annotation" }, { code: "Attachment" }, { code: "CodeableConcept" }, { code: "Coding" }, { code: "ContactPoint" }, { code: "Count" }, { code: "Distance" }, { code: "Duration" }, { code: "HumanName" }, { code: "Identifier" }, { code: "Money" }, { code: "Period" }, { code: "Quantity" }, { code: "Range" }, { code: "Ratio" }, { code: "Reference" }, { code: "SampledData" }, { code: "Signature" }, { code: "Timing" }, { code: "ContactDetail" }, { code: "Contributor" }, { code: "DataRequirement" }, { code: "Expression" }, { code: "ParameterDefinition" }, { code: "RelatedArtifact" }, { code: "TriggerDefinition" }, { code: "UsageContext" }, { code: "Dosage" }, { code: "Meta" }] }, "pattern[x]": { type: [{ code: "base64Binary" }, { code: "boolean" }, { code: "canonical" }, { code: "code" }, { code: "date" }, { code: "dateTime" }, { code: "decimal" }, { code: "id" }, { code: "instant" }, { code: "integer" }, { code: "markdown" }, { code: "oid" }, { code: "positiveInt" }, { code: "string" }, { code: "time" }, { code: "unsignedInt" }, { code: "uri" }, { code: "url" }, { code: "uuid" }, { code: "Address" }, { code: "Age" }, { code: "Annotation" }, { code: "Attachment" }, { code: "CodeableConcept" }, { code: "Coding" }, { code: "ContactPoint" }, { code: "Count" }, { code: "Distance" }, { code: "Duration" }, { code: "HumanName" }, { code: "Identifier" }, { code: "Money" }, { code: "Period" }, { code: "Quantity" }, { code: "Range" }, { code: "Ratio" }, { code: "Reference" }, { code: "SampledData" }, { code: "Signature" }, { code: "Timing" }, { code: "ContactDetail" }, { code: "Contributor" }, { code: "DataRequirement" }, { code: "Expression" }, { code: "ParameterDefinition" }, { code: "RelatedArtifact" }, { code: "TriggerDefinition" }, { code: "UsageContext" }, { code: "Dosage" }, { code: "Meta" }] }, example: { max: 9007199254740991, type: [{ code: "ElementDefinitionExample" }] }, "minValue[x]": { type: [{ code: "date" }, { code: "dateTime" }, { code: "instant" }, { code: "time" }, { code: "decimal" }, { code: "integer" }, { code: "positiveInt" }, { code: "unsignedInt" }, { code: "Quantity" }] }, "maxValue[x]": { type: [{ code: "date" }, { code: "dateTime" }, { code: "instant" }, { code: "time" }, { code: "decimal" }, { code: "integer" }, { code: "positiveInt" }, { code: "unsignedInt" }, { code: "Quantity" }] }, maxLength: { type: [{ code: "integer" }] }, condition: { max: 9007199254740991, type: [{ code: "id" }] }, constraint: { max: 9007199254740991, type: [{ code: "ElementDefinitionConstraint" }] }, mustSupport: { type: [{ code: "boolean" }] }, isModifier: { type: [{ code: "boolean" }] }, isModifierReason: { type: [{ code: "string" }] }, isSummary: { type: [{ code: "boolean" }] }, binding: { type: [{ code: "ElementDefinitionBinding" }] }, mapping: { max: 9007199254740991, type: [{ code: "ElementDefinitionMapping" }] } } }, Expression: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, description: { type: [{ code: "string" }] }, name: { type: [{ code: "id" }] }, language: { min: 1, type: [{ code: "code" }] }, expression: { type: [{ code: "string" }] }, reference: { type: [{ code: "uri" }] } } }, Extension: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, url: { min: 1, type: [{ code: "uri" }] }, "value[x]": { type: [{ code: "base64Binary" }, { code: "boolean" }, { code: "canonical" }, { code: "code" }, { code: "date" }, { code: "dateTime" }, { code: "decimal" }, { code: "id" }, { code: "instant" }, { code: "integer" }, { code: "markdown" }, { code: "oid" }, { code: "positiveInt" }, { code: "string" }, { code: "time" }, { code: "unsignedInt" }, { code: "uri" }, { code: "url" }, { code: "uuid" }, { code: "Address" }, { code: "Age" }, { code: "Annotation" }, { code: "Attachment" }, { code: "CodeableConcept" }, { code: "Coding" }, { code: "ContactPoint" }, { code: "Count" }, { code: "Distance" }, { code: "Duration" }, { code: "HumanName" }, { code: "Identifier" }, { code: "Money" }, { code: "Period" }, { code: "Quantity" }, { code: "Range" }, { code: "Ratio" }, { code: "Reference" }, { code: "SampledData" }, { code: "Signature" }, { code: "Timing" }, { code: "ContactDetail" }, { code: "Contributor" }, { code: "DataRequirement" }, { code: "Expression" }, { code: "ParameterDefinition" }, { code: "RelatedArtifact" }, { code: "TriggerDefinition" }, { code: "UsageContext" }, { code: "Dosage" }, { code: "Meta" }] } } }, HumanName: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, use: { type: [{ code: "code" }] }, text: { type: [{ code: "string" }] }, family: { type: [{ code: "string" }] }, given: { max: 9007199254740991, type: [{ code: "string" }] }, prefix: { max: 9007199254740991, type: [{ code: "string" }] }, suffix: { max: 9007199254740991, type: [{ code: "string" }] }, period: { type: [{ code: "Period" }] } } }, Identifier: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, use: { type: [{ code: "code" }] }, type: { type: [{ code: "CodeableConcept" }] }, system: { type: [{ code: "uri" }] }, value: { type: [{ code: "string" }] }, period: { type: [{ code: "Period" }] }, assigner: { type: [{ code: "Reference", targetProfile: ["http://hl7.org/fhir/StructureDefinition/Organization"] }] } } }, MarketingStatus: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, country: { min: 1, type: [{ code: "CodeableConcept" }] }, jurisdiction: { type: [{ code: "CodeableConcept" }] }, status: { min: 1, type: [{ code: "CodeableConcept" }] }, dateRange: { min: 1, type: [{ code: "Period" }] }, restoreDate: { type: [{ code: "dateTime" }] } } }, Meta: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, versionId: { type: [{ code: "id" }] }, lastUpdated: { type: [{ code: "instant" }] }, source: { type: [{ code: "uri" }] }, profile: { max: 9007199254740991, type: [{ code: "canonical", targetProfile: ["http://hl7.org/fhir/StructureDefinition/StructureDefinition"] }] }, security: { max: 9007199254740991, type: [{ code: "Coding" }] }, tag: { max: 9007199254740991, type: [{ code: "Coding" }] }, project: { type: [{ code: "uri" }] }, author: { type: [{ code: "Reference" }] }, account: { type: [{ code: "Reference" }] }, compartment: { max: 9007199254740991, type: [{ code: "Reference" }] } } }, Money: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, currency: { type: [{ code: "code" }] } } }, Narrative: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, status: { min: 1, type: [{ code: "code" }] }, div: { min: 1, type: [{ code: "xhtml" }] } } }, ParameterDefinition: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, name: { type: [{ code: "code" }] }, use: { min: 1, type: [{ code: "code" }] }, min: { type: [{ code: "integer" }] }, max: { type: [{ code: "string" }] }, documentation: { type: [{ code: "string" }] }, type: { min: 1, type: [{ code: "code" }] }, profile: { type: [{ code: "canonical", targetProfile: ["http://hl7.org/fhir/StructureDefinition/StructureDefinition"] }] } } }, Period: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, start: { type: [{ code: "dateTime" }] }, end: { type: [{ code: "dateTime" }] } } }, Population: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, "age[x]": { type: [{ code: "Range" }, { code: "CodeableConcept" }] }, gender: { type: [{ code: "CodeableConcept" }] }, race: { type: [{ code: "CodeableConcept" }] }, physiologicalCondition: { type: [{ code: "CodeableConcept" }] } } }, ProdCharacteristic: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, height: { type: [{ code: "Quantity" }] }, width: { type: [{ code: "Quantity" }] }, depth: { type: [{ code: "Quantity" }] }, weight: { type: [{ code: "Quantity" }] }, nominalVolume: { type: [{ code: "Quantity" }] }, externalDiameter: { type: [{ code: "Quantity" }] }, shape: { type: [{ code: "string" }] }, color: { max: 9007199254740991, type: [{ code: "string" }] }, imprint: { max: 9007199254740991, type: [{ code: "string" }] }, image: { max: 9007199254740991, type: [{ code: "Attachment" }] }, scoring: { type: [{ code: "CodeableConcept" }] } } }, ProductShelfLife: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, identifier: { type: [{ code: "Identifier" }] }, type: { min: 1, type: [{ code: "CodeableConcept" }] }, period: { min: 1, type: [{ code: "Quantity" }] }, specialPrecautionsForStorage: { max: 9007199254740991, type: [{ code: "CodeableConcept" }] } } }, Quantity: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, comparator: { type: [{ code: "code" }] }, unit: { type: [{ code: "string" }] }, system: { type: [{ code: "uri" }] }, code: { type: [{ code: "code" }] } } }, Range: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, low: { type: [{ code: "Quantity", profile: ["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"] }] }, high: { type: [{ code: "Quantity", profile: ["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"] }] } } }, Ratio: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, numerator: { type: [{ code: "Quantity" }] }, denominator: { type: [{ code: "Quantity" }] } } }, Reference: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, reference: { type: [{ code: "string" }] }, type: { type: [{ code: "uri" }] }, identifier: { type: [{ code: "Identifier" }] }, display: { type: [{ code: "string" }] } } }, RelatedArtifact: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, type: { min: 1, type: [{ code: "code" }] }, label: { type: [{ code: "string" }] }, display: { type: [{ code: "string" }] }, citation: { type: [{ code: "markdown" }] }, url: { type: [{ code: "url" }] }, document: { type: [{ code: "Attachment" }] }, resource: { type: [{ code: "canonical", targetProfile: ["http://hl7.org/fhir/StructureDefinition/Resource"] }] } } }, SampledData: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, origin: { min: 1, type: [{ code: "Quantity", profile: ["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"] }] }, period: { min: 1, type: [{ code: "decimal" }] }, factor: { type: [{ code: "decimal" }] }, lowerLimit: { type: [{ code: "decimal" }] }, upperLimit: { type: [{ code: "decimal" }] }, dimensions: { min: 1, type: [{ code: "positiveInt" }] }, data: { type: [{ code: "string" }] } } }, Signature: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, type: { min: 1, max: 9007199254740991, type: [{ code: "Coding" }] }, when: { min: 1, type: [{ code: "instant" }] }, who: { min: 1, type: [{ code: "Reference", targetProfile: ["http://hl7.org/fhir/StructureDefinition/Practitioner", "http://hl7.org/fhir/StructureDefinition/PractitionerRole", "http://hl7.org/fhir/StructureDefinition/RelatedPerson", "http://hl7.org/fhir/StructureDefinition/Patient", "http://hl7.org/fhir/StructureDefinition/Device", "http://hl7.org/fhir/StructureDefinition/Organization"] }] }, onBehalfOf: { type: [{ code: "Reference", targetProfile: ["http://hl7.org/fhir/StructureDefinition/Practitioner", "http://hl7.org/fhir/StructureDefinition/PractitionerRole", "http://hl7.org/fhir/StructureDefinition/RelatedPerson", "http://hl7.org/fhir/StructureDefinition/Patient", "http://hl7.org/fhir/StructureDefinition/Device", "http://hl7.org/fhir/StructureDefinition/Organization"] }] }, targetFormat: { type: [{ code: "code" }] }, sigFormat: { type: [{ code: "code" }] }, data: { type: [{ code: "base64Binary" }] } } }, SubstanceAmount: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, "amount[x]": { type: [{ code: "Quantity" }, { code: "Range" }, { code: "string" }] }, amountType: { type: [{ code: "CodeableConcept" }] }, amountText: { type: [{ code: "string" }] }, referenceRange: { type: [{ code: "SubstanceAmountReferenceRange" }] } } }, Timing: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, event: { max: 9007199254740991, type: [{ code: "dateTime" }] }, repeat: { type: [{ code: "TimingRepeat" }] }, code: { type: [{ code: "CodeableConcept" }] } } }, TriggerDefinition: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, type: { min: 1, type: [{ code: "code" }] }, name: { type: [{ code: "string" }] }, "timing[x]": { type: [{ code: "Timing" }, { code: "Reference", targetProfile: ["http://hl7.org/fhir/StructureDefinition/Schedule"] }, { code: "date" }, { code: "dateTime" }] }, data: { max: 9007199254740991, type: [{ code: "DataRequirement" }] }, condition: { type: [{ code: "Expression" }] } } }, UsageContext: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, code: { min: 1, type: [{ code: "Coding" }] }, "value[x]": { min: 1, type: [{ code: "CodeableConcept" }, { code: "Quantity" }, { code: "Range" }, { code: "Reference", targetProfile: ["http://hl7.org/fhir/StructureDefinition/PlanDefinition", "http://hl7.org/fhir/StructureDefinition/ResearchStudy", "http://hl7.org/fhir/StructureDefinition/InsurancePlan", "http://hl7.org/fhir/StructureDefinition/HealthcareService", "http://hl7.org/fhir/StructureDefinition/Group", "http://hl7.org/fhir/StructureDefinition/Location", "http://hl7.org/fhir/StructureDefinition/Organization"] }] } } }, MoneyQuantity: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, comparator: { type: [{ code: "code" }] }, unit: { type: [{ code: "string" }] }, system: { type: [{ code: "uri" }] }, code: { type: [{ code: "code" }] } } }, SimpleQuantity: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, comparator: { max: 0, type: [{ code: "code" }] }, unit: { type: [{ code: "string" }] }, system: { type: [{ code: "uri" }] }, code: { type: [{ code: "code" }] } } }, MetadataResource: { elements: { id: { type: [{ code: "string" }] }, meta: { type: [{ code: "Meta" }] }, implicitRules: { type: [{ code: "uri" }] }, language: { type: [{ code: "code" }] }, text: { type: [{ code: "Narrative" }] }, contained: { max: 9007199254740991, type: [{ code: "Resource" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, url: { type: [{ code: "uri" }] }, version: { type: [{ code: "string" }] }, name: { type: [{ code: "string" }] }, title: { type: [{ code: "string" }] }, status: { min: 1, type: [{ code: "code" }] }, experimental: { type: [{ code: "boolean" }] }, date: { type: [{ code: "dateTime" }] }, publisher: { type: [{ code: "string" }] }, contact: { max: 9007199254740991, type: [{ code: "ContactDetail" }] }, description: { type: [{ code: "markdown" }] }, useContext: { max: 9007199254740991, type: [{ code: "UsageContext" }] }, jurisdiction: { max: 9007199254740991, type: [{ code: "CodeableConcept" }] } } }, IdentityProvider: { elements: { authorizeUrl: { min: 1, type: [{ code: "string" }] }, tokenUrl: { min: 1, type: [{ code: "string" }] }, tokenAuthMethod: { type: [{ code: "code" }] }, userInfoUrl: { min: 1, type: [{ code: "string" }] }, clientId: { min: 1, type: [{ code: "string" }] }, clientSecret: { min: 1, type: [{ code: "string" }] }, usePkce: { type: [{ code: "boolean" }] }, useSubject: { type: [{ code: "boolean" }] } } } };
39470
37176
  function $t(r4) {
39471
37177
  return new qt(r4).parse();
39472
37178
  }
39473
- var Pe = jr($r);
37179
+ var Pe = $r(Wr);
39474
37180
  var Wt = /* @__PURE__ */ Object.create(null);
39475
- var Wr = /* @__PURE__ */ Object.create(null);
37181
+ var Hr = /* @__PURE__ */ Object.create(null);
39476
37182
  function Bt(r4) {
39477
37183
  let e;
39478
- return r4 ? (e = Wr[r4], e || (e = Wr[r4] = /* @__PURE__ */ Object.create(null))) : e = Pe, e;
37184
+ return r4 ? (e = Hr[r4], e || (e = Hr[r4] = /* @__PURE__ */ Object.create(null))) : e = Pe, e;
39479
37185
  }
39480
37186
  function Ht(r4, e) {
39481
37187
  let t = Array.isArray(r4) ? r4 : r4.entry?.map((n) => n.resource) ?? [];
@@ -39492,21 +37198,21 @@ function Gt(r4, e) {
39492
37198
  for (let i2 of t.innerTypes)
39493
37199
  i2.parentType = t, n[i2.name] = i2;
39494
37200
  }
39495
- function zr(r4) {
37201
+ function Jr(r4) {
39496
37202
  return !!Pe[r4];
39497
37203
  }
39498
37204
  function Ce(r4, e) {
39499
37205
  let t = Bt(e)[r4];
39500
37206
  return !t && e && (t = Bt()[r4]), t;
39501
37207
  }
39502
- function Yr(r4) {
37208
+ function Zr(r4) {
39503
37209
  return !!Wt[r4];
39504
37210
  }
39505
37211
  var qt = class {
39506
37212
  constructor(e) {
39507
37213
  if (!e.snapshot?.element || e.snapshot.element.length === 0)
39508
37214
  throw new Error(`No snapshot defined for StructureDefinition '${e.name}'`);
39509
- this.root = e.snapshot.element[0], this.elements = e.snapshot.element.slice(1), this.elementIndex = /* @__PURE__ */ Object.create(null), this.index = 0, this.resourceSchema = { name: e.name, title: e.title, type: e.type, url: e.url, kind: e.kind, description: Ri(e), elements: {}, constraints: this.parseElementDefinition(this.root).constraints, innerTypes: [], summaryProperties: /* @__PURE__ */ new Set(), mandatoryProperties: /* @__PURE__ */ new Set() }, this.innerTypes = [];
37215
+ this.root = e.snapshot.element[0], this.elements = e.snapshot.element.slice(1), this.elementIndex = /* @__PURE__ */ Object.create(null), this.index = 0, this.resourceSchema = { name: e.name, title: e.title, type: e.type, url: e.url, kind: e.kind, description: wi(e), elements: {}, constraints: this.parseElementDefinition(this.root).constraints, innerTypes: [], summaryProperties: /* @__PURE__ */ new Set(), mandatoryProperties: /* @__PURE__ */ new Set() }, this.innerTypes = [];
39510
37216
  }
39511
37217
  parse() {
39512
37218
  let e = this.next();
@@ -39548,7 +37254,7 @@ var qt = class {
39548
37254
  this.backboneContext = { type: { name: jt(e), title: e.label, description: e.definition, elements: {}, constraints: this.parseElementDefinition(e).constraints, innerTypes: [] }, path: e.path ?? "", parent: de(this.backboneContext?.path, e.path) ? this.backboneContext : this.backboneContext?.parent };
39549
37255
  }
39550
37256
  enterSlice(e, t) {
39551
- bi(e) && !this.peek()?.sliceName || (t.slicing = { discriminator: (e.slicing?.discriminator ?? []).map((n) => {
37257
+ Ci(e) && !this.peek()?.sliceName || (t.slicing = { discriminator: (e.slicing?.discriminator ?? []).map((n) => {
39552
37258
  if (n.type !== "value" && n.type !== "pattern" && n.type !== "type")
39553
37259
  throw new Error(`Unsupported slicing discriminator type: ${n.type}`);
39554
37260
  return { path: n.path, type: n.type };
@@ -39595,30 +37301,30 @@ var qt = class {
39595
37301
  });
39596
37302
  }
39597
37303
  parseElementDefinition(e) {
39598
- let t = Gr(e.max), n = e.base?.max ? Gr(e.base.max) : t, i2 = { type: "ElementDefinition", value: e };
39599
- return { description: e.definition || "", path: e.path || e.base?.path || "", min: e.min ?? 0, max: t, isArray: n > 1, constraints: (e.constraint ?? []).map((o) => ({ key: o.key ?? "", severity: o.severity ?? "error", expression: o.expression ?? "", description: o.human ?? "" })), type: this.parseElementDefinitionType(e), fixed: Qr(A(i2, "fixed[x]")), pattern: Qr(A(i2, "pattern[x]")), binding: e.binding };
37304
+ let t = Qr(e.max), n = e.base?.max ? Qr(e.base.max) : t, i2 = { type: "ElementDefinition", value: e };
37305
+ return { description: e.definition || "", path: e.path || e.base?.path || "", min: e.min ?? 0, max: t, isArray: n > 1, constraints: (e.constraint ?? []).map((o) => ({ key: o.key ?? "", severity: o.severity ?? "error", expression: o.expression ?? "", description: o.human ?? "" })), type: this.parseElementDefinitionType(e), fixed: Kr(A(i2, "fixed[x]")), pattern: Kr(A(i2, "pattern[x]")), binding: e.binding };
39600
37306
  }
39601
37307
  };
39602
- function Gr(r4) {
37308
+ function Qr(r4) {
39603
37309
  return r4 === "*" ? Number.POSITIVE_INFINITY : Number.parseInt(r4, 10);
39604
37310
  }
39605
37311
  function Ut(r4, e = "") {
39606
- return Ei(r4.path, e);
37312
+ return Pi(r4.path, e);
39607
37313
  }
39608
- function Ei(r4, e) {
37314
+ function Pi(r4, e) {
39609
37315
  return r4 ? e && r4.startsWith(e) ? r4.substring(e.length + 1) : r4 : "";
39610
37316
  }
39611
37317
  function de(r4, e) {
39612
37318
  return !r4 || !e ? false : e.startsWith(r4 + ".") || e === r4;
39613
37319
  }
39614
- function Qr(r4) {
37320
+ function Kr(r4) {
39615
37321
  return Array.isArray(r4) && r4.length > 0 ? r4[0] : S(r4) ? void 0 : r4;
39616
37322
  }
39617
- function bi(r4) {
37323
+ function Ci(r4) {
39618
37324
  let e = r4.slicing?.discriminator;
39619
37325
  return !!(r4.type?.some((t) => t.code === "Extension") && e?.length === 1 && e[0].type === "value" && e[0].path === "url");
39620
37326
  }
39621
- function Ri(r4) {
37327
+ function wi(r4) {
39622
37328
  let e = r4.description;
39623
37329
  return e?.startsWith(`Base StructureDefinition for ${r4.name} Type: `) && (e = e.substring(`Base StructureDefinition for ${r4.name} Type: `.length)), e;
39624
37330
  }
@@ -39643,9 +37349,9 @@ function A(r4, e, t) {
39643
37349
  if (!r4.value)
39644
37350
  return;
39645
37351
  let n = Ze(r4.type, e, t?.profileUrl);
39646
- return n ? Vi(r4, e, n) : Di(r4, e);
37352
+ return n ? Ni(r4, e, n) : Fi(r4, e);
39647
37353
  }
39648
- function Vi(r4, e, t) {
37354
+ function Ni(r4, e, t) {
39649
37355
  let n = r4.value, i2 = t.type;
39650
37356
  if (!i2 || i2.length === 0)
39651
37357
  return;
@@ -39665,16 +37371,16 @@ function Vi(r4, e, t) {
39665
37371
  if (Array.isArray(o)) {
39666
37372
  o = o.slice();
39667
37373
  for (let c2 = 0; c2 < Math.max(o.length, a.length); c2++)
39668
- o[c2] = sn(o[c2], a[c2]);
37374
+ o[c2] = an(o[c2], a[c2]);
39669
37375
  } else
39670
- o = sn(o, a);
37376
+ o = an(o, a);
39671
37377
  if (!S(o))
39672
- return (s === "Element" || s === "BackboneElement") && (s = t.type[0].code), Array.isArray(o) ? o.map((c2) => tn(c2, s)) : tn(o, s);
37378
+ return (s === "Element" || s === "BackboneElement") && (s = t.type[0].code), Array.isArray(o) ? o.map((c2) => rn(c2, s)) : rn(o, s);
39673
37379
  }
39674
- function tn(r4, e) {
37380
+ function rn(r4, e) {
39675
37381
  return e === "Resource" && _(r4) && (e = r4.resourceType), { type: e, value: r4 };
39676
37382
  }
39677
- function Di(r4, e) {
37383
+ function Fi(r4, e) {
39678
37384
  let t = r4.value;
39679
37385
  if (!t || typeof t != "object")
39680
37386
  return;
@@ -39697,7 +37403,7 @@ function Je(r4) {
39697
37403
  for (let t of r4) {
39698
37404
  let n = false;
39699
37405
  for (let i2 of e)
39700
- if (F(an(t, i2))) {
37406
+ if (F(cn(t, i2))) {
39701
37407
  n = true;
39702
37408
  break;
39703
37409
  }
@@ -39709,20 +37415,20 @@ function er(r4) {
39709
37415
  return f(!F(r4));
39710
37416
  }
39711
37417
  function tr(r4, e) {
39712
- return r4.length === 0 || e.length === 0 ? [] : r4.length !== e.length ? f(false) : f(r4.every((t, n) => F(an(t, e[n]))));
37418
+ return r4.length === 0 || e.length === 0 ? [] : r4.length !== e.length ? f(false) : f(r4.every((t, n) => F(cn(t, e[n]))));
39713
37419
  }
39714
- function an(r4, e) {
37420
+ function cn(r4, e) {
39715
37421
  let t = r4.value?.valueOf(), n = e.value?.valueOf();
39716
- return typeof t == "number" && typeof n == "number" ? f(Math.abs(t - n) < 1e-8) : O(t) && O(n) ? f(ln(t, n)) : f(typeof t == "object" && typeof n == "object" ? nr(r4, e) : t === n);
37422
+ return typeof t == "number" && typeof n == "number" ? f(Math.abs(t - n) < 1e-8) : O(t) && O(n) ? f(pn(t, n)) : f(typeof t == "object" && typeof n == "object" ? nr(r4, e) : t === n);
39717
37423
  }
39718
37424
  function rr(r4, e) {
39719
- return r4.length === 0 && e.length === 0 ? f(true) : r4.length !== e.length ? f(false) : (r4.sort(rn), e.sort(rn), f(r4.every((t, n) => F(Mi(t, e[n])))));
37425
+ return r4.length === 0 && e.length === 0 ? f(true) : r4.length !== e.length ? f(false) : (r4.sort(nn), e.sort(nn), f(r4.every((t, n) => F(_i(t, e[n])))));
39720
37426
  }
39721
- function Mi(r4, e) {
37427
+ function _i(r4, e) {
39722
37428
  let { type: t, value: n } = r4, { type: i2, value: o } = e, s = n?.valueOf(), a = o?.valueOf();
39723
- return typeof s == "number" && typeof a == "number" ? f(Math.abs(s - a) < 0.01) : O(s) && O(a) ? f(ln(s, a)) : f(t === "Coding" && i2 === "Coding" ? typeof s != "object" || typeof a != "object" ? false : s.code === a.code && s.system === a.system : typeof s == "object" && typeof a == "object" ? nr({ ...s, id: void 0 }, { ...a, id: void 0 }) : typeof s == "string" && typeof a == "string" ? s.toLowerCase() === a.toLowerCase() : s === a);
37429
+ return typeof s == "number" && typeof a == "number" ? f(Math.abs(s - a) < 0.01) : O(s) && O(a) ? f(pn(s, a)) : f(t === "Coding" && i2 === "Coding" ? typeof s != "object" || typeof a != "object" ? false : s.code === a.code && s.system === a.system : typeof s == "object" && typeof a == "object" ? nr({ ...s, id: void 0 }, { ...a, id: void 0 }) : typeof s == "string" && typeof a == "string" ? s.toLowerCase() === a.toLowerCase() : s === a);
39724
37430
  }
39725
- function rn(r4, e) {
37431
+ function nn(r4, e) {
39726
37432
  let t = r4.value?.valueOf(), n = e.value?.valueOf();
39727
37433
  return typeof t == "number" && typeof n == "number" ? t - n : typeof t == "string" && typeof n == "string" ? t.localeCompare(n) : 0;
39728
37434
  }
@@ -39737,32 +37443,32 @@ function Ye(r4, e) {
39737
37443
  case "Integer":
39738
37444
  return typeof t == "number";
39739
37445
  case "Date":
39740
- return cn(t);
37446
+ return un(t);
39741
37447
  case "DateTime":
39742
37448
  return ze(t);
39743
37449
  case "Time":
39744
37450
  return typeof t == "string" && !!/^T\d/.exec(t);
39745
37451
  case "Period":
39746
- return un(t);
37452
+ return ln(t);
39747
37453
  case "Quantity":
39748
37454
  return O(t);
39749
37455
  default:
39750
37456
  return typeof t == "object" && t?.resourceType === e;
39751
37457
  }
39752
37458
  }
39753
- function cn(r4) {
37459
+ function un(r4) {
39754
37460
  return typeof r4 == "string" && !!Ge.date.exec(r4);
39755
37461
  }
39756
37462
  function ze(r4) {
39757
37463
  return typeof r4 == "string" && !!Ge.dateTime.exec(r4);
39758
37464
  }
39759
- function un(r4) {
37465
+ function ln(r4) {
39760
37466
  return !!(r4 && typeof r4 == "object" && ("start" in r4 && ze(r4.start) || "end" in r4 && ze(r4.end)));
39761
37467
  }
39762
37468
  function O(r4) {
39763
37469
  return !!(r4 && typeof r4 == "object" && "value" in r4 && typeof r4.value == "number");
39764
37470
  }
39765
- function ln(r4, e) {
37471
+ function pn(r4, e) {
39766
37472
  return Math.abs(r4.value - e.value) < 0.01 && (r4.unit === e.unit || r4.code === e.code || r4.unit === e.code || r4.code === e.unit);
39767
37473
  }
39768
37474
  function nr(r4, e) {
@@ -39771,7 +37477,7 @@ function nr(r4, e) {
39771
37477
  return false;
39772
37478
  for (let i2 of t) {
39773
37479
  let o = r4[i2], s = e[i2];
39774
- if (on(o) && on(s)) {
37480
+ if (sn(o) && sn(s)) {
39775
37481
  if (!nr(o, s))
39776
37482
  return false;
39777
37483
  } else if (o !== s)
@@ -39779,42 +37485,42 @@ function nr(r4, e) {
39779
37485
  }
39780
37486
  return true;
39781
37487
  }
39782
- function on(r4) {
37488
+ function sn(r4) {
39783
37489
  return r4 !== null && typeof r4 == "object";
39784
37490
  }
39785
- function sn(r4, e) {
37491
+ function an(r4, e) {
39786
37492
  if (e) {
39787
37493
  if (typeof e != "object")
39788
37494
  throw new Error("Primitive extension must be an object");
39789
- return Ni(r4 ?? {}, e);
37495
+ return Li(r4 ?? {}, e);
39790
37496
  }
39791
37497
  return r4;
39792
37498
  }
39793
- function Ni(r4, e) {
37499
+ function Li(r4, e) {
39794
37500
  return delete e.__proto__, delete e.constructor, Object.assign(r4, e);
39795
37501
  }
39796
37502
  function K(r4) {
39797
- let e = ee(r4), t = _i(r4);
37503
+ let e = te(r4), t = Bi(r4);
39798
37504
  return t === e ? { reference: e } : { reference: e, display: t };
39799
37505
  }
39800
- function ee(r4) {
39801
- return X(r4) ? r4.reference : `${r4.resourceType}/${r4.id}`;
37506
+ function te(r4) {
37507
+ return ee(r4) ? r4.reference : `${r4.resourceType}/${r4.id}`;
39802
37508
  }
39803
37509
  function et(r4) {
39804
37510
  if (r4)
39805
- return X(r4) ? r4.reference.split("/")[1] : r4.id;
37511
+ return ee(r4) ? r4.reference.split("/")[1] : r4.id;
39806
37512
  }
39807
- function Fi(r4) {
37513
+ function Ui(r4) {
39808
37514
  return r4.resourceType === "Patient" || r4.resourceType === "Practitioner" || r4.resourceType === "RelatedPerson";
39809
37515
  }
39810
- function _i(r4) {
39811
- if (Fi(r4)) {
39812
- let e = Li(r4);
37516
+ function Bi(r4) {
37517
+ if (Ui(r4)) {
37518
+ let e = qi(r4);
39813
37519
  if (e)
39814
37520
  return e;
39815
37521
  }
39816
37522
  if (r4.resourceType === "Device") {
39817
- let e = Ui(r4);
37523
+ let e = ji(r4);
39818
37524
  if (e)
39819
37525
  return e;
39820
37526
  }
@@ -39829,19 +37535,19 @@ function _i(r4) {
39829
37535
  return r4.name;
39830
37536
  if ("code" in r4 && r4.code) {
39831
37537
  let e = r4.code;
39832
- if (Array.isArray(e) && (e = e[0]), Ki(e))
37538
+ if (Array.isArray(e) && (e = e[0]), Yi(e))
39833
37539
  return Xe(e);
39834
- if (zi(e))
37540
+ if (Zi(e))
39835
37541
  return e.text;
39836
37542
  }
39837
- return ee(r4);
37543
+ return te(r4);
39838
37544
  }
39839
- function Li(r4) {
37545
+ function qi(r4) {
39840
37546
  let e = r4.name;
39841
37547
  if (e && e.length > 0)
39842
37548
  return nt(e[0]);
39843
37549
  }
39844
- function Ui(r4) {
37550
+ function ji(r4) {
39845
37551
  let e = r4.deviceName;
39846
37552
  if (e && e.length > 0)
39847
37553
  return e[0].name;
@@ -39864,13 +37570,13 @@ function Qt(r4, ...e) {
39864
37570
  t = t?.extension?.find((i2) => i2.url === e[n]);
39865
37571
  return t;
39866
37572
  }
39867
- function mn(r4, e) {
39868
- return JSON.stringify(r4, Bi, e ? 2 : void 0);
37573
+ function hn(r4, e) {
37574
+ return JSON.stringify(r4, $i, e ? 2 : void 0);
39869
37575
  }
39870
- function Bi(r4, e) {
39871
- return !qi(r4) && S(e) ? void 0 : e;
37576
+ function $i(r4, e) {
37577
+ return !Wi(r4) && S(e) ? void 0 : e;
39872
37578
  }
39873
- function qi(r4) {
37579
+ function Wi(r4) {
39874
37580
  return !!/\d+$/.exec(r4);
39875
37581
  }
39876
37582
  function S(r4) {
@@ -39888,31 +37594,31 @@ function H(r4) {
39888
37594
  function b(r4) {
39889
37595
  return r4 !== null && typeof r4 == "object";
39890
37596
  }
39891
- function hn(r4) {
39892
- return r4.every(Gi);
37597
+ function yn(r4) {
37598
+ return r4.every(zi);
39893
37599
  }
39894
- function Gi(r4) {
37600
+ function zi(r4) {
39895
37601
  return typeof r4 == "string";
39896
37602
  }
39897
- function Qi(r4) {
37603
+ function Ji(r4) {
39898
37604
  return b(r4) && "code" in r4 && typeof r4.code == "string";
39899
37605
  }
39900
- function Ki(r4) {
39901
- return b(r4) && "coding" in r4 && Array.isArray(r4.coding) && r4.coding.every(Qi);
37606
+ function Yi(r4) {
37607
+ return b(r4) && "coding" in r4 && Array.isArray(r4.coding) && r4.coding.every(Ji);
39902
37608
  }
39903
- function zi(r4) {
37609
+ function Zi(r4) {
39904
37610
  return b(r4) && "text" in r4 && typeof r4.text == "string";
39905
37611
  }
39906
- var yn = [];
37612
+ var gn = [];
39907
37613
  for (let r4 = 0; r4 < 256; r4++)
39908
- yn.push(r4.toString(16).padStart(2, "0"));
39909
- function gn(r4) {
37614
+ gn.push(r4.toString(16).padStart(2, "0"));
37615
+ function xn(r4) {
39910
37616
  let e = new Uint8Array(r4), t = new Array(e.length);
39911
37617
  for (let n = 0; n < e.length; n++)
39912
- t[n] = yn[e[n]];
37618
+ t[n] = gn[e[n]];
39913
37619
  return t.join("");
39914
37620
  }
39915
- function xn(r4) {
37621
+ function vn(r4) {
39916
37622
  let e = new Uint8Array(r4), t = [];
39917
37623
  for (let n = 0; n < e.length; n++)
39918
37624
  t[n] = String.fromCharCode(e[n]);
@@ -39930,15 +37636,22 @@ function rt(r4) {
39930
37636
  function ar(r4) {
39931
37637
  return r4.endsWith("/") ? r4 : r4 + "/";
39932
37638
  }
39933
- function to(r4) {
37639
+ function io(r4) {
39934
37640
  return r4.startsWith("/") ? r4.slice(1) : r4;
39935
37641
  }
39936
37642
  function B(r4, e) {
39937
- return new URL(to(e), ar(r4.toString())).toString();
37643
+ return new URL(io(e), ar(r4.toString())).toString();
39938
37644
  }
39939
- function En(r4, e) {
37645
+ function bn(r4, e) {
39940
37646
  return B(r4, e).toString().replace("http://", "ws://").replace("https://", "wss://");
39941
37647
  }
37648
+ function Rn(r4) {
37649
+ return typeof r4 == "object" && !Array.isArray(r4) && !(r4 instanceof URLSearchParams) && (r4 = Object.fromEntries(Object.entries(r4).filter((e) => e[1] !== void 0))), new URLSearchParams(r4).toString();
37650
+ }
37651
+ var oo = /^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-_]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-_]*[A-Za-z0-9])$/;
37652
+ function eu(r4) {
37653
+ return oo.test(r4);
37654
+ }
39942
37655
  function nt(r4, e) {
39943
37656
  let t = [];
39944
37657
  if (r4.prefix && e?.prefix !== false && t.push(...r4.prefix), r4.given && t.push(...r4.given), r4.family && t.push(r4.family), r4.suffix && e?.suffix !== false && t.push(...r4.suffix), r4.use && (e?.all || e?.use) && t.push("[" + r4.use + "]"), t.length === 0) {
@@ -39952,9 +37665,9 @@ function Xe(r4) {
39952
37665
  if (!r4)
39953
37666
  return "";
39954
37667
  let e = ye(r4.text);
39955
- return e || (r4.coding ? r4.coding.map((t) => ao(t)).join(", ") : "");
37668
+ return e || (r4.coding ? r4.coding.map((t) => po(t)).join(", ") : "");
39956
37669
  }
39957
- function ao(r4) {
37670
+ function po(r4) {
39958
37671
  return ye(r4?.display) ?? ye(r4?.code) ?? "";
39959
37672
  }
39960
37673
  function ye(r4) {
@@ -39969,17 +37682,17 @@ function lr(r4) {
39969
37682
  }
39970
37683
  function jt(r4) {
39971
37684
  let e = r4.type?.[0]?.code;
39972
- return e === "BackboneElement" || e === "Element" ? po((r4.base?.path ?? r4.path)?.split(".")) : e;
37685
+ return e === "BackboneElement" || e === "Element" ? yo((r4.base?.path ?? r4.path)?.split(".")) : e;
39973
37686
  }
39974
- function po(r4) {
37687
+ function yo(r4) {
39975
37688
  return r4.length === 1 ? r4[0] : r4.map(C).join("");
39976
37689
  }
39977
37690
  function Ze(r4, e, t) {
39978
37691
  let n = Ce(r4, t);
39979
37692
  if (n)
39980
- return yo(n.elements, e);
37693
+ return To(n.elements, e);
39981
37694
  }
39982
- function yo(r4, e) {
37695
+ function To(r4, e) {
39983
37696
  let t = r4[e] ?? r4[e + "[x]"];
39984
37697
  if (t)
39985
37698
  return t;
@@ -39995,7 +37708,7 @@ function yo(r4, e) {
39995
37708
  function _(r4) {
39996
37709
  return !!(r4 && typeof r4 == "object" && "resourceType" in r4);
39997
37710
  }
39998
- function X(r4) {
37711
+ function ee(r4) {
39999
37712
  return !!(r4 && typeof r4 == "object" && "reference" in r4 && typeof r4.reference == "string");
40000
37713
  }
40001
37714
  var V = { types: {} };
@@ -40265,7 +37978,7 @@ var st = class extends Ue {
40265
37978
  return this.operator + this.child.toString();
40266
37979
  }
40267
37980
  };
40268
- var ne = class extends Q {
37981
+ var ie = class extends Q {
40269
37982
  constructor(e, t) {
40270
37983
  super("as", e, t);
40271
37984
  }
@@ -40374,7 +38087,7 @@ var ft = class extends P {
40374
38087
  return er(rr(n, i2));
40375
38088
  }
40376
38089
  };
40377
- var ie = class extends P {
38090
+ var oe = class extends P {
40378
38091
  constructor(e, t) {
40379
38092
  super("is", e, t);
40380
38093
  }
@@ -40437,7 +38150,7 @@ var G = class {
40437
38150
  return `${this.name}(${this.args.map((e) => e.toString()).join(", ")})`;
40438
38151
  }
40439
38152
  };
40440
- var oe = class {
38153
+ var se = class {
40441
38154
  constructor(e, t) {
40442
38155
  this.left = e;
40443
38156
  this.expr = t;
@@ -40458,19 +38171,19 @@ var oe = class {
40458
38171
  };
40459
38172
  var Ie = ["!=", "!~", "<=", ">=", "{}", "->"];
40460
38173
  var h = { FunctionCall: 0, Dot: 1, Indexer: 2, UnaryAdd: 3, UnarySubtract: 3, Multiply: 4, Divide: 4, IntegerDivide: 4, Modulo: 4, Add: 5, Subtract: 5, Ampersand: 5, Is: 6, As: 6, Union: 7, GreaterThan: 8, GreaterThanOrEquals: 8, LessThan: 8, LessThanOrEquals: 8, Equals: 9, Equivalent: 9, NotEquals: 9, NotEquivalent: 9, In: 10, Contains: 10, And: 11, Xor: 12, Or: 12, Implies: 13, Arrow: 100, Semicolon: 200 };
40461
- var vo = { parse(r4) {
38174
+ var bo = { parse(r4) {
40462
38175
  let e = r4.consumeAndParse();
40463
38176
  if (!r4.match(")"))
40464
38177
  throw new Error("Parse error: expected `)` got `" + r4.peek()?.value + "`");
40465
38178
  return e;
40466
38179
  } };
40467
- var To = { parse(r4, e) {
38180
+ var Ro = { parse(r4, e) {
40468
38181
  let t = r4.consumeAndParse();
40469
38182
  if (!r4.match("]"))
40470
38183
  throw new Error("Parse error: expected `]`");
40471
- return new oe(e, t);
38184
+ return new se(e, t);
40472
38185
  }, precedence: h.Indexer };
40473
- var So = { parse(r4, e) {
38186
+ var Po = { parse(r4, e) {
40474
38187
  if (!(e instanceof $))
40475
38188
  throw new Error("Unexpected parentheses");
40476
38189
  let t = [];
@@ -40478,25 +38191,25 @@ var So = { parse(r4, e) {
40478
38191
  t.push(r4.consumeAndParse()), r4.match(",");
40479
38192
  return new G(e.name, t);
40480
38193
  }, precedence: h.FunctionCall };
40481
- function Eo(r4) {
38194
+ function Co(r4) {
40482
38195
  let e = r4.split(" "), t = parseFloat(e[0]), n = e[1];
40483
38196
  return n?.startsWith("'") && n.endsWith("'") ? n = n.substring(1, n.length - 1) : n = "{" + n + "}", { value: t, unit: n };
40484
38197
  }
40485
38198
  function ke() {
40486
- return new Be().registerPrefix("String", { parse: (r4, e) => new M({ type: l.string, value: e.value }) }).registerPrefix("DateTime", { parse: (r4, e) => new M({ type: l.dateTime, value: ge(e.value) }) }).registerPrefix("Quantity", { parse: (r4, e) => new M({ type: l.Quantity, value: Eo(e.value) }) }).registerPrefix("Number", { parse: (r4, e) => new M({ type: e.value.includes(".") ? l.decimal : l.integer, value: parseFloat(e.value) }) }).registerPrefix("true", { parse: () => new M({ type: l.boolean, value: true }) }).registerPrefix("false", { parse: () => new M({ type: l.boolean, value: false }) }).registerPrefix("Symbol", { parse: (r4, e) => new $(e.value) }).registerPrefix("{}", { parse: () => new ot() }).registerPrefix("(", vo).registerInfix("[", To).registerInfix("(", So).prefix("+", h.UnaryAdd, (r4, e) => new st("+", e, (t) => t)).prefix("-", h.UnarySubtract, (r4, e) => new I("-", e, e, (t, n) => -n)).infixLeft(".", h.Dot, (r4, e, t) => new z(r4, t)).infixLeft("/", h.Divide, (r4, e, t) => new I("/", r4, t, (n, i2) => n / i2)).infixLeft("*", h.Multiply, (r4, e, t) => new I("*", r4, t, (n, i2) => n * i2)).infixLeft("+", h.Add, (r4, e, t) => new I("+", r4, t, (n, i2) => n + i2)).infixLeft("-", h.Subtract, (r4, e, t) => new I("-", r4, t, (n, i2) => n - i2)).infixLeft("|", h.Union, (r4, e, t) => new xe(r4, t)).infixLeft("=", h.Equals, (r4, e, t) => new lt(r4, t)).infixLeft("!=", h.NotEquals, (r4, e, t) => new pt(r4, t)).infixLeft("~", h.Equivalent, (r4, e, t) => new dt(r4, t)).infixLeft("!~", h.NotEquivalent, (r4, e, t) => new ft(r4, t)).infixLeft("<", h.LessThan, (r4, e, t) => new I("<", r4, t, (n, i2) => n < i2)).infixLeft("<=", h.LessThanOrEquals, (r4, e, t) => new I("<=", r4, t, (n, i2) => n <= i2)).infixLeft(">", h.GreaterThan, (r4, e, t) => new I(">", r4, t, (n, i2) => n > i2)).infixLeft(">=", h.GreaterThanOrEquals, (r4, e, t) => new I(">=", r4, t, (n, i2) => n >= i2)).infixLeft("&", h.Ampersand, (r4, e, t) => new at(r4, t)).infixLeft("and", h.And, (r4, e, t) => new mt(r4, t)).infixLeft("as", h.As, (r4, e, t) => new ne(r4, t)).infixLeft("contains", h.Contains, (r4, e, t) => new ct(r4, t)).infixLeft("div", h.Divide, (r4, e, t) => new I("div", r4, t, (n, i2) => n / i2 | 0)).infixLeft("in", h.In, (r4, e, t) => new ut(r4, t)).infixLeft("is", h.Is, (r4, e, t) => new ie(r4, t)).infixLeft("mod", h.Modulo, (r4, e, t) => new I("mod", r4, t, (n, i2) => n % i2)).infixLeft("or", h.Or, (r4, e, t) => new ht(r4, t)).infixLeft("xor", h.Xor, (r4, e, t) => new yt(r4, t)).infixLeft("implies", h.Implies, (r4, e, t) => new gt(r4, t));
38199
+ return new Be().registerPrefix("String", { parse: (r4, e) => new M({ type: l.string, value: e.value }) }).registerPrefix("DateTime", { parse: (r4, e) => new M({ type: l.dateTime, value: ge(e.value) }) }).registerPrefix("Quantity", { parse: (r4, e) => new M({ type: l.Quantity, value: Co(e.value) }) }).registerPrefix("Number", { parse: (r4, e) => new M({ type: e.value.includes(".") ? l.decimal : l.integer, value: parseFloat(e.value) }) }).registerPrefix("true", { parse: () => new M({ type: l.boolean, value: true }) }).registerPrefix("false", { parse: () => new M({ type: l.boolean, value: false }) }).registerPrefix("Symbol", { parse: (r4, e) => new $(e.value) }).registerPrefix("{}", { parse: () => new ot() }).registerPrefix("(", bo).registerInfix("[", Ro).registerInfix("(", Po).prefix("+", h.UnaryAdd, (r4, e) => new st("+", e, (t) => t)).prefix("-", h.UnarySubtract, (r4, e) => new I("-", e, e, (t, n) => -n)).infixLeft(".", h.Dot, (r4, e, t) => new z(r4, t)).infixLeft("/", h.Divide, (r4, e, t) => new I("/", r4, t, (n, i2) => n / i2)).infixLeft("*", h.Multiply, (r4, e, t) => new I("*", r4, t, (n, i2) => n * i2)).infixLeft("+", h.Add, (r4, e, t) => new I("+", r4, t, (n, i2) => n + i2)).infixLeft("-", h.Subtract, (r4, e, t) => new I("-", r4, t, (n, i2) => n - i2)).infixLeft("|", h.Union, (r4, e, t) => new xe(r4, t)).infixLeft("=", h.Equals, (r4, e, t) => new lt(r4, t)).infixLeft("!=", h.NotEquals, (r4, e, t) => new pt(r4, t)).infixLeft("~", h.Equivalent, (r4, e, t) => new dt(r4, t)).infixLeft("!~", h.NotEquivalent, (r4, e, t) => new ft(r4, t)).infixLeft("<", h.LessThan, (r4, e, t) => new I("<", r4, t, (n, i2) => n < i2)).infixLeft("<=", h.LessThanOrEquals, (r4, e, t) => new I("<=", r4, t, (n, i2) => n <= i2)).infixLeft(">", h.GreaterThan, (r4, e, t) => new I(">", r4, t, (n, i2) => n > i2)).infixLeft(">=", h.GreaterThanOrEquals, (r4, e, t) => new I(">=", r4, t, (n, i2) => n >= i2)).infixLeft("&", h.Ampersand, (r4, e, t) => new at(r4, t)).infixLeft("and", h.And, (r4, e, t) => new mt(r4, t)).infixLeft("as", h.As, (r4, e, t) => new ie(r4, t)).infixLeft("contains", h.Contains, (r4, e, t) => new ct(r4, t)).infixLeft("div", h.Divide, (r4, e, t) => new I("div", r4, t, (n, i2) => n / i2 | 0)).infixLeft("in", h.In, (r4, e, t) => new ut(r4, t)).infixLeft("is", h.Is, (r4, e, t) => new oe(r4, t)).infixLeft("mod", h.Modulo, (r4, e, t) => new I("mod", r4, t, (n, i2) => n % i2)).infixLeft("or", h.Or, (r4, e, t) => new ht(r4, t)).infixLeft("xor", h.Xor, (r4, e, t) => new yt(r4, t)).infixLeft("implies", h.Implies, (r4, e, t) => new gt(r4, t));
40487
38200
  }
40488
- var bo = ke();
40489
- var wn = ((p2) => (p2.BOOLEAN = "BOOLEAN", p2.NUMBER = "NUMBER", p2.QUANTITY = "QUANTITY", p2.TEXT = "TEXT", p2.REFERENCE = "REFERENCE", p2.CANONICAL = "CANONICAL", p2.DATE = "DATE", p2.DATETIME = "DATETIME", p2.PERIOD = "PERIOD", p2.UUID = "UUID", p2))(wn || {});
40490
- var Io = ((T) => (T.EQUALS = "eq", T.NOT_EQUALS = "ne", T.GREATER_THAN = "gt", T.LESS_THAN = "lt", T.GREATER_THAN_OR_EQUALS = "ge", T.LESS_THAN_OR_EQUALS = "le", T.STARTS_AFTER = "sa", T.ENDS_BEFORE = "eb", T.APPROXIMATELY = "ap", T.CONTAINS = "contains", T.EXACT = "exact", T.TEXT = "text", T.NOT = "not", T.ABOVE = "above", T.BELOW = "below", T.IN = "in", T.NOT_IN = "not-in", T.OF_TYPE = "of-type", T.MISSING = "missing", T.IDENTIFIER = "identifier", T.ITERATE = "iterate", T))(Io || {});
40491
- var Zo = ((E2) => (E2.READ = "read", E2.VREAD = "vread", E2.UPDATE = "update", E2.PATCH = "patch", E2.DELETE = "delete", E2.HISTORY = "history", E2.HISTORY_INSTANCE = "history-instance", E2.HISTORY_TYPE = "history-type", E2.HISTORY_SYSTEM = "history-system", E2.CREATE = "create", E2.SEARCH = "search", E2.SEARCH_TYPE = "search-type", E2.SEARCH_SYSTEM = "search-system", E2.SEARCH_COMPARTMENT = "search-compartment", E2.CAPABILITIES = "capabilities", E2.TRANSACTION = "transaction", E2.BATCH = "batch", E2.OPERATION = "operation", E2))(Zo || {});
40492
- function _n(r4) {
38201
+ var wo = ke();
38202
+ var On = ((p2) => (p2.BOOLEAN = "BOOLEAN", p2.NUMBER = "NUMBER", p2.QUANTITY = "QUANTITY", p2.TEXT = "TEXT", p2.REFERENCE = "REFERENCE", p2.CANONICAL = "CANONICAL", p2.DATE = "DATE", p2.DATETIME = "DATETIME", p2.PERIOD = "PERIOD", p2.UUID = "UUID", p2))(On || {});
38203
+ var Mo = ((T) => (T.EQUALS = "eq", T.NOT_EQUALS = "ne", T.GREATER_THAN = "gt", T.LESS_THAN = "lt", T.GREATER_THAN_OR_EQUALS = "ge", T.LESS_THAN_OR_EQUALS = "le", T.STARTS_AFTER = "sa", T.ENDS_BEFORE = "eb", T.APPROXIMATELY = "ap", T.CONTAINS = "contains", T.EXACT = "exact", T.TEXT = "text", T.NOT = "not", T.ABOVE = "above", T.BELOW = "below", T.IN = "in", T.NOT_IN = "not-in", T.OF_TYPE = "of-type", T.MISSING = "missing", T.IDENTIFIER = "identifier", T.ITERATE = "iterate", T))(Mo || {});
38204
+ var rs = ((E2) => (E2.READ = "read", E2.VREAD = "vread", E2.UPDATE = "update", E2.PATCH = "patch", E2.DELETE = "delete", E2.HISTORY = "history", E2.HISTORY_INSTANCE = "history-instance", E2.HISTORY_TYPE = "history-type", E2.HISTORY_SYSTEM = "history-system", E2.CREATE = "create", E2.SEARCH = "search", E2.SEARCH_TYPE = "search-type", E2.SEARCH_SYSTEM = "search-system", E2.SEARCH_COMPARTMENT = "search-compartment", E2.CAPABILITIES = "capabilities", E2.TRANSACTION = "transaction", E2.BATCH = "batch", E2.OPERATION = "operation", E2))(rs || {});
38205
+ function Un(r4) {
40493
38206
  if (typeof window < "u")
40494
38207
  return window.atob(r4);
40495
38208
  if (typeof Buffer < "u")
40496
38209
  return Buffer.from(r4, "base64").toString("binary");
40497
38210
  throw new Error("Unable to decode base64");
40498
38211
  }
40499
- function Ln(r4) {
38212
+ function Bn(r4) {
40500
38213
  if (typeof window < "u")
40501
38214
  return window.btoa(r4);
40502
38215
  if (typeof Buffer < "u")
@@ -40505,12 +38218,12 @@ function Ln(r4) {
40505
38218
  }
40506
38219
  function yr() {
40507
38220
  let r4 = new Uint32Array(28);
40508
- return crypto.getRandomValues(r4), gn(r4.buffer);
38221
+ return crypto.getRandomValues(r4), xn(r4.buffer);
40509
38222
  }
40510
- async function Un(r4) {
38223
+ async function qn(r4) {
40511
38224
  return crypto.subtle.digest("SHA-256", new TextEncoder().encode(r4));
40512
38225
  }
40513
- function se() {
38226
+ function ae() {
40514
38227
  return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (r4) => {
40515
38228
  let e = Math.random() * 16 | 0;
40516
38229
  return (r4 === "x" ? e : e & 3 | 8).toString(16);
@@ -40569,7 +38282,7 @@ var De = class {
40569
38282
  this.listeners = {};
40570
38283
  }
40571
38284
  };
40572
- var ae = class {
38285
+ var ce = class {
40573
38286
  constructor() {
40574
38287
  this.emitter = new De();
40575
38288
  }
@@ -40587,27 +38300,27 @@ var ae = class {
40587
38300
  }
40588
38301
  };
40589
38302
  var gr = { "Patient-open": "Patient-open", "Patient-close": "Patient-close", "ImagingStudy-open": "ImagingStudy-open", "ImagingStudy-close": "ImagingStudy-close", "Encounter-open": "Encounter-open", "Encounter-close": "Encounter-close", "DiagnosticReport-open": "DiagnosticReport-open", "DiagnosticReport-close": "DiagnosticReport-close", "DiagnosticReport-select": "DiagnosticReport-select", "DiagnosticReport-update": "DiagnosticReport-update", syncerror: "syncerror" };
40590
- var as = ["Patient", "Encounter", "ImagingStudy", "DiagnosticReport", "OperationOutcome", "Bundle"];
38303
+ var ps = ["Patient", "Encounter", "ImagingStudy", "DiagnosticReport", "OperationOutcome", "Bundle"];
40591
38304
  var xr = ["DiagnosticReport-update"];
40592
- function jn(r4) {
38305
+ function Wn(r4) {
40593
38306
  return xr.includes(r4);
40594
38307
  }
40595
- function $n(r4) {
38308
+ function Hn(r4) {
40596
38309
  if (xr.includes(r4))
40597
38310
  throw new d(m(`'context.version' is required for '${r4}'.`));
40598
38311
  }
40599
- var cs = { "Patient-open": { patient: { resourceType: "Patient" }, encounter: { resourceType: "Encounter", optional: true } }, "Patient-close": { patient: { resourceType: "Patient" }, encounter: { resourceType: "Encounter", optional: true } }, "ImagingStudy-open": { study: { resourceType: "ImagingStudy" }, encounter: { resourceType: "Encounter", optional: true }, patient: { resourceType: "Patient", optional: true } }, "ImagingStudy-close": { study: { resourceType: "ImagingStudy" }, encounter: { resourceType: "Encounter", optional: true }, patient: { resourceType: "Patient", optional: true } }, "Encounter-open": { encounter: { resourceType: "Encounter" }, patient: { resourceType: "Patient" } }, "Encounter-close": { encounter: { resourceType: "Encounter" }, patient: { resourceType: "Patient" } }, "DiagnosticReport-open": { report: { resourceType: "DiagnosticReport" }, encounter: { resourceType: "Encounter", optional: true }, study: { resourceType: "ImagingStudy", optional: true, manyAllowed: true }, patient: { resourceType: "Patient" } }, "DiagnosticReport-close": { report: { resourceType: "DiagnosticReport" }, encounter: { resourceType: "Encounter", optional: true }, study: { resourceType: "ImagingStudy", optional: true, manyAllowed: true }, patient: { resourceType: "Patient" } }, "DiagnosticReport-select": { report: { resourceType: "DiagnosticReport" }, select: { resourceType: "*", isArray: true } }, "DiagnosticReport-update": { report: { resourceType: "DiagnosticReport" }, patient: { resourceType: "Patient", optional: true }, study: { resourceType: "ImagingStudy", optional: true }, updates: { resourceType: "Bundle" } }, syncerror: { operationoutcome: { resourceType: "OperationOutcome" } } };
40600
- function us(r4) {
40601
- return as.includes(r4);
38312
+ var ds = { "Patient-open": { patient: { resourceType: "Patient" }, encounter: { resourceType: "Encounter", optional: true } }, "Patient-close": { patient: { resourceType: "Patient" }, encounter: { resourceType: "Encounter", optional: true } }, "ImagingStudy-open": { study: { resourceType: "ImagingStudy" }, encounter: { resourceType: "Encounter", optional: true }, patient: { resourceType: "Patient", optional: true } }, "ImagingStudy-close": { study: { resourceType: "ImagingStudy" }, encounter: { resourceType: "Encounter", optional: true }, patient: { resourceType: "Patient", optional: true } }, "Encounter-open": { encounter: { resourceType: "Encounter" }, patient: { resourceType: "Patient" } }, "Encounter-close": { encounter: { resourceType: "Encounter" }, patient: { resourceType: "Patient" } }, "DiagnosticReport-open": { report: { resourceType: "DiagnosticReport" }, encounter: { resourceType: "Encounter", optional: true }, study: { resourceType: "ImagingStudy", optional: true, manyAllowed: true }, patient: { resourceType: "Patient" } }, "DiagnosticReport-close": { report: { resourceType: "DiagnosticReport" }, encounter: { resourceType: "Encounter", optional: true }, study: { resourceType: "ImagingStudy", optional: true, manyAllowed: true }, patient: { resourceType: "Patient" } }, "DiagnosticReport-select": { report: { resourceType: "DiagnosticReport" }, select: { resourceType: "*", isArray: true } }, "DiagnosticReport-update": { report: { resourceType: "DiagnosticReport" }, patient: { resourceType: "Patient", optional: true }, study: { resourceType: "ImagingStudy", optional: true }, updates: { resourceType: "Bundle" } }, syncerror: { operationoutcome: { resourceType: "OperationOutcome" } } };
38313
+ function fs(r4) {
38314
+ return ps.includes(r4);
40602
38315
  }
40603
- function Wn(r4) {
38316
+ function Gn(r4) {
40604
38317
  return !!r4.endpoint;
40605
38318
  }
40606
38319
  function vr(r4) {
40607
38320
  if (!St(r4))
40608
38321
  throw new d(m("subscriptionRequest must be an object conforming to SubscriptionRequest type."));
40609
38322
  let { channelType: e, mode: t, topic: n, events: i2 } = r4, o = { "hub.channel.type": e, "hub.mode": t, "hub.topic": n, "hub.events": i2.join(",") };
40610
- return Wn(r4) && (o.endpoint = r4.endpoint), new URLSearchParams(o).toString();
38323
+ return Gn(r4) && (o.endpoint = r4.endpoint), new URLSearchParams(o).toString();
40611
38324
  }
40612
38325
  function St(r4) {
40613
38326
  if (typeof r4 != "object")
@@ -40618,9 +38331,9 @@ function St(r4) {
40618
38331
  for (let o of i2)
40619
38332
  if (!gr[o])
40620
38333
  return false;
40621
- return !(Wn(r4) && !(typeof r4.endpoint == "string" && r4.endpoint.startsWith("ws")));
38334
+ return !(Gn(r4) && !(typeof r4.endpoint == "string" && r4.endpoint.startsWith("ws")));
40622
38335
  }
40623
- function qn(r4, e, t, n) {
38336
+ function $n(r4, e, t, n) {
40624
38337
  if (typeof e != "object")
40625
38338
  throw new d(m(`context[${t}] is invalid. Context must contain a single valid FHIR resource! Resource is not an object.`));
40626
38339
  if (!(e.id && typeof e.id == "string"))
@@ -40629,30 +38342,30 @@ function qn(r4, e, t, n) {
40629
38342
  throw new d(m(`context[${t}] is invalid. Resource must contain a resource type. No resource type found.`));
40630
38343
  let i2 = n.resourceType;
40631
38344
  if (i2 !== "*") {
40632
- if (!us(e.resourceType))
38345
+ if (!fs(e.resourceType))
40633
38346
  throw new d(m(`context[${t}] is invalid. Resource must contain a valid FHIRcast resource type. Resource type is not a known resource type.`));
40634
38347
  if (i2 && e.resourceType !== i2)
40635
38348
  throw new d(m(`context[${t}] is invalid. context[${t}] for the '${r4}' event should contain resource of type ${i2}.`));
40636
38349
  }
40637
38350
  }
40638
- function ls(r4, e, t, n, i2) {
38351
+ function ms(r4, e, t, n, i2) {
40639
38352
  if (i2.set(e.key, (i2.get(e.key) ?? 0) + 1), !n.isArray)
40640
- qn(r4, e.resource, t, n);
38353
+ $n(r4, e.resource, t, n);
40641
38354
  else {
40642
38355
  let { resources: o } = e;
40643
38356
  if (!o)
40644
38357
  throw new d(m(`context[${t}] is invalid. context[${t}] for the '${r4}' with key '${String(e.key)}' should contain an array of resources on the key 'resources'.`));
40645
38358
  for (let s of o)
40646
- qn(r4, s, t, n);
38359
+ $n(r4, s, t, n);
40647
38360
  }
40648
38361
  }
40649
- function ps(r4, e) {
40650
- let t = /* @__PURE__ */ new Map(), n = cs[r4];
38362
+ function hs(r4, e) {
38363
+ let t = /* @__PURE__ */ new Map(), n = ds[r4];
40651
38364
  for (let i2 = 0; i2 < e.length; i2++) {
40652
38365
  let o = e[i2].key;
40653
38366
  if (!n[o])
40654
38367
  throw new d(m(`Key '${o}' not found for event '${r4}'. Make sure to add only valid keys.`));
40655
- ls(r4, e[i2], i2, n[o], t);
38368
+ ms(r4, e[i2], i2, n[o], t);
40656
38369
  }
40657
38370
  for (let [i2, o] of Object.entries(n)) {
40658
38371
  if (!(o.optional || t.has(i2)))
@@ -40671,9 +38384,9 @@ function Tr(r4, e, t, n) {
40671
38384
  if (xr.includes(e) && !n)
40672
38385
  throw new d(m(`The '${e}' event must contain a 'context.versionId'.`));
40673
38386
  let i2 = Array.isArray(t) ? t : [t];
40674
- return ps(e, i2), { timestamp: (/* @__PURE__ */ new Date()).toISOString(), id: se(), event: { "hub.topic": r4, "hub.event": e, context: i2, ...n ? { "context.versionId": n } : {} } };
38387
+ return hs(e, i2), { timestamp: (/* @__PURE__ */ new Date()).toISOString(), id: ae(), event: { "hub.topic": r4, "hub.event": e, context: i2, ...n ? { "context.versionId": n } : {} } };
40675
38388
  }
40676
- var Tt = class extends ae {
38389
+ var Tt = class extends ce {
40677
38390
  constructor(e) {
40678
38391
  if (super(), this.subRequest = e, !e.endpoint)
40679
38392
  throw new d(m("Subscription request should contain an endpoint."));
@@ -40696,28 +38409,28 @@ var Tt = class extends ae {
40696
38409
  this.websocket.close();
40697
38410
  }
40698
38411
  };
40699
- function ds(r4) {
40700
- let e = r4.replace(/-/g, "+").replace(/_/g, "/"), t = _n(e), n = Array.from(t).reduce((o, s) => {
38412
+ function ys(r4) {
38413
+ let e = r4.replace(/-/g, "+").replace(/_/g, "/"), t = Un(e), n = Array.from(t).reduce((o, s) => {
40701
38414
  let a = ("00" + s.charCodeAt(0).toString(16)).slice(-2);
40702
38415
  return `${o}%${a}`;
40703
38416
  }, ""), i2 = decodeURIComponent(n);
40704
38417
  return JSON.parse(i2);
40705
38418
  }
40706
- function Hn(r4) {
38419
+ function Qn(r4) {
40707
38420
  return r4.split(".").length === 3;
40708
38421
  }
40709
38422
  function Et(r4) {
40710
38423
  let [e, t, n] = r4.split(".");
40711
- return ds(t);
38424
+ return ys(t);
40712
38425
  }
40713
- function Gn(r4) {
38426
+ function Kn(r4) {
40714
38427
  try {
40715
38428
  return typeof Et(r4).login_id == "string";
40716
38429
  } catch {
40717
38430
  return false;
40718
38431
  }
40719
38432
  }
40720
- function Qn(r4) {
38433
+ function zn(r4) {
40721
38434
  try {
40722
38435
  let t = Et(r4).exp;
40723
38436
  return typeof t == "number" ? t * 1e3 : void 0;
@@ -40739,10 +38452,10 @@ var bt = class {
40739
38452
  await this.medplum.delete(`keyvalue/v1/${e}`);
40740
38453
  }
40741
38454
  };
40742
- var fs;
38455
+ var gs;
40743
38456
  var k = class {
40744
38457
  constructor(e) {
40745
- this[fs] = "ReadablePromise";
38458
+ this[gs] = "ReadablePromise";
40746
38459
  this.status = "pending";
40747
38460
  this.suspender = e.then((t) => (this.status = "success", this.response = t, t), (t) => {
40748
38461
  throw this.status = "error", this.error = t, t;
@@ -40774,7 +38487,7 @@ var k = class {
40774
38487
  return this.suspender.finally(e);
40775
38488
  }
40776
38489
  };
40777
- fs = Symbol.toStringTag;
38490
+ gs = Symbol.toStringTag;
40778
38491
  var Me = class {
40779
38492
  constructor(e) {
40780
38493
  this.storage = e ?? (typeof localStorage < "u" ? localStorage : new Sr());
@@ -40793,7 +38506,7 @@ var Me = class {
40793
38506
  return t ? JSON.parse(t) : void 0;
40794
38507
  }
40795
38508
  setObject(e, t) {
40796
- this.setString(e, t ? mn(t) : void 0);
38509
+ this.setString(e, t ? hn(t) : void 0);
40797
38510
  }
40798
38511
  };
40799
38512
  var Sr = class {
@@ -40819,7 +38532,7 @@ var Sr = class {
40819
38532
  return Array.from(this.data.keys())[e];
40820
38533
  }
40821
38534
  };
40822
- var Er = class extends ae {
38535
+ var Er = class extends ce {
40823
38536
  constructor(t) {
40824
38537
  super();
40825
38538
  this.bufferedAmount = -1 / 0;
@@ -40859,7 +38572,7 @@ var Er = class extends ae {
40859
38572
  }
40860
38573
  }
40861
38574
  };
40862
- var Ne = class extends ae {
38575
+ var Ne = class extends ce {
40863
38576
  constructor(...e) {
40864
38577
  super(), this.criteria = new Set(e);
40865
38578
  }
@@ -40915,7 +38628,7 @@ var Rt = class {
40915
38628
  o.dispatchEvent(i2);
40916
38629
  }
40917
38630
  }), e.addEventListener("error", () => {
40918
- let t = { type: "error", payload: new d(Lr(new Error("WebSocket error"))) };
38631
+ let t = { type: "error", payload: new d(Ur(new Error("WebSocket error"))) };
40919
38632
  this.masterSubEmitter?.dispatchEvent(t);
40920
38633
  for (let { emitter: n } of this.criteriaEntries.values())
40921
38634
  n.dispatchEvent(t);
@@ -40938,7 +38651,7 @@ var Rt = class {
40938
38651
  }
40939
38652
  async getTokenForCriteria(e) {
40940
38653
  let t = e?.subscriptionId;
40941
- t || (t = (await this.medplum.createResource({ resourceType: "Subscription", status: "active", reason: `WebSocket subscription for ${ee(this.medplum.getProfile())}`, criteria: e.criteria, channel: { type: "websocket" } })).id);
38654
+ t || (t = (await this.medplum.createResource({ resourceType: "Subscription", status: "active", reason: `WebSocket subscription for ${te(this.medplum.getProfile())}`, criteria: e.criteria, channel: { type: "websocket" } })).id);
40942
38655
  let { parameter: n } = await this.medplum.get(`fhir/R4/Subscription/${t}/$get-ws-binding-token`), i2 = n?.find((s) => s.name === "token")?.valueString, o = n?.find((s) => s.name === "websocket-url")?.valueUrl;
40943
38656
  if (!i2)
40944
38657
  throw new d(m("Failed to get token"));
@@ -40979,24 +38692,25 @@ var Rt = class {
40979
38692
  return this.masterSubEmitter || (this.masterSubEmitter = new Ne(...Array.from(this.criteriaEntries.keys()))), this.masterSubEmitter;
40980
38693
  }
40981
38694
  };
40982
- var ms = N.FHIR_JSON + ", */*; q=0.1";
40983
- var hs = "https://api.medplum.com/";
40984
- var ys = 1e3;
40985
- var gs = 6e4;
40986
- var xs = 0;
40987
- var vs = "Binary/";
40988
- var zn = { resourceType: "Device", id: "system", deviceName: [{ type: "model-name", name: "System" }] };
40989
- var Ts = ((o) => (o.ClientCredentials = "client_credentials", o.AuthorizationCode = "authorization_code", o.RefreshToken = "refresh_token", o.JwtBearer = "urn:ietf:params:oauth:grant-type:jwt-bearer", o.TokenExchange = "urn:ietf:params:oauth:grant-type:token-exchange", o))(Ts || {});
40990
- var Ss = ((o) => (o.AccessToken = "urn:ietf:params:oauth:token-type:access_token", o.RefreshToken = "urn:ietf:params:oauth:token-type:refresh_token", o.IdToken = "urn:ietf:params:oauth:token-type:id_token", o.Saml1Token = "urn:ietf:params:oauth:token-type:saml1", o.Saml2Token = "urn:ietf:params:oauth:token-type:saml2", o))(Ss || {});
40991
- var Es = ((o) => (o.ClientSecretBasic = "client_secret_basic", o.ClientSecretPost = "client_secret_post", o.ClientSecretJwt = "client_secret_jwt", o.PrivateKeyJwt = "private_key_jwt", o.None = "none", o))(Es || {});
40992
- var bs = ((e) => (e.JwtBearer = "urn:ietf:params:oauth:client-assertion-type:jwt-bearer", e))(bs || {});
38695
+ var Op = "3.1.4-17ee35b26";
38696
+ var xs = N.FHIR_JSON + ", */*; q=0.1";
38697
+ var vs = "https://api.medplum.com/";
38698
+ var Ts = 1e3;
38699
+ var Ss = 6e4;
38700
+ var Es = 0;
38701
+ var bs = "Binary/";
38702
+ var Yn = { resourceType: "Device", id: "system", deviceName: [{ type: "model-name", name: "System" }] };
38703
+ var Rs = ((o) => (o.ClientCredentials = "client_credentials", o.AuthorizationCode = "authorization_code", o.RefreshToken = "refresh_token", o.JwtBearer = "urn:ietf:params:oauth:grant-type:jwt-bearer", o.TokenExchange = "urn:ietf:params:oauth:grant-type:token-exchange", o))(Rs || {});
38704
+ var Ps = ((o) => (o.AccessToken = "urn:ietf:params:oauth:token-type:access_token", o.RefreshToken = "urn:ietf:params:oauth:token-type:refresh_token", o.IdToken = "urn:ietf:params:oauth:token-type:id_token", o.Saml1Token = "urn:ietf:params:oauth:token-type:saml1", o.Saml2Token = "urn:ietf:params:oauth:token-type:saml2", o))(Ps || {});
38705
+ var Cs = ((o) => (o.ClientSecretBasic = "client_secret_basic", o.ClientSecretPost = "client_secret_post", o.ClientSecretJwt = "client_secret_jwt", o.PrivateKeyJwt = "private_key_jwt", o.None = "none", o))(Cs || {});
38706
+ var ws = ((e) => (e.JwtBearer = "urn:ietf:params:oauth:client-assertion-type:jwt-bearer", e))(ws || {});
40993
38707
  var Pt = class extends De {
40994
38708
  constructor(t) {
40995
38709
  super();
40996
38710
  this.initComplete = true;
40997
38711
  if (t?.baseUrl && !t.baseUrl.startsWith("http"))
40998
38712
  throw new Error("Base URL must start with http or https");
40999
- this.options = t ?? {}, this.fetch = t?.fetch ?? Rs(), this.storage = t?.storage ?? new Me(), this.createPdfImpl = t?.createPdf, this.baseUrl = ar(t?.baseUrl ?? hs), this.fhirBaseUrl = B(this.baseUrl, t?.fhirUrlPath ?? "fhir/R4"), this.authorizeUrl = B(this.baseUrl, t?.authorizeUrl ?? "oauth2/authorize"), this.tokenUrl = B(this.baseUrl, t?.tokenUrl ?? "oauth2/token"), this.logoutUrl = B(this.baseUrl, t?.logoutUrl ?? "oauth2/logout"), this.clientId = t?.clientId ?? "", this.clientSecret = t?.clientSecret ?? "", this.onUnauthenticated = t?.onUnauthenticated, this.cacheTime = t?.cacheTime ?? (typeof window > "u" ? xs : gs), this.cacheTime > 0 ? this.requestCache = new vt(t?.resourceCacheSize ?? ys) : this.requestCache = void 0, t?.autoBatchTime ? (this.autoBatchTime = t.autoBatchTime, this.autoBatchQueue = []) : (this.autoBatchTime = 0, this.autoBatchQueue = void 0), t?.accessToken && this.setAccessToken(t.accessToken), this.storage.getInitPromise === void 0 ? (t?.accessToken || this.attemptResumeActiveLogin().catch(console.error), this.initPromise = Promise.resolve()) : (this.initComplete = false, this.initPromise = this.storage.getInitPromise(), this.initPromise.then(() => {
38713
+ this.options = t ?? {}, this.fetch = t?.fetch ?? As(), this.storage = t?.storage ?? new Me(), this.createPdfImpl = t?.createPdf, this.baseUrl = ar(t?.baseUrl ?? vs), this.fhirBaseUrl = B(this.baseUrl, t?.fhirUrlPath ?? "fhir/R4"), this.authorizeUrl = B(this.baseUrl, t?.authorizeUrl ?? "oauth2/authorize"), this.tokenUrl = B(this.baseUrl, t?.tokenUrl ?? "oauth2/token"), this.logoutUrl = B(this.baseUrl, t?.logoutUrl ?? "oauth2/logout"), this.clientId = t?.clientId ?? "", this.clientSecret = t?.clientSecret ?? "", this.onUnauthenticated = t?.onUnauthenticated, this.cacheTime = t?.cacheTime ?? (typeof window > "u" ? Es : Ss), this.cacheTime > 0 ? this.requestCache = new vt(t?.resourceCacheSize ?? Ts) : this.requestCache = void 0, t?.autoBatchTime ? (this.autoBatchTime = t.autoBatchTime, this.autoBatchQueue = []) : (this.autoBatchTime = 0, this.autoBatchQueue = void 0), t?.accessToken && this.setAccessToken(t.accessToken), this.storage.getInitPromise === void 0 ? (t?.accessToken || this.attemptResumeActiveLogin().catch(console.error), this.initPromise = Promise.resolve()) : (this.initComplete = false, this.initPromise = this.storage.getInitPromise(), this.initPromise.then(() => {
41000
38714
  t?.accessToken || this.attemptResumeActiveLogin().catch(console.error), this.initComplete = true;
41001
38715
  }).catch(console.error)), this.setupStorageListener();
41002
38716
  }
@@ -41023,7 +38737,7 @@ var Pt = class extends De {
41023
38737
  return this.logoutUrl;
41024
38738
  }
41025
38739
  clear() {
41026
- this.storage.clear(), sessionStorage.clear(), this.clearActiveLogin();
38740
+ this.storage.clear(), typeof window < "u" && sessionStorage.clear(), this.clearActiveLogin();
41027
38741
  }
41028
38742
  clearActiveLogin() {
41029
38743
  this.storage.setString("activeLogin", void 0), this.requestCache?.clear(), this.accessToken = void 0, this.refreshToken = void 0, this.refreshPromise = void 0, this.accessTokenExpires = void 0, this.sessionDetails = void 0, this.medplumServer = void 0, this.dispatchEvent({ type: "change" });
@@ -41124,7 +38838,7 @@ var Pt = class extends De {
41124
38838
  }
41125
38839
  fhirSearchUrl(t, n) {
41126
38840
  let i2 = this.fhirUrl(t);
41127
- return n && (i2.search = new URLSearchParams(n).toString()), i2;
38841
+ return n && (i2.search = Rn(n)), i2;
41128
38842
  }
41129
38843
  search(t, n, i2) {
41130
38844
  let o = this.fhirSearchUrl(t, n), s = "search-" + o.toString(), a = this.getCacheEntry(s, i2);
@@ -41180,7 +38894,7 @@ var Pt = class extends De {
41180
38894
  if (!n)
41181
38895
  return;
41182
38896
  if (n === "system")
41183
- return zn;
38897
+ return Yn;
41184
38898
  let [i2, o] = n.split("/");
41185
38899
  if (!(!i2 || !o))
41186
38900
  return this.getCached(i2, o);
@@ -41193,12 +38907,12 @@ var Pt = class extends De {
41193
38907
  if (!i2)
41194
38908
  return new k(Promise.reject(new Error("Missing reference")));
41195
38909
  if (i2 === "system")
41196
- return new k(Promise.resolve(zn));
38910
+ return new k(Promise.resolve(Yn));
41197
38911
  let [o, s] = i2.split("/");
41198
38912
  return !o || !s ? new k(Promise.reject(new Error("Invalid reference"))) : this.readResource(o, s, n);
41199
38913
  }
41200
38914
  requestSchema(t) {
41201
- if (zr(t))
38915
+ if (Jr(t))
41202
38916
  return Promise.resolve();
41203
38917
  let n = t + "-requestSchema", i2 = this.getCacheEntry(n, void 0);
41204
38918
  if (i2)
@@ -41251,7 +38965,7 @@ var Pt = class extends De {
41251
38965
  return this.setCacheEntry(n, o), o;
41252
38966
  }
41253
38967
  requestProfileSchema(t, n) {
41254
- if (!n?.expandProfile && Yr(t))
38968
+ if (!n?.expandProfile && Zr(t))
41255
38969
  return Promise.resolve([t]);
41256
38970
  let i2 = t + "-requestSchema" + (n?.expandProfile ? "-nested" : ""), o = this.getCacheEntry(i2, void 0);
41257
38971
  if (o)
@@ -41286,13 +39000,17 @@ var Pt = class extends De {
41286
39000
  async createResourceIfNoneExist(t, n, i2) {
41287
39001
  return await this.searchOne(t.resourceType, n, i2) ?? this.createResource(t, i2);
41288
39002
  }
39003
+ async upsertResource(t, n, i2) {
39004
+ let o = this.fhirSearchUrl(t.resourceType, n), s = await this.put(o, t, void 0, i2);
39005
+ return s || (s = t), this.cacheResource(s), this.invalidateUrl(this.fhirUrl(t.resourceType, t.id, "_history")), this.invalidateSearches(t.resourceType), s;
39006
+ }
41289
39007
  async createAttachment(t, n, i2, o, s) {
41290
- let a = Zn(t, n, i2, o), c2 = s ?? (typeof n == "object" ? n : {}), u2 = await this.createBinary(a, c2);
39008
+ let a = ei(t, n, i2, o), c2 = s ?? (typeof n == "object" ? n : {}), u2 = await this.createBinary(a, c2);
41291
39009
  return { contentType: a.contentType, url: u2.url, title: a.filename };
41292
39010
  }
41293
39011
  createBinary(t, n, i2, o, s) {
41294
- let a = Zn(t, n, i2, o), c2 = s ?? (typeof n == "object" ? n : {}), { data: u2, contentType: p2, filename: y, securityContext: g2, onProgress: ue } = a, Re = this.fhirUrl("Binary");
41295
- return y && Re.searchParams.set("_filename", y), g2?.reference && this.setRequestHeader(c2, "X-Security-Context", g2.reference), ue ? this.uploadwithProgress(Re, u2, p2, ue, c2) : this.post(Re, u2, p2, c2);
39012
+ let a = ei(t, n, i2, o), c2 = s ?? (typeof n == "object" ? n : {}), { data: u2, contentType: p2, filename: y, securityContext: g2, onProgress: le } = a, Re = this.fhirUrl("Binary");
39013
+ return y && Re.searchParams.set("_filename", y), g2?.reference && this.setRequestHeader(c2, "X-Security-Context", g2.reference), le ? this.uploadwithProgress(Re, u2, p2, le, c2) : this.post(Re, u2, p2, c2);
41296
39014
  }
41297
39015
  uploadwithProgress(t, n, i2, o, s) {
41298
39016
  return new Promise((a, c2) => {
@@ -41305,8 +39023,8 @@ var Pt = class extends De {
41305
39023
  u2.status >= 200 && u2.status < 300 ? y(u2.response) : y(new d($e(u2.response || u2.statusText)));
41306
39024
  }, u2.open("POST", t), u2.withCredentials = true, u2.setRequestHeader("Authorization", "Bearer " + this.accessToken), u2.setRequestHeader("Cache-Control", "no-cache, no-store, max-age=0"), u2.setRequestHeader("Content-Type", i2), u2.setRequestHeader("X-Medplum", "extended"), s?.headers) {
41307
39025
  let g2 = s.headers;
41308
- for (let [ue, Re] of Object.entries(g2))
41309
- u2.setRequestHeader(ue, Re);
39026
+ for (let [le, Re] of Object.entries(g2))
39027
+ u2.setRequestHeader(le, Re);
41310
39028
  }
41311
39029
  u2.send(n);
41312
39030
  });
@@ -41314,8 +39032,8 @@ var Pt = class extends De {
41314
39032
  async createPdf(t, n, i2, o) {
41315
39033
  if (!this.createPdfImpl)
41316
39034
  throw new Error("PDF creation not enabled");
41317
- let s = ws(t, n, i2, o), a = typeof n == "object" ? n : {}, { docDefinition: c2, tableLayouts: u2, fonts: p2, ...y } = s, g2 = await this.createPdfImpl(c2, u2, p2), ue = { ...y, data: g2, contentType: "application/pdf" };
41318
- return this.createBinary(ue, a);
39035
+ let s = ks(t, n, i2, o), a = typeof n == "object" ? n : {}, { docDefinition: c2, tableLayouts: u2, fonts: p2, ...y } = s, g2 = await this.createPdfImpl(c2, u2, p2), le = { ...y, data: g2, contentType: "application/pdf" };
39036
+ return this.createBinary(le, a);
41319
39037
  }
41320
39038
  createComment(t, n, i2) {
41321
39039
  let o = this.getProfile(), s, a;
@@ -41362,19 +39080,19 @@ var Pt = class extends De {
41362
39080
  return this.get(`${this.fhirUrl(t, n)}/$graph?graph=${i2}`, o);
41363
39081
  }
41364
39082
  pushToAgent(t, n, i2, o, s, a) {
41365
- return this.post(this.fhirUrl("Agent", et(t), "$push"), { destination: typeof n == "string" ? n : ee(n), body: i2, contentType: o, waitForResponse: s }, N.FHIR_JSON, a);
39083
+ return this.post(this.fhirUrl("Agent", et(t), "$push"), { destination: typeof n == "string" ? n : te(n), body: i2, contentType: o, waitForResponse: s }, N.FHIR_JSON, a);
41366
39084
  }
41367
39085
  getActiveLogin() {
41368
39086
  return this.storage.getObject("activeLogin");
41369
39087
  }
41370
39088
  async setActiveLogin(t) {
41371
- (!this.sessionDetails?.profile || ee(this.sessionDetails.profile) !== t.profile?.reference) && this.clearActiveLogin(), this.setAccessToken(t.accessToken, t.refreshToken), this.storage.setObject("activeLogin", t), this.addLogin(t), this.refreshPromise = void 0, await this.refreshProfile();
39089
+ (!this.sessionDetails?.profile || te(this.sessionDetails.profile) !== t.profile?.reference) && this.clearActiveLogin(), this.setAccessToken(t.accessToken, t.refreshToken), this.storage.setObject("activeLogin", t), this.addLogin(t), this.refreshPromise = void 0, await this.refreshProfile();
41372
39090
  }
41373
39091
  getAccessToken() {
41374
39092
  return this.accessToken;
41375
39093
  }
41376
39094
  setAccessToken(t, n) {
41377
- this.accessToken = t, this.refreshToken = n, this.sessionDetails = void 0, this.accessTokenExpires = Qn(t), this.medplumServer = Gn(t);
39095
+ this.accessToken = t, this.refreshToken = n, this.sessionDetails = void 0, this.accessTokenExpires = zn(t), this.medplumServer = Kn(t);
41378
39096
  }
41379
39097
  getLogins() {
41380
39098
  return this.storage.getObject("logins") ?? [];
@@ -41422,7 +39140,7 @@ var Pt = class extends De {
41422
39140
  async download(t, n = {}) {
41423
39141
  this.refreshPromise && await this.refreshPromise;
41424
39142
  let i2 = t.toString();
41425
- i2.startsWith(vs) && (t = this.fhirUrl(i2));
39143
+ i2.startsWith(bs) && (t = this.fhirUrl(i2));
41426
39144
  let o = n.headers;
41427
39145
  return o || (o = {}, n.headers = o), o.Accept || (o.Accept = "*/*"), this.addFetchOptionsDefaults(n), (await this.fetchWithRetry(t.toString(), n)).blob();
41428
39146
  }
@@ -41472,15 +39190,15 @@ var Pt = class extends De {
41472
39190
  return;
41473
39191
  let c2 = s.headers.get("content-type")?.includes("json");
41474
39192
  if (s.status === 404 && !c2)
41475
- throw new d(_r);
39193
+ throw new d(Lr);
41476
39194
  let u2 = await this.parseBody(s, c2);
41477
39195
  if (s.status === 200 && i2.followRedirectOnOk || s.status === 201 && i2.followRedirectOnCreated) {
41478
- let p2 = await Yn(s, u2);
39196
+ let p2 = await Xn(s, u2);
41479
39197
  if (p2)
41480
39198
  return this.request("GET", p2, { ...i2, body: void 0 });
41481
39199
  }
41482
39200
  if (s.status === 202 && i2.pollStatusOnAccepted) {
41483
- let y = await Yn(s, u2) ?? o.statusUrl;
39201
+ let y = await Xn(s, u2) ?? o.statusUrl;
41484
39202
  if (y)
41485
39203
  return this.pollStatus(y, i2, o);
41486
39204
  }
@@ -41552,7 +39270,7 @@ var Pt = class extends De {
41552
39270
  }
41553
39271
  }
41554
39272
  addFetchOptionsDefaults(t) {
41555
- this.setRequestHeader(t, "X-Medplum", "extended"), this.setRequestHeader(t, "Accept", ms, true), t.body && this.setRequestHeader(t, "Content-Type", N.FHIR_JSON, true), this.accessToken ? this.setRequestHeader(t, "Authorization", "Bearer " + this.accessToken) : this.basicAuth && this.setRequestHeader(t, "Authorization", "Basic " + this.basicAuth), t.cache || (t.cache = "no-cache"), t.credentials || (t.credentials = "include");
39273
+ this.setRequestHeader(t, "X-Medplum", "extended"), this.setRequestHeader(t, "Accept", xs, true), t.body && this.setRequestHeader(t, "Content-Type", N.FHIR_JSON, true), this.accessToken ? this.setRequestHeader(t, "Authorization", "Bearer " + this.accessToken) : this.basicAuth && this.setRequestHeader(t, "Authorization", "Basic " + this.basicAuth), t.cache || (t.cache = "no-cache"), t.credentials || (t.credentials = "include");
41556
39274
  }
41557
39275
  setRequestContentType(t, n) {
41558
39276
  this.setRequestHeader(t, "Content-Type", n);
@@ -41566,23 +39284,23 @@ var Pt = class extends De {
41566
39284
  typeof n == "string" || typeof Blob < "u" && (n instanceof Blob || n.constructor.name === "Blob") || typeof File < "u" && (n instanceof File || n.constructor.name === "File") || typeof Uint8Array < "u" && (n instanceof Uint8Array || n.constructor.name === "Uint8Array") ? t.body = n : n && (t.body = JSON.stringify(n));
41567
39285
  }
41568
39286
  handleUnauthenticated(t, n, i2) {
41569
- return this.refresh() ? this.request(t, n, i2) : (this.clearActiveLogin(), this.onUnauthenticated && this.onUnauthenticated(), Promise.reject(new Error("Unauthenticated")));
39287
+ return this.refresh() ? this.request(t, n, i2) : (this.clear(), this.onUnauthenticated && this.onUnauthenticated(), Promise.reject(new Error("Unauthenticated")));
41570
39288
  }
41571
39289
  async startPkce() {
41572
39290
  let t = yr();
41573
39291
  sessionStorage.setItem("pkceState", t);
41574
39292
  let n = yr();
41575
39293
  sessionStorage.setItem("codeVerifier", n);
41576
- let i2 = await Un(n), o = xn(i2).replaceAll("+", "-").replaceAll("/", "_").replaceAll("=", "");
39294
+ let i2 = await qn(n), o = vn(i2).replaceAll("+", "-").replaceAll("/", "_").replaceAll("=", "");
41577
39295
  return sessionStorage.setItem("codeChallenge", o), { codeChallengeMethod: "S256", codeChallenge: o };
41578
39296
  }
41579
39297
  async requestAuthorization(t) {
41580
39298
  let n = await this.ensureCodeChallenge(t ?? {}), i2 = new URL(this.authorizeUrl);
41581
- i2.searchParams.set("response_type", "code"), i2.searchParams.set("state", sessionStorage.getItem("pkceState")), i2.searchParams.set("client_id", n.clientId ?? this.clientId), i2.searchParams.set("redirect_uri", n.redirectUri ?? Jn()), i2.searchParams.set("code_challenge_method", n.codeChallengeMethod), i2.searchParams.set("code_challenge", n.codeChallenge), i2.searchParams.set("scope", n.scope ?? "openid profile"), window.location.assign(i2.toString());
39299
+ i2.searchParams.set("response_type", "code"), i2.searchParams.set("state", sessionStorage.getItem("pkceState")), i2.searchParams.set("client_id", n.clientId ?? this.clientId), i2.searchParams.set("redirect_uri", n.redirectUri ?? Zn()), i2.searchParams.set("code_challenge_method", n.codeChallengeMethod), i2.searchParams.set("code_challenge", n.codeChallenge), i2.searchParams.set("scope", n.scope ?? "openid profile"), window.location.assign(i2.toString());
41582
39300
  }
41583
39301
  processCode(t, n) {
41584
39302
  let i2 = new URLSearchParams();
41585
- if (i2.set("grant_type", "authorization_code"), i2.set("code", t), i2.set("client_id", n?.clientId ?? this.clientId), i2.set("redirect_uri", n?.redirectUri ?? Jn()), typeof sessionStorage < "u") {
39303
+ if (i2.set("grant_type", "authorization_code"), i2.set("code", t), i2.set("client_id", n?.clientId ?? this.clientId), i2.set("redirect_uri", n?.redirectUri ?? Zn()), typeof sessionStorage < "u") {
41586
39304
  let o = sessionStorage.getItem("codeVerifier");
41587
39305
  o && i2.set("code_verifier", o);
41588
39306
  }
@@ -41616,7 +39334,7 @@ var Pt = class extends De {
41616
39334
  return n.append("grant_type", "client_credentials"), n.append("client_assertion_type", "urn:ietf:params:oauth:client-assertion-type:jwt-bearer"), n.append("client_assertion", t), this.fetchTokens(n);
41617
39335
  }
41618
39336
  setBasicAuth(t, n) {
41619
- this.clientId = t, this.clientSecret = n, this.basicAuth = Ln(t + ":" + n);
39337
+ this.clientId = t, this.clientSecret = n, this.basicAuth = Bn(t + ":" + n);
41620
39338
  }
41621
39339
  async fhircastSubscribe(t, n) {
41622
39340
  if (!(typeof t == "string" && t !== ""))
@@ -41639,7 +39357,7 @@ var Pt = class extends De {
41639
39357
  return new Tt(t);
41640
39358
  }
41641
39359
  async fhircastPublish(t, n, i2, o) {
41642
- return jn(n) ? this.post(`/fhircast/STU3/${t}`, Tr(t, n, i2, o), N.JSON) : ($n(n), this.post(`/fhircast/STU3/${t}`, Tr(t, n, i2), N.JSON));
39360
+ return Wn(n) ? this.post(`/fhircast/STU3/${t}`, Tr(t, n, i2, o), N.JSON) : (Hn(n), this.post(`/fhircast/STU3/${t}`, Tr(t, n, i2), N.JSON));
41643
39361
  }
41644
39362
  async fhircastGetContext(t) {
41645
39363
  return this.get(`/fhircast/STU3/${t}`);
@@ -41670,7 +39388,7 @@ var Pt = class extends De {
41670
39388
  }
41671
39389
  async verifyTokens(t) {
41672
39390
  let n = t.access_token;
41673
- if (Hn(n)) {
39391
+ if (Qn(n)) {
41674
39392
  let i2 = Et(n);
41675
39393
  if (Date.now() >= i2.exp * 1e3)
41676
39394
  throw this.clearActiveLogin(), new Error("Token expired");
@@ -41695,7 +39413,7 @@ var Pt = class extends De {
41695
39413
  throw i2;
41696
39414
  }
41697
39415
  getSubscriptionManager() {
41698
- return this.subscriptionManager || (this.subscriptionManager = new Rt(this, En(this.baseUrl, "/ws/subscriptions-r4"))), this.subscriptionManager;
39416
+ return this.subscriptionManager || (this.subscriptionManager = new Rt(this, bn(this.baseUrl, "/ws/subscriptions-r4"))), this.subscriptionManager;
41699
39417
  }
41700
39418
  subscribeToCriteria(t) {
41701
39419
  return this.getSubscriptionManager().addCriteria(t);
@@ -41707,44 +39425,44 @@ var Pt = class extends De {
41707
39425
  return this.getSubscriptionManager().getMasterEmitter();
41708
39426
  }
41709
39427
  };
41710
- function Rs() {
39428
+ function As() {
41711
39429
  if (!globalThis.fetch)
41712
39430
  throw new Error("Fetch not available in this environment");
41713
39431
  return globalThis.fetch.bind(globalThis);
41714
39432
  }
41715
- function Jn() {
39433
+ function Zn() {
41716
39434
  return typeof window > "u" ? "" : window.location.protocol + "//" + window.location.host + "/";
41717
39435
  }
41718
- async function Yn(r4, e) {
39436
+ async function Xn(r4, e) {
41719
39437
  let t = r4.headers.get("content-location");
41720
39438
  if (t)
41721
39439
  return t;
41722
39440
  let n = r4.headers.get("location");
41723
39441
  if (n)
41724
39442
  return n;
41725
- if (le(e) && e.issue?.[0]?.diagnostics)
39443
+ if (pe(e) && e.issue?.[0]?.diagnostics)
41726
39444
  return e.issue[0].diagnostics;
41727
39445
  }
41728
39446
  function Rr(r4) {
41729
39447
  let e = r4.entry?.map((t) => t.resource) ?? [];
41730
39448
  return Object.assign(e, { bundle: r4 });
41731
39449
  }
41732
- function Ps(r4) {
39450
+ function Os(r4) {
41733
39451
  return b(r4) && "data" in r4 && "contentType" in r4;
41734
39452
  }
41735
- function Zn(r4, e, t, n) {
41736
- return Ps(r4) ? r4 : { data: r4, filename: e, contentType: t, onProgress: n };
39453
+ function ei(r4, e, t, n) {
39454
+ return Os(r4) ? r4 : { data: r4, filename: e, contentType: t, onProgress: n };
41737
39455
  }
41738
- function Cs(r4) {
39456
+ function Is(r4) {
41739
39457
  return b(r4) && "docDefinition" in r4;
41740
39458
  }
41741
- function ws(r4, e, t, n) {
41742
- return Cs(r4) ? r4 : { docDefinition: r4, filename: e, tableLayouts: t, fonts: n };
39459
+ function ks(r4, e, t, n) {
39460
+ return Is(r4) ? r4 : { docDefinition: r4, filename: e, tableLayouts: t, fonts: n };
41743
39461
  }
41744
- var _s = [...Ie, "->", "<<", ">>", "=="];
41745
- var Bs = ke().registerInfix("->", { precedence: h.Arrow }).registerInfix(";", { precedence: h.Semicolon });
41746
- var ra = [...Ie, "eq", "ne", "co"];
41747
- var oa = ke();
39462
+ var qs = [...Ie, "->", "<<", ">>", "=="];
39463
+ var Ws = ke().registerInfix("->", { precedence: h.Arrow }).registerInfix(";", { precedence: h.Semicolon });
39464
+ var sa = [...Ie, "eq", "ne", "co"];
39465
+ var ua = ke();
41748
39466
  var Z = class {
41749
39467
  constructor(e = "\r", t = "|", n = "^", i2 = "~", o = "\\", s = "&") {
41750
39468
  this.segmentSeparator = e;
@@ -41761,7 +39479,7 @@ var Z = class {
41761
39479
  return this.componentSeparator + this.repetitionSeparator + this.escapeCharacter + this.subcomponentSeparator;
41762
39480
  }
41763
39481
  };
41764
- var fi = class r {
39482
+ var yi = class r {
41765
39483
  constructor(e, t = new Z()) {
41766
39484
  this.context = t, this.segments = e;
41767
39485
  }
@@ -41785,7 +39503,7 @@ var fi = class r {
41785
39503
  }
41786
39504
  buildAck() {
41787
39505
  let e = /* @__PURE__ */ new Date(), t = this.getSegment("MSH"), n = t?.getField(3)?.toString() ?? "", i2 = t?.getField(4)?.toString() ?? "", o = t?.getField(5)?.toString() ?? "", s = t?.getField(6)?.toString() ?? "", a = t?.getField(10)?.toString() ?? "", c2 = t?.getField(12)?.toString() ?? "2.5.1";
41788
- return new r([new Le(["MSH", this.context.getMsh2(), o, s, n, i2, aa(e), "", this.buildAckMessageType(t), e.getTime().toString(), "P", c2], this.context), new Le(["MSA", "AA", a, "OK"], this.context)]);
39506
+ return new r([new Le(["MSH", this.context.getMsh2(), o, s, n, i2, pa(e), "", this.buildAckMessageType(t), e.getTime().toString(), "P", c2], this.context), new Le(["MSA", "AA", a, "OK"], this.context)]);
41789
39507
  }
41790
39508
  buildAckMessageType(e) {
41791
39509
  let t = e?.getField(9), n = t?.getComponent(2), i2 = t?.getComponent(3), o = "ACK";
@@ -41802,7 +39520,7 @@ var fi = class r {
41802
39520
  };
41803
39521
  var Le = class r2 {
41804
39522
  constructor(e, t = new Z()) {
41805
- this.context = t, hn(e) ? this.fields = e.map((n) => be.parse(n, t)) : this.fields = e, this.name = this.fields[0].components[0][0];
39523
+ this.context = t, yn(e) ? this.fields = e.map((n) => be.parse(n, t)) : this.fields = e, this.name = this.fields[0].components[0][0];
41806
39524
  }
41807
39525
  get(e) {
41808
39526
  return this.fields[e];
@@ -41846,12 +39564,12 @@ var be = class r3 {
41846
39564
  return new r3(e.split(t.repetitionSeparator).map((n) => n.split(t.componentSeparator)), t);
41847
39565
  }
41848
39566
  };
41849
- function aa(r4) {
39567
+ function pa(r4) {
41850
39568
  let e = r4 instanceof Date ? r4 : new Date(r4), n = e.toISOString().replace(/[-:T]/g, "").replace(/(\.\d+)?Z$/, ""), i2 = e.getUTCMilliseconds();
41851
39569
  return i2 > 0 && (n += "." + i2.toString()), n;
41852
39570
  }
41853
39571
  var Or = ((o) => (o[o.NONE = 0] = "NONE", o[o.ERROR = 1] = "ERROR", o[o.WARN = 2] = "WARN", o[o.INFO = 3] = "INFO", o[o.DEBUG = 4] = "DEBUG", o))(Or || {});
41854
- var mi = class {
39572
+ var gi = class {
41855
39573
  constructor(e, t = {}, n = 3) {
41856
39574
  this.write = e;
41857
39575
  this.metadata = t;
@@ -41874,7 +39592,7 @@ var mi = class {
41874
39592
  `) }), this.write(JSON.stringify({ level: Or[e], timestamp: (/* @__PURE__ */ new Date()).toISOString(), msg: t, ...n, ...this.metadata })));
41875
39593
  }
41876
39594
  };
41877
- function Dd(r4) {
39595
+ function qd(r4) {
41878
39596
  let e = Or[r4.toUpperCase()];
41879
39597
  if (e === void 0)
41880
39598
  throw new Error(`Invalid log level: ${r4}`);
@@ -41920,7 +39638,7 @@ var c = class extends i {
41920
39638
  t.on("data", (s) => {
41921
39639
  try {
41922
39640
  if (o += s.toString(), o.endsWith(p + v)) {
41923
- let r4 = fi.parse(o.substring(1, o.length - 2));
39641
+ let r4 = yi.parse(o.substring(1, o.length - 2));
41924
39642
  this.dispatchEvent(new d2(this, r4)), o = "";
41925
39643
  }
41926
39644
  } catch (r4) {
@@ -41986,8 +39704,7 @@ var E = class {
41986
39704
  // src/app.ts
41987
39705
  var import_node_child_process = require("child_process");
41988
39706
  var import_node_net = require("net");
41989
- var import_node_util = require("util");
41990
- var import_os = require("os");
39707
+ var import_node_os2 = require("os");
41991
39708
 
41992
39709
  // ../../node_modules/ws/wrapper.mjs
41993
39710
  var import_stream = __toESM(require_stream(), 1);
@@ -42107,7 +39824,7 @@ var DcmjsDimseScp = class extends dimse.Scp {
42107
39824
  });
42108
39825
  response.setStatus(dimse.constants.Status.Success);
42109
39826
  } catch (err) {
42110
- App.instance.log.error(`DICOM error: ${yi(err)}`);
39827
+ App.instance.log.error(`DICOM error: ${vi(err)}`);
42111
39828
  response.setStatus(dimse.constants.Status.ProcessingFailure);
42112
39829
  }
42113
39830
  return response;
@@ -42138,7 +39855,7 @@ var AgentHl7Channel = class {
42138
39855
  sendToRemote(msg) {
42139
39856
  const connection = this.connections.get(msg.remote);
42140
39857
  if (connection) {
42141
- connection.hl7Connection.send(fi.parse(msg.body));
39858
+ connection.hl7Connection.send(yi.parse(msg.body));
42142
39859
  }
42143
39860
  }
42144
39861
  handleNewConnection(connection) {
@@ -42167,7 +39884,7 @@ var AgentHl7ChannelConnection = class {
42167
39884
  body: event.message.toString()
42168
39885
  });
42169
39886
  } catch (err) {
42170
- this.channel.app.log.error(`HL7 error: ${yi(err)}`);
39887
+ this.channel.app.log.error(`HL7 error: ${vi(err)}`);
42171
39888
  }
42172
39889
  }
42173
39890
  close() {
@@ -42176,7 +39893,19 @@ var AgentHl7ChannelConnection = class {
42176
39893
  };
42177
39894
 
42178
39895
  // src/app.ts
42179
- var exec = (0, import_node_util.promisify)(import_node_child_process.exec);
39896
+ async function execAsync(command, options) {
39897
+ return new Promise((resolve, reject) => {
39898
+ (0, import_node_child_process.exec)(command, options, (ex, stdout, stderr) => {
39899
+ if (ex) {
39900
+ const err = ex;
39901
+ reject(err);
39902
+ return;
39903
+ }
39904
+ resolve({ stdout, stderr });
39905
+ });
39906
+ });
39907
+ }
39908
+ var DEFAULT_PING_TIMEOUT = 3600;
42180
39909
  var App = class _App {
42181
39910
  constructor(medplum, agentId, logLevel) {
42182
39911
  this.medplum = medplum;
@@ -42185,11 +39914,11 @@ var App = class _App {
42185
39914
  this.webSocketQueue = [];
42186
39915
  this.channels = /* @__PURE__ */ new Map();
42187
39916
  this.hl7Queue = [];
42188
- this.healthcheckPeriod = 10 * 1e3;
39917
+ this.heartbeatPeriod = 10 * 1e3;
42189
39918
  this.live = false;
42190
39919
  this.shutdown = false;
42191
39920
  _App.instance = this;
42192
- this.log = new mi((msg) => console.log(msg), void 0, logLevel);
39921
+ this.log = new gi((msg) => console.log(msg), void 0, logLevel);
42193
39922
  }
42194
39923
  async start() {
42195
39924
  this.log.info("Medplum service starting...");
@@ -42206,10 +39935,10 @@ var App = class _App {
42206
39935
  }
42207
39936
  startWebSocket() {
42208
39937
  this.connectWebSocket();
42209
- this.healthcheckTimer = setInterval(() => this.healthcheck(), this.healthcheckPeriod);
39938
+ this.heartbeatTimer = setInterval(() => this.heartbeat(), this.heartbeatPeriod);
42210
39939
  }
42211
- async healthcheck() {
42212
- if (!this.webSocket && !this.reconnectTimer) {
39940
+ async heartbeat() {
39941
+ if (!(this.webSocket || this.reconnectTimer)) {
42213
39942
  this.log.warn("WebSocket not connected");
42214
39943
  this.connectWebSocket();
42215
39944
  return;
@@ -42231,7 +39960,7 @@ var App = class _App {
42231
39960
  this.webSocket.binaryType = "nodebuffer";
42232
39961
  this.webSocket.addEventListener("error", (err) => {
42233
39962
  if (!this.shutdown) {
42234
- this.log.error(yi(err.error));
39963
+ this.log.error(vi(err.error));
42235
39964
  }
42236
39965
  });
42237
39966
  this.webSocket.addEventListener("open", async () => {
@@ -42262,7 +39991,7 @@ var App = class _App {
42262
39991
  this.startWebSocketWorker();
42263
39992
  break;
42264
39993
  case "agent:heartbeat:request":
42265
- await this.sendToWebSocket({ type: "agent:heartbeat:response" });
39994
+ await this.sendToWebSocket({ type: "agent:heartbeat:response", version: Op });
42266
39995
  break;
42267
39996
  case "agent:heartbeat:response":
42268
39997
  break;
@@ -42273,7 +40002,7 @@ var App = class _App {
42273
40002
  case "push":
42274
40003
  case "agent:transmit:request":
42275
40004
  if (command.contentType === N.PING) {
42276
- await this.tryPingIp(command);
40005
+ await this.tryPingHost(command);
42277
40006
  } else {
42278
40007
  this.pushMessage(command);
42279
40008
  }
@@ -42285,7 +40014,7 @@ var App = class _App {
42285
40014
  this.log.error(`Unknown message type: ${command.type}`);
42286
40015
  }
42287
40016
  } catch (err) {
42288
- this.log.error(`WebSocket error: ${yi(err)}`);
40017
+ this.log.error(`WebSocket error: ${vi(err)}`);
42289
40018
  }
42290
40019
  });
42291
40020
  }
@@ -42312,9 +40041,9 @@ var App = class _App {
42312
40041
  stop() {
42313
40042
  this.log.info("Medplum service stopping...");
42314
40043
  this.shutdown = true;
42315
- if (this.healthcheckTimer) {
42316
- clearInterval(this.healthcheckTimer);
42317
- this.healthcheckTimer = void 0;
40044
+ if (this.heartbeatTimer) {
40045
+ clearInterval(this.heartbeatTimer);
40046
+ this.heartbeatTimer = void 0;
42318
40047
  }
42319
40048
  if (this.reconnectTimer) {
42320
40049
  clearTimeout(this.reconnectTimer);
@@ -42351,7 +40080,7 @@ var App = class _App {
42351
40080
  try {
42352
40081
  await this.sendToWebSocket(msg);
42353
40082
  } catch (err) {
42354
- this.log.error(`WebSocket error: ${yi(err)}`);
40083
+ this.log.error(`WebSocket error: ${vi(err)}`);
42355
40084
  this.webSocketQueue.unshift(msg);
42356
40085
  throw err;
42357
40086
  }
@@ -42371,29 +40100,47 @@ var App = class _App {
42371
40100
  }
42372
40101
  }
42373
40102
  }
42374
- async tryPingIp(message) {
40103
+ // This covers Windows, Linux, and Mac
40104
+ getPingCommand(host, count = 1) {
40105
+ return (0, import_node_os2.platform)() === "win32" ? `ping /n ${count} ${host}` : `ping -c ${count} ${host}`;
40106
+ }
40107
+ async tryPingHost(message) {
42375
40108
  try {
42376
- if (message.body && message.body !== "PING") {
42377
- const warnMsg = "Message body present but unused. Body should be empty for a ping request.";
40109
+ if (message.body && !message.body.startsWith("PING")) {
40110
+ const warnMsg = "Message body present but unused. Body for a ping request should be empty or a message formatted as `PING[ count]`.";
42378
40111
  this.log.warn(warnMsg);
42379
40112
  }
42380
- if (!(0, import_node_net.isIPv4)(message.remote)) {
42381
- let errMsg = `Attempted to ping invalid IP: ${message.remote}`;
42382
- if ((0, import_node_net.isIPv6)(message.remote)) {
42383
- errMsg = `Attempted to ping an IPv6 address: ${message.remote}
40113
+ if ((0, import_node_net.isIPv6)(message.remote)) {
40114
+ const errMsg = `Attempted to ping an IPv6 address: ${message.remote}
42384
40115
 
42385
40116
  IPv6 is currently unsupported.`;
42386
- }
42387
40117
  this.log.error(errMsg);
42388
40118
  throw new Error(errMsg);
42389
40119
  }
42390
- const { stderr, stdout } = await exec(
42391
- (0, import_os.platform)() === "win32" ? `ping ${message.remote}` : `ping -c 4 ${message.remote}`
42392
- );
40120
+ if (!((0, import_node_net.isIPv4)(message.remote) || eu(message.remote))) {
40121
+ const errMsg = `Attempted to ping an invalid host.
40122
+
40123
+ "${message.remote}" is not a valid IPv4 address or a resolvable hostname.`;
40124
+ this.log.error(errMsg);
40125
+ throw new Error(errMsg);
40126
+ }
40127
+ const pingCountAsStr = message.body.startsWith("PING") ? message.body.split(" ")?.[1] ?? "" : "";
40128
+ let pingCount = void 0;
40129
+ if (pingCountAsStr !== "") {
40130
+ pingCount = Number.parseInt(pingCountAsStr, 10);
40131
+ if (Number.isNaN(pingCount)) {
40132
+ throw new Error(
40133
+ `Unable to ping ${message.remote} "${pingCountAsStr}" times. "${pingCountAsStr}" is not a number.`
40134
+ );
40135
+ }
40136
+ }
40137
+ const { stdout, stderr } = await execAsync(this.getPingCommand(message.remote, pingCount), {
40138
+ timeout: DEFAULT_PING_TIMEOUT
40139
+ });
42393
40140
  if (stderr) {
42394
40141
  throw new Error(`Received on stderr:
42395
40142
 
42396
- ${stderr}`);
40143
+ ${stderr.trim()}`);
42397
40144
  }
42398
40145
  const result = stdout.trim();
42399
40146
  this.log.info(`Ping result for ${message.remote}:
@@ -42405,13 +40152,19 @@ ${result}`);
42405
40152
  contentType: N.PING,
42406
40153
  remote: message.remote,
42407
40154
  callback: message.callback,
40155
+ statusCode: 200,
42408
40156
  body: result
42409
40157
  });
42410
40158
  } catch (err) {
42411
- this.log.error(`Error during ping attempt to ${message.remote ?? "NO_IP_GIVEN"}: ${yi(err)}`);
40159
+ this.log.error(`Error during ping attempt to ${message.remote ?? "NO_HOST_GIVEN"}: ${vi(err)}`);
42412
40160
  this.addToWebSocketQueue({
42413
- type: "agent:error",
42414
- body: err.message
40161
+ type: "agent:transmit:response",
40162
+ channel: message.channel,
40163
+ contentType: N.TEXT,
40164
+ remote: message.remote,
40165
+ callback: message.callback,
40166
+ statusCode: 500,
40167
+ body: vi(err)
42415
40168
  });
42416
40169
  }
42417
40170
  }
@@ -42433,9 +40186,9 @@ ${result}`);
42433
40186
  const address = new URL(message.remote);
42434
40187
  const client = new h2({
42435
40188
  host: address.hostname,
42436
- port: parseInt(address.port, 10)
40189
+ port: Number.parseInt(address.port, 10)
42437
40190
  });
42438
- client.sendAndWait(fi.parse(message.body)).then((response) => {
40191
+ client.sendAndWait(yi.parse(message.body)).then((response) => {
42439
40192
  this.log.info(`Response: ${response.toString().replaceAll("\r", "\n")}`);
42440
40193
  this.addToWebSocketQueue({
42441
40194
  type: "agent:transmit:response",
@@ -42443,10 +40196,20 @@ ${result}`);
42443
40196
  remote: message.remote,
42444
40197
  callback: message.callback,
42445
40198
  contentType: N.HL7_V2,
40199
+ statusCode: 200,
42446
40200
  body: response.toString()
42447
40201
  });
42448
40202
  }).catch((err) => {
42449
- this.log.error(`HL7 error: ${yi(err)}`);
40203
+ this.log.error(`HL7 error: ${vi(err)}`);
40204
+ this.addToWebSocketQueue({
40205
+ type: "agent:transmit:response",
40206
+ channel: message.channel,
40207
+ remote: message.remote,
40208
+ callback: message.callback,
40209
+ contentType: N.TEXT,
40210
+ statusCode: 500,
40211
+ body: vi(err)
40212
+ });
42450
40213
  }).finally(() => {
42451
40214
  client.close();
42452
40215
  });
@@ -42458,6 +40221,13 @@ async function main(argv) {
42458
40221
  let args;
42459
40222
  if (argv.length >= 6) {
42460
40223
  args = readCommandLineArgs(argv);
40224
+ } else if (argv.length === 3 && (argv[2] === "-h" || argv[2] === "--help")) {
40225
+ console.log("Expected arguments:");
40226
+ console.log(" baseUrl: The Medplum server base URL.");
40227
+ console.log(" clientId: The OAuth client ID.");
40228
+ console.log(" clientSecret: The OAuth client secret.");
40229
+ console.log(" agentId: The Medplum agent ID.");
40230
+ process.exit(0);
42461
40231
  } else if ((0, import_fs.existsSync)("agent.properties")) {
42462
40232
  args = readPropertiesFile("agent.properties");
42463
40233
  } else {
@@ -42481,7 +40251,7 @@ async function main(argv) {
42481
40251
  const { baseUrl, clientId, clientSecret, agentId } = args;
42482
40252
  const medplum = new Pt({ baseUrl, clientId });
42483
40253
  await medplum.startClientLogin(clientId, clientSecret);
42484
- const app = new App(medplum, agentId, Dd(args.logLevel ?? "INFO"));
40254
+ const app = new App(medplum, agentId, qd(args.logLevel ?? "INFO"));
42485
40255
  await app.start();
42486
40256
  process.on("SIGINT", () => {
42487
40257
  console.log("Gracefully shutting down from SIGINT (Crtl-C)");
@@ -42517,6 +40287,9 @@ dcmjs/build/dcmjs.js:
42517
40287
  * @license MIT
42518
40288
  *)
42519
40289
 
40290
+ safe-buffer/index.js:
40291
+ (*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> *)
40292
+
42520
40293
  dcmjs-dimse/build/dcmjs-dimse.min.js:
42521
40294
  (*! dcmjs-dimse - 0.1.27 - 2024-03-07 | (c) 2021-2024 Pantelis Georgiadis | https://github.com/PantelisGeorgiadis/dcmjs-dimse *)
42522
40295
  */