Liferay.Loader.define("dynamic-data-mapping-form-web@4.0.121/admin/js/components/share-form/Email.es",["module","exports","require","@frontend-taglib-clay$clayui/data-provider","@frontend-taglib-clay$clayui/form","@frontend-taglib-clay$clayui/multi-select","liferay!frontend-js-react-web$react"],(function(e,t,a){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r=a("@frontend-taglib-clay$clayui/data-provider"),l=_interopRequireWildcard(a("@frontend-taglib-clay$clayui/form")),n=_interopRequireWildcard(a("@frontend-taglib-clay$clayui/multi-select")),u=_interopRequireWildcard(a("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 a={},r=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var l in e)if(Object.prototype.hasOwnProperty.call(e,l)){var n=r?Object.getOwnPropertyDescriptor(e,l):null;n&&(n.get||n.set)?Object.defineProperty(a,l,n):a[l]=e[l]}return a.default=e,t&&t.set(e,a),a}function formatAutocompleteValue(e){return"".concat(e.fullName," (").concat(e.emailAddress,")")}function isEmailAddressValid(e){return/.+@.+\..+/i.test(e.label)}function formatAutocompleteUsersFromRequest(e,t){return e.length?(0,n.itemLabelFilter)(e.map((e=>({label:e.emailAddress,value:formatAutocompleteValue(e)}))),t):e}var _default=({addresses:e,autocompleteUserURL:t,emailContent:a,message:o,onMessageChanged:c,onMultiSelectItemsChanged:d,onSubjectChanged:i,subject:s})=>{const[f,m]=(0,u.useState)(""),[p,g]=(0,u.useState)(4),{resource:y}=(0,r.useResource)({fetchPolicy:"cache-first",link:t,onNetworkStatusChange:g});return u.default.createElement("div",{className:"share-form-modal-item-email"},u.default.createElement(l.default.Group,null,u.default.createElement("label",null,Liferay.Language.get("to")),u.default.createElement(l.ClayInput.Group,{small:!0,stacked:!0},u.default.createElement(l.ClayInput.GroupItem,null,!(5===p)&&u.default.createElement(u.default.Fragment,null,u.default.createElement(n.default,{closeButtonAriaLabel:Liferay.Language.get("remove"),items:e,onChange:m,onClearAllButtonClick:()=>{a.current.addresses=[],d([])},onItemsChange:e=>{if(!e.length)return a.current.addresses=e,d(e);const t=e.filter(isEmailAddressValid);return t.length?(a.current.addresses=t,d(t)):void 0},placeholder:Liferay.Language.get("enter-a-list-of-email-addresses"),sourceItems:y?formatAutocompleteUsersFromRequest(y,f):[],value:f}),u.default.createElement(l.default.FeedbackGroup,null,u.default.createElement(l.default.Text,null,Liferay.Language.get("type-a-comma-or-press-enter-to-input-email-addresses"))))))),u.default.createElement(l.default.Group,null,u.default.createElement("label",{htmlFor:"subject"},Liferay.Language.get("subject")),u.default.createElement(l.ClayInput.Group,null,u.default.createElement(l.ClayInput.GroupItem,null,u.default.createElement(l.ClayInput,{className:"form-control",id:"subject",onChange:({target:{value:e}})=>{a.current.subject=e,i(e)},type:"text",value:s})))),u.default.createElement(l.default.Group,null,u.default.createElement("label",{htmlFor:"message"},Liferay.Language.get("message")),u.default.createElement(l.ClayInput.Group,null,u.default.createElement(l.ClayInput.GroupItem,null,u.default.createElement(l.ClayInput,{className:"form-control",component:"textarea",id:"message",onChange:({target:{value:e}})=>{a.current.message=e,c(e)},type:"text",value:o})))))};t.default=_default}}));
//# sourceMappingURL=Email.es.js.map