@openmrs/esm-api 5.0.0 → 5.0.1-pre.815

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,9 +1,17 @@
1
- @openmrs/esm-api:build: cache hit, replaying output 24ac365aed9359db
2
- @openmrs/esm-api:build: asset openmrs-esm-api.js 147 KiB [emitted] [minimized] (name: main) 2 related assets
3
- @openmrs/esm-api:build: orphan modules 892 KiB [orphan] 593 modules
4
- @openmrs/esm-api:build: runtime modules 891 bytes 4 modules
5
- @openmrs/esm-api:build: cacheable modules 291 KiB
6
- @openmrs/esm-api:build:  ./src/index.ts + 93 modules 282 KiB [built] [code generated]
7
- @openmrs/esm-api:build:  ../esm-state/dist/openmrs-esm-state.js 2.56 KiB [built] [code generated]
8
- @openmrs/esm-api:build:  ../esm-error-handling/dist/openmrs-esm-error-handling.js 6.21 KiB [built] [code generated]
9
- @openmrs/esm-api:build: webpack 5.88.0 compiled successfully in 10189 ms
1
+ @openmrs/esm-api:build: cache hit, replaying output 14acdf9bbe0c4388
2
+ @openmrs/esm-api:build: asset openmrs-esm-api.js 26.8 KiB [emitted] [minimized] (name: main) 2 related assets
3
+ @openmrs/esm-api:build: orphan modules 366 KiB [orphan] 226 modules
4
+ @openmrs/esm-api:build: runtime modules 1.81 KiB 6 modules
5
+ @openmrs/esm-api:build: built modules 87.6 KiB [built]
6
+ @openmrs/esm-api:build:  cacheable modules 87.4 KiB
7
+ @openmrs/esm-api:build:  modules by path ../../../node_modules/systemjs-webpack-interop/ 3.27 KiB
8
+ @openmrs/esm-api:build:  ../../../node_modules/systemjs-webpack-interop/auto-public-path/1.js 89 bytes [built] [code generated]
9
+ @openmrs/esm-api:build:  ../../../node_modules/systemjs-webpack-interop/auto-public-path/auto-...(truncated) 846 bytes [built] [code generated]
10
+ @openmrs/esm-api:build:  ../../../node_modules/systemjs-webpack-interop/public-path.js 2.36 KiB [built] [code generated]
11
+ @openmrs/esm-api:build:  ./src/index.ts + 44 modules 77.9 KiB [built] [code generated]
12
+ @openmrs/esm-api:build:  ../esm-state/dist/openmrs-esm-state.js 6.25 KiB [built] [code generated]
13
+ @openmrs/esm-api:build:  modules by path external "@openmrs/ 126 bytes
14
+ @openmrs/esm-api:build:  external "@openmrs/esm-config" 42 bytes [built] [code generated]
15
+ @openmrs/esm-api:build:  external "@openmrs/esm-error-handling" 42 bytes [built] [code generated]
16
+ @openmrs/esm-api:build:  external "@openmrs/esm-offline" 42 bytes [built] [code generated]
17
+ @openmrs/esm-api:build: webpack 5.88.0 compiled successfully in 7124 ms
@@ -1,3 +1,3 @@
1
1
  /*! For license information please see openmrs-esm-api.js.LICENSE.txt */
