AUI.add("liferay-portlet-dynamic-data-mapping-custom-fields",(e=>{const t=e.Array,a=e.Escape,i=e.FormBuilderTextField,o=e.FormBuilderField.types,r=Liferay.FormBuilder.Util,l=e.Lang,n={false:'No',true:'Yes'},s=e.DataType.Boolean.parse,d=l.String.camelize,c={cancel:'Cancel',edit:'Edit',save:'Save'},u=e.instanceOf,p=l.isNull,g=l.isObject,y=l.isUndefined,m=l.isValue,f=function structureFieldIndexEnable(){for(let t=0;t<Liferay.Portlet.list.length;t++){const a=e.one("#_"+Liferay.Portlet.list[t]+"_indexable");if(a){if("false"===a.getAttribute("value"))return!1}}return!0},L=e.getClassName("field"),h=e.getClassName("field","choice"),b=e.getClassName("field","radio"),E=e.getClassName("form-builder-field","node"),v=e.getClassName("radio"),T=e.config.FormValidator,N=Liferay.FormBuilder.LOCALIZABLE_FIELD_ATTRS,F="submit",_="",S='<input class="field form-control" type="text" value="'+e.Escape.html('Color')+'" readonly="readonly">',M='<div class="field-labels-inline"><img src="'+themeDisplay.getPathThemeImages()+'/common/geolocation.png" title="'+e.Escape.html('Geolocate')+'" /><div>',C='<div class="form-group"><input class="field form-control" type="text" value="" readonly="readonly"><div class="button-holder"><button class="btn btn-secondary select-button" type="button"><span class="lfr-btn-label">'+e.Escape.html('Select')+"</span></button></div></div>",A='<div class="'+v+'"><label class="radio-inline" for="{id}"><input id="{id}" class="'+[L,h,b,E].join(" ")+'" name="{name}" type="radio" value="{value}" {checked} {disabled} />{label}</label></div>',D='<div class="form-group"><input class="field form-control" type="text" value="" readonly="readonly"><div class="button-holder"><button class="btn btn-secondary select-button" type="button"><span class="lfr-btn-label">'+e.Escape.html('Select')+'</span></button></div><label class="control-label">'+e.Escape.html('Image\x20Description')+"</label>"+Liferay.Util.getLexiconIconTpl("asterisk")+'<input class="field form-control" type="text" value="" disabled></div>',x=Liferay.FormBuilder.UNIQUE_FIELD_NAMES_MAP,R=Liferay.FormBuilder.UNLOCALIZABLE_FIELD_ATTRS;T.STRINGS.structureDuplicateFieldName='Please\x20enter\x20a\x20unique\x20field\x20name\x2e',T.RULES.structureDuplicateFieldName=function(e,t){const a=this,i=x.getValue(e),o=i&&!i.get("selected");return o&&(t.selectText(0,e.length),a.resetField(t)),!o},T.STRINGS.structureFieldName='Please\x20enter\x20only\x20alphanumeric\x20characters\x20or\x20underscore\x2e',T.RULES.structureFieldName=function(e){return r.validateFieldName(e)},T.STRINGS.structureRestrictedFieldName=l.sub('\x7b0\x7d\x20is\x20a\x20reserved\x20word\x20and\x20cannot\x20be\x20used\x2e',[F]),T.RULES.structureRestrictedFieldName=function(e){return F!==e};const U=function applyStyles(e,t){const a=t.replace(/\n/g,_).split(";");e.setStyle(_),a.forEach((t=>{const a=t.split(":");if(2===a.length){const t=d(a[0]),i=a[1].trim();e.setStyle(t,i)}}))},P=e.Component.create({EXTENDS:e.BaseCellEditor,NAME:"color-cell-editor",prototype:{_defSaveFn(){const e=this,t=e.get("colorPicker"),a=e.get("boundingBox").one("input");/#[A-F\d]{6}/.test(a.val().toUpperCase())?P.superclass._defSaveFn.apply(e,arguments):t.show()},_uiSetValue(e){const t=this.get("boundingBox").one("input");t.setStyle("color",e),t.val(e),this.elements.val(e)},ELEMENT_TEMPLATE:'<input type="text" />',getElementsValue(){let e;const t=this.get("boundingBox").one("input");if(t){const a=t.val().toUpperCase();(/#[A-F\d]{6}/.test(a)||""===a)&&(e=a)}return e},renderUI(){const t=this;P.superclass.renderUI.apply(t,arguments);const a=t.get("boundingBox").one("input"),i=new e.ColorPickerPopover({trigger:a,zIndex:65535}).render();i.on("select",(e=>{a.setStyle("color",e.color),a.val(e.color),t.fire("save",{newVal:t.getValue(),prevVal:e.color})})),t.set("colorPicker",i)}}}),k=e.Component.create({EXTENDS:e.BaseCellEditor,NAME:"document-library-file-entry-cell-editor",prototype:{_defInitToolbarFn(){const t=this;k.superclass._defInitToolbarFn.apply(t,arguments),t.toolbar.add({label:'Select',on:{click:e.bind("_onClickChoose",t)}},1),t.toolbar.add({label:'Clear',on:{click:e.bind("_onClickClear",t)}},2)},_getDocumentLibrarySelectorURL(){const e=this.get("portletNamespace"),t={desiredItemSelectorReturnTypes:"com.liferay.item.selector.criteria.FileEntryItemSelectorReturnType"},a={URL:this._getUploadURL(),desiredItemSelectorReturnTypes:"com.liferay.item.selector.criteria.FileEntryItemSelectorReturnType"},i={"0_json":JSON.stringify(t),"1_json":JSON.stringify(t),"2_json":JSON.stringify(a),criteria:"file",itemSelectedEventName:e+"selectDocumentLibrary",p_p_id:Liferay.PortletKeys.ITEM_SELECTOR,p_p_mode:"view",p_p_state:"pop_up"};return Liferay.Util.PortletURL.createPortletURL(themeDisplay.getLayoutRelativeControlPanelURL(),i).toString()},_getUploadURL(){const e={cmd:"add_temp","javax.portlet.action":"/document_library/upload_file_entry",p_auth:Liferay.authToken,p_p_id:Liferay.PortletKeys.DOCUMENT_LIBRARY};return Liferay.Util.PortletURL.createActionURL(themeDisplay.getLayoutRelativeControlPanelURL(),e).toString()},_isDocumentLibraryDialogOpen(){const e=this.get("portletNamespace");return!!Liferay.Util.getWindow(e+"selectDocumentLibrary")},_onClickChoose(){const e=this,t=e.get("portletNamespace");Liferay.Util.openSelectionModal({onSelect:t=>{if(t){const a=JSON.parse(t.value);e._selectFileEntry(a.groupId,a.title,a.uuid)}},selectEventName:t+"selectDocumentLibrary",title:'Select\x20File',url:e._getDocumentLibrarySelectorURL()})},_onClickClear(){this.set("value",_)},_onDocMouseDownExt(e){const t=this,a=t.get("boundingBox");t._isDocumentLibraryDialogOpen()||a.contains(e.target)||t.set("visible",!1)},_selectFileEntry(e,t,a){this.set("value",JSON.stringify({groupId:e,title:t,uuid:a}))},_syncElementsFocus(){const e=this,t=e.toolbar.get("boundingBox").one("button");t?t.focus():k.superclass._syncElementsFocus.apply(e,arguments)},_syncFileLabel(t,a){const i=this.get("contentBox");let o=i.one("a");o||(o=e.Node.create("<a></a>"),i.prepend(o)),o.setAttribute("href",a),o.setContent(Liferay.Util.escapeHTML(t))},_uiSetValue(e){const t=this;e?r.getFileEntry(e,(e=>{const a=r.getFileEntryURL(e);t._syncFileLabel(e.title,a)})):(t._syncFileLabel(_,_),e=_),t.elements.val(e)},ELEMENT_TEMPLATE:'<input type="hidden" />',getElementsValue(){return this.get("value")}}}),z=e.Component.create({EXTENDS:e.TextCellEditor,NAME:"text-cell-editor",prototype:{ELEMENT_TEMPLATE:'<input type="text" />',getElementsValue(){const e=this;let t;const a=e.get("boundingBox").one("input");if(a){const e=a.val();(/^[+-]?(\d+)*$/.test(e)||""===e)&&(t=e)}if(t)return t;e.fire("save",{newVal:"",prevVal:t})}}}),I=e.Component.create({EXTENDS:e.TextCellEditor,NAME:"text-cell-editor",prototype:{ELEMENT_TEMPLATE:'<input type="text" />',getElementsValue(){const e=this;let t;const a=e.get("boundingBox").one("input");if(a){const e=a.val();(/^[+-]?(\d+)([.,]\d+)*$/.test(e)||""===e)&&(t=e)}if(t)return t;e.fire("save",{newVal:"",prevVal:t})}}});Liferay.FormBuilder.CUSTOM_CELL_EDITORS={};[P,k,z,I].forEach((e=>{Liferay.FormBuilder.CUSTOM_CELL_EDITORS[e.NAME]=e}));const V=function LiferayFieldSupport(){};V.ATTRS={autoGeneratedName:{setter:s,value:!0},indexType:{valueFn:()=>f()?"keyword":""},localizable:{setter:s,value:!0},name:{setter:r.normalizeKey,validator:e=>!x.has(e),valueFn(){let t=r.normalizeKey(this.get("label"));t=t.replace(/[^a-z0-9]/gi,"");let a=t+this._randomString(4);for(;x.has(a);)a=e.FormBuilderField.buildFieldName(a);return a}},repeatable:{setter:s,value:!1}},V.prototype.initializer=function(){this.after("nameChange",this._afterNameChange)},V.prototype._afterNameChange=function(e){x.remove(e.prevVal),x.put(e.newVal,this)},V.prototype._handleDeleteEvent=function(e){const t=this,a=t.getStrings(),i=Liferay.Util.Window.getWindow({dialog:{bodyContent:a.deleteFieldsMessage,destroyOnHide:!0,height:200,resizable:!1,toolbars:{footer:[{cssClass:"btn-primary",label:'OK',on:{click(){t.destroy(),i.hide()}}},{label:'Cancel',on:{click(){i.hide()}}}]},width:700},title:t.get("label")}).render().show();e.stopPropagation()},V.prototype._randomString=function(e){return Math.ceil(Math.random()*Number.MAX_SAFE_INTEGER).toString(36).substring(0,e)};const w=function LocalizableFieldSupport(){};w.ATTRS={localizationMap:{setter:e.clone,value:{}},readOnlyAttributes:{getter:"_getReadOnlyAttributes"}},w.prototype.initializer=function(){const e=this,t=e.get("builder");e.after("render",e._afterLocalizableFieldRender),N.forEach((t=>{e.after(t+"Change",e._afterLocalizableFieldChange)})),t.translationManager.after("editingLocaleChange",e._afterEditingLocaleChange,e)},w.prototype._afterEditingLocaleChange=function(e){this._syncLocaleUI(e.newVal)},w.prototype._afterLocalizableFieldChange=function(e){const t=this.get("builder").translationManager.get("editingLocale");this._updateLocalizationMapAttribute(t,e.attrName)},w.prototype._afterLocalizableFieldRender=function(){const e=this.get("builder").translationManager.get("editingLocale");this._updateLocalizationMap(e)},w.prototype._getReadOnlyAttributes=function(e){const a=this.get("builder").translationManager;return a.get("defaultLocale")!==a.get("editingLocale")&&(e=R.concat(e)),t.dedupe(e)},w.prototype._syncLocaleUI=function(t){const a=this,i=a.get("builder"),o=a.get("localizationMap"),r=i.translationManager;let l=themeDisplay.getDefaultLanguageId();r&&(l=r.get("defaultLocale"));const n=o[t]||o[l];g(n)&&(N.forEach((e=>{if("options"!==e){const t=n[e];y(t)||p(t)||a.set(e,t)}})),i._syncUniqueField(a)),u(a,e.FormBuilderMultipleChoiceField)&&a._syncOptionsLocaleUI(t),i.editingField===a&&i.propertyList.set("data",a.getProperties())},w.prototype._syncOptionsLocaleUI=function(e){const t=this.get("options");t.forEach((t=>{const a=t.localizationMap;if(g(a)){const i=a[e];g(i)&&(t.label=i.label)}})),this.set("options",t)},w.prototype._updateLocalizationMap=function(e){const t=this;N.forEach((a=>{t._updateLocalizationMapAttribute(e,a)}))},w.prototype._updateLocalizationMapAttribute=function(e,t){const a=this;if("options"===t)a._updateLocalizationMapOptions(e);else{const i=a.get("localizationMap"),o=i[e]||{};o[t]=a.get(t),i[e]=o,a.set("localizationMap",i)}},w.prototype._updateLocalizationMapOptions=function(e){const t=this.get("options");t&&t.forEach((t=>{let a=t.localizationMap;g(a)||(a={}),a[e]={label:t.label},t.localizationMap=a}))};const B=function SerializableFieldSupport(){};B.prototype._addDefinitionFieldLocalizedAttributes=function(t){const a=this;N.forEach((i=>{"options"===i?u(a,e.FormBuilderMultipleChoiceField)&&a._addDefinitionFieldOptions(t):t[i]=a._getLocalizedValue(i)}))},B.prototype._addDefinitionFieldUnlocalizedAttributes=function(e){const t=this;R.forEach((a=>{e[a]=t.get(a)}))},B.prototype._addDefinitionFieldOptions=function(e){const t=this,a=t.get("options"),i=[];if(a){const o=t.get("builder").translationManager.get("availableLocales");a.forEach((e=>{const a={},l=e.localizationMap;a.value=e.value,a.label={},o.forEach((e=>{const i=t._getValue("label",e,l);a.label[e]=r.normalizeValue(i)})),i.push(a)})),e.options=i}},B.prototype._addDefinitionFieldNestedFields=function(e){const t=[];this.get("fields").each((e=>{t.push(e.serialize())})),t.length&&(e.nestedFields=t)},B.prototype._getLocalizedValue=function(e){const t=this,a=t.get("builder"),i=t.get("localizationMap"),o={};return a.translationManager.get("availableLocales").forEach((a=>{o[a]=r.normalizeValue(t._getValue(e,a,i))})),o},B.prototype._getValue=function(t,a,i){const o=this.get("builder").translationManager.get("defaultLocale");let r=e.Object.getValue(i,[a,t]);if(m(r))return r;if(r=e.Object.getValue(i,[o,t]),m(r))return r;for(const a in i)if(r=e.Object.getValue(i,[a,t]),m(r))return r;return _},B.prototype.serialize=function(){const e=this,t={};return e._addDefinitionFieldLocalizedAttributes(t),e._addDefinitionFieldUnlocalizedAttributes(t),e._addDefinitionFieldNestedFields(t),t},e.Base.mix(e.FormBuilderField,[V,w,B]);const O=e.FormBuilderField.prototype,X=O.getPropertyModel;O.getPropertyModel=function(){const t=this,a=X.call(t),i=t.get("type");let o={"":'No',keyword:'Yes'};"ddm-image"!==i&&"text"!==i||(o={"":'Not\x20Indexable',keyword:'Indexable\x20-\x20Keyword',text:'Indexable\x20-\x20Text'}),"ddm-text-html"!==i&&"textarea"!==i||(o={"":'Not\x20Indexable',text:'Indexable\x20-\x20Text'});const r=[];return a.forEach((a=>{"name"===a.attributeName&&(a.editor=new e.TextCellEditor({validator:{rules:{value:{required:!0,structureDuplicateFieldName:!0,structureFieldName:!0,structureRestrictedFieldName:!0}}}})),a.editor&&a.editor.set("strings",c),r.push(a),"required"===a.attributeName&&(a.id="required","ddm-image"===i&&r.push(t.getRequiredDescriptionPropertyModel()))})),r.concat([{attributeName:"indexType",editor:new e.RadioCellEditor({options:o,strings:c}),formatter:e=>o[e.data.value],name:'Indexable'},{attributeName:"localizable",editor:new e.RadioCellEditor({options:n,strings:c}),formatter:e=>n[e.data.value],name:'Localizable'},{attributeName:"repeatable",editor:new e.RadioCellEditor({options:n,strings:c}),formatter:e=>n[e.data.value],name:'Repeatable'}])};const q=e.Component.create({ATTRS:{dataType:{value:"color"},fieldNamespace:{value:"ddm"},showLabel:{value:!1}},EXTENDS:e.FormBuilderField,NAME:"ddm-color",prototype:{getHTML:()=>S,getPropertyModel(){const e=q.superclass.getPropertyModel.apply(this,arguments);return e.forEach(((e,t,a)=>{const i=e.attributeName;"predefinedValue"===i&&(a[t]={attributeName:i,editor:new P({strings:c}),name:'Predefined\x20Value'})})),e}}}),j=e.Component.create({ATTRS:{dataType:{value:"date"},fieldNamespace:{value:"ddm"}},EXTENDS:e.FormBuilderTextField,NAME:"ddm-date",prototype:{getPropertyModel(){const t=j.superclass.getPropertyModel.apply(this,arguments);return t.forEach(((t,a,i)=>{const o=t.attributeName;"predefinedValue"===o&&(i[a]={attributeName:o,editor:new e.DateCellEditor({dateFormat:"%m/%d/%Y",inputFormatter(e){const t=this;let a=e;return Array.isArray(e)&&(a=t.formatDate(e[0])),a},outputFormatter(t){const a=this;let i=t;if(Array.isArray(t)){i=[e.DataType.Date.parse(a.get("dateFormat"),t[0])]}return i}}),name:'Predefined\x20Value',strings:c})})),t},renderUI(){const t=this;j.superclass.renderUI.apply(t,arguments);let a={};const i=function onKeyDown(e){16===e.keyCode&&(a[e.keyCode]=!0)},o=function onKeyUp(e){16===e.keyCode&&delete a[e.keyCode]},r=t.get("templateNode").one("input"),l=function closePopoverOnKeyboardNavigation(e){e.hide(),a={},r&&Liferay.Util.focusFormField(r)};r&&(t.datePicker=new e.DatePickerDeprecated({calendar:{locale:Liferay.ThemeDisplay.getLanguageId()},on:{destroy(){document.removeEventListener("keydown",i),document.removeEventListener("keyup",o)},enterKey(){let t=0;const a=setInterval((()=>{const i=e.one(".datepicker-popover:not(.popover-hidden) .yui3-calendarnav-prevmonth");i?(Liferay.Util.focusFormField(i),clearInterval(a)):t>10&&clearInterval(a),t++}),100)},init(){document.addEventListener("keydown",i),document.addEventListener("keyup",o)},selectionChange(a){const i=a.newSelection;t.setValue(e.Date.format(i))}},popover:{on:{keydown(e){const t=this,i=e.domEvent;a[i.keyCode]=!0;const o=9===i.keyCode||a[9],r=16===i.keyCode||a[16],n=o&&!r,s=27===i.keyCode||a[27],d=i.target.hasClass("yui3-calendar-grid")||i.target.hasClass("yui3-calendar-day");(n&&d||s)&&l(t)},keyup(e){const t=this,i=e.domEvent,o=9===i.keyCode||a[9],r=16===i.keyCode||a[16],n=o&&r,s=i.target.hasClass("yui3-calendar-focused");n&&s&&l(t),delete a[i.keyCode]}}},trigger:r}).render()),t.datePicker.calendar.set("strings",{next:'Next',none:'None',previous:'Previous',today:'Today'})}}}),H=e.Component.create({ATTRS:{dataType:{value:"decimal"},fieldNamespace:{value:"ddm"}},EXTENDS:e.FormBuilderTextField,NAME:"ddm-decimal",prototype:{getPropertyModel(){const e=H.superclass.getPropertyModel.apply(this,arguments);return e.forEach(((e,t,a)=>{const i=e.attributeName;"predefinedValue"===i&&(a[t]={attributeName:i,editor:new I({strings:c}),name:'Predefined\x20Value'})})),e}}}),K=e.Component.create({ATTRS:{dataType:{value:"document-library"},fieldNamespace:{value:"ddm"}},EXTENDS:e.FormBuilderField,NAME:"ddm-documentlibrary",prototype:{_defaultFormatter:()=>"documents-and-media",_uiSetValue:()=>'Select',getHTML:()=>C,getPropertyModel(){const e=this,t=K.superclass.getPropertyModel.apply(e,arguments);return t.forEach((t=>{const a=t.attributeName;"predefinedValue"===a?(t.editor=new k({strings:c}),t.formatter=function(e){const t=e.data;let a=_;return t.value!==_&&(a="("+'File'+")"),a}):"type"===a&&(t.formatter=e._defaultFormatter)})),t}}}),G=e.Component.create({ATTRS:{dataType:{value:"geolocation"},fieldNamespace:{value:"ddm"},localizable:{setter:s,value:!1}},EXTENDS:e.FormBuilderField,NAME:"ddm-geolocation",prototype:{getHTML:()=>M,getPropertyModel(){return G.superclass.getPropertyModel.apply(this,arguments).filter((e=>"predefinedValue"!==e.attributeName))}}}),J=e.Component.create({ATTRS:{dataType:{value:"image"},fieldNamespace:{value:"ddm"},indexType:{valueFn:()=>f()?"text":""},requiredDescription:{setter:s,value:!0}},EXTENDS:e.FormBuilderField,NAME:"ddm-image",prototype:{getHTML:()=>D,getRequiredDescriptionPropertyModel:()=>({attributeName:"requiredDescription",editor:new e.RadioCellEditor({options:n,strings:c}),formatter:e=>n[e.data.value],id:"requiredDescription",name:'Required\x20Description'})}}),Y=e.Component.create({ATTRS:{dataType:{value:"integer"},fieldNamespace:{value:"ddm"}},EXTENDS:e.FormBuilderTextField,NAME:"ddm-integer",prototype:{getPropertyModel(){const e=Y.superclass.getPropertyModel.apply(this,arguments);return e.forEach(((e,t,a)=>{const i=e.attributeName;"predefinedValue"===i&&(a[t]={attributeName:i,editor:new z({strings:c}),name:'Predefined\x20Value'})})),e}}}),W=e.Component.create({ATTRS:{dataType:{value:"number"},fieldNamespace:{value:"ddm"}},EXTENDS:e.FormBuilderTextField,NAME:"ddm-number",prototype:{getPropertyModel(){const e=Y.superclass.getPropertyModel.apply(this,arguments);return e.forEach(((e,t,a)=>{const i=e.attributeName;"predefinedValue"===i&&(a[t]={attributeName:i,editor:new I({strings:c}),name:'Predefined\x20Value'})})),e}}}),Z=e.Component.create({ATTRS:{dataType:{value:void 0},fieldNamespace:{value:"ddm"},showLabel:{readOnly:!0,value:!0},style:{value:_}},EXTENDS:e.FormBuilderField,NAME:"ddm-paragraph",UI_ATTRS:["label","style"],prototype:{_uiSetLabel(e){this.get("templateNode").setContent(e)},_uiSetStyle(e){const t=this.get("templateNode");U(t,e)},getHTML:()=>"<p></p>",getPropertyModel:()=>[{attributeName:"type",editor:!1,name:'Type'},{attributeName:"label",editor:new e.TextAreaCellEditor({strings:c}),name:'Text'},{attributeName:"style",editor:new e.TextAreaCellEditor({strings:c}),name:'Style'}]}}),$=e.Component.create({ATTRS:{dataType:{value:"radio"},predefinedValue:{setter:e=>e}},EXTENDS:e.FormBuilderRadioField,NAME:"ddm-radio",OVERRIDE_TYPE:"radio",prototype:{_uiSetOptions(t){const i=this,o=[];let r=0;const n=i.get("predefinedValue"),s=i.get("templateNode");e.each(t,(e=>{const t=n===e.value;o.push(l.sub(A,{checked:t?'checked="checked"':"",disabled:i.get("disabled")?'disabled="disabled"':"",id:a.html(i.get("id")+r++),label:a.html(e.label),name:a.html(i.get("name")),value:a.html(e.value)}))})),i.optionNodes=e.NodeList.create(o.join("")),s.setContent(i.optionNodes)},_uiSetPredefinedValue(e){const t=this.optionNodes;t&&(t.set("checked",!1),t.all('input[value="'+a.html(e)+'"]').set("checked",!0))}}}),Q=e.Component.create({ATTRS:{dataType:{value:void 0},fieldNamespace:{value:"ddm"},showLabel:{value:!1},style:{value:_}},EXTENDS:e.FormBuilderField,NAME:"ddm-separator",UI_ATTRS:["style"],prototype:{_uiSetStyle(e){const t=this.get("templateNode");U(t,e)},getHTML:()=>'<hr class="separator" />',getPropertyModel(){const t=Q.superclass.getPropertyModel.apply(this,arguments);return t.push({attributeName:"style",editor:new e.TextAreaCellEditor({strings:c}),name:'Style'}),t}}}),ee=e.Component.create({ATTRS:{dataType:{value:"html"},fieldNamespace:{value:"ddm"},indexType:{valueFn:()=>f()?"text":""}},EXTENDS:i,NAME:"ddm-text-html",prototype:{getHTML:()=>'<textarea class="form-builder-field-node lfr-ddm-text-html"></textarea>'}}),te=e.Component.create({ATTRS:{dataType:{value:"link-to-page"},fieldNamespace:{value:"ddm"}},EXTENDS:e.FormBuilderField,NAME:"ddm-link-to-page",prototype:{getHTML:()=>C}}),ae=e.Component.create({ATTRS:{indexType:{valueFn:()=>f()?"text":""}},EXTENDS:e.FormBuilderTextAreaField,NAME:"textarea"});[q,j,H,K,G,J,Y,te,W,Z,$,Q,ee,ae].forEach((e=>{o[e.OVERRIDE_TYPE||e.NAME]=e}))}),"",{requires:["aui-base","aui-color-picker-popover","aui-url","liferay-item-selector-dialog","liferay-portlet-dynamic-data-mapping"]});

function ownKeys(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),a.push.apply(a,i)}return a}function _objectSpread(e){for(var t=1;t<arguments.length;t++){var a=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(a),!0).forEach((function(t){_defineProperty(e,t,a[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):ownKeys(Object(a)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(a,t))}))}return e}function _defineProperty(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}AUI.add("liferay-portlet-dynamic-data-mapping",(e=>{const t=e.Array,a=e.Lang,i=document.body,r=e.instanceOf,n=Array.isArray,l=function isFormBuilderField(t){return t instanceof e.FormBuilderField},o=a.isObject,s=a.isString,d=a.isUndefined,g=e.config.FormValidator,u='<label><span class="reference-mark">'+Liferay.Util.getLexiconIconTpl("asterisk")+"</span></label>",c="<span>"+Liferay.Util.getLexiconIconTpl("question-circle-full")+"</span>",p={DEFAULT:["readOnly","width"],checkbox:["readOnly"],separator:["indexType","localizable","predefinedValue","readOnly","required"]},L=/[-–—]/i;g.STRINGS.structureFieldName='Please\x20enter\x20only\x20alphanumeric\x20characters\x2e',g.RULES.structureFieldName=function(e){return/^[\w-]+$/.test(e)},e.PropertyBuilderAvailableField.prototype.FIELD_ITEM_TEMPLATE=e.PropertyBuilderAvailableField.prototype.FIELD_ITEM_TEMPLATE.replace(/<\s*span[^>]*>(.*?)<\s*\/\s*span>/,Liferay.Util.getLexiconIconTpl("{iconClass}")),e.ToolbarRenderer.prototype.TEMPLATES.icon=Liferay.Util.getLexiconIconTpl("{cssClass}");const f=e.Component.create({ATTRS:{localizationMap:{validator:o,value:{}},name:{validator:s}},EXTENDS:e.FormBuilderAvailableField,NAME:"availableField"}),y=function ReadOnlyFormBuilderSupport(){};y.ATTRS={readOnly:{value:!1}},e.mix(y.prototype,{_afterFieldRender(a){const i=a.target;if(r(i,e.FormBuilderField)){const e=t.map(i.getPropertyModel(),(e=>e.attributeName));i.set("readOnlyAttributes",e)}},_afterRenderReadOnlyFormBuilder(){const e=this;e.tabView.enableTab(1),e.openEditProperties(e.get("fields").item(0)),e.tabView.getTabs().item(0).hide()},_onMouseOverFieldReadOnlyFormBuilder(t){const a=e.Widget.getByNode(t.currentTarget);a.controlsToolbar.hide(),a.get("boundingBox").removeClass("form-builder-field-hover")},initializer(){const e=this;e.get("readOnly")&&(e.set("allowRemoveRequiredFields",!1),e.set("enableEditing",!1),e.translationManager.hide(),e.after("render",e._afterRenderReadOnlyFormBuilder),e.after("*:render",e._afterFieldRender),e.dropContainer.delegate("mouseover",e._onMouseOverFieldReadOnlyFormBuilder,".form-builder-field"))}}),e.LiferayAvailableField=f;const b=e.Component.create({ATTRS:{availableFields:{validator:o,valueFn:()=>b.AVAILABLE_FIELDS.DEFAULT},fieldNameEditionDisabled:{value:!1},portletNamespace:{value:""},portletResourceNamespace:{value:""},propertyList:{value:{strings:{asc:'Ascending',desc:'Descending',propertyName:'Property\x20Name',reverseSortBy:a.sub('Reverse\x20Sort\x20by\x20\x7b0\x7d',["{column}"]),sortBy:a.sub('Sort\x20by\x20\x7b0\x7d',["{column}"]),value:'Value'}}},strings:{value:{addNode:'Add\x20Field',button:'Button',buttonType:'Button\x20Type',cancel:'Cancel',deleteFieldsMessage:'Are\x20you\x20sure\x20you\x20want\x20to\x20delete\x20the\x20selected\x20entries\x3f\x20They\x20will\x20be\x20deleted\x20immediately\x2e',duplicateMessage:'Duplicate',editMessage:'Edit',label:'Field\x20Label',large:'Large',localizable:'Localizable',medium:'Medium',multiple:'Multiple',name:'Name',no:'No',options:'Options',predefinedValue:'Predefined\x20Value',propertyName:'Property\x20Name',required:'Required',requiredDescription:'Required\x20Description',reset:'Reset',save:'Save',settings:'Settings',showLabel:'Show\x20Label',small:'Small',submit:'Submit',tip:'Tip',type:'Type',value:'Value',width:'Width',yes:'Yes'}},translationManager:{validator:o,value:{}},validator:{setter:e=>_objectSpread({fieldStrings:{name:{required:'This\x20field\x20is\x20required\x2e'}},rules:{name:{required:!0,structureFieldName:!0}}},e),value:{}}},AUGMENTS:[y],EXTENDS:e.FormBuilder,LOCALIZABLE_FIELD_ATTRS:["label","options","predefinedValue","style","tip"],NAME:"liferayformbuilder",UNIQUE_FIELD_NAMES_MAP:new e.Map,UNLOCALIZABLE_FIELD_ATTRS:["dataType","fieldNamespace","indexType","localizable","multiple","name","readOnly","repeatable","required","requiredDescription","showLabel","type"],prototype:{_afterEditingLocaleChange(e){this._toggleInputDirection(e.newVal)},_afterFieldsChange(e){const t=this;1===t.tabView.getTabs().indexOf(t.tabView.getActiveTab())&&t.editField(e.newVal.item(0)),this._handleAlertMessages(t.get("fields"))},_beforeGetEditor(t,a){if("name"===a.key)return;const i=this,n=a.editor,l=t.get("editor")||n;r(l,e.BaseOptionsCellEditor)&&(l.get("rendered")?i._toggleOptionsEditorInputs(l):l.after("render",(()=>{i._toggleOptionsEditorInputs(l)}))),l.after("render",(()=>{l.set("visible",!0);const e=l.get("boundingBox");e&&e.show()}))},_deserializeField(e,t){const a=this,i=e.fields;n(i)&&i.forEach((e=>{a._deserializeField(e,t)})),a._deserializeFieldLocalizationMap(e,t),a._deserializeFieldLocalizableAttributes(e)},_deserializeFieldLocalizableAttributes(e){const t=this.translationManager.get("defaultLocale"),a=this.translationManager.get("editingLocale");b.LOCALIZABLE_FIELD_ATTRS.forEach((i=>{const r=e[i];"options"!==i&&r&&(e[i]=r[a]||r[t])}))},_deserializeFieldLocalizationMap(e,t){const a=this;t.forEach((t=>{e.localizationMap=e.localizationMap||{},e.localizationMap[t]={},b.LOCALIZABLE_FIELD_ATTRS.forEach((a=>{const i=e[a];i&&i[t]&&(e.localizationMap[t][a]=i[t])}))})),e.options&&a._deserializeFieldOptionsLocalizationMap(e,t)},_deserializeFieldOptionsLocalizationMap(e,t){let a;const i=this.translationManager.get("defaultLocale"),r=this.translationManager.get("editingLocale");e.options.forEach((e=>{a=e.label,e.label=a[r]||a[i],e.localizationMap={},t.forEach((t=>{e.localizationMap[t]={label:a[t]}}))}))},_getGeneratedFieldName(e){const t=b.Util.normalizeKey(e);let a=t;if(b.Util.validateFieldName(a)){let e=1;for(;b.UNIQUE_FIELD_NAMES_MAP.has(a);)a=t+e++}return a},_getSerializedFields(){const e=[];return this.get("fields").each((t=>{e.push(t.serialize())})),e},_handleAlertMessages(e){const t=e.some((e=>"ddm-documentlibrary"===e.name)),a=document.querySelector(".ddm-documents-and-media-field");if(null!==a){const e=a.classList.contains("hide");t&&e?a.classList.remove("hide"):t||a.classList.add("hide")}},_onDataTableRender(t){e.on(this._beforeGetEditor,t.target,"getEditor",this)},_onDefaultLocaleChange(e){const t=this,a=t.get("fields"),i=e.newVal,r=t.translationManager;if(r.get("availableLocales").indexOf(i)<0){const n={fields:a,newVal:i,prevVal:e.prevVal};r.addAvailableLocale(i),t._updateLocalizationMaps(n)}},_onMouseOutField(t){const a=e.Widget.getByNode(t.currentTarget);this._setInvalidDDHandles(a,"remove"),b.superclass._onMouseOutField.apply(this,arguments)},_onMouseOverField(t){const a=e.Widget.getByNode(t.currentTarget);this._setInvalidDDHandles(a,"add"),b.superclass._onMouseOverField.apply(this,arguments)},_onPropertyModelChange(e){const t=this,a=t.get("fieldNameEditionDisabled"),i=e.changed,r=e.target.get("attributeName"),n=t.editingField,l=n.get("readOnlyAttributes");if(Object.prototype.hasOwnProperty.call(i,"value")&&-1===l.indexOf("name"))if("name"===r)n.set("autoGeneratedName",!0===e.autoGeneratedName);else if("label"===r&&n.get("autoGeneratedName")&&!a){const e=t.translationManager;if(e.get("editingLocale")===e.get("defaultLocale")){const e=t._getGeneratedFieldName(i.value.newVal);if(b.Util.validateFieldName(e)){const a=t.propertyList.get("data").filter((e=>"name"===e.get("attributeName")));a.length&&a[0].set("value",e,{autoGeneratedName:!0})}}}else"ddm-image"===n.get("type")?"required"===r?(n.get("requiredDescription")&&t._toggleImageDescriptionAsterisk(n,"true"===i.value.newVal),t._toggleRequiredDescriptionPropertyModel(n,"true"===i.value.newVal)):"requiredDescription"===r&&n.get("required")&&t._toggleImageDescriptionAsterisk(n,"true"===i.value.newVal):"multiple"===r&&"false"===i.value.newVal&&(n.set("multiple",i.value.newVal),n.set("predefinedValue",[""]),t.editField(n))},_renderSettings(){const t=this;t._renderPropertyList();const a=t.propertyList.getEditor;t.propertyList.getEditor=function(){const t=a.apply(this,arguments);if(t){const a=e.bind(t._setToolbar,t);t._setToolbar=function(e){const t=a(e);return t&&t.children&&(t.children=t.children.map((e=>e=e.map((e=>(delete e.icon,e)))))),t}}return t}},_setAvailableFields(t){const a=t.map((t=>r(t,e.PropertyBuilderAvailableField)?t:new e.LiferayAvailableField(t)));return a.sort(((t,a)=>e.ArraySort.compare(t.get("label"),a.get("label")))),a},_setFields(){return b.UNIQUE_FIELD_NAMES_MAP.clear(),b.superclass._setFields.apply(this,arguments)},_setFieldsSortableListConfig(){const t=b.superclass._setFieldsSortableListConfig.apply(this,arguments);return t.dd.plugins=[{cfg:{constrain:"#main-content"},fn:e.Plugin.DDConstrained},{cfg:{horizontal:!1,node:"#main-content"},fn:e.Plugin.DDNodeScroll}],t},_setInvalidDDHandles(e,t){const a=t+"Invalid";this.eachParentField(e,(e=>{const t=e.get("boundingBox");t.dd[a]("#"+t.attr("id"))}))},_toggleImageDescriptionAsterisk(e,t){const a=e._getFieldNode().one(".lexicon-icon-asterisk");a&&a.toggle(t)},_toggleInputDirection(e){const t="rtl"===Liferay.Language.direction[e];i.classList.toggle("form-builder-ltr-inputs",!t),i.classList.toggle("form-builder-rtl-inputs",t)},_toggleOptionsEditorInputs(e){const t=this,a=e.get("boundingBox");if(a.hasClass("radiocelleditor")){const e=t.translationManager.get("defaultLocale"),i=t.translationManager.get("editingLocale"),r=a.all(".celleditor-edit-input-value");Liferay.Util.toggleDisabled(r,e!==i)}},_toggleRequiredDescriptionPropertyModel(e,t){const a=this.propertyList.get("data");t?a.add(_objectSpread(_objectSpread({},e.getRequiredDescriptionPropertyModel()),{},{value:e.get("requiredDescription")}),{index:a.indexOf(a.getById("required"))+1}):a.remove(a.getById("requiredDescription"))},_updateLocalizationMaps(e){const t=this,a=e.fields,i=e.newVal,r=e.prevVal;a._items.forEach((e=>{const a=e.get("fields"),n=e.get("localizationMap"),l={fields:a,newVal:i,prevVal:r};n[i]=n[r],t._updateLocalizationMaps(l)}))},bindUI(){const t=this;b.superclass.bindUI.apply(t,arguments),t.translationManager.after("defaultLocaleChange",t._onDefaultLocaleChange,t),t.translationManager.after("editingLocaleChange",t._afterEditingLocaleChange,t),t.on("datatable:render",t._onDataTableRender),t.on("drag:drag",e.DD.DDM.syncActiveShims,e.DD.DDM,!0),t.on("model:change",t._onPropertyModelChange)},createField(){const t=this,a=b.superclass.createField.apply(t,arguments);"ddm-image"===a.name&&(a.get("required")?!1===a.get("requiredDescription")&&t._toggleImageDescriptionAsterisk(a,!1):(t._toggleImageDescriptionAsterisk(a,!1),t.MAP_HIDDEN_FIELD_ATTRS.DEFAULT.push("requiredDescription"))),a.set("requiredFlagNode",e.Node.create(u)),a.set("tipFlagNode",e.Node.create(c));const i=e.bind(a._getToolbarItems,a);a._getToolbarItems=function(){const e=i();return e&&e.map((e=>e.map((e=>(e.icon&&(e.icon=e.icon.replace("glyphicon glyphicon-","").replace("wrench","cog")),e)))))},a.set("strings",t.get("strings"));const r={checkbox:t.MAP_HIDDEN_FIELD_ATTRS.checkbox,"ddm-separator":t.MAP_HIDDEN_FIELD_ATTRS.separator,default:t.MAP_HIDDEN_FIELD_ATTRS.DEFAULT};let n=r[a.get("type")];return n||(n=r.default),a.set("hiddenAttributes",n),a},deserializeDefinitionFields(e){const t=this,a=e.availableLanguageIds,i=e.fields;return i.forEach((e=>{t._deserializeField(e,a)})),i},eachParentField(e,t){const a=this;let i=e.get("parent");for(;l(i);)t.call(a,i),i=i.get("parent")},getContent(){const e={},t=this.translationManager;return e.availableLanguageIds=t.get("availableLocales"),e.defaultLanguageId=t.get("defaultLocale"),e.fields=this._getSerializedFields(),JSON.stringify(e,null,4)},getContentValue(){return window[this.get("portletResourceNamespace")+"getContentValue"]()},initializer(){const t=this;t.MAP_HIDDEN_FIELD_ATTRS=e.clone(p);const a=t.translationManager=new Liferay.TranslationManager(t.get("translationManager"));t.after("render",(()=>{a.render()})),t.after("fieldsChange",t._afterFieldsChange),themeDisplay.isStatePopUp()&&t.addTarget(Liferay.Util.getOpener().Liferay),t._toggleInputDirection(a.get("defaultLocale"))},plotField(e){return b.UNIQUE_FIELD_NAMES_MAP.put(e.get("name"),e),b.superclass.plotField.apply(this,arguments)}}});b.Util={getFileEntry(e,t){e=this.parseJSON(e),Liferay.Service("/dlapp/get-file-entry-by-uuid-and-group-id",{groupId:e.groupId,uuid:e.uuid},t)},getFileEntryURL:e=>[themeDisplay.getPathContext(),"documents",e.groupId,e.folderId,encodeURIComponent(e.title)].join("/"),normalizeKey(t){t=t.trim();for(let a=0;a<t.length;a++){const i=t[a];e.Text.Unicode.test(i,"L")||e.Text.Unicode.test(i,"N")||e.Text.Unicode.test(i,"Pd")||"_"===i||(t=t.replace(i," "))}return(t=a.String.camelize(t," ")).replace(/\s+/gi,"")},normalizeValue:e=>(d(e)&&(e=""),e),parseJSON(e){let t={};try{t=JSON.parse(e)}catch(e){}return t},validateFieldName(t){let a=!0;if(L.test(t))return a=!1,a;for(let i=0;i<t.length;i++){const r=t[i];if(!e.Text.Unicode.test(r,"L")&&!e.Text.Unicode.test(r,"N")&&!e.Text.Unicode.test(r,"Pd")&&"_"!==r){a=!1;break}}return a}},b.DEFAULT_ICON_CLASS="text";const m={DDM_STRUCTURE:[{hiddenAttributes:p.checkbox,iconClass:"check-square",label:'Boolean',type:"checkbox"},{hiddenAttributes:p.DEFAULT,iconClass:"adjust",label:'Color',type:"ddm-color"},{hiddenAttributes:p.DEFAULT,iconClass:"calendar",label:'Date',type:"ddm-date"},{hiddenAttributes:p.DEFAULT,iconClass:"decimal",label:'Decimal',type:"ddm-decimal"},{hiddenAttributes:p.DEFAULT,iconClass:"document-text",label:'Documents\x20and\x20Media',type:"ddm-documentlibrary"},{hiddenAttributes:p.DEFAULT,iconClass:"text",label:'Web\x20Content',type:"ddm-journal-article"},{hiddenAttributes:p.DEFAULT,iconClass:"code",label:'HTML',type:"ddm-text-html"},{hiddenAttributes:p.DEFAULT,iconClass:"globe",label:'Geolocation',type:"ddm-geolocation"},{hiddenAttributes:p.DEFAULT,iconClass:"integer",label:'Integer',type:"ddm-integer"},{hiddenAttributes:p.DEFAULT,iconClass:"link",label:'Link\x20to\x20Page',type:"ddm-link-to-page"},{hiddenAttributes:p.DEFAULT,iconClass:"number",label:'Number',type:"ddm-number"},{hiddenAttributes:p.DEFAULT,iconClass:"radio-button",label:'Radio',type:"radio"},{hiddenAttributes:p.DEFAULT,iconClass:"select",label:'Select',type:"select"},{hiddenAttributes:p.DEFAULT,iconClass:"text",label:'Text',type:"text"},{hiddenAttributes:p.DEFAULT,iconClass:"textbox",label:'Text\x20Box',type:"textarea"}],DDM_TEMPLATE:[{hiddenAttributes:p.DEFAULT,iconClass:"paragraph",label:'Paragraph',type:"ddm-paragraph"},{hiddenAttributes:p.DEFAULT,iconClass:"separator",label:'Separator',type:"ddm-separator"},{hiddenAttributes:p.DEFAULT,iconClass:"blogs",label:'Fieldset',type:"fieldset"}],DEFAULT:[{fieldLabel:'Button',iconClass:"square-hole",label:'Button',type:"button"},{fieldLabel:'Checkbox',iconClass:"check-square",label:'Checkbox',type:"checkbox"},{fieldLabel:'Fieldset',iconClass:"cards",label:'Fieldset',type:"fieldset"},{fieldLabel:'Text\x20Box',iconClass:"text",label:'Text\x20Box',type:"text"},{fieldLabel:'Text\x20Area\x20\x28HTML\x29',iconClass:"textbox",label:'Text\x20Area\x20\x28HTML\x29',type:"textarea"},{fieldLabel:'Radio\x20Buttons',iconClass:"radio",label:'Radio\x20Buttons',type:"radio"},{fieldLabel:'Select\x20Option',iconClass:"select",label:'Select\x20Option',type:"select"}],WCM_STRUCTURE:[{hiddenAttributes:p.DEFAULT,iconClass:"picture",label:'Image',type:"ddm-image"},{hiddenAttributes:p.separator,iconClass:"separator",label:'Separator',type:"ddm-separator"}]};m.WCM_STRUCTURE=m.WCM_STRUCTURE.concat(m.DDM_STRUCTURE),b.AVAILABLE_FIELDS=m,Liferay.FormBuilder=b}),"",{requires:["arraysort","aui-form-builder-deprecated","aui-form-validator","aui-map","aui-text-unicode","json","liferay-menu","liferay-translation-manager","liferay-util-window","text"]});

