UNPKG

survey-creator-core

Version:

A framework-independent core package of the SurveyJS Survey Creator component. With Survey Creator, you can visually design complex, interactive JSON forms and surveys in a drag-and-drop interface.

7 lines 131 kB
/*! * SurveyJS Creator v2.5.21 * (c) 2015-2026 Devsoft Baltic OÜ - http://surveyjs.io/ * Github: https://github.com/surveyjs/survey-creator * License: https://surveyjs.io/Licenses#SurveyCreator */ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("survey-core"),require("survey-creator-core")):"function"==typeof define&&define.amd?define(["exports","survey-core","survey-creator-core"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).SurveyCreatorUIPresetEditorCore={},e.Survey,e.SurveyCreatorCore)}(this,function(e,t,o){"use strict";function n(e,n){var i=new t.LocalizableString(void 0,!1);i.defaultValue=n.title;var s=new t.LocalizableString(void 0,!1);s.defaultValue=n.message;var r=new o.ComponentContainerModel;r.elements=[{componentName:"sv-string-viewer",componentData:{locStr:i,locString:i,model:i,textClass:"svc-creator-confirm-dialog__title"}},{componentName:"sv-string-viewer",componentData:{locStr:s,locString:s,model:s,textClass:"svc-creator-confirm-dialog__message"}}],r.cssClass="svc-creator-confirm-dialog__title-container";var a="svc-creator-confirm-dialog__icon"+("danger"===n.category?" svc-creator-confirm-dialog__icon--danger":""),l=[{componentName:"sv-svg-icon",componentData:{iconName:n.iconName,size:"auto",className:a,class:a,partCss:a}},{componentName:"svc-component-container",componentData:{model:r}}],u=new o.ComponentContainerModel;u.elements=l,u.cssClass="svc-creator-confirm-dialog__content-container";var p=t.settings.showDialog({componentName:"svc-component-container",data:{model:u},onApply:function(){return n.onApply()},onCancel:function(){return n.onCancel()},cssClass:"sps-popup svc-creator-popup svc-creator-confirm-dialog",displayMode:"popup",showCloseButton:n.showCloseButton},e.rootElement),c=p.footerToolbar.cssClasses;c.item="sps-btn",p.footerToolbar.cssClasses=c;var d=p.footerToolbar.getActionById("apply"),m=p.footerToolbar.getActionById("cancel");return d.title=n.applyText,d.innerCss="danger"===n.category?"sps-btn--secondary-alert":"sps-btn--primary-neutral",m.title=n.cancelText,m.innerCss="sps-btn--secondary-neutral",p}var i=function(e,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])},i(e,t)};function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function o(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(o.prototype=t.prototype,new o)}var r=function(){return r=Object.assign||function(e){for(var t,o=1,n=arguments.length;o<n;o++)for(var i in t=arguments[o])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},r.apply(this,arguments)};function a(e,t,o){if(o||2===arguments.length)for(var n,i=0,s=t.length;i<s;i++)!n&&i in t||(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))}"function"==typeof SuppressedError&&SuppressedError;var l=function(){function e(e){this.preset=e,this.children=[],this.notifyCallback=function(e){}}return Object.defineProperty(e.prototype,"navigationPanelName",{get:function(){return this.path+"_navigation"},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isSettingUp",{get:function(){return!1},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"path",{get:function(){return this.preset.getPath()},enumerable:!1,configurable:!0}),e.prototype.getJsonPath=function(e){return this.path},Object.defineProperty(e.prototype,"fullPath",{get:function(){var e=this.parent?this.parent.fullPath:"";return this.path&&e&&(e+="_"),e+this.path},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"pageName",{get:function(){return"page_"+this.fullPath},enumerable:!1,configurable:!0}),e.prototype.getPageTitle=function(e){return e.getPageByName(this.pageName).title},e.prototype.getPageShortTitle=function(e){return e.getPageByName(this.pageName).navigationTitle},Object.defineProperty(e.prototype,"mainPanelName",{get:function(){return this.path+"_mainPanel"},enumerable:!1,configurable:!0}),e.prototype.getMainElementNames=function(){return[this.mainPanelName]},e.prototype.getMainPanelName=function(){return this.mainPanelName},e.prototype.getCustomQuestionCssSuffix=function(e){return""},e.prototype.createPages=function(){var e=[],t=this.createMainPage();return t&&e.push(t),this.children.forEach(function(t){var o=t.createPages();Array.isArray(o)&&o.forEach(function(t){return e.push(t)})}),e},Object.defineProperty(e.prototype,"questionNames",{get:function(){return[]},enumerable:!1,configurable:!0}),e.prototype.validate=function(e){if(!this.validateCore(e))return!1;for(var t=0;t<this.children.length;t++)if(!this.children[t].validate(e))return!1;return!0},e.prototype.validateCore=function(e){return!0},e.prototype.createMainPage=function(){var e=this.createMainPageCore();return e&&(e.name=this.pageName),e},e.prototype.getBoolVisibleIf=function(e,t){return void 0===t&&(t=!0),"{"+e+"}="+(t?"true":"false")},e.prototype.getTextVisibleIf=function(e,t){return"{"+e+"}='"+t+"'"},e.prototype.getNotEmptyVisibleIf=function(e){return"{"+e+"} notempty"},e.prototype.createMainPageCore=function(){},e.prototype.getNavigationElementName=function(){return this.navigationPanelName},e.prototype.getJsonValue=function(e,t,o){var n=e.getPageByName(this.pageName),i=n&&n.isVisible?this.getJsonValueCore(e,t,o):void 0,s=!!i,r=s?i:{};return this.children.forEach(function(o){var n=o.getJsonValue(e,t);n&&(s=!0,r[o.getJsonPath(e)]=n)}),s?r:void 0},e.prototype.getDefaultJsonValue=function(e){var t=this.getDefaultJsonValueCore(e);return this.children.forEach(function(o){return t[o.path]=o.getDefaultJsonValueCore(e)}),t},e.prototype.setJsonLocalizationStrings=function(e,t){this.setJsonLocalizationStringsCore(e,t),this.children.forEach(function(o){return o.setJsonLocalizationStrings(e,t)})},e.prototype.updateJsonLocalizationStrings=function(e){this.updateJsonLocalizationStringsCore(e),this.children.forEach(function(t){return t.updateJsonLocalizationStrings(e)})},e.prototype.dispose=function(){this.disposeCore(),this.children.forEach(function(e){return e.dispose()})},e.prototype.setupQuestions=function(e,t){this.setupQuestionsCore(e,t),this.children.forEach(function(o){o.setupQuestions(e,t)})},e.prototype.resetToDefaults=function(e,t){void 0===t&&(t=!0),this.restoreValuesFromDefault(e),this.notifyCallback(this.getPageTitle(e)+" "+o.getLocString("presets.editor.resoredToDefault")),this.children.forEach(function(o){o.resetToDefaults(e,t)})},e.prototype.setupOnCurrentPage=function(e,t,o){this.setupOnCurrentPageCore(e,t,o),this.children.forEach(function(n){n.setupOnCurrentPage(e,t,o)})},e.prototype.updateOnValueChanged=function(e,t){this.updateOnValueChangedCore(e,t),this.children.forEach(function(o){o.updateOnValueChanged(e,t)})},e.prototype.updateOnMatrixDetailPanelVisibleChanged=function(e,t,o){this.updateOnMatrixDetailPanelVisibleChangedCore(e,t,o),this.children.forEach(function(n){n.updateOnMatrixDetailPanelVisibleChanged(e,t,o)})},e.prototype.onGetMatrixRowActions=function(e,t,o){this.onGetMatrixRowActionsCore(e,t,o),this.children.forEach(function(n){n.onGetMatrixRowActions(e,t,o)})},e.prototype.onGetQuestionTitleActions=function(e,t,o){},e.prototype.onGetPanelTitleActions=function(e,t,o){},e.prototype.onMatrixRowDragOver=function(e,t,o){},e.prototype.onMatrixRowRemoving=function(e,t,o){},e.prototype.onMatrixRowAdded=function(e,t,o){},e.prototype.onMatrixCellValueChanged=function(e,t,o){},e.prototype.setupQuestionsValue=function(e,t,o){this.setupQuestionsValueCore(e,t,o),this.saveValuesAsDefault(e),this.children.forEach(function(n){n.setupQuestionsValue(e,t?t[n.path]:void 0,o)})},e.prototype.onLocaleChanged=function(e,t,o){this.onLocaleChangedCore(e,t,o),this.children.forEach(function(n){n.setupQuestionsValue(e,t?t[n.path]:void 0,o)})},e.prototype.saveValuesAsDefault=function(e){this.questionNames.forEach(function(t){return e.getQuestionByName(t).defaultValue=e.getValue(t)&&JSON.parse(JSON.stringify(e.getValue(t)))})},e.prototype.restoreValuesFromDefault=function(e){this.questionNames.forEach(function(t){return e.getQuestionByName(t).value=e.getQuestionByName(t).defaultValue&&JSON.parse(JSON.stringify(e.getQuestionByName(t).defaultValue))})},e.prototype.setupQuestionsCore=function(e,t){},e.prototype.resetToDefaultsCore=function(e){},e.prototype.setupQuestionsValueCore=function(e,t,o){},e.prototype.onLocaleChangedCore=function(e,t,o){},e.prototype.getJsonValueCore=function(e,t,o){},e.prototype.getDefaultJsonValueCore=function(e){return{}},e.prototype.setJsonLocalizationStringsCore=function(e,t){},e.prototype.updateJsonLocalizationStringsCore=function(e){},e.prototype.disposeCore=function(){},e.prototype.setupOnCurrentPageCore=function(e,t,o){},e.prototype.updateOnValueChangedCore=function(e,t){},e.prototype.updateOnMatrixDetailPanelVisibleChangedCore=function(e,t,o){},e.prototype.onGetMatrixRowActionsCore=function(e,t,o){},e.prototype.copyJson=function(e){return t.Helpers.getUnbindValue(e)},e.updateModifiedText=function(t,n,i){if(i&&n){var s=o.editorLocalization.presetStrings;o.editorLocalization.presetStrings=void 0,n!==o.editorLocalization.getString(i)&&e.saveTextInLocStrs(t,n,i),o.editorLocalization.presetStrings=s}},e.saveTextInLocStrs=function(e,t,o){for(var n=o.split("."),i=0;i<n.length-1;i++){var s=n[i];e[s]||(e[s]={}),e=e[s]}e[n[n.length-1]]=t},e}(),u={root:"sps-root-modern",container:"sps-container-modern",header:"sps-title sps-container-modern__title",body:"sps-body",bodyEmpty:"sps-body sps-body--empty",footer:"sps-footer sps-body__footer sps-clearfix",title:"",description:"",logo:"sps-logo",logoImage:"sps-logo__image",headerText:"sps-header__text",navigationButton:"",bodyNavigationButton:"",completedPage:"sps-completedpage",navigation:{complete:"sps-btn sps-btn--primary-brand sps-footer__complete-btn",prev:"sps-btn sps-btn--secondary-brand sps-footer__prev-btn",next:"sps-btn sps-btn--primary-brand sps-footer__next-btn",start:"sps-btn sps-footer__start-btn",preview:"sps-btn sps-footer__preview-btn",edit:"sps-btn sps-footer__edit-btn"},list:JSON.parse(JSON.stringify(o.listComponentCss)),panel:{withFrame:"sps-panel--with-frame",nested:"sps-panel--nested",expandableAnimating:"",header:"sps-panel__header",title:"sps-title sps-panel__title",titleBar:"sd-action-title-bar sps-action-title-bar",contentEnter:"sps-panel__content--enter",contentLeave:"sps-panel__content--leave",titleExpandable:"sps-panel__title--expandable",titleExpanded:"sps-panel__title--expanded",titleCollapsed:"sps-panel__title--collapsed",titleOnError:"sps-panel__title--error",description:"sps-description sps-panel__description",container:"sps-panel sps-row__panel",content:"sps-panel__content",icon:"sps-panel__icon",iconExpanded:"sps-panel__icon--expanded",footer:"sps-panel__footer",requiredMark:"sps-panel__required-text",collapsed:"sps-panel--collapsed",expanded:"sps-panel--expanded"},paneldynamic:{nested:"",mainRoot:"sps-question sps-row__question",root:"sps-paneldynamic",navigation:"sps-paneldynamic__navigation",title:"sps-title sps-question__title",button:"sps-action-button sps-action-button--text",buttonRemove:"sps-action-button--danger",buttonAdd:"sps-paneldynamic__add-btn",panelsContainer:"",panelWrapper:"sps-paneldynamic__panel-wrapper",panelWrapperList:"",progressTop:"sps-paneldynamic__progress sps-paneldynamic__progress--top",progressBottom:"sps-paneldynamic__progress sps-paneldynamic__progress--bottom",buttonPrev:"sps-paneldynamic__prev-btn",buttonNext:"sps-paneldynamic__next-btn",progressContainer:"sps-paneldynamic__progress-container",progress:"sps-progress",progressBar:"sps-progress__bar",progressText:"sps-paneldynamic__progress-text",panelFooter:"sps-panel__footer",separator:"sps-paneldynamic__separator",footer:"sps-paneldynamic__footer",footerButtonsContainer:"sps-paneldynamic__buttons-container"},progress:"sps-progress sps-body__progress",progressBar:"sps-progress__bar",progressText:"sps-progress__text",progressTextInBar:"sps-hidden",page:{root:"sps-page sps-body__page",title:"sps-title sps-page__title",description:"sps-description sps-page__description"},pageTitle:"sps-title sps-page__title",pageDescription:"sps-description sps-page__description",row:"sps-row sps-clearfix",rowEnter:"sps-row--enter",rowLeave:"sps-row--leave",rowDelayedEnter:"sps-row--delayed-fade-in",rowMultiple:"sps-row--multiple",question:{withFrame:"sps-question--with-frame",nested:"sps-question--nested",mainRoot:"sps-question sps-row__question",flowRoot:"sps-question sps-row__question sps-row__question--flow",asCell:"sps-table__cell",header:"sps-question__header",headerLeft:"sps-question__header--location--left",headerTop:"sps-question__header--location--top",headerBottom:"sps-question__header--location--bottom",content:"sps-question__content",contentLeft:"sps-question__content--left",titleLeftRoot:"sps-question--location--left",titleOnAnswer:"sps-question__title--answer",titleOnError:"sps-question__title--error",title:"sps-title sps-question__title",titleBar:"sd-action-title-bar sps-action-title-bar",requiredMark:"sps-question__required-text",number:"sps-question__num",description:"sps-description sps-question__description",descriptionUnderInput:"sps-question__description--under",comment:"sps-comment",required:"sps-question--required",titleRequired:"sps-question__title--required",indent:0,footer:"sps-question__footer",formGroup:"sps-question__form-group",hasError:"",readOnly:"sd-question--readonly sps-question--disabled",confirmDialog:"sps-popup--confirm sv-popup--confirm svc-creator-popup",errorsContainerBottom:"sps-question__erbox--below-question"},checkbox:{root:"sps-selectbase",item:"sps-item sps-checkbox sps-selectbase__item",itemSelectAll:"sps-checkbox--selectall",itemNone:"sps-checkbox--none",itemReadOnly:"sps-item--disabled sps-checkbox--disabled",itemChecked:"sps-checkbox--checked",itemHover:"sps-checkbox--allowhover",itemInline:"sps-selectbase__item--inline",label:"sps-selectbase__label",itemSvgIconId:"#icon-check-16x16",labelChecked:"",itemControl:"sps-checkbox__control",itemDecorator:"sps-checkbox__svg",controlLabel:"sps-checkbox__caption",materialDecorator:"sps-checkbox__rectangle",other:"sps-comment sps-question__other",column:"sps-selectbase__column"},radiogroup:{root:"sps-selectbase",item:"sps-item sps-radio sps-selectbase__item",itemInline:"sps-selectbase__item--inline",label:"sps-selectbase__label",labelChecked:"",itemReadOnly:"sps-item--disabled sps-radio--disabled",itemChecked:"sps-radio--checked",itemHover:"sps-radio--allowhover",itemControl:"sps-visuallyhidden sps-item__control",itemDecorator:"sps-item__svg sps-radio__svg",controlLabel:"sps-item__control-label",materialDecorator:"sps-item__decorator sps-radio__decorator",other:"sps-comment sps-question__other",clearButton:"sps-btn sps-selectbase__clear-btn",column:"sps-selectbase__column"},boolean:{mainRoot:"sps-question sps-row__question sps-question--boolean",rootCheckbox:"sps-selectbase",checkboxItem:"sps-checkbox",checkboxItemChecked:"sps-checkbox--checked",checkboxitemIndeterminate:"sps-checkbox--indeterminate",checkboxItemReadOnly:"sps-checkbox--disabled",svgIconId:"#icon-v2check",checkboxLabel:"sps-selectbase__label",controlCheckbox:"sps-checkbox__control",checkboxControlLabel:"sps-checkbox__caption",checkboxItemDecorator:"sps-checkbox__svg",checkboxMaterialDecorator:"sps-checkbox__rectangle"},text:{root:"sps-input sps-text",controlReadOnly:"sps-input--readonly",small:"sps-row__question--small",content:"sps-question__content sps-text__content",remainingCharacterCounter:"sps-remaining-character-counter",onError:"sps-input--error"},comment:{root:"sps-input sps-comment",content:"sps-question__content sps-comment__content",remainingCharacterCounter:"sps-remaining-character-counter",small:"sps-row__question--small",onError:"sps-input--error"},dropdown:{root:"sps-selectbase",popup:"sps-dropdown-popup svc-creator-popup",small:"sps-row__question--small sd-row__question--small",control:"sps-input sps-dropdown",controlEmpty:"sps-dropdown--empty sd-dropdown--empty",controlValue:"sps-dropdown__value",filterStringInput:"sd-dropdown__filter-string-input sps-dropdown__filter-string-input",other:"sps-comment sps-question__other",onError:"sps-input--error",selectWrapper:"sv-dropdown_select-wrapper sps-dropdown_select-wrapper",chevronButtonIconId:"icon-chevron",cleanButton:"sps-dropdown__clean-button sps-input__edit-button",controlReadOnly:"sps-input--readonly sd-input--disabled sd-input--readonly",hintPrefix:"sps-dropdown__hint-prefix sd-dropdown__hint-prefix",hintSuffix:"sps-dropdown__hint-suffix sd-dropdown__hint-suffix"},tagbox:{cleanItemButton:"sd-tagbox-item_clean-button sps-tagbox-item_clean-button",cleanItemButtonSvg:"sd-tagbox-item_clean-button-svg sps-tagbox-item_clean-button-svg",control:"sd-input sd-tagbox sd-dropdown sps-tagbox sps-dropdown",controlValue:"sd-tagbox__value sd-dropdown__value sps-tagbox__value",filterStringInput:"sd-dropdown__filter-string-input sps-dropdown__filter-string-input"},matrix:{tableWrapper:"sps-matrix sps-table-wrapper",root:"sps-table",rowError:"sps-matrix__row--error",cell:"sps-table__cell sps-matrix__cell",headerCell:"sps-table__cell sps-table__cell--header",label:"sps-item sps-radio sps-matrix__label",itemValue:"sps-visuallyhidden sps-item__control sps-radio__control",itemChecked:"sps-radio--checked",itemReadOnly:"sps-item--disabled sps-radio--disabled",itemHover:"sps-radio--allowhover",materialDecorator:"sps-item__decorator sps-radio__decorator",itemDecorator:"sps-item__svg sps-radio__svg",cellText:"sps-matrix__text",cellTextSelected:"sps-matrix__text--checked",cellTextReadOnly:"sps-matrix__text--disabled"},matrixdropdown:{tableWrapper:"sps-table-wrapper",root:"sps-table",cell:"sps-table__cell",headerCell:"sps-table__cell sps-table__cell--header",emptyCell:"sps-table__cell--empty",rowEnter:"sps-table__row--enter",rowLeave:"sps-table__row--leave"},matrixdynamic:{mainRoot:"sps-question sps-question--matrixdynamic sd-element sd-question sd-row__question sd-element--complex sd-question--complex sd-question--table",tableWrapper:"sps-table-wrapper",root:"sps-table sps-matrixdynamic",content:"sps-matrixdynamic__content sps-text__content",cell:"sps-table__cell",row:"sps-table__row",rowDisabled:"sps-table__row-disabled",rowReadOnly:"sps-table__row-readonly",headerCell:"sps-table__cell sps-table__cell--header",button:"sps-btn",detailRow:"sps-table__row sps-table__row--detail",detailButton:"sps-table__cell--detail-button sps-action-button sps-action-button--icon",detailButtonExpanded:"sps-table__cell--detail-button--expanded",detailIcon:"sps-detail-panel__icon sps-action-button__icon",detailIconExpanded:"sps-detail-panel__icon--expanded",detailIconExpandedId:"icon-collapse-24x24",detailIconId:"icon-expand-24x24",detailPanelCell:"sps-table__cell sps-table__cell--detail-panel",actionsCell:"sps-table__cell sps-table__cell--actions",buttonAdd:"sps-matrixdynamic__add-btn sps-action-button sps-action-button--large",buttonRemove:"",iconAdd:"",iconRemove:"#icon-delete-24x24",dragElementDecorator:"sps-drag-element__svg",iconDragElement:"#icon-drag-24x24",iconDrag:"sps-matrixdynamic__drag-element",footer:"sps-matrixdynamic__footer",dragDropGhostPositionTop:"sps-matrixdynamic__drag-drop-ghost-position-top",dragDropGhostPositionBottom:"sps-matrixdynamic__drag-drop-ghost-position-bottom",noRowsSection:"sps-matrixdynamic__placeholder",noRowsText:"sps-matrixdynamic__placeholder-text",cellQuestionWrapper:"sps-table__question-wrapper",draggedRow:"sps-matrixdynamic__dragged-row",emptyCell:"sps-table__cell--empty",rowEmpty:"sps-table__row--empty",rowEnter:"sps-table__row--enter",rowLeave:"sps-table__row--leave"},actionBar:{root:"sps-action-bar",item:"sps-action-button",itemPressed:"sps-action-button--pressed",itemAsIcon:"sps-action-button--icon",itemIcon:"sps-action-button__icon",itemTitle:"sps-action-button__title"}},p=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.defaultIcon="square-dashed-24x24",t}return s(n,e),Object.defineProperty(n.prototype,"nameItems",{get:function(){return this.path+"_items"},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"nameMatrix",{get:function(){return this.fullPath+"_matrix"},enumerable:!1,configurable:!0}),n.prototype.hasIcon=function(e){return!1},n.prototype.getMainElementNames=function(){return[this.nameItems]},Object.defineProperty(n.prototype,"iconList",{get:function(){return Object.keys(t.SvgRegistry.icons).map(function(e){return"icon-"+e})},enumerable:!1,configurable:!0}),n.prototype.getMatrixKeyColumnName=function(e){return"name"},n.prototype.getDefaultItems=function(e){return this.defaultItems},n.prototype.getDefaultItem=function(e,t){var o=this.getMatrixKeyColumnName(e);return this.getDefaultItems(e).filter(function(e){return e[o]==t})[0]},n.prototype.updateOnValueChangedCore=function(e,t){if(this.needToSetActions(t)){var o=e.getQuestionByName(t);this.updateMatrixRowActions(e,o)}},n.prototype.updateMatrixRowActions=function(e,t){var o=this;t.renderedTable.rows.forEach(function(e){var n,i,s;if(e.row){var r=null===(i=null===(n=e.cells[1])||void 0===n?void 0:n.item)||void 0===i?void 0:i.value.actions;o.updateRowActions(t,e.row,r);var a=null===(s=e.cells[e.cells.length-1].item)||void 0===s?void 0:s.value.actions;o.updateRowActions(t,e.row,a)}})},n.prototype.updateRowActions=function(e,t,o){var n=this;if(o){var i=this.getMatrixKeyColumnName(e);if(e.value){var s=e.value.filter(function(e){var o;return(null===(o=t.value)||void 0===o?void 0:o[i])==(null==e?void 0:e[i])})[0];s&&o.forEach(function(o){return n.updateRowAction(e,t,s,i,o)})}}},n.prototype.updateRowAction=function(e,o,n,i,s){if("icon-action"==s.id&&(s.iconName=n.iconName||this.defaultIcon),"reset-to-default"==s.id){var r=this.getDefaultItem(e,n[i]);if(!r)return;var a={};Object.keys(n).forEach(function(e){return a[e]=r[e]}),s.enabled=!t.Helpers.isTwoValueEquals(n,a)}},n.prototype.createResetAction=function(e,t,n){return{id:"reset-to-default",iconName:"icon-reset",tooltip:o.getLocString("presets.items.restoreToDefault"),location:"end",visibleIndex:15,action:n}},n.prototype.createEditAction=function(e,t,n,i){var s=this;return{id:"edit-item",iconName:"icon-edit",tooltip:o.getLocString("presets.items.edit"),location:"end",visibleIndex:13,action:function(){s.editItem(e,t,n,i)}}},n.prototype.createIconAction=function(e,t){return void 0===t&&(t="sps-matrixdynamic__row-icon"),{id:"icon-action",iconName:e,innerCss:t,location:"start",enabled:!1}},n.prototype.setupStandardActions=function(e,n,i,s,r){e.forEach(function(e){"show-detail"==e.id&&(e.location="end",e.iconName="icon-expand-24x24",e.title=new t.ComputedUpdater(function(){return i.isDetailPanelShowing?o.getLocString("presets.items.collapse"):o.getLocString("presets.items.expand")}),e.tooltip=o.getLocString("presets.items.expand"),e.visibleIndex=10,e.visible=s),"remove-row"==e.id&&(e.visibleIndex=20,e.component="sv-action-bar-item",e.action=function(){return n.removeRowUI(i)},e.iconName=r?"icon-add_24x24":"icon-remove_24x24",e.tooltip=r?o.getLocString("presets.items.add"):o.getLocString("presets.items.delete"))})},n.prototype.editItem=function(e,n,i,s,r){var a,l,u=this,p=this.getMatrixKeyColumnName(i),c={id:"reset-to-default",title:o.getLocString("presets.editor.resetToDefault"),css:"sps-action--grow",innerCss:"sps-btn sps-btn--secondary-alert",visibleIndex:15,action:function(e){var t=u.getDefaultItem(i,a.getValue(p));a.data=t,l.enabled=!1,u.notifyCallback(o.getLocString("presets.editor.itemRestoredToDefault"))}};l=new t.Action(c),a=this.showDetailPanelInPopup(i,s,e.rootElement,{actions:[l],title:null==r?void 0:r.description,removeOnCancel:null==r?void 0:r.isNew}),l.enabled=!t.Helpers.isTwoValueEquals(a.data,this.getDefaultItem(i,a.getValue(p))),a.onValueChanged.add(function(){return l.enabled=!0});var d=a.getQuestionByName(p);this.getDefaultItem(i,d.value)&&(d.readOnly=!0)},n.prototype.resetItem=function(e,t,n){var i=n.getValue("name"),s=this.getDefaultItem(t,i);if(s){var r=t.value,a=r.filter(function(e){return e.name==i})[0];Object.keys(a).forEach(function(e){a[e]=s[e]}),t.value=r}this.notifyCallback(o.getLocString("presets.editor.itemRestoredToDefault"))},n.prototype.restoreItems=function(e,t,o){var n=t.value[o],i=e.value?a([],e.value,!0):[];i.push(n),e.value=i},n.prototype.getMatrix=function(e){return e.getQuestionByName(this.nameMatrix)},n.prototype.isItemsMatrix=function(e){return e===this.nameMatrix},n.prototype.needToSetActions=function(e){return this.isItemsMatrix(e)},n.prototype.onGetMatrixRowActionsCore=function(e,t,o){var n,i,s=this;if(this.needToSetActions(o.question.name)){var r=o.question,a=r.detailElements.filter(function(e){return e.visible}).length>0;if(this.hasIcon(o.question.name)){var l=this.getMatrixKeyColumnName(o.question),u=(null===(i=null===(n=r.value)||void 0===n?void 0:n.filter(function(e){return e[l]==o.row.getValue(l)})[0])||void 0===i?void 0:i.iconName)||this.defaultIcon;o.actions.push(this.createIconAction(u))}var p=this.createResetAction(e,o.row,function(t){s.resetItem(e,r,o.row),t.enabled=!1});o.actions.push(p),o.actions.push(this.createEditAction(e,t,r,o.row)),this.setupStandardActions(o.actions,r,o.row,a,r.name==this.nameMatrix),this.updateRowActions(r,o.row,o.actions)}},n.prototype.onMatrixRowDragOver=function(e,t,o){this.isItemsMatrix(o.fromMatrix.name)&&this.isItemsMatrix(o.toMatrix.name)&&(o.allow=!0)},n.prototype.onMatrixRowRemoving=function(e,t,o){if(this.isItemsMatrix(o.question.name)&&o.question.name!=this.nameMatrix){var n=o.question.value[o.rowIndex],i=this.getMatrix(e),s=i.value?a([],i.value,!0):[];s.push(n),i.value=s}},n.prototype.getExistingKeys=function(e,t){var o=e.getQuestionByName(this.nameItems).value||[],n=e.getQuestionByName(this.nameMatrix).value||[];return a(a([],o,!0),n,!0)},n.prototype.getDefaultValueForRow=function(e,t,n){return o.SurveyHelper.getNewName(this.getExistingKeys(e,n).map(function(e){return e[n]}).filter(function(e){return!!e}).map(function(e){return{name:e}}),n)},n.prototype.setDefaultValueForRow=function(e,t,o){var n=this.getMatrixKeyColumnName(t),i=this.getDefaultValueForRow(e,t,n);o.getQuestionByName(n).value=i,o.getQuestionByName("title").value=i},n.prototype.onMatrixRowAdded=function(e,t,n){var i,s;this.isItemsMatrix(n.question.name)&&(this.setDefaultValueForRow(e,n.question,n.row),this.editItem(e,t,n.question,n.row,{description:o.getLocString("presets.items.newItem")+" "+((null===(s=null===(i=n.question.data)||void 0===i?void 0:i.value)||void 0===s?void 0:s.title)||this.getPageShortTitle(e)),isNew:!0}))},n.prototype.onMatrixCellValueChanged=function(e,t,o){if(this.needToSetActions(o.question.name)){var n=o.question.renderedTable.rows.find(function(e){return e.row==o.row});if(!n)return;var i=n.cells[n.cells.length-1].item.value.actions;if(!i)return;this.updateRowActions(o.question,o.row,i)}},n.prototype.onDetailPanelInPopupApply=function(e,t,o){return!0},n.prototype.applyDetailPanelInPopup=function(e,t,o,n){if(e.validate()){var i={};e.getAllQuestions().forEach(function(e){e.visible&&(i[e.name]=e.isEmpty()&&e.isDescendantOf("checkbox")?[]:e.value)});var s=a([],t.value,!0),l=r(r({},t.value[n]),i);return s[n]=l,this.onDetailPanelInPopupApply(i,t,o)&&(t.value=s),this.updateMatrixRowActions(t.survey,t),!0}return!1},n.prototype.showDetailPanelInPopup=function(e,n,i,s){var r,a,l=this,p=e.visibleRows.findIndex(function(e){return e===n}),c=e.value[p],d=new t.SurveyModel({elements:e.toJSON().detailElements});if(d.fitToContainer=!1,d.showNavigationButtons=!1,d.data=c,d.css=u,d.enterKeyAction="loseFocus",d.questionErrorLocation="bottom",t.settings.showDialog){var m=null===(a=t.settings.showDialog)||void 0===a?void 0:a.call(t.settings,{componentName:"survey",data:{survey:d,model:d},onApply:function(){return l.applyDetailPanelInPopup(d,e,n,p)},onCancel:function(){return s.removeOnCancel&&e.removeRowUI(n),!0},cssClass:"sps-popup svc-property-editor svc-creator-popup",title:s.title||o.getLocString("presets.editor.edit"),displayMode:"popup"},i);if(d.getAllQuestions().filter(function(e){return!e.startWithNewLine}).length>0&&(m.width="100%"),m.footerToolbar){var g=m.footerToolbar.cssClasses;g.item="sps-btn",m.footerToolbar.cssClasses=g,m.footerToolbar.getActionById("apply").innerCss="sps-btn--primary-brand",m.footerToolbar.getActionById("cancel").innerCss="sps-btn--secondary-brand",s.actions&&(r=m.footerToolbar.actions).unshift.apply(r,s.actions)}d.getAllPanels().forEach(function(e){return e.visible=!e.visible}),d.getAllQuestions().forEach(function(e){e.visible=!e.visible,e.isRequired&&(e.requiredErrorText=o.getLocString("presets.editor.required"))})}return d},n}(l),c={root:"sps-list__container",itemsContainer:"sps-list",itemsContainerFiltering:"sps-list--filtering",emptyContainer:"sps-list__empty-container",emptyText:"sps-list__empty-text",filter:"sps-list__filter",filterIcon:"sps-list__filter-icon",filterInput:"sps-list__input",searchClearButtonIcon:"sps-list__filter-clear-button",loadingIndicator:"sps-list__loading-indicator",item:"sps-list__item",itemSelected:"sps-list__item--selected",itemGroup:"sps-list__item--group",itemGroupSelected:"sps-list__item--group-selected",itemWithIcon:"sps-list__item--with-icon",itemDisabled:"sps-list__item--disabled",itemFocused:"sps-list__item--focused",itemHovered:"sps-list__item--hovered",itemTextWrap:"sps-list__item-text--wrap",itemIcon:"sps-list__item-icon",itemMarkerIcon:"sps-list-item__marker-icon",itemSeparator:"sps-list__item-separator",itemBody:"sps-list__item-body"},d=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return s(n,e),Object.defineProperty(n.prototype,"defaultCategoriesMap",{get:function(){return this.defaultCategories.reduce(function(e,t){return e[t.category]=t,e},{})},enumerable:!1,configurable:!0}),n.prototype.getDefaultItems=function(e){return(null==e?void 0:e.name)===this.nameCategories?this.defaultCategories:this.defaultItems},Object.defineProperty(n.prototype,"nameInnerMatrix",{get:function(){return"items"},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"nameCategories",{get:function(){return this.fullPath+"_categories"},enumerable:!1,configurable:!0}),n.prototype.getMainElementNames=function(){return[this.nameCategories]},n.prototype.getMatrixKeyColumnName=function(e){return e.name===this.nameCategories?"category":"name"},Object.defineProperty(n.prototype,"questionNames",{get:function(){return[this.nameCategories]},enumerable:!1,configurable:!0}),n.prototype.setupCategoryActions=function(e,t,n,i,s){var r=this;s.forEach(function(t){"remove-row"==t.id&&(t.iconName="icon-delete_24x24",t.tooltip=o.getLocString("presets.items.delete"),t.innerCss="sps-action-button sps-action-button--icon sps-action-button--danger"),"reset-to-default"==t.id&&(t.action=function(){r.resetCategory(e,i)})})},n.prototype.ejectRowData=function(e,t,o){var n=e.value,i=e.visibleRows.indexOf(t),s=n[i];return o&&(n.splice(i,1),e.value=n),s},n.prototype.moveToCategory=function(e,t,o,n,i){void 0===i&&(i=!1);var s=this.ejectRowData(t,o,i),r=this.getQuestionCategories(e),a=r.value;return this.findOrCreateCategory(a,n)[this.nameInnerMatrix].push(s),r.value=a,r.visibleRows.find(function(e){return e.getValue("category")==n})},n.prototype.itemMenuCategoriesEnabled=function(e){return!0},n.prototype.setSubitemsToAction=function(e,t){e.setSubItems({items:t,cssClasses:c}),e.markerIconName="icon-chevronright-24x24"},n.prototype.getItemMenuActionsCore=function(e,n,i){var s=this,r=this.getQuestionCategories(e),a=r.value,l=[],u=n.name==this.nameMatrix,p=this.itemMenuCategoriesEnabled(e);if(u?p?l.push(new t.Action({id:"move-to",title:o.getLocString("presets.items.moveTo"),css:"sps-list__item--label",enabled:!1})):l.push(new t.Action({id:"restore-item",title:o.getLocString("presets.toolbox.addToToolbox"),action:function(){var e=n.visibleRows.indexOf(i);n.removeRow(e)}})):l.push(new t.Action({id:"remove-from",title:o.getLocString("presets.items.removeFrom").replace("{0}",n.title),action:function(){var e=n.visibleRows.indexOf(i);n.removeRow(e)}})),!p)return l;var c=a.filter(function(e){return(e[s.nameInnerMatrix]||[]).filter(function(e){var t;return e.name==(null===(t=i.value)||void 0===t?void 0:t.name)}).length>0})[0],d=a.filter(function(e){return e.category!=(null==c?void 0:c.category)}).map(function(o){return new t.Action({id:"to-"+o.category,title:o.title,action:function(){s.moveToCategory(e,n,i,o.category,!0)}})});if(u)l.push.apply(l,d);else{l.push(new t.Action({id:"categories",title:o.getLocString("presets.items.categoriesLabel"),css:"sps-list__item--label",enabled:!1,needSeparator:!0}));var m=new t.Action({id:"move-to-categories",title:o.getLocString("presets.items.moveToCategory")});this.setSubitemsToAction(m,d),l.push(m)}return l.push(new t.Action({id:"move-to-new-category",title:o.getLocString("presets.items.moveToNewCategory"),needSeparator:u,action:function(){var t=s.moveToCategory(e,n,i,s.getDefaultValueForRow(e,n,"category"),!0);s.editItem(e,null,r,t,{description:o.getLocString("presets.items.newCategory")+" "+s.getPageShortTitle(e),isNew:!0})}})),l},n.prototype.getItemMenuActions=function(e,n,i){var s=this,r=this.getItemMenuActionsCore(e,n,i);return this.getDefaultItem(n,i.value.name)||r.push(new t.Action({id:"remove-custom-item",title:o.getLocString("presets.toolbox.deleteCustomItem"),css:"sps-list__item--alert",needSeparator:!0,action:function(){s.ejectRowData(n,i,!0)}})),r},n.prototype.replaceRemoveAction=function(e,n,i,s){var r=this,a=s.filter(function(e){return"remove-row"==e.id})[0];if(a){a.visible=!1;var l=t.createDropdownActionModel({id:"context-menu",iconName:"more-circle-24x24",tooltip:o.getLocString("presets.items.more"),location:"end",visibleIndex:20},{items:[],showPointer:!1,verticalPosition:"bottom",horizontalPosition:"center",cssClass:"sps-popup-menu sps-popup-menu--context",cssClasses:c,searchEnabled:!1});l.popupModel.onVisibilityChanged.add(function(t,o){if(o.isVisible){var s=o.model.contentComponentData.model;s.actions=r.getItemMenuActions(e,n,i),s.flushUpdates()}}),s.push(l)}},n.prototype.getQuestionCategories=function(e){return e.getQuestionByName(this.nameCategories)},n.prototype.isItemsMatrix=function(t){return e.prototype.isItemsMatrix.call(this,t)||t===this.nameInnerMatrix},n.prototype.resetCategory=function(e,t){var n,i=this,s=t.getValue("category"),r=null===(n=this.defaultCategories.filter(function(e){return e.category==s})[0])||void 0===n?void 0:n[this.nameInnerMatrix];if(r){var a=this.getQuestionCategories(e),l=this.getMatrix(e),u=l.value||[],p=a.value,c=p.filter(function(e){return e.category==s})[0];c[this.nameInnerMatrix].forEach(function(e){r.some(function(t){return t.name==e.name})||u.push(e)}),c[this.nameInnerMatrix]=r,p.filter(function(e){return e.category!=s}).forEach(function(e){r.forEach(function(t){d(e[i.nameInnerMatrix])})}),d(u),l.value=u,a.value=p,this.notifyCallback(o.getLocString("presets.editor.categoryRestoredToDefault"))}function d(e){e&&r.forEach(function(t){var o=e.findIndex(function(e){return e.name==t.name});o>=0&&e.splice(o,1)})}},n.prototype.findOrCreateCategory=function(e,t){var o,n=e.filter(function(e){return e.category==t})[0];return n||((o={category:t||"general",title:t||"General"})[this.nameInnerMatrix]=[],n=o,e.push(n)),n},n.prototype.needToSetActions=function(e){return this.isItemsMatrix(e)||e===this.nameCategories},n.prototype.onGetMatrixRowActionsCore=function(t,o,n){e.prototype.onGetMatrixRowActionsCore.call(this,t,o,n),n.question.name===this.nameCategories&&this.setupCategoryActions(t,o,n.question,n.row,n.actions),this.isItemsMatrix(n.question.name)&&this.replaceRemoveAction(t,n.question,n.row,n.actions)},n.prototype.getExistingKeys=function(e,t){var o=e.getQuestionByName(this.nameCategories).value||[],n=e.getQuestionByName(this.nameMatrix).value||[];return a(a(a([],o,!0),o.map(function(e){return e.items}).flat().filter(function(e){return!!e}),!0),n,!0)},n.prototype.onMatrixRowRemoving=function(t,o,n){var i=this;if(e.prototype.onMatrixRowRemoving.call(this,t,o,n),n.question.name==this.nameCategories){var s=n.question.value[n.rowIndex][this.nameInnerMatrix];if(s){var r=this.getMatrix(t),a=r.value?r.value.concat(s):s;r.value=a}}if(n.question.name==this.nameMatrix){var l=n.question.value[n.rowIndex],u=this.defaultCategories.filter(function(e){return e[i.nameInnerMatrix].filter(function(e){return e.name==l.name}).length>0})[0];this.moveToCategory(t,n.question,n.row,null==u?void 0:u.category)}},n.prototype.onMatrixRowAdded=function(t,n,i){e.prototype.onMatrixRowAdded.call(this,t,n,i),i.question.name==this.nameCategories&&(this.setDefaultValueForRow(t,i.question,i.row),this.editItem(t,n,i.question,i.row,{description:o.getLocString("presets.items.newCategory")+" "+this.getPageShortTitle(t),isNew:!0}))},n}(p),m="toolboxCategories";t.FunctionFactory.Instance.register("validateToolboxJson",function(e){var o=e[0];return!o||!o.type||!!t.Serializer.createClass(o.type,o)});var g=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return s(n,e),n.prototype.createItemsMatrixJSON=function(e,t){var n={type:"matrixdynamic",name:"items",title:"Toolbox",allowRowReorder:!0,cellType:"text",showHeader:!1,rowCount:0,allowAddRows:!1,addRowButtonLocation:"top",columns:[{name:"name",visible:!1},{name:"title"}],detailPanelMode:"underRow",detailElements:[{type:"panel",name:"details",maxWidth:"30%",elements:[{type:"text",name:"name",title:o.getLocString("presets.toolbox.categoryName"),isUnique:!0,visible:!1,isRequired:!0},{type:"text",name:"title",title:o.getLocString("presets.toolbox.categoryTitle"),visible:!1},{type:"dropdown",name:"iconName",title:o.getLocString("presets.toolbox.iconName"),itemComponent:"svc-presets-icon-item",allowCustomChoices:!0,choices:this.iconList,visible:!1},{type:"text",name:"tooltip",title:o.getLocString("presets.toolbox.tooltip"),visible:!1}],visible:!1},{type:"presetjson",name:"json",startWithNewLine:!1,renderAs:"default-comment",title:o.getLocString("presets.toolbox.jsonObject"),validators:[{type:"expression",text:"JSON should be correct",expression:"validateToolboxJson({json})"}],visible:!1}]},i=r(r({},n),e);return t&&i.detailElements.push(this.createItemsMatrixJSON({allowAddRows:!0,addRowText:o.getLocString("presets.toolbox.addNewSubitem"),addRowButtonLocation:"bottom",name:this.nameSubitems,valueName:"subitems",titleLocation:"hidden",startWithNewLine:!1},!1)),i},n.prototype.createMainPageCore=function(){return{title:o.getLocString("presets.toolbox.title"),description:o.getLocString("presets.toolbox.description"),navigationTitle:o.getLocString("presets.toolbox.navigationTitle"),elements:[{type:"panel",name:this.mainPanelName,elements:[{type:"matrixdynamic",name:this.nameCategories,title:o.getLocString("presets.toolbox.toolbox"),visibleIf:this.getTextVisibleIf(this.nameCategoriesMode,"categories"),allowRowReorder:!0,allowAddRows:!0,addRowButtonLocation:"top",noRowsText:o.getLocString("presets.toolbox.noCategoriesText"),addRowText:o.getLocString("presets.toolbox.addCustomCategory"),showHeader:!1,columns:[{cellType:"text",name:"category",isUnique:!0,isRequired:!0,visible:!1},{cellType:"text",name:"title"}],detailPanelMode:"underRow",detailElements:[{type:"text",name:"category",title:o.getLocString("presets.toolbox.categoryName"),isRequired:!0,visible:!1},{type:"text",name:"title",title:o.getLocString("presets.toolbox.categoryTitle"),visible:!1},{type:"text",name:"tooltip",title:o.getLocString("presets.toolbox.tooltip"),visible:!1},this.createItemsMatrixJSON({name:this.nameInnerMatrix,titleLocation:"hidden",allowAddRows:!0,addRowButtonLocation:"bottom",noRowsText:o.getLocString("presets.toolbox.noItemsText"),addRowText:o.getLocString("presets.toolbox.addNewItem"),valueName:"items"},!0)]},this.createItemsMatrixJSON({name:this.nameItems,title:o.getLocString("presets.toolbox.toolbox"),addRowButtonLocation:"top",noRowsText:o.getLocString("presets.toolbox.noItemsText"),addRowText:o.getLocString("presets.toolbox.addCustomItem"),startWithNewLine:!1,visibleIf:this.getTextVisibleIf(this.nameCategoriesMode,"items")},!0),this.createItemsMatrixJSON({allowAddRows:!0,title:o.getLocString("presets.toolbox.hiddenItems"),noRowsText:o.getLocString("presets.toolbox.noHiddenItemsText"),descriptionLocation:"underInput",addRowButtonLocation:"bottom",addRowText:o.getLocString("presets.toolbox.addNewItem"),startWithNewLine:!1,name:this.nameMatrix},!0)]},{type:"panel",title:" ",name:this.navigationPanelName,elements:[{type:"boolean",name:this.nameCategoriesMode,title:o.getLocString("presets.toolbox.enableGrouping"),titleLocation:"hidden",defaultValue:"categories",valueTrue:"categories",valueFalse:"items",clearIfInvisible:"onHidden",renderAs:"switch"},{type:"boolean",name:this.nameShowCategoryTitles,title:o.getLocString("presets.toolbox.showCategoryTitles"),defaultValue:!1,useTitleAsLabel:!0,visibleIf:this.getTextVisibleIf(this.nameCategoriesMode,"categories"),clearIfInvisible:"onHidden",renderAs:"switch"}]}]}},Object.defineProperty(n.prototype,"nameCategoriesMode",{get:function(){return this.fullPath+"_mode"},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"nameItems",{get:function(){return this.fullPath+"_items"},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"nameSubitems",{get:function(){return"subitems"},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"nameShowCategoryTitles",{get:function(){return this.fullPath+"_showCategoryTitles"},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"questionNames",{get:function(){return[this.nameCategories,this.nameItems,this.nameMatrix,this.nameShowCategoryTitles,this.nameCategoriesMode]},enumerable:!1,configurable:!0}),n.prototype.hasIcon=function(e){return e!==this.nameCategories&&e!==this.nameSubitems},n.prototype.getDefaultItems=function(e){return(null==e?void 0:e.name)===this.nameCategories?this.defaultCategories:a(a([],this.defaultItems,!0),this.defaultSubitems,!0)},n.prototype.updateRowAction=function(t,o,n,i,s){e.prototype.updateRowAction.call(this,t,o,n,i,s),"show-detail"==s.id&&t.name!=this.nameCategories&&(s.visible=o.isDetailPanelShowing||!!n.subitems)},n.prototype.findItem=function(e,t,o){return o?e.map(function(e){return e.items.filter(function(e){return e.name==t})[0]}).filter(function(e){return!!e})[0]:e.filter(function(e){return e.name==t})[0]},n.prototype.moveToSubitems=function(e,t,o,n,i){void 0===i&&(i=!1);var s=this.ejectRowData(t,o,i),r=this.itemMenuCategoriesEnabled(e),a=r?this.getQuestionCategories(e):this.getQuestionItems(e),l=JSON.parse(JSON.stringify(a.value)),u=this.findItem(l,n,r);u&&(u.subitems||(u.subitems=[]),u.subitems.push(s)),a.value=l},n.prototype.getExistingKeys=function(t,o){var n=e.prototype.getExistingKeys.call(this,t,o),i=t.getQuestionByName(this.nameItems).value||[],s=a(a([],n,!0),i,!0),r=s.map(function(e){return e.subitems||[]}).flat();return a(a([],s,!0),r,!0)},n.prototype.itemMenuCategoriesEnabled=function(e){return"items"!==e.getValue(this.nameCategoriesMode)},n.prototype.getItemMenuActionsCore=function(n,i,s){var r=this,a=this.getQuestionCategories(n).value,l=e.prototype.getItemMenuActionsCore.call(this,n,i,s),u=this.itemMenuCategoriesEnabled(n),p=a.map(function(e){var o=new t.Action({id:"tosubitemcategory-"+e.category,title:e.title});if(e.items){var a=e.items.filter(function(e){var t;return e.name!=(null===(t=s.value)||void 0===t?void 0:t.name)}).map(function(e){return new t.Action({id:"tosubitem-"+e.name,title:e.title,action:function(){r.moveToSubitems(n,i,s,e.name,!0)}})});r.setSubitemsToAction(o,a)}return o}),c=u?p:p.map(function(e){return e.items}).flat(),d=i.visibleRows.indexOf(s),m=i.value[d];if(!m.subitems){i.name!=this.nameItems&&i.name!=this.nameInnerMatrix||(l.push(new t.Action({id:"subcategories",title:o.getLocString("presets.toolbox.subitems"),css:"sps-list__item--label",enabled:!1,needSeparator:!0})),l.push(new t.Action({id:"convert-to-subcategory",title:o.getLocString("presets.toolbox.enableSubitems"),action:function(){var e=u?r.getQuestionCategories(n):r.getQuestionItems(n),t=JSON.parse(JSON.stringify(e.value)),o=r.findItem(t,m.name,u);o&&(o.subitems=[]),e.value=t,r.updateMatrixRowActions(n,i),s.showDetailPanel()}})));var g=new t.Action({id:"move-as-subitem",title:o.getLocString("presets.toolbox.moveAsSubitem"),needSeparator:!0});this.setSubitemsToAction(g,c),l.push(g)}return l},n.prototype.getJsonValueCore=function(e,t,o){var n={},i=this.getJsonItemsDefinition(e);i&&(n.definition=i);var s=e.getValue(this.nameCategoriesMode);t.toolbox;var r=null==o?void 0:o.categories;if("categories"===s){var a=this.getCategoriesJson(e);Array.isArray(a)&&a.length>0&&!this.isCategoriesSame(a,r)&&(n.categories=this.getCategoriesJson(e))}else n.categories=[];return e.getValue(this.nameShowCategoryTitles)&&(n.showCategoryTitles=!0),Object.keys(n).length>0?n:void 0},n.prototype.getDefaultJsonValueCore=function(e){return{categories:e.toolbox.categories.map(function(e){return{category:e.name,title:e.title,items:e.items.map(function(e){return e.name})}})}},n.prototype.isCategoriesSame=function(e,o){if(e.length!==(null==o?void 0:o.length))return!1;for(var n=0;n<e.length;n++){if(e[n].category!==o[n].category)return!1;var i=o[n].items,s=e[n].items;if(!t.Helpers.isTwoValueEquals(s,i))return!1}return!0},n.prototype.getCategoriesJson=function(e){var t=e.getValue(this.nameCategories);if(Array.isArray(t))return t.map(function(e){var t;return{category:e.category,items:null===(t=e.items)||void 0===t?void 0:t.map(function(e){return e.name})}})},n.prototype.cleanIfNotDiffers=function(e,o){if(!o)return!0;var n=!1;return Object.keys(r(r({},e),o)).forEach(function(i){t.Helpers.isTwoValueEquals(e[i],o[i])?"name"!==i&&delete e[i]:n=!0}),n},n.prototype.getJsonItemsDefinition=function(e){var o=this,n=(("items"===e.getValue(this.nameCategoriesMode)?e.getValue(this.nameItems):(e.getValue(this.nameCategories)||[]).map(function(e){return e.items}).flat())||[]).map(function(e){return r({},e)}),i=!1;return n.forEach(function(e){var t=o.defaultItems.filter(function(t){return t.name==e.name})[0];!e.subitems&&(null==t?void 0:t.subitems)&&(e.subitems=[]),o.cleanIfNotDiffers(e,t)&&(i=!0)}),i||t.Helpers.isTwoValueEquals(n.map(function(e){return e.name}),this.defaultItems.map(function(e){return e.name}))||(i=!0),i?n:void 0},n.prototype.isItemsMatrix=function(t){return t===this.nameItems||t===this.nameSubitems||e.prototype.isItemsMatrix.call(this,t)},n.prototype.onMatrixRowRemoving=function(t,o,n){n.question.name==this.nameMatrix&&("items"===t.getValue(this.nameCategoriesMode)&&this.restoreItems(this.getQuestionItems(t),n.question,n.rowIndex));e.prototype.onMatrixRowRemoving.call(this,t,o,n)},n.prototype.setupOnCurrentPageCore=function(e,t,o){t.toolbox.forceCompact=!o,t.toolbox.isCompact=!o,t.readOnly!=o&&t.setPropertyValue("readOnly",o),t.toolbox.items.forEach(function(e){return e.enabled=o}),t.toolbox.enabled=o},n.prototype.setupQuestionsCore=function(t,o){e.prototype.setupQuestionsCore.call(this,t,o),this.setupDefaults(t,o.creator)},n.prototype.setupDefaults=function(e,t){var o=this,n=t.toolbox.getDefaultItems([],!0,!0,!0),i=t.toolbox.getDefaultCategories();this.defaultItems=n.map(function(e){return o.createToolboxItemRow(e)}),this.defaultSubitems=[],n.forEach(function(e){var t;e.items&&(t=o.defaultSubitems).push.apply(t,e.items.map(function(e){return o.createToolboxItemRow(e)}))}),this.defaultCategories=i.map(function(e){return o.createToolboxCategoryRow(e)})},n.prototype.setupQuestionsValueCore=function(e,t,o){var n=this.defaultItems.reduce(function(e,t){return e[t.name]=t,e},{}),i=this.defaultCategoriesMap;this.defaultItems.filter(function(e){return e.subitems}).map(function(e){return e.subitems.forEach(function(e){return n[e.name]=e})});var s=((t=t||{}).definition||[]).map(function(e){return"string"==typeof e?{name:e}:e}),a=t.categories||[];s=0===s.length?this.defaultItems:s.map(function(e){return r(r({},n[e.name]||{}),e)});var l={};s.forEach(function(e){return l[e.name]=r(r({},e),{subitems:e.subitems&&e.subitems.map(function(e){return r(r({},n[e.name]||{}),e)})})}),(a=0===a.length?this.defaultCategories:a.map(function(e){var t;return r(r(r({},i[e.category]),e),{items:null===(t=e.items)||void 0===t?void 0:t.map(function(e){return l[e]}).filter(function(e){return!!e})})})).filter(function(e){return e.items}).forEach(function(e){return e.items.forEach(function(e){return delete n[e.name]})});var u=this.defaultItems.filter(function(e){return n[e.name]});e.setValue(this.nameMatrix,u),e.setValue(this.nameCategories,a),this.updateItemsFromCategories(e),this.updateShowCategoriesTitlesElements(e)},n.prototype.onLocaleChangedCore=function(e,t,o){this.setupDefaults(e,o),this.setupQuestionsValueCore(e,t,o)},n.prototype.updateItemsFromCategories=function(e){this.getQuestionItems(e).value=this.getQuestionCategories(e).value.map(function(e){return a([],e.items||[],!0)}).flat()},n.prototype.updateCategoriesFromItems=function(e){var t=this,o=this.getQuestionCategories(e).value,n=a([],this.getQuestionItems(e).value,!0).reduce(function(e,t){return e[t.name]=t,e},{});o.forEach(function(e){e.items=e.items.map(function(e){var t=n[e.name];return delete n[e.name],t}).filter(function(e){return!!e})});var i=Object.keys(n);if(i.length>0){var s=this.findOrCreateCategory(o,"general");s.items=s.items.concat(i.map(function(e){return t.createToolboxItemRow(n[e])}))}this.getQuestionCategories(e).value=o},n.prototype.updateOnValueChangedCore=function(t,o){e.prototype.updateOnValueChangedCore.call(this,t,o),o===this.nameCategoriesMode&&("items"==t.getValue(this.nameCategoriesMode)?this.updateItemsFromCategories(t):this.updateCategoriesFromItems(t)),o===this.nameShowCategoryTitles&&this.updateShowCategoriesTitlesElements(t)},n.prototype.updateShowCategoriesTitlesElements=function(e){var t=this;e.getValue(this.nameShowCategoryTitles),this.getQuestionCategories(e).visibleRows.fo