"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. var Enums = require("./enums"); exports.ContentTypes = { applicationJson: "application/json", applicationXWwwFormUrlencoded: "application/x-www-form-urlencoded" }; var StringWithSubstitutions = /** @class */ (function () { function StringWithSubstitutions() { this._isProcessed = false; this._original = null; this._processed = null; } StringWithSubstitutions.prototype.getReferencedInputs = function (inputs, referencedInputs) { if (!referencedInputs) { throw new Error("The referencedInputs parameter cannot be null."); } for (var _i = 0, inputs_1 = inputs; _i < inputs_1.length; _i++) { var input = inputs_1[_i]; var matches = new RegExp("\\{{2}(" + input.id + ").value\\}{2}", "gi").exec(this._original); if (matches != null) { referencedInputs[input.id] = input; } } }; StringWithSubstitutions.prototype.substituteInputValues = function (inputs, contentType) { this._processed = this._original; var regEx = /\{{2}([a-z0-9_$@]+).value\}{2}/gi; var matches; while ((matches = regEx.exec(this._original)) != null) { var matchedInput = null; for (var _i = 0, _a = Object.keys(inputs); _i < _a.length; _i++) { var key = _a[_i]; if (key.toLowerCase() == matches[1].toLowerCase()) { matchedInput = inputs[key]; break; } } if (matchedInput) { var valueForReplace = ""; if (matchedInput.value) { valueForReplace = matchedInput.value; } if (contentType === exports.ContentTypes.applicationJson) { valueForReplace = JSON.stringify(valueForReplace); valueForReplace = valueForReplace.slice(1, -1); } else if (contentType === exports.ContentTypes.applicationXWwwFormUrlencoded) { valueForReplace = encodeURIComponent(valueForReplace); } this._processed = this._processed.replace(matches[0], valueForReplace); } } ; this._isProcessed = true; }; StringWithSubstitutions.prototype.getOriginal = function () { return this._original; }; StringWithSubstitutions.prototype.get = function () { if (!this._isProcessed) { return this._original; } else { return this._processed; } }; StringWithSubstitutions.prototype.set = function (value) { this._original = value; this._isProcessed = false; }; return StringWithSubstitutions; }()); exports.StringWithSubstitutions = StringWithSubstitutions; var SpacingDefinition = /** @class */ (function () { function SpacingDefinition(top, right, bottom, left) { if (top === void 0) { top = 0; } if (right === void 0) { right = 0; } if (bottom === void 0) { bottom = 0; } if (left === void 0) { left = 0; } this.left = 0; this.top = 0; this.right = 0; this.bottom = 0; this.top = top; this.right = right; this.bottom = bottom; this.left = left; } return SpacingDefinition; }()); exports.SpacingDefinition = SpacingDefinition; var PaddingDefinition = /** @class */ (function () { function PaddingDefinition(top, right, bottom, left) { if (top === void 0) { top = Enums.Spacing.None; } if (right === void 0) { right = Enums.Spacing.None; } if (bottom === void 0) { bottom = Enums.Spacing.None; } if (left === void 0) { left = Enums.Spacing.None; } this.top = Enums.Spacing.None; this.right = Enums.Spacing.None; this.bottom = Enums.Spacing.None; this.left = Enums.Spacing.None; this.top = top; this.right = right; this.bottom = bottom; this.left = left; } return PaddingDefinition; }()); exports.PaddingDefinition = PaddingDefinition; var SizeAndUnit = /** @class */ (function () { function SizeAndUnit(physicalSize, unit) { this.physicalSize = physicalSize; this.unit = unit; } SizeAndUnit.parse = function (input, requireUnitSpecifier) { if (requireUnitSpecifier === void 0) { requireUnitSpecifier = false; } var result = new SizeAndUnit(0, Enums.SizeUnit.Weight); var regExp = /^([0-9]+)(px|\*)?$/g; var matches = regExp.exec(input); var expectedMatchCount = requireUnitSpecifier ? 3 : 2; if (matches && matches.length >= expectedMatchCount) { result.physicalSize = parseInt(matches[1]); if (matches.length == 3) { if (matches[2] == "px") { result.unit = Enums.SizeUnit.Pixel; } } return result; } throw new Error("Invalid size: " + input); }; return SizeAndUnit; }()); exports.SizeAndUnit = SizeAndUnit; /** * Fast UUID generator, RFC4122 version 4 compliant. * @author Jeff Ward (jcward.com). * @license MIT license * @link http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/21963136#21963136 **/ var UUID = /** @class */ (function () { function UUID() { } UUID.generate = function () { var d0 = Math.random() * 0xffffffff | 0; var d1 = Math.random() * 0xffffffff | 0; var d2 = Math.random() * 0xffffffff | 0; var d3 = Math.random() * 0xffffffff | 0; return UUID.lut[d0 & 0xff] + UUID.lut[d0 >> 8 & 0xff] + UUID.lut[d0 >> 16 & 0xff] + UUID.lut[d0 >> 24 & 0xff] + '-' + UUID.lut[d1 & 0xff] + UUID.lut[d1 >> 8 & 0xff] + '-' + UUID.lut[d1 >> 16 & 0x0f | 0x40] + UUID.lut[d1 >> 24 & 0xff] + '-' + UUID.lut[d2 & 0x3f | 0x80] + UUID.lut[d2 >> 8 & 0xff] + '-' + UUID.lut[d2 >> 16 & 0xff] + UUID.lut[d2 >> 24 & 0xff] + UUID.lut[d3 & 0xff] + UUID.lut[d3 >> 8 & 0xff] + UUID.lut[d3 >> 16 & 0xff] + UUID.lut[d3 >> 24 & 0xff]; }; UUID.initialize = function () { for (var i = 0; i < 256; i++) { UUID.lut[i] = (i < 16 ? '0' : '') + i.toString(16); } }; UUID.lut = []; return UUID; }()); exports.UUID = UUID; UUID.initialize(); //# sourceMappingURL=shared.js.map