From a87f59dfd8fff9e1921b9dbcf4270d180f9b72dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=ED=98=84=EC=84=B1=ED=95=84?= Date: Mon, 13 May 2024 20:37:46 +0900 Subject: [PATCH] Flat Message Layout --- .../controller/ApiClientController.java | 7 +- .../testmaster/client/entity/ApiLayout.java | 11 +++ .../client/mapper/ApiLayoutMapper.java | 29 ++++++++ .../client/service/ApiLayoutMgmtService.java | 2 +- .../loadtest/service/VirtualUser.java | 72 ++++++++++++++++--- .../plugins/apitestmanager/app.bundle.js | 6 +- 6 files changed, 111 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/eactive/testmaster/client/controller/ApiClientController.java b/src/main/java/com/eactive/testmaster/client/controller/ApiClientController.java index 78e7cbc..0dae17b 100644 --- a/src/main/java/com/eactive/testmaster/client/controller/ApiClientController.java +++ b/src/main/java/com/eactive/testmaster/client/controller/ApiClientController.java @@ -2,8 +2,8 @@ package com.eactive.testmaster.client.controller; import com.eactive.testmaster.client.dto.ApiRequestDTO; import com.eactive.testmaster.client.dto.ApiResponse; -import com.eactive.testmaster.client.service.ApiClient; import com.eactive.testmaster.client.service.ApiClientFactory; +import com.eactive.testmaster.loadtest.service.VirtualUser; import java.util.concurrent.ExecutionException; import org.springframework.validation.BindingResult; import org.springframework.validation.Validator; @@ -30,9 +30,8 @@ public class ApiClientController { if (bindingResult.hasErrors()) { throw new IllegalArgumentException(bindingResult.getAllErrors().get(0).getDefaultMessage()); } - - ApiClient client = apiClientFactory.getClient(request); - return client.handleRequest(request).get(); + VirtualUser virtualUser = new VirtualUser(request.getId(), apiClientFactory); + return virtualUser.processApiAndReturn(request); } } diff --git a/src/main/java/com/eactive/testmaster/client/entity/ApiLayout.java b/src/main/java/com/eactive/testmaster/client/entity/ApiLayout.java index a39434b..52f9925 100644 --- a/src/main/java/com/eactive/testmaster/client/entity/ApiLayout.java +++ b/src/main/java/com/eactive/testmaster/client/entity/ApiLayout.java @@ -7,6 +7,7 @@ import javax.persistence.Entity; import javax.persistence.FetchType; import javax.persistence.Id; import javax.persistence.JoinColumn; +import javax.persistence.Lob; import javax.persistence.ManyToOne; import javax.persistence.OneToMany; import javax.persistence.Table; @@ -47,6 +48,9 @@ public class ApiLayout { @OneToMany(mappedBy = "apiLayout", cascade = CascadeType.ALL, fetch = FetchType.LAZY, orphanRemoval = true) private List layoutItems = new ArrayList<>(); + @Lob + private String computedLayoutItemRoot; + public String getId() { return id; } @@ -164,4 +168,11 @@ public class ApiLayout { this.layoutItems.add(item); } + public String getComputedLayoutItemRoot() { + return computedLayoutItemRoot; + } + + public void setComputedLayoutItemRoot(String computedLayoutItemRoot) { + this.computedLayoutItemRoot = computedLayoutItemRoot; + } } diff --git a/src/main/java/com/eactive/testmaster/client/mapper/ApiLayoutMapper.java b/src/main/java/com/eactive/testmaster/client/mapper/ApiLayoutMapper.java index 026d1e8..f96a428 100644 --- a/src/main/java/com/eactive/testmaster/client/mapper/ApiLayoutMapper.java +++ b/src/main/java/com/eactive/testmaster/client/mapper/ApiLayoutMapper.java @@ -1,11 +1,13 @@ package com.eactive.testmaster.client.mapper; import com.eactive.testmaster.client.dto.ApiLayoutDTO; +import com.eactive.testmaster.client.dto.ApiLayoutItemDTO; import com.eactive.testmaster.client.entity.ApiLayout; import com.eactive.testmaster.client.entity.ApiRequestInfo; import com.eactive.testmaster.client.repository.ApiLayoutRepository; import com.eactive.testmaster.client.repository.ApiRequestRepository; import com.eactive.testmaster.common.mapper.CommonMapper; +import com.fasterxml.jackson.databind.ObjectMapper; import java.util.List; import org.mapstruct.Mapper; import org.mapstruct.Mapping; @@ -19,6 +21,8 @@ import org.springframework.stereotype.Component; @Component public abstract class ApiLayoutMapper { + ObjectMapper objectMapper = new ObjectMapper(); + @Autowired private ApiLayoutRepository apiLayoutRepository; @@ -32,6 +36,31 @@ public abstract class ApiLayoutMapper { @Mapping(target = "apiRequestId", source = "apiRequestInfo") public abstract ApiLayoutDTO map(ApiLayout entity); + + public String treeToString(ApiLayoutItemDTO value) { + if (value == null) { + return null; + } + try { + return objectMapper.writeValueAsString(value); + } catch (Exception e) { + throw new IllegalArgumentException("Failed to convert ApiLayoutItemDTO to JSON", e); + } + + } + + public ApiLayoutItemDTO stringToTree(String value) { + if (value == null) { + return null; + } + try { + return objectMapper.readValue(value, ApiLayoutItemDTO.class); + } catch (Exception e) { + throw new IllegalArgumentException("Failed to convert JSON to ApiLayoutItemDTO", e); + } + + } + public ApiRequestInfo mapApiRequestInfo(String id) { if (id == null) { return null; diff --git a/src/main/java/com/eactive/testmaster/client/service/ApiLayoutMgmtService.java b/src/main/java/com/eactive/testmaster/client/service/ApiLayoutMgmtService.java index 4cb248c..b02c2c1 100644 --- a/src/main/java/com/eactive/testmaster/client/service/ApiLayoutMgmtService.java +++ b/src/main/java/com/eactive/testmaster/client/service/ApiLayoutMgmtService.java @@ -6,7 +6,6 @@ import com.eactive.testmaster.client.entity.ApiRequestInfo; import com.eactive.testmaster.client.repository.ApiLayoutRepository; import com.eactive.testmaster.client.repository.ApiRequestRepository; import com.eactive.testmaster.common.exception.NotFoundException; -import java.util.Optional; import java.util.UUID; import javax.transaction.Transactional; import org.springframework.stereotype.Service; @@ -64,6 +63,7 @@ public class ApiLayoutMgmtService { layout.setModfMgtStusDstCd(updatedLayout.getModfMgtStusDstCd()); layout.setUseYn(updatedLayout.getUseYn()); layout.setVerInfo(updatedLayout.getVerInfo()); + layout.setComputedLayoutItemRoot(updatedLayout.getComputedLayoutItemRoot()); if (updatedLayout.getLayoutItems() != null && !updatedLayout.getLayoutItems().isEmpty()) { layout.getLayoutItems().clear(); diff --git a/src/main/java/com/eactive/testmaster/loadtest/service/VirtualUser.java b/src/main/java/com/eactive/testmaster/loadtest/service/VirtualUser.java index eacf30c..bf9123e 100644 --- a/src/main/java/com/eactive/testmaster/loadtest/service/VirtualUser.java +++ b/src/main/java/com/eactive/testmaster/loadtest/service/VirtualUser.java @@ -36,8 +36,8 @@ public class VirtualUser implements Runnable { private Thread runningThread; - private final LoadTestService loadTestService; - private final ApiClientFactory apiClientFactory; + private LoadTestService loadTestService; + private ApiClientFactory apiClientFactory; private static Map globals = new ConcurrentHashMap<>(); private Map variables = new ConcurrentHashMap<>(); @@ -57,7 +57,11 @@ public class VirtualUser implements Runnable { this.maxCount = maxCount; this.apiClientFactory = apiClientFactory; this.latch = latch; + } + public VirtualUser(String testId, ApiClientFactory apiClientFactory) { + this.testId = testId; + this.apiClientFactory = apiClientFactory; } public void pause() { @@ -130,7 +134,7 @@ public class VirtualUser implements Runnable { visitedNodes.add(currentNode); if (currentNode.getClassName().equalsIgnoreCase("api")) { - processApi(currentNode); + processApi(currentNode.getApiRequest()); } if (currentNode.getConnections() != null && !currentNode.getConnections().isEmpty()) { @@ -143,10 +147,35 @@ public class VirtualUser implements Runnable { logger.debug("Action performed or interrupted"); } - private void processApi(ScenarioNode currentNode) { + + public ApiResponse processApiAndReturn(ApiRequestDTO apiRequest) { + ApiRequestDTO cloned = SerializationUtils.clone(apiRequest); + ApiRequestDTO replaced = null; + + executePreRequestScript(cloned); + replaced = replacePlaceHoldersWithVariables(cloned); + +// long startTime = System.currentTimeMillis(); + ApiResponse response = null; try { - if (currentNode.getApiRequest() != null) { - ApiRequestDTO cloned = SerializationUtils.clone(currentNode.getApiRequest()); + response = apiClientFactory.getClient(replaced).handleRequest(replaced).get(); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } catch (ExecutionException e) { + throw new RuntimeException(e); + } +// long endTime = System.currentTimeMillis(); +// long responseTime = endTime - startTime; + + executePostRequestScript(replaced, response); + + return response; + } + + public void processApi(ApiRequestDTO apiRequest) { + try { + if (apiRequest != null) { + ApiRequestDTO cloned = SerializationUtils.clone(apiRequest); ApiRequestDTO replaced = null; executePreRequestScript(cloned); @@ -175,7 +204,8 @@ public class VirtualUser implements Runnable { engine.put("variables", variables); engine.put("request", apiRequest); try { - engine.eval(apiRequest.getPreRequestScript()); + if(apiRequest.getPreRequestScript() != null) + engine.eval(apiRequest.getPreRequestScript()); } catch (ScriptException e) { logger.error("Error executing pre-request script", e); e.printStackTrace(); @@ -191,7 +221,9 @@ public class VirtualUser implements Runnable { engine.put("request", apiRequest); engine.put("response", response); try { - engine.eval(apiRequest.getPostRequestScript()); + if (apiRequest.getPostRequestScript() != null){ + engine.eval(apiRequest.getPostRequestScript()); + } } catch (ScriptException e) { logger.error("Error executing post-request script", e); e.printStackTrace(); @@ -227,14 +259,38 @@ public class VirtualUser implements Runnable { if (apiRequest.getQueryParams() != null) { apiRequest.setQueryParams(replaceInList(apiRequest.getQueryParams(), placeholder, value)); } + if (apiRequest.getLayout() != null && apiRequest.getLayout().getLayoutItems() != null) { apiRequest.getLayout().setLayoutItems(replaceInLayoutItems(apiRequest.getLayout().getLayoutItems(), placeholder, value)); } + if (apiRequest.getLayout() !=null && apiRequest.getLayout().getComputedLayoutItemRoot() !=null){ + replaceLayoutItemTree(apiRequest.getLayout().getComputedLayoutItemRoot(), placeholder, value); + } } return apiRequest; } + private void replaceLayoutItemTree(ApiLayoutItemDTO computedLayoutItemRoot, String placeholder, String value) { + if (computedLayoutItemRoot == null) { + return; // Base case: if the node is null, just return. + } + + // Replace the value in the current node if it contains the placeholder + if (computedLayoutItemRoot.getValue() != null) { + String replacedValue = computedLayoutItemRoot.getValue().replaceAll(placeholder, value); + computedLayoutItemRoot.setValue(replacedValue); + } + + // Recursively replace the value in each child + if (computedLayoutItemRoot.getChildren() != null) { + for (ApiLayoutItemDTO child : computedLayoutItemRoot.getChildren()) { + replaceLayoutItemTree(child, placeholder, value); + } + } + } + + private List replaceInLayoutItems(List originalList, String placeholder, String value) { List replacedList = new ArrayList<>(); Pattern pattern = Pattern.compile(placeholder); diff --git a/src/main/resources/static/plugins/apitestmanager/app.bundle.js b/src/main/resources/static/plugins/apitestmanager/app.bundle.js index 50fb1d3..62a098b 100644 --- a/src/main/resources/static/plugins/apitestmanager/app.bundle.js +++ b/src/main/resources/static/plugins/apitestmanager/app.bundle.js @@ -587,7 +587,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\nfunction _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }\nfunction _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.\"); }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _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; } }\nfunction _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }\nfunction _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); }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(t) { var i = _toPrimitive(t, \"string\"); return \"symbol\" == _typeof(i) ? i : String(i); }\nfunction _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); }\n// const ZERO_WIDTH_SPACE = '​';\nvar ZERO_WIDTH_SPACE = '​';\nvar EditableInputModel = /*#__PURE__*/function () {\n function EditableInputModel() {\n var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';\n _classCallCheck(this, EditableInputModel);\n this.value = value;\n }\n _createClass(EditableInputModel, [{\n key: \"setValue\",\n value: function setValue(newValue) {\n this.value = newValue;\n }\n }, {\n key: \"getValue\",\n value: function getValue() {\n return this.value;\n }\n }]);\n return EditableInputModel;\n}();\nvar EditableInputView = /*#__PURE__*/function () {\n function EditableInputView(model, controller, options) {\n _classCallCheck(this, EditableInputView);\n this.model = model;\n this.controller = controller;\n this.options = options;\n }\n _createClass(EditableInputView, [{\n key: \"render\",\n value: function render(element) {\n this.element = element;\n this.element.innerHTML = this.generateInputHtml();\n this.editableDiv = this.element.querySelector('.editableInputContent');\n this.attachEventListeners();\n }\n }, {\n key: \"generateInputHtml\",\n value: function generateInputHtml() {\n var contentHtml = this.model.getValue() ? this.renderContent(this.parseContent(this.model.getValue())) : ZERO_WIDTH_SPACE;\n var styleString = '';\n if (this.options.style && _typeof(this.options.style) === 'object') {\n var styles = Object.entries(this.options.style);\n styleString = styles.map(function (_ref) {\n var _ref2 = _slicedToArray(_ref, 2),\n prop = _ref2[0],\n value = _ref2[1];\n return \"\".concat(prop, \": \").concat(value, \";\");\n }).join(' ');\n }\n var style = styleString ? \"style=\\\"\".concat(styleString, \"\\\"\") : '';\n return \"\\n
\\n \").concat(contentHtml, \"\\n
\\n \");\n }\n }, {\n key: \"attachEventListeners\",\n value: function attachEventListeners() {\n var _this = this;\n this.editableDiv.addEventListener('input', function (event) {\n _this.controller.handleInput(_this.editableDiv);\n if (_this.controller.additionalCallback) {\n _this.controller.additionalCallback(_this.model.getValue());\n }\n });\n this.editableDiv.addEventListener('paste', function (event) {\n event.preventDefault();\n if (navigator.clipboard && navigator.clipboard.readText) {\n navigator.clipboard.readText().then(function (text) {\n _this.insertTextAtCursor(text);\n })[\"catch\"](function (err) {\n console.error('Failed to read clipboard contents: ', err);\n // Fallback to using clipboardData from the paste event\n var text = (event.clipboardData || window.clipboardData).getData('text');\n _this.insertTextAtCursor(text);\n });\n } else {\n var text = (event.clipboardData || window.clipboardData).getData('text');\n _this.insertTextAtCursor(text);\n }\n });\n }\n }, {\n key: \"insertTextAtCursor\",\n value: function insertTextAtCursor(text) {\n var selection = window.getSelection();\n if (!selection.rangeCount) return;\n var range = selection.getRangeAt(0);\n range.deleteContents();\n var textNode = document.createTextNode(text);\n range.insertNode(textNode);\n range.setStartAfter(textNode);\n range.setEndAfter(textNode);\n selection.removeAllRanges();\n selection.addRange(range);\n this.controller.handleInput(this.editableDiv);\n }\n }, {\n key: \"updateUI\",\n value: function updateUI() {\n var content = this.model.getValue();\n if (content) {\n this.editableDiv.innerHTML = this.renderContent(this.parseContent(content));\n } else {\n this.editableDiv.innerHTML = ZERO_WIDTH_SPACE; // Insert a zero-width space\n }\n this.editableDiv.setAttribute('data-value', content);\n }\n }, {\n key: \"renderContent\",\n value: function renderContent(contentArray) {\n var content = '';\n contentArray.forEach(function (item) {\n if (item.startsWith('{{') && item.endsWith('}}')) {\n content += \"\".concat(item, \"\");\n } else {\n content += \"\".concat(item, \"\");\n }\n });\n return content;\n }\n }, {\n key: \"parseContent\",\n value: function parseContent(inputString) {\n var returnStringArray = [];\n var regex = /{{.*?}}/g;\n var lastIndex = 0;\n inputString.replace(regex, function (match, index) {\n // Add the string before the match\n if (index > lastIndex) {\n returnStringArray.push(inputString.slice(lastIndex, index));\n }\n\n // Add the matched string including the delimiters\n returnStringArray.push(match);\n\n // Update lastIndex for the next iteration\n lastIndex = index + match.length;\n });\n\n // Add any remaining string after the last match\n if (lastIndex < inputString.length) {\n returnStringArray.push(inputString.slice(lastIndex));\n }\n return returnStringArray;\n }\n }]);\n return EditableInputView;\n}();\nvar EditableInputController = /*#__PURE__*/function () {\n function EditableInputController(model, options) {\n _classCallCheck(this, EditableInputController);\n this.model = model;\n this.view = new EditableInputView(this.model, this, options);\n }\n _createClass(EditableInputController, [{\n key: \"init\",\n value: function init(element, callback) {\n this.view.render(element);\n this.additionalCallback = callback;\n }\n }, {\n key: \"getCurrentCursor\",\n value: function getCurrentCursor(element) {\n var selection = window.getSelection();\n if (selection.rangeCount === 0) return null;\n var range = selection.getRangeAt(0);\n var preCaretRange = range.cloneRange();\n preCaretRange.selectNodeContents(element);\n preCaretRange.setEnd(range.endContainer, range.endOffset);\n var content = preCaretRange.toString().trim();\n if (content === \"\\u200B\") {\n return 0; // Return 0 if the content is only the zero-width space character\n }\n console.log(content);\n return content.replace(\"\\u200B\", '').length;\n }\n }, {\n key: \"handleInput\",\n value: function handleInput(editableDiv) {\n // Check and remove zero-width space if it's the only content\n if (editableDiv.innerHTML === '​') {\n editableDiv.innerHTML = '';\n }\n var cursor = this.getCurrentCursor(editableDiv);\n var mergedString = Array.from(editableDiv.childNodes).filter(function (node) {\n // Keep only SPAN elements and text nodes\n return node.nodeName.toUpperCase() === 'SPAN' || node.nodeType === 3;\n }).map(function (node) {\n return node.nodeType === 3 ? node.data.trim() : node.innerText.trim();\n }).join('');\n var result = mergedString.replace(/[\\u200B-\\u200D\\uFEFF]/g, '');\n var content = this.parseContent(result);\n this.model.setValue(content.join(''));\n // Optionally, update the view if needed\n this.view.updateUI();\n this.restoreCursor(editableDiv, cursor);\n }\n }, {\n key: \"restoreCursor\",\n value: function restoreCursor(element, position) {\n var selection = window.getSelection();\n var range = document.createRange();\n range.setStart(element, 0);\n range.collapse(true);\n var nodeStack = [element];\n var node,\n foundStart = false,\n stop = false;\n var charIndex = 0;\n console.log('restoreCursor', position);\n while (!stop && (node = nodeStack.pop())) {\n if (node.nodeType === 3) {\n console.log(node);\n var nextCharIndex = charIndex + node.length;\n if (!foundStart && position >= charIndex && position <= nextCharIndex) {\n range.setStart(node, position - charIndex);\n foundStart = true;\n }\n if (foundStart && position >= charIndex && position <= nextCharIndex) {\n range.setEnd(node, position - charIndex);\n stop = true;\n }\n charIndex = nextCharIndex;\n } else {\n var i = node.childNodes.length;\n while (i--) {\n nodeStack.push(node.childNodes[i]);\n }\n }\n }\n selection.removeAllRanges();\n selection.addRange(range);\n }\n }, {\n key: \"parseContent\",\n value: function parseContent(inputString) {\n var returnStringArray = [];\n var regex = /{{.*?}}/g;\n var lastIndex = 0;\n inputString.replace(regex, function (match, index) {\n // Add the string before the match\n if (index > lastIndex) {\n returnStringArray.push(inputString.slice(lastIndex, index));\n }\n\n // Add the matched string including the delimiters\n returnStringArray.push(match);\n\n // Update lastIndex for the next iteration\n lastIndex = index + match.length;\n });\n\n // Add any remaining string after the last match\n if (lastIndex < inputString.length) {\n returnStringArray.push(inputString.slice(lastIndex));\n }\n return returnStringArray;\n }\n }, {\n key: \"updateUI\",\n value: function updateUI() {\n this.view.updateUI();\n }\n }]);\n return EditableInputController;\n}();\nvar EditableInput = /*#__PURE__*/function () {\n function EditableInput() {\n var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n _classCallCheck(this, EditableInput);\n // Initialize the model with the value\n this.model = new EditableInputModel(options.value || '');\n this.controller = new EditableInputController(this.model, options);\n\n // Additional properties as required\n this.name = options.name || '';\n this.id = options.id || '';\n this[\"class\"] = options[\"class\"] || 'form-control';\n this.placeholder = options.placeholder || '';\n }\n _createClass(EditableInput, [{\n key: \"init\",\n value: function init(element, callback) {\n // Initialize the controller with the DOM element\n this.controller.init(element, callback);\n }\n }, {\n key: \"getValue\",\n value: function getValue() {\n // Delegate to the model\n return this.model.getValue();\n }\n }, {\n key: \"setValue\",\n value: function setValue(newValue) {\n // Delegate to the model and update the view\n this.model.setValue(newValue);\n this.controller.updateUI();\n }\n\n // Any additional methods required for interaction with this component\n }]);\n return EditableInput;\n}();\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (EditableInput);\n\n//# sourceURL=webpack://APITestManager/./src/components/EditableInput.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\nfunction _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }\nfunction _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.\"); }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _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; } }\nfunction _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }\nfunction _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); }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(t) { var i = _toPrimitive(t, \"string\"); return \"symbol\" == _typeof(i) ? i : String(i); }\nfunction _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); }\n// const ZERO_WIDTH_SPACE = '​';\nvar ZERO_WIDTH_SPACE = '​';\nvar EditableInputModel = /*#__PURE__*/function () {\n function EditableInputModel() {\n var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';\n _classCallCheck(this, EditableInputModel);\n this.value = value;\n }\n _createClass(EditableInputModel, [{\n key: \"setValue\",\n value: function setValue(newValue) {\n this.value = newValue;\n }\n }, {\n key: \"getValue\",\n value: function getValue() {\n return this.value;\n }\n }]);\n return EditableInputModel;\n}();\nvar EditableInputView = /*#__PURE__*/function () {\n function EditableInputView(model, controller, options) {\n _classCallCheck(this, EditableInputView);\n this.model = model;\n this.controller = controller;\n this.options = options;\n }\n _createClass(EditableInputView, [{\n key: \"render\",\n value: function render(element) {\n this.element = element;\n this.element.innerHTML = this.generateInputHtml();\n this.editableDiv = this.element.querySelector('.editableInputContent');\n this.attachEventListeners();\n }\n }, {\n key: \"generateInputHtml\",\n value: function generateInputHtml() {\n var contentHtml = this.model.getValue() ? this.renderContent(this.parseContent(this.model.getValue())) : ZERO_WIDTH_SPACE;\n var styleString = '';\n if (this.options.style && _typeof(this.options.style) === 'object') {\n var styles = Object.entries(this.options.style);\n styleString = styles.map(function (_ref) {\n var _ref2 = _slicedToArray(_ref, 2),\n prop = _ref2[0],\n value = _ref2[1];\n return \"\".concat(prop, \": \").concat(value, \";\");\n }).join(' ');\n }\n var style = styleString ? \"style=\\\"\".concat(styleString, \"\\\"\") : '';\n return \"\\n
\\n \").concat(contentHtml, \"\\n
\\n \");\n }\n }, {\n key: \"attachEventListeners\",\n value: function attachEventListeners() {\n var _this = this;\n this.editableDiv.addEventListener('input', function (event) {\n _this.controller.handleInput(_this.editableDiv);\n if (_this.controller.additionalCallback) {\n _this.controller.additionalCallback(_this.model.getValue());\n }\n });\n this.editableDiv.addEventListener('paste', function (event) {\n event.preventDefault();\n if (navigator.clipboard && navigator.clipboard.readText) {\n navigator.clipboard.readText().then(function (text) {\n _this.insertTextAtCursor(text);\n })[\"catch\"](function (err) {\n console.error('Failed to read clipboard contents: ', err);\n // Fallback to using clipboardData from the paste event\n var text = (event.clipboardData || window.clipboardData).getData('text');\n _this.insertTextAtCursor(text);\n });\n } else {\n var text = (event.clipboardData || window.clipboardData).getData('text');\n _this.insertTextAtCursor(text);\n }\n });\n }\n }, {\n key: \"insertTextAtCursor\",\n value: function insertTextAtCursor(text) {\n var selection = window.getSelection();\n if (!selection.rangeCount) return;\n var range = selection.getRangeAt(0);\n range.deleteContents();\n var textNode = document.createTextNode(text);\n range.insertNode(textNode);\n range.setStartAfter(textNode);\n range.setEndAfter(textNode);\n selection.removeAllRanges();\n selection.addRange(range);\n this.controller.handleInput(this.editableDiv);\n }\n }, {\n key: \"updateUI\",\n value: function updateUI() {\n var content = this.model.getValue();\n if (content) {\n this.editableDiv.innerHTML = this.renderContent(this.parseContent(content));\n } else {\n this.editableDiv.innerHTML = ZERO_WIDTH_SPACE; // Insert a zero-width space\n }\n this.editableDiv.setAttribute('data-value', content);\n }\n }, {\n key: \"renderContent\",\n value: function renderContent(contentArray) {\n var content = '';\n contentArray.forEach(function (item) {\n if (item.startsWith('{{') && item.endsWith('}}')) {\n content += \"\".concat(item, \"\");\n } else {\n content += \"\".concat(item, \"\");\n }\n });\n return content;\n }\n }, {\n key: \"parseContent\",\n value: function parseContent(inputString) {\n var returnStringArray = [];\n var regex = /{{.*?}}/g;\n var lastIndex = 0;\n inputString.replace(regex, function (match, index) {\n // Add the string before the match\n if (index > lastIndex) {\n returnStringArray.push(inputString.slice(lastIndex, index));\n }\n\n // Add the matched string including the delimiters\n returnStringArray.push(match);\n\n // Update lastIndex for the next iteration\n lastIndex = index + match.length;\n });\n\n // Add any remaining string after the last match\n if (lastIndex < inputString.length) {\n returnStringArray.push(inputString.slice(lastIndex));\n }\n return returnStringArray;\n }\n }]);\n return EditableInputView;\n}();\nvar EditableInputController = /*#__PURE__*/function () {\n function EditableInputController(model, options) {\n _classCallCheck(this, EditableInputController);\n this.model = model;\n this.view = new EditableInputView(this.model, this, options);\n }\n _createClass(EditableInputController, [{\n key: \"init\",\n value: function init(element, callback) {\n this.view.render(element);\n this.additionalCallback = callback;\n }\n }, {\n key: \"getCurrentCursor\",\n value: function getCurrentCursor(element) {\n var selection = window.getSelection();\n if (selection.rangeCount === 0) return null;\n var range = selection.getRangeAt(0);\n var preCaretRange = range.cloneRange();\n preCaretRange.selectNodeContents(element);\n preCaretRange.setEnd(range.endContainer, range.endOffset);\n var content = preCaretRange.toString().trim();\n if (content === \"\\u200B\") {\n return 0; // Return 0 if the content is only the zero-width space character\n }\n return content.replace(\"\\u200B\", '').length;\n }\n }, {\n key: \"handleInput\",\n value: function handleInput(editableDiv) {\n // Check and remove zero-width space if it's the only content\n if (editableDiv.innerHTML === '​') {\n editableDiv.innerHTML = '';\n }\n var cursor = this.getCurrentCursor(editableDiv);\n var mergedString = Array.from(editableDiv.childNodes).filter(function (node) {\n // Keep only SPAN elements and text nodes\n return node.nodeName.toUpperCase() === 'SPAN' || node.nodeType === 3;\n }).map(function (node) {\n return node.nodeType === 3 ? node.data.trim() : node.innerText.trim();\n }).join('');\n var result = mergedString.replace(/[\\u200B-\\u200D\\uFEFF]/g, '');\n var content = this.parseContent(result);\n this.model.setValue(content.join(''));\n // Optionally, update the view if needed\n this.view.updateUI();\n this.restoreCursor(editableDiv, cursor);\n }\n }, {\n key: \"restoreCursor\",\n value: function restoreCursor(element, position) {\n var selection = window.getSelection();\n var range = document.createRange();\n range.setStart(element, 0);\n range.collapse(true);\n var nodeStack = [element];\n var node,\n foundStart = false,\n stop = false;\n var charIndex = 0;\n while (!stop && (node = nodeStack.pop())) {\n if (node.nodeType === 3) {\n var nextCharIndex = charIndex + node.length;\n if (!foundStart && position >= charIndex && position <= nextCharIndex) {\n range.setStart(node, position - charIndex);\n foundStart = true;\n }\n if (foundStart && position >= charIndex && position <= nextCharIndex) {\n range.setEnd(node, position - charIndex);\n stop = true;\n }\n charIndex = nextCharIndex;\n } else {\n var i = node.childNodes.length;\n while (i--) {\n nodeStack.push(node.childNodes[i]);\n }\n }\n }\n selection.removeAllRanges();\n selection.addRange(range);\n }\n }, {\n key: \"parseContent\",\n value: function parseContent(inputString) {\n var returnStringArray = [];\n var regex = /{{.*?}}/g;\n var lastIndex = 0;\n inputString.replace(regex, function (match, index) {\n // Add the string before the match\n if (index > lastIndex) {\n returnStringArray.push(inputString.slice(lastIndex, index));\n }\n\n // Add the matched string including the delimiters\n returnStringArray.push(match);\n\n // Update lastIndex for the next iteration\n lastIndex = index + match.length;\n });\n\n // Add any remaining string after the last match\n if (lastIndex < inputString.length) {\n returnStringArray.push(inputString.slice(lastIndex));\n }\n return returnStringArray;\n }\n }, {\n key: \"updateUI\",\n value: function updateUI() {\n this.view.updateUI();\n }\n }]);\n return EditableInputController;\n}();\nvar EditableInput = /*#__PURE__*/function () {\n function EditableInput() {\n var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n _classCallCheck(this, EditableInput);\n // Initialize the model with the value\n this.model = new EditableInputModel(options.value || '');\n this.controller = new EditableInputController(this.model, options);\n\n // Additional properties as required\n this.name = options.name || '';\n this.id = options.id || '';\n this[\"class\"] = options[\"class\"] || 'form-control';\n this.placeholder = options.placeholder || '';\n }\n _createClass(EditableInput, [{\n key: \"init\",\n value: function init(element, callback) {\n // Initialize the controller with the DOM element\n this.controller.init(element, callback);\n }\n }, {\n key: \"getValue\",\n value: function getValue() {\n // Delegate to the model\n return this.model.getValue();\n }\n }, {\n key: \"setValue\",\n value: function setValue(newValue) {\n // Delegate to the model and update the view\n this.model.setValue(newValue);\n this.controller.updateUI();\n }\n\n // Any additional methods required for interaction with this component\n }]);\n return EditableInput;\n}();\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (EditableInput);\n\n//# sourceURL=webpack://APITestManager/./src/components/EditableInput.js?"); /***/ }), @@ -620,7 +620,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var _EditableInput__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./EditableInput */ \"./src/components/EditableInput.js\");\n/* harmony import */ var _APIClient__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../APIClient */ \"./src/APIClient.js\");\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, 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 normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }\nfunction _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, \"next\", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, \"throw\", err); } _next(undefined); }); }; }\nfunction _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); }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(t) { var i = _toPrimitive(t, \"string\"); return \"symbol\" == _typeof(i) ? i : String(i); }\nfunction _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); }\n\n\nvar LayoutTreeDataGridModel = /*#__PURE__*/function () {\n function LayoutTreeDataGridModel(root, apiRequest) {\n _classCallCheck(this, LayoutTreeDataGridModel);\n this.dataRoot = root;\n this.apiRequest = apiRequest;\n console.log('LayoutTreeDataGridModel', this.dataRoot);\n }\n _createClass(LayoutTreeDataGridModel, [{\n key: \"getNodePath\",\n value: function getNodePath(node, targetId) {\n var path = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';\n // Check if the current node is the target node\n if (node.id === targetId) {\n return path;\n }\n\n // If the current node has children, iterate over them\n if (node.children) {\n for (var i = 0; i < node.children.length; i++) {\n // Construct the path to the current child\n var currentPath = path ? \"\".concat(path, \".children[\").concat(i, \"]\") : \"children[\".concat(i, \"]\");\n\n // Recursively call findPath on the child\n var resultPath = this.getNodePath(node.children[i], targetId, currentPath);\n\n // If resultPath is not null, the target has been found in the subtree\n if (resultPath) {\n return resultPath;\n }\n }\n }\n\n // Return null if the target is not found in this subtree\n return null;\n }\n }]);\n return LayoutTreeDataGridModel;\n}();\nvar LayoutTreeDataGridView = /*#__PURE__*/function () {\n function LayoutTreeDataGridView(selector) {\n _classCallCheck(this, LayoutTreeDataGridView);\n console.log({\n selector: selector\n });\n this.table = $('').appendTo($(selector));\n this.table.addClass('layout_table');\n this.table.css({\n 'width': 'inherit',\n 'border-collapse': 'collapse',\n 'border': '1px gray solid'\n });\n console.log(this.table);\n }\n _createClass(LayoutTreeDataGridView, [{\n key: \"addHeaders\",\n value: function addHeaders(fields) {\n var thead = $('').appendTo(this.table);\n var tr = $('').appendTo(thead);\n tr.addClass('layout-grid-row');\n fields.forEach(function (field) {\n var th = $('').addClass('treegrid-' + node.id).data('nodeId', node.id); // Storing node ID for easy access later\n\n if (depth === 0) {\n tr.css({\n 'display': 'none'\n });\n }\n if (node.parent) {\n var parentSelector = \".treegrid-\".concat(node.parent);\n var lastChildSelector = \".treegrid-parent-\".concat(node.parent);\n if ($(this.view.table).find(lastChildSelector).length > 0) {\n var lastChild = $(this.view.table).find(lastChildSelector).last();\n tr.insertAfter(lastChild);\n } else {\n tr.insertAfter($(this.view.table).find(parentSelector));\n }\n tr.addClass('treegrid-parent-' + node.parent);\n } else {\n tr.appendTo(this.view.table);\n }\n return tr;\n }\n\n //processNode in bfs\n }, {\n key: \"processNode\",\n value: function processNode(node, depth) {\n var _this3 = this;\n var queue = [{\n node: node,\n depth: depth\n }];\n var _loop = function _loop() {\n var _queue$shift = queue.shift(),\n node = _queue$shift.node,\n depth = _queue$shift.depth;\n var tr = _this3.addRow(node, depth);\n _this3.options.forEach(function (fieldInfo) {\n var content = node[fieldInfo.name];\n var td = _this3.addCell(tr, node, fieldInfo, depth);\n if (fieldInfo.isFirst) {\n if (node.children && node.children.length > 0) {\n _this3.view.setupExpander($(tr.children()[0]), function () {\n return _this3.handleExpanderClick(node.id);\n });\n }\n }\n if (fieldInfo.type !== 'textfield') {\n td.append(content);\n }\n });\n if (node.children && node.children.length > 0) {\n var _iterator3 = _createForOfIteratorHelper(node.children),\n _step3;\n try {\n for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {\n var child = _step3.value;\n queue.push({\n node: child,\n depth: depth + 1\n });\n }\n } catch (err) {\n _iterator3.e(err);\n } finally {\n _iterator3.f();\n }\n }\n };\n while (queue.length > 0) {\n _loop();\n }\n }\n }, {\n key: \"handleExpanderClick\",\n value: function handleExpanderClick(nodeId) {\n var expander = $(\".treegrid-\".concat(nodeId, \" .treegrid-expander\"));\n var isExpanded = expander.html() === '-';\n expander.html(isExpanded ? '+' : '-');\n this.view.toggleChildrenVisibility(nodeId, isExpanded);\n }\n }]);\n return LayoutTreeGridController;\n}();\nvar LayoutTreeDataGrid = /*#__PURE__*/function () {\n function LayoutTreeDataGrid(selector, root, apiRequest, options, totalMessageLengthSelector) {\n _classCallCheck(this, LayoutTreeDataGrid);\n this.model = new LayoutTreeDataGridModel(root, apiRequest);\n this.view = new LayoutTreeDataGridView(selector);\n this.controller = new LayoutTreeGridController(this.model, this.view, options, totalMessageLengthSelector);\n }\n _createClass(LayoutTreeDataGrid, [{\n key: \"init\",\n value: function init(callback) {\n this.controller.init(callback);\n }\n }, {\n key: \"rebuild\",\n value: function rebuild(dataRoot) {\n this.controller.rebuild(dataRoot);\n }\n }]);\n return LayoutTreeDataGrid;\n}();\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (LayoutTreeDataGrid);\n\n//# sourceURL=webpack://APITestManager/./src/components/LayoutTreeDataGrid.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var _EditableInput__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./EditableInput */ \"./src/components/EditableInput.js\");\n/* harmony import */ var _APIClient__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../APIClient */ \"./src/APIClient.js\");\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, 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 normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }\nfunction _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, \"next\", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, \"throw\", err); } _next(undefined); }); }; }\nfunction _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); }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(t) { var i = _toPrimitive(t, \"string\"); return \"symbol\" == _typeof(i) ? i : String(i); }\nfunction _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); }\n\n\nvar LayoutTreeDataGridModel = /*#__PURE__*/function () {\n function LayoutTreeDataGridModel(root, apiRequest) {\n _classCallCheck(this, LayoutTreeDataGridModel);\n this.dataRoot = root;\n this.apiRequest = apiRequest;\n console.log('LayoutTreeDataGridModel', this.dataRoot);\n }\n _createClass(LayoutTreeDataGridModel, [{\n key: \"getNodePath\",\n value: function getNodePath(node, targetId) {\n var path = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';\n // Check if the current node is the target node\n if (node.id === targetId) {\n return path;\n }\n\n // If the current node has children, iterate over them\n if (node.children) {\n for (var i = 0; i < node.children.length; i++) {\n // Construct the path to the current child\n var currentPath = path ? \"\".concat(path, \".children[\").concat(i, \"]\") : \"children[\".concat(i, \"]\");\n\n // Recursively call findPath on the child\n var resultPath = this.getNodePath(node.children[i], targetId, currentPath);\n\n // If resultPath is not null, the target has been found in the subtree\n if (resultPath) {\n return resultPath;\n }\n }\n }\n\n // Return null if the target is not found in this subtree\n return null;\n }\n }]);\n return LayoutTreeDataGridModel;\n}();\nvar LayoutTreeDataGridView = /*#__PURE__*/function () {\n function LayoutTreeDataGridView(selector) {\n _classCallCheck(this, LayoutTreeDataGridView);\n console.log({\n selector: selector\n });\n this.table = $('
').html(field.label).appendTo(tr);\n th.css({\n 'width': field.width + 'px',\n 'border': '1px gray solid',\n 'text-align': 'center'\n });\n });\n }\n }, {\n key: \"toggleChildrenVisibility\",\n value: function toggleChildrenVisibility(nodeId, isExpanded) {\n var _this = this;\n var selector = \".treegrid-parent-\".concat(nodeId);\n $(selector).each(function (_, el) {\n $(el).toggle(!isExpanded);\n if (isExpanded) {\n // If we are hiding the children\n var childNodeId = $(el).data('nodeId'); // Assume data-nodeId is set when rows are created\n _this.toggleChildrenVisibility(childNodeId, true); // Recursively hide all descendants\n var expander = $(\".treegrid-\".concat(nodeId, \" .treegrid-expander\"));\n expander.html(isExpanded ? '+' : '-');\n }\n });\n }\n }, {\n key: \"setupExpander\",\n value: function setupExpander(cell, callback) {\n var expander = $('').addClass('treegrid-expander').html('-').appendTo(cell);\n expander.click(callback);\n }\n }]);\n return LayoutTreeDataGridView;\n}();\nvar LayoutTreeGridController = /*#__PURE__*/function () {\n function LayoutTreeGridController(model, view, options, totalMessageLengthSelector) {\n _classCallCheck(this, LayoutTreeGridController);\n this.model = model;\n this.view = view;\n this.options = options;\n this.apiClient = new _APIClient__WEBPACK_IMPORTED_MODULE_1__[\"default\"]();\n this.totalMessageLengthSelector = totalMessageLengthSelector;\n }\n _createClass(LayoutTreeGridController, [{\n key: \"init\",\n value: function init(callback) {\n this.view.addHeaders(this.options);\n this.processNode(this.model.dataRoot, 0);\n this.setupEditableFields();\n this.callback = callback;\n }\n }, {\n key: \"rebuild\",\n value: function () {\n var _rebuild = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(dataRoot) {\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n this.model.dataRoot = dataRoot;\n this.view.table.children().remove();\n this.view.addHeaders(this.options);\n this.processNode(this.model.dataRoot, 0);\n this.setupEditableFields();\n _context.t0 = this;\n _context.next = 8;\n return this.concatenateFieldValues(this.model.dataRoot);\n case 8:\n _context.t1 = _context.sent;\n _context.t0.callback.call(_context.t0, _context.t1);\n case 10:\n case \"end\":\n return _context.stop();\n }\n }, _callee, this);\n }));\n function rebuild(_x) {\n return _rebuild.apply(this, arguments);\n }\n return rebuild;\n }()\n }, {\n key: \"getIndent\",\n value: function getIndent(depth) {\n return new Array(depth + 1).join('');\n }\n }, {\n key: \"fillPadding\",\n value: function () {\n var _fillPadding = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(value, dataLength) {\n var paddedValue;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return this.apiClient.processPreScriptAndVariables(this.model.apiRequest, value.toString());\n case 2:\n paddedValue = _context2.sent;\n while (paddedValue.length < dataLength) {\n paddedValue = ' ' + paddedValue; // Prepend a space character to the string\n }\n return _context2.abrupt(\"return\", paddedValue);\n case 5:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2, this);\n }));\n function fillPadding(_x2, _x3) {\n return _fillPadding.apply(this, arguments);\n }\n return fillPadding;\n }()\n }, {\n key: \"concatenateFieldValues\",\n value: function () {\n var _concatenateFieldValues = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(node) {\n var concatenatedValues, _iterator, _step, child;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n concatenatedValues = ''; // Process the current node if it is of type 'Field'\n if (!(node.loutItemType === 'Field')) {\n _context3.next = 9;\n break;\n }\n _context3.t0 = concatenatedValues;\n _context3.next = 5;\n return this.fillPadding(node.value, node.loutItemLength);\n case 5:\n _context3.t1 = _context3.sent;\n if (_context3.t1) {\n _context3.next = 8;\n break;\n }\n _context3.t1 = '';\n case 8:\n concatenatedValues = _context3.t0 += _context3.t1;\n case 9:\n if (!(node.children && node.children.length > 0)) {\n _context3.next = 29;\n break;\n }\n _iterator = _createForOfIteratorHelper(node.children);\n _context3.prev = 11;\n _iterator.s();\n case 13:\n if ((_step = _iterator.n()).done) {\n _context3.next = 21;\n break;\n }\n child = _step.value;\n _context3.t2 = concatenatedValues;\n _context3.next = 18;\n return this.concatenateFieldValues(child);\n case 18:\n concatenatedValues = _context3.t2 += _context3.sent;\n case 19:\n _context3.next = 13;\n break;\n case 21:\n _context3.next = 26;\n break;\n case 23:\n _context3.prev = 23;\n _context3.t3 = _context3[\"catch\"](11);\n _iterator.e(_context3.t3);\n case 26:\n _context3.prev = 26;\n _iterator.f();\n return _context3.finish(26);\n case 29:\n return _context3.abrupt(\"return\", concatenatedValues);\n case 30:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3, this, [[11, 23, 26, 29]]);\n }));\n function concatenateFieldValues(_x4) {\n return _concatenateFieldValues.apply(this, arguments);\n }\n return concatenateFieldValues;\n }()\n }, {\n key: \"sumFieldLoutItemLengths\",\n value: function sumFieldLoutItemLengths() {\n var queue = [this.model.dataRoot];\n var sum = 0;\n while (queue.length > 0) {\n var node = queue.shift();\n if (node.loutItemType === 'Field') {\n sum += parseInt(node.loutItemLength) || 0; // Add the loutItemLength of the node, or 0 if undefined\n }\n if (node.children && node.children.length > 0) {\n var _iterator2 = _createForOfIteratorHelper(node.children),\n _step2;\n try {\n for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {\n var child = _step2.value;\n queue.push(child);\n }\n } catch (err) {\n _iterator2.e(err);\n } finally {\n _iterator2.f();\n }\n }\n }\n return sum;\n }\n }, {\n key: \"setupEditableFields\",\n value: function setupEditableFields() {\n var _this2 = this;\n this.view.table.find('.editable').each(function (index, editableElement) {\n var editableInput = new _EditableInput__WEBPACK_IMPORTED_MODULE_0__[\"default\"]({\n name: editableElement.dataset.name,\n value: editableElement.dataset.value,\n path: editableElement.dataset.path\n });\n editableInput.init(editableElement, /*#__PURE__*/function () {\n var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(value) {\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n console.log(editableElement.dataset.path);\n console.log(value);\n _.set(_this2.model.dataRoot, editableElement.dataset.path, value);\n console.log(_this2.model.dataRoot);\n _context4.t0 = _this2;\n _context4.next = 7;\n return _this2.concatenateFieldValues(_this2.model.dataRoot);\n case 7:\n _context4.t1 = _context4.sent;\n _context4.t0.callback.call(_context4.t0, _context4.t1);\n case 9:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n return function (_x5) {\n return _ref.apply(this, arguments);\n };\n }());\n });\n this.totalMessageLengthSelector.text(this.sumFieldLoutItemLengths());\n }\n }, {\n key: \"addCell\",\n value: function addCell(row, node, fieldInfo, depth) {\n var td = $('').appendTo(row);\n var padding = fieldInfo.isFirst ? this.getIndent(depth) : '';\n var nodePath = this.model.getNodePath(this.model.dataRoot, node.id) + '.value';\n if (node.loutItemType === 'Field' && fieldInfo.type === 'textfield') {\n var div = $('
');\n div.addClass('editable');\n div.appendTo(td);\n div.attr('data-name', fieldInfo.name);\n div.attr('data-value', node[fieldInfo.name]);\n div.attr('data-path', nodePath);\n } else {\n td.html(padding); // Default to just displaying the content\n }\n if (fieldInfo.width) {\n td.css({\n 'width': fieldInfo.width + 'px',\n 'border': '1px gray solid'\n });\n }\n if (fieldInfo.align) {\n td.css({\n 'text-align': fieldInfo.align\n });\n }\n return td;\n }\n }, {\n key: \"addRow\",\n value: function addRow(node, depth) {\n var tr = $('
').appendTo($(selector));\n this.table.addClass('layout_table');\n this.table.css({\n 'width': 'inherit',\n 'border-collapse': 'collapse',\n 'border': '1px gray solid'\n });\n console.log(this.table);\n }\n _createClass(LayoutTreeDataGridView, [{\n key: \"addHeaders\",\n value: function addHeaders(fields) {\n var thead = $('').appendTo(this.table);\n var tr = $('').appendTo(thead);\n tr.addClass('layout-grid-row');\n fields.forEach(function (field) {\n var th = $('').addClass('treegrid-' + node.id).data('nodeId', node.id); // Storing node ID for easy access later\n\n if (depth === 0) {\n tr.css({\n 'display': 'none'\n });\n }\n if (node.parent) {\n var parentSelector = \".treegrid-\".concat(node.parent);\n var lastChildSelector = \".treegrid-parent-\".concat(node.parent);\n if ($(this.view.table).find(lastChildSelector).length > 0) {\n var lastChild = $(this.view.table).find(lastChildSelector).last();\n tr.insertAfter(lastChild);\n } else {\n tr.insertAfter($(this.view.table).find(parentSelector));\n }\n tr.addClass('treegrid-parent-' + node.parent);\n } else {\n tr.appendTo(this.view.table);\n }\n return tr;\n }\n\n //processNode in bfs\n }, {\n key: \"processNode\",\n value: function processNode(node, depth) {\n var _this3 = this;\n var queue = [{\n node: node,\n depth: depth\n }];\n var _loop = function _loop() {\n var _queue$shift = queue.shift(),\n node = _queue$shift.node,\n depth = _queue$shift.depth;\n var tr = _this3.addRow(node, depth);\n _this3.options.forEach(function (fieldInfo) {\n var content = node[fieldInfo.name];\n var td = _this3.addCell(tr, node, fieldInfo, depth);\n if (fieldInfo.isFirst) {\n if (node.children && node.children.length > 0) {\n _this3.view.setupExpander($(tr.children()[0]), function () {\n return _this3.handleExpanderClick(node.id);\n });\n }\n }\n if (fieldInfo.type !== 'textfield') {\n td.append(content);\n }\n });\n if (node.children && node.children.length > 0) {\n var _iterator3 = _createForOfIteratorHelper(node.children),\n _step3;\n try {\n for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {\n var child = _step3.value;\n queue.push({\n node: child,\n depth: depth + 1\n });\n }\n } catch (err) {\n _iterator3.e(err);\n } finally {\n _iterator3.f();\n }\n }\n };\n while (queue.length > 0) {\n _loop();\n }\n }\n }, {\n key: \"handleExpanderClick\",\n value: function handleExpanderClick(nodeId) {\n var expander = $(\".treegrid-\".concat(nodeId, \" .treegrid-expander\"));\n var isExpanded = expander.html() === '-';\n expander.html(isExpanded ? '+' : '-');\n this.view.toggleChildrenVisibility(nodeId, isExpanded);\n }\n }]);\n return LayoutTreeGridController;\n}();\nvar LayoutTreeDataGrid = /*#__PURE__*/function () {\n function LayoutTreeDataGrid(selector, root, apiRequest, options, totalMessageLengthSelector) {\n _classCallCheck(this, LayoutTreeDataGrid);\n this.model = new LayoutTreeDataGridModel(root, apiRequest);\n this.view = new LayoutTreeDataGridView(selector);\n this.controller = new LayoutTreeGridController(this.model, this.view, options, totalMessageLengthSelector);\n }\n _createClass(LayoutTreeDataGrid, [{\n key: \"init\",\n value: function init(callback) {\n this.controller.init(callback);\n }\n }, {\n key: \"rebuild\",\n value: function rebuild(dataRoot) {\n this.controller.rebuild(dataRoot);\n }\n }]);\n return LayoutTreeDataGrid;\n}();\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (LayoutTreeDataGrid);\n\n//# sourceURL=webpack://APITestManager/./src/components/LayoutTreeDataGrid.js?"); /***/ }), @@ -708,7 +708,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var _LayoutGrid__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./LayoutGrid */ \"./src/components/LayoutGrid.js\");\n/* harmony import */ var _LayoutTreeGrid__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./LayoutTreeGrid */ \"./src/components/LayoutTreeGrid.js\");\n/* harmony import */ var _LayoutTreeDataGrid__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./LayoutTreeDataGrid */ \"./src/components/LayoutTreeDataGrid.js\");\n/* harmony import */ var monaco_editor__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! monaco-editor */ \"include-loader!./node_modules/monaco-editor/esm/vs/editor/editor.main.js\");\n/* harmony import */ var _ApiLayoutItemTreeBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ApiLayoutItemTreeBuilder */ \"./src/components/ApiLayoutItemTreeBuilder.js\");\n/* harmony import */ var _ApiLayoutItemTreeDataBuilder__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ApiLayoutItemTreeDataBuilder */ \"./src/components/ApiLayoutItemTreeDataBuilder.js\");\nfunction _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); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }\nfunction _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, \"next\", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, \"throw\", err); } _next(undefined); }); }; }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(t) { var i = _toPrimitive(t, \"string\"); return \"symbol\" == _typeof(i) ? i : String(i); }\nfunction _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); }\n\n\n\n\n\n\nvar TCPClientView = /*#__PURE__*/function () {\n function TCPClientView(parent, serverManager, apiRequestTabContent, model, index) {\n _classCallCheck(this, TCPClientView);\n this.parent = parent;\n this.serverManager = serverManager;\n this.apiRequestTabContent = apiRequestTabContent;\n this.model = model;\n this.index = index;\n this.server = this.serverManager.getServer(this.model.server);\n }\n _createClass(TCPClientView, [{\n key: \"init\",\n value: function init() {\n var _this = this;\n console.log('TCPClientView init');\n this.apiRequestTabContent.append(this.tcpApiRequestTemplate(this.model, this.index));\n if (this.server && this.server.headers === undefined) {\n this.server.headers = [];\n }\n if (this.server) {\n this.serverManager.renderTcpServerOptions('.server_options', this.server.serverOptions, this.model.headers, this.parent);\n }\n var layoutJson = JSON.stringify(this.model.layout, null, 2);\n this.layoutJsonEditor = monaco_editor__WEBPACK_IMPORTED_MODULE_3__.editor.create(this.apiRequestTabContent.find(\"#api_request_\".concat(this.model.id)).find('.layout-json')[0], {\n value: layoutJson,\n language: 'json',\n automaticLayout: true,\n quickSuggestions: false\n });\n var layoutDataTreeOptions = [{\n name: 'loutItemSerno',\n width: 100,\n isFirst: true,\n label: '#'\n }, {\n name: 'loutItemName',\n width: 100,\n align: 'left',\n label: '항목명(영문)'\n }, {\n name: 'loutItemDesc',\n width: 100,\n align: 'left',\n label: '항목설명'\n }, {\n name: 'loutItemDepth',\n width: 60,\n align: 'center',\n label: '깊이'\n }, {\n name: 'loutItemType',\n width: 100,\n align: 'center',\n label: '아이템 유형'\n }, {\n name: 'loutItemOccCnt',\n width: 100,\n align: 'center',\n label: '반복 횟수'\n }, {\n name: 'loutItemOccRef',\n width: 120,\n align: 'center',\n label: '반복 참조 필드'\n }, {\n name: 'loutItemLength',\n width: 100,\n align: 'center',\n label: '데이터 길이'\n }, {\n name: 'value',\n width: 200,\n align: 'left',\n label: '값',\n type: 'textfield'\n }];\n var layoutRoot = _ApiLayoutItemTreeBuilder__WEBPACK_IMPORTED_MODULE_4__[\"default\"].createTree(this.model.layout.layoutItems);\n var replicator = new _ApiLayoutItemTreeDataBuilder__WEBPACK_IMPORTED_MODULE_5__[\"default\"](10000);\n var layoutDataRoot = replicator.createReplicatedTree(layoutRoot);\n var layoutTreeDataGrid = new _LayoutTreeDataGrid__WEBPACK_IMPORTED_MODULE_2__[\"default\"](this.apiRequestTabContent.find(\"#api_request_\".concat(this.model.id)).find('.request_layout_data_tree'), layoutDataRoot, this.model, layoutDataTreeOptions, this.apiRequestTabContent.find(\"#api_request_\".concat(this.model.id)).find('.total_message_length'));\n layoutTreeDataGrid.init( /*#__PURE__*/function () {\n var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(finalMessage) {\n var prefix;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n if (!_this.server.serverOptions) {\n _context.next = 6;\n break;\n }\n _context.next = 3;\n return _this.serverManager.renderServerPrefix(_this.server.serverOptions, _this.model);\n case 3:\n _context.t0 = _context.sent;\n _context.next = 7;\n break;\n case 6:\n _context.t0 = '';\n case 7:\n prefix = _context.t0;\n _this.requestBodyEditor.setValue(prefix + finalMessage);\n case 9:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n return function (_x) {\n return _ref.apply(this, arguments);\n };\n }());\n var layoutTreeGrid = new _LayoutTreeGrid__WEBPACK_IMPORTED_MODULE_1__[\"default\"](this.apiRequestTabContent.find(\"#api_request_\".concat(this.model.id)).find('.request_layout_tree'), layoutRoot, layoutDataTreeOptions, function (root) {\n var replicator = new _ApiLayoutItemTreeDataBuilder__WEBPACK_IMPORTED_MODULE_5__[\"default\"](10000);\n var layoutDataRoot = replicator.createReplicatedTree(root);\n layoutTreeDataGrid.rebuild(layoutDataRoot);\n });\n var layoutGrid = new _LayoutGrid__WEBPACK_IMPORTED_MODULE_0__[\"default\"](this.apiRequestTabContent.find(\"#api_request_\".concat(this.model.id)).find('.request_layout'), this.model.layout, function (model) {\n model.items.forEach(function (item) {\n item.children = [];\n });\n var updatedRoot = _ApiLayoutItemTreeBuilder__WEBPACK_IMPORTED_MODULE_4__[\"default\"].createTree(model.items);\n layoutTreeGrid.rebuild(updatedRoot, function (root) {\n var replicator = new _ApiLayoutItemTreeDataBuilder__WEBPACK_IMPORTED_MODULE_5__[\"default\"](10000);\n var layoutDataRoot = replicator.createReplicatedTree(root);\n layoutTreeDataGrid.rebuild(layoutDataRoot);\n });\n _this.layoutJsonEditor.setValue(JSON.stringify(_this.model.layout, null, 2));\n $('span.variable').off('mouseover');\n $('span.variable').off('mouseout');\n document.querySelectorAll('span.variable').forEach(function (element) {\n var text = element.innerText;\n element.addEventListener('mouseover', function () {\n return _this.parent.showPopper(element, text);\n });\n element.addEventListener('mouseout', function () {\n return _this.parent.hidePopper(element);\n });\n });\n });\n this.apiRequestTabContent.find(\"#api_request_\".concat(this.model.id)).find('.load_layout').on('click', function () {\n try {\n _this.model.layout = JSON.parse(_this.layoutJsonEditor.getValue());\n _this.model.layout.layoutItems.forEach(function (item) {\n if (item.value === undefined) {\n item.value = '';\n }\n });\n console.log(_this.model);\n layoutGrid.rebuild(_this.model.layout);\n } catch (e) {\n console.error(e);\n alert(e);\n }\n });\n window.addEventListener('resize', this.resizeEditor.bind(this));\n }\n }, {\n key: \"resizeEditor\",\n value: function resizeEditor() {\n this.requestBodyEditor.layout({\n width: 0\n });\n this.requestBodyEditor.layout({});\n this.layoutJsonEditor.layout({\n width: 0\n });\n this.layoutJsonEditor.layout({});\n }\n }, {\n key: \"tcpApiRequestTemplate\",\n value: function tcpApiRequestTemplate(apiRequest, index) {\n console.log('tcpApiRequestTemplate');\n return \"\\n
\\n
\").concat(apiRequest.collectionName, \" > \").concat(apiRequest.name, \"
\\n
\\n
\\n \").concat(this.serverManager.renderTcpServers(apiRequest.server), \"\\n \\n
\\n \\n \\n
\\n
\\n
\\n
\\n
\\n
    \\n
  • \\n \\n
  • \\n
  • \\n \\n
  • \\n
  • \\n \\n
  • \\n
  • \\n \\n
  • \\n
  • \\n \\n
  • \\n
  • \\n \\n
  • \\n
\\n
\\n
\\n
\\n
\\n
\\n
\\n \\n
\\n
\\n
\\n
\\n
\\n \\n
\\n
\\n
\\n
\\n
\\n
\\n
\\n
\\n
\\n
\\n \\n
\\n
\\n
\\n
\\n
\\n
\\n
\\n
\\n
\\n
\\n
\\n
\\n
\\n
\\n
\\n
\\n
\\n
\\n
\\n
\\n
\\n
\\n
\\n
\\n
\\n
\\n
\\n
\\n \\uC804\\uCCB4 \\uBA54\\uC2DC\\uC9C0 \\uAE38\\uC774: \\n \\n
\\n
\\n
\\n
\\n
\\n Response\\n \\n \\n
\\n
    \\n
  • \\n \\n
  • \\n
  • \\n \\n
  • \\n
\\n
\\n
\\n
\\n
\\n
\\n
\\n
\\n
\\n
\\n
\\n
\\n \\n \");\n }\n }]);\n return TCPClientView;\n}();\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (TCPClientView);\n\n//# sourceURL=webpack://APITestManager/./src/components/TCPClientView.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var _LayoutGrid__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./LayoutGrid */ \"./src/components/LayoutGrid.js\");\n/* harmony import */ var _LayoutTreeGrid__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./LayoutTreeGrid */ \"./src/components/LayoutTreeGrid.js\");\n/* harmony import */ var _LayoutTreeDataGrid__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./LayoutTreeDataGrid */ \"./src/components/LayoutTreeDataGrid.js\");\n/* harmony import */ var monaco_editor__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! monaco-editor */ \"include-loader!./node_modules/monaco-editor/esm/vs/editor/editor.main.js\");\n/* harmony import */ var _ApiLayoutItemTreeBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ApiLayoutItemTreeBuilder */ \"./src/components/ApiLayoutItemTreeBuilder.js\");\n/* harmony import */ var _ApiLayoutItemTreeDataBuilder__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ApiLayoutItemTreeDataBuilder */ \"./src/components/ApiLayoutItemTreeDataBuilder.js\");\nfunction _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); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }\nfunction _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, \"next\", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, \"throw\", err); } _next(undefined); }); }; }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(t) { var i = _toPrimitive(t, \"string\"); return \"symbol\" == _typeof(i) ? i : String(i); }\nfunction _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); }\n\n\n\n\n\n\nvar TCPClientView = /*#__PURE__*/function () {\n function TCPClientView(parent, serverManager, apiRequestTabContent, model, index) {\n _classCallCheck(this, TCPClientView);\n this.parent = parent;\n this.serverManager = serverManager;\n this.apiRequestTabContent = apiRequestTabContent;\n this.model = model;\n this.index = index;\n this.server = this.serverManager.getServer(this.model.server);\n }\n _createClass(TCPClientView, [{\n key: \"init\",\n value: function init() {\n var _this = this;\n console.log('TCPClientView init');\n this.apiRequestTabContent.append(this.tcpApiRequestTemplate(this.model, this.index));\n if (this.server && this.server.headers === undefined) {\n this.server.headers = [];\n }\n if (this.server) {\n this.serverManager.renderTcpServerOptions('.server_options', this.server.serverOptions, this.model.headers, this.parent);\n }\n var layoutJson = JSON.stringify(this.model.layout, null, 2);\n this.layoutJsonEditor = monaco_editor__WEBPACK_IMPORTED_MODULE_3__.editor.create(this.apiRequestTabContent.find(\"#api_request_\".concat(this.model.id)).find('.layout-json')[0], {\n value: layoutJson,\n language: 'json',\n automaticLayout: true,\n quickSuggestions: false\n });\n var layoutDataTreeOptions = [{\n name: 'loutItemSerno',\n width: 100,\n isFirst: true,\n label: '#'\n }, {\n name: 'loutItemName',\n width: 100,\n align: 'left',\n label: '항목명(영문)'\n }, {\n name: 'loutItemDesc',\n width: 100,\n align: 'left',\n label: '항목설명'\n }, {\n name: 'loutItemDepth',\n width: 60,\n align: 'center',\n label: '깊이'\n }, {\n name: 'loutItemType',\n width: 100,\n align: 'center',\n label: '아이템 유형'\n }, {\n name: 'loutItemOccCnt',\n width: 100,\n align: 'center',\n label: '반복 횟수'\n }, {\n name: 'loutItemOccRef',\n width: 120,\n align: 'center',\n label: '반복 참조 필드'\n }, {\n name: 'loutItemLength',\n width: 100,\n align: 'center',\n label: '데이터 길이'\n }, {\n name: 'value',\n width: 200,\n align: 'left',\n label: '값',\n type: 'textfield'\n }];\n var layoutRoot = _ApiLayoutItemTreeBuilder__WEBPACK_IMPORTED_MODULE_4__[\"default\"].createTree(this.model.layout.layoutItems);\n var replicator = new _ApiLayoutItemTreeDataBuilder__WEBPACK_IMPORTED_MODULE_5__[\"default\"](10000);\n var layoutDataRoot = replicator.createReplicatedTree(layoutRoot);\n var layoutTreeDataGrid = new _LayoutTreeDataGrid__WEBPACK_IMPORTED_MODULE_2__[\"default\"](this.apiRequestTabContent.find(\"#api_request_\".concat(this.model.id)).find('.request_layout_data_tree'), layoutDataRoot, this.model, layoutDataTreeOptions, this.apiRequestTabContent.find(\"#api_request_\".concat(this.model.id)).find('.total_message_length'));\n layoutTreeDataGrid.init( /*#__PURE__*/function () {\n var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(finalMessage, layoutDataTree) {\n var prefix;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n if (!_this.server.serverOptions) {\n _context.next = 6;\n break;\n }\n _context.next = 3;\n return _this.serverManager.renderServerPrefix(_this.server.serverOptions, _this.model);\n case 3:\n _context.t0 = _context.sent;\n _context.next = 7;\n break;\n case 6:\n _context.t0 = '';\n case 7:\n prefix = _context.t0;\n _this.requestBodyEditor.setValue(prefix + finalMessage);\n _this.model.layout.computedLayoutItemRoot = layoutDataTree;\n case 10:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n return function (_x, _x2) {\n return _ref.apply(this, arguments);\n };\n }());\n var layoutTreeGrid = new _LayoutTreeGrid__WEBPACK_IMPORTED_MODULE_1__[\"default\"](this.apiRequestTabContent.find(\"#api_request_\".concat(this.model.id)).find('.request_layout_tree'), layoutRoot, layoutDataTreeOptions, function (root) {\n var replicator = new _ApiLayoutItemTreeDataBuilder__WEBPACK_IMPORTED_MODULE_5__[\"default\"](10000);\n var layoutDataRoot = replicator.createReplicatedTree(root);\n layoutTreeDataGrid.rebuild(layoutDataRoot);\n });\n var layoutGrid = new _LayoutGrid__WEBPACK_IMPORTED_MODULE_0__[\"default\"](this.apiRequestTabContent.find(\"#api_request_\".concat(this.model.id)).find('.request_layout'), this.model.layout, function (model) {\n model.items.forEach(function (item) {\n item.children = [];\n });\n var updatedRoot = _ApiLayoutItemTreeBuilder__WEBPACK_IMPORTED_MODULE_4__[\"default\"].createTree(model.items);\n layoutTreeGrid.rebuild(updatedRoot, function (root) {\n var replicator = new _ApiLayoutItemTreeDataBuilder__WEBPACK_IMPORTED_MODULE_5__[\"default\"](10000);\n var layoutDataRoot = replicator.createReplicatedTree(root);\n layoutTreeDataGrid.rebuild(layoutDataRoot);\n });\n _this.layoutJsonEditor.setValue(JSON.stringify(_this.model.layout, null, 2));\n $('span.variable').off('mouseover');\n $('span.variable').off('mouseout');\n document.querySelectorAll('span.variable').forEach(function (element) {\n var text = element.innerText;\n element.addEventListener('mouseover', function () {\n return _this.parent.showPopper(element, text);\n });\n element.addEventListener('mouseout', function () {\n return _this.parent.hidePopper(element);\n });\n });\n });\n this.apiRequestTabContent.find(\"#api_request_\".concat(this.model.id)).find('.load_layout').on('click', function () {\n try {\n _this.model.layout = JSON.parse(_this.layoutJsonEditor.getValue());\n _this.model.layout.layoutItems.forEach(function (item) {\n if (item.value === undefined) {\n item.value = '';\n }\n });\n console.log(_this.model);\n layoutGrid.rebuild(_this.model.layout);\n } catch (e) {\n console.error(e);\n alert(e);\n }\n });\n window.addEventListener('resize', this.resizeEditor.bind(this));\n }\n }, {\n key: \"resizeEditor\",\n value: function resizeEditor() {\n this.requestBodyEditor.layout({\n width: 0\n });\n this.requestBodyEditor.layout({});\n this.layoutJsonEditor.layout({\n width: 0\n });\n this.layoutJsonEditor.layout({});\n }\n }, {\n key: \"tcpApiRequestTemplate\",\n value: function tcpApiRequestTemplate(apiRequest, index) {\n console.log('tcpApiRequestTemplate');\n return \"\\n
\\n
\").concat(apiRequest.collectionName, \" > \").concat(apiRequest.name, \"
\\n
\\n
\\n \").concat(this.serverManager.renderTcpServers(apiRequest.server), \"\\n \\n
\\n \\n \\n
\\n
\\n
\\n
\\n
\\n
    \\n
  • \\n \\n
  • \\n
  • \\n \\n
  • \\n
  • \\n \\n
  • \\n
  • \\n \\n
  • \\n
  • \\n \\n
  • \\n
  • \\n \\n
  • \\n
\\n
\\n
\\n
\\n
\\n
\\n
\\n \\n
\\n
\\n
\\n
\\n
\\n \\n
\\n
\\n
\\n
\\n
\\n
\\n
\\n
\\n
\\n
\\n \\n
\\n
\\n
\\n
\\n
\\n
\\n
\\n
\\n
\\n
\\n
\\n
\\n
\\n
\\n
\\n
\\n
\\n
\\n
\\n
\\n
\\n
\\n
\\n
\\n
\\n
\\n
\\n
\\n \\uC804\\uCCB4 \\uBA54\\uC2DC\\uC9C0 \\uAE38\\uC774: \\n \\n
\\n
\\n
\\n
\\n
\\n Response\\n \\n \\n
\\n
    \\n
  • \\n \\n
  • \\n
  • \\n \\n
  • \\n
\\n
\\n
\\n
\\n
\\n
\\n
\\n
\\n
\\n
\\n
\\n
\\n \\n \");\n }\n }]);\n return TCPClientView;\n}();\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (TCPClientView);\n\n//# sourceURL=webpack://APITestManager/./src/components/TCPClientView.js?"); /***/ }),
').html(field.label).appendTo(tr);\n th.css({\n 'width': field.width + 'px',\n 'border': '1px gray solid',\n 'text-align': 'center'\n });\n });\n }\n }, {\n key: \"toggleChildrenVisibility\",\n value: function toggleChildrenVisibility(nodeId, isExpanded) {\n var _this = this;\n var selector = \".treegrid-parent-\".concat(nodeId);\n $(selector).each(function (_, el) {\n $(el).toggle(!isExpanded);\n if (isExpanded) {\n // If we are hiding the children\n var childNodeId = $(el).data('nodeId'); // Assume data-nodeId is set when rows are created\n _this.toggleChildrenVisibility(childNodeId, true); // Recursively hide all descendants\n var expander = $(\".treegrid-\".concat(nodeId, \" .treegrid-expander\"));\n expander.html(isExpanded ? '+' : '-');\n }\n });\n }\n }, {\n key: \"setupExpander\",\n value: function setupExpander(cell, callback) {\n var expander = $('').addClass('treegrid-expander').html('-').appendTo(cell);\n expander.click(callback);\n }\n }]);\n return LayoutTreeDataGridView;\n}();\nvar LayoutTreeGridController = /*#__PURE__*/function () {\n function LayoutTreeGridController(model, view, options, totalMessageLengthSelector) {\n _classCallCheck(this, LayoutTreeGridController);\n this.model = model;\n this.view = view;\n this.options = options;\n this.apiClient = new _APIClient__WEBPACK_IMPORTED_MODULE_1__[\"default\"]();\n this.totalMessageLengthSelector = totalMessageLengthSelector;\n }\n _createClass(LayoutTreeGridController, [{\n key: \"init\",\n value: function init(callback) {\n this.view.addHeaders(this.options);\n this.processNode(this.model.dataRoot, 0);\n this.setupEditableFields();\n this.callback = callback;\n }\n }, {\n key: \"rebuild\",\n value: function () {\n var _rebuild = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(dataRoot) {\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n this.model.dataRoot = dataRoot;\n this.view.table.children().remove();\n this.view.addHeaders(this.options);\n this.processNode(this.model.dataRoot, 0);\n this.setupEditableFields();\n _context.t0 = this;\n _context.next = 8;\n return this.concatenateFieldValues(this.model.dataRoot);\n case 8:\n _context.t1 = _context.sent;\n _context.t2 = this.model.dataRoot;\n _context.t0.callback.call(_context.t0, _context.t1, _context.t2);\n case 11:\n case \"end\":\n return _context.stop();\n }\n }, _callee, this);\n }));\n function rebuild(_x) {\n return _rebuild.apply(this, arguments);\n }\n return rebuild;\n }()\n }, {\n key: \"getIndent\",\n value: function getIndent(depth) {\n return new Array(depth + 1).join('');\n }\n }, {\n key: \"fillPadding\",\n value: function () {\n var _fillPadding = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(value, dataLength) {\n var paddedValue;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return this.apiClient.processPreScriptAndVariables(this.model.apiRequest, value.toString());\n case 2:\n paddedValue = _context2.sent;\n while (paddedValue.length < dataLength) {\n paddedValue = ' ' + paddedValue; // Prepend a space character to the string\n }\n return _context2.abrupt(\"return\", paddedValue);\n case 5:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2, this);\n }));\n function fillPadding(_x2, _x3) {\n return _fillPadding.apply(this, arguments);\n }\n return fillPadding;\n }()\n }, {\n key: \"concatenateFieldValues\",\n value: function () {\n var _concatenateFieldValues = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(node) {\n var concatenatedValues, _iterator, _step, child;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n concatenatedValues = ''; // Process the current node if it is of type 'Field'\n if (!(node.loutItemType === 'Field')) {\n _context3.next = 9;\n break;\n }\n _context3.t0 = concatenatedValues;\n _context3.next = 5;\n return this.fillPadding(node.value, node.loutItemLength);\n case 5:\n _context3.t1 = _context3.sent;\n if (_context3.t1) {\n _context3.next = 8;\n break;\n }\n _context3.t1 = '';\n case 8:\n concatenatedValues = _context3.t0 += _context3.t1;\n case 9:\n if (!(node.children && node.children.length > 0)) {\n _context3.next = 29;\n break;\n }\n _iterator = _createForOfIteratorHelper(node.children);\n _context3.prev = 11;\n _iterator.s();\n case 13:\n if ((_step = _iterator.n()).done) {\n _context3.next = 21;\n break;\n }\n child = _step.value;\n _context3.t2 = concatenatedValues;\n _context3.next = 18;\n return this.concatenateFieldValues(child);\n case 18:\n concatenatedValues = _context3.t2 += _context3.sent;\n case 19:\n _context3.next = 13;\n break;\n case 21:\n _context3.next = 26;\n break;\n case 23:\n _context3.prev = 23;\n _context3.t3 = _context3[\"catch\"](11);\n _iterator.e(_context3.t3);\n case 26:\n _context3.prev = 26;\n _iterator.f();\n return _context3.finish(26);\n case 29:\n return _context3.abrupt(\"return\", concatenatedValues);\n case 30:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3, this, [[11, 23, 26, 29]]);\n }));\n function concatenateFieldValues(_x4) {\n return _concatenateFieldValues.apply(this, arguments);\n }\n return concatenateFieldValues;\n }()\n }, {\n key: \"sumFieldLoutItemLengths\",\n value: function sumFieldLoutItemLengths() {\n var queue = [this.model.dataRoot];\n var sum = 0;\n while (queue.length > 0) {\n var node = queue.shift();\n if (node.loutItemType === 'Field') {\n sum += parseInt(node.loutItemLength) || 0; // Add the loutItemLength of the node, or 0 if undefined\n }\n if (node.children && node.children.length > 0) {\n var _iterator2 = _createForOfIteratorHelper(node.children),\n _step2;\n try {\n for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {\n var child = _step2.value;\n queue.push(child);\n }\n } catch (err) {\n _iterator2.e(err);\n } finally {\n _iterator2.f();\n }\n }\n }\n return sum;\n }\n }, {\n key: \"setupEditableFields\",\n value: function setupEditableFields() {\n var _this2 = this;\n this.view.table.find('.editable').each(function (index, editableElement) {\n var editableInput = new _EditableInput__WEBPACK_IMPORTED_MODULE_0__[\"default\"]({\n name: editableElement.dataset.name,\n value: editableElement.dataset.value,\n path: editableElement.dataset.path\n });\n editableInput.init(editableElement, /*#__PURE__*/function () {\n var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(value) {\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n _.set(_this2.model.dataRoot, editableElement.dataset.path, value);\n _context4.t0 = _this2;\n _context4.next = 4;\n return _this2.concatenateFieldValues(_this2.model.dataRoot);\n case 4:\n _context4.t1 = _context4.sent;\n _context4.t2 = _this2.model.dataRoot;\n _context4.t0.callback.call(_context4.t0, _context4.t1, _context4.t2);\n case 7:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n return function (_x5) {\n return _ref.apply(this, arguments);\n };\n }());\n });\n this.totalMessageLengthSelector.text(this.sumFieldLoutItemLengths());\n }\n }, {\n key: \"addCell\",\n value: function addCell(row, node, fieldInfo, depth) {\n var td = $('').appendTo(row);\n var padding = fieldInfo.isFirst ? this.getIndent(depth) : '';\n var nodePath = this.model.getNodePath(this.model.dataRoot, node.id) + '.value';\n if (node.loutItemType === 'Field' && fieldInfo.type === 'textfield') {\n var div = $('
');\n div.addClass('editable');\n div.appendTo(td);\n div.attr('data-name', fieldInfo.name);\n div.attr('data-value', node[fieldInfo.name]);\n div.attr('data-path', nodePath);\n } else {\n td.html(padding); // Default to just displaying the content\n }\n if (fieldInfo.width) {\n td.css({\n 'width': fieldInfo.width + 'px',\n 'border': '1px gray solid'\n });\n }\n if (fieldInfo.align) {\n td.css({\n 'text-align': fieldInfo.align\n });\n }\n return td;\n }\n }, {\n key: \"addRow\",\n value: function addRow(node, depth) {\n var tr = $('