@openmrs/esm-api 5.8.2-pre.2388 → 5.8.2-pre.2391

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,13 +1,13 @@
1
- asset openmrs-esm-api.js 53.5 KiB [emitted] [minimized] (name: main) 2 related assets
2
- orphan modules 440 KiB [orphan] 240 modules
1
+ asset openmrs-esm-api.js 54.9 KiB [emitted] [minimized] (name: main) 2 related assets
2
+ orphan modules 1.02 MiB [orphan] 869 modules
3
3
  runtime modules 670 bytes 3 modules
4
- built modules 140 KiB [built]
4
+ built modules 143 KiB [built]
5
5
  modules by path external "@openmrs/ 168 bytes
6
6
  external "@openmrs/esm-config" 42 bytes [built] [code generated]
7
7
  external "@openmrs/esm-navigation" 42 bytes [built] [code generated]
8
8
  external "@openmrs/esm-error-handling" 42 bytes [built] [code generated]
9
9
  external "@openmrs/esm-offline" 42 bytes [built] [code generated]
10
- cacheable modules 140 KiB
10
+ cacheable modules 143 KiB
11
11
  ./src/index.ts + 51 modules 135 KiB [built] [code generated]
12
- ../esm-state/dist/openmrs-esm-state.js 4.79 KiB [built] [code generated]
13
- webpack 5.88.0 compiled successfully in 4257 ms
12
+ ../esm-state/dist/openmrs-esm-state.js 8.12 KiB [built] [code generated]
13
+ webpack 5.88.0 compiled successfully in 4515 ms
@@ -1,3 +1,3 @@
1
1
  /*! For license information please see openmrs-esm-api.js.LICENSE.txt */
