Liferay.Loader.define("@liferay/object-web@1.0.108/js/components/EditObjectStateField",["module","exports","require","@liferay/object-js-components-web","frontend-js-web","liferay!frontend-js-react-web$react","./ObjectFieldFormBase","./StateManager/StateDefinition"],(function(e,t,r){var n;window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function({objectField:e,readOnly:t}){const[r,n]=(0,o.useState)([]);(0,o.useEffect)((()=>{a.API.getPickListItems(e.listTypeDefinitionId).then(n)}),[e.listTypeDefinitionId,n]);const s=({currentKey:t,pickListItemKey:r})=>void 0!==e.objectFieldSettings.find((({name:e})=>"stateFlow"===e)).value.objectStates.find((e=>e.key===t)).objectStateTransitions.find((({key:e})=>e===r)),{handleSubmit:f,setValues:d,values:b}=(0,c.useObjectFieldForm)({initialValues:e,onSubmit:async e=>{let{id:t}=e,r=function(e,t){if(null==e)return{};var r,n,a=function(e,t){if(null==e)return{};var r,n,a={},i=Object.keys(e);for(n=0;n<i.length;n++)r=i[n],t.indexOf(r)>=0||(a[r]=e[r]);return a}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)r=i[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(a[r]=e[r])}return a}(e,["id"]);delete r.system;try{await a.API.save("/o/object-admin/v1.0/object-fields/".concat(t),r),(0,a.saveAndReload)(),(0,i.openToast)({message:Liferay.Language.get("the-object-field-was-updated-successfully")})}catch(e){(0,i.openToast)({message:e.message,type:"danger"})}}});return o.default.createElement(a.SidePanelForm,{className:"lfr-objects__edit-object-state-field",onSubmit:f,readOnly:t,title:"".concat(e.label[Liferay.ThemeDisplay.getDefaultLanguageId()]," ").concat(Liferay.Language.get("settings"))},o.default.createElement(a.Card,{title:Liferay.Language.get("select-the-state-flow")},null==r?void 0:r.map((({key:e,name:n},a)=>o.default.createElement(l.default,{currentKey:e,disabled:t,index:a,initialValues:r.filter((e=>e.name!==n)).map((t=>u(u({},t),{},{checked:s({currentKey:e,pickListItemKey:t.key})}))),key:a,setValues:d,stateName:n,values:b})))))};var a=r("@liferay/object-js-components-web"),i=r("frontend-js-web"),o=function(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=s();if(t&&t.has(e))return t.get(e);var r={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in e)if(Object.prototype.hasOwnProperty.call(e,a)){var i=n?Object.getOwnPropertyDescriptor(e,a):null;i&&(i.get||i.set)?Object.defineProperty(r,a,i):r[a]=e[a]}r.default=e,t&&t.set(e,r);return r}(r("liferay!frontend-js-react-web$react")),c=r("./ObjectFieldFormBase"),l=(n=r("./StateManager/StateDefinition"))&&n.__esModule?n:{default:n};function s(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return s=function(){return e},e}function f(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function u(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?f(Object(r),!0).forEach((function(t){d(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):f(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function d(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}}}));
//# sourceMappingURL=EditObjectStateField.js.map