@umessen/dicom-deidentifier
Version:
DICOM de-identification library for TypeScript
1,674 lines • 1.62 MB
JavaScript
var Ls = Object.defineProperty;
var _s = (n, t, e) => t in n ? Ls(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
var r0 = (n, t, e) => (_s(n, typeof t != "symbol" ? t + "" : t, e), e);
var Ct = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
function iv(n, t) {
return t = { exports: {} }, n(t, t.exports), t.exports;
}
const Ai = () => {
}, Ti = Symbol("log-levels"), Na = Symbol("log-instance");
var Za = class {
constructor(t) {
this[Na] = t, this[Ti] = {
TRACE: 0,
DEBUG: 1,
INFO: 2,
WARN: 3,
ERROR: 4,
SILENT: 5
};
}
get levels() {
return this[Ti];
}
get logger() {
return this[Na];
}
set logger(t) {
this[Na] = t;
}
get methods() {
return Object.keys(this.levels).map((t) => t.toLowerCase()).filter((t) => t !== "silent");
}
bindMethod(t, e) {
const a = t[e];
if (typeof a.bind == "function")
return a.bind(t);
try {
return Function.prototype.bind.call(a, t);
} catch {
return function() {
return Function.prototype.apply.apply(a, [t, arguments]);
};
}
}
distillLevel(t) {
let e = t;
return typeof e == "string" && typeof this.levels[e.toUpperCase()] < "u" && (e = this.levels[e.toUpperCase()]), this.levelValid(e) ? e : !1;
}
levelValid(t) {
return typeof t == "number" && t >= 0 && t <= this.levels.SILENT;
}
make(t) {
return t === "debug" && (t = "log"), typeof console[t] < "u" ? this.bindMethod(console, t) : typeof console.log < "u" ? this.bindMethod(console, "log") : Ai;
}
replaceMethods(t) {
const e = this.distillLevel(t);
if (e == null)
throw new Error(`loglevelnext: replaceMethods() called with invalid level: ${t}`);
if (!this.logger || this.logger.type !== "LogLevel")
throw new TypeError(
"loglevelnext: Logger is undefined or invalid. Please specify a valid Logger instance."
);
this.methods.forEach((a) => {
const { [a.toUpperCase()]: r } = this.levels;
this.logger[a] = r < e ? Ai : this.make(a);
}), this.logger.log = this.logger.debug;
}
};
const ys = {
level: (n) => `[${n.level}]`,
name: (n) => n.logger.name,
template: "{{time}} {{level}} ",
time: () => new Date().toTimeString().split(" ")[0]
};
var vv = class extends Za {
constructor(t, e) {
super(t), this.options = Object.assign({}, ys, e);
}
interpolate(t) {
return this.options.template.replace(/{{([^{}]*)}}/g, (e, a) => {
const r = this.options[a];
return r ? r({ level: t, logger: this.logger }) : e;
});
}
make(t) {
const e = super.make(t);
return (...a) => {
const r = this.interpolate(t), [v] = a;
typeof v == "string" ? a[0] = r + v : a.unshift(r), e(...a);
};
}
};
const Us = {
factory: null,
level: "warn",
name: +new Date(),
prefix: null
};
var hi = class {
constructor(t) {
if (this.type = "LogLevel", this.options = Object.assign({}, Us, t), this.methodFactory = t.factory, !this.methodFactory) {
const e = t.prefix ? new vv(this, t.prefix) : new Za(this);
this.methodFactory = e;
}
this.methodFactory.logger || (this.methodFactory.logger = this), this.name = t.name || "<unknown>", this.level = this.options.level;
}
get factory() {
return this.methodFactory;
}
set factory(t) {
t.logger = this, this.methodFactory = t, this.methodFactory.replaceMethods(this.level);
}
disable() {
this.level = this.levels.SILENT;
}
enable() {
this.level = this.levels.TRACE;
}
get level() {
return this.currentLevel;
}
set level(t) {
const e = this.methodFactory.distillLevel(t);
if (e === !1 || e == null)
throw new RangeError(`loglevelnext: setLevel() called with invalid level: ${t}`);
this.currentLevel = e, this.methodFactory.replaceMethods(e), typeof console > "u" && e < this.levels.SILENT && console.warn("loglevelnext: console is undefined. The log will produce no output.");
}
get levels() {
return this.methodFactory.levels;
}
}, Gs = iv(function(n) {
const t = Symbol("log-factories");
class e extends hi {
constructor() {
super({ name: "default" }), this.cache = { default: this }, this[t] = { MethodFactory: Za, PrefixFactory: vv };
}
get factories() {
return this[t];
}
get loggers() {
return this.cache;
}
create(r) {
let v;
typeof r == "string" ? v = { name: r } : v = Object.assign({}, r), v.id || (v.id = v.name);
const { name: o, id: s } = v, m = { level: this.level };
if (typeof o != "string" || !o || !o.length)
throw new TypeError("You must supply a name when creating a logger.");
let l = this.cache[s];
return l || (l = new hi(Object.assign({}, m, v)), this.cache[s] = l), l;
}
}
n.exports = new e(), n.exports.default = n.exports;
}), ve = Gs.create("dcmjs"), tt = {
getBytesForBinaryFrame: ov,
pack: Fs,
unpack: bs
};
function ov(n) {
var t = n % 8, e = Math.floor(n / 8);
return t > 0 && e++, e;
}
function Fs(n) {
var t = n.length;
ve.log("numPixels: " + t);
for (var e = ov(t), a = new Uint8Array(e), r = 0, v = 0; v < t; v++) {
r = Math.floor(v / 8);
var o = n[v] !== 0, s = o << v % 8;
a[r] |= s;
}
return a;
}
function bs(n) {
for (var t = new Uint8Array(n), e = new Uint8Array(8 * t.length), a = 0; a < e.length; a++) {
var r = a % 8, v = Math.floor(a / 8);
e[a] = 255 * ((t[v] & 1 << r) >> r);
}
return e;
}
function Ni(n, t) {
var e = Object.keys(n);
if (Object.getOwnPropertySymbols) {
var a = Object.getOwnPropertySymbols(n);
t && (a = a.filter(function(r) {
return Object.getOwnPropertyDescriptor(n, r).enumerable;
})), e.push.apply(e, a);
}
return e;
}
function de(n) {
for (var t = 1; t < arguments.length; t++) {
var e = arguments[t] != null ? arguments[t] : {};
t % 2 ? Ni(Object(e), !0).forEach(function(a) {
M0(n, a, e[a]);
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(n, Object.getOwnPropertyDescriptors(e)) : Ni(Object(e)).forEach(function(a) {
Object.defineProperty(n, a, Object.getOwnPropertyDescriptor(e, a));
});
}
return n;
}
function ie(n) {
return ie = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(t) {
return typeof t;
} : function(t) {
return t && typeof Symbol == "function" && t.constructor === Symbol && t !== Symbol.prototype ? "symbol" : typeof t;
}, ie(n);
}
function P(n, t) {
if (!(n instanceof t))
throw new TypeError("Cannot call a class as a function");
}
function Li(n, t) {
for (var e = 0; e < t.length; e++) {
var a = t[e];
a.enumerable = a.enumerable || !1, a.configurable = !0, "value" in a && (a.writable = !0), Object.defineProperty(n, a.key, a);
}
}
function p(n, t, e) {
return t && Li(n.prototype, t), e && Li(n, e), Object.defineProperty(n, "prototype", {
writable: !1
}), n;
}
function M0(n, t, e) {
return t in n ? Object.defineProperty(n, t, {
value: e,
enumerable: !0,
configurable: !0,
writable: !0
}) : n[t] = e, n;
}
function T(n, t) {
if (typeof t != "function" && t !== null)
throw new TypeError("Super expression must either be null or a function");
n.prototype = Object.create(t && t.prototype, {
constructor: {
value: n,
writable: !0,
configurable: !0
}
}), Object.defineProperty(n, "prototype", {
writable: !1
}), t && zn(n, t);
}
function W(n) {
return W = Object.setPrototypeOf ? Object.getPrototypeOf : function(e) {
return e.__proto__ || Object.getPrototypeOf(e);
}, W(n);
}
function zn(n, t) {
return zn = Object.setPrototypeOf || function(a, r) {
return a.__proto__ = r, a;
}, zn(n, t);
}
function sv() {
if (typeof Reflect > "u" || !Reflect.construct || Reflect.construct.sham)
return !1;
if (typeof Proxy == "function")
return !0;
try {
return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {
})), !0;
} catch {
return !1;
}
}
function f0(n, t, e) {
return sv() ? f0 = Reflect.construct : f0 = function(r, v, o) {
var s = [null];
s.push.apply(s, v);
var m = Function.bind.apply(r, s), l = new m();
return o && zn(l, o.prototype), l;
}, f0.apply(null, arguments);
}
function ws(n) {
return Function.toString.call(n).indexOf("[native code]") !== -1;
}
function wa(n) {
var t = typeof Map == "function" ? /* @__PURE__ */ new Map() : void 0;
return wa = function(a) {
if (a === null || !ws(a))
return a;
if (typeof a != "function")
throw new TypeError("Super expression must either be null or a function");
if (typeof t < "u") {
if (t.has(a))
return t.get(a);
t.set(a, r);
}
function r() {
return f0(a, arguments, W(this).constructor);
}
return r.prototype = Object.create(a.prototype, {
constructor: {
value: r,
enumerable: !1,
writable: !0,
configurable: !0
}
}), zn(r, a);
}, wa(n);
}
function Vs(n) {
if (n === void 0)
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
return n;
}
function qt(n, t) {
if (t && (typeof t == "object" || typeof t == "function"))
return t;
if (t !== void 0)
throw new TypeError("Derived constructors may only return object or undefined");
return Vs(n);
}
function h(n) {
var t = sv();
return function() {
var a = W(n), r;
if (t) {
var v = W(this).constructor;
r = Reflect.construct(a, arguments, v);
} else
r = a.apply(this, arguments);
return qt(this, r);
};
}
function Bs(n, t) {
for (; !Object.prototype.hasOwnProperty.call(n, t) && (n = W(n), n !== null); )
;
return n;
}
function Y() {
return typeof Reflect < "u" && Reflect.get ? Y = Reflect.get : Y = function(t, e, a) {
var r = Bs(t, e);
if (!!r) {
var v = Object.getOwnPropertyDescriptor(r, e);
return v.get ? v.get.call(arguments.length < 3 ? t : a) : v.value;
}
}, Y.apply(this, arguments);
}
function me(n, t) {
return xs(n) || Qs(n, t) || Ja(n, t) || Ws();
}
function z(n) {
return qs(n) || ks(n) || Ja(n) || Hs();
}
function qs(n) {
if (Array.isArray(n))
return Va(n);
}
function xs(n) {
if (Array.isArray(n))
return n;
}
function ks(n) {
if (typeof Symbol < "u" && n[Symbol.iterator] != null || n["@@iterator"] != null)
return Array.from(n);
}
function Qs(n, t) {
var e = n == null ? null : typeof Symbol < "u" && n[Symbol.iterator] || n["@@iterator"];
if (e != null) {
var a = [], r = !0, v = !1, o, s;
try {
for (e = e.call(n); !(r = (o = e.next()).done) && (a.push(o.value), !(t && a.length === t)); r = !0)
;
} catch (m) {
v = !0, s = m;
} finally {
try {
!r && e.return != null && e.return();
} finally {
if (v)
throw s;
}
}
return a;
}
}
function Ja(n, t) {
if (!!n) {
if (typeof n == "string")
return Va(n, t);
var e = Object.prototype.toString.call(n).slice(8, -1);
if (e === "Object" && n.constructor && (e = n.constructor.name), e === "Map" || e === "Set")
return Array.from(n);
if (e === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e))
return Va(n, t);
}
}
function Va(n, t) {
(t == null || t > n.length) && (t = n.length);
for (var e = 0, a = new Array(t); e < t; e++)
a[e] = n[e];
return a;
}
function Hs() {
throw new TypeError(`Invalid attempt to spread non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`);
}
function Ws() {
throw new TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`);
}
function Xs(n, t) {
var e = typeof Symbol < "u" && n[Symbol.iterator] || n["@@iterator"];
if (!e) {
if (Array.isArray(n) || (e = Ja(n)) || t && n && typeof n.length == "number") {
e && (n = e);
var a = 0, r = function() {
};
return {
s: r,
n: function() {
return a >= n.length ? {
done: !0
} : {
done: !1,
value: n[a++]
};
},
e: function(m) {
throw m;
},
f: r
};
}
throw new TypeError(`Invalid attempt to iterate non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`);
}
var v = !0, o = !1, s;
return {
s: function() {
e = e.call(n);
},
n: function() {
var m = e.next();
return v = m.done, m;
},
e: function(m) {
o = !0, s = m;
},
f: function() {
try {
!v && e.return != null && e.return();
} finally {
if (o)
throw s;
}
}
};
}
function C0(n) {
if (isNaN(n))
throw new Error("Not a number: " + n);
return typeof n == "string" ? parseInt(n) : n;
}
function _i(n) {
if (isNaN(n))
throw new Error("Not a number: " + n);
return typeof n == "string" ? parseFloat(n) : n;
}
var mv = /* @__PURE__ */ function() {
function n(t, e) {
P(this, n), this.buffer = typeof t == "number" ? new ArrayBuffer(t) : t, this.buffer || (this.buffer = new ArrayBuffer(0)), this.view = new DataView(this.buffer), this.offset = 0, this.isLittleEndian = e || !1, this.size = 0, this.encoder = new TextEncoder("utf-8");
}
return p(n, [{
key: "setEndian",
value: function(e) {
this.isLittleEndian = e;
}
}, {
key: "writeUint8",
value: function(e) {
return this.checkSize(1), this.view.setUint8(this.offset, C0(e)), this.increment(1);
}
}, {
key: "writeUint8Repeat",
value: function(e, a) {
var r = C0(e);
this.checkSize(a);
for (var v = 0; v < a; v++)
this.view.setUint8(this.offset + v, r);
return this.increment(a);
}
}, {
key: "writeInt8",
value: function(e) {
return this.checkSize(1), this.view.setInt8(this.offset, C0(e)), this.increment(1);
}
}, {
key: "writeUint16",
value: function(e) {
return this.checkSize(2), this.view.setUint16(this.offset, C0(e), this.isLittleEndian), this.increment(2);
}
}, {
key: "writeTwoUint16s",
value: function(e) {
this.checkSize(4);
var a = e >> 16, r = e & 65535;
return this.view.setUint16(this.offset, C0(a), this.isLittleEndian), this.view.setUint16(this.offset + 2, C0(r), this.isLittleEndian), this.increment(4);
}
}, {
key: "writeInt16",
value: function(e) {
return this.checkSize(2), this.view.setInt16(this.offset, C0(e), this.isLittleEndian), this.increment(2);
}
}, {
key: "writeUint32",
value: function(e) {
return this.checkSize(4), this.view.setUint32(this.offset, C0(e), this.isLittleEndian), this.increment(4);
}
}, {
key: "writeInt32",
value: function(e) {
return this.checkSize(4), this.view.setInt32(this.offset, C0(e), this.isLittleEndian), this.increment(4);
}
}, {
key: "writeFloat",
value: function(e) {
return this.checkSize(4), this.view.setFloat32(this.offset, _i(e), this.isLittleEndian), this.increment(4);
}
}, {
key: "writeDouble",
value: function(e) {
return this.checkSize(8), this.view.setFloat64(this.offset, _i(e), this.isLittleEndian), this.increment(8);
}
}, {
key: "writeUTF8String",
value: function(e) {
var a = this.encoder.encode(e);
return this.checkSize(a.byteLength), new Uint8Array(this.buffer).set(a, this.offset), this.increment(a.byteLength);
}
}, {
key: "writeAsciiString",
value: function(e) {
e = e || "";
var a = e.length;
this.checkSize(a);
for (var r = this.offset, v = 0; v < a; v++) {
var o = e.charCodeAt(v);
this.view.setUint8(r + v, o);
}
return this.increment(a);
}
}, {
key: "readUint32",
value: function() {
var e = this.view.getUint32(this.offset, this.isLittleEndian);
return this.increment(4), e;
}
}, {
key: "readUint16",
value: function() {
var e = this.view.getUint16(this.offset, this.isLittleEndian);
return this.increment(2), e;
}
}, {
key: "readUint8",
value: function() {
var e = this.view.getUint8(this.offset);
return this.increment(1), e;
}
}, {
key: "peekUint8",
value: function(e) {
return this.view.getUint8(this.offset + e);
}
}, {
key: "readUint8Array",
value: function(e) {
var a = new Uint8Array(this.buffer, this.offset, e);
return this.increment(e), a;
}
}, {
key: "readUint16Array",
value: function(e) {
for (var a = e / 2, r = new Uint16Array(a), v = 0; v++ < a; )
r[v] = this.view.getUint16(this.offset, this.isLittleEndian), this.offset += 2;
return r;
}
}, {
key: "readInt16",
value: function() {
var e = this.view.getInt16(this.offset, this.isLittleEndian);
return this.increment(2), e;
}
}, {
key: "readInt32",
value: function() {
var e = this.view.getInt32(this.offset, this.isLittleEndian);
return this.increment(4), e;
}
}, {
key: "readFloat",
value: function() {
var e = this.view.getFloat32(this.offset, this.isLittleEndian);
return this.increment(4), e;
}
}, {
key: "readDouble",
value: function() {
var e = this.view.getFloat64(this.offset, this.isLittleEndian);
return this.increment(8), e;
}
}, {
key: "readAsciiString",
value: function(e) {
var a = "", r = this.offset, v = this.offset + e;
v >= this.buffer.byteLength && (v = this.buffer.byteLength);
for (var o = r; o < v; ++o)
a += String.fromCharCode(this.view.getUint8(o));
return this.increment(v - r), a;
}
}, {
key: "readVR",
value: function() {
var e = String.fromCharCode(this.view.getUint8(this.offset)) + String.fromCharCode(this.view.getUint8(this.offset + 1));
return this.increment(2), e;
}
}, {
key: "readEncodedString",
value: function(e) {
this.offset + e >= this.buffer.byteLength && (e = this.buffer.byteLength - this.offset);
var a = new DataView(this.buffer, this.offset, e), r = this.decoder.decode(a);
return this.increment(e), r;
}
}, {
key: "readHex",
value: function(e) {
for (var a = "", r = 0; r < e; r++)
a += this.readUint8().toString(16);
return a;
}
}, {
key: "checkSize",
value: function(e) {
if (this.offset + e > this.buffer.byteLength) {
var a = this.offset + e + this.buffer.byteLength, r = new ArrayBuffer(a);
new Uint8Array(r).set(new Uint8Array(this.buffer)), this.buffer = r, this.view = new DataView(this.buffer);
}
}
}, {
key: "concat",
value: function(e) {
var a = this.buffer.byteLength - this.offset;
if (e.size > a) {
var r = new ArrayBuffer(this.offset + e.size), v = new Uint8Array(r);
v.set(new Uint8Array(this.getBuffer(0, this.offset))), v.set(new Uint8Array(e.getBuffer(0, e.size)), this.offset), this.buffer = r, this.view = new DataView(this.buffer);
} else {
var o = new Uint8Array(this.buffer);
o.set(new Uint8Array(e.getBuffer(0, e.size)), this.offset);
}
return this.offset += e.size, this.size = this.offset, this.buffer.byteLength;
}
}, {
key: "increment",
value: function(e) {
return this.offset += e, this.offset > this.size && (this.size = this.offset), e;
}
}, {
key: "getBuffer",
value: function(e, a) {
return !e && !a && (e = 0, a = this.size), this.buffer.slice(e, a);
}
}, {
key: "more",
value: function(e) {
if (this.offset + e > this.endOffset)
throw new Error("Request more than currently allocated buffer");
var a = new X0(this.buffer, null, {
start: this.offset,
stop: this.offset + e
});
return this.increment(e), a;
}
}, {
key: "reset",
value: function() {
return this.offset = 0, this;
}
}, {
key: "end",
value: function() {
return this.offset >= this.buffer.byteLength;
}
}, {
key: "toEnd",
value: function() {
this.offset = this.buffer.byteLength;
}
}]), n;
}(), X0 = /* @__PURE__ */ function(n) {
T(e, n);
var t = h(e);
function e(a, r) {
var v, o = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {
start: null,
stop: null,
noCopy: !1
};
return P(this, e), v = t.call(this, a, r), v.offset = o.start || 0, v.size = o.stop || v.buffer.byteLength, v.noCopy = o.noCopy, v.startOffset = v.offset, v.endOffset = v.size, v.decoder = new TextDecoder("latin1"), v;
}
return p(e, [{
key: "setDecoder",
value: function(r) {
this.decoder = r;
}
}, {
key: "getBuffer",
value: function(r, v) {
return this.noCopy ? new Uint8Array(this.buffer, r, v - r) : (!r && !v && (r = 0, v = this.size), this.buffer.slice(r, v));
}
}, {
key: "reset",
value: function() {
return this.offset = this.startOffset, this;
}
}, {
key: "end",
value: function() {
return this.offset >= this.endOffset;
}
}, {
key: "toEnd",
value: function() {
this.offset = this.endOffset;
}
}, {
key: "writeUint8",
value: function(r) {
throw new Error(r, "writeUint8 not implemented");
}
}, {
key: "writeUint8Repeat",
value: function(r, v) {
throw new Error(r, "writeUint8Repeat not implemented");
}
}, {
key: "writeInt8",
value: function(r) {
throw new Error(r, "writeInt8 not implemented");
}
}, {
key: "writeUint16",
value: function(r) {
throw new Error(r, "writeUint16 not implemented");
}
}, {
key: "writeTwoUint16s",
value: function(r) {
throw new Error(r, "writeTwoUint16s not implemented");
}
}, {
key: "writeInt16",
value: function(r) {
throw new Error(r, "writeInt16 not implemented");
}
}, {
key: "writeUint32",
value: function(r) {
throw new Error(r, "writeUint32 not implemented");
}
}, {
key: "writeInt32",
value: function(r) {
throw new Error(r, "writeInt32 not implemented");
}
}, {
key: "writeFloat",
value: function(r) {
throw new Error(r, "writeFloat not implemented");
}
}, {
key: "writeDouble",
value: function(r) {
throw new Error(r, "writeDouble not implemented");
}
}, {
key: "writeAsciiString",
value: function(r) {
throw new Error(r, "writeAsciiString not implemented");
}
}, {
key: "writeUTF8String",
value: function(r) {
throw new Error(r, "writeUTF8String not implemented");
}
}, {
key: "checkSize",
value: function(r) {
throw new Error(r, "checkSize not implemented");
}
}, {
key: "concat",
value: function(r) {
throw new Error(r, "concat not implemented");
}
}]), e;
}(mv), jn = /* @__PURE__ */ function(n) {
T(e, n);
var t = h(e);
function e(a, r) {
var v;
return P(this, e), v = t.call(this, a, r), v.size = 0, v;
}
return p(e);
}(mv);
function cn(n) {
return n.replace(/\s*$/g, "");
}
function Ys(n, t) {
return Array.from(
{
length: n.length - (t - 1)
},
function(e, a) {
return n.slice(a, a + t);
}
);
}
var zs = ["FL", "FD", "SL", "SS", "UL", "US", "AT"], js = ["OB", "OW", "OF", "SQ", "UC", "UR", "UT", "UN"], Ks = ["SQ", "OF", "OW", "OB", "UN"], Ge = /* @__PURE__ */ function() {
function n(t) {
P(this, n), this.type = t, this.multi = !1, this._isBinary = zs.indexOf(this.type) != -1, this._allowMultiple = !this._isBinary && Ks.indexOf(this.type) == -1, this._isExplicit = js.indexOf(this.type) != -1;
}
return p(n, [{
key: "isBinary",
value: function() {
return this._isBinary;
}
}, {
key: "allowMultiple",
value: function() {
return this._allowMultiple;
}
}, {
key: "isExplicit",
value: function() {
return this._isExplicit;
}
}, {
key: "read",
value: function(e, a, r) {
if (this.fixed && this.maxLength) {
if (!a)
return this.defaultValue;
this.maxLength != a && ve.error("Invalid length for fixed length tag, vr " + this.type + ", length " + this.maxLength + " != " + a);
}
return this.readBytes(e, a, r);
}
}, {
key: "readBytes",
value: function(e, a) {
return e.readAsciiString(a);
}
}, {
key: "readNullPaddedString",
value: function(e, a) {
if (!a)
return "";
if (e.peekUint8(a - 1) !== 0)
return e.readAsciiString(a);
var r = e.readAsciiString(a - 1);
return e.increment(1), r;
}
}, {
key: "write",
value: function(e, a) {
var r = Array.from(arguments);
if (r[2] === null || r[2] === "" || r[2] === void 0)
return [e.writeAsciiString("")];
var v = [], o = r.slice(2), s = e["write" + a];
if (Array.isArray(o[0]))
if (o[0].length < 1)
v.push(0);
else {
var m = this;
o[0].forEach(function(l, S) {
m.allowMultiple() && S > 0 && e.writeUint8(92);
var u = [l].concat(o.slice(1)), I = s.apply(e, u);
v.push(I);
});
}
else
v.push(s.apply(e, o));
return v;
}
}, {
key: "writeBytes",
value: function(e, a, r) {
for (var v = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {
allowInvalidVRLength: !1
}, o = v.allowInvalidVRLength, s = !0, m = Array.isArray(a) ? a : [a], l = 0, S = 0; S < m.length; S++) {
var u = m[S], I = r[S], D = !1, C = I;
if (u === null || o)
s = !0;
else if (this.checkLength)
s = this.checkLength(u);
else if (this.maxCharLength) {
var M = this.maxCharLength;
s = u.length <= M, C = u.length, D = !0;
} else
this.maxLength && (s = I <= this.maxLength);
if (!s) {
var O = "Value exceeds max length, vr: " + this.type + ", value: " + u + ", length: " + C;
if (D)
ve.log(O);
else
throw new Error(O);
}
l += I;
}
this.allowMultiple() && (l += m.length ? m.length - 1 : 0);
var R = l;
return l & 1 && (e.writeUint8(this.padByte), R++), R;
}
}], [{
key: "createByTypeString",
value: function(e) {
var a = ct[e];
return a === void 0 && (e == "ox" ? (ve.error("Invalid vr type " + e + " - using OW"), a = ct.OW) : e == "xs" ? (ve.error("Invalid vr type " + e + " - using US"), a = ct.US) : (ve.error("Invalid vr type " + e + " - using UN"), a = ct.UN)), a;
}
}]), n;
}(), S0 = /* @__PURE__ */ function(n) {
T(e, n);
var t = h(e);
function e(a) {
return P(this, e), t.call(this, a);
}
return p(e, [{
key: "readBytes",
value: function(r, v) {
return r.readAsciiString(v);
}
}, {
key: "writeBytes",
value: function(r, v, o) {
var s = Y(W(e.prototype), "write", this).call(this, r, "AsciiString", v);
return Y(W(e.prototype), "writeBytes", this).call(this, r, v, s, o);
}
}]), e;
}(Ge), J0 = /* @__PURE__ */ function(n) {
T(e, n);
var t = h(e);
function e(a) {
return P(this, e), t.call(this, a);
}
return p(e, [{
key: "readBytes",
value: function(r, v) {
return r.readEncodedString(v);
}
}, {
key: "writeBytes",
value: function(r, v, o) {
var s = Y(W(e.prototype), "write", this).call(this, r, "UTF8String", v);
return Y(W(e.prototype), "writeBytes", this).call(this, r, v, s, o);
}
}]), e;
}(Ge), at = /* @__PURE__ */ function(n) {
T(e, n);
var t = h(e);
function e(a) {
return P(this, e), t.call(this, a);
}
return p(e, [{
key: "writeBytes",
value: function(r, v, o, s) {
var m = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : {}, l, S, u = m.fragmentMultiframe, I = u === void 0 ? !0 : u;
if (v = v == null ? [] : v, s) {
var D = 20480, C = v.length, M = [], O = 0;
for (l = 0; l < C; l++) {
var R = Boolean(v[l].byteLength & 1);
O += v[l].byteLength + (R ? 1 : 0);
var c = 1;
I && (c = Math.ceil(v[l].byteLength / D)), O += c * 8;
}
for (S = new jn(O, r.isLittleEndian), l = 0; l < C; l++) {
var f = Boolean(v[l].byteLength & 1);
M.push(S.size);
var E = v[l], N = new X0(E), b = 1;
I && (b = Math.ceil(N.size / D));
for (var q = 0, H = 0; q < b; q++) {
var X = q === b - 1, J = H + N.size;
I && (J = H + D), X && (J = N.size);
var re = new X0(N.getBuffer(H, J));
H = J, S.writeUint16(65534), S.writeUint16(57344);
var Z = X && f;
S.writeUint32(re.size + (Z ? 1 : 0)), S.concat(re), Z && S.writeInt8(this.padByte);
}
}
for (r.writeUint16(65534), r.writeUint16(57344), r.writeUint32(M.length * 4), l = 0; l < M.length; l++)
r.writeUint32(M[l]);
return r.concat(S), r.writeUint16(65534), r.writeUint16(57565), r.writeUint32(0), 4294967295;
} else {
var ge = v[0];
return S = new X0(ge), r.concat(S), Y(W(e.prototype), "writeBytes", this).call(this, r, ge, [S.size], m);
}
}
}, {
key: "readBytes",
value: function(r, v) {
if (v == 4294967295) {
var o = E0.readTag(r), s = [];
if (o.is(4294893568)) {
var m = r.readUint32(), l = 1, S = [];
if (m > 0) {
l = m / 4;
for (var u = 0; u++ < l; )
S.push(r.readUint32());
} else
S = [];
var I = 4294893568, D = 4294893789, C = function(c) {
var f = E0.readTag(c);
if (f.is(I)) {
var E = c.readUint32(), N = c.getBuffer(c.offset, c.offset + E);
return c.increment(E), N;
} else if (f.is(D)) {
if (c.readUint32() !== 0)
throw Error("SequenceDelimiterItem tag value was not zero");
return null;
}
throw Error("Invalid tag in sequence");
};
if (S.length > 0)
S = S.map(function(R) {
return R + r.offset;
}), S.push(r.size), s = Ys(S, 2).map(function(R) {
for (var c = [], f = me(R, 2), E = f[0], N = f[1], b = new X0(r.buffer, r.isLittleEndian, {
start: E,
stop: N,
noCopy: r.noCopy
}), q = 0; !b.end(); ) {
var H = C(b);
if (H === null)
break;
c.push(H), q += H.byteLength;
}
if (r.offset = b.offset, c.length === 1)
return c[0];
if (b.noCopy)
return c;
var X = new ArrayBuffer(q), J = new Uint8Array(X);
return c.reduce(function(re, Z) {
return J.set(new Uint8Array(Z), re), re + Z.byteLength;
}, 0), X;
});
else
for (; !r.end(); ) {
var M = C(r);
if (M === null)
break;
s.push(M);
}
} else
throw new Error("Item tag not found after undefined binary length");
return s;
} else {
var O;
return O = r.getBuffer(r.offset, r.offset + v), r.increment(v), [O];
}
}
}]), e;
}(Ge), $s = /* @__PURE__ */ function(n) {
T(e, n);
var t = h(e);
function e() {
var a;
return P(this, e), a = t.call(this, "AE"), a.maxLength = 16, a.padByte = 32, a;
}
return p(e, [{
key: "readBytes",
value: function(r, v) {
return r.readAsciiString(v).trim();
}
}]), e;
}(S0), Zs = /* @__PURE__ */ function(n) {
T(e, n);
var t = h(e);
function e() {
var a;
return P(this, e), a = t.call(this, "CS"), a.maxLength = 16, a.padByte = 32, a;
}
return p(e, [{
key: "readBytes",
value: function(r, v) {
return r.readAsciiString(v).trim();
}
}]), e;
}(S0), Js = /* @__PURE__ */ function(n) {
T(e, n);
var t = h(e);
function e() {
var a;
return P(this, e), a = t.call(this, "AS"), a.maxLength = 4, a.padByte = 32, a.fixed = !0, a.defaultValue = "", a;
}
return p(e);
}(S0), em = /* @__PURE__ */ function(n) {
T(e, n);
var t = h(e);
function e() {
var a;
return P(this, e), a = t.call(this, "AT"), a.maxLength = 4, a.valueLength = 4, a.padByte = 0, a.fixed = !0, a;
}
return p(e, [{
key: "readBytes",
value: function(r) {
return E0.readTag(r).value;
}
}, {
key: "writeBytes",
value: function(r, v, o) {
return Y(W(e.prototype), "writeBytes", this).call(this, r, v, Y(W(e.prototype), "write", this).call(this, r, "TwoUint16s", v), o);
}
}]), e;
}(Ge), nm = /* @__PURE__ */ function(n) {
T(e, n);
var t = h(e);
function e(a) {
var r;
return P(this, e), r = t.call(this, "DA", a), r.maxLength = 18, r.padByte = 32, r.defaultValue = "", r;
}
return p(e);
}(S0), tm = /* @__PURE__ */ function(n) {
T(e, n);
var t = h(e);
function e() {
var a;
return P(this, e), a = t.call(this, "DS"), a.maxLength = 16, a.padByte = 32, a;
}
return p(e, [{
key: "readBytes",
value: function(r, v) {
var o = String.fromCharCode(92), s = r.readAsciiString(v);
if (s = s.replace(/[^0-9.\\\-+e]/gi, ""), s.indexOf(o) !== -1) {
var m = s.split(o);
s = m.map(function(l) {
return l === "" ? null : Number(l);
});
} else
s = [s === "" ? null : Number(s)];
return s;
}
}, {
key: "formatValue",
value: function(r) {
if (r === null)
return "";
var v = String(r);
return v.length > this.maxLength ? r.toExponential() : v;
}
}, {
key: "writeBytes",
value: function(r, v, o) {
var s = this, m = Array.isArray(v) ? v.map(function(l) {
return s.formatValue(l);
}) : [this.formatValue(v)];
return Y(W(e.prototype), "writeBytes", this).call(this, r, m, o);
}
}]), e;
}(S0), am = /* @__PURE__ */ function(n) {
T(e, n);
var t = h(e);
function e() {
var a;
return P(this, e), a = t.call(this, "DT"), a.maxLength = 26, a.padByte = 32, a;
}
return p(e);
}(S0), rm = /* @__PURE__ */ function(n) {
T(e, n);
var t = h(e);
function e() {
var a;
return P(this, e), a = t.call(this, "FL"), a.maxLength = 4, a.padByte = 0, a.fixed = !0, a.defaultValue = 0, a;
}
return p(e, [{
key: "readBytes",
value: function(r) {
return Number(r.readFloat());
}
}, {
key: "writeBytes",
value: function(r, v, o) {
return Y(W(e.prototype), "writeBytes", this).call(this, r, v, Y(W(e.prototype), "write", this).call(this, r, "Float", v), o);
}
}]), e;
}(Ge), im = /* @__PURE__ */ function(n) {
T(e, n);
var t = h(e);
function e() {
var a;
return P(this, e), a = t.call(this, "FD"), a.maxLength = 8, a.padByte = 0, a.fixed = !0, a.defaultValue = 0, a;
}
return p(e, [{
key: "readBytes",
value: function(r) {
return Number(r.readDouble());
}
}, {
key: "writeBytes",
value: function(r, v, o) {
return Y(W(e.prototype), "writeBytes", this).call(this, r, v, Y(W(e.prototype), "write", this).call(this, r, "Double", v), o);
}
}]), e;
}(Ge), vm = /* @__PURE__ */ function(n) {
T(e, n);
var t = h(e);
function e() {
var a;
return P(this, e), a = t.call(this, "IS"), a.maxLength = 12, a.padByte = 32, a;
}
return p(e, [{
key: "readBytes",
value: function(r, v) {
var o = String.fromCharCode(92), s = r.readAsciiString(v).trim();
if (s = s.replace(/[^0-9.\\\-+e]/gi, ""), s.indexOf(o) !== -1) {
var m = s.split(o);
s = m.map(function(l) {
return l === "" ? null : Number(l);
});
} else
s = [s === "" ? null : Number(s)];
return s;
}
}, {
key: "formatValue",
value: function(r) {
return r === null ? "" : String(r);
}
}, {
key: "writeBytes",
value: function(r, v, o) {
var s = this, m = Array.isArray(v) ? v.map(function(l) {
return s.formatValue(l);
}) : [this.formatValue(v)];
return Y(W(e.prototype), "writeBytes", this).call(this, r, m, o);
}
}]), e;
}(S0), om = /* @__PURE__ */ function(n) {
T(e, n);
var t = h(e);
function e() {
var a;
return P(this, e), a = t.call(this, "LO"), a.maxCharLength = 64, a.padByte = 32, a;
}
return p(e, [{
key: "readBytes",
value: function(r, v) {
return r.readEncodedString(v).trim();
}
}]), e;
}(J0), sm = /* @__PURE__ */ function(n) {
T(e, n);
var t = h(e);
function e() {
var a;
return P(this, e), a = t.call(this, "LT"), a.maxCharLength = 10240, a.padByte = 32, a;
}
return p(e, [{
key: "readBytes",
value: function(r, v) {
return cn(r.readEncodedString(v));
}
}]), e;
}(J0), mm = /* @__PURE__ */ function(n) {
T(e, n);
var t = h(e);
function e() {
var a;
return P(this, e), a = t.call(this, "PN"), a.maxLength = null, a.padByte = 32, a;
}
return p(e, [{
key: "checkLength",
value: function(r) {
var v = [];
ie(r) === "object" && r !== null ? v = Object.keys(r).forEach(function(m) {
return r[m];
}) : (typeof r == "string" || r instanceof String) && (v = r.split(/\=/));
for (var o in v) {
var s = v[o];
if (s.length > 64)
return !1;
}
return !0;
}
}, {
key: "readBytes",
value: function(r, v) {
return cn(r.readEncodedString(v));
}
}]), e;
}(J0), lm = /* @__PURE__ */ function(n) {
T(e, n);
var t = h(e);
function e() {
var a;
return P(this, e), a = t.call(this, "SH"), a.maxCharLength = 16, a.padByte = 32, a;
}
return p(e, [{
key: "readBytes",
value: function(r, v) {
return r.readEncodedString(v).trim();
}
}]), e;
}(J0), Sm = /* @__PURE__ */ function(n) {
T(e, n);
var t = h(e);
function e() {
var a;
return P(this, e), a = t.call(this, "SL"), a.maxLength = 4, a.padByte = 0, a.fixed = !0, a.defaultValue = 0, a;
}
return p(e, [{
key: "readBytes",
value: function(r) {
return r.readInt32();
}
}, {
key: "writeBytes",
value: function(r, v, o) {
return Y(W(e.prototype), "writeBytes", this).call(this, r, v, Y(W(e.prototype), "write", this).call(this, r, "Int32", v), o);
}
}]), e;
}(Ge), um = /* @__PURE__ */ function(n) {
T(e, n);
var t = h(e);
function e() {
var a;
return P(this, e), a = t.call(this, "SQ"), a.maxLength = null, a.padByte = 0, a.noMultiple = !0, a;
}
return p(e, [{
key: "readBytes",
value: function(r, v, o) {
if (v == 0)
return [];
for (var s = v == 4294967295, m = [], l = 0; ; ) {
var S = E0.readTag(r), u = null;
if (l += 4, S.is(4294893789)) {
r.readUint32();
break;
} else {
if (!s && l == v)
break;
if (S.is(4294893568)) {
u = r.readUint32(), l += 4;
var I = null, D = 0, C = u == 4294967295;
if (C)
for (var M = 0; ; ) {
var O = r.readUint16();
if (O == 65534) {
var R = r.readUint16();
if (R == 57357)
if (M--, M < 0) {
r.increment(4), l += 8;
break;
} else
D += 4;
else if (R == 57344) {
M++, D += 4;
var c = r.readUint32();
r.increment(-4), c === 0 && M--;
} else
D += 2, r.increment(-2);
} else
D += 2;
}
else
D = u;
if (D) {
r.increment(C ? -D - 8 : 0), I = r.more(D), l += D, C && r.increment(8);
var f = xe._read(I, o);
m.push(f);
}
if (!s && l == v)
break;
}
}
}
return m;
}
}, {
key: "writeBytes",
value: function(r, v, o, s) {
var m = 0;
if (v)
for (var l = 0; l < v.length; l++) {
var S = v[l];
Y(W(e.prototype), "write", this).call(this, r, "Uint16", 65534), Y(W(e.prototype), "write", this).call(this, r, "Uint16", 57344), Y(W(e.prototype), "write", this).call(this, r, "Uint32", 4294967295), m += xe.write(S, r, o, s), Y(W(e.prototype), "write", this).call(this, r, "Uint16", 65534), Y(W(e.prototype), "write", this).call(this, r, "Uint16", 57357), Y(W(e.prototype), "write", this).call(this, r, "Uint32", 0), m += 16;
}
return Y(W(e.prototype), "write", this).call(this, r, "Uint16", 65534), Y(W(e.prototype), "write", this).call(this, r, "Uint16", 57565), Y(W(e.prototype), "write", this).call(this, r, "Uint32", 0), m += 8, Y(W(e.prototype), "writeBytes", this).call(this, r, v, [m], s);
}
}]), e;
}(Ge), Im = /* @__PURE__ */ function(n) {
T(e, n);
var t = h(e);
function e() {
var a;
return P(this, e), a = t.call(this, "SS"), a.maxLength = 2, a.valueLength = 2, a.padByte = 0, a.fixed = !0, a.defaultValue = 0, a;
}
return p(e, [{
key: "readBytes",
value: function(r) {
return r.readInt16();
}
}, {
key: "writeBytes",
value: function(r, v, o) {
return Y(W(e.prototype), "writeBytes", this).call(this, r, v, Y(W(e.prototype), "write", this).call(this, r, "Int16", v), o);
}
}]), e;
}(Ge), gm = /* @__PURE__ */ function(n) {
T(e, n);
var t = h(e);
function e() {
var a;
return P(this, e), a = t.call(this, "ST"), a.maxCharLength = 1024, a.padByte = 32, a;
}
return p(e, [{
key: "readBytes",
value: function(r, v) {
return cn(r.readEncodedString(v));
}
}]), e;
}(J0), Dm = /* @__PURE__ */ function(n) {
T(e, n);
var t = h(e);
function e() {
var a;
return P(this, e), a = t.call(this, "TM"), a.maxLength = 14, a.padByte = 32, a;
}
return p(e, [{
key: "readBytes",
value: function(r, v) {
return cn(r.readAsciiString(v));
}
}]), e;
}(S0), Cm = /* @__PURE__ */ function(n) {
T(e, n);
var t = h(e);
function e() {
var a;
return P(this, e), a = t.call(this, "UC"), a.maxLength = null, a.multi = !0, a.padByte = 32, a;
}
return p(e, [{
key: "readBytes",
value: function(r, v) {
return cn(r.readEncodedString(v));
}
}]), e;
}(J0), cm = /* @__PURE__ */ function(n) {
T(e, n);
var t = h(e);
function e() {
var a;
return P(this, e), a = t.call(this, "UT"), a.maxLength = null, a.padByte = 32, a;
}
return p(e, [{
key: "readBytes",
value: function(r, v) {
return cn(r.readEncodedString(v));
}
}]), e;
}(J0), Om = /* @__PURE__ */ function(n) {
T(e, n);
var t = h(e);
function e() {
var a;
return P(this, e), a = t.call(this, "US"), a.maxLength = 2, a.padByte = 0, a.fixed = !0, a.defaultValue = 0, a;
}
return p(e, [{
key: "readBytes",
value: function(r) {
return r.readUint16();
}
}, {
key: "writeBytes",
value: function(r, v, o) {
return Y(W(e.prototype), "writeBytes", this).call(this, r, v, Y(W(e.prototype), "write", this).call(this, r, "Uint16", v), o);
}
}]), e;
}(Ge), Mm = /* @__PURE__ */ function(n) {
T(e, n);
var t = h(e);
function e() {
var a;
return P(this, e), a = t.call(this, "UL"), a.maxLength = 4, a.padByte = 0, a.fixed = !0, a.defaultValue = 0, a;
}
return p(e, [{
key: "readBytes",
value: function(r) {
return r.readUint32();
}
}, {
key: "writeBytes",
value: function(r, v, o) {
return Y(W(e.prototype), "writeBytes", this).call(this, r, v, Y(W(e.prototype), "write", this).call(this, r, "Uint32", v), o);
}
}]), e;
}(Ge), Pm = /* @__PURE__ */ function(n) {
T(e, n);
var t = h(e);
function e() {
var a;
return P(this, e), a = t.call(this, "UI"), a.maxLength = 64, a.padByte = 0, a;
}
return p(e, [{
key: "readBytes",
value: function(r, v) {
var o = this.readNullPaddedString(r, v), s = String.fromCharCode(92), m = /[^0-9.]/g;
return o.indexOf(s) === -1 ? o.replace(m, "") : o.split(s).map(function(l) {
return l.replace(m, "");
});
}
}]), e;
}(S0), pm = /* @__PURE__ */ function(n) {
T(e, n);
var t = h(e);
function e() {
var a;
return P(this, e), a = t.call(this, "UR"), a.maxLength = null, a.padByte = 32, a;
}
return p(e, [{
key: "readBytes",
value: function(r, v) {
return r.readAsciiString(v);
}
}]), e;
}(S0), dm = /* @__PURE__ */ function(n) {
T(e, n);
var t = h(e);
function e() {
var a;
return P(this, e), a = t.call(this, "UN"), a.maxLength = null, a.padByte = 0, a.noMultiple = !0, a;
}
return p(e);
}(at), fm = /* @__PURE__ */ function(n) {
T(e, n);
var t = h(e);
function e() {
var a;
return P(this, e), a = t.call(this, "OW"), a.maxLength = null, a.padByte = 0, a.noMultiple = !0, a;
}
return p(e);
}(at), Em = /* @__PURE__ */ function(n) {
T(e, n);
var t = h(e);
function e() {
var a;
return P(this, e), a = t.call(this, "OB"), a.maxLength = null, a.padByte = 0, a.noMultiple = !0, a;
}
return p(e);
}(at), Rm = /* @__PURE__ */ function(n) {
T(e, n);
var t = h(e);
function e() {
var a;
return P(this, e), a = t.call(this, "OD"), a.maxLength = null, a.padByte = 0, a.noMultiple = !0, a;
}
return p(e);
}(at), Am = /* @__PURE__ */ function(n) {
T(e, n);
var t = h(e);
function e() {
var a;
return P(this, e), a = t.call(this, "OF"), a.maxLength = null, a.padByte = 0, a.noMultiple = !0, a;
}
return p(e);
}(at), ct = {
AE: new $s(),
AS: new Js(),
AT: new em(),
CS: new Zs(),
DA: new nm(),
DS: new tm(),
DT: new am(),
FL: new rm(),
FD: new im(),
IS: new vm(),
LO: new om(),
LT: new sm(),
OB: new Em(),
OD: new Rm(),
OF: new Am(),
OW: new fm(),
PN: new mm(),
SH: new lm(),
SL: new Sm(),
SQ: new um(),
SS: new Im(),
ST: new gm(),
TM: new Dm(),
UC: new Cm(),
UI: new Pm(),
UL: new Mm(),
UN: new dm(),
UR: new pm(),
US: new Om(),
UT: new cm()
}, yi = "1.2.840.10008.1.2", Tm = "1.2.840.10008.1.2.1";
function Ot(n, t) {
return String(n + t).slice(-n.length);
}
var E0 = /* @__PURE__ */ function() {
function n(t) {
P(this, n), this.value = t;
}
return p(n, [{
key: "toString",
value: function() {
return "(" + Ot("0000", this.group().toString(16).toUpperCase()) + "," + Ot("0000", this.element().toString(16).toUpperCase()) + ")";
}
}, {
key: "toCleanString",
value: function() {
return Ot("0000", this.group().toString(16).toUpperCase()) + Ot("0000", this.element().toString(16).toUpperCase());
}
}, {
key: "is",
value: function(e) {
return this.value == e;
}
}, {
key: "group",
value: function() {
return this.value >>> 16;
}
}, {
key: "element",
value: function() {
return this.value & 65535;
}
}, {
key: "isPixelDataTag",
value: function() {
return this.is(2145386512);
}
}, {
key: "isPrivateCreator",
value: function() {
var e = this.group(), a = this.element();
return e % 2 === 1 && a < 256 && a > 0;
}
}, {
key: "write",
value: function(e, a, r, v, o) {
var s = Ge.createByTypeString(a), m = xe._normalizeSyntax(v), l = m == yi, S = m == yi || m == Tm, u = this.isPixelDataTag() && xe.isEncapsulated(v), I = e.isLittleEndian;
e.setEndian(S), e.writeUint16(this.group()), e.writeUint16(this.element());
var D = new jn(256), C;
D.setEndian(S), a == "OW" || a == "OB" || a == "UN" ? C = s.writeBytes(D, r, m, u, o) : a == "SQ" ? C = s.writeBytes(D, r, m, o) : C = s.writeBytes(D, r, o), a == "SQ" && (C = 4294967295);
var M = D.size + 4;
return l ? (e.writeUint32(C), M += 4) : s.isExplicit() ? (e.writeAsciiString(s.type), e.writeUint16(0), e.writeUint32(C), M += 8) : (e.writeAsciiString(s.type), e.writeUint16(C), M += 4), e.concat(D), e.setEndian(I), M;
}
}], [{
key: "fromString",
value: function(e) {
var a = parseInt(e.substring(0, 4), 16), r = parseInt(e.substring(4), 16);
return n.fromNumbers(a, r);
}
}, {
key: "fromPString",
value: function(e) {
var a = parseInt(e.substring(1, 5), 16), r = parseInt(e.substring(6, 10), 16);
return n.fromNumbers(a, r);
}
}, {
key: "fromNumbers",
value: function(e, a) {
return new n((e << 16 | a) >>> 0);
}
}, {
key: "readTag",
value: function(e) {
var a = e.readUint16(), r = e.readUint16();
return n.fromNumbers(a, r);
}
}]), n;
}(), hm = { "(0000,0000)": { tag: "(0000,0000)", vr: "UL", name: "CommandGroupLength", vm: "1", version: "DICOM" }, "(0000,0002)": { tag: "(0000,0002)", vr: "UI", name: "AffectedSOPClassUID", vm: "1", version: "DICOM" }, "(0000,0003)": { tag: "(0000,0003)", vr: "UI", name: "RequestedSOPClassUID", vm: "1", version: "DICOM" }, "(0000,0100)": { tag: "(0000,0100)", vr: "US", name: "CommandField", vm: "1", version: "DICOM" }, "(0000,0110)": { tag: "(0000,0110)", vr: "US", name: "MessageID", vm: "1", version: "DICOM" }, "(0000,0120)": { tag: "(0000,0120)", vr: "US", name: "MessageIDBeingRespondedTo", vm: "1", version: "DICOM" }, "