vcard4
Version:
An RFC 6350 compliant JavaScript library for generating and parsing version 4.0 vCards. Can also generate RFC 6351 compliant XML vCards and RFC 7095 compliant jCards. TypeScript type declarations are provided.
1,114 lines (1,095 loc) • 334 kB
JavaScript
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.vcard4 = {}));
})(this, (function (exports) { 'use strict';
function _arrayLikeToArray(r, a) {
(null == a || a > r.length) && (a = r.length);
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
return n;
}
function _arrayWithHoles(r) {
if (Array.isArray(r)) return r;
}
function _arrayWithoutHoles(r) {
if (Array.isArray(r)) return _arrayLikeToArray(r);
}
function _assertClassBrand(e, t, n) {
if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n;
throw new TypeError("Private element is not present on this object");
}
function _assertThisInitialized(e) {
if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
return e;
}
function _callSuper(t, o, e) {
return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e));
}
function _checkPrivateRedeclaration(e, t) {
if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object");
}
function _classCallCheck(a, n) {
if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
}
function _classPrivateFieldGet2(s, a) {
return s.get(_assertClassBrand(s, a));
}
function _classPrivateFieldInitSpec(e, t, a) {
_checkPrivateRedeclaration(e, t), t.set(e, a);
}
function _classPrivateFieldSet2(s, a, r) {
return s.set(_assertClassBrand(s, a), r), r;
}
function _classPrivateMethodInitSpec(e, a) {
_checkPrivateRedeclaration(e, a), a.add(e);
}
function _construct(t, e, r) {
if (_isNativeReflectConstruct()) return Reflect.construct.apply(null, arguments);
var o = [null];
o.push.apply(o, e);
var p = new (t.bind.apply(t, o))();
return r && _setPrototypeOf(p, r.prototype), p;
}
function _defineProperties(e, r) {
for (var t = 0; t < r.length; t++) {
var o = r[t];
o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o);
}
}
function _createClass(e, r, t) {
return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", {
writable: !1
}), e;
}
function _createForOfIteratorHelper(r, e) {
var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
if (!t) {
if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) {
t && (r = t);
var n = 0,
F = function () {};
return {
s: F,
n: function () {
return n >= r.length ? {
done: !0
} : {
done: !1,
value: r[n++]
};
},
e: function (r) {
throw r;
},
f: F
};
}
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
var o,
a = !0,
u = !1;
return {
s: function () {
t = t.call(r);
},
n: function () {
var r = t.next();
return a = r.done, r;
},
e: function (r) {
u = !0, o = r;
},
f: function () {
try {
a || null == t.return || t.return();
} finally {
if (u) throw o;
}
}
};
}
function _defineProperty(e, r, t) {
return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
value: t,
enumerable: !0,
configurable: !0,
writable: !0
}) : e[r] = t, e;
}
function _getPrototypeOf(t) {
return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) {
return t.__proto__ || Object.getPrototypeOf(t);
}, _getPrototypeOf(t);
}
function _inherits(t, e) {
if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function");
t.prototype = Object.create(e && e.prototype, {
constructor: {
value: t,
writable: !0,
configurable: !0
}
}), Object.defineProperty(t, "prototype", {
writable: !1
}), e && _setPrototypeOf(t, e);
}
function _isNativeFunction(t) {
try {
return -1 !== Function.toString.call(t).indexOf("[native code]");
} catch (n) {
return "function" == typeof t;
}
}
function _isNativeReflectConstruct() {
try {
var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
} catch (t) {}
return (_isNativeReflectConstruct = function () {
return !!t;
})();
}
function _iterableToArray(r) {
if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
}
function _iterableToArrayLimit(r, l) {
var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
if (null != t) {
var e,
n,
i,
u,
a = [],
f = !0,
o = !1;
try {
if (i = (t = t.call(r)).next, 0 === l) {
if (Object(t) !== t) return;
f = !1;
} else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
} catch (r) {
o = !0, n = r;
} finally {
try {
if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
} finally {
if (o) throw n;
}
}
return a;
}
}
function _nonIterableRest() {
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
function _nonIterableSpread() {
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
function ownKeys(e, r) {
var t = Object.keys(e);
if (Object.getOwnPropertySymbols) {
var o = Object.getOwnPropertySymbols(e);
r && (o = o.filter(function (r) {
return Object.getOwnPropertyDescriptor(e, r).enumerable;
})), t.push.apply(t, o);
}
return t;
}
function _objectSpread2(e) {
for (var r = 1; r < arguments.length; r++) {
var t = null != arguments[r] ? arguments[r] : {};
r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
_defineProperty(e, r, t[r]);
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
});
}
return e;
}
function _possibleConstructorReturn(t, e) {
if (e && ("object" == typeof e || "function" == typeof e)) return e;
if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined");
return _assertThisInitialized(t);
}
function _setPrototypeOf(t, e) {
return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
return t.__proto__ = e, t;
}, _setPrototypeOf(t, e);
}
function _slicedToArray(r, e) {
return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
}
function _toConsumableArray(r) {
return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
}
function _toPrimitive(t, r) {
if ("object" != typeof t || !t) return t;
var e = t[Symbol.toPrimitive];
if (void 0 !== e) {
var i = e.call(t, r || "default");
if ("object" != typeof i) return i;
throw new TypeError("@@toPrimitive must return a primitive value.");
}
return ("string" === r ? String : Number)(t);
}
function _toPropertyKey(t) {
var i = _toPrimitive(t, "string");
return "symbol" == typeof i ? i : i + "";
}
function _typeof(o) {
"@babel/helpers - typeof";
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
return typeof o;
} : function (o) {
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
}, _typeof(o);
}
function _unsupportedIterableToArray(r, a) {
if (r) {
if ("string" == typeof r) return _arrayLikeToArray(r, a);
var t = {}.toString.call(r).slice(8, -1);
return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
}
}
function _wrapNativeSuper(t) {
var r = "function" == typeof Map ? new Map() : void 0;
return _wrapNativeSuper = function (t) {
if (null === t || !_isNativeFunction(t)) return t;
if ("function" != typeof t) throw new TypeError("Super expression must either be null or a function");
if (void 0 !== r) {
if (r.has(t)) return r.get(t);
r.set(t, Wrapper);
}
function Wrapper() {
return _construct(t, arguments, _getPrototypeOf(this).constructor);
}
return Wrapper.prototype = Object.create(t.prototype, {
constructor: {
value: Wrapper,
enumerable: !1,
writable: !0,
configurable: !0
}
}), _setPrototypeOf(Wrapper, t);
}, _wrapNativeSuper(t);
}
var MissingArgument = /*#__PURE__*/function (_Error) {
function MissingArgument(message) {
var _this;
_classCallCheck(this, MissingArgument);
_this = _callSuper(this, MissingArgument, [message]);
_this.name = "MissingArgument";
return _this;
}
_inherits(MissingArgument, _Error);
return _createClass(MissingArgument);
}(/*#__PURE__*/_wrapNativeSuper(Error));
Object.freeze(MissingArgument);
var InvalidArgument = /*#__PURE__*/function (_Error) {
function InvalidArgument(message) {
var _this;
_classCallCheck(this, InvalidArgument);
_this = _callSuper(this, InvalidArgument, [message]);
_this.name = "InvalidArgument";
return _this;
}
_inherits(InvalidArgument, _Error);
return _createClass(InvalidArgument);
}(/*#__PURE__*/_wrapNativeSuper(Error));
Object.freeze(InvalidArgument);
var InvalidVcard = /*#__PURE__*/function (_Error) {
function InvalidVcard(message) {
var _this;
_classCallCheck(this, InvalidVcard);
_this = _callSuper(this, InvalidVcard, [message]);
_this.name = "InvalidVcard";
return _this;
}
_inherits(InvalidVcard, _Error);
return _createClass(InvalidVcard);
}(/*#__PURE__*/_wrapNativeSuper(Error));
Object.freeze(InvalidVcard);
var _abstractPropertiesAndMethods$2 = /*#__PURE__*/new WeakMap();
var BaseValue = /*#__PURE__*/function () {
function BaseValue() {
_classCallCheck(this, BaseValue);
_classPrivateFieldInitSpec(this, _abstractPropertiesAndMethods$2, ["type", "value", "valueXML", "valueJSON", "identifier"]);
if (this.constructor === BaseValue) throw new Error("Cannot create instance of base class");
}
return _createClass(BaseValue, [{
key: "checkAbstractPropertiesAndMethods",
value: function checkAbstractPropertiesAndMethods() {
var _this = this;
if (!_classPrivateFieldGet2(_abstractPropertiesAndMethods$2, this).every(function (abstractPropertyOrMethod) {
return Object.prototype.hasOwnProperty.call(_this, abstractPropertyOrMethod) || Object.prototype.hasOwnProperty.call(Object.getPrototypeOf(_this), abstractPropertyOrMethod) || Object.prototype.hasOwnProperty.call(_this.constructor, abstractPropertyOrMethod);
})) throw new Error("All abstract properties and methods in abstract base class must be defined in child class");
}
}, {
key: "repr",
value: function repr() {
return this.value;
}
}, {
key: "reprXML",
value: function reprXML() {
return this.valueXML;
}
}, {
key: "reprJSON",
value: function reprJSON() {
return this.valueJSON;
}
}]);
}();
Object.freeze(BaseValue);
var _textValue = /*#__PURE__*/new WeakMap();
var _TextType_brand = /*#__PURE__*/new WeakSet();
var TextType = /*#__PURE__*/function (_BaseValue) {
function TextType(_textValue2) {
var _this;
_classCallCheck(this, TextType);
_this = _callSuper(this, TextType);
_classPrivateMethodInitSpec(_this, _TextType_brand);
_classPrivateFieldInitSpec(_this, _textValue, void 0);
_assertClassBrand(_TextType_brand, _this, _validate$19).call(_this, _textValue2);
_classPrivateFieldSet2(_textValue, _this, _textValue2);
_this.checkAbstractPropertiesAndMethods();
Object.freeze(_this);
return _this;
}
_inherits(TextType, _BaseValue);
return _createClass(TextType, [{
key: "value",
get: function get() {
return _assertClassBrand(_TextType_brand, this, _cleanUp$1).call(this, _classPrivateFieldGet2(_textValue, this));
}
}, {
key: "valueXML",
get: function get() {
return "<".concat(this.constructor.type.toLowerCase(), ">").concat(_assertClassBrand(_TextType_brand, this, _cleanUpXML$1).call(this, _classPrivateFieldGet2(_textValue, this)), "</").concat(this.constructor.type.toLowerCase(), ">");
}
}, {
key: "valueJSON",
get: function get() {
return [this.constructor.type.toLowerCase(), _classPrivateFieldGet2(_textValue, this)];
}
}, {
key: "_unsafe_raw_value",
get: function get() {
return _classPrivateFieldGet2(_textValue, this);
}
}]);
}(BaseValue);
function _validate$19(textValue) {
if (typeof textValue === "undefined" || textValue === "") throw new MissingArgument("Value for TextType must be supplied");else if (typeof textValue !== "string") throw new TypeError("Only type string allowed for TextType value");
}
function _cleanUp$1(textValue) {
return textValue.replaceAll("\\", "\\\\").replaceAll(",", "\\,").replaceAll(":", "\\:").replaceAll(";", "\\;").replaceAll("\n", "\\n");
}
function _cleanUpXML$1(textValue) {
return textValue.replaceAll("&", "&").replaceAll(">", ">").replaceAll("<", "<").replaceAll('"', """).replaceAll("'", "'");
}
_defineProperty(TextType, "type", "TEXT");
_defineProperty(TextType, "identifier", "TextType");
Object.freeze(TextType);
var _textlist = /*#__PURE__*/new WeakMap();
var _TextListType_brand = /*#__PURE__*/new WeakSet();
var TextListType = /*#__PURE__*/function (_BaseValue) {
function TextListType(_textlist2) {
var _this;
_classCallCheck(this, TextListType);
_this = _callSuper(this, TextListType);
_classPrivateMethodInitSpec(_this, _TextListType_brand);
_classPrivateFieldInitSpec(_this, _textlist, void 0);
_assertClassBrand(_TextListType_brand, _this, _validate$18).call(_this, _textlist2);
_classPrivateFieldSet2(_textlist, _this, _textlist2);
_this.checkAbstractPropertiesAndMethods();
Object.freeze(_this);
return _this;
}
_inherits(TextListType, _BaseValue);
return _createClass(TextListType, [{
key: "value",
get: function get() {
return _classPrivateFieldGet2(_textlist, this).reduce(function (accumulatedTextTypes, currentTextType) {
accumulatedTextTypes.push(currentTextType.repr());
return accumulatedTextTypes;
}, []).join(",");
}
}, {
key: "valueXML",
get: function get() {
return _classPrivateFieldGet2(_textlist, this).reduce(function (accumulatedTextTypes, currentTextType) {
return accumulatedTextTypes + currentTextType.reprXML();
}, "");
}
}, {
key: "valueJSON",
get: function get() {
var value = _classPrivateFieldGet2(_textlist, this).reduce(function (accumulatedTextTypes, currentTextType) {
accumulatedTextTypes.push(currentTextType.reprJSON().pop());
return accumulatedTextTypes;
}, []);
value.unshift(this.constructor.type.toLowerCase());
return value;
}
}]);
}(BaseValue);
function _validate$18(textlist) {
if (typeof textlist === "undefined") throw new MissingArgument("Value for TextListType must be supplied");else if (!Array.isArray(textlist)) throw new TypeError("Value for TextListType must be passed in an array");
var _iterator = _createForOfIteratorHelper(textlist),
_step;
try {
for (_iterator.s(); !(_step = _iterator.n()).done;) {
var text = _step.value;
if (text.constructor.identifier !== "TextType") throw new TypeError("Invalid type for value of TextListType. It should be an array of TextTypes");
}
} catch (err) {
_iterator.e(err);
} finally {
_iterator.f();
}
}
_defineProperty(TextListType, "type", "TEXT");
_defineProperty(TextListType, "identifier", "TextListType");
Object.freeze(TextListType);
var _boolValue = /*#__PURE__*/new WeakMap();
var _BooleanType_brand = /*#__PURE__*/new WeakSet();
var BooleanType = /*#__PURE__*/function (_BaseValue) {
function BooleanType(_boolValue2) {
var _this;
_classCallCheck(this, BooleanType);
_this = _callSuper(this, BooleanType);
_classPrivateMethodInitSpec(_this, _BooleanType_brand);
_classPrivateFieldInitSpec(_this, _boolValue, void 0);
_assertClassBrand(_BooleanType_brand, _this, _validate$17).call(_this, _boolValue2);
_classPrivateFieldSet2(_boolValue, _this, _boolValue2);
_this.checkAbstractPropertiesAndMethods();
Object.freeze(_this);
return _this;
}
_inherits(BooleanType, _BaseValue);
return _createClass(BooleanType, [{
key: "value",
get: function get() {
return "".concat(_classPrivateFieldGet2(_boolValue, this));
}
}, {
key: "valueXML",
get: function get() {
return "<".concat(this.constructor.type.toLowerCase(), ">").concat(_classPrivateFieldGet2(_boolValue, this), "</").concat(this.constructor.type.toLowerCase(), ">");
}
}, {
key: "valueJSON",
get: function get() {
return [this.constructor.type.toLowerCase(), _classPrivateFieldGet2(_boolValue, this)];
}
}]);
}(BaseValue);
function _validate$17(boolValue) {
if (typeof boolValue === "undefined") throw new MissingArgument("boolValue must be supplied");else if (typeof boolValue !== "boolean") throw new TypeError("Value for BooleanType should be of type boolean");
}
_defineProperty(BooleanType, "type", "BOOLEAN");
_defineProperty(BooleanType, "identifier", "BooleanType");
Object.freeze(BooleanType);
var _dateTimeValue = /*#__PURE__*/new WeakMap();
var _dateRegExp = /*#__PURE__*/new WeakMap();
var _timeRegExp = /*#__PURE__*/new WeakMap();
var _dateTimeRegExp = /*#__PURE__*/new WeakMap();
var _dateAndOrTimeRegExp = /*#__PURE__*/new WeakMap();
var _timestampRegExp = /*#__PURE__*/new WeakMap();
var _utcOffsetRegExp = /*#__PURE__*/new WeakMap();
var _MAX_DATETIMEVALUE_LEN = /*#__PURE__*/new WeakMap();
var _DateTimeType_brand = /*#__PURE__*/new WeakSet();
var DateTimeType = /*#__PURE__*/function (_BaseValue) {
function DateTimeType(_type, _dateTimeValue2) {
var _this;
_classCallCheck(this, DateTimeType);
_this = _callSuper(this, DateTimeType);
_classPrivateMethodInitSpec(_this, _DateTimeType_brand);
_classPrivateFieldInitSpec(_this, _dateTimeValue, void 0);
_classPrivateFieldInitSpec(_this, _dateRegExp, /^(?:(?:\d{4})|(?:(?:\d{4}(?:(?:(?:0[469]|11)(?:[0-2]\d|30))|(?:(?:0[13578]|1[02])(?:[0-2]\d|3[01]))))|(?:\d{2}(?:(?:(?:[02468][048]|[13579][26])(?:02)(?:[0-2]\d))|(?:(:?\d[13579]|[02468][26]|[13579][048])(?:02)(?:[0-2][0-8]|[01]9)))))|(?:-{2}(?:(?:(?:0[469]|11)(?:[0-2]\d|30)?)|(?:(?:0[13578]|1[02])(?:[0-2]\d|3[01])?)|(?:(?:02)(?:[0-2]\d)?)))|(?:-{3}(?:[0-2]\d|3[01]))|(?:\d{4}-(?:(?:0[1-9])|1[0-2])))$/);
_classPrivateFieldInitSpec(_this, _timeRegExp, /^(?:(?:(?:(?:[01]\d)|(?:2[0-3]))(?:(?:[0-5]\d){1,2})?)|(?:-(?:[0-5]\d){1,2})|(?:-{2}[0-5]\d))(?:Z|(?:[+-]((?:[01]\d)|(?:2[0-3]))(?:[0-5]\d)?))?$/);
_classPrivateFieldInitSpec(_this, _dateTimeRegExp, /^(?:(?:(?:\d{4}(?:(?:(?:0[469]|11)(?:[0-2]\d|30))|(?:(?:0[13578]|1[02])(?:[0-2]\d|3[01]))))|(?:\d{2}(?:(?:(?:[02468][048]|[13579][26])(?:02)(?:[0-2]\d))|(?:(:?\d[13579]|[02468][26]|[13579][048])(?:02)(?:[0-2][0-8]|[01]9)))))|(?:-{2}(?:(?:(?:0[469]|11)(?:[0-2]\d|30))|(?:(?:0[13578]|1[02])(?:[0-2]\d|3[01]))|(?:(?:02)(?:[0-2]\d))))|(?:-{3}(?:[0-2]\d|3[01])))(?:T)(?:(?:(?:(?:[01]\d)|(?:2[0-3]))(?:(?:[0-5]\d){1,2})?)(?:Z|(?:[+-]((?:[01]\d)|(?:2[0-3]))(?:[0-5]\d)?))?)$/);
_classPrivateFieldInitSpec(_this, _dateAndOrTimeRegExp, new RegExp("(?:".concat(_classPrivateFieldGet2(_dateRegExp, _this).source, "|").concat(_classPrivateFieldGet2(_timeRegExp, _this).source.replace("^", "^T"), "|").concat(_classPrivateFieldGet2(_dateTimeRegExp, _this).source, ")")));
_classPrivateFieldInitSpec(_this, _timestampRegExp, /^(?:(?:\d{4}(?:(?:(?:0[469]|11)(?:[0-2]\d|30))|(?:(?:0[13578]|1[02])(?:[0-2]\d|3[01]))))|(?:\d{2}(?:(?:(?:[02468][048]|[13579][26])(?:02)(?:[0-2]\d))|(?:(:?\d[13579]|[02468][26]|[13579][048])(?:02)(?:[0-2][0-8]|[01]9)))))(?:T)(?:(?:(?:(?:[01]\d)|(?:2[0-3]))(?:[0-5]\d){2})(?:Z|(?:[+-]((?:[01]\d)|(?:2[0-3]))(?:[0-5]\d)?))?)$/);
_classPrivateFieldInitSpec(_this, _utcOffsetRegExp, /^(?:[+-]((?:[01]\d)|(?:2[0-3]))(?:[0-5]\d)?)$/);
_classPrivateFieldInitSpec(_this, _MAX_DATETIMEVALUE_LEN, 20);
_assertClassBrand(_DateTimeType_brand, _this, _validateAndSetType).call(_this, _type, _dateTimeValue2);
_classPrivateFieldSet2(_dateTimeValue, _this, _dateTimeValue2);
_this.checkAbstractPropertiesAndMethods();
Object.freeze(_this);
return _this;
}
_inherits(DateTimeType, _BaseValue);
return _createClass(DateTimeType, [{
key: "value",
get: function get() {
return "".concat(_classPrivateFieldGet2(_dateTimeValue, this));
}
}, {
key: "valueXML",
get: function get() {
var tag = this.type.toLowerCase();
var value = _classPrivateFieldGet2(_dateTimeValue, this);
if (tag === "date-and-or-time") {
switch (true) {
case _classPrivateFieldGet2(_dateRegExp, this).test(value):
tag = "date";
break;
case _classPrivateFieldGet2(_timeRegExp, this).test(value):
tag = "time";
break;
case _classPrivateFieldGet2(_dateTimeRegExp, this).test(value):
tag = "date-time";
break;
}
}
return "<".concat(tag, ">").concat(value, "</").concat(tag, ">");
}
}, {
key: "valueJSON",
get: function get() {
var type = this.type.toLowerCase();
var value;
function _extendDate(date) {
if (/^\d{8}$/.test(date)) {
date = _toConsumableArray(date);
date.splice(4, 0, "-");
date.splice(7, 0, "-");
return date.join("");
} else if (/^-{2}\d{4}$/.test(date)) {
date = _toConsumableArray(date);
date.splice(4, 0, "-");
return date.join("");
}
return date;
}
function _extendTime(time) {
var timeModified = [];
for (var index = 0; index < time.length; index += 2) {
if (!/^\d$/.test(time[index])) {
timeModified.push(time[index]);
index--;
continue;
}
timeModified.push(time[index]);
timeModified.push(time[index + 1]);
/^\d$/.test(time[index + 2]) && timeModified.push(":");
}
return timeModified.join("");
}
switch (type) {
case "date":
value = _extendDate(_classPrivateFieldGet2(_dateTimeValue, this));
break;
case "time":
value = _extendTime(_classPrivateFieldGet2(_dateTimeValue, this));
break;
case "date-time":
value = _classPrivateFieldGet2(_dateTimeValue, this).split("T");
value = _extendDate(value[0]) + "T" + _extendTime(value[1]);
break;
case "date-and-or-time":
if (_classPrivateFieldGet2(_dateTimeValue, this).includes("T")) {
value = _classPrivateFieldGet2(_dateTimeValue, this).split("T");
value = _extendDate(value[0]) + "T" + _extendTime(value[1]);
} else value = _extendDate(_classPrivateFieldGet2(_dateTimeValue, this));
break;
case "timestamp":
value = _classPrivateFieldGet2(_dateTimeValue, this).split("T");
value = _extendDate(value[0]) + "T" + _extendTime(value[1]);
break;
case "utc-offset":
value = _extendTime(_classPrivateFieldGet2(_dateTimeValue, this));
}
return [type, value];
}
}]);
}(BaseValue);
function _validateAndSetType(type, dateTimeValue) {
if (typeof dateTimeValue === "undefined" || typeof type === "undefined") throw new MissingArgument("Value and type for DateTimeType must be supplied");else if (!/^(?:(?:date((?:andor)?(?:time))?)|(?:time(?:stamp)?)|(?:utcoffset))$/.test(type)) throw new InvalidArgument("Accepted values of type for DateTimeType are date, time, datetime, dateandortime, timestamp or utcoffset");else if ("".concat(dateTimeValue).length > _classPrivateFieldGet2(_MAX_DATETIMEVALUE_LEN, this)) throw new InvalidArgument("The value must not exceed ".concat(_classPrivateFieldGet2(_MAX_DATETIMEVALUE_LEN, this), " characters"));
switch (type) {
case "date":
if (!_classPrivateFieldGet2(_dateRegExp, this).test(dateTimeValue)) throw new InvalidArgument("Invalid value for type date of DateTimeType");
this.type = "DATE";
break;
case "time":
if (!_classPrivateFieldGet2(_timeRegExp, this).test(dateTimeValue)) throw new InvalidArgument("Invalid value for type time of DateTimeType");
this.type = "TIME";
break;
case "datetime":
if (!_classPrivateFieldGet2(_dateTimeRegExp, this).test(dateTimeValue)) throw new InvalidArgument("Invalid value for type datetime of DateTimeType");
this.type = "DATE-TIME";
break;
case "dateandortime":
if (!_classPrivateFieldGet2(_dateAndOrTimeRegExp, this).test(dateTimeValue)) throw new InvalidArgument("Invalid value for type dateandortime of DateTimeType");
this.type = "DATE-AND-OR-TIME";
break;
case "timestamp":
if (!_classPrivateFieldGet2(_timestampRegExp, this).test(dateTimeValue)) throw new InvalidArgument("Invalid value for type timestamp of DateTimeType");
this.type = "TIMESTAMP";
break;
case "utcoffset":
if (!_classPrivateFieldGet2(_utcOffsetRegExp, this).test(dateTimeValue)) throw new InvalidArgument("Invalid value for type utcoffset of DateTimeType");
this.type = "UTC-OFFSET";
break;
default:
throw new InvalidArgument("Accepted values for type property of type object for DateTimeType are date, time, datetime, dateandortime, timestamp or utcoffset");
}
}
_defineProperty(DateTimeType, "identifier", "DateTimeType");
Object.freeze(DateTimeType);
var _datetimelist = /*#__PURE__*/new WeakMap();
var _DateTimeListType_brand = /*#__PURE__*/new WeakSet();
var DateTimeListType = /*#__PURE__*/function (_BaseValue) {
function DateTimeListType(_datetimelist2) {
var _this;
_classCallCheck(this, DateTimeListType);
_this = _callSuper(this, DateTimeListType);
_classPrivateMethodInitSpec(_this, _DateTimeListType_brand);
_classPrivateFieldInitSpec(_this, _datetimelist, void 0);
_assertClassBrand(_DateTimeListType_brand, _this, _validate$16).call(_this, _datetimelist2);
_classPrivateFieldSet2(_datetimelist, _this, _datetimelist2);
_this.type = _datetimelist2[0]["type"];
_this.checkAbstractPropertiesAndMethods();
Object.freeze(_this);
return _this;
}
_inherits(DateTimeListType, _BaseValue);
return _createClass(DateTimeListType, [{
key: "value",
get: function get() {
return _classPrivateFieldGet2(_datetimelist, this).reduce(function (accumulatedDateTimeTypes, currentDateTimeType) {
accumulatedDateTimeTypes.push(currentDateTimeType.repr());
return accumulatedDateTimeTypes;
}, []).join(",");
}
}, {
key: "valueXML",
get: function get() {
return _classPrivateFieldGet2(_datetimelist, this).reduce(function (accumulatedDateTimeTypes, currentDateTimeType) {
return accumulatedDateTimeTypes + currentDateTimeType.reprXML();
}, "");
}
}, {
key: "valueJSON",
get: function get() {
var value = _classPrivateFieldGet2(_datetimelist, this).reduce(function (accumulatedIntegerTypes, currentIntegerType) {
accumulatedIntegerTypes.push(currentIntegerType.reprJSON().pop());
return accumulatedIntegerTypes;
}, []);
value.unshift(this.type.toLowerCase());
return value;
}
}]);
}(BaseValue);
function _validate$16(datetimelist) {
if (typeof datetimelist === "undefined") throw new MissingArgument("Value for DateTimeListType must be supplied");else if (!Array.isArray(datetimelist)) throw new TypeError("Value for DateTimeListType should be passed in an array");
var conformType = datetimelist[0]["type"];
var _iterator = _createForOfIteratorHelper(datetimelist),
_step;
try {
for (_iterator.s(); !(_step = _iterator.n()).done;) {
var datetime = _step.value;
if (datetime.type !== conformType) throw new TypeError("Value for DateTimeListType should be an array of DateTimeTypes of the same type");else if (datetime.type === "UTC-OFFSET") throw new TypeError("Invalid type for value of DateTimeListType");else if (datetime.constructor.identifier !== "DateTimeType") throw new TypeError("Value for DateTimeListType should be an array of DateTimeTypes");
}
} catch (err) {
_iterator.e(err);
} finally {
_iterator.f();
}
}
_defineProperty(DateTimeListType, "identifier", "DateTimeListType");
Object.freeze(DateTimeListType);
var _intValue = /*#__PURE__*/new WeakMap();
var _IntegerType_brand = /*#__PURE__*/new WeakSet();
var IntegerType = /*#__PURE__*/function (_BaseValue) {
function IntegerType(_intValue2) {
var _this;
_classCallCheck(this, IntegerType);
_this = _callSuper(this, IntegerType);
_classPrivateMethodInitSpec(_this, _IntegerType_brand);
_classPrivateFieldInitSpec(_this, _intValue, void 0);
_assertClassBrand(_IntegerType_brand, _this, _validate$15).call(_this, _intValue2);
_classPrivateFieldSet2(_intValue, _this, _intValue2);
_this.checkAbstractPropertiesAndMethods();
Object.freeze(_this);
return _this;
}
_inherits(IntegerType, _BaseValue);
return _createClass(IntegerType, [{
key: "value",
get: function get() {
return "".concat(_classPrivateFieldGet2(_intValue, this));
}
}, {
key: "valueXML",
get: function get() {
return "<".concat(this.constructor.type.toLowerCase(), ">").concat(_classPrivateFieldGet2(_intValue, this), "</").concat(this.constructor.type.toLowerCase(), ">");
}
}, {
key: "valueJSON",
get: function get() {
return [this.constructor.type.toLowerCase(), _classPrivateFieldGet2(_intValue, this)];
}
}]);
}(BaseValue);
function _validate$15(intValue) {
if (typeof intValue === "undefined") throw new MissingArgument("Value for IntegerType must be supplied");else if (typeof intValue !== "number" && typeof intValue !== "bigint") throw new TypeError("Value for IntegerType must be of type number or bigint");else if (/\./.test(intValue.toString())) throw new InvalidArgument("Invalid value for IntegerType");else if (typeof intValue === "number" && !(-Number.MAX_SAFE_INTEGER < intValue && intValue < Number.MAX_SAFE_INTEGER)) throw new InvalidArgument("The maximum value is ".concat(Number.MAX_SAFE_INTEGER, ", and the minimum value is ").concat(Number.MIN_SAFE_INTEGER, " for number IntegerType"));else if (typeof intValue === "bigint" && !(-9223372036854775809n < intValue && intValue < 9223372036854775808n)) throw new InvalidArgument("The maximum value is 9223372036854775807n, and the minimum value is -9223372036854775808n for bigint IntegerType");
}
_defineProperty(IntegerType, "type", "INTEGER");
_defineProperty(IntegerType, "identifier", "IntegerType");
Object.freeze(IntegerType);
var _integerlist = /*#__PURE__*/new WeakMap();
var _IntegerListType_brand = /*#__PURE__*/new WeakSet();
var IntegerListType = /*#__PURE__*/function (_BaseValue) {
function IntegerListType(_integerlist2) {
var _this;
_classCallCheck(this, IntegerListType);
_this = _callSuper(this, IntegerListType);
_classPrivateMethodInitSpec(_this, _IntegerListType_brand);
_classPrivateFieldInitSpec(_this, _integerlist, void 0);
_assertClassBrand(_IntegerListType_brand, _this, _validate$14).call(_this, _integerlist2);
_classPrivateFieldSet2(_integerlist, _this, _integerlist2);
_this.checkAbstractPropertiesAndMethods();
Object.freeze(_this);
return _this;
}
_inherits(IntegerListType, _BaseValue);
return _createClass(IntegerListType, [{
key: "value",
get: function get() {
return _classPrivateFieldGet2(_integerlist, this).reduce(function (accumulatedIntegerTypes, currentIntegerType) {
accumulatedIntegerTypes.push(currentIntegerType.repr());
return accumulatedIntegerTypes;
}, []).join(",");
}
}, {
key: "valueXML",
get: function get() {
return _classPrivateFieldGet2(_integerlist, this).reduce(function (accumulatedIntegerTypes, currentIntegerType) {
return accumulatedIntegerTypes + currentIntegerType.reprXML();
}, "");
}
}, {
key: "valueJSON",
get: function get() {
var value = _classPrivateFieldGet2(_integerlist, this).reduce(function (accumulatedIntegerTypes, currentIntegerType) {
accumulatedIntegerTypes.push(currentIntegerType.reprJSON().pop());
return accumulatedIntegerTypes;
}, []);
value.unshift(this.constructor.type.toLowerCase());
return value;
}
}]);
}(BaseValue);
function _validate$14(integerlist) {
if (typeof integerlist === "undefined") throw new MissingArgument("Value for IntegerListType must be supplied");else if (!Array.isArray(integerlist)) throw new TypeError("Value for IntegerListType must be passed in an array");
var _iterator = _createForOfIteratorHelper(integerlist),
_step;
try {
for (_iterator.s(); !(_step = _iterator.n()).done;) {
var integer = _step.value;
if (integer.constructor.identifier !== "IntegerType") throw new TypeError("Invalid type for value of IntegerListType. It should be an array of IntegerTypes");
}
} catch (err) {
_iterator.e(err);
} finally {
_iterator.f();
}
}
_defineProperty(IntegerListType, "type", "INTEGER");
_defineProperty(IntegerListType, "identifier", "IntegerListType");
Object.freeze(IntegerListType);
var _floatValue = /*#__PURE__*/new WeakMap();
var _FloatType_brand = /*#__PURE__*/new WeakSet();
var FloatType = /*#__PURE__*/function (_BaseValue) {
function FloatType(_floatValue2) {
var _this;
_classCallCheck(this, FloatType);
_this = _callSuper(this, FloatType);
_classPrivateMethodInitSpec(_this, _FloatType_brand);
_classPrivateFieldInitSpec(_this, _floatValue, void 0);
_assertClassBrand(_FloatType_brand, _this, _validate$13).call(_this, _floatValue2);
_classPrivateFieldSet2(_floatValue, _this, _floatValue2);
_this.checkAbstractPropertiesAndMethods();
Object.freeze(_this);
return _this;
}
_inherits(FloatType, _BaseValue);
return _createClass(FloatType, [{
key: "value",
get: function get() {
return "".concat(_classPrivateFieldGet2(_floatValue, this));
}
}, {
key: "valueXML",
get: function get() {
return "<".concat(this.constructor.type.toLowerCase(), ">").concat(_classPrivateFieldGet2(_floatValue, this), "</").concat(this.constructor.type.toLowerCase(), ">");
}
}, {
key: "valueJSON",
get: function get() {
return [this.constructor.type.toLowerCase(), _classPrivateFieldGet2(_floatValue, this)];
}
}]);
}(BaseValue);
function _validate$13(floatValue) {
if (typeof floatValue === "undefined") throw new MissingArgument("Value for FloatType must be supplied");
if (!(typeof floatValue === "number") && !/\./.test(floatValue) || !/^[-+]?\d+\.\d+$/.test(floatValue)) throw new TypeError("Invalid value for FloatType");
}
_defineProperty(FloatType, "type", "FLOAT");
_defineProperty(FloatType, "identifier", "FloatType");
Object.freeze(FloatType);
var _floatlist = /*#__PURE__*/new WeakMap();
var _FloatListType_brand = /*#__PURE__*/new WeakSet();
var FloatListType = /*#__PURE__*/function (_BaseValue) {
function FloatListType(_floatlist2) {
var _this;
_classCallCheck(this, FloatListType);
_this = _callSuper(this, FloatListType);
_classPrivateMethodInitSpec(_this, _FloatListType_brand);
_classPrivateFieldInitSpec(_this, _floatlist, void 0);
_assertClassBrand(_FloatListType_brand, _this, _validate$12).call(_this, _floatlist2);
_classPrivateFieldSet2(_floatlist, _this, _floatlist2);
_this.checkAbstractPropertiesAndMethods();
Object.freeze(_this);
return _this;
}
_inherits(FloatListType, _BaseValue);
return _createClass(FloatListType, [{
key: "value",
get: function get() {
return _classPrivateFieldGet2(_floatlist, this).reduce(function (accumulatedFloatTypes, currentFloatType) {
accumulatedFloatTypes.push(currentFloatType.repr());
return accumulatedFloatTypes;
}, []).join(",");
}
}, {
key: "valueXML",
get: function get() {
return _classPrivateFieldGet2(_floatlist, this).reduce(function (accumulatedFloatTypes, currentFloatType) {
return accumulatedFloatTypes + currentFloatType.reprXML();
}, "");
}
}, {
key: "valueJSON",
get: function get() {
var value = _classPrivateFieldGet2(_floatlist, this).reduce(function (accumulatedFloatTypes, currentFloatType) {
accumulatedFloatTypes.push(currentFloatType.reprJSON().pop());
return accumulatedFloatTypes;
}, []);
value.unshift(this.constructor.type.toLowerCase());
return value;
}
}]);
}(BaseValue);
function _validate$12(floatlist) {
if (typeof floatlist === "undefined") throw new MissingArgument("Value for FloatListType must be supplied");else if (!Array.isArray(floatlist)) throw new TypeError("Value of FloatListType should be passed in an array");
var _iterator = _createForOfIteratorHelper(floatlist),
_step;
try {
for (_iterator.s(); !(_step = _iterator.n()).done;) {
var _float = _step.value;
if (_float.constructor.identifier !== "FloatType") throw new TypeError("Value of FloatListType should be an array of FloatTypes");
}
} catch (err) {
_iterator.e(err);
} finally {
_iterator.f();
}
}
_defineProperty(FloatListType, "type", "FLOAT");
_defineProperty(FloatListType, "identifier", "FloatListType");
Object.freeze(FloatListType);
var _langTagValue = /*#__PURE__*/new WeakMap();
var _langTagRegexp = /*#__PURE__*/new WeakMap();
var _MAX_LANGTAGVALUE_LEN = /*#__PURE__*/new WeakMap();
var _LanguageTagType_brand = /*#__PURE__*/new WeakSet();
var LanguageTagType = /*#__PURE__*/function (_BaseValue) {
function LanguageTagType(_langTagValue2) {
var _this;
_classCallCheck(this, LanguageTagType);
_this = _callSuper(this, LanguageTagType);
_classPrivateMethodInitSpec(_this, _LanguageTagType_brand);
_classPrivateFieldInitSpec(_this, _langTagValue, void 0);
_classPrivateFieldInitSpec(_this, _langTagRegexp, /^(?:[a-zA-Z]{2,3}(-[a-zA-Z]{3}){0,3})(-[0-9A-Za-z]+){0,3}(-x(-[0-9A-Za-z]{1,8})+)?(-[0-9A-WY-Za-wy-z]+)?(-[0-9A-Za-z]+)?$/);
_classPrivateFieldInitSpec(_this, _MAX_LANGTAGVALUE_LEN, 255);
_assertClassBrand(_LanguageTagType_brand, _this, _validate$11).call(_this, _langTagValue2);
_classPrivateFieldSet2(_langTagValue, _this, _langTagValue2);
_this.checkAbstractPropertiesAndMethods();
Object.freeze(_this);
return _this;
}
_inherits(LanguageTagType, _BaseValue);
return _createClass(LanguageTagType, [{
key: "value",
get: function get() {
return _classPrivateFieldGet2(_langTagValue, this);
}
}, {
key: "valueXML",
get: function get() {
return "<".concat(this.constructor.type.toLowerCase(), ">").concat(_classPrivateFieldGet2(_langTagValue, this), "</").concat(this.constructor.type.toLowerCase(), ">");
}
}, {
key: "valueJSON",
get: function get() {
return [this.constructor.type.toLowerCase(), _classPrivateFieldGet2(_langTagValue, this)];
}
}]);
}(BaseValue);
function _validate$11(langTagValue) {
if (typeof langTagValue === "undefined") throw new MissingArgument("Value for LanguageTagType must be supplied");else if (typeof langTagValue !== "string") throw new TypeError("Value for LanguageTagType should be of type string");else if (langTagValue.length > _classPrivateFieldGet2(_MAX_LANGTAGVALUE_LEN, this)) throw new InvalidArgument("Value for LanguageTagType must not exceed ".concat(_classPrivateFieldGet2(_MAX_LANGTAGVALUE_LEN, this), " characters"));else if (!_classPrivateFieldGet2(_langTagRegexp, this).test(langTagValue)) throw new InvalidArgument("Invalid language tag");
}
_defineProperty(LanguageTagType, "type", "LANGUAGE-TAG");
_defineProperty(LanguageTagType, "identifier", "LanguageTagType");
Object.freeze(LanguageTagType);
var _uriValue = /*#__PURE__*/new WeakMap();
var _URIType_brand = /*#__PURE__*/new WeakSet();
var URIType = /*#__PURE__*/function (_BaseValue) {
function URIType(_uriValue2) {
var _this;
_classCallCheck(this, URIType);
_this = _callSuper(this, URIType);
_classPrivateMethodInitSpec(_this, _URIType_brand);
_classPrivateFieldInitSpec(_this, _uriValue, void 0);
_assertClassBrand(_URIType_brand, _this, _validate$10).call(_this, _uriValue2);
_classPrivateFieldSet2(_uriValue, _this, _uriValue2);
_this.checkAbstractPropertiesAndMethods();
Object.freeze(_this);
return _this;
}
_inherits(URIType, _BaseValue);
return _createClass(URIType, [{
key: "value",
get: function get() {
return _classPrivateFieldGet2(_uriValue, this);
}
}, {
key: "valueXML",
get: function get() {
return "<".concat(this.constructor.type.toLowerCase(), ">").concat(_classPrivateFieldGet2(_uriValue, this), "</").concat(this.constructor.type.toLowerCase(), ">");
}
}, {
key: "valueJSON",
get: function get() {
return [this.constructor.type.toLowerCase(), _classPrivateFieldGet2(_uriValue, this)];
}
}]);
}(BaseValue);
function _validate$10(uriValue) {
if (typeof uriValue === "undefined") throw new MissingArgument("Value for URIType must be supplied");else if (typeof uriValue !== "string") throw new TypeError("Value for URIType should be of type string");else if (!URL.canParse(uriValue)) throw new InvalidArgument("Invalid URI");
}
_defineProperty(URIType, "type", "URI");
_defineProperty(URIType, "identifier", "URIType");
Object.freeze(URIType);
var _sexRegExp = /*#__PURE__*/new WeakMap();
var _sexValue = /*#__PURE__*/new WeakMap();
var _SexType_brand = /*#__PURE__*/new WeakSet();
var SexType = /*#__PURE__*/function (_BaseValue) {
function SexType(_sexValue2) {
var _this;
_classCallCheck(this, SexType);
_this = _callSuper(this, SexType);
_classPrivateMethodInitSpec(_this, _SexType_brand);
_classPrivateFieldInitSpec(_this, _sexRegExp, /^[MFONU]$/);
_classPrivateFieldInitSpec(_this, _sexValue, void 0);
_assertClassBrand(_SexType_brand, _this, _validate$$).call(_this, _sexValue2);
_classPrivateFieldSet2(_sexValue, _this, _sexValue2);
_this.checkAbstractPropertiesAndMethods();
Object.freeze(_this);
return _this;
}
_inherits(SexType, _BaseValue);
return _createClass(SexType, [{
key: "value",
get: function get() {
return _classPrivateFieldGet2(_sexValue, this);
}
}, {
key: "valueXML",
get: function get() {
return "<sex>".concat(_classPrivateFieldGet2(_sexValue, this), "</sex>");
}
}, {
key: "valueJSON",
get: function get() {
return [this.constructor.type.toLowerCase(), _classPrivateFieldGet2(_sexValue, this)];
}
}]);
}(BaseValue);
function _validate$$(sexValue) {
if (typeof sexValue === "undefined") throw new MissingArgument("Value for SexType must be supplied");else if (!_classPrivateFieldGet2(_sexRegExp, this).test(sexValue)) throw new InvalidArgument("Invalid sex");
}
_defineProperty(SexType, "type", "TEXT");
_defineProperty(SexType, "identifier", "SexType");
Object.freeze(SexType);
var _SpecialValueType_brand = /*#__PURE__*/new WeakSet();
var SpecialValueType = /*#__PURE__*/function (_BaseValue) {
function SpecialValueType(_targetProp, _value) {
var _this;
_classCallCheck(this, SpecialValueType);
_this = _callSuper(this, SpecialValueType);
_classPrivateMethodInitSpec(_this, _SpecialValueType_brand);
_assertClassBrand(_SpecialValueType_brand, _this, _validateAndSet).call(_this, _targetProp, _value);
_this.targetProp = _targetProp.toUpperCase();
_this.checkAbstractPropertiesAndMethods();
Object.freeze(_this);
return _this;
}
_inherits(SpecialValueType, _BaseValue);
return _createClass(SpecialValueType);
}(BaseValue);
function _validateAndSet(targetProp, value) {
var _value$, _value$2;
if (typeof value === "undefined" || typeof targetProp === "undefined") throw new MissingArgument("Value and target property for SpecialValueType must be supplied");
var valueRegExp = /^(?:individual|group|org|location|application|x-[a-z0-9-]+)$/i;
var valueCopy;
var _tempValue;
switch (true) {
case /^KindProperty$/i.test(targetProp):
if (typeof value !== "string" || !valueRegExp.test(value)) throw new InvalidArgument("Invalid value for SpecialValueType for KindProperty");
this.value = value;
this.valueXML = "<text>".concat(value, "</text>");
this.valueJSON = [this.constructor.type.toLowerCase(), value];
break;
case /^NProperty$/i.test(targetProp):
if (!Array.isArray(value) || value.length !== 5) throw new InvalidArgument("Invalid value for SpecialValueType for NProperty. It should be an array with a length of 5");
for (var index = 0; index < value.length; index++) if (value[index]) if (value[index].constructor.identifier !== "TextType" && value[index].constructor.identifier !== "TextListType") throw new TypeError("Invalid value for SpecialValueType for NProperty. The items in the array, if present, should be of type TextType or TextListType");
valueCopy = _toConsumableArray(value);
for (var _index = 0; _index < valueCopy.length; _index++) if (valueCopy[_index]) valueCopy[_index] = valueCopy[_index].repr();
this.value = valueCopy.join(";");
this.valueXML = "";
this.valueJSON = [];
for (var _index2 = 0; _index2 < value.length; _index2++) switch (_index2) {
case 0:
if (!value[_index2]) {
this.valueXML += "<surname/>";
this.valueJSON[_index2] = "";
} else {
this.valueXML += value[_index2].reprXML().replaceAll("text>", "surname>");
_tempValue = value[_index2].reprJSON();
if (_tempValue.length === 2) this.valueJSON[_index2] = _tempValue.pop();else {
_tempValue.shift();
this.valueJSON[_index2] = _tempValue;
}
}
break;
case 1:
if (!value[_index2]) {
this.valueXML += "<given/>";
this.valueJSON[_index2] = "";
} else {
this.valueXML += value[_index2].reprXML().replaceAll("text>", "given>");
_tempValue = value[_index2].reprJSON();
if (_tempValue.length === 2) this.valueJSON[_index2] = _tempValue.pop();else {
_tempValue.shift();
this.valueJSON[_index2] = _tempValue;
}
}
break;
case 2:
if (!value[_index2]) {
this.valueX