Liferay.Loader.define("portal-search-synonyms-web@3.0.44/js/components/SynonymSetsForm.es",["module","exports","require","@frontend-taglib-clay$clayui/button","@frontend-taglib-clay$clayui/form","@frontend-taglib-clay$clayui/layout","@frontend-taglib-clay$clayui/multi-select","liferay!frontend-js-react-web$prop-types","liferay!frontend-js-react-web$react"],(function(e,t,n){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var a=_interopRequireDefault(n("@frontend-taglib-clay$clayui/button")),r=_interopRequireWildcard(n("@frontend-taglib-clay$clayui/form")),l=_interopRequireDefault(n("@frontend-taglib-clay$clayui/layout")),i=_interopRequireDefault(n("@frontend-taglib-clay$clayui/multi-select")),u=(_interopRequireDefault(n("liferay!frontend-js-react-web$prop-types")),_interopRequireWildcard(n("liferay!frontend-js-react-web$react")));function _getRequireWildcardCache(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return _getRequireWildcardCache=function _getRequireWildcardCache(){return e},e}function _interopRequireWildcard(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=_getRequireWildcardCache();if(t&&t.has(e))return t.get(e);var n={},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){var l=a?Object.getOwnPropertyDescriptor(e,r):null;l&&(l.get||l.set)?Object.defineProperty(n,r,l):n[r]=e[r]}return n.default=e,t&&t.set(e,n),n}function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function _defineProperty(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function filterDuplicates(e){const t=function filterEmptyStrings(e){return e.filter((({label:e,value:t})=>e&&t))}(function trimListItems(e){return e.map((({label:e,value:t})=>({label:e.trim(),value:t.trim()})))}(e));return t.filter(((e,n)=>t.findIndex((t=>t.label.toLowerCase()===e.label.toLowerCase()&&t.value.toLowerCase()===e.value.toLowerCase()))===n))}class SynonymSetsForm extends u.Component{constructor(e){super(e),_defineProperty(this,"state",{inputValue:"",synonyms:[]}),_defineProperty(this,"_handleCancel",(()=>{window.history.back()})),_defineProperty(this,"_handleInputChange",(e=>{this.setState({inputValue:e})})),_defineProperty(this,"_handleSubmit",(e=>{e.preventDefault();const t=document.forms[this.props.formName],n=this.state.synonyms.map((e=>e.value));t.elements[this.props.inputName].value=n,submitForm(t)})),_defineProperty(this,"_handleItemsChange",(e=>{this.setState({synonyms:filterDuplicates(e)})})),e.synonymSets.length&&e.synonymSets.split(",").forEach((e=>{this.state.synonyms.push({label:e,value:e})}))}render(){const{inputValue:e,synonyms:t}=this.state;return u.default.createElement("div",{className:"synonym-sets-form"},u.default.createElement("div",{className:"sheet-title"},Liferay.Language.get("create-synonym-set")),u.default.createElement("div",{className:"sheet-text"},Liferay.Language.get("broaden-the-scope-of-search-by-treating-terms-equally-using-synonyms")),u.default.createElement(r.default.Group,null,u.default.createElement("label",{htmlFor:"synonym-sets-input"},Liferay.Language.get("synonyms")),u.default.createElement(r.ClayInput.Group,null,u.default.createElement(r.ClayInput.GroupItem,null,u.default.createElement(i.default,{id:"synonym-sets-input",items:t,onChange:this._handleInputChange,onItemsChange:this._handleItemsChange,value:e}),u.default.createElement(r.default.FeedbackGroup,null,u.default.createElement(r.default.Text,null,Liferay.Language.get("type-a-comma-or-press-enter-to-input-a-synonym")))))),u.default.createElement(l.default.SheetFooter,null,u.default.createElement(a.default,{disabled:!t.length,displayType:"primary",onClick:this._handleSubmit,type:"submit"},Liferay.Language.get("publish")),u.default.createElement(a.default,{displayType:"secondary",onClick:this._handleCancel},Liferay.Language.get("cancel"))))}}_defineProperty(SynonymSetsForm,"defaultProps",{synonymSets:""});var o=SynonymSetsForm;t.default=o}}));
//# sourceMappingURL=SynonymSetsForm.es.js.map