"use strict";(globalThis.webpackChunk_openmrs_esm_patient_vitals_app=globalThis.webpackChunk_openmrs_esm_patient_vitals_app||[]).push([[8953],{48953:(e,t,n)=>{n.r(t),n.d(t,{default:()=>d});var r=n(1343),o=n.n(r),l=n(14863),i=n(72339),a=n(31806),c=n(20299);function u(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function s(e,t,n,r,o,l,i){try{var a=e[l](i),c=a.value}catch(e){return void n(e)}a.done?t(c):Promise.resolve(c).then(r,o)}const d=function(e){var t,n,d=e.encounterUuid,f=e.closeDeleteModal,p=(0,i.useTranslation)().t,b=(t=(0,r.useState)(!1),n=2,function(e){if(Array.isArray(e))return e}(t)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,l=[],i=!0,a=!1;try{for(n=n.call(e);!(i=(r=n.next()).done)&&(l.push(r.value),!t||l.length!==t);i=!0);}catch(e){a=!0,o=e}finally{try{i||null==n.return||n.return()}finally{if(a)throw o}}return l}}(t,n)||function(e,t){if(e){if("string"==typeof e)return u(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(n):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?u(e,t):void 0}}(t,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),m=b[0],h=b[1],y=(0,r.useCallback)((function(){return(e=function(){return function(e,t){var n,r,o,l={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=a(0),i.throw=a(1),i.return=a(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(l=0)),l;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return l.label++,{value:a[1],done:!1};case 5:l.label++,r=a[1],a=[0];continue;case 7:a=l.ops.pop(),l.trys.pop();continue;default:if(!((o=(o=l.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){l=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){l.label=a[1];break}if(6===a[0]&&l.label<o[1]){l.label=o[1],o=a;break}if(o&&l.label<o[2]){l.label=o[2],l.ops.push(a);break}o[2]&&l.ops.pop(),l.trys.pop();continue}a=t.call(e,l)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}(this,(function(e){return d?(h(!0),(0,a.ZJ)(d).then((function(){(0,a.vt)(),f(),(0,l.showSnackbar)({isLowContrast:!0,kind:"success",title:p("vitalsAndBiometricsDeleted","Vitals and biometrics deleted")})})).catch((function(e){console.error("Error deleting encounter: ",e),(0,l.showSnackbar)({isLowContrast:!1,kind:"error",title:p("errorDeleting","Error deleting vitals and biometrics"),subtitle:null==e?void 0:e.message})})).finally((function(){return h(!1)})),[2]):((0,l.showSnackbar)({isLowContrast:!1,kind:"error",title:p("errorDeleting","Error deleting vitals and biometrics"),subtitle:p("encounterUuidRequired","Encounter UUID is required to delete vitals and biometrics")}),[2])}))},function(){var t=this,n=arguments;return new Promise((function(r,o){var l=e.apply(t,n);function i(e){s(l,r,o,i,a,"next",e)}function a(e){s(l,r,o,i,a,"throw",e)}i(void 0)}))})();var e}),[d,p,f]);return o().createElement(o().Fragment,null,o().createElement(c.rQ0,{closeModal:f,title:p("deleteVitalsAndBiometrics","Delete vitals and biometrics")}),o().createElement(c.cwr,null,o().createElement("p",null,p("deleteConfirmationText","Note: Deleting these entries will also remove related vitals or biometrics data. Are you sure you want to continue?"))),o().createElement(c.jlY,null,o().createElement(c.$nd,{kind:"secondary",onClick:f},p("cancel","Cancel")),o().createElement(c.$nd,{kind:"danger",onClick:y,disabled:m},m?o().createElement(c.OuH,{description:p("deleting","Deleting")+"..."}):o().createElement("span",null,p("delete","Delete")))))}}}]);