2
- var _openmrs_esm_api;(()=>{var e={151:()=>{(()=>{var e={758:()=>{(()=>{"use strict";var e={d:(t,n)=>{for(var r in n)e.o(n,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:n[r]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{dispatchActionableNotificationShown:()=>d,dispatchConnectivityChanged:()=>r,dispatchNotificationShown:()=>h,dispatchPrecacheStaticDependencies:()=>a,subscribeActionableNotificationShown:()=>y,subscribeConnectivity:()=>i,subscribeConnectivityChanged:()=>o,subscribeNotificationShown:()=>p,subscribePrecacheStaticDependencies:()=>u,subscribeToastShown:()=>m});const n="openmrs:connectivity-changed";function r(e){window.dispatchEvent(new CustomEvent(n,{detail:{online:e}}))}function o(e){const t=t=>e(t.detail);return window.addEventListener(n,t),()=>window.removeEventListener(n,t)}function i(e){return e({online:navigator.onLine}),o(e)}const s="openmrs:precache-static-dependencies";function a(e={}){window.dispatchEvent(new CustomEvent(s,{detail:e}))}function u(e){const t=t=>e(t.detail);return window.addEventListener(s,t),()=>window.removeEventListener(s,t)}const c="openmrs:notification-shown",l="openmrs:actionable-notification-shown",f="openmrs:toast-shown";function h(e){window.dispatchEvent(new CustomEvent(c,{detail:e}))}function d(e){window.dispatchEvent(new CustomEvent(l,{detail:e}))}function p(e){const t=t=>e(t.detail);return window.addEventListener(c,t),()=>window.removeEventListener(c,t)}function y(e){const t=t=>e(t.detail);return window.addEventListener(l,t),()=>window.removeEventListener(l,t)}function m(e){const t=t=>e(t.detail);return window.addEventListener(f,t),()=>window.removeEventListener(f,t)}})()}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var i=t[r]={exports:{}};return e[r](i,i.exports,n),i.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};(()=>{"use strict";n.r(r),n.d(r,{createErrorHandler:()=>o,reportError:()=>t});var e=n(758);function t(e){const t=i(e);setTimeout((()=>{throw t}))}function o(){const e=Error();return n=>{i(n).stack+=`\nAsync stacktrace:\n${e.stack}`,t(n)}}function i(e){let t;if(e instanceof Error)return e;if(null===e)return Error("'null' was thrown as an error");if("object"==typeof e){try{t=`Object thrown as error: ${JSON.stringify(e)}`}catch(n){t=`Object thrown as error with the following properties: ${Object.keys(e)}`}return Error(t)}return void 0===e?Error("'undefined' was thrown as an error"):Error(e.toString())}window.onerror=function(t){return console.error("Unexpected error: ",t),(0,e.dispatchNotificationShown)({description:null!=t?t:"Oops! An unexpected error occurred.",kind:"error",title:"Error"}),!1},window.onunhandledrejection=function(t){var n;console.error("Unhandled rejection: ",t.reason),(0,e.dispatchNotificationShown)({description:null!==(n=t.reason)&&void 0!==n?n:"Oops! An unhandled promise rejection occurred.",kind:"error",title:"Error"})}})()})()},403:()=>{(()=>{"use strict";var e={d:(t,n)=>{for(var r in n)e.o(n,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:n[r]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{createAppState:()=>a,createGlobalStore:()=>i,getAppState:()=>u,getGlobalStore:()=>s,subscribeTo:()=>c});const n=e=>{let t;const n=new Set,r=(e,r)=>{const o="function"==typeof e?e(t):e;if(!Object.is(o,t)){const e=t;t=(null!=r?r:"object"!=typeof o)?o:Object.assign({},t,o),n.forEach((n=>n(t,e)))}},o=()=>t,i={setState:r,getState:o,subscribe:e=>(n.add(e),()=>n.delete(e)),destroy:()=>{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()}};return t=e(r,o,i),i},r=e=>e?n(e):n,o={};function i(e,t){const n=o[e];if(n)return n.active?console.error("Cannot override an existing store. Make sure that stores are only created once."):n.value.setState(t,!0),n.active=!0,n.value;{const n=r()((()=>t));return o[e]={value:n,active:!0},n}}function s(e,t){const n=o[e];if(!n){const n=r()((()=>null!=t?t:{}));return o[e]={value:n,active:!1},n}return n.value}function a(e){return i("app",e)}function u(){return s("app",{})}function c(e,t,n){let r=t(e.getState());return e.subscribe((e=>{const o=t(e);o!==r&&(r=o,n(o))}))}})()}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var i=t[r]={exports:{}};return e[r](i,i.exports,n),i.exports}n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};(()=>{"use strict";n.r(r),n.d(r,{OpenmrsFetchError:()=>lr,VisitMode:()=>iu,VisitStatus:()=>su,backendDependencies:()=>fu,clearCurrentUser:()=>gr,defaultVisitCustomRepresentation:()=>eu,fetchCurrentPatient:()=>Ba,fhirBaseUrl:()=>ir,getCurrentUser:()=>mr,getLocations:()=>lu,getLoggedInUser:()=>_r,getSessionLocation:()=>Er,getSessionStore:()=>vr,getStartedVisit:()=>ou,getVisitTypes:()=>uu,getVisitsForPatient:()=>tu,makeUrl:()=>ar,openmrsFetch:()=>ur,openmrsObservableFetch:()=>cr,refetchCurrentUser:()=>br,restBaseUrl:()=>or,saveVisit:()=>nu,sessionEndpoint:()=>sr,setSessionLocation:()=>Or,setupApiModule:()=>Pr,toLocationObject:()=>cu,toVisitTypeObject:()=>au,updateVisit:()=>ru,userHasAccess:()=>wr});var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},e(t,n)};function t(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}function o(e){return"function"==typeof e}var i=!1,s={Promise:void 0,set useDeprecatedSynchronousErrorHandling(e){e&&(new Error).stack,i=e},get useDeprecatedSynchronousErrorHandling(){return i}};function a(e){setTimeout((function(){throw e}),0)}var u={closed:!0,next:function(e){},error:function(e){if(s.useDeprecatedSynchronousErrorHandling)throw e;a(e)},complete:function(){}},c=function(){return Array.isArray||function(e){return e&&"number"==typeof e.length}}();function l(e){return null!==e&&"object"==typeof e}var f=function(){function e(e){return Error.call(this),this.message=e?e.length+" errors occurred during unsubscription:\n"+e.map((function(e,t){return t+1+") "+e.toString()})).join("\n "):"",this.name="UnsubscriptionError",this.errors=e,this}return e.prototype=Object.create(Error.prototype),e}(),h=f,d=function(){function e(e){this.closed=!1,this._parentOrParents=null,this._subscriptions=null,e&&(this._ctorUnsubscribe=!0,this._unsubscribe=e)}return e.prototype.unsubscribe=function(){var t;if(!this.closed){var n=this,r=n._parentOrParents,i=n._ctorUnsubscribe,s=n._unsubscribe,a=n._subscriptions;if(this.closed=!0,this._parentOrParents=null,this._subscriptions=null,r instanceof e)r.remove(this);else if(null!==r)for(var u=0;u<r.length;++u)r[u].remove(this);if(o(s)){i&&(this._unsubscribe=void 0);try{s.call(this)}catch(e){t=e instanceof h?p(e.errors):[e]}}if(c(a)){u=-1;for(var f=a.length;++u<f;){var d=a[u];if(l(d))try{d.unsubscribe()}catch(e){t=t||[],e instanceof h?t=t.concat(p(e.errors)):t.push(e)}}}if(t)throw new h(t)}},e.prototype.add=function(t){var n=t;if(!t)return e.EMPTY;switch(typeof t){case"function":n=new e(t);case"object":if(n===this||n.closed||"function"!=typeof n.unsubscribe)return n;if(this.closed)return n.unsubscribe(),n;if(!(n instanceof e)){var r=n;(n=new e)._subscriptions=[r]}break;default:throw new Error("unrecognized teardown "+t+" added to Subscription.")}var o=n._parentOrParents;if(null===o)n._parentOrParents=this;else if(o instanceof e){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},e.prototype.remove=function(e){var t=this._subscriptions;if(t){var n=t.indexOf(e);-1!==n&&t.splice(n,1)}},e.EMPTY=function(e){return e.closed=!0,e}(new e),e}();function p(e){return e.reduce((function(e,t){return e.concat(t instanceof h?t.errors:t)}),[])}var y=function(){return"function"==typeof Symbol?Symbol("rxSubscriber"):"@@rxSubscriber_"+Math.random()}(),m=function(e){function n(t,r,o){var i=e.call(this)||this;switch(i.syncErrorValue=null,i.syncErrorThrown=!1,i.syncErrorThrowable=!1,i.isStopped=!1,arguments.length){case 0:i.destination=u;break;case 1:if(!t){i.destination=u;break}if("object"==typeof t){t instanceof n?(i.syncErrorThrowable=t.syncErrorThrowable,i.destination=t,t.add(i)):(i.syncErrorThrowable=!0,i.destination=new v(i,t));break}default:i.syncErrorThrowable=!0,i.destination=new v(i,t,r,o)}return i}return t(n,e),n.prototype[y]=function(){return this},n.create=function(e,t,r){var o=new n(e,t,r);return o.syncErrorThrowable=!1,o},n.prototype.next=function(e){this.isStopped||this._next(e)},n.prototype.error=function(e){this.isStopped||(this.isStopped=!0,this._error(e))},n.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},n.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this))},n.prototype._next=function(e){this.destination.next(e)},n.prototype._error=function(e){this.destination.error(e),this.unsubscribe()},n.prototype._complete=function(){this.destination.complete(),this.unsubscribe()},n.prototype._unsubscribeAndRecycle=function(){var e=this._parentOrParents;return this._parentOrParents=null,this.unsubscribe(),this.closed=!1,this.isStopped=!1,this._parentOrParents=e,this},n}(d),v=function(e){function n(t,n,r,i){var s,a=e.call(this)||this;a._parentSubscriber=t;var c=a;return o(n)?s=n:n&&(s=n.next,r=n.error,i=n.complete,n!==u&&(o((c=Object.create(n)).unsubscribe)&&a.add(c.unsubscribe.bind(c)),c.unsubscribe=a.unsubscribe.bind(a))),a._context=c,a._next=s,a._error=r,a._complete=i,a}return t(n,e),n.prototype.next=function(e){if(!this.isStopped&&this._next){var t=this._parentSubscriber;s.useDeprecatedSynchronousErrorHandling&&t.syncErrorThrowable?this.__tryOrSetError(t,this._next,e)&&this.unsubscribe():this.__tryOrUnsub(this._next,e)}},n.prototype.error=function(e){if(!this.isStopped){var t=this._parentSubscriber,n=s.useDeprecatedSynchronousErrorHandling;if(this._error)n&&t.syncErrorThrowable?(this.__tryOrSetError(t,this._error,e),this.unsubscribe()):(this.__tryOrUnsub(this._error,e),this.unsubscribe());else if(t.syncErrorThrowable)n?(t.syncErrorValue=e,t.syncErrorThrown=!0):a(e),this.unsubscribe();else{if(this.unsubscribe(),n)throw e;a(e)}}},n.prototype.complete=function(){var e=this;if(!this.isStopped){var t=this._parentSubscriber;if(this._complete){var n=function(){return e._complete.call(e._context)};s.useDeprecatedSynchronousErrorHandling&&t.syncErrorThrowable?(this.__tryOrSetError(t,n),this.unsubscribe()):(this.__tryOrUnsub(n),this.unsubscribe())}else this.unsubscribe()}},n.prototype.__tryOrUnsub=function(e,t){try{e.call(this._context,t)}catch(e){if(this.unsubscribe(),s.useDeprecatedSynchronousErrorHandling)throw e;a(e)}},n.prototype.__tryOrSetError=function(e,t,n){if(!s.useDeprecatedSynchronousErrorHandling)throw new Error("bad call");try{t.call(this._context,n)}catch(t){return s.useDeprecatedSynchronousErrorHandling?(e.syncErrorValue=t,e.syncErrorThrown=!0,!0):(a(t),!0)}return!1},n.prototype._unsubscribe=function(){var e=this._parentSubscriber;this._context=null,this._parentSubscriber=null,e.unsubscribe()},n}(m),b=function(){return"function"==typeof Symbol&&Symbol.observable||"@@observable"}();function g(e){return e}var w=function(){function e(e){this._isScalar=!1,e&&(this._subscribe=e)}return e.prototype.lift=function(t){var n=new e;return n.source=this,n.operator=t,n},e.prototype.subscribe=function(e,t,n){var r=this.operator,o=function(e,t,n){if(e){if(e instanceof m)return e;if(e[y])return e[y]()}return e||t||n?new m(e,t,n):new m(u)}(e,t,n);if(r?o.add(r.call(o,this.source)):o.add(this.source||s.useDeprecatedSynchronousErrorHandling&&!o.syncErrorThrowable?this._subscribe(o):this._trySubscribe(o)),s.useDeprecatedSynchronousErrorHandling&&o.syncErrorThrowable&&(o.syncErrorThrowable=!1,o.syncErrorThrown))throw o.syncErrorValue;return o},e.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(t){s.useDeprecatedSynchronousErrorHandling&&(e.syncErrorThrown=!0,e.syncErrorValue=t),function(e){for(;e;){var t=e,n=t.closed,r=t.destination,o=t.isStopped;if(n||o)return!1;e=r&&r instanceof m?r:null}return!0}(e)?e.error(t):console.warn(t)}},e.prototype.forEach=function(e,t){var n=this;return new(t=E(t))((function(t,r){var o;o=n.subscribe((function(t){try{e(t)}catch(e){r(e),o&&o.unsubscribe()}}),r,t)}))},e.prototype._subscribe=function(e){var t=this.source;return t&&t.subscribe(e)},e.prototype[b]=function(){return this},e.prototype.pipe=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return 0===e.length?this:(0===(n=e).length?g:1===n.length?n[0]:function(e){return n.reduce((function(e,t){return t(e)}),e)})(this);var n},e.prototype.toPromise=function(e){var t=this;return new(e=E(e))((function(e,n){var r;t.subscribe((function(e){return r=e}),(function(e){return n(e)}),(function(){return e(r)}))}))},e.create=function(t){return new e(t)},e}();function E(e){if(e||(e=s.Promise||Promise),!e)throw new Error("no Promise impl found");return e}const O="object"==typeof global&&global&&global.Object===Object&&global;var S="object"==typeof self&&self&&self.Object===Object&&self;const P=(O||S||Function("return this")()).Symbol;var x=Object.prototype,j=x.hasOwnProperty,k=x.toString,A=P?P.toStringTag:void 0;var T=Object.prototype.toString;var D=P?P.toStringTag:void 0;const C=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":D&&D in Object(e)?function(e){var t=j.call(e,A),n=e[A];try{e[A]=void 0;var r=!0}catch(e){}var o=k.call(e);return r&&(t?e[A]=n:delete e[A]),o}(e):function(e){return T.call(e)}(e)},I=(K=Object.getPrototypeOf,N=Object,function(e){return K(N(e))});var K,N;var B=Function.prototype,R=Object.prototype,M=B.toString,$=R.hasOwnProperty,U=M.call(Object);const F=function(e){if(!function(e){return null!=e&&"object"==typeof e}(e)||"[object Object]"!=C(e))return!1;var t=I(e);if(null===t)return!0;var n=$.call(t,"constructor")&&t.constructor;return"function"==typeof n&&n instanceof n&&M.call(n)==U};function L(e){return null!=e&&"object"==typeof e&&!0===e["@@functional/placeholder"]}function q(e){return function t(n){return 0===arguments.length||L(n)?t:e.apply(this,arguments)}}function W(e){return function t(n,r){switch(arguments.length){case 0:return t;case 1:return L(n)?t:q((function(t){return e(n,t)}));default:return L(n)&&L(r)?t:L(n)?q((function(t){return e(t,r)})):L(r)?q((function(t){return e(n,t)})):e(n,r)}}}function V(e){for(var t,n=[];!(t=e.next()).done;)n.push(t.value);return n}function G(e,t,n){for(var r=0,o=n.length;r<o;){if(e(t,n[r]))return!0;r+=1}return!1}function H(e,t){return Object.prototype.hasOwnProperty.call(t,e)}const z="function"==typeof Object.is?Object.is:function(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t};var Y=Object.prototype.toString,Q=function(){return"[object Arguments]"===Y.call(arguments)?function(e){return"[object Arguments]"===Y.call(e)}:function(e){return H("callee",e)}}();const J=Q;var X=!{toString:null}.propertyIsEnumerable("toString"),Z=["constructor","valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"],ee=function(){return arguments.propertyIsEnumerable("length")}(),te=function(e,t){for(var n=0;n<e.length;){if(e[n]===t)return!0;n+=1}return!1};const ne="function"!=typeof Object.keys||ee?q((function(e){if(Object(e)!==e)return[];var t,n,r=[],o=ee&&J(e);for(t in e)!H(t,e)||o&&"length"===t||(r[r.length]=t);if(X)for(n=Z.length-1;n>=0;)H(t=Z[n],e)&&!te(r,t)&&(r[r.length]=t),n-=1;return r})):q((function(e){return Object(e)!==e?[]:Object.keys(e)})),re=q((function(e){return null===e?"Null":void 0===e?"Undefined":Object.prototype.toString.call(e).slice(8,-1)}));function oe(e,t,n,r){var o=V(e);function i(e,t){return ie(e,t,n.slice(),r.slice())}return!G((function(e,t){return!G(i,t,e)}),V(t),o)}function ie(e,t,n,r){if(z(e,t))return!0;var o=re(e);if(o!==re(t))return!1;if(null==e||null==t)return!1;if("function"==typeof e["fantasy-land/equals"]||"function"==typeof t["fantasy-land/equals"])return"function"==typeof e["fantasy-land/equals"]&&e["fantasy-land/equals"](t)&&"function"==typeof t["fantasy-land/equals"]&&t["fantasy-land/equals"](e);if("function"==typeof e.equals||"function"==typeof t.equals)return"function"==typeof e.equals&&e.equals(t)&&"function"==typeof t.equals&&t.equals(e);switch(o){case"Arguments":case"Array":case"Object":if("function"==typeof e.constructor&&"Promise"===function(e){var t=String(e).match(/^function (\w*)/);return null==t?"":t[1]}(e.constructor))return e===t;break;case"Boolean":case"Number":case"String":if(typeof e!=typeof t||!z(e.valueOf(),t.valueOf()))return!1;break;case"Date":if(!z(e.valueOf(),t.valueOf()))return!1;break;case"Error":return e.name===t.name&&e.message===t.message;case"RegExp":if(e.source!==t.source||e.global!==t.global||e.ignoreCase!==t.ignoreCase||e.multiline!==t.multiline||e.sticky!==t.sticky||e.unicode!==t.unicode)return!1}for(var i=n.length-1;i>=0;){if(n[i]===e)return r[i]===t;i-=1}switch(o){case"Map":return e.size===t.size&&oe(e.entries(),t.entries(),n.concat([e]),r.concat([t]));case"Set":return e.size===t.size&&oe(e.values(),t.values(),n.concat([e]),r.concat([t]));case"Arguments":case"Array":case"Object":case"Boolean":case"Number":case"String":case"Date":case"Error":case"RegExp":case"Int8Array":case"Uint8Array":case"Uint8ClampedArray":case"Int16Array":case"Uint16Array":case"Int32Array":case"Uint32Array":case"Float32Array":case"Float64Array":case"ArrayBuffer":break;default:return!1}var s=ne(e);if(s.length!==ne(t).length)return!1;var a=n.concat([e]),u=r.concat([t]);for(i=s.length-1;i>=0;){var c=s[i];if(!H(c,t)||!ie(t[c],e[c],a,u))return!1;i-=1}return!0}var se=W((function(e,t){return ie(e,t,[],[])}));const ae=se;function ue(e){return function t(n,r,o){switch(arguments.length){case 0:return t;case 1:return L(n)?t:W((function(t,r){return e(n,t,r)}));case 2:return L(n)&&L(r)?t:L(n)?W((function(t,n){return e(t,r,n)})):L(r)?W((function(t,r){return e(n,t,r)})):q((function(t){return e(n,r,t)}));default:return L(n)&&L(r)&&L(o)?t:L(n)&&L(r)?W((function(t,n){return e(t,n,o)})):L(n)&&L(o)?W((function(t,n){return e(t,r,n)})):L(r)&&L(o)?W((function(t,r){return e(n,t,r)})):L(n)?q((function(t){return e(t,r,o)})):L(r)?q((function(t){return e(n,t,o)})):L(o)?q((function(t){return e(n,r,t)})):e(n,r,o)}}}function ce(e){return"[object Object]"===Object.prototype.toString.call(e)}var le=ue((function(e,t,n){var r,o={};for(r in t)H(r,t)&&(o[r]=H(r,n)?e(r,t[r],n[r]):t[r]);for(r in n)H(r,n)&&!H(r,o)&&(o[r]=n[r]);return o}));const fe=le;var he=ue((function e(t,n,r){return fe((function(n,r,o){return ce(r)&&ce(o)?e(t,r,o):t(n,r,o)}),n,r)}));const de=he,pe=W((function(e,t){return de((function(e,t,n){return n}),e,t)})),ye=W((function(e,t){for(var n={},r={},o=0,i=e.length;o<i;)r[e[o]]=1,o+=1;for(var s in t)r.hasOwnProperty(s)||(n[s]=t[s]);return n}));function me(e,t,n,r){var o,i=function(o){for(var i=t.length,s=0;s<i;){if(e===t[s])return n[s];s+=1}for(var a in t[s+1]=e,n[s+1]=o,e)o[a]=r?me(e[a],t,n,!0):e[a];return o};switch(re(e)){case"Object":return i({});case"Array":return i([]);case"Date":return new Date(e.valueOf());case"RegExp":return o=e,new RegExp(o.source,(o.global?"g":"")+(o.ignoreCase?"i":"")+(o.multiline?"m":"")+(o.sticky?"y":"")+(o.unicode?"u":""));default:return e}}const ve=q((function(e){return null!=e&&"function"==typeof e.clone?e.clone():me(e,[],[],!0)})),be=Array.isArray||function(e){return null!=e&&e.length>=0&&"[object Array]"===Object.prototype.toString.call(e)};var ge=q((function(e){return!!be(e)||!!e&&"object"==typeof e&&!function(e){return"[object String]"===Object.prototype.toString.call(e)}(e)&&(1===e.nodeType?!!e.length:0===e.length||e.length>0&&e.hasOwnProperty(0)&&e.hasOwnProperty(e.length-1))}));const we=ge;var _e=function(){function e(e){this.f=e}return e.prototype["@@transducer/init"]=function(){throw new Error("init not implemented on XWrap")},e.prototype["@@transducer/result"]=function(e){return e},e.prototype["@@transducer/step"]=function(e,t){return this.f(e,t)},e}(),Ee=W((function(e,t){return function(e,t){switch(e){case 0:return function(){return t.apply(this,arguments)};case 1:return function(e){return t.apply(this,arguments)};case 2:return function(e,n){return t.apply(this,arguments)};case 3:return function(e,n,r){return t.apply(this,arguments)};case 4:return function(e,n,r,o){return t.apply(this,arguments)};case 5:return function(e,n,r,o,i){return t.apply(this,arguments)};case 6:return function(e,n,r,o,i,s){return t.apply(this,arguments)};case 7:return function(e,n,r,o,i,s,a){return t.apply(this,arguments)};case 8:return function(e,n,r,o,i,s,a,u){return t.apply(this,arguments)};case 9:return function(e,n,r,o,i,s,a,u,c){return t.apply(this,arguments)};case 10:return function(e,n,r,o,i,s,a,u,c,l){return t.apply(this,arguments)};default:throw new Error("First argument to _arity must be a non-negative integer no greater than ten")}}(e.length,(function(){return e.apply(t,arguments)}))}));const Oe=Ee;function Se(e,t,n){for(var r=n.next();!r.done;){if((t=e["@@transducer/step"](t,r.value))&&t["@@transducer/reduced"]){t=t["@@transducer/value"];break}r=n.next()}return e["@@transducer/result"](t)}function Pe(e,t,n,r){return e["@@transducer/result"](n[r](Oe(e["@@transducer/step"],e),t))}var xe="undefined"!=typeof Symbol?Symbol.iterator:"@@iterator";function je(e,t,n){if("function"==typeof e&&(e=function(e){return new _e(e)}(e)),we(n))return function(e,t,n){for(var r=0,o=n.length;r<o;){if((t=e["@@transducer/step"](t,n[r]))&&t["@@transducer/reduced"]){t=t["@@transducer/value"];break}r+=1}return e["@@transducer/result"](t)}(e,t,n);if("function"==typeof n["fantasy-land/reduce"])return Pe(e,t,n,"fantasy-land/reduce");if(null!=n[xe])return Se(e,t,n[xe]());if("function"==typeof n.next)return Se(e,t,n);if("function"==typeof n.reduce)return Pe(e,t,n,"reduce");throw new TypeError("reduce: list must be array or iterable")}const ke=ue(je);var Ae;function Te(e,t){return n=>{if(!e(n))return"function"==typeof t?t(n):t}}!function(e){e.Array="Array",e.Boolean="Boolean",e.ConceptUuid="ConceptUuid",e.Number="Number",e.Object="Object",e.String="String",e.UUID="UUID",e.PersonAttributeTypeUuid="PersonAttributeTypeUuid",e.PatientIdentifierTypeUuid="PatientIdentifierTypeUuid"}(Ae||(Ae={}));const De=Te((e=>Array.isArray(e)),"must be an array"),Ce=Te((e=>"boolean"==typeof e),"must be a boolean"),Ie=Te((e=>"number"==typeof e),"must be a number"),Ke=Te((e=>"string"==typeof e),"must be a string"),Ne=Te((e=>"object"==typeof e&&!Array.isArray(e)&&null!==e),"must be an object (not an array or null)"),Be=Te((e=>/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e)||/^[0-9a-f]{36}$/i.test(e)),"must be a valid UUID or a 36-character hexadecimal string");var Re=n(403);const Me=(0,Re.createGlobalStore)("config-internal",{providedConfigs:[],schemas:{}}),$e=(0,Re.createGlobalStore)("temporary-config",{config:function(){try{return JSON.parse(localStorage.getItem("openmrs:temporaryConfig")||"{}")}catch(e){return{}}}()});$e.subscribe((e=>{var t;t=e.config,localStorage.setItem("openmrs:temporaryConfig",JSON.stringify(t))}));const Ue=(0,Re.createGlobalStore)("config-store-of-extension-state",{mountedExtensions:[]});function Fe(e){return(0,Re.getGlobalStore)(`config-module-${e}`,{config:null,loaded:!1})}const Le=(0,Re.createGlobalStore)("config-implementer-tools",{config:{}});function qe(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function We(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter((function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})))),r.forEach((function(t){qe(e,t,n[t])}))}return e}function Ve(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n}(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})),e}function Ge(e,t){for(let n of Object.keys(e.schemas)){const r=nt(n,e,t);Fe(n).setState({loaded:!0,config:r})}}function He(e,t){const n=function(e,t){const n=ot(et(e,t)),r=Object.keys(n).reduce(((e,t)=>{var r,o;return(null===(r=n[t])||void 0===r?void 0:r.extensionSlots)&&(e[t]=null===(o=n[t])||void 0===o?void 0:o.extensionSlots),e}),{});!function(e){for(let[t,n]of Object.entries(e))for(let[e,r]of Object.entries(n))Ze(r,t,e)}(r);return Object.keys(r).reduce(((e,t)=>We({},e,r[t])),{})}(e,t),r=Object.fromEntries(Object.entries(n).map((([e,t])=>[e,{loaded:!0,config:t}]))),o=(0,Re.getGlobalStore)("config-extension-slots",{slots:{}}),i=o.getState(),s={slots:We({},i.slots,r)};ae(i,s)||o.setState(s)}function ze(e,t){const n=function(e,t){let n=Je(ve(e.schemas));const r=[...e.providedConfigs.map((e=>[e.config,e.source])),[t.config,"temporary config"]];for(let[e,t]of r)n=ot([n,Xe(e,t)]);return n}(e,t);Le.setState({config:n})}function Ye(e,t,n){const r={};for(let o of t.mountedExtensions){const t=Qe(o.slotModuleName,o.extensionModuleName,o.slotName,o.extensionId,e,n);r[o.slotName]=Ve(We({},r[o.slotName]),{[o.extensionId]:{config:t,loaded:!0}})}(0,Re.getGlobalStore)("config-extensions",{configs:{}}).setState({configs:r})}function Qe(e,t,n,r,o,i){var s,a,u;const c=function(e){const[t]=e.split("#");return t}(r),l=o.schemas[c],f=l?c:t,h=et(o,i),d=rt(e,h);var p;const y=null!==(p=null==d||null===(s=d.extensionSlots)||void 0===s||null===(a=s[n])||void 0===a||null===(u=a.configure)||void 0===u?void 0:u[r])&&void 0!==p?p:{},m=ot([rt(f,h),y]),v=null!=l?l:o.schemas[t];it(v,m,f);const b=lt(v,m);return at(v,b,f),delete b.extensionSlots,b}function Je(e){return e.hasOwnProperty("_default")?Ve(We({},e),{_value:e._default,_source:"default"}):ht(e)?Object.keys(e).reduce(((t,n)=>(t[n]=Je(e[n]),t)),{}):{}}function Xe(e,t){return ht(e)?Object.keys(e).reduce(((n,r)=>(n[r]=Xe(e[r],t),n)),{}):{_value:e,_source:t}}function Ze(e,t,n){const r=`Extension slot config '${t}.extensionSlots.${n}`,o=Object.keys(e).filter((e=>!["add","remove","order","configure"].includes(e)));o.length&&console.error(r+`' contains invalid keys '${o.join("', '")}'`),e.add&&(Array.isArray(e.add)&&e.add.every((e=>"string"==typeof e))||console.error(r+".add' is invalid. Must be an array of strings (extension IDs)")),e.remove&&(Array.isArray(e.remove)&&e.remove.every((e=>"string"==typeof e))||console.error(r+".remove' is invalid. Must be an array of strings (extension IDs)")),e.order&&(Array.isArray(e.order)&&e.order.every((e=>"string"==typeof e))||console.error(r+".order' is invalid. Must be an array of strings (extension IDs)")),e.configure&&(ht(e.configure)||console.error(r+".configure' is invalid. Must be an object with extension IDs for keys"))}function et(e,t){return[...e.providedConfigs.map((e=>e.config)),t.config]}function tt(e,t,n=""){const r="Please verify that you are running the latest version and, if so, alert the maintainer.";for(const o of Object.keys(t).filter((e=>!e.startsWith("_")))){const i=n+(n&&".")+o,s=t[o];if("Display conditions"===i&&console.error(`${e} declares a configuration option called "Display conditions"; the "Display conditions" option is a reserved name. ${r}`),"Translation overrides"===i&&console.error(`${e} declares a configuration option called "Translation overrides"; the "Translation overrides" option is a reserved name. ${r}`),!ht(s)){console.error(`${e} has bad config schema definition for key '${i}'. ${r}`);continue}s.hasOwnProperty("_default")||tt(e,s,i);const a=s._elements;if(ft(a)&&tt(e,a,i+"._elements"),s._validators)for(let t of s._validators)"function"!=typeof t&&console.error(`${e} has invalid validator for key '${i}' ${r}.\n\nIf you're the maintainer: validators must be functions that return either undefined or an error string. Received ${t}.`);const u=s._type;u&&!Object.values(Ae).includes(u)&&console.error(`${e} has invalid type for key '${i}' ${r}.\n\nIf you're the maintainer: the allowed types are ${Object.values(Ae).join(", ")}. Received '${u}'`),Object.keys(s).every((e=>["_description","_validators","_elements","_type"].includes(e)))&&!n.includes("._elements")&&console.error(`${e} has bad config schema definition for key '${i}'. ${r}.\n\nIf you're the maintainer: all config elements must have a default. Received ${JSON.stringify(s)}`),a&&u&&![Ae.Array,Ae.Object].includes(u)&&console.error(`${e} has bad config schema definition for key '${i}'. ${r}.\n\nIf you're the maintainer: the 'elements' key only works with '_type' equal to 'Array' or 'Object'. Received ${JSON.stringify(u)}`)}}function nt(e,t,n){if(!t.schemas.hasOwnProperty(e))throw Error("No config schema has been defined for "+e);const r=t.schemas[e],o=rt(e,et(t,n));it(r,o,e);const i=lt(r,o);return at(r,i,e),delete i.extensionSlots,i}function rt(e,t){const n=t.map((({[e]:t})=>t)).filter((e=>!!e));return ot(n)}function ot(e){return ke(pe)({},e)}function it(e,t,n=""){for(const r of Object.keys(t)){const o=t[r],i=n+"."+r,s=e[r];e.hasOwnProperty(r)?st(s,o,i):"extensionSlots"===r&&""!==n||console.error(`Unknown config key '${i}' provided. Ignoring.`)}}function st(e,t,n){ut(n,e._type,t),ht(t)?e._type===Ae.Object?function(e,t,n){if(e._elements)for(const r of Object.keys(t)){const o=t[r];it(e._elements,o,`${n}.${r}`)}}(e,t,n):e.hasOwnProperty("_default")||it(e,t,n):e._type===Ae.Array&&function(e,t,n){if(ft(e._elements))for(let r=0;r<t.length;r++)st(e._elements,t[r],`${n}[${r}]`);for(let o=0;o<t.length;o++){var r;ut(`${n}[${o}]`,null===(r=e._elements)||void 0===r?void 0:r._type,t[o])}}(e,t,n)}function at(e,t,n=""){if(e)if(t!==e._default&&ct(n,e._validators,t),ht(t))for(const r of Object.keys(t)){const o=t[r],i=n+"."+r,s=e[r];e._type===Ae.Object&&e._elements?at(e._elements,o,i):at(s,o,i)}else if(Array.isArray(t)&&e._elements)for(let r=0;r<t.length;r++)at(e._elements,t[r],`${n}[${r}]`)}function ut(e,t,n){t&&ct(e,[{Array:De,Boolean:Ce,ConceptUuid:Be,Number:Ie,Object:Ne,String:Ke,UUID:Be,PersonAttributeTypeUuid:Be,PatientIdentifierTypeUuid:Be}[t]],n)}function ct(e,t,n){if(t)try{for(let r of t){const t=r(n);"string"==typeof t&&("object"==typeof n?console.error(`Invalid configuration for ${e}: ${t}`):console.error(`Invalid configuration value ${n} for ${e}: ${t}`))}}catch(t){console.error(`Skipping invalid validator at "${e}". Encountered error\n\t${t}`)}}Ge(Me.getState(),$e.getState()),Me.subscribe((e=>Ge(e,$e.getState()))),$e.subscribe((e=>Ge(Me.getState(),e))),ze(Me.getState(),$e.getState()),Me.subscribe((e=>ze(e,$e.getState()))),$e.subscribe((e=>ze(Me.getState(),e))),He(Me.getState(),$e.getState()),Me.subscribe((e=>He(e,$e.getState()))),$e.subscribe((e=>He(Me.getState(),e))),Ye(Me.getState(),Ue.getState(),$e.getState()),Me.subscribe((e=>{Ye(e,Ue.getState(),$e.getState())})),Ue.subscribe((e=>{Ye(Me.getState(),e,$e.getState())})),$e.subscribe((e=>{Ye(Me.getState(),Ue.getState(),e)}));const lt=(e,t)=>{const n=ve(t);if(!e)return n;for(const t of Object.keys(e)){const r=n[t],o=e[t];if(o&&o.hasOwnProperty("_default")){n.hasOwnProperty(t)||(n[t]=o._default);const e=o._elements;if(r&&ft(e))if(o._type===Ae.Array&&Array.isArray(r)){const o=r.map((t=>lt(e,t)));n[t]=o}else if(o._type===Ae.Object)for(let t of Object.keys(r))r[t]=lt(e,r[t])}else if(ht(o)){const e=n.hasOwnProperty(t)?r:{};ht(e)&&(n[t]=lt(o,e))}}return n};function ft(e){return!!e&&Object.keys(e).filter((e=>!["_default","_validators"].includes(e))).length>0}function ht(e){return"object"==typeof e&&!Array.isArray(e)&&null!==e}const dt={"Display conditions":{privileges:{_description:"The privilege(s) the user must have to use this extension",_type:Ae.Array,_default:[]}},"Translation overrides":{_description:"Per-language overrides for frontend translations should be keyed by language code and each language dictionary contains the translation key and the display value",_type:Ae.Object,_default:{}}};var pt=Object.freeze({__proto__:null,get start(){return Qn},get ensureJQuerySupport(){return Sn},get setBootstrapMaxTime(){return on},get setMountMaxTime(){return sn},get setUnmountMaxTime(){return an},get setUnloadMaxTime(){return un},get registerApplication(){return Bn},get unregisterApplication(){return Mn},get getMountedApps(){return In},get getAppStatus(){return Nn},get unloadApplication(){return $n},get checkActivityFunctions(){return Rn},get getAppNames(){return Kn},get pathToActiveWhen(){return Ln},get navigateToUrl(){return mn},get triggerAppChange(){return Gn},get addErrorHandler(){return _t},get removeErrorHandler(){return Et},get mountRootParcel(){return Zt},get NOT_LOADED(){return Pt},get LOADING_SOURCE_CODE(){return xt},get NOT_BOOTSTRAPPED(){return jt},get BOOTSTRAPPING(){return kt},get NOT_MOUNTED(){return At},get MOUNTING(){return Tt},get UPDATING(){return Ct},get LOAD_ERROR(){return Kt},get MOUNTED(){return Dt},get UNMOUNTING(){return It},get SKIP_BECAUSE_BROKEN(){return Nt}});function yt(e){return(yt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function mt(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var vt=("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:void 0!==n.g?n.g:"undefined"!=typeof self?self:{}).CustomEvent,bt=function(){try{var e=new vt("cat",{detail:{foo:"bar"}});return"cat"===e.type&&"bar"===e.detail.foo}catch(e){}return!1}()?vt:"undefined"!=typeof document&&"function"==typeof document.createEvent?function(e,t){var n=document.createEvent("CustomEvent");return t?n.initCustomEvent(e,t.bubbles,t.cancelable,t.detail):n.initCustomEvent(e,!1,!1,void 0),n}:function(e,t){var n=document.createEventObject();return n.type=e,t?(n.bubbles=Boolean(t.bubbles),n.cancelable=Boolean(t.cancelable),n.detail=t.detail):(n.bubbles=!1,n.cancelable=!1,n.detail=void 0),n},gt=[];function wt(e,t,n){var r=St(e,t,n);gt.length?gt.forEach((function(e){return e(r)})):setTimeout((function(){throw r}))}function _t(e){if("function"!=typeof e)throw Error(Ot(28,!1));gt.push(e)}function Et(e){if("function"!=typeof e)throw Error(Ot(29,!1));var t=!1;return gt=gt.filter((function(n){var r=n===e;return t=t||r,!r})),t}function Ot(e,t){for(var n=arguments.length,r=new Array(n>2?n-2:0),o=2;o<n;o++)r[o-2]=arguments[o];return"single-spa minified message #".concat(e,": ").concat(t?t+" ":"","See https://single-spa.js.org/error/?code=").concat(e).concat(r.length?"&arg=".concat(r.join("&arg=")):"")}function St(e,t,n){var r,o="".concat(Ut(t)," '").concat(Mt(t),"' died in status ").concat(t.status,": ");if(e instanceof Error){try{e.message=o+e.message}catch(e){}r=e}else{console.warn(Ot(30,!1,t.status,Mt(t)));try{r=Error(o+JSON.stringify(e))}catch(t){r=e}}return r.appOrParcelName=Mt(t),t.status=n,r}var Pt="NOT_LOADED",xt="LOADING_SOURCE_CODE",jt="NOT_BOOTSTRAPPED",kt="BOOTSTRAPPING",At="NOT_MOUNTED",Tt="MOUNTING",Dt="MOUNTED",Ct="UPDATING",It="UNMOUNTING",Kt="LOAD_ERROR",Nt="SKIP_BECAUSE_BROKEN";function Bt(e){return e.status===Dt}function Rt(e){try{return e.activeWhen(window.location)}catch(t){return wt(t,e,Nt),!1}}function Mt(e){return e.name}function $t(e){return Boolean(e.unmountThisParcel)}function Ut(e){return $t(e)?"parcel":"application"}function Ft(){for(var e=arguments.length-1;e>0;e--)for(var t in arguments[e])"__proto__"!==t&&(arguments[e-1][t]=arguments[e][t]);return arguments[0]}function Lt(e,t){for(var n=0;n<e.length;n++)if(t(e[n]))return e[n];return null}function qt(e){return e&&("function"==typeof e||(t=e,Array.isArray(t)&&!Lt(t,(function(e){return"function"!=typeof e}))));var t}function Wt(e,t){var n=e[t]||[];0===(n=Array.isArray(n)?n:[n]).length&&(n=[function(){return Promise.resolve()}]);var r=Ut(e),o=Mt(e);return function(e){return n.reduce((function(n,i,s){return n.then((function(){var n=i(e);return Vt(n)?n:Promise.reject(Ot(15,!1,r,o,t,s))}))}),Promise.resolve())}}function Vt(e){return e&&"function"==typeof e.then&&"function"==typeof e.catch}function Gt(e,t){return Promise.resolve().then((function(){return e.status!==jt?e:(e.status=kt,e.bootstrap?cn(e,"bootstrap").then(n).catch((function(n){if(t)throw St(n,e,Nt);return wt(n,e,Nt),e})):Promise.resolve().then(n))}));function n(){return e.status=At,e}}function Ht(e,t){return Promise.resolve().then((function(){if(e.status!==Dt)return e;e.status=It;var n=Object.keys(e.parcels).map((function(t){return e.parcels[t].unmountThisParcel()}));return Promise.all(n).then(r,(function(n){return r().then((function(){var r=Error(n.message);if(t)throw St(r,e,Nt);wt(r,e,Nt)}))})).then((function(){return e}));function r(){return cn(e,"unmount").then((function(){e.status=At})).catch((function(n){if(t)throw St(n,e,Nt);wt(n,e,Nt)}))}}))}var zt=!1,Yt=!1;function Qt(e,t){return Promise.resolve().then((function(){return e.status!==At?e:(zt||(window.dispatchEvent(new bt("single-spa:before-first-mount")),zt=!0),cn(e,"mount").then((function(){return e.status=Dt,Yt||(window.dispatchEvent(new bt("single-spa:first-mount")),Yt=!0),e})).catch((function(n){return e.status=Dt,Ht(e,!0).then(r,r);function r(){if(t)throw St(n,e,Nt);return wt(n,e,Nt),e}})))}))}var Jt=0,Xt={parcels:{}};function Zt(){return en.apply(Xt,arguments)}function en(e,t){var n=this;if(!e||"object"!==yt(e)&&"function"!=typeof e)throw Error(Ot(2,!1));if(e.name&&"string"!=typeof e.name)throw Error(Ot(3,!1,yt(e.name)));if("object"!==yt(t))throw Error(Ot(4,!1,name,yt(t)));if(!t.domElement)throw Error(Ot(5,!1,name));var r,o=Jt++,i="function"==typeof e,s=i?e:function(){return Promise.resolve(e)},a={id:o,parcels:{},status:i?xt:jt,customProps:t,parentName:Mt(n),unmountThisParcel:function(){return h.then((function(){if(a.status!==Dt)throw Error(Ot(6,!1,name,a.status));return Ht(a,!0)})).then((function(e){return a.parentName&&delete n.parcels[a.id],e})).then((function(e){return c(e),e})).catch((function(e){throw a.status=Nt,l(e),e}))}};n.parcels[o]=a;var u=s();if(!u||"function"!=typeof u.then)throw Error(Ot(7,!1));var c,l,f=(u=u.then((function(e){if(!e)throw Error(Ot(8,!1));var t=e.name||"parcel-".concat(o);if(Object.prototype.hasOwnProperty.call(e,"bootstrap")&&!qt(e.bootstrap))throw Error(Ot(9,!1,t));if(!qt(e.mount))throw Error(Ot(10,!1,t));if(!qt(e.unmount))throw Error(Ot(11,!1,t));if(e.update&&!qt(e.update))throw Error(Ot(12,!1,t));var n=Wt(e,"bootstrap"),i=Wt(e,"mount"),s=Wt(e,"unmount");a.status=jt,a.name=t,a.bootstrap=n,a.mount=i,a.unmount=s,a.timeouts=ln(e.timeouts),e.update&&(a.update=Wt(e,"update"),r.update=function(e){return a.customProps=e,tn(function(e){return Promise.resolve().then((function(){if(e.status!==Dt)throw Error(Ot(32,!1,Mt(e)));return e.status=Ct,cn(e,"update").then((function(){return e.status=Dt,e})).catch((function(t){throw St(t,e,Nt)}))}))}(a))})}))).then((function(){return Gt(a,!0)})),h=f.then((function(){return Qt(a,!0)})),d=new Promise((function(e,t){c=e,l=t}));return r={mount:function(){return tn(Promise.resolve().then((function(){if(a.status!==At)throw Error(Ot(13,!1,name,a.status));return n.parcels[o]=a,Qt(a)})))},unmount:function(){return tn(a.unmountThisParcel())},getStatus:function(){return a.status},loadPromise:tn(u),bootstrapPromise:tn(f),mountPromise:tn(h),unmountPromise:tn(d)}}function tn(e){return e.then((function(){return null}))}function nn(e){var t=Mt(e),n="function"==typeof e.customProps?e.customProps(t,window.location):e.customProps;("object"!==yt(n)||null===n||Array.isArray(n))&&(n={},console.warn(Ot(40,!1),t,n));var r=Ft({},n,{name:t,mountParcel:en.bind(e),singleSpa:pt});return $t(e)&&(r.unmountSelf=e.unmountThisParcel),r}var rn={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 on(e,t,n){if("number"!=typeof e||e<=0)throw Error(Ot(16,!1));rn.bootstrap={millis:e,dieOnTimeout:t,warningMillis:n||1e3}}function sn(e,t,n){if("number"!=typeof e||e<=0)throw Error(Ot(17,!1));rn.mount={millis:e,dieOnTimeout:t,warningMillis:n||1e3}}function an(e,t,n){if("number"!=typeof e||e<=0)throw Error(Ot(18,!1));rn.unmount={millis:e,dieOnTimeout:t,warningMillis:n||1e3}}function un(e,t,n){if("number"!=typeof e||e<=0)throw Error(Ot(19,!1));rn.unload={millis:e,dieOnTimeout:t,warningMillis:n||1e3}}function cn(e,t){var n=e.timeouts[t],r=n.warningMillis,o=Ut(e);return new Promise((function(i,s){var a=!1,u=!1;e[t](nn(e)).then((function(e){a=!0,i(e)})).catch((function(e){a=!0,s(e)})),setTimeout((function(){return l(1)}),r),setTimeout((function(){return l(!0)}),n.millis);var c=Ot(31,!1,t,o,Mt(e),n.millis);function l(e){if(!a)if(!0===e)u=!0,n.dieOnTimeout?s(Error(c)):console.error(c);else if(!u){var t=e,o=t*r;console.warn(c),o+r<n.millis&&setTimeout((function(){return l(t+1)}),r)}}}))}function ln(e){var t={};for(var n in rn)t[n]=Ft({},rn[n],e&&e[n]||{});return t}function fn(e){return Promise.resolve().then((function(){return e.loadPromise?e.loadPromise:e.status!==Pt&&e.status!==Kt?e:(e.status=xt,e.loadPromise=Promise.resolve().then((function(){var r=e.loadApp(nn(e));if(!Vt(r))throw n=!0,Error(Ot(33,!1,Mt(e)));return r.then((function(n){var r;e.loadErrorTime=null,"object"!==yt(t=n)&&(r=34),Object.prototype.hasOwnProperty.call(t,"bootstrap")&&!qt(t.bootstrap)&&(r=35),qt(t.mount)||(r=36),qt(t.unmount)||(r=37);var o=Ut(t);if(r){var i;try{i=JSON.stringify(t)}catch(e){}return console.error(Ot(r,!1,o,Mt(e),i),t),wt(void 0,e,Nt),e}return t.devtools&&t.devtools.overlays&&(e.devtools.overlays=Ft({},e.devtools.overlays,t.devtools.overlays)),e.status=jt,e.bootstrap=Wt(t,"bootstrap"),e.mount=Wt(t,"mount"),e.unmount=Wt(t,"unmount"),e.unload=Wt(t,"unload"),e.timeouts=ln(t.timeouts),delete e.loadPromise,e}))})).catch((function(t){var r;return delete e.loadPromise,n?r=Nt:(r=Kt,e.loadErrorTime=(new Date).getTime()),wt(t,e,r),e})));var t,n}))}var hn,dn="undefined"!=typeof window,pn={hashchange:[],popstate:[]},yn=["hashchange","popstate"];function mn(e){var t;if("string"==typeof e)t=e;else if(this&&this.href)t=this.href;else{if(!(e&&e.currentTarget&&e.currentTarget.href&&e.preventDefault))throw Error(Ot(14,!1));t=e.currentTarget.href,e.preventDefault()}var n=En(window.location.href),r=En(t);0===t.indexOf("#")?window.location.hash=r.hash:n.host!==r.host&&r.host?window.location.href=t:r.pathname===n.pathname&&r.search===n.search?window.location.hash=r.hash:window.history.pushState(null,null,t)}function vn(e){var t=this;if(e){var n=e[0].type;yn.indexOf(n)>=0&&pn[n].forEach((function(n){try{n.apply(t,e)}catch(e){setTimeout((function(){throw e}))}}))}}function bn(){Hn([],arguments)}function gn(e,t){return function(){var n=window.location.href,r=e.apply(this,arguments),o=window.location.href;return hn&&n===o||(Jn()?window.dispatchEvent(function(e,t){var n;try{n=new PopStateEvent("popstate",{state:e})}catch(t){(n=document.createEvent("PopStateEvent")).initPopStateEvent("popstate",!1,!1,e)}return n.singleSpa=!0,n.singleSpaTrigger=t,n}(window.history.state,t)):Hn([])),r}}if(dn){window.addEventListener("hashchange",bn),window.addEventListener("popstate",bn);var wn=window.addEventListener,_n=window.removeEventListener;window.addEventListener=function(e,t){if(!("function"==typeof t&&yn.indexOf(e)>=0)||Lt(pn[e],(function(e){return e===t})))return wn.apply(this,arguments);pn[e].push(t)},window.removeEventListener=function(e,t){if(!("function"==typeof t&&yn.indexOf(e)>=0))return _n.apply(this,arguments);pn[e]=pn[e].filter((function(e){return e!==t}))},window.history.pushState=gn(window.history.pushState,"pushState"),window.history.replaceState=gn(window.history.replaceState,"replaceState"),window.singleSpaNavigate?console.warn(Ot(41,!1)):window.singleSpaNavigate=mn}function En(e){var t=document.createElement("a");return t.href=e,t}var On=!1;function Sn(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:window.jQuery;if(e||window.$&&window.$.fn&&window.$.fn.jquery&&(e=window.$),e&&!On){var t=e.fn.on,n=e.fn.off;e.fn.on=function(e,n){return Pn.call(this,t,window.addEventListener,e,n,arguments)},e.fn.off=function(e,t){return Pn.call(this,n,window.removeEventListener,e,t,arguments)},On=!0}}function Pn(e,t,n,r,o){return"string"!=typeof n?e.apply(this,o):(n.split(/\s+/).forEach((function(e){yn.indexOf(e)>=0&&(t(e,r),n=n.replace(e,""))})),""===n.trim()?this:e.apply(this,o))}var xn={};function jn(e){return Promise.resolve().then((function(){var t=xn[Mt(e)];if(!t)return e;if(e.status===Pt)return kn(e,t),e;if("UNLOADING"===e.status)return t.promise.then((function(){return e}));if(e.status!==At&&e.status!==Kt)return e;var n=e.status===Kt?Promise.resolve():cn(e,"unload");return e.status="UNLOADING",n.then((function(){return kn(e,t),e})).catch((function(n){return function(e,t,n){delete xn[Mt(e)],delete e.bootstrap,delete e.mount,delete e.unmount,delete e.unload,wt(n,e,Nt),t.reject(n)}(e,t,n),e}))}))}function kn(e,t){delete xn[Mt(e)],delete e.bootstrap,delete e.mount,delete e.unmount,delete e.unload,e.status=Pt,t.resolve()}function An(e,t,n,r){xn[Mt(e)]={app:e,resolve:n,reject:r},Object.defineProperty(xn[Mt(e)],"promise",{get:t})}function Tn(e){return xn[e]}var Dn=[];function Cn(){var e=[],t=[],n=[],r=[],o=(new Date).getTime();return Dn.forEach((function(i){var s=i.status!==Nt&&Rt(i);switch(i.status){case Kt:s&&o-i.loadErrorTime>=200&&n.push(i);break;case Pt:case xt:s&&n.push(i);break;case jt:case At:!s&&Tn(Mt(i))?e.push(i):s&&r.push(i);break;case Dt:s||t.push(i)}})),{appsToUnload:e,appsToUnmount:t,appsToLoad:n,appsToMount:r}}function In(){return Dn.filter(Bt).map(Mt)}function Kn(){return Dn.map(Mt)}function Nn(e){var t=Lt(Dn,(function(t){return Mt(t)===e}));return t?t.status:null}function Bn(e,t,n,r){var o=function(e,t,n,r){var o,i={name:null,loadApp:null,activeWhen:null,customProps:null};return"object"===yt(e)?(function(e){if(Array.isArray(e)||null===e)throw Error(Ot(39,!1));var t=["name","app","activeWhen","customProps"],n=Object.keys(e).reduce((function(e,n){return t.indexOf(n)>=0?e:e.concat(n)}),[]);if(0!==n.length)throw Error(Ot(38,!1,t.join(", "),n.join(", ")));if("string"!=typeof e.name||0===e.name.length)throw Error(Ot(20,!1));if("object"!==yt(e.app)&&"function"!=typeof e.app)throw Error(Ot(20,!1));var r=function(e){return"string"==typeof e||"function"==typeof e};if(!(r(e.activeWhen)||Array.isArray(e.activeWhen)&&e.activeWhen.every(r)))throw Error(Ot(24,!1));if(!Fn(e.customProps))throw Error(Ot(22,!1))}(e),i.name=e.name,i.loadApp=e.app,i.activeWhen=e.activeWhen,i.customProps=e.customProps):(function(e,t,n,r){if("string"!=typeof e||0===e.length)throw Error(Ot(20,!1));if(!t)throw Error(Ot(23,!1));if("function"!=typeof n)throw Error(Ot(24,!1));if(!Fn(r))throw Error(Ot(22,!1))}(e,t,n,r),i.name=e,i.loadApp=t,i.activeWhen=n,i.customProps=r),i.loadApp="function"!=typeof(o=i.loadApp)?function(){return Promise.resolve(o)}:o,i.customProps=function(e){return e||{}}(i.customProps),i.activeWhen=function(e){var t=Array.isArray(e)?e:[e];return t=t.map((function(e){return"function"==typeof e?e:Ln(e)})),function(e){return t.some((function(t){return t(e)}))}}(i.activeWhen),i}(e,t,n,r);if(-1!==Kn().indexOf(o.name))throw Error(Ot(21,!1,o.name));Dn.push(Ft({loadErrorTime:null,status:Pt,parcels:{},devtools:{overlays:{options:{},selectors:[]}}},o)),dn&&(Sn(),Hn())}function Rn(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:window.location;return Dn.filter((function(t){return t.activeWhen(e)})).map(Mt)}function Mn(e){if(0===Dn.filter((function(t){return Mt(t)===e})).length)throw Error(Ot(25,!1,e));return $n(e).then((function(){var t=Dn.map(Mt).indexOf(e);Dn.splice(t,1)}))}function $n(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{waitForUnmount:!1};if("string"!=typeof e)throw Error(Ot(26,!1));var n=Lt(Dn,(function(t){return Mt(t)===e}));if(!n)throw Error(Ot(27,!1,e));var r,o=Tn(Mt(n));if(t&&t.waitForUnmount){if(o)return o.promise;var i=new Promise((function(e,t){An(n,(function(){return i}),e,t)}));return i}return o?(r=o.promise,Un(n,o.resolve,o.reject)):r=new Promise((function(e,t){An(n,(function(){return r}),e,t),Un(n,e,t)})),r}function Un(e,t,n){Ht(e).then(jn).then((function(){t(),setTimeout((function(){Hn()}))})).catch(n)}function Fn(e){return!e||"function"==typeof e||"object"===yt(e)&&null!==e&&!Array.isArray(e)}function Ln(e,t){var n=function(e,t){var n=0,r=!1,o="^";"/"!==e[0]&&(e="/"+e);for(var i=0;i<e.length;i++){var s=e[i];(!r&&":"===s||r&&"/"===s)&&a(i)}return a(e.length),new RegExp(o,"i");function a(i){var s=e.slice(n,i).replace(/[|\\{}()[\]^$+*?.]/g,"\\$&");if(o+=r?"[^/]+/?":s,i===e.length)if(r)t&&(o+="$");else{var a=t?"":".*";o="/"===o.charAt(o.length-1)?"".concat(o).concat(a,"$"):"".concat(o,"(/").concat(a,")?(#.*)?$")}r=!r,n=i}}(e,t);return function(e){var t=e.origin;t||(t="".concat(e.protocol,"//").concat(e.host));var r=e.href.replace(t,"").replace(e.search,"").split("?")[0];return n.test(r)}}var qn=!1,Wn=[],Vn=dn&&window.location.href;function Gn(){return Hn()}function Hn(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1?arguments[1]:void 0;if(qn)return new Promise((function(e,n){Wn.push({resolve:e,reject:n,eventArguments:t})}));var n,r=Cn(),o=r.appsToUnload,i=r.appsToUnmount,s=r.appsToLoad,a=r.appsToMount,u=!1,c=Vn,l=Vn=window.location.href;return Jn()?(qn=!0,n=o.concat(s,i,a),Promise.resolve().then((function(){if(window.dispatchEvent(new bt(0===n.length?"single-spa:before-no-app-change":"single-spa:before-app-change",p(!0))),window.dispatchEvent(new bt("single-spa:before-routing-event",p(!0,{cancelNavigation:f}))),u)return window.dispatchEvent(new bt("single-spa:before-mount-routing-event",p(!0))),h(),void mn(c);var t=o.map(jn),r=i.map(Ht).map((function(e){return e.then(jn)})).concat(t),l=Promise.all(r);l.then((function(){window.dispatchEvent(new bt("single-spa:before-mount-routing-event",p(!0)))}));var y=s.map((function(e){return fn(e).then((function(e){return zn(e,l)}))})),m=a.filter((function(e){return s.indexOf(e)<0})).map((function(e){return zn(e,l)}));return l.catch((function(e){throw d(),e})).then((function(){return d(),Promise.all(y.concat(m)).catch((function(t){throw e.forEach((function(e){return e.reject(t)})),t})).then(h)}))}))):(n=s,Promise.resolve().then((function(){var e=s.map(fn);return Promise.all(e).then(d).then((function(){return[]})).catch((function(e){throw d(),e}))})));function f(){u=!0}function h(){var t=In();e.forEach((function(e){return e.resolve(t)}));try{var r=0===n.length?"single-spa:no-app-change":"single-spa:app-change";window.dispatchEvent(new bt(r,p())),window.dispatchEvent(new bt("single-spa:routing-event",p()))}catch(e){setTimeout((function(){throw e}))}if(qn=!1,Wn.length>0){var o=Wn;Wn=[],Hn(o)}return t}function d(){e.forEach((function(e){vn(e.eventArguments)})),vn(t)}function p(){var e,r=arguments.length>0&&void 0!==arguments[0]&&arguments[0],f=arguments.length>1?arguments[1]:void 0,h={},d=(mt(e={},Dt,[]),mt(e,At,[]),mt(e,Pt,[]),mt(e,Nt,[]),e);r?(s.concat(a).forEach((function(e,t){y(e,Dt)})),o.forEach((function(e){y(e,Pt)})),i.forEach((function(e){y(e,At)}))):n.forEach((function(e){y(e)}));var p={detail:{newAppStatuses:h,appsByNewStatus:d,totalAppChanges:n.length,originalEvent:null==t?void 0:t[0],oldUrl:c,newUrl:l,navigationIsCanceled:u}};return f&&Ft(p.detail,f),p;function y(e,t){var n=Mt(e);t=t||Nn(n),h[n]=t,(d[t]=d[t]||[]).push(n)}}}function zn(e,t){return Rt(e)?Gt(e).then((function(e){return t.then((function(){return Rt(e)?Qt(e):e}))})):t.then((function(){return e}))}var Yn=!1;function Qn(e){var t;Yn=!0,e&&e.urlRerouteOnly&&(t=e.urlRerouteOnly,hn=t),dn&&Hn()}function Jn(){return Yn}dn&&setTimeout((function(){Yn||console.warn(Ot(1,!1))}),5e3);var Xn={getRawAppData:function(){return[].concat(Dn)},reroute:Hn,NOT_LOADED:Pt,toLoadPromise:fn,toBootstrapPromise:Gt,unregisterApplication:Mn};function Zn(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}dn&&window.__SINGLE_SPA_DEVTOOLS__&&(window.__SINGLE_SPA_DEVTOOLS__.exposedMethods=Xn);const er=e=>{const t=e.concat(["openmrsBase","openmrsSpaBase"]);return Te((e=>{if(!e||"string"!=typeof e)return!1;const n=/\${(.*?)}/g;let r=n.exec(e);for(;r;){if(!t.includes(r[1]))return!1;r=n.exec(e)}return!0}),"Should be a URL or path. The allowed template parameters are "+t.map((e=>"${"+e+"}")).join(", "))},tr={inRange:(e,t)=>Te((n=>e<=n&&n<=t),`must be between ${e} and ${t}`),isUrl:er([]),isUrlWithTemplateParameters:er,oneOf:e=>Te((t=>e.includes(t)),`Must be one of the following: '${e.join("', '")}'.`)};function nr(e,t,n,r,o,i,s){try{var a=e[i](s),u=a.value}catch(e){return void n(e)}a.done?t(u):Promise.resolve(u).then(r,o)}function rr(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}const or="/ws/rest/v1/",ir="/ws/fhir2/R4",sr=`${or}session`;function ar(e){return e&&e.startsWith("http")?e:("/"!==e[0]&&(e="/"+e),window.openmrsBase+e)}function ur(e,t={}){if("string"!=typeof e)throw Error("The first argument to @openmrs/api's openmrsFetch function must be a url string");if("object"!=typeof t)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.");let n=ar(e);if(t.headers||(t.headers={}),F(t.body)&&(t.body=JSON.stringify(t.body)),void 0===t.headers.Accept&&(t.headers.Accept="application/json"),null===t.headers.Accept&&delete t.headers.Accept,e.startsWith(or)&&void 0===t.headers["Disable-WWW-Authenticate"]&&(t.headers["Disable-WWW-Authenticate"]="true"),e.startsWith(ir)){const e=new URL(n,window.location.toString());e.searchParams.has("_summary")||(e.searchParams.set("_summary","data"),n=e.toString())}const r=Error();return window.fetch(n,t).then((o=function(e){return function(){var t=this,n=arguments;return new Promise((function(r,o){var i=e.apply(t,n);function s(e){nr(i,r,o,s,a,"next",e)}function a(e){nr(i,r,o,s,a,"throw",e)}s(void 0)}))}}((function*(e){const t=e;if(t.ok)return 204===t.status?(t.data=null,t):t.clone().text().then((e=>{try{e&&(t.data=JSON.parse(e))}catch(e){}return t}));{const{redirectAuthFailure:e}=yield("@openmrs/esm-api",new Promise((e=>{const t=Fe("@openmrs/esm-api");function n(t){if(t.loaded&&t.config){const n=ye(["Display conditions","Translation overrides"],t.config);e(n),r&&r()}}n(t.getState());const r=t.subscribe(n)})));return n===ar(sr)&&403===t.status||e.enabled&&e.errors.includes(t.status)?(function({to:e,templateParams:t}){const n=window.getOpenmrsSpaBase().replace(/\/$/,""),r=function(e,t){const n=window.getOpenmrsSpaBase().replace(/\/$/,"");return function(e,t){return Object.keys(t).reduce(((e,n)=>e.split("${"+n+"}").join(t[n])),e)}(e,function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter((function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})))),r.forEach((function(t){Zn(e,t,n[t])}))}return e}({openmrsBase:window.openmrsBase,openmrsSpaBase:n},t)).replace(/^\/\//,"/")}(e,t);r.startsWith(n)?mn(r):window.location.assign(r)}({to:e.url}),e.resolvePromise?Promise.resolve():new Promise((()=>{}))):t.clone().text().then((e=>{let o=e;try{o=JSON.parse(e)}catch(e){}throw new lr(n,t,o,r)}),(e=>{throw new lr(n,t,null,r)}))}})),function(e){return o.apply(this,arguments)}));var o}function cr(e,t={}){if("object"!=typeof t)throw Error("The second argument to openmrsObservableFetch must be either omitted or an object");const n=new AbortController;return t.signal=n.signal,new w((r=>{let o=!1;return ur(e,t).then((e=>{o=!0,r.next(e),r.complete()}),(e=>{o=!0,r.error(e)})),()=>{o||n.abort()}}))}class lr extends Error{constructor(e,t,n,r){super(),rr(this,"response",void 0),rr(this,"responseBody",void 0),this.message=`Server responded with ${t.status} (${t.statusText}) for url ${e}. Check err.responseBody or network tab in dev tools for more info`,r.message=this.message,this.responseBody=n,this.response=t,this.stack=`Stacktrace for outgoing request:\n${r.stack}\nStacktrace for incoming response:\n${this.stack}`}}var fr=n(151);const hr=function(e){return void 0===e};function dr(e,t,n,r,o,i,s){try{var a=e[i](s),u=a.value}catch(e){return void n(e)}a.done?t(u):Promise.resolve(u).then(r,o)}const pr=(0,Re.createGlobalStore)("session",{loaded:!1,session:null});let yr=0;function mr(e={includeAuthStatus:!0}){return(yr<Date.now()-6e4||!pr.getState().loaded)&&br(),new w((t=>{const n=n=>{var r;n.loaded&&(e.includeAuthStatus?t.next(n.session):t.next(null===(r=n.session)||void 0===r?void 0:r.user))};return n(pr.getState()),pr.subscribe(n)}))}function vr(){return(yr<Date.now()-6e4||!pr.getState().loaded)&&br(),pr}function br(){return new Promise(((e,t)=>{yr=Date.now(),ur(sr).then((n=>{if("object"!=typeof(null==n?void 0:n.data))return t(),Promise.reject();!function(e){var t,n,r;const o=null!==(r=null==e||null===(t=e.user)||void 0===t||null===(n=t.userProperties)||void 0===n?void 0:n.defaultLocale)&&void 0!==r?r:e.locale;o!==document.documentElement.getAttribute("lang")&&document.documentElement.setAttribute("lang",o)}(n.data),e(n.data),pr.setState({loaded:!0,session:n.data})})).catch((e=>((0,fr.reportError)(`Failed to fetch new session information: ${e}`),t(e),{sessionId:"",authenticated:!1})))}))}function gr(){pr.setState({loaded:!0,session:{authenticated:!1,sessionId:""}})}function wr(e,t){return void 0===t?Boolean(e):!Boolean(e)||function(e,t){return"string"==typeof e?!hr(t.privileges.find((t=>e===t.display))):Array.isArray(e)?e.every((e=>!hr(t.privileges.find((t=>e===t.display))))):(hr(e)||console.error(`Could not understand privileges "${e}"`),!0)}(e,t)||function(e){return!hr(e.roles.find((e=>"System Developer"===e.display)))}(t)}function _r(){let e,t;return new Promise(((n,r)=>{const o=r=>{r.loaded&&r.session.user&&(e=r.session.user,n(r.session.user),t&&t())};o(pr.getState()),e||(t=pr.subscribe(o))}))}function Er(){return new Promise(((e,t)=>{mr().subscribe((t=>{e(t.sessionLocation)}),t).unsubscribe()}))}function Or(e,t){return Sr.apply(this,arguments)}function Sr(){return Sr=function(e){return function(){var t=this,n=arguments;return new Promise((function(r,o){var i=e.apply(t,n);function s(e){dr(i,r,o,s,a,"next",e)}function a(e){dr(i,r,o,s,a,"throw",e)}s(void 0)}))}}((function*(e,t){yield ur(sr,{method:"POST",body:{sessionLocation:e},headers:{"Content-Type":"application/json"},signal:t.signal}),yield br()})),Sr.apply(this,arguments)}function Pr(){!function(e,t){tt(e,t);const n=pe(t,dt),r=Me.getState();Me.setState({schemas:Ve(We({},r.schemas),{[e]:n})})}("@openmrs/esm-api",{redirectAuthFailure:{enabled:{_type:Ae.Boolean,_default:!0,_description:"Whether to redirect logged-out users to `redirectAuthFailure.url`"},url:{_type:Ae.String,_default:"${openmrsSpaBase}/login",_validators:[tr.isUrl]},errors:{_type:Ae.Array,_default:[401],_elements:{_type:Ae.Number,_validators:[tr.inRange(100,600)]},_description:"The HTTP error codes for which users will be redirected"},resolvePromise:{_type:Ae.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."}}}),br()}try{self["workbox:window:6.5.3"]&&_()}catch(yt){}function xr(e,t){return new Promise((function(n){var r=new MessageChannel;r.port1.onmessage=function(e){n(e.data)},e.postMessage(t,[r.port2])}))}function jr(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}try{self["workbox:core:6.5.3"]&&_()}catch(yt){}var kr=function(){var e=this;this.promise=new Promise((function(t,n){e.resolve=t,e.reject=n}))};function Ar(e,t){var n=location.href;return new URL(e,n).href===new URL(t,n).href}var Tr=function(e,t){this.type=e,Object.assign(this,t)};function Dr(e,t,n){return n?t?t(e):e:(e&&e.then||(e=Promise.resolve(e)),t?e.then(t):e)}function Cr(){}var Ir={type:"SKIP_WAITING"};function Kr(e,t){if(!t)return e&&e.then?e.then(Cr):Promise.resolve()}!function(e){var t,n;function r(t,n){var r,o;return void 0===n&&(n={}),(r=e.call(this)||this).nn={},r.tn=0,r.rn=new kr,r.en=new kr,r.on=new kr,r.un=0,r.an=new Set,r.cn=function(){var e=r.fn,t=e.installing;r.tn>0||!Ar(t.scriptURL,r.sn.toString())||performance.now()>r.un+6e4?(r.vn=t,e.removeEventListener("updatefound",r.cn)):(r.hn=t,r.an.add(t),r.rn.resolve(t)),++r.tn,t.addEventListener("statechange",r.ln)},r.ln=function(e){var t=r.fn,n=e.target,o=n.state,i=n===r.vn,s={sw:n,isExternal:i,originalEvent:e};!i&&r.mn&&(s.isUpdate=!0),r.dispatchEvent(new Tr(o,s)),"installed"===o?r.wn=self.setTimeout((function(){"installed"===o&&t.waiting===n&&r.dispatchEvent(new Tr("waiting",s))}),200):"activating"===o&&(clearTimeout(r.wn),i||r.en.resolve(n))},r.dn=function(e){var t=r.hn,n=t!==navigator.serviceWorker.controller;r.dispatchEvent(new Tr("controlling",{isExternal:n,originalEvent:e,sw:t,isUpdate:r.mn})),n||r.on.resolve(t)},r.gn=(o=function(e){var t=e.data,n=e.ports,o=e.source;return Dr(r.getSW(),(function(){r.an.has(o)&&r.dispatchEvent(new Tr("message",{data:t,originalEvent:e,ports:n,sw:o}))}))},function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];try{return Promise.resolve(o.apply(this,e))}catch(e){return Promise.reject(e)}}),r.sn=t,r.nn=n,navigator.serviceWorker.addEventListener("message",r.gn),r}n=e,(t=r).prototype=Object.create(n.prototype),t.prototype.constructor=t,t.__proto__=n;var o,i=r.prototype;i.register=function(e){var t=(void 0===e?{}:e).immediate,n=void 0!==t&&t;try{var r=this;return function(e,t){var n=e();return n&&n.then?n.then(t):t()}((function(){if(!n&&"complete"!==document.readyState)return Kr(new Promise((function(e){return window.addEventListener("load",e)})))}),(function(){return r.mn=Boolean(navigator.serviceWorker.controller),r.yn=r.pn(),Dr(r.bn(),(function(e){r.fn=e,r.yn&&(r.hn=r.yn,r.en.resolve(r.yn),r.on.resolve(r.yn),r.yn.addEventListener("statechange",r.ln,{once:!0}));var t=r.fn.waiting;return t&&Ar(t.scriptURL,r.sn.toString())&&(r.hn=t,Promise.resolve().then((function(){r.dispatchEvent(new Tr("waiting",{sw:t,wasWaitingBeforeRegister:!0}))})).then((function(){}))),r.hn&&(r.rn.resolve(r.hn),r.an.add(r.hn)),r.fn.addEventListener("updatefound",r.cn),navigator.serviceWorker.addEventListener("controllerchange",r.dn),r.fn}))}))}catch(e){return Promise.reject(e)}},i.update=function(){try{return this.fn?Kr(this.fn.update()):void 0}catch(e){return Promise.reject(e)}},i.getSW=function(){return void 0!==this.hn?Promise.resolve(this.hn):this.rn.promise},i.messageSW=function(e){try{return Dr(this.getSW(),(function(t){return xr(t,e)}))}catch(e){return Promise.reject(e)}},i.messageSkipWaiting=function(){this.fn&&this.fn.waiting&&xr(this.fn.waiting,Ir)},i.pn=function(){var e=navigator.serviceWorker.controller;return e&&Ar(e.scriptURL,this.sn.toString())?e:void 0},i.bn=function(){try{var e=this;return function(e,t){try{var n=e()}catch(e){return t(e)}return n&&n.then?n.then(void 0,t):n}((function(){return Dr(navigator.serviceWorker.register(e.sn,e.nn),(function(t){return e.un=performance.now(),t}))}),(function(e){throw e}))}catch(e){return Promise.reject(e)}},(o=[{key:"active",get:function(){return this.en.promise}},{key:"controlling",get:function(){return this.on.promise}}])&&function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(r.prototype,o)}(function(){function e(){this.Pn=new Map}var t=e.prototype;return t.addEventListener=function(e,t){this.Sn(e).add(t)},t.removeEventListener=function(e,t){this.Sn(e).delete(t)},t.dispatchEvent=function(e){e.target=this;for(var t,n=function(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return jr(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?jr(e,t):void 0}}(e))){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(n=e[Symbol.iterator]()).next.bind(n)}(this.Sn(e.type));!(t=n()).done;)(0,t.value)(e)},t.Sn=function(e){return this.Pn.has(e)||this.Pn.set(e,new Set),this.Pn.get(e)},e}());const Nr="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:global,Br=Object.keys,Rr=Array.isArray;function Mr(e,t){return"object"!=typeof t||Br(t).forEach((function(n){e[n]=t[n]})),e}"undefined"==typeof Promise||Nr.Promise||(Nr.Promise=Promise);const $r=Object.getPrototypeOf,Ur={}.hasOwnProperty;function Fr(e,t){return Ur.call(e,t)}function Lr(e,t){"function"==typeof t&&(t=t($r(e))),("undefined"==typeof Reflect?Br:Reflect.ownKeys)(t).forEach((n=>{Wr(e,n,t[n])}))}const qr=Object.defineProperty;function Wr(e,t,n,r){qr(e,t,Mr(n&&Fr(n,"get")&&"function"==typeof n.get?{get:n.get,set:n.set,configurable:!0}:{value:n,configurable:!0,writable:!0},r))}function Vr(e){return{from:function(t){return e.prototype=Object.create(t.prototype),Wr(e.prototype,"constructor",e),{extend:Lr.bind(null,e.prototype)}}}}const Gr=Object.getOwnPropertyDescriptor;function Hr(e,t){let n;return Gr(e,t)||(n=$r(e))&&Hr(n,t)}const zr=[].slice;function Yr(e,t,n){return zr.call(e,t,n)}function Qr(e,t){return t(e)}function Jr(e){if(!e)throw new Error("Assertion Failed")}function Xr(e){Nr.setImmediate?setImmediate(e):setTimeout(e,0)}function Zr(e,t){return e.reduce(((e,n,r)=>{var o=t(n,r);return o&&(e[o[0]]=o[1]),e}),{})}function eo(e,t){if(Fr(e,t))return e[t];if(!t)return e;if("string"!=typeof t){for(var n=[],r=0,o=t.length;r<o;++r){var i=eo(e,t[r]);n.push(i)}return n}var s=t.indexOf(".");if(-1!==s){var a=e[t.substr(0,s)];return void 0===a?void 0:eo(a,t.substr(s+1))}}function to(e,t,n){if(e&&void 0!==t&&(!("isFrozen"in Object)||!Object.isFrozen(e)))if("string"!=typeof t&&"length"in t){Jr("string"!=typeof n&&"length"in n);for(var r=0,o=t.length;r<o;++r)to(e,t[r],n[r])}else{var i=t.indexOf(".");if(-1!==i){var s=t.substr(0,i),a=t.substr(i+1);if(""===a)void 0===n?Rr(e)&&!isNaN(parseInt(s))?e.splice(s,1):delete e[s]:e[s]=n;else{var u=e[s];u&&Fr(e,s)||(u=e[s]={}),to(u,a,n)}}else void 0===n?Rr(e)&&!isNaN(parseInt(t))?e.splice(t,1):delete e[t]:e[t]=n}}function no(e){var t={};for(var n in e)Fr(e,n)&&(t[n]=e[n]);return t}const ro=[].concat;function oo(e){return ro.apply([],e)}const io="Boolean,String,Date,RegExp,Blob,File,FileList,FileSystemFileHandle,ArrayBuffer,DataView,Uint8ClampedArray,ImageBitmap,ImageData,Map,Set,CryptoKey".split(",").concat(oo([8,16,32,64].map((e=>["Int","Uint","Float"].map((t=>t+e+"Array")))))).filter((e=>Nr[e])),so=io.map((e=>Nr[e]));Zr(io,(e=>[e,!0]));let ao=null;function uo(e){ao="undefined"!=typeof WeakMap&&new WeakMap;const t=co(e);return ao=null,t}function co(e){if(!e||"object"!=typeof e)return e;let t=ao&&ao.get(e);if(t)return t;if(Rr(e)){t=[],ao&&ao.set(e,t);for(var n=0,r=e.length;n<r;++n)t.push(co(e[n]))}else if(so.indexOf(e.constructor)>=0)t=e;else{const n=$r(e);for(var o in t=n===Object.prototype?{}:Object.create(n),ao&&ao.set(e,t),e)Fr(e,o)&&(t[o]=co(e[o]))}return t}const{toString:lo}={};function fo(e){return lo.call(e).slice(8,-1)}const ho="undefined"!=typeof Symbol?Symbol.iterator:"@@iterator",po="symbol"==typeof ho?function(e){var t;return null!=e&&(t=e[ho])&&t.apply(e)}:function(){return null},yo={};function mo(e){var t,n,r,o;if(1===arguments.length){if(Rr(e))return e.slice();if(this===yo&&"string"==typeof e)return[e];if(o=po(e)){for(n=[];!(r=o.next()).done;)n.push(r.value);return n}if(null==e)return[e];if("number"==typeof(t=e.length)){for(n=new Array(t);t--;)n[t]=e[t];return n}return[e]}for(t=arguments.length,n=new Array(t);t--;)n[t]=arguments[t];return n}const vo="undefined"!=typeof Symbol?e=>"AsyncFunction"===e[Symbol.toStringTag]:()=>!1;var bo="undefined"!=typeof location&&/^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href);function go(e,t){bo=e,wo=t}var wo=()=>!0;const _o=!new Error("").stack;function Eo(){if(_o)try{throw Eo.arguments,new Error}catch(e){return e}return new Error}function Oo(e,t){var n=e.stack;return n?(t=t||0,0===n.indexOf(e.name)&&(t+=(e.name+e.message).split("\n").length),n.split("\n").slice(t).filter(wo).map((e=>"\n"+e)).join("")):""}var So=["Unknown","Constraint","Data","TransactionInactive","ReadOnly","Version","NotFound","InvalidState","InvalidAccess","Abort","Timeout","QuotaExceeded","Syntax","DataClone"],Po=["Modify","Bulk","OpenFailed","VersionChange","Schema","Upgrade","InvalidTable","MissingAPI","NoSuchDatabase","InvalidArgument","SubTransaction","Unsupported","Internal","DatabaseClosed","PrematureCommit","ForeignAwait"].concat(So),xo={VersionChanged:"Database version changed by other database connection",DatabaseClosed:"Database has been closed",Abort:"Transaction aborted",TransactionInactive:"Transaction has already completed or failed",MissingAPI:"IndexedDB API missing. Please visit https://tinyurl.com/y2uuvskb"};function jo(e,t){this._e=Eo(),this.name=e,this.message=t}function ko(e,t){return e+". Errors: "+Object.keys(t).map((e=>t[e].toString())).filter(((e,t,n)=>n.indexOf(e)===t)).join("\n")}function Ao(e,t,n,r){this._e=Eo(),this.failures=t,this.failedKeys=r,this.successCount=n,this.message=ko(e,t)}function To(e,t){this._e=Eo(),this.name="BulkError",this.failures=Object.keys(t).map((e=>t[e])),this.failuresByPos=t,this.message=ko(e,t)}Vr(jo).from(Error).extend({stack:{get:function(){return this._stack||(this._stack=this.name+": "+this.message+Oo(this._e,2))}},toString:function(){return this.name+": "+this.message}}),Vr(Ao).from(jo),Vr(To).from(jo);var Do=Po.reduce(((e,t)=>(e[t]=t+"Error",e)),{});const Co=jo;var Io=Po.reduce(((e,t)=>{var n=t+"Error";function r(e,r){this._e=Eo(),this.name=n,e?"string"==typeof e?(this.message=`${e}${r?"\n "+r:""}`,this.inner=r||null):"object"==typeof e&&(this.message=`${e.name} ${e.message}`,this.inner=e):(this.message=xo[t]||n,this.inner=null)}return Vr(r).from(Co),e[t]=r,e}),{});Io.Syntax=SyntaxError,Io.Type=TypeError,Io.Range=RangeError;var Ko=So.reduce(((e,t)=>(e[t+"Error"]=Io[t],e)),{}),No=Po.reduce(((e,t)=>(-1===["Syntax","Type","Range"].indexOf(t)&&(e[t+"Error"]=Io[t]),e)),{});function Bo(){}function Ro(e){return e}function Mo(e,t){return null==e||e===Ro?t:function(n){return t(e(n))}}function $o(e,t){return function(){e.apply(this,arguments),t.apply(this,arguments)}}function Uo(e,t){return e===Bo?t:function(){var n=e.apply(this,arguments);void 0!==n&&(arguments[0]=n);var r=this.onsuccess,o=this.onerror;this.onsuccess=null,this.onerror=null;var i=t.apply(this,arguments);return r&&(this.onsuccess=this.onsuccess?$o(r,this.onsuccess):r),o&&(this.onerror=this.onerror?$o(o,this.onerror):o),void 0!==i?i:n}}function Fo(e,t){return e===Bo?t:function(){e.apply(this,arguments);var n=this.onsuccess,r=this.onerror;this.onsuccess=this.onerror=null,t.apply(this,arguments),n&&(this.onsuccess=this.onsuccess?$o(n,this.onsuccess):n),r&&(this.onerror=this.onerror?$o(r,this.onerror):r)}}function Lo(e,t){return e===Bo?t:function(n){var r=e.apply(this,arguments);Mr(n,r);var o=this.onsuccess,i=this.onerror;this.onsuccess=null,this.onerror=null;var s=t.apply(this,arguments);return o&&(this.onsuccess=this.onsuccess?$o(o,this.onsuccess):o),i&&(this.onerror=this.onerror?$o(i,this.onerror):i),void 0===r?void 0===s?void 0:s:Mr(r,s)}}function qo(e,t){return e===Bo?t:function(){return!1!==t.apply(this,arguments)&&e.apply(this,arguments)}}function Wo(e,t){return e===Bo?t:function(){var n=e.apply(this,arguments);if(n&&"function"==typeof n.then){for(var r=this,o=arguments.length,i=new Array(o);o--;)i[o]=arguments[o];return n.then((function(){return t.apply(r,i)}))}return t.apply(this,arguments)}}No.ModifyError=Ao,No.DexieError=jo,No.BulkError=To;var Vo={};const[Go,Ho,zo]="undefined"==typeof Promise?[]:(()=>{let e=Promise.resolve();if("undefined"==typeof crypto||!crypto.subtle)return[e,$r(e),e];const t=crypto.subtle.digest("SHA-512",new Uint8Array([0]));return[t,$r(t),e]})(),Yo=Ho&&Ho.then,Qo=Go&&Go.constructor,Jo=!!zo;var Xo=!1,Zo=zo?()=>{zo.then(Ei)}:Nr.setImmediate?setImmediate.bind(null,Ei):Nr.MutationObserver?()=>{var e=document.createElement("div");new MutationObserver((()=>{Ei(),e=null})).observe(e,{attributes:!0}),e.setAttribute("i","1")}:()=>{setTimeout(Ei,0)},ei=function(e,t){ci.push([e,t]),ni&&(Zo(),ni=!1)},ti=!0,ni=!0,ri=[],oi=[],ii=null,si=Ro,ai={id:"global",global:!0,ref:0,unhandleds:[],onunhandled:Gi,pgp:!1,env:{},finalize:function(){this.unhandleds.forEach((e=>{try{Gi(e[0],e[1])}catch(e){}}))}},ui=ai,ci=[],li=0,fi=[];function hi(e){if("object"!=typeof this)throw new TypeError("Promises must be constructed via new");this._listeners=[],this.onuncatched=Bo,this._lib=!1;var t=this._PSD=ui;if(bo&&(this._stackHolder=Eo(),this._prev=null,this._numPrev=0),"function"!=typeof e){if(e!==Vo)throw new TypeError("Not a function");return this._state=arguments[1],this._value=arguments[2],void(!1===this._state&&mi(this,this._value))}this._state=null,this._value=null,++t.ref,yi(this,e)}const di={get:function(){var e=ui,t=Ci;function n(n,r){var o=!e.global&&(e!==ui||t!==Ci);const i=o&&!Bi();var s=new hi(((t,s)=>{bi(this,new pi(Wi(n,e,o,i),Wi(r,e,o,i),t,s,e))}));return bo&&_i(s,this),s}return n.prototype=Vo,n},set:function(e){Wr(this,"then",e&&e.prototype===Vo?di:{get:function(){return e},set:di.set})}};function pi(e,t,n,r,o){this.onFulfilled="function"==typeof e?e:null,this.onRejected="function"==typeof t?t:null,this.resolve=n,this.reject=r,this.psd=o}function yi(e,t){try{t((t=>{if(null===e._state){if(t===e)throw new TypeError("A promise cannot be resolved with itself.");var n=e._lib&&Oi();t&&"function"==typeof t.then?yi(e,((e,n)=>{t instanceof hi?t._then(e,n):t.then(e,n)})):(e._state=!0,e._value=t,vi(e)),n&&Si()}}),mi.bind(null,e))}catch(t){mi(e,t)}}function mi(e,t){if(oi.push(t),null===e._state){var n=e._lib&&Oi();t=si(t),e._state=!1,e._value=t,bo&&null!==t&&"object"==typeof t&&!t._promise&&function(e,t,n){try{e.apply(null,void 0)}catch(e){}}((()=>{var n=Hr(t,"stack");t._promise=e,Wr(t,"stack",{get:()=>Xo?n&&(n.get?n.get.apply(t):n.value):e.stack})})),function(e){ri.some((t=>t._value===e._value))||ri.push(e)}(e),vi(e),n&&Si()}}function vi(e){var t=e._listeners;e._listeners=[];for(var n=0,r=t.length;n<r;++n)bi(e,t[n]);var o=e._PSD;--o.ref||o.finalize(),0===li&&(++li,ei((()=>{0==--li&&Pi()}),[]))}function bi(e,t){if(null!==e._state){var n=e._state?t.onFulfilled:t.onRejected;if(null===n)return(e._state?t.resolve:t.reject)(e._value);++t.psd.ref,++li,ei(gi,[n,e,t])}else e._listeners.push(t)}function gi(e,t,n){try{ii=t;var r,o=t._value;t._state?r=e(o):(oi.length&&(oi=[]),r=e(o),-1===oi.indexOf(o)&&function(e){for(var t=ri.length;t;)if(ri[--t]._value===e._value)return void ri.splice(t,1)}(t)),n.resolve(r)}catch(e){n.reject(e)}finally{ii=null,0==--li&&Pi(),--n.psd.ref||n.psd.finalize()}}function wi(e,t,n){if(t.length===n)return t;var r="";if(!1===e._state){var o,i,s=e._value;null!=s?(o=s.name||"Error",i=s.message||s,r=Oo(s,0)):(o=s,i=""),t.push(o+(i?": "+i:"")+r)}return bo&&((r=Oo(e._stackHolder,2))&&-1===t.indexOf(r)&&t.push(r),e._prev&&wi(e._prev,t,n)),t}function _i(e,t){var n=t?t._numPrev+1:0;n<100&&(e._prev=t,e._numPrev=n)}function Ei(){Oi()&&Si()}function Oi(){var e=ti;return ti=!1,ni=!1,e}function Si(){var e,t,n;do{for(;ci.length>0;)for(e=ci,ci=[],n=e.length,t=0;t<n;++t){var r=e[t];r[0].apply(null,r[1])}}while(ci.length>0);ti=!0,ni=!0}function Pi(){var e=ri;ri=[],e.forEach((e=>{e._PSD.onunhandled.call(null,e._value,e)}));for(var t=fi.slice(0),n=t.length;n;)t[--n]()}function xi(e){return new hi(Vo,!1,e)}function ji(e,t){var n=ui;return function(){var r=Oi(),o=ui;try{return Ui(n,!0),e.apply(this,arguments)}catch(e){t&&t(e)}finally{Ui(o,!1),r&&Si()}}}Lr(hi.prototype,{then:di,_then:function(e,t){bi(this,new pi(null,null,e,t,ui))},catch:function(e){if(1===arguments.length)return this.then(null,e);var t=arguments[0],n=arguments[1];return"function"==typeof t?this.then(null,(e=>e instanceof t?n(e):xi(e))):this.then(null,(e=>e&&e.name===t?n(e):xi(e)))},finally:function(e){return this.then((t=>(e(),t)),(t=>(e(),xi(t))))},stack:{get:function(){if(this._stack)return this._stack;try{Xo=!0;var e=wi(this,[],20).join("\nFrom previous: ");return null!==this._state&&(this._stack=e),e}finally{Xo=!1}}},timeout:function(e,t){return e<1/0?new hi(((n,r)=>{var o=setTimeout((()=>r(new Io.Timeout(t))),e);this.then(n,r).finally(clearTimeout.bind(null,o))})):this}}),"undefined"!=typeof Symbol&&Symbol.toStringTag&&Wr(hi.prototype,Symbol.toStringTag,"Dexie.Promise"),ai.env=Fi(),Lr(hi,{all:function(){var e=mo.apply(null,arguments).map(Ri);return new hi((function(t,n){0===e.length&&t([]);var r=e.length;e.forEach(((o,i)=>hi.resolve(o).then((n=>{e[i]=n,--r||t(e)}),n)))}))},resolve:e=>{if(e instanceof hi)return e;if(e&&"function"==typeof e.then)return new hi(((t,n)=>{e.then(t,n)}));var t=new hi(Vo,!0,e);return _i(t,ii),t},reject:xi,race:function(){var e=mo.apply(null,arguments).map(Ri);return new hi(((t,n)=>{e.map((e=>hi.resolve(e).then(t,n)))}))},PSD:{get:()=>ui,set:e=>ui=e},totalEchoes:{get:()=>Ci},newPSD:Ki,usePSD:Li,scheduler:{get:()=>ei,set:e=>{ei=e}},rejectionMapper:{get:()=>si,set:e=>{si=e}},follow:(e,t)=>new hi(((n,r)=>Ki(((t,n)=>{var r=ui;r.unhandleds=[],r.onunhandled=n,r.finalize=$o((function(){!function(e){fi.push((function t(){e(),fi.splice(fi.indexOf(t),1)})),++li,ei((()=>{0==--li&&Pi()}),[])}((()=>{0===this.unhandleds.length?t():n(this.unhandleds[0])}))}),r.finalize),e()}),t,n,r)))}),Qo&&(Qo.allSettled&&Wr(hi,"allSettled",(function(){const e=mo.apply(null,arguments).map(Ri);return new hi((t=>{0===e.length&&t([]);let n=e.length;const r=new Array(n);e.forEach(((e,o)=>hi.resolve(e).then((e=>r[o]={status:"fulfilled",value:e}),(e=>r[o]={status:"rejected",reason:e})).then((()=>--n||t(r)))))}))})),Qo.any&&"undefined"!=typeof AggregateError&&Wr(hi,"any",(function(){const e=mo.apply(null,arguments).map(Ri);return new hi(((t,n)=>{0===e.length&&n(new AggregateError([]));let r=e.length;const o=new Array(r);e.forEach(((e,i)=>hi.resolve(e).then((e=>t(e)),(e=>{o[i]=e,--r||n(new AggregateError(o))}))))}))})));const ki={awaits:0,echoes:0,id:0};var Ai=0,Ti=[],Di=0,Ci=0,Ii=0;function Ki(e,t,n,r){var o=ui,i=Object.create(o);i.parent=o,i.ref=0,i.global=!1,i.id=++Ii;var s=ai.env;i.env=Jo?{Promise:hi,PromiseProp:{value:hi,configurable:!0,writable:!0},all:hi.all,race:hi.race,allSettled:hi.allSettled,any:hi.any,resolve:hi.resolve,reject:hi.reject,nthen:Vi(s.nthen,i),gthen:Vi(s.gthen,i)}:{},t&&Mr(i,t),++o.ref,i.finalize=function(){--this.parent.ref||this.parent.finalize()};var a=Li(i,e,n,r);return 0===i.ref&&i.finalize(),a}function Ni(){return ki.id||(ki.id=++Ai),++ki.awaits,ki.echoes+=100,ki.id}function Bi(){return!!ki.awaits&&(0==--ki.awaits&&(ki.id=0),ki.echoes=100*ki.awaits,!0)}function Ri(e){return ki.echoes&&e&&e.constructor===Qo?(Ni(),e.then((e=>(Bi(),e)),(e=>(Bi(),Hi(e))))):e}function Mi(e){++Ci,ki.echoes&&0!=--ki.echoes||(ki.echoes=ki.id=0),Ti.push(ui),Ui(e,!0)}function $i(){var e=Ti[Ti.length-1];Ti.pop(),Ui(e,!1)}function Ui(e,t){var n=ui;if((t?!ki.echoes||Di++&&e===ui:!Di||--Di&&e===ui)||qi(t?Mi.bind(null,e):$i),e!==ui&&(ui=e,n===ai&&(ai.env=Fi()),Jo)){var r=ai.env.Promise,o=e.env;Ho.then=o.nthen,r.prototype.then=o.gthen,(n.global||e.global)&&(Object.defineProperty(Nr,"Promise",o.PromiseProp),r.all=o.all,r.race=o.race,r.resolve=o.resolve,r.reject=o.reject,o.allSettled&&(r.allSettled=o.allSettled),o.any&&(r.any=o.any))}}function Fi(){var e=Nr.Promise;return Jo?{Promise:e,PromiseProp:Object.getOwnPropertyDescriptor(Nr,"Promise"),all:e.all,race:e.race,allSettled:e.allSettled,any:e.any,resolve:e.resolve,reject:e.reject,nthen:Ho.then,gthen:e.prototype.then}:{}}function Li(e,t,n,r,o){var i=ui;try{return Ui(e,!0),t(n,r,o)}finally{Ui(i,!1)}}function qi(e){Yo.call(Go,e)}function Wi(e,t,n,r){return"function"!=typeof e?e:function(){var o=ui;n&&Ni(),Ui(t,!0);try{return e.apply(this,arguments)}finally{Ui(o,!1),r&&qi(Bi)}}}function Vi(e,t){return function(n,r){return e.call(this,Wi(n,t),Wi(r,t))}}function Gi(e,t){var n;try{n=t.onuncatched(e)}catch(e){}if(!1!==n)try{var r,o={promise:t,reason:e};if(Nr.document&&document.createEvent?((r=document.createEvent("Event")).initEvent("unhandledrejection",!0,!0),Mr(r,o)):Nr.CustomEvent&&Mr(r=new CustomEvent("unhandledrejection",{detail:o}),o),r&&Nr.dispatchEvent&&(dispatchEvent(r),!Nr.PromiseRejectionEvent&&Nr.onunhandledrejection))try{Nr.onunhandledrejection(r)}catch(e){}bo&&r&&!r.defaultPrevented&&console.warn(`Unhandled rejection: ${e.stack||e}`)}catch(e){}}-1===(""+Yo).indexOf("[native code]")&&(Ni=Bi=Bo);var Hi=hi.reject;function zi(e,t,n,r){if(e.idbdb&&(e._state.openComplete||ui.letThrough||e._vip)){var o=e._createTransaction(t,n,e._dbSchema);try{o.create(),e._state.PR1398_maxLoop=3}catch(o){return o.name===Do.InvalidState&&e.isOpen()&&--e._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),e._close(),e.open().then((()=>zi(e,t,n,r)))):Hi(o)}return o._promise(t,((e,t)=>Ki((()=>(ui.trans=o,r(e,t,o)))))).then((e=>o._completion.then((()=>e))))}if(e._state.openComplete)return Hi(new Io.DatabaseClosed(e._state.dbOpenError));if(!e._state.isBeingOpened){if(!e._options.autoOpen)return Hi(new Io.DatabaseClosed);e.open().catch(Bo)}return e._state.dbReadyPromise.then((()=>zi(e,t,n,r)))}const Yi=String.fromCharCode(65535),Qi="Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.",Ji=[],Xi="undefined"!=typeof navigator&&/(MSIE|Trident|Edge)/.test(navigator.userAgent),Zi=Xi,es=Xi,ts=e=>!/(dexie\.js|dexie\.min\.js)/.test(e);function ns(e,t){return e?t?function(){return e.apply(this,arguments)&&t.apply(this,arguments)}:e:t}const rs={type:3,lower:-1/0,lowerOpen:!1,upper:[[]],upperOpen:!1};function os(e){return"string"!=typeof e||/\./.test(e)?e=>e:t=>(void 0===t[e]&&e in t&&delete(t=uo(t))[e],t)}class is{_trans(e,t,n){const r=this._tx||ui.trans,o=this.name;function i(e,n,r){if(!r.schema[o])throw new Io.NotFound("Table "+o+" not part of transaction");return t(r.idbtrans,r)}const s=Oi();try{return r&&r.db===this.db?r===ui.trans?r._promise(e,i,n):Ki((()=>r._promise(e,i,n)),{trans:r,transless:ui.transless||ui}):zi(this.db,e,[this.name],i)}finally{s&&Si()}}get(e,t){return e&&e.constructor===Object?this.where(e).first(t):this._trans("readonly",(t=>this.core.get({trans:t,key:e}).then((e=>this.hook.reading.fire(e))))).then(t)}where(e){if("string"==typeof e)return new this.db.WhereClause(this,e);if(Rr(e))return new this.db.WhereClause(this,`[${e.join("+")}]`);const t=Br(e);if(1===t.length)return this.where(t[0]).equals(e[t[0]]);const n=this.schema.indexes.concat(this.schema.primKey).filter((e=>e.compound&&t.every((t=>e.keyPath.indexOf(t)>=0))&&e.keyPath.every((e=>t.indexOf(e)>=0))))[0];if(n&&this.db._maxKey!==Yi)return this.where(n.name).equals(n.keyPath.map((t=>e[t])));!n&&bo&&console.warn(`The query ${JSON.stringify(e)} on ${this.name} would benefit of a compound index [${t.join("+")}]`);const{idxByName:r}=this.schema,o=this.db._deps.indexedDB;function i(e,t){try{return 0===o.cmp(e,t)}catch(e){return!1}}const[s,a]=t.reduce((([t,n],o)=>{const s=r[o],a=e[o];return[t||s,t||!s?ns(n,s&&s.multi?e=>{const t=eo(e,o);return Rr(t)&&t.some((e=>i(a,e)))}:e=>i(a,eo(e,o))):n]}),[null,null]);return s?this.where(s.name).equals(e[s.keyPath]).filter(a):n?this.filter(a):this.where(t).equals("")}filter(e){return this.toCollection().and(e)}count(e){return this.toCollection().count(e)}offset(e){return this.toCollection().offset(e)}limit(e){return this.toCollection().limit(e)}each(e){return this.toCollection().each(e)}toArray(e){return this.toCollection().toArray(e)}toCollection(){return new this.db.Collection(new this.db.WhereClause(this))}orderBy(e){return new this.db.Collection(new this.db.WhereClause(this,Rr(e)?`[${e.join("+")}]`:e))}reverse(){return this.toCollection().reverse()}mapToClass(e){this.schema.mappedClass=e;const t=t=>{if(!t)return t;const n=Object.create(e.prototype);for(var r in t)if(Fr(t,r))try{n[r]=t[r]}catch(e){}return n};return this.schema.readHook&&this.hook.reading.unsubscribe(this.schema.readHook),this.schema.readHook=t,this.hook("reading",t),e}defineClass(){return this.mapToClass((function(e){Mr(this,e)}))}add(e,t){const{auto:n,keyPath:r}=this.schema.primKey;let o=e;return r&&n&&(o=os(r)(e)),this._trans("readwrite",(e=>this.core.mutate({trans:e,type:"add",keys:null!=t?[t]:null,values:[o]}))).then((e=>e.numFailures?hi.reject(e.failures[0]):e.lastResult)).then((t=>{if(r)try{to(e,r,t)}catch(e){}return t}))}update(e,t){if("object"!=typeof e||Rr(e))return this.where(":id").equals(e).modify(t);{const n=eo(e,this.schema.primKey.keyPath);if(void 0===n)return Hi(new Io.InvalidArgument("Given object does not contain its primary key"));try{"function"!=typeof t?Br(t).forEach((n=>{to(e,n,t[n])})):t(e,{value:e,primKey:n})}catch(e){}return this.where(":id").equals(n).modify(t)}}put(e,t){const{auto:n,keyPath:r}=this.schema.primKey;let o=e;return r&&n&&(o=os(r)(e)),this._trans("readwrite",(e=>this.core.mutate({trans:e,type:"put",values:[o],keys:null!=t?[t]:null}))).then((e=>e.numFailures?hi.reject(e.failures[0]):e.lastResult)).then((t=>{if(r)try{to(e,r,t)}catch(e){}return t}))}delete(e){return this._trans("readwrite",(t=>this.core.mutate({trans:t,type:"delete",keys:[e]}))).then((e=>e.numFailures?hi.reject(e.failures[0]):void 0))}clear(){return this._trans("readwrite",(e=>this.core.mutate({trans:e,type:"deleteRange",range:rs}))).then((e=>e.numFailures?hi.reject(e.failures[0]):void 0))}bulkGet(e){return this._trans("readonly",(t=>this.core.getMany({keys:e,trans:t}).then((e=>e.map((e=>this.hook.reading.fire(e)))))))}bulkAdd(e,t,n){const r=Array.isArray(t)?t:void 0,o=(n=n||(r?void 0:t))?n.allKeys:void 0;return this._trans("readwrite",(t=>{const{auto:n,keyPath:i}=this.schema.primKey;if(i&&r)throw new Io.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(r&&r.length!==e.length)throw new Io.InvalidArgument("Arguments objects and keys must have the same length");const s=e.length;let a=i&&n?e.map(os(i)):e;return this.core.mutate({trans:t,type:"add",keys:r,values:a,wantResults:o}).then((({numFailures:e,results:t,lastResult:n,failures:r})=>{if(0===e)return o?t:n;throw new To(`${this.name}.bulkAdd(): ${e} of ${s} operations failed`,r)}))}))}bulkPut(e,t,n){const r=Array.isArray(t)?t:void 0,o=(n=n||(r?void 0:t))?n.allKeys:void 0;return this._trans("readwrite",(t=>{const{auto:n,keyPath:i}=this.schema.primKey;if(i&&r)throw new Io.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(r&&r.length!==e.length)throw new Io.InvalidArgument("Arguments objects and keys must have the same length");const s=e.length;let a=i&&n?e.map(os(i)):e;return this.core.mutate({trans:t,type:"put",keys:r,values:a,wantResults:o}).then((({numFailures:e,results:t,lastResult:n,failures:r})=>{if(0===e)return o?t:n;throw new To(`${this.name}.bulkPut(): ${e} of ${s} operations failed`,r)}))}))}bulkDelete(e){const t=e.length;return this._trans("readwrite",(t=>this.core.mutate({trans:t,type:"delete",keys:e}))).then((({numFailures:e,lastResult:n,failures:r})=>{if(0===e)return n;throw new To(`${this.name}.bulkDelete(): ${e} of ${t} operations failed`,r)}))}}function ss(e){var t={},n=function(n,r){if(r){for(var o=arguments.length,i=new Array(o-1);--o;)i[o-1]=arguments[o];return t[n].subscribe.apply(null,i),e}if("string"==typeof n)return t[n]};n.addEventType=i;for(var r=1,o=arguments.length;r<o;++r)i(arguments[r]);return n;function i(e,r,o){if("object"==typeof e)return function(e){Br(e).forEach((function(t){var n=e[t];if(Rr(n))i(t,e[t][0],e[t][1]);else{if("asap"!==n)throw new Io.InvalidArgument("Invalid event config");var r=i(t,Ro,(function(){for(var e=arguments.length,t=new Array(e);e--;)t[e]=arguments[e];r.subscribers.forEach((function(e){Xr((function(){e.apply(null,t)}))}))}))}}))}(e);r||(r=qo),o||(o=Bo);var s={subscribers:[],fire:o,subscribe:function(e){-1===s.subscribers.indexOf(e)&&(s.subscribers.push(e),s.fire=r(s.fire,e))},unsubscribe:function(e){s.subscribers=s.subscribers.filter((function(t){return t!==e})),s.fire=s.subscribers.reduce(r,o)}};return t[e]=n[e]=s,s}}function as(e,t){return Vr(t).from({prototype:e}),t}function us(e,t){return!(e.filter||e.algorithm||e.or)&&(t?e.justLimit:!e.replayFilter)}function cs(e,t){e.filter=ns(e.filter,t)}function ls(e,t,n){var r=e.replayFilter;e.replayFilter=r?()=>ns(r(),t()):t,e.justLimit=n&&!r}function fs(e,t){if(e.isPrimKey)return t.primaryKey;const n=t.getIndexByKeyPath(e.index);if(!n)throw new Io.Schema("KeyPath "+e.index+" on object store "+t.name+" is not indexed");return n}function hs(e,t,n){const r=fs(e,t.schema);return t.openCursor({trans:n,values:!e.keysOnly,reverse:"prev"===e.dir,unique:!!e.unique,query:{index:r,range:e.range}})}function ds(e,t,n,r){const o=e.replayFilter?ns(e.filter,e.replayFilter()):e.filter;if(e.or){const i={},s=(e,n,r)=>{if(!o||o(n,r,(e=>n.stop(e)),(e=>n.fail(e)))){var s=n.primaryKey,a=""+s;"[object ArrayBuffer]"===a&&(a=""+new Uint8Array(s)),Fr(i,a)||(i[a]=!0,t(e,n,r))}};return Promise.all([e.or._iterate(s,n),ps(hs(e,r,n),e.algorithm,s,!e.keysOnly&&e.valueMapper)])}return ps(hs(e,r,n),ns(e.algorithm,o),t,!e.keysOnly&&e.valueMapper)}function ps(e,t,n,r){var o=ji(r?(e,t,o)=>n(r(e),t,o):n);return e.then((e=>{if(e)return e.start((()=>{var n=()=>e.continue();t&&!t(e,(e=>n=e),(t=>{e.stop(t),n=Bo}),(t=>{e.fail(t),n=Bo}))||o(e.value,e,(e=>n=e)),n()}))}))}function ys(e,t){try{const n=ms(e),r=ms(t);if(n!==r)return"Array"===n?1:"Array"===r?-1:"binary"===n?1:"binary"===r?-1:"string"===n?1:"string"===r?-1:"Date"===n?1:"Date"!==r?NaN:-1;switch(n){case"number":case"Date":case"string":return e>t?1:e<t?-1:0;case"binary":return function(e,t){const n=e.length,r=t.length,o=n<r?n:r;for(let n=0;n<o;++n)if(e[n]!==t[n])return e[n]<t[n]?-1:1;return n===r?0:n<r?-1:1}(vs(e),vs(t));case"Array":return function(e,t){const n=e.length,r=t.length,o=n<r?n:r;for(let n=0;n<o;++n){const r=ys(e[n],t[n]);if(0!==r)return r}return n===r?0:n<r?-1:1}(e,t)}}catch(e){}return NaN}function ms(e){const t=typeof e;if("object"!==t)return t;if(ArrayBuffer.isView(e))return"binary";const n=fo(e);return"ArrayBuffer"===n?"binary":n}function vs(e){return e instanceof Uint8Array?e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e)}class bs{_read(e,t){var n=this._ctx;return n.error?n.table._trans(null,Hi.bind(null,n.error)):n.table._trans("readonly",e).then(t)}_write(e){var t=this._ctx;return t.error?t.table._trans(null,Hi.bind(null,t.error)):t.table._trans("readwrite",e,"locked")}_addAlgorithm(e){var t=this._ctx;t.algorithm=ns(t.algorithm,e)}_iterate(e,t){return ds(this._ctx,e,t,this._ctx.table.core)}clone(e){var t=Object.create(this.constructor.prototype),n=Object.create(this._ctx);return e&&Mr(n,e),t._ctx=n,t}raw(){return this._ctx.valueMapper=null,this}each(e){var t=this._ctx;return this._read((n=>ds(t,e,n,t.table.core)))}count(e){return this._read((e=>{const t=this._ctx,n=t.table.core;if(us(t,!0))return n.count({trans:e,query:{index:fs(t,n.schema),range:t.range}}).then((e=>Math.min(e,t.limit)));var r=0;return ds(t,(()=>(++r,!1)),e,n).then((()=>r))})).then(e)}sortBy(e,t){const n=e.split(".").reverse(),r=n[0],o=n.length-1;function i(e,t){return t?i(e[n[t]],t-1):e[r]}var s="next"===this._ctx.dir?1:-1;function a(e,t){var n=i(e,o),r=i(t,o);return n<r?-s:n>r?s:0}return this.toArray((function(e){return e.sort(a)})).then(t)}toArray(e){return this._read((e=>{var t=this._ctx;if("next"===t.dir&&us(t,!0)&&t.limit>0){const{valueMapper:n}=t,r=fs(t,t.table.core.schema);return t.table.core.query({trans:e,limit:t.limit,values:!0,query:{index:r,range:t.range}}).then((({result:e})=>n?e.map(n):e))}{const n=[];return ds(t,(e=>n.push(e)),e,t.table.core).then((()=>n))}}),e)}offset(e){var t=this._ctx;return e<=0||(t.offset+=e,us(t)?ls(t,(()=>{var t=e;return(e,n)=>0===t||(1===t?(--t,!1):(n((()=>{e.advance(t),t=0})),!1))})):ls(t,(()=>{var t=e;return()=>--t<0}))),this}limit(e){return this._ctx.limit=Math.min(this._ctx.limit,e),ls(this._ctx,(()=>{var t=e;return function(e,n,r){return--t<=0&&n(r),t>=0}}),!0),this}until(e,t){return cs(this._ctx,(function(n,r,o){return!e(n.value)||(r(o),t)})),this}first(e){return this.limit(1).toArray((function(e){return e[0]})).then(e)}last(e){return this.reverse().first(e)}filter(e){var t,n;return cs(this._ctx,(function(t){return e(t.value)})),t=this._ctx,n=e,t.isMatch=ns(t.isMatch,n),this}and(e){return this.filter(e)}or(e){return new this.db.WhereClause(this._ctx.table,e,this)}reverse(){return this._ctx.dir="prev"===this._ctx.dir?"next":"prev",this._ondirectionchange&&this._ondirectionchange(this._ctx.dir),this}desc(){return this.reverse()}eachKey(e){var t=this._ctx;return t.keysOnly=!t.isMatch,this.each((function(t,n){e(n.key,n)}))}eachUniqueKey(e){return this._ctx.unique="unique",this.eachKey(e)}eachPrimaryKey(e){var t=this._ctx;return t.keysOnly=!t.isMatch,this.each((function(t,n){e(n.primaryKey,n)}))}keys(e){var t=this._ctx;t.keysOnly=!t.isMatch;var n=[];return this.each((function(e,t){n.push(t.key)})).then((function(){return n})).then(e)}primaryKeys(e){var t=this._ctx;if("next"===t.dir&&us(t,!0)&&t.limit>0)return this._read((e=>{var n=fs(t,t.table.core.schema);return t.table.core.query({trans:e,values:!1,limit:t.limit,query:{index:n,range:t.range}})})).then((({result:e})=>e)).then(e);t.keysOnly=!t.isMatch;var n=[];return this.each((function(e,t){n.push(t.primaryKey)})).then((function(){return n})).then(e)}uniqueKeys(e){return this._ctx.unique="unique",this.keys(e)}firstKey(e){return this.limit(1).keys((function(e){return e[0]})).then(e)}lastKey(e){return this.reverse().firstKey(e)}distinct(){var e=this._ctx,t=e.index&&e.table.schema.idxByName[e.index];if(!t||!t.multi)return this;var n={};return cs(this._ctx,(function(e){var t=e.primaryKey.toString(),r=Fr(n,t);return n[t]=!0,!r})),this}modify(e){var t=this._ctx;return this._write((n=>{var r;if("function"==typeof e)r=e;else{var o=Br(e),i=o.length;r=function(t){for(var n=!1,r=0;r<i;++r){var s=o[r],a=e[s];eo(t,s)!==a&&(to(t,s,a),n=!0)}return n}}const s=t.table.core,{outbound:a,extractKey:u}=s.schema.primaryKey,c=this.db._options.modifyChunkSize||200,l=[];let f=0;const h=[],d=(e,t)=>{const{failures:n,numFailures:r}=t;f+=e-r;for(let e of Br(n))l.push(n[e])};return this.clone().primaryKeys().then((o=>{const i=l=>{const f=Math.min(c,o.length-l);return s.getMany({trans:n,keys:o.slice(l,l+f),cache:"immutable"}).then((h=>{const p=[],y=[],m=a?[]:null,v=[];for(let e=0;e<f;++e){const t=h[e],n={value:uo(t),primKey:o[l+e]};!1!==r.call(n,n.value,n)&&(null==n.value?v.push(o[l+e]):a||0===ys(u(t),u(n.value))?(y.push(n.value),a&&m.push(o[l+e])):(v.push(o[l+e]),p.push(n.value)))}const b=us(t)&&t.limit===1/0&&("function"!=typeof e||e===gs)&&{index:t.index,range:t.range};return Promise.resolve(p.length>0&&s.mutate({trans:n,type:"add",values:p}).then((e=>{for(let t in e.failures)v.splice(parseInt(t),1);d(p.length,e)}))).then((()=>(y.length>0||b&&"object"==typeof e)&&s.mutate({trans:n,type:"put",keys:m,values:y,criteria:b,changeSpec:"function"!=typeof e&&e}).then((e=>d(y.length,e))))).then((()=>(v.length>0||b&&e===gs)&&s.mutate({trans:n,type:"delete",keys:v,criteria:b}).then((e=>d(v.length,e))))).then((()=>o.length>l+f&&i(l+c)))}))};return i(0).then((()=>{if(l.length>0)throw new Ao("Error modifying one or more objects",l,f,h);return o.length}))}))}))}delete(){var e=this._ctx,t=e.range;return us(e)&&(e.isPrimKey&&!es||3===t.type)?this._write((n=>{const{primaryKey:r}=e.table.core.schema,o=t;return e.table.core.count({trans:n,query:{index:r,range:o}}).then((t=>e.table.core.mutate({trans:n,type:"deleteRange",range:o}).then((({failures:e,lastResult:n,results:r,numFailures:o})=>{if(o)throw new Ao("Could not delete some values",Object.keys(e).map((t=>e[t])),t-o);return t-o}))))})):this.modify(gs)}}const gs=(e,t)=>t.value=null;function ws(e,t){return e<t?-1:e===t?0:1}function _s(e,t){return e>t?-1:e===t?0:1}function Es(e,t,n){var r=e instanceof ks?new e.Collection(e):e;return r._ctx.error=n?new n(t):new TypeError(t),r}function Os(e){return new e.Collection(e,(()=>js(""))).limit(0)}function Ss(e,t,n,r,o,i){for(var s=Math.min(e.length,r.length),a=-1,u=0;u<s;++u){var c=t[u];if(c!==r[u])return o(e[u],n[u])<0?e.substr(0,u)+n[u]+n.substr(u+1):o(e[u],r[u])<0?e.substr(0,u)+r[u]+n.substr(u+1):a>=0?e.substr(0,a)+t[a]+n.substr(a+1):null;o(e[u],c)<0&&(a=u)}return s<r.length&&"next"===i?e+n.substr(e.length):s<e.length&&"prev"===i?e.substr(0,n.length):a<0?null:e.substr(0,a)+r[a]+n.substr(a+1)}function Ps(e,t,n,r){var o,i,s,a,u,c,l,f=n.length;if(!n.every((e=>"string"==typeof e)))return Es(e,"String expected.");function h(e){o=function(e){return"next"===e?e=>e.toUpperCase():e=>e.toLowerCase()}(e),i=function(e){return"next"===e?e=>e.toLowerCase():e=>e.toUpperCase()}(e),s="next"===e?ws:_s;var t=n.map((function(e){return{lower:i(e),upper:o(e)}})).sort((function(e,t){return s(e.lower,t.lower)}));a=t.map((function(e){return e.upper})),u=t.map((function(e){return e.lower})),c=e,l="next"===e?"":r}h("next");var d=new e.Collection(e,(()=>xs(a[0],u[f-1]+r)));d._ondirectionchange=function(e){h(e)};var p=0;return d._addAlgorithm((function(e,n,r){var o=e.key;if("string"!=typeof o)return!1;var h=i(o);if(t(h,u,p))return!0;for(var d=null,y=p;y<f;++y){var m=Ss(o,h,a[y],u[y],s,c);null===m&&null===d?p=y+1:(null===d||s(d,m)>0)&&(d=m)}return n(null!==d?function(){e.continue(d+l)}:r),!1})),d}function xs(e,t,n,r){return{type:2,lower:e,upper:t,lowerOpen:n,upperOpen:r}}function js(e){return{type:1,lower:e,upper:e}}class ks{get Collection(){return this._ctx.table.db.Collection}between(e,t,n,r){n=!1!==n,r=!0===r;try{return this._cmp(e,t)>0||0===this._cmp(e,t)&&(n||r)&&(!n||!r)?Os(this):new this.Collection(this,(()=>xs(e,t,!n,!r)))}catch(e){return Es(this,Qi)}}equals(e){return null==e?Es(this,Qi):new this.Collection(this,(()=>js(e)))}above(e){return null==e?Es(this,Qi):new this.Collection(this,(()=>xs(e,void 0,!0)))}aboveOrEqual(e){return null==e?Es(this,Qi):new this.Collection(this,(()=>xs(e,void 0,!1)))}below(e){return null==e?Es(this,Qi):new this.Collection(this,(()=>xs(void 0,e,!1,!0)))}belowOrEqual(e){return null==e?Es(this,Qi):new this.Collection(this,(()=>xs(void 0,e)))}startsWith(e){return"string"!=typeof e?Es(this,"String expected."):this.between(e,e+Yi,!0,!0)}startsWithIgnoreCase(e){return""===e?this.startsWith(e):Ps(this,((e,t)=>0===e.indexOf(t[0])),[e],Yi)}equalsIgnoreCase(e){return Ps(this,((e,t)=>e===t[0]),[e],"")}anyOfIgnoreCase(){var e=mo.apply(yo,arguments);return 0===e.length?Os(this):Ps(this,((e,t)=>-1!==t.indexOf(e)),e,"")}startsWithAnyOfIgnoreCase(){var e=mo.apply(yo,arguments);return 0===e.length?Os(this):Ps(this,((e,t)=>t.some((t=>0===e.indexOf(t)))),e,Yi)}anyOf(){const e=mo.apply(yo,arguments);let t=this._cmp;try{e.sort(t)}catch(e){return Es(this,Qi)}if(0===e.length)return Os(this);const n=new this.Collection(this,(()=>xs(e[0],e[e.length-1])));n._ondirectionchange=n=>{t="next"===n?this._ascending:this._descending,e.sort(t)};let r=0;return n._addAlgorithm(((n,o,i)=>{const s=n.key;for(;t(s,e[r])>0;)if(++r,r===e.length)return o(i),!1;return 0===t(s,e[r])||(o((()=>{n.continue(e[r])})),!1)})),n}notEqual(e){return this.inAnyRange([[-1/0,e],[e,this.db._maxKey]],{includeLowers:!1,includeUppers:!1})}noneOf(){const e=mo.apply(yo,arguments);if(0===e.length)return new this.Collection(this);try{e.sort(this._ascending)}catch(e){return Es(this,Qi)}const t=e.reduce(((e,t)=>e?e.concat([[e[e.length-1][1],t]]):[[-1/0,t]]),null);return t.push([e[e.length-1],this.db._maxKey]),this.inAnyRange(t,{includeLowers:!1,includeUppers:!1})}inAnyRange(e,t){const n=this._cmp,r=this._ascending,o=this._descending,i=this._min,s=this._max;if(0===e.length)return Os(this);if(!e.every((e=>void 0!==e[0]&&void 0!==e[1]&&r(e[0],e[1])<=0)))return Es(this,"First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower",Io.InvalidArgument);const a=!t||!1!==t.includeLowers,u=t&&!0===t.includeUppers;let c,l=r;function f(e,t){return l(e[0],t[0])}try{c=e.reduce((function(e,t){let r=0,o=e.length;for(;r<o;++r){const o=e[r];if(n(t[0],o[1])<0&&n(t[1],o[0])>0){o[0]=i(o[0],t[0]),o[1]=s(o[1],t[1]);break}}return r===o&&e.push(t),e}),[]),c.sort(f)}catch(e){return Es(this,Qi)}let h=0;const d=u?e=>r(e,c[h][1])>0:e=>r(e,c[h][1])>=0,p=a?e=>o(e,c[h][0])>0:e=>o(e,c[h][0])>=0;let y=d;const m=new this.Collection(this,(()=>xs(c[0][0],c[c.length-1][1],!a,!u)));return m._ondirectionchange=e=>{"next"===e?(y=d,l=r):(y=p,l=o),c.sort(f)},m._addAlgorithm(((e,t,n)=>{for(var o=e.key;y(o);)if(++h,h===c.length)return t(n),!1;return!!function(e){return!d(e)&&!p(e)}(o)||(0===this._cmp(o,c[h][1])||0===this._cmp(o,c[h][0])||t((()=>{l===r?e.continue(c[h][0]):e.continue(c[h][1])})),!1)})),m}startsWithAnyOf(){const e=mo.apply(yo,arguments);return e.every((e=>"string"==typeof e))?0===e.length?Os(this):this.inAnyRange(e.map((e=>[e,e+Yi]))):Es(this,"startsWithAnyOf() only works with strings")}}function As(e){return ji((function(t){return Ts(t),e(t.target.error),!1}))}function Ts(e){e.stopPropagation&&e.stopPropagation(),e.preventDefault&&e.preventDefault()}const Ds=ss(null,"storagemutated");class Cs{_lock(){return Jr(!ui.global),++this._reculock,1!==this._reculock||ui.global||(ui.lockOwnerFor=this),this}_unlock(){if(Jr(!ui.global),0==--this._reculock)for(ui.global||(ui.lockOwnerFor=null);this._blockedFuncs.length>0&&!this._locked();){var e=this._blockedFuncs.shift();try{Li(e[1],e[0])}catch(e){}}return this}_locked(){return this._reculock&&ui.lockOwnerFor!==this}create(e){if(!this.mode)return this;const t=this.db.idbdb,n=this.db._state.dbOpenError;if(Jr(!this.idbtrans),!e&&!t)switch(n&&n.name){case"DatabaseClosedError":throw new Io.DatabaseClosed(n);case"MissingAPIError":throw new Io.MissingAPI(n.message,n);default:throw new Io.OpenFailed(n)}if(!this.active)throw new Io.TransactionInactive;return Jr(null===this._completion._state),(e=this.idbtrans=e||(this.db.core?this.db.core.transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability}):t.transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability}))).onerror=ji((t=>{Ts(t),this._reject(e.error)})),e.onabort=ji((t=>{Ts(t),this.active&&this._reject(new Io.Abort(e.error)),this.active=!1,this.on("abort").fire(t)})),e.oncomplete=ji((()=>{this.active=!1,this._resolve(),"mutatedParts"in e&&Ds.storagemutated.fire(e.mutatedParts)})),this}_promise(e,t,n){if("readwrite"===e&&"readwrite"!==this.mode)return Hi(new Io.ReadOnly("Transaction is readonly"));if(!this.active)return Hi(new Io.TransactionInactive);if(this._locked())return new hi(((r,o)=>{this._blockedFuncs.push([()=>{this._promise(e,t,n).then(r,o)},ui])}));if(n)return Ki((()=>{var e=new hi(((e,n)=>{this._lock();const r=t(e,n,this);r&&r.then&&r.then(e,n)}));return e.finally((()=>this._unlock())),e._lib=!0,e}));var r=new hi(((e,n)=>{var r=t(e,n,this);r&&r.then&&r.then(e,n)}));return r._lib=!0,r}_root(){return this.parent?this.parent._root():this}waitFor(e){var t=this._root();const n=hi.resolve(e);if(t._waitingFor)t._waitingFor=t._waitingFor.then((()=>n));else{t._waitingFor=n,t._waitingQueue=[];var r=t.idbtrans.objectStore(t.storeNames[0]);!function e(){for(++t._spinCount;t._waitingQueue.length;)t._waitingQueue.shift()();t._waitingFor&&(r.get(-1/0).onsuccess=e)}()}var o=t._waitingFor;return new hi(((e,r)=>{n.then((n=>t._waitingQueue.push(ji(e.bind(null,n)))),(e=>t._waitingQueue.push(ji(r.bind(null,e))))).finally((()=>{t._waitingFor===o&&(t._waitingFor=null)}))}))}abort(){this.active&&(this.active=!1,this.idbtrans&&this.idbtrans.abort(),this._reject(new Io.Abort))}table(e){const t=this._memoizedTables||(this._memoizedTables={});if(Fr(t,e))return t[e];const n=this.schema[e];if(!n)throw new Io.NotFound("Table "+e+" not part of transaction");const r=new this.db.Table(e,n,this);return r.core=this.db.core.table(e),t[e]=r,r}}function Is(e,t,n,r,o,i,s){return{name:e,keyPath:t,unique:n,multi:r,auto:o,compound:i,src:(n&&!s?"&":"")+(r?"*":"")+(o?"++":"")+Ks(t)}}function Ks(e){return"string"==typeof e?e:e?"["+[].join.call(e,"+")+"]":""}function Ns(e,t,n){return{name:e,primKey:t,indexes:n,mappedClass:null,idxByName:Zr(n,(e=>[e.name,e]))}}let Bs=e=>{try{return e.only([[]]),Bs=()=>[[]],[[]]}catch(e){return Bs=()=>Yi,Yi}};function Rs(e){return null==e?()=>{}:"string"==typeof e?function(e){return 1===e.split(".").length?t=>t[e]:t=>eo(t,e)}(e):t=>eo(t,e)}function Ms(e){return[].slice.call(e)}let $s=0;function Us(e){return null==e?":id":"string"==typeof e?e:`[${e.join("+")}]`}function Fs({_novip:e},t){const n=t.db,r=function(e,t,{IDBKeyRange:n,indexedDB:r},o){const i=function(e,t){return t.reduce(((e,{create:t})=>({...e,...t(e)})),e)}(function(e,t,n){function r(e){if(3===e.type)return null;if(4===e.type)throw new Error("Cannot convert never type to IDBKeyRange");const{lower:n,upper:r,lowerOpen:o,upperOpen:i}=e;return void 0===n?void 0===r?null:t.upperBound(r,!!i):void 0===r?t.lowerBound(n,!!o):t.bound(n,r,!!o,!!i)}const{schema:o,hasGetAll:i}=function(e,t){const n=Ms(e.objectStoreNames);return{schema:{name:e.name,tables:n.map((e=>t.objectStore(e))).map((e=>{const{keyPath:t,autoIncrement:n}=e,r=Rr(t),o=null==t,i={},s={name:e.name,primaryKey:{name:null,isPrimaryKey:!0,outbound:o,compound:r,keyPath:t,autoIncrement:n,unique:!0,extractKey:Rs(t)},indexes:Ms(e.indexNames).map((t=>e.index(t))).map((e=>{const{name:t,unique:n,multiEntry:r,keyPath:o}=e,s={name:t,compound:Rr(o),keyPath:o,unique:n,multiEntry:r,extractKey:Rs(o)};return i[Us(o)]=s,s})),getIndexByKeyPath:e=>i[Us(e)]};return i[":id"]=s.primaryKey,null!=t&&(i[Us(t)]=s.primaryKey),s}))},hasGetAll:n.length>0&&"getAll"in t.objectStore(n[0])&&!("undefined"!=typeof navigator&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604)}}(e,n),s=o.tables.map((e=>function(e){const t=e.name;return{name:t,schema:e,mutate:function({trans:e,type:n,keys:o,values:i,range:s}){return new Promise(((a,u)=>{a=ji(a);const c=e.objectStore(t),l=null==c.keyPath,f="put"===n||"add"===n;if(!f&&"delete"!==n&&"deleteRange"!==n)throw new Error("Invalid operation type: "+n);const{length:h}=o||i||{length:1};if(o&&i&&o.length!==i.length)throw new Error("Given keys array must have same length as given values array.");if(0===h)return a({numFailures:0,failures:{},results:[],lastResult:void 0});let d;const p=[],y=[];let m=0;const v=e=>{++m,Ts(e)};if("deleteRange"===n){if(4===s.type)return a({numFailures:m,failures:y,results:[],lastResult:void 0});3===s.type?p.push(d=c.clear()):p.push(d=c.delete(r(s)))}else{const[e,t]=f?l?[i,o]:[i,null]:[o,null];if(f)for(let r=0;r<h;++r)p.push(d=t&&void 0!==t[r]?c[n](e[r],t[r]):c[n](e[r])),d.onerror=v;else for(let t=0;t<h;++t)p.push(d=c[n](e[t])),d.onerror=v}const b=e=>{const t=e.target.result;p.forEach(((e,t)=>null!=e.error&&(y[t]=e.error))),a({numFailures:m,failures:y,results:"delete"===n?o:p.map((e=>e.result)),lastResult:t})};d.onerror=e=>{v(e),b(e)},d.onsuccess=b}))},getMany:({trans:e,keys:n})=>new Promise(((r,o)=>{r=ji(r);const i=e.objectStore(t),s=n.length,a=new Array(s);let u,c=0,l=0;const f=e=>{const t=e.target;a[t._pos]=t.result,++l===c&&r(a)},h=As(o);for(let e=0;e<s;++e)null!=n[e]&&(u=i.get(n[e]),u._pos=e,u.onsuccess=f,u.onerror=h,++c);0===c&&r(a)})),get:({trans:e,key:n})=>new Promise(((r,o)=>{r=ji(r);const i=e.objectStore(t).get(n);i.onsuccess=e=>r(e.target.result),i.onerror=As(o)})),query:function(e){return n=>new Promise(((o,i)=>{o=ji(o);const{trans:s,values:a,limit:u,query:c}=n,l=u===1/0?void 0:u,{index:f,range:h}=c,d=s.objectStore(t),p=f.isPrimaryKey?d:d.index(f.name),y=r(h);if(0===u)return o({result:[]});if(e){const e=a?p.getAll(y,l):p.getAllKeys(y,l);e.onsuccess=e=>o({result:e.target.result}),e.onerror=As(i)}else{let e=0;const t=a||!("openKeyCursor"in p)?p.openCursor(y):p.openKeyCursor(y),n=[];t.onsuccess=r=>{const i=t.result;return i?(n.push(a?i.value:i.primaryKey),++e===u?o({result:n}):void i.continue()):o({result:n})},t.onerror=As(i)}}))}(i),openCursor:function({trans:e,values:n,query:o,reverse:i,unique:s}){return new Promise(((a,u)=>{a=ji(a);const{index:c,range:l}=o,f=e.objectStore(t),h=c.isPrimaryKey?f:f.index(c.name),d=i?s?"prevunique":"prev":s?"nextunique":"next",p=n||!("openKeyCursor"in h)?h.openCursor(r(l),d):h.openKeyCursor(r(l),d);p.onerror=As(u),p.onsuccess=ji((t=>{const n=p.result;if(!n)return void a(null);n.___id=++$s,n.done=!1;const r=n.continue.bind(n);let o=n.continuePrimaryKey;o&&(o=o.bind(n));const i=n.advance.bind(n),s=()=>{throw new Error("Cursor not stopped")};n.trans=e,n.stop=n.continue=n.continuePrimaryKey=n.advance=()=>{throw new Error("Cursor not started")},n.fail=ji(u),n.next=function(){let e=1;return this.start((()=>e--?this.continue():this.stop())).then((()=>this))},n.start=e=>{const t=new Promise(((e,t)=>{e=ji(e),p.onerror=As(t),n.fail=t,n.stop=t=>{n.stop=n.continue=n.continuePrimaryKey=n.advance=s,e(t)}})),a=()=>{if(p.result)try{e()}catch(e){n.fail(e)}else n.done=!0,n.start=()=>{throw new Error("Cursor behind last entry")},n.stop()};return p.onsuccess=ji((e=>{p.onsuccess=a,a()})),n.continue=r,n.continuePrimaryKey=o,n.advance=i,a(),t},a(n)}),u)}))},count({query:e,trans:n}){const{index:o,range:i}=e;return new Promise(((e,s)=>{const a=n.objectStore(t),u=o.isPrimaryKey?a:a.index(o.name),c=r(i),l=c?u.count(c):u.count();l.onsuccess=ji((t=>e(t.target.result))),l.onerror=As(s)}))}}}(e))),a={};return s.forEach((e=>a[e.name]=e)),{stack:"dbcore",transaction:e.transaction.bind(e),table(e){if(!a[e])throw new Error(`Table '${e}' not found`);return a[e]},MIN_KEY:-1/0,MAX_KEY:Bs(t),schema:o}}(t,n,o),e.dbcore);return{dbcore:i}}(e._middlewares,n,e._deps,t);e.core=r.dbcore,e.tables.forEach((t=>{const n=t.name;e.core.schema.tables.some((e=>e.name===n))&&(t.core=e.core.table(n),e[n]instanceof e.Table&&(e[n].core=t.core))}))}function Ls({_novip:e},t,n,r){n.forEach((n=>{const o=r[n];t.forEach((t=>{const r=Hr(t,n);(!r||"value"in r&&void 0===r.value)&&(t===e.Transaction.prototype||t instanceof e.Transaction?Wr(t,n,{get(){return this.table(n)},set(e){qr(this,n,{value:e,writable:!0,configurable:!0,enumerable:!0})}}):t[n]=new e.Table(n,o))}))}))}function qs({_novip:e},t){t.forEach((t=>{for(let n in t)t[n]instanceof e.Table&&delete t[n]}))}function Ws(e,t){return e._cfg.version-t._cfg.version}function Vs(e,t){const n={del:[],add:[],change:[]};let r;for(r in e)t[r]||n.del.push(r);for(r in t){const o=e[r],i=t[r];if(o){const e={name:r,def:i,recreate:!1,del:[],add:[],change:[]};if(""+(o.primKey.keyPath||"")!=""+(i.primKey.keyPath||"")||o.primKey.auto!==i.primKey.auto&&!Xi)e.recreate=!0,n.change.push(e);else{const t=o.idxByName,r=i.idxByName;let s;for(s in t)r[s]||e.del.push(s);for(s in r){const n=t[s],o=r[s];n?n.src!==o.src&&e.change.push(o):e.add.push(o)}(e.del.length>0||e.add.length>0||e.change.length>0)&&n.change.push(e)}}else n.add.push([r,i])}return n}function Gs(e,t,n,r){const o=e.db.createObjectStore(t,n.keyPath?{keyPath:n.keyPath,autoIncrement:n.auto}:{autoIncrement:n.auto});return r.forEach((e=>Hs(o,e))),o}function Hs(e,t){e.createIndex(t.name,t.keyPath,{unique:t.unique,multiEntry:t.multi})}function zs(e,t,n){const r={};return Yr(t.objectStoreNames,0).forEach((e=>{const t=n.objectStore(e);let o=t.keyPath;const i=Is(Ks(o),o||"",!1,!1,!!t.autoIncrement,o&&"string"!=typeof o,!0),s=[];for(let e=0;e<t.indexNames.length;++e){const n=t.index(t.indexNames[e]);o=n.keyPath;var a=Is(n.name,o,!!n.unique,!!n.multiEntry,!1,o&&"string"!=typeof o,!1);s.push(a)}r[e]=Ns(e,i,s)})),r}function Ys({_novip:e},t,n){const r=n.db.objectStoreNames;for(let o=0;o<r.length;++o){const i=r[o],s=n.objectStore(i);e._hasGetAll="getAll"in s;for(let e=0;e<s.indexNames.length;++e){const n=s.indexNames[e],r=s.index(n).keyPath,o="string"==typeof r?r:"["+Yr(r).join("+")+"]";if(t[i]){const e=t[i].idxByName[o];e&&(e.name=n,delete t[i].idxByName[o],t[i].idxByName[n]=e)}}}"undefined"!=typeof navigator&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&Nr.WorkerGlobalScope&&Nr instanceof Nr.WorkerGlobalScope&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604&&(e._hasGetAll=!1)}class Qs{_parseStoresSpec(e,t){Br(e).forEach((n=>{if(null!==e[n]){var r=e[n].split(",").map(((e,t)=>{const n=(e=e.trim()).replace(/([&*]|\+\+)/g,""),r=/^\[/.test(n)?n.match(/^\[(.*)\]$/)[1].split("+"):n;return Is(n,r||null,/\&/.test(e),/\*/.test(e),/\+\+/.test(e),Rr(r),0===t)})),o=r.shift();if(o.multi)throw new Io.Schema("Primary key cannot be multi-valued");r.forEach((e=>{if(e.auto)throw new Io.Schema("Only primary key can be marked as autoIncrement (++)");if(!e.keyPath)throw new Io.Schema("Index must have a name and cannot be an empty string")})),t[n]=Ns(n,o,r)}}))}stores(e){const t=this.db;this._cfg.storesSource=this._cfg.storesSource?Mr(this._cfg.storesSource,e):e;const n=t._versions,r={};let o={};return n.forEach((e=>{Mr(r,e._cfg.storesSource),o=e._cfg.dbschema={},e._parseStoresSpec(r,o)})),t._dbSchema=o,qs(t,[t._allTables,t,t.Transaction.prototype]),Ls(t,[t._allTables,t,t.Transaction.prototype,this._cfg.tables],Br(o),o),t._storeNames=Br(o),this}upgrade(e){return this._cfg.contentUpgrade=Wo(this._cfg.contentUpgrade||Bo,e),this}}function Js(e,t){let n=e._dbNamesDB;return n||(n=e._dbNamesDB=new ba("__dbnames",{addons:[],indexedDB:e,IDBKeyRange:t}),n.version(1).stores({dbnames:"name"})),n.table("dbnames")}function Xs(e){return e&&"function"==typeof e.databases}function Zs(e){return Ki((function(){return ui.letThrough=!0,e()}))}function ea(){var e;return!navigator.userAgentData&&/Safari\//.test(navigator.userAgent)&&!/Chrom(e|ium)\//.test(navigator.userAgent)&&indexedDB.databases?new Promise((function(t){var n=function(){return indexedDB.databases().finally(t)};e=setInterval(n,100),n()})).finally((function(){return clearInterval(e)})):Promise.resolve()}function ta(e){var t=t=>e.next(t),n=o(t),r=o((t=>e.throw(t)));function o(e){return t=>{var o=e(t),i=o.value;return o.done?i:i&&"function"==typeof i.then?i.then(n,r):Rr(i)?Promise.all(i).then(n,r):n(i)}}return o(t)()}function na(e,t,n){var r=arguments.length;if(r<2)throw new Io.InvalidArgument("Too few arguments");for(var o=new Array(r-1);--r;)o[r-1]=arguments[r];return n=o.pop(),[e,oo(o),n]}function ra(e,t,n,r,o){return hi.resolve().then((()=>{const i=ui.transless||ui,s=e._createTransaction(t,n,e._dbSchema,r),a={trans:s,transless:i};if(r)s.idbtrans=r.idbtrans;else try{s.create(),e._state.PR1398_maxLoop=3}catch(r){return r.name===Do.InvalidState&&e.isOpen()&&--e._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),e._close(),e.open().then((()=>ra(e,t,n,null,o)))):Hi(r)}const u=vo(o);let c;u&&Ni();const l=hi.follow((()=>{if(c=o.call(s,s),c)if(u){var e=Bi.bind(null,null);c.then(e,e)}else"function"==typeof c.next&&"function"==typeof c.throw&&(c=ta(c))}),a);return(c&&"function"==typeof c.then?hi.resolve(c).then((e=>s.active?e:Hi(new Io.PrematureCommit("Transaction committed too early. See http://bit.ly/2kdckMn")))):l.then((()=>c))).then((e=>(r&&s._resolve(),s._completion.then((()=>e))))).catch((e=>(s._reject(e),Hi(e))))}))}function oa(e,t,n){const r=Rr(e)?e.slice():[e];for(let e=0;e<n;++e)r.push(t);return r}const ia={stack:"dbcore",name:"VirtualIndexMiddleware",level:1,create:function(e){return{...e,table(t){const n=e.table(t),{schema:r}=n,o={},i=[];function s(e,t,n){const r=Us(e),a=o[r]=o[r]||[],u=null==e?0:"string"==typeof e?1:e.length,c=t>0,l={...n,isVirtual:c,keyTail:t,keyLength:u,extractKey:Rs(e),unique:!c&&n.unique};return a.push(l),l.isPrimaryKey||i.push(l),u>1&&s(2===u?e[0]:e.slice(0,u-1),t+1,n),a.sort(((e,t)=>e.keyTail-t.keyTail)),l}const a=s(r.primaryKey.keyPath,0,r.primaryKey);o[":id"]=[a];for(const e of r.indexes)s(e.keyPath,0,e);function u(t){const n=t.query.index;return n.isVirtual?{...t,query:{index:n,range:(r=t.query.range,o=n.keyTail,{type:1===r.type?2:r.type,lower:oa(r.lower,r.lowerOpen?e.MAX_KEY:e.MIN_KEY,o),lowerOpen:!0,upper:oa(r.upper,r.upperOpen?e.MIN_KEY:e.MAX_KEY,o),upperOpen:!0})}}:t;var r,o}const c={...n,schema:{...r,primaryKey:a,indexes:i,getIndexByKeyPath:function(e){const t=o[Us(e)];return t&&t[0]}},count:e=>n.count(u(e)),query:e=>n.query(u(e)),openCursor(t){const{keyTail:r,isVirtual:o,keyLength:i}=t.query.index;return o?n.openCursor(u(t)).then((n=>n&&function(n){const o=Object.create(n,{continue:{value:function(o){null!=o?n.continue(oa(o,t.reverse?e.MAX_KEY:e.MIN_KEY,r)):t.unique?n.continue(n.key.slice(0,i).concat(t.reverse?e.MIN_KEY:e.MAX_KEY,r)):n.continue()}},continuePrimaryKey:{value(t,o){n.continuePrimaryKey(oa(t,e.MAX_KEY,r),o)}},primaryKey:{get:()=>n.primaryKey},key:{get(){const e=n.key;return 1===i?e[0]:e.slice(0,i)}},value:{get:()=>n.value}});return o}(n))):n.openCursor(t)}};return c}}}};function sa(e,t,n,r){return n=n||{},r=r||"",Br(e).forEach((o=>{if(Fr(t,o)){var i=e[o],s=t[o];if("object"==typeof i&&"object"==typeof s&&i&&s){const e=fo(i);e!==fo(s)?n[r+o]=t[o]:"Object"===e?sa(i,s,n,r+o+"."):i!==s&&(n[r+o]=t[o])}else i!==s&&(n[r+o]=t[o])}else n[r+o]=void 0})),Br(t).forEach((o=>{Fr(e,o)||(n[r+o]=t[o])})),n}const aa={stack:"dbcore",name:"HooksMiddleware",level:2,create:e=>({...e,table(t){const n=e.table(t),{primaryKey:r}=n.schema,o={...n,mutate(e){const o=ui.trans,{deleting:i,creating:s,updating:a}=o.table(t).hook;switch(e.type){case"add":if(s.fire===Bo)break;return o._promise("readwrite",(()=>u(e)),!0);case"put":if(s.fire===Bo&&a.fire===Bo)break;return o._promise("readwrite",(()=>u(e)),!0);case"delete":if(i.fire===Bo)break;return o._promise("readwrite",(()=>u(e)),!0);case"deleteRange":if(i.fire===Bo)break;return o._promise("readwrite",(()=>function(e){return c(e.trans,e.range,1e4)}(e)),!0)}return n.mutate(e);function u(e){const t=ui.trans,o=e.keys||function(e,t){return"delete"===t.type?t.keys:t.keys||t.values.map(e.extractKey)}(r,e);if(!o)throw new Error("Keys missing");return"delete"!==(e="add"===e.type||"put"===e.type?{...e,keys:o}:{...e}).type&&(e.values=[...e.values]),e.keys&&(e.keys=[...e.keys]),function(e,t,n){return"add"===t.type?Promise.resolve([]):e.getMany({trans:t.trans,keys:n,cache:"immutable"})}(n,e,o).then((u=>{const c=o.map(((n,o)=>{const c=u[o],l={onerror:null,onsuccess:null};if("delete"===e.type)i.fire.call(l,n,c,t);else if("add"===e.type||void 0===c){const i=s.fire.call(l,n,e.values[o],t);null==n&&null!=i&&(n=i,e.keys[o]=n,r.outbound||to(e.values[o],r.keyPath,n))}else{const r=sa(c,e.values[o]),i=a.fire.call(l,r,n,c,t);if(i){const t=e.values[o];Object.keys(i).forEach((e=>{Fr(t,e)?t[e]=i[e]:to(t,e,i[e])}))}}return l}));return n.mutate(e).then((({failures:t,results:n,numFailures:r,lastResult:i})=>{for(let r=0;r<o.length;++r){const i=n?n[r]:o[r],s=c[r];null==i?s.onerror&&s.onerror(t[r]):s.onsuccess&&s.onsuccess("put"===e.type&&u[r]?e.values[r]:i)}return{failures:t,results:n,numFailures:r,lastResult:i}})).catch((e=>(c.forEach((t=>t.onerror&&t.onerror(e))),Promise.reject(e))))}))}function c(e,t,o){return n.query({trans:e,values:!1,query:{index:r,range:t},limit:o}).then((({result:n})=>u({type:"delete",keys:n,trans:e}).then((r=>r.numFailures>0?Promise.reject(r.failures[0]):n.length<o?{failures:[],numFailures:0,lastResult:void 0}:c(e,{...t,lower:n[n.length-1],lowerOpen:!0},o)))))}}};return o}})};function ua(e,t,n){try{if(!t)return null;if(t.keys.length<e.length)return null;const r=[];for(let o=0,i=0;o<t.keys.length&&i<e.length;++o)0===ys(t.keys[o],e[i])&&(r.push(n?uo(t.values[o]):t.values[o]),++i);return r.length===e.length?r:null}catch(e){return null}}const ca={stack:"dbcore",level:-1,create:e=>({table:t=>{const n=e.table(t);return{...n,getMany:e=>{if(!e.cache)return n.getMany(e);const t=ua(e.keys,e.trans._cache,"clone"===e.cache);return t?hi.resolve(t):n.getMany(e).then((t=>(e.trans._cache={keys:e.keys,values:"clone"===e.cache?uo(t):t},t)))},mutate:e=>("add"!==e.type&&(e.trans._cache=null),n.mutate(e))}}})};function la(e){return!("from"in e)}const fa=function(e,t){if(!this){const t=new fa;return e&&"d"in e&&Mr(t,e),t}Mr(this,arguments.length?{d:1,from:e,to:arguments.length>1?t:e}:{d:0})};function ha(e,t,n){const r=ys(t,n);if(isNaN(r))return;if(r>0)throw RangeError();if(la(e))return Mr(e,{from:t,to:n,d:1});const o=e.l,i=e.r;if(ys(n,e.from)<0)return o?ha(o,t,n):e.l={from:t,to:n,d:1,l:null,r:null},ya(e);if(ys(t,e.to)>0)return i?ha(i,t,n):e.r={from:t,to:n,d:1,l:null,r:null},ya(e);ys(t,e.from)<0&&(e.from=t,e.l=null,e.d=i?i.d+1:1),ys(n,e.to)>0&&(e.to=n,e.r=null,e.d=e.l?e.l.d+1:1);const s=!e.r;o&&!e.l&&da(e,o),i&&s&&da(e,i)}function da(e,t){la(t)||function e(t,{from:n,to:r,l:o,r:i}){ha(t,n,r),o&&e(t,o),i&&e(t,i)}(e,t)}function pa(e){let t=la(e)?null:{s:0,n:e};return{next(e){const n=arguments.length>0;for(;t;)switch(t.s){case 0:if(t.s=1,n)for(;t.n.l&&ys(e,t.n.from)<0;)t={up:t,n:t.n.l,s:1};else for(;t.n.l;)t={up:t,n:t.n.l,s:1};case 1:if(t.s=2,!n||ys(e,t.n.to)<=0)return{value:t.n,done:!1};case 2:if(t.n.r){t.s=3,t={up:t,n:t.n.r,s:0};continue}case 3:t=t.up}return{done:!0}}}}function ya(e){var t,n;const r=((null===(t=e.r)||void 0===t?void 0:t.d)||0)-((null===(n=e.l)||void 0===n?void 0:n.d)||0),o=r>1?"r":r<-1?"l":"";if(o){const t="r"===o?"l":"r",n={...e},r=e[o];e.from=r.from,e.to=r.to,e[o]=r[o],n[o]=r[t],e[t]=n,n.d=ma(n)}e.d=ma(e)}function ma({r:e,l:t}){return(e?t?Math.max(e.d,t.d):e.d:t?t.d:0)+1}Lr(fa.prototype,{add(e){return da(this,e),this},addKey(e){return ha(this,e,e),this},addKeys(e){return e.forEach((e=>ha(this,e,e))),this},[ho](){return pa(this)}});const va={stack:"dbcore",level:0,create:e=>{const t=e.schema.name,n=new fa(e.MIN_KEY,e.MAX_KEY);return{...e,table:r=>{const o=e.table(r),{schema:i}=o,{primaryKey:s}=i,{extractKey:a,outbound:u}=s,c={...o,mutate:e=>{const s=e.trans,a=s.mutatedParts||(s.mutatedParts={}),u=e=>{const n=`idb://${t}/${r}/${e}`;return a[n]||(a[n]=new fa)},c=u(""),l=u(":dels"),{type:f}=e;let[h,d]="deleteRange"===e.type?[e.range]:"delete"===e.type?[e.keys]:e.values.length<50?[[],e.values]:[];const p=e.trans._cache;return o.mutate(e).then((e=>{if(Rr(h)){"delete"!==f&&(h=e.results),c.addKeys(h);const t=ua(h,p);t||"add"===f||l.addKeys(h),(t||d)&&function(e,t,n,r){t.indexes.forEach((function(t){const o=e(t.name||"");function i(e){return null!=e?t.extractKey(e):null}const s=e=>t.multiEntry&&Rr(e)?e.forEach((e=>o.addKey(e))):o.addKey(e);(n||r).forEach(((e,t)=>{const o=n&&i(n[t]),a=r&&i(r[t]);0!==ys(o,a)&&(null!=o&&s(o),null!=a&&s(a))}))}))}(u,i,t,d)}else if(h){const e={from:h.lower,to:h.upper};l.add(e),c.add(e)}else c.add(n),l.add(n),i.indexes.forEach((e=>u(e.name).add(n)));return e}))}},l=({query:{index:t,range:n}})=>{var r,o;return[t,new fa(null!==(r=n.lower)&&void 0!==r?r:e.MIN_KEY,null!==(o=n.upper)&&void 0!==o?o:e.MAX_KEY)]},f={get:e=>[s,new fa(e.key)],getMany:e=>[s,(new fa).addKeys(e.keys)],count:l,query:l,openCursor:l};return Br(f).forEach((e=>{c[e]=function(i){const{subscr:s}=ui;if(s){const c=e=>{const n=`idb://${t}/${r}/${e}`;return s[n]||(s[n]=new fa)},l=c(""),h=c(":dels"),[d,p]=f[e](i);if(c(d.name||"").add(p),!d.isPrimaryKey){if("count"!==e){const t="query"===e&&u&&i.values&&o.query({...i,values:!1});return o[e].apply(this,arguments).then((n=>{if("query"===e){if(u&&i.values)return t.then((({result:e})=>(l.addKeys(e),n)));const e=i.values?n.result.map(a):n.result;i.values?l.addKeys(e):h.addKeys(e)}else if("openCursor"===e){const e=n,t=i.values;return e&&Object.create(e,{key:{get:()=>(h.addKey(e.primaryKey),e.key)},primaryKey:{get(){const t=e.primaryKey;return h.addKey(t),t}},value:{get:()=>(t&&l.addKey(e.primaryKey),e.value)}})}return n}))}h.add(n)}}return o[e].apply(this,arguments)}})),c}}}};class ba{constructor(e,t){this._middlewares={},this.verno=0;const n=ba.dependencies;this._options=t={addons:ba.addons,autoOpen:!0,indexedDB:n.indexedDB,IDBKeyRange:n.IDBKeyRange,...t},this._deps={indexedDB:t.indexedDB,IDBKeyRange:t.IDBKeyRange};const{addons:r}=t;this._dbSchema={},this._versions=[],this._storeNames=[],this._allTables={},this.idbdb=null,this._novip=this;const o={dbOpenError:null,isBeingOpened:!1,onReadyBeingFired:null,openComplete:!1,dbReadyResolve:Bo,dbReadyPromise:null,cancelOpen:Bo,openCanceller:null,autoSchema:!0,PR1398_maxLoop:3};var i;o.dbReadyPromise=new hi((e=>{o.dbReadyResolve=e})),o.openCanceller=new hi(((e,t)=>{o.cancelOpen=t})),this._state=o,this.name=e,this.on=ss(this,"populate","blocked","versionchange","close",{ready:[Wo,Bo]}),this.on.ready.subscribe=Qr(this.on.ready.subscribe,(e=>(t,n)=>{ba.vip((()=>{const r=this._state;if(r.openComplete)r.dbOpenError||hi.resolve().then(t),n&&e(t);else if(r.onReadyBeingFired)r.onReadyBeingFired.push(t),n&&e(t);else{e(t);const r=this;n||e((function e(){r.on.ready.unsubscribe(t),r.on.ready.unsubscribe(e)}))}}))})),this.Collection=(i=this,as(bs.prototype,(function(e,t){this.db=i;let n=rs,r=null;if(t)try{n=t()}catch(e){r=e}const o=e._ctx,s=o.table,a=s.hook.reading.fire;this._ctx={table:s,index:o.index,isPrimKey:!o.index||s.schema.primKey.keyPath&&o.index===s.schema.primKey.name,range:n,keysOnly:!1,dir:"next",unique:"",algorithm:null,filter:null,replayFilter:null,justLimit:!0,isMatch:null,offset:0,limit:1/0,error:r,or:o.or,valueMapper:a!==Ro?a:null}}))),this.Table=function(e){return as(is.prototype,(function(t,n,r){this.db=e,this._tx=r,this.name=t,this.schema=n,this.hook=e._allTables[t]?e._allTables[t].hook:ss(null,{creating:[Uo,Bo],reading:[Mo,Ro],updating:[Lo,Bo],deleting:[Fo,Bo]})}))}(this),this.Transaction=function(e){return as(Cs.prototype,(function(t,n,r,o,i){this.db=e,this.mode=t,this.storeNames=n,this.schema=r,this.chromeTransactionDurability=o,this.idbtrans=null,this.on=ss(this,"complete","error","abort"),this.parent=i||null,this.active=!0,this._reculock=0,this._blockedFuncs=[],this._resolve=null,this._reject=null,this._waitingFor=null,this._waitingQueue=null,this._spinCount=0,this._completion=new hi(((e,t)=>{this._resolve=e,this._reject=t})),this._completion.then((()=>{this.active=!1,this.on.complete.fire()}),(e=>{var t=this.active;return this.active=!1,this.on.error.fire(e),this.parent?this.parent._reject(e):t&&this.idbtrans&&this.idbtrans.abort(),Hi(e)}))}))}(this),this.Version=function(e){return as(Qs.prototype,(function(t){this.db=e,this._cfg={version:t,storesSource:null,dbschema:{},tables:{},contentUpgrade:null}}))}(this),this.WhereClause=function(e){return as(ks.prototype,(function(t,n,r){this.db=e,this._ctx={table:t,index:":id"===n?null:n,or:r};const o=e._deps.indexedDB;if(!o)throw new Io.MissingAPI;this._cmp=this._ascending=o.cmp.bind(o),this._descending=(e,t)=>o.cmp(t,e),this._max=(e,t)=>o.cmp(e,t)>0?e:t,this._min=(e,t)=>o.cmp(e,t)<0?e:t,this._IDBKeyRange=e._deps.IDBKeyRange}))}(this),this.on("versionchange",(e=>{e.newVersion>0?console.warn(`Another connection wants to upgrade database '${this.name}'. Closing db now to resume the upgrade.`):console.warn(`Another connection wants to delete database '${this.name}'. Closing db now to resume the delete request.`),this.close()})),this.on("blocked",(e=>{!e.newVersion||e.newVersion<e.oldVersion?console.warn(`Dexie.delete('${this.name}') was blocked`):console.warn(`Upgrade '${this.name}' blocked by other connection holding version ${e.oldVersion/10}`)})),this._maxKey=Bs(t.IDBKeyRange),this._createTransaction=(e,t,n,r)=>new this.Transaction(e,t,n,this._options.chromeTransactionDurability,r),this._fireOnBlocked=e=>{this.on("blocked").fire(e),Ji.filter((e=>e.name===this.name&&e!==this&&!e._state.vcFired)).map((t=>t.on("versionchange").fire(e)))},this.use(ia),this.use(aa),this.use(va),this.use(ca),this.vip=Object.create(this,{_vip:{value:!0}}),r.forEach((e=>e(this)))}version(e){if(isNaN(e)||e<.1)throw new Io.Type("Given version is not a positive number");if(e=Math.round(10*e)/10,this.idbdb||this._state.isBeingOpened)throw new Io.Schema("Cannot add version when database is open");this.verno=Math.max(this.verno,e);const t=this._versions;var n=t.filter((t=>t._cfg.version===e))[0];return n||(n=new this.Version(e),t.push(n),t.sort(Ws),n.stores({}),this._state.autoSchema=!1,n)}_whenReady(e){return this.idbdb&&(this._state.openComplete||ui.letThrough||this._vip)?e():new hi(((e,t)=>{if(this._state.openComplete)return t(new Io.DatabaseClosed(this._state.dbOpenError));if(!this._state.isBeingOpened){if(!this._options.autoOpen)return void t(new Io.DatabaseClosed);this.open().catch(Bo)}this._state.dbReadyPromise.then(e,t)})).then(e)}use({stack:e,create:t,level:n,name:r}){r&&this.unuse({stack:e,name:r});const o=this._middlewares[e]||(this._middlewares[e]=[]);return o.push({stack:e,create:t,level:null==n?10:n,name:r}),o.sort(((e,t)=>e.level-t.level)),this}unuse({stack:e,name:t,create:n}){return e&&this._middlewares[e]&&(this._middlewares[e]=this._middlewares[e].filter((e=>n?e.create!==n:!!t&&e.name!==t))),this}open(){return function(e){const t=e._state,{indexedDB:n}=e._deps;if(t.isBeingOpened||e.idbdb)return t.dbReadyPromise.then((()=>t.dbOpenError?Hi(t.dbOpenError):e));bo&&(t.openCanceller._stackHolder=Eo()),t.isBeingOpened=!0,t.dbOpenError=null,t.openComplete=!1;const r=t.openCanceller;function o(){if(t.openCanceller!==r)throw new Io.DatabaseClosed("db.open() was cancelled")}let i=t.dbReadyResolve,s=null,a=!1;return hi.race([r,("undefined"==typeof navigator?hi.resolve():ea()).then((()=>new hi(((r,i)=>{if(o(),!n)throw new Io.MissingAPI;const u=e.name,c=t.autoSchema?n.open(u):n.open(u,Math.round(10*e.verno));if(!c)throw new Io.MissingAPI;c.onerror=As(i),c.onblocked=ji(e._fireOnBlocked),c.onupgradeneeded=ji((r=>{if(s=c.transaction,t.autoSchema&&!e._options.allowEmptyDB){c.onerror=Ts,s.abort(),c.result.close();const e=n.deleteDatabase(u);e.onsuccess=e.onerror=ji((()=>{i(new Io.NoSuchDatabase(`Database ${u} doesnt exist`))}))}else{s.onerror=As(i);var o=r.oldVersion>Math.pow(2,62)?0:r.oldVersion;a=o<1,e._novip.idbdb=c.result,function(e,t,n,r){const o=e._dbSchema,i=e._createTransaction("readwrite",e._storeNames,o);i.create(n),i._completion.catch(r);const s=i._reject.bind(i),a=ui.transless||ui;Ki((()=>{ui.trans=i,ui.transless=a,0===t?(Br(o).forEach((e=>{Gs(n,e,o[e].primKey,o[e].indexes)})),Fs(e,n),hi.follow((()=>e.on.populate.fire(i))).catch(s)):function({_novip:e},t,n,r){const o=[],i=e._versions;let s=e._dbSchema=zs(0,e.idbdb,r),a=!1;return i.filter((e=>e._cfg.version>=t)).forEach((i=>{o.push((()=>{const o=s,u=i._cfg.dbschema;Ys(e,o,r),Ys(e,u,r),s=e._dbSchema=u;const c=Vs(o,u);c.add.forEach((e=>{Gs(r,e[0],e[1].primKey,e[1].indexes)})),c.change.forEach((e=>{if(e.recreate)throw new Io.Upgrade("Not yet support for changing primary key");{const t=r.objectStore(e.name);e.add.forEach((e=>Hs(t,e))),e.change.forEach((e=>{t.deleteIndex(e.name),Hs(t,e)})),e.del.forEach((e=>t.deleteIndex(e)))}}));const l=i._cfg.contentUpgrade;if(l&&i._cfg.version>t){Fs(e,r),n._memoizedTables={},a=!0;let t=no(u);c.del.forEach((e=>{t[e]=o[e]})),qs(e,[e.Transaction.prototype]),Ls(e,[e.Transaction.prototype],Br(t),t),n.schema=t;const i=vo(l);let s;i&&Ni();const f=hi.follow((()=>{if(s=l(n),s&&i){var e=Bi.bind(null,null);s.then(e,e)}}));return s&&"function"==typeof s.then?hi.resolve(s):f.then((()=>s))}})),o.push((t=>{a&&Zi||function(e,t){[].slice.call(t.db.objectStoreNames).forEach((n=>null==e[n]&&t.db.deleteObjectStore(n)))}(i._cfg.dbschema,t),qs(e,[e.Transaction.prototype]),Ls(e,[e.Transaction.prototype],e._storeNames,e._dbSchema),n.schema=e._dbSchema}))})),function e(){return o.length?hi.resolve(o.shift()(n.idbtrans)).then(e):hi.resolve()}().then((()=>{var e,t;t=r,Br(e=s).forEach((n=>{t.db.objectStoreNames.contains(n)||Gs(t,n,e[n].primKey,e[n].indexes)}))}))}(e,t,i,n).catch(s)}))}(e,o/10,s,i)}}),i),c.onsuccess=ji((()=>{s=null;const n=e._novip.idbdb=c.result,o=Yr(n.objectStoreNames);if(o.length>0)try{const r=n.transaction(1===(i=o).length?i[0]:i,"readonly");t.autoSchema?function({_novip:e},t,n){e.verno=t.version/10;const r=e._dbSchema=zs(0,t,n);e._storeNames=Yr(t.objectStoreNames,0),Ls(e,[e._allTables],Br(r),r)}(e,n,r):(Ys(e,e._dbSchema,r),function(e,t){const n=Vs(zs(0,e.idbdb,t),e._dbSchema);return!(n.add.length||n.change.some((e=>e.add.length||e.change.length)))}(e,r)||console.warn("Dexie SchemaDiff: Schema was extended without increasing the number passed to db.version(). Some queries may fail.")),Fs(e,r)}catch(e){}var i;Ji.push(e),n.onversionchange=ji((n=>{t.vcFired=!0,e.on("versionchange").fire(n)})),n.onclose=ji((t=>{e.on("close").fire(t)})),a&&function({indexedDB:e,IDBKeyRange:t},n){!Xs(e)&&"__dbnames"!==n&&Js(e,t).put({name:n}).catch(Bo)}(e._deps,u),r()}),i)}))))]).then((()=>(o(),t.onReadyBeingFired=[],hi.resolve(Zs((()=>e.on.ready.fire(e.vip)))).then((function n(){if(t.onReadyBeingFired.length>0){let r=t.onReadyBeingFired.reduce(Wo,Bo);return t.onReadyBeingFired=[],hi.resolve(Zs((()=>r(e.vip)))).then(n)}}))))).finally((()=>{t.onReadyBeingFired=null,t.isBeingOpened=!1})).then((()=>e)).catch((n=>{t.dbOpenError=n;try{s&&s.abort()}catch(e){}return r===t.openCanceller&&e._close(),Hi(n)})).finally((()=>{t.openComplete=!0,i()}))}(this)}_close(){const e=this._state,t=Ji.indexOf(this);if(t>=0&&Ji.splice(t,1),this.idbdb){try{this.idbdb.close()}catch(e){}this._novip.idbdb=null}e.dbReadyPromise=new hi((t=>{e.dbReadyResolve=t})),e.openCanceller=new hi(((t,n)=>{e.cancelOpen=n}))}close(){this._close();const e=this._state;this._options.autoOpen=!1,e.dbOpenError=new Io.DatabaseClosed,e.isBeingOpened&&e.cancelOpen(e.dbOpenError)}delete(){const e=arguments.length>0,t=this._state;return new hi(((n,r)=>{const o=()=>{this.close();var e=this._deps.indexedDB.deleteDatabase(this.name);e.onsuccess=ji((()=>{!function({indexedDB:e,IDBKeyRange:t},n){!Xs(e)&&"__dbnames"!==n&&Js(e,t).delete(n).catch(Bo)}(this._deps,this.name),n()})),e.onerror=As(r),e.onblocked=this._fireOnBlocked};if(e)throw new Io.InvalidArgument("Arguments not allowed in db.delete()");t.isBeingOpened?t.dbReadyPromise.then(o):o()}))}backendDB(){return this.idbdb}isOpen(){return null!==this.idbdb}hasBeenClosed(){const e=this._state.dbOpenError;return e&&"DatabaseClosed"===e.name}hasFailed(){return null!==this._state.dbOpenError}dynamicallyOpened(){return this._state.autoSchema}get tables(){return Br(this._allTables).map((e=>this._allTables[e]))}transaction(){const e=na.apply(this,arguments);return this._transaction.apply(this,e)}_transaction(e,t,n){let r=ui.trans;r&&r.db===this&&-1===e.indexOf("!")||(r=null);const o=-1!==e.indexOf("?");let i,s;e=e.replace("!","").replace("?","");try{if(s=t.map((e=>{var t=e instanceof this.Table?e.name:e;if("string"!=typeof t)throw new TypeError("Invalid table argument to Dexie.transaction(). Only Table or String are allowed");return t})),"r"==e||"readonly"===e)i="readonly";else{if("rw"!=e&&"readwrite"!=e)throw new Io.InvalidArgument("Invalid transaction mode: "+e);i="readwrite"}if(r){if("readonly"===r.mode&&"readwrite"===i){if(!o)throw new Io.SubTransaction("Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY");r=null}r&&s.forEach((e=>{if(r&&-1===r.storeNames.indexOf(e)){if(!o)throw new Io.SubTransaction("Table "+e+" not included in parent transaction.");r=null}})),o&&r&&!r.active&&(r=null)}}catch(e){return r?r._promise(null,((t,n)=>{n(e)})):Hi(e)}const a=ra.bind(null,this,i,s,r,n);return r?r._promise(i,a,"lock"):ui.trans?Li(ui.transless,(()=>this._whenReady(a))):this._whenReady(a)}table(e){if(!Fr(this._allTables,e))throw new Io.InvalidTable(`Table ${e} does not exist`);return this._allTables[e]}}const ga="undefined"!=typeof Symbol&&"observable"in Symbol?Symbol.observable:"@@observable";class wa{constructor(e){this._subscribe=e}subscribe(e,t,n){return this._subscribe(e&&"function"!=typeof e?e:{next:e,error:t,complete:n})}[ga](){return this}}function _a(e,t){return Br(t).forEach((n=>{da(e[n]||(e[n]=new fa),t[n])})),e}let Ea;try{Ea={indexedDB:Nr.indexedDB||Nr.mozIndexedDB||Nr.webkitIndexedDB||Nr.msIndexedDB,IDBKeyRange:Nr.IDBKeyRange||Nr.webkitIDBKeyRange}}catch(mt){Ea={indexedDB:null,IDBKeyRange:null}}const Oa=ba;function Sa(e){let t=Pa;try{Pa=!0,Ds.storagemutated.fire(e)}finally{Pa=t}}Lr(Oa,{...No,delete:e=>new Oa(e,{addons:[]}).delete(),exists:e=>new Oa(e,{addons:[]}).open().then((e=>(e.close(),!0))).catch("NoSuchDatabaseError",(()=>!1)),getDatabaseNames(e){try{return function({indexedDB:e,IDBKeyRange:t}){return Xs(e)?Promise.resolve(e.databases()).then((e=>e.map((e=>e.name)).filter((e=>"__dbnames"!==e)))):Js(e,t).toCollection().primaryKeys()}(Oa.dependencies).then(e)}catch(e){return Hi(new Io.MissingAPI)}},defineClass:()=>function(e){Mr(this,e)},ignoreTransaction:e=>ui.trans?Li(ui.transless,e):e(),vip:Zs,async:function(e){return function(){try{var t=ta(e.apply(this,arguments));return t&&"function"==typeof t.then?t:hi.resolve(t)}catch(e){return Hi(e)}}},spawn:function(e,t,n){try{var r=ta(e.apply(n,t||[]));return r&&"function"==typeof r.then?r:hi.resolve(r)}catch(e){return Hi(e)}},currentTransaction:{get:()=>ui.trans||null},waitFor:function(e,t){const n=hi.resolve("function"==typeof e?Oa.ignoreTransaction(e):e).timeout(t||6e4);return ui.trans?ui.trans.waitFor(n):n},Promise:hi,debug:{get:()=>bo,set:e=>{go(e,"dexie"===e?()=>!0:ts)}},derive:Vr,extend:Mr,props:Lr,override:Qr,Events:ss,on:Ds,liveQuery:function(e){return new wa((t=>{const n=vo(e);let r=!1,o={},i={};const s={get closed(){return r},unsubscribe:()=>{r=!0,Ds.storagemutated.unsubscribe(l)}};t.start&&t.start(s);let a=!1,u=!1;function c(){return Br(i).some((e=>o[e]&&function(e,t){const n=pa(t);let r=n.next();if(r.done)return!1;let o=r.value;const i=pa(e);let s=i.next(o.from),a=s.value;for(;!r.done&&!s.done;){if(ys(a.from,o.to)<=0&&ys(a.to,o.from)>=0)return!0;ys(o.from,a.from)<0?o=(r=n.next(a.from)).value:a=(s=i.next(o.from)).value}return!1}(o[e],i[e])))}const l=e=>{_a(o,e),c()&&f()},f=()=>{if(a||r)return;o={};const h={},d=function(t){n&&Ni();const r=()=>Ki(e,{subscr:t,trans:null}),o=ui.trans?Li(ui.transless,r):r();return n&&o.then(Bi,Bi),o}(h);u||(Ds("storagemutated",l),u=!0),a=!0,Promise.resolve(d).then((e=>{a=!1,r||(c()?f():(o={},i=h,t.next&&t.next(e)))}),(e=>{a=!1,t.error&&t.error(e),s.unsubscribe()}))};return f(),s}))},extendObservabilitySet:_a,getByKeyPath:eo,setByKeyPath:to,delByKeyPath:function(e,t){"string"==typeof t?to(e,t,void 0):"length"in t&&[].map.call(t,(function(t){to(e,t,void 0)}))},shallowClone:no,deepClone:uo,getObjectDiff:sa,cmp:ys,asap:Xr,minKey:-1/0,addons:[],connections:Ji,errnames:Do,dependencies:Ea,semVer:"3.2.3",version:"3.2.3".split(".").map((e=>parseInt(e))).reduce(((e,t,n)=>e+t/Math.pow(10,2*n)))}),Oa.maxKey=Bs(Oa.dependencies.IDBKeyRange),"undefined"!=typeof dispatchEvent&&"undefined"!=typeof addEventListener&&(Ds("storagemutated",(e=>{if(!Pa){let t;Xi?(t=document.createEvent("CustomEvent"),t.initCustomEvent("x-storagemutated-1",!0,!0,e)):t=new CustomEvent("x-storagemutated-1",{detail:e}),Pa=!0,dispatchEvent(t),Pa=!1}})),addEventListener("x-storagemutated-1",(({detail:e})=>{Pa||Sa(e)})));let Pa=!1;if("undefined"!=typeof BroadcastChannel){const e=new BroadcastChannel("x-storagemutated-1");"function"==typeof e.unref&&e.unref(),Ds("storagemutated",(t=>{Pa||e.postMessage(t)})),e.onmessage=e=>{e.data&&Sa(e.data)}}else if("undefined"!=typeof self&&"undefined"!=typeof navigator){Ds("storagemutated",(e=>{try{Pa||("undefined"!=typeof localStorage&&localStorage.setItem("x-storagemutated-1",JSON.stringify({trig:Math.random(),changedParts:e})),"object"==typeof self.clients&&[...self.clients.matchAll({includeUncontrolled:!0})].forEach((t=>t.postMessage({type:"x-storagemutated-1",changedParts:e}))))}catch(e){}})),"undefined"!=typeof addEventListener&&addEventListener("storage",(e=>{if("x-storagemutated-1"===e.key){const t=JSON.parse(e.newValue);t&&Sa(t.changedParts)}}));const e=self.document&&navigator.serviceWorker;e&&e.addEventListener("message",(function({data:e}){e&&"x-storagemutated-1"===e.type&&Sa(e.changedParts)}))}function xa(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}hi.rejectionMapper=function(e,t){if(!e||e instanceof jo||e instanceof TypeError||e instanceof SyntaxError||!e.name||!Ko[e.name])return e;var n=new Ko[e.name](t||e.message,e);return"stack"in e&&Wr(n,"stack",{get:function(){return this.inner.stack}}),n},go(bo,ts);function ja(e,t,n,r,o,i,s){try{var a=e[i](s),u=a.value}catch(e){return void n(e)}a.done?t(u):Promise.resolve(u).then(r,o)}function ka(e){return function(){var t=this,n=arguments;return new Promise((function(r,o){var i=e.apply(t,n);function s(e){ja(i,r,o,s,a,"next",e)}function a(e){ja(i,r,o,s,a,"throw",e)}s(void 0)}))}}const Aa=new class extends ba{constructor(){super("EsmOffline"),xa(this,"syncQueue",void 0),xa(this,"dynamicOfflineData",void 0),this.version(4).stores({syncQueue:"++id,userId,type,[userId+type]",dynamicOfflineData:"++id,type,identifier,*users,&[type+identifier]"}),this.syncQueue=this.table("syncQueue"),this.dynamicOfflineData=this.table("dynamicOfflineData")}};function Ta(){return(Ta=ka((function*(){const e=yield _r();return(null==e?void 0:e.uuid)||"*"}))).apply(this,arguments)}function Da(){return Da=ka((function*(e,t){return(yield function(e,t){return Ca.apply(this,arguments)}(e,t)).map((e=>e.content))})),Da.apply(this,arguments)}function Ca(){return(Ca=ka((function*(e,t){const n=t?{type:t,userId:e}:{userId:e};return yield Aa.syncQueue.where(n).toArray().catch(ba.errnames.DatabaseClosed,(()=>[]))}))).apply(this,arguments)}function Ia(){return Ia=ka((function*(e){const t=yield function(){return Ta.apply(this,arguments)}();return yield function(e,t){return Da.apply(this,arguments)}(t,e)})),Ia.apply(this,arguments)}function Ka(e,t,n,r,o,i,s){try{var a=e[i](s),u=a.value}catch(e){return void n(e)}a.done?t(u):Promise.resolve(u).then(r,o)}function Na(e){return function(){var t=this,n=arguments;return new Promise((function(r,o){var i=e.apply(t,n);function s(e){Ka(i,r,o,s,a,"next",e)}function a(e){Ka(i,r,o,s,a,"throw",e)}s(void 0)}))}}function Ba(e,t){return Ra.apply(this,arguments)}function Ra(){return Ra=Na((function*(e,t,n=!0){if(e){let r=null;const[o,i]=yield Promise.all([ur(`${ir}/Patient/${e}`,t).catch((e=>r=e)),n?Ma(e):Promise.resolve(null)]);if(o.ok)return o.data;if(i)return i;if(r)throw r}return null})),Ra.apply(this,arguments)}function Ma(e){return $a.apply(this,arguments)}function $a(){return $a=Na((function*(e){const t=yield function(e){return Ia.apply(this,arguments)}("patient-registration"),n=t.find((t=>t.fhirPatient.id===e));var r;return null!==(r=null==n?void 0:n.fhirPatient)&&void 0!==r?r:null})),$a.apply(this,arguments)}(0,Re.createGlobalStore)("offline-synchronization",{}),(0,Re.createGlobalStore)("offline-patients",{offlinePatientDataSyncState:{},handlers:{}});var Ua=function(){function e(){return Error.call(this),this.message="object unsubscribed",this.name="ObjectUnsubscribedError",this}return e.prototype=Object.create(Error.prototype),e}(),Fa=function(e){function n(t,n){var r=e.call(this)||this;return r.subject=t,r.subscriber=n,r.closed=!1,r}return t(n,e),n.prototype.unsubscribe=function(){if(!this.closed){this.closed=!0;var e=this.subject,t=e.observers;if(this.subject=null,t&&0!==t.length&&!e.isStopped&&!e.closed){var n=t.indexOf(this.subscriber);-1!==n&&t.splice(n,1)}}},n}(d),La=function(e){function n(t){var n=e.call(this,t)||this;return n.destination=t,n}return t(n,e),n}(m),qa=function(e){function n(){var t=e.call(this)||this;return t.observers=[],t.closed=!1,t.isStopped=!1,t.hasError=!1,t.thrownError=null,t}return t(n,e),n.prototype[y]=function(){return new La(this)},n.prototype.lift=function(e){var t=new Wa(this,this);return t.operator=e,t},n.prototype.next=function(e){if(this.closed)throw new Ua;if(!this.isStopped)for(var t=this.observers,n=t.length,r=t.slice(),o=0;o<n;o++)r[o].next(e)},n.prototype.error=function(e){if(this.closed)throw new Ua;this.hasError=!0,this.thrownError=e,this.isStopped=!0;for(var t=this.observers,n=t.length,r=t.slice(),o=0;o<n;o++)r[o].error(e);this.observers.length=0},n.prototype.complete=function(){if(this.closed)throw new Ua;this.isStopped=!0;for(var e=this.observers,t=e.length,n=e.slice(),r=0;r<t;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(t){if(this.closed)throw new Ua;return e.prototype._trySubscribe.call(this,t)},n.prototype._subscribe=function(e){if(this.closed)throw new Ua;return this.hasError?(e.error(this.thrownError),d.EMPTY):this.isStopped?(e.complete(),d.EMPTY):(this.observers.push(e),new Fa(this,e))},n.prototype.asObservable=function(){var e=new w;return e.source=this,e},n.create=function(e,t){return new Wa(e,t)},n}(w),Wa=function(e){function n(t,n){var r=e.call(this)||this;return r.destination=t,r.source=n,r}return t(n,e),n.prototype.next=function(e){var t=this.destination;t&&t.next&&t.next(e)},n.prototype.error=function(e){var t=this.destination;t&&t.error&&this.destination.error(e)},n.prototype.complete=function(){var e=this.destination;e&&e.complete&&this.destination.complete()},n.prototype._subscribe=function(e){return this.source?this.source.subscribe(e):d.EMPTY},n}(qa),Va=function(e){function n(t){var n=e.call(this)||this;return n._value=t,n}return t(n,e),Object.defineProperty(n.prototype,"value",{get:function(){return this.getValue()},enumerable:!0,configurable:!0}),n.prototype._subscribe=function(t){var n=e.prototype._subscribe.call(this,t);return n&&!n.closed&&t.next(this._value),n},n.prototype.getValue=function(){if(this.hasError)throw this.thrownError;if(this.closed)throw new Ua;return this._value},n.prototype.next=function(t){e.prototype.next.call(this,this._value=t)},n}(qa),Ga=function(){function e(){return Error.call(this),this.message="argument out of range",this.name="ArgumentOutOfRangeError",this}return e.prototype=Object.create(Error.prototype),e}(),Ha=new w((function(e){return e.complete()}));function za(e){return function(t){return 0===e?n?function(e){return new w((function(t){return e.schedule((function(){return t.complete()}))}))}(n):Ha:t.lift(new Ya(e));var n}}var Ya=function(){function e(e){if(this.total=e,this.total<0)throw new Ga}return e.prototype.call=function(e,t){return t.subscribe(new Qa(e,this.total))},e}(),Qa=function(e){function n(t,n){var r=e.call(this,t)||this;return r.total=n,r.count=0,r}return t(n,e),n.prototype._next=function(e){var t=this.total,n=++this.count;n<=t&&(this.destination.next(e),n===t&&(this.destination.complete(),this.unsubscribe()))},n}(m);function Ja(e,t){return function(n){if("function"!=typeof e)throw new TypeError("argument is not a function. Are you looking for `mapTo()`?");return n.lift(new Xa(e,t))}}var Xa=function(){function e(e,t){this.project=e,this.thisArg=t}return e.prototype.call=function(e,t){return t.subscribe(new Za(e,this.project,this.thisArg))},e}(),Za=function(e){function n(t,n,r){var o=e.call(this,t)||this;return o.project=n,o.count=0,o.thisArg=r||o,o}return t(n,e),n.prototype._next=function(e){var t;try{t=this.project.call(this.thisArg,e,this.count++)}catch(e){return void this.destination.error(e)}this.destination.next(t)},n}(m);const eu="custom:(uuid,encounters:(uuid,encounterDatetime,form:(uuid,name),location:ref,encounterType:ref,encounterProviders:(uuid,display,provider:(uuid,display))),patient:(uuid,uuid),visitType:(uuid,name,display),attributes:(uuid,display,attributeType:(name,datatypeClassname,uuid),value),location:(uuid,name,display),startDatetime,stopDatetime)";function tu(e,t,n){return cr(`/ws/rest/v1/visit?patient=${e}&v=${null!=n?n:eu}`,{signal:t.signal,method:"GET",headers:{"Content-type":"application/json"}}).pipe(za(1)).pipe(Ja((e=>e)))}function nu(e,t){return cr("/ws/rest/v1/visit",{signal:t.signal,method:"POST",headers:{"Content-type":"application/json"},body:e})}function ru(e,t,n){return cr(`/ws/rest/v1/visit/${e}`,{signal:n.signal,method:"POST",headers:{"Content-type":"application/json"},body:t})}const ou=new Va(null);var iu,su;function au(e){return{uuid:e.uuid,display:e.display,name:e.name}}function uu(){return cr("/ws/rest/v1/visittype").pipe(Ja((e=>e.data.results.map(au)))).pipe(za(1))}function cu(e){return{uuid:e.uuid,display:e.display}}function lu(){return cr("/ws/rest/v1/location").pipe(Ja((e=>e.data.results.map(cu)))).pipe(za(1))}!function(e){e.NEWVISIT="startVisit",e.EDITVISIT="editVisit",e.LOADING="loadingVisit"}(iu||(iu={})),function(e){e.NOTSTARTED="notStarted",e.ONGOING="ongoing"}(su||(su={}));const fu={"webservices.rest":"2.24.0",fhir2:"1.0.0-SNAPSHOT"}})(),_openmrs_esm_api=r})();
2
+ System.register(["@openmrs/esm-config","@openmrs/esm-error-handling","@openmrs/esm-offline"],(function(t,e){var r={},n={},o={};return{setters:[function(t){r.Type=t.Type,r.defineConfigSchema=t.defineConfigSchema,r.getConfig=t.getConfig,r.navigate=t.navigate,r.validators=t.validators},function(t){n.reportError=t.reportError},function(t){o.getSynchronizationItems=t.getSynchronizationItems}],execute:function(){t((()=>{var t={403:()=>{System.register([],(function(t,e){return{execute:function(){t((()=>{var t={968:(t,e,r)=>{const n=r(577).R;e.s=function(t){if(t||(t=1),!r.y.meta||!r.y.meta.url)throw console.error("__system_context__",r.y),Error("systemjs-webpack-interop was provided an unknown SystemJS context. Expected context.meta.url, but none was provided");r.p=n(r.y.meta.url,t)}},577:(t,e,r)=>{e.R=function(t,e){var r=document.createElement("a");r.href=t;for(var n="/"===r.pathname[0]?r.pathname:"/"+r.pathname,o=0,i=n.length;o!==e&&i>=0;)"/"===n[--i]&&o++;if(o!==e)throw Error("systemjs-webpack-interop: rootDirectoryLevel ("+e+") is greater than the number of directories ("+o+") in the URL path "+t);var s=n.slice(0,i+1);return r.protocol+"//"+r.host+s},Number.isInteger}},r={};function n(e){var o=r[e];if(void 0!==o)return o.exports;var i=r[e]={exports:{}};return t[e](i,i.exports,n),i.exports}n.y=e,n.d=(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.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},(()=>{var t;n.g.importScripts&&(t=n.g.location+"");var e=n.g.document;if(!t&&e&&(e.currentScript&&(t=e.currentScript.src),!t)){var r=e.getElementsByTagName("script");if(r.length)for(var o=r.length-1;o>-1&&!t;)t=r[o--].src}if(!t)throw new Error("Automatic publicPath is not supported in this browser");t=t.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),n.p=t})();var o={};return(0,n(968).s)(1),(()=>{"use strict";n.r(o),n.d(o,{createAppState:()=>u,createGlobalStore:()=>i,getAppState:()=>c,getGlobalStore:()=>s,subscribeTo:()=>a});const t=t=>{let e;const r=new Set,n=(t,n)=>{const o="function"==typeof t?t(e):t;if(!Object.is(o,e)){const t=e;e=(null!=n?n:"object"!=typeof o)?o:Object.assign({},e,o),r.forEach((r=>r(e,t)))}},o=()=>e,i={setState:n,getState:o,subscribe:t=>(r.add(t),()=>r.delete(t)),destroy:()=>{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()}};return e=t(n,o,i),i},e=e=>e?t(e):t,r={};function i(t,n){const o=r[t];if(o)return o.active?console.error("Cannot override an existing store. Make sure that stores are only created once."):o.value.setState(n,!0),o.active=!0,o.value;{const o=e()((()=>n));return r[t]={value:o,active:!0},o}}function s(t,n){const o=r[t];if(!o){const o=e()((()=>null!=n?n:{}));return r[t]={value:o,active:!1},o}return o.value}function u(t){return i("app",t)}function c(){return s("app",{})}function a(t,e,r){let n=e(t.getState());return t.subscribe((t=>{const o=e(t);o!==n&&(n=o,r(o))}))}})(),o})())}}}))},968:(t,e,r)=>{const n=r(577).R;e.s=function(t){if(t||(t=1),!r.y.meta||!r.y.meta.url)throw console.error("__system_context__",r.y),Error("systemjs-webpack-interop was provided an unknown SystemJS context. Expected context.meta.url, but none was provided");r.p=n(r.y.meta.url,t)}},577:(t,e,r)=>{e.R=function(t,e){var r=document.createElement("a");r.href=t;for(var n="/"===r.pathname[0]?r.pathname:"/"+r.pathname,o=0,i=n.length;o!==e&&i>=0;)"/"===n[--i]&&o++;if(o!==e)throw Error("systemjs-webpack-interop: rootDirectoryLevel ("+e+") is greater than the number of directories ("+o+") in the URL path "+t);var s=n.slice(0,i+1);return r.protocol+"//"+r.host+s};Number.isInteger},824:t=>{"use strict";t.exports=r},254:t=>{"use strict";t.exports=n},738:t=>{"use strict";t.exports=o}},i={};function s(e){var r=i[e];if(void 0!==r)return r.exports;var n=i[e]={exports:{}};return t[e](n,n.exports,s),n.exports}s.y=e,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.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),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 t;s.g.importScripts&&(t=s.g.location+"");var e=s.g.document;if(!t&&e&&(e.currentScript&&(t=e.currentScript.src),!t)){var r=e.getElementsByTagName("script");if(r.length)for(var n=r.length-1;n>-1&&!t;)t=r[n--].src}if(!t)throw new Error("Automatic publicPath is not supported in this browser");t=t.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),s.p=t})();var u={};return(0,s(968).s)(1),(()=>{"use strict";s.r(u),s.d(u,{OpenmrsFetchError:()=>z,VisitMode:()=>It,VisitStatus:()=>Bt,backendDependencies:()=>Rt,clearCurrentUser:()=>ot,defaultVisitCustomRepresentation:()=>Ct,fetchCurrentPatient:()=>dt,fhirBaseUrl:()=>R,getCurrentUser:()=>et,getLocations:()=>Mt,getLoggedInUser:()=>st,getSessionLocation:()=>ut,getSessionStore:()=>rt,getStartedVisit:()=>Ht,getVisitTypes:()=>Lt,getVisitsForPatient:()=>Vt,makeUrl:()=>G,openmrsFetch:()=>J,openmrsObservableFetch:()=>Y,refetchCurrentUser:()=>nt,restBaseUrl:()=>M,saveVisit:()=>Ut,sessionEndpoint:()=>W,setSessionLocation:()=>ct,setupApiModule:()=>lt,toLocationObject:()=>Nt,toVisitTypeObject:()=>Ft,updateVisit:()=>$t,userHasAccess:()=>it});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 c={closed:!0,next:function(t){},error:function(t){if(o.useDeprecatedSynchronousErrorHandling)throw t;i(t)},complete:function(){}},a=function(){return Array.isArray||function(t){return t&&"number"==typeof t.length}}(),l=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=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,o=this,i=o._parentOrParents,s=o._ctorUnsubscribe,u=o._unsubscribe,c=o._subscriptions;if(this.closed=!0,this._parentOrParents=null,this._subscriptions=null,i instanceof t)i.remove(this);else if(null!==i)for(var p=0;p<i.length;++p)i[p].remove(this);if(r(u)){s&&(this._unsubscribe=void 0);try{u.call(this)}catch(t){e=t instanceof l?h(t.errors):[t]}}if(a(c)){p=-1;for(var f=c.length;++p<f;){var d=c[p];if(null!==(n=d)&&"object"==typeof n)try{d.unsubscribe()}catch(t){e=e||[],t instanceof l?e=e.concat(h(t.errors)):e.push(t)}}}if(e)throw new l(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 h(t){return t.reduce((function(t,e){return t.concat(e instanceof l?e.errors:e)}),[])}var f=function(){return"function"==typeof Symbol?Symbol("rxSubscriber"):"@@rxSubscriber_"+Math.random()}(),d=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=c;break;case 1:if(!e){i.destination=c;break}if("object"==typeof e){e instanceof r?(i.syncErrorThrowable=e.syncErrorThrowable,i.destination=e,e.add(i)):(i.syncErrorThrowable=!0,i.destination=new b(i,e));break}default:i.syncErrorThrowable=!0,i.destination=new b(i,e,n,o)}return i}return e(r,t),r.prototype[f]=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}(p),b=function(t){function n(e,n,o,i){var s,u=t.call(this)||this;u._parentSubscriber=e;var a=u;return r(n)?s=n:n&&(s=n.next,o=n.error,i=n.complete,n!==c&&(r((a=Object.create(n)).unsubscribe)&&u.add(a.unsubscribe.bind(a)),a.unsubscribe=u.unsubscribe.bind(u))),u._context=a,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}(d),y=function(){return"function"==typeof Symbol&&Symbol.observable||"@@observable"}();function v(t){return t}var m=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 d)return t;if(t[f])return t[f]()}return t||e||r?new d(t,e,r):new d(c)}(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 d?n:null}return!0}(t)?t.error(e):console.warn(e)}},t.prototype.forEach=function(t,e){var r=this;return new(e=g(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[y]=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?v: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=g(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 g(t){if(t||(t=o.Promise||Promise),!t)throw new Error("no Promise impl found");return t}const w="object"==typeof global&&global&&global.Object===Object&&global;var S="object"==typeof self&&self&&self.Object===Object&&self;const _=(w||S||Function("return this")()).Symbol;var E=Object.prototype,O=E.hasOwnProperty,T=E.toString,j=_?_.toStringTag:void 0;var P=Object.prototype.toString;var x=_?_.toStringTag:void 0;const A=function(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":x&&x in Object(t)?function(t){var e=O.call(t,j),r=t[j];try{t[j]=void 0;var n=!0}catch(t){}var o=T.call(t);return n&&(e?t[j]=r:delete t[j]),o}(t):function(t){return P.call(t)}(t)},D=(k=Object.getPrototypeOf,C=Object,function(t){return k(C(t))});var k,C;var V=Function.prototype,U=Object.prototype,$=V.toString,H=U.hasOwnProperty,I=$.call(Object);const B=function(t){if(!function(t){return null!=t&&"object"==typeof t}(t)||"[object Object]"!=A(t))return!1;var e=D(t);if(null===e)return!0;var r=H.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&$.call(r)==I};var F=s(824);function L(t,e,r,n,o,i,s){try{var u=t[i](s),c=u.value}catch(t){return void r(t)}u.done?e(c):Promise.resolve(c).then(n,o)}function N(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}const M="/ws/rest/v1/",R="/ws/fhir2/R4",W=`${M}session`;function G(t){return t&&t.startsWith("http")?t:("/"!==t[0]&&(t="/"+t),window.openmrsBase+t)}function J(t,e={}){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.");let r=G(t);if(e.headers||(e.headers={}),B(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(M)&&void 0===e.headers["Disable-WWW-Authenticate"]&&(e.headers["Disable-WWW-Authenticate"]="true"),t.startsWith(R)){const t=new URL(r,window.location.toString());t.searchParams.has("_summary")||(t.searchParams.set("_summary","data"),r=t.toString())}const n=Error();return window.fetch(r,e).then((o=function*(t){const e=t;if(e.ok)return 204===e.status?(e.data=null,e):e.clone().text().then((t=>{try{t&&(e.data=JSON.parse(t))}catch(t){}return e}));{const{redirectAuthFailure:t}=yield(0,F.getConfig)("@openmrs/esm-api");return r===G(W)&&403===e.status||t.enabled&&t.errors.includes(e.status)?((0,F.navigate)({to:t.url}),t.resolvePromise?Promise.resolve():new Promise((()=>{}))):e.clone().text().then((t=>{let o=t;try{o=JSON.parse(t)}catch(t){}throw new z(r,e,o,n)}),(t=>{throw new z(r,e,null,n)}))}},i=function(){var t=this,e=arguments;return new Promise((function(r,n){var i=o.apply(t,e);function s(t){L(i,r,n,s,u,"next",t)}function u(t){L(i,r,n,s,u,"throw",t)}s(void 0)}))},function(t){return i.apply(this,arguments)}));var o,i}function Y(t,e={}){if("object"!=typeof e)throw Error("The second argument to openmrsObservableFetch must be either omitted or an object");const r=new AbortController;return e.signal=r.signal,new m((n=>{let o=!1;return J(t,e).then((t=>{o=!0,n.next(t),n.complete()}),(t=>{o=!0,n.error(t)})),()=>{o||r.abort()}}))}class z extends Error{constructor(t,e,r,n){super(),N(this,"response",void 0),N(this,"responseBody",void 0),this.message=`Server responded with ${e.status} (${e.statusText}) for url ${t}. Check err.responseBody or network tab in dev tools for more info`,n.message=this.message,this.responseBody=r,this.response=e,this.stack=`Stacktrace for outgoing request:\n${n.stack}\nStacktrace for incoming response:\n${this.stack}`}}var q=s(254),K=s(403);const Q=function(t){return void 0===t};function X(t,e,r,n,o,i,s){try{var u=t[i](s),c=u.value}catch(t){return void r(t)}u.done?e(c):Promise.resolve(c).then(n,o)}const Z=(0,K.createGlobalStore)("session",{loaded:!1,session:null});let tt=0;function et(t={includeAuthStatus:!0}){return(tt<Date.now()-6e4||!Z.getState().loaded)&&nt(),new m((e=>{const r=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(Z.getState()),Z.subscribe(r)}))}function rt(){return(tt<Date.now()-6e4||!Z.getState().loaded)&&nt(),Z}function nt(){return new Promise(((t,e)=>{tt=Date.now(),J(W).then((r=>{if("object"!=typeof(null==r?void 0:r.data))return e(),Promise.reject();!function(t){var e,r,n;const 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;o!==document.documentElement.getAttribute("lang")&&document.documentElement.setAttribute("lang",o)}(r.data),t(r.data),Z.setState({loaded:!0,session:r.data})})).catch((t=>((0,q.reportError)(`Failed to fetch new session information: ${t}`),e(t),{sessionId:"",authenticated:!1})))}))}function ot(){Z.setState({loaded:!0,session:{authenticated:!1,sessionId:""}})}function it(t,e){return void 0===e?Boolean(t):!Boolean(t)||function(t,e){return"string"==typeof t?!Q(e.privileges.find((e=>t===e.display))):Array.isArray(t)?t.every((t=>!Q(e.privileges.find((e=>t===e.display))))):(Q(t)||console.error(`Could not understand privileges "${t}"`),!0)}(t,e)||function(t){return!Q(t.roles.find((t=>"System Developer"===t.display)))}(e)}function st(){let t,e;return new Promise(((r,n)=>{const o=n=>{n.loaded&&n.session.user&&(t=n.session.user,r(n.session.user),e&&e())};o(Z.getState()),t||(e=Z.subscribe(o))}))}function ut(){return new Promise(((t,e)=>{et().subscribe((e=>{t(e.sessionLocation)}),e).unsubscribe()}))}function ct(t,e){return at.apply(this,arguments)}function at(){var t;return t=function*(t,e){yield J(W,{method:"POST",body:{sessionLocation:t},headers:{"Content-Type":"application/json"},signal:e.signal}),yield nt()},at=function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function s(t){X(i,n,o,s,u,"next",t)}function u(t){X(i,n,o,s,u,"throw",t)}s(void 0)}))},at.apply(this,arguments)}function lt(){(0,F.defineConfigSchema)("@openmrs/esm-api",{redirectAuthFailure:{enabled:{_type:F.Type.Boolean,_default:!0,_description:"Whether to redirect logged-out users to `redirectAuthFailure.url`"},url:{_type:F.Type.String,_default:"${openmrsSpaBase}/login",_validators:[F.validators.isUrl]},errors:{_type:F.Type.Array,_default:[401],_elements:{_type:F.Type.Number,_validators:[F.validators.inRange(100,600)]},_description:"The HTTP error codes for which users will be redirected"},resolvePromise:{_type:F.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."}}}),nt()}var pt=s(738);function ht(t,e,r,n,o,i,s){try{var u=t[i](s),c=u.value}catch(t){return void r(t)}u.done?e(c):Promise.resolve(c).then(n,o)}function ft(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function s(t){ht(i,n,o,s,u,"next",t)}function u(t){ht(i,n,o,s,u,"throw",t)}s(void 0)}))}}function dt(t,e){return bt.apply(this,arguments)}function bt(){return(bt=ft((function*(t,e,r=!0){if(t){let n=null;const[o,i]=yield Promise.all([J(`${R}/Patient/${t}`,e).catch((t=>n=t)),r?yt(t):Promise.resolve(null)]);if(o.ok)return o.data;if(i)return i;if(n)throw n}return null}))).apply(this,arguments)}function yt(t){return vt.apply(this,arguments)}function vt(){return(vt=ft((function*(t){const e=(yield(0,pt.getSynchronizationItems)("patient-registration")).find((e=>e.fhirPatient.id===t));var r;return null!==(r=null==e?void 0:e.fhirPatient)&&void 0!==r?r:null}))).apply(this,arguments)}var mt=function(){function t(){return Error.call(this),this.message="object unsubscribed",this.name="ObjectUnsubscribedError",this}return t.prototype=Object.create(Error.prototype),t}(),gt=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}(p),wt=function(t){function r(e){var r=t.call(this,e)||this;return r.destination=e,r}return e(r,t),r}(d),St=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[f]=function(){return new wt(this)},r.prototype.lift=function(t){var e=new _t(this,this);return e.operator=t,e},r.prototype.next=function(t){if(this.closed)throw new mt;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 mt;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 mt;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 mt;return t.prototype._trySubscribe.call(this,e)},r.prototype._subscribe=function(t){if(this.closed)throw new mt;return this.hasError?(t.error(this.thrownError),p.EMPTY):this.isStopped?(t.complete(),p.EMPTY):(this.observers.push(t),new gt(this,t))},r.prototype.asObservable=function(){var t=new m;return t.source=this,t},r.create=function(t,e){return new _t(t,e)},r}(m),_t=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):p.EMPTY},r}(St),Et=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 mt;return this._value},r.prototype.next=function(e){t.prototype.next.call(this,this._value=e)},r}(St),Ot=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}(),Tt=new m((function(t){return t.complete()}));function jt(t){return function(e){return 0===t?r?function(t){return new m((function(e){return t.schedule((function(){return e.complete()}))}))}(r):Tt:e.lift(new Pt(t));var r}}var Pt=function(){function t(t){if(this.total=t,this.total<0)throw new Ot}return t.prototype.call=function(t,e){return e.subscribe(new xt(t,this.total))},t}(),xt=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}(d);function At(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 Dt(t,e))}}var Dt=function(){function t(t,e){this.project=t,this.thisArg=e}return t.prototype.call=function(t,e){return e.subscribe(new kt(t,this.project,this.thisArg))},t}(),kt=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}(d);const Ct="custom:(uuid,encounters:(uuid,encounterDatetime,form:(uuid,name),location:ref,encounterType:ref,encounterProviders:(uuid,display,provider:(uuid,display))),patient:(uuid,uuid),visitType:(uuid,name,display),attributes:(uuid,display,attributeType:(name,datatypeClassname,uuid),value),location:(uuid,name,display),startDatetime,stopDatetime)";function Vt(t,e,r){return Y(`/ws/rest/v1/visit?patient=${t}&v=${null!=r?r:Ct}`,{signal:e.signal,method:"GET",headers:{"Content-type":"application/json"}}).pipe(jt(1)).pipe(At((t=>t)))}function Ut(t,e){return Y("/ws/rest/v1/visit",{signal:e.signal,method:"POST",headers:{"Content-type":"application/json"},body:t})}function $t(t,e,r){return Y(`/ws/rest/v1/visit/${t}`,{signal:r.signal,method:"POST",headers:{"Content-type":"application/json"},body:e})}const Ht=new Et(null);var It,Bt;function Ft(t){return{uuid:t.uuid,display:t.display,name:t.name}}function Lt(){return Y("/ws/rest/v1/visittype").pipe(At((t=>t.data.results.map(Ft)))).pipe(jt(1))}function Nt(t){return{uuid:t.uuid,display:t.display}}function Mt(){return Y("/ws/rest/v1/location").pipe(At((t=>t.data.results.map(Nt)))).pipe(jt(1))}!function(t){t.NEWVISIT="startVisit",t.EDITVISIT="editVisit",t.LOADING="loadingVisit"}(It||(It={})),function(t){t.NOTSTARTED="notStarted",t.ONGOING="ongoing"}(Bt||(Bt={}));const Rt={"webservices.rest":"2.24.0",fhir2:"1.0.0-SNAPSHOT"}})(),u})())}}}));
3
3
  //# sourceMappingURL=openmrs-esm-api.js.map