"use strict";(globalThis.webpackChunk_openmrs_esm_service_queues_app=globalThis.webpackChunk_openmrs_esm_service_queues_app||[]).push([["6623"],{14626(e,t,n){n.r(t),n.d(t,{default:()=>f});var r=n(97125),i=n.n(r),a=n(75921),u=n(86835),o=n(82895),l=n(36831),s=n(41751),c=n(51812),d=n(73275),m=n(70160);function y(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}let f=function(e){var t=e.queueEntry,n=e.closeModal,f=(0,a.useTranslation)().t,p=(0,l.v)(t.uuid),E=p.queueEntry,b=p.error,g=p.isLoading,T=(0,s.fe)().mutateQueueEntries,h=!g&&!b&&(!E||!!E.endedAt);return((0,r.useEffect)(function(){h&&T()},[h,T]),g)?i().createElement(i().Fragment,null,i().createElement(u.rQ0,{closeModal:n,title:f("transitionPatient","Transition {{patient}}",{patient:t.display})}),i().createElement(u.cwr,null,i().createElement(u.dF7,{"data-testid":"transition-queue-entry-loading-skeleton"}))):b?i().createElement(i().Fragment,null,i().createElement(u.rQ0,{closeModal:n,title:f("transitionPatient","Transition {{patient}}",{patient:t.display})}),i().createElement(u.cwr,null,i().createElement(u.jeF,{hideCloseButton:!0,kind:"error",lowContrast:!0,title:f("errorLoadingQueueEntry","Error loading queue entry"),subtitle:(null==b?void 0:b.message)||f("unexpectedError","An unexpected error occurred")})),i().createElement(u.jlY,null,i().createElement(u.$nd,{kind:"secondary",onClick:n},(0,o.getCoreTranslation)("close")))):h?i().createElement(i().Fragment,null,i().createElement(u.rQ0,{closeModal:n,title:f("transitionPatient","Transition {{patient}}",{patient:t.display})}),i().createElement(u.cwr,null,i().createElement(u.jeF,{hideCloseButton:!0,kind:"warning",lowContrast:!0,title:f("queueEntryAlreadyEnded","Queue entry is no longer active"),subtitle:f("queueEntryAlreadyEndedMessage","This queue entry has already been completed by another user. The queue has been refreshed.")})),i().createElement(u.jlY,null,i().createElement(u.$nd,{kind:"secondary",onClick:n},(0,o.getCoreTranslation)("close")))):i().createElement(m.A,{queueEntry:E,closeModal:n,modalParams:{modalTitle:f("transitionPatient","Transition {{patient}}",{patient:E.display}),submitButtonText:f("transition","Transition"),submitSuccessTitle:f("queueEntryTransitioned","Queue entry transitioned"),submitSuccessText:f("queueEntryTransitionedSuccessfully","Queue entry transitioned successfully"),submitFailureTitle:f("queueEntryTransitionFailed","Error transitioning queue entry"),submitAction:function(e,t){var n,r=new Date(t.transitionDate),i=function(e){if(Array.isArray(e))return e}(n=(0,c.R)(t.transitionTime,t.transitionTimeFormat))||function(e){var t,n,r=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var i=[],a=!0,u=!1;try{for(r=r.call(e);!(a=(t=r.next()).done)&&(i.push(t.value),2!==i.length);a=!0);}catch(e){u=!0,n=e}finally{try{a||null==r.return||r.return()}finally{if(u)throw n}}return i}}(n)||function(e){if(e){if("string"==typeof e)return y(e,2);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return y(e,2)}}(n)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),a=i[0],u=i[1];return r.setHours(a,u,0,0),(0,d.TI)(function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({queueEntryToTransition:e.uuid,newQueue:t.selectedQueue,newStatus:t.selectedStatus,newPriority:t.selectedPriority,newPriorityComment:t.priorityComment},t.modifyDefaultTransitionDateTime?{transitionDate:r.toISOString()}:{}))},disableSubmit:function(e,t){return t.selectedQueue===e.queue.uuid&&t.selectedStatus===e.status.uuid},isEdit:!1,showQueuePicker:!1,showStatusPicker:!0}})}}}]);