Liferay.Loader.define("portal-workflow-kaleo-designer-web@5.0.85/designer/js/definition-builder/diagram-builder/components/sidebar/sections/shared-components/BaseRole",["module","exports","require","@frontend-taglib-clay$clayui/autocomplete","@frontend-taglib-clay$clayui/data-provider","@frontend-taglib-clay$clayui/drop-down","@frontend-taglib-clay$clayui/form","liferay!frontend-js-react-web$prop-types","liferay!frontend-js-react-web$react","../../../../../constants","../../../../../util/fetchUtil"],(function(e,t,a){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function({defaultFieldValue:e={id:"",name:""},inputLabel:t,selectLabel:a,updateSelectedItem:f}){const[d,s]=(0,c.useState)(!1),[p,y]=(0,c.useState)(!0),[b,g]=(0,c.useState)(e),[O,w]=(0,c.useState)(4),{resource:j}=(0,n.useResource)({fetchOptions:{headers:m(m({},i.headers),{},{accept:"application/json","x-csrf-token":Liferay.authToken})},fetchPolicy:"cache-first",link:"".concat(window.location.origin).concat(u.contextUrl).concat(i.userBaseURL,"/roles"),onNetworkStatusChange:w,variables:{pageSize:-1}});(0,c.useEffect)((()=>{""!==e.name&&g((t=>{const a=m({},t);return a.name=e.name,a}))}),[e]);const v=5===O;return c.default.createElement(c.default.Fragment,null,c.default.createElement(o.default.Group,null,c.default.createElement(r.default,null,c.default.createElement("label",{htmlFor:"role-name"},a),c.default.createElement(r.default.Input,{autoComplete:"off",id:"role-name",onChange:e=>(e=>{e.persist(),y(!0),g((t=>m(m({},t),{},{name:e.target.value})))})(e),onFocus:()=>(y(""===b.name),void s(!0)),placeholder:"Search",value:b.name}),c.default.createElement(r.default.DropDown,{active:!!j&&d,closeOnClickOutside:!0,onSetActive:s},c.default.createElement(l.default.ItemList,null,(v||j&&j.error)&&c.default.createElement(l.default.Item,{className:"disabled"},Liferay.Language.get("no-results-found")),!v&&(null==j?void 0:j.items)&&j.items.filter((e=>p?e.name.toLowerCase().match(b.name.toLowerCase()):e)).map((e=>c.default.createElement(r.default.Item,{key:e.id,onClickCapture:()=>{(e=>{g({id:e.id,name:e.name}),s(!1),f(e)})(e)},value:e.name}))))),O<4&&c.default.createElement(r.default.LoadingIndicator,null))),c.default.createElement(o.default.Group,null,c.default.createElement("label",{htmlFor:"role-id"},t,c.default.createElement("span",{className:"ml-1 mr-1 text-warning"},"*")),c.default.createElement(o.ClayInput,{component:"input",disabled:!0,id:"role-id",type:"text",value:b.id})))};var r=s(a("@frontend-taglib-clay$clayui/autocomplete")),n=a("@frontend-taglib-clay$clayui/data-provider"),l=s(a("@frontend-taglib-clay$clayui/drop-down")),o=d(a("@frontend-taglib-clay$clayui/form")),c=(s(a("liferay!frontend-js-react-web$prop-types")),d(a("liferay!frontend-js-react-web$react"))),u=a("../../../../../constants"),i=a("../../../../../util/fetchUtil");function f(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return f=function(){return e},e}function d(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=f();if(t&&t.has(e))return t.get(e);var a={},r=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){var l=r?Object.getOwnPropertyDescriptor(e,n):null;l&&(l.get||l.set)?Object.defineProperty(a,n,l):a[n]=e[n]}return a.default=e,t&&t.set(e,a),a}function s(e){return e&&e.__esModule?e:{default:e}}function p(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),a.push.apply(a,r)}return a}function m(e){for(var t=1;t<arguments.length;t++){var a=null!=arguments[t]?arguments[t]:{};t%2?p(Object(a),!0).forEach((function(t){y(e,t,a[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):p(Object(a)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(a,t))}))}return e}function y(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}}}));
//# sourceMappingURL=BaseRole.js.map