"use strict";(globalThis.webpackChunk_openmrs_esm_bed_management_app=globalThis.webpackChunk_openmrs_esm_bed_management_app||[]).push([["1738"],{6003:function(e,t,r){r.r(t),r.d(t,{default:()=>p});var n=r(27350),o=r.n(n),a=r(98900),l=r(20366),c=r(54675),i=r(94180),u=r(68892),s=r(93798);function f(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function y(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r,n,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var a=[],l=!0,c=!1;try{for(o=o.call(e);!(l=(r=o.next()).done)&&(a.push(r.value),!t||a.length!==t);l=!0);}catch(e){c=!0,n=e}finally{try{l||null==o.return||o.return()}finally{if(c)throw n}}return a}}(e,t)||function(e,t){if(e){if("string"==typeof e)return f(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return f(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var d=a.Ry({reason:a.Z_().min(1).max(255)});let p=function(e){var t=e.bedTypeData,r=e.handleDeleteBedType,a=e.closeModal,f=(0,u.useTranslation)().t,p=y((0,n.useState)(!1),2),b=p[0],m=p[1],g=y((0,n.useState)(""),2),h=g[0],O=g[1],v=(0,l.cI)({mode:"all",resolver:(0,c.F)(d)}),j=v.handleSubmit,w=v.control,T=v.formState.isDirty;return o().createElement(o().Fragment,null,o().createElement(i.xBx,{closeModal:a,title:f("deleteBedTypeConfirmation","Are you sure you want to delete this bed type?")}),o().createElement(i.fef,null,o().createElement(i.l09,null,o().createElement(i.cwH,{legendText:""},o().createElement(l.Qr,{control:w,name:"reason",render:function(e){var t,r,n=e.field;return o().createElement(i.oil,(t=function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){var n;n=r[t],t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n})}return e}({},n),r=r={id:"bedType",invalidText:b&&h,labelText:f("reasonForDeletingBedType","Reason for deleting the bed type"),placeholder:f("reasonForDeletingBedTypePlaceholder","Enter a reason for deleting this bed type")},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):(function(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r.push.apply(r,n)}return r})(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}),t))},rules:{required:!0}})))),o().createElement(i.mzw,null,o().createElement(i.zxk,{onClick:a,kind:"secondary"},(0,s.getCoreTranslation)("cancel","Cancel")),o().createElement(i.zxk,{disabled:!T,onClick:j(function(e){d.safeParse(e).success&&(m(!1),r(t.uuid,e.reason,t,a))},function(e){O(Object.entries(e)[0][1].message),m(!0)})},(0,s.getCoreTranslation)("delete","Delete"))))}}}]);