@openmrs/esm-stock-management-app 3.2.2-pre.1707 → 3.2.2-pre.1713

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/4716.js CHANGED
@@ -12,7 +12,7 @@ If you're the maintainer: the 'elements' key only works with '_type' equal to 'A
12
12
  ${t}`)}return n}let rB=(e,t)=>{let r=structuredClone(t);if(!e)return r;for(let t of Object.keys(e)){let n=r[t],o=e[t];if(o&&(o.hasOwnProperty("_type")||o.hasOwnProperty("_default"))){r.hasOwnProperty(t)||(r[t]=o._default);let e=o._elements;if(n&&rV(e)){if(o._type===tG.Array&&Array.isArray(n)){let o=n.map(t=>rB(e,t));r[t]=o}else if(o._type===tG.Object)for(let t of Object.keys(n))n[t]=rB(e,n[t])}}else if(rU(o)){let e=n??{};rU(e)&&(r[t]=rB(o,e))}}return r};function rV(e){return!!e&&Object.keys(e).filter(e=>!["_default","_validators"].includes(e)).length>0}function rU(e){return"object"==typeof e&&!Array.isArray(e)&&null!==e}let rW=new Set;function rK(e,t){let r=`${e}:::${t}`;rW||(rW=new Set),rW.has(r)||(console.error(t),rW.add(r))}function rz(e){e?rW.forEach(t=>{t.startsWith(e)&&rW.delete(t)}):rW.clear()}function rH(){rh.forEach(e=>e()),rh.length=0,rv.clear(),rC.clear(),rT.clear(),rj.clear(),rg()}let rG={"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:tG.Object,_default:{},_validators:[tq(e=>Object.keys(e).every(e=>/^[a-z]{2,3}(-[A-Z]{2,3})?$/.test(e)),e=>{let t=Object.keys(e).filter(e=>!/^[a-z]{2,3}(-[A-Z]{2,3})?$/.test(e));return`The 'Translation overrides' object should have language codes for keys. Language codes must be in the form of a two-to-three letter language code optionally followed by a hyphen and a two-to-three letter country code. The following keys do not conform: ${t.join(", ")}.`})]}},rq={"Display conditions":{privileges:{_description:"The privilege(s) the user must have to use this extension",_type:tG.Array,_default:[]},expression:{_description:"The expression that determines whether the extension is displayed",_type:tG.String,_default:void 0}},...rG},rY=(e,t)=>tq(r=>e<=r&&r<=t,`must be between ${e} and ${t}`),rZ=e=>{let t=e.concat(["openmrsBase","openmrsSpaBase"]);return tq(e=>{if(!e||"string"!=typeof e)return!1;let r=/\${(.*?)}/g,n=r.exec(e);for(;n;){if(!t.includes(n[1]))return!1;n=r.exec(e)}return!0},"Should be a URL or path. The allowed template parameters are "+t.map(e=>"${"+e+"}").join(", "))},rJ=rZ([]),rX=e=>tq(t=>e.includes(t),`Must be one of the following: '${e.join("', '")}'.`),rQ={inRange:rY,isUrl:rJ,isUrlWithTemplateParameters:rZ,oneOf:rX};var r0=r(8067);let r1=q("breadcrumbs",[]);function r4(e){return r3([e])}function r3(e){let t=[...r2(),...e.map(e=>({matcher:e.matcher instanceof RegExp?e.matcher:"string"==typeof e.matcher?(0,r0.pathToRegexp)(e.matcher).regexp:(0,r0.pathToRegexp)(e.path).regexp,settings:e}))];r1.setState(t,!0)}function r2(){return r1.getState()}function r6(e,t){if(t)return function(e,t){let[r]=e.filter(e=>e.matcher.test(t));return r}(e,t)||function(e,t){let r=t.split("/");for(;r.length>1;){r.pop();let t=r6(e,r.join("/"));if(t)return t}}(e,t)}function r5(e,t){if(e.length>0){let r=r6(e,t);if(r){let t=[r],n=r6(e,r.settings.parent);for(;void 0!==n;)t.push(n),n=r6(e,n.settings.parent);return t.reverse()}}return[]}function r8(e){return r5(r2(),e)}var r9=Object.freeze({__proto__:null,get start(){return ox},get ensureJQuerySupport(){return n8},get setBootstrapMaxTime(){return nU},get setMountMaxTime(){return nW},get setUnmountMaxTime(){return nK},get setUnloadMaxTime(){return nz},get registerApplication(){return ol},get unregisterApplication(){return oc},get getMountedApps(){return oo},get getAppStatus(){return oa},get unloadApplication(){return od},get checkActivityFunctions(){return ou},get getAppNames(){return oi},get pathToActiveWhen(){return oh},get navigateToUrl(){return nX},get patchHistoryApi(){return n2},get triggerAppChange(){return ov},get addErrorHandler(){return nn},get removeErrorHandler(){return no},get mountRootParcel(){return nM},get NOT_LOADED(){return ns},get LOADING_SOURCE_CODE(){return nl},get NOT_BOOTSTRAPPED(){return nu},get BOOTSTRAPPING(){return nc},get NOT_MOUNTED(){return nd},get MOUNTING(){return np},get UPDATING(){return nh},get LOAD_ERROR(){return ny},get MOUNTED(){return nf},get UNLOADING(){return ng},get UNMOUNTING(){return nm},get SKIP_BECAUSE_BROKEN(){return nv}}),r7=("u">typeof globalThis?globalThis:"u">typeof window?window:"u">typeof global?global:"u">typeof self?self:{}).CustomEvent,ne=!function(){try{var e=new r7("cat",{detail:{foo:"bar"}});return"cat"===e.type&&"bar"===e.detail.foo}catch(e){}return!1}()?"u">typeof document&&"function"==typeof document.createEvent?function(e,t){var r=document.createEvent("CustomEvent");return t?r.initCustomEvent(e,t.bubbles,t.cancelable,t.detail):r.initCustomEvent(e,!1,!1,void 0),r}:function(e,t){var r=document.createEventObject();return r.type=e,t?(r.bubbles=!!t.bubbles,r.cancelable=!!t.cancelable,r.detail=t.detail):(r.bubbles=!1,r.cancelable=!1,r.detail=void 0),r}:r7;let nt=[];function nr(e,t,r){let n=na(e,t,r);nt.length?nt.forEach(e=>e(n)):setTimeout(()=>{throw n})}function nn(e){if("function"!=typeof e)throw Error(ni(28,!1));nt.push(e)}function no(e){if("function"!=typeof e)throw Error(ni(29,!1));let t=!1;return nt=nt.filter(r=>{let n=r===e;return t=t||n,!n}),t}function ni(e,t,...r){return`single-spa minified message #${e}: ${t?t+" ":""}See https://single-spa.js.org/error/?code=${e}${r.length?`&arg=${r.join("&arg=")}`:""}`}function na(e,t,r){let n,o=`${nE(t)} '${n_(t)}' died in status ${t.status}: `;if(e instanceof Error){try{e.message=o+e.message}catch(e){}n=e}else{console.warn(ni(30,!1,t.status,n_(t)));try{n=Error(o+JSON.stringify(e))}catch(t){n=e}}return n.appOrParcelName=n_(t),t.status=r,n}let ns="NOT_LOADED",nl="LOADING_SOURCE_CODE",nu="NOT_BOOTSTRAPPED",nc="BOOTSTRAPPING",nd="NOT_MOUNTED",np="MOUNTING",nf="MOUNTED",nh="UPDATING",nm="UNMOUNTING",ng="UNLOADING",ny="LOAD_ERROR",nv="SKIP_BECAUSE_BROKEN";function nb(e){return e.status===nf}function nw(e){try{return e.activeWhen(window.location)}catch(t){return nr(t,e,nv),!1}}function n_(e){return e.name}function nx(e){return!!e.unmountThisParcel}function nE(e){return nx(e)?"parcel":"application"}function nS(){for(let e=arguments.length-1;e>0;e--)for(let t in arguments[e])"__proto__"!==t&&(arguments[e-1][t]=arguments[e][t]);return arguments[0]}function nD(e,t){for(let r=0;r<e.length;r++)if(t(e[r]))return e[r];return null}function nO(e){return e&&("function"==typeof e||Array.isArray(e)&&!nD(e,e=>"function"!=typeof e))}function nk(e,t){let r=e[t]||[];0===(r=Array.isArray(r)?r:[r]).length&&(r=[()=>Promise.resolve()]);let n=nE(e),o=n_(e);return function(e){return r.reduce((r,i,a)=>r.then(()=>{let r=i(e);return nP(r)?r:Promise.reject(ni(15,!1,n,o,t,a))}),Promise.resolve())}}function nP(e){return e&&"function"==typeof e.then&&"function"==typeof e.catch}let nC=[];function nj(e,t){return Promise.resolve().then(()=>e.status!==nu?e:(e.status=nc,e.bootstrap?nH(e,"bootstrap").then(r).catch(r=>{if(t)throw na(r,e,nv);return nr(r,e,nv),e}):Promise.resolve().then(r)));function r(){return e.status=nd,e}}function nT(e,t){return Promise.resolve().then(()=>{if(e.status!==nf)return e;return e.status=nm,Promise.all(Object.keys(e.parcels).map(t=>e.parcels[t].unmountThisParcel())).then(r,n=>r().then(()=>{let r=Error(n.message);if(t)throw na(r,e,nv);nr(r,e,nv)})).then(()=>e);function r(){return nH(e,"unmount").then(()=>{e.status=nd},r=>{if(t)throw na(r,e,nv);nr(r,e,nv)})}})}let nR=!1,nA=!1;function nN(e,t){return Promise.resolve().then(()=>e.status!==nd?e:(nR||(window.dispatchEvent(new ne("single-spa:before-first-mount")),nR=!0),e.status=np,nH(e,"mount").then(()=>(e.status=nf,nA||(window.dispatchEvent(new ne("single-spa:first-mount")),nA=!0),e)).catch(r=>{return e.status=nf,nT(e,!0).then(n,n);function n(){if(t)throw na(r,e,nv);return nr(r,e,nv),e}})))}let n$=0,nI={parcels:{}};function nM(){return nL.apply(nI,arguments)}function nL(e,t){let r,n,o,i=this;if(!e||"object"!=typeof e&&"function"!=typeof e)throw Error(ni(2,!1));if(e.name&&"string"!=typeof e.name)throw Error(ni(3,!1,typeof e.name));let a=n$++,s=e.name||`parcel-${a}`;if("object"!=typeof t)throw Error(ni(4,!1,s,typeof t));if(!t.domElement)throw Error(ni(5,!1,s));let l="function"==typeof e,u=l?e:()=>Promise.resolve(e),c={id:a,parcels:{},status:l?nl:nu,customProps:t,parentName:n_(i),unmountThisParcel:()=>f.then(()=>{if(c.status!==nf)throw Error(ni(6,!1,s,c.status));return nT(c,!0)}).then(e=>(c.parentName&&delete i.parcels[c.id],e)).then(e=>(n(e),e)).catch(e=>{throw c.status=nv,o(e),e})};i.parcels[a]=c;let d=u();if(!d||"function"!=typeof d.then)throw Error(ni(7,!1));let p=(d=d.then(e=>{if(!e)throw Error(ni(8,!1));if(s=e.name||`parcel-${a}`,Object.prototype.hasOwnProperty.call(e,"bootstrap")&&!nO(e.bootstrap))throw Error(ni(9,!1,s));if(!nO(e.mount))throw Error(ni(10,!1,s));if(!nO(e.unmount))throw Error(ni(11,!1,s));if(e.update&&!nO(e.update))throw Error(ni(12,!1,s));let t=nk(e,"bootstrap"),n=nk(e,"mount"),o=nk(e,"unmount");c.status=nu,c.name=s,c.bootstrap=t,c.mount=n,c.unmount=o,c.timeouts=nG(e.timeouts),e.update&&(c.update=nk(e,"update"),r.update=function(e){return c.customProps=e,nF(Promise.resolve().then(()=>{if(c.status!==nf)throw Error(ni(32,!1,n_(c)));return c.status=nh,nH(c,"update").then(()=>(c.status=nf,c)).catch(e=>{throw na(e,c,nv)})}))})})).then(()=>nj(c,!0)),f=p.then(()=>nN(c,!0)),h=new Promise((e,t)=>{n=e,o=t});return r={mount:()=>nF(Promise.resolve().then(()=>{if(c.status!==nd)throw Error(ni(13,!1,s,c.status));return i.parcels[a]=c,nN(c)})),unmount:()=>nF(c.unmountThisParcel()),getStatus:()=>c.status,loadPromise:nF(d),bootstrapPromise:nF(p),mountPromise:nF(f),unmountPromise:nF(h)}}function nF(e){return e.then(()=>null)}function nB(e){let t=n_(e),r="function"==typeof e.customProps?e.customProps(t,window.location):e.customProps;("object"!=typeof r||null===r||Array.isArray(r))&&(r={},console.warn(ni(40,!1),t,r));let n=nS({},r,{name:t,mountParcel:nL.bind(e),singleSpa:r9});return nx(e)&&(n.unmountSelf=e.unmountThisParcel),n}let nV={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 nU(e,t,r){if("number"!=typeof e||e<=0)throw Error(ni(16,!1));nV.bootstrap={millis:e,dieOnTimeout:t,warningMillis:r||1e3}}function nW(e,t,r){if("number"!=typeof e||e<=0)throw Error(ni(17,!1));nV.mount={millis:e,dieOnTimeout:t,warningMillis:r||1e3}}function nK(e,t,r){if("number"!=typeof e||e<=0)throw Error(ni(18,!1));nV.unmount={millis:e,dieOnTimeout:t,warningMillis:r||1e3}}function nz(e,t,r){if("number"!=typeof e||e<=0)throw Error(ni(19,!1));nV.unload={millis:e,dieOnTimeout:t,warningMillis:r||1e3}}function nH(e,t){let r=e.timeouts[t],n=r.warningMillis,o=nE(e);return new Promise((i,a)=>{let s=!1,l=!1;e[t](nB(e)).then(e=>{s=!0,i(e)}).catch(e=>{s=!0,a(e)}),setTimeout(()=>c(1),n),setTimeout(()=>c(!0),r.millis);let u=ni(31,!1,t,o,n_(e),r.millis);function c(e){s||(!0===e?(l=!0,r.dieOnTimeout?a(Error(u)):console.error(u)):!l&&(console.warn(u),e*n+n<r.millis&&setTimeout(()=>c(e+1),n)))}})}function nG(e){let t={};for(let r in nV)t[r]=nS({},nV[r],e&&e[r]||{});return t}function nq(e){return Promise.resolve().then(()=>{let t,r;return e.loadPromise?e.loadPromise:e.status!==ns&&e.status!==ny?e:(e.status=nl,e.loadPromise=Promise.resolve().then(()=>{let n=e.loadApp(nB(e));if(!nP(n))throw r=!0,Error(ni(33,!1,n_(e)));return n.then(r=>{let n;e.loadErrorTime=null,"object"!=typeof(t=r)&&(n=34),Object.prototype.hasOwnProperty.call(t,"bootstrap")&&!nO(t.bootstrap)&&(n=35),nO(t.mount)||(n=36),nO(t.unmount)||(n=37);let o=nE(t);if(n){let r;try{r=JSON.stringify(t)}catch(e){}return console.error(ni(n,!1,o,n_(e),r),t),nr(void 0,e,nv),e}return t.devtools&&t.devtools.overlays&&(e.devtools.overlays=nS({},e.devtools.overlays,t.devtools.overlays)),e.status=nu,e.bootstrap=nk(t,"bootstrap"),e.mount=nk(t,"mount"),e.unmount=nk(t,"unmount"),e.unload=nk(t,"unload"),e.timeouts=nG(t.timeouts),delete e.loadPromise,e})}).catch(t=>{let n;return delete e.loadPromise,r?n=nv:(n=ny,e.loadErrorTime=(new Date).getTime()),nr(t,e,n),e}))})}let nY="u">typeof window,nZ={hashchange:[],popstate:[]},nJ=["hashchange","popstate"];function nX(e){let t;if("string"==typeof e)t=e;else if(this&&this.href)t=this.href;else{if(!(e&&e.currentTarget&&e.currentTarget.href&&e.preventDefault))throw Error(ni(14,!1));t=e.currentTarget.href,e.preventDefault()}let r=n6(window.location.href),n=n6(t);0===t.indexOf("#")?window.location.hash=n.hash:r.host!==n.host&&n.host?window.location.href=t:n.pathname===r.pathname&&n.search===r.search?window.location.hash=n.hash:window.history.pushState(null,null,t)}function nQ(e){if(e){let t=e[0].type;nJ.indexOf(t)>=0&&nZ[t].forEach(t=>{try{t.apply(this,e)}catch(e){setTimeout(()=>{throw e})}})}}function n0(){ob([],arguments)}function n1(e,t){return function(){let r=window.location.href,n=e.apply(this,arguments),i=window.location.href;return o&&r===i||window.dispatchEvent(function(e,t){let r;try{r=new PopStateEvent("popstate",{state:e})}catch(t){(r=document.createEvent("PopStateEvent")).initPopStateEvent("popstate",!1,!1,e)}return r.singleSpa=!0,r.singleSpaTrigger=t,r}(window.history.state,t)),n}}let n4=null,n3=!1;function n2(e){if(n3)throw Error(ni(43,!1));o=!e||!e.hasOwnProperty("urlRerouteOnly")||e.urlRerouteOnly,n3=!0,n4=window.history.replaceState,window.addEventListener("hashchange",n0),window.addEventListener("popstate",n0);let t=window.addEventListener,r=window.removeEventListener;window.addEventListener=function(e,r){if(!("function"==typeof r&&nJ.indexOf(e)>=0)||nD(nZ[e],e=>e===r))return t.apply(this,arguments);nZ[e].push(r)},window.removeEventListener=function(e,t){return"function"==typeof t&&nJ.indexOf(e)>=0&&(nZ[e]=nZ[e].filter(e=>e!==t)),r.apply(this,arguments)},window.history.pushState=n1(window.history.pushState,"pushState"),window.history.replaceState=n1(n4,"replaceState")}function n6(e){let t=document.createElement("a");return t.href=e,t}nY&&(window.singleSpaNavigate?console.warn(ni(41,!1)):window.singleSpaNavigate=nX);let n5=!1;function n8(e=window.jQuery){if(e||window.$&&window.$.fn&&window.$.fn.jquery&&(e=window.$),e&&!n5){let t=e.fn.on,r=e.fn.off;e.fn.on=function(e,r){return n9.call(this,t,window.addEventListener,e,r,arguments)},e.fn.off=function(e,t){return n9.call(this,r,window.removeEventListener,e,t,arguments)},n5=!0}}function n9(e,t,r,n,o){return"string"!=typeof r?e.apply(this,o):(r.split(/\s+/).forEach(e=>{nJ.indexOf(e)>=0&&(t(e,n),r=r.replace(e,""))}),""===r.trim()?this:e.apply(this,o))}let n7={};function oe(e){return Promise.resolve().then(()=>{let t=n7[n_(e)];if(!t)return e;if(e.status===ns)return ot(e,t),e;if(e.status===ng)return t.promise.then(()=>e);if(e.status!==nd&&e.status!==ny)return e;let r=e.status===ny?Promise.resolve():nH(e,"unload");return e.status=ng,r.then(()=>(ot(e,t),e)).catch(r=>(delete n7[n_(e)],delete e.bootstrap,delete e.mount,delete e.unmount,delete e.unload,nr(r,e,nv),t.reject(r),e))})}function ot(e,t){delete n7[n_(e)],delete e.bootstrap,delete e.mount,delete e.unmount,delete e.unload,e.status=ns,t.resolve()}function or(e,t,r,n){n7[n_(e)]={app:e,resolve:r,reject:n},Object.defineProperty(n7[n_(e)],"promise",{get:t})}let on=[];function oo(){return on.filter(nb).map(n_)}function oi(){return on.map(n_)}function oa(e){let t=nD(on,t=>n_(t)===e);return t?t.status:null}let os=!1;function ol(e,t,r,n){var o,i;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(ni(39,!1));let t=["name","app","activeWhen","customProps"],r=Object.keys(e).reduce((e,r)=>t.indexOf(r)>=0?e:e.concat(r),[]);if(0!==r.length)throw Error(ni(38,!1,t.join(", "),r.join(", ")));if("string"!=typeof e.name||0===e.name.length||"object"!=typeof e.app&&"function"!=typeof e.app)throw Error(ni(20,!1));let n=e=>"string"==typeof e||"function"==typeof e;if(!(n(e.activeWhen)||Array.isArray(e.activeWhen)&&e.activeWhen.every(n)))throw Error(ni(24,!1));if(!of(e.customProps))throw Error(ni(22,!1))}(e),a.name=e.name,a.loadApp=e.app,a.activeWhen=e.activeWhen,a.customProps=e.customProps):(function(e,t,r,n){if("string"!=typeof e||0===e.length)throw Error(ni(20,!1));if(!t)throw Error(ni(23,!1));if("function"!=typeof r)throw Error(ni(24,!1));if(!of(n))throw Error(ni(22,!1))}(e,t,r,n),a.name=e,a.loadApp=t,a.activeWhen=r,a.customProps=n),a.loadApp="function"!=typeof(o=a.loadApp)?()=>Promise.resolve(o):o,a.customProps=a.customProps||{},s=(s=Array.isArray(i=a.activeWhen)?i:[i]).map(e=>"function"==typeof e?e:oh(e)),a.activeWhen=e=>s.some(t=>t(e)),a);if(o_||os||(os=!0,setTimeout(()=>{o_||console.warn(ni(1,!1))},5e3)),-1!==oi().indexOf(l.name))throw Error(ni(21,!1,l.name));on.push(nS({loadErrorTime:null,status:ns,parcels:{},devtools:{overlays:{options:{},selectors:[]}}},l)),nY&&(n8(),ob())}function ou(e=window.location){return on.filter(t=>t.activeWhen(e)).map(n_)}function oc(e){if(0===on.filter(t=>n_(t)===e).length)throw Error(ni(25,!1,e));return(nY?od(e,{waitForUnmount:!1}):Promise.resolve()).then(()=>{let t=on.map(n_).indexOf(e);on.splice(t,1)})}function od(e,t={waitForUnmount:!1}){if("string"!=typeof e)throw Error(ni(26,!1));let r=nD(on,t=>n_(t)===e);if(!r)throw Error(ni(27,!1,e));let n=n7[n_(r)];if(t&&t.waitForUnmount){if(n)return n.promise;{let e=new Promise((t,n)=>{or(r,()=>e,t,n)});return e}}{let e;return n?(e=n.promise,op(r,n.resolve,n.reject)):e=new Promise((t,n)=>{or(r,()=>e,t,n),op(r,t,n)}),e}}function op(e,t,r){Promise.resolve().then(()=>{if(nD(ou(),t=>t===n_(e)))return ov()}).then(()=>nT(e).then(oe).then(()=>{t(),setTimeout(()=>{ob()})})).catch(r)}function of(e){return!e||"function"==typeof e||"object"==typeof e&&null!==e&&!Array.isArray(e)}function oh(e,t){let r=function(e,t){let r=0,n=!1,o="^";"/"!==e[0]&&(e="/"+e);for(let t=0;t<e.length;t++){let r=e[t],o=n&&"/"===r;(!n&&":"===r||o)&&i(t)}return i(e.length),RegExp(o,"i");function i(i){let a=e.slice(r,i).replace(/[|\\{}()[\]^$+*?.]/g,"\\$&");if(o+=n?"[^/]+/?":a,i===e.length)if(n)t&&(o+="$");else{let e=t?"":".*";o="/"===o.charAt(o.length-1)?`${o}${e}$`:`${o}(/${e})?(#.*)?$`}n=!n,r=i}}(e,t);return e=>{let t=e.origin;t||(t=`${e.protocol}//${e.host}`);let n=e.href.replace(t,"").replace(e.search,"").split("?")[0];return r.test(n)}}let om=!1,og=[],oy=nY&&window.location.href;function ov(){return ob()}function ob(e=[],t,r=!1){let n,o,i,a,s;if(om)return new Promise((e,r)=>{og.push({resolve:e,reject:r,eventArguments:t})});let{appsToUnload:l,appsToUnmount:u,appsToLoad:c,appsToMount:d}=(n=[],o=[],i=[],a=[],s=(new Date).getTime(),on.forEach(e=>{let t=e.status!==nv&&nw(e);switch(e.status){case ny:t&&s-e.loadErrorTime>=200&&i.push(e);break;case ns:case nl:t&&i.push(e);break;case nu:case nd:!t&&n7[n_(e)]?n.push(e):t&&a.push(e);break;case nf:t||o.push(e)}}),{appsToUnload:n,appsToUnmount:o,appsToLoad:i,appsToMount:a}),p,f=[],h=oy,m=oy=window.location.href;return o_?(om=!0,p=l.concat(c,u,d),Promise.resolve().then(()=>(w(0===p.length?"before-no-app-change":"before-app-change",b(!0)),w("before-routing-event",b(!0,{cancelNavigation:g})),Promise.all(f).then(r=>{if(r.some(e=>e))return n4.call(window.history,history.state,"",h.substring(location.origin.length)),oy=location.href,om=!1,ob(e,t,!0);let n=l.map(oe),o=Promise.all(u.map(nT).map(e=>e.then(oe)).concat(n));o.then(()=>{w("before-mount-routing-event",b(!0))},e=>{throw e});let i=c.map(e=>nq(e).then(e=>ow(e,o))),a=d.filter(e=>0>c.indexOf(e)).map(e=>ow(e,o));return o.catch(e=>{throw v(),e}).then(()=>(v(),Promise.all(i.concat(a)).catch(t=>{throw e.forEach(e=>e.reject(t)),t}).then(y).then(()=>{},e=>{throw e})))})))):(p=c,Promise.resolve().then(()=>Promise.all(c.map(nq)).then(v).then(()=>[]).catch(e=>{throw v(),e}).finally(()=>{})));function g(e=!0){let t="function"==typeof(null==e?void 0:e.then)?e:Promise.resolve(e);f.push(t.catch(e=>(console.warn(Error(ni(42,!1))),console.warn(e),!1)))}function y(){let t=oo();e.forEach(e=>e.resolve(t));try{w(0===p.length?"no-app-change":"app-change",b()),w("routing-event",b())}catch(e){setTimeout(()=>{throw e})}if(om=!1,og.length>0){let e=og;og=[],ob(e)}return t}function v(){r||(e.forEach(e=>{nQ(e.eventArguments)}),nQ(t))}function b(e=!1,r){let n={},o={[nf]:[],[nd]:[],[ns]:[],[nv]:[]};e?(c.concat(d).forEach((e,t)=>{a(e,nf)}),l.forEach(e=>{a(e,ns)}),u.forEach(e=>{a(e,nd)})):p.forEach(e=>{a(e)});let i={detail:{newAppStatuses:n,appsByNewStatus:o,totalAppChanges:p.length,originalEvent:null==t?void 0:t[0],oldUrl:h,newUrl:m}};return r&&nS(i.detail,r),i;function a(e,t){let r=n_(e);t=t||oa(r),n[r]=t,(o[t]=o[t]||[]).push(r)}}function w(e,t){r||window.dispatchEvent(new ne(`single-spa:${e}`,t))}}function ow(e,t){return nw(e)?nj(e).then(e=>t.then(()=>nw(e)?nN(e):e)):t.then(()=>e)}let o_=!1;function ox(e){o_=!0,nY&&(n2(e),ob())}function oE(e,t){let r=window.getOpenmrsSpaBase().replace(/\/$/,"");return oS(e,{openmrsBase:window.openmrsBase,openmrsSpaBase:r,...t}).replace(/^\/\//,"/")}function oS(e,t){return Object.keys(t).reduce((e,r)=>e.split("${"+r+"}").join(t[r]),e)}function oD({to:e,templateParams:t}){let r=window.getOpenmrsSpaBase().replace(/\/$/,""),n=oE(e,t).replace(window.location.origin,"");n.startsWith(r)?nX(n):window.location.assign(n)}nY&&window.__SINGLE_SPA_DEVTOOLS__&&(window.__SINGLE_SPA_DEVTOOLS__.exposedMethods={getRawAppData:function(){return[...on]},reroute:ob,NOT_LOADED:ns,toLoadPromise:nq,toBootstrapPromise:nj,unregisterApplication:oc,getProfilerData:function(){return nC}});let oO="openmrs:history";function ok(e){let t=JSON.parse(sessionStorage.getItem(oO)??"[]")||[];t.push(e),t.length>50&&(t=t.slice(-50)),sessionStorage.setItem(oO,JSON.stringify(t))}function oP(){0===JSON.parse(sessionStorage.getItem(oO)??"[]").length&&document.referrer&&ok(document.referrer),window.addEventListener("single-spa:routing-event",e=>{let t=oC();e.detail.originalEvent?.singleSpaTrigger=="replaceState"?(t[t.length-1]=window.location.href,sessionStorage.setItem(oO,JSON.stringify(t))):!e.detail.originalEvent?.singleSpa&&t.includes(window.location.href)?oj({toUrl:window.location.href}):t[t.length-1]!==window.location.href&&ok(window.location.href)})}function oC(){return JSON.parse(sessionStorage.getItem(oO)??"[]")}function oj({toUrl:e}){let t=oC(),r=t.lastIndexOf(e);if(-1!=r){let e=t.slice(0,r+1);oD({to:t[r]}),sessionStorage.setItem(oO,JSON.stringify(e))}else throw Error(`URL ${e} not found in history; cannot go back to it.`)}function oT(){sessionStorage.removeItem(oO)}let oR="${openmrsSpaBase}/login",oA={redirectAuthFailure:{enabled:{_type:tG.Boolean,_default:!0,_description:"Whether to redirect logged-out users to `redirectAuthFailure.url`"},url:{_type:tG.String,_default:oR,_validators:[rQ.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:tG.Array,_default:[401],_elements:{_type:tG.Number,_validators:[rQ.inRange(100,600)]},_description:"The HTTP error codes for which users will be redirected"},resolvePromise:{_type:tG.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:tG.Boolean,_default:!0,_description:"Whether openmrsFetch should support redirects returned from the backend"}};function oN(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}let o$="/ws/rest/v1",oI="/ws/fhir2/R4",oM=`${o$}/session`;function oL(e){return e&&e.startsWith("http")?e:("/"!==e[0]&&(e="/"+e),window.openmrsBase+e)}function oF(e,t={}){if("string"!=typeof e)throw Error("The first argument to @openmrs/api's openmrsFetch function must be a url string");if("object"!=typeof t)throw Error("The second argument to @openmrs/api's openmrsFetch function must be a plain object.");if(!window.openmrsBase)throw Error("@openmrs/api is running in a browser that doesn't have window.openmrsBase, which is provided by openmrs-module-spa's HTML file.");let r=oL(e);if(t.headers||(t.headers={}),eg(t.body)&&(t.body=JSON.stringify(t.body)),void 0===t.headers.Accept&&(t.headers.Accept="application/json"),null===t.headers.Accept&&delete t.headers.Accept,e.startsWith(o$)&&void 0===t.headers["Disable-WWW-Authenticate"]&&(t.headers["Disable-WWW-Authenticate"]="true"),e.startsWith(oI)){let e=new URL(r,window.location.toString());e.searchParams.has("_summary")||(e.searchParams.set("_summary","data"),r=e.toString())}let n=Error();return window.fetch(r,t).then(async e=>{let{redirectAuthFailure:t,followRedirects:o}=await rO("@openmrs/esm-api");if(e.ok){let t=e.headers.get("location");return(o&&t&&(r===oL(oM)||204===e.status)&&oD({to:t}),204===e.status)?(e.data=null,e):e.clone().text().then(t=>{try{t&&(e.data=JSON.parse(t))}catch(e){}return e})}return r===oL(oM)&&403===e.status||t.enabled&&t.errors.includes(e.status)?(oT(),oD({to:t.url||e.headers.get("location")||oR}),t.resolvePromise?Promise.resolve():new Promise(()=>{})):e.clone().text().then(t=>{let o=t;try{o=JSON.parse(t)}catch(e){}throw new oV(r,e,o,n)},t=>{throw new oV(r,e,null,n)})})}function oB(e,t={}){if("object"!=typeof t)throw Error("The second argument to openmrsObservableFetch must be either omitted or an object");let r=new AbortController;return t.signal=r.signal,new el.Observable(n=>{let o=!1;return oF(e,t).then(e=>{o=!0,n.next(e),n.complete()},e=>{o=!0,n.error(e)}),()=>{o||r.abort()}})}class oV extends Error{constructor(e,t,r,n){super(),oN(this,"response",void 0),oN(this,"responseBody",void 0),this.message=`Server responded with ${t.status} (${t.statusText}) for url ${e}. Check err.responseBody or network tab in dev tools for more info`,n.message=this.message,this.responseBody=r,this.response=t,this.stack=`Stacktrace for outgoing request:
13
13
  ${n.stack}
14
14
  Stacktrace for incoming response:
15
- ${this.stack}`}}let oU=q("session",{loaded:!1,session:null}),oW=0;function oK(e={includeAuthStatus:!0}){return(oW<Date.now()-6e4||!oU.getState().loaded)&&oG(),new el.Observable(t=>{let r=r=>{r.loaded&&(e.includeAuthStatus?t.next(r.session):t.next(r.session?.user))};return r(oU.getState()),oU.subscribe(r)})}function oz(){return(oW<Date.now()-6e4||!oU.getState().loaded)&&oG(),oU}function oH(e){let t=e.locale??e.user?.userProperties?.defaultLocale;t&&t.includes("_")&&(t=t.replaceAll("_","-")),function(e){if(void 0===e||"string"!=typeof e)return!1;try{new Intl.Locale(e)}catch(e){return!1}return!0}(t)&&t!==document.documentElement.getAttribute("lang")&&document.documentElement.setAttribute("lang",t)}function oG(e,t){oW=Date.now();let r={};return e&&t&&(r.Authorization=`Basic ${window.btoa(`${e}:${t}`)}`),o0(oF(oM,{headers:r}))}function oq(){oU.setState({loaded:!0,session:{authenticated:!1,sessionId:""}})}function oY(e,t){var r,n;if(void 0===t)return!e;if(!e)return!0;return r=e,n=t,("string"==typeof r?!Q(n.privileges.find(e=>r===e.display)):Array.isArray(r)?r.every(e=>!Q(n.privileges.find(t=>e===t.display))):(Q(r)||console.error(`Could not understand privileges "${r}"`),!0))||!Q(t.roles.find(e=>"System Developer"===e.display))}function oZ(){let e,t;return new Promise(r=>{let n=n=>{n.loaded&&n.session.user&&(e=n.session.user,r(n.session.user),t&&t())};n(oU.getState()),e||(t=oU.subscribe(n))})}function oJ(){return new Promise((e,t)=>{oK().subscribe(t=>{e(t.sessionLocation)},t).unsubscribe()})}async function oX(e,t){return o0(oF(oM,{method:"POST",body:{sessionLocation:e},headers:{"Content-Type":"application/json"},signal:t.signal}))}async function oQ(e,t,r){return r||(r=new AbortController),await oF(`${o$}/user/${e}`,{method:"POST",body:{userProperties:t},headers:{"Content-Type":"application/json"},signal:r.signal}),oG()}function o0(e){return new Promise((t,r)=>{e.then(e=>{let n;"object"==typeof e?.data?(n={loaded:!0,session:e.data},oU.setState(n),t(n)):(n={loaded:!1,session:null},oU.setState(n),r(n))}).catch(e=>{$(`Failed to fetch new session information: ${e}`);let t={loaded:!1,session:null};oU.setState(t),r(t)})})}function o1(){return"development"===window.spaEnv||"true"===localStorage.getItem("openmrs:devtools")}oU.subscribe(e=>{e.loaded&&e.session&&oH(e.session)});let o4={"webservices.rest":"2.24.0",fhir2:"1.0.0-SNAPSHOT"};function o3(){rb("@openmrs/esm-api",oA),oG()}let o2={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"},o6=e=>"string"==typeof e,o5=()=>{let e,t,r=new Promise((r,n)=>{e=r,t=n});return r.resolve=e,r.reject=t,r},o8=e=>null==e?"":""+e,o9=/###/g,o7=e=>e&&e.indexOf("###")>-1?e.replace(o9,"."):e,ie=e=>!e||o6(e),it=(e,t,r)=>{let n=o6(t)?t.split("."):t,o=0;for(;o<n.length-1;){if(ie(e))return{};let t=o7(n[o]);!e[t]&&r&&(e[t]=new r),e=Object.prototype.hasOwnProperty.call(e,t)?e[t]:{},++o}return ie(e)?{}:{obj:e,k:o7(n[o])}},ir=(e,t,r)=>{let{obj:n,k:o}=it(e,t,Object);if(void 0!==n||1===t.length){n[o]=r;return}let i=t[t.length-1],a=t.slice(0,t.length-1),s=it(e,a,Object);for(;void 0===s.obj&&a.length;)i=`${a[a.length-1]}.${i}`,s=it(e,a=a.slice(0,a.length-1),Object),s?.obj&&void 0!==s.obj[`${s.k}.${i}`]&&(s.obj=void 0);s.obj[`${s.k}.${i}`]=r},io=(e,t)=>{let{obj:r,k:n}=it(e,t);if(r&&Object.prototype.hasOwnProperty.call(r,n))return r[n]},ii=(e,t,r)=>{for(let n in t)"__proto__"!==n&&"constructor"!==n&&(n in e?o6(e[n])||e[n]instanceof String||o6(t[n])||t[n]instanceof String?r&&(e[n]=t[n]):ii(e[n],t[n],r):e[n]=t[n]);return e};var ia={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};let is=e=>o6(e)?e.replace(/[&<>"'\/]/g,e=>ia[e]):e,il=[" ",",","?","!",";"],iu=new class{constructor(e){this.capacity=e,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(e){let t=this.regExpMap.get(e);if(void 0!==t)return t;let r=new RegExp(e);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(e,r),this.regExpQueue.push(e),r}}(20),ic=(e,t,r=".")=>{if(!e)return;if(e[t]){if(!Object.prototype.hasOwnProperty.call(e,t))return;return e[t]}let n=t.split(r),o=e;for(let e=0;e<n.length;){let t;if(!o||"object"!=typeof o)return;let i="";for(let a=e;a<n.length;++a)if(a!==e&&(i+=r),i+=n[a],void 0!==(t=o[i])){if(["string","number","boolean"].indexOf(typeof t)>-1&&a<n.length-1)continue;e+=a-e+1;break}o=t}return o},id=e=>e?.replace("_","-"),ip={type:"logger",log(e){this.output("log",e)},warn(e){this.output("warn",e)},error(e){this.output("error",e)},output(e,t){console?.[e]?.apply?.(console,t)}};class ih{constructor(e,t={}){this.init(e,t)}init(e,t={}){this.prefix=t.prefix||"i18next:",this.logger=e||ip,this.options=t,this.debug=t.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,t,r,n){return n&&!this.debug?null:(o6(e[0])&&(e[0]=`${r}${this.prefix} ${e[0]}`),this.logger[t](e))}create(e){return new ih(this.logger,{...{prefix:`${this.prefix}:${e}:`},...this.options})}clone(e){return(e=e||this.options).prefix=e.prefix||this.prefix,new ih(this.logger,e)}}var im=new ih;class ig{constructor(){this.observers={}}on(e,t){return e.split(" ").forEach(e=>{this.observers[e]||(this.observers[e]=new Map);let r=this.observers[e].get(t)||0;this.observers[e].set(t,r+1)}),this}off(e,t){if(this.observers[e]){if(!t)return void delete this.observers[e];this.observers[e].delete(t)}}emit(e,...t){this.observers[e]&&Array.from(this.observers[e].entries()).forEach(([e,r])=>{for(let n=0;n<r;n++)e(...t)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(([r,n])=>{for(let o=0;o<n;o++)r.apply(r,[e,...t])})}}class iy extends ig{constructor(e,t={ns:["translation"],defaultNS:"translation"}){super(),this.data=e||{},this.options=t,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 t=this.options.ns.indexOf(e);t>-1&&this.options.ns.splice(t,1)}getResource(e,t,r,n={}){let o,i=void 0!==n.keySeparator?n.keySeparator:this.options.keySeparator,a=void 0!==n.ignoreJSONStructure?n.ignoreJSONStructure:this.options.ignoreJSONStructure;e.indexOf(".")>-1?o=e.split("."):(o=[e,t],r&&(Array.isArray(r)?o.push(...r):o6(r)&&i?o.push(...r.split(i)):o.push(r)));let s=io(this.data,o);return(!s&&!t&&!r&&e.indexOf(".")>-1&&(e=o[0],t=o[1],r=o.slice(2).join(".")),!s&&a&&o6(r))?ic(this.data?.[e]?.[t],r,i):s}addResource(e,t,r,n,o={silent:!1}){let i=void 0!==o.keySeparator?o.keySeparator:this.options.keySeparator,a=[e,t];r&&(a=a.concat(i?r.split(i):r)),e.indexOf(".")>-1&&(a=e.split("."),n=t,t=a[1]),this.addNamespaces(t),ir(this.data,a,n),o.silent||this.emit("added",e,t,r,n)}addResources(e,t,r,n={silent:!1}){for(let n in r)(o6(r[n])||Array.isArray(r[n]))&&this.addResource(e,t,n,r[n],{silent:!0});n.silent||this.emit("added",e,t,r)}addResourceBundle(e,t,r,n,o,i={silent:!1,skipCopy:!1}){let a=[e,t];e.indexOf(".")>-1&&(a=e.split("."),n=r,r=t,t=a[1]),this.addNamespaces(t);let s=io(this.data,a)||{};i.skipCopy||(r=JSON.parse(JSON.stringify(r))),n?ii(s,r,o):s={...s,...r},ir(this.data,a,s),i.silent||this.emit("added",e,t,r)}removeResourceBundle(e,t){this.hasResourceBundle(e,t)&&delete this.data[e][t],this.removeNamespaces(t),this.emit("removed",e,t)}hasResourceBundle(e,t){return void 0!==this.getResource(e,t)}getResourceBundle(e,t){return t||(t=this.options.defaultNS),this.getResource(e,t)}getDataByLanguage(e){return this.data[e]}hasLanguageSomeTranslations(e){let t=this.getDataByLanguage(e);return!!(t&&Object.keys(t)||[]).find(e=>t[e]&&Object.keys(t[e]).length>0)}toJSON(){return this.data}}var iv={processors:{},addPostProcessor(e){this.processors[e.name]=e},handle(e,t,r,n,o){return e.forEach(e=>{t=this.processors[e]?.process(t,r,n,o)??t}),t}};let ib=Symbol("i18next/PATH_KEY");function iw(e,t){let r,n,o,{[ib]:i}=e((n=[],(o=Object.create(null)).get=(e,t)=>(r?.revoke?.(),t===ib)?n:(n.push(t),(r=Proxy.revocable(e,o)).proxy),Proxy.revocable(Object.create(null),o).proxy));return i.join(t?.keySeparator??".")}let i_={},ix=e=>!o6(e)&&"boolean"!=typeof e&&"number"!=typeof e;class iE extends ig{constructor(e,t={}){super(),((e,t,r)=>{e.forEach(e=>{t[e]&&(r[e]=t[e])})})(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=t,void 0===this.options.keySeparator&&(this.options.keySeparator="."),this.logger=im.create("translator")}changeLanguage(e){e&&(this.language=e)}exists(e,t={interpolation:{}}){let r={...t};if(null==e)return!1;let n=this.resolve(e,r);if(n?.res===void 0)return!1;let o=ix(n.res);return!1!==r.returnObjects||!o}extractFromKey(e,t){let r=void 0!==t.nsSeparator?t.nsSeparator:this.options.nsSeparator;void 0===r&&(r=":");let n=void 0!==t.keySeparator?t.keySeparator:this.options.keySeparator,o=t.ns||this.options.defaultNS||[],i=r&&e.indexOf(r)>-1,a=!this.options.userDefinedKeySeparator&&!t.keySeparator&&!this.options.userDefinedNsSeparator&&!t.nsSeparator&&!((e,t,r)=>{t=t||"",r=r||"";let n=il.filter(e=>0>t.indexOf(e)&&0>r.indexOf(e));if(0===n.length)return!0;let o=iu.getRegExp(`(${n.map(e=>"?"===e?"\\?":e).join("|")})`),i=!o.test(e);if(!i){let t=e.indexOf(r);t>0&&!o.test(e.substring(0,t))&&(i=!0)}return i})(e,r,n);if(i&&!a){let t=e.match(this.interpolator.nestingRegexp);if(t&&t.length>0)return{key:e,namespaces:o6(o)?[o]:o};let i=e.split(r);(r!==n||r===n&&this.options.ns.indexOf(i[0])>-1)&&(o=i.shift()),e=i.join(n)}return{key:e,namespaces:o6(o)?[o]:o}}translate(e,t,r){let n="object"==typeof t?{...t}:t;if("object"!=typeof n&&this.options.overloadTranslationOptionHandler&&(n=this.options.overloadTranslationOptionHandler(arguments)),"object"==typeof n&&(n={...n}),n||(n={}),null==e)return"";"function"==typeof e&&(e=iw(e,{...this.options,...n})),Array.isArray(e)||(e=[String(e)]);let o=void 0!==n.returnDetails?n.returnDetails:this.options.returnDetails,i=void 0!==n.keySeparator?n.keySeparator:this.options.keySeparator,{key:a,namespaces:s}=this.extractFromKey(e[e.length-1],n),l=s[s.length-1],u=void 0!==n.nsSeparator?n.nsSeparator:this.options.nsSeparator;void 0===u&&(u=":");let c=n.lng||this.language,d=n.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(c?.toLowerCase()==="cimode")return d?o?{res:`${l}${u}${a}`,usedKey:a,exactUsedKey:a,usedLng:c,usedNS:l,usedParams:this.getUsedParamsDetails(n)}:`${l}${u}${a}`:o?{res:a,usedKey:a,exactUsedKey:a,usedLng:c,usedNS:l,usedParams:this.getUsedParamsDetails(n)}:a;let p=this.resolve(e,n),f=p?.res,h=p?.usedKey||a,m=p?.exactUsedKey||a,g=void 0!==n.joinArrays?n.joinArrays:this.options.joinArrays,y=!this.i18nFormat||this.i18nFormat.handleAsObject,v=void 0!==n.count&&!o6(n.count),b=iE.hasDefaultValue(n),w=v?this.pluralResolver.getSuffix(c,n.count,n):"",x=n.ordinal&&v?this.pluralResolver.getSuffix(c,n.count,{ordinal:!1}):"",E=v&&!n.ordinal&&0===n.count,S=E&&n[`defaultValue${this.options.pluralSeparator}zero`]||n[`defaultValue${w}`]||n[`defaultValue${x}`]||n.defaultValue,D=f;y&&!f&&b&&(D=S);let O=ix(D),k=Object.prototype.toString.apply(D);if(y&&D&&O&&0>["[object Number]","[object Function]","[object RegExp]"].indexOf(k)&&!(o6(g)&&Array.isArray(D))){if(!n.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,D,{...n,ns:s}):`key '${a} (${this.language})' returned an object instead of string.`;return o?(p.res=e,p.usedParams=this.getUsedParamsDetails(n),p):e}if(i){let e=Array.isArray(D),t=e?[]:{},r=e?m:h;for(let e in D)if(Object.prototype.hasOwnProperty.call(D,e)){let o=`${r}${i}${e}`;b&&!f?t[e]=this.translate(o,{...n,defaultValue:ix(S)?S[e]:void 0,...{joinArrays:!1,ns:s}}):t[e]=this.translate(o,{...n,joinArrays:!1,ns:s}),t[e]===o&&(t[e]=D[e])}f=t}}else if(y&&o6(g)&&Array.isArray(f))(f=f.join(g))&&(f=this.extendTranslation(f,e,n,r));else{let t=!1,o=!1;!this.isValidLookup(f)&&b&&(t=!0,f=S),this.isValidLookup(f)||(o=!0,f=a);let s=(n.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&o?void 0:f,d=b&&S!==f&&this.options.updateMissing;if(o||t||d){if(this.logger.log(d?"updateKey":"missingKey",c,l,a,d?S:f),i){let e=this.resolve(a,{...n,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=[],t=this.languageUtils.getFallbackCodes(this.options.fallbackLng,n.lng||this.language);if("fallback"===this.options.saveMissingTo&&t&&t[0])for(let r=0;r<t.length;r++)e.push(t[r]);else"all"===this.options.saveMissingTo?e=this.languageUtils.toResolveHierarchy(n.lng||this.language):e.push(n.lng||this.language);let r=(e,t,r)=>{let o=b&&r!==f?r:s;this.options.missingKeyHandler?this.options.missingKeyHandler(e,l,t,o,d,n):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(e,l,t,o,d,n),this.emit("missingKey",e,l,t,f)};this.options.saveMissing&&(this.options.saveMissingPlurals&&v?e.forEach(e=>{let t=this.pluralResolver.getSuffixes(e,n);E&&n[`defaultValue${this.options.pluralSeparator}zero`]&&0>t.indexOf(`${this.options.pluralSeparator}zero`)&&t.push(`${this.options.pluralSeparator}zero`),t.forEach(t=>{r([e],a+t,n[`defaultValue${t}`]||S)})}):r(e,a,S))}f=this.extendTranslation(f,e,n,p,r),o&&f===a&&this.options.appendNamespaceToMissingKey&&(f=`${l}${u}${a}`),(o||t)&&this.options.parseMissingKeyHandler&&(f=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${l}${u}${a}`:a,t?f:void 0,n))}return o?(p.res=f,p.usedParams=this.getUsedParamsDetails(n),p):f}extendTranslation(e,t,r,n,o){if(this.i18nFormat?.parse)e=this.i18nFormat.parse(e,{...this.options.interpolation.defaultVariables,...r},r.lng||this.language||n.usedLng,n.usedNS,n.usedKey,{resolved:n});else if(!r.skipInterpolation){let i;r.interpolation&&this.interpolator.init({...r,...{interpolation:{...this.options.interpolation,...r.interpolation}}});let a=o6(e)&&(r?.interpolation?.skipOnVariables!==void 0?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);if(a){let t=e.match(this.interpolator.nestingRegexp);i=t&&t.length}let s=r.replace&&!o6(r.replace)?r.replace:r;if(this.options.interpolation.defaultVariables&&(s={...this.options.interpolation.defaultVariables,...s}),e=this.interpolator.interpolate(e,s,r.lng||this.language||n.usedLng,r),a){let t=e.match(this.interpolator.nestingRegexp);i<(t&&t.length)&&(r.nest=!1)}!r.lng&&n&&n.res&&(r.lng=this.language||n.usedLng),!1!==r.nest&&(e=this.interpolator.nest(e,(...e)=>o?.[0]!==e[0]||r.context?this.translate(...e,t):(this.logger.warn(`It seems you are nesting recursively key: ${e[0]} in key: ${t[0]}`),null),r)),r.interpolation&&this.interpolator.reset()}let i=r.postProcess||this.options.postProcess,a=o6(i)?[i]:i;return null!=e&&a?.length&&!1!==r.applyPostProcessor&&(e=iv.handle(a,e,t,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...n,usedParams:this.getUsedParamsDetails(r)},...r}:r,this)),e}resolve(e,t={}){let r,n,o,i,a;return o6(e)&&(e=[e]),e.forEach(e=>{if(this.isValidLookup(r))return;let s=this.extractFromKey(e,t),l=s.key;n=l;let u=s.namespaces;this.options.fallbackNS&&(u=u.concat(this.options.fallbackNS));let c=void 0!==t.count&&!o6(t.count),d=c&&!t.ordinal&&0===t.count,p=void 0!==t.context&&(o6(t.context)||"number"==typeof t.context)&&""!==t.context,f=t.lngs?t.lngs:this.languageUtils.toResolveHierarchy(t.lng||this.language,t.fallbackLng);u.forEach(e=>{this.isValidLookup(r)||(a=e,!i_[`${f[0]}-${e}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(a)&&(i_[`${f[0]}-${e}`]=!0,this.logger.warn(`key "${n}" 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(n=>{let a;if(this.isValidLookup(r))return;i=n;let s=[l];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(s,l,n,e,t);else{let e;c&&(e=this.pluralResolver.getSuffix(n,t.count,t));let r=`${this.options.pluralSeparator}zero`,o=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(c&&(t.ordinal&&0===e.indexOf(o)&&s.push(l+e.replace(o,this.options.pluralSeparator)),s.push(l+e),d&&s.push(l+r)),p){let n=`${l}${this.options.contextSeparator||"_"}${t.context}`;s.push(n),c&&(t.ordinal&&0===e.indexOf(o)&&s.push(n+e.replace(o,this.options.pluralSeparator)),s.push(n+e),d&&s.push(n+r))}}for(;a=s.pop();)this.isValidLookup(r)||(o=a,r=this.getResource(n,e,a,t))}))})}),{res:r,usedKey:n,exactUsedKey:o,usedLng:i,usedNS:a}}isValidLookup(e){return void 0!==e&&!(!this.options.returnNull&&null===e)&&!(!this.options.returnEmptyString&&""===e)}getResource(e,t,r,n={}){return this.i18nFormat?.getResource?this.i18nFormat.getResource(e,t,r,n):this.resourceStore.getResource(e,t,r,n)}getUsedParamsDetails(e={}){let t=e.replace&&!o6(e.replace),r=t?e.replace:e;if(t&&void 0!==e.count&&(r.count=e.count),this.options.interpolation.defaultVariables&&(r={...this.options.interpolation.defaultVariables,...r}),!t)for(let e of(r={...r},["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"]))delete r[e];return r}static hasDefaultValue(e){let t="defaultValue";for(let r in e)if(Object.prototype.hasOwnProperty.call(e,r)&&t===r.substring(0,t.length)&&void 0!==e[r])return!0;return!1}}class iS{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=im.create("languageUtils")}getScriptPartFromCode(e){if(!(e=id(e))||0>e.indexOf("-"))return null;let t=e.split("-");return 2===t.length||(t.pop(),"x"===t[t.length-1].toLowerCase())?null:this.formatLanguageCode(t.join("-"))}getLanguagePartFromCode(e){if(!(e=id(e))||0>e.indexOf("-"))return e;let t=e.split("-");return this.formatLanguageCode(t[0])}formatLanguageCode(e){if(o6(e)&&e.indexOf("-")>-1){let t;try{t=Intl.getCanonicalLocales(e)[0]}catch(e){}return(t&&this.options.lowerCaseLng&&(t=t.toLowerCase()),t)?t: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 t;return e?(e.forEach(e=>{if(t)return;let r=this.formatLanguageCode(e);(!this.options.supportedLngs||this.isSupportedCode(r))&&(t=r)}),!t&&this.options.supportedLngs&&e.forEach(e=>{if(t)return;let r=this.getScriptPartFromCode(e);if(this.isSupportedCode(r))return t=r;let n=this.getLanguagePartFromCode(e);if(this.isSupportedCode(n))return t=n;t=this.options.supportedLngs.find(e=>{if(e===n||!(0>e.indexOf("-")&&0>n.indexOf("-"))&&(e.indexOf("-")>0&&0>n.indexOf("-")&&e.substring(0,e.indexOf("-"))===n||0===e.indexOf(n)&&n.length>1))return e})}),t||(t=this.getFallbackCodes(this.options.fallbackLng)[0]),t):null}getFallbackCodes(e,t){if(!e)return[];if("function"==typeof e&&(e=e(t)),o6(e)&&(e=[e]),Array.isArray(e))return e;if(!t)return e.default||[];let r=e[t];return r||(r=e[this.getScriptPartFromCode(t)]),r||(r=e[this.formatLanguageCode(t)]),r||(r=e[this.getLanguagePartFromCode(t)]),r||(r=e.default),r||[]}toResolveHierarchy(e,t){let r=this.getFallbackCodes((!1===t?[]:t)||this.options.fallbackLng||[],e),n=[],o=e=>{e&&(this.isSupportedCode(e)?n.push(e):this.logger.warn(`rejecting language code not found in supportedLngs: ${e}`))};return o6(e)&&(e.indexOf("-")>-1||e.indexOf("_")>-1)?("languageOnly"!==this.options.load&&o(this.formatLanguageCode(e)),"languageOnly"!==this.options.load&&"currentOnly"!==this.options.load&&o(this.getScriptPartFromCode(e)),"currentOnly"!==this.options.load&&o(this.getLanguagePartFromCode(e))):o6(e)&&o(this.formatLanguageCode(e)),r.forEach(e=>{0>n.indexOf(e)&&o(this.formatLanguageCode(e))}),n}}let iD={zero:0,one:1,two:2,few:3,many:4,other:5},iO={select:e=>1===e?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class ik{constructor(e,t={}){this.languageUtils=e,this.options=t,this.logger=im.create("pluralResolver"),this.pluralRulesCache={}}addRule(e,t){this.rules[e]=t}clearCache(){this.pluralRulesCache={}}getRule(e,t={}){let r,n=id("dev"===e?"en":e),o=t.ordinal?"ordinal":"cardinal",i=JSON.stringify({cleanedCode:n,type:o});if(i in this.pluralRulesCache)return this.pluralRulesCache[i];try{r=new Intl.PluralRules(n,{type:o})}catch(o){if(!Intl)return this.logger.error("No Intl support, please use an Intl polyfill!"),iO;if(!e.match(/-|_/))return iO;let n=this.languageUtils.getLanguagePartFromCode(e);r=this.getRule(n,t)}return this.pluralRulesCache[i]=r,r}needsPlural(e,t={}){let r=this.getRule(e,t);return r||(r=this.getRule("dev",t)),r?.resolvedOptions().pluralCategories.length>1}getPluralFormsOfKey(e,t,r={}){return this.getSuffixes(e,r).map(e=>`${t}${e}`)}getSuffixes(e,t={}){let r=this.getRule(e,t);return(r||(r=this.getRule("dev",t)),r)?r.resolvedOptions().pluralCategories.sort((e,t)=>iD[e]-iD[t]).map(e=>`${this.options.prepend}${t.ordinal?`ordinal${this.options.prepend}`:""}${e}`):[]}getSuffix(e,t,r={}){let n=this.getRule(e,r);return n?`${this.options.prepend}${r.ordinal?`ordinal${this.options.prepend}`:""}${n.select(t)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix("dev",t,r))}}let iP=(e,t,r,n=".",o=!0)=>{let i,a=void 0!==(i=io(e,r))?i:io(t,r);return!a&&o&&o6(r)&&void 0===(a=ic(e,r,n))&&(a=ic(t,r,n)),a};class iC{constructor(e={}){this.logger=im.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:t,escapeValue:r,useRawValueToEscape:n,prefix:o,prefixEscaped:i,suffix:a,suffixEscaped:s,formatSeparator:l,unescapeSuffix:u,unescapePrefix:c,nestingPrefix:d,nestingPrefixEscaped:p,nestingSuffix:f,nestingSuffixEscaped:h,nestingOptionsSeparator:m,maxReplaces:g,alwaysFormat:y}=e.interpolation;this.escape=void 0!==t?t:is,this.escapeValue=void 0===r||r,this.useRawValueToEscape=void 0!==n&&n,this.prefix=o?o.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"):i||"{{",this.suffix=a?a.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"):s||"}}",this.formatSeparator=l||",",this.unescapePrefix=u?"":c||"-",this.unescapeSuffix=this.unescapePrefix?"":u||"",this.nestingPrefix=d?d.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"):p||"$t(".replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),this.nestingSuffix=f?f.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"):h||")".replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),this.nestingOptionsSeparator=m||",",this.maxReplaces=g||1e3,this.alwaysFormat=void 0!==y&&y,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){let e=(e,t)=>e?.source===t?(e.lastIndex=0,e):RegExp(t,"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,t,r,n){let o,i,a,s=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},l=e=>{if(0>e.indexOf(this.formatSeparator)){let o=iP(t,s,e,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(o,void 0,r,{...n,...t,interpolationkey:e}):o}let o=e.split(this.formatSeparator),i=o.shift().trim(),a=o.join(this.formatSeparator).trim();return this.format(iP(t,s,i,this.options.keySeparator,this.options.ignoreJSONStructure),a,r,{...n,...t,interpolationkey:i})};this.resetRegExp();let u=n?.missingInterpolationHandler||this.options.missingInterpolationHandler,c=n?.interpolation?.skipOnVariables!==void 0?n.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(t=>{for(a=0;o=t.regex.exec(e);){let r=o[1].trim();if(void 0===(i=l(r)))if("function"==typeof u){let t=u(e,o,n);i=o6(t)?t:""}else if(n&&Object.prototype.hasOwnProperty.call(n,r))i="";else if(c){i=o[0];continue}else this.logger.warn(`missed to pass in variable ${r} for interpolating ${e}`),i="";else o6(i)||this.useRawValueToEscape||(i=o8(i));let s=t.safeValue(i);if(e=e.replace(o[0],s),c?(t.regex.lastIndex+=i.length,t.regex.lastIndex-=o[0].length):t.regex.lastIndex=0,++a>=this.maxReplaces)break}}),e}nest(e,t,r={}){let n,o,i,a=(e,t)=>{let r=this.nestingOptionsSeparator;if(0>e.indexOf(r))return e;let n=e.split(RegExp(`${r}[ ]*{`)),o=`{${n[1]}`;e=n[0];let a=(o=this.interpolate(o,i)).match(/'/g),s=o.match(/"/g);((a?.length??0)%2!=0||s)&&s.length%2==0||(o=o.replace(/'/g,'"'));try{i=JSON.parse(o),t&&(i={...t,...i})}catch(t){return this.logger.warn(`failed parsing options string in nesting for key ${e}`,t),`${e}${r}${o}`}return i.defaultValue&&i.defaultValue.indexOf(this.prefix)>-1&&delete i.defaultValue,e};for(;n=this.nestingRegexp.exec(e);){let s=[];(i=(i={...r}).replace&&!o6(i.replace)?i.replace:i).applyPostProcessor=!1,delete i.defaultValue;let l=/{.*}/.test(n[1])?n[1].lastIndexOf("}")+1:n[1].indexOf(this.formatSeparator);if(-1!==l&&(s=n[1].slice(l).split(this.formatSeparator).map(e=>e.trim()).filter(Boolean),n[1]=n[1].slice(0,l)),(o=t(a.call(this,n[1].trim(),i),i))&&n[0]===e&&!o6(o))return o;o6(o)||(o=o8(o)),o||(this.logger.warn(`missed to resolve ${n[1]} for nesting ${e}`),o=""),s.length&&(o=s.reduce((e,t)=>this.format(e,t,r.lng,{...r,interpolationkey:n[1].trim()}),o.trim())),e=e.replace(n[0],o),this.regexp.lastIndex=0}return e}}let ij=e=>{let t={};return(r,n,o)=>{let i=o;o&&o.interpolationkey&&o.formatParams&&o.formatParams[o.interpolationkey]&&o[o.interpolationkey]&&(i={...i,[o.interpolationkey]:void 0});let a=n+JSON.stringify(i),s=t[a];return s||(s=e(id(n),o),t[a]=s),s(r)}},iT=e=>(t,r,n)=>e(id(r),n)(t);class iR{constructor(e={}){this.logger=im.create("formatter"),this.options=e,this.init(e)}init(e,t={interpolation:{}}){this.formatSeparator=t.interpolation.formatSeparator||",";let r=t.cacheInBuiltFormats?ij:iT;this.formats={number:r((e,t)=>{let r=new Intl.NumberFormat(e,{...t});return e=>r.format(e)}),currency:r((e,t)=>{let r=new Intl.NumberFormat(e,{...t,style:"currency"});return e=>r.format(e)}),datetime:r((e,t)=>{let r=new Intl.DateTimeFormat(e,{...t});return e=>r.format(e)}),relativetime:r((e,t)=>{let r=new Intl.RelativeTimeFormat(e,{...t});return e=>r.format(e,t.range||"day")}),list:r((e,t)=>{let r=new Intl.ListFormat(e,{...t});return e=>r.format(e)})}}add(e,t){this.formats[e.toLowerCase().trim()]=t}addCached(e,t){this.formats[e.toLowerCase().trim()]=ij(t)}format(e,t,r,n={}){let o=t.split(this.formatSeparator);if(o.length>1&&o[0].indexOf("(")>1&&0>o[0].indexOf(")")&&o.find(e=>e.indexOf(")")>-1)){let e=o.findIndex(e=>e.indexOf(")")>-1);o[0]=[o[0],...o.splice(1,e)].join(this.formatSeparator)}return o.reduce((e,t)=>{let{formatName:o,formatOptions:i}=(e=>{let t=e.toLowerCase().trim(),r={};if(e.indexOf("(")>-1){let n=e.split("(");t=n[0].toLowerCase().trim();let o=n[1].substring(0,n[1].length-1);"currency"===t&&0>o.indexOf(":")?r.currency||(r.currency=o.trim()):"relativetime"===t&&0>o.indexOf(":")?r.range||(r.range=o.trim()):o.split(";").forEach(e=>{if(e){let[t,...n]=e.split(":"),o=n.join(":").trim().replace(/^'+|'+$/g,""),i=t.trim();r[i]||(r[i]=o),"false"===o&&(r[i]=!1),"true"===o&&(r[i]=!0),isNaN(o)||(r[i]=parseInt(o,10))}})}return{formatName:t,formatOptions:r}})(t);if(this.formats[o]){let t=e;try{let a=n?.formatParams?.[n.interpolationkey]||{},s=a.locale||a.lng||n.locale||n.lng||r;t=this.formats[o](e,s,{...i,...n,...a})}catch(e){this.logger.warn(e)}return t}return this.logger.warn(`there was no format function for ${o}`),e},e)}}class iA extends ig{constructor(e,t,r,n={}){super(),this.backend=e,this.store=t,this.services=r,this.languageUtils=r.languageUtils,this.options=n,this.logger=im.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=n.maxParallelReads||10,this.readingCalls=0,this.maxRetries=n.maxRetries>=0?n.maxRetries:5,this.retryTimeout=n.retryTimeout>=1?n.retryTimeout:350,this.state={},this.queue=[],this.backend?.init?.(r,n.backend,n)}queueLoad(e,t,r,n){let o={},i={},a={},s={};return e.forEach(e=>{let n=!0;t.forEach(t=>{let a=`${e}|${t}`;!r.reload&&this.store.hasResourceBundle(e,t)?this.state[a]=2:this.state[a]<0||(1===this.state[a]?void 0===i[a]&&(i[a]=!0):(this.state[a]=1,n=!1,void 0===i[a]&&(i[a]=!0),void 0===o[a]&&(o[a]=!0),void 0===s[t]&&(s[t]=!0)))}),n||(a[e]=!0)}),(Object.keys(o).length||Object.keys(i).length)&&this.queue.push({pending:i,pendingCount:Object.keys(i).length,loaded:{},errors:[],callback:n}),{toLoad:Object.keys(o),pending:Object.keys(i),toLoadLanguages:Object.keys(a),toLoadNamespaces:Object.keys(s)}}loaded(e,t,r){let n=e.split("|"),o=n[0],i=n[1];t&&this.emit("failedLoading",o,i,t),!t&&r&&this.store.addResourceBundle(o,i,r,void 0,void 0,{skipCopy:!0}),this.state[e]=t?-1:2,t&&r&&(this.state[e]=0);let a={};this.queue.forEach(r=>{((e,t,r,n)=>{let{obj:o,k:i}=it(e,t,Object);o[i]=o[i]||[],o[i].push(r)})(r.loaded,[o],i),void 0!==r.pending[e]&&(delete r.pending[e],r.pendingCount--),t&&r.errors.push(t),0!==r.pendingCount||r.done||(Object.keys(r.loaded).forEach(e=>{a[e]||(a[e]={});let t=r.loaded[e];t.length&&t.forEach(t=>{void 0===a[e][t]&&(a[e][t]=!0)})}),r.done=!0,r.errors.length?r.callback(r.errors):r.callback())}),this.emit("loaded",a),this.queue=this.queue.filter(e=>!e.done)}read(e,t,r,n=0,o=this.retryTimeout,i){if(!e.length)return i(null,{});if(this.readingCalls>=this.maxParallelReads)return void this.waitingReads.push({lng:e,ns:t,fcName:r,tried:n,wait:o,callback:i});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&&n<this.maxRetries?setTimeout(()=>{this.read.call(this,e,t,r,n+1,2*o,i)},o):i(a,s)},s=this.backend[r].bind(this.backend);if(2===s.length){try{let r=s(e,t);r&&"function"==typeof r.then?r.then(e=>a(null,e)).catch(a):a(null,r)}catch(e){a(e)}return}return s(e,t,a)}prepareLoading(e,t,r={},n){if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),n&&n();o6(e)&&(e=this.languageUtils.toResolveHierarchy(e)),o6(t)&&(t=[t]);let o=this.queueLoad(e,t,r,n);if(!o.toLoad.length)return o.pending.length||n(),null;o.toLoad.forEach(e=>{this.loadOne(e)})}load(e,t,r){this.prepareLoading(e,t,{},r)}reload(e,t,r){this.prepareLoading(e,t,{reload:!0},r)}loadOne(e,t=""){let r=e.split("|"),n=r[0],o=r[1];this.read(n,o,"read",void 0,void 0,(r,i)=>{r&&this.logger.warn(`${t}loading namespace ${o} for language ${n} failed`,r),!r&&i&&this.logger.log(`${t}loaded namespace ${o} for language ${n}`,i),this.loaded(e,r,i)})}saveMissing(e,t,r,n,o,i={},a=()=>{}){if(this.services?.utils?.hasLoadedNamespace&&!this.services?.utils?.hasLoadedNamespace(t))return void this.logger.warn(`did not save key "${r}" as the namespace "${t}" 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!=r&&""!==r){if(this.backend?.create){let s={...i,isUpdate:o},l=this.backend.create.bind(this.backend);if(l.length<6)try{let o;(o=5===l.length?l(e,t,r,n,s):l(e,t,r,n))&&"function"==typeof o.then?o.then(e=>a(null,e)).catch(a):a(null,o)}catch(e){a(e)}else l(e,t,r,n,a,s)}e&&e[0]&&this.store.addResource(e[0],t,r,n)}}}let iN=()=>({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 t={};if("object"==typeof e[1]&&(t=e[1]),o6(e[1])&&(t.defaultValue=e[1]),o6(e[2])&&(t.tDescription=e[2]),"object"==typeof e[2]||"object"==typeof e[3]){let r=e[3]||e[2];Object.keys(r).forEach(e=>{t[e]=r[e]})}return t},interpolation:{escapeValue:!0,format:e=>e,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0},cacheInBuiltFormats:!0}),i$=e=>(o6(e.ns)&&(e.ns=[e.ns]),o6(e.fallbackLng)&&(e.fallbackLng=[e.fallbackLng]),o6(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),iI=()=>{};class iM extends ig{constructor(e={},t){if(super(),this.options=i$(e),this.services={},this.logger=im,this.modules={external:[]},(e=>{Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach(t=>{"function"==typeof e[t]&&(e[t]=e[t].bind(e))})})(this),t&&!this.isInitialized&&!e.isClone){if(!this.options.initAsync)return this.init(e,t),this;setTimeout(()=>{this.init(e,t)},0)}}init(e={},t){this.isInitializing=!0,"function"==typeof e&&(t=e,e={}),null==e.defaultNS&&e.ns&&(o6(e.ns)?e.defaultNS=e.ns:0>e.ns.indexOf("translation")&&(e.defaultNS=e.ns[0]));let r=iN();this.options={...r,...this.options,...i$(e)},this.options.interpolation={...r.interpolation,...this.options.interpolation},void 0!==e.keySeparator&&(this.options.userDefinedKeySeparator=e.keySeparator),void 0!==e.nsSeparator&&(this.options.userDefinedNsSeparator=e.nsSeparator);let n=e=>e?"function"==typeof e?new e:e:null;if(!this.options.isClone){let e;this.modules.logger?im.init(n(this.modules.logger),this.options):im.init(null,this.options),e=this.modules.formatter?this.modules.formatter:iR;let t=new iS(this.options);this.store=new iy(this.options.resources,this.options);let o=this.services;o.logger=im,o.resourceStore=this.store,o.languageUtils=t,o.pluralResolver=new ik(t,{prepend:this.options.pluralSeparator,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),this.options.interpolation.format&&this.options.interpolation.format!==r.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===r.interpolation.format)&&(o.formatter=n(e),o.formatter.init&&o.formatter.init(o,this.options),this.options.interpolation.format=o.formatter.format.bind(o.formatter)),o.interpolator=new iC(this.options),o.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},o.backendConnector=new iA(n(this.modules.backend),o.resourceStore,o,this.options),o.backendConnector.on("*",(e,...t)=>{this.emit(e,...t)}),this.modules.languageDetector&&(o.languageDetector=n(this.modules.languageDetector),o.languageDetector.init&&o.languageDetector.init(o,this.options.detection,this.options)),this.modules.i18nFormat&&(o.i18nFormat=n(this.modules.i18nFormat),o.i18nFormat.init&&o.i18nFormat.init(this)),this.translator=new iE(this.services,this.options),this.translator.on("*",(e,...t)=>{this.emit(e,...t)}),this.modules.external.forEach(e=>{e.init&&e.init(this)})}if(this.format=this.options.interpolation.format,t||(t=iI),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]=(...t)=>this.store[e](...t)}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(e=>{this[e]=(...t)=>(this.store[e](...t),this)});let o=o5(),i=()=>{let e=(e,r)=>{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),o.resolve(r),t(e,r)};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?i():setTimeout(i,0),o}loadResources(e,t=iI){let r=t,n=o6(e)?e:this.language;if("function"==typeof e&&(r=e),!this.options.resources||this.options.partialBundledLanguages){if(n?.toLowerCase()==="cimode"&&(!this.options.preload||0===this.options.preload.length))return r();let e=[],t=t=>{t&&"cimode"!==t&&this.services.languageUtils.toResolveHierarchy(t).forEach(t=>{"cimode"!==t&&0>e.indexOf(t)&&e.push(t)})};n?t(n):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(e=>t(e)),this.options.preload?.forEach?.(e=>t(e)),this.services.backendConnector.load(e,this.options.ns,e=>{e||this.resolvedLanguage||!this.language||this.setResolvedLanguage(this.language),r(e)})}else r(null)}reloadResources(e,t,r){let n=o5();return"function"==typeof e&&(r=e,e=void 0),"function"==typeof t&&(r=t,t=void 0),e||(e=this.languages),t||(t=this.options.ns),r||(r=iI),this.services.backendConnector.reload(e,t,e=>{n.resolve(),r(e)}),n}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&&iv.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 t=this.languages[e];if(!(["cimode","dev"].indexOf(t)>-1)&&this.store.hasLanguageSomeTranslations(t)){this.resolvedLanguage=t;break}}!this.resolvedLanguage&&0>this.languages.indexOf(e)&&this.store.hasLanguageSomeTranslations(e)&&(this.resolvedLanguage=e,this.languages.unshift(e))}}changeLanguage(e,t){this.isLanguageChangingTo=e;let r=o5();this.emit("languageChanging",e);let n=e=>{this.language=e,this.languages=this.services.languageUtils.toResolveHierarchy(e),this.resolvedLanguage=void 0,this.setResolvedLanguage(e)},o=(o,i)=>{i?this.isLanguageChangingTo===e&&(n(i),this.translator.changeLanguage(i),this.isLanguageChangingTo=void 0,this.emit("languageChanged",i),this.logger.log("languageChanged",i)):this.isLanguageChangingTo=void 0,r.resolve((...e)=>this.t(...e)),t&&t(o,(...e)=>this.t(...e))},i=t=>{e||t||!this.services.languageDetector||(t=[]);let r=o6(t)?t:t&&t[0],i=this.store.hasLanguageSomeTranslations(r)?r:this.services.languageUtils.getBestMatchFromCodes(o6(t)?[t]:t);i&&(this.language||n(i),this.translator.language||this.translator.changeLanguage(i),this.services.languageDetector?.cacheUserLanguage?.(i)),this.loadResources(i,e=>{o(e,i)})};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(i):this.services.languageDetector.detect(i):i(e):i(this.services.languageDetector.detect()),r}getFixedT(e,t,r){let n=(e,t,...o)=>{let i,a;(i="object"!=typeof t?this.options.overloadTranslationOptionHandler([e,t].concat(o)):{...t}).lng=i.lng||n.lng,i.lngs=i.lngs||n.lngs,i.ns=i.ns||n.ns,""!==i.keyPrefix&&(i.keyPrefix=i.keyPrefix||r||n.keyPrefix);let s=this.options.keySeparator||".";return i.keyPrefix&&Array.isArray(e)?a=e.map(e=>("function"==typeof e&&(e=iw(e,{...this.options,...t})),`${i.keyPrefix}${s}${e}`)):("function"==typeof e&&(e=iw(e,{...this.options,...t})),a=i.keyPrefix?`${i.keyPrefix}${s}${e}`:e),this.t(a,i)};return o6(e)?n.lng=e:n.lngs=e,n.ns=t,n.keyPrefix=r,n}t(...e){return this.translator?.translate(...e)}exists(...e){return this.translator?.exists(...e)}setDefaultNamespace(e){this.options.defaultNS=e}hasLoadedNamespace(e,t={}){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 r=t.lng||this.resolvedLanguage||this.languages[0],n=!!this.options&&this.options.fallbackLng,o=this.languages[this.languages.length-1];if("cimode"===r.toLowerCase())return!0;let i=(e,t)=>{let r=this.services.backendConnector.state[`${e}|${t}`];return -1===r||0===r||2===r};if(t.precheck){let e=t.precheck(this,i);if(void 0!==e)return e}return!!(this.hasResourceBundle(r,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||i(r,e)&&(!n||i(o,e)))}loadNamespaces(e,t){let r=o5();return this.options.ns?(o6(e)&&(e=[e]),e.forEach(e=>{0>this.options.ns.indexOf(e)&&this.options.ns.push(e)}),this.loadResources(e=>{r.resolve(),t&&t(e)}),r):(t&&t(),Promise.resolve())}loadLanguages(e,t){let r=o5();o6(e)&&(e=[e]);let n=this.options.preload||[],o=e.filter(e=>0>n.indexOf(e)&&this.services.languageUtils.isSupportedCode(e));return o.length?(this.options.preload=n.concat(o),this.loadResources(e=>{r.resolve(),t&&t(e)}),r):(t&&t(),Promise.resolve())}dir(e){if(e||(e=this.resolvedLanguage||(this.languages?.length>0?this.languages[0]:this.language)),!e)return"rtl";try{let t=new Intl.Locale(e);if(t&&t.getTextInfo){let e=t.getTextInfo();if(e&&e.direction)return e.direction}}catch(e){}let t=this.services?.languageUtils||new iS(iN());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(t.getLanguagePartFromCode(e))>-1||e.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(e={},t){return new iM(e,t)}cloneInstance(e={},t=iI){let r=e.forkResourceStore;r&&delete e.forkResourceStore;let n={...this.options,...e,isClone:!0},o=new iM(n);return(void 0!==e.debug||void 0!==e.prefix)&&(o.logger=o.logger.clone(e)),["store","services","language"].forEach(e=>{o[e]=this[e]}),o.services={...this.services},o.services.utils={hasLoadedNamespace:o.hasLoadedNamespace.bind(o)},r&&(o.store=new iy(Object.keys(this.store.data).reduce((e,t)=>(e[t]={...this.store.data[t]},e[t]=Object.keys(e[t]).reduce((r,n)=>(r[n]={...e[t][n]},r),e[t]),e),{}),n),o.services.resourceStore=o.store),o.translator=new iE(o.services,n),o.translator.on("*",(e,...t)=>{o.emit(e,...t)}),o.init(n,t),o.translator.options=n,o.translator.backendConnector.services.utils={hasLoadedNamespace:o.hasLoadedNamespace.bind(o)},o}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}let iL=iM.createInstance();iL.createInstance=iM.createInstance,iL.createInstance,iL.dir,iL.init,iL.loadResources,iL.reloadResources,iL.use,iL.changeLanguage,iL.getFixedT,iL.t,iL.exists,iL.setDefaultNamespace,iL.hasLoadedNamespace,iL.loadNamespaces,iL.loadLanguages;let iF=iL.default||iL;function iB(e,t,r,n){return iF.t(t,{ns:e,defaultValue:r,...n})}function iV(e,t,r){return o2[e]?iB("core",e,t??o2[e],r):(console.error(`O3 Core Translations does not provide key '${e}'. The key itself is being rendered as text.`),e)}iF.on("initialized",function(){window.i18next.loadNamespaces(["core"])});let iU="import-map-override:",iW="import-map-overrides-disabled",iK="import-map-overrides:change",iz=!1,iH=null,iG=null;async function iq(){return iG??(iG=iY().then(({map:e,complete:t})=>(t||(iG=null),e))),iG}async function iY(){let e=document.querySelectorAll('script[type="systemjs-importmap"]'),t=[],r=!0;for(let n=0;n<e.length;n++){let o=e[n];try{if(o.src){let e=await fetch(o.src);if(!e.ok)throw Error(`Request for ${o.src} returned ${e.status} ${e.statusText}`);t.push(await e.json())}else o.textContent&&t.push(JSON.parse(o.textContent))}catch(e){r=!1,console.warn(`[import-maps] Failed to parse import map from script tag at index ${n}`,e)}}return{map:iZ(t),complete:r}}function iZ(e){let t={imports:{}};for(let r of e)r?.imports&&Object.assign(t.imports,r.imports);return t}function iJ(){let e={};try{let t=i4();for(let r=0;r<localStorage.length;r++){let n=localStorage.key(r);if(n?.startsWith(iU)){let r=n.slice(iU.length);if(!t.includes(r)){let t=localStorage.getItem(n);t&&(e[r]=t)}}}}catch(e){console.warn("[import-maps] Failed to read import-map overrides from localStorage",e)}return{imports:e}}async function iX(){let e=await iq();return iz?iZ([e,iH??iJ()]):e}async function iQ(){return iq()}async function i0(){return iz?iZ([await iq(),iJ()]):iq()}function i1(e){if(!iz)return{imports:{}};if(e){let e={};for(let t=0;t<localStorage.length;t++){let r=localStorage.key(t);if(r?.startsWith(iU)){let t=localStorage.getItem(r);t&&(e[r.slice(iU.length)]=t)}}return{imports:e}}return iJ()}function i4(){if(!iz)return[];try{let e=localStorage.getItem(iW);if(e){let t=JSON.parse(e);if(Array.isArray(t))return t}}catch{}return[]}function i3(e){return!!iz&&i4().includes(e)}function i2(e,t){if(!iz)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{localStorage.setItem(iU+e,t),window.dispatchEvent(new CustomEvent(iK))}catch(e){console.warn("[import-maps] Failed to write import-map override to localStorage",e)}}function i6(e){if(!iz)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{localStorage.removeItem(iU+e);let t=i4().filter(t=>t!==e);t.length>0?localStorage.setItem(iW,JSON.stringify(t)):localStorage.removeItem(iW),window.dispatchEvent(new CustomEvent(iK))}catch(e){console.warn("[import-maps] Failed to update import-map overrides in localStorage",e)}}function i5(){if(!iz)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{let e=[];for(let t=0;t<localStorage.length;t++){let r=localStorage.key(t);r?.startsWith(iU)&&e.push(r)}e.forEach(e=>localStorage.removeItem(e)),localStorage.removeItem(iW),window.dispatchEvent(new CustomEvent(iK))}catch(e){console.warn("[import-maps] Failed to clear import-map overrides from localStorage",e)}}function i8(e){if(!iz)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{let t=i4().filter(t=>t!==e);t.length>0?localStorage.setItem(iW,JSON.stringify(t)):localStorage.removeItem(iW),window.dispatchEvent(new CustomEvent(iK))}catch(e){console.warn("[import-maps] Failed to update import-map overrides in localStorage",e)}}let i9=!1;function i7(){!i9&&(i9=!0,(iz="development"===window.spaEnv)&&(iH=iJ()))}function ae(e){return e.replace(/[\/\-@]/g,"_")}async function at(e,t="./start",n){var o;let i,a=!n?.maxLoadingTime||n.maxLoadingTime<=0?6e5:n.maxLoadingTime;await Promise.race([ar(e,n?.importMap),new Promise((t,r)=>{i=setTimeout(()=>{var t;r(Error(`Could not resolve requested script, ${e}, within ${(t=a)<1e3?`${t} milliseconds`:t<6e4?`${Math.floor(t/1e3)} seconds`:t<36e5?`${Math.floor(t/6e4)} minutes`:t<864e5?`${Math.floor(t/36e5)} hours`:`${Math.floor(t/864e5)} days`}.`))},a)})]),i&&clearTimeout(i);let s=ae(e),l=window[s];if(!("object"==typeof(o=l)&&null!==o&&"init"in o&&"function"==typeof o.init&&"get"in o&&"function"==typeof o.get)){let e=`The global variable ${s} does not refer to a federated module`;throw console.error(e),Error(e)}l.init(r.S.default);let u=(await l.get(t))();if("object"!=typeof u||null===u){let t=`Container for ${e} did not return an ESM module as expected`;throw console.error(t),Error(t)}return u}async function ar(e,t){if("string"!=typeof e||0===e.trim().length){let e="Attempted to call importDynamic() without supplying a package to load";throw console.error(e),Error(e)}let r=ae(e);if(!window[r]){let r=t??await an();if(!r.imports.hasOwnProperty(e)){let t=`Could not find the package ${e} defined in the current importmap`;throw console.error(t),Error(t)}let n=r.imports[e];n.startsWith("./")&&(n=window.spaBase+n.substring(1));let o=e in i1().imports;try{return await function(e){var t;let r=(t=window)[ao]??(t[ao]=new Map),n=r.get(e);if(n)return n;if(document.head.querySelector(`script[src="${e}"]`))return console.warn(`Script at ${e} already loaded. Not loading it again.`),Promise.resolve();let o=document.createElement("script");o.src=e,o.type="text/javascript",o.async=!0;let i=new Promise((t,n)=>{let i=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(i),o.removeEventListener("load",s),o.removeEventListener("error",l)}function s(){a(),t()}function l(t){a(),r.delete(e),o.remove();let i=`Failed to load script from ${e}`;console.error(i,t),n(t.message??i)}o.addEventListener("load",s),o.addEventListener("error",l),document.head.appendChild(o)});return r.set(e,i),i}(n)}catch(e){return o&&j({kind:"error",title:iV("scriptLoadingFailed","Error: Script failed to load"),description:iV("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:n}),actionButtonLabel:iV("resetOverrides","Reset overrides"),onActionButtonClick(){i5(),window.location.reload()}}),Promise.reject(e)}}return Promise.resolve()}async function an(){return iX()}let ao=Symbol.for("__openmrs_script_loading");function ai(e){return!!e&&"object"==typeof e&&!(Object.hasOwn(e,"pages")&&(!e.pages||!Array.isArray(e.pages))||Object.hasOwn(e,"extensions")&&(!e.extensions||!Array.isArray(e.extensions))||Object.hasOwn(e,"workspaces")&&(!e.workspaces||!Array.isArray(e.workspaces))||Object.hasOwn(e,"modals")&&(!e.modals||!Array.isArray(e.modals)))}function aa(e){return!!e&&"object"==typeof e&&"routes"in e&&!!e.routes&&"object"==typeof e.routes&&Object.entries(e.routes).every(([e,t])=>"string"==typeof e&&ai(t))}let as="openmrs-routes:",al="openmrs-routes:change",au=!1,ac=null,ad=null;async function ap(){return ad??(ad=af().then(({map:e,complete:t})=>(t||(ad=null),e))),ad}async function af(){let e=document.querySelectorAll("script[type='openmrs-routes']"),t=[],r=!0;for(let n=0;n<e.length;n++){let o=e[n];try{let e;if(o.src){let t=await fetch(o.src);if(!t.ok)throw Error(`Request for ${o.src} returned ${t.status} ${t.statusText}`);e=await t.json()}else o.textContent&&(e=JSON.parse(o.textContent));e&&aa(e)&&t.push(e)}catch(e){r=!1,console.warn(`[route-maps] Failed to parse routes from script tag at index ${n}`,e)}}return{map:ah(t),complete:r}}function ah(e){let t={routes:{}};for(let r of e)r&&"object"==typeof r&&!Array.isArray(r)&&(Object.assign(t.routes,r.routes),void 0===t.version&&void 0!==r.version&&(t.version=r.version));return t}async function am(){let e={version:void 0,routes:{}};try{let t=[];for(let e=0;e<localStorage.length;e++){let r=localStorage.key(e);if(r?.startsWith(as)){let e=localStorage.getItem(r);e&&t.push({moduleName:r.slice(as.length),raw:e})}}for(let r of(await Promise.allSettled(t.map(async({moduleName:e,raw:t})=>{let r=JSON.parse(t);if(ai(r))return{moduleName:e,routes:r};if("string"==typeof r&&r.startsWith("http")){let t=await fetch(r),n=await t.json();if(ai(n))return{moduleName:e,routes:n};throw Error(`${r} did not resolve to a valid OpenmrsAppRoutes object`)}throw Error(`Override for ${e} is neither a valid routes object nor a URL`)}))))"fulfilled"===r.status?e.routes[r.value.moduleName]=r.value.routes:console.warn("[route-maps] Failed to load route override",r.reason)}catch(e){console.warn("[route-maps] Failed to read route overrides from localStorage",e)}return e}async function ag(){let e=await ap();return au?ah([e,ac??await am()]):e}async function ay(){return ap()}async function av(){return au?ah([await ap(),await am()]):ap()}function ab(){if(!au)return{};let e={};try{for(let t=0;t<localStorage.length;t++){let r=localStorage.key(t);if(r?.startsWith(as)){let t=localStorage.getItem(r);t&&(e[r.slice(as.length)]=t)}}}catch(e){console.warn("[route-maps] Failed to read route overrides from localStorage",e)}return e}function aw(e,t){if(!au)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{if("string"==typeof t)if(t.startsWith("http"))localStorage.setItem(as+e,JSON.stringify(t));else{let r=JSON.parse(t);if(!ai(r))return void console.error(`The supplied routes for ${e} is not a valid OpenmrsAppRoutes object`,t);localStorage.setItem(as+e,JSON.stringify(r))}else if(t instanceof URL)localStorage.setItem(as+e,JSON.stringify(t.toString()));else{if(!ai(t))return void console.error(`Override for ${e} is not in a valid format. Expected either a Javascript Object, a JSON string of a Javascript object, or a URL`,t);localStorage.setItem(as+e,JSON.stringify(t))}window.dispatchEvent(new CustomEvent(al))}catch(e){console.warn("[route-maps] Failed to write route override to localStorage",e)}}function a_(e){if(!au)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{localStorage.removeItem(as+e),window.dispatchEvent(new CustomEvent(al))}catch(e){console.warn("[route-maps] Failed to remove route override from localStorage",e)}}function ax(){if(!au)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{let e=[];for(let t=0;t<localStorage.length;t++){let r=localStorage.key(t);r?.startsWith(as)&&e.push(r)}e.forEach(e=>localStorage.removeItem(e)),window.dispatchEvent(new CustomEvent(al))}catch(e){console.warn("[route-maps] Failed to clear route overrides from localStorage",e)}}let aE=null;function aS(){return aE||(aE=(au="development"===window.spaEnv)?am().then(e=>{ac=e}):Promise.resolve())}let aD=`${o$}/attachment`;function aO(e,t){return oF(`${aD}/${e}`,{signal:t.signal})}function ak(e,t,r){return oF(`${aD}?patient=${e}&includeEncounterless=${t}`,{signal:r.signal})}async function aP(e,t){let r=new FormData;return r.append("fileCaption",t.fileDescription),r.append("patient",e),t.file?r.append("file",t.file,t.fileName):(r.append("file",new File([""],t.fileName),t.fileName),r.append("base64Content",t.base64Content)),oF(`${aD}`,{method:"POST",body:r})}function aC(e,t){return oF(`${aD}/${e}`,{method:"DELETE",signal:t.signal})}try{self["workbox:window:6.5.4"]&&_()}catch(e){}function aj(e,t){return new Promise(function(r){var n=new MessageChannel;n.port1.onmessage=function(e){r(e.data)},e.postMessage(t,[n.port2])})}function aT(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function aR(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}try{self["workbox:core:6.5.4"]&&_()}catch(e){}var aA=function(){var e=this;this.promise=new Promise(function(t,r){e.resolve=t,e.reject=r})};function aN(e,t){var r=location.href;return new URL(e,r).href===new URL(t,r).href}var a$=function(e,t){this.type=e,Object.assign(this,t)};function aI(e,t,r){return r?t?t(e):e:(e&&e.then||(e=Promise.resolve(e)),t?e.then(t):e)}function aM(){}var aL={type:"SKIP_WAITING"};function aF(e,t){if(!t)return e&&e.then?e.then(aM):Promise.resolve()}var aB=function(e){function t(t,r){var n,o;return void 0===r&&(r={}),(n=e.call(this)||this).nn={},n.tn=0,n.rn=new aA,n.en=new aA,n.on=new aA,n.un=0,n.an=new Set,n.cn=function(){var e=n.fn,t=e.installing;n.tn>0||!aN(t.scriptURL,n.sn.toString())||performance.now()>n.un+6e4?(n.vn=t,e.removeEventListener("updatefound",n.cn)):(n.hn=t,n.an.add(t),n.rn.resolve(t)),++n.tn,t.addEventListener("statechange",n.ln)},n.ln=function(e){var t=n.fn,r=e.target,o=r.state,i=r===n.vn,a={sw:r,isExternal:i,originalEvent:e};!i&&n.mn&&(a.isUpdate=!0),n.dispatchEvent(new a$(o,a)),"installed"===o?n.wn=self.setTimeout(function(){"installed"===o&&t.waiting===r&&n.dispatchEvent(new a$("waiting",a))},200):"activating"===o&&(clearTimeout(n.wn),i||n.en.resolve(r))},n.dn=function(e){var t=n.hn,r=t!==navigator.serviceWorker.controller;n.dispatchEvent(new a$("controlling",{isExternal:r,originalEvent:e,sw:t,isUpdate:n.mn})),r||n.on.resolve(t)},o=function(e){var t=e.data,r=e.ports,o=e.source;return aI(n.getSW(),function(){n.an.has(o)&&n.dispatchEvent(new a$("message",{data:t,originalEvent:e,ports:r,sw:o}))})},n.gn=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];try{return Promise.resolve(o.apply(this,e))}catch(e){return Promise.reject(e)}},n.sn=t,n.nn=r,navigator.serviceWorker.addEventListener("message",n.gn),n}t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e;var r,n,o=t.prototype;return o.register=function(e){var t=(void 0===e?{}:e).immediate,r=void 0!==t&&t;try{var n,o,i,a=this;return n=function(){if(!r&&"complete"!==document.readyState)return aF(new Promise(function(e){return window.addEventListener("load",e)}))},o=function(){return a.mn=!!navigator.serviceWorker.controller,a.yn=a.pn(),aI(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 t=a.fn.waiting;return t&&aN(t.scriptURL,a.sn.toString())&&(a.hn=t,Promise.resolve().then(function(){a.dispatchEvent(new a$("waiting",{sw:t,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})},(i=n())&&i.then?i.then(o):o(i)}catch(e){return Promise.reject(e)}},o.update=function(){try{return this.fn?aF(this.fn.update()):void 0}catch(e){return Promise.reject(e)}},o.getSW=function(){return void 0!==this.hn?Promise.resolve(this.hn):this.rn.promise},o.messageSW=function(e){try{return aI(this.getSW(),function(t){return aj(t,e)})}catch(e){return Promise.reject(e)}},o.messageSkipWaiting=function(){this.fn&&this.fn.waiting&&aj(this.fn.waiting,aL)},o.pn=function(){var e=navigator.serviceWorker.controller;return e&&aN(e.scriptURL,this.sn.toString())?e:void 0},o.bn=function(){try{var e=this;return function(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}(function(){return aI(navigator.serviceWorker.register(e.sn,e.nn),function(t){return e.un=performance.now(),t})},function(e){throw e})}catch(e){return Promise.reject(e)}},r=[{key:"active",get:function(){return this.en.promise}},{key:"controlling",get:function(){return this.on.promise}}],aT(t.prototype,r),n&&aT(t,n),t}(function(){function e(){this.Pn=new Map}var t=e.prototype;return t.addEventListener=function(e,t){this.Sn(e).add(t)},t.removeEventListener=function(e,t){this.Sn(e).delete(t)},t.dispatchEvent=function(e){e.target=this;for(var t,r=function(e){var t;if("u"<typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(t=function(e){if(e){if("string"==typeof e)return aR(e,void 0);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?aR(e,void 0):void 0}}(e))){t&&(e=t);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(t=e[Symbol.iterator]()).next.bind(t)}(this.Sn(e.type));!(t=r()).done;)(0,t.value)(e)},t.Sn=function(e){return this.Pn.has(e)||this.Pn.set(e,new Set),this.Pn.get(e)},e}());function aV(e,t){if(void 0!==p)return console.warn(`The application's Service Worker has already been registered. The new service worker at ${e} will not be registered.`),p;if(!("serviceWorker"in navigator))throw Error("Registering the Service Worker is not possible due to missing browser capabilities.");let r=new aB(e,t);return p=r.register().then(()=>r.controlling.then(()=>r))}function aU(){return p??Promise.resolve(void 0)}let aW="x-omrs-offline-response-body",aK="x-omrs-offline-response-status",az="x-omrs-offline-caching-strategy";async function aH(e){let t=await aU();return t?await t.messageSW(e):{success:!1,result:void 0,error:"No service worker has been registered. This is typically the case when the application has been built without offline-related features."}}async function aG(){let e=window.sessionStorage;try{e.setItem("someKeyHere","test"),e.removeItem("someKeyHere")}catch(t){if(t.code===DOMException.QUOTA_EXCEEDED_ERR&&0===e.length)return!0}return!1}async function aq(){return!window.indexedDB}async function aY(){return new Promise(e=>{let t=indexedDB.open("test");t.onerror=()=>e(!0),t.onsuccess=()=>e(!1)})}async function aZ(){return await aY()||await aq()||await aG()}let aJ="openmrs3:offline-mode",aX="unavailable";function aQ(){return{current:aX,notAvailable:"unavailable"===aX,active:"on"===aX}}function a0(e){"unavailable"!==aX&&"unavailable"!==e&&(localStorage.setItem(aJ,"on"===e?"active":"disabled"),aX=e)}async function a1(){await aZ()||(aX="active"===localStorage.getItem(aJ)?"on":"off"),navigator.onLine}let a4="u">typeof globalThis?globalThis:"u">typeof self?self:"u">typeof window?window:global,a3=Object.keys,a2=Array.isArray;function a6(e,t){return"object"!=typeof t||a3(t).forEach(function(r){e[r]=t[r]}),e}"u"<typeof Promise||a4.Promise||(a4.Promise=Promise);let a5=Object.getPrototypeOf,a8={}.hasOwnProperty;function a9(e,t){return a8.call(e,t)}function a7(e,t){"function"==typeof t&&(t=t(a5(e))),("u"<typeof Reflect?a3:Reflect.ownKeys)(t).forEach(r=>{st(e,r,t[r])})}let se=Object.defineProperty;function st(e,t,r,n){se(e,t,a6(r&&a9(r,"get")&&"function"==typeof r.get?{get:r.get,set:r.set,configurable:!0}:{value:r,configurable:!0,writable:!0},n))}function sr(e){return{from:function(t){return e.prototype=Object.create(t.prototype),st(e.prototype,"constructor",e),{extend:a7.bind(null,e.prototype)}}}}let sn=Object.getOwnPropertyDescriptor;function so(e,t){let r;return sn(e,t)||(r=a5(e))&&so(r,t)}let si=[].slice;function sa(e,t,r){return si.call(e,t,r)}function ss(e,t){return t(e)}function sl(e){if(!e)throw Error("Assertion Failed")}function su(e){a4.setImmediate?setImmediate(e):setTimeout(e,0)}function sc(e,t){return e.reduce((e,r,n)=>{var o=t(r,n);return o&&(e[o[0]]=o[1]),e},{})}function sd(e,t){if(a9(e,t))return e[t];if(!t)return e;if("string"!=typeof t){for(var r=[],n=0,o=t.length;n<o;++n){var i=sd(e,t[n]);r.push(i)}return r}var a=t.indexOf(".");if(-1!==a){var s=e[t.substr(0,a)];return void 0===s?void 0:sd(s,t.substr(a+1))}}function sp(e,t,r){if(e&&void 0!==t&&(!("isFrozen"in Object)||!Object.isFrozen(e)))if("string"!=typeof t&&"length"in t){sl("string"!=typeof r&&"length"in r);for(var n=0,o=t.length;n<o;++n)sp(e,t[n],r[n])}else{var i=t.indexOf(".");if(-1!==i){var a=t.substr(0,i),s=t.substr(i+1);if(""===s)void 0===r?a2(e)&&!isNaN(parseInt(a))?e.splice(a,1):delete e[a]:e[a]=r;else{var l=e[a];l&&a9(e,a)||(l=e[a]={}),sp(l,s,r)}}else void 0===r?a2(e)&&!isNaN(parseInt(t))?e.splice(t,1):delete e[t]:e[t]=r}}function sf(e){var t={};for(var r in e)a9(e,r)&&(t[r]=e[r]);return t}let sh=[].concat;function sm(e){return sh.apply([],e)}let sg="Boolean,String,Date,RegExp,Blob,File,FileList,FileSystemFileHandle,ArrayBuffer,DataView,Uint8ClampedArray,ImageBitmap,ImageData,Map,Set,CryptoKey".split(",").concat(sm([8,16,32,64].map(e=>["Int","Uint","Float"].map(t=>t+e+"Array")))).filter(e=>a4[e]),sy=sg.map(e=>a4[e]);sc(sg,e=>[e,!0]);let sv=null;function sb(e){sv="u">typeof WeakMap&&new WeakMap;let t=function e(t){if(!t||"object"!=typeof t)return t;let r=sv&&sv.get(t);if(r)return r;if(a2(t)){r=[],sv&&sv.set(t,r);for(var n=0,o=t.length;n<o;++n)r.push(e(t[n]))}else if(sy.indexOf(t.constructor)>=0)r=t;else{let n=a5(t);for(var i in r=n===Object.prototype?{}:Object.create(n),sv&&sv.set(t,r),t)a9(t,i)&&(r[i]=e(t[i]))}return r}(e);return sv=null,t}let{toString:sw}={};function s_(e){return sw.call(e).slice(8,-1)}let sx="u">typeof Symbol?Symbol.iterator:"@@iterator",sE="symbol"==typeof sx?function(e){var t;return null!=e&&(t=e[sx])&&t.apply(e)}:function(){return null},sS={};function sD(e){var t,r,n,o;if(1==arguments.length){if(a2(e))return e.slice();if(this===sS&&"string"==typeof e)return[e];if(o=sE(e)){for(r=[];!(n=o.next()).done;)r.push(n.value);return r}if(null==e)return[e];if("number"==typeof(t=e.length)){for(r=Array(t);t--;)r[t]=e[t];return r}return[e]}for(t=arguments.length,r=Array(t);t--;)r[t]=arguments[t];return r}let sO="u">typeof Symbol?e=>"AsyncFunction"===e[Symbol.toStringTag]:()=>!1;var sk="u">typeof location&&/^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href),sP=()=>!0;let sC=!Error("").stack;function sj(){if(sC)try{throw sj.arguments,Error()}catch(e){return e}return Error()}function sT(e,t){var r=e.stack;return r?(t=t||0,0===r.indexOf(e.name)&&(t+=(e.name+e.message).split("\n").length),r.split("\n").slice(t).filter(sP).map(e=>"\n"+e).join("")):""}var sR=["Unknown","Constraint","Data","TransactionInactive","ReadOnly","Version","NotFound","InvalidState","InvalidAccess","Abort","Timeout","QuotaExceeded","Syntax","DataClone"],sA=["Modify","Bulk","OpenFailed","VersionChange","Schema","Upgrade","InvalidTable","MissingAPI","NoSuchDatabase","InvalidArgument","SubTransaction","Unsupported","Internal","DatabaseClosed","PrematureCommit","ForeignAwait"].concat(sR),sN={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 s$(e,t){this._e=sj(),this.name=e,this.message=t}function sI(e,t){return e+". Errors: "+Object.keys(t).map(e=>t[e].toString()).filter((e,t,r)=>r.indexOf(e)===t).join("\n")}function sM(e,t,r,n){this._e=sj(),this.failures=t,this.failedKeys=n,this.successCount=r,this.message=sI(e,t)}function sL(e,t){this._e=sj(),this.name="BulkError",this.failures=Object.keys(t).map(e=>t[e]),this.failuresByPos=t,this.message=sI(e,t)}sr(s$).from(Error).extend({stack:{get:function(){return this._stack||(this._stack=this.name+": "+this.message+sT(this._e,2))}},toString:function(){return this.name+": "+this.message}}),sr(sM).from(s$),sr(sL).from(s$);var sF=sA.reduce((e,t)=>(e[t]=t+"Error",e),{}),sB=sA.reduce((e,t)=>{var r=t+"Error";function n(e,n){this._e=sj(),this.name=r,e?"string"==typeof e?(this.message=`${e}${n?"\n "+n:""}`,this.inner=n||null):"object"==typeof e&&(this.message=`${e.name} ${e.message}`,this.inner=e):(this.message=sN[t]||r,this.inner=null)}return sr(n).from(s$),e[t]=n,e},{});sB.Syntax=SyntaxError,sB.Type=TypeError,sB.Range=RangeError;var sV=sR.reduce((e,t)=>(e[t+"Error"]=sB[t],e),{}),sU=sA.reduce((e,t)=>(-1===["Syntax","Type","Range"].indexOf(t)&&(e[t+"Error"]=sB[t]),e),{});function sW(){}function sK(e){return e}function sz(e,t){return null==e||e===sK?t:function(r){return t(e(r))}}function sH(e,t){return function(){e.apply(this,arguments),t.apply(this,arguments)}}function sG(e,t){return e===sW?t:function(){var r=e.apply(this,arguments);void 0!==r&&(arguments[0]=r);var n=this.onsuccess,o=this.onerror;this.onsuccess=null,this.onerror=null;var i=t.apply(this,arguments);return n&&(this.onsuccess=this.onsuccess?sH(n,this.onsuccess):n),o&&(this.onerror=this.onerror?sH(o,this.onerror):o),void 0!==i?i:r}}function sq(e,t){return e===sW?t:function(){e.apply(this,arguments);var r=this.onsuccess,n=this.onerror;this.onsuccess=this.onerror=null,t.apply(this,arguments),r&&(this.onsuccess=this.onsuccess?sH(r,this.onsuccess):r),n&&(this.onerror=this.onerror?sH(n,this.onerror):n)}}function sY(e,t){return e===sW?t:function(r){var n=e.apply(this,arguments);a6(r,n);var o=this.onsuccess,i=this.onerror;this.onsuccess=null,this.onerror=null;var a=t.apply(this,arguments);return o&&(this.onsuccess=this.onsuccess?sH(o,this.onsuccess):o),i&&(this.onerror=this.onerror?sH(i,this.onerror):i),void 0===n?void 0===a?void 0:a:a6(n,a)}}function sZ(e,t){return e===sW?t:function(){return!1!==t.apply(this,arguments)&&e.apply(this,arguments)}}function sJ(e,t){return e===sW?t:function(){var r=e.apply(this,arguments);if(r&&"function"==typeof r.then){for(var n=this,o=arguments.length,i=Array(o);o--;)i[o]=arguments[o];return r.then(function(){return t.apply(n,i)})}return t.apply(this,arguments)}}sU.ModifyError=sM,sU.DexieError=s$,sU.BulkError=sL;var sX={};let[sQ,s0,s1]="u"<typeof Promise?[]:(()=>{let e=Promise.resolve();if("u"<typeof crypto||!crypto.subtle)return[e,a5(e),e];let t=crypto.subtle.digest("SHA-512",new Uint8Array([0]));return[t,a5(t),e]})(),s4=s0&&s0.then,s3=sQ&&sQ.constructor,s2=!!s1;var s6=!1,s5=s1?()=>{s1.then(ly)}:a4.setImmediate?setImmediate.bind(null,ly):a4.MutationObserver?()=>{var e=document.createElement("div");new MutationObserver(()=>{ly(),e=null}).observe(e,{attributes:!0}),e.setAttribute("i","1")}:()=>{setTimeout(ly,0)},s8=function(e,t){la.push([e,t]),s7&&(s5(),s7=!1)},s9=!0,s7=!0,le=[],lt=[],lr=null,ln=sK,lo={id:"global",global:!0,ref:0,unhandleds:[],onunhandled:lV,pgp:!1,env:{},finalize:function(){this.unhandleds.forEach(e=>{try{lV(e[0],e[1])}catch(e){}})}},li=lo,la=[],ls=0,ll=[];function lu(e){if("object"!=typeof this)throw TypeError("Promises must be constructed via new");this._listeners=[],this.onuncatched=sW,this._lib=!1;var t=this._PSD=li;if(sk&&(this._stackHolder=sj(),this._prev=null,this._numPrev=0),"function"!=typeof e){if(e!==sX)throw TypeError("Not a function");return this._state=arguments[1],this._value=arguments[2],void(!1===this._state&&lp(this,this._value))}this._state=null,this._value=null,++t.ref,function e(t,r){try{r(r=>{if(null===t._state){if(r===t)throw TypeError("A promise cannot be resolved with itself.");var n=t._lib&&lv();r&&"function"==typeof r.then?e(t,(e,t)=>{r instanceof lu?r._then(e,t):r.then(e,t)}):(t._state=!0,t._value=r,lf(t)),n&&lb()}},lp.bind(null,t))}catch(e){lp(t,e)}}(this,e)}let lc={get:function(){var e=li,t=lk;function r(r,n){var o=!e.global&&(e!==li||t!==lk);let i=o&&!lT();var a=new lu((t,a)=>{lh(this,new ld(lL(r,e,o,i),lL(n,e,o,i),t,a,e))});return sk&&lg(a,this),a}return r.prototype=sX,r},set:function(e){st(this,"then",e&&e.prototype===sX?lc:{get:function(){return e},set:lc.set})}};function ld(e,t,r,n,o){this.onFulfilled="function"==typeof e?e:null,this.onRejected="function"==typeof t?t:null,this.resolve=r,this.reject=n,this.psd=o}function lp(e,t){if(lt.push(t),null===e._state){var r=e._lib&&lv();t=ln(t),e._state=!1,e._value=t,sk&&null!==t&&"object"==typeof t&&!t._promise&&function(e){try{e.apply(null,void 0)}catch(e){}}(()=>{var r=so(t,"stack");t._promise=e,st(t,"stack",{get:()=>s6?r&&(r.get?r.get.apply(t):r.value):e.stack})}),le.some(t=>t._value===e._value)||le.push(e),lf(e),r&&lb()}}function lf(e){var t=e._listeners;e._listeners=[];for(var r=0,n=t.length;r<n;++r)lh(e,t[r]);var o=e._PSD;--o.ref||o.finalize(),0===ls&&(++ls,s8(()=>{0==--ls&&lw()},[]))}function lh(e,t){if(null!==e._state){var r=e._state?t.onFulfilled:t.onRejected;if(null===r)return(e._state?t.resolve:t.reject)(e._value);++t.psd.ref,++ls,s8(lm,[r,e,t])}else e._listeners.push(t)}function lm(e,t,r){try{lr=t;var n,o=t._value;t._state?n=e(o):(lt.length&&(lt=[]),n=e(o),-1===lt.indexOf(o)&&function(e){for(var t=le.length;t;)if(le[--t]._value===e._value)return void le.splice(t,1)}(t)),r.resolve(n)}catch(e){r.reject(e)}finally{lr=null,0==--ls&&lw(),--r.psd.ref||r.psd.finalize()}}function lg(e,t){var r=t?t._numPrev+1:0;r<100&&(e._prev=t,e._numPrev=r)}function ly(){lv()&&lb()}function lv(){var e=s9;return s9=!1,s7=!1,e}function lb(){var e,t,r;do for(;la.length>0;)for(e=la,la=[],r=e.length,t=0;t<r;++t){var n=e[t];n[0].apply(null,n[1])}while(la.length>0);s9=!0,s7=!0}function lw(){var e=le;le=[],e.forEach(e=>{e._PSD.onunhandled.call(null,e._value,e)});for(var t=ll.slice(0),r=t.length;r;)t[--r]()}function l_(e){return new lu(sX,!1,e)}function lx(e,t){var r=li;return function(){var n=lv(),o=li;try{return l$(r,!0),e.apply(this,arguments)}catch(e){t&&t(e)}finally{l$(o,!1),n&&lb()}}}a7(lu.prototype,{then:lc,_then:function(e,t){lh(this,new ld(null,null,e,t,li))},catch:function(e){if(1==arguments.length)return this.then(null,e);var t=arguments[0],r=arguments[1];return"function"==typeof t?this.then(null,e=>e instanceof t?r(e):l_(e)):this.then(null,e=>e&&e.name===t?r(e):l_(e))},finally:function(e){return this.then(t=>(e(),t),t=>(e(),l_(t)))},stack:{get:function(){if(this._stack)return this._stack;try{s6=!0;var e=(function e(t,r,n){if(r.length===n)return r;var o="";if(!1===t._state){var i,a,s=t._value;null!=s?(i=s.name||"Error",a=s.message||s,o=sT(s,0)):(i=s,a=""),r.push(i+(a?": "+a:"")+o)}return sk&&((o=sT(t._stackHolder,2))&&-1===r.indexOf(o)&&r.push(o),t._prev&&e(t._prev,r,n)),r})(this,[],20).join("\nFrom previous: ");return null!==this._state&&(this._stack=e),e}finally{s6=!1}}},timeout:function(e,t){return e<1/0?new lu((r,n)=>{var o=setTimeout(()=>n(new sB.Timeout(t)),e);this.then(r,n).finally(clearTimeout.bind(null,o))}):this}}),"u">typeof Symbol&&Symbol.toStringTag&&st(lu.prototype,Symbol.toStringTag,"Dexie.Promise"),lo.env=lI(),a7(lu,{all:function(){var e=sD.apply(null,arguments).map(lR);return new lu(function(t,r){0===e.length&&t([]);var n=e.length;e.forEach((o,i)=>lu.resolve(o).then(r=>{e[i]=r,--n||t(e)},r))})},resolve:e=>{if(e instanceof lu)return e;if(e&&"function"==typeof e.then)return new lu((t,r)=>{e.then(t,r)});var t=new lu(sX,!0,e);return lg(t,lr),t},reject:l_,race:function(){var e=sD.apply(null,arguments).map(lR);return new lu((t,r)=>{e.map(e=>lu.resolve(e).then(t,r))})},PSD:{get:()=>li,set:e=>li=e},totalEchoes:{get:()=>lk},newPSD:lC,usePSD:lM,scheduler:{get:()=>s8,set:e=>{s8=e}},rejectionMapper:{get:()=>ln,set:e=>{ln=e}},follow:(e,t)=>new lu((r,n)=>lC((t,r)=>{var n=li;n.unhandleds=[],n.onunhandled=r,n.finalize=sH(function(){var e;e=()=>{0===this.unhandleds.length?t():r(this.unhandleds[0])},ll.push(function t(){e(),ll.splice(ll.indexOf(t),1)}),++ls,s8(()=>{0==--ls&&lw()},[])},n.finalize),e()},t,r,n))}),s3&&(s3.allSettled&&st(lu,"allSettled",function(){let e=sD.apply(null,arguments).map(lR);return new lu(t=>{0===e.length&&t([]);let r=e.length,n=Array(r);e.forEach((e,o)=>lu.resolve(e).then(e=>n[o]={status:"fulfilled",value:e},e=>n[o]={status:"rejected",reason:e}).then(()=>--r||t(n)))})}),s3.any&&"u">typeof AggregateError&&st(lu,"any",function(){let e=sD.apply(null,arguments).map(lR);return new lu((t,r)=>{0===e.length&&r(AggregateError([]));let n=e.length,o=Array(n);e.forEach((e,i)=>lu.resolve(e).then(e=>t(e),e=>{o[i]=e,--n||r(AggregateError(o))}))})}));let lE={awaits:0,echoes:0,id:0};var lS=0,lD=[],lO=0,lk=0,lP=0;function lC(e,t,r,n){var o=li,i=Object.create(o);i.parent=o,i.ref=0,i.global=!1,i.id=++lP;var a=lo.env;i.env=s2?{Promise:lu,PromiseProp:{value:lu,configurable:!0,writable:!0},all:lu.all,race:lu.race,allSettled:lu.allSettled,any:lu.any,resolve:lu.resolve,reject:lu.reject,nthen:lF(a.nthen,i),gthen:lF(a.gthen,i)}:{},t&&a6(i,t),++o.ref,i.finalize=function(){--this.parent.ref||this.parent.finalize()};var s=lM(i,e,r,n);return 0===i.ref&&i.finalize(),s}function lj(){return lE.id||(lE.id=++lS),++lE.awaits,lE.echoes+=100,lE.id}function lT(){return!!lE.awaits&&(0==--lE.awaits&&(lE.id=0),lE.echoes=100*lE.awaits,!0)}function lR(e){return lE.echoes&&e&&e.constructor===s3?(lj(),e.then(e=>(lT(),e),e=>(lT(),lU(e)))):e}function lA(e){++lk,lE.echoes&&0!=--lE.echoes||(lE.echoes=lE.id=0),lD.push(li),l$(e,!0)}function lN(){var e=lD[lD.length-1];lD.pop(),l$(e,!1)}function l$(e,t){var r,n=li;if((t?!lE.echoes||lO++&&e===li:!lO||--lO&&e===li)||(r=t?lA.bind(null,e):lN,s4.call(sQ,r)),e!==li&&(li=e,n===lo&&(lo.env=lI()),s2)){var o=lo.env.Promise,i=e.env;s0.then=i.nthen,o.prototype.then=i.gthen,(n.global||e.global)&&(Object.defineProperty(a4,"Promise",i.PromiseProp),o.all=i.all,o.race=i.race,o.resolve=i.resolve,o.reject=i.reject,i.allSettled&&(o.allSettled=i.allSettled),i.any&&(o.any=i.any))}}function lI(){var e=a4.Promise;return s2?{Promise:e,PromiseProp:Object.getOwnPropertyDescriptor(a4,"Promise"),all:e.all,race:e.race,allSettled:e.allSettled,any:e.any,resolve:e.resolve,reject:e.reject,nthen:s0.then,gthen:e.prototype.then}:{}}function lM(e,t,r,n,o){var i=li;try{return l$(e,!0),t(r,n,o)}finally{l$(i,!1)}}function lL(e,t,r,n){return"function"!=typeof e?e:function(){var o,i=li;r&&lj(),l$(t,!0);try{return e.apply(this,arguments)}finally{l$(i,!1),n&&(o=lT,s4.call(sQ,o))}}}function lF(e,t){return function(r,n){return e.call(this,lL(r,t),lL(n,t))}}-1===(""+s4).indexOf("[native code]")&&(lj=lT=sW);let lB="unhandledrejection";function lV(e,t){var r;try{r=t.onuncatched(e)}catch(e){}if(!1!==r)try{var n,o={promise:t,reason:e};if(a4.document&&document.createEvent?((n=document.createEvent("Event")).initEvent(lB,!0,!0),a6(n,o)):a4.CustomEvent&&a6(n=new CustomEvent(lB,{detail:o}),o),n&&a4.dispatchEvent&&(dispatchEvent(n),!a4.PromiseRejectionEvent&&a4.onunhandledrejection))try{a4.onunhandledrejection(n)}catch(e){}sk&&n&&!n.defaultPrevented&&console.warn(`Unhandled rejection: ${e.stack||e}`)}catch(e){}}var lU=lu.reject;let lW="3.2.4",lK=String.fromCharCode(65535),lz=-1/0,lH="Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.",lG="String expected.",lq=[],lY="u">typeof navigator&&/(MSIE|Trident|Edge)/.test(navigator.userAgent),lZ=e=>!/(dexie\.js|dexie\.min\.js)/.test(e),lJ="__dbnames",lX="readonly",lQ="readwrite";function l0(e,t){return e?t?function(){return e.apply(this,arguments)&&t.apply(this,arguments)}:e:t}let l1={type:3,lower:-1/0,lowerOpen:!1,upper:[[]],upperOpen:!1};function l4(e){return"string"!=typeof e||/\./.test(e)?e=>e:t=>(void 0===t[e]&&e in t&&delete(t=sb(t))[e],t)}class l3{_trans(e,t,r){let n=this._tx||li.trans,o=this.name;function i(e,r,n){if(!n.schema[o])throw new sB.NotFound("Table "+o+" not part of transaction");return t(n.idbtrans,n)}let a=lv();try{return n&&n.db===this.db?n===li.trans?n._promise(e,i,r):lC(()=>n._promise(e,i,r),{trans:n,transless:li.transless||li}):function e(t,r,n,o){if(t.idbdb&&(t._state.openComplete||li.letThrough||t._vip)){var i=t._createTransaction(r,n,t._dbSchema);try{i.create(),t._state.PR1398_maxLoop=3}catch(i){return i.name===sF.InvalidState&&t.isOpen()&&--t._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),t._close(),t.open().then(()=>e(t,r,n,o))):lU(i)}return i._promise(r,(e,t)=>lC(()=>(li.trans=i,o(e,t,i)))).then(e=>i._completion.then(()=>e))}if(t._state.openComplete)return lU(new sB.DatabaseClosed(t._state.dbOpenError));if(!t._state.isBeingOpened){if(!t._options.autoOpen)return lU(new sB.DatabaseClosed);t.open().catch(sW)}return t._state.dbReadyPromise.then(()=>e(t,r,n,o))}(this.db,e,[this.name],i)}finally{a&&lb()}}get(e,t){return e&&e.constructor===Object?this.where(e).first(t):this._trans("readonly",t=>this.core.get({trans:t,key:e}).then(e=>this.hook.reading.fire(e))).then(t)}where(e){if("string"==typeof e)return new this.db.WhereClause(this,e);if(a2(e))return new this.db.WhereClause(this,`[${e.join("+")}]`);let t=a3(e);if(1===t.length)return this.where(t[0]).equals(e[t[0]]);let r=this.schema.indexes.concat(this.schema.primKey).filter(e=>e.compound&&t.every(t=>e.keyPath.indexOf(t)>=0)&&e.keyPath.every(e=>t.indexOf(e)>=0))[0];if(r&&this.db._maxKey!==lK)return this.where(r.name).equals(r.keyPath.map(t=>e[t]));!r&&sk&&console.warn(`The query ${JSON.stringify(e)} on ${this.name} would benefit of a compound index [${t.join("+")}]`);let{idxByName:n}=this.schema,o=this.db._deps.indexedDB;function i(e,t){try{return 0===o.cmp(e,t)}catch(e){return!1}}let[a,s]=t.reduce(([t,r],o)=>{let a=n[o],s=e[o];return[t||a,t||!a?l0(r,a&&a.multi?e=>{let t=sd(e,o);return a2(t)&&t.some(e=>i(s,e))}:e=>i(s,sd(e,o))):r]},[null,null]);return a?this.where(a.name).equals(e[a.keyPath]).filter(s):r?this.filter(s):this.where(t).equals("")}filter(e){return this.toCollection().and(e)}count(e){return this.toCollection().count(e)}offset(e){return this.toCollection().offset(e)}limit(e){return this.toCollection().limit(e)}each(e){return this.toCollection().each(e)}toArray(e){return this.toCollection().toArray(e)}toCollection(){return new this.db.Collection(new this.db.WhereClause(this))}orderBy(e){return new this.db.Collection(new this.db.WhereClause(this,a2(e)?`[${e.join("+")}]`:e))}reverse(){return this.toCollection().reverse()}mapToClass(e){this.schema.mappedClass=e;let t=t=>{if(!t)return t;let r=Object.create(e.prototype);for(var n in t)if(a9(t,n))try{r[n]=t[n]}catch(e){}return r};return this.schema.readHook&&this.hook.reading.unsubscribe(this.schema.readHook),this.schema.readHook=t,this.hook("reading",t),e}defineClass(){return this.mapToClass(function(e){a6(this,e)})}add(e,t){let{auto:r,keyPath:n}=this.schema.primKey,o=e;return n&&r&&(o=l4(n)(e)),this._trans("readwrite",e=>this.core.mutate({trans:e,type:"add",keys:null!=t?[t]:null,values:[o]})).then(e=>e.numFailures?lu.reject(e.failures[0]):e.lastResult).then(t=>{if(n)try{sp(e,n,t)}catch(e){}return t})}update(e,t){if("object"!=typeof e||a2(e))return this.where(":id").equals(e).modify(t);{let r=sd(e,this.schema.primKey.keyPath);if(void 0===r)return lU(new sB.InvalidArgument("Given object does not contain its primary key"));try{"function"!=typeof t?a3(t).forEach(r=>{sp(e,r,t[r])}):t(e,{value:e,primKey:r})}catch(e){}return this.where(":id").equals(r).modify(t)}}put(e,t){let{auto:r,keyPath:n}=this.schema.primKey,o=e;return n&&r&&(o=l4(n)(e)),this._trans("readwrite",e=>this.core.mutate({trans:e,type:"put",values:[o],keys:null!=t?[t]:null})).then(e=>e.numFailures?lu.reject(e.failures[0]):e.lastResult).then(t=>{if(n)try{sp(e,n,t)}catch(e){}return t})}delete(e){return this._trans("readwrite",t=>this.core.mutate({trans:t,type:"delete",keys:[e]})).then(e=>e.numFailures?lu.reject(e.failures[0]):void 0)}clear(){return this._trans("readwrite",e=>this.core.mutate({trans:e,type:"deleteRange",range:l1})).then(e=>e.numFailures?lu.reject(e.failures[0]):void 0)}bulkGet(e){return this._trans("readonly",t=>this.core.getMany({keys:e,trans:t}).then(e=>e.map(e=>this.hook.reading.fire(e))))}bulkAdd(e,t,r){let n=Array.isArray(t)?t:void 0,o=(r=r||(n?void 0:t))?r.allKeys:void 0;return this._trans("readwrite",t=>{let{auto:r,keyPath:i}=this.schema.primKey;if(i&&n)throw new sB.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(n&&n.length!==e.length)throw new sB.InvalidArgument("Arguments objects and keys must have the same length");let a=e.length,s=i&&r?e.map(l4(i)):e;return this.core.mutate({trans:t,type:"add",keys:n,values:s,wantResults:o}).then(({numFailures:e,results:t,lastResult:r,failures:n})=>{if(0===e)return o?t:r;throw new sL(`${this.name}.bulkAdd(): ${e} of ${a} operations failed`,n)})})}bulkPut(e,t,r){let n=Array.isArray(t)?t:void 0,o=(r=r||(n?void 0:t))?r.allKeys:void 0;return this._trans("readwrite",t=>{let{auto:r,keyPath:i}=this.schema.primKey;if(i&&n)throw new sB.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(n&&n.length!==e.length)throw new sB.InvalidArgument("Arguments objects and keys must have the same length");let a=e.length,s=i&&r?e.map(l4(i)):e;return this.core.mutate({trans:t,type:"put",keys:n,values:s,wantResults:o}).then(({numFailures:e,results:t,lastResult:r,failures:n})=>{if(0===e)return o?t:r;throw new sL(`${this.name}.bulkPut(): ${e} of ${a} operations failed`,n)})})}bulkDelete(e){let t=e.length;return this._trans("readwrite",t=>this.core.mutate({trans:t,type:"delete",keys:e})).then(({numFailures:e,lastResult:r,failures:n})=>{if(0===e)return r;throw new sL(`${this.name}.bulkDelete(): ${e} of ${t} operations failed`,n)})}}function l2(e){var t={},r=function(r,n){if(n){for(var o=arguments.length,i=Array(o-1);--o;)i[o-1]=arguments[o];return t[r].subscribe.apply(null,i),e}if("string"==typeof r)return t[r]};r.addEventType=i;for(var n=1,o=arguments.length;n<o;++n)i(arguments[n]);return r;function i(e,n,o){if("object"!=typeof e){n||(n=sZ),o||(o=sW);var a={subscribers:[],fire:o,subscribe:function(e){-1===a.subscribers.indexOf(e)&&(a.subscribers.push(e),a.fire=n(a.fire,e))},unsubscribe:function(e){a.subscribers=a.subscribers.filter(function(t){return t!==e}),a.fire=a.subscribers.reduce(n,o)}};return t[e]=r[e]=a,a}a3(e).forEach(function(t){var r=e[t];if(a2(r))i(t,e[t][0],e[t][1]);else{if("asap"!==r)throw new sB.InvalidArgument("Invalid event config");var n=i(t,sK,function(){for(var e=arguments.length,t=Array(e);e--;)t[e]=arguments[e];n.subscribers.forEach(function(e){su(function(){e.apply(null,t)})})})}})}}function l6(e,t){return sr(t).from({prototype:e}),t}function l5(e,t){return!(e.filter||e.algorithm||e.or)&&(t?e.justLimit:!e.replayFilter)}function l8(e,t){e.filter=l0(e.filter,t)}function l9(e,t,r){var n=e.replayFilter;e.replayFilter=n?()=>l0(n(),t()):t,e.justLimit=r&&!n}function l7(e,t){if(e.isPrimKey)return t.primaryKey;let r=t.getIndexByKeyPath(e.index);if(!r)throw new sB.Schema("KeyPath "+e.index+" on object store "+t.name+" is not indexed");return r}function ue(e,t,r){let n=l7(e,t.schema);return t.openCursor({trans:r,values:!e.keysOnly,reverse:"prev"===e.dir,unique:!!e.unique,query:{index:n,range:e.range}})}function ut(e,t,r,n){let o=e.replayFilter?l0(e.filter,e.replayFilter()):e.filter;if(e.or){let i={},a=(e,r,n)=>{if(!o||o(r,n,e=>r.stop(e),e=>r.fail(e))){var a=r.primaryKey,s=""+a;"[object ArrayBuffer]"===s&&(s=""+new Uint8Array(a)),a9(i,s)||(i[s]=!0,t(e,r,n))}};return Promise.all([e.or._iterate(a,r),ur(ue(e,n,r),e.algorithm,a,!e.keysOnly&&e.valueMapper)])}return ur(ue(e,n,r),l0(e.algorithm,o),t,!e.keysOnly&&e.valueMapper)}function ur(e,t,r,n){var o=lx(n?(e,t,o)=>r(n(e),t,o):r);return e.then(e=>{if(e)return e.start(()=>{var r=()=>e.continue();t&&!t(e,e=>r=e,t=>{e.stop(t),r=sW},t=>{e.fail(t),r=sW})||o(e.value,e,e=>r=e),r()})})}function un(e,t){try{let r=uo(e),n=uo(t);if(r!==n)return"Array"===r?1:"Array"===n?-1:"binary"===r?1:"binary"===n?-1:"string"===r?1:"string"===n?-1:"Date"===r?1:"Date"!==n?NaN:-1;switch(r){case"number":case"Date":case"string":return e>t?1:e<t?-1:0;case"binary":return function(e,t){let r=e.length,n=t.length,o=r<n?r:n;for(let r=0;r<o;++r)if(e[r]!==t[r])return e[r]<t[r]?-1:1;return r===n?0:r<n?-1:1}(ui(e),ui(t));case"Array":return function(e,t){let r=e.length,n=t.length,o=r<n?r:n;for(let r=0;r<o;++r){let n=un(e[r],t[r]);if(0!==n)return n}return r===n?0:r<n?-1:1}(e,t)}}catch(e){}return NaN}function uo(e){let t=typeof e;if("object"!==t)return t;if(ArrayBuffer.isView(e))return"binary";let r=s_(e);return"ArrayBuffer"===r?"binary":r}function ui(e){return e instanceof Uint8Array?e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e)}class ua{_read(e,t){var r=this._ctx;return r.error?r.table._trans(null,lU.bind(null,r.error)):r.table._trans("readonly",e).then(t)}_write(e){var t=this._ctx;return t.error?t.table._trans(null,lU.bind(null,t.error)):t.table._trans("readwrite",e,"locked")}_addAlgorithm(e){var t=this._ctx;t.algorithm=l0(t.algorithm,e)}_iterate(e,t){return ut(this._ctx,e,t,this._ctx.table.core)}clone(e){var t=Object.create(this.constructor.prototype),r=Object.create(this._ctx);return e&&a6(r,e),t._ctx=r,t}raw(){return this._ctx.valueMapper=null,this}each(e){var t=this._ctx;return this._read(r=>ut(t,e,r,t.table.core))}count(e){return this._read(e=>{let t=this._ctx,r=t.table.core;if(l5(t,!0))return r.count({trans:e,query:{index:l7(t,r.schema),range:t.range}}).then(e=>Math.min(e,t.limit));var n=0;return ut(t,()=>(++n,!1),e,r).then(()=>n)}).then(e)}sortBy(e,t){let r=e.split(".").reverse(),n=r[0],o=r.length-1;function i(e,t){return t?i(e[r[t]],t-1):e[n]}var a="next"===this._ctx.dir?1:-1;function s(e,t){var r=i(e,o),n=i(t,o);return r<n?-a:r>n?a:0}return this.toArray(function(e){return e.sort(s)}).then(t)}toArray(e){return this._read(e=>{var t=this._ctx;if("next"===t.dir&&l5(t,!0)&&t.limit>0){let{valueMapper:r}=t,n=l7(t,t.table.core.schema);return t.table.core.query({trans:e,limit:t.limit,values:!0,query:{index:n,range:t.range}}).then(({result:e})=>r?e.map(r):e)}{let r=[];return ut(t,e=>r.push(e),e,t.table.core).then(()=>r)}},e)}offset(e){var t=this._ctx;return e<=0||(t.offset+=e,l5(t)?l9(t,()=>{var t=e;return(e,r)=>0===t||(1===t?--t:r(()=>{e.advance(t),t=0}),!1)}):l9(t,()=>{var t=e;return()=>--t<0})),this}limit(e){return this._ctx.limit=Math.min(this._ctx.limit,e),l9(this._ctx,()=>{var t=e;return function(e,r,n){return--t<=0&&r(n),t>=0}},!0),this}until(e,t){return l8(this._ctx,function(r,n,o){return!e(r.value)||(n(o),t)}),this}first(e){return this.limit(1).toArray(function(e){return e[0]}).then(e)}last(e){return this.reverse().first(e)}filter(e){var t;return l8(this._ctx,function(t){return e(t.value)}),(t=this._ctx).isMatch=l0(t.isMatch,e),this}and(e){return this.filter(e)}or(e){return new this.db.WhereClause(this._ctx.table,e,this)}reverse(){return this._ctx.dir="prev"===this._ctx.dir?"next":"prev",this._ondirectionchange&&this._ondirectionchange(this._ctx.dir),this}desc(){return this.reverse()}eachKey(e){var t=this._ctx;return t.keysOnly=!t.isMatch,this.each(function(t,r){e(r.key,r)})}eachUniqueKey(e){return this._ctx.unique="unique",this.eachKey(e)}eachPrimaryKey(e){var t=this._ctx;return t.keysOnly=!t.isMatch,this.each(function(t,r){e(r.primaryKey,r)})}keys(e){var t=this._ctx;t.keysOnly=!t.isMatch;var r=[];return this.each(function(e,t){r.push(t.key)}).then(function(){return r}).then(e)}primaryKeys(e){var t=this._ctx;if("next"===t.dir&&l5(t,!0)&&t.limit>0)return this._read(e=>{var r=l7(t,t.table.core.schema);return t.table.core.query({trans:e,values:!1,limit:t.limit,query:{index:r,range:t.range}})}).then(({result:e})=>e).then(e);t.keysOnly=!t.isMatch;var r=[];return this.each(function(e,t){r.push(t.primaryKey)}).then(function(){return r}).then(e)}uniqueKeys(e){return this._ctx.unique="unique",this.keys(e)}firstKey(e){return this.limit(1).keys(function(e){return e[0]}).then(e)}lastKey(e){return this.reverse().firstKey(e)}distinct(){var e=this._ctx,t=e.index&&e.table.schema.idxByName[e.index];if(!t||!t.multi)return this;var r={};return l8(this._ctx,function(e){var t=e.primaryKey.toString(),n=a9(r,t);return r[t]=!0,!n}),this}modify(e){var t=this._ctx;return this._write(r=>{var n;if("function"==typeof e)n=e;else{var o=a3(e),i=o.length;n=function(t){for(var r=!1,n=0;n<i;++n){var a=o[n],s=e[a];sd(t,a)!==s&&(sp(t,a,s),r=!0)}return r}}let a=t.table.core,{outbound:s,extractKey:l}=a.schema.primaryKey,u=this.db._options.modifyChunkSize||200,c=[],d=0,p=[],f=(e,t)=>{let{failures:r,numFailures:n}=t;for(let t of(d+=e-n,a3(r)))c.push(r[t])};return this.clone().primaryKeys().then(o=>{let i=c=>{let d=Math.min(u,o.length-c);return a.getMany({trans:r,keys:o.slice(c,c+d),cache:"immutable"}).then(p=>{let h=[],m=[],g=s?[]:null,y=[];for(let e=0;e<d;++e){let t=p[e],r={value:sb(t),primKey:o[c+e]};!1!==n.call(r,r.value,r)&&(null==r.value?y.push(o[c+e]):s||0===un(l(t),l(r.value))?(m.push(r.value),s&&g.push(o[c+e])):(y.push(o[c+e]),h.push(r.value)))}let v=l5(t)&&t.limit===1/0&&("function"!=typeof e||e===us)&&{index:t.index,range:t.range};return Promise.resolve(h.length>0&&a.mutate({trans:r,type:"add",values:h}).then(e=>{for(let t in e.failures)y.splice(parseInt(t),1);f(h.length,e)})).then(()=>(m.length>0||v&&"object"==typeof e)&&a.mutate({trans:r,type:"put",keys:g,values:m,criteria:v,changeSpec:"function"!=typeof e&&e}).then(e=>f(m.length,e))).then(()=>(y.length>0||v&&e===us)&&a.mutate({trans:r,type:"delete",keys:y,criteria:v}).then(e=>f(y.length,e))).then(()=>o.length>c+d&&i(c+u))})};return i(0).then(()=>{if(c.length>0)throw new sM("Error modifying one or more objects",c,d,p);return o.length})})})}delete(){var e=this._ctx,t=e.range;return l5(e)&&(e.isPrimKey&&!lY||3===t.type)?this._write(r=>{let{primaryKey:n}=e.table.core.schema;return e.table.core.count({trans:r,query:{index:n,range:t}}).then(n=>e.table.core.mutate({trans:r,type:"deleteRange",range:t}).then(({failures:e,lastResult:t,results:r,numFailures:o})=>{if(o)throw new sM("Could not delete some values",Object.keys(e).map(t=>e[t]),n-o);return n-o}))}):this.modify(us)}}let us=(e,t)=>t.value=null;function ul(e,t){return e<t?-1:+(e!==t)}function uu(e,t){return e>t?-1:+(e!==t)}function uc(e,t,r){var n=e instanceof um?new e.Collection(e):e;return n._ctx.error=r?new r(t):TypeError(t),n}function ud(e){return new e.Collection(e,()=>uh("")).limit(0)}function up(e,t,r,n){var o,i,a,s,l,u,c,d=r.length;if(!r.every(e=>"string"==typeof e))return uc(e,lG);function p(e){o="next"===e?e=>e.toUpperCase():e=>e.toLowerCase(),i="next"===e?e=>e.toLowerCase():e=>e.toUpperCase(),a="next"===e?ul:uu;var t=r.map(function(e){return{lower:i(e),upper:o(e)}}).sort(function(e,t){return a(e.lower,t.lower)});s=t.map(function(e){return e.upper}),l=t.map(function(e){return e.lower}),u=e,c="next"===e?"":n}p("next");var f=new e.Collection(e,()=>uf(s[0],l[d-1]+n));f._ondirectionchange=function(e){p(e)};var h=0;return f._addAlgorithm(function(e,r,n){var o=e.key;if("string"!=typeof o)return!1;var p=i(o);if(t(p,l,h))return!0;for(var f=null,m=h;m<d;++m){var g=function(e,t,r,n,o,i){for(var a=Math.min(e.length,n.length),s=-1,l=0;l<a;++l){var u=t[l];if(u!==n[l])return 0>o(e[l],r[l])?e.substr(0,l)+r[l]+r.substr(l+1):0>o(e[l],n[l])?e.substr(0,l)+n[l]+r.substr(l+1):s>=0?e.substr(0,s)+t[s]+r.substr(s+1):null;0>o(e[l],u)&&(s=l)}return a<n.length&&"next"===i?e+r.substr(e.length):a<e.length&&"prev"===i?e.substr(0,r.length):s<0?null:e.substr(0,s)+n[s]+r.substr(s+1)}(o,p,s[m],l[m],a,u);null===g&&null===f?h=m+1:(null===f||a(f,g)>0)&&(f=g)}return r(null!==f?function(){e.continue(f+c)}:n),!1}),f}function uf(e,t,r,n){return{type:2,lower:e,upper:t,lowerOpen:r,upperOpen:n}}function uh(e){return{type:1,lower:e,upper:e}}class um{get Collection(){return this._ctx.table.db.Collection}between(e,t,r,n){r=!1!==r,n=!0===n;try{return this._cmp(e,t)>0||0===this._cmp(e,t)&&(r||n)&&(!r||!n)?ud(this):new this.Collection(this,()=>uf(e,t,!r,!n))}catch(e){return uc(this,lH)}}equals(e){return null==e?uc(this,lH):new this.Collection(this,()=>uh(e))}above(e){return null==e?uc(this,lH):new this.Collection(this,()=>uf(e,void 0,!0))}aboveOrEqual(e){return null==e?uc(this,lH):new this.Collection(this,()=>uf(e,void 0,!1))}below(e){return null==e?uc(this,lH):new this.Collection(this,()=>uf(void 0,e,!1,!0))}belowOrEqual(e){return null==e?uc(this,lH):new this.Collection(this,()=>uf(void 0,e))}startsWith(e){return"string"!=typeof e?uc(this,lG):this.between(e,e+lK,!0,!0)}startsWithIgnoreCase(e){return""===e?this.startsWith(e):up(this,(e,t)=>0===e.indexOf(t[0]),[e],lK)}equalsIgnoreCase(e){return up(this,(e,t)=>e===t[0],[e],"")}anyOfIgnoreCase(){var e=sD.apply(sS,arguments);return 0===e.length?ud(this):up(this,(e,t)=>-1!==t.indexOf(e),e,"")}startsWithAnyOfIgnoreCase(){var e=sD.apply(sS,arguments);return 0===e.length?ud(this):up(this,(e,t)=>t.some(t=>0===e.indexOf(t)),e,lK)}anyOf(){let e=sD.apply(sS,arguments),t=this._cmp;try{e.sort(t)}catch(e){return uc(this,lH)}if(0===e.length)return ud(this);let r=new this.Collection(this,()=>uf(e[0],e[e.length-1]));r._ondirectionchange=r=>{t="next"===r?this._ascending:this._descending,e.sort(t)};let n=0;return r._addAlgorithm((r,o,i)=>{let a=r.key;for(;t(a,e[n])>0;)if(++n===e.length)return o(i),!1;return 0===t(a,e[n])||(o(()=>{r.continue(e[n])}),!1)}),r}notEqual(e){return this.inAnyRange([[lz,e],[e,this.db._maxKey]],{includeLowers:!1,includeUppers:!1})}noneOf(){let e=sD.apply(sS,arguments);if(0===e.length)return new this.Collection(this);try{e.sort(this._ascending)}catch(e){return uc(this,lH)}let t=e.reduce((e,t)=>e?e.concat([[e[e.length-1][1],t]]):[[lz,t]],null);return t.push([e[e.length-1],this.db._maxKey]),this.inAnyRange(t,{includeLowers:!1,includeUppers:!1})}inAnyRange(e,t){let r=this._cmp,n=this._ascending,o=this._descending,i=this._min,a=this._max;if(0===e.length)return ud(this);if(!e.every(e=>void 0!==e[0]&&void 0!==e[1]&&0>=n(e[0],e[1])))return uc(this,"First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower",sB.InvalidArgument);let s=!t||!1!==t.includeLowers,l=t&&!0===t.includeUppers,u,c=n;function d(e,t){return c(e[0],t[0])}try{(u=e.reduce(function(e,t){let n=0,o=e.length;for(;n<o;++n){let o=e[n];if(0>r(t[0],o[1])&&r(t[1],o[0])>0){o[0]=i(o[0],t[0]),o[1]=a(o[1],t[1]);break}}return n===o&&e.push(t),e},[])).sort(d)}catch(e){return uc(this,lH)}let p=0,f=l?e=>n(e,u[p][1])>0:e=>n(e,u[p][1])>=0,h=s?e=>o(e,u[p][0])>0:e=>o(e,u[p][0])>=0,m=f,g=new this.Collection(this,()=>uf(u[0][0],u[u.length-1][1],!s,!l));return g._ondirectionchange=e=>{"next"===e?(m=f,c=n):(m=h,c=o),u.sort(d)},g._addAlgorithm((e,t,r)=>{for(var o=e.key;m(o);)if(++p===u.length)return t(r),!1;return!!(!f(o)&&!h(o))||(0===this._cmp(o,u[p][1])||0===this._cmp(o,u[p][0])||t(()=>{c===n?e.continue(u[p][0]):e.continue(u[p][1])}),!1)}),g}startsWithAnyOf(){let e=sD.apply(sS,arguments);return e.every(e=>"string"==typeof e)?0===e.length?ud(this):this.inAnyRange(e.map(e=>[e,e+lK])):uc(this,"startsWithAnyOf() only works with strings")}}function ug(e){return lx(function(t){return uy(t),e(t.target.error),!1})}function uy(e){e.stopPropagation&&e.stopPropagation(),e.preventDefault&&e.preventDefault()}let uv="storagemutated",ub="x-storagemutated-1",uw=l2(null,uv);class u_{_lock(){return sl(!li.global),++this._reculock,1!==this._reculock||li.global||(li.lockOwnerFor=this),this}_unlock(){if(sl(!li.global),0==--this._reculock)for(li.global||(li.lockOwnerFor=null);this._blockedFuncs.length>0&&!this._locked();){var e=this._blockedFuncs.shift();try{lM(e[1],e[0])}catch(e){}}return this}_locked(){return this._reculock&&li.lockOwnerFor!==this}create(e){if(!this.mode)return this;let t=this.db.idbdb,r=this.db._state.dbOpenError;if(sl(!this.idbtrans),!e&&!t)switch(r&&r.name){case"DatabaseClosedError":throw new sB.DatabaseClosed(r);case"MissingAPIError":throw new sB.MissingAPI(r.message,r);default:throw new sB.OpenFailed(r)}if(!this.active)throw new sB.TransactionInactive;return sl(null===this._completion._state),(e=this.idbtrans=e||(this.db.core?this.db.core.transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability}):t.transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability}))).onerror=lx(t=>{uy(t),this._reject(e.error)}),e.onabort=lx(t=>{uy(t),this.active&&this._reject(new sB.Abort(e.error)),this.active=!1,this.on("abort").fire(t)}),e.oncomplete=lx(()=>{this.active=!1,this._resolve(),"mutatedParts"in e&&uw.storagemutated.fire(e.mutatedParts)}),this}_promise(e,t,r){if("readwrite"===e&&"readwrite"!==this.mode)return lU(new sB.ReadOnly("Transaction is readonly"));if(!this.active)return lU(new sB.TransactionInactive);if(this._locked())return new lu((n,o)=>{this._blockedFuncs.push([()=>{this._promise(e,t,r).then(n,o)},li])});if(r)return lC(()=>{var e=new lu((e,r)=>{this._lock();let n=t(e,r,this);n&&n.then&&n.then(e,r)});return e.finally(()=>this._unlock()),e._lib=!0,e});var n=new lu((e,r)=>{var n=t(e,r,this);n&&n.then&&n.then(e,r)});return n._lib=!0,n}_root(){return this.parent?this.parent._root():this}waitFor(e){var t=this._root();let r=lu.resolve(e);if(t._waitingFor)t._waitingFor=t._waitingFor.then(()=>r);else{t._waitingFor=r,t._waitingQueue=[];var n=t.idbtrans.objectStore(t.storeNames[0]);!function e(){for(++t._spinCount;t._waitingQueue.length;)t._waitingQueue.shift()();t._waitingFor&&(n.get(-1/0).onsuccess=e)}()}var o=t._waitingFor;return new lu((e,n)=>{r.then(r=>t._waitingQueue.push(lx(e.bind(null,r))),e=>t._waitingQueue.push(lx(n.bind(null,e)))).finally(()=>{t._waitingFor===o&&(t._waitingFor=null)})})}abort(){this.active&&(this.active=!1,this.idbtrans&&this.idbtrans.abort(),this._reject(new sB.Abort))}table(e){let t=this._memoizedTables||(this._memoizedTables={});if(a9(t,e))return t[e];let r=this.schema[e];if(!r)throw new sB.NotFound("Table "+e+" not part of transaction");let n=new this.db.Table(e,r,this);return n.core=this.db.core.table(e),t[e]=n,n}}function ux(e,t,r,n,o,i,a){return{name:e,keyPath:t,unique:r,multi:n,auto:o,compound:i,src:(r&&!a?"&":"")+(n?"*":"")+(o?"++":"")+uE(t)}}function uE(e){return"string"==typeof e?e:e?"["+[].join.call(e,"+")+"]":""}function uS(e,t,r){return{name:e,primKey:t,indexes:r,mappedClass:null,idxByName:sc(r,e=>[e.name,e])}}let uD=e=>{try{return e.only([[]]),uD=()=>[[]],[[]]}catch(e){return uD=()=>lK,lK}};function uO(e){return null==e?()=>{}:"string"==typeof e?1===e.split(".").length?t=>t[e]:t=>sd(t,e):t=>sd(t,e)}function uk(e){return[].slice.call(e)}let uP=0;function uC(e){return null==e?":id":"string"==typeof e?e:`[${e.join("+")}]`}function uj({_novip:e},t){let r=t.db,n=function(e,t,{IDBKeyRange:r,indexedDB:n},o){var i;return{dbcore:(i=function(e,t,r){let n;function o(e){if(3===e.type)return null;if(4===e.type)throw Error("Cannot convert never type to IDBKeyRange");let{lower:r,upper:n,lowerOpen:o,upperOpen:i}=e;return void 0===r?void 0===n?null:t.upperBound(n,!!i):void 0===n?t.lowerBound(r,!!o):t.bound(r,n,!!o,!!i)}let{schema:i,hasGetAll:a}=(n=uk(e.objectStoreNames),{schema:{name:e.name,tables:n.map(e=>r.objectStore(e)).map(e=>{let{keyPath:t,autoIncrement:r}=e,n=a2(t),o=null==t,i={},a={name:e.name,primaryKey:{name:null,isPrimaryKey:!0,outbound:o,compound:n,keyPath:t,autoIncrement:r,unique:!0,extractKey:uO(t)},indexes:uk(e.indexNames).map(t=>e.index(t)).map(e=>{let{name:t,unique:r,multiEntry:n,keyPath:o}=e,a={name:t,compound:a2(o),keyPath:o,unique:r,multiEntry:n,extractKey:uO(o)};return i[uC(o)]=a,a}),getIndexByKeyPath:e=>i[uC(e)]};return i[":id"]=a.primaryKey,null!=t&&(i[uC(t)]=a.primaryKey),a})},hasGetAll:n.length>0&&"getAll"in r.objectStore(n[0])&&!("u">typeof navigator&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604)}),s=i.tables.map(e=>{let t;return{name:t=e.name,schema:e,mutate:function({trans:e,type:r,keys:n,values:i,range:a}){return new Promise((s,l)=>{let u;s=lx(s);let c=e.objectStore(t),d=null==c.keyPath,p="put"===r||"add"===r;if(!p&&"delete"!==r&&"deleteRange"!==r)throw Error("Invalid operation type: "+r);let{length:f}=n||i||{length:1};if(n&&i&&n.length!==i.length)throw Error("Given keys array must have same length as given values array.");if(0===f)return s({numFailures:0,failures:{},results:[],lastResult:void 0});let h=[],m=[],g=0,y=e=>{++g,uy(e)};if("deleteRange"===r){if(4===a.type)return s({numFailures:g,failures:m,results:[],lastResult:void 0});3===a.type?h.push(u=c.clear()):h.push(u=c.delete(o(a)))}else{let[e,t]=p?d?[i,n]:[i,null]:[n,null];if(p)for(let n=0;n<f;++n)h.push(u=t&&void 0!==t[n]?c[r](e[n],t[n]):c[r](e[n])),u.onerror=y;else for(let t=0;t<f;++t)h.push(u=c[r](e[t])),u.onerror=y}let v=e=>{let t=e.target.result;h.forEach((e,t)=>null!=e.error&&(m[t]=e.error)),s({numFailures:g,failures:m,results:"delete"===r?n:h.map(e=>e.result),lastResult:t})};u.onerror=e=>{y(e),v(e)},u.onsuccess=v})},getMany:({trans:e,keys:r})=>new Promise((n,o)=>{n=lx(n);let i=e.objectStore(t),a=r.length,s=Array(a),l,u=0,c=0,d=e=>{let t=e.target;s[t._pos]=t.result,++c===u&&n(s)},p=ug(o);for(let e=0;e<a;++e)null!=r[e]&&((l=i.get(r[e]))._pos=e,l.onsuccess=d,l.onerror=p,++u);0===u&&n(s)}),get:({trans:e,key:r})=>new Promise((n,o)=>{n=lx(n);let i=e.objectStore(t).get(r);i.onsuccess=e=>n(e.target.result),i.onerror=ug(o)}),query:e=>new Promise((r,n)=>{r=lx(r);let{trans:i,values:s,limit:l,query:u}=e,c=l===1/0?void 0:l,{index:d,range:p}=u,f=i.objectStore(t),h=d.isPrimaryKey?f:f.index(d.name),m=o(p);if(0===l)return r({result:[]});if(a){let e=s?h.getAll(m,c):h.getAllKeys(m,c);e.onsuccess=e=>r({result:e.target.result}),e.onerror=ug(n)}else{let e=0,t=!s&&"openKeyCursor"in h?h.openKeyCursor(m):h.openCursor(m),o=[];t.onsuccess=n=>{let i=t.result;return i?(o.push(s?i.value:i.primaryKey),++e===l?r({result:o}):void i.continue()):r({result:o})},t.onerror=ug(n)}}),openCursor:function({trans:e,values:r,query:n,reverse:i,unique:a}){return new Promise((s,l)=>{s=lx(s);let{index:u,range:c}=n,d=e.objectStore(t),p=u.isPrimaryKey?d:d.index(u.name),f=i?a?"prevunique":"prev":a?"nextunique":"next",h=!r&&"openKeyCursor"in p?p.openKeyCursor(o(c),f):p.openCursor(o(c),f);h.onerror=ug(l),h.onsuccess=lx(t=>{let r=h.result;if(!r)return void s(null);r.___id=++uP,r.done=!1;let n=r.continue.bind(r),o=r.continuePrimaryKey;o&&(o=o.bind(r));let i=r.advance.bind(r),a=()=>{throw Error("Cursor not stopped")};r.trans=e,r.stop=r.continue=r.continuePrimaryKey=r.advance=()=>{throw Error("Cursor not started")},r.fail=lx(l),r.next=function(){let e=1;return this.start(()=>e--?this.continue():this.stop()).then(()=>this)},r.start=e=>{let t=new Promise((e,t)=>{e=lx(e),h.onerror=ug(t),r.fail=t,r.stop=t=>{r.stop=r.continue=r.continuePrimaryKey=r.advance=a,e(t)}}),s=()=>{if(h.result)try{e()}catch(e){r.fail(e)}else r.done=!0,r.start=()=>{throw Error("Cursor behind last entry")},r.stop()};return h.onsuccess=lx(e=>{h.onsuccess=s,s()}),r.continue=n,r.continuePrimaryKey=o,r.advance=i,s(),t},s(r)},l)})},count({query:e,trans:r}){let{index:n,range:i}=e;return new Promise((e,a)=>{let s=r.objectStore(t),l=n.isPrimaryKey?s:s.index(n.name),u=o(i),c=u?l.count(u):l.count();c.onsuccess=lx(t=>e(t.target.result)),c.onerror=ug(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:uD(t),schema:i}}(t,r,o),e.dbcore.reduce((e,{create:t})=>({...e,...t(e)}),i))}}(e._middlewares,r,e._deps,t);e.core=n.dbcore,e.tables.forEach(t=>{let r=t.name;e.core.schema.tables.some(e=>e.name===r)&&(t.core=e.core.table(r),e[r]instanceof e.Table&&(e[r].core=t.core))})}function uT({_novip:e},t,r,n){r.forEach(r=>{let o=n[r];t.forEach(t=>{let n=so(t,r);(!n||"value"in n&&void 0===n.value)&&(t===e.Transaction.prototype||t instanceof e.Transaction?st(t,r,{get(){return this.table(r)},set(e){se(this,r,{value:e,writable:!0,configurable:!0,enumerable:!0})}}):t[r]=new e.Table(r,o))})})}function uR({_novip:e},t){t.forEach(t=>{for(let r in t)t[r]instanceof e.Table&&delete t[r]})}function uA(e,t){return e._cfg.version-t._cfg.version}function uN(e,t){let r,n={del:[],add:[],change:[]};for(r in e)t[r]||n.del.push(r);for(r in t){let o=e[r],i=t[r];if(o){let e={name:r,def:i,recreate:!1,del:[],add:[],change:[]};if(""+(o.primKey.keyPath||"")==""+(i.primKey.keyPath||"")&&(o.primKey.auto===i.primKey.auto||lY)){let t,r=o.idxByName,a=i.idxByName;for(t in r)a[t]||e.del.push(t);for(t in a){let n=r[t],o=a[t];n?n.src!==o.src&&e.change.push(o):e.add.push(o)}(e.del.length>0||e.add.length>0||e.change.length>0)&&n.change.push(e)}else e.recreate=!0,n.change.push(e)}else n.add.push([r,i])}return n}function u$(e,t,r,n){let o=e.db.createObjectStore(t,r.keyPath?{keyPath:r.keyPath,autoIncrement:r.auto}:{autoIncrement:r.auto});return n.forEach(e=>uI(o,e)),o}function uI(e,t){e.createIndex(t.name,t.keyPath,{unique:t.unique,multiEntry:t.multi})}function uM(e,t,r){let n={};return sa(t.objectStoreNames,0).forEach(e=>{let t=r.objectStore(e),o=t.keyPath,i=ux(uE(o),o||"",!1,!1,!!t.autoIncrement,o&&"string"!=typeof o,!0),a=[];for(let e=0;e<t.indexNames.length;++e){let r=t.index(t.indexNames[e]);o=r.keyPath;var s=ux(r.name,o,!!r.unique,!!r.multiEntry,!1,o&&"string"!=typeof o,!1);a.push(s)}n[e]=uS(e,i,a)}),n}function uL({_novip:e},t,r){let n=r.db.objectStoreNames;for(let o=0;o<n.length;++o){let i=n[o],a=r.objectStore(i);e._hasGetAll="getAll"in a;for(let e=0;e<a.indexNames.length;++e){let r=a.indexNames[e],n=a.index(r).keyPath,o="string"==typeof n?n:"["+sa(n).join("+")+"]";if(t[i]){let e=t[i].idxByName[o];e&&(e.name=r,delete t[i].idxByName[o],t[i].idxByName[r]=e)}}}"u">typeof navigator&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&a4.WorkerGlobalScope&&a4 instanceof a4.WorkerGlobalScope&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604&&(e._hasGetAll=!1)}class uF{_parseStoresSpec(e,t){a3(e).forEach(r=>{if(null!==e[r]){var n=e[r].split(",").map((e,t)=>{let r=(e=e.trim()).replace(/([&*]|\+\+)/g,""),n=/^\[/.test(r)?r.match(/^\[(.*)\]$/)[1].split("+"):r;return ux(r,n||null,/\&/.test(e),/\*/.test(e),/\+\+/.test(e),a2(n),0===t)}),o=n.shift();if(o.multi)throw new sB.Schema("Primary key cannot be multi-valued");n.forEach(e=>{if(e.auto)throw new sB.Schema("Only primary key can be marked as autoIncrement (++)");if(!e.keyPath)throw new sB.Schema("Index must have a name and cannot be an empty string")}),t[r]=uS(r,o,n)}})}stores(e){let t=this.db;this._cfg.storesSource=this._cfg.storesSource?a6(this._cfg.storesSource,e):e;let r=t._versions,n={},o={};return r.forEach(e=>{a6(n,e._cfg.storesSource),o=e._cfg.dbschema={},e._parseStoresSpec(n,o)}),t._dbSchema=o,uR(t,[t._allTables,t,t.Transaction.prototype]),uT(t,[t._allTables,t,t.Transaction.prototype,this._cfg.tables],a3(o),o),t._storeNames=a3(o),this}upgrade(e){return this._cfg.contentUpgrade=sJ(this._cfg.contentUpgrade||sW,e),this}}function uB(e,t){let r=e._dbNamesDB;return r||(r=e._dbNamesDB=new u6(lJ,{addons:[],indexedDB:e,IDBKeyRange:t})).version(1).stores({dbnames:"name"}),r.table("dbnames")}function uV(e){return e&&"function"==typeof e.databases}function uU(e){return lC(function(){return li.letThrough=!0,e()})}function uW(e){var t=t=>e.next(t),r=o(t),n=o(t=>e.throw(t));function o(e){return t=>{var o=e(t),i=o.value;return o.done?i:i&&"function"==typeof i.then?i.then(r,n):a2(i)?Promise.all(i).then(r,n):r(i)}}return o(t)()}function uK(e,t,r){var n=arguments.length;if(n<2)throw new sB.InvalidArgument("Too few arguments");for(var o=Array(n-1);--n;)o[n-1]=arguments[n];return r=o.pop(),[e,sm(o),r]}function uz(e,t,r){let n=a2(e)?e.slice():[e];for(let e=0;e<r;++e)n.push(t);return n}let uH={stack:"dbcore",name:"VirtualIndexMiddleware",level:1,create:function(e){return{...e,table(t){let r=e.table(t),{schema:n}=r,o={},i=[];function a(e,t,r){let n=uC(e),s=o[n]=o[n]||[],l=null==e?0:"string"==typeof e?1:e.length,u=t>0,c={...r,isVirtual:u,keyTail:t,keyLength:l,extractKey:uO(e),unique:!u&&r.unique};return s.push(c),c.isPrimaryKey||i.push(c),l>1&&a(2===l?e[0]:e.slice(0,l-1),t+1,r),s.sort((e,t)=>e.keyTail-t.keyTail),c}let s=a(n.primaryKey.keyPath,0,n.primaryKey);for(let e of(o[":id"]=[s],n.indexes))a(e.keyPath,0,e);function l(t){var r,n;let o=t.query.index;return o.isVirtual?{...t,query:{index:o,range:(r=t.query.range,n=o.keyTail,{type:1===r.type?2:r.type,lower:uz(r.lower,r.lowerOpen?e.MAX_KEY:e.MIN_KEY,n),lowerOpen:!0,upper:uz(r.upper,r.upperOpen?e.MIN_KEY:e.MAX_KEY,n),upperOpen:!0})}}:t}return{...r,schema:{...n,primaryKey:s,indexes:i,getIndexByKeyPath:function(e){let t=o[uC(e)];return t&&t[0]}},count:e=>r.count(l(e)),query:e=>r.query(l(e)),openCursor(t){let{keyTail:n,isVirtual:o,keyLength:i}=t.query.index;return o?r.openCursor(l(t)).then(r=>r&&Object.create(r,{continue:{value:function(o){null!=o?r.continue(uz(o,t.reverse?e.MAX_KEY:e.MIN_KEY,n)):t.unique?r.continue(r.key.slice(0,i).concat(t.reverse?e.MIN_KEY:e.MAX_KEY,n)):r.continue()}},continuePrimaryKey:{value(t,o){r.continuePrimaryKey(uz(t,e.MAX_KEY,n),o)}},primaryKey:{get:()=>r.primaryKey},key:{get(){let e=r.key;return 1===i?e[0]:e.slice(0,i)}},value:{get:()=>r.value}})):r.openCursor(t)}}}}}};function uG(e,t,r,n){return r=r||{},n=n||"",a3(e).forEach(o=>{if(a9(t,o)){var i=e[o],a=t[o];if("object"==typeof i&&"object"==typeof a&&i&&a){let e=s_(i);e!==s_(a)?r[n+o]=t[o]:"Object"===e?uG(i,a,r,n+o+"."):i!==a&&(r[n+o]=t[o])}else i!==a&&(r[n+o]=t[o])}else r[n+o]=void 0}),a3(t).forEach(o=>{a9(e,o)||(r[n+o]=t[o])}),r}let uq={stack:"dbcore",name:"HooksMiddleware",level:2,create:e=>({...e,table(t){let r=e.table(t),{primaryKey:n}=r.schema;return{...r,mutate(e){let o=li.trans,{deleting:i,creating:a,updating:s}=o.table(t).hook;switch(e.type){case"add":if(a.fire===sW)break;return o._promise("readwrite",()=>l(e),!0);case"put":if(a.fire===sW&&s.fire===sW)break;return o._promise("readwrite",()=>l(e),!0);case"delete":if(i.fire===sW)break;return o._promise("readwrite",()=>l(e),!0);case"deleteRange":if(i.fire===sW)break;return o._promise("readwrite",()=>(function e(t,o,i){return r.query({trans:t,values:!1,query:{index:n,range:o},limit:i}).then(({result:r})=>l({type:"delete",keys:r,trans:t}).then(n=>n.numFailures>0?Promise.reject(n.failures[0]):r.length<i?{failures:[],numFailures:0,lastResult:void 0}:e(t,{...o,lower:r[r.length-1],lowerOpen:!0},i)))})(e.trans,e.range,1e4),!0)}return r.mutate(e);function l(e){var t,o;let l=li.trans,u=e.keys||("delete"===(t=e).type?t.keys:t.keys||t.values.map(n.extractKey));if(!u)throw Error("Keys missing");return"delete"!==(e="add"===e.type||"put"===e.type?{...e,keys:u}:{...e}).type&&(e.values=[...e.values]),e.keys&&(e.keys=[...e.keys]),("add"===(o=e).type?Promise.resolve([]):r.getMany({trans:o.trans,keys:u,cache:"immutable"})).then(t=>{let o=u.map((r,o)=>{let u=t[o],c={onerror:null,onsuccess:null};if("delete"===e.type)i.fire.call(c,r,u,l);else if("add"===e.type||void 0===u){let t=a.fire.call(c,r,e.values[o],l);null==r&&null!=t&&(r=t,e.keys[o]=r,n.outbound||sp(e.values[o],n.keyPath,r))}else{let t=uG(u,e.values[o]),n=s.fire.call(c,t,r,u,l);if(n){let t=e.values[o];Object.keys(n).forEach(e=>{a9(t,e)?t[e]=n[e]:sp(t,e,n[e])})}}return c});return r.mutate(e).then(({failures:r,results:n,numFailures:i,lastResult:a})=>{for(let i=0;i<u.length;++i){let a=n?n[i]:u[i],s=o[i];null==a?s.onerror&&s.onerror(r[i]):s.onsuccess&&s.onsuccess("put"===e.type&&t[i]?e.values[i]:a)}return{failures:r,results:n,numFailures:i,lastResult:a}}).catch(e=>(o.forEach(t=>t.onerror&&t.onerror(e)),Promise.reject(e)))})}}}}})};function uY(e,t,r){try{if(!t||t.keys.length<e.length)return null;let n=[];for(let o=0,i=0;o<t.keys.length&&i<e.length;++o)0===un(t.keys[o],e[i])&&(n.push(r?sb(t.values[o]):t.values[o]),++i);return n.length===e.length?n:null}catch(e){return null}}let uZ={stack:"dbcore",level:-1,create:e=>({table:t=>{let r=e.table(t);return{...r,getMany:e=>{if(!e.cache)return r.getMany(e);let t=uY(e.keys,e.trans._cache,"clone"===e.cache);return t?lu.resolve(t):r.getMany(e).then(t=>(e.trans._cache={keys:e.keys,values:"clone"===e.cache?sb(t):t},t))},mutate:e=>("add"!==e.type&&(e.trans._cache=null),r.mutate(e))}}})};function uJ(e){return!("from"in e)}let uX=function(e,t){if(!this){let t=new uX;return e&&"d"in e&&a6(t,e),t}a6(this,arguments.length?{d:1,from:e,to:arguments.length>1?t:e}:{d:0})};function uQ(e,t,r){let n=un(t,r);if(isNaN(n))return;if(n>0)throw RangeError();if(uJ(e))return a6(e,{from:t,to:r,d:1});let o=e.l,i=e.r;if(0>un(r,e.from))return o?uQ(o,t,r):e.l={from:t,to:r,d:1,l:null,r:null},u4(e);if(un(t,e.to)>0)return i?uQ(i,t,r):e.r={from:t,to:r,d:1,l:null,r:null},u4(e);0>un(t,e.from)&&(e.from=t,e.l=null,e.d=i?i.d+1:1),un(r,e.to)>0&&(e.to=r,e.r=null,e.d=e.l?e.l.d+1:1);let a=!e.r;o&&!e.l&&u0(e,o),i&&a&&u0(e,i)}function u0(e,t){uJ(t)||function e(t,{from:r,to:n,l:o,r:i}){uQ(t,r,n),o&&e(t,o),i&&e(t,i)}(e,t)}function u1(e){let t=uJ(e)?null:{s:0,n:e};return{next(e){let r=arguments.length>0;for(;t;)switch(t.s){case 0:if(t.s=1,r)for(;t.n.l&&0>un(e,t.n.from);)t={up:t,n:t.n.l,s:1};else for(;t.n.l;)t={up:t,n:t.n.l,s:1};case 1:if(t.s=2,!r||0>=un(e,t.n.to))return{value:t.n,done:!1};case 2:if(t.n.r){t.s=3,t={up:t,n:t.n.r,s:0};continue}case 3:t=t.up}return{done:!0}}}}function u4(e){var t,r;let n=((null==(t=e.r)?void 0:t.d)||0)-((null==(r=e.l)?void 0:r.d)||0),o=n>1?"r":n<-1?"l":"";if(o){let t="r"===o?"l":"r",r={...e},n=e[o];e.from=n.from,e.to=n.to,e[o]=n[o],r[o]=n[t],e[t]=r,r.d=u3(r)}e.d=u3(e)}function u3({r:e,l:t}){return(e?t?Math.max(e.d,t.d):e.d:t?t.d:0)+1}a7(uX.prototype,{add(e){return u0(this,e),this},addKey(e){return uQ(this,e,e),this},addKeys(e){return e.forEach(e=>uQ(this,e,e)),this},[sx](){return u1(this)}});let u2={stack:"dbcore",level:0,create:e=>{let t=e.schema.name,r=new uX(e.MIN_KEY,e.MAX_KEY);return{...e,table:n=>{let o=e.table(n),{schema:i}=o,{primaryKey:a}=i,{extractKey:s,outbound:l}=a,u={...o,mutate:e=>{let a=e.trans,s=a.mutatedParts||(a.mutatedParts={}),l=e=>{let r=`idb://${t}/${n}/${e}`;return s[r]||(s[r]=new uX)},u=l(""),c=l(":dels"),{type:d}=e,[p,f]="deleteRange"===e.type?[e.range]:"delete"===e.type?[e.keys]:e.values.length<50?[[],e.values]:[],h=e.trans._cache;return o.mutate(e).then(e=>{if(a2(p)){"delete"!==d&&(p=e.results),u.addKeys(p);let t=uY(p,h);t||"add"===d||c.addKeys(p),(t||f)&&i.indexes.forEach(function(e){let r=l(e.name||"");function n(t){return null!=t?e.extractKey(t):null}let o=t=>e.multiEntry&&a2(t)?t.forEach(e=>r.addKey(e)):r.addKey(t);(t||f).forEach((e,r)=>{let i=t&&n(t[r]),a=f&&n(f[r]);0!==un(i,a)&&(null!=i&&o(i),null!=a&&o(a))})})}else if(p){let e={from:p.lower,to:p.upper};c.add(e),u.add(e)}else u.add(r),c.add(r),i.indexes.forEach(e=>l(e.name).add(r));return e})}},c=({query:{index:t,range:r}})=>{var n,o;return[t,new uX(null!=(n=r.lower)?n:e.MIN_KEY,null!=(o=r.upper)?o:e.MAX_KEY)]},d={get:e=>[a,new uX(e.key)],getMany:e=>[a,(new uX).addKeys(e.keys)],count:c,query:c,openCursor:c};return a3(d).forEach(e=>{u[e]=function(i){let{subscr:a}=li;if(a){let u=e=>{let r=`idb://${t}/${n}/${e}`;return a[r]||(a[r]=new uX)},c=u(""),p=u(":dels"),[f,h]=d[e](i);if(u(f.name||"").add(h),!f.isPrimaryKey){if("count"!==e){let t="query"===e&&l&&i.values&&o.query({...i,values:!1});return o[e].apply(this,arguments).then(r=>{if("query"===e){if(l&&i.values)return t.then(({result:e})=>(c.addKeys(e),r));let e=i.values?r.result.map(s):r.result;i.values?c.addKeys(e):p.addKeys(e)}else if("openCursor"===e){let e=i.values;return r&&Object.create(r,{key:{get:()=>(p.addKey(r.primaryKey),r.key)},primaryKey:{get(){let e=r.primaryKey;return p.addKey(e),e}},value:{get:()=>(e&&c.addKey(r.primaryKey),r.value)}})}return r})}p.add(r)}}return o[e].apply(this,arguments)}}),u}}}};class u6{constructor(e,t){var r;this._middlewares={},this.verno=0;const n=u6.dependencies;this._options=t={addons:u6.addons,autoOpen:!0,indexedDB:n.indexedDB,IDBKeyRange:n.IDBKeyRange,...t},this._deps={indexedDB:t.indexedDB,IDBKeyRange:t.IDBKeyRange};const{addons:o}=t;this._dbSchema={},this._versions=[],this._storeNames=[],this._allTables={},this.idbdb=null,this._novip=this;const i={dbOpenError:null,isBeingOpened:!1,onReadyBeingFired:null,openComplete:!1,dbReadyResolve:sW,dbReadyPromise:null,cancelOpen:sW,openCanceller:null,autoSchema:!0,PR1398_maxLoop:3};i.dbReadyPromise=new lu(e=>{i.dbReadyResolve=e}),i.openCanceller=new lu((e,t)=>{i.cancelOpen=t}),this._state=i,this.name=e,this.on=l2(this,"populate","blocked","versionchange","close",{ready:[sJ,sW]}),this.on.ready.subscribe=ss(this.on.ready.subscribe,e=>(t,r)=>{u6.vip(()=>{let n=this._state;if(n.openComplete)n.dbOpenError||lu.resolve().then(t),r&&e(t);else if(n.onReadyBeingFired)n.onReadyBeingFired.push(t),r&&e(t);else{e(t);let n=this;r||e(function e(){n.on.ready.unsubscribe(t),n.on.ready.unsubscribe(e)})}})}),this.Collection=(r=this,l6(ua.prototype,function(e,t){this.db=r;let n=l1,o=null;if(t)try{n=t()}catch(e){o=e}let i=e._ctx,a=i.table,s=a.hook.reading.fire;this._ctx={table:a,index:i.index,isPrimKey:!i.index||a.schema.primKey.keyPath&&i.index===a.schema.primKey.name,range:n,keysOnly:!1,dir:"next",unique:"",algorithm:null,filter:null,replayFilter:null,justLimit:!0,isMatch:null,offset:0,limit:1/0,error:o,or:i.or,valueMapper:s!==sK?s:null}})),this.Table=function(e){return l6(l3.prototype,function(t,r,n){this.db=e,this._tx=n,this.name=t,this.schema=r,this.hook=e._allTables[t]?e._allTables[t].hook:l2(null,{creating:[sG,sW],reading:[sz,sK],updating:[sY,sW],deleting:[sq,sW]})})}(this),this.Transaction=function(e){return l6(u_.prototype,function(t,r,n,o,i){this.db=e,this.mode=t,this.storeNames=r,this.schema=n,this.chromeTransactionDurability=o,this.idbtrans=null,this.on=l2(this,"complete","error","abort"),this.parent=i||null,this.active=!0,this._reculock=0,this._blockedFuncs=[],this._resolve=null,this._reject=null,this._waitingFor=null,this._waitingQueue=null,this._spinCount=0,this._completion=new lu((e,t)=>{this._resolve=e,this._reject=t}),this._completion.then(()=>{this.active=!1,this.on.complete.fire()},e=>{var t=this.active;return this.active=!1,this.on.error.fire(e),this.parent?this.parent._reject(e):t&&this.idbtrans&&this.idbtrans.abort(),lU(e)})})}(this),this.Version=function(e){return l6(uF.prototype,function(t){this.db=e,this._cfg={version:t,storesSource:null,dbschema:{},tables:{},contentUpgrade:null}})}(this),this.WhereClause=function(e){return l6(um.prototype,function(t,r,n){this.db=e,this._ctx={table:t,index:":id"===r?null:r,or:n};let o=e._deps.indexedDB;if(!o)throw new sB.MissingAPI;this._cmp=this._ascending=o.cmp.bind(o),this._descending=(e,t)=>o.cmp(t,e),this._max=(e,t)=>o.cmp(e,t)>0?e:t,this._min=(e,t)=>0>o.cmp(e,t)?e:t,this._IDBKeyRange=e._deps.IDBKeyRange})}(this),this.on("versionchange",e=>{e.newVersion>0?console.warn(`Another connection wants to upgrade database '${this.name}'. Closing db now to resume the upgrade.`):console.warn(`Another connection wants to delete database '${this.name}'. Closing db now to resume the delete request.`),this.close()}),this.on("blocked",e=>{!e.newVersion||e.newVersion<e.oldVersion?console.warn(`Dexie.delete('${this.name}') was blocked`):console.warn(`Upgrade '${this.name}' blocked by other connection holding version ${e.oldVersion/10}`)}),this._maxKey=uD(t.IDBKeyRange),this._createTransaction=(e,t,r,n)=>new this.Transaction(e,t,r,this._options.chromeTransactionDurability,n),this._fireOnBlocked=e=>{this.on("blocked").fire(e),lq.filter(e=>e.name===this.name&&e!==this&&!e._state.vcFired).map(t=>t.on("versionchange").fire(e))},this.use(uH),this.use(uq),this.use(u2),this.use(uZ),this.vip=Object.create(this,{_vip:{value:!0}}),o.forEach(e=>e(this))}version(e){if(isNaN(e)||e<.1)throw new sB.Type("Given version is not a positive number");if(e=Math.round(10*e)/10,this.idbdb||this._state.isBeingOpened)throw new sB.Schema("Cannot add version when database is open");this.verno=Math.max(this.verno,e);let t=this._versions;var r=t.filter(t=>t._cfg.version===e)[0];return r||(r=new this.Version(e),t.push(r),t.sort(uA),r.stores({}),this._state.autoSchema=!1,r)}_whenReady(e){return this.idbdb&&(this._state.openComplete||li.letThrough||this._vip)?e():new lu((e,t)=>{if(this._state.openComplete)return t(new sB.DatabaseClosed(this._state.dbOpenError));if(!this._state.isBeingOpened){if(!this._options.autoOpen)return void t(new sB.DatabaseClosed);this.open().catch(sW)}this._state.dbReadyPromise.then(e,t)}).then(e)}use({stack:e,create:t,level:r,name:n}){n&&this.unuse({stack:e,name:n});let o=this._middlewares[e]||(this._middlewares[e]=[]);return o.push({stack:e,create:t,level:null==r?10:r,name:n}),o.sort((e,t)=>e.level-t.level),this}unuse({stack:e,name:t,create:r}){return e&&this._middlewares[e]&&(this._middlewares[e]=this._middlewares[e].filter(e=>r?e.create!==r:!!t&&e.name!==t)),this}open(){return function(e){var t;let r=e._state,{indexedDB:n}=e._deps;if(r.isBeingOpened||e.idbdb)return r.dbReadyPromise.then(()=>r.dbOpenError?lU(r.dbOpenError):e);sk&&(r.openCanceller._stackHolder=sj()),r.isBeingOpened=!0,r.dbOpenError=null,r.openComplete=!1;let o=r.openCanceller;function i(){if(r.openCanceller!==o)throw new sB.DatabaseClosed("db.open() was cancelled")}let a=r.dbReadyResolve,s=null,l=!1;return lu.race([o,("u"<typeof navigator?lu.resolve():!navigator.userAgentData&&/Safari\//.test(navigator.userAgent)&&!/Chrom(e|ium)\//.test(navigator.userAgent)&&indexedDB.databases?new Promise(function(e){var r=function(){return indexedDB.databases().finally(e)};t=setInterval(r,100),r()}).finally(function(){return clearInterval(t)}):Promise.resolve()).then(()=>new lu((t,o)=>{if(i(),!n)throw new sB.MissingAPI;let a=e.name,u=r.autoSchema?n.open(a):n.open(a,Math.round(10*e.verno));if(!u)throw new sB.MissingAPI;u.onerror=ug(o),u.onblocked=lx(e._fireOnBlocked),u.onupgradeneeded=lx(t=>{if(s=u.transaction,r.autoSchema&&!e._options.allowEmptyDB){u.onerror=uy,s.abort(),u.result.close();let e=n.deleteDatabase(a);e.onsuccess=e.onerror=lx(()=>{o(new sB.NoSuchDatabase(`Database ${a} doesnt exist`))})}else{let r,n,a,p;s.onerror=ug(o);var i,c,d=t.oldVersion>0x4000000000000000?0:t.oldVersion;l=d<1,e._novip.idbdb=u.result,i=d/10,c=s,r=e._dbSchema,(n=e._createTransaction("readwrite",e._storeNames,r)).create(c),n._completion.catch(o),a=n._reject.bind(n),p=li.transless||li,lC(()=>{li.trans=n,li.transless=p,0===i?(a3(r).forEach(e=>{u$(c,e,r[e].primKey,r[e].indexes)}),uj(e,c),lu.follow(()=>e.on.populate.fire(n)).catch(a)):(function({_novip:e},t,r,n){let o=[],i=e._versions,a=e._dbSchema=uM(e,e.idbdb,n),s=!1;return i.filter(e=>e._cfg.version>=t).forEach(i=>{o.push(()=>{let o=a,l=i._cfg.dbschema;uL(e,o,n),uL(e,l,n),a=e._dbSchema=l;let u=uN(o,l);u.add.forEach(e=>{u$(n,e[0],e[1].primKey,e[1].indexes)}),u.change.forEach(e=>{if(e.recreate)throw new sB.Upgrade("Not yet support for changing primary key");{let t=n.objectStore(e.name);e.add.forEach(e=>uI(t,e)),e.change.forEach(e=>{t.deleteIndex(e.name),uI(t,e)}),e.del.forEach(e=>t.deleteIndex(e))}});let c=i._cfg.contentUpgrade;if(c&&i._cfg.version>t){let t;uj(e,n),r._memoizedTables={},s=!0;let i=sf(l);u.del.forEach(e=>{i[e]=o[e]}),uR(e,[e.Transaction.prototype]),uT(e,[e.Transaction.prototype],a3(i),i),r.schema=i;let a=sO(c);a&&lj();let d=lu.follow(()=>{if((t=c(r))&&a){var e=lT.bind(null,null);t.then(e,e)}});return t&&"function"==typeof t.then?lu.resolve(t):d.then(()=>t)}}),o.push(t=>{var n;s&&lY||(n=i._cfg.dbschema,[].slice.call(t.db.objectStoreNames).forEach(e=>null==n[e]&&t.db.deleteObjectStore(e))),uR(e,[e.Transaction.prototype]),uT(e,[e.Transaction.prototype],e._storeNames,e._dbSchema),r.schema=e._dbSchema})}),(function e(){return o.length?lu.resolve(o.shift()(r.idbtrans)).then(e):lu.resolve()})().then(()=>{var e;a3(e=a).forEach(t=>{n.db.objectStoreNames.contains(t)||u$(n,t,e[t].primKey,e[t].indexes)})})})(e,i,n,c).catch(a)})}},o),u.onsuccess=lx(()=>{s=null;let n=e._novip.idbdb=u.result,o=sa(n.objectStoreNames);if(o.length>0)try{let t,i=n.transaction(1===o.length?o[0]:o,"readonly");r.autoSchema?function({_novip:e},t,r){e.verno=t.version/10;let n=e._dbSchema=uM(0,t,r);e._storeNames=sa(t.objectStoreNames,0),uT(e,[e._allTables],a3(n),n)}(e,n,i):(uL(e,e._dbSchema,i),((t=uN(uM(0,e.idbdb,i),e._dbSchema)).add.length||t.change.some(e=>e.add.length||e.change.length))&&console.warn("Dexie SchemaDiff: Schema was extended without increasing the number passed to db.version(). Some queries may fail.")),uj(e,i)}catch(e){}lq.push(e),n.onversionchange=lx(t=>{r.vcFired=!0,e.on("versionchange").fire(t)}),n.onclose=lx(t=>{e.on("close").fire(t)}),l&&function({indexedDB:e,IDBKeyRange:t},r){uV(e)||r===lJ||uB(e,t).put({name:r}).catch(sW)}(e._deps,a),t()},o)}))]).then(()=>(i(),r.onReadyBeingFired=[],lu.resolve(uU(()=>e.on.ready.fire(e.vip))).then(function t(){if(r.onReadyBeingFired.length>0){let n=r.onReadyBeingFired.reduce(sJ,sW);return r.onReadyBeingFired=[],lu.resolve(uU(()=>n(e.vip))).then(t)}}))).finally(()=>{r.onReadyBeingFired=null,r.isBeingOpened=!1}).then(()=>e).catch(t=>{r.dbOpenError=t;try{s&&s.abort()}catch(e){}return o===r.openCanceller&&e._close(),lU(t)}).finally(()=>{r.openComplete=!0,a()})}(this)}_close(){let e=this._state,t=lq.indexOf(this);if(t>=0&&lq.splice(t,1),this.idbdb){try{this.idbdb.close()}catch(e){}this._novip.idbdb=null}e.dbReadyPromise=new lu(t=>{e.dbReadyResolve=t}),e.openCanceller=new lu((t,r)=>{e.cancelOpen=r})}close(){this._close();let e=this._state;this._options.autoOpen=!1,e.dbOpenError=new sB.DatabaseClosed,e.isBeingOpened&&e.cancelOpen(e.dbOpenError)}delete(){let e=arguments.length>0,t=this._state;return new lu((r,n)=>{let o=()=>{this.close();var e=this._deps.indexedDB.deleteDatabase(this.name);e.onsuccess=lx(()=>{!function({indexedDB:e,IDBKeyRange:t},r){uV(e)||r===lJ||uB(e,t).delete(r).catch(sW)}(this._deps,this.name),r()}),e.onerror=ug(n),e.onblocked=this._fireOnBlocked};if(e)throw new sB.InvalidArgument("Arguments not allowed in db.delete()");t.isBeingOpened?t.dbReadyPromise.then(o):o()})}backendDB(){return this.idbdb}isOpen(){return null!==this.idbdb}hasBeenClosed(){let e=this._state.dbOpenError;return e&&"DatabaseClosed"===e.name}hasFailed(){return null!==this._state.dbOpenError}dynamicallyOpened(){return this._state.autoSchema}get tables(){return a3(this._allTables).map(e=>this._allTables[e])}transaction(){let e=uK.apply(this,arguments);return this._transaction.apply(this,e)}_transaction(e,t,r){let n,o,i=li.trans;i&&i.db===this&&-1===e.indexOf("!")||(i=null);let a=-1!==e.indexOf("?");e=e.replace("!","").replace("?","");try{if(o=t.map(e=>{var t=e instanceof this.Table?e.name:e;if("string"!=typeof t)throw TypeError("Invalid table argument to Dexie.transaction(). Only Table or String are allowed");return t}),"r"==e||e===lX)n=lX;else{if("rw"!=e&&e!=lQ)throw new sB.InvalidArgument("Invalid transaction mode: "+e);n=lQ}if(i){if(i.mode===lX&&n===lQ){if(!a)throw new sB.SubTransaction("Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY");i=null}i&&o.forEach(e=>{if(i&&-1===i.storeNames.indexOf(e)){if(!a)throw new sB.SubTransaction("Table "+e+" not included in parent transaction.");i=null}}),a&&i&&!i.active&&(i=null)}}catch(e){return i?i._promise(null,(t,r)=>{r(e)}):lU(e)}let s=(function e(t,r,n,o,i){return lu.resolve().then(()=>{let a,s=li.transless||li,l=t._createTransaction(r,n,t._dbSchema,o);if(o)l.idbtrans=o.idbtrans;else try{l.create(),t._state.PR1398_maxLoop=3}catch(o){return o.name===sF.InvalidState&&t.isOpen()&&--t._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),t._close(),t.open().then(()=>e(t,r,n,null,i))):lU(o)}let u=sO(i);u&&lj();let c=lu.follow(()=>{if(a=i.call(l,l))if(u){var e=lT.bind(null,null);a.then(e,e)}else"function"==typeof a.next&&"function"==typeof a.throw&&(a=uW(a))},{trans:l,transless:s});return(a&&"function"==typeof a.then?lu.resolve(a).then(e=>l.active?e:lU(new sB.PrematureCommit("Transaction committed too early. See http://bit.ly/2kdckMn"))):c.then(()=>a)).then(e=>(o&&l._resolve(),l._completion.then(()=>e))).catch(e=>(l._reject(e),lU(e)))})}).bind(null,this,n,o,i,r);return i?i._promise(n,s,"lock"):li.trans?lM(li.transless,()=>this._whenReady(s)):this._whenReady(s)}table(e){if(!a9(this._allTables,e))throw new sB.InvalidTable(`Table ${e} does not exist`);return this._allTables[e]}}let u5="u">typeof Symbol&&"observable"in Symbol?Symbol.observable:"@@observable";class u8{constructor(e){this._subscribe=e}subscribe(e,t,r){return this._subscribe(e&&"function"!=typeof e?e:{next:e,error:t,complete:r})}[u5](){return this}}function u9(e,t){return a3(t).forEach(r=>{u0(e[r]||(e[r]=new uX),t[r])}),e}try{i={indexedDB:a4.indexedDB||a4.mozIndexedDB||a4.webkitIndexedDB||a4.msIndexedDB,IDBKeyRange:a4.IDBKeyRange||a4.webkitIDBKeyRange}}catch(e){i={indexedDB:null,IDBKeyRange:null}}function u7(e){let t=ce;try{ce=!0,uw.storagemutated.fire(e)}finally{ce=t}}a7(u6,{...sU,delete:e=>new u6(e,{addons:[]}).delete(),exists:e=>new u6(e,{addons:[]}).open().then(e=>(e.close(),!0)).catch("NoSuchDatabaseError",()=>!1),getDatabaseNames(e){try{return(function({indexedDB:e,IDBKeyRange:t}){return uV(e)?Promise.resolve(e.databases()).then(e=>e.map(e=>e.name).filter(e=>e!==lJ)):uB(e,t).toCollection().primaryKeys()})(u6.dependencies).then(e)}catch(e){return lU(new sB.MissingAPI)}},defineClass:()=>function(e){a6(this,e)},ignoreTransaction:e=>li.trans?lM(li.transless,e):e(),vip:uU,async:function(e){return function(){try{var t=uW(e.apply(this,arguments));return t&&"function"==typeof t.then?t:lu.resolve(t)}catch(e){return lU(e)}}},spawn:function(e,t,r){try{var n=uW(e.apply(r,t||[]));return n&&"function"==typeof n.then?n:lu.resolve(n)}catch(e){return lU(e)}},currentTransaction:{get:()=>li.trans||null},waitFor:function(e,t){let r=lu.resolve("function"==typeof e?u6.ignoreTransaction(e):e).timeout(t||6e4);return li.trans?li.trans.waitFor(r):r},Promise:lu,debug:{get:()=>sk,set:e=>{sk=e,sP="dexie"===e?()=>!0:lZ}},derive:sr,extend:a6,props:a7,override:ss,Events:l2,on:uw,liveQuery:function(e){let t,r=!1,n=new u8(n=>{let o=sO(e),i=!1,a={},s={},l={get closed(){return i},unsubscribe:()=>{i=!0,uw.storagemutated.unsubscribe(p)}};n.start&&n.start(l);let u=!1,c=!1;function d(){return a3(s).some(e=>a[e]&&function(e,t){let r=u1(t),n=r.next();if(n.done)return!1;let o=n.value,i=u1(e),a=i.next(o.from),s=a.value;for(;!n.done&&!a.done;){if(0>=un(s.from,o.to)&&un(s.to,o.from)>=0)return!0;0>un(o.from,s.from)?o=(n=r.next(s.from)).value:s=(a=i.next(o.from)).value}return!1}(a[e],s[e]))}let p=e=>{u9(a,e),d()&&f()},f=()=>{let h,m;if(u||i)return;a={};let g={},y=(o&&lj(),h=()=>lC(e,{subscr:g,trans:null}),m=li.trans?lM(li.transless,h):h(),o&&m.then(lT,lT),m);c||(uw(uv,p),c=!0),u=!0,Promise.resolve(y).then(e=>{r=!0,t=e,u=!1,i||(d()?f():(a={},s=g,n.next&&n.next(e)))},e=>{u=!1,r=!1,n.error&&n.error(e),l.unsubscribe()})};return f(),l});return n.hasValue=()=>r,n.getValue=()=>t,n},extendObservabilitySet:u9,getByKeyPath:sd,setByKeyPath:sp,delByKeyPath:function(e,t){"string"==typeof t?sp(e,t,void 0):"length"in t&&[].map.call(t,function(t){sp(e,t,void 0)})},shallowClone:sf,deepClone:sb,getObjectDiff:uG,cmp:un,asap:su,minKey:lz,addons:[],connections:lq,errnames:sF,dependencies:i,semVer:lW,version:lW.split(".").map(e=>parseInt(e)).reduce((e,t,r)=>e+t/Math.pow(10,2*r))}),u6.maxKey=uD(u6.dependencies.IDBKeyRange),"u">typeof dispatchEvent&&"u">typeof addEventListener&&(uw(uv,e=>{if(!ce){let t;lY?(t=document.createEvent("CustomEvent")).initCustomEvent(ub,!0,!0,e):t=new CustomEvent(ub,{detail:e}),ce=!0,dispatchEvent(t),ce=!1}}),addEventListener(ub,({detail:e})=>{ce||u7(e)}));let ce=!1;if("u">typeof BroadcastChannel){let e=new BroadcastChannel(ub);"function"==typeof e.unref&&e.unref(),uw(uv,t=>{ce||e.postMessage(t)}),e.onmessage=e=>{e.data&&u7(e.data)}}else if("u">typeof self&&"u">typeof navigator){uw(uv,e=>{try{ce||("u">typeof localStorage&&localStorage.setItem(ub,JSON.stringify({trig:Math.random(),changedParts:e})),"object"==typeof self.clients&&[...self.clients.matchAll({includeUncontrolled:!0})].forEach(t=>t.postMessage({type:ub,changedParts:e})))}catch(e){}}),"u">typeof addEventListener&&addEventListener("storage",e=>{if(e.key===ub){let t=JSON.parse(e.newValue);t&&u7(t.changedParts)}});let e=self.document&&navigator.serviceWorker;e&&e.addEventListener("message",function({data:e}){e&&e.type===ub&&u7(e.changedParts)})}function ct(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}lu.rejectionMapper=function(e,t){if(!e||e instanceof s$||e instanceof TypeError||e instanceof SyntaxError||!e.name||!sV[e.name])return e;var r=new sV[e.name](t||e.message,e);return"stack"in e&&st(r,"stack",{get:function(){return this.inner.stack}}),r},sP=lZ;class cr extends u6{constructor(){super("EsmOffline"),ct(this,"syncQueue",void 0),ct(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 cn(){return new cr}let co=new cr,ci={},ca=q("offline-synchronization",{});function cs(){return ca}async function cl(){if(ca.getState().synchronization)return;let e=await co.syncQueue.count(),t={},r=Object.entries(ci),n=r.length,o={},i=new AbortController,a=()=>{let e=ca.getState().synchronization;ca.setState({synchronization:{...e,pendingCount:e.pendingCount-1}})};try{ca.setState({synchronization:{totalCount:e,pendingCount:e,abortController:i}});for(let e=0;e<n&&r.length>0;e++)for(let e=r.length;e--;){let[n,s]=r[e],l=s.dependsOn.map(e=>t[e]);l.every(Boolean)&&(o[n]={},await Promise.all(l),t[n]=cu(s,o,i,a),r.splice(e,1))}await Promise.allSettled(Object.values(t))}finally{ca.setState({synchronization:void 0})}}async function cu({type:e,dependsOn:t,process:r},n,o,i){let a=[],s=[],l=await cc();await co.syncQueue.where({type:e,userId:l}).each((e,t)=>{a.push([t.primaryKey,e.content,e.descriptor]),s.push(e.content)});for(let u=0;u<a.length;u++){let[c,d,{id:p,dependencies:f=[]}]=a[u];try{let i=await r(d,{abort:o,index:u,items:s,userId:l,dependencies:f.map(({id:e,type:r})=>t.includes(r)?n[r][e]:void 0)});void 0!==p&&(n[e][p]=i),await co.syncQueue.delete(c)}catch(e){await co.syncQueue.update(c,{lastError:{name:e?.name,message:e?.message??e?.toString()}})}finally{i()}}}async function cc(){let e=await oZ();return e?.uuid||"*"}async function cd(e,t,r,n){let o=n&&n.id;return void 0!==o&&await co.syncQueue.where({type:t,userId:e}).filter(e=>e?.descriptor.id===o).delete().catch(u6.errnames.DatabaseClosed),await co.syncQueue.add({type:t,content:r,userId:e,descriptor:n||{},createdOn:new Date}).catch(u6.errnames.DatabaseClosed,()=>-1)}async function cp(e,t,r){let n=await cc();return await cd(n,e,t,r)}async function cf(e,t){return(await ch(e,t)).map(e=>e.content)}async function ch(e,t){return await co.syncQueue.where(t?{type:t,userId:e}:{userId:e}).toArray().catch(u6.errnames.DatabaseClosed,()=>[])}async function cm(e){let t=await cc();return await cf(t,e)}async function cg(e){let t=await cc();return await ch(t,e)}async function cy(e){return await co.syncQueue.get(e).catch(u6.errnames.DatabaseClosed,()=>void 0)}function cv(e){return!!ci[e]?.options.onBeginEditSyncItem}async function cb(e){let t=await cy(e);if(!t)throw Error(`No sync item with the ID ${e} exists.`);let r=ci[t.type]?.options.onBeginEditSyncItem;if(!r)throw Error(`A sync item with the ID ${e} exists, but the associated handler (if one exists) doesn't support editing the item. You can avoid this error by either verifying that sync items of this type can be edited via the "canEditSynchronizationItemsOfType(type: string)" function or alternatively ensure that the synchronizaton handler for sync items of type "${t.type}" supports editing items.`);r(t)}async function cw(e){await co.syncQueue.delete(e).catch(u6.errnames.DatabaseClosed)}function c_(e,t,r,n={}){ci[e]={type:e,dependsOn:t,process:r,options:n}}let cx="u">typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),cE=new Uint8Array(16),cS=[];for(let e=0;e<256;++e)cS.push((e+256).toString(16).slice(1));let cD=function(e,t,r){if(cx&&!t&&!e)return cx();let n=(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(cE)})();if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,t){r=r||0;for(let e=0;e<16;++e)t[r+e]=n[e];return t}return function(e,t=0){return cS[e[t+0]]+cS[e[t+1]]+cS[e[t+2]]+cS[e[t+3]]+"-"+cS[e[t+4]]+cS[e[t+5]]+"-"+cS[e[t+6]]+cS[e[t+7]]+"-"+cS[e[t+8]]+cS[e[t+9]]+"-"+cS[e[t+10]]+cS[e[t+11]]+cS[e[t+12]]+cS[e[t+13]]+cS[e[t+14]]+cS[e[t+15]]}(n)},cO="OFFLINE+";function ck(){return cO+cD()}function cP(e){return e.startsWith(cO)}let cC={};function cj(){return Object.values(cC)}function cT(e){cC[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.`),cC[e.id]=e}async function cR(e){let t=await cB();return await cA(t,e)}async function cA(e,t){let r=new cr;return await r.dynamicOfflineData.where(t?{type:t,users:e}:{users:e}).toArray().catch(u6.errnames.DatabaseClosed,()=>[])}async function cN(e,t){let r=await cB();return await c$(r,e,t)}async function c$(e,t,r){let n=new cr,o=await n.dynamicOfflineData.get({type:t,identifier:r}).catch(u6.errnames.DatabaseClosed,()=>void 0);o?o.users.includes(e)||await n.dynamicOfflineData.update(o.id,{users:[...o.users,e]}).catch(u6.errnames.DatabaseClosed):await n.dynamicOfflineData.add({users:[e],type:t,identifier:r}).catch(u6.errnames.DatabaseClosed)}async function cI(e,t){let r=await cB();return await cM(r,e,t)}async function cM(e,t,r){let n=new cr,o=await n.dynamicOfflineData.get({type:t,identifier:r,users:e}).catch(u6.errnames.DatabaseClosed,()=>void 0);o&&(o.users.length>1?await n.dynamicOfflineData.update(o.id,{users:o.users.filter(t=>t!==e)}).catch(u6.errnames.DatabaseClosed):await n.dynamicOfflineData.delete(o.id).catch(u6.errnames.DatabaseClosed))}async function cL(e,t){let r=await cR(e);await Promise.all(r.map(async e=>cF(e.type,e.identifier,t)))}async function cF(e,t,r){await cN(e,t);let n=new cr,o=await cB(),i=await n.dynamicOfflineData.get({type:e,identifier:t}).catch(u6.errnames.DatabaseClosed,()=>void 0),a=cj().filter(t=>t.type===e);if(!i)return;let s=await Promise.all(a.map(async e=>{try{return e.sync(t,r),{id:e.id,error:void 0}}catch(r){let t=r.message?.toString()??r.toString();return{id:e.id,error:t}}})),l=s.filter(e=>!e.error).map(e=>e.id),u=s.filter(e=>e.error).map(e=>e.id),c=s.filter(e=>e.error).map(e=>({handlerId:e.id,message:e.error})),d={syncedOn:new Date,syncedBy:o,succeededHandlers:l,erroredHandlers:u,errors:c};i.id&&await n.dynamicOfflineData.update(i.id,{syncState:d}).catch(u6.errnames.DatabaseClosed)}async function cB(){let e=(await oZ()).uuid;if(!e)throw Error("Using the dynamic offline data API requires a logged in user.");return e}let cV=q("offline-patients",{offlinePatientDataSyncState:{},handlers:{}});function cU(){return cz(),cV}function cW(e,t){cz(),cT({type:"patient",displayName:t.displayName,id:e,isSynced:()=>Promise.resolve(!0),sync:(e,r)=>t.onOfflinePatientAdded({patientUuid:e,signal:r??new AbortController().signal})})}async function cK(e){cz(),await cF("patient",e)}function cz(){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 cH(e,t,r=!0){if(e){let n=null,[o,i]=await Promise.all([oF(`${oI}/Patient/${e}`,t).catch(e=>n=e),r?cG(e):Promise.resolve(null)]);if(o.ok)return o.data;if(i)return i;if(n)throw n}return null}async function cG(e){let t=(await cm("patient-registration")).find(t=>t.fhirPatient.id===e);return t?.fhirPatient??null}function cq(e,t){let r=new CustomEvent(`openmrs:${e}`,{detail:t??void 0,cancelable:!0,bubbles:!0});return window.dispatchEvent(r)}function cY(e,t){let r=e=>{t("detail"in e&&null!==e.detail?e.detail:void 0)};return window.addEventListener(`openmrs:${e}`,r),()=>{window.removeEventListener(`openmrs:${e}`,r)}}var cZ=r(6170);function cJ(e){return{uuid:e.uuid,display:e.display}}function cX(e=null,t=null){let r=new URLSearchParams;e&&r.set("tag",e),t&&r.set("q",t);let n=r.toString();return oB(`${o$}/location${n?"?"+n:""}`).pipe((0,cZ.map)(e=>e.data.results.map(cJ))).pipe((0,cZ.take)(1))}function cQ(e){return{uuid:e.uuid,display:e.display,name:e.name}}function c0(){return oB(`${o$}/visittype`).pipe((0,cZ.map)(e=>e.data.results.map(cQ))).pipe((0,cZ.take)(1))}var c1=((eo={}).NEWVISIT="startVisit",eo.EDITVISIT="editVisit",eo.LOADING="loadingVisit",eo),c4=((ei={}).NOTSTARTED="notStarted",ei.ONGOING="ongoing",ei);let c3="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))",c2=function(){try{return JSON.parse(sessionStorage.getItem("openmrs:visitStoreState")||"null")}catch(e){return null}}()||{patientUuid:null,manuallySetVisitUuid:null};function c6(){return Z("visit",c2)}function c5(e,t){c6().setState({patientUuid:e,manuallySetVisitUuid:t})}function c8(e,t){return oF(`${o$}/visit`,{signal:t.signal,method:"POST",headers:{"Content-type":"application/json"},body:e})}function c9(e,t,r){return oF(`${o$}/visit/${e}`,{signal:r.signal,method:"POST",headers:{"Content-type":"application/json"},body:t})}function c7(e,t,r){return oF(`${o$}/visit?patient=${e}&v=${r??c3}`,{signal:t.signal,method:"GET",headers:{"Content-type":"application/json"}})}c6().subscribe(e=>{var t;t=e,sessionStorage.setItem("openmrs:visitStoreState",JSON.stringify(t))});let de=new el.BehaviorSubject(null);class dt{static get version(){return"1.4.0"}static toString(){return"JavaScript Expression Parser (JSEP) v"+dt.version}static addUnaryOp(e){return dt.max_unop_len=Math.max(e.length,dt.max_unop_len),dt.unary_ops[e]=1,dt}static addBinaryOp(e,t,r){return dt.max_binop_len=Math.max(e.length,dt.max_binop_len),dt.binary_ops[e]=t,r?dt.right_associative.add(e):dt.right_associative.delete(e),dt}static addIdentifierChar(e){return dt.additional_identifier_chars.add(e),dt}static addLiteral(e,t){return dt.literals[e]=t,dt}static removeUnaryOp(e){return delete dt.unary_ops[e],e.length===dt.max_unop_len&&(dt.max_unop_len=dt.getMaxKeyLen(dt.unary_ops)),dt}static removeAllUnaryOps(){return dt.unary_ops={},dt.max_unop_len=0,dt}static removeIdentifierChar(e){return dt.additional_identifier_chars.delete(e),dt}static removeBinaryOp(e){return delete dt.binary_ops[e],e.length===dt.max_binop_len&&(dt.max_binop_len=dt.getMaxKeyLen(dt.binary_ops)),dt.right_associative.delete(e),dt}static removeAllBinaryOps(){return dt.binary_ops={},dt.max_binop_len=0,dt}static removeLiteral(e){return delete dt.literals[e],dt}static removeAllLiterals(){return dt.literals={},dt}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 dt(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 dt.binary_ops[e]||0}static isIdentifierStart(e){return e>=65&&e<=90||e>=97&&e<=122||e>=128&&!dt.binary_ops[String.fromCharCode(e)]||dt.additional_identifier_chars.has(String.fromCharCode(e))}static isIdentifierPart(e){return dt.isIdentifierStart(e)||dt.isDecimalDigit(e)}throwError(e){let t=Error(e+" at character "+this.index);throw t.index=this.index,t.description=e,t}runHook(e,t){if(dt.hooks[e]){let r={context:this,node:t};return dt.hooks.run(e,r),r.node}return t}searchHook(e){if(dt.hooks[e]){let t={context:this};return dt.hooks[e].find(function(e){return e.call(t.context,t),t.node}),t.node}}gobbleSpaces(){let e=this.code;for(;e===dt.SPACE_CODE||e===dt.TAB_CODE||e===dt.LF_CODE||e===dt.CR_CODE;)e=this.expr.charCodeAt(++this.index);this.runHook("gobble-spaces")}parse(){this.runHook("before-all");let e=this.gobbleExpressions(),t=1===e.length?e[0]:{type:dt.COMPOUND,body:e};return this.runHook("after-all",t)}gobbleExpressions(e){let t=[],r,n;for(;this.index<this.expr.length;)if((r=this.code)===dt.SEMCOL_CODE||r===dt.COMMA_CODE)this.index++;else if(n=this.gobbleExpression())t.push(n);else if(this.index<this.expr.length){if(r===e)break;this.throwError('Unexpected "'+this.char+'"')}return t}gobbleExpression(){let e=this.searchHook("gobble-expression")||this.gobbleBinaryExpression();return this.gobbleSpaces(),this.runHook("after-expression",e)}gobbleBinaryOp(){this.gobbleSpaces();let e=this.expr.substr(this.index,dt.max_binop_len),t=e.length;for(;t>0;){if(dt.binary_ops.hasOwnProperty(e)&&(!dt.isIdentifierStart(this.code)||this.index+e.length<this.expr.length&&!dt.isIdentifierPart(this.expr.charCodeAt(this.index+e.length))))return this.index+=t,e;e=e.substr(0,--t)}return!1}gobbleBinaryExpression(){let e,t,r,n,o,i,a,s,l;if(!(i=this.gobbleToken())||!(t=this.gobbleBinaryOp()))return i;for(o={value:t,prec:dt.binaryPrecedence(t),right_a:dt.right_associative.has(t)},(a=this.gobbleToken())||this.throwError("Expected expression after "+t),n=[i,o,a];t=this.gobbleBinaryOp();){if(0===(r=dt.binaryPrecedence(t))){this.index-=t.length;break}o={value:t,prec:r,right_a:dt.right_associative.has(t)},l=t;let s=e=>o.right_a&&e.right_a?r>e.prec:r<=e.prec;for(;n.length>2&&s(n[n.length-2]);)a=n.pop(),t=n.pop().value,i=n.pop(),e={type:dt.BINARY_EXP,operator:t,left:i,right:a},n.push(e);(e=this.gobbleToken())||this.throwError("Expected expression after "+l),n.push(o,e)}for(s=n.length-1,e=n[s];s>1;)e={type:dt.BINARY_EXP,operator:n[s-1].value,left:n[s-2],right:e},s-=2;return e}gobbleToken(){let e,t,r,n;if(this.gobbleSpaces(),n=this.searchHook("gobble-token"))return this.runHook("after-token",n);if(e=this.code,dt.isDecimalDigit(e)||e===dt.PERIOD_CODE)return this.gobbleNumericLiteral();if(e===dt.SQUOTE_CODE||e===dt.DQUOTE_CODE)n=this.gobbleStringLiteral();else if(e===dt.OBRACK_CODE)n=this.gobbleArray();else{for(r=(t=this.expr.substr(this.index,dt.max_unop_len)).length;r>0;){if(dt.unary_ops.hasOwnProperty(t)&&(!dt.isIdentifierStart(this.code)||this.index+t.length<this.expr.length&&!dt.isIdentifierPart(this.expr.charCodeAt(this.index+t.length)))){this.index+=r;let e=this.gobbleToken();return e||this.throwError("missing unaryOp argument"),this.runHook("after-token",{type:dt.UNARY_EXP,operator:t,argument:e,prefix:!0})}t=t.substr(0,--r)}dt.isIdentifierStart(e)?(n=this.gobbleIdentifier(),dt.literals.hasOwnProperty(n.name)?n={type:dt.LITERAL,value:dt.literals[n.name],raw:n.name}:n.name===dt.this_str&&(n={type:dt.THIS_EXP})):e===dt.OPAREN_CODE&&(n=this.gobbleGroup())}return n?(n=this.gobbleTokenProperty(n),this.runHook("after-token",n)):this.runHook("after-token",!1)}gobbleTokenProperty(e){this.gobbleSpaces();let t=this.code;for(;t===dt.PERIOD_CODE||t===dt.OBRACK_CODE||t===dt.OPAREN_CODE||t===dt.QUMARK_CODE;){let r;if(t===dt.QUMARK_CODE){if(this.expr.charCodeAt(this.index+1)!==dt.PERIOD_CODE)break;r=!0,this.index+=2,this.gobbleSpaces(),t=this.code}this.index++,t===dt.OBRACK_CODE?((e={type:dt.MEMBER_EXP,computed:!0,object:e,property:this.gobbleExpression()}).property||this.throwError('Unexpected "'+this.char+'"'),this.gobbleSpaces(),(t=this.code)!==dt.CBRACK_CODE&&this.throwError("Unclosed ["),this.index++):t===dt.OPAREN_CODE?e={type:dt.CALL_EXP,arguments:this.gobbleArguments(dt.CPAREN_CODE),callee:e}:(t===dt.PERIOD_CODE||r)&&(r&&this.index--,this.gobbleSpaces(),e={type:dt.MEMBER_EXP,computed:!1,object:e,property:this.gobbleIdentifier()}),r&&(e.optional=!0),this.gobbleSpaces(),t=this.code}return e}gobbleNumericLiteral(){let e="",t,r;for(;dt.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);if(this.code===dt.PERIOD_CODE)for(e+=this.expr.charAt(this.index++);dt.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);if("e"===(t=this.char)||"E"===t){for(e+=this.expr.charAt(this.index++),("+"===(t=this.char)||"-"===t)&&(e+=this.expr.charAt(this.index++));dt.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);dt.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+e+this.char+")")}return r=this.code,dt.isIdentifierStart(r)?this.throwError("Variable names cannot start with a number ("+e+this.char+")"):(r===dt.PERIOD_CODE||1===e.length&&e.charCodeAt(0)===dt.PERIOD_CODE)&&this.throwError("Unexpected period"),{type:dt.LITERAL,value:parseFloat(e),raw:e}}gobbleStringLiteral(){let e="",t=this.index,r=this.expr.charAt(this.index++),n=!1;for(;this.index<this.expr.length;){let t=this.expr.charAt(this.index++);if(t===r){n=!0;break}if("\\"===t)switch(t=this.expr.charAt(this.index++)){case"n":e+="\n";break;case"r":e+="\r";break;case"t":e+=" ";break;case"b":e+="\b";break;case"f":e+="\f";break;case"v":e+="\v";break;default:e+=t}else e+=t}return n||this.throwError('Unclosed quote after "'+e+'"'),{type:dt.LITERAL,value:e,raw:this.expr.substring(t,this.index)}}gobbleIdentifier(){let e=this.code,t=this.index;for(dt.isIdentifierStart(e)?this.index++:this.throwError("Unexpected "+this.char);this.index<this.expr.length;)if(e=this.code,dt.isIdentifierPart(e))this.index++;else break;return{type:dt.IDENTIFIER,name:this.expr.slice(t,this.index)}}gobbleArguments(e){let t=[],r=!1,n=0;for(;this.index<this.expr.length;){this.gobbleSpaces();let o=this.code;if(o===e){r=!0,this.index++,e===dt.CPAREN_CODE&&n&&n>=t.length&&this.throwError("Unexpected token "+String.fromCharCode(e));break}if(o===dt.COMMA_CODE){if(this.index++,++n!==t.length){if(e===dt.CPAREN_CODE)this.throwError("Unexpected token ,");else if(e===dt.CBRACK_CODE)for(let e=t.length;e<n;e++)t.push(null)}}else if(t.length!==n&&0!==n)this.throwError("Expected comma");else{let e=this.gobbleExpression();e&&e.type!==dt.COMPOUND||this.throwError("Expected comma"),t.push(e)}}return r||this.throwError("Expected "+String.fromCharCode(e)),t}gobbleGroup(){this.index++;let e=this.gobbleExpressions(dt.CPAREN_CODE);if(this.code===dt.CPAREN_CODE)return(this.index++,1===e.length)?e[0]:!!e.length&&{type:dt.SEQUENCE_EXP,expressions:e};this.throwError("Unclosed (")}gobbleArray(){return this.index++,{type:dt.ARRAY_EXP,elements:this.gobbleArguments(dt.CBRACK_CODE)}}}Object.assign(dt,{hooks:new class{add(e,t,r){if("string"!=typeof arguments[0])for(let e in arguments[0])this.add(e,arguments[0][e],arguments[1]);else(Array.isArray(e)?e:[e]).forEach(function(e){this[e]=this[e]||[],t&&this[e][r?"unshift":"push"](t)},this)}run(e,t){this[e]=this[e]||[],this[e].forEach(function(e){e.call(t&&t.context?t.context:t,t)})}},plugins:new class{constructor(e){this.jsep=e,this.registered={}}register(...e){e.forEach(e=>{if("object"!=typeof e||!e.name||!e.init)throw Error("Invalid JSEP plugin format");this.registered[e.name]||(e.init(this.jsep),this.registered[e.name]=e)})}}(dt),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"}),dt.max_unop_len=dt.getMaxKeyLen(dt.unary_ops),dt.max_binop_len=dt.getMaxKeyLen(dt.binary_ops);let dr=e=>new dt(e).parse(),dn=Object.getOwnPropertyNames(class{});Object.getOwnPropertyNames(dt).filter(e=>!dn.includes(e)&&void 0===dr[e]).forEach(e=>{dr[e]=dt[e]}),dr.Jsep=dt,dr.plugins.register({name:"ternary",init(e){e.hooks.add("after-expression",function(t){if(t.node&&this.code===e.QUMARK_CODE){this.index++;let r=t.node,n=this.gobbleExpression();if(n||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===e.COLON_CODE){this.index++;let o=this.gobbleExpression();if(o||this.throwError("Expected expression"),t.node={type:"ConditionalExpression",test:r,consequent:n,alternate:o},r.operator&&e.binary_ops[r.operator]<=.9){let n=r;for(;n.right.operator&&e.binary_ops[n.right.operator]<=.9;)n=n.right;t.node.test=n.right,n.right=t.node,t.node=r}}else this.throwError("Expected :")}})}});let di="ArrowFunctionExpression",da={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)}},ds={...da,Promise};function dl(e,t={}){return dh(e,t,dy)}async function du(e,t={}){return dm(e,t,dy)}function dc(e,t={}){return dh(e,t,dv)}function dd(e,t={}){return dm(e,t,dv)}function dp(e,t={}){return dh(e,t,db)}function df(e,t={}){return dm(e,t,db)}function dh(e,t={},r){if("string"!=typeof e&&("object"!=typeof e||!e||!("type"in e)))throw`Unknown expression type ${e}. Expressions must either be a string or pre-compiled string.`;if("string"==typeof e&&0===e.trim().length)throw{type:"Empty expression",message:"Expression cannot be an empty string"};null==t&&(t={});let n=dx(t,da),o=dw("string"==typeof e?dr(e):e,n);if(r(o))return o;throw{type:"Invalid result",message:"string"==typeof e?`The expression ${e} did not produce a valid result`:"The expression did not produce a valid result"}}async function dm(e,t={},r){if("string"!=typeof e&&("object"!=typeof e||!e||!("type"in e)))return Promise.reject(`Unknown expression type ${e}. Expressions must either be a string or pre-compiled string.`);if("string"==typeof e&&0===e.trim().length)throw{type:"Empty expression",message:"Expression cannot be an empty string"};null==t&&(t={});let n=dx(t,ds);return Promise.resolve(dw("string"==typeof e?dr(e):e,n)).then(t=>{if(r(t))return t;throw{type:"Invalid result",message:"string"==typeof e?`The expression ${e} did not produce a valid result`:"The expression did not produce a valid result"}})}function dg(e){return dr(e)}function dy(e){return"string"==typeof e||"number"==typeof e||"boolean"==typeof e||null==e||e instanceof Date}function dv(e){return"boolean"==typeof e}function db(e){return"number"==typeof e}function dw(e,t){switch(e.type){case"UnaryExpression":var r,n,o,i,a,s,l,u,c,d,p,f,h=e,m=t;let g=dw(h.argument,m);switch(h.operator){case"+":return+g;case"-":return-g;case"~":return~g;case"!":return!g;default:throw`Expression evaluator does not support operator '${h.operator}''`}case"BinaryExpression":var y=e,v=t;let b=dw(y.left,v),w=dw(y.right,v);switch(y.operator){case"+":return b+w;case"-":return b-w;case"*":return b*w;case"/":return b/w;case"%":return b%w;case"**":return b**w;case"==":return b==w;case"===":return b===w;case"!=":return b!=w;case"!==":return b!==w;case">":return b>w;case">=":return b>=w;case"<":return b<w;case"<=":return b<=w;case"in":return b in w;case"&&":return b&&w;case"||":return b||w;case"??":return b??w;default:throw`Expression evaluator does not support operator '${y.operator}' operator`}case"ConditionalExpression":return r=e,n=t,dw(r.test,n)?dw(r.consequent,n):dw(r.alternate,n);case"CallExpression":var x=e,E=t;let S=x.arguments?.map(dE(E)),D=dw(x.callee,E);if(D){if("function"!=typeof D)throw`${dD(x.callee)} is not a function`}else throw`No function named ${dD(x.callee)} is defined in this context`;return D(...S);case"ArrowFunctionExpression":let O;return o=e,i=t,O=o.params?.map(e=>{if("Identifier"===e.type)return e.name;throw`Cannot handle parameter of type ${e.type}`})??[],(function(...e){if(e.length<O.length)throw`Required argument(s) ${O.slice(e.length,-1).join(", ")} were not provided`;let t=Object.fromEntries(O.reduce((t,r,n)=>{let o=e[n];return function e(t){if("string"==typeof t||"number"==typeof t||"boolean"==typeof t||"function"==typeof t||null===t||t instanceof RegExp)return!0;if("object"==typeof t){for(let r of Object.keys(t))if(!e(t[r]))return!1;return!0}if(Array.isArray(t)){for(let r of t)if(!e(r))break}return!1}(o)&&t.push([r,o]),t},[]));return dw(o.body,i.addVariables(t))}).bind(i.thisObj??null);case"MemberExpression":return function(e,t){let r,n=dw(e.object,t);if(void 0===n)switch(e.object.type){case"Identifier":{let r=d_(e.object,t);throw ReferenceError(`ReferenceError: ${r} is not defined`)}case"MemberExpression":{let r=d_(e.property,t);throw TypeError(`TypeError: cannot read properties of undefined (reading '${r}')`)}default:throw`VisitMemberExpression does not support operator '${e.object.type}' type`}let o=n;if("string"==typeof n)o=String.prototype;else if("number"==typeof n)o=Number.prototype;else if("function"==typeof n);else if("object"!=typeof n)throw`VisitMemberExpression does not support member access on type ${typeof n}`;switch(t.thisObj=o,e.property.type){case"Identifier":case"MemberExpression":r=dw(e.property,t);break;default:{let o=dw(e.property,t);if(void 0===o)throw{type:"Illegal property access",message:"No property was supplied to the property access"};dS(o),r=n[o]}}return"function"==typeof r?r.bind(n):r}(e,t);case"ArrayExpression":return a=e,s=t,a.elements?.map(dE(s));case"SequenceExpression":let k;return l=e,u=t,(k=l.expressions.map(dE(u)))[k.length-1];case"NewExpression":var P=e,C=t;if(P.callee&&"Identifier"===P.callee.type){let e=P.arguments?.map(dE(C));switch(P.callee.name){case"Date":return new Date(...e);case"RegExp":return new RegExp(...e);default:throw`Cannot instantiate object of type ${P.callee.name}`}}if(P.callee)throw"new must be called with either Date or RegExp";throw'Could not handle "new" without a specified class';case"Literal":return dS((c=e).value),c.value;case"Identifier":var j=e,T=t;dS(j.name);let R=T.thisObj;if(R&&("object"==typeof R||"function"==typeof R)&&j.name in R){let e=R[j.name];return dS(e),e}if(T.variables&&j.name in T.variables){let e=T.variables[j.name];return dS(e),e}return j.name in T.globals?T.globals[j.name]:void 0;case"TemplateLiteral":let A,N;return d=e,p=t,A=d.expressions?.map(dE(p))??[],(N=d.quasis?.map(dE(p))??[]).filter(e=>!e.tail).map(e=>e.value).join("")+A.join("")+N.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 d_(e,t){switch(e.type){case"Literal":return e.value;case"Identifier":return e.name;case"MemberExpression":return d_(e.property,t);default:throw`VisitExpressionName does not support expression of type '${e.type}'`}}function dx(e,t){let r={thisObj:void 0,variables:{...e},globals:{...t},addVariables(e){return this.variables={...this.variables,...e},this}};return r.addVariables.bind(r),r}function dE(e){return function(t){return null===t?null:dw(t,e)}}function dS(e){if("__proto__"===e||"prototype"===e||"constructor"===e)throw{type:"Illegal property access",message:`Cannot access the ${e} property of objects`}}function dD(e){return e?"MemberExpression"===e.type?e.property?.name:e.name:null}function dO(e){if("string"!=typeof e&&("object"!=typeof e||!e||!("type"in e)))throw`Unknown expression type ${e}. Expressions must either be a string or pre-compiled string.`;let t={globals:{...ds},isLocalExpression:!1,variables:new Set};return dk("string"==typeof e?dr(e):e,t),[...t.variables]}function dk(e,t){switch(e.type){case"UnaryExpression":return n=e,o=t,dk(n.argument,o);case"BinaryExpression":return i=e,a=t,[dk(i.left,a),dk(i.right,a)].filter(Boolean);case"ConditionalExpression":return s=e,l=t,[dk(s.consequent,l),dk(s.test,l),dk(s.alternate,l)].filter(Boolean);case"CallExpression":let r;return u=e,c=t,r=dk(u.callee,c),u.arguments?.map(dP(c)),r;case"ArrowFunctionExpression":var n,o,i,a,s,l,u,c,d,p,f,h,m,g,y,v,b,w,x=e,E=t;let S={...E};S.isLocalExpression=!0;let D=x.params?.map(dP(S))??[],O=dk(x.body,S)??[];if(O&&Array.isArray(O))for(let e of O)D.includes(e)||E.variables.add(e);return;case"MemberExpression":let k;return d=e,p=t,dk(d.object,p),void((k={...p}).isLocalExpression=!0,dk(d.property,k));case"ArrayExpression":return f=e,h=t,void f.elements?.map(dP(h));case"SequenceExpression":return m=e,g=t,void m.expressions?.map(dP(g));case"NewExpression":return y=e,v=t,void y.arguments?.map(dP(v));case"Literal":case"TemplateElement":return;case"Identifier":var P=e,C=t;if(!(P.name in C.globals))if(C.isLocalExpression)return P.name;else C.variables.add(P.name);return;case"TemplateLiteral":return b=e,w=t,void(b.expressions?.map(dP(w)),b.quasis?.map(dP(w)));default:throw`Expression evaluator does not support expression of type '${e.type}'`}}function dP(e){return function(t){return null===t?null:dk(t,e)}}dr.plugins.register({name:"arrow",init(e){e.addBinaryOp("=>",.1,!0),e.hooks.add("gobble-expression",function(t){if(this.gobbleSpaces(),this.code===e.OPAREN_CODE){let r=this.index;if(this.index++,this.gobbleSpaces(),this.code===e.CPAREN_CODE){this.index++;let e=this.gobbleBinaryOp();if("=>"===e){let r=this.gobbleBinaryExpression();r||this.throwError("Expected expression after "+e),t.node={type:di,params:null,body:r};return}}this.index=r}}),e.hooks.add("after-expression",function(t){!function t(r){r&&(Object.values(r).forEach(e=>{e&&"object"==typeof e&&t(e)}),"=>"===r.operator&&(r.type=di,r.params=r.left?[r.left]:null,r.body=r.right,r.params&&r.params[0].type===e.SEQUENCE_EXP&&(r.params=r.params[0].expressions),delete r.left,delete r.right,delete r.operator))}(t.node)})}}),dr.plugins.register({name:"new",init(e){e.addUnaryOp("new"),e.hooks.add("after-token",function(t){let r=t.node;if(r&&"new"===r.operator){r.argument&&[e.CALL_EXP,e.MEMBER_EXP].includes(r.argument.type)||this.throwError("Expected new function()"),t.node=r.argument;let n=t.node;for(;n.type===e.MEMBER_EXP||n.type===e.CALL_EXP&&n.callee.type===e.MEMBER_EXP;)n=n.type===e.MEMBER_EXP?n.object:n.callee.object;n.type="NewExpression"}})}}),dr.plugins.register({name:"numbers",init(e){function t(e){return"x"===e||"X"===e?(this.index+=2,[[48,57],[65,70],[97,102]]):"b"===e||"B"===e?(this.index+=2,[[48,49]]):"o"===e||"O"===e||e>="0"&&e<="7"?(this.index+=e<="7"?1:2,[[48,55]]):null}function r(t){let r=this.index,n="",o=()=>{for(;e.isDecimalDigit(this.code)||95===this.code;)95===this.code?this.index++:n+=this.expr.charAt(this.index++)};o(),this.code===e.PERIOD_CODE&&(n+=this.expr.charAt(this.index++),o());let i=this.char;("e"===i||"E"===i)&&(n+=this.expr.charAt(this.index++),("+"===(i=this.char)||"-"===i)&&(n+=this.expr.charAt(this.index++)),o(),e.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+n+this.char+")"));let a=this.code;if(e.isIdentifierStart(a))this.throwError("Variable names cannot start with a number ("+n+this.char+")");else if(a===e.PERIOD_CODE){n.length>1&&this.throwError(`Unexpected period ${JSON.stringify({chCode:a,number:n},null,2)}`),this.index=r;return}t.node={type:e.LITERAL,value:parseFloat(n),raw:this.expr.substring(r,this.index)}}e.hooks.add("gobble-token",function(n){if(48===this.code){var o,i,a;let s=this.index,l=this.expr.charAt(this.index+1),u=t.call(this,l);if(!u)return;let c="";for(;o=this.code,i=u,95===o||i.some(([e,t])=>o>=e&&o<=t);)95===this.code?this.index++:c+=this.expr.charAt(this.index++);if(e.isIdentifierPart(this.code)){if(e.isDecimalDigit(this.code)&&e.isDecimalDigit(l.charCodeAt(0))){this.index=s+1,r.call(this,n);return}this.throwError("unexpected char within number")}n.node={type:e.LITERAL,value:parseInt(c,"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)&&r.call(this,n)})}}),dr.plugins.register({name:"regex",init(e){e.hooks.add("gobble-token",function(t){if(47===this.code){let r=++this.index,n=!1;for(;this.index<this.expr.length;){if(47===this.code&&!n){let n,o=this.expr.slice(r,this.index),i="";for(;++this.index<this.expr.length;){let e=this.code;if(e>=97&&e<=122||e>=65&&e<=90||e>=48&&e<=57)i+=this.char;else break}try{n=new RegExp(o,i)}catch(e){this.throwError(e.message)}return t.node={type:e.LITERAL,value:n,raw:this.expr.slice(r-1,this.index)},t.node=this.gobbleTokenProperty(t.node),t.node}this.code===e.OBRACK_CODE?n=!0:n&&this.code===e.CBRACK_CODE&&(n=!1),this.index+=92===this.code?2:1}this.throwError("Unclosed Regex")}})}}),dr.plugins.register({name:"ternary",init(e){e.hooks.add("after-expression",function(t){if(t.node&&this.code===e.QUMARK_CODE){this.index++;let r=t.node,n=this.gobbleExpression();if(n||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===e.COLON_CODE){this.index++;let o=this.gobbleExpression();if(o||this.throwError("Expected expression"),t.node={type:"ConditionalExpression",test:r,consequent:n,alternate:o},r.operator&&e.binary_ops[r.operator]<=.9){let n=r;for(;n.right.operator&&e.binary_ops[n.right.operator]<=.9;)n=n.right;t.node.test=n.right,n.right=t.node,t.node=r}}else this.throwError("Expected :")}})}}),dr.plugins.register({name:"jsepTemplateLiteral",init(e){function t(e,r=!0){if(96===this.code){let t={type:"TemplateLiteral",quasis:[],expressions:[]},n="",o="",i=!1,a=this.expr.length,s=()=>t.quasis.push({type:"TemplateElement",value:{raw:o,cooked:n},tail:i});for(;this.index<a;){let a=this.expr.charAt(++this.index);if("`"===a)return this.index+=1,i=!0,s(),e.node=t,r&&(e.node=this.gobbleTokenProperty(e.node)),e.node;if("$"===a&&"{"===this.expr.charAt(this.index+1))this.index+=2,s(),o="",n="",t.expressions.push(...this.gobbleExpressions(125)),125!==this.code&&this.throwError("unclosed ${");else if("\\"===a)switch(o+=a,a=this.expr.charAt(++this.index),o+=a,a){case"n":n+="\n";break;case"r":n+="\r";break;case"t":n+=" ";break;case"b":n+="\b";break;case"f":n+="\f";break;case"v":n+="\v";break;default:n+=a}else n+=a,o+=a}this.throwError("Unclosed `")}}e.hooks.add("gobble-token",t),e.hooks.add("after-token",function(r){if((r.node.type===e.IDENTIFIER||r.node.type===e.MEMBER_EXP)&&96===this.code)return r.node={type:"TaggedTemplateExpression",tag:r.node,quasi:t.bind(this)(r,!1)},r.node=this.gobbleTokenProperty(r.node),r.node})}}),dr.addBinaryOp("in",7),dr.addBinaryOp("??",1);let dC=Z("feature-flags",{flags:function(){let e={};for(let t of Object.keys(localStorage))if(t.startsWith("openmrs:feature-flag:")){let r=t.replace("openmrs:feature-flag:",""),n=JSON.parse(localStorage.getItem(`openmrs:feature-flag-meta:${r}`)||"{}");e[r]={enabled:"true"===localStorage.getItem(t),...n}}return e}()});function dj(e,t,r){dC.setState(n=>({flags:{...n.flags,[e]:{enabled:n.flags[e]?.enabled??!1,label:t,description:r}}}))}function dT(){let e=dC.getState().flags;Object.keys(localStorage).filter(e=>e.startsWith("openmrs:feature-flag:")).forEach(t=>{let r=t.replace("openmrs:feature-flag:","");e[r]||(localStorage.removeItem(t),localStorage.removeItem(`openmrs:feature-flag-meta:${r}`))})}function dR(e){return dC.getState().flags[e].enabled}function dA(e,t){dC.subscribe(r=>{t(r.flags[e].enabled)})}function dN(e,t){dC.setState(r=>({flags:{...r.flags,[e]:{...r.flags[e],enabled:t}}}))}function d$(e){return!window.offlineEnabled||(e??navigator.onLine)}dC.subscribe(e=>{for(let[t,r]of Object.entries(e.flags))localStorage.setItem(`openmrs:feature-flag:${t}`,r.enabled.toString()),localStorage.setItem(`openmrs:feature-flag-meta:${t}`,JSON.stringify({label:r.label,description:r.description}))});var dI=tt(function(e,t,r){e1(e,t,r)});function dM(e=!0,t=!1){return dL(d$(),e,t)}function dL(e,t=!0,r=!1){return!!(e?t:r)}let dF=q("extensionsInternal",{slots:{},extensions:{}}),dB=q("extensionRenderings",{renderings:new Map}),dV=()=>Z("extensionsInternal",{slots:{},extensions:{}}),dU=()=>Z("extensionRenderings",{renderings:new Map});function dW(e){let t=dF.getState(),r=e(t);r!==t&&dF.setState(r)}let dK=null,dz=null;function dH(){let e=dB.getState();return dK&&e===dz||(dK=new Map(e.renderings),dz=e,function(e){for(let t of(d4.clear(),e.values()))d2(t,1);d3=!0}(dK)),dK}function dG(e){dz={renderings:e},dB.setState(dz,!0)}function dq(e){let t=dH();t.has(e.renderingId)||(t.set(e.renderingId,e),d2(e,1),dG(t))}function dY(e){let t=dH(),r=t.get(e);r&&(t.delete(e),d2(r,-1),dG(t))}let dZ=()=>Z("extensions",{slots:{}}),dJ=0,dX=new Set;function dQ(e){dJ++;try{return e()}finally{if(0==--dJ&&dX.size>0){let e=Array.from(dX);for(let t of(dX.clear(),e))d0(t)}}}function d0(e){try{e()}catch(t){console.error(`The extension system's '${e.name}' recomputation failed`,t)}}function d1(e){dJ>0?dX.add(e):d0(e)}let d4=new Map,d3=!1;function d2(e,t){let r=JSON.stringify([e.slotName,e.extensionId,e.slotModuleName,e.extensionModuleName]),n=d4.get(r);if(!n){if(t<0)return;d4.set(r,{count:1,record:{slotModuleName:e.slotModuleName,extensionModuleName:e.extensionModuleName,slotName:e.slotName,extensionId:e.extensionId}}),d3=!0;return}n.count+=t,n.count<1&&(d4.delete(r),d3=!0)}function d6(){var e,t;if(dH(),!d3)return;d3=!1;let r=Array.from(d4.values(),({record:e})=>e);r.sort(d5),e=t3.getState().mountedExtensions,t=r,e.length===t.length&&e.every((e,r)=>0===d5(e,t[r]))||t3.setState({mountedExtensions:r})}function d5(e,t){return d8(e.slotName,t.slotName)||d8(e.extensionId,t.extensionId)||d8(e.slotModuleName,t.slotModuleName)||d8(e.extensionModuleName,t.extensionModuleName)}function d8(e,t){return e===t?0:e<t?-1:1}d6(),dB.subscribe(()=>d1(d6));let d9=dV(),d7=dZ(),pe=t6(),pt=t9(),pr=new Set,pn=!1;function po(e){if(null===e)pr=null;else if(null!==pr)for(let t of e)pr.add(t);d1(pi)}function pi(){if(!pn){pn=!0;try{for(let e=1;;e++){let t=pr;if(null!==t&&0===t.size)return;pr=new Set;try{!function(e,t,r,n,o,i=null){let a=d7.getState().slots,s={},l=!1,u=d$(),c=Object.entries(n.flags).filter(([,{enabled:e}])=>e).map(([e])=>e);for(let[n,d]of Object.entries(e.slots)){let p=a[n];if(p&&i&&!i.has(n)){s[n]=p;continue}let{config:f}=t8(t,d.name),h=function(e,t,r,n,o,i,a){let s=function(e,t){let r=e.add||[],n=e.remove||[],o=e.order||[],{extensions:i}=d9.getState();return[...t,...r].filter(e=>!n.includes(e)).sort((e,r)=>pg(e,o,i[pu(e)]?.order,t)-pg(r,o,i[pu(r)]?.order,t))}(r,t.slots[e].attachedIds),l=[];for(let u of s){let{config:s}=re(n,e,u),c=rt(r,e,u),d=c?dI({},s,c):s,p=pu(u),f=t.extensions[p];if(f){let e=d?.["Display conditions"]?.privileges??f.privileges??[];if(e&&("string"==typeof e||Array.isArray(e)&&e.length>0)&&(!a?.user||!oY(e,a.user))||f.featureFlag&&!o.includes(f.featureFlag)||window.offlineEnabled&&!dL(i,f.online,f.offline))continue;l.push({id:u,name:p,moduleName:f.moduleName,config:d,featureFlag:f.featureFlag,meta:f.meta,online:d?.["Display conditions"]?.online??f.online??!0,offline:d?.["Display conditions"]?.offline??f.offline??!1,displayConditionExpression:d?.["Display conditions"]?.expression||f.displayExpression})}}return l}(n,e,f,r,c,u,o.session);p&&p.moduleName===d.moduleName&&to(p.candidateExtensions,h)?s[n]=p:(s[n]={moduleName:d.moduleName,candidateExtensions:h},l=!0)}(l||Object.keys(a).length!==Object.keys(s).length)&&d7.setState({slots:s})}(d9.getState(),pe.getState(),pt.getState(),dC.getState(),oU.getState(),t)}catch(e){throw pr=null===t||null===pr?null:new Set([...t,...pr]),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{pn=!1}}}function pa(e,t){let r=new Set;for(let n of Object.keys(e))e[n]!==t[n]&&r.add(n);for(let n of Object.keys(t))n in e||r.add(n);return r}function ps(){po(null)}function pl(e,t){return{moduleName:t,name:e,attachedIds:[]}}function pu(e){let[t]=e.split("#");return t}function pc(e,t){let r=pu(t);return e.extensions[r]}function pd(e){return pc(d9.getState(),e)}d9.subscribe((e,t)=>{po(e.extensions!==t.extensions?null:pa(e.slots,t.slots))}),pe.subscribe((e,t)=>{po(pa(e.slots,t.slots))}),pt.subscribe((e,t)=>{po(pa(e.configs,t.configs))}),dC.subscribe(()=>po(null)),oU.subscribe(()=>po(null)),ps(),y(ps);let pp=e=>dW(t=>({...t,extensions:{...t.extensions,[e.name]:{...e}}}));function pf(e,t){dW(r=>{let n=r.slots[e];return n?{...r,slots:{...r.slots,[e]:{...n,attachedIds:[...n.attachedIds,t]}}}:{...r,slots:{...r.slots,[e]:{...pl(e),attachedIds:[t]}}}})}function ph(e,t){dW(r=>{let n=r.slots[e];return n&&n.attachedIds.includes(t)?{...r,slots:{...r.slots,[e]:{...n,attachedIds:n.attachedIds.filter(e=>e!==t)}}}:r})}function pm(e){dW(t=>{let r=t.slots[e];return r?{...t,slots:{...t.slots,[e]:{...r,attachedIds:[]}}}:t})}function pg(e,t,r,n){let o=t.indexOf(e);if(-1!==o)return o;{if(void 0!==r)return 1e3+r;let t=n.indexOf(e);return -1!==t?2e3+t:3e3}}function py(e,t){return function(e,t,r=null,n){let o;return e.filter(e=>{let i=e.displayConditionExpression;if("string"!=typeof i||0===i.trim().length)return!0;o??(o=t&&"object"==typeof t?{session:r,...t}:{session:r});try{return!!dc(i,o)}catch(t){return console.error(`Error while evaluating expression '${i}' for ${e.id}`+(n?` in ${n}`:""),t),!1}})}(pv(e),t,oU.getState().session,e)}function pv(e){return d7.getState().slots[e]?.candidateExtensions??[]}let pb=(e,t)=>d9.setState(r=>{let n=r.slots[t]?.moduleName;if(n&&n!=e)return console.warn(`An extension slot with the name '${t}' already exists. Refusing to register the same slot name twice (in "registerExtensionSlot"). The existing one is from module ${n}.`),r;if(n&&n==e)return r;if(r.slots[t])return{...r,slots:{...r.slots,[t]:{...r.slots[t],moduleName:e}}};let o=pl(t,e);return{...r,slots:{...r.slots,[t]:{...o}}}}),pw=()=>{pr=null,dW(()=>({slots:{},extensions:{}})),dU().setState({renderings:new Map}),d7.setState({slots:{}})},p_=q("left-nav",{slotName:null,basePath:window.spaBase,mode:"normal"});function px({name:e,basePath:t,mode:r,componentContext:n,state:o}){p_.setState({slotName:e,basePath:t,mode:r??"normal",componentContext:n,state:o})}function pE(e){p_.getState().slotName===e&&p_.setState(p_.getInitialState(),!0)}let pS=q("modalRegistry",{modals:{}});function pD(e){pS.setState(t=>(t.modals[e.name]=e,t))}function pO(e){let t=pS.getState().modals[e];if(!t){let r=pd(e);r&&(t={name:e,load:r.load,moduleName:r.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.`),pD(t))}return t}let pk=q("workspaceRegistrations",{workspaces:{}}),pP=q("workspaceGroups",{workspaceGroups:{}});function pC(e){pk.setState(t=>({workspaces:{...t.workspaces,[e.name]:{...e,load:e.load,preferredWindowSize:e.preferredWindowSize??"normal",type:e.type??"form",canHide:e.canHide??!1,canMaximize:e.canMaximize??!1,width:e.width??"narrow",groups:e.groups??[]}}}))}function pj(e){pP.setState(t=>{let r=t.workspaceGroups[e.name];return r?{workspaceGroups:{...t.workspaceGroups,[e.name]:{...r,members:Array.from(new Set([...r.members,...e.members]))}}}:{workspaceGroups:{...t.workspaceGroups,[e.name]:{name:e.name,members:e.members}}}})}let pT=new Set;function pR(e){let t=pk.getState().workspaces;if(t[e])return t[e];{let t=pd(e);if(t){var r;let n;return pT.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.`),pT.add(e)),{name:t.name,title:(r=t,"string"==typeof(n=r?.meta?.title)?n:n&&"object"==typeof n?iB(r.moduleName,n.key,n.default):r.name),moduleName:t.moduleName,preferredWindowSize:t.meta?.screenSize??"normal",load:t.load,type:t.meta?.type??"form",canHide:t.meta?.canHide??!1,canMaximize:t.meta?.canMaximize??!1,width:t.meta?.width??"narrow",groups:t.meta?.groups??[]}}throw Error(`No workspace named '${e}' has been registered.`)}}function pA(e){let t=pP.getState().workspaceGroups;if(t[e])return t[e];throw Error(`No workspace group named '${e}' has been registered.`)}let pN=q("workspace2",{registeredGroupsByName:{},registeredWindowsByName:{},registeredWorkspacesByName:{},openedGroup:null,openedWindows:[],workspaceTitleByWorkspaceName:{},isMostRecentlyOpenedWindowHidden:!1});function p$(e){let{registeredWorkspacesByName:t,registeredWindowsByName:r}=pN.getState(),n=t[e];if(n){let t=r[n.window];if(t)return t;throw Error(`No workspace window found with name: ${n.window} for workspace: ${e}`)}throw Error(`No workspace found with name: ${e}`)}function pI(e){let{registeredGroupsByName:t,registeredWindowsByName:r}=pN.getState(),n=r[e];if(n){let r=t[n.group];if(r)return r;throw Error(`No workspace group found with name: ${n.group} for window: ${e}`)}throw Error(`No workspace window found with name: ${e}`)}function pM(e){let{openedWindows:t}=pN.getState();return t.findIndex(t=>t.openedWorkspaces.find(t=>t.workspaceName===e))}function pL(e,t){if(0==t.length)return;let{registeredGroupsByName:r}=pN.getState(),n={...r};for(let r of t){if(n[r.name])throw Error(`Cannot register workspace group ${r.name} more than once`);n[r.name]={...r,moduleName:e}}pN.setState({registeredGroupsByName:n})}function pF(e,t){if(0==t.length)return;let{registeredWindowsByName:r}=pN.getState(),n={...r};for(let r of t){if(n[r.name])throw Error(`Cannot register workspace window ${r.name} more than once`);let t={...r,moduleName:e};n[r.name]=t}pN.setState({registeredWindowsByName:n})}function pB(e,t){if(0==t.length)return;let{registeredWorkspacesByName:r}=pN.getState(),n={...r};for(let r of t){if(n[r.name])throw Error(`Cannot register workspace ${r.name} more than once`);let t={...r,moduleName:e};n[r.name]=t}pN.setState({registeredWorkspacesByName:n})}let pV=0,pU=null,pW={bootstrap:15e3,mount:15e3,unmount:15e3};function pK(e){if(e.timeouts)return e;let t=e.name??"parcel",r=Object.fromEntries(Object.keys(pW).filter(t=>e[t]).map(r=>{var n,o;let i,a;return[r,(n=e[r],o=pW[r],i=Array.isArray(n)?n:[n],a=e=>i.reduce((n,o,i)=>n.then(()=>{let n=o(e);return"function"==typeof n?.then&&"function"==typeof n?.catch?n:Promise.reject(Error(`Lifecycle function ${r} at array index ${i} for parcel ${t} did not return a promise`))}),Promise.resolve(void 0)),e=>{let n,i=new Promise((e,i)=>{n=setTimeout(()=>i(Error(`Lifecycle function ${r} for parcel ${t} did not settle within ${o}ms`)),o)});return Promise.race([a(e),i]).finally(()=>clearTimeout(n))})]}));return{...e,...r}}async function pz(e,t){return(await (pU??(pU=new Promise((e,t)=>{nM({name:"openmrs-extension-host",bootstrap:()=>Promise.resolve(),mount:t=>(e(t.mountParcel),Promise.resolve()),unmount:()=>Promise.resolve()},{domElement:document.createElement("div")}).mountPromise.catch(t)}).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),nM))),pU))("function"==typeof e?()=>e().then(pK):pK(e),t)}function pH(){return pG}function pG(e,t){let r,n=pz(e,t).then(e=>r=e);return{mount:()=>n.then(e=>e.mount()),unmount:()=>n.then(e=>e.unmount()),update:e=>n.then(t=>t.update?.(e)),getStatus:()=>r?.getStatus()??"LOADING_SOURCE_CODE",get loadPromise(){return n.then(e=>e.loadPromise)},get bootstrapPromise(){return n.then(e=>e.bootstrapPromise)},get mountPromise(){return n.then(e=>e.mountPromise)},get unmountPromise(){return n.then(e=>e.unmountPromise)}}}async function pq(e,t,r,n,o=e=>e,i={}){let a=pu(n),s=pd(n),l=null;if(e){if(!s)throw Error(`Couldn't find extension '${a}' to attach to '${t}'`);let{meta:u,moduleName:c,online:d,offline:p,load:f}=s;if(dM(d,p)){let s,d=pV++,p=`${t}/${n}-${d}`;e.dataset.extensionRenderingId=p;let h=e=>{try{dY(p)}catch(t){console.error(e,t)}};try{dq({renderingId:p,extensionName:a,extensionModuleName:c,extensionId:n,slotName:t,slotModuleName:r})}catch(e){throw h(`Recomputing configuration after registering '${n}' failed also failed`),e}try{s=await f()}catch(e){throw h(`Recomputing configuration after '${n}' failed to load also failed`),e}try{l=await pz(o({...s,name:`${t}/${a}-${d}`}),{...i,_meta:u,_extensionContext:{extensionId:n,extensionSlotName:t,extensionSlotModuleName:r,extensionModuleName:c},domElement:e})}catch(e){throw h(`Recomputing configuration after '${n}' failed to mount also failed`),e}l.mountPromise.then(void 0,e=>{console.error(`Extension '${n}' in slot '${t}' failed to mount`,e),h(`Recomputing configuration after '${n}' failed to mount also failed`)}),l.unmountPromise.then(()=>h(`Recomputing configuration after unmounting '${n}' failed`),e=>{console.error(`Extension '${n}' in slot '${t}' failed to unmount`,e),h(`Recomputing configuration after '${n}' failed to unmount also failed`)})}}else console.warn(`Tried to render ${n} into ${t} but no DOM element was available.`);return l}var pY=r(695),pZ=r.n(pY);let pJ=(0,pY.createContext)({moduleName:"",featureName:""});function pX({to:e,templateParams:t,onBeforeNavigate:r,children:n,...o}){return(0,pY.useEffect)(()=>{o.href&&console.warn(`ConfigurableLink does not support the href prop. Use the 'to' prop instead. The provided href value is '${o.href}'`),o.onClick&&console.warn(`ConfigurableLink does not support the onClick prop. Use the 'onBeforeNavigate' prop instead. The 'to' prop of the offending link is ${e}`)},[]),pZ().createElement("a",{onClick:n=>{0===n.button&&!n.ctrlKey&&!n.shiftKey&&!n.altKey&&!n.metaKey&&(n.preventDefault(),r?.(n),oD({to:e,templateParams:t})),0===n.button&&(n.ctrlKey||n.metaKey)&&r?.(n),0===n.button&&n.shiftKey&&r?.(n),1===n.button&&r?.(n)},href:oE(e,t),...o},n)}let pQ=({state:e,children:t,...r})=>{let{extension:n}=(0,pY.useContext)(pJ),o=(0,pY.useRef)(null),i=(0,pY.useRef)(Promise.resolve()),a=(0,pY.useRef)(!1),s=(0,pY.useRef)(!1),l=(0,pY.useRef)(e),u=(0,pY.useCallback)(e=>{if(!e)return;let t=()=>{"MOUNTED"===e.getStatus()&&e.unmount()};switch(e.getStatus()){case"MOUNTED":e.unmount();break;case"UPDATING":i.current?.then(t,t);break;default:e.mountPromise.then(t,()=>{})}},[]),c=(0,pY.useCallback)((e,t)=>{e.update&&"UNMOUNTING"!==e.getStatus()&&(i.current=Promise.all([e.mountPromise,i.current]).then(()=>{if(o.current?.getStatus()==="MOUNTED"&&o.current.update)return o.current.update({...t})}).catch(e=>{let t=o.current?.getStatus();"UNMOUNTING"!==t&&"NOT_MOUNTED"!==t&&"UNLOADING"!==t&&console.error(`The extension '${n?.extensionId}' failed to update`,e)}))},[]),d=(0,pY.useCallback)(t=>{t&&!o.current&&!s.current&&n?.extensionSlotName&&n.extensionSlotModuleName&&(s.current=!0,pq(t,n.extensionSlotName,n.extensionSlotModuleName,n.extensionId,void 0,e).then(t=>{(s.current=!1,o.current=t,a.current)?u(t):t&&l.current!==e&&c(t,l.current)},()=>{s.current=!1}))},[]);return(0,pY.useEffect)(()=>(a.current=!1,()=>{a.current=!0,u(o.current)}),[]),(0,pY.useEffect)(()=>{l.current=e,o.current&&c(o.current,e)},[e]),n?pZ().createElement("div",{ref:d,"data-extension-id":n?.extensionId,style:{position:"relative"},...r}):null};function p0(e){let t=(0,pY.useRef)(e);return L(t.current,e)||(t.current=e),t.current}function p1(e,t){"function"==typeof t&&(t=t(e));let r={};for(let[n,o]of Object.entries(t)){let t=function(...t){e.setState(e=>o(e,...t))};r[n]=t}return r}let p4=e=>e;function p3(e,t=p4,r){let n=(0,pY.useCallback)(t=>e.subscribe(t),[e]),o=(0,pY.useCallback)(()=>t(e.getState()),[e,t]),i=(0,pY.useSyncExternalStore)(n,o,o),a=(0,pY.useMemo)(()=>r?p1(e,r):null,[e,r]);return(0,pY.useMemo)(()=>a?{...i,...a}:i,[i,a])}function p2(e,t){return p3(e,p4,t)}function p6(e){return function(t){let r=(0,pY.useCallback)(t=>e.subscribe(t),[]),n=(0,pY.useCallback)(()=>e.getState(),[]),o=(0,pY.useSyncExternalStore)(r,n,n),i=(0,pY.useMemo)(()=>t?p1(e,t):null,[t]);return(0,pY.useMemo)(()=>i?{...o,...i}:o,[o,i])}}let p5=[];Object.freeze(p5);let p8={candidateExtensions:p5};Object.freeze(p8);let p9=e=>{let t=(0,pY.useCallback)(t=>t.slots?.[e]??p8,[e]);return p3(dZ(),t)},p7=e=>e.session;function fe(e,t){let{candidateExtensions:r}=p9(e),n=p3(oU,p7),o=p0(t);return(0,pY.useMemo)(()=>py(e,o),[e,o,n,r])}function ft(e,t){let{moduleName:r}=(0,pY.useContext)(pJ);if(!r)throw Error("ComponentContext has not been provided. This should come from @openmrs/esm-react-utils.");return(0,pY.useEffect)(()=>{pb(r,e)},[r,e]),{extensions:fe(e,t),extensionSlotName:e,extensionSlotModuleName:r}}function fr(e){return e}function fn({name:e,extensionSlotName:t,select:r=fr,children:n,state:o,style:i,...a}){if(n&&o)throw Error("Both children and state have been provided. If children are provided, the state must be passed as a prop to the `Extension` component.");let s=e??t,l=(0,pY.useRef)(null),{extensions:u,extensionSlotModuleName:c}=ft(s,o),d=(0,pY.useMemo)(()=>r(u),[r,u]),p=(0,pY.useMemo)(()=>{if("function"==typeof n&&!pZ().isValidElement(n))return d.map(e=>n(e,o))},[n,d]);return pZ().createElement("div",{ref:l,"data-extension-slot-name":s,"data-extension-slot-module-name":c,style:{...i,position:"relative"},...a},s&&d?.map((e,t)=>pZ().createElement(pJ.Provider,{key:e.id,value:{moduleName:c,featureName:"",extension:{extensionId:e.id,extensionSlotName:s,extensionSlotModuleName:c}}},p?.[t]??("function"!=typeof n?n:null)??pZ().createElement(pQ,{state:o}))))}var fo=r(5338);function fi(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function fa(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?fi(Object(r),!0).forEach(function(t){var n,o,i;n=e,o=t,i=r[t],o in n?Object.defineProperty(n,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):n[o]=i}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):fi(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function fs(e){return(fs="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 fl(e){return(fl="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 fu(e,t){var r;if("function"!=typeof(r=t.domElement?function(){return t.domElement}:t.domElementGetter?t.domElementGetter:e.domElementGetter?e.domElementGetter:function(e){var t=e.appName||e.name;if(!t)throw Error("single-spa's dom-element-getter-helpers was not given an application name as a prop, so it can't make a unique dom element container for the react application");var r="single-spa-application:".concat(t);return function(){var e=document.getElementById(r);return e||((e=document.createElement("div")).id=r,document.body.appendChild(e)),e}}(t)))throw Error("single-spa's dom-element-getter-helpers was given an invalid domElementGetter for application or parcel '".concat(t.name,"'. Expected a function, received ").concat(fl(r)));return function(){var e=r(t);if(!(e instanceof HTMLElement))throw Error("single-spa's dom-element-getter-helpers: domElementGetter returned an invalid dom element for application or parcel '".concat(t.name,"'. Expected HTMLElement, received ").concat(fl(e)));return e}}var fc=null;try{fc=require("react").createContext()}catch(e){}var fd={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 fp(e,t){return e.rootComponent?Promise.resolve():e.loadRootComponent(t).then(function(t){e.rootComponent=t})}function ff(e,t){return new Promise(function(r,n){e.suppressComponentDidCatchWarning||!function(e){if(!(e&&"string"==typeof e.version&&e.version.indexOf(".")>=0))return!1;var t=e.version.slice(0,e.version.indexOf("."));try{return Number(t)>=16}catch(e){return!1}}(e.React)||e.errorBoundary||e.errorBoundaryClass||(e.rootComponent.prototype?e.rootComponent.prototype.componentDidCatch||console.warn("single-spa-react: ".concat(t.name||t.appName||t.childAppName,"'s rootComponent should implement componentDidCatch to avoid accidentally unmounting the entire single-spa application.")):console.warn("single-spa-react: ".concat(t.name||t.appName||t.childAppName,"'s rootComponent does not implement an error boundary. If using a functional component, consider providing an opts.errorBoundary to singleSpaReact(opts).")));var o,i=fy(e,t,function(){r(this)}),a=fu(e,t)(),s=function(e){var t=e.reactDom,r=e.renderType,n=e.elementToRender,o=e.domElement,i=t[r];if("function"!=typeof i)throw Error('renderType "'.concat(r,'" did not return a function.'));switch(r){case"createRoot":case"unstable_createRoot":case"createBlockingRoot":case"unstable_createBlockingRoot":var a=i(o);return a.render(n),a;case"hydrateRoot":return i(o,n);default:return i(n,o),null}}({elementToRender:i,domElement:a,reactDom:fg(e),renderType:"function"==typeof(o=e).renderType?o.renderType():o.renderType});e.domElements[t.name]=a,e.renderResults[t.name]=s})}function fh(e,t){return new Promise(function(r){e.unmountResolves[t.name]=r;var n=e.renderResults[t.name];n&&n.unmount?n.unmount():fg(e).unmountComponentAtNode(e.domElements[t.name]),delete e.domElements[t.name],delete e.renderResults[t.name]})}function fm(e,t){return new Promise(function(r){e.updateResolves[t.name]||(e.updateResolves[t.name]=[]),e.updateResolves[t.name].push(r);var n=fy(e,t,null),o=e.renderResults[t.name];if(o&&o.render)o.render(n);else{var i=fu(e,t)();fg(e).render(n,i)}})}function fg(e){return e.ReactDOMClient||e.ReactDOM}function fy(e,t,r){var n=e.React.createElement(e.rootComponent,t),o=fc?e.React.createElement(fc.Provider,{value:t},n):n;return(e.errorBoundary||t.errorBoundary||e.errorBoundaryClass||t.errorBoundaryClass)&&(e.errorBoundaryClass=e.errorBoundaryClass||t.errorBoundaryClass||function(e,t){function r(t){e.React.Component.apply(this,arguments),this.state={caughtError:null,caughtErrorInfo:null},r.displayName="SingleSpaReactErrorBoundary(".concat(t.name,")")}return r.prototype=Object.create(e.React.Component.prototype),r.prototype.render=function(){return this.state.caughtError?(e.errorBoundary||t.errorBoundary)(this.state.caughtError,this.state.caughtErrorInfo,this.props):this.props.children},r.prototype.componentDidCatch=function(e,t){this.setState({caughtError:e,caughtErrorInfo:t})},r}(e,t),o=e.React.createElement(e.errorBoundaryClass,t,o)),o=e.React.createElement(e.SingleSpaRoot,fa(fa({},t),{},{mountFinished:r,updateFinished:function(){e.updateResolves[t.name]&&(e.updateResolves[t.name].forEach(function(e){return e()}),delete e.updateResolves[t.name])},unmountFinished:function(){e.unmountResolves[t.name]&&(e.unmountResolves[t.name](),delete e.unmountResolves[t.name])}}),o)}var fv=r(287),fb=r(9324),fw=r(2108);let f_={strictMode:!0,throwErrorsToConsole:!0,disableTranslations:!1},fx=new Map;(0,fw.initCache)(fx);let fE={errorRetryCount:3,fetcher:oF,focusThrottleInterval:18e5,revalidateIfStale:!0,revalidateOnFocus:!1,revalidateOnReconnect:!1,refreshInterval:0,shouldRetryOnError:e=>{if(e instanceof oV){let t=e.response.status;return!!(t>=500)||401===t||403===t||429===t}return!0},provider:()=>fx};function fS(e){if("object"!=typeof e||"string"!=typeof e.featureName||"string"!=typeof e.moduleName)throw Error("Invalid options");let t=Object.assign({},f_,e),r={...fE,...t.swrConfig};return function(e){var n,o,i,a,s;return i=o=class extends(n=pZ().Component){componentDidCatch(e,r){r&&r.componentStack&&(e.extra=Object.assign(e.extra||{},{componentStack:r.componentStack})),t.throwErrorsToConsole&&setTimeout(()=>{throw e}),this.setState({caughtError:e,caughtErrorInfo:r})}render(){if(this.state.caughtError)return pZ().createElement("div",null,"An error has occurred. Please try reloading the page.");{let n=pZ().createElement(pY.Suspense,{fallback:null},pZ().createElement(fb.BE,{value:r},pZ().createElement(pJ.Provider,{value:this.state.config},t.disableTranslations?pZ().createElement(e,this.props):pZ().createElement(fv.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},pZ().createElement(e,this.props)))));return t.strictMode&&pZ().StrictMode?pZ().createElement(pZ().StrictMode,null,n):n}}constructor(e){super(e),this.state={caughtError:null,caughtErrorInfo:null,config:{moduleName:t.moduleName,featureName:t.featureName,extension:e._extensionContext}}}},a="displayName",s=`OpenmrsReactComponent(${t.featureName})`,a in i?Object.defineProperty(i,a,{value:s,enumerable:!0,configurable:!0,writable:!0}):i[a]=s,o}}function fD(e,t){return function(e){if("object"!==fs(e))throw Error("single-spa-react requires a configuration object");var t,r=fa(fa({},fd),e);if(!r.React)throw Error("single-spa-react must be passed opts.React");if(!r.ReactDOM&&!r.ReactDOMClient)throw Error("single-spa-react must be passed opts.ReactDOM or opts.ReactDOMClient");if(r.renderType||(null!=(t=r.ReactDOMClient)&&t.createRoot?r.renderType="createRoot":r.renderType="render"),!r.rootComponent&&!r.loadRootComponent)throw Error("single-spa-react must be passed opts.rootComponent or opts.loadRootComponent");if(r.errorBoundary&&"function"!=typeof r.errorBoundary)throw Error("The errorBoundary opt for single-spa-react must either be omitted or be a function that returns React elements");!fc&&r.React.createContext&&(fc=r.React.createContext()),r.SingleSpaRoot=function(e){function t(e){t.displayName="SingleSpaRoot(".concat(e.name,")")}return t.prototype=Object.create(e.React.Component.prototype),t.prototype.componentDidMount=function(){setTimeout(this.props.mountFinished)},t.prototype.componentWillUnmount=function(){setTimeout(this.props.unmountFinished)},t.prototype.render=function(){return setTimeout(this.props.updateFinished),this.props.children},t}(r);var n={bootstrap:fp.bind(null,r),mount:ff.bind(null,r),unmount:fh.bind(null,r)};return r.parcelCanUpdate&&(n.update=fm.bind(null,r)),n}({React:pZ(),ReactDOMClient:fo,rootComponent:fS(t)(e)})}function fO(e,t){return()=>e().then(({default:e})=>fD(e,t))}function fk(e,t){return()=>Promise.resolve(fD(e,t))}let fP=fO,fC=U()(()=>({}));Y("openmrs-app-context",fC);let fj={};function fT(e,t=e=>e){let r=fC.getState();return e in r?Object.freeze(Object.assign({},t?t(r[e]):r[e])):null}function fR(e,t){fC.setState(r=>(e in r||(r[e]={}),r[e]=t(r[e]),Object.assign({},r)))}function fA(e){return null===e?null:Object.freeze(Object.assign({},e))}let fN=new Map;function f$(e,t){let r=(0,pY.useRef)(t??{}),n=(0,pY.useRef)(t=>fR(e,t)),o=(0,pY.useRef)(Symbol());return(0,pY.useEffect)(()=>{let r=t??{},n=o.current;return null===fT(e)?!function(e,t=fj){fC.setState(r=>{if(e in r)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({},r,{[e]:t===fj?{}:t})})}(e,r):(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.`),fR(e,()=>r)),fN.set(e,n),()=>{fN.get(e)===n&&(fC.setState(t=>(e in t&&delete t[e],t)),fN.delete(e))}},[e]),(0,pY.useEffect)(()=>{let n=t??{};L(r.current,n)||(fR(e,()=>n),r.current=n)},[t]),n.current}function fI({namespace:e,value:t}){return f$(e,t),null}let fM=({children:e,value:t,fallback:r})=>t?pZ().createElement(pZ().Fragment,null,e):r?pZ().createElement(pZ().Fragment,null,r):null;function fL(){let e=(0,pY.useRef)();return(!e.current||e.current.signal.aborted)&&(e.current=new AbortController),(0,pY.useEffect)(()=>{let t=e.current;return()=>t?.abort()},[]),e.current}function fF(e,t=e=>e??{}){let[r,n]=(0,pY.useState)(()=>{if(fB(e))return;let r=fT(e);if(null!==r)return t?t(r):r});return(0,pY.useEffect)(()=>{if(fB(e))throw Error(`The namespace supplied to useAppContext must be a non-empty string, but was "${e}".`)},[e]),(0,pY.useEffect)(()=>{var r;let o;return(r=e=>{if(null==e)return void n(void 0);let r=t?t(e):e;n(e=>L(e,r)?e:r)})(fA(o=fT(e))),fC.subscribe(t=>{let n=e in t?t[e]:null;n!==o&&(o=n,r(fA(n)))})},[e,t]),r}function fB(e){return"string"!=typeof e||0===e.trim().length}function fV(e){let t=fe(e);return(0,pY.useMemo)(()=>t.map(e=>e.id),[t])}function fU(e){return p9(e).candidateExtensions}function fW(e,t){let{data:r,error:n,mutate:o,isLoading:i,isValidating:a}=(0,fb.Ay)(`${aD}?patient=${e}&includeEncounterless=${t}`,oF);return(0,pY.useMemo)(()=>({isLoading:i,data:r?.data.results??[],error:n,mutate:o,isValidating:a}),[r,n,i,a,o])}function fK(e){(0,pY.useEffect)(()=>{if(e){let e=window.getComputedStyle(document.body).overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=e}}},[e])}let fz={},fH=`No ComponentContext has been provided. This should come from "openmrsComponentDecorator".
15
+ ${this.stack}`}}let oU=q("session",{loaded:!1,session:null}),oW=0;function oK(e={includeAuthStatus:!0}){return(oW<Date.now()-6e4||!oU.getState().loaded)&&oG(),new el.Observable(t=>{let r=r=>{r.loaded&&(e.includeAuthStatus?t.next(r.session):t.next(r.session?.user))};return r(oU.getState()),oU.subscribe(r)})}function oz(){return(oW<Date.now()-6e4||!oU.getState().loaded)&&oG(),oU}function oH(e){let t=e.locale??e.user?.userProperties?.defaultLocale;t&&t.includes("_")&&(t=t.replaceAll("_","-")),function(e){if(void 0===e||"string"!=typeof e)return!1;try{new Intl.Locale(e)}catch(e){return!1}return!0}(t)&&t!==document.documentElement.getAttribute("lang")&&document.documentElement.setAttribute("lang",t)}function oG(e,t){oW=Date.now();let r={};return e&&t&&(r.Authorization=`Basic ${window.btoa(`${e}:${t}`)}`),o0(oF(oM,{headers:r}))}function oq(){oU.setState({loaded:!0,session:{authenticated:!1,sessionId:""}})}function oY(e,t){var r,n;if(void 0===t)return!e;if(!e)return!0;return r=e,n=t,("string"==typeof r?!Q(n.privileges.find(e=>r===e.display)):Array.isArray(r)?r.every(e=>!Q(n.privileges.find(t=>e===t.display))):(Q(r)||console.error(`Could not understand privileges "${r}"`),!0))||!Q(t.roles.find(e=>"System Developer"===e.display))}function oZ(){let e,t;return new Promise(r=>{let n=n=>{n.loaded&&n.session.user&&(e=n.session.user,r(n.session.user),t&&t())};n(oU.getState()),e||(t=oU.subscribe(n))})}function oJ(){return new Promise((e,t)=>{oK().subscribe(t=>{e(t.sessionLocation)},t).unsubscribe()})}async function oX(e,t){return o0(oF(oM,{method:"POST",body:{sessionLocation:e},headers:{"Content-Type":"application/json"},signal:t.signal}))}async function oQ(e,t,r){return r||(r=new AbortController),await oF(`${o$}/user/${e}`,{method:"POST",body:{userProperties:t},headers:{"Content-Type":"application/json"},signal:r.signal}),oG()}function o0(e){return new Promise((t,r)=>{e.then(e=>{let n;"object"==typeof e?.data?(n={loaded:!0,session:e.data},oU.setState(n),t(n)):(n={loaded:!1,session:null},oU.setState(n),r(n))}).catch(e=>{$(`Failed to fetch new session information: ${e}`);let t={loaded:!1,session:null};oU.setState(t),r(t)})})}function o1(){return"development"===window.spaEnv||"true"===localStorage.getItem("openmrs:devtools")}oU.subscribe(e=>{e.loaded&&e.session&&oH(e.session)});let o4={"webservices.rest":"2.24.0",fhir2:"1.0.0-SNAPSHOT"};function o3(){rb("@openmrs/esm-api",oA),oG()}let o2={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"},o6=e=>"string"==typeof e,o5=()=>{let e,t,r=new Promise((r,n)=>{e=r,t=n});return r.resolve=e,r.reject=t,r},o8=e=>null==e?"":""+e,o9=/###/g,o7=e=>e&&e.indexOf("###")>-1?e.replace(o9,"."):e,ie=e=>!e||o6(e),it=(e,t,r)=>{let n=o6(t)?t.split("."):t,o=0;for(;o<n.length-1;){if(ie(e))return{};let t=o7(n[o]);!e[t]&&r&&(e[t]=new r),e=Object.prototype.hasOwnProperty.call(e,t)?e[t]:{},++o}return ie(e)?{}:{obj:e,k:o7(n[o])}},ir=(e,t,r)=>{let{obj:n,k:o}=it(e,t,Object);if(void 0!==n||1===t.length){n[o]=r;return}let i=t[t.length-1],a=t.slice(0,t.length-1),s=it(e,a,Object);for(;void 0===s.obj&&a.length;)i=`${a[a.length-1]}.${i}`,s=it(e,a=a.slice(0,a.length-1),Object),s?.obj&&void 0!==s.obj[`${s.k}.${i}`]&&(s.obj=void 0);s.obj[`${s.k}.${i}`]=r},io=(e,t)=>{let{obj:r,k:n}=it(e,t);if(r&&Object.prototype.hasOwnProperty.call(r,n))return r[n]},ii=(e,t,r)=>{for(let n in t)"__proto__"!==n&&"constructor"!==n&&(n in e?o6(e[n])||e[n]instanceof String||o6(t[n])||t[n]instanceof String?r&&(e[n]=t[n]):ii(e[n],t[n],r):e[n]=t[n]);return e};var ia={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};let is=e=>o6(e)?e.replace(/[&<>"'\/]/g,e=>ia[e]):e,il=[" ",",","?","!",";"],iu=new class{constructor(e){this.capacity=e,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(e){let t=this.regExpMap.get(e);if(void 0!==t)return t;let r=new RegExp(e);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(e,r),this.regExpQueue.push(e),r}}(20),ic=(e,t,r=".")=>{if(!e)return;if(e[t]){if(!Object.prototype.hasOwnProperty.call(e,t))return;return e[t]}let n=t.split(r),o=e;for(let e=0;e<n.length;){let t;if(!o||"object"!=typeof o)return;let i="";for(let a=e;a<n.length;++a)if(a!==e&&(i+=r),i+=n[a],void 0!==(t=o[i])){if(["string","number","boolean"].indexOf(typeof t)>-1&&a<n.length-1)continue;e+=a-e+1;break}o=t}return o},id=e=>e?.replace("_","-"),ip={type:"logger",log(e){this.output("log",e)},warn(e){this.output("warn",e)},error(e){this.output("error",e)},output(e,t){console?.[e]?.apply?.(console,t)}};class ih{constructor(e,t={}){this.init(e,t)}init(e,t={}){this.prefix=t.prefix||"i18next:",this.logger=e||ip,this.options=t,this.debug=t.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,t,r,n){return n&&!this.debug?null:(o6(e[0])&&(e[0]=`${r}${this.prefix} ${e[0]}`),this.logger[t](e))}create(e){return new ih(this.logger,{...{prefix:`${this.prefix}:${e}:`},...this.options})}clone(e){return(e=e||this.options).prefix=e.prefix||this.prefix,new ih(this.logger,e)}}var im=new ih;class ig{constructor(){this.observers={}}on(e,t){return e.split(" ").forEach(e=>{this.observers[e]||(this.observers[e]=new Map);let r=this.observers[e].get(t)||0;this.observers[e].set(t,r+1)}),this}off(e,t){if(this.observers[e]){if(!t)return void delete this.observers[e];this.observers[e].delete(t)}}emit(e,...t){this.observers[e]&&Array.from(this.observers[e].entries()).forEach(([e,r])=>{for(let n=0;n<r;n++)e(...t)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(([r,n])=>{for(let o=0;o<n;o++)r.apply(r,[e,...t])})}}class iy extends ig{constructor(e,t={ns:["translation"],defaultNS:"translation"}){super(),this.data=e||{},this.options=t,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 t=this.options.ns.indexOf(e);t>-1&&this.options.ns.splice(t,1)}getResource(e,t,r,n={}){let o,i=void 0!==n.keySeparator?n.keySeparator:this.options.keySeparator,a=void 0!==n.ignoreJSONStructure?n.ignoreJSONStructure:this.options.ignoreJSONStructure;e.indexOf(".")>-1?o=e.split("."):(o=[e,t],r&&(Array.isArray(r)?o.push(...r):o6(r)&&i?o.push(...r.split(i)):o.push(r)));let s=io(this.data,o);return(!s&&!t&&!r&&e.indexOf(".")>-1&&(e=o[0],t=o[1],r=o.slice(2).join(".")),!s&&a&&o6(r))?ic(this.data?.[e]?.[t],r,i):s}addResource(e,t,r,n,o={silent:!1}){let i=void 0!==o.keySeparator?o.keySeparator:this.options.keySeparator,a=[e,t];r&&(a=a.concat(i?r.split(i):r)),e.indexOf(".")>-1&&(a=e.split("."),n=t,t=a[1]),this.addNamespaces(t),ir(this.data,a,n),o.silent||this.emit("added",e,t,r,n)}addResources(e,t,r,n={silent:!1}){for(let n in r)(o6(r[n])||Array.isArray(r[n]))&&this.addResource(e,t,n,r[n],{silent:!0});n.silent||this.emit("added",e,t,r)}addResourceBundle(e,t,r,n,o,i={silent:!1,skipCopy:!1}){let a=[e,t];e.indexOf(".")>-1&&(a=e.split("."),n=r,r=t,t=a[1]),this.addNamespaces(t);let s=io(this.data,a)||{};i.skipCopy||(r=JSON.parse(JSON.stringify(r))),n?ii(s,r,o):s={...s,...r},ir(this.data,a,s),i.silent||this.emit("added",e,t,r)}removeResourceBundle(e,t){this.hasResourceBundle(e,t)&&delete this.data[e][t],this.removeNamespaces(t),this.emit("removed",e,t)}hasResourceBundle(e,t){return void 0!==this.getResource(e,t)}getResourceBundle(e,t){return t||(t=this.options.defaultNS),this.getResource(e,t)}getDataByLanguage(e){return this.data[e]}hasLanguageSomeTranslations(e){let t=this.getDataByLanguage(e);return!!(t&&Object.keys(t)||[]).find(e=>t[e]&&Object.keys(t[e]).length>0)}toJSON(){return this.data}}var iv={processors:{},addPostProcessor(e){this.processors[e.name]=e},handle(e,t,r,n,o){return e.forEach(e=>{t=this.processors[e]?.process(t,r,n,o)??t}),t}};let ib=Symbol("i18next/PATH_KEY");function iw(e,t){let r,n,o,{[ib]:i}=e((n=[],(o=Object.create(null)).get=(e,t)=>(r?.revoke?.(),t===ib)?n:(n.push(t),(r=Proxy.revocable(e,o)).proxy),Proxy.revocable(Object.create(null),o).proxy));return i.join(t?.keySeparator??".")}let i_={},ix=e=>!o6(e)&&"boolean"!=typeof e&&"number"!=typeof e;class iE extends ig{constructor(e,t={}){super(),((e,t,r)=>{e.forEach(e=>{t[e]&&(r[e]=t[e])})})(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=t,void 0===this.options.keySeparator&&(this.options.keySeparator="."),this.logger=im.create("translator")}changeLanguage(e){e&&(this.language=e)}exists(e,t={interpolation:{}}){let r={...t};if(null==e)return!1;let n=this.resolve(e,r);if(n?.res===void 0)return!1;let o=ix(n.res);return!1!==r.returnObjects||!o}extractFromKey(e,t){let r=void 0!==t.nsSeparator?t.nsSeparator:this.options.nsSeparator;void 0===r&&(r=":");let n=void 0!==t.keySeparator?t.keySeparator:this.options.keySeparator,o=t.ns||this.options.defaultNS||[],i=r&&e.indexOf(r)>-1,a=!this.options.userDefinedKeySeparator&&!t.keySeparator&&!this.options.userDefinedNsSeparator&&!t.nsSeparator&&!((e,t,r)=>{t=t||"",r=r||"";let n=il.filter(e=>0>t.indexOf(e)&&0>r.indexOf(e));if(0===n.length)return!0;let o=iu.getRegExp(`(${n.map(e=>"?"===e?"\\?":e).join("|")})`),i=!o.test(e);if(!i){let t=e.indexOf(r);t>0&&!o.test(e.substring(0,t))&&(i=!0)}return i})(e,r,n);if(i&&!a){let t=e.match(this.interpolator.nestingRegexp);if(t&&t.length>0)return{key:e,namespaces:o6(o)?[o]:o};let i=e.split(r);(r!==n||r===n&&this.options.ns.indexOf(i[0])>-1)&&(o=i.shift()),e=i.join(n)}return{key:e,namespaces:o6(o)?[o]:o}}translate(e,t,r){let n="object"==typeof t?{...t}:t;if("object"!=typeof n&&this.options.overloadTranslationOptionHandler&&(n=this.options.overloadTranslationOptionHandler(arguments)),"object"==typeof n&&(n={...n}),n||(n={}),null==e)return"";"function"==typeof e&&(e=iw(e,{...this.options,...n})),Array.isArray(e)||(e=[String(e)]);let o=void 0!==n.returnDetails?n.returnDetails:this.options.returnDetails,i=void 0!==n.keySeparator?n.keySeparator:this.options.keySeparator,{key:a,namespaces:s}=this.extractFromKey(e[e.length-1],n),l=s[s.length-1],u=void 0!==n.nsSeparator?n.nsSeparator:this.options.nsSeparator;void 0===u&&(u=":");let c=n.lng||this.language,d=n.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(c?.toLowerCase()==="cimode")return d?o?{res:`${l}${u}${a}`,usedKey:a,exactUsedKey:a,usedLng:c,usedNS:l,usedParams:this.getUsedParamsDetails(n)}:`${l}${u}${a}`:o?{res:a,usedKey:a,exactUsedKey:a,usedLng:c,usedNS:l,usedParams:this.getUsedParamsDetails(n)}:a;let p=this.resolve(e,n),f=p?.res,h=p?.usedKey||a,m=p?.exactUsedKey||a,g=void 0!==n.joinArrays?n.joinArrays:this.options.joinArrays,y=!this.i18nFormat||this.i18nFormat.handleAsObject,v=void 0!==n.count&&!o6(n.count),b=iE.hasDefaultValue(n),w=v?this.pluralResolver.getSuffix(c,n.count,n):"",x=n.ordinal&&v?this.pluralResolver.getSuffix(c,n.count,{ordinal:!1}):"",E=v&&!n.ordinal&&0===n.count,S=E&&n[`defaultValue${this.options.pluralSeparator}zero`]||n[`defaultValue${w}`]||n[`defaultValue${x}`]||n.defaultValue,D=f;y&&!f&&b&&(D=S);let O=ix(D),k=Object.prototype.toString.apply(D);if(y&&D&&O&&0>["[object Number]","[object Function]","[object RegExp]"].indexOf(k)&&!(o6(g)&&Array.isArray(D))){if(!n.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,D,{...n,ns:s}):`key '${a} (${this.language})' returned an object instead of string.`;return o?(p.res=e,p.usedParams=this.getUsedParamsDetails(n),p):e}if(i){let e=Array.isArray(D),t=e?[]:{},r=e?m:h;for(let e in D)if(Object.prototype.hasOwnProperty.call(D,e)){let o=`${r}${i}${e}`;b&&!f?t[e]=this.translate(o,{...n,defaultValue:ix(S)?S[e]:void 0,...{joinArrays:!1,ns:s}}):t[e]=this.translate(o,{...n,joinArrays:!1,ns:s}),t[e]===o&&(t[e]=D[e])}f=t}}else if(y&&o6(g)&&Array.isArray(f))(f=f.join(g))&&(f=this.extendTranslation(f,e,n,r));else{let t=!1,o=!1;!this.isValidLookup(f)&&b&&(t=!0,f=S),this.isValidLookup(f)||(o=!0,f=a);let s=(n.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&o?void 0:f,d=b&&S!==f&&this.options.updateMissing;if(o||t||d){if(this.logger.log(d?"updateKey":"missingKey",c,l,a,d?S:f),i){let e=this.resolve(a,{...n,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=[],t=this.languageUtils.getFallbackCodes(this.options.fallbackLng,n.lng||this.language);if("fallback"===this.options.saveMissingTo&&t&&t[0])for(let r=0;r<t.length;r++)e.push(t[r]);else"all"===this.options.saveMissingTo?e=this.languageUtils.toResolveHierarchy(n.lng||this.language):e.push(n.lng||this.language);let r=(e,t,r)=>{let o=b&&r!==f?r:s;this.options.missingKeyHandler?this.options.missingKeyHandler(e,l,t,o,d,n):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(e,l,t,o,d,n),this.emit("missingKey",e,l,t,f)};this.options.saveMissing&&(this.options.saveMissingPlurals&&v?e.forEach(e=>{let t=this.pluralResolver.getSuffixes(e,n);E&&n[`defaultValue${this.options.pluralSeparator}zero`]&&0>t.indexOf(`${this.options.pluralSeparator}zero`)&&t.push(`${this.options.pluralSeparator}zero`),t.forEach(t=>{r([e],a+t,n[`defaultValue${t}`]||S)})}):r(e,a,S))}f=this.extendTranslation(f,e,n,p,r),o&&f===a&&this.options.appendNamespaceToMissingKey&&(f=`${l}${u}${a}`),(o||t)&&this.options.parseMissingKeyHandler&&(f=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${l}${u}${a}`:a,t?f:void 0,n))}return o?(p.res=f,p.usedParams=this.getUsedParamsDetails(n),p):f}extendTranslation(e,t,r,n,o){if(this.i18nFormat?.parse)e=this.i18nFormat.parse(e,{...this.options.interpolation.defaultVariables,...r},r.lng||this.language||n.usedLng,n.usedNS,n.usedKey,{resolved:n});else if(!r.skipInterpolation){let i;r.interpolation&&this.interpolator.init({...r,...{interpolation:{...this.options.interpolation,...r.interpolation}}});let a=o6(e)&&(r?.interpolation?.skipOnVariables!==void 0?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);if(a){let t=e.match(this.interpolator.nestingRegexp);i=t&&t.length}let s=r.replace&&!o6(r.replace)?r.replace:r;if(this.options.interpolation.defaultVariables&&(s={...this.options.interpolation.defaultVariables,...s}),e=this.interpolator.interpolate(e,s,r.lng||this.language||n.usedLng,r),a){let t=e.match(this.interpolator.nestingRegexp);i<(t&&t.length)&&(r.nest=!1)}!r.lng&&n&&n.res&&(r.lng=this.language||n.usedLng),!1!==r.nest&&(e=this.interpolator.nest(e,(...e)=>o?.[0]!==e[0]||r.context?this.translate(...e,t):(this.logger.warn(`It seems you are nesting recursively key: ${e[0]} in key: ${t[0]}`),null),r)),r.interpolation&&this.interpolator.reset()}let i=r.postProcess||this.options.postProcess,a=o6(i)?[i]:i;return null!=e&&a?.length&&!1!==r.applyPostProcessor&&(e=iv.handle(a,e,t,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...n,usedParams:this.getUsedParamsDetails(r)},...r}:r,this)),e}resolve(e,t={}){let r,n,o,i,a;return o6(e)&&(e=[e]),e.forEach(e=>{if(this.isValidLookup(r))return;let s=this.extractFromKey(e,t),l=s.key;n=l;let u=s.namespaces;this.options.fallbackNS&&(u=u.concat(this.options.fallbackNS));let c=void 0!==t.count&&!o6(t.count),d=c&&!t.ordinal&&0===t.count,p=void 0!==t.context&&(o6(t.context)||"number"==typeof t.context)&&""!==t.context,f=t.lngs?t.lngs:this.languageUtils.toResolveHierarchy(t.lng||this.language,t.fallbackLng);u.forEach(e=>{this.isValidLookup(r)||(a=e,!i_[`${f[0]}-${e}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(a)&&(i_[`${f[0]}-${e}`]=!0,this.logger.warn(`key "${n}" 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(n=>{let a;if(this.isValidLookup(r))return;i=n;let s=[l];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(s,l,n,e,t);else{let e;c&&(e=this.pluralResolver.getSuffix(n,t.count,t));let r=`${this.options.pluralSeparator}zero`,o=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(c&&(t.ordinal&&0===e.indexOf(o)&&s.push(l+e.replace(o,this.options.pluralSeparator)),s.push(l+e),d&&s.push(l+r)),p){let n=`${l}${this.options.contextSeparator||"_"}${t.context}`;s.push(n),c&&(t.ordinal&&0===e.indexOf(o)&&s.push(n+e.replace(o,this.options.pluralSeparator)),s.push(n+e),d&&s.push(n+r))}}for(;a=s.pop();)this.isValidLookup(r)||(o=a,r=this.getResource(n,e,a,t))}))})}),{res:r,usedKey:n,exactUsedKey:o,usedLng:i,usedNS:a}}isValidLookup(e){return void 0!==e&&!(!this.options.returnNull&&null===e)&&!(!this.options.returnEmptyString&&""===e)}getResource(e,t,r,n={}){return this.i18nFormat?.getResource?this.i18nFormat.getResource(e,t,r,n):this.resourceStore.getResource(e,t,r,n)}getUsedParamsDetails(e={}){let t=e.replace&&!o6(e.replace),r=t?e.replace:e;if(t&&void 0!==e.count&&(r.count=e.count),this.options.interpolation.defaultVariables&&(r={...this.options.interpolation.defaultVariables,...r}),!t)for(let e of(r={...r},["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"]))delete r[e];return r}static hasDefaultValue(e){let t="defaultValue";for(let r in e)if(Object.prototype.hasOwnProperty.call(e,r)&&t===r.substring(0,t.length)&&void 0!==e[r])return!0;return!1}}class iS{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=im.create("languageUtils")}getScriptPartFromCode(e){if(!(e=id(e))||0>e.indexOf("-"))return null;let t=e.split("-");return 2===t.length||(t.pop(),"x"===t[t.length-1].toLowerCase())?null:this.formatLanguageCode(t.join("-"))}getLanguagePartFromCode(e){if(!(e=id(e))||0>e.indexOf("-"))return e;let t=e.split("-");return this.formatLanguageCode(t[0])}formatLanguageCode(e){if(o6(e)&&e.indexOf("-")>-1){let t;try{t=Intl.getCanonicalLocales(e)[0]}catch(e){}return(t&&this.options.lowerCaseLng&&(t=t.toLowerCase()),t)?t: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 t;return e?(e.forEach(e=>{if(t)return;let r=this.formatLanguageCode(e);(!this.options.supportedLngs||this.isSupportedCode(r))&&(t=r)}),!t&&this.options.supportedLngs&&e.forEach(e=>{if(t)return;let r=this.getScriptPartFromCode(e);if(this.isSupportedCode(r))return t=r;let n=this.getLanguagePartFromCode(e);if(this.isSupportedCode(n))return t=n;t=this.options.supportedLngs.find(e=>{if(e===n||!(0>e.indexOf("-")&&0>n.indexOf("-"))&&(e.indexOf("-")>0&&0>n.indexOf("-")&&e.substring(0,e.indexOf("-"))===n||0===e.indexOf(n)&&n.length>1))return e})}),t||(t=this.getFallbackCodes(this.options.fallbackLng)[0]),t):null}getFallbackCodes(e,t){if(!e)return[];if("function"==typeof e&&(e=e(t)),o6(e)&&(e=[e]),Array.isArray(e))return e;if(!t)return e.default||[];let r=e[t];return r||(r=e[this.getScriptPartFromCode(t)]),r||(r=e[this.formatLanguageCode(t)]),r||(r=e[this.getLanguagePartFromCode(t)]),r||(r=e.default),r||[]}toResolveHierarchy(e,t){let r=this.getFallbackCodes((!1===t?[]:t)||this.options.fallbackLng||[],e),n=[],o=e=>{e&&(this.isSupportedCode(e)?n.push(e):this.logger.warn(`rejecting language code not found in supportedLngs: ${e}`))};return o6(e)&&(e.indexOf("-")>-1||e.indexOf("_")>-1)?("languageOnly"!==this.options.load&&o(this.formatLanguageCode(e)),"languageOnly"!==this.options.load&&"currentOnly"!==this.options.load&&o(this.getScriptPartFromCode(e)),"currentOnly"!==this.options.load&&o(this.getLanguagePartFromCode(e))):o6(e)&&o(this.formatLanguageCode(e)),r.forEach(e=>{0>n.indexOf(e)&&o(this.formatLanguageCode(e))}),n}}let iD={zero:0,one:1,two:2,few:3,many:4,other:5},iO={select:e=>1===e?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class ik{constructor(e,t={}){this.languageUtils=e,this.options=t,this.logger=im.create("pluralResolver"),this.pluralRulesCache={}}addRule(e,t){this.rules[e]=t}clearCache(){this.pluralRulesCache={}}getRule(e,t={}){let r,n=id("dev"===e?"en":e),o=t.ordinal?"ordinal":"cardinal",i=JSON.stringify({cleanedCode:n,type:o});if(i in this.pluralRulesCache)return this.pluralRulesCache[i];try{r=new Intl.PluralRules(n,{type:o})}catch(o){if(!Intl)return this.logger.error("No Intl support, please use an Intl polyfill!"),iO;if(!e.match(/-|_/))return iO;let n=this.languageUtils.getLanguagePartFromCode(e);r=this.getRule(n,t)}return this.pluralRulesCache[i]=r,r}needsPlural(e,t={}){let r=this.getRule(e,t);return r||(r=this.getRule("dev",t)),r?.resolvedOptions().pluralCategories.length>1}getPluralFormsOfKey(e,t,r={}){return this.getSuffixes(e,r).map(e=>`${t}${e}`)}getSuffixes(e,t={}){let r=this.getRule(e,t);return(r||(r=this.getRule("dev",t)),r)?r.resolvedOptions().pluralCategories.sort((e,t)=>iD[e]-iD[t]).map(e=>`${this.options.prepend}${t.ordinal?`ordinal${this.options.prepend}`:""}${e}`):[]}getSuffix(e,t,r={}){let n=this.getRule(e,r);return n?`${this.options.prepend}${r.ordinal?`ordinal${this.options.prepend}`:""}${n.select(t)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix("dev",t,r))}}let iP=(e,t,r,n=".",o=!0)=>{let i,a=void 0!==(i=io(e,r))?i:io(t,r);return!a&&o&&o6(r)&&void 0===(a=ic(e,r,n))&&(a=ic(t,r,n)),a};class iC{constructor(e={}){this.logger=im.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:t,escapeValue:r,useRawValueToEscape:n,prefix:o,prefixEscaped:i,suffix:a,suffixEscaped:s,formatSeparator:l,unescapeSuffix:u,unescapePrefix:c,nestingPrefix:d,nestingPrefixEscaped:p,nestingSuffix:f,nestingSuffixEscaped:h,nestingOptionsSeparator:m,maxReplaces:g,alwaysFormat:y}=e.interpolation;this.escape=void 0!==t?t:is,this.escapeValue=void 0===r||r,this.useRawValueToEscape=void 0!==n&&n,this.prefix=o?o.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"):i||"{{",this.suffix=a?a.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"):s||"}}",this.formatSeparator=l||",",this.unescapePrefix=u?"":c||"-",this.unescapeSuffix=this.unescapePrefix?"":u||"",this.nestingPrefix=d?d.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"):p||"$t(".replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),this.nestingSuffix=f?f.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"):h||")".replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),this.nestingOptionsSeparator=m||",",this.maxReplaces=g||1e3,this.alwaysFormat=void 0!==y&&y,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){let e=(e,t)=>e?.source===t?(e.lastIndex=0,e):RegExp(t,"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,t,r,n){let o,i,a,s=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},l=e=>{if(0>e.indexOf(this.formatSeparator)){let o=iP(t,s,e,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(o,void 0,r,{...n,...t,interpolationkey:e}):o}let o=e.split(this.formatSeparator),i=o.shift().trim(),a=o.join(this.formatSeparator).trim();return this.format(iP(t,s,i,this.options.keySeparator,this.options.ignoreJSONStructure),a,r,{...n,...t,interpolationkey:i})};this.resetRegExp();let u=n?.missingInterpolationHandler||this.options.missingInterpolationHandler,c=n?.interpolation?.skipOnVariables!==void 0?n.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(t=>{for(a=0;o=t.regex.exec(e);){let r=o[1].trim();if(void 0===(i=l(r)))if("function"==typeof u){let t=u(e,o,n);i=o6(t)?t:""}else if(n&&Object.prototype.hasOwnProperty.call(n,r))i="";else if(c){i=o[0];continue}else this.logger.warn(`missed to pass in variable ${r} for interpolating ${e}`),i="";else o6(i)||this.useRawValueToEscape||(i=o8(i));let s=t.safeValue(i);if(e=e.replace(o[0],s),c?(t.regex.lastIndex+=i.length,t.regex.lastIndex-=o[0].length):t.regex.lastIndex=0,++a>=this.maxReplaces)break}}),e}nest(e,t,r={}){let n,o,i,a=(e,t)=>{let r=this.nestingOptionsSeparator;if(0>e.indexOf(r))return e;let n=e.split(RegExp(`${r}[ ]*{`)),o=`{${n[1]}`;e=n[0];let a=(o=this.interpolate(o,i)).match(/'/g),s=o.match(/"/g);((a?.length??0)%2!=0||s)&&s.length%2==0||(o=o.replace(/'/g,'"'));try{i=JSON.parse(o),t&&(i={...t,...i})}catch(t){return this.logger.warn(`failed parsing options string in nesting for key ${e}`,t),`${e}${r}${o}`}return i.defaultValue&&i.defaultValue.indexOf(this.prefix)>-1&&delete i.defaultValue,e};for(;n=this.nestingRegexp.exec(e);){let s=[];(i=(i={...r}).replace&&!o6(i.replace)?i.replace:i).applyPostProcessor=!1,delete i.defaultValue;let l=/{.*}/.test(n[1])?n[1].lastIndexOf("}")+1:n[1].indexOf(this.formatSeparator);if(-1!==l&&(s=n[1].slice(l).split(this.formatSeparator).map(e=>e.trim()).filter(Boolean),n[1]=n[1].slice(0,l)),(o=t(a.call(this,n[1].trim(),i),i))&&n[0]===e&&!o6(o))return o;o6(o)||(o=o8(o)),o||(this.logger.warn(`missed to resolve ${n[1]} for nesting ${e}`),o=""),s.length&&(o=s.reduce((e,t)=>this.format(e,t,r.lng,{...r,interpolationkey:n[1].trim()}),o.trim())),e=e.replace(n[0],o),this.regexp.lastIndex=0}return e}}let ij=e=>{let t={};return(r,n,o)=>{let i=o;o&&o.interpolationkey&&o.formatParams&&o.formatParams[o.interpolationkey]&&o[o.interpolationkey]&&(i={...i,[o.interpolationkey]:void 0});let a=n+JSON.stringify(i),s=t[a];return s||(s=e(id(n),o),t[a]=s),s(r)}},iT=e=>(t,r,n)=>e(id(r),n)(t);class iR{constructor(e={}){this.logger=im.create("formatter"),this.options=e,this.init(e)}init(e,t={interpolation:{}}){this.formatSeparator=t.interpolation.formatSeparator||",";let r=t.cacheInBuiltFormats?ij:iT;this.formats={number:r((e,t)=>{let r=new Intl.NumberFormat(e,{...t});return e=>r.format(e)}),currency:r((e,t)=>{let r=new Intl.NumberFormat(e,{...t,style:"currency"});return e=>r.format(e)}),datetime:r((e,t)=>{let r=new Intl.DateTimeFormat(e,{...t});return e=>r.format(e)}),relativetime:r((e,t)=>{let r=new Intl.RelativeTimeFormat(e,{...t});return e=>r.format(e,t.range||"day")}),list:r((e,t)=>{let r=new Intl.ListFormat(e,{...t});return e=>r.format(e)})}}add(e,t){this.formats[e.toLowerCase().trim()]=t}addCached(e,t){this.formats[e.toLowerCase().trim()]=ij(t)}format(e,t,r,n={}){let o=t.split(this.formatSeparator);if(o.length>1&&o[0].indexOf("(")>1&&0>o[0].indexOf(")")&&o.find(e=>e.indexOf(")")>-1)){let e=o.findIndex(e=>e.indexOf(")")>-1);o[0]=[o[0],...o.splice(1,e)].join(this.formatSeparator)}return o.reduce((e,t)=>{let{formatName:o,formatOptions:i}=(e=>{let t=e.toLowerCase().trim(),r={};if(e.indexOf("(")>-1){let n=e.split("(");t=n[0].toLowerCase().trim();let o=n[1].substring(0,n[1].length-1);"currency"===t&&0>o.indexOf(":")?r.currency||(r.currency=o.trim()):"relativetime"===t&&0>o.indexOf(":")?r.range||(r.range=o.trim()):o.split(";").forEach(e=>{if(e){let[t,...n]=e.split(":"),o=n.join(":").trim().replace(/^'+|'+$/g,""),i=t.trim();r[i]||(r[i]=o),"false"===o&&(r[i]=!1),"true"===o&&(r[i]=!0),isNaN(o)||(r[i]=parseInt(o,10))}})}return{formatName:t,formatOptions:r}})(t);if(this.formats[o]){let t=e;try{let a=n?.formatParams?.[n.interpolationkey]||{},s=a.locale||a.lng||n.locale||n.lng||r;t=this.formats[o](e,s,{...i,...n,...a})}catch(e){this.logger.warn(e)}return t}return this.logger.warn(`there was no format function for ${o}`),e},e)}}class iA extends ig{constructor(e,t,r,n={}){super(),this.backend=e,this.store=t,this.services=r,this.languageUtils=r.languageUtils,this.options=n,this.logger=im.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=n.maxParallelReads||10,this.readingCalls=0,this.maxRetries=n.maxRetries>=0?n.maxRetries:5,this.retryTimeout=n.retryTimeout>=1?n.retryTimeout:350,this.state={},this.queue=[],this.backend?.init?.(r,n.backend,n)}queueLoad(e,t,r,n){let o={},i={},a={},s={};return e.forEach(e=>{let n=!0;t.forEach(t=>{let a=`${e}|${t}`;!r.reload&&this.store.hasResourceBundle(e,t)?this.state[a]=2:this.state[a]<0||(1===this.state[a]?void 0===i[a]&&(i[a]=!0):(this.state[a]=1,n=!1,void 0===i[a]&&(i[a]=!0),void 0===o[a]&&(o[a]=!0),void 0===s[t]&&(s[t]=!0)))}),n||(a[e]=!0)}),(Object.keys(o).length||Object.keys(i).length)&&this.queue.push({pending:i,pendingCount:Object.keys(i).length,loaded:{},errors:[],callback:n}),{toLoad:Object.keys(o),pending:Object.keys(i),toLoadLanguages:Object.keys(a),toLoadNamespaces:Object.keys(s)}}loaded(e,t,r){let n=e.split("|"),o=n[0],i=n[1];t&&this.emit("failedLoading",o,i,t),!t&&r&&this.store.addResourceBundle(o,i,r,void 0,void 0,{skipCopy:!0}),this.state[e]=t?-1:2,t&&r&&(this.state[e]=0);let a={};this.queue.forEach(r=>{((e,t,r,n)=>{let{obj:o,k:i}=it(e,t,Object);o[i]=o[i]||[],o[i].push(r)})(r.loaded,[o],i),void 0!==r.pending[e]&&(delete r.pending[e],r.pendingCount--),t&&r.errors.push(t),0!==r.pendingCount||r.done||(Object.keys(r.loaded).forEach(e=>{a[e]||(a[e]={});let t=r.loaded[e];t.length&&t.forEach(t=>{void 0===a[e][t]&&(a[e][t]=!0)})}),r.done=!0,r.errors.length?r.callback(r.errors):r.callback())}),this.emit("loaded",a),this.queue=this.queue.filter(e=>!e.done)}read(e,t,r,n=0,o=this.retryTimeout,i){if(!e.length)return i(null,{});if(this.readingCalls>=this.maxParallelReads)return void this.waitingReads.push({lng:e,ns:t,fcName:r,tried:n,wait:o,callback:i});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&&n<this.maxRetries?setTimeout(()=>{this.read.call(this,e,t,r,n+1,2*o,i)},o):i(a,s)},s=this.backend[r].bind(this.backend);if(2===s.length){try{let r=s(e,t);r&&"function"==typeof r.then?r.then(e=>a(null,e)).catch(a):a(null,r)}catch(e){a(e)}return}return s(e,t,a)}prepareLoading(e,t,r={},n){if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),n&&n();o6(e)&&(e=this.languageUtils.toResolveHierarchy(e)),o6(t)&&(t=[t]);let o=this.queueLoad(e,t,r,n);if(!o.toLoad.length)return o.pending.length||n(),null;o.toLoad.forEach(e=>{this.loadOne(e)})}load(e,t,r){this.prepareLoading(e,t,{},r)}reload(e,t,r){this.prepareLoading(e,t,{reload:!0},r)}loadOne(e,t=""){let r=e.split("|"),n=r[0],o=r[1];this.read(n,o,"read",void 0,void 0,(r,i)=>{r&&this.logger.warn(`${t}loading namespace ${o} for language ${n} failed`,r),!r&&i&&this.logger.log(`${t}loaded namespace ${o} for language ${n}`,i),this.loaded(e,r,i)})}saveMissing(e,t,r,n,o,i={},a=()=>{}){if(this.services?.utils?.hasLoadedNamespace&&!this.services?.utils?.hasLoadedNamespace(t))return void this.logger.warn(`did not save key "${r}" as the namespace "${t}" 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!=r&&""!==r){if(this.backend?.create){let s={...i,isUpdate:o},l=this.backend.create.bind(this.backend);if(l.length<6)try{let o;(o=5===l.length?l(e,t,r,n,s):l(e,t,r,n))&&"function"==typeof o.then?o.then(e=>a(null,e)).catch(a):a(null,o)}catch(e){a(e)}else l(e,t,r,n,a,s)}e&&e[0]&&this.store.addResource(e[0],t,r,n)}}}let iN=()=>({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 t={};if("object"==typeof e[1]&&(t=e[1]),o6(e[1])&&(t.defaultValue=e[1]),o6(e[2])&&(t.tDescription=e[2]),"object"==typeof e[2]||"object"==typeof e[3]){let r=e[3]||e[2];Object.keys(r).forEach(e=>{t[e]=r[e]})}return t},interpolation:{escapeValue:!0,format:e=>e,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0},cacheInBuiltFormats:!0}),i$=e=>(o6(e.ns)&&(e.ns=[e.ns]),o6(e.fallbackLng)&&(e.fallbackLng=[e.fallbackLng]),o6(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),iI=()=>{};class iM extends ig{constructor(e={},t){if(super(),this.options=i$(e),this.services={},this.logger=im,this.modules={external:[]},(e=>{Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach(t=>{"function"==typeof e[t]&&(e[t]=e[t].bind(e))})})(this),t&&!this.isInitialized&&!e.isClone){if(!this.options.initAsync)return this.init(e,t),this;setTimeout(()=>{this.init(e,t)},0)}}init(e={},t){this.isInitializing=!0,"function"==typeof e&&(t=e,e={}),null==e.defaultNS&&e.ns&&(o6(e.ns)?e.defaultNS=e.ns:0>e.ns.indexOf("translation")&&(e.defaultNS=e.ns[0]));let r=iN();this.options={...r,...this.options,...i$(e)},this.options.interpolation={...r.interpolation,...this.options.interpolation},void 0!==e.keySeparator&&(this.options.userDefinedKeySeparator=e.keySeparator),void 0!==e.nsSeparator&&(this.options.userDefinedNsSeparator=e.nsSeparator);let n=e=>e?"function"==typeof e?new e:e:null;if(!this.options.isClone){let e;this.modules.logger?im.init(n(this.modules.logger),this.options):im.init(null,this.options),e=this.modules.formatter?this.modules.formatter:iR;let t=new iS(this.options);this.store=new iy(this.options.resources,this.options);let o=this.services;o.logger=im,o.resourceStore=this.store,o.languageUtils=t,o.pluralResolver=new ik(t,{prepend:this.options.pluralSeparator,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),this.options.interpolation.format&&this.options.interpolation.format!==r.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===r.interpolation.format)&&(o.formatter=n(e),o.formatter.init&&o.formatter.init(o,this.options),this.options.interpolation.format=o.formatter.format.bind(o.formatter)),o.interpolator=new iC(this.options),o.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},o.backendConnector=new iA(n(this.modules.backend),o.resourceStore,o,this.options),o.backendConnector.on("*",(e,...t)=>{this.emit(e,...t)}),this.modules.languageDetector&&(o.languageDetector=n(this.modules.languageDetector),o.languageDetector.init&&o.languageDetector.init(o,this.options.detection,this.options)),this.modules.i18nFormat&&(o.i18nFormat=n(this.modules.i18nFormat),o.i18nFormat.init&&o.i18nFormat.init(this)),this.translator=new iE(this.services,this.options),this.translator.on("*",(e,...t)=>{this.emit(e,...t)}),this.modules.external.forEach(e=>{e.init&&e.init(this)})}if(this.format=this.options.interpolation.format,t||(t=iI),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]=(...t)=>this.store[e](...t)}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(e=>{this[e]=(...t)=>(this.store[e](...t),this)});let o=o5(),i=()=>{let e=(e,r)=>{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),o.resolve(r),t(e,r)};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?i():setTimeout(i,0),o}loadResources(e,t=iI){let r=t,n=o6(e)?e:this.language;if("function"==typeof e&&(r=e),!this.options.resources||this.options.partialBundledLanguages){if(n?.toLowerCase()==="cimode"&&(!this.options.preload||0===this.options.preload.length))return r();let e=[],t=t=>{t&&"cimode"!==t&&this.services.languageUtils.toResolveHierarchy(t).forEach(t=>{"cimode"!==t&&0>e.indexOf(t)&&e.push(t)})};n?t(n):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(e=>t(e)),this.options.preload?.forEach?.(e=>t(e)),this.services.backendConnector.load(e,this.options.ns,e=>{e||this.resolvedLanguage||!this.language||this.setResolvedLanguage(this.language),r(e)})}else r(null)}reloadResources(e,t,r){let n=o5();return"function"==typeof e&&(r=e,e=void 0),"function"==typeof t&&(r=t,t=void 0),e||(e=this.languages),t||(t=this.options.ns),r||(r=iI),this.services.backendConnector.reload(e,t,e=>{n.resolve(),r(e)}),n}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&&iv.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 t=this.languages[e];if(!(["cimode","dev"].indexOf(t)>-1)&&this.store.hasLanguageSomeTranslations(t)){this.resolvedLanguage=t;break}}!this.resolvedLanguage&&0>this.languages.indexOf(e)&&this.store.hasLanguageSomeTranslations(e)&&(this.resolvedLanguage=e,this.languages.unshift(e))}}changeLanguage(e,t){this.isLanguageChangingTo=e;let r=o5();this.emit("languageChanging",e);let n=e=>{this.language=e,this.languages=this.services.languageUtils.toResolveHierarchy(e),this.resolvedLanguage=void 0,this.setResolvedLanguage(e)},o=(o,i)=>{i?this.isLanguageChangingTo===e&&(n(i),this.translator.changeLanguage(i),this.isLanguageChangingTo=void 0,this.emit("languageChanged",i),this.logger.log("languageChanged",i)):this.isLanguageChangingTo=void 0,r.resolve((...e)=>this.t(...e)),t&&t(o,(...e)=>this.t(...e))},i=t=>{e||t||!this.services.languageDetector||(t=[]);let r=o6(t)?t:t&&t[0],i=this.store.hasLanguageSomeTranslations(r)?r:this.services.languageUtils.getBestMatchFromCodes(o6(t)?[t]:t);i&&(this.language||n(i),this.translator.language||this.translator.changeLanguage(i),this.services.languageDetector?.cacheUserLanguage?.(i)),this.loadResources(i,e=>{o(e,i)})};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(i):this.services.languageDetector.detect(i):i(e):i(this.services.languageDetector.detect()),r}getFixedT(e,t,r){let n=(e,t,...o)=>{let i,a;(i="object"!=typeof t?this.options.overloadTranslationOptionHandler([e,t].concat(o)):{...t}).lng=i.lng||n.lng,i.lngs=i.lngs||n.lngs,i.ns=i.ns||n.ns,""!==i.keyPrefix&&(i.keyPrefix=i.keyPrefix||r||n.keyPrefix);let s=this.options.keySeparator||".";return i.keyPrefix&&Array.isArray(e)?a=e.map(e=>("function"==typeof e&&(e=iw(e,{...this.options,...t})),`${i.keyPrefix}${s}${e}`)):("function"==typeof e&&(e=iw(e,{...this.options,...t})),a=i.keyPrefix?`${i.keyPrefix}${s}${e}`:e),this.t(a,i)};return o6(e)?n.lng=e:n.lngs=e,n.ns=t,n.keyPrefix=r,n}t(...e){return this.translator?.translate(...e)}exists(...e){return this.translator?.exists(...e)}setDefaultNamespace(e){this.options.defaultNS=e}hasLoadedNamespace(e,t={}){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 r=t.lng||this.resolvedLanguage||this.languages[0],n=!!this.options&&this.options.fallbackLng,o=this.languages[this.languages.length-1];if("cimode"===r.toLowerCase())return!0;let i=(e,t)=>{let r=this.services.backendConnector.state[`${e}|${t}`];return -1===r||0===r||2===r};if(t.precheck){let e=t.precheck(this,i);if(void 0!==e)return e}return!!(this.hasResourceBundle(r,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||i(r,e)&&(!n||i(o,e)))}loadNamespaces(e,t){let r=o5();return this.options.ns?(o6(e)&&(e=[e]),e.forEach(e=>{0>this.options.ns.indexOf(e)&&this.options.ns.push(e)}),this.loadResources(e=>{r.resolve(),t&&t(e)}),r):(t&&t(),Promise.resolve())}loadLanguages(e,t){let r=o5();o6(e)&&(e=[e]);let n=this.options.preload||[],o=e.filter(e=>0>n.indexOf(e)&&this.services.languageUtils.isSupportedCode(e));return o.length?(this.options.preload=n.concat(o),this.loadResources(e=>{r.resolve(),t&&t(e)}),r):(t&&t(),Promise.resolve())}dir(e){if(e||(e=this.resolvedLanguage||(this.languages?.length>0?this.languages[0]:this.language)),!e)return"rtl";try{let t=new Intl.Locale(e);if(t&&t.getTextInfo){let e=t.getTextInfo();if(e&&e.direction)return e.direction}}catch(e){}let t=this.services?.languageUtils||new iS(iN());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(t.getLanguagePartFromCode(e))>-1||e.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(e={},t){return new iM(e,t)}cloneInstance(e={},t=iI){let r=e.forkResourceStore;r&&delete e.forkResourceStore;let n={...this.options,...e,isClone:!0},o=new iM(n);return(void 0!==e.debug||void 0!==e.prefix)&&(o.logger=o.logger.clone(e)),["store","services","language"].forEach(e=>{o[e]=this[e]}),o.services={...this.services},o.services.utils={hasLoadedNamespace:o.hasLoadedNamespace.bind(o)},r&&(o.store=new iy(Object.keys(this.store.data).reduce((e,t)=>(e[t]={...this.store.data[t]},e[t]=Object.keys(e[t]).reduce((r,n)=>(r[n]={...e[t][n]},r),e[t]),e),{}),n),o.services.resourceStore=o.store),o.translator=new iE(o.services,n),o.translator.on("*",(e,...t)=>{o.emit(e,...t)}),o.init(n,t),o.translator.options=n,o.translator.backendConnector.services.utils={hasLoadedNamespace:o.hasLoadedNamespace.bind(o)},o}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}let iL=iM.createInstance();iL.createInstance=iM.createInstance,iL.createInstance,iL.dir,iL.init,iL.loadResources,iL.reloadResources,iL.use,iL.changeLanguage,iL.getFixedT,iL.t,iL.exists,iL.setDefaultNamespace,iL.hasLoadedNamespace,iL.loadNamespaces,iL.loadLanguages;let iF=iL.default||iL;function iB(e,t,r,n){return iF.t(t,{ns:e,defaultValue:r,...n})}function iV(e,t,r){return o2[e]?iB("core",e,t??o2[e],r):(console.error(`O3 Core Translations does not provide key '${e}'. The key itself is being rendered as text.`),e)}iF.on("initialized",function(){window.i18next.loadNamespaces(["core"])});let iU="import-map-override:",iW="import-map-overrides-disabled",iK="import-map-overrides:change",iz=!1,iH=null,iG=null;async function iq(){return iG??(iG=iY().then(({map:e,complete:t})=>(t||(iG=null),e))),iG}async function iY(){let e=document.querySelectorAll('script[type="systemjs-importmap"]'),t=[],r=!0;for(let n=0;n<e.length;n++){let o=e[n];try{if(o.src){let e=await fetch(o.src);if(!e.ok)throw Error(`Request for ${o.src} returned ${e.status} ${e.statusText}`);t.push(await e.json())}else o.textContent&&t.push(JSON.parse(o.textContent))}catch(e){r=!1,console.warn(`[import-maps] Failed to parse import map from script tag at index ${n}`,e)}}return{map:iZ(t),complete:r}}function iZ(e){let t={imports:{}};for(let r of e)r?.imports&&Object.assign(t.imports,r.imports);return t}function iJ(){let e={};try{let t=i4();for(let r=0;r<localStorage.length;r++){let n=localStorage.key(r);if(n?.startsWith(iU)){let r=n.slice(iU.length);if(!t.includes(r)){let t=localStorage.getItem(n);t&&(e[r]=t)}}}}catch(e){console.warn("[import-maps] Failed to read import-map overrides from localStorage",e)}return{imports:e}}async function iX(){let e=await iq();return iz?iZ([e,iH??iJ()]):e}async function iQ(){return iq()}async function i0(){return iz?iZ([await iq(),iJ()]):iq()}function i1(e){if(!iz)return{imports:{}};if(e){let e={};for(let t=0;t<localStorage.length;t++){let r=localStorage.key(t);if(r?.startsWith(iU)){let t=localStorage.getItem(r);t&&(e[r.slice(iU.length)]=t)}}return{imports:e}}return iJ()}function i4(){if(!iz)return[];try{let e=localStorage.getItem(iW);if(e){let t=JSON.parse(e);if(Array.isArray(t))return t}}catch{}return[]}function i3(e){return!!iz&&i4().includes(e)}function i2(e,t){if(!iz)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{localStorage.setItem(iU+e,t),window.dispatchEvent(new CustomEvent(iK))}catch(e){console.warn("[import-maps] Failed to write import-map override to localStorage",e)}}function i6(e){if(!iz)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{localStorage.removeItem(iU+e);let t=i4().filter(t=>t!==e);t.length>0?localStorage.setItem(iW,JSON.stringify(t)):localStorage.removeItem(iW),window.dispatchEvent(new CustomEvent(iK))}catch(e){console.warn("[import-maps] Failed to update import-map overrides in localStorage",e)}}function i5(){if(!iz)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{let e=[];for(let t=0;t<localStorage.length;t++){let r=localStorage.key(t);r?.startsWith(iU)&&e.push(r)}e.forEach(e=>localStorage.removeItem(e)),localStorage.removeItem(iW),window.dispatchEvent(new CustomEvent(iK))}catch(e){console.warn("[import-maps] Failed to clear import-map overrides from localStorage",e)}}function i8(e){if(!iz)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{let t=i4().filter(t=>t!==e);t.length>0?localStorage.setItem(iW,JSON.stringify(t)):localStorage.removeItem(iW),window.dispatchEvent(new CustomEvent(iK))}catch(e){console.warn("[import-maps] Failed to update import-map overrides in localStorage",e)}}let i9=!1;function i7(){!i9&&(i9=!0,(iz="development"===window.spaEnv)&&(iH=iJ()))}function ae(e){return e.replace(/[\/\-@]/g,"_")}async function at(e,t="./start",n){var o;let i,a=!n?.maxLoadingTime||n.maxLoadingTime<=0?6e5:n.maxLoadingTime;await Promise.race([ar(e,n?.importMap),new Promise((t,r)=>{i=setTimeout(()=>{var t;r(Error(`Could not resolve requested script, ${e}, within ${(t=a)<1e3?`${t} milliseconds`:t<6e4?`${Math.floor(t/1e3)} seconds`:t<36e5?`${Math.floor(t/6e4)} minutes`:t<864e5?`${Math.floor(t/36e5)} hours`:`${Math.floor(t/864e5)} days`}.`))},a)})]),i&&clearTimeout(i);let s=ae(e),l=window[s];if(!("object"==typeof(o=l)&&null!==o&&"init"in o&&"function"==typeof o.init&&"get"in o&&"function"==typeof o.get)){let e=`The global variable ${s} does not refer to a federated module`;throw console.error(e),Error(e)}l.init(r.S.default);let u=(await l.get(t))();if("object"!=typeof u||null===u){let t=`Container for ${e} did not return an ESM module as expected`;throw console.error(t),Error(t)}return u}async function ar(e,t){if("string"!=typeof e||0===e.trim().length){let e="Attempted to call importDynamic() without supplying a package to load";throw console.error(e),Error(e)}let r=ae(e);if(!window[r]){let r=t??await an();if(!r.imports.hasOwnProperty(e)){let t=`Could not find the package ${e} defined in the current importmap`;throw console.error(t),Error(t)}let n=r.imports[e];n.startsWith("./")&&(n=window.spaBase+n.substring(1));let o=e in i1().imports;try{return await function(e){var t;let r=(t=window)[ao]??(t[ao]=new Map),n=r.get(e);if(n)return n;if(document.head.querySelector(`script[src="${e}"]`))return console.warn(`Script at ${e} already loaded. Not loading it again.`),Promise.resolve();let o=document.createElement("script");o.src=e,o.type="text/javascript",o.async=!0;let i=new Promise((t,n)=>{let i=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(i),o.removeEventListener("load",s),o.removeEventListener("error",l)}function s(){a(),t()}function l(t){a(),r.delete(e),o.remove();let i=`Failed to load script from ${e}`;console.error(i,t),n(t.message??i)}o.addEventListener("load",s),o.addEventListener("error",l),document.head.appendChild(o)});return r.set(e,i),i}(n)}catch(e){return o&&j({kind:"error",title:iV("scriptLoadingFailed","Error: Script failed to load"),description:iV("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:n}),actionButtonLabel:iV("resetOverrides","Reset overrides"),onActionButtonClick(){i5(),window.location.reload()}}),Promise.reject(e)}}return Promise.resolve()}async function an(){return iX()}let ao=Symbol.for("__openmrs_script_loading");function ai(e){return!!e&&"object"==typeof e&&!(Object.hasOwn(e,"pages")&&(!e.pages||!Array.isArray(e.pages))||Object.hasOwn(e,"extensions")&&(!e.extensions||!Array.isArray(e.extensions))||Object.hasOwn(e,"workspaces")&&(!e.workspaces||!Array.isArray(e.workspaces))||Object.hasOwn(e,"modals")&&(!e.modals||!Array.isArray(e.modals)))}function aa(e){return!!e&&"object"==typeof e&&"routes"in e&&!!e.routes&&"object"==typeof e.routes&&Object.entries(e.routes).every(([e,t])=>"string"==typeof e&&ai(t))}let as="openmrs-routes:",al="openmrs-routes:change",au=!1,ac=null,ad=null;async function ap(){return ad??(ad=af().then(({map:e,complete:t})=>(t||(ad=null),e))),ad}async function af(){let e=document.querySelectorAll("script[type='openmrs-routes']"),t=[],r=!0;for(let n=0;n<e.length;n++){let o=e[n];try{let e;if(o.src){let t=await fetch(o.src);if(!t.ok)throw Error(`Request for ${o.src} returned ${t.status} ${t.statusText}`);e=await t.json()}else o.textContent&&(e=JSON.parse(o.textContent));e&&aa(e)&&t.push(e)}catch(e){r=!1,console.warn(`[route-maps] Failed to parse routes from script tag at index ${n}`,e)}}return{map:ah(t),complete:r}}function ah(e){let t={routes:{}};for(let r of e)r&&"object"==typeof r&&!Array.isArray(r)&&(Object.assign(t.routes,r.routes),void 0===t.version&&void 0!==r.version&&(t.version=r.version));return t}async function am(){let e={version:void 0,routes:{}};try{let t=[];for(let e=0;e<localStorage.length;e++){let r=localStorage.key(e);if(r?.startsWith(as)){let e=localStorage.getItem(r);e&&t.push({moduleName:r.slice(as.length),raw:e})}}for(let r of(await Promise.allSettled(t.map(async({moduleName:e,raw:t})=>{let r=JSON.parse(t);if(ai(r))return{moduleName:e,routes:r};if("string"==typeof r&&r.startsWith("http")){let t=await fetch(r),n=await t.json();if(ai(n))return{moduleName:e,routes:n};throw Error(`${r} did not resolve to a valid OpenmrsAppRoutes object`)}throw Error(`Override for ${e} is neither a valid routes object nor a URL`)}))))"fulfilled"===r.status?e.routes[r.value.moduleName]=r.value.routes:console.warn("[route-maps] Failed to load route override",r.reason)}catch(e){console.warn("[route-maps] Failed to read route overrides from localStorage",e)}return e}async function ag(){let e=await ap();return au?ah([e,ac??await am()]):e}async function ay(){return ap()}async function av(){return au?ah([await ap(),await am()]):ap()}function ab(){if(!au)return{};let e={};try{for(let t=0;t<localStorage.length;t++){let r=localStorage.key(t);if(r?.startsWith(as)){let t=localStorage.getItem(r);t&&(e[r.slice(as.length)]=t)}}}catch(e){console.warn("[route-maps] Failed to read route overrides from localStorage",e)}return e}function aw(e,t){if(!au)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{if("string"==typeof t)if(t.startsWith("http"))localStorage.setItem(as+e,JSON.stringify(t));else{let r=JSON.parse(t);if(!ai(r))return void console.error(`The supplied routes for ${e} is not a valid OpenmrsAppRoutes object`,t);localStorage.setItem(as+e,JSON.stringify(r))}else if(t instanceof URL)localStorage.setItem(as+e,JSON.stringify(t.toString()));else{if(!ai(t))return void console.error(`Override for ${e} is not in a valid format. Expected either a Javascript Object, a JSON string of a Javascript object, or a URL`,t);localStorage.setItem(as+e,JSON.stringify(t))}window.dispatchEvent(new CustomEvent(al))}catch(e){console.warn("[route-maps] Failed to write route override to localStorage",e)}}function a_(e){if(!au)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{localStorage.removeItem(as+e),window.dispatchEvent(new CustomEvent(al))}catch(e){console.warn("[route-maps] Failed to remove route override from localStorage",e)}}function ax(){if(!au)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{let e=[];for(let t=0;t<localStorage.length;t++){let r=localStorage.key(t);r?.startsWith(as)&&e.push(r)}e.forEach(e=>localStorage.removeItem(e)),window.dispatchEvent(new CustomEvent(al))}catch(e){console.warn("[route-maps] Failed to clear route overrides from localStorage",e)}}let aE=null;function aS(){return aE||(aE=(au="development"===window.spaEnv)?am().then(e=>{ac=e}):Promise.resolve())}let aD=`${o$}/attachment`;function aO(e,t){return oF(`${aD}/${e}`,{signal:t.signal})}function ak(e,t,r){return oF(`${aD}?patient=${e}&includeEncounterless=${t}`,{signal:r.signal})}async function aP(e,t){let r=new FormData;return r.append("fileCaption",t.fileDescription),r.append("patient",e),t.file?r.append("file",t.file,t.fileName):(r.append("file",new File([""],t.fileName),t.fileName),r.append("base64Content",t.base64Content)),oF(`${aD}`,{method:"POST",body:r})}function aC(e,t){return oF(`${aD}/${e}`,{method:"DELETE",signal:t.signal})}try{self["workbox:window:6.5.4"]&&_()}catch(e){}function aj(e,t){return new Promise(function(r){var n=new MessageChannel;n.port1.onmessage=function(e){r(e.data)},e.postMessage(t,[n.port2])})}function aT(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function aR(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}try{self["workbox:core:6.5.4"]&&_()}catch(e){}var aA=function(){var e=this;this.promise=new Promise(function(t,r){e.resolve=t,e.reject=r})};function aN(e,t){var r=location.href;return new URL(e,r).href===new URL(t,r).href}var a$=function(e,t){this.type=e,Object.assign(this,t)};function aI(e,t,r){return r?t?t(e):e:(e&&e.then||(e=Promise.resolve(e)),t?e.then(t):e)}function aM(){}var aL={type:"SKIP_WAITING"};function aF(e,t){if(!t)return e&&e.then?e.then(aM):Promise.resolve()}var aB=function(e){function t(t,r){var n,o;return void 0===r&&(r={}),(n=e.call(this)||this).nn={},n.tn=0,n.rn=new aA,n.en=new aA,n.on=new aA,n.un=0,n.an=new Set,n.cn=function(){var e=n.fn,t=e.installing;n.tn>0||!aN(t.scriptURL,n.sn.toString())||performance.now()>n.un+6e4?(n.vn=t,e.removeEventListener("updatefound",n.cn)):(n.hn=t,n.an.add(t),n.rn.resolve(t)),++n.tn,t.addEventListener("statechange",n.ln)},n.ln=function(e){var t=n.fn,r=e.target,o=r.state,i=r===n.vn,a={sw:r,isExternal:i,originalEvent:e};!i&&n.mn&&(a.isUpdate=!0),n.dispatchEvent(new a$(o,a)),"installed"===o?n.wn=self.setTimeout(function(){"installed"===o&&t.waiting===r&&n.dispatchEvent(new a$("waiting",a))},200):"activating"===o&&(clearTimeout(n.wn),i||n.en.resolve(r))},n.dn=function(e){var t=n.hn,r=t!==navigator.serviceWorker.controller;n.dispatchEvent(new a$("controlling",{isExternal:r,originalEvent:e,sw:t,isUpdate:n.mn})),r||n.on.resolve(t)},o=function(e){var t=e.data,r=e.ports,o=e.source;return aI(n.getSW(),function(){n.an.has(o)&&n.dispatchEvent(new a$("message",{data:t,originalEvent:e,ports:r,sw:o}))})},n.gn=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];try{return Promise.resolve(o.apply(this,e))}catch(e){return Promise.reject(e)}},n.sn=t,n.nn=r,navigator.serviceWorker.addEventListener("message",n.gn),n}t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e;var r,n,o=t.prototype;return o.register=function(e){var t=(void 0===e?{}:e).immediate,r=void 0!==t&&t;try{var n,o,i,a=this;return n=function(){if(!r&&"complete"!==document.readyState)return aF(new Promise(function(e){return window.addEventListener("load",e)}))},o=function(){return a.mn=!!navigator.serviceWorker.controller,a.yn=a.pn(),aI(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 t=a.fn.waiting;return t&&aN(t.scriptURL,a.sn.toString())&&(a.hn=t,Promise.resolve().then(function(){a.dispatchEvent(new a$("waiting",{sw:t,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})},(i=n())&&i.then?i.then(o):o(i)}catch(e){return Promise.reject(e)}},o.update=function(){try{return this.fn?aF(this.fn.update()):void 0}catch(e){return Promise.reject(e)}},o.getSW=function(){return void 0!==this.hn?Promise.resolve(this.hn):this.rn.promise},o.messageSW=function(e){try{return aI(this.getSW(),function(t){return aj(t,e)})}catch(e){return Promise.reject(e)}},o.messageSkipWaiting=function(){this.fn&&this.fn.waiting&&aj(this.fn.waiting,aL)},o.pn=function(){var e=navigator.serviceWorker.controller;return e&&aN(e.scriptURL,this.sn.toString())?e:void 0},o.bn=function(){try{var e=this;return function(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}(function(){return aI(navigator.serviceWorker.register(e.sn,e.nn),function(t){return e.un=performance.now(),t})},function(e){throw e})}catch(e){return Promise.reject(e)}},r=[{key:"active",get:function(){return this.en.promise}},{key:"controlling",get:function(){return this.on.promise}}],aT(t.prototype,r),n&&aT(t,n),t}(function(){function e(){this.Pn=new Map}var t=e.prototype;return t.addEventListener=function(e,t){this.Sn(e).add(t)},t.removeEventListener=function(e,t){this.Sn(e).delete(t)},t.dispatchEvent=function(e){e.target=this;for(var t,r=function(e){var t;if("u"<typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(t=function(e){if(e){if("string"==typeof e)return aR(e,void 0);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?aR(e,void 0):void 0}}(e))){t&&(e=t);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(t=e[Symbol.iterator]()).next.bind(t)}(this.Sn(e.type));!(t=r()).done;)(0,t.value)(e)},t.Sn=function(e){return this.Pn.has(e)||this.Pn.set(e,new Set),this.Pn.get(e)},e}());function aV(e,t){if(void 0!==p)return console.warn(`The application's Service Worker has already been registered. The new service worker at ${e} will not be registered.`),p;if(!("serviceWorker"in navigator))throw Error("Registering the Service Worker is not possible due to missing browser capabilities.");let r=new aB(e,t);return p=r.register().then(()=>r.controlling.then(()=>r))}function aU(){return p??Promise.resolve(void 0)}let aW="x-omrs-offline-response-body",aK="x-omrs-offline-response-status",az="x-omrs-offline-caching-strategy";async function aH(e){let t=await aU();return t?await t.messageSW(e):{success:!1,result:void 0,error:"No service worker has been registered. This is typically the case when the application has been built without offline-related features."}}async function aG(){let e=window.sessionStorage;try{e.setItem("someKeyHere","test"),e.removeItem("someKeyHere")}catch(t){if(t.code===DOMException.QUOTA_EXCEEDED_ERR&&0===e.length)return!0}return!1}async function aq(){return!window.indexedDB}async function aY(){return new Promise(e=>{let t=indexedDB.open("test");t.onerror=()=>e(!0),t.onsuccess=()=>e(!1)})}async function aZ(){return await aY()||await aq()||await aG()}let aJ="openmrs3:offline-mode",aX="unavailable";function aQ(){return{current:aX,notAvailable:"unavailable"===aX,active:"on"===aX}}function a0(e){"unavailable"!==aX&&"unavailable"!==e&&(localStorage.setItem(aJ,"on"===e?"active":"disabled"),aX=e)}async function a1(){await aZ()||(aX="active"===localStorage.getItem(aJ)?"on":"off"),navigator.onLine}let a4="u">typeof globalThis?globalThis:"u">typeof self?self:"u">typeof window?window:global,a3=Object.keys,a2=Array.isArray;function a6(e,t){return"object"!=typeof t||a3(t).forEach(function(r){e[r]=t[r]}),e}"u"<typeof Promise||a4.Promise||(a4.Promise=Promise);let a5=Object.getPrototypeOf,a8={}.hasOwnProperty;function a9(e,t){return a8.call(e,t)}function a7(e,t){"function"==typeof t&&(t=t(a5(e))),("u"<typeof Reflect?a3:Reflect.ownKeys)(t).forEach(r=>{st(e,r,t[r])})}let se=Object.defineProperty;function st(e,t,r,n){se(e,t,a6(r&&a9(r,"get")&&"function"==typeof r.get?{get:r.get,set:r.set,configurable:!0}:{value:r,configurable:!0,writable:!0},n))}function sr(e){return{from:function(t){return e.prototype=Object.create(t.prototype),st(e.prototype,"constructor",e),{extend:a7.bind(null,e.prototype)}}}}let sn=Object.getOwnPropertyDescriptor;function so(e,t){let r;return sn(e,t)||(r=a5(e))&&so(r,t)}let si=[].slice;function sa(e,t,r){return si.call(e,t,r)}function ss(e,t){return t(e)}function sl(e){if(!e)throw Error("Assertion Failed")}function su(e){a4.setImmediate?setImmediate(e):setTimeout(e,0)}function sc(e,t){return e.reduce((e,r,n)=>{var o=t(r,n);return o&&(e[o[0]]=o[1]),e},{})}function sd(e,t){if(a9(e,t))return e[t];if(!t)return e;if("string"!=typeof t){for(var r=[],n=0,o=t.length;n<o;++n){var i=sd(e,t[n]);r.push(i)}return r}var a=t.indexOf(".");if(-1!==a){var s=e[t.substr(0,a)];return void 0===s?void 0:sd(s,t.substr(a+1))}}function sp(e,t,r){if(e&&void 0!==t&&(!("isFrozen"in Object)||!Object.isFrozen(e)))if("string"!=typeof t&&"length"in t){sl("string"!=typeof r&&"length"in r);for(var n=0,o=t.length;n<o;++n)sp(e,t[n],r[n])}else{var i=t.indexOf(".");if(-1!==i){var a=t.substr(0,i),s=t.substr(i+1);if(""===s)void 0===r?a2(e)&&!isNaN(parseInt(a))?e.splice(a,1):delete e[a]:e[a]=r;else{var l=e[a];l&&a9(e,a)||(l=e[a]={}),sp(l,s,r)}}else void 0===r?a2(e)&&!isNaN(parseInt(t))?e.splice(t,1):delete e[t]:e[t]=r}}function sf(e){var t={};for(var r in e)a9(e,r)&&(t[r]=e[r]);return t}let sh=[].concat;function sm(e){return sh.apply([],e)}let sg="Boolean,String,Date,RegExp,Blob,File,FileList,FileSystemFileHandle,ArrayBuffer,DataView,Uint8ClampedArray,ImageBitmap,ImageData,Map,Set,CryptoKey".split(",").concat(sm([8,16,32,64].map(e=>["Int","Uint","Float"].map(t=>t+e+"Array")))).filter(e=>a4[e]),sy=sg.map(e=>a4[e]);sc(sg,e=>[e,!0]);let sv=null;function sb(e){sv="u">typeof WeakMap&&new WeakMap;let t=function e(t){if(!t||"object"!=typeof t)return t;let r=sv&&sv.get(t);if(r)return r;if(a2(t)){r=[],sv&&sv.set(t,r);for(var n=0,o=t.length;n<o;++n)r.push(e(t[n]))}else if(sy.indexOf(t.constructor)>=0)r=t;else{let n=a5(t);for(var i in r=n===Object.prototype?{}:Object.create(n),sv&&sv.set(t,r),t)a9(t,i)&&(r[i]=e(t[i]))}return r}(e);return sv=null,t}let{toString:sw}={};function s_(e){return sw.call(e).slice(8,-1)}let sx="u">typeof Symbol?Symbol.iterator:"@@iterator",sE="symbol"==typeof sx?function(e){var t;return null!=e&&(t=e[sx])&&t.apply(e)}:function(){return null},sS={};function sD(e){var t,r,n,o;if(1==arguments.length){if(a2(e))return e.slice();if(this===sS&&"string"==typeof e)return[e];if(o=sE(e)){for(r=[];!(n=o.next()).done;)r.push(n.value);return r}if(null==e)return[e];if("number"==typeof(t=e.length)){for(r=Array(t);t--;)r[t]=e[t];return r}return[e]}for(t=arguments.length,r=Array(t);t--;)r[t]=arguments[t];return r}let sO="u">typeof Symbol?e=>"AsyncFunction"===e[Symbol.toStringTag]:()=>!1;var sk="u">typeof location&&/^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href),sP=()=>!0;let sC=!Error("").stack;function sj(){if(sC)try{throw sj.arguments,Error()}catch(e){return e}return Error()}function sT(e,t){var r=e.stack;return r?(t=t||0,0===r.indexOf(e.name)&&(t+=(e.name+e.message).split("\n").length),r.split("\n").slice(t).filter(sP).map(e=>"\n"+e).join("")):""}var sR=["Unknown","Constraint","Data","TransactionInactive","ReadOnly","Version","NotFound","InvalidState","InvalidAccess","Abort","Timeout","QuotaExceeded","Syntax","DataClone"],sA=["Modify","Bulk","OpenFailed","VersionChange","Schema","Upgrade","InvalidTable","MissingAPI","NoSuchDatabase","InvalidArgument","SubTransaction","Unsupported","Internal","DatabaseClosed","PrematureCommit","ForeignAwait"].concat(sR),sN={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 s$(e,t){this._e=sj(),this.name=e,this.message=t}function sI(e,t){return e+". Errors: "+Object.keys(t).map(e=>t[e].toString()).filter((e,t,r)=>r.indexOf(e)===t).join("\n")}function sM(e,t,r,n){this._e=sj(),this.failures=t,this.failedKeys=n,this.successCount=r,this.message=sI(e,t)}function sL(e,t){this._e=sj(),this.name="BulkError",this.failures=Object.keys(t).map(e=>t[e]),this.failuresByPos=t,this.message=sI(e,t)}sr(s$).from(Error).extend({stack:{get:function(){return this._stack||(this._stack=this.name+": "+this.message+sT(this._e,2))}},toString:function(){return this.name+": "+this.message}}),sr(sM).from(s$),sr(sL).from(s$);var sF=sA.reduce((e,t)=>(e[t]=t+"Error",e),{}),sB=sA.reduce((e,t)=>{var r=t+"Error";function n(e,n){this._e=sj(),this.name=r,e?"string"==typeof e?(this.message=`${e}${n?"\n "+n:""}`,this.inner=n||null):"object"==typeof e&&(this.message=`${e.name} ${e.message}`,this.inner=e):(this.message=sN[t]||r,this.inner=null)}return sr(n).from(s$),e[t]=n,e},{});sB.Syntax=SyntaxError,sB.Type=TypeError,sB.Range=RangeError;var sV=sR.reduce((e,t)=>(e[t+"Error"]=sB[t],e),{}),sU=sA.reduce((e,t)=>(-1===["Syntax","Type","Range"].indexOf(t)&&(e[t+"Error"]=sB[t]),e),{});function sW(){}function sK(e){return e}function sz(e,t){return null==e||e===sK?t:function(r){return t(e(r))}}function sH(e,t){return function(){e.apply(this,arguments),t.apply(this,arguments)}}function sG(e,t){return e===sW?t:function(){var r=e.apply(this,arguments);void 0!==r&&(arguments[0]=r);var n=this.onsuccess,o=this.onerror;this.onsuccess=null,this.onerror=null;var i=t.apply(this,arguments);return n&&(this.onsuccess=this.onsuccess?sH(n,this.onsuccess):n),o&&(this.onerror=this.onerror?sH(o,this.onerror):o),void 0!==i?i:r}}function sq(e,t){return e===sW?t:function(){e.apply(this,arguments);var r=this.onsuccess,n=this.onerror;this.onsuccess=this.onerror=null,t.apply(this,arguments),r&&(this.onsuccess=this.onsuccess?sH(r,this.onsuccess):r),n&&(this.onerror=this.onerror?sH(n,this.onerror):n)}}function sY(e,t){return e===sW?t:function(r){var n=e.apply(this,arguments);a6(r,n);var o=this.onsuccess,i=this.onerror;this.onsuccess=null,this.onerror=null;var a=t.apply(this,arguments);return o&&(this.onsuccess=this.onsuccess?sH(o,this.onsuccess):o),i&&(this.onerror=this.onerror?sH(i,this.onerror):i),void 0===n?void 0===a?void 0:a:a6(n,a)}}function sZ(e,t){return e===sW?t:function(){return!1!==t.apply(this,arguments)&&e.apply(this,arguments)}}function sJ(e,t){return e===sW?t:function(){var r=e.apply(this,arguments);if(r&&"function"==typeof r.then){for(var n=this,o=arguments.length,i=Array(o);o--;)i[o]=arguments[o];return r.then(function(){return t.apply(n,i)})}return t.apply(this,arguments)}}sU.ModifyError=sM,sU.DexieError=s$,sU.BulkError=sL;var sX={};let[sQ,s0,s1]="u"<typeof Promise?[]:(()=>{let e=Promise.resolve();if("u"<typeof crypto||!crypto.subtle)return[e,a5(e),e];let t=crypto.subtle.digest("SHA-512",new Uint8Array([0]));return[t,a5(t),e]})(),s4=s0&&s0.then,s3=sQ&&sQ.constructor,s2=!!s1;var s6=!1,s5=s1?()=>{s1.then(ly)}:a4.setImmediate?setImmediate.bind(null,ly):a4.MutationObserver?()=>{var e=document.createElement("div");new MutationObserver(()=>{ly(),e=null}).observe(e,{attributes:!0}),e.setAttribute("i","1")}:()=>{setTimeout(ly,0)},s8=function(e,t){la.push([e,t]),s7&&(s5(),s7=!1)},s9=!0,s7=!0,le=[],lt=[],lr=null,ln=sK,lo={id:"global",global:!0,ref:0,unhandleds:[],onunhandled:lV,pgp:!1,env:{},finalize:function(){this.unhandleds.forEach(e=>{try{lV(e[0],e[1])}catch(e){}})}},li=lo,la=[],ls=0,ll=[];function lu(e){if("object"!=typeof this)throw TypeError("Promises must be constructed via new");this._listeners=[],this.onuncatched=sW,this._lib=!1;var t=this._PSD=li;if(sk&&(this._stackHolder=sj(),this._prev=null,this._numPrev=0),"function"!=typeof e){if(e!==sX)throw TypeError("Not a function");return this._state=arguments[1],this._value=arguments[2],void(!1===this._state&&lp(this,this._value))}this._state=null,this._value=null,++t.ref,function e(t,r){try{r(r=>{if(null===t._state){if(r===t)throw TypeError("A promise cannot be resolved with itself.");var n=t._lib&&lv();r&&"function"==typeof r.then?e(t,(e,t)=>{r instanceof lu?r._then(e,t):r.then(e,t)}):(t._state=!0,t._value=r,lf(t)),n&&lb()}},lp.bind(null,t))}catch(e){lp(t,e)}}(this,e)}let lc={get:function(){var e=li,t=lk;function r(r,n){var o=!e.global&&(e!==li||t!==lk);let i=o&&!lT();var a=new lu((t,a)=>{lh(this,new ld(lL(r,e,o,i),lL(n,e,o,i),t,a,e))});return sk&&lg(a,this),a}return r.prototype=sX,r},set:function(e){st(this,"then",e&&e.prototype===sX?lc:{get:function(){return e},set:lc.set})}};function ld(e,t,r,n,o){this.onFulfilled="function"==typeof e?e:null,this.onRejected="function"==typeof t?t:null,this.resolve=r,this.reject=n,this.psd=o}function lp(e,t){if(lt.push(t),null===e._state){var r=e._lib&&lv();t=ln(t),e._state=!1,e._value=t,sk&&null!==t&&"object"==typeof t&&!t._promise&&function(e){try{e.apply(null,void 0)}catch(e){}}(()=>{var r=so(t,"stack");t._promise=e,st(t,"stack",{get:()=>s6?r&&(r.get?r.get.apply(t):r.value):e.stack})}),le.some(t=>t._value===e._value)||le.push(e),lf(e),r&&lb()}}function lf(e){var t=e._listeners;e._listeners=[];for(var r=0,n=t.length;r<n;++r)lh(e,t[r]);var o=e._PSD;--o.ref||o.finalize(),0===ls&&(++ls,s8(()=>{0==--ls&&lw()},[]))}function lh(e,t){if(null!==e._state){var r=e._state?t.onFulfilled:t.onRejected;if(null===r)return(e._state?t.resolve:t.reject)(e._value);++t.psd.ref,++ls,s8(lm,[r,e,t])}else e._listeners.push(t)}function lm(e,t,r){try{lr=t;var n,o=t._value;t._state?n=e(o):(lt.length&&(lt=[]),n=e(o),-1===lt.indexOf(o)&&function(e){for(var t=le.length;t;)if(le[--t]._value===e._value)return void le.splice(t,1)}(t)),r.resolve(n)}catch(e){r.reject(e)}finally{lr=null,0==--ls&&lw(),--r.psd.ref||r.psd.finalize()}}function lg(e,t){var r=t?t._numPrev+1:0;r<100&&(e._prev=t,e._numPrev=r)}function ly(){lv()&&lb()}function lv(){var e=s9;return s9=!1,s7=!1,e}function lb(){var e,t,r;do for(;la.length>0;)for(e=la,la=[],r=e.length,t=0;t<r;++t){var n=e[t];n[0].apply(null,n[1])}while(la.length>0);s9=!0,s7=!0}function lw(){var e=le;le=[],e.forEach(e=>{e._PSD.onunhandled.call(null,e._value,e)});for(var t=ll.slice(0),r=t.length;r;)t[--r]()}function l_(e){return new lu(sX,!1,e)}function lx(e,t){var r=li;return function(){var n=lv(),o=li;try{return l$(r,!0),e.apply(this,arguments)}catch(e){t&&t(e)}finally{l$(o,!1),n&&lb()}}}a7(lu.prototype,{then:lc,_then:function(e,t){lh(this,new ld(null,null,e,t,li))},catch:function(e){if(1==arguments.length)return this.then(null,e);var t=arguments[0],r=arguments[1];return"function"==typeof t?this.then(null,e=>e instanceof t?r(e):l_(e)):this.then(null,e=>e&&e.name===t?r(e):l_(e))},finally:function(e){return this.then(t=>(e(),t),t=>(e(),l_(t)))},stack:{get:function(){if(this._stack)return this._stack;try{s6=!0;var e=(function e(t,r,n){if(r.length===n)return r;var o="";if(!1===t._state){var i,a,s=t._value;null!=s?(i=s.name||"Error",a=s.message||s,o=sT(s,0)):(i=s,a=""),r.push(i+(a?": "+a:"")+o)}return sk&&((o=sT(t._stackHolder,2))&&-1===r.indexOf(o)&&r.push(o),t._prev&&e(t._prev,r,n)),r})(this,[],20).join("\nFrom previous: ");return null!==this._state&&(this._stack=e),e}finally{s6=!1}}},timeout:function(e,t){return e<1/0?new lu((r,n)=>{var o=setTimeout(()=>n(new sB.Timeout(t)),e);this.then(r,n).finally(clearTimeout.bind(null,o))}):this}}),"u">typeof Symbol&&Symbol.toStringTag&&st(lu.prototype,Symbol.toStringTag,"Dexie.Promise"),lo.env=lI(),a7(lu,{all:function(){var e=sD.apply(null,arguments).map(lR);return new lu(function(t,r){0===e.length&&t([]);var n=e.length;e.forEach((o,i)=>lu.resolve(o).then(r=>{e[i]=r,--n||t(e)},r))})},resolve:e=>{if(e instanceof lu)return e;if(e&&"function"==typeof e.then)return new lu((t,r)=>{e.then(t,r)});var t=new lu(sX,!0,e);return lg(t,lr),t},reject:l_,race:function(){var e=sD.apply(null,arguments).map(lR);return new lu((t,r)=>{e.map(e=>lu.resolve(e).then(t,r))})},PSD:{get:()=>li,set:e=>li=e},totalEchoes:{get:()=>lk},newPSD:lC,usePSD:lM,scheduler:{get:()=>s8,set:e=>{s8=e}},rejectionMapper:{get:()=>ln,set:e=>{ln=e}},follow:(e,t)=>new lu((r,n)=>lC((t,r)=>{var n=li;n.unhandleds=[],n.onunhandled=r,n.finalize=sH(function(){var e;e=()=>{0===this.unhandleds.length?t():r(this.unhandleds[0])},ll.push(function t(){e(),ll.splice(ll.indexOf(t),1)}),++ls,s8(()=>{0==--ls&&lw()},[])},n.finalize),e()},t,r,n))}),s3&&(s3.allSettled&&st(lu,"allSettled",function(){let e=sD.apply(null,arguments).map(lR);return new lu(t=>{0===e.length&&t([]);let r=e.length,n=Array(r);e.forEach((e,o)=>lu.resolve(e).then(e=>n[o]={status:"fulfilled",value:e},e=>n[o]={status:"rejected",reason:e}).then(()=>--r||t(n)))})}),s3.any&&"u">typeof AggregateError&&st(lu,"any",function(){let e=sD.apply(null,arguments).map(lR);return new lu((t,r)=>{0===e.length&&r(AggregateError([]));let n=e.length,o=Array(n);e.forEach((e,i)=>lu.resolve(e).then(e=>t(e),e=>{o[i]=e,--n||r(AggregateError(o))}))})}));let lE={awaits:0,echoes:0,id:0};var lS=0,lD=[],lO=0,lk=0,lP=0;function lC(e,t,r,n){var o=li,i=Object.create(o);i.parent=o,i.ref=0,i.global=!1,i.id=++lP;var a=lo.env;i.env=s2?{Promise:lu,PromiseProp:{value:lu,configurable:!0,writable:!0},all:lu.all,race:lu.race,allSettled:lu.allSettled,any:lu.any,resolve:lu.resolve,reject:lu.reject,nthen:lF(a.nthen,i),gthen:lF(a.gthen,i)}:{},t&&a6(i,t),++o.ref,i.finalize=function(){--this.parent.ref||this.parent.finalize()};var s=lM(i,e,r,n);return 0===i.ref&&i.finalize(),s}function lj(){return lE.id||(lE.id=++lS),++lE.awaits,lE.echoes+=100,lE.id}function lT(){return!!lE.awaits&&(0==--lE.awaits&&(lE.id=0),lE.echoes=100*lE.awaits,!0)}function lR(e){return lE.echoes&&e&&e.constructor===s3?(lj(),e.then(e=>(lT(),e),e=>(lT(),lU(e)))):e}function lA(e){++lk,lE.echoes&&0!=--lE.echoes||(lE.echoes=lE.id=0),lD.push(li),l$(e,!0)}function lN(){var e=lD[lD.length-1];lD.pop(),l$(e,!1)}function l$(e,t){var r,n=li;if((t?!lE.echoes||lO++&&e===li:!lO||--lO&&e===li)||(r=t?lA.bind(null,e):lN,s4.call(sQ,r)),e!==li&&(li=e,n===lo&&(lo.env=lI()),s2)){var o=lo.env.Promise,i=e.env;s0.then=i.nthen,o.prototype.then=i.gthen,(n.global||e.global)&&(Object.defineProperty(a4,"Promise",i.PromiseProp),o.all=i.all,o.race=i.race,o.resolve=i.resolve,o.reject=i.reject,i.allSettled&&(o.allSettled=i.allSettled),i.any&&(o.any=i.any))}}function lI(){var e=a4.Promise;return s2?{Promise:e,PromiseProp:Object.getOwnPropertyDescriptor(a4,"Promise"),all:e.all,race:e.race,allSettled:e.allSettled,any:e.any,resolve:e.resolve,reject:e.reject,nthen:s0.then,gthen:e.prototype.then}:{}}function lM(e,t,r,n,o){var i=li;try{return l$(e,!0),t(r,n,o)}finally{l$(i,!1)}}function lL(e,t,r,n){return"function"!=typeof e?e:function(){var o,i=li;r&&lj(),l$(t,!0);try{return e.apply(this,arguments)}finally{l$(i,!1),n&&(o=lT,s4.call(sQ,o))}}}function lF(e,t){return function(r,n){return e.call(this,lL(r,t),lL(n,t))}}-1===(""+s4).indexOf("[native code]")&&(lj=lT=sW);let lB="unhandledrejection";function lV(e,t){var r;try{r=t.onuncatched(e)}catch(e){}if(!1!==r)try{var n,o={promise:t,reason:e};if(a4.document&&document.createEvent?((n=document.createEvent("Event")).initEvent(lB,!0,!0),a6(n,o)):a4.CustomEvent&&a6(n=new CustomEvent(lB,{detail:o}),o),n&&a4.dispatchEvent&&(dispatchEvent(n),!a4.PromiseRejectionEvent&&a4.onunhandledrejection))try{a4.onunhandledrejection(n)}catch(e){}sk&&n&&!n.defaultPrevented&&console.warn(`Unhandled rejection: ${e.stack||e}`)}catch(e){}}var lU=lu.reject;let lW="3.2.4",lK=String.fromCharCode(65535),lz=-1/0,lH="Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.",lG="String expected.",lq=[],lY="u">typeof navigator&&/(MSIE|Trident|Edge)/.test(navigator.userAgent),lZ=e=>!/(dexie\.js|dexie\.min\.js)/.test(e),lJ="__dbnames",lX="readonly",lQ="readwrite";function l0(e,t){return e?t?function(){return e.apply(this,arguments)&&t.apply(this,arguments)}:e:t}let l1={type:3,lower:-1/0,lowerOpen:!1,upper:[[]],upperOpen:!1};function l4(e){return"string"!=typeof e||/\./.test(e)?e=>e:t=>(void 0===t[e]&&e in t&&delete(t=sb(t))[e],t)}class l3{_trans(e,t,r){let n=this._tx||li.trans,o=this.name;function i(e,r,n){if(!n.schema[o])throw new sB.NotFound("Table "+o+" not part of transaction");return t(n.idbtrans,n)}let a=lv();try{return n&&n.db===this.db?n===li.trans?n._promise(e,i,r):lC(()=>n._promise(e,i,r),{trans:n,transless:li.transless||li}):function e(t,r,n,o){if(t.idbdb&&(t._state.openComplete||li.letThrough||t._vip)){var i=t._createTransaction(r,n,t._dbSchema);try{i.create(),t._state.PR1398_maxLoop=3}catch(i){return i.name===sF.InvalidState&&t.isOpen()&&--t._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),t._close(),t.open().then(()=>e(t,r,n,o))):lU(i)}return i._promise(r,(e,t)=>lC(()=>(li.trans=i,o(e,t,i)))).then(e=>i._completion.then(()=>e))}if(t._state.openComplete)return lU(new sB.DatabaseClosed(t._state.dbOpenError));if(!t._state.isBeingOpened){if(!t._options.autoOpen)return lU(new sB.DatabaseClosed);t.open().catch(sW)}return t._state.dbReadyPromise.then(()=>e(t,r,n,o))}(this.db,e,[this.name],i)}finally{a&&lb()}}get(e,t){return e&&e.constructor===Object?this.where(e).first(t):this._trans("readonly",t=>this.core.get({trans:t,key:e}).then(e=>this.hook.reading.fire(e))).then(t)}where(e){if("string"==typeof e)return new this.db.WhereClause(this,e);if(a2(e))return new this.db.WhereClause(this,`[${e.join("+")}]`);let t=a3(e);if(1===t.length)return this.where(t[0]).equals(e[t[0]]);let r=this.schema.indexes.concat(this.schema.primKey).filter(e=>e.compound&&t.every(t=>e.keyPath.indexOf(t)>=0)&&e.keyPath.every(e=>t.indexOf(e)>=0))[0];if(r&&this.db._maxKey!==lK)return this.where(r.name).equals(r.keyPath.map(t=>e[t]));!r&&sk&&console.warn(`The query ${JSON.stringify(e)} on ${this.name} would benefit of a compound index [${t.join("+")}]`);let{idxByName:n}=this.schema,o=this.db._deps.indexedDB;function i(e,t){try{return 0===o.cmp(e,t)}catch(e){return!1}}let[a,s]=t.reduce(([t,r],o)=>{let a=n[o],s=e[o];return[t||a,t||!a?l0(r,a&&a.multi?e=>{let t=sd(e,o);return a2(t)&&t.some(e=>i(s,e))}:e=>i(s,sd(e,o))):r]},[null,null]);return a?this.where(a.name).equals(e[a.keyPath]).filter(s):r?this.filter(s):this.where(t).equals("")}filter(e){return this.toCollection().and(e)}count(e){return this.toCollection().count(e)}offset(e){return this.toCollection().offset(e)}limit(e){return this.toCollection().limit(e)}each(e){return this.toCollection().each(e)}toArray(e){return this.toCollection().toArray(e)}toCollection(){return new this.db.Collection(new this.db.WhereClause(this))}orderBy(e){return new this.db.Collection(new this.db.WhereClause(this,a2(e)?`[${e.join("+")}]`:e))}reverse(){return this.toCollection().reverse()}mapToClass(e){this.schema.mappedClass=e;let t=t=>{if(!t)return t;let r=Object.create(e.prototype);for(var n in t)if(a9(t,n))try{r[n]=t[n]}catch(e){}return r};return this.schema.readHook&&this.hook.reading.unsubscribe(this.schema.readHook),this.schema.readHook=t,this.hook("reading",t),e}defineClass(){return this.mapToClass(function(e){a6(this,e)})}add(e,t){let{auto:r,keyPath:n}=this.schema.primKey,o=e;return n&&r&&(o=l4(n)(e)),this._trans("readwrite",e=>this.core.mutate({trans:e,type:"add",keys:null!=t?[t]:null,values:[o]})).then(e=>e.numFailures?lu.reject(e.failures[0]):e.lastResult).then(t=>{if(n)try{sp(e,n,t)}catch(e){}return t})}update(e,t){if("object"!=typeof e||a2(e))return this.where(":id").equals(e).modify(t);{let r=sd(e,this.schema.primKey.keyPath);if(void 0===r)return lU(new sB.InvalidArgument("Given object does not contain its primary key"));try{"function"!=typeof t?a3(t).forEach(r=>{sp(e,r,t[r])}):t(e,{value:e,primKey:r})}catch(e){}return this.where(":id").equals(r).modify(t)}}put(e,t){let{auto:r,keyPath:n}=this.schema.primKey,o=e;return n&&r&&(o=l4(n)(e)),this._trans("readwrite",e=>this.core.mutate({trans:e,type:"put",values:[o],keys:null!=t?[t]:null})).then(e=>e.numFailures?lu.reject(e.failures[0]):e.lastResult).then(t=>{if(n)try{sp(e,n,t)}catch(e){}return t})}delete(e){return this._trans("readwrite",t=>this.core.mutate({trans:t,type:"delete",keys:[e]})).then(e=>e.numFailures?lu.reject(e.failures[0]):void 0)}clear(){return this._trans("readwrite",e=>this.core.mutate({trans:e,type:"deleteRange",range:l1})).then(e=>e.numFailures?lu.reject(e.failures[0]):void 0)}bulkGet(e){return this._trans("readonly",t=>this.core.getMany({keys:e,trans:t}).then(e=>e.map(e=>this.hook.reading.fire(e))))}bulkAdd(e,t,r){let n=Array.isArray(t)?t:void 0,o=(r=r||(n?void 0:t))?r.allKeys:void 0;return this._trans("readwrite",t=>{let{auto:r,keyPath:i}=this.schema.primKey;if(i&&n)throw new sB.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(n&&n.length!==e.length)throw new sB.InvalidArgument("Arguments objects and keys must have the same length");let a=e.length,s=i&&r?e.map(l4(i)):e;return this.core.mutate({trans:t,type:"add",keys:n,values:s,wantResults:o}).then(({numFailures:e,results:t,lastResult:r,failures:n})=>{if(0===e)return o?t:r;throw new sL(`${this.name}.bulkAdd(): ${e} of ${a} operations failed`,n)})})}bulkPut(e,t,r){let n=Array.isArray(t)?t:void 0,o=(r=r||(n?void 0:t))?r.allKeys:void 0;return this._trans("readwrite",t=>{let{auto:r,keyPath:i}=this.schema.primKey;if(i&&n)throw new sB.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(n&&n.length!==e.length)throw new sB.InvalidArgument("Arguments objects and keys must have the same length");let a=e.length,s=i&&r?e.map(l4(i)):e;return this.core.mutate({trans:t,type:"put",keys:n,values:s,wantResults:o}).then(({numFailures:e,results:t,lastResult:r,failures:n})=>{if(0===e)return o?t:r;throw new sL(`${this.name}.bulkPut(): ${e} of ${a} operations failed`,n)})})}bulkDelete(e){let t=e.length;return this._trans("readwrite",t=>this.core.mutate({trans:t,type:"delete",keys:e})).then(({numFailures:e,lastResult:r,failures:n})=>{if(0===e)return r;throw new sL(`${this.name}.bulkDelete(): ${e} of ${t} operations failed`,n)})}}function l2(e){var t={},r=function(r,n){if(n){for(var o=arguments.length,i=Array(o-1);--o;)i[o-1]=arguments[o];return t[r].subscribe.apply(null,i),e}if("string"==typeof r)return t[r]};r.addEventType=i;for(var n=1,o=arguments.length;n<o;++n)i(arguments[n]);return r;function i(e,n,o){if("object"!=typeof e){n||(n=sZ),o||(o=sW);var a={subscribers:[],fire:o,subscribe:function(e){-1===a.subscribers.indexOf(e)&&(a.subscribers.push(e),a.fire=n(a.fire,e))},unsubscribe:function(e){a.subscribers=a.subscribers.filter(function(t){return t!==e}),a.fire=a.subscribers.reduce(n,o)}};return t[e]=r[e]=a,a}a3(e).forEach(function(t){var r=e[t];if(a2(r))i(t,e[t][0],e[t][1]);else{if("asap"!==r)throw new sB.InvalidArgument("Invalid event config");var n=i(t,sK,function(){for(var e=arguments.length,t=Array(e);e--;)t[e]=arguments[e];n.subscribers.forEach(function(e){su(function(){e.apply(null,t)})})})}})}}function l6(e,t){return sr(t).from({prototype:e}),t}function l5(e,t){return!(e.filter||e.algorithm||e.or)&&(t?e.justLimit:!e.replayFilter)}function l8(e,t){e.filter=l0(e.filter,t)}function l9(e,t,r){var n=e.replayFilter;e.replayFilter=n?()=>l0(n(),t()):t,e.justLimit=r&&!n}function l7(e,t){if(e.isPrimKey)return t.primaryKey;let r=t.getIndexByKeyPath(e.index);if(!r)throw new sB.Schema("KeyPath "+e.index+" on object store "+t.name+" is not indexed");return r}function ue(e,t,r){let n=l7(e,t.schema);return t.openCursor({trans:r,values:!e.keysOnly,reverse:"prev"===e.dir,unique:!!e.unique,query:{index:n,range:e.range}})}function ut(e,t,r,n){let o=e.replayFilter?l0(e.filter,e.replayFilter()):e.filter;if(e.or){let i={},a=(e,r,n)=>{if(!o||o(r,n,e=>r.stop(e),e=>r.fail(e))){var a=r.primaryKey,s=""+a;"[object ArrayBuffer]"===s&&(s=""+new Uint8Array(a)),a9(i,s)||(i[s]=!0,t(e,r,n))}};return Promise.all([e.or._iterate(a,r),ur(ue(e,n,r),e.algorithm,a,!e.keysOnly&&e.valueMapper)])}return ur(ue(e,n,r),l0(e.algorithm,o),t,!e.keysOnly&&e.valueMapper)}function ur(e,t,r,n){var o=lx(n?(e,t,o)=>r(n(e),t,o):r);return e.then(e=>{if(e)return e.start(()=>{var r=()=>e.continue();t&&!t(e,e=>r=e,t=>{e.stop(t),r=sW},t=>{e.fail(t),r=sW})||o(e.value,e,e=>r=e),r()})})}function un(e,t){try{let r=uo(e),n=uo(t);if(r!==n)return"Array"===r?1:"Array"===n?-1:"binary"===r?1:"binary"===n?-1:"string"===r?1:"string"===n?-1:"Date"===r?1:"Date"!==n?NaN:-1;switch(r){case"number":case"Date":case"string":return e>t?1:e<t?-1:0;case"binary":return function(e,t){let r=e.length,n=t.length,o=r<n?r:n;for(let r=0;r<o;++r)if(e[r]!==t[r])return e[r]<t[r]?-1:1;return r===n?0:r<n?-1:1}(ui(e),ui(t));case"Array":return function(e,t){let r=e.length,n=t.length,o=r<n?r:n;for(let r=0;r<o;++r){let n=un(e[r],t[r]);if(0!==n)return n}return r===n?0:r<n?-1:1}(e,t)}}catch(e){}return NaN}function uo(e){let t=typeof e;if("object"!==t)return t;if(ArrayBuffer.isView(e))return"binary";let r=s_(e);return"ArrayBuffer"===r?"binary":r}function ui(e){return e instanceof Uint8Array?e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e)}class ua{_read(e,t){var r=this._ctx;return r.error?r.table._trans(null,lU.bind(null,r.error)):r.table._trans("readonly",e).then(t)}_write(e){var t=this._ctx;return t.error?t.table._trans(null,lU.bind(null,t.error)):t.table._trans("readwrite",e,"locked")}_addAlgorithm(e){var t=this._ctx;t.algorithm=l0(t.algorithm,e)}_iterate(e,t){return ut(this._ctx,e,t,this._ctx.table.core)}clone(e){var t=Object.create(this.constructor.prototype),r=Object.create(this._ctx);return e&&a6(r,e),t._ctx=r,t}raw(){return this._ctx.valueMapper=null,this}each(e){var t=this._ctx;return this._read(r=>ut(t,e,r,t.table.core))}count(e){return this._read(e=>{let t=this._ctx,r=t.table.core;if(l5(t,!0))return r.count({trans:e,query:{index:l7(t,r.schema),range:t.range}}).then(e=>Math.min(e,t.limit));var n=0;return ut(t,()=>(++n,!1),e,r).then(()=>n)}).then(e)}sortBy(e,t){let r=e.split(".").reverse(),n=r[0],o=r.length-1;function i(e,t){return t?i(e[r[t]],t-1):e[n]}var a="next"===this._ctx.dir?1:-1;function s(e,t){var r=i(e,o),n=i(t,o);return r<n?-a:r>n?a:0}return this.toArray(function(e){return e.sort(s)}).then(t)}toArray(e){return this._read(e=>{var t=this._ctx;if("next"===t.dir&&l5(t,!0)&&t.limit>0){let{valueMapper:r}=t,n=l7(t,t.table.core.schema);return t.table.core.query({trans:e,limit:t.limit,values:!0,query:{index:n,range:t.range}}).then(({result:e})=>r?e.map(r):e)}{let r=[];return ut(t,e=>r.push(e),e,t.table.core).then(()=>r)}},e)}offset(e){var t=this._ctx;return e<=0||(t.offset+=e,l5(t)?l9(t,()=>{var t=e;return(e,r)=>0===t||(1===t?--t:r(()=>{e.advance(t),t=0}),!1)}):l9(t,()=>{var t=e;return()=>--t<0})),this}limit(e){return this._ctx.limit=Math.min(this._ctx.limit,e),l9(this._ctx,()=>{var t=e;return function(e,r,n){return--t<=0&&r(n),t>=0}},!0),this}until(e,t){return l8(this._ctx,function(r,n,o){return!e(r.value)||(n(o),t)}),this}first(e){return this.limit(1).toArray(function(e){return e[0]}).then(e)}last(e){return this.reverse().first(e)}filter(e){var t;return l8(this._ctx,function(t){return e(t.value)}),(t=this._ctx).isMatch=l0(t.isMatch,e),this}and(e){return this.filter(e)}or(e){return new this.db.WhereClause(this._ctx.table,e,this)}reverse(){return this._ctx.dir="prev"===this._ctx.dir?"next":"prev",this._ondirectionchange&&this._ondirectionchange(this._ctx.dir),this}desc(){return this.reverse()}eachKey(e){var t=this._ctx;return t.keysOnly=!t.isMatch,this.each(function(t,r){e(r.key,r)})}eachUniqueKey(e){return this._ctx.unique="unique",this.eachKey(e)}eachPrimaryKey(e){var t=this._ctx;return t.keysOnly=!t.isMatch,this.each(function(t,r){e(r.primaryKey,r)})}keys(e){var t=this._ctx;t.keysOnly=!t.isMatch;var r=[];return this.each(function(e,t){r.push(t.key)}).then(function(){return r}).then(e)}primaryKeys(e){var t=this._ctx;if("next"===t.dir&&l5(t,!0)&&t.limit>0)return this._read(e=>{var r=l7(t,t.table.core.schema);return t.table.core.query({trans:e,values:!1,limit:t.limit,query:{index:r,range:t.range}})}).then(({result:e})=>e).then(e);t.keysOnly=!t.isMatch;var r=[];return this.each(function(e,t){r.push(t.primaryKey)}).then(function(){return r}).then(e)}uniqueKeys(e){return this._ctx.unique="unique",this.keys(e)}firstKey(e){return this.limit(1).keys(function(e){return e[0]}).then(e)}lastKey(e){return this.reverse().firstKey(e)}distinct(){var e=this._ctx,t=e.index&&e.table.schema.idxByName[e.index];if(!t||!t.multi)return this;var r={};return l8(this._ctx,function(e){var t=e.primaryKey.toString(),n=a9(r,t);return r[t]=!0,!n}),this}modify(e){var t=this._ctx;return this._write(r=>{var n;if("function"==typeof e)n=e;else{var o=a3(e),i=o.length;n=function(t){for(var r=!1,n=0;n<i;++n){var a=o[n],s=e[a];sd(t,a)!==s&&(sp(t,a,s),r=!0)}return r}}let a=t.table.core,{outbound:s,extractKey:l}=a.schema.primaryKey,u=this.db._options.modifyChunkSize||200,c=[],d=0,p=[],f=(e,t)=>{let{failures:r,numFailures:n}=t;for(let t of(d+=e-n,a3(r)))c.push(r[t])};return this.clone().primaryKeys().then(o=>{let i=c=>{let d=Math.min(u,o.length-c);return a.getMany({trans:r,keys:o.slice(c,c+d),cache:"immutable"}).then(p=>{let h=[],m=[],g=s?[]:null,y=[];for(let e=0;e<d;++e){let t=p[e],r={value:sb(t),primKey:o[c+e]};!1!==n.call(r,r.value,r)&&(null==r.value?y.push(o[c+e]):s||0===un(l(t),l(r.value))?(m.push(r.value),s&&g.push(o[c+e])):(y.push(o[c+e]),h.push(r.value)))}let v=l5(t)&&t.limit===1/0&&("function"!=typeof e||e===us)&&{index:t.index,range:t.range};return Promise.resolve(h.length>0&&a.mutate({trans:r,type:"add",values:h}).then(e=>{for(let t in e.failures)y.splice(parseInt(t),1);f(h.length,e)})).then(()=>(m.length>0||v&&"object"==typeof e)&&a.mutate({trans:r,type:"put",keys:g,values:m,criteria:v,changeSpec:"function"!=typeof e&&e}).then(e=>f(m.length,e))).then(()=>(y.length>0||v&&e===us)&&a.mutate({trans:r,type:"delete",keys:y,criteria:v}).then(e=>f(y.length,e))).then(()=>o.length>c+d&&i(c+u))})};return i(0).then(()=>{if(c.length>0)throw new sM("Error modifying one or more objects",c,d,p);return o.length})})})}delete(){var e=this._ctx,t=e.range;return l5(e)&&(e.isPrimKey&&!lY||3===t.type)?this._write(r=>{let{primaryKey:n}=e.table.core.schema;return e.table.core.count({trans:r,query:{index:n,range:t}}).then(n=>e.table.core.mutate({trans:r,type:"deleteRange",range:t}).then(({failures:e,lastResult:t,results:r,numFailures:o})=>{if(o)throw new sM("Could not delete some values",Object.keys(e).map(t=>e[t]),n-o);return n-o}))}):this.modify(us)}}let us=(e,t)=>t.value=null;function ul(e,t){return e<t?-1:+(e!==t)}function uu(e,t){return e>t?-1:+(e!==t)}function uc(e,t,r){var n=e instanceof um?new e.Collection(e):e;return n._ctx.error=r?new r(t):TypeError(t),n}function ud(e){return new e.Collection(e,()=>uh("")).limit(0)}function up(e,t,r,n){var o,i,a,s,l,u,c,d=r.length;if(!r.every(e=>"string"==typeof e))return uc(e,lG);function p(e){o="next"===e?e=>e.toUpperCase():e=>e.toLowerCase(),i="next"===e?e=>e.toLowerCase():e=>e.toUpperCase(),a="next"===e?ul:uu;var t=r.map(function(e){return{lower:i(e),upper:o(e)}}).sort(function(e,t){return a(e.lower,t.lower)});s=t.map(function(e){return e.upper}),l=t.map(function(e){return e.lower}),u=e,c="next"===e?"":n}p("next");var f=new e.Collection(e,()=>uf(s[0],l[d-1]+n));f._ondirectionchange=function(e){p(e)};var h=0;return f._addAlgorithm(function(e,r,n){var o=e.key;if("string"!=typeof o)return!1;var p=i(o);if(t(p,l,h))return!0;for(var f=null,m=h;m<d;++m){var g=function(e,t,r,n,o,i){for(var a=Math.min(e.length,n.length),s=-1,l=0;l<a;++l){var u=t[l];if(u!==n[l])return 0>o(e[l],r[l])?e.substr(0,l)+r[l]+r.substr(l+1):0>o(e[l],n[l])?e.substr(0,l)+n[l]+r.substr(l+1):s>=0?e.substr(0,s)+t[s]+r.substr(s+1):null;0>o(e[l],u)&&(s=l)}return a<n.length&&"next"===i?e+r.substr(e.length):a<e.length&&"prev"===i?e.substr(0,r.length):s<0?null:e.substr(0,s)+n[s]+r.substr(s+1)}(o,p,s[m],l[m],a,u);null===g&&null===f?h=m+1:(null===f||a(f,g)>0)&&(f=g)}return r(null!==f?function(){e.continue(f+c)}:n),!1}),f}function uf(e,t,r,n){return{type:2,lower:e,upper:t,lowerOpen:r,upperOpen:n}}function uh(e){return{type:1,lower:e,upper:e}}class um{get Collection(){return this._ctx.table.db.Collection}between(e,t,r,n){r=!1!==r,n=!0===n;try{return this._cmp(e,t)>0||0===this._cmp(e,t)&&(r||n)&&(!r||!n)?ud(this):new this.Collection(this,()=>uf(e,t,!r,!n))}catch(e){return uc(this,lH)}}equals(e){return null==e?uc(this,lH):new this.Collection(this,()=>uh(e))}above(e){return null==e?uc(this,lH):new this.Collection(this,()=>uf(e,void 0,!0))}aboveOrEqual(e){return null==e?uc(this,lH):new this.Collection(this,()=>uf(e,void 0,!1))}below(e){return null==e?uc(this,lH):new this.Collection(this,()=>uf(void 0,e,!1,!0))}belowOrEqual(e){return null==e?uc(this,lH):new this.Collection(this,()=>uf(void 0,e))}startsWith(e){return"string"!=typeof e?uc(this,lG):this.between(e,e+lK,!0,!0)}startsWithIgnoreCase(e){return""===e?this.startsWith(e):up(this,(e,t)=>0===e.indexOf(t[0]),[e],lK)}equalsIgnoreCase(e){return up(this,(e,t)=>e===t[0],[e],"")}anyOfIgnoreCase(){var e=sD.apply(sS,arguments);return 0===e.length?ud(this):up(this,(e,t)=>-1!==t.indexOf(e),e,"")}startsWithAnyOfIgnoreCase(){var e=sD.apply(sS,arguments);return 0===e.length?ud(this):up(this,(e,t)=>t.some(t=>0===e.indexOf(t)),e,lK)}anyOf(){let e=sD.apply(sS,arguments),t=this._cmp;try{e.sort(t)}catch(e){return uc(this,lH)}if(0===e.length)return ud(this);let r=new this.Collection(this,()=>uf(e[0],e[e.length-1]));r._ondirectionchange=r=>{t="next"===r?this._ascending:this._descending,e.sort(t)};let n=0;return r._addAlgorithm((r,o,i)=>{let a=r.key;for(;t(a,e[n])>0;)if(++n===e.length)return o(i),!1;return 0===t(a,e[n])||(o(()=>{r.continue(e[n])}),!1)}),r}notEqual(e){return this.inAnyRange([[lz,e],[e,this.db._maxKey]],{includeLowers:!1,includeUppers:!1})}noneOf(){let e=sD.apply(sS,arguments);if(0===e.length)return new this.Collection(this);try{e.sort(this._ascending)}catch(e){return uc(this,lH)}let t=e.reduce((e,t)=>e?e.concat([[e[e.length-1][1],t]]):[[lz,t]],null);return t.push([e[e.length-1],this.db._maxKey]),this.inAnyRange(t,{includeLowers:!1,includeUppers:!1})}inAnyRange(e,t){let r=this._cmp,n=this._ascending,o=this._descending,i=this._min,a=this._max;if(0===e.length)return ud(this);if(!e.every(e=>void 0!==e[0]&&void 0!==e[1]&&0>=n(e[0],e[1])))return uc(this,"First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower",sB.InvalidArgument);let s=!t||!1!==t.includeLowers,l=t&&!0===t.includeUppers,u,c=n;function d(e,t){return c(e[0],t[0])}try{(u=e.reduce(function(e,t){let n=0,o=e.length;for(;n<o;++n){let o=e[n];if(0>r(t[0],o[1])&&r(t[1],o[0])>0){o[0]=i(o[0],t[0]),o[1]=a(o[1],t[1]);break}}return n===o&&e.push(t),e},[])).sort(d)}catch(e){return uc(this,lH)}let p=0,f=l?e=>n(e,u[p][1])>0:e=>n(e,u[p][1])>=0,h=s?e=>o(e,u[p][0])>0:e=>o(e,u[p][0])>=0,m=f,g=new this.Collection(this,()=>uf(u[0][0],u[u.length-1][1],!s,!l));return g._ondirectionchange=e=>{"next"===e?(m=f,c=n):(m=h,c=o),u.sort(d)},g._addAlgorithm((e,t,r)=>{for(var o=e.key;m(o);)if(++p===u.length)return t(r),!1;return!!(!f(o)&&!h(o))||(0===this._cmp(o,u[p][1])||0===this._cmp(o,u[p][0])||t(()=>{c===n?e.continue(u[p][0]):e.continue(u[p][1])}),!1)}),g}startsWithAnyOf(){let e=sD.apply(sS,arguments);return e.every(e=>"string"==typeof e)?0===e.length?ud(this):this.inAnyRange(e.map(e=>[e,e+lK])):uc(this,"startsWithAnyOf() only works with strings")}}function ug(e){return lx(function(t){return uy(t),e(t.target.error),!1})}function uy(e){e.stopPropagation&&e.stopPropagation(),e.preventDefault&&e.preventDefault()}let uv="storagemutated",ub="x-storagemutated-1",uw=l2(null,uv);class u_{_lock(){return sl(!li.global),++this._reculock,1!==this._reculock||li.global||(li.lockOwnerFor=this),this}_unlock(){if(sl(!li.global),0==--this._reculock)for(li.global||(li.lockOwnerFor=null);this._blockedFuncs.length>0&&!this._locked();){var e=this._blockedFuncs.shift();try{lM(e[1],e[0])}catch(e){}}return this}_locked(){return this._reculock&&li.lockOwnerFor!==this}create(e){if(!this.mode)return this;let t=this.db.idbdb,r=this.db._state.dbOpenError;if(sl(!this.idbtrans),!e&&!t)switch(r&&r.name){case"DatabaseClosedError":throw new sB.DatabaseClosed(r);case"MissingAPIError":throw new sB.MissingAPI(r.message,r);default:throw new sB.OpenFailed(r)}if(!this.active)throw new sB.TransactionInactive;return sl(null===this._completion._state),(e=this.idbtrans=e||(this.db.core?this.db.core.transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability}):t.transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability}))).onerror=lx(t=>{uy(t),this._reject(e.error)}),e.onabort=lx(t=>{uy(t),this.active&&this._reject(new sB.Abort(e.error)),this.active=!1,this.on("abort").fire(t)}),e.oncomplete=lx(()=>{this.active=!1,this._resolve(),"mutatedParts"in e&&uw.storagemutated.fire(e.mutatedParts)}),this}_promise(e,t,r){if("readwrite"===e&&"readwrite"!==this.mode)return lU(new sB.ReadOnly("Transaction is readonly"));if(!this.active)return lU(new sB.TransactionInactive);if(this._locked())return new lu((n,o)=>{this._blockedFuncs.push([()=>{this._promise(e,t,r).then(n,o)},li])});if(r)return lC(()=>{var e=new lu((e,r)=>{this._lock();let n=t(e,r,this);n&&n.then&&n.then(e,r)});return e.finally(()=>this._unlock()),e._lib=!0,e});var n=new lu((e,r)=>{var n=t(e,r,this);n&&n.then&&n.then(e,r)});return n._lib=!0,n}_root(){return this.parent?this.parent._root():this}waitFor(e){var t=this._root();let r=lu.resolve(e);if(t._waitingFor)t._waitingFor=t._waitingFor.then(()=>r);else{t._waitingFor=r,t._waitingQueue=[];var n=t.idbtrans.objectStore(t.storeNames[0]);!function e(){for(++t._spinCount;t._waitingQueue.length;)t._waitingQueue.shift()();t._waitingFor&&(n.get(-1/0).onsuccess=e)}()}var o=t._waitingFor;return new lu((e,n)=>{r.then(r=>t._waitingQueue.push(lx(e.bind(null,r))),e=>t._waitingQueue.push(lx(n.bind(null,e)))).finally(()=>{t._waitingFor===o&&(t._waitingFor=null)})})}abort(){this.active&&(this.active=!1,this.idbtrans&&this.idbtrans.abort(),this._reject(new sB.Abort))}table(e){let t=this._memoizedTables||(this._memoizedTables={});if(a9(t,e))return t[e];let r=this.schema[e];if(!r)throw new sB.NotFound("Table "+e+" not part of transaction");let n=new this.db.Table(e,r,this);return n.core=this.db.core.table(e),t[e]=n,n}}function ux(e,t,r,n,o,i,a){return{name:e,keyPath:t,unique:r,multi:n,auto:o,compound:i,src:(r&&!a?"&":"")+(n?"*":"")+(o?"++":"")+uE(t)}}function uE(e){return"string"==typeof e?e:e?"["+[].join.call(e,"+")+"]":""}function uS(e,t,r){return{name:e,primKey:t,indexes:r,mappedClass:null,idxByName:sc(r,e=>[e.name,e])}}let uD=e=>{try{return e.only([[]]),uD=()=>[[]],[[]]}catch(e){return uD=()=>lK,lK}};function uO(e){return null==e?()=>{}:"string"==typeof e?1===e.split(".").length?t=>t[e]:t=>sd(t,e):t=>sd(t,e)}function uk(e){return[].slice.call(e)}let uP=0;function uC(e){return null==e?":id":"string"==typeof e?e:`[${e.join("+")}]`}function uj({_novip:e},t){let r=t.db,n=function(e,t,{IDBKeyRange:r,indexedDB:n},o){var i;return{dbcore:(i=function(e,t,r){let n;function o(e){if(3===e.type)return null;if(4===e.type)throw Error("Cannot convert never type to IDBKeyRange");let{lower:r,upper:n,lowerOpen:o,upperOpen:i}=e;return void 0===r?void 0===n?null:t.upperBound(n,!!i):void 0===n?t.lowerBound(r,!!o):t.bound(r,n,!!o,!!i)}let{schema:i,hasGetAll:a}=(n=uk(e.objectStoreNames),{schema:{name:e.name,tables:n.map(e=>r.objectStore(e)).map(e=>{let{keyPath:t,autoIncrement:r}=e,n=a2(t),o=null==t,i={},a={name:e.name,primaryKey:{name:null,isPrimaryKey:!0,outbound:o,compound:n,keyPath:t,autoIncrement:r,unique:!0,extractKey:uO(t)},indexes:uk(e.indexNames).map(t=>e.index(t)).map(e=>{let{name:t,unique:r,multiEntry:n,keyPath:o}=e,a={name:t,compound:a2(o),keyPath:o,unique:r,multiEntry:n,extractKey:uO(o)};return i[uC(o)]=a,a}),getIndexByKeyPath:e=>i[uC(e)]};return i[":id"]=a.primaryKey,null!=t&&(i[uC(t)]=a.primaryKey),a})},hasGetAll:n.length>0&&"getAll"in r.objectStore(n[0])&&!("u">typeof navigator&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604)}),s=i.tables.map(e=>{let t;return{name:t=e.name,schema:e,mutate:function({trans:e,type:r,keys:n,values:i,range:a}){return new Promise((s,l)=>{let u;s=lx(s);let c=e.objectStore(t),d=null==c.keyPath,p="put"===r||"add"===r;if(!p&&"delete"!==r&&"deleteRange"!==r)throw Error("Invalid operation type: "+r);let{length:f}=n||i||{length:1};if(n&&i&&n.length!==i.length)throw Error("Given keys array must have same length as given values array.");if(0===f)return s({numFailures:0,failures:{},results:[],lastResult:void 0});let h=[],m=[],g=0,y=e=>{++g,uy(e)};if("deleteRange"===r){if(4===a.type)return s({numFailures:g,failures:m,results:[],lastResult:void 0});3===a.type?h.push(u=c.clear()):h.push(u=c.delete(o(a)))}else{let[e,t]=p?d?[i,n]:[i,null]:[n,null];if(p)for(let n=0;n<f;++n)h.push(u=t&&void 0!==t[n]?c[r](e[n],t[n]):c[r](e[n])),u.onerror=y;else for(let t=0;t<f;++t)h.push(u=c[r](e[t])),u.onerror=y}let v=e=>{let t=e.target.result;h.forEach((e,t)=>null!=e.error&&(m[t]=e.error)),s({numFailures:g,failures:m,results:"delete"===r?n:h.map(e=>e.result),lastResult:t})};u.onerror=e=>{y(e),v(e)},u.onsuccess=v})},getMany:({trans:e,keys:r})=>new Promise((n,o)=>{n=lx(n);let i=e.objectStore(t),a=r.length,s=Array(a),l,u=0,c=0,d=e=>{let t=e.target;s[t._pos]=t.result,++c===u&&n(s)},p=ug(o);for(let e=0;e<a;++e)null!=r[e]&&((l=i.get(r[e]))._pos=e,l.onsuccess=d,l.onerror=p,++u);0===u&&n(s)}),get:({trans:e,key:r})=>new Promise((n,o)=>{n=lx(n);let i=e.objectStore(t).get(r);i.onsuccess=e=>n(e.target.result),i.onerror=ug(o)}),query:e=>new Promise((r,n)=>{r=lx(r);let{trans:i,values:s,limit:l,query:u}=e,c=l===1/0?void 0:l,{index:d,range:p}=u,f=i.objectStore(t),h=d.isPrimaryKey?f:f.index(d.name),m=o(p);if(0===l)return r({result:[]});if(a){let e=s?h.getAll(m,c):h.getAllKeys(m,c);e.onsuccess=e=>r({result:e.target.result}),e.onerror=ug(n)}else{let e=0,t=!s&&"openKeyCursor"in h?h.openKeyCursor(m):h.openCursor(m),o=[];t.onsuccess=n=>{let i=t.result;return i?(o.push(s?i.value:i.primaryKey),++e===l?r({result:o}):void i.continue()):r({result:o})},t.onerror=ug(n)}}),openCursor:function({trans:e,values:r,query:n,reverse:i,unique:a}){return new Promise((s,l)=>{s=lx(s);let{index:u,range:c}=n,d=e.objectStore(t),p=u.isPrimaryKey?d:d.index(u.name),f=i?a?"prevunique":"prev":a?"nextunique":"next",h=!r&&"openKeyCursor"in p?p.openKeyCursor(o(c),f):p.openCursor(o(c),f);h.onerror=ug(l),h.onsuccess=lx(t=>{let r=h.result;if(!r)return void s(null);r.___id=++uP,r.done=!1;let n=r.continue.bind(r),o=r.continuePrimaryKey;o&&(o=o.bind(r));let i=r.advance.bind(r),a=()=>{throw Error("Cursor not stopped")};r.trans=e,r.stop=r.continue=r.continuePrimaryKey=r.advance=()=>{throw Error("Cursor not started")},r.fail=lx(l),r.next=function(){let e=1;return this.start(()=>e--?this.continue():this.stop()).then(()=>this)},r.start=e=>{let t=new Promise((e,t)=>{e=lx(e),h.onerror=ug(t),r.fail=t,r.stop=t=>{r.stop=r.continue=r.continuePrimaryKey=r.advance=a,e(t)}}),s=()=>{if(h.result)try{e()}catch(e){r.fail(e)}else r.done=!0,r.start=()=>{throw Error("Cursor behind last entry")},r.stop()};return h.onsuccess=lx(e=>{h.onsuccess=s,s()}),r.continue=n,r.continuePrimaryKey=o,r.advance=i,s(),t},s(r)},l)})},count({query:e,trans:r}){let{index:n,range:i}=e;return new Promise((e,a)=>{let s=r.objectStore(t),l=n.isPrimaryKey?s:s.index(n.name),u=o(i),c=u?l.count(u):l.count();c.onsuccess=lx(t=>e(t.target.result)),c.onerror=ug(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:uD(t),schema:i}}(t,r,o),e.dbcore.reduce((e,{create:t})=>({...e,...t(e)}),i))}}(e._middlewares,r,e._deps,t);e.core=n.dbcore,e.tables.forEach(t=>{let r=t.name;e.core.schema.tables.some(e=>e.name===r)&&(t.core=e.core.table(r),e[r]instanceof e.Table&&(e[r].core=t.core))})}function uT({_novip:e},t,r,n){r.forEach(r=>{let o=n[r];t.forEach(t=>{let n=so(t,r);(!n||"value"in n&&void 0===n.value)&&(t===e.Transaction.prototype||t instanceof e.Transaction?st(t,r,{get(){return this.table(r)},set(e){se(this,r,{value:e,writable:!0,configurable:!0,enumerable:!0})}}):t[r]=new e.Table(r,o))})})}function uR({_novip:e},t){t.forEach(t=>{for(let r in t)t[r]instanceof e.Table&&delete t[r]})}function uA(e,t){return e._cfg.version-t._cfg.version}function uN(e,t){let r,n={del:[],add:[],change:[]};for(r in e)t[r]||n.del.push(r);for(r in t){let o=e[r],i=t[r];if(o){let e={name:r,def:i,recreate:!1,del:[],add:[],change:[]};if(""+(o.primKey.keyPath||"")==""+(i.primKey.keyPath||"")&&(o.primKey.auto===i.primKey.auto||lY)){let t,r=o.idxByName,a=i.idxByName;for(t in r)a[t]||e.del.push(t);for(t in a){let n=r[t],o=a[t];n?n.src!==o.src&&e.change.push(o):e.add.push(o)}(e.del.length>0||e.add.length>0||e.change.length>0)&&n.change.push(e)}else e.recreate=!0,n.change.push(e)}else n.add.push([r,i])}return n}function u$(e,t,r,n){let o=e.db.createObjectStore(t,r.keyPath?{keyPath:r.keyPath,autoIncrement:r.auto}:{autoIncrement:r.auto});return n.forEach(e=>uI(o,e)),o}function uI(e,t){e.createIndex(t.name,t.keyPath,{unique:t.unique,multiEntry:t.multi})}function uM(e,t,r){let n={};return sa(t.objectStoreNames,0).forEach(e=>{let t=r.objectStore(e),o=t.keyPath,i=ux(uE(o),o||"",!1,!1,!!t.autoIncrement,o&&"string"!=typeof o,!0),a=[];for(let e=0;e<t.indexNames.length;++e){let r=t.index(t.indexNames[e]);o=r.keyPath;var s=ux(r.name,o,!!r.unique,!!r.multiEntry,!1,o&&"string"!=typeof o,!1);a.push(s)}n[e]=uS(e,i,a)}),n}function uL({_novip:e},t,r){let n=r.db.objectStoreNames;for(let o=0;o<n.length;++o){let i=n[o],a=r.objectStore(i);e._hasGetAll="getAll"in a;for(let e=0;e<a.indexNames.length;++e){let r=a.indexNames[e],n=a.index(r).keyPath,o="string"==typeof n?n:"["+sa(n).join("+")+"]";if(t[i]){let e=t[i].idxByName[o];e&&(e.name=r,delete t[i].idxByName[o],t[i].idxByName[r]=e)}}}"u">typeof navigator&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&a4.WorkerGlobalScope&&a4 instanceof a4.WorkerGlobalScope&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604&&(e._hasGetAll=!1)}class uF{_parseStoresSpec(e,t){a3(e).forEach(r=>{if(null!==e[r]){var n=e[r].split(",").map((e,t)=>{let r=(e=e.trim()).replace(/([&*]|\+\+)/g,""),n=/^\[/.test(r)?r.match(/^\[(.*)\]$/)[1].split("+"):r;return ux(r,n||null,/\&/.test(e),/\*/.test(e),/\+\+/.test(e),a2(n),0===t)}),o=n.shift();if(o.multi)throw new sB.Schema("Primary key cannot be multi-valued");n.forEach(e=>{if(e.auto)throw new sB.Schema("Only primary key can be marked as autoIncrement (++)");if(!e.keyPath)throw new sB.Schema("Index must have a name and cannot be an empty string")}),t[r]=uS(r,o,n)}})}stores(e){let t=this.db;this._cfg.storesSource=this._cfg.storesSource?a6(this._cfg.storesSource,e):e;let r=t._versions,n={},o={};return r.forEach(e=>{a6(n,e._cfg.storesSource),o=e._cfg.dbschema={},e._parseStoresSpec(n,o)}),t._dbSchema=o,uR(t,[t._allTables,t,t.Transaction.prototype]),uT(t,[t._allTables,t,t.Transaction.prototype,this._cfg.tables],a3(o),o),t._storeNames=a3(o),this}upgrade(e){return this._cfg.contentUpgrade=sJ(this._cfg.contentUpgrade||sW,e),this}}function uB(e,t){let r=e._dbNamesDB;return r||(r=e._dbNamesDB=new u6(lJ,{addons:[],indexedDB:e,IDBKeyRange:t})).version(1).stores({dbnames:"name"}),r.table("dbnames")}function uV(e){return e&&"function"==typeof e.databases}function uU(e){return lC(function(){return li.letThrough=!0,e()})}function uW(e){var t=t=>e.next(t),r=o(t),n=o(t=>e.throw(t));function o(e){return t=>{var o=e(t),i=o.value;return o.done?i:i&&"function"==typeof i.then?i.then(r,n):a2(i)?Promise.all(i).then(r,n):r(i)}}return o(t)()}function uK(e,t,r){var n=arguments.length;if(n<2)throw new sB.InvalidArgument("Too few arguments");for(var o=Array(n-1);--n;)o[n-1]=arguments[n];return r=o.pop(),[e,sm(o),r]}function uz(e,t,r){let n=a2(e)?e.slice():[e];for(let e=0;e<r;++e)n.push(t);return n}let uH={stack:"dbcore",name:"VirtualIndexMiddleware",level:1,create:function(e){return{...e,table(t){let r=e.table(t),{schema:n}=r,o={},i=[];function a(e,t,r){let n=uC(e),s=o[n]=o[n]||[],l=null==e?0:"string"==typeof e?1:e.length,u=t>0,c={...r,isVirtual:u,keyTail:t,keyLength:l,extractKey:uO(e),unique:!u&&r.unique};return s.push(c),c.isPrimaryKey||i.push(c),l>1&&a(2===l?e[0]:e.slice(0,l-1),t+1,r),s.sort((e,t)=>e.keyTail-t.keyTail),c}let s=a(n.primaryKey.keyPath,0,n.primaryKey);for(let e of(o[":id"]=[s],n.indexes))a(e.keyPath,0,e);function l(t){var r,n;let o=t.query.index;return o.isVirtual?{...t,query:{index:o,range:(r=t.query.range,n=o.keyTail,{type:1===r.type?2:r.type,lower:uz(r.lower,r.lowerOpen?e.MAX_KEY:e.MIN_KEY,n),lowerOpen:!0,upper:uz(r.upper,r.upperOpen?e.MIN_KEY:e.MAX_KEY,n),upperOpen:!0})}}:t}return{...r,schema:{...n,primaryKey:s,indexes:i,getIndexByKeyPath:function(e){let t=o[uC(e)];return t&&t[0]}},count:e=>r.count(l(e)),query:e=>r.query(l(e)),openCursor(t){let{keyTail:n,isVirtual:o,keyLength:i}=t.query.index;return o?r.openCursor(l(t)).then(r=>r&&Object.create(r,{continue:{value:function(o){null!=o?r.continue(uz(o,t.reverse?e.MAX_KEY:e.MIN_KEY,n)):t.unique?r.continue(r.key.slice(0,i).concat(t.reverse?e.MIN_KEY:e.MAX_KEY,n)):r.continue()}},continuePrimaryKey:{value(t,o){r.continuePrimaryKey(uz(t,e.MAX_KEY,n),o)}},primaryKey:{get:()=>r.primaryKey},key:{get(){let e=r.key;return 1===i?e[0]:e.slice(0,i)}},value:{get:()=>r.value}})):r.openCursor(t)}}}}}};function uG(e,t,r,n){return r=r||{},n=n||"",a3(e).forEach(o=>{if(a9(t,o)){var i=e[o],a=t[o];if("object"==typeof i&&"object"==typeof a&&i&&a){let e=s_(i);e!==s_(a)?r[n+o]=t[o]:"Object"===e?uG(i,a,r,n+o+"."):i!==a&&(r[n+o]=t[o])}else i!==a&&(r[n+o]=t[o])}else r[n+o]=void 0}),a3(t).forEach(o=>{a9(e,o)||(r[n+o]=t[o])}),r}let uq={stack:"dbcore",name:"HooksMiddleware",level:2,create:e=>({...e,table(t){let r=e.table(t),{primaryKey:n}=r.schema;return{...r,mutate(e){let o=li.trans,{deleting:i,creating:a,updating:s}=o.table(t).hook;switch(e.type){case"add":if(a.fire===sW)break;return o._promise("readwrite",()=>l(e),!0);case"put":if(a.fire===sW&&s.fire===sW)break;return o._promise("readwrite",()=>l(e),!0);case"delete":if(i.fire===sW)break;return o._promise("readwrite",()=>l(e),!0);case"deleteRange":if(i.fire===sW)break;return o._promise("readwrite",()=>(function e(t,o,i){return r.query({trans:t,values:!1,query:{index:n,range:o},limit:i}).then(({result:r})=>l({type:"delete",keys:r,trans:t}).then(n=>n.numFailures>0?Promise.reject(n.failures[0]):r.length<i?{failures:[],numFailures:0,lastResult:void 0}:e(t,{...o,lower:r[r.length-1],lowerOpen:!0},i)))})(e.trans,e.range,1e4),!0)}return r.mutate(e);function l(e){var t,o;let l=li.trans,u=e.keys||("delete"===(t=e).type?t.keys:t.keys||t.values.map(n.extractKey));if(!u)throw Error("Keys missing");return"delete"!==(e="add"===e.type||"put"===e.type?{...e,keys:u}:{...e}).type&&(e.values=[...e.values]),e.keys&&(e.keys=[...e.keys]),("add"===(o=e).type?Promise.resolve([]):r.getMany({trans:o.trans,keys:u,cache:"immutable"})).then(t=>{let o=u.map((r,o)=>{let u=t[o],c={onerror:null,onsuccess:null};if("delete"===e.type)i.fire.call(c,r,u,l);else if("add"===e.type||void 0===u){let t=a.fire.call(c,r,e.values[o],l);null==r&&null!=t&&(r=t,e.keys[o]=r,n.outbound||sp(e.values[o],n.keyPath,r))}else{let t=uG(u,e.values[o]),n=s.fire.call(c,t,r,u,l);if(n){let t=e.values[o];Object.keys(n).forEach(e=>{a9(t,e)?t[e]=n[e]:sp(t,e,n[e])})}}return c});return r.mutate(e).then(({failures:r,results:n,numFailures:i,lastResult:a})=>{for(let i=0;i<u.length;++i){let a=n?n[i]:u[i],s=o[i];null==a?s.onerror&&s.onerror(r[i]):s.onsuccess&&s.onsuccess("put"===e.type&&t[i]?e.values[i]:a)}return{failures:r,results:n,numFailures:i,lastResult:a}}).catch(e=>(o.forEach(t=>t.onerror&&t.onerror(e)),Promise.reject(e)))})}}}}})};function uY(e,t,r){try{if(!t||t.keys.length<e.length)return null;let n=[];for(let o=0,i=0;o<t.keys.length&&i<e.length;++o)0===un(t.keys[o],e[i])&&(n.push(r?sb(t.values[o]):t.values[o]),++i);return n.length===e.length?n:null}catch(e){return null}}let uZ={stack:"dbcore",level:-1,create:e=>({table:t=>{let r=e.table(t);return{...r,getMany:e=>{if(!e.cache)return r.getMany(e);let t=uY(e.keys,e.trans._cache,"clone"===e.cache);return t?lu.resolve(t):r.getMany(e).then(t=>(e.trans._cache={keys:e.keys,values:"clone"===e.cache?sb(t):t},t))},mutate:e=>("add"!==e.type&&(e.trans._cache=null),r.mutate(e))}}})};function uJ(e){return!("from"in e)}let uX=function(e,t){if(!this){let t=new uX;return e&&"d"in e&&a6(t,e),t}a6(this,arguments.length?{d:1,from:e,to:arguments.length>1?t:e}:{d:0})};function uQ(e,t,r){let n=un(t,r);if(isNaN(n))return;if(n>0)throw RangeError();if(uJ(e))return a6(e,{from:t,to:r,d:1});let o=e.l,i=e.r;if(0>un(r,e.from))return o?uQ(o,t,r):e.l={from:t,to:r,d:1,l:null,r:null},u4(e);if(un(t,e.to)>0)return i?uQ(i,t,r):e.r={from:t,to:r,d:1,l:null,r:null},u4(e);0>un(t,e.from)&&(e.from=t,e.l=null,e.d=i?i.d+1:1),un(r,e.to)>0&&(e.to=r,e.r=null,e.d=e.l?e.l.d+1:1);let a=!e.r;o&&!e.l&&u0(e,o),i&&a&&u0(e,i)}function u0(e,t){uJ(t)||function e(t,{from:r,to:n,l:o,r:i}){uQ(t,r,n),o&&e(t,o),i&&e(t,i)}(e,t)}function u1(e){let t=uJ(e)?null:{s:0,n:e};return{next(e){let r=arguments.length>0;for(;t;)switch(t.s){case 0:if(t.s=1,r)for(;t.n.l&&0>un(e,t.n.from);)t={up:t,n:t.n.l,s:1};else for(;t.n.l;)t={up:t,n:t.n.l,s:1};case 1:if(t.s=2,!r||0>=un(e,t.n.to))return{value:t.n,done:!1};case 2:if(t.n.r){t.s=3,t={up:t,n:t.n.r,s:0};continue}case 3:t=t.up}return{done:!0}}}}function u4(e){var t,r;let n=((null==(t=e.r)?void 0:t.d)||0)-((null==(r=e.l)?void 0:r.d)||0),o=n>1?"r":n<-1?"l":"";if(o){let t="r"===o?"l":"r",r={...e},n=e[o];e.from=n.from,e.to=n.to,e[o]=n[o],r[o]=n[t],e[t]=r,r.d=u3(r)}e.d=u3(e)}function u3({r:e,l:t}){return(e?t?Math.max(e.d,t.d):e.d:t?t.d:0)+1}a7(uX.prototype,{add(e){return u0(this,e),this},addKey(e){return uQ(this,e,e),this},addKeys(e){return e.forEach(e=>uQ(this,e,e)),this},[sx](){return u1(this)}});let u2={stack:"dbcore",level:0,create:e=>{let t=e.schema.name,r=new uX(e.MIN_KEY,e.MAX_KEY);return{...e,table:n=>{let o=e.table(n),{schema:i}=o,{primaryKey:a}=i,{extractKey:s,outbound:l}=a,u={...o,mutate:e=>{let a=e.trans,s=a.mutatedParts||(a.mutatedParts={}),l=e=>{let r=`idb://${t}/${n}/${e}`;return s[r]||(s[r]=new uX)},u=l(""),c=l(":dels"),{type:d}=e,[p,f]="deleteRange"===e.type?[e.range]:"delete"===e.type?[e.keys]:e.values.length<50?[[],e.values]:[],h=e.trans._cache;return o.mutate(e).then(e=>{if(a2(p)){"delete"!==d&&(p=e.results),u.addKeys(p);let t=uY(p,h);t||"add"===d||c.addKeys(p),(t||f)&&i.indexes.forEach(function(e){let r=l(e.name||"");function n(t){return null!=t?e.extractKey(t):null}let o=t=>e.multiEntry&&a2(t)?t.forEach(e=>r.addKey(e)):r.addKey(t);(t||f).forEach((e,r)=>{let i=t&&n(t[r]),a=f&&n(f[r]);0!==un(i,a)&&(null!=i&&o(i),null!=a&&o(a))})})}else if(p){let e={from:p.lower,to:p.upper};c.add(e),u.add(e)}else u.add(r),c.add(r),i.indexes.forEach(e=>l(e.name).add(r));return e})}},c=({query:{index:t,range:r}})=>{var n,o;return[t,new uX(null!=(n=r.lower)?n:e.MIN_KEY,null!=(o=r.upper)?o:e.MAX_KEY)]},d={get:e=>[a,new uX(e.key)],getMany:e=>[a,(new uX).addKeys(e.keys)],count:c,query:c,openCursor:c};return a3(d).forEach(e=>{u[e]=function(i){let{subscr:a}=li;if(a){let u=e=>{let r=`idb://${t}/${n}/${e}`;return a[r]||(a[r]=new uX)},c=u(""),p=u(":dels"),[f,h]=d[e](i);if(u(f.name||"").add(h),!f.isPrimaryKey){if("count"!==e){let t="query"===e&&l&&i.values&&o.query({...i,values:!1});return o[e].apply(this,arguments).then(r=>{if("query"===e){if(l&&i.values)return t.then(({result:e})=>(c.addKeys(e),r));let e=i.values?r.result.map(s):r.result;i.values?c.addKeys(e):p.addKeys(e)}else if("openCursor"===e){let e=i.values;return r&&Object.create(r,{key:{get:()=>(p.addKey(r.primaryKey),r.key)},primaryKey:{get(){let e=r.primaryKey;return p.addKey(e),e}},value:{get:()=>(e&&c.addKey(r.primaryKey),r.value)}})}return r})}p.add(r)}}return o[e].apply(this,arguments)}}),u}}}};class u6{constructor(e,t){var r;this._middlewares={},this.verno=0;const n=u6.dependencies;this._options=t={addons:u6.addons,autoOpen:!0,indexedDB:n.indexedDB,IDBKeyRange:n.IDBKeyRange,...t},this._deps={indexedDB:t.indexedDB,IDBKeyRange:t.IDBKeyRange};const{addons:o}=t;this._dbSchema={},this._versions=[],this._storeNames=[],this._allTables={},this.idbdb=null,this._novip=this;const i={dbOpenError:null,isBeingOpened:!1,onReadyBeingFired:null,openComplete:!1,dbReadyResolve:sW,dbReadyPromise:null,cancelOpen:sW,openCanceller:null,autoSchema:!0,PR1398_maxLoop:3};i.dbReadyPromise=new lu(e=>{i.dbReadyResolve=e}),i.openCanceller=new lu((e,t)=>{i.cancelOpen=t}),this._state=i,this.name=e,this.on=l2(this,"populate","blocked","versionchange","close",{ready:[sJ,sW]}),this.on.ready.subscribe=ss(this.on.ready.subscribe,e=>(t,r)=>{u6.vip(()=>{let n=this._state;if(n.openComplete)n.dbOpenError||lu.resolve().then(t),r&&e(t);else if(n.onReadyBeingFired)n.onReadyBeingFired.push(t),r&&e(t);else{e(t);let n=this;r||e(function e(){n.on.ready.unsubscribe(t),n.on.ready.unsubscribe(e)})}})}),this.Collection=(r=this,l6(ua.prototype,function(e,t){this.db=r;let n=l1,o=null;if(t)try{n=t()}catch(e){o=e}let i=e._ctx,a=i.table,s=a.hook.reading.fire;this._ctx={table:a,index:i.index,isPrimKey:!i.index||a.schema.primKey.keyPath&&i.index===a.schema.primKey.name,range:n,keysOnly:!1,dir:"next",unique:"",algorithm:null,filter:null,replayFilter:null,justLimit:!0,isMatch:null,offset:0,limit:1/0,error:o,or:i.or,valueMapper:s!==sK?s:null}})),this.Table=function(e){return l6(l3.prototype,function(t,r,n){this.db=e,this._tx=n,this.name=t,this.schema=r,this.hook=e._allTables[t]?e._allTables[t].hook:l2(null,{creating:[sG,sW],reading:[sz,sK],updating:[sY,sW],deleting:[sq,sW]})})}(this),this.Transaction=function(e){return l6(u_.prototype,function(t,r,n,o,i){this.db=e,this.mode=t,this.storeNames=r,this.schema=n,this.chromeTransactionDurability=o,this.idbtrans=null,this.on=l2(this,"complete","error","abort"),this.parent=i||null,this.active=!0,this._reculock=0,this._blockedFuncs=[],this._resolve=null,this._reject=null,this._waitingFor=null,this._waitingQueue=null,this._spinCount=0,this._completion=new lu((e,t)=>{this._resolve=e,this._reject=t}),this._completion.then(()=>{this.active=!1,this.on.complete.fire()},e=>{var t=this.active;return this.active=!1,this.on.error.fire(e),this.parent?this.parent._reject(e):t&&this.idbtrans&&this.idbtrans.abort(),lU(e)})})}(this),this.Version=function(e){return l6(uF.prototype,function(t){this.db=e,this._cfg={version:t,storesSource:null,dbschema:{},tables:{},contentUpgrade:null}})}(this),this.WhereClause=function(e){return l6(um.prototype,function(t,r,n){this.db=e,this._ctx={table:t,index:":id"===r?null:r,or:n};let o=e._deps.indexedDB;if(!o)throw new sB.MissingAPI;this._cmp=this._ascending=o.cmp.bind(o),this._descending=(e,t)=>o.cmp(t,e),this._max=(e,t)=>o.cmp(e,t)>0?e:t,this._min=(e,t)=>0>o.cmp(e,t)?e:t,this._IDBKeyRange=e._deps.IDBKeyRange})}(this),this.on("versionchange",e=>{e.newVersion>0?console.warn(`Another connection wants to upgrade database '${this.name}'. Closing db now to resume the upgrade.`):console.warn(`Another connection wants to delete database '${this.name}'. Closing db now to resume the delete request.`),this.close()}),this.on("blocked",e=>{!e.newVersion||e.newVersion<e.oldVersion?console.warn(`Dexie.delete('${this.name}') was blocked`):console.warn(`Upgrade '${this.name}' blocked by other connection holding version ${e.oldVersion/10}`)}),this._maxKey=uD(t.IDBKeyRange),this._createTransaction=(e,t,r,n)=>new this.Transaction(e,t,r,this._options.chromeTransactionDurability,n),this._fireOnBlocked=e=>{this.on("blocked").fire(e),lq.filter(e=>e.name===this.name&&e!==this&&!e._state.vcFired).map(t=>t.on("versionchange").fire(e))},this.use(uH),this.use(uq),this.use(u2),this.use(uZ),this.vip=Object.create(this,{_vip:{value:!0}}),o.forEach(e=>e(this))}version(e){if(isNaN(e)||e<.1)throw new sB.Type("Given version is not a positive number");if(e=Math.round(10*e)/10,this.idbdb||this._state.isBeingOpened)throw new sB.Schema("Cannot add version when database is open");this.verno=Math.max(this.verno,e);let t=this._versions;var r=t.filter(t=>t._cfg.version===e)[0];return r||(r=new this.Version(e),t.push(r),t.sort(uA),r.stores({}),this._state.autoSchema=!1,r)}_whenReady(e){return this.idbdb&&(this._state.openComplete||li.letThrough||this._vip)?e():new lu((e,t)=>{if(this._state.openComplete)return t(new sB.DatabaseClosed(this._state.dbOpenError));if(!this._state.isBeingOpened){if(!this._options.autoOpen)return void t(new sB.DatabaseClosed);this.open().catch(sW)}this._state.dbReadyPromise.then(e,t)}).then(e)}use({stack:e,create:t,level:r,name:n}){n&&this.unuse({stack:e,name:n});let o=this._middlewares[e]||(this._middlewares[e]=[]);return o.push({stack:e,create:t,level:null==r?10:r,name:n}),o.sort((e,t)=>e.level-t.level),this}unuse({stack:e,name:t,create:r}){return e&&this._middlewares[e]&&(this._middlewares[e]=this._middlewares[e].filter(e=>r?e.create!==r:!!t&&e.name!==t)),this}open(){return function(e){var t;let r=e._state,{indexedDB:n}=e._deps;if(r.isBeingOpened||e.idbdb)return r.dbReadyPromise.then(()=>r.dbOpenError?lU(r.dbOpenError):e);sk&&(r.openCanceller._stackHolder=sj()),r.isBeingOpened=!0,r.dbOpenError=null,r.openComplete=!1;let o=r.openCanceller;function i(){if(r.openCanceller!==o)throw new sB.DatabaseClosed("db.open() was cancelled")}let a=r.dbReadyResolve,s=null,l=!1;return lu.race([o,("u"<typeof navigator?lu.resolve():!navigator.userAgentData&&/Safari\//.test(navigator.userAgent)&&!/Chrom(e|ium)\//.test(navigator.userAgent)&&indexedDB.databases?new Promise(function(e){var r=function(){return indexedDB.databases().finally(e)};t=setInterval(r,100),r()}).finally(function(){return clearInterval(t)}):Promise.resolve()).then(()=>new lu((t,o)=>{if(i(),!n)throw new sB.MissingAPI;let a=e.name,u=r.autoSchema?n.open(a):n.open(a,Math.round(10*e.verno));if(!u)throw new sB.MissingAPI;u.onerror=ug(o),u.onblocked=lx(e._fireOnBlocked),u.onupgradeneeded=lx(t=>{if(s=u.transaction,r.autoSchema&&!e._options.allowEmptyDB){u.onerror=uy,s.abort(),u.result.close();let e=n.deleteDatabase(a);e.onsuccess=e.onerror=lx(()=>{o(new sB.NoSuchDatabase(`Database ${a} doesnt exist`))})}else{let r,n,a,p;s.onerror=ug(o);var i,c,d=t.oldVersion>0x4000000000000000?0:t.oldVersion;l=d<1,e._novip.idbdb=u.result,i=d/10,c=s,r=e._dbSchema,(n=e._createTransaction("readwrite",e._storeNames,r)).create(c),n._completion.catch(o),a=n._reject.bind(n),p=li.transless||li,lC(()=>{li.trans=n,li.transless=p,0===i?(a3(r).forEach(e=>{u$(c,e,r[e].primKey,r[e].indexes)}),uj(e,c),lu.follow(()=>e.on.populate.fire(n)).catch(a)):(function({_novip:e},t,r,n){let o=[],i=e._versions,a=e._dbSchema=uM(e,e.idbdb,n),s=!1;return i.filter(e=>e._cfg.version>=t).forEach(i=>{o.push(()=>{let o=a,l=i._cfg.dbschema;uL(e,o,n),uL(e,l,n),a=e._dbSchema=l;let u=uN(o,l);u.add.forEach(e=>{u$(n,e[0],e[1].primKey,e[1].indexes)}),u.change.forEach(e=>{if(e.recreate)throw new sB.Upgrade("Not yet support for changing primary key");{let t=n.objectStore(e.name);e.add.forEach(e=>uI(t,e)),e.change.forEach(e=>{t.deleteIndex(e.name),uI(t,e)}),e.del.forEach(e=>t.deleteIndex(e))}});let c=i._cfg.contentUpgrade;if(c&&i._cfg.version>t){let t;uj(e,n),r._memoizedTables={},s=!0;let i=sf(l);u.del.forEach(e=>{i[e]=o[e]}),uR(e,[e.Transaction.prototype]),uT(e,[e.Transaction.prototype],a3(i),i),r.schema=i;let a=sO(c);a&&lj();let d=lu.follow(()=>{if((t=c(r))&&a){var e=lT.bind(null,null);t.then(e,e)}});return t&&"function"==typeof t.then?lu.resolve(t):d.then(()=>t)}}),o.push(t=>{var n;s&&lY||(n=i._cfg.dbschema,[].slice.call(t.db.objectStoreNames).forEach(e=>null==n[e]&&t.db.deleteObjectStore(e))),uR(e,[e.Transaction.prototype]),uT(e,[e.Transaction.prototype],e._storeNames,e._dbSchema),r.schema=e._dbSchema})}),(function e(){return o.length?lu.resolve(o.shift()(r.idbtrans)).then(e):lu.resolve()})().then(()=>{var e;a3(e=a).forEach(t=>{n.db.objectStoreNames.contains(t)||u$(n,t,e[t].primKey,e[t].indexes)})})})(e,i,n,c).catch(a)})}},o),u.onsuccess=lx(()=>{s=null;let n=e._novip.idbdb=u.result,o=sa(n.objectStoreNames);if(o.length>0)try{let t,i=n.transaction(1===o.length?o[0]:o,"readonly");r.autoSchema?function({_novip:e},t,r){e.verno=t.version/10;let n=e._dbSchema=uM(0,t,r);e._storeNames=sa(t.objectStoreNames,0),uT(e,[e._allTables],a3(n),n)}(e,n,i):(uL(e,e._dbSchema,i),((t=uN(uM(0,e.idbdb,i),e._dbSchema)).add.length||t.change.some(e=>e.add.length||e.change.length))&&console.warn("Dexie SchemaDiff: Schema was extended without increasing the number passed to db.version(). Some queries may fail.")),uj(e,i)}catch(e){}lq.push(e),n.onversionchange=lx(t=>{r.vcFired=!0,e.on("versionchange").fire(t)}),n.onclose=lx(t=>{e.on("close").fire(t)}),l&&function({indexedDB:e,IDBKeyRange:t},r){uV(e)||r===lJ||uB(e,t).put({name:r}).catch(sW)}(e._deps,a),t()},o)}))]).then(()=>(i(),r.onReadyBeingFired=[],lu.resolve(uU(()=>e.on.ready.fire(e.vip))).then(function t(){if(r.onReadyBeingFired.length>0){let n=r.onReadyBeingFired.reduce(sJ,sW);return r.onReadyBeingFired=[],lu.resolve(uU(()=>n(e.vip))).then(t)}}))).finally(()=>{r.onReadyBeingFired=null,r.isBeingOpened=!1}).then(()=>e).catch(t=>{r.dbOpenError=t;try{s&&s.abort()}catch(e){}return o===r.openCanceller&&e._close(),lU(t)}).finally(()=>{r.openComplete=!0,a()})}(this)}_close(){let e=this._state,t=lq.indexOf(this);if(t>=0&&lq.splice(t,1),this.idbdb){try{this.idbdb.close()}catch(e){}this._novip.idbdb=null}e.dbReadyPromise=new lu(t=>{e.dbReadyResolve=t}),e.openCanceller=new lu((t,r)=>{e.cancelOpen=r})}close(){this._close();let e=this._state;this._options.autoOpen=!1,e.dbOpenError=new sB.DatabaseClosed,e.isBeingOpened&&e.cancelOpen(e.dbOpenError)}delete(){let e=arguments.length>0,t=this._state;return new lu((r,n)=>{let o=()=>{this.close();var e=this._deps.indexedDB.deleteDatabase(this.name);e.onsuccess=lx(()=>{!function({indexedDB:e,IDBKeyRange:t},r){uV(e)||r===lJ||uB(e,t).delete(r).catch(sW)}(this._deps,this.name),r()}),e.onerror=ug(n),e.onblocked=this._fireOnBlocked};if(e)throw new sB.InvalidArgument("Arguments not allowed in db.delete()");t.isBeingOpened?t.dbReadyPromise.then(o):o()})}backendDB(){return this.idbdb}isOpen(){return null!==this.idbdb}hasBeenClosed(){let e=this._state.dbOpenError;return e&&"DatabaseClosed"===e.name}hasFailed(){return null!==this._state.dbOpenError}dynamicallyOpened(){return this._state.autoSchema}get tables(){return a3(this._allTables).map(e=>this._allTables[e])}transaction(){let e=uK.apply(this,arguments);return this._transaction.apply(this,e)}_transaction(e,t,r){let n,o,i=li.trans;i&&i.db===this&&-1===e.indexOf("!")||(i=null);let a=-1!==e.indexOf("?");e=e.replace("!","").replace("?","");try{if(o=t.map(e=>{var t=e instanceof this.Table?e.name:e;if("string"!=typeof t)throw TypeError("Invalid table argument to Dexie.transaction(). Only Table or String are allowed");return t}),"r"==e||e===lX)n=lX;else{if("rw"!=e&&e!=lQ)throw new sB.InvalidArgument("Invalid transaction mode: "+e);n=lQ}if(i){if(i.mode===lX&&n===lQ){if(!a)throw new sB.SubTransaction("Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY");i=null}i&&o.forEach(e=>{if(i&&-1===i.storeNames.indexOf(e)){if(!a)throw new sB.SubTransaction("Table "+e+" not included in parent transaction.");i=null}}),a&&i&&!i.active&&(i=null)}}catch(e){return i?i._promise(null,(t,r)=>{r(e)}):lU(e)}let s=(function e(t,r,n,o,i){return lu.resolve().then(()=>{let a,s=li.transless||li,l=t._createTransaction(r,n,t._dbSchema,o);if(o)l.idbtrans=o.idbtrans;else try{l.create(),t._state.PR1398_maxLoop=3}catch(o){return o.name===sF.InvalidState&&t.isOpen()&&--t._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),t._close(),t.open().then(()=>e(t,r,n,null,i))):lU(o)}let u=sO(i);u&&lj();let c=lu.follow(()=>{if(a=i.call(l,l))if(u){var e=lT.bind(null,null);a.then(e,e)}else"function"==typeof a.next&&"function"==typeof a.throw&&(a=uW(a))},{trans:l,transless:s});return(a&&"function"==typeof a.then?lu.resolve(a).then(e=>l.active?e:lU(new sB.PrematureCommit("Transaction committed too early. See http://bit.ly/2kdckMn"))):c.then(()=>a)).then(e=>(o&&l._resolve(),l._completion.then(()=>e))).catch(e=>(l._reject(e),lU(e)))})}).bind(null,this,n,o,i,r);return i?i._promise(n,s,"lock"):li.trans?lM(li.transless,()=>this._whenReady(s)):this._whenReady(s)}table(e){if(!a9(this._allTables,e))throw new sB.InvalidTable(`Table ${e} does not exist`);return this._allTables[e]}}let u5="u">typeof Symbol&&"observable"in Symbol?Symbol.observable:"@@observable";class u8{constructor(e){this._subscribe=e}subscribe(e,t,r){return this._subscribe(e&&"function"!=typeof e?e:{next:e,error:t,complete:r})}[u5](){return this}}function u9(e,t){return a3(t).forEach(r=>{u0(e[r]||(e[r]=new uX),t[r])}),e}try{i={indexedDB:a4.indexedDB||a4.mozIndexedDB||a4.webkitIndexedDB||a4.msIndexedDB,IDBKeyRange:a4.IDBKeyRange||a4.webkitIDBKeyRange}}catch(e){i={indexedDB:null,IDBKeyRange:null}}function u7(e){let t=ce;try{ce=!0,uw.storagemutated.fire(e)}finally{ce=t}}a7(u6,{...sU,delete:e=>new u6(e,{addons:[]}).delete(),exists:e=>new u6(e,{addons:[]}).open().then(e=>(e.close(),!0)).catch("NoSuchDatabaseError",()=>!1),getDatabaseNames(e){try{return(function({indexedDB:e,IDBKeyRange:t}){return uV(e)?Promise.resolve(e.databases()).then(e=>e.map(e=>e.name).filter(e=>e!==lJ)):uB(e,t).toCollection().primaryKeys()})(u6.dependencies).then(e)}catch(e){return lU(new sB.MissingAPI)}},defineClass:()=>function(e){a6(this,e)},ignoreTransaction:e=>li.trans?lM(li.transless,e):e(),vip:uU,async:function(e){return function(){try{var t=uW(e.apply(this,arguments));return t&&"function"==typeof t.then?t:lu.resolve(t)}catch(e){return lU(e)}}},spawn:function(e,t,r){try{var n=uW(e.apply(r,t||[]));return n&&"function"==typeof n.then?n:lu.resolve(n)}catch(e){return lU(e)}},currentTransaction:{get:()=>li.trans||null},waitFor:function(e,t){let r=lu.resolve("function"==typeof e?u6.ignoreTransaction(e):e).timeout(t||6e4);return li.trans?li.trans.waitFor(r):r},Promise:lu,debug:{get:()=>sk,set:e=>{sk=e,sP="dexie"===e?()=>!0:lZ}},derive:sr,extend:a6,props:a7,override:ss,Events:l2,on:uw,liveQuery:function(e){let t,r=!1,n=new u8(n=>{let o=sO(e),i=!1,a={},s={},l={get closed(){return i},unsubscribe:()=>{i=!0,uw.storagemutated.unsubscribe(p)}};n.start&&n.start(l);let u=!1,c=!1;function d(){return a3(s).some(e=>a[e]&&function(e,t){let r=u1(t),n=r.next();if(n.done)return!1;let o=n.value,i=u1(e),a=i.next(o.from),s=a.value;for(;!n.done&&!a.done;){if(0>=un(s.from,o.to)&&un(s.to,o.from)>=0)return!0;0>un(o.from,s.from)?o=(n=r.next(s.from)).value:s=(a=i.next(o.from)).value}return!1}(a[e],s[e]))}let p=e=>{u9(a,e),d()&&f()},f=()=>{let h,m;if(u||i)return;a={};let g={},y=(o&&lj(),h=()=>lC(e,{subscr:g,trans:null}),m=li.trans?lM(li.transless,h):h(),o&&m.then(lT,lT),m);c||(uw(uv,p),c=!0),u=!0,Promise.resolve(y).then(e=>{r=!0,t=e,u=!1,i||(d()?f():(a={},s=g,n.next&&n.next(e)))},e=>{u=!1,r=!1,n.error&&n.error(e),l.unsubscribe()})};return f(),l});return n.hasValue=()=>r,n.getValue=()=>t,n},extendObservabilitySet:u9,getByKeyPath:sd,setByKeyPath:sp,delByKeyPath:function(e,t){"string"==typeof t?sp(e,t,void 0):"length"in t&&[].map.call(t,function(t){sp(e,t,void 0)})},shallowClone:sf,deepClone:sb,getObjectDiff:uG,cmp:un,asap:su,minKey:lz,addons:[],connections:lq,errnames:sF,dependencies:i,semVer:lW,version:lW.split(".").map(e=>parseInt(e)).reduce((e,t,r)=>e+t/Math.pow(10,2*r))}),u6.maxKey=uD(u6.dependencies.IDBKeyRange),"u">typeof dispatchEvent&&"u">typeof addEventListener&&(uw(uv,e=>{if(!ce){let t;lY?(t=document.createEvent("CustomEvent")).initCustomEvent(ub,!0,!0,e):t=new CustomEvent(ub,{detail:e}),ce=!0,dispatchEvent(t),ce=!1}}),addEventListener(ub,({detail:e})=>{ce||u7(e)}));let ce=!1;if("u">typeof BroadcastChannel){let e=new BroadcastChannel(ub);"function"==typeof e.unref&&e.unref(),uw(uv,t=>{ce||e.postMessage(t)}),e.onmessage=e=>{e.data&&u7(e.data)}}else if("u">typeof self&&"u">typeof navigator){uw(uv,e=>{try{ce||("u">typeof localStorage&&localStorage.setItem(ub,JSON.stringify({trig:Math.random(),changedParts:e})),"object"==typeof self.clients&&[...self.clients.matchAll({includeUncontrolled:!0})].forEach(t=>t.postMessage({type:ub,changedParts:e})))}catch(e){}}),"u">typeof addEventListener&&addEventListener("storage",e=>{if(e.key===ub){let t=JSON.parse(e.newValue);t&&u7(t.changedParts)}});let e=self.document&&navigator.serviceWorker;e&&e.addEventListener("message",function({data:e}){e&&e.type===ub&&u7(e.changedParts)})}function ct(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}lu.rejectionMapper=function(e,t){if(!e||e instanceof s$||e instanceof TypeError||e instanceof SyntaxError||!e.name||!sV[e.name])return e;var r=new sV[e.name](t||e.message,e);return"stack"in e&&st(r,"stack",{get:function(){return this.inner.stack}}),r},sP=lZ;class cr extends u6{constructor(){super("EsmOffline"),ct(this,"syncQueue",void 0),ct(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 cn(){return new cr}let co=new cr,ci={},ca=q("offline-synchronization",{});function cs(){return ca}async function cl(){if(ca.getState().synchronization)return;let e=await co.syncQueue.count(),t={},r=Object.entries(ci),n=r.length,o={},i=new AbortController,a=()=>{let e=ca.getState().synchronization;ca.setState({synchronization:{...e,pendingCount:e.pendingCount-1}})};try{ca.setState({synchronization:{totalCount:e,pendingCount:e,abortController:i}});for(let e=0;e<n&&r.length>0;e++)for(let e=r.length;e--;){let[n,s]=r[e],l=s.dependsOn.map(e=>t[e]);l.every(Boolean)&&(o[n]={},await Promise.all(l),t[n]=cu(s,o,i,a),r.splice(e,1))}await Promise.allSettled(Object.values(t))}finally{ca.setState({synchronization:void 0})}}async function cu({type:e,dependsOn:t,process:r},n,o,i){let a=[],s=[],l=await cc();await co.syncQueue.where({type:e,userId:l}).each((e,t)=>{a.push([t.primaryKey,e.content,e.descriptor]),s.push(e.content)});for(let u=0;u<a.length;u++){let[c,d,{id:p,dependencies:f=[]}]=a[u];try{let i=await r(d,{abort:o,index:u,items:s,userId:l,dependencies:f.map(({id:e,type:r})=>t.includes(r)?n[r][e]:void 0)});void 0!==p&&(n[e][p]=i),await co.syncQueue.delete(c)}catch(e){await co.syncQueue.update(c,{lastError:{name:e?.name,message:e?.message??e?.toString()}})}finally{i()}}}async function cc(){let e=await oZ();return e?.uuid||"*"}async function cd(e,t,r,n){let o=n&&n.id;return void 0!==o&&await co.syncQueue.where({type:t,userId:e}).filter(e=>e?.descriptor.id===o).delete().catch(u6.errnames.DatabaseClosed),await co.syncQueue.add({type:t,content:r,userId:e,descriptor:n||{},createdOn:new Date}).catch(u6.errnames.DatabaseClosed,()=>-1)}async function cp(e,t,r){let n=await cc();return await cd(n,e,t,r)}async function cf(e,t){return(await ch(e,t)).map(e=>e.content)}async function ch(e,t){return await co.syncQueue.where(t?{type:t,userId:e}:{userId:e}).toArray().catch(u6.errnames.DatabaseClosed,()=>[])}async function cm(e){let t=await cc();return await cf(t,e)}async function cg(e){let t=await cc();return await ch(t,e)}async function cy(e){return await co.syncQueue.get(e).catch(u6.errnames.DatabaseClosed,()=>void 0)}function cv(e){return!!ci[e]?.options.onBeginEditSyncItem}async function cb(e){let t=await cy(e);if(!t)throw Error(`No sync item with the ID ${e} exists.`);let r=ci[t.type]?.options.onBeginEditSyncItem;if(!r)throw Error(`A sync item with the ID ${e} exists, but the associated handler (if one exists) doesn't support editing the item. You can avoid this error by either verifying that sync items of this type can be edited via the "canEditSynchronizationItemsOfType(type: string)" function or alternatively ensure that the synchronizaton handler for sync items of type "${t.type}" supports editing items.`);r(t)}async function cw(e){await co.syncQueue.delete(e).catch(u6.errnames.DatabaseClosed)}function c_(e,t,r,n={}){ci[e]={type:e,dependsOn:t,process:r,options:n}}let cx="u">typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),cE=new Uint8Array(16),cS=[];for(let e=0;e<256;++e)cS.push((e+256).toString(16).slice(1));let cD=function(e,t,r){if(cx&&!t&&!e)return cx();let n=(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(cE)})();if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,t){r=r||0;for(let e=0;e<16;++e)t[r+e]=n[e];return t}return function(e,t=0){return cS[e[t+0]]+cS[e[t+1]]+cS[e[t+2]]+cS[e[t+3]]+"-"+cS[e[t+4]]+cS[e[t+5]]+"-"+cS[e[t+6]]+cS[e[t+7]]+"-"+cS[e[t+8]]+cS[e[t+9]]+"-"+cS[e[t+10]]+cS[e[t+11]]+cS[e[t+12]]+cS[e[t+13]]+cS[e[t+14]]+cS[e[t+15]]}(n)},cO="OFFLINE+";function ck(){return cO+cD()}function cP(e){return e.startsWith(cO)}let cC={};function cj(){return Object.values(cC)}function cT(e){cC[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.`),cC[e.id]=e}async function cR(e){let t=await cB();return await cA(t,e)}async function cA(e,t){let r=new cr;return await r.dynamicOfflineData.where(t?{type:t,users:e}:{users:e}).toArray().catch(u6.errnames.DatabaseClosed,()=>[])}async function cN(e,t){let r=await cB();return await c$(r,e,t)}async function c$(e,t,r){let n=new cr,o=await n.dynamicOfflineData.get({type:t,identifier:r}).catch(u6.errnames.DatabaseClosed,()=>void 0);o?o.users.includes(e)||await n.dynamicOfflineData.update(o.id,{users:[...o.users,e]}).catch(u6.errnames.DatabaseClosed):await n.dynamicOfflineData.add({users:[e],type:t,identifier:r}).catch(u6.errnames.DatabaseClosed)}async function cI(e,t){let r=await cB();return await cM(r,e,t)}async function cM(e,t,r){let n=new cr,o=await n.dynamicOfflineData.get({type:t,identifier:r,users:e}).catch(u6.errnames.DatabaseClosed,()=>void 0);o&&(o.users.length>1?await n.dynamicOfflineData.update(o.id,{users:o.users.filter(t=>t!==e)}).catch(u6.errnames.DatabaseClosed):await n.dynamicOfflineData.delete(o.id).catch(u6.errnames.DatabaseClosed))}async function cL(e,t){let r=await cR(e);await Promise.all(r.map(async e=>cF(e.type,e.identifier,t)))}async function cF(e,t,r){await cN(e,t);let n=new cr,o=await cB(),i=await n.dynamicOfflineData.get({type:e,identifier:t}).catch(u6.errnames.DatabaseClosed,()=>void 0),a=cj().filter(t=>t.type===e);if(!i)return;let s=await Promise.all(a.map(async e=>{try{return e.sync(t,r),{id:e.id,error:void 0}}catch(r){let t=r.message?.toString()??r.toString();return{id:e.id,error:t}}})),l=s.filter(e=>!e.error).map(e=>e.id),u=s.filter(e=>e.error).map(e=>e.id),c=s.filter(e=>e.error).map(e=>({handlerId:e.id,message:e.error})),d={syncedOn:new Date,syncedBy:o,succeededHandlers:l,erroredHandlers:u,errors:c};i.id&&await n.dynamicOfflineData.update(i.id,{syncState:d}).catch(u6.errnames.DatabaseClosed)}async function cB(){let e=(await oZ()).uuid;if(!e)throw Error("Using the dynamic offline data API requires a logged in user.");return e}let cV=q("offline-patients",{offlinePatientDataSyncState:{},handlers:{}});function cU(){return cz(),cV}function cW(e,t){cz(),cT({type:"patient",displayName:t.displayName,id:e,isSynced:()=>Promise.resolve(!0),sync:(e,r)=>t.onOfflinePatientAdded({patientUuid:e,signal:r??new AbortController().signal})})}async function cK(e){cz(),await cF("patient",e)}function cz(){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 cH(e,t,r=!0){if(e){let n=null,[o,i]=await Promise.all([oF(`${oI}/Patient/${e}`,t).catch(e=>n=e),r?cG(e):Promise.resolve(null)]);if(o.ok)return o.data;if(i)return i;if(n)throw n}return null}async function cG(e){let t=(await cm("patient-registration")).find(t=>t.fhirPatient.id===e);return t?.fhirPatient??null}function cq(e,t){let r=new CustomEvent(`openmrs:${e}`,{detail:t??void 0,cancelable:!0,bubbles:!0});return window.dispatchEvent(r)}function cY(e,t){let r=e=>{t("detail"in e&&null!==e.detail?e.detail:void 0)};return window.addEventListener(`openmrs:${e}`,r),()=>{window.removeEventListener(`openmrs:${e}`,r)}}var cZ=r(6170);function cJ(e){return{uuid:e.uuid,display:e.display}}function cX(e=null,t=null){let r=new URLSearchParams;e&&r.set("tag",e),t&&r.set("q",t);let n=r.toString();return oB(`${o$}/location${n?"?"+n:""}`).pipe((0,cZ.map)(e=>e.data.results.map(cJ))).pipe((0,cZ.take)(1))}function cQ(e){return{uuid:e.uuid,display:e.display,name:e.name}}function c0(){return oB(`${o$}/visittype`).pipe((0,cZ.map)(e=>e.data.results.map(cQ))).pipe((0,cZ.take)(1))}var c1=((eo={}).NEWVISIT="startVisit",eo.EDITVISIT="editVisit",eo.LOADING="loadingVisit",eo),c4=((ei={}).NOTSTARTED="notStarted",ei.ONGOING="ongoing",ei);let c3="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))",c2=function(){try{return JSON.parse(sessionStorage.getItem("openmrs:visitStoreState")||"null")}catch(e){return null}}()||{patientUuid:null,manuallySetVisitUuid:null};function c6(){return Z("visit",c2)}function c5(e,t){c6().setState({patientUuid:e,manuallySetVisitUuid:t})}function c8(e,t){return oF(`${o$}/visit`,{signal:t.signal,method:"POST",headers:{"Content-type":"application/json"},body:e})}function c9(e,t,r){return oF(`${o$}/visit/${e}`,{signal:r.signal,method:"POST",headers:{"Content-type":"application/json"},body:t})}function c7(e,t,r){return oF(`${o$}/visit?patient=${e}&v=${r??c3}`,{signal:t.signal,method:"GET",headers:{"Content-type":"application/json"}})}c6().subscribe(e=>{var t;t=e,sessionStorage.setItem("openmrs:visitStoreState",JSON.stringify(t))});let de=new el.BehaviorSubject(null);class dt{static get version(){return"1.4.0"}static toString(){return"JavaScript Expression Parser (JSEP) v"+dt.version}static addUnaryOp(e){return dt.max_unop_len=Math.max(e.length,dt.max_unop_len),dt.unary_ops[e]=1,dt}static addBinaryOp(e,t,r){return dt.max_binop_len=Math.max(e.length,dt.max_binop_len),dt.binary_ops[e]=t,r?dt.right_associative.add(e):dt.right_associative.delete(e),dt}static addIdentifierChar(e){return dt.additional_identifier_chars.add(e),dt}static addLiteral(e,t){return dt.literals[e]=t,dt}static removeUnaryOp(e){return delete dt.unary_ops[e],e.length===dt.max_unop_len&&(dt.max_unop_len=dt.getMaxKeyLen(dt.unary_ops)),dt}static removeAllUnaryOps(){return dt.unary_ops={},dt.max_unop_len=0,dt}static removeIdentifierChar(e){return dt.additional_identifier_chars.delete(e),dt}static removeBinaryOp(e){return delete dt.binary_ops[e],e.length===dt.max_binop_len&&(dt.max_binop_len=dt.getMaxKeyLen(dt.binary_ops)),dt.right_associative.delete(e),dt}static removeAllBinaryOps(){return dt.binary_ops={},dt.max_binop_len=0,dt}static removeLiteral(e){return delete dt.literals[e],dt}static removeAllLiterals(){return dt.literals={},dt}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 dt(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 dt.binary_ops[e]||0}static isIdentifierStart(e){return e>=65&&e<=90||e>=97&&e<=122||e>=128&&!dt.binary_ops[String.fromCharCode(e)]||dt.additional_identifier_chars.has(String.fromCharCode(e))}static isIdentifierPart(e){return dt.isIdentifierStart(e)||dt.isDecimalDigit(e)}throwError(e){let t=Error(e+" at character "+this.index);throw t.index=this.index,t.description=e,t}runHook(e,t){if(dt.hooks[e]){let r={context:this,node:t};return dt.hooks.run(e,r),r.node}return t}searchHook(e){if(dt.hooks[e]){let t={context:this};return dt.hooks[e].find(function(e){return e.call(t.context,t),t.node}),t.node}}gobbleSpaces(){let e=this.code;for(;e===dt.SPACE_CODE||e===dt.TAB_CODE||e===dt.LF_CODE||e===dt.CR_CODE;)e=this.expr.charCodeAt(++this.index);this.runHook("gobble-spaces")}parse(){this.runHook("before-all");let e=this.gobbleExpressions(),t=1===e.length?e[0]:{type:dt.COMPOUND,body:e};return this.runHook("after-all",t)}gobbleExpressions(e){let t=[],r,n;for(;this.index<this.expr.length;)if((r=this.code)===dt.SEMCOL_CODE||r===dt.COMMA_CODE)this.index++;else if(n=this.gobbleExpression())t.push(n);else if(this.index<this.expr.length){if(r===e)break;this.throwError('Unexpected "'+this.char+'"')}return t}gobbleExpression(){let e=this.searchHook("gobble-expression")||this.gobbleBinaryExpression();return this.gobbleSpaces(),this.runHook("after-expression",e)}gobbleBinaryOp(){this.gobbleSpaces();let e=this.expr.substr(this.index,dt.max_binop_len),t=e.length;for(;t>0;){if(dt.binary_ops.hasOwnProperty(e)&&(!dt.isIdentifierStart(this.code)||this.index+e.length<this.expr.length&&!dt.isIdentifierPart(this.expr.charCodeAt(this.index+e.length))))return this.index+=t,e;e=e.substr(0,--t)}return!1}gobbleBinaryExpression(){let e,t,r,n,o,i,a,s,l;if(!(i=this.gobbleToken())||!(t=this.gobbleBinaryOp()))return i;for(o={value:t,prec:dt.binaryPrecedence(t),right_a:dt.right_associative.has(t)},(a=this.gobbleToken())||this.throwError("Expected expression after "+t),n=[i,o,a];t=this.gobbleBinaryOp();){if(0===(r=dt.binaryPrecedence(t))){this.index-=t.length;break}o={value:t,prec:r,right_a:dt.right_associative.has(t)},l=t;let s=e=>o.right_a&&e.right_a?r>e.prec:r<=e.prec;for(;n.length>2&&s(n[n.length-2]);)a=n.pop(),t=n.pop().value,i=n.pop(),e={type:dt.BINARY_EXP,operator:t,left:i,right:a},n.push(e);(e=this.gobbleToken())||this.throwError("Expected expression after "+l),n.push(o,e)}for(s=n.length-1,e=n[s];s>1;)e={type:dt.BINARY_EXP,operator:n[s-1].value,left:n[s-2],right:e},s-=2;return e}gobbleToken(){let e,t,r,n;if(this.gobbleSpaces(),n=this.searchHook("gobble-token"))return this.runHook("after-token",n);if(e=this.code,dt.isDecimalDigit(e)||e===dt.PERIOD_CODE)return this.gobbleNumericLiteral();if(e===dt.SQUOTE_CODE||e===dt.DQUOTE_CODE)n=this.gobbleStringLiteral();else if(e===dt.OBRACK_CODE)n=this.gobbleArray();else{for(r=(t=this.expr.substr(this.index,dt.max_unop_len)).length;r>0;){if(dt.unary_ops.hasOwnProperty(t)&&(!dt.isIdentifierStart(this.code)||this.index+t.length<this.expr.length&&!dt.isIdentifierPart(this.expr.charCodeAt(this.index+t.length)))){this.index+=r;let e=this.gobbleToken();return e||this.throwError("missing unaryOp argument"),this.runHook("after-token",{type:dt.UNARY_EXP,operator:t,argument:e,prefix:!0})}t=t.substr(0,--r)}dt.isIdentifierStart(e)?(n=this.gobbleIdentifier(),dt.literals.hasOwnProperty(n.name)?n={type:dt.LITERAL,value:dt.literals[n.name],raw:n.name}:n.name===dt.this_str&&(n={type:dt.THIS_EXP})):e===dt.OPAREN_CODE&&(n=this.gobbleGroup())}return n?(n=this.gobbleTokenProperty(n),this.runHook("after-token",n)):this.runHook("after-token",!1)}gobbleTokenProperty(e){this.gobbleSpaces();let t=this.code;for(;t===dt.PERIOD_CODE||t===dt.OBRACK_CODE||t===dt.OPAREN_CODE||t===dt.QUMARK_CODE;){let r;if(t===dt.QUMARK_CODE){if(this.expr.charCodeAt(this.index+1)!==dt.PERIOD_CODE)break;r=!0,this.index+=2,this.gobbleSpaces(),t=this.code}this.index++,t===dt.OBRACK_CODE?((e={type:dt.MEMBER_EXP,computed:!0,object:e,property:this.gobbleExpression()}).property||this.throwError('Unexpected "'+this.char+'"'),this.gobbleSpaces(),(t=this.code)!==dt.CBRACK_CODE&&this.throwError("Unclosed ["),this.index++):t===dt.OPAREN_CODE?e={type:dt.CALL_EXP,arguments:this.gobbleArguments(dt.CPAREN_CODE),callee:e}:(t===dt.PERIOD_CODE||r)&&(r&&this.index--,this.gobbleSpaces(),e={type:dt.MEMBER_EXP,computed:!1,object:e,property:this.gobbleIdentifier()}),r&&(e.optional=!0),this.gobbleSpaces(),t=this.code}return e}gobbleNumericLiteral(){let e="",t,r;for(;dt.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);if(this.code===dt.PERIOD_CODE)for(e+=this.expr.charAt(this.index++);dt.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);if("e"===(t=this.char)||"E"===t){for(e+=this.expr.charAt(this.index++),("+"===(t=this.char)||"-"===t)&&(e+=this.expr.charAt(this.index++));dt.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);dt.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+e+this.char+")")}return r=this.code,dt.isIdentifierStart(r)?this.throwError("Variable names cannot start with a number ("+e+this.char+")"):(r===dt.PERIOD_CODE||1===e.length&&e.charCodeAt(0)===dt.PERIOD_CODE)&&this.throwError("Unexpected period"),{type:dt.LITERAL,value:parseFloat(e),raw:e}}gobbleStringLiteral(){let e="",t=this.index,r=this.expr.charAt(this.index++),n=!1;for(;this.index<this.expr.length;){let t=this.expr.charAt(this.index++);if(t===r){n=!0;break}if("\\"===t)switch(t=this.expr.charAt(this.index++)){case"n":e+="\n";break;case"r":e+="\r";break;case"t":e+=" ";break;case"b":e+="\b";break;case"f":e+="\f";break;case"v":e+="\v";break;default:e+=t}else e+=t}return n||this.throwError('Unclosed quote after "'+e+'"'),{type:dt.LITERAL,value:e,raw:this.expr.substring(t,this.index)}}gobbleIdentifier(){let e=this.code,t=this.index;for(dt.isIdentifierStart(e)?this.index++:this.throwError("Unexpected "+this.char);this.index<this.expr.length;)if(e=this.code,dt.isIdentifierPart(e))this.index++;else break;return{type:dt.IDENTIFIER,name:this.expr.slice(t,this.index)}}gobbleArguments(e){let t=[],r=!1,n=0;for(;this.index<this.expr.length;){this.gobbleSpaces();let o=this.code;if(o===e){r=!0,this.index++,e===dt.CPAREN_CODE&&n&&n>=t.length&&this.throwError("Unexpected token "+String.fromCharCode(e));break}if(o===dt.COMMA_CODE){if(this.index++,++n!==t.length){if(e===dt.CPAREN_CODE)this.throwError("Unexpected token ,");else if(e===dt.CBRACK_CODE)for(let e=t.length;e<n;e++)t.push(null)}}else if(t.length!==n&&0!==n)this.throwError("Expected comma");else{let e=this.gobbleExpression();e&&e.type!==dt.COMPOUND||this.throwError("Expected comma"),t.push(e)}}return r||this.throwError("Expected "+String.fromCharCode(e)),t}gobbleGroup(){this.index++;let e=this.gobbleExpressions(dt.CPAREN_CODE);if(this.code===dt.CPAREN_CODE)return(this.index++,1===e.length)?e[0]:!!e.length&&{type:dt.SEQUENCE_EXP,expressions:e};this.throwError("Unclosed (")}gobbleArray(){return this.index++,{type:dt.ARRAY_EXP,elements:this.gobbleArguments(dt.CBRACK_CODE)}}}Object.assign(dt,{hooks:new class{add(e,t,r){if("string"!=typeof arguments[0])for(let e in arguments[0])this.add(e,arguments[0][e],arguments[1]);else(Array.isArray(e)?e:[e]).forEach(function(e){this[e]=this[e]||[],t&&this[e][r?"unshift":"push"](t)},this)}run(e,t){this[e]=this[e]||[],this[e].forEach(function(e){e.call(t&&t.context?t.context:t,t)})}},plugins:new class{constructor(e){this.jsep=e,this.registered={}}register(...e){e.forEach(e=>{if("object"!=typeof e||!e.name||!e.init)throw Error("Invalid JSEP plugin format");this.registered[e.name]||(e.init(this.jsep),this.registered[e.name]=e)})}}(dt),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"}),dt.max_unop_len=dt.getMaxKeyLen(dt.unary_ops),dt.max_binop_len=dt.getMaxKeyLen(dt.binary_ops);let dr=e=>new dt(e).parse(),dn=Object.getOwnPropertyNames(class{});Object.getOwnPropertyNames(dt).filter(e=>!dn.includes(e)&&void 0===dr[e]).forEach(e=>{dr[e]=dt[e]}),dr.Jsep=dt,dr.plugins.register({name:"ternary",init(e){e.hooks.add("after-expression",function(t){if(t.node&&this.code===e.QUMARK_CODE){this.index++;let r=t.node,n=this.gobbleExpression();if(n||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===e.COLON_CODE){this.index++;let o=this.gobbleExpression();if(o||this.throwError("Expected expression"),t.node={type:"ConditionalExpression",test:r,consequent:n,alternate:o},r.operator&&e.binary_ops[r.operator]<=.9){let n=r;for(;n.right.operator&&e.binary_ops[n.right.operator]<=.9;)n=n.right;t.node.test=n.right,n.right=t.node,t.node=r}}else this.throwError("Expected :")}})}});let di="ArrowFunctionExpression",da={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)}},ds={...da,Promise};function dl(e,t={}){return dh(e,t,dy)}async function du(e,t={}){return dm(e,t,dy)}function dc(e,t={}){return dh(e,t,dv)}function dd(e,t={}){return dm(e,t,dv)}function dp(e,t={}){return dh(e,t,db)}function df(e,t={}){return dm(e,t,db)}function dh(e,t={},r){if("string"!=typeof e&&("object"!=typeof e||!e||!("type"in e)))throw`Unknown expression type ${e}. Expressions must either be a string or pre-compiled string.`;if("string"==typeof e&&0===e.trim().length)throw{type:"Empty expression",message:"Expression cannot be an empty string"};null==t&&(t={});let n=dx(t,da),o=dw("string"==typeof e?dr(e):e,n);if(r(o))return o;throw{type:"Invalid result",message:"string"==typeof e?`The expression ${e} did not produce a valid result`:"The expression did not produce a valid result"}}async function dm(e,t={},r){if("string"!=typeof e&&("object"!=typeof e||!e||!("type"in e)))return Promise.reject(`Unknown expression type ${e}. Expressions must either be a string or pre-compiled string.`);if("string"==typeof e&&0===e.trim().length)throw{type:"Empty expression",message:"Expression cannot be an empty string"};null==t&&(t={});let n=dx(t,ds);return Promise.resolve(dw("string"==typeof e?dr(e):e,n)).then(t=>{if(r(t))return t;throw{type:"Invalid result",message:"string"==typeof e?`The expression ${e} did not produce a valid result`:"The expression did not produce a valid result"}})}function dg(e){return dr(e)}function dy(e){return"string"==typeof e||"number"==typeof e||"boolean"==typeof e||null==e||e instanceof Date}function dv(e){return"boolean"==typeof e}function db(e){return"number"==typeof e}function dw(e,t){switch(e.type){case"UnaryExpression":var r,n,o,i,a,s,l,u,c,d,p,f,h=e,m=t;let g=dw(h.argument,m);switch(h.operator){case"+":return+g;case"-":return-g;case"~":return~g;case"!":return!g;default:throw`Expression evaluator does not support operator '${h.operator}''`}case"BinaryExpression":var y=e,v=t;let b=dw(y.left,v),w=dw(y.right,v);switch(y.operator){case"+":return b+w;case"-":return b-w;case"*":return b*w;case"/":return b/w;case"%":return b%w;case"**":return b**w;case"==":return b==w;case"===":return b===w;case"!=":return b!=w;case"!==":return b!==w;case">":return b>w;case">=":return b>=w;case"<":return b<w;case"<=":return b<=w;case"in":return b in w;case"&&":return b&&w;case"||":return b||w;case"??":return b??w;default:throw`Expression evaluator does not support operator '${y.operator}' operator`}case"ConditionalExpression":return r=e,n=t,dw(r.test,n)?dw(r.consequent,n):dw(r.alternate,n);case"CallExpression":var x=e,E=t;let S=x.arguments?.map(dE(E)),D=dw(x.callee,E);if(D){if("function"!=typeof D)throw`${dD(x.callee)} is not a function`}else throw`No function named ${dD(x.callee)} is defined in this context`;return D(...S);case"ArrowFunctionExpression":let O;return o=e,i=t,O=o.params?.map(e=>{if("Identifier"===e.type)return e.name;throw`Cannot handle parameter of type ${e.type}`})??[],(function(...e){if(e.length<O.length)throw`Required argument(s) ${O.slice(e.length,-1).join(", ")} were not provided`;let t=Object.fromEntries(O.reduce((t,r,n)=>{let o=e[n];return function e(t){if("string"==typeof t||"number"==typeof t||"boolean"==typeof t||"function"==typeof t||null===t||t instanceof RegExp)return!0;if("object"==typeof t){for(let r of Object.keys(t))if(!e(t[r]))return!1;return!0}if(Array.isArray(t)){for(let r of t)if(!e(r))break}return!1}(o)&&t.push([r,o]),t},[]));return dw(o.body,i.addVariables(t))}).bind(i.thisObj??null);case"MemberExpression":return function(e,t){let r,n=dw(e.object,t);if(void 0===n)switch(e.object.type){case"Identifier":{let r=d_(e.object,t);throw ReferenceError(`ReferenceError: ${r} is not defined`)}case"MemberExpression":{let r=d_(e.property,t);throw TypeError(`TypeError: cannot read properties of undefined (reading '${r}')`)}default:throw`VisitMemberExpression does not support operator '${e.object.type}' type`}let o=n;if("string"==typeof n)o=String.prototype;else if("number"==typeof n)o=Number.prototype;else if("function"==typeof n);else if("object"!=typeof n)throw`VisitMemberExpression does not support member access on type ${typeof n}`;switch(t.thisObj=o,e.property.type){case"Identifier":case"MemberExpression":r=dw(e.property,t);break;default:{let o=dw(e.property,t);if(void 0===o)throw{type:"Illegal property access",message:"No property was supplied to the property access"};dS(o),r=n[o]}}return"function"==typeof r?r.bind(n):r}(e,t);case"ArrayExpression":return a=e,s=t,a.elements?.map(dE(s));case"SequenceExpression":let k;return l=e,u=t,(k=l.expressions.map(dE(u)))[k.length-1];case"NewExpression":var P=e,C=t;if(P.callee&&"Identifier"===P.callee.type){let e=P.arguments?.map(dE(C));switch(P.callee.name){case"Date":return new Date(...e);case"RegExp":return new RegExp(...e);default:throw`Cannot instantiate object of type ${P.callee.name}`}}if(P.callee)throw"new must be called with either Date or RegExp";throw'Could not handle "new" without a specified class';case"Literal":return dS((c=e).value),c.value;case"Identifier":var j=e,T=t;dS(j.name);let R=T.thisObj;if(R&&("object"==typeof R||"function"==typeof R)&&j.name in R){let e=R[j.name];return dS(e),e}if(T.variables&&j.name in T.variables){let e=T.variables[j.name];return dS(e),e}return j.name in T.globals?T.globals[j.name]:void 0;case"TemplateLiteral":let A,N;return d=e,p=t,A=d.expressions?.map(dE(p))??[],(N=d.quasis?.map(dE(p))??[]).filter(e=>!e.tail).map(e=>e.value).join("")+A.join("")+N.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 d_(e,t){switch(e.type){case"Literal":return e.value;case"Identifier":return e.name;case"MemberExpression":return d_(e.property,t);default:throw`VisitExpressionName does not support expression of type '${e.type}'`}}function dx(e,t){let r={thisObj:void 0,variables:{...e},globals:{...t},addVariables(e){return this.variables={...this.variables,...e},this}};return r.addVariables.bind(r),r}function dE(e){return function(t){return null===t?null:dw(t,e)}}function dS(e){if("__proto__"===e||"prototype"===e||"constructor"===e)throw{type:"Illegal property access",message:`Cannot access the ${e} property of objects`}}function dD(e){return e?"MemberExpression"===e.type?e.property?.name:e.name:null}function dO(e){if("string"!=typeof e&&("object"!=typeof e||!e||!("type"in e)))throw`Unknown expression type ${e}. Expressions must either be a string or pre-compiled string.`;let t={globals:{...ds},isLocalExpression:!1,variables:new Set};return dk("string"==typeof e?dr(e):e,t),[...t.variables]}function dk(e,t){switch(e.type){case"UnaryExpression":return n=e,o=t,dk(n.argument,o);case"BinaryExpression":return i=e,a=t,[dk(i.left,a),dk(i.right,a)].filter(Boolean);case"ConditionalExpression":return s=e,l=t,[dk(s.consequent,l),dk(s.test,l),dk(s.alternate,l)].filter(Boolean);case"CallExpression":let r;return u=e,c=t,r=dk(u.callee,c),u.arguments?.map(dP(c)),r;case"ArrowFunctionExpression":var n,o,i,a,s,l,u,c,d,p,f,h,m,g,y,v,b,w,x=e,E=t;let S={...E};S.isLocalExpression=!0;let D=x.params?.map(dP(S))??[],O=dk(x.body,S)??[];if(O&&Array.isArray(O))for(let e of O)D.includes(e)||E.variables.add(e);return;case"MemberExpression":let k;return d=e,p=t,dk(d.object,p),void((k={...p}).isLocalExpression=!0,dk(d.property,k));case"ArrayExpression":return f=e,h=t,void f.elements?.map(dP(h));case"SequenceExpression":return m=e,g=t,void m.expressions?.map(dP(g));case"NewExpression":return y=e,v=t,void y.arguments?.map(dP(v));case"Literal":case"TemplateElement":return;case"Identifier":var P=e,C=t;if(!(P.name in C.globals))if(C.isLocalExpression)return P.name;else C.variables.add(P.name);return;case"TemplateLiteral":return b=e,w=t,void(b.expressions?.map(dP(w)),b.quasis?.map(dP(w)));default:throw`Expression evaluator does not support expression of type '${e.type}'`}}function dP(e){return function(t){return null===t?null:dk(t,e)}}dr.plugins.register({name:"arrow",init(e){e.addBinaryOp("=>",.1,!0),e.hooks.add("gobble-expression",function(t){if(this.gobbleSpaces(),this.code===e.OPAREN_CODE){let r=this.index;if(this.index++,this.gobbleSpaces(),this.code===e.CPAREN_CODE){this.index++;let e=this.gobbleBinaryOp();if("=>"===e){let r=this.gobbleBinaryExpression();r||this.throwError("Expected expression after "+e),t.node={type:di,params:null,body:r};return}}this.index=r}}),e.hooks.add("after-expression",function(t){!function t(r){r&&(Object.values(r).forEach(e=>{e&&"object"==typeof e&&t(e)}),"=>"===r.operator&&(r.type=di,r.params=r.left?[r.left]:null,r.body=r.right,r.params&&r.params[0].type===e.SEQUENCE_EXP&&(r.params=r.params[0].expressions),delete r.left,delete r.right,delete r.operator))}(t.node)})}}),dr.plugins.register({name:"new",init(e){e.addUnaryOp("new"),e.hooks.add("after-token",function(t){let r=t.node;if(r&&"new"===r.operator){r.argument&&[e.CALL_EXP,e.MEMBER_EXP].includes(r.argument.type)||this.throwError("Expected new function()"),t.node=r.argument;let n=t.node;for(;n.type===e.MEMBER_EXP||n.type===e.CALL_EXP&&n.callee.type===e.MEMBER_EXP;)n=n.type===e.MEMBER_EXP?n.object:n.callee.object;n.type="NewExpression"}})}}),dr.plugins.register({name:"numbers",init(e){function t(e){return"x"===e||"X"===e?(this.index+=2,[[48,57],[65,70],[97,102]]):"b"===e||"B"===e?(this.index+=2,[[48,49]]):"o"===e||"O"===e||e>="0"&&e<="7"?(this.index+=e<="7"?1:2,[[48,55]]):null}function r(t){let r=this.index,n="",o=()=>{for(;e.isDecimalDigit(this.code)||95===this.code;)95===this.code?this.index++:n+=this.expr.charAt(this.index++)};o(),this.code===e.PERIOD_CODE&&(n+=this.expr.charAt(this.index++),o());let i=this.char;("e"===i||"E"===i)&&(n+=this.expr.charAt(this.index++),("+"===(i=this.char)||"-"===i)&&(n+=this.expr.charAt(this.index++)),o(),e.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+n+this.char+")"));let a=this.code;if(e.isIdentifierStart(a))this.throwError("Variable names cannot start with a number ("+n+this.char+")");else if(a===e.PERIOD_CODE){n.length>1&&this.throwError(`Unexpected period ${JSON.stringify({chCode:a,number:n},null,2)}`),this.index=r;return}t.node={type:e.LITERAL,value:parseFloat(n),raw:this.expr.substring(r,this.index)}}e.hooks.add("gobble-token",function(n){if(48===this.code){var o,i,a;let s=this.index,l=this.expr.charAt(this.index+1),u=t.call(this,l);if(!u)return;let c="";for(;o=this.code,i=u,95===o||i.some(([e,t])=>o>=e&&o<=t);)95===this.code?this.index++:c+=this.expr.charAt(this.index++);if(e.isIdentifierPart(this.code)){if(e.isDecimalDigit(this.code)&&e.isDecimalDigit(l.charCodeAt(0))){this.index=s+1,r.call(this,n);return}this.throwError("unexpected char within number")}n.node={type:e.LITERAL,value:parseInt(c,"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)&&r.call(this,n)})}}),dr.plugins.register({name:"regex",init(e){e.hooks.add("gobble-token",function(t){if(47===this.code){let r=++this.index,n=!1;for(;this.index<this.expr.length;){if(47===this.code&&!n){let n,o=this.expr.slice(r,this.index),i="";for(;++this.index<this.expr.length;){let e=this.code;if(e>=97&&e<=122||e>=65&&e<=90||e>=48&&e<=57)i+=this.char;else break}try{n=new RegExp(o,i)}catch(e){this.throwError(e.message)}return t.node={type:e.LITERAL,value:n,raw:this.expr.slice(r-1,this.index)},t.node=this.gobbleTokenProperty(t.node),t.node}this.code===e.OBRACK_CODE?n=!0:n&&this.code===e.CBRACK_CODE&&(n=!1),this.index+=92===this.code?2:1}this.throwError("Unclosed Regex")}})}}),dr.plugins.register({name:"ternary",init(e){e.hooks.add("after-expression",function(t){if(t.node&&this.code===e.QUMARK_CODE){this.index++;let r=t.node,n=this.gobbleExpression();if(n||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===e.COLON_CODE){this.index++;let o=this.gobbleExpression();if(o||this.throwError("Expected expression"),t.node={type:"ConditionalExpression",test:r,consequent:n,alternate:o},r.operator&&e.binary_ops[r.operator]<=.9){let n=r;for(;n.right.operator&&e.binary_ops[n.right.operator]<=.9;)n=n.right;t.node.test=n.right,n.right=t.node,t.node=r}}else this.throwError("Expected :")}})}}),dr.plugins.register({name:"jsepTemplateLiteral",init(e){function t(e,r=!0){if(96===this.code){let t={type:"TemplateLiteral",quasis:[],expressions:[]},n="",o="",i=!1,a=this.expr.length,s=()=>t.quasis.push({type:"TemplateElement",value:{raw:o,cooked:n},tail:i});for(;this.index<a;){let a=this.expr.charAt(++this.index);if("`"===a)return this.index+=1,i=!0,s(),e.node=t,r&&(e.node=this.gobbleTokenProperty(e.node)),e.node;if("$"===a&&"{"===this.expr.charAt(this.index+1))this.index+=2,s(),o="",n="",t.expressions.push(...this.gobbleExpressions(125)),125!==this.code&&this.throwError("unclosed ${");else if("\\"===a)switch(o+=a,a=this.expr.charAt(++this.index),o+=a,a){case"n":n+="\n";break;case"r":n+="\r";break;case"t":n+=" ";break;case"b":n+="\b";break;case"f":n+="\f";break;case"v":n+="\v";break;default:n+=a}else n+=a,o+=a}this.throwError("Unclosed `")}}e.hooks.add("gobble-token",t),e.hooks.add("after-token",function(r){if((r.node.type===e.IDENTIFIER||r.node.type===e.MEMBER_EXP)&&96===this.code)return r.node={type:"TaggedTemplateExpression",tag:r.node,quasi:t.bind(this)(r,!1)},r.node=this.gobbleTokenProperty(r.node),r.node})}}),dr.addBinaryOp("in",7),dr.addBinaryOp("??",1);let dC=Z("feature-flags",{flags:function(){let e={};for(let t of Object.keys(localStorage))if(t.startsWith("openmrs:feature-flag:")){let r=t.replace("openmrs:feature-flag:",""),n=JSON.parse(localStorage.getItem(`openmrs:feature-flag-meta:${r}`)||"{}");e[r]={enabled:"true"===localStorage.getItem(t),...n}}return e}()});function dj(e,t,r){dC.setState(n=>({flags:{...n.flags,[e]:{enabled:n.flags[e]?.enabled??!1,label:t,description:r}}}))}function dT(){let e=dC.getState().flags;Object.keys(localStorage).filter(e=>e.startsWith("openmrs:feature-flag:")).forEach(t=>{let r=t.replace("openmrs:feature-flag:","");e[r]||(localStorage.removeItem(t),localStorage.removeItem(`openmrs:feature-flag-meta:${r}`))})}function dR(e){return dC.getState().flags[e].enabled}function dA(e,t){dC.subscribe(r=>{t(r.flags[e].enabled)})}function dN(e,t){dC.setState(r=>({flags:{...r.flags,[e]:{...r.flags[e],enabled:t}}}))}function d$(e){return!window.offlineEnabled||(e??navigator.onLine)}dC.subscribe(e=>{for(let[t,r]of Object.entries(e.flags))localStorage.setItem(`openmrs:feature-flag:${t}`,r.enabled.toString()),localStorage.setItem(`openmrs:feature-flag-meta:${t}`,JSON.stringify({label:r.label,description:r.description}))});var dI=tt(function(e,t,r){e1(e,t,r)});function dM(e=!0,t=!1){return dL(d$(),e,t)}function dL(e,t=!0,r=!1){return!!(e?t:r)}let dF=q("extensionsInternal",{slots:{},extensions:{}}),dB=q("extensionRenderings",{renderings:new Map}),dV=()=>Z("extensionsInternal",{slots:{},extensions:{}}),dU=()=>Z("extensionRenderings",{renderings:new Map});function dW(e){let t=dF.getState(),r=e(t);r!==t&&dF.setState(r)}let dK=null,dz=null;function dH(){let e=dB.getState();return dK&&e===dz||(dK=new Map(e.renderings),dz=e,function(e){for(let t of(d4.clear(),e.values()))d2(t,1);d3=!0}(dK)),dK}function dG(e){dz={renderings:e},dB.setState(dz,!0)}function dq(e){let t=dH();t.has(e.renderingId)||(t.set(e.renderingId,e),d2(e,1),dG(t))}function dY(e){let t=dH(),r=t.get(e);r&&(t.delete(e),d2(r,-1),dG(t))}let dZ=()=>Z("extensions",{slots:{}}),dJ=0,dX=new Set;function dQ(e){dJ++;try{return e()}finally{if(0==--dJ&&dX.size>0){let e=Array.from(dX);for(let t of(dX.clear(),e))d0(t)}}}function d0(e){try{e()}catch(t){console.error(`The extension system's '${e.name}' recomputation failed`,t)}}function d1(e){dJ>0?dX.add(e):d0(e)}let d4=new Map,d3=!1;function d2(e,t){let r=JSON.stringify([e.slotName,e.extensionId,e.slotModuleName,e.extensionModuleName]),n=d4.get(r);if(!n){if(t<0)return;d4.set(r,{count:1,record:{slotModuleName:e.slotModuleName,extensionModuleName:e.extensionModuleName,slotName:e.slotName,extensionId:e.extensionId}}),d3=!0;return}n.count+=t,n.count<1&&(d4.delete(r),d3=!0)}function d6(){var e,t;if(dH(),!d3)return;d3=!1;let r=Array.from(d4.values(),({record:e})=>e);r.sort(d5),e=t3.getState().mountedExtensions,t=r,e.length===t.length&&e.every((e,r)=>0===d5(e,t[r]))||t3.setState({mountedExtensions:r})}function d5(e,t){return d8(e.slotName,t.slotName)||d8(e.extensionId,t.extensionId)||d8(e.slotModuleName,t.slotModuleName)||d8(e.extensionModuleName,t.extensionModuleName)}function d8(e,t){return e===t?0:e<t?-1:1}d6(),dB.subscribe(()=>d1(d6));let d9=dV(),d7=dZ(),pe=t6(),pt=t9(),pr=new Set,pn=!1;function po(e){if(null===e)pr=null;else if(null!==pr)for(let t of e)pr.add(t);d1(pi)}function pi(){if(!pn){pn=!0;try{for(let e=1;;e++){let t=pr;if(null!==t&&0===t.size)return;pr=new Set;try{!function(e,t,r,n,o,i=null){let a=d7.getState().slots,s={},l=!1,u=d$(),c=Object.entries(n.flags).filter(([,{enabled:e}])=>e).map(([e])=>e);for(let[n,d]of Object.entries(e.slots)){let p=a[n];if(p&&i&&!i.has(n)){s[n]=p;continue}let{config:f}=t8(t,d.name),h=function(e,t,r,n,o,i,a){let s=function(e,t){let r=e.add||[],n=e.remove||[],o=e.order||[],{extensions:i}=d9.getState();return[...t,...r].filter(e=>!n.includes(e)).sort((e,r)=>pg(e,o,i[pu(e)]?.order,t)-pg(r,o,i[pu(r)]?.order,t))}(r,t.slots[e].attachedIds),l=[];for(let u of s){let{config:s}=re(n,e,u),c=rt(r,e,u),d=c?dI({},s,c):s,p=pu(u),f=t.extensions[p];if(f){let e=d?.["Display conditions"]?.privileges??f.privileges??[];if(e&&("string"==typeof e||Array.isArray(e)&&e.length>0)&&(!a?.user||!oY(e,a.user))||f.featureFlag&&!o.includes(f.featureFlag)||window.offlineEnabled&&!dL(i,f.online,f.offline))continue;l.push({id:u,name:p,moduleName:f.moduleName,config:d,featureFlag:f.featureFlag,meta:f.meta,online:d?.["Display conditions"]?.online??f.online??!0,offline:d?.["Display conditions"]?.offline??f.offline??!1,displayConditionExpression:d?.["Display conditions"]?.expression||f.displayExpression})}}return l}(n,e,f,r,c,u,o.session);p&&p.moduleName===d.moduleName&&to(p.candidateExtensions,h)?s[n]=p:(s[n]={moduleName:d.moduleName,candidateExtensions:h},l=!0)}(l||Object.keys(a).length!==Object.keys(s).length)&&d7.setState({slots:s})}(d9.getState(),pe.getState(),pt.getState(),dC.getState(),oU.getState(),t)}catch(e){throw pr=null===t||null===pr?null:new Set([...t,...pr]),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{pn=!1}}}function pa(e,t){let r=new Set;for(let n of Object.keys(e))e[n]!==t[n]&&r.add(n);for(let n of Object.keys(t))n in e||r.add(n);return r}function ps(){po(null)}function pl(e,t){return{moduleName:t,name:e,attachedIds:[]}}function pu(e){let[t]=e.split("#");return t}function pc(e,t){let r=pu(t);return e.extensions[r]}function pd(e){return pc(d9.getState(),e)}d9.subscribe((e,t)=>{po(e.extensions!==t.extensions?null:pa(e.slots,t.slots))}),pe.subscribe((e,t)=>{po(pa(e.slots,t.slots))}),pt.subscribe((e,t)=>{po(pa(e.configs,t.configs))}),dC.subscribe(()=>po(null)),oU.subscribe(()=>po(null)),ps(),y(ps);let pp=e=>dW(t=>({...t,extensions:{...t.extensions,[e.name]:{...e}}}));function pf(e,t){dW(r=>{let n=r.slots[e];return n?{...r,slots:{...r.slots,[e]:{...n,attachedIds:[...n.attachedIds,t]}}}:{...r,slots:{...r.slots,[e]:{...pl(e),attachedIds:[t]}}}})}function ph(e,t){dW(r=>{let n=r.slots[e];return n&&n.attachedIds.includes(t)?{...r,slots:{...r.slots,[e]:{...n,attachedIds:n.attachedIds.filter(e=>e!==t)}}}:r})}function pm(e){dW(t=>{let r=t.slots[e];return r?{...t,slots:{...t.slots,[e]:{...r,attachedIds:[]}}}:t})}function pg(e,t,r,n){let o=t.indexOf(e);if(-1!==o)return o;{if(void 0!==r)return 1e3+r;let t=n.indexOf(e);return -1!==t?2e3+t:3e3}}function py(e,t){return function(e,t,r=null,n){let o;return e.filter(e=>{let i=e.displayConditionExpression;if("string"!=typeof i||0===i.trim().length)return!0;o??(o=t&&"object"==typeof t?{session:r,...t}:{session:r});try{return!!dc(i,o)}catch(t){return console.error(`Error while evaluating expression '${i}' for ${e.id}`+(n?` in ${n}`:""),t),!1}})}(pv(e),t,oU.getState().session,e)}function pv(e){return d7.getState().slots[e]?.candidateExtensions??[]}let pb=(e,t)=>d9.setState(r=>{let n=r.slots[t]?.moduleName;if(n&&n!=e)return console.warn(`An extension slot with the name '${t}' already exists. Refusing to register the same slot name twice (in "registerExtensionSlot"). The existing one is from module ${n}.`),r;if(n&&n==e)return r;if(r.slots[t])return{...r,slots:{...r.slots,[t]:{...r.slots[t],moduleName:e}}};let o=pl(t,e);return{...r,slots:{...r.slots,[t]:{...o}}}}),pw=()=>{pr=null,dW(()=>({slots:{},extensions:{}})),dU().setState({renderings:new Map}),d7.setState({slots:{}})},p_=q("left-nav",{slotName:null,basePath:window.spaBase,mode:"normal"});function px({name:e,basePath:t,mode:r,componentContext:n,state:o}){p_.setState({slotName:e,basePath:t,mode:r??"normal",componentContext:n,state:o})}function pE(e){p_.getState().slotName===e&&p_.setState(p_.getInitialState(),!0)}let pS=q("modalRegistry",{modals:{}});function pD(e){pS.setState(t=>(t.modals[e.name]=e,t))}function pO(e){let t=pS.getState().modals[e];if(!t){let r=pd(e);r&&(t={name:e,load:r.load,moduleName:r.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.`),pD(t))}return t}let pk=q("workspaceRegistrations",{workspaces:{}}),pP=q("workspaceGroups",{workspaceGroups:{}});function pC(e){pk.setState(t=>({workspaces:{...t.workspaces,[e.name]:{...e,load:e.load,preferredWindowSize:e.preferredWindowSize??"normal",type:e.type??"form",canHide:e.canHide??!1,canMaximize:e.canMaximize??!1,width:e.width??"narrow",groups:e.groups??[]}}}))}function pj(e){pP.setState(t=>{let r=t.workspaceGroups[e.name];return r?{workspaceGroups:{...t.workspaceGroups,[e.name]:{...r,members:Array.from(new Set([...r.members,...e.members]))}}}:{workspaceGroups:{...t.workspaceGroups,[e.name]:{name:e.name,members:e.members}}}})}let pT=new Set;function pR(e){let t=pk.getState().workspaces;if(t[e])return t[e];{let t=pd(e);if(t){var r;let n;return pT.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.`),pT.add(e)),{name:t.name,title:(r=t,"string"==typeof(n=r?.meta?.title)?n:n&&"object"==typeof n?iB(r.moduleName,n.key,n.default):r.name),moduleName:t.moduleName,preferredWindowSize:t.meta?.screenSize??"normal",load:t.load,type:t.meta?.type??"form",canHide:t.meta?.canHide??!1,canMaximize:t.meta?.canMaximize??!1,width:t.meta?.width??"narrow",groups:t.meta?.groups??[]}}throw Error(`No workspace named '${e}' has been registered.`)}}function pA(e){let t=pP.getState().workspaceGroups;if(t[e])return t[e];throw Error(`No workspace group named '${e}' has been registered.`)}let pN=q("workspace2",{registeredGroupsByName:{},registeredWindowsByName:{},registeredWorkspacesByName:{},openedGroup:null,openedWindows:[],workspaceTitleByWorkspaceName:{},isMostRecentlyOpenedWindowHidden:!1});function p$(e){let{registeredWorkspacesByName:t,registeredWindowsByName:r}=pN.getState(),n=t[e];if(n){let t=r[n.window];if(t)return t;throw Error(`No workspace window found with name: ${n.window} for workspace: ${e}`)}throw Error(`No workspace found with name: ${e}`)}function pI(e){let{registeredGroupsByName:t,registeredWindowsByName:r}=pN.getState(),n=r[e];if(n){let r=t[n.group];if(r)return r;throw Error(`No workspace group found with name: ${n.group} for window: ${e}`)}throw Error(`No workspace window found with name: ${e}`)}function pM(e){let{openedWindows:t}=pN.getState();return t.findIndex(t=>t.openedWorkspaces.find(t=>t.workspaceName===e))}function pL(e,t){if(0==t.length)return;let{registeredGroupsByName:r}=pN.getState(),n={...r};for(let r of t){if(n[r.name])throw Error(`Cannot register workspace group ${r.name} more than once`);n[r.name]={...r,moduleName:e}}pN.setState({registeredGroupsByName:n})}function pF(e,t){if(0==t.length)return;let{registeredWindowsByName:r}=pN.getState(),n={...r};for(let r of t){if(n[r.name])throw Error(`Cannot register workspace window ${r.name} more than once`);let t={...r,moduleName:e};n[r.name]=t}pN.setState({registeredWindowsByName:n})}function pB(e,t){if(0==t.length)return;let{registeredWorkspacesByName:r}=pN.getState(),n={...r};for(let r of t){if(n[r.name])throw Error(`Cannot register workspace ${r.name} more than once`);let t={...r,moduleName:e};n[r.name]=t}pN.setState({registeredWorkspacesByName:n})}let pV=0,pU=null,pW={bootstrap:15e3,mount:15e3,unmount:15e3};function pK(e,t){if(e.timeouts)return e;let r=e.name??"parcel",n=Object.fromEntries(Object.keys(pW).filter(t=>e[t]).map(n=>{var o,i;let a,s;return[n,(o=e[n],i=pW[n],a=Array.isArray(o)?o:[o],s=e=>a.reduce((t,o,i)=>t.then(()=>{let t=o(e);return"function"==typeof t?.then&&"function"==typeof t?.catch?t:Promise.reject(Error(`Lifecycle function ${n} at array index ${i} for parcel ${r} did not return a promise`))}),Promise.resolve(void 0)),e=>{let o,a=new Promise((e,t)=>{o=setTimeout(()=>t(Error(`Lifecycle function ${n} for parcel ${r} did not settle within ${i}ms`)),i)});return Promise.race([s(e),a]).finally(()=>clearTimeout(o)).then(e=>(t(n,!1),e),e=>{throw t(n,!0),e})})]}));return{...e,...n}}async function pz(e,t){var r,n;let o,i,a,s,l,u=await (pU??(pU=new Promise((e,t)=>{nM({name:"openmrs-extension-host",bootstrap:()=>Promise.resolve(),mount:t=>(e(t.mountParcel),Promise.resolve()),unmount:()=>Promise.resolve()},{domElement:document.createElement("div")}).mountPromise.catch(t)}).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),nM))),pU),c={...t},d=(o=c,i=!1,{retarget:e=>o={...e},release:a=()=>(function(e){for(let t of Object.keys(e))delete e[t]})(o),onSettled(e,t){switch(e){case"bootstrap":t&&a();return;case"mount":i||(i=t);return;case"unmount":(t||i)&&a();return}}});return n=u((r=d.onSettled,"function"==typeof e?()=>e().then(e=>pK(e,r)):pK(e,r)),c),s=e=>t=>e.call(n,d.retarget(t)).catch(e=>{throw"SKIP_BECAUSE_BROKEN"===n.getStatus()&&d.release(),e}),l=n.update&&s(n.update),Object.defineProperty(n,"update",{configurable:!0,enumerable:!0,get:()=>l,set:e=>{l=e&&s(e)}})}function pH(){return pG}function pG(e,t){let r,n=pz(e,t).then(e=>r=e);return{mount:()=>n.then(e=>e.mount()),unmount:()=>n.then(e=>e.unmount()),update:e=>n.then(t=>t.update?.(e)),getStatus:()=>r?.getStatus()??"LOADING_SOURCE_CODE",get loadPromise(){return n.then(e=>e.loadPromise)},get bootstrapPromise(){return n.then(e=>e.bootstrapPromise)},get mountPromise(){return n.then(e=>e.mountPromise)},get unmountPromise(){return n.then(e=>e.unmountPromise)}}}async function pq(e,t,r,n,o=e=>e,i={}){let a=pu(n),s=pd(n),l=null;if(e){if(!s)throw Error(`Couldn't find extension '${a}' to attach to '${t}'`);let{meta:u,moduleName:c,online:d,offline:p,load:f}=s;if(dM(d,p)){let s,d=pV++,p=`${t}/${n}-${d}`;e.dataset.extensionRenderingId=p;let h=e=>{try{dY(p)}catch(t){console.error(e,t)}};try{dq({renderingId:p,extensionName:a,extensionModuleName:c,extensionId:n,slotName:t,slotModuleName:r})}catch(e){throw h(`Recomputing configuration after registering '${n}' failed also failed`),e}try{s=await f()}catch(e){throw h(`Recomputing configuration after '${n}' failed to load also failed`),e}try{l=await pz(o({...s,name:`${t}/${a}-${d}`}),{...i,_meta:u,_extensionContext:{extensionId:n,extensionSlotName:t,extensionSlotModuleName:r,extensionModuleName:c},domElement:e})}catch(e){throw h(`Recomputing configuration after '${n}' failed to mount also failed`),e}l.mountPromise.then(void 0,e=>{console.error(`Extension '${n}' in slot '${t}' failed to mount`,e),h(`Recomputing configuration after '${n}' failed to mount also failed`)}),l.unmountPromise.then(()=>h(`Recomputing configuration after unmounting '${n}' failed`),e=>{console.error(`Extension '${n}' in slot '${t}' failed to unmount`,e),h(`Recomputing configuration after '${n}' failed to unmount also failed`)})}}else console.warn(`Tried to render ${n} into ${t} but no DOM element was available.`);return l}var pY=r(695),pZ=r.n(pY);let pJ=(0,pY.createContext)({moduleName:"",featureName:""});function pX({to:e,templateParams:t,onBeforeNavigate:r,children:n,...o}){return(0,pY.useEffect)(()=>{o.href&&console.warn(`ConfigurableLink does not support the href prop. Use the 'to' prop instead. The provided href value is '${o.href}'`),o.onClick&&console.warn(`ConfigurableLink does not support the onClick prop. Use the 'onBeforeNavigate' prop instead. The 'to' prop of the offending link is ${e}`)},[]),pZ().createElement("a",{onClick:n=>{0===n.button&&!n.ctrlKey&&!n.shiftKey&&!n.altKey&&!n.metaKey&&(n.preventDefault(),r?.(n),oD({to:e,templateParams:t})),0===n.button&&(n.ctrlKey||n.metaKey)&&r?.(n),0===n.button&&n.shiftKey&&r?.(n),1===n.button&&r?.(n)},href:oE(e,t),...o},n)}let pQ=({state:e,children:t,...r})=>{let{extension:n}=(0,pY.useContext)(pJ),o=(0,pY.useRef)(null),i=(0,pY.useRef)(Promise.resolve()),a=(0,pY.useRef)(!1),s=(0,pY.useRef)(!1),l=(0,pY.useRef)(e),u=(0,pY.useCallback)(e=>{if(!e)return;let t=()=>{"MOUNTED"===e.getStatus()&&e.unmount()};switch(e.getStatus()){case"MOUNTED":e.unmount();break;case"UPDATING":i.current?.then(t,t);break;default:e.mountPromise.then(t,()=>{})}},[]),c=(0,pY.useCallback)((e,t)=>{e.update&&"UNMOUNTING"!==e.getStatus()&&(i.current=Promise.all([e.mountPromise,i.current]).then(()=>{if(o.current?.getStatus()==="MOUNTED"&&o.current.update)return o.current.update({...t})}).catch(e=>{let t=o.current?.getStatus();"UNMOUNTING"!==t&&"NOT_MOUNTED"!==t&&"UNLOADING"!==t&&console.error(`The extension '${n?.extensionId}' failed to update`,e)}))},[]),d=(0,pY.useCallback)(t=>{t&&!o.current&&!s.current&&n?.extensionSlotName&&n.extensionSlotModuleName&&(s.current=!0,pq(t,n.extensionSlotName,n.extensionSlotModuleName,n.extensionId,void 0,e).then(t=>{(s.current=!1,o.current=t,a.current)?u(t):t&&l.current!==e&&c(t,l.current)},()=>{s.current=!1}))},[]);return(0,pY.useEffect)(()=>(a.current=!1,()=>{a.current=!0,u(o.current)}),[]),(0,pY.useEffect)(()=>{l.current=e,o.current&&c(o.current,e)},[e]),n?pZ().createElement("div",{ref:d,"data-extension-id":n?.extensionId,style:{position:"relative"},...r}):null};function p0(e){let t=(0,pY.useRef)(e);return L(t.current,e)||(t.current=e),t.current}function p1(e,t){"function"==typeof t&&(t=t(e));let r={};for(let[n,o]of Object.entries(t)){let t=function(...t){e.setState(e=>o(e,...t))};r[n]=t}return r}let p4=e=>e;function p3(e,t=p4,r){let n=(0,pY.useCallback)(t=>e.subscribe(t),[e]),o=(0,pY.useCallback)(()=>t(e.getState()),[e,t]),i=(0,pY.useSyncExternalStore)(n,o,o),a=(0,pY.useMemo)(()=>r?p1(e,r):null,[e,r]);return(0,pY.useMemo)(()=>a?{...i,...a}:i,[i,a])}function p2(e,t){return p3(e,p4,t)}function p6(e){return function(t){let r=(0,pY.useCallback)(t=>e.subscribe(t),[]),n=(0,pY.useCallback)(()=>e.getState(),[]),o=(0,pY.useSyncExternalStore)(r,n,n),i=(0,pY.useMemo)(()=>t?p1(e,t):null,[t]);return(0,pY.useMemo)(()=>i?{...o,...i}:o,[o,i])}}let p5=[];Object.freeze(p5);let p8={candidateExtensions:p5};Object.freeze(p8);let p9=e=>{let t=(0,pY.useCallback)(t=>t.slots?.[e]??p8,[e]);return p3(dZ(),t)},p7=e=>e.session;function fe(e,t){let{candidateExtensions:r}=p9(e),n=p3(oU,p7),o=p0(t);return(0,pY.useMemo)(()=>py(e,o),[e,o,n,r])}function ft(e,t){let{moduleName:r}=(0,pY.useContext)(pJ);if(!r)throw Error("ComponentContext has not been provided. This should come from @openmrs/esm-react-utils.");return(0,pY.useEffect)(()=>{pb(r,e)},[r,e]),{extensions:fe(e,t),extensionSlotName:e,extensionSlotModuleName:r}}function fr(e){return e}function fn({name:e,extensionSlotName:t,select:r=fr,children:n,state:o,style:i,...a}){if(n&&o)throw Error("Both children and state have been provided. If children are provided, the state must be passed as a prop to the `Extension` component.");let s=e??t,l=(0,pY.useRef)(null),{extensions:u,extensionSlotModuleName:c}=ft(s,o),d=(0,pY.useMemo)(()=>r(u),[r,u]),p=(0,pY.useMemo)(()=>{if("function"==typeof n&&!pZ().isValidElement(n))return d.map(e=>n(e,o))},[n,d]);return pZ().createElement("div",{ref:l,"data-extension-slot-name":s,"data-extension-slot-module-name":c,style:{...i,position:"relative"},...a},s&&d?.map((e,t)=>pZ().createElement(pJ.Provider,{key:e.id,value:{moduleName:c,featureName:"",extension:{extensionId:e.id,extensionSlotName:s,extensionSlotModuleName:c}}},p?.[t]??("function"!=typeof n?n:null)??pZ().createElement(pQ,{state:o}))))}var fo=r(5338);function fi(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function fa(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?fi(Object(r),!0).forEach(function(t){var n,o,i;n=e,o=t,i=r[t],o in n?Object.defineProperty(n,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):n[o]=i}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):fi(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function fs(e){return(fs="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 fl(e){return(fl="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 fu(e,t){var r;if("function"!=typeof(r=t.domElement?function(){return t.domElement}:t.domElementGetter?t.domElementGetter:e.domElementGetter?e.domElementGetter:function(e){var t=e.appName||e.name;if(!t)throw Error("single-spa's dom-element-getter-helpers was not given an application name as a prop, so it can't make a unique dom element container for the react application");var r="single-spa-application:".concat(t);return function(){var e=document.getElementById(r);return e||((e=document.createElement("div")).id=r,document.body.appendChild(e)),e}}(t)))throw Error("single-spa's dom-element-getter-helpers was given an invalid domElementGetter for application or parcel '".concat(t.name,"'. Expected a function, received ").concat(fl(r)));return function(){var e=r(t);if(!(e instanceof HTMLElement))throw Error("single-spa's dom-element-getter-helpers: domElementGetter returned an invalid dom element for application or parcel '".concat(t.name,"'. Expected HTMLElement, received ").concat(fl(e)));return e}}var fc=null;try{fc=require("react").createContext()}catch(e){}var fd={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 fp(e,t){return e.rootComponent?Promise.resolve():e.loadRootComponent(t).then(function(t){e.rootComponent=t})}function ff(e,t){return new Promise(function(r,n){e.suppressComponentDidCatchWarning||!function(e){if(!(e&&"string"==typeof e.version&&e.version.indexOf(".")>=0))return!1;var t=e.version.slice(0,e.version.indexOf("."));try{return Number(t)>=16}catch(e){return!1}}(e.React)||e.errorBoundary||e.errorBoundaryClass||(e.rootComponent.prototype?e.rootComponent.prototype.componentDidCatch||console.warn("single-spa-react: ".concat(t.name||t.appName||t.childAppName,"'s rootComponent should implement componentDidCatch to avoid accidentally unmounting the entire single-spa application.")):console.warn("single-spa-react: ".concat(t.name||t.appName||t.childAppName,"'s rootComponent does not implement an error boundary. If using a functional component, consider providing an opts.errorBoundary to singleSpaReact(opts).")));var o,i=fy(e,t,function(){r(this)}),a=fu(e,t)(),s=function(e){var t=e.reactDom,r=e.renderType,n=e.elementToRender,o=e.domElement,i=t[r];if("function"!=typeof i)throw Error('renderType "'.concat(r,'" did not return a function.'));switch(r){case"createRoot":case"unstable_createRoot":case"createBlockingRoot":case"unstable_createBlockingRoot":var a=i(o);return a.render(n),a;case"hydrateRoot":return i(o,n);default:return i(n,o),null}}({elementToRender:i,domElement:a,reactDom:fg(e),renderType:"function"==typeof(o=e).renderType?o.renderType():o.renderType});e.domElements[t.name]=a,e.renderResults[t.name]=s})}function fh(e,t){return new Promise(function(r){e.unmountResolves[t.name]=r;var n=e.renderResults[t.name];n&&n.unmount?n.unmount():fg(e).unmountComponentAtNode(e.domElements[t.name]),delete e.domElements[t.name],delete e.renderResults[t.name]})}function fm(e,t){return new Promise(function(r){e.updateResolves[t.name]||(e.updateResolves[t.name]=[]),e.updateResolves[t.name].push(r);var n=fy(e,t,null),o=e.renderResults[t.name];if(o&&o.render)o.render(n);else{var i=fu(e,t)();fg(e).render(n,i)}})}function fg(e){return e.ReactDOMClient||e.ReactDOM}function fy(e,t,r){var n=e.React.createElement(e.rootComponent,t),o=fc?e.React.createElement(fc.Provider,{value:t},n):n;return(e.errorBoundary||t.errorBoundary||e.errorBoundaryClass||t.errorBoundaryClass)&&(e.errorBoundaryClass=e.errorBoundaryClass||t.errorBoundaryClass||function(e,t){function r(t){e.React.Component.apply(this,arguments),this.state={caughtError:null,caughtErrorInfo:null},r.displayName="SingleSpaReactErrorBoundary(".concat(t.name,")")}return r.prototype=Object.create(e.React.Component.prototype),r.prototype.render=function(){return this.state.caughtError?(e.errorBoundary||t.errorBoundary)(this.state.caughtError,this.state.caughtErrorInfo,this.props):this.props.children},r.prototype.componentDidCatch=function(e,t){this.setState({caughtError:e,caughtErrorInfo:t})},r}(e,t),o=e.React.createElement(e.errorBoundaryClass,t,o)),o=e.React.createElement(e.SingleSpaRoot,fa(fa({},t),{},{mountFinished:r,updateFinished:function(){e.updateResolves[t.name]&&(e.updateResolves[t.name].forEach(function(e){return e()}),delete e.updateResolves[t.name])},unmountFinished:function(){e.unmountResolves[t.name]&&(e.unmountResolves[t.name](),delete e.unmountResolves[t.name])}}),o)}var fv=r(287),fb=r(9324),fw=r(2108);let f_={strictMode:!0,throwErrorsToConsole:!0,disableTranslations:!1},fx=new Map;(0,fw.initCache)(fx);let fE={errorRetryCount:3,fetcher:oF,focusThrottleInterval:18e5,revalidateIfStale:!0,revalidateOnFocus:!1,revalidateOnReconnect:!1,refreshInterval:0,shouldRetryOnError:e=>{if(e instanceof oV){let t=e.response.status;return!!(t>=500)||401===t||403===t||429===t}return!0},provider:()=>fx};function fS(e){if("object"!=typeof e||"string"!=typeof e.featureName||"string"!=typeof e.moduleName)throw Error("Invalid options");let t=Object.assign({},f_,e),r={...fE,...t.swrConfig};return function(e){var n,o,i,a,s;return i=o=class extends(n=pZ().Component){componentDidCatch(e,r){r&&r.componentStack&&(e.extra=Object.assign(e.extra||{},{componentStack:r.componentStack})),t.throwErrorsToConsole&&setTimeout(()=>{throw e}),this.setState({caughtError:e,caughtErrorInfo:r})}render(){if(this.state.caughtError)return pZ().createElement("div",null,"An error has occurred. Please try reloading the page.");{let n=pZ().createElement(pY.Suspense,{fallback:null},pZ().createElement(fb.BE,{value:r},pZ().createElement(pJ.Provider,{value:this.state.config},t.disableTranslations?pZ().createElement(e,this.props):pZ().createElement(fv.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},pZ().createElement(e,this.props)))));return t.strictMode&&pZ().StrictMode?pZ().createElement(pZ().StrictMode,null,n):n}}constructor(e){super(e),this.state={caughtError:null,caughtErrorInfo:null,config:{moduleName:t.moduleName,featureName:t.featureName,extension:e._extensionContext}}}},a="displayName",s=`OpenmrsReactComponent(${t.featureName})`,a in i?Object.defineProperty(i,a,{value:s,enumerable:!0,configurable:!0,writable:!0}):i[a]=s,o}}function fD(e,t){return function(e){if("object"!==fs(e))throw Error("single-spa-react requires a configuration object");var t,r=fa(fa({},fd),e);if(!r.React)throw Error("single-spa-react must be passed opts.React");if(!r.ReactDOM&&!r.ReactDOMClient)throw Error("single-spa-react must be passed opts.ReactDOM or opts.ReactDOMClient");if(r.renderType||(null!=(t=r.ReactDOMClient)&&t.createRoot?r.renderType="createRoot":r.renderType="render"),!r.rootComponent&&!r.loadRootComponent)throw Error("single-spa-react must be passed opts.rootComponent or opts.loadRootComponent");if(r.errorBoundary&&"function"!=typeof r.errorBoundary)throw Error("The errorBoundary opt for single-spa-react must either be omitted or be a function that returns React elements");!fc&&r.React.createContext&&(fc=r.React.createContext()),r.SingleSpaRoot=function(e){function t(e){t.displayName="SingleSpaRoot(".concat(e.name,")")}return t.prototype=Object.create(e.React.Component.prototype),t.prototype.componentDidMount=function(){setTimeout(this.props.mountFinished)},t.prototype.componentWillUnmount=function(){setTimeout(this.props.unmountFinished)},t.prototype.render=function(){return setTimeout(this.props.updateFinished),this.props.children},t}(r);var n={bootstrap:fp.bind(null,r),mount:ff.bind(null,r),unmount:fh.bind(null,r)};return r.parcelCanUpdate&&(n.update=fm.bind(null,r)),n}({React:pZ(),ReactDOMClient:fo,rootComponent:fS(t)(e)})}function fO(e,t){return()=>e().then(({default:e})=>fD(e,t))}function fk(e,t){return()=>Promise.resolve(fD(e,t))}let fP=fO,fC=U()(()=>({}));Y("openmrs-app-context",fC);let fj={};function fT(e,t=e=>e){let r=fC.getState();return e in r?Object.freeze(Object.assign({},t?t(r[e]):r[e])):null}function fR(e,t){fC.setState(r=>(e in r||(r[e]={}),r[e]=t(r[e]),Object.assign({},r)))}function fA(e){return null===e?null:Object.freeze(Object.assign({},e))}let fN=new Map;function f$(e,t){let r=(0,pY.useRef)(t??{}),n=(0,pY.useRef)(t=>fR(e,t)),o=(0,pY.useRef)(Symbol());return(0,pY.useEffect)(()=>{let r=t??{},n=o.current;return null===fT(e)?!function(e,t=fj){fC.setState(r=>{if(e in r)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({},r,{[e]:t===fj?{}:t})})}(e,r):(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.`),fR(e,()=>r)),fN.set(e,n),()=>{fN.get(e)===n&&(fC.setState(t=>(e in t&&delete t[e],t)),fN.delete(e))}},[e]),(0,pY.useEffect)(()=>{let n=t??{};L(r.current,n)||(fR(e,()=>n),r.current=n)},[t]),n.current}function fI({namespace:e,value:t}){return f$(e,t),null}let fM=({children:e,value:t,fallback:r})=>t?pZ().createElement(pZ().Fragment,null,e):r?pZ().createElement(pZ().Fragment,null,r):null;function fL(){let e=(0,pY.useRef)();return(!e.current||e.current.signal.aborted)&&(e.current=new AbortController),(0,pY.useEffect)(()=>{let t=e.current;return()=>t?.abort()},[]),e.current}function fF(e,t=e=>e??{}){let[r,n]=(0,pY.useState)(()=>{if(fB(e))return;let r=fT(e);if(null!==r)return t?t(r):r});return(0,pY.useEffect)(()=>{if(fB(e))throw Error(`The namespace supplied to useAppContext must be a non-empty string, but was "${e}".`)},[e]),(0,pY.useEffect)(()=>{var r;let o;return(r=e=>{if(null==e)return void n(void 0);let r=t?t(e):e;n(e=>L(e,r)?e:r)})(fA(o=fT(e))),fC.subscribe(t=>{let n=e in t?t[e]:null;n!==o&&(o=n,r(fA(n)))})},[e,t]),r}function fB(e){return"string"!=typeof e||0===e.trim().length}function fV(e){let t=fe(e);return(0,pY.useMemo)(()=>t.map(e=>e.id),[t])}function fU(e){return p9(e).candidateExtensions}function fW(e,t){let{data:r,error:n,mutate:o,isLoading:i,isValidating:a}=(0,fb.Ay)(`${aD}?patient=${e}&includeEncounterless=${t}`,oF);return(0,pY.useMemo)(()=>({isLoading:i,data:r?.data.results??[],error:n,mutate:o,isValidating:a}),[r,n,i,a,o])}function fK(e){(0,pY.useEffect)(()=>{if(e){let e=window.getComputedStyle(document.body).overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=e}}},[e])}let fz={},fH=`No ComponentContext has been provided. This should come from "openmrsComponentDecorator".
16
16
  Usually this is already applied when using "getAsyncLifecycle" or "getSyncLifecycle".`;function fG(e){let{moduleName:t,extension:r}=(0,pY.useContext)(pJ),n=e?.externalModuleName??t;if(!n&&!r)throw Error(fH);let o=function(e){let t=(0,pY.useMemo)(()=>t2(e),[e]),r=function(e){let[t,r]=(0,pY.useState)(()=>{let t=e.getState();return t.loaded&&t.config?t.config:null});return(0,pY.useEffect)(()=>e?.subscribe(e=>{e.loaded&&e.config&&r(e.config)}),[e]),t}(t);if(!r)throw fz[e]||(fz[e]=new Promise(e=>{let r=t.subscribe(t=>{t.loaded&&t.config&&(e(t.config),r())})})),fz[e];return r}(n),i=function(e){let t=(0,pY.useMemo)(t9,[]),r=function(e,t){let[r,n]=(0,pY.useState)(t?()=>{let r=re(e.getState(),t.extensionSlotName,t.extensionId);if(r.loaded&&r.config)return r.config}:null);return(0,pY.useEffect)(()=>{if(t)return e.subscribe(e=>{let o=re(e,t.extensionSlotName,t.extensionId);o.loaded&&o.config&&!to(o.config,r)&&n(o.config)})},[e,t,r]),r}(t,e);if(!r&&e){let r=`${e.extensionSlotName}-${e.extensionId}`;throw!fz[r]&&t&&(fz[r]=new Promise(r=>{let n=t.subscribe(t=>{let o=re(t,e.extensionSlotName,e.extensionId);o.loaded&&o.config&&(r(o.config),n())})})),fz[r]}return r||{}}(r);return(0,pY.useMemo)(()=>e?.externalModuleName&&n===e.externalModuleName?{...o}:{...o,...i},[n,e?.externalModuleName,o,i])}let fq=fe;function fY(){let[e,t]=(0,pY.useState)(d$());return(0,pY.useEffect)(()=>y(({online:e})=>t(e)),[]),e}function fZ(e,t=300){let[r,n]=(0,pY.useState)(e);return(0,pY.useEffect)(()=>{let r=setTimeout(()=>{n(e)},t);return()=>{clearTimeout(r)}},[e,t]),r}var fJ=r(1760),fX=r.n(fJ);let fQ=`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,t])=>`${e}:${t}`).join(",")}`;function f0(){let e=`${o$}/emrapi/configuration?v=${fQ}`,t=fX()(e,oF);return(0,pY.useMemo)(()=>({emrConfiguration:t.data?.data,isLoadingEmrConfiguration:t.isLoading,mutateEmrConfiguration:t.mutate,errorFetchingEmrConfiguration:t.error}),[t])}let f1=p6(dV());function f4(e){let t=fe(e);return(0,pY.useMemo)(()=>Object.fromEntries(t.map(e=>[e.name,e.meta])),[t])}let f3=p6(dZ());function f2(e){let{flags:t}=p3(dC);return t[e]?.enabled??!1}function f6(){let[,e]=(0,pY.useState)(0);return(0,pY.useCallback)(()=>{e(e=>e+1)},[])}function f5(e,t,r={}){return f9(e,t,f8,r)}let f8={getPaginatedUrl:(e,t,r)=>{if(!e)return null;{let n=new URL(oL(e.toString()),window.location.toString());return n.searchParams.set("limit",""+t),n.searchParams.set("startIndex",""+r),n.searchParams.set("totalCount","true"),n.toString()}},getNextUrl:e=>{let t=e?.links?.find(e=>"next"==e.rel)?.uri;if(!t)return null;{let e=new URL(t);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 f9(e,t,r,n={}){let{getPaginatedUrl:o,getTotalCount:i,getCurrentPageSize:a,getData:s}=r,{immutable:l,swrConfig:u}=n,c=n.fetcher??oF,[d,p]=(0,pY.useState)(1),f=(0,pY.useRef)(NaN),h=(0,pY.useRef)(NaN),m=(0,pY.useRef)(d),g=(0,pY.useRef)(!1),y=(0,pY.useRef)(!1),v=e?.toString()??"",[b,w]=(0,pY.useState)(v);v!==b&&(w(v),p(1),m.current=1,f.current=NaN,h.current=NaN,g.current=!1,y.current=!1);let x=(d-1)*t,E=(0,pY.useMemo)(()=>o(e,t,x),[e,t,x]),{data:S,...D}=(l?fX():fb.Ay)(E,c,u);S?.data&&(f.current=i(S?.data),h.current=a(S?.data),g.current=!0);let O=Math.ceil(f.current/t),k=(0,pY.useCallback)(e=>{if(!Number.isInteger(e)||e<1)return void console.warn(`useServerPagination: ignoring goTo(${e}); page must be a positive integer.`);let r=Math.ceil(f.current/t);!g.current||Number.isNaN(r)||e<=r?(m.current=e,p(e)):console.warn("Invalid attempt to go to out of bounds page: "+e)},[t]);(0,pY.useEffect)(()=>{if(!g.current)return;if(Number.isNaN(f.current)){y.current||(y.current=!0,console.warn(`useServerPagination: ${v} returned no total count, so out-of-range pages cannot be detected.`));return}let e=Math.max(1,Math.ceil(f.current/t));d>e&&(console.warn(`Invalid attempt to go to out of bounds page: ${d}; returning to page ${e}.`),m.current=e,p(e))},[d,t,v,S]);let P=(0,pY.useCallback)(()=>{k(m.current+1)},[k]),C=(0,pY.useCallback)(()=>{k(m.current-1)},[k]);return{data:s(S?.data),totalPages:O,totalCount:f.current,currentPage:d,currentPageSize:h.current,paginated:O>1,showNextButton:d<O,showPreviousButton:d>1,goTo:k,goToNext:P,goToPrevious:C,...D}}function f7(e,t,r={}){return f9(e,t,he(),r)}function he(){return{getPaginatedUrl:(e,t,r)=>{if(!e)return null;{let n=new URL(oL(e.toString()),window.location.toString());return n.searchParams.set("_count",""+t),n.searchParams.set("_getpagesoffset",""+r),n.toString()}},getNextUrl:e=>{let t=e?.link?.find(e=>"next"==e.relation)?.url;if(!t)return null;{let e=new URL(t);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 ht=r(9366),hr=r.n(ht);function hn(e,t={}){return ho(e,f8,t)}function ho(e,t,r={}){let{swrInfiniteConfig:n,immutable:o}=r,{getNextUrl:i,getTotalCount:a,getData:s}=t,l=r.fetcher??oF,u=(0,pY.useCallback)((r,n)=>0==r?e?.toString()??null:t.getNextUrl(n.data),[e]),{data:c,size:d,setSize:p,...f}=hr()(u,l,{...n,...o?{revalidateIfStale:!1,revalidateOnFocus:!1,revalidateOnReconnect:!1}:{}}),h=i(c?.[c.length-1].data),m=a(c?.[0]?.data);return{data:c?.flatMap(e=>s(e.data)),totalCount:m,hasMore:null!=h,loadMore:()=>{p((c?.length??0)+1)},nextUri:h,...f}}function hi(e,t={}){return ha(e,f8,t)}function ha(e,t,r={}){let n=ho(e,t,r),{hasMore:o,error:i,data:a,loadMore:s,isLoading:l,nextUri:u}=n;return((0,pY.useEffect)(()=>{o&&!i&&s()},[o,u]),r.partialData)?n:{...n,data:o||i?void 0:a,isLoading:l||o}}function hs(e,t={}){return ha(e,he(),t)}function hl(e,t={}){return ho(e,he(),t)}function hu(){let e="tablet";return document.body.classList.forEach(t=>{switch(t){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 hc(){let[e,t]=(0,pY.useState)(hu);return(0,pY.useEffect)(()=>{let e=()=>{t(hu())};return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),e}let hd=e=>"small-desktop"===e||"large-desktop"===e;function hp(e){let t=(0,pY.useContext)(pJ);(0,pY.useEffect)(()=>(t&&t.moduleName&&(e.componentContext=t),px(e),()=>{pE(e.name)}),[t,e])}function hf(){return p3(p_)}function hh(e=null,t=null){let[r,n]=(0,pY.useState)([]);return(0,pY.useEffect)(()=>{let r=cX(e,t).subscribe(e=>{n(e)},e=>{console.error(e)});return()=>r.unsubscribe()},[e,t]),r}function hm(e,t=!0){let r=(0,pY.useRef)(null);return(0,pY.useEffect)(()=>{let n=n=>{t&&r.current&&n.target&&n.target instanceof Node&&(r.current.contains(n.target)||e(n))};return window.addEventListener("mousedown",n),window.addEventListener("touchstart",n),()=>{window.removeEventListener("mousedown",n),window.removeEventListener("touchstart",n)}},[e,t]),r}function hg(e){let t=(0,pY.useRef)();return(0,pY.useEffect)(()=>{let r=new IntersectionObserver(t=>{for(let r of t)if(r.isIntersecting)return void e()},{threshold:1});return t.current&&r.observe(t.current),()=>{t.current&&r.unobserve(t.current)}},[t.current,e]),t}function hy(e,t={}){let{abortController:r,fetchInit:n,url:o,swrConfig:i}=t,a=fL(),s=(0,pY.useMemo)(()=>n?.signal??r?.signal??a.signal,[r?.signal,n?.signal,a.signal]),l=(0,pY.useCallback)(e=>oF(function(e,t){if(t)return"function"==typeof t?t(e):t;if("string"==typeof e)return e;throw Error(`When using useOpenmrsSWR with a key that is not a string, you must provide a url() function that converts the key to a valid url. The key for this hook is ${e}.`)}(e,o),{...n,signal:s}),[s,n,o]);return(0,fb.Ay)(e,l,i)}function hv(e=[],t=10){let[r,n]=(0,pY.useState)(1),o=(0,pY.useMemo)(()=>"number"==typeof t&&t>0?Math.max(1,Math.ceil(e.length/t)):1,[e.length,t]);r>o&&n(o);let i=Math.min(Math.max(1,r),o),a=(0,pY.useMemo)(()=>{let r=(i-1)*t,n=(i+0)*t;return e.slice(r,n)},[e,i,t]),s=(0,pY.useCallback)(e=>{!Number.isInteger(e)||e<1?console.warn(`usePagination: ignoring goTo(${e}); page must be a positive integer.`):n(e)},[]),l=(0,pY.useCallback)(()=>{n(e=>e+1)},[]),u=(0,pY.useCallback)(()=>{n(e=>Math.max(1,e-1))},[]);return(0,pY.useMemo)(()=>({results:a,totalPages:o,currentPage:i,paginated:e.length>t,showNextButton:i<o,showPreviousButton:i>1,goTo:s,goToNext:l,goToPrevious:u}),[a,o,e.length,t,i,s,l,u])}function hb(e,t,r,n){return{pageSizes:(0,pY.useMemo)(()=>{let r=Math.ceil(t/e);return isNaN(r)&&(r=0),[...Array(r).keys()].map(t=>(t+1)*e)},[e,t]),pageItemsCount:(0,pY.useMemo)(()=>e>t?t:e*r>t?e*(r-1)+n:e*r,[e,t,r,n])}}function hw(){let e=/\/patient\/([a-zA-Z0-9\-]+)\/?/.exec(location.pathname);return e&&e[1]}function h_(e){let[t,r]=(0,pY.useState)(e??hw()),{data:n,error:o,isValidating:i}=(0,fb.Ay)(t?["patient",t]:null,()=>cH(t,{}));return(0,pY.useEffect)(()=>{let e=()=>{let e=hw();e!==t&&r(e)};return window.addEventListener("single-spa:routing-event",e),()=>window.removeEventListener("single-spa:routing-event",e)},[t]),(0,pY.useMemo)(()=>({isLoading:i&&!o&&!n,patient:n,patientUuid:t,error:o}),[i,o,n,t])}function hx(){let e=`${o$}/metadatamapping/termmapping?v=custom:(metadataUuid)&code=emr.primaryIdentifierType`,{data:t,error:r,isLoading:n}=(0,fb.Ay)(e,oF);return(0,pY.useMemo)(()=>({primaryIdentifierCode:t?.data?.results[0]?.metadataUuid,isLoading:n,error:r}),[t,r,n])}function hE(e){let{extensions:t,extensionSlotModuleName:r}=ft(e);return e?t.map(t=>({state:n})=>pZ().createElement(pJ.Provider,{value:{moduleName:r,featureName:"",extension:{extensionId:t.id,extensionSlotName:e,extensionSlotModuleName:r}}},pZ().createElement(pQ,{state:n}))):[]}function hS(){let e=(0,pY.useRef)(),[t,r]=(0,pY.useState)(null),n=null;if(!t){if(s){let e=oz().getState();e.loaded&&(n=e.session)}else s=new Promise(t=>{let r=({loaded:r,session:o})=>{r&&(t(o),n=o,e.current&&(e.current(),e.current=void 0))};r(oz().getState()),n||(e.current=oz().subscribe(r))});if(n)r(n);else throw s}(0,pY.useEffect)(()=>(e.current||(e.current=oz().subscribe(({loaded:e,session:t})=>{e&&(n=t,r(t))})),()=>{e.current&&(e.current(),e.current=void 0)}),[]);let o=t||n;if(!o)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 o}let hD=({privilege:e,fallback:t,children:r})=>{let[n,o]=(0,pY.useState)(null);return((0,pY.useEffect)(()=>{let e=oK({includeAuthStatus:!1}).subscribe(o);return()=>e.unsubscribe()},[]),n&&oY(e,n))?pZ().createElement(pZ().Fragment,null,r):t?pZ().createElement(pZ().Fragment,null,t):null};var hO=r(2542),hk=r.n(hO),hP=r(7581);let hC=new Map;function hj(){for(let e of Array.from(hC.values()))e()}let hT={setVisitContext:(e,t)=>null==t?{manuallySetVisitUuid:null}:{manuallySetVisitUuid:t.uuid,patientUuid:t.patient?.uuid}};function hR(e){let t=(0,pY.useId)();return(0,pY.useEffect)(()=>{if(e)return hC.set(t,e),()=>{hC.delete(t)}},[t,e]),{...p2(c6(),hT),mutateVisit:hj}}function hA(e,t=c3){let r=(0,pY.useRef)(void 0),{patientUuid:n,manuallySetVisitUuid:o,setVisitContext:i}=hR((0,pY.useCallback)(()=>r.current?.(),[])),a=e&&n==e?o:null,s=`?patient=${e}&v=${t}&includeInactive=false`,l=`/${a}?v=${t}`,{data:u,error:c,mutate:d,isValidating:p}=(0,fb.Ay)(e?`${o$}/visit${s}`:null,oF),{data:f,error:h,mutate:m,isValidating:g}=(0,fb.Ay)(e&&a?`${o$}/visit${l}`:null,oF),y=(0,pY.useMemo)(()=>u?.data.results.find(e=>null===e.stopDatetime)??null,[u]),v=(0,pY.useMemo)(()=>a&&f?f.data:null,[f,a]),b=(0,pY.useRef)(null);(0,pY.useEffect)(()=>{!p&&y&&n===e&&null===o&&i(y),g||(b.current&&v&&b.current.uuid===v.uuid&&!b.current.stopDatetime&&v.stopDatetime&&i(null),b.current=v)},[v,o,y,p,g,n]);let w=(0,pY.useCallback)(()=>{d(),m()},[d,m]);(0,pY.useEffect)(()=>{r.current=w},[w]);let x=!!(!u||a&&!f),E=!!(a?h:c);return{error:c||h,mutate:w,isValidating:p||g,activeVisit:y,currentVisit:v,currentVisitIsRetrospective:!!a,isLoading:x&&!E}}function hN(){let[e,t]=(0,pY.useState)([]);return(0,pY.useEffect)(()=>{let e=c0().subscribe(e=>{t(e)},e=>console.error(e));return()=>e.unsubscribe()},[]),e}hk().extend(hP);let h$=new Map;async function hI(e,t){let r=t.indexOf("#"),n=r>=0,o=n?t.substring(0,r):e,i=n?t.substring(r+1):t,a=await at(o);return a&&Object.hasOwn(a,i)&&"function"==typeof a[i]?hL(o,a).then(()=>a[i]()):(a?a&&Object.hasOwn(a,i)?console.warn(`The export ${t}, defined in ${e}'s routes.json, is not a function`):console.warn(`${o} does not define a component called "${i}", referenced in ${e}'s routes.json. This cannot be loaded.`):console.warn(`Unknown app ${o} for ${t} defined in ${e}'s routes.json`),hM)}let hM={bootstrap:()=>Promise.resolve(),mount:()=>Promise.resolve(),unmount:()=>Promise.resolve()};async function hL(e,t){if(e in h$)await h$[e];else{let r=t??await at(e);await (h$[e]=new Promise((t,n)=>{if(Object.hasOwn(r,"startupApp")){let o=r.startupApp;if("function"==typeof o)return Promise.resolve(o()).then(()=>{r_(e),t(null)}).catch(n)}r_(e),t(null)}))}}function hF(e,t){let r=t.name;if(!r)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.`,t);t.slots&&t.slot&&console.warn(`The extension ${r} from ${e} declares both a 'slots' property and