@openmrs/esm-laboratory-app 1.5.2-pre.1622 → 1.5.2-pre.1624
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.
- package/.turbo/cache/f61ecd56a40e7a29-meta.json +1 -0
- package/.turbo/cache/f61ecd56a40e7a29.tar.zst +0 -0
- package/.turbo/turbo-build.log +1 -1
- package/dist/4976.js +1 -1
- package/dist/4976.js.map +1 -1
- package/dist/main.js +1 -1
- package/dist/openmrs-esm-laboratory-app.js +2 -2
- package/dist/openmrs-esm-laboratory-app.js.buildmanifest.json +5 -5
- package/dist/routes.json +1 -1
- package/package.json +1 -1
- package/.turbo/cache/cc9807cb2077857e-meta.json +0 -1
- package/.turbo/cache/cc9807cb2077857e.tar.zst +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"hash":"f61ecd56a40e7a29","duration":10307}
|
|
Binary file
|
package/.turbo/turbo-build.log
CHANGED
package/dist/4976.js
CHANGED
|
@@ -9,7 +9,7 @@ If you're the maintainer: the allowed types are ${Object.values(r$).join(", ")}.
|
|
|
9
9
|
If you're the maintainer: all config elements must have a default. Received ${JSON.stringify(i)}`),s&&l&&![r$.Array,r$.Object].includes(l)&&console.error(`${e} has bad config schema definition for key '${a}'. ${r}.
|
|
10
10
|
|
|
11
11
|
If you're the maintainer: the 'elements' key only works with '_type' equal to 'Array' or 'Object'. Received ${JSON.stringify(l)}`)}}function r3(e,t){return r5(t.map(({[e]:t})=>t).filter(e=>!!e))}function r5(e){return e.reduce((e,t)=>rW(e,t),{})}function r4(e,t,n=""){for(let r of Object.keys(t)){let o=t[r],a=n+"."+r,i=e[r];if(!e.hasOwnProperty(r)){("extensionSlots"!==r||""===n)&&or(a,`Unknown config key '${a}' provided. Ignoring.`);continue}(function e(t,n,r){r8(r,t._type,n),ot(n)?t._type===r$.Object?function(t,n,r){if(t._elements)for(let o of Object.keys(n)){let a=n[o];e(t._elements,a,`${r}.${o}`)}}(t,n,r):t.hasOwnProperty("_default")||t.hasOwnProperty("_type")||r4(t,n,r):t._type===r$.Array&&function(t,n,r){if(r8(r,r$.Array,n)){if(oe(t._elements))for(let o=0;o<n.length;o++)e(t._elements,n[o],`${r}[${o}]`);for(let e=0;e<n.length;e++)r8(`${r}[${e}]`,t._elements?._type,n[e])}}(t,n,r)})(i,o,a)}}rU();function r6(e,t,n=""){if(e){if(t!==e._default&&r7(n,e._validators,t),ot(t))for(let r of Object.keys(t)){let o=t[r],a=n+"."+r,i=e[r];e._type===r$.Object&&e._elements?r6(e._elements,o,a):r6(i,o,a)}else if(Array.isArray(t)&&e._elements)for(let r=0;r<t.length;r++)r6(e._elements,t[r],`${n}[${r}]`)}}function r8(e,t,n){return!t||r7(e,[{Array:rw,Boolean:rx,ConceptUuid:rD,Number:rC,Object:rS,String:rE,UUID:rD,PersonAttributeTypeUuid:rD,PatientIdentifierTypeUuid:rD}[t]],n)}function r7(e,t,n){let r=!0;if(t)try{for(let o of t){let t=o(n);if("string"==typeof t){let o="object"==typeof n?`Invalid configuration for ${e}: ${t}`:`Invalid configuration value ${n} for ${e}: ${t}`;or(e,o),r=!1}}}catch(t){console.error(`Skipping invalid validator at "${e}". Encountered error
|
|
12
|
-
${t}`)}return r}let r9=(e,t)=>{let n=structuredClone(t);if(!e)return n;for(let t of Object.keys(e)){let r=n[t],o=e[t];if(o&&(o.hasOwnProperty("_type")||o.hasOwnProperty("_default"))){n.hasOwnProperty(t)||(n[t]=o._default);let e=o._elements;if(r&&oe(e)){if(o._type===r$.Array&&Array.isArray(r)){let o=r.map(t=>r9(e,t));n[t]=o}else if(o._type===r$.Object)for(let t of Object.keys(r))r[t]=r9(e,r[t])}}else if(ot(o)){let e=r??{};ot(e)&&(n[t]=r9(o,e))}}return n};function oe(e){return!!e&&Object.keys(e).filter(e=>!["_default","_validators"].includes(e)).length>0}function ot(e){return"object"==typeof e&&!Array.isArray(e)&&null!==e}let on=new Set;function or(e,t){let n=`${e}:::${t}`;on||(on=new Set),on.has(n)||(console.error(t),on.add(n))}function oo(e){e?on.forEach(t=>{t.startsWith(e)&&on.delete(t)}):on.clear()}function oa(){rG.forEach(e=>e()),rG.length=0,rU()}let oi={"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:r$.Object,_default:{},_validators:[rk(e=>Object.keys(e).every(e=>/^[a-z]{2,3}(-[A-Z]{2,3})?$/.test(e)),e=>{let t=Object.keys(e).filter(e=>!/^[a-z]{2,3}(-[A-Z]{2,3})?$/.test(e));return`The 'Translation overrides' object should have language codes for keys. Language codes must be in the form of a two-to-three letter language code optionally followed by a hyphen and a two-to-three letter country code. The following keys do not conform: ${t.join(", ")}.`})]}},os={"Display conditions":{privileges:{_description:"The privilege(s) the user must have to use this extension",_type:r$.Array,_default:[]},expression:{_description:"The expression that determines whether the extension is displayed",_type:r$.String,_default:void 0}},...oi},ol=(e,t)=>rk(n=>e<=n&&n<=t,`must be between ${e} and ${t}`),oc=e=>{let t=e.concat(["openmrsBase","openmrsSpaBase"]);return rk(e=>{if(!e||"string"!=typeof e)return!1;let n=/\${(.*?)}/g,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(", "))},op=oc([]),ou=e=>rk(t=>e.includes(t),`Must be one of the following: '${e.join("', '")}'.`),od={inRange:ol,isUrl:op,isUrlWithTemplateParameters:oc,oneOf:ou};var of=n(8067);let oh=U("breadcrumbs",[]);function om(e){return o_([e])}function o_(e){let t=[...oy(),...e.map(e=>({matcher:e.matcher instanceof RegExp?e.matcher:"string"==typeof e.matcher?(0,of.pathToRegexp)(e.matcher).regexp:(0,of.pathToRegexp)(e.path).regexp,settings:e}))];oh.setState(t,!0)}function oy(){return oh.getState()}function og(e,t){if(t)return function(e,t){let[n]=e.filter(e=>e.matcher.test(t));return n}(e,t)||function(e,t){let n=t.split("/");for(;n.length>1;){n.pop();let t=og(e,n.join("/"));if(t)return t}}(e,t)}function ob(e,t){if(e.length>0){let n=og(e,t);if(n){let t=[n],r=og(e,n.settings.parent);for(;void 0!==r;)t.push(r),r=og(e,r.settings.parent);return t.reverse()}}return[]}function ov(e){return ob(oy(),e)}var oA=Object.freeze({__proto__:null,get start(){return aU},get ensureJQuerySupport(){return av},get setBootstrapMaxTime(){return at},get setMountMaxTime(){return an},get setUnmountMaxTime(){return ar},get setUnloadMaxTime(){return ao},get registerApplication(){return az},get unregisterApplication(){return aP},get getMountedApps(){return aE},get getAppStatus(){return aD},get unloadApplication(){return aT},get checkActivityFunctions(){return aO},get getAppNames(){return aS},get pathToActiveWhen(){return aN},get navigateToUrl(){return au},get patchHistoryApi(){return ay},get triggerAppChange(){return aL},get addErrorHandler(){return oC},get removeErrorHandler(){return oE},get mountRootParcel(){return o6},get NOT_LOADED(){return oM},get LOADING_SOURCE_CODE(){return oz},get NOT_BOOTSTRAPPED(){return oO},get BOOTSTRAPPING(){return oP},get NOT_MOUNTED(){return oT},get MOUNTING(){return oB},get UPDATING(){return oN},get LOAD_ERROR(){return oF},get MOUNTED(){return oI},get UNLOADING(){return oR},get UNMOUNTING(){return oj},get SKIP_BECAUSE_BROKEN(){return oL}}),o$=("u">typeof globalThis?globalThis:"u">typeof window?window:"u">typeof global?global:"u">typeof self?self:{}).CustomEvent,ok=!function(){try{var e=new o$("cat",{detail:{foo:"bar"}});return"cat"===e.type&&"bar"===e.detail.foo}catch(e){}return!1}()?"u">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=!!t.bubbles,n.cancelable=!!t.cancelable,n.detail=t.detail):(n.bubbles=!1,n.cancelable=!1,n.detail=void 0),n}:o$;let ow=[];function ox(e,t,n){let r=oD(e,t,n);ow.length?ow.forEach(e=>e(r)):setTimeout(()=>{throw r})}function oC(e){if("function"!=typeof e)throw Error(oS(28,!1));ow.push(e)}function oE(e){if("function"!=typeof e)throw Error(oS(29,!1));let t=!1;return ow=ow.filter(n=>{let r=n===e;return t=t||r,!r}),t}function oS(e,t,...n){return`single-spa minified message #${e}: ${t?t+" ":""}See https://single-spa.js.org/error/?code=${e}${n.length?`&arg=${n.join("&arg=")}`:""}`}function oD(e,t,n){let r,o=`${oq(t)} '${oV(t)}' died in status ${t.status}: `;if(e instanceof Error){try{e.message=o+e.message}catch(e){}r=e}else{console.warn(oS(30,!1,t.status,oV(t)));try{r=Error(o+JSON.stringify(e))}catch(t){r=e}}return r.appOrParcelName=oV(t),t.status=n,r}let oM="NOT_LOADED",oz="LOADING_SOURCE_CODE",oO="NOT_BOOTSTRAPPED",oP="BOOTSTRAPPING",oT="NOT_MOUNTED",oB="MOUNTING",oI="MOUNTED",oN="UPDATING",oj="UNMOUNTING",oR="UNLOADING",oF="LOAD_ERROR",oL="SKIP_BECAUSE_BROKEN";function oW(e){return e.status===oI}function oG(e){try{return e.activeWhen(window.location)}catch(t){return ox(t,e,oL),!1}}function oV(e){return e.name}function oU(e){return!!e.unmountThisParcel}function oq(e){return oU(e)?"parcel":"application"}function oH(){for(let e=arguments.length-1;e>0;e--)for(let t in arguments[e])"__proto__"!==t&&(arguments[e-1][t]=arguments[e][t]);return arguments[0]}function oK(e,t){for(let n=0;n<e.length;n++)if(t(e[n]))return e[n];return null}function oY(e){return e&&("function"==typeof e||Array.isArray(e)&&!oK(e,e=>"function"!=typeof e))}function oJ(e,t){let n=e[t]||[];0===(n=Array.isArray(n)?n:[n]).length&&(n=[()=>Promise.resolve()]);let r=oq(e),o=oV(e);return function(e){return n.reduce((n,a,i)=>n.then(()=>{let n=a(e);return oZ(n)?n:Promise.reject(oS(15,!1,r,o,t,i))}),Promise.resolve())}}function oZ(e){return e&&"function"==typeof e.then&&"function"==typeof e.catch}let oX=[];function oQ(e,t){return Promise.resolve().then(()=>e.status!==oO?e:(e.status=oP,e.bootstrap?aa(e,"bootstrap").then(n).catch(n=>{if(t)throw oD(n,e,oL);return ox(n,e,oL),e}):Promise.resolve().then(n)));function n(){return e.status=oT,e}}function o0(e,t){return Promise.resolve().then(()=>{if(e.status!==oI)return e;return e.status=oj,Promise.all(Object.keys(e.parcels).map(t=>e.parcels[t].unmountThisParcel())).then(n,r=>n().then(()=>{let n=Error(r.message);if(t)throw oD(n,e,oL);ox(n,e,oL)})).then(()=>e);function n(){return aa(e,"unmount").then(()=>{e.status=oT},n=>{if(t)throw oD(n,e,oL);ox(n,e,oL)})}})}let o1=!1,o2=!1;function o3(e,t){return Promise.resolve().then(()=>e.status!==oT?e:(o1||(window.dispatchEvent(new ok("single-spa:before-first-mount")),o1=!0),e.status=oB,aa(e,"mount").then(()=>(e.status=oI,o2||(window.dispatchEvent(new ok("single-spa:first-mount")),o2=!0),e)).catch(n=>{return e.status=oI,o0(e,!0).then(r,r);function r(){if(t)throw oD(n,e,oL);return ox(n,e,oL),e}})))}let o5=0,o4={parcels:{}};function o6(){return o8.apply(o4,arguments)}function o8(e,t){let n,r,o,a=this;if(!e||"object"!=typeof e&&"function"!=typeof e)throw Error(oS(2,!1));if(e.name&&"string"!=typeof e.name)throw Error(oS(3,!1,typeof e.name));let i=o5++,s=e.name||`parcel-${i}`;if("object"!=typeof t)throw Error(oS(4,!1,s,typeof t));if(!t.domElement)throw Error(oS(5,!1,s));let l="function"==typeof e,c=l?e:()=>Promise.resolve(e),p={id:i,parcels:{},status:l?oz:oO,customProps:t,parentName:oV(a),unmountThisParcel:()=>f.then(()=>{if(p.status!==oI)throw Error(oS(6,!1,s,p.status));return o0(p,!0)}).then(e=>(p.parentName&&delete a.parcels[p.id],e)).then(e=>(r(e),e)).catch(e=>{throw p.status=oL,o(e),e})};a.parcels[i]=p;let u=c();if(!u||"function"!=typeof u.then)throw Error(oS(7,!1));let d=(u=u.then(e=>{if(!e)throw Error(oS(8,!1));if(s=e.name||`parcel-${i}`,Object.prototype.hasOwnProperty.call(e,"bootstrap")&&!oY(e.bootstrap))throw Error(oS(9,!1,s));if(!oY(e.mount))throw Error(oS(10,!1,s));if(!oY(e.unmount))throw Error(oS(11,!1,s));if(e.update&&!oY(e.update))throw Error(oS(12,!1,s));let t=oJ(e,"bootstrap"),r=oJ(e,"mount"),o=oJ(e,"unmount");p.status=oO,p.name=s,p.bootstrap=t,p.mount=r,p.unmount=o,p.timeouts=ai(e.timeouts),e.update&&(p.update=oJ(e,"update"),n.update=function(e){return p.customProps=e,o7(Promise.resolve().then(()=>{if(p.status!==oI)throw Error(oS(32,!1,oV(p)));return p.status=oN,aa(p,"update").then(()=>(p.status=oI,p)).catch(e=>{throw oD(e,p,oL)})}))})})).then(()=>oQ(p,!0)),f=d.then(()=>o3(p,!0)),h=new Promise((e,t)=>{r=e,o=t});return n={mount:()=>o7(Promise.resolve().then(()=>{if(p.status!==oT)throw Error(oS(13,!1,s,p.status));return a.parcels[i]=p,o3(p)})),unmount:()=>o7(p.unmountThisParcel()),getStatus:()=>p.status,loadPromise:o7(u),bootstrapPromise:o7(d),mountPromise:o7(f),unmountPromise:o7(h)}}function o7(e){return e.then(()=>null)}function o9(e){let t=oV(e),n="function"==typeof e.customProps?e.customProps(t,window.location):e.customProps;("object"!=typeof n||null===n||Array.isArray(n))&&(n={},console.warn(oS(40,!1),t,n));let r=oH({},n,{name:t,mountParcel:o8.bind(e),singleSpa:oA});return oU(e)&&(r.unmountSelf=e.unmountThisParcel),r}let ae={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 at(e,t,n){if("number"!=typeof e||e<=0)throw Error(oS(16,!1));ae.bootstrap={millis:e,dieOnTimeout:t,warningMillis:n||1e3}}function an(e,t,n){if("number"!=typeof e||e<=0)throw Error(oS(17,!1));ae.mount={millis:e,dieOnTimeout:t,warningMillis:n||1e3}}function ar(e,t,n){if("number"!=typeof e||e<=0)throw Error(oS(18,!1));ae.unmount={millis:e,dieOnTimeout:t,warningMillis:n||1e3}}function ao(e,t,n){if("number"!=typeof e||e<=0)throw Error(oS(19,!1));ae.unload={millis:e,dieOnTimeout:t,warningMillis:n||1e3}}function aa(e,t){let n=e.timeouts[t],r=n.warningMillis,o=oq(e);return new Promise((a,i)=>{let s=!1,l=!1;e[t](o9(e)).then(e=>{s=!0,a(e)}).catch(e=>{s=!0,i(e)}),setTimeout(()=>p(1),r),setTimeout(()=>p(!0),n.millis);let c=oS(31,!1,t,o,oV(e),n.millis);function p(e){s||(!0===e?(l=!0,n.dieOnTimeout?i(Error(c)):console.error(c)):!l&&(console.warn(c),e*r+r<n.millis&&setTimeout(()=>p(e+1),r)))}})}function ai(e){let t={};for(let n in ae)t[n]=oH({},ae[n],e&&e[n]||{});return t}function as(e){return Promise.resolve().then(()=>{let t,n;return e.loadPromise?e.loadPromise:e.status!==oM&&e.status!==oF?e:(e.status=oz,e.loadPromise=Promise.resolve().then(()=>{let r=e.loadApp(o9(e));if(!oZ(r))throw n=!0,Error(oS(33,!1,oV(e)));return r.then(n=>{let r;e.loadErrorTime=null,"object"!=typeof(t=n)&&(r=34),Object.prototype.hasOwnProperty.call(t,"bootstrap")&&!oY(t.bootstrap)&&(r=35),oY(t.mount)||(r=36),oY(t.unmount)||(r=37);let o=oq(t);if(r){let n;try{n=JSON.stringify(t)}catch(e){}return console.error(oS(r,!1,o,oV(e),n),t),ox(void 0,e,oL),e}return t.devtools&&t.devtools.overlays&&(e.devtools.overlays=oH({},e.devtools.overlays,t.devtools.overlays)),e.status=oO,e.bootstrap=oJ(t,"bootstrap"),e.mount=oJ(t,"mount"),e.unmount=oJ(t,"unmount"),e.unload=oJ(t,"unload"),e.timeouts=ai(t.timeouts),delete e.loadPromise,e})}).catch(t=>{let r;return delete e.loadPromise,n?r=oL:(r=oF,e.loadErrorTime=(new Date).getTime()),ox(t,e,r),e}))})}let al="u">typeof window,ac={hashchange:[],popstate:[]},ap=["hashchange","popstate"];function au(e){let 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(oS(14,!1));t=e.currentTarget.href,e.preventDefault()}let n=ag(window.location.href),r=ag(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 ad(e){if(e){let t=e[0].type;ap.indexOf(t)>=0&&ac[t].forEach(t=>{try{t.apply(this,e)}catch(e){setTimeout(()=>{throw e})}})}}function af(){aW([],arguments)}function ah(e,t){return function(){let n=window.location.href,o=e.apply(this,arguments),a=window.location.href;return r&&n===a||window.dispatchEvent(function(e,t){let 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)),o}}let am=null,a_=!1;function ay(e){if(a_)throw Error(oS(43,!1));r=!e||!e.hasOwnProperty("urlRerouteOnly")||e.urlRerouteOnly,a_=!0,am=window.history.replaceState,window.addEventListener("hashchange",af),window.addEventListener("popstate",af);let t=window.addEventListener,n=window.removeEventListener;window.addEventListener=function(e,n){if(!("function"==typeof n&&ap.indexOf(e)>=0)||oK(ac[e],e=>e===n))return t.apply(this,arguments);ac[e].push(n)},window.removeEventListener=function(e,t){return"function"==typeof t&&ap.indexOf(e)>=0&&(ac[e]=ac[e].filter(e=>e!==t)),n.apply(this,arguments)},window.history.pushState=ah(window.history.pushState,"pushState"),window.history.replaceState=ah(am,"replaceState")}function ag(e){let t=document.createElement("a");return t.href=e,t}al&&(window.singleSpaNavigate?console.warn(oS(41,!1)):window.singleSpaNavigate=au);let ab=!1;function av(e=window.jQuery){if(e||window.$&&window.$.fn&&window.$.fn.jquery&&(e=window.$),e&&!ab){let t=e.fn.on,n=e.fn.off;e.fn.on=function(e,n){return aA.call(this,t,window.addEventListener,e,n,arguments)},e.fn.off=function(e,t){return aA.call(this,n,window.removeEventListener,e,t,arguments)},ab=!0}}function aA(e,t,n,r,o){return"string"!=typeof n?e.apply(this,o):(n.split(/\s+/).forEach(e=>{ap.indexOf(e)>=0&&(t(e,r),n=n.replace(e,""))}),""===n.trim()?this:e.apply(this,o))}let a$={};function ak(e){return Promise.resolve().then(()=>{let t=a$[oV(e)];if(!t)return e;if(e.status===oM)return aw(e,t),e;if(e.status===oR)return t.promise.then(()=>e);if(e.status!==oT&&e.status!==oF)return e;let n=e.status===oF?Promise.resolve():aa(e,"unload");return e.status=oR,n.then(()=>(aw(e,t),e)).catch(n=>(delete a$[oV(e)],delete e.bootstrap,delete e.mount,delete e.unmount,delete e.unload,ox(n,e,oL),t.reject(n),e))})}function aw(e,t){delete a$[oV(e)],delete e.bootstrap,delete e.mount,delete e.unmount,delete e.unload,e.status=oM,t.resolve()}function ax(e,t,n,r){a$[oV(e)]={app:e,resolve:n,reject:r},Object.defineProperty(a$[oV(e)],"promise",{get:t})}let aC=[];function aE(){return aC.filter(oW).map(oV)}function aS(){return aC.map(oV)}function aD(e){let t=oK(aC,t=>oV(t)===e);return t?t.status:null}let aM=!1;function az(e,t,n,r){var o,a;let i,s,l=(i={name:null,loadApp:null,activeWhen:null,customProps:null},"object"==typeof e?(function(e){if(Array.isArray(e)||null===e)throw Error(oS(39,!1));let t=["name","app","activeWhen","customProps"],n=Object.keys(e).reduce((e,n)=>t.indexOf(n)>=0?e:e.concat(n),[]);if(0!==n.length)throw Error(oS(38,!1,t.join(", "),n.join(", ")));if("string"!=typeof e.name||0===e.name.length||"object"!=typeof e.app&&"function"!=typeof e.app)throw Error(oS(20,!1));let r=e=>"string"==typeof e||"function"==typeof e;if(!(r(e.activeWhen)||Array.isArray(e.activeWhen)&&e.activeWhen.every(r)))throw Error(oS(24,!1));if(!aI(e.customProps))throw Error(oS(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(oS(20,!1));if(!t)throw Error(oS(23,!1));if("function"!=typeof n)throw Error(oS(24,!1));if(!aI(r))throw Error(oS(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)?()=>Promise.resolve(o):o,i.customProps=i.customProps||{},s=(s=Array.isArray(a=i.activeWhen)?a:[a]).map(e=>"function"==typeof e?e:aN(e)),i.activeWhen=e=>s.some(t=>t(e)),i);if(aV||aM||(aM=!0,setTimeout(()=>{aV||console.warn(oS(1,!1))},5e3)),-1!==aS().indexOf(l.name))throw Error(oS(21,!1,l.name));aC.push(oH({loadErrorTime:null,status:oM,parcels:{},devtools:{overlays:{options:{},selectors:[]}}},l)),al&&(av(),aW())}function aO(e=window.location){return aC.filter(t=>t.activeWhen(e)).map(oV)}function aP(e){if(0===aC.filter(t=>oV(t)===e).length)throw Error(oS(25,!1,e));return(al?aT(e,{waitForUnmount:!1}):Promise.resolve()).then(()=>{let t=aC.map(oV).indexOf(e);aC.splice(t,1)})}function aT(e,t={waitForUnmount:!1}){if("string"!=typeof e)throw Error(oS(26,!1));let n=oK(aC,t=>oV(t)===e);if(!n)throw Error(oS(27,!1,e));let r=a$[oV(n)];if(t&&t.waitForUnmount){if(r)return r.promise;{let e=new Promise((t,r)=>{ax(n,()=>e,t,r)});return e}}{let e;return r?(e=r.promise,aB(n,r.resolve,r.reject)):e=new Promise((t,r)=>{ax(n,()=>e,t,r),aB(n,t,r)}),e}}function aB(e,t,n){Promise.resolve().then(()=>{if(oK(aO(),t=>t===oV(e)))return aL()}).then(()=>o0(e).then(ak).then(()=>{t(),setTimeout(()=>{aW()})})).catch(n)}function aI(e){return!e||"function"==typeof e||"object"==typeof e&&null!==e&&!Array.isArray(e)}function aN(e,t){let n=function(e,t){let n=0,r=!1,o="^";"/"!==e[0]&&(e="/"+e);for(let t=0;t<e.length;t++){let n=e[t],o=r&&"/"===n;(!r&&":"===n||o)&&a(t)}return a(e.length),RegExp(o,"i");function a(a){let i=e.slice(n,a).replace(/[|\\{}()[\]^$+*?.]/g,"\\$&");if(o+=r?"[^/]+/?":i,a===e.length)if(r)t&&(o+="$");else{let e=t?"":".*";o="/"===o.charAt(o.length-1)?`${o}${e}$`:`${o}(/${e})?(#.*)?$`}r=!r,n=a}}(e,t);return e=>{let t=e.origin;t||(t=`${e.protocol}//${e.host}`);let r=e.href.replace(t,"").replace(e.search,"").split("?")[0];return n.test(r)}}let aj=!1,aR=[],aF=al&&window.location.href;function aL(){return aW()}function aW(e=[],t,n=!1){let r,o,a,i,s;if(aj)return new Promise((e,n)=>{aR.push({resolve:e,reject:n,eventArguments:t})});let{appsToUnload:l,appsToUnmount:c,appsToLoad:p,appsToMount:u}=(r=[],o=[],a=[],i=[],s=(new Date).getTime(),aC.forEach(e=>{let t=e.status!==oL&&oG(e);switch(e.status){case oF:t&&s-e.loadErrorTime>=200&&a.push(e);break;case oM:case oz:t&&a.push(e);break;case oO:case oT:!t&&a$[oV(e)]?r.push(e):t&&i.push(e);break;case oI:t||o.push(e)}}),{appsToUnload:r,appsToUnmount:o,appsToLoad:a,appsToMount:i}),d,f=[],h=aF,m=aF=window.location.href;return aV?(aj=!0,d=l.concat(p,c,u),Promise.resolve().then(()=>(A(0===d.length?"before-no-app-change":"before-app-change",v(!0)),A("before-routing-event",v(!0,{cancelNavigation:y})),Promise.all(f).then(n=>{if(n.some(e=>e))return am.call(window.history,history.state,"",h.substring(location.origin.length)),aF=location.href,aj=!1,aW(e,t,!0);let r=l.map(ak),o=Promise.all(c.map(o0).map(e=>e.then(ak)).concat(r));o.then(()=>{A("before-mount-routing-event",v(!0))},e=>{throw e});let a=p.map(e=>as(e).then(e=>aG(e,o))),i=u.filter(e=>0>p.indexOf(e)).map(e=>aG(e,o));return o.catch(e=>{throw b(),e}).then(()=>(b(),Promise.all(a.concat(i)).catch(t=>{throw e.forEach(e=>e.reject(t)),t}).then(g).then(()=>{},e=>{throw e})))})))):(d=p,Promise.resolve().then(()=>Promise.all(p.map(as)).then(b).then(()=>[]).catch(e=>{throw b(),e}).finally(()=>{})));function y(e=!0){let t="function"==typeof(null==e?void 0:e.then)?e:Promise.resolve(e);f.push(t.catch(e=>(console.warn(Error(oS(42,!1))),console.warn(e),!1)))}function g(){let t=aE();e.forEach(e=>e.resolve(t));try{A(0===d.length?"no-app-change":"app-change",v()),A("routing-event",v())}catch(e){setTimeout(()=>{throw e})}if(aj=!1,aR.length>0){let e=aR;aR=[],aW(e)}return t}function b(){n||(e.forEach(e=>{ad(e.eventArguments)}),ad(t))}function v(e=!1,n){let r={},o={[oI]:[],[oT]:[],[oM]:[],[oL]:[]};e?(p.concat(u).forEach((e,t)=>{i(e,oI)}),l.forEach(e=>{i(e,oM)}),c.forEach(e=>{i(e,oT)})):d.forEach(e=>{i(e)});let a={detail:{newAppStatuses:r,appsByNewStatus:o,totalAppChanges:d.length,originalEvent:null==t?void 0:t[0],oldUrl:h,newUrl:m}};return n&&oH(a.detail,n),a;function i(e,t){let n=oV(e);t=t||aD(n),r[n]=t,(o[t]=o[t]||[]).push(n)}}function A(e,t){n||window.dispatchEvent(new ok(`single-spa:${e}`,t))}}function aG(e,t){return oG(e)?oQ(e).then(e=>t.then(()=>oG(e)?o3(e):e)):t.then(()=>e)}let aV=!1;function aU(e){aV=!0,al&&(ay(e),aW())}function aq(e,t){let n=window.getOpenmrsSpaBase().replace(/\/$/,"");return aH(e,{openmrsBase:window.openmrsBase,openmrsSpaBase:n,...t}).replace(/^\/\//,"/")}function aH(e,t){return Object.keys(t).reduce((e,n)=>e.split("${"+n+"}").join(t[n]),e)}function aK({to:e,templateParams:t}){let n=window.getOpenmrsSpaBase().replace(/\/$/,""),r=aq(e,t).replace(window.location.origin,"");r.startsWith(n)?au(r):window.location.assign(r)}al&&window.__SINGLE_SPA_DEVTOOLS__&&(window.__SINGLE_SPA_DEVTOOLS__.exposedMethods={getRawAppData:function(){return[...aC]},reroute:aW,NOT_LOADED:oM,toLoadPromise:as,toBootstrapPromise:oQ,unregisterApplication:aP,getProfilerData:function(){return oX}});let aY="openmrs:history";function aJ(e){let t=JSON.parse(sessionStorage.getItem(aY)??"[]")||[];t.push(e),t.length>50&&(t=t.slice(-50)),sessionStorage.setItem(aY,JSON.stringify(t))}function aZ(){0===JSON.parse(sessionStorage.getItem(aY)??"[]").length&&document.referrer&&aJ(document.referrer),window.addEventListener("single-spa:routing-event",e=>{let t=aX();e.detail.originalEvent?.singleSpaTrigger=="replaceState"?(t[t.length-1]=window.location.href,sessionStorage.setItem(aY,JSON.stringify(t))):!e.detail.originalEvent?.singleSpa&&t.includes(window.location.href)?aQ({toUrl:window.location.href}):t[t.length-1]!==window.location.href&&aJ(window.location.href)})}function aX(){return JSON.parse(sessionStorage.getItem(aY)??"[]")}function aQ({toUrl:e}){let t=aX(),n=t.lastIndexOf(e);if(-1!=n){let e=t.slice(0,n+1);aK({to:t[n]}),sessionStorage.setItem(aY,JSON.stringify(e))}else throw Error(`URL ${e} not found in history; cannot go back to it.`)}function a0(){sessionStorage.removeItem(aY)}let a1="${openmrsSpaBase}/login",a2={redirectAuthFailure:{enabled:{_type:r$.Boolean,_default:!0,_description:"Whether to redirect logged-out users to `redirectAuthFailure.url`"},url:{_type:r$.String,_default:a1,_validators:[od.isUrl],_description:"The url to which users will be redirected when they are logged out. If set to blank, the `location` header from the response will be used."},errors:{_type:r$.Array,_default:[401],_elements:{_type:r$.Number,_validators:[od.inRange(100,600)]},_description:"The HTTP error codes for which users will be redirected"},resolvePromise:{_type:r$.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."}},followRedirects:{_type:r$.Boolean,_default:!0,_description:"Whether openmrsFetch should support redirects returned from the backend"}};function a3(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}let a5="/ws/rest/v1",a4="/ws/fhir2/R4",a6=`${a5}/session`;function a8(e){return e&&e.startsWith("http")?e:("/"!==e[0]&&(e="/"+e),window.openmrsBase+e)}function a7(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=a8(e);if(t.headers||(t.headers={}),eI(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(a5)&&void 0===t.headers["Disable-WWW-Authenticate"]&&(t.headers["Disable-WWW-Authenticate"]="true"),e.startsWith(a4)){let e=new URL(n,window.location.toString());e.searchParams.has("_summary")||(e.searchParams.set("_summary","data"),n=e.toString())}let r=Error();return window.fetch(n,t).then(async e=>{let{redirectAuthFailure:t,followRedirects:o}=await rX("@openmrs/esm-api");if(e.ok)if(204!==e.status)return e.clone().text().then(t=>{try{t&&(e.data=JSON.parse(t))}catch(e){}return e});else{if(o&&e.headers.has("location")){let t=e.headers.get("location");t&&aK({to:t})}return e.data=null,e}return n===a8(a6)&&403===e.status||t.enabled&&t.errors.includes(e.status)?(a0(),aK({to:t.url||e.headers.get("location")||a1}),t.resolvePromise?Promise.resolve():new Promise(()=>{})):e.clone().text().then(t=>{let o=t;try{o=JSON.parse(t)}catch(e){}throw new ie(n,e,o,r)},t=>{throw new ie(n,e,null,r)})})}function a9(e,t={}){if("object"!=typeof t)throw Error("The second argument to openmrsObservableFetch must be either omitted or an object");let n=new AbortController;return t.signal=n.signal,new eC(r=>{let o=!1;return a7(e,t).then(e=>{o=!0,r.next(e),r.complete()},e=>{o=!0,r.error(e)}),()=>{o||n.abort()}})}class ie extends Error{constructor(e,t,n,r){super(),a3(this,"response",void 0),a3(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:
|
|
12
|
+
${t}`)}return r}let r9=(e,t)=>{let n=structuredClone(t);if(!e)return n;for(let t of Object.keys(e)){let r=n[t],o=e[t];if(o&&(o.hasOwnProperty("_type")||o.hasOwnProperty("_default"))){n.hasOwnProperty(t)||(n[t]=o._default);let e=o._elements;if(r&&oe(e)){if(o._type===r$.Array&&Array.isArray(r)){let o=r.map(t=>r9(e,t));n[t]=o}else if(o._type===r$.Object)for(let t of Object.keys(r))r[t]=r9(e,r[t])}}else if(ot(o)){let e=r??{};ot(e)&&(n[t]=r9(o,e))}}return n};function oe(e){return!!e&&Object.keys(e).filter(e=>!["_default","_validators"].includes(e)).length>0}function ot(e){return"object"==typeof e&&!Array.isArray(e)&&null!==e}let on=new Set;function or(e,t){let n=`${e}:::${t}`;on||(on=new Set),on.has(n)||(console.error(t),on.add(n))}function oo(e){e?on.forEach(t=>{t.startsWith(e)&&on.delete(t)}):on.clear()}function oa(){rG.forEach(e=>e()),rG.length=0,rU()}let oi={"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:r$.Object,_default:{},_validators:[rk(e=>Object.keys(e).every(e=>/^[a-z]{2,3}(-[A-Z]{2,3})?$/.test(e)),e=>{let t=Object.keys(e).filter(e=>!/^[a-z]{2,3}(-[A-Z]{2,3})?$/.test(e));return`The 'Translation overrides' object should have language codes for keys. Language codes must be in the form of a two-to-three letter language code optionally followed by a hyphen and a two-to-three letter country code. The following keys do not conform: ${t.join(", ")}.`})]}},os={"Display conditions":{privileges:{_description:"The privilege(s) the user must have to use this extension",_type:r$.Array,_default:[]},expression:{_description:"The expression that determines whether the extension is displayed",_type:r$.String,_default:void 0}},...oi},ol=(e,t)=>rk(n=>e<=n&&n<=t,`must be between ${e} and ${t}`),oc=e=>{let t=e.concat(["openmrsBase","openmrsSpaBase"]);return rk(e=>{if(!e||"string"!=typeof e)return!1;let n=/\${(.*?)}/g,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(", "))},op=oc([]),ou=e=>rk(t=>e.includes(t),`Must be one of the following: '${e.join("', '")}'.`),od={inRange:ol,isUrl:op,isUrlWithTemplateParameters:oc,oneOf:ou};var of=n(8067);let oh=U("breadcrumbs",[]);function om(e){return o_([e])}function o_(e){let t=[...oy(),...e.map(e=>({matcher:e.matcher instanceof RegExp?e.matcher:"string"==typeof e.matcher?(0,of.pathToRegexp)(e.matcher).regexp:(0,of.pathToRegexp)(e.path).regexp,settings:e}))];oh.setState(t,!0)}function oy(){return oh.getState()}function og(e,t){if(t)return function(e,t){let[n]=e.filter(e=>e.matcher.test(t));return n}(e,t)||function(e,t){let n=t.split("/");for(;n.length>1;){n.pop();let t=og(e,n.join("/"));if(t)return t}}(e,t)}function ob(e,t){if(e.length>0){let n=og(e,t);if(n){let t=[n],r=og(e,n.settings.parent);for(;void 0!==r;)t.push(r),r=og(e,r.settings.parent);return t.reverse()}}return[]}function ov(e){return ob(oy(),e)}var oA=Object.freeze({__proto__:null,get start(){return aU},get ensureJQuerySupport(){return av},get setBootstrapMaxTime(){return at},get setMountMaxTime(){return an},get setUnmountMaxTime(){return ar},get setUnloadMaxTime(){return ao},get registerApplication(){return az},get unregisterApplication(){return aP},get getMountedApps(){return aE},get getAppStatus(){return aD},get unloadApplication(){return aT},get checkActivityFunctions(){return aO},get getAppNames(){return aS},get pathToActiveWhen(){return aN},get navigateToUrl(){return au},get patchHistoryApi(){return ay},get triggerAppChange(){return aL},get addErrorHandler(){return oC},get removeErrorHandler(){return oE},get mountRootParcel(){return o6},get NOT_LOADED(){return oM},get LOADING_SOURCE_CODE(){return oz},get NOT_BOOTSTRAPPED(){return oO},get BOOTSTRAPPING(){return oP},get NOT_MOUNTED(){return oT},get MOUNTING(){return oB},get UPDATING(){return oN},get LOAD_ERROR(){return oF},get MOUNTED(){return oI},get UNLOADING(){return oR},get UNMOUNTING(){return oj},get SKIP_BECAUSE_BROKEN(){return oL}}),o$=("u">typeof globalThis?globalThis:"u">typeof window?window:"u">typeof global?global:"u">typeof self?self:{}).CustomEvent,ok=!function(){try{var e=new o$("cat",{detail:{foo:"bar"}});return"cat"===e.type&&"bar"===e.detail.foo}catch(e){}return!1}()?"u">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=!!t.bubbles,n.cancelable=!!t.cancelable,n.detail=t.detail):(n.bubbles=!1,n.cancelable=!1,n.detail=void 0),n}:o$;let ow=[];function ox(e,t,n){let r=oD(e,t,n);ow.length?ow.forEach(e=>e(r)):setTimeout(()=>{throw r})}function oC(e){if("function"!=typeof e)throw Error(oS(28,!1));ow.push(e)}function oE(e){if("function"!=typeof e)throw Error(oS(29,!1));let t=!1;return ow=ow.filter(n=>{let r=n===e;return t=t||r,!r}),t}function oS(e,t,...n){return`single-spa minified message #${e}: ${t?t+" ":""}See https://single-spa.js.org/error/?code=${e}${n.length?`&arg=${n.join("&arg=")}`:""}`}function oD(e,t,n){let r,o=`${oq(t)} '${oV(t)}' died in status ${t.status}: `;if(e instanceof Error){try{e.message=o+e.message}catch(e){}r=e}else{console.warn(oS(30,!1,t.status,oV(t)));try{r=Error(o+JSON.stringify(e))}catch(t){r=e}}return r.appOrParcelName=oV(t),t.status=n,r}let oM="NOT_LOADED",oz="LOADING_SOURCE_CODE",oO="NOT_BOOTSTRAPPED",oP="BOOTSTRAPPING",oT="NOT_MOUNTED",oB="MOUNTING",oI="MOUNTED",oN="UPDATING",oj="UNMOUNTING",oR="UNLOADING",oF="LOAD_ERROR",oL="SKIP_BECAUSE_BROKEN";function oW(e){return e.status===oI}function oG(e){try{return e.activeWhen(window.location)}catch(t){return ox(t,e,oL),!1}}function oV(e){return e.name}function oU(e){return!!e.unmountThisParcel}function oq(e){return oU(e)?"parcel":"application"}function oH(){for(let e=arguments.length-1;e>0;e--)for(let t in arguments[e])"__proto__"!==t&&(arguments[e-1][t]=arguments[e][t]);return arguments[0]}function oK(e,t){for(let n=0;n<e.length;n++)if(t(e[n]))return e[n];return null}function oY(e){return e&&("function"==typeof e||Array.isArray(e)&&!oK(e,e=>"function"!=typeof e))}function oJ(e,t){let n=e[t]||[];0===(n=Array.isArray(n)?n:[n]).length&&(n=[()=>Promise.resolve()]);let r=oq(e),o=oV(e);return function(e){return n.reduce((n,a,i)=>n.then(()=>{let n=a(e);return oZ(n)?n:Promise.reject(oS(15,!1,r,o,t,i))}),Promise.resolve())}}function oZ(e){return e&&"function"==typeof e.then&&"function"==typeof e.catch}let oX=[];function oQ(e,t){return Promise.resolve().then(()=>e.status!==oO?e:(e.status=oP,e.bootstrap?aa(e,"bootstrap").then(n).catch(n=>{if(t)throw oD(n,e,oL);return ox(n,e,oL),e}):Promise.resolve().then(n)));function n(){return e.status=oT,e}}function o0(e,t){return Promise.resolve().then(()=>{if(e.status!==oI)return e;return e.status=oj,Promise.all(Object.keys(e.parcels).map(t=>e.parcels[t].unmountThisParcel())).then(n,r=>n().then(()=>{let n=Error(r.message);if(t)throw oD(n,e,oL);ox(n,e,oL)})).then(()=>e);function n(){return aa(e,"unmount").then(()=>{e.status=oT},n=>{if(t)throw oD(n,e,oL);ox(n,e,oL)})}})}let o1=!1,o2=!1;function o3(e,t){return Promise.resolve().then(()=>e.status!==oT?e:(o1||(window.dispatchEvent(new ok("single-spa:before-first-mount")),o1=!0),e.status=oB,aa(e,"mount").then(()=>(e.status=oI,o2||(window.dispatchEvent(new ok("single-spa:first-mount")),o2=!0),e)).catch(n=>{return e.status=oI,o0(e,!0).then(r,r);function r(){if(t)throw oD(n,e,oL);return ox(n,e,oL),e}})))}let o5=0,o4={parcels:{}};function o6(){return o8.apply(o4,arguments)}function o8(e,t){let n,r,o,a=this;if(!e||"object"!=typeof e&&"function"!=typeof e)throw Error(oS(2,!1));if(e.name&&"string"!=typeof e.name)throw Error(oS(3,!1,typeof e.name));let i=o5++,s=e.name||`parcel-${i}`;if("object"!=typeof t)throw Error(oS(4,!1,s,typeof t));if(!t.domElement)throw Error(oS(5,!1,s));let l="function"==typeof e,c=l?e:()=>Promise.resolve(e),p={id:i,parcels:{},status:l?oz:oO,customProps:t,parentName:oV(a),unmountThisParcel:()=>f.then(()=>{if(p.status!==oI)throw Error(oS(6,!1,s,p.status));return o0(p,!0)}).then(e=>(p.parentName&&delete a.parcels[p.id],e)).then(e=>(r(e),e)).catch(e=>{throw p.status=oL,o(e),e})};a.parcels[i]=p;let u=c();if(!u||"function"!=typeof u.then)throw Error(oS(7,!1));let d=(u=u.then(e=>{if(!e)throw Error(oS(8,!1));if(s=e.name||`parcel-${i}`,Object.prototype.hasOwnProperty.call(e,"bootstrap")&&!oY(e.bootstrap))throw Error(oS(9,!1,s));if(!oY(e.mount))throw Error(oS(10,!1,s));if(!oY(e.unmount))throw Error(oS(11,!1,s));if(e.update&&!oY(e.update))throw Error(oS(12,!1,s));let t=oJ(e,"bootstrap"),r=oJ(e,"mount"),o=oJ(e,"unmount");p.status=oO,p.name=s,p.bootstrap=t,p.mount=r,p.unmount=o,p.timeouts=ai(e.timeouts),e.update&&(p.update=oJ(e,"update"),n.update=function(e){return p.customProps=e,o7(Promise.resolve().then(()=>{if(p.status!==oI)throw Error(oS(32,!1,oV(p)));return p.status=oN,aa(p,"update").then(()=>(p.status=oI,p)).catch(e=>{throw oD(e,p,oL)})}))})})).then(()=>oQ(p,!0)),f=d.then(()=>o3(p,!0)),h=new Promise((e,t)=>{r=e,o=t});return n={mount:()=>o7(Promise.resolve().then(()=>{if(p.status!==oT)throw Error(oS(13,!1,s,p.status));return a.parcels[i]=p,o3(p)})),unmount:()=>o7(p.unmountThisParcel()),getStatus:()=>p.status,loadPromise:o7(u),bootstrapPromise:o7(d),mountPromise:o7(f),unmountPromise:o7(h)}}function o7(e){return e.then(()=>null)}function o9(e){let t=oV(e),n="function"==typeof e.customProps?e.customProps(t,window.location):e.customProps;("object"!=typeof n||null===n||Array.isArray(n))&&(n={},console.warn(oS(40,!1),t,n));let r=oH({},n,{name:t,mountParcel:o8.bind(e),singleSpa:oA});return oU(e)&&(r.unmountSelf=e.unmountThisParcel),r}let ae={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 at(e,t,n){if("number"!=typeof e||e<=0)throw Error(oS(16,!1));ae.bootstrap={millis:e,dieOnTimeout:t,warningMillis:n||1e3}}function an(e,t,n){if("number"!=typeof e||e<=0)throw Error(oS(17,!1));ae.mount={millis:e,dieOnTimeout:t,warningMillis:n||1e3}}function ar(e,t,n){if("number"!=typeof e||e<=0)throw Error(oS(18,!1));ae.unmount={millis:e,dieOnTimeout:t,warningMillis:n||1e3}}function ao(e,t,n){if("number"!=typeof e||e<=0)throw Error(oS(19,!1));ae.unload={millis:e,dieOnTimeout:t,warningMillis:n||1e3}}function aa(e,t){let n=e.timeouts[t],r=n.warningMillis,o=oq(e);return new Promise((a,i)=>{let s=!1,l=!1;e[t](o9(e)).then(e=>{s=!0,a(e)}).catch(e=>{s=!0,i(e)}),setTimeout(()=>p(1),r),setTimeout(()=>p(!0),n.millis);let c=oS(31,!1,t,o,oV(e),n.millis);function p(e){s||(!0===e?(l=!0,n.dieOnTimeout?i(Error(c)):console.error(c)):!l&&(console.warn(c),e*r+r<n.millis&&setTimeout(()=>p(e+1),r)))}})}function ai(e){let t={};for(let n in ae)t[n]=oH({},ae[n],e&&e[n]||{});return t}function as(e){return Promise.resolve().then(()=>{let t,n;return e.loadPromise?e.loadPromise:e.status!==oM&&e.status!==oF?e:(e.status=oz,e.loadPromise=Promise.resolve().then(()=>{let r=e.loadApp(o9(e));if(!oZ(r))throw n=!0,Error(oS(33,!1,oV(e)));return r.then(n=>{let r;e.loadErrorTime=null,"object"!=typeof(t=n)&&(r=34),Object.prototype.hasOwnProperty.call(t,"bootstrap")&&!oY(t.bootstrap)&&(r=35),oY(t.mount)||(r=36),oY(t.unmount)||(r=37);let o=oq(t);if(r){let n;try{n=JSON.stringify(t)}catch(e){}return console.error(oS(r,!1,o,oV(e),n),t),ox(void 0,e,oL),e}return t.devtools&&t.devtools.overlays&&(e.devtools.overlays=oH({},e.devtools.overlays,t.devtools.overlays)),e.status=oO,e.bootstrap=oJ(t,"bootstrap"),e.mount=oJ(t,"mount"),e.unmount=oJ(t,"unmount"),e.unload=oJ(t,"unload"),e.timeouts=ai(t.timeouts),delete e.loadPromise,e})}).catch(t=>{let r;return delete e.loadPromise,n?r=oL:(r=oF,e.loadErrorTime=(new Date).getTime()),ox(t,e,r),e}))})}let al="u">typeof window,ac={hashchange:[],popstate:[]},ap=["hashchange","popstate"];function au(e){let 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(oS(14,!1));t=e.currentTarget.href,e.preventDefault()}let n=ag(window.location.href),r=ag(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 ad(e){if(e){let t=e[0].type;ap.indexOf(t)>=0&&ac[t].forEach(t=>{try{t.apply(this,e)}catch(e){setTimeout(()=>{throw e})}})}}function af(){aW([],arguments)}function ah(e,t){return function(){let n=window.location.href,o=e.apply(this,arguments),a=window.location.href;return r&&n===a||window.dispatchEvent(function(e,t){let 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)),o}}let am=null,a_=!1;function ay(e){if(a_)throw Error(oS(43,!1));r=!e||!e.hasOwnProperty("urlRerouteOnly")||e.urlRerouteOnly,a_=!0,am=window.history.replaceState,window.addEventListener("hashchange",af),window.addEventListener("popstate",af);let t=window.addEventListener,n=window.removeEventListener;window.addEventListener=function(e,n){if(!("function"==typeof n&&ap.indexOf(e)>=0)||oK(ac[e],e=>e===n))return t.apply(this,arguments);ac[e].push(n)},window.removeEventListener=function(e,t){return"function"==typeof t&&ap.indexOf(e)>=0&&(ac[e]=ac[e].filter(e=>e!==t)),n.apply(this,arguments)},window.history.pushState=ah(window.history.pushState,"pushState"),window.history.replaceState=ah(am,"replaceState")}function ag(e){let t=document.createElement("a");return t.href=e,t}al&&(window.singleSpaNavigate?console.warn(oS(41,!1)):window.singleSpaNavigate=au);let ab=!1;function av(e=window.jQuery){if(e||window.$&&window.$.fn&&window.$.fn.jquery&&(e=window.$),e&&!ab){let t=e.fn.on,n=e.fn.off;e.fn.on=function(e,n){return aA.call(this,t,window.addEventListener,e,n,arguments)},e.fn.off=function(e,t){return aA.call(this,n,window.removeEventListener,e,t,arguments)},ab=!0}}function aA(e,t,n,r,o){return"string"!=typeof n?e.apply(this,o):(n.split(/\s+/).forEach(e=>{ap.indexOf(e)>=0&&(t(e,r),n=n.replace(e,""))}),""===n.trim()?this:e.apply(this,o))}let a$={};function ak(e){return Promise.resolve().then(()=>{let t=a$[oV(e)];if(!t)return e;if(e.status===oM)return aw(e,t),e;if(e.status===oR)return t.promise.then(()=>e);if(e.status!==oT&&e.status!==oF)return e;let n=e.status===oF?Promise.resolve():aa(e,"unload");return e.status=oR,n.then(()=>(aw(e,t),e)).catch(n=>(delete a$[oV(e)],delete e.bootstrap,delete e.mount,delete e.unmount,delete e.unload,ox(n,e,oL),t.reject(n),e))})}function aw(e,t){delete a$[oV(e)],delete e.bootstrap,delete e.mount,delete e.unmount,delete e.unload,e.status=oM,t.resolve()}function ax(e,t,n,r){a$[oV(e)]={app:e,resolve:n,reject:r},Object.defineProperty(a$[oV(e)],"promise",{get:t})}let aC=[];function aE(){return aC.filter(oW).map(oV)}function aS(){return aC.map(oV)}function aD(e){let t=oK(aC,t=>oV(t)===e);return t?t.status:null}let aM=!1;function az(e,t,n,r){var o,a;let i,s,l=(i={name:null,loadApp:null,activeWhen:null,customProps:null},"object"==typeof e?(function(e){if(Array.isArray(e)||null===e)throw Error(oS(39,!1));let t=["name","app","activeWhen","customProps"],n=Object.keys(e).reduce((e,n)=>t.indexOf(n)>=0?e:e.concat(n),[]);if(0!==n.length)throw Error(oS(38,!1,t.join(", "),n.join(", ")));if("string"!=typeof e.name||0===e.name.length||"object"!=typeof e.app&&"function"!=typeof e.app)throw Error(oS(20,!1));let r=e=>"string"==typeof e||"function"==typeof e;if(!(r(e.activeWhen)||Array.isArray(e.activeWhen)&&e.activeWhen.every(r)))throw Error(oS(24,!1));if(!aI(e.customProps))throw Error(oS(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(oS(20,!1));if(!t)throw Error(oS(23,!1));if("function"!=typeof n)throw Error(oS(24,!1));if(!aI(r))throw Error(oS(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)?()=>Promise.resolve(o):o,i.customProps=i.customProps||{},s=(s=Array.isArray(a=i.activeWhen)?a:[a]).map(e=>"function"==typeof e?e:aN(e)),i.activeWhen=e=>s.some(t=>t(e)),i);if(aV||aM||(aM=!0,setTimeout(()=>{aV||console.warn(oS(1,!1))},5e3)),-1!==aS().indexOf(l.name))throw Error(oS(21,!1,l.name));aC.push(oH({loadErrorTime:null,status:oM,parcels:{},devtools:{overlays:{options:{},selectors:[]}}},l)),al&&(av(),aW())}function aO(e=window.location){return aC.filter(t=>t.activeWhen(e)).map(oV)}function aP(e){if(0===aC.filter(t=>oV(t)===e).length)throw Error(oS(25,!1,e));return(al?aT(e,{waitForUnmount:!1}):Promise.resolve()).then(()=>{let t=aC.map(oV).indexOf(e);aC.splice(t,1)})}function aT(e,t={waitForUnmount:!1}){if("string"!=typeof e)throw Error(oS(26,!1));let n=oK(aC,t=>oV(t)===e);if(!n)throw Error(oS(27,!1,e));let r=a$[oV(n)];if(t&&t.waitForUnmount){if(r)return r.promise;{let e=new Promise((t,r)=>{ax(n,()=>e,t,r)});return e}}{let e;return r?(e=r.promise,aB(n,r.resolve,r.reject)):e=new Promise((t,r)=>{ax(n,()=>e,t,r),aB(n,t,r)}),e}}function aB(e,t,n){Promise.resolve().then(()=>{if(oK(aO(),t=>t===oV(e)))return aL()}).then(()=>o0(e).then(ak).then(()=>{t(),setTimeout(()=>{aW()})})).catch(n)}function aI(e){return!e||"function"==typeof e||"object"==typeof e&&null!==e&&!Array.isArray(e)}function aN(e,t){let n=function(e,t){let n=0,r=!1,o="^";"/"!==e[0]&&(e="/"+e);for(let t=0;t<e.length;t++){let n=e[t],o=r&&"/"===n;(!r&&":"===n||o)&&a(t)}return a(e.length),RegExp(o,"i");function a(a){let i=e.slice(n,a).replace(/[|\\{}()[\]^$+*?.]/g,"\\$&");if(o+=r?"[^/]+/?":i,a===e.length)if(r)t&&(o+="$");else{let e=t?"":".*";o="/"===o.charAt(o.length-1)?`${o}${e}$`:`${o}(/${e})?(#.*)?$`}r=!r,n=a}}(e,t);return e=>{let t=e.origin;t||(t=`${e.protocol}//${e.host}`);let r=e.href.replace(t,"").replace(e.search,"").split("?")[0];return n.test(r)}}let aj=!1,aR=[],aF=al&&window.location.href;function aL(){return aW()}function aW(e=[],t,n=!1){let r,o,a,i,s;if(aj)return new Promise((e,n)=>{aR.push({resolve:e,reject:n,eventArguments:t})});let{appsToUnload:l,appsToUnmount:c,appsToLoad:p,appsToMount:u}=(r=[],o=[],a=[],i=[],s=(new Date).getTime(),aC.forEach(e=>{let t=e.status!==oL&&oG(e);switch(e.status){case oF:t&&s-e.loadErrorTime>=200&&a.push(e);break;case oM:case oz:t&&a.push(e);break;case oO:case oT:!t&&a$[oV(e)]?r.push(e):t&&i.push(e);break;case oI:t||o.push(e)}}),{appsToUnload:r,appsToUnmount:o,appsToLoad:a,appsToMount:i}),d,f=[],h=aF,m=aF=window.location.href;return aV?(aj=!0,d=l.concat(p,c,u),Promise.resolve().then(()=>(A(0===d.length?"before-no-app-change":"before-app-change",v(!0)),A("before-routing-event",v(!0,{cancelNavigation:y})),Promise.all(f).then(n=>{if(n.some(e=>e))return am.call(window.history,history.state,"",h.substring(location.origin.length)),aF=location.href,aj=!1,aW(e,t,!0);let r=l.map(ak),o=Promise.all(c.map(o0).map(e=>e.then(ak)).concat(r));o.then(()=>{A("before-mount-routing-event",v(!0))},e=>{throw e});let a=p.map(e=>as(e).then(e=>aG(e,o))),i=u.filter(e=>0>p.indexOf(e)).map(e=>aG(e,o));return o.catch(e=>{throw b(),e}).then(()=>(b(),Promise.all(a.concat(i)).catch(t=>{throw e.forEach(e=>e.reject(t)),t}).then(g).then(()=>{},e=>{throw e})))})))):(d=p,Promise.resolve().then(()=>Promise.all(p.map(as)).then(b).then(()=>[]).catch(e=>{throw b(),e}).finally(()=>{})));function y(e=!0){let t="function"==typeof(null==e?void 0:e.then)?e:Promise.resolve(e);f.push(t.catch(e=>(console.warn(Error(oS(42,!1))),console.warn(e),!1)))}function g(){let t=aE();e.forEach(e=>e.resolve(t));try{A(0===d.length?"no-app-change":"app-change",v()),A("routing-event",v())}catch(e){setTimeout(()=>{throw e})}if(aj=!1,aR.length>0){let e=aR;aR=[],aW(e)}return t}function b(){n||(e.forEach(e=>{ad(e.eventArguments)}),ad(t))}function v(e=!1,n){let r={},o={[oI]:[],[oT]:[],[oM]:[],[oL]:[]};e?(p.concat(u).forEach((e,t)=>{i(e,oI)}),l.forEach(e=>{i(e,oM)}),c.forEach(e=>{i(e,oT)})):d.forEach(e=>{i(e)});let a={detail:{newAppStatuses:r,appsByNewStatus:o,totalAppChanges:d.length,originalEvent:null==t?void 0:t[0],oldUrl:h,newUrl:m}};return n&&oH(a.detail,n),a;function i(e,t){let n=oV(e);t=t||aD(n),r[n]=t,(o[t]=o[t]||[]).push(n)}}function A(e,t){n||window.dispatchEvent(new ok(`single-spa:${e}`,t))}}function aG(e,t){return oG(e)?oQ(e).then(e=>t.then(()=>oG(e)?o3(e):e)):t.then(()=>e)}let aV=!1;function aU(e){aV=!0,al&&(ay(e),aW())}function aq(e,t){let n=window.getOpenmrsSpaBase().replace(/\/$/,"");return aH(e,{openmrsBase:window.openmrsBase,openmrsSpaBase:n,...t}).replace(/^\/\//,"/")}function aH(e,t){return Object.keys(t).reduce((e,n)=>e.split("${"+n+"}").join(t[n]),e)}function aK({to:e,templateParams:t}){let n=window.getOpenmrsSpaBase().replace(/\/$/,""),r=aq(e,t).replace(window.location.origin,"");r.startsWith(n)?au(r):window.location.assign(r)}al&&window.__SINGLE_SPA_DEVTOOLS__&&(window.__SINGLE_SPA_DEVTOOLS__.exposedMethods={getRawAppData:function(){return[...aC]},reroute:aW,NOT_LOADED:oM,toLoadPromise:as,toBootstrapPromise:oQ,unregisterApplication:aP,getProfilerData:function(){return oX}});let aY="openmrs:history";function aJ(e){let t=JSON.parse(sessionStorage.getItem(aY)??"[]")||[];t.push(e),t.length>50&&(t=t.slice(-50)),sessionStorage.setItem(aY,JSON.stringify(t))}function aZ(){0===JSON.parse(sessionStorage.getItem(aY)??"[]").length&&document.referrer&&aJ(document.referrer),window.addEventListener("single-spa:routing-event",e=>{let t=aX();e.detail.originalEvent?.singleSpaTrigger=="replaceState"?(t[t.length-1]=window.location.href,sessionStorage.setItem(aY,JSON.stringify(t))):!e.detail.originalEvent?.singleSpa&&t.includes(window.location.href)?aQ({toUrl:window.location.href}):t[t.length-1]!==window.location.href&&aJ(window.location.href)})}function aX(){return JSON.parse(sessionStorage.getItem(aY)??"[]")}function aQ({toUrl:e}){let t=aX(),n=t.lastIndexOf(e);if(-1!=n){let e=t.slice(0,n+1);aK({to:t[n]}),sessionStorage.setItem(aY,JSON.stringify(e))}else throw Error(`URL ${e} not found in history; cannot go back to it.`)}function a0(){sessionStorage.removeItem(aY)}let a1="${openmrsSpaBase}/login",a2={redirectAuthFailure:{enabled:{_type:r$.Boolean,_default:!0,_description:"Whether to redirect logged-out users to `redirectAuthFailure.url`"},url:{_type:r$.String,_default:a1,_validators:[od.isUrl],_description:"The url to which users will be redirected when they are logged out. If set to blank, the `location` header from the response will be used."},errors:{_type:r$.Array,_default:[401],_elements:{_type:r$.Number,_validators:[od.inRange(100,600)]},_description:"The HTTP error codes for which users will be redirected"},resolvePromise:{_type:r$.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."}},followRedirects:{_type:r$.Boolean,_default:!0,_description:"Whether openmrsFetch should support redirects returned from the backend"}};function a3(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}let a5="/ws/rest/v1",a4="/ws/fhir2/R4",a6=`${a5}/session`;function a8(e){return e&&e.startsWith("http")?e:("/"!==e[0]&&(e="/"+e),window.openmrsBase+e)}function a7(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=a8(e);if(t.headers||(t.headers={}),eI(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(a5)&&void 0===t.headers["Disable-WWW-Authenticate"]&&(t.headers["Disable-WWW-Authenticate"]="true"),e.startsWith(a4)){let e=new URL(n,window.location.toString());e.searchParams.has("_summary")||(e.searchParams.set("_summary","data"),n=e.toString())}let r=Error();return window.fetch(n,t).then(async e=>{let{redirectAuthFailure:t,followRedirects:o}=await rX("@openmrs/esm-api");if(e.ok){let t=e.headers.get("location");return(o&&t&&(n===a8(a6)||204===e.status)&&aK({to:t}),204===e.status)?(e.data=null,e):e.clone().text().then(t=>{try{t&&(e.data=JSON.parse(t))}catch(e){}return e})}return n===a8(a6)&&403===e.status||t.enabled&&t.errors.includes(e.status)?(a0(),aK({to:t.url||e.headers.get("location")||a1}),t.resolvePromise?Promise.resolve():new Promise(()=>{})):e.clone().text().then(t=>{let o=t;try{o=JSON.parse(t)}catch(e){}throw new ie(n,e,o,r)},t=>{throw new ie(n,e,null,r)})})}function a9(e,t={}){if("object"!=typeof t)throw Error("The second argument to openmrsObservableFetch must be either omitted or an object");let n=new AbortController;return t.signal=n.signal,new eC(r=>{let o=!1;return a7(e,t).then(e=>{o=!0,r.next(e),r.complete()},e=>{o=!0,r.error(e)}),()=>{o||n.abort()}})}class ie extends Error{constructor(e,t,n,r){super(),a3(this,"response",void 0),a3(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:
|
|
13
13
|
${r.stack}
|
|
14
14
|
Stacktrace for incoming response:
|
|
15
15
|
${this.stack}`}}let it=U("session",{loaded:!1,session:null}),ir=0;function io(e={includeAuthStatus:!0}){return(ir<Date.now()-6e4||!it.getState().loaded)&&is(),new eC(t=>{let n=n=>{n.loaded&&(e.includeAuthStatus?t.next(n.session):t.next(n.session?.user))};return n(it.getState()),it.subscribe(n)})}function ia(){return(ir<Date.now()-6e4||!it.getState().loaded)&&is(),it}function ii(e){let t=e.locale??e.user?.userProperties?.defaultLocale;t&&t.includes("_")&&(t=t.replaceAll("_","-")),function(e){if(void 0===e||"string"!=typeof e)return!1;try{new Intl.Locale(e)}catch(e){return!1}return!0}(t)&&t!==document.documentElement.getAttribute("lang")&&document.documentElement.setAttribute("lang",t)}function is(e,t){ir=Date.now();let n={};return e&&t&&(n.Authorization=`Basic ${window.btoa(`${e}:${t}`)}`),im(a7(a6,{headers:n}))}function il(){it.setState({loaded:!0,session:{authenticated:!1,sessionId:""}})}function ic(e,t){var n,r;if(void 0===t)return!e;if(!e)return!0;return n=e,r=t,("string"==typeof n?!J(r.privileges.find(e=>n===e.display)):Array.isArray(n)?n.every(e=>!J(r.privileges.find(t=>e===t.display))):(J(n)||console.error(`Could not understand privileges "${n}"`),!0))||!J(t.roles.find(e=>"System Developer"===e.display))}function ip(){let e,t;return new Promise(n=>{let r=r=>{r.loaded&&r.session.user&&(e=r.session.user,n(r.session.user),t&&t())};r(it.getState()),e||(t=it.subscribe(r))})}function iu(){return new Promise((e,t)=>{io().subscribe(t=>{e(t.sessionLocation)},t).unsubscribe()})}async function id(e,t){return im(a7(a6,{method:"POST",body:{sessionLocation:e},headers:{"Content-Type":"application/json"},signal:t.signal}))}async function ih(e,t,n){return n||(n=new AbortController),await a7(`${a5}/user/${e}`,{method:"POST",body:{userProperties:t},headers:{"Content-Type":"application/json"},signal:n.signal}),is()}function im(e){return new Promise((t,n)=>{e.then(e=>{let r;"object"==typeof e?.data?(r={loaded:!0,session:e.data},it.setState(r),t(r)):(r={loaded:!1,session:null},it.setState(r),n(r))}).catch(e=>{B(`Failed to fetch new session information: ${e}`);let t={loaded:!1,session:null};it.setState(t),n(t)})})}function i_(){return"development"===window.spaEnv||"true"===localStorage.getItem("openmrs:devtools")}it.subscribe(e=>{e.loaded&&e.session&&ii(e.session)});let iy={"webservices.rest":"2.24.0",fhir2:"1.0.0-SNAPSHOT"};function ig(){rq("@openmrs/esm-api",a2),is()}let ib={address1:"Address line 1",address2:"Address line 2",address3:"Address line 3",address4:"Address line 4",address5:"Address line 5",address6:"Address line 6",city:"City",cityVillage:"City",country:"Country",countyDistrict:"District",district:"District",postalCode:"Postal code",state:"State",stateProvince:"State",closeAllOpenedWorkspaces:"Discard changes in {{count}} workspaces",closingAllWorkspacesPromptBody:"There may be unsaved changes in the following workspaces. Do you want to discard changes in the following workspaces? {{workspaceNames}}",closingAllWorkspacesPromptTitle:"You have unsaved changes",discard:"Discard",hide:"Hide",maximize:"Maximize",minimize:"Minimize",openAnyway:"Open anyway",unsavedChangesInOpenedWorkspace:"You may have unsaved changes in the opened workspace. Do you want to discard these changes?",unsavedChangesInWorkspace:'There may be unsaved changes in "{{workspaceName}}". Please save them before opening another workspace.',unsavedChangesTitleText:"Unsaved changes",workspaceHeader:"Workspace header",closeWorkspaces2PromptTitle:"Close workspace(s)",closeWorkspaces2PromptBody:"You are about to close the following workspace(s), which might have unsaved changes:",abnormalValue:"Abnormal value",actions:"Actions",actionableNotification:"Actionable notification",address:"Address",age:"Age",batchActionItemSelected:"{{totalSelected}} item selected",batchActionsItemsSelected:"{{totalSelected}} items selected",cancel:"Cancel",change:"Change",Clinic:"Clinic",close:"Close",closesActionableNotification:"Close actionable notification",closeSnackbar:"Close snackbar",confirm:"Confirm",contactAdministratorIfIssuePersists:"Contact your system administrator if the problem persists.",contactDetails:"Contact details",delete:"Delete",discardChanges:"Discard changes",edit:"Edit",emptyStateText:"There are no {{displayText}} to display",error:"Error",errorCopy:"Sorry, there was a problem displaying this information. You can try to reload this page, or contact the site administrator and quote the error code above.",errorLoadingLoginLocations:"Unable to load login locations. Please try again or contact support if the problem persists.",female:"Female",leftNavigation:"Left navigation",loading:"Loading",male:"Male",noResultsToDisplay:"No results to display",notAvailable:"Not available",other:"Other",paginationItemsCount:"{{pageItemsCount}} / {{totalItems}} items",paginationOfPages:"of {{count}} pages",patientAvatarAlt:"Avatar for {{patientName}}",patientIdentifierSticker:"Patient identifier sticker",patientLists:"Patient lists",patientPhotoAlt:"Profile photo of {{patientName}}",patientPhotoPlaceholder:"Photo placeholder for {{patientName}}",print:"Print",printError:"Print error",printErrorExplainer:"An error occurred in {{errorLocation}}",printIdentifierSticker:"Print identifier sticker",printing:"Printing",recordNewEntry:"Record {{displayText}}",relationships:"Relationships",resetOverrides:"Reset overrides",save:"Save",scriptLoadingFailed:"Error: Script failed to load",scriptLoadingError:"Failed to load overridden script from {{url}}. Please check that the bundled script is available at the expected URL. Click the button below to reset all import map overrides.",searchForLocation:"Search for a location",seeAll:"See all",seeMoreLists:"See {{count}} more lists",selectAll:"Select all",sex:"Sex",showLess:"Show less",showMore:"Show more",snackbarNotification:"Snackbar notification",toggleDevTools:"Toggle dev tools",unknown:"Unknown",yearAbbreviation:"yr",yearsAbbreviation:"yrs"};var iv=n(2635);let iA=iv.Ay.default||iv.Ay;function i$(e,t,n,r){return iA.t(t,{ns:e,defaultValue:n,...r})}function ik(e,t,n){return ib[e]?i$("core",e,t??ib[e],n):(console.error(`O3 Core Translations does not provide key '${e}'. The key itself is being rendered as text.`),e)}iA.on("initialized",function(){window.i18next.loadNamespaces(["core"])});let iw="import-map-override:",ix="import-map-overrides-disabled",iC="import-map-overrides:change",iE=!1,iS=null;async function iD(){let e=document.querySelectorAll('script[type="systemjs-importmap"]'),t=[];for(let n=0;n<e.length;n++){let r=e[n];try{if(r.src){let e=await fetch(r.src);t.push(await e.json())}else r.textContent&&t.push(JSON.parse(r.textContent))}catch(e){console.warn(`[import-maps] Failed to parse import map from script tag at index ${n}`,e)}}return iM(t)}function iM(e){let t={imports:{}};for(let n of e)n?.imports&&Object.assign(t.imports,n.imports);return t}function iz(){let e={};try{let t=iI();for(let n=0;n<localStorage.length;n++){let r=localStorage.key(n);if(r?.startsWith(iw)){let n=r.slice(iw.length);if(!t.includes(n)){let t=localStorage.getItem(r);t&&(e[n]=t)}}}}catch(e){console.warn("[import-maps] Failed to read import-map overrides from localStorage",e)}return{imports:e}}async function iO(){let e=await iD();return iE?iM([e,iS??iz()]):e}async function iP(){return iD()}async function iT(){return iE?iM([await iD(),iz()]):iD()}function iB(e){if(!iE)return{imports:{}};if(e){let e={};for(let t=0;t<localStorage.length;t++){let n=localStorage.key(t);if(n?.startsWith(iw)){let t=localStorage.getItem(n);t&&(e[n.slice(iw.length)]=t)}}return{imports:e}}return iz()}function iI(){if(!iE)return[];try{let e=localStorage.getItem(ix);if(e){let t=JSON.parse(e);if(Array.isArray(t))return t}}catch{}return[]}function iN(e){return!!iE&&iI().includes(e)}function ij(e,t){if(!iE)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{localStorage.setItem(iw+e,t),window.dispatchEvent(new CustomEvent(iC))}catch(e){console.warn("[import-maps] Failed to write import-map override to localStorage",e)}}function iR(e){if(!iE)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{localStorage.removeItem(iw+e);let t=iI().filter(t=>t!==e);t.length>0?localStorage.setItem(ix,JSON.stringify(t)):localStorage.removeItem(ix),window.dispatchEvent(new CustomEvent(iC))}catch(e){console.warn("[import-maps] Failed to update import-map overrides in localStorage",e)}}function iF(){if(!iE)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{let e=[];for(let t=0;t<localStorage.length;t++){let n=localStorage.key(t);n?.startsWith(iw)&&e.push(n)}e.forEach(e=>localStorage.removeItem(e)),localStorage.removeItem(ix),window.dispatchEvent(new CustomEvent(iC))}catch(e){console.warn("[import-maps] Failed to clear import-map overrides from localStorage",e)}}function iL(e){if(!iE)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{let t=iI().filter(t=>t!==e);t.length>0?localStorage.setItem(ix,JSON.stringify(t)):localStorage.removeItem(ix),window.dispatchEvent(new CustomEvent(iC))}catch(e){console.warn("[import-maps] Failed to update import-map overrides in localStorage",e)}}let iW=!1;function iG(){!iW&&(iW=!0,(iE="development"===window.spaEnv)&&(iS=iz()))}function iV(e){return e.replace(/[\/\-@]/g,"_")}async function iU(e,t="./start",r){var o;let a,i=!r?.maxLoadingTime||r.maxLoadingTime<=0?6e5:r.maxLoadingTime;await Promise.race([iq(e,r?.importMap),new Promise((t,n)=>{a=setTimeout(()=>{var t;n(Error(`Could not resolve requested script, ${e}, within ${(t=i)<1e3?`${t} milliseconds`:t<6e4?`${Math.floor(t/1e3)} seconds`:t<36e5?`${Math.floor(t/6e4)} minutes`:t<864e5?`${Math.floor(t/36e5)} hours`:`${Math.floor(t/864e5)} days`}.`))},i)})]),a&&clearTimeout(a);let s=iV(e),l=window[s];if(!("object"==typeof(o=l)&&null!==o&&"init"in o&&"function"==typeof o.init&&"get"in o&&"function"==typeof o.get)){let e=`The global variable ${s} does not refer to a federated module`;throw console.error(e),Error(e)}l.init(n.S.default);let c=(await l.get(t))();if("object"!=typeof c||null===c){let t=`Container for ${e} did not return an ESM module as expected`;throw console.error(t),Error(t)}return c}async function iq(e,t){if("string"!=typeof e||0===e.trim().length){let e="Attempted to call importDynamic() without supplying a package to load";throw console.error(e),Error(e)}let n=iV(e);if(!window[n]){let n=t??await iH();if(!n.imports.hasOwnProperty(e)){let t=`Could not find the package ${e} defined in the current importmap`;throw console.error(t),Error(t)}let r=n.imports[e];r.startsWith("./")&&(r=window.spaBase+r.substring(1));let o=e in iB().imports;try{return await new Promise((e,t)=>{!function(e,t,n){let r=document.head.querySelector(`script[src="${e}"]`),o=window[iK];if(o||(o=window[iK]=new Set([])),r)if(o.has(e)){let e,o,a;a=()=>{e&&r.removeEventListener("load",e),o&&r.removeEventListener("error",o)},e=()=>{a(),t(null)},o=e=>{a(),n(e.message)},r.addEventListener("load",e),r.addEventListener("error",o)}else console.warn(`Script at ${e} already loaded. Not loading it again.`),t(null);else{let r,a,i;o.add(e);let s=document.createElement("script");s.src=e,s.type="text/javascript",s.async=!0;let l=setTimeout(()=>{console.error(`The script at ${e} did not load within 5 seconds. This may indicate an issue with the imports in the script's entry-point file or with the script's bundler configuration.`)},5e3);i=()=>{clearTimeout(l),o.delete(e),r&&s.removeEventListener("load",r),a&&s.removeEventListener("error",a)},r=()=>{i(),t(null)},a=t=>{i();let r=`Failed to load script from ${e}`;console.error(r,t),n(t.message??r)},s.addEventListener("load",r),s.addEventListener("error",a),document.head.appendChild(s)}}(r,e,t)})}catch(e){return o&&M({kind:"error",title:ik("scriptLoadingFailed","Error: Script failed to load"),description:ik("scriptLoadingError","Failed to load overridden script from {{- url}}. Please check that the bundled script is available at the expected URL. Click the button below to reset all import map overrides.",{url:r}),actionButtonLabel:ik("resetOverrides","Reset overrides"),onActionButtonClick(){iF(),window.location.reload()}}),Promise.reject(e)}}return Promise.resolve()}async function iH(){return iO()}let iK=Symbol("__openmrs_script_loading");function iY(e){return!!e&&"object"==typeof e&&!(Object.hasOwn(e,"pages")&&(!e.pages||!Array.isArray(e.pages))||Object.hasOwn(e,"extensions")&&(!e.extensions||!Array.isArray(e.extensions))||Object.hasOwn(e,"workspaces")&&(!e.workspaces||!Array.isArray(e.workspaces))||Object.hasOwn(e,"modals")&&(!e.modals||!Array.isArray(e.modals)))}function iJ(e){return!!e&&"object"==typeof e&&Object.entries(e).every(([e,t])=>"string"==typeof e&&iY(t))}let iZ="openmrs-routes:",iX="openmrs-routes:change",iQ=!1,i0=null;async function i1(){let e=document.querySelectorAll("script[type='openmrs-routes']"),t=[];for(let n=0;n<e.length;n++){let r=e[n];try{let e;if(r.src){let t=await fetch(r.src);e=await t.json()}else r.textContent&&(e=JSON.parse(r.textContent));e&&iJ(e)&&t.push(e)}catch(e){console.warn(`[route-maps] Failed to parse routes from script tag at index ${n}`,e)}}return i2(t)}function i2(e){let t={};for(let n of e)n&&"object"==typeof n&&Object.assign(t,n);return t}async function i3(){let e={};try{let t=[];for(let e=0;e<localStorage.length;e++){let n=localStorage.key(e);if(n?.startsWith(iZ)){let e=localStorage.getItem(n);e&&t.push({moduleName:n.slice(iZ.length),raw:e})}}for(let n of(await Promise.allSettled(t.map(async({moduleName:e,raw:t})=>{let n=JSON.parse(t);if(iY(n))return{moduleName:e,routes:n};if("string"==typeof n&&n.startsWith("http")){let t=await fetch(n),r=await t.json();if(iY(r))return{moduleName:e,routes:r};throw Error(`${n} did not resolve to a valid OpenmrsAppRoutes object`)}throw Error(`Override for ${e} is neither a valid routes object nor a URL`)}))))"fulfilled"===n.status?e[n.value.moduleName]=n.value.routes:console.warn("[route-maps] Failed to load route override",n.reason)}catch(e){console.warn("[route-maps] Failed to read route overrides from localStorage",e)}return e}async function i5(){let e=await i1();return iQ?i2([e,i0??await i3()]):e}async function i4(){return i1()}async function i6(){return iQ?i2([await i1(),await i3()]):i1()}function i8(){if(!iQ)return{};let e={};try{for(let t=0;t<localStorage.length;t++){let n=localStorage.key(t);if(n?.startsWith(iZ)){let t=localStorage.getItem(n);t&&(e[n.slice(iZ.length)]=t)}}}catch(e){console.warn("[route-maps] Failed to read route overrides from localStorage",e)}return e}function i7(e,t){if(!iQ)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{if("string"==typeof t)if(t.startsWith("http"))localStorage.setItem(iZ+e,JSON.stringify(t));else{let n=JSON.parse(t);if(!iY(n))return void console.error(`The supplied routes for ${e} is not a valid OpenmrsAppRoutes object`,t);localStorage.setItem(iZ+e,JSON.stringify(n))}else if(t instanceof URL)localStorage.setItem(iZ+e,JSON.stringify(t.toString()));else{if(!iY(t))return void console.error(`Override for ${e} is not in a valid format. Expected either a Javascript Object, a JSON string of a Javascript object, or a URL`,t);localStorage.setItem(iZ+e,JSON.stringify(t))}window.dispatchEvent(new CustomEvent(iX))}catch(e){console.warn("[route-maps] Failed to write route override to localStorage",e)}}function i9(e){if(!iQ)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{localStorage.removeItem(iZ+e),window.dispatchEvent(new CustomEvent(iX))}catch(e){console.warn("[route-maps] Failed to remove route override from localStorage",e)}}function se(){if(!iQ)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{let e=[];for(let t=0;t<localStorage.length;t++){let n=localStorage.key(t);n?.startsWith(iZ)&&e.push(n)}e.forEach(e=>localStorage.removeItem(e)),window.dispatchEvent(new CustomEvent(iX))}catch(e){console.warn("[route-maps] Failed to clear route overrides from localStorage",e)}}let st=null;function sn(){return st||(st=(iQ="development"===window.spaEnv)?i3().then(e=>{i0=e}):Promise.resolve())}let sr=`${a5}/attachment`;function so(e,t){return a7(`${sr}/${e}`,{signal:t.signal})}function sa(e,t,n){return a7(`${sr}?patient=${e}&includeEncounterless=${t}`,{signal:n.signal})}async function si(e,t){let n=new FormData;return n.append("fileCaption",t.fileDescription),n.append("patient",e),t.file?n.append("file",t.file,t.fileName):(n.append("file",new File([""],t.fileName),t.fileName),n.append("base64Content",t.base64Content)),a7(`${sr}`,{method:"POST",body:n})}function ss(e,t){return a7(`${sr}/${e}`,{method:"DELETE",signal:t.signal})}try{self["workbox:window:6.5.4"]&&_()}catch(e){}function sl(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 sc(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)}}function sp(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}try{self["workbox:core:6.5.4"]&&_()}catch(e){}var su=function(){var e=this;this.promise=new Promise(function(t,n){e.resolve=t,e.reject=n})};function sd(e,t){var n=location.href;return new URL(e,n).href===new URL(t,n).href}var sf=function(e,t){this.type=e,Object.assign(this,t)};function sh(e,t,n){return n?t?t(e):e:(e&&e.then||(e=Promise.resolve(e)),t?e.then(t):e)}function sm(){}var s_={type:"SKIP_WAITING"};function sy(e,t){if(!t)return e&&e.then?e.then(sm):Promise.resolve()}var sg=function(e){function t(t,n){var r,o;return void 0===n&&(n={}),(r=e.call(this)||this).nn={},r.tn=0,r.rn=new su,r.en=new su,r.on=new su,r.un=0,r.an=new Set,r.cn=function(){var e=r.fn,t=e.installing;r.tn>0||!sd(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,a=n===r.vn,i={sw:n,isExternal:a,originalEvent:e};!a&&r.mn&&(i.isUpdate=!0),r.dispatchEvent(new sf(o,i)),"installed"===o?r.wn=self.setTimeout(function(){"installed"===o&&t.waiting===n&&r.dispatchEvent(new sf("waiting",i))},200):"activating"===o&&(clearTimeout(r.wn),a||r.en.resolve(n))},r.dn=function(e){var t=r.hn,n=t!==navigator.serviceWorker.controller;r.dispatchEvent(new sf("controlling",{isExternal:n,originalEvent:e,sw:t,isUpdate:r.mn})),n||r.on.resolve(t)},o=function(e){var t=e.data,n=e.ports,o=e.source;return sh(r.getSW(),function(){r.an.has(o)&&r.dispatchEvent(new sf("message",{data:t,originalEvent:e,ports:n,sw:o}))})},r.gn=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}t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e;var n,r,o=t.prototype;return o.register=function(e){var t=(void 0===e?{}:e).immediate,n=void 0!==t&&t;try{var r,o,a,i=this;return r=function(){if(!n&&"complete"!==document.readyState)return sy(new Promise(function(e){return window.addEventListener("load",e)}))},o=function(){return i.mn=!!navigator.serviceWorker.controller,i.yn=i.pn(),sh(i.bn(),function(e){i.fn=e,i.yn&&(i.hn=i.yn,i.en.resolve(i.yn),i.on.resolve(i.yn),i.yn.addEventListener("statechange",i.ln,{once:!0}));var t=i.fn.waiting;return t&&sd(t.scriptURL,i.sn.toString())&&(i.hn=t,Promise.resolve().then(function(){i.dispatchEvent(new sf("waiting",{sw:t,wasWaitingBeforeRegister:!0}))}).then(function(){})),i.hn&&(i.rn.resolve(i.hn),i.an.add(i.hn)),i.fn.addEventListener("updatefound",i.cn),navigator.serviceWorker.addEventListener("controllerchange",i.dn),i.fn})},(a=r())&&a.then?a.then(o):o(a)}catch(e){return Promise.reject(e)}},o.update=function(){try{return this.fn?sy(this.fn.update()):void 0}catch(e){return Promise.reject(e)}},o.getSW=function(){return void 0!==this.hn?Promise.resolve(this.hn):this.rn.promise},o.messageSW=function(e){try{return sh(this.getSW(),function(t){return sl(t,e)})}catch(e){return Promise.reject(e)}},o.messageSkipWaiting=function(){this.fn&&this.fn.waiting&&sl(this.fn.waiting,s_)},o.pn=function(){var e=navigator.serviceWorker.controller;return e&&sd(e.scriptURL,this.sn.toString())?e:void 0},o.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 sh(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)}},n=[{key:"active",get:function(){return this.en.promise}},{key:"controlling",get:function(){return this.on.promise}}],sc(t.prototype,n),r&&sc(t,r),t}(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){var t;if("u"<typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(t=function(e){if(e){if("string"==typeof e)return sp(e,void 0);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?sp(e,void 0):void 0}}(e))){t&&(e=t);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(t=e[Symbol.iterator]()).next.bind(t)}(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}());function sb(e,t){if(void 0!==u)return console.warn(`The application's Service Worker has already been registered. The new service worker at ${e} will not be registered.`),u;if(!("serviceWorker"in navigator))throw Error("Registering the Service Worker is not possible due to missing browser capabilities.");let n=new sg(e,t);return u=n.register().then(()=>n.controlling.then(()=>n))}function sv(){return u??Promise.resolve(void 0)}let sA="x-omrs-offline-response-body",s$="x-omrs-offline-response-status",sk="x-omrs-offline-caching-strategy";async function sw(e){let t=await sv();return t?await t.messageSW(e):{success:!1,result:void 0,error:"No service worker has been registered. This is typically the case when the application has been built without offline-related features."}}async function sx(){let e=window.sessionStorage;try{e.setItem("someKeyHere","test"),e.removeItem("someKeyHere")}catch(t){if(t.code===DOMException.QUOTA_EXCEEDED_ERR&&0===e.length)return!0}return!1}async function sC(){return!window.indexedDB}async function sE(){return new Promise(e=>{let t=indexedDB.open("test");t.onerror=()=>e(!0),t.onsuccess=()=>e(!1)})}async function sS(){return await sE()||await sC()||await sx()}let sD="openmrs3:offline-mode",sM="unavailable";function sz(){return{current:sM,notAvailable:"unavailable"===sM,active:"on"===sM}}function sO(e){"unavailable"!==sM&&"unavailable"!==e&&(localStorage.setItem(sD,"on"===e?"active":"disabled"),sM=e)}async function sP(){await sS()||(sM="active"===localStorage.getItem(sD)?"on":"off"),navigator.onLine}let sT="u">typeof globalThis?globalThis:"u">typeof self?self:"u">typeof window?window:global,sB=Object.keys,sI=Array.isArray;function sN(e,t){return"object"!=typeof t||sB(t).forEach(function(n){e[n]=t[n]}),e}"u"<typeof Promise||sT.Promise||(sT.Promise=Promise);let sj=Object.getPrototypeOf,sR={}.hasOwnProperty;function sF(e,t){return sR.call(e,t)}function sL(e,t){"function"==typeof t&&(t=t(sj(e))),("u"<typeof Reflect?sB:Reflect.ownKeys)(t).forEach(n=>{sG(e,n,t[n])})}let sW=Object.defineProperty;function sG(e,t,n,r){sW(e,t,sN(n&&sF(n,"get")&&"function"==typeof n.get?{get:n.get,set:n.set,configurable:!0}:{value:n,configurable:!0,writable:!0},r))}function sV(e){return{from:function(t){return e.prototype=Object.create(t.prototype),sG(e.prototype,"constructor",e),{extend:sL.bind(null,e.prototype)}}}}let sU=Object.getOwnPropertyDescriptor;function sq(e,t){let n;return sU(e,t)||(n=sj(e))&&sq(n,t)}let sH=[].slice;function sK(e,t,n){return sH.call(e,t,n)}function sY(e,t){return t(e)}function sJ(e){if(!e)throw Error("Assertion Failed")}function sZ(e){sT.setImmediate?setImmediate(e):setTimeout(e,0)}function sX(e,t){return e.reduce((e,n,r)=>{var o=t(n,r);return o&&(e[o[0]]=o[1]),e},{})}function sQ(e,t){if("string"==typeof t&&sF(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 a=sQ(e,t[r]);n.push(a)}return n}var i=t.indexOf(".");if(-1!==i){var s=e[t.substr(0,i)];return null==s?void 0:sQ(s,t.substr(i+1))}}function s0(e,t,n){if(e&&void 0!==t&&(!("isFrozen"in Object)||!Object.isFrozen(e)))if("string"!=typeof t&&"length"in t){sJ("string"!=typeof n&&"length"in n);for(var r=0,o=t.length;r<o;++r)s0(e,t[r],n[r])}else{var a=t.indexOf(".");if(-1!==a){var i=t.substr(0,a),s=t.substr(a+1);if(""===s)void 0===n?sI(e)&&!isNaN(parseInt(i))?e.splice(i,1):delete e[i]:e[i]=n;else{var l=e[i];l&&sF(e,i)||(l=e[i]={}),s0(l,s,n)}}else void 0===n?sI(e)&&!isNaN(parseInt(t))?e.splice(t,1):delete e[t]:e[t]=n}}function s1(e){var t={};for(var n in e)sF(e,n)&&(t[n]=e[n]);return t}let s2=[].concat;function s3(e){return s2.apply([],e)}let s5="BigUint64Array,BigInt64Array,Array,Boolean,String,Date,RegExp,Blob,File,FileList,FileSystemFileHandle,FileSystemDirectoryHandle,ArrayBuffer,DataView,Uint8ClampedArray,ImageBitmap,ImageData,Map,Set,CryptoKey".split(",").concat(s3([8,16,32,64].map(e=>["Int","Uint","Float"].map(t=>t+e+"Array")))).filter(e=>sT[e]),s4=s5.map(e=>sT[e]);sX(s5,e=>[e,!0]);let s6=null;function s8(e){s6="u">typeof WeakMap&&new WeakMap;let t=function e(t){if(!t||"object"!=typeof t)return t;let n=s6&&s6.get(t);if(n)return n;if(sI(t)){n=[],s6&&s6.set(t,n);for(var r=0,o=t.length;r<o;++r)n.push(e(t[r]))}else if(s4.indexOf(t.constructor)>=0)n=t;else{let r=sj(t);for(var a in n=r===Object.prototype?{}:Object.create(r),s6&&s6.set(t,n),t)sF(t,a)&&(n[a]=e(t[a]))}return n}(e);return s6=null,t}let{toString:s7}={};function s9(e){return s7.call(e).slice(8,-1)}let le="u">typeof Symbol?Symbol.iterator:"@@iterator",lt="symbol"==typeof le?function(e){var t;return null!=e&&(t=e[le])&&t.apply(e)}:function(){return null},ln={};function lr(e){var t,n,r,o;if(1==arguments.length){if(sI(e))return e.slice();if(this===ln&&"string"==typeof e)return[e];if(o=lt(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=Array(t);t--;)n[t]=e[t];return n}return[e]}for(t=arguments.length,n=Array(t);t--;)n[t]=arguments[t];return n}let lo="u">typeof Symbol?e=>"AsyncFunction"===e[Symbol.toStringTag]:()=>!1;var la="u">typeof location&&/^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href),li=()=>!0;let ls=!Error("").stack;function ll(){if(ls)try{throw ll.arguments,Error()}catch(e){return e}return Error()}function lc(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(li).map(e=>"\n"+e).join("")):""}var lp=["Unknown","Constraint","Data","TransactionInactive","ReadOnly","Version","NotFound","InvalidState","InvalidAccess","Abort","Timeout","QuotaExceeded","Syntax","DataClone"],lu=["Modify","Bulk","OpenFailed","VersionChange","Schema","Upgrade","InvalidTable","MissingAPI","NoSuchDatabase","InvalidArgument","SubTransaction","Unsupported","Internal","DatabaseClosed","PrematureCommit","ForeignAwait"].concat(lp),ld={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 lf(e,t){this._e=ll(),this.name=e,this.message=t}function lh(e,t){return e+". Errors: "+Object.keys(t).map(e=>t[e].toString()).filter((e,t,n)=>n.indexOf(e)===t).join("\n")}function lm(e,t,n,r){this._e=ll(),this.failures=t,this.failedKeys=r,this.successCount=n,this.message=lh(e,t)}function l_(e,t){this._e=ll(),this.name="BulkError",this.failures=Object.keys(t).map(e=>t[e]),this.failuresByPos=t,this.message=lh(e,t)}sV(lf).from(Error).extend({stack:{get:function(){return this._stack||(this._stack=this.name+": "+this.message+lc(this._e,2))}},toString:function(){return this.name+": "+this.message}}),sV(lm).from(lf),sV(l_).from(lf);var ly=lu.reduce((e,t)=>(e[t]=t+"Error",e),{}),lg=lu.reduce((e,t)=>{var n=t+"Error";function r(e,r){this._e=ll(),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=ld[t]||n,this.inner=null)}return sV(r).from(lf),e[t]=r,e},{});lg.Syntax=SyntaxError,lg.Type=TypeError,lg.Range=RangeError;var lb=lp.reduce((e,t)=>(e[t+"Error"]=lg[t],e),{}),lv=lu.reduce((e,t)=>(-1===["Syntax","Type","Range"].indexOf(t)&&(e[t+"Error"]=lg[t]),e),{});function lA(){}function l$(e){return e}function lk(e,t){return null==e||e===l$?t:function(n){return t(e(n))}}function lw(e,t){return function(){e.apply(this,arguments),t.apply(this,arguments)}}function lx(e,t){return e===lA?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 a=t.apply(this,arguments);return r&&(this.onsuccess=this.onsuccess?lw(r,this.onsuccess):r),o&&(this.onerror=this.onerror?lw(o,this.onerror):o),void 0!==a?a:n}}function lC(e,t){return e===lA?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?lw(n,this.onsuccess):n),r&&(this.onerror=this.onerror?lw(r,this.onerror):r)}}function lE(e,t){return e===lA?t:function(n){var r=e.apply(this,arguments);sN(n,r);var o=this.onsuccess,a=this.onerror;this.onsuccess=null,this.onerror=null;var i=t.apply(this,arguments);return o&&(this.onsuccess=this.onsuccess?lw(o,this.onsuccess):o),a&&(this.onerror=this.onerror?lw(a,this.onerror):a),void 0===r?void 0===i?void 0:i:sN(r,i)}}function lS(e,t){return e===lA?t:function(){return!1!==t.apply(this,arguments)&&e.apply(this,arguments)}}function lD(e,t){return e===lA?t:function(){var n=e.apply(this,arguments);if(n&&"function"==typeof n.then){for(var r=this,o=arguments.length,a=Array(o);o--;)a[o]=arguments[o];return n.then(function(){return t.apply(r,a)})}return t.apply(this,arguments)}}lv.ModifyError=lm,lv.DexieError=lf,lv.BulkError=l_;var lM={};let[lz,lO,lP]="u"<typeof Promise?[]:(()=>{let e=Promise.resolve();if("u"<typeof crypto||!crypto.subtle)return[e,sj(e),e];let t=crypto.subtle.digest("SHA-512",new Uint8Array([0]));return[t,sj(t),e]})(),lT=lO&&lO.then,lB=lz&&lz.constructor,lI=!!lP;var lN=!1,lj=lP?()=>{lP.then(l4)}:sT.setImmediate?setImmediate.bind(null,l4):sT.MutationObserver?()=>{var e=document.createElement("div");new MutationObserver(()=>{l4(),e=null}).observe(e,{attributes:!0}),e.setAttribute("i","1")}:()=>{setTimeout(l4,0)},lR=function(e,t){lK.push([e,t]),lL&&(lj(),lL=!1)},lF=!0,lL=!0,lW=[],lG=[],lV=null,lU=l$,lq={id:"global",global:!0,ref:0,unhandleds:[],onunhandled:cb,pgp:!1,env:{},finalize:function(){this.unhandleds.forEach(e=>{try{cb(e[0],e[1])}catch(e){}})}},lH=lq,lK=[],lY=0,lJ=[];function lZ(e){if("object"!=typeof this)throw TypeError("Promises must be constructed via new");this._listeners=[],this.onuncatched=lA,this._lib=!1;var t=this._PSD=lH;if(la&&(this._stackHolder=ll(),this._prev=null,this._numPrev=0),"function"!=typeof e){if(e!==lM)throw TypeError("Not a function");return this._state=arguments[1],this._value=arguments[2],void(!1===this._state&&l0(this,this._value))}this._state=null,this._value=null,++t.ref,function e(t,n){try{n(n=>{if(null===t._state){if(n===t)throw TypeError("A promise cannot be resolved with itself.");var r=t._lib&&l6();n&&"function"==typeof n.then?e(t,(e,t)=>{n instanceof lZ?n._then(e,t):n.then(e,t)}):(t._state=!0,t._value=n,l1(t)),r&&l8()}},l0.bind(null,t))}catch(e){l0(t,e)}}(this,e)}let lX={get:function(){var e=lH,t=ca;function n(n,r){var o=!e.global&&(e!==lH||t!==ca);let a=o&&!cc();var i=new lZ((t,i)=>{l2(this,new lQ(c_(n,e,o,a),c_(r,e,o,a),t,i,e))});return la&&l5(i,this),i}return n.prototype=lM,n},set:function(e){sG(this,"then",e&&e.prototype===lM?lX:{get:function(){return e},set:lX.set})}};function lQ(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 l0(e,t){if(lG.push(t),null===e._state){var n=e._lib&&l6();t=lU(t),e._state=!1,e._value=t,la&&null!==t&&"object"==typeof t&&!t._promise&&function(e){try{e.apply(null,void 0)}catch(e){}}(()=>{var n=sq(t,"stack");t._promise=e,sG(t,"stack",{get:()=>lN?n&&(n.get?n.get.apply(t):n.value):e.stack})}),lW.some(t=>t._value===e._value)||lW.push(e),l1(e),n&&l8()}}function l1(e){var t=e._listeners;e._listeners=[];for(var n=0,r=t.length;n<r;++n)l2(e,t[n]);var o=e._PSD;--o.ref||o.finalize(),0===lY&&(++lY,lR(()=>{0==--lY&&l7()},[]))}function l2(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,++lY,lR(l3,[n,e,t])}else e._listeners.push(t)}function l3(e,t,n){try{lV=t;var r,o=t._value;t._state?r=e(o):(lG.length&&(lG=[]),r=e(o),-1===lG.indexOf(o)&&function(e){for(var t=lW.length;t;)if(lW[--t]._value===e._value)return void lW.splice(t,1)}(t)),n.resolve(r)}catch(e){n.reject(e)}finally{lV=null,0==--lY&&l7(),--n.psd.ref||n.psd.finalize()}}function l5(e,t){var n=t?t._numPrev+1:0;n<100&&(e._prev=t,e._numPrev=n)}function l4(){l6()&&l8()}function l6(){var e=lF;return lF=!1,lL=!1,e}function l8(){var e,t,n;do for(;lK.length>0;)for(e=lK,lK=[],n=e.length,t=0;t<n;++t){var r=e[t];r[0].apply(null,r[1])}while(lK.length>0);lF=!0,lL=!0}function l7(){var e=lW;lW=[],e.forEach(e=>{e._PSD.onunhandled.call(null,e._value,e)});for(var t=lJ.slice(0),n=t.length;n;)t[--n]()}function l9(e){return new lZ(lM,!1,e)}function ce(e,t){var n=lH;return function(){var r=l6(),o=lH;try{return cf(n,!0),e.apply(this,arguments)}catch(e){t&&t(e)}finally{cf(o,!1),r&&l8()}}}sL(lZ.prototype,{then:lX,_then:function(e,t){l2(this,new lQ(null,null,e,t,lH))},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):l9(e)):this.then(null,e=>e&&e.name===t?n(e):l9(e))},finally:function(e){return this.then(t=>(e(),t),t=>(e(),l9(t)))},stack:{get:function(){if(this._stack)return this._stack;try{lN=!0;var e=(function e(t,n,r){if(n.length===r)return n;var o="";if(!1===t._state){var a,i,s=t._value;null!=s?(a=s.name||"Error",i=s.message||s,o=lc(s,0)):(a=s,i=""),n.push(a+(i?": "+i:"")+o)}return la&&((o=lc(t._stackHolder,2))&&-1===n.indexOf(o)&&n.push(o),t._prev&&e(t._prev,n,r)),n})(this,[],20).join("\nFrom previous: ");return null!==this._state&&(this._stack=e),e}finally{lN=!1}}},timeout:function(e,t){return e<1/0?new lZ((n,r)=>{var o=setTimeout(()=>r(new lg.Timeout(t)),e);this.then(n,r).finally(clearTimeout.bind(null,o))}):this}}),"u">typeof Symbol&&Symbol.toStringTag&&sG(lZ.prototype,Symbol.toStringTag,"Dexie.Promise"),lq.env=ch(),sL(lZ,{all:function(){var e=lr.apply(null,arguments).map(cp);return new lZ(function(t,n){0===e.length&&t([]);var r=e.length;e.forEach((o,a)=>lZ.resolve(o).then(n=>{e[a]=n,--r||t(e)},n))})},resolve:e=>{if(e instanceof lZ)return e;if(e&&"function"==typeof e.then)return new lZ((t,n)=>{e.then(t,n)});var t=new lZ(lM,!0,e);return l5(t,lV),t},reject:l9,race:function(){var e=lr.apply(null,arguments).map(cp);return new lZ((t,n)=>{e.map(e=>lZ.resolve(e).then(t,n))})},PSD:{get:()=>lH,set:e=>lH=e},totalEchoes:{get:()=>ca},newPSD:cs,usePSD:cm,scheduler:{get:()=>lR,set:e=>{lR=e}},rejectionMapper:{get:()=>lU,set:e=>{lU=e}},follow:(e,t)=>new lZ((n,r)=>cs((t,n)=>{var r=lH;r.unhandleds=[],r.onunhandled=n,r.finalize=lw(function(){var e;e=()=>{0===this.unhandleds.length?t():n(this.unhandleds[0])},lJ.push(function t(){e(),lJ.splice(lJ.indexOf(t),1)}),++lY,lR(()=>{0==--lY&&l7()},[])},r.finalize),e()},t,n,r))}),lB&&(lB.allSettled&&sG(lZ,"allSettled",function(){let e=lr.apply(null,arguments).map(cp);return new lZ(t=>{0===e.length&&t([]);let n=e.length,r=Array(n);e.forEach((e,o)=>lZ.resolve(e).then(e=>r[o]={status:"fulfilled",value:e},e=>r[o]={status:"rejected",reason:e}).then(()=>--n||t(r)))})}),lB.any&&"u">typeof AggregateError&&sG(lZ,"any",function(){let e=lr.apply(null,arguments).map(cp);return new lZ((t,n)=>{0===e.length&&n(AggregateError([]));let r=e.length,o=Array(r);e.forEach((e,a)=>lZ.resolve(e).then(e=>t(e),e=>{o[a]=e,--r||n(AggregateError(o))}))})}));let ct={awaits:0,echoes:0,id:0};var cn=0,cr=[],co=0,ca=0,ci=0;function cs(e,t,n,r){var o=lH,a=Object.create(o);a.parent=o,a.ref=0,a.global=!1,a.id=++ci;var i=lq.env;a.env=lI?{Promise:lZ,PromiseProp:{value:lZ,configurable:!0,writable:!0},all:lZ.all,race:lZ.race,allSettled:lZ.allSettled,any:lZ.any,resolve:lZ.resolve,reject:lZ.reject,nthen:cy(i.nthen,a),gthen:cy(i.gthen,a)}:{},t&&sN(a,t),++o.ref,a.finalize=function(){--this.parent.ref||this.parent.finalize()};var s=cm(a,e,n,r);return 0===a.ref&&a.finalize(),s}function cl(){return ct.id||(ct.id=++cn),++ct.awaits,ct.echoes+=100,ct.id}function cc(){return!!ct.awaits&&(0==--ct.awaits&&(ct.id=0),ct.echoes=100*ct.awaits,!0)}function cp(e){return ct.echoes&&e&&e.constructor===lB?(cl(),e.then(e=>(cc(),e),e=>(cc(),cv(e)))):e}function cu(e){++ca,ct.echoes&&0!=--ct.echoes||(ct.echoes=ct.id=0),cr.push(lH),cf(e,!0)}function cd(){var e=cr[cr.length-1];cr.pop(),cf(e,!1)}function cf(e,t){var n,r=lH;if((t?!ct.echoes||co++&&e===lH:!co||--co&&e===lH)||(n=t?cu.bind(null,e):cd,lT.call(lz,n)),e!==lH&&(lH=e,r===lq&&(lq.env=ch()),lI)){var o=lq.env.Promise,a=e.env;lO.then=a.nthen,o.prototype.then=a.gthen,(r.global||e.global)&&(Object.defineProperty(sT,"Promise",a.PromiseProp),o.all=a.all,o.race=a.race,o.resolve=a.resolve,o.reject=a.reject,a.allSettled&&(o.allSettled=a.allSettled),a.any&&(o.any=a.any))}}function ch(){var e=sT.Promise;return lI?{Promise:e,PromiseProp:Object.getOwnPropertyDescriptor(sT,"Promise"),all:e.all,race:e.race,allSettled:e.allSettled,any:e.any,resolve:e.resolve,reject:e.reject,nthen:lO.then,gthen:e.prototype.then}:{}}function cm(e,t,n,r,o){var a=lH;try{return cf(e,!0),t(n,r,o)}finally{cf(a,!1)}}function c_(e,t,n,r){return"function"!=typeof e?e:function(){var o,a=lH;n&&cl(),cf(t,!0);try{return e.apply(this,arguments)}finally{cf(a,!1),r&&(o=cc,lT.call(lz,o))}}}function cy(e,t){return function(n,r){return e.call(this,c_(n,t),c_(r,t))}}-1===(""+lT).indexOf("[native code]")&&(cl=cc=lA);let cg="unhandledrejection";function cb(e,t){var n;try{n=t.onuncatched(e)}catch(e){}if(!1!==n)try{var r,o={promise:t,reason:e};if(sT.document&&document.createEvent?((r=document.createEvent("Event")).initEvent(cg,!0,!0),sN(r,o)):sT.CustomEvent&&sN(r=new CustomEvent(cg,{detail:o}),o),r&&sT.dispatchEvent&&(dispatchEvent(r),!sT.PromiseRejectionEvent&&sT.onunhandledrejection))try{sT.onunhandledrejection(r)}catch(e){}la&&r&&!r.defaultPrevented&&console.warn(`Unhandled rejection: ${e.stack||e}`)}catch(e){}}var cv=lZ.reject;let cA="3.2.7",c$=String.fromCharCode(65535),ck=-1/0,cw="Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.",cx="String expected.",cC=[],cE="u">typeof navigator&&/(MSIE|Trident|Edge)/.test(navigator.userAgent),cS=e=>!/(dexie\.js|dexie\.min\.js)/.test(e),cD="__dbnames",cM="readonly",cz="readwrite";function cO(e,t){return e?t?function(){return e.apply(this,arguments)&&t.apply(this,arguments)}:e:t}let cP={type:3,lower:-1/0,lowerOpen:!1,upper:[[]],upperOpen:!1};function cT(e){return"string"!=typeof e||/\./.test(e)?e=>e:t=>(void 0===t[e]&&e in t&&delete(t=s8(t))[e],t)}class cB{_trans(e,t,n){let r=this._tx||lH.trans,o=this.name;function a(e,n,r){if(!r.schema[o])throw new lg.NotFound("Table "+o+" not part of transaction");return t(r.idbtrans,r)}let i=l6();try{return r&&r.db===this.db?r===lH.trans?r._promise(e,a,n):cs(()=>r._promise(e,a,n),{trans:r,transless:lH.transless||lH}):function e(t,n,r,o){if(t.idbdb&&(t._state.openComplete||lH.letThrough||t._vip)){var a=t._createTransaction(n,r,t._dbSchema);try{a.create(),t._state.PR1398_maxLoop=3}catch(a){return a.name===ly.InvalidState&&t.isOpen()&&--t._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),t._close(),t.open().then(()=>e(t,n,r,o))):cv(a)}return a._promise(n,(e,t)=>cs(()=>(lH.trans=a,o(e,t,a)))).then(e=>a._completion.then(()=>e))}if(t._state.openComplete)return cv(new lg.DatabaseClosed(t._state.dbOpenError));if(!t._state.isBeingOpened){if(!t._options.autoOpen)return cv(new lg.DatabaseClosed);t.open().catch(lA)}return t._state.dbReadyPromise.then(()=>e(t,n,r,o))}(this.db,e,[this.name],a)}finally{i&&l8()}}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(sI(e))return new this.db.WhereClause(this,`[${e.join("+")}]`);let t=sB(e);if(1===t.length)return this.where(t[0]).equals(e[t[0]]);let n=this.schema.indexes.concat(this.schema.primKey).filter(e=>{if(e.compound&&t.every(t=>e.keyPath.indexOf(t)>=0)){for(let n=0;n<t.length;++n)if(-1===t.indexOf(e.keyPath[n]))return!1;return!0}return!1}).sort((e,t)=>e.keyPath.length-t.keyPath.length)[0];if(n&&this.db._maxKey!==c$){let r=n.keyPath.slice(0,t.length);return this.where(r).equals(r.map(t=>e[t]))}!n&&la&&console.warn(`The query ${JSON.stringify(e)} on ${this.name} would benefit of a compound index [${t.join("+")}]`);let{idxByName:r}=this.schema,o=this.db._deps.indexedDB;function a(e,t){try{return 0===o.cmp(e,t)}catch(e){return!1}}let[i,s]=t.reduce(([t,n],o)=>{let i=r[o],s=e[o];return[t||i,t||!i?cO(n,i&&i.multi?e=>{let t=sQ(e,o);return sI(t)&&t.some(e=>a(s,e))}:e=>a(s,sQ(e,o))):n]},[null,null]);return i?this.where(i.name).equals(e[i.keyPath]).filter(s):n?this.filter(s):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,sI(e)?`[${e.join("+")}]`:e))}reverse(){return this.toCollection().reverse()}mapToClass(e){this.schema.mappedClass=e;let t=t=>{if(!t)return t;let n=Object.create(e.prototype);for(var r in t)if(sF(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){sN(this,e)})}add(e,t){let{auto:n,keyPath:r}=this.schema.primKey,o=e;return r&&n&&(o=cT(r)(e)),this._trans("readwrite",e=>this.core.mutate({trans:e,type:"add",keys:null!=t?[t]:null,values:[o]})).then(e=>e.numFailures?lZ.reject(e.failures[0]):e.lastResult).then(t=>{if(r)try{s0(e,r,t)}catch(e){}return t})}update(e,t){if("object"!=typeof e||sI(e))return this.where(":id").equals(e).modify(t);{let n=sQ(e,this.schema.primKey.keyPath);if(void 0===n)return cv(new lg.InvalidArgument("Given object does not contain its primary key"));try{"function"!=typeof t?sB(t).forEach(n=>{s0(e,n,t[n])}):t(e,{value:e,primKey:n})}catch(e){}return this.where(":id").equals(n).modify(t)}}put(e,t){let{auto:n,keyPath:r}=this.schema.primKey,o=e;return r&&n&&(o=cT(r)(e)),this._trans("readwrite",e=>this.core.mutate({trans:e,type:"put",values:[o],keys:null!=t?[t]:null})).then(e=>e.numFailures?lZ.reject(e.failures[0]):e.lastResult).then(t=>{if(r)try{s0(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?lZ.reject(e.failures[0]):void 0)}clear(){return this._trans("readwrite",e=>this.core.mutate({trans:e,type:"deleteRange",range:cP})).then(e=>e.numFailures?lZ.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){let r=Array.isArray(t)?t:void 0,o=(n=n||(r?void 0:t))?n.allKeys:void 0;return this._trans("readwrite",t=>{let{auto:n,keyPath:a}=this.schema.primKey;if(a&&r)throw new lg.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(r&&r.length!==e.length)throw new lg.InvalidArgument("Arguments objects and keys must have the same length");let i=e.length,s=a&&n?e.map(cT(a)):e;return this.core.mutate({trans:t,type:"add",keys:r,values:s,wantResults:o}).then(({numFailures:e,results:t,lastResult:n,failures:r})=>{if(0===e)return o?t:n;throw new l_(`${this.name}.bulkAdd(): ${e} of ${i} operations failed`,r)})})}bulkPut(e,t,n){let r=Array.isArray(t)?t:void 0,o=(n=n||(r?void 0:t))?n.allKeys:void 0;return this._trans("readwrite",t=>{let{auto:n,keyPath:a}=this.schema.primKey;if(a&&r)throw new lg.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(r&&r.length!==e.length)throw new lg.InvalidArgument("Arguments objects and keys must have the same length");let i=e.length,s=a&&n?e.map(cT(a)):e;return this.core.mutate({trans:t,type:"put",keys:r,values:s,wantResults:o}).then(({numFailures:e,results:t,lastResult:n,failures:r})=>{if(0===e)return o?t:n;throw new l_(`${this.name}.bulkPut(): ${e} of ${i} operations failed`,r)})})}bulkDelete(e){let 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 l_(`${this.name}.bulkDelete(): ${e} of ${t} operations failed`,r)})}}function cI(e){var t={},n=function(n,r){if(r){for(var o=arguments.length,a=Array(o-1);--o;)a[o-1]=arguments[o];return t[n].subscribe.apply(null,a),e}if("string"==typeof n)return t[n]};n.addEventType=a;for(var r=1,o=arguments.length;r<o;++r)a(arguments[r]);return n;function a(e,r,o){if("object"!=typeof e){r||(r=lS),o||(o=lA);var i={subscribers:[],fire:o,subscribe:function(e){-1===i.subscribers.indexOf(e)&&(i.subscribers.push(e),i.fire=r(i.fire,e))},unsubscribe:function(e){i.subscribers=i.subscribers.filter(function(t){return t!==e}),i.fire=i.subscribers.reduce(r,o)}};return t[e]=n[e]=i,i}sB(e).forEach(function(t){var n=e[t];if(sI(n))a(t,e[t][0],e[t][1]);else{if("asap"!==n)throw new lg.InvalidArgument("Invalid event config");var r=a(t,l$,function(){for(var e=arguments.length,t=Array(e);e--;)t[e]=arguments[e];r.subscribers.forEach(function(e){sZ(function(){e.apply(null,t)})})})}})}}function cN(e,t){return sV(t).from({prototype:e}),t}function cj(e,t){return!(e.filter||e.algorithm||e.or)&&(t?e.justLimit:!e.replayFilter)}function cR(e,t){e.filter=cO(e.filter,t)}function cF(e,t,n){var r=e.replayFilter;e.replayFilter=r?()=>cO(r(),t()):t,e.justLimit=n&&!r}function cL(e,t){if(e.isPrimKey)return t.primaryKey;let n=t.getIndexByKeyPath(e.index);if(!n)throw new lg.Schema("KeyPath "+e.index+" on object store "+t.name+" is not indexed");return n}function cW(e,t,n){let r=cL(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 cG(e,t,n,r){let o=e.replayFilter?cO(e.filter,e.replayFilter()):e.filter;if(e.or){let a={},i=(e,n,r)=>{if(!o||o(n,r,e=>n.stop(e),e=>n.fail(e))){var i=n.primaryKey,s=""+i;"[object ArrayBuffer]"===s&&(s=""+new Uint8Array(i)),sF(a,s)||(a[s]=!0,t(e,n,r))}};return Promise.all([e.or._iterate(i,n),cV(cW(e,r,n),e.algorithm,i,!e.keysOnly&&e.valueMapper)])}return cV(cW(e,r,n),cO(e.algorithm,o),t,!e.keysOnly&&e.valueMapper)}function cV(e,t,n,r){var o=ce(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=lA},t=>{e.fail(t),n=lA})||o(e.value,e,e=>n=e),n()})})}function cU(e,t){try{let n=cq(e),r=cq(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){let 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}(cH(e),cH(t));case"Array":return function(e,t){let n=e.length,r=t.length,o=n<r?n:r;for(let n=0;n<o;++n){let r=cU(e[n],t[n]);if(0!==r)return r}return n===r?0:n<r?-1:1}(e,t)}}catch(e){}return NaN}function cq(e){let t=typeof e;if("object"!==t)return t;if(ArrayBuffer.isView(e))return"binary";let n=s9(e);return"ArrayBuffer"===n?"binary":n}function cH(e){return e instanceof Uint8Array?e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e)}class cK{_read(e,t){var n=this._ctx;return n.error?n.table._trans(null,cv.bind(null,n.error)):n.table._trans("readonly",e).then(t)}_write(e){var t=this._ctx;return t.error?t.table._trans(null,cv.bind(null,t.error)):t.table._trans("readwrite",e,"locked")}_addAlgorithm(e){var t=this._ctx;t.algorithm=cO(t.algorithm,e)}_iterate(e,t){return cG(this._ctx,e,t,this._ctx.table.core)}clone(e){var t=Object.create(this.constructor.prototype),n=Object.create(this._ctx);return e&&sN(n,e),t._ctx=n,t}raw(){return this._ctx.valueMapper=null,this}each(e){var t=this._ctx;return this._read(n=>cG(t,e,n,t.table.core))}count(e){return this._read(e=>{let t=this._ctx,n=t.table.core;if(cj(t,!0))return n.count({trans:e,query:{index:cL(t,n.schema),range:t.range}}).then(e=>Math.min(e,t.limit));var r=0;return cG(t,()=>(++r,!1),e,n).then(()=>r)}).then(e)}sortBy(e,t){let n=e.split(".").reverse(),r=n[0],o=n.length-1;function a(e,t){return t?a(e[n[t]],t-1):e[r]}var i="next"===this._ctx.dir?1:-1;function s(e,t){var n=a(e,o),r=a(t,o);return n<r?-i:n>r?i:0}return this.toArray(function(e){return e.sort(s)}).then(t)}toArray(e){return this._read(e=>{var t=this._ctx;if("next"===t.dir&&cj(t,!0)&&t.limit>0){let{valueMapper:n}=t,r=cL(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)}{let n=[];return cG(t,e=>n.push(e),e,t.table.core).then(()=>n)}},e)}offset(e){var t=this._ctx;return e<=0||(t.offset+=e,cj(t)?cF(t,()=>{var t=e;return(e,n)=>0===t||(1===t?--t:n(()=>{e.advance(t),t=0}),!1)}):cF(t,()=>{var t=e;return()=>--t<0})),this}limit(e){return this._ctx.limit=Math.min(this._ctx.limit,e),cF(this._ctx,()=>{var t=e;return function(e,n,r){return--t<=0&&n(r),t>=0}},!0),this}until(e,t){return cR(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;return cR(this._ctx,function(t){return e(t.value)}),(t=this._ctx).isMatch=cO(t.isMatch,e),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&&cj(t,!0)&&t.limit>0)return this._read(e=>{var n=cL(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 cR(this._ctx,function(e){var t=e.primaryKey.toString(),r=sF(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=sB(e),a=o.length;r=function(t){for(var n=!1,r=0;r<a;++r){var i=o[r],s=e[i];sQ(t,i)!==s&&(s0(t,i,s),n=!0)}return n}}let i=t.table.core,{outbound:s,extractKey:l}=i.schema.primaryKey,c=this.db._options.modifyChunkSize||200,p=[],u=0,d=[],f=(e,t)=>{let{failures:n,numFailures:r}=t;for(let t of(u+=e-r,sB(n)))p.push(n[t])};return this.clone().primaryKeys().then(o=>{let a=p=>{let u=Math.min(c,o.length-p);return i.getMany({trans:n,keys:o.slice(p,p+u),cache:"immutable"}).then(d=>{let h=[],m=[],y=s?[]:null,g=[];for(let e=0;e<u;++e){let t=d[e],n={value:s8(t),primKey:o[p+e]};!1!==r.call(n,n.value,n)&&(null==n.value?g.push(o[p+e]):s||0===cU(l(t),l(n.value))?(m.push(n.value),s&&y.push(o[p+e])):(g.push(o[p+e]),h.push(n.value)))}let b=cj(t)&&t.limit===1/0&&("function"!=typeof e||e===cY)&&{index:t.index,range:t.range};return Promise.resolve(h.length>0&&i.mutate({trans:n,type:"add",values:h}).then(e=>{for(let t in e.failures)g.splice(parseInt(t),1);f(h.length,e)})).then(()=>(m.length>0||b&&"object"==typeof e)&&i.mutate({trans:n,type:"put",keys:y,values:m,criteria:b,changeSpec:"function"!=typeof e&&e}).then(e=>f(m.length,e))).then(()=>(g.length>0||b&&e===cY)&&i.mutate({trans:n,type:"delete",keys:g,criteria:b}).then(e=>f(g.length,e))).then(()=>o.length>p+u&&a(p+c))})};return a(0).then(()=>{if(p.length>0)throw new lm("Error modifying one or more objects",p,u,d);return o.length})})})}delete(){var e=this._ctx,t=e.range;return cj(e)&&(e.isPrimKey&&!cE||3===t.type)?this._write(n=>{let{primaryKey:r}=e.table.core.schema;return e.table.core.count({trans:n,query:{index:r,range:t}}).then(r=>e.table.core.mutate({trans:n,type:"deleteRange",range:t}).then(({failures:e,lastResult:t,results:n,numFailures:o})=>{if(o)throw new lm("Could not delete some values",Object.keys(e).map(t=>e[t]),r-o);return r-o}))}):this.modify(cY)}}let cY=(e,t)=>t.value=null;function cJ(e,t){return e<t?-1:+(e!==t)}function cZ(e,t){return e>t?-1:+(e!==t)}function cX(e,t,n){var r=e instanceof c3?new e.Collection(e):e;return r._ctx.error=n?new n(t):TypeError(t),r}function cQ(e){return new e.Collection(e,()=>c2("")).limit(0)}function c0(e,t,n,r){var o,a,i,s,l,c,p,u=n.length;if(!n.every(e=>"string"==typeof e))return cX(e,cx);function d(e){o="next"===e?e=>e.toUpperCase():e=>e.toLowerCase(),a="next"===e?e=>e.toLowerCase():e=>e.toUpperCase(),i="next"===e?cJ:cZ;var t=n.map(function(e){return{lower:a(e),upper:o(e)}}).sort(function(e,t){return i(e.lower,t.lower)});s=t.map(function(e){return e.upper}),l=t.map(function(e){return e.lower}),c=e,p="next"===e?"":r}d("next");var f=new e.Collection(e,()=>c1(s[0],l[u-1]+r));f._ondirectionchange=function(e){d(e)};var h=0;return f._addAlgorithm(function(e,n,r){var o=e.key;if("string"!=typeof o)return!1;var d=a(o);if(t(d,l,h))return!0;for(var f=null,m=h;m<u;++m){var y=function(e,t,n,r,o,a){for(var i=Math.min(e.length,r.length),s=-1,l=0;l<i;++l){var c=t[l];if(c!==r[l])return 0>o(e[l],n[l])?e.substr(0,l)+n[l]+n.substr(l+1):0>o(e[l],r[l])?e.substr(0,l)+r[l]+n.substr(l+1):s>=0?e.substr(0,s)+t[s]+n.substr(s+1):null;0>o(e[l],c)&&(s=l)}return i<r.length&&"next"===a?e+n.substr(e.length):i<e.length&&"prev"===a?e.substr(0,n.length):s<0?null:e.substr(0,s)+r[s]+n.substr(s+1)}(o,d,s[m],l[m],i,c);null===y&&null===f?h=m+1:(null===f||i(f,y)>0)&&(f=y)}return n(null!==f?function(){e.continue(f+p)}:r),!1}),f}function c1(e,t,n,r){return{type:2,lower:e,upper:t,lowerOpen:n,upperOpen:r}}function c2(e){return{type:1,lower:e,upper:e}}class c3{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)?cQ(this):new this.Collection(this,()=>c1(e,t,!n,!r))}catch(e){return cX(this,cw)}}equals(e){return null==e?cX(this,cw):new this.Collection(this,()=>c2(e))}above(e){return null==e?cX(this,cw):new this.Collection(this,()=>c1(e,void 0,!0))}aboveOrEqual(e){return null==e?cX(this,cw):new this.Collection(this,()=>c1(e,void 0,!1))}below(e){return null==e?cX(this,cw):new this.Collection(this,()=>c1(void 0,e,!1,!0))}belowOrEqual(e){return null==e?cX(this,cw):new this.Collection(this,()=>c1(void 0,e))}startsWith(e){return"string"!=typeof e?cX(this,cx):this.between(e,e+c$,!0,!0)}startsWithIgnoreCase(e){return""===e?this.startsWith(e):c0(this,(e,t)=>0===e.indexOf(t[0]),[e],c$)}equalsIgnoreCase(e){return c0(this,(e,t)=>e===t[0],[e],"")}anyOfIgnoreCase(){var e=lr.apply(ln,arguments);return 0===e.length?cQ(this):c0(this,(e,t)=>-1!==t.indexOf(e),e,"")}startsWithAnyOfIgnoreCase(){var e=lr.apply(ln,arguments);return 0===e.length?cQ(this):c0(this,(e,t)=>t.some(t=>0===e.indexOf(t)),e,c$)}anyOf(){let e=lr.apply(ln,arguments),t=this._cmp;try{e.sort(t)}catch(e){return cX(this,cw)}if(0===e.length)return cQ(this);let n=new this.Collection(this,()=>c1(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,a)=>{let i=n.key;for(;t(i,e[r])>0;)if(++r===e.length)return o(a),!1;return 0===t(i,e[r])||(o(()=>{n.continue(e[r])}),!1)}),n}notEqual(e){return this.inAnyRange([[ck,e],[e,this.db._maxKey]],{includeLowers:!1,includeUppers:!1})}noneOf(){let e=lr.apply(ln,arguments);if(0===e.length)return new this.Collection(this);try{e.sort(this._ascending)}catch(e){return cX(this,cw)}let t=e.reduce((e,t)=>e?e.concat([[e[e.length-1][1],t]]):[[ck,t]],null);return t.push([e[e.length-1],this.db._maxKey]),this.inAnyRange(t,{includeLowers:!1,includeUppers:!1})}inAnyRange(e,t){let n=this._cmp,r=this._ascending,o=this._descending,a=this._min,i=this._max;if(0===e.length)return cQ(this);if(!e.every(e=>void 0!==e[0]&&void 0!==e[1]&&0>=r(e[0],e[1])))return cX(this,"First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower",lg.InvalidArgument);let s=!t||!1!==t.includeLowers,l=t&&!0===t.includeUppers,c,p=r;function u(e,t){return p(e[0],t[0])}try{(c=e.reduce(function(e,t){let r=0,o=e.length;for(;r<o;++r){let o=e[r];if(0>n(t[0],o[1])&&n(t[1],o[0])>0){o[0]=a(o[0],t[0]),o[1]=i(o[1],t[1]);break}}return r===o&&e.push(t),e},[])).sort(u)}catch(e){return cX(this,cw)}let d=0,f=l?e=>r(e,c[d][1])>0:e=>r(e,c[d][1])>=0,h=s?e=>o(e,c[d][0])>0:e=>o(e,c[d][0])>=0,m=f,y=new this.Collection(this,()=>c1(c[0][0],c[c.length-1][1],!s,!l));return y._ondirectionchange=e=>{"next"===e?(m=f,p=r):(m=h,p=o),c.sort(u)},y._addAlgorithm((e,t,n)=>{for(var o=e.key;m(o);)if(++d===c.length)return t(n),!1;return!!(!f(o)&&!h(o))||(0===this._cmp(o,c[d][1])||0===this._cmp(o,c[d][0])||t(()=>{p===r?e.continue(c[d][0]):e.continue(c[d][1])}),!1)}),y}startsWithAnyOf(){let e=lr.apply(ln,arguments);return e.every(e=>"string"==typeof e)?0===e.length?cQ(this):this.inAnyRange(e.map(e=>[e,e+c$])):cX(this,"startsWithAnyOf() only works with strings")}}function c5(e){return ce(function(t){return c4(t),e(t.target.error),!1})}function c4(e){e.stopPropagation&&e.stopPropagation(),e.preventDefault&&e.preventDefault()}let c6="storagemutated",c8="x-storagemutated-1",c7=cI(null,c6);class c9{_lock(){return sJ(!lH.global),++this._reculock,1!==this._reculock||lH.global||(lH.lockOwnerFor=this),this}_unlock(){if(sJ(!lH.global),0==--this._reculock)for(lH.global||(lH.lockOwnerFor=null);this._blockedFuncs.length>0&&!this._locked();){var e=this._blockedFuncs.shift();try{cm(e[1],e[0])}catch(e){}}return this}_locked(){return this._reculock&&lH.lockOwnerFor!==this}create(e){if(!this.mode)return this;let t=this.db.idbdb,n=this.db._state.dbOpenError;if(sJ(!this.idbtrans),!e&&!t)switch(n&&n.name){case"DatabaseClosedError":throw new lg.DatabaseClosed(n);case"MissingAPIError":throw new lg.MissingAPI(n.message,n);default:throw new lg.OpenFailed(n)}if(!this.active)throw new lg.TransactionInactive;return sJ(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=ce(t=>{c4(t),this._reject(e.error)}),e.onabort=ce(t=>{c4(t),this.active&&this._reject(new lg.Abort(e.error)),this.active=!1,this.on("abort").fire(t)}),e.oncomplete=ce(()=>{this.active=!1,this._resolve(),"mutatedParts"in e&&c7.storagemutated.fire(e.mutatedParts)}),this}_promise(e,t,n){if("readwrite"===e&&"readwrite"!==this.mode)return cv(new lg.ReadOnly("Transaction is readonly"));if(!this.active)return cv(new lg.TransactionInactive);if(this._locked())return new lZ((r,o)=>{this._blockedFuncs.push([()=>{this._promise(e,t,n).then(r,o)},lH])});if(n)return cs(()=>{var e=new lZ((e,n)=>{this._lock();let r=t(e,n,this);r&&r.then&&r.then(e,n)});return e.finally(()=>this._unlock()),e._lib=!0,e});var r=new lZ((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();let n=lZ.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 lZ((e,r)=>{n.then(n=>t._waitingQueue.push(ce(e.bind(null,n))),e=>t._waitingQueue.push(ce(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 lg.Abort))}table(e){let t=this._memoizedTables||(this._memoizedTables={});if(sF(t,e))return t[e];let n=this.schema[e];if(!n)throw new lg.NotFound("Table "+e+" not part of transaction");let r=new this.db.Table(e,n,this);return r.core=this.db.core.table(e),t[e]=r,r}}function pe(e,t,n,r,o,a,i){return{name:e,keyPath:t,unique:n,multi:r,auto:o,compound:a,src:(n&&!i?"&":"")+(r?"*":"")+(o?"++":"")+pt(t)}}function pt(e){return"string"==typeof e?e:e?"["+[].join.call(e,"+")+"]":""}function pn(e,t,n){return{name:e,primKey:t,indexes:n,mappedClass:null,idxByName:sX(n,e=>[e.name,e])}}let pr=e=>{try{return e.only([[]]),pr=()=>[[]],[[]]}catch(e){return pr=()=>c$,c$}};function po(e){return null==e?()=>{}:"string"==typeof e?1===e.split(".").length?t=>t[e]:t=>sQ(t,e):t=>sQ(t,e)}function pa(e){return[].slice.call(e)}let pi=0;function ps(e){return null==e?":id":"string"==typeof e?e:`[${e.join("+")}]`}function pl({_novip:e},t){let n=t.db,r=function(e,t,{IDBKeyRange:n,indexedDB:r},o){var a;return{dbcore:(a=function(e,t,n){let r;function o(e){if(3===e.type)return null;if(4===e.type)throw Error("Cannot convert never type to IDBKeyRange");let{lower:n,upper:r,lowerOpen:o,upperOpen:a}=e;return void 0===n?void 0===r?null:t.upperBound(r,!!a):void 0===r?t.lowerBound(n,!!o):t.bound(n,r,!!o,!!a)}let{schema:a,hasGetAll:i}=(r=pa(e.objectStoreNames),{schema:{name:e.name,tables:r.map(e=>n.objectStore(e)).map(e=>{let{keyPath:t,autoIncrement:n}=e,r=sI(t),o=null==t,a={},i={name:e.name,primaryKey:{name:null,isPrimaryKey:!0,outbound:o,compound:r,keyPath:t,autoIncrement:n,unique:!0,extractKey:po(t)},indexes:pa(e.indexNames).map(t=>e.index(t)).map(e=>{let{name:t,unique:n,multiEntry:r,keyPath:o}=e,i={name:t,compound:sI(o),keyPath:o,unique:n,multiEntry:r,extractKey:po(o)};return a[ps(o)]=i,i}),getIndexByKeyPath:e=>a[ps(e)]};return a[":id"]=i.primaryKey,null!=t&&(a[ps(t)]=i.primaryKey),i})},hasGetAll:r.length>0&&"getAll"in n.objectStore(r[0])&&!("u">typeof navigator&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604)}),s=a.tables.map(e=>{let t;return{name:t=e.name,schema:e,mutate:function({trans:e,type:n,keys:r,values:a,range:i}){return new Promise((s,l)=>{let c;s=ce(s);let p=e.objectStore(t),u=null==p.keyPath,d="put"===n||"add"===n;if(!d&&"delete"!==n&&"deleteRange"!==n)throw Error("Invalid operation type: "+n);let{length:f}=r||a||{length:1};if(r&&a&&r.length!==a.length)throw Error("Given keys array must have same length as given values array.");if(0===f)return s({numFailures:0,failures:{},results:[],lastResult:void 0});let h=[],m=[],y=0,g=e=>{++y,c4(e)};if("deleteRange"===n){if(4===i.type)return s({numFailures:y,failures:m,results:[],lastResult:void 0});3===i.type?h.push(c=p.clear()):h.push(c=p.delete(o(i)))}else{let[e,t]=d?u?[a,r]:[a,null]:[r,null];if(d)for(let r=0;r<f;++r)h.push(c=t&&void 0!==t[r]?p[n](e[r],t[r]):p[n](e[r])),c.onerror=g;else for(let t=0;t<f;++t)h.push(c=p[n](e[t])),c.onerror=g}let b=e=>{let t=e.target.result;h.forEach((e,t)=>null!=e.error&&(m[t]=e.error)),s({numFailures:y,failures:m,results:"delete"===n?r:h.map(e=>e.result),lastResult:t})};c.onerror=e=>{g(e),b(e)},c.onsuccess=b})},getMany:({trans:e,keys:n})=>new Promise((r,o)=>{r=ce(r);let a=e.objectStore(t),i=n.length,s=Array(i),l,c=0,p=0,u=e=>{let t=e.target;s[t._pos]=t.result,++p===c&&r(s)},d=c5(o);for(let e=0;e<i;++e)null!=n[e]&&((l=a.get(n[e]))._pos=e,l.onsuccess=u,l.onerror=d,++c);0===c&&r(s)}),get:({trans:e,key:n})=>new Promise((r,o)=>{r=ce(r);let a=e.objectStore(t).get(n);a.onsuccess=e=>r(e.target.result),a.onerror=c5(o)}),query:e=>new Promise((n,r)=>{n=ce(n);let{trans:a,values:s,limit:l,query:c}=e,p=l===1/0?void 0:l,{index:u,range:d}=c,f=a.objectStore(t),h=u.isPrimaryKey?f:f.index(u.name),m=o(d);if(0===l)return n({result:[]});if(i){let e=s?h.getAll(m,p):h.getAllKeys(m,p);e.onsuccess=e=>n({result:e.target.result}),e.onerror=c5(r)}else{let e=0,t=!s&&"openKeyCursor"in h?h.openKeyCursor(m):h.openCursor(m),o=[];t.onsuccess=r=>{let a=t.result;return a?(o.push(s?a.value:a.primaryKey),++e===l?n({result:o}):void a.continue()):n({result:o})},t.onerror=c5(r)}}),openCursor:function({trans:e,values:n,query:r,reverse:a,unique:i}){return new Promise((s,l)=>{s=ce(s);let{index:c,range:p}=r,u=e.objectStore(t),d=c.isPrimaryKey?u:u.index(c.name),f=a?i?"prevunique":"prev":i?"nextunique":"next",h=!n&&"openKeyCursor"in d?d.openKeyCursor(o(p),f):d.openCursor(o(p),f);h.onerror=c5(l),h.onsuccess=ce(t=>{let n=h.result;if(!n)return void s(null);n.___id=++pi,n.done=!1;let r=n.continue.bind(n),o=n.continuePrimaryKey;o&&(o=o.bind(n));let a=n.advance.bind(n),i=()=>{throw Error("Cursor not stopped")};n.trans=e,n.stop=n.continue=n.continuePrimaryKey=n.advance=()=>{throw Error("Cursor not started")},n.fail=ce(l),n.next=function(){let e=1;return this.start(()=>e--?this.continue():this.stop()).then(()=>this)},n.start=e=>{let t=new Promise((e,t)=>{e=ce(e),h.onerror=c5(t),n.fail=t,n.stop=t=>{n.stop=n.continue=n.continuePrimaryKey=n.advance=i,e(t)}}),s=()=>{if(h.result)try{e()}catch(e){n.fail(e)}else n.done=!0,n.start=()=>{throw Error("Cursor behind last entry")},n.stop()};return h.onsuccess=ce(e=>{h.onsuccess=s,s()}),n.continue=r,n.continuePrimaryKey=o,n.advance=a,s(),t},s(n)},l)})},count({query:e,trans:n}){let{index:r,range:a}=e;return new Promise((e,i)=>{let s=n.objectStore(t),l=r.isPrimaryKey?s:s.index(r.name),c=o(a),p=c?l.count(c):l.count();p.onsuccess=ce(t=>e(t.target.result)),p.onerror=c5(i)})}}}),l={};return s.forEach(e=>l[e.name]=e),{stack:"dbcore",transaction:e.transaction.bind(e),table(e){if(!l[e])throw Error(`Table '${e}' not found`);return l[e]},MIN_KEY:-1/0,MAX_KEY:pr(t),schema:a}}(t,n,o),e.dbcore.reduce((e,{create:t})=>({...e,...t(e)}),a))}}(e._middlewares,n,e._deps,t);e.core=r.dbcore,e.tables.forEach(t=>{let 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 pc({_novip:e},t,n,r){n.forEach(n=>{let o=r[n];t.forEach(t=>{let r=sq(t,n);(!r||"value"in r&&void 0===r.value)&&(t===e.Transaction.prototype||t instanceof e.Transaction?sG(t,n,{get(){return this.table(n)},set(e){sW(this,n,{value:e,writable:!0,configurable:!0,enumerable:!0})}}):t[n]=new e.Table(n,o))})})}function pp({_novip:e},t){t.forEach(t=>{for(let n in t)t[n]instanceof e.Table&&delete t[n]})}function pu(e,t){return e._cfg.version-t._cfg.version}function pd(e,t){let n,r={del:[],add:[],change:[]};for(n in e)t[n]||r.del.push(n);for(n in t){let o=e[n],a=t[n];if(o){let e={name:n,def:a,recreate:!1,del:[],add:[],change:[]};if(""+(o.primKey.keyPath||"")==""+(a.primKey.keyPath||"")&&(o.primKey.auto===a.primKey.auto||cE)){let t,n=o.idxByName,i=a.idxByName;for(t in n)i[t]||e.del.push(t);for(t in i){let r=n[t],o=i[t];r?r.src!==o.src&&e.change.push(o):e.add.push(o)}(e.del.length>0||e.add.length>0||e.change.length>0)&&r.change.push(e)}else e.recreate=!0,r.change.push(e)}else r.add.push([n,a])}return r}function pf(e,t,n,r){let o=e.db.createObjectStore(t,n.keyPath?{keyPath:n.keyPath,autoIncrement:n.auto}:{autoIncrement:n.auto});return r.forEach(e=>ph(o,e)),o}function ph(e,t){e.createIndex(t.name,t.keyPath,{unique:t.unique,multiEntry:t.multi})}function pm(e,t,n){let r={};return sK(t.objectStoreNames,0).forEach(e=>{let t=n.objectStore(e),o=t.keyPath,a=pe(pt(o),o||"",!1,!1,!!t.autoIncrement,o&&"string"!=typeof o,!0),i=[];for(let e=0;e<t.indexNames.length;++e){let n=t.index(t.indexNames[e]);o=n.keyPath;var s=pe(n.name,o,!!n.unique,!!n.multiEntry,!1,o&&"string"!=typeof o,!1);i.push(s)}r[e]=pn(e,a,i)}),r}function p_({_novip:e},t,n){let r=n.db.objectStoreNames;for(let o=0;o<r.length;++o){let a=r[o],i=n.objectStore(a);e._hasGetAll="getAll"in i;for(let e=0;e<i.indexNames.length;++e){let n=i.indexNames[e],r=i.index(n).keyPath,o="string"==typeof r?r:"["+sK(r).join("+")+"]";if(t[a]){let e=t[a].idxByName[o];e&&(e.name=n,delete t[a].idxByName[o],t[a].idxByName[n]=e)}}}"u">typeof navigator&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&sT.WorkerGlobalScope&&sT instanceof sT.WorkerGlobalScope&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604&&(e._hasGetAll=!1)}class py{_parseStoresSpec(e,t){sB(e).forEach(n=>{if(null!==e[n]){var r=e[n].split(",").map((e,t)=>{let n=(e=e.trim()).replace(/([&*]|\+\+)/g,""),r=/^\[/.test(n)?n.match(/^\[(.*)\]$/)[1].split("+"):n;return pe(n,r||null,/\&/.test(e),/\*/.test(e),/\+\+/.test(e),sI(r),0===t)}),o=r.shift();if(o.multi)throw new lg.Schema("Primary key cannot be multi-valued");r.forEach(e=>{if(e.auto)throw new lg.Schema("Only primary key can be marked as autoIncrement (++)");if(!e.keyPath)throw new lg.Schema("Index must have a name and cannot be an empty string")}),t[n]=pn(n,o,r)}})}stores(e){let t=this.db;this._cfg.storesSource=this._cfg.storesSource?sN(this._cfg.storesSource,e):e;let n=t._versions,r={},o={};return n.forEach(e=>{sN(r,e._cfg.storesSource),o=e._cfg.dbschema={},e._parseStoresSpec(r,o)}),t._dbSchema=o,pp(t,[t._allTables,t,t.Transaction.prototype]),pc(t,[t._allTables,t,t.Transaction.prototype,this._cfg.tables],sB(o),o),t._storeNames=sB(o),this}upgrade(e){return this._cfg.contentUpgrade=lD(this._cfg.contentUpgrade||lA,e),this}}function pg(e,t){let n=e._dbNamesDB;return n||(n=e._dbNamesDB=new pN(cD,{addons:[],indexedDB:e,IDBKeyRange:t})).version(1).stores({dbnames:"name"}),n.table("dbnames")}function pb(e){return e&&"function"==typeof e.databases}function pv(e){return cs(function(){return lH.letThrough=!0,e()})}function pA(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),a=o.value;return o.done?a:a&&"function"==typeof a.then?a.then(n,r):sI(a)?Promise.all(a).then(n,r):n(a)}}return o(t)()}function p$(e,t,n){var r=arguments.length;if(r<2)throw new lg.InvalidArgument("Too few arguments");for(var o=Array(r-1);--r;)o[r-1]=arguments[r];return n=o.pop(),[e,s3(o),n]}function pk(e,t,n){let r=sI(e)?e.slice():[e];for(let e=0;e<n;++e)r.push(t);return r}let pw={stack:"dbcore",name:"VirtualIndexMiddleware",level:1,create:function(e){return{...e,table(t){let n=e.table(t),{schema:r}=n,o={},a=[];function i(e,t,n){let r=ps(e),s=o[r]=o[r]||[],l=null==e?0:"string"==typeof e?1:e.length,c=t>0,p={...n,isVirtual:c,keyTail:t,keyLength:l,extractKey:po(e),unique:!c&&n.unique};return s.push(p),p.isPrimaryKey||a.push(p),l>1&&i(2===l?e[0]:e.slice(0,l-1),t+1,n),s.sort((e,t)=>e.keyTail-t.keyTail),p}let s=i(r.primaryKey.keyPath,0,r.primaryKey);for(let e of(o[":id"]=[s],r.indexes))i(e.keyPath,0,e);function l(t){var n,r;let o=t.query.index;return o.isVirtual?{...t,query:{index:o,range:(n=t.query.range,r=o.keyTail,{type:1===n.type?2:n.type,lower:pk(n.lower,n.lowerOpen?e.MAX_KEY:e.MIN_KEY,r),lowerOpen:!0,upper:pk(n.upper,n.upperOpen?e.MIN_KEY:e.MAX_KEY,r),upperOpen:!0})}}:t}return{...n,schema:{...r,primaryKey:s,indexes:a,getIndexByKeyPath:function(e){let t=o[ps(e)];return t&&t[0]}},count:e=>n.count(l(e)),query:e=>n.query(l(e)),openCursor(t){let{keyTail:r,isVirtual:o,keyLength:a}=t.query.index;return o?n.openCursor(l(t)).then(n=>n&&Object.create(n,{continue:{value:function(o){null!=o?n.continue(pk(o,t.reverse?e.MAX_KEY:e.MIN_KEY,r)):t.unique?n.continue(n.key.slice(0,a).concat(t.reverse?e.MIN_KEY:e.MAX_KEY,r)):n.continue()}},continuePrimaryKey:{value(t,o){n.continuePrimaryKey(pk(t,e.MAX_KEY,r),o)}},primaryKey:{get:()=>n.primaryKey},key:{get(){let e=n.key;return 1===a?e[0]:e.slice(0,a)}},value:{get:()=>n.value}})):n.openCursor(t)}}}}}};function px(e,t,n,r){return n=n||{},r=r||"",sB(e).forEach(o=>{if(sF(t,o)){var a=e[o],i=t[o];if("object"==typeof a&&"object"==typeof i&&a&&i){let e=s9(a);e!==s9(i)?n[r+o]=t[o]:"Object"===e?px(a,i,n,r+o+"."):a!==i&&(n[r+o]=t[o])}else a!==i&&(n[r+o]=t[o])}else n[r+o]=void 0}),sB(t).forEach(o=>{sF(e,o)||(n[r+o]=t[o])}),n}let pC={stack:"dbcore",name:"HooksMiddleware",level:2,create:e=>({...e,table(t){let n=e.table(t),{primaryKey:r}=n.schema;return{...n,mutate(e){let o=lH.trans,{deleting:a,creating:i,updating:s}=o.table(t).hook;switch(e.type){case"add":if(i.fire===lA)break;return o._promise("readwrite",()=>l(e),!0);case"put":if(i.fire===lA&&s.fire===lA)break;return o._promise("readwrite",()=>l(e),!0);case"delete":if(a.fire===lA)break;return o._promise("readwrite",()=>l(e),!0);case"deleteRange":if(a.fire===lA)break;return o._promise("readwrite",()=>(function e(t,o,a){return n.query({trans:t,values:!1,query:{index:r,range:o},limit:a}).then(({result:n})=>l({type:"delete",keys:n,trans:t}).then(r=>r.numFailures>0?Promise.reject(r.failures[0]):n.length<a?{failures:[],numFailures:0,lastResult:void 0}:e(t,{...o,lower:n[n.length-1],lowerOpen:!0},a)))})(e.trans,e.range,1e4),!0)}return n.mutate(e);function l(e){var t,o;let l=lH.trans,c=e.keys||("delete"===(t=e).type?t.keys:t.keys||t.values.map(r.extractKey));if(!c)throw Error("Keys missing");return"delete"!==(e="add"===e.type||"put"===e.type?{...e,keys:c}:{...e}).type&&(e.values=[...e.values]),e.keys&&(e.keys=[...e.keys]),("add"===(o=e).type?Promise.resolve([]):n.getMany({trans:o.trans,keys:c,cache:"immutable"})).then(t=>{let o=c.map((n,o)=>{let c=t[o],p={onerror:null,onsuccess:null};if("delete"===e.type)a.fire.call(p,n,c,l);else if("add"===e.type||void 0===c){let t=i.fire.call(p,n,e.values[o],l);null==n&&null!=t&&(n=t,e.keys[o]=n,r.outbound||s0(e.values[o],r.keyPath,n))}else{let t=px(c,e.values[o]),r=s.fire.call(p,t,n,c,l);if(r){let t=e.values[o];Object.keys(r).forEach(e=>{sF(t,e)?t[e]=r[e]:s0(t,e,r[e])})}}return p});return n.mutate(e).then(({failures:n,results:r,numFailures:a,lastResult:i})=>{for(let a=0;a<c.length;++a){let i=r?r[a]:c[a],s=o[a];null==i?s.onerror&&s.onerror(n[a]):s.onsuccess&&s.onsuccess("put"===e.type&&t[a]?e.values[a]:i)}return{failures:n,results:r,numFailures:a,lastResult:i}}).catch(e=>(o.forEach(t=>t.onerror&&t.onerror(e)),Promise.reject(e)))})}}}}})};function pE(e,t,n){try{if(!t||t.keys.length<e.length)return null;let r=[];for(let o=0,a=0;o<t.keys.length&&a<e.length;++o)0===cU(t.keys[o],e[a])&&(r.push(n?s8(t.values[o]):t.values[o]),++a);return r.length===e.length?r:null}catch(e){return null}}let pS={stack:"dbcore",level:-1,create:e=>({table:t=>{let n=e.table(t);return{...n,getMany:e=>{if(!e.cache)return n.getMany(e);let t=pE(e.keys,e.trans._cache,"clone"===e.cache);return t?lZ.resolve(t):n.getMany(e).then(t=>(e.trans._cache={keys:e.keys,values:"clone"===e.cache?s8(t):t},t))},mutate:e=>("add"!==e.type&&(e.trans._cache=null),n.mutate(e))}}})};function pD(e){return!("from"in e)}let pM=function(e,t){if(!this){let t=new pM;return e&&"d"in e&&sN(t,e),t}sN(this,arguments.length?{d:1,from:e,to:arguments.length>1?t:e}:{d:0})};function pz(e,t,n){let r=cU(t,n);if(isNaN(r))return;if(r>0)throw RangeError();if(pD(e))return sN(e,{from:t,to:n,d:1});let o=e.l,a=e.r;if(0>cU(n,e.from))return o?pz(o,t,n):e.l={from:t,to:n,d:1,l:null,r:null},pT(e);if(cU(t,e.to)>0)return a?pz(a,t,n):e.r={from:t,to:n,d:1,l:null,r:null},pT(e);0>cU(t,e.from)&&(e.from=t,e.l=null,e.d=a?a.d+1:1),cU(n,e.to)>0&&(e.to=n,e.r=null,e.d=e.l?e.l.d+1:1);let i=!e.r;o&&!e.l&&pO(e,o),a&&i&&pO(e,a)}function pO(e,t){pD(t)||function e(t,{from:n,to:r,l:o,r:a}){pz(t,n,r),o&&e(t,o),a&&e(t,a)}(e,t)}function pP(e){let t=pD(e)?null:{s:0,n:e};return{next(e){let n=arguments.length>0;for(;t;)switch(t.s){case 0:if(t.s=1,n)for(;t.n.l&&0>cU(e,t.n.from);)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||0>=cU(e,t.n.to))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 pT(e){var t,n;let r=((null==(t=e.r)?void 0:t.d)||0)-((null==(n=e.l)?void 0:n.d)||0),o=r>1?"r":r<-1?"l":"";if(o){let 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=pB(n)}e.d=pB(e)}function pB({r:e,l:t}){return(e?t?Math.max(e.d,t.d):e.d:t?t.d:0)+1}sL(pM.prototype,{add(e){return pO(this,e),this},addKey(e){return pz(this,e,e),this},addKeys(e){return e.forEach(e=>pz(this,e,e)),this},[le](){return pP(this)}});let pI={stack:"dbcore",level:0,create:e=>{let t=e.schema.name,n=new pM(e.MIN_KEY,e.MAX_KEY);return{...e,table:r=>{let o=e.table(r),{schema:a}=o,{primaryKey:i}=a,{extractKey:s,outbound:l}=i,c={...o,mutate:e=>{let i=e.trans,s=i.mutatedParts||(i.mutatedParts={}),l=e=>{let n=`idb://${t}/${r}/${e}`;return s[n]||(s[n]=new pM)},c=l(""),p=l(":dels"),{type:u}=e,[d,f]="deleteRange"===e.type?[e.range]:"delete"===e.type?[e.keys]:e.values.length<50?[[],e.values]:[],h=e.trans._cache;return o.mutate(e).then(e=>{if(sI(d)){"delete"!==u&&(d=e.results),c.addKeys(d);let t=pE(d,h);t||"add"===u||p.addKeys(d),(t||f)&&a.indexes.forEach(function(e){let n=l(e.name||"");function r(t){return null!=t?e.extractKey(t):null}let o=t=>e.multiEntry&&sI(t)?t.forEach(e=>n.addKey(e)):n.addKey(t);(t||f).forEach((e,n)=>{let a=t&&r(t[n]),i=f&&r(f[n]);0!==cU(a,i)&&(null!=a&&o(a),null!=i&&o(i))})})}else if(d){let e={from:d.lower,to:d.upper};p.add(e),c.add(e)}else c.add(n),p.add(n),a.indexes.forEach(e=>l(e.name).add(n));return e})}},p=({query:{index:t,range:n}})=>{var r,o;return[t,new pM(null!=(r=n.lower)?r:e.MIN_KEY,null!=(o=n.upper)?o:e.MAX_KEY)]},u={get:e=>[i,new pM(e.key)],getMany:e=>[i,(new pM).addKeys(e.keys)],count:p,query:p,openCursor:p};return sB(u).forEach(e=>{c[e]=function(a){let{subscr:i}=lH;if(i){let c=e=>{let n=`idb://${t}/${r}/${e}`;return i[n]||(i[n]=new pM)},p=c(""),d=c(":dels"),[f,h]=u[e](a);if(c(f.name||"").add(h),!f.isPrimaryKey){if("count"!==e){let t="query"===e&&l&&a.values&&o.query({...a,values:!1});return o[e].apply(this,arguments).then(n=>{if("query"===e){if(l&&a.values)return t.then(({result:e})=>(p.addKeys(e),n));let e=a.values?n.result.map(s):n.result;a.values?p.addKeys(e):d.addKeys(e)}else if("openCursor"===e){let e=a.values;return n&&Object.create(n,{key:{get:()=>(d.addKey(n.primaryKey),n.key)},primaryKey:{get(){let e=n.primaryKey;return d.addKey(e),e}},value:{get:()=>(e&&p.addKey(n.primaryKey),n.value)}})}return n})}d.add(n)}}return o[e].apply(this,arguments)}}),c}}}};class pN{constructor(e,t){var n;this._middlewares={},this.verno=0;const r=pN.dependencies;this._options=t={addons:pN.addons,autoOpen:!0,indexedDB:r.indexedDB,IDBKeyRange:r.IDBKeyRange,...t},this._deps={indexedDB:t.indexedDB,IDBKeyRange:t.IDBKeyRange};const{addons:o}=t;this._dbSchema={},this._versions=[],this._storeNames=[],this._allTables={},this.idbdb=null,this._novip=this;const a={dbOpenError:null,isBeingOpened:!1,onReadyBeingFired:null,openComplete:!1,dbReadyResolve:lA,dbReadyPromise:null,cancelOpen:lA,openCanceller:null,autoSchema:!0,PR1398_maxLoop:3};a.dbReadyPromise=new lZ(e=>{a.dbReadyResolve=e}),a.openCanceller=new lZ((e,t)=>{a.cancelOpen=t}),this._state=a,this.name=e,this.on=cI(this,"populate","blocked","versionchange","close",{ready:[lD,lA]}),this.on.ready.subscribe=sY(this.on.ready.subscribe,e=>(t,n)=>{pN.vip(()=>{let r=this._state;if(r.openComplete)r.dbOpenError||lZ.resolve().then(t),n&&e(t);else if(r.onReadyBeingFired)r.onReadyBeingFired.push(t),n&&e(t);else{e(t);let r=this;n||e(function e(){r.on.ready.unsubscribe(t),r.on.ready.unsubscribe(e)})}})}),this.Collection=(n=this,cN(cK.prototype,function(e,t){this.db=n;let r=cP,o=null;if(t)try{r=t()}catch(e){o=e}let a=e._ctx,i=a.table,s=i.hook.reading.fire;this._ctx={table:i,index:a.index,isPrimKey:!a.index||i.schema.primKey.keyPath&&a.index===i.schema.primKey.name,range:r,keysOnly:!1,dir:"next",unique:"",algorithm:null,filter:null,replayFilter:null,justLimit:!0,isMatch:null,offset:0,limit:1/0,error:o,or:a.or,valueMapper:s!==l$?s:null}})),this.Table=function(e){return cN(cB.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:cI(null,{creating:[lx,lA],reading:[lk,l$],updating:[lE,lA],deleting:[lC,lA]})})}(this),this.Transaction=function(e){return cN(c9.prototype,function(t,n,r,o,a){this.db=e,this.mode=t,this.storeNames=n,this.schema=r,this.chromeTransactionDurability=o,this.idbtrans=null,this.on=cI(this,"complete","error","abort"),this.parent=a||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 lZ((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(),cv(e)})})}(this),this.Version=function(e){return cN(py.prototype,function(t){this.db=e,this._cfg={version:t,storesSource:null,dbschema:{},tables:{},contentUpgrade:null}})}(this),this.WhereClause=function(e){return cN(c3.prototype,function(t,n,r){this.db=e,this._ctx={table:t,index:":id"===n?null:n,or:r};let o=e._deps.indexedDB;if(!o)throw new lg.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)=>0>o.cmp(e,t)?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=pr(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),cC.filter(e=>e.name===this.name&&e!==this&&!e._state.vcFired).map(t=>t.on("versionchange").fire(e))},this.use(pw),this.use(pC),this.use(pI),this.use(pS),this.vip=Object.create(this,{_vip:{value:!0}}),o.forEach(e=>e(this))}version(e){if(isNaN(e)||e<.1)throw new lg.Type("Given version is not a positive number");if(e=Math.round(10*e)/10,this.idbdb||this._state.isBeingOpened)throw new lg.Schema("Cannot add version when database is open");this.verno=Math.max(this.verno,e);let 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(pu),n.stores({}),this._state.autoSchema=!1,n)}_whenReady(e){return this.idbdb&&(this._state.openComplete||lH.letThrough||this._vip)?e():new lZ((e,t)=>{if(this._state.openComplete)return t(new lg.DatabaseClosed(this._state.dbOpenError));if(!this._state.isBeingOpened){if(!this._options.autoOpen)return void t(new lg.DatabaseClosed);this.open().catch(lA)}this._state.dbReadyPromise.then(e,t)}).then(e)}use({stack:e,create:t,level:n,name:r}){r&&this.unuse({stack:e,name:r});let 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){var t;let n=e._state,{indexedDB:r}=e._deps;if(n.isBeingOpened||e.idbdb)return n.dbReadyPromise.then(()=>n.dbOpenError?cv(n.dbOpenError):e);la&&(n.openCanceller._stackHolder=ll()),n.isBeingOpened=!0,n.dbOpenError=null,n.openComplete=!1;let o=n.openCanceller;function a(){if(n.openCanceller!==o)throw new lg.DatabaseClosed("db.open() was cancelled")}let i=n.dbReadyResolve,s=null,l=!1,c=()=>new lZ((t,o)=>{if(a(),!r)throw new lg.MissingAPI;let i=e.name,c=n.autoSchema?r.open(i):r.open(i,Math.round(10*e.verno));if(!c)throw new lg.MissingAPI;c.onerror=c5(o),c.onblocked=ce(e._fireOnBlocked),c.onupgradeneeded=ce(t=>{if(s=c.transaction,n.autoSchema&&!e._options.allowEmptyDB){c.onerror=c4,s.abort(),c.result.close();let e=r.deleteDatabase(i);e.onsuccess=e.onerror=ce(()=>{o(new lg.NoSuchDatabase(`Database ${i} doesnt exist`))})}else{let n,r,i,d;s.onerror=c5(o);var a,p,u=t.oldVersion>0x4000000000000000?0:t.oldVersion;l=u<1,e._novip.idbdb=c.result,a=u/10,p=s,n=e._dbSchema,(r=e._createTransaction("readwrite",e._storeNames,n)).create(p),r._completion.catch(o),i=r._reject.bind(r),d=lH.transless||lH,cs(()=>{lH.trans=r,lH.transless=d,0===a?(sB(n).forEach(e=>{pf(p,e,n[e].primKey,n[e].indexes)}),pl(e,p),lZ.follow(()=>e.on.populate.fire(r)).catch(i)):(function({_novip:e},t,n,r){let o=[],a=e._versions,i=e._dbSchema=pm(e,e.idbdb,r),s=!1;return a.filter(e=>e._cfg.version>=t).forEach(a=>{o.push(()=>{let o=i,l=a._cfg.dbschema;p_(e,o,r),p_(e,l,r),i=e._dbSchema=l;let c=pd(o,l);c.add.forEach(e=>{pf(r,e[0],e[1].primKey,e[1].indexes)}),c.change.forEach(e=>{if(e.recreate)throw new lg.Upgrade("Not yet support for changing primary key");{let t=r.objectStore(e.name);e.add.forEach(e=>ph(t,e)),e.change.forEach(e=>{t.deleteIndex(e.name),ph(t,e)}),e.del.forEach(e=>t.deleteIndex(e))}});let p=a._cfg.contentUpgrade;if(p&&a._cfg.version>t){let t;pl(e,r),n._memoizedTables={},s=!0;let a=s1(l);c.del.forEach(e=>{a[e]=o[e]}),pp(e,[e.Transaction.prototype]),pc(e,[e.Transaction.prototype],sB(a),a),n.schema=a;let i=lo(p);i&&cl();let u=lZ.follow(()=>{if((t=p(n))&&i){var e=cc.bind(null,null);t.then(e,e)}});return t&&"function"==typeof t.then?lZ.resolve(t):u.then(()=>t)}}),o.push(t=>{var r;s&&cE||(r=a._cfg.dbschema,[].slice.call(t.db.objectStoreNames).forEach(e=>null==r[e]&&t.db.deleteObjectStore(e))),pp(e,[e.Transaction.prototype]),pc(e,[e.Transaction.prototype],e._storeNames,e._dbSchema),n.schema=e._dbSchema})}),(function e(){return o.length?lZ.resolve(o.shift()(n.idbtrans)).then(e):lZ.resolve()})().then(()=>{var e;sB(e=i).forEach(t=>{r.db.objectStoreNames.contains(t)||pf(r,t,e[t].primKey,e[t].indexes)})})})(e,a,r,p).catch(i)})}},o),c.onsuccess=ce(()=>{s=null;let r=e._novip.idbdb=c.result,o=sK(r.objectStoreNames);if(o.length>0)try{let t,a=r.transaction(1===o.length?o[0]:o,"readonly");n.autoSchema?function({_novip:e},t,n){e.verno=t.version/10;let r=e._dbSchema=pm(0,t,n);e._storeNames=sK(t.objectStoreNames,0),pc(e,[e._allTables],sB(r),r)}(e,r,a):(p_(e,e._dbSchema,a),((t=pd(pm(0,e.idbdb,a),e._dbSchema)).add.length||t.change.some(e=>e.add.length||e.change.length))&&console.warn("Dexie SchemaDiff: Schema was extended without increasing the number passed to db.version(). Some queries may fail.")),pl(e,a)}catch(e){}cC.push(e),r.onversionchange=ce(t=>{n.vcFired=!0,e.on("versionchange").fire(t)}),r.onclose=ce(t=>{e.on("close").fire(t)}),l&&function({indexedDB:e,IDBKeyRange:t},n){pb(e)||n===cD||pg(e,t).put({name:n}).catch(lA)}(e._deps,i),t()},o)}).catch(e=>e&&"UnknownError"===e.name&&n.PR1398_maxLoop>0?(n.PR1398_maxLoop--,console.warn("Dexie: Workaround for Chrome UnknownError on open()"),c()):lZ.reject(e));return lZ.race([o,("u"<typeof navigator?lZ.resolve():!navigator.userAgentData&&/Safari\//.test(navigator.userAgent)&&!/Chrom(e|ium)\//.test(navigator.userAgent)&&indexedDB.databases?new Promise(function(e){var n=function(){return indexedDB.databases().finally(e)};t=setInterval(n,100),n()}).finally(function(){return clearInterval(t)}):Promise.resolve()).then(c)]).then(()=>(a(),n.onReadyBeingFired=[],lZ.resolve(pv(()=>e.on.ready.fire(e.vip))).then(function t(){if(n.onReadyBeingFired.length>0){let r=n.onReadyBeingFired.reduce(lD,lA);return n.onReadyBeingFired=[],lZ.resolve(pv(()=>r(e.vip))).then(t)}}))).finally(()=>{n.onReadyBeingFired=null,n.isBeingOpened=!1}).then(()=>e).catch(t=>{n.dbOpenError=t;try{s&&s.abort()}catch(e){}return o===n.openCanceller&&e._close(),cv(t)}).finally(()=>{n.openComplete=!0,i()})}(this)}_close(){let e=this._state,t=cC.indexOf(this);if(t>=0&&cC.splice(t,1),this.idbdb){try{this.idbdb.close()}catch(e){}this._novip.idbdb=null}e.dbReadyPromise=new lZ(t=>{e.dbReadyResolve=t}),e.openCanceller=new lZ((t,n)=>{e.cancelOpen=n})}close(){this._close();let e=this._state;this._options.autoOpen=!1,e.dbOpenError=new lg.DatabaseClosed,e.isBeingOpened&&e.cancelOpen(e.dbOpenError)}delete(){let e=arguments.length>0,t=this._state;return new lZ((n,r)=>{let o=()=>{this.close();var e=this._deps.indexedDB.deleteDatabase(this.name);e.onsuccess=ce(()=>{!function({indexedDB:e,IDBKeyRange:t},n){pb(e)||n===cD||pg(e,t).delete(n).catch(lA)}(this._deps,this.name),n()}),e.onerror=c5(r),e.onblocked=this._fireOnBlocked};if(e)throw new lg.InvalidArgument("Arguments not allowed in db.delete()");t.isBeingOpened?t.dbReadyPromise.then(o):o()})}backendDB(){return this.idbdb}isOpen(){return null!==this.idbdb}hasBeenClosed(){let e=this._state.dbOpenError;return e&&"DatabaseClosed"===e.name}hasFailed(){return null!==this._state.dbOpenError}dynamicallyOpened(){return this._state.autoSchema}get tables(){return sB(this._allTables).map(e=>this._allTables[e])}transaction(){let e=p$.apply(this,arguments);return this._transaction.apply(this,e)}_transaction(e,t,n){let r,o,a=lH.trans;a&&a.db===this&&-1===e.indexOf("!")||(a=null);let i=-1!==e.indexOf("?");e=e.replace("!","").replace("?","");try{if(o=t.map(e=>{var t=e instanceof this.Table?e.name:e;if("string"!=typeof t)throw TypeError("Invalid table argument to Dexie.transaction(). Only Table or String are allowed");return t}),"r"==e||e===cM)r=cM;else{if("rw"!=e&&e!=cz)throw new lg.InvalidArgument("Invalid transaction mode: "+e);r=cz}if(a){if(a.mode===cM&&r===cz){if(!i)throw new lg.SubTransaction("Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY");a=null}a&&o.forEach(e=>{if(a&&-1===a.storeNames.indexOf(e)){if(!i)throw new lg.SubTransaction("Table "+e+" not included in parent transaction.");a=null}}),i&&a&&!a.active&&(a=null)}}catch(e){return a?a._promise(null,(t,n)=>{n(e)}):cv(e)}let s=(function e(t,n,r,o,a){return lZ.resolve().then(()=>{let i,s=lH.transless||lH,l=t._createTransaction(n,r,t._dbSchema,o);if(o)l.idbtrans=o.idbtrans;else try{l.create(),t._state.PR1398_maxLoop=3}catch(o){return o.name===ly.InvalidState&&t.isOpen()&&--t._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),t._close(),t.open().then(()=>e(t,n,r,null,a))):cv(o)}let c=lo(a);c&&cl();let p=lZ.follow(()=>{if(i=a.call(l,l))if(c){var e=cc.bind(null,null);i.then(e,e)}else"function"==typeof i.next&&"function"==typeof i.throw&&(i=pA(i))},{trans:l,transless:s});return(i&&"function"==typeof i.then?lZ.resolve(i).then(e=>l.active?e:cv(new lg.PrematureCommit("Transaction committed too early. See http://bit.ly/2kdckMn"))):p.then(()=>i)).then(e=>(o&&l._resolve(),l._completion.then(()=>e))).catch(e=>(l._reject(e),cv(e)))})}).bind(null,this,r,o,a,n);return a?a._promise(r,s,"lock"):lH.trans?cm(lH.transless,()=>this._whenReady(s)):this._whenReady(s)}table(e){if(!sF(this._allTables,e))throw new lg.InvalidTable(`Table ${e} does not exist`);return this._allTables[e]}}let pj="u">typeof Symbol&&"observable"in Symbol?Symbol.observable:"@@observable";class pR{constructor(e){this._subscribe=e}subscribe(e,t,n){return this._subscribe(e&&"function"!=typeof e?e:{next:e,error:t,complete:n})}[pj](){return this}}function pF(e,t){return sB(t).forEach(n=>{pO(e[n]||(e[n]=new pM),t[n])}),e}try{o={indexedDB:sT.indexedDB||sT.mozIndexedDB||sT.webkitIndexedDB||sT.msIndexedDB,IDBKeyRange:sT.IDBKeyRange||sT.webkitIDBKeyRange}}catch(e){o={indexedDB:null,IDBKeyRange:null}}function pL(e){let t=pW;try{pW=!0,c7.storagemutated.fire(e)}finally{pW=t}}sL(pN,{...lv,delete:e=>new pN(e,{addons:[]}).delete(),exists:e=>new pN(e,{addons:[]}).open().then(e=>(e.close(),!0)).catch("NoSuchDatabaseError",()=>!1),getDatabaseNames(e){try{return(function({indexedDB:e,IDBKeyRange:t}){return pb(e)?Promise.resolve(e.databases()).then(e=>e.map(e=>e.name).filter(e=>e!==cD)):pg(e,t).toCollection().primaryKeys()})(pN.dependencies).then(e)}catch(e){return cv(new lg.MissingAPI)}},defineClass:()=>function(e){sN(this,e)},ignoreTransaction:e=>lH.trans?cm(lH.transless,e):e(),vip:pv,async:function(e){return function(){try{var t=pA(e.apply(this,arguments));return t&&"function"==typeof t.then?t:lZ.resolve(t)}catch(e){return cv(e)}}},spawn:function(e,t,n){try{var r=pA(e.apply(n,t||[]));return r&&"function"==typeof r.then?r:lZ.resolve(r)}catch(e){return cv(e)}},currentTransaction:{get:()=>lH.trans||null},waitFor:function(e,t){let n=lZ.resolve("function"==typeof e?pN.ignoreTransaction(e):e).timeout(t||6e4);return lH.trans?lH.trans.waitFor(n):n},Promise:lZ,debug:{get:()=>la,set:e=>{la=e,li="dexie"===e?()=>!0:cS}},derive:sV,extend:sN,props:sL,override:sY,Events:cI,on:c7,liveQuery:function(e){let t,n=!1,r=new pR(r=>{let o=lo(e),a=!1,i={},s={},l={get closed(){return a},unsubscribe:()=>{a=!0,c7.storagemutated.unsubscribe(d)}};r.start&&r.start(l);let c=!1,p=!1;function u(){return sB(s).some(e=>i[e]&&function(e,t){let n=pP(t),r=n.next();if(r.done)return!1;let o=r.value,a=pP(e),i=a.next(o.from),s=i.value;for(;!r.done&&!i.done;){if(0>=cU(s.from,o.to)&&cU(s.to,o.from)>=0)return!0;0>cU(o.from,s.from)?o=(r=n.next(s.from)).value:s=(i=a.next(o.from)).value}return!1}(i[e],s[e]))}let d=e=>{pF(i,e),u()&&f()},f=()=>{let h,m;if(c||a)return;i={};let y={},g=(o&&cl(),h=()=>cs(e,{subscr:y,trans:null}),m=lH.trans?cm(lH.transless,h):h(),o&&m.then(cc,cc),m);p||(c7(c6,d),p=!0),c=!0,Promise.resolve(g).then(e=>{n=!0,t=e,c=!1,a||(u()?f():(i={},s=y,r.next&&r.next(e)))},e=>{c=!1,n=!1,r.error&&r.error(e),l.unsubscribe()})};return f(),l});return r.hasValue=()=>n,r.getValue=()=>t,r},extendObservabilitySet:pF,getByKeyPath:sQ,setByKeyPath:s0,delByKeyPath:function(e,t){"string"==typeof t?s0(e,t,void 0):"length"in t&&[].map.call(t,function(t){s0(e,t,void 0)})},shallowClone:s1,deepClone:s8,getObjectDiff:px,cmp:cU,asap:sZ,minKey:ck,addons:[],connections:cC,errnames:ly,dependencies:o,semVer:cA,version:cA.split(".").map(e=>parseInt(e)).reduce((e,t,n)=>e+t/Math.pow(10,2*n))}),pN.maxKey=pr(pN.dependencies.IDBKeyRange),"u">typeof dispatchEvent&&"u">typeof addEventListener&&(c7(c6,e=>{if(!pW){let t;cE?(t=document.createEvent("CustomEvent")).initCustomEvent(c8,!0,!0,e):t=new CustomEvent(c8,{detail:e}),pW=!0,dispatchEvent(t),pW=!1}}),addEventListener(c8,({detail:e})=>{pW||pL(e)}));let pW=!1;if("u">typeof BroadcastChannel){let e=new BroadcastChannel(c8);"function"==typeof e.unref&&e.unref(),c7(c6,t=>{pW||e.postMessage(t)}),e.onmessage=e=>{e.data&&pL(e.data)}}else if("u">typeof self&&"u">typeof navigator){c7(c6,e=>{try{pW||("u">typeof localStorage&&localStorage.setItem(c8,JSON.stringify({trig:Math.random(),changedParts:e})),"object"==typeof self.clients&&[...self.clients.matchAll({includeUncontrolled:!0})].forEach(t=>t.postMessage({type:c8,changedParts:e})))}catch(e){}}),"u">typeof addEventListener&&addEventListener("storage",e=>{if(e.key===c8){let t=JSON.parse(e.newValue);t&&pL(t.changedParts)}});let e=self.document&&navigator.serviceWorker;e&&e.addEventListener("message",function({data:e}){e&&e.type===c8&&pL(e.changedParts)})}function pG(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}lZ.rejectionMapper=function(e,t){if(!e||e instanceof lf||e instanceof TypeError||e instanceof SyntaxError||!e.name||!lb[e.name])return e;var n=new lb[e.name](t||e.message,e);return"stack"in e&&sG(n,"stack",{get:function(){return this.inner.stack}}),n},li=cS;class pV extends pN{constructor(){super("EsmOffline"),pG(this,"syncQueue",void 0),pG(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 pU(){return new pV}let pq=new pV,pH={},pK=U("offline-synchronization",{});function pY(){return pK}async function pJ(){if(pK.getState().synchronization)return;let e=await pq.syncQueue.count(),t={},n=Object.entries(pH),r=n.length,o={},a=new AbortController,i=()=>{let e=pK.getState().synchronization;pK.setState({synchronization:{...e,pendingCount:e.pendingCount-1}})};try{pK.setState({synchronization:{totalCount:e,pendingCount:e,abortController:a}});for(let e=0;e<r&&n.length>0;e++)for(let e=n.length;e--;){let[r,s]=n[e],l=s.dependsOn.map(e=>t[e]);l.every(Boolean)&&(o[r]={},await Promise.all(l),t[r]=pZ(s,o,a,i),n.splice(e,1))}await Promise.allSettled(Object.values(t))}finally{pK.setState({synchronization:void 0})}}async function pZ({type:e,dependsOn:t,process:n},r,o,a){let i=[],s=[],l=await pX();await pq.syncQueue.where({type:e,userId:l}).each((e,t)=>{i.push([t.primaryKey,e.content,e.descriptor]),s.push(e.content)});for(let c=0;c<i.length;c++){let[p,u,{id:d,dependencies:f=[]}]=i[c];try{let a=await n(u,{abort:o,index:c,items:s,userId:l,dependencies:f.map(({id:e,type:n})=>t.includes(n)?r[n][e]:void 0)});void 0!==d&&(r[e][d]=a),await pq.syncQueue.delete(p)}catch(e){await pq.syncQueue.update(p,{lastError:{name:e?.name,message:e?.message??e?.toString()}})}finally{a()}}}async function pX(){let e=await ip();return e?.uuid||"*"}async function pQ(e,t,n,r){let o=r&&r.id;return void 0!==o&&await pq.syncQueue.where({type:t,userId:e}).filter(e=>e?.descriptor.id===o).delete().catch(pN.errnames.DatabaseClosed),await pq.syncQueue.add({type:t,content:n,userId:e,descriptor:r||{},createdOn:new Date}).catch(pN.errnames.DatabaseClosed,()=>-1)}async function p0(e,t,n){let r=await pX();return await pQ(r,e,t,n)}async function p1(e,t){return(await p2(e,t)).map(e=>e.content)}async function p2(e,t){return await pq.syncQueue.where(t?{type:t,userId:e}:{userId:e}).toArray().catch(pN.errnames.DatabaseClosed,()=>[])}async function p3(e){let t=await pX();return await p1(t,e)}async function p5(e){let t=await pX();return await p2(t,e)}async function p4(e){return await pq.syncQueue.get(e).catch(pN.errnames.DatabaseClosed,()=>void 0)}function p6(e){return!!pH[e]?.options.onBeginEditSyncItem}async function p8(e){let t=await p4(e);if(!t)throw Error(`No sync item with the ID ${e} exists.`);let n=pH[t.type]?.options.onBeginEditSyncItem;if(!n)throw Error(`A sync item with the ID ${e} exists, but the associated handler (if one exists) doesn't support editing the item. You can avoid this error by either verifying that sync items of this type can be edited via the "canEditSynchronizationItemsOfType(type: string)" function or alternatively ensure that the synchronizaton handler for sync items of type "${t.type}" supports editing items.`);n(t)}async function p7(e){await pq.syncQueue.delete(e).catch(pN.errnames.DatabaseClosed)}function p9(e,t,n,r={}){pH[e]={type:e,dependsOn:t,process:n,options:r}}let ue="u">typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),ut=new Uint8Array(16),un=[];for(let e=0;e<256;++e)un.push((e+256).toString(16).slice(1));let ur=function(e,t,n){if(ue&&!t&&!e)return ue();let r=(e=e||{}).random||(e.rng||function(){if(!a&&!(a="u">typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)))throw Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return a(ut)})();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,t){n=n||0;for(let e=0;e<16;++e)t[n+e]=r[e];return t}return function(e,t=0){return un[e[t+0]]+un[e[t+1]]+un[e[t+2]]+un[e[t+3]]+"-"+un[e[t+4]]+un[e[t+5]]+"-"+un[e[t+6]]+un[e[t+7]]+"-"+un[e[t+8]]+un[e[t+9]]+"-"+un[e[t+10]]+un[e[t+11]]+un[e[t+12]]+un[e[t+13]]+un[e[t+14]]+un[e[t+15]]}(r)},uo="OFFLINE+";function ua(){return uo+ur()}function ui(e){return e.startsWith(uo)}let us={};function ul(){return Object.values(us)}function uc(e){us[e.id]&&console.warn(`[setupDynamicOfflineDataHandler] Another second handler with the ID "${e.id}" was registered. This handler will override the previous one. This could be unintended as the previous handler might run different flows than the newly registered one. If this is the case, ensure that you are setting up the handlers with different IDs.`),us[e.id]=e}async function up(e){let t=await ug();return await uu(t,e)}async function uu(e,t){let n=new pV;return await n.dynamicOfflineData.where(t?{type:t,users:e}:{users:e}).toArray().catch(pN.errnames.DatabaseClosed,()=>[])}async function ud(e,t){let n=await ug();return await uf(n,e,t)}async function uf(e,t,n){let r=new pV,o=await r.dynamicOfflineData.get({type:t,identifier:n}).catch(pN.errnames.DatabaseClosed,()=>void 0);o?o.users.includes(e)||await r.dynamicOfflineData.update(o.id,{users:[...o.users,e]}).catch(pN.errnames.DatabaseClosed):await r.dynamicOfflineData.add({users:[e],type:t,identifier:n}).catch(pN.errnames.DatabaseClosed)}async function uh(e,t){let n=await ug();return await um(n,e,t)}async function um(e,t,n){let r=new pV,o=await r.dynamicOfflineData.get({type:t,identifier:n,users:e}).catch(pN.errnames.DatabaseClosed,()=>void 0);o&&(o.users.length>1?await r.dynamicOfflineData.update(o.id,{users:o.users.filter(t=>t!==e)}).catch(pN.errnames.DatabaseClosed):await r.dynamicOfflineData.delete(o.id).catch(pN.errnames.DatabaseClosed))}async function u_(e,t){let n=await up(e);await Promise.all(n.map(async e=>uy(e.type,e.identifier,t)))}async function uy(e,t,n){await ud(e,t);let r=new pV,o=await ug(),a=await r.dynamicOfflineData.get({type:e,identifier:t}).catch(pN.errnames.DatabaseClosed,()=>void 0),i=ul().filter(t=>t.type===e);if(!a)return;let s=await Promise.all(i.map(async e=>{try{return e.sync(t,n),{id:e.id,error:void 0}}catch(n){let t=n.message?.toString()??n.toString();return{id:e.id,error:t}}})),l=s.filter(e=>!e.error).map(e=>e.id),c=s.filter(e=>e.error).map(e=>e.id),p=s.filter(e=>e.error).map(e=>({handlerId:e.id,message:e.error})),u={syncedOn:new Date,syncedBy:o,succeededHandlers:l,erroredHandlers:c,errors:p};a.id&&await r.dynamicOfflineData.update(a.id,{syncState:u}).catch(pN.errnames.DatabaseClosed)}async function ug(){let e=(await ip()).uuid;if(!e)throw Error("Using the dynamic offline data API requires a logged in user.");return e}let ub=U("offline-patients",{offlinePatientDataSyncState:{},handlers:{}});function uv(){return uk(),ub}function uA(e,t){uk(),uc({type:"patient",displayName:t.displayName,id:e,isSynced:()=>Promise.resolve(!0),sync:(e,n)=>t.onOfflinePatientAdded({patientUuid:e,signal:n??new AbortController().signal})})}async function u$(e){uk(),await uy("patient",e)}function uk(){console.warn("The offline patient API has been deprecated and will be removed in a future release. To prevent future crashes, the functions remain available for the moment, but any invocations should be migrated ASAP.")}async function uw(e,t,n=!0){if(e){let r=null,[o,a]=await Promise.all([a7(`${a4}/Patient/${e}`,t).catch(e=>r=e),n?ux(e):Promise.resolve(null)]);if(o.ok)return o.data;if(a)return a;if(r)throw r}return null}async function ux(e){let t=(await p3("patient-registration")).find(t=>t.fhirPatient.id===e);return t?.fhirPatient??null}function uC(e,t){let n=new CustomEvent(`openmrs:${e}`,{detail:t??void 0,cancelable:!0,bubbles:!0});return window.dispatchEvent(n)}function uE(e,t){let n=e=>{t("detail"in e&&null!==e.detail?e.detail:void 0)};return window.addEventListener(`openmrs:${e}`,n),()=>{window.removeEventListener(`openmrs:${e}`,n)}}var uS=n(6170);function uD(e){return{uuid:e.uuid,display:e.display}}function uM(e=null,t=null){let n=new URLSearchParams;e&&n.set("tag",e),t&&n.set("q",t);let r=n.toString();return a9(`${a5}/location${r?"?"+r:""}`).pipe((0,uS.map)(e=>e.data.results.map(uD))).pipe((0,uS.take)(1))}function uz(e){return{uuid:e.uuid,display:e.display,name:e.name}}function uO(){return a9(`${a5}/visittype`).pipe((0,uS.map)(e=>e.data.results.map(uz))).pipe((0,uS.take)(1))}var uP=function(){function e(){return Error.call(this),this.message="object unsubscribed",this.name="ObjectUnsubscribedError",this}return e.prototype=Object.create(Error.prototype),e}(),uT=function(e){function t(t,n){var r=e.call(this)||this;return r.subject=t,r.subscriber=n,r.closed=!1,r}return ed(t,e),t.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)}}},t}(ev),uB=function(e){function t(t){var n=e.call(this,t)||this;return n.destination=t,n}return ed(t,e),t}(ek),uI=function(e){function t(){var t=e.call(this)||this;return t.observers=[],t.closed=!1,t.isStopped=!1,t.hasError=!1,t.thrownError=null,t}return ed(t,e),t.prototype[e$]=function(){return new uB(this)},t.prototype.lift=function(e){var t=new uN(this,this);return t.operator=e,t},t.prototype.next=function(e){if(this.closed)throw new uP;if(!this.isStopped)for(var t=this.observers,n=t.length,r=t.slice(),o=0;o<n;o++)r[o].next(e)},t.prototype.error=function(e){if(this.closed)throw new uP;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},t.prototype.complete=function(){if(this.closed)throw new uP;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},t.prototype.unsubscribe=function(){this.isStopped=!0,this.closed=!0,this.observers=null},t.prototype._trySubscribe=function(t){if(!this.closed)return e.prototype._trySubscribe.call(this,t);throw new uP},t.prototype._subscribe=function(e){if(this.closed)throw new uP;return this.hasError?(e.error(this.thrownError),ev.EMPTY):this.isStopped?(e.complete(),ev.EMPTY):(this.observers.push(e),new uT(this,e))},t.prototype.asObservable=function(){var e=new eC;return e.source=this,e},t.create=function(e,t){return new uN(e,t)},t}(eC),uN=function(e){function t(t,n){var r=e.call(this)||this;return r.destination=t,r.source=n,r}return ed(t,e),t.prototype.next=function(e){var t=this.destination;t&&t.next&&t.next(e)},t.prototype.error=function(e){var t=this.destination;t&&t.error&&this.destination.error(e)},t.prototype.complete=function(){var e=this.destination;e&&e.complete&&this.destination.complete()},t.prototype._subscribe=function(e){return this.source?this.source.subscribe(e):ev.EMPTY},t}(uI),uj=function(e){function t(t){var n=e.call(this)||this;return n._value=t,n}return ed(t,e),Object.defineProperty(t.prototype,"value",{get:function(){return this.getValue()},enumerable:!0,configurable:!0}),t.prototype._subscribe=function(t){var n=e.prototype._subscribe.call(this,t);return n&&!n.closed&&t.next(this._value),n},t.prototype.getValue=function(){if(this.hasError)throw this.thrownError;if(!this.closed)return this._value;throw new uP},t.prototype.next=function(t){e.prototype.next.call(this,this._value=t)},t}(uI),uR=((ea={}).NEWVISIT="startVisit",ea.EDITVISIT="editVisit",ea.LOADING="loadingVisit",ea),uF=((ei={}).NOTSTARTED="notStarted",ei.ONGOING="ongoing",ei);let uL="custom:(uuid,display,voided,indication,startDatetime,stopDatetime,encounters:(uuid,display,encounterDatetime,form:(uuid,name),location:ref,encounterType:ref,encounterProviders:(uuid,display,provider:(uuid,display))),patient:(uuid,display),visitType:(uuid,name,display),attributes:(uuid,display,attributeType:(name,datatypeClassname,uuid),value),location:(uuid,name,display))",uW=function(){try{return JSON.parse(sessionStorage.getItem("openmrs:visitStoreState")||"null")}catch(e){return null}}()||{patientUuid:null,manuallySetVisitUuid:null,mutateVisitCallbacks:{}};function uG(){return H("visit",uW)}function uV(e,t){uG().setState({patientUuid:e,manuallySetVisitUuid:t})}function uU(e,t){return a7(`${a5}/visit`,{signal:t.signal,method:"POST",headers:{"Content-type":"application/json"},body:e})}function uq(e,t,n){return a7(`${a5}/visit/${e}`,{signal:n.signal,method:"POST",headers:{"Content-type":"application/json"},body:t})}function uH(e,t,n){return a7(`${a5}/visit?patient=${e}&v=${n??uL}`,{signal:t.signal,method:"GET",headers:{"Content-type":"application/json"}})}uG().subscribe(e=>{var t;t=e,sessionStorage.setItem("openmrs:visitStoreState",JSON.stringify(t))});let uK=new uj(null);class uY{static get version(){return"1.4.0"}static toString(){return"JavaScript Expression Parser (JSEP) v"+uY.version}static addUnaryOp(e){return uY.max_unop_len=Math.max(e.length,uY.max_unop_len),uY.unary_ops[e]=1,uY}static addBinaryOp(e,t,n){return uY.max_binop_len=Math.max(e.length,uY.max_binop_len),uY.binary_ops[e]=t,n?uY.right_associative.add(e):uY.right_associative.delete(e),uY}static addIdentifierChar(e){return uY.additional_identifier_chars.add(e),uY}static addLiteral(e,t){return uY.literals[e]=t,uY}static removeUnaryOp(e){return delete uY.unary_ops[e],e.length===uY.max_unop_len&&(uY.max_unop_len=uY.getMaxKeyLen(uY.unary_ops)),uY}static removeAllUnaryOps(){return uY.unary_ops={},uY.max_unop_len=0,uY}static removeIdentifierChar(e){return uY.additional_identifier_chars.delete(e),uY}static removeBinaryOp(e){return delete uY.binary_ops[e],e.length===uY.max_binop_len&&(uY.max_binop_len=uY.getMaxKeyLen(uY.binary_ops)),uY.right_associative.delete(e),uY}static removeAllBinaryOps(){return uY.binary_ops={},uY.max_binop_len=0,uY}static removeLiteral(e){return delete uY.literals[e],uY}static removeAllLiterals(){return uY.literals={},uY}get char(){return this.expr.charAt(this.index)}get code(){return this.expr.charCodeAt(this.index)}constructor(e){this.expr=e,this.index=0}static parse(e){return new uY(e).parse()}static getMaxKeyLen(e){return Math.max(0,...Object.keys(e).map(e=>e.length))}static isDecimalDigit(e){return e>=48&&e<=57}static binaryPrecedence(e){return uY.binary_ops[e]||0}static isIdentifierStart(e){return e>=65&&e<=90||e>=97&&e<=122||e>=128&&!uY.binary_ops[String.fromCharCode(e)]||uY.additional_identifier_chars.has(String.fromCharCode(e))}static isIdentifierPart(e){return uY.isIdentifierStart(e)||uY.isDecimalDigit(e)}throwError(e){let t=Error(e+" at character "+this.index);throw t.index=this.index,t.description=e,t}runHook(e,t){if(uY.hooks[e]){let n={context:this,node:t};return uY.hooks.run(e,n),n.node}return t}searchHook(e){if(uY.hooks[e]){let t={context:this};return uY.hooks[e].find(function(e){return e.call(t.context,t),t.node}),t.node}}gobbleSpaces(){let e=this.code;for(;e===uY.SPACE_CODE||e===uY.TAB_CODE||e===uY.LF_CODE||e===uY.CR_CODE;)e=this.expr.charCodeAt(++this.index);this.runHook("gobble-spaces")}parse(){this.runHook("before-all");let e=this.gobbleExpressions(),t=1===e.length?e[0]:{type:uY.COMPOUND,body:e};return this.runHook("after-all",t)}gobbleExpressions(e){let t=[],n,r;for(;this.index<this.expr.length;)if((n=this.code)===uY.SEMCOL_CODE||n===uY.COMMA_CODE)this.index++;else if(r=this.gobbleExpression())t.push(r);else if(this.index<this.expr.length){if(n===e)break;this.throwError('Unexpected "'+this.char+'"')}return t}gobbleExpression(){let e=this.searchHook("gobble-expression")||this.gobbleBinaryExpression();return this.gobbleSpaces(),this.runHook("after-expression",e)}gobbleBinaryOp(){this.gobbleSpaces();let e=this.expr.substr(this.index,uY.max_binop_len),t=e.length;for(;t>0;){if(uY.binary_ops.hasOwnProperty(e)&&(!uY.isIdentifierStart(this.code)||this.index+e.length<this.expr.length&&!uY.isIdentifierPart(this.expr.charCodeAt(this.index+e.length))))return this.index+=t,e;e=e.substr(0,--t)}return!1}gobbleBinaryExpression(){let e,t,n,r,o,a,i,s,l;if(!(a=this.gobbleToken())||!(t=this.gobbleBinaryOp()))return a;for(o={value:t,prec:uY.binaryPrecedence(t),right_a:uY.right_associative.has(t)},(i=this.gobbleToken())||this.throwError("Expected expression after "+t),r=[a,o,i];t=this.gobbleBinaryOp();){if(0===(n=uY.binaryPrecedence(t))){this.index-=t.length;break}o={value:t,prec:n,right_a:uY.right_associative.has(t)},l=t;let s=e=>o.right_a&&e.right_a?n>e.prec:n<=e.prec;for(;r.length>2&&s(r[r.length-2]);)i=r.pop(),t=r.pop().value,a=r.pop(),e={type:uY.BINARY_EXP,operator:t,left:a,right:i},r.push(e);(e=this.gobbleToken())||this.throwError("Expected expression after "+l),r.push(o,e)}for(s=r.length-1,e=r[s];s>1;)e={type:uY.BINARY_EXP,operator:r[s-1].value,left:r[s-2],right:e},s-=2;return e}gobbleToken(){let e,t,n,r;if(this.gobbleSpaces(),r=this.searchHook("gobble-token"))return this.runHook("after-token",r);if(e=this.code,uY.isDecimalDigit(e)||e===uY.PERIOD_CODE)return this.gobbleNumericLiteral();if(e===uY.SQUOTE_CODE||e===uY.DQUOTE_CODE)r=this.gobbleStringLiteral();else if(e===uY.OBRACK_CODE)r=this.gobbleArray();else{for(n=(t=this.expr.substr(this.index,uY.max_unop_len)).length;n>0;){if(uY.unary_ops.hasOwnProperty(t)&&(!uY.isIdentifierStart(this.code)||this.index+t.length<this.expr.length&&!uY.isIdentifierPart(this.expr.charCodeAt(this.index+t.length)))){this.index+=n;let e=this.gobbleToken();return e||this.throwError("missing unaryOp argument"),this.runHook("after-token",{type:uY.UNARY_EXP,operator:t,argument:e,prefix:!0})}t=t.substr(0,--n)}uY.isIdentifierStart(e)?(r=this.gobbleIdentifier(),uY.literals.hasOwnProperty(r.name)?r={type:uY.LITERAL,value:uY.literals[r.name],raw:r.name}:r.name===uY.this_str&&(r={type:uY.THIS_EXP})):e===uY.OPAREN_CODE&&(r=this.gobbleGroup())}return r?(r=this.gobbleTokenProperty(r),this.runHook("after-token",r)):this.runHook("after-token",!1)}gobbleTokenProperty(e){this.gobbleSpaces();let t=this.code;for(;t===uY.PERIOD_CODE||t===uY.OBRACK_CODE||t===uY.OPAREN_CODE||t===uY.QUMARK_CODE;){let n;if(t===uY.QUMARK_CODE){if(this.expr.charCodeAt(this.index+1)!==uY.PERIOD_CODE)break;n=!0,this.index+=2,this.gobbleSpaces(),t=this.code}this.index++,t===uY.OBRACK_CODE?((e={type:uY.MEMBER_EXP,computed:!0,object:e,property:this.gobbleExpression()}).property||this.throwError('Unexpected "'+this.char+'"'),this.gobbleSpaces(),(t=this.code)!==uY.CBRACK_CODE&&this.throwError("Unclosed ["),this.index++):t===uY.OPAREN_CODE?e={type:uY.CALL_EXP,arguments:this.gobbleArguments(uY.CPAREN_CODE),callee:e}:(t===uY.PERIOD_CODE||n)&&(n&&this.index--,this.gobbleSpaces(),e={type:uY.MEMBER_EXP,computed:!1,object:e,property:this.gobbleIdentifier()}),n&&(e.optional=!0),this.gobbleSpaces(),t=this.code}return e}gobbleNumericLiteral(){let e="",t,n;for(;uY.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);if(this.code===uY.PERIOD_CODE)for(e+=this.expr.charAt(this.index++);uY.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);if("e"===(t=this.char)||"E"===t){for(e+=this.expr.charAt(this.index++),("+"===(t=this.char)||"-"===t)&&(e+=this.expr.charAt(this.index++));uY.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);uY.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+e+this.char+")")}return n=this.code,uY.isIdentifierStart(n)?this.throwError("Variable names cannot start with a number ("+e+this.char+")"):(n===uY.PERIOD_CODE||1===e.length&&e.charCodeAt(0)===uY.PERIOD_CODE)&&this.throwError("Unexpected period"),{type:uY.LITERAL,value:parseFloat(e),raw:e}}gobbleStringLiteral(){let e="",t=this.index,n=this.expr.charAt(this.index++),r=!1;for(;this.index<this.expr.length;){let t=this.expr.charAt(this.index++);if(t===n){r=!0;break}if("\\"===t)switch(t=this.expr.charAt(this.index++)){case"n":e+="\n";break;case"r":e+="\r";break;case"t":e+=" ";break;case"b":e+="\b";break;case"f":e+="\f";break;case"v":e+="\v";break;default:e+=t}else e+=t}return r||this.throwError('Unclosed quote after "'+e+'"'),{type:uY.LITERAL,value:e,raw:this.expr.substring(t,this.index)}}gobbleIdentifier(){let e=this.code,t=this.index;for(uY.isIdentifierStart(e)?this.index++:this.throwError("Unexpected "+this.char);this.index<this.expr.length;)if(e=this.code,uY.isIdentifierPart(e))this.index++;else break;return{type:uY.IDENTIFIER,name:this.expr.slice(t,this.index)}}gobbleArguments(e){let t=[],n=!1,r=0;for(;this.index<this.expr.length;){this.gobbleSpaces();let o=this.code;if(o===e){n=!0,this.index++,e===uY.CPAREN_CODE&&r&&r>=t.length&&this.throwError("Unexpected token "+String.fromCharCode(e));break}if(o===uY.COMMA_CODE){if(this.index++,++r!==t.length){if(e===uY.CPAREN_CODE)this.throwError("Unexpected token ,");else if(e===uY.CBRACK_CODE)for(let e=t.length;e<r;e++)t.push(null)}}else if(t.length!==r&&0!==r)this.throwError("Expected comma");else{let e=this.gobbleExpression();e&&e.type!==uY.COMPOUND||this.throwError("Expected comma"),t.push(e)}}return n||this.throwError("Expected "+String.fromCharCode(e)),t}gobbleGroup(){this.index++;let e=this.gobbleExpressions(uY.CPAREN_CODE);if(this.code===uY.CPAREN_CODE)return(this.index++,1===e.length)?e[0]:!!e.length&&{type:uY.SEQUENCE_EXP,expressions:e};this.throwError("Unclosed (")}gobbleArray(){return this.index++,{type:uY.ARRAY_EXP,elements:this.gobbleArguments(uY.CBRACK_CODE)}}}Object.assign(uY,{hooks:new class{add(e,t,n){if("string"!=typeof arguments[0])for(let e in arguments[0])this.add(e,arguments[0][e],arguments[1]);else(Array.isArray(e)?e:[e]).forEach(function(e){this[e]=this[e]||[],t&&this[e][n?"unshift":"push"](t)},this)}run(e,t){this[e]=this[e]||[],this[e].forEach(function(e){e.call(t&&t.context?t.context:t,t)})}},plugins:new class{constructor(e){this.jsep=e,this.registered={}}register(...e){e.forEach(e=>{if("object"!=typeof e||!e.name||!e.init)throw Error("Invalid JSEP plugin format");this.registered[e.name]||(e.init(this.jsep),this.registered[e.name]=e)})}}(uY),COMPOUND:"Compound",SEQUENCE_EXP:"SequenceExpression",IDENTIFIER:"Identifier",MEMBER_EXP:"MemberExpression",LITERAL:"Literal",THIS_EXP:"ThisExpression",CALL_EXP:"CallExpression",UNARY_EXP:"UnaryExpression",BINARY_EXP:"BinaryExpression",ARRAY_EXP:"ArrayExpression",TAB_CODE:9,LF_CODE:10,CR_CODE:13,SPACE_CODE:32,PERIOD_CODE:46,COMMA_CODE:44,SQUOTE_CODE:39,DQUOTE_CODE:34,OPAREN_CODE:40,CPAREN_CODE:41,OBRACK_CODE:91,CBRACK_CODE:93,QUMARK_CODE:63,SEMCOL_CODE:59,COLON_CODE:58,unary_ops:{"-":1,"!":1,"~":1,"+":1},binary_ops:{"||":1,"??":1,"&&":2,"|":3,"^":4,"&":5,"==":6,"!=":6,"===":6,"!==":6,"<":7,">":7,"<=":7,">=":7,"<<":8,">>":8,">>>":8,"+":9,"-":9,"*":10,"/":10,"%":10,"**":11},right_associative:new Set(["**"]),additional_identifier_chars:new Set(["$","_"]),literals:{true:!0,false:!1,null:null},this_str:"this"}),uY.max_unop_len=uY.getMaxKeyLen(uY.unary_ops),uY.max_binop_len=uY.getMaxKeyLen(uY.binary_ops);let uJ=e=>new uY(e).parse(),uZ=Object.getOwnPropertyNames(class{});Object.getOwnPropertyNames(uY).filter(e=>!uZ.includes(e)&&void 0===uJ[e]).forEach(e=>{uJ[e]=uY[e]}),uJ.Jsep=uY,uJ.plugins.register({name:"ternary",init(e){e.hooks.add("after-expression",function(t){if(t.node&&this.code===e.QUMARK_CODE){this.index++;let n=t.node,r=this.gobbleExpression();if(r||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===e.COLON_CODE){this.index++;let o=this.gobbleExpression();if(o||this.throwError("Expected expression"),t.node={type:"ConditionalExpression",test:n,consequent:r,alternate:o},n.operator&&e.binary_ops[n.operator]<=.9){let r=n;for(;r.right.operator&&e.binary_ops[r.right.operator]<=.9;)r=r.right;t.node.test=r.right,r.right=t.node,t.node=n}}else this.throwError("Expected :")}})}});let uX="ArrowFunctionExpression",uQ={Array,Boolean,Symbol,Infinity,NaN,Math,Number,BigInt,String,RegExp,JSON,isFinite,isNaN,parseFloat,parseInt,decodeURI,encodeURI,encodeURIComponent,Object:{__proto__:void 0,assign:Object.assign.bind(null),fromEntries:Object.fromEntries.bind(null),hasOwn:Object.hasOwn.bind(null),keys:Object.keys.bind(null),is:Object.is.bind(null),values:Object.values.bind(null)}},u0={...uQ,Promise};function u1(e,t={}){return u8(e,t,de)}async function u2(e,t={}){return u7(e,t,de)}function u3(e,t={}){return u8(e,t,dt)}function u5(e,t={}){return u7(e,t,dt)}function u4(e,t={}){return u8(e,t,dn)}function u6(e,t={}){return u7(e,t,dn)}function u8(e,t={},n){if("string"!=typeof e&&("object"!=typeof e||!e||!("type"in e)))throw`Unknown expression type ${e}. Expressions must either be a string or pre-compiled string.`;if("string"==typeof e&&0===e.trim().length)throw{type:"Empty expression",message:"Expression cannot be an empty string"};null==t&&(t={});let r=di(t,uQ),o=dr("string"==typeof e?uJ(e):e,r);if(n(o))return o;throw{type:"Invalid result",message:"string"==typeof e?`The expression ${e} did not produce a valid result`:"The expression did not produce a valid result"}}async function u7(e,t={},n){if("string"!=typeof e&&("object"!=typeof e||!e||!("type"in e)))return Promise.reject(`Unknown expression type ${e}. Expressions must either be a string or pre-compiled string.`);if("string"==typeof e&&0===e.trim().length)throw{type:"Empty expression",message:"Expression cannot be an empty string"};null==t&&(t={});let r=di(t,u0);return Promise.resolve(dr("string"==typeof e?uJ(e):e,r)).then(t=>{if(n(t))return t;throw{type:"Invalid result",message:"string"==typeof e?`The expression ${e} did not produce a valid result`:"The expression did not produce a valid result"}})}function u9(e){return uJ(e)}function de(e){return"string"==typeof e||"number"==typeof e||"boolean"==typeof e||null==e||e instanceof Date}function dt(e){return"boolean"==typeof e}function dn(e){return"number"==typeof e}function dr(e,t){switch(e.type){case"UnaryExpression":var n,r,o,a,i,s,l,c,p,u,d,f,h=e,m=t;let y=dr(h.argument,m);switch(h.operator){case"+":return+y;case"-":return-y;case"~":return~y;case"!":return!y;default:throw`Expression evaluator does not support operator '${h.operator}''`}case"BinaryExpression":var g=e,b=t;let v=dr(g.left,b),A=dr(g.right,b);switch(g.operator){case"+":return v+A;case"-":return v-A;case"*":return v*A;case"/":return v/A;case"%":return v%A;case"**":return v**A;case"==":return v==A;case"===":return v===A;case"!=":return v!=A;case"!==":return v!==A;case">":return v>A;case">=":return v>=A;case"<":return v<A;case"<=":return v<=A;case"in":return v in A;case"&&":return v&&A;case"||":return v||A;case"??":return v??A;default:throw`Expression evaluator does not support operator '${g.operator}' operator`}case"ConditionalExpression":return n=e,r=t,dr(n.test,r)?dr(n.consequent,r):dr(n.alternate,r);case"CallExpression":var $=e,k=t;let w=$.arguments?.map(ds(k)),x=dr($.callee,k);if(x){if("function"!=typeof x)throw`${dc($.callee)} is not a function`}else throw`No function named ${dc($.callee)} is defined in this context`;return x(...w);case"ArrowFunctionExpression":let C;return o=e,a=t,C=o.params?.map(e=>{if("Identifier"===e.type)return e.name;throw`Cannot handle parameter of type ${e.type}`})??[],(function(...e){if(e.length<C.length)throw`Required argument(s) ${C.slice(e.length,-1).join(", ")} were not provided`;let t=Object.fromEntries(C.reduce((t,n,r)=>{let o=e[r];return function e(t){if("string"==typeof t||"number"==typeof t||"boolean"==typeof t||"function"==typeof t||null===t||t instanceof RegExp)return!0;if("object"==typeof t){for(let n of Object.keys(t))if(!e(t[n]))return!1;return!0}if(Array.isArray(t)){for(let n of t)if(!e(n))break}return!1}(o)&&t.push([n,o]),t},[]));return dr(o.body,a.addVariables(t))}).bind(a.thisObj??null);case"MemberExpression":return function(e,t){let n,r=dr(e.object,t);if(void 0===r)switch(e.object.type){case"Identifier":{let n=da(e.object,t);throw ReferenceError(`ReferenceError: ${n} is not defined`)}case"MemberExpression":{let n=da(e.property,t);throw TypeError(`TypeError: cannot read properties of undefined (reading '${n}')`)}default:throw`VisitMemberExpression does not support operator '${e.object.type}' type`}let o=r;if("string"==typeof r)o=String.prototype;else if("number"==typeof r)o=Number.prototype;else if("function"==typeof r);else if("object"!=typeof r)throw`VisitMemberExpression does not support member access on type ${typeof r}`;switch(t.thisObj=o,e.property.type){case"Identifier":case"MemberExpression":n=dr(e.property,t);break;default:{let o=dr(e.property,t);if(void 0===o)throw{type:"Illegal property access",message:"No property was supplied to the property access"};dl(o),n=r[o]}}return"function"==typeof n?n.bind(r):n}(e,t);case"ArrayExpression":return i=e,s=t,i.elements?.map(ds(s));case"SequenceExpression":let E;return l=e,c=t,(E=l.expressions.map(ds(c)))[E.length-1];case"NewExpression":var S=e,D=t;if(S.callee&&"Identifier"===S.callee.type){let e=S.arguments?.map(ds(D));switch(S.callee.name){case"Date":return new Date(...e);case"RegExp":return new RegExp(...e);default:throw`Cannot instantiate object of type ${S.callee.name}`}}if(S.callee)throw"new must be called with either Date or RegExp";throw'Could not handle "new" without a specified class';case"Literal":return dl((p=e).value),p.value;case"Identifier":var M=e,z=t;dl(M.name);let O=z.thisObj;if(O&&("object"==typeof O||"function"==typeof O)&&M.name in O){let e=O[M.name];return dl(e),e}if(z.variables&&M.name in z.variables){let e=z.variables[M.name];return dl(e),e}return M.name in z.globals?z.globals[M.name]:void 0;case"TemplateLiteral":let P,T;return u=e,d=t,P=u.expressions?.map(ds(d))??[],(T=u.quasis?.map(ds(d))??[]).filter(e=>!e.tail).map(e=>e.value).join("")+P.join("")+T.filter(e=>e.tail).map(e=>e.value).join("");case"TemplateElement":return{value:(f=e).cooked,tail:f.tail};default:throw`Expression evaluator does not support expression of type '${e.type}'`}}function da(e,t){switch(e.type){case"Literal":return e.value;case"Identifier":return e.name;case"MemberExpression":return da(e.property,t);default:throw`VisitExpressionName does not support expression of type '${e.type}'`}}function di(e,t){let n={thisObj:void 0,variables:{...e},globals:{...t},addVariables(e){return this.variables={...this.variables,...e},this}};return n.addVariables.bind(n),n}function ds(e){return function(t){return null===t?null:dr(t,e)}}function dl(e){if("__proto__"===e||"prototype"===e||"constructor"===e)throw{type:"Illegal property access",message:`Cannot access the ${e} property of objects`}}function dc(e){return e?"MemberExpression"===e.type?e.property?.name:e.name:null}function dp(e){if("string"!=typeof e&&("object"!=typeof e||!e||!("type"in e)))throw`Unknown expression type ${e}. Expressions must either be a string or pre-compiled string.`;let t={globals:{...u0},isLocalExpression:!1,variables:new Set};return du("string"==typeof e?uJ(e):e,t),[...t.variables]}function du(e,t){switch(e.type){case"UnaryExpression":return r=e,o=t,du(r.argument,o);case"BinaryExpression":return a=e,i=t,[du(a.left,i),du(a.right,i)].filter(Boolean);case"ConditionalExpression":return s=e,l=t,[du(s.consequent,l),du(s.test,l),du(s.alternate,l)].filter(Boolean);case"CallExpression":let n;return c=e,p=t,n=du(c.callee,p),c.arguments?.map(dd(p)),n;case"ArrowFunctionExpression":var r,o,a,i,s,l,c,p,u,d,f,h,m,y,g,b,v,A,$=e,k=t;let w={...k};w.isLocalExpression=!0;let x=$.params?.map(dd(w))??[],C=du($.body,w)??[];if(C&&Array.isArray(C))for(let e of C)x.includes(e)||k.variables.add(e);return;case"MemberExpression":let E;return u=e,d=t,du(u.object,d),void((E={...d}).isLocalExpression=!0,du(u.property,E));case"ArrayExpression":return f=e,h=t,void f.elements?.map(dd(h));case"SequenceExpression":return m=e,y=t,void m.expressions?.map(dd(y));case"NewExpression":return g=e,b=t,void g.arguments?.map(dd(b));case"Literal":case"TemplateElement":return;case"Identifier":var S=e,D=t;if(!(S.name in D.globals))if(D.isLocalExpression)return S.name;else D.variables.add(S.name);return;case"TemplateLiteral":return v=e,A=t,void(v.expressions?.map(dd(A)),v.quasis?.map(dd(A)));default:throw`Expression evaluator does not support expression of type '${e.type}'`}}function dd(e){return function(t){return null===t?null:du(t,e)}}uJ.plugins.register({name:"arrow",init(e){e.addBinaryOp("=>",.1,!0),e.hooks.add("gobble-expression",function(t){if(this.gobbleSpaces(),this.code===e.OPAREN_CODE){let n=this.index;if(this.index++,this.gobbleSpaces(),this.code===e.CPAREN_CODE){this.index++;let e=this.gobbleBinaryOp();if("=>"===e){let n=this.gobbleBinaryExpression();n||this.throwError("Expected expression after "+e),t.node={type:uX,params:null,body:n};return}}this.index=n}}),e.hooks.add("after-expression",function(t){!function t(n){n&&(Object.values(n).forEach(e=>{e&&"object"==typeof e&&t(e)}),"=>"===n.operator&&(n.type=uX,n.params=n.left?[n.left]:null,n.body=n.right,n.params&&n.params[0].type===e.SEQUENCE_EXP&&(n.params=n.params[0].expressions),delete n.left,delete n.right,delete n.operator))}(t.node)})}}),uJ.plugins.register({name:"new",init(e){e.addUnaryOp("new"),e.hooks.add("after-token",function(t){let n=t.node;if(n&&"new"===n.operator){n.argument&&[e.CALL_EXP,e.MEMBER_EXP].includes(n.argument.type)||this.throwError("Expected new function()"),t.node=n.argument;let r=t.node;for(;r.type===e.MEMBER_EXP||r.type===e.CALL_EXP&&r.callee.type===e.MEMBER_EXP;)r=r.type===e.MEMBER_EXP?r.object:r.callee.object;r.type="NewExpression"}})}}),uJ.plugins.register({name:"numbers",init(e){function t(e){return"x"===e||"X"===e?(this.index+=2,[[48,57],[65,70],[97,102]]):"b"===e||"B"===e?(this.index+=2,[[48,49]]):"o"===e||"O"===e||e>="0"&&e<="7"?(this.index+=e<="7"?1:2,[[48,55]]):null}function n(t){let n=this.index,r="",o=()=>{for(;e.isDecimalDigit(this.code)||95===this.code;)95===this.code?this.index++:r+=this.expr.charAt(this.index++)};o(),this.code===e.PERIOD_CODE&&(r+=this.expr.charAt(this.index++),o());let a=this.char;("e"===a||"E"===a)&&(r+=this.expr.charAt(this.index++),("+"===(a=this.char)||"-"===a)&&(r+=this.expr.charAt(this.index++)),o(),e.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+r+this.char+")"));let i=this.code;if(e.isIdentifierStart(i))this.throwError("Variable names cannot start with a number ("+r+this.char+")");else if(i===e.PERIOD_CODE){r.length>1&&this.throwError(`Unexpected period ${JSON.stringify({chCode:i,number:r},null,2)}`),this.index=n;return}t.node={type:e.LITERAL,value:parseFloat(r),raw:this.expr.substring(n,this.index)}}e.hooks.add("gobble-token",function(r){if(48===this.code){var o,a,i;let s=this.index,l=this.expr.charAt(this.index+1),c=t.call(this,l);if(!c)return;let p="";for(;o=this.code,a=c,95===o||a.some(([e,t])=>o>=e&&o<=t);)95===this.code?this.index++:p+=this.expr.charAt(this.index++);if(e.isIdentifierPart(this.code)){if(e.isDecimalDigit(this.code)&&e.isDecimalDigit(l.charCodeAt(0))){this.index=s+1,n.call(this,r);return}this.throwError("unexpected char within number")}r.node={type:e.LITERAL,value:parseInt(p,"x"===(i=l)||"X"===i?16:"b"===i||"B"===i?2:8),raw:this.expr.substring(s,this.index)}}else(e.isDecimalDigit(this.code)||this.code===e.PERIOD_CODE)&&n.call(this,r)})}}),uJ.plugins.register({name:"regex",init(e){e.hooks.add("gobble-token",function(t){if(47===this.code){let n=++this.index,r=!1;for(;this.index<this.expr.length;){if(47===this.code&&!r){let r,o=this.expr.slice(n,this.index),a="";for(;++this.index<this.expr.length;){let e=this.code;if(e>=97&&e<=122||e>=65&&e<=90||e>=48&&e<=57)a+=this.char;else break}try{r=new RegExp(o,a)}catch(e){this.throwError(e.message)}return t.node={type:e.LITERAL,value:r,raw:this.expr.slice(n-1,this.index)},t.node=this.gobbleTokenProperty(t.node),t.node}this.code===e.OBRACK_CODE?r=!0:r&&this.code===e.CBRACK_CODE&&(r=!1),this.index+=92===this.code?2:1}this.throwError("Unclosed Regex")}})}}),uJ.plugins.register({name:"ternary",init(e){e.hooks.add("after-expression",function(t){if(t.node&&this.code===e.QUMARK_CODE){this.index++;let n=t.node,r=this.gobbleExpression();if(r||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===e.COLON_CODE){this.index++;let o=this.gobbleExpression();if(o||this.throwError("Expected expression"),t.node={type:"ConditionalExpression",test:n,consequent:r,alternate:o},n.operator&&e.binary_ops[n.operator]<=.9){let r=n;for(;r.right.operator&&e.binary_ops[r.right.operator]<=.9;)r=r.right;t.node.test=r.right,r.right=t.node,t.node=n}}else this.throwError("Expected :")}})}}),uJ.plugins.register({name:"jsepTemplateLiteral",init(e){function t(e,n=!0){if(96===this.code){let t={type:"TemplateLiteral",quasis:[],expressions:[]},r="",o="",a=!1,i=this.expr.length,s=()=>t.quasis.push({type:"TemplateElement",value:{raw:o,cooked:r},tail:a});for(;this.index<i;){let i=this.expr.charAt(++this.index);if("`"===i)return this.index+=1,a=!0,s(),e.node=t,n&&(e.node=this.gobbleTokenProperty(e.node)),e.node;if("$"===i&&"{"===this.expr.charAt(this.index+1))this.index+=2,s(),o="",r="",t.expressions.push(...this.gobbleExpressions(125)),125!==this.code&&this.throwError("unclosed ${");else if("\\"===i)switch(o+=i,i=this.expr.charAt(++this.index),o+=i,i){case"n":r+="\n";break;case"r":r+="\r";break;case"t":r+=" ";break;case"b":r+="\b";break;case"f":r+="\f";break;case"v":r+="\v";break;default:r+=i}else r+=i,o+=i}this.throwError("Unclosed `")}}e.hooks.add("gobble-token",t),e.hooks.add("after-token",function(n){if((n.node.type===e.IDENTIFIER||n.node.type===e.MEMBER_EXP)&&96===this.code)return n.node={type:"TaggedTemplateExpression",tag:n.node,quasi:t.bind(this)(n,!1)},n.node=this.gobbleTokenProperty(n.node),n.node})}}),uJ.addBinaryOp("in",7),uJ.addBinaryOp("??",1);let df=H("feature-flags",{flags:function(){let e={};for(let t of Object.keys(localStorage))if(t.startsWith("openmrs:feature-flag:")){let n=t.replace("openmrs:feature-flag:",""),r=JSON.parse(localStorage.getItem(`openmrs:feature-flag-meta:${n}`)||"{}");e[n]={enabled:"true"===localStorage.getItem(t),...r}}return e}()});function dh(e,t,n){df.setState(r=>({flags:{...r.flags,[e]:{enabled:r.flags[e]?.enabled??!1,label:t,description:n}}}))}function dm(){let e=df.getState().flags;Object.keys(localStorage).filter(e=>e.startsWith("openmrs:feature-flag:")).forEach(t=>{let n=t.replace("openmrs:feature-flag:","");e[n]||(localStorage.removeItem(t),localStorage.removeItem(`openmrs:feature-flag-meta:${n}`))})}function d_(e){return df.getState().flags[e].enabled}function dy(e,t){df.subscribe(n=>{t(n.flags[e].enabled)})}function dg(e,t){df.setState(n=>({flags:{...n.flags,[e]:{...n.flags[e],enabled:t}}}))}function db(e){return!window.offlineEnabled||(e??navigator.onLine)}df.subscribe(e=>{for(let[t,n]of Object.entries(e.flags))localStorage.setItem(`openmrs:feature-flag:${t}`,n.enabled.toString()),localStorage.setItem(`openmrs:feature-flag-meta:${t}`,JSON.stringify({label:n.label,description:n.description}))});var dv=t8(function(e,t,n){tQ(e,t,n)});function dA(e=!0,t=!1){return d$(db(),e,t)}function d$(e,t=!0,n=!1){return!!(e?t:n)}let dk=U("extensionsInternal",{slots:{},extensions:{}}),dw=()=>H("extensionsInternal",{slots:{},extensions:{}});function dx(e){let t=dk.getState(),n=e(t);n!==t&&dk.setState(n)}let dC=()=>H("extensions",{slots:{}});function dE(e){let t=[];for(let n of Object.values(e.extensions))for(let e of n.instances)t.push({slotModuleName:e.slotModuleName,extensionModuleName:n.moduleName,slotName:e.slotName,extensionId:e.id});nG(rO.getState().mountedExtensions,t)||rO.setState({mountedExtensions:t})}dE(dk.getState()),dk.subscribe(dE);let dS=dw(),dD=dC(),dM=rT(),dz=rN();function dO(e,t,n,r,o){let a={},i=db(),s=Object.entries(r.flags).filter(([,{enabled:e}])=>e).map(([e])=>e);for(let[r,l]of Object.entries(e.slots)){let{config:c}=rI(t,l.name),p=dG(r,e,c,n,s,i,o.session);a[r]={moduleName:l.moduleName,assignedExtensions:p}}nG(dD.getState().slots,a)||dD.setState({slots:a})}function dP(){dO(dS.getState(),dM.getState(),dz.getState(),df.getState(),it.getState())}function dT(e,t,n){return{moduleName:t,name:e,attachedIds:[],config:null,state:n}}function dB(e){let[t]=e.split("#");return t}function dI(e,t){let n=dB(t);return e.extensions[n]}function dN(e){return dI(dS.getState(),e)}dS.subscribe(e=>{dO(e,dM.getState(),dz.getState(),df.getState(),it.getState())}),dM.subscribe(e=>{dO(dS.getState(),e,dz.getState(),df.getState(),it.getState())}),dz.subscribe(e=>{dO(dS.getState(),dM.getState(),e,df.getState(),it.getState())}),df.subscribe(e=>{dO(dS.getState(),dM.getState(),dz.getState(),e,it.getState())}),it.subscribe(e=>{dO(dS.getState(),dM.getState(),dz.getState(),df.getState(),e)}),dP(),g(dP);let dj=e=>dS.setState(t=>(t.extensions[e.name]={...e,instances:[]},t));function dR(e,t){dx(n=>{let r=n.slots[e];return r?{...n,slots:{...n.slots,[e]:{...r,attachedIds:[...r.attachedIds,t]}}}:{...n,slots:{...n.slots,[e]:{...dT(e),attachedIds:[t]}}}})}function dF(e,t){dx(n=>{let r=n.slots[e];return r&&r.attachedIds.includes(t)?{...n,slots:{...n.slots,[e]:{...r,attachedIds:r.attachedIds.filter(e=>e!==t)}}}:n})}function dL(e){dx(t=>{let n=t.slots[e];return n?{...t,slots:{...t.slots,[e]:{...n,attachedIds:[]}}}:t})}function dW(e,t,n,r){let o=t.indexOf(e);if(-1!==o)return o;{if(void 0!==n)return 1e3+n;let t=r.indexOf(e);return -1!==t?2e3+t:-1}}function dG(e,t,n,r,o,a,i){let s=function(e,t){let n=e.add||[],r=e.remove||[],o=e.order||[],{extensions:a}=dS.getState();return[...t,...n].filter(e=>!r.includes(e)).sort((e,n)=>{let r=dW(e,o,a[dB(e)]?.order,t),i=dW(n,o,a[dB(n)]?.order,t);return -1===i?-1:-1===r?1:r-i})}(n,t.slots[e].attachedIds),l=[],c=t.slots[e]?.state,p=c&&"object"==typeof c?{session:i,...c}:{session:i};for(let c of s){let{config:s}=rR(r,e,c),u=dv(s,rF(n,e,c)),d=dB(c),f=t.extensions[d];if(f){let t=u?.["Display conditions"]?.privileges??f.privileges??[];if(t&&("string"==typeof t||Array.isArray(t)&&t.length>0)&&(!i?.user||!ic(t,i.user)))continue;let n=u?.["Display conditions"]?.expression||f.displayExpression;if(void 0!==n&&"string"==typeof n&&n.trim().length>0)try{if(!u3(n,p))continue}catch(t){console.error(`Error while evaluating expression '${n}' for extension ${d} in slot ${e}`,t);continue}if(f.featureFlag&&!o.includes(f.featureFlag)||window.offlineEnabled&&!d$(a,f.online,f.offline))continue;l.push({id:c,name:d,moduleName:f.moduleName,config:u,featureFlag:f.featureFlag,meta:f.meta,online:u?.["Display conditions"]?.online??f.online??!0,offline:u?.["Display conditions"]?.offline??f.offline??!1})}}return l}function dV(e){let t=dS.getState(),{config:n}=rB(e),r=dz.getState(),o=df.getState(),a=it.getState(),i=db();return dG(e,t,n,r,Object.entries(o.flags).filter(([,{enabled:e}])=>e).map(([e])=>e),i,a.session)}let dU=(e,t,n)=>dS.setState(r=>{let o=r.slots[t]?.moduleName;if(o&&o!=e)return console.warn(`An extension slot with the name '${t}' already exists. Refusing to register the same slot name twice (in "registerExtensionSlot"). The existing one is from module ${o}.`),r;if(o&&o==e)return r;if(r.slots[t])return{...r,slots:{...r.slots,[t]:{...r.slots[t],moduleName:e,state:n}}};let a=dT(t,e,n);return{...r,slots:{...r.slots,[t]:{...a}}}});function dq(e,t,n=!1){dS.setState(r=>{let o=n?dv(r.slots[e].state,t):t;return{...r,slots:{...r.slots,[e]:{...r.slots[e],state:o}}}})}let dH=()=>dD.setState(()=>({slots:{},extensions:{}})),dK=U("left-nav",{slotName:null,basePath:window.spaBase,mode:"normal"});function dY({name:e,basePath:t,mode:n,componentContext:r,state:o}){dK.setState({slotName:e,basePath:t,mode:n??"normal",componentContext:r,state:o})}function dJ(e){dK.getState().slotName===e&&dK.setState(dK.getInitialState(),!0)}let dZ=U("modalRegistry",{modals:{}});function dX(e){dZ.setState(t=>(t.modals[e.name]=e,t))}function dQ(e){let t=dZ.getState().modals[e];if(!t){let n=dN(e);n&&(t={name:e,load:n.load,moduleName:n.moduleName},console.warn(`Modal ${e} was registered as an extension. This is deprecated and will be removed in the future. Please register it in the "modals" section of routes.json instead of the "extensions" section.`),dX(t))}return t}let d0=U("workspaceRegistrations",{workspaces:{}}),d1=U("workspaceGroups",{workspaceGroups:{}});function d2(e){d0.setState(t=>({workspaces:{...t.workspaces,[e.name]:{...e,load:e.load,preferredWindowSize:e.preferredWindowSize??"normal",type:e.type??"form",canHide:e.canHide??!1,canMaximize:e.canMaximize??!1,width:e.width??"narrow",groups:e.groups??[]}}}))}function d3(e){d1.setState(t=>{let n=t.workspaceGroups[e.name];return n?{workspaceGroups:{...t.workspaceGroups,[e.name]:{...n,members:Array.from(new Set([...n.members,...e.members]))}}}:{workspaceGroups:{...t.workspaceGroups,[e.name]:{name:e.name,members:e.members}}}})}let d5=new Set;function d4(e){let t=d0.getState().workspaces;if(t[e])return t[e];{let t=dN(e);if(t){var n;let r;return d5.has(e)||(console.warn(`The workspace '${e}' is registered as an extension. This is deprecated. Please register it in the "workspaces" section of the routes.json file.`),d5.add(e)),{name:t.name,title:(n=t,"string"==typeof(r=n?.meta?.title)?r:r&&"object"==typeof r?i$(n.moduleName,r.key,r.default):n.name),moduleName:t.moduleName,preferredWindowSize:t.meta?.screenSize??"normal",load:t.load,type:t.meta?.type??"form",canHide:t.meta?.canHide??!1,canMaximize:t.meta?.canMaximize??!1,width:t.meta?.width??"narrow",groups:t.meta?.groups??[]}}throw Error(`No workspace named '${e}' has been registered.`)}}function d6(e){let t=d1.getState().workspaceGroups;if(t[e])return t[e];throw Error(`No workspace group named '${e}' has been registered.`)}let d8=U("workspace2",{registeredGroupsByName:{},registeredWindowsByName:{},registeredWorkspacesByName:{},openedGroup:null,openedWindows:[],workspaceTitleByWorkspaceName:{},isMostRecentlyOpenedWindowHidden:!1});function d7(e){let{registeredWorkspacesByName:t,registeredWindowsByName:n}=d8.getState(),r=t[e];if(r){let t=n[r.window];if(t)return t;throw Error(`No workspace window found with name: ${r.window} for workspace: ${e}`)}throw Error(`No workspace found with name: ${e}`)}function d9(e){let{registeredGroupsByName:t,registeredWindowsByName:n}=d8.getState(),r=n[e];if(r){let n=t[r.group];if(n)return n;throw Error(`No workspace group found with name: ${r.group} for window: ${e}`)}throw Error(`No workspace window found with name: ${e}`)}function fe(e){let{openedWindows:t}=d8.getState();return t.findIndex(t=>t.openedWorkspaces.find(t=>t.workspaceName===e))}function ft(e,t){if(0==t.length)return;let{registeredGroupsByName:n}=d8.getState(),r={...n};for(let n of t){if(r[n.name])throw Error(`Cannot register workspace group ${n.name} more than once`);r[n.name]={...n,moduleName:e}}d8.setState({registeredGroupsByName:r})}function fn(e,t){if(0==t.length)return;let{registeredWindowsByName:n}=d8.getState(),r={...n};for(let n of t){if(r[n.name])throw Error(`Cannot register workspace window ${n.name} more than once`);let t={...n,moduleName:e};r[n.name]=t}d8.setState({registeredWindowsByName:r})}function fr(e,t){if(0==t.length)return;let{registeredWorkspacesByName:n}=d8.getState(),r={...n};for(let n of t){if(r[n.name])throw Error(`Cannot register workspace ${n.name} more than once`);let t={...n,moduleName:e};r[n.name]=t}d8.setState({registeredWorkspacesByName:r})}let fo=0;async function fa(e,t,n,r,o=e=>e,a={}){let i=dB(r),s=dN(r),l=null;if(e){if(!s)throw Error(`Couldn't find extension '${i}' to attach to '${t}'`);let{meta:c,moduleName:p,online:u,offline:d,load:f}=s;if(dA(u,d)){dx(o=>({...o,extensions:{...o.extensions,[i]:{...o.extensions[i],instances:[...o.extensions[i].instances,{domElement:e,id:r,slotName:t,slotModuleName:n}]}}}));let s=await f(),u=fo++;l=o6(o({...s,name:`${t}/${i}-${u}`}),{...a,_meta:c,_extensionContext:{extensionId:r,extensionSlotName:t,extensionSlotModuleName:n,extensionModuleName:p},domElement:e})}}else console.warn(`Tried to render ${r} into ${t} but no DOM element was available.`);return l}var fi=n(2153),fs=n.n(fi);let fl=(0,fi.createContext)({moduleName:"",featureName:""});function fc({to:e,templateParams:t,onBeforeNavigate:n,children:r,...o}){return(0,fi.useEffect)(()=>{o.href&&console.warn(`ConfigurableLink does not support the href prop. Use the 'to' prop instead. The provided href value is '${o.href}'`),o.onClick&&console.warn(`ConfigurableLink does not support the onClick prop. Use the 'onBeforeNavigate' prop instead. The 'to' prop of the offending link is ${e}`)},[]),fs().createElement("a",{onClick:r=>{0===r.button&&!r.ctrlKey&&!r.shiftKey&&!r.altKey&&!r.metaKey&&(r.preventDefault(),n?.(r),aK({to:e,templateParams:t})),0===r.button&&(r.ctrlKey||r.metaKey)&&n?.(r),0===r.button&&r.shiftKey&&n?.(r),1===r.button&&n?.(r)},href:aq(e,t),...o},r)}let fp=({state:e,children:t,...n})=>{let{extension:r}=(0,fi.useContext)(fl),o=(0,fi.useRef)(null),a=(0,fi.useRef)(Promise.resolve()),i=(0,fi.useCallback)(t=>{r?.extensionSlotName&&r.extensionSlotModuleName&&r.extensionSlotModuleName&&!o.current&&fa(t,r.extensionSlotName,r.extensionSlotModuleName,r.extensionId,void 0,e).then(e=>{o.current=e})},[]);return(0,fi.useEffect)(()=>()=>{if(o&&o.current)switch(o.current.getStatus()){case"MOUNTING":o.current.mountPromise.then(()=>{o.current?.getStatus()==="MOUNTED"&&o.current.unmount()});break;case"MOUNTED":o.current.unmount();break;case"UPDATING":a.current&&a.current.then(()=>{o.current?.getStatus()==="MOUNTED"&&o.current.unmount()})}},[]),(0,fi.useEffect)(()=>{o.current&&o.current.update&&"UNMOUNTING"!==o.current.getStatus()&&Promise.all([o.current.mountPromise,a.current]).then(()=>{o?.current?.getStatus()==="MOUNTED"&&o.current.update&&(a.current=o.current.update({...e}).catch(e=>{if(!(e instanceof Error)||!e.message.includes("minified message #32")||o.current?.getStatus()==="MOUNTED")throw e}))})},[e]),r?fs().createElement("div",{ref:i,"data-extension-id":r?.extensionId,style:{position:"relative"},...n}):null};function fu(e,t){"function"==typeof t&&(t=t(e));let n={};for(let[r,o]of Object.entries(t)){let t=function(...t){e.setState(e=>o(e,...t))};n[r]=t}return n}let fd=()=>e=>e;function ff(e,t=fd(),n){let r=(0,fi.useCallback)(t=>e.subscribe(t),[e]),o=(0,fi.useCallback)(()=>t(e.getState()),[e,t]),a=(0,fi.useSyncExternalStore)(r,o,o),i=(0,fi.useMemo)(()=>n?fu(e,n):{},[e,n]);return{...a,...i}}function fh(e,t){return ff(e,fd(),t)}function fm(e){return function(t){let n=(0,fi.useCallback)(t=>e.subscribe(t),[]),r=(0,fi.useCallback)(()=>e.getState(),[]),o=(0,fi.useSyncExternalStore)(n,r,r),a=(0,fi.useMemo)(()=>t?fu(e,t):{},[t]);return{...o,...a}}}let f_=e=>ff(dC(),t=>t.slots?.[e]);function fy(e){let t=f_(e);return t?.assignedExtensions??[]}function fg(e,t){let{moduleName:n}=(0,fi.useContext)(fl),r=(0,fi.useRef)(!0);if(!n)throw Error("ComponentContext has not been provided. This should come from @openmrs/esm-react-utils.");return(0,fi.useEffect)(()=>{dU(n,e,t),r.current=!1},[]),(0,fi.useEffect)(()=>{r.current||dq(e,t)},[e,t]),{extensions:fy(e),extensionSlotName:e,extensionSlotModuleName:n}}function fb(e){return e}function fv({name:e,extensionSlotName:t,select:n=fb,children:r,state:o,style:a,...i}){if(r&&o)throw Error("Both children and state have been provided. If children are provided, the state must be passed as a prop to the `Extension` component.");let s=e??t,l=(0,fi.useRef)(null),{extensions:c,extensionSlotModuleName:p}=fg(s,o),u=(0,fi.useMemo)(()=>n(c),[n,c]),d=(0,fi.useMemo)(()=>{if("function"==typeof r&&!fs().isValidElement(r))return u.map(e=>r(e,o))},[r,u]);return fs().createElement("div",{ref:l,"data-extension-slot-name":s,"data-extension-slot-module-name":p,style:{...a,position:"relative"},...i},s&&u?.map((e,t)=>fs().createElement(fl.Provider,{key:e.id,value:{moduleName:p,featureName:"",extension:{extensionId:e.id,extensionSlotName:s,extensionSlotModuleName:p}}},d?.[t]??("function"!=typeof r?r:null)??fs().createElement(fp,{state:o}))))}var fA=n(5338);function f$(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function fk(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?f$(Object(n),!0).forEach(function(t){var r,o,a;r=e,o=t,a=n[t],o in r?Object.defineProperty(r,o,{value:a,enumerable:!0,configurable:!0,writable:!0}):r[o]=a}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):f$(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function fw(e){return(fw="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 fx(e){return(fx="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 fC(e,t){var n;if("function"!=typeof(n=t.domElement?function(){return t.domElement}:t.domElementGetter?t.domElementGetter:e.domElementGetter?e.domElementGetter:function(e){var t=e.appName||e.name;if(!t)throw Error("single-spa's dom-element-getter-helpers was not given an application name as a prop, so it can't make a unique dom element container for the react application");var n="single-spa-application:".concat(t);return function(){var e=document.getElementById(n);return e||((e=document.createElement("div")).id=n,document.body.appendChild(e)),e}}(t)))throw Error("single-spa's dom-element-getter-helpers was given an invalid domElementGetter for application or parcel '".concat(t.name,"'. Expected a function, received ").concat(fx(n)));return function(){var e=n(t);if(!(e instanceof HTMLElement))throw Error("single-spa's dom-element-getter-helpers: domElementGetter returned an invalid dom element for application or parcel '".concat(t.name,"'. Expected HTMLElement, received ").concat(fx(e)));return e}}var fE=null;try{fE=require("react").createContext()}catch(e){}var fS={React:null,ReactDOM:null,ReactDOMClient:null,rootComponent:null,loadRootComponent:null,errorBoundary:null,errorBoundaryClass:null,domElementGetter:null,parcelCanUpdate:!0,suppressComponentDidCatchWarning:!1,domElements:{},renderResults:{},updateResolves:{},unmountResolves:{}};function fD(e,t){return e.rootComponent?Promise.resolve():e.loadRootComponent(t).then(function(t){e.rootComponent=t})}function fM(e,t){return new Promise(function(n,r){e.suppressComponentDidCatchWarning||!function(e){if(!(e&&"string"==typeof e.version&&e.version.indexOf(".")>=0))return!1;var t=e.version.slice(0,e.version.indexOf("."));try{return Number(t)>=16}catch(e){return!1}}(e.React)||e.errorBoundary||e.errorBoundaryClass||(e.rootComponent.prototype?e.rootComponent.prototype.componentDidCatch||console.warn("single-spa-react: ".concat(t.name||t.appName||t.childAppName,"'s rootComponent should implement componentDidCatch to avoid accidentally unmounting the entire single-spa application.")):console.warn("single-spa-react: ".concat(t.name||t.appName||t.childAppName,"'s rootComponent does not implement an error boundary. If using a functional component, consider providing an opts.errorBoundary to singleSpaReact(opts).")));var o,a=fT(e,t,function(){n(this)}),i=fC(e,t)(),s=function(e){var t=e.reactDom,n=e.renderType,r=e.elementToRender,o=e.domElement,a=t[n];if("function"!=typeof a)throw Error('renderType "'.concat(n,'" did not return a function.'));switch(n){case"createRoot":case"unstable_createRoot":case"createBlockingRoot":case"unstable_createBlockingRoot":var i=a(o);return i.render(r),i;case"hydrateRoot":return a(o,r);default:return a(r,o),null}}({elementToRender:a,domElement:i,reactDom:fP(e),renderType:"function"==typeof(o=e).renderType?o.renderType():o.renderType});e.domElements[t.name]=i,e.renderResults[t.name]=s})}function fz(e,t){return new Promise(function(n){e.unmountResolves[t.name]=n;var r=e.renderResults[t.name];r&&r.unmount?r.unmount():fP(e).unmountComponentAtNode(e.domElements[t.name]),delete e.domElements[t.name],delete e.renderResults[t.name]})}function fO(e,t){return new Promise(function(n){e.updateResolves[t.name]||(e.updateResolves[t.name]=[]),e.updateResolves[t.name].push(n);var r=fT(e,t,null),o=e.renderResults[t.name];if(o&&o.render)o.render(r);else{var a=fC(e,t)();fP(e).render(r,a)}})}function fP(e){return e.ReactDOMClient||e.ReactDOM}function fT(e,t,n){var r=e.React.createElement(e.rootComponent,t),o=fE?e.React.createElement(fE.Provider,{value:t},r):r;return(e.errorBoundary||t.errorBoundary||e.errorBoundaryClass||t.errorBoundaryClass)&&(e.errorBoundaryClass=e.errorBoundaryClass||t.errorBoundaryClass||function(e,t){function n(t){e.React.Component.apply(this,arguments),this.state={caughtError:null,caughtErrorInfo:null},n.displayName="SingleSpaReactErrorBoundary(".concat(t.name,")")}return n.prototype=Object.create(e.React.Component.prototype),n.prototype.render=function(){return this.state.caughtError?(e.errorBoundary||t.errorBoundary)(this.state.caughtError,this.state.caughtErrorInfo,this.props):this.props.children},n.prototype.componentDidCatch=function(e,t){this.setState({caughtError:e,caughtErrorInfo:t})},n}(e,t),o=e.React.createElement(e.errorBoundaryClass,t,o)),o=e.React.createElement(e.SingleSpaRoot,fk(fk({},t),{},{mountFinished:n,updateFinished:function(){e.updateResolves[t.name]&&(e.updateResolves[t.name].forEach(function(e){return e()}),delete e.updateResolves[t.name])},unmountFinished:function(){e.unmountResolves[t.name]&&(e.unmountResolves[t.name](),delete e.unmountResolves[t.name])}}),o)}var fB=n(6045),fI=n(9324),fN=n(4993);let fj={strictMode:!0,throwErrorsToConsole:!0,disableTranslations:!1},fR=new Map;(0,fN.r2)(fR);let fF={errorRetryCount:3,fetcher:a7,focusThrottleInterval:18e5,revalidateIfStale:!0,revalidateOnFocus:!1,revalidateOnReconnect:!1,refreshInterval:0,shouldRetryOnError:e=>{if(e instanceof ie){let t=e.response.status;return!!(t>=500)||401===t||403===t||429===t}return!0},provider:()=>fR};function fL(e){if("object"!=typeof e||"string"!=typeof e.featureName||"string"!=typeof e.moduleName)throw Error("Invalid options");let t=Object.assign({},fj,e),n={...fF,...t.swrConfig};return function(e){var r,o,a,i,s;return a=o=class extends(r=fs().Component){componentDidCatch(e,n){n&&n.componentStack&&(e.extra=Object.assign(e.extra||{},{componentStack:n.componentStack})),t.throwErrorsToConsole&&setTimeout(()=>{throw e}),this.setState({caughtError:e,caughtErrorInfo:n})}render(){if(this.state.caughtError)return fs().createElement("div",null,"An error has occurred. Please try reloading the page.");{let r=fs().createElement(fi.Suspense,{fallback:null},fs().createElement(fI.BE,{value:n},fs().createElement(fl.Provider,{value:this.state.config},t.disableTranslations?fs().createElement(e,this.props):fs().createElement(fB.I18nextProvider,{i18n:window.i18next,defaultNS:this.state.config.extension?`${this.state.config.moduleName}___${this.state.config.extension.extensionSlotName}___${this.state.config.extension.extensionId}`:this.state.config.moduleName},fs().createElement(e,this.props)))));return t.strictMode&&fs().StrictMode?fs().createElement(fs().StrictMode,null,r):r}}constructor(e){super(e),this.state={caughtError:null,caughtErrorInfo:null,config:{moduleName:t.moduleName,featureName:t.featureName,extension:e._extensionContext}}}},i="displayName",s=`OpenmrsReactComponent(${t.featureName})`,i in a?Object.defineProperty(a,i,{value:s,enumerable:!0,configurable:!0,writable:!0}):a[i]=s,o}}function fW(e,t){return function(e){if("object"!==fw(e))throw Error("single-spa-react requires a configuration object");var t,n=fk(fk({},fS),e);if(!n.React)throw Error("single-spa-react must be passed opts.React");if(!n.ReactDOM&&!n.ReactDOMClient)throw Error("single-spa-react must be passed opts.ReactDOM or opts.ReactDOMClient");if(n.renderType||(null!=(t=n.ReactDOMClient)&&t.createRoot?n.renderType="createRoot":n.renderType="render"),!n.rootComponent&&!n.loadRootComponent)throw Error("single-spa-react must be passed opts.rootComponent or opts.loadRootComponent");if(n.errorBoundary&&"function"!=typeof n.errorBoundary)throw Error("The errorBoundary opt for single-spa-react must either be omitted or be a function that returns React elements");!fE&&n.React.createContext&&(fE=n.React.createContext()),n.SingleSpaRoot=function(e){function t(e){t.displayName="SingleSpaRoot(".concat(e.name,")")}return t.prototype=Object.create(e.React.Component.prototype),t.prototype.componentDidMount=function(){setTimeout(this.props.mountFinished)},t.prototype.componentWillUnmount=function(){setTimeout(this.props.unmountFinished)},t.prototype.render=function(){return setTimeout(this.props.updateFinished),this.props.children},t}(n);var r={bootstrap:fD.bind(null,n),mount:fM.bind(null,n),unmount:fz.bind(null,n)};return n.parcelCanUpdate&&(r.update=fO.bind(null,n)),r}({React:fs(),ReactDOMClient:fA,rootComponent:fL(t)(e)})}function fG(e,t){return()=>e().then(({default:e})=>fW(e,t))}function fV(e,t){return()=>Promise.resolve(fW(e,t))}let fU=fG,fq=W()(()=>({}));q("openmrs-app-context",fq);let fH={};function fK(e,t=e=>e){let n=fq.getState();return e in n?Object.freeze(Object.assign({},t?t(n[e]):n[e])):null}function fY(e,t){fq.setState(n=>(e in n||(n[e]={}),n[e]=t(n[e]),Object.assign({},n)))}function fJ(e){return null===e?null:Object.freeze(Object.assign({},e))}let fZ=new Map;function fX(e,t){let n=(0,fi.useRef)(t??{}),r=(0,fi.useRef)(t=>fY(e,t)),o=(0,fi.useRef)(Symbol());return(0,fi.useEffect)(()=>{let n=t??{},r=o.current;return null===fK(e)?!function(e,t=fH){fq.setState(n=>{if(e in n)throw Error(`Attempted to re-register namespace ${e} in the app context. Each namespace must be unregistered before the name can be registered again.`);return Object.assign({},n,{[e]:t===fH?{}:t})})}(e,n):(console.warn(`Namespace ${e} is already registered in the app context. This is likely a race condition during navigation, but may indicate two components are trying to own the same namespace. Updating the existing context.`),fY(e,()=>n)),fZ.set(e,r),()=>{fZ.get(e)===r&&(fq.setState(t=>(e in t&&delete t[e],t)),fZ.delete(e))}},[e]),(0,fi.useEffect)(()=>{let r=t??{};j(n.current,r)||(fY(e,()=>r),n.current=r)},[t]),r.current}function fQ({namespace:e,value:t}){return fX(e,t),null}let f0=({children:e,value:t,fallback:n})=>t?fs().createElement(fs().Fragment,null,e):n?fs().createElement(fs().Fragment,null,n):null;function f1(){let e=(0,fi.useRef)();return(!e.current||e.current.signal.aborted)&&(e.current=new AbortController),(0,fi.useEffect)(()=>{let t=e.current;return()=>t?.abort()},[]),e.current}function f2(e,t=e=>e??{}){let[n,r]=(0,fi.useState)(()=>{if(f3(e))return;let n=fK(e);if(null!==n)return t?t(n):n});return(0,fi.useEffect)(()=>{if(f3(e))throw Error(`The namespace supplied to useAppContext must be a non-empty string, but was "${e}".`)},[e]),(0,fi.useEffect)(()=>{var n;let o;return(n=e=>{if(null==e)return void r(void 0);let n=t?t(e):e;r(e=>j(e,n)?e:n)})(fJ(o=fK(e))),fq.subscribe(t=>{let r=e in t?t[e]:null;r!==o&&(o=r,n(fJ(r)))})},[e,t]),n}function f3(e){return"string"!=typeof e||0===e.trim().length}function f5(e){let[t,n]=(0,fi.useState)([]);return(0,fi.useEffect)(()=>dC().subscribe(r=>{let o=r.slots[e]?.assignedExtensions.map(e=>e.id)??[];nG(o,t)||n(o)}),[]),t}function f4(e,t){let{data:n,error:r,mutate:o,isLoading:a,isValidating:i}=(0,fI.Ay)(`${sr}?patient=${e}&includeEncounterless=${t}`,a7);return(0,fi.useMemo)(()=>({isLoading:a,data:n?.data.results??[],error:r,mutate:o,isValidating:i}),[n,r,a,i,o])}function f6(e){(0,fi.useEffect)(()=>{if(e){let e=window.getComputedStyle(document.body).overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=e}}},[e])}let f8={},f7=`No ComponentContext has been provided. This should come from "openmrsComponentDecorator".
|