@openmrs/esm-reports-app 4.4.1-pre.673 → 4.4.1-pre.689

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/dist/3359.js CHANGED
@@ -12,7 +12,7 @@ If you're the maintainer: the 'elements' key only works with '_type' equal to 'A
12
12
  ${n}`)}return r}let tI=(e,n)=>{let t=structuredClone(n);if(!e)return t;for(let n of Object.keys(e)){let r=t[n],o=e[n];if(o&&(o.hasOwnProperty("_type")||o.hasOwnProperty("_default"))){t.hasOwnProperty(n)||(t[n]=o._default);let e=o._elements;if(r&&tB(e)){if(o._type===n4.Array&&Array.isArray(r)){let o=r.map(n=>tI(e,n));t[n]=o}else if(o._type===n4.Object)for(let n of Object.keys(r))r[n]=tI(e,r[n])}}else if(tj(o)){let e=r??{};tj(e)&&(t[n]=tI(o,e))}}return t};function tB(e){return!!e&&Object.keys(e).filter(e=>!["_default","_validators"].includes(e)).length>0}function tj(e){return"object"==typeof e&&!Array.isArray(e)&&null!==e}let tR=new Set;function tF(e,n){let t=`${e}:::${n}`;tR||(tR=new Set),tR.has(t)||(console.error(n),tR.add(t))}function tL(e){e?tR.forEach(n=>{n.startsWith(e)&&tR.delete(n)}):tR.clear()}function tW(){tg.forEach(e=>e()),tg.length=0,tb()}let tV={"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:n4.Object,_default:{},_validators:[n6(e=>Object.keys(e).every(e=>/^[a-z]{2,3}(-[A-Z]{2,3})?$/.test(e)),e=>{let n=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: ${n.join(", ")}.`})]}},tG={"Display conditions":{privileges:{_description:"The privilege(s) the user must have to use this extension",_type:n4.Array,_default:[]},expression:{_description:"The expression that determines whether the extension is displayed",_type:n4.String,_default:void 0}},...tV},tU=(e,n)=>n6(t=>e<=t&&t<=n,`must be between ${e} and ${n}`),tq=e=>{let n=e.concat(["openmrsBase","openmrsSpaBase"]);return n6(e=>{if(!e||"string"!=typeof e)return!1;let t=/\${(.*?)}/g,r=t.exec(e);for(;r;){if(!n.includes(r[1]))return!1;r=t.exec(e)}return!0},"Should be a URL or path. The allowed template parameters are "+n.map(e=>"${"+e+"}").join(", "))},tH=tq([]),tK=e=>n6(n=>e.includes(n),`Must be one of the following: '${e.join("', '")}'.`),tY={inRange:tU,isUrl:tH,isUrlWithTemplateParameters:tq,oneOf:tK};var tZ=t(2034);let tJ=G("breadcrumbs",[]);function tX(e){return tQ([e])}function tQ(e){let n=[...t0(),...e.map(e=>({matcher:e.matcher instanceof RegExp?e.matcher:"string"==typeof e.matcher?(0,tZ.pathToRegexp)(e.matcher).regexp:(0,tZ.pathToRegexp)(e.path).regexp,settings:e}))];tJ.setState(n,!0)}function t0(){return tJ.getState()}function t1(e,n){if(n)return function(e,n){let[t]=e.filter(e=>e.matcher.test(n));return t}(e,n)||function(e,n){let t=n.split("/");for(;t.length>1;){t.pop();let n=t1(e,t.join("/"));if(n)return n}}(e,n)}function t2(e,n){if(e.length>0){let t=t1(e,n);if(t){let n=[t],r=t1(e,t.settings.parent);for(;void 0!==r;)n.push(r),r=t1(e,r.settings.parent);return n.reverse()}}return[]}function t3(e){return t2(t0(),e)}var t5=Object.freeze({__proto__:null,get start(){return ob},get ensureJQuerySupport(){return r3},get setBootstrapMaxTime(){return rj},get setMountMaxTime(){return rR},get setUnmountMaxTime(){return rF},get setUnloadMaxTime(){return rL},get registerApplication(){return oo},get unregisterApplication(){return oi},get getMountedApps(){return oe},get getAppStatus(){return ot},get unloadApplication(){return os},get checkActivityFunctions(){return oa},get getAppNames(){return on},get pathToActiveWhen(){return op},get navigateToUrl(){return rK},get patchHistoryApi(){return r0},get triggerAppChange(){return oh},get addErrorHandler(){return t9},get removeErrorHandler(){return re},get mountRootParcel(){return rT},get NOT_LOADED(){return rr},get LOADING_SOURCE_CODE(){return ro},get NOT_BOOTSTRAPPED(){return ra},get BOOTSTRAPPING(){return ri},get NOT_MOUNTED(){return rs},get MOUNTING(){return rl},get UPDATING(){return rp},get LOAD_ERROR(){return rf},get MOUNTED(){return rc},get UNLOADING(){return rd},get UNMOUNTING(){return ru},get SKIP_BECAUSE_BROKEN(){return rh}}),t4=("u">typeof globalThis?globalThis:"u">typeof window?window:"u">typeof global?global:"u">typeof self?self:{}).CustomEvent,t6=!function(){try{var e=new t4("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,n){var t=document.createEvent("CustomEvent");return n?t.initCustomEvent(e,n.bubbles,n.cancelable,n.detail):t.initCustomEvent(e,!1,!1,void 0),t}:function(e,n){var t=document.createEventObject();return t.type=e,n?(t.bubbles=!!n.bubbles,t.cancelable=!!n.cancelable,t.detail=n.detail):(t.bubbles=!1,t.cancelable=!1,t.detail=void 0),t}:t4;let t7=[];function t8(e,n,t){let r=rt(e,n,t);t7.length?t7.forEach(e=>e(r)):setTimeout(()=>{throw r})}function t9(e){if("function"!=typeof e)throw Error(rn(28,!1));t7.push(e)}function re(e){if("function"!=typeof e)throw Error(rn(29,!1));let n=!1;return t7=t7.filter(t=>{let r=t===e;return n=n||r,!r}),n}function rn(e,n,...t){return`single-spa minified message #${e}: ${n?n+" ":""}See https://single-spa.js.org/error/?code=${e}${t.length?`&arg=${t.join("&arg=")}`:""}`}function rt(e,n,t){let r,o=`${r_(n)} '${ry(n)}' died in status ${n.status}: `;if(e instanceof Error){try{e.message=o+e.message}catch(e){}r=e}else{console.warn(rn(30,!1,n.status,ry(n)));try{r=Error(o+JSON.stringify(e))}catch(n){r=e}}return r.appOrParcelName=ry(n),n.status=t,r}let rr="NOT_LOADED",ro="LOADING_SOURCE_CODE",ra="NOT_BOOTSTRAPPED",ri="BOOTSTRAPPING",rs="NOT_MOUNTED",rl="MOUNTING",rc="MOUNTED",rp="UPDATING",ru="UNMOUNTING",rd="UNLOADING",rf="LOAD_ERROR",rh="SKIP_BECAUSE_BROKEN";function rm(e){return e.status===rc}function rg(e){try{return e.activeWhen(window.location)}catch(n){return t8(n,e,rh),!1}}function ry(e){return e.name}function rb(e){return!!e.unmountThisParcel}function r_(e){return rb(e)?"parcel":"application"}function rv(){for(let e=arguments.length-1;e>0;e--)for(let n in arguments[e])"__proto__"!==n&&(arguments[e-1][n]=arguments[e][n]);return arguments[0]}function r$(e,n){for(let t=0;t<e.length;t++)if(n(e[t]))return e[t];return null}function rA(e){return e&&("function"==typeof e||Array.isArray(e)&&!r$(e,e=>"function"!=typeof e))}function rw(e,n){let t=e[n]||[];0===(t=Array.isArray(t)?t:[t]).length&&(t=[()=>Promise.resolve()]);let r=r_(e),o=ry(e);return function(e){return t.reduce((t,a,i)=>t.then(()=>{let t=a(e);return rk(t)?t:Promise.reject(rn(15,!1,r,o,n,i))}),Promise.resolve())}}function rk(e){return e&&"function"==typeof e.then&&"function"==typeof e.catch}let rx=[];function rC(e,n){return Promise.resolve().then(()=>e.status!==ra?e:(e.status=ri,e.bootstrap?rW(e,"bootstrap").then(t).catch(t=>{if(n)throw rt(t,e,rh);return t8(t,e,rh),e}):Promise.resolve().then(t)));function t(){return e.status=rs,e}}function rE(e,n){return Promise.resolve().then(()=>{if(e.status!==rc)return e;return e.status=ru,Promise.all(Object.keys(e.parcels).map(n=>e.parcels[n].unmountThisParcel())).then(t,r=>t().then(()=>{let t=Error(r.message);if(n)throw rt(t,e,rh);t8(t,e,rh)})).then(()=>e);function t(){return rW(e,"unmount").then(()=>{e.status=rs},t=>{if(n)throw rt(t,e,rh);t8(t,e,rh)})}})}let rS=!1,rD=!1;function rz(e,n){return Promise.resolve().then(()=>e.status!==rs?e:(rS||(window.dispatchEvent(new t6("single-spa:before-first-mount")),rS=!0),e.status=rl,rW(e,"mount").then(()=>(e.status=rc,rD||(window.dispatchEvent(new t6("single-spa:first-mount")),rD=!0),e)).catch(t=>{return e.status=rc,rE(e,!0).then(r,r);function r(){if(n)throw rt(t,e,rh);return t8(t,e,rh),e}})))}let rM=0,rP={parcels:{}};function rT(){return rO.apply(rP,arguments)}function rO(e,n){let t,r,o,a=this;if(!e||"object"!=typeof e&&"function"!=typeof e)throw Error(rn(2,!1));if(e.name&&"string"!=typeof e.name)throw Error(rn(3,!1,typeof e.name));let i=rM++,s=e.name||`parcel-${i}`;if("object"!=typeof n)throw Error(rn(4,!1,s,typeof n));if(!n.domElement)throw Error(rn(5,!1,s));let l="function"==typeof e,c=l?e:()=>Promise.resolve(e),p={id:i,parcels:{},status:l?ro:ra,customProps:n,parentName:ry(a),unmountThisParcel:()=>f.then(()=>{if(p.status!==rc)throw Error(rn(6,!1,s,p.status));return rE(p,!0)}).then(e=>(p.parentName&&delete a.parcels[p.id],e)).then(e=>(r(e),e)).catch(e=>{throw p.status=rh,o(e),e})};a.parcels[i]=p;let u=c();if(!u||"function"!=typeof u.then)throw Error(rn(7,!1));let d=(u=u.then(e=>{if(!e)throw Error(rn(8,!1));if(s=e.name||`parcel-${i}`,Object.prototype.hasOwnProperty.call(e,"bootstrap")&&!rA(e.bootstrap))throw Error(rn(9,!1,s));if(!rA(e.mount))throw Error(rn(10,!1,s));if(!rA(e.unmount))throw Error(rn(11,!1,s));if(e.update&&!rA(e.update))throw Error(rn(12,!1,s));let n=rw(e,"bootstrap"),r=rw(e,"mount"),o=rw(e,"unmount");p.status=ra,p.name=s,p.bootstrap=n,p.mount=r,p.unmount=o,p.timeouts=rV(e.timeouts),e.update&&(p.update=rw(e,"update"),t.update=function(e){return p.customProps=e,rN(Promise.resolve().then(()=>{if(p.status!==rc)throw Error(rn(32,!1,ry(p)));return p.status=rp,rW(p,"update").then(()=>(p.status=rc,p)).catch(e=>{throw rt(e,p,rh)})}))})})).then(()=>rC(p,!0)),f=d.then(()=>rz(p,!0)),h=new Promise((e,n)=>{r=e,o=n});return t={mount:()=>rN(Promise.resolve().then(()=>{if(p.status!==rs)throw Error(rn(13,!1,s,p.status));return a.parcels[i]=p,rz(p)})),unmount:()=>rN(p.unmountThisParcel()),getStatus:()=>p.status,loadPromise:rN(u),bootstrapPromise:rN(d),mountPromise:rN(f),unmountPromise:rN(h)}}function rN(e){return e.then(()=>null)}function rI(e){let n=ry(e),t="function"==typeof e.customProps?e.customProps(n,window.location):e.customProps;("object"!=typeof t||null===t||Array.isArray(t))&&(t={},console.warn(rn(40,!1),n,t));let r=rv({},t,{name:n,mountParcel:rO.bind(e),singleSpa:t5});return rb(e)&&(r.unmountSelf=e.unmountThisParcel),r}let rB={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 rj(e,n,t){if("number"!=typeof e||e<=0)throw Error(rn(16,!1));rB.bootstrap={millis:e,dieOnTimeout:n,warningMillis:t||1e3}}function rR(e,n,t){if("number"!=typeof e||e<=0)throw Error(rn(17,!1));rB.mount={millis:e,dieOnTimeout:n,warningMillis:t||1e3}}function rF(e,n,t){if("number"!=typeof e||e<=0)throw Error(rn(18,!1));rB.unmount={millis:e,dieOnTimeout:n,warningMillis:t||1e3}}function rL(e,n,t){if("number"!=typeof e||e<=0)throw Error(rn(19,!1));rB.unload={millis:e,dieOnTimeout:n,warningMillis:t||1e3}}function rW(e,n){let t=e.timeouts[n],r=t.warningMillis,o=r_(e);return new Promise((a,i)=>{let s=!1,l=!1;e[n](rI(e)).then(e=>{s=!0,a(e)}).catch(e=>{s=!0,i(e)}),setTimeout(()=>p(1),r),setTimeout(()=>p(!0),t.millis);let c=rn(31,!1,n,o,ry(e),t.millis);function p(e){s||(!0===e?(l=!0,t.dieOnTimeout?i(Error(c)):console.error(c)):!l&&(console.warn(c),e*r+r<t.millis&&setTimeout(()=>p(e+1),r)))}})}function rV(e){let n={};for(let t in rB)n[t]=rv({},rB[t],e&&e[t]||{});return n}function rG(e){return Promise.resolve().then(()=>{let n,t;return e.loadPromise?e.loadPromise:e.status!==rr&&e.status!==rf?e:(e.status=ro,e.loadPromise=Promise.resolve().then(()=>{let r=e.loadApp(rI(e));if(!rk(r))throw t=!0,Error(rn(33,!1,ry(e)));return r.then(t=>{let r;e.loadErrorTime=null,"object"!=typeof(n=t)&&(r=34),Object.prototype.hasOwnProperty.call(n,"bootstrap")&&!rA(n.bootstrap)&&(r=35),rA(n.mount)||(r=36),rA(n.unmount)||(r=37);let o=r_(n);if(r){let t;try{t=JSON.stringify(n)}catch(e){}return console.error(rn(r,!1,o,ry(e),t),n),t8(void 0,e,rh),e}return n.devtools&&n.devtools.overlays&&(e.devtools.overlays=rv({},e.devtools.overlays,n.devtools.overlays)),e.status=ra,e.bootstrap=rw(n,"bootstrap"),e.mount=rw(n,"mount"),e.unmount=rw(n,"unmount"),e.unload=rw(n,"unload"),e.timeouts=rV(n.timeouts),delete e.loadPromise,e})}).catch(n=>{let r;return delete e.loadPromise,t?r=rh:(r=rf,e.loadErrorTime=(new Date).getTime()),t8(n,e,r),e}))})}let rU="u">typeof window,rq={hashchange:[],popstate:[]},rH=["hashchange","popstate"];function rK(e){let n;if("string"==typeof e)n=e;else if(this&&this.href)n=this.href;else{if(!(e&&e.currentTarget&&e.currentTarget.href&&e.preventDefault))throw Error(rn(14,!1));n=e.currentTarget.href,e.preventDefault()}let t=r1(window.location.href),r=r1(n);0===n.indexOf("#")?window.location.hash=r.hash:t.host!==r.host&&r.host?window.location.href=n:r.pathname===t.pathname&&r.search===t.search?window.location.hash=r.hash:window.history.pushState(null,null,n)}function rY(e){if(e){let n=e[0].type;rH.indexOf(n)>=0&&rq[n].forEach(n=>{try{n.apply(this,e)}catch(e){setTimeout(()=>{throw e})}})}}function rZ(){om([],arguments)}function rJ(e,n){return function(){let t=window.location.href,o=e.apply(this,arguments),a=window.location.href;return r&&t===a||window.dispatchEvent(function(e,n){let t;try{t=new PopStateEvent("popstate",{state:e})}catch(n){(t=document.createEvent("PopStateEvent")).initPopStateEvent("popstate",!1,!1,e)}return t.singleSpa=!0,t.singleSpaTrigger=n,t}(window.history.state,n)),o}}let rX=null,rQ=!1;function r0(e){if(rQ)throw Error(rn(43,!1));r=!e||!e.hasOwnProperty("urlRerouteOnly")||e.urlRerouteOnly,rQ=!0,rX=window.history.replaceState,window.addEventListener("hashchange",rZ),window.addEventListener("popstate",rZ);let n=window.addEventListener,t=window.removeEventListener;window.addEventListener=function(e,t){if(!("function"==typeof t&&rH.indexOf(e)>=0)||r$(rq[e],e=>e===t))return n.apply(this,arguments);rq[e].push(t)},window.removeEventListener=function(e,n){return"function"==typeof n&&rH.indexOf(e)>=0&&(rq[e]=rq[e].filter(e=>e!==n)),t.apply(this,arguments)},window.history.pushState=rJ(window.history.pushState,"pushState"),window.history.replaceState=rJ(rX,"replaceState")}function r1(e){let n=document.createElement("a");return n.href=e,n}rU&&(window.singleSpaNavigate?console.warn(rn(41,!1)):window.singleSpaNavigate=rK);let r2=!1;function r3(e=window.jQuery){if(e||window.$&&window.$.fn&&window.$.fn.jquery&&(e=window.$),e&&!r2){let n=e.fn.on,t=e.fn.off;e.fn.on=function(e,t){return r5.call(this,n,window.addEventListener,e,t,arguments)},e.fn.off=function(e,n){return r5.call(this,t,window.removeEventListener,e,n,arguments)},r2=!0}}function r5(e,n,t,r,o){return"string"!=typeof t?e.apply(this,o):(t.split(/\s+/).forEach(e=>{rH.indexOf(e)>=0&&(n(e,r),t=t.replace(e,""))}),""===t.trim()?this:e.apply(this,o))}let r4={};function r6(e){return Promise.resolve().then(()=>{let n=r4[ry(e)];if(!n)return e;if(e.status===rr)return r7(e,n),e;if(e.status===rd)return n.promise.then(()=>e);if(e.status!==rs&&e.status!==rf)return e;let t=e.status===rf?Promise.resolve():rW(e,"unload");return e.status=rd,t.then(()=>(r7(e,n),e)).catch(t=>(delete r4[ry(e)],delete e.bootstrap,delete e.mount,delete e.unmount,delete e.unload,t8(t,e,rh),n.reject(t),e))})}function r7(e,n){delete r4[ry(e)],delete e.bootstrap,delete e.mount,delete e.unmount,delete e.unload,e.status=rr,n.resolve()}function r8(e,n,t,r){r4[ry(e)]={app:e,resolve:t,reject:r},Object.defineProperty(r4[ry(e)],"promise",{get:n})}let r9=[];function oe(){return r9.filter(rm).map(ry)}function on(){return r9.map(ry)}function ot(e){let n=r$(r9,n=>ry(n)===e);return n?n.status:null}let or=!1;function oo(e,n,t,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(rn(39,!1));let n=["name","app","activeWhen","customProps"],t=Object.keys(e).reduce((e,t)=>n.indexOf(t)>=0?e:e.concat(t),[]);if(0!==t.length)throw Error(rn(38,!1,n.join(", "),t.join(", ")));if("string"!=typeof e.name||0===e.name.length||"object"!=typeof e.app&&"function"!=typeof e.app)throw Error(rn(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(rn(24,!1));if(!oc(e.customProps))throw Error(rn(22,!1))}(e),i.name=e.name,i.loadApp=e.app,i.activeWhen=e.activeWhen,i.customProps=e.customProps):(function(e,n,t,r){if("string"!=typeof e||0===e.length)throw Error(rn(20,!1));if(!n)throw Error(rn(23,!1));if("function"!=typeof t)throw Error(rn(24,!1));if(!oc(r))throw Error(rn(22,!1))}(e,n,t,r),i.name=e,i.loadApp=n,i.activeWhen=t,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:op(e)),i.activeWhen=e=>s.some(n=>n(e)),i);if(oy||or||(or=!0,setTimeout(()=>{oy||console.warn(rn(1,!1))},5e3)),-1!==on().indexOf(l.name))throw Error(rn(21,!1,l.name));r9.push(rv({loadErrorTime:null,status:rr,parcels:{},devtools:{overlays:{options:{},selectors:[]}}},l)),rU&&(r3(),om())}function oa(e=window.location){return r9.filter(n=>n.activeWhen(e)).map(ry)}function oi(e){if(0===r9.filter(n=>ry(n)===e).length)throw Error(rn(25,!1,e));return(rU?os(e,{waitForUnmount:!1}):Promise.resolve()).then(()=>{let n=r9.map(ry).indexOf(e);r9.splice(n,1)})}function os(e,n={waitForUnmount:!1}){if("string"!=typeof e)throw Error(rn(26,!1));let t=r$(r9,n=>ry(n)===e);if(!t)throw Error(rn(27,!1,e));let r=r4[ry(t)];if(n&&n.waitForUnmount){if(r)return r.promise;{let e=new Promise((n,r)=>{r8(t,()=>e,n,r)});return e}}{let e;return r?(e=r.promise,ol(t,r.resolve,r.reject)):e=new Promise((n,r)=>{r8(t,()=>e,n,r),ol(t,n,r)}),e}}function ol(e,n,t){Promise.resolve().then(()=>{if(r$(oa(),n=>n===ry(e)))return oh()}).then(()=>rE(e).then(r6).then(()=>{n(),setTimeout(()=>{om()})})).catch(t)}function oc(e){return!e||"function"==typeof e||"object"==typeof e&&null!==e&&!Array.isArray(e)}function op(e,n){let t=function(e,n){let t=0,r=!1,o="^";"/"!==e[0]&&(e="/"+e);for(let n=0;n<e.length;n++){let t=e[n],o=r&&"/"===t;(!r&&":"===t||o)&&a(n)}return a(e.length),RegExp(o,"i");function a(a){let i=e.slice(t,a).replace(/[|\\{}()[\]^$+*?.]/g,"\\$&");if(o+=r?"[^/]+/?":i,a===e.length)if(r)n&&(o+="$");else{let e=n?"":".*";o="/"===o.charAt(o.length-1)?`${o}${e}$`:`${o}(/${e})?(#.*)?$`}r=!r,t=a}}(e,n);return e=>{let n=e.origin;n||(n=`${e.protocol}//${e.host}`);let r=e.href.replace(n,"").replace(e.search,"").split("?")[0];return t.test(r)}}let ou=!1,od=[],of=rU&&window.location.href;function oh(){return om()}function om(e=[],n,t=!1){let r,o,a,i,s;if(ou)return new Promise((e,t)=>{od.push({resolve:e,reject:t,eventArguments:n})});let{appsToUnload:l,appsToUnmount:c,appsToLoad:p,appsToMount:u}=(r=[],o=[],a=[],i=[],s=(new Date).getTime(),r9.forEach(e=>{let n=e.status!==rh&&rg(e);switch(e.status){case rf:n&&s-e.loadErrorTime>=200&&a.push(e);break;case rr:case ro:n&&a.push(e);break;case ra:case rs:!n&&r4[ry(e)]?r.push(e):n&&i.push(e);break;case rc:n||o.push(e)}}),{appsToUnload:r,appsToUnmount:o,appsToLoad:a,appsToMount:i}),d,f=[],h=of,m=of=window.location.href;return oy?(ou=!0,d=l.concat(p,c,u),Promise.resolve().then(()=>($(0===d.length?"before-no-app-change":"before-app-change",v(!0)),$("before-routing-event",v(!0,{cancelNavigation:g})),Promise.all(f).then(t=>{if(t.some(e=>e))return rX.call(window.history,history.state,"",h.substring(location.origin.length)),of=location.href,ou=!1,om(e,n,!0);let r=l.map(r6),o=Promise.all(c.map(rE).map(e=>e.then(r6)).concat(r));o.then(()=>{$("before-mount-routing-event",v(!0))},e=>{throw e});let a=p.map(e=>rG(e).then(e=>og(e,o))),i=u.filter(e=>0>p.indexOf(e)).map(e=>og(e,o));return o.catch(e=>{throw b(),e}).then(()=>(b(),Promise.all(a.concat(i)).catch(n=>{throw e.forEach(e=>e.reject(n)),n}).then(y).then(()=>{},e=>{throw e})))})))):(d=p,Promise.resolve().then(()=>Promise.all(p.map(rG)).then(b).then(()=>[]).catch(e=>{throw b(),e}).finally(()=>{})));function g(e=!0){let n="function"==typeof(null==e?void 0:e.then)?e:Promise.resolve(e);f.push(n.catch(e=>(console.warn(Error(rn(42,!1))),console.warn(e),!1)))}function y(){let n=oe();e.forEach(e=>e.resolve(n));try{$(0===d.length?"no-app-change":"app-change",v()),$("routing-event",v())}catch(e){setTimeout(()=>{throw e})}if(ou=!1,od.length>0){let e=od;od=[],om(e)}return n}function b(){t||(e.forEach(e=>{rY(e.eventArguments)}),rY(n))}function v(e=!1,t){let r={},o={[rc]:[],[rs]:[],[rr]:[],[rh]:[]};e?(p.concat(u).forEach((e,n)=>{i(e,rc)}),l.forEach(e=>{i(e,rr)}),c.forEach(e=>{i(e,rs)})):d.forEach(e=>{i(e)});let a={detail:{newAppStatuses:r,appsByNewStatus:o,totalAppChanges:d.length,originalEvent:null==n?void 0:n[0],oldUrl:h,newUrl:m}};return t&&rv(a.detail,t),a;function i(e,n){let t=ry(e);n=n||ot(t),r[t]=n,(o[n]=o[n]||[]).push(t)}}function $(e,n){t||window.dispatchEvent(new t6(`single-spa:${e}`,n))}}function og(e,n){return rg(e)?rC(e).then(e=>n.then(()=>rg(e)?rz(e):e)):n.then(()=>e)}let oy=!1;function ob(e){oy=!0,rU&&(r0(e),om())}function o_(e,n){let t=window.getOpenmrsSpaBase().replace(/\/$/,"");return ov(e,{openmrsBase:window.openmrsBase,openmrsSpaBase:t,...n}).replace(/^\/\//,"/")}function ov(e,n){return Object.keys(n).reduce((e,t)=>e.split("${"+t+"}").join(n[t]),e)}function o$({to:e,templateParams:n}){let t=window.getOpenmrsSpaBase().replace(/\/$/,""),r=o_(e,n).replace(window.location.origin,"");r.startsWith(t)?rK(r):window.location.assign(r)}rU&&window.__SINGLE_SPA_DEVTOOLS__&&(window.__SINGLE_SPA_DEVTOOLS__.exposedMethods={getRawAppData:function(){return[...r9]},reroute:om,NOT_LOADED:rr,toLoadPromise:rG,toBootstrapPromise:rC,unregisterApplication:oi,getProfilerData:function(){return rx}});let oA="openmrs:history";function ow(e){let n=JSON.parse(sessionStorage.getItem(oA)??"[]")||[];n.push(e),n.length>50&&(n=n.slice(-50)),sessionStorage.setItem(oA,JSON.stringify(n))}function ok(){0===JSON.parse(sessionStorage.getItem(oA)??"[]").length&&document.referrer&&ow(document.referrer),window.addEventListener("single-spa:routing-event",e=>{let n=ox();e.detail.originalEvent?.singleSpaTrigger=="replaceState"?(n[n.length-1]=window.location.href,sessionStorage.setItem(oA,JSON.stringify(n))):!e.detail.originalEvent?.singleSpa&&n.includes(window.location.href)?oC({toUrl:window.location.href}):n[n.length-1]!==window.location.href&&ow(window.location.href)})}function ox(){return JSON.parse(sessionStorage.getItem(oA)??"[]")}function oC({toUrl:e}){let n=ox(),t=n.lastIndexOf(e);if(-1!=t){let e=n.slice(0,t+1);o$({to:n[t]}),sessionStorage.setItem(oA,JSON.stringify(e))}else throw Error(`URL ${e} not found in history; cannot go back to it.`)}function oE(){sessionStorage.removeItem(oA)}let oS="${openmrsSpaBase}/login",oD={redirectAuthFailure:{enabled:{_type:n4.Boolean,_default:!0,_description:"Whether to redirect logged-out users to `redirectAuthFailure.url`"},url:{_type:n4.String,_default:oS,_validators:[tY.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:n4.Array,_default:[401],_elements:{_type:n4.Number,_validators:[tY.inRange(100,600)]},_description:"The HTTP error codes for which users will be redirected"},resolvePromise:{_type:n4.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:n4.Boolean,_default:!0,_description:"Whether openmrsFetch should support redirects returned from the backend"}};function oz(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}let oM="/ws/rest/v1",oP="/ws/fhir2/R4",oT=`${oM}/session`;function oO(e){return e&&e.startsWith("http")?e:("/"!==e[0]&&(e="/"+e),window.openmrsBase+e)}function oN(e,n={}){if("string"!=typeof e)throw Error("The first argument to @openmrs/api's openmrsFetch function must be a url string");if("object"!=typeof n)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 t=oO(e);if(n.headers||(n.headers={}),em(n.body)&&(n.body=JSON.stringify(n.body)),void 0===n.headers.Accept&&(n.headers.Accept="application/json"),null===n.headers.Accept&&delete n.headers.Accept,e.startsWith(oM)&&void 0===n.headers["Disable-WWW-Authenticate"]&&(n.headers["Disable-WWW-Authenticate"]="true"),e.startsWith(oP)){let e=new URL(t,window.location.toString());e.searchParams.has("_summary")||(e.searchParams.set("_summary","data"),t=e.toString())}let r=Error();return window.fetch(t,n).then(async e=>{let{redirectAuthFailure:n,followRedirects:o}=await tx("@openmrs/esm-api");if(e.ok){let n=e.headers.get("location");return(o&&n&&(t===oO(oT)||204===e.status)&&o$({to:n}),204===e.status)?(e.data=null,e):e.clone().text().then(n=>{try{n&&(e.data=JSON.parse(n))}catch(e){}return e})}return t===oO(oT)&&403===e.status||n.enabled&&n.errors.includes(e.status)?(oE(),o$({to:n.url||e.headers.get("location")||oS}),n.resolvePromise?Promise.resolve():new Promise(()=>{})):e.clone().text().then(n=>{let o=n;try{o=JSON.parse(n)}catch(e){}throw new oB(t,e,o,r)},n=>{throw new oB(t,e,null,r)})})}function oI(e,n={}){if("object"!=typeof n)throw Error("The second argument to openmrsObservableFetch must be either omitted or an object");let t=new AbortController;return n.signal=t.signal,new es.Observable(r=>{let o=!1;return oN(e,n).then(e=>{o=!0,r.next(e),r.complete()},e=>{o=!0,r.error(e)}),()=>{o||t.abort()}})}class oB extends Error{constructor(e,n,t,r){super(),oz(this,"response",void 0),oz(this,"responseBody",void 0),this.message=`Server responded with ${n.status} (${n.statusText}) for url ${e}. Check err.responseBody or network tab in dev tools for more info`,r.message=this.message,this.responseBody=t,this.response=n,this.stack=`Stacktrace for outgoing request:
13
13
  ${r.stack}
14
14
  Stacktrace for incoming response:
15
- ${this.stack}`}}let oj=G("session",{loaded:!1,session:null}),oR=0;function oF(e={includeAuthStatus:!0}){return(oR<Date.now()-6e4||!oj.getState().loaded)&&oV(),new es.Observable(n=>{let t=t=>{t.loaded&&(e.includeAuthStatus?n.next(t.session):n.next(t.session?.user))};return t(oj.getState()),oj.subscribe(t)})}function oL(){return(oR<Date.now()-6e4||!oj.getState().loaded)&&oV(),oj}function oW(e){let n=e.locale??e.user?.userProperties?.defaultLocale;n&&n.includes("_")&&(n=n.replaceAll("_","-")),function(e){if(void 0===e||"string"!=typeof e)return!1;try{new Intl.Locale(e)}catch(e){return!1}return!0}(n)&&n!==document.documentElement.getAttribute("lang")&&document.documentElement.setAttribute("lang",n)}function oV(e,n){oR=Date.now();let t={};return e&&n&&(t.Authorization=`Basic ${window.btoa(`${e}:${n}`)}`),oZ(oN(oT,{headers:t}))}function oG(){oj.setState({loaded:!0,session:{authenticated:!1,sessionId:""}})}function oU(e,n){var t,r;if(void 0===n)return!e;if(!e)return!0;return t=e,r=n,("string"==typeof t?!Y(r.privileges.find(e=>t===e.display)):Array.isArray(t)?t.every(e=>!Y(r.privileges.find(n=>e===n.display))):(Y(t)||console.error(`Could not understand privileges "${t}"`),!0))||!Y(n.roles.find(e=>"System Developer"===e.display))}function oq(){let e,n;return new Promise(t=>{let r=r=>{r.loaded&&r.session.user&&(e=r.session.user,t(r.session.user),n&&n())};r(oj.getState()),e||(n=oj.subscribe(r))})}function oH(){return new Promise((e,n)=>{oF().subscribe(n=>{e(n.sessionLocation)},n).unsubscribe()})}async function oK(e,n){return oZ(oN(oT,{method:"POST",body:{sessionLocation:e},headers:{"Content-Type":"application/json"},signal:n.signal}))}async function oY(e,n,t){return t||(t=new AbortController),await oN(`${oM}/user/${e}`,{method:"POST",body:{userProperties:n},headers:{"Content-Type":"application/json"},signal:t.signal}),oV()}function oZ(e){return new Promise((n,t)=>{e.then(e=>{let r;"object"==typeof e?.data?(r={loaded:!0,session:e.data},oj.setState(r),n(r)):(r={loaded:!1,session:null},oj.setState(r),t(r))}).catch(e=>{O(`Failed to fetch new session information: ${e}`);let n={loaded:!1,session:null};oj.setState(n),t(n)})})}function oJ(){return"development"===window.spaEnv||"true"===localStorage.getItem("openmrs:devtools")}oj.subscribe(e=>{e.loaded&&e.session&&oW(e.session)});let oX={"webservices.rest":"2.24.0",fhir2:"1.0.0-SNAPSHOT"};function oQ(){t_("@openmrs/esm-api",oD),oV()}let o0={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",discardUnsavedChangesPromptBodyMultiple:"{{count}} workspaces have unsaved changes. Closing them will discard the changes:",discardUnsavedChangesPromptBodySingle:"<strong>{{workspaceTitle}}</strong> has unsaved changes. Closing it will discard them.",discardUnsavedChangesPromptTitle:"Discard unsaved changes?",keepEditing:"Keep editing",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 o1=t(4557),o2=t.n(o1);let o3=o2().default||o2();function o5(e,n,t,r){return o3.t(n,{ns:e,defaultValue:t,...r})}function o4(e,n,t){return o0[e]?o5("core",e,n??o0[e],t):(console.error(`O3 Core Translations does not provide key '${e}'. The key itself is being rendered as text.`),e)}o3.on("initialized",function(){window.i18next.loadNamespaces(["core"])});let o6="import-map-override:",o7="import-map-overrides-disabled",o8="import-map-overrides:change",o9=!1,ae=null;async function an(){let e=document.querySelectorAll('script[type="systemjs-importmap"]'),n=[];for(let t=0;t<e.length;t++){let r=e[t];try{if(r.src){let e=await fetch(r.src);n.push(await e.json())}else r.textContent&&n.push(JSON.parse(r.textContent))}catch(e){console.warn(`[import-maps] Failed to parse import map from script tag at index ${t}`,e)}}return at(n)}function at(e){let n={imports:{}};for(let t of e)t?.imports&&Object.assign(n.imports,t.imports);return n}function ar(){let e={};try{let n=al();for(let t=0;t<localStorage.length;t++){let r=localStorage.key(t);if(r?.startsWith(o6)){let t=r.slice(o6.length);if(!n.includes(t)){let n=localStorage.getItem(r);n&&(e[t]=n)}}}}catch(e){console.warn("[import-maps] Failed to read import-map overrides from localStorage",e)}return{imports:e}}async function ao(){let e=await an();return o9?at([e,ae??ar()]):e}async function aa(){return an()}async function ai(){return o9?at([await an(),ar()]):an()}function as(e){if(!o9)return{imports:{}};if(e){let e={};for(let n=0;n<localStorage.length;n++){let t=localStorage.key(n);if(t?.startsWith(o6)){let n=localStorage.getItem(t);n&&(e[t.slice(o6.length)]=n)}}return{imports:e}}return ar()}function al(){if(!o9)return[];try{let e=localStorage.getItem(o7);if(e){let n=JSON.parse(e);if(Array.isArray(n))return n}}catch{}return[]}function ac(e){return!!o9&&al().includes(e)}function ap(e,n){if(!o9)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{localStorage.setItem(o6+e,n),window.dispatchEvent(new CustomEvent(o8))}catch(e){console.warn("[import-maps] Failed to write import-map override to localStorage",e)}}function au(e){if(!o9)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{localStorage.removeItem(o6+e);let n=al().filter(n=>n!==e);n.length>0?localStorage.setItem(o7,JSON.stringify(n)):localStorage.removeItem(o7),window.dispatchEvent(new CustomEvent(o8))}catch(e){console.warn("[import-maps] Failed to update import-map overrides in localStorage",e)}}function ad(){if(!o9)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{let e=[];for(let n=0;n<localStorage.length;n++){let t=localStorage.key(n);t?.startsWith(o6)&&e.push(t)}e.forEach(e=>localStorage.removeItem(e)),localStorage.removeItem(o7),window.dispatchEvent(new CustomEvent(o8))}catch(e){console.warn("[import-maps] Failed to clear import-map overrides from localStorage",e)}}function af(e){if(!o9)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{let n=al().filter(n=>n!==e);n.length>0?localStorage.setItem(o7,JSON.stringify(n)):localStorage.removeItem(o7),window.dispatchEvent(new CustomEvent(o8))}catch(e){console.warn("[import-maps] Failed to update import-map overrides in localStorage",e)}}let ah=!1;function am(){!ah&&(ah=!0,(o9="development"===window.spaEnv)&&(ae=ar()))}function ag(e){return e.replace(/[\/\-@]/g,"_")}async function ay(e,n="./start",r){var o;let a,i=!r?.maxLoadingTime||r.maxLoadingTime<=0?6e5:r.maxLoadingTime;await Promise.race([ab(e,r?.importMap),new Promise((n,t)=>{a=setTimeout(()=>{var n;t(Error(`Could not resolve requested script, ${e}, within ${(n=i)<1e3?`${n} milliseconds`:n<6e4?`${Math.floor(n/1e3)} seconds`:n<36e5?`${Math.floor(n/6e4)} minutes`:n<864e5?`${Math.floor(n/36e5)} hours`:`${Math.floor(n/864e5)} days`}.`))},i)})]),a&&clearTimeout(a);let s=ag(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(t.S.default);let c=(await l.get(n))();if("object"!=typeof c||null===c){let n=`Container for ${e} did not return an ESM module as expected`;throw console.error(n),Error(n)}return c}async function ab(e,n){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 t=ag(e);if(!window[t]){let t=n??await a_();if(!t.imports.hasOwnProperty(e)){let n=`Could not find the package ${e} defined in the current importmap`;throw console.error(n),Error(n)}let r=t.imports[e];r.startsWith("./")&&(r=window.spaBase+r.substring(1));let o=e in as().imports;try{return await new Promise((e,n)=>{!function(e,n,t){let r=document.head.querySelector(`script[src="${e}"]`),o=window[av];if(o||(o=window[av]=new Set([])),r)if(o.has(e)){let e,o,a;a=()=>{e&&r.removeEventListener("load",e),o&&r.removeEventListener("error",o)},e=()=>{a(),n(null)},o=e=>{a(),t(e.message)},r.addEventListener("load",e),r.addEventListener("error",o)}else console.warn(`Script at ${e} already loaded. Not loading it again.`),n(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(),n(null)},a=n=>{i();let r=`Failed to load script from ${e}`;console.error(r,n),t(n.message??r)},s.addEventListener("load",r),s.addEventListener("error",a),document.head.appendChild(s)}}(r,e,n)})}catch(e){return o&&D({kind:"error",title:o4("scriptLoadingFailed","Error: Script failed to load"),description:o4("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:o4("resetOverrides","Reset overrides"),onActionButtonClick(){ad(),window.location.reload()}}),Promise.reject(e)}}return Promise.resolve()}async function a_(){return ao()}let av=Symbol("__openmrs_script_loading");function a$(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 aA(e){return!!e&&"object"==typeof e&&Object.entries(e).every(([e,n])=>"string"==typeof e&&a$(n))}let aw="openmrs-routes:",ak="openmrs-routes:change",ax=!1,aC=null;async function aE(){let e=document.querySelectorAll("script[type='openmrs-routes']"),n=[];for(let t=0;t<e.length;t++){let r=e[t];try{let e;if(r.src){let n=await fetch(r.src);e=await n.json()}else r.textContent&&(e=JSON.parse(r.textContent));e&&aA(e)&&n.push(e)}catch(e){console.warn(`[route-maps] Failed to parse routes from script tag at index ${t}`,e)}}return aS(n)}function aS(e){let n={};for(let t of e)t&&"object"==typeof t&&Object.assign(n,t);return n}async function aD(){let e={};try{let n=[];for(let e=0;e<localStorage.length;e++){let t=localStorage.key(e);if(t?.startsWith(aw)){let e=localStorage.getItem(t);e&&n.push({moduleName:t.slice(aw.length),raw:e})}}for(let t of(await Promise.allSettled(n.map(async({moduleName:e,raw:n})=>{let t=JSON.parse(n);if(a$(t))return{moduleName:e,routes:t};if("string"==typeof t&&t.startsWith("http")){let n=await fetch(t),r=await n.json();if(a$(r))return{moduleName:e,routes:r};throw Error(`${t} did not resolve to a valid OpenmrsAppRoutes object`)}throw Error(`Override for ${e} is neither a valid routes object nor a URL`)}))))"fulfilled"===t.status?e[t.value.moduleName]=t.value.routes:console.warn("[route-maps] Failed to load route override",t.reason)}catch(e){console.warn("[route-maps] Failed to read route overrides from localStorage",e)}return e}async function az(){let e=await aE();return ax?aS([e,aC??await aD()]):e}async function aM(){return aE()}async function aP(){return ax?aS([await aE(),await aD()]):aE()}function aT(){if(!ax)return{};let e={};try{for(let n=0;n<localStorage.length;n++){let t=localStorage.key(n);if(t?.startsWith(aw)){let n=localStorage.getItem(t);n&&(e[t.slice(aw.length)]=n)}}}catch(e){console.warn("[route-maps] Failed to read route overrides from localStorage",e)}return e}function aO(e,n){if(!ax)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{if("string"==typeof n)if(n.startsWith("http"))localStorage.setItem(aw+e,JSON.stringify(n));else{let t=JSON.parse(n);if(!a$(t))return void console.error(`The supplied routes for ${e} is not a valid OpenmrsAppRoutes object`,n);localStorage.setItem(aw+e,JSON.stringify(t))}else if(n instanceof URL)localStorage.setItem(aw+e,JSON.stringify(n.toString()));else{if(!a$(n))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`,n);localStorage.setItem(aw+e,JSON.stringify(n))}window.dispatchEvent(new CustomEvent(ak))}catch(e){console.warn("[route-maps] Failed to write route override to localStorage",e)}}function aN(e){if(!ax)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{localStorage.removeItem(aw+e),window.dispatchEvent(new CustomEvent(ak))}catch(e){console.warn("[route-maps] Failed to remove route override from localStorage",e)}}function aI(){if(!ax)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{let e=[];for(let n=0;n<localStorage.length;n++){let t=localStorage.key(n);t?.startsWith(aw)&&e.push(t)}e.forEach(e=>localStorage.removeItem(e)),window.dispatchEvent(new CustomEvent(ak))}catch(e){console.warn("[route-maps] Failed to clear route overrides from localStorage",e)}}let aB=null;function aj(){return aB||(aB=(ax="development"===window.spaEnv)?aD().then(e=>{aC=e}):Promise.resolve())}let aR=`${oM}/attachment`;function aF(e,n){return oN(`${aR}/${e}`,{signal:n.signal})}function aL(e,n,t){return oN(`${aR}?patient=${e}&includeEncounterless=${n}`,{signal:t.signal})}async function aW(e,n){let t=new FormData;return t.append("fileCaption",n.fileDescription),t.append("patient",e),n.file?t.append("file",n.file,n.fileName):(t.append("file",new File([""],n.fileName),n.fileName),t.append("base64Content",n.base64Content)),oN(`${aR}`,{method:"POST",body:t})}function aV(e,n){return oN(`${aR}/${e}`,{method:"DELETE",signal:n.signal})}try{self["workbox:window:6.5.4"]&&_()}catch(e){}function aG(e,n){return new Promise(function(t){var r=new MessageChannel;r.port1.onmessage=function(e){t(e.data)},e.postMessage(n,[r.port2])})}function aU(e,n){for(var t=0;t<n.length;t++){var r=n[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function aq(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=Array(n);t<n;t++)r[t]=e[t];return r}try{self["workbox:core:6.5.4"]&&_()}catch(e){}var aH=function(){var e=this;this.promise=new Promise(function(n,t){e.resolve=n,e.reject=t})};function aK(e,n){var t=location.href;return new URL(e,t).href===new URL(n,t).href}var aY=function(e,n){this.type=e,Object.assign(this,n)};function aZ(e,n,t){return t?n?n(e):e:(e&&e.then||(e=Promise.resolve(e)),n?e.then(n):e)}function aJ(){}var aX={type:"SKIP_WAITING"};function aQ(e,n){if(!n)return e&&e.then?e.then(aJ):Promise.resolve()}var a0=function(e){function n(n,t){var r,o;return void 0===t&&(t={}),(r=e.call(this)||this).nn={},r.tn=0,r.rn=new aH,r.en=new aH,r.on=new aH,r.un=0,r.an=new Set,r.cn=function(){var e=r.fn,n=e.installing;r.tn>0||!aK(n.scriptURL,r.sn.toString())||performance.now()>r.un+6e4?(r.vn=n,e.removeEventListener("updatefound",r.cn)):(r.hn=n,r.an.add(n),r.rn.resolve(n)),++r.tn,n.addEventListener("statechange",r.ln)},r.ln=function(e){var n=r.fn,t=e.target,o=t.state,a=t===r.vn,i={sw:t,isExternal:a,originalEvent:e};!a&&r.mn&&(i.isUpdate=!0),r.dispatchEvent(new aY(o,i)),"installed"===o?r.wn=self.setTimeout(function(){"installed"===o&&n.waiting===t&&r.dispatchEvent(new aY("waiting",i))},200):"activating"===o&&(clearTimeout(r.wn),a||r.en.resolve(t))},r.dn=function(e){var n=r.hn,t=n!==navigator.serviceWorker.controller;r.dispatchEvent(new aY("controlling",{isExternal:t,originalEvent:e,sw:n,isUpdate:r.mn})),t||r.on.resolve(n)},o=function(e){var n=e.data,t=e.ports,o=e.source;return aZ(r.getSW(),function(){r.an.has(o)&&r.dispatchEvent(new aY("message",{data:n,originalEvent:e,ports:t,sw:o}))})},r.gn=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];try{return Promise.resolve(o.apply(this,e))}catch(e){return Promise.reject(e)}},r.sn=n,r.nn=t,navigator.serviceWorker.addEventListener("message",r.gn),r}n.prototype=Object.create(e.prototype),n.prototype.constructor=n,n.__proto__=e;var t,r,o=n.prototype;return o.register=function(e){var n=(void 0===e?{}:e).immediate,t=void 0!==n&&n;try{var r,o,a,i=this;return r=function(){if(!t&&"complete"!==document.readyState)return aQ(new Promise(function(e){return window.addEventListener("load",e)}))},o=function(){return i.mn=!!navigator.serviceWorker.controller,i.yn=i.pn(),aZ(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 n=i.fn.waiting;return n&&aK(n.scriptURL,i.sn.toString())&&(i.hn=n,Promise.resolve().then(function(){i.dispatchEvent(new aY("waiting",{sw:n,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?aQ(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 aZ(this.getSW(),function(n){return aG(n,e)})}catch(e){return Promise.reject(e)}},o.messageSkipWaiting=function(){this.fn&&this.fn.waiting&&aG(this.fn.waiting,aX)},o.pn=function(){var e=navigator.serviceWorker.controller;return e&&aK(e.scriptURL,this.sn.toString())?e:void 0},o.bn=function(){try{var e=this;return function(e,n){try{var t=e()}catch(e){return n(e)}return t&&t.then?t.then(void 0,n):t}(function(){return aZ(navigator.serviceWorker.register(e.sn,e.nn),function(n){return e.un=performance.now(),n})},function(e){throw e})}catch(e){return Promise.reject(e)}},t=[{key:"active",get:function(){return this.en.promise}},{key:"controlling",get:function(){return this.on.promise}}],aU(n.prototype,t),r&&aU(n,r),n}(function(){function e(){this.Pn=new Map}var n=e.prototype;return n.addEventListener=function(e,n){this.Sn(e).add(n)},n.removeEventListener=function(e,n){this.Sn(e).delete(n)},n.dispatchEvent=function(e){e.target=this;for(var n,t=function(e){var n;if("u"<typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e){if(e){if("string"==typeof e)return aq(e,void 0);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?aq(e,void 0):void 0}}(e))){n&&(e=n);var t=0;return function(){return t>=e.length?{done:!0}:{done:!1,value:e[t++]}}}throw TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(n=e[Symbol.iterator]()).next.bind(n)}(this.Sn(e.type));!(n=t()).done;)(0,n.value)(e)},n.Sn=function(e){return this.Pn.has(e)||this.Pn.set(e,new Set),this.Pn.get(e)},e}());function a1(e,n){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 t=new a0(e,n);return u=t.register().then(()=>t.controlling.then(()=>t))}function a2(){return u??Promise.resolve(void 0)}let a3="x-omrs-offline-response-body",a5="x-omrs-offline-response-status",a4="x-omrs-offline-caching-strategy";async function a6(e){let n=await a2();return n?await n.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 a7(){let e=window.sessionStorage;try{e.setItem("someKeyHere","test"),e.removeItem("someKeyHere")}catch(n){if(n.code===DOMException.QUOTA_EXCEEDED_ERR&&0===e.length)return!0}return!1}async function a8(){return!window.indexedDB}async function a9(){return new Promise(e=>{let n=indexedDB.open("test");n.onerror=()=>e(!0),n.onsuccess=()=>e(!1)})}async function ie(){return await a9()||await a8()||await a7()}let it="openmrs3:offline-mode",ir="unavailable";function io(){return{current:ir,notAvailable:"unavailable"===ir,active:"on"===ir}}function ia(e){"unavailable"!==ir&&"unavailable"!==e&&(localStorage.setItem(it,"on"===e?"active":"disabled"),ir=e)}async function ii(){await ie()||(ir="active"===localStorage.getItem(it)?"on":"off"),navigator.onLine}let is="u">typeof globalThis?globalThis:"u">typeof self?self:"u">typeof window?window:global,il=Object.keys,ic=Array.isArray;function ip(e,n){return"object"!=typeof n||il(n).forEach(function(t){e[t]=n[t]}),e}"u"<typeof Promise||is.Promise||(is.Promise=Promise);let iu=Object.getPrototypeOf,id={}.hasOwnProperty;function ih(e,n){return id.call(e,n)}function im(e,n){"function"==typeof n&&(n=n(iu(e))),("u"<typeof Reflect?il:Reflect.ownKeys)(n).forEach(t=>{iy(e,t,n[t])})}let ig=Object.defineProperty;function iy(e,n,t,r){ig(e,n,ip(t&&ih(t,"get")&&"function"==typeof t.get?{get:t.get,set:t.set,configurable:!0}:{value:t,configurable:!0,writable:!0},r))}function ib(e){return{from:function(n){return e.prototype=Object.create(n.prototype),iy(e.prototype,"constructor",e),{extend:im.bind(null,e.prototype)}}}}let i_=Object.getOwnPropertyDescriptor;function iv(e,n){let t;return i_(e,n)||(t=iu(e))&&iv(t,n)}let i$=[].slice;function iA(e,n,t){return i$.call(e,n,t)}function iw(e,n){return n(e)}function ik(e){if(!e)throw Error("Assertion Failed")}function ix(e){is.setImmediate?setImmediate(e):setTimeout(e,0)}function iC(e,n){return e.reduce((e,t,r)=>{var o=n(t,r);return o&&(e[o[0]]=o[1]),e},{})}function iE(e,n){if(ih(e,n))return e[n];if(!n)return e;if("string"!=typeof n){for(var t=[],r=0,o=n.length;r<o;++r){var a=iE(e,n[r]);t.push(a)}return t}var i=n.indexOf(".");if(-1!==i){var s=e[n.substr(0,i)];return void 0===s?void 0:iE(s,n.substr(i+1))}}function iS(e,n,t){if(e&&void 0!==n&&(!("isFrozen"in Object)||!Object.isFrozen(e)))if("string"!=typeof n&&"length"in n){ik("string"!=typeof t&&"length"in t);for(var r=0,o=n.length;r<o;++r)iS(e,n[r],t[r])}else{var a=n.indexOf(".");if(-1!==a){var i=n.substr(0,a),s=n.substr(a+1);if(""===s)void 0===t?ic(e)&&!isNaN(parseInt(i))?e.splice(i,1):delete e[i]:e[i]=t;else{var l=e[i];l&&ih(e,i)||(l=e[i]={}),iS(l,s,t)}}else void 0===t?ic(e)&&!isNaN(parseInt(n))?e.splice(n,1):delete e[n]:e[n]=t}}function iD(e){var n={};for(var t in e)ih(e,t)&&(n[t]=e[t]);return n}let iz=[].concat;function iM(e){return iz.apply([],e)}let iP="Boolean,String,Date,RegExp,Blob,File,FileList,FileSystemFileHandle,ArrayBuffer,DataView,Uint8ClampedArray,ImageBitmap,ImageData,Map,Set,CryptoKey".split(",").concat(iM([8,16,32,64].map(e=>["Int","Uint","Float"].map(n=>n+e+"Array")))).filter(e=>is[e]),iT=iP.map(e=>is[e]);iC(iP,e=>[e,!0]);let iO=null;function iN(e){iO="u">typeof WeakMap&&new WeakMap;let n=function e(n){if(!n||"object"!=typeof n)return n;let t=iO&&iO.get(n);if(t)return t;if(ic(n)){t=[],iO&&iO.set(n,t);for(var r=0,o=n.length;r<o;++r)t.push(e(n[r]))}else if(iT.indexOf(n.constructor)>=0)t=n;else{let r=iu(n);for(var a in t=r===Object.prototype?{}:Object.create(r),iO&&iO.set(n,t),n)ih(n,a)&&(t[a]=e(n[a]))}return t}(e);return iO=null,n}let{toString:iI}={};function iB(e){return iI.call(e).slice(8,-1)}let ij="u">typeof Symbol?Symbol.iterator:"@@iterator",iR="symbol"==typeof ij?function(e){var n;return null!=e&&(n=e[ij])&&n.apply(e)}:function(){return null},iF={};function iL(e){var n,t,r,o;if(1==arguments.length){if(ic(e))return e.slice();if(this===iF&&"string"==typeof e)return[e];if(o=iR(e)){for(t=[];!(r=o.next()).done;)t.push(r.value);return t}if(null==e)return[e];if("number"==typeof(n=e.length)){for(t=Array(n);n--;)t[n]=e[n];return t}return[e]}for(n=arguments.length,t=Array(n);n--;)t[n]=arguments[n];return t}let iW="u">typeof Symbol?e=>"AsyncFunction"===e[Symbol.toStringTag]:()=>!1;var iV="u">typeof location&&/^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href),iG=()=>!0;let iU=!Error("").stack;function iq(){if(iU)try{throw iq.arguments,Error()}catch(e){return e}return Error()}function iH(e,n){var t=e.stack;return t?(n=n||0,0===t.indexOf(e.name)&&(n+=(e.name+e.message).split("\n").length),t.split("\n").slice(n).filter(iG).map(e=>"\n"+e).join("")):""}var iK=["Unknown","Constraint","Data","TransactionInactive","ReadOnly","Version","NotFound","InvalidState","InvalidAccess","Abort","Timeout","QuotaExceeded","Syntax","DataClone"],iY=["Modify","Bulk","OpenFailed","VersionChange","Schema","Upgrade","InvalidTable","MissingAPI","NoSuchDatabase","InvalidArgument","SubTransaction","Unsupported","Internal","DatabaseClosed","PrematureCommit","ForeignAwait"].concat(iK),iZ={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 iJ(e,n){this._e=iq(),this.name=e,this.message=n}function iX(e,n){return e+". Errors: "+Object.keys(n).map(e=>n[e].toString()).filter((e,n,t)=>t.indexOf(e)===n).join("\n")}function iQ(e,n,t,r){this._e=iq(),this.failures=n,this.failedKeys=r,this.successCount=t,this.message=iX(e,n)}function i0(e,n){this._e=iq(),this.name="BulkError",this.failures=Object.keys(n).map(e=>n[e]),this.failuresByPos=n,this.message=iX(e,n)}ib(iJ).from(Error).extend({stack:{get:function(){return this._stack||(this._stack=this.name+": "+this.message+iH(this._e,2))}},toString:function(){return this.name+": "+this.message}}),ib(iQ).from(iJ),ib(i0).from(iJ);var i1=iY.reduce((e,n)=>(e[n]=n+"Error",e),{}),i2=iY.reduce((e,n)=>{var t=n+"Error";function r(e,r){this._e=iq(),this.name=t,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=iZ[n]||t,this.inner=null)}return ib(r).from(iJ),e[n]=r,e},{});i2.Syntax=SyntaxError,i2.Type=TypeError,i2.Range=RangeError;var i3=iK.reduce((e,n)=>(e[n+"Error"]=i2[n],e),{}),i5=iY.reduce((e,n)=>(-1===["Syntax","Type","Range"].indexOf(n)&&(e[n+"Error"]=i2[n]),e),{});function i4(){}function i6(e){return e}function i7(e,n){return null==e||e===i6?n:function(t){return n(e(t))}}function i8(e,n){return function(){e.apply(this,arguments),n.apply(this,arguments)}}function i9(e,n){return e===i4?n:function(){var t=e.apply(this,arguments);void 0!==t&&(arguments[0]=t);var r=this.onsuccess,o=this.onerror;this.onsuccess=null,this.onerror=null;var a=n.apply(this,arguments);return r&&(this.onsuccess=this.onsuccess?i8(r,this.onsuccess):r),o&&(this.onerror=this.onerror?i8(o,this.onerror):o),void 0!==a?a:t}}function se(e,n){return e===i4?n:function(){e.apply(this,arguments);var t=this.onsuccess,r=this.onerror;this.onsuccess=this.onerror=null,n.apply(this,arguments),t&&(this.onsuccess=this.onsuccess?i8(t,this.onsuccess):t),r&&(this.onerror=this.onerror?i8(r,this.onerror):r)}}function sn(e,n){return e===i4?n:function(t){var r=e.apply(this,arguments);ip(t,r);var o=this.onsuccess,a=this.onerror;this.onsuccess=null,this.onerror=null;var i=n.apply(this,arguments);return o&&(this.onsuccess=this.onsuccess?i8(o,this.onsuccess):o),a&&(this.onerror=this.onerror?i8(a,this.onerror):a),void 0===r?void 0===i?void 0:i:ip(r,i)}}function st(e,n){return e===i4?n:function(){return!1!==n.apply(this,arguments)&&e.apply(this,arguments)}}function sr(e,n){return e===i4?n:function(){var t=e.apply(this,arguments);if(t&&"function"==typeof t.then){for(var r=this,o=arguments.length,a=Array(o);o--;)a[o]=arguments[o];return t.then(function(){return n.apply(r,a)})}return n.apply(this,arguments)}}i5.ModifyError=iQ,i5.DexieError=iJ,i5.BulkError=i0;var so={};let[sa,si,ss]="u"<typeof Promise?[]:(()=>{let e=Promise.resolve();if("u"<typeof crypto||!crypto.subtle)return[e,iu(e),e];let n=crypto.subtle.digest("SHA-512",new Uint8Array([0]));return[n,iu(n),e]})(),sl=si&&si.then,sc=sa&&sa.constructor,sp=!!ss;var su=!1,sd=ss?()=>{ss.then(sT)}:is.setImmediate?setImmediate.bind(null,sT):is.MutationObserver?()=>{var e=document.createElement("div");new MutationObserver(()=>{sT(),e=null}).observe(e,{attributes:!0}),e.setAttribute("i","1")}:()=>{setTimeout(sT,0)},sf=function(e,n){sA.push([e,n]),sm&&(sd(),sm=!1)},sh=!0,sm=!0,sg=[],sy=[],sb=null,s_=i6,sv={id:"global",global:!0,ref:0,unhandleds:[],onunhandled:s3,pgp:!1,env:{},finalize:function(){this.unhandleds.forEach(e=>{try{s3(e[0],e[1])}catch(e){}})}},s$=sv,sA=[],sw=0,sk=[];function sx(e){if("object"!=typeof this)throw TypeError("Promises must be constructed via new");this._listeners=[],this.onuncatched=i4,this._lib=!1;var n=this._PSD=s$;if(iV&&(this._stackHolder=iq(),this._prev=null,this._numPrev=0),"function"!=typeof e){if(e!==so)throw TypeError("Not a function");return this._state=arguments[1],this._value=arguments[2],void(!1===this._state&&sS(this,this._value))}this._state=null,this._value=null,++n.ref,function e(n,t){try{t(t=>{if(null===n._state){if(t===n)throw TypeError("A promise cannot be resolved with itself.");var r=n._lib&&sO();t&&"function"==typeof t.then?e(n,(e,n)=>{t instanceof sx?t._then(e,n):t.then(e,n)}):(n._state=!0,n._value=t,sD(n)),r&&sN()}},sS.bind(null,n))}catch(e){sS(n,e)}}(this,e)}let sC={get:function(){var e=s$,n=sV;function t(t,r){var o=!e.global&&(e!==s$||n!==sV);let a=o&&!sH();var i=new sx((n,i)=>{sz(this,new sE(s0(t,e,o,a),s0(r,e,o,a),n,i,e))});return iV&&sP(i,this),i}return t.prototype=so,t},set:function(e){iy(this,"then",e&&e.prototype===so?sC:{get:function(){return e},set:sC.set})}};function sE(e,n,t,r,o){this.onFulfilled="function"==typeof e?e:null,this.onRejected="function"==typeof n?n:null,this.resolve=t,this.reject=r,this.psd=o}function sS(e,n){if(sy.push(n),null===e._state){var t=e._lib&&sO();n=s_(n),e._state=!1,e._value=n,iV&&null!==n&&"object"==typeof n&&!n._promise&&function(e){try{e.apply(null,void 0)}catch(e){}}(()=>{var t=iv(n,"stack");n._promise=e,iy(n,"stack",{get:()=>su?t&&(t.get?t.get.apply(n):t.value):e.stack})}),sg.some(n=>n._value===e._value)||sg.push(e),sD(e),t&&sN()}}function sD(e){var n=e._listeners;e._listeners=[];for(var t=0,r=n.length;t<r;++t)sz(e,n[t]);var o=e._PSD;--o.ref||o.finalize(),0===sw&&(++sw,sf(()=>{0==--sw&&sI()},[]))}function sz(e,n){if(null!==e._state){var t=e._state?n.onFulfilled:n.onRejected;if(null===t)return(e._state?n.resolve:n.reject)(e._value);++n.psd.ref,++sw,sf(sM,[t,e,n])}else e._listeners.push(n)}function sM(e,n,t){try{sb=n;var r,o=n._value;n._state?r=e(o):(sy.length&&(sy=[]),r=e(o),-1===sy.indexOf(o)&&function(e){for(var n=sg.length;n;)if(sg[--n]._value===e._value)return void sg.splice(n,1)}(n)),t.resolve(r)}catch(e){t.reject(e)}finally{sb=null,0==--sw&&sI(),--t.psd.ref||t.psd.finalize()}}function sP(e,n){var t=n?n._numPrev+1:0;t<100&&(e._prev=n,e._numPrev=t)}function sT(){sO()&&sN()}function sO(){var e=sh;return sh=!1,sm=!1,e}function sN(){var e,n,t;do for(;sA.length>0;)for(e=sA,sA=[],t=e.length,n=0;n<t;++n){var r=e[n];r[0].apply(null,r[1])}while(sA.length>0);sh=!0,sm=!0}function sI(){var e=sg;sg=[],e.forEach(e=>{e._PSD.onunhandled.call(null,e._value,e)});for(var n=sk.slice(0),t=n.length;t;)n[--t]()}function sB(e){return new sx(so,!1,e)}function sj(e,n){var t=s$;return function(){var r=sO(),o=s$;try{return sJ(t,!0),e.apply(this,arguments)}catch(e){n&&n(e)}finally{sJ(o,!1),r&&sN()}}}im(sx.prototype,{then:sC,_then:function(e,n){sz(this,new sE(null,null,e,n,s$))},catch:function(e){if(1==arguments.length)return this.then(null,e);var n=arguments[0],t=arguments[1];return"function"==typeof n?this.then(null,e=>e instanceof n?t(e):sB(e)):this.then(null,e=>e&&e.name===n?t(e):sB(e))},finally:function(e){return this.then(n=>(e(),n),n=>(e(),sB(n)))},stack:{get:function(){if(this._stack)return this._stack;try{su=!0;var e=(function e(n,t,r){if(t.length===r)return t;var o="";if(!1===n._state){var a,i,s=n._value;null!=s?(a=s.name||"Error",i=s.message||s,o=iH(s,0)):(a=s,i=""),t.push(a+(i?": "+i:"")+o)}return iV&&((o=iH(n._stackHolder,2))&&-1===t.indexOf(o)&&t.push(o),n._prev&&e(n._prev,t,r)),t})(this,[],20).join("\nFrom previous: ");return null!==this._state&&(this._stack=e),e}finally{su=!1}}},timeout:function(e,n){return e<1/0?new sx((t,r)=>{var o=setTimeout(()=>r(new i2.Timeout(n)),e);this.then(t,r).finally(clearTimeout.bind(null,o))}):this}}),"u">typeof Symbol&&Symbol.toStringTag&&iy(sx.prototype,Symbol.toStringTag,"Dexie.Promise"),sv.env=sX(),im(sx,{all:function(){var e=iL.apply(null,arguments).map(sK);return new sx(function(n,t){0===e.length&&n([]);var r=e.length;e.forEach((o,a)=>sx.resolve(o).then(t=>{e[a]=t,--r||n(e)},t))})},resolve:e=>{if(e instanceof sx)return e;if(e&&"function"==typeof e.then)return new sx((n,t)=>{e.then(n,t)});var n=new sx(so,!0,e);return sP(n,sb),n},reject:sB,race:function(){var e=iL.apply(null,arguments).map(sK);return new sx((n,t)=>{e.map(e=>sx.resolve(e).then(n,t))})},PSD:{get:()=>s$,set:e=>s$=e},totalEchoes:{get:()=>sV},newPSD:sU,usePSD:sQ,scheduler:{get:()=>sf,set:e=>{sf=e}},rejectionMapper:{get:()=>s_,set:e=>{s_=e}},follow:(e,n)=>new sx((t,r)=>sU((n,t)=>{var r=s$;r.unhandleds=[],r.onunhandled=t,r.finalize=i8(function(){var e;e=()=>{0===this.unhandleds.length?n():t(this.unhandleds[0])},sk.push(function n(){e(),sk.splice(sk.indexOf(n),1)}),++sw,sf(()=>{0==--sw&&sI()},[])},r.finalize),e()},n,t,r))}),sc&&(sc.allSettled&&iy(sx,"allSettled",function(){let e=iL.apply(null,arguments).map(sK);return new sx(n=>{0===e.length&&n([]);let t=e.length,r=Array(t);e.forEach((e,o)=>sx.resolve(e).then(e=>r[o]={status:"fulfilled",value:e},e=>r[o]={status:"rejected",reason:e}).then(()=>--t||n(r)))})}),sc.any&&"u">typeof AggregateError&&iy(sx,"any",function(){let e=iL.apply(null,arguments).map(sK);return new sx((n,t)=>{0===e.length&&t(AggregateError([]));let r=e.length,o=Array(r);e.forEach((e,a)=>sx.resolve(e).then(e=>n(e),e=>{o[a]=e,--r||t(AggregateError(o))}))})}));let sR={awaits:0,echoes:0,id:0};var sF=0,sL=[],sW=0,sV=0,sG=0;function sU(e,n,t,r){var o=s$,a=Object.create(o);a.parent=o,a.ref=0,a.global=!1,a.id=++sG;var i=sv.env;a.env=sp?{Promise:sx,PromiseProp:{value:sx,configurable:!0,writable:!0},all:sx.all,race:sx.race,allSettled:sx.allSettled,any:sx.any,resolve:sx.resolve,reject:sx.reject,nthen:s1(i.nthen,a),gthen:s1(i.gthen,a)}:{},n&&ip(a,n),++o.ref,a.finalize=function(){--this.parent.ref||this.parent.finalize()};var s=sQ(a,e,t,r);return 0===a.ref&&a.finalize(),s}function sq(){return sR.id||(sR.id=++sF),++sR.awaits,sR.echoes+=100,sR.id}function sH(){return!!sR.awaits&&(0==--sR.awaits&&(sR.id=0),sR.echoes=100*sR.awaits,!0)}function sK(e){return sR.echoes&&e&&e.constructor===sc?(sq(),e.then(e=>(sH(),e),e=>(sH(),s5(e)))):e}function sY(e){++sV,sR.echoes&&0!=--sR.echoes||(sR.echoes=sR.id=0),sL.push(s$),sJ(e,!0)}function sZ(){var e=sL[sL.length-1];sL.pop(),sJ(e,!1)}function sJ(e,n){var t,r=s$;if((n?!sR.echoes||sW++&&e===s$:!sW||--sW&&e===s$)||(t=n?sY.bind(null,e):sZ,sl.call(sa,t)),e!==s$&&(s$=e,r===sv&&(sv.env=sX()),sp)){var o=sv.env.Promise,a=e.env;si.then=a.nthen,o.prototype.then=a.gthen,(r.global||e.global)&&(Object.defineProperty(is,"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 sX(){var e=is.Promise;return sp?{Promise:e,PromiseProp:Object.getOwnPropertyDescriptor(is,"Promise"),all:e.all,race:e.race,allSettled:e.allSettled,any:e.any,resolve:e.resolve,reject:e.reject,nthen:si.then,gthen:e.prototype.then}:{}}function sQ(e,n,t,r,o){var a=s$;try{return sJ(e,!0),n(t,r,o)}finally{sJ(a,!1)}}function s0(e,n,t,r){return"function"!=typeof e?e:function(){var o,a=s$;t&&sq(),sJ(n,!0);try{return e.apply(this,arguments)}finally{sJ(a,!1),r&&(o=sH,sl.call(sa,o))}}}function s1(e,n){return function(t,r){return e.call(this,s0(t,n),s0(r,n))}}-1===(""+sl).indexOf("[native code]")&&(sq=sH=i4);let s2="unhandledrejection";function s3(e,n){var t;try{t=n.onuncatched(e)}catch(e){}if(!1!==t)try{var r,o={promise:n,reason:e};if(is.document&&document.createEvent?((r=document.createEvent("Event")).initEvent(s2,!0,!0),ip(r,o)):is.CustomEvent&&ip(r=new CustomEvent(s2,{detail:o}),o),r&&is.dispatchEvent&&(dispatchEvent(r),!is.PromiseRejectionEvent&&is.onunhandledrejection))try{is.onunhandledrejection(r)}catch(e){}iV&&r&&!r.defaultPrevented&&console.warn(`Unhandled rejection: ${e.stack||e}`)}catch(e){}}var s5=sx.reject;let s4="3.2.4",s6=String.fromCharCode(65535),s7=-1/0,s8="Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.",s9="String expected.",le=[],ln="u">typeof navigator&&/(MSIE|Trident|Edge)/.test(navigator.userAgent),lt=e=>!/(dexie\.js|dexie\.min\.js)/.test(e),lr="__dbnames",lo="readonly",la="readwrite";function li(e,n){return e?n?function(){return e.apply(this,arguments)&&n.apply(this,arguments)}:e:n}let ls={type:3,lower:-1/0,lowerOpen:!1,upper:[[]],upperOpen:!1};function ll(e){return"string"!=typeof e||/\./.test(e)?e=>e:n=>(void 0===n[e]&&e in n&&delete(n=iN(n))[e],n)}class lc{_trans(e,n,t){let r=this._tx||s$.trans,o=this.name;function a(e,t,r){if(!r.schema[o])throw new i2.NotFound("Table "+o+" not part of transaction");return n(r.idbtrans,r)}let i=sO();try{return r&&r.db===this.db?r===s$.trans?r._promise(e,a,t):sU(()=>r._promise(e,a,t),{trans:r,transless:s$.transless||s$}):function e(n,t,r,o){if(n.idbdb&&(n._state.openComplete||s$.letThrough||n._vip)){var a=n._createTransaction(t,r,n._dbSchema);try{a.create(),n._state.PR1398_maxLoop=3}catch(a){return a.name===i1.InvalidState&&n.isOpen()&&--n._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),n._close(),n.open().then(()=>e(n,t,r,o))):s5(a)}return a._promise(t,(e,n)=>sU(()=>(s$.trans=a,o(e,n,a)))).then(e=>a._completion.then(()=>e))}if(n._state.openComplete)return s5(new i2.DatabaseClosed(n._state.dbOpenError));if(!n._state.isBeingOpened){if(!n._options.autoOpen)return s5(new i2.DatabaseClosed);n.open().catch(i4)}return n._state.dbReadyPromise.then(()=>e(n,t,r,o))}(this.db,e,[this.name],a)}finally{i&&sN()}}get(e,n){return e&&e.constructor===Object?this.where(e).first(n):this._trans("readonly",n=>this.core.get({trans:n,key:e}).then(e=>this.hook.reading.fire(e))).then(n)}where(e){if("string"==typeof e)return new this.db.WhereClause(this,e);if(ic(e))return new this.db.WhereClause(this,`[${e.join("+")}]`);let n=il(e);if(1===n.length)return this.where(n[0]).equals(e[n[0]]);let t=this.schema.indexes.concat(this.schema.primKey).filter(e=>e.compound&&n.every(n=>e.keyPath.indexOf(n)>=0)&&e.keyPath.every(e=>n.indexOf(e)>=0))[0];if(t&&this.db._maxKey!==s6)return this.where(t.name).equals(t.keyPath.map(n=>e[n]));!t&&iV&&console.warn(`The query ${JSON.stringify(e)} on ${this.name} would benefit of a compound index [${n.join("+")}]`);let{idxByName:r}=this.schema,o=this.db._deps.indexedDB;function a(e,n){try{return 0===o.cmp(e,n)}catch(e){return!1}}let[i,s]=n.reduce(([n,t],o)=>{let i=r[o],s=e[o];return[n||i,n||!i?li(t,i&&i.multi?e=>{let n=iE(e,o);return ic(n)&&n.some(e=>a(s,e))}:e=>a(s,iE(e,o))):t]},[null,null]);return i?this.where(i.name).equals(e[i.keyPath]).filter(s):t?this.filter(s):this.where(n).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,ic(e)?`[${e.join("+")}]`:e))}reverse(){return this.toCollection().reverse()}mapToClass(e){this.schema.mappedClass=e;let n=n=>{if(!n)return n;let t=Object.create(e.prototype);for(var r in n)if(ih(n,r))try{t[r]=n[r]}catch(e){}return t};return this.schema.readHook&&this.hook.reading.unsubscribe(this.schema.readHook),this.schema.readHook=n,this.hook("reading",n),e}defineClass(){return this.mapToClass(function(e){ip(this,e)})}add(e,n){let{auto:t,keyPath:r}=this.schema.primKey,o=e;return r&&t&&(o=ll(r)(e)),this._trans("readwrite",e=>this.core.mutate({trans:e,type:"add",keys:null!=n?[n]:null,values:[o]})).then(e=>e.numFailures?sx.reject(e.failures[0]):e.lastResult).then(n=>{if(r)try{iS(e,r,n)}catch(e){}return n})}update(e,n){if("object"!=typeof e||ic(e))return this.where(":id").equals(e).modify(n);{let t=iE(e,this.schema.primKey.keyPath);if(void 0===t)return s5(new i2.InvalidArgument("Given object does not contain its primary key"));try{"function"!=typeof n?il(n).forEach(t=>{iS(e,t,n[t])}):n(e,{value:e,primKey:t})}catch(e){}return this.where(":id").equals(t).modify(n)}}put(e,n){let{auto:t,keyPath:r}=this.schema.primKey,o=e;return r&&t&&(o=ll(r)(e)),this._trans("readwrite",e=>this.core.mutate({trans:e,type:"put",values:[o],keys:null!=n?[n]:null})).then(e=>e.numFailures?sx.reject(e.failures[0]):e.lastResult).then(n=>{if(r)try{iS(e,r,n)}catch(e){}return n})}delete(e){return this._trans("readwrite",n=>this.core.mutate({trans:n,type:"delete",keys:[e]})).then(e=>e.numFailures?sx.reject(e.failures[0]):void 0)}clear(){return this._trans("readwrite",e=>this.core.mutate({trans:e,type:"deleteRange",range:ls})).then(e=>e.numFailures?sx.reject(e.failures[0]):void 0)}bulkGet(e){return this._trans("readonly",n=>this.core.getMany({keys:e,trans:n}).then(e=>e.map(e=>this.hook.reading.fire(e))))}bulkAdd(e,n,t){let r=Array.isArray(n)?n:void 0,o=(t=t||(r?void 0:n))?t.allKeys:void 0;return this._trans("readwrite",n=>{let{auto:t,keyPath:a}=this.schema.primKey;if(a&&r)throw new i2.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(r&&r.length!==e.length)throw new i2.InvalidArgument("Arguments objects and keys must have the same length");let i=e.length,s=a&&t?e.map(ll(a)):e;return this.core.mutate({trans:n,type:"add",keys:r,values:s,wantResults:o}).then(({numFailures:e,results:n,lastResult:t,failures:r})=>{if(0===e)return o?n:t;throw new i0(`${this.name}.bulkAdd(): ${e} of ${i} operations failed`,r)})})}bulkPut(e,n,t){let r=Array.isArray(n)?n:void 0,o=(t=t||(r?void 0:n))?t.allKeys:void 0;return this._trans("readwrite",n=>{let{auto:t,keyPath:a}=this.schema.primKey;if(a&&r)throw new i2.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(r&&r.length!==e.length)throw new i2.InvalidArgument("Arguments objects and keys must have the same length");let i=e.length,s=a&&t?e.map(ll(a)):e;return this.core.mutate({trans:n,type:"put",keys:r,values:s,wantResults:o}).then(({numFailures:e,results:n,lastResult:t,failures:r})=>{if(0===e)return o?n:t;throw new i0(`${this.name}.bulkPut(): ${e} of ${i} operations failed`,r)})})}bulkDelete(e){let n=e.length;return this._trans("readwrite",n=>this.core.mutate({trans:n,type:"delete",keys:e})).then(({numFailures:e,lastResult:t,failures:r})=>{if(0===e)return t;throw new i0(`${this.name}.bulkDelete(): ${e} of ${n} operations failed`,r)})}}function lp(e){var n={},t=function(t,r){if(r){for(var o=arguments.length,a=Array(o-1);--o;)a[o-1]=arguments[o];return n[t].subscribe.apply(null,a),e}if("string"==typeof t)return n[t]};t.addEventType=a;for(var r=1,o=arguments.length;r<o;++r)a(arguments[r]);return t;function a(e,r,o){if("object"!=typeof e){r||(r=st),o||(o=i4);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(n){return n!==e}),i.fire=i.subscribers.reduce(r,o)}};return n[e]=t[e]=i,i}il(e).forEach(function(n){var t=e[n];if(ic(t))a(n,e[n][0],e[n][1]);else{if("asap"!==t)throw new i2.InvalidArgument("Invalid event config");var r=a(n,i6,function(){for(var e=arguments.length,n=Array(e);e--;)n[e]=arguments[e];r.subscribers.forEach(function(e){ix(function(){e.apply(null,n)})})})}})}}function lu(e,n){return ib(n).from({prototype:e}),n}function ld(e,n){return!(e.filter||e.algorithm||e.or)&&(n?e.justLimit:!e.replayFilter)}function lf(e,n){e.filter=li(e.filter,n)}function lh(e,n,t){var r=e.replayFilter;e.replayFilter=r?()=>li(r(),n()):n,e.justLimit=t&&!r}function lm(e,n){if(e.isPrimKey)return n.primaryKey;let t=n.getIndexByKeyPath(e.index);if(!t)throw new i2.Schema("KeyPath "+e.index+" on object store "+n.name+" is not indexed");return t}function lg(e,n,t){let r=lm(e,n.schema);return n.openCursor({trans:t,values:!e.keysOnly,reverse:"prev"===e.dir,unique:!!e.unique,query:{index:r,range:e.range}})}function ly(e,n,t,r){let o=e.replayFilter?li(e.filter,e.replayFilter()):e.filter;if(e.or){let a={},i=(e,t,r)=>{if(!o||o(t,r,e=>t.stop(e),e=>t.fail(e))){var i=t.primaryKey,s=""+i;"[object ArrayBuffer]"===s&&(s=""+new Uint8Array(i)),ih(a,s)||(a[s]=!0,n(e,t,r))}};return Promise.all([e.or._iterate(i,t),lb(lg(e,r,t),e.algorithm,i,!e.keysOnly&&e.valueMapper)])}return lb(lg(e,r,t),li(e.algorithm,o),n,!e.keysOnly&&e.valueMapper)}function lb(e,n,t,r){var o=sj(r?(e,n,o)=>t(r(e),n,o):t);return e.then(e=>{if(e)return e.start(()=>{var t=()=>e.continue();n&&!n(e,e=>t=e,n=>{e.stop(n),t=i4},n=>{e.fail(n),t=i4})||o(e.value,e,e=>t=e),t()})})}function l_(e,n){try{let t=lv(e),r=lv(n);if(t!==r)return"Array"===t?1:"Array"===r?-1:"binary"===t?1:"binary"===r?-1:"string"===t?1:"string"===r?-1:"Date"===t?1:"Date"!==r?NaN:-1;switch(t){case"number":case"Date":case"string":return e>n?1:e<n?-1:0;case"binary":return function(e,n){let t=e.length,r=n.length,o=t<r?t:r;for(let t=0;t<o;++t)if(e[t]!==n[t])return e[t]<n[t]?-1:1;return t===r?0:t<r?-1:1}(l$(e),l$(n));case"Array":return function(e,n){let t=e.length,r=n.length,o=t<r?t:r;for(let t=0;t<o;++t){let r=l_(e[t],n[t]);if(0!==r)return r}return t===r?0:t<r?-1:1}(e,n)}}catch(e){}return NaN}function lv(e){let n=typeof e;if("object"!==n)return n;if(ArrayBuffer.isView(e))return"binary";let t=iB(e);return"ArrayBuffer"===t?"binary":t}function l$(e){return e instanceof Uint8Array?e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e)}class lA{_read(e,n){var t=this._ctx;return t.error?t.table._trans(null,s5.bind(null,t.error)):t.table._trans("readonly",e).then(n)}_write(e){var n=this._ctx;return n.error?n.table._trans(null,s5.bind(null,n.error)):n.table._trans("readwrite",e,"locked")}_addAlgorithm(e){var n=this._ctx;n.algorithm=li(n.algorithm,e)}_iterate(e,n){return ly(this._ctx,e,n,this._ctx.table.core)}clone(e){var n=Object.create(this.constructor.prototype),t=Object.create(this._ctx);return e&&ip(t,e),n._ctx=t,n}raw(){return this._ctx.valueMapper=null,this}each(e){var n=this._ctx;return this._read(t=>ly(n,e,t,n.table.core))}count(e){return this._read(e=>{let n=this._ctx,t=n.table.core;if(ld(n,!0))return t.count({trans:e,query:{index:lm(n,t.schema),range:n.range}}).then(e=>Math.min(e,n.limit));var r=0;return ly(n,()=>(++r,!1),e,t).then(()=>r)}).then(e)}sortBy(e,n){let t=e.split(".").reverse(),r=t[0],o=t.length-1;function a(e,n){return n?a(e[t[n]],n-1):e[r]}var i="next"===this._ctx.dir?1:-1;function s(e,n){var t=a(e,o),r=a(n,o);return t<r?-i:t>r?i:0}return this.toArray(function(e){return e.sort(s)}).then(n)}toArray(e){return this._read(e=>{var n=this._ctx;if("next"===n.dir&&ld(n,!0)&&n.limit>0){let{valueMapper:t}=n,r=lm(n,n.table.core.schema);return n.table.core.query({trans:e,limit:n.limit,values:!0,query:{index:r,range:n.range}}).then(({result:e})=>t?e.map(t):e)}{let t=[];return ly(n,e=>t.push(e),e,n.table.core).then(()=>t)}},e)}offset(e){var n=this._ctx;return e<=0||(n.offset+=e,ld(n)?lh(n,()=>{var n=e;return(e,t)=>0===n||(1===n?--n:t(()=>{e.advance(n),n=0}),!1)}):lh(n,()=>{var n=e;return()=>--n<0})),this}limit(e){return this._ctx.limit=Math.min(this._ctx.limit,e),lh(this._ctx,()=>{var n=e;return function(e,t,r){return--n<=0&&t(r),n>=0}},!0),this}until(e,n){return lf(this._ctx,function(t,r,o){return!e(t.value)||(r(o),n)}),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 n;return lf(this._ctx,function(n){return e(n.value)}),(n=this._ctx).isMatch=li(n.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 n=this._ctx;return n.keysOnly=!n.isMatch,this.each(function(n,t){e(t.key,t)})}eachUniqueKey(e){return this._ctx.unique="unique",this.eachKey(e)}eachPrimaryKey(e){var n=this._ctx;return n.keysOnly=!n.isMatch,this.each(function(n,t){e(t.primaryKey,t)})}keys(e){var n=this._ctx;n.keysOnly=!n.isMatch;var t=[];return this.each(function(e,n){t.push(n.key)}).then(function(){return t}).then(e)}primaryKeys(e){var n=this._ctx;if("next"===n.dir&&ld(n,!0)&&n.limit>0)return this._read(e=>{var t=lm(n,n.table.core.schema);return n.table.core.query({trans:e,values:!1,limit:n.limit,query:{index:t,range:n.range}})}).then(({result:e})=>e).then(e);n.keysOnly=!n.isMatch;var t=[];return this.each(function(e,n){t.push(n.primaryKey)}).then(function(){return t}).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,n=e.index&&e.table.schema.idxByName[e.index];if(!n||!n.multi)return this;var t={};return lf(this._ctx,function(e){var n=e.primaryKey.toString(),r=ih(t,n);return t[n]=!0,!r}),this}modify(e){var n=this._ctx;return this._write(t=>{var r;if("function"==typeof e)r=e;else{var o=il(e),a=o.length;r=function(n){for(var t=!1,r=0;r<a;++r){var i=o[r],s=e[i];iE(n,i)!==s&&(iS(n,i,s),t=!0)}return t}}let i=n.table.core,{outbound:s,extractKey:l}=i.schema.primaryKey,c=this.db._options.modifyChunkSize||200,p=[],u=0,d=[],f=(e,n)=>{let{failures:t,numFailures:r}=n;for(let n of(u+=e-r,il(t)))p.push(t[n])};return this.clone().primaryKeys().then(o=>{let a=p=>{let u=Math.min(c,o.length-p);return i.getMany({trans:t,keys:o.slice(p,p+u),cache:"immutable"}).then(d=>{let h=[],m=[],g=s?[]:null,y=[];for(let e=0;e<u;++e){let n=d[e],t={value:iN(n),primKey:o[p+e]};!1!==r.call(t,t.value,t)&&(null==t.value?y.push(o[p+e]):s||0===l_(l(n),l(t.value))?(m.push(t.value),s&&g.push(o[p+e])):(y.push(o[p+e]),h.push(t.value)))}let b=ld(n)&&n.limit===1/0&&("function"!=typeof e||e===lw)&&{index:n.index,range:n.range};return Promise.resolve(h.length>0&&i.mutate({trans:t,type:"add",values:h}).then(e=>{for(let n in e.failures)y.splice(parseInt(n),1);f(h.length,e)})).then(()=>(m.length>0||b&&"object"==typeof e)&&i.mutate({trans:t,type:"put",keys:g,values:m,criteria:b,changeSpec:"function"!=typeof e&&e}).then(e=>f(m.length,e))).then(()=>(y.length>0||b&&e===lw)&&i.mutate({trans:t,type:"delete",keys:y,criteria:b}).then(e=>f(y.length,e))).then(()=>o.length>p+u&&a(p+c))})};return a(0).then(()=>{if(p.length>0)throw new iQ("Error modifying one or more objects",p,u,d);return o.length})})})}delete(){var e=this._ctx,n=e.range;return ld(e)&&(e.isPrimKey&&!ln||3===n.type)?this._write(t=>{let{primaryKey:r}=e.table.core.schema;return e.table.core.count({trans:t,query:{index:r,range:n}}).then(r=>e.table.core.mutate({trans:t,type:"deleteRange",range:n}).then(({failures:e,lastResult:n,results:t,numFailures:o})=>{if(o)throw new iQ("Could not delete some values",Object.keys(e).map(n=>e[n]),r-o);return r-o}))}):this.modify(lw)}}let lw=(e,n)=>n.value=null;function lk(e,n){return e<n?-1:+(e!==n)}function lx(e,n){return e>n?-1:+(e!==n)}function lC(e,n,t){var r=e instanceof lM?new e.Collection(e):e;return r._ctx.error=t?new t(n):TypeError(n),r}function lE(e){return new e.Collection(e,()=>lz("")).limit(0)}function lS(e,n,t,r){var o,a,i,s,l,c,p,u=t.length;if(!t.every(e=>"string"==typeof e))return lC(e,s9);function d(e){o="next"===e?e=>e.toUpperCase():e=>e.toLowerCase(),a="next"===e?e=>e.toLowerCase():e=>e.toUpperCase(),i="next"===e?lk:lx;var n=t.map(function(e){return{lower:a(e),upper:o(e)}}).sort(function(e,n){return i(e.lower,n.lower)});s=n.map(function(e){return e.upper}),l=n.map(function(e){return e.lower}),c=e,p="next"===e?"":r}d("next");var f=new e.Collection(e,()=>lD(s[0],l[u-1]+r));f._ondirectionchange=function(e){d(e)};var h=0;return f._addAlgorithm(function(e,t,r){var o=e.key;if("string"!=typeof o)return!1;var d=a(o);if(n(d,l,h))return!0;for(var f=null,m=h;m<u;++m){var g=function(e,n,t,r,o,a){for(var i=Math.min(e.length,r.length),s=-1,l=0;l<i;++l){var c=n[l];if(c!==r[l])return 0>o(e[l],t[l])?e.substr(0,l)+t[l]+t.substr(l+1):0>o(e[l],r[l])?e.substr(0,l)+r[l]+t.substr(l+1):s>=0?e.substr(0,s)+n[s]+t.substr(s+1):null;0>o(e[l],c)&&(s=l)}return i<r.length&&"next"===a?e+t.substr(e.length):i<e.length&&"prev"===a?e.substr(0,t.length):s<0?null:e.substr(0,s)+r[s]+t.substr(s+1)}(o,d,s[m],l[m],i,c);null===g&&null===f?h=m+1:(null===f||i(f,g)>0)&&(f=g)}return t(null!==f?function(){e.continue(f+p)}:r),!1}),f}function lD(e,n,t,r){return{type:2,lower:e,upper:n,lowerOpen:t,upperOpen:r}}function lz(e){return{type:1,lower:e,upper:e}}class lM{get Collection(){return this._ctx.table.db.Collection}between(e,n,t,r){t=!1!==t,r=!0===r;try{return this._cmp(e,n)>0||0===this._cmp(e,n)&&(t||r)&&(!t||!r)?lE(this):new this.Collection(this,()=>lD(e,n,!t,!r))}catch(e){return lC(this,s8)}}equals(e){return null==e?lC(this,s8):new this.Collection(this,()=>lz(e))}above(e){return null==e?lC(this,s8):new this.Collection(this,()=>lD(e,void 0,!0))}aboveOrEqual(e){return null==e?lC(this,s8):new this.Collection(this,()=>lD(e,void 0,!1))}below(e){return null==e?lC(this,s8):new this.Collection(this,()=>lD(void 0,e,!1,!0))}belowOrEqual(e){return null==e?lC(this,s8):new this.Collection(this,()=>lD(void 0,e))}startsWith(e){return"string"!=typeof e?lC(this,s9):this.between(e,e+s6,!0,!0)}startsWithIgnoreCase(e){return""===e?this.startsWith(e):lS(this,(e,n)=>0===e.indexOf(n[0]),[e],s6)}equalsIgnoreCase(e){return lS(this,(e,n)=>e===n[0],[e],"")}anyOfIgnoreCase(){var e=iL.apply(iF,arguments);return 0===e.length?lE(this):lS(this,(e,n)=>-1!==n.indexOf(e),e,"")}startsWithAnyOfIgnoreCase(){var e=iL.apply(iF,arguments);return 0===e.length?lE(this):lS(this,(e,n)=>n.some(n=>0===e.indexOf(n)),e,s6)}anyOf(){let e=iL.apply(iF,arguments),n=this._cmp;try{e.sort(n)}catch(e){return lC(this,s8)}if(0===e.length)return lE(this);let t=new this.Collection(this,()=>lD(e[0],e[e.length-1]));t._ondirectionchange=t=>{n="next"===t?this._ascending:this._descending,e.sort(n)};let r=0;return t._addAlgorithm((t,o,a)=>{let i=t.key;for(;n(i,e[r])>0;)if(++r===e.length)return o(a),!1;return 0===n(i,e[r])||(o(()=>{t.continue(e[r])}),!1)}),t}notEqual(e){return this.inAnyRange([[s7,e],[e,this.db._maxKey]],{includeLowers:!1,includeUppers:!1})}noneOf(){let e=iL.apply(iF,arguments);if(0===e.length)return new this.Collection(this);try{e.sort(this._ascending)}catch(e){return lC(this,s8)}let n=e.reduce((e,n)=>e?e.concat([[e[e.length-1][1],n]]):[[s7,n]],null);return n.push([e[e.length-1],this.db._maxKey]),this.inAnyRange(n,{includeLowers:!1,includeUppers:!1})}inAnyRange(e,n){let t=this._cmp,r=this._ascending,o=this._descending,a=this._min,i=this._max;if(0===e.length)return lE(this);if(!e.every(e=>void 0!==e[0]&&void 0!==e[1]&&0>=r(e[0],e[1])))return lC(this,"First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower",i2.InvalidArgument);let s=!n||!1!==n.includeLowers,l=n&&!0===n.includeUppers,c,p=r;function u(e,n){return p(e[0],n[0])}try{(c=e.reduce(function(e,n){let r=0,o=e.length;for(;r<o;++r){let o=e[r];if(0>t(n[0],o[1])&&t(n[1],o[0])>0){o[0]=a(o[0],n[0]),o[1]=i(o[1],n[1]);break}}return r===o&&e.push(n),e},[])).sort(u)}catch(e){return lC(this,s8)}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,g=new this.Collection(this,()=>lD(c[0][0],c[c.length-1][1],!s,!l));return g._ondirectionchange=e=>{"next"===e?(m=f,p=r):(m=h,p=o),c.sort(u)},g._addAlgorithm((e,n,t)=>{for(var o=e.key;m(o);)if(++d===c.length)return n(t),!1;return!!(!f(o)&&!h(o))||(0===this._cmp(o,c[d][1])||0===this._cmp(o,c[d][0])||n(()=>{p===r?e.continue(c[d][0]):e.continue(c[d][1])}),!1)}),g}startsWithAnyOf(){let e=iL.apply(iF,arguments);return e.every(e=>"string"==typeof e)?0===e.length?lE(this):this.inAnyRange(e.map(e=>[e,e+s6])):lC(this,"startsWithAnyOf() only works with strings")}}function lP(e){return sj(function(n){return lT(n),e(n.target.error),!1})}function lT(e){e.stopPropagation&&e.stopPropagation(),e.preventDefault&&e.preventDefault()}let lO="storagemutated",lN="x-storagemutated-1",lI=lp(null,lO);class lB{_lock(){return ik(!s$.global),++this._reculock,1!==this._reculock||s$.global||(s$.lockOwnerFor=this),this}_unlock(){if(ik(!s$.global),0==--this._reculock)for(s$.global||(s$.lockOwnerFor=null);this._blockedFuncs.length>0&&!this._locked();){var e=this._blockedFuncs.shift();try{sQ(e[1],e[0])}catch(e){}}return this}_locked(){return this._reculock&&s$.lockOwnerFor!==this}create(e){if(!this.mode)return this;let n=this.db.idbdb,t=this.db._state.dbOpenError;if(ik(!this.idbtrans),!e&&!n)switch(t&&t.name){case"DatabaseClosedError":throw new i2.DatabaseClosed(t);case"MissingAPIError":throw new i2.MissingAPI(t.message,t);default:throw new i2.OpenFailed(t)}if(!this.active)throw new i2.TransactionInactive;return ik(null===this._completion._state),(e=this.idbtrans=e||(this.db.core?this.db.core.transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability}):n.transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability}))).onerror=sj(n=>{lT(n),this._reject(e.error)}),e.onabort=sj(n=>{lT(n),this.active&&this._reject(new i2.Abort(e.error)),this.active=!1,this.on("abort").fire(n)}),e.oncomplete=sj(()=>{this.active=!1,this._resolve(),"mutatedParts"in e&&lI.storagemutated.fire(e.mutatedParts)}),this}_promise(e,n,t){if("readwrite"===e&&"readwrite"!==this.mode)return s5(new i2.ReadOnly("Transaction is readonly"));if(!this.active)return s5(new i2.TransactionInactive);if(this._locked())return new sx((r,o)=>{this._blockedFuncs.push([()=>{this._promise(e,n,t).then(r,o)},s$])});if(t)return sU(()=>{var e=new sx((e,t)=>{this._lock();let r=n(e,t,this);r&&r.then&&r.then(e,t)});return e.finally(()=>this._unlock()),e._lib=!0,e});var r=new sx((e,t)=>{var r=n(e,t,this);r&&r.then&&r.then(e,t)});return r._lib=!0,r}_root(){return this.parent?this.parent._root():this}waitFor(e){var n=this._root();let t=sx.resolve(e);if(n._waitingFor)n._waitingFor=n._waitingFor.then(()=>t);else{n._waitingFor=t,n._waitingQueue=[];var r=n.idbtrans.objectStore(n.storeNames[0]);!function e(){for(++n._spinCount;n._waitingQueue.length;)n._waitingQueue.shift()();n._waitingFor&&(r.get(-1/0).onsuccess=e)}()}var o=n._waitingFor;return new sx((e,r)=>{t.then(t=>n._waitingQueue.push(sj(e.bind(null,t))),e=>n._waitingQueue.push(sj(r.bind(null,e)))).finally(()=>{n._waitingFor===o&&(n._waitingFor=null)})})}abort(){this.active&&(this.active=!1,this.idbtrans&&this.idbtrans.abort(),this._reject(new i2.Abort))}table(e){let n=this._memoizedTables||(this._memoizedTables={});if(ih(n,e))return n[e];let t=this.schema[e];if(!t)throw new i2.NotFound("Table "+e+" not part of transaction");let r=new this.db.Table(e,t,this);return r.core=this.db.core.table(e),n[e]=r,r}}function lj(e,n,t,r,o,a,i){return{name:e,keyPath:n,unique:t,multi:r,auto:o,compound:a,src:(t&&!i?"&":"")+(r?"*":"")+(o?"++":"")+lR(n)}}function lR(e){return"string"==typeof e?e:e?"["+[].join.call(e,"+")+"]":""}function lF(e,n,t){return{name:e,primKey:n,indexes:t,mappedClass:null,idxByName:iC(t,e=>[e.name,e])}}let lL=e=>{try{return e.only([[]]),lL=()=>[[]],[[]]}catch(e){return lL=()=>s6,s6}};function lW(e){return null==e?()=>{}:"string"==typeof e?1===e.split(".").length?n=>n[e]:n=>iE(n,e):n=>iE(n,e)}function lV(e){return[].slice.call(e)}let lG=0;function lU(e){return null==e?":id":"string"==typeof e?e:`[${e.join("+")}]`}function lq({_novip:e},n){let t=n.db,r=function(e,n,{IDBKeyRange:t,indexedDB:r},o){var a;return{dbcore:(a=function(e,n,t){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:t,upper:r,lowerOpen:o,upperOpen:a}=e;return void 0===t?void 0===r?null:n.upperBound(r,!!a):void 0===r?n.lowerBound(t,!!o):n.bound(t,r,!!o,!!a)}let{schema:a,hasGetAll:i}=(r=lV(e.objectStoreNames),{schema:{name:e.name,tables:r.map(e=>t.objectStore(e)).map(e=>{let{keyPath:n,autoIncrement:t}=e,r=ic(n),o=null==n,a={},i={name:e.name,primaryKey:{name:null,isPrimaryKey:!0,outbound:o,compound:r,keyPath:n,autoIncrement:t,unique:!0,extractKey:lW(n)},indexes:lV(e.indexNames).map(n=>e.index(n)).map(e=>{let{name:n,unique:t,multiEntry:r,keyPath:o}=e,i={name:n,compound:ic(o),keyPath:o,unique:t,multiEntry:r,extractKey:lW(o)};return a[lU(o)]=i,i}),getIndexByKeyPath:e=>a[lU(e)]};return a[":id"]=i.primaryKey,null!=n&&(a[lU(n)]=i.primaryKey),i})},hasGetAll:r.length>0&&"getAll"in t.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 n;return{name:n=e.name,schema:e,mutate:function({trans:e,type:t,keys:r,values:a,range:i}){return new Promise((s,l)=>{let c;s=sj(s);let p=e.objectStore(n),u=null==p.keyPath,d="put"===t||"add"===t;if(!d&&"delete"!==t&&"deleteRange"!==t)throw Error("Invalid operation type: "+t);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=[],g=0,y=e=>{++g,lT(e)};if("deleteRange"===t){if(4===i.type)return s({numFailures:g,failures:m,results:[],lastResult:void 0});3===i.type?h.push(c=p.clear()):h.push(c=p.delete(o(i)))}else{let[e,n]=d?u?[a,r]:[a,null]:[r,null];if(d)for(let r=0;r<f;++r)h.push(c=n&&void 0!==n[r]?p[t](e[r],n[r]):p[t](e[r])),c.onerror=y;else for(let n=0;n<f;++n)h.push(c=p[t](e[n])),c.onerror=y}let b=e=>{let n=e.target.result;h.forEach((e,n)=>null!=e.error&&(m[n]=e.error)),s({numFailures:g,failures:m,results:"delete"===t?r:h.map(e=>e.result),lastResult:n})};c.onerror=e=>{y(e),b(e)},c.onsuccess=b})},getMany:({trans:e,keys:t})=>new Promise((r,o)=>{r=sj(r);let a=e.objectStore(n),i=t.length,s=Array(i),l,c=0,p=0,u=e=>{let n=e.target;s[n._pos]=n.result,++p===c&&r(s)},d=lP(o);for(let e=0;e<i;++e)null!=t[e]&&((l=a.get(t[e]))._pos=e,l.onsuccess=u,l.onerror=d,++c);0===c&&r(s)}),get:({trans:e,key:t})=>new Promise((r,o)=>{r=sj(r);let a=e.objectStore(n).get(t);a.onsuccess=e=>r(e.target.result),a.onerror=lP(o)}),query:e=>new Promise((t,r)=>{t=sj(t);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(n),h=u.isPrimaryKey?f:f.index(u.name),m=o(d);if(0===l)return t({result:[]});if(i){let e=s?h.getAll(m,p):h.getAllKeys(m,p);e.onsuccess=e=>t({result:e.target.result}),e.onerror=lP(r)}else{let e=0,n=!s&&"openKeyCursor"in h?h.openKeyCursor(m):h.openCursor(m),o=[];n.onsuccess=r=>{let a=n.result;return a?(o.push(s?a.value:a.primaryKey),++e===l?t({result:o}):void a.continue()):t({result:o})},n.onerror=lP(r)}}),openCursor:function({trans:e,values:t,query:r,reverse:a,unique:i}){return new Promise((s,l)=>{s=sj(s);let{index:c,range:p}=r,u=e.objectStore(n),d=c.isPrimaryKey?u:u.index(c.name),f=a?i?"prevunique":"prev":i?"nextunique":"next",h=!t&&"openKeyCursor"in d?d.openKeyCursor(o(p),f):d.openCursor(o(p),f);h.onerror=lP(l),h.onsuccess=sj(n=>{let t=h.result;if(!t)return void s(null);t.___id=++lG,t.done=!1;let r=t.continue.bind(t),o=t.continuePrimaryKey;o&&(o=o.bind(t));let a=t.advance.bind(t),i=()=>{throw Error("Cursor not stopped")};t.trans=e,t.stop=t.continue=t.continuePrimaryKey=t.advance=()=>{throw Error("Cursor not started")},t.fail=sj(l),t.next=function(){let e=1;return this.start(()=>e--?this.continue():this.stop()).then(()=>this)},t.start=e=>{let n=new Promise((e,n)=>{e=sj(e),h.onerror=lP(n),t.fail=n,t.stop=n=>{t.stop=t.continue=t.continuePrimaryKey=t.advance=i,e(n)}}),s=()=>{if(h.result)try{e()}catch(e){t.fail(e)}else t.done=!0,t.start=()=>{throw Error("Cursor behind last entry")},t.stop()};return h.onsuccess=sj(e=>{h.onsuccess=s,s()}),t.continue=r,t.continuePrimaryKey=o,t.advance=a,s(),n},s(t)},l)})},count({query:e,trans:t}){let{index:r,range:a}=e;return new Promise((e,i)=>{let s=t.objectStore(n),l=r.isPrimaryKey?s:s.index(r.name),c=o(a),p=c?l.count(c):l.count();p.onsuccess=sj(n=>e(n.target.result)),p.onerror=lP(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:lL(n),schema:a}}(n,t,o),e.dbcore.reduce((e,{create:n})=>({...e,...n(e)}),a))}}(e._middlewares,t,e._deps,n);e.core=r.dbcore,e.tables.forEach(n=>{let t=n.name;e.core.schema.tables.some(e=>e.name===t)&&(n.core=e.core.table(t),e[t]instanceof e.Table&&(e[t].core=n.core))})}function lH({_novip:e},n,t,r){t.forEach(t=>{let o=r[t];n.forEach(n=>{let r=iv(n,t);(!r||"value"in r&&void 0===r.value)&&(n===e.Transaction.prototype||n instanceof e.Transaction?iy(n,t,{get(){return this.table(t)},set(e){ig(this,t,{value:e,writable:!0,configurable:!0,enumerable:!0})}}):n[t]=new e.Table(t,o))})})}function lK({_novip:e},n){n.forEach(n=>{for(let t in n)n[t]instanceof e.Table&&delete n[t]})}function lY(e,n){return e._cfg.version-n._cfg.version}function lZ(e,n){let t,r={del:[],add:[],change:[]};for(t in e)n[t]||r.del.push(t);for(t in n){let o=e[t],a=n[t];if(o){let e={name:t,def:a,recreate:!1,del:[],add:[],change:[]};if(""+(o.primKey.keyPath||"")==""+(a.primKey.keyPath||"")&&(o.primKey.auto===a.primKey.auto||ln)){let n,t=o.idxByName,i=a.idxByName;for(n in t)i[n]||e.del.push(n);for(n in i){let r=t[n],o=i[n];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([t,a])}return r}function lJ(e,n,t,r){let o=e.db.createObjectStore(n,t.keyPath?{keyPath:t.keyPath,autoIncrement:t.auto}:{autoIncrement:t.auto});return r.forEach(e=>lX(o,e)),o}function lX(e,n){e.createIndex(n.name,n.keyPath,{unique:n.unique,multiEntry:n.multi})}function lQ(e,n,t){let r={};return iA(n.objectStoreNames,0).forEach(e=>{let n=t.objectStore(e),o=n.keyPath,a=lj(lR(o),o||"",!1,!1,!!n.autoIncrement,o&&"string"!=typeof o,!0),i=[];for(let e=0;e<n.indexNames.length;++e){let t=n.index(n.indexNames[e]);o=t.keyPath;var s=lj(t.name,o,!!t.unique,!!t.multiEntry,!1,o&&"string"!=typeof o,!1);i.push(s)}r[e]=lF(e,a,i)}),r}function l0({_novip:e},n,t){let r=t.db.objectStoreNames;for(let o=0;o<r.length;++o){let a=r[o],i=t.objectStore(a);e._hasGetAll="getAll"in i;for(let e=0;e<i.indexNames.length;++e){let t=i.indexNames[e],r=i.index(t).keyPath,o="string"==typeof r?r:"["+iA(r).join("+")+"]";if(n[a]){let e=n[a].idxByName[o];e&&(e.name=t,delete n[a].idxByName[o],n[a].idxByName[t]=e)}}}"u">typeof navigator&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&is.WorkerGlobalScope&&is instanceof is.WorkerGlobalScope&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604&&(e._hasGetAll=!1)}class l1{_parseStoresSpec(e,n){il(e).forEach(t=>{if(null!==e[t]){var r=e[t].split(",").map((e,n)=>{let t=(e=e.trim()).replace(/([&*]|\+\+)/g,""),r=/^\[/.test(t)?t.match(/^\[(.*)\]$/)[1].split("+"):t;return lj(t,r||null,/\&/.test(e),/\*/.test(e),/\+\+/.test(e),ic(r),0===n)}),o=r.shift();if(o.multi)throw new i2.Schema("Primary key cannot be multi-valued");r.forEach(e=>{if(e.auto)throw new i2.Schema("Only primary key can be marked as autoIncrement (++)");if(!e.keyPath)throw new i2.Schema("Index must have a name and cannot be an empty string")}),n[t]=lF(t,o,r)}})}stores(e){let n=this.db;this._cfg.storesSource=this._cfg.storesSource?ip(this._cfg.storesSource,e):e;let t=n._versions,r={},o={};return t.forEach(e=>{ip(r,e._cfg.storesSource),o=e._cfg.dbschema={},e._parseStoresSpec(r,o)}),n._dbSchema=o,lK(n,[n._allTables,n,n.Transaction.prototype]),lH(n,[n._allTables,n,n.Transaction.prototype,this._cfg.tables],il(o),o),n._storeNames=il(o),this}upgrade(e){return this._cfg.contentUpgrade=sr(this._cfg.contentUpgrade||i4,e),this}}function l2(e,n){let t=e._dbNamesDB;return t||(t=e._dbNamesDB=new cu(lr,{addons:[],indexedDB:e,IDBKeyRange:n})).version(1).stores({dbnames:"name"}),t.table("dbnames")}function l3(e){return e&&"function"==typeof e.databases}function l5(e){return sU(function(){return s$.letThrough=!0,e()})}function l4(e){var n=n=>e.next(n),t=o(n),r=o(n=>e.throw(n));function o(e){return n=>{var o=e(n),a=o.value;return o.done?a:a&&"function"==typeof a.then?a.then(t,r):ic(a)?Promise.all(a).then(t,r):t(a)}}return o(n)()}function l6(e,n,t){var r=arguments.length;if(r<2)throw new i2.InvalidArgument("Too few arguments");for(var o=Array(r-1);--r;)o[r-1]=arguments[r];return t=o.pop(),[e,iM(o),t]}function l7(e,n,t){let r=ic(e)?e.slice():[e];for(let e=0;e<t;++e)r.push(n);return r}let l8={stack:"dbcore",name:"VirtualIndexMiddleware",level:1,create:function(e){return{...e,table(n){let t=e.table(n),{schema:r}=t,o={},a=[];function i(e,n,t){let r=lU(e),s=o[r]=o[r]||[],l=null==e?0:"string"==typeof e?1:e.length,c=n>0,p={...t,isVirtual:c,keyTail:n,keyLength:l,extractKey:lW(e),unique:!c&&t.unique};return s.push(p),p.isPrimaryKey||a.push(p),l>1&&i(2===l?e[0]:e.slice(0,l-1),n+1,t),s.sort((e,n)=>e.keyTail-n.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(n){var t,r;let o=n.query.index;return o.isVirtual?{...n,query:{index:o,range:(t=n.query.range,r=o.keyTail,{type:1===t.type?2:t.type,lower:l7(t.lower,t.lowerOpen?e.MAX_KEY:e.MIN_KEY,r),lowerOpen:!0,upper:l7(t.upper,t.upperOpen?e.MIN_KEY:e.MAX_KEY,r),upperOpen:!0})}}:n}return{...t,schema:{...r,primaryKey:s,indexes:a,getIndexByKeyPath:function(e){let n=o[lU(e)];return n&&n[0]}},count:e=>t.count(l(e)),query:e=>t.query(l(e)),openCursor(n){let{keyTail:r,isVirtual:o,keyLength:a}=n.query.index;return o?t.openCursor(l(n)).then(t=>t&&Object.create(t,{continue:{value:function(o){null!=o?t.continue(l7(o,n.reverse?e.MAX_KEY:e.MIN_KEY,r)):n.unique?t.continue(t.key.slice(0,a).concat(n.reverse?e.MIN_KEY:e.MAX_KEY,r)):t.continue()}},continuePrimaryKey:{value(n,o){t.continuePrimaryKey(l7(n,e.MAX_KEY,r),o)}},primaryKey:{get:()=>t.primaryKey},key:{get(){let e=t.key;return 1===a?e[0]:e.slice(0,a)}},value:{get:()=>t.value}})):t.openCursor(n)}}}}}};function l9(e,n,t,r){return t=t||{},r=r||"",il(e).forEach(o=>{if(ih(n,o)){var a=e[o],i=n[o];if("object"==typeof a&&"object"==typeof i&&a&&i){let e=iB(a);e!==iB(i)?t[r+o]=n[o]:"Object"===e?l9(a,i,t,r+o+"."):a!==i&&(t[r+o]=n[o])}else a!==i&&(t[r+o]=n[o])}else t[r+o]=void 0}),il(n).forEach(o=>{ih(e,o)||(t[r+o]=n[o])}),t}let ce={stack:"dbcore",name:"HooksMiddleware",level:2,create:e=>({...e,table(n){let t=e.table(n),{primaryKey:r}=t.schema;return{...t,mutate(e){let o=s$.trans,{deleting:a,creating:i,updating:s}=o.table(n).hook;switch(e.type){case"add":if(i.fire===i4)break;return o._promise("readwrite",()=>l(e),!0);case"put":if(i.fire===i4&&s.fire===i4)break;return o._promise("readwrite",()=>l(e),!0);case"delete":if(a.fire===i4)break;return o._promise("readwrite",()=>l(e),!0);case"deleteRange":if(a.fire===i4)break;return o._promise("readwrite",()=>(function e(n,o,a){return t.query({trans:n,values:!1,query:{index:r,range:o},limit:a}).then(({result:t})=>l({type:"delete",keys:t,trans:n}).then(r=>r.numFailures>0?Promise.reject(r.failures[0]):t.length<a?{failures:[],numFailures:0,lastResult:void 0}:e(n,{...o,lower:t[t.length-1],lowerOpen:!0},a)))})(e.trans,e.range,1e4),!0)}return t.mutate(e);function l(e){var n,o;let l=s$.trans,c=e.keys||("delete"===(n=e).type?n.keys:n.keys||n.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([]):t.getMany({trans:o.trans,keys:c,cache:"immutable"})).then(n=>{let o=c.map((t,o)=>{let c=n[o],p={onerror:null,onsuccess:null};if("delete"===e.type)a.fire.call(p,t,c,l);else if("add"===e.type||void 0===c){let n=i.fire.call(p,t,e.values[o],l);null==t&&null!=n&&(t=n,e.keys[o]=t,r.outbound||iS(e.values[o],r.keyPath,t))}else{let n=l9(c,e.values[o]),r=s.fire.call(p,n,t,c,l);if(r){let n=e.values[o];Object.keys(r).forEach(e=>{ih(n,e)?n[e]=r[e]:iS(n,e,r[e])})}}return p});return t.mutate(e).then(({failures:t,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(t[a]):s.onsuccess&&s.onsuccess("put"===e.type&&n[a]?e.values[a]:i)}return{failures:t,results:r,numFailures:a,lastResult:i}}).catch(e=>(o.forEach(n=>n.onerror&&n.onerror(e)),Promise.reject(e)))})}}}}})};function cn(e,n,t){try{if(!n||n.keys.length<e.length)return null;let r=[];for(let o=0,a=0;o<n.keys.length&&a<e.length;++o)0===l_(n.keys[o],e[a])&&(r.push(t?iN(n.values[o]):n.values[o]),++a);return r.length===e.length?r:null}catch(e){return null}}let ct={stack:"dbcore",level:-1,create:e=>({table:n=>{let t=e.table(n);return{...t,getMany:e=>{if(!e.cache)return t.getMany(e);let n=cn(e.keys,e.trans._cache,"clone"===e.cache);return n?sx.resolve(n):t.getMany(e).then(n=>(e.trans._cache={keys:e.keys,values:"clone"===e.cache?iN(n):n},n))},mutate:e=>("add"!==e.type&&(e.trans._cache=null),t.mutate(e))}}})};function cr(e){return!("from"in e)}let co=function(e,n){if(!this){let n=new co;return e&&"d"in e&&ip(n,e),n}ip(this,arguments.length?{d:1,from:e,to:arguments.length>1?n:e}:{d:0})};function ca(e,n,t){let r=l_(n,t);if(isNaN(r))return;if(r>0)throw RangeError();if(cr(e))return ip(e,{from:n,to:t,d:1});let o=e.l,a=e.r;if(0>l_(t,e.from))return o?ca(o,n,t):e.l={from:n,to:t,d:1,l:null,r:null},cl(e);if(l_(n,e.to)>0)return a?ca(a,n,t):e.r={from:n,to:t,d:1,l:null,r:null},cl(e);0>l_(n,e.from)&&(e.from=n,e.l=null,e.d=a?a.d+1:1),l_(t,e.to)>0&&(e.to=t,e.r=null,e.d=e.l?e.l.d+1:1);let i=!e.r;o&&!e.l&&ci(e,o),a&&i&&ci(e,a)}function ci(e,n){cr(n)||function e(n,{from:t,to:r,l:o,r:a}){ca(n,t,r),o&&e(n,o),a&&e(n,a)}(e,n)}function cs(e){let n=cr(e)?null:{s:0,n:e};return{next(e){let t=arguments.length>0;for(;n;)switch(n.s){case 0:if(n.s=1,t)for(;n.n.l&&0>l_(e,n.n.from);)n={up:n,n:n.n.l,s:1};else for(;n.n.l;)n={up:n,n:n.n.l,s:1};case 1:if(n.s=2,!t||0>=l_(e,n.n.to))return{value:n.n,done:!1};case 2:if(n.n.r){n.s=3,n={up:n,n:n.n.r,s:0};continue}case 3:n=n.up}return{done:!0}}}}function cl(e){var n,t;let r=((null==(n=e.r)?void 0:n.d)||0)-((null==(t=e.l)?void 0:t.d)||0),o=r>1?"r":r<-1?"l":"";if(o){let n="r"===o?"l":"r",t={...e},r=e[o];e.from=r.from,e.to=r.to,e[o]=r[o],t[o]=r[n],e[n]=t,t.d=cc(t)}e.d=cc(e)}function cc({r:e,l:n}){return(e?n?Math.max(e.d,n.d):e.d:n?n.d:0)+1}im(co.prototype,{add(e){return ci(this,e),this},addKey(e){return ca(this,e,e),this},addKeys(e){return e.forEach(e=>ca(this,e,e)),this},[ij](){return cs(this)}});let cp={stack:"dbcore",level:0,create:e=>{let n=e.schema.name,t=new co(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 t=`idb://${n}/${r}/${e}`;return s[t]||(s[t]=new co)},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(ic(d)){"delete"!==u&&(d=e.results),c.addKeys(d);let n=cn(d,h);n||"add"===u||p.addKeys(d),(n||f)&&a.indexes.forEach(function(e){let t=l(e.name||"");function r(n){return null!=n?e.extractKey(n):null}let o=n=>e.multiEntry&&ic(n)?n.forEach(e=>t.addKey(e)):t.addKey(n);(n||f).forEach((e,t)=>{let a=n&&r(n[t]),i=f&&r(f[t]);0!==l_(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(t),p.add(t),a.indexes.forEach(e=>l(e.name).add(t));return e})}},p=({query:{index:n,range:t}})=>{var r,o;return[n,new co(null!=(r=t.lower)?r:e.MIN_KEY,null!=(o=t.upper)?o:e.MAX_KEY)]},u={get:e=>[i,new co(e.key)],getMany:e=>[i,(new co).addKeys(e.keys)],count:p,query:p,openCursor:p};return il(u).forEach(e=>{c[e]=function(a){let{subscr:i}=s$;if(i){let c=e=>{let t=`idb://${n}/${r}/${e}`;return i[t]||(i[t]=new co)},p=c(""),d=c(":dels"),[f,h]=u[e](a);if(c(f.name||"").add(h),!f.isPrimaryKey){if("count"!==e){let n="query"===e&&l&&a.values&&o.query({...a,values:!1});return o[e].apply(this,arguments).then(t=>{if("query"===e){if(l&&a.values)return n.then(({result:e})=>(p.addKeys(e),t));let e=a.values?t.result.map(s):t.result;a.values?p.addKeys(e):d.addKeys(e)}else if("openCursor"===e){let e=a.values;return t&&Object.create(t,{key:{get:()=>(d.addKey(t.primaryKey),t.key)},primaryKey:{get(){let e=t.primaryKey;return d.addKey(e),e}},value:{get:()=>(e&&p.addKey(t.primaryKey),t.value)}})}return t})}d.add(t)}}return o[e].apply(this,arguments)}}),c}}}};class cu{constructor(e,n){var t;this._middlewares={},this.verno=0;const r=cu.dependencies;this._options=n={addons:cu.addons,autoOpen:!0,indexedDB:r.indexedDB,IDBKeyRange:r.IDBKeyRange,...n},this._deps={indexedDB:n.indexedDB,IDBKeyRange:n.IDBKeyRange};const{addons:o}=n;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:i4,dbReadyPromise:null,cancelOpen:i4,openCanceller:null,autoSchema:!0,PR1398_maxLoop:3};a.dbReadyPromise=new sx(e=>{a.dbReadyResolve=e}),a.openCanceller=new sx((e,n)=>{a.cancelOpen=n}),this._state=a,this.name=e,this.on=lp(this,"populate","blocked","versionchange","close",{ready:[sr,i4]}),this.on.ready.subscribe=iw(this.on.ready.subscribe,e=>(n,t)=>{cu.vip(()=>{let r=this._state;if(r.openComplete)r.dbOpenError||sx.resolve().then(n),t&&e(n);else if(r.onReadyBeingFired)r.onReadyBeingFired.push(n),t&&e(n);else{e(n);let r=this;t||e(function e(){r.on.ready.unsubscribe(n),r.on.ready.unsubscribe(e)})}})}),this.Collection=(t=this,lu(lA.prototype,function(e,n){this.db=t;let r=ls,o=null;if(n)try{r=n()}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!==i6?s:null}})),this.Table=function(e){return lu(lc.prototype,function(n,t,r){this.db=e,this._tx=r,this.name=n,this.schema=t,this.hook=e._allTables[n]?e._allTables[n].hook:lp(null,{creating:[i9,i4],reading:[i7,i6],updating:[sn,i4],deleting:[se,i4]})})}(this),this.Transaction=function(e){return lu(lB.prototype,function(n,t,r,o,a){this.db=e,this.mode=n,this.storeNames=t,this.schema=r,this.chromeTransactionDurability=o,this.idbtrans=null,this.on=lp(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 sx((e,n)=>{this._resolve=e,this._reject=n}),this._completion.then(()=>{this.active=!1,this.on.complete.fire()},e=>{var n=this.active;return this.active=!1,this.on.error.fire(e),this.parent?this.parent._reject(e):n&&this.idbtrans&&this.idbtrans.abort(),s5(e)})})}(this),this.Version=function(e){return lu(l1.prototype,function(n){this.db=e,this._cfg={version:n,storesSource:null,dbschema:{},tables:{},contentUpgrade:null}})}(this),this.WhereClause=function(e){return lu(lM.prototype,function(n,t,r){this.db=e,this._ctx={table:n,index:":id"===t?null:t,or:r};let o=e._deps.indexedDB;if(!o)throw new i2.MissingAPI;this._cmp=this._ascending=o.cmp.bind(o),this._descending=(e,n)=>o.cmp(n,e),this._max=(e,n)=>o.cmp(e,n)>0?e:n,this._min=(e,n)=>0>o.cmp(e,n)?e:n,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=lL(n.IDBKeyRange),this._createTransaction=(e,n,t,r)=>new this.Transaction(e,n,t,this._options.chromeTransactionDurability,r),this._fireOnBlocked=e=>{this.on("blocked").fire(e),le.filter(e=>e.name===this.name&&e!==this&&!e._state.vcFired).map(n=>n.on("versionchange").fire(e))},this.use(l8),this.use(ce),this.use(cp),this.use(ct),this.vip=Object.create(this,{_vip:{value:!0}}),o.forEach(e=>e(this))}version(e){if(isNaN(e)||e<.1)throw new i2.Type("Given version is not a positive number");if(e=Math.round(10*e)/10,this.idbdb||this._state.isBeingOpened)throw new i2.Schema("Cannot add version when database is open");this.verno=Math.max(this.verno,e);let n=this._versions;var t=n.filter(n=>n._cfg.version===e)[0];return t||(t=new this.Version(e),n.push(t),n.sort(lY),t.stores({}),this._state.autoSchema=!1,t)}_whenReady(e){return this.idbdb&&(this._state.openComplete||s$.letThrough||this._vip)?e():new sx((e,n)=>{if(this._state.openComplete)return n(new i2.DatabaseClosed(this._state.dbOpenError));if(!this._state.isBeingOpened){if(!this._options.autoOpen)return void n(new i2.DatabaseClosed);this.open().catch(i4)}this._state.dbReadyPromise.then(e,n)}).then(e)}use({stack:e,create:n,level:t,name:r}){r&&this.unuse({stack:e,name:r});let o=this._middlewares[e]||(this._middlewares[e]=[]);return o.push({stack:e,create:n,level:null==t?10:t,name:r}),o.sort((e,n)=>e.level-n.level),this}unuse({stack:e,name:n,create:t}){return e&&this._middlewares[e]&&(this._middlewares[e]=this._middlewares[e].filter(e=>t?e.create!==t:!!n&&e.name!==n)),this}open(){return function(e){var n;let t=e._state,{indexedDB:r}=e._deps;if(t.isBeingOpened||e.idbdb)return t.dbReadyPromise.then(()=>t.dbOpenError?s5(t.dbOpenError):e);iV&&(t.openCanceller._stackHolder=iq()),t.isBeingOpened=!0,t.dbOpenError=null,t.openComplete=!1;let o=t.openCanceller;function a(){if(t.openCanceller!==o)throw new i2.DatabaseClosed("db.open() was cancelled")}let i=t.dbReadyResolve,s=null,l=!1;return sx.race([o,("u"<typeof navigator?sx.resolve():!navigator.userAgentData&&/Safari\//.test(navigator.userAgent)&&!/Chrom(e|ium)\//.test(navigator.userAgent)&&indexedDB.databases?new Promise(function(e){var t=function(){return indexedDB.databases().finally(e)};n=setInterval(t,100),t()}).finally(function(){return clearInterval(n)}):Promise.resolve()).then(()=>new sx((n,o)=>{if(a(),!r)throw new i2.MissingAPI;let i=e.name,c=t.autoSchema?r.open(i):r.open(i,Math.round(10*e.verno));if(!c)throw new i2.MissingAPI;c.onerror=lP(o),c.onblocked=sj(e._fireOnBlocked),c.onupgradeneeded=sj(n=>{if(s=c.transaction,t.autoSchema&&!e._options.allowEmptyDB){c.onerror=lT,s.abort(),c.result.close();let e=r.deleteDatabase(i);e.onsuccess=e.onerror=sj(()=>{o(new i2.NoSuchDatabase(`Database ${i} doesnt exist`))})}else{let t,r,i,d;s.onerror=lP(o);var a,p,u=n.oldVersion>0x4000000000000000?0:n.oldVersion;l=u<1,e._novip.idbdb=c.result,a=u/10,p=s,t=e._dbSchema,(r=e._createTransaction("readwrite",e._storeNames,t)).create(p),r._completion.catch(o),i=r._reject.bind(r),d=s$.transless||s$,sU(()=>{s$.trans=r,s$.transless=d,0===a?(il(t).forEach(e=>{lJ(p,e,t[e].primKey,t[e].indexes)}),lq(e,p),sx.follow(()=>e.on.populate.fire(r)).catch(i)):(function({_novip:e},n,t,r){let o=[],a=e._versions,i=e._dbSchema=lQ(e,e.idbdb,r),s=!1;return a.filter(e=>e._cfg.version>=n).forEach(a=>{o.push(()=>{let o=i,l=a._cfg.dbschema;l0(e,o,r),l0(e,l,r),i=e._dbSchema=l;let c=lZ(o,l);c.add.forEach(e=>{lJ(r,e[0],e[1].primKey,e[1].indexes)}),c.change.forEach(e=>{if(e.recreate)throw new i2.Upgrade("Not yet support for changing primary key");{let n=r.objectStore(e.name);e.add.forEach(e=>lX(n,e)),e.change.forEach(e=>{n.deleteIndex(e.name),lX(n,e)}),e.del.forEach(e=>n.deleteIndex(e))}});let p=a._cfg.contentUpgrade;if(p&&a._cfg.version>n){let n;lq(e,r),t._memoizedTables={},s=!0;let a=iD(l);c.del.forEach(e=>{a[e]=o[e]}),lK(e,[e.Transaction.prototype]),lH(e,[e.Transaction.prototype],il(a),a),t.schema=a;let i=iW(p);i&&sq();let u=sx.follow(()=>{if((n=p(t))&&i){var e=sH.bind(null,null);n.then(e,e)}});return n&&"function"==typeof n.then?sx.resolve(n):u.then(()=>n)}}),o.push(n=>{var r;s&&ln||(r=a._cfg.dbschema,[].slice.call(n.db.objectStoreNames).forEach(e=>null==r[e]&&n.db.deleteObjectStore(e))),lK(e,[e.Transaction.prototype]),lH(e,[e.Transaction.prototype],e._storeNames,e._dbSchema),t.schema=e._dbSchema})}),(function e(){return o.length?sx.resolve(o.shift()(t.idbtrans)).then(e):sx.resolve()})().then(()=>{var e;il(e=i).forEach(n=>{r.db.objectStoreNames.contains(n)||lJ(r,n,e[n].primKey,e[n].indexes)})})})(e,a,r,p).catch(i)})}},o),c.onsuccess=sj(()=>{s=null;let r=e._novip.idbdb=c.result,o=iA(r.objectStoreNames);if(o.length>0)try{let n,a=r.transaction(1===o.length?o[0]:o,"readonly");t.autoSchema?function({_novip:e},n,t){e.verno=n.version/10;let r=e._dbSchema=lQ(0,n,t);e._storeNames=iA(n.objectStoreNames,0),lH(e,[e._allTables],il(r),r)}(e,r,a):(l0(e,e._dbSchema,a),((n=lZ(lQ(0,e.idbdb,a),e._dbSchema)).add.length||n.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.")),lq(e,a)}catch(e){}le.push(e),r.onversionchange=sj(n=>{t.vcFired=!0,e.on("versionchange").fire(n)}),r.onclose=sj(n=>{e.on("close").fire(n)}),l&&function({indexedDB:e,IDBKeyRange:n},t){l3(e)||t===lr||l2(e,n).put({name:t}).catch(i4)}(e._deps,i),n()},o)}))]).then(()=>(a(),t.onReadyBeingFired=[],sx.resolve(l5(()=>e.on.ready.fire(e.vip))).then(function n(){if(t.onReadyBeingFired.length>0){let r=t.onReadyBeingFired.reduce(sr,i4);return t.onReadyBeingFired=[],sx.resolve(l5(()=>r(e.vip))).then(n)}}))).finally(()=>{t.onReadyBeingFired=null,t.isBeingOpened=!1}).then(()=>e).catch(n=>{t.dbOpenError=n;try{s&&s.abort()}catch(e){}return o===t.openCanceller&&e._close(),s5(n)}).finally(()=>{t.openComplete=!0,i()})}(this)}_close(){let e=this._state,n=le.indexOf(this);if(n>=0&&le.splice(n,1),this.idbdb){try{this.idbdb.close()}catch(e){}this._novip.idbdb=null}e.dbReadyPromise=new sx(n=>{e.dbReadyResolve=n}),e.openCanceller=new sx((n,t)=>{e.cancelOpen=t})}close(){this._close();let e=this._state;this._options.autoOpen=!1,e.dbOpenError=new i2.DatabaseClosed,e.isBeingOpened&&e.cancelOpen(e.dbOpenError)}delete(){let e=arguments.length>0,n=this._state;return new sx((t,r)=>{let o=()=>{this.close();var e=this._deps.indexedDB.deleteDatabase(this.name);e.onsuccess=sj(()=>{!function({indexedDB:e,IDBKeyRange:n},t){l3(e)||t===lr||l2(e,n).delete(t).catch(i4)}(this._deps,this.name),t()}),e.onerror=lP(r),e.onblocked=this._fireOnBlocked};if(e)throw new i2.InvalidArgument("Arguments not allowed in db.delete()");n.isBeingOpened?n.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 il(this._allTables).map(e=>this._allTables[e])}transaction(){let e=l6.apply(this,arguments);return this._transaction.apply(this,e)}_transaction(e,n,t){let r,o,a=s$.trans;a&&a.db===this&&-1===e.indexOf("!")||(a=null);let i=-1!==e.indexOf("?");e=e.replace("!","").replace("?","");try{if(o=n.map(e=>{var n=e instanceof this.Table?e.name:e;if("string"!=typeof n)throw TypeError("Invalid table argument to Dexie.transaction(). Only Table or String are allowed");return n}),"r"==e||e===lo)r=lo;else{if("rw"!=e&&e!=la)throw new i2.InvalidArgument("Invalid transaction mode: "+e);r=la}if(a){if(a.mode===lo&&r===la){if(!i)throw new i2.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 i2.SubTransaction("Table "+e+" not included in parent transaction.");a=null}}),i&&a&&!a.active&&(a=null)}}catch(e){return a?a._promise(null,(n,t)=>{t(e)}):s5(e)}let s=(function e(n,t,r,o,a){return sx.resolve().then(()=>{let i,s=s$.transless||s$,l=n._createTransaction(t,r,n._dbSchema,o);if(o)l.idbtrans=o.idbtrans;else try{l.create(),n._state.PR1398_maxLoop=3}catch(o){return o.name===i1.InvalidState&&n.isOpen()&&--n._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),n._close(),n.open().then(()=>e(n,t,r,null,a))):s5(o)}let c=iW(a);c&&sq();let p=sx.follow(()=>{if(i=a.call(l,l))if(c){var e=sH.bind(null,null);i.then(e,e)}else"function"==typeof i.next&&"function"==typeof i.throw&&(i=l4(i))},{trans:l,transless:s});return(i&&"function"==typeof i.then?sx.resolve(i).then(e=>l.active?e:s5(new i2.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),s5(e)))})}).bind(null,this,r,o,a,t);return a?a._promise(r,s,"lock"):s$.trans?sQ(s$.transless,()=>this._whenReady(s)):this._whenReady(s)}table(e){if(!ih(this._allTables,e))throw new i2.InvalidTable(`Table ${e} does not exist`);return this._allTables[e]}}let cd="u">typeof Symbol&&"observable"in Symbol?Symbol.observable:"@@observable";class cf{constructor(e){this._subscribe=e}subscribe(e,n,t){return this._subscribe(e&&"function"!=typeof e?e:{next:e,error:n,complete:t})}[cd](){return this}}function ch(e,n){return il(n).forEach(t=>{ci(e[t]||(e[t]=new co),n[t])}),e}try{o={indexedDB:is.indexedDB||is.mozIndexedDB||is.webkitIndexedDB||is.msIndexedDB,IDBKeyRange:is.IDBKeyRange||is.webkitIDBKeyRange}}catch(e){o={indexedDB:null,IDBKeyRange:null}}function cm(e){let n=cg;try{cg=!0,lI.storagemutated.fire(e)}finally{cg=n}}im(cu,{...i5,delete:e=>new cu(e,{addons:[]}).delete(),exists:e=>new cu(e,{addons:[]}).open().then(e=>(e.close(),!0)).catch("NoSuchDatabaseError",()=>!1),getDatabaseNames(e){try{return(function({indexedDB:e,IDBKeyRange:n}){return l3(e)?Promise.resolve(e.databases()).then(e=>e.map(e=>e.name).filter(e=>e!==lr)):l2(e,n).toCollection().primaryKeys()})(cu.dependencies).then(e)}catch(e){return s5(new i2.MissingAPI)}},defineClass:()=>function(e){ip(this,e)},ignoreTransaction:e=>s$.trans?sQ(s$.transless,e):e(),vip:l5,async:function(e){return function(){try{var n=l4(e.apply(this,arguments));return n&&"function"==typeof n.then?n:sx.resolve(n)}catch(e){return s5(e)}}},spawn:function(e,n,t){try{var r=l4(e.apply(t,n||[]));return r&&"function"==typeof r.then?r:sx.resolve(r)}catch(e){return s5(e)}},currentTransaction:{get:()=>s$.trans||null},waitFor:function(e,n){let t=sx.resolve("function"==typeof e?cu.ignoreTransaction(e):e).timeout(n||6e4);return s$.trans?s$.trans.waitFor(t):t},Promise:sx,debug:{get:()=>iV,set:e=>{iV=e,iG="dexie"===e?()=>!0:lt}},derive:ib,extend:ip,props:im,override:iw,Events:lp,on:lI,liveQuery:function(e){let n,t=!1,r=new cf(r=>{let o=iW(e),a=!1,i={},s={},l={get closed(){return a},unsubscribe:()=>{a=!0,lI.storagemutated.unsubscribe(d)}};r.start&&r.start(l);let c=!1,p=!1;function u(){return il(s).some(e=>i[e]&&function(e,n){let t=cs(n),r=t.next();if(r.done)return!1;let o=r.value,a=cs(e),i=a.next(o.from),s=i.value;for(;!r.done&&!i.done;){if(0>=l_(s.from,o.to)&&l_(s.to,o.from)>=0)return!0;0>l_(o.from,s.from)?o=(r=t.next(s.from)).value:s=(i=a.next(o.from)).value}return!1}(i[e],s[e]))}let d=e=>{ch(i,e),u()&&f()},f=()=>{let h,m;if(c||a)return;i={};let g={},y=(o&&sq(),h=()=>sU(e,{subscr:g,trans:null}),m=s$.trans?sQ(s$.transless,h):h(),o&&m.then(sH,sH),m);p||(lI(lO,d),p=!0),c=!0,Promise.resolve(y).then(e=>{t=!0,n=e,c=!1,a||(u()?f():(i={},s=g,r.next&&r.next(e)))},e=>{c=!1,t=!1,r.error&&r.error(e),l.unsubscribe()})};return f(),l});return r.hasValue=()=>t,r.getValue=()=>n,r},extendObservabilitySet:ch,getByKeyPath:iE,setByKeyPath:iS,delByKeyPath:function(e,n){"string"==typeof n?iS(e,n,void 0):"length"in n&&[].map.call(n,function(n){iS(e,n,void 0)})},shallowClone:iD,deepClone:iN,getObjectDiff:l9,cmp:l_,asap:ix,minKey:s7,addons:[],connections:le,errnames:i1,dependencies:o,semVer:s4,version:s4.split(".").map(e=>parseInt(e)).reduce((e,n,t)=>e+n/Math.pow(10,2*t))}),cu.maxKey=lL(cu.dependencies.IDBKeyRange),"u">typeof dispatchEvent&&"u">typeof addEventListener&&(lI(lO,e=>{if(!cg){let n;ln?(n=document.createEvent("CustomEvent")).initCustomEvent(lN,!0,!0,e):n=new CustomEvent(lN,{detail:e}),cg=!0,dispatchEvent(n),cg=!1}}),addEventListener(lN,({detail:e})=>{cg||cm(e)}));let cg=!1;if("u">typeof BroadcastChannel){let e=new BroadcastChannel(lN);"function"==typeof e.unref&&e.unref(),lI(lO,n=>{cg||e.postMessage(n)}),e.onmessage=e=>{e.data&&cm(e.data)}}else if("u">typeof self&&"u">typeof navigator){lI(lO,e=>{try{cg||("u">typeof localStorage&&localStorage.setItem(lN,JSON.stringify({trig:Math.random(),changedParts:e})),"object"==typeof self.clients&&[...self.clients.matchAll({includeUncontrolled:!0})].forEach(n=>n.postMessage({type:lN,changedParts:e})))}catch(e){}}),"u">typeof addEventListener&&addEventListener("storage",e=>{if(e.key===lN){let n=JSON.parse(e.newValue);n&&cm(n.changedParts)}});let e=self.document&&navigator.serviceWorker;e&&e.addEventListener("message",function({data:e}){e&&e.type===lN&&cm(e.changedParts)})}function cy(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}sx.rejectionMapper=function(e,n){if(!e||e instanceof iJ||e instanceof TypeError||e instanceof SyntaxError||!e.name||!i3[e.name])return e;var t=new i3[e.name](n||e.message,e);return"stack"in e&&iy(t,"stack",{get:function(){return this.inner.stack}}),t},iG=lt;class cb extends cu{constructor(){super("EsmOffline"),cy(this,"syncQueue",void 0),cy(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 c_(){return new cb}let cv=new cb,c$={},cA=G("offline-synchronization",{});function cw(){return cA}async function ck(){if(cA.getState().synchronization)return;let e=await cv.syncQueue.count(),n={},t=Object.entries(c$),r=t.length,o={},a=new AbortController,i=()=>{let e=cA.getState().synchronization;cA.setState({synchronization:{...e,pendingCount:e.pendingCount-1}})};try{cA.setState({synchronization:{totalCount:e,pendingCount:e,abortController:a}});for(let e=0;e<r&&t.length>0;e++)for(let e=t.length;e--;){let[r,s]=t[e],l=s.dependsOn.map(e=>n[e]);l.every(Boolean)&&(o[r]={},await Promise.all(l),n[r]=cx(s,o,a,i),t.splice(e,1))}await Promise.allSettled(Object.values(n))}finally{cA.setState({synchronization:void 0})}}async function cx({type:e,dependsOn:n,process:t},r,o,a){let i=[],s=[],l=await cC();await cv.syncQueue.where({type:e,userId:l}).each((e,n)=>{i.push([n.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 t(u,{abort:o,index:c,items:s,userId:l,dependencies:f.map(({id:e,type:t})=>n.includes(t)?r[t][e]:void 0)});void 0!==d&&(r[e][d]=a),await cv.syncQueue.delete(p)}catch(e){await cv.syncQueue.update(p,{lastError:{name:e?.name,message:e?.message??e?.toString()}})}finally{a()}}}async function cC(){let e=await oq();return e?.uuid||"*"}async function cE(e,n,t,r){let o=r&&r.id;return void 0!==o&&await cv.syncQueue.where({type:n,userId:e}).filter(e=>e?.descriptor.id===o).delete().catch(cu.errnames.DatabaseClosed),await cv.syncQueue.add({type:n,content:t,userId:e,descriptor:r||{},createdOn:new Date}).catch(cu.errnames.DatabaseClosed,()=>-1)}async function cS(e,n,t){let r=await cC();return await cE(r,e,n,t)}async function cD(e,n){return(await cz(e,n)).map(e=>e.content)}async function cz(e,n){return await cv.syncQueue.where(n?{type:n,userId:e}:{userId:e}).toArray().catch(cu.errnames.DatabaseClosed,()=>[])}async function cM(e){let n=await cC();return await cD(n,e)}async function cP(e){let n=await cC();return await cz(n,e)}async function cT(e){return await cv.syncQueue.get(e).catch(cu.errnames.DatabaseClosed,()=>void 0)}function cO(e){return!!c$[e]?.options.onBeginEditSyncItem}async function cN(e){let n=await cT(e);if(!n)throw Error(`No sync item with the ID ${e} exists.`);let t=c$[n.type]?.options.onBeginEditSyncItem;if(!t)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 "${n.type}" supports editing items.`);t(n)}async function cI(e){await cv.syncQueue.delete(e).catch(cu.errnames.DatabaseClosed)}function cB(e,n,t,r={}){c$[e]={type:e,dependsOn:n,process:t,options:r}}let cj="u">typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),cR=new Uint8Array(16),cF=[];for(let e=0;e<256;++e)cF.push((e+256).toString(16).slice(1));let cL=function(e,n,t){if(cj&&!n&&!e)return cj();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(cR)})();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,n){t=t||0;for(let e=0;e<16;++e)n[t+e]=r[e];return n}return function(e,n=0){return cF[e[n+0]]+cF[e[n+1]]+cF[e[n+2]]+cF[e[n+3]]+"-"+cF[e[n+4]]+cF[e[n+5]]+"-"+cF[e[n+6]]+cF[e[n+7]]+"-"+cF[e[n+8]]+cF[e[n+9]]+"-"+cF[e[n+10]]+cF[e[n+11]]+cF[e[n+12]]+cF[e[n+13]]+cF[e[n+14]]+cF[e[n+15]]}(r)},cW="OFFLINE+";function cV(){return cW+cL()}function cG(e){return e.startsWith(cW)}let cU={};function cq(){return Object.values(cU)}function cH(e){cU[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.`),cU[e.id]=e}async function cK(e){let n=await c2();return await cY(n,e)}async function cY(e,n){let t=new cb;return await t.dynamicOfflineData.where(n?{type:n,users:e}:{users:e}).toArray().catch(cu.errnames.DatabaseClosed,()=>[])}async function cZ(e,n){let t=await c2();return await cJ(t,e,n)}async function cJ(e,n,t){let r=new cb,o=await r.dynamicOfflineData.get({type:n,identifier:t}).catch(cu.errnames.DatabaseClosed,()=>void 0);o?o.users.includes(e)||await r.dynamicOfflineData.update(o.id,{users:[...o.users,e]}).catch(cu.errnames.DatabaseClosed):await r.dynamicOfflineData.add({users:[e],type:n,identifier:t}).catch(cu.errnames.DatabaseClosed)}async function cX(e,n){let t=await c2();return await cQ(t,e,n)}async function cQ(e,n,t){let r=new cb,o=await r.dynamicOfflineData.get({type:n,identifier:t,users:e}).catch(cu.errnames.DatabaseClosed,()=>void 0);o&&(o.users.length>1?await r.dynamicOfflineData.update(o.id,{users:o.users.filter(n=>n!==e)}).catch(cu.errnames.DatabaseClosed):await r.dynamicOfflineData.delete(o.id).catch(cu.errnames.DatabaseClosed))}async function c0(e,n){let t=await cK(e);await Promise.all(t.map(async e=>c1(e.type,e.identifier,n)))}async function c1(e,n,t){await cZ(e,n);let r=new cb,o=await c2(),a=await r.dynamicOfflineData.get({type:e,identifier:n}).catch(cu.errnames.DatabaseClosed,()=>void 0),i=cq().filter(n=>n.type===e);if(!a)return;let s=await Promise.all(i.map(async e=>{try{return e.sync(n,t),{id:e.id,error:void 0}}catch(t){let n=t.message?.toString()??t.toString();return{id:e.id,error:n}}})),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(cu.errnames.DatabaseClosed)}async function c2(){let e=(await oq()).uuid;if(!e)throw Error("Using the dynamic offline data API requires a logged in user.");return e}let c3=G("offline-patients",{offlinePatientDataSyncState:{},handlers:{}});function c5(){return c7(),c3}function c4(e,n){c7(),cH({type:"patient",displayName:n.displayName,id:e,isSynced:()=>Promise.resolve(!0),sync:(e,t)=>n.onOfflinePatientAdded({patientUuid:e,signal:t??new AbortController().signal})})}async function c6(e){c7(),await c1("patient",e)}function c7(){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 c8(e,n,t=!0){if(e){let r=null,[o,a]=await Promise.all([oN(`${oP}/Patient/${e}`,n).catch(e=>r=e),t?c9(e):Promise.resolve(null)]);if(o.ok)return o.data;if(a)return a;if(r)throw r}return null}async function c9(e){let n=(await cM("patient-registration")).find(n=>n.fhirPatient.id===e);return n?.fhirPatient??null}function pe(e,n){let t=new CustomEvent(`openmrs:${e}`,{detail:n??void 0,cancelable:!0,bubbles:!0});return window.dispatchEvent(t)}function pn(e,n){let t=e=>{n("detail"in e&&null!==e.detail?e.detail:void 0)};return window.addEventListener(`openmrs:${e}`,t),()=>{window.removeEventListener(`openmrs:${e}`,t)}}var pt=t(9549);function pr(e){return{uuid:e.uuid,display:e.display}}function po(e=null,n=null){let t=new URLSearchParams;e&&t.set("tag",e),n&&t.set("q",n);let r=t.toString();return oI(`${oM}/location${r?"?"+r:""}`).pipe((0,pt.map)(e=>e.data.results.map(pr))).pipe((0,pt.take)(1))}function pa(e){return{uuid:e.uuid,display:e.display,name:e.name}}function pi(){return oI(`${oM}/visittype`).pipe((0,pt.map)(e=>e.data.results.map(pa))).pipe((0,pt.take)(1))}var ps=((er={}).NEWVISIT="startVisit",er.EDITVISIT="editVisit",er.LOADING="loadingVisit",er),pl=((eo={}).NOTSTARTED="notStarted",eo.ONGOING="ongoing",eo);let pc="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))",pp=function(){try{return JSON.parse(sessionStorage.getItem("openmrs:visitStoreState")||"null")}catch(e){return null}}()||{patientUuid:null,manuallySetVisitUuid:null,mutateVisitCallbacks:{}};function pu(){return q("visit",pp)}function pd(e,n){pu().setState({patientUuid:e,manuallySetVisitUuid:n})}function pf(e,n){return oN(`${oM}/visit`,{signal:n.signal,method:"POST",headers:{"Content-type":"application/json"},body:e})}function ph(e,n,t){return oN(`${oM}/visit/${e}`,{signal:t.signal,method:"POST",headers:{"Content-type":"application/json"},body:n})}function pm(e,n,t){return oN(`${oM}/visit?patient=${e}&v=${t??pc}`,{signal:n.signal,method:"GET",headers:{"Content-type":"application/json"}})}pu().subscribe(e=>{var n;n=e,sessionStorage.setItem("openmrs:visitStoreState",JSON.stringify(n))});let pg=new es.BehaviorSubject(null);class py{static get version(){return"1.4.0"}static toString(){return"JavaScript Expression Parser (JSEP) v"+py.version}static addUnaryOp(e){return py.max_unop_len=Math.max(e.length,py.max_unop_len),py.unary_ops[e]=1,py}static addBinaryOp(e,n,t){return py.max_binop_len=Math.max(e.length,py.max_binop_len),py.binary_ops[e]=n,t?py.right_associative.add(e):py.right_associative.delete(e),py}static addIdentifierChar(e){return py.additional_identifier_chars.add(e),py}static addLiteral(e,n){return py.literals[e]=n,py}static removeUnaryOp(e){return delete py.unary_ops[e],e.length===py.max_unop_len&&(py.max_unop_len=py.getMaxKeyLen(py.unary_ops)),py}static removeAllUnaryOps(){return py.unary_ops={},py.max_unop_len=0,py}static removeIdentifierChar(e){return py.additional_identifier_chars.delete(e),py}static removeBinaryOp(e){return delete py.binary_ops[e],e.length===py.max_binop_len&&(py.max_binop_len=py.getMaxKeyLen(py.binary_ops)),py.right_associative.delete(e),py}static removeAllBinaryOps(){return py.binary_ops={},py.max_binop_len=0,py}static removeLiteral(e){return delete py.literals[e],py}static removeAllLiterals(){return py.literals={},py}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 py(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 py.binary_ops[e]||0}static isIdentifierStart(e){return e>=65&&e<=90||e>=97&&e<=122||e>=128&&!py.binary_ops[String.fromCharCode(e)]||py.additional_identifier_chars.has(String.fromCharCode(e))}static isIdentifierPart(e){return py.isIdentifierStart(e)||py.isDecimalDigit(e)}throwError(e){let n=Error(e+" at character "+this.index);throw n.index=this.index,n.description=e,n}runHook(e,n){if(py.hooks[e]){let t={context:this,node:n};return py.hooks.run(e,t),t.node}return n}searchHook(e){if(py.hooks[e]){let n={context:this};return py.hooks[e].find(function(e){return e.call(n.context,n),n.node}),n.node}}gobbleSpaces(){let e=this.code;for(;e===py.SPACE_CODE||e===py.TAB_CODE||e===py.LF_CODE||e===py.CR_CODE;)e=this.expr.charCodeAt(++this.index);this.runHook("gobble-spaces")}parse(){this.runHook("before-all");let e=this.gobbleExpressions(),n=1===e.length?e[0]:{type:py.COMPOUND,body:e};return this.runHook("after-all",n)}gobbleExpressions(e){let n=[],t,r;for(;this.index<this.expr.length;)if((t=this.code)===py.SEMCOL_CODE||t===py.COMMA_CODE)this.index++;else if(r=this.gobbleExpression())n.push(r);else if(this.index<this.expr.length){if(t===e)break;this.throwError('Unexpected "'+this.char+'"')}return n}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,py.max_binop_len),n=e.length;for(;n>0;){if(py.binary_ops.hasOwnProperty(e)&&(!py.isIdentifierStart(this.code)||this.index+e.length<this.expr.length&&!py.isIdentifierPart(this.expr.charCodeAt(this.index+e.length))))return this.index+=n,e;e=e.substr(0,--n)}return!1}gobbleBinaryExpression(){let e,n,t,r,o,a,i,s,l;if(!(a=this.gobbleToken())||!(n=this.gobbleBinaryOp()))return a;for(o={value:n,prec:py.binaryPrecedence(n),right_a:py.right_associative.has(n)},(i=this.gobbleToken())||this.throwError("Expected expression after "+n),r=[a,o,i];n=this.gobbleBinaryOp();){if(0===(t=py.binaryPrecedence(n))){this.index-=n.length;break}o={value:n,prec:t,right_a:py.right_associative.has(n)},l=n;let s=e=>o.right_a&&e.right_a?t>e.prec:t<=e.prec;for(;r.length>2&&s(r[r.length-2]);)i=r.pop(),n=r.pop().value,a=r.pop(),e={type:py.BINARY_EXP,operator:n,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:py.BINARY_EXP,operator:r[s-1].value,left:r[s-2],right:e},s-=2;return e}gobbleToken(){let e,n,t,r;if(this.gobbleSpaces(),r=this.searchHook("gobble-token"))return this.runHook("after-token",r);if(e=this.code,py.isDecimalDigit(e)||e===py.PERIOD_CODE)return this.gobbleNumericLiteral();if(e===py.SQUOTE_CODE||e===py.DQUOTE_CODE)r=this.gobbleStringLiteral();else if(e===py.OBRACK_CODE)r=this.gobbleArray();else{for(t=(n=this.expr.substr(this.index,py.max_unop_len)).length;t>0;){if(py.unary_ops.hasOwnProperty(n)&&(!py.isIdentifierStart(this.code)||this.index+n.length<this.expr.length&&!py.isIdentifierPart(this.expr.charCodeAt(this.index+n.length)))){this.index+=t;let e=this.gobbleToken();return e||this.throwError("missing unaryOp argument"),this.runHook("after-token",{type:py.UNARY_EXP,operator:n,argument:e,prefix:!0})}n=n.substr(0,--t)}py.isIdentifierStart(e)?(r=this.gobbleIdentifier(),py.literals.hasOwnProperty(r.name)?r={type:py.LITERAL,value:py.literals[r.name],raw:r.name}:r.name===py.this_str&&(r={type:py.THIS_EXP})):e===py.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 n=this.code;for(;n===py.PERIOD_CODE||n===py.OBRACK_CODE||n===py.OPAREN_CODE||n===py.QUMARK_CODE;){let t;if(n===py.QUMARK_CODE){if(this.expr.charCodeAt(this.index+1)!==py.PERIOD_CODE)break;t=!0,this.index+=2,this.gobbleSpaces(),n=this.code}this.index++,n===py.OBRACK_CODE?((e={type:py.MEMBER_EXP,computed:!0,object:e,property:this.gobbleExpression()}).property||this.throwError('Unexpected "'+this.char+'"'),this.gobbleSpaces(),(n=this.code)!==py.CBRACK_CODE&&this.throwError("Unclosed ["),this.index++):n===py.OPAREN_CODE?e={type:py.CALL_EXP,arguments:this.gobbleArguments(py.CPAREN_CODE),callee:e}:(n===py.PERIOD_CODE||t)&&(t&&this.index--,this.gobbleSpaces(),e={type:py.MEMBER_EXP,computed:!1,object:e,property:this.gobbleIdentifier()}),t&&(e.optional=!0),this.gobbleSpaces(),n=this.code}return e}gobbleNumericLiteral(){let e="",n,t;for(;py.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);if(this.code===py.PERIOD_CODE)for(e+=this.expr.charAt(this.index++);py.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);if("e"===(n=this.char)||"E"===n){for(e+=this.expr.charAt(this.index++),("+"===(n=this.char)||"-"===n)&&(e+=this.expr.charAt(this.index++));py.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);py.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+e+this.char+")")}return t=this.code,py.isIdentifierStart(t)?this.throwError("Variable names cannot start with a number ("+e+this.char+")"):(t===py.PERIOD_CODE||1===e.length&&e.charCodeAt(0)===py.PERIOD_CODE)&&this.throwError("Unexpected period"),{type:py.LITERAL,value:parseFloat(e),raw:e}}gobbleStringLiteral(){let e="",n=this.index,t=this.expr.charAt(this.index++),r=!1;for(;this.index<this.expr.length;){let n=this.expr.charAt(this.index++);if(n===t){r=!0;break}if("\\"===n)switch(n=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+=n}else e+=n}return r||this.throwError('Unclosed quote after "'+e+'"'),{type:py.LITERAL,value:e,raw:this.expr.substring(n,this.index)}}gobbleIdentifier(){let e=this.code,n=this.index;for(py.isIdentifierStart(e)?this.index++:this.throwError("Unexpected "+this.char);this.index<this.expr.length;)if(e=this.code,py.isIdentifierPart(e))this.index++;else break;return{type:py.IDENTIFIER,name:this.expr.slice(n,this.index)}}gobbleArguments(e){let n=[],t=!1,r=0;for(;this.index<this.expr.length;){this.gobbleSpaces();let o=this.code;if(o===e){t=!0,this.index++,e===py.CPAREN_CODE&&r&&r>=n.length&&this.throwError("Unexpected token "+String.fromCharCode(e));break}if(o===py.COMMA_CODE){if(this.index++,++r!==n.length){if(e===py.CPAREN_CODE)this.throwError("Unexpected token ,");else if(e===py.CBRACK_CODE)for(let e=n.length;e<r;e++)n.push(null)}}else if(n.length!==r&&0!==r)this.throwError("Expected comma");else{let e=this.gobbleExpression();e&&e.type!==py.COMPOUND||this.throwError("Expected comma"),n.push(e)}}return t||this.throwError("Expected "+String.fromCharCode(e)),n}gobbleGroup(){this.index++;let e=this.gobbleExpressions(py.CPAREN_CODE);if(this.code===py.CPAREN_CODE)return(this.index++,1===e.length)?e[0]:!!e.length&&{type:py.SEQUENCE_EXP,expressions:e};this.throwError("Unclosed (")}gobbleArray(){return this.index++,{type:py.ARRAY_EXP,elements:this.gobbleArguments(py.CBRACK_CODE)}}}Object.assign(py,{hooks:new class{add(e,n,t){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]||[],n&&this[e][t?"unshift":"push"](n)},this)}run(e,n){this[e]=this[e]||[],this[e].forEach(function(e){e.call(n&&n.context?n.context:n,n)})}},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)})}}(py),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"}),py.max_unop_len=py.getMaxKeyLen(py.unary_ops),py.max_binop_len=py.getMaxKeyLen(py.binary_ops);let pb=e=>new py(e).parse(),p_=Object.getOwnPropertyNames(class{});Object.getOwnPropertyNames(py).filter(e=>!p_.includes(e)&&void 0===pb[e]).forEach(e=>{pb[e]=py[e]}),pb.Jsep=py,pb.plugins.register({name:"ternary",init(e){e.hooks.add("after-expression",function(n){if(n.node&&this.code===e.QUMARK_CODE){this.index++;let t=n.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"),n.node={type:"ConditionalExpression",test:t,consequent:r,alternate:o},t.operator&&e.binary_ops[t.operator]<=.9){let r=t;for(;r.right.operator&&e.binary_ops[r.right.operator]<=.9;)r=r.right;n.node.test=r.right,r.right=n.node,n.node=t}}else this.throwError("Expected :")}})}});let pv="ArrowFunctionExpression",p$={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)}},pA={...p$,Promise};function pw(e,n={}){return pD(e,n,pP)}async function pk(e,n={}){return pz(e,n,pP)}function px(e,n={}){return pD(e,n,pT)}function pC(e,n={}){return pz(e,n,pT)}function pE(e,n={}){return pD(e,n,pO)}function pS(e,n={}){return pz(e,n,pO)}function pD(e,n={},t){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==n&&(n={});let r=pB(n,p$),o=pN("string"==typeof e?pb(e):e,r);if(t(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 pz(e,n={},t){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==n&&(n={});let r=pB(n,pA);return Promise.resolve(pN("string"==typeof e?pb(e):e,r)).then(n=>{if(t(n))return n;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 pM(e){return pb(e)}function pP(e){return"string"==typeof e||"number"==typeof e||"boolean"==typeof e||null==e||e instanceof Date}function pT(e){return"boolean"==typeof e}function pO(e){return"number"==typeof e}function pN(e,n){switch(e.type){case"UnaryExpression":var t,r,o,a,i,s,l,c,p,u,d,f,h=e,m=n;let g=pN(h.argument,m);switch(h.operator){case"+":return+g;case"-":return-g;case"~":return~g;case"!":return!g;default:throw`Expression evaluator does not support operator '${h.operator}''`}case"BinaryExpression":var y=e,b=n;let v=pN(y.left,b),$=pN(y.right,b);switch(y.operator){case"+":return v+$;case"-":return v-$;case"*":return v*$;case"/":return v/$;case"%":return v%$;case"**":return v**$;case"==":return v==$;case"===":return v===$;case"!=":return v!=$;case"!==":return v!==$;case">":return v>$;case">=":return v>=$;case"<":return v<$;case"<=":return v<=$;case"in":return v in $;case"&&":return v&&$;case"||":return v||$;case"??":return v??$;default:throw`Expression evaluator does not support operator '${y.operator}' operator`}case"ConditionalExpression":return t=e,r=n,pN(t.test,r)?pN(t.consequent,r):pN(t.alternate,r);case"CallExpression":var A=e,w=n;let k=A.arguments?.map(pj(w)),x=pN(A.callee,w);if(x){if("function"!=typeof x)throw`${pF(A.callee)} is not a function`}else throw`No function named ${pF(A.callee)} is defined in this context`;return x(...k);case"ArrowFunctionExpression":let C;return o=e,a=n,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 n=Object.fromEntries(C.reduce((n,t,r)=>{let o=e[r];return function e(n){if("string"==typeof n||"number"==typeof n||"boolean"==typeof n||"function"==typeof n||null===n||n instanceof RegExp)return!0;if("object"==typeof n){for(let t of Object.keys(n))if(!e(n[t]))return!1;return!0}if(Array.isArray(n)){for(let t of n)if(!e(t))break}return!1}(o)&&n.push([t,o]),n},[]));return pN(o.body,a.addVariables(n))}).bind(a.thisObj??null);case"MemberExpression":return function(e,n){let t,r=pN(e.object,n);if(void 0===r)switch(e.object.type){case"Identifier":{let t=pI(e.object,n);throw ReferenceError(`ReferenceError: ${t} is not defined`)}case"MemberExpression":{let t=pI(e.property,n);throw TypeError(`TypeError: cannot read properties of undefined (reading '${t}')`)}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(n.thisObj=o,e.property.type){case"Identifier":case"MemberExpression":t=pN(e.property,n);break;default:{let o=pN(e.property,n);if(void 0===o)throw{type:"Illegal property access",message:"No property was supplied to the property access"};pR(o),t=r[o]}}return"function"==typeof t?t.bind(r):t}(e,n);case"ArrayExpression":return i=e,s=n,i.elements?.map(pj(s));case"SequenceExpression":let E;return l=e,c=n,(E=l.expressions.map(pj(c)))[E.length-1];case"NewExpression":var S=e,D=n;if(S.callee&&"Identifier"===S.callee.type){let e=S.arguments?.map(pj(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 pR((p=e).value),p.value;case"Identifier":var z=e,M=n;pR(z.name);let P=M.thisObj;if(P&&("object"==typeof P||"function"==typeof P)&&z.name in P){let e=P[z.name];return pR(e),e}if(M.variables&&z.name in M.variables){let e=M.variables[z.name];return pR(e),e}return z.name in M.globals?M.globals[z.name]:void 0;case"TemplateLiteral":let T,O;return u=e,d=n,T=u.expressions?.map(pj(d))??[],(O=u.quasis?.map(pj(d))??[]).filter(e=>!e.tail).map(e=>e.value).join("")+T.join("")+O.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 pI(e,n){switch(e.type){case"Literal":return e.value;case"Identifier":return e.name;case"MemberExpression":return pI(e.property,n);default:throw`VisitExpressionName does not support expression of type '${e.type}'`}}function pB(e,n){let t={thisObj:void 0,variables:{...e},globals:{...n},addVariables(e){return this.variables={...this.variables,...e},this}};return t.addVariables.bind(t),t}function pj(e){return function(n){return null===n?null:pN(n,e)}}function pR(e){if("__proto__"===e||"prototype"===e||"constructor"===e)throw{type:"Illegal property access",message:`Cannot access the ${e} property of objects`}}function pF(e){return e?"MemberExpression"===e.type?e.property?.name:e.name:null}function pL(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 n={globals:{...pA},isLocalExpression:!1,variables:new Set};return pW("string"==typeof e?pb(e):e,n),[...n.variables]}function pW(e,n){switch(e.type){case"UnaryExpression":return r=e,o=n,pW(r.argument,o);case"BinaryExpression":return a=e,i=n,[pW(a.left,i),pW(a.right,i)].filter(Boolean);case"ConditionalExpression":return s=e,l=n,[pW(s.consequent,l),pW(s.test,l),pW(s.alternate,l)].filter(Boolean);case"CallExpression":let t;return c=e,p=n,t=pW(c.callee,p),c.arguments?.map(pV(p)),t;case"ArrowFunctionExpression":var r,o,a,i,s,l,c,p,u,d,f,h,m,g,y,b,v,$,A=e,w=n;let k={...w};k.isLocalExpression=!0;let x=A.params?.map(pV(k))??[],C=pW(A.body,k)??[];if(C&&Array.isArray(C))for(let e of C)x.includes(e)||w.variables.add(e);return;case"MemberExpression":let E;return u=e,d=n,pW(u.object,d),void((E={...d}).isLocalExpression=!0,pW(u.property,E));case"ArrayExpression":return f=e,h=n,void f.elements?.map(pV(h));case"SequenceExpression":return m=e,g=n,void m.expressions?.map(pV(g));case"NewExpression":return y=e,b=n,void y.arguments?.map(pV(b));case"Literal":case"TemplateElement":return;case"Identifier":var S=e,D=n;if(!(S.name in D.globals))if(D.isLocalExpression)return S.name;else D.variables.add(S.name);return;case"TemplateLiteral":return v=e,$=n,void(v.expressions?.map(pV($)),v.quasis?.map(pV($)));default:throw`Expression evaluator does not support expression of type '${e.type}'`}}function pV(e){return function(n){return null===n?null:pW(n,e)}}pb.plugins.register({name:"arrow",init(e){e.addBinaryOp("=>",.1,!0),e.hooks.add("gobble-expression",function(n){if(this.gobbleSpaces(),this.code===e.OPAREN_CODE){let t=this.index;if(this.index++,this.gobbleSpaces(),this.code===e.CPAREN_CODE){this.index++;let e=this.gobbleBinaryOp();if("=>"===e){let t=this.gobbleBinaryExpression();t||this.throwError("Expected expression after "+e),n.node={type:pv,params:null,body:t};return}}this.index=t}}),e.hooks.add("after-expression",function(n){!function n(t){t&&(Object.values(t).forEach(e=>{e&&"object"==typeof e&&n(e)}),"=>"===t.operator&&(t.type=pv,t.params=t.left?[t.left]:null,t.body=t.right,t.params&&t.params[0].type===e.SEQUENCE_EXP&&(t.params=t.params[0].expressions),delete t.left,delete t.right,delete t.operator))}(n.node)})}}),pb.plugins.register({name:"new",init(e){e.addUnaryOp("new"),e.hooks.add("after-token",function(n){let t=n.node;if(t&&"new"===t.operator){t.argument&&[e.CALL_EXP,e.MEMBER_EXP].includes(t.argument.type)||this.throwError("Expected new function()"),n.node=t.argument;let r=n.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"}})}}),pb.plugins.register({name:"numbers",init(e){function n(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 t(n){let t=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=t;return}n.node={type:e.LITERAL,value:parseFloat(r),raw:this.expr.substring(t,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=n.call(this,l);if(!c)return;let p="";for(;o=this.code,a=c,95===o||a.some(([e,n])=>o>=e&&o<=n);)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,t.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)&&t.call(this,r)})}}),pb.plugins.register({name:"regex",init(e){e.hooks.add("gobble-token",function(n){if(47===this.code){let t=++this.index,r=!1;for(;this.index<this.expr.length;){if(47===this.code&&!r){let r,o=this.expr.slice(t,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 n.node={type:e.LITERAL,value:r,raw:this.expr.slice(t-1,this.index)},n.node=this.gobbleTokenProperty(n.node),n.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")}})}}),pb.plugins.register({name:"ternary",init(e){e.hooks.add("after-expression",function(n){if(n.node&&this.code===e.QUMARK_CODE){this.index++;let t=n.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"),n.node={type:"ConditionalExpression",test:t,consequent:r,alternate:o},t.operator&&e.binary_ops[t.operator]<=.9){let r=t;for(;r.right.operator&&e.binary_ops[r.right.operator]<=.9;)r=r.right;n.node.test=r.right,r.right=n.node,n.node=t}}else this.throwError("Expected :")}})}}),pb.plugins.register({name:"jsepTemplateLiteral",init(e){function n(e,t=!0){if(96===this.code){let n={type:"TemplateLiteral",quasis:[],expressions:[]},r="",o="",a=!1,i=this.expr.length,s=()=>n.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=n,t&&(e.node=this.gobbleTokenProperty(e.node)),e.node;if("$"===i&&"{"===this.expr.charAt(this.index+1))this.index+=2,s(),o="",r="",n.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",n),e.hooks.add("after-token",function(t){if((t.node.type===e.IDENTIFIER||t.node.type===e.MEMBER_EXP)&&96===this.code)return t.node={type:"TaggedTemplateExpression",tag:t.node,quasi:n.bind(this)(t,!1)},t.node=this.gobbleTokenProperty(t.node),t.node})}}),pb.addBinaryOp("in",7),pb.addBinaryOp("??",1);let pG=q("feature-flags",{flags:function(){let e={};for(let n of Object.keys(localStorage))if(n.startsWith("openmrs:feature-flag:")){let t=n.replace("openmrs:feature-flag:",""),r=JSON.parse(localStorage.getItem(`openmrs:feature-flag-meta:${t}`)||"{}");e[t]={enabled:"true"===localStorage.getItem(n),...r}}return e}()});function pU(e,n,t){pG.setState(r=>({flags:{...r.flags,[e]:{enabled:r.flags[e]?.enabled??!1,label:n,description:t}}}))}function pq(){let e=pG.getState().flags;Object.keys(localStorage).filter(e=>e.startsWith("openmrs:feature-flag:")).forEach(n=>{let t=n.replace("openmrs:feature-flag:","");e[t]||(localStorage.removeItem(n),localStorage.removeItem(`openmrs:feature-flag-meta:${t}`))})}function pH(e){return pG.getState().flags[e].enabled}function pK(e,n){pG.subscribe(t=>{n(t.flags[e].enabled)})}function pY(e,n){pG.setState(t=>({flags:{...t.flags,[e]:{...t.flags[e],enabled:n}}}))}function pZ(e){return!window.offlineEnabled||(e??navigator.onLine)}pG.subscribe(e=>{for(let[n,t]of Object.entries(e.flags))localStorage.setItem(`openmrs:feature-flag:${n}`,t.enabled.toString()),localStorage.setItem(`openmrs:feature-flag-meta:${n}`,JSON.stringify({label:t.label,description:t.description}))});var pJ=e9(function(e,n,t){e0(e,n,t)});function pX(e=!0,n=!1){return pQ(pZ(),e,n)}function pQ(e,n=!0,t=!1){return!!(e?n:t)}let p0=G("extensionsInternal",{slots:{},extensions:{}}),p1=()=>q("extensionsInternal",{slots:{},extensions:{}});function p2(e){let n=p0.getState(),t=e(n);t!==n&&p0.setState(t)}let p3=()=>q("extensions",{slots:{}});function p5(e){let n=[];for(let t of Object.values(e.extensions))for(let e of t.instances)n.push({slotModuleName:e.slotModuleName,extensionModuleName:t.moduleName,slotName:e.slotName,extensionId:e.id});(0,nn.A)(ta.getState().mountedExtensions,n)||ta.setState({mountedExtensions:n})}p5(p0.getState()),p0.subscribe(p5);let p4=p1(),p6=p3(),p7=ts(),p8=tp();function p9(e,n,t,r,o){let a={},i=pZ(),s=Object.entries(r.flags).filter(([,{enabled:e}])=>e).map(([e])=>e);for(let[r,l]of Object.entries(e.slots)){let{config:c}=tc(n,l.name),p=up(r,e,c,t,s,i,o.session);a[r]={moduleName:l.moduleName,assignedExtensions:p}}(0,nn.A)(p6.getState().slots,a)||p6.setState({slots:a})}function ue(){p9(p4.getState(),p7.getState(),p8.getState(),pG.getState(),oj.getState())}function un(e,n,t){return{moduleName:n,name:e,attachedIds:[],config:null,state:t}}function ut(e){let[n]=e.split("#");return n}function ur(e,n){let t=ut(n);return e.extensions[t]}function uo(e){return ur(p4.getState(),e)}p4.subscribe(e=>{p9(e,p7.getState(),p8.getState(),pG.getState(),oj.getState())}),p7.subscribe(e=>{p9(p4.getState(),e,p8.getState(),pG.getState(),oj.getState())}),p8.subscribe(e=>{p9(p4.getState(),p7.getState(),e,pG.getState(),oj.getState())}),pG.subscribe(e=>{p9(p4.getState(),p7.getState(),p8.getState(),e,oj.getState())}),oj.subscribe(e=>{p9(p4.getState(),p7.getState(),p8.getState(),pG.getState(),e)}),ue(),g(ue);let ua=e=>p4.setState(n=>(n.extensions[e.name]={...e,instances:[]},n));function ui(e,n){p2(t=>{let r=t.slots[e];return r?{...t,slots:{...t.slots,[e]:{...r,attachedIds:[...r.attachedIds,n]}}}:{...t,slots:{...t.slots,[e]:{...un(e),attachedIds:[n]}}}})}function us(e,n){p2(t=>{let r=t.slots[e];return r&&r.attachedIds.includes(n)?{...t,slots:{...t.slots,[e]:{...r,attachedIds:r.attachedIds.filter(e=>e!==n)}}}:t})}function ul(e){p2(n=>{let t=n.slots[e];return t?{...n,slots:{...n.slots,[e]:{...t,attachedIds:[]}}}:n})}function uc(e,n,t,r){let o=n.indexOf(e);if(-1!==o)return o;{if(void 0!==t)return 1e3+t;let n=r.indexOf(e);return -1!==n?2e3+n:-1}}function up(e,n,t,r,o,a,i){let s=function(e,n){let t=e.add||[],r=e.remove||[],o=e.order||[],{extensions:a}=p4.getState();return[...n,...t].filter(e=>!r.includes(e)).sort((e,t)=>{let r=uc(e,o,a[ut(e)]?.order,n),i=uc(t,o,a[ut(t)]?.order,n);return -1===i?-1:-1===r?1:r-i})}(t,n.slots[e].attachedIds),l=[],c=n.slots[e]?.state,p=c&&"object"==typeof c?{session:i,...c}:{session:i};for(let c of s){let{config:s}=td(r,e,c),u=pJ(s,tf(t,e,c)),d=ut(c),f=n.extensions[d];if(f){let n=u?.["Display conditions"]?.privileges??f.privileges??[];if(n&&("string"==typeof n||Array.isArray(n)&&n.length>0)&&(!i?.user||!oU(n,i.user)))continue;let t=u?.["Display conditions"]?.expression||f.displayExpression;if(void 0!==t&&"string"==typeof t&&t.trim().length>0)try{if(!px(t,p))continue}catch(n){console.error(`Error while evaluating expression '${t}' for extension ${d} in slot ${e}`,n);continue}if(f.featureFlag&&!o.includes(f.featureFlag)||window.offlineEnabled&&!pQ(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 uu(e){let n=p4.getState(),{config:t}=tl(e),r=p8.getState(),o=pG.getState(),a=oj.getState(),i=pZ();return up(e,n,t,r,Object.entries(o.flags).filter(([,{enabled:e}])=>e).map(([e])=>e),i,a.session)}let ud=(e,n,t)=>p4.setState(r=>{let o=r.slots[n]?.moduleName;if(o&&o!=e)return console.warn(`An extension slot with the name '${n}' 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[n])return{...r,slots:{...r.slots,[n]:{...r.slots[n],moduleName:e,state:t}}};let a=un(n,e,t);return{...r,slots:{...r.slots,[n]:{...a}}}});function uf(e,n,t=!1){p4.setState(r=>{let o=t?pJ(r.slots[e].state,n):n;return{...r,slots:{...r.slots,[e]:{...r.slots[e],state:o}}}})}let uh=()=>p6.setState(()=>({slots:{},extensions:{}})),um=G("left-nav",{slotName:null,basePath:window.spaBase,mode:"normal"});function ug({name:e,basePath:n,mode:t,componentContext:r,state:o}){um.setState({slotName:e,basePath:n,mode:t??"normal",componentContext:r,state:o})}function uy(e){um.getState().slotName===e&&um.setState(um.getInitialState(),!0)}let ub=G("modalRegistry",{modals:{}});function u_(e){ub.setState(n=>(n.modals[e.name]=e,n))}function uv(e){let n=ub.getState().modals[e];if(!n){let t=uo(e);t&&(n={name:e,load:t.load,moduleName:t.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.`),u_(n))}return n}let u$=G("workspaceRegistrations",{workspaces:{}}),uA=G("workspaceGroups",{workspaceGroups:{}});function uw(e){u$.setState(n=>({workspaces:{...n.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 uk(e){uA.setState(n=>{let t=n.workspaceGroups[e.name];return t?{workspaceGroups:{...n.workspaceGroups,[e.name]:{...t,members:Array.from(new Set([...t.members,...e.members]))}}}:{workspaceGroups:{...n.workspaceGroups,[e.name]:{name:e.name,members:e.members}}}})}let ux=new Set;function uC(e){let n=u$.getState().workspaces;if(n[e])return n[e];{let n=uo(e);if(n){var t;let r;return ux.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.`),ux.add(e)),{name:n.name,title:(t=n,"string"==typeof(r=t?.meta?.title)?r:r&&"object"==typeof r?o5(t.moduleName,r.key,r.default):t.name),moduleName:n.moduleName,preferredWindowSize:n.meta?.screenSize??"normal",load:n.load,type:n.meta?.type??"form",canHide:n.meta?.canHide??!1,canMaximize:n.meta?.canMaximize??!1,width:n.meta?.width??"narrow",groups:n.meta?.groups??[]}}throw Error(`No workspace named '${e}' has been registered.`)}}function uE(e){let n=uA.getState().workspaceGroups;if(n[e])return n[e];throw Error(`No workspace group named '${e}' has been registered.`)}let uS=G("workspace2",{registeredGroupsByName:{},registeredWindowsByName:{},registeredWorkspacesByName:{},openedGroup:null,openedWindows:[],workspaceTitleByWorkspaceName:{},isMostRecentlyOpenedWindowHidden:!1});function uD(e){let{registeredWorkspacesByName:n,registeredWindowsByName:t}=uS.getState(),r=n[e];if(r){let n=t[r.window];if(n)return n;throw Error(`No workspace window found with name: ${r.window} for workspace: ${e}`)}throw Error(`No workspace found with name: ${e}`)}function uz(e){let{registeredGroupsByName:n,registeredWindowsByName:t}=uS.getState(),r=t[e];if(r){let t=n[r.group];if(t)return t;throw Error(`No workspace group found with name: ${r.group} for window: ${e}`)}throw Error(`No workspace window found with name: ${e}`)}function uM(e){let{openedWindows:n}=uS.getState();return n.findIndex(n=>n.openedWorkspaces.find(n=>n.workspaceName===e))}function uP(e,n){if(0==n.length)return;let{registeredGroupsByName:t}=uS.getState(),r={...t};for(let t of n){if(r[t.name])throw Error(`Cannot register workspace group ${t.name} more than once`);r[t.name]={...t,moduleName:e}}uS.setState({registeredGroupsByName:r})}function uT(e,n){if(0==n.length)return;let{registeredWindowsByName:t}=uS.getState(),r={...t};for(let t of n){if(r[t.name])throw Error(`Cannot register workspace window ${t.name} more than once`);let n={...t,moduleName:e};r[t.name]=n}uS.setState({registeredWindowsByName:r})}function uO(e,n){if(0==n.length)return;let{registeredWorkspacesByName:t}=uS.getState(),r={...t};for(let t of n){if(r[t.name])throw Error(`Cannot register workspace ${t.name} more than once`);let n={...t,moduleName:e};r[t.name]=n}uS.setState({registeredWorkspacesByName:r})}let uN=0;async function uI(e,n,t,r,o=e=>e,a={}){let i=ut(r),s=uo(r),l=null;if(e){if(!s)throw Error(`Couldn't find extension '${i}' to attach to '${n}'`);let{meta:c,moduleName:p,online:u,offline:d,load:f}=s;if(pX(u,d)){p2(o=>({...o,extensions:{...o.extensions,[i]:{...o.extensions[i],instances:[...o.extensions[i].instances,{domElement:e,id:r,slotName:n,slotModuleName:t}]}}}));let s=await f(),u=uN++;l=rT(o({...s,name:`${n}/${i}-${u}`}),{...a,_meta:c,_extensionContext:{extensionId:r,extensionSlotName:n,extensionSlotModuleName:t,extensionModuleName:p},domElement:e})}}else console.warn(`Tried to render ${r} into ${n} but no DOM element was available.`);return l}var uB=t(2491),uj=t.n(uB);let uR=(0,uB.createContext)({moduleName:"",featureName:""});function uF({to:e,templateParams:n,onBeforeNavigate:t,children:r,...o}){return(0,uB.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}`)},[]),uj().createElement("a",{onClick:r=>{0===r.button&&!r.ctrlKey&&!r.shiftKey&&!r.altKey&&!r.metaKey&&(r.preventDefault(),t?.(r),o$({to:e,templateParams:n})),0===r.button&&(r.ctrlKey||r.metaKey)&&t?.(r),0===r.button&&r.shiftKey&&t?.(r),1===r.button&&t?.(r)},href:o_(e,n),...o},r)}let uL=({state:e,children:n,...t})=>{let{extension:r}=(0,uB.useContext)(uR),o=(0,uB.useRef)(null),a=(0,uB.useRef)(Promise.resolve()),i=(0,uB.useCallback)(n=>{r?.extensionSlotName&&r.extensionSlotModuleName&&r.extensionSlotModuleName&&!o.current&&uI(n,r.extensionSlotName,r.extensionSlotModuleName,r.extensionId,void 0,e).then(e=>{o.current=e})},[]);return(0,uB.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,uB.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?uj().createElement("div",{ref:i,"data-extension-id":r?.extensionId,style:{position:"relative"},...t}):null};function uW(e,n){"function"==typeof n&&(n=n(e));let t={};for(let[r,o]of Object.entries(n)){let n=function(...n){e.setState(e=>o(e,...n))};t[r]=n}return t}let uV=()=>e=>e;function uG(e,n=uV(),t){let r=(0,uB.useCallback)(n=>e.subscribe(n),[e]),o=(0,uB.useCallback)(()=>n(e.getState()),[e,n]),a=(0,uB.useSyncExternalStore)(r,o,o),i=(0,uB.useMemo)(()=>t?uW(e,t):{},[e,t]);return{...a,...i}}function uU(e,n){return uG(e,uV(),n)}function uq(e){return function(n){let t=(0,uB.useCallback)(n=>e.subscribe(n),[]),r=(0,uB.useCallback)(()=>e.getState(),[]),o=(0,uB.useSyncExternalStore)(t,r,r),a=(0,uB.useMemo)(()=>n?uW(e,n):{},[n]);return{...o,...a}}}let uH=e=>uG(p3(),n=>n.slots?.[e]);function uK(e){let n=uH(e);return n?.assignedExtensions??[]}function uY(e,n){let{moduleName:t}=(0,uB.useContext)(uR),r=(0,uB.useRef)(!0);if(!t)throw Error("ComponentContext has not been provided. This should come from @openmrs/esm-react-utils.");return(0,uB.useEffect)(()=>{ud(t,e,n),r.current=!1},[]),(0,uB.useEffect)(()=>{r.current||uf(e,n)},[e,n]),{extensions:uK(e),extensionSlotName:e,extensionSlotModuleName:t}}function uZ(e){return e}function uJ({name:e,extensionSlotName:n,select:t=uZ,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??n,l=(0,uB.useRef)(null),{extensions:c,extensionSlotModuleName:p}=uY(s,o),u=(0,uB.useMemo)(()=>t(c),[t,c]),d=(0,uB.useMemo)(()=>{if("function"==typeof r&&!uj().isValidElement(r))return u.map(e=>r(e,o))},[r,u]);return uj().createElement("div",{ref:l,"data-extension-slot-name":s,"data-extension-slot-module-name":p,style:{...a,position:"relative"},...i},s&&u?.map((e,n)=>uj().createElement(uR.Provider,{key:e.id,value:{moduleName:p,featureName:"",extension:{extensionId:e.id,extensionSlotName:s,extensionSlotModuleName:p}}},d?.[n]??("function"!=typeof r?r:null)??uj().createElement(uL,{state:o}))))}var uX=t(5873);function uQ(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),t.push.apply(t,r)}return t}function u0(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?uQ(Object(t),!0).forEach(function(n){var r,o,a;r=e,o=n,a=t[n],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(t)):uQ(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})}return e}function u1(e){return(u1="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 u2(e){return(u2="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 u3(e,n){var t;if("function"!=typeof(t=n.domElement?function(){return n.domElement}:n.domElementGetter?n.domElementGetter:e.domElementGetter?e.domElementGetter:function(e){var n=e.appName||e.name;if(!n)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 t="single-spa-application:".concat(n);return function(){var e=document.getElementById(t);return e||((e=document.createElement("div")).id=t,document.body.appendChild(e)),e}}(n)))throw Error("single-spa's dom-element-getter-helpers was given an invalid domElementGetter for application or parcel '".concat(n.name,"'. Expected a function, received ").concat(u2(t)));return function(){var e=t(n);if(!(e instanceof HTMLElement))throw Error("single-spa's dom-element-getter-helpers: domElementGetter returned an invalid dom element for application or parcel '".concat(n.name,"'. Expected HTMLElement, received ").concat(u2(e)));return e}}var u5=null;try{u5=require("react").createContext()}catch(e){}var u4={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 u6(e,n){return e.rootComponent?Promise.resolve():e.loadRootComponent(n).then(function(n){e.rootComponent=n})}function u7(e,n){return new Promise(function(t,r){e.suppressComponentDidCatchWarning||!function(e){if(!(e&&"string"==typeof e.version&&e.version.indexOf(".")>=0))return!1;var n=e.version.slice(0,e.version.indexOf("."));try{return Number(n)>=16}catch(e){return!1}}(e.React)||e.errorBoundary||e.errorBoundaryClass||(e.rootComponent.prototype?e.rootComponent.prototype.componentDidCatch||console.warn("single-spa-react: ".concat(n.name||n.appName||n.childAppName,"'s rootComponent should implement componentDidCatch to avoid accidentally unmounting the entire single-spa application.")):console.warn("single-spa-react: ".concat(n.name||n.appName||n.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=dn(e,n,function(){t(this)}),i=u3(e,n)(),s=function(e){var n=e.reactDom,t=e.renderType,r=e.elementToRender,o=e.domElement,a=n[t];if("function"!=typeof a)throw Error('renderType "'.concat(t,'" did not return a function.'));switch(t){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:de(e),renderType:"function"==typeof(o=e).renderType?o.renderType():o.renderType});e.domElements[n.name]=i,e.renderResults[n.name]=s})}function u8(e,n){return new Promise(function(t){e.unmountResolves[n.name]=t;var r=e.renderResults[n.name];r&&r.unmount?r.unmount():de(e).unmountComponentAtNode(e.domElements[n.name]),delete e.domElements[n.name],delete e.renderResults[n.name]})}function u9(e,n){return new Promise(function(t){e.updateResolves[n.name]||(e.updateResolves[n.name]=[]),e.updateResolves[n.name].push(t);var r=dn(e,n,null),o=e.renderResults[n.name];if(o&&o.render)o.render(r);else{var a=u3(e,n)();de(e).render(r,a)}})}function de(e){return e.ReactDOMClient||e.ReactDOM}function dn(e,n,t){var r=e.React.createElement(e.rootComponent,n),o=u5?e.React.createElement(u5.Provider,{value:n},r):r;return(e.errorBoundary||n.errorBoundary||e.errorBoundaryClass||n.errorBoundaryClass)&&(e.errorBoundaryClass=e.errorBoundaryClass||n.errorBoundaryClass||function(e,n){function t(n){e.React.Component.apply(this,arguments),this.state={caughtError:null,caughtErrorInfo:null},t.displayName="SingleSpaReactErrorBoundary(".concat(n.name,")")}return t.prototype=Object.create(e.React.Component.prototype),t.prototype.render=function(){return this.state.caughtError?(e.errorBoundary||n.errorBoundary)(this.state.caughtError,this.state.caughtErrorInfo,this.props):this.props.children},t.prototype.componentDidCatch=function(e,n){this.setState({caughtError:e,caughtErrorInfo:n})},t}(e,n),o=e.React.createElement(e.errorBoundaryClass,n,o)),o=e.React.createElement(e.SingleSpaRoot,u0(u0({},n),{},{mountFinished:t,updateFinished:function(){e.updateResolves[n.name]&&(e.updateResolves[n.name].forEach(function(e){return e()}),delete e.updateResolves[n.name])},unmountFinished:function(){e.unmountResolves[n.name]&&(e.unmountResolves[n.name](),delete e.unmountResolves[n.name])}}),o)}var dt=t(4011),dr=t(1123),da=t(2372);let di={strictMode:!0,throwErrorsToConsole:!0,disableTranslations:!1},ds=new Map;(0,da.r2)(ds);let dl={errorRetryCount:3,fetcher:oN,focusThrottleInterval:18e5,revalidateIfStale:!0,revalidateOnFocus:!1,revalidateOnReconnect:!1,refreshInterval:0,shouldRetryOnError:e=>{if(e instanceof oB){let n=e.response.status;return!!(n>=500)||401===n||403===n||429===n}return!0},provider:()=>ds};function dc(e){if("object"!=typeof e||"string"!=typeof e.featureName||"string"!=typeof e.moduleName)throw Error("Invalid options");let n=Object.assign({},di,e),t={...dl,...n.swrConfig};return function(e){var r,o,a,i,s;return a=o=class extends(r=uj().Component){componentDidCatch(e,t){t&&t.componentStack&&(e.extra=Object.assign(e.extra||{},{componentStack:t.componentStack})),n.throwErrorsToConsole&&setTimeout(()=>{throw e}),this.setState({caughtError:e,caughtErrorInfo:t})}render(){if(this.state.caughtError)return uj().createElement("div",null,"An error has occurred. Please try reloading the page.");{let r=uj().createElement(uB.Suspense,{fallback:null},uj().createElement(dr.BE,{value:t},uj().createElement(uR.Provider,{value:this.state.config},n.disableTranslations?uj().createElement(e,this.props):uj().createElement(dt.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},uj().createElement(e,this.props)))));return n.strictMode&&uj().StrictMode?uj().createElement(uj().StrictMode,null,r):r}}constructor(e){super(e),this.state={caughtError:null,caughtErrorInfo:null,config:{moduleName:n.moduleName,featureName:n.featureName,extension:e._extensionContext}}}},i="displayName",s=`OpenmrsReactComponent(${n.featureName})`,i in a?Object.defineProperty(a,i,{value:s,enumerable:!0,configurable:!0,writable:!0}):a[i]=s,o}}function dp(e,n){return function(e){if("object"!==u1(e))throw Error("single-spa-react requires a configuration object");var n,t=u0(u0({},u4),e);if(!t.React)throw Error("single-spa-react must be passed opts.React");if(!t.ReactDOM&&!t.ReactDOMClient)throw Error("single-spa-react must be passed opts.ReactDOM or opts.ReactDOMClient");if(t.renderType||(null!=(n=t.ReactDOMClient)&&n.createRoot?t.renderType="createRoot":t.renderType="render"),!t.rootComponent&&!t.loadRootComponent)throw Error("single-spa-react must be passed opts.rootComponent or opts.loadRootComponent");if(t.errorBoundary&&"function"!=typeof t.errorBoundary)throw Error("The errorBoundary opt for single-spa-react must either be omitted or be a function that returns React elements");!u5&&t.React.createContext&&(u5=t.React.createContext()),t.SingleSpaRoot=function(e){function n(e){n.displayName="SingleSpaRoot(".concat(e.name,")")}return n.prototype=Object.create(e.React.Component.prototype),n.prototype.componentDidMount=function(){setTimeout(this.props.mountFinished)},n.prototype.componentWillUnmount=function(){setTimeout(this.props.unmountFinished)},n.prototype.render=function(){return setTimeout(this.props.updateFinished),this.props.children},n}(t);var r={bootstrap:u6.bind(null,t),mount:u7.bind(null,t),unmount:u8.bind(null,t)};return t.parcelCanUpdate&&(r.update=u9.bind(null,t)),r}({React:uj(),ReactDOMClient:uX,rootComponent:dc(n)(e)})}function du(e,n){return()=>e().then(({default:e})=>dp(e,n))}function dd(e,n){return()=>Promise.resolve(dp(e,n))}let df=du,dh=L()(()=>({}));U("openmrs-app-context",dh);let dm={};function dg(e,n=e=>e){let t=dh.getState();return e in t?Object.freeze(Object.assign({},n?n(t[e]):t[e])):null}function dy(e,n){dh.setState(t=>(e in t||(t[e]={}),t[e]=n(t[e]),Object.assign({},t)))}function db(e){return null===e?null:Object.freeze(Object.assign({},e))}let d_=new Map;function dv(e,n){let t=(0,uB.useRef)(n??{}),r=(0,uB.useRef)(n=>dy(e,n)),o=(0,uB.useRef)(Symbol());return(0,uB.useEffect)(()=>{let t=n??{},r=o.current;return null===dg(e)?!function(e,n=dm){dh.setState(t=>{if(e in t)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({},t,{[e]:n===dm?{}:n})})}(e,t):(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.`),dy(e,()=>t)),d_.set(e,r),()=>{d_.get(e)===r&&(dh.setState(n=>(e in n&&delete n[e],n)),d_.delete(e))}},[e]),(0,uB.useEffect)(()=>{let r=n??{};B(t.current,r)||(dy(e,()=>r),t.current=r)},[n]),r.current}function d$({namespace:e,value:n}){return dv(e,n),null}let dA=({children:e,value:n,fallback:t})=>n?uj().createElement(uj().Fragment,null,e):t?uj().createElement(uj().Fragment,null,t):null;function dw(){let e=(0,uB.useRef)();return(!e.current||e.current.signal.aborted)&&(e.current=new AbortController),(0,uB.useEffect)(()=>{let n=e.current;return()=>n?.abort()},[]),e.current}function dk(e,n=e=>e??{}){let[t,r]=(0,uB.useState)(()=>{if(dx(e))return;let t=dg(e);if(null!==t)return n?n(t):t});return(0,uB.useEffect)(()=>{if(dx(e))throw Error(`The namespace supplied to useAppContext must be a non-empty string, but was "${e}".`)},[e]),(0,uB.useEffect)(()=>{var t;let o;return(t=e=>{if(null==e)return void r(void 0);let t=n?n(e):e;r(e=>B(e,t)?e:t)})(db(o=dg(e))),dh.subscribe(n=>{let r=e in n?n[e]:null;r!==o&&(o=r,t(db(r)))})},[e,n]),t}function dx(e){return"string"!=typeof e||0===e.trim().length}function dC(e){let[n,t]=(0,uB.useState)([]);return(0,uB.useEffect)(()=>p3().subscribe(r=>{let o=r.slots[e]?.assignedExtensions.map(e=>e.id)??[];(0,nn.A)(o,n)||t(o)}),[]),n}function dE(e,n){let{data:t,error:r,mutate:o,isLoading:a,isValidating:i}=(0,dr.Ay)(`${aR}?patient=${e}&includeEncounterless=${n}`,oN);return(0,uB.useMemo)(()=>({isLoading:a,data:t?.data.results??[],error:r,mutate:o,isValidating:i}),[t,r,a,i,o])}function dS(e){(0,uB.useEffect)(()=>{if(e){let e=window.getComputedStyle(document.body).overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=e}}},[e])}let dD={},dz=`No ComponentContext has been provided. This should come from "openmrsComponentDecorator".
15
+ ${this.stack}`}}let oj=G("session",{loaded:!1,session:null}),oR=0;function oF(e={includeAuthStatus:!0}){return(oR<Date.now()-6e4||!oj.getState().loaded)&&oV(),new es.Observable(n=>{let t=t=>{t.loaded&&(e.includeAuthStatus?n.next(t.session):n.next(t.session?.user))};return t(oj.getState()),oj.subscribe(t)})}function oL(){return(oR<Date.now()-6e4||!oj.getState().loaded)&&oV(),oj}function oW(e){let n=e.locale??e.user?.userProperties?.defaultLocale;n&&n.includes("_")&&(n=n.replaceAll("_","-")),function(e){if(void 0===e||"string"!=typeof e)return!1;try{new Intl.Locale(e)}catch(e){return!1}return!0}(n)&&n!==document.documentElement.getAttribute("lang")&&document.documentElement.setAttribute("lang",n)}function oV(e,n){oR=Date.now();let t={};return e&&n&&(t.Authorization=`Basic ${window.btoa(`${e}:${n}`)}`),oZ(oN(oT,{headers:t}))}function oG(){oj.setState({loaded:!0,session:{authenticated:!1,sessionId:""}})}function oU(e,n){var t,r;if(void 0===n)return!e;if(!e)return!0;return t=e,r=n,("string"==typeof t?!Y(r.privileges.find(e=>t===e.display)):Array.isArray(t)?t.every(e=>!Y(r.privileges.find(n=>e===n.display))):(Y(t)||console.error(`Could not understand privileges "${t}"`),!0))||!Y(n.roles.find(e=>"System Developer"===e.display))}function oq(){let e,n;return new Promise(t=>{let r=r=>{r.loaded&&r.session.user&&(e=r.session.user,t(r.session.user),n&&n())};r(oj.getState()),e||(n=oj.subscribe(r))})}function oH(){return new Promise((e,n)=>{oF().subscribe(n=>{e(n.sessionLocation)},n).unsubscribe()})}async function oK(e,n){return oZ(oN(oT,{method:"POST",body:{sessionLocation:e},headers:{"Content-Type":"application/json"},signal:n.signal}))}async function oY(e,n,t){return t||(t=new AbortController),await oN(`${oM}/user/${e}`,{method:"POST",body:{userProperties:n},headers:{"Content-Type":"application/json"},signal:t.signal}),oV()}function oZ(e){return new Promise((n,t)=>{e.then(e=>{let r;"object"==typeof e?.data?(r={loaded:!0,session:e.data},oj.setState(r),n(r)):(r={loaded:!1,session:null},oj.setState(r),t(r))}).catch(e=>{O(`Failed to fetch new session information: ${e}`);let n={loaded:!1,session:null};oj.setState(n),t(n)})})}function oJ(){return"development"===window.spaEnv||"true"===localStorage.getItem("openmrs:devtools")}oj.subscribe(e=>{e.loaded&&e.session&&oW(e.session)});let oX={"webservices.rest":"2.24.0",fhir2:"1.0.0-SNAPSHOT"};function oQ(){t_("@openmrs/esm-api",oD),oV()}let o0={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",discardUnsavedChangesPromptBodyMultiple:"{{count}} workspaces have unsaved changes. Closing them will discard the changes:",discardUnsavedChangesPromptBodySingle:"<strong>{{workspaceTitle}}</strong> has unsaved changes. Closing it will discard them.",discardUnsavedChangesPromptTitle:"Discard unsaved changes?",keepEditing:"Keep editing",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",localVersion:"Local Build",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}}",prereleaseVersion:"Prerelease",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 o1=t(4557),o2=t.n(o1);let o3=o2().default||o2();function o5(e,n,t,r){return o3.t(n,{ns:e,defaultValue:t,...r})}function o4(e,n,t){return o0[e]?o5("core",e,n??o0[e],t):(console.error(`O3 Core Translations does not provide key '${e}'. The key itself is being rendered as text.`),e)}o3.on("initialized",function(){window.i18next.loadNamespaces(["core"])});let o6="import-map-override:",o7="import-map-overrides-disabled",o8="import-map-overrides:change",o9=!1,ae=null;async function an(){let e=document.querySelectorAll('script[type="systemjs-importmap"]'),n=[];for(let t=0;t<e.length;t++){let r=e[t];try{if(r.src){let e=await fetch(r.src);n.push(await e.json())}else r.textContent&&n.push(JSON.parse(r.textContent))}catch(e){console.warn(`[import-maps] Failed to parse import map from script tag at index ${t}`,e)}}return at(n)}function at(e){let n={imports:{}};for(let t of e)t?.imports&&Object.assign(n.imports,t.imports);return n}function ar(){let e={};try{let n=al();for(let t=0;t<localStorage.length;t++){let r=localStorage.key(t);if(r?.startsWith(o6)){let t=r.slice(o6.length);if(!n.includes(t)){let n=localStorage.getItem(r);n&&(e[t]=n)}}}}catch(e){console.warn("[import-maps] Failed to read import-map overrides from localStorage",e)}return{imports:e}}async function ao(){let e=await an();return o9?at([e,ae??ar()]):e}async function aa(){return an()}async function ai(){return o9?at([await an(),ar()]):an()}function as(e){if(!o9)return{imports:{}};if(e){let e={};for(let n=0;n<localStorage.length;n++){let t=localStorage.key(n);if(t?.startsWith(o6)){let n=localStorage.getItem(t);n&&(e[t.slice(o6.length)]=n)}}return{imports:e}}return ar()}function al(){if(!o9)return[];try{let e=localStorage.getItem(o7);if(e){let n=JSON.parse(e);if(Array.isArray(n))return n}}catch{}return[]}function ac(e){return!!o9&&al().includes(e)}function ap(e,n){if(!o9)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{localStorage.setItem(o6+e,n),window.dispatchEvent(new CustomEvent(o8))}catch(e){console.warn("[import-maps] Failed to write import-map override to localStorage",e)}}function au(e){if(!o9)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{localStorage.removeItem(o6+e);let n=al().filter(n=>n!==e);n.length>0?localStorage.setItem(o7,JSON.stringify(n)):localStorage.removeItem(o7),window.dispatchEvent(new CustomEvent(o8))}catch(e){console.warn("[import-maps] Failed to update import-map overrides in localStorage",e)}}function ad(){if(!o9)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{let e=[];for(let n=0;n<localStorage.length;n++){let t=localStorage.key(n);t?.startsWith(o6)&&e.push(t)}e.forEach(e=>localStorage.removeItem(e)),localStorage.removeItem(o7),window.dispatchEvent(new CustomEvent(o8))}catch(e){console.warn("[import-maps] Failed to clear import-map overrides from localStorage",e)}}function af(e){if(!o9)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{let n=al().filter(n=>n!==e);n.length>0?localStorage.setItem(o7,JSON.stringify(n)):localStorage.removeItem(o7),window.dispatchEvent(new CustomEvent(o8))}catch(e){console.warn("[import-maps] Failed to update import-map overrides in localStorage",e)}}let ah=!1;function am(){!ah&&(ah=!0,(o9="development"===window.spaEnv)&&(ae=ar()))}function ag(e){return e.replace(/[\/\-@]/g,"_")}async function ay(e,n="./start",r){var o;let a,i=!r?.maxLoadingTime||r.maxLoadingTime<=0?6e5:r.maxLoadingTime;await Promise.race([ab(e,r?.importMap),new Promise((n,t)=>{a=setTimeout(()=>{var n;t(Error(`Could not resolve requested script, ${e}, within ${(n=i)<1e3?`${n} milliseconds`:n<6e4?`${Math.floor(n/1e3)} seconds`:n<36e5?`${Math.floor(n/6e4)} minutes`:n<864e5?`${Math.floor(n/36e5)} hours`:`${Math.floor(n/864e5)} days`}.`))},i)})]),a&&clearTimeout(a);let s=ag(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(t.S.default);let c=(await l.get(n))();if("object"!=typeof c||null===c){let n=`Container for ${e} did not return an ESM module as expected`;throw console.error(n),Error(n)}return c}async function ab(e,n){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 t=ag(e);if(!window[t]){let t=n??await a_();if(!t.imports.hasOwnProperty(e)){let n=`Could not find the package ${e} defined in the current importmap`;throw console.error(n),Error(n)}let r=t.imports[e];r.startsWith("./")&&(r=window.spaBase+r.substring(1));let o=e in as().imports;try{return await new Promise((e,n)=>{!function(e,n,t){let r=document.head.querySelector(`script[src="${e}"]`),o=window[av];if(o||(o=window[av]=new Set([])),r)if(o.has(e)){let e,o,a;a=()=>{e&&r.removeEventListener("load",e),o&&r.removeEventListener("error",o)},e=()=>{a(),n(null)},o=e=>{a(),t(e.message)},r.addEventListener("load",e),r.addEventListener("error",o)}else console.warn(`Script at ${e} already loaded. Not loading it again.`),n(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(),n(null)},a=n=>{i();let r=`Failed to load script from ${e}`;console.error(r,n),t(n.message??r)},s.addEventListener("load",r),s.addEventListener("error",a),document.head.appendChild(s)}}(r,e,n)})}catch(e){return o&&D({kind:"error",title:o4("scriptLoadingFailed","Error: Script failed to load"),description:o4("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:o4("resetOverrides","Reset overrides"),onActionButtonClick(){ad(),window.location.reload()}}),Promise.reject(e)}}return Promise.resolve()}async function a_(){return ao()}let av=Symbol("__openmrs_script_loading");function a$(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 aA(e){return!!e&&"object"==typeof e&&"routes"in e&&!!e.routes&&"object"==typeof e.routes&&Object.entries(e.routes).every(([e,n])=>"string"==typeof e&&a$(n))}let aw="openmrs-routes:",ak="openmrs-routes:change",ax=!1,aC=null;async function aE(){let e=document.querySelectorAll("script[type='openmrs-routes']"),n=[];for(let t=0;t<e.length;t++){let r=e[t];try{let e;if(r.src){let n=await fetch(r.src);e=await n.json()}else r.textContent&&(e=JSON.parse(r.textContent));e&&aA(e)&&n.push(e)}catch(e){console.warn(`[route-maps] Failed to parse routes from script tag at index ${t}`,e)}}return aS(n)}function aS(e){let n={routes:{}};for(let t of e)t&&"object"==typeof t&&!Array.isArray(t)&&(Object.assign(n.routes,t.routes),void 0===n.version&&void 0!==t.version&&(n.version=t.version));return n}async function aD(){let e={version:void 0,routes:{}};try{let n=[];for(let e=0;e<localStorage.length;e++){let t=localStorage.key(e);if(t?.startsWith(aw)){let e=localStorage.getItem(t);e&&n.push({moduleName:t.slice(aw.length),raw:e})}}for(let t of(await Promise.allSettled(n.map(async({moduleName:e,raw:n})=>{let t=JSON.parse(n);if(a$(t))return{moduleName:e,routes:t};if("string"==typeof t&&t.startsWith("http")){let n=await fetch(t),r=await n.json();if(a$(r))return{moduleName:e,routes:r};throw Error(`${t} did not resolve to a valid OpenmrsAppRoutes object`)}throw Error(`Override for ${e} is neither a valid routes object nor a URL`)}))))"fulfilled"===t.status?e.routes[t.value.moduleName]=t.value.routes:console.warn("[route-maps] Failed to load route override",t.reason)}catch(e){console.warn("[route-maps] Failed to read route overrides from localStorage",e)}return e}async function az(){let e=await aE();return ax?aS([e,aC??await aD()]):e}async function aM(){return aE()}async function aP(){return ax?aS([await aE(),await aD()]):aE()}function aT(){if(!ax)return{};let e={};try{for(let n=0;n<localStorage.length;n++){let t=localStorage.key(n);if(t?.startsWith(aw)){let n=localStorage.getItem(t);n&&(e[t.slice(aw.length)]=n)}}}catch(e){console.warn("[route-maps] Failed to read route overrides from localStorage",e)}return e}function aO(e,n){if(!ax)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{if("string"==typeof n)if(n.startsWith("http"))localStorage.setItem(aw+e,JSON.stringify(n));else{let t=JSON.parse(n);if(!a$(t))return void console.error(`The supplied routes for ${e} is not a valid OpenmrsAppRoutes object`,n);localStorage.setItem(aw+e,JSON.stringify(t))}else if(n instanceof URL)localStorage.setItem(aw+e,JSON.stringify(n.toString()));else{if(!a$(n))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`,n);localStorage.setItem(aw+e,JSON.stringify(n))}window.dispatchEvent(new CustomEvent(ak))}catch(e){console.warn("[route-maps] Failed to write route override to localStorage",e)}}function aN(e){if(!ax)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{localStorage.removeItem(aw+e),window.dispatchEvent(new CustomEvent(ak))}catch(e){console.warn("[route-maps] Failed to remove route override from localStorage",e)}}function aI(){if(!ax)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{let e=[];for(let n=0;n<localStorage.length;n++){let t=localStorage.key(n);t?.startsWith(aw)&&e.push(t)}e.forEach(e=>localStorage.removeItem(e)),window.dispatchEvent(new CustomEvent(ak))}catch(e){console.warn("[route-maps] Failed to clear route overrides from localStorage",e)}}let aB=null;function aj(){return aB||(aB=(ax="development"===window.spaEnv)?aD().then(e=>{aC=e}):Promise.resolve())}let aR=`${oM}/attachment`;function aF(e,n){return oN(`${aR}/${e}`,{signal:n.signal})}function aL(e,n,t){return oN(`${aR}?patient=${e}&includeEncounterless=${n}`,{signal:t.signal})}async function aW(e,n){let t=new FormData;return t.append("fileCaption",n.fileDescription),t.append("patient",e),n.file?t.append("file",n.file,n.fileName):(t.append("file",new File([""],n.fileName),n.fileName),t.append("base64Content",n.base64Content)),oN(`${aR}`,{method:"POST",body:t})}function aV(e,n){return oN(`${aR}/${e}`,{method:"DELETE",signal:n.signal})}try{self["workbox:window:6.5.4"]&&_()}catch(e){}function aG(e,n){return new Promise(function(t){var r=new MessageChannel;r.port1.onmessage=function(e){t(e.data)},e.postMessage(n,[r.port2])})}function aU(e,n){for(var t=0;t<n.length;t++){var r=n[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function aq(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=Array(n);t<n;t++)r[t]=e[t];return r}try{self["workbox:core:6.5.4"]&&_()}catch(e){}var aH=function(){var e=this;this.promise=new Promise(function(n,t){e.resolve=n,e.reject=t})};function aK(e,n){var t=location.href;return new URL(e,t).href===new URL(n,t).href}var aY=function(e,n){this.type=e,Object.assign(this,n)};function aZ(e,n,t){return t?n?n(e):e:(e&&e.then||(e=Promise.resolve(e)),n?e.then(n):e)}function aJ(){}var aX={type:"SKIP_WAITING"};function aQ(e,n){if(!n)return e&&e.then?e.then(aJ):Promise.resolve()}var a0=function(e){function n(n,t){var r,o;return void 0===t&&(t={}),(r=e.call(this)||this).nn={},r.tn=0,r.rn=new aH,r.en=new aH,r.on=new aH,r.un=0,r.an=new Set,r.cn=function(){var e=r.fn,n=e.installing;r.tn>0||!aK(n.scriptURL,r.sn.toString())||performance.now()>r.un+6e4?(r.vn=n,e.removeEventListener("updatefound",r.cn)):(r.hn=n,r.an.add(n),r.rn.resolve(n)),++r.tn,n.addEventListener("statechange",r.ln)},r.ln=function(e){var n=r.fn,t=e.target,o=t.state,a=t===r.vn,i={sw:t,isExternal:a,originalEvent:e};!a&&r.mn&&(i.isUpdate=!0),r.dispatchEvent(new aY(o,i)),"installed"===o?r.wn=self.setTimeout(function(){"installed"===o&&n.waiting===t&&r.dispatchEvent(new aY("waiting",i))},200):"activating"===o&&(clearTimeout(r.wn),a||r.en.resolve(t))},r.dn=function(e){var n=r.hn,t=n!==navigator.serviceWorker.controller;r.dispatchEvent(new aY("controlling",{isExternal:t,originalEvent:e,sw:n,isUpdate:r.mn})),t||r.on.resolve(n)},o=function(e){var n=e.data,t=e.ports,o=e.source;return aZ(r.getSW(),function(){r.an.has(o)&&r.dispatchEvent(new aY("message",{data:n,originalEvent:e,ports:t,sw:o}))})},r.gn=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];try{return Promise.resolve(o.apply(this,e))}catch(e){return Promise.reject(e)}},r.sn=n,r.nn=t,navigator.serviceWorker.addEventListener("message",r.gn),r}n.prototype=Object.create(e.prototype),n.prototype.constructor=n,n.__proto__=e;var t,r,o=n.prototype;return o.register=function(e){var n=(void 0===e?{}:e).immediate,t=void 0!==n&&n;try{var r,o,a,i=this;return r=function(){if(!t&&"complete"!==document.readyState)return aQ(new Promise(function(e){return window.addEventListener("load",e)}))},o=function(){return i.mn=!!navigator.serviceWorker.controller,i.yn=i.pn(),aZ(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 n=i.fn.waiting;return n&&aK(n.scriptURL,i.sn.toString())&&(i.hn=n,Promise.resolve().then(function(){i.dispatchEvent(new aY("waiting",{sw:n,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?aQ(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 aZ(this.getSW(),function(n){return aG(n,e)})}catch(e){return Promise.reject(e)}},o.messageSkipWaiting=function(){this.fn&&this.fn.waiting&&aG(this.fn.waiting,aX)},o.pn=function(){var e=navigator.serviceWorker.controller;return e&&aK(e.scriptURL,this.sn.toString())?e:void 0},o.bn=function(){try{var e=this;return function(e,n){try{var t=e()}catch(e){return n(e)}return t&&t.then?t.then(void 0,n):t}(function(){return aZ(navigator.serviceWorker.register(e.sn,e.nn),function(n){return e.un=performance.now(),n})},function(e){throw e})}catch(e){return Promise.reject(e)}},t=[{key:"active",get:function(){return this.en.promise}},{key:"controlling",get:function(){return this.on.promise}}],aU(n.prototype,t),r&&aU(n,r),n}(function(){function e(){this.Pn=new Map}var n=e.prototype;return n.addEventListener=function(e,n){this.Sn(e).add(n)},n.removeEventListener=function(e,n){this.Sn(e).delete(n)},n.dispatchEvent=function(e){e.target=this;for(var n,t=function(e){var n;if("u"<typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e){if(e){if("string"==typeof e)return aq(e,void 0);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?aq(e,void 0):void 0}}(e))){n&&(e=n);var t=0;return function(){return t>=e.length?{done:!0}:{done:!1,value:e[t++]}}}throw TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(n=e[Symbol.iterator]()).next.bind(n)}(this.Sn(e.type));!(n=t()).done;)(0,n.value)(e)},n.Sn=function(e){return this.Pn.has(e)||this.Pn.set(e,new Set),this.Pn.get(e)},e}());function a1(e,n){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 t=new a0(e,n);return u=t.register().then(()=>t.controlling.then(()=>t))}function a2(){return u??Promise.resolve(void 0)}let a3="x-omrs-offline-response-body",a5="x-omrs-offline-response-status",a4="x-omrs-offline-caching-strategy";async function a6(e){let n=await a2();return n?await n.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 a7(){let e=window.sessionStorage;try{e.setItem("someKeyHere","test"),e.removeItem("someKeyHere")}catch(n){if(n.code===DOMException.QUOTA_EXCEEDED_ERR&&0===e.length)return!0}return!1}async function a8(){return!window.indexedDB}async function a9(){return new Promise(e=>{let n=indexedDB.open("test");n.onerror=()=>e(!0),n.onsuccess=()=>e(!1)})}async function ie(){return await a9()||await a8()||await a7()}let it="openmrs3:offline-mode",ir="unavailable";function io(){return{current:ir,notAvailable:"unavailable"===ir,active:"on"===ir}}function ia(e){"unavailable"!==ir&&"unavailable"!==e&&(localStorage.setItem(it,"on"===e?"active":"disabled"),ir=e)}async function ii(){await ie()||(ir="active"===localStorage.getItem(it)?"on":"off"),navigator.onLine}let is="u">typeof globalThis?globalThis:"u">typeof self?self:"u">typeof window?window:global,il=Object.keys,ic=Array.isArray;function ip(e,n){return"object"!=typeof n||il(n).forEach(function(t){e[t]=n[t]}),e}"u"<typeof Promise||is.Promise||(is.Promise=Promise);let iu=Object.getPrototypeOf,id={}.hasOwnProperty;function ih(e,n){return id.call(e,n)}function im(e,n){"function"==typeof n&&(n=n(iu(e))),("u"<typeof Reflect?il:Reflect.ownKeys)(n).forEach(t=>{iy(e,t,n[t])})}let ig=Object.defineProperty;function iy(e,n,t,r){ig(e,n,ip(t&&ih(t,"get")&&"function"==typeof t.get?{get:t.get,set:t.set,configurable:!0}:{value:t,configurable:!0,writable:!0},r))}function ib(e){return{from:function(n){return e.prototype=Object.create(n.prototype),iy(e.prototype,"constructor",e),{extend:im.bind(null,e.prototype)}}}}let i_=Object.getOwnPropertyDescriptor;function iv(e,n){let t;return i_(e,n)||(t=iu(e))&&iv(t,n)}let i$=[].slice;function iA(e,n,t){return i$.call(e,n,t)}function iw(e,n){return n(e)}function ik(e){if(!e)throw Error("Assertion Failed")}function ix(e){is.setImmediate?setImmediate(e):setTimeout(e,0)}function iC(e,n){return e.reduce((e,t,r)=>{var o=n(t,r);return o&&(e[o[0]]=o[1]),e},{})}function iE(e,n){if(ih(e,n))return e[n];if(!n)return e;if("string"!=typeof n){for(var t=[],r=0,o=n.length;r<o;++r){var a=iE(e,n[r]);t.push(a)}return t}var i=n.indexOf(".");if(-1!==i){var s=e[n.substr(0,i)];return void 0===s?void 0:iE(s,n.substr(i+1))}}function iS(e,n,t){if(e&&void 0!==n&&(!("isFrozen"in Object)||!Object.isFrozen(e)))if("string"!=typeof n&&"length"in n){ik("string"!=typeof t&&"length"in t);for(var r=0,o=n.length;r<o;++r)iS(e,n[r],t[r])}else{var a=n.indexOf(".");if(-1!==a){var i=n.substr(0,a),s=n.substr(a+1);if(""===s)void 0===t?ic(e)&&!isNaN(parseInt(i))?e.splice(i,1):delete e[i]:e[i]=t;else{var l=e[i];l&&ih(e,i)||(l=e[i]={}),iS(l,s,t)}}else void 0===t?ic(e)&&!isNaN(parseInt(n))?e.splice(n,1):delete e[n]:e[n]=t}}function iD(e){var n={};for(var t in e)ih(e,t)&&(n[t]=e[t]);return n}let iz=[].concat;function iM(e){return iz.apply([],e)}let iP="Boolean,String,Date,RegExp,Blob,File,FileList,FileSystemFileHandle,ArrayBuffer,DataView,Uint8ClampedArray,ImageBitmap,ImageData,Map,Set,CryptoKey".split(",").concat(iM([8,16,32,64].map(e=>["Int","Uint","Float"].map(n=>n+e+"Array")))).filter(e=>is[e]),iT=iP.map(e=>is[e]);iC(iP,e=>[e,!0]);let iO=null;function iN(e){iO="u">typeof WeakMap&&new WeakMap;let n=function e(n){if(!n||"object"!=typeof n)return n;let t=iO&&iO.get(n);if(t)return t;if(ic(n)){t=[],iO&&iO.set(n,t);for(var r=0,o=n.length;r<o;++r)t.push(e(n[r]))}else if(iT.indexOf(n.constructor)>=0)t=n;else{let r=iu(n);for(var a in t=r===Object.prototype?{}:Object.create(r),iO&&iO.set(n,t),n)ih(n,a)&&(t[a]=e(n[a]))}return t}(e);return iO=null,n}let{toString:iI}={};function iB(e){return iI.call(e).slice(8,-1)}let ij="u">typeof Symbol?Symbol.iterator:"@@iterator",iR="symbol"==typeof ij?function(e){var n;return null!=e&&(n=e[ij])&&n.apply(e)}:function(){return null},iF={};function iL(e){var n,t,r,o;if(1==arguments.length){if(ic(e))return e.slice();if(this===iF&&"string"==typeof e)return[e];if(o=iR(e)){for(t=[];!(r=o.next()).done;)t.push(r.value);return t}if(null==e)return[e];if("number"==typeof(n=e.length)){for(t=Array(n);n--;)t[n]=e[n];return t}return[e]}for(n=arguments.length,t=Array(n);n--;)t[n]=arguments[n];return t}let iW="u">typeof Symbol?e=>"AsyncFunction"===e[Symbol.toStringTag]:()=>!1;var iV="u">typeof location&&/^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href),iG=()=>!0;let iU=!Error("").stack;function iq(){if(iU)try{throw iq.arguments,Error()}catch(e){return e}return Error()}function iH(e,n){var t=e.stack;return t?(n=n||0,0===t.indexOf(e.name)&&(n+=(e.name+e.message).split("\n").length),t.split("\n").slice(n).filter(iG).map(e=>"\n"+e).join("")):""}var iK=["Unknown","Constraint","Data","TransactionInactive","ReadOnly","Version","NotFound","InvalidState","InvalidAccess","Abort","Timeout","QuotaExceeded","Syntax","DataClone"],iY=["Modify","Bulk","OpenFailed","VersionChange","Schema","Upgrade","InvalidTable","MissingAPI","NoSuchDatabase","InvalidArgument","SubTransaction","Unsupported","Internal","DatabaseClosed","PrematureCommit","ForeignAwait"].concat(iK),iZ={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 iJ(e,n){this._e=iq(),this.name=e,this.message=n}function iX(e,n){return e+". Errors: "+Object.keys(n).map(e=>n[e].toString()).filter((e,n,t)=>t.indexOf(e)===n).join("\n")}function iQ(e,n,t,r){this._e=iq(),this.failures=n,this.failedKeys=r,this.successCount=t,this.message=iX(e,n)}function i0(e,n){this._e=iq(),this.name="BulkError",this.failures=Object.keys(n).map(e=>n[e]),this.failuresByPos=n,this.message=iX(e,n)}ib(iJ).from(Error).extend({stack:{get:function(){return this._stack||(this._stack=this.name+": "+this.message+iH(this._e,2))}},toString:function(){return this.name+": "+this.message}}),ib(iQ).from(iJ),ib(i0).from(iJ);var i1=iY.reduce((e,n)=>(e[n]=n+"Error",e),{}),i2=iY.reduce((e,n)=>{var t=n+"Error";function r(e,r){this._e=iq(),this.name=t,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=iZ[n]||t,this.inner=null)}return ib(r).from(iJ),e[n]=r,e},{});i2.Syntax=SyntaxError,i2.Type=TypeError,i2.Range=RangeError;var i3=iK.reduce((e,n)=>(e[n+"Error"]=i2[n],e),{}),i5=iY.reduce((e,n)=>(-1===["Syntax","Type","Range"].indexOf(n)&&(e[n+"Error"]=i2[n]),e),{});function i4(){}function i6(e){return e}function i7(e,n){return null==e||e===i6?n:function(t){return n(e(t))}}function i8(e,n){return function(){e.apply(this,arguments),n.apply(this,arguments)}}function i9(e,n){return e===i4?n:function(){var t=e.apply(this,arguments);void 0!==t&&(arguments[0]=t);var r=this.onsuccess,o=this.onerror;this.onsuccess=null,this.onerror=null;var a=n.apply(this,arguments);return r&&(this.onsuccess=this.onsuccess?i8(r,this.onsuccess):r),o&&(this.onerror=this.onerror?i8(o,this.onerror):o),void 0!==a?a:t}}function se(e,n){return e===i4?n:function(){e.apply(this,arguments);var t=this.onsuccess,r=this.onerror;this.onsuccess=this.onerror=null,n.apply(this,arguments),t&&(this.onsuccess=this.onsuccess?i8(t,this.onsuccess):t),r&&(this.onerror=this.onerror?i8(r,this.onerror):r)}}function sn(e,n){return e===i4?n:function(t){var r=e.apply(this,arguments);ip(t,r);var o=this.onsuccess,a=this.onerror;this.onsuccess=null,this.onerror=null;var i=n.apply(this,arguments);return o&&(this.onsuccess=this.onsuccess?i8(o,this.onsuccess):o),a&&(this.onerror=this.onerror?i8(a,this.onerror):a),void 0===r?void 0===i?void 0:i:ip(r,i)}}function st(e,n){return e===i4?n:function(){return!1!==n.apply(this,arguments)&&e.apply(this,arguments)}}function sr(e,n){return e===i4?n:function(){var t=e.apply(this,arguments);if(t&&"function"==typeof t.then){for(var r=this,o=arguments.length,a=Array(o);o--;)a[o]=arguments[o];return t.then(function(){return n.apply(r,a)})}return n.apply(this,arguments)}}i5.ModifyError=iQ,i5.DexieError=iJ,i5.BulkError=i0;var so={};let[sa,si,ss]="u"<typeof Promise?[]:(()=>{let e=Promise.resolve();if("u"<typeof crypto||!crypto.subtle)return[e,iu(e),e];let n=crypto.subtle.digest("SHA-512",new Uint8Array([0]));return[n,iu(n),e]})(),sl=si&&si.then,sc=sa&&sa.constructor,sp=!!ss;var su=!1,sd=ss?()=>{ss.then(sT)}:is.setImmediate?setImmediate.bind(null,sT):is.MutationObserver?()=>{var e=document.createElement("div");new MutationObserver(()=>{sT(),e=null}).observe(e,{attributes:!0}),e.setAttribute("i","1")}:()=>{setTimeout(sT,0)},sf=function(e,n){sA.push([e,n]),sm&&(sd(),sm=!1)},sh=!0,sm=!0,sg=[],sy=[],sb=null,s_=i6,sv={id:"global",global:!0,ref:0,unhandleds:[],onunhandled:s3,pgp:!1,env:{},finalize:function(){this.unhandleds.forEach(e=>{try{s3(e[0],e[1])}catch(e){}})}},s$=sv,sA=[],sw=0,sk=[];function sx(e){if("object"!=typeof this)throw TypeError("Promises must be constructed via new");this._listeners=[],this.onuncatched=i4,this._lib=!1;var n=this._PSD=s$;if(iV&&(this._stackHolder=iq(),this._prev=null,this._numPrev=0),"function"!=typeof e){if(e!==so)throw TypeError("Not a function");return this._state=arguments[1],this._value=arguments[2],void(!1===this._state&&sS(this,this._value))}this._state=null,this._value=null,++n.ref,function e(n,t){try{t(t=>{if(null===n._state){if(t===n)throw TypeError("A promise cannot be resolved with itself.");var r=n._lib&&sO();t&&"function"==typeof t.then?e(n,(e,n)=>{t instanceof sx?t._then(e,n):t.then(e,n)}):(n._state=!0,n._value=t,sD(n)),r&&sN()}},sS.bind(null,n))}catch(e){sS(n,e)}}(this,e)}let sC={get:function(){var e=s$,n=sV;function t(t,r){var o=!e.global&&(e!==s$||n!==sV);let a=o&&!sH();var i=new sx((n,i)=>{sz(this,new sE(s0(t,e,o,a),s0(r,e,o,a),n,i,e))});return iV&&sP(i,this),i}return t.prototype=so,t},set:function(e){iy(this,"then",e&&e.prototype===so?sC:{get:function(){return e},set:sC.set})}};function sE(e,n,t,r,o){this.onFulfilled="function"==typeof e?e:null,this.onRejected="function"==typeof n?n:null,this.resolve=t,this.reject=r,this.psd=o}function sS(e,n){if(sy.push(n),null===e._state){var t=e._lib&&sO();n=s_(n),e._state=!1,e._value=n,iV&&null!==n&&"object"==typeof n&&!n._promise&&function(e){try{e.apply(null,void 0)}catch(e){}}(()=>{var t=iv(n,"stack");n._promise=e,iy(n,"stack",{get:()=>su?t&&(t.get?t.get.apply(n):t.value):e.stack})}),sg.some(n=>n._value===e._value)||sg.push(e),sD(e),t&&sN()}}function sD(e){var n=e._listeners;e._listeners=[];for(var t=0,r=n.length;t<r;++t)sz(e,n[t]);var o=e._PSD;--o.ref||o.finalize(),0===sw&&(++sw,sf(()=>{0==--sw&&sI()},[]))}function sz(e,n){if(null!==e._state){var t=e._state?n.onFulfilled:n.onRejected;if(null===t)return(e._state?n.resolve:n.reject)(e._value);++n.psd.ref,++sw,sf(sM,[t,e,n])}else e._listeners.push(n)}function sM(e,n,t){try{sb=n;var r,o=n._value;n._state?r=e(o):(sy.length&&(sy=[]),r=e(o),-1===sy.indexOf(o)&&function(e){for(var n=sg.length;n;)if(sg[--n]._value===e._value)return void sg.splice(n,1)}(n)),t.resolve(r)}catch(e){t.reject(e)}finally{sb=null,0==--sw&&sI(),--t.psd.ref||t.psd.finalize()}}function sP(e,n){var t=n?n._numPrev+1:0;t<100&&(e._prev=n,e._numPrev=t)}function sT(){sO()&&sN()}function sO(){var e=sh;return sh=!1,sm=!1,e}function sN(){var e,n,t;do for(;sA.length>0;)for(e=sA,sA=[],t=e.length,n=0;n<t;++n){var r=e[n];r[0].apply(null,r[1])}while(sA.length>0);sh=!0,sm=!0}function sI(){var e=sg;sg=[],e.forEach(e=>{e._PSD.onunhandled.call(null,e._value,e)});for(var n=sk.slice(0),t=n.length;t;)n[--t]()}function sB(e){return new sx(so,!1,e)}function sj(e,n){var t=s$;return function(){var r=sO(),o=s$;try{return sJ(t,!0),e.apply(this,arguments)}catch(e){n&&n(e)}finally{sJ(o,!1),r&&sN()}}}im(sx.prototype,{then:sC,_then:function(e,n){sz(this,new sE(null,null,e,n,s$))},catch:function(e){if(1==arguments.length)return this.then(null,e);var n=arguments[0],t=arguments[1];return"function"==typeof n?this.then(null,e=>e instanceof n?t(e):sB(e)):this.then(null,e=>e&&e.name===n?t(e):sB(e))},finally:function(e){return this.then(n=>(e(),n),n=>(e(),sB(n)))},stack:{get:function(){if(this._stack)return this._stack;try{su=!0;var e=(function e(n,t,r){if(t.length===r)return t;var o="";if(!1===n._state){var a,i,s=n._value;null!=s?(a=s.name||"Error",i=s.message||s,o=iH(s,0)):(a=s,i=""),t.push(a+(i?": "+i:"")+o)}return iV&&((o=iH(n._stackHolder,2))&&-1===t.indexOf(o)&&t.push(o),n._prev&&e(n._prev,t,r)),t})(this,[],20).join("\nFrom previous: ");return null!==this._state&&(this._stack=e),e}finally{su=!1}}},timeout:function(e,n){return e<1/0?new sx((t,r)=>{var o=setTimeout(()=>r(new i2.Timeout(n)),e);this.then(t,r).finally(clearTimeout.bind(null,o))}):this}}),"u">typeof Symbol&&Symbol.toStringTag&&iy(sx.prototype,Symbol.toStringTag,"Dexie.Promise"),sv.env=sX(),im(sx,{all:function(){var e=iL.apply(null,arguments).map(sK);return new sx(function(n,t){0===e.length&&n([]);var r=e.length;e.forEach((o,a)=>sx.resolve(o).then(t=>{e[a]=t,--r||n(e)},t))})},resolve:e=>{if(e instanceof sx)return e;if(e&&"function"==typeof e.then)return new sx((n,t)=>{e.then(n,t)});var n=new sx(so,!0,e);return sP(n,sb),n},reject:sB,race:function(){var e=iL.apply(null,arguments).map(sK);return new sx((n,t)=>{e.map(e=>sx.resolve(e).then(n,t))})},PSD:{get:()=>s$,set:e=>s$=e},totalEchoes:{get:()=>sV},newPSD:sU,usePSD:sQ,scheduler:{get:()=>sf,set:e=>{sf=e}},rejectionMapper:{get:()=>s_,set:e=>{s_=e}},follow:(e,n)=>new sx((t,r)=>sU((n,t)=>{var r=s$;r.unhandleds=[],r.onunhandled=t,r.finalize=i8(function(){var e;e=()=>{0===this.unhandleds.length?n():t(this.unhandleds[0])},sk.push(function n(){e(),sk.splice(sk.indexOf(n),1)}),++sw,sf(()=>{0==--sw&&sI()},[])},r.finalize),e()},n,t,r))}),sc&&(sc.allSettled&&iy(sx,"allSettled",function(){let e=iL.apply(null,arguments).map(sK);return new sx(n=>{0===e.length&&n([]);let t=e.length,r=Array(t);e.forEach((e,o)=>sx.resolve(e).then(e=>r[o]={status:"fulfilled",value:e},e=>r[o]={status:"rejected",reason:e}).then(()=>--t||n(r)))})}),sc.any&&"u">typeof AggregateError&&iy(sx,"any",function(){let e=iL.apply(null,arguments).map(sK);return new sx((n,t)=>{0===e.length&&t(AggregateError([]));let r=e.length,o=Array(r);e.forEach((e,a)=>sx.resolve(e).then(e=>n(e),e=>{o[a]=e,--r||t(AggregateError(o))}))})}));let sR={awaits:0,echoes:0,id:0};var sF=0,sL=[],sW=0,sV=0,sG=0;function sU(e,n,t,r){var o=s$,a=Object.create(o);a.parent=o,a.ref=0,a.global=!1,a.id=++sG;var i=sv.env;a.env=sp?{Promise:sx,PromiseProp:{value:sx,configurable:!0,writable:!0},all:sx.all,race:sx.race,allSettled:sx.allSettled,any:sx.any,resolve:sx.resolve,reject:sx.reject,nthen:s1(i.nthen,a),gthen:s1(i.gthen,a)}:{},n&&ip(a,n),++o.ref,a.finalize=function(){--this.parent.ref||this.parent.finalize()};var s=sQ(a,e,t,r);return 0===a.ref&&a.finalize(),s}function sq(){return sR.id||(sR.id=++sF),++sR.awaits,sR.echoes+=100,sR.id}function sH(){return!!sR.awaits&&(0==--sR.awaits&&(sR.id=0),sR.echoes=100*sR.awaits,!0)}function sK(e){return sR.echoes&&e&&e.constructor===sc?(sq(),e.then(e=>(sH(),e),e=>(sH(),s5(e)))):e}function sY(e){++sV,sR.echoes&&0!=--sR.echoes||(sR.echoes=sR.id=0),sL.push(s$),sJ(e,!0)}function sZ(){var e=sL[sL.length-1];sL.pop(),sJ(e,!1)}function sJ(e,n){var t,r=s$;if((n?!sR.echoes||sW++&&e===s$:!sW||--sW&&e===s$)||(t=n?sY.bind(null,e):sZ,sl.call(sa,t)),e!==s$&&(s$=e,r===sv&&(sv.env=sX()),sp)){var o=sv.env.Promise,a=e.env;si.then=a.nthen,o.prototype.then=a.gthen,(r.global||e.global)&&(Object.defineProperty(is,"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 sX(){var e=is.Promise;return sp?{Promise:e,PromiseProp:Object.getOwnPropertyDescriptor(is,"Promise"),all:e.all,race:e.race,allSettled:e.allSettled,any:e.any,resolve:e.resolve,reject:e.reject,nthen:si.then,gthen:e.prototype.then}:{}}function sQ(e,n,t,r,o){var a=s$;try{return sJ(e,!0),n(t,r,o)}finally{sJ(a,!1)}}function s0(e,n,t,r){return"function"!=typeof e?e:function(){var o,a=s$;t&&sq(),sJ(n,!0);try{return e.apply(this,arguments)}finally{sJ(a,!1),r&&(o=sH,sl.call(sa,o))}}}function s1(e,n){return function(t,r){return e.call(this,s0(t,n),s0(r,n))}}-1===(""+sl).indexOf("[native code]")&&(sq=sH=i4);let s2="unhandledrejection";function s3(e,n){var t;try{t=n.onuncatched(e)}catch(e){}if(!1!==t)try{var r,o={promise:n,reason:e};if(is.document&&document.createEvent?((r=document.createEvent("Event")).initEvent(s2,!0,!0),ip(r,o)):is.CustomEvent&&ip(r=new CustomEvent(s2,{detail:o}),o),r&&is.dispatchEvent&&(dispatchEvent(r),!is.PromiseRejectionEvent&&is.onunhandledrejection))try{is.onunhandledrejection(r)}catch(e){}iV&&r&&!r.defaultPrevented&&console.warn(`Unhandled rejection: ${e.stack||e}`)}catch(e){}}var s5=sx.reject;let s4="3.2.4",s6=String.fromCharCode(65535),s7=-1/0,s8="Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.",s9="String expected.",le=[],ln="u">typeof navigator&&/(MSIE|Trident|Edge)/.test(navigator.userAgent),lt=e=>!/(dexie\.js|dexie\.min\.js)/.test(e),lr="__dbnames",lo="readonly",la="readwrite";function li(e,n){return e?n?function(){return e.apply(this,arguments)&&n.apply(this,arguments)}:e:n}let ls={type:3,lower:-1/0,lowerOpen:!1,upper:[[]],upperOpen:!1};function ll(e){return"string"!=typeof e||/\./.test(e)?e=>e:n=>(void 0===n[e]&&e in n&&delete(n=iN(n))[e],n)}class lc{_trans(e,n,t){let r=this._tx||s$.trans,o=this.name;function a(e,t,r){if(!r.schema[o])throw new i2.NotFound("Table "+o+" not part of transaction");return n(r.idbtrans,r)}let i=sO();try{return r&&r.db===this.db?r===s$.trans?r._promise(e,a,t):sU(()=>r._promise(e,a,t),{trans:r,transless:s$.transless||s$}):function e(n,t,r,o){if(n.idbdb&&(n._state.openComplete||s$.letThrough||n._vip)){var a=n._createTransaction(t,r,n._dbSchema);try{a.create(),n._state.PR1398_maxLoop=3}catch(a){return a.name===i1.InvalidState&&n.isOpen()&&--n._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),n._close(),n.open().then(()=>e(n,t,r,o))):s5(a)}return a._promise(t,(e,n)=>sU(()=>(s$.trans=a,o(e,n,a)))).then(e=>a._completion.then(()=>e))}if(n._state.openComplete)return s5(new i2.DatabaseClosed(n._state.dbOpenError));if(!n._state.isBeingOpened){if(!n._options.autoOpen)return s5(new i2.DatabaseClosed);n.open().catch(i4)}return n._state.dbReadyPromise.then(()=>e(n,t,r,o))}(this.db,e,[this.name],a)}finally{i&&sN()}}get(e,n){return e&&e.constructor===Object?this.where(e).first(n):this._trans("readonly",n=>this.core.get({trans:n,key:e}).then(e=>this.hook.reading.fire(e))).then(n)}where(e){if("string"==typeof e)return new this.db.WhereClause(this,e);if(ic(e))return new this.db.WhereClause(this,`[${e.join("+")}]`);let n=il(e);if(1===n.length)return this.where(n[0]).equals(e[n[0]]);let t=this.schema.indexes.concat(this.schema.primKey).filter(e=>e.compound&&n.every(n=>e.keyPath.indexOf(n)>=0)&&e.keyPath.every(e=>n.indexOf(e)>=0))[0];if(t&&this.db._maxKey!==s6)return this.where(t.name).equals(t.keyPath.map(n=>e[n]));!t&&iV&&console.warn(`The query ${JSON.stringify(e)} on ${this.name} would benefit of a compound index [${n.join("+")}]`);let{idxByName:r}=this.schema,o=this.db._deps.indexedDB;function a(e,n){try{return 0===o.cmp(e,n)}catch(e){return!1}}let[i,s]=n.reduce(([n,t],o)=>{let i=r[o],s=e[o];return[n||i,n||!i?li(t,i&&i.multi?e=>{let n=iE(e,o);return ic(n)&&n.some(e=>a(s,e))}:e=>a(s,iE(e,o))):t]},[null,null]);return i?this.where(i.name).equals(e[i.keyPath]).filter(s):t?this.filter(s):this.where(n).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,ic(e)?`[${e.join("+")}]`:e))}reverse(){return this.toCollection().reverse()}mapToClass(e){this.schema.mappedClass=e;let n=n=>{if(!n)return n;let t=Object.create(e.prototype);for(var r in n)if(ih(n,r))try{t[r]=n[r]}catch(e){}return t};return this.schema.readHook&&this.hook.reading.unsubscribe(this.schema.readHook),this.schema.readHook=n,this.hook("reading",n),e}defineClass(){return this.mapToClass(function(e){ip(this,e)})}add(e,n){let{auto:t,keyPath:r}=this.schema.primKey,o=e;return r&&t&&(o=ll(r)(e)),this._trans("readwrite",e=>this.core.mutate({trans:e,type:"add",keys:null!=n?[n]:null,values:[o]})).then(e=>e.numFailures?sx.reject(e.failures[0]):e.lastResult).then(n=>{if(r)try{iS(e,r,n)}catch(e){}return n})}update(e,n){if("object"!=typeof e||ic(e))return this.where(":id").equals(e).modify(n);{let t=iE(e,this.schema.primKey.keyPath);if(void 0===t)return s5(new i2.InvalidArgument("Given object does not contain its primary key"));try{"function"!=typeof n?il(n).forEach(t=>{iS(e,t,n[t])}):n(e,{value:e,primKey:t})}catch(e){}return this.where(":id").equals(t).modify(n)}}put(e,n){let{auto:t,keyPath:r}=this.schema.primKey,o=e;return r&&t&&(o=ll(r)(e)),this._trans("readwrite",e=>this.core.mutate({trans:e,type:"put",values:[o],keys:null!=n?[n]:null})).then(e=>e.numFailures?sx.reject(e.failures[0]):e.lastResult).then(n=>{if(r)try{iS(e,r,n)}catch(e){}return n})}delete(e){return this._trans("readwrite",n=>this.core.mutate({trans:n,type:"delete",keys:[e]})).then(e=>e.numFailures?sx.reject(e.failures[0]):void 0)}clear(){return this._trans("readwrite",e=>this.core.mutate({trans:e,type:"deleteRange",range:ls})).then(e=>e.numFailures?sx.reject(e.failures[0]):void 0)}bulkGet(e){return this._trans("readonly",n=>this.core.getMany({keys:e,trans:n}).then(e=>e.map(e=>this.hook.reading.fire(e))))}bulkAdd(e,n,t){let r=Array.isArray(n)?n:void 0,o=(t=t||(r?void 0:n))?t.allKeys:void 0;return this._trans("readwrite",n=>{let{auto:t,keyPath:a}=this.schema.primKey;if(a&&r)throw new i2.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(r&&r.length!==e.length)throw new i2.InvalidArgument("Arguments objects and keys must have the same length");let i=e.length,s=a&&t?e.map(ll(a)):e;return this.core.mutate({trans:n,type:"add",keys:r,values:s,wantResults:o}).then(({numFailures:e,results:n,lastResult:t,failures:r})=>{if(0===e)return o?n:t;throw new i0(`${this.name}.bulkAdd(): ${e} of ${i} operations failed`,r)})})}bulkPut(e,n,t){let r=Array.isArray(n)?n:void 0,o=(t=t||(r?void 0:n))?t.allKeys:void 0;return this._trans("readwrite",n=>{let{auto:t,keyPath:a}=this.schema.primKey;if(a&&r)throw new i2.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(r&&r.length!==e.length)throw new i2.InvalidArgument("Arguments objects and keys must have the same length");let i=e.length,s=a&&t?e.map(ll(a)):e;return this.core.mutate({trans:n,type:"put",keys:r,values:s,wantResults:o}).then(({numFailures:e,results:n,lastResult:t,failures:r})=>{if(0===e)return o?n:t;throw new i0(`${this.name}.bulkPut(): ${e} of ${i} operations failed`,r)})})}bulkDelete(e){let n=e.length;return this._trans("readwrite",n=>this.core.mutate({trans:n,type:"delete",keys:e})).then(({numFailures:e,lastResult:t,failures:r})=>{if(0===e)return t;throw new i0(`${this.name}.bulkDelete(): ${e} of ${n} operations failed`,r)})}}function lp(e){var n={},t=function(t,r){if(r){for(var o=arguments.length,a=Array(o-1);--o;)a[o-1]=arguments[o];return n[t].subscribe.apply(null,a),e}if("string"==typeof t)return n[t]};t.addEventType=a;for(var r=1,o=arguments.length;r<o;++r)a(arguments[r]);return t;function a(e,r,o){if("object"!=typeof e){r||(r=st),o||(o=i4);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(n){return n!==e}),i.fire=i.subscribers.reduce(r,o)}};return n[e]=t[e]=i,i}il(e).forEach(function(n){var t=e[n];if(ic(t))a(n,e[n][0],e[n][1]);else{if("asap"!==t)throw new i2.InvalidArgument("Invalid event config");var r=a(n,i6,function(){for(var e=arguments.length,n=Array(e);e--;)n[e]=arguments[e];r.subscribers.forEach(function(e){ix(function(){e.apply(null,n)})})})}})}}function lu(e,n){return ib(n).from({prototype:e}),n}function ld(e,n){return!(e.filter||e.algorithm||e.or)&&(n?e.justLimit:!e.replayFilter)}function lf(e,n){e.filter=li(e.filter,n)}function lh(e,n,t){var r=e.replayFilter;e.replayFilter=r?()=>li(r(),n()):n,e.justLimit=t&&!r}function lm(e,n){if(e.isPrimKey)return n.primaryKey;let t=n.getIndexByKeyPath(e.index);if(!t)throw new i2.Schema("KeyPath "+e.index+" on object store "+n.name+" is not indexed");return t}function lg(e,n,t){let r=lm(e,n.schema);return n.openCursor({trans:t,values:!e.keysOnly,reverse:"prev"===e.dir,unique:!!e.unique,query:{index:r,range:e.range}})}function ly(e,n,t,r){let o=e.replayFilter?li(e.filter,e.replayFilter()):e.filter;if(e.or){let a={},i=(e,t,r)=>{if(!o||o(t,r,e=>t.stop(e),e=>t.fail(e))){var i=t.primaryKey,s=""+i;"[object ArrayBuffer]"===s&&(s=""+new Uint8Array(i)),ih(a,s)||(a[s]=!0,n(e,t,r))}};return Promise.all([e.or._iterate(i,t),lb(lg(e,r,t),e.algorithm,i,!e.keysOnly&&e.valueMapper)])}return lb(lg(e,r,t),li(e.algorithm,o),n,!e.keysOnly&&e.valueMapper)}function lb(e,n,t,r){var o=sj(r?(e,n,o)=>t(r(e),n,o):t);return e.then(e=>{if(e)return e.start(()=>{var t=()=>e.continue();n&&!n(e,e=>t=e,n=>{e.stop(n),t=i4},n=>{e.fail(n),t=i4})||o(e.value,e,e=>t=e),t()})})}function l_(e,n){try{let t=lv(e),r=lv(n);if(t!==r)return"Array"===t?1:"Array"===r?-1:"binary"===t?1:"binary"===r?-1:"string"===t?1:"string"===r?-1:"Date"===t?1:"Date"!==r?NaN:-1;switch(t){case"number":case"Date":case"string":return e>n?1:e<n?-1:0;case"binary":return function(e,n){let t=e.length,r=n.length,o=t<r?t:r;for(let t=0;t<o;++t)if(e[t]!==n[t])return e[t]<n[t]?-1:1;return t===r?0:t<r?-1:1}(l$(e),l$(n));case"Array":return function(e,n){let t=e.length,r=n.length,o=t<r?t:r;for(let t=0;t<o;++t){let r=l_(e[t],n[t]);if(0!==r)return r}return t===r?0:t<r?-1:1}(e,n)}}catch(e){}return NaN}function lv(e){let n=typeof e;if("object"!==n)return n;if(ArrayBuffer.isView(e))return"binary";let t=iB(e);return"ArrayBuffer"===t?"binary":t}function l$(e){return e instanceof Uint8Array?e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e)}class lA{_read(e,n){var t=this._ctx;return t.error?t.table._trans(null,s5.bind(null,t.error)):t.table._trans("readonly",e).then(n)}_write(e){var n=this._ctx;return n.error?n.table._trans(null,s5.bind(null,n.error)):n.table._trans("readwrite",e,"locked")}_addAlgorithm(e){var n=this._ctx;n.algorithm=li(n.algorithm,e)}_iterate(e,n){return ly(this._ctx,e,n,this._ctx.table.core)}clone(e){var n=Object.create(this.constructor.prototype),t=Object.create(this._ctx);return e&&ip(t,e),n._ctx=t,n}raw(){return this._ctx.valueMapper=null,this}each(e){var n=this._ctx;return this._read(t=>ly(n,e,t,n.table.core))}count(e){return this._read(e=>{let n=this._ctx,t=n.table.core;if(ld(n,!0))return t.count({trans:e,query:{index:lm(n,t.schema),range:n.range}}).then(e=>Math.min(e,n.limit));var r=0;return ly(n,()=>(++r,!1),e,t).then(()=>r)}).then(e)}sortBy(e,n){let t=e.split(".").reverse(),r=t[0],o=t.length-1;function a(e,n){return n?a(e[t[n]],n-1):e[r]}var i="next"===this._ctx.dir?1:-1;function s(e,n){var t=a(e,o),r=a(n,o);return t<r?-i:t>r?i:0}return this.toArray(function(e){return e.sort(s)}).then(n)}toArray(e){return this._read(e=>{var n=this._ctx;if("next"===n.dir&&ld(n,!0)&&n.limit>0){let{valueMapper:t}=n,r=lm(n,n.table.core.schema);return n.table.core.query({trans:e,limit:n.limit,values:!0,query:{index:r,range:n.range}}).then(({result:e})=>t?e.map(t):e)}{let t=[];return ly(n,e=>t.push(e),e,n.table.core).then(()=>t)}},e)}offset(e){var n=this._ctx;return e<=0||(n.offset+=e,ld(n)?lh(n,()=>{var n=e;return(e,t)=>0===n||(1===n?--n:t(()=>{e.advance(n),n=0}),!1)}):lh(n,()=>{var n=e;return()=>--n<0})),this}limit(e){return this._ctx.limit=Math.min(this._ctx.limit,e),lh(this._ctx,()=>{var n=e;return function(e,t,r){return--n<=0&&t(r),n>=0}},!0),this}until(e,n){return lf(this._ctx,function(t,r,o){return!e(t.value)||(r(o),n)}),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 n;return lf(this._ctx,function(n){return e(n.value)}),(n=this._ctx).isMatch=li(n.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 n=this._ctx;return n.keysOnly=!n.isMatch,this.each(function(n,t){e(t.key,t)})}eachUniqueKey(e){return this._ctx.unique="unique",this.eachKey(e)}eachPrimaryKey(e){var n=this._ctx;return n.keysOnly=!n.isMatch,this.each(function(n,t){e(t.primaryKey,t)})}keys(e){var n=this._ctx;n.keysOnly=!n.isMatch;var t=[];return this.each(function(e,n){t.push(n.key)}).then(function(){return t}).then(e)}primaryKeys(e){var n=this._ctx;if("next"===n.dir&&ld(n,!0)&&n.limit>0)return this._read(e=>{var t=lm(n,n.table.core.schema);return n.table.core.query({trans:e,values:!1,limit:n.limit,query:{index:t,range:n.range}})}).then(({result:e})=>e).then(e);n.keysOnly=!n.isMatch;var t=[];return this.each(function(e,n){t.push(n.primaryKey)}).then(function(){return t}).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,n=e.index&&e.table.schema.idxByName[e.index];if(!n||!n.multi)return this;var t={};return lf(this._ctx,function(e){var n=e.primaryKey.toString(),r=ih(t,n);return t[n]=!0,!r}),this}modify(e){var n=this._ctx;return this._write(t=>{var r;if("function"==typeof e)r=e;else{var o=il(e),a=o.length;r=function(n){for(var t=!1,r=0;r<a;++r){var i=o[r],s=e[i];iE(n,i)!==s&&(iS(n,i,s),t=!0)}return t}}let i=n.table.core,{outbound:s,extractKey:l}=i.schema.primaryKey,c=this.db._options.modifyChunkSize||200,p=[],u=0,d=[],f=(e,n)=>{let{failures:t,numFailures:r}=n;for(let n of(u+=e-r,il(t)))p.push(t[n])};return this.clone().primaryKeys().then(o=>{let a=p=>{let u=Math.min(c,o.length-p);return i.getMany({trans:t,keys:o.slice(p,p+u),cache:"immutable"}).then(d=>{let h=[],m=[],g=s?[]:null,y=[];for(let e=0;e<u;++e){let n=d[e],t={value:iN(n),primKey:o[p+e]};!1!==r.call(t,t.value,t)&&(null==t.value?y.push(o[p+e]):s||0===l_(l(n),l(t.value))?(m.push(t.value),s&&g.push(o[p+e])):(y.push(o[p+e]),h.push(t.value)))}let b=ld(n)&&n.limit===1/0&&("function"!=typeof e||e===lw)&&{index:n.index,range:n.range};return Promise.resolve(h.length>0&&i.mutate({trans:t,type:"add",values:h}).then(e=>{for(let n in e.failures)y.splice(parseInt(n),1);f(h.length,e)})).then(()=>(m.length>0||b&&"object"==typeof e)&&i.mutate({trans:t,type:"put",keys:g,values:m,criteria:b,changeSpec:"function"!=typeof e&&e}).then(e=>f(m.length,e))).then(()=>(y.length>0||b&&e===lw)&&i.mutate({trans:t,type:"delete",keys:y,criteria:b}).then(e=>f(y.length,e))).then(()=>o.length>p+u&&a(p+c))})};return a(0).then(()=>{if(p.length>0)throw new iQ("Error modifying one or more objects",p,u,d);return o.length})})})}delete(){var e=this._ctx,n=e.range;return ld(e)&&(e.isPrimKey&&!ln||3===n.type)?this._write(t=>{let{primaryKey:r}=e.table.core.schema;return e.table.core.count({trans:t,query:{index:r,range:n}}).then(r=>e.table.core.mutate({trans:t,type:"deleteRange",range:n}).then(({failures:e,lastResult:n,results:t,numFailures:o})=>{if(o)throw new iQ("Could not delete some values",Object.keys(e).map(n=>e[n]),r-o);return r-o}))}):this.modify(lw)}}let lw=(e,n)=>n.value=null;function lk(e,n){return e<n?-1:+(e!==n)}function lx(e,n){return e>n?-1:+(e!==n)}function lC(e,n,t){var r=e instanceof lM?new e.Collection(e):e;return r._ctx.error=t?new t(n):TypeError(n),r}function lE(e){return new e.Collection(e,()=>lz("")).limit(0)}function lS(e,n,t,r){var o,a,i,s,l,c,p,u=t.length;if(!t.every(e=>"string"==typeof e))return lC(e,s9);function d(e){o="next"===e?e=>e.toUpperCase():e=>e.toLowerCase(),a="next"===e?e=>e.toLowerCase():e=>e.toUpperCase(),i="next"===e?lk:lx;var n=t.map(function(e){return{lower:a(e),upper:o(e)}}).sort(function(e,n){return i(e.lower,n.lower)});s=n.map(function(e){return e.upper}),l=n.map(function(e){return e.lower}),c=e,p="next"===e?"":r}d("next");var f=new e.Collection(e,()=>lD(s[0],l[u-1]+r));f._ondirectionchange=function(e){d(e)};var h=0;return f._addAlgorithm(function(e,t,r){var o=e.key;if("string"!=typeof o)return!1;var d=a(o);if(n(d,l,h))return!0;for(var f=null,m=h;m<u;++m){var g=function(e,n,t,r,o,a){for(var i=Math.min(e.length,r.length),s=-1,l=0;l<i;++l){var c=n[l];if(c!==r[l])return 0>o(e[l],t[l])?e.substr(0,l)+t[l]+t.substr(l+1):0>o(e[l],r[l])?e.substr(0,l)+r[l]+t.substr(l+1):s>=0?e.substr(0,s)+n[s]+t.substr(s+1):null;0>o(e[l],c)&&(s=l)}return i<r.length&&"next"===a?e+t.substr(e.length):i<e.length&&"prev"===a?e.substr(0,t.length):s<0?null:e.substr(0,s)+r[s]+t.substr(s+1)}(o,d,s[m],l[m],i,c);null===g&&null===f?h=m+1:(null===f||i(f,g)>0)&&(f=g)}return t(null!==f?function(){e.continue(f+p)}:r),!1}),f}function lD(e,n,t,r){return{type:2,lower:e,upper:n,lowerOpen:t,upperOpen:r}}function lz(e){return{type:1,lower:e,upper:e}}class lM{get Collection(){return this._ctx.table.db.Collection}between(e,n,t,r){t=!1!==t,r=!0===r;try{return this._cmp(e,n)>0||0===this._cmp(e,n)&&(t||r)&&(!t||!r)?lE(this):new this.Collection(this,()=>lD(e,n,!t,!r))}catch(e){return lC(this,s8)}}equals(e){return null==e?lC(this,s8):new this.Collection(this,()=>lz(e))}above(e){return null==e?lC(this,s8):new this.Collection(this,()=>lD(e,void 0,!0))}aboveOrEqual(e){return null==e?lC(this,s8):new this.Collection(this,()=>lD(e,void 0,!1))}below(e){return null==e?lC(this,s8):new this.Collection(this,()=>lD(void 0,e,!1,!0))}belowOrEqual(e){return null==e?lC(this,s8):new this.Collection(this,()=>lD(void 0,e))}startsWith(e){return"string"!=typeof e?lC(this,s9):this.between(e,e+s6,!0,!0)}startsWithIgnoreCase(e){return""===e?this.startsWith(e):lS(this,(e,n)=>0===e.indexOf(n[0]),[e],s6)}equalsIgnoreCase(e){return lS(this,(e,n)=>e===n[0],[e],"")}anyOfIgnoreCase(){var e=iL.apply(iF,arguments);return 0===e.length?lE(this):lS(this,(e,n)=>-1!==n.indexOf(e),e,"")}startsWithAnyOfIgnoreCase(){var e=iL.apply(iF,arguments);return 0===e.length?lE(this):lS(this,(e,n)=>n.some(n=>0===e.indexOf(n)),e,s6)}anyOf(){let e=iL.apply(iF,arguments),n=this._cmp;try{e.sort(n)}catch(e){return lC(this,s8)}if(0===e.length)return lE(this);let t=new this.Collection(this,()=>lD(e[0],e[e.length-1]));t._ondirectionchange=t=>{n="next"===t?this._ascending:this._descending,e.sort(n)};let r=0;return t._addAlgorithm((t,o,a)=>{let i=t.key;for(;n(i,e[r])>0;)if(++r===e.length)return o(a),!1;return 0===n(i,e[r])||(o(()=>{t.continue(e[r])}),!1)}),t}notEqual(e){return this.inAnyRange([[s7,e],[e,this.db._maxKey]],{includeLowers:!1,includeUppers:!1})}noneOf(){let e=iL.apply(iF,arguments);if(0===e.length)return new this.Collection(this);try{e.sort(this._ascending)}catch(e){return lC(this,s8)}let n=e.reduce((e,n)=>e?e.concat([[e[e.length-1][1],n]]):[[s7,n]],null);return n.push([e[e.length-1],this.db._maxKey]),this.inAnyRange(n,{includeLowers:!1,includeUppers:!1})}inAnyRange(e,n){let t=this._cmp,r=this._ascending,o=this._descending,a=this._min,i=this._max;if(0===e.length)return lE(this);if(!e.every(e=>void 0!==e[0]&&void 0!==e[1]&&0>=r(e[0],e[1])))return lC(this,"First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower",i2.InvalidArgument);let s=!n||!1!==n.includeLowers,l=n&&!0===n.includeUppers,c,p=r;function u(e,n){return p(e[0],n[0])}try{(c=e.reduce(function(e,n){let r=0,o=e.length;for(;r<o;++r){let o=e[r];if(0>t(n[0],o[1])&&t(n[1],o[0])>0){o[0]=a(o[0],n[0]),o[1]=i(o[1],n[1]);break}}return r===o&&e.push(n),e},[])).sort(u)}catch(e){return lC(this,s8)}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,g=new this.Collection(this,()=>lD(c[0][0],c[c.length-1][1],!s,!l));return g._ondirectionchange=e=>{"next"===e?(m=f,p=r):(m=h,p=o),c.sort(u)},g._addAlgorithm((e,n,t)=>{for(var o=e.key;m(o);)if(++d===c.length)return n(t),!1;return!!(!f(o)&&!h(o))||(0===this._cmp(o,c[d][1])||0===this._cmp(o,c[d][0])||n(()=>{p===r?e.continue(c[d][0]):e.continue(c[d][1])}),!1)}),g}startsWithAnyOf(){let e=iL.apply(iF,arguments);return e.every(e=>"string"==typeof e)?0===e.length?lE(this):this.inAnyRange(e.map(e=>[e,e+s6])):lC(this,"startsWithAnyOf() only works with strings")}}function lP(e){return sj(function(n){return lT(n),e(n.target.error),!1})}function lT(e){e.stopPropagation&&e.stopPropagation(),e.preventDefault&&e.preventDefault()}let lO="storagemutated",lN="x-storagemutated-1",lI=lp(null,lO);class lB{_lock(){return ik(!s$.global),++this._reculock,1!==this._reculock||s$.global||(s$.lockOwnerFor=this),this}_unlock(){if(ik(!s$.global),0==--this._reculock)for(s$.global||(s$.lockOwnerFor=null);this._blockedFuncs.length>0&&!this._locked();){var e=this._blockedFuncs.shift();try{sQ(e[1],e[0])}catch(e){}}return this}_locked(){return this._reculock&&s$.lockOwnerFor!==this}create(e){if(!this.mode)return this;let n=this.db.idbdb,t=this.db._state.dbOpenError;if(ik(!this.idbtrans),!e&&!n)switch(t&&t.name){case"DatabaseClosedError":throw new i2.DatabaseClosed(t);case"MissingAPIError":throw new i2.MissingAPI(t.message,t);default:throw new i2.OpenFailed(t)}if(!this.active)throw new i2.TransactionInactive;return ik(null===this._completion._state),(e=this.idbtrans=e||(this.db.core?this.db.core.transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability}):n.transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability}))).onerror=sj(n=>{lT(n),this._reject(e.error)}),e.onabort=sj(n=>{lT(n),this.active&&this._reject(new i2.Abort(e.error)),this.active=!1,this.on("abort").fire(n)}),e.oncomplete=sj(()=>{this.active=!1,this._resolve(),"mutatedParts"in e&&lI.storagemutated.fire(e.mutatedParts)}),this}_promise(e,n,t){if("readwrite"===e&&"readwrite"!==this.mode)return s5(new i2.ReadOnly("Transaction is readonly"));if(!this.active)return s5(new i2.TransactionInactive);if(this._locked())return new sx((r,o)=>{this._blockedFuncs.push([()=>{this._promise(e,n,t).then(r,o)},s$])});if(t)return sU(()=>{var e=new sx((e,t)=>{this._lock();let r=n(e,t,this);r&&r.then&&r.then(e,t)});return e.finally(()=>this._unlock()),e._lib=!0,e});var r=new sx((e,t)=>{var r=n(e,t,this);r&&r.then&&r.then(e,t)});return r._lib=!0,r}_root(){return this.parent?this.parent._root():this}waitFor(e){var n=this._root();let t=sx.resolve(e);if(n._waitingFor)n._waitingFor=n._waitingFor.then(()=>t);else{n._waitingFor=t,n._waitingQueue=[];var r=n.idbtrans.objectStore(n.storeNames[0]);!function e(){for(++n._spinCount;n._waitingQueue.length;)n._waitingQueue.shift()();n._waitingFor&&(r.get(-1/0).onsuccess=e)}()}var o=n._waitingFor;return new sx((e,r)=>{t.then(t=>n._waitingQueue.push(sj(e.bind(null,t))),e=>n._waitingQueue.push(sj(r.bind(null,e)))).finally(()=>{n._waitingFor===o&&(n._waitingFor=null)})})}abort(){this.active&&(this.active=!1,this.idbtrans&&this.idbtrans.abort(),this._reject(new i2.Abort))}table(e){let n=this._memoizedTables||(this._memoizedTables={});if(ih(n,e))return n[e];let t=this.schema[e];if(!t)throw new i2.NotFound("Table "+e+" not part of transaction");let r=new this.db.Table(e,t,this);return r.core=this.db.core.table(e),n[e]=r,r}}function lj(e,n,t,r,o,a,i){return{name:e,keyPath:n,unique:t,multi:r,auto:o,compound:a,src:(t&&!i?"&":"")+(r?"*":"")+(o?"++":"")+lR(n)}}function lR(e){return"string"==typeof e?e:e?"["+[].join.call(e,"+")+"]":""}function lF(e,n,t){return{name:e,primKey:n,indexes:t,mappedClass:null,idxByName:iC(t,e=>[e.name,e])}}let lL=e=>{try{return e.only([[]]),lL=()=>[[]],[[]]}catch(e){return lL=()=>s6,s6}};function lW(e){return null==e?()=>{}:"string"==typeof e?1===e.split(".").length?n=>n[e]:n=>iE(n,e):n=>iE(n,e)}function lV(e){return[].slice.call(e)}let lG=0;function lU(e){return null==e?":id":"string"==typeof e?e:`[${e.join("+")}]`}function lq({_novip:e},n){let t=n.db,r=function(e,n,{IDBKeyRange:t,indexedDB:r},o){var a;return{dbcore:(a=function(e,n,t){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:t,upper:r,lowerOpen:o,upperOpen:a}=e;return void 0===t?void 0===r?null:n.upperBound(r,!!a):void 0===r?n.lowerBound(t,!!o):n.bound(t,r,!!o,!!a)}let{schema:a,hasGetAll:i}=(r=lV(e.objectStoreNames),{schema:{name:e.name,tables:r.map(e=>t.objectStore(e)).map(e=>{let{keyPath:n,autoIncrement:t}=e,r=ic(n),o=null==n,a={},i={name:e.name,primaryKey:{name:null,isPrimaryKey:!0,outbound:o,compound:r,keyPath:n,autoIncrement:t,unique:!0,extractKey:lW(n)},indexes:lV(e.indexNames).map(n=>e.index(n)).map(e=>{let{name:n,unique:t,multiEntry:r,keyPath:o}=e,i={name:n,compound:ic(o),keyPath:o,unique:t,multiEntry:r,extractKey:lW(o)};return a[lU(o)]=i,i}),getIndexByKeyPath:e=>a[lU(e)]};return a[":id"]=i.primaryKey,null!=n&&(a[lU(n)]=i.primaryKey),i})},hasGetAll:r.length>0&&"getAll"in t.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 n;return{name:n=e.name,schema:e,mutate:function({trans:e,type:t,keys:r,values:a,range:i}){return new Promise((s,l)=>{let c;s=sj(s);let p=e.objectStore(n),u=null==p.keyPath,d="put"===t||"add"===t;if(!d&&"delete"!==t&&"deleteRange"!==t)throw Error("Invalid operation type: "+t);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=[],g=0,y=e=>{++g,lT(e)};if("deleteRange"===t){if(4===i.type)return s({numFailures:g,failures:m,results:[],lastResult:void 0});3===i.type?h.push(c=p.clear()):h.push(c=p.delete(o(i)))}else{let[e,n]=d?u?[a,r]:[a,null]:[r,null];if(d)for(let r=0;r<f;++r)h.push(c=n&&void 0!==n[r]?p[t](e[r],n[r]):p[t](e[r])),c.onerror=y;else for(let n=0;n<f;++n)h.push(c=p[t](e[n])),c.onerror=y}let b=e=>{let n=e.target.result;h.forEach((e,n)=>null!=e.error&&(m[n]=e.error)),s({numFailures:g,failures:m,results:"delete"===t?r:h.map(e=>e.result),lastResult:n})};c.onerror=e=>{y(e),b(e)},c.onsuccess=b})},getMany:({trans:e,keys:t})=>new Promise((r,o)=>{r=sj(r);let a=e.objectStore(n),i=t.length,s=Array(i),l,c=0,p=0,u=e=>{let n=e.target;s[n._pos]=n.result,++p===c&&r(s)},d=lP(o);for(let e=0;e<i;++e)null!=t[e]&&((l=a.get(t[e]))._pos=e,l.onsuccess=u,l.onerror=d,++c);0===c&&r(s)}),get:({trans:e,key:t})=>new Promise((r,o)=>{r=sj(r);let a=e.objectStore(n).get(t);a.onsuccess=e=>r(e.target.result),a.onerror=lP(o)}),query:e=>new Promise((t,r)=>{t=sj(t);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(n),h=u.isPrimaryKey?f:f.index(u.name),m=o(d);if(0===l)return t({result:[]});if(i){let e=s?h.getAll(m,p):h.getAllKeys(m,p);e.onsuccess=e=>t({result:e.target.result}),e.onerror=lP(r)}else{let e=0,n=!s&&"openKeyCursor"in h?h.openKeyCursor(m):h.openCursor(m),o=[];n.onsuccess=r=>{let a=n.result;return a?(o.push(s?a.value:a.primaryKey),++e===l?t({result:o}):void a.continue()):t({result:o})},n.onerror=lP(r)}}),openCursor:function({trans:e,values:t,query:r,reverse:a,unique:i}){return new Promise((s,l)=>{s=sj(s);let{index:c,range:p}=r,u=e.objectStore(n),d=c.isPrimaryKey?u:u.index(c.name),f=a?i?"prevunique":"prev":i?"nextunique":"next",h=!t&&"openKeyCursor"in d?d.openKeyCursor(o(p),f):d.openCursor(o(p),f);h.onerror=lP(l),h.onsuccess=sj(n=>{let t=h.result;if(!t)return void s(null);t.___id=++lG,t.done=!1;let r=t.continue.bind(t),o=t.continuePrimaryKey;o&&(o=o.bind(t));let a=t.advance.bind(t),i=()=>{throw Error("Cursor not stopped")};t.trans=e,t.stop=t.continue=t.continuePrimaryKey=t.advance=()=>{throw Error("Cursor not started")},t.fail=sj(l),t.next=function(){let e=1;return this.start(()=>e--?this.continue():this.stop()).then(()=>this)},t.start=e=>{let n=new Promise((e,n)=>{e=sj(e),h.onerror=lP(n),t.fail=n,t.stop=n=>{t.stop=t.continue=t.continuePrimaryKey=t.advance=i,e(n)}}),s=()=>{if(h.result)try{e()}catch(e){t.fail(e)}else t.done=!0,t.start=()=>{throw Error("Cursor behind last entry")},t.stop()};return h.onsuccess=sj(e=>{h.onsuccess=s,s()}),t.continue=r,t.continuePrimaryKey=o,t.advance=a,s(),n},s(t)},l)})},count({query:e,trans:t}){let{index:r,range:a}=e;return new Promise((e,i)=>{let s=t.objectStore(n),l=r.isPrimaryKey?s:s.index(r.name),c=o(a),p=c?l.count(c):l.count();p.onsuccess=sj(n=>e(n.target.result)),p.onerror=lP(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:lL(n),schema:a}}(n,t,o),e.dbcore.reduce((e,{create:n})=>({...e,...n(e)}),a))}}(e._middlewares,t,e._deps,n);e.core=r.dbcore,e.tables.forEach(n=>{let t=n.name;e.core.schema.tables.some(e=>e.name===t)&&(n.core=e.core.table(t),e[t]instanceof e.Table&&(e[t].core=n.core))})}function lH({_novip:e},n,t,r){t.forEach(t=>{let o=r[t];n.forEach(n=>{let r=iv(n,t);(!r||"value"in r&&void 0===r.value)&&(n===e.Transaction.prototype||n instanceof e.Transaction?iy(n,t,{get(){return this.table(t)},set(e){ig(this,t,{value:e,writable:!0,configurable:!0,enumerable:!0})}}):n[t]=new e.Table(t,o))})})}function lK({_novip:e},n){n.forEach(n=>{for(let t in n)n[t]instanceof e.Table&&delete n[t]})}function lY(e,n){return e._cfg.version-n._cfg.version}function lZ(e,n){let t,r={del:[],add:[],change:[]};for(t in e)n[t]||r.del.push(t);for(t in n){let o=e[t],a=n[t];if(o){let e={name:t,def:a,recreate:!1,del:[],add:[],change:[]};if(""+(o.primKey.keyPath||"")==""+(a.primKey.keyPath||"")&&(o.primKey.auto===a.primKey.auto||ln)){let n,t=o.idxByName,i=a.idxByName;for(n in t)i[n]||e.del.push(n);for(n in i){let r=t[n],o=i[n];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([t,a])}return r}function lJ(e,n,t,r){let o=e.db.createObjectStore(n,t.keyPath?{keyPath:t.keyPath,autoIncrement:t.auto}:{autoIncrement:t.auto});return r.forEach(e=>lX(o,e)),o}function lX(e,n){e.createIndex(n.name,n.keyPath,{unique:n.unique,multiEntry:n.multi})}function lQ(e,n,t){let r={};return iA(n.objectStoreNames,0).forEach(e=>{let n=t.objectStore(e),o=n.keyPath,a=lj(lR(o),o||"",!1,!1,!!n.autoIncrement,o&&"string"!=typeof o,!0),i=[];for(let e=0;e<n.indexNames.length;++e){let t=n.index(n.indexNames[e]);o=t.keyPath;var s=lj(t.name,o,!!t.unique,!!t.multiEntry,!1,o&&"string"!=typeof o,!1);i.push(s)}r[e]=lF(e,a,i)}),r}function l0({_novip:e},n,t){let r=t.db.objectStoreNames;for(let o=0;o<r.length;++o){let a=r[o],i=t.objectStore(a);e._hasGetAll="getAll"in i;for(let e=0;e<i.indexNames.length;++e){let t=i.indexNames[e],r=i.index(t).keyPath,o="string"==typeof r?r:"["+iA(r).join("+")+"]";if(n[a]){let e=n[a].idxByName[o];e&&(e.name=t,delete n[a].idxByName[o],n[a].idxByName[t]=e)}}}"u">typeof navigator&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&is.WorkerGlobalScope&&is instanceof is.WorkerGlobalScope&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604&&(e._hasGetAll=!1)}class l1{_parseStoresSpec(e,n){il(e).forEach(t=>{if(null!==e[t]){var r=e[t].split(",").map((e,n)=>{let t=(e=e.trim()).replace(/([&*]|\+\+)/g,""),r=/^\[/.test(t)?t.match(/^\[(.*)\]$/)[1].split("+"):t;return lj(t,r||null,/\&/.test(e),/\*/.test(e),/\+\+/.test(e),ic(r),0===n)}),o=r.shift();if(o.multi)throw new i2.Schema("Primary key cannot be multi-valued");r.forEach(e=>{if(e.auto)throw new i2.Schema("Only primary key can be marked as autoIncrement (++)");if(!e.keyPath)throw new i2.Schema("Index must have a name and cannot be an empty string")}),n[t]=lF(t,o,r)}})}stores(e){let n=this.db;this._cfg.storesSource=this._cfg.storesSource?ip(this._cfg.storesSource,e):e;let t=n._versions,r={},o={};return t.forEach(e=>{ip(r,e._cfg.storesSource),o=e._cfg.dbschema={},e._parseStoresSpec(r,o)}),n._dbSchema=o,lK(n,[n._allTables,n,n.Transaction.prototype]),lH(n,[n._allTables,n,n.Transaction.prototype,this._cfg.tables],il(o),o),n._storeNames=il(o),this}upgrade(e){return this._cfg.contentUpgrade=sr(this._cfg.contentUpgrade||i4,e),this}}function l2(e,n){let t=e._dbNamesDB;return t||(t=e._dbNamesDB=new cu(lr,{addons:[],indexedDB:e,IDBKeyRange:n})).version(1).stores({dbnames:"name"}),t.table("dbnames")}function l3(e){return e&&"function"==typeof e.databases}function l5(e){return sU(function(){return s$.letThrough=!0,e()})}function l4(e){var n=n=>e.next(n),t=o(n),r=o(n=>e.throw(n));function o(e){return n=>{var o=e(n),a=o.value;return o.done?a:a&&"function"==typeof a.then?a.then(t,r):ic(a)?Promise.all(a).then(t,r):t(a)}}return o(n)()}function l6(e,n,t){var r=arguments.length;if(r<2)throw new i2.InvalidArgument("Too few arguments");for(var o=Array(r-1);--r;)o[r-1]=arguments[r];return t=o.pop(),[e,iM(o),t]}function l7(e,n,t){let r=ic(e)?e.slice():[e];for(let e=0;e<t;++e)r.push(n);return r}let l8={stack:"dbcore",name:"VirtualIndexMiddleware",level:1,create:function(e){return{...e,table(n){let t=e.table(n),{schema:r}=t,o={},a=[];function i(e,n,t){let r=lU(e),s=o[r]=o[r]||[],l=null==e?0:"string"==typeof e?1:e.length,c=n>0,p={...t,isVirtual:c,keyTail:n,keyLength:l,extractKey:lW(e),unique:!c&&t.unique};return s.push(p),p.isPrimaryKey||a.push(p),l>1&&i(2===l?e[0]:e.slice(0,l-1),n+1,t),s.sort((e,n)=>e.keyTail-n.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(n){var t,r;let o=n.query.index;return o.isVirtual?{...n,query:{index:o,range:(t=n.query.range,r=o.keyTail,{type:1===t.type?2:t.type,lower:l7(t.lower,t.lowerOpen?e.MAX_KEY:e.MIN_KEY,r),lowerOpen:!0,upper:l7(t.upper,t.upperOpen?e.MIN_KEY:e.MAX_KEY,r),upperOpen:!0})}}:n}return{...t,schema:{...r,primaryKey:s,indexes:a,getIndexByKeyPath:function(e){let n=o[lU(e)];return n&&n[0]}},count:e=>t.count(l(e)),query:e=>t.query(l(e)),openCursor(n){let{keyTail:r,isVirtual:o,keyLength:a}=n.query.index;return o?t.openCursor(l(n)).then(t=>t&&Object.create(t,{continue:{value:function(o){null!=o?t.continue(l7(o,n.reverse?e.MAX_KEY:e.MIN_KEY,r)):n.unique?t.continue(t.key.slice(0,a).concat(n.reverse?e.MIN_KEY:e.MAX_KEY,r)):t.continue()}},continuePrimaryKey:{value(n,o){t.continuePrimaryKey(l7(n,e.MAX_KEY,r),o)}},primaryKey:{get:()=>t.primaryKey},key:{get(){let e=t.key;return 1===a?e[0]:e.slice(0,a)}},value:{get:()=>t.value}})):t.openCursor(n)}}}}}};function l9(e,n,t,r){return t=t||{},r=r||"",il(e).forEach(o=>{if(ih(n,o)){var a=e[o],i=n[o];if("object"==typeof a&&"object"==typeof i&&a&&i){let e=iB(a);e!==iB(i)?t[r+o]=n[o]:"Object"===e?l9(a,i,t,r+o+"."):a!==i&&(t[r+o]=n[o])}else a!==i&&(t[r+o]=n[o])}else t[r+o]=void 0}),il(n).forEach(o=>{ih(e,o)||(t[r+o]=n[o])}),t}let ce={stack:"dbcore",name:"HooksMiddleware",level:2,create:e=>({...e,table(n){let t=e.table(n),{primaryKey:r}=t.schema;return{...t,mutate(e){let o=s$.trans,{deleting:a,creating:i,updating:s}=o.table(n).hook;switch(e.type){case"add":if(i.fire===i4)break;return o._promise("readwrite",()=>l(e),!0);case"put":if(i.fire===i4&&s.fire===i4)break;return o._promise("readwrite",()=>l(e),!0);case"delete":if(a.fire===i4)break;return o._promise("readwrite",()=>l(e),!0);case"deleteRange":if(a.fire===i4)break;return o._promise("readwrite",()=>(function e(n,o,a){return t.query({trans:n,values:!1,query:{index:r,range:o},limit:a}).then(({result:t})=>l({type:"delete",keys:t,trans:n}).then(r=>r.numFailures>0?Promise.reject(r.failures[0]):t.length<a?{failures:[],numFailures:0,lastResult:void 0}:e(n,{...o,lower:t[t.length-1],lowerOpen:!0},a)))})(e.trans,e.range,1e4),!0)}return t.mutate(e);function l(e){var n,o;let l=s$.trans,c=e.keys||("delete"===(n=e).type?n.keys:n.keys||n.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([]):t.getMany({trans:o.trans,keys:c,cache:"immutable"})).then(n=>{let o=c.map((t,o)=>{let c=n[o],p={onerror:null,onsuccess:null};if("delete"===e.type)a.fire.call(p,t,c,l);else if("add"===e.type||void 0===c){let n=i.fire.call(p,t,e.values[o],l);null==t&&null!=n&&(t=n,e.keys[o]=t,r.outbound||iS(e.values[o],r.keyPath,t))}else{let n=l9(c,e.values[o]),r=s.fire.call(p,n,t,c,l);if(r){let n=e.values[o];Object.keys(r).forEach(e=>{ih(n,e)?n[e]=r[e]:iS(n,e,r[e])})}}return p});return t.mutate(e).then(({failures:t,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(t[a]):s.onsuccess&&s.onsuccess("put"===e.type&&n[a]?e.values[a]:i)}return{failures:t,results:r,numFailures:a,lastResult:i}}).catch(e=>(o.forEach(n=>n.onerror&&n.onerror(e)),Promise.reject(e)))})}}}}})};function cn(e,n,t){try{if(!n||n.keys.length<e.length)return null;let r=[];for(let o=0,a=0;o<n.keys.length&&a<e.length;++o)0===l_(n.keys[o],e[a])&&(r.push(t?iN(n.values[o]):n.values[o]),++a);return r.length===e.length?r:null}catch(e){return null}}let ct={stack:"dbcore",level:-1,create:e=>({table:n=>{let t=e.table(n);return{...t,getMany:e=>{if(!e.cache)return t.getMany(e);let n=cn(e.keys,e.trans._cache,"clone"===e.cache);return n?sx.resolve(n):t.getMany(e).then(n=>(e.trans._cache={keys:e.keys,values:"clone"===e.cache?iN(n):n},n))},mutate:e=>("add"!==e.type&&(e.trans._cache=null),t.mutate(e))}}})};function cr(e){return!("from"in e)}let co=function(e,n){if(!this){let n=new co;return e&&"d"in e&&ip(n,e),n}ip(this,arguments.length?{d:1,from:e,to:arguments.length>1?n:e}:{d:0})};function ca(e,n,t){let r=l_(n,t);if(isNaN(r))return;if(r>0)throw RangeError();if(cr(e))return ip(e,{from:n,to:t,d:1});let o=e.l,a=e.r;if(0>l_(t,e.from))return o?ca(o,n,t):e.l={from:n,to:t,d:1,l:null,r:null},cl(e);if(l_(n,e.to)>0)return a?ca(a,n,t):e.r={from:n,to:t,d:1,l:null,r:null},cl(e);0>l_(n,e.from)&&(e.from=n,e.l=null,e.d=a?a.d+1:1),l_(t,e.to)>0&&(e.to=t,e.r=null,e.d=e.l?e.l.d+1:1);let i=!e.r;o&&!e.l&&ci(e,o),a&&i&&ci(e,a)}function ci(e,n){cr(n)||function e(n,{from:t,to:r,l:o,r:a}){ca(n,t,r),o&&e(n,o),a&&e(n,a)}(e,n)}function cs(e){let n=cr(e)?null:{s:0,n:e};return{next(e){let t=arguments.length>0;for(;n;)switch(n.s){case 0:if(n.s=1,t)for(;n.n.l&&0>l_(e,n.n.from);)n={up:n,n:n.n.l,s:1};else for(;n.n.l;)n={up:n,n:n.n.l,s:1};case 1:if(n.s=2,!t||0>=l_(e,n.n.to))return{value:n.n,done:!1};case 2:if(n.n.r){n.s=3,n={up:n,n:n.n.r,s:0};continue}case 3:n=n.up}return{done:!0}}}}function cl(e){var n,t;let r=((null==(n=e.r)?void 0:n.d)||0)-((null==(t=e.l)?void 0:t.d)||0),o=r>1?"r":r<-1?"l":"";if(o){let n="r"===o?"l":"r",t={...e},r=e[o];e.from=r.from,e.to=r.to,e[o]=r[o],t[o]=r[n],e[n]=t,t.d=cc(t)}e.d=cc(e)}function cc({r:e,l:n}){return(e?n?Math.max(e.d,n.d):e.d:n?n.d:0)+1}im(co.prototype,{add(e){return ci(this,e),this},addKey(e){return ca(this,e,e),this},addKeys(e){return e.forEach(e=>ca(this,e,e)),this},[ij](){return cs(this)}});let cp={stack:"dbcore",level:0,create:e=>{let n=e.schema.name,t=new co(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 t=`idb://${n}/${r}/${e}`;return s[t]||(s[t]=new co)},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(ic(d)){"delete"!==u&&(d=e.results),c.addKeys(d);let n=cn(d,h);n||"add"===u||p.addKeys(d),(n||f)&&a.indexes.forEach(function(e){let t=l(e.name||"");function r(n){return null!=n?e.extractKey(n):null}let o=n=>e.multiEntry&&ic(n)?n.forEach(e=>t.addKey(e)):t.addKey(n);(n||f).forEach((e,t)=>{let a=n&&r(n[t]),i=f&&r(f[t]);0!==l_(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(t),p.add(t),a.indexes.forEach(e=>l(e.name).add(t));return e})}},p=({query:{index:n,range:t}})=>{var r,o;return[n,new co(null!=(r=t.lower)?r:e.MIN_KEY,null!=(o=t.upper)?o:e.MAX_KEY)]},u={get:e=>[i,new co(e.key)],getMany:e=>[i,(new co).addKeys(e.keys)],count:p,query:p,openCursor:p};return il(u).forEach(e=>{c[e]=function(a){let{subscr:i}=s$;if(i){let c=e=>{let t=`idb://${n}/${r}/${e}`;return i[t]||(i[t]=new co)},p=c(""),d=c(":dels"),[f,h]=u[e](a);if(c(f.name||"").add(h),!f.isPrimaryKey){if("count"!==e){let n="query"===e&&l&&a.values&&o.query({...a,values:!1});return o[e].apply(this,arguments).then(t=>{if("query"===e){if(l&&a.values)return n.then(({result:e})=>(p.addKeys(e),t));let e=a.values?t.result.map(s):t.result;a.values?p.addKeys(e):d.addKeys(e)}else if("openCursor"===e){let e=a.values;return t&&Object.create(t,{key:{get:()=>(d.addKey(t.primaryKey),t.key)},primaryKey:{get(){let e=t.primaryKey;return d.addKey(e),e}},value:{get:()=>(e&&p.addKey(t.primaryKey),t.value)}})}return t})}d.add(t)}}return o[e].apply(this,arguments)}}),c}}}};class cu{constructor(e,n){var t;this._middlewares={},this.verno=0;const r=cu.dependencies;this._options=n={addons:cu.addons,autoOpen:!0,indexedDB:r.indexedDB,IDBKeyRange:r.IDBKeyRange,...n},this._deps={indexedDB:n.indexedDB,IDBKeyRange:n.IDBKeyRange};const{addons:o}=n;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:i4,dbReadyPromise:null,cancelOpen:i4,openCanceller:null,autoSchema:!0,PR1398_maxLoop:3};a.dbReadyPromise=new sx(e=>{a.dbReadyResolve=e}),a.openCanceller=new sx((e,n)=>{a.cancelOpen=n}),this._state=a,this.name=e,this.on=lp(this,"populate","blocked","versionchange","close",{ready:[sr,i4]}),this.on.ready.subscribe=iw(this.on.ready.subscribe,e=>(n,t)=>{cu.vip(()=>{let r=this._state;if(r.openComplete)r.dbOpenError||sx.resolve().then(n),t&&e(n);else if(r.onReadyBeingFired)r.onReadyBeingFired.push(n),t&&e(n);else{e(n);let r=this;t||e(function e(){r.on.ready.unsubscribe(n),r.on.ready.unsubscribe(e)})}})}),this.Collection=(t=this,lu(lA.prototype,function(e,n){this.db=t;let r=ls,o=null;if(n)try{r=n()}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!==i6?s:null}})),this.Table=function(e){return lu(lc.prototype,function(n,t,r){this.db=e,this._tx=r,this.name=n,this.schema=t,this.hook=e._allTables[n]?e._allTables[n].hook:lp(null,{creating:[i9,i4],reading:[i7,i6],updating:[sn,i4],deleting:[se,i4]})})}(this),this.Transaction=function(e){return lu(lB.prototype,function(n,t,r,o,a){this.db=e,this.mode=n,this.storeNames=t,this.schema=r,this.chromeTransactionDurability=o,this.idbtrans=null,this.on=lp(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 sx((e,n)=>{this._resolve=e,this._reject=n}),this._completion.then(()=>{this.active=!1,this.on.complete.fire()},e=>{var n=this.active;return this.active=!1,this.on.error.fire(e),this.parent?this.parent._reject(e):n&&this.idbtrans&&this.idbtrans.abort(),s5(e)})})}(this),this.Version=function(e){return lu(l1.prototype,function(n){this.db=e,this._cfg={version:n,storesSource:null,dbschema:{},tables:{},contentUpgrade:null}})}(this),this.WhereClause=function(e){return lu(lM.prototype,function(n,t,r){this.db=e,this._ctx={table:n,index:":id"===t?null:t,or:r};let o=e._deps.indexedDB;if(!o)throw new i2.MissingAPI;this._cmp=this._ascending=o.cmp.bind(o),this._descending=(e,n)=>o.cmp(n,e),this._max=(e,n)=>o.cmp(e,n)>0?e:n,this._min=(e,n)=>0>o.cmp(e,n)?e:n,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=lL(n.IDBKeyRange),this._createTransaction=(e,n,t,r)=>new this.Transaction(e,n,t,this._options.chromeTransactionDurability,r),this._fireOnBlocked=e=>{this.on("blocked").fire(e),le.filter(e=>e.name===this.name&&e!==this&&!e._state.vcFired).map(n=>n.on("versionchange").fire(e))},this.use(l8),this.use(ce),this.use(cp),this.use(ct),this.vip=Object.create(this,{_vip:{value:!0}}),o.forEach(e=>e(this))}version(e){if(isNaN(e)||e<.1)throw new i2.Type("Given version is not a positive number");if(e=Math.round(10*e)/10,this.idbdb||this._state.isBeingOpened)throw new i2.Schema("Cannot add version when database is open");this.verno=Math.max(this.verno,e);let n=this._versions;var t=n.filter(n=>n._cfg.version===e)[0];return t||(t=new this.Version(e),n.push(t),n.sort(lY),t.stores({}),this._state.autoSchema=!1,t)}_whenReady(e){return this.idbdb&&(this._state.openComplete||s$.letThrough||this._vip)?e():new sx((e,n)=>{if(this._state.openComplete)return n(new i2.DatabaseClosed(this._state.dbOpenError));if(!this._state.isBeingOpened){if(!this._options.autoOpen)return void n(new i2.DatabaseClosed);this.open().catch(i4)}this._state.dbReadyPromise.then(e,n)}).then(e)}use({stack:e,create:n,level:t,name:r}){r&&this.unuse({stack:e,name:r});let o=this._middlewares[e]||(this._middlewares[e]=[]);return o.push({stack:e,create:n,level:null==t?10:t,name:r}),o.sort((e,n)=>e.level-n.level),this}unuse({stack:e,name:n,create:t}){return e&&this._middlewares[e]&&(this._middlewares[e]=this._middlewares[e].filter(e=>t?e.create!==t:!!n&&e.name!==n)),this}open(){return function(e){var n;let t=e._state,{indexedDB:r}=e._deps;if(t.isBeingOpened||e.idbdb)return t.dbReadyPromise.then(()=>t.dbOpenError?s5(t.dbOpenError):e);iV&&(t.openCanceller._stackHolder=iq()),t.isBeingOpened=!0,t.dbOpenError=null,t.openComplete=!1;let o=t.openCanceller;function a(){if(t.openCanceller!==o)throw new i2.DatabaseClosed("db.open() was cancelled")}let i=t.dbReadyResolve,s=null,l=!1;return sx.race([o,("u"<typeof navigator?sx.resolve():!navigator.userAgentData&&/Safari\//.test(navigator.userAgent)&&!/Chrom(e|ium)\//.test(navigator.userAgent)&&indexedDB.databases?new Promise(function(e){var t=function(){return indexedDB.databases().finally(e)};n=setInterval(t,100),t()}).finally(function(){return clearInterval(n)}):Promise.resolve()).then(()=>new sx((n,o)=>{if(a(),!r)throw new i2.MissingAPI;let i=e.name,c=t.autoSchema?r.open(i):r.open(i,Math.round(10*e.verno));if(!c)throw new i2.MissingAPI;c.onerror=lP(o),c.onblocked=sj(e._fireOnBlocked),c.onupgradeneeded=sj(n=>{if(s=c.transaction,t.autoSchema&&!e._options.allowEmptyDB){c.onerror=lT,s.abort(),c.result.close();let e=r.deleteDatabase(i);e.onsuccess=e.onerror=sj(()=>{o(new i2.NoSuchDatabase(`Database ${i} doesnt exist`))})}else{let t,r,i,d;s.onerror=lP(o);var a,p,u=n.oldVersion>0x4000000000000000?0:n.oldVersion;l=u<1,e._novip.idbdb=c.result,a=u/10,p=s,t=e._dbSchema,(r=e._createTransaction("readwrite",e._storeNames,t)).create(p),r._completion.catch(o),i=r._reject.bind(r),d=s$.transless||s$,sU(()=>{s$.trans=r,s$.transless=d,0===a?(il(t).forEach(e=>{lJ(p,e,t[e].primKey,t[e].indexes)}),lq(e,p),sx.follow(()=>e.on.populate.fire(r)).catch(i)):(function({_novip:e},n,t,r){let o=[],a=e._versions,i=e._dbSchema=lQ(e,e.idbdb,r),s=!1;return a.filter(e=>e._cfg.version>=n).forEach(a=>{o.push(()=>{let o=i,l=a._cfg.dbschema;l0(e,o,r),l0(e,l,r),i=e._dbSchema=l;let c=lZ(o,l);c.add.forEach(e=>{lJ(r,e[0],e[1].primKey,e[1].indexes)}),c.change.forEach(e=>{if(e.recreate)throw new i2.Upgrade("Not yet support for changing primary key");{let n=r.objectStore(e.name);e.add.forEach(e=>lX(n,e)),e.change.forEach(e=>{n.deleteIndex(e.name),lX(n,e)}),e.del.forEach(e=>n.deleteIndex(e))}});let p=a._cfg.contentUpgrade;if(p&&a._cfg.version>n){let n;lq(e,r),t._memoizedTables={},s=!0;let a=iD(l);c.del.forEach(e=>{a[e]=o[e]}),lK(e,[e.Transaction.prototype]),lH(e,[e.Transaction.prototype],il(a),a),t.schema=a;let i=iW(p);i&&sq();let u=sx.follow(()=>{if((n=p(t))&&i){var e=sH.bind(null,null);n.then(e,e)}});return n&&"function"==typeof n.then?sx.resolve(n):u.then(()=>n)}}),o.push(n=>{var r;s&&ln||(r=a._cfg.dbschema,[].slice.call(n.db.objectStoreNames).forEach(e=>null==r[e]&&n.db.deleteObjectStore(e))),lK(e,[e.Transaction.prototype]),lH(e,[e.Transaction.prototype],e._storeNames,e._dbSchema),t.schema=e._dbSchema})}),(function e(){return o.length?sx.resolve(o.shift()(t.idbtrans)).then(e):sx.resolve()})().then(()=>{var e;il(e=i).forEach(n=>{r.db.objectStoreNames.contains(n)||lJ(r,n,e[n].primKey,e[n].indexes)})})})(e,a,r,p).catch(i)})}},o),c.onsuccess=sj(()=>{s=null;let r=e._novip.idbdb=c.result,o=iA(r.objectStoreNames);if(o.length>0)try{let n,a=r.transaction(1===o.length?o[0]:o,"readonly");t.autoSchema?function({_novip:e},n,t){e.verno=n.version/10;let r=e._dbSchema=lQ(0,n,t);e._storeNames=iA(n.objectStoreNames,0),lH(e,[e._allTables],il(r),r)}(e,r,a):(l0(e,e._dbSchema,a),((n=lZ(lQ(0,e.idbdb,a),e._dbSchema)).add.length||n.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.")),lq(e,a)}catch(e){}le.push(e),r.onversionchange=sj(n=>{t.vcFired=!0,e.on("versionchange").fire(n)}),r.onclose=sj(n=>{e.on("close").fire(n)}),l&&function({indexedDB:e,IDBKeyRange:n},t){l3(e)||t===lr||l2(e,n).put({name:t}).catch(i4)}(e._deps,i),n()},o)}))]).then(()=>(a(),t.onReadyBeingFired=[],sx.resolve(l5(()=>e.on.ready.fire(e.vip))).then(function n(){if(t.onReadyBeingFired.length>0){let r=t.onReadyBeingFired.reduce(sr,i4);return t.onReadyBeingFired=[],sx.resolve(l5(()=>r(e.vip))).then(n)}}))).finally(()=>{t.onReadyBeingFired=null,t.isBeingOpened=!1}).then(()=>e).catch(n=>{t.dbOpenError=n;try{s&&s.abort()}catch(e){}return o===t.openCanceller&&e._close(),s5(n)}).finally(()=>{t.openComplete=!0,i()})}(this)}_close(){let e=this._state,n=le.indexOf(this);if(n>=0&&le.splice(n,1),this.idbdb){try{this.idbdb.close()}catch(e){}this._novip.idbdb=null}e.dbReadyPromise=new sx(n=>{e.dbReadyResolve=n}),e.openCanceller=new sx((n,t)=>{e.cancelOpen=t})}close(){this._close();let e=this._state;this._options.autoOpen=!1,e.dbOpenError=new i2.DatabaseClosed,e.isBeingOpened&&e.cancelOpen(e.dbOpenError)}delete(){let e=arguments.length>0,n=this._state;return new sx((t,r)=>{let o=()=>{this.close();var e=this._deps.indexedDB.deleteDatabase(this.name);e.onsuccess=sj(()=>{!function({indexedDB:e,IDBKeyRange:n},t){l3(e)||t===lr||l2(e,n).delete(t).catch(i4)}(this._deps,this.name),t()}),e.onerror=lP(r),e.onblocked=this._fireOnBlocked};if(e)throw new i2.InvalidArgument("Arguments not allowed in db.delete()");n.isBeingOpened?n.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 il(this._allTables).map(e=>this._allTables[e])}transaction(){let e=l6.apply(this,arguments);return this._transaction.apply(this,e)}_transaction(e,n,t){let r,o,a=s$.trans;a&&a.db===this&&-1===e.indexOf("!")||(a=null);let i=-1!==e.indexOf("?");e=e.replace("!","").replace("?","");try{if(o=n.map(e=>{var n=e instanceof this.Table?e.name:e;if("string"!=typeof n)throw TypeError("Invalid table argument to Dexie.transaction(). Only Table or String are allowed");return n}),"r"==e||e===lo)r=lo;else{if("rw"!=e&&e!=la)throw new i2.InvalidArgument("Invalid transaction mode: "+e);r=la}if(a){if(a.mode===lo&&r===la){if(!i)throw new i2.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 i2.SubTransaction("Table "+e+" not included in parent transaction.");a=null}}),i&&a&&!a.active&&(a=null)}}catch(e){return a?a._promise(null,(n,t)=>{t(e)}):s5(e)}let s=(function e(n,t,r,o,a){return sx.resolve().then(()=>{let i,s=s$.transless||s$,l=n._createTransaction(t,r,n._dbSchema,o);if(o)l.idbtrans=o.idbtrans;else try{l.create(),n._state.PR1398_maxLoop=3}catch(o){return o.name===i1.InvalidState&&n.isOpen()&&--n._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),n._close(),n.open().then(()=>e(n,t,r,null,a))):s5(o)}let c=iW(a);c&&sq();let p=sx.follow(()=>{if(i=a.call(l,l))if(c){var e=sH.bind(null,null);i.then(e,e)}else"function"==typeof i.next&&"function"==typeof i.throw&&(i=l4(i))},{trans:l,transless:s});return(i&&"function"==typeof i.then?sx.resolve(i).then(e=>l.active?e:s5(new i2.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),s5(e)))})}).bind(null,this,r,o,a,t);return a?a._promise(r,s,"lock"):s$.trans?sQ(s$.transless,()=>this._whenReady(s)):this._whenReady(s)}table(e){if(!ih(this._allTables,e))throw new i2.InvalidTable(`Table ${e} does not exist`);return this._allTables[e]}}let cd="u">typeof Symbol&&"observable"in Symbol?Symbol.observable:"@@observable";class cf{constructor(e){this._subscribe=e}subscribe(e,n,t){return this._subscribe(e&&"function"!=typeof e?e:{next:e,error:n,complete:t})}[cd](){return this}}function ch(e,n){return il(n).forEach(t=>{ci(e[t]||(e[t]=new co),n[t])}),e}try{o={indexedDB:is.indexedDB||is.mozIndexedDB||is.webkitIndexedDB||is.msIndexedDB,IDBKeyRange:is.IDBKeyRange||is.webkitIDBKeyRange}}catch(e){o={indexedDB:null,IDBKeyRange:null}}function cm(e){let n=cg;try{cg=!0,lI.storagemutated.fire(e)}finally{cg=n}}im(cu,{...i5,delete:e=>new cu(e,{addons:[]}).delete(),exists:e=>new cu(e,{addons:[]}).open().then(e=>(e.close(),!0)).catch("NoSuchDatabaseError",()=>!1),getDatabaseNames(e){try{return(function({indexedDB:e,IDBKeyRange:n}){return l3(e)?Promise.resolve(e.databases()).then(e=>e.map(e=>e.name).filter(e=>e!==lr)):l2(e,n).toCollection().primaryKeys()})(cu.dependencies).then(e)}catch(e){return s5(new i2.MissingAPI)}},defineClass:()=>function(e){ip(this,e)},ignoreTransaction:e=>s$.trans?sQ(s$.transless,e):e(),vip:l5,async:function(e){return function(){try{var n=l4(e.apply(this,arguments));return n&&"function"==typeof n.then?n:sx.resolve(n)}catch(e){return s5(e)}}},spawn:function(e,n,t){try{var r=l4(e.apply(t,n||[]));return r&&"function"==typeof r.then?r:sx.resolve(r)}catch(e){return s5(e)}},currentTransaction:{get:()=>s$.trans||null},waitFor:function(e,n){let t=sx.resolve("function"==typeof e?cu.ignoreTransaction(e):e).timeout(n||6e4);return s$.trans?s$.trans.waitFor(t):t},Promise:sx,debug:{get:()=>iV,set:e=>{iV=e,iG="dexie"===e?()=>!0:lt}},derive:ib,extend:ip,props:im,override:iw,Events:lp,on:lI,liveQuery:function(e){let n,t=!1,r=new cf(r=>{let o=iW(e),a=!1,i={},s={},l={get closed(){return a},unsubscribe:()=>{a=!0,lI.storagemutated.unsubscribe(d)}};r.start&&r.start(l);let c=!1,p=!1;function u(){return il(s).some(e=>i[e]&&function(e,n){let t=cs(n),r=t.next();if(r.done)return!1;let o=r.value,a=cs(e),i=a.next(o.from),s=i.value;for(;!r.done&&!i.done;){if(0>=l_(s.from,o.to)&&l_(s.to,o.from)>=0)return!0;0>l_(o.from,s.from)?o=(r=t.next(s.from)).value:s=(i=a.next(o.from)).value}return!1}(i[e],s[e]))}let d=e=>{ch(i,e),u()&&f()},f=()=>{let h,m;if(c||a)return;i={};let g={},y=(o&&sq(),h=()=>sU(e,{subscr:g,trans:null}),m=s$.trans?sQ(s$.transless,h):h(),o&&m.then(sH,sH),m);p||(lI(lO,d),p=!0),c=!0,Promise.resolve(y).then(e=>{t=!0,n=e,c=!1,a||(u()?f():(i={},s=g,r.next&&r.next(e)))},e=>{c=!1,t=!1,r.error&&r.error(e),l.unsubscribe()})};return f(),l});return r.hasValue=()=>t,r.getValue=()=>n,r},extendObservabilitySet:ch,getByKeyPath:iE,setByKeyPath:iS,delByKeyPath:function(e,n){"string"==typeof n?iS(e,n,void 0):"length"in n&&[].map.call(n,function(n){iS(e,n,void 0)})},shallowClone:iD,deepClone:iN,getObjectDiff:l9,cmp:l_,asap:ix,minKey:s7,addons:[],connections:le,errnames:i1,dependencies:o,semVer:s4,version:s4.split(".").map(e=>parseInt(e)).reduce((e,n,t)=>e+n/Math.pow(10,2*t))}),cu.maxKey=lL(cu.dependencies.IDBKeyRange),"u">typeof dispatchEvent&&"u">typeof addEventListener&&(lI(lO,e=>{if(!cg){let n;ln?(n=document.createEvent("CustomEvent")).initCustomEvent(lN,!0,!0,e):n=new CustomEvent(lN,{detail:e}),cg=!0,dispatchEvent(n),cg=!1}}),addEventListener(lN,({detail:e})=>{cg||cm(e)}));let cg=!1;if("u">typeof BroadcastChannel){let e=new BroadcastChannel(lN);"function"==typeof e.unref&&e.unref(),lI(lO,n=>{cg||e.postMessage(n)}),e.onmessage=e=>{e.data&&cm(e.data)}}else if("u">typeof self&&"u">typeof navigator){lI(lO,e=>{try{cg||("u">typeof localStorage&&localStorage.setItem(lN,JSON.stringify({trig:Math.random(),changedParts:e})),"object"==typeof self.clients&&[...self.clients.matchAll({includeUncontrolled:!0})].forEach(n=>n.postMessage({type:lN,changedParts:e})))}catch(e){}}),"u">typeof addEventListener&&addEventListener("storage",e=>{if(e.key===lN){let n=JSON.parse(e.newValue);n&&cm(n.changedParts)}});let e=self.document&&navigator.serviceWorker;e&&e.addEventListener("message",function({data:e}){e&&e.type===lN&&cm(e.changedParts)})}function cy(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}sx.rejectionMapper=function(e,n){if(!e||e instanceof iJ||e instanceof TypeError||e instanceof SyntaxError||!e.name||!i3[e.name])return e;var t=new i3[e.name](n||e.message,e);return"stack"in e&&iy(t,"stack",{get:function(){return this.inner.stack}}),t},iG=lt;class cb extends cu{constructor(){super("EsmOffline"),cy(this,"syncQueue",void 0),cy(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 c_(){return new cb}let cv=new cb,c$={},cA=G("offline-synchronization",{});function cw(){return cA}async function ck(){if(cA.getState().synchronization)return;let e=await cv.syncQueue.count(),n={},t=Object.entries(c$),r=t.length,o={},a=new AbortController,i=()=>{let e=cA.getState().synchronization;cA.setState({synchronization:{...e,pendingCount:e.pendingCount-1}})};try{cA.setState({synchronization:{totalCount:e,pendingCount:e,abortController:a}});for(let e=0;e<r&&t.length>0;e++)for(let e=t.length;e--;){let[r,s]=t[e],l=s.dependsOn.map(e=>n[e]);l.every(Boolean)&&(o[r]={},await Promise.all(l),n[r]=cx(s,o,a,i),t.splice(e,1))}await Promise.allSettled(Object.values(n))}finally{cA.setState({synchronization:void 0})}}async function cx({type:e,dependsOn:n,process:t},r,o,a){let i=[],s=[],l=await cC();await cv.syncQueue.where({type:e,userId:l}).each((e,n)=>{i.push([n.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 t(u,{abort:o,index:c,items:s,userId:l,dependencies:f.map(({id:e,type:t})=>n.includes(t)?r[t][e]:void 0)});void 0!==d&&(r[e][d]=a),await cv.syncQueue.delete(p)}catch(e){await cv.syncQueue.update(p,{lastError:{name:e?.name,message:e?.message??e?.toString()}})}finally{a()}}}async function cC(){let e=await oq();return e?.uuid||"*"}async function cE(e,n,t,r){let o=r&&r.id;return void 0!==o&&await cv.syncQueue.where({type:n,userId:e}).filter(e=>e?.descriptor.id===o).delete().catch(cu.errnames.DatabaseClosed),await cv.syncQueue.add({type:n,content:t,userId:e,descriptor:r||{},createdOn:new Date}).catch(cu.errnames.DatabaseClosed,()=>-1)}async function cS(e,n,t){let r=await cC();return await cE(r,e,n,t)}async function cD(e,n){return(await cz(e,n)).map(e=>e.content)}async function cz(e,n){return await cv.syncQueue.where(n?{type:n,userId:e}:{userId:e}).toArray().catch(cu.errnames.DatabaseClosed,()=>[])}async function cM(e){let n=await cC();return await cD(n,e)}async function cP(e){let n=await cC();return await cz(n,e)}async function cT(e){return await cv.syncQueue.get(e).catch(cu.errnames.DatabaseClosed,()=>void 0)}function cO(e){return!!c$[e]?.options.onBeginEditSyncItem}async function cN(e){let n=await cT(e);if(!n)throw Error(`No sync item with the ID ${e} exists.`);let t=c$[n.type]?.options.onBeginEditSyncItem;if(!t)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 "${n.type}" supports editing items.`);t(n)}async function cI(e){await cv.syncQueue.delete(e).catch(cu.errnames.DatabaseClosed)}function cB(e,n,t,r={}){c$[e]={type:e,dependsOn:n,process:t,options:r}}let cj="u">typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),cR=new Uint8Array(16),cF=[];for(let e=0;e<256;++e)cF.push((e+256).toString(16).slice(1));let cL=function(e,n,t){if(cj&&!n&&!e)return cj();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(cR)})();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,n){t=t||0;for(let e=0;e<16;++e)n[t+e]=r[e];return n}return function(e,n=0){return cF[e[n+0]]+cF[e[n+1]]+cF[e[n+2]]+cF[e[n+3]]+"-"+cF[e[n+4]]+cF[e[n+5]]+"-"+cF[e[n+6]]+cF[e[n+7]]+"-"+cF[e[n+8]]+cF[e[n+9]]+"-"+cF[e[n+10]]+cF[e[n+11]]+cF[e[n+12]]+cF[e[n+13]]+cF[e[n+14]]+cF[e[n+15]]}(r)},cW="OFFLINE+";function cV(){return cW+cL()}function cG(e){return e.startsWith(cW)}let cU={};function cq(){return Object.values(cU)}function cH(e){cU[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.`),cU[e.id]=e}async function cK(e){let n=await c2();return await cY(n,e)}async function cY(e,n){let t=new cb;return await t.dynamicOfflineData.where(n?{type:n,users:e}:{users:e}).toArray().catch(cu.errnames.DatabaseClosed,()=>[])}async function cZ(e,n){let t=await c2();return await cJ(t,e,n)}async function cJ(e,n,t){let r=new cb,o=await r.dynamicOfflineData.get({type:n,identifier:t}).catch(cu.errnames.DatabaseClosed,()=>void 0);o?o.users.includes(e)||await r.dynamicOfflineData.update(o.id,{users:[...o.users,e]}).catch(cu.errnames.DatabaseClosed):await r.dynamicOfflineData.add({users:[e],type:n,identifier:t}).catch(cu.errnames.DatabaseClosed)}async function cX(e,n){let t=await c2();return await cQ(t,e,n)}async function cQ(e,n,t){let r=new cb,o=await r.dynamicOfflineData.get({type:n,identifier:t,users:e}).catch(cu.errnames.DatabaseClosed,()=>void 0);o&&(o.users.length>1?await r.dynamicOfflineData.update(o.id,{users:o.users.filter(n=>n!==e)}).catch(cu.errnames.DatabaseClosed):await r.dynamicOfflineData.delete(o.id).catch(cu.errnames.DatabaseClosed))}async function c0(e,n){let t=await cK(e);await Promise.all(t.map(async e=>c1(e.type,e.identifier,n)))}async function c1(e,n,t){await cZ(e,n);let r=new cb,o=await c2(),a=await r.dynamicOfflineData.get({type:e,identifier:n}).catch(cu.errnames.DatabaseClosed,()=>void 0),i=cq().filter(n=>n.type===e);if(!a)return;let s=await Promise.all(i.map(async e=>{try{return e.sync(n,t),{id:e.id,error:void 0}}catch(t){let n=t.message?.toString()??t.toString();return{id:e.id,error:n}}})),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(cu.errnames.DatabaseClosed)}async function c2(){let e=(await oq()).uuid;if(!e)throw Error("Using the dynamic offline data API requires a logged in user.");return e}let c3=G("offline-patients",{offlinePatientDataSyncState:{},handlers:{}});function c5(){return c7(),c3}function c4(e,n){c7(),cH({type:"patient",displayName:n.displayName,id:e,isSynced:()=>Promise.resolve(!0),sync:(e,t)=>n.onOfflinePatientAdded({patientUuid:e,signal:t??new AbortController().signal})})}async function c6(e){c7(),await c1("patient",e)}function c7(){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 c8(e,n,t=!0){if(e){let r=null,[o,a]=await Promise.all([oN(`${oP}/Patient/${e}`,n).catch(e=>r=e),t?c9(e):Promise.resolve(null)]);if(o.ok)return o.data;if(a)return a;if(r)throw r}return null}async function c9(e){let n=(await cM("patient-registration")).find(n=>n.fhirPatient.id===e);return n?.fhirPatient??null}function pe(e,n){let t=new CustomEvent(`openmrs:${e}`,{detail:n??void 0,cancelable:!0,bubbles:!0});return window.dispatchEvent(t)}function pn(e,n){let t=e=>{n("detail"in e&&null!==e.detail?e.detail:void 0)};return window.addEventListener(`openmrs:${e}`,t),()=>{window.removeEventListener(`openmrs:${e}`,t)}}var pt=t(9549);function pr(e){return{uuid:e.uuid,display:e.display}}function po(e=null,n=null){let t=new URLSearchParams;e&&t.set("tag",e),n&&t.set("q",n);let r=t.toString();return oI(`${oM}/location${r?"?"+r:""}`).pipe((0,pt.map)(e=>e.data.results.map(pr))).pipe((0,pt.take)(1))}function pa(e){return{uuid:e.uuid,display:e.display,name:e.name}}function pi(){return oI(`${oM}/visittype`).pipe((0,pt.map)(e=>e.data.results.map(pa))).pipe((0,pt.take)(1))}var ps=((er={}).NEWVISIT="startVisit",er.EDITVISIT="editVisit",er.LOADING="loadingVisit",er),pl=((eo={}).NOTSTARTED="notStarted",eo.ONGOING="ongoing",eo);let pc="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))",pp=function(){try{return JSON.parse(sessionStorage.getItem("openmrs:visitStoreState")||"null")}catch(e){return null}}()||{patientUuid:null,manuallySetVisitUuid:null,mutateVisitCallbacks:{}};function pu(){return q("visit",pp)}function pd(e,n){pu().setState({patientUuid:e,manuallySetVisitUuid:n})}function pf(e,n){return oN(`${oM}/visit`,{signal:n.signal,method:"POST",headers:{"Content-type":"application/json"},body:e})}function ph(e,n,t){return oN(`${oM}/visit/${e}`,{signal:t.signal,method:"POST",headers:{"Content-type":"application/json"},body:n})}function pm(e,n,t){return oN(`${oM}/visit?patient=${e}&v=${t??pc}`,{signal:n.signal,method:"GET",headers:{"Content-type":"application/json"}})}pu().subscribe(e=>{var n;n=e,sessionStorage.setItem("openmrs:visitStoreState",JSON.stringify(n))});let pg=new es.BehaviorSubject(null);class py{static get version(){return"1.4.0"}static toString(){return"JavaScript Expression Parser (JSEP) v"+py.version}static addUnaryOp(e){return py.max_unop_len=Math.max(e.length,py.max_unop_len),py.unary_ops[e]=1,py}static addBinaryOp(e,n,t){return py.max_binop_len=Math.max(e.length,py.max_binop_len),py.binary_ops[e]=n,t?py.right_associative.add(e):py.right_associative.delete(e),py}static addIdentifierChar(e){return py.additional_identifier_chars.add(e),py}static addLiteral(e,n){return py.literals[e]=n,py}static removeUnaryOp(e){return delete py.unary_ops[e],e.length===py.max_unop_len&&(py.max_unop_len=py.getMaxKeyLen(py.unary_ops)),py}static removeAllUnaryOps(){return py.unary_ops={},py.max_unop_len=0,py}static removeIdentifierChar(e){return py.additional_identifier_chars.delete(e),py}static removeBinaryOp(e){return delete py.binary_ops[e],e.length===py.max_binop_len&&(py.max_binop_len=py.getMaxKeyLen(py.binary_ops)),py.right_associative.delete(e),py}static removeAllBinaryOps(){return py.binary_ops={},py.max_binop_len=0,py}static removeLiteral(e){return delete py.literals[e],py}static removeAllLiterals(){return py.literals={},py}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 py(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 py.binary_ops[e]||0}static isIdentifierStart(e){return e>=65&&e<=90||e>=97&&e<=122||e>=128&&!py.binary_ops[String.fromCharCode(e)]||py.additional_identifier_chars.has(String.fromCharCode(e))}static isIdentifierPart(e){return py.isIdentifierStart(e)||py.isDecimalDigit(e)}throwError(e){let n=Error(e+" at character "+this.index);throw n.index=this.index,n.description=e,n}runHook(e,n){if(py.hooks[e]){let t={context:this,node:n};return py.hooks.run(e,t),t.node}return n}searchHook(e){if(py.hooks[e]){let n={context:this};return py.hooks[e].find(function(e){return e.call(n.context,n),n.node}),n.node}}gobbleSpaces(){let e=this.code;for(;e===py.SPACE_CODE||e===py.TAB_CODE||e===py.LF_CODE||e===py.CR_CODE;)e=this.expr.charCodeAt(++this.index);this.runHook("gobble-spaces")}parse(){this.runHook("before-all");let e=this.gobbleExpressions(),n=1===e.length?e[0]:{type:py.COMPOUND,body:e};return this.runHook("after-all",n)}gobbleExpressions(e){let n=[],t,r;for(;this.index<this.expr.length;)if((t=this.code)===py.SEMCOL_CODE||t===py.COMMA_CODE)this.index++;else if(r=this.gobbleExpression())n.push(r);else if(this.index<this.expr.length){if(t===e)break;this.throwError('Unexpected "'+this.char+'"')}return n}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,py.max_binop_len),n=e.length;for(;n>0;){if(py.binary_ops.hasOwnProperty(e)&&(!py.isIdentifierStart(this.code)||this.index+e.length<this.expr.length&&!py.isIdentifierPart(this.expr.charCodeAt(this.index+e.length))))return this.index+=n,e;e=e.substr(0,--n)}return!1}gobbleBinaryExpression(){let e,n,t,r,o,a,i,s,l;if(!(a=this.gobbleToken())||!(n=this.gobbleBinaryOp()))return a;for(o={value:n,prec:py.binaryPrecedence(n),right_a:py.right_associative.has(n)},(i=this.gobbleToken())||this.throwError("Expected expression after "+n),r=[a,o,i];n=this.gobbleBinaryOp();){if(0===(t=py.binaryPrecedence(n))){this.index-=n.length;break}o={value:n,prec:t,right_a:py.right_associative.has(n)},l=n;let s=e=>o.right_a&&e.right_a?t>e.prec:t<=e.prec;for(;r.length>2&&s(r[r.length-2]);)i=r.pop(),n=r.pop().value,a=r.pop(),e={type:py.BINARY_EXP,operator:n,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:py.BINARY_EXP,operator:r[s-1].value,left:r[s-2],right:e},s-=2;return e}gobbleToken(){let e,n,t,r;if(this.gobbleSpaces(),r=this.searchHook("gobble-token"))return this.runHook("after-token",r);if(e=this.code,py.isDecimalDigit(e)||e===py.PERIOD_CODE)return this.gobbleNumericLiteral();if(e===py.SQUOTE_CODE||e===py.DQUOTE_CODE)r=this.gobbleStringLiteral();else if(e===py.OBRACK_CODE)r=this.gobbleArray();else{for(t=(n=this.expr.substr(this.index,py.max_unop_len)).length;t>0;){if(py.unary_ops.hasOwnProperty(n)&&(!py.isIdentifierStart(this.code)||this.index+n.length<this.expr.length&&!py.isIdentifierPart(this.expr.charCodeAt(this.index+n.length)))){this.index+=t;let e=this.gobbleToken();return e||this.throwError("missing unaryOp argument"),this.runHook("after-token",{type:py.UNARY_EXP,operator:n,argument:e,prefix:!0})}n=n.substr(0,--t)}py.isIdentifierStart(e)?(r=this.gobbleIdentifier(),py.literals.hasOwnProperty(r.name)?r={type:py.LITERAL,value:py.literals[r.name],raw:r.name}:r.name===py.this_str&&(r={type:py.THIS_EXP})):e===py.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 n=this.code;for(;n===py.PERIOD_CODE||n===py.OBRACK_CODE||n===py.OPAREN_CODE||n===py.QUMARK_CODE;){let t;if(n===py.QUMARK_CODE){if(this.expr.charCodeAt(this.index+1)!==py.PERIOD_CODE)break;t=!0,this.index+=2,this.gobbleSpaces(),n=this.code}this.index++,n===py.OBRACK_CODE?((e={type:py.MEMBER_EXP,computed:!0,object:e,property:this.gobbleExpression()}).property||this.throwError('Unexpected "'+this.char+'"'),this.gobbleSpaces(),(n=this.code)!==py.CBRACK_CODE&&this.throwError("Unclosed ["),this.index++):n===py.OPAREN_CODE?e={type:py.CALL_EXP,arguments:this.gobbleArguments(py.CPAREN_CODE),callee:e}:(n===py.PERIOD_CODE||t)&&(t&&this.index--,this.gobbleSpaces(),e={type:py.MEMBER_EXP,computed:!1,object:e,property:this.gobbleIdentifier()}),t&&(e.optional=!0),this.gobbleSpaces(),n=this.code}return e}gobbleNumericLiteral(){let e="",n,t;for(;py.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);if(this.code===py.PERIOD_CODE)for(e+=this.expr.charAt(this.index++);py.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);if("e"===(n=this.char)||"E"===n){for(e+=this.expr.charAt(this.index++),("+"===(n=this.char)||"-"===n)&&(e+=this.expr.charAt(this.index++));py.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);py.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+e+this.char+")")}return t=this.code,py.isIdentifierStart(t)?this.throwError("Variable names cannot start with a number ("+e+this.char+")"):(t===py.PERIOD_CODE||1===e.length&&e.charCodeAt(0)===py.PERIOD_CODE)&&this.throwError("Unexpected period"),{type:py.LITERAL,value:parseFloat(e),raw:e}}gobbleStringLiteral(){let e="",n=this.index,t=this.expr.charAt(this.index++),r=!1;for(;this.index<this.expr.length;){let n=this.expr.charAt(this.index++);if(n===t){r=!0;break}if("\\"===n)switch(n=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+=n}else e+=n}return r||this.throwError('Unclosed quote after "'+e+'"'),{type:py.LITERAL,value:e,raw:this.expr.substring(n,this.index)}}gobbleIdentifier(){let e=this.code,n=this.index;for(py.isIdentifierStart(e)?this.index++:this.throwError("Unexpected "+this.char);this.index<this.expr.length;)if(e=this.code,py.isIdentifierPart(e))this.index++;else break;return{type:py.IDENTIFIER,name:this.expr.slice(n,this.index)}}gobbleArguments(e){let n=[],t=!1,r=0;for(;this.index<this.expr.length;){this.gobbleSpaces();let o=this.code;if(o===e){t=!0,this.index++,e===py.CPAREN_CODE&&r&&r>=n.length&&this.throwError("Unexpected token "+String.fromCharCode(e));break}if(o===py.COMMA_CODE){if(this.index++,++r!==n.length){if(e===py.CPAREN_CODE)this.throwError("Unexpected token ,");else if(e===py.CBRACK_CODE)for(let e=n.length;e<r;e++)n.push(null)}}else if(n.length!==r&&0!==r)this.throwError("Expected comma");else{let e=this.gobbleExpression();e&&e.type!==py.COMPOUND||this.throwError("Expected comma"),n.push(e)}}return t||this.throwError("Expected "+String.fromCharCode(e)),n}gobbleGroup(){this.index++;let e=this.gobbleExpressions(py.CPAREN_CODE);if(this.code===py.CPAREN_CODE)return(this.index++,1===e.length)?e[0]:!!e.length&&{type:py.SEQUENCE_EXP,expressions:e};this.throwError("Unclosed (")}gobbleArray(){return this.index++,{type:py.ARRAY_EXP,elements:this.gobbleArguments(py.CBRACK_CODE)}}}Object.assign(py,{hooks:new class{add(e,n,t){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]||[],n&&this[e][t?"unshift":"push"](n)},this)}run(e,n){this[e]=this[e]||[],this[e].forEach(function(e){e.call(n&&n.context?n.context:n,n)})}},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)})}}(py),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"}),py.max_unop_len=py.getMaxKeyLen(py.unary_ops),py.max_binop_len=py.getMaxKeyLen(py.binary_ops);let pb=e=>new py(e).parse(),p_=Object.getOwnPropertyNames(class{});Object.getOwnPropertyNames(py).filter(e=>!p_.includes(e)&&void 0===pb[e]).forEach(e=>{pb[e]=py[e]}),pb.Jsep=py,pb.plugins.register({name:"ternary",init(e){e.hooks.add("after-expression",function(n){if(n.node&&this.code===e.QUMARK_CODE){this.index++;let t=n.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"),n.node={type:"ConditionalExpression",test:t,consequent:r,alternate:o},t.operator&&e.binary_ops[t.operator]<=.9){let r=t;for(;r.right.operator&&e.binary_ops[r.right.operator]<=.9;)r=r.right;n.node.test=r.right,r.right=n.node,n.node=t}}else this.throwError("Expected :")}})}});let pv="ArrowFunctionExpression",p$={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)}},pA={...p$,Promise};function pw(e,n={}){return pD(e,n,pP)}async function pk(e,n={}){return pz(e,n,pP)}function px(e,n={}){return pD(e,n,pT)}function pC(e,n={}){return pz(e,n,pT)}function pE(e,n={}){return pD(e,n,pO)}function pS(e,n={}){return pz(e,n,pO)}function pD(e,n={},t){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==n&&(n={});let r=pB(n,p$),o=pN("string"==typeof e?pb(e):e,r);if(t(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 pz(e,n={},t){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==n&&(n={});let r=pB(n,pA);return Promise.resolve(pN("string"==typeof e?pb(e):e,r)).then(n=>{if(t(n))return n;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 pM(e){return pb(e)}function pP(e){return"string"==typeof e||"number"==typeof e||"boolean"==typeof e||null==e||e instanceof Date}function pT(e){return"boolean"==typeof e}function pO(e){return"number"==typeof e}function pN(e,n){switch(e.type){case"UnaryExpression":var t,r,o,a,i,s,l,c,p,u,d,f,h=e,m=n;let g=pN(h.argument,m);switch(h.operator){case"+":return+g;case"-":return-g;case"~":return~g;case"!":return!g;default:throw`Expression evaluator does not support operator '${h.operator}''`}case"BinaryExpression":var y=e,b=n;let v=pN(y.left,b),$=pN(y.right,b);switch(y.operator){case"+":return v+$;case"-":return v-$;case"*":return v*$;case"/":return v/$;case"%":return v%$;case"**":return v**$;case"==":return v==$;case"===":return v===$;case"!=":return v!=$;case"!==":return v!==$;case">":return v>$;case">=":return v>=$;case"<":return v<$;case"<=":return v<=$;case"in":return v in $;case"&&":return v&&$;case"||":return v||$;case"??":return v??$;default:throw`Expression evaluator does not support operator '${y.operator}' operator`}case"ConditionalExpression":return t=e,r=n,pN(t.test,r)?pN(t.consequent,r):pN(t.alternate,r);case"CallExpression":var A=e,w=n;let k=A.arguments?.map(pj(w)),x=pN(A.callee,w);if(x){if("function"!=typeof x)throw`${pF(A.callee)} is not a function`}else throw`No function named ${pF(A.callee)} is defined in this context`;return x(...k);case"ArrowFunctionExpression":let C;return o=e,a=n,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 n=Object.fromEntries(C.reduce((n,t,r)=>{let o=e[r];return function e(n){if("string"==typeof n||"number"==typeof n||"boolean"==typeof n||"function"==typeof n||null===n||n instanceof RegExp)return!0;if("object"==typeof n){for(let t of Object.keys(n))if(!e(n[t]))return!1;return!0}if(Array.isArray(n)){for(let t of n)if(!e(t))break}return!1}(o)&&n.push([t,o]),n},[]));return pN(o.body,a.addVariables(n))}).bind(a.thisObj??null);case"MemberExpression":return function(e,n){let t,r=pN(e.object,n);if(void 0===r)switch(e.object.type){case"Identifier":{let t=pI(e.object,n);throw ReferenceError(`ReferenceError: ${t} is not defined`)}case"MemberExpression":{let t=pI(e.property,n);throw TypeError(`TypeError: cannot read properties of undefined (reading '${t}')`)}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(n.thisObj=o,e.property.type){case"Identifier":case"MemberExpression":t=pN(e.property,n);break;default:{let o=pN(e.property,n);if(void 0===o)throw{type:"Illegal property access",message:"No property was supplied to the property access"};pR(o),t=r[o]}}return"function"==typeof t?t.bind(r):t}(e,n);case"ArrayExpression":return i=e,s=n,i.elements?.map(pj(s));case"SequenceExpression":let E;return l=e,c=n,(E=l.expressions.map(pj(c)))[E.length-1];case"NewExpression":var S=e,D=n;if(S.callee&&"Identifier"===S.callee.type){let e=S.arguments?.map(pj(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 pR((p=e).value),p.value;case"Identifier":var z=e,M=n;pR(z.name);let P=M.thisObj;if(P&&("object"==typeof P||"function"==typeof P)&&z.name in P){let e=P[z.name];return pR(e),e}if(M.variables&&z.name in M.variables){let e=M.variables[z.name];return pR(e),e}return z.name in M.globals?M.globals[z.name]:void 0;case"TemplateLiteral":let T,O;return u=e,d=n,T=u.expressions?.map(pj(d))??[],(O=u.quasis?.map(pj(d))??[]).filter(e=>!e.tail).map(e=>e.value).join("")+T.join("")+O.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 pI(e,n){switch(e.type){case"Literal":return e.value;case"Identifier":return e.name;case"MemberExpression":return pI(e.property,n);default:throw`VisitExpressionName does not support expression of type '${e.type}'`}}function pB(e,n){let t={thisObj:void 0,variables:{...e},globals:{...n},addVariables(e){return this.variables={...this.variables,...e},this}};return t.addVariables.bind(t),t}function pj(e){return function(n){return null===n?null:pN(n,e)}}function pR(e){if("__proto__"===e||"prototype"===e||"constructor"===e)throw{type:"Illegal property access",message:`Cannot access the ${e} property of objects`}}function pF(e){return e?"MemberExpression"===e.type?e.property?.name:e.name:null}function pL(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 n={globals:{...pA},isLocalExpression:!1,variables:new Set};return pW("string"==typeof e?pb(e):e,n),[...n.variables]}function pW(e,n){switch(e.type){case"UnaryExpression":return r=e,o=n,pW(r.argument,o);case"BinaryExpression":return a=e,i=n,[pW(a.left,i),pW(a.right,i)].filter(Boolean);case"ConditionalExpression":return s=e,l=n,[pW(s.consequent,l),pW(s.test,l),pW(s.alternate,l)].filter(Boolean);case"CallExpression":let t;return c=e,p=n,t=pW(c.callee,p),c.arguments?.map(pV(p)),t;case"ArrowFunctionExpression":var r,o,a,i,s,l,c,p,u,d,f,h,m,g,y,b,v,$,A=e,w=n;let k={...w};k.isLocalExpression=!0;let x=A.params?.map(pV(k))??[],C=pW(A.body,k)??[];if(C&&Array.isArray(C))for(let e of C)x.includes(e)||w.variables.add(e);return;case"MemberExpression":let E;return u=e,d=n,pW(u.object,d),void((E={...d}).isLocalExpression=!0,pW(u.property,E));case"ArrayExpression":return f=e,h=n,void f.elements?.map(pV(h));case"SequenceExpression":return m=e,g=n,void m.expressions?.map(pV(g));case"NewExpression":return y=e,b=n,void y.arguments?.map(pV(b));case"Literal":case"TemplateElement":return;case"Identifier":var S=e,D=n;if(!(S.name in D.globals))if(D.isLocalExpression)return S.name;else D.variables.add(S.name);return;case"TemplateLiteral":return v=e,$=n,void(v.expressions?.map(pV($)),v.quasis?.map(pV($)));default:throw`Expression evaluator does not support expression of type '${e.type}'`}}function pV(e){return function(n){return null===n?null:pW(n,e)}}pb.plugins.register({name:"arrow",init(e){e.addBinaryOp("=>",.1,!0),e.hooks.add("gobble-expression",function(n){if(this.gobbleSpaces(),this.code===e.OPAREN_CODE){let t=this.index;if(this.index++,this.gobbleSpaces(),this.code===e.CPAREN_CODE){this.index++;let e=this.gobbleBinaryOp();if("=>"===e){let t=this.gobbleBinaryExpression();t||this.throwError("Expected expression after "+e),n.node={type:pv,params:null,body:t};return}}this.index=t}}),e.hooks.add("after-expression",function(n){!function n(t){t&&(Object.values(t).forEach(e=>{e&&"object"==typeof e&&n(e)}),"=>"===t.operator&&(t.type=pv,t.params=t.left?[t.left]:null,t.body=t.right,t.params&&t.params[0].type===e.SEQUENCE_EXP&&(t.params=t.params[0].expressions),delete t.left,delete t.right,delete t.operator))}(n.node)})}}),pb.plugins.register({name:"new",init(e){e.addUnaryOp("new"),e.hooks.add("after-token",function(n){let t=n.node;if(t&&"new"===t.operator){t.argument&&[e.CALL_EXP,e.MEMBER_EXP].includes(t.argument.type)||this.throwError("Expected new function()"),n.node=t.argument;let r=n.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"}})}}),pb.plugins.register({name:"numbers",init(e){function n(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 t(n){let t=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=t;return}n.node={type:e.LITERAL,value:parseFloat(r),raw:this.expr.substring(t,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=n.call(this,l);if(!c)return;let p="";for(;o=this.code,a=c,95===o||a.some(([e,n])=>o>=e&&o<=n);)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,t.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)&&t.call(this,r)})}}),pb.plugins.register({name:"regex",init(e){e.hooks.add("gobble-token",function(n){if(47===this.code){let t=++this.index,r=!1;for(;this.index<this.expr.length;){if(47===this.code&&!r){let r,o=this.expr.slice(t,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 n.node={type:e.LITERAL,value:r,raw:this.expr.slice(t-1,this.index)},n.node=this.gobbleTokenProperty(n.node),n.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")}})}}),pb.plugins.register({name:"ternary",init(e){e.hooks.add("after-expression",function(n){if(n.node&&this.code===e.QUMARK_CODE){this.index++;let t=n.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"),n.node={type:"ConditionalExpression",test:t,consequent:r,alternate:o},t.operator&&e.binary_ops[t.operator]<=.9){let r=t;for(;r.right.operator&&e.binary_ops[r.right.operator]<=.9;)r=r.right;n.node.test=r.right,r.right=n.node,n.node=t}}else this.throwError("Expected :")}})}}),pb.plugins.register({name:"jsepTemplateLiteral",init(e){function n(e,t=!0){if(96===this.code){let n={type:"TemplateLiteral",quasis:[],expressions:[]},r="",o="",a=!1,i=this.expr.length,s=()=>n.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=n,t&&(e.node=this.gobbleTokenProperty(e.node)),e.node;if("$"===i&&"{"===this.expr.charAt(this.index+1))this.index+=2,s(),o="",r="",n.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",n),e.hooks.add("after-token",function(t){if((t.node.type===e.IDENTIFIER||t.node.type===e.MEMBER_EXP)&&96===this.code)return t.node={type:"TaggedTemplateExpression",tag:t.node,quasi:n.bind(this)(t,!1)},t.node=this.gobbleTokenProperty(t.node),t.node})}}),pb.addBinaryOp("in",7),pb.addBinaryOp("??",1);let pG=q("feature-flags",{flags:function(){let e={};for(let n of Object.keys(localStorage))if(n.startsWith("openmrs:feature-flag:")){let t=n.replace("openmrs:feature-flag:",""),r=JSON.parse(localStorage.getItem(`openmrs:feature-flag-meta:${t}`)||"{}");e[t]={enabled:"true"===localStorage.getItem(n),...r}}return e}()});function pU(e,n,t){pG.setState(r=>({flags:{...r.flags,[e]:{enabled:r.flags[e]?.enabled??!1,label:n,description:t}}}))}function pq(){let e=pG.getState().flags;Object.keys(localStorage).filter(e=>e.startsWith("openmrs:feature-flag:")).forEach(n=>{let t=n.replace("openmrs:feature-flag:","");e[t]||(localStorage.removeItem(n),localStorage.removeItem(`openmrs:feature-flag-meta:${t}`))})}function pH(e){return pG.getState().flags[e].enabled}function pK(e,n){pG.subscribe(t=>{n(t.flags[e].enabled)})}function pY(e,n){pG.setState(t=>({flags:{...t.flags,[e]:{...t.flags[e],enabled:n}}}))}function pZ(e){return!window.offlineEnabled||(e??navigator.onLine)}pG.subscribe(e=>{for(let[n,t]of Object.entries(e.flags))localStorage.setItem(`openmrs:feature-flag:${n}`,t.enabled.toString()),localStorage.setItem(`openmrs:feature-flag-meta:${n}`,JSON.stringify({label:t.label,description:t.description}))});var pJ=e9(function(e,n,t){e0(e,n,t)});function pX(e=!0,n=!1){return pQ(pZ(),e,n)}function pQ(e,n=!0,t=!1){return!!(e?n:t)}let p0=G("extensionsInternal",{slots:{},extensions:{}}),p1=()=>q("extensionsInternal",{slots:{},extensions:{}});function p2(e){let n=p0.getState(),t=e(n);t!==n&&p0.setState(t)}let p3=()=>q("extensions",{slots:{}});function p5(e){let n=[];for(let t of Object.values(e.extensions))for(let e of t.instances)n.push({slotModuleName:e.slotModuleName,extensionModuleName:t.moduleName,slotName:e.slotName,extensionId:e.id});(0,nn.A)(ta.getState().mountedExtensions,n)||ta.setState({mountedExtensions:n})}p5(p0.getState()),p0.subscribe(p5);let p4=p1(),p6=p3(),p7=ts(),p8=tp();function p9(e,n,t,r,o){let a={},i=pZ(),s=Object.entries(r.flags).filter(([,{enabled:e}])=>e).map(([e])=>e);for(let[r,l]of Object.entries(e.slots)){let{config:c}=tc(n,l.name),p=up(r,e,c,t,s,i,o.session);a[r]={moduleName:l.moduleName,assignedExtensions:p}}(0,nn.A)(p6.getState().slots,a)||p6.setState({slots:a})}function ue(){p9(p4.getState(),p7.getState(),p8.getState(),pG.getState(),oj.getState())}function un(e,n,t){return{moduleName:n,name:e,attachedIds:[],config:null,state:t}}function ut(e){let[n]=e.split("#");return n}function ur(e,n){let t=ut(n);return e.extensions[t]}function uo(e){return ur(p4.getState(),e)}p4.subscribe(e=>{p9(e,p7.getState(),p8.getState(),pG.getState(),oj.getState())}),p7.subscribe(e=>{p9(p4.getState(),e,p8.getState(),pG.getState(),oj.getState())}),p8.subscribe(e=>{p9(p4.getState(),p7.getState(),e,pG.getState(),oj.getState())}),pG.subscribe(e=>{p9(p4.getState(),p7.getState(),p8.getState(),e,oj.getState())}),oj.subscribe(e=>{p9(p4.getState(),p7.getState(),p8.getState(),pG.getState(),e)}),ue(),g(ue);let ua=e=>p4.setState(n=>(n.extensions[e.name]={...e,instances:[]},n));function ui(e,n){p2(t=>{let r=t.slots[e];return r?{...t,slots:{...t.slots,[e]:{...r,attachedIds:[...r.attachedIds,n]}}}:{...t,slots:{...t.slots,[e]:{...un(e),attachedIds:[n]}}}})}function us(e,n){p2(t=>{let r=t.slots[e];return r&&r.attachedIds.includes(n)?{...t,slots:{...t.slots,[e]:{...r,attachedIds:r.attachedIds.filter(e=>e!==n)}}}:t})}function ul(e){p2(n=>{let t=n.slots[e];return t?{...n,slots:{...n.slots,[e]:{...t,attachedIds:[]}}}:n})}function uc(e,n,t,r){let o=n.indexOf(e);if(-1!==o)return o;{if(void 0!==t)return 1e3+t;let n=r.indexOf(e);return -1!==n?2e3+n:-1}}function up(e,n,t,r,o,a,i){let s=function(e,n){let t=e.add||[],r=e.remove||[],o=e.order||[],{extensions:a}=p4.getState();return[...n,...t].filter(e=>!r.includes(e)).sort((e,t)=>{let r=uc(e,o,a[ut(e)]?.order,n),i=uc(t,o,a[ut(t)]?.order,n);return -1===i?-1:-1===r?1:r-i})}(t,n.slots[e].attachedIds),l=[],c=n.slots[e]?.state,p=c&&"object"==typeof c?{session:i,...c}:{session:i};for(let c of s){let{config:s}=td(r,e,c),u=pJ(s,tf(t,e,c)),d=ut(c),f=n.extensions[d];if(f){let n=u?.["Display conditions"]?.privileges??f.privileges??[];if(n&&("string"==typeof n||Array.isArray(n)&&n.length>0)&&(!i?.user||!oU(n,i.user)))continue;let t=u?.["Display conditions"]?.expression||f.displayExpression;if(void 0!==t&&"string"==typeof t&&t.trim().length>0)try{if(!px(t,p))continue}catch(n){console.error(`Error while evaluating expression '${t}' for extension ${d} in slot ${e}`,n);continue}if(f.featureFlag&&!o.includes(f.featureFlag)||window.offlineEnabled&&!pQ(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 uu(e){let n=p4.getState(),{config:t}=tl(e),r=p8.getState(),o=pG.getState(),a=oj.getState(),i=pZ();return up(e,n,t,r,Object.entries(o.flags).filter(([,{enabled:e}])=>e).map(([e])=>e),i,a.session)}let ud=(e,n,t)=>p4.setState(r=>{let o=r.slots[n]?.moduleName;if(o&&o!=e)return console.warn(`An extension slot with the name '${n}' 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[n])return{...r,slots:{...r.slots,[n]:{...r.slots[n],moduleName:e,state:t}}};let a=un(n,e,t);return{...r,slots:{...r.slots,[n]:{...a}}}});function uf(e,n,t=!1){p4.setState(r=>{let o=t?pJ(r.slots[e].state,n):n;return{...r,slots:{...r.slots,[e]:{...r.slots[e],state:o}}}})}let uh=()=>p6.setState(()=>({slots:{},extensions:{}})),um=G("left-nav",{slotName:null,basePath:window.spaBase,mode:"normal"});function ug({name:e,basePath:n,mode:t,componentContext:r,state:o}){um.setState({slotName:e,basePath:n,mode:t??"normal",componentContext:r,state:o})}function uy(e){um.getState().slotName===e&&um.setState(um.getInitialState(),!0)}let ub=G("modalRegistry",{modals:{}});function u_(e){ub.setState(n=>(n.modals[e.name]=e,n))}function uv(e){let n=ub.getState().modals[e];if(!n){let t=uo(e);t&&(n={name:e,load:t.load,moduleName:t.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.`),u_(n))}return n}let u$=G("workspaceRegistrations",{workspaces:{}}),uA=G("workspaceGroups",{workspaceGroups:{}});function uw(e){u$.setState(n=>({workspaces:{...n.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 uk(e){uA.setState(n=>{let t=n.workspaceGroups[e.name];return t?{workspaceGroups:{...n.workspaceGroups,[e.name]:{...t,members:Array.from(new Set([...t.members,...e.members]))}}}:{workspaceGroups:{...n.workspaceGroups,[e.name]:{name:e.name,members:e.members}}}})}let ux=new Set;function uC(e){let n=u$.getState().workspaces;if(n[e])return n[e];{let n=uo(e);if(n){var t;let r;return ux.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.`),ux.add(e)),{name:n.name,title:(t=n,"string"==typeof(r=t?.meta?.title)?r:r&&"object"==typeof r?o5(t.moduleName,r.key,r.default):t.name),moduleName:n.moduleName,preferredWindowSize:n.meta?.screenSize??"normal",load:n.load,type:n.meta?.type??"form",canHide:n.meta?.canHide??!1,canMaximize:n.meta?.canMaximize??!1,width:n.meta?.width??"narrow",groups:n.meta?.groups??[]}}throw Error(`No workspace named '${e}' has been registered.`)}}function uE(e){let n=uA.getState().workspaceGroups;if(n[e])return n[e];throw Error(`No workspace group named '${e}' has been registered.`)}let uS=G("workspace2",{registeredGroupsByName:{},registeredWindowsByName:{},registeredWorkspacesByName:{},openedGroup:null,openedWindows:[],workspaceTitleByWorkspaceName:{},isMostRecentlyOpenedWindowHidden:!1});function uD(e){let{registeredWorkspacesByName:n,registeredWindowsByName:t}=uS.getState(),r=n[e];if(r){let n=t[r.window];if(n)return n;throw Error(`No workspace window found with name: ${r.window} for workspace: ${e}`)}throw Error(`No workspace found with name: ${e}`)}function uz(e){let{registeredGroupsByName:n,registeredWindowsByName:t}=uS.getState(),r=t[e];if(r){let t=n[r.group];if(t)return t;throw Error(`No workspace group found with name: ${r.group} for window: ${e}`)}throw Error(`No workspace window found with name: ${e}`)}function uM(e){let{openedWindows:n}=uS.getState();return n.findIndex(n=>n.openedWorkspaces.find(n=>n.workspaceName===e))}function uP(e,n){if(0==n.length)return;let{registeredGroupsByName:t}=uS.getState(),r={...t};for(let t of n){if(r[t.name])throw Error(`Cannot register workspace group ${t.name} more than once`);r[t.name]={...t,moduleName:e}}uS.setState({registeredGroupsByName:r})}function uT(e,n){if(0==n.length)return;let{registeredWindowsByName:t}=uS.getState(),r={...t};for(let t of n){if(r[t.name])throw Error(`Cannot register workspace window ${t.name} more than once`);let n={...t,moduleName:e};r[t.name]=n}uS.setState({registeredWindowsByName:r})}function uO(e,n){if(0==n.length)return;let{registeredWorkspacesByName:t}=uS.getState(),r={...t};for(let t of n){if(r[t.name])throw Error(`Cannot register workspace ${t.name} more than once`);let n={...t,moduleName:e};r[t.name]=n}uS.setState({registeredWorkspacesByName:r})}let uN=0;async function uI(e,n,t,r,o=e=>e,a={}){let i=ut(r),s=uo(r),l=null;if(e){if(!s)throw Error(`Couldn't find extension '${i}' to attach to '${n}'`);let{meta:c,moduleName:p,online:u,offline:d,load:f}=s;if(pX(u,d)){p2(o=>({...o,extensions:{...o.extensions,[i]:{...o.extensions[i],instances:[...o.extensions[i].instances,{domElement:e,id:r,slotName:n,slotModuleName:t}]}}}));let s=await f(),u=uN++;l=rT(o({...s,name:`${n}/${i}-${u}`}),{...a,_meta:c,_extensionContext:{extensionId:r,extensionSlotName:n,extensionSlotModuleName:t,extensionModuleName:p},domElement:e})}}else console.warn(`Tried to render ${r} into ${n} but no DOM element was available.`);return l}var uB=t(2491),uj=t.n(uB);let uR=(0,uB.createContext)({moduleName:"",featureName:""});function uF({to:e,templateParams:n,onBeforeNavigate:t,children:r,...o}){return(0,uB.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}`)},[]),uj().createElement("a",{onClick:r=>{0===r.button&&!r.ctrlKey&&!r.shiftKey&&!r.altKey&&!r.metaKey&&(r.preventDefault(),t?.(r),o$({to:e,templateParams:n})),0===r.button&&(r.ctrlKey||r.metaKey)&&t?.(r),0===r.button&&r.shiftKey&&t?.(r),1===r.button&&t?.(r)},href:o_(e,n),...o},r)}let uL=({state:e,children:n,...t})=>{let{extension:r}=(0,uB.useContext)(uR),o=(0,uB.useRef)(null),a=(0,uB.useRef)(Promise.resolve()),i=(0,uB.useCallback)(n=>{r?.extensionSlotName&&r.extensionSlotModuleName&&r.extensionSlotModuleName&&!o.current&&uI(n,r.extensionSlotName,r.extensionSlotModuleName,r.extensionId,void 0,e).then(e=>{o.current=e})},[]);return(0,uB.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,uB.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?uj().createElement("div",{ref:i,"data-extension-id":r?.extensionId,style:{position:"relative"},...t}):null};function uW(e,n){"function"==typeof n&&(n=n(e));let t={};for(let[r,o]of Object.entries(n)){let n=function(...n){e.setState(e=>o(e,...n))};t[r]=n}return t}let uV=()=>e=>e;function uG(e,n=uV(),t){let r=(0,uB.useCallback)(n=>e.subscribe(n),[e]),o=(0,uB.useCallback)(()=>n(e.getState()),[e,n]),a=(0,uB.useSyncExternalStore)(r,o,o),i=(0,uB.useMemo)(()=>t?uW(e,t):{},[e,t]);return{...a,...i}}function uU(e,n){return uG(e,uV(),n)}function uq(e){return function(n){let t=(0,uB.useCallback)(n=>e.subscribe(n),[]),r=(0,uB.useCallback)(()=>e.getState(),[]),o=(0,uB.useSyncExternalStore)(t,r,r),a=(0,uB.useMemo)(()=>n?uW(e,n):{},[n]);return{...o,...a}}}let uH=e=>uG(p3(),n=>n.slots?.[e]);function uK(e){let n=uH(e);return n?.assignedExtensions??[]}function uY(e,n){let{moduleName:t}=(0,uB.useContext)(uR),r=(0,uB.useRef)(!0);if(!t)throw Error("ComponentContext has not been provided. This should come from @openmrs/esm-react-utils.");return(0,uB.useEffect)(()=>{ud(t,e,n),r.current=!1},[]),(0,uB.useEffect)(()=>{r.current||uf(e,n)},[e,n]),{extensions:uK(e),extensionSlotName:e,extensionSlotModuleName:t}}function uZ(e){return e}function uJ({name:e,extensionSlotName:n,select:t=uZ,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??n,l=(0,uB.useRef)(null),{extensions:c,extensionSlotModuleName:p}=uY(s,o),u=(0,uB.useMemo)(()=>t(c),[t,c]),d=(0,uB.useMemo)(()=>{if("function"==typeof r&&!uj().isValidElement(r))return u.map(e=>r(e,o))},[r,u]);return uj().createElement("div",{ref:l,"data-extension-slot-name":s,"data-extension-slot-module-name":p,style:{...a,position:"relative"},...i},s&&u?.map((e,n)=>uj().createElement(uR.Provider,{key:e.id,value:{moduleName:p,featureName:"",extension:{extensionId:e.id,extensionSlotName:s,extensionSlotModuleName:p}}},d?.[n]??("function"!=typeof r?r:null)??uj().createElement(uL,{state:o}))))}var uX=t(5873);function uQ(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),t.push.apply(t,r)}return t}function u0(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?uQ(Object(t),!0).forEach(function(n){var r,o,a;r=e,o=n,a=t[n],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(t)):uQ(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})}return e}function u1(e){return(u1="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 u2(e){return(u2="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 u3(e,n){var t;if("function"!=typeof(t=n.domElement?function(){return n.domElement}:n.domElementGetter?n.domElementGetter:e.domElementGetter?e.domElementGetter:function(e){var n=e.appName||e.name;if(!n)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 t="single-spa-application:".concat(n);return function(){var e=document.getElementById(t);return e||((e=document.createElement("div")).id=t,document.body.appendChild(e)),e}}(n)))throw Error("single-spa's dom-element-getter-helpers was given an invalid domElementGetter for application or parcel '".concat(n.name,"'. Expected a function, received ").concat(u2(t)));return function(){var e=t(n);if(!(e instanceof HTMLElement))throw Error("single-spa's dom-element-getter-helpers: domElementGetter returned an invalid dom element for application or parcel '".concat(n.name,"'. Expected HTMLElement, received ").concat(u2(e)));return e}}var u5=null;try{u5=require("react").createContext()}catch(e){}var u4={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 u6(e,n){return e.rootComponent?Promise.resolve():e.loadRootComponent(n).then(function(n){e.rootComponent=n})}function u7(e,n){return new Promise(function(t,r){e.suppressComponentDidCatchWarning||!function(e){if(!(e&&"string"==typeof e.version&&e.version.indexOf(".")>=0))return!1;var n=e.version.slice(0,e.version.indexOf("."));try{return Number(n)>=16}catch(e){return!1}}(e.React)||e.errorBoundary||e.errorBoundaryClass||(e.rootComponent.prototype?e.rootComponent.prototype.componentDidCatch||console.warn("single-spa-react: ".concat(n.name||n.appName||n.childAppName,"'s rootComponent should implement componentDidCatch to avoid accidentally unmounting the entire single-spa application.")):console.warn("single-spa-react: ".concat(n.name||n.appName||n.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=dn(e,n,function(){t(this)}),i=u3(e,n)(),s=function(e){var n=e.reactDom,t=e.renderType,r=e.elementToRender,o=e.domElement,a=n[t];if("function"!=typeof a)throw Error('renderType "'.concat(t,'" did not return a function.'));switch(t){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:de(e),renderType:"function"==typeof(o=e).renderType?o.renderType():o.renderType});e.domElements[n.name]=i,e.renderResults[n.name]=s})}function u8(e,n){return new Promise(function(t){e.unmountResolves[n.name]=t;var r=e.renderResults[n.name];r&&r.unmount?r.unmount():de(e).unmountComponentAtNode(e.domElements[n.name]),delete e.domElements[n.name],delete e.renderResults[n.name]})}function u9(e,n){return new Promise(function(t){e.updateResolves[n.name]||(e.updateResolves[n.name]=[]),e.updateResolves[n.name].push(t);var r=dn(e,n,null),o=e.renderResults[n.name];if(o&&o.render)o.render(r);else{var a=u3(e,n)();de(e).render(r,a)}})}function de(e){return e.ReactDOMClient||e.ReactDOM}function dn(e,n,t){var r=e.React.createElement(e.rootComponent,n),o=u5?e.React.createElement(u5.Provider,{value:n},r):r;return(e.errorBoundary||n.errorBoundary||e.errorBoundaryClass||n.errorBoundaryClass)&&(e.errorBoundaryClass=e.errorBoundaryClass||n.errorBoundaryClass||function(e,n){function t(n){e.React.Component.apply(this,arguments),this.state={caughtError:null,caughtErrorInfo:null},t.displayName="SingleSpaReactErrorBoundary(".concat(n.name,")")}return t.prototype=Object.create(e.React.Component.prototype),t.prototype.render=function(){return this.state.caughtError?(e.errorBoundary||n.errorBoundary)(this.state.caughtError,this.state.caughtErrorInfo,this.props):this.props.children},t.prototype.componentDidCatch=function(e,n){this.setState({caughtError:e,caughtErrorInfo:n})},t}(e,n),o=e.React.createElement(e.errorBoundaryClass,n,o)),o=e.React.createElement(e.SingleSpaRoot,u0(u0({},n),{},{mountFinished:t,updateFinished:function(){e.updateResolves[n.name]&&(e.updateResolves[n.name].forEach(function(e){return e()}),delete e.updateResolves[n.name])},unmountFinished:function(){e.unmountResolves[n.name]&&(e.unmountResolves[n.name](),delete e.unmountResolves[n.name])}}),o)}var dt=t(4011),dr=t(1123),da=t(2372);let di={strictMode:!0,throwErrorsToConsole:!0,disableTranslations:!1},ds=new Map;(0,da.r2)(ds);let dl={errorRetryCount:3,fetcher:oN,focusThrottleInterval:18e5,revalidateIfStale:!0,revalidateOnFocus:!1,revalidateOnReconnect:!1,refreshInterval:0,shouldRetryOnError:e=>{if(e instanceof oB){let n=e.response.status;return!!(n>=500)||401===n||403===n||429===n}return!0},provider:()=>ds};function dc(e){if("object"!=typeof e||"string"!=typeof e.featureName||"string"!=typeof e.moduleName)throw Error("Invalid options");let n=Object.assign({},di,e),t={...dl,...n.swrConfig};return function(e){var r,o,a,i,s;return a=o=class extends(r=uj().Component){componentDidCatch(e,t){t&&t.componentStack&&(e.extra=Object.assign(e.extra||{},{componentStack:t.componentStack})),n.throwErrorsToConsole&&setTimeout(()=>{throw e}),this.setState({caughtError:e,caughtErrorInfo:t})}render(){if(this.state.caughtError)return uj().createElement("div",null,"An error has occurred. Please try reloading the page.");{let r=uj().createElement(uB.Suspense,{fallback:null},uj().createElement(dr.BE,{value:t},uj().createElement(uR.Provider,{value:this.state.config},n.disableTranslations?uj().createElement(e,this.props):uj().createElement(dt.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},uj().createElement(e,this.props)))));return n.strictMode&&uj().StrictMode?uj().createElement(uj().StrictMode,null,r):r}}constructor(e){super(e),this.state={caughtError:null,caughtErrorInfo:null,config:{moduleName:n.moduleName,featureName:n.featureName,extension:e._extensionContext}}}},i="displayName",s=`OpenmrsReactComponent(${n.featureName})`,i in a?Object.defineProperty(a,i,{value:s,enumerable:!0,configurable:!0,writable:!0}):a[i]=s,o}}function dp(e,n){return function(e){if("object"!==u1(e))throw Error("single-spa-react requires a configuration object");var n,t=u0(u0({},u4),e);if(!t.React)throw Error("single-spa-react must be passed opts.React");if(!t.ReactDOM&&!t.ReactDOMClient)throw Error("single-spa-react must be passed opts.ReactDOM or opts.ReactDOMClient");if(t.renderType||(null!=(n=t.ReactDOMClient)&&n.createRoot?t.renderType="createRoot":t.renderType="render"),!t.rootComponent&&!t.loadRootComponent)throw Error("single-spa-react must be passed opts.rootComponent or opts.loadRootComponent");if(t.errorBoundary&&"function"!=typeof t.errorBoundary)throw Error("The errorBoundary opt for single-spa-react must either be omitted or be a function that returns React elements");!u5&&t.React.createContext&&(u5=t.React.createContext()),t.SingleSpaRoot=function(e){function n(e){n.displayName="SingleSpaRoot(".concat(e.name,")")}return n.prototype=Object.create(e.React.Component.prototype),n.prototype.componentDidMount=function(){setTimeout(this.props.mountFinished)},n.prototype.componentWillUnmount=function(){setTimeout(this.props.unmountFinished)},n.prototype.render=function(){return setTimeout(this.props.updateFinished),this.props.children},n}(t);var r={bootstrap:u6.bind(null,t),mount:u7.bind(null,t),unmount:u8.bind(null,t)};return t.parcelCanUpdate&&(r.update=u9.bind(null,t)),r}({React:uj(),ReactDOMClient:uX,rootComponent:dc(n)(e)})}function du(e,n){return()=>e().then(({default:e})=>dp(e,n))}function dd(e,n){return()=>Promise.resolve(dp(e,n))}let df=du,dh=L()(()=>({}));U("openmrs-app-context",dh);let dm={};function dg(e,n=e=>e){let t=dh.getState();return e in t?Object.freeze(Object.assign({},n?n(t[e]):t[e])):null}function dy(e,n){dh.setState(t=>(e in t||(t[e]={}),t[e]=n(t[e]),Object.assign({},t)))}function db(e){return null===e?null:Object.freeze(Object.assign({},e))}let d_=new Map;function dv(e,n){let t=(0,uB.useRef)(n??{}),r=(0,uB.useRef)(n=>dy(e,n)),o=(0,uB.useRef)(Symbol());return(0,uB.useEffect)(()=>{let t=n??{},r=o.current;return null===dg(e)?!function(e,n=dm){dh.setState(t=>{if(e in t)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({},t,{[e]:n===dm?{}:n})})}(e,t):(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.`),dy(e,()=>t)),d_.set(e,r),()=>{d_.get(e)===r&&(dh.setState(n=>(e in n&&delete n[e],n)),d_.delete(e))}},[e]),(0,uB.useEffect)(()=>{let r=n??{};B(t.current,r)||(dy(e,()=>r),t.current=r)},[n]),r.current}function d$({namespace:e,value:n}){return dv(e,n),null}let dA=({children:e,value:n,fallback:t})=>n?uj().createElement(uj().Fragment,null,e):t?uj().createElement(uj().Fragment,null,t):null;function dw(){let e=(0,uB.useRef)();return(!e.current||e.current.signal.aborted)&&(e.current=new AbortController),(0,uB.useEffect)(()=>{let n=e.current;return()=>n?.abort()},[]),e.current}function dk(e,n=e=>e??{}){let[t,r]=(0,uB.useState)(()=>{if(dx(e))return;let t=dg(e);if(null!==t)return n?n(t):t});return(0,uB.useEffect)(()=>{if(dx(e))throw Error(`The namespace supplied to useAppContext must be a non-empty string, but was "${e}".`)},[e]),(0,uB.useEffect)(()=>{var t;let o;return(t=e=>{if(null==e)return void r(void 0);let t=n?n(e):e;r(e=>B(e,t)?e:t)})(db(o=dg(e))),dh.subscribe(n=>{let r=e in n?n[e]:null;r!==o&&(o=r,t(db(r)))})},[e,n]),t}function dx(e){return"string"!=typeof e||0===e.trim().length}function dC(e){let[n,t]=(0,uB.useState)([]);return(0,uB.useEffect)(()=>p3().subscribe(r=>{let o=r.slots[e]?.assignedExtensions.map(e=>e.id)??[];(0,nn.A)(o,n)||t(o)}),[]),n}function dE(e,n){let{data:t,error:r,mutate:o,isLoading:a,isValidating:i}=(0,dr.Ay)(`${aR}?patient=${e}&includeEncounterless=${n}`,oN);return(0,uB.useMemo)(()=>({isLoading:a,data:t?.data.results??[],error:r,mutate:o,isValidating:i}),[t,r,a,i,o])}function dS(e){(0,uB.useEffect)(()=>{if(e){let e=window.getComputedStyle(document.body).overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=e}}},[e])}let dD={},dz=`No ComponentContext has been provided. This should come from "openmrsComponentDecorator".
16
16
  Usually this is already applied when using "getAsyncLifecycle" or "getSyncLifecycle".`;function dM(e){let{moduleName:n,extension:t}=(0,uB.useContext)(uR),r=e?.externalModuleName??n;if(!r&&!t)throw Error(dz);let o=function(e){let n=(0,uB.useMemo)(()=>ti(e),[e]),t=function(e){let[n,t]=(0,uB.useState)(()=>{let n=e.getState();return n.loaded&&n.config?n.config:null});return(0,uB.useEffect)(()=>e?.subscribe(e=>{e.loaded&&e.config&&t(e.config)}),[e]),n}(n);if(!t)throw dD[e]||(dD[e]=new Promise(e=>{let t=n.subscribe(n=>{n.loaded&&n.config&&(e(n.config),t())})})),dD[e];return t}(r),a=function(e){let n=(0,uB.useMemo)(tp,[]),t=function(e,n){let[t,r]=(0,uB.useState)(n?()=>{let t=td(e.getState(),n.extensionSlotName,n.extensionId);if(t.loaded&&t.config)return t.config}:null);return(0,uB.useEffect)(()=>{if(n)return e.subscribe(e=>{let o=td(e,n.extensionSlotName,n.extensionId);o.loaded&&o.config&&!(0,nn.A)(o.config,t)&&r(o.config)})},[e,n,t]),t}(n,e);if(!t&&e){let t=`${e.extensionSlotName}-${e.extensionId}`;throw!dD[t]&&n&&(dD[t]=new Promise(t=>{let r=n.subscribe(n=>{let o=td(n,e.extensionSlotName,e.extensionId);o.loaded&&o.config&&(t(o.config),r())})})),dD[t]}return t||{}}(t);return(0,uB.useMemo)(()=>e?.externalModuleName&&r===e.externalModuleName?{...o}:{...o,...a},[r,e?.externalModuleName,o,a])}let dP=uK;function dT(){let[e,n]=(0,uB.useState)(pZ());return(0,uB.useEffect)(()=>g(({online:e})=>n(e)),[]),e}function dO(e,n=300){let[t,r]=(0,uB.useState)(e);return(0,uB.useEffect)(()=>{let t=setTimeout(()=>{r(e)},n);return()=>{clearTimeout(t)}},[e,n]),t}var dN=t(9876);let dI=`custom:${[["admissionDecisionConcept","ref"],["admissionEncounterType","ref"],["admissionForm","ref"],["atFacilityVisitType","ref"],["bedAssignmentEncounterType","ref"],["cancelADTRequestEncounterType","ref"],["checkInClerkEncounterRole","ref"],["checkInEncounterType","ref"],["clinicianEncounterRole","ref"],["conceptSourcesForDiagnosisSearch","ref"],["consultEncounterType","ref"],["consultFreeTextCommentsConcept","ref"],["denyAdmissionConcept","ref"],["diagnosisMetadata","ref"],["diagnosisSets","ref"],["dischargeForm","ref"],["dispositionDescriptor","ref"],["dispositions","ref"],["emrApiConceptSource","ref"],["exitFromInpatientEncounterType","ref"],["extraPatientIdentifierTypes","ref"],["fullPrivilegeLevel","ref"],["highPrivilegeLevel","ref"],["identifierTypesToSearch","ref"],["inpatientNoteEncounterType","ref"],["lastViewedPatientSizeLimit","ref"],["metadataSourceName","ref"],["motherChildRelationshipType","ref"],["narrowerThanConceptMapType","ref"],["nonDiagnosisConceptSets","ref"],["orderingProviderEncounterRole","ref"],["patientDiedConcept","ref"],["personImageDirectory","ref"],["primaryIdentifierType","ref"],["sameAsConceptMapType","ref"],["suppressedDiagnosisConcepts","ref"],["supportsAdmissionLocationTag","(uuid,display,name,links)"],["supportsLoginLocationTag","(uuid,display,name,links)"],["supportsTransferLocationTag","(uuid,display,name,links)"],["supportsVisitsLocationTag","(uuid,display,name,links)"],["telephoneAttributeType","ref"],["testPatientPersonAttributeType","ref"],["transferForm","ref"],["transferRequestEncounterType","ref"],["transferWithinHospitalEncounterType","ref"],["unknownCauseOfDeathConcept","ref"],["unknownLocation","ref"],["unknownPatientPersonAttributeType","ref"],["unknownProvider","ref"],["visitAssignmentHandlerAdjustEncounterTimeOfDayIfNecessary","ref"],["visitExpireHours","ref"],["visitNoteEncounterType","ref"]].map(([e,n])=>`${e}:${n}`).join(",")}`;function dB(){let e=`${oM}/emrapi/configuration?v=${dI}`,n=(0,dN.A)(e,oN);return(0,uB.useMemo)(()=>({emrConfiguration:n.data?.data,isLoadingEmrConfiguration:n.isLoading,mutateEmrConfiguration:n.mutate,errorFetchingEmrConfiguration:n.error}),[n])}let dj=uq(p1());function dR(e){let n=uK(e);return(0,uB.useMemo)(()=>Object.fromEntries(n.map(e=>[e.name,e.meta])),[n])}let dF=uq(p3());function dL(e){let{flags:n}=uG(pG);return n[e]?.enabled??!1}function dW(){let[,e]=(0,uB.useState)(0);return(0,uB.useCallback)(()=>{e(e=>e+1)},[])}function dV(e,n,t={}){return dU(e,n,dG,t)}let dG={getPaginatedUrl:(e,n,t)=>{if(!e)return null;{let r=new URL(oO(e.toString()),window.location.toString());return r.searchParams.set("limit",""+n),r.searchParams.set("startIndex",""+t),r.searchParams.set("totalCount","true"),r.toString()}},getNextUrl:e=>{let n=e?.links?.find(e=>"next"==e.rel)?.uri;if(!n)return null;{let e=new URL(n);return e.host=window.location.host,e.protocol=window.location.protocol,e.toString()}},getTotalCount:e=>e?.totalCount??NaN,getCurrentPageSize:e=>e?.results?.length??NaN,getData:e=>e?.results};function dU(e,n,t,r={}){let{getPaginatedUrl:o,getTotalCount:a,getCurrentPageSize:i,getData:s}=t,{immutable:l,swrConfig:c}=r,p=r.fetcher??oN,[u,d]=(0,uB.useState)(1),f=(0,uB.useRef)(NaN),h=(0,uB.useRef)(NaN),m=(u-1)*n,g=(0,uB.useMemo)(()=>o(e,n,m),[e,n,m]),{data:y,...b}=(l?dN.A:dr.Ay)(g,p,c);y?.data&&(f.current=a(y?.data),h.current=i(y?.data));let v=Math.ceil(f.current/n),$=(0,uB.useCallback)(e=>{0<e&&e<=v?d(e):console.warn("Invalid attempt to go to out of bounds page: "+e)},[e,u,v]),A=(0,uB.useCallback)(()=>{$(u+1)},[e,u,v]),w=(0,uB.useCallback)(()=>{$(u-1)},[e,u,v]);return{data:s(y?.data),totalPages:v,totalCount:f.current,currentPage:u,currentPageSize:h,paginated:v>1,showNextButton:u<v,showPreviousButton:u>1,goTo:$,goToNext:A,goToPrevious:w,...b}}function dq(e,n,t={}){return dU(e,n,dH(),t)}function dH(){return{getPaginatedUrl:(e,n,t)=>{if(!e)return null;{let r=new URL(oO(e.toString()),window.location.toString());return r.searchParams.set("_count",""+n),r.searchParams.set("_getpagesoffset",""+t),r.toString()}},getNextUrl:e=>{let n=e?.link?.find(e=>"next"==e.relation)?.url;if(!n)return null;{let e=new URL(n);return e.host=window.location.host,e.protocol=window.location.protocol,e.toString()}},getTotalCount:e=>e?.total??NaN,getCurrentPageSize:e=>e?.entry?.length??NaN,getData:e=>e?.entry?.map(e=>e.resource)}}var dK=t(8139);let dY=uj().use||(e=>{if("pending"===e.status)throw e;if("fulfilled"===e.status)return e.value;if("rejected"===e.status)throw e.reason;throw e.status="pending",e.then(n=>{e.status="fulfilled",e.value=n},n=>{e.status="rejected",e.reason=n}),e}),dZ={dedupe:!0};da.qv.defineProperty(da.BE,"defaultValue",{value:da.sb});let dJ=(0,da.qm)((e,n,t)=>{let{cache:r,compare:o,suspense:a,fallbackData:i,revalidateOnMount:s,revalidateIfStale:l,refreshInterval:c,refreshWhenHidden:p,refreshWhenOffline:u,keepPreviousData:d}=t,[f,h,m,g]=da.bZ.get(r),[y,b]=(0,da.lK)(e),v=(0,uB.useRef)(!1),$=(0,uB.useRef)(!1),A=(0,uB.useRef)(y),w=(0,uB.useRef)(n),k=(0,uB.useRef)(t),x=()=>k.current.isVisible()&&k.current.isOnline(),[C,E,S,D]=(0,da.r9)(r,y),z=(0,uB.useRef)({}).current,M=(0,da.b0)(i)?t.fallback[y]:i,P=(e,n)=>{for(let t in z)if("data"===t){if(!o(e[t],n[t])&&(!(0,da.b0)(e[t])||!o(L,n[t])))return!1}else if(n[t]!==e[t])return!1;return!0},T=(0,uB.useMemo)(()=>{let e=!!y&&!!n&&((0,da.b0)(s)?!k.current.isPaused()&&!a&&(!!(0,da.b0)(l)||l):s),t=n=>{let t=(0,da.rL)(n);return(delete t._k,e)?{isValidating:!0,isLoading:!0,...t}:t},r=C(),o=D(),i=t(r),c=r===o?i:t(o),p=i;return[()=>{let e=t(C());return P(e,p)?(p.data=e.data,p.isLoading=e.isLoading,p.isValidating=e.isValidating,p.error=e.error,p):(p=e,e)},()=>c]},[r,y]),O=(0,dK.useSyncExternalStore)((0,uB.useCallback)(e=>S(y,(n,t)=>{P(t,n)||e()}),[r,y]),T[0],T[1]),N=!v.current,I=f[y]&&f[y].length>0,B=O.data,j=(0,da.b0)(B)?M:B,R=O.error,F=(0,uB.useRef)(j),L=d?(0,da.b0)(B)?F.current:B:j,W=(!I||!!(0,da.b0)(R))&&(N&&!(0,da.b0)(s)?s:!k.current.isPaused()&&(a?!(0,da.b0)(j)&&l:(0,da.b0)(j)||l)),V=!!(y&&n&&N&&W),G=(0,da.b0)(O.isValidating)?V:O.isValidating,U=(0,da.b0)(O.isLoading)?V:O.isLoading,q=(0,uB.useCallback)(async e=>{let n,r,a=w.current;if(!y||!a||$.current||k.current.isPaused())return!1;let i=!0,s=e||{},l=!m[y]||!s.dedupe,c=()=>da.dO?!$.current&&y===A.current&&v.current:y===A.current,p={isValidating:!1,isLoading:!1},u=()=>{E(p)},d=()=>{let e=m[y];e&&e[1]===r&&delete m[y]},g={isValidating:!0};(0,da.b0)(C().data)&&(g.isLoading=!0);try{if(l&&(E(g),t.loadingTimeout&&(0,da.b0)(C().data)&&setTimeout(()=>{i&&c()&&k.current.onLoadingSlow(y,t)},t.loadingTimeout),m[y]=[a(b),(0,da.lg)()]),[n,r]=m[y],n=await n,l&&setTimeout(d,t.dedupingInterval),!m[y]||m[y][1]!==r)return l&&c()&&k.current.onDiscarded(y),!1;p.error=da.ZH;let e=h[y];if(!(0,da.b0)(e)&&(r<=e[0]||r<=e[1]||0===e[1]))return u(),l&&c()&&k.current.onDiscarded(y),!1;let s=C().data;p.data=o(s,n)?s:n,l&&c()&&k.current.onSuccess(n,y,t)}catch(t){d();let e=k.current,{shouldRetryOnError:n}=e;!e.isPaused()&&(p.error=t,l&&c()&&(e.onError(t,y,e),(!0===n||(0,da.Tn)(n)&&n(t))&&(!k.current.revalidateOnFocus||!k.current.revalidateOnReconnect||x())&&e.onErrorRetry(t,y,e,e=>{let n=f[y];n&&n[0]&&n[0](da.bu.ERROR_REVALIDATE_EVENT,e)},{retryCount:(s.retryCount||0)+1,dedupe:!0})))}return i=!1,u(),!0},[y,r]),H=(0,uB.useCallback)((...e)=>(0,da.mF)(r,A.current,...e),[]);if((0,da.Es)(()=>{w.current=n,k.current=t,(0,da.b0)(B)||(F.current=B)}),(0,da.Es)(()=>{if(!y)return;let e=q.bind(da.ZH,dZ),n=0,t=(0,da.aw)(y,f,(t,r={})=>{if(t==da.bu.FOCUS_EVENT){let t=Date.now();k.current.revalidateOnFocus&&t>n&&x()&&(n=t+k.current.focusThrottleInterval,e())}else if(t==da.bu.RECONNECT_EVENT)k.current.revalidateOnReconnect&&x()&&e();else if(t==da.bu.MUTATE_EVENT)return q();else if(t==da.bu.ERROR_REVALIDATE_EVENT)return q(r)});return $.current=!1,A.current=y,v.current=!0,E({_k:b}),W&&((0,da.b0)(j)||da.X3?e():(0,da.mf)(e)),()=>{$.current=!0,t()}},[y]),(0,da.Es)(()=>{let e;function n(){let n=(0,da.Tn)(c)?c(C().data):c;n&&-1!==e&&(e=setTimeout(t,n))}function t(){!C().error&&(p||k.current.isVisible())&&(u||k.current.isOnline())?q(dZ).then(n):n()}return n(),()=>{e&&(clearTimeout(e),e=-1)}},[c,p,u,y]),(0,uB.useDebugValue)(L),a&&(0,da.b0)(j)&&y){if(!da.dO&&da.X3)throw Error("Fallback data is required when using suspense in SSR.");w.current=n,k.current=t,$.current=!1;let e=g[y];if((0,da.b0)(e)||dY(H(e)),(0,da.b0)(R)){let e=q(dZ);(0,da.b0)(L)||(e.status="fulfilled",e.value=!0),dY(e)}else throw R}return{mutate:H,get data(){return z.data=!0,L},get error(){return z.error=!0,R},get isValidating(){return z.isValidating=!0,G},get isLoading(){return z.isLoading=!0,U}}}),dX=Promise.resolve(),dQ=(0,da.Ht)(dJ,e=>(n,t,r)=>{let o,a=(0,uB.useRef)(!1),{cache:i,initialSize:s=1,revalidateAll:l=!1,persistSize:c=!1,revalidateFirstPage:p=!0,revalidateOnMount:u=!1,parallel:d=!1}=r,[,,,f]=da.bZ.get(da.PP);try{(o=(0,da.lK)(n?n(0,null):null)[0])&&(o=da.q9+o)}catch(e){}let[h,m,g]=(0,da.r9)(i,o),y=(0,uB.useCallback)(()=>(0,da.b0)(h()._l)?s:h()._l,[i,o,s]);(0,dK.useSyncExternalStore)((0,uB.useCallback)(e=>o?g(o,()=>{e()}):()=>{},[i,o]),y,y);let b=(0,uB.useCallback)(()=>{let e=h()._l;return(0,da.b0)(e)?s:e},[o,s]),v=(0,uB.useRef)(b());(0,da.Es)(()=>{if(!a.current){a.current=!0;return}o&&m({_l:c?v.current:b()})},[o,i]);let $=u&&!a.current,A=e(o,async e=>{let o=h()._i,a=h()._r;m({_r:da.ZH});let s=[],c=b(),[u]=(0,da.r9)(i,e),g=u().data,y=[],v=null;for(let e=0;e<c;++e){let[c,u]=(0,da.lK)(n(e,d?null:v));if(!c)break;let[h,m]=(0,da.r9)(i,c),b=h().data,A=l||o||(0,da.b0)(b)||p&&!e&&!(0,da.b0)(g)||$||g&&!(0,da.b0)(g[e])&&!r.compare(g[e],b);if(t&&("function"==typeof a?a(b,u):A)){let n=async()=>{if(c in f){let e=f[c];delete f[c],b=await e}else b=await t(u);m({data:b,_k:u}),s[e]=b};d?y.push(n):await n()}else s[e]=b;d||(v=b)}return d&&await Promise.all(y.map(e=>e())),m({_i:da.ZH}),s},r),w=(0,uB.useCallback)(function(e,n){let t="boolean"==typeof n?{revalidate:n}:n||{},r=!1!==t.revalidate;return o?(r&&((0,da.b0)(e)?m({_i:!0,_r:t.revalidate}):m({_i:!1,_r:t.revalidate})),arguments.length?A.mutate(e,{...t,revalidate:r}):A.mutate()):dX},[o,i]),k=(0,uB.useCallback)(e=>{let t;if(!o)return dX;let[,r]=(0,da.r9)(i,o);if((0,da.Tn)(e)?t=e(b()):"number"==typeof e&&(t=e),"number"!=typeof t)return dX;r({_l:t}),v.current=t;let a=[],[s]=(0,da.r9)(i,o),l=null;for(let e=0;e<t;++e){let[t]=(0,da.lK)(n(e,l)),[r]=(0,da.r9)(i,t),o=t?r().data:da.ZH;if((0,da.b0)(o))return w(s().data);a.push(o),l=o}return w(a)},[o,i,w,b]);return{size:b(),setSize:k,mutate:w,get data(){return A.data},get error(){return A.error},get isValidating(){return A.isValidating},get isLoading(){return A.isLoading}}});function d0(e,n={}){return d1(e,dG,n)}function d1(e,n,t={}){let{swrInfiniteConfig:r,immutable:o}=t,{getNextUrl:a,getTotalCount:i,getData:s}=n,l=t.fetcher??oN,{data:c,size:p,setSize:u,...d}=dQ((0,uB.useCallback)((t,r)=>0==t?e?.toString()??null:n.getNextUrl(r.data),[e]),l,{...r,...o?{revalidateIfStale:!1,revalidateOnFocus:!1,revalidateOnReconnect:!1}:{}}),f=a(c?.[c.length-1].data),h=i(c?.[0]?.data);return{data:c?.flatMap(e=>s(e.data)),totalCount:h,hasMore:null!=f,loadMore:()=>{u((c?.length??0)+1)},nextUri:f,...d}}function d2(e,n={}){return d3(e,dG,n)}function d3(e,n,t={}){let r=d1(e,n,t),{hasMore:o,error:a,data:i,loadMore:s,isLoading:l,nextUri:c}=r;return((0,uB.useEffect)(()=>{o&&!a&&s()},[o,c]),t.partialData)?r:{...r,data:o||a?void 0:i,isLoading:l||o}}function d5(e,n={}){return d3(e,dH(),n)}function d4(e,n={}){return d1(e,dH(),n)}function d6(){let e="tablet";return document.body.classList.forEach(n=>{switch(n){case"omrs-breakpoint-lt-tablet":e="phone";break;case"omrs-breakpoint-gt-small-desktop":e="large-desktop";break;case"omrs-breakpoint-gt-tablet":e="small-desktop"}}),e}function d7(){let[e,n]=(0,uB.useState)(d6);return(0,uB.useEffect)(()=>{let e=()=>{n(d6())};return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),e}let d8=e=>"small-desktop"===e||"large-desktop"===e;function d9(e){let n=(0,uB.useContext)(uR);(0,uB.useEffect)(()=>(n&&n.moduleName&&(e.componentContext=n),ug(e),()=>{uy(e.name)}),[n,e])}function fe(){return uG(um)}function fn(e=null,n=null){let[t,r]=(0,uB.useState)([]);return(0,uB.useEffect)(()=>{let t=po(e,n).subscribe(e=>{r(e)},e=>{console.error(e)});return()=>t.unsubscribe()},[e,n]),t}function ft(e,n=!0){let t=(0,uB.useRef)(null);return(0,uB.useEffect)(()=>{let r=r=>{n&&t.current&&r.target&&r.target instanceof Node&&(t.current.contains(r.target)||e(r))};return window.addEventListener("mousedown",r),window.addEventListener("touchstart",r),()=>{window.removeEventListener("mousedown",r),window.removeEventListener("touchstart",r)}},[e,n]),t}function fr(e){let n=(0,uB.useRef)();return(0,uB.useEffect)(()=>{let t=new IntersectionObserver(n=>{for(let t of n)if(t.isIntersecting)return void e()},{threshold:1});return n.current&&t.observe(n.current),()=>{n.current&&t.unobserve(n.current)}},[n.current,e]),n}function fo(e,n={}){let{abortController:t,fetchInit:r,url:o,swrConfig:a}=n,i=dw(),s=(0,uB.useMemo)(()=>r?.signal??t?.signal??i.signal,[t?.signal,r?.signal,i.signal]),l=(0,uB.useCallback)(e=>oN(function(e,n){if(n)return"function"==typeof n?n(e):n;if("string"==typeof e)return e;throw Error(`When using useOpenmrsSWR with a key that is not a string, you must provide a url() function that converts the key to a valid url. The key for this hook is ${e}.`)}(e,o),{...r,signal:s}),[s,r,o]);return(0,dr.Ay)(e,l,a)}function fa(e=[],n=10){let[t,r]=(0,uB.useState)(1),o=(0,uB.useMemo)(()=>"number"==typeof n&&n>0?Math.max(1,Math.ceil(e.length/n)):1,[e.length,n]),a=(0,uB.useMemo)(()=>{let r=(t-1)*n,o=(t+0)*n;return e.slice(r,o)},[e,t,n]),i=(0,uB.useCallback)(e=>{r(Math.max(1,Math.min(o,e)))},[r,o]),s=(0,uB.useCallback)(()=>{t<o&&r(t+1)},[t,o,r]),l=(0,uB.useCallback)(()=>{t>1&&r(t-1)},[t,r]);return(0,uB.useMemo)(()=>({results:a,totalPages:o,currentPage:t,paginated:e.length>n,showNextButton:t<o,showPreviousButton:t>1,goTo:i,goToNext:s,goToPrevious:l}),[a,o,e.length,n,t,i,s,l])}function fi(e,n,t,r){return{pageSizes:(0,uB.useMemo)(()=>{let t=Math.ceil(n/e);return isNaN(t)&&(t=0),[...Array(t).keys()].map(n=>(n+1)*e)},[e,n]),pageItemsCount:(0,uB.useMemo)(()=>e>n?n:e*t>n?e*(t-1)+r:e*t,[e,n,t,r])}}function fs(){let e=/\/patient\/([a-zA-Z0-9\-]+)\/?/.exec(location.pathname);return e&&e[1]}function fl(e){let[n,t]=(0,uB.useState)(e??fs()),{data:r,error:o,isValidating:a}=(0,dr.Ay)(n?["patient",n]:null,()=>c8(n,{}));return(0,uB.useEffect)(()=>{let e=()=>{let e=fs();e!==n&&t(e)};return window.addEventListener("single-spa:routing-event",e),()=>window.removeEventListener("single-spa:routing-event",e)},[n]),(0,uB.useMemo)(()=>({isLoading:a&&!o&&!r,patient:r,patientUuid:n,error:o}),[a,o,r,n])}function fc(){let e=`${oM}/metadatamapping/termmapping?v=custom:(metadataUuid)&code=emr.primaryIdentifierType`,{data:n,error:t,isLoading:r}=(0,dr.Ay)(e,oN);return(0,uB.useMemo)(()=>({primaryIdentifierCode:n?.data?.results[0]?.metadataUuid,isLoading:r,error:t}),[n,t,r])}function fp(e){let{extensions:n,extensionSlotModuleName:t}=uY(e);return e?n.map(n=>({state:r})=>uj().createElement(uR.Provider,{value:{moduleName:t,featureName:"",extension:{extensionId:n.id,extensionSlotName:e,extensionSlotModuleName:t}}},uj().createElement(uL,{state:r}))):[]}function fu(){let e=(0,uB.useRef)(),[n,t]=(0,uB.useState)(null),r=null;if(!n){if(i){let e=oL().getState();e.loaded&&(r=e.session)}else i=new Promise(n=>{let t=({loaded:t,session:o})=>{t&&(n(o),r=o,e.current&&(e.current(),e.current=void 0))};t(oL().getState()),r||(e.current=oL().subscribe(t))});if(r)t(r);else throw i}(0,uB.useEffect)(()=>(e.current||(e.current=oL().subscribe(({loaded:e,session:n})=>{e&&(r=n,t(n))})),()=>{e.current&&(e.current(),e.current=void 0)}),[]);let o=n||r;if(!o)if(i)throw console.warn("useSession is in an unexpected state. Attempting to recover."),i;else throw Error("useSession is in an invalid state.");return o}let fd=({privilege:e,fallback:n,children:t})=>{let[r,o]=(0,uB.useState)(null);return((0,uB.useEffect)(()=>{let e=oF({includeAuthStatus:!1}).subscribe(o);return()=>e.unsubscribe()},[]),r&&oU(e,r))?uj().createElement(uj().Fragment,null,t):n?uj().createElement(uj().Fragment,null,n):null};var ff=t(4274),fh=t.n(ff),fm=t(5602);let fg={setVisitContext:(e,n)=>null==n?{manuallySetVisitUuid:null}:{manuallySetVisitUuid:n.uuid,patientUuid:n.patient?.uuid},mutateVisit(e){for(let n of Object.values(e.mutateVisitCallbacks??{}))n();return{}}};function fy(e){let n=(0,uB.useId)();return(0,uB.useEffect)(()=>{let t=pu();return e&&t.setState({mutateVisitCallbacks:{...t.getState().mutateVisitCallbacks,[n]:e}}),()=>{if(e){let e={...t.getState().mutateVisitCallbacks};delete e[n],t.setState({mutateVisitCallbacks:e})}}},[n,e]),uU(pu(),fg)}function fb(e,n=pc){let{patientUuid:t,manuallySetVisitUuid:r,setVisitContext:o}=fy(),a=e&&t==e?r:null,i=`?patient=${e}&v=${n}&includeInactive=false`,s=`/${a}?v=${n}`,{data:l,error:c,mutate:p,isValidating:u}=(0,dr.Ay)(e?`${oM}/visit${i}`:null,oN),{data:d,error:f,mutate:h,isValidating:m}=(0,dr.Ay)(e&&a?`${oM}/visit${s}`:null,oN),g=(0,uB.useMemo)(()=>l?.data.results.find(e=>null===e.stopDatetime)??null,[l]),y=(0,uB.useMemo)(()=>a&&d?d.data:null,[d,a]),b=(0,uB.useRef)(null);(0,uB.useEffect)(()=>{!u&&g&&t===e&&null===r&&o(g),m||(b.current&&y&&b.current.uuid===y.uuid&&!b.current.stopDatetime&&y.stopDatetime&&o(null),b.current=y)},[y,r,g,u,m,t]);let v=(0,uB.useCallback)(()=>{p(),h()},[p,h]);fy(v);let $=!!(!l||a&&!d),A=!!(a?f:c);return{error:c||f,mutate:v,isValidating:u||m,activeVisit:g,currentVisit:y,currentVisitIsRetrospective:!!a,isLoading:$&&!A}}function f_(){let[e,n]=(0,uB.useState)([]);return(0,uB.useEffect)(()=>{let e=pi().subscribe(e=>{n(e)},e=>console.error(e));return()=>e.unsubscribe()},[]),e}fh().extend(fm);let fv=new Map;async function f$(e,n){let t=n.indexOf("#"),r=t>=0,o=r?n.substring(0,t):e,a=r?n.substring(t+1):n,i=await ay(o);return i&&Object.hasOwn(i,a)&&"function"==typeof i[a]?fw(o,i).then(()=>i[a]()):(i?i&&Object.hasOwn(i,a)?console.warn(`The export ${n}, defined in ${e}'s routes.json, is not a function`):console.warn(`${o} does not define a component called "${a}", referenced in ${e}'s routes.json. This cannot be loaded.`):console.warn(`Unknown app ${o} for ${n} defined in ${e}'s routes.json`),fA)}let fA={bootstrap:()=>Promise.resolve(),mount:()=>Promise.resolve(),unmount:()=>Promise.resolve()};async function fw(e,n){if(e in fv)await fv[e];else{let t=n??await ay(e);await (fv[e]=new Promise((n,r)=>{if(Object.hasOwn(t,"startupApp")){let o=t.startupApp;if("function"==typeof o)return Promise.resolve(o()).then(()=>{t$(e),n(null)}).catch(r)}t$(e),n(null)}))}}function fk(e,n){let t=n.name;if(!t)return void console.error(`An extension definition in ${e} is missing an name and thus cannot be
17
17
  registered. To fix this, ensure that you define the "name" field inside the
18
18
  extension definition.`,n);n.slots&&n.slot&&console.warn(`The extension ${t} from ${e} declares both a 'slots' property and