@openmrs/esm-billing-app 1.3.2-pre.1992 → 1.3.2-pre.1995
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/cache/41434d502135d9a5-meta.json +1 -0
- package/.turbo/cache/41434d502135d9a5.tar.zst +0 -0
- package/.turbo/turbo-build.log +1 -1
- package/SECURITY.md +12 -0
- package/dist/2450.js +1 -1
- package/dist/2450.js.map +1 -1
- package/dist/main.js +2 -2
- package/dist/openmrs-esm-billing-app.js +2 -2
- package/dist/openmrs-esm-billing-app.js.buildmanifest.json +5 -5
- package/dist/routes.json +1 -1
- package/package.json +1 -1
- package/.turbo/cache/65a6cb6fedae6425-meta.json +0 -1
- package/.turbo/cache/65a6cb6fedae6425.tar.zst +0 -0
package/dist/2450.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 i}let tE=(e,n)=>{let t=structuredClone(n);if(!e)return t;for(let n of Object.keys(e)){let i=t[n],r=e[n];if(r&&(r.hasOwnProperty("_type")||r.hasOwnProperty("_default"))){t.hasOwnProperty(n)||(t[n]=r._default);let e=r._elements;if(i&&tS(e)){if(r._type===nB.Array&&Array.isArray(i)){let r=i.map(n=>tE(e,n));t[n]=r}else if(r._type===nB.Object)for(let n of Object.keys(i))i[n]=tE(e,i[n])}}else if(tD(r)){let e=i??{};tD(e)&&(t[n]=tE(r,e))}}return t};function tS(e){return!!e&&Object.keys(e).filter(e=>!["_default","_validators"].includes(e)).length>0}function tD(e){return"object"==typeof e&&!Array.isArray(e)&&null!==e}let tM=new Set;function tz(e,n){let t=`${e}:::${n}`;tM||(tM=new Set),tM.has(t)||(console.error(n),tM.add(t))}function tO(e){e?tM.forEach(n=>{n.startsWith(e)&&tM.delete(n)}):tM.clear()}function tP(){tn.forEach(e=>e()),tn.length=0,to.clear(),tm.clear(),ty.clear(),tb.clear(),ti()}let tT={"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:nB.Object,_default:{},_validators:[nI(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(", ")}.`})]}},tB={"Display conditions":{privileges:{_description:"The privilege(s) the user must have to use this extension",_type:nB.Array,_default:[]},expression:{_description:"The expression that determines whether the extension is displayed",_type:nB.String,_default:void 0}},...tT},tI=(e,n)=>nI(t=>e<=t&&t<=n,`must be between ${e} and ${n}`),tN=e=>{let n=e.concat(["openmrsBase","openmrsSpaBase"]);return nI(e=>{if(!e||"string"!=typeof e)return!1;let t=/\${(.*?)}/g,i=t.exec(e);for(;i;){if(!n.includes(i[1]))return!1;i=t.exec(e)}return!0},"Should be a URL or path. The allowed template parameters are "+n.map(e=>"${"+e+"}").join(", "))},tj=tN([]),tR=e=>nI(n=>e.includes(n),`Must be one of the following: '${e.join("', '")}'.`),tF={inRange:tI,isUrl:tj,isUrlWithTemplateParameters:tN,oneOf:tR};var tL=t(48067);let tW=H("breadcrumbs",[]);function tV(e){return tG([e])}function tG(e){let n=[...tU(),...e.map(e=>({matcher:e.matcher instanceof RegExp?e.matcher:"string"==typeof e.matcher?(0,tL.pathToRegexp)(e.matcher).regexp:(0,tL.pathToRegexp)(e.path).regexp,settings:e}))];tW.setState(n,!0)}function tU(){return tW.getState()}function tH(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=tH(e,t.join("/"));if(n)return n}}(e,n)}function tq(e,n){if(e.length>0){let t=tH(e,n);if(t){let n=[t],i=tH(e,t.settings.parent);for(;void 0!==i;)n.push(i),i=tH(e,i.settings.parent);return n.reverse()}}return[]}function tK(e){return tq(tU(),e)}var tY=Object.freeze({__proto__:null,get start(){return rp},get ensureJQuerySupport(){return iJ},get setBootstrapMaxTime(){return iz},get setMountMaxTime(){return iO},get setUnmountMaxTime(){return iP},get setUnloadMaxTime(){return iT},get registerApplication(){return i8},get unregisterApplication(){return i9},get getMountedApps(){return i3},get getAppStatus(){return i4},get unloadApplication(){return re},get checkActivityFunctions(){return i7},get getAppNames(){return i5},get pathToActiveWhen(){return ri},get navigateToUrl(){return iL},get patchHistoryApi(){return iq},get triggerAppChange(){return rs},get addErrorHandler(){return t0},get removeErrorHandler(){return t1},get mountRootParcel(){return iC},get NOT_LOADED(){return t5},get LOADING_SOURCE_CODE(){return t4},get NOT_BOOTSTRAPPED(){return t6},get BOOTSTRAPPING(){return t8},get NOT_MOUNTED(){return t7},get MOUNTING(){return t9},get UPDATING(){return it},get LOAD_ERROR(){return io},get MOUNTED(){return ie},get UNLOADING(){return ir},get UNMOUNTING(){return ii},get SKIP_BECAUSE_BROKEN(){return ia}}),tJ=("u">typeof globalThis?globalThis:"u">typeof window?window:"u">typeof global?global:"u">typeof self?self:{}).CustomEvent,tZ=!function(){try{var e=new tJ("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}:tJ;let tX=[];function tQ(e,n,t){let i=t3(e,n,t);tX.length?tX.forEach(e=>e(i)):setTimeout(()=>{throw i})}function t0(e){if("function"!=typeof e)throw Error(t2(28,!1));tX.push(e)}function t1(e){if("function"!=typeof e)throw Error(t2(29,!1));let n=!1;return tX=tX.filter(t=>{let i=t===e;return n=n||i,!i}),n}function t2(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 t3(e,n,t){let i,r=`${ip(n)} '${ic(n)}' died in status ${n.status}: `;if(e instanceof Error){try{e.message=r+e.message}catch(e){}i=e}else{console.warn(t2(30,!1,n.status,ic(n)));try{i=Error(r+JSON.stringify(e))}catch(n){i=e}}return i.appOrParcelName=ic(n),n.status=t,i}let t5="NOT_LOADED",t4="LOADING_SOURCE_CODE",t6="NOT_BOOTSTRAPPED",t8="BOOTSTRAPPING",t7="NOT_MOUNTED",t9="MOUNTING",ie="MOUNTED",it="UPDATING",ii="UNMOUNTING",ir="UNLOADING",io="LOAD_ERROR",ia="SKIP_BECAUSE_BROKEN";function is(e){return e.status===ie}function il(e){try{return e.activeWhen(window.location)}catch(n){return tQ(n,e,ia),!1}}function ic(e){return e.name}function iu(e){return!!e.unmountThisParcel}function ip(e){return iu(e)?"parcel":"application"}function id(){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 ih(e,n){for(let t=0;t<e.length;t++)if(n(e[t]))return e[t];return null}function ig(e){return e&&("function"==typeof e||Array.isArray(e)&&!ih(e,e=>"function"!=typeof e))}function im(e,n){let t=e[n]||[];0===(t=Array.isArray(t)?t:[t]).length&&(t=[()=>Promise.resolve()]);let i=ip(e),r=ic(e);return function(e){return t.reduce((t,o,a)=>t.then(()=>{let t=o(e);return ib(t)?t:Promise.reject(t2(15,!1,i,r,n,a))}),Promise.resolve())}}function ib(e){return e&&"function"==typeof e.then&&"function"==typeof e.catch}let iy=[];function i_(e,n){return Promise.resolve().then(()=>e.status!==t6?e:(e.status=t8,e.bootstrap?iB(e,"bootstrap").then(t).catch(t=>{if(n)throw t3(t,e,ia);return tQ(t,e,ia),e}):Promise.resolve().then(t)));function t(){return e.status=t7,e}}function iv(e,n){return Promise.resolve().then(()=>{if(e.status!==ie)return e;return e.status=ii,Promise.all(Object.keys(e.parcels).map(n=>e.parcels[n].unmountThisParcel())).then(t,i=>t().then(()=>{let t=Error(i.message);if(n)throw t3(t,e,ia);tQ(t,e,ia)})).then(()=>e);function t(){return iB(e,"unmount").then(()=>{e.status=t7},t=>{if(n)throw t3(t,e,ia);tQ(t,e,ia)})}})}let i$=!1,iA=!1;function iw(e,n){return Promise.resolve().then(()=>e.status!==t7?e:(i$||(window.dispatchEvent(new tZ("single-spa:before-first-mount")),i$=!0),e.status=t9,iB(e,"mount").then(()=>(e.status=ie,iA||(window.dispatchEvent(new tZ("single-spa:first-mount")),iA=!0),e)).catch(t=>{return e.status=ie,iv(e,!0).then(i,i);function i(){if(n)throw t3(t,e,ia);return tQ(t,e,ia),e}})))}let ik=0,ix={parcels:{}};function iC(){return iE.apply(ix,arguments)}function iE(e,n){let t,i,r,o=this;if(!e||"object"!=typeof e&&"function"!=typeof e)throw Error(t2(2,!1));if(e.name&&"string"!=typeof e.name)throw Error(t2(3,!1,typeof e.name));let a=ik++,s=e.name||`parcel-${a}`;if("object"!=typeof n)throw Error(t2(4,!1,s,typeof n));if(!n.domElement)throw Error(t2(5,!1,s));let l="function"==typeof e,c=l?e:()=>Promise.resolve(e),u={id:a,parcels:{},status:l?t4:t6,customProps:n,parentName:ic(o),unmountThisParcel:()=>f.then(()=>{if(u.status!==ie)throw Error(t2(6,!1,s,u.status));return iv(u,!0)}).then(e=>(u.parentName&&delete o.parcels[u.id],e)).then(e=>(i(e),e)).catch(e=>{throw u.status=ia,r(e),e})};o.parcels[a]=u;let p=c();if(!p||"function"!=typeof p.then)throw Error(t2(7,!1));let d=(p=p.then(e=>{if(!e)throw Error(t2(8,!1));if(s=e.name||`parcel-${a}`,Object.prototype.hasOwnProperty.call(e,"bootstrap")&&!ig(e.bootstrap))throw Error(t2(9,!1,s));if(!ig(e.mount))throw Error(t2(10,!1,s));if(!ig(e.unmount))throw Error(t2(11,!1,s));if(e.update&&!ig(e.update))throw Error(t2(12,!1,s));let n=im(e,"bootstrap"),i=im(e,"mount"),r=im(e,"unmount");u.status=t6,u.name=s,u.bootstrap=n,u.mount=i,u.unmount=r,u.timeouts=iI(e.timeouts),e.update&&(u.update=im(e,"update"),t.update=function(e){return u.customProps=e,iS(Promise.resolve().then(()=>{if(u.status!==ie)throw Error(t2(32,!1,ic(u)));return u.status=it,iB(u,"update").then(()=>(u.status=ie,u)).catch(e=>{throw t3(e,u,ia)})}))})})).then(()=>i_(u,!0)),f=d.then(()=>iw(u,!0)),h=new Promise((e,n)=>{i=e,r=n});return t={mount:()=>iS(Promise.resolve().then(()=>{if(u.status!==t7)throw Error(t2(13,!1,s,u.status));return o.parcels[a]=u,iw(u)})),unmount:()=>iS(u.unmountThisParcel()),getStatus:()=>u.status,loadPromise:iS(p),bootstrapPromise:iS(d),mountPromise:iS(f),unmountPromise:iS(h)}}function iS(e){return e.then(()=>null)}function iD(e){let n=ic(e),t="function"==typeof e.customProps?e.customProps(n,window.location):e.customProps;("object"!=typeof t||null===t||Array.isArray(t))&&(t={},console.warn(t2(40,!1),n,t));let i=id({},t,{name:n,mountParcel:iE.bind(e),singleSpa:tY});return iu(e)&&(i.unmountSelf=e.unmountThisParcel),i}let iM={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 iz(e,n,t){if("number"!=typeof e||e<=0)throw Error(t2(16,!1));iM.bootstrap={millis:e,dieOnTimeout:n,warningMillis:t||1e3}}function iO(e,n,t){if("number"!=typeof e||e<=0)throw Error(t2(17,!1));iM.mount={millis:e,dieOnTimeout:n,warningMillis:t||1e3}}function iP(e,n,t){if("number"!=typeof e||e<=0)throw Error(t2(18,!1));iM.unmount={millis:e,dieOnTimeout:n,warningMillis:t||1e3}}function iT(e,n,t){if("number"!=typeof e||e<=0)throw Error(t2(19,!1));iM.unload={millis:e,dieOnTimeout:n,warningMillis:t||1e3}}function iB(e,n){let t=e.timeouts[n],i=t.warningMillis,r=ip(e);return new Promise((o,a)=>{let s=!1,l=!1;e[n](iD(e)).then(e=>{s=!0,o(e)}).catch(e=>{s=!0,a(e)}),setTimeout(()=>u(1),i),setTimeout(()=>u(!0),t.millis);let c=t2(31,!1,n,r,ic(e),t.millis);function u(e){s||(!0===e?(l=!0,t.dieOnTimeout?a(Error(c)):console.error(c)):!l&&(console.warn(c),e*i+i<t.millis&&setTimeout(()=>u(e+1),i)))}})}function iI(e){let n={};for(let t in iM)n[t]=id({},iM[t],e&&e[t]||{});return n}function iN(e){return Promise.resolve().then(()=>{let n,t;return e.loadPromise?e.loadPromise:e.status!==t5&&e.status!==io?e:(e.status=t4,e.loadPromise=Promise.resolve().then(()=>{let i=e.loadApp(iD(e));if(!ib(i))throw t=!0,Error(t2(33,!1,ic(e)));return i.then(t=>{let i;e.loadErrorTime=null,"object"!=typeof(n=t)&&(i=34),Object.prototype.hasOwnProperty.call(n,"bootstrap")&&!ig(n.bootstrap)&&(i=35),ig(n.mount)||(i=36),ig(n.unmount)||(i=37);let r=ip(n);if(i){let t;try{t=JSON.stringify(n)}catch(e){}return console.error(t2(i,!1,r,ic(e),t),n),tQ(void 0,e,ia),e}return n.devtools&&n.devtools.overlays&&(e.devtools.overlays=id({},e.devtools.overlays,n.devtools.overlays)),e.status=t6,e.bootstrap=im(n,"bootstrap"),e.mount=im(n,"mount"),e.unmount=im(n,"unmount"),e.unload=im(n,"unload"),e.timeouts=iI(n.timeouts),delete e.loadPromise,e})}).catch(n=>{let i;return delete e.loadPromise,t?i=ia:(i=io,e.loadErrorTime=(new Date).getTime()),tQ(n,e,i),e}))})}let ij="u">typeof window,iR={hashchange:[],popstate:[]},iF=["hashchange","popstate"];function iL(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(t2(14,!1));n=e.currentTarget.href,e.preventDefault()}let t=iK(window.location.href),i=iK(n);0===n.indexOf("#")?window.location.hash=i.hash:t.host!==i.host&&i.host?window.location.href=n:i.pathname===t.pathname&&i.search===t.search?window.location.hash=i.hash:window.history.pushState(null,null,n)}function iW(e){if(e){let n=e[0].type;iF.indexOf(n)>=0&&iR[n].forEach(n=>{try{n.apply(this,e)}catch(e){setTimeout(()=>{throw e})}})}}function iV(){rl([],arguments)}function iG(e,n){return function(){let t=window.location.href,i=e.apply(this,arguments),o=window.location.href;return r&&t===o||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)),i}}let iU=null,iH=!1;function iq(e){if(iH)throw Error(t2(43,!1));r=!e||!e.hasOwnProperty("urlRerouteOnly")||e.urlRerouteOnly,iH=!0,iU=window.history.replaceState,window.addEventListener("hashchange",iV),window.addEventListener("popstate",iV);let n=window.addEventListener,t=window.removeEventListener;window.addEventListener=function(e,t){if(!("function"==typeof t&&iF.indexOf(e)>=0)||ih(iR[e],e=>e===t))return n.apply(this,arguments);iR[e].push(t)},window.removeEventListener=function(e,n){return"function"==typeof n&&iF.indexOf(e)>=0&&(iR[e]=iR[e].filter(e=>e!==n)),t.apply(this,arguments)},window.history.pushState=iG(window.history.pushState,"pushState"),window.history.replaceState=iG(iU,"replaceState")}function iK(e){let n=document.createElement("a");return n.href=e,n}ij&&(window.singleSpaNavigate?console.warn(t2(41,!1)):window.singleSpaNavigate=iL);let iY=!1;function iJ(e=window.jQuery){if(e||window.$&&window.$.fn&&window.$.fn.jquery&&(e=window.$),e&&!iY){let n=e.fn.on,t=e.fn.off;e.fn.on=function(e,t){return iZ.call(this,n,window.addEventListener,e,t,arguments)},e.fn.off=function(e,n){return iZ.call(this,t,window.removeEventListener,e,n,arguments)},iY=!0}}function iZ(e,n,t,i,r){return"string"!=typeof t?e.apply(this,r):(t.split(/\s+/).forEach(e=>{iF.indexOf(e)>=0&&(n(e,i),t=t.replace(e,""))}),""===t.trim()?this:e.apply(this,r))}let iX={};function iQ(e){return Promise.resolve().then(()=>{let n=iX[ic(e)];if(!n)return e;if(e.status===t5)return i0(e,n),e;if(e.status===ir)return n.promise.then(()=>e);if(e.status!==t7&&e.status!==io)return e;let t=e.status===io?Promise.resolve():iB(e,"unload");return e.status=ir,t.then(()=>(i0(e,n),e)).catch(t=>(delete iX[ic(e)],delete e.bootstrap,delete e.mount,delete e.unmount,delete e.unload,tQ(t,e,ia),n.reject(t),e))})}function i0(e,n){delete iX[ic(e)],delete e.bootstrap,delete e.mount,delete e.unmount,delete e.unload,e.status=t5,n.resolve()}function i1(e,n,t,i){iX[ic(e)]={app:e,resolve:t,reject:i},Object.defineProperty(iX[ic(e)],"promise",{get:n})}let i2=[];function i3(){return i2.filter(is).map(ic)}function i5(){return i2.map(ic)}function i4(e){let n=ih(i2,n=>ic(n)===e);return n?n.status:null}let i6=!1;function i8(e,n,t,i){var r,o;let a,s,l=(a={name:null,loadApp:null,activeWhen:null,customProps:null},"object"==typeof e?(function(e){if(Array.isArray(e)||null===e)throw Error(t2(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(t2(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(t2(20,!1));let i=e=>"string"==typeof e||"function"==typeof e;if(!(i(e.activeWhen)||Array.isArray(e.activeWhen)&&e.activeWhen.every(i)))throw Error(t2(24,!1));if(!rt(e.customProps))throw Error(t2(22,!1))}(e),a.name=e.name,a.loadApp=e.app,a.activeWhen=e.activeWhen,a.customProps=e.customProps):(function(e,n,t,i){if("string"!=typeof e||0===e.length)throw Error(t2(20,!1));if(!n)throw Error(t2(23,!1));if("function"!=typeof t)throw Error(t2(24,!1));if(!rt(i))throw Error(t2(22,!1))}(e,n,t,i),a.name=e,a.loadApp=n,a.activeWhen=t,a.customProps=i),a.loadApp="function"!=typeof(r=a.loadApp)?()=>Promise.resolve(r):r,a.customProps=a.customProps||{},s=(s=Array.isArray(o=a.activeWhen)?o:[o]).map(e=>"function"==typeof e?e:ri(e)),a.activeWhen=e=>s.some(n=>n(e)),a);if(ru||i6||(i6=!0,setTimeout(()=>{ru||console.warn(t2(1,!1))},5e3)),-1!==i5().indexOf(l.name))throw Error(t2(21,!1,l.name));i2.push(id({loadErrorTime:null,status:t5,parcels:{},devtools:{overlays:{options:{},selectors:[]}}},l)),ij&&(iJ(),rl())}function i7(e=window.location){return i2.filter(n=>n.activeWhen(e)).map(ic)}function i9(e){if(0===i2.filter(n=>ic(n)===e).length)throw Error(t2(25,!1,e));return(ij?re(e,{waitForUnmount:!1}):Promise.resolve()).then(()=>{let n=i2.map(ic).indexOf(e);i2.splice(n,1)})}function re(e,n={waitForUnmount:!1}){if("string"!=typeof e)throw Error(t2(26,!1));let t=ih(i2,n=>ic(n)===e);if(!t)throw Error(t2(27,!1,e));let i=iX[ic(t)];if(n&&n.waitForUnmount){if(i)return i.promise;{let e=new Promise((n,i)=>{i1(t,()=>e,n,i)});return e}}{let e;return i?(e=i.promise,rn(t,i.resolve,i.reject)):e=new Promise((n,i)=>{i1(t,()=>e,n,i),rn(t,n,i)}),e}}function rn(e,n,t){Promise.resolve().then(()=>{if(ih(i7(),n=>n===ic(e)))return rs()}).then(()=>iv(e).then(iQ).then(()=>{n(),setTimeout(()=>{rl()})})).catch(t)}function rt(e){return!e||"function"==typeof e||"object"==typeof e&&null!==e&&!Array.isArray(e)}function ri(e,n){let t=function(e,n){let t=0,i=!1,r="^";"/"!==e[0]&&(e="/"+e);for(let n=0;n<e.length;n++){let t=e[n],r=i&&"/"===t;(!i&&":"===t||r)&&o(n)}return o(e.length),RegExp(r,"i");function o(o){let a=e.slice(t,o).replace(/[|\\{}()[\]^$+*?.]/g,"\\$&");if(r+=i?"[^/]+/?":a,o===e.length)if(i)n&&(r+="$");else{let e=n?"":".*";r="/"===r.charAt(r.length-1)?`${r}${e}$`:`${r}(/${e})?(#.*)?$`}i=!i,t=o}}(e,n);return e=>{let n=e.origin;n||(n=`${e.protocol}//${e.host}`);let i=e.href.replace(n,"").replace(e.search,"").split("?")[0];return t.test(i)}}let rr=!1,ro=[],ra=ij&&window.location.href;function rs(){return rl()}function rl(e=[],n,t=!1){let i,r,o,a,s;if(rr)return new Promise((e,t)=>{ro.push({resolve:e,reject:t,eventArguments:n})});let{appsToUnload:l,appsToUnmount:c,appsToLoad:u,appsToMount:p}=(i=[],r=[],o=[],a=[],s=(new Date).getTime(),i2.forEach(e=>{let n=e.status!==ia&&il(e);switch(e.status){case io:n&&s-e.loadErrorTime>=200&&o.push(e);break;case t5:case t4:n&&o.push(e);break;case t6:case t7:!n&&iX[ic(e)]?i.push(e):n&&a.push(e);break;case ie:n||r.push(e)}}),{appsToUnload:i,appsToUnmount:r,appsToLoad:o,appsToMount:a}),d,f=[],h=ra,g=ra=window.location.href;return ru?(rr=!0,d=l.concat(u,c,p),Promise.resolve().then(()=>($(0===d.length?"before-no-app-change":"before-app-change",v(!0)),$("before-routing-event",v(!0,{cancelNavigation:m})),Promise.all(f).then(t=>{if(t.some(e=>e))return iU.call(window.history,history.state,"",h.substring(location.origin.length)),ra=location.href,rr=!1,rl(e,n,!0);let i=l.map(iQ),r=Promise.all(c.map(iv).map(e=>e.then(iQ)).concat(i));r.then(()=>{$("before-mount-routing-event",v(!0))},e=>{throw e});let o=u.map(e=>iN(e).then(e=>rc(e,r))),a=p.filter(e=>0>u.indexOf(e)).map(e=>rc(e,r));return r.catch(e=>{throw y(),e}).then(()=>(y(),Promise.all(o.concat(a)).catch(n=>{throw e.forEach(e=>e.reject(n)),n}).then(b).then(()=>{},e=>{throw e})))})))):(d=u,Promise.resolve().then(()=>Promise.all(u.map(iN)).then(y).then(()=>[]).catch(e=>{throw y(),e}).finally(()=>{})));function m(e=!0){let n="function"==typeof(null==e?void 0:e.then)?e:Promise.resolve(e);f.push(n.catch(e=>(console.warn(Error(t2(42,!1))),console.warn(e),!1)))}function b(){let n=i3();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(rr=!1,ro.length>0){let e=ro;ro=[],rl(e)}return n}function y(){t||(e.forEach(e=>{iW(e.eventArguments)}),iW(n))}function v(e=!1,t){let i={},r={[ie]:[],[t7]:[],[t5]:[],[ia]:[]};e?(u.concat(p).forEach((e,n)=>{a(e,ie)}),l.forEach(e=>{a(e,t5)}),c.forEach(e=>{a(e,t7)})):d.forEach(e=>{a(e)});let o={detail:{newAppStatuses:i,appsByNewStatus:r,totalAppChanges:d.length,originalEvent:null==n?void 0:n[0],oldUrl:h,newUrl:g}};return t&&id(o.detail,t),o;function a(e,n){let t=ic(e);n=n||i4(t),i[t]=n,(r[n]=r[n]||[]).push(t)}}function $(e,n){t||window.dispatchEvent(new tZ(`single-spa:${e}`,n))}}function rc(e,n){return il(e)?i_(e).then(e=>n.then(()=>il(e)?iw(e):e)):n.then(()=>e)}let ru=!1;function rp(e){ru=!0,ij&&(iq(e),rl())}function rd(e,n){let t=window.getOpenmrsSpaBase().replace(/\/$/,"");return rf(e,{openmrsBase:window.openmrsBase,openmrsSpaBase:t,...n}).replace(/^\/\//,"/")}function rf(e,n){return Object.keys(n).reduce((e,t)=>e.split("${"+t+"}").join(n[t]),e)}function rh({to:e,templateParams:n}){let t=window.getOpenmrsSpaBase().replace(/\/$/,""),i=rd(e,n).replace(window.location.origin,"");i.startsWith(t)?iL(i):window.location.assign(i)}ij&&window.__SINGLE_SPA_DEVTOOLS__&&(window.__SINGLE_SPA_DEVTOOLS__.exposedMethods={getRawAppData:function(){return[...i2]},reroute:rl,NOT_LOADED:t5,toLoadPromise:iN,toBootstrapPromise:i_,unregisterApplication:i9,getProfilerData:function(){return iy}});let rg="openmrs:history";function rm(e){let n=JSON.parse(sessionStorage.getItem(rg)??"[]")||[];n.push(e),n.length>50&&(n=n.slice(-50)),sessionStorage.setItem(rg,JSON.stringify(n))}function rb(){0===JSON.parse(sessionStorage.getItem(rg)??"[]").length&&document.referrer&&rm(document.referrer),window.addEventListener("single-spa:routing-event",e=>{let n=ry();e.detail.originalEvent?.singleSpaTrigger=="replaceState"?(n[n.length-1]=window.location.href,sessionStorage.setItem(rg,JSON.stringify(n))):!e.detail.originalEvent?.singleSpa&&n.includes(window.location.href)?r_({toUrl:window.location.href}):n[n.length-1]!==window.location.href&&rm(window.location.href)})}function ry(){return JSON.parse(sessionStorage.getItem(rg)??"[]")}function r_({toUrl:e}){let n=ry(),t=n.lastIndexOf(e);if(-1!=t){let e=n.slice(0,t+1);rh({to:n[t]}),sessionStorage.setItem(rg,JSON.stringify(e))}else throw Error(`URL ${e} not found in history; cannot go back to it.`)}function rv(){sessionStorage.removeItem(rg)}let r$="${openmrsSpaBase}/login",rA={redirectAuthFailure:{enabled:{_type:nB.Boolean,_default:!0,_description:"Whether to redirect logged-out users to `redirectAuthFailure.url`"},url:{_type:nB.String,_default:r$,_validators:[tF.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:nB.Array,_default:[401],_elements:{_type:nB.Number,_validators:[tF.inRange(100,600)]},_description:"The HTTP error codes for which users will be redirected"},resolvePromise:{_type:nB.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:nB.Boolean,_default:!0,_description:"Whether openmrsFetch should support redirects returned from the backend"}};function rw(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}let rk="/ws/rest/v1",rx="/ws/fhir2/R4",rC=`${rk}/session`;function rE(e){return e&&e.startsWith("http")?e:("/"!==e[0]&&(e="/"+e),window.openmrsBase+e)}function rS(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=rE(e);if(n.headers||(n.headers={}),ed(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(rk)&&void 0===n.headers["Disable-WWW-Authenticate"]&&(n.headers["Disable-WWW-Authenticate"]="true"),e.startsWith(rx)){let e=new URL(t,window.location.toString());e.searchParams.has("_summary")||(e.searchParams.set("_summary","data"),t=e.toString())}let i=Error();return window.fetch(t,n).then(async e=>{let{redirectAuthFailure:n,followRedirects:r}=await tf("@openmrs/esm-api");if(e.ok){let n=e.headers.get("location");return(r&&n&&(t===rE(rC)||204===e.status)&&rh({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===rE(rC)&&403===e.status||n.enabled&&n.errors.includes(e.status)?(rv(),rh({to:n.url||e.headers.get("location")||r$}),n.resolvePromise?Promise.resolve():new Promise(()=>{})):e.clone().text().then(n=>{let r=n;try{r=JSON.parse(n)}catch(e){}throw new rM(t,e,r,i)},n=>{throw new rM(t,e,null,i)})})}function rD(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 er.Observable(i=>{let r=!1;return rS(e,n).then(e=>{r=!0,i.next(e),i.complete()},e=>{r=!0,i.error(e)}),()=>{r||t.abort()}})}class rM extends Error{constructor(e,n,t,i){super(),rw(this,"response",void 0),rw(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`,i.message=this.message,this.responseBody=t,this.response=n,this.stack=`Stacktrace for outgoing request:
|
|
13
13
|
${i.stack}
|
|
14
14
|
Stacktrace for incoming response:
|
|
15
|
-
${this.stack}`}}let rz=H("session",{loaded:!1,session:null}),rO=0;function rP(e={includeAuthStatus:!0}){return(rO<Date.now()-6e4||!rz.getState().loaded)&&rI(),new er.Observable(n=>{let t=t=>{t.loaded&&(e.includeAuthStatus?n.next(t.session):n.next(t.session?.user))};return t(rz.getState()),rz.subscribe(t)})}function rT(){return(rO<Date.now()-6e4||!rz.getState().loaded)&&rI(),rz}function rB(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 rI(e,n){rO=Date.now();let t={};return e&&n&&(t.Authorization=`Basic ${window.btoa(`${e}:${n}`)}`),rV(rS(rC,{headers:t}))}function rN(){rz.setState({loaded:!0,session:{authenticated:!1,sessionId:""}})}function rj(e,n){var t,i;if(void 0===n)return!e;if(!e)return!0;return t=e,i=n,("string"==typeof t?!Z(i.privileges.find(e=>t===e.display)):Array.isArray(t)?t.every(e=>!Z(i.privileges.find(n=>e===n.display))):(Z(t)||console.error(`Could not understand privileges "${t}"`),!0))||!Z(n.roles.find(e=>"System Developer"===e.display))}function rR(){let e,n;return new Promise(t=>{let i=i=>{i.loaded&&i.session.user&&(e=i.session.user,t(i.session.user),n&&n())};i(rz.getState()),e||(n=rz.subscribe(i))})}function rF(){return new Promise((e,n)=>{rP().subscribe(n=>{e(n.sessionLocation)},n).unsubscribe()})}async function rL(e,n){return rV(rS(rC,{method:"POST",body:{sessionLocation:e},headers:{"Content-Type":"application/json"},signal:n.signal}))}async function rW(e,n,t){return t||(t=new AbortController),await rS(`${rk}/user/${e}`,{method:"POST",body:{userProperties:n},headers:{"Content-Type":"application/json"},signal:t.signal}),rI()}function rV(e){return new Promise((n,t)=>{e.then(e=>{let i;"object"==typeof e?.data?(i={loaded:!0,session:e.data},rz.setState(i),n(i)):(i={loaded:!1,session:null},rz.setState(i),t(i))}).catch(e=>{I(`Failed to fetch new session information: ${e}`);let n={loaded:!1,session:null};rz.setState(n),t(n)})})}function rG(){return"development"===window.spaEnv||"true"===localStorage.getItem("openmrs:devtools")}rz.subscribe(e=>{e.loaded&&e.session&&rB(e.session)});let rU={"webservices.rest":"2.24.0",fhir2:"1.0.0-SNAPSHOT"};function rH(){ta("@openmrs/esm-api",rA),rI()}let rq={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"},rK=e=>"string"==typeof e,rY=()=>{let e,n,t=new Promise((t,i)=>{e=t,n=i});return t.resolve=e,t.reject=n,t},rJ=e=>null==e?"":""+e,rZ=/###/g,rX=e=>e&&e.indexOf("###")>-1?e.replace(rZ,"."):e,rQ=e=>!e||rK(e),r0=(e,n,t)=>{let i=rK(n)?n.split("."):n,r=0;for(;r<i.length-1;){if(rQ(e))return{};let n=rX(i[r]);!e[n]&&t&&(e[n]=new t),e=Object.prototype.hasOwnProperty.call(e,n)?e[n]:{},++r}return rQ(e)?{}:{obj:e,k:rX(i[r])}},r1=(e,n,t)=>{let{obj:i,k:r}=r0(e,n,Object);if(void 0!==i||1===n.length){i[r]=t;return}let o=n[n.length-1],a=n.slice(0,n.length-1),s=r0(e,a,Object);for(;void 0===s.obj&&a.length;)o=`${a[a.length-1]}.${o}`,s=r0(e,a=a.slice(0,a.length-1),Object),s?.obj&&void 0!==s.obj[`${s.k}.${o}`]&&(s.obj=void 0);s.obj[`${s.k}.${o}`]=t},r2=(e,n)=>{let{obj:t,k:i}=r0(e,n);if(t&&Object.prototype.hasOwnProperty.call(t,i))return t[i]},r3=(e,n,t)=>{for(let i in n)"__proto__"!==i&&"constructor"!==i&&(i in e?rK(e[i])||e[i]instanceof String||rK(n[i])||n[i]instanceof String?t&&(e[i]=n[i]):r3(e[i],n[i],t):e[i]=n[i]);return e};var r5={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};let r4=e=>rK(e)?e.replace(/[&<>"'\/]/g,e=>r5[e]):e,r6=[" ",",","?","!",";"],r8=new class{constructor(e){this.capacity=e,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(e){let n=this.regExpMap.get(e);if(void 0!==n)return n;let t=new RegExp(e);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(e,t),this.regExpQueue.push(e),t}}(20),r7=(e,n,t=".")=>{if(!e)return;if(e[n]){if(!Object.prototype.hasOwnProperty.call(e,n))return;return e[n]}let i=n.split(t),r=e;for(let e=0;e<i.length;){let n;if(!r||"object"!=typeof r)return;let o="";for(let a=e;a<i.length;++a)if(a!==e&&(o+=t),o+=i[a],void 0!==(n=r[o])){if(["string","number","boolean"].indexOf(typeof n)>-1&&a<i.length-1)continue;e+=a-e+1;break}r=n}return r},r9=e=>e?.replace("_","-"),oe={type:"logger",log(e){this.output("log",e)},warn(e){this.output("warn",e)},error(e){this.output("error",e)},output(e,n){console?.[e]?.apply?.(console,n)}};class on{constructor(e,n={}){this.init(e,n)}init(e,n={}){this.prefix=n.prefix||"i18next:",this.logger=e||oe,this.options=n,this.debug=n.debug}log(...e){return this.forward(e,"log","",!0)}warn(...e){return this.forward(e,"warn","",!0)}error(...e){return this.forward(e,"error","")}deprecate(...e){return this.forward(e,"warn","WARNING DEPRECATED: ",!0)}forward(e,n,t,i){return i&&!this.debug?null:(rK(e[0])&&(e[0]=`${t}${this.prefix} ${e[0]}`),this.logger[n](e))}create(e){return new on(this.logger,{...{prefix:`${this.prefix}:${e}:`},...this.options})}clone(e){return(e=e||this.options).prefix=e.prefix||this.prefix,new on(this.logger,e)}}var ot=new on;class oi{constructor(){this.observers={}}on(e,n){return e.split(" ").forEach(e=>{this.observers[e]||(this.observers[e]=new Map);let t=this.observers[e].get(n)||0;this.observers[e].set(n,t+1)}),this}off(e,n){if(this.observers[e]){if(!n)return void delete this.observers[e];this.observers[e].delete(n)}}emit(e,...n){this.observers[e]&&Array.from(this.observers[e].entries()).forEach(([e,t])=>{for(let i=0;i<t;i++)e(...n)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(([t,i])=>{for(let r=0;r<i;r++)t.apply(t,[e,...n])})}}class or extends oi{constructor(e,n={ns:["translation"],defaultNS:"translation"}){super(),this.data=e||{},this.options=n,void 0===this.options.keySeparator&&(this.options.keySeparator="."),void 0===this.options.ignoreJSONStructure&&(this.options.ignoreJSONStructure=!0)}addNamespaces(e){0>this.options.ns.indexOf(e)&&this.options.ns.push(e)}removeNamespaces(e){let n=this.options.ns.indexOf(e);n>-1&&this.options.ns.splice(n,1)}getResource(e,n,t,i={}){let r,o=void 0!==i.keySeparator?i.keySeparator:this.options.keySeparator,a=void 0!==i.ignoreJSONStructure?i.ignoreJSONStructure:this.options.ignoreJSONStructure;e.indexOf(".")>-1?r=e.split("."):(r=[e,n],t&&(Array.isArray(t)?r.push(...t):rK(t)&&o?r.push(...t.split(o)):r.push(t)));let s=r2(this.data,r);return(!s&&!n&&!t&&e.indexOf(".")>-1&&(e=r[0],n=r[1],t=r.slice(2).join(".")),!s&&a&&rK(t))?r7(this.data?.[e]?.[n],t,o):s}addResource(e,n,t,i,r={silent:!1}){let o=void 0!==r.keySeparator?r.keySeparator:this.options.keySeparator,a=[e,n];t&&(a=a.concat(o?t.split(o):t)),e.indexOf(".")>-1&&(a=e.split("."),i=n,n=a[1]),this.addNamespaces(n),r1(this.data,a,i),r.silent||this.emit("added",e,n,t,i)}addResources(e,n,t,i={silent:!1}){for(let i in t)(rK(t[i])||Array.isArray(t[i]))&&this.addResource(e,n,i,t[i],{silent:!0});i.silent||this.emit("added",e,n,t)}addResourceBundle(e,n,t,i,r,o={silent:!1,skipCopy:!1}){let a=[e,n];e.indexOf(".")>-1&&(a=e.split("."),i=t,t=n,n=a[1]),this.addNamespaces(n);let s=r2(this.data,a)||{};o.skipCopy||(t=JSON.parse(JSON.stringify(t))),i?r3(s,t,r):s={...s,...t},r1(this.data,a,s),o.silent||this.emit("added",e,n,t)}removeResourceBundle(e,n){this.hasResourceBundle(e,n)&&delete this.data[e][n],this.removeNamespaces(n),this.emit("removed",e,n)}hasResourceBundle(e,n){return void 0!==this.getResource(e,n)}getResourceBundle(e,n){return n||(n=this.options.defaultNS),this.getResource(e,n)}getDataByLanguage(e){return this.data[e]}hasLanguageSomeTranslations(e){let n=this.getDataByLanguage(e);return!!(n&&Object.keys(n)||[]).find(e=>n[e]&&Object.keys(n[e]).length>0)}toJSON(){return this.data}}var oo={processors:{},addPostProcessor(e){this.processors[e.name]=e},handle(e,n,t,i,r){return e.forEach(e=>{n=this.processors[e]?.process(n,t,i,r)??n}),n}};let oa=Symbol("i18next/PATH_KEY");function os(e,n){let t,i,r,{[oa]:o}=e((i=[],(r=Object.create(null)).get=(e,n)=>(t?.revoke?.(),n===oa)?i:(i.push(n),(t=Proxy.revocable(e,r)).proxy),Proxy.revocable(Object.create(null),r).proxy));return o.join(n?.keySeparator??".")}let ol={},oc=e=>!rK(e)&&"boolean"!=typeof e&&"number"!=typeof e;class ou extends oi{constructor(e,n={}){super(),((e,n,t)=>{e.forEach(e=>{n[e]&&(t[e]=n[e])})})(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=n,void 0===this.options.keySeparator&&(this.options.keySeparator="."),this.logger=ot.create("translator")}changeLanguage(e){e&&(this.language=e)}exists(e,n={interpolation:{}}){let t={...n};if(null==e)return!1;let i=this.resolve(e,t);if(i?.res===void 0)return!1;let r=oc(i.res);return!1!==t.returnObjects||!r}extractFromKey(e,n){let t=void 0!==n.nsSeparator?n.nsSeparator:this.options.nsSeparator;void 0===t&&(t=":");let i=void 0!==n.keySeparator?n.keySeparator:this.options.keySeparator,r=n.ns||this.options.defaultNS||[],o=t&&e.indexOf(t)>-1,a=!this.options.userDefinedKeySeparator&&!n.keySeparator&&!this.options.userDefinedNsSeparator&&!n.nsSeparator&&!((e,n,t)=>{n=n||"",t=t||"";let i=r6.filter(e=>0>n.indexOf(e)&&0>t.indexOf(e));if(0===i.length)return!0;let r=r8.getRegExp(`(${i.map(e=>"?"===e?"\\?":e).join("|")})`),o=!r.test(e);if(!o){let n=e.indexOf(t);n>0&&!r.test(e.substring(0,n))&&(o=!0)}return o})(e,t,i);if(o&&!a){let n=e.match(this.interpolator.nestingRegexp);if(n&&n.length>0)return{key:e,namespaces:rK(r)?[r]:r};let o=e.split(t);(t!==i||t===i&&this.options.ns.indexOf(o[0])>-1)&&(r=o.shift()),e=o.join(i)}return{key:e,namespaces:rK(r)?[r]:r}}translate(e,n,t){let i="object"==typeof n?{...n}:n;if("object"!=typeof i&&this.options.overloadTranslationOptionHandler&&(i=this.options.overloadTranslationOptionHandler(arguments)),"object"==typeof i&&(i={...i}),i||(i={}),null==e)return"";"function"==typeof e&&(e=os(e,{...this.options,...i})),Array.isArray(e)||(e=[String(e)]);let r=void 0!==i.returnDetails?i.returnDetails:this.options.returnDetails,o=void 0!==i.keySeparator?i.keySeparator:this.options.keySeparator,{key:a,namespaces:s}=this.extractFromKey(e[e.length-1],i),l=s[s.length-1],c=void 0!==i.nsSeparator?i.nsSeparator:this.options.nsSeparator;void 0===c&&(c=":");let u=i.lng||this.language,p=i.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(u?.toLowerCase()==="cimode")return p?r?{res:`${l}${c}${a}`,usedKey:a,exactUsedKey:a,usedLng:u,usedNS:l,usedParams:this.getUsedParamsDetails(i)}:`${l}${c}${a}`:r?{res:a,usedKey:a,exactUsedKey:a,usedLng:u,usedNS:l,usedParams:this.getUsedParamsDetails(i)}:a;let d=this.resolve(e,i),f=d?.res,h=d?.usedKey||a,g=d?.exactUsedKey||a,m=void 0!==i.joinArrays?i.joinArrays:this.options.joinArrays,b=!this.i18nFormat||this.i18nFormat.handleAsObject,y=void 0!==i.count&&!rK(i.count),v=ou.hasDefaultValue(i),$=y?this.pluralResolver.getSuffix(u,i.count,i):"",A=i.ordinal&&y?this.pluralResolver.getSuffix(u,i.count,{ordinal:!1}):"",w=y&&!i.ordinal&&0===i.count,k=w&&i[`defaultValue${this.options.pluralSeparator}zero`]||i[`defaultValue${$}`]||i[`defaultValue${A}`]||i.defaultValue,x=f;b&&!f&&v&&(x=k);let C=oc(x),E=Object.prototype.toString.apply(x);if(b&&x&&C&&0>["[object Number]","[object Function]","[object RegExp]"].indexOf(E)&&!(rK(m)&&Array.isArray(x))){if(!i.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");let e=this.options.returnedObjectHandler?this.options.returnedObjectHandler(h,x,{...i,ns:s}):`key '${a} (${this.language})' returned an object instead of string.`;return r?(d.res=e,d.usedParams=this.getUsedParamsDetails(i),d):e}if(o){let e=Array.isArray(x),n=e?[]:{},t=e?g:h;for(let e in x)if(Object.prototype.hasOwnProperty.call(x,e)){let r=`${t}${o}${e}`;v&&!f?n[e]=this.translate(r,{...i,defaultValue:oc(k)?k[e]:void 0,...{joinArrays:!1,ns:s}}):n[e]=this.translate(r,{...i,joinArrays:!1,ns:s}),n[e]===r&&(n[e]=x[e])}f=n}}else if(b&&rK(m)&&Array.isArray(f))(f=f.join(m))&&(f=this.extendTranslation(f,e,i,t));else{let n=!1,r=!1;!this.isValidLookup(f)&&v&&(n=!0,f=k),this.isValidLookup(f)||(r=!0,f=a);let s=(i.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&r?void 0:f,p=v&&k!==f&&this.options.updateMissing;if(r||n||p){if(this.logger.log(p?"updateKey":"missingKey",u,l,a,p?k:f),o){let e=this.resolve(a,{...i,keySeparator:!1});e&&e.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}let e=[],n=this.languageUtils.getFallbackCodes(this.options.fallbackLng,i.lng||this.language);if("fallback"===this.options.saveMissingTo&&n&&n[0])for(let t=0;t<n.length;t++)e.push(n[t]);else"all"===this.options.saveMissingTo?e=this.languageUtils.toResolveHierarchy(i.lng||this.language):e.push(i.lng||this.language);let t=(e,n,t)=>{let r=v&&t!==f?t:s;this.options.missingKeyHandler?this.options.missingKeyHandler(e,l,n,r,p,i):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(e,l,n,r,p,i),this.emit("missingKey",e,l,n,f)};this.options.saveMissing&&(this.options.saveMissingPlurals&&y?e.forEach(e=>{let n=this.pluralResolver.getSuffixes(e,i);w&&i[`defaultValue${this.options.pluralSeparator}zero`]&&0>n.indexOf(`${this.options.pluralSeparator}zero`)&&n.push(`${this.options.pluralSeparator}zero`),n.forEach(n=>{t([e],a+n,i[`defaultValue${n}`]||k)})}):t(e,a,k))}f=this.extendTranslation(f,e,i,d,t),r&&f===a&&this.options.appendNamespaceToMissingKey&&(f=`${l}${c}${a}`),(r||n)&&this.options.parseMissingKeyHandler&&(f=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${l}${c}${a}`:a,n?f:void 0,i))}return r?(d.res=f,d.usedParams=this.getUsedParamsDetails(i),d):f}extendTranslation(e,n,t,i,r){if(this.i18nFormat?.parse)e=this.i18nFormat.parse(e,{...this.options.interpolation.defaultVariables,...t},t.lng||this.language||i.usedLng,i.usedNS,i.usedKey,{resolved:i});else if(!t.skipInterpolation){let o;t.interpolation&&this.interpolator.init({...t,...{interpolation:{...this.options.interpolation,...t.interpolation}}});let a=rK(e)&&(t?.interpolation?.skipOnVariables!==void 0?t.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);if(a){let n=e.match(this.interpolator.nestingRegexp);o=n&&n.length}let s=t.replace&&!rK(t.replace)?t.replace:t;if(this.options.interpolation.defaultVariables&&(s={...this.options.interpolation.defaultVariables,...s}),e=this.interpolator.interpolate(e,s,t.lng||this.language||i.usedLng,t),a){let n=e.match(this.interpolator.nestingRegexp);o<(n&&n.length)&&(t.nest=!1)}!t.lng&&i&&i.res&&(t.lng=this.language||i.usedLng),!1!==t.nest&&(e=this.interpolator.nest(e,(...e)=>r?.[0]!==e[0]||t.context?this.translate(...e,n):(this.logger.warn(`It seems you are nesting recursively key: ${e[0]} in key: ${n[0]}`),null),t)),t.interpolation&&this.interpolator.reset()}let o=t.postProcess||this.options.postProcess,a=rK(o)?[o]:o;return null!=e&&a?.length&&!1!==t.applyPostProcessor&&(e=oo.handle(a,e,n,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...i,usedParams:this.getUsedParamsDetails(t)},...t}:t,this)),e}resolve(e,n={}){let t,i,r,o,a;return rK(e)&&(e=[e]),e.forEach(e=>{if(this.isValidLookup(t))return;let s=this.extractFromKey(e,n),l=s.key;i=l;let c=s.namespaces;this.options.fallbackNS&&(c=c.concat(this.options.fallbackNS));let u=void 0!==n.count&&!rK(n.count),p=u&&!n.ordinal&&0===n.count,d=void 0!==n.context&&(rK(n.context)||"number"==typeof n.context)&&""!==n.context,f=n.lngs?n.lngs:this.languageUtils.toResolveHierarchy(n.lng||this.language,n.fallbackLng);c.forEach(e=>{this.isValidLookup(t)||(a=e,!ol[`${f[0]}-${e}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(a)&&(ol[`${f[0]}-${e}`]=!0,this.logger.warn(`key "${i}" for languages "${f.join(", ")}" won't get resolved as namespace "${a}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),f.forEach(i=>{let a;if(this.isValidLookup(t))return;o=i;let s=[l];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(s,l,i,e,n);else{let e;u&&(e=this.pluralResolver.getSuffix(i,n.count,n));let t=`${this.options.pluralSeparator}zero`,r=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(u&&(n.ordinal&&0===e.indexOf(r)&&s.push(l+e.replace(r,this.options.pluralSeparator)),s.push(l+e),p&&s.push(l+t)),d){let i=`${l}${this.options.contextSeparator||"_"}${n.context}`;s.push(i),u&&(n.ordinal&&0===e.indexOf(r)&&s.push(i+e.replace(r,this.options.pluralSeparator)),s.push(i+e),p&&s.push(i+t))}}for(;a=s.pop();)this.isValidLookup(t)||(r=a,t=this.getResource(i,e,a,n))}))})}),{res:t,usedKey:i,exactUsedKey:r,usedLng:o,usedNS:a}}isValidLookup(e){return void 0!==e&&!(!this.options.returnNull&&null===e)&&!(!this.options.returnEmptyString&&""===e)}getResource(e,n,t,i={}){return this.i18nFormat?.getResource?this.i18nFormat.getResource(e,n,t,i):this.resourceStore.getResource(e,n,t,i)}getUsedParamsDetails(e={}){let n=e.replace&&!rK(e.replace),t=n?e.replace:e;if(n&&void 0!==e.count&&(t.count=e.count),this.options.interpolation.defaultVariables&&(t={...this.options.interpolation.defaultVariables,...t}),!n)for(let e of(t={...t},["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"]))delete t[e];return t}static hasDefaultValue(e){let n="defaultValue";for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&n===t.substring(0,n.length)&&void 0!==e[t])return!0;return!1}}class op{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=ot.create("languageUtils")}getScriptPartFromCode(e){if(!(e=r9(e))||0>e.indexOf("-"))return null;let n=e.split("-");return 2===n.length||(n.pop(),"x"===n[n.length-1].toLowerCase())?null:this.formatLanguageCode(n.join("-"))}getLanguagePartFromCode(e){if(!(e=r9(e))||0>e.indexOf("-"))return e;let n=e.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(e){if(rK(e)&&e.indexOf("-")>-1){let n;try{n=Intl.getCanonicalLocales(e)[0]}catch(e){}return(n&&this.options.lowerCaseLng&&(n=n.toLowerCase()),n)?n:this.options.lowerCaseLng?e.toLowerCase():e}return this.options.cleanCode||this.options.lowerCaseLng?e.toLowerCase():e}isSupportedCode(e){return("languageOnly"===this.options.load||this.options.nonExplicitSupportedLngs)&&(e=this.getLanguagePartFromCode(e)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(e)>-1}getBestMatchFromCodes(e){let n;return e?(e.forEach(e=>{if(n)return;let t=this.formatLanguageCode(e);(!this.options.supportedLngs||this.isSupportedCode(t))&&(n=t)}),!n&&this.options.supportedLngs&&e.forEach(e=>{if(n)return;let t=this.getScriptPartFromCode(e);if(this.isSupportedCode(t))return n=t;let i=this.getLanguagePartFromCode(e);if(this.isSupportedCode(i))return n=i;n=this.options.supportedLngs.find(e=>{if(e===i||!(0>e.indexOf("-")&&0>i.indexOf("-"))&&(e.indexOf("-")>0&&0>i.indexOf("-")&&e.substring(0,e.indexOf("-"))===i||0===e.indexOf(i)&&i.length>1))return e})}),n||(n=this.getFallbackCodes(this.options.fallbackLng)[0]),n):null}getFallbackCodes(e,n){if(!e)return[];if("function"==typeof e&&(e=e(n)),rK(e)&&(e=[e]),Array.isArray(e))return e;if(!n)return e.default||[];let t=e[n];return t||(t=e[this.getScriptPartFromCode(n)]),t||(t=e[this.formatLanguageCode(n)]),t||(t=e[this.getLanguagePartFromCode(n)]),t||(t=e.default),t||[]}toResolveHierarchy(e,n){let t=this.getFallbackCodes((!1===n?[]:n)||this.options.fallbackLng||[],e),i=[],r=e=>{e&&(this.isSupportedCode(e)?i.push(e):this.logger.warn(`rejecting language code not found in supportedLngs: ${e}`))};return rK(e)&&(e.indexOf("-")>-1||e.indexOf("_")>-1)?("languageOnly"!==this.options.load&&r(this.formatLanguageCode(e)),"languageOnly"!==this.options.load&&"currentOnly"!==this.options.load&&r(this.getScriptPartFromCode(e)),"currentOnly"!==this.options.load&&r(this.getLanguagePartFromCode(e))):rK(e)&&r(this.formatLanguageCode(e)),t.forEach(e=>{0>i.indexOf(e)&&r(this.formatLanguageCode(e))}),i}}let od={zero:0,one:1,two:2,few:3,many:4,other:5},of={select:e=>1===e?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class oh{constructor(e,n={}){this.languageUtils=e,this.options=n,this.logger=ot.create("pluralResolver"),this.pluralRulesCache={}}addRule(e,n){this.rules[e]=n}clearCache(){this.pluralRulesCache={}}getRule(e,n={}){let t,i=r9("dev"===e?"en":e),r=n.ordinal?"ordinal":"cardinal",o=JSON.stringify({cleanedCode:i,type:r});if(o in this.pluralRulesCache)return this.pluralRulesCache[o];try{t=new Intl.PluralRules(i,{type:r})}catch(r){if(!Intl)return this.logger.error("No Intl support, please use an Intl polyfill!"),of;if(!e.match(/-|_/))return of;let i=this.languageUtils.getLanguagePartFromCode(e);t=this.getRule(i,n)}return this.pluralRulesCache[o]=t,t}needsPlural(e,n={}){let t=this.getRule(e,n);return t||(t=this.getRule("dev",n)),t?.resolvedOptions().pluralCategories.length>1}getPluralFormsOfKey(e,n,t={}){return this.getSuffixes(e,t).map(e=>`${n}${e}`)}getSuffixes(e,n={}){let t=this.getRule(e,n);return(t||(t=this.getRule("dev",n)),t)?t.resolvedOptions().pluralCategories.sort((e,n)=>od[e]-od[n]).map(e=>`${this.options.prepend}${n.ordinal?`ordinal${this.options.prepend}`:""}${e}`):[]}getSuffix(e,n,t={}){let i=this.getRule(e,t);return i?`${this.options.prepend}${t.ordinal?`ordinal${this.options.prepend}`:""}${i.select(n)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix("dev",n,t))}}let og=(e,n,t,i=".",r=!0)=>{let o,a=void 0!==(o=r2(e,t))?o:r2(n,t);return!a&&r&&rK(t)&&void 0===(a=r7(e,t,i))&&(a=r7(n,t,i)),a};class om{constructor(e={}){this.logger=ot.create("interpolator"),this.options=e,this.format=e?.interpolation?.format||(e=>e),this.init(e)}init(e={}){e.interpolation||(e.interpolation={escapeValue:!0});let{escape:n,escapeValue:t,useRawValueToEscape:i,prefix:r,prefixEscaped:o,suffix:a,suffixEscaped:s,formatSeparator:l,unescapeSuffix:c,unescapePrefix:u,nestingPrefix:p,nestingPrefixEscaped:d,nestingSuffix:f,nestingSuffixEscaped:h,nestingOptionsSeparator:g,maxReplaces:m,alwaysFormat:b}=e.interpolation;this.escape=void 0!==n?n:r4,this.escapeValue=void 0===t||t,this.useRawValueToEscape=void 0!==i&&i,this.prefix=r?r.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"):o||"{{",this.suffix=a?a.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"):s||"}}",this.formatSeparator=l||",",this.unescapePrefix=c?"":u||"-",this.unescapeSuffix=this.unescapePrefix?"":c||"",this.nestingPrefix=p?p.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"):d||"$t(".replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),this.nestingSuffix=f?f.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"):h||")".replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),this.nestingOptionsSeparator=g||",",this.maxReplaces=m||1e3,this.alwaysFormat=void 0!==b&&b,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){let e=(e,n)=>e?.source===n?(e.lastIndex=0,e):RegExp(n,"g");this.regexp=e(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=e(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=e(this.nestingRegexp,`${this.nestingPrefix}((?:[^()"']+|"[^"]*"|'[^']*'|\\((?:[^()]|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`)}interpolate(e,n,t,i){let r,o,a,s=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},l=e=>{if(0>e.indexOf(this.formatSeparator)){let r=og(n,s,e,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(r,void 0,t,{...i,...n,interpolationkey:e}):r}let r=e.split(this.formatSeparator),o=r.shift().trim(),a=r.join(this.formatSeparator).trim();return this.format(og(n,s,o,this.options.keySeparator,this.options.ignoreJSONStructure),a,t,{...i,...n,interpolationkey:o})};this.resetRegExp();let c=i?.missingInterpolationHandler||this.options.missingInterpolationHandler,u=i?.interpolation?.skipOnVariables!==void 0?i.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:e=>e.replace(/\$/g,"$$$$")},{regex:this.regexp,safeValue:e=>this.escapeValue?this.escape(e).replace(/\$/g,"$$$$"):e.replace(/\$/g,"$$$$")}].forEach(n=>{for(a=0;r=n.regex.exec(e);){let t=r[1].trim();if(void 0===(o=l(t)))if("function"==typeof c){let n=c(e,r,i);o=rK(n)?n:""}else if(i&&Object.prototype.hasOwnProperty.call(i,t))o="";else if(u){o=r[0];continue}else this.logger.warn(`missed to pass in variable ${t} for interpolating ${e}`),o="";else rK(o)||this.useRawValueToEscape||(o=rJ(o));let s=n.safeValue(o);if(e=e.replace(r[0],s),u?(n.regex.lastIndex+=o.length,n.regex.lastIndex-=r[0].length):n.regex.lastIndex=0,++a>=this.maxReplaces)break}}),e}nest(e,n,t={}){let i,r,o,a=(e,n)=>{let t=this.nestingOptionsSeparator;if(0>e.indexOf(t))return e;let i=e.split(RegExp(`${t}[ ]*{`)),r=`{${i[1]}`;e=i[0];let a=(r=this.interpolate(r,o)).match(/'/g),s=r.match(/"/g);((a?.length??0)%2!=0||s)&&s.length%2==0||(r=r.replace(/'/g,'"'));try{o=JSON.parse(r),n&&(o={...n,...o})}catch(n){return this.logger.warn(`failed parsing options string in nesting for key ${e}`,n),`${e}${t}${r}`}return o.defaultValue&&o.defaultValue.indexOf(this.prefix)>-1&&delete o.defaultValue,e};for(;i=this.nestingRegexp.exec(e);){let s=[];(o=(o={...t}).replace&&!rK(o.replace)?o.replace:o).applyPostProcessor=!1,delete o.defaultValue;let l=/{.*}/.test(i[1])?i[1].lastIndexOf("}")+1:i[1].indexOf(this.formatSeparator);if(-1!==l&&(s=i[1].slice(l).split(this.formatSeparator).map(e=>e.trim()).filter(Boolean),i[1]=i[1].slice(0,l)),(r=n(a.call(this,i[1].trim(),o),o))&&i[0]===e&&!rK(r))return r;rK(r)||(r=rJ(r)),r||(this.logger.warn(`missed to resolve ${i[1]} for nesting ${e}`),r=""),s.length&&(r=s.reduce((e,n)=>this.format(e,n,t.lng,{...t,interpolationkey:i[1].trim()}),r.trim())),e=e.replace(i[0],r),this.regexp.lastIndex=0}return e}}let ob=e=>{let n={};return(t,i,r)=>{let o=r;r&&r.interpolationkey&&r.formatParams&&r.formatParams[r.interpolationkey]&&r[r.interpolationkey]&&(o={...o,[r.interpolationkey]:void 0});let a=i+JSON.stringify(o),s=n[a];return s||(s=e(r9(i),r),n[a]=s),s(t)}},oy=e=>(n,t,i)=>e(r9(t),i)(n);class o_{constructor(e={}){this.logger=ot.create("formatter"),this.options=e,this.init(e)}init(e,n={interpolation:{}}){this.formatSeparator=n.interpolation.formatSeparator||",";let t=n.cacheInBuiltFormats?ob:oy;this.formats={number:t((e,n)=>{let t=new Intl.NumberFormat(e,{...n});return e=>t.format(e)}),currency:t((e,n)=>{let t=new Intl.NumberFormat(e,{...n,style:"currency"});return e=>t.format(e)}),datetime:t((e,n)=>{let t=new Intl.DateTimeFormat(e,{...n});return e=>t.format(e)}),relativetime:t((e,n)=>{let t=new Intl.RelativeTimeFormat(e,{...n});return e=>t.format(e,n.range||"day")}),list:t((e,n)=>{let t=new Intl.ListFormat(e,{...n});return e=>t.format(e)})}}add(e,n){this.formats[e.toLowerCase().trim()]=n}addCached(e,n){this.formats[e.toLowerCase().trim()]=ob(n)}format(e,n,t,i={}){let r=n.split(this.formatSeparator);if(r.length>1&&r[0].indexOf("(")>1&&0>r[0].indexOf(")")&&r.find(e=>e.indexOf(")")>-1)){let e=r.findIndex(e=>e.indexOf(")")>-1);r[0]=[r[0],...r.splice(1,e)].join(this.formatSeparator)}return r.reduce((e,n)=>{let{formatName:r,formatOptions:o}=(e=>{let n=e.toLowerCase().trim(),t={};if(e.indexOf("(")>-1){let i=e.split("(");n=i[0].toLowerCase().trim();let r=i[1].substring(0,i[1].length-1);"currency"===n&&0>r.indexOf(":")?t.currency||(t.currency=r.trim()):"relativetime"===n&&0>r.indexOf(":")?t.range||(t.range=r.trim()):r.split(";").forEach(e=>{if(e){let[n,...i]=e.split(":"),r=i.join(":").trim().replace(/^'+|'+$/g,""),o=n.trim();t[o]||(t[o]=r),"false"===r&&(t[o]=!1),"true"===r&&(t[o]=!0),isNaN(r)||(t[o]=parseInt(r,10))}})}return{formatName:n,formatOptions:t}})(n);if(this.formats[r]){let n=e;try{let a=i?.formatParams?.[i.interpolationkey]||{},s=a.locale||a.lng||i.locale||i.lng||t;n=this.formats[r](e,s,{...o,...i,...a})}catch(e){this.logger.warn(e)}return n}return this.logger.warn(`there was no format function for ${r}`),e},e)}}class ov extends oi{constructor(e,n,t,i={}){super(),this.backend=e,this.store=n,this.services=t,this.languageUtils=t.languageUtils,this.options=i,this.logger=ot.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=i.maxParallelReads||10,this.readingCalls=0,this.maxRetries=i.maxRetries>=0?i.maxRetries:5,this.retryTimeout=i.retryTimeout>=1?i.retryTimeout:350,this.state={},this.queue=[],this.backend?.init?.(t,i.backend,i)}queueLoad(e,n,t,i){let r={},o={},a={},s={};return e.forEach(e=>{let i=!0;n.forEach(n=>{let a=`${e}|${n}`;!t.reload&&this.store.hasResourceBundle(e,n)?this.state[a]=2:this.state[a]<0||(1===this.state[a]?void 0===o[a]&&(o[a]=!0):(this.state[a]=1,i=!1,void 0===o[a]&&(o[a]=!0),void 0===r[a]&&(r[a]=!0),void 0===s[n]&&(s[n]=!0)))}),i||(a[e]=!0)}),(Object.keys(r).length||Object.keys(o).length)&&this.queue.push({pending:o,pendingCount:Object.keys(o).length,loaded:{},errors:[],callback:i}),{toLoad:Object.keys(r),pending:Object.keys(o),toLoadLanguages:Object.keys(a),toLoadNamespaces:Object.keys(s)}}loaded(e,n,t){let i=e.split("|"),r=i[0],o=i[1];n&&this.emit("failedLoading",r,o,n),!n&&t&&this.store.addResourceBundle(r,o,t,void 0,void 0,{skipCopy:!0}),this.state[e]=n?-1:2,n&&t&&(this.state[e]=0);let a={};this.queue.forEach(t=>{((e,n,t,i)=>{let{obj:r,k:o}=r0(e,n,Object);r[o]=r[o]||[],r[o].push(t)})(t.loaded,[r],o),void 0!==t.pending[e]&&(delete t.pending[e],t.pendingCount--),n&&t.errors.push(n),0!==t.pendingCount||t.done||(Object.keys(t.loaded).forEach(e=>{a[e]||(a[e]={});let n=t.loaded[e];n.length&&n.forEach(n=>{void 0===a[e][n]&&(a[e][n]=!0)})}),t.done=!0,t.errors.length?t.callback(t.errors):t.callback())}),this.emit("loaded",a),this.queue=this.queue.filter(e=>!e.done)}read(e,n,t,i=0,r=this.retryTimeout,o){if(!e.length)return o(null,{});if(this.readingCalls>=this.maxParallelReads)return void this.waitingReads.push({lng:e,ns:n,fcName:t,tried:i,wait:r,callback:o});this.readingCalls++;let a=(a,s)=>{if(this.readingCalls--,this.waitingReads.length>0){let e=this.waitingReads.shift();this.read(e.lng,e.ns,e.fcName,e.tried,e.wait,e.callback)}a&&s&&i<this.maxRetries?setTimeout(()=>{this.read.call(this,e,n,t,i+1,2*r,o)},r):o(a,s)},s=this.backend[t].bind(this.backend);if(2===s.length){try{let t=s(e,n);t&&"function"==typeof t.then?t.then(e=>a(null,e)).catch(a):a(null,t)}catch(e){a(e)}return}return s(e,n,a)}prepareLoading(e,n,t={},i){if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),i&&i();rK(e)&&(e=this.languageUtils.toResolveHierarchy(e)),rK(n)&&(n=[n]);let r=this.queueLoad(e,n,t,i);if(!r.toLoad.length)return r.pending.length||i(),null;r.toLoad.forEach(e=>{this.loadOne(e)})}load(e,n,t){this.prepareLoading(e,n,{},t)}reload(e,n,t){this.prepareLoading(e,n,{reload:!0},t)}loadOne(e,n=""){let t=e.split("|"),i=t[0],r=t[1];this.read(i,r,"read",void 0,void 0,(t,o)=>{t&&this.logger.warn(`${n}loading namespace ${r} for language ${i} failed`,t),!t&&o&&this.logger.log(`${n}loaded namespace ${r} for language ${i}`,o),this.loaded(e,t,o)})}saveMissing(e,n,t,i,r,o={},a=()=>{}){if(this.services?.utils?.hasLoadedNamespace&&!this.services?.utils?.hasLoadedNamespace(n))return void this.logger.warn(`did not save key "${t}" as the namespace "${n}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");if(null!=t&&""!==t){if(this.backend?.create){let s={...o,isUpdate:r},l=this.backend.create.bind(this.backend);if(l.length<6)try{let r;(r=5===l.length?l(e,n,t,i,s):l(e,n,t,i))&&"function"==typeof r.then?r.then(e=>a(null,e)).catch(a):a(null,r)}catch(e){a(e)}else l(e,n,t,i,a,s)}e&&e[0]&&this.store.addResource(e[0],n,t,i)}}}let o$=()=>({debug:!1,initAsync:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:e=>{let n={};if("object"==typeof e[1]&&(n=e[1]),rK(e[1])&&(n.defaultValue=e[1]),rK(e[2])&&(n.tDescription=e[2]),"object"==typeof e[2]||"object"==typeof e[3]){let t=e[3]||e[2];Object.keys(t).forEach(e=>{n[e]=t[e]})}return n},interpolation:{escapeValue:!0,format:e=>e,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0},cacheInBuiltFormats:!0}),oA=e=>(rK(e.ns)&&(e.ns=[e.ns]),rK(e.fallbackLng)&&(e.fallbackLng=[e.fallbackLng]),rK(e.fallbackNS)&&(e.fallbackNS=[e.fallbackNS]),e.supportedLngs?.indexOf?.("cimode")<0&&(e.supportedLngs=e.supportedLngs.concat(["cimode"])),"boolean"==typeof e.initImmediate&&(e.initAsync=e.initImmediate),e),ow=()=>{};class ok extends oi{constructor(e={},n){if(super(),this.options=oA(e),this.services={},this.logger=ot,this.modules={external:[]},(e=>{Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach(n=>{"function"==typeof e[n]&&(e[n]=e[n].bind(e))})})(this),n&&!this.isInitialized&&!e.isClone){if(!this.options.initAsync)return this.init(e,n),this;setTimeout(()=>{this.init(e,n)},0)}}init(e={},n){this.isInitializing=!0,"function"==typeof e&&(n=e,e={}),null==e.defaultNS&&e.ns&&(rK(e.ns)?e.defaultNS=e.ns:0>e.ns.indexOf("translation")&&(e.defaultNS=e.ns[0]));let t=o$();this.options={...t,...this.options,...oA(e)},this.options.interpolation={...t.interpolation,...this.options.interpolation},void 0!==e.keySeparator&&(this.options.userDefinedKeySeparator=e.keySeparator),void 0!==e.nsSeparator&&(this.options.userDefinedNsSeparator=e.nsSeparator);let i=e=>e?"function"==typeof e?new e:e:null;if(!this.options.isClone){let e;this.modules.logger?ot.init(i(this.modules.logger),this.options):ot.init(null,this.options),e=this.modules.formatter?this.modules.formatter:o_;let n=new op(this.options);this.store=new or(this.options.resources,this.options);let r=this.services;r.logger=ot,r.resourceStore=this.store,r.languageUtils=n,r.pluralResolver=new oh(n,{prepend:this.options.pluralSeparator,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),this.options.interpolation.format&&this.options.interpolation.format!==t.interpolation.format&&this.logger.deprecate("init: you are still using the legacy format function, please use the new approach: https://www.i18next.com/translation-function/formatting"),e&&(!this.options.interpolation.format||this.options.interpolation.format===t.interpolation.format)&&(r.formatter=i(e),r.formatter.init&&r.formatter.init(r,this.options),this.options.interpolation.format=r.formatter.format.bind(r.formatter)),r.interpolator=new om(this.options),r.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},r.backendConnector=new ov(i(this.modules.backend),r.resourceStore,r,this.options),r.backendConnector.on("*",(e,...n)=>{this.emit(e,...n)}),this.modules.languageDetector&&(r.languageDetector=i(this.modules.languageDetector),r.languageDetector.init&&r.languageDetector.init(r,this.options.detection,this.options)),this.modules.i18nFormat&&(r.i18nFormat=i(this.modules.i18nFormat),r.i18nFormat.init&&r.i18nFormat.init(this)),this.translator=new ou(this.services,this.options),this.translator.on("*",(e,...n)=>{this.emit(e,...n)}),this.modules.external.forEach(e=>{e.init&&e.init(this)})}if(this.format=this.options.interpolation.format,n||(n=ow),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){let e=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);e.length>0&&"dev"!==e[0]&&(this.options.lng=e[0])}this.services.languageDetector||this.options.lng||this.logger.warn("init: no languageDetector is used and no lng is defined"),["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach(e=>{this[e]=(...n)=>this.store[e](...n)}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(e=>{this[e]=(...n)=>(this.store[e](...n),this)});let r=rY(),o=()=>{let e=(e,t)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=!0,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),r.resolve(t),n(e,t)};if(this.languages&&!this.isInitialized)return e(null,this.t.bind(this));this.changeLanguage(this.options.lng,e)};return this.options.resources||!this.options.initAsync?o():setTimeout(o,0),r}loadResources(e,n=ow){let t=n,i=rK(e)?e:this.language;if("function"==typeof e&&(t=e),!this.options.resources||this.options.partialBundledLanguages){if(i?.toLowerCase()==="cimode"&&(!this.options.preload||0===this.options.preload.length))return t();let e=[],n=n=>{n&&"cimode"!==n&&this.services.languageUtils.toResolveHierarchy(n).forEach(n=>{"cimode"!==n&&0>e.indexOf(n)&&e.push(n)})};i?n(i):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(e=>n(e)),this.options.preload?.forEach?.(e=>n(e)),this.services.backendConnector.load(e,this.options.ns,e=>{e||this.resolvedLanguage||!this.language||this.setResolvedLanguage(this.language),t(e)})}else t(null)}reloadResources(e,n,t){let i=rY();return"function"==typeof e&&(t=e,e=void 0),"function"==typeof n&&(t=n,n=void 0),e||(e=this.languages),n||(n=this.options.ns),t||(t=ow),this.services.backendConnector.reload(e,n,e=>{i.resolve(),t(e)}),i}use(e){if(!e)throw Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!e.type)throw Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return"backend"===e.type&&(this.modules.backend=e),("logger"===e.type||e.log&&e.warn&&e.error)&&(this.modules.logger=e),"languageDetector"===e.type&&(this.modules.languageDetector=e),"i18nFormat"===e.type&&(this.modules.i18nFormat=e),"postProcessor"===e.type&&oo.addPostProcessor(e),"formatter"===e.type&&(this.modules.formatter=e),"3rdParty"===e.type&&this.modules.external.push(e),this}setResolvedLanguage(e){if(e&&this.languages&&!(["cimode","dev"].indexOf(e)>-1)){for(let e=0;e<this.languages.length;e++){let n=this.languages[e];if(!(["cimode","dev"].indexOf(n)>-1)&&this.store.hasLanguageSomeTranslations(n)){this.resolvedLanguage=n;break}}!this.resolvedLanguage&&0>this.languages.indexOf(e)&&this.store.hasLanguageSomeTranslations(e)&&(this.resolvedLanguage=e,this.languages.unshift(e))}}changeLanguage(e,n){this.isLanguageChangingTo=e;let t=rY();this.emit("languageChanging",e);let i=e=>{this.language=e,this.languages=this.services.languageUtils.toResolveHierarchy(e),this.resolvedLanguage=void 0,this.setResolvedLanguage(e)},r=(r,o)=>{o?this.isLanguageChangingTo===e&&(i(o),this.translator.changeLanguage(o),this.isLanguageChangingTo=void 0,this.emit("languageChanged",o),this.logger.log("languageChanged",o)):this.isLanguageChangingTo=void 0,t.resolve((...e)=>this.t(...e)),n&&n(r,(...e)=>this.t(...e))},o=n=>{e||n||!this.services.languageDetector||(n=[]);let t=rK(n)?n:n&&n[0],o=this.store.hasLanguageSomeTranslations(t)?t:this.services.languageUtils.getBestMatchFromCodes(rK(n)?[n]:n);o&&(this.language||i(o),this.translator.language||this.translator.changeLanguage(o),this.services.languageDetector?.cacheUserLanguage?.(o)),this.loadResources(o,e=>{r(e,o)})};return e||!this.services.languageDetector||this.services.languageDetector.async?!e&&this.services.languageDetector&&this.services.languageDetector.async?0===this.services.languageDetector.detect.length?this.services.languageDetector.detect().then(o):this.services.languageDetector.detect(o):o(e):o(this.services.languageDetector.detect()),t}getFixedT(e,n,t){let i=(e,n,...r)=>{let o,a;(o="object"!=typeof n?this.options.overloadTranslationOptionHandler([e,n].concat(r)):{...n}).lng=o.lng||i.lng,o.lngs=o.lngs||i.lngs,o.ns=o.ns||i.ns,""!==o.keyPrefix&&(o.keyPrefix=o.keyPrefix||t||i.keyPrefix);let s=this.options.keySeparator||".";return o.keyPrefix&&Array.isArray(e)?a=e.map(e=>("function"==typeof e&&(e=os(e,{...this.options,...n})),`${o.keyPrefix}${s}${e}`)):("function"==typeof e&&(e=os(e,{...this.options,...n})),a=o.keyPrefix?`${o.keyPrefix}${s}${e}`:e),this.t(a,o)};return rK(e)?i.lng=e:i.lngs=e,i.ns=n,i.keyPrefix=t,i}t(...e){return this.translator?.translate(...e)}exists(...e){return this.translator?.exists(...e)}setDefaultNamespace(e){this.options.defaultNS=e}hasLoadedNamespace(e,n={}){if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;let t=n.lng||this.resolvedLanguage||this.languages[0],i=!!this.options&&this.options.fallbackLng,r=this.languages[this.languages.length-1];if("cimode"===t.toLowerCase())return!0;let o=(e,n)=>{let t=this.services.backendConnector.state[`${e}|${n}`];return -1===t||0===t||2===t};if(n.precheck){let e=n.precheck(this,o);if(void 0!==e)return e}return!!(this.hasResourceBundle(t,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||o(t,e)&&(!i||o(r,e)))}loadNamespaces(e,n){let t=rY();return this.options.ns?(rK(e)&&(e=[e]),e.forEach(e=>{0>this.options.ns.indexOf(e)&&this.options.ns.push(e)}),this.loadResources(e=>{t.resolve(),n&&n(e)}),t):(n&&n(),Promise.resolve())}loadLanguages(e,n){let t=rY();rK(e)&&(e=[e]);let i=this.options.preload||[],r=e.filter(e=>0>i.indexOf(e)&&this.services.languageUtils.isSupportedCode(e));return r.length?(this.options.preload=i.concat(r),this.loadResources(e=>{t.resolve(),n&&n(e)}),t):(n&&n(),Promise.resolve())}dir(e){if(e||(e=this.resolvedLanguage||(this.languages?.length>0?this.languages[0]:this.language)),!e)return"rtl";try{let n=new Intl.Locale(e);if(n&&n.getTextInfo){let e=n.getTextInfo();if(e&&e.direction)return e.direction}}catch(e){}let n=this.services?.languageUtils||new op(o$());return e.toLowerCase().indexOf("-latn")>1?"ltr":["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"].indexOf(n.getLanguagePartFromCode(e))>-1||e.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(e={},n){return new ok(e,n)}cloneInstance(e={},n=ow){let t=e.forkResourceStore;t&&delete e.forkResourceStore;let i={...this.options,...e,isClone:!0},r=new ok(i);return(void 0!==e.debug||void 0!==e.prefix)&&(r.logger=r.logger.clone(e)),["store","services","language"].forEach(e=>{r[e]=this[e]}),r.services={...this.services},r.services.utils={hasLoadedNamespace:r.hasLoadedNamespace.bind(r)},t&&(r.store=new or(Object.keys(this.store.data).reduce((e,n)=>(e[n]={...this.store.data[n]},e[n]=Object.keys(e[n]).reduce((t,i)=>(t[i]={...e[n][i]},t),e[n]),e),{}),i),r.services.resourceStore=r.store),r.translator=new ou(r.services,i),r.translator.on("*",(e,...n)=>{r.emit(e,...n)}),r.init(i,n),r.translator.options=i,r.translator.backendConnector.services.utils={hasLoadedNamespace:r.hasLoadedNamespace.bind(r)},r}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}let ox=ok.createInstance();ox.createInstance=ok.createInstance,ox.createInstance,ox.dir,ox.init,ox.loadResources,ox.reloadResources,ox.use,ox.changeLanguage,ox.getFixedT,ox.t,ox.exists,ox.setDefaultNamespace,ox.hasLoadedNamespace,ox.loadNamespaces,ox.loadLanguages;let oC=ox.default||ox;function oE(e,n,t,i){return oC.t(n,{ns:e,defaultValue:t,...i})}function oS(e,n,t){return rq[e]?oE("core",e,n??rq[e],t):(console.error(`O3 Core Translations does not provide key '${e}'. The key itself is being rendered as text.`),e)}oC.on("initialized",function(){window.i18next.loadNamespaces(["core"])});let oD="import-map-override:",oM="import-map-overrides-disabled",oz="import-map-overrides:change",oO=!1,oP=null,oT=null;async function oB(){return oT??(oT=oI().then(({map:e,complete:n})=>(n||(oT=null),e))),oT}async function oI(){let e=document.querySelectorAll('script[type="systemjs-importmap"]'),n=[],t=!0;for(let i=0;i<e.length;i++){let r=e[i];try{if(r.src){let e=await fetch(r.src);if(!e.ok)throw Error(`Request for ${r.src} returned ${e.status} ${e.statusText}`);n.push(await e.json())}else r.textContent&&n.push(JSON.parse(r.textContent))}catch(e){t=!1,console.warn(`[import-maps] Failed to parse import map from script tag at index ${i}`,e)}}return{map:oN(n),complete:t}}function oN(e){let n={imports:{}};for(let t of e)t?.imports&&Object.assign(n.imports,t.imports);return n}function oj(){let e={};try{let n=oV();for(let t=0;t<localStorage.length;t++){let i=localStorage.key(t);if(i?.startsWith(oD)){let t=i.slice(oD.length);if(!n.includes(t)){let n=localStorage.getItem(i);n&&(e[t]=n)}}}}catch(e){console.warn("[import-maps] Failed to read import-map overrides from localStorage",e)}return{imports:e}}async function oR(){let e=await oB();return oO?oN([e,oP??oj()]):e}async function oF(){return oB()}async function oL(){return oO?oN([await oB(),oj()]):oB()}function oW(e){if(!oO)return{imports:{}};if(e){let e={};for(let n=0;n<localStorage.length;n++){let t=localStorage.key(n);if(t?.startsWith(oD)){let n=localStorage.getItem(t);n&&(e[t.slice(oD.length)]=n)}}return{imports:e}}return oj()}function oV(){if(!oO)return[];try{let e=localStorage.getItem(oM);if(e){let n=JSON.parse(e);if(Array.isArray(n))return n}}catch{}return[]}function oG(e){return!!oO&&oV().includes(e)}function oU(e,n){if(!oO)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{localStorage.setItem(oD+e,n),window.dispatchEvent(new CustomEvent(oz))}catch(e){console.warn("[import-maps] Failed to write import-map override to localStorage",e)}}function oH(e){if(!oO)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{localStorage.removeItem(oD+e);let n=oV().filter(n=>n!==e);n.length>0?localStorage.setItem(oM,JSON.stringify(n)):localStorage.removeItem(oM),window.dispatchEvent(new CustomEvent(oz))}catch(e){console.warn("[import-maps] Failed to update import-map overrides in localStorage",e)}}function oq(){if(!oO)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(oD)&&e.push(t)}e.forEach(e=>localStorage.removeItem(e)),localStorage.removeItem(oM),window.dispatchEvent(new CustomEvent(oz))}catch(e){console.warn("[import-maps] Failed to clear import-map overrides from localStorage",e)}}function oK(e){if(!oO)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{let n=oV().filter(n=>n!==e);n.length>0?localStorage.setItem(oM,JSON.stringify(n)):localStorage.removeItem(oM),window.dispatchEvent(new CustomEvent(oz))}catch(e){console.warn("[import-maps] Failed to update import-map overrides in localStorage",e)}}let oY=!1;function oJ(){!oY&&(oY=!0,(oO="development"===window.spaEnv)&&(oP=oj()))}function oZ(e){return e.replace(/[\/\-@]/g,"_")}async function oX(e,n="./start",i){var r;let o,a=!i?.maxLoadingTime||i.maxLoadingTime<=0?6e5:i.maxLoadingTime;await Promise.race([oQ(e,i?.importMap),new Promise((n,t)=>{o=setTimeout(()=>{var n;t(Error(`Could not resolve requested script, ${e}, within ${(n=a)<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`}.`))},a)})]),o&&clearTimeout(o);let s=oZ(e),l=window[s];if(!("object"==typeof(r=l)&&null!==r&&"init"in r&&"function"==typeof r.init&&"get"in r&&"function"==typeof r.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 oQ(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=oZ(e);if(!window[t]){let t=n??await o0();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 i=t.imports[e];i.startsWith("./")&&(i=window.spaBase+i.substring(1));let r=e in oW().imports;try{return await new Promise((e,n)=>{!function(e,n,t){let i=document.head.querySelector(`script[src="${e}"]`),r=window[o1];if(r||(r=window[o1]=new Set([])),i)if(r.has(e)){let e,r,o;o=()=>{e&&i.removeEventListener("load",e),r&&i.removeEventListener("error",r)},e=()=>{o(),n(null)},r=e=>{o(),t(e.message)},i.addEventListener("load",e),i.addEventListener("error",r)}else console.warn(`Script at ${e} already loaded. Not loading it again.`),n(null);else{let i,o,a;r.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);a=()=>{clearTimeout(l),r.delete(e),i&&s.removeEventListener("load",i),o&&s.removeEventListener("error",o)},i=()=>{a(),n(null)},o=n=>{a();let i=`Failed to load script from ${e}`;console.error(i,n),t(n.message??i)},s.addEventListener("load",i),s.addEventListener("error",o),document.head.appendChild(s)}}(i,e,n)})}catch(e){return r&&z({kind:"error",title:oS("scriptLoadingFailed","Error: Script failed to load"),description:oS("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:i}),actionButtonLabel:oS("resetOverrides","Reset overrides"),onActionButtonClick(){oq(),window.location.reload()}}),Promise.reject(e)}}return Promise.resolve()}async function o0(){return oR()}let o1=Symbol("__openmrs_script_loading");function o2(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 o3(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&&o2(n))}let o5="openmrs-routes:",o4="openmrs-routes:change",o6=!1,o8=null,o7=null;async function o9(){return o7??(o7=ae().then(({map:e,complete:n})=>(n||(o7=null),e))),o7}async function ae(){let e=document.querySelectorAll("script[type='openmrs-routes']"),n=[],t=!0;for(let i=0;i<e.length;i++){let r=e[i];try{let e;if(r.src){let n=await fetch(r.src);if(!n.ok)throw Error(`Request for ${r.src} returned ${n.status} ${n.statusText}`);e=await n.json()}else r.textContent&&(e=JSON.parse(r.textContent));e&&o3(e)&&n.push(e)}catch(e){t=!1,console.warn(`[route-maps] Failed to parse routes from script tag at index ${i}`,e)}}return{map:an(n),complete:t}}function an(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 at(){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(o5)){let e=localStorage.getItem(t);e&&n.push({moduleName:t.slice(o5.length),raw:e})}}for(let t of(await Promise.allSettled(n.map(async({moduleName:e,raw:n})=>{let t=JSON.parse(n);if(o2(t))return{moduleName:e,routes:t};if("string"==typeof t&&t.startsWith("http")){let n=await fetch(t),i=await n.json();if(o2(i))return{moduleName:e,routes:i};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 ai(){let e=await o9();return o6?an([e,o8??await at()]):e}async function ar(){return o9()}async function ao(){return o6?an([await o9(),await at()]):o9()}function aa(){if(!o6)return{};let e={};try{for(let n=0;n<localStorage.length;n++){let t=localStorage.key(n);if(t?.startsWith(o5)){let n=localStorage.getItem(t);n&&(e[t.slice(o5.length)]=n)}}}catch(e){console.warn("[route-maps] Failed to read route overrides from localStorage",e)}return e}function as(e,n){if(!o6)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{if("string"==typeof n)if(n.startsWith("http"))localStorage.setItem(o5+e,JSON.stringify(n));else{let t=JSON.parse(n);if(!o2(t))return void console.error(`The supplied routes for ${e} is not a valid OpenmrsAppRoutes object`,n);localStorage.setItem(o5+e,JSON.stringify(t))}else if(n instanceof URL)localStorage.setItem(o5+e,JSON.stringify(n.toString()));else{if(!o2(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(o5+e,JSON.stringify(n))}window.dispatchEvent(new CustomEvent(o4))}catch(e){console.warn("[route-maps] Failed to write route override to localStorage",e)}}function al(e){if(!o6)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{localStorage.removeItem(o5+e),window.dispatchEvent(new CustomEvent(o4))}catch(e){console.warn("[route-maps] Failed to remove route override from localStorage",e)}}function ac(){if(!o6)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(o5)&&e.push(t)}e.forEach(e=>localStorage.removeItem(e)),window.dispatchEvent(new CustomEvent(o4))}catch(e){console.warn("[route-maps] Failed to clear route overrides from localStorage",e)}}let au=null;function ap(){return au||(au=(o6="development"===window.spaEnv)?at().then(e=>{o8=e}):Promise.resolve())}let ad=`${rk}/attachment`;function af(e,n){return rS(`${ad}/${e}`,{signal:n.signal})}function ah(e,n,t){return rS(`${ad}?patient=${e}&includeEncounterless=${n}`,{signal:t.signal})}async function ag(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)),rS(`${ad}`,{method:"POST",body:t})}function am(e,n){return rS(`${ad}/${e}`,{method:"DELETE",signal:n.signal})}try{self["workbox:window:6.5.4"]&&_()}catch(e){}function ab(e,n){return new Promise(function(t){var i=new MessageChannel;i.port1.onmessage=function(e){t(e.data)},e.postMessage(n,[i.port2])})}function ay(e,n){for(var t=0;t<n.length;t++){var i=n[t];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function a_(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,i=Array(n);t<n;t++)i[t]=e[t];return i}try{self["workbox:core:6.5.4"]&&_()}catch(e){}var av=function(){var e=this;this.promise=new Promise(function(n,t){e.resolve=n,e.reject=t})};function a$(e,n){var t=location.href;return new URL(e,t).href===new URL(n,t).href}var aA=function(e,n){this.type=e,Object.assign(this,n)};function aw(e,n,t){return t?n?n(e):e:(e&&e.then||(e=Promise.resolve(e)),n?e.then(n):e)}function ak(){}var ax={type:"SKIP_WAITING"};function aC(e,n){if(!n)return e&&e.then?e.then(ak):Promise.resolve()}var aE=function(e){function n(n,t){var i,r;return void 0===t&&(t={}),(i=e.call(this)||this).nn={},i.tn=0,i.rn=new av,i.en=new av,i.on=new av,i.un=0,i.an=new Set,i.cn=function(){var e=i.fn,n=e.installing;i.tn>0||!a$(n.scriptURL,i.sn.toString())||performance.now()>i.un+6e4?(i.vn=n,e.removeEventListener("updatefound",i.cn)):(i.hn=n,i.an.add(n),i.rn.resolve(n)),++i.tn,n.addEventListener("statechange",i.ln)},i.ln=function(e){var n=i.fn,t=e.target,r=t.state,o=t===i.vn,a={sw:t,isExternal:o,originalEvent:e};!o&&i.mn&&(a.isUpdate=!0),i.dispatchEvent(new aA(r,a)),"installed"===r?i.wn=self.setTimeout(function(){"installed"===r&&n.waiting===t&&i.dispatchEvent(new aA("waiting",a))},200):"activating"===r&&(clearTimeout(i.wn),o||i.en.resolve(t))},i.dn=function(e){var n=i.hn,t=n!==navigator.serviceWorker.controller;i.dispatchEvent(new aA("controlling",{isExternal:t,originalEvent:e,sw:n,isUpdate:i.mn})),t||i.on.resolve(n)},r=function(e){var n=e.data,t=e.ports,r=e.source;return aw(i.getSW(),function(){i.an.has(r)&&i.dispatchEvent(new aA("message",{data:n,originalEvent:e,ports:t,sw:r}))})},i.gn=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];try{return Promise.resolve(r.apply(this,e))}catch(e){return Promise.reject(e)}},i.sn=n,i.nn=t,navigator.serviceWorker.addEventListener("message",i.gn),i}n.prototype=Object.create(e.prototype),n.prototype.constructor=n,n.__proto__=e;var t,i,r=n.prototype;return r.register=function(e){var n=(void 0===e?{}:e).immediate,t=void 0!==n&&n;try{var i,r,o,a=this;return i=function(){if(!t&&"complete"!==document.readyState)return aC(new Promise(function(e){return window.addEventListener("load",e)}))},r=function(){return a.mn=!!navigator.serviceWorker.controller,a.yn=a.pn(),aw(a.bn(),function(e){a.fn=e,a.yn&&(a.hn=a.yn,a.en.resolve(a.yn),a.on.resolve(a.yn),a.yn.addEventListener("statechange",a.ln,{once:!0}));var n=a.fn.waiting;return n&&a$(n.scriptURL,a.sn.toString())&&(a.hn=n,Promise.resolve().then(function(){a.dispatchEvent(new aA("waiting",{sw:n,wasWaitingBeforeRegister:!0}))}).then(function(){})),a.hn&&(a.rn.resolve(a.hn),a.an.add(a.hn)),a.fn.addEventListener("updatefound",a.cn),navigator.serviceWorker.addEventListener("controllerchange",a.dn),a.fn})},(o=i())&&o.then?o.then(r):r(o)}catch(e){return Promise.reject(e)}},r.update=function(){try{return this.fn?aC(this.fn.update()):void 0}catch(e){return Promise.reject(e)}},r.getSW=function(){return void 0!==this.hn?Promise.resolve(this.hn):this.rn.promise},r.messageSW=function(e){try{return aw(this.getSW(),function(n){return ab(n,e)})}catch(e){return Promise.reject(e)}},r.messageSkipWaiting=function(){this.fn&&this.fn.waiting&&ab(this.fn.waiting,ax)},r.pn=function(){var e=navigator.serviceWorker.controller;return e&&a$(e.scriptURL,this.sn.toString())?e:void 0},r.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 aw(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}}],ay(n.prototype,t),i&&ay(n,i),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 a_(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)?a_(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 aS(e,n){if(void 0!==d)return console.warn(`The application's Service Worker has already been registered. The new service worker at ${e} will not be registered.`),d;if(!("serviceWorker"in navigator))throw Error("Registering the Service Worker is not possible due to missing browser capabilities.");let t=new aE(e,n);return d=t.register().then(()=>t.controlling.then(()=>t))}function aD(){return d??Promise.resolve(void 0)}let aM="x-omrs-offline-response-body",az="x-omrs-offline-response-status",aO="x-omrs-offline-caching-strategy";async function aP(e){let n=await aD();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 aT(){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 aB(){return!window.indexedDB}async function aI(){return new Promise(e=>{let n=indexedDB.open("test");n.onerror=()=>e(!0),n.onsuccess=()=>e(!1)})}async function aN(){return await aI()||await aB()||await aT()}let aj="openmrs3:offline-mode",aR="unavailable";function aF(){return{current:aR,notAvailable:"unavailable"===aR,active:"on"===aR}}function aL(e){"unavailable"!==aR&&"unavailable"!==e&&(localStorage.setItem(aj,"on"===e?"active":"disabled"),aR=e)}async function aW(){await aN()||(aR="active"===localStorage.getItem(aj)?"on":"off"),navigator.onLine}let aV="u">typeof globalThis?globalThis:"u">typeof self?self:"u">typeof window?window:global,aG=Object.keys,aU=Array.isArray;function aH(e,n){return"object"!=typeof n||aG(n).forEach(function(t){e[t]=n[t]}),e}"u"<typeof Promise||aV.Promise||(aV.Promise=Promise);let aq=Object.getPrototypeOf,aK={}.hasOwnProperty;function aY(e,n){return aK.call(e,n)}function aJ(e,n){"function"==typeof n&&(n=n(aq(e))),("u"<typeof Reflect?aG:Reflect.ownKeys)(n).forEach(t=>{aX(e,t,n[t])})}let aZ=Object.defineProperty;function aX(e,n,t,i){aZ(e,n,aH(t&&aY(t,"get")&&"function"==typeof t.get?{get:t.get,set:t.set,configurable:!0}:{value:t,configurable:!0,writable:!0},i))}function aQ(e){return{from:function(n){return e.prototype=Object.create(n.prototype),aX(e.prototype,"constructor",e),{extend:aJ.bind(null,e.prototype)}}}}let a0=Object.getOwnPropertyDescriptor;function a1(e,n){let t;return a0(e,n)||(t=aq(e))&&a1(t,n)}let a2=[].slice;function a3(e,n,t){return a2.call(e,n,t)}function a5(e,n){return n(e)}function a4(e){if(!e)throw Error("Assertion Failed")}function a6(e){aV.setImmediate?setImmediate(e):setTimeout(e,0)}function a8(e,n){return e.reduce((e,t,i)=>{var r=n(t,i);return r&&(e[r[0]]=r[1]),e},{})}function a7(e,n){if(aY(e,n))return e[n];if(!n)return e;if("string"!=typeof n){for(var t=[],i=0,r=n.length;i<r;++i){var o=a7(e,n[i]);t.push(o)}return t}var a=n.indexOf(".");if(-1!==a){var s=e[n.substr(0,a)];return void 0===s?void 0:a7(s,n.substr(a+1))}}function a9(e,n,t){if(e&&void 0!==n&&(!("isFrozen"in Object)||!Object.isFrozen(e)))if("string"!=typeof n&&"length"in n){a4("string"!=typeof t&&"length"in t);for(var i=0,r=n.length;i<r;++i)a9(e,n[i],t[i])}else{var o=n.indexOf(".");if(-1!==o){var a=n.substr(0,o),s=n.substr(o+1);if(""===s)void 0===t?aU(e)&&!isNaN(parseInt(a))?e.splice(a,1):delete e[a]:e[a]=t;else{var l=e[a];l&&aY(e,a)||(l=e[a]={}),a9(l,s,t)}}else void 0===t?aU(e)&&!isNaN(parseInt(n))?e.splice(n,1):delete e[n]:e[n]=t}}function se(e){var n={};for(var t in e)aY(e,t)&&(n[t]=e[t]);return n}let sn=[].concat;function st(e){return sn.apply([],e)}let si="Boolean,String,Date,RegExp,Blob,File,FileList,FileSystemFileHandle,ArrayBuffer,DataView,Uint8ClampedArray,ImageBitmap,ImageData,Map,Set,CryptoKey".split(",").concat(st([8,16,32,64].map(e=>["Int","Uint","Float"].map(n=>n+e+"Array")))).filter(e=>aV[e]),sr=si.map(e=>aV[e]);a8(si,e=>[e,!0]);let so=null;function sa(e){so="u">typeof WeakMap&&new WeakMap;let n=function e(n){if(!n||"object"!=typeof n)return n;let t=so&&so.get(n);if(t)return t;if(aU(n)){t=[],so&&so.set(n,t);for(var i=0,r=n.length;i<r;++i)t.push(e(n[i]))}else if(sr.indexOf(n.constructor)>=0)t=n;else{let i=aq(n);for(var o in t=i===Object.prototype?{}:Object.create(i),so&&so.set(n,t),n)aY(n,o)&&(t[o]=e(n[o]))}return t}(e);return so=null,n}let{toString:ss}={};function sl(e){return ss.call(e).slice(8,-1)}let sc="u">typeof Symbol?Symbol.iterator:"@@iterator",su="symbol"==typeof sc?function(e){var n;return null!=e&&(n=e[sc])&&n.apply(e)}:function(){return null},sp={};function sd(e){var n,t,i,r;if(1==arguments.length){if(aU(e))return e.slice();if(this===sp&&"string"==typeof e)return[e];if(r=su(e)){for(t=[];!(i=r.next()).done;)t.push(i.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 sf="u">typeof Symbol?e=>"AsyncFunction"===e[Symbol.toStringTag]:()=>!1;var sh="u">typeof location&&/^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href),sg=()=>!0;let sm=!Error("").stack;function sb(){if(sm)try{throw sb.arguments,Error()}catch(e){return e}return Error()}function sy(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(sg).map(e=>"\n"+e).join("")):""}var s_=["Unknown","Constraint","Data","TransactionInactive","ReadOnly","Version","NotFound","InvalidState","InvalidAccess","Abort","Timeout","QuotaExceeded","Syntax","DataClone"],sv=["Modify","Bulk","OpenFailed","VersionChange","Schema","Upgrade","InvalidTable","MissingAPI","NoSuchDatabase","InvalidArgument","SubTransaction","Unsupported","Internal","DatabaseClosed","PrematureCommit","ForeignAwait"].concat(s_),s$={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 sA(e,n){this._e=sb(),this.name=e,this.message=n}function sw(e,n){return e+". Errors: "+Object.keys(n).map(e=>n[e].toString()).filter((e,n,t)=>t.indexOf(e)===n).join("\n")}function sk(e,n,t,i){this._e=sb(),this.failures=n,this.failedKeys=i,this.successCount=t,this.message=sw(e,n)}function sx(e,n){this._e=sb(),this.name="BulkError",this.failures=Object.keys(n).map(e=>n[e]),this.failuresByPos=n,this.message=sw(e,n)}aQ(sA).from(Error).extend({stack:{get:function(){return this._stack||(this._stack=this.name+": "+this.message+sy(this._e,2))}},toString:function(){return this.name+": "+this.message}}),aQ(sk).from(sA),aQ(sx).from(sA);var sC=sv.reduce((e,n)=>(e[n]=n+"Error",e),{}),sE=sv.reduce((e,n)=>{var t=n+"Error";function i(e,i){this._e=sb(),this.name=t,e?"string"==typeof e?(this.message=`${e}${i?"\n "+i:""}`,this.inner=i||null):"object"==typeof e&&(this.message=`${e.name} ${e.message}`,this.inner=e):(this.message=s$[n]||t,this.inner=null)}return aQ(i).from(sA),e[n]=i,e},{});sE.Syntax=SyntaxError,sE.Type=TypeError,sE.Range=RangeError;var sS=s_.reduce((e,n)=>(e[n+"Error"]=sE[n],e),{}),sD=sv.reduce((e,n)=>(-1===["Syntax","Type","Range"].indexOf(n)&&(e[n+"Error"]=sE[n]),e),{});function sM(){}function sz(e){return e}function sO(e,n){return null==e||e===sz?n:function(t){return n(e(t))}}function sP(e,n){return function(){e.apply(this,arguments),n.apply(this,arguments)}}function sT(e,n){return e===sM?n:function(){var t=e.apply(this,arguments);void 0!==t&&(arguments[0]=t);var i=this.onsuccess,r=this.onerror;this.onsuccess=null,this.onerror=null;var o=n.apply(this,arguments);return i&&(this.onsuccess=this.onsuccess?sP(i,this.onsuccess):i),r&&(this.onerror=this.onerror?sP(r,this.onerror):r),void 0!==o?o:t}}function sB(e,n){return e===sM?n:function(){e.apply(this,arguments);var t=this.onsuccess,i=this.onerror;this.onsuccess=this.onerror=null,n.apply(this,arguments),t&&(this.onsuccess=this.onsuccess?sP(t,this.onsuccess):t),i&&(this.onerror=this.onerror?sP(i,this.onerror):i)}}function sI(e,n){return e===sM?n:function(t){var i=e.apply(this,arguments);aH(t,i);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?sP(r,this.onsuccess):r),o&&(this.onerror=this.onerror?sP(o,this.onerror):o),void 0===i?void 0===a?void 0:a:aH(i,a)}}function sN(e,n){return e===sM?n:function(){return!1!==n.apply(this,arguments)&&e.apply(this,arguments)}}function sj(e,n){return e===sM?n:function(){var t=e.apply(this,arguments);if(t&&"function"==typeof t.then){for(var i=this,r=arguments.length,o=Array(r);r--;)o[r]=arguments[r];return t.then(function(){return n.apply(i,o)})}return n.apply(this,arguments)}}sD.ModifyError=sk,sD.DexieError=sA,sD.BulkError=sx;var sR={};let[sF,sL,sW]="u"<typeof Promise?[]:(()=>{let e=Promise.resolve();if("u"<typeof crypto||!crypto.subtle)return[e,aq(e),e];let n=crypto.subtle.digest("SHA-512",new Uint8Array([0]));return[n,aq(n),e]})(),sV=sL&&sL.then,sG=sF&&sF.constructor,sU=!!sW;var sH=!1,sq=sW?()=>{sW.then(lr)}:aV.setImmediate?setImmediate.bind(null,lr):aV.MutationObserver?()=>{var e=document.createElement("div");new MutationObserver(()=>{lr(),e=null}).observe(e,{attributes:!0}),e.setAttribute("i","1")}:()=>{setTimeout(lr,0)},sK=function(e,n){s3.push([e,n]),sJ&&(sq(),sJ=!1)},sY=!0,sJ=!0,sZ=[],sX=[],sQ=null,s0=sz,s1={id:"global",global:!0,ref:0,unhandleds:[],onunhandled:lS,pgp:!1,env:{},finalize:function(){this.unhandleds.forEach(e=>{try{lS(e[0],e[1])}catch(e){}})}},s2=s1,s3=[],s5=0,s4=[];function s6(e){if("object"!=typeof this)throw TypeError("Promises must be constructed via new");this._listeners=[],this.onuncatched=sM,this._lib=!1;var n=this._PSD=s2;if(sh&&(this._stackHolder=sb(),this._prev=null,this._numPrev=0),"function"!=typeof e){if(e!==sR)throw TypeError("Not a function");return this._state=arguments[1],this._value=arguments[2],void(!1===this._state&&s9(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 i=n._lib&&lo();t&&"function"==typeof t.then?e(n,(e,n)=>{t instanceof s6?t._then(e,n):t.then(e,n)}):(n._state=!0,n._value=t,le(n)),i&&la()}},s9.bind(null,n))}catch(e){s9(n,e)}}(this,e)}let s8={get:function(){var e=s2,n=lh;function t(t,i){var r=!e.global&&(e!==s2||n!==lh);let o=r&&!ly();var a=new s6((n,a)=>{ln(this,new s7(lx(t,e,r,o),lx(i,e,r,o),n,a,e))});return sh&&li(a,this),a}return t.prototype=sR,t},set:function(e){aX(this,"then",e&&e.prototype===sR?s8:{get:function(){return e},set:s8.set})}};function s7(e,n,t,i,r){this.onFulfilled="function"==typeof e?e:null,this.onRejected="function"==typeof n?n:null,this.resolve=t,this.reject=i,this.psd=r}function s9(e,n){if(sX.push(n),null===e._state){var t=e._lib&&lo();n=s0(n),e._state=!1,e._value=n,sh&&null!==n&&"object"==typeof n&&!n._promise&&function(e){try{e.apply(null,void 0)}catch(e){}}(()=>{var t=a1(n,"stack");n._promise=e,aX(n,"stack",{get:()=>sH?t&&(t.get?t.get.apply(n):t.value):e.stack})}),sZ.some(n=>n._value===e._value)||sZ.push(e),le(e),t&&la()}}function le(e){var n=e._listeners;e._listeners=[];for(var t=0,i=n.length;t<i;++t)ln(e,n[t]);var r=e._PSD;--r.ref||r.finalize(),0===s5&&(++s5,sK(()=>{0==--s5&&ls()},[]))}function ln(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,++s5,sK(lt,[t,e,n])}else e._listeners.push(n)}function lt(e,n,t){try{sQ=n;var i,r=n._value;n._state?i=e(r):(sX.length&&(sX=[]),i=e(r),-1===sX.indexOf(r)&&function(e){for(var n=sZ.length;n;)if(sZ[--n]._value===e._value)return void sZ.splice(n,1)}(n)),t.resolve(i)}catch(e){t.reject(e)}finally{sQ=null,0==--s5&&ls(),--t.psd.ref||t.psd.finalize()}}function li(e,n){var t=n?n._numPrev+1:0;t<100&&(e._prev=n,e._numPrev=t)}function lr(){lo()&&la()}function lo(){var e=sY;return sY=!1,sJ=!1,e}function la(){var e,n,t;do for(;s3.length>0;)for(e=s3,s3=[],t=e.length,n=0;n<t;++n){var i=e[n];i[0].apply(null,i[1])}while(s3.length>0);sY=!0,sJ=!0}function ls(){var e=sZ;sZ=[],e.forEach(e=>{e._PSD.onunhandled.call(null,e._value,e)});for(var n=s4.slice(0),t=n.length;t;)n[--t]()}function ll(e){return new s6(sR,!1,e)}function lc(e,n){var t=s2;return function(){var i=lo(),r=s2;try{return lA(t,!0),e.apply(this,arguments)}catch(e){n&&n(e)}finally{lA(r,!1),i&&la()}}}aJ(s6.prototype,{then:s8,_then:function(e,n){ln(this,new s7(null,null,e,n,s2))},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):ll(e)):this.then(null,e=>e&&e.name===n?t(e):ll(e))},finally:function(e){return this.then(n=>(e(),n),n=>(e(),ll(n)))},stack:{get:function(){if(this._stack)return this._stack;try{sH=!0;var e=(function e(n,t,i){if(t.length===i)return t;var r="";if(!1===n._state){var o,a,s=n._value;null!=s?(o=s.name||"Error",a=s.message||s,r=sy(s,0)):(o=s,a=""),t.push(o+(a?": "+a:"")+r)}return sh&&((r=sy(n._stackHolder,2))&&-1===t.indexOf(r)&&t.push(r),n._prev&&e(n._prev,t,i)),t})(this,[],20).join("\nFrom previous: ");return null!==this._state&&(this._stack=e),e}finally{sH=!1}}},timeout:function(e,n){return e<1/0?new s6((t,i)=>{var r=setTimeout(()=>i(new sE.Timeout(n)),e);this.then(t,i).finally(clearTimeout.bind(null,r))}):this}}),"u">typeof Symbol&&Symbol.toStringTag&&aX(s6.prototype,Symbol.toStringTag,"Dexie.Promise"),s1.env=lw(),aJ(s6,{all:function(){var e=sd.apply(null,arguments).map(l_);return new s6(function(n,t){0===e.length&&n([]);var i=e.length;e.forEach((r,o)=>s6.resolve(r).then(t=>{e[o]=t,--i||n(e)},t))})},resolve:e=>{if(e instanceof s6)return e;if(e&&"function"==typeof e.then)return new s6((n,t)=>{e.then(n,t)});var n=new s6(sR,!0,e);return li(n,sQ),n},reject:ll,race:function(){var e=sd.apply(null,arguments).map(l_);return new s6((n,t)=>{e.map(e=>s6.resolve(e).then(n,t))})},PSD:{get:()=>s2,set:e=>s2=e},totalEchoes:{get:()=>lh},newPSD:lm,usePSD:lk,scheduler:{get:()=>sK,set:e=>{sK=e}},rejectionMapper:{get:()=>s0,set:e=>{s0=e}},follow:(e,n)=>new s6((t,i)=>lm((n,t)=>{var i=s2;i.unhandleds=[],i.onunhandled=t,i.finalize=sP(function(){var e;e=()=>{0===this.unhandleds.length?n():t(this.unhandleds[0])},s4.push(function n(){e(),s4.splice(s4.indexOf(n),1)}),++s5,sK(()=>{0==--s5&&ls()},[])},i.finalize),e()},n,t,i))}),sG&&(sG.allSettled&&aX(s6,"allSettled",function(){let e=sd.apply(null,arguments).map(l_);return new s6(n=>{0===e.length&&n([]);let t=e.length,i=Array(t);e.forEach((e,r)=>s6.resolve(e).then(e=>i[r]={status:"fulfilled",value:e},e=>i[r]={status:"rejected",reason:e}).then(()=>--t||n(i)))})}),sG.any&&"u">typeof AggregateError&&aX(s6,"any",function(){let e=sd.apply(null,arguments).map(l_);return new s6((n,t)=>{0===e.length&&t(AggregateError([]));let i=e.length,r=Array(i);e.forEach((e,o)=>s6.resolve(e).then(e=>n(e),e=>{r[o]=e,--i||t(AggregateError(r))}))})}));let lu={awaits:0,echoes:0,id:0};var lp=0,ld=[],lf=0,lh=0,lg=0;function lm(e,n,t,i){var r=s2,o=Object.create(r);o.parent=r,o.ref=0,o.global=!1,o.id=++lg;var a=s1.env;o.env=sU?{Promise:s6,PromiseProp:{value:s6,configurable:!0,writable:!0},all:s6.all,race:s6.race,allSettled:s6.allSettled,any:s6.any,resolve:s6.resolve,reject:s6.reject,nthen:lC(a.nthen,o),gthen:lC(a.gthen,o)}:{},n&&aH(o,n),++r.ref,o.finalize=function(){--this.parent.ref||this.parent.finalize()};var s=lk(o,e,t,i);return 0===o.ref&&o.finalize(),s}function lb(){return lu.id||(lu.id=++lp),++lu.awaits,lu.echoes+=100,lu.id}function ly(){return!!lu.awaits&&(0==--lu.awaits&&(lu.id=0),lu.echoes=100*lu.awaits,!0)}function l_(e){return lu.echoes&&e&&e.constructor===sG?(lb(),e.then(e=>(ly(),e),e=>(ly(),lD(e)))):e}function lv(e){++lh,lu.echoes&&0!=--lu.echoes||(lu.echoes=lu.id=0),ld.push(s2),lA(e,!0)}function l$(){var e=ld[ld.length-1];ld.pop(),lA(e,!1)}function lA(e,n){var t,i=s2;if((n?!lu.echoes||lf++&&e===s2:!lf||--lf&&e===s2)||(t=n?lv.bind(null,e):l$,sV.call(sF,t)),e!==s2&&(s2=e,i===s1&&(s1.env=lw()),sU)){var r=s1.env.Promise,o=e.env;sL.then=o.nthen,r.prototype.then=o.gthen,(i.global||e.global)&&(Object.defineProperty(aV,"Promise",o.PromiseProp),r.all=o.all,r.race=o.race,r.resolve=o.resolve,r.reject=o.reject,o.allSettled&&(r.allSettled=o.allSettled),o.any&&(r.any=o.any))}}function lw(){var e=aV.Promise;return sU?{Promise:e,PromiseProp:Object.getOwnPropertyDescriptor(aV,"Promise"),all:e.all,race:e.race,allSettled:e.allSettled,any:e.any,resolve:e.resolve,reject:e.reject,nthen:sL.then,gthen:e.prototype.then}:{}}function lk(e,n,t,i,r){var o=s2;try{return lA(e,!0),n(t,i,r)}finally{lA(o,!1)}}function lx(e,n,t,i){return"function"!=typeof e?e:function(){var r,o=s2;t&&lb(),lA(n,!0);try{return e.apply(this,arguments)}finally{lA(o,!1),i&&(r=ly,sV.call(sF,r))}}}function lC(e,n){return function(t,i){return e.call(this,lx(t,n),lx(i,n))}}-1===(""+sV).indexOf("[native code]")&&(lb=ly=sM);let lE="unhandledrejection";function lS(e,n){var t;try{t=n.onuncatched(e)}catch(e){}if(!1!==t)try{var i,r={promise:n,reason:e};if(aV.document&&document.createEvent?((i=document.createEvent("Event")).initEvent(lE,!0,!0),aH(i,r)):aV.CustomEvent&&aH(i=new CustomEvent(lE,{detail:r}),r),i&&aV.dispatchEvent&&(dispatchEvent(i),!aV.PromiseRejectionEvent&&aV.onunhandledrejection))try{aV.onunhandledrejection(i)}catch(e){}sh&&i&&!i.defaultPrevented&&console.warn(`Unhandled rejection: ${e.stack||e}`)}catch(e){}}var lD=s6.reject;let lM="3.2.4",lz=String.fromCharCode(65535),lO=-1/0,lP="Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.",lT="String expected.",lB=[],lI="u">typeof navigator&&/(MSIE|Trident|Edge)/.test(navigator.userAgent),lN=e=>!/(dexie\.js|dexie\.min\.js)/.test(e),lj="__dbnames",lR="readonly",lF="readwrite";function lL(e,n){return e?n?function(){return e.apply(this,arguments)&&n.apply(this,arguments)}:e:n}let lW={type:3,lower:-1/0,lowerOpen:!1,upper:[[]],upperOpen:!1};function lV(e){return"string"!=typeof e||/\./.test(e)?e=>e:n=>(void 0===n[e]&&e in n&&delete(n=sa(n))[e],n)}class lG{_trans(e,n,t){let i=this._tx||s2.trans,r=this.name;function o(e,t,i){if(!i.schema[r])throw new sE.NotFound("Table "+r+" not part of transaction");return n(i.idbtrans,i)}let a=lo();try{return i&&i.db===this.db?i===s2.trans?i._promise(e,o,t):lm(()=>i._promise(e,o,t),{trans:i,transless:s2.transless||s2}):function e(n,t,i,r){if(n.idbdb&&(n._state.openComplete||s2.letThrough||n._vip)){var o=n._createTransaction(t,i,n._dbSchema);try{o.create(),n._state.PR1398_maxLoop=3}catch(o){return o.name===sC.InvalidState&&n.isOpen()&&--n._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),n._close(),n.open().then(()=>e(n,t,i,r))):lD(o)}return o._promise(t,(e,n)=>lm(()=>(s2.trans=o,r(e,n,o)))).then(e=>o._completion.then(()=>e))}if(n._state.openComplete)return lD(new sE.DatabaseClosed(n._state.dbOpenError));if(!n._state.isBeingOpened){if(!n._options.autoOpen)return lD(new sE.DatabaseClosed);n.open().catch(sM)}return n._state.dbReadyPromise.then(()=>e(n,t,i,r))}(this.db,e,[this.name],o)}finally{a&&la()}}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(aU(e))return new this.db.WhereClause(this,`[${e.join("+")}]`);let n=aG(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!==lz)return this.where(t.name).equals(t.keyPath.map(n=>e[n]));!t&&sh&&console.warn(`The query ${JSON.stringify(e)} on ${this.name} would benefit of a compound index [${n.join("+")}]`);let{idxByName:i}=this.schema,r=this.db._deps.indexedDB;function o(e,n){try{return 0===r.cmp(e,n)}catch(e){return!1}}let[a,s]=n.reduce(([n,t],r)=>{let a=i[r],s=e[r];return[n||a,n||!a?lL(t,a&&a.multi?e=>{let n=a7(e,r);return aU(n)&&n.some(e=>o(s,e))}:e=>o(s,a7(e,r))):t]},[null,null]);return a?this.where(a.name).equals(e[a.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,aU(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 i in n)if(aY(n,i))try{t[i]=n[i]}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){aH(this,e)})}add(e,n){let{auto:t,keyPath:i}=this.schema.primKey,r=e;return i&&t&&(r=lV(i)(e)),this._trans("readwrite",e=>this.core.mutate({trans:e,type:"add",keys:null!=n?[n]:null,values:[r]})).then(e=>e.numFailures?s6.reject(e.failures[0]):e.lastResult).then(n=>{if(i)try{a9(e,i,n)}catch(e){}return n})}update(e,n){if("object"!=typeof e||aU(e))return this.where(":id").equals(e).modify(n);{let t=a7(e,this.schema.primKey.keyPath);if(void 0===t)return lD(new sE.InvalidArgument("Given object does not contain its primary key"));try{"function"!=typeof n?aG(n).forEach(t=>{a9(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:i}=this.schema.primKey,r=e;return i&&t&&(r=lV(i)(e)),this._trans("readwrite",e=>this.core.mutate({trans:e,type:"put",values:[r],keys:null!=n?[n]:null})).then(e=>e.numFailures?s6.reject(e.failures[0]):e.lastResult).then(n=>{if(i)try{a9(e,i,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?s6.reject(e.failures[0]):void 0)}clear(){return this._trans("readwrite",e=>this.core.mutate({trans:e,type:"deleteRange",range:lW})).then(e=>e.numFailures?s6.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 i=Array.isArray(n)?n:void 0,r=(t=t||(i?void 0:n))?t.allKeys:void 0;return this._trans("readwrite",n=>{let{auto:t,keyPath:o}=this.schema.primKey;if(o&&i)throw new sE.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(i&&i.length!==e.length)throw new sE.InvalidArgument("Arguments objects and keys must have the same length");let a=e.length,s=o&&t?e.map(lV(o)):e;return this.core.mutate({trans:n,type:"add",keys:i,values:s,wantResults:r}).then(({numFailures:e,results:n,lastResult:t,failures:i})=>{if(0===e)return r?n:t;throw new sx(`${this.name}.bulkAdd(): ${e} of ${a} operations failed`,i)})})}bulkPut(e,n,t){let i=Array.isArray(n)?n:void 0,r=(t=t||(i?void 0:n))?t.allKeys:void 0;return this._trans("readwrite",n=>{let{auto:t,keyPath:o}=this.schema.primKey;if(o&&i)throw new sE.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(i&&i.length!==e.length)throw new sE.InvalidArgument("Arguments objects and keys must have the same length");let a=e.length,s=o&&t?e.map(lV(o)):e;return this.core.mutate({trans:n,type:"put",keys:i,values:s,wantResults:r}).then(({numFailures:e,results:n,lastResult:t,failures:i})=>{if(0===e)return r?n:t;throw new sx(`${this.name}.bulkPut(): ${e} of ${a} operations failed`,i)})})}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:i})=>{if(0===e)return t;throw new sx(`${this.name}.bulkDelete(): ${e} of ${n} operations failed`,i)})}}function lU(e){var n={},t=function(t,i){if(i){for(var r=arguments.length,o=Array(r-1);--r;)o[r-1]=arguments[r];return n[t].subscribe.apply(null,o),e}if("string"==typeof t)return n[t]};t.addEventType=o;for(var i=1,r=arguments.length;i<r;++i)o(arguments[i]);return t;function o(e,i,r){if("object"!=typeof e){i||(i=sN),r||(r=sM);var a={subscribers:[],fire:r,subscribe:function(e){-1===a.subscribers.indexOf(e)&&(a.subscribers.push(e),a.fire=i(a.fire,e))},unsubscribe:function(e){a.subscribers=a.subscribers.filter(function(n){return n!==e}),a.fire=a.subscribers.reduce(i,r)}};return n[e]=t[e]=a,a}aG(e).forEach(function(n){var t=e[n];if(aU(t))o(n,e[n][0],e[n][1]);else{if("asap"!==t)throw new sE.InvalidArgument("Invalid event config");var i=o(n,sz,function(){for(var e=arguments.length,n=Array(e);e--;)n[e]=arguments[e];i.subscribers.forEach(function(e){a6(function(){e.apply(null,n)})})})}})}}function lH(e,n){return aQ(n).from({prototype:e}),n}function lq(e,n){return!(e.filter||e.algorithm||e.or)&&(n?e.justLimit:!e.replayFilter)}function lK(e,n){e.filter=lL(e.filter,n)}function lY(e,n,t){var i=e.replayFilter;e.replayFilter=i?()=>lL(i(),n()):n,e.justLimit=t&&!i}function lJ(e,n){if(e.isPrimKey)return n.primaryKey;let t=n.getIndexByKeyPath(e.index);if(!t)throw new sE.Schema("KeyPath "+e.index+" on object store "+n.name+" is not indexed");return t}function lZ(e,n,t){let i=lJ(e,n.schema);return n.openCursor({trans:t,values:!e.keysOnly,reverse:"prev"===e.dir,unique:!!e.unique,query:{index:i,range:e.range}})}function lX(e,n,t,i){let r=e.replayFilter?lL(e.filter,e.replayFilter()):e.filter;if(e.or){let o={},a=(e,t,i)=>{if(!r||r(t,i,e=>t.stop(e),e=>t.fail(e))){var a=t.primaryKey,s=""+a;"[object ArrayBuffer]"===s&&(s=""+new Uint8Array(a)),aY(o,s)||(o[s]=!0,n(e,t,i))}};return Promise.all([e.or._iterate(a,t),lQ(lZ(e,i,t),e.algorithm,a,!e.keysOnly&&e.valueMapper)])}return lQ(lZ(e,i,t),lL(e.algorithm,r),n,!e.keysOnly&&e.valueMapper)}function lQ(e,n,t,i){var r=lc(i?(e,n,r)=>t(i(e),n,r):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=sM},n=>{e.fail(n),t=sM})||r(e.value,e,e=>t=e),t()})})}function l0(e,n){try{let t=l1(e),i=l1(n);if(t!==i)return"Array"===t?1:"Array"===i?-1:"binary"===t?1:"binary"===i?-1:"string"===t?1:"string"===i?-1:"Date"===t?1:"Date"!==i?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,i=n.length,r=t<i?t:i;for(let t=0;t<r;++t)if(e[t]!==n[t])return e[t]<n[t]?-1:1;return t===i?0:t<i?-1:1}(l2(e),l2(n));case"Array":return function(e,n){let t=e.length,i=n.length,r=t<i?t:i;for(let t=0;t<r;++t){let i=l0(e[t],n[t]);if(0!==i)return i}return t===i?0:t<i?-1:1}(e,n)}}catch(e){}return NaN}function l1(e){let n=typeof e;if("object"!==n)return n;if(ArrayBuffer.isView(e))return"binary";let t=sl(e);return"ArrayBuffer"===t?"binary":t}function l2(e){return e instanceof Uint8Array?e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e)}class l3{_read(e,n){var t=this._ctx;return t.error?t.table._trans(null,lD.bind(null,t.error)):t.table._trans("readonly",e).then(n)}_write(e){var n=this._ctx;return n.error?n.table._trans(null,lD.bind(null,n.error)):n.table._trans("readwrite",e,"locked")}_addAlgorithm(e){var n=this._ctx;n.algorithm=lL(n.algorithm,e)}_iterate(e,n){return lX(this._ctx,e,n,this._ctx.table.core)}clone(e){var n=Object.create(this.constructor.prototype),t=Object.create(this._ctx);return e&&aH(t,e),n._ctx=t,n}raw(){return this._ctx.valueMapper=null,this}each(e){var n=this._ctx;return this._read(t=>lX(n,e,t,n.table.core))}count(e){return this._read(e=>{let n=this._ctx,t=n.table.core;if(lq(n,!0))return t.count({trans:e,query:{index:lJ(n,t.schema),range:n.range}}).then(e=>Math.min(e,n.limit));var i=0;return lX(n,()=>(++i,!1),e,t).then(()=>i)}).then(e)}sortBy(e,n){let t=e.split(".").reverse(),i=t[0],r=t.length-1;function o(e,n){return n?o(e[t[n]],n-1):e[i]}var a="next"===this._ctx.dir?1:-1;function s(e,n){var t=o(e,r),i=o(n,r);return t<i?-a:t>i?a: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&&lq(n,!0)&&n.limit>0){let{valueMapper:t}=n,i=lJ(n,n.table.core.schema);return n.table.core.query({trans:e,limit:n.limit,values:!0,query:{index:i,range:n.range}}).then(({result:e})=>t?e.map(t):e)}{let t=[];return lX(n,e=>t.push(e),e,n.table.core).then(()=>t)}},e)}offset(e){var n=this._ctx;return e<=0||(n.offset+=e,lq(n)?lY(n,()=>{var n=e;return(e,t)=>0===n||(1===n?--n:t(()=>{e.advance(n),n=0}),!1)}):lY(n,()=>{var n=e;return()=>--n<0})),this}limit(e){return this._ctx.limit=Math.min(this._ctx.limit,e),lY(this._ctx,()=>{var n=e;return function(e,t,i){return--n<=0&&t(i),n>=0}},!0),this}until(e,n){return lK(this._ctx,function(t,i,r){return!e(t.value)||(i(r),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 lK(this._ctx,function(n){return e(n.value)}),(n=this._ctx).isMatch=lL(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&&lq(n,!0)&&n.limit>0)return this._read(e=>{var t=lJ(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 lK(this._ctx,function(e){var n=e.primaryKey.toString(),i=aY(t,n);return t[n]=!0,!i}),this}modify(e){var n=this._ctx;return this._write(t=>{var i;if("function"==typeof e)i=e;else{var r=aG(e),o=r.length;i=function(n){for(var t=!1,i=0;i<o;++i){var a=r[i],s=e[a];a7(n,a)!==s&&(a9(n,a,s),t=!0)}return t}}let a=n.table.core,{outbound:s,extractKey:l}=a.schema.primaryKey,c=this.db._options.modifyChunkSize||200,u=[],p=0,d=[],f=(e,n)=>{let{failures:t,numFailures:i}=n;for(let n of(p+=e-i,aG(t)))u.push(t[n])};return this.clone().primaryKeys().then(r=>{let o=u=>{let p=Math.min(c,r.length-u);return a.getMany({trans:t,keys:r.slice(u,u+p),cache:"immutable"}).then(d=>{let h=[],g=[],m=s?[]:null,b=[];for(let e=0;e<p;++e){let n=d[e],t={value:sa(n),primKey:r[u+e]};!1!==i.call(t,t.value,t)&&(null==t.value?b.push(r[u+e]):s||0===l0(l(n),l(t.value))?(g.push(t.value),s&&m.push(r[u+e])):(b.push(r[u+e]),h.push(t.value)))}let y=lq(n)&&n.limit===1/0&&("function"!=typeof e||e===l5)&&{index:n.index,range:n.range};return Promise.resolve(h.length>0&&a.mutate({trans:t,type:"add",values:h}).then(e=>{for(let n in e.failures)b.splice(parseInt(n),1);f(h.length,e)})).then(()=>(g.length>0||y&&"object"==typeof e)&&a.mutate({trans:t,type:"put",keys:m,values:g,criteria:y,changeSpec:"function"!=typeof e&&e}).then(e=>f(g.length,e))).then(()=>(b.length>0||y&&e===l5)&&a.mutate({trans:t,type:"delete",keys:b,criteria:y}).then(e=>f(b.length,e))).then(()=>r.length>u+p&&o(u+c))})};return o(0).then(()=>{if(u.length>0)throw new sk("Error modifying one or more objects",u,p,d);return r.length})})})}delete(){var e=this._ctx,n=e.range;return lq(e)&&(e.isPrimKey&&!lI||3===n.type)?this._write(t=>{let{primaryKey:i}=e.table.core.schema;return e.table.core.count({trans:t,query:{index:i,range:n}}).then(i=>e.table.core.mutate({trans:t,type:"deleteRange",range:n}).then(({failures:e,lastResult:n,results:t,numFailures:r})=>{if(r)throw new sk("Could not delete some values",Object.keys(e).map(n=>e[n]),i-r);return i-r}))}):this.modify(l5)}}let l5=(e,n)=>n.value=null;function l4(e,n){return e<n?-1:+(e!==n)}function l6(e,n){return e>n?-1:+(e!==n)}function l8(e,n,t){var i=e instanceof ct?new e.Collection(e):e;return i._ctx.error=t?new t(n):TypeError(n),i}function l7(e){return new e.Collection(e,()=>cn("")).limit(0)}function l9(e,n,t,i){var r,o,a,s,l,c,u,p=t.length;if(!t.every(e=>"string"==typeof e))return l8(e,lT);function d(e){r="next"===e?e=>e.toUpperCase():e=>e.toLowerCase(),o="next"===e?e=>e.toLowerCase():e=>e.toUpperCase(),a="next"===e?l4:l6;var n=t.map(function(e){return{lower:o(e),upper:r(e)}}).sort(function(e,n){return a(e.lower,n.lower)});s=n.map(function(e){return e.upper}),l=n.map(function(e){return e.lower}),c=e,u="next"===e?"":i}d("next");var f=new e.Collection(e,()=>ce(s[0],l[p-1]+i));f._ondirectionchange=function(e){d(e)};var h=0;return f._addAlgorithm(function(e,t,i){var r=e.key;if("string"!=typeof r)return!1;var d=o(r);if(n(d,l,h))return!0;for(var f=null,g=h;g<p;++g){var m=function(e,n,t,i,r,o){for(var a=Math.min(e.length,i.length),s=-1,l=0;l<a;++l){var c=n[l];if(c!==i[l])return 0>r(e[l],t[l])?e.substr(0,l)+t[l]+t.substr(l+1):0>r(e[l],i[l])?e.substr(0,l)+i[l]+t.substr(l+1):s>=0?e.substr(0,s)+n[s]+t.substr(s+1):null;0>r(e[l],c)&&(s=l)}return a<i.length&&"next"===o?e+t.substr(e.length):a<e.length&&"prev"===o?e.substr(0,t.length):s<0?null:e.substr(0,s)+i[s]+t.substr(s+1)}(r,d,s[g],l[g],a,c);null===m&&null===f?h=g+1:(null===f||a(f,m)>0)&&(f=m)}return t(null!==f?function(){e.continue(f+u)}:i),!1}),f}function ce(e,n,t,i){return{type:2,lower:e,upper:n,lowerOpen:t,upperOpen:i}}function cn(e){return{type:1,lower:e,upper:e}}class ct{get Collection(){return this._ctx.table.db.Collection}between(e,n,t,i){t=!1!==t,i=!0===i;try{return this._cmp(e,n)>0||0===this._cmp(e,n)&&(t||i)&&(!t||!i)?l7(this):new this.Collection(this,()=>ce(e,n,!t,!i))}catch(e){return l8(this,lP)}}equals(e){return null==e?l8(this,lP):new this.Collection(this,()=>cn(e))}above(e){return null==e?l8(this,lP):new this.Collection(this,()=>ce(e,void 0,!0))}aboveOrEqual(e){return null==e?l8(this,lP):new this.Collection(this,()=>ce(e,void 0,!1))}below(e){return null==e?l8(this,lP):new this.Collection(this,()=>ce(void 0,e,!1,!0))}belowOrEqual(e){return null==e?l8(this,lP):new this.Collection(this,()=>ce(void 0,e))}startsWith(e){return"string"!=typeof e?l8(this,lT):this.between(e,e+lz,!0,!0)}startsWithIgnoreCase(e){return""===e?this.startsWith(e):l9(this,(e,n)=>0===e.indexOf(n[0]),[e],lz)}equalsIgnoreCase(e){return l9(this,(e,n)=>e===n[0],[e],"")}anyOfIgnoreCase(){var e=sd.apply(sp,arguments);return 0===e.length?l7(this):l9(this,(e,n)=>-1!==n.indexOf(e),e,"")}startsWithAnyOfIgnoreCase(){var e=sd.apply(sp,arguments);return 0===e.length?l7(this):l9(this,(e,n)=>n.some(n=>0===e.indexOf(n)),e,lz)}anyOf(){let e=sd.apply(sp,arguments),n=this._cmp;try{e.sort(n)}catch(e){return l8(this,lP)}if(0===e.length)return l7(this);let t=new this.Collection(this,()=>ce(e[0],e[e.length-1]));t._ondirectionchange=t=>{n="next"===t?this._ascending:this._descending,e.sort(n)};let i=0;return t._addAlgorithm((t,r,o)=>{let a=t.key;for(;n(a,e[i])>0;)if(++i===e.length)return r(o),!1;return 0===n(a,e[i])||(r(()=>{t.continue(e[i])}),!1)}),t}notEqual(e){return this.inAnyRange([[lO,e],[e,this.db._maxKey]],{includeLowers:!1,includeUppers:!1})}noneOf(){let e=sd.apply(sp,arguments);if(0===e.length)return new this.Collection(this);try{e.sort(this._ascending)}catch(e){return l8(this,lP)}let n=e.reduce((e,n)=>e?e.concat([[e[e.length-1][1],n]]):[[lO,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,i=this._ascending,r=this._descending,o=this._min,a=this._max;if(0===e.length)return l7(this);if(!e.every(e=>void 0!==e[0]&&void 0!==e[1]&&0>=i(e[0],e[1])))return l8(this,"First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower",sE.InvalidArgument);let s=!n||!1!==n.includeLowers,l=n&&!0===n.includeUppers,c,u=i;function p(e,n){return u(e[0],n[0])}try{(c=e.reduce(function(e,n){let i=0,r=e.length;for(;i<r;++i){let r=e[i];if(0>t(n[0],r[1])&&t(n[1],r[0])>0){r[0]=o(r[0],n[0]),r[1]=a(r[1],n[1]);break}}return i===r&&e.push(n),e},[])).sort(p)}catch(e){return l8(this,lP)}let d=0,f=l?e=>i(e,c[d][1])>0:e=>i(e,c[d][1])>=0,h=s?e=>r(e,c[d][0])>0:e=>r(e,c[d][0])>=0,g=f,m=new this.Collection(this,()=>ce(c[0][0],c[c.length-1][1],!s,!l));return m._ondirectionchange=e=>{"next"===e?(g=f,u=i):(g=h,u=r),c.sort(p)},m._addAlgorithm((e,n,t)=>{for(var r=e.key;g(r);)if(++d===c.length)return n(t),!1;return!!(!f(r)&&!h(r))||(0===this._cmp(r,c[d][1])||0===this._cmp(r,c[d][0])||n(()=>{u===i?e.continue(c[d][0]):e.continue(c[d][1])}),!1)}),m}startsWithAnyOf(){let e=sd.apply(sp,arguments);return e.every(e=>"string"==typeof e)?0===e.length?l7(this):this.inAnyRange(e.map(e=>[e,e+lz])):l8(this,"startsWithAnyOf() only works with strings")}}function ci(e){return lc(function(n){return cr(n),e(n.target.error),!1})}function cr(e){e.stopPropagation&&e.stopPropagation(),e.preventDefault&&e.preventDefault()}let co="storagemutated",ca="x-storagemutated-1",cs=lU(null,co);class cl{_lock(){return a4(!s2.global),++this._reculock,1!==this._reculock||s2.global||(s2.lockOwnerFor=this),this}_unlock(){if(a4(!s2.global),0==--this._reculock)for(s2.global||(s2.lockOwnerFor=null);this._blockedFuncs.length>0&&!this._locked();){var e=this._blockedFuncs.shift();try{lk(e[1],e[0])}catch(e){}}return this}_locked(){return this._reculock&&s2.lockOwnerFor!==this}create(e){if(!this.mode)return this;let n=this.db.idbdb,t=this.db._state.dbOpenError;if(a4(!this.idbtrans),!e&&!n)switch(t&&t.name){case"DatabaseClosedError":throw new sE.DatabaseClosed(t);case"MissingAPIError":throw new sE.MissingAPI(t.message,t);default:throw new sE.OpenFailed(t)}if(!this.active)throw new sE.TransactionInactive;return a4(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=lc(n=>{cr(n),this._reject(e.error)}),e.onabort=lc(n=>{cr(n),this.active&&this._reject(new sE.Abort(e.error)),this.active=!1,this.on("abort").fire(n)}),e.oncomplete=lc(()=>{this.active=!1,this._resolve(),"mutatedParts"in e&&cs.storagemutated.fire(e.mutatedParts)}),this}_promise(e,n,t){if("readwrite"===e&&"readwrite"!==this.mode)return lD(new sE.ReadOnly("Transaction is readonly"));if(!this.active)return lD(new sE.TransactionInactive);if(this._locked())return new s6((i,r)=>{this._blockedFuncs.push([()=>{this._promise(e,n,t).then(i,r)},s2])});if(t)return lm(()=>{var e=new s6((e,t)=>{this._lock();let i=n(e,t,this);i&&i.then&&i.then(e,t)});return e.finally(()=>this._unlock()),e._lib=!0,e});var i=new s6((e,t)=>{var i=n(e,t,this);i&&i.then&&i.then(e,t)});return i._lib=!0,i}_root(){return this.parent?this.parent._root():this}waitFor(e){var n=this._root();let t=s6.resolve(e);if(n._waitingFor)n._waitingFor=n._waitingFor.then(()=>t);else{n._waitingFor=t,n._waitingQueue=[];var i=n.idbtrans.objectStore(n.storeNames[0]);!function e(){for(++n._spinCount;n._waitingQueue.length;)n._waitingQueue.shift()();n._waitingFor&&(i.get(-1/0).onsuccess=e)}()}var r=n._waitingFor;return new s6((e,i)=>{t.then(t=>n._waitingQueue.push(lc(e.bind(null,t))),e=>n._waitingQueue.push(lc(i.bind(null,e)))).finally(()=>{n._waitingFor===r&&(n._waitingFor=null)})})}abort(){this.active&&(this.active=!1,this.idbtrans&&this.idbtrans.abort(),this._reject(new sE.Abort))}table(e){let n=this._memoizedTables||(this._memoizedTables={});if(aY(n,e))return n[e];let t=this.schema[e];if(!t)throw new sE.NotFound("Table "+e+" not part of transaction");let i=new this.db.Table(e,t,this);return i.core=this.db.core.table(e),n[e]=i,i}}function cc(e,n,t,i,r,o,a){return{name:e,keyPath:n,unique:t,multi:i,auto:r,compound:o,src:(t&&!a?"&":"")+(i?"*":"")+(r?"++":"")+cu(n)}}function cu(e){return"string"==typeof e?e:e?"["+[].join.call(e,"+")+"]":""}function cp(e,n,t){return{name:e,primKey:n,indexes:t,mappedClass:null,idxByName:a8(t,e=>[e.name,e])}}let cd=e=>{try{return e.only([[]]),cd=()=>[[]],[[]]}catch(e){return cd=()=>lz,lz}};function cf(e){return null==e?()=>{}:"string"==typeof e?1===e.split(".").length?n=>n[e]:n=>a7(n,e):n=>a7(n,e)}function ch(e){return[].slice.call(e)}let cg=0;function cm(e){return null==e?":id":"string"==typeof e?e:`[${e.join("+")}]`}function cb({_novip:e},n){let t=n.db,i=function(e,n,{IDBKeyRange:t,indexedDB:i},r){var o;return{dbcore:(o=function(e,n,t){let i;function r(e){if(3===e.type)return null;if(4===e.type)throw Error("Cannot convert never type to IDBKeyRange");let{lower:t,upper:i,lowerOpen:r,upperOpen:o}=e;return void 0===t?void 0===i?null:n.upperBound(i,!!o):void 0===i?n.lowerBound(t,!!r):n.bound(t,i,!!r,!!o)}let{schema:o,hasGetAll:a}=(i=ch(e.objectStoreNames),{schema:{name:e.name,tables:i.map(e=>t.objectStore(e)).map(e=>{let{keyPath:n,autoIncrement:t}=e,i=aU(n),r=null==n,o={},a={name:e.name,primaryKey:{name:null,isPrimaryKey:!0,outbound:r,compound:i,keyPath:n,autoIncrement:t,unique:!0,extractKey:cf(n)},indexes:ch(e.indexNames).map(n=>e.index(n)).map(e=>{let{name:n,unique:t,multiEntry:i,keyPath:r}=e,a={name:n,compound:aU(r),keyPath:r,unique:t,multiEntry:i,extractKey:cf(r)};return o[cm(r)]=a,a}),getIndexByKeyPath:e=>o[cm(e)]};return o[":id"]=a.primaryKey,null!=n&&(o[cm(n)]=a.primaryKey),a})},hasGetAll:i.length>0&&"getAll"in t.objectStore(i[0])&&!("u">typeof navigator&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604)}),s=o.tables.map(e=>{let n;return{name:n=e.name,schema:e,mutate:function({trans:e,type:t,keys:i,values:o,range:a}){return new Promise((s,l)=>{let c;s=lc(s);let u=e.objectStore(n),p=null==u.keyPath,d="put"===t||"add"===t;if(!d&&"delete"!==t&&"deleteRange"!==t)throw Error("Invalid operation type: "+t);let{length:f}=i||o||{length:1};if(i&&o&&i.length!==o.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=[],g=[],m=0,b=e=>{++m,cr(e)};if("deleteRange"===t){if(4===a.type)return s({numFailures:m,failures:g,results:[],lastResult:void 0});3===a.type?h.push(c=u.clear()):h.push(c=u.delete(r(a)))}else{let[e,n]=d?p?[o,i]:[o,null]:[i,null];if(d)for(let i=0;i<f;++i)h.push(c=n&&void 0!==n[i]?u[t](e[i],n[i]):u[t](e[i])),c.onerror=b;else for(let n=0;n<f;++n)h.push(c=u[t](e[n])),c.onerror=b}let y=e=>{let n=e.target.result;h.forEach((e,n)=>null!=e.error&&(g[n]=e.error)),s({numFailures:m,failures:g,results:"delete"===t?i:h.map(e=>e.result),lastResult:n})};c.onerror=e=>{b(e),y(e)},c.onsuccess=y})},getMany:({trans:e,keys:t})=>new Promise((i,r)=>{i=lc(i);let o=e.objectStore(n),a=t.length,s=Array(a),l,c=0,u=0,p=e=>{let n=e.target;s[n._pos]=n.result,++u===c&&i(s)},d=ci(r);for(let e=0;e<a;++e)null!=t[e]&&((l=o.get(t[e]))._pos=e,l.onsuccess=p,l.onerror=d,++c);0===c&&i(s)}),get:({trans:e,key:t})=>new Promise((i,r)=>{i=lc(i);let o=e.objectStore(n).get(t);o.onsuccess=e=>i(e.target.result),o.onerror=ci(r)}),query:e=>new Promise((t,i)=>{t=lc(t);let{trans:o,values:s,limit:l,query:c}=e,u=l===1/0?void 0:l,{index:p,range:d}=c,f=o.objectStore(n),h=p.isPrimaryKey?f:f.index(p.name),g=r(d);if(0===l)return t({result:[]});if(a){let e=s?h.getAll(g,u):h.getAllKeys(g,u);e.onsuccess=e=>t({result:e.target.result}),e.onerror=ci(i)}else{let e=0,n=!s&&"openKeyCursor"in h?h.openKeyCursor(g):h.openCursor(g),r=[];n.onsuccess=i=>{let o=n.result;return o?(r.push(s?o.value:o.primaryKey),++e===l?t({result:r}):void o.continue()):t({result:r})},n.onerror=ci(i)}}),openCursor:function({trans:e,values:t,query:i,reverse:o,unique:a}){return new Promise((s,l)=>{s=lc(s);let{index:c,range:u}=i,p=e.objectStore(n),d=c.isPrimaryKey?p:p.index(c.name),f=o?a?"prevunique":"prev":a?"nextunique":"next",h=!t&&"openKeyCursor"in d?d.openKeyCursor(r(u),f):d.openCursor(r(u),f);h.onerror=ci(l),h.onsuccess=lc(n=>{let t=h.result;if(!t)return void s(null);t.___id=++cg,t.done=!1;let i=t.continue.bind(t),r=t.continuePrimaryKey;r&&(r=r.bind(t));let o=t.advance.bind(t),a=()=>{throw Error("Cursor not stopped")};t.trans=e,t.stop=t.continue=t.continuePrimaryKey=t.advance=()=>{throw Error("Cursor not started")},t.fail=lc(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=lc(e),h.onerror=ci(n),t.fail=n,t.stop=n=>{t.stop=t.continue=t.continuePrimaryKey=t.advance=a,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=lc(e=>{h.onsuccess=s,s()}),t.continue=i,t.continuePrimaryKey=r,t.advance=o,s(),n},s(t)},l)})},count({query:e,trans:t}){let{index:i,range:o}=e;return new Promise((e,a)=>{let s=t.objectStore(n),l=i.isPrimaryKey?s:s.index(i.name),c=r(o),u=c?l.count(c):l.count();u.onsuccess=lc(n=>e(n.target.result)),u.onerror=ci(a)})}}}),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:cd(n),schema:o}}(n,t,r),e.dbcore.reduce((e,{create:n})=>({...e,...n(e)}),o))}}(e._middlewares,t,e._deps,n);e.core=i.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 cy({_novip:e},n,t,i){t.forEach(t=>{let r=i[t];n.forEach(n=>{let i=a1(n,t);(!i||"value"in i&&void 0===i.value)&&(n===e.Transaction.prototype||n instanceof e.Transaction?aX(n,t,{get(){return this.table(t)},set(e){aZ(this,t,{value:e,writable:!0,configurable:!0,enumerable:!0})}}):n[t]=new e.Table(t,r))})})}function c_({_novip:e},n){n.forEach(n=>{for(let t in n)n[t]instanceof e.Table&&delete n[t]})}function cv(e,n){return e._cfg.version-n._cfg.version}function c$(e,n){let t,i={del:[],add:[],change:[]};for(t in e)n[t]||i.del.push(t);for(t in n){let r=e[t],o=n[t];if(r){let e={name:t,def:o,recreate:!1,del:[],add:[],change:[]};if(""+(r.primKey.keyPath||"")==""+(o.primKey.keyPath||"")&&(r.primKey.auto===o.primKey.auto||lI)){let n,t=r.idxByName,a=o.idxByName;for(n in t)a[n]||e.del.push(n);for(n in a){let i=t[n],r=a[n];i?i.src!==r.src&&e.change.push(r):e.add.push(r)}(e.del.length>0||e.add.length>0||e.change.length>0)&&i.change.push(e)}else e.recreate=!0,i.change.push(e)}else i.add.push([t,o])}return i}function cA(e,n,t,i){let r=e.db.createObjectStore(n,t.keyPath?{keyPath:t.keyPath,autoIncrement:t.auto}:{autoIncrement:t.auto});return i.forEach(e=>cw(r,e)),r}function cw(e,n){e.createIndex(n.name,n.keyPath,{unique:n.unique,multiEntry:n.multi})}function ck(e,n,t){let i={};return a3(n.objectStoreNames,0).forEach(e=>{let n=t.objectStore(e),r=n.keyPath,o=cc(cu(r),r||"",!1,!1,!!n.autoIncrement,r&&"string"!=typeof r,!0),a=[];for(let e=0;e<n.indexNames.length;++e){let t=n.index(n.indexNames[e]);r=t.keyPath;var s=cc(t.name,r,!!t.unique,!!t.multiEntry,!1,r&&"string"!=typeof r,!1);a.push(s)}i[e]=cp(e,o,a)}),i}function cx({_novip:e},n,t){let i=t.db.objectStoreNames;for(let r=0;r<i.length;++r){let o=i[r],a=t.objectStore(o);e._hasGetAll="getAll"in a;for(let e=0;e<a.indexNames.length;++e){let t=a.indexNames[e],i=a.index(t).keyPath,r="string"==typeof i?i:"["+a3(i).join("+")+"]";if(n[o]){let e=n[o].idxByName[r];e&&(e.name=t,delete n[o].idxByName[r],n[o].idxByName[t]=e)}}}"u">typeof navigator&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&aV.WorkerGlobalScope&&aV instanceof aV.WorkerGlobalScope&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604&&(e._hasGetAll=!1)}class cC{_parseStoresSpec(e,n){aG(e).forEach(t=>{if(null!==e[t]){var i=e[t].split(",").map((e,n)=>{let t=(e=e.trim()).replace(/([&*]|\+\+)/g,""),i=/^\[/.test(t)?t.match(/^\[(.*)\]$/)[1].split("+"):t;return cc(t,i||null,/\&/.test(e),/\*/.test(e),/\+\+/.test(e),aU(i),0===n)}),r=i.shift();if(r.multi)throw new sE.Schema("Primary key cannot be multi-valued");i.forEach(e=>{if(e.auto)throw new sE.Schema("Only primary key can be marked as autoIncrement (++)");if(!e.keyPath)throw new sE.Schema("Index must have a name and cannot be an empty string")}),n[t]=cp(t,r,i)}})}stores(e){let n=this.db;this._cfg.storesSource=this._cfg.storesSource?aH(this._cfg.storesSource,e):e;let t=n._versions,i={},r={};return t.forEach(e=>{aH(i,e._cfg.storesSource),r=e._cfg.dbschema={},e._parseStoresSpec(i,r)}),n._dbSchema=r,c_(n,[n._allTables,n,n.Transaction.prototype]),cy(n,[n._allTables,n,n.Transaction.prototype,this._cfg.tables],aG(r),r),n._storeNames=aG(r),this}upgrade(e){return this._cfg.contentUpgrade=sj(this._cfg.contentUpgrade||sM,e),this}}function cE(e,n){let t=e._dbNamesDB;return t||(t=e._dbNamesDB=new cH(lj,{addons:[],indexedDB:e,IDBKeyRange:n})).version(1).stores({dbnames:"name"}),t.table("dbnames")}function cS(e){return e&&"function"==typeof e.databases}function cD(e){return lm(function(){return s2.letThrough=!0,e()})}function cM(e){var n=n=>e.next(n),t=r(n),i=r(n=>e.throw(n));function r(e){return n=>{var r=e(n),o=r.value;return r.done?o:o&&"function"==typeof o.then?o.then(t,i):aU(o)?Promise.all(o).then(t,i):t(o)}}return r(n)()}function cz(e,n,t){var i=arguments.length;if(i<2)throw new sE.InvalidArgument("Too few arguments");for(var r=Array(i-1);--i;)r[i-1]=arguments[i];return t=r.pop(),[e,st(r),t]}function cO(e,n,t){let i=aU(e)?e.slice():[e];for(let e=0;e<t;++e)i.push(n);return i}let cP={stack:"dbcore",name:"VirtualIndexMiddleware",level:1,create:function(e){return{...e,table(n){let t=e.table(n),{schema:i}=t,r={},o=[];function a(e,n,t){let i=cm(e),s=r[i]=r[i]||[],l=null==e?0:"string"==typeof e?1:e.length,c=n>0,u={...t,isVirtual:c,keyTail:n,keyLength:l,extractKey:cf(e),unique:!c&&t.unique};return s.push(u),u.isPrimaryKey||o.push(u),l>1&&a(2===l?e[0]:e.slice(0,l-1),n+1,t),s.sort((e,n)=>e.keyTail-n.keyTail),u}let s=a(i.primaryKey.keyPath,0,i.primaryKey);for(let e of(r[":id"]=[s],i.indexes))a(e.keyPath,0,e);function l(n){var t,i;let r=n.query.index;return r.isVirtual?{...n,query:{index:r,range:(t=n.query.range,i=r.keyTail,{type:1===t.type?2:t.type,lower:cO(t.lower,t.lowerOpen?e.MAX_KEY:e.MIN_KEY,i),lowerOpen:!0,upper:cO(t.upper,t.upperOpen?e.MIN_KEY:e.MAX_KEY,i),upperOpen:!0})}}:n}return{...t,schema:{...i,primaryKey:s,indexes:o,getIndexByKeyPath:function(e){let n=r[cm(e)];return n&&n[0]}},count:e=>t.count(l(e)),query:e=>t.query(l(e)),openCursor(n){let{keyTail:i,isVirtual:r,keyLength:o}=n.query.index;return r?t.openCursor(l(n)).then(t=>t&&Object.create(t,{continue:{value:function(r){null!=r?t.continue(cO(r,n.reverse?e.MAX_KEY:e.MIN_KEY,i)):n.unique?t.continue(t.key.slice(0,o).concat(n.reverse?e.MIN_KEY:e.MAX_KEY,i)):t.continue()}},continuePrimaryKey:{value(n,r){t.continuePrimaryKey(cO(n,e.MAX_KEY,i),r)}},primaryKey:{get:()=>t.primaryKey},key:{get(){let e=t.key;return 1===o?e[0]:e.slice(0,o)}},value:{get:()=>t.value}})):t.openCursor(n)}}}}}};function cT(e,n,t,i){return t=t||{},i=i||"",aG(e).forEach(r=>{if(aY(n,r)){var o=e[r],a=n[r];if("object"==typeof o&&"object"==typeof a&&o&&a){let e=sl(o);e!==sl(a)?t[i+r]=n[r]:"Object"===e?cT(o,a,t,i+r+"."):o!==a&&(t[i+r]=n[r])}else o!==a&&(t[i+r]=n[r])}else t[i+r]=void 0}),aG(n).forEach(r=>{aY(e,r)||(t[i+r]=n[r])}),t}let cB={stack:"dbcore",name:"HooksMiddleware",level:2,create:e=>({...e,table(n){let t=e.table(n),{primaryKey:i}=t.schema;return{...t,mutate(e){let r=s2.trans,{deleting:o,creating:a,updating:s}=r.table(n).hook;switch(e.type){case"add":if(a.fire===sM)break;return r._promise("readwrite",()=>l(e),!0);case"put":if(a.fire===sM&&s.fire===sM)break;return r._promise("readwrite",()=>l(e),!0);case"delete":if(o.fire===sM)break;return r._promise("readwrite",()=>l(e),!0);case"deleteRange":if(o.fire===sM)break;return r._promise("readwrite",()=>(function e(n,r,o){return t.query({trans:n,values:!1,query:{index:i,range:r},limit:o}).then(({result:t})=>l({type:"delete",keys:t,trans:n}).then(i=>i.numFailures>0?Promise.reject(i.failures[0]):t.length<o?{failures:[],numFailures:0,lastResult:void 0}:e(n,{...r,lower:t[t.length-1],lowerOpen:!0},o)))})(e.trans,e.range,1e4),!0)}return t.mutate(e);function l(e){var n,r;let l=s2.trans,c=e.keys||("delete"===(n=e).type?n.keys:n.keys||n.values.map(i.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"===(r=e).type?Promise.resolve([]):t.getMany({trans:r.trans,keys:c,cache:"immutable"})).then(n=>{let r=c.map((t,r)=>{let c=n[r],u={onerror:null,onsuccess:null};if("delete"===e.type)o.fire.call(u,t,c,l);else if("add"===e.type||void 0===c){let n=a.fire.call(u,t,e.values[r],l);null==t&&null!=n&&(t=n,e.keys[r]=t,i.outbound||a9(e.values[r],i.keyPath,t))}else{let n=cT(c,e.values[r]),i=s.fire.call(u,n,t,c,l);if(i){let n=e.values[r];Object.keys(i).forEach(e=>{aY(n,e)?n[e]=i[e]:a9(n,e,i[e])})}}return u});return t.mutate(e).then(({failures:t,results:i,numFailures:o,lastResult:a})=>{for(let o=0;o<c.length;++o){let a=i?i[o]:c[o],s=r[o];null==a?s.onerror&&s.onerror(t[o]):s.onsuccess&&s.onsuccess("put"===e.type&&n[o]?e.values[o]:a)}return{failures:t,results:i,numFailures:o,lastResult:a}}).catch(e=>(r.forEach(n=>n.onerror&&n.onerror(e)),Promise.reject(e)))})}}}}})};function cI(e,n,t){try{if(!n||n.keys.length<e.length)return null;let i=[];for(let r=0,o=0;r<n.keys.length&&o<e.length;++r)0===l0(n.keys[r],e[o])&&(i.push(t?sa(n.values[r]):n.values[r]),++o);return i.length===e.length?i:null}catch(e){return null}}let cN={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=cI(e.keys,e.trans._cache,"clone"===e.cache);return n?s6.resolve(n):t.getMany(e).then(n=>(e.trans._cache={keys:e.keys,values:"clone"===e.cache?sa(n):n},n))},mutate:e=>("add"!==e.type&&(e.trans._cache=null),t.mutate(e))}}})};function cj(e){return!("from"in e)}let cR=function(e,n){if(!this){let n=new cR;return e&&"d"in e&&aH(n,e),n}aH(this,arguments.length?{d:1,from:e,to:arguments.length>1?n:e}:{d:0})};function cF(e,n,t){let i=l0(n,t);if(isNaN(i))return;if(i>0)throw RangeError();if(cj(e))return aH(e,{from:n,to:t,d:1});let r=e.l,o=e.r;if(0>l0(t,e.from))return r?cF(r,n,t):e.l={from:n,to:t,d:1,l:null,r:null},cV(e);if(l0(n,e.to)>0)return o?cF(o,n,t):e.r={from:n,to:t,d:1,l:null,r:null},cV(e);0>l0(n,e.from)&&(e.from=n,e.l=null,e.d=o?o.d+1:1),l0(t,e.to)>0&&(e.to=t,e.r=null,e.d=e.l?e.l.d+1:1);let a=!e.r;r&&!e.l&&cL(e,r),o&&a&&cL(e,o)}function cL(e,n){cj(n)||function e(n,{from:t,to:i,l:r,r:o}){cF(n,t,i),r&&e(n,r),o&&e(n,o)}(e,n)}function cW(e){let n=cj(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>l0(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>=l0(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 cV(e){var n,t;let i=((null==(n=e.r)?void 0:n.d)||0)-((null==(t=e.l)?void 0:t.d)||0),r=i>1?"r":i<-1?"l":"";if(r){let n="r"===r?"l":"r",t={...e},i=e[r];e.from=i.from,e.to=i.to,e[r]=i[r],t[r]=i[n],e[n]=t,t.d=cG(t)}e.d=cG(e)}function cG({r:e,l:n}){return(e?n?Math.max(e.d,n.d):e.d:n?n.d:0)+1}aJ(cR.prototype,{add(e){return cL(this,e),this},addKey(e){return cF(this,e,e),this},addKeys(e){return e.forEach(e=>cF(this,e,e)),this},[sc](){return cW(this)}});let cU={stack:"dbcore",level:0,create:e=>{let n=e.schema.name,t=new cR(e.MIN_KEY,e.MAX_KEY);return{...e,table:i=>{let r=e.table(i),{schema:o}=r,{primaryKey:a}=o,{extractKey:s,outbound:l}=a,c={...r,mutate:e=>{let a=e.trans,s=a.mutatedParts||(a.mutatedParts={}),l=e=>{let t=`idb://${n}/${i}/${e}`;return s[t]||(s[t]=new cR)},c=l(""),u=l(":dels"),{type:p}=e,[d,f]="deleteRange"===e.type?[e.range]:"delete"===e.type?[e.keys]:e.values.length<50?[[],e.values]:[],h=e.trans._cache;return r.mutate(e).then(e=>{if(aU(d)){"delete"!==p&&(d=e.results),c.addKeys(d);let n=cI(d,h);n||"add"===p||u.addKeys(d),(n||f)&&o.indexes.forEach(function(e){let t=l(e.name||"");function i(n){return null!=n?e.extractKey(n):null}let r=n=>e.multiEntry&&aU(n)?n.forEach(e=>t.addKey(e)):t.addKey(n);(n||f).forEach((e,t)=>{let o=n&&i(n[t]),a=f&&i(f[t]);0!==l0(o,a)&&(null!=o&&r(o),null!=a&&r(a))})})}else if(d){let e={from:d.lower,to:d.upper};u.add(e),c.add(e)}else c.add(t),u.add(t),o.indexes.forEach(e=>l(e.name).add(t));return e})}},u=({query:{index:n,range:t}})=>{var i,r;return[n,new cR(null!=(i=t.lower)?i:e.MIN_KEY,null!=(r=t.upper)?r:e.MAX_KEY)]},p={get:e=>[a,new cR(e.key)],getMany:e=>[a,(new cR).addKeys(e.keys)],count:u,query:u,openCursor:u};return aG(p).forEach(e=>{c[e]=function(o){let{subscr:a}=s2;if(a){let c=e=>{let t=`idb://${n}/${i}/${e}`;return a[t]||(a[t]=new cR)},u=c(""),d=c(":dels"),[f,h]=p[e](o);if(c(f.name||"").add(h),!f.isPrimaryKey){if("count"!==e){let n="query"===e&&l&&o.values&&r.query({...o,values:!1});return r[e].apply(this,arguments).then(t=>{if("query"===e){if(l&&o.values)return n.then(({result:e})=>(u.addKeys(e),t));let e=o.values?t.result.map(s):t.result;o.values?u.addKeys(e):d.addKeys(e)}else if("openCursor"===e){let e=o.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&&u.addKey(t.primaryKey),t.value)}})}return t})}d.add(t)}}return r[e].apply(this,arguments)}}),c}}}};class cH{constructor(e,n){var t;this._middlewares={},this.verno=0;const i=cH.dependencies;this._options=n={addons:cH.addons,autoOpen:!0,indexedDB:i.indexedDB,IDBKeyRange:i.IDBKeyRange,...n},this._deps={indexedDB:n.indexedDB,IDBKeyRange:n.IDBKeyRange};const{addons:r}=n;this._dbSchema={},this._versions=[],this._storeNames=[],this._allTables={},this.idbdb=null,this._novip=this;const o={dbOpenError:null,isBeingOpened:!1,onReadyBeingFired:null,openComplete:!1,dbReadyResolve:sM,dbReadyPromise:null,cancelOpen:sM,openCanceller:null,autoSchema:!0,PR1398_maxLoop:3};o.dbReadyPromise=new s6(e=>{o.dbReadyResolve=e}),o.openCanceller=new s6((e,n)=>{o.cancelOpen=n}),this._state=o,this.name=e,this.on=lU(this,"populate","blocked","versionchange","close",{ready:[sj,sM]}),this.on.ready.subscribe=a5(this.on.ready.subscribe,e=>(n,t)=>{cH.vip(()=>{let i=this._state;if(i.openComplete)i.dbOpenError||s6.resolve().then(n),t&&e(n);else if(i.onReadyBeingFired)i.onReadyBeingFired.push(n),t&&e(n);else{e(n);let i=this;t||e(function e(){i.on.ready.unsubscribe(n),i.on.ready.unsubscribe(e)})}})}),this.Collection=(t=this,lH(l3.prototype,function(e,n){this.db=t;let i=lW,r=null;if(n)try{i=n()}catch(e){r=e}let o=e._ctx,a=o.table,s=a.hook.reading.fire;this._ctx={table:a,index:o.index,isPrimKey:!o.index||a.schema.primKey.keyPath&&o.index===a.schema.primKey.name,range:i,keysOnly:!1,dir:"next",unique:"",algorithm:null,filter:null,replayFilter:null,justLimit:!0,isMatch:null,offset:0,limit:1/0,error:r,or:o.or,valueMapper:s!==sz?s:null}})),this.Table=function(e){return lH(lG.prototype,function(n,t,i){this.db=e,this._tx=i,this.name=n,this.schema=t,this.hook=e._allTables[n]?e._allTables[n].hook:lU(null,{creating:[sT,sM],reading:[sO,sz],updating:[sI,sM],deleting:[sB,sM]})})}(this),this.Transaction=function(e){return lH(cl.prototype,function(n,t,i,r,o){this.db=e,this.mode=n,this.storeNames=t,this.schema=i,this.chromeTransactionDurability=r,this.idbtrans=null,this.on=lU(this,"complete","error","abort"),this.parent=o||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 s6((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(),lD(e)})})}(this),this.Version=function(e){return lH(cC.prototype,function(n){this.db=e,this._cfg={version:n,storesSource:null,dbschema:{},tables:{},contentUpgrade:null}})}(this),this.WhereClause=function(e){return lH(ct.prototype,function(n,t,i){this.db=e,this._ctx={table:n,index:":id"===t?null:t,or:i};let r=e._deps.indexedDB;if(!r)throw new sE.MissingAPI;this._cmp=this._ascending=r.cmp.bind(r),this._descending=(e,n)=>r.cmp(n,e),this._max=(e,n)=>r.cmp(e,n)>0?e:n,this._min=(e,n)=>0>r.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=cd(n.IDBKeyRange),this._createTransaction=(e,n,t,i)=>new this.Transaction(e,n,t,this._options.chromeTransactionDurability,i),this._fireOnBlocked=e=>{this.on("blocked").fire(e),lB.filter(e=>e.name===this.name&&e!==this&&!e._state.vcFired).map(n=>n.on("versionchange").fire(e))},this.use(cP),this.use(cB),this.use(cU),this.use(cN),this.vip=Object.create(this,{_vip:{value:!0}}),r.forEach(e=>e(this))}version(e){if(isNaN(e)||e<.1)throw new sE.Type("Given version is not a positive number");if(e=Math.round(10*e)/10,this.idbdb||this._state.isBeingOpened)throw new sE.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(cv),t.stores({}),this._state.autoSchema=!1,t)}_whenReady(e){return this.idbdb&&(this._state.openComplete||s2.letThrough||this._vip)?e():new s6((e,n)=>{if(this._state.openComplete)return n(new sE.DatabaseClosed(this._state.dbOpenError));if(!this._state.isBeingOpened){if(!this._options.autoOpen)return void n(new sE.DatabaseClosed);this.open().catch(sM)}this._state.dbReadyPromise.then(e,n)}).then(e)}use({stack:e,create:n,level:t,name:i}){i&&this.unuse({stack:e,name:i});let r=this._middlewares[e]||(this._middlewares[e]=[]);return r.push({stack:e,create:n,level:null==t?10:t,name:i}),r.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:i}=e._deps;if(t.isBeingOpened||e.idbdb)return t.dbReadyPromise.then(()=>t.dbOpenError?lD(t.dbOpenError):e);sh&&(t.openCanceller._stackHolder=sb()),t.isBeingOpened=!0,t.dbOpenError=null,t.openComplete=!1;let r=t.openCanceller;function o(){if(t.openCanceller!==r)throw new sE.DatabaseClosed("db.open() was cancelled")}let a=t.dbReadyResolve,s=null,l=!1;return s6.race([r,("u"<typeof navigator?s6.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 s6((n,r)=>{if(o(),!i)throw new sE.MissingAPI;let a=e.name,c=t.autoSchema?i.open(a):i.open(a,Math.round(10*e.verno));if(!c)throw new sE.MissingAPI;c.onerror=ci(r),c.onblocked=lc(e._fireOnBlocked),c.onupgradeneeded=lc(n=>{if(s=c.transaction,t.autoSchema&&!e._options.allowEmptyDB){c.onerror=cr,s.abort(),c.result.close();let e=i.deleteDatabase(a);e.onsuccess=e.onerror=lc(()=>{r(new sE.NoSuchDatabase(`Database ${a} doesnt exist`))})}else{let t,i,a,d;s.onerror=ci(r);var o,u,p=n.oldVersion>0x4000000000000000?0:n.oldVersion;l=p<1,e._novip.idbdb=c.result,o=p/10,u=s,t=e._dbSchema,(i=e._createTransaction("readwrite",e._storeNames,t)).create(u),i._completion.catch(r),a=i._reject.bind(i),d=s2.transless||s2,lm(()=>{s2.trans=i,s2.transless=d,0===o?(aG(t).forEach(e=>{cA(u,e,t[e].primKey,t[e].indexes)}),cb(e,u),s6.follow(()=>e.on.populate.fire(i)).catch(a)):(function({_novip:e},n,t,i){let r=[],o=e._versions,a=e._dbSchema=ck(e,e.idbdb,i),s=!1;return o.filter(e=>e._cfg.version>=n).forEach(o=>{r.push(()=>{let r=a,l=o._cfg.dbschema;cx(e,r,i),cx(e,l,i),a=e._dbSchema=l;let c=c$(r,l);c.add.forEach(e=>{cA(i,e[0],e[1].primKey,e[1].indexes)}),c.change.forEach(e=>{if(e.recreate)throw new sE.Upgrade("Not yet support for changing primary key");{let n=i.objectStore(e.name);e.add.forEach(e=>cw(n,e)),e.change.forEach(e=>{n.deleteIndex(e.name),cw(n,e)}),e.del.forEach(e=>n.deleteIndex(e))}});let u=o._cfg.contentUpgrade;if(u&&o._cfg.version>n){let n;cb(e,i),t._memoizedTables={},s=!0;let o=se(l);c.del.forEach(e=>{o[e]=r[e]}),c_(e,[e.Transaction.prototype]),cy(e,[e.Transaction.prototype],aG(o),o),t.schema=o;let a=sf(u);a&&lb();let p=s6.follow(()=>{if((n=u(t))&&a){var e=ly.bind(null,null);n.then(e,e)}});return n&&"function"==typeof n.then?s6.resolve(n):p.then(()=>n)}}),r.push(n=>{var i;s&&lI||(i=o._cfg.dbschema,[].slice.call(n.db.objectStoreNames).forEach(e=>null==i[e]&&n.db.deleteObjectStore(e))),c_(e,[e.Transaction.prototype]),cy(e,[e.Transaction.prototype],e._storeNames,e._dbSchema),t.schema=e._dbSchema})}),(function e(){return r.length?s6.resolve(r.shift()(t.idbtrans)).then(e):s6.resolve()})().then(()=>{var e;aG(e=a).forEach(n=>{i.db.objectStoreNames.contains(n)||cA(i,n,e[n].primKey,e[n].indexes)})})})(e,o,i,u).catch(a)})}},r),c.onsuccess=lc(()=>{s=null;let i=e._novip.idbdb=c.result,r=a3(i.objectStoreNames);if(r.length>0)try{let n,o=i.transaction(1===r.length?r[0]:r,"readonly");t.autoSchema?function({_novip:e},n,t){e.verno=n.version/10;let i=e._dbSchema=ck(0,n,t);e._storeNames=a3(n.objectStoreNames,0),cy(e,[e._allTables],aG(i),i)}(e,i,o):(cx(e,e._dbSchema,o),((n=c$(ck(0,e.idbdb,o),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.")),cb(e,o)}catch(e){}lB.push(e),i.onversionchange=lc(n=>{t.vcFired=!0,e.on("versionchange").fire(n)}),i.onclose=lc(n=>{e.on("close").fire(n)}),l&&function({indexedDB:e,IDBKeyRange:n},t){cS(e)||t===lj||cE(e,n).put({name:t}).catch(sM)}(e._deps,a),n()},r)}))]).then(()=>(o(),t.onReadyBeingFired=[],s6.resolve(cD(()=>e.on.ready.fire(e.vip))).then(function n(){if(t.onReadyBeingFired.length>0){let i=t.onReadyBeingFired.reduce(sj,sM);return t.onReadyBeingFired=[],s6.resolve(cD(()=>i(e.vip))).then(n)}}))).finally(()=>{t.onReadyBeingFired=null,t.isBeingOpened=!1}).then(()=>e).catch(n=>{t.dbOpenError=n;try{s&&s.abort()}catch(e){}return r===t.openCanceller&&e._close(),lD(n)}).finally(()=>{t.openComplete=!0,a()})}(this)}_close(){let e=this._state,n=lB.indexOf(this);if(n>=0&&lB.splice(n,1),this.idbdb){try{this.idbdb.close()}catch(e){}this._novip.idbdb=null}e.dbReadyPromise=new s6(n=>{e.dbReadyResolve=n}),e.openCanceller=new s6((n,t)=>{e.cancelOpen=t})}close(){this._close();let e=this._state;this._options.autoOpen=!1,e.dbOpenError=new sE.DatabaseClosed,e.isBeingOpened&&e.cancelOpen(e.dbOpenError)}delete(){let e=arguments.length>0,n=this._state;return new s6((t,i)=>{let r=()=>{this.close();var e=this._deps.indexedDB.deleteDatabase(this.name);e.onsuccess=lc(()=>{!function({indexedDB:e,IDBKeyRange:n},t){cS(e)||t===lj||cE(e,n).delete(t).catch(sM)}(this._deps,this.name),t()}),e.onerror=ci(i),e.onblocked=this._fireOnBlocked};if(e)throw new sE.InvalidArgument("Arguments not allowed in db.delete()");n.isBeingOpened?n.dbReadyPromise.then(r):r()})}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 aG(this._allTables).map(e=>this._allTables[e])}transaction(){let e=cz.apply(this,arguments);return this._transaction.apply(this,e)}_transaction(e,n,t){let i,r,o=s2.trans;o&&o.db===this&&-1===e.indexOf("!")||(o=null);let a=-1!==e.indexOf("?");e=e.replace("!","").replace("?","");try{if(r=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===lR)i=lR;else{if("rw"!=e&&e!=lF)throw new sE.InvalidArgument("Invalid transaction mode: "+e);i=lF}if(o){if(o.mode===lR&&i===lF){if(!a)throw new sE.SubTransaction("Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY");o=null}o&&r.forEach(e=>{if(o&&-1===o.storeNames.indexOf(e)){if(!a)throw new sE.SubTransaction("Table "+e+" not included in parent transaction.");o=null}}),a&&o&&!o.active&&(o=null)}}catch(e){return o?o._promise(null,(n,t)=>{t(e)}):lD(e)}let s=(function e(n,t,i,r,o){return s6.resolve().then(()=>{let a,s=s2.transless||s2,l=n._createTransaction(t,i,n._dbSchema,r);if(r)l.idbtrans=r.idbtrans;else try{l.create(),n._state.PR1398_maxLoop=3}catch(r){return r.name===sC.InvalidState&&n.isOpen()&&--n._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),n._close(),n.open().then(()=>e(n,t,i,null,o))):lD(r)}let c=sf(o);c&&lb();let u=s6.follow(()=>{if(a=o.call(l,l))if(c){var e=ly.bind(null,null);a.then(e,e)}else"function"==typeof a.next&&"function"==typeof a.throw&&(a=cM(a))},{trans:l,transless:s});return(a&&"function"==typeof a.then?s6.resolve(a).then(e=>l.active?e:lD(new sE.PrematureCommit("Transaction committed too early. See http://bit.ly/2kdckMn"))):u.then(()=>a)).then(e=>(r&&l._resolve(),l._completion.then(()=>e))).catch(e=>(l._reject(e),lD(e)))})}).bind(null,this,i,r,o,t);return o?o._promise(i,s,"lock"):s2.trans?lk(s2.transless,()=>this._whenReady(s)):this._whenReady(s)}table(e){if(!aY(this._allTables,e))throw new sE.InvalidTable(`Table ${e} does not exist`);return this._allTables[e]}}let cq="u">typeof Symbol&&"observable"in Symbol?Symbol.observable:"@@observable";class cK{constructor(e){this._subscribe=e}subscribe(e,n,t){return this._subscribe(e&&"function"!=typeof e?e:{next:e,error:n,complete:t})}[cq](){return this}}function cY(e,n){return aG(n).forEach(t=>{cL(e[t]||(e[t]=new cR),n[t])}),e}try{o={indexedDB:aV.indexedDB||aV.mozIndexedDB||aV.webkitIndexedDB||aV.msIndexedDB,IDBKeyRange:aV.IDBKeyRange||aV.webkitIDBKeyRange}}catch(e){o={indexedDB:null,IDBKeyRange:null}}function cJ(e){let n=cZ;try{cZ=!0,cs.storagemutated.fire(e)}finally{cZ=n}}aJ(cH,{...sD,delete:e=>new cH(e,{addons:[]}).delete(),exists:e=>new cH(e,{addons:[]}).open().then(e=>(e.close(),!0)).catch("NoSuchDatabaseError",()=>!1),getDatabaseNames(e){try{return(function({indexedDB:e,IDBKeyRange:n}){return cS(e)?Promise.resolve(e.databases()).then(e=>e.map(e=>e.name).filter(e=>e!==lj)):cE(e,n).toCollection().primaryKeys()})(cH.dependencies).then(e)}catch(e){return lD(new sE.MissingAPI)}},defineClass:()=>function(e){aH(this,e)},ignoreTransaction:e=>s2.trans?lk(s2.transless,e):e(),vip:cD,async:function(e){return function(){try{var n=cM(e.apply(this,arguments));return n&&"function"==typeof n.then?n:s6.resolve(n)}catch(e){return lD(e)}}},spawn:function(e,n,t){try{var i=cM(e.apply(t,n||[]));return i&&"function"==typeof i.then?i:s6.resolve(i)}catch(e){return lD(e)}},currentTransaction:{get:()=>s2.trans||null},waitFor:function(e,n){let t=s6.resolve("function"==typeof e?cH.ignoreTransaction(e):e).timeout(n||6e4);return s2.trans?s2.trans.waitFor(t):t},Promise:s6,debug:{get:()=>sh,set:e=>{sh=e,sg="dexie"===e?()=>!0:lN}},derive:aQ,extend:aH,props:aJ,override:a5,Events:lU,on:cs,liveQuery:function(e){let n,t=!1,i=new cK(i=>{let r=sf(e),o=!1,a={},s={},l={get closed(){return o},unsubscribe:()=>{o=!0,cs.storagemutated.unsubscribe(d)}};i.start&&i.start(l);let c=!1,u=!1;function p(){return aG(s).some(e=>a[e]&&function(e,n){let t=cW(n),i=t.next();if(i.done)return!1;let r=i.value,o=cW(e),a=o.next(r.from),s=a.value;for(;!i.done&&!a.done;){if(0>=l0(s.from,r.to)&&l0(s.to,r.from)>=0)return!0;0>l0(r.from,s.from)?r=(i=t.next(s.from)).value:s=(a=o.next(r.from)).value}return!1}(a[e],s[e]))}let d=e=>{cY(a,e),p()&&f()},f=()=>{let h,g;if(c||o)return;a={};let m={},b=(r&&lb(),h=()=>lm(e,{subscr:m,trans:null}),g=s2.trans?lk(s2.transless,h):h(),r&&g.then(ly,ly),g);u||(cs(co,d),u=!0),c=!0,Promise.resolve(b).then(e=>{t=!0,n=e,c=!1,o||(p()?f():(a={},s=m,i.next&&i.next(e)))},e=>{c=!1,t=!1,i.error&&i.error(e),l.unsubscribe()})};return f(),l});return i.hasValue=()=>t,i.getValue=()=>n,i},extendObservabilitySet:cY,getByKeyPath:a7,setByKeyPath:a9,delByKeyPath:function(e,n){"string"==typeof n?a9(e,n,void 0):"length"in n&&[].map.call(n,function(n){a9(e,n,void 0)})},shallowClone:se,deepClone:sa,getObjectDiff:cT,cmp:l0,asap:a6,minKey:lO,addons:[],connections:lB,errnames:sC,dependencies:o,semVer:lM,version:lM.split(".").map(e=>parseInt(e)).reduce((e,n,t)=>e+n/Math.pow(10,2*t))}),cH.maxKey=cd(cH.dependencies.IDBKeyRange),"u">typeof dispatchEvent&&"u">typeof addEventListener&&(cs(co,e=>{if(!cZ){let n;lI?(n=document.createEvent("CustomEvent")).initCustomEvent(ca,!0,!0,e):n=new CustomEvent(ca,{detail:e}),cZ=!0,dispatchEvent(n),cZ=!1}}),addEventListener(ca,({detail:e})=>{cZ||cJ(e)}));let cZ=!1;if("u">typeof BroadcastChannel){let e=new BroadcastChannel(ca);"function"==typeof e.unref&&e.unref(),cs(co,n=>{cZ||e.postMessage(n)}),e.onmessage=e=>{e.data&&cJ(e.data)}}else if("u">typeof self&&"u">typeof navigator){cs(co,e=>{try{cZ||("u">typeof localStorage&&localStorage.setItem(ca,JSON.stringify({trig:Math.random(),changedParts:e})),"object"==typeof self.clients&&[...self.clients.matchAll({includeUncontrolled:!0})].forEach(n=>n.postMessage({type:ca,changedParts:e})))}catch(e){}}),"u">typeof addEventListener&&addEventListener("storage",e=>{if(e.key===ca){let n=JSON.parse(e.newValue);n&&cJ(n.changedParts)}});let e=self.document&&navigator.serviceWorker;e&&e.addEventListener("message",function({data:e}){e&&e.type===ca&&cJ(e.changedParts)})}function cX(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}s6.rejectionMapper=function(e,n){if(!e||e instanceof sA||e instanceof TypeError||e instanceof SyntaxError||!e.name||!sS[e.name])return e;var t=new sS[e.name](n||e.message,e);return"stack"in e&&aX(t,"stack",{get:function(){return this.inner.stack}}),t},sg=lN;class cQ extends cH{constructor(){super("EsmOffline"),cX(this,"syncQueue",void 0),cX(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 c0(){return new cQ}let c1=new cQ,c2={},c3=H("offline-synchronization",{});function c5(){return c3}async function c4(){if(c3.getState().synchronization)return;let e=await c1.syncQueue.count(),n={},t=Object.entries(c2),i=t.length,r={},o=new AbortController,a=()=>{let e=c3.getState().synchronization;c3.setState({synchronization:{...e,pendingCount:e.pendingCount-1}})};try{c3.setState({synchronization:{totalCount:e,pendingCount:e,abortController:o}});for(let e=0;e<i&&t.length>0;e++)for(let e=t.length;e--;){let[i,s]=t[e],l=s.dependsOn.map(e=>n[e]);l.every(Boolean)&&(r[i]={},await Promise.all(l),n[i]=c6(s,r,o,a),t.splice(e,1))}await Promise.allSettled(Object.values(n))}finally{c3.setState({synchronization:void 0})}}async function c6({type:e,dependsOn:n,process:t},i,r,o){let a=[],s=[],l=await c8();await c1.syncQueue.where({type:e,userId:l}).each((e,n)=>{a.push([n.primaryKey,e.content,e.descriptor]),s.push(e.content)});for(let c=0;c<a.length;c++){let[u,p,{id:d,dependencies:f=[]}]=a[c];try{let o=await t(p,{abort:r,index:c,items:s,userId:l,dependencies:f.map(({id:e,type:t})=>n.includes(t)?i[t][e]:void 0)});void 0!==d&&(i[e][d]=o),await c1.syncQueue.delete(u)}catch(e){await c1.syncQueue.update(u,{lastError:{name:e?.name,message:e?.message??e?.toString()}})}finally{o()}}}async function c8(){let e=await rR();return e?.uuid||"*"}async function c7(e,n,t,i){let r=i&&i.id;return void 0!==r&&await c1.syncQueue.where({type:n,userId:e}).filter(e=>e?.descriptor.id===r).delete().catch(cH.errnames.DatabaseClosed),await c1.syncQueue.add({type:n,content:t,userId:e,descriptor:i||{},createdOn:new Date}).catch(cH.errnames.DatabaseClosed,()=>-1)}async function c9(e,n,t){let i=await c8();return await c7(i,e,n,t)}async function ue(e,n){return(await un(e,n)).map(e=>e.content)}async function un(e,n){return await c1.syncQueue.where(n?{type:n,userId:e}:{userId:e}).toArray().catch(cH.errnames.DatabaseClosed,()=>[])}async function ut(e){let n=await c8();return await ue(n,e)}async function ui(e){let n=await c8();return await un(n,e)}async function ur(e){return await c1.syncQueue.get(e).catch(cH.errnames.DatabaseClosed,()=>void 0)}function uo(e){return!!c2[e]?.options.onBeginEditSyncItem}async function ua(e){let n=await ur(e);if(!n)throw Error(`No sync item with the ID ${e} exists.`);let t=c2[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 us(e){await c1.syncQueue.delete(e).catch(cH.errnames.DatabaseClosed)}function ul(e,n,t,i={}){c2[e]={type:e,dependsOn:n,process:t,options:i}}let uc="u">typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),uu=new Uint8Array(16),up=[];for(let e=0;e<256;++e)up.push((e+256).toString(16).slice(1));let ud=function(e,n,t){if(uc&&!n&&!e)return uc();let i=(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(uu)})();if(i[6]=15&i[6]|64,i[8]=63&i[8]|128,n){t=t||0;for(let e=0;e<16;++e)n[t+e]=i[e];return n}return function(e,n=0){return up[e[n+0]]+up[e[n+1]]+up[e[n+2]]+up[e[n+3]]+"-"+up[e[n+4]]+up[e[n+5]]+"-"+up[e[n+6]]+up[e[n+7]]+"-"+up[e[n+8]]+up[e[n+9]]+"-"+up[e[n+10]]+up[e[n+11]]+up[e[n+12]]+up[e[n+13]]+up[e[n+14]]+up[e[n+15]]}(i)},uf="OFFLINE+";function uh(){return uf+ud()}function ug(e){return e.startsWith(uf)}let um={};function ub(){return Object.values(um)}function uy(e){um[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.`),um[e.id]=e}async function u_(e){let n=await uE();return await uv(n,e)}async function uv(e,n){let t=new cQ;return await t.dynamicOfflineData.where(n?{type:n,users:e}:{users:e}).toArray().catch(cH.errnames.DatabaseClosed,()=>[])}async function u$(e,n){let t=await uE();return await uA(t,e,n)}async function uA(e,n,t){let i=new cQ,r=await i.dynamicOfflineData.get({type:n,identifier:t}).catch(cH.errnames.DatabaseClosed,()=>void 0);r?r.users.includes(e)||await i.dynamicOfflineData.update(r.id,{users:[...r.users,e]}).catch(cH.errnames.DatabaseClosed):await i.dynamicOfflineData.add({users:[e],type:n,identifier:t}).catch(cH.errnames.DatabaseClosed)}async function uw(e,n){let t=await uE();return await uk(t,e,n)}async function uk(e,n,t){let i=new cQ,r=await i.dynamicOfflineData.get({type:n,identifier:t,users:e}).catch(cH.errnames.DatabaseClosed,()=>void 0);r&&(r.users.length>1?await i.dynamicOfflineData.update(r.id,{users:r.users.filter(n=>n!==e)}).catch(cH.errnames.DatabaseClosed):await i.dynamicOfflineData.delete(r.id).catch(cH.errnames.DatabaseClosed))}async function ux(e,n){let t=await u_(e);await Promise.all(t.map(async e=>uC(e.type,e.identifier,n)))}async function uC(e,n,t){await u$(e,n);let i=new cQ,r=await uE(),o=await i.dynamicOfflineData.get({type:e,identifier:n}).catch(cH.errnames.DatabaseClosed,()=>void 0),a=ub().filter(n=>n.type===e);if(!o)return;let s=await Promise.all(a.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),u=s.filter(e=>e.error).map(e=>({handlerId:e.id,message:e.error})),p={syncedOn:new Date,syncedBy:r,succeededHandlers:l,erroredHandlers:c,errors:u};o.id&&await i.dynamicOfflineData.update(o.id,{syncState:p}).catch(cH.errnames.DatabaseClosed)}async function uE(){let e=(await rR()).uuid;if(!e)throw Error("Using the dynamic offline data API requires a logged in user.");return e}let uS=H("offline-patients",{offlinePatientDataSyncState:{},handlers:{}});function uD(){return uO(),uS}function uM(e,n){uO(),uy({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 uz(e){uO(),await uC("patient",e)}function uO(){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 uP(e,n,t=!0){if(e){let i=null,[r,o]=await Promise.all([rS(`${rx}/Patient/${e}`,n).catch(e=>i=e),t?uT(e):Promise.resolve(null)]);if(r.ok)return r.data;if(o)return o;if(i)throw i}return null}async function uT(e){let n=(await ut("patient-registration")).find(n=>n.fhirPatient.id===e);return n?.fhirPatient??null}function uB(e,n){let t=new CustomEvent(`openmrs:${e}`,{detail:n??void 0,cancelable:!0,bubbles:!0});return window.dispatchEvent(t)}function uI(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 uN=t(56170);function uj(e){return{uuid:e.uuid,display:e.display}}function uR(e=null,n=null){let t=new URLSearchParams;e&&t.set("tag",e),n&&t.set("q",n);let i=t.toString();return rD(`${rk}/location${i?"?"+i:""}`).pipe((0,uN.map)(e=>e.data.results.map(uj))).pipe((0,uN.take)(1))}function uF(e){return{uuid:e.uuid,display:e.display,name:e.name}}function uL(){return rD(`${rk}/visittype`).pipe((0,uN.map)(e=>e.data.results.map(uF))).pipe((0,uN.take)(1))}var uW=((ee={}).NEWVISIT="startVisit",ee.EDITVISIT="editVisit",ee.LOADING="loadingVisit",ee),uV=((en={}).NOTSTARTED="notStarted",en.ONGOING="ongoing",en);let uG="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))",uU=function(){try{return JSON.parse(sessionStorage.getItem("openmrs:visitStoreState")||"null")}catch(e){return null}}()||{patientUuid:null,manuallySetVisitUuid:null};function uH(){return K("visit",uU)}function uq(e,n){uH().setState({patientUuid:e,manuallySetVisitUuid:n})}function uK(e,n){return rS(`${rk}/visit`,{signal:n.signal,method:"POST",headers:{"Content-type":"application/json"},body:e})}function uY(e,n,t){return rS(`${rk}/visit/${e}`,{signal:t.signal,method:"POST",headers:{"Content-type":"application/json"},body:n})}function uJ(e,n,t){return rS(`${rk}/visit?patient=${e}&v=${t??uG}`,{signal:n.signal,method:"GET",headers:{"Content-type":"application/json"}})}uH().subscribe(e=>{var n;n=e,sessionStorage.setItem("openmrs:visitStoreState",JSON.stringify(n))});let uZ=new er.BehaviorSubject(null);class uX{static get version(){return"1.4.0"}static toString(){return"JavaScript Expression Parser (JSEP) v"+uX.version}static addUnaryOp(e){return uX.max_unop_len=Math.max(e.length,uX.max_unop_len),uX.unary_ops[e]=1,uX}static addBinaryOp(e,n,t){return uX.max_binop_len=Math.max(e.length,uX.max_binop_len),uX.binary_ops[e]=n,t?uX.right_associative.add(e):uX.right_associative.delete(e),uX}static addIdentifierChar(e){return uX.additional_identifier_chars.add(e),uX}static addLiteral(e,n){return uX.literals[e]=n,uX}static removeUnaryOp(e){return delete uX.unary_ops[e],e.length===uX.max_unop_len&&(uX.max_unop_len=uX.getMaxKeyLen(uX.unary_ops)),uX}static removeAllUnaryOps(){return uX.unary_ops={},uX.max_unop_len=0,uX}static removeIdentifierChar(e){return uX.additional_identifier_chars.delete(e),uX}static removeBinaryOp(e){return delete uX.binary_ops[e],e.length===uX.max_binop_len&&(uX.max_binop_len=uX.getMaxKeyLen(uX.binary_ops)),uX.right_associative.delete(e),uX}static removeAllBinaryOps(){return uX.binary_ops={},uX.max_binop_len=0,uX}static removeLiteral(e){return delete uX.literals[e],uX}static removeAllLiterals(){return uX.literals={},uX}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 uX(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 uX.binary_ops[e]||0}static isIdentifierStart(e){return e>=65&&e<=90||e>=97&&e<=122||e>=128&&!uX.binary_ops[String.fromCharCode(e)]||uX.additional_identifier_chars.has(String.fromCharCode(e))}static isIdentifierPart(e){return uX.isIdentifierStart(e)||uX.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(uX.hooks[e]){let t={context:this,node:n};return uX.hooks.run(e,t),t.node}return n}searchHook(e){if(uX.hooks[e]){let n={context:this};return uX.hooks[e].find(function(e){return e.call(n.context,n),n.node}),n.node}}gobbleSpaces(){let e=this.code;for(;e===uX.SPACE_CODE||e===uX.TAB_CODE||e===uX.LF_CODE||e===uX.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:uX.COMPOUND,body:e};return this.runHook("after-all",n)}gobbleExpressions(e){let n=[],t,i;for(;this.index<this.expr.length;)if((t=this.code)===uX.SEMCOL_CODE||t===uX.COMMA_CODE)this.index++;else if(i=this.gobbleExpression())n.push(i);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,uX.max_binop_len),n=e.length;for(;n>0;){if(uX.binary_ops.hasOwnProperty(e)&&(!uX.isIdentifierStart(this.code)||this.index+e.length<this.expr.length&&!uX.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,i,r,o,a,s,l;if(!(o=this.gobbleToken())||!(n=this.gobbleBinaryOp()))return o;for(r={value:n,prec:uX.binaryPrecedence(n),right_a:uX.right_associative.has(n)},(a=this.gobbleToken())||this.throwError("Expected expression after "+n),i=[o,r,a];n=this.gobbleBinaryOp();){if(0===(t=uX.binaryPrecedence(n))){this.index-=n.length;break}r={value:n,prec:t,right_a:uX.right_associative.has(n)},l=n;let s=e=>r.right_a&&e.right_a?t>e.prec:t<=e.prec;for(;i.length>2&&s(i[i.length-2]);)a=i.pop(),n=i.pop().value,o=i.pop(),e={type:uX.BINARY_EXP,operator:n,left:o,right:a},i.push(e);(e=this.gobbleToken())||this.throwError("Expected expression after "+l),i.push(r,e)}for(s=i.length-1,e=i[s];s>1;)e={type:uX.BINARY_EXP,operator:i[s-1].value,left:i[s-2],right:e},s-=2;return e}gobbleToken(){let e,n,t,i;if(this.gobbleSpaces(),i=this.searchHook("gobble-token"))return this.runHook("after-token",i);if(e=this.code,uX.isDecimalDigit(e)||e===uX.PERIOD_CODE)return this.gobbleNumericLiteral();if(e===uX.SQUOTE_CODE||e===uX.DQUOTE_CODE)i=this.gobbleStringLiteral();else if(e===uX.OBRACK_CODE)i=this.gobbleArray();else{for(t=(n=this.expr.substr(this.index,uX.max_unop_len)).length;t>0;){if(uX.unary_ops.hasOwnProperty(n)&&(!uX.isIdentifierStart(this.code)||this.index+n.length<this.expr.length&&!uX.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:uX.UNARY_EXP,operator:n,argument:e,prefix:!0})}n=n.substr(0,--t)}uX.isIdentifierStart(e)?(i=this.gobbleIdentifier(),uX.literals.hasOwnProperty(i.name)?i={type:uX.LITERAL,value:uX.literals[i.name],raw:i.name}:i.name===uX.this_str&&(i={type:uX.THIS_EXP})):e===uX.OPAREN_CODE&&(i=this.gobbleGroup())}return i?(i=this.gobbleTokenProperty(i),this.runHook("after-token",i)):this.runHook("after-token",!1)}gobbleTokenProperty(e){this.gobbleSpaces();let n=this.code;for(;n===uX.PERIOD_CODE||n===uX.OBRACK_CODE||n===uX.OPAREN_CODE||n===uX.QUMARK_CODE;){let t;if(n===uX.QUMARK_CODE){if(this.expr.charCodeAt(this.index+1)!==uX.PERIOD_CODE)break;t=!0,this.index+=2,this.gobbleSpaces(),n=this.code}this.index++,n===uX.OBRACK_CODE?((e={type:uX.MEMBER_EXP,computed:!0,object:e,property:this.gobbleExpression()}).property||this.throwError('Unexpected "'+this.char+'"'),this.gobbleSpaces(),(n=this.code)!==uX.CBRACK_CODE&&this.throwError("Unclosed ["),this.index++):n===uX.OPAREN_CODE?e={type:uX.CALL_EXP,arguments:this.gobbleArguments(uX.CPAREN_CODE),callee:e}:(n===uX.PERIOD_CODE||t)&&(t&&this.index--,this.gobbleSpaces(),e={type:uX.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(;uX.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);if(this.code===uX.PERIOD_CODE)for(e+=this.expr.charAt(this.index++);uX.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++));uX.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);uX.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+e+this.char+")")}return t=this.code,uX.isIdentifierStart(t)?this.throwError("Variable names cannot start with a number ("+e+this.char+")"):(t===uX.PERIOD_CODE||1===e.length&&e.charCodeAt(0)===uX.PERIOD_CODE)&&this.throwError("Unexpected period"),{type:uX.LITERAL,value:parseFloat(e),raw:e}}gobbleStringLiteral(){let e="",n=this.index,t=this.expr.charAt(this.index++),i=!1;for(;this.index<this.expr.length;){let n=this.expr.charAt(this.index++);if(n===t){i=!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 i||this.throwError('Unclosed quote after "'+e+'"'),{type:uX.LITERAL,value:e,raw:this.expr.substring(n,this.index)}}gobbleIdentifier(){let e=this.code,n=this.index;for(uX.isIdentifierStart(e)?this.index++:this.throwError("Unexpected "+this.char);this.index<this.expr.length;)if(e=this.code,uX.isIdentifierPart(e))this.index++;else break;return{type:uX.IDENTIFIER,name:this.expr.slice(n,this.index)}}gobbleArguments(e){let n=[],t=!1,i=0;for(;this.index<this.expr.length;){this.gobbleSpaces();let r=this.code;if(r===e){t=!0,this.index++,e===uX.CPAREN_CODE&&i&&i>=n.length&&this.throwError("Unexpected token "+String.fromCharCode(e));break}if(r===uX.COMMA_CODE){if(this.index++,++i!==n.length){if(e===uX.CPAREN_CODE)this.throwError("Unexpected token ,");else if(e===uX.CBRACK_CODE)for(let e=n.length;e<i;e++)n.push(null)}}else if(n.length!==i&&0!==i)this.throwError("Expected comma");else{let e=this.gobbleExpression();e&&e.type!==uX.COMPOUND||this.throwError("Expected comma"),n.push(e)}}return t||this.throwError("Expected "+String.fromCharCode(e)),n}gobbleGroup(){this.index++;let e=this.gobbleExpressions(uX.CPAREN_CODE);if(this.code===uX.CPAREN_CODE)return(this.index++,1===e.length)?e[0]:!!e.length&&{type:uX.SEQUENCE_EXP,expressions:e};this.throwError("Unclosed (")}gobbleArray(){return this.index++,{type:uX.ARRAY_EXP,elements:this.gobbleArguments(uX.CBRACK_CODE)}}}Object.assign(uX,{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)})}}(uX),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"}),uX.max_unop_len=uX.getMaxKeyLen(uX.unary_ops),uX.max_binop_len=uX.getMaxKeyLen(uX.binary_ops);let uQ=e=>new uX(e).parse(),u0=Object.getOwnPropertyNames(class{});Object.getOwnPropertyNames(uX).filter(e=>!u0.includes(e)&&void 0===uQ[e]).forEach(e=>{uQ[e]=uX[e]}),uQ.Jsep=uX,uQ.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,i=this.gobbleExpression();if(i||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===e.COLON_CODE){this.index++;let r=this.gobbleExpression();if(r||this.throwError("Expected expression"),n.node={type:"ConditionalExpression",test:t,consequent:i,alternate:r},t.operator&&e.binary_ops[t.operator]<=.9){let i=t;for(;i.right.operator&&e.binary_ops[i.right.operator]<=.9;)i=i.right;n.node.test=i.right,i.right=n.node,n.node=t}}else this.throwError("Expected :")}})}});let u1="ArrowFunctionExpression",u2={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)}},u3={...u2,Promise};function u5(e,n={}){return pe(e,n,pi)}async function u4(e,n={}){return pn(e,n,pi)}function u6(e,n={}){return pe(e,n,pr)}function u8(e,n={}){return pn(e,n,pr)}function u7(e,n={}){return pe(e,n,po)}function u9(e,n={}){return pn(e,n,po)}function pe(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 i=pl(n,u2),r=pa("string"==typeof e?uQ(e):e,i);if(t(r))return r;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 pn(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 i=pl(n,u3);return Promise.resolve(pa("string"==typeof e?uQ(e):e,i)).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 pt(e){return uQ(e)}function pi(e){return"string"==typeof e||"number"==typeof e||"boolean"==typeof e||null==e||e instanceof Date}function pr(e){return"boolean"==typeof e}function po(e){return"number"==typeof e}function pa(e,n){switch(e.type){case"UnaryExpression":var t,i,r,o,a,s,l,c,u,p,d,f,h=e,g=n;let m=pa(h.argument,g);switch(h.operator){case"+":return+m;case"-":return-m;case"~":return~m;case"!":return!m;default:throw`Expression evaluator does not support operator '${h.operator}''`}case"BinaryExpression":var b=e,y=n;let v=pa(b.left,y),$=pa(b.right,y);switch(b.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 '${b.operator}' operator`}case"ConditionalExpression":return t=e,i=n,pa(t.test,i)?pa(t.consequent,i):pa(t.alternate,i);case"CallExpression":var A=e,w=n;let k=A.arguments?.map(pc(w)),x=pa(A.callee,w);if(x){if("function"!=typeof x)throw`${pp(A.callee)} is not a function`}else throw`No function named ${pp(A.callee)} is defined in this context`;return x(...k);case"ArrowFunctionExpression":let C;return r=e,o=n,C=r.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,i)=>{let r=e[i];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}(r)&&n.push([t,r]),n},[]));return pa(r.body,o.addVariables(n))}).bind(o.thisObj??null);case"MemberExpression":return function(e,n){let t,i=pa(e.object,n);if(void 0===i)switch(e.object.type){case"Identifier":{let t=ps(e.object,n);throw ReferenceError(`ReferenceError: ${t} is not defined`)}case"MemberExpression":{let t=ps(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 r=i;if("string"==typeof i)r=String.prototype;else if("number"==typeof i)r=Number.prototype;else if("function"==typeof i);else if("object"!=typeof i)throw`VisitMemberExpression does not support member access on type ${typeof i}`;switch(n.thisObj=r,e.property.type){case"Identifier":case"MemberExpression":t=pa(e.property,n);break;default:{let r=pa(e.property,n);if(void 0===r)throw{type:"Illegal property access",message:"No property was supplied to the property access"};pu(r),t=i[r]}}return"function"==typeof t?t.bind(i):t}(e,n);case"ArrayExpression":return a=e,s=n,a.elements?.map(pc(s));case"SequenceExpression":let E;return l=e,c=n,(E=l.expressions.map(pc(c)))[E.length-1];case"NewExpression":var S=e,D=n;if(S.callee&&"Identifier"===S.callee.type){let e=S.arguments?.map(pc(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 pu((u=e).value),u.value;case"Identifier":var M=e,z=n;pu(M.name);let O=z.thisObj;if(O&&("object"==typeof O||"function"==typeof O)&&M.name in O){let e=O[M.name];return pu(e),e}if(z.variables&&M.name in z.variables){let e=z.variables[M.name];return pu(e),e}return M.name in z.globals?z.globals[M.name]:void 0;case"TemplateLiteral":let P,T;return p=e,d=n,P=p.expressions?.map(pc(d))??[],(T=p.quasis?.map(pc(d))??[]).filter(e=>!e.tail).map(e=>e.value).join("")+P.join("")+T.filter(e=>e.tail).map(e=>e.value).join("");case"TemplateElement":return{value:(f=e).cooked,tail:f.tail};default:throw`Expression evaluator does not support expression of type '${e.type}'`}}function ps(e,n){switch(e.type){case"Literal":return e.value;case"Identifier":return e.name;case"MemberExpression":return ps(e.property,n);default:throw`VisitExpressionName does not support expression of type '${e.type}'`}}function pl(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 pc(e){return function(n){return null===n?null:pa(n,e)}}function pu(e){if("__proto__"===e||"prototype"===e||"constructor"===e)throw{type:"Illegal property access",message:`Cannot access the ${e} property of objects`}}function pp(e){return e?"MemberExpression"===e.type?e.property?.name:e.name:null}function pd(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:{...u3},isLocalExpression:!1,variables:new Set};return pf("string"==typeof e?uQ(e):e,n),[...n.variables]}function pf(e,n){switch(e.type){case"UnaryExpression":return i=e,r=n,pf(i.argument,r);case"BinaryExpression":return o=e,a=n,[pf(o.left,a),pf(o.right,a)].filter(Boolean);case"ConditionalExpression":return s=e,l=n,[pf(s.consequent,l),pf(s.test,l),pf(s.alternate,l)].filter(Boolean);case"CallExpression":let t;return c=e,u=n,t=pf(c.callee,u),c.arguments?.map(ph(u)),t;case"ArrowFunctionExpression":var i,r,o,a,s,l,c,u,p,d,f,h,g,m,b,y,v,$,A=e,w=n;let k={...w};k.isLocalExpression=!0;let x=A.params?.map(ph(k))??[],C=pf(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 p=e,d=n,pf(p.object,d),void((E={...d}).isLocalExpression=!0,pf(p.property,E));case"ArrayExpression":return f=e,h=n,void f.elements?.map(ph(h));case"SequenceExpression":return g=e,m=n,void g.expressions?.map(ph(m));case"NewExpression":return b=e,y=n,void b.arguments?.map(ph(y));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(ph($)),v.quasis?.map(ph($)));default:throw`Expression evaluator does not support expression of type '${e.type}'`}}function ph(e){return function(n){return null===n?null:pf(n,e)}}uQ.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:u1,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=u1,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)})}}),uQ.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 i=n.node;for(;i.type===e.MEMBER_EXP||i.type===e.CALL_EXP&&i.callee.type===e.MEMBER_EXP;)i=i.type===e.MEMBER_EXP?i.object:i.callee.object;i.type="NewExpression"}})}}),uQ.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,i="",r=()=>{for(;e.isDecimalDigit(this.code)||95===this.code;)95===this.code?this.index++:i+=this.expr.charAt(this.index++)};r(),this.code===e.PERIOD_CODE&&(i+=this.expr.charAt(this.index++),r());let o=this.char;("e"===o||"E"===o)&&(i+=this.expr.charAt(this.index++),("+"===(o=this.char)||"-"===o)&&(i+=this.expr.charAt(this.index++)),r(),e.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+i+this.char+")"));let a=this.code;if(e.isIdentifierStart(a))this.throwError("Variable names cannot start with a number ("+i+this.char+")");else if(a===e.PERIOD_CODE){i.length>1&&this.throwError(`Unexpected period ${JSON.stringify({chCode:a,number:i},null,2)}`),this.index=t;return}n.node={type:e.LITERAL,value:parseFloat(i),raw:this.expr.substring(t,this.index)}}e.hooks.add("gobble-token",function(i){if(48===this.code){var r,o,a;let s=this.index,l=this.expr.charAt(this.index+1),c=n.call(this,l);if(!c)return;let u="";for(;r=this.code,o=c,95===r||o.some(([e,n])=>r>=e&&r<=n);)95===this.code?this.index++:u+=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,i);return}this.throwError("unexpected char within number")}i.node={type:e.LITERAL,value:parseInt(u,"x"===(a=l)||"X"===a?16:"b"===a||"B"===a?2:8),raw:this.expr.substring(s,this.index)}}else(e.isDecimalDigit(this.code)||this.code===e.PERIOD_CODE)&&t.call(this,i)})}}),uQ.plugins.register({name:"regex",init(e){e.hooks.add("gobble-token",function(n){if(47===this.code){let t=++this.index,i=!1;for(;this.index<this.expr.length;){if(47===this.code&&!i){let i,r=this.expr.slice(t,this.index),o="";for(;++this.index<this.expr.length;){let e=this.code;if(e>=97&&e<=122||e>=65&&e<=90||e>=48&&e<=57)o+=this.char;else break}try{i=new RegExp(r,o)}catch(e){this.throwError(e.message)}return n.node={type:e.LITERAL,value:i,raw:this.expr.slice(t-1,this.index)},n.node=this.gobbleTokenProperty(n.node),n.node}this.code===e.OBRACK_CODE?i=!0:i&&this.code===e.CBRACK_CODE&&(i=!1),this.index+=92===this.code?2:1}this.throwError("Unclosed Regex")}})}}),uQ.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,i=this.gobbleExpression();if(i||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===e.COLON_CODE){this.index++;let r=this.gobbleExpression();if(r||this.throwError("Expected expression"),n.node={type:"ConditionalExpression",test:t,consequent:i,alternate:r},t.operator&&e.binary_ops[t.operator]<=.9){let i=t;for(;i.right.operator&&e.binary_ops[i.right.operator]<=.9;)i=i.right;n.node.test=i.right,i.right=n.node,n.node=t}}else this.throwError("Expected :")}})}}),uQ.plugins.register({name:"jsepTemplateLiteral",init(e){function n(e,t=!0){if(96===this.code){let n={type:"TemplateLiteral",quasis:[],expressions:[]},i="",r="",o=!1,a=this.expr.length,s=()=>n.quasis.push({type:"TemplateElement",value:{raw:r,cooked:i},tail:o});for(;this.index<a;){let a=this.expr.charAt(++this.index);if("`"===a)return this.index+=1,o=!0,s(),e.node=n,t&&(e.node=this.gobbleTokenProperty(e.node)),e.node;if("$"===a&&"{"===this.expr.charAt(this.index+1))this.index+=2,s(),r="",i="",n.expressions.push(...this.gobbleExpressions(125)),125!==this.code&&this.throwError("unclosed ${");else if("\\"===a)switch(r+=a,a=this.expr.charAt(++this.index),r+=a,a){case"n":i+="\n";break;case"r":i+="\r";break;case"t":i+=" ";break;case"b":i+="\b";break;case"f":i+="\f";break;case"v":i+="\v";break;default:i+=a}else i+=a,r+=a}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})}}),uQ.addBinaryOp("in",7),uQ.addBinaryOp("??",1);let pg=K("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:",""),i=JSON.parse(localStorage.getItem(`openmrs:feature-flag-meta:${t}`)||"{}");e[t]={enabled:"true"===localStorage.getItem(n),...i}}return e}()});function pm(e,n,t){pg.setState(i=>({flags:{...i.flags,[e]:{enabled:i.flags[e]?.enabled??!1,label:n,description:t}}}))}function pb(){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 py(e){return pg.getState().flags[e].enabled}function p_(e,n){pg.subscribe(t=>{n(t.flags[e].enabled)})}function pv(e,n){pg.setState(t=>({flags:{...t.flags,[e]:{...t.flags[e],enabled:n}}}))}function p$(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 pA=eQ(function(e,n,t){eJ(e,n,t)});function pw(e=!0,n=!1){return pk(p$(),e,n)}function pk(e,n=!0,t=!1){return!!(e?n:t)}let px=H("extensionsInternal",{slots:{},extensions:{}}),pC=H("extensionRenderings",{renderings:new Map}),pE=()=>K("extensionsInternal",{slots:{},extensions:{}}),pS=()=>K("extensionRenderings",{renderings:new Map});function pD(e){let n=px.getState(),t=e(n);t!==n&&px.setState(t)}let pM=null,pz=null;function pO(){let e=pC.getState();return pM&&e===pz||(pM=new Map(e.renderings),pz=e,function(e){for(let n of(pW.clear(),e.values()))pG(n,1);pV=!0}(pM)),pM}function pP(e){pz={renderings:e},pC.setState(pz,!0)}function pT(e){let n=pO();n.has(e.renderingId)||(n.set(e.renderingId,e),pG(e,1),pP(n))}function pB(e){let n=pO(),t=n.get(e);t&&(n.delete(e),pG(t,-1),pP(n))}let pI=()=>K("extensions",{slots:{}}),pN=0,pj=new Set;function pR(e){pN++;try{return e()}finally{if(0==--pN&&pj.size>0){let e=Array.from(pj);for(let n of(pj.clear(),e))pF(n)}}}function pF(e){try{e()}catch(n){console.error(`The extension system's '${e.name}' recomputation failed`,n)}}function pL(e){pN>0?pj.add(e):pF(e)}let pW=new Map,pV=!1;function pG(e,n){let t=JSON.stringify([e.slotName,e.extensionId,e.slotModuleName,e.extensionModuleName]),i=pW.get(t);if(!i){if(n<0)return;pW.set(t,{count:1,record:{slotModuleName:e.slotModuleName,extensionModuleName:e.extensionModuleName,slotName:e.slotName,extensionId:e.extensionId}}),pV=!0;return}i.count+=n,i.count<1&&(pW.delete(t),pV=!0)}function pU(){var e,n;if(pO(),!pV)return;pV=!1;let t=Array.from(pW.values(),({record:e})=>e);t.sort(pH),e=nU.getState().mountedExtensions,n=t,e.length===n.length&&e.every((e,t)=>0===pH(e,n[t]))||nU.setState({mountedExtensions:t})}function pH(e,n){return pq(e.slotName,n.slotName)||pq(e.extensionId,n.extensionId)||pq(e.slotModuleName,n.slotModuleName)||pq(e.extensionModuleName,n.extensionModuleName)}function pq(e,n){return e===n?0:e<n?-1:1}pU(),pC.subscribe(()=>pL(pU));let pK=pE(),pY=pI(),pJ=nq(),pZ=nJ(),pX=new Set,pQ=!1;function p0(e){if(null===e)pX=null;else if(null!==pX)for(let n of e)pX.add(n);pL(p1)}function p1(){if(!pQ){pQ=!0;try{for(let e=1;;e++){let n=pX;if(null!==n&&0===n.size)return;pX=new Set;try{!function(e,n,t,i,r,o=null){let a=pY.getState().slots,s={},l=!1,c=p$(),u=Object.entries(i.flags).filter(([,{enabled:e}])=>e).map(([e])=>e);for(let[i,p]of Object.entries(e.slots)){let d=a[i];if(d&&o&&!o.has(i)){s[i]=d;continue}let{config:f}=nY(n,p.name),h=function(e,n,t,i,r,o,a){let s=function(e,n){let t=e.add||[],i=e.remove||[],r=e.order||[],{extensions:o}=pK.getState();return[...n,...t].filter(e=>!i.includes(e)).sort((e,t)=>dt(e,r,o[p4(e)]?.order,n)-dt(t,r,o[p4(t)]?.order,n))}(t,n.slots[e].attachedIds),l=[];for(let c of s){let{config:s}=nX(i,e,c),u=nQ(t,e,c),p=u?pA({},s,u):s,d=p4(c),f=n.extensions[d];if(f){let e=p?.["Display conditions"]?.privileges??f.privileges??[];if(e&&("string"==typeof e||Array.isArray(e)&&e.length>0)&&(!a?.user||!rj(e,a.user))||f.featureFlag&&!r.includes(f.featureFlag)||window.offlineEnabled&&!pk(o,f.online,f.offline))continue;l.push({id:c,name:d,moduleName:f.moduleName,config:p,featureFlag:f.featureFlag,meta:f.meta,online:p?.["Display conditions"]?.online??f.online??!0,offline:p?.["Display conditions"]?.offline??f.offline??!1,displayConditionExpression:p?.["Display conditions"]?.expression||f.displayExpression})}}return l}(i,e,f,t,u,c,r.session);d&&d.moduleName===p.moduleName&&e2(d.candidateExtensions,h)?s[i]=d:(s[i]={moduleName:p.moduleName,candidateExtensions:h},l=!0)}(l||Object.keys(a).length!==Object.keys(s).length)&&pY.setState({slots:s})}(pK.getState(),pJ.getState(),pZ.getState(),pg.getState(),rz.getState(),n)}catch(e){throw pX=null===n||null===pX?null:new Set([...n,...pX]),e}if(e>=20)return void console.error("The extension system stopped recomputing after 20 passes because something keeps invalidating slots in response to the extension store being written. Some slots are left stale until the next write.")}}finally{pQ=!1}}}function p2(e,n){let t=new Set;for(let i of Object.keys(e))e[i]!==n[i]&&t.add(i);for(let i of Object.keys(n))i in e||t.add(i);return t}function p3(){p0(null)}function p5(e,n){return{moduleName:n,name:e,attachedIds:[]}}function p4(e){let[n]=e.split("#");return n}function p6(e,n){let t=p4(n);return e.extensions[t]}function p8(e){return p6(pK.getState(),e)}pK.subscribe((e,n)=>{p0(e.extensions!==n.extensions?null:p2(e.slots,n.slots))}),pJ.subscribe((e,n)=>{p0(p2(e.slots,n.slots))}),pZ.subscribe((e,n)=>{p0(p2(e.configs,n.configs))}),pg.subscribe(()=>p0(null)),rz.subscribe(()=>p0(null)),p3(),y(p3);let p7=e=>pD(n=>({...n,extensions:{...n.extensions,[e.name]:{...e}}}));function p9(e,n){pD(t=>{let i=t.slots[e];return i?{...t,slots:{...t.slots,[e]:{...i,attachedIds:[...i.attachedIds,n]}}}:{...t,slots:{...t.slots,[e]:{...p5(e),attachedIds:[n]}}}})}function de(e,n){pD(t=>{let i=t.slots[e];return i&&i.attachedIds.includes(n)?{...t,slots:{...t.slots,[e]:{...i,attachedIds:i.attachedIds.filter(e=>e!==n)}}}:t})}function dn(e){pD(n=>{let t=n.slots[e];return t?{...n,slots:{...n.slots,[e]:{...t,attachedIds:[]}}}:n})}function dt(e,n,t,i){let r=n.indexOf(e);if(-1!==r)return r;{if(void 0!==t)return 1e3+t;let n=i.indexOf(e);return -1!==n?2e3+n:3e3}}function di(e,n){return function(e,n,t=null,i){let r;return e.filter(e=>{let o=e.displayConditionExpression;if("string"!=typeof o||0===o.trim().length)return!0;r??(r=n&&"object"==typeof n?{session:t,...n}:{session:t});try{return!!u6(o,r)}catch(n){return console.error(`Error while evaluating expression '${o}' for ${e.id}`+(i?` in ${i}`:""),n),!1}})}(dr(e),n,rz.getState().session,e)}function dr(e){return pY.getState().slots[e]?.candidateExtensions??[]}let da=(e,n)=>pK.setState(t=>{let i=t.slots[n]?.moduleName;if(i&&i!=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 ${i}.`),t;if(i&&i==e)return t;if(t.slots[n])return{...t,slots:{...t.slots,[n]:{...t.slots[n],moduleName:e}}};let r=p5(n,e);return{...t,slots:{...t.slots,[n]:{...r}}}}),ds=()=>{pX=null,pD(()=>({slots:{},extensions:{}})),pS().setState({renderings:new Map}),pY.setState({slots:{}})},dl=H("left-nav",{slotName:null,basePath:window.spaBase,mode:"normal"});function dc({name:e,basePath:n,mode:t,componentContext:i,state:r}){dl.setState({slotName:e,basePath:n,mode:t??"normal",componentContext:i,state:r})}function du(e){dl.getState().slotName===e&&dl.setState(dl.getInitialState(),!0)}let dp=H("modalRegistry",{modals:{}});function dd(e){dp.setState(n=>(n.modals[e.name]=e,n))}function df(e){let n=dp.getState().modals[e];if(!n){let t=p8(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.`),dd(n))}return n}let dh=H("workspaceRegistrations",{workspaces:{}}),dg=H("workspaceGroups",{workspaceGroups:{}});function dm(e){dh.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 db(e){dg.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 dy=new Set;function d_(e){let n=dh.getState().workspaces;if(n[e])return n[e];{let n=p8(e);if(n){var t;let i;return dy.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.`),dy.add(e)),{name:n.name,title:(t=n,"string"==typeof(i=t?.meta?.title)?i:i&&"object"==typeof i?oE(t.moduleName,i.key,i.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 dv(e){let n=dg.getState().workspaceGroups;if(n[e])return n[e];throw Error(`No workspace group named '${e}' has been registered.`)}let d$=H("workspace2",{registeredGroupsByName:{},registeredWindowsByName:{},registeredWorkspacesByName:{},openedGroup:null,openedWindows:[],workspaceTitleByWorkspaceName:{},isMostRecentlyOpenedWindowHidden:!1});function dA(e){let{registeredWorkspacesByName:n,registeredWindowsByName:t}=d$.getState(),i=n[e];if(i){let n=t[i.window];if(n)return n;throw Error(`No workspace window found with name: ${i.window} for workspace: ${e}`)}throw Error(`No workspace found with name: ${e}`)}function dw(e){let{registeredGroupsByName:n,registeredWindowsByName:t}=d$.getState(),i=t[e];if(i){let t=n[i.group];if(t)return t;throw Error(`No workspace group found with name: ${i.group} for window: ${e}`)}throw Error(`No workspace window found with name: ${e}`)}function dk(e){let{openedWindows:n}=d$.getState();return n.findIndex(n=>n.openedWorkspaces.find(n=>n.workspaceName===e))}function dx(e,n){if(0==n.length)return;let{registeredGroupsByName:t}=d$.getState(),i={...t};for(let t of n){if(i[t.name])throw Error(`Cannot register workspace group ${t.name} more than once`);i[t.name]={...t,moduleName:e}}d$.setState({registeredGroupsByName:i})}function dC(e,n){if(0==n.length)return;let{registeredWindowsByName:t}=d$.getState(),i={...t};for(let t of n){if(i[t.name])throw Error(`Cannot register workspace window ${t.name} more than once`);let n={...t,moduleName:e};i[t.name]=n}d$.setState({registeredWindowsByName:i})}function dE(e,n){if(0==n.length)return;let{registeredWorkspacesByName:t}=d$.getState(),i={...t};for(let t of n){if(i[t.name])throw Error(`Cannot register workspace ${t.name} more than once`);let n={...t,moduleName:e};i[t.name]=n}d$.setState({registeredWorkspacesByName:i})}let dS=0,dD=null,dM={bootstrap:{millis:15e3,dieOnTimeout:!0},mount:{millis:15e3,dieOnTimeout:!0},unmount:{millis:15e3,dieOnTimeout:!0}};async function dz(e,n){return(await (dD??(dD=new Promise((e,n)=>{iC({name:"openmrs-extension-host",bootstrap:()=>Promise.resolve(),mount:n=>(e(n.mountParcel),Promise.resolve()),unmount:()=>Promise.resolve()},{domElement:document.createElement("div")}).mountPromise.catch(n)}).catch(e=>(console.error("The host parcel used to mount extensions could not be mounted. Falling back to mounting extensions as root parcels, which leaks their DOM elements.",e),iC))),dD))("function"==typeof e?()=>e().then(e=>({timeouts:dM,...e})):{timeouts:dM,...e},n)}function dO(){return dP}function dP(e,n){let t,i=dz(e,n).then(e=>t=e);return{mount:()=>i.then(e=>e.mount()),unmount:()=>i.then(e=>e.unmount()),update:e=>i.then(n=>n.update?.(e)),getStatus:()=>t?.getStatus()??"LOADING_SOURCE_CODE",get loadPromise(){return i.then(e=>e.loadPromise)},get bootstrapPromise(){return i.then(e=>e.bootstrapPromise)},get mountPromise(){return i.then(e=>e.mountPromise)},get unmountPromise(){return i.then(e=>e.unmountPromise)}}}async function dT(e,n,t,i,r=e=>e,o={}){let a=p4(i),s=p8(i),l=null;if(e){if(!s)throw Error(`Couldn't find extension '${a}' to attach to '${n}'`);let{meta:c,moduleName:u,online:p,offline:d,load:f}=s;if(pw(p,d)){let s,p=dS++,d=`${n}/${i}-${p}`;e.dataset.extensionRenderingId=d;let h=e=>{try{pB(d)}catch(n){console.error(e,n)}};try{pT({renderingId:d,extensionName:a,extensionModuleName:u,extensionId:i,slotName:n,slotModuleName:t})}catch(e){throw h(`Recomputing configuration after registering '${i}' failed also failed`),e}try{s=await f()}catch(e){throw h(`Recomputing configuration after '${i}' failed to load also failed`),e}try{l=await dz(r({...s,name:`${n}/${a}-${p}`}),{...o,_meta:c,_extensionContext:{extensionId:i,extensionSlotName:n,extensionSlotModuleName:t,extensionModuleName:u},domElement:e})}catch(e){throw h(`Recomputing configuration after '${i}' failed to mount also failed`),e}l.mountPromise.then(void 0,e=>{console.error(`Extension '${i}' in slot '${n}' failed to mount`,e),h(`Recomputing configuration after '${i}' failed to mount also failed`)}),l.unmountPromise.then(()=>h(`Recomputing configuration after unmounting '${i}' failed`),e=>{console.error(`Extension '${i}' in slot '${n}' failed to unmount`,e),h(`Recomputing configuration after '${i}' failed to unmount also failed`)})}}else console.warn(`Tried to render ${i} into ${n} but no DOM element was available.`);return l}var dB=t(15275),dI=t.n(dB);let dN=(0,dB.createContext)({moduleName:"",featureName:""});function dj({to:e,templateParams:n,onBeforeNavigate:t,children:i,...r}){return(0,dB.useEffect)(()=>{r.href&&console.warn(`ConfigurableLink does not support the href prop. Use the 'to' prop instead. The provided href value is '${r.href}'`),r.onClick&&console.warn(`ConfigurableLink does not support the onClick prop. Use the 'onBeforeNavigate' prop instead. The 'to' prop of the offending link is ${e}`)},[]),dI().createElement("a",{onClick:i=>{0===i.button&&!i.ctrlKey&&!i.shiftKey&&!i.altKey&&!i.metaKey&&(i.preventDefault(),t?.(i),rh({to:e,templateParams:n})),0===i.button&&(i.ctrlKey||i.metaKey)&&t?.(i),0===i.button&&i.shiftKey&&t?.(i),1===i.button&&t?.(i)},href:rd(e,n),...r},i)}let dR=({state:e,children:n,...t})=>{let{extension:i}=(0,dB.useContext)(dN),r=(0,dB.useRef)(null),o=(0,dB.useRef)(Promise.resolve()),a=(0,dB.useRef)(!1),s=(0,dB.useRef)(!1),l=(0,dB.useRef)(e),c=(0,dB.useCallback)(e=>{if(!e)return;let n=()=>{"MOUNTED"===e.getStatus()&&e.unmount()};switch(e.getStatus()){case"MOUNTED":e.unmount();break;case"UPDATING":o.current?.then(n,n);break;default:e.mountPromise.then(n,()=>{})}},[]),u=(0,dB.useCallback)((e,n)=>{e.update&&"UNMOUNTING"!==e.getStatus()&&(o.current=Promise.all([e.mountPromise,o.current]).then(()=>{if(r.current?.getStatus()==="MOUNTED"&&r.current.update)return r.current.update({...n})}).catch(e=>{let n=r.current?.getStatus();"UNMOUNTING"!==n&&"NOT_MOUNTED"!==n&&"UNLOADING"!==n&&console.error(`The extension '${i?.extensionId}' failed to update`,e)}))},[]),p=(0,dB.useCallback)(n=>{n&&!r.current&&!s.current&&i?.extensionSlotName&&i.extensionSlotModuleName&&(s.current=!0,dT(n,i.extensionSlotName,i.extensionSlotModuleName,i.extensionId,void 0,e).then(n=>{(s.current=!1,r.current=n,a.current)?c(n):n&&l.current!==e&&u(n,l.current)},()=>{s.current=!1}))},[]);return(0,dB.useEffect)(()=>(a.current=!1,()=>{a.current=!0,c(r.current)}),[]),(0,dB.useEffect)(()=>{l.current=e,r.current&&u(r.current,e)},[e]),i?dI().createElement("div",{ref:p,"data-extension-id":i?.extensionId,style:{position:"relative"},...t}):null};function dF(e){let n=(0,dB.useRef)(e);return R(n.current,e)||(n.current=e),n.current}function dL(e,n){"function"==typeof n&&(n=n(e));let t={};for(let[i,r]of Object.entries(n)){let n=function(...n){e.setState(e=>r(e,...n))};t[i]=n}return t}let dW=e=>e;function dV(e,n=dW,t){let i=(0,dB.useCallback)(n=>e.subscribe(n),[e]),r=(0,dB.useCallback)(()=>n(e.getState()),[e,n]),o=(0,dB.useSyncExternalStore)(i,r,r),a=(0,dB.useMemo)(()=>t?dL(e,t):null,[e,t]);return(0,dB.useMemo)(()=>a?{...o,...a}:o,[o,a])}function dG(e,n){return dV(e,dW,n)}function dU(e){return function(n){let t=(0,dB.useCallback)(n=>e.subscribe(n),[]),i=(0,dB.useCallback)(()=>e.getState(),[]),r=(0,dB.useSyncExternalStore)(t,i,i),o=(0,dB.useMemo)(()=>n?dL(e,n):null,[n]);return(0,dB.useMemo)(()=>o?{...r,...o}:r,[r,o])}}let dH=[];Object.freeze(dH);let dq={candidateExtensions:dH};Object.freeze(dq);let dK=e=>{let n=(0,dB.useCallback)(n=>n.slots?.[e]??dq,[e]);return dV(pI(),n)},dY=e=>e.session;function dJ(e,n){let{candidateExtensions:t}=dK(e),i=dV(rz,dY),r=dF(n);return(0,dB.useMemo)(()=>di(e,r),[e,r,i,t])}function dZ(e,n){let{moduleName:t}=(0,dB.useContext)(dN);if(!t)throw Error("ComponentContext has not been provided. This should come from @openmrs/esm-react-utils.");return(0,dB.useEffect)(()=>{da(t,e)},[t,e]),{extensions:dJ(e,n),extensionSlotName:e,extensionSlotModuleName:t}}function dX(e){return e}function dQ({name:e,extensionSlotName:n,select:t=dX,children:i,state:r,style:o,...a}){if(i&&r)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,dB.useRef)(null),{extensions:c,extensionSlotModuleName:u}=dZ(s,r),p=(0,dB.useMemo)(()=>t(c),[t,c]),d=(0,dB.useMemo)(()=>{if("function"==typeof i&&!dI().isValidElement(i))return p.map(e=>i(e,r))},[i,p]);return dI().createElement("div",{ref:l,"data-extension-slot-name":s,"data-extension-slot-module-name":u,style:{...o,position:"relative"},...a},s&&p?.map((e,n)=>dI().createElement(dN.Provider,{key:e.id,value:{moduleName:u,featureName:"",extension:{extensionId:e.id,extensionSlotName:s,extensionSlotModuleName:u}}},d?.[n]??("function"!=typeof i?i:null)??dI().createElement(dR,{state:r}))))}var d0=t(5338);function d1(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);n&&(i=i.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),t.push.apply(t,i)}return t}function d2(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?d1(Object(t),!0).forEach(function(n){var i,r,o;i=e,r=n,o=t[n],r in i?Object.defineProperty(i,r,{value:o,enumerable:!0,configurable:!0,writable:!0}):i[r]=o}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):d1(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})}return e}function d3(e){return(d3="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 d5(e){return(d5="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 d4(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(d5(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(d5(e)));return e}}var d6=null;try{d6=require("react").createContext()}catch(e){}var d8={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 d7(e,n){return e.rootComponent?Promise.resolve():e.loadRootComponent(n).then(function(n){e.rootComponent=n})}function d9(e,n){return new Promise(function(t,i){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 r,o=fi(e,n,function(){t(this)}),a=d4(e,n)(),s=function(e){var n=e.reactDom,t=e.renderType,i=e.elementToRender,r=e.domElement,o=n[t];if("function"!=typeof o)throw Error('renderType "'.concat(t,'" did not return a function.'));switch(t){case"createRoot":case"unstable_createRoot":case"createBlockingRoot":case"unstable_createBlockingRoot":var a=o(r);return a.render(i),a;case"hydrateRoot":return o(r,i);default:return o(i,r),null}}({elementToRender:o,domElement:a,reactDom:ft(e),renderType:"function"==typeof(r=e).renderType?r.renderType():r.renderType});e.domElements[n.name]=a,e.renderResults[n.name]=s})}function fe(e,n){return new Promise(function(t){e.unmountResolves[n.name]=t;var i=e.renderResults[n.name];i&&i.unmount?i.unmount():ft(e).unmountComponentAtNode(e.domElements[n.name]),delete e.domElements[n.name],delete e.renderResults[n.name]})}function fn(e,n){return new Promise(function(t){e.updateResolves[n.name]||(e.updateResolves[n.name]=[]),e.updateResolves[n.name].push(t);var i=fi(e,n,null),r=e.renderResults[n.name];if(r&&r.render)r.render(i);else{var o=d4(e,n)();ft(e).render(i,o)}})}function ft(e){return e.ReactDOMClient||e.ReactDOM}function fi(e,n,t){var i=e.React.createElement(e.rootComponent,n),r=d6?e.React.createElement(d6.Provider,{value:n},i):i;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),r=e.React.createElement(e.errorBoundaryClass,n,r)),r=e.React.createElement(e.SingleSpaRoot,d2(d2({},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])}}),r)}var fr=t(38395),fo=t(59324),fa=t(88716);let fs={strictMode:!0,throwErrorsToConsole:!0,disableTranslations:!1},fl=new Map;(0,fa.initCache)(fl);let fc={errorRetryCount:3,fetcher:rS,focusThrottleInterval:18e5,revalidateIfStale:!0,revalidateOnFocus:!1,revalidateOnReconnect:!1,refreshInterval:0,shouldRetryOnError:e=>{if(e instanceof rM){let n=e.response.status;return!!(n>=500)||401===n||403===n||429===n}return!0},provider:()=>fl};function fu(e){if("object"!=typeof e||"string"!=typeof e.featureName||"string"!=typeof e.moduleName)throw Error("Invalid options");let n=Object.assign({},fs,e),t={...fc,...n.swrConfig};return function(e){var i,r,o,a,s;return o=r=class extends(i=dI().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 dI().createElement("div",null,"An error has occurred. Please try reloading the page.");{let i=dI().createElement(dB.Suspense,{fallback:null},dI().createElement(fo.BE,{value:t},dI().createElement(dN.Provider,{value:this.state.config},n.disableTranslations?dI().createElement(e,this.props):dI().createElement(fr.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},dI().createElement(e,this.props)))));return n.strictMode&&dI().StrictMode?dI().createElement(dI().StrictMode,null,i):i}}constructor(e){super(e),this.state={caughtError:null,caughtErrorInfo:null,config:{moduleName:n.moduleName,featureName:n.featureName,extension:e._extensionContext}}}},a="displayName",s=`OpenmrsReactComponent(${n.featureName})`,a in o?Object.defineProperty(o,a,{value:s,enumerable:!0,configurable:!0,writable:!0}):o[a]=s,r}}function fp(e,n){return function(e){if("object"!==d3(e))throw Error("single-spa-react requires a configuration object");var n,t=d2(d2({},d8),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");!d6&&t.React.createContext&&(d6=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 i={bootstrap:d7.bind(null,t),mount:d9.bind(null,t),unmount:fe.bind(null,t)};return t.parcelCanUpdate&&(i.update=fn.bind(null,t)),i}({React:dI(),ReactDOMClient:d0,rootComponent:fu(n)(e)})}function fd(e,n){return()=>e().then(({default:e})=>fp(e,n))}function ff(e,n){return()=>Promise.resolve(fp(e,n))}let fh=fd,fg=V()(()=>({}));q("openmrs-app-context",fg);let fm={};function fb(e,n=e=>e){let t=fg.getState();return e in t?Object.freeze(Object.assign({},n?n(t[e]):t[e])):null}function fy(e,n){fg.setState(t=>(e in t||(t[e]={}),t[e]=n(t[e]),Object.assign({},t)))}function f_(e){return null===e?null:Object.freeze(Object.assign({},e))}let fv=new Map;function f$(e,n){let t=(0,dB.useRef)(n??{}),i=(0,dB.useRef)(n=>fy(e,n)),r=(0,dB.useRef)(Symbol());return(0,dB.useEffect)(()=>{let t=n??{},i=r.current;return null===fb(e)?!function(e,n=fm){fg.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===fm?{}: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.`),fy(e,()=>t)),fv.set(e,i),()=>{fv.get(e)===i&&(fg.setState(n=>(e in n&&delete n[e],n)),fv.delete(e))}},[e]),(0,dB.useEffect)(()=>{let i=n??{};R(t.current,i)||(fy(e,()=>i),t.current=i)},[n]),i.current}function fA({namespace:e,value:n}){return f$(e,n),null}let fw=({children:e,value:n,fallback:t})=>n?dI().createElement(dI().Fragment,null,e):t?dI().createElement(dI().Fragment,null,t):null;function fk(){let e=(0,dB.useRef)();return(!e.current||e.current.signal.aborted)&&(e.current=new AbortController),(0,dB.useEffect)(()=>{let n=e.current;return()=>n?.abort()},[]),e.current}function fx(e,n=e=>e??{}){let[t,i]=(0,dB.useState)(()=>{if(fC(e))return;let t=fb(e);if(null!==t)return n?n(t):t});return(0,dB.useEffect)(()=>{if(fC(e))throw Error(`The namespace supplied to useAppContext must be a non-empty string, but was "${e}".`)},[e]),(0,dB.useEffect)(()=>{var t;let r;return(t=e=>{if(null==e)return void i(void 0);let t=n?n(e):e;i(e=>R(e,t)?e:t)})(f_(r=fb(e))),fg.subscribe(n=>{let i=e in n?n[e]:null;i!==r&&(r=i,t(f_(i)))})},[e,n]),t}function fC(e){return"string"!=typeof e||0===e.trim().length}function fE(e){let n=dJ(e);return(0,dB.useMemo)(()=>n.map(e=>e.id),[n])}function fS(e){return dK(e).candidateExtensions}function fD(e,n){let{data:t,error:i,mutate:r,isLoading:o,isValidating:a}=(0,fo.Ay)(`${ad}?patient=${e}&includeEncounterless=${n}`,rS);return(0,dB.useMemo)(()=>({isLoading:o,data:t?.data.results??[],error:i,mutate:r,isValidating:a}),[t,i,o,a,r])}function fM(e){(0,dB.useEffect)(()=>{if(e){let e=window.getComputedStyle(document.body).overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=e}}},[e])}let fz={},fO=`No ComponentContext has been provided. This should come from "openmrsComponentDecorator".
|
|
15
|
+
${this.stack}`}}let rz=H("session",{loaded:!1,session:null}),rO=0;function rP(e={includeAuthStatus:!0}){return(rO<Date.now()-6e4||!rz.getState().loaded)&&rI(),new er.Observable(n=>{let t=t=>{t.loaded&&(e.includeAuthStatus?n.next(t.session):n.next(t.session?.user))};return t(rz.getState()),rz.subscribe(t)})}function rT(){return(rO<Date.now()-6e4||!rz.getState().loaded)&&rI(),rz}function rB(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 rI(e,n){rO=Date.now();let t={};return e&&n&&(t.Authorization=`Basic ${window.btoa(`${e}:${n}`)}`),rV(rS(rC,{headers:t}))}function rN(){rz.setState({loaded:!0,session:{authenticated:!1,sessionId:""}})}function rj(e,n){var t,i;if(void 0===n)return!e;if(!e)return!0;return t=e,i=n,("string"==typeof t?!Z(i.privileges.find(e=>t===e.display)):Array.isArray(t)?t.every(e=>!Z(i.privileges.find(n=>e===n.display))):(Z(t)||console.error(`Could not understand privileges "${t}"`),!0))||!Z(n.roles.find(e=>"System Developer"===e.display))}function rR(){let e,n;return new Promise(t=>{let i=i=>{i.loaded&&i.session.user&&(e=i.session.user,t(i.session.user),n&&n())};i(rz.getState()),e||(n=rz.subscribe(i))})}function rF(){return new Promise((e,n)=>{rP().subscribe(n=>{e(n.sessionLocation)},n).unsubscribe()})}async function rL(e,n){return rV(rS(rC,{method:"POST",body:{sessionLocation:e},headers:{"Content-Type":"application/json"},signal:n.signal}))}async function rW(e,n,t){return t||(t=new AbortController),await rS(`${rk}/user/${e}`,{method:"POST",body:{userProperties:n},headers:{"Content-Type":"application/json"},signal:t.signal}),rI()}function rV(e){return new Promise((n,t)=>{e.then(e=>{let i;"object"==typeof e?.data?(i={loaded:!0,session:e.data},rz.setState(i),n(i)):(i={loaded:!1,session:null},rz.setState(i),t(i))}).catch(e=>{I(`Failed to fetch new session information: ${e}`);let n={loaded:!1,session:null};rz.setState(n),t(n)})})}function rG(){return"development"===window.spaEnv||"true"===localStorage.getItem("openmrs:devtools")}rz.subscribe(e=>{e.loaded&&e.session&&rB(e.session)});let rU={"webservices.rest":"2.24.0",fhir2:"1.0.0-SNAPSHOT"};function rH(){ta("@openmrs/esm-api",rA),rI()}let rq={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"},rK=e=>"string"==typeof e,rY=()=>{let e,n,t=new Promise((t,i)=>{e=t,n=i});return t.resolve=e,t.reject=n,t},rJ=e=>null==e?"":""+e,rZ=/###/g,rX=e=>e&&e.indexOf("###")>-1?e.replace(rZ,"."):e,rQ=e=>!e||rK(e),r0=(e,n,t)=>{let i=rK(n)?n.split("."):n,r=0;for(;r<i.length-1;){if(rQ(e))return{};let n=rX(i[r]);!e[n]&&t&&(e[n]=new t),e=Object.prototype.hasOwnProperty.call(e,n)?e[n]:{},++r}return rQ(e)?{}:{obj:e,k:rX(i[r])}},r1=(e,n,t)=>{let{obj:i,k:r}=r0(e,n,Object);if(void 0!==i||1===n.length){i[r]=t;return}let o=n[n.length-1],a=n.slice(0,n.length-1),s=r0(e,a,Object);for(;void 0===s.obj&&a.length;)o=`${a[a.length-1]}.${o}`,s=r0(e,a=a.slice(0,a.length-1),Object),s?.obj&&void 0!==s.obj[`${s.k}.${o}`]&&(s.obj=void 0);s.obj[`${s.k}.${o}`]=t},r2=(e,n)=>{let{obj:t,k:i}=r0(e,n);if(t&&Object.prototype.hasOwnProperty.call(t,i))return t[i]},r3=(e,n,t)=>{for(let i in n)"__proto__"!==i&&"constructor"!==i&&(i in e?rK(e[i])||e[i]instanceof String||rK(n[i])||n[i]instanceof String?t&&(e[i]=n[i]):r3(e[i],n[i],t):e[i]=n[i]);return e};var r5={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};let r4=e=>rK(e)?e.replace(/[&<>"'\/]/g,e=>r5[e]):e,r6=[" ",",","?","!",";"],r8=new class{constructor(e){this.capacity=e,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(e){let n=this.regExpMap.get(e);if(void 0!==n)return n;let t=new RegExp(e);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(e,t),this.regExpQueue.push(e),t}}(20),r7=(e,n,t=".")=>{if(!e)return;if(e[n]){if(!Object.prototype.hasOwnProperty.call(e,n))return;return e[n]}let i=n.split(t),r=e;for(let e=0;e<i.length;){let n;if(!r||"object"!=typeof r)return;let o="";for(let a=e;a<i.length;++a)if(a!==e&&(o+=t),o+=i[a],void 0!==(n=r[o])){if(["string","number","boolean"].indexOf(typeof n)>-1&&a<i.length-1)continue;e+=a-e+1;break}r=n}return r},r9=e=>e?.replace("_","-"),oe={type:"logger",log(e){this.output("log",e)},warn(e){this.output("warn",e)},error(e){this.output("error",e)},output(e,n){console?.[e]?.apply?.(console,n)}};class on{constructor(e,n={}){this.init(e,n)}init(e,n={}){this.prefix=n.prefix||"i18next:",this.logger=e||oe,this.options=n,this.debug=n.debug}log(...e){return this.forward(e,"log","",!0)}warn(...e){return this.forward(e,"warn","",!0)}error(...e){return this.forward(e,"error","")}deprecate(...e){return this.forward(e,"warn","WARNING DEPRECATED: ",!0)}forward(e,n,t,i){return i&&!this.debug?null:(rK(e[0])&&(e[0]=`${t}${this.prefix} ${e[0]}`),this.logger[n](e))}create(e){return new on(this.logger,{...{prefix:`${this.prefix}:${e}:`},...this.options})}clone(e){return(e=e||this.options).prefix=e.prefix||this.prefix,new on(this.logger,e)}}var ot=new on;class oi{constructor(){this.observers={}}on(e,n){return e.split(" ").forEach(e=>{this.observers[e]||(this.observers[e]=new Map);let t=this.observers[e].get(n)||0;this.observers[e].set(n,t+1)}),this}off(e,n){if(this.observers[e]){if(!n)return void delete this.observers[e];this.observers[e].delete(n)}}emit(e,...n){this.observers[e]&&Array.from(this.observers[e].entries()).forEach(([e,t])=>{for(let i=0;i<t;i++)e(...n)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(([t,i])=>{for(let r=0;r<i;r++)t.apply(t,[e,...n])})}}class or extends oi{constructor(e,n={ns:["translation"],defaultNS:"translation"}){super(),this.data=e||{},this.options=n,void 0===this.options.keySeparator&&(this.options.keySeparator="."),void 0===this.options.ignoreJSONStructure&&(this.options.ignoreJSONStructure=!0)}addNamespaces(e){0>this.options.ns.indexOf(e)&&this.options.ns.push(e)}removeNamespaces(e){let n=this.options.ns.indexOf(e);n>-1&&this.options.ns.splice(n,1)}getResource(e,n,t,i={}){let r,o=void 0!==i.keySeparator?i.keySeparator:this.options.keySeparator,a=void 0!==i.ignoreJSONStructure?i.ignoreJSONStructure:this.options.ignoreJSONStructure;e.indexOf(".")>-1?r=e.split("."):(r=[e,n],t&&(Array.isArray(t)?r.push(...t):rK(t)&&o?r.push(...t.split(o)):r.push(t)));let s=r2(this.data,r);return(!s&&!n&&!t&&e.indexOf(".")>-1&&(e=r[0],n=r[1],t=r.slice(2).join(".")),!s&&a&&rK(t))?r7(this.data?.[e]?.[n],t,o):s}addResource(e,n,t,i,r={silent:!1}){let o=void 0!==r.keySeparator?r.keySeparator:this.options.keySeparator,a=[e,n];t&&(a=a.concat(o?t.split(o):t)),e.indexOf(".")>-1&&(a=e.split("."),i=n,n=a[1]),this.addNamespaces(n),r1(this.data,a,i),r.silent||this.emit("added",e,n,t,i)}addResources(e,n,t,i={silent:!1}){for(let i in t)(rK(t[i])||Array.isArray(t[i]))&&this.addResource(e,n,i,t[i],{silent:!0});i.silent||this.emit("added",e,n,t)}addResourceBundle(e,n,t,i,r,o={silent:!1,skipCopy:!1}){let a=[e,n];e.indexOf(".")>-1&&(a=e.split("."),i=t,t=n,n=a[1]),this.addNamespaces(n);let s=r2(this.data,a)||{};o.skipCopy||(t=JSON.parse(JSON.stringify(t))),i?r3(s,t,r):s={...s,...t},r1(this.data,a,s),o.silent||this.emit("added",e,n,t)}removeResourceBundle(e,n){this.hasResourceBundle(e,n)&&delete this.data[e][n],this.removeNamespaces(n),this.emit("removed",e,n)}hasResourceBundle(e,n){return void 0!==this.getResource(e,n)}getResourceBundle(e,n){return n||(n=this.options.defaultNS),this.getResource(e,n)}getDataByLanguage(e){return this.data[e]}hasLanguageSomeTranslations(e){let n=this.getDataByLanguage(e);return!!(n&&Object.keys(n)||[]).find(e=>n[e]&&Object.keys(n[e]).length>0)}toJSON(){return this.data}}var oo={processors:{},addPostProcessor(e){this.processors[e.name]=e},handle(e,n,t,i,r){return e.forEach(e=>{n=this.processors[e]?.process(n,t,i,r)??n}),n}};let oa=Symbol("i18next/PATH_KEY");function os(e,n){let t,i,r,{[oa]:o}=e((i=[],(r=Object.create(null)).get=(e,n)=>(t?.revoke?.(),n===oa)?i:(i.push(n),(t=Proxy.revocable(e,r)).proxy),Proxy.revocable(Object.create(null),r).proxy));return o.join(n?.keySeparator??".")}let ol={},oc=e=>!rK(e)&&"boolean"!=typeof e&&"number"!=typeof e;class ou extends oi{constructor(e,n={}){super(),((e,n,t)=>{e.forEach(e=>{n[e]&&(t[e]=n[e])})})(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=n,void 0===this.options.keySeparator&&(this.options.keySeparator="."),this.logger=ot.create("translator")}changeLanguage(e){e&&(this.language=e)}exists(e,n={interpolation:{}}){let t={...n};if(null==e)return!1;let i=this.resolve(e,t);if(i?.res===void 0)return!1;let r=oc(i.res);return!1!==t.returnObjects||!r}extractFromKey(e,n){let t=void 0!==n.nsSeparator?n.nsSeparator:this.options.nsSeparator;void 0===t&&(t=":");let i=void 0!==n.keySeparator?n.keySeparator:this.options.keySeparator,r=n.ns||this.options.defaultNS||[],o=t&&e.indexOf(t)>-1,a=!this.options.userDefinedKeySeparator&&!n.keySeparator&&!this.options.userDefinedNsSeparator&&!n.nsSeparator&&!((e,n,t)=>{n=n||"",t=t||"";let i=r6.filter(e=>0>n.indexOf(e)&&0>t.indexOf(e));if(0===i.length)return!0;let r=r8.getRegExp(`(${i.map(e=>"?"===e?"\\?":e).join("|")})`),o=!r.test(e);if(!o){let n=e.indexOf(t);n>0&&!r.test(e.substring(0,n))&&(o=!0)}return o})(e,t,i);if(o&&!a){let n=e.match(this.interpolator.nestingRegexp);if(n&&n.length>0)return{key:e,namespaces:rK(r)?[r]:r};let o=e.split(t);(t!==i||t===i&&this.options.ns.indexOf(o[0])>-1)&&(r=o.shift()),e=o.join(i)}return{key:e,namespaces:rK(r)?[r]:r}}translate(e,n,t){let i="object"==typeof n?{...n}:n;if("object"!=typeof i&&this.options.overloadTranslationOptionHandler&&(i=this.options.overloadTranslationOptionHandler(arguments)),"object"==typeof i&&(i={...i}),i||(i={}),null==e)return"";"function"==typeof e&&(e=os(e,{...this.options,...i})),Array.isArray(e)||(e=[String(e)]);let r=void 0!==i.returnDetails?i.returnDetails:this.options.returnDetails,o=void 0!==i.keySeparator?i.keySeparator:this.options.keySeparator,{key:a,namespaces:s}=this.extractFromKey(e[e.length-1],i),l=s[s.length-1],c=void 0!==i.nsSeparator?i.nsSeparator:this.options.nsSeparator;void 0===c&&(c=":");let u=i.lng||this.language,p=i.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(u?.toLowerCase()==="cimode")return p?r?{res:`${l}${c}${a}`,usedKey:a,exactUsedKey:a,usedLng:u,usedNS:l,usedParams:this.getUsedParamsDetails(i)}:`${l}${c}${a}`:r?{res:a,usedKey:a,exactUsedKey:a,usedLng:u,usedNS:l,usedParams:this.getUsedParamsDetails(i)}:a;let d=this.resolve(e,i),f=d?.res,h=d?.usedKey||a,g=d?.exactUsedKey||a,m=void 0!==i.joinArrays?i.joinArrays:this.options.joinArrays,b=!this.i18nFormat||this.i18nFormat.handleAsObject,y=void 0!==i.count&&!rK(i.count),v=ou.hasDefaultValue(i),$=y?this.pluralResolver.getSuffix(u,i.count,i):"",A=i.ordinal&&y?this.pluralResolver.getSuffix(u,i.count,{ordinal:!1}):"",w=y&&!i.ordinal&&0===i.count,k=w&&i[`defaultValue${this.options.pluralSeparator}zero`]||i[`defaultValue${$}`]||i[`defaultValue${A}`]||i.defaultValue,x=f;b&&!f&&v&&(x=k);let C=oc(x),E=Object.prototype.toString.apply(x);if(b&&x&&C&&0>["[object Number]","[object Function]","[object RegExp]"].indexOf(E)&&!(rK(m)&&Array.isArray(x))){if(!i.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");let e=this.options.returnedObjectHandler?this.options.returnedObjectHandler(h,x,{...i,ns:s}):`key '${a} (${this.language})' returned an object instead of string.`;return r?(d.res=e,d.usedParams=this.getUsedParamsDetails(i),d):e}if(o){let e=Array.isArray(x),n=e?[]:{},t=e?g:h;for(let e in x)if(Object.prototype.hasOwnProperty.call(x,e)){let r=`${t}${o}${e}`;v&&!f?n[e]=this.translate(r,{...i,defaultValue:oc(k)?k[e]:void 0,...{joinArrays:!1,ns:s}}):n[e]=this.translate(r,{...i,joinArrays:!1,ns:s}),n[e]===r&&(n[e]=x[e])}f=n}}else if(b&&rK(m)&&Array.isArray(f))(f=f.join(m))&&(f=this.extendTranslation(f,e,i,t));else{let n=!1,r=!1;!this.isValidLookup(f)&&v&&(n=!0,f=k),this.isValidLookup(f)||(r=!0,f=a);let s=(i.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&r?void 0:f,p=v&&k!==f&&this.options.updateMissing;if(r||n||p){if(this.logger.log(p?"updateKey":"missingKey",u,l,a,p?k:f),o){let e=this.resolve(a,{...i,keySeparator:!1});e&&e.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}let e=[],n=this.languageUtils.getFallbackCodes(this.options.fallbackLng,i.lng||this.language);if("fallback"===this.options.saveMissingTo&&n&&n[0])for(let t=0;t<n.length;t++)e.push(n[t]);else"all"===this.options.saveMissingTo?e=this.languageUtils.toResolveHierarchy(i.lng||this.language):e.push(i.lng||this.language);let t=(e,n,t)=>{let r=v&&t!==f?t:s;this.options.missingKeyHandler?this.options.missingKeyHandler(e,l,n,r,p,i):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(e,l,n,r,p,i),this.emit("missingKey",e,l,n,f)};this.options.saveMissing&&(this.options.saveMissingPlurals&&y?e.forEach(e=>{let n=this.pluralResolver.getSuffixes(e,i);w&&i[`defaultValue${this.options.pluralSeparator}zero`]&&0>n.indexOf(`${this.options.pluralSeparator}zero`)&&n.push(`${this.options.pluralSeparator}zero`),n.forEach(n=>{t([e],a+n,i[`defaultValue${n}`]||k)})}):t(e,a,k))}f=this.extendTranslation(f,e,i,d,t),r&&f===a&&this.options.appendNamespaceToMissingKey&&(f=`${l}${c}${a}`),(r||n)&&this.options.parseMissingKeyHandler&&(f=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${l}${c}${a}`:a,n?f:void 0,i))}return r?(d.res=f,d.usedParams=this.getUsedParamsDetails(i),d):f}extendTranslation(e,n,t,i,r){if(this.i18nFormat?.parse)e=this.i18nFormat.parse(e,{...this.options.interpolation.defaultVariables,...t},t.lng||this.language||i.usedLng,i.usedNS,i.usedKey,{resolved:i});else if(!t.skipInterpolation){let o;t.interpolation&&this.interpolator.init({...t,...{interpolation:{...this.options.interpolation,...t.interpolation}}});let a=rK(e)&&(t?.interpolation?.skipOnVariables!==void 0?t.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);if(a){let n=e.match(this.interpolator.nestingRegexp);o=n&&n.length}let s=t.replace&&!rK(t.replace)?t.replace:t;if(this.options.interpolation.defaultVariables&&(s={...this.options.interpolation.defaultVariables,...s}),e=this.interpolator.interpolate(e,s,t.lng||this.language||i.usedLng,t),a){let n=e.match(this.interpolator.nestingRegexp);o<(n&&n.length)&&(t.nest=!1)}!t.lng&&i&&i.res&&(t.lng=this.language||i.usedLng),!1!==t.nest&&(e=this.interpolator.nest(e,(...e)=>r?.[0]!==e[0]||t.context?this.translate(...e,n):(this.logger.warn(`It seems you are nesting recursively key: ${e[0]} in key: ${n[0]}`),null),t)),t.interpolation&&this.interpolator.reset()}let o=t.postProcess||this.options.postProcess,a=rK(o)?[o]:o;return null!=e&&a?.length&&!1!==t.applyPostProcessor&&(e=oo.handle(a,e,n,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...i,usedParams:this.getUsedParamsDetails(t)},...t}:t,this)),e}resolve(e,n={}){let t,i,r,o,a;return rK(e)&&(e=[e]),e.forEach(e=>{if(this.isValidLookup(t))return;let s=this.extractFromKey(e,n),l=s.key;i=l;let c=s.namespaces;this.options.fallbackNS&&(c=c.concat(this.options.fallbackNS));let u=void 0!==n.count&&!rK(n.count),p=u&&!n.ordinal&&0===n.count,d=void 0!==n.context&&(rK(n.context)||"number"==typeof n.context)&&""!==n.context,f=n.lngs?n.lngs:this.languageUtils.toResolveHierarchy(n.lng||this.language,n.fallbackLng);c.forEach(e=>{this.isValidLookup(t)||(a=e,!ol[`${f[0]}-${e}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(a)&&(ol[`${f[0]}-${e}`]=!0,this.logger.warn(`key "${i}" for languages "${f.join(", ")}" won't get resolved as namespace "${a}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),f.forEach(i=>{let a;if(this.isValidLookup(t))return;o=i;let s=[l];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(s,l,i,e,n);else{let e;u&&(e=this.pluralResolver.getSuffix(i,n.count,n));let t=`${this.options.pluralSeparator}zero`,r=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(u&&(n.ordinal&&0===e.indexOf(r)&&s.push(l+e.replace(r,this.options.pluralSeparator)),s.push(l+e),p&&s.push(l+t)),d){let i=`${l}${this.options.contextSeparator||"_"}${n.context}`;s.push(i),u&&(n.ordinal&&0===e.indexOf(r)&&s.push(i+e.replace(r,this.options.pluralSeparator)),s.push(i+e),p&&s.push(i+t))}}for(;a=s.pop();)this.isValidLookup(t)||(r=a,t=this.getResource(i,e,a,n))}))})}),{res:t,usedKey:i,exactUsedKey:r,usedLng:o,usedNS:a}}isValidLookup(e){return void 0!==e&&!(!this.options.returnNull&&null===e)&&!(!this.options.returnEmptyString&&""===e)}getResource(e,n,t,i={}){return this.i18nFormat?.getResource?this.i18nFormat.getResource(e,n,t,i):this.resourceStore.getResource(e,n,t,i)}getUsedParamsDetails(e={}){let n=e.replace&&!rK(e.replace),t=n?e.replace:e;if(n&&void 0!==e.count&&(t.count=e.count),this.options.interpolation.defaultVariables&&(t={...this.options.interpolation.defaultVariables,...t}),!n)for(let e of(t={...t},["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"]))delete t[e];return t}static hasDefaultValue(e){let n="defaultValue";for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&n===t.substring(0,n.length)&&void 0!==e[t])return!0;return!1}}class op{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=ot.create("languageUtils")}getScriptPartFromCode(e){if(!(e=r9(e))||0>e.indexOf("-"))return null;let n=e.split("-");return 2===n.length||(n.pop(),"x"===n[n.length-1].toLowerCase())?null:this.formatLanguageCode(n.join("-"))}getLanguagePartFromCode(e){if(!(e=r9(e))||0>e.indexOf("-"))return e;let n=e.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(e){if(rK(e)&&e.indexOf("-")>-1){let n;try{n=Intl.getCanonicalLocales(e)[0]}catch(e){}return(n&&this.options.lowerCaseLng&&(n=n.toLowerCase()),n)?n:this.options.lowerCaseLng?e.toLowerCase():e}return this.options.cleanCode||this.options.lowerCaseLng?e.toLowerCase():e}isSupportedCode(e){return("languageOnly"===this.options.load||this.options.nonExplicitSupportedLngs)&&(e=this.getLanguagePartFromCode(e)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(e)>-1}getBestMatchFromCodes(e){let n;return e?(e.forEach(e=>{if(n)return;let t=this.formatLanguageCode(e);(!this.options.supportedLngs||this.isSupportedCode(t))&&(n=t)}),!n&&this.options.supportedLngs&&e.forEach(e=>{if(n)return;let t=this.getScriptPartFromCode(e);if(this.isSupportedCode(t))return n=t;let i=this.getLanguagePartFromCode(e);if(this.isSupportedCode(i))return n=i;n=this.options.supportedLngs.find(e=>{if(e===i||!(0>e.indexOf("-")&&0>i.indexOf("-"))&&(e.indexOf("-")>0&&0>i.indexOf("-")&&e.substring(0,e.indexOf("-"))===i||0===e.indexOf(i)&&i.length>1))return e})}),n||(n=this.getFallbackCodes(this.options.fallbackLng)[0]),n):null}getFallbackCodes(e,n){if(!e)return[];if("function"==typeof e&&(e=e(n)),rK(e)&&(e=[e]),Array.isArray(e))return e;if(!n)return e.default||[];let t=e[n];return t||(t=e[this.getScriptPartFromCode(n)]),t||(t=e[this.formatLanguageCode(n)]),t||(t=e[this.getLanguagePartFromCode(n)]),t||(t=e.default),t||[]}toResolveHierarchy(e,n){let t=this.getFallbackCodes((!1===n?[]:n)||this.options.fallbackLng||[],e),i=[],r=e=>{e&&(this.isSupportedCode(e)?i.push(e):this.logger.warn(`rejecting language code not found in supportedLngs: ${e}`))};return rK(e)&&(e.indexOf("-")>-1||e.indexOf("_")>-1)?("languageOnly"!==this.options.load&&r(this.formatLanguageCode(e)),"languageOnly"!==this.options.load&&"currentOnly"!==this.options.load&&r(this.getScriptPartFromCode(e)),"currentOnly"!==this.options.load&&r(this.getLanguagePartFromCode(e))):rK(e)&&r(this.formatLanguageCode(e)),t.forEach(e=>{0>i.indexOf(e)&&r(this.formatLanguageCode(e))}),i}}let od={zero:0,one:1,two:2,few:3,many:4,other:5},of={select:e=>1===e?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class oh{constructor(e,n={}){this.languageUtils=e,this.options=n,this.logger=ot.create("pluralResolver"),this.pluralRulesCache={}}addRule(e,n){this.rules[e]=n}clearCache(){this.pluralRulesCache={}}getRule(e,n={}){let t,i=r9("dev"===e?"en":e),r=n.ordinal?"ordinal":"cardinal",o=JSON.stringify({cleanedCode:i,type:r});if(o in this.pluralRulesCache)return this.pluralRulesCache[o];try{t=new Intl.PluralRules(i,{type:r})}catch(r){if(!Intl)return this.logger.error("No Intl support, please use an Intl polyfill!"),of;if(!e.match(/-|_/))return of;let i=this.languageUtils.getLanguagePartFromCode(e);t=this.getRule(i,n)}return this.pluralRulesCache[o]=t,t}needsPlural(e,n={}){let t=this.getRule(e,n);return t||(t=this.getRule("dev",n)),t?.resolvedOptions().pluralCategories.length>1}getPluralFormsOfKey(e,n,t={}){return this.getSuffixes(e,t).map(e=>`${n}${e}`)}getSuffixes(e,n={}){let t=this.getRule(e,n);return(t||(t=this.getRule("dev",n)),t)?t.resolvedOptions().pluralCategories.sort((e,n)=>od[e]-od[n]).map(e=>`${this.options.prepend}${n.ordinal?`ordinal${this.options.prepend}`:""}${e}`):[]}getSuffix(e,n,t={}){let i=this.getRule(e,t);return i?`${this.options.prepend}${t.ordinal?`ordinal${this.options.prepend}`:""}${i.select(n)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix("dev",n,t))}}let og=(e,n,t,i=".",r=!0)=>{let o,a=void 0!==(o=r2(e,t))?o:r2(n,t);return!a&&r&&rK(t)&&void 0===(a=r7(e,t,i))&&(a=r7(n,t,i)),a};class om{constructor(e={}){this.logger=ot.create("interpolator"),this.options=e,this.format=e?.interpolation?.format||(e=>e),this.init(e)}init(e={}){e.interpolation||(e.interpolation={escapeValue:!0});let{escape:n,escapeValue:t,useRawValueToEscape:i,prefix:r,prefixEscaped:o,suffix:a,suffixEscaped:s,formatSeparator:l,unescapeSuffix:c,unescapePrefix:u,nestingPrefix:p,nestingPrefixEscaped:d,nestingSuffix:f,nestingSuffixEscaped:h,nestingOptionsSeparator:g,maxReplaces:m,alwaysFormat:b}=e.interpolation;this.escape=void 0!==n?n:r4,this.escapeValue=void 0===t||t,this.useRawValueToEscape=void 0!==i&&i,this.prefix=r?r.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"):o||"{{",this.suffix=a?a.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"):s||"}}",this.formatSeparator=l||",",this.unescapePrefix=c?"":u||"-",this.unescapeSuffix=this.unescapePrefix?"":c||"",this.nestingPrefix=p?p.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"):d||"$t(".replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),this.nestingSuffix=f?f.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"):h||")".replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),this.nestingOptionsSeparator=g||",",this.maxReplaces=m||1e3,this.alwaysFormat=void 0!==b&&b,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){let e=(e,n)=>e?.source===n?(e.lastIndex=0,e):RegExp(n,"g");this.regexp=e(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=e(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=e(this.nestingRegexp,`${this.nestingPrefix}((?:[^()"']+|"[^"]*"|'[^']*'|\\((?:[^()]|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`)}interpolate(e,n,t,i){let r,o,a,s=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},l=e=>{if(0>e.indexOf(this.formatSeparator)){let r=og(n,s,e,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(r,void 0,t,{...i,...n,interpolationkey:e}):r}let r=e.split(this.formatSeparator),o=r.shift().trim(),a=r.join(this.formatSeparator).trim();return this.format(og(n,s,o,this.options.keySeparator,this.options.ignoreJSONStructure),a,t,{...i,...n,interpolationkey:o})};this.resetRegExp();let c=i?.missingInterpolationHandler||this.options.missingInterpolationHandler,u=i?.interpolation?.skipOnVariables!==void 0?i.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:e=>e.replace(/\$/g,"$$$$")},{regex:this.regexp,safeValue:e=>this.escapeValue?this.escape(e).replace(/\$/g,"$$$$"):e.replace(/\$/g,"$$$$")}].forEach(n=>{for(a=0;r=n.regex.exec(e);){let t=r[1].trim();if(void 0===(o=l(t)))if("function"==typeof c){let n=c(e,r,i);o=rK(n)?n:""}else if(i&&Object.prototype.hasOwnProperty.call(i,t))o="";else if(u){o=r[0];continue}else this.logger.warn(`missed to pass in variable ${t} for interpolating ${e}`),o="";else rK(o)||this.useRawValueToEscape||(o=rJ(o));let s=n.safeValue(o);if(e=e.replace(r[0],s),u?(n.regex.lastIndex+=o.length,n.regex.lastIndex-=r[0].length):n.regex.lastIndex=0,++a>=this.maxReplaces)break}}),e}nest(e,n,t={}){let i,r,o,a=(e,n)=>{let t=this.nestingOptionsSeparator;if(0>e.indexOf(t))return e;let i=e.split(RegExp(`${t}[ ]*{`)),r=`{${i[1]}`;e=i[0];let a=(r=this.interpolate(r,o)).match(/'/g),s=r.match(/"/g);((a?.length??0)%2!=0||s)&&s.length%2==0||(r=r.replace(/'/g,'"'));try{o=JSON.parse(r),n&&(o={...n,...o})}catch(n){return this.logger.warn(`failed parsing options string in nesting for key ${e}`,n),`${e}${t}${r}`}return o.defaultValue&&o.defaultValue.indexOf(this.prefix)>-1&&delete o.defaultValue,e};for(;i=this.nestingRegexp.exec(e);){let s=[];(o=(o={...t}).replace&&!rK(o.replace)?o.replace:o).applyPostProcessor=!1,delete o.defaultValue;let l=/{.*}/.test(i[1])?i[1].lastIndexOf("}")+1:i[1].indexOf(this.formatSeparator);if(-1!==l&&(s=i[1].slice(l).split(this.formatSeparator).map(e=>e.trim()).filter(Boolean),i[1]=i[1].slice(0,l)),(r=n(a.call(this,i[1].trim(),o),o))&&i[0]===e&&!rK(r))return r;rK(r)||(r=rJ(r)),r||(this.logger.warn(`missed to resolve ${i[1]} for nesting ${e}`),r=""),s.length&&(r=s.reduce((e,n)=>this.format(e,n,t.lng,{...t,interpolationkey:i[1].trim()}),r.trim())),e=e.replace(i[0],r),this.regexp.lastIndex=0}return e}}let ob=e=>{let n={};return(t,i,r)=>{let o=r;r&&r.interpolationkey&&r.formatParams&&r.formatParams[r.interpolationkey]&&r[r.interpolationkey]&&(o={...o,[r.interpolationkey]:void 0});let a=i+JSON.stringify(o),s=n[a];return s||(s=e(r9(i),r),n[a]=s),s(t)}},oy=e=>(n,t,i)=>e(r9(t),i)(n);class o_{constructor(e={}){this.logger=ot.create("formatter"),this.options=e,this.init(e)}init(e,n={interpolation:{}}){this.formatSeparator=n.interpolation.formatSeparator||",";let t=n.cacheInBuiltFormats?ob:oy;this.formats={number:t((e,n)=>{let t=new Intl.NumberFormat(e,{...n});return e=>t.format(e)}),currency:t((e,n)=>{let t=new Intl.NumberFormat(e,{...n,style:"currency"});return e=>t.format(e)}),datetime:t((e,n)=>{let t=new Intl.DateTimeFormat(e,{...n});return e=>t.format(e)}),relativetime:t((e,n)=>{let t=new Intl.RelativeTimeFormat(e,{...n});return e=>t.format(e,n.range||"day")}),list:t((e,n)=>{let t=new Intl.ListFormat(e,{...n});return e=>t.format(e)})}}add(e,n){this.formats[e.toLowerCase().trim()]=n}addCached(e,n){this.formats[e.toLowerCase().trim()]=ob(n)}format(e,n,t,i={}){let r=n.split(this.formatSeparator);if(r.length>1&&r[0].indexOf("(")>1&&0>r[0].indexOf(")")&&r.find(e=>e.indexOf(")")>-1)){let e=r.findIndex(e=>e.indexOf(")")>-1);r[0]=[r[0],...r.splice(1,e)].join(this.formatSeparator)}return r.reduce((e,n)=>{let{formatName:r,formatOptions:o}=(e=>{let n=e.toLowerCase().trim(),t={};if(e.indexOf("(")>-1){let i=e.split("(");n=i[0].toLowerCase().trim();let r=i[1].substring(0,i[1].length-1);"currency"===n&&0>r.indexOf(":")?t.currency||(t.currency=r.trim()):"relativetime"===n&&0>r.indexOf(":")?t.range||(t.range=r.trim()):r.split(";").forEach(e=>{if(e){let[n,...i]=e.split(":"),r=i.join(":").trim().replace(/^'+|'+$/g,""),o=n.trim();t[o]||(t[o]=r),"false"===r&&(t[o]=!1),"true"===r&&(t[o]=!0),isNaN(r)||(t[o]=parseInt(r,10))}})}return{formatName:n,formatOptions:t}})(n);if(this.formats[r]){let n=e;try{let a=i?.formatParams?.[i.interpolationkey]||{},s=a.locale||a.lng||i.locale||i.lng||t;n=this.formats[r](e,s,{...o,...i,...a})}catch(e){this.logger.warn(e)}return n}return this.logger.warn(`there was no format function for ${r}`),e},e)}}class ov extends oi{constructor(e,n,t,i={}){super(),this.backend=e,this.store=n,this.services=t,this.languageUtils=t.languageUtils,this.options=i,this.logger=ot.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=i.maxParallelReads||10,this.readingCalls=0,this.maxRetries=i.maxRetries>=0?i.maxRetries:5,this.retryTimeout=i.retryTimeout>=1?i.retryTimeout:350,this.state={},this.queue=[],this.backend?.init?.(t,i.backend,i)}queueLoad(e,n,t,i){let r={},o={},a={},s={};return e.forEach(e=>{let i=!0;n.forEach(n=>{let a=`${e}|${n}`;!t.reload&&this.store.hasResourceBundle(e,n)?this.state[a]=2:this.state[a]<0||(1===this.state[a]?void 0===o[a]&&(o[a]=!0):(this.state[a]=1,i=!1,void 0===o[a]&&(o[a]=!0),void 0===r[a]&&(r[a]=!0),void 0===s[n]&&(s[n]=!0)))}),i||(a[e]=!0)}),(Object.keys(r).length||Object.keys(o).length)&&this.queue.push({pending:o,pendingCount:Object.keys(o).length,loaded:{},errors:[],callback:i}),{toLoad:Object.keys(r),pending:Object.keys(o),toLoadLanguages:Object.keys(a),toLoadNamespaces:Object.keys(s)}}loaded(e,n,t){let i=e.split("|"),r=i[0],o=i[1];n&&this.emit("failedLoading",r,o,n),!n&&t&&this.store.addResourceBundle(r,o,t,void 0,void 0,{skipCopy:!0}),this.state[e]=n?-1:2,n&&t&&(this.state[e]=0);let a={};this.queue.forEach(t=>{((e,n,t,i)=>{let{obj:r,k:o}=r0(e,n,Object);r[o]=r[o]||[],r[o].push(t)})(t.loaded,[r],o),void 0!==t.pending[e]&&(delete t.pending[e],t.pendingCount--),n&&t.errors.push(n),0!==t.pendingCount||t.done||(Object.keys(t.loaded).forEach(e=>{a[e]||(a[e]={});let n=t.loaded[e];n.length&&n.forEach(n=>{void 0===a[e][n]&&(a[e][n]=!0)})}),t.done=!0,t.errors.length?t.callback(t.errors):t.callback())}),this.emit("loaded",a),this.queue=this.queue.filter(e=>!e.done)}read(e,n,t,i=0,r=this.retryTimeout,o){if(!e.length)return o(null,{});if(this.readingCalls>=this.maxParallelReads)return void this.waitingReads.push({lng:e,ns:n,fcName:t,tried:i,wait:r,callback:o});this.readingCalls++;let a=(a,s)=>{if(this.readingCalls--,this.waitingReads.length>0){let e=this.waitingReads.shift();this.read(e.lng,e.ns,e.fcName,e.tried,e.wait,e.callback)}a&&s&&i<this.maxRetries?setTimeout(()=>{this.read.call(this,e,n,t,i+1,2*r,o)},r):o(a,s)},s=this.backend[t].bind(this.backend);if(2===s.length){try{let t=s(e,n);t&&"function"==typeof t.then?t.then(e=>a(null,e)).catch(a):a(null,t)}catch(e){a(e)}return}return s(e,n,a)}prepareLoading(e,n,t={},i){if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),i&&i();rK(e)&&(e=this.languageUtils.toResolveHierarchy(e)),rK(n)&&(n=[n]);let r=this.queueLoad(e,n,t,i);if(!r.toLoad.length)return r.pending.length||i(),null;r.toLoad.forEach(e=>{this.loadOne(e)})}load(e,n,t){this.prepareLoading(e,n,{},t)}reload(e,n,t){this.prepareLoading(e,n,{reload:!0},t)}loadOne(e,n=""){let t=e.split("|"),i=t[0],r=t[1];this.read(i,r,"read",void 0,void 0,(t,o)=>{t&&this.logger.warn(`${n}loading namespace ${r} for language ${i} failed`,t),!t&&o&&this.logger.log(`${n}loaded namespace ${r} for language ${i}`,o),this.loaded(e,t,o)})}saveMissing(e,n,t,i,r,o={},a=()=>{}){if(this.services?.utils?.hasLoadedNamespace&&!this.services?.utils?.hasLoadedNamespace(n))return void this.logger.warn(`did not save key "${t}" as the namespace "${n}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");if(null!=t&&""!==t){if(this.backend?.create){let s={...o,isUpdate:r},l=this.backend.create.bind(this.backend);if(l.length<6)try{let r;(r=5===l.length?l(e,n,t,i,s):l(e,n,t,i))&&"function"==typeof r.then?r.then(e=>a(null,e)).catch(a):a(null,r)}catch(e){a(e)}else l(e,n,t,i,a,s)}e&&e[0]&&this.store.addResource(e[0],n,t,i)}}}let o$=()=>({debug:!1,initAsync:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:e=>{let n={};if("object"==typeof e[1]&&(n=e[1]),rK(e[1])&&(n.defaultValue=e[1]),rK(e[2])&&(n.tDescription=e[2]),"object"==typeof e[2]||"object"==typeof e[3]){let t=e[3]||e[2];Object.keys(t).forEach(e=>{n[e]=t[e]})}return n},interpolation:{escapeValue:!0,format:e=>e,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0},cacheInBuiltFormats:!0}),oA=e=>(rK(e.ns)&&(e.ns=[e.ns]),rK(e.fallbackLng)&&(e.fallbackLng=[e.fallbackLng]),rK(e.fallbackNS)&&(e.fallbackNS=[e.fallbackNS]),e.supportedLngs?.indexOf?.("cimode")<0&&(e.supportedLngs=e.supportedLngs.concat(["cimode"])),"boolean"==typeof e.initImmediate&&(e.initAsync=e.initImmediate),e),ow=()=>{};class ok extends oi{constructor(e={},n){if(super(),this.options=oA(e),this.services={},this.logger=ot,this.modules={external:[]},(e=>{Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach(n=>{"function"==typeof e[n]&&(e[n]=e[n].bind(e))})})(this),n&&!this.isInitialized&&!e.isClone){if(!this.options.initAsync)return this.init(e,n),this;setTimeout(()=>{this.init(e,n)},0)}}init(e={},n){this.isInitializing=!0,"function"==typeof e&&(n=e,e={}),null==e.defaultNS&&e.ns&&(rK(e.ns)?e.defaultNS=e.ns:0>e.ns.indexOf("translation")&&(e.defaultNS=e.ns[0]));let t=o$();this.options={...t,...this.options,...oA(e)},this.options.interpolation={...t.interpolation,...this.options.interpolation},void 0!==e.keySeparator&&(this.options.userDefinedKeySeparator=e.keySeparator),void 0!==e.nsSeparator&&(this.options.userDefinedNsSeparator=e.nsSeparator);let i=e=>e?"function"==typeof e?new e:e:null;if(!this.options.isClone){let e;this.modules.logger?ot.init(i(this.modules.logger),this.options):ot.init(null,this.options),e=this.modules.formatter?this.modules.formatter:o_;let n=new op(this.options);this.store=new or(this.options.resources,this.options);let r=this.services;r.logger=ot,r.resourceStore=this.store,r.languageUtils=n,r.pluralResolver=new oh(n,{prepend:this.options.pluralSeparator,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),this.options.interpolation.format&&this.options.interpolation.format!==t.interpolation.format&&this.logger.deprecate("init: you are still using the legacy format function, please use the new approach: https://www.i18next.com/translation-function/formatting"),e&&(!this.options.interpolation.format||this.options.interpolation.format===t.interpolation.format)&&(r.formatter=i(e),r.formatter.init&&r.formatter.init(r,this.options),this.options.interpolation.format=r.formatter.format.bind(r.formatter)),r.interpolator=new om(this.options),r.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},r.backendConnector=new ov(i(this.modules.backend),r.resourceStore,r,this.options),r.backendConnector.on("*",(e,...n)=>{this.emit(e,...n)}),this.modules.languageDetector&&(r.languageDetector=i(this.modules.languageDetector),r.languageDetector.init&&r.languageDetector.init(r,this.options.detection,this.options)),this.modules.i18nFormat&&(r.i18nFormat=i(this.modules.i18nFormat),r.i18nFormat.init&&r.i18nFormat.init(this)),this.translator=new ou(this.services,this.options),this.translator.on("*",(e,...n)=>{this.emit(e,...n)}),this.modules.external.forEach(e=>{e.init&&e.init(this)})}if(this.format=this.options.interpolation.format,n||(n=ow),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){let e=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);e.length>0&&"dev"!==e[0]&&(this.options.lng=e[0])}this.services.languageDetector||this.options.lng||this.logger.warn("init: no languageDetector is used and no lng is defined"),["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach(e=>{this[e]=(...n)=>this.store[e](...n)}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(e=>{this[e]=(...n)=>(this.store[e](...n),this)});let r=rY(),o=()=>{let e=(e,t)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=!0,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),r.resolve(t),n(e,t)};if(this.languages&&!this.isInitialized)return e(null,this.t.bind(this));this.changeLanguage(this.options.lng,e)};return this.options.resources||!this.options.initAsync?o():setTimeout(o,0),r}loadResources(e,n=ow){let t=n,i=rK(e)?e:this.language;if("function"==typeof e&&(t=e),!this.options.resources||this.options.partialBundledLanguages){if(i?.toLowerCase()==="cimode"&&(!this.options.preload||0===this.options.preload.length))return t();let e=[],n=n=>{n&&"cimode"!==n&&this.services.languageUtils.toResolveHierarchy(n).forEach(n=>{"cimode"!==n&&0>e.indexOf(n)&&e.push(n)})};i?n(i):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(e=>n(e)),this.options.preload?.forEach?.(e=>n(e)),this.services.backendConnector.load(e,this.options.ns,e=>{e||this.resolvedLanguage||!this.language||this.setResolvedLanguage(this.language),t(e)})}else t(null)}reloadResources(e,n,t){let i=rY();return"function"==typeof e&&(t=e,e=void 0),"function"==typeof n&&(t=n,n=void 0),e||(e=this.languages),n||(n=this.options.ns),t||(t=ow),this.services.backendConnector.reload(e,n,e=>{i.resolve(),t(e)}),i}use(e){if(!e)throw Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!e.type)throw Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return"backend"===e.type&&(this.modules.backend=e),("logger"===e.type||e.log&&e.warn&&e.error)&&(this.modules.logger=e),"languageDetector"===e.type&&(this.modules.languageDetector=e),"i18nFormat"===e.type&&(this.modules.i18nFormat=e),"postProcessor"===e.type&&oo.addPostProcessor(e),"formatter"===e.type&&(this.modules.formatter=e),"3rdParty"===e.type&&this.modules.external.push(e),this}setResolvedLanguage(e){if(e&&this.languages&&!(["cimode","dev"].indexOf(e)>-1)){for(let e=0;e<this.languages.length;e++){let n=this.languages[e];if(!(["cimode","dev"].indexOf(n)>-1)&&this.store.hasLanguageSomeTranslations(n)){this.resolvedLanguage=n;break}}!this.resolvedLanguage&&0>this.languages.indexOf(e)&&this.store.hasLanguageSomeTranslations(e)&&(this.resolvedLanguage=e,this.languages.unshift(e))}}changeLanguage(e,n){this.isLanguageChangingTo=e;let t=rY();this.emit("languageChanging",e);let i=e=>{this.language=e,this.languages=this.services.languageUtils.toResolveHierarchy(e),this.resolvedLanguage=void 0,this.setResolvedLanguage(e)},r=(r,o)=>{o?this.isLanguageChangingTo===e&&(i(o),this.translator.changeLanguage(o),this.isLanguageChangingTo=void 0,this.emit("languageChanged",o),this.logger.log("languageChanged",o)):this.isLanguageChangingTo=void 0,t.resolve((...e)=>this.t(...e)),n&&n(r,(...e)=>this.t(...e))},o=n=>{e||n||!this.services.languageDetector||(n=[]);let t=rK(n)?n:n&&n[0],o=this.store.hasLanguageSomeTranslations(t)?t:this.services.languageUtils.getBestMatchFromCodes(rK(n)?[n]:n);o&&(this.language||i(o),this.translator.language||this.translator.changeLanguage(o),this.services.languageDetector?.cacheUserLanguage?.(o)),this.loadResources(o,e=>{r(e,o)})};return e||!this.services.languageDetector||this.services.languageDetector.async?!e&&this.services.languageDetector&&this.services.languageDetector.async?0===this.services.languageDetector.detect.length?this.services.languageDetector.detect().then(o):this.services.languageDetector.detect(o):o(e):o(this.services.languageDetector.detect()),t}getFixedT(e,n,t){let i=(e,n,...r)=>{let o,a;(o="object"!=typeof n?this.options.overloadTranslationOptionHandler([e,n].concat(r)):{...n}).lng=o.lng||i.lng,o.lngs=o.lngs||i.lngs,o.ns=o.ns||i.ns,""!==o.keyPrefix&&(o.keyPrefix=o.keyPrefix||t||i.keyPrefix);let s=this.options.keySeparator||".";return o.keyPrefix&&Array.isArray(e)?a=e.map(e=>("function"==typeof e&&(e=os(e,{...this.options,...n})),`${o.keyPrefix}${s}${e}`)):("function"==typeof e&&(e=os(e,{...this.options,...n})),a=o.keyPrefix?`${o.keyPrefix}${s}${e}`:e),this.t(a,o)};return rK(e)?i.lng=e:i.lngs=e,i.ns=n,i.keyPrefix=t,i}t(...e){return this.translator?.translate(...e)}exists(...e){return this.translator?.exists(...e)}setDefaultNamespace(e){this.options.defaultNS=e}hasLoadedNamespace(e,n={}){if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;let t=n.lng||this.resolvedLanguage||this.languages[0],i=!!this.options&&this.options.fallbackLng,r=this.languages[this.languages.length-1];if("cimode"===t.toLowerCase())return!0;let o=(e,n)=>{let t=this.services.backendConnector.state[`${e}|${n}`];return -1===t||0===t||2===t};if(n.precheck){let e=n.precheck(this,o);if(void 0!==e)return e}return!!(this.hasResourceBundle(t,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||o(t,e)&&(!i||o(r,e)))}loadNamespaces(e,n){let t=rY();return this.options.ns?(rK(e)&&(e=[e]),e.forEach(e=>{0>this.options.ns.indexOf(e)&&this.options.ns.push(e)}),this.loadResources(e=>{t.resolve(),n&&n(e)}),t):(n&&n(),Promise.resolve())}loadLanguages(e,n){let t=rY();rK(e)&&(e=[e]);let i=this.options.preload||[],r=e.filter(e=>0>i.indexOf(e)&&this.services.languageUtils.isSupportedCode(e));return r.length?(this.options.preload=i.concat(r),this.loadResources(e=>{t.resolve(),n&&n(e)}),t):(n&&n(),Promise.resolve())}dir(e){if(e||(e=this.resolvedLanguage||(this.languages?.length>0?this.languages[0]:this.language)),!e)return"rtl";try{let n=new Intl.Locale(e);if(n&&n.getTextInfo){let e=n.getTextInfo();if(e&&e.direction)return e.direction}}catch(e){}let n=this.services?.languageUtils||new op(o$());return e.toLowerCase().indexOf("-latn")>1?"ltr":["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"].indexOf(n.getLanguagePartFromCode(e))>-1||e.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(e={},n){return new ok(e,n)}cloneInstance(e={},n=ow){let t=e.forkResourceStore;t&&delete e.forkResourceStore;let i={...this.options,...e,isClone:!0},r=new ok(i);return(void 0!==e.debug||void 0!==e.prefix)&&(r.logger=r.logger.clone(e)),["store","services","language"].forEach(e=>{r[e]=this[e]}),r.services={...this.services},r.services.utils={hasLoadedNamespace:r.hasLoadedNamespace.bind(r)},t&&(r.store=new or(Object.keys(this.store.data).reduce((e,n)=>(e[n]={...this.store.data[n]},e[n]=Object.keys(e[n]).reduce((t,i)=>(t[i]={...e[n][i]},t),e[n]),e),{}),i),r.services.resourceStore=r.store),r.translator=new ou(r.services,i),r.translator.on("*",(e,...n)=>{r.emit(e,...n)}),r.init(i,n),r.translator.options=i,r.translator.backendConnector.services.utils={hasLoadedNamespace:r.hasLoadedNamespace.bind(r)},r}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}let ox=ok.createInstance();ox.createInstance=ok.createInstance,ox.createInstance,ox.dir,ox.init,ox.loadResources,ox.reloadResources,ox.use,ox.changeLanguage,ox.getFixedT,ox.t,ox.exists,ox.setDefaultNamespace,ox.hasLoadedNamespace,ox.loadNamespaces,ox.loadLanguages;let oC=ox.default||ox;function oE(e,n,t,i){return oC.t(n,{ns:e,defaultValue:t,...i})}function oS(e,n,t){return rq[e]?oE("core",e,n??rq[e],t):(console.error(`O3 Core Translations does not provide key '${e}'. The key itself is being rendered as text.`),e)}oC.on("initialized",function(){window.i18next.loadNamespaces(["core"])});let oD="import-map-override:",oM="import-map-overrides-disabled",oz="import-map-overrides:change",oO=!1,oP=null,oT=null;async function oB(){return oT??(oT=oI().then(({map:e,complete:n})=>(n||(oT=null),e))),oT}async function oI(){let e=document.querySelectorAll('script[type="systemjs-importmap"]'),n=[],t=!0;for(let i=0;i<e.length;i++){let r=e[i];try{if(r.src){let e=await fetch(r.src);if(!e.ok)throw Error(`Request for ${r.src} returned ${e.status} ${e.statusText}`);n.push(await e.json())}else r.textContent&&n.push(JSON.parse(r.textContent))}catch(e){t=!1,console.warn(`[import-maps] Failed to parse import map from script tag at index ${i}`,e)}}return{map:oN(n),complete:t}}function oN(e){let n={imports:{}};for(let t of e)t?.imports&&Object.assign(n.imports,t.imports);return n}function oj(){let e={};try{let n=oV();for(let t=0;t<localStorage.length;t++){let i=localStorage.key(t);if(i?.startsWith(oD)){let t=i.slice(oD.length);if(!n.includes(t)){let n=localStorage.getItem(i);n&&(e[t]=n)}}}}catch(e){console.warn("[import-maps] Failed to read import-map overrides from localStorage",e)}return{imports:e}}async function oR(){let e=await oB();return oO?oN([e,oP??oj()]):e}async function oF(){return oB()}async function oL(){return oO?oN([await oB(),oj()]):oB()}function oW(e){if(!oO)return{imports:{}};if(e){let e={};for(let n=0;n<localStorage.length;n++){let t=localStorage.key(n);if(t?.startsWith(oD)){let n=localStorage.getItem(t);n&&(e[t.slice(oD.length)]=n)}}return{imports:e}}return oj()}function oV(){if(!oO)return[];try{let e=localStorage.getItem(oM);if(e){let n=JSON.parse(e);if(Array.isArray(n))return n}}catch{}return[]}function oG(e){return!!oO&&oV().includes(e)}function oU(e,n){if(!oO)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{localStorage.setItem(oD+e,n),window.dispatchEvent(new CustomEvent(oz))}catch(e){console.warn("[import-maps] Failed to write import-map override to localStorage",e)}}function oH(e){if(!oO)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{localStorage.removeItem(oD+e);let n=oV().filter(n=>n!==e);n.length>0?localStorage.setItem(oM,JSON.stringify(n)):localStorage.removeItem(oM),window.dispatchEvent(new CustomEvent(oz))}catch(e){console.warn("[import-maps] Failed to update import-map overrides in localStorage",e)}}function oq(){if(!oO)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(oD)&&e.push(t)}e.forEach(e=>localStorage.removeItem(e)),localStorage.removeItem(oM),window.dispatchEvent(new CustomEvent(oz))}catch(e){console.warn("[import-maps] Failed to clear import-map overrides from localStorage",e)}}function oK(e){if(!oO)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{let n=oV().filter(n=>n!==e);n.length>0?localStorage.setItem(oM,JSON.stringify(n)):localStorage.removeItem(oM),window.dispatchEvent(new CustomEvent(oz))}catch(e){console.warn("[import-maps] Failed to update import-map overrides in localStorage",e)}}let oY=!1;function oJ(){!oY&&(oY=!0,(oO="development"===window.spaEnv)&&(oP=oj()))}function oZ(e){return e.replace(/[\/\-@]/g,"_")}async function oX(e,n="./start",i){var r;let o,a=!i?.maxLoadingTime||i.maxLoadingTime<=0?6e5:i.maxLoadingTime;await Promise.race([oQ(e,i?.importMap),new Promise((n,t)=>{o=setTimeout(()=>{var n;t(Error(`Could not resolve requested script, ${e}, within ${(n=a)<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`}.`))},a)})]),o&&clearTimeout(o);let s=oZ(e),l=window[s];if(!("object"==typeof(r=l)&&null!==r&&"init"in r&&"function"==typeof r.init&&"get"in r&&"function"==typeof r.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 oQ(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=oZ(e);if(!window[t]){let t=n??await o0();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 i=t.imports[e];i.startsWith("./")&&(i=window.spaBase+i.substring(1));let r=e in oW().imports;try{return await function(e){var n;let t=(n=window)[o1]??(n[o1]=new Map),i=t.get(e);if(i)return i;if(document.head.querySelector(`script[src="${e}"]`))return console.warn(`Script at ${e} already loaded. Not loading it again.`),Promise.resolve();let r=document.createElement("script");r.src=e,r.type="text/javascript",r.async=!0;let o=new Promise((n,i)=>{let o=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);function a(){clearTimeout(o),r.removeEventListener("load",s),r.removeEventListener("error",l)}function s(){a(),n()}function l(n){a(),t.delete(e),r.remove();let o=`Failed to load script from ${e}`;console.error(o,n),i(n.message??o)}r.addEventListener("load",s),r.addEventListener("error",l),document.head.appendChild(r)});return t.set(e,o),o}(i)}catch(e){return r&&z({kind:"error",title:oS("scriptLoadingFailed","Error: Script failed to load"),description:oS("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:i}),actionButtonLabel:oS("resetOverrides","Reset overrides"),onActionButtonClick(){oq(),window.location.reload()}}),Promise.reject(e)}}return Promise.resolve()}async function o0(){return oR()}let o1=Symbol.for("__openmrs_script_loading");function o2(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 o3(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&&o2(n))}let o5="openmrs-routes:",o4="openmrs-routes:change",o6=!1,o8=null,o7=null;async function o9(){return o7??(o7=ae().then(({map:e,complete:n})=>(n||(o7=null),e))),o7}async function ae(){let e=document.querySelectorAll("script[type='openmrs-routes']"),n=[],t=!0;for(let i=0;i<e.length;i++){let r=e[i];try{let e;if(r.src){let n=await fetch(r.src);if(!n.ok)throw Error(`Request for ${r.src} returned ${n.status} ${n.statusText}`);e=await n.json()}else r.textContent&&(e=JSON.parse(r.textContent));e&&o3(e)&&n.push(e)}catch(e){t=!1,console.warn(`[route-maps] Failed to parse routes from script tag at index ${i}`,e)}}return{map:an(n),complete:t}}function an(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 at(){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(o5)){let e=localStorage.getItem(t);e&&n.push({moduleName:t.slice(o5.length),raw:e})}}for(let t of(await Promise.allSettled(n.map(async({moduleName:e,raw:n})=>{let t=JSON.parse(n);if(o2(t))return{moduleName:e,routes:t};if("string"==typeof t&&t.startsWith("http")){let n=await fetch(t),i=await n.json();if(o2(i))return{moduleName:e,routes:i};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 ai(){let e=await o9();return o6?an([e,o8??await at()]):e}async function ar(){return o9()}async function ao(){return o6?an([await o9(),await at()]):o9()}function aa(){if(!o6)return{};let e={};try{for(let n=0;n<localStorage.length;n++){let t=localStorage.key(n);if(t?.startsWith(o5)){let n=localStorage.getItem(t);n&&(e[t.slice(o5.length)]=n)}}}catch(e){console.warn("[route-maps] Failed to read route overrides from localStorage",e)}return e}function as(e,n){if(!o6)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{if("string"==typeof n)if(n.startsWith("http"))localStorage.setItem(o5+e,JSON.stringify(n));else{let t=JSON.parse(n);if(!o2(t))return void console.error(`The supplied routes for ${e} is not a valid OpenmrsAppRoutes object`,n);localStorage.setItem(o5+e,JSON.stringify(t))}else if(n instanceof URL)localStorage.setItem(o5+e,JSON.stringify(n.toString()));else{if(!o2(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(o5+e,JSON.stringify(n))}window.dispatchEvent(new CustomEvent(o4))}catch(e){console.warn("[route-maps] Failed to write route override to localStorage",e)}}function al(e){if(!o6)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{localStorage.removeItem(o5+e),window.dispatchEvent(new CustomEvent(o4))}catch(e){console.warn("[route-maps] Failed to remove route override from localStorage",e)}}function ac(){if(!o6)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(o5)&&e.push(t)}e.forEach(e=>localStorage.removeItem(e)),window.dispatchEvent(new CustomEvent(o4))}catch(e){console.warn("[route-maps] Failed to clear route overrides from localStorage",e)}}let au=null;function ap(){return au||(au=(o6="development"===window.spaEnv)?at().then(e=>{o8=e}):Promise.resolve())}let ad=`${rk}/attachment`;function af(e,n){return rS(`${ad}/${e}`,{signal:n.signal})}function ah(e,n,t){return rS(`${ad}?patient=${e}&includeEncounterless=${n}`,{signal:t.signal})}async function ag(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)),rS(`${ad}`,{method:"POST",body:t})}function am(e,n){return rS(`${ad}/${e}`,{method:"DELETE",signal:n.signal})}try{self["workbox:window:6.5.4"]&&_()}catch(e){}function ab(e,n){return new Promise(function(t){var i=new MessageChannel;i.port1.onmessage=function(e){t(e.data)},e.postMessage(n,[i.port2])})}function ay(e,n){for(var t=0;t<n.length;t++){var i=n[t];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function a_(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,i=Array(n);t<n;t++)i[t]=e[t];return i}try{self["workbox:core:6.5.4"]&&_()}catch(e){}var av=function(){var e=this;this.promise=new Promise(function(n,t){e.resolve=n,e.reject=t})};function a$(e,n){var t=location.href;return new URL(e,t).href===new URL(n,t).href}var aA=function(e,n){this.type=e,Object.assign(this,n)};function aw(e,n,t){return t?n?n(e):e:(e&&e.then||(e=Promise.resolve(e)),n?e.then(n):e)}function ak(){}var ax={type:"SKIP_WAITING"};function aC(e,n){if(!n)return e&&e.then?e.then(ak):Promise.resolve()}var aE=function(e){function n(n,t){var i,r;return void 0===t&&(t={}),(i=e.call(this)||this).nn={},i.tn=0,i.rn=new av,i.en=new av,i.on=new av,i.un=0,i.an=new Set,i.cn=function(){var e=i.fn,n=e.installing;i.tn>0||!a$(n.scriptURL,i.sn.toString())||performance.now()>i.un+6e4?(i.vn=n,e.removeEventListener("updatefound",i.cn)):(i.hn=n,i.an.add(n),i.rn.resolve(n)),++i.tn,n.addEventListener("statechange",i.ln)},i.ln=function(e){var n=i.fn,t=e.target,r=t.state,o=t===i.vn,a={sw:t,isExternal:o,originalEvent:e};!o&&i.mn&&(a.isUpdate=!0),i.dispatchEvent(new aA(r,a)),"installed"===r?i.wn=self.setTimeout(function(){"installed"===r&&n.waiting===t&&i.dispatchEvent(new aA("waiting",a))},200):"activating"===r&&(clearTimeout(i.wn),o||i.en.resolve(t))},i.dn=function(e){var n=i.hn,t=n!==navigator.serviceWorker.controller;i.dispatchEvent(new aA("controlling",{isExternal:t,originalEvent:e,sw:n,isUpdate:i.mn})),t||i.on.resolve(n)},r=function(e){var n=e.data,t=e.ports,r=e.source;return aw(i.getSW(),function(){i.an.has(r)&&i.dispatchEvent(new aA("message",{data:n,originalEvent:e,ports:t,sw:r}))})},i.gn=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];try{return Promise.resolve(r.apply(this,e))}catch(e){return Promise.reject(e)}},i.sn=n,i.nn=t,navigator.serviceWorker.addEventListener("message",i.gn),i}n.prototype=Object.create(e.prototype),n.prototype.constructor=n,n.__proto__=e;var t,i,r=n.prototype;return r.register=function(e){var n=(void 0===e?{}:e).immediate,t=void 0!==n&&n;try{var i,r,o,a=this;return i=function(){if(!t&&"complete"!==document.readyState)return aC(new Promise(function(e){return window.addEventListener("load",e)}))},r=function(){return a.mn=!!navigator.serviceWorker.controller,a.yn=a.pn(),aw(a.bn(),function(e){a.fn=e,a.yn&&(a.hn=a.yn,a.en.resolve(a.yn),a.on.resolve(a.yn),a.yn.addEventListener("statechange",a.ln,{once:!0}));var n=a.fn.waiting;return n&&a$(n.scriptURL,a.sn.toString())&&(a.hn=n,Promise.resolve().then(function(){a.dispatchEvent(new aA("waiting",{sw:n,wasWaitingBeforeRegister:!0}))}).then(function(){})),a.hn&&(a.rn.resolve(a.hn),a.an.add(a.hn)),a.fn.addEventListener("updatefound",a.cn),navigator.serviceWorker.addEventListener("controllerchange",a.dn),a.fn})},(o=i())&&o.then?o.then(r):r(o)}catch(e){return Promise.reject(e)}},r.update=function(){try{return this.fn?aC(this.fn.update()):void 0}catch(e){return Promise.reject(e)}},r.getSW=function(){return void 0!==this.hn?Promise.resolve(this.hn):this.rn.promise},r.messageSW=function(e){try{return aw(this.getSW(),function(n){return ab(n,e)})}catch(e){return Promise.reject(e)}},r.messageSkipWaiting=function(){this.fn&&this.fn.waiting&&ab(this.fn.waiting,ax)},r.pn=function(){var e=navigator.serviceWorker.controller;return e&&a$(e.scriptURL,this.sn.toString())?e:void 0},r.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 aw(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}}],ay(n.prototype,t),i&&ay(n,i),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 a_(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)?a_(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 aS(e,n){if(void 0!==d)return console.warn(`The application's Service Worker has already been registered. The new service worker at ${e} will not be registered.`),d;if(!("serviceWorker"in navigator))throw Error("Registering the Service Worker is not possible due to missing browser capabilities.");let t=new aE(e,n);return d=t.register().then(()=>t.controlling.then(()=>t))}function aD(){return d??Promise.resolve(void 0)}let aM="x-omrs-offline-response-body",az="x-omrs-offline-response-status",aO="x-omrs-offline-caching-strategy";async function aP(e){let n=await aD();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 aT(){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 aB(){return!window.indexedDB}async function aI(){return new Promise(e=>{let n=indexedDB.open("test");n.onerror=()=>e(!0),n.onsuccess=()=>e(!1)})}async function aN(){return await aI()||await aB()||await aT()}let aj="openmrs3:offline-mode",aR="unavailable";function aF(){return{current:aR,notAvailable:"unavailable"===aR,active:"on"===aR}}function aL(e){"unavailable"!==aR&&"unavailable"!==e&&(localStorage.setItem(aj,"on"===e?"active":"disabled"),aR=e)}async function aW(){await aN()||(aR="active"===localStorage.getItem(aj)?"on":"off"),navigator.onLine}let aV="u">typeof globalThis?globalThis:"u">typeof self?self:"u">typeof window?window:global,aG=Object.keys,aU=Array.isArray;function aH(e,n){return"object"!=typeof n||aG(n).forEach(function(t){e[t]=n[t]}),e}"u"<typeof Promise||aV.Promise||(aV.Promise=Promise);let aq=Object.getPrototypeOf,aK={}.hasOwnProperty;function aY(e,n){return aK.call(e,n)}function aJ(e,n){"function"==typeof n&&(n=n(aq(e))),("u"<typeof Reflect?aG:Reflect.ownKeys)(n).forEach(t=>{aX(e,t,n[t])})}let aZ=Object.defineProperty;function aX(e,n,t,i){aZ(e,n,aH(t&&aY(t,"get")&&"function"==typeof t.get?{get:t.get,set:t.set,configurable:!0}:{value:t,configurable:!0,writable:!0},i))}function aQ(e){return{from:function(n){return e.prototype=Object.create(n.prototype),aX(e.prototype,"constructor",e),{extend:aJ.bind(null,e.prototype)}}}}let a0=Object.getOwnPropertyDescriptor;function a1(e,n){let t;return a0(e,n)||(t=aq(e))&&a1(t,n)}let a2=[].slice;function a3(e,n,t){return a2.call(e,n,t)}function a5(e,n){return n(e)}function a4(e){if(!e)throw Error("Assertion Failed")}function a6(e){aV.setImmediate?setImmediate(e):setTimeout(e,0)}function a8(e,n){return e.reduce((e,t,i)=>{var r=n(t,i);return r&&(e[r[0]]=r[1]),e},{})}function a7(e,n){if(aY(e,n))return e[n];if(!n)return e;if("string"!=typeof n){for(var t=[],i=0,r=n.length;i<r;++i){var o=a7(e,n[i]);t.push(o)}return t}var a=n.indexOf(".");if(-1!==a){var s=e[n.substr(0,a)];return void 0===s?void 0:a7(s,n.substr(a+1))}}function a9(e,n,t){if(e&&void 0!==n&&(!("isFrozen"in Object)||!Object.isFrozen(e)))if("string"!=typeof n&&"length"in n){a4("string"!=typeof t&&"length"in t);for(var i=0,r=n.length;i<r;++i)a9(e,n[i],t[i])}else{var o=n.indexOf(".");if(-1!==o){var a=n.substr(0,o),s=n.substr(o+1);if(""===s)void 0===t?aU(e)&&!isNaN(parseInt(a))?e.splice(a,1):delete e[a]:e[a]=t;else{var l=e[a];l&&aY(e,a)||(l=e[a]={}),a9(l,s,t)}}else void 0===t?aU(e)&&!isNaN(parseInt(n))?e.splice(n,1):delete e[n]:e[n]=t}}function se(e){var n={};for(var t in e)aY(e,t)&&(n[t]=e[t]);return n}let sn=[].concat;function st(e){return sn.apply([],e)}let si="Boolean,String,Date,RegExp,Blob,File,FileList,FileSystemFileHandle,ArrayBuffer,DataView,Uint8ClampedArray,ImageBitmap,ImageData,Map,Set,CryptoKey".split(",").concat(st([8,16,32,64].map(e=>["Int","Uint","Float"].map(n=>n+e+"Array")))).filter(e=>aV[e]),sr=si.map(e=>aV[e]);a8(si,e=>[e,!0]);let so=null;function sa(e){so="u">typeof WeakMap&&new WeakMap;let n=function e(n){if(!n||"object"!=typeof n)return n;let t=so&&so.get(n);if(t)return t;if(aU(n)){t=[],so&&so.set(n,t);for(var i=0,r=n.length;i<r;++i)t.push(e(n[i]))}else if(sr.indexOf(n.constructor)>=0)t=n;else{let i=aq(n);for(var o in t=i===Object.prototype?{}:Object.create(i),so&&so.set(n,t),n)aY(n,o)&&(t[o]=e(n[o]))}return t}(e);return so=null,n}let{toString:ss}={};function sl(e){return ss.call(e).slice(8,-1)}let sc="u">typeof Symbol?Symbol.iterator:"@@iterator",su="symbol"==typeof sc?function(e){var n;return null!=e&&(n=e[sc])&&n.apply(e)}:function(){return null},sp={};function sd(e){var n,t,i,r;if(1==arguments.length){if(aU(e))return e.slice();if(this===sp&&"string"==typeof e)return[e];if(r=su(e)){for(t=[];!(i=r.next()).done;)t.push(i.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 sf="u">typeof Symbol?e=>"AsyncFunction"===e[Symbol.toStringTag]:()=>!1;var sh="u">typeof location&&/^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href),sg=()=>!0;let sm=!Error("").stack;function sb(){if(sm)try{throw sb.arguments,Error()}catch(e){return e}return Error()}function sy(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(sg).map(e=>"\n"+e).join("")):""}var s_=["Unknown","Constraint","Data","TransactionInactive","ReadOnly","Version","NotFound","InvalidState","InvalidAccess","Abort","Timeout","QuotaExceeded","Syntax","DataClone"],sv=["Modify","Bulk","OpenFailed","VersionChange","Schema","Upgrade","InvalidTable","MissingAPI","NoSuchDatabase","InvalidArgument","SubTransaction","Unsupported","Internal","DatabaseClosed","PrematureCommit","ForeignAwait"].concat(s_),s$={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 sA(e,n){this._e=sb(),this.name=e,this.message=n}function sw(e,n){return e+". Errors: "+Object.keys(n).map(e=>n[e].toString()).filter((e,n,t)=>t.indexOf(e)===n).join("\n")}function sk(e,n,t,i){this._e=sb(),this.failures=n,this.failedKeys=i,this.successCount=t,this.message=sw(e,n)}function sx(e,n){this._e=sb(),this.name="BulkError",this.failures=Object.keys(n).map(e=>n[e]),this.failuresByPos=n,this.message=sw(e,n)}aQ(sA).from(Error).extend({stack:{get:function(){return this._stack||(this._stack=this.name+": "+this.message+sy(this._e,2))}},toString:function(){return this.name+": "+this.message}}),aQ(sk).from(sA),aQ(sx).from(sA);var sC=sv.reduce((e,n)=>(e[n]=n+"Error",e),{}),sE=sv.reduce((e,n)=>{var t=n+"Error";function i(e,i){this._e=sb(),this.name=t,e?"string"==typeof e?(this.message=`${e}${i?"\n "+i:""}`,this.inner=i||null):"object"==typeof e&&(this.message=`${e.name} ${e.message}`,this.inner=e):(this.message=s$[n]||t,this.inner=null)}return aQ(i).from(sA),e[n]=i,e},{});sE.Syntax=SyntaxError,sE.Type=TypeError,sE.Range=RangeError;var sS=s_.reduce((e,n)=>(e[n+"Error"]=sE[n],e),{}),sD=sv.reduce((e,n)=>(-1===["Syntax","Type","Range"].indexOf(n)&&(e[n+"Error"]=sE[n]),e),{});function sM(){}function sz(e){return e}function sO(e,n){return null==e||e===sz?n:function(t){return n(e(t))}}function sP(e,n){return function(){e.apply(this,arguments),n.apply(this,arguments)}}function sT(e,n){return e===sM?n:function(){var t=e.apply(this,arguments);void 0!==t&&(arguments[0]=t);var i=this.onsuccess,r=this.onerror;this.onsuccess=null,this.onerror=null;var o=n.apply(this,arguments);return i&&(this.onsuccess=this.onsuccess?sP(i,this.onsuccess):i),r&&(this.onerror=this.onerror?sP(r,this.onerror):r),void 0!==o?o:t}}function sB(e,n){return e===sM?n:function(){e.apply(this,arguments);var t=this.onsuccess,i=this.onerror;this.onsuccess=this.onerror=null,n.apply(this,arguments),t&&(this.onsuccess=this.onsuccess?sP(t,this.onsuccess):t),i&&(this.onerror=this.onerror?sP(i,this.onerror):i)}}function sI(e,n){return e===sM?n:function(t){var i=e.apply(this,arguments);aH(t,i);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?sP(r,this.onsuccess):r),o&&(this.onerror=this.onerror?sP(o,this.onerror):o),void 0===i?void 0===a?void 0:a:aH(i,a)}}function sN(e,n){return e===sM?n:function(){return!1!==n.apply(this,arguments)&&e.apply(this,arguments)}}function sj(e,n){return e===sM?n:function(){var t=e.apply(this,arguments);if(t&&"function"==typeof t.then){for(var i=this,r=arguments.length,o=Array(r);r--;)o[r]=arguments[r];return t.then(function(){return n.apply(i,o)})}return n.apply(this,arguments)}}sD.ModifyError=sk,sD.DexieError=sA,sD.BulkError=sx;var sR={};let[sF,sL,sW]="u"<typeof Promise?[]:(()=>{let e=Promise.resolve();if("u"<typeof crypto||!crypto.subtle)return[e,aq(e),e];let n=crypto.subtle.digest("SHA-512",new Uint8Array([0]));return[n,aq(n),e]})(),sV=sL&&sL.then,sG=sF&&sF.constructor,sU=!!sW;var sH=!1,sq=sW?()=>{sW.then(lr)}:aV.setImmediate?setImmediate.bind(null,lr):aV.MutationObserver?()=>{var e=document.createElement("div");new MutationObserver(()=>{lr(),e=null}).observe(e,{attributes:!0}),e.setAttribute("i","1")}:()=>{setTimeout(lr,0)},sK=function(e,n){s3.push([e,n]),sJ&&(sq(),sJ=!1)},sY=!0,sJ=!0,sZ=[],sX=[],sQ=null,s0=sz,s1={id:"global",global:!0,ref:0,unhandleds:[],onunhandled:lS,pgp:!1,env:{},finalize:function(){this.unhandleds.forEach(e=>{try{lS(e[0],e[1])}catch(e){}})}},s2=s1,s3=[],s5=0,s4=[];function s6(e){if("object"!=typeof this)throw TypeError("Promises must be constructed via new");this._listeners=[],this.onuncatched=sM,this._lib=!1;var n=this._PSD=s2;if(sh&&(this._stackHolder=sb(),this._prev=null,this._numPrev=0),"function"!=typeof e){if(e!==sR)throw TypeError("Not a function");return this._state=arguments[1],this._value=arguments[2],void(!1===this._state&&s9(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 i=n._lib&&lo();t&&"function"==typeof t.then?e(n,(e,n)=>{t instanceof s6?t._then(e,n):t.then(e,n)}):(n._state=!0,n._value=t,le(n)),i&&la()}},s9.bind(null,n))}catch(e){s9(n,e)}}(this,e)}let s8={get:function(){var e=s2,n=lh;function t(t,i){var r=!e.global&&(e!==s2||n!==lh);let o=r&&!ly();var a=new s6((n,a)=>{ln(this,new s7(lx(t,e,r,o),lx(i,e,r,o),n,a,e))});return sh&&li(a,this),a}return t.prototype=sR,t},set:function(e){aX(this,"then",e&&e.prototype===sR?s8:{get:function(){return e},set:s8.set})}};function s7(e,n,t,i,r){this.onFulfilled="function"==typeof e?e:null,this.onRejected="function"==typeof n?n:null,this.resolve=t,this.reject=i,this.psd=r}function s9(e,n){if(sX.push(n),null===e._state){var t=e._lib&&lo();n=s0(n),e._state=!1,e._value=n,sh&&null!==n&&"object"==typeof n&&!n._promise&&function(e){try{e.apply(null,void 0)}catch(e){}}(()=>{var t=a1(n,"stack");n._promise=e,aX(n,"stack",{get:()=>sH?t&&(t.get?t.get.apply(n):t.value):e.stack})}),sZ.some(n=>n._value===e._value)||sZ.push(e),le(e),t&&la()}}function le(e){var n=e._listeners;e._listeners=[];for(var t=0,i=n.length;t<i;++t)ln(e,n[t]);var r=e._PSD;--r.ref||r.finalize(),0===s5&&(++s5,sK(()=>{0==--s5&&ls()},[]))}function ln(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,++s5,sK(lt,[t,e,n])}else e._listeners.push(n)}function lt(e,n,t){try{sQ=n;var i,r=n._value;n._state?i=e(r):(sX.length&&(sX=[]),i=e(r),-1===sX.indexOf(r)&&function(e){for(var n=sZ.length;n;)if(sZ[--n]._value===e._value)return void sZ.splice(n,1)}(n)),t.resolve(i)}catch(e){t.reject(e)}finally{sQ=null,0==--s5&&ls(),--t.psd.ref||t.psd.finalize()}}function li(e,n){var t=n?n._numPrev+1:0;t<100&&(e._prev=n,e._numPrev=t)}function lr(){lo()&&la()}function lo(){var e=sY;return sY=!1,sJ=!1,e}function la(){var e,n,t;do for(;s3.length>0;)for(e=s3,s3=[],t=e.length,n=0;n<t;++n){var i=e[n];i[0].apply(null,i[1])}while(s3.length>0);sY=!0,sJ=!0}function ls(){var e=sZ;sZ=[],e.forEach(e=>{e._PSD.onunhandled.call(null,e._value,e)});for(var n=s4.slice(0),t=n.length;t;)n[--t]()}function ll(e){return new s6(sR,!1,e)}function lc(e,n){var t=s2;return function(){var i=lo(),r=s2;try{return lA(t,!0),e.apply(this,arguments)}catch(e){n&&n(e)}finally{lA(r,!1),i&&la()}}}aJ(s6.prototype,{then:s8,_then:function(e,n){ln(this,new s7(null,null,e,n,s2))},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):ll(e)):this.then(null,e=>e&&e.name===n?t(e):ll(e))},finally:function(e){return this.then(n=>(e(),n),n=>(e(),ll(n)))},stack:{get:function(){if(this._stack)return this._stack;try{sH=!0;var e=(function e(n,t,i){if(t.length===i)return t;var r="";if(!1===n._state){var o,a,s=n._value;null!=s?(o=s.name||"Error",a=s.message||s,r=sy(s,0)):(o=s,a=""),t.push(o+(a?": "+a:"")+r)}return sh&&((r=sy(n._stackHolder,2))&&-1===t.indexOf(r)&&t.push(r),n._prev&&e(n._prev,t,i)),t})(this,[],20).join("\nFrom previous: ");return null!==this._state&&(this._stack=e),e}finally{sH=!1}}},timeout:function(e,n){return e<1/0?new s6((t,i)=>{var r=setTimeout(()=>i(new sE.Timeout(n)),e);this.then(t,i).finally(clearTimeout.bind(null,r))}):this}}),"u">typeof Symbol&&Symbol.toStringTag&&aX(s6.prototype,Symbol.toStringTag,"Dexie.Promise"),s1.env=lw(),aJ(s6,{all:function(){var e=sd.apply(null,arguments).map(l_);return new s6(function(n,t){0===e.length&&n([]);var i=e.length;e.forEach((r,o)=>s6.resolve(r).then(t=>{e[o]=t,--i||n(e)},t))})},resolve:e=>{if(e instanceof s6)return e;if(e&&"function"==typeof e.then)return new s6((n,t)=>{e.then(n,t)});var n=new s6(sR,!0,e);return li(n,sQ),n},reject:ll,race:function(){var e=sd.apply(null,arguments).map(l_);return new s6((n,t)=>{e.map(e=>s6.resolve(e).then(n,t))})},PSD:{get:()=>s2,set:e=>s2=e},totalEchoes:{get:()=>lh},newPSD:lm,usePSD:lk,scheduler:{get:()=>sK,set:e=>{sK=e}},rejectionMapper:{get:()=>s0,set:e=>{s0=e}},follow:(e,n)=>new s6((t,i)=>lm((n,t)=>{var i=s2;i.unhandleds=[],i.onunhandled=t,i.finalize=sP(function(){var e;e=()=>{0===this.unhandleds.length?n():t(this.unhandleds[0])},s4.push(function n(){e(),s4.splice(s4.indexOf(n),1)}),++s5,sK(()=>{0==--s5&&ls()},[])},i.finalize),e()},n,t,i))}),sG&&(sG.allSettled&&aX(s6,"allSettled",function(){let e=sd.apply(null,arguments).map(l_);return new s6(n=>{0===e.length&&n([]);let t=e.length,i=Array(t);e.forEach((e,r)=>s6.resolve(e).then(e=>i[r]={status:"fulfilled",value:e},e=>i[r]={status:"rejected",reason:e}).then(()=>--t||n(i)))})}),sG.any&&"u">typeof AggregateError&&aX(s6,"any",function(){let e=sd.apply(null,arguments).map(l_);return new s6((n,t)=>{0===e.length&&t(AggregateError([]));let i=e.length,r=Array(i);e.forEach((e,o)=>s6.resolve(e).then(e=>n(e),e=>{r[o]=e,--i||t(AggregateError(r))}))})}));let lu={awaits:0,echoes:0,id:0};var lp=0,ld=[],lf=0,lh=0,lg=0;function lm(e,n,t,i){var r=s2,o=Object.create(r);o.parent=r,o.ref=0,o.global=!1,o.id=++lg;var a=s1.env;o.env=sU?{Promise:s6,PromiseProp:{value:s6,configurable:!0,writable:!0},all:s6.all,race:s6.race,allSettled:s6.allSettled,any:s6.any,resolve:s6.resolve,reject:s6.reject,nthen:lC(a.nthen,o),gthen:lC(a.gthen,o)}:{},n&&aH(o,n),++r.ref,o.finalize=function(){--this.parent.ref||this.parent.finalize()};var s=lk(o,e,t,i);return 0===o.ref&&o.finalize(),s}function lb(){return lu.id||(lu.id=++lp),++lu.awaits,lu.echoes+=100,lu.id}function ly(){return!!lu.awaits&&(0==--lu.awaits&&(lu.id=0),lu.echoes=100*lu.awaits,!0)}function l_(e){return lu.echoes&&e&&e.constructor===sG?(lb(),e.then(e=>(ly(),e),e=>(ly(),lD(e)))):e}function lv(e){++lh,lu.echoes&&0!=--lu.echoes||(lu.echoes=lu.id=0),ld.push(s2),lA(e,!0)}function l$(){var e=ld[ld.length-1];ld.pop(),lA(e,!1)}function lA(e,n){var t,i=s2;if((n?!lu.echoes||lf++&&e===s2:!lf||--lf&&e===s2)||(t=n?lv.bind(null,e):l$,sV.call(sF,t)),e!==s2&&(s2=e,i===s1&&(s1.env=lw()),sU)){var r=s1.env.Promise,o=e.env;sL.then=o.nthen,r.prototype.then=o.gthen,(i.global||e.global)&&(Object.defineProperty(aV,"Promise",o.PromiseProp),r.all=o.all,r.race=o.race,r.resolve=o.resolve,r.reject=o.reject,o.allSettled&&(r.allSettled=o.allSettled),o.any&&(r.any=o.any))}}function lw(){var e=aV.Promise;return sU?{Promise:e,PromiseProp:Object.getOwnPropertyDescriptor(aV,"Promise"),all:e.all,race:e.race,allSettled:e.allSettled,any:e.any,resolve:e.resolve,reject:e.reject,nthen:sL.then,gthen:e.prototype.then}:{}}function lk(e,n,t,i,r){var o=s2;try{return lA(e,!0),n(t,i,r)}finally{lA(o,!1)}}function lx(e,n,t,i){return"function"!=typeof e?e:function(){var r,o=s2;t&&lb(),lA(n,!0);try{return e.apply(this,arguments)}finally{lA(o,!1),i&&(r=ly,sV.call(sF,r))}}}function lC(e,n){return function(t,i){return e.call(this,lx(t,n),lx(i,n))}}-1===(""+sV).indexOf("[native code]")&&(lb=ly=sM);let lE="unhandledrejection";function lS(e,n){var t;try{t=n.onuncatched(e)}catch(e){}if(!1!==t)try{var i,r={promise:n,reason:e};if(aV.document&&document.createEvent?((i=document.createEvent("Event")).initEvent(lE,!0,!0),aH(i,r)):aV.CustomEvent&&aH(i=new CustomEvent(lE,{detail:r}),r),i&&aV.dispatchEvent&&(dispatchEvent(i),!aV.PromiseRejectionEvent&&aV.onunhandledrejection))try{aV.onunhandledrejection(i)}catch(e){}sh&&i&&!i.defaultPrevented&&console.warn(`Unhandled rejection: ${e.stack||e}`)}catch(e){}}var lD=s6.reject;let lM="3.2.4",lz=String.fromCharCode(65535),lO=-1/0,lP="Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.",lT="String expected.",lB=[],lI="u">typeof navigator&&/(MSIE|Trident|Edge)/.test(navigator.userAgent),lN=e=>!/(dexie\.js|dexie\.min\.js)/.test(e),lj="__dbnames",lR="readonly",lF="readwrite";function lL(e,n){return e?n?function(){return e.apply(this,arguments)&&n.apply(this,arguments)}:e:n}let lW={type:3,lower:-1/0,lowerOpen:!1,upper:[[]],upperOpen:!1};function lV(e){return"string"!=typeof e||/\./.test(e)?e=>e:n=>(void 0===n[e]&&e in n&&delete(n=sa(n))[e],n)}class lG{_trans(e,n,t){let i=this._tx||s2.trans,r=this.name;function o(e,t,i){if(!i.schema[r])throw new sE.NotFound("Table "+r+" not part of transaction");return n(i.idbtrans,i)}let a=lo();try{return i&&i.db===this.db?i===s2.trans?i._promise(e,o,t):lm(()=>i._promise(e,o,t),{trans:i,transless:s2.transless||s2}):function e(n,t,i,r){if(n.idbdb&&(n._state.openComplete||s2.letThrough||n._vip)){var o=n._createTransaction(t,i,n._dbSchema);try{o.create(),n._state.PR1398_maxLoop=3}catch(o){return o.name===sC.InvalidState&&n.isOpen()&&--n._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),n._close(),n.open().then(()=>e(n,t,i,r))):lD(o)}return o._promise(t,(e,n)=>lm(()=>(s2.trans=o,r(e,n,o)))).then(e=>o._completion.then(()=>e))}if(n._state.openComplete)return lD(new sE.DatabaseClosed(n._state.dbOpenError));if(!n._state.isBeingOpened){if(!n._options.autoOpen)return lD(new sE.DatabaseClosed);n.open().catch(sM)}return n._state.dbReadyPromise.then(()=>e(n,t,i,r))}(this.db,e,[this.name],o)}finally{a&&la()}}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(aU(e))return new this.db.WhereClause(this,`[${e.join("+")}]`);let n=aG(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!==lz)return this.where(t.name).equals(t.keyPath.map(n=>e[n]));!t&&sh&&console.warn(`The query ${JSON.stringify(e)} on ${this.name} would benefit of a compound index [${n.join("+")}]`);let{idxByName:i}=this.schema,r=this.db._deps.indexedDB;function o(e,n){try{return 0===r.cmp(e,n)}catch(e){return!1}}let[a,s]=n.reduce(([n,t],r)=>{let a=i[r],s=e[r];return[n||a,n||!a?lL(t,a&&a.multi?e=>{let n=a7(e,r);return aU(n)&&n.some(e=>o(s,e))}:e=>o(s,a7(e,r))):t]},[null,null]);return a?this.where(a.name).equals(e[a.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,aU(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 i in n)if(aY(n,i))try{t[i]=n[i]}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){aH(this,e)})}add(e,n){let{auto:t,keyPath:i}=this.schema.primKey,r=e;return i&&t&&(r=lV(i)(e)),this._trans("readwrite",e=>this.core.mutate({trans:e,type:"add",keys:null!=n?[n]:null,values:[r]})).then(e=>e.numFailures?s6.reject(e.failures[0]):e.lastResult).then(n=>{if(i)try{a9(e,i,n)}catch(e){}return n})}update(e,n){if("object"!=typeof e||aU(e))return this.where(":id").equals(e).modify(n);{let t=a7(e,this.schema.primKey.keyPath);if(void 0===t)return lD(new sE.InvalidArgument("Given object does not contain its primary key"));try{"function"!=typeof n?aG(n).forEach(t=>{a9(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:i}=this.schema.primKey,r=e;return i&&t&&(r=lV(i)(e)),this._trans("readwrite",e=>this.core.mutate({trans:e,type:"put",values:[r],keys:null!=n?[n]:null})).then(e=>e.numFailures?s6.reject(e.failures[0]):e.lastResult).then(n=>{if(i)try{a9(e,i,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?s6.reject(e.failures[0]):void 0)}clear(){return this._trans("readwrite",e=>this.core.mutate({trans:e,type:"deleteRange",range:lW})).then(e=>e.numFailures?s6.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 i=Array.isArray(n)?n:void 0,r=(t=t||(i?void 0:n))?t.allKeys:void 0;return this._trans("readwrite",n=>{let{auto:t,keyPath:o}=this.schema.primKey;if(o&&i)throw new sE.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(i&&i.length!==e.length)throw new sE.InvalidArgument("Arguments objects and keys must have the same length");let a=e.length,s=o&&t?e.map(lV(o)):e;return this.core.mutate({trans:n,type:"add",keys:i,values:s,wantResults:r}).then(({numFailures:e,results:n,lastResult:t,failures:i})=>{if(0===e)return r?n:t;throw new sx(`${this.name}.bulkAdd(): ${e} of ${a} operations failed`,i)})})}bulkPut(e,n,t){let i=Array.isArray(n)?n:void 0,r=(t=t||(i?void 0:n))?t.allKeys:void 0;return this._trans("readwrite",n=>{let{auto:t,keyPath:o}=this.schema.primKey;if(o&&i)throw new sE.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(i&&i.length!==e.length)throw new sE.InvalidArgument("Arguments objects and keys must have the same length");let a=e.length,s=o&&t?e.map(lV(o)):e;return this.core.mutate({trans:n,type:"put",keys:i,values:s,wantResults:r}).then(({numFailures:e,results:n,lastResult:t,failures:i})=>{if(0===e)return r?n:t;throw new sx(`${this.name}.bulkPut(): ${e} of ${a} operations failed`,i)})})}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:i})=>{if(0===e)return t;throw new sx(`${this.name}.bulkDelete(): ${e} of ${n} operations failed`,i)})}}function lU(e){var n={},t=function(t,i){if(i){for(var r=arguments.length,o=Array(r-1);--r;)o[r-1]=arguments[r];return n[t].subscribe.apply(null,o),e}if("string"==typeof t)return n[t]};t.addEventType=o;for(var i=1,r=arguments.length;i<r;++i)o(arguments[i]);return t;function o(e,i,r){if("object"!=typeof e){i||(i=sN),r||(r=sM);var a={subscribers:[],fire:r,subscribe:function(e){-1===a.subscribers.indexOf(e)&&(a.subscribers.push(e),a.fire=i(a.fire,e))},unsubscribe:function(e){a.subscribers=a.subscribers.filter(function(n){return n!==e}),a.fire=a.subscribers.reduce(i,r)}};return n[e]=t[e]=a,a}aG(e).forEach(function(n){var t=e[n];if(aU(t))o(n,e[n][0],e[n][1]);else{if("asap"!==t)throw new sE.InvalidArgument("Invalid event config");var i=o(n,sz,function(){for(var e=arguments.length,n=Array(e);e--;)n[e]=arguments[e];i.subscribers.forEach(function(e){a6(function(){e.apply(null,n)})})})}})}}function lH(e,n){return aQ(n).from({prototype:e}),n}function lq(e,n){return!(e.filter||e.algorithm||e.or)&&(n?e.justLimit:!e.replayFilter)}function lK(e,n){e.filter=lL(e.filter,n)}function lY(e,n,t){var i=e.replayFilter;e.replayFilter=i?()=>lL(i(),n()):n,e.justLimit=t&&!i}function lJ(e,n){if(e.isPrimKey)return n.primaryKey;let t=n.getIndexByKeyPath(e.index);if(!t)throw new sE.Schema("KeyPath "+e.index+" on object store "+n.name+" is not indexed");return t}function lZ(e,n,t){let i=lJ(e,n.schema);return n.openCursor({trans:t,values:!e.keysOnly,reverse:"prev"===e.dir,unique:!!e.unique,query:{index:i,range:e.range}})}function lX(e,n,t,i){let r=e.replayFilter?lL(e.filter,e.replayFilter()):e.filter;if(e.or){let o={},a=(e,t,i)=>{if(!r||r(t,i,e=>t.stop(e),e=>t.fail(e))){var a=t.primaryKey,s=""+a;"[object ArrayBuffer]"===s&&(s=""+new Uint8Array(a)),aY(o,s)||(o[s]=!0,n(e,t,i))}};return Promise.all([e.or._iterate(a,t),lQ(lZ(e,i,t),e.algorithm,a,!e.keysOnly&&e.valueMapper)])}return lQ(lZ(e,i,t),lL(e.algorithm,r),n,!e.keysOnly&&e.valueMapper)}function lQ(e,n,t,i){var r=lc(i?(e,n,r)=>t(i(e),n,r):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=sM},n=>{e.fail(n),t=sM})||r(e.value,e,e=>t=e),t()})})}function l0(e,n){try{let t=l1(e),i=l1(n);if(t!==i)return"Array"===t?1:"Array"===i?-1:"binary"===t?1:"binary"===i?-1:"string"===t?1:"string"===i?-1:"Date"===t?1:"Date"!==i?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,i=n.length,r=t<i?t:i;for(let t=0;t<r;++t)if(e[t]!==n[t])return e[t]<n[t]?-1:1;return t===i?0:t<i?-1:1}(l2(e),l2(n));case"Array":return function(e,n){let t=e.length,i=n.length,r=t<i?t:i;for(let t=0;t<r;++t){let i=l0(e[t],n[t]);if(0!==i)return i}return t===i?0:t<i?-1:1}(e,n)}}catch(e){}return NaN}function l1(e){let n=typeof e;if("object"!==n)return n;if(ArrayBuffer.isView(e))return"binary";let t=sl(e);return"ArrayBuffer"===t?"binary":t}function l2(e){return e instanceof Uint8Array?e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e)}class l3{_read(e,n){var t=this._ctx;return t.error?t.table._trans(null,lD.bind(null,t.error)):t.table._trans("readonly",e).then(n)}_write(e){var n=this._ctx;return n.error?n.table._trans(null,lD.bind(null,n.error)):n.table._trans("readwrite",e,"locked")}_addAlgorithm(e){var n=this._ctx;n.algorithm=lL(n.algorithm,e)}_iterate(e,n){return lX(this._ctx,e,n,this._ctx.table.core)}clone(e){var n=Object.create(this.constructor.prototype),t=Object.create(this._ctx);return e&&aH(t,e),n._ctx=t,n}raw(){return this._ctx.valueMapper=null,this}each(e){var n=this._ctx;return this._read(t=>lX(n,e,t,n.table.core))}count(e){return this._read(e=>{let n=this._ctx,t=n.table.core;if(lq(n,!0))return t.count({trans:e,query:{index:lJ(n,t.schema),range:n.range}}).then(e=>Math.min(e,n.limit));var i=0;return lX(n,()=>(++i,!1),e,t).then(()=>i)}).then(e)}sortBy(e,n){let t=e.split(".").reverse(),i=t[0],r=t.length-1;function o(e,n){return n?o(e[t[n]],n-1):e[i]}var a="next"===this._ctx.dir?1:-1;function s(e,n){var t=o(e,r),i=o(n,r);return t<i?-a:t>i?a: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&&lq(n,!0)&&n.limit>0){let{valueMapper:t}=n,i=lJ(n,n.table.core.schema);return n.table.core.query({trans:e,limit:n.limit,values:!0,query:{index:i,range:n.range}}).then(({result:e})=>t?e.map(t):e)}{let t=[];return lX(n,e=>t.push(e),e,n.table.core).then(()=>t)}},e)}offset(e){var n=this._ctx;return e<=0||(n.offset+=e,lq(n)?lY(n,()=>{var n=e;return(e,t)=>0===n||(1===n?--n:t(()=>{e.advance(n),n=0}),!1)}):lY(n,()=>{var n=e;return()=>--n<0})),this}limit(e){return this._ctx.limit=Math.min(this._ctx.limit,e),lY(this._ctx,()=>{var n=e;return function(e,t,i){return--n<=0&&t(i),n>=0}},!0),this}until(e,n){return lK(this._ctx,function(t,i,r){return!e(t.value)||(i(r),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 lK(this._ctx,function(n){return e(n.value)}),(n=this._ctx).isMatch=lL(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&&lq(n,!0)&&n.limit>0)return this._read(e=>{var t=lJ(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 lK(this._ctx,function(e){var n=e.primaryKey.toString(),i=aY(t,n);return t[n]=!0,!i}),this}modify(e){var n=this._ctx;return this._write(t=>{var i;if("function"==typeof e)i=e;else{var r=aG(e),o=r.length;i=function(n){for(var t=!1,i=0;i<o;++i){var a=r[i],s=e[a];a7(n,a)!==s&&(a9(n,a,s),t=!0)}return t}}let a=n.table.core,{outbound:s,extractKey:l}=a.schema.primaryKey,c=this.db._options.modifyChunkSize||200,u=[],p=0,d=[],f=(e,n)=>{let{failures:t,numFailures:i}=n;for(let n of(p+=e-i,aG(t)))u.push(t[n])};return this.clone().primaryKeys().then(r=>{let o=u=>{let p=Math.min(c,r.length-u);return a.getMany({trans:t,keys:r.slice(u,u+p),cache:"immutable"}).then(d=>{let h=[],g=[],m=s?[]:null,b=[];for(let e=0;e<p;++e){let n=d[e],t={value:sa(n),primKey:r[u+e]};!1!==i.call(t,t.value,t)&&(null==t.value?b.push(r[u+e]):s||0===l0(l(n),l(t.value))?(g.push(t.value),s&&m.push(r[u+e])):(b.push(r[u+e]),h.push(t.value)))}let y=lq(n)&&n.limit===1/0&&("function"!=typeof e||e===l5)&&{index:n.index,range:n.range};return Promise.resolve(h.length>0&&a.mutate({trans:t,type:"add",values:h}).then(e=>{for(let n in e.failures)b.splice(parseInt(n),1);f(h.length,e)})).then(()=>(g.length>0||y&&"object"==typeof e)&&a.mutate({trans:t,type:"put",keys:m,values:g,criteria:y,changeSpec:"function"!=typeof e&&e}).then(e=>f(g.length,e))).then(()=>(b.length>0||y&&e===l5)&&a.mutate({trans:t,type:"delete",keys:b,criteria:y}).then(e=>f(b.length,e))).then(()=>r.length>u+p&&o(u+c))})};return o(0).then(()=>{if(u.length>0)throw new sk("Error modifying one or more objects",u,p,d);return r.length})})})}delete(){var e=this._ctx,n=e.range;return lq(e)&&(e.isPrimKey&&!lI||3===n.type)?this._write(t=>{let{primaryKey:i}=e.table.core.schema;return e.table.core.count({trans:t,query:{index:i,range:n}}).then(i=>e.table.core.mutate({trans:t,type:"deleteRange",range:n}).then(({failures:e,lastResult:n,results:t,numFailures:r})=>{if(r)throw new sk("Could not delete some values",Object.keys(e).map(n=>e[n]),i-r);return i-r}))}):this.modify(l5)}}let l5=(e,n)=>n.value=null;function l4(e,n){return e<n?-1:+(e!==n)}function l6(e,n){return e>n?-1:+(e!==n)}function l8(e,n,t){var i=e instanceof ct?new e.Collection(e):e;return i._ctx.error=t?new t(n):TypeError(n),i}function l7(e){return new e.Collection(e,()=>cn("")).limit(0)}function l9(e,n,t,i){var r,o,a,s,l,c,u,p=t.length;if(!t.every(e=>"string"==typeof e))return l8(e,lT);function d(e){r="next"===e?e=>e.toUpperCase():e=>e.toLowerCase(),o="next"===e?e=>e.toLowerCase():e=>e.toUpperCase(),a="next"===e?l4:l6;var n=t.map(function(e){return{lower:o(e),upper:r(e)}}).sort(function(e,n){return a(e.lower,n.lower)});s=n.map(function(e){return e.upper}),l=n.map(function(e){return e.lower}),c=e,u="next"===e?"":i}d("next");var f=new e.Collection(e,()=>ce(s[0],l[p-1]+i));f._ondirectionchange=function(e){d(e)};var h=0;return f._addAlgorithm(function(e,t,i){var r=e.key;if("string"!=typeof r)return!1;var d=o(r);if(n(d,l,h))return!0;for(var f=null,g=h;g<p;++g){var m=function(e,n,t,i,r,o){for(var a=Math.min(e.length,i.length),s=-1,l=0;l<a;++l){var c=n[l];if(c!==i[l])return 0>r(e[l],t[l])?e.substr(0,l)+t[l]+t.substr(l+1):0>r(e[l],i[l])?e.substr(0,l)+i[l]+t.substr(l+1):s>=0?e.substr(0,s)+n[s]+t.substr(s+1):null;0>r(e[l],c)&&(s=l)}return a<i.length&&"next"===o?e+t.substr(e.length):a<e.length&&"prev"===o?e.substr(0,t.length):s<0?null:e.substr(0,s)+i[s]+t.substr(s+1)}(r,d,s[g],l[g],a,c);null===m&&null===f?h=g+1:(null===f||a(f,m)>0)&&(f=m)}return t(null!==f?function(){e.continue(f+u)}:i),!1}),f}function ce(e,n,t,i){return{type:2,lower:e,upper:n,lowerOpen:t,upperOpen:i}}function cn(e){return{type:1,lower:e,upper:e}}class ct{get Collection(){return this._ctx.table.db.Collection}between(e,n,t,i){t=!1!==t,i=!0===i;try{return this._cmp(e,n)>0||0===this._cmp(e,n)&&(t||i)&&(!t||!i)?l7(this):new this.Collection(this,()=>ce(e,n,!t,!i))}catch(e){return l8(this,lP)}}equals(e){return null==e?l8(this,lP):new this.Collection(this,()=>cn(e))}above(e){return null==e?l8(this,lP):new this.Collection(this,()=>ce(e,void 0,!0))}aboveOrEqual(e){return null==e?l8(this,lP):new this.Collection(this,()=>ce(e,void 0,!1))}below(e){return null==e?l8(this,lP):new this.Collection(this,()=>ce(void 0,e,!1,!0))}belowOrEqual(e){return null==e?l8(this,lP):new this.Collection(this,()=>ce(void 0,e))}startsWith(e){return"string"!=typeof e?l8(this,lT):this.between(e,e+lz,!0,!0)}startsWithIgnoreCase(e){return""===e?this.startsWith(e):l9(this,(e,n)=>0===e.indexOf(n[0]),[e],lz)}equalsIgnoreCase(e){return l9(this,(e,n)=>e===n[0],[e],"")}anyOfIgnoreCase(){var e=sd.apply(sp,arguments);return 0===e.length?l7(this):l9(this,(e,n)=>-1!==n.indexOf(e),e,"")}startsWithAnyOfIgnoreCase(){var e=sd.apply(sp,arguments);return 0===e.length?l7(this):l9(this,(e,n)=>n.some(n=>0===e.indexOf(n)),e,lz)}anyOf(){let e=sd.apply(sp,arguments),n=this._cmp;try{e.sort(n)}catch(e){return l8(this,lP)}if(0===e.length)return l7(this);let t=new this.Collection(this,()=>ce(e[0],e[e.length-1]));t._ondirectionchange=t=>{n="next"===t?this._ascending:this._descending,e.sort(n)};let i=0;return t._addAlgorithm((t,r,o)=>{let a=t.key;for(;n(a,e[i])>0;)if(++i===e.length)return r(o),!1;return 0===n(a,e[i])||(r(()=>{t.continue(e[i])}),!1)}),t}notEqual(e){return this.inAnyRange([[lO,e],[e,this.db._maxKey]],{includeLowers:!1,includeUppers:!1})}noneOf(){let e=sd.apply(sp,arguments);if(0===e.length)return new this.Collection(this);try{e.sort(this._ascending)}catch(e){return l8(this,lP)}let n=e.reduce((e,n)=>e?e.concat([[e[e.length-1][1],n]]):[[lO,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,i=this._ascending,r=this._descending,o=this._min,a=this._max;if(0===e.length)return l7(this);if(!e.every(e=>void 0!==e[0]&&void 0!==e[1]&&0>=i(e[0],e[1])))return l8(this,"First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower",sE.InvalidArgument);let s=!n||!1!==n.includeLowers,l=n&&!0===n.includeUppers,c,u=i;function p(e,n){return u(e[0],n[0])}try{(c=e.reduce(function(e,n){let i=0,r=e.length;for(;i<r;++i){let r=e[i];if(0>t(n[0],r[1])&&t(n[1],r[0])>0){r[0]=o(r[0],n[0]),r[1]=a(r[1],n[1]);break}}return i===r&&e.push(n),e},[])).sort(p)}catch(e){return l8(this,lP)}let d=0,f=l?e=>i(e,c[d][1])>0:e=>i(e,c[d][1])>=0,h=s?e=>r(e,c[d][0])>0:e=>r(e,c[d][0])>=0,g=f,m=new this.Collection(this,()=>ce(c[0][0],c[c.length-1][1],!s,!l));return m._ondirectionchange=e=>{"next"===e?(g=f,u=i):(g=h,u=r),c.sort(p)},m._addAlgorithm((e,n,t)=>{for(var r=e.key;g(r);)if(++d===c.length)return n(t),!1;return!!(!f(r)&&!h(r))||(0===this._cmp(r,c[d][1])||0===this._cmp(r,c[d][0])||n(()=>{u===i?e.continue(c[d][0]):e.continue(c[d][1])}),!1)}),m}startsWithAnyOf(){let e=sd.apply(sp,arguments);return e.every(e=>"string"==typeof e)?0===e.length?l7(this):this.inAnyRange(e.map(e=>[e,e+lz])):l8(this,"startsWithAnyOf() only works with strings")}}function ci(e){return lc(function(n){return cr(n),e(n.target.error),!1})}function cr(e){e.stopPropagation&&e.stopPropagation(),e.preventDefault&&e.preventDefault()}let co="storagemutated",ca="x-storagemutated-1",cs=lU(null,co);class cl{_lock(){return a4(!s2.global),++this._reculock,1!==this._reculock||s2.global||(s2.lockOwnerFor=this),this}_unlock(){if(a4(!s2.global),0==--this._reculock)for(s2.global||(s2.lockOwnerFor=null);this._blockedFuncs.length>0&&!this._locked();){var e=this._blockedFuncs.shift();try{lk(e[1],e[0])}catch(e){}}return this}_locked(){return this._reculock&&s2.lockOwnerFor!==this}create(e){if(!this.mode)return this;let n=this.db.idbdb,t=this.db._state.dbOpenError;if(a4(!this.idbtrans),!e&&!n)switch(t&&t.name){case"DatabaseClosedError":throw new sE.DatabaseClosed(t);case"MissingAPIError":throw new sE.MissingAPI(t.message,t);default:throw new sE.OpenFailed(t)}if(!this.active)throw new sE.TransactionInactive;return a4(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=lc(n=>{cr(n),this._reject(e.error)}),e.onabort=lc(n=>{cr(n),this.active&&this._reject(new sE.Abort(e.error)),this.active=!1,this.on("abort").fire(n)}),e.oncomplete=lc(()=>{this.active=!1,this._resolve(),"mutatedParts"in e&&cs.storagemutated.fire(e.mutatedParts)}),this}_promise(e,n,t){if("readwrite"===e&&"readwrite"!==this.mode)return lD(new sE.ReadOnly("Transaction is readonly"));if(!this.active)return lD(new sE.TransactionInactive);if(this._locked())return new s6((i,r)=>{this._blockedFuncs.push([()=>{this._promise(e,n,t).then(i,r)},s2])});if(t)return lm(()=>{var e=new s6((e,t)=>{this._lock();let i=n(e,t,this);i&&i.then&&i.then(e,t)});return e.finally(()=>this._unlock()),e._lib=!0,e});var i=new s6((e,t)=>{var i=n(e,t,this);i&&i.then&&i.then(e,t)});return i._lib=!0,i}_root(){return this.parent?this.parent._root():this}waitFor(e){var n=this._root();let t=s6.resolve(e);if(n._waitingFor)n._waitingFor=n._waitingFor.then(()=>t);else{n._waitingFor=t,n._waitingQueue=[];var i=n.idbtrans.objectStore(n.storeNames[0]);!function e(){for(++n._spinCount;n._waitingQueue.length;)n._waitingQueue.shift()();n._waitingFor&&(i.get(-1/0).onsuccess=e)}()}var r=n._waitingFor;return new s6((e,i)=>{t.then(t=>n._waitingQueue.push(lc(e.bind(null,t))),e=>n._waitingQueue.push(lc(i.bind(null,e)))).finally(()=>{n._waitingFor===r&&(n._waitingFor=null)})})}abort(){this.active&&(this.active=!1,this.idbtrans&&this.idbtrans.abort(),this._reject(new sE.Abort))}table(e){let n=this._memoizedTables||(this._memoizedTables={});if(aY(n,e))return n[e];let t=this.schema[e];if(!t)throw new sE.NotFound("Table "+e+" not part of transaction");let i=new this.db.Table(e,t,this);return i.core=this.db.core.table(e),n[e]=i,i}}function cc(e,n,t,i,r,o,a){return{name:e,keyPath:n,unique:t,multi:i,auto:r,compound:o,src:(t&&!a?"&":"")+(i?"*":"")+(r?"++":"")+cu(n)}}function cu(e){return"string"==typeof e?e:e?"["+[].join.call(e,"+")+"]":""}function cp(e,n,t){return{name:e,primKey:n,indexes:t,mappedClass:null,idxByName:a8(t,e=>[e.name,e])}}let cd=e=>{try{return e.only([[]]),cd=()=>[[]],[[]]}catch(e){return cd=()=>lz,lz}};function cf(e){return null==e?()=>{}:"string"==typeof e?1===e.split(".").length?n=>n[e]:n=>a7(n,e):n=>a7(n,e)}function ch(e){return[].slice.call(e)}let cg=0;function cm(e){return null==e?":id":"string"==typeof e?e:`[${e.join("+")}]`}function cb({_novip:e},n){let t=n.db,i=function(e,n,{IDBKeyRange:t,indexedDB:i},r){var o;return{dbcore:(o=function(e,n,t){let i;function r(e){if(3===e.type)return null;if(4===e.type)throw Error("Cannot convert never type to IDBKeyRange");let{lower:t,upper:i,lowerOpen:r,upperOpen:o}=e;return void 0===t?void 0===i?null:n.upperBound(i,!!o):void 0===i?n.lowerBound(t,!!r):n.bound(t,i,!!r,!!o)}let{schema:o,hasGetAll:a}=(i=ch(e.objectStoreNames),{schema:{name:e.name,tables:i.map(e=>t.objectStore(e)).map(e=>{let{keyPath:n,autoIncrement:t}=e,i=aU(n),r=null==n,o={},a={name:e.name,primaryKey:{name:null,isPrimaryKey:!0,outbound:r,compound:i,keyPath:n,autoIncrement:t,unique:!0,extractKey:cf(n)},indexes:ch(e.indexNames).map(n=>e.index(n)).map(e=>{let{name:n,unique:t,multiEntry:i,keyPath:r}=e,a={name:n,compound:aU(r),keyPath:r,unique:t,multiEntry:i,extractKey:cf(r)};return o[cm(r)]=a,a}),getIndexByKeyPath:e=>o[cm(e)]};return o[":id"]=a.primaryKey,null!=n&&(o[cm(n)]=a.primaryKey),a})},hasGetAll:i.length>0&&"getAll"in t.objectStore(i[0])&&!("u">typeof navigator&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604)}),s=o.tables.map(e=>{let n;return{name:n=e.name,schema:e,mutate:function({trans:e,type:t,keys:i,values:o,range:a}){return new Promise((s,l)=>{let c;s=lc(s);let u=e.objectStore(n),p=null==u.keyPath,d="put"===t||"add"===t;if(!d&&"delete"!==t&&"deleteRange"!==t)throw Error("Invalid operation type: "+t);let{length:f}=i||o||{length:1};if(i&&o&&i.length!==o.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=[],g=[],m=0,b=e=>{++m,cr(e)};if("deleteRange"===t){if(4===a.type)return s({numFailures:m,failures:g,results:[],lastResult:void 0});3===a.type?h.push(c=u.clear()):h.push(c=u.delete(r(a)))}else{let[e,n]=d?p?[o,i]:[o,null]:[i,null];if(d)for(let i=0;i<f;++i)h.push(c=n&&void 0!==n[i]?u[t](e[i],n[i]):u[t](e[i])),c.onerror=b;else for(let n=0;n<f;++n)h.push(c=u[t](e[n])),c.onerror=b}let y=e=>{let n=e.target.result;h.forEach((e,n)=>null!=e.error&&(g[n]=e.error)),s({numFailures:m,failures:g,results:"delete"===t?i:h.map(e=>e.result),lastResult:n})};c.onerror=e=>{b(e),y(e)},c.onsuccess=y})},getMany:({trans:e,keys:t})=>new Promise((i,r)=>{i=lc(i);let o=e.objectStore(n),a=t.length,s=Array(a),l,c=0,u=0,p=e=>{let n=e.target;s[n._pos]=n.result,++u===c&&i(s)},d=ci(r);for(let e=0;e<a;++e)null!=t[e]&&((l=o.get(t[e]))._pos=e,l.onsuccess=p,l.onerror=d,++c);0===c&&i(s)}),get:({trans:e,key:t})=>new Promise((i,r)=>{i=lc(i);let o=e.objectStore(n).get(t);o.onsuccess=e=>i(e.target.result),o.onerror=ci(r)}),query:e=>new Promise((t,i)=>{t=lc(t);let{trans:o,values:s,limit:l,query:c}=e,u=l===1/0?void 0:l,{index:p,range:d}=c,f=o.objectStore(n),h=p.isPrimaryKey?f:f.index(p.name),g=r(d);if(0===l)return t({result:[]});if(a){let e=s?h.getAll(g,u):h.getAllKeys(g,u);e.onsuccess=e=>t({result:e.target.result}),e.onerror=ci(i)}else{let e=0,n=!s&&"openKeyCursor"in h?h.openKeyCursor(g):h.openCursor(g),r=[];n.onsuccess=i=>{let o=n.result;return o?(r.push(s?o.value:o.primaryKey),++e===l?t({result:r}):void o.continue()):t({result:r})},n.onerror=ci(i)}}),openCursor:function({trans:e,values:t,query:i,reverse:o,unique:a}){return new Promise((s,l)=>{s=lc(s);let{index:c,range:u}=i,p=e.objectStore(n),d=c.isPrimaryKey?p:p.index(c.name),f=o?a?"prevunique":"prev":a?"nextunique":"next",h=!t&&"openKeyCursor"in d?d.openKeyCursor(r(u),f):d.openCursor(r(u),f);h.onerror=ci(l),h.onsuccess=lc(n=>{let t=h.result;if(!t)return void s(null);t.___id=++cg,t.done=!1;let i=t.continue.bind(t),r=t.continuePrimaryKey;r&&(r=r.bind(t));let o=t.advance.bind(t),a=()=>{throw Error("Cursor not stopped")};t.trans=e,t.stop=t.continue=t.continuePrimaryKey=t.advance=()=>{throw Error("Cursor not started")},t.fail=lc(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=lc(e),h.onerror=ci(n),t.fail=n,t.stop=n=>{t.stop=t.continue=t.continuePrimaryKey=t.advance=a,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=lc(e=>{h.onsuccess=s,s()}),t.continue=i,t.continuePrimaryKey=r,t.advance=o,s(),n},s(t)},l)})},count({query:e,trans:t}){let{index:i,range:o}=e;return new Promise((e,a)=>{let s=t.objectStore(n),l=i.isPrimaryKey?s:s.index(i.name),c=r(o),u=c?l.count(c):l.count();u.onsuccess=lc(n=>e(n.target.result)),u.onerror=ci(a)})}}}),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:cd(n),schema:o}}(n,t,r),e.dbcore.reduce((e,{create:n})=>({...e,...n(e)}),o))}}(e._middlewares,t,e._deps,n);e.core=i.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 cy({_novip:e},n,t,i){t.forEach(t=>{let r=i[t];n.forEach(n=>{let i=a1(n,t);(!i||"value"in i&&void 0===i.value)&&(n===e.Transaction.prototype||n instanceof e.Transaction?aX(n,t,{get(){return this.table(t)},set(e){aZ(this,t,{value:e,writable:!0,configurable:!0,enumerable:!0})}}):n[t]=new e.Table(t,r))})})}function c_({_novip:e},n){n.forEach(n=>{for(let t in n)n[t]instanceof e.Table&&delete n[t]})}function cv(e,n){return e._cfg.version-n._cfg.version}function c$(e,n){let t,i={del:[],add:[],change:[]};for(t in e)n[t]||i.del.push(t);for(t in n){let r=e[t],o=n[t];if(r){let e={name:t,def:o,recreate:!1,del:[],add:[],change:[]};if(""+(r.primKey.keyPath||"")==""+(o.primKey.keyPath||"")&&(r.primKey.auto===o.primKey.auto||lI)){let n,t=r.idxByName,a=o.idxByName;for(n in t)a[n]||e.del.push(n);for(n in a){let i=t[n],r=a[n];i?i.src!==r.src&&e.change.push(r):e.add.push(r)}(e.del.length>0||e.add.length>0||e.change.length>0)&&i.change.push(e)}else e.recreate=!0,i.change.push(e)}else i.add.push([t,o])}return i}function cA(e,n,t,i){let r=e.db.createObjectStore(n,t.keyPath?{keyPath:t.keyPath,autoIncrement:t.auto}:{autoIncrement:t.auto});return i.forEach(e=>cw(r,e)),r}function cw(e,n){e.createIndex(n.name,n.keyPath,{unique:n.unique,multiEntry:n.multi})}function ck(e,n,t){let i={};return a3(n.objectStoreNames,0).forEach(e=>{let n=t.objectStore(e),r=n.keyPath,o=cc(cu(r),r||"",!1,!1,!!n.autoIncrement,r&&"string"!=typeof r,!0),a=[];for(let e=0;e<n.indexNames.length;++e){let t=n.index(n.indexNames[e]);r=t.keyPath;var s=cc(t.name,r,!!t.unique,!!t.multiEntry,!1,r&&"string"!=typeof r,!1);a.push(s)}i[e]=cp(e,o,a)}),i}function cx({_novip:e},n,t){let i=t.db.objectStoreNames;for(let r=0;r<i.length;++r){let o=i[r],a=t.objectStore(o);e._hasGetAll="getAll"in a;for(let e=0;e<a.indexNames.length;++e){let t=a.indexNames[e],i=a.index(t).keyPath,r="string"==typeof i?i:"["+a3(i).join("+")+"]";if(n[o]){let e=n[o].idxByName[r];e&&(e.name=t,delete n[o].idxByName[r],n[o].idxByName[t]=e)}}}"u">typeof navigator&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&aV.WorkerGlobalScope&&aV instanceof aV.WorkerGlobalScope&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604&&(e._hasGetAll=!1)}class cC{_parseStoresSpec(e,n){aG(e).forEach(t=>{if(null!==e[t]){var i=e[t].split(",").map((e,n)=>{let t=(e=e.trim()).replace(/([&*]|\+\+)/g,""),i=/^\[/.test(t)?t.match(/^\[(.*)\]$/)[1].split("+"):t;return cc(t,i||null,/\&/.test(e),/\*/.test(e),/\+\+/.test(e),aU(i),0===n)}),r=i.shift();if(r.multi)throw new sE.Schema("Primary key cannot be multi-valued");i.forEach(e=>{if(e.auto)throw new sE.Schema("Only primary key can be marked as autoIncrement (++)");if(!e.keyPath)throw new sE.Schema("Index must have a name and cannot be an empty string")}),n[t]=cp(t,r,i)}})}stores(e){let n=this.db;this._cfg.storesSource=this._cfg.storesSource?aH(this._cfg.storesSource,e):e;let t=n._versions,i={},r={};return t.forEach(e=>{aH(i,e._cfg.storesSource),r=e._cfg.dbschema={},e._parseStoresSpec(i,r)}),n._dbSchema=r,c_(n,[n._allTables,n,n.Transaction.prototype]),cy(n,[n._allTables,n,n.Transaction.prototype,this._cfg.tables],aG(r),r),n._storeNames=aG(r),this}upgrade(e){return this._cfg.contentUpgrade=sj(this._cfg.contentUpgrade||sM,e),this}}function cE(e,n){let t=e._dbNamesDB;return t||(t=e._dbNamesDB=new cH(lj,{addons:[],indexedDB:e,IDBKeyRange:n})).version(1).stores({dbnames:"name"}),t.table("dbnames")}function cS(e){return e&&"function"==typeof e.databases}function cD(e){return lm(function(){return s2.letThrough=!0,e()})}function cM(e){var n=n=>e.next(n),t=r(n),i=r(n=>e.throw(n));function r(e){return n=>{var r=e(n),o=r.value;return r.done?o:o&&"function"==typeof o.then?o.then(t,i):aU(o)?Promise.all(o).then(t,i):t(o)}}return r(n)()}function cz(e,n,t){var i=arguments.length;if(i<2)throw new sE.InvalidArgument("Too few arguments");for(var r=Array(i-1);--i;)r[i-1]=arguments[i];return t=r.pop(),[e,st(r),t]}function cO(e,n,t){let i=aU(e)?e.slice():[e];for(let e=0;e<t;++e)i.push(n);return i}let cP={stack:"dbcore",name:"VirtualIndexMiddleware",level:1,create:function(e){return{...e,table(n){let t=e.table(n),{schema:i}=t,r={},o=[];function a(e,n,t){let i=cm(e),s=r[i]=r[i]||[],l=null==e?0:"string"==typeof e?1:e.length,c=n>0,u={...t,isVirtual:c,keyTail:n,keyLength:l,extractKey:cf(e),unique:!c&&t.unique};return s.push(u),u.isPrimaryKey||o.push(u),l>1&&a(2===l?e[0]:e.slice(0,l-1),n+1,t),s.sort((e,n)=>e.keyTail-n.keyTail),u}let s=a(i.primaryKey.keyPath,0,i.primaryKey);for(let e of(r[":id"]=[s],i.indexes))a(e.keyPath,0,e);function l(n){var t,i;let r=n.query.index;return r.isVirtual?{...n,query:{index:r,range:(t=n.query.range,i=r.keyTail,{type:1===t.type?2:t.type,lower:cO(t.lower,t.lowerOpen?e.MAX_KEY:e.MIN_KEY,i),lowerOpen:!0,upper:cO(t.upper,t.upperOpen?e.MIN_KEY:e.MAX_KEY,i),upperOpen:!0})}}:n}return{...t,schema:{...i,primaryKey:s,indexes:o,getIndexByKeyPath:function(e){let n=r[cm(e)];return n&&n[0]}},count:e=>t.count(l(e)),query:e=>t.query(l(e)),openCursor(n){let{keyTail:i,isVirtual:r,keyLength:o}=n.query.index;return r?t.openCursor(l(n)).then(t=>t&&Object.create(t,{continue:{value:function(r){null!=r?t.continue(cO(r,n.reverse?e.MAX_KEY:e.MIN_KEY,i)):n.unique?t.continue(t.key.slice(0,o).concat(n.reverse?e.MIN_KEY:e.MAX_KEY,i)):t.continue()}},continuePrimaryKey:{value(n,r){t.continuePrimaryKey(cO(n,e.MAX_KEY,i),r)}},primaryKey:{get:()=>t.primaryKey},key:{get(){let e=t.key;return 1===o?e[0]:e.slice(0,o)}},value:{get:()=>t.value}})):t.openCursor(n)}}}}}};function cT(e,n,t,i){return t=t||{},i=i||"",aG(e).forEach(r=>{if(aY(n,r)){var o=e[r],a=n[r];if("object"==typeof o&&"object"==typeof a&&o&&a){let e=sl(o);e!==sl(a)?t[i+r]=n[r]:"Object"===e?cT(o,a,t,i+r+"."):o!==a&&(t[i+r]=n[r])}else o!==a&&(t[i+r]=n[r])}else t[i+r]=void 0}),aG(n).forEach(r=>{aY(e,r)||(t[i+r]=n[r])}),t}let cB={stack:"dbcore",name:"HooksMiddleware",level:2,create:e=>({...e,table(n){let t=e.table(n),{primaryKey:i}=t.schema;return{...t,mutate(e){let r=s2.trans,{deleting:o,creating:a,updating:s}=r.table(n).hook;switch(e.type){case"add":if(a.fire===sM)break;return r._promise("readwrite",()=>l(e),!0);case"put":if(a.fire===sM&&s.fire===sM)break;return r._promise("readwrite",()=>l(e),!0);case"delete":if(o.fire===sM)break;return r._promise("readwrite",()=>l(e),!0);case"deleteRange":if(o.fire===sM)break;return r._promise("readwrite",()=>(function e(n,r,o){return t.query({trans:n,values:!1,query:{index:i,range:r},limit:o}).then(({result:t})=>l({type:"delete",keys:t,trans:n}).then(i=>i.numFailures>0?Promise.reject(i.failures[0]):t.length<o?{failures:[],numFailures:0,lastResult:void 0}:e(n,{...r,lower:t[t.length-1],lowerOpen:!0},o)))})(e.trans,e.range,1e4),!0)}return t.mutate(e);function l(e){var n,r;let l=s2.trans,c=e.keys||("delete"===(n=e).type?n.keys:n.keys||n.values.map(i.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"===(r=e).type?Promise.resolve([]):t.getMany({trans:r.trans,keys:c,cache:"immutable"})).then(n=>{let r=c.map((t,r)=>{let c=n[r],u={onerror:null,onsuccess:null};if("delete"===e.type)o.fire.call(u,t,c,l);else if("add"===e.type||void 0===c){let n=a.fire.call(u,t,e.values[r],l);null==t&&null!=n&&(t=n,e.keys[r]=t,i.outbound||a9(e.values[r],i.keyPath,t))}else{let n=cT(c,e.values[r]),i=s.fire.call(u,n,t,c,l);if(i){let n=e.values[r];Object.keys(i).forEach(e=>{aY(n,e)?n[e]=i[e]:a9(n,e,i[e])})}}return u});return t.mutate(e).then(({failures:t,results:i,numFailures:o,lastResult:a})=>{for(let o=0;o<c.length;++o){let a=i?i[o]:c[o],s=r[o];null==a?s.onerror&&s.onerror(t[o]):s.onsuccess&&s.onsuccess("put"===e.type&&n[o]?e.values[o]:a)}return{failures:t,results:i,numFailures:o,lastResult:a}}).catch(e=>(r.forEach(n=>n.onerror&&n.onerror(e)),Promise.reject(e)))})}}}}})};function cI(e,n,t){try{if(!n||n.keys.length<e.length)return null;let i=[];for(let r=0,o=0;r<n.keys.length&&o<e.length;++r)0===l0(n.keys[r],e[o])&&(i.push(t?sa(n.values[r]):n.values[r]),++o);return i.length===e.length?i:null}catch(e){return null}}let cN={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=cI(e.keys,e.trans._cache,"clone"===e.cache);return n?s6.resolve(n):t.getMany(e).then(n=>(e.trans._cache={keys:e.keys,values:"clone"===e.cache?sa(n):n},n))},mutate:e=>("add"!==e.type&&(e.trans._cache=null),t.mutate(e))}}})};function cj(e){return!("from"in e)}let cR=function(e,n){if(!this){let n=new cR;return e&&"d"in e&&aH(n,e),n}aH(this,arguments.length?{d:1,from:e,to:arguments.length>1?n:e}:{d:0})};function cF(e,n,t){let i=l0(n,t);if(isNaN(i))return;if(i>0)throw RangeError();if(cj(e))return aH(e,{from:n,to:t,d:1});let r=e.l,o=e.r;if(0>l0(t,e.from))return r?cF(r,n,t):e.l={from:n,to:t,d:1,l:null,r:null},cV(e);if(l0(n,e.to)>0)return o?cF(o,n,t):e.r={from:n,to:t,d:1,l:null,r:null},cV(e);0>l0(n,e.from)&&(e.from=n,e.l=null,e.d=o?o.d+1:1),l0(t,e.to)>0&&(e.to=t,e.r=null,e.d=e.l?e.l.d+1:1);let a=!e.r;r&&!e.l&&cL(e,r),o&&a&&cL(e,o)}function cL(e,n){cj(n)||function e(n,{from:t,to:i,l:r,r:o}){cF(n,t,i),r&&e(n,r),o&&e(n,o)}(e,n)}function cW(e){let n=cj(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>l0(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>=l0(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 cV(e){var n,t;let i=((null==(n=e.r)?void 0:n.d)||0)-((null==(t=e.l)?void 0:t.d)||0),r=i>1?"r":i<-1?"l":"";if(r){let n="r"===r?"l":"r",t={...e},i=e[r];e.from=i.from,e.to=i.to,e[r]=i[r],t[r]=i[n],e[n]=t,t.d=cG(t)}e.d=cG(e)}function cG({r:e,l:n}){return(e?n?Math.max(e.d,n.d):e.d:n?n.d:0)+1}aJ(cR.prototype,{add(e){return cL(this,e),this},addKey(e){return cF(this,e,e),this},addKeys(e){return e.forEach(e=>cF(this,e,e)),this},[sc](){return cW(this)}});let cU={stack:"dbcore",level:0,create:e=>{let n=e.schema.name,t=new cR(e.MIN_KEY,e.MAX_KEY);return{...e,table:i=>{let r=e.table(i),{schema:o}=r,{primaryKey:a}=o,{extractKey:s,outbound:l}=a,c={...r,mutate:e=>{let a=e.trans,s=a.mutatedParts||(a.mutatedParts={}),l=e=>{let t=`idb://${n}/${i}/${e}`;return s[t]||(s[t]=new cR)},c=l(""),u=l(":dels"),{type:p}=e,[d,f]="deleteRange"===e.type?[e.range]:"delete"===e.type?[e.keys]:e.values.length<50?[[],e.values]:[],h=e.trans._cache;return r.mutate(e).then(e=>{if(aU(d)){"delete"!==p&&(d=e.results),c.addKeys(d);let n=cI(d,h);n||"add"===p||u.addKeys(d),(n||f)&&o.indexes.forEach(function(e){let t=l(e.name||"");function i(n){return null!=n?e.extractKey(n):null}let r=n=>e.multiEntry&&aU(n)?n.forEach(e=>t.addKey(e)):t.addKey(n);(n||f).forEach((e,t)=>{let o=n&&i(n[t]),a=f&&i(f[t]);0!==l0(o,a)&&(null!=o&&r(o),null!=a&&r(a))})})}else if(d){let e={from:d.lower,to:d.upper};u.add(e),c.add(e)}else c.add(t),u.add(t),o.indexes.forEach(e=>l(e.name).add(t));return e})}},u=({query:{index:n,range:t}})=>{var i,r;return[n,new cR(null!=(i=t.lower)?i:e.MIN_KEY,null!=(r=t.upper)?r:e.MAX_KEY)]},p={get:e=>[a,new cR(e.key)],getMany:e=>[a,(new cR).addKeys(e.keys)],count:u,query:u,openCursor:u};return aG(p).forEach(e=>{c[e]=function(o){let{subscr:a}=s2;if(a){let c=e=>{let t=`idb://${n}/${i}/${e}`;return a[t]||(a[t]=new cR)},u=c(""),d=c(":dels"),[f,h]=p[e](o);if(c(f.name||"").add(h),!f.isPrimaryKey){if("count"!==e){let n="query"===e&&l&&o.values&&r.query({...o,values:!1});return r[e].apply(this,arguments).then(t=>{if("query"===e){if(l&&o.values)return n.then(({result:e})=>(u.addKeys(e),t));let e=o.values?t.result.map(s):t.result;o.values?u.addKeys(e):d.addKeys(e)}else if("openCursor"===e){let e=o.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&&u.addKey(t.primaryKey),t.value)}})}return t})}d.add(t)}}return r[e].apply(this,arguments)}}),c}}}};class cH{constructor(e,n){var t;this._middlewares={},this.verno=0;const i=cH.dependencies;this._options=n={addons:cH.addons,autoOpen:!0,indexedDB:i.indexedDB,IDBKeyRange:i.IDBKeyRange,...n},this._deps={indexedDB:n.indexedDB,IDBKeyRange:n.IDBKeyRange};const{addons:r}=n;this._dbSchema={},this._versions=[],this._storeNames=[],this._allTables={},this.idbdb=null,this._novip=this;const o={dbOpenError:null,isBeingOpened:!1,onReadyBeingFired:null,openComplete:!1,dbReadyResolve:sM,dbReadyPromise:null,cancelOpen:sM,openCanceller:null,autoSchema:!0,PR1398_maxLoop:3};o.dbReadyPromise=new s6(e=>{o.dbReadyResolve=e}),o.openCanceller=new s6((e,n)=>{o.cancelOpen=n}),this._state=o,this.name=e,this.on=lU(this,"populate","blocked","versionchange","close",{ready:[sj,sM]}),this.on.ready.subscribe=a5(this.on.ready.subscribe,e=>(n,t)=>{cH.vip(()=>{let i=this._state;if(i.openComplete)i.dbOpenError||s6.resolve().then(n),t&&e(n);else if(i.onReadyBeingFired)i.onReadyBeingFired.push(n),t&&e(n);else{e(n);let i=this;t||e(function e(){i.on.ready.unsubscribe(n),i.on.ready.unsubscribe(e)})}})}),this.Collection=(t=this,lH(l3.prototype,function(e,n){this.db=t;let i=lW,r=null;if(n)try{i=n()}catch(e){r=e}let o=e._ctx,a=o.table,s=a.hook.reading.fire;this._ctx={table:a,index:o.index,isPrimKey:!o.index||a.schema.primKey.keyPath&&o.index===a.schema.primKey.name,range:i,keysOnly:!1,dir:"next",unique:"",algorithm:null,filter:null,replayFilter:null,justLimit:!0,isMatch:null,offset:0,limit:1/0,error:r,or:o.or,valueMapper:s!==sz?s:null}})),this.Table=function(e){return lH(lG.prototype,function(n,t,i){this.db=e,this._tx=i,this.name=n,this.schema=t,this.hook=e._allTables[n]?e._allTables[n].hook:lU(null,{creating:[sT,sM],reading:[sO,sz],updating:[sI,sM],deleting:[sB,sM]})})}(this),this.Transaction=function(e){return lH(cl.prototype,function(n,t,i,r,o){this.db=e,this.mode=n,this.storeNames=t,this.schema=i,this.chromeTransactionDurability=r,this.idbtrans=null,this.on=lU(this,"complete","error","abort"),this.parent=o||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 s6((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(),lD(e)})})}(this),this.Version=function(e){return lH(cC.prototype,function(n){this.db=e,this._cfg={version:n,storesSource:null,dbschema:{},tables:{},contentUpgrade:null}})}(this),this.WhereClause=function(e){return lH(ct.prototype,function(n,t,i){this.db=e,this._ctx={table:n,index:":id"===t?null:t,or:i};let r=e._deps.indexedDB;if(!r)throw new sE.MissingAPI;this._cmp=this._ascending=r.cmp.bind(r),this._descending=(e,n)=>r.cmp(n,e),this._max=(e,n)=>r.cmp(e,n)>0?e:n,this._min=(e,n)=>0>r.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=cd(n.IDBKeyRange),this._createTransaction=(e,n,t,i)=>new this.Transaction(e,n,t,this._options.chromeTransactionDurability,i),this._fireOnBlocked=e=>{this.on("blocked").fire(e),lB.filter(e=>e.name===this.name&&e!==this&&!e._state.vcFired).map(n=>n.on("versionchange").fire(e))},this.use(cP),this.use(cB),this.use(cU),this.use(cN),this.vip=Object.create(this,{_vip:{value:!0}}),r.forEach(e=>e(this))}version(e){if(isNaN(e)||e<.1)throw new sE.Type("Given version is not a positive number");if(e=Math.round(10*e)/10,this.idbdb||this._state.isBeingOpened)throw new sE.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(cv),t.stores({}),this._state.autoSchema=!1,t)}_whenReady(e){return this.idbdb&&(this._state.openComplete||s2.letThrough||this._vip)?e():new s6((e,n)=>{if(this._state.openComplete)return n(new sE.DatabaseClosed(this._state.dbOpenError));if(!this._state.isBeingOpened){if(!this._options.autoOpen)return void n(new sE.DatabaseClosed);this.open().catch(sM)}this._state.dbReadyPromise.then(e,n)}).then(e)}use({stack:e,create:n,level:t,name:i}){i&&this.unuse({stack:e,name:i});let r=this._middlewares[e]||(this._middlewares[e]=[]);return r.push({stack:e,create:n,level:null==t?10:t,name:i}),r.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:i}=e._deps;if(t.isBeingOpened||e.idbdb)return t.dbReadyPromise.then(()=>t.dbOpenError?lD(t.dbOpenError):e);sh&&(t.openCanceller._stackHolder=sb()),t.isBeingOpened=!0,t.dbOpenError=null,t.openComplete=!1;let r=t.openCanceller;function o(){if(t.openCanceller!==r)throw new sE.DatabaseClosed("db.open() was cancelled")}let a=t.dbReadyResolve,s=null,l=!1;return s6.race([r,("u"<typeof navigator?s6.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 s6((n,r)=>{if(o(),!i)throw new sE.MissingAPI;let a=e.name,c=t.autoSchema?i.open(a):i.open(a,Math.round(10*e.verno));if(!c)throw new sE.MissingAPI;c.onerror=ci(r),c.onblocked=lc(e._fireOnBlocked),c.onupgradeneeded=lc(n=>{if(s=c.transaction,t.autoSchema&&!e._options.allowEmptyDB){c.onerror=cr,s.abort(),c.result.close();let e=i.deleteDatabase(a);e.onsuccess=e.onerror=lc(()=>{r(new sE.NoSuchDatabase(`Database ${a} doesnt exist`))})}else{let t,i,a,d;s.onerror=ci(r);var o,u,p=n.oldVersion>0x4000000000000000?0:n.oldVersion;l=p<1,e._novip.idbdb=c.result,o=p/10,u=s,t=e._dbSchema,(i=e._createTransaction("readwrite",e._storeNames,t)).create(u),i._completion.catch(r),a=i._reject.bind(i),d=s2.transless||s2,lm(()=>{s2.trans=i,s2.transless=d,0===o?(aG(t).forEach(e=>{cA(u,e,t[e].primKey,t[e].indexes)}),cb(e,u),s6.follow(()=>e.on.populate.fire(i)).catch(a)):(function({_novip:e},n,t,i){let r=[],o=e._versions,a=e._dbSchema=ck(e,e.idbdb,i),s=!1;return o.filter(e=>e._cfg.version>=n).forEach(o=>{r.push(()=>{let r=a,l=o._cfg.dbschema;cx(e,r,i),cx(e,l,i),a=e._dbSchema=l;let c=c$(r,l);c.add.forEach(e=>{cA(i,e[0],e[1].primKey,e[1].indexes)}),c.change.forEach(e=>{if(e.recreate)throw new sE.Upgrade("Not yet support for changing primary key");{let n=i.objectStore(e.name);e.add.forEach(e=>cw(n,e)),e.change.forEach(e=>{n.deleteIndex(e.name),cw(n,e)}),e.del.forEach(e=>n.deleteIndex(e))}});let u=o._cfg.contentUpgrade;if(u&&o._cfg.version>n){let n;cb(e,i),t._memoizedTables={},s=!0;let o=se(l);c.del.forEach(e=>{o[e]=r[e]}),c_(e,[e.Transaction.prototype]),cy(e,[e.Transaction.prototype],aG(o),o),t.schema=o;let a=sf(u);a&&lb();let p=s6.follow(()=>{if((n=u(t))&&a){var e=ly.bind(null,null);n.then(e,e)}});return n&&"function"==typeof n.then?s6.resolve(n):p.then(()=>n)}}),r.push(n=>{var i;s&&lI||(i=o._cfg.dbschema,[].slice.call(n.db.objectStoreNames).forEach(e=>null==i[e]&&n.db.deleteObjectStore(e))),c_(e,[e.Transaction.prototype]),cy(e,[e.Transaction.prototype],e._storeNames,e._dbSchema),t.schema=e._dbSchema})}),(function e(){return r.length?s6.resolve(r.shift()(t.idbtrans)).then(e):s6.resolve()})().then(()=>{var e;aG(e=a).forEach(n=>{i.db.objectStoreNames.contains(n)||cA(i,n,e[n].primKey,e[n].indexes)})})})(e,o,i,u).catch(a)})}},r),c.onsuccess=lc(()=>{s=null;let i=e._novip.idbdb=c.result,r=a3(i.objectStoreNames);if(r.length>0)try{let n,o=i.transaction(1===r.length?r[0]:r,"readonly");t.autoSchema?function({_novip:e},n,t){e.verno=n.version/10;let i=e._dbSchema=ck(0,n,t);e._storeNames=a3(n.objectStoreNames,0),cy(e,[e._allTables],aG(i),i)}(e,i,o):(cx(e,e._dbSchema,o),((n=c$(ck(0,e.idbdb,o),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.")),cb(e,o)}catch(e){}lB.push(e),i.onversionchange=lc(n=>{t.vcFired=!0,e.on("versionchange").fire(n)}),i.onclose=lc(n=>{e.on("close").fire(n)}),l&&function({indexedDB:e,IDBKeyRange:n},t){cS(e)||t===lj||cE(e,n).put({name:t}).catch(sM)}(e._deps,a),n()},r)}))]).then(()=>(o(),t.onReadyBeingFired=[],s6.resolve(cD(()=>e.on.ready.fire(e.vip))).then(function n(){if(t.onReadyBeingFired.length>0){let i=t.onReadyBeingFired.reduce(sj,sM);return t.onReadyBeingFired=[],s6.resolve(cD(()=>i(e.vip))).then(n)}}))).finally(()=>{t.onReadyBeingFired=null,t.isBeingOpened=!1}).then(()=>e).catch(n=>{t.dbOpenError=n;try{s&&s.abort()}catch(e){}return r===t.openCanceller&&e._close(),lD(n)}).finally(()=>{t.openComplete=!0,a()})}(this)}_close(){let e=this._state,n=lB.indexOf(this);if(n>=0&&lB.splice(n,1),this.idbdb){try{this.idbdb.close()}catch(e){}this._novip.idbdb=null}e.dbReadyPromise=new s6(n=>{e.dbReadyResolve=n}),e.openCanceller=new s6((n,t)=>{e.cancelOpen=t})}close(){this._close();let e=this._state;this._options.autoOpen=!1,e.dbOpenError=new sE.DatabaseClosed,e.isBeingOpened&&e.cancelOpen(e.dbOpenError)}delete(){let e=arguments.length>0,n=this._state;return new s6((t,i)=>{let r=()=>{this.close();var e=this._deps.indexedDB.deleteDatabase(this.name);e.onsuccess=lc(()=>{!function({indexedDB:e,IDBKeyRange:n},t){cS(e)||t===lj||cE(e,n).delete(t).catch(sM)}(this._deps,this.name),t()}),e.onerror=ci(i),e.onblocked=this._fireOnBlocked};if(e)throw new sE.InvalidArgument("Arguments not allowed in db.delete()");n.isBeingOpened?n.dbReadyPromise.then(r):r()})}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 aG(this._allTables).map(e=>this._allTables[e])}transaction(){let e=cz.apply(this,arguments);return this._transaction.apply(this,e)}_transaction(e,n,t){let i,r,o=s2.trans;o&&o.db===this&&-1===e.indexOf("!")||(o=null);let a=-1!==e.indexOf("?");e=e.replace("!","").replace("?","");try{if(r=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===lR)i=lR;else{if("rw"!=e&&e!=lF)throw new sE.InvalidArgument("Invalid transaction mode: "+e);i=lF}if(o){if(o.mode===lR&&i===lF){if(!a)throw new sE.SubTransaction("Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY");o=null}o&&r.forEach(e=>{if(o&&-1===o.storeNames.indexOf(e)){if(!a)throw new sE.SubTransaction("Table "+e+" not included in parent transaction.");o=null}}),a&&o&&!o.active&&(o=null)}}catch(e){return o?o._promise(null,(n,t)=>{t(e)}):lD(e)}let s=(function e(n,t,i,r,o){return s6.resolve().then(()=>{let a,s=s2.transless||s2,l=n._createTransaction(t,i,n._dbSchema,r);if(r)l.idbtrans=r.idbtrans;else try{l.create(),n._state.PR1398_maxLoop=3}catch(r){return r.name===sC.InvalidState&&n.isOpen()&&--n._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),n._close(),n.open().then(()=>e(n,t,i,null,o))):lD(r)}let c=sf(o);c&&lb();let u=s6.follow(()=>{if(a=o.call(l,l))if(c){var e=ly.bind(null,null);a.then(e,e)}else"function"==typeof a.next&&"function"==typeof a.throw&&(a=cM(a))},{trans:l,transless:s});return(a&&"function"==typeof a.then?s6.resolve(a).then(e=>l.active?e:lD(new sE.PrematureCommit("Transaction committed too early. See http://bit.ly/2kdckMn"))):u.then(()=>a)).then(e=>(r&&l._resolve(),l._completion.then(()=>e))).catch(e=>(l._reject(e),lD(e)))})}).bind(null,this,i,r,o,t);return o?o._promise(i,s,"lock"):s2.trans?lk(s2.transless,()=>this._whenReady(s)):this._whenReady(s)}table(e){if(!aY(this._allTables,e))throw new sE.InvalidTable(`Table ${e} does not exist`);return this._allTables[e]}}let cq="u">typeof Symbol&&"observable"in Symbol?Symbol.observable:"@@observable";class cK{constructor(e){this._subscribe=e}subscribe(e,n,t){return this._subscribe(e&&"function"!=typeof e?e:{next:e,error:n,complete:t})}[cq](){return this}}function cY(e,n){return aG(n).forEach(t=>{cL(e[t]||(e[t]=new cR),n[t])}),e}try{o={indexedDB:aV.indexedDB||aV.mozIndexedDB||aV.webkitIndexedDB||aV.msIndexedDB,IDBKeyRange:aV.IDBKeyRange||aV.webkitIDBKeyRange}}catch(e){o={indexedDB:null,IDBKeyRange:null}}function cJ(e){let n=cZ;try{cZ=!0,cs.storagemutated.fire(e)}finally{cZ=n}}aJ(cH,{...sD,delete:e=>new cH(e,{addons:[]}).delete(),exists:e=>new cH(e,{addons:[]}).open().then(e=>(e.close(),!0)).catch("NoSuchDatabaseError",()=>!1),getDatabaseNames(e){try{return(function({indexedDB:e,IDBKeyRange:n}){return cS(e)?Promise.resolve(e.databases()).then(e=>e.map(e=>e.name).filter(e=>e!==lj)):cE(e,n).toCollection().primaryKeys()})(cH.dependencies).then(e)}catch(e){return lD(new sE.MissingAPI)}},defineClass:()=>function(e){aH(this,e)},ignoreTransaction:e=>s2.trans?lk(s2.transless,e):e(),vip:cD,async:function(e){return function(){try{var n=cM(e.apply(this,arguments));return n&&"function"==typeof n.then?n:s6.resolve(n)}catch(e){return lD(e)}}},spawn:function(e,n,t){try{var i=cM(e.apply(t,n||[]));return i&&"function"==typeof i.then?i:s6.resolve(i)}catch(e){return lD(e)}},currentTransaction:{get:()=>s2.trans||null},waitFor:function(e,n){let t=s6.resolve("function"==typeof e?cH.ignoreTransaction(e):e).timeout(n||6e4);return s2.trans?s2.trans.waitFor(t):t},Promise:s6,debug:{get:()=>sh,set:e=>{sh=e,sg="dexie"===e?()=>!0:lN}},derive:aQ,extend:aH,props:aJ,override:a5,Events:lU,on:cs,liveQuery:function(e){let n,t=!1,i=new cK(i=>{let r=sf(e),o=!1,a={},s={},l={get closed(){return o},unsubscribe:()=>{o=!0,cs.storagemutated.unsubscribe(d)}};i.start&&i.start(l);let c=!1,u=!1;function p(){return aG(s).some(e=>a[e]&&function(e,n){let t=cW(n),i=t.next();if(i.done)return!1;let r=i.value,o=cW(e),a=o.next(r.from),s=a.value;for(;!i.done&&!a.done;){if(0>=l0(s.from,r.to)&&l0(s.to,r.from)>=0)return!0;0>l0(r.from,s.from)?r=(i=t.next(s.from)).value:s=(a=o.next(r.from)).value}return!1}(a[e],s[e]))}let d=e=>{cY(a,e),p()&&f()},f=()=>{let h,g;if(c||o)return;a={};let m={},b=(r&&lb(),h=()=>lm(e,{subscr:m,trans:null}),g=s2.trans?lk(s2.transless,h):h(),r&&g.then(ly,ly),g);u||(cs(co,d),u=!0),c=!0,Promise.resolve(b).then(e=>{t=!0,n=e,c=!1,o||(p()?f():(a={},s=m,i.next&&i.next(e)))},e=>{c=!1,t=!1,i.error&&i.error(e),l.unsubscribe()})};return f(),l});return i.hasValue=()=>t,i.getValue=()=>n,i},extendObservabilitySet:cY,getByKeyPath:a7,setByKeyPath:a9,delByKeyPath:function(e,n){"string"==typeof n?a9(e,n,void 0):"length"in n&&[].map.call(n,function(n){a9(e,n,void 0)})},shallowClone:se,deepClone:sa,getObjectDiff:cT,cmp:l0,asap:a6,minKey:lO,addons:[],connections:lB,errnames:sC,dependencies:o,semVer:lM,version:lM.split(".").map(e=>parseInt(e)).reduce((e,n,t)=>e+n/Math.pow(10,2*t))}),cH.maxKey=cd(cH.dependencies.IDBKeyRange),"u">typeof dispatchEvent&&"u">typeof addEventListener&&(cs(co,e=>{if(!cZ){let n;lI?(n=document.createEvent("CustomEvent")).initCustomEvent(ca,!0,!0,e):n=new CustomEvent(ca,{detail:e}),cZ=!0,dispatchEvent(n),cZ=!1}}),addEventListener(ca,({detail:e})=>{cZ||cJ(e)}));let cZ=!1;if("u">typeof BroadcastChannel){let e=new BroadcastChannel(ca);"function"==typeof e.unref&&e.unref(),cs(co,n=>{cZ||e.postMessage(n)}),e.onmessage=e=>{e.data&&cJ(e.data)}}else if("u">typeof self&&"u">typeof navigator){cs(co,e=>{try{cZ||("u">typeof localStorage&&localStorage.setItem(ca,JSON.stringify({trig:Math.random(),changedParts:e})),"object"==typeof self.clients&&[...self.clients.matchAll({includeUncontrolled:!0})].forEach(n=>n.postMessage({type:ca,changedParts:e})))}catch(e){}}),"u">typeof addEventListener&&addEventListener("storage",e=>{if(e.key===ca){let n=JSON.parse(e.newValue);n&&cJ(n.changedParts)}});let e=self.document&&navigator.serviceWorker;e&&e.addEventListener("message",function({data:e}){e&&e.type===ca&&cJ(e.changedParts)})}function cX(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}s6.rejectionMapper=function(e,n){if(!e||e instanceof sA||e instanceof TypeError||e instanceof SyntaxError||!e.name||!sS[e.name])return e;var t=new sS[e.name](n||e.message,e);return"stack"in e&&aX(t,"stack",{get:function(){return this.inner.stack}}),t},sg=lN;class cQ extends cH{constructor(){super("EsmOffline"),cX(this,"syncQueue",void 0),cX(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 c0(){return new cQ}let c1=new cQ,c2={},c3=H("offline-synchronization",{});function c5(){return c3}async function c4(){if(c3.getState().synchronization)return;let e=await c1.syncQueue.count(),n={},t=Object.entries(c2),i=t.length,r={},o=new AbortController,a=()=>{let e=c3.getState().synchronization;c3.setState({synchronization:{...e,pendingCount:e.pendingCount-1}})};try{c3.setState({synchronization:{totalCount:e,pendingCount:e,abortController:o}});for(let e=0;e<i&&t.length>0;e++)for(let e=t.length;e--;){let[i,s]=t[e],l=s.dependsOn.map(e=>n[e]);l.every(Boolean)&&(r[i]={},await Promise.all(l),n[i]=c6(s,r,o,a),t.splice(e,1))}await Promise.allSettled(Object.values(n))}finally{c3.setState({synchronization:void 0})}}async function c6({type:e,dependsOn:n,process:t},i,r,o){let a=[],s=[],l=await c8();await c1.syncQueue.where({type:e,userId:l}).each((e,n)=>{a.push([n.primaryKey,e.content,e.descriptor]),s.push(e.content)});for(let c=0;c<a.length;c++){let[u,p,{id:d,dependencies:f=[]}]=a[c];try{let o=await t(p,{abort:r,index:c,items:s,userId:l,dependencies:f.map(({id:e,type:t})=>n.includes(t)?i[t][e]:void 0)});void 0!==d&&(i[e][d]=o),await c1.syncQueue.delete(u)}catch(e){await c1.syncQueue.update(u,{lastError:{name:e?.name,message:e?.message??e?.toString()}})}finally{o()}}}async function c8(){let e=await rR();return e?.uuid||"*"}async function c7(e,n,t,i){let r=i&&i.id;return void 0!==r&&await c1.syncQueue.where({type:n,userId:e}).filter(e=>e?.descriptor.id===r).delete().catch(cH.errnames.DatabaseClosed),await c1.syncQueue.add({type:n,content:t,userId:e,descriptor:i||{},createdOn:new Date}).catch(cH.errnames.DatabaseClosed,()=>-1)}async function c9(e,n,t){let i=await c8();return await c7(i,e,n,t)}async function ue(e,n){return(await un(e,n)).map(e=>e.content)}async function un(e,n){return await c1.syncQueue.where(n?{type:n,userId:e}:{userId:e}).toArray().catch(cH.errnames.DatabaseClosed,()=>[])}async function ut(e){let n=await c8();return await ue(n,e)}async function ui(e){let n=await c8();return await un(n,e)}async function ur(e){return await c1.syncQueue.get(e).catch(cH.errnames.DatabaseClosed,()=>void 0)}function uo(e){return!!c2[e]?.options.onBeginEditSyncItem}async function ua(e){let n=await ur(e);if(!n)throw Error(`No sync item with the ID ${e} exists.`);let t=c2[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 us(e){await c1.syncQueue.delete(e).catch(cH.errnames.DatabaseClosed)}function ul(e,n,t,i={}){c2[e]={type:e,dependsOn:n,process:t,options:i}}let uc="u">typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),uu=new Uint8Array(16),up=[];for(let e=0;e<256;++e)up.push((e+256).toString(16).slice(1));let ud=function(e,n,t){if(uc&&!n&&!e)return uc();let i=(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(uu)})();if(i[6]=15&i[6]|64,i[8]=63&i[8]|128,n){t=t||0;for(let e=0;e<16;++e)n[t+e]=i[e];return n}return function(e,n=0){return up[e[n+0]]+up[e[n+1]]+up[e[n+2]]+up[e[n+3]]+"-"+up[e[n+4]]+up[e[n+5]]+"-"+up[e[n+6]]+up[e[n+7]]+"-"+up[e[n+8]]+up[e[n+9]]+"-"+up[e[n+10]]+up[e[n+11]]+up[e[n+12]]+up[e[n+13]]+up[e[n+14]]+up[e[n+15]]}(i)},uf="OFFLINE+";function uh(){return uf+ud()}function ug(e){return e.startsWith(uf)}let um={};function ub(){return Object.values(um)}function uy(e){um[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.`),um[e.id]=e}async function u_(e){let n=await uE();return await uv(n,e)}async function uv(e,n){let t=new cQ;return await t.dynamicOfflineData.where(n?{type:n,users:e}:{users:e}).toArray().catch(cH.errnames.DatabaseClosed,()=>[])}async function u$(e,n){let t=await uE();return await uA(t,e,n)}async function uA(e,n,t){let i=new cQ,r=await i.dynamicOfflineData.get({type:n,identifier:t}).catch(cH.errnames.DatabaseClosed,()=>void 0);r?r.users.includes(e)||await i.dynamicOfflineData.update(r.id,{users:[...r.users,e]}).catch(cH.errnames.DatabaseClosed):await i.dynamicOfflineData.add({users:[e],type:n,identifier:t}).catch(cH.errnames.DatabaseClosed)}async function uw(e,n){let t=await uE();return await uk(t,e,n)}async function uk(e,n,t){let i=new cQ,r=await i.dynamicOfflineData.get({type:n,identifier:t,users:e}).catch(cH.errnames.DatabaseClosed,()=>void 0);r&&(r.users.length>1?await i.dynamicOfflineData.update(r.id,{users:r.users.filter(n=>n!==e)}).catch(cH.errnames.DatabaseClosed):await i.dynamicOfflineData.delete(r.id).catch(cH.errnames.DatabaseClosed))}async function ux(e,n){let t=await u_(e);await Promise.all(t.map(async e=>uC(e.type,e.identifier,n)))}async function uC(e,n,t){await u$(e,n);let i=new cQ,r=await uE(),o=await i.dynamicOfflineData.get({type:e,identifier:n}).catch(cH.errnames.DatabaseClosed,()=>void 0),a=ub().filter(n=>n.type===e);if(!o)return;let s=await Promise.all(a.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),u=s.filter(e=>e.error).map(e=>({handlerId:e.id,message:e.error})),p={syncedOn:new Date,syncedBy:r,succeededHandlers:l,erroredHandlers:c,errors:u};o.id&&await i.dynamicOfflineData.update(o.id,{syncState:p}).catch(cH.errnames.DatabaseClosed)}async function uE(){let e=(await rR()).uuid;if(!e)throw Error("Using the dynamic offline data API requires a logged in user.");return e}let uS=H("offline-patients",{offlinePatientDataSyncState:{},handlers:{}});function uD(){return uO(),uS}function uM(e,n){uO(),uy({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 uz(e){uO(),await uC("patient",e)}function uO(){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 uP(e,n,t=!0){if(e){let i=null,[r,o]=await Promise.all([rS(`${rx}/Patient/${e}`,n).catch(e=>i=e),t?uT(e):Promise.resolve(null)]);if(r.ok)return r.data;if(o)return o;if(i)throw i}return null}async function uT(e){let n=(await ut("patient-registration")).find(n=>n.fhirPatient.id===e);return n?.fhirPatient??null}function uB(e,n){let t=new CustomEvent(`openmrs:${e}`,{detail:n??void 0,cancelable:!0,bubbles:!0});return window.dispatchEvent(t)}function uI(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 uN=t(56170);function uj(e){return{uuid:e.uuid,display:e.display}}function uR(e=null,n=null){let t=new URLSearchParams;e&&t.set("tag",e),n&&t.set("q",n);let i=t.toString();return rD(`${rk}/location${i?"?"+i:""}`).pipe((0,uN.map)(e=>e.data.results.map(uj))).pipe((0,uN.take)(1))}function uF(e){return{uuid:e.uuid,display:e.display,name:e.name}}function uL(){return rD(`${rk}/visittype`).pipe((0,uN.map)(e=>e.data.results.map(uF))).pipe((0,uN.take)(1))}var uW=((ee={}).NEWVISIT="startVisit",ee.EDITVISIT="editVisit",ee.LOADING="loadingVisit",ee),uV=((en={}).NOTSTARTED="notStarted",en.ONGOING="ongoing",en);let uG="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))",uU=function(){try{return JSON.parse(sessionStorage.getItem("openmrs:visitStoreState")||"null")}catch(e){return null}}()||{patientUuid:null,manuallySetVisitUuid:null};function uH(){return K("visit",uU)}function uq(e,n){uH().setState({patientUuid:e,manuallySetVisitUuid:n})}function uK(e,n){return rS(`${rk}/visit`,{signal:n.signal,method:"POST",headers:{"Content-type":"application/json"},body:e})}function uY(e,n,t){return rS(`${rk}/visit/${e}`,{signal:t.signal,method:"POST",headers:{"Content-type":"application/json"},body:n})}function uJ(e,n,t){return rS(`${rk}/visit?patient=${e}&v=${t??uG}`,{signal:n.signal,method:"GET",headers:{"Content-type":"application/json"}})}uH().subscribe(e=>{var n;n=e,sessionStorage.setItem("openmrs:visitStoreState",JSON.stringify(n))});let uZ=new er.BehaviorSubject(null);class uX{static get version(){return"1.4.0"}static toString(){return"JavaScript Expression Parser (JSEP) v"+uX.version}static addUnaryOp(e){return uX.max_unop_len=Math.max(e.length,uX.max_unop_len),uX.unary_ops[e]=1,uX}static addBinaryOp(e,n,t){return uX.max_binop_len=Math.max(e.length,uX.max_binop_len),uX.binary_ops[e]=n,t?uX.right_associative.add(e):uX.right_associative.delete(e),uX}static addIdentifierChar(e){return uX.additional_identifier_chars.add(e),uX}static addLiteral(e,n){return uX.literals[e]=n,uX}static removeUnaryOp(e){return delete uX.unary_ops[e],e.length===uX.max_unop_len&&(uX.max_unop_len=uX.getMaxKeyLen(uX.unary_ops)),uX}static removeAllUnaryOps(){return uX.unary_ops={},uX.max_unop_len=0,uX}static removeIdentifierChar(e){return uX.additional_identifier_chars.delete(e),uX}static removeBinaryOp(e){return delete uX.binary_ops[e],e.length===uX.max_binop_len&&(uX.max_binop_len=uX.getMaxKeyLen(uX.binary_ops)),uX.right_associative.delete(e),uX}static removeAllBinaryOps(){return uX.binary_ops={},uX.max_binop_len=0,uX}static removeLiteral(e){return delete uX.literals[e],uX}static removeAllLiterals(){return uX.literals={},uX}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 uX(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 uX.binary_ops[e]||0}static isIdentifierStart(e){return e>=65&&e<=90||e>=97&&e<=122||e>=128&&!uX.binary_ops[String.fromCharCode(e)]||uX.additional_identifier_chars.has(String.fromCharCode(e))}static isIdentifierPart(e){return uX.isIdentifierStart(e)||uX.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(uX.hooks[e]){let t={context:this,node:n};return uX.hooks.run(e,t),t.node}return n}searchHook(e){if(uX.hooks[e]){let n={context:this};return uX.hooks[e].find(function(e){return e.call(n.context,n),n.node}),n.node}}gobbleSpaces(){let e=this.code;for(;e===uX.SPACE_CODE||e===uX.TAB_CODE||e===uX.LF_CODE||e===uX.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:uX.COMPOUND,body:e};return this.runHook("after-all",n)}gobbleExpressions(e){let n=[],t,i;for(;this.index<this.expr.length;)if((t=this.code)===uX.SEMCOL_CODE||t===uX.COMMA_CODE)this.index++;else if(i=this.gobbleExpression())n.push(i);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,uX.max_binop_len),n=e.length;for(;n>0;){if(uX.binary_ops.hasOwnProperty(e)&&(!uX.isIdentifierStart(this.code)||this.index+e.length<this.expr.length&&!uX.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,i,r,o,a,s,l;if(!(o=this.gobbleToken())||!(n=this.gobbleBinaryOp()))return o;for(r={value:n,prec:uX.binaryPrecedence(n),right_a:uX.right_associative.has(n)},(a=this.gobbleToken())||this.throwError("Expected expression after "+n),i=[o,r,a];n=this.gobbleBinaryOp();){if(0===(t=uX.binaryPrecedence(n))){this.index-=n.length;break}r={value:n,prec:t,right_a:uX.right_associative.has(n)},l=n;let s=e=>r.right_a&&e.right_a?t>e.prec:t<=e.prec;for(;i.length>2&&s(i[i.length-2]);)a=i.pop(),n=i.pop().value,o=i.pop(),e={type:uX.BINARY_EXP,operator:n,left:o,right:a},i.push(e);(e=this.gobbleToken())||this.throwError("Expected expression after "+l),i.push(r,e)}for(s=i.length-1,e=i[s];s>1;)e={type:uX.BINARY_EXP,operator:i[s-1].value,left:i[s-2],right:e},s-=2;return e}gobbleToken(){let e,n,t,i;if(this.gobbleSpaces(),i=this.searchHook("gobble-token"))return this.runHook("after-token",i);if(e=this.code,uX.isDecimalDigit(e)||e===uX.PERIOD_CODE)return this.gobbleNumericLiteral();if(e===uX.SQUOTE_CODE||e===uX.DQUOTE_CODE)i=this.gobbleStringLiteral();else if(e===uX.OBRACK_CODE)i=this.gobbleArray();else{for(t=(n=this.expr.substr(this.index,uX.max_unop_len)).length;t>0;){if(uX.unary_ops.hasOwnProperty(n)&&(!uX.isIdentifierStart(this.code)||this.index+n.length<this.expr.length&&!uX.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:uX.UNARY_EXP,operator:n,argument:e,prefix:!0})}n=n.substr(0,--t)}uX.isIdentifierStart(e)?(i=this.gobbleIdentifier(),uX.literals.hasOwnProperty(i.name)?i={type:uX.LITERAL,value:uX.literals[i.name],raw:i.name}:i.name===uX.this_str&&(i={type:uX.THIS_EXP})):e===uX.OPAREN_CODE&&(i=this.gobbleGroup())}return i?(i=this.gobbleTokenProperty(i),this.runHook("after-token",i)):this.runHook("after-token",!1)}gobbleTokenProperty(e){this.gobbleSpaces();let n=this.code;for(;n===uX.PERIOD_CODE||n===uX.OBRACK_CODE||n===uX.OPAREN_CODE||n===uX.QUMARK_CODE;){let t;if(n===uX.QUMARK_CODE){if(this.expr.charCodeAt(this.index+1)!==uX.PERIOD_CODE)break;t=!0,this.index+=2,this.gobbleSpaces(),n=this.code}this.index++,n===uX.OBRACK_CODE?((e={type:uX.MEMBER_EXP,computed:!0,object:e,property:this.gobbleExpression()}).property||this.throwError('Unexpected "'+this.char+'"'),this.gobbleSpaces(),(n=this.code)!==uX.CBRACK_CODE&&this.throwError("Unclosed ["),this.index++):n===uX.OPAREN_CODE?e={type:uX.CALL_EXP,arguments:this.gobbleArguments(uX.CPAREN_CODE),callee:e}:(n===uX.PERIOD_CODE||t)&&(t&&this.index--,this.gobbleSpaces(),e={type:uX.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(;uX.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);if(this.code===uX.PERIOD_CODE)for(e+=this.expr.charAt(this.index++);uX.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++));uX.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);uX.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+e+this.char+")")}return t=this.code,uX.isIdentifierStart(t)?this.throwError("Variable names cannot start with a number ("+e+this.char+")"):(t===uX.PERIOD_CODE||1===e.length&&e.charCodeAt(0)===uX.PERIOD_CODE)&&this.throwError("Unexpected period"),{type:uX.LITERAL,value:parseFloat(e),raw:e}}gobbleStringLiteral(){let e="",n=this.index,t=this.expr.charAt(this.index++),i=!1;for(;this.index<this.expr.length;){let n=this.expr.charAt(this.index++);if(n===t){i=!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 i||this.throwError('Unclosed quote after "'+e+'"'),{type:uX.LITERAL,value:e,raw:this.expr.substring(n,this.index)}}gobbleIdentifier(){let e=this.code,n=this.index;for(uX.isIdentifierStart(e)?this.index++:this.throwError("Unexpected "+this.char);this.index<this.expr.length;)if(e=this.code,uX.isIdentifierPart(e))this.index++;else break;return{type:uX.IDENTIFIER,name:this.expr.slice(n,this.index)}}gobbleArguments(e){let n=[],t=!1,i=0;for(;this.index<this.expr.length;){this.gobbleSpaces();let r=this.code;if(r===e){t=!0,this.index++,e===uX.CPAREN_CODE&&i&&i>=n.length&&this.throwError("Unexpected token "+String.fromCharCode(e));break}if(r===uX.COMMA_CODE){if(this.index++,++i!==n.length){if(e===uX.CPAREN_CODE)this.throwError("Unexpected token ,");else if(e===uX.CBRACK_CODE)for(let e=n.length;e<i;e++)n.push(null)}}else if(n.length!==i&&0!==i)this.throwError("Expected comma");else{let e=this.gobbleExpression();e&&e.type!==uX.COMPOUND||this.throwError("Expected comma"),n.push(e)}}return t||this.throwError("Expected "+String.fromCharCode(e)),n}gobbleGroup(){this.index++;let e=this.gobbleExpressions(uX.CPAREN_CODE);if(this.code===uX.CPAREN_CODE)return(this.index++,1===e.length)?e[0]:!!e.length&&{type:uX.SEQUENCE_EXP,expressions:e};this.throwError("Unclosed (")}gobbleArray(){return this.index++,{type:uX.ARRAY_EXP,elements:this.gobbleArguments(uX.CBRACK_CODE)}}}Object.assign(uX,{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)})}}(uX),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"}),uX.max_unop_len=uX.getMaxKeyLen(uX.unary_ops),uX.max_binop_len=uX.getMaxKeyLen(uX.binary_ops);let uQ=e=>new uX(e).parse(),u0=Object.getOwnPropertyNames(class{});Object.getOwnPropertyNames(uX).filter(e=>!u0.includes(e)&&void 0===uQ[e]).forEach(e=>{uQ[e]=uX[e]}),uQ.Jsep=uX,uQ.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,i=this.gobbleExpression();if(i||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===e.COLON_CODE){this.index++;let r=this.gobbleExpression();if(r||this.throwError("Expected expression"),n.node={type:"ConditionalExpression",test:t,consequent:i,alternate:r},t.operator&&e.binary_ops[t.operator]<=.9){let i=t;for(;i.right.operator&&e.binary_ops[i.right.operator]<=.9;)i=i.right;n.node.test=i.right,i.right=n.node,n.node=t}}else this.throwError("Expected :")}})}});let u1="ArrowFunctionExpression",u2={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)}},u3={...u2,Promise};function u5(e,n={}){return pe(e,n,pi)}async function u4(e,n={}){return pn(e,n,pi)}function u6(e,n={}){return pe(e,n,pr)}function u8(e,n={}){return pn(e,n,pr)}function u7(e,n={}){return pe(e,n,po)}function u9(e,n={}){return pn(e,n,po)}function pe(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 i=pl(n,u2),r=pa("string"==typeof e?uQ(e):e,i);if(t(r))return r;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 pn(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 i=pl(n,u3);return Promise.resolve(pa("string"==typeof e?uQ(e):e,i)).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 pt(e){return uQ(e)}function pi(e){return"string"==typeof e||"number"==typeof e||"boolean"==typeof e||null==e||e instanceof Date}function pr(e){return"boolean"==typeof e}function po(e){return"number"==typeof e}function pa(e,n){switch(e.type){case"UnaryExpression":var t,i,r,o,a,s,l,c,u,p,d,f,h=e,g=n;let m=pa(h.argument,g);switch(h.operator){case"+":return+m;case"-":return-m;case"~":return~m;case"!":return!m;default:throw`Expression evaluator does not support operator '${h.operator}''`}case"BinaryExpression":var b=e,y=n;let v=pa(b.left,y),$=pa(b.right,y);switch(b.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 '${b.operator}' operator`}case"ConditionalExpression":return t=e,i=n,pa(t.test,i)?pa(t.consequent,i):pa(t.alternate,i);case"CallExpression":var A=e,w=n;let k=A.arguments?.map(pc(w)),x=pa(A.callee,w);if(x){if("function"!=typeof x)throw`${pp(A.callee)} is not a function`}else throw`No function named ${pp(A.callee)} is defined in this context`;return x(...k);case"ArrowFunctionExpression":let C;return r=e,o=n,C=r.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,i)=>{let r=e[i];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}(r)&&n.push([t,r]),n},[]));return pa(r.body,o.addVariables(n))}).bind(o.thisObj??null);case"MemberExpression":return function(e,n){let t,i=pa(e.object,n);if(void 0===i)switch(e.object.type){case"Identifier":{let t=ps(e.object,n);throw ReferenceError(`ReferenceError: ${t} is not defined`)}case"MemberExpression":{let t=ps(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 r=i;if("string"==typeof i)r=String.prototype;else if("number"==typeof i)r=Number.prototype;else if("function"==typeof i);else if("object"!=typeof i)throw`VisitMemberExpression does not support member access on type ${typeof i}`;switch(n.thisObj=r,e.property.type){case"Identifier":case"MemberExpression":t=pa(e.property,n);break;default:{let r=pa(e.property,n);if(void 0===r)throw{type:"Illegal property access",message:"No property was supplied to the property access"};pu(r),t=i[r]}}return"function"==typeof t?t.bind(i):t}(e,n);case"ArrayExpression":return a=e,s=n,a.elements?.map(pc(s));case"SequenceExpression":let E;return l=e,c=n,(E=l.expressions.map(pc(c)))[E.length-1];case"NewExpression":var S=e,D=n;if(S.callee&&"Identifier"===S.callee.type){let e=S.arguments?.map(pc(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 pu((u=e).value),u.value;case"Identifier":var M=e,z=n;pu(M.name);let O=z.thisObj;if(O&&("object"==typeof O||"function"==typeof O)&&M.name in O){let e=O[M.name];return pu(e),e}if(z.variables&&M.name in z.variables){let e=z.variables[M.name];return pu(e),e}return M.name in z.globals?z.globals[M.name]:void 0;case"TemplateLiteral":let P,T;return p=e,d=n,P=p.expressions?.map(pc(d))??[],(T=p.quasis?.map(pc(d))??[]).filter(e=>!e.tail).map(e=>e.value).join("")+P.join("")+T.filter(e=>e.tail).map(e=>e.value).join("");case"TemplateElement":return{value:(f=e).cooked,tail:f.tail};default:throw`Expression evaluator does not support expression of type '${e.type}'`}}function ps(e,n){switch(e.type){case"Literal":return e.value;case"Identifier":return e.name;case"MemberExpression":return ps(e.property,n);default:throw`VisitExpressionName does not support expression of type '${e.type}'`}}function pl(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 pc(e){return function(n){return null===n?null:pa(n,e)}}function pu(e){if("__proto__"===e||"prototype"===e||"constructor"===e)throw{type:"Illegal property access",message:`Cannot access the ${e} property of objects`}}function pp(e){return e?"MemberExpression"===e.type?e.property?.name:e.name:null}function pd(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:{...u3},isLocalExpression:!1,variables:new Set};return pf("string"==typeof e?uQ(e):e,n),[...n.variables]}function pf(e,n){switch(e.type){case"UnaryExpression":return i=e,r=n,pf(i.argument,r);case"BinaryExpression":return o=e,a=n,[pf(o.left,a),pf(o.right,a)].filter(Boolean);case"ConditionalExpression":return s=e,l=n,[pf(s.consequent,l),pf(s.test,l),pf(s.alternate,l)].filter(Boolean);case"CallExpression":let t;return c=e,u=n,t=pf(c.callee,u),c.arguments?.map(ph(u)),t;case"ArrowFunctionExpression":var i,r,o,a,s,l,c,u,p,d,f,h,g,m,b,y,v,$,A=e,w=n;let k={...w};k.isLocalExpression=!0;let x=A.params?.map(ph(k))??[],C=pf(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 p=e,d=n,pf(p.object,d),void((E={...d}).isLocalExpression=!0,pf(p.property,E));case"ArrayExpression":return f=e,h=n,void f.elements?.map(ph(h));case"SequenceExpression":return g=e,m=n,void g.expressions?.map(ph(m));case"NewExpression":return b=e,y=n,void b.arguments?.map(ph(y));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(ph($)),v.quasis?.map(ph($)));default:throw`Expression evaluator does not support expression of type '${e.type}'`}}function ph(e){return function(n){return null===n?null:pf(n,e)}}uQ.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:u1,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=u1,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)})}}),uQ.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 i=n.node;for(;i.type===e.MEMBER_EXP||i.type===e.CALL_EXP&&i.callee.type===e.MEMBER_EXP;)i=i.type===e.MEMBER_EXP?i.object:i.callee.object;i.type="NewExpression"}})}}),uQ.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,i="",r=()=>{for(;e.isDecimalDigit(this.code)||95===this.code;)95===this.code?this.index++:i+=this.expr.charAt(this.index++)};r(),this.code===e.PERIOD_CODE&&(i+=this.expr.charAt(this.index++),r());let o=this.char;("e"===o||"E"===o)&&(i+=this.expr.charAt(this.index++),("+"===(o=this.char)||"-"===o)&&(i+=this.expr.charAt(this.index++)),r(),e.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+i+this.char+")"));let a=this.code;if(e.isIdentifierStart(a))this.throwError("Variable names cannot start with a number ("+i+this.char+")");else if(a===e.PERIOD_CODE){i.length>1&&this.throwError(`Unexpected period ${JSON.stringify({chCode:a,number:i},null,2)}`),this.index=t;return}n.node={type:e.LITERAL,value:parseFloat(i),raw:this.expr.substring(t,this.index)}}e.hooks.add("gobble-token",function(i){if(48===this.code){var r,o,a;let s=this.index,l=this.expr.charAt(this.index+1),c=n.call(this,l);if(!c)return;let u="";for(;r=this.code,o=c,95===r||o.some(([e,n])=>r>=e&&r<=n);)95===this.code?this.index++:u+=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,i);return}this.throwError("unexpected char within number")}i.node={type:e.LITERAL,value:parseInt(u,"x"===(a=l)||"X"===a?16:"b"===a||"B"===a?2:8),raw:this.expr.substring(s,this.index)}}else(e.isDecimalDigit(this.code)||this.code===e.PERIOD_CODE)&&t.call(this,i)})}}),uQ.plugins.register({name:"regex",init(e){e.hooks.add("gobble-token",function(n){if(47===this.code){let t=++this.index,i=!1;for(;this.index<this.expr.length;){if(47===this.code&&!i){let i,r=this.expr.slice(t,this.index),o="";for(;++this.index<this.expr.length;){let e=this.code;if(e>=97&&e<=122||e>=65&&e<=90||e>=48&&e<=57)o+=this.char;else break}try{i=new RegExp(r,o)}catch(e){this.throwError(e.message)}return n.node={type:e.LITERAL,value:i,raw:this.expr.slice(t-1,this.index)},n.node=this.gobbleTokenProperty(n.node),n.node}this.code===e.OBRACK_CODE?i=!0:i&&this.code===e.CBRACK_CODE&&(i=!1),this.index+=92===this.code?2:1}this.throwError("Unclosed Regex")}})}}),uQ.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,i=this.gobbleExpression();if(i||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===e.COLON_CODE){this.index++;let r=this.gobbleExpression();if(r||this.throwError("Expected expression"),n.node={type:"ConditionalExpression",test:t,consequent:i,alternate:r},t.operator&&e.binary_ops[t.operator]<=.9){let i=t;for(;i.right.operator&&e.binary_ops[i.right.operator]<=.9;)i=i.right;n.node.test=i.right,i.right=n.node,n.node=t}}else this.throwError("Expected :")}})}}),uQ.plugins.register({name:"jsepTemplateLiteral",init(e){function n(e,t=!0){if(96===this.code){let n={type:"TemplateLiteral",quasis:[],expressions:[]},i="",r="",o=!1,a=this.expr.length,s=()=>n.quasis.push({type:"TemplateElement",value:{raw:r,cooked:i},tail:o});for(;this.index<a;){let a=this.expr.charAt(++this.index);if("`"===a)return this.index+=1,o=!0,s(),e.node=n,t&&(e.node=this.gobbleTokenProperty(e.node)),e.node;if("$"===a&&"{"===this.expr.charAt(this.index+1))this.index+=2,s(),r="",i="",n.expressions.push(...this.gobbleExpressions(125)),125!==this.code&&this.throwError("unclosed ${");else if("\\"===a)switch(r+=a,a=this.expr.charAt(++this.index),r+=a,a){case"n":i+="\n";break;case"r":i+="\r";break;case"t":i+=" ";break;case"b":i+="\b";break;case"f":i+="\f";break;case"v":i+="\v";break;default:i+=a}else i+=a,r+=a}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})}}),uQ.addBinaryOp("in",7),uQ.addBinaryOp("??",1);let pg=K("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:",""),i=JSON.parse(localStorage.getItem(`openmrs:feature-flag-meta:${t}`)||"{}");e[t]={enabled:"true"===localStorage.getItem(n),...i}}return e}()});function pm(e,n,t){pg.setState(i=>({flags:{...i.flags,[e]:{enabled:i.flags[e]?.enabled??!1,label:n,description:t}}}))}function pb(){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 py(e){return pg.getState().flags[e].enabled}function p_(e,n){pg.subscribe(t=>{n(t.flags[e].enabled)})}function pv(e,n){pg.setState(t=>({flags:{...t.flags,[e]:{...t.flags[e],enabled:n}}}))}function p$(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 pA=eQ(function(e,n,t){eJ(e,n,t)});function pw(e=!0,n=!1){return pk(p$(),e,n)}function pk(e,n=!0,t=!1){return!!(e?n:t)}let px=H("extensionsInternal",{slots:{},extensions:{}}),pC=H("extensionRenderings",{renderings:new Map}),pE=()=>K("extensionsInternal",{slots:{},extensions:{}}),pS=()=>K("extensionRenderings",{renderings:new Map});function pD(e){let n=px.getState(),t=e(n);t!==n&&px.setState(t)}let pM=null,pz=null;function pO(){let e=pC.getState();return pM&&e===pz||(pM=new Map(e.renderings),pz=e,function(e){for(let n of(pW.clear(),e.values()))pG(n,1);pV=!0}(pM)),pM}function pP(e){pz={renderings:e},pC.setState(pz,!0)}function pT(e){let n=pO();n.has(e.renderingId)||(n.set(e.renderingId,e),pG(e,1),pP(n))}function pB(e){let n=pO(),t=n.get(e);t&&(n.delete(e),pG(t,-1),pP(n))}let pI=()=>K("extensions",{slots:{}}),pN=0,pj=new Set;function pR(e){pN++;try{return e()}finally{if(0==--pN&&pj.size>0){let e=Array.from(pj);for(let n of(pj.clear(),e))pF(n)}}}function pF(e){try{e()}catch(n){console.error(`The extension system's '${e.name}' recomputation failed`,n)}}function pL(e){pN>0?pj.add(e):pF(e)}let pW=new Map,pV=!1;function pG(e,n){let t=JSON.stringify([e.slotName,e.extensionId,e.slotModuleName,e.extensionModuleName]),i=pW.get(t);if(!i){if(n<0)return;pW.set(t,{count:1,record:{slotModuleName:e.slotModuleName,extensionModuleName:e.extensionModuleName,slotName:e.slotName,extensionId:e.extensionId}}),pV=!0;return}i.count+=n,i.count<1&&(pW.delete(t),pV=!0)}function pU(){var e,n;if(pO(),!pV)return;pV=!1;let t=Array.from(pW.values(),({record:e})=>e);t.sort(pH),e=nU.getState().mountedExtensions,n=t,e.length===n.length&&e.every((e,t)=>0===pH(e,n[t]))||nU.setState({mountedExtensions:t})}function pH(e,n){return pq(e.slotName,n.slotName)||pq(e.extensionId,n.extensionId)||pq(e.slotModuleName,n.slotModuleName)||pq(e.extensionModuleName,n.extensionModuleName)}function pq(e,n){return e===n?0:e<n?-1:1}pU(),pC.subscribe(()=>pL(pU));let pK=pE(),pY=pI(),pJ=nq(),pZ=nJ(),pX=new Set,pQ=!1;function p0(e){if(null===e)pX=null;else if(null!==pX)for(let n of e)pX.add(n);pL(p1)}function p1(){if(!pQ){pQ=!0;try{for(let e=1;;e++){let n=pX;if(null!==n&&0===n.size)return;pX=new Set;try{!function(e,n,t,i,r,o=null){let a=pY.getState().slots,s={},l=!1,c=p$(),u=Object.entries(i.flags).filter(([,{enabled:e}])=>e).map(([e])=>e);for(let[i,p]of Object.entries(e.slots)){let d=a[i];if(d&&o&&!o.has(i)){s[i]=d;continue}let{config:f}=nY(n,p.name),h=function(e,n,t,i,r,o,a){let s=function(e,n){let t=e.add||[],i=e.remove||[],r=e.order||[],{extensions:o}=pK.getState();return[...n,...t].filter(e=>!i.includes(e)).sort((e,t)=>dt(e,r,o[p4(e)]?.order,n)-dt(t,r,o[p4(t)]?.order,n))}(t,n.slots[e].attachedIds),l=[];for(let c of s){let{config:s}=nX(i,e,c),u=nQ(t,e,c),p=u?pA({},s,u):s,d=p4(c),f=n.extensions[d];if(f){let e=p?.["Display conditions"]?.privileges??f.privileges??[];if(e&&("string"==typeof e||Array.isArray(e)&&e.length>0)&&(!a?.user||!rj(e,a.user))||f.featureFlag&&!r.includes(f.featureFlag)||window.offlineEnabled&&!pk(o,f.online,f.offline))continue;l.push({id:c,name:d,moduleName:f.moduleName,config:p,featureFlag:f.featureFlag,meta:f.meta,online:p?.["Display conditions"]?.online??f.online??!0,offline:p?.["Display conditions"]?.offline??f.offline??!1,displayConditionExpression:p?.["Display conditions"]?.expression||f.displayExpression})}}return l}(i,e,f,t,u,c,r.session);d&&d.moduleName===p.moduleName&&e2(d.candidateExtensions,h)?s[i]=d:(s[i]={moduleName:p.moduleName,candidateExtensions:h},l=!0)}(l||Object.keys(a).length!==Object.keys(s).length)&&pY.setState({slots:s})}(pK.getState(),pJ.getState(),pZ.getState(),pg.getState(),rz.getState(),n)}catch(e){throw pX=null===n||null===pX?null:new Set([...n,...pX]),e}if(e>=20)return void console.error("The extension system stopped recomputing after 20 passes because something keeps invalidating slots in response to the extension store being written. Some slots are left stale until the next write.")}}finally{pQ=!1}}}function p2(e,n){let t=new Set;for(let i of Object.keys(e))e[i]!==n[i]&&t.add(i);for(let i of Object.keys(n))i in e||t.add(i);return t}function p3(){p0(null)}function p5(e,n){return{moduleName:n,name:e,attachedIds:[]}}function p4(e){let[n]=e.split("#");return n}function p6(e,n){let t=p4(n);return e.extensions[t]}function p8(e){return p6(pK.getState(),e)}pK.subscribe((e,n)=>{p0(e.extensions!==n.extensions?null:p2(e.slots,n.slots))}),pJ.subscribe((e,n)=>{p0(p2(e.slots,n.slots))}),pZ.subscribe((e,n)=>{p0(p2(e.configs,n.configs))}),pg.subscribe(()=>p0(null)),rz.subscribe(()=>p0(null)),p3(),y(p3);let p7=e=>pD(n=>({...n,extensions:{...n.extensions,[e.name]:{...e}}}));function p9(e,n){pD(t=>{let i=t.slots[e];return i?{...t,slots:{...t.slots,[e]:{...i,attachedIds:[...i.attachedIds,n]}}}:{...t,slots:{...t.slots,[e]:{...p5(e),attachedIds:[n]}}}})}function de(e,n){pD(t=>{let i=t.slots[e];return i&&i.attachedIds.includes(n)?{...t,slots:{...t.slots,[e]:{...i,attachedIds:i.attachedIds.filter(e=>e!==n)}}}:t})}function dn(e){pD(n=>{let t=n.slots[e];return t?{...n,slots:{...n.slots,[e]:{...t,attachedIds:[]}}}:n})}function dt(e,n,t,i){let r=n.indexOf(e);if(-1!==r)return r;{if(void 0!==t)return 1e3+t;let n=i.indexOf(e);return -1!==n?2e3+n:3e3}}function di(e,n){return function(e,n,t=null,i){let r;return e.filter(e=>{let o=e.displayConditionExpression;if("string"!=typeof o||0===o.trim().length)return!0;r??(r=n&&"object"==typeof n?{session:t,...n}:{session:t});try{return!!u6(o,r)}catch(n){return console.error(`Error while evaluating expression '${o}' for ${e.id}`+(i?` in ${i}`:""),n),!1}})}(dr(e),n,rz.getState().session,e)}function dr(e){return pY.getState().slots[e]?.candidateExtensions??[]}let da=(e,n)=>pK.setState(t=>{let i=t.slots[n]?.moduleName;if(i&&i!=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 ${i}.`),t;if(i&&i==e)return t;if(t.slots[n])return{...t,slots:{...t.slots,[n]:{...t.slots[n],moduleName:e}}};let r=p5(n,e);return{...t,slots:{...t.slots,[n]:{...r}}}}),ds=()=>{pX=null,pD(()=>({slots:{},extensions:{}})),pS().setState({renderings:new Map}),pY.setState({slots:{}})},dl=H("left-nav",{slotName:null,basePath:window.spaBase,mode:"normal"});function dc({name:e,basePath:n,mode:t,componentContext:i,state:r}){dl.setState({slotName:e,basePath:n,mode:t??"normal",componentContext:i,state:r})}function du(e){dl.getState().slotName===e&&dl.setState(dl.getInitialState(),!0)}let dp=H("modalRegistry",{modals:{}});function dd(e){dp.setState(n=>(n.modals[e.name]=e,n))}function df(e){let n=dp.getState().modals[e];if(!n){let t=p8(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.`),dd(n))}return n}let dh=H("workspaceRegistrations",{workspaces:{}}),dg=H("workspaceGroups",{workspaceGroups:{}});function dm(e){dh.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 db(e){dg.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 dy=new Set;function d_(e){let n=dh.getState().workspaces;if(n[e])return n[e];{let n=p8(e);if(n){var t;let i;return dy.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.`),dy.add(e)),{name:n.name,title:(t=n,"string"==typeof(i=t?.meta?.title)?i:i&&"object"==typeof i?oE(t.moduleName,i.key,i.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 dv(e){let n=dg.getState().workspaceGroups;if(n[e])return n[e];throw Error(`No workspace group named '${e}' has been registered.`)}let d$=H("workspace2",{registeredGroupsByName:{},registeredWindowsByName:{},registeredWorkspacesByName:{},openedGroup:null,openedWindows:[],workspaceTitleByWorkspaceName:{},isMostRecentlyOpenedWindowHidden:!1});function dA(e){let{registeredWorkspacesByName:n,registeredWindowsByName:t}=d$.getState(),i=n[e];if(i){let n=t[i.window];if(n)return n;throw Error(`No workspace window found with name: ${i.window} for workspace: ${e}`)}throw Error(`No workspace found with name: ${e}`)}function dw(e){let{registeredGroupsByName:n,registeredWindowsByName:t}=d$.getState(),i=t[e];if(i){let t=n[i.group];if(t)return t;throw Error(`No workspace group found with name: ${i.group} for window: ${e}`)}throw Error(`No workspace window found with name: ${e}`)}function dk(e){let{openedWindows:n}=d$.getState();return n.findIndex(n=>n.openedWorkspaces.find(n=>n.workspaceName===e))}function dx(e,n){if(0==n.length)return;let{registeredGroupsByName:t}=d$.getState(),i={...t};for(let t of n){if(i[t.name])throw Error(`Cannot register workspace group ${t.name} more than once`);i[t.name]={...t,moduleName:e}}d$.setState({registeredGroupsByName:i})}function dC(e,n){if(0==n.length)return;let{registeredWindowsByName:t}=d$.getState(),i={...t};for(let t of n){if(i[t.name])throw Error(`Cannot register workspace window ${t.name} more than once`);let n={...t,moduleName:e};i[t.name]=n}d$.setState({registeredWindowsByName:i})}function dE(e,n){if(0==n.length)return;let{registeredWorkspacesByName:t}=d$.getState(),i={...t};for(let t of n){if(i[t.name])throw Error(`Cannot register workspace ${t.name} more than once`);let n={...t,moduleName:e};i[t.name]=n}d$.setState({registeredWorkspacesByName:i})}let dS=0,dD=null,dM={bootstrap:{millis:15e3,dieOnTimeout:!0},mount:{millis:15e3,dieOnTimeout:!0},unmount:{millis:15e3,dieOnTimeout:!0}};async function dz(e,n){return(await (dD??(dD=new Promise((e,n)=>{iC({name:"openmrs-extension-host",bootstrap:()=>Promise.resolve(),mount:n=>(e(n.mountParcel),Promise.resolve()),unmount:()=>Promise.resolve()},{domElement:document.createElement("div")}).mountPromise.catch(n)}).catch(e=>(console.error("The host parcel used to mount extensions could not be mounted. Falling back to mounting extensions as root parcels, which leaks their DOM elements.",e),iC))),dD))("function"==typeof e?()=>e().then(e=>({timeouts:dM,...e})):{timeouts:dM,...e},n)}function dO(){return dP}function dP(e,n){let t,i=dz(e,n).then(e=>t=e);return{mount:()=>i.then(e=>e.mount()),unmount:()=>i.then(e=>e.unmount()),update:e=>i.then(n=>n.update?.(e)),getStatus:()=>t?.getStatus()??"LOADING_SOURCE_CODE",get loadPromise(){return i.then(e=>e.loadPromise)},get bootstrapPromise(){return i.then(e=>e.bootstrapPromise)},get mountPromise(){return i.then(e=>e.mountPromise)},get unmountPromise(){return i.then(e=>e.unmountPromise)}}}async function dT(e,n,t,i,r=e=>e,o={}){let a=p4(i),s=p8(i),l=null;if(e){if(!s)throw Error(`Couldn't find extension '${a}' to attach to '${n}'`);let{meta:c,moduleName:u,online:p,offline:d,load:f}=s;if(pw(p,d)){let s,p=dS++,d=`${n}/${i}-${p}`;e.dataset.extensionRenderingId=d;let h=e=>{try{pB(d)}catch(n){console.error(e,n)}};try{pT({renderingId:d,extensionName:a,extensionModuleName:u,extensionId:i,slotName:n,slotModuleName:t})}catch(e){throw h(`Recomputing configuration after registering '${i}' failed also failed`),e}try{s=await f()}catch(e){throw h(`Recomputing configuration after '${i}' failed to load also failed`),e}try{l=await dz(r({...s,name:`${n}/${a}-${p}`}),{...o,_meta:c,_extensionContext:{extensionId:i,extensionSlotName:n,extensionSlotModuleName:t,extensionModuleName:u},domElement:e})}catch(e){throw h(`Recomputing configuration after '${i}' failed to mount also failed`),e}l.mountPromise.then(void 0,e=>{console.error(`Extension '${i}' in slot '${n}' failed to mount`,e),h(`Recomputing configuration after '${i}' failed to mount also failed`)}),l.unmountPromise.then(()=>h(`Recomputing configuration after unmounting '${i}' failed`),e=>{console.error(`Extension '${i}' in slot '${n}' failed to unmount`,e),h(`Recomputing configuration after '${i}' failed to unmount also failed`)})}}else console.warn(`Tried to render ${i} into ${n} but no DOM element was available.`);return l}var dB=t(15275),dI=t.n(dB);let dN=(0,dB.createContext)({moduleName:"",featureName:""});function dj({to:e,templateParams:n,onBeforeNavigate:t,children:i,...r}){return(0,dB.useEffect)(()=>{r.href&&console.warn(`ConfigurableLink does not support the href prop. Use the 'to' prop instead. The provided href value is '${r.href}'`),r.onClick&&console.warn(`ConfigurableLink does not support the onClick prop. Use the 'onBeforeNavigate' prop instead. The 'to' prop of the offending link is ${e}`)},[]),dI().createElement("a",{onClick:i=>{0===i.button&&!i.ctrlKey&&!i.shiftKey&&!i.altKey&&!i.metaKey&&(i.preventDefault(),t?.(i),rh({to:e,templateParams:n})),0===i.button&&(i.ctrlKey||i.metaKey)&&t?.(i),0===i.button&&i.shiftKey&&t?.(i),1===i.button&&t?.(i)},href:rd(e,n),...r},i)}let dR=({state:e,children:n,...t})=>{let{extension:i}=(0,dB.useContext)(dN),r=(0,dB.useRef)(null),o=(0,dB.useRef)(Promise.resolve()),a=(0,dB.useRef)(!1),s=(0,dB.useRef)(!1),l=(0,dB.useRef)(e),c=(0,dB.useCallback)(e=>{if(!e)return;let n=()=>{"MOUNTED"===e.getStatus()&&e.unmount()};switch(e.getStatus()){case"MOUNTED":e.unmount();break;case"UPDATING":o.current?.then(n,n);break;default:e.mountPromise.then(n,()=>{})}},[]),u=(0,dB.useCallback)((e,n)=>{e.update&&"UNMOUNTING"!==e.getStatus()&&(o.current=Promise.all([e.mountPromise,o.current]).then(()=>{if(r.current?.getStatus()==="MOUNTED"&&r.current.update)return r.current.update({...n})}).catch(e=>{let n=r.current?.getStatus();"UNMOUNTING"!==n&&"NOT_MOUNTED"!==n&&"UNLOADING"!==n&&console.error(`The extension '${i?.extensionId}' failed to update`,e)}))},[]),p=(0,dB.useCallback)(n=>{n&&!r.current&&!s.current&&i?.extensionSlotName&&i.extensionSlotModuleName&&(s.current=!0,dT(n,i.extensionSlotName,i.extensionSlotModuleName,i.extensionId,void 0,e).then(n=>{(s.current=!1,r.current=n,a.current)?c(n):n&&l.current!==e&&u(n,l.current)},()=>{s.current=!1}))},[]);return(0,dB.useEffect)(()=>(a.current=!1,()=>{a.current=!0,c(r.current)}),[]),(0,dB.useEffect)(()=>{l.current=e,r.current&&u(r.current,e)},[e]),i?dI().createElement("div",{ref:p,"data-extension-id":i?.extensionId,style:{position:"relative"},...t}):null};function dF(e){let n=(0,dB.useRef)(e);return R(n.current,e)||(n.current=e),n.current}function dL(e,n){"function"==typeof n&&(n=n(e));let t={};for(let[i,r]of Object.entries(n)){let n=function(...n){e.setState(e=>r(e,...n))};t[i]=n}return t}let dW=e=>e;function dV(e,n=dW,t){let i=(0,dB.useCallback)(n=>e.subscribe(n),[e]),r=(0,dB.useCallback)(()=>n(e.getState()),[e,n]),o=(0,dB.useSyncExternalStore)(i,r,r),a=(0,dB.useMemo)(()=>t?dL(e,t):null,[e,t]);return(0,dB.useMemo)(()=>a?{...o,...a}:o,[o,a])}function dG(e,n){return dV(e,dW,n)}function dU(e){return function(n){let t=(0,dB.useCallback)(n=>e.subscribe(n),[]),i=(0,dB.useCallback)(()=>e.getState(),[]),r=(0,dB.useSyncExternalStore)(t,i,i),o=(0,dB.useMemo)(()=>n?dL(e,n):null,[n]);return(0,dB.useMemo)(()=>o?{...r,...o}:r,[r,o])}}let dH=[];Object.freeze(dH);let dq={candidateExtensions:dH};Object.freeze(dq);let dK=e=>{let n=(0,dB.useCallback)(n=>n.slots?.[e]??dq,[e]);return dV(pI(),n)},dY=e=>e.session;function dJ(e,n){let{candidateExtensions:t}=dK(e),i=dV(rz,dY),r=dF(n);return(0,dB.useMemo)(()=>di(e,r),[e,r,i,t])}function dZ(e,n){let{moduleName:t}=(0,dB.useContext)(dN);if(!t)throw Error("ComponentContext has not been provided. This should come from @openmrs/esm-react-utils.");return(0,dB.useEffect)(()=>{da(t,e)},[t,e]),{extensions:dJ(e,n),extensionSlotName:e,extensionSlotModuleName:t}}function dX(e){return e}function dQ({name:e,extensionSlotName:n,select:t=dX,children:i,state:r,style:o,...a}){if(i&&r)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,dB.useRef)(null),{extensions:c,extensionSlotModuleName:u}=dZ(s,r),p=(0,dB.useMemo)(()=>t(c),[t,c]),d=(0,dB.useMemo)(()=>{if("function"==typeof i&&!dI().isValidElement(i))return p.map(e=>i(e,r))},[i,p]);return dI().createElement("div",{ref:l,"data-extension-slot-name":s,"data-extension-slot-module-name":u,style:{...o,position:"relative"},...a},s&&p?.map((e,n)=>dI().createElement(dN.Provider,{key:e.id,value:{moduleName:u,featureName:"",extension:{extensionId:e.id,extensionSlotName:s,extensionSlotModuleName:u}}},d?.[n]??("function"!=typeof i?i:null)??dI().createElement(dR,{state:r}))))}var d0=t(5338);function d1(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);n&&(i=i.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),t.push.apply(t,i)}return t}function d2(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?d1(Object(t),!0).forEach(function(n){var i,r,o;i=e,r=n,o=t[n],r in i?Object.defineProperty(i,r,{value:o,enumerable:!0,configurable:!0,writable:!0}):i[r]=o}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):d1(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})}return e}function d3(e){return(d3="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 d5(e){return(d5="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 d4(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(d5(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(d5(e)));return e}}var d6=null;try{d6=require("react").createContext()}catch(e){}var d8={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 d7(e,n){return e.rootComponent?Promise.resolve():e.loadRootComponent(n).then(function(n){e.rootComponent=n})}function d9(e,n){return new Promise(function(t,i){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 r,o=fi(e,n,function(){t(this)}),a=d4(e,n)(),s=function(e){var n=e.reactDom,t=e.renderType,i=e.elementToRender,r=e.domElement,o=n[t];if("function"!=typeof o)throw Error('renderType "'.concat(t,'" did not return a function.'));switch(t){case"createRoot":case"unstable_createRoot":case"createBlockingRoot":case"unstable_createBlockingRoot":var a=o(r);return a.render(i),a;case"hydrateRoot":return o(r,i);default:return o(i,r),null}}({elementToRender:o,domElement:a,reactDom:ft(e),renderType:"function"==typeof(r=e).renderType?r.renderType():r.renderType});e.domElements[n.name]=a,e.renderResults[n.name]=s})}function fe(e,n){return new Promise(function(t){e.unmountResolves[n.name]=t;var i=e.renderResults[n.name];i&&i.unmount?i.unmount():ft(e).unmountComponentAtNode(e.domElements[n.name]),delete e.domElements[n.name],delete e.renderResults[n.name]})}function fn(e,n){return new Promise(function(t){e.updateResolves[n.name]||(e.updateResolves[n.name]=[]),e.updateResolves[n.name].push(t);var i=fi(e,n,null),r=e.renderResults[n.name];if(r&&r.render)r.render(i);else{var o=d4(e,n)();ft(e).render(i,o)}})}function ft(e){return e.ReactDOMClient||e.ReactDOM}function fi(e,n,t){var i=e.React.createElement(e.rootComponent,n),r=d6?e.React.createElement(d6.Provider,{value:n},i):i;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),r=e.React.createElement(e.errorBoundaryClass,n,r)),r=e.React.createElement(e.SingleSpaRoot,d2(d2({},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])}}),r)}var fr=t(38395),fo=t(59324),fa=t(88716);let fs={strictMode:!0,throwErrorsToConsole:!0,disableTranslations:!1},fl=new Map;(0,fa.initCache)(fl);let fc={errorRetryCount:3,fetcher:rS,focusThrottleInterval:18e5,revalidateIfStale:!0,revalidateOnFocus:!1,revalidateOnReconnect:!1,refreshInterval:0,shouldRetryOnError:e=>{if(e instanceof rM){let n=e.response.status;return!!(n>=500)||401===n||403===n||429===n}return!0},provider:()=>fl};function fu(e){if("object"!=typeof e||"string"!=typeof e.featureName||"string"!=typeof e.moduleName)throw Error("Invalid options");let n=Object.assign({},fs,e),t={...fc,...n.swrConfig};return function(e){var i,r,o,a,s;return o=r=class extends(i=dI().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 dI().createElement("div",null,"An error has occurred. Please try reloading the page.");{let i=dI().createElement(dB.Suspense,{fallback:null},dI().createElement(fo.BE,{value:t},dI().createElement(dN.Provider,{value:this.state.config},n.disableTranslations?dI().createElement(e,this.props):dI().createElement(fr.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},dI().createElement(e,this.props)))));return n.strictMode&&dI().StrictMode?dI().createElement(dI().StrictMode,null,i):i}}constructor(e){super(e),this.state={caughtError:null,caughtErrorInfo:null,config:{moduleName:n.moduleName,featureName:n.featureName,extension:e._extensionContext}}}},a="displayName",s=`OpenmrsReactComponent(${n.featureName})`,a in o?Object.defineProperty(o,a,{value:s,enumerable:!0,configurable:!0,writable:!0}):o[a]=s,r}}function fp(e,n){return function(e){if("object"!==d3(e))throw Error("single-spa-react requires a configuration object");var n,t=d2(d2({},d8),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");!d6&&t.React.createContext&&(d6=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 i={bootstrap:d7.bind(null,t),mount:d9.bind(null,t),unmount:fe.bind(null,t)};return t.parcelCanUpdate&&(i.update=fn.bind(null,t)),i}({React:dI(),ReactDOMClient:d0,rootComponent:fu(n)(e)})}function fd(e,n){return()=>e().then(({default:e})=>fp(e,n))}function ff(e,n){return()=>Promise.resolve(fp(e,n))}let fh=fd,fg=V()(()=>({}));q("openmrs-app-context",fg);let fm={};function fb(e,n=e=>e){let t=fg.getState();return e in t?Object.freeze(Object.assign({},n?n(t[e]):t[e])):null}function fy(e,n){fg.setState(t=>(e in t||(t[e]={}),t[e]=n(t[e]),Object.assign({},t)))}function f_(e){return null===e?null:Object.freeze(Object.assign({},e))}let fv=new Map;function f$(e,n){let t=(0,dB.useRef)(n??{}),i=(0,dB.useRef)(n=>fy(e,n)),r=(0,dB.useRef)(Symbol());return(0,dB.useEffect)(()=>{let t=n??{},i=r.current;return null===fb(e)?!function(e,n=fm){fg.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===fm?{}: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.`),fy(e,()=>t)),fv.set(e,i),()=>{fv.get(e)===i&&(fg.setState(n=>(e in n&&delete n[e],n)),fv.delete(e))}},[e]),(0,dB.useEffect)(()=>{let i=n??{};R(t.current,i)||(fy(e,()=>i),t.current=i)},[n]),i.current}function fA({namespace:e,value:n}){return f$(e,n),null}let fw=({children:e,value:n,fallback:t})=>n?dI().createElement(dI().Fragment,null,e):t?dI().createElement(dI().Fragment,null,t):null;function fk(){let e=(0,dB.useRef)();return(!e.current||e.current.signal.aborted)&&(e.current=new AbortController),(0,dB.useEffect)(()=>{let n=e.current;return()=>n?.abort()},[]),e.current}function fx(e,n=e=>e??{}){let[t,i]=(0,dB.useState)(()=>{if(fC(e))return;let t=fb(e);if(null!==t)return n?n(t):t});return(0,dB.useEffect)(()=>{if(fC(e))throw Error(`The namespace supplied to useAppContext must be a non-empty string, but was "${e}".`)},[e]),(0,dB.useEffect)(()=>{var t;let r;return(t=e=>{if(null==e)return void i(void 0);let t=n?n(e):e;i(e=>R(e,t)?e:t)})(f_(r=fb(e))),fg.subscribe(n=>{let i=e in n?n[e]:null;i!==r&&(r=i,t(f_(i)))})},[e,n]),t}function fC(e){return"string"!=typeof e||0===e.trim().length}function fE(e){let n=dJ(e);return(0,dB.useMemo)(()=>n.map(e=>e.id),[n])}function fS(e){return dK(e).candidateExtensions}function fD(e,n){let{data:t,error:i,mutate:r,isLoading:o,isValidating:a}=(0,fo.Ay)(`${ad}?patient=${e}&includeEncounterless=${n}`,rS);return(0,dB.useMemo)(()=>({isLoading:o,data:t?.data.results??[],error:i,mutate:r,isValidating:a}),[t,i,o,a,r])}function fM(e){(0,dB.useEffect)(()=>{if(e){let e=window.getComputedStyle(document.body).overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=e}}},[e])}let fz={},fO=`No ComponentContext has been provided. This should come from "openmrsComponentDecorator".
|
|
16
16
|
Usually this is already applied when using "getAsyncLifecycle" or "getSyncLifecycle".`;function fP(e){let{moduleName:n,extension:t}=(0,dB.useContext)(dN),i=e?.externalModuleName??n;if(!i&&!t)throw Error(fO);let r=function(e){let n=(0,dB.useMemo)(()=>nH(e),[e]),t=function(e){let[n,t]=(0,dB.useState)(()=>{let n=e.getState();return n.loaded&&n.config?n.config:null});return(0,dB.useEffect)(()=>e?.subscribe(e=>{e.loaded&&e.config&&t(e.config)}),[e]),n}(n);if(!t)throw fz[e]||(fz[e]=new Promise(e=>{let t=n.subscribe(n=>{n.loaded&&n.config&&(e(n.config),t())})})),fz[e];return t}(i),o=function(e){let n=(0,dB.useMemo)(nJ,[]),t=function(e,n){let[t,i]=(0,dB.useState)(n?()=>{let t=nX(e.getState(),n.extensionSlotName,n.extensionId);if(t.loaded&&t.config)return t.config}:null);return(0,dB.useEffect)(()=>{if(n)return e.subscribe(e=>{let r=nX(e,n.extensionSlotName,n.extensionId);r.loaded&&r.config&&!e2(r.config,t)&&i(r.config)})},[e,n,t]),t}(n,e);if(!t&&e){let t=`${e.extensionSlotName}-${e.extensionId}`;throw!fz[t]&&n&&(fz[t]=new Promise(t=>{let i=n.subscribe(n=>{let r=nX(n,e.extensionSlotName,e.extensionId);r.loaded&&r.config&&(t(r.config),i())})})),fz[t]}return t||{}}(t);return(0,dB.useMemo)(()=>e?.externalModuleName&&i===e.externalModuleName?{...r}:{...r,...o},[i,e?.externalModuleName,r,o])}let fT=dJ;function fB(){let[e,n]=(0,dB.useState)(p$());return(0,dB.useEffect)(()=>y(({online:e})=>n(e)),[]),e}function fI(e,n=300){let[t,i]=(0,dB.useState)(e);return(0,dB.useEffect)(()=>{let t=setTimeout(()=>{i(e)},n);return()=>{clearTimeout(t)}},[e,n]),t}var fN=t(32016),fj=t.n(fN);let fR=`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 fF(){let e=`${rk}/emrapi/configuration?v=${fR}`,n=fj()(e,rS);return(0,dB.useMemo)(()=>({emrConfiguration:n.data?.data,isLoadingEmrConfiguration:n.isLoading,mutateEmrConfiguration:n.mutate,errorFetchingEmrConfiguration:n.error}),[n])}let fL=dU(pE());function fW(e){let n=dJ(e);return(0,dB.useMemo)(()=>Object.fromEntries(n.map(e=>[e.name,e.meta])),[n])}let fV=dU(pI());function fG(e){let{flags:n}=dV(pg);return n[e]?.enabled??!1}function fU(){let[,e]=(0,dB.useState)(0);return(0,dB.useCallback)(()=>{e(e=>e+1)},[])}function fH(e,n,t={}){return fK(e,n,fq,t)}let fq={getPaginatedUrl:(e,n,t)=>{if(!e)return null;{let i=new URL(rE(e.toString()),window.location.toString());return i.searchParams.set("limit",""+n),i.searchParams.set("startIndex",""+t),i.searchParams.set("totalCount","true"),i.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 fK(e,n,t,i={}){let{getPaginatedUrl:r,getTotalCount:o,getCurrentPageSize:a,getData:s}=t,{immutable:l,swrConfig:c}=i,u=i.fetcher??rS,[p,d]=(0,dB.useState)(1),f=(0,dB.useRef)(NaN),h=(0,dB.useRef)(NaN),g=(0,dB.useRef)(p),m=(0,dB.useRef)(!1),b=(0,dB.useRef)(!1),y=e?.toString()??"",[v,$]=(0,dB.useState)(y);y!==v&&($(y),d(1),g.current=1,f.current=NaN,h.current=NaN,m.current=!1,b.current=!1);let A=(p-1)*n,w=(0,dB.useMemo)(()=>r(e,n,A),[e,n,A]),{data:k,...x}=(l?fj():fo.Ay)(w,u,c);k?.data&&(f.current=o(k?.data),h.current=a(k?.data),m.current=!0);let C=Math.ceil(f.current/n),E=(0,dB.useCallback)(e=>{if(!Number.isInteger(e)||e<1)return void console.warn(`useServerPagination: ignoring goTo(${e}); page must be a positive integer.`);let t=Math.ceil(f.current/n);!m.current||Number.isNaN(t)||e<=t?(g.current=e,d(e)):console.warn("Invalid attempt to go to out of bounds page: "+e)},[n]);(0,dB.useEffect)(()=>{if(!m.current)return;if(Number.isNaN(f.current)){b.current||(b.current=!0,console.warn(`useServerPagination: ${y} returned no total count, so out-of-range pages cannot be detected.`));return}let e=Math.max(1,Math.ceil(f.current/n));p>e&&(console.warn(`Invalid attempt to go to out of bounds page: ${p}; returning to page ${e}.`),g.current=e,d(e))},[p,n,y,k]);let S=(0,dB.useCallback)(()=>{E(g.current+1)},[E]),D=(0,dB.useCallback)(()=>{E(g.current-1)},[E]);return{data:s(k?.data),totalPages:C,totalCount:f.current,currentPage:p,currentPageSize:h.current,paginated:C>1,showNextButton:p<C,showPreviousButton:p>1,goTo:E,goToNext:S,goToPrevious:D,...x}}function fY(e,n,t={}){return fK(e,n,fJ(),t)}function fJ(){return{getPaginatedUrl:(e,n,t)=>{if(!e)return null;{let i=new URL(rE(e.toString()),window.location.toString());return i.searchParams.set("_count",""+n),i.searchParams.set("_getpagesoffset",""+t),i.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 fZ=t(62142),fX=t.n(fZ);function fQ(e,n={}){return f0(e,fq,n)}function f0(e,n,t={}){let{swrInfiniteConfig:i,immutable:r}=t,{getNextUrl:o,getTotalCount:a,getData:s}=n,l=t.fetcher??rS,c=(0,dB.useCallback)((t,i)=>0==t?e?.toString()??null:n.getNextUrl(i.data),[e]),{data:u,size:p,setSize:d,...f}=fX()(c,l,{...i,...r?{revalidateIfStale:!1,revalidateOnFocus:!1,revalidateOnReconnect:!1}:{}}),h=o(u?.[u.length-1].data),g=a(u?.[0]?.data);return{data:u?.flatMap(e=>s(e.data)),totalCount:g,hasMore:null!=h,loadMore:()=>{d((u?.length??0)+1)},nextUri:h,...f}}function f1(e,n={}){return f2(e,fq,n)}function f2(e,n,t={}){let i=f0(e,n,t),{hasMore:r,error:o,data:a,loadMore:s,isLoading:l,nextUri:c}=i;return((0,dB.useEffect)(()=>{r&&!o&&s()},[r,c]),t.partialData)?i:{...i,data:r||o?void 0:a,isLoading:l||r}}function f3(e,n={}){return f2(e,fJ(),n)}function f5(e,n={}){return f0(e,fJ(),n)}function f4(){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 f6(){let[e,n]=(0,dB.useState)(f4);return(0,dB.useEffect)(()=>{let e=()=>{n(f4())};return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),e}let f8=e=>"small-desktop"===e||"large-desktop"===e;function f7(e){let n=(0,dB.useContext)(dN);(0,dB.useEffect)(()=>(n&&n.moduleName&&(e.componentContext=n),dc(e),()=>{du(e.name)}),[n,e])}function f9(){return dV(dl)}function he(e=null,n=null){let[t,i]=(0,dB.useState)([]);return(0,dB.useEffect)(()=>{let t=uR(e,n).subscribe(e=>{i(e)},e=>{console.error(e)});return()=>t.unsubscribe()},[e,n]),t}function hn(e,n=!0){let t=(0,dB.useRef)(null);return(0,dB.useEffect)(()=>{let i=i=>{n&&t.current&&i.target&&i.target instanceof Node&&(t.current.contains(i.target)||e(i))};return window.addEventListener("mousedown",i),window.addEventListener("touchstart",i),()=>{window.removeEventListener("mousedown",i),window.removeEventListener("touchstart",i)}},[e,n]),t}function ht(e){let n=(0,dB.useRef)();return(0,dB.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 hi(e,n={}){let{abortController:t,fetchInit:i,url:r,swrConfig:o}=n,a=fk(),s=(0,dB.useMemo)(()=>i?.signal??t?.signal??a.signal,[t?.signal,i?.signal,a.signal]),l=(0,dB.useCallback)(e=>rS(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,r),{...i,signal:s}),[s,i,r]);return(0,fo.Ay)(e,l,o)}function hr(e=[],n=10){let[t,i]=(0,dB.useState)(1),r=(0,dB.useMemo)(()=>"number"==typeof n&&n>0?Math.max(1,Math.ceil(e.length/n)):1,[e.length,n]);t>r&&i(r);let o=Math.min(Math.max(1,t),r),a=(0,dB.useMemo)(()=>{let t=(o-1)*n,i=(o+0)*n;return e.slice(t,i)},[e,o,n]),s=(0,dB.useCallback)(e=>{!Number.isInteger(e)||e<1?console.warn(`usePagination: ignoring goTo(${e}); page must be a positive integer.`):i(e)},[]),l=(0,dB.useCallback)(()=>{i(e=>e+1)},[]),c=(0,dB.useCallback)(()=>{i(e=>Math.max(1,e-1))},[]);return(0,dB.useMemo)(()=>({results:a,totalPages:r,currentPage:o,paginated:e.length>n,showNextButton:o<r,showPreviousButton:o>1,goTo:s,goToNext:l,goToPrevious:c}),[a,r,e.length,n,o,s,l,c])}function ho(e,n,t,i){return{pageSizes:(0,dB.useMemo)(()=>{let t=Math.ceil(n/e);return isNaN(t)&&(t=0),[...Array(t).keys()].map(n=>(n+1)*e)},[e,n]),pageItemsCount:(0,dB.useMemo)(()=>e>n?n:e*t>n?e*(t-1)+i:e*t,[e,n,t,i])}}function ha(){let e=/\/patient\/([a-zA-Z0-9\-]+)\/?/.exec(location.pathname);return e&&e[1]}function hs(e){let[n,t]=(0,dB.useState)(e??ha()),{data:i,error:r,isValidating:o}=(0,fo.Ay)(n?["patient",n]:null,()=>uP(n,{}));return(0,dB.useEffect)(()=>{let e=()=>{let e=ha();e!==n&&t(e)};return window.addEventListener("single-spa:routing-event",e),()=>window.removeEventListener("single-spa:routing-event",e)},[n]),(0,dB.useMemo)(()=>({isLoading:o&&!r&&!i,patient:i,patientUuid:n,error:r}),[o,r,i,n])}function hl(){let e=`${rk}/metadatamapping/termmapping?v=custom:(metadataUuid)&code=emr.primaryIdentifierType`,{data:n,error:t,isLoading:i}=(0,fo.Ay)(e,rS);return(0,dB.useMemo)(()=>({primaryIdentifierCode:n?.data?.results[0]?.metadataUuid,isLoading:i,error:t}),[n,t,i])}function hc(e){let{extensions:n,extensionSlotModuleName:t}=dZ(e);return e?n.map(n=>({state:i})=>dI().createElement(dN.Provider,{value:{moduleName:t,featureName:"",extension:{extensionId:n.id,extensionSlotName:e,extensionSlotModuleName:t}}},dI().createElement(dR,{state:i}))):[]}function hu(){let e=(0,dB.useRef)(),[n,t]=(0,dB.useState)(null),i=null;if(!n){if(s){let e=rT().getState();e.loaded&&(i=e.session)}else s=new Promise(n=>{let t=({loaded:t,session:r})=>{t&&(n(r),i=r,e.current&&(e.current(),e.current=void 0))};t(rT().getState()),i||(e.current=rT().subscribe(t))});if(i)t(i);else throw s}(0,dB.useEffect)(()=>(e.current||(e.current=rT().subscribe(({loaded:e,session:n})=>{e&&(i=n,t(n))})),()=>{e.current&&(e.current(),e.current=void 0)}),[]);let r=n||i;if(!r)if(s)throw console.warn("useSession is in an unexpected state. Attempting to recover."),s;else throw Error("useSession is in an invalid state.");return r}let hp=({privilege:e,fallback:n,children:t})=>{let[i,r]=(0,dB.useState)(null);return((0,dB.useEffect)(()=>{let e=rP({includeAuthStatus:!1}).subscribe(r);return()=>e.unsubscribe()},[]),i&&rj(e,i))?dI().createElement(dI().Fragment,null,t):n?dI().createElement(dI().Fragment,null,n):null};var hd=t(74353),hf=t.n(hd),hh=t(47581);let hg=new Map;function hm(){for(let e of Array.from(hg.values()))e()}let hb={setVisitContext:(e,n)=>null==n?{manuallySetVisitUuid:null}:{manuallySetVisitUuid:n.uuid,patientUuid:n.patient?.uuid}};function hy(e){let n=(0,dB.useId)();return(0,dB.useEffect)(()=>{if(e)return hg.set(n,e),()=>{hg.delete(n)}},[n,e]),{...dG(uH(),hb),mutateVisit:hm}}function h_(e,n=uG){let t=(0,dB.useRef)(void 0),{patientUuid:i,manuallySetVisitUuid:r,setVisitContext:o}=hy((0,dB.useCallback)(()=>t.current?.(),[])),a=e&&i==e?r:null,s=`?patient=${e}&v=${n}&includeInactive=false`,l=`/${a}?v=${n}`,{data:c,error:u,mutate:p,isValidating:d}=(0,fo.Ay)(e?`${rk}/visit${s}`:null,rS),{data:f,error:h,mutate:g,isValidating:m}=(0,fo.Ay)(e&&a?`${rk}/visit${l}`:null,rS),b=(0,dB.useMemo)(()=>c?.data.results.find(e=>null===e.stopDatetime)??null,[c]),y=(0,dB.useMemo)(()=>a&&f?f.data:null,[f,a]),v=(0,dB.useRef)(null);(0,dB.useEffect)(()=>{!d&&b&&i===e&&null===r&&o(b),m||(v.current&&y&&v.current.uuid===y.uuid&&!v.current.stopDatetime&&y.stopDatetime&&o(null),v.current=y)},[y,r,b,d,m,i]);let $=(0,dB.useCallback)(()=>{p(),g()},[p,g]);(0,dB.useEffect)(()=>{t.current=$},[$]);let A=!!(!c||a&&!f),w=!!(a?h:u);return{error:u||h,mutate:$,isValidating:d||m,activeVisit:b,currentVisit:y,currentVisitIsRetrospective:!!a,isLoading:A&&!w}}function hv(){let[e,n]=(0,dB.useState)([]);return(0,dB.useEffect)(()=>{let e=uL().subscribe(e=>{n(e)},e=>console.error(e));return()=>e.unsubscribe()},[]),e}hd.extend(hh);let h$=new Map;async function hA(e,n){let t=n.indexOf("#"),i=t>=0,r=i?n.substring(0,t):e,o=i?n.substring(t+1):n,a=await oX(r);return a&&Object.hasOwn(a,o)&&"function"==typeof a[o]?hk(r,a).then(()=>a[o]()):(a?a&&Object.hasOwn(a,o)?console.warn(`The export ${n}, defined in ${e}'s routes.json, is not a function`):console.warn(`${r} does not define a component called "${o}", referenced in ${e}'s routes.json. This cannot be loaded.`):console.warn(`Unknown app ${r} for ${n} defined in ${e}'s routes.json`),hw)}let hw={bootstrap:()=>Promise.resolve(),mount:()=>Promise.resolve(),unmount:()=>Promise.resolve()};async function hk(e,n){if(e in h$)await h$[e];else{let t=n??await oX(e);await (h$[e]=new Promise((n,i)=>{if(Object.hasOwn(t,"startupApp")){let r=t.startupApp;if("function"==typeof r)return Promise.resolve(r()).then(()=>{tl(e),n(null)}).catch(i)}tl(e),n(null)}))}}function hx(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
|