2
- System.register(["@openmrs/esm-config","@openmrs/esm-navigation","@openmrs/esm-error-handling","@openmrs/esm-offline"],(function(t,e){var n={},r={},o={},i={};return{setters:[function(t){n.Type=t.Type,n.defineConfigSchema=t.defineConfigSchema,n.getConfig=t.getConfig,n.validators=t.validators},function(t){r.navigate=t.navigate},function(t){o.reportError=t.reportError},function(t){i.getSynchronizationItems=t.getSynchronizationItems}],execute:function(){t((()=>{var t={385:()=>{System.register([],(function(t,e){return{execute:function(){t(function(){"use strict";var t=function(t,e){var n=a[t];if(n)return n.active?console.error("Cannot override an existing store. Make sure that stores are only created once."):n.value.setState(e,!0),n.active=!0,n.value;var r=u()((function(){return e}));return a[t]={value:r,active:!0},r},e=function(t,e){var n=a[t];return n?(n.active?console.error("Cannot override an existing store. Make sure that stores are only created once."):n.value=e,n.active=!0,n.value):(a[t]={value:e,active:!0},e)},n=function(t,e){var n=a[t];if(!n){var r=u()((function(){return null!=e?e:{}}));return a[t]={value:r,active:!1},r}return n.value},r=function(t,e,n){var r=e(t.getState());return t.subscribe((function(t){var o=e(t);o!==r&&(r=o,n(o))}))},o={d:function(t,e){for(var n in e)o.o(e,n)&&!o.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},o:function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r:function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},i={};o.r(i),o.d(i,{createGlobalStore:function(){return t},getGlobalStore:function(){return n},registerGlobalStore:function(){return e},subscribeTo:function(){return r}});var s=function(t){var e,n=new Set,r=function(t,r){var o="function"==typeof t?t(e):t;if(!Object.is(o,e)){var i=e;e=(null!=r?r:"object"!=typeof o||null===o)?o:Object.assign({},e,o),n.forEach((function(t){return t(e,i)}))}},o=function(){return e},i={setState:r,getState:o,getInitialState:function(){return s},subscribe:function(t){return n.add(t),function(){return n.delete(t)}},destroy:function(){console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},s=e=t(r,o,i);return i},u=function(t){return t?s(t):s},a={};return setTimeout((function(){"development"===window.spaEnv&&(window.stores=a)}),1e3),i}())}}}))},824:t=>{"use strict";t.exports=n},254:t=>{"use strict";t.exports=o},513:t=>{"use strict";t.exports=r},738:t=>{"use strict";t.exports=i}},e={};function s(n){var r=e[n];if(void 0!==r)return r.exports;var o=e[n]={exports:{}};return t[n](o,o.exports,s),o.exports}s.d=(t,e)=>{for(var n in e)s.o(e,n)&&!s.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},s.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),s.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var u={};return(()=>{"use strict";s.r(u),s.d(u,{OpenmrsFetchError:()=>Fe,VisitMode:()=>Qn,VisitStatus:()=>Xn,attachmentUrl:()=>Je,backendDependencies:()=>or,clearCurrentUser:()=>ln,createAttachment:()=>Ke,defaultVisitCustomRepresentation:()=>Fn,deleteAttachmentPermanently:()=>Qe,fetchCurrentPatient:()=>Tn,fhirBaseUrl:()=>Be,getAttachmentByUuid:()=>ze,getAttachments:()=>Ye,getCurrentUser:()=>sn,getLocations:()=>rr,getLoggedInUser:()=>pn,getSessionLocation:()=>hn,getSessionStore:()=>un,getStartedVisit:()=>Zn,getVisitStore:()=>Jn,getVisitTypes:()=>er,getVisitsForPatient:()=>Yn,makeUrl:()=>$e,openmrsFetch:()=>Ve,openmrsObservableFetch:()=>We,refetchCurrentUser:()=>cn,restBaseUrl:()=>Re,saveVisit:()=>Kn,sessionEndpoint:()=>Ge,setCurrentVisit:()=>zn,setSessionLocation:()=>dn,setUserLanguage:()=>an,setUserProperties:()=>bn,setupApiModule:()=>wn,toLocationObject:()=>nr,toVisitTypeObject:()=>tr,updateVisit:()=>qn,userHasAccess:()=>fn});var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])},t(e,n)};function e(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}function n(t){return"function"==typeof t}var r=!1,o={Promise:void 0,set useDeprecatedSynchronousErrorHandling(t){t&&(new Error).stack,r=t},get useDeprecatedSynchronousErrorHandling(){return r}};function i(t){setTimeout((function(){throw t}),0)}var a={closed:!0,next:function(t){},error:function(t){if(o.useDeprecatedSynchronousErrorHandling)throw t;i(t)},complete:function(){}},c=function(){return Array.isArray||function(t){return t&&"number"==typeof t.length}}();function l(t){return null!==t&&"object"==typeof t}var f=function(){function t(t){return Error.call(this),this.message=t?t.length+" errors occurred during unsubscription:\n"+t.map((function(t,e){return e+1+") "+t.toString()})).join("\n "):"",this.name="UnsubscriptionError",this.errors=t,this}return t.prototype=Object.create(Error.prototype),t}(),p=f,h=function(){function t(t){this.closed=!1,this._parentOrParents=null,this._subscriptions=null,t&&(this._ctorUnsubscribe=!0,this._unsubscribe=t)}return t.prototype.unsubscribe=function(){var e;if(!this.closed){var r=this,o=r._parentOrParents,i=r._ctorUnsubscribe,s=r._unsubscribe,u=r._subscriptions;if(this.closed=!0,this._parentOrParents=null,this._subscriptions=null,o instanceof t)o.remove(this);else if(null!==o)for(var a=0;a<o.length;++a)o[a].remove(this);if(n(s)){i&&(this._unsubscribe=void 0);try{s.call(this)}catch(t){e=t instanceof p?d(t.errors):[t]}}if(c(u)){a=-1;for(var f=u.length;++a<f;){var h=u[a];if(l(h))try{h.unsubscribe()}catch(t){e=e||[],t instanceof p?e=e.concat(d(t.errors)):e.push(t)}}}if(e)throw new p(e)}},t.prototype.add=function(e){var n=e;if(!e)return t.EMPTY;switch(typeof e){case"function":n=new t(e);case"object":if(n===this||n.closed||"function"!=typeof n.unsubscribe)return n;if(this.closed)return n.unsubscribe(),n;if(!(n instanceof t)){var r=n;(n=new t)._subscriptions=[r]}break;default:throw new Error("unrecognized teardown "+e+" added to Subscription.")}var o=n._parentOrParents;if(null===o)n._parentOrParents=this;else if(o instanceof t){if(o===this)return n;n._parentOrParents=[o,this]}else{if(-1!==o.indexOf(this))return n;o.push(this)}var i=this._subscriptions;return null===i?this._subscriptions=[n]:i.push(n),n},t.prototype.remove=function(t){var e=this._subscriptions;if(e){var n=e.indexOf(t);-1!==n&&e.splice(n,1)}},t.EMPTY=function(t){return t.closed=!0,t}(new t),t}();function d(t){return t.reduce((function(t,e){return t.concat(e instanceof p?e.errors:e)}),[])}var y=function(){return"function"==typeof Symbol?Symbol("rxSubscriber"):"@@rxSubscriber_"+Math.random()}(),b=function(t){function n(e,r,o){var i=t.call(this)||this;switch(i.syncErrorValue=null,i.syncErrorThrown=!1,i.syncErrorThrowable=!1,i.isStopped=!1,arguments.length){case 0:i.destination=a;break;case 1:if(!e){i.destination=a;break}if("object"==typeof e){e instanceof n?(i.syncErrorThrowable=e.syncErrorThrowable,i.destination=e,e.add(i)):(i.syncErrorThrowable=!0,i.destination=new m(i,e));break}default:i.syncErrorThrowable=!0,i.destination=new m(i,e,r,o)}return i}return e(n,t),n.prototype[y]=function(){return this},n.create=function(t,e,r){var o=new n(t,e,r);return o.syncErrorThrowable=!1,o},n.prototype.next=function(t){this.isStopped||this._next(t)},n.prototype.error=function(t){this.isStopped||(this.isStopped=!0,this._error(t))},n.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},n.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,t.prototype.unsubscribe.call(this))},n.prototype._next=function(t){this.destination.next(t)},n.prototype._error=function(t){this.destination.error(t),this.unsubscribe()},n.prototype._complete=function(){this.destination.complete(),this.unsubscribe()},n.prototype._unsubscribeAndRecycle=function(){var t=this._parentOrParents;return this._parentOrParents=null,this.unsubscribe(),this.closed=!1,this.isStopped=!1,this._parentOrParents=t,this},n}(h),m=function(t){function r(e,r,o,i){var s,u=t.call(this)||this;u._parentSubscriber=e;var c=u;return n(r)?s=r:r&&(s=r.next,o=r.error,i=r.complete,r!==a&&(n((c=Object.create(r)).unsubscribe)&&u.add(c.unsubscribe.bind(c)),c.unsubscribe=u.unsubscribe.bind(u))),u._context=c,u._next=s,u._error=o,u._complete=i,u}return e(r,t),r.prototype.next=function(t){if(!this.isStopped&&this._next){var e=this._parentSubscriber;o.useDeprecatedSynchronousErrorHandling&&e.syncErrorThrowable?this.__tryOrSetError(e,this._next,t)&&this.unsubscribe():this.__tryOrUnsub(this._next,t)}},r.prototype.error=function(t){if(!this.isStopped){var e=this._parentSubscriber,n=o.useDeprecatedSynchronousErrorHandling;if(this._error)n&&e.syncErrorThrowable?(this.__tryOrSetError(e,this._error,t),this.unsubscribe()):(this.__tryOrUnsub(this._error,t),this.unsubscribe());else if(e.syncErrorThrowable)n?(e.syncErrorValue=t,e.syncErrorThrown=!0):i(t),this.unsubscribe();else{if(this.unsubscribe(),n)throw t;i(t)}}},r.prototype.complete=function(){var t=this;if(!this.isStopped){var e=this._parentSubscriber;if(this._complete){var n=function(){return t._complete.call(t._context)};o.useDeprecatedSynchronousErrorHandling&&e.syncErrorThrowable?(this.__tryOrSetError(e,n),this.unsubscribe()):(this.__tryOrUnsub(n),this.unsubscribe())}else this.unsubscribe()}},r.prototype.__tryOrUnsub=function(t,e){try{t.call(this._context,e)}catch(t){if(this.unsubscribe(),o.useDeprecatedSynchronousErrorHandling)throw t;i(t)}},r.prototype.__tryOrSetError=function(t,e,n){if(!o.useDeprecatedSynchronousErrorHandling)throw new Error("bad call");try{e.call(this._context,n)}catch(e){return o.useDeprecatedSynchronousErrorHandling?(t.syncErrorValue=e,t.syncErrorThrown=!0,!0):(i(e),!0)}return!1},r.prototype._unsubscribe=function(){var t=this._parentSubscriber;this._context=null,this._parentSubscriber=null,t.unsubscribe()},r}(b),v=function(){return"function"==typeof Symbol&&Symbol.observable||"@@observable"}();function w(t){return t}var g=function(){function t(t){this._isScalar=!1,t&&(this._subscribe=t)}return t.prototype.lift=function(e){var n=new t;return n.source=this,n.operator=e,n},t.prototype.subscribe=function(t,e,n){var r=this.operator,i=function(t,e,n){if(t){if(t instanceof b)return t;if(t[y])return t[y]()}return t||e||n?new b(t,e,n):new b(a)}(t,e,n);if(r?i.add(r.call(i,this.source)):i.add(this.source||o.useDeprecatedSynchronousErrorHandling&&!i.syncErrorThrowable?this._subscribe(i):this._trySubscribe(i)),o.useDeprecatedSynchronousErrorHandling&&i.syncErrorThrowable&&(i.syncErrorThrowable=!1,i.syncErrorThrown))throw i.syncErrorValue;return i},t.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(e){o.useDeprecatedSynchronousErrorHandling&&(t.syncErrorThrown=!0,t.syncErrorValue=e),function(t){for(;t;){var e=t,n=e.closed,r=e.destination,o=e.isStopped;if(n||o)return!1;t=r&&r instanceof b?r:null}return!0}(t)?t.error(e):console.warn(e)}},t.prototype.forEach=function(t,e){var n=this;return new(e=E(e))((function(e,r){var o;o=n.subscribe((function(e){try{t(e)}catch(t){r(t),o&&o.unsubscribe()}}),r,e)}))},t.prototype._subscribe=function(t){var e=this.source;return e&&e.subscribe(t)},t.prototype[v]=function(){return this},t.prototype.pipe=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return 0===t.length?this:(0===(n=t).length?w:1===n.length?n[0]:function(t){return n.reduce((function(t,e){return e(t)}),t)})(this);var n},t.prototype.toPromise=function(t){var e=this;return new(t=E(t))((function(t,n){var r;e.subscribe((function(t){return r=t}),(function(t){return n(t)}),(function(){return t(r)}))}))},t.create=function(e){return new t(e)},t}();function E(t){if(t||(t=o.Promise||Promise),!t)throw new Error("no Promise impl found");return t}const S="object"==typeof global&&global&&global.Object===Object&&global;var O="object"==typeof self&&self&&self.Object===Object&&self;const _=(S||O||Function("return this")()).Symbol;var P=Object.prototype,T=P.hasOwnProperty,A=P.toString,j=_?_.toStringTag:void 0;var x=Object.prototype.toString;var D=_?_.toStringTag:void 0;const N=function(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":D&&D in Object(t)?function(t){var e=T.call(t,j),n=t[j];try{t[j]=void 0;var r=!0}catch(t){}var o=A.call(t);return r&&(e?t[j]=n:delete t[j]),o}(t):function(t){return x.call(t)}(t)},U=(M=Object.getPrototypeOf,C=Object,function(t){return M(C(t))});var M,C;var k=Function.prototype,L=Object.prototype,I=k.toString,R=L.hasOwnProperty,B=I.call(Object);const G=function(t){if(!function(t){return null!=t&&"object"==typeof t}(t)||"[object Object]"!=N(t))return!1;var e=U(t);if(null===e)return!0;var n=R.call(e,"constructor")&&e.constructor;return"function"==typeof n&&n instanceof n&&I.call(n)==B};var $=s(824),V=s(513),W=s(385);(0,W.createGlobalStore)("breadcrumbs",[]);var F=Object.freeze({__proto__:null,get start(){return Te},get ensureJQuerySupport(){return te},get setBootstrapMaxTime(){return Ct},get setMountMaxTime(){return kt},get setUnmountMaxTime(){return Lt},get setUnloadMaxTime(){return It},get registerApplication(){return pe},get unregisterApplication(){return de},get getMountedApps(){return ae},get getAppStatus(){return le},get unloadApplication(){return ye},get checkActivityFunctions(){return he},get getAppNames(){return ce},get pathToActiveWhen(){return ve},get navigateToUrl(){return Ft},get patchHistoryApi(){return Qt},get triggerAppChange(){return Se},get addErrorHandler(){return K},get removeErrorHandler(){return q},get mountRootParcel(){return xt},get NOT_LOADED(){return Z},get LOADING_SOURCE_CODE(){return tt},get NOT_BOOTSTRAPPED(){return et},get BOOTSTRAPPING(){return nt},get NOT_MOUNTED(){return rt},get MOUNTING(){return ot},get UPDATING(){return st},get LOAD_ERROR(){return ct},get MOUNTED(){return it},get UNLOADING(){return at},get UNMOUNTING(){return ut},get SKIP_BECAUSE_BROKEN(){return lt}}),H=("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{}).CustomEvent,J=function(){try{var t=new H("cat",{detail:{foo:"bar"}});return"cat"===t.type&&"bar"===t.detail.foo}catch(t){}return!1}()?H:"undefined"!=typeof document&&"function"==typeof document.createEvent?function(t,e){var n=document.createEvent("CustomEvent");return e?n.initCustomEvent(t,e.bubbles,e.cancelable,e.detail):n.initCustomEvent(t,!1,!1,void 0),n}:function(t,e){var n=document.createEventObject();return n.type=t,e?(n.bubbles=Boolean(e.bubbles),n.cancelable=Boolean(e.cancelable),n.detail=e.detail):(n.bubbles=!1,n.cancelable=!1,n.detail=void 0),n};let z=[];function Y(t,e,n){const r=X(t,e,n);z.length?z.forEach((t=>t(r))):setTimeout((()=>{throw r}))}function K(t){if("function"!=typeof t)throw Error(Q(28,!1));z.push(t)}function q(t){if("function"!=typeof t)throw Error(Q(29,!1));let e=!1;return z=z.filter((n=>{const r=n===t;return e=e||r,!r})),e}function Q(t,e,...n){return`single-spa minified message #${t}: ${e?e+" ":""}See https://single-spa.js.org/error/?code=${t}${n.length?`&arg=${n.join("&arg=")}`:""}`}function X(t,e,n){const r=`${yt(e)} '${ht(e)}' died in status ${e.status}: `;let o;if(t instanceof Error){try{t.message=r+t.message}catch(t){}o=t}else{console.warn(Q(30,!1,e.status,ht(e)));try{o=Error(r+JSON.stringify(t))}catch(e){o=t}}return o.appOrParcelName=ht(e),e.status=n,o}const Z="NOT_LOADED",tt="LOADING_SOURCE_CODE",et="NOT_BOOTSTRAPPED",nt="BOOTSTRAPPING",rt="NOT_MOUNTED",ot="MOUNTING",it="MOUNTED",st="UPDATING",ut="UNMOUNTING",at="UNLOADING",ct="LOAD_ERROR",lt="SKIP_BECAUSE_BROKEN";function ft(t){return t.status===it}function pt(t){try{return t.activeWhen(window.location)}catch(e){return Y(e,t,lt),!1}}function ht(t){return t.name}function dt(t){return Boolean(t.unmountThisParcel)}function yt(t){return dt(t)?"parcel":"application"}function bt(){for(let t=arguments.length-1;t>0;t--)for(let e in arguments[t])"__proto__"!==e&&(arguments[t-1][e]=arguments[t][e]);return arguments[0]}function mt(t,e){for(let n=0;n<t.length;n++)if(e(t[n]))return t[n];return null}function vt(t){return t&&("function"==typeof t||(e=t,Array.isArray(e)&&!mt(e,(t=>"function"!=typeof t))));var e}function wt(t,e){let n=t[e]||[];n=Array.isArray(n)?n:[n],0===n.length&&(n=[()=>Promise.resolve()]);const r=yt(t),o=ht(t);return function(t){return n.reduce(((n,i,s)=>n.then((()=>{const n=i(t);return gt(n)?n:Promise.reject(Q(15,!1,r,o,e,s))}))),Promise.resolve())}}function gt(t){return t&&"function"==typeof t.then&&"function"==typeof t.catch}let Et=[];function St(t,e){return Promise.resolve().then((()=>t.status!==et?t:(t.status=nt,t.bootstrap?Rt(t,"bootstrap").then(n).catch((n=>{if(e)throw X(n,t,lt);return Y(n,t,lt),t})):Promise.resolve().then(n))));function n(){return t.status=rt,t}}function Ot(t,e){return Promise.resolve().then((()=>{if(t.status!==it)return t;t.status=ut;const n=Object.keys(t.parcels).map((e=>t.parcels[e].unmountThisParcel()));return Promise.all(n).then(r,(n=>r().then((()=>{const r=Error(n.message);if(e)throw X(r,t,lt);Y(r,t,lt)})))).then((()=>t));function r(){return Rt(t,"unmount").then((()=>{t.status=rt}),(n=>{if(e)throw X(n,t,lt);Y(n,t,lt)}))}}))}let _t=!1,Pt=!1;function Tt(t,e){return Promise.resolve().then((()=>t.status!==rt?t:(_t||(window.dispatchEvent(new J("single-spa:before-first-mount")),_t=!0),t.status=ot,Rt(t,"mount").then((()=>(t.status=it,Pt||(window.dispatchEvent(new J("single-spa:first-mount")),Pt=!0),t))).catch((n=>{return t.status=it,Ot(t,!0).then(r,r);function r(){if(e)throw X(n,t,lt);return Y(n,t,lt),t}})))))}let At=0;const jt={parcels:{}};function xt(){return Dt.apply(jt,arguments)}function Dt(t,e){const n=this;if(!t||"object"!=typeof t&&"function"!=typeof t)throw Error(Q(2,!1));if(t.name&&"string"!=typeof t.name)throw Error(Q(3,!1,typeof t.name));const r=At++;let o=t.name||`parcel-${r}`;if("object"!=typeof e)throw Error(Q(4,!1,o,typeof e));if(!e.domElement)throw Error(Q(5,!1,o));const i="function"==typeof t,s=i?t:()=>Promise.resolve(t),u={id:r,parcels:{},status:i?tt:et,customProps:e,parentName:ht(n),unmountThisParcel:()=>f.then((()=>{if(u.status!==it)throw Error(Q(6,!1,o,u.status));return Ot(u,!0)})).then((t=>(u.parentName&&delete n.parcels[u.id],t))).then((t=>(p(t),t))).catch((t=>{throw u.status=lt,h(t),t}))};let a;n.parcels[r]=u;let c=s();if(!c||"function"!=typeof c.then)throw Error(Q(7,!1));c=c.then((t=>{if(!t)throw Error(Q(8,!1));if(o=t.name||`parcel-${r}`,Object.prototype.hasOwnProperty.call(t,"bootstrap")&&!vt(t.bootstrap))throw Error(Q(9,!1,o));if(!vt(t.mount))throw Error(Q(10,!1,o));if(!vt(t.unmount))throw Error(Q(11,!1,o));if(t.update&&!vt(t.update))throw Error(Q(12,!1,o));const e=wt(t,"bootstrap"),n=wt(t,"mount"),i=wt(t,"unmount");u.status=et,u.name=o,u.bootstrap=e,u.mount=n,u.unmount=i,u.timeouts=Bt(t.timeouts),t.update&&(u.update=wt(t,"update"),a.update=function(t){return u.customProps=t,Nt((e=u,Promise.resolve().then((()=>{if(e.status!==it)throw Error(Q(32,!1,ht(e)));return e.status=st,Rt(e,"update").then((()=>(e.status=it,e))).catch((t=>{throw X(t,e,lt)}))}))));var e})}));const l=c.then((()=>St(u,!0))),f=l.then((()=>Tt(u,!0)));let p,h;const d=new Promise(((t,e)=>{p=t,h=e}));return a={mount:()=>Nt(Promise.resolve().then((()=>{if(u.status!==rt)throw Error(Q(13,!1,o,u.status));return n.parcels[r]=u,Tt(u)}))),unmount:()=>Nt(u.unmountThisParcel()),getStatus:()=>u.status,loadPromise:Nt(c),bootstrapPromise:Nt(l),mountPromise:Nt(f),unmountPromise:Nt(d)},a}function Nt(t){return t.then((()=>null))}function Ut(t){const e=ht(t);let n="function"==typeof t.customProps?t.customProps(e,window.location):t.customProps;("object"!=typeof n||null===n||Array.isArray(n))&&(n={},console.warn(Q(40,!1),e,n));const r=bt({},n,{name:e,mountParcel:Dt.bind(t),singleSpa:F});return dt(t)&&(r.unmountSelf=t.unmountThisParcel),r}const Mt={bootstrap:{millis:4e3,dieOnTimeout:!1,warningMillis:1e3},mount:{millis:3e3,dieOnTimeout:!1,warningMillis:1e3},unmount:{millis:3e3,dieOnTimeout:!1,warningMillis:1e3},unload:{millis:3e3,dieOnTimeout:!1,warningMillis:1e3},update:{millis:3e3,dieOnTimeout:!1,warningMillis:1e3}};function Ct(t,e,n){if("number"!=typeof t||t<=0)throw Error(Q(16,!1));Mt.bootstrap={millis:t,dieOnTimeout:e,warningMillis:n||1e3}}function kt(t,e,n){if("number"!=typeof t||t<=0)throw Error(Q(17,!1));Mt.mount={millis:t,dieOnTimeout:e,warningMillis:n||1e3}}function Lt(t,e,n){if("number"!=typeof t||t<=0)throw Error(Q(18,!1));Mt.unmount={millis:t,dieOnTimeout:e,warningMillis:n||1e3}}function It(t,e,n){if("number"!=typeof t||t<=0)throw Error(Q(19,!1));Mt.unload={millis:t,dieOnTimeout:e,warningMillis:n||1e3}}function Rt(t,e){const n=t.timeouts[e],r=n.warningMillis,o=yt(t);return new Promise(((i,s)=>{let u=!1,a=!1;t[e](Ut(t)).then((t=>{u=!0,i(t)})).catch((t=>{u=!0,s(t)})),setTimeout((()=>l(1)),r),setTimeout((()=>l(!0)),n.millis);const c=Q(31,!1,e,o,ht(t),n.millis);function l(t){if(!u)if(!0===t)a=!0,n.dieOnTimeout?s(Error(c)):console.error(c);else if(!a){const e=t,o=e*r;console.warn(c),o+r<n.millis&&setTimeout((()=>l(e+1)),r)}}}))}function Bt(t){const e={};for(let n in Mt)e[n]=bt({},Mt[n],t&&t[n]||{});return e}function Gt(t){return Promise.resolve().then((()=>{if(t.loadPromise)return t.loadPromise;if(t.status!==Z&&t.status!==ct)return t;let e,n;return t.status=tt,t.loadPromise=Promise.resolve().then((()=>{const r=t.loadApp(Ut(t));if(!gt(r))throw n=!0,Error(Q(33,!1,ht(t)));return r.then((n=>{let r;t.loadErrorTime=null,e=n,"object"!=typeof e&&(r=34),Object.prototype.hasOwnProperty.call(e,"bootstrap")&&!vt(e.bootstrap)&&(r=35),vt(e.mount)||(r=36),vt(e.unmount)||(r=37);const o=yt(e);if(r){let n;try{n=JSON.stringify(e)}catch(t){}return console.error(Q(r,!1,o,ht(t),n),e),Y(void 0,t,lt),t}return e.devtools&&e.devtools.overlays&&(t.devtools.overlays=bt({},t.devtools.overlays,e.devtools.overlays)),t.status=et,t.bootstrap=wt(e,"bootstrap"),t.mount=wt(e,"mount"),t.unmount=wt(e,"unmount"),t.unload=wt(e,"unload"),t.timeouts=Bt(e.timeouts),delete t.loadPromise,t}))})).catch((e=>{let r;return delete t.loadPromise,n?r=lt:(r=ct,t.loadErrorTime=(new Date).getTime()),Y(e,t,r),t}))}))}const $t="undefined"!=typeof window,Vt={hashchange:[],popstate:[]},Wt=["hashchange","popstate"];function Ft(t){let e;if("string"==typeof t)e=t;else if(this&&this.href)e=this.href;else{if(!(t&&t.currentTarget&&t.currentTarget.href&&t.preventDefault))throw Error(Q(14,!1));e=t.currentTarget.href,t.preventDefault()}const n=Xt(window.location.href),r=Xt(e);0===e.indexOf("#")?window.location.hash=r.hash:n.host!==r.host&&r.host?window.location.href=e:r.pathname===n.pathname&&r.search===n.search?window.location.hash=r.hash:window.history.pushState(null,null,e)}function Ht(t){if(t){const e=t[0].type;Wt.indexOf(e)>=0&&Vt[e].forEach((e=>{try{e.apply(this,t)}catch(t){setTimeout((()=>{throw t}))}}))}}let Jt;function zt(){Oe([],arguments)}function Yt(t,e){return function(){const n=window.location.href,r=t.apply(this,arguments),o=window.location.href;return Jt&&n===o||window.dispatchEvent(function(t,e){let n;try{n=new PopStateEvent("popstate",{state:t})}catch(e){n=document.createEvent("PopStateEvent"),n.initPopStateEvent("popstate",!1,!1,t)}return n.singleSpa=!0,n.singleSpaTrigger=e,n}(window.history.state,e)),r}}let Kt=null,qt=!1;function Qt(t){if(qt)throw Error(Q(43,!1));Jt=!t||!t.hasOwnProperty("urlRerouteOnly")||t.urlRerouteOnly,qt=!0,Kt=window.history.replaceState,window.addEventListener("hashchange",zt),window.addEventListener("popstate",zt);const e=window.addEventListener,n=window.removeEventListener;window.addEventListener=function(t,n){if(!("function"==typeof n&&Wt.indexOf(t)>=0)||mt(Vt[t],(t=>t===n)))return e.apply(this,arguments);Vt[t].push(n)},window.removeEventListener=function(t,e){if(!("function"==typeof e&&Wt.indexOf(t)>=0))return n.apply(this,arguments);Vt[t]=Vt[t].filter((t=>t!==e))},window.history.pushState=Yt(window.history.pushState,"pushState"),window.history.replaceState=Yt(Kt,"replaceState")}function Xt(t){const e=document.createElement("a");return e.href=t,e}$t&&(window.singleSpaNavigate?console.warn(Q(41,!1)):window.singleSpaNavigate=Ft);let Zt=!1;function te(t=window.jQuery){if(t||window.$&&window.$.fn&&window.$.fn.jquery&&(t=window.$),t&&!Zt){const e=t.fn.on,n=t.fn.off;t.fn.on=function(t,n){return ee.call(this,e,window.addEventListener,t,n,arguments)},t.fn.off=function(t,e){return ee.call(this,n,window.removeEventListener,t,e,arguments)},Zt=!0}}function ee(t,e,n,r,o){return"string"!=typeof n?t.apply(this,o):(n.split(/\s+/).forEach((t=>{Wt.indexOf(t)>=0&&(e(t,r),n=n.replace(t,""))})),""===n.trim()?this:t.apply(this,o))}const ne={};function re(t){return Promise.resolve().then((()=>{const e=ne[ht(t)];if(!e)return t;if(t.status===Z)return oe(t,e),t;if(t.status===at)return e.promise.then((()=>t));if(t.status!==rt&&t.status!==ct)return t;const n=t.status===ct?Promise.resolve():Rt(t,"unload");return t.status=at,n.then((()=>(oe(t,e),t))).catch((n=>(function(t,e,n){delete ne[ht(t)],delete t.bootstrap,delete t.mount,delete t.unmount,delete t.unload,Y(n,t,lt),e.reject(n)}(t,e,n),t)))}))}function oe(t,e){delete ne[ht(t)],delete t.bootstrap,delete t.mount,delete t.unmount,delete t.unload,t.status=Z,e.resolve()}function ie(t,e,n,r){ne[ht(t)]={app:t,resolve:n,reject:r},Object.defineProperty(ne[ht(t)],"promise",{get:e})}function se(t){return ne[t]}const ue=[];function ae(){return ue.filter(ft).map(ht)}function ce(){return ue.map(ht)}function le(t){const e=mt(ue,(e=>ht(e)===t));return e?e.status:null}let fe=!1;function pe(t,e,n,r){const o=function(t,e,n,r){const o={name:null,loadApp:null,activeWhen:null,customProps:null};return"object"==typeof t?(function(t){if(Array.isArray(t)||null===t)throw Error(Q(39,!1));const e=["name","app","activeWhen","customProps"],n=Object.keys(t).reduce(((t,n)=>e.indexOf(n)>=0?t:t.concat(n)),[]);if(0!==n.length)throw Error(Q(38,!1,e.join(", "),n.join(", ")));if("string"!=typeof t.name||0===t.name.length)throw Error(Q(20,!1));if("object"!=typeof t.app&&"function"!=typeof t.app)throw Error(Q(20,!1));const r=t=>"string"==typeof t||"function"==typeof t;if(!(r(t.activeWhen)||Array.isArray(t.activeWhen)&&t.activeWhen.every(r)))throw Error(Q(24,!1));if(!me(t.customProps))throw Error(Q(22,!1))}(t),o.name=t.name,o.loadApp=t.app,o.activeWhen=t.activeWhen,o.customProps=t.customProps):(function(t,e,n,r){if("string"!=typeof t||0===t.length)throw Error(Q(20,!1));if(!e)throw Error(Q(23,!1));if("function"!=typeof n)throw Error(Q(24,!1));if(!me(r))throw Error(Q(22,!1))}(t,e,n,r),o.name=t,o.loadApp=e,o.activeWhen=n,o.customProps=r),o.loadApp="function"!=typeof(i=o.loadApp)?()=>Promise.resolve(i):i,o.customProps=function(t){return t||{}}(o.customProps),o.activeWhen=function(t){let e=Array.isArray(t)?t:[t];return e=e.map((t=>"function"==typeof t?t:ve(t))),t=>e.some((e=>e(t)))}(o.activeWhen),o;var i}(t,e,n,r);if(Ae()||fe||(fe=!0,setTimeout((()=>{Ae()||console.warn(Q(1,!1))}),5e3)),-1!==ce().indexOf(o.name))throw Error(Q(21,!1,o.name));ue.push(bt({loadErrorTime:null,status:Z,parcels:{},devtools:{overlays:{options:{},selectors:[]}}},o)),$t&&(te(),Oe())}function he(t=window.location){return ue.filter((e=>e.activeWhen(t))).map(ht)}function de(t){if(0===ue.filter((e=>ht(e)===t)).length)throw Error(Q(25,!1,t));return($t?ye(t,{waitForUnmount:!1}):Promise.resolve()).then((()=>{const e=ue.map(ht).indexOf(t);ue.splice(e,1)}))}function ye(t,e={waitForUnmount:!1}){if("string"!=typeof t)throw Error(Q(26,!1));const n=mt(ue,(e=>ht(e)===t));if(!n)throw Error(Q(27,!1,t));const r=se(ht(n));if(e&&e.waitForUnmount){if(r)return r.promise;{const t=new Promise(((e,r)=>{ie(n,(()=>t),e,r)}));return t}}{let t;return r?(t=r.promise,be(n,r.resolve,r.reject)):t=new Promise(((e,r)=>{ie(n,(()=>t),e,r),be(n,e,r)})),t}}function be(t,e,n){Promise.resolve().then((()=>{if(mt(he(),(e=>e===ht(t))))return Se()})).then((()=>Ot(t).then(re).then((()=>{e(),setTimeout((()=>{Oe()}))})))).catch(n)}function me(t){return!t||"function"==typeof t||"object"==typeof t&&null!==t&&!Array.isArray(t)}function ve(t,e){const n=function(t,e){let n=0,r=!1,o="^";"/"!==t[0]&&(t="/"+t);for(let e=0;e<t.length;e++){const n=t[e];(!r&&":"===n||r&&"/"===n)&&i(e)}return i(t.length),new RegExp(o,"i");function i(i){const s=t.slice(n,i).replace(/[|\\{}()[\]^$+*?.]/g,"\\$&");if(o+=r?"[^/]+/?":s,i===t.length)if(r)e&&(o+="$");else{const t=e?"":".*";o="/"===o.charAt(o.length-1)?`${o}${t}$`:`${o}(/${t})?(#.*)?$`}r=!r,n=i}}(t,e);return t=>{let e=t.origin;e||(e=`${t.protocol}//${t.host}`);const r=t.href.replace(e,"").replace(t.search,"").split("?")[0];return n.test(r)}}let we=!1,ge=[],Ee=$t&&window.location.href;function Se(){return Oe()}function Oe(t=[],e,n=!1){if(we)return new Promise(((t,n)=>{ge.push({resolve:t,reject:n,eventArguments:e})}));const{appsToUnload:r,appsToUnmount:o,appsToLoad:i,appsToMount:s}=function(){const t=[],e=[],n=[],r=[],o=(new Date).getTime();return ue.forEach((i=>{const s=i.status!==lt&&pt(i);switch(i.status){case ct:s&&o-i.loadErrorTime>=200&&n.push(i);break;case Z:case tt:s&&n.push(i);break;case et:case rt:!s&&se(ht(i))?t.push(i):s&&r.push(i);break;case it:s||e.push(i)}})),{appsToUnload:t,appsToUnmount:e,appsToLoad:n,appsToMount:r}}();let u,a=[],c=Ee,l=Ee=window.location.href;return Ae()?(we=!0,u=r.concat(i,o,s),Promise.resolve().then((()=>(y(0===u.length?"before-no-app-change":"before-app-change",d(!0)),y("before-routing-event",d(!0,{cancelNavigation:f})),Promise.all(a).then((n=>{if(n.some((t=>t)))return Kt.call(window.history,history.state,"",c.substring(location.origin.length)),Ee=location.href,we=!1,Oe(t,e,!0);const u=r.map(re),a=o.map(Ot).map((t=>t.then(re))).concat(u),l=Promise.all(a);l.then((()=>{y("before-mount-routing-event",d(!0))}),(t=>{throw t}));const f=i.map((t=>Gt(t).then((t=>_e(t,l))))),b=s.filter((t=>i.indexOf(t)<0)).map((t=>_e(t,l)));return l.catch((t=>{throw h(),t})).then((()=>(h(),Promise.all(f.concat(b)).catch((e=>{throw t.forEach((t=>t.reject(e))),e})).then(p).then((()=>{}),(t=>{throw t})))))})))))):(u=i,Promise.resolve().then((()=>{const t=i.map(Gt);return Promise.all(t).then(h).then((()=>[])).catch((t=>{throw h(),t})).finally((()=>{}))})));function f(t=!0){const e="function"==typeof(null==t?void 0:t.then)?t:Promise.resolve(t);a.push(e.catch((t=>(console.warn(Error(Q(42,!1))),console.warn(t),!1))))}function p(){const e=ae();t.forEach((t=>t.resolve(e)));try{y(0===u.length?"no-app-change":"app-change",d()),y("routing-event",d())}catch(t){setTimeout((()=>{throw t}))}if(we=!1,ge.length>0){const t=ge;ge=[],Oe(t)}return e}function h(){n||(t.forEach((t=>{Ht(t.eventArguments)})),Ht(e))}function d(t=!1,n){const a={},f={[it]:[],[rt]:[],[Z]:[],[lt]:[]};t?(i.concat(s).forEach(((t,e)=>{h(t,it)})),r.forEach((t=>{h(t,Z)})),o.forEach((t=>{h(t,rt)}))):u.forEach((t=>{h(t)}));const p={detail:{newAppStatuses:a,appsByNewStatus:f,totalAppChanges:u.length,originalEvent:null==e?void 0:e[0],oldUrl:c,newUrl:l}};return n&&bt(p.detail,n),p;function h(t,e){const n=ht(t);e=e||le(n),a[n]=e,(f[e]=f[e]||[]).push(n)}}function y(t,e){n||window.dispatchEvent(new J(`single-spa:${t}`,e))}}function _e(t,e){return pt(t)?St(t).then((t=>e.then((()=>pt(t)?Tt(t):t)))):e.then((()=>t))}let Pe=!1;function Te(t){Pe=!0,$t&&(Qt(t),Oe())}function Ae(){return Pe}var je={getRawAppData:function(){return[...ue]},reroute:Oe,NOT_LOADED:Z,toLoadPromise:Gt,toBootstrapPromise:St,unregisterApplication:de,getProfilerData:function(){return Et}};$t&&window.__SINGLE_SPA_DEVTOOLS__&&(window.__SINGLE_SPA_DEVTOOLS__.exposedMethods=je);var xe="openmrs:history";function De(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function Ne(t,e,n,r,o,i,s){try{var u=t[i](s),a=u.value}catch(t){return void n(t)}u.done?e(a):Promise.resolve(a).then(r,o)}function Ue(t,e,n){return Ue=Ie()?Reflect.construct:function(t,e,n){var r=[null];r.push.apply(r,e);var o=new(Function.bind.apply(t,r));return n&&ke(o,n.prototype),o},Ue.apply(null,arguments)}function Me(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Ce(t){return Ce=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},Ce(t)}function ke(t,e){return ke=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},ke(t,e)}function Le(t){var e="function"==typeof Map?new Map:void 0;return Le=function(t){if(null===t||(n=t,-1===Function.toString.call(n).indexOf("[native code]")))return t;var n;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,r)}function r(){return Ue(t,arguments,Ce(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),ke(r,t)},Le(t)}function Ie(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}var Re="/ws/rest/v1",Be="/ws/fhir2/R4",Ge="".concat(Re,"/session");function $e(t){return t&&t.startsWith("http")?t:("/"!==t[0]&&(t="/"+t),window.openmrsBase+t)}function Ve(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if("string"!=typeof t)throw Error("The first argument to @openmrs/api's openmrsFetch function must be a url string");if("object"!=typeof e)throw Error("The second argument to @openmrs/api's openmrsFetch function must be a plain object.");if(!window.openmrsBase)throw Error("@openmrs/api is running in a browser that doesn't have window.openmrsBase, which is provided by openmrs-module-spa's HTML file.");var n=$e(t);if(e.headers||(e.headers={}),G(e.body)&&(e.body=JSON.stringify(e.body)),void 0===e.headers.Accept&&(e.headers.Accept="application/json"),null===e.headers.Accept&&delete e.headers.Accept,t.startsWith(Re)&&void 0===e.headers["Disable-WWW-Authenticate"]&&(e.headers["Disable-WWW-Authenticate"]="true"),t.startsWith(Be)){var r=new URL(n,window.location.toString());r.searchParams.has("_summary")||(r.searchParams.set("_summary","data"),n=r.toString())}var o,i,s=Error();return window.fetch(n,e).then((o=function(t){var e,r;return function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}}(this,(function(o){switch(o.label){case 0:return(e=t).ok?204===e.status?(e.data=null,[2,e]):[2,e.clone().text().then((function(t){try{t&&(e.data=JSON.parse(t))}catch(t){}return e}))]:[3,1];case 1:return[4,(0,$.getConfig)("@openmrs/esm-api")];case 2:return r=o.sent().redirectAuthFailure,n===$e(Ge)&&403===e.status||r.enabled&&r.errors.includes(e.status)?(sessionStorage.removeItem(xe),(0,V.navigate)({to:r.url}),[2,r.resolvePromise?Promise.resolve():new Promise((function(){}))]):[2,e.clone().text().then((function(t){var r=t;try{r=JSON.parse(t)}catch(t){}throw new Fe(n,e,r,s)}),(function(t){throw new Fe(n,e,null,s)}))];case 3:return[2]}}))},i=function(){var t=this,e=arguments;return new Promise((function(n,r){var i=o.apply(t,e);function s(t){Ne(i,n,r,s,u,"next",t)}function u(t){Ne(i,n,r,s,u,"throw",t)}s(void 0)}))},function(t){return i.apply(this,arguments)}))}function We(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if("object"!=typeof e)throw Error("The second argument to openmrsObservableFetch must be either omitted or an object");var n=new AbortController;return e.signal=n.signal,new g((function(r){var o=!1;return Ve(t,e).then((function(t){o=!0,r.next(t),r.complete()}),(function(t){o=!0,r.error(t)})),function(){o||n.abort()}}))}var Fe=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&ke(t,e)}(o,t);var e,n,r=(e=o,n=Ie(),function(){var t,r=Ce(e);if(n){var o=Ce(this).constructor;t=Reflect.construct(r,arguments,o)}else t=r.apply(this,arguments);return function(t,e){return!e||"object"!=((n=e)&&"undefined"!=typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)&&"function"!=typeof e?De(t):e;var n}(this,t)});function o(t,e,n,i){var s;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,o),Me(De(s=r.call(this)),"response",void 0),Me(De(s),"responseBody",void 0),s.message="Server responded with ".concat(e.status," (").concat(e.statusText,") for url ").concat(t,". Check err.responseBody or network tab in dev tools for more info"),i.message=s.message,s.responseBody=n,s.response=e,s.stack="Stacktrace for outgoing request:\n".concat(i.stack,"\nStacktrace for incoming response:\n").concat(s.stack),s}return o}(Le(Error));function He(t,e,n,r,o,i,s){try{var u=t[i](s),a=u.value}catch(t){return void n(t)}u.done?e(a):Promise.resolve(a).then(r,o)}var Je="".concat(Re,"/attachment");function ze(t,e){return Ve("".concat(Je,"/").concat(t),{signal:e.signal})}function Ye(t,e,n){return Ve("".concat(Je,"?patient=").concat(t,"&includeEncounterless=").concat(e),{signal:n.signal})}function Ke(t,e){return qe.apply(this,arguments)}function qe(){var t;return t=function(t,e){var n;return function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}}(this,(function(r){return(n=new FormData).append("fileCaption",e.fileDescription),n.append("patient",t),e.file?n.append("file",e.file):(n.append("file",new File([""],e.fileName),e.fileName),n.append("base64Content",e.base64Content)),[2,Ve("".concat(Je),{method:"POST",body:n})]}))},qe=function(){var e=this,n=arguments;return new Promise((function(r,o){var i=t.apply(e,n);function s(t){He(i,r,o,s,u,"next",t)}function u(t){He(i,r,o,s,u,"throw",t)}s(void 0)}))},qe.apply(this,arguments)}function Qe(t,e){return Ve("".concat(Je,"/").concat(t),{method:"DELETE",signal:e.signal})}var Xe=s(254);const Ze=function(t){return void 0===t};function tn(t,e,n,r,o,i,s){try{var u=t[i](s),a=u.value}catch(t){return void n(t)}u.done?e(a):Promise.resolve(a).then(r,o)}function en(t){return function(){var e=this,n=arguments;return new Promise((function(r,o){var i=t.apply(e,n);function s(t){tn(i,r,o,s,u,"next",t)}function u(t){tn(i,r,o,s,u,"throw",t)}s(void 0)}))}}function nn(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}}var rn=(0,W.createGlobalStore)("session",{loaded:!1,session:null}),on=0;function sn(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{includeAuthStatus:!0};return(on<Date.now()-6e4||!rn.getState().loaded)&&cn(),new g((function(e){var n=function(n){var r;n.loaded&&(t.includeAuthStatus?e.next(n.session):e.next(null===(r=n.session)||void 0===r?void 0:r.user))};return n(rn.getState()),rn.subscribe(n)}))}function un(){return(on<Date.now()-6e4||!rn.getState().loaded)&&cn(),rn}function an(t){var e,n,r,o=null!==(r=null==t||null===(e=t.user)||void 0===e||null===(n=e.userProperties)||void 0===n?void 0:n.defaultLocale)&&void 0!==r?r:t.locale,i=document.documentElement.getAttribute("lang");(function(t){if(void 0===t||"string"!=typeof t)return!1;try{new Intl.Locale(t)}catch(t){return!1}return!0})(o)&&o!==i&&document.documentElement.setAttribute("lang",o)}function cn(t,e){on=Date.now();var n={};return t&&e&&(n.Authorization="Basic ".concat(window.btoa("".concat(t,":").concat(e)))),vn(Ve(Ge,{headers:n}))}function ln(){rn.setState({loaded:!0,session:{authenticated:!1,sessionId:""}})}function fn(t,e){return void 0===e?Boolean(t):!Boolean(t)||function(t,e){return"string"==typeof t?!Ze(e.privileges.find((function(e){return t===e.display}))):Array.isArray(t)?t.every((function(t){return!Ze(e.privileges.find((function(e){return t===e.display})))})):(Ze(t)||console.error('Could not understand privileges "'.concat(t,'"')),!0)}(t,e)||function(t){return!Ze(t.roles.find((function(t){return"System Developer"===t.display})))}(e)}function pn(){var t,e;return new Promise((function(n){var r=function(r){r.loaded&&r.session.user&&(t=r.session.user,n(r.session.user),e&&e())};r(rn.getState()),t||(e=rn.subscribe(r))}))}function hn(){return new Promise((function(t,e){sn().subscribe((function(e){t(e.sessionLocation)}),e).unsubscribe()}))}function dn(t,e){return yn.apply(this,arguments)}function yn(){return(yn=en((function(t,e){return nn(this,(function(n){return[2,vn(Ve(Ge,{method:"POST",body:{sessionLocation:t},headers:{"Content-Type":"application/json"},signal:e.signal}))]}))}))).apply(this,arguments)}function bn(t,e,n){return mn.apply(this,arguments)}function mn(){return(mn=en((function(t,e,n){return nn(this,(function(r){switch(r.label){case 0:return n||(n=new AbortController),[4,Ve("".concat(Re,"/user/").concat(t),{method:"POST",body:{userProperties:e},headers:{"Content-Type":"application/json"},signal:n.signal})];case 1:return r.sent(),[2,cn()]}}))}))).apply(this,arguments)}function vn(t){return new Promise((function(e,n){t.then((function(t){var r;"object"==typeof(null==t?void 0:t.data)?(r={loaded:!0,session:t.data},rn.setState(r),e(r)):(r={loaded:!1,session:null},rn.setState(r),n(r))})).catch((function(t){(0,Xe.reportError)("Failed to fetch new session information: ".concat(t));var e={loaded:!1,session:null};rn.setState(e),n(e)}))}))}function wn(){(0,$.defineConfigSchema)("@openmrs/esm-api",{redirectAuthFailure:{enabled:{_type:$.Type.Boolean,_default:!0,_description:"Whether to redirect logged-out users to `redirectAuthFailure.url`"},url:{_type:$.Type.String,_default:"${openmrsSpaBase}/login",_validators:[$.validators.isUrl]},errors:{_type:$.Type.Array,_default:[401],_elements:{_type:$.Type.Number,_validators:[$.validators.inRange(100,600)]},_description:"The HTTP error codes for which users will be redirected"},resolvePromise:{_type:$.Type.Boolean,_default:!1,_description:"Changes how requests that fail authentication are handled. Try messing with this if redirects to the login page aren't working correctly."}}}),cn()}rn.subscribe((function(t){return t.session&&an(t.session)}));var gn=s(738);function En(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function Sn(t,e,n,r,o,i,s){try{var u=t[i](s),a=u.value}catch(t){return void n(t)}u.done?e(a):Promise.resolve(a).then(r,o)}function On(t){return function(){var e=this,n=arguments;return new Promise((function(r,o){var i=t.apply(e,n);function s(t){Sn(i,r,o,s,u,"next",t)}function u(t){Sn(i,r,o,s,u,"throw",t)}s(void 0)}))}}function _n(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,o,i=[],s=!0,u=!1;try{for(n=n.call(t);!(s=(r=n.next()).done)&&(i.push(r.value),!e||i.length!==e);s=!0);}catch(t){u=!0,o=t}finally{try{s||null==n.return||n.return()}finally{if(u)throw o}}return i}}(t,e)||function(t,e){if(t){if("string"==typeof t)return En(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(n):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?En(t,e):void 0}}(t,e)||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.")}()}function Pn(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}}function Tn(t,e){return An.apply(this,arguments)}function An(){return An=On((function(t,e){var n,r,o,i,s,u=arguments;return Pn(this,(function(a){switch(a.label){case 0:return n=!(u.length>2&&void 0!==u[2])||u[2],t?(r=null,[4,Promise.all([Ve("".concat(Be,"/Patient/").concat(t),e).catch((function(t){return r=t})),n?jn(t):Promise.resolve(null)])]):[3,2];case 1:if(o=_n.apply(void 0,[a.sent(),2]),i=o[0],s=o[1],i.ok)return[2,i.data];if(s)return[2,s];if(r)throw r;a.label=2;case 2:return[2,null]}}))})),An.apply(this,arguments)}function jn(t){return xn.apply(this,arguments)}function xn(){return(xn=On((function(t){var e,n,r;return Pn(this,(function(o){switch(o.label){case 0:return[4,(0,gn.getSynchronizationItems)("patient-registration")];case 1:return e=o.sent(),n=e.find((function(e){return e.fhirPatient.id===t})),[2,null!==(r=null==n?void 0:n.fhirPatient)&&void 0!==r?r:null]}}))}))).apply(this,arguments)}var Dn=function(){function t(){return Error.call(this),this.message="object unsubscribed",this.name="ObjectUnsubscribedError",this}return t.prototype=Object.create(Error.prototype),t}(),Nn=function(t){function n(e,n){var r=t.call(this)||this;return r.subject=e,r.subscriber=n,r.closed=!1,r}return e(n,t),n.prototype.unsubscribe=function(){if(!this.closed){this.closed=!0;var t=this.subject,e=t.observers;if(this.subject=null,e&&0!==e.length&&!t.isStopped&&!t.closed){var n=e.indexOf(this.subscriber);-1!==n&&e.splice(n,1)}}},n}(h),Un=function(t){function n(e){var n=t.call(this,e)||this;return n.destination=e,n}return e(n,t),n}(b),Mn=function(t){function n(){var e=t.call(this)||this;return e.observers=[],e.closed=!1,e.isStopped=!1,e.hasError=!1,e.thrownError=null,e}return e(n,t),n.prototype[y]=function(){return new Un(this)},n.prototype.lift=function(t){var e=new Cn(this,this);return e.operator=t,e},n.prototype.next=function(t){if(this.closed)throw new Dn;if(!this.isStopped)for(var e=this.observers,n=e.length,r=e.slice(),o=0;o<n;o++)r[o].next(t)},n.prototype.error=function(t){if(this.closed)throw new Dn;this.hasError=!0,this.thrownError=t,this.isStopped=!0;for(var e=this.observers,n=e.length,r=e.slice(),o=0;o<n;o++)r[o].error(t);this.observers.length=0},n.prototype.complete=function(){if(this.closed)throw new Dn;this.isStopped=!0;for(var t=this.observers,e=t.length,n=t.slice(),r=0;r<e;r++)n[r].complete();this.observers.length=0},n.prototype.unsubscribe=function(){this.isStopped=!0,this.closed=!0,this.observers=null},n.prototype._trySubscribe=function(e){if(this.closed)throw new Dn;return t.prototype._trySubscribe.call(this,e)},n.prototype._subscribe=function(t){if(this.closed)throw new Dn;return this.hasError?(t.error(this.thrownError),h.EMPTY):this.isStopped?(t.complete(),h.EMPTY):(this.observers.push(t),new Nn(this,t))},n.prototype.asObservable=function(){var t=new g;return t.source=this,t},n.create=function(t,e){return new Cn(t,e)},n}(g),Cn=function(t){function n(e,n){var r=t.call(this)||this;return r.destination=e,r.source=n,r}return e(n,t),n.prototype.next=function(t){var e=this.destination;e&&e.next&&e.next(t)},n.prototype.error=function(t){var e=this.destination;e&&e.error&&this.destination.error(t)},n.prototype.complete=function(){var t=this.destination;t&&t.complete&&this.destination.complete()},n.prototype._subscribe=function(t){return this.source?this.source.subscribe(t):h.EMPTY},n}(Mn),kn=function(t){function n(e){var n=t.call(this)||this;return n._value=e,n}return e(n,t),Object.defineProperty(n.prototype,"value",{get:function(){return this.getValue()},enumerable:!0,configurable:!0}),n.prototype._subscribe=function(e){var n=t.prototype._subscribe.call(this,e);return n&&!n.closed&&e.next(this._value),n},n.prototype.getValue=function(){if(this.hasError)throw this.thrownError;if(this.closed)throw new Dn;return this._value},n.prototype.next=function(e){t.prototype.next.call(this,this._value=e)},n}(Mn),Ln=function(){function t(){return Error.call(this),this.message="argument out of range",this.name="ArgumentOutOfRangeError",this}return t.prototype=Object.create(Error.prototype),t}(),In=new g((function(t){return t.complete()}));function Rn(t){return function(e){return 0===t?n?function(t){return new g((function(e){return t.schedule((function(){return e.complete()}))}))}(n):In:e.lift(new Bn(t));var n}}var Bn=function(){function t(t){if(this.total=t,this.total<0)throw new Ln}return t.prototype.call=function(t,e){return e.subscribe(new Gn(t,this.total))},t}(),Gn=function(t){function n(e,n){var r=t.call(this,e)||this;return r.total=n,r.count=0,r}return e(n,t),n.prototype._next=function(t){var e=this.total,n=++this.count;n<=e&&(this.destination.next(t),n===e&&(this.destination.complete(),this.unsubscribe()))},n}(b);function $n(t,e){return function(n){if("function"!=typeof t)throw new TypeError("argument is not a function. Are you looking for `mapTo()`?");return n.lift(new Vn(t,e))}}var Vn=function(){function t(t,e){this.project=t,this.thisArg=e}return t.prototype.call=function(t,e){return e.subscribe(new Wn(t,this.project,this.thisArg))},t}(),Wn=function(t){function n(e,n,r){var o=t.call(this,e)||this;return o.project=n,o.count=0,o.thisArg=r||o,o}return e(n,t),n.prototype._next=function(t){var e;try{e=this.project.call(this.thisArg,t,this.count++)}catch(t){return void this.destination.error(t)}this.destination.next(e)},n}(b),Fn="custom:(uuid,display,voided,indication,startDatetime,stopDatetime,encounters:(uuid,display,encounterDatetime,form:(uuid,name),location:ref,encounterType:ref,encounterProviders:(uuid,display,provider:(uuid,display))),patient:(uuid,display),visitType:(uuid,name,display),attributes:(uuid,display,attributeType:(name,datatypeClassname,uuid),value),location:(uuid,name,display))",Hn=function(){try{return JSON.parse(localStorage.getItem("openmrs:visitStoreState")||"null")}catch(t){return null}}()||{patientUuid:null,manuallySetVisitUuid:null};function Jn(){return(0,W.getGlobalStore)("visit",Hn)}function zn(t,e){Jn().setState({patientUuid:t,manuallySetVisitUuid:e})}function Yn(t,e,n){var r=null!=n?n:Fn;return We("".concat(Re,"/visit?patient=").concat(t,"&v=").concat(r),{signal:e.signal,method:"GET",headers:{"Content-type":"application/json"}}).pipe(Rn(1)).pipe($n((function(t){return t})))}function Kn(t,e){return We("".concat(Re,"/visit"),{signal:e.signal,method:"POST",headers:{"Content-type":"application/json"},body:t})}function qn(t,e,n){return We("".concat(Re,"/visit/").concat(t),{signal:n.signal,method:"POST",headers:{"Content-type":"application/json"},body:e})}Jn().subscribe((function(t){var e;e=t,localStorage.setItem("openmrs:visitStoreState",JSON.stringify(e))}));var Qn,Xn,Zn=new kn(null);function tr(t){return{uuid:t.uuid,display:t.display,name:t.name}}function er(){return We("".concat(Re,"/visittype")).pipe($n((function(t){return t.data.results.map(tr)}))).pipe(Rn(1))}function nr(t){return{uuid:t.uuid,display:t.display}}function rr(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return We("".concat(Re,"/location")+(t?"?tag="+t:"")).pipe($n((function(t){return t.data.results.map(nr)}))).pipe(Rn(1))}!function(t){t.NEWVISIT="startVisit",t.EDITVISIT="editVisit",t.LOADING="loadingVisit"}(Qn||(Qn={})),function(t){t.NOTSTARTED="notStarted",t.ONGOING="ongoing"}(Xn||(Xn={}));var or={"webservices.rest":"2.24.0",fhir2:"1.0.0-SNAPSHOT"}})(),u})())}}}));
2
+ System.register(["@openmrs/esm-config","@openmrs/esm-navigation","@openmrs/esm-error-handling","@openmrs/esm-offline"],(function(t,e){var r={},n={},o={},i={};return{setters:[function(t){r.Type=t.Type,r.defineConfigSchema=t.defineConfigSchema,r.getConfig=t.getConfig,r.validators=t.validators},function(t){n.navigate=t.navigate},function(t){o.reportError=t.reportError},function(t){i.getSynchronizationItems=t.getSynchronizationItems}],execute:function(){t((()=>{var t={385:()=>{System.register(["@openmrs/esm-utils"],(function(t,e){var r={};return{setters:[function(t){r.shallowEqual=t.shallowEqual}],execute:function(){t(function(){"use strict";var t={618:function(t){t.exports=r}},e={};function n(r){var o=e[r];if(void 0!==o)return o.exports;var i=e[r]={exports:{}};return t[r](i,i.exports,n),i.exports}n.d=function(t,e){for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var o={};return function(){var t=function(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n},e=function(t,e){var r=l[t];if(r)return r.active?console.error("Attempted to override the existing store ".concat(t,". Make sure that stores are only created once.")):r.value.setState(e,!0),r.active=!0,r.value;var n=c()((function(){return e}));return l[t]={value:n,active:!0},n},r=function(t,e){var r=l[t];return r?(r.active?console.error("Attempted to override the existing store ".concat(t,". Make sure that stores are only created once.")):r.value=e,r.active=!0,r.value):(l[t]={value:e,active:!0},e)},i=function(t,e){var r=l[t];if(!r){var n=c()((function(){return null!=e?e:{}}));return l[t]={value:n,active:!1},n}return r.value},s=function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];var o,i=function(t){if(Array.isArray(t))return t}(o=r)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i=[],s=!0,u=!1;try{for(r=r.call(t);!(s=(n=r.next()).done)&&(i.push(n.value),3!==i.length);s=!0);}catch(t){u=!0,o=t}finally{try{s||null==r.return||r.return()}finally{if(u)throw o}}return i}}(o)||function(e,r){if(e){if("string"==typeof e)return t(e,3);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)?t(e,3):void 0}}(o)||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.")}(),s=i[0],a=i[1],c=i[2],l=void 0===c?a:c,f=void 0===c?function(t){return t}:a;return l(f(s.getState())),s.subscribe((function(t,e){var r=f(t);(0,u.shallowEqual)(e,r)||l(r)}))};n.r(o),n.d(o,{createGlobalStore:function(){return e},getGlobalStore:function(){return i},registerGlobalStore:function(){return r},subscribeTo:function(){return s}});var u=n(618),a=function(t){var e,r=new Set,n=function(t,n){var o="function"==typeof t?t(e):t;if(!Object.is(o,e)){var i=e;e=(null!=n?n:"object"!=typeof o||null===o)?o:Object.assign({},e,o),r.forEach((function(t){return t(e,i)}))}},o=function(){return e},i={setState:n,getState:o,getInitialState:function(){return s},subscribe:function(t){return r.add(t),function(){return r.delete(t)}},destroy:function(){console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),r.clear()}},s=e=t(n,o,i);return i},c=function(t){return t?a(t):a},l={};setTimeout((function(){"development"===window.spaEnv&&(window.stores=l)}),1e3)}(),o}())}}}))},824:t=>{"use strict";t.exports=r},254:t=>{"use strict";t.exports=o},513:t=>{"use strict";t.exports=n},738:t=>{"use strict";t.exports=i}},e={};function s(r){var n=e[r];if(void 0!==n)return n.exports;var o=e[r]={exports:{}};return t[r](o,o.exports,s),o.exports}s.d=(t,e)=>{for(var r in e)s.o(e,r)&&!s.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},s.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),s.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var u={};return(()=>{"use strict";s.r(u),s.d(u,{OpenmrsFetchError:()=>Fe,VisitMode:()=>Kr,VisitStatus:()=>Qr,attachmentUrl:()=>Je,backendDependencies:()=>nn,clearCurrentUser:()=>cr,createAttachment:()=>Ye,defaultVisitCustomRepresentation:()=>Wr,deleteAttachmentPermanently:()=>Qe,fetchCurrentPatient:()=>Pr,fhirBaseUrl:()=>Be,getAttachmentByUuid:()=>qe,getAttachments:()=>ze,getCurrentUser:()=>ir,getLocations:()=>rn,getLoggedInUser:()=>fr,getSessionLocation:()=>pr,getSessionStore:()=>sr,getStartedVisit:()=>Xr,getVisitStore:()=>Hr,getVisitTypes:()=>tn,getVisitsForPatient:()=>qr,makeUrl:()=>Ge,openmrsFetch:()=>Ve,openmrsObservableFetch:()=>We,refetchCurrentUser:()=>ar,restBaseUrl:()=>Re,saveVisit:()=>zr,sessionEndpoint:()=>$e,sessionStore:()=>nr,setCurrentVisit:()=>Jr,setSessionLocation:()=>hr,setUserLanguage:()=>ur,setUserProperties:()=>yr,setupApiModule:()=>mr,toLocationObject:()=>en,toVisitTypeObject:()=>Zr,updateVisit:()=>Yr,userHasAccess:()=>lr});var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])},t(e,r)};function e(e,r){function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}function r(t){return"function"==typeof t}var n=!1,o={Promise:void 0,set useDeprecatedSynchronousErrorHandling(t){t&&(new Error).stack,n=t},get useDeprecatedSynchronousErrorHandling(){return n}};function i(t){setTimeout((function(){throw t}),0)}var a={closed:!0,next:function(t){},error:function(t){if(o.useDeprecatedSynchronousErrorHandling)throw t;i(t)},complete:function(){}},c=function(){return Array.isArray||function(t){return t&&"number"==typeof t.length}}();function l(t){return null!==t&&"object"==typeof t}var f=function(){function t(t){return Error.call(this),this.message=t?t.length+" errors occurred during unsubscription:\n"+t.map((function(t,e){return e+1+") "+t.toString()})).join("\n "):"",this.name="UnsubscriptionError",this.errors=t,this}return t.prototype=Object.create(Error.prototype),t}(),p=f,h=function(){function t(t){this.closed=!1,this._parentOrParents=null,this._subscriptions=null,t&&(this._ctorUnsubscribe=!0,this._unsubscribe=t)}return t.prototype.unsubscribe=function(){var e;if(!this.closed){var n=this,o=n._parentOrParents,i=n._ctorUnsubscribe,s=n._unsubscribe,u=n._subscriptions;if(this.closed=!0,this._parentOrParents=null,this._subscriptions=null,o instanceof t)o.remove(this);else if(null!==o)for(var a=0;a<o.length;++a)o[a].remove(this);if(r(s)){i&&(this._unsubscribe=void 0);try{s.call(this)}catch(t){e=t instanceof p?d(t.errors):[t]}}if(c(u)){a=-1;for(var f=u.length;++a<f;){var h=u[a];if(l(h))try{h.unsubscribe()}catch(t){e=e||[],t instanceof p?e=e.concat(d(t.errors)):e.push(t)}}}if(e)throw new p(e)}},t.prototype.add=function(e){var r=e;if(!e)return t.EMPTY;switch(typeof e){case"function":r=new t(e);case"object":if(r===this||r.closed||"function"!=typeof r.unsubscribe)return r;if(this.closed)return r.unsubscribe(),r;if(!(r instanceof t)){var n=r;(r=new t)._subscriptions=[n]}break;default:throw new Error("unrecognized teardown "+e+" added to Subscription.")}var o=r._parentOrParents;if(null===o)r._parentOrParents=this;else if(o instanceof t){if(o===this)return r;r._parentOrParents=[o,this]}else{if(-1!==o.indexOf(this))return r;o.push(this)}var i=this._subscriptions;return null===i?this._subscriptions=[r]:i.push(r),r},t.prototype.remove=function(t){var e=this._subscriptions;if(e){var r=e.indexOf(t);-1!==r&&e.splice(r,1)}},t.EMPTY=function(t){return t.closed=!0,t}(new t),t}();function d(t){return t.reduce((function(t,e){return t.concat(e instanceof p?e.errors:e)}),[])}var y=function(){return"function"==typeof Symbol?Symbol("rxSubscriber"):"@@rxSubscriber_"+Math.random()}(),b=function(t){function r(e,n,o){var i=t.call(this)||this;switch(i.syncErrorValue=null,i.syncErrorThrown=!1,i.syncErrorThrowable=!1,i.isStopped=!1,arguments.length){case 0:i.destination=a;break;case 1:if(!e){i.destination=a;break}if("object"==typeof e){e instanceof r?(i.syncErrorThrowable=e.syncErrorThrowable,i.destination=e,e.add(i)):(i.syncErrorThrowable=!0,i.destination=new v(i,e));break}default:i.syncErrorThrowable=!0,i.destination=new v(i,e,n,o)}return i}return e(r,t),r.prototype[y]=function(){return this},r.create=function(t,e,n){var o=new r(t,e,n);return o.syncErrorThrowable=!1,o},r.prototype.next=function(t){this.isStopped||this._next(t)},r.prototype.error=function(t){this.isStopped||(this.isStopped=!0,this._error(t))},r.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},r.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,t.prototype.unsubscribe.call(this))},r.prototype._next=function(t){this.destination.next(t)},r.prototype._error=function(t){this.destination.error(t),this.unsubscribe()},r.prototype._complete=function(){this.destination.complete(),this.unsubscribe()},r.prototype._unsubscribeAndRecycle=function(){var t=this._parentOrParents;return this._parentOrParents=null,this.unsubscribe(),this.closed=!1,this.isStopped=!1,this._parentOrParents=t,this},r}(h),v=function(t){function n(e,n,o,i){var s,u=t.call(this)||this;u._parentSubscriber=e;var c=u;return r(n)?s=n:n&&(s=n.next,o=n.error,i=n.complete,n!==a&&(r((c=Object.create(n)).unsubscribe)&&u.add(c.unsubscribe.bind(c)),c.unsubscribe=u.unsubscribe.bind(u))),u._context=c,u._next=s,u._error=o,u._complete=i,u}return e(n,t),n.prototype.next=function(t){if(!this.isStopped&&this._next){var e=this._parentSubscriber;o.useDeprecatedSynchronousErrorHandling&&e.syncErrorThrowable?this.__tryOrSetError(e,this._next,t)&&this.unsubscribe():this.__tryOrUnsub(this._next,t)}},n.prototype.error=function(t){if(!this.isStopped){var e=this._parentSubscriber,r=o.useDeprecatedSynchronousErrorHandling;if(this._error)r&&e.syncErrorThrowable?(this.__tryOrSetError(e,this._error,t),this.unsubscribe()):(this.__tryOrUnsub(this._error,t),this.unsubscribe());else if(e.syncErrorThrowable)r?(e.syncErrorValue=t,e.syncErrorThrown=!0):i(t),this.unsubscribe();else{if(this.unsubscribe(),r)throw t;i(t)}}},n.prototype.complete=function(){var t=this;if(!this.isStopped){var e=this._parentSubscriber;if(this._complete){var r=function(){return t._complete.call(t._context)};o.useDeprecatedSynchronousErrorHandling&&e.syncErrorThrowable?(this.__tryOrSetError(e,r),this.unsubscribe()):(this.__tryOrUnsub(r),this.unsubscribe())}else this.unsubscribe()}},n.prototype.__tryOrUnsub=function(t,e){try{t.call(this._context,e)}catch(t){if(this.unsubscribe(),o.useDeprecatedSynchronousErrorHandling)throw t;i(t)}},n.prototype.__tryOrSetError=function(t,e,r){if(!o.useDeprecatedSynchronousErrorHandling)throw new Error("bad call");try{e.call(this._context,r)}catch(e){return o.useDeprecatedSynchronousErrorHandling?(t.syncErrorValue=e,t.syncErrorThrown=!0,!0):(i(e),!0)}return!1},n.prototype._unsubscribe=function(){var t=this._parentSubscriber;this._context=null,this._parentSubscriber=null,t.unsubscribe()},n}(b),m=function(){return"function"==typeof Symbol&&Symbol.observable||"@@observable"}();function w(t){return t}var g=function(){function t(t){this._isScalar=!1,t&&(this._subscribe=t)}return t.prototype.lift=function(e){var r=new t;return r.source=this,r.operator=e,r},t.prototype.subscribe=function(t,e,r){var n=this.operator,i=function(t,e,r){if(t){if(t instanceof b)return t;if(t[y])return t[y]()}return t||e||r?new b(t,e,r):new b(a)}(t,e,r);if(n?i.add(n.call(i,this.source)):i.add(this.source||o.useDeprecatedSynchronousErrorHandling&&!i.syncErrorThrowable?this._subscribe(i):this._trySubscribe(i)),o.useDeprecatedSynchronousErrorHandling&&i.syncErrorThrowable&&(i.syncErrorThrowable=!1,i.syncErrorThrown))throw i.syncErrorValue;return i},t.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(e){o.useDeprecatedSynchronousErrorHandling&&(t.syncErrorThrown=!0,t.syncErrorValue=e),function(t){for(;t;){var e=t,r=e.closed,n=e.destination,o=e.isStopped;if(r||o)return!1;t=n&&n instanceof b?n:null}return!0}(t)?t.error(e):console.warn(e)}},t.prototype.forEach=function(t,e){var r=this;return new(e=E(e))((function(e,n){var o;o=r.subscribe((function(e){try{t(e)}catch(t){n(t),o&&o.unsubscribe()}}),n,e)}))},t.prototype._subscribe=function(t){var e=this.source;return e&&e.subscribe(t)},t.prototype[m]=function(){return this},t.prototype.pipe=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return 0===t.length?this:(0===(r=t).length?w:1===r.length?r[0]:function(t){return r.reduce((function(t,e){return e(t)}),t)})(this);var r},t.prototype.toPromise=function(t){var e=this;return new(t=E(t))((function(t,r){var n;e.subscribe((function(t){return n=t}),(function(t){return r(t)}),(function(){return t(n)}))}))},t.create=function(e){return new t(e)},t}();function E(t){if(t||(t=o.Promise||Promise),!t)throw new Error("no Promise impl found");return t}const S="object"==typeof global&&global&&global.Object===Object&&global;var O="object"==typeof self&&self&&self.Object===Object&&self;const _=(S||O||Function("return this")()).Symbol;var P=Object.prototype,T=P.hasOwnProperty,A=P.toString,j=_?_.toStringTag:void 0;var x=Object.prototype.toString;var D=_?_.toStringTag:void 0;const N=function(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":D&&D in Object(t)?function(t){var e=T.call(t,j),r=t[j];try{t[j]=void 0;var n=!0}catch(t){}var o=A.call(t);return n&&(e?t[j]=r:delete t[j]),o}(t):function(t){return x.call(t)}(t)},U=(M=Object.getPrototypeOf,k=Object,function(t){return M(k(t))});var M,k;var C=Function.prototype,I=Object.prototype,L=C.toString,R=I.hasOwnProperty,B=L.call(Object);const $=function(t){if(!function(t){return null!=t&&"object"==typeof t}(t)||"[object Object]"!=N(t))return!1;var e=U(t);if(null===e)return!0;var r=R.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&L.call(r)==B};var G=s(824),V=s(513),W=s(385);(0,W.createGlobalStore)("breadcrumbs",[]);var F=Object.freeze({__proto__:null,get start(){return Te},get ensureJQuerySupport(){return te},get setBootstrapMaxTime(){return kt},get setMountMaxTime(){return Ct},get setUnmountMaxTime(){return It},get setUnloadMaxTime(){return Lt},get registerApplication(){return pe},get unregisterApplication(){return de},get getMountedApps(){return ae},get getAppStatus(){return le},get unloadApplication(){return ye},get checkActivityFunctions(){return he},get getAppNames(){return ce},get pathToActiveWhen(){return me},get navigateToUrl(){return Ft},get patchHistoryApi(){return Qt},get triggerAppChange(){return Se},get addErrorHandler(){return Y},get removeErrorHandler(){return K},get mountRootParcel(){return xt},get NOT_LOADED(){return Z},get LOADING_SOURCE_CODE(){return tt},get NOT_BOOTSTRAPPED(){return et},get BOOTSTRAPPING(){return rt},get NOT_MOUNTED(){return nt},get MOUNTING(){return ot},get UPDATING(){return st},get LOAD_ERROR(){return ct},get MOUNTED(){return it},get UNLOADING(){return at},get UNMOUNTING(){return ut},get SKIP_BECAUSE_BROKEN(){return lt}}),H=("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{}).CustomEvent,J=function(){try{var t=new H("cat",{detail:{foo:"bar"}});return"cat"===t.type&&"bar"===t.detail.foo}catch(t){}return!1}()?H:"undefined"!=typeof document&&"function"==typeof document.createEvent?function(t,e){var r=document.createEvent("CustomEvent");return e?r.initCustomEvent(t,e.bubbles,e.cancelable,e.detail):r.initCustomEvent(t,!1,!1,void 0),r}:function(t,e){var r=document.createEventObject();return r.type=t,e?(r.bubbles=Boolean(e.bubbles),r.cancelable=Boolean(e.cancelable),r.detail=e.detail):(r.bubbles=!1,r.cancelable=!1,r.detail=void 0),r};let q=[];function z(t,e,r){const n=X(t,e,r);q.length?q.forEach((t=>t(n))):setTimeout((()=>{throw n}))}function Y(t){if("function"!=typeof t)throw Error(Q(28,!1));q.push(t)}function K(t){if("function"!=typeof t)throw Error(Q(29,!1));let e=!1;return q=q.filter((r=>{const n=r===t;return e=e||n,!n})),e}function Q(t,e,...r){return`single-spa minified message #${t}: ${e?e+" ":""}See https://single-spa.js.org/error/?code=${t}${r.length?`&arg=${r.join("&arg=")}`:""}`}function X(t,e,r){const n=`${yt(e)} '${ht(e)}' died in status ${e.status}: `;let o;if(t instanceof Error){try{t.message=n+t.message}catch(t){}o=t}else{console.warn(Q(30,!1,e.status,ht(e)));try{o=Error(n+JSON.stringify(t))}catch(e){o=t}}return o.appOrParcelName=ht(e),e.status=r,o}const Z="NOT_LOADED",tt="LOADING_SOURCE_CODE",et="NOT_BOOTSTRAPPED",rt="BOOTSTRAPPING",nt="NOT_MOUNTED",ot="MOUNTING",it="MOUNTED",st="UPDATING",ut="UNMOUNTING",at="UNLOADING",ct="LOAD_ERROR",lt="SKIP_BECAUSE_BROKEN";function ft(t){return t.status===it}function pt(t){try{return t.activeWhen(window.location)}catch(e){return z(e,t,lt),!1}}function ht(t){return t.name}function dt(t){return Boolean(t.unmountThisParcel)}function yt(t){return dt(t)?"parcel":"application"}function bt(){for(let t=arguments.length-1;t>0;t--)for(let e in arguments[t])"__proto__"!==e&&(arguments[t-1][e]=arguments[t][e]);return arguments[0]}function vt(t,e){for(let r=0;r<t.length;r++)if(e(t[r]))return t[r];return null}function mt(t){return t&&("function"==typeof t||(e=t,Array.isArray(e)&&!vt(e,(t=>"function"!=typeof t))));var e}function wt(t,e){let r=t[e]||[];r=Array.isArray(r)?r:[r],0===r.length&&(r=[()=>Promise.resolve()]);const n=yt(t),o=ht(t);return function(t){return r.reduce(((r,i,s)=>r.then((()=>{const r=i(t);return gt(r)?r:Promise.reject(Q(15,!1,n,o,e,s))}))),Promise.resolve())}}function gt(t){return t&&"function"==typeof t.then&&"function"==typeof t.catch}let Et=[];function St(t,e){return Promise.resolve().then((()=>t.status!==et?t:(t.status=rt,t.bootstrap?Rt(t,"bootstrap").then(r).catch((r=>{if(e)throw X(r,t,lt);return z(r,t,lt),t})):Promise.resolve().then(r))));function r(){return t.status=nt,t}}function Ot(t,e){return Promise.resolve().then((()=>{if(t.status!==it)return t;t.status=ut;const r=Object.keys(t.parcels).map((e=>t.parcels[e].unmountThisParcel()));return Promise.all(r).then(n,(r=>n().then((()=>{const n=Error(r.message);if(e)throw X(n,t,lt);z(n,t,lt)})))).then((()=>t));function n(){return Rt(t,"unmount").then((()=>{t.status=nt}),(r=>{if(e)throw X(r,t,lt);z(r,t,lt)}))}}))}let _t=!1,Pt=!1;function Tt(t,e){return Promise.resolve().then((()=>t.status!==nt?t:(_t||(window.dispatchEvent(new J("single-spa:before-first-mount")),_t=!0),t.status=ot,Rt(t,"mount").then((()=>(t.status=it,Pt||(window.dispatchEvent(new J("single-spa:first-mount")),Pt=!0),t))).catch((r=>{return t.status=it,Ot(t,!0).then(n,n);function n(){if(e)throw X(r,t,lt);return z(r,t,lt),t}})))))}let At=0;const jt={parcels:{}};function xt(){return Dt.apply(jt,arguments)}function Dt(t,e){const r=this;if(!t||"object"!=typeof t&&"function"!=typeof t)throw Error(Q(2,!1));if(t.name&&"string"!=typeof t.name)throw Error(Q(3,!1,typeof t.name));const n=At++;let o=t.name||`parcel-${n}`;if("object"!=typeof e)throw Error(Q(4,!1,o,typeof e));if(!e.domElement)throw Error(Q(5,!1,o));const i="function"==typeof t,s=i?t:()=>Promise.resolve(t),u={id:n,parcels:{},status:i?tt:et,customProps:e,parentName:ht(r),unmountThisParcel:()=>f.then((()=>{if(u.status!==it)throw Error(Q(6,!1,o,u.status));return Ot(u,!0)})).then((t=>(u.parentName&&delete r.parcels[u.id],t))).then((t=>(p(t),t))).catch((t=>{throw u.status=lt,h(t),t}))};let a;r.parcels[n]=u;let c=s();if(!c||"function"!=typeof c.then)throw Error(Q(7,!1));c=c.then((t=>{if(!t)throw Error(Q(8,!1));if(o=t.name||`parcel-${n}`,Object.prototype.hasOwnProperty.call(t,"bootstrap")&&!mt(t.bootstrap))throw Error(Q(9,!1,o));if(!mt(t.mount))throw Error(Q(10,!1,o));if(!mt(t.unmount))throw Error(Q(11,!1,o));if(t.update&&!mt(t.update))throw Error(Q(12,!1,o));const e=wt(t,"bootstrap"),r=wt(t,"mount"),i=wt(t,"unmount");u.status=et,u.name=o,u.bootstrap=e,u.mount=r,u.unmount=i,u.timeouts=Bt(t.timeouts),t.update&&(u.update=wt(t,"update"),a.update=function(t){return u.customProps=t,Nt((e=u,Promise.resolve().then((()=>{if(e.status!==it)throw Error(Q(32,!1,ht(e)));return e.status=st,Rt(e,"update").then((()=>(e.status=it,e))).catch((t=>{throw X(t,e,lt)}))}))));var e})}));const l=c.then((()=>St(u,!0))),f=l.then((()=>Tt(u,!0)));let p,h;const d=new Promise(((t,e)=>{p=t,h=e}));return a={mount:()=>Nt(Promise.resolve().then((()=>{if(u.status!==nt)throw Error(Q(13,!1,o,u.status));return r.parcels[n]=u,Tt(u)}))),unmount:()=>Nt(u.unmountThisParcel()),getStatus:()=>u.status,loadPromise:Nt(c),bootstrapPromise:Nt(l),mountPromise:Nt(f),unmountPromise:Nt(d)},a}function Nt(t){return t.then((()=>null))}function Ut(t){const e=ht(t);let r="function"==typeof t.customProps?t.customProps(e,window.location):t.customProps;("object"!=typeof r||null===r||Array.isArray(r))&&(r={},console.warn(Q(40,!1),e,r));const n=bt({},r,{name:e,mountParcel:Dt.bind(t),singleSpa:F});return dt(t)&&(n.unmountSelf=t.unmountThisParcel),n}const Mt={bootstrap:{millis:4e3,dieOnTimeout:!1,warningMillis:1e3},mount:{millis:3e3,dieOnTimeout:!1,warningMillis:1e3},unmount:{millis:3e3,dieOnTimeout:!1,warningMillis:1e3},unload:{millis:3e3,dieOnTimeout:!1,warningMillis:1e3},update:{millis:3e3,dieOnTimeout:!1,warningMillis:1e3}};function kt(t,e,r){if("number"!=typeof t||t<=0)throw Error(Q(16,!1));Mt.bootstrap={millis:t,dieOnTimeout:e,warningMillis:r||1e3}}function Ct(t,e,r){if("number"!=typeof t||t<=0)throw Error(Q(17,!1));Mt.mount={millis:t,dieOnTimeout:e,warningMillis:r||1e3}}function It(t,e,r){if("number"!=typeof t||t<=0)throw Error(Q(18,!1));Mt.unmount={millis:t,dieOnTimeout:e,warningMillis:r||1e3}}function Lt(t,e,r){if("number"!=typeof t||t<=0)throw Error(Q(19,!1));Mt.unload={millis:t,dieOnTimeout:e,warningMillis:r||1e3}}function Rt(t,e){const r=t.timeouts[e],n=r.warningMillis,o=yt(t);return new Promise(((i,s)=>{let u=!1,a=!1;t[e](Ut(t)).then((t=>{u=!0,i(t)})).catch((t=>{u=!0,s(t)})),setTimeout((()=>l(1)),n),setTimeout((()=>l(!0)),r.millis);const c=Q(31,!1,e,o,ht(t),r.millis);function l(t){if(!u)if(!0===t)a=!0,r.dieOnTimeout?s(Error(c)):console.error(c);else if(!a){const e=t,o=e*n;console.warn(c),o+n<r.millis&&setTimeout((()=>l(e+1)),n)}}}))}function Bt(t){const e={};for(let r in Mt)e[r]=bt({},Mt[r],t&&t[r]||{});return e}function $t(t){return Promise.resolve().then((()=>{if(t.loadPromise)return t.loadPromise;if(t.status!==Z&&t.status!==ct)return t;let e,r;return t.status=tt,t.loadPromise=Promise.resolve().then((()=>{const n=t.loadApp(Ut(t));if(!gt(n))throw r=!0,Error(Q(33,!1,ht(t)));return n.then((r=>{let n;t.loadErrorTime=null,e=r,"object"!=typeof e&&(n=34),Object.prototype.hasOwnProperty.call(e,"bootstrap")&&!mt(e.bootstrap)&&(n=35),mt(e.mount)||(n=36),mt(e.unmount)||(n=37);const o=yt(e);if(n){let r;try{r=JSON.stringify(e)}catch(t){}return console.error(Q(n,!1,o,ht(t),r),e),z(void 0,t,lt),t}return e.devtools&&e.devtools.overlays&&(t.devtools.overlays=bt({},t.devtools.overlays,e.devtools.overlays)),t.status=et,t.bootstrap=wt(e,"bootstrap"),t.mount=wt(e,"mount"),t.unmount=wt(e,"unmount"),t.unload=wt(e,"unload"),t.timeouts=Bt(e.timeouts),delete t.loadPromise,t}))})).catch((e=>{let n;return delete t.loadPromise,r?n=lt:(n=ct,t.loadErrorTime=(new Date).getTime()),z(e,t,n),t}))}))}const Gt="undefined"!=typeof window,Vt={hashchange:[],popstate:[]},Wt=["hashchange","popstate"];function Ft(t){let e;if("string"==typeof t)e=t;else if(this&&this.href)e=this.href;else{if(!(t&&t.currentTarget&&t.currentTarget.href&&t.preventDefault))throw Error(Q(14,!1));e=t.currentTarget.href,t.preventDefault()}const r=Xt(window.location.href),n=Xt(e);0===e.indexOf("#")?window.location.hash=n.hash:r.host!==n.host&&n.host?window.location.href=e:n.pathname===r.pathname&&n.search===r.search?window.location.hash=n.hash:window.history.pushState(null,null,e)}function Ht(t){if(t){const e=t[0].type;Wt.indexOf(e)>=0&&Vt[e].forEach((e=>{try{e.apply(this,t)}catch(t){setTimeout((()=>{throw t}))}}))}}let Jt;function qt(){Oe([],arguments)}function zt(t,e){return function(){const r=window.location.href,n=t.apply(this,arguments),o=window.location.href;return Jt&&r===o||window.dispatchEvent(function(t,e){let r;try{r=new PopStateEvent("popstate",{state:t})}catch(e){r=document.createEvent("PopStateEvent"),r.initPopStateEvent("popstate",!1,!1,t)}return r.singleSpa=!0,r.singleSpaTrigger=e,r}(window.history.state,e)),n}}let Yt=null,Kt=!1;function Qt(t){if(Kt)throw Error(Q(43,!1));Jt=!t||!t.hasOwnProperty("urlRerouteOnly")||t.urlRerouteOnly,Kt=!0,Yt=window.history.replaceState,window.addEventListener("hashchange",qt),window.addEventListener("popstate",qt);const e=window.addEventListener,r=window.removeEventListener;window.addEventListener=function(t,r){if(!("function"==typeof r&&Wt.indexOf(t)>=0)||vt(Vt[t],(t=>t===r)))return e.apply(this,arguments);Vt[t].push(r)},window.removeEventListener=function(t,e){if(!("function"==typeof e&&Wt.indexOf(t)>=0))return r.apply(this,arguments);Vt[t]=Vt[t].filter((t=>t!==e))},window.history.pushState=zt(window.history.pushState,"pushState"),window.history.replaceState=zt(Yt,"replaceState")}function Xt(t){const e=document.createElement("a");return e.href=t,e}Gt&&(window.singleSpaNavigate?console.warn(Q(41,!1)):window.singleSpaNavigate=Ft);let Zt=!1;function te(t=window.jQuery){if(t||window.$&&window.$.fn&&window.$.fn.jquery&&(t=window.$),t&&!Zt){const e=t.fn.on,r=t.fn.off;t.fn.on=function(t,r){return ee.call(this,e,window.addEventListener,t,r,arguments)},t.fn.off=function(t,e){return ee.call(this,r,window.removeEventListener,t,e,arguments)},Zt=!0}}function ee(t,e,r,n,o){return"string"!=typeof r?t.apply(this,o):(r.split(/\s+/).forEach((t=>{Wt.indexOf(t)>=0&&(e(t,n),r=r.replace(t,""))})),""===r.trim()?this:t.apply(this,o))}const re={};function ne(t){return Promise.resolve().then((()=>{const e=re[ht(t)];if(!e)return t;if(t.status===Z)return oe(t,e),t;if(t.status===at)return e.promise.then((()=>t));if(t.status!==nt&&t.status!==ct)return t;const r=t.status===ct?Promise.resolve():Rt(t,"unload");return t.status=at,r.then((()=>(oe(t,e),t))).catch((r=>(function(t,e,r){delete re[ht(t)],delete t.bootstrap,delete t.mount,delete t.unmount,delete t.unload,z(r,t,lt),e.reject(r)}(t,e,r),t)))}))}function oe(t,e){delete re[ht(t)],delete t.bootstrap,delete t.mount,delete t.unmount,delete t.unload,t.status=Z,e.resolve()}function ie(t,e,r,n){re[ht(t)]={app:t,resolve:r,reject:n},Object.defineProperty(re[ht(t)],"promise",{get:e})}function se(t){return re[t]}const ue=[];function ae(){return ue.filter(ft).map(ht)}function ce(){return ue.map(ht)}function le(t){const e=vt(ue,(e=>ht(e)===t));return e?e.status:null}let fe=!1;function pe(t,e,r,n){const o=function(t,e,r,n){const o={name:null,loadApp:null,activeWhen:null,customProps:null};return"object"==typeof t?(function(t){if(Array.isArray(t)||null===t)throw Error(Q(39,!1));const e=["name","app","activeWhen","customProps"],r=Object.keys(t).reduce(((t,r)=>e.indexOf(r)>=0?t:t.concat(r)),[]);if(0!==r.length)throw Error(Q(38,!1,e.join(", "),r.join(", ")));if("string"!=typeof t.name||0===t.name.length)throw Error(Q(20,!1));if("object"!=typeof t.app&&"function"!=typeof t.app)throw Error(Q(20,!1));const n=t=>"string"==typeof t||"function"==typeof t;if(!(n(t.activeWhen)||Array.isArray(t.activeWhen)&&t.activeWhen.every(n)))throw Error(Q(24,!1));if(!ve(t.customProps))throw Error(Q(22,!1))}(t),o.name=t.name,o.loadApp=t.app,o.activeWhen=t.activeWhen,o.customProps=t.customProps):(function(t,e,r,n){if("string"!=typeof t||0===t.length)throw Error(Q(20,!1));if(!e)throw Error(Q(23,!1));if("function"!=typeof r)throw Error(Q(24,!1));if(!ve(n))throw Error(Q(22,!1))}(t,e,r,n),o.name=t,o.loadApp=e,o.activeWhen=r,o.customProps=n),o.loadApp="function"!=typeof(i=o.loadApp)?()=>Promise.resolve(i):i,o.customProps=function(t){return t||{}}(o.customProps),o.activeWhen=function(t){let e=Array.isArray(t)?t:[t];return e=e.map((t=>"function"==typeof t?t:me(t))),t=>e.some((e=>e(t)))}(o.activeWhen),o;var i}(t,e,r,n);if(Ae()||fe||(fe=!0,setTimeout((()=>{Ae()||console.warn(Q(1,!1))}),5e3)),-1!==ce().indexOf(o.name))throw Error(Q(21,!1,o.name));ue.push(bt({loadErrorTime:null,status:Z,parcels:{},devtools:{overlays:{options:{},selectors:[]}}},o)),Gt&&(te(),Oe())}function he(t=window.location){return ue.filter((e=>e.activeWhen(t))).map(ht)}function de(t){if(0===ue.filter((e=>ht(e)===t)).length)throw Error(Q(25,!1,t));return(Gt?ye(t,{waitForUnmount:!1}):Promise.resolve()).then((()=>{const e=ue.map(ht).indexOf(t);ue.splice(e,1)}))}function ye(t,e={waitForUnmount:!1}){if("string"!=typeof t)throw Error(Q(26,!1));const r=vt(ue,(e=>ht(e)===t));if(!r)throw Error(Q(27,!1,t));const n=se(ht(r));if(e&&e.waitForUnmount){if(n)return n.promise;{const t=new Promise(((e,n)=>{ie(r,(()=>t),e,n)}));return t}}{let t;return n?(t=n.promise,be(r,n.resolve,n.reject)):t=new Promise(((e,n)=>{ie(r,(()=>t),e,n),be(r,e,n)})),t}}function be(t,e,r){Promise.resolve().then((()=>{if(vt(he(),(e=>e===ht(t))))return Se()})).then((()=>Ot(t).then(ne).then((()=>{e(),setTimeout((()=>{Oe()}))})))).catch(r)}function ve(t){return!t||"function"==typeof t||"object"==typeof t&&null!==t&&!Array.isArray(t)}function me(t,e){const r=function(t,e){let r=0,n=!1,o="^";"/"!==t[0]&&(t="/"+t);for(let e=0;e<t.length;e++){const r=t[e];(!n&&":"===r||n&&"/"===r)&&i(e)}return i(t.length),new RegExp(o,"i");function i(i){const s=t.slice(r,i).replace(/[|\\{}()[\]^$+*?.]/g,"\\$&");if(o+=n?"[^/]+/?":s,i===t.length)if(n)e&&(o+="$");else{const t=e?"":".*";o="/"===o.charAt(o.length-1)?`${o}${t}$`:`${o}(/${t})?(#.*)?$`}n=!n,r=i}}(t,e);return t=>{let e=t.origin;e||(e=`${t.protocol}//${t.host}`);const n=t.href.replace(e,"").replace(t.search,"").split("?")[0];return r.test(n)}}let we=!1,ge=[],Ee=Gt&&window.location.href;function Se(){return Oe()}function Oe(t=[],e,r=!1){if(we)return new Promise(((t,r)=>{ge.push({resolve:t,reject:r,eventArguments:e})}));const{appsToUnload:n,appsToUnmount:o,appsToLoad:i,appsToMount:s}=function(){const t=[],e=[],r=[],n=[],o=(new Date).getTime();return ue.forEach((i=>{const s=i.status!==lt&&pt(i);switch(i.status){case ct:s&&o-i.loadErrorTime>=200&&r.push(i);break;case Z:case tt:s&&r.push(i);break;case et:case nt:!s&&se(ht(i))?t.push(i):s&&n.push(i);break;case it:s||e.push(i)}})),{appsToUnload:t,appsToUnmount:e,appsToLoad:r,appsToMount:n}}();let u,a=[],c=Ee,l=Ee=window.location.href;return Ae()?(we=!0,u=n.concat(i,o,s),Promise.resolve().then((()=>(y(0===u.length?"before-no-app-change":"before-app-change",d(!0)),y("before-routing-event",d(!0,{cancelNavigation:f})),Promise.all(a).then((r=>{if(r.some((t=>t)))return Yt.call(window.history,history.state,"",c.substring(location.origin.length)),Ee=location.href,we=!1,Oe(t,e,!0);const u=n.map(ne),a=o.map(Ot).map((t=>t.then(ne))).concat(u),l=Promise.all(a);l.then((()=>{y("before-mount-routing-event",d(!0))}),(t=>{throw t}));const f=i.map((t=>$t(t).then((t=>_e(t,l))))),b=s.filter((t=>i.indexOf(t)<0)).map((t=>_e(t,l)));return l.catch((t=>{throw h(),t})).then((()=>(h(),Promise.all(f.concat(b)).catch((e=>{throw t.forEach((t=>t.reject(e))),e})).then(p).then((()=>{}),(t=>{throw t})))))})))))):(u=i,Promise.resolve().then((()=>{const t=i.map($t);return Promise.all(t).then(h).then((()=>[])).catch((t=>{throw h(),t})).finally((()=>{}))})));function f(t=!0){const e="function"==typeof(null==t?void 0:t.then)?t:Promise.resolve(t);a.push(e.catch((t=>(console.warn(Error(Q(42,!1))),console.warn(t),!1))))}function p(){const e=ae();t.forEach((t=>t.resolve(e)));try{y(0===u.length?"no-app-change":"app-change",d()),y("routing-event",d())}catch(t){setTimeout((()=>{throw t}))}if(we=!1,ge.length>0){const t=ge;ge=[],Oe(t)}return e}function h(){r||(t.forEach((t=>{Ht(t.eventArguments)})),Ht(e))}function d(t=!1,r){const a={},f={[it]:[],[nt]:[],[Z]:[],[lt]:[]};t?(i.concat(s).forEach(((t,e)=>{h(t,it)})),n.forEach((t=>{h(t,Z)})),o.forEach((t=>{h(t,nt)}))):u.forEach((t=>{h(t)}));const p={detail:{newAppStatuses:a,appsByNewStatus:f,totalAppChanges:u.length,originalEvent:null==e?void 0:e[0],oldUrl:c,newUrl:l}};return r&&bt(p.detail,r),p;function h(t,e){const r=ht(t);e=e||le(r),a[r]=e,(f[e]=f[e]||[]).push(r)}}function y(t,e){r||window.dispatchEvent(new J(`single-spa:${t}`,e))}}function _e(t,e){return pt(t)?St(t).then((t=>e.then((()=>pt(t)?Tt(t):t)))):e.then((()=>t))}let Pe=!1;function Te(t){Pe=!0,Gt&&(Qt(t),Oe())}function Ae(){return Pe}var je={getRawAppData:function(){return[...ue]},reroute:Oe,NOT_LOADED:Z,toLoadPromise:$t,toBootstrapPromise:St,unregisterApplication:de,getProfilerData:function(){return Et}};Gt&&window.__SINGLE_SPA_DEVTOOLS__&&(window.__SINGLE_SPA_DEVTOOLS__.exposedMethods=je);var xe="openmrs:history";function De(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function Ne(t,e,r,n,o,i,s){try{var u=t[i](s),a=u.value}catch(t){return void r(t)}u.done?e(a):Promise.resolve(a).then(n,o)}function Ue(t,e,r){return Ue=Le()?Reflect.construct:function(t,e,r){var n=[null];n.push.apply(n,e);var o=new(Function.bind.apply(t,n));return r&&Ce(o,r.prototype),o},Ue.apply(null,arguments)}function Me(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function ke(t){return ke=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},ke(t)}function Ce(t,e){return Ce=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},Ce(t,e)}function Ie(t){var e="function"==typeof Map?new Map:void 0;return Ie=function(t){if(null===t||(r=t,-1===Function.toString.call(r).indexOf("[native code]")))return t;var r;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,n)}function n(){return Ue(t,arguments,ke(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),Ce(n,t)},Ie(t)}function Le(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}var Re="/ws/rest/v1",Be="/ws/fhir2/R4",$e="".concat(Re,"/session");function Ge(t){return t&&t.startsWith("http")?t:("/"!==t[0]&&(t="/"+t),window.openmrsBase+t)}function Ve(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if("string"!=typeof t)throw Error("The first argument to @openmrs/api's openmrsFetch function must be a url string");if("object"!=typeof e)throw Error("The second argument to @openmrs/api's openmrsFetch function must be a plain object.");if(!window.openmrsBase)throw Error("@openmrs/api is running in a browser that doesn't have window.openmrsBase, which is provided by openmrs-module-spa's HTML file.");var r=Ge(t);if(e.headers||(e.headers={}),$(e.body)&&(e.body=JSON.stringify(e.body)),void 0===e.headers.Accept&&(e.headers.Accept="application/json"),null===e.headers.Accept&&delete e.headers.Accept,t.startsWith(Re)&&void 0===e.headers["Disable-WWW-Authenticate"]&&(e.headers["Disable-WWW-Authenticate"]="true"),t.startsWith(Be)){var n=new URL(r,window.location.toString());n.searchParams.has("_summary")||(n.searchParams.set("_summary","data"),r=n.toString())}var o,i,s=Error();return window.fetch(r,e).then((o=function(t){var e,n;return function(t,e){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,n=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}}(this,(function(o){switch(o.label){case 0:return(e=t).ok?204===e.status?(e.data=null,[2,e]):[2,e.clone().text().then((function(t){try{t&&(e.data=JSON.parse(t))}catch(t){}return e}))]:[3,1];case 1:return[4,(0,G.getConfig)("@openmrs/esm-api")];case 2:return n=o.sent().redirectAuthFailure,r===Ge($e)&&403===e.status||n.enabled&&n.errors.includes(e.status)?(sessionStorage.removeItem(xe),(0,V.navigate)({to:n.url}),[2,n.resolvePromise?Promise.resolve():new Promise((function(){}))]):[2,e.clone().text().then((function(t){var n=t;try{n=JSON.parse(t)}catch(t){}throw new Fe(r,e,n,s)}),(function(t){throw new Fe(r,e,null,s)}))];case 3:return[2]}}))},i=function(){var t=this,e=arguments;return new Promise((function(r,n){var i=o.apply(t,e);function s(t){Ne(i,r,n,s,u,"next",t)}function u(t){Ne(i,r,n,s,u,"throw",t)}s(void 0)}))},function(t){return i.apply(this,arguments)}))}function We(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if("object"!=typeof e)throw Error("The second argument to openmrsObservableFetch must be either omitted or an object");var r=new AbortController;return e.signal=r.signal,new g((function(n){var o=!1;return Ve(t,e).then((function(t){o=!0,n.next(t),n.complete()}),(function(t){o=!0,n.error(t)})),function(){o||r.abort()}}))}var Fe=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Ce(t,e)}(o,t);var e,r,n=(e=o,r=Le(),function(){var t,n=ke(e);if(r){var o=ke(this).constructor;t=Reflect.construct(n,arguments,o)}else t=n.apply(this,arguments);return function(t,e){return!e||"object"!=((r=e)&&"undefined"!=typeof Symbol&&r.constructor===Symbol?"symbol":typeof r)&&"function"!=typeof e?De(t):e;var r}(this,t)});function o(t,e,r,i){var s;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,o),Me(De(s=n.call(this)),"response",void 0),Me(De(s),"responseBody",void 0),s.message="Server responded with ".concat(e.status," (").concat(e.statusText,") for url ").concat(t,". Check err.responseBody or network tab in dev tools for more info"),i.message=s.message,s.responseBody=r,s.response=e,s.stack="Stacktrace for outgoing request:\n".concat(i.stack,"\nStacktrace for incoming response:\n").concat(s.stack),s}return o}(Ie(Error));function He(t,e,r,n,o,i,s){try{var u=t[i](s),a=u.value}catch(t){return void r(t)}u.done?e(a):Promise.resolve(a).then(n,o)}var Je="".concat(Re,"/attachment");function qe(t,e){return Ve("".concat(Je,"/").concat(t),{signal:e.signal})}function ze(t,e,r){return Ve("".concat(Je,"?patient=").concat(t,"&includeEncounterless=").concat(e),{signal:r.signal})}function Ye(t,e){return Ke.apply(this,arguments)}function Ke(){var t;return t=function(t,e){var r;return function(t,e){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,n=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}}(this,(function(n){return(r=new FormData).append("fileCaption",e.fileDescription),r.append("patient",t),e.file?r.append("file",e.file):(r.append("file",new File([""],e.fileName),e.fileName),r.append("base64Content",e.base64Content)),[2,Ve("".concat(Je),{method:"POST",body:r})]}))},Ke=function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function s(t){He(i,n,o,s,u,"next",t)}function u(t){He(i,n,o,s,u,"throw",t)}s(void 0)}))},Ke.apply(this,arguments)}function Qe(t,e){return Ve("".concat(Je,"/").concat(t),{method:"DELETE",signal:e.signal})}var Xe=s(254);const Ze=function(t){return void 0===t};function tr(t,e,r,n,o,i,s){try{var u=t[i](s),a=u.value}catch(t){return void r(t)}u.done?e(a):Promise.resolve(a).then(n,o)}function er(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function s(t){tr(i,n,o,s,u,"next",t)}function u(t){tr(i,n,o,s,u,"throw",t)}s(void 0)}))}}function rr(t,e){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,n=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}}var nr=(0,W.createGlobalStore)("session",{loaded:!1,session:null}),or=0;function ir(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{includeAuthStatus:!0};return(or<Date.now()-6e4||!nr.getState().loaded)&&ar(),new g((function(e){var r=function(r){var n;r.loaded&&(t.includeAuthStatus?e.next(r.session):e.next(null===(n=r.session)||void 0===n?void 0:n.user))};return r(nr.getState()),nr.subscribe(r)}))}function sr(){return(or<Date.now()-6e4||!nr.getState().loaded)&&ar(),nr}function ur(t){var e,r,n,o=null!==(n=null==t||null===(e=t.user)||void 0===e||null===(r=e.userProperties)||void 0===r?void 0:r.defaultLocale)&&void 0!==n?n:t.locale,i=document.documentElement.getAttribute("lang");(function(t){if(void 0===t||"string"!=typeof t)return!1;try{new Intl.Locale(t)}catch(t){return!1}return!0})(o)&&o!==i&&document.documentElement.setAttribute("lang",o)}function ar(t,e){or=Date.now();var r={};return t&&e&&(r.Authorization="Basic ".concat(window.btoa("".concat(t,":").concat(e)))),vr(Ve($e,{headers:r}))}function cr(){nr.setState({loaded:!0,session:{authenticated:!1,sessionId:""}})}function lr(t,e){return void 0===e?Boolean(t):!Boolean(t)||function(t,e){return"string"==typeof t?!Ze(e.privileges.find((function(e){return t===e.display}))):Array.isArray(t)?t.every((function(t){return!Ze(e.privileges.find((function(e){return t===e.display})))})):(Ze(t)||console.error('Could not understand privileges "'.concat(t,'"')),!0)}(t,e)||function(t){return!Ze(t.roles.find((function(t){return"System Developer"===t.display})))}(e)}function fr(){var t,e;return new Promise((function(r){var n=function(n){n.loaded&&n.session.user&&(t=n.session.user,r(n.session.user),e&&e())};n(nr.getState()),t||(e=nr.subscribe(n))}))}function pr(){return new Promise((function(t,e){ir().subscribe((function(e){t(e.sessionLocation)}),e).unsubscribe()}))}function hr(t,e){return dr.apply(this,arguments)}function dr(){return(dr=er((function(t,e){return rr(this,(function(r){return[2,vr(Ve($e,{method:"POST",body:{sessionLocation:t},headers:{"Content-Type":"application/json"},signal:e.signal}))]}))}))).apply(this,arguments)}function yr(t,e,r){return br.apply(this,arguments)}function br(){return(br=er((function(t,e,r){return rr(this,(function(n){switch(n.label){case 0:return r||(r=new AbortController),[4,Ve("".concat(Re,"/user/").concat(t),{method:"POST",body:{userProperties:e},headers:{"Content-Type":"application/json"},signal:r.signal})];case 1:return n.sent(),[2,ar()]}}))}))).apply(this,arguments)}function vr(t){return new Promise((function(e,r){t.then((function(t){var n;"object"==typeof(null==t?void 0:t.data)?(n={loaded:!0,session:t.data},nr.setState(n),e(n)):(n={loaded:!1,session:null},nr.setState(n),r(n))})).catch((function(t){(0,Xe.reportError)("Failed to fetch new session information: ".concat(t));var e={loaded:!1,session:null};nr.setState(e),r(e)}))}))}function mr(){(0,G.defineConfigSchema)("@openmrs/esm-api",{redirectAuthFailure:{enabled:{_type:G.Type.Boolean,_default:!0,_description:"Whether to redirect logged-out users to `redirectAuthFailure.url`"},url:{_type:G.Type.String,_default:"${openmrsSpaBase}/login",_validators:[G.validators.isUrl]},errors:{_type:G.Type.Array,_default:[401],_elements:{_type:G.Type.Number,_validators:[G.validators.inRange(100,600)]},_description:"The HTTP error codes for which users will be redirected"},resolvePromise:{_type:G.Type.Boolean,_default:!1,_description:"Changes how requests that fail authentication are handled. Try messing with this if redirects to the login page aren't working correctly."}}}),ar()}nr.subscribe((function(t){return t.session&&ur(t.session)}));var wr=s(738);function gr(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function Er(t,e,r,n,o,i,s){try{var u=t[i](s),a=u.value}catch(t){return void r(t)}u.done?e(a):Promise.resolve(a).then(n,o)}function Sr(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function s(t){Er(i,n,o,s,u,"next",t)}function u(t){Er(i,n,o,s,u,"throw",t)}s(void 0)}))}}function Or(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i=[],s=!0,u=!1;try{for(r=r.call(t);!(s=(n=r.next()).done)&&(i.push(n.value),!e||i.length!==e);s=!0);}catch(t){u=!0,o=t}finally{try{s||null==r.return||r.return()}finally{if(u)throw o}}return i}}(t,e)||function(t,e){if(t){if("string"==typeof t)return gr(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(r):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?gr(t,e):void 0}}(t,e)||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.")}()}function _r(t,e){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,n=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}}function Pr(t,e){return Tr.apply(this,arguments)}function Tr(){return Tr=Sr((function(t,e){var r,n,o,i,s,u=arguments;return _r(this,(function(a){switch(a.label){case 0:return r=!(u.length>2&&void 0!==u[2])||u[2],t?(n=null,[4,Promise.all([Ve("".concat(Be,"/Patient/").concat(t),e).catch((function(t){return n=t})),r?Ar(t):Promise.resolve(null)])]):[3,2];case 1:if(o=Or.apply(void 0,[a.sent(),2]),i=o[0],s=o[1],i.ok)return[2,i.data];if(s)return[2,s];if(n)throw n;a.label=2;case 2:return[2,null]}}))})),Tr.apply(this,arguments)}function Ar(t){return jr.apply(this,arguments)}function jr(){return(jr=Sr((function(t){var e,r,n;return _r(this,(function(o){switch(o.label){case 0:return[4,(0,wr.getSynchronizationItems)("patient-registration")];case 1:return e=o.sent(),r=e.find((function(e){return e.fhirPatient.id===t})),[2,null!==(n=null==r?void 0:r.fhirPatient)&&void 0!==n?n:null]}}))}))).apply(this,arguments)}var xr=function(){function t(){return Error.call(this),this.message="object unsubscribed",this.name="ObjectUnsubscribedError",this}return t.prototype=Object.create(Error.prototype),t}(),Dr=function(t){function r(e,r){var n=t.call(this)||this;return n.subject=e,n.subscriber=r,n.closed=!1,n}return e(r,t),r.prototype.unsubscribe=function(){if(!this.closed){this.closed=!0;var t=this.subject,e=t.observers;if(this.subject=null,e&&0!==e.length&&!t.isStopped&&!t.closed){var r=e.indexOf(this.subscriber);-1!==r&&e.splice(r,1)}}},r}(h),Nr=function(t){function r(e){var r=t.call(this,e)||this;return r.destination=e,r}return e(r,t),r}(b),Ur=function(t){function r(){var e=t.call(this)||this;return e.observers=[],e.closed=!1,e.isStopped=!1,e.hasError=!1,e.thrownError=null,e}return e(r,t),r.prototype[y]=function(){return new Nr(this)},r.prototype.lift=function(t){var e=new Mr(this,this);return e.operator=t,e},r.prototype.next=function(t){if(this.closed)throw new xr;if(!this.isStopped)for(var e=this.observers,r=e.length,n=e.slice(),o=0;o<r;o++)n[o].next(t)},r.prototype.error=function(t){if(this.closed)throw new xr;this.hasError=!0,this.thrownError=t,this.isStopped=!0;for(var e=this.observers,r=e.length,n=e.slice(),o=0;o<r;o++)n[o].error(t);this.observers.length=0},r.prototype.complete=function(){if(this.closed)throw new xr;this.isStopped=!0;for(var t=this.observers,e=t.length,r=t.slice(),n=0;n<e;n++)r[n].complete();this.observers.length=0},r.prototype.unsubscribe=function(){this.isStopped=!0,this.closed=!0,this.observers=null},r.prototype._trySubscribe=function(e){if(this.closed)throw new xr;return t.prototype._trySubscribe.call(this,e)},r.prototype._subscribe=function(t){if(this.closed)throw new xr;return this.hasError?(t.error(this.thrownError),h.EMPTY):this.isStopped?(t.complete(),h.EMPTY):(this.observers.push(t),new Dr(this,t))},r.prototype.asObservable=function(){var t=new g;return t.source=this,t},r.create=function(t,e){return new Mr(t,e)},r}(g),Mr=function(t){function r(e,r){var n=t.call(this)||this;return n.destination=e,n.source=r,n}return e(r,t),r.prototype.next=function(t){var e=this.destination;e&&e.next&&e.next(t)},r.prototype.error=function(t){var e=this.destination;e&&e.error&&this.destination.error(t)},r.prototype.complete=function(){var t=this.destination;t&&t.complete&&this.destination.complete()},r.prototype._subscribe=function(t){return this.source?this.source.subscribe(t):h.EMPTY},r}(Ur),kr=function(t){function r(e){var r=t.call(this)||this;return r._value=e,r}return e(r,t),Object.defineProperty(r.prototype,"value",{get:function(){return this.getValue()},enumerable:!0,configurable:!0}),r.prototype._subscribe=function(e){var r=t.prototype._subscribe.call(this,e);return r&&!r.closed&&e.next(this._value),r},r.prototype.getValue=function(){if(this.hasError)throw this.thrownError;if(this.closed)throw new xr;return this._value},r.prototype.next=function(e){t.prototype.next.call(this,this._value=e)},r}(Ur),Cr=function(){function t(){return Error.call(this),this.message="argument out of range",this.name="ArgumentOutOfRangeError",this}return t.prototype=Object.create(Error.prototype),t}(),Ir=new g((function(t){return t.complete()}));function Lr(t){return function(e){return 0===t?r?function(t){return new g((function(e){return t.schedule((function(){return e.complete()}))}))}(r):Ir:e.lift(new Rr(t));var r}}var Rr=function(){function t(t){if(this.total=t,this.total<0)throw new Cr}return t.prototype.call=function(t,e){return e.subscribe(new Br(t,this.total))},t}(),Br=function(t){function r(e,r){var n=t.call(this,e)||this;return n.total=r,n.count=0,n}return e(r,t),r.prototype._next=function(t){var e=this.total,r=++this.count;r<=e&&(this.destination.next(t),r===e&&(this.destination.complete(),this.unsubscribe()))},r}(b);function $r(t,e){return function(r){if("function"!=typeof t)throw new TypeError("argument is not a function. Are you looking for `mapTo()`?");return r.lift(new Gr(t,e))}}var Gr=function(){function t(t,e){this.project=t,this.thisArg=e}return t.prototype.call=function(t,e){return e.subscribe(new Vr(t,this.project,this.thisArg))},t}(),Vr=function(t){function r(e,r,n){var o=t.call(this,e)||this;return o.project=r,o.count=0,o.thisArg=n||o,o}return e(r,t),r.prototype._next=function(t){var e;try{e=this.project.call(this.thisArg,t,this.count++)}catch(t){return void this.destination.error(t)}this.destination.next(e)},r}(b),Wr="custom:(uuid,display,voided,indication,startDatetime,stopDatetime,encounters:(uuid,display,encounterDatetime,form:(uuid,name),location:ref,encounterType:ref,encounterProviders:(uuid,display,provider:(uuid,display))),patient:(uuid,display),visitType:(uuid,name,display),attributes:(uuid,display,attributeType:(name,datatypeClassname,uuid),value),location:(uuid,name,display))",Fr=function(){try{return JSON.parse(localStorage.getItem("openmrs:visitStoreState")||"null")}catch(t){return null}}()||{patientUuid:null,manuallySetVisitUuid:null};function Hr(){return(0,W.getGlobalStore)("visit",Fr)}function Jr(t,e){Hr().setState({patientUuid:t,manuallySetVisitUuid:e})}function qr(t,e,r){var n=null!=r?r:Wr;return We("".concat(Re,"/visit?patient=").concat(t,"&v=").concat(n),{signal:e.signal,method:"GET",headers:{"Content-type":"application/json"}}).pipe(Lr(1)).pipe($r((function(t){return t})))}function zr(t,e){return We("".concat(Re,"/visit"),{signal:e.signal,method:"POST",headers:{"Content-type":"application/json"},body:t})}function Yr(t,e,r){return We("".concat(Re,"/visit/").concat(t),{signal:r.signal,method:"POST",headers:{"Content-type":"application/json"},body:e})}Hr().subscribe((function(t){var e;e=t,localStorage.setItem("openmrs:visitStoreState",JSON.stringify(e))}));var Kr,Qr,Xr=new kr(null);function Zr(t){return{uuid:t.uuid,display:t.display,name:t.name}}function tn(){return We("".concat(Re,"/visittype")).pipe($r((function(t){return t.data.results.map(Zr)}))).pipe(Lr(1))}function en(t){return{uuid:t.uuid,display:t.display}}function rn(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return We("".concat(Re,"/location")+(t?"?tag="+t:"")).pipe($r((function(t){return t.data.results.map(en)}))).pipe(Lr(1))}!function(t){t.NEWVISIT="startVisit",t.EDITVISIT="editVisit",t.LOADING="loadingVisit"}(Kr||(Kr={})),function(t){t.NOTSTARTED="notStarted",t.ONGOING="ongoing"}(Qr||(Qr={}));var nn={"webservices.rest":"2.24.0",fhir2:"1.0.0-SNAPSHOT"}})(),u})())}}}));
3
3
  //# sourceMappingURL=openmrs-esm-api.js.map