@openmrs/esm-form-engine-app 12.3.5-pre.12249 → 12.3.5-pre.12254

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/810.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 r}let nB=(e,t)=>{let n=structuredClone(t);if(!e)return n;for(let t of Object.keys(e)){let r=n[t],o=e[t];if(o&&(o.hasOwnProperty("_type")||o.hasOwnProperty("_default"))){n.hasOwnProperty(t)||(n[t]=o._default);let e=o._elements;if(r&&nV(e)){if(o._type===tG.Array&&Array.isArray(r)){let o=r.map(t=>nB(e,t));n[t]=o}else if(o._type===tG.Object)for(let t of Object.keys(r))r[t]=nB(e,r[t])}}else if(nU(o)){let e=r??{};nU(e)&&(n[t]=nB(o,e))}}return n};function nV(e){return!!e&&Object.keys(e).filter(e=>!["_default","_validators"].includes(e)).length>0}function nU(e){return"object"==typeof e&&!Array.isArray(e)&&null!==e}let nW=new Set;function nK(e,t){let n=`${e}:::${t}`;nW||(nW=new Set),nW.has(n)||(console.error(t),nW.add(n))}function nz(e){e?nW.forEach(t=>{t.startsWith(e)&&nW.delete(t)}):nW.clear()}function nH(){nh.forEach(e=>e()),nh.length=0,nb.clear(),nC.clear(),nT.clear(),nj.clear(),ny()}let nG={"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(", ")}.`})]}},nq={"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}},...nG},nZ=(e,t)=>tq(n=>e<=n&&n<=t,`must be between ${e} and ${t}`),nY=e=>{let t=e.concat(["openmrsBase","openmrsSpaBase"]);return tq(e=>{if(!e||"string"!=typeof e)return!1;let n=/\${(.*?)}/g,r=n.exec(e);for(;r;){if(!t.includes(r[1]))return!1;r=n.exec(e)}return!0},"Should be a URL or path. The allowed template parameters are "+t.map(e=>"${"+e+"}").join(", "))},nJ=nY([]),nQ=e=>tq(t=>e.includes(t),`Must be one of the following: '${e.join("', '")}'.`),nX={inRange:nZ,isUrl:nJ,isUrlWithTemplateParameters:nY,oneOf:nQ};var n0=n(82034);let n1=Z("breadcrumbs",[]);function n2(e){return n4([e])}function n4(e){let t=[...n3(),...e.map(e=>({matcher:e.matcher instanceof RegExp?e.matcher:"string"==typeof e.matcher?(0,n0.pathToRegexp)(e.matcher).regexp:(0,n0.pathToRegexp)(e.path).regexp,settings:e}))];n1.setState(t,!0)}function n3(){return n1.getState()}function n6(e,t){if(t)return function(e,t){let[n]=e.filter(e=>e.matcher.test(t));return n}(e,t)||function(e,t){let n=t.split("/");for(;n.length>1;){n.pop();let t=n6(e,n.join("/"));if(t)return t}}(e,t)}function n5(e,t){if(e.length>0){let n=n6(e,t);if(n){let t=[n],r=n6(e,n.settings.parent);for(;void 0!==r;)t.push(r),r=n6(e,r.settings.parent);return t.reverse()}}return[]}function n7(e){return n5(n3(),e)}var n9=Object.freeze({__proto__:null,get start(){return ox},get ensureJQuerySupport(){return r7},get setBootstrapMaxTime(){return rU},get setMountMaxTime(){return rW},get setUnmountMaxTime(){return rK},get setUnloadMaxTime(){return rz},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 rQ},get patchHistoryApi(){return r3},get triggerAppChange(){return ob},get addErrorHandler(){return rr},get removeErrorHandler(){return ro},get mountRootParcel(){return r$},get NOT_LOADED(){return rs},get LOADING_SOURCE_CODE(){return rl},get NOT_BOOTSTRAPPED(){return ru},get BOOTSTRAPPING(){return rc},get NOT_MOUNTED(){return rd},get MOUNTING(){return rf},get UPDATING(){return rh},get LOAD_ERROR(){return rg},get MOUNTED(){return rp},get UNLOADING(){return ry},get UNMOUNTING(){return rm},get SKIP_BECAUSE_BROKEN(){return rb}}),n8=("u">typeof globalThis?globalThis:"u">typeof window?window:"u">typeof global?global:"u">typeof self?self:{}).CustomEvent,re=!function(){try{var e=new n8("cat",{detail:{foo:"bar"}});return"cat"===e.type&&"bar"===e.detail.foo}catch(e){}return!1}()?"u">typeof document&&"function"==typeof document.createEvent?function(e,t){var n=document.createEvent("CustomEvent");return t?n.initCustomEvent(e,t.bubbles,t.cancelable,t.detail):n.initCustomEvent(e,!1,!1,void 0),n}:function(e,t){var n=document.createEventObject();return n.type=e,t?(n.bubbles=!!t.bubbles,n.cancelable=!!t.cancelable,n.detail=t.detail):(n.bubbles=!1,n.cancelable=!1,n.detail=void 0),n}:n8;let rt=[];function rn(e,t,n){let r=ra(e,t,n);rt.length?rt.forEach(e=>e(r)):setTimeout(()=>{throw r})}function rr(e){if("function"!=typeof e)throw Error(ri(28,!1));rt.push(e)}function ro(e){if("function"!=typeof e)throw Error(ri(29,!1));let t=!1;return rt=rt.filter(n=>{let r=n===e;return t=t||r,!r}),t}function ri(e,t,...n){return`single-spa minified message #${e}: ${t?t+" ":""}See https://single-spa.js.org/error/?code=${e}${n.length?`&arg=${n.join("&arg=")}`:""}`}function ra(e,t,n){let r,o=`${rS(t)} '${r_(t)}' died in status ${t.status}: `;if(e instanceof Error){try{e.message=o+e.message}catch(e){}r=e}else{console.warn(ri(30,!1,t.status,r_(t)));try{r=Error(o+JSON.stringify(e))}catch(t){r=e}}return r.appOrParcelName=r_(t),t.status=n,r}let rs="NOT_LOADED",rl="LOADING_SOURCE_CODE",ru="NOT_BOOTSTRAPPED",rc="BOOTSTRAPPING",rd="NOT_MOUNTED",rf="MOUNTING",rp="MOUNTED",rh="UPDATING",rm="UNMOUNTING",ry="UNLOADING",rg="LOAD_ERROR",rb="SKIP_BECAUSE_BROKEN";function rv(e){return e.status===rp}function rw(e){try{return e.activeWhen(window.location)}catch(t){return rn(t,e,rb),!1}}function r_(e){return e.name}function rx(e){return!!e.unmountThisParcel}function rS(e){return rx(e)?"parcel":"application"}function rE(){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 rD(e,t){for(let n=0;n<e.length;n++)if(t(e[n]))return e[n];return null}function rO(e){return e&&("function"==typeof e||Array.isArray(e)&&!rD(e,e=>"function"!=typeof e))}function rk(e,t){let n=e[t]||[];0===(n=Array.isArray(n)?n:[n]).length&&(n=[()=>Promise.resolve()]);let r=rS(e),o=r_(e);return function(e){return n.reduce((n,i,a)=>n.then(()=>{let n=i(e);return rP(n)?n:Promise.reject(ri(15,!1,r,o,t,a))}),Promise.resolve())}}function rP(e){return e&&"function"==typeof e.then&&"function"==typeof e.catch}let rC=[];function rj(e,t){return Promise.resolve().then(()=>e.status!==ru?e:(e.status=rc,e.bootstrap?rH(e,"bootstrap").then(n).catch(n=>{if(t)throw ra(n,e,rb);return rn(n,e,rb),e}):Promise.resolve().then(n)));function n(){return e.status=rd,e}}function rT(e,t){return Promise.resolve().then(()=>{if(e.status!==rp)return e;return e.status=rm,Promise.all(Object.keys(e.parcels).map(t=>e.parcels[t].unmountThisParcel())).then(n,r=>n().then(()=>{let n=Error(r.message);if(t)throw ra(n,e,rb);rn(n,e,rb)})).then(()=>e);function n(){return rH(e,"unmount").then(()=>{e.status=rd},n=>{if(t)throw ra(n,e,rb);rn(n,e,rb)})}})}let rR=!1,rA=!1;function rN(e,t){return Promise.resolve().then(()=>e.status!==rd?e:(rR||(window.dispatchEvent(new re("single-spa:before-first-mount")),rR=!0),e.status=rf,rH(e,"mount").then(()=>(e.status=rp,rA||(window.dispatchEvent(new re("single-spa:first-mount")),rA=!0),e)).catch(n=>{return e.status=rp,rT(e,!0).then(r,r);function r(){if(t)throw ra(n,e,rb);return rn(n,e,rb),e}})))}let rM=0,rI={parcels:{}};function r$(){return rL.apply(rI,arguments)}function rL(e,t){let n,r,o,i=this;if(!e||"object"!=typeof e&&"function"!=typeof e)throw Error(ri(2,!1));if(e.name&&"string"!=typeof e.name)throw Error(ri(3,!1,typeof e.name));let a=rM++,s=e.name||`parcel-${a}`;if("object"!=typeof t)throw Error(ri(4,!1,s,typeof t));if(!t.domElement)throw Error(ri(5,!1,s));let l="function"==typeof e,u=l?e:()=>Promise.resolve(e),c={id:a,parcels:{},status:l?rl:ru,customProps:t,parentName:r_(i),unmountThisParcel:()=>p.then(()=>{if(c.status!==rp)throw Error(ri(6,!1,s,c.status));return rT(c,!0)}).then(e=>(c.parentName&&delete i.parcels[c.id],e)).then(e=>(r(e),e)).catch(e=>{throw c.status=rb,o(e),e})};i.parcels[a]=c;let d=u();if(!d||"function"!=typeof d.then)throw Error(ri(7,!1));let f=(d=d.then(e=>{if(!e)throw Error(ri(8,!1));if(s=e.name||`parcel-${a}`,Object.prototype.hasOwnProperty.call(e,"bootstrap")&&!rO(e.bootstrap))throw Error(ri(9,!1,s));if(!rO(e.mount))throw Error(ri(10,!1,s));if(!rO(e.unmount))throw Error(ri(11,!1,s));if(e.update&&!rO(e.update))throw Error(ri(12,!1,s));let t=rk(e,"bootstrap"),r=rk(e,"mount"),o=rk(e,"unmount");c.status=ru,c.name=s,c.bootstrap=t,c.mount=r,c.unmount=o,c.timeouts=rG(e.timeouts),e.update&&(c.update=rk(e,"update"),n.update=function(e){return c.customProps=e,rF(Promise.resolve().then(()=>{if(c.status!==rp)throw Error(ri(32,!1,r_(c)));return c.status=rh,rH(c,"update").then(()=>(c.status=rp,c)).catch(e=>{throw ra(e,c,rb)})}))})})).then(()=>rj(c,!0)),p=f.then(()=>rN(c,!0)),h=new Promise((e,t)=>{r=e,o=t});return n={mount:()=>rF(Promise.resolve().then(()=>{if(c.status!==rd)throw Error(ri(13,!1,s,c.status));return i.parcels[a]=c,rN(c)})),unmount:()=>rF(c.unmountThisParcel()),getStatus:()=>c.status,loadPromise:rF(d),bootstrapPromise:rF(f),mountPromise:rF(p),unmountPromise:rF(h)}}function rF(e){return e.then(()=>null)}function rB(e){let t=r_(e),n="function"==typeof e.customProps?e.customProps(t,window.location):e.customProps;("object"!=typeof n||null===n||Array.isArray(n))&&(n={},console.warn(ri(40,!1),t,n));let r=rE({},n,{name:t,mountParcel:rL.bind(e),singleSpa:n9});return rx(e)&&(r.unmountSelf=e.unmountThisParcel),r}let rV={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 rU(e,t,n){if("number"!=typeof e||e<=0)throw Error(ri(16,!1));rV.bootstrap={millis:e,dieOnTimeout:t,warningMillis:n||1e3}}function rW(e,t,n){if("number"!=typeof e||e<=0)throw Error(ri(17,!1));rV.mount={millis:e,dieOnTimeout:t,warningMillis:n||1e3}}function rK(e,t,n){if("number"!=typeof e||e<=0)throw Error(ri(18,!1));rV.unmount={millis:e,dieOnTimeout:t,warningMillis:n||1e3}}function rz(e,t,n){if("number"!=typeof e||e<=0)throw Error(ri(19,!1));rV.unload={millis:e,dieOnTimeout:t,warningMillis:n||1e3}}function rH(e,t){let n=e.timeouts[t],r=n.warningMillis,o=rS(e);return new Promise((i,a)=>{let s=!1,l=!1;e[t](rB(e)).then(e=>{s=!0,i(e)}).catch(e=>{s=!0,a(e)}),setTimeout(()=>c(1),r),setTimeout(()=>c(!0),n.millis);let u=ri(31,!1,t,o,r_(e),n.millis);function c(e){s||(!0===e?(l=!0,n.dieOnTimeout?a(Error(u)):console.error(u)):!l&&(console.warn(u),e*r+r<n.millis&&setTimeout(()=>c(e+1),r)))}})}function rG(e){let t={};for(let n in rV)t[n]=rE({},rV[n],e&&e[n]||{});return t}function rq(e){return Promise.resolve().then(()=>{let t,n;return e.loadPromise?e.loadPromise:e.status!==rs&&e.status!==rg?e:(e.status=rl,e.loadPromise=Promise.resolve().then(()=>{let r=e.loadApp(rB(e));if(!rP(r))throw n=!0,Error(ri(33,!1,r_(e)));return r.then(n=>{let r;e.loadErrorTime=null,"object"!=typeof(t=n)&&(r=34),Object.prototype.hasOwnProperty.call(t,"bootstrap")&&!rO(t.bootstrap)&&(r=35),rO(t.mount)||(r=36),rO(t.unmount)||(r=37);let o=rS(t);if(r){let n;try{n=JSON.stringify(t)}catch(e){}return console.error(ri(r,!1,o,r_(e),n),t),rn(void 0,e,rb),e}return t.devtools&&t.devtools.overlays&&(e.devtools.overlays=rE({},e.devtools.overlays,t.devtools.overlays)),e.status=ru,e.bootstrap=rk(t,"bootstrap"),e.mount=rk(t,"mount"),e.unmount=rk(t,"unmount"),e.unload=rk(t,"unload"),e.timeouts=rG(t.timeouts),delete e.loadPromise,e})}).catch(t=>{let r;return delete e.loadPromise,n?r=rb:(r=rg,e.loadErrorTime=(new Date).getTime()),rn(t,e,r),e}))})}let rZ="u">typeof window,rY={hashchange:[],popstate:[]},rJ=["hashchange","popstate"];function rQ(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(ri(14,!1));t=e.currentTarget.href,e.preventDefault()}let n=r6(window.location.href),r=r6(t);0===t.indexOf("#")?window.location.hash=r.hash:n.host!==r.host&&r.host?window.location.href=t:r.pathname===n.pathname&&r.search===n.search?window.location.hash=r.hash:window.history.pushState(null,null,t)}function rX(e){if(e){let t=e[0].type;rJ.indexOf(t)>=0&&rY[t].forEach(t=>{try{t.apply(this,e)}catch(e){setTimeout(()=>{throw e})}})}}function r0(){ov([],arguments)}function r1(e,t){return function(){let n=window.location.href,r=e.apply(this,arguments),i=window.location.href;return o&&n===i||window.dispatchEvent(function(e,t){let n;try{n=new PopStateEvent("popstate",{state:e})}catch(t){(n=document.createEvent("PopStateEvent")).initPopStateEvent("popstate",!1,!1,e)}return n.singleSpa=!0,n.singleSpaTrigger=t,n}(window.history.state,t)),r}}let r2=null,r4=!1;function r3(e){if(r4)throw Error(ri(43,!1));o=!e||!e.hasOwnProperty("urlRerouteOnly")||e.urlRerouteOnly,r4=!0,r2=window.history.replaceState,window.addEventListener("hashchange",r0),window.addEventListener("popstate",r0);let t=window.addEventListener,n=window.removeEventListener;window.addEventListener=function(e,n){if(!("function"==typeof n&&rJ.indexOf(e)>=0)||rD(rY[e],e=>e===n))return t.apply(this,arguments);rY[e].push(n)},window.removeEventListener=function(e,t){return"function"==typeof t&&rJ.indexOf(e)>=0&&(rY[e]=rY[e].filter(e=>e!==t)),n.apply(this,arguments)},window.history.pushState=r1(window.history.pushState,"pushState"),window.history.replaceState=r1(r2,"replaceState")}function r6(e){let t=document.createElement("a");return t.href=e,t}rZ&&(window.singleSpaNavigate?console.warn(ri(41,!1)):window.singleSpaNavigate=rQ);let r5=!1;function r7(e=window.jQuery){if(e||window.$&&window.$.fn&&window.$.fn.jquery&&(e=window.$),e&&!r5){let t=e.fn.on,n=e.fn.off;e.fn.on=function(e,n){return r9.call(this,t,window.addEventListener,e,n,arguments)},e.fn.off=function(e,t){return r9.call(this,n,window.removeEventListener,e,t,arguments)},r5=!0}}function r9(e,t,n,r,o){return"string"!=typeof n?e.apply(this,o):(n.split(/\s+/).forEach(e=>{rJ.indexOf(e)>=0&&(t(e,r),n=n.replace(e,""))}),""===n.trim()?this:e.apply(this,o))}let r8={};function oe(e){return Promise.resolve().then(()=>{let t=r8[r_(e)];if(!t)return e;if(e.status===rs)return ot(e,t),e;if(e.status===ry)return t.promise.then(()=>e);if(e.status!==rd&&e.status!==rg)return e;let n=e.status===rg?Promise.resolve():rH(e,"unload");return e.status=ry,n.then(()=>(ot(e,t),e)).catch(n=>(delete r8[r_(e)],delete e.bootstrap,delete e.mount,delete e.unmount,delete e.unload,rn(n,e,rb),t.reject(n),e))})}function ot(e,t){delete r8[r_(e)],delete e.bootstrap,delete e.mount,delete e.unmount,delete e.unload,e.status=rs,t.resolve()}function on(e,t,n,r){r8[r_(e)]={app:e,resolve:n,reject:r},Object.defineProperty(r8[r_(e)],"promise",{get:t})}let or=[];function oo(){return or.filter(rv).map(r_)}function oi(){return or.map(r_)}function oa(e){let t=rD(or,t=>r_(t)===e);return t?t.status:null}let os=!1;function ol(e,t,n,r){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(ri(39,!1));let t=["name","app","activeWhen","customProps"],n=Object.keys(e).reduce((e,n)=>t.indexOf(n)>=0?e:e.concat(n),[]);if(0!==n.length)throw Error(ri(38,!1,t.join(", "),n.join(", ")));if("string"!=typeof e.name||0===e.name.length||"object"!=typeof e.app&&"function"!=typeof e.app)throw Error(ri(20,!1));let r=e=>"string"==typeof e||"function"==typeof e;if(!(r(e.activeWhen)||Array.isArray(e.activeWhen)&&e.activeWhen.every(r)))throw Error(ri(24,!1));if(!op(e.customProps))throw Error(ri(22,!1))}(e),a.name=e.name,a.loadApp=e.app,a.activeWhen=e.activeWhen,a.customProps=e.customProps):(function(e,t,n,r){if("string"!=typeof e||0===e.length)throw Error(ri(20,!1));if(!t)throw Error(ri(23,!1));if("function"!=typeof n)throw Error(ri(24,!1));if(!op(r))throw Error(ri(22,!1))}(e,t,n,r),a.name=e,a.loadApp=t,a.activeWhen=n,a.customProps=r),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(ri(1,!1))},5e3)),-1!==oi().indexOf(l.name))throw Error(ri(21,!1,l.name));or.push(rE({loadErrorTime:null,status:rs,parcels:{},devtools:{overlays:{options:{},selectors:[]}}},l)),rZ&&(r7(),ov())}function ou(e=window.location){return or.filter(t=>t.activeWhen(e)).map(r_)}function oc(e){if(0===or.filter(t=>r_(t)===e).length)throw Error(ri(25,!1,e));return(rZ?od(e,{waitForUnmount:!1}):Promise.resolve()).then(()=>{let t=or.map(r_).indexOf(e);or.splice(t,1)})}function od(e,t={waitForUnmount:!1}){if("string"!=typeof e)throw Error(ri(26,!1));let n=rD(or,t=>r_(t)===e);if(!n)throw Error(ri(27,!1,e));let r=r8[r_(n)];if(t&&t.waitForUnmount){if(r)return r.promise;{let e=new Promise((t,r)=>{on(n,()=>e,t,r)});return e}}{let e;return r?(e=r.promise,of(n,r.resolve,r.reject)):e=new Promise((t,r)=>{on(n,()=>e,t,r),of(n,t,r)}),e}}function of(e,t,n){Promise.resolve().then(()=>{if(rD(ou(),t=>t===r_(e)))return ob()}).then(()=>rT(e).then(oe).then(()=>{t(),setTimeout(()=>{ov()})})).catch(n)}function op(e){return!e||"function"==typeof e||"object"==typeof e&&null!==e&&!Array.isArray(e)}function oh(e,t){let n=function(e,t){let n=0,r=!1,o="^";"/"!==e[0]&&(e="/"+e);for(let t=0;t<e.length;t++){let n=e[t],o=r&&"/"===n;(!r&&":"===n||o)&&i(t)}return i(e.length),RegExp(o,"i");function i(i){let a=e.slice(n,i).replace(/[|\\{}()[\]^$+*?.]/g,"\\$&");if(o+=r?"[^/]+/?":a,i===e.length)if(r)t&&(o+="$");else{let e=t?"":".*";o="/"===o.charAt(o.length-1)?`${o}${e}$`:`${o}(/${e})?(#.*)?$`}r=!r,n=i}}(e,t);return e=>{let t=e.origin;t||(t=`${e.protocol}//${e.host}`);let r=e.href.replace(t,"").replace(e.search,"").split("?")[0];return n.test(r)}}let om=!1,oy=[],og=rZ&&window.location.href;function ob(){return ov()}function ov(e=[],t,n=!1){let r,o,i,a,s;if(om)return new Promise((e,n)=>{oy.push({resolve:e,reject:n,eventArguments:t})});let{appsToUnload:l,appsToUnmount:u,appsToLoad:c,appsToMount:d}=(r=[],o=[],i=[],a=[],s=(new Date).getTime(),or.forEach(e=>{let t=e.status!==rb&&rw(e);switch(e.status){case rg:t&&s-e.loadErrorTime>=200&&i.push(e);break;case rs:case rl:t&&i.push(e);break;case ru:case rd:!t&&r8[r_(e)]?r.push(e):t&&a.push(e);break;case rp:t||o.push(e)}}),{appsToUnload:r,appsToUnmount:o,appsToLoad:i,appsToMount:a}),f,p=[],h=og,m=og=window.location.href;return o_?(om=!0,f=l.concat(c,u,d),Promise.resolve().then(()=>(w(0===f.length?"before-no-app-change":"before-app-change",v(!0)),w("before-routing-event",v(!0,{cancelNavigation:y})),Promise.all(p).then(n=>{if(n.some(e=>e))return r2.call(window.history,history.state,"",h.substring(location.origin.length)),og=location.href,om=!1,ov(e,t,!0);let r=l.map(oe),o=Promise.all(u.map(rT).map(e=>e.then(oe)).concat(r));o.then(()=>{w("before-mount-routing-event",v(!0))},e=>{throw e});let i=c.map(e=>rq(e).then(e=>ow(e,o))),a=d.filter(e=>0>c.indexOf(e)).map(e=>ow(e,o));return o.catch(e=>{throw b(),e}).then(()=>(b(),Promise.all(i.concat(a)).catch(t=>{throw e.forEach(e=>e.reject(t)),t}).then(g).then(()=>{},e=>{throw e})))})))):(f=c,Promise.resolve().then(()=>Promise.all(c.map(rq)).then(b).then(()=>[]).catch(e=>{throw b(),e}).finally(()=>{})));function y(e=!0){let t="function"==typeof(null==e?void 0:e.then)?e:Promise.resolve(e);p.push(t.catch(e=>(console.warn(Error(ri(42,!1))),console.warn(e),!1)))}function g(){let t=oo();e.forEach(e=>e.resolve(t));try{w(0===f.length?"no-app-change":"app-change",v()),w("routing-event",v())}catch(e){setTimeout(()=>{throw e})}if(om=!1,oy.length>0){let e=oy;oy=[],ov(e)}return t}function b(){n||(e.forEach(e=>{rX(e.eventArguments)}),rX(t))}function v(e=!1,n){let r={},o={[rp]:[],[rd]:[],[rs]:[],[rb]:[]};e?(c.concat(d).forEach((e,t)=>{a(e,rp)}),l.forEach(e=>{a(e,rs)}),u.forEach(e=>{a(e,rd)})):f.forEach(e=>{a(e)});let i={detail:{newAppStatuses:r,appsByNewStatus:o,totalAppChanges:f.length,originalEvent:null==t?void 0:t[0],oldUrl:h,newUrl:m}};return n&&rE(i.detail,n),i;function a(e,t){let n=r_(e);t=t||oa(n),r[n]=t,(o[t]=o[t]||[]).push(n)}}function w(e,t){n||window.dispatchEvent(new re(`single-spa:${e}`,t))}}function ow(e,t){return rw(e)?rj(e).then(e=>t.then(()=>rw(e)?rN(e):e)):t.then(()=>e)}let o_=!1;function ox(e){o_=!0,rZ&&(r3(e),ov())}function oS(e,t){let n=window.getOpenmrsSpaBase().replace(/\/$/,"");return oE(e,{openmrsBase:window.openmrsBase,openmrsSpaBase:n,...t}).replace(/^\/\//,"/")}function oE(e,t){return Object.keys(t).reduce((e,n)=>e.split("${"+n+"}").join(t[n]),e)}function oD({to:e,templateParams:t}){let n=window.getOpenmrsSpaBase().replace(/\/$/,""),r=oS(e,t).replace(window.location.origin,"");r.startsWith(n)?rQ(r):window.location.assign(r)}rZ&&window.__SINGLE_SPA_DEVTOOLS__&&(window.__SINGLE_SPA_DEVTOOLS__.exposedMethods={getRawAppData:function(){return[...or]},reroute:ov,NOT_LOADED:rs,toLoadPromise:rq,toBootstrapPromise:rj,unregisterApplication:oc,getProfilerData:function(){return rC}});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(),n=t.lastIndexOf(e);if(-1!=n){let e=t.slice(0,n+1);oD({to:t[n]}),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:[nX.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:[nX.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,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}let oM="/ws/rest/v1",oI="/ws/fhir2/R4",o$=`${oM}/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 n=oL(e);if(t.headers||(t.headers={}),eD(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(oM)&&void 0===t.headers["Disable-WWW-Authenticate"]&&(t.headers["Disable-WWW-Authenticate"]="true"),e.startsWith(oI)){let e=new URL(n,window.location.toString());e.searchParams.has("_summary")||(e.searchParams.set("_summary","data"),n=e.toString())}let r=Error();return window.fetch(n,t).then(async e=>{let{redirectAuthFailure:t,followRedirects:o}=await nO("@openmrs/esm-api");if(e.ok){let t=e.headers.get("location");return(o&&t&&(n===oL(o$)||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 n===oL(o$)&&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(n,e,o,r)},t=>{throw new oV(n,e,null,r)})})}function oB(e,t={}){if("object"!=typeof t)throw Error("The second argument to openmrsObservableFetch must be either omitted or an object");let n=new AbortController;return t.signal=n.signal,new eg.c(r=>{let o=!1;return oF(e,t).then(e=>{o=!0,r.next(e),r.complete()},e=>{o=!0,r.error(e)}),()=>{o||n.abort()}})}class oV extends Error{constructor(e,t,n,r){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`,r.message=this.message,this.responseBody=n,this.response=t,this.stack=`Stacktrace for outgoing request:
13
13
  ${r.stack}
14
14
  Stacktrace for incoming response:
15
- ${this.stack}`}}let oU=Z("session",{loaded:!1,session:null}),oW=0;function oK(e={includeAuthStatus:!0}){return(oW<Date.now()-6e4||!oU.getState().loaded)&&oG(),new eg.c(t=>{let n=n=>{n.loaded&&(e.includeAuthStatus?t.next(n.session):t.next(n.session?.user))};return n(oU.getState()),oU.subscribe(n)})}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 n={};return e&&t&&(n.Authorization=`Basic ${window.btoa(`${e}:${t}`)}`),o0(oF(o$,{headers:n}))}function oq(){oU.setState({loaded:!0,session:{authenticated:!1,sessionId:""}})}function oZ(e,t){var n,r;if(void 0===t)return!e;if(!e)return!0;return n=e,r=t,("string"==typeof n?!ee(r.privileges.find(e=>n===e.display)):Array.isArray(n)?n.every(e=>!ee(r.privileges.find(t=>e===t.display))):(ee(n)||console.error(`Could not understand privileges "${n}"`),!0))||!ee(t.roles.find(e=>"System Developer"===e.display))}function oY(){let e,t;return new Promise(n=>{let r=r=>{r.loaded&&r.session.user&&(e=r.session.user,n(r.session.user),t&&t())};r(oU.getState()),e||(t=oU.subscribe(r))})}function oJ(){return new Promise((e,t)=>{oK().subscribe(t=>{e(t.sessionLocation)},t).unsubscribe()})}async function oQ(e,t){return o0(oF(o$,{method:"POST",body:{sessionLocation:e},headers:{"Content-Type":"application/json"},signal:t.signal}))}async function oX(e,t,n){return n||(n=new AbortController),await oF(`${oM}/user/${e}`,{method:"POST",body:{userProperties:t},headers:{"Content-Type":"application/json"},signal:n.signal}),oG()}function o0(e){return new Promise((t,n)=>{e.then(e=>{let r;"object"==typeof e?.data?(r={loaded:!0,session:e.data},oU.setState(r),t(r)):(r={loaded:!1,session:null},oU.setState(r),n(r))}).catch(e=>{I(`Failed to fetch new session information: ${e}`);let t={loaded:!1,session:null};oU.setState(t),n(t)})})}function o1(){return"development"===window.spaEnv||"true"===localStorage.getItem("openmrs:devtools")}oU.subscribe(e=>{e.loaded&&e.session&&oH(e.session)});let o2={"webservices.rest":"2.24.0",fhir2:"1.0.0-SNAPSHOT"};function o4(){nv("@openmrs/esm-api",oA),oG()}let o3={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,n=new Promise((n,r)=>{e=n,t=r});return n.resolve=e,n.reject=t,n},o7=e=>null==e?"":""+e,o9=/###/g,o8=e=>e&&e.indexOf("###")>-1?e.replace(o9,"."):e,ie=e=>!e||o6(e),it=(e,t,n)=>{let r=o6(t)?t.split("."):t,o=0;for(;o<r.length-1;){if(ie(e))return{};let t=o8(r[o]);!e[t]&&n&&(e[t]=new n),e=Object.prototype.hasOwnProperty.call(e,t)?e[t]:{},++o}return ie(e)?{}:{obj:e,k:o8(r[o])}},ir=(e,t,n)=>{let{obj:r,k:o}=it(e,t,Object);if(void 0!==r||1===t.length){r[o]=n;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}`]=n},io=(e,t)=>{let{obj:n,k:r}=it(e,t);if(n&&Object.prototype.hasOwnProperty.call(n,r))return n[r]},ii=(e,t,n)=>{for(let r in t)"__proto__"!==r&&"constructor"!==r&&(r in e?o6(e[r])||e[r]instanceof String||o6(t[r])||t[r]instanceof String?n&&(e[r]=t[r]):ii(e[r],t[r],n):e[r]=t[r]);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 n=new RegExp(e);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(e,n),this.regExpQueue.push(e),n}}(20),ic=(e,t,n=".")=>{if(!e)return;if(e[t]){if(!Object.prototype.hasOwnProperty.call(e,t))return;return e[t]}let r=t.split(n),o=e;for(let e=0;e<r.length;){let t;if(!o||"object"!=typeof o)return;let i="";for(let a=e;a<r.length;++a)if(a!==e&&(i+=n),i+=r[a],void 0!==(t=o[i])){if(["string","number","boolean"].indexOf(typeof t)>-1&&a<r.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,n,r){return r&&!this.debug?null:(o6(e[0])&&(e[0]=`${n}${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 iy{constructor(){this.observers={}}on(e,t){return e.split(" ").forEach(e=>{this.observers[e]||(this.observers[e]=new Map);let n=this.observers[e].get(t)||0;this.observers[e].set(t,n+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,n])=>{for(let r=0;r<n;r++)e(...t)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(([n,r])=>{for(let o=0;o<r;o++)n.apply(n,[e,...t])})}}class ig extends iy{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,n,r={}){let o,i=void 0!==r.keySeparator?r.keySeparator:this.options.keySeparator,a=void 0!==r.ignoreJSONStructure?r.ignoreJSONStructure:this.options.ignoreJSONStructure;e.indexOf(".")>-1?o=e.split("."):(o=[e,t],n&&(Array.isArray(n)?o.push(...n):o6(n)&&i?o.push(...n.split(i)):o.push(n)));let s=io(this.data,o);return(!s&&!t&&!n&&e.indexOf(".")>-1&&(e=o[0],t=o[1],n=o.slice(2).join(".")),!s&&a&&o6(n))?ic(this.data?.[e]?.[t],n,i):s}addResource(e,t,n,r,o={silent:!1}){let i=void 0!==o.keySeparator?o.keySeparator:this.options.keySeparator,a=[e,t];n&&(a=a.concat(i?n.split(i):n)),e.indexOf(".")>-1&&(a=e.split("."),r=t,t=a[1]),this.addNamespaces(t),ir(this.data,a,r),o.silent||this.emit("added",e,t,n,r)}addResources(e,t,n,r={silent:!1}){for(let r in n)(o6(n[r])||Array.isArray(n[r]))&&this.addResource(e,t,r,n[r],{silent:!0});r.silent||this.emit("added",e,t,n)}addResourceBundle(e,t,n,r,o,i={silent:!1,skipCopy:!1}){let a=[e,t];e.indexOf(".")>-1&&(a=e.split("."),r=n,n=t,t=a[1]),this.addNamespaces(t);let s=io(this.data,a)||{};i.skipCopy||(n=JSON.parse(JSON.stringify(n))),r?ii(s,n,o):s={...s,...n},ir(this.data,a,s),i.silent||this.emit("added",e,t,n)}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 ib={processors:{},addPostProcessor(e){this.processors[e.name]=e},handle(e,t,n,r,o){return e.forEach(e=>{t=this.processors[e]?.process(t,n,r,o)??t}),t}};let iv=Symbol("i18next/PATH_KEY");function iw(e,t){let n,r,o,{[iv]:i}=e((r=[],(o=Object.create(null)).get=(e,t)=>(n?.revoke?.(),t===iv)?r:(r.push(t),(n=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 iS extends iy{constructor(e,t={}){super(),((e,t,n)=>{e.forEach(e=>{t[e]&&(n[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 n={...t};if(null==e)return!1;let r=this.resolve(e,n);if(r?.res===void 0)return!1;let o=ix(r.res);return!1!==n.returnObjects||!o}extractFromKey(e,t){let n=void 0!==t.nsSeparator?t.nsSeparator:this.options.nsSeparator;void 0===n&&(n=":");let r=void 0!==t.keySeparator?t.keySeparator:this.options.keySeparator,o=t.ns||this.options.defaultNS||[],i=n&&e.indexOf(n)>-1,a=!this.options.userDefinedKeySeparator&&!t.keySeparator&&!this.options.userDefinedNsSeparator&&!t.nsSeparator&&!((e,t,n)=>{t=t||"",n=n||"";let r=il.filter(e=>0>t.indexOf(e)&&0>n.indexOf(e));if(0===r.length)return!0;let o=iu.getRegExp(`(${r.map(e=>"?"===e?"\\?":e).join("|")})`),i=!o.test(e);if(!i){let t=e.indexOf(n);t>0&&!o.test(e.substring(0,t))&&(i=!0)}return i})(e,n,r);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(n);(n!==r||n===r&&this.options.ns.indexOf(i[0])>-1)&&(o=i.shift()),e=i.join(r)}return{key:e,namespaces:o6(o)?[o]:o}}translate(e,t,n){let r="object"==typeof t?{...t}:t;if("object"!=typeof r&&this.options.overloadTranslationOptionHandler&&(r=this.options.overloadTranslationOptionHandler(arguments)),"object"==typeof r&&(r={...r}),r||(r={}),null==e)return"";"function"==typeof e&&(e=iw(e,{...this.options,...r})),Array.isArray(e)||(e=[String(e)]);let o=void 0!==r.returnDetails?r.returnDetails:this.options.returnDetails,i=void 0!==r.keySeparator?r.keySeparator:this.options.keySeparator,{key:a,namespaces:s}=this.extractFromKey(e[e.length-1],r),l=s[s.length-1],u=void 0!==r.nsSeparator?r.nsSeparator:this.options.nsSeparator;void 0===u&&(u=":");let c=r.lng||this.language,d=r.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(r)}:`${l}${u}${a}`:o?{res:a,usedKey:a,exactUsedKey:a,usedLng:c,usedNS:l,usedParams:this.getUsedParamsDetails(r)}:a;let f=this.resolve(e,r),p=f?.res,h=f?.usedKey||a,m=f?.exactUsedKey||a,y=void 0!==r.joinArrays?r.joinArrays:this.options.joinArrays,g=!this.i18nFormat||this.i18nFormat.handleAsObject,b=void 0!==r.count&&!o6(r.count),v=iS.hasDefaultValue(r),w=b?this.pluralResolver.getSuffix(c,r.count,r):"",x=r.ordinal&&b?this.pluralResolver.getSuffix(c,r.count,{ordinal:!1}):"",S=b&&!r.ordinal&&0===r.count,E=S&&r[`defaultValue${this.options.pluralSeparator}zero`]||r[`defaultValue${w}`]||r[`defaultValue${x}`]||r.defaultValue,D=p;g&&!p&&v&&(D=E);let O=ix(D),k=Object.prototype.toString.apply(D);if(g&&D&&O&&0>["[object Number]","[object Function]","[object RegExp]"].indexOf(k)&&!(o6(y)&&Array.isArray(D))){if(!r.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,{...r,ns:s}):`key '${a} (${this.language})' returned an object instead of string.`;return o?(f.res=e,f.usedParams=this.getUsedParamsDetails(r),f):e}if(i){let e=Array.isArray(D),t=e?[]:{},n=e?m:h;for(let e in D)if(Object.prototype.hasOwnProperty.call(D,e)){let o=`${n}${i}${e}`;v&&!p?t[e]=this.translate(o,{...r,defaultValue:ix(E)?E[e]:void 0,...{joinArrays:!1,ns:s}}):t[e]=this.translate(o,{...r,joinArrays:!1,ns:s}),t[e]===o&&(t[e]=D[e])}p=t}}else if(g&&o6(y)&&Array.isArray(p))(p=p.join(y))&&(p=this.extendTranslation(p,e,r,n));else{let t=!1,o=!1;!this.isValidLookup(p)&&v&&(t=!0,p=E),this.isValidLookup(p)||(o=!0,p=a);let s=(r.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&o?void 0:p,d=v&&E!==p&&this.options.updateMissing;if(o||t||d){if(this.logger.log(d?"updateKey":"missingKey",c,l,a,d?E:p),i){let e=this.resolve(a,{...r,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,r.lng||this.language);if("fallback"===this.options.saveMissingTo&&t&&t[0])for(let n=0;n<t.length;n++)e.push(t[n]);else"all"===this.options.saveMissingTo?e=this.languageUtils.toResolveHierarchy(r.lng||this.language):e.push(r.lng||this.language);let n=(e,t,n)=>{let o=v&&n!==p?n:s;this.options.missingKeyHandler?this.options.missingKeyHandler(e,l,t,o,d,r):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(e,l,t,o,d,r),this.emit("missingKey",e,l,t,p)};this.options.saveMissing&&(this.options.saveMissingPlurals&&b?e.forEach(e=>{let t=this.pluralResolver.getSuffixes(e,r);S&&r[`defaultValue${this.options.pluralSeparator}zero`]&&0>t.indexOf(`${this.options.pluralSeparator}zero`)&&t.push(`${this.options.pluralSeparator}zero`),t.forEach(t=>{n([e],a+t,r[`defaultValue${t}`]||E)})}):n(e,a,E))}p=this.extendTranslation(p,e,r,f,n),o&&p===a&&this.options.appendNamespaceToMissingKey&&(p=`${l}${u}${a}`),(o||t)&&this.options.parseMissingKeyHandler&&(p=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${l}${u}${a}`:a,t?p:void 0,r))}return o?(f.res=p,f.usedParams=this.getUsedParamsDetails(r),f):p}extendTranslation(e,t,n,r,o){if(this.i18nFormat?.parse)e=this.i18nFormat.parse(e,{...this.options.interpolation.defaultVariables,...n},n.lng||this.language||r.usedLng,r.usedNS,r.usedKey,{resolved:r});else if(!n.skipInterpolation){let i;n.interpolation&&this.interpolator.init({...n,...{interpolation:{...this.options.interpolation,...n.interpolation}}});let a=o6(e)&&(n?.interpolation?.skipOnVariables!==void 0?n.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);if(a){let t=e.match(this.interpolator.nestingRegexp);i=t&&t.length}let s=n.replace&&!o6(n.replace)?n.replace:n;if(this.options.interpolation.defaultVariables&&(s={...this.options.interpolation.defaultVariables,...s}),e=this.interpolator.interpolate(e,s,n.lng||this.language||r.usedLng,n),a){let t=e.match(this.interpolator.nestingRegexp);i<(t&&t.length)&&(n.nest=!1)}!n.lng&&r&&r.res&&(n.lng=this.language||r.usedLng),!1!==n.nest&&(e=this.interpolator.nest(e,(...e)=>o?.[0]!==e[0]||n.context?this.translate(...e,t):(this.logger.warn(`It seems you are nesting recursively key: ${e[0]} in key: ${t[0]}`),null),n)),n.interpolation&&this.interpolator.reset()}let i=n.postProcess||this.options.postProcess,a=o6(i)?[i]:i;return null!=e&&a?.length&&!1!==n.applyPostProcessor&&(e=ib.handle(a,e,t,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...r,usedParams:this.getUsedParamsDetails(n)},...n}:n,this)),e}resolve(e,t={}){let n,r,o,i,a;return o6(e)&&(e=[e]),e.forEach(e=>{if(this.isValidLookup(n))return;let s=this.extractFromKey(e,t),l=s.key;r=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,f=void 0!==t.context&&(o6(t.context)||"number"==typeof t.context)&&""!==t.context,p=t.lngs?t.lngs:this.languageUtils.toResolveHierarchy(t.lng||this.language,t.fallbackLng);u.forEach(e=>{this.isValidLookup(n)||(a=e,!i_[`${p[0]}-${e}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(a)&&(i_[`${p[0]}-${e}`]=!0,this.logger.warn(`key "${r}" for languages "${p.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!!!")),p.forEach(r=>{let a;if(this.isValidLookup(n))return;i=r;let s=[l];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(s,l,r,e,t);else{let e;c&&(e=this.pluralResolver.getSuffix(r,t.count,t));let n=`${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+n)),f){let r=`${l}${this.options.contextSeparator||"_"}${t.context}`;s.push(r),c&&(t.ordinal&&0===e.indexOf(o)&&s.push(r+e.replace(o,this.options.pluralSeparator)),s.push(r+e),d&&s.push(r+n))}}for(;a=s.pop();)this.isValidLookup(n)||(o=a,n=this.getResource(r,e,a,t))}))})}),{res:n,usedKey:r,exactUsedKey:o,usedLng:i,usedNS:a}}isValidLookup(e){return void 0!==e&&!(!this.options.returnNull&&null===e)&&!(!this.options.returnEmptyString&&""===e)}getResource(e,t,n,r={}){return this.i18nFormat?.getResource?this.i18nFormat.getResource(e,t,n,r):this.resourceStore.getResource(e,t,n,r)}getUsedParamsDetails(e={}){let t=e.replace&&!o6(e.replace),n=t?e.replace:e;if(t&&void 0!==e.count&&(n.count=e.count),this.options.interpolation.defaultVariables&&(n={...this.options.interpolation.defaultVariables,...n}),!t)for(let e of(n={...n},["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"]))delete n[e];return n}static hasDefaultValue(e){let t="defaultValue";for(let n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t===n.substring(0,t.length)&&void 0!==e[n])return!0;return!1}}class iE{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 n=this.formatLanguageCode(e);(!this.options.supportedLngs||this.isSupportedCode(n))&&(t=n)}),!t&&this.options.supportedLngs&&e.forEach(e=>{if(t)return;let n=this.getScriptPartFromCode(e);if(this.isSupportedCode(n))return t=n;let r=this.getLanguagePartFromCode(e);if(this.isSupportedCode(r))return t=r;t=this.options.supportedLngs.find(e=>{if(e===r||!(0>e.indexOf("-")&&0>r.indexOf("-"))&&(e.indexOf("-")>0&&0>r.indexOf("-")&&e.substring(0,e.indexOf("-"))===r||0===e.indexOf(r)&&r.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 n=e[t];return n||(n=e[this.getScriptPartFromCode(t)]),n||(n=e[this.formatLanguageCode(t)]),n||(n=e[this.getLanguagePartFromCode(t)]),n||(n=e.default),n||[]}toResolveHierarchy(e,t){let n=this.getFallbackCodes((!1===t?[]:t)||this.options.fallbackLng||[],e),r=[],o=e=>{e&&(this.isSupportedCode(e)?r.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)),n.forEach(e=>{0>r.indexOf(e)&&o(this.formatLanguageCode(e))}),r}}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 n,r=id("dev"===e?"en":e),o=t.ordinal?"ordinal":"cardinal",i=JSON.stringify({cleanedCode:r,type:o});if(i in this.pluralRulesCache)return this.pluralRulesCache[i];try{n=new Intl.PluralRules(r,{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 r=this.languageUtils.getLanguagePartFromCode(e);n=this.getRule(r,t)}return this.pluralRulesCache[i]=n,n}needsPlural(e,t={}){let n=this.getRule(e,t);return n||(n=this.getRule("dev",t)),n?.resolvedOptions().pluralCategories.length>1}getPluralFormsOfKey(e,t,n={}){return this.getSuffixes(e,n).map(e=>`${t}${e}`)}getSuffixes(e,t={}){let n=this.getRule(e,t);return(n||(n=this.getRule("dev",t)),n)?n.resolvedOptions().pluralCategories.sort((e,t)=>iD[e]-iD[t]).map(e=>`${this.options.prepend}${t.ordinal?`ordinal${this.options.prepend}`:""}${e}`):[]}getSuffix(e,t,n={}){let r=this.getRule(e,n);return r?`${this.options.prepend}${n.ordinal?`ordinal${this.options.prepend}`:""}${r.select(t)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix("dev",t,n))}}let iP=(e,t,n,r=".",o=!0)=>{let i,a=void 0!==(i=io(e,n))?i:io(t,n);return!a&&o&&o6(n)&&void 0===(a=ic(e,n,r))&&(a=ic(t,n,r)),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:n,useRawValueToEscape:r,prefix:o,prefixEscaped:i,suffix:a,suffixEscaped:s,formatSeparator:l,unescapeSuffix:u,unescapePrefix:c,nestingPrefix:d,nestingPrefixEscaped:f,nestingSuffix:p,nestingSuffixEscaped:h,nestingOptionsSeparator:m,maxReplaces:y,alwaysFormat:g}=e.interpolation;this.escape=void 0!==t?t:is,this.escapeValue=void 0===n||n,this.useRawValueToEscape=void 0!==r&&r,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,"\\$&"):f||"$t(".replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),this.nestingSuffix=p?p.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"):h||")".replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),this.nestingOptionsSeparator=m||",",this.maxReplaces=y||1e3,this.alwaysFormat=void 0!==g&&g,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,n,r){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,n,{...r,...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,n,{...r,...t,interpolationkey:i})};this.resetRegExp();let u=r?.missingInterpolationHandler||this.options.missingInterpolationHandler,c=r?.interpolation?.skipOnVariables!==void 0?r.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 n=o[1].trim();if(void 0===(i=l(n)))if("function"==typeof u){let t=u(e,o,r);i=o6(t)?t:""}else if(r&&Object.prototype.hasOwnProperty.call(r,n))i="";else if(c){i=o[0];continue}else this.logger.warn(`missed to pass in variable ${n} for interpolating ${e}`),i="";else o6(i)||this.useRawValueToEscape||(i=o7(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,n={}){let r,o,i,a=(e,t)=>{let n=this.nestingOptionsSeparator;if(0>e.indexOf(n))return e;let r=e.split(RegExp(`${n}[ ]*{`)),o=`{${r[1]}`;e=r[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}${n}${o}`}return i.defaultValue&&i.defaultValue.indexOf(this.prefix)>-1&&delete i.defaultValue,e};for(;r=this.nestingRegexp.exec(e);){let s=[];(i=(i={...n}).replace&&!o6(i.replace)?i.replace:i).applyPostProcessor=!1,delete i.defaultValue;let l=/{.*}/.test(r[1])?r[1].lastIndexOf("}")+1:r[1].indexOf(this.formatSeparator);if(-1!==l&&(s=r[1].slice(l).split(this.formatSeparator).map(e=>e.trim()).filter(Boolean),r[1]=r[1].slice(0,l)),(o=t(a.call(this,r[1].trim(),i),i))&&r[0]===e&&!o6(o))return o;o6(o)||(o=o7(o)),o||(this.logger.warn(`missed to resolve ${r[1]} for nesting ${e}`),o=""),s.length&&(o=s.reduce((e,t)=>this.format(e,t,n.lng,{...n,interpolationkey:r[1].trim()}),o.trim())),e=e.replace(r[0],o),this.regexp.lastIndex=0}return e}}let ij=e=>{let t={};return(n,r,o)=>{let i=o;o&&o.interpolationkey&&o.formatParams&&o.formatParams[o.interpolationkey]&&o[o.interpolationkey]&&(i={...i,[o.interpolationkey]:void 0});let a=r+JSON.stringify(i),s=t[a];return s||(s=e(id(r),o),t[a]=s),s(n)}},iT=e=>(t,n,r)=>e(id(n),r)(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 n=t.cacheInBuiltFormats?ij:iT;this.formats={number:n((e,t)=>{let n=new Intl.NumberFormat(e,{...t});return e=>n.format(e)}),currency:n((e,t)=>{let n=new Intl.NumberFormat(e,{...t,style:"currency"});return e=>n.format(e)}),datetime:n((e,t)=>{let n=new Intl.DateTimeFormat(e,{...t});return e=>n.format(e)}),relativetime:n((e,t)=>{let n=new Intl.RelativeTimeFormat(e,{...t});return e=>n.format(e,t.range||"day")}),list:n((e,t)=>{let n=new Intl.ListFormat(e,{...t});return e=>n.format(e)})}}add(e,t){this.formats[e.toLowerCase().trim()]=t}addCached(e,t){this.formats[e.toLowerCase().trim()]=ij(t)}format(e,t,n,r={}){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(),n={};if(e.indexOf("(")>-1){let r=e.split("(");t=r[0].toLowerCase().trim();let o=r[1].substring(0,r[1].length-1);"currency"===t&&0>o.indexOf(":")?n.currency||(n.currency=o.trim()):"relativetime"===t&&0>o.indexOf(":")?n.range||(n.range=o.trim()):o.split(";").forEach(e=>{if(e){let[t,...r]=e.split(":"),o=r.join(":").trim().replace(/^'+|'+$/g,""),i=t.trim();n[i]||(n[i]=o),"false"===o&&(n[i]=!1),"true"===o&&(n[i]=!0),isNaN(o)||(n[i]=parseInt(o,10))}})}return{formatName:t,formatOptions:n}})(t);if(this.formats[o]){let t=e;try{let a=r?.formatParams?.[r.interpolationkey]||{},s=a.locale||a.lng||r.locale||r.lng||n;t=this.formats[o](e,s,{...i,...r,...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 iy{constructor(e,t,n,r={}){super(),this.backend=e,this.store=t,this.services=n,this.languageUtils=n.languageUtils,this.options=r,this.logger=im.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=r.maxParallelReads||10,this.readingCalls=0,this.maxRetries=r.maxRetries>=0?r.maxRetries:5,this.retryTimeout=r.retryTimeout>=1?r.retryTimeout:350,this.state={},this.queue=[],this.backend?.init?.(n,r.backend,r)}queueLoad(e,t,n,r){let o={},i={},a={},s={};return e.forEach(e=>{let r=!0;t.forEach(t=>{let a=`${e}|${t}`;!n.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,r=!1,void 0===i[a]&&(i[a]=!0),void 0===o[a]&&(o[a]=!0),void 0===s[t]&&(s[t]=!0)))}),r||(a[e]=!0)}),(Object.keys(o).length||Object.keys(i).length)&&this.queue.push({pending:i,pendingCount:Object.keys(i).length,loaded:{},errors:[],callback:r}),{toLoad:Object.keys(o),pending:Object.keys(i),toLoadLanguages:Object.keys(a),toLoadNamespaces:Object.keys(s)}}loaded(e,t,n){let r=e.split("|"),o=r[0],i=r[1];t&&this.emit("failedLoading",o,i,t),!t&&n&&this.store.addResourceBundle(o,i,n,void 0,void 0,{skipCopy:!0}),this.state[e]=t?-1:2,t&&n&&(this.state[e]=0);let a={};this.queue.forEach(n=>{((e,t,n,r)=>{let{obj:o,k:i}=it(e,t,Object);o[i]=o[i]||[],o[i].push(n)})(n.loaded,[o],i),void 0!==n.pending[e]&&(delete n.pending[e],n.pendingCount--),t&&n.errors.push(t),0!==n.pendingCount||n.done||(Object.keys(n.loaded).forEach(e=>{a[e]||(a[e]={});let t=n.loaded[e];t.length&&t.forEach(t=>{void 0===a[e][t]&&(a[e][t]=!0)})}),n.done=!0,n.errors.length?n.callback(n.errors):n.callback())}),this.emit("loaded",a),this.queue=this.queue.filter(e=>!e.done)}read(e,t,n,r=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:n,tried:r,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&&r<this.maxRetries?setTimeout(()=>{this.read.call(this,e,t,n,r+1,2*o,i)},o):i(a,s)},s=this.backend[n].bind(this.backend);if(2===s.length){try{let n=s(e,t);n&&"function"==typeof n.then?n.then(e=>a(null,e)).catch(a):a(null,n)}catch(e){a(e)}return}return s(e,t,a)}prepareLoading(e,t,n={},r){if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),r&&r();o6(e)&&(e=this.languageUtils.toResolveHierarchy(e)),o6(t)&&(t=[t]);let o=this.queueLoad(e,t,n,r);if(!o.toLoad.length)return o.pending.length||r(),null;o.toLoad.forEach(e=>{this.loadOne(e)})}load(e,t,n){this.prepareLoading(e,t,{},n)}reload(e,t,n){this.prepareLoading(e,t,{reload:!0},n)}loadOne(e,t=""){let n=e.split("|"),r=n[0],o=n[1];this.read(r,o,"read",void 0,void 0,(n,i)=>{n&&this.logger.warn(`${t}loading namespace ${o} for language ${r} failed`,n),!n&&i&&this.logger.log(`${t}loaded namespace ${o} for language ${r}`,i),this.loaded(e,n,i)})}saveMissing(e,t,n,r,o,i={},a=()=>{}){if(this.services?.utils?.hasLoadedNamespace&&!this.services?.utils?.hasLoadedNamespace(t))return void this.logger.warn(`did not save key "${n}" 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!=n&&""!==n){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,n,r,s):l(e,t,n,r))&&"function"==typeof o.then?o.then(e=>a(null,e)).catch(a):a(null,o)}catch(e){a(e)}else l(e,t,n,r,a,s)}e&&e[0]&&this.store.addResource(e[0],t,n,r)}}}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 n=e[3]||e[2];Object.keys(n).forEach(e=>{t[e]=n[e]})}return t},interpolation:{escapeValue:!0,format:e=>e,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0},cacheInBuiltFormats:!0}),iM=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 i$ extends iy{constructor(e={},t){if(super(),this.options=iM(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 n=iN();this.options={...n,...this.options,...iM(e)},this.options.interpolation={...n.interpolation,...this.options.interpolation},void 0!==e.keySeparator&&(this.options.userDefinedKeySeparator=e.keySeparator),void 0!==e.nsSeparator&&(this.options.userDefinedNsSeparator=e.nsSeparator);let r=e=>e?"function"==typeof e?new e:e:null;if(!this.options.isClone){let e;this.modules.logger?im.init(r(this.modules.logger),this.options):im.init(null,this.options),e=this.modules.formatter?this.modules.formatter:iR;let t=new iE(this.options);this.store=new ig(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!==n.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===n.interpolation.format)&&(o.formatter=r(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(r(this.modules.backend),o.resourceStore,o,this.options),o.backendConnector.on("*",(e,...t)=>{this.emit(e,...t)}),this.modules.languageDetector&&(o.languageDetector=r(this.modules.languageDetector),o.languageDetector.init&&o.languageDetector.init(o,this.options.detection,this.options)),this.modules.i18nFormat&&(o.i18nFormat=r(this.modules.i18nFormat),o.i18nFormat.init&&o.i18nFormat.init(this)),this.translator=new iS(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,n)=>{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(n),t(e,n)};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 n=t,r=o6(e)?e:this.language;if("function"==typeof e&&(n=e),!this.options.resources||this.options.partialBundledLanguages){if(r?.toLowerCase()==="cimode"&&(!this.options.preload||0===this.options.preload.length))return n();let e=[],t=t=>{t&&"cimode"!==t&&this.services.languageUtils.toResolveHierarchy(t).forEach(t=>{"cimode"!==t&&0>e.indexOf(t)&&e.push(t)})};r?t(r):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),n(e)})}else n(null)}reloadResources(e,t,n){let r=o5();return"function"==typeof e&&(n=e,e=void 0),"function"==typeof t&&(n=t,t=void 0),e||(e=this.languages),t||(t=this.options.ns),n||(n=iI),this.services.backendConnector.reload(e,t,e=>{r.resolve(),n(e)}),r}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&&ib.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 n=o5();this.emit("languageChanging",e);let r=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&&(r(i),this.translator.changeLanguage(i),this.isLanguageChangingTo=void 0,this.emit("languageChanged",i),this.logger.log("languageChanged",i)):this.isLanguageChangingTo=void 0,n.resolve((...e)=>this.t(...e)),t&&t(o,(...e)=>this.t(...e))},i=t=>{e||t||!this.services.languageDetector||(t=[]);let n=o6(t)?t:t&&t[0],i=this.store.hasLanguageSomeTranslations(n)?n:this.services.languageUtils.getBestMatchFromCodes(o6(t)?[t]:t);i&&(this.language||r(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()),n}getFixedT(e,t,n){let r=(e,t,...o)=>{let i,a;(i="object"!=typeof t?this.options.overloadTranslationOptionHandler([e,t].concat(o)):{...t}).lng=i.lng||r.lng,i.lngs=i.lngs||r.lngs,i.ns=i.ns||r.ns,""!==i.keyPrefix&&(i.keyPrefix=i.keyPrefix||n||r.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)?r.lng=e:r.lngs=e,r.ns=t,r.keyPrefix=n,r}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 n=t.lng||this.resolvedLanguage||this.languages[0],r=!!this.options&&this.options.fallbackLng,o=this.languages[this.languages.length-1];if("cimode"===n.toLowerCase())return!0;let i=(e,t)=>{let n=this.services.backendConnector.state[`${e}|${t}`];return -1===n||0===n||2===n};if(t.precheck){let e=t.precheck(this,i);if(void 0!==e)return e}return!!(this.hasResourceBundle(n,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||i(n,e)&&(!r||i(o,e)))}loadNamespaces(e,t){let n=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=>{n.resolve(),t&&t(e)}),n):(t&&t(),Promise.resolve())}loadLanguages(e,t){let n=o5();o6(e)&&(e=[e]);let r=this.options.preload||[],o=e.filter(e=>0>r.indexOf(e)&&this.services.languageUtils.isSupportedCode(e));return o.length?(this.options.preload=r.concat(o),this.loadResources(e=>{n.resolve(),t&&t(e)}),n):(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 iE(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 i$(e,t)}cloneInstance(e={},t=iI){let n=e.forkResourceStore;n&&delete e.forkResourceStore;let r={...this.options,...e,isClone:!0},o=new i$(r);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)},n&&(o.store=new ig(Object.keys(this.store.data).reduce((e,t)=>(e[t]={...this.store.data[t]},e[t]=Object.keys(e[t]).reduce((n,r)=>(n[r]={...e[t][r]},n),e[t]),e),{}),r),o.services.resourceStore=o.store),o.translator=new iS(o.services,r),o.translator.on("*",(e,...t)=>{o.emit(e,...t)}),o.init(r,t),o.translator.options=r,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=i$.createInstance();iL.createInstance=i$.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,n,r){return iF.t(t,{ns:e,defaultValue:n,...r})}function iV(e,t,n){return o3[e]?iB("core",e,t??o3[e],n):(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=iZ().then(({map:e,complete:t})=>(t||(iG=null),e))),iG}async function iZ(){let e=document.querySelectorAll('script[type="systemjs-importmap"]'),t=[],n=!0;for(let r=0;r<e.length;r++){let o=e[r];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){n=!1,console.warn(`[import-maps] Failed to parse import map from script tag at index ${r}`,e)}}return{map:iY(t),complete:n}}function iY(e){let t={imports:{}};for(let n of e)n?.imports&&Object.assign(t.imports,n.imports);return t}function iJ(){let e={};try{let t=i2();for(let n=0;n<localStorage.length;n++){let r=localStorage.key(n);if(r?.startsWith(iU)){let n=r.slice(iU.length);if(!t.includes(n)){let t=localStorage.getItem(r);t&&(e[n]=t)}}}}catch(e){console.warn("[import-maps] Failed to read import-map overrides from localStorage",e)}return{imports:e}}async function iQ(){let e=await iq();return iz?iY([e,iH??iJ()]):e}async function iX(){return iq()}async function i0(){return iz?iY([await iq(),iJ()]):iq()}function i1(e){if(!iz)return{imports:{}};if(e){let e={};for(let t=0;t<localStorage.length;t++){let n=localStorage.key(t);if(n?.startsWith(iU)){let t=localStorage.getItem(n);t&&(e[n.slice(iU.length)]=t)}}return{imports:e}}return iJ()}function i2(){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 i4(e){return!!iz&&i2().includes(e)}function i3(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=i2().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 n=localStorage.key(t);n?.startsWith(iU)&&e.push(n)}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 i7(e){if(!iz)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{let t=i2().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 i8(){!i9&&(i9=!0,(iz="development"===window.spaEnv)&&(iH=iJ()))}function ae(e){return e.replace(/[\/\-@]/g,"_")}async function at(e,t="./start",r){var o;let i,a=!r?.maxLoadingTime||r.maxLoadingTime<=0?6e5:r.maxLoadingTime;await Promise.race([an(e,r?.importMap),new Promise((t,n)=>{i=setTimeout(()=>{var t;n(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(n.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 an(e,t){if("string"!=typeof e||0===e.trim().length){let e="Attempted to call importDynamic() without supplying a package to load";throw console.error(e),Error(e)}let n=ae(e);if(!window[n]){let n=t??await ar();if(!n.imports.hasOwnProperty(e)){let t=`Could not find the package ${e} defined in the current importmap`;throw console.error(t),Error(t)}let r=n.imports[e];r.startsWith("./")&&(r=window.spaBase+r.substring(1));let o=e in i1().imports;try{return await function(e){var t;let n=(t=window)[ao]??(t[ao]=new Map),r=n.get(e);if(r)return r;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,r)=>{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(),n.delete(e),o.remove();let i=`Failed to load script from ${e}`;console.error(i,t),r(t.message??i)}o.addEventListener("load",s),o.addEventListener("error",l),document.head.appendChild(o)});return n.set(e,i),i}(r)}catch(e){return o&&T({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:r}),actionButtonLabel:iV("resetOverrides","Reset overrides"),onActionButtonClick(){i5(),window.location.reload()}}),Promise.reject(e)}}return Promise.resolve()}async function ar(){return iQ()}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 af(){return ad??(ad=ap().then(({map:e,complete:t})=>(t||(ad=null),e))),ad}async function ap(){let e=document.querySelectorAll("script[type='openmrs-routes']"),t=[],n=!0;for(let r=0;r<e.length;r++){let o=e[r];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){n=!1,console.warn(`[route-maps] Failed to parse routes from script tag at index ${r}`,e)}}return{map:ah(t),complete:n}}function ah(e){let t={routes:{}};for(let n of e)n&&"object"==typeof n&&!Array.isArray(n)&&(Object.assign(t.routes,n.routes),void 0===t.version&&void 0!==n.version&&(t.version=n.version));return t}async function am(){let e={version:void 0,routes:{}};try{let t=[];for(let e=0;e<localStorage.length;e++){let n=localStorage.key(e);if(n?.startsWith(as)){let e=localStorage.getItem(n);e&&t.push({moduleName:n.slice(as.length),raw:e})}}for(let n of(await Promise.allSettled(t.map(async({moduleName:e,raw:t})=>{let n=JSON.parse(t);if(ai(n))return{moduleName:e,routes:n};if("string"==typeof n&&n.startsWith("http")){let t=await fetch(n),r=await t.json();if(ai(r))return{moduleName:e,routes:r};throw Error(`${n} did not resolve to a valid OpenmrsAppRoutes object`)}throw Error(`Override for ${e} is neither a valid routes object nor a URL`)}))))"fulfilled"===n.status?e.routes[n.value.moduleName]=n.value.routes:console.warn("[route-maps] Failed to load route override",n.reason)}catch(e){console.warn("[route-maps] Failed to read route overrides from localStorage",e)}return e}async function ay(){let e=await af();return au?ah([e,ac??await am()]):e}async function ag(){return af()}async function ab(){return au?ah([await af(),await am()]):af()}function av(){if(!au)return{};let e={};try{for(let t=0;t<localStorage.length;t++){let n=localStorage.key(t);if(n?.startsWith(as)){let t=localStorage.getItem(n);t&&(e[n.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 n=JSON.parse(t);if(!ai(n))return void console.error(`The supplied routes for ${e} is not a valid OpenmrsAppRoutes object`,t);localStorage.setItem(as+e,JSON.stringify(n))}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 n=localStorage.key(t);n?.startsWith(as)&&e.push(n)}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 aS=null;function aE(){return aS||(aS=(au="development"===window.spaEnv)?am().then(e=>{ac=e}):Promise.resolve())}let aD=`${oM}/attachment`;function aO(e,t){return oF(`${aD}/${e}`,{signal:t.signal})}function ak(e,t,n){return oF(`${aD}?patient=${e}&includeEncounterless=${t}`,{signal:n.signal})}async function aP(e,t){let n=new FormData;return n.append("fileCaption",t.fileDescription),n.append("patient",e),t.file?n.append("file",t.file,t.fileName):(n.append("file",new File([""],t.fileName),t.fileName),n.append("base64Content",t.base64Content)),oF(`${aD}`,{method:"POST",body:n})}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(n){var r=new MessageChannel;r.port1.onmessage=function(e){n(e.data)},e.postMessage(t,[r.port2])})}function aT(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function aR(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}try{self["workbox:core:6.5.4"]&&_()}catch(e){}var aA=function(){var e=this;this.promise=new Promise(function(t,n){e.resolve=t,e.reject=n})};function aN(e,t){var n=location.href;return new URL(e,n).href===new URL(t,n).href}var aM=function(e,t){this.type=e,Object.assign(this,t)};function aI(e,t,n){return n?t?t(e):e:(e&&e.then||(e=Promise.resolve(e)),t?e.then(t):e)}function a$(){}var aL={type:"SKIP_WAITING"};function aF(e,t){if(!t)return e&&e.then?e.then(a$):Promise.resolve()}var aB=function(e){function t(t,n){var r,o;return void 0===n&&(n={}),(r=e.call(this)||this).nn={},r.tn=0,r.rn=new aA,r.en=new aA,r.on=new aA,r.un=0,r.an=new Set,r.cn=function(){var e=r.fn,t=e.installing;r.tn>0||!aN(t.scriptURL,r.sn.toString())||performance.now()>r.un+6e4?(r.vn=t,e.removeEventListener("updatefound",r.cn)):(r.hn=t,r.an.add(t),r.rn.resolve(t)),++r.tn,t.addEventListener("statechange",r.ln)},r.ln=function(e){var t=r.fn,n=e.target,o=n.state,i=n===r.vn,a={sw:n,isExternal:i,originalEvent:e};!i&&r.mn&&(a.isUpdate=!0),r.dispatchEvent(new aM(o,a)),"installed"===o?r.wn=self.setTimeout(function(){"installed"===o&&t.waiting===n&&r.dispatchEvent(new aM("waiting",a))},200):"activating"===o&&(clearTimeout(r.wn),i||r.en.resolve(n))},r.dn=function(e){var t=r.hn,n=t!==navigator.serviceWorker.controller;r.dispatchEvent(new aM("controlling",{isExternal:n,originalEvent:e,sw:t,isUpdate:r.mn})),n||r.on.resolve(t)},o=function(e){var t=e.data,n=e.ports,o=e.source;return aI(r.getSW(),function(){r.an.has(o)&&r.dispatchEvent(new aM("message",{data:t,originalEvent:e,ports:n,sw:o}))})},r.gn=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];try{return Promise.resolve(o.apply(this,e))}catch(e){return Promise.reject(e)}},r.sn=t,r.nn=n,navigator.serviceWorker.addEventListener("message",r.gn),r}t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e;var n,r,o=t.prototype;return o.register=function(e){var t=(void 0===e?{}:e).immediate,n=void 0!==t&&t;try{var r,o,i,a=this;return r=function(){if(!n&&"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 aM("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=r())&&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 n=e()}catch(e){return t(e)}return n&&n.then?n.then(void 0,t):n}(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)}},n=[{key:"active",get:function(){return this.en.promise}},{key:"controlling",get:function(){return this.on.promise}}],aT(t.prototype,n),r&&aT(t,r),t}(function(){function e(){this.Pn=new Map}var t=e.prototype;return t.addEventListener=function(e,t){this.Sn(e).add(t)},t.removeEventListener=function(e,t){this.Sn(e).delete(t)},t.dispatchEvent=function(e){e.target=this;for(var t,n=function(e){var t;if("u"<typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(t=function(e){if(e){if("string"==typeof e)return 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 n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(t=e[Symbol.iterator]()).next.bind(t)}(this.Sn(e.type));!(t=n()).done;)(0,t.value)(e)},t.Sn=function(e){return this.Pn.has(e)||this.Pn.set(e,new Set),this.Pn.get(e)},e}());function aV(e,t){if(void 0!==f)return console.warn(`The application's Service Worker has already been registered. The new service worker at ${e} will not be registered.`),f;if(!("serviceWorker"in navigator))throw Error("Registering the Service Worker is not possible due to missing browser capabilities.");let n=new aB(e,t);return f=n.register().then(()=>n.controlling.then(()=>n))}function aU(){return f??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 aZ(){return new Promise(e=>{let t=indexedDB.open("test");t.onerror=()=>e(!0),t.onsuccess=()=>e(!1)})}async function aY(){return await aZ()||await aq()||await aG()}let aJ="openmrs3:offline-mode",aQ="unavailable";function aX(){return{current:aQ,notAvailable:"unavailable"===aQ,active:"on"===aQ}}function a0(e){"unavailable"!==aQ&&"unavailable"!==e&&(localStorage.setItem(aJ,"on"===e?"active":"disabled"),aQ=e)}async function a1(){await aY()||(aQ="active"===localStorage.getItem(aJ)?"on":"off"),navigator.onLine}let a2="u">typeof globalThis?globalThis:"u">typeof self?self:"u">typeof window?window:global,a4=Object.keys,a3=Array.isArray;function a6(e,t){return"object"!=typeof t||a4(t).forEach(function(n){e[n]=t[n]}),e}"u"<typeof Promise||a2.Promise||(a2.Promise=Promise);let a5=Object.getPrototypeOf,a7={}.hasOwnProperty;function a9(e,t){return a7.call(e,t)}function a8(e,t){"function"==typeof t&&(t=t(a5(e))),("u"<typeof Reflect?a4:Reflect.ownKeys)(t).forEach(n=>{st(e,n,t[n])})}let se=Object.defineProperty;function st(e,t,n,r){se(e,t,a6(n&&a9(n,"get")&&"function"==typeof n.get?{get:n.get,set:n.set,configurable:!0}:{value:n,configurable:!0,writable:!0},r))}function sn(e){return{from:function(t){return e.prototype=Object.create(t.prototype),st(e.prototype,"constructor",e),{extend:a8.bind(null,e.prototype)}}}}let sr=Object.getOwnPropertyDescriptor;function so(e,t){let n;return sr(e,t)||(n=a5(e))&&so(n,t)}let si=[].slice;function sa(e,t,n){return si.call(e,t,n)}function ss(e,t){return t(e)}function sl(e){if(!e)throw Error("Assertion Failed")}function su(e){a2.setImmediate?setImmediate(e):setTimeout(e,0)}function sc(e,t){return e.reduce((e,n,r)=>{var o=t(n,r);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 n=[],r=0,o=t.length;r<o;++r){var i=sd(e,t[r]);n.push(i)}return n}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 sf(e,t,n){if(e&&void 0!==t&&(!("isFrozen"in Object)||!Object.isFrozen(e)))if("string"!=typeof t&&"length"in t){sl("string"!=typeof n&&"length"in n);for(var r=0,o=t.length;r<o;++r)sf(e,t[r],n[r])}else{var i=t.indexOf(".");if(-1!==i){var a=t.substr(0,i),s=t.substr(i+1);if(""===s)void 0===n?a3(e)&&!isNaN(parseInt(a))?e.splice(a,1):delete e[a]:e[a]=n;else{var l=e[a];l&&a9(e,a)||(l=e[a]={}),sf(l,s,n)}}else void 0===n?a3(e)&&!isNaN(parseInt(t))?e.splice(t,1):delete e[t]:e[t]=n}}function sp(e){var t={};for(var n in e)a9(e,n)&&(t[n]=e[n]);return t}let sh=[].concat;function sm(e){return sh.apply([],e)}let sy="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=>a2[e]),sg=sy.map(e=>a2[e]);sc(sy,e=>[e,!0]);let sb=null;function sv(e){sb="u">typeof WeakMap&&new WeakMap;let t=function e(t){if(!t||"object"!=typeof t)return t;let n=sb&&sb.get(t);if(n)return n;if(a3(t)){n=[],sb&&sb.set(t,n);for(var r=0,o=t.length;r<o;++r)n.push(e(t[r]))}else if(sg.indexOf(t.constructor)>=0)n=t;else{let r=a5(t);for(var i in n=r===Object.prototype?{}:Object.create(r),sb&&sb.set(t,n),t)a9(t,i)&&(n[i]=e(t[i]))}return n}(e);return sb=null,t}let{toString:sw}={};function s_(e){return sw.call(e).slice(8,-1)}let sx="u">typeof Symbol?Symbol.iterator:"@@iterator",sS="symbol"==typeof sx?function(e){var t;return null!=e&&(t=e[sx])&&t.apply(e)}:function(){return null},sE={};function sD(e){var t,n,r,o;if(1==arguments.length){if(a3(e))return e.slice();if(this===sE&&"string"==typeof e)return[e];if(o=sS(e)){for(n=[];!(r=o.next()).done;)n.push(r.value);return n}if(null==e)return[e];if("number"==typeof(t=e.length)){for(n=Array(t);t--;)n[t]=e[t];return n}return[e]}for(t=arguments.length,n=Array(t);t--;)n[t]=arguments[t];return n}let 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 n=e.stack;return n?(t=t||0,0===n.indexOf(e.name)&&(t+=(e.name+e.message).split("\n").length),n.split("\n").slice(t).filter(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 sM(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,n)=>n.indexOf(e)===t).join("\n")}function s$(e,t,n,r){this._e=sj(),this.failures=t,this.failedKeys=r,this.successCount=n,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)}sn(sM).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}}),sn(s$).from(sM),sn(sL).from(sM);var sF=sA.reduce((e,t)=>(e[t]=t+"Error",e),{}),sB=sA.reduce((e,t)=>{var n=t+"Error";function r(e,r){this._e=sj(),this.name=n,e?"string"==typeof e?(this.message=`${e}${r?"\n "+r:""}`,this.inner=r||null):"object"==typeof e&&(this.message=`${e.name} ${e.message}`,this.inner=e):(this.message=sN[t]||n,this.inner=null)}return sn(r).from(sM),e[t]=r,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(n){return t(e(n))}}function sH(e,t){return function(){e.apply(this,arguments),t.apply(this,arguments)}}function sG(e,t){return e===sW?t:function(){var n=e.apply(this,arguments);void 0!==n&&(arguments[0]=n);var r=this.onsuccess,o=this.onerror;this.onsuccess=null,this.onerror=null;var i=t.apply(this,arguments);return r&&(this.onsuccess=this.onsuccess?sH(r,this.onsuccess):r),o&&(this.onerror=this.onerror?sH(o,this.onerror):o),void 0!==i?i:n}}function sq(e,t){return e===sW?t:function(){e.apply(this,arguments);var n=this.onsuccess,r=this.onerror;this.onsuccess=this.onerror=null,t.apply(this,arguments),n&&(this.onsuccess=this.onsuccess?sH(n,this.onsuccess):n),r&&(this.onerror=this.onerror?sH(r,this.onerror):r)}}function sZ(e,t){return e===sW?t:function(n){var r=e.apply(this,arguments);a6(n,r);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===r?void 0===a?void 0:a:a6(r,a)}}function sY(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 n=e.apply(this,arguments);if(n&&"function"==typeof n.then){for(var r=this,o=arguments.length,i=Array(o);o--;)i[o]=arguments[o];return n.then(function(){return t.apply(r,i)})}return t.apply(this,arguments)}}sU.ModifyError=s$,sU.DexieError=sM,sU.BulkError=sL;var sQ={};let[sX,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]})(),s2=s0&&s0.then,s4=sX&&sX.constructor,s3=!!s1;var s6=!1,s5=s1?()=>{s1.then(lg)}:a2.setImmediate?setImmediate.bind(null,lg):a2.MutationObserver?()=>{var e=document.createElement("div");new MutationObserver(()=>{lg(),e=null}).observe(e,{attributes:!0}),e.setAttribute("i","1")}:()=>{setTimeout(lg,0)},s7=function(e,t){la.push([e,t]),s8&&(s5(),s8=!1)},s9=!0,s8=!0,le=[],lt=[],ln=null,lr=sK,lo={id:"global",global:!0,ref:0,unhandleds:[],onunhandled:lB,pgp:!1,env:{},finalize:function(){this.unhandleds.forEach(e=>{try{lB(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!==sQ)throw TypeError("Not a function");return this._state=arguments[1],this._value=arguments[2],void(!1===this._state&&lf(this,this._value))}this._state=null,this._value=null,++t.ref,function e(t,n){try{n(n=>{if(null===t._state){if(n===t)throw TypeError("A promise cannot be resolved with itself.");var r=t._lib&&lb();n&&"function"==typeof n.then?e(t,(e,t)=>{n instanceof lu?n._then(e,t):n.then(e,t)}):(t._state=!0,t._value=n,lp(t)),r&&lv()}},lf.bind(null,t))}catch(e){lf(t,e)}}(this,e)}let lc={get:function(){var e=li,t=lk;function n(n,r){var o=!e.global&&(e!==li||t!==lk);let i=o&&!lT();var a=new lu((t,a)=>{lh(this,new ld(lL(n,e,o,i),lL(r,e,o,i),t,a,e))});return sk&&ly(a,this),a}return n.prototype=sQ,n},set:function(e){st(this,"then",e&&e.prototype===sQ?lc:{get:function(){return e},set:lc.set})}};function ld(e,t,n,r,o){this.onFulfilled="function"==typeof e?e:null,this.onRejected="function"==typeof t?t:null,this.resolve=n,this.reject=r,this.psd=o}function lf(e,t){if(lt.push(t),null===e._state){var n=e._lib&&lb();t=lr(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 n=so(t,"stack");t._promise=e,st(t,"stack",{get:()=>s6?n&&(n.get?n.get.apply(t):n.value):e.stack})}),le.some(t=>t._value===e._value)||le.push(e),lp(e),n&&lv()}}function lp(e){var t=e._listeners;e._listeners=[];for(var n=0,r=t.length;n<r;++n)lh(e,t[n]);var o=e._PSD;--o.ref||o.finalize(),0===ls&&(++ls,s7(()=>{0==--ls&&lw()},[]))}function lh(e,t){if(null!==e._state){var n=e._state?t.onFulfilled:t.onRejected;if(null===n)return(e._state?t.resolve:t.reject)(e._value);++t.psd.ref,++ls,s7(lm,[n,e,t])}else e._listeners.push(t)}function lm(e,t,n){try{ln=t;var r,o=t._value;t._state?r=e(o):(lt.length&&(lt=[]),r=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)),n.resolve(r)}catch(e){n.reject(e)}finally{ln=null,0==--ls&&lw(),--n.psd.ref||n.psd.finalize()}}function ly(e,t){var n=t?t._numPrev+1:0;n<100&&(e._prev=t,e._numPrev=n)}function lg(){lb()&&lv()}function lb(){var e=s9;return s9=!1,s8=!1,e}function lv(){var e,t,n;do for(;la.length>0;)for(e=la,la=[],n=e.length,t=0;t<n;++t){var r=e[t];r[0].apply(null,r[1])}while(la.length>0);s9=!0,s8=!0}function lw(){var e=le;le=[],e.forEach(e=>{e._PSD.onunhandled.call(null,e._value,e)});for(var t=ll.slice(0),n=t.length;n;)t[--n]()}function l_(e){return new lu(sQ,!1,e)}function lx(e,t){var n=li;return function(){var r=lb(),o=li;try{return lM(n,!0),e.apply(this,arguments)}catch(e){t&&t(e)}finally{lM(o,!1),r&&lv()}}}a8(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],n=arguments[1];return"function"==typeof t?this.then(null,e=>e instanceof t?n(e):l_(e)):this.then(null,e=>e&&e.name===t?n(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,n,r){if(n.length===r)return n;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=""),n.push(i+(a?": "+a:"")+o)}return sk&&((o=sT(t._stackHolder,2))&&-1===n.indexOf(o)&&n.push(o),t._prev&&e(t._prev,n,r)),n})(this,[],20).join("\nFrom previous: ");return null!==this._state&&(this._stack=e),e}finally{s6=!1}}},timeout:function(e,t){return e<1/0?new lu((n,r)=>{var o=setTimeout(()=>r(new sB.Timeout(t)),e);this.then(n,r).finally(clearTimeout.bind(null,o))}):this}}),"u">typeof Symbol&&Symbol.toStringTag&&st(lu.prototype,Symbol.toStringTag,"Dexie.Promise"),lo.env=lI(),a8(lu,{all:function(){var e=sD.apply(null,arguments).map(lR);return new lu(function(t,n){0===e.length&&t([]);var r=e.length;e.forEach((o,i)=>lu.resolve(o).then(n=>{e[i]=n,--r||t(e)},n))})},resolve:e=>{if(e instanceof lu)return e;if(e&&"function"==typeof e.then)return new lu((t,n)=>{e.then(t,n)});var t=new lu(sQ,!0,e);return ly(t,ln),t},reject:l_,race:function(){var e=sD.apply(null,arguments).map(lR);return new lu((t,n)=>{e.map(e=>lu.resolve(e).then(t,n))})},PSD:{get:()=>li,set:e=>li=e},totalEchoes:{get:()=>lk},newPSD:lC,usePSD:l$,scheduler:{get:()=>s7,set:e=>{s7=e}},rejectionMapper:{get:()=>lr,set:e=>{lr=e}},follow:(e,t)=>new lu((n,r)=>lC((t,n)=>{var r=li;r.unhandleds=[],r.onunhandled=n,r.finalize=sH(function(){var e;e=()=>{0===this.unhandleds.length?t():n(this.unhandleds[0])},ll.push(function t(){e(),ll.splice(ll.indexOf(t),1)}),++ls,s7(()=>{0==--ls&&lw()},[])},r.finalize),e()},t,n,r))}),s4&&(s4.allSettled&&st(lu,"allSettled",function(){let e=sD.apply(null,arguments).map(lR);return new lu(t=>{0===e.length&&t([]);let n=e.length,r=Array(n);e.forEach((e,o)=>lu.resolve(e).then(e=>r[o]={status:"fulfilled",value:e},e=>r[o]={status:"rejected",reason:e}).then(()=>--n||t(r)))})}),s4.any&&"u">typeof AggregateError&&st(lu,"any",function(){let e=sD.apply(null,arguments).map(lR);return new lu((t,n)=>{0===e.length&&n(AggregateError([]));let r=e.length,o=Array(r);e.forEach((e,i)=>lu.resolve(e).then(e=>t(e),e=>{o[i]=e,--r||n(AggregateError(o))}))})}));let lS={awaits:0,echoes:0,id:0};var lE=0,lD=[],lO=0,lk=0,lP=0;function lC(e,t,n,r){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=s3?{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=l$(i,e,n,r);return 0===i.ref&&i.finalize(),s}function lj(){return lS.id||(lS.id=++lE),++lS.awaits,lS.echoes+=100,lS.id}function lT(){return!!lS.awaits&&(0==--lS.awaits&&(lS.id=0),lS.echoes=100*lS.awaits,!0)}function lR(e){return lS.echoes&&e&&e.constructor===s4?(lj(),e.then(e=>(lT(),e),e=>(lT(),lV(e)))):e}function lA(e){++lk,lS.echoes&&0!=--lS.echoes||(lS.echoes=lS.id=0),lD.push(li),lM(e,!0)}function lN(){var e=lD[lD.length-1];lD.pop(),lM(e,!1)}function lM(e,t){var n,r=li;if((t?!lS.echoes||lO++&&e===li:!lO||--lO&&e===li)||(n=t?lA.bind(null,e):lN,s2.call(sX,n)),e!==li&&(li=e,r===lo&&(lo.env=lI()),s3)){var o=lo.env.Promise,i=e.env;s0.then=i.nthen,o.prototype.then=i.gthen,(r.global||e.global)&&(Object.defineProperty(a2,"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=a2.Promise;return s3?{Promise:e,PromiseProp:Object.getOwnPropertyDescriptor(a2,"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 l$(e,t,n,r,o){var i=li;try{return lM(e,!0),t(n,r,o)}finally{lM(i,!1)}}function lL(e,t,n,r){return"function"!=typeof e?e:function(){var o,i=li;n&&lj(),lM(t,!0);try{return e.apply(this,arguments)}finally{lM(i,!1),r&&(o=lT,s2.call(sX,o))}}}function lF(e,t){return function(n,r){return e.call(this,lL(n,t),lL(r,t))}}function lB(e,t){var n;try{n=t.onuncatched(e)}catch(e){}if(!1!==n)try{var r,o={promise:t,reason:e};if(a2.document&&document.createEvent?((r=document.createEvent("Event")).initEvent("unhandledrejection",!0,!0),a6(r,o)):a2.CustomEvent&&a6(r=new CustomEvent("unhandledrejection",{detail:o}),o),r&&a2.dispatchEvent&&(dispatchEvent(r),!a2.PromiseRejectionEvent&&a2.onunhandledrejection))try{a2.onunhandledrejection(r)}catch(e){}sk&&r&&!r.defaultPrevented&&console.warn(`Unhandled rejection: ${e.stack||e}`)}catch(e){}}-1===(""+s2).indexOf("[native code]")&&(lj=lT=sW);var lV=lu.reject;let lU=String.fromCharCode(65535),lW="Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.",lK=[],lz="u">typeof navigator&&/(MSIE|Trident|Edge)/.test(navigator.userAgent),lH=e=>!/(dexie\.js|dexie\.min\.js)/.test(e);function lG(e,t){return e?t?function(){return e.apply(this,arguments)&&t.apply(this,arguments)}:e:t}let lq={type:3,lower:-1/0,lowerOpen:!1,upper:[[]],upperOpen:!1};function lZ(e){return"string"!=typeof e||/\./.test(e)?e=>e:t=>(void 0===t[e]&&e in t&&delete(t=sv(t))[e],t)}class lY{_trans(e,t,n){let r=this._tx||li.trans,o=this.name;function i(e,n,r){if(!r.schema[o])throw new sB.NotFound("Table "+o+" not part of transaction");return t(r.idbtrans,r)}let a=lb();try{return r&&r.db===this.db?r===li.trans?r._promise(e,i,n):lC(()=>r._promise(e,i,n),{trans:r,transless:li.transless||li}):function e(t,n,r,o){if(t.idbdb&&(t._state.openComplete||li.letThrough||t._vip)){var i=t._createTransaction(n,r,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,n,r,o))):lV(i)}return i._promise(n,(e,t)=>lC(()=>(li.trans=i,o(e,t,i)))).then(e=>i._completion.then(()=>e))}if(t._state.openComplete)return lV(new sB.DatabaseClosed(t._state.dbOpenError));if(!t._state.isBeingOpened){if(!t._options.autoOpen)return lV(new sB.DatabaseClosed);t.open().catch(sW)}return t._state.dbReadyPromise.then(()=>e(t,n,r,o))}(this.db,e,[this.name],i)}finally{a&&lv()}}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(a3(e))return new this.db.WhereClause(this,`[${e.join("+")}]`);let t=a4(e);if(1===t.length)return this.where(t[0]).equals(e[t[0]]);let n=this.schema.indexes.concat(this.schema.primKey).filter(e=>e.compound&&t.every(t=>e.keyPath.indexOf(t)>=0)&&e.keyPath.every(e=>t.indexOf(e)>=0))[0];if(n&&this.db._maxKey!==lU)return this.where(n.name).equals(n.keyPath.map(t=>e[t]));!n&&sk&&console.warn(`The query ${JSON.stringify(e)} on ${this.name} would benefit of a compound index [${t.join("+")}]`);let{idxByName:r}=this.schema,o=this.db._deps.indexedDB;function i(e,t){try{return 0===o.cmp(e,t)}catch(e){return!1}}let[a,s]=t.reduce(([t,n],o)=>{let a=r[o],s=e[o];return[t||a,t||!a?lG(n,a&&a.multi?e=>{let t=sd(e,o);return a3(t)&&t.some(e=>i(s,e))}:e=>i(s,sd(e,o))):n]},[null,null]);return a?this.where(a.name).equals(e[a.keyPath]).filter(s):n?this.filter(s):this.where(t).equals("")}filter(e){return this.toCollection().and(e)}count(e){return this.toCollection().count(e)}offset(e){return this.toCollection().offset(e)}limit(e){return this.toCollection().limit(e)}each(e){return this.toCollection().each(e)}toArray(e){return this.toCollection().toArray(e)}toCollection(){return new this.db.Collection(new this.db.WhereClause(this))}orderBy(e){return new this.db.Collection(new this.db.WhereClause(this,a3(e)?`[${e.join("+")}]`:e))}reverse(){return this.toCollection().reverse()}mapToClass(e){this.schema.mappedClass=e;let t=t=>{if(!t)return t;let n=Object.create(e.prototype);for(var r in t)if(a9(t,r))try{n[r]=t[r]}catch(e){}return n};return this.schema.readHook&&this.hook.reading.unsubscribe(this.schema.readHook),this.schema.readHook=t,this.hook("reading",t),e}defineClass(){return this.mapToClass(function(e){a6(this,e)})}add(e,t){let{auto:n,keyPath:r}=this.schema.primKey,o=e;return r&&n&&(o=lZ(r)(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(r)try{sf(e,r,t)}catch(e){}return t})}update(e,t){if("object"!=typeof e||a3(e))return this.where(":id").equals(e).modify(t);{let n=sd(e,this.schema.primKey.keyPath);if(void 0===n)return lV(new sB.InvalidArgument("Given object does not contain its primary key"));try{"function"!=typeof t?a4(t).forEach(n=>{sf(e,n,t[n])}):t(e,{value:e,primKey:n})}catch(e){}return this.where(":id").equals(n).modify(t)}}put(e,t){let{auto:n,keyPath:r}=this.schema.primKey,o=e;return r&&n&&(o=lZ(r)(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(r)try{sf(e,r,t)}catch(e){}return t})}delete(e){return this._trans("readwrite",t=>this.core.mutate({trans:t,type:"delete",keys:[e]})).then(e=>e.numFailures?lu.reject(e.failures[0]):void 0)}clear(){return this._trans("readwrite",e=>this.core.mutate({trans:e,type:"deleteRange",range:lq})).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,n){let r=Array.isArray(t)?t:void 0,o=(n=n||(r?void 0:t))?n.allKeys:void 0;return this._trans("readwrite",t=>{let{auto:n,keyPath:i}=this.schema.primKey;if(i&&r)throw new sB.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(r&&r.length!==e.length)throw new sB.InvalidArgument("Arguments objects and keys must have the same length");let a=e.length,s=i&&n?e.map(lZ(i)):e;return this.core.mutate({trans:t,type:"add",keys:r,values:s,wantResults:o}).then(({numFailures:e,results:t,lastResult:n,failures:r})=>{if(0===e)return o?t:n;throw new sL(`${this.name}.bulkAdd(): ${e} of ${a} operations failed`,r)})})}bulkPut(e,t,n){let r=Array.isArray(t)?t:void 0,o=(n=n||(r?void 0:t))?n.allKeys:void 0;return this._trans("readwrite",t=>{let{auto:n,keyPath:i}=this.schema.primKey;if(i&&r)throw new sB.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(r&&r.length!==e.length)throw new sB.InvalidArgument("Arguments objects and keys must have the same length");let a=e.length,s=i&&n?e.map(lZ(i)):e;return this.core.mutate({trans:t,type:"put",keys:r,values:s,wantResults:o}).then(({numFailures:e,results:t,lastResult:n,failures:r})=>{if(0===e)return o?t:n;throw new sL(`${this.name}.bulkPut(): ${e} of ${a} operations failed`,r)})})}bulkDelete(e){let t=e.length;return this._trans("readwrite",t=>this.core.mutate({trans:t,type:"delete",keys:e})).then(({numFailures:e,lastResult:n,failures:r})=>{if(0===e)return n;throw new sL(`${this.name}.bulkDelete(): ${e} of ${t} operations failed`,r)})}}function lJ(e){var t={},n=function(n,r){if(r){for(var o=arguments.length,i=Array(o-1);--o;)i[o-1]=arguments[o];return t[n].subscribe.apply(null,i),e}if("string"==typeof n)return t[n]};n.addEventType=i;for(var r=1,o=arguments.length;r<o;++r)i(arguments[r]);return n;function i(e,r,o){if("object"==typeof e){var a;return void a4(a=e).forEach(function(e){var t=a[e];if(a3(t))i(e,a[e][0],a[e][1]);else{if("asap"!==t)throw new sB.InvalidArgument("Invalid event config");var n=i(e,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)})})})}})}r||(r=sY),o||(o=sW);var s={subscribers:[],fire:o,subscribe:function(e){-1===s.subscribers.indexOf(e)&&(s.subscribers.push(e),s.fire=r(s.fire,e))},unsubscribe:function(e){s.subscribers=s.subscribers.filter(function(t){return t!==e}),s.fire=s.subscribers.reduce(r,o)}};return t[e]=n[e]=s,s}}function lQ(e,t){return sn(t).from({prototype:e}),t}function lX(e,t){return!(e.filter||e.algorithm||e.or)&&(t?e.justLimit:!e.replayFilter)}function l0(e,t){e.filter=lG(e.filter,t)}function l1(e,t,n){var r=e.replayFilter;e.replayFilter=r?()=>lG(r(),t()):t,e.justLimit=n&&!r}function l2(e,t){if(e.isPrimKey)return t.primaryKey;let n=t.getIndexByKeyPath(e.index);if(!n)throw new sB.Schema("KeyPath "+e.index+" on object store "+t.name+" is not indexed");return n}function l4(e,t,n){let r=l2(e,t.schema);return t.openCursor({trans:n,values:!e.keysOnly,reverse:"prev"===e.dir,unique:!!e.unique,query:{index:r,range:e.range}})}function l3(e,t,n,r){let o=e.replayFilter?lG(e.filter,e.replayFilter()):e.filter;if(e.or){let i={},a=(e,n,r)=>{if(!o||o(n,r,e=>n.stop(e),e=>n.fail(e))){var a=n.primaryKey,s=""+a;"[object ArrayBuffer]"===s&&(s=""+new Uint8Array(a)),a9(i,s)||(i[s]=!0,t(e,n,r))}};return Promise.all([e.or._iterate(a,n),l6(l4(e,r,n),e.algorithm,a,!e.keysOnly&&e.valueMapper)])}return l6(l4(e,r,n),lG(e.algorithm,o),t,!e.keysOnly&&e.valueMapper)}function l6(e,t,n,r){var o=lx(r?(e,t,o)=>n(r(e),t,o):n);return e.then(e=>{if(e)return e.start(()=>{var n=()=>e.continue();t&&!t(e,e=>n=e,t=>{e.stop(t),n=sW},t=>{e.fail(t),n=sW})||o(e.value,e,e=>n=e),n()})})}function l5(e,t){try{let n=l7(e),r=l7(t);if(n!==r)return"Array"===n?1:"Array"===r?-1:"binary"===n?1:"binary"===r?-1:"string"===n?1:"string"===r?-1:"Date"===n?1:"Date"!==r?NaN:-1;switch(n){case"number":case"Date":case"string":return e>t?1:e<t?-1:0;case"binary":return function(e,t){let n=e.length,r=t.length,o=n<r?n:r;for(let n=0;n<o;++n)if(e[n]!==t[n])return e[n]<t[n]?-1:1;return n===r?0:n<r?-1:1}(l9(e),l9(t));case"Array":return function(e,t){let n=e.length,r=t.length,o=n<r?n:r;for(let n=0;n<o;++n){let r=l5(e[n],t[n]);if(0!==r)return r}return n===r?0:n<r?-1:1}(e,t)}}catch(e){}return NaN}function l7(e){let t=typeof e;if("object"!==t)return t;if(ArrayBuffer.isView(e))return"binary";let n=s_(e);return"ArrayBuffer"===n?"binary":n}function l9(e){return e instanceof Uint8Array?e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e)}class l8{_read(e,t){var n=this._ctx;return n.error?n.table._trans(null,lV.bind(null,n.error)):n.table._trans("readonly",e).then(t)}_write(e){var t=this._ctx;return t.error?t.table._trans(null,lV.bind(null,t.error)):t.table._trans("readwrite",e,"locked")}_addAlgorithm(e){var t=this._ctx;t.algorithm=lG(t.algorithm,e)}_iterate(e,t){return l3(this._ctx,e,t,this._ctx.table.core)}clone(e){var t=Object.create(this.constructor.prototype),n=Object.create(this._ctx);return e&&a6(n,e),t._ctx=n,t}raw(){return this._ctx.valueMapper=null,this}each(e){var t=this._ctx;return this._read(n=>l3(t,e,n,t.table.core))}count(e){return this._read(e=>{let t=this._ctx,n=t.table.core;if(lX(t,!0))return n.count({trans:e,query:{index:l2(t,n.schema),range:t.range}}).then(e=>Math.min(e,t.limit));var r=0;return l3(t,()=>(++r,!1),e,n).then(()=>r)}).then(e)}sortBy(e,t){let n=e.split(".").reverse(),r=n[0],o=n.length-1;function i(e,t){return t?i(e[n[t]],t-1):e[r]}var a="next"===this._ctx.dir?1:-1;function s(e,t){var n=i(e,o),r=i(t,o);return n<r?-a:n>r?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&&lX(t,!0)&&t.limit>0){let{valueMapper:n}=t,r=l2(t,t.table.core.schema);return t.table.core.query({trans:e,limit:t.limit,values:!0,query:{index:r,range:t.range}}).then(({result:e})=>n?e.map(n):e)}{let n=[];return l3(t,e=>n.push(e),e,t.table.core).then(()=>n)}},e)}offset(e){var t=this._ctx;return e<=0||(t.offset+=e,lX(t)?l1(t,()=>{var t=e;return(e,n)=>0===t||(1===t?--t:n(()=>{e.advance(t),t=0}),!1)}):l1(t,()=>{var t=e;return()=>--t<0})),this}limit(e){return this._ctx.limit=Math.min(this._ctx.limit,e),l1(this._ctx,()=>{var t=e;return function(e,n,r){return--t<=0&&n(r),t>=0}},!0),this}until(e,t){return l0(this._ctx,function(n,r,o){return!e(n.value)||(r(o),t)}),this}first(e){return this.limit(1).toArray(function(e){return e[0]}).then(e)}last(e){return this.reverse().first(e)}filter(e){var t;return l0(this._ctx,function(t){return e(t.value)}),(t=this._ctx).isMatch=lG(t.isMatch,e),this}and(e){return this.filter(e)}or(e){return new this.db.WhereClause(this._ctx.table,e,this)}reverse(){return this._ctx.dir="prev"===this._ctx.dir?"next":"prev",this._ondirectionchange&&this._ondirectionchange(this._ctx.dir),this}desc(){return this.reverse()}eachKey(e){var t=this._ctx;return t.keysOnly=!t.isMatch,this.each(function(t,n){e(n.key,n)})}eachUniqueKey(e){return this._ctx.unique="unique",this.eachKey(e)}eachPrimaryKey(e){var t=this._ctx;return t.keysOnly=!t.isMatch,this.each(function(t,n){e(n.primaryKey,n)})}keys(e){var t=this._ctx;t.keysOnly=!t.isMatch;var n=[];return this.each(function(e,t){n.push(t.key)}).then(function(){return n}).then(e)}primaryKeys(e){var t=this._ctx;if("next"===t.dir&&lX(t,!0)&&t.limit>0)return this._read(e=>{var n=l2(t,t.table.core.schema);return t.table.core.query({trans:e,values:!1,limit:t.limit,query:{index:n,range:t.range}})}).then(({result:e})=>e).then(e);t.keysOnly=!t.isMatch;var n=[];return this.each(function(e,t){n.push(t.primaryKey)}).then(function(){return n}).then(e)}uniqueKeys(e){return this._ctx.unique="unique",this.keys(e)}firstKey(e){return this.limit(1).keys(function(e){return e[0]}).then(e)}lastKey(e){return this.reverse().firstKey(e)}distinct(){var e=this._ctx,t=e.index&&e.table.schema.idxByName[e.index];if(!t||!t.multi)return this;var n={};return l0(this._ctx,function(e){var t=e.primaryKey.toString(),r=a9(n,t);return n[t]=!0,!r}),this}modify(e){var t=this._ctx;return this._write(n=>{var r;if("function"==typeof e)r=e;else{var o=a4(e),i=o.length;r=function(t){for(var n=!1,r=0;r<i;++r){var a=o[r],s=e[a];sd(t,a)!==s&&(sf(t,a,s),n=!0)}return n}}let a=t.table.core,{outbound:s,extractKey:l}=a.schema.primaryKey,u=this.db._options.modifyChunkSize||200,c=[],d=0,f=[],p=(e,t)=>{let{failures:n,numFailures:r}=t;for(let t of(d+=e-r,a4(n)))c.push(n[t])};return this.clone().primaryKeys().then(o=>{let i=c=>{let d=Math.min(u,o.length-c);return a.getMany({trans:n,keys:o.slice(c,c+d),cache:"immutable"}).then(f=>{let h=[],m=[],y=s?[]:null,g=[];for(let e=0;e<d;++e){let t=f[e],n={value:sv(t),primKey:o[c+e]};!1!==r.call(n,n.value,n)&&(null==n.value?g.push(o[c+e]):s||0===l5(l(t),l(n.value))?(m.push(n.value),s&&y.push(o[c+e])):(g.push(o[c+e]),h.push(n.value)))}let b=lX(t)&&t.limit===1/0&&("function"!=typeof e||e===ue)&&{index:t.index,range:t.range};return Promise.resolve(h.length>0&&a.mutate({trans:n,type:"add",values:h}).then(e=>{for(let t in e.failures)g.splice(parseInt(t),1);p(h.length,e)})).then(()=>(m.length>0||b&&"object"==typeof e)&&a.mutate({trans:n,type:"put",keys:y,values:m,criteria:b,changeSpec:"function"!=typeof e&&e}).then(e=>p(m.length,e))).then(()=>(g.length>0||b&&e===ue)&&a.mutate({trans:n,type:"delete",keys:g,criteria:b}).then(e=>p(g.length,e))).then(()=>o.length>c+d&&i(c+u))})};return i(0).then(()=>{if(c.length>0)throw new s$("Error modifying one or more objects",c,d,f);return o.length})})})}delete(){var e=this._ctx,t=e.range;return lX(e)&&(e.isPrimKey&&!lz||3===t.type)?this._write(n=>{let{primaryKey:r}=e.table.core.schema;return e.table.core.count({trans:n,query:{index:r,range:t}}).then(r=>e.table.core.mutate({trans:n,type:"deleteRange",range:t}).then(({failures:e,lastResult:t,results:n,numFailures:o})=>{if(o)throw new s$("Could not delete some values",Object.keys(e).map(t=>e[t]),r-o);return r-o}))}):this.modify(ue)}}let ue=(e,t)=>t.value=null;function ut(e,t){return e<t?-1:+(e!==t)}function un(e,t){return e>t?-1:+(e!==t)}function ur(e,t,n){var r=e instanceof ul?new e.Collection(e):e;return r._ctx.error=n?new n(t):TypeError(t),r}function uo(e){return new e.Collection(e,()=>us("")).limit(0)}function ui(e,t,n,r){var o,i,a,s,l,u,c,d=n.length;if(!n.every(e=>"string"==typeof e))return ur(e,"String expected.");function f(e){o="next"===e?e=>e.toUpperCase():e=>e.toLowerCase(),i="next"===e?e=>e.toLowerCase():e=>e.toUpperCase(),a="next"===e?ut:un;var t=n.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?"":r}f("next");var p=new e.Collection(e,()=>ua(s[0],l[d-1]+r));p._ondirectionchange=function(e){f(e)};var h=0;return p._addAlgorithm(function(e,n,r){var o=e.key;if("string"!=typeof o)return!1;var f=i(o);if(t(f,l,h))return!0;for(var p=null,m=h;m<d;++m){var y=function(e,t,n,r,o,i){for(var a=Math.min(e.length,r.length),s=-1,l=0;l<a;++l){var u=t[l];if(u!==r[l])return 0>o(e[l],n[l])?e.substr(0,l)+n[l]+n.substr(l+1):0>o(e[l],r[l])?e.substr(0,l)+r[l]+n.substr(l+1):s>=0?e.substr(0,s)+t[s]+n.substr(s+1):null;0>o(e[l],u)&&(s=l)}return a<r.length&&"next"===i?e+n.substr(e.length):a<e.length&&"prev"===i?e.substr(0,n.length):s<0?null:e.substr(0,s)+r[s]+n.substr(s+1)}(o,f,s[m],l[m],a,u);null===y&&null===p?h=m+1:(null===p||a(p,y)>0)&&(p=y)}return n(null!==p?function(){e.continue(p+c)}:r),!1}),p}function ua(e,t,n,r){return{type:2,lower:e,upper:t,lowerOpen:n,upperOpen:r}}function us(e){return{type:1,lower:e,upper:e}}class ul{get Collection(){return this._ctx.table.db.Collection}between(e,t,n,r){n=!1!==n,r=!0===r;try{return this._cmp(e,t)>0||0===this._cmp(e,t)&&(n||r)&&(!n||!r)?uo(this):new this.Collection(this,()=>ua(e,t,!n,!r))}catch(e){return ur(this,lW)}}equals(e){return null==e?ur(this,lW):new this.Collection(this,()=>us(e))}above(e){return null==e?ur(this,lW):new this.Collection(this,()=>ua(e,void 0,!0))}aboveOrEqual(e){return null==e?ur(this,lW):new this.Collection(this,()=>ua(e,void 0,!1))}below(e){return null==e?ur(this,lW):new this.Collection(this,()=>ua(void 0,e,!1,!0))}belowOrEqual(e){return null==e?ur(this,lW):new this.Collection(this,()=>ua(void 0,e))}startsWith(e){return"string"!=typeof e?ur(this,"String expected."):this.between(e,e+lU,!0,!0)}startsWithIgnoreCase(e){return""===e?this.startsWith(e):ui(this,(e,t)=>0===e.indexOf(t[0]),[e],lU)}equalsIgnoreCase(e){return ui(this,(e,t)=>e===t[0],[e],"")}anyOfIgnoreCase(){var e=sD.apply(sE,arguments);return 0===e.length?uo(this):ui(this,(e,t)=>-1!==t.indexOf(e),e,"")}startsWithAnyOfIgnoreCase(){var e=sD.apply(sE,arguments);return 0===e.length?uo(this):ui(this,(e,t)=>t.some(t=>0===e.indexOf(t)),e,lU)}anyOf(){let e=sD.apply(sE,arguments),t=this._cmp;try{e.sort(t)}catch(e){return ur(this,lW)}if(0===e.length)return uo(this);let n=new this.Collection(this,()=>ua(e[0],e[e.length-1]));n._ondirectionchange=n=>{t="next"===n?this._ascending:this._descending,e.sort(t)};let r=0;return n._addAlgorithm((n,o,i)=>{let a=n.key;for(;t(a,e[r])>0;)if(++r===e.length)return o(i),!1;return 0===t(a,e[r])||(o(()=>{n.continue(e[r])}),!1)}),n}notEqual(e){return this.inAnyRange([[-1/0,e],[e,this.db._maxKey]],{includeLowers:!1,includeUppers:!1})}noneOf(){let e=sD.apply(sE,arguments);if(0===e.length)return new this.Collection(this);try{e.sort(this._ascending)}catch(e){return ur(this,lW)}let t=e.reduce((e,t)=>e?e.concat([[e[e.length-1][1],t]]):[[-1/0,t]],null);return t.push([e[e.length-1],this.db._maxKey]),this.inAnyRange(t,{includeLowers:!1,includeUppers:!1})}inAnyRange(e,t){let n=this._cmp,r=this._ascending,o=this._descending,i=this._min,a=this._max;if(0===e.length)return uo(this);if(!e.every(e=>void 0!==e[0]&&void 0!==e[1]&&0>=r(e[0],e[1])))return ur(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=r;function d(e,t){return c(e[0],t[0])}try{(u=e.reduce(function(e,t){let r=0,o=e.length;for(;r<o;++r){let o=e[r];if(0>n(t[0],o[1])&&n(t[1],o[0])>0){o[0]=i(o[0],t[0]),o[1]=a(o[1],t[1]);break}}return r===o&&e.push(t),e},[])).sort(d)}catch(e){return ur(this,lW)}let f=0,p=l?e=>r(e,u[f][1])>0:e=>r(e,u[f][1])>=0,h=s?e=>o(e,u[f][0])>0:e=>o(e,u[f][0])>=0,m=p,y=new this.Collection(this,()=>ua(u[0][0],u[u.length-1][1],!s,!l));return y._ondirectionchange=e=>{"next"===e?(m=p,c=r):(m=h,c=o),u.sort(d)},y._addAlgorithm((e,t,n)=>{for(var o=e.key;m(o);)if(++f===u.length)return t(n),!1;return!!(!p(o)&&!h(o))||(0===this._cmp(o,u[f][1])||0===this._cmp(o,u[f][0])||t(()=>{c===r?e.continue(u[f][0]):e.continue(u[f][1])}),!1)}),y}startsWithAnyOf(){let e=sD.apply(sE,arguments);return e.every(e=>"string"==typeof e)?0===e.length?uo(this):this.inAnyRange(e.map(e=>[e,e+lU])):ur(this,"startsWithAnyOf() only works with strings")}}function uu(e){return lx(function(t){return uc(t),e(t.target.error),!1})}function uc(e){e.stopPropagation&&e.stopPropagation(),e.preventDefault&&e.preventDefault()}let ud=lJ(null,"storagemutated");class uf{_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{l$(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,n=this.db._state.dbOpenError;if(sl(!this.idbtrans),!e&&!t)switch(n&&n.name){case"DatabaseClosedError":throw new sB.DatabaseClosed(n);case"MissingAPIError":throw new sB.MissingAPI(n.message,n);default:throw new sB.OpenFailed(n)}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=>{uc(t),this._reject(e.error)}),e.onabort=lx(t=>{uc(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&&ud.storagemutated.fire(e.mutatedParts)}),this}_promise(e,t,n){if("readwrite"===e&&"readwrite"!==this.mode)return lV(new sB.ReadOnly("Transaction is readonly"));if(!this.active)return lV(new sB.TransactionInactive);if(this._locked())return new lu((r,o)=>{this._blockedFuncs.push([()=>{this._promise(e,t,n).then(r,o)},li])});if(n)return lC(()=>{var e=new lu((e,n)=>{this._lock();let r=t(e,n,this);r&&r.then&&r.then(e,n)});return e.finally(()=>this._unlock()),e._lib=!0,e});var r=new lu((e,n)=>{var r=t(e,n,this);r&&r.then&&r.then(e,n)});return r._lib=!0,r}_root(){return this.parent?this.parent._root():this}waitFor(e){var t=this._root();let n=lu.resolve(e);if(t._waitingFor)t._waitingFor=t._waitingFor.then(()=>n);else{t._waitingFor=n,t._waitingQueue=[];var r=t.idbtrans.objectStore(t.storeNames[0]);!function e(){for(++t._spinCount;t._waitingQueue.length;)t._waitingQueue.shift()();t._waitingFor&&(r.get(-1/0).onsuccess=e)}()}var o=t._waitingFor;return new lu((e,r)=>{n.then(n=>t._waitingQueue.push(lx(e.bind(null,n))),e=>t._waitingQueue.push(lx(r.bind(null,e)))).finally(()=>{t._waitingFor===o&&(t._waitingFor=null)})})}abort(){this.active&&(this.active=!1,this.idbtrans&&this.idbtrans.abort(),this._reject(new sB.Abort))}table(e){let t=this._memoizedTables||(this._memoizedTables={});if(a9(t,e))return t[e];let n=this.schema[e];if(!n)throw new sB.NotFound("Table "+e+" not part of transaction");let r=new this.db.Table(e,n,this);return r.core=this.db.core.table(e),t[e]=r,r}}function up(e,t,n,r,o,i,a){return{name:e,keyPath:t,unique:n,multi:r,auto:o,compound:i,src:(n&&!a?"&":"")+(r?"*":"")+(o?"++":"")+uh(t)}}function uh(e){return"string"==typeof e?e:e?"["+[].join.call(e,"+")+"]":""}function um(e,t,n){return{name:e,primKey:t,indexes:n,mappedClass:null,idxByName:sc(n,e=>[e.name,e])}}let uy=e=>{try{return e.only([[]]),uy=()=>[[]],[[]]}catch(e){return uy=()=>lU,lU}};function ug(e){return null==e?()=>{}:"string"==typeof e?1===e.split(".").length?t=>t[e]:t=>sd(t,e):t=>sd(t,e)}function ub(e){return[].slice.call(e)}let uv=0;function uw(e){return null==e?":id":"string"==typeof e?e:`[${e.join("+")}]`}function u_({_novip:e},t){let n=t.db,r=function(e,t,{IDBKeyRange:n,indexedDB:r},o){var i;return{dbcore:(i=function(e,t,n){let r;function o(e){if(3===e.type)return null;if(4===e.type)throw Error("Cannot convert never type to IDBKeyRange");let{lower:n,upper:r,lowerOpen:o,upperOpen:i}=e;return void 0===n?void 0===r?null:t.upperBound(r,!!i):void 0===r?t.lowerBound(n,!!o):t.bound(n,r,!!o,!!i)}let{schema:i,hasGetAll:a}=(r=ub(e.objectStoreNames),{schema:{name:e.name,tables:r.map(e=>n.objectStore(e)).map(e=>{let{keyPath:t,autoIncrement:n}=e,r=a3(t),o=null==t,i={},a={name:e.name,primaryKey:{name:null,isPrimaryKey:!0,outbound:o,compound:r,keyPath:t,autoIncrement:n,unique:!0,extractKey:ug(t)},indexes:ub(e.indexNames).map(t=>e.index(t)).map(e=>{let{name:t,unique:n,multiEntry:r,keyPath:o}=e,a={name:t,compound:a3(o),keyPath:o,unique:n,multiEntry:r,extractKey:ug(o)};return i[uw(o)]=a,a}),getIndexByKeyPath:e=>i[uw(e)]};return i[":id"]=a.primaryKey,null!=t&&(i[uw(t)]=a.primaryKey),a})},hasGetAll:r.length>0&&"getAll"in n.objectStore(r[0])&&!("u">typeof navigator&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604)}),s=i.tables.map(e=>{let t;return{name:t=e.name,schema:e,mutate:function({trans:e,type:n,keys:r,values:i,range:a}){return new Promise((s,l)=>{let u;s=lx(s);let c=e.objectStore(t),d=null==c.keyPath,f="put"===n||"add"===n;if(!f&&"delete"!==n&&"deleteRange"!==n)throw Error("Invalid operation type: "+n);let{length:p}=r||i||{length:1};if(r&&i&&r.length!==i.length)throw Error("Given keys array must have same length as given values array.");if(0===p)return s({numFailures:0,failures:{},results:[],lastResult:void 0});let h=[],m=[],y=0,g=e=>{++y,uc(e)};if("deleteRange"===n){if(4===a.type)return s({numFailures:y,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]=f?d?[i,r]:[i,null]:[r,null];if(f)for(let r=0;r<p;++r)h.push(u=t&&void 0!==t[r]?c[n](e[r],t[r]):c[n](e[r])),u.onerror=g;else for(let t=0;t<p;++t)h.push(u=c[n](e[t])),u.onerror=g}let b=e=>{let t=e.target.result;h.forEach((e,t)=>null!=e.error&&(m[t]=e.error)),s({numFailures:y,failures:m,results:"delete"===n?r:h.map(e=>e.result),lastResult:t})};u.onerror=e=>{g(e),b(e)},u.onsuccess=b})},getMany:({trans:e,keys:n})=>new Promise((r,o)=>{r=lx(r);let i=e.objectStore(t),a=n.length,s=Array(a),l,u=0,c=0,d=e=>{let t=e.target;s[t._pos]=t.result,++c===u&&r(s)},f=uu(o);for(let e=0;e<a;++e)null!=n[e]&&((l=i.get(n[e]))._pos=e,l.onsuccess=d,l.onerror=f,++u);0===u&&r(s)}),get:({trans:e,key:n})=>new Promise((r,o)=>{r=lx(r);let i=e.objectStore(t).get(n);i.onsuccess=e=>r(e.target.result),i.onerror=uu(o)}),query:e=>new Promise((n,r)=>{n=lx(n);let{trans:i,values:s,limit:l,query:u}=e,c=l===1/0?void 0:l,{index:d,range:f}=u,p=i.objectStore(t),h=d.isPrimaryKey?p:p.index(d.name),m=o(f);if(0===l)return n({result:[]});if(a){let e=s?h.getAll(m,c):h.getAllKeys(m,c);e.onsuccess=e=>n({result:e.target.result}),e.onerror=uu(r)}else{let e=0,t=!s&&"openKeyCursor"in h?h.openKeyCursor(m):h.openCursor(m),o=[];t.onsuccess=r=>{let i=t.result;return i?(o.push(s?i.value:i.primaryKey),++e===l?n({result:o}):void i.continue()):n({result:o})},t.onerror=uu(r)}}),openCursor:function({trans:e,values:n,query:r,reverse:i,unique:a}){return new Promise((s,l)=>{s=lx(s);let{index:u,range:c}=r,d=e.objectStore(t),f=u.isPrimaryKey?d:d.index(u.name),p=i?a?"prevunique":"prev":a?"nextunique":"next",h=!n&&"openKeyCursor"in f?f.openKeyCursor(o(c),p):f.openCursor(o(c),p);h.onerror=uu(l),h.onsuccess=lx(t=>{let n=h.result;if(!n)return void s(null);n.___id=++uv,n.done=!1;let r=n.continue.bind(n),o=n.continuePrimaryKey;o&&(o=o.bind(n));let i=n.advance.bind(n),a=()=>{throw Error("Cursor not stopped")};n.trans=e,n.stop=n.continue=n.continuePrimaryKey=n.advance=()=>{throw Error("Cursor not started")},n.fail=lx(l),n.next=function(){let e=1;return this.start(()=>e--?this.continue():this.stop()).then(()=>this)},n.start=e=>{let t=new Promise((e,t)=>{e=lx(e),h.onerror=uu(t),n.fail=t,n.stop=t=>{n.stop=n.continue=n.continuePrimaryKey=n.advance=a,e(t)}}),s=()=>{if(h.result)try{e()}catch(e){n.fail(e)}else n.done=!0,n.start=()=>{throw Error("Cursor behind last entry")},n.stop()};return h.onsuccess=lx(e=>{h.onsuccess=s,s()}),n.continue=r,n.continuePrimaryKey=o,n.advance=i,s(),t},s(n)},l)})},count({query:e,trans:n}){let{index:r,range:i}=e;return new Promise((e,a)=>{let s=n.objectStore(t),l=r.isPrimaryKey?s:s.index(r.name),u=o(i),c=u?l.count(u):l.count();c.onsuccess=lx(t=>e(t.target.result)),c.onerror=uu(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:uy(t),schema:i}}(t,n,o),e.dbcore.reduce((e,{create:t})=>({...e,...t(e)}),i))}}(e._middlewares,n,e._deps,t);e.core=r.dbcore,e.tables.forEach(t=>{let n=t.name;e.core.schema.tables.some(e=>e.name===n)&&(t.core=e.core.table(n),e[n]instanceof e.Table&&(e[n].core=t.core))})}function ux({_novip:e},t,n,r){n.forEach(n=>{let o=r[n];t.forEach(t=>{let r=so(t,n);(!r||"value"in r&&void 0===r.value)&&(t===e.Transaction.prototype||t instanceof e.Transaction?st(t,n,{get(){return this.table(n)},set(e){se(this,n,{value:e,writable:!0,configurable:!0,enumerable:!0})}}):t[n]=new e.Table(n,o))})})}function uS({_novip:e},t){t.forEach(t=>{for(let n in t)t[n]instanceof e.Table&&delete t[n]})}function uE(e,t){return e._cfg.version-t._cfg.version}function uD(e,t){let n,r={del:[],add:[],change:[]};for(n in e)t[n]||r.del.push(n);for(n in t){let o=e[n],i=t[n];if(o){let e={name:n,def:i,recreate:!1,del:[],add:[],change:[]};if(""+(o.primKey.keyPath||"")==""+(i.primKey.keyPath||"")&&(o.primKey.auto===i.primKey.auto||lz)){let t,n=o.idxByName,a=i.idxByName;for(t in n)a[t]||e.del.push(t);for(t in a){let r=n[t],o=a[t];r?r.src!==o.src&&e.change.push(o):e.add.push(o)}(e.del.length>0||e.add.length>0||e.change.length>0)&&r.change.push(e)}else e.recreate=!0,r.change.push(e)}else r.add.push([n,i])}return r}function uO(e,t,n,r){let o=e.db.createObjectStore(t,n.keyPath?{keyPath:n.keyPath,autoIncrement:n.auto}:{autoIncrement:n.auto});return r.forEach(e=>uk(o,e)),o}function uk(e,t){e.createIndex(t.name,t.keyPath,{unique:t.unique,multiEntry:t.multi})}function uP(e,t,n){let r={};return sa(t.objectStoreNames,0).forEach(e=>{let t=n.objectStore(e),o=t.keyPath,i=up(uh(o),o||"",!1,!1,!!t.autoIncrement,o&&"string"!=typeof o,!0),a=[];for(let e=0;e<t.indexNames.length;++e){let n=t.index(t.indexNames[e]);o=n.keyPath;var s=up(n.name,o,!!n.unique,!!n.multiEntry,!1,o&&"string"!=typeof o,!1);a.push(s)}r[e]=um(e,i,a)}),r}function uC({_novip:e},t,n){let r=n.db.objectStoreNames;for(let o=0;o<r.length;++o){let i=r[o],a=n.objectStore(i);e._hasGetAll="getAll"in a;for(let e=0;e<a.indexNames.length;++e){let n=a.indexNames[e],r=a.index(n).keyPath,o="string"==typeof r?r:"["+sa(r).join("+")+"]";if(t[i]){let e=t[i].idxByName[o];e&&(e.name=n,delete t[i].idxByName[o],t[i].idxByName[n]=e)}}}"u">typeof navigator&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&a2.WorkerGlobalScope&&a2 instanceof a2.WorkerGlobalScope&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604&&(e._hasGetAll=!1)}class uj{_parseStoresSpec(e,t){a4(e).forEach(n=>{if(null!==e[n]){var r=e[n].split(",").map((e,t)=>{let n=(e=e.trim()).replace(/([&*]|\+\+)/g,""),r=/^\[/.test(n)?n.match(/^\[(.*)\]$/)[1].split("+"):n;return up(n,r||null,/\&/.test(e),/\*/.test(e),/\+\+/.test(e),a3(r),0===t)}),o=r.shift();if(o.multi)throw new sB.Schema("Primary key cannot be multi-valued");r.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[n]=um(n,o,r)}})}stores(e){let t=this.db;this._cfg.storesSource=this._cfg.storesSource?a6(this._cfg.storesSource,e):e;let n=t._versions,r={},o={};return n.forEach(e=>{a6(r,e._cfg.storesSource),o=e._cfg.dbschema={},e._parseStoresSpec(r,o)}),t._dbSchema=o,uS(t,[t._allTables,t,t.Transaction.prototype]),ux(t,[t._allTables,t,t.Transaction.prototype,this._cfg.tables],a4(o),o),t._storeNames=a4(o),this}upgrade(e){return this._cfg.contentUpgrade=sJ(this._cfg.contentUpgrade||sW,e),this}}function uT(e,t){let n=e._dbNamesDB;return n||(n=e._dbNamesDB=new uY("__dbnames",{addons:[],indexedDB:e,IDBKeyRange:t})).version(1).stores({dbnames:"name"}),n.table("dbnames")}function uR(e){return e&&"function"==typeof e.databases}function uA(e){return lC(function(){return li.letThrough=!0,e()})}function uN(e){var t=t=>e.next(t),n=o(t),r=o(t=>e.throw(t));function o(e){return t=>{var o=e(t),i=o.value;return o.done?i:i&&"function"==typeof i.then?i.then(n,r):a3(i)?Promise.all(i).then(n,r):n(i)}}return o(t)()}function uM(e,t,n){var r=arguments.length;if(r<2)throw new sB.InvalidArgument("Too few arguments");for(var o=Array(r-1);--r;)o[r-1]=arguments[r];return n=o.pop(),[e,sm(o),n]}function uI(e,t,n){let r=a3(e)?e.slice():[e];for(let e=0;e<n;++e)r.push(t);return r}let u$={stack:"dbcore",name:"VirtualIndexMiddleware",level:1,create:function(e){return{...e,table(t){let n=e.table(t),{schema:r}=n,o={},i=[];function a(e,t,n){let r=uw(e),s=o[r]=o[r]||[],l=null==e?0:"string"==typeof e?1:e.length,u=t>0,c={...n,isVirtual:u,keyTail:t,keyLength:l,extractKey:ug(e),unique:!u&&n.unique};return s.push(c),c.isPrimaryKey||i.push(c),l>1&&a(2===l?e[0]:e.slice(0,l-1),t+1,n),s.sort((e,t)=>e.keyTail-t.keyTail),c}let s=a(r.primaryKey.keyPath,0,r.primaryKey);for(let e of(o[":id"]=[s],r.indexes))a(e.keyPath,0,e);function l(t){var n,r;let o=t.query.index;return o.isVirtual?{...t,query:{index:o,range:(n=t.query.range,r=o.keyTail,{type:1===n.type?2:n.type,lower:uI(n.lower,n.lowerOpen?e.MAX_KEY:e.MIN_KEY,r),lowerOpen:!0,upper:uI(n.upper,n.upperOpen?e.MIN_KEY:e.MAX_KEY,r),upperOpen:!0})}}:t}return{...n,schema:{...r,primaryKey:s,indexes:i,getIndexByKeyPath:function(e){let t=o[uw(e)];return t&&t[0]}},count:e=>n.count(l(e)),query:e=>n.query(l(e)),openCursor(t){let{keyTail:r,isVirtual:o,keyLength:i}=t.query.index;return o?n.openCursor(l(t)).then(n=>n&&Object.create(n,{continue:{value:function(o){null!=o?n.continue(uI(o,t.reverse?e.MAX_KEY:e.MIN_KEY,r)):t.unique?n.continue(n.key.slice(0,i).concat(t.reverse?e.MIN_KEY:e.MAX_KEY,r)):n.continue()}},continuePrimaryKey:{value(t,o){n.continuePrimaryKey(uI(t,e.MAX_KEY,r),o)}},primaryKey:{get:()=>n.primaryKey},key:{get(){let e=n.key;return 1===i?e[0]:e.slice(0,i)}},value:{get:()=>n.value}})):n.openCursor(t)}}}}}};function uL(e,t,n,r){return n=n||{},r=r||"",a4(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)?n[r+o]=t[o]:"Object"===e?uL(i,a,n,r+o+"."):i!==a&&(n[r+o]=t[o])}else i!==a&&(n[r+o]=t[o])}else n[r+o]=void 0}),a4(t).forEach(o=>{a9(e,o)||(n[r+o]=t[o])}),n}let uF={stack:"dbcore",name:"HooksMiddleware",level:2,create:e=>({...e,table(t){let n=e.table(t),{primaryKey:r}=n.schema;return{...n,mutate(e){let o=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 n.query({trans:t,values:!1,query:{index:r,range:o},limit:i}).then(({result:n})=>l({type:"delete",keys:n,trans:t}).then(r=>r.numFailures>0?Promise.reject(r.failures[0]):n.length<i?{failures:[],numFailures:0,lastResult:void 0}:e(t,{...o,lower:n[n.length-1],lowerOpen:!0},i)))})(e.trans,e.range,1e4),!0)}return n.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(r.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([]):n.getMany({trans:o.trans,keys:u,cache:"immutable"})).then(t=>{let o=u.map((n,o)=>{let u=t[o],c={onerror:null,onsuccess:null};if("delete"===e.type)i.fire.call(c,n,u,l);else if("add"===e.type||void 0===u){let t=a.fire.call(c,n,e.values[o],l);null==n&&null!=t&&(n=t,e.keys[o]=n,r.outbound||sf(e.values[o],r.keyPath,n))}else{let t=uL(u,e.values[o]),r=s.fire.call(c,t,n,u,l);if(r){let t=e.values[o];Object.keys(r).forEach(e=>{a9(t,e)?t[e]=r[e]:sf(t,e,r[e])})}}return c});return n.mutate(e).then(({failures:n,results:r,numFailures:i,lastResult:a})=>{for(let i=0;i<u.length;++i){let a=r?r[i]:u[i],s=o[i];null==a?s.onerror&&s.onerror(n[i]):s.onsuccess&&s.onsuccess("put"===e.type&&t[i]?e.values[i]:a)}return{failures:n,results:r,numFailures:i,lastResult:a}}).catch(e=>(o.forEach(t=>t.onerror&&t.onerror(e)),Promise.reject(e)))})}}}}})};function uB(e,t,n){try{if(!t||t.keys.length<e.length)return null;let r=[];for(let o=0,i=0;o<t.keys.length&&i<e.length;++o)0===l5(t.keys[o],e[i])&&(r.push(n?sv(t.values[o]):t.values[o]),++i);return r.length===e.length?r:null}catch(e){return null}}let uV={stack:"dbcore",level:-1,create:e=>({table:t=>{let n=e.table(t);return{...n,getMany:e=>{if(!e.cache)return n.getMany(e);let t=uB(e.keys,e.trans._cache,"clone"===e.cache);return t?lu.resolve(t):n.getMany(e).then(t=>(e.trans._cache={keys:e.keys,values:"clone"===e.cache?sv(t):t},t))},mutate:e=>("add"!==e.type&&(e.trans._cache=null),n.mutate(e))}}})};function uU(e){return!("from"in e)}let uW=function(e,t){if(!this){let t=new uW;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 uK(e,t,n){let r=l5(t,n);if(isNaN(r))return;if(r>0)throw RangeError();if(uU(e))return a6(e,{from:t,to:n,d:1});let o=e.l,i=e.r;if(0>l5(n,e.from))return o?uK(o,t,n):e.l={from:t,to:n,d:1,l:null,r:null},uG(e);if(l5(t,e.to)>0)return i?uK(i,t,n):e.r={from:t,to:n,d:1,l:null,r:null},uG(e);0>l5(t,e.from)&&(e.from=t,e.l=null,e.d=i?i.d+1:1),l5(n,e.to)>0&&(e.to=n,e.r=null,e.d=e.l?e.l.d+1:1);let a=!e.r;o&&!e.l&&uz(e,o),i&&a&&uz(e,i)}function uz(e,t){uU(t)||function e(t,{from:n,to:r,l:o,r:i}){uK(t,n,r),o&&e(t,o),i&&e(t,i)}(e,t)}function uH(e){let t=uU(e)?null:{s:0,n:e};return{next(e){let n=arguments.length>0;for(;t;)switch(t.s){case 0:if(t.s=1,n)for(;t.n.l&&0>l5(e,t.n.from);)t={up:t,n:t.n.l,s:1};else for(;t.n.l;)t={up:t,n:t.n.l,s:1};case 1:if(t.s=2,!n||0>=l5(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 uG(e){var t,n;let r=((null==(t=e.r)?void 0:t.d)||0)-((null==(n=e.l)?void 0:n.d)||0),o=r>1?"r":r<-1?"l":"";if(o){let t="r"===o?"l":"r",n={...e},r=e[o];e.from=r.from,e.to=r.to,e[o]=r[o],n[o]=r[t],e[t]=n,n.d=uq(n)}e.d=uq(e)}function uq({r:e,l:t}){return(e?t?Math.max(e.d,t.d):e.d:t?t.d:0)+1}a8(uW.prototype,{add(e){return uz(this,e),this},addKey(e){return uK(this,e,e),this},addKeys(e){return e.forEach(e=>uK(this,e,e)),this},[sx](){return uH(this)}});let uZ={stack:"dbcore",level:0,create:e=>{let t=e.schema.name,n=new uW(e.MIN_KEY,e.MAX_KEY);return{...e,table:r=>{let o=e.table(r),{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 n=`idb://${t}/${r}/${e}`;return s[n]||(s[n]=new uW)},u=l(""),c=l(":dels"),{type:d}=e,[f,p]="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(a3(f)){"delete"!==d&&(f=e.results),u.addKeys(f);let t=uB(f,h);t||"add"===d||c.addKeys(f),(t||p)&&i.indexes.forEach(function(e){let n=l(e.name||"");function r(t){return null!=t?e.extractKey(t):null}let o=t=>e.multiEntry&&a3(t)?t.forEach(e=>n.addKey(e)):n.addKey(t);(t||p).forEach((e,n)=>{let i=t&&r(t[n]),a=p&&r(p[n]);0!==l5(i,a)&&(null!=i&&o(i),null!=a&&o(a))})})}else if(f){let e={from:f.lower,to:f.upper};c.add(e),u.add(e)}else u.add(n),c.add(n),i.indexes.forEach(e=>l(e.name).add(n));return e})}},c=({query:{index:t,range:n}})=>{var r,o;return[t,new uW(null!=(r=n.lower)?r:e.MIN_KEY,null!=(o=n.upper)?o:e.MAX_KEY)]},d={get:e=>[a,new uW(e.key)],getMany:e=>[a,(new uW).addKeys(e.keys)],count:c,query:c,openCursor:c};return a4(d).forEach(e=>{u[e]=function(i){let{subscr:a}=li;if(a){let u=e=>{let n=`idb://${t}/${r}/${e}`;return a[n]||(a[n]=new uW)},c=u(""),f=u(":dels"),[p,h]=d[e](i);if(u(p.name||"").add(h),!p.isPrimaryKey){if("count"!==e){let t="query"===e&&l&&i.values&&o.query({...i,values:!1});return o[e].apply(this,arguments).then(n=>{if("query"===e){if(l&&i.values)return t.then(({result:e})=>(c.addKeys(e),n));let e=i.values?n.result.map(s):n.result;i.values?c.addKeys(e):f.addKeys(e)}else if("openCursor"===e){let e=i.values;return n&&Object.create(n,{key:{get:()=>(f.addKey(n.primaryKey),n.key)},primaryKey:{get(){let e=n.primaryKey;return f.addKey(e),e}},value:{get:()=>(e&&c.addKey(n.primaryKey),n.value)}})}return n})}f.add(n)}}return o[e].apply(this,arguments)}}),u}}}};class uY{constructor(e,t){var n;this._middlewares={},this.verno=0;const r=uY.dependencies;this._options=t={addons:uY.addons,autoOpen:!0,indexedDB:r.indexedDB,IDBKeyRange:r.IDBKeyRange,...t},this._deps={indexedDB:t.indexedDB,IDBKeyRange:t.IDBKeyRange};const{addons:o}=t;this._dbSchema={},this._versions=[],this._storeNames=[],this._allTables={},this.idbdb=null,this._novip=this;const 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=lJ(this,"populate","blocked","versionchange","close",{ready:[sJ,sW]}),this.on.ready.subscribe=ss(this.on.ready.subscribe,e=>(t,n)=>{uY.vip(()=>{let r=this._state;if(r.openComplete)r.dbOpenError||lu.resolve().then(t),n&&e(t);else if(r.onReadyBeingFired)r.onReadyBeingFired.push(t),n&&e(t);else{e(t);let r=this;n||e(function e(){r.on.ready.unsubscribe(t),r.on.ready.unsubscribe(e)})}})}),this.Collection=(n=this,lQ(l8.prototype,function(e,t){this.db=n;let r=lq,o=null;if(t)try{r=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:r,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 lQ(lY.prototype,function(t,n,r){this.db=e,this._tx=r,this.name=t,this.schema=n,this.hook=e._allTables[t]?e._allTables[t].hook:lJ(null,{creating:[sG,sW],reading:[sz,sK],updating:[sZ,sW],deleting:[sq,sW]})})}(this),this.Transaction=function(e){return lQ(uf.prototype,function(t,n,r,o,i){this.db=e,this.mode=t,this.storeNames=n,this.schema=r,this.chromeTransactionDurability=o,this.idbtrans=null,this.on=lJ(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(),lV(e)})})}(this),this.Version=function(e){return lQ(uj.prototype,function(t){this.db=e,this._cfg={version:t,storesSource:null,dbschema:{},tables:{},contentUpgrade:null}})}(this),this.WhereClause=function(e){return lQ(ul.prototype,function(t,n,r){this.db=e,this._ctx={table:t,index:":id"===n?null:n,or:r};let o=e._deps.indexedDB;if(!o)throw new 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=uy(t.IDBKeyRange),this._createTransaction=(e,t,n,r)=>new this.Transaction(e,t,n,this._options.chromeTransactionDurability,r),this._fireOnBlocked=e=>{this.on("blocked").fire(e),lK.filter(e=>e.name===this.name&&e!==this&&!e._state.vcFired).map(t=>t.on("versionchange").fire(e))},this.use(u$),this.use(uF),this.use(uZ),this.use(uV),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 n=t.filter(t=>t._cfg.version===e)[0];return n||(n=new this.Version(e),t.push(n),t.sort(uE),n.stores({}),this._state.autoSchema=!1,n)}_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:n,name:r}){r&&this.unuse({stack:e,name:r});let o=this._middlewares[e]||(this._middlewares[e]=[]);return o.push({stack:e,create:t,level:null==n?10:n,name:r}),o.sort((e,t)=>e.level-t.level),this}unuse({stack:e,name:t,create:n}){return e&&this._middlewares[e]&&(this._middlewares[e]=this._middlewares[e].filter(e=>n?e.create!==n:!!t&&e.name!==t)),this}open(){return function(e){var t;let n=e._state,{indexedDB:r}=e._deps;if(n.isBeingOpened||e.idbdb)return n.dbReadyPromise.then(()=>n.dbOpenError?lV(n.dbOpenError):e);sk&&(n.openCanceller._stackHolder=sj()),n.isBeingOpened=!0,n.dbOpenError=null,n.openComplete=!1;let o=n.openCanceller;function i(){if(n.openCanceller!==o)throw new sB.DatabaseClosed("db.open() was cancelled")}let a=n.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 n=function(){return indexedDB.databases().finally(e)};t=setInterval(n,100),n()}).finally(function(){return clearInterval(t)}):Promise.resolve()).then(()=>new lu((t,o)=>{if(i(),!r)throw new sB.MissingAPI;let a=e.name,u=n.autoSchema?r.open(a):r.open(a,Math.round(10*e.verno));if(!u)throw new sB.MissingAPI;u.onerror=uu(o),u.onblocked=lx(e._fireOnBlocked),u.onupgradeneeded=lx(t=>{if(s=u.transaction,n.autoSchema&&!e._options.allowEmptyDB){u.onerror=uc,s.abort(),u.result.close();let e=r.deleteDatabase(a);e.onsuccess=e.onerror=lx(()=>{o(new sB.NoSuchDatabase(`Database ${a} doesnt exist`))})}else{let n,r,a,f;s.onerror=uu(o);var i,c,d=t.oldVersion>0x4000000000000000?0:t.oldVersion;l=d<1,e._novip.idbdb=u.result,i=d/10,c=s,n=e._dbSchema,(r=e._createTransaction("readwrite",e._storeNames,n)).create(c),r._completion.catch(o),a=r._reject.bind(r),f=li.transless||li,lC(()=>{li.trans=r,li.transless=f,0===i?(a4(n).forEach(e=>{uO(c,e,n[e].primKey,n[e].indexes)}),u_(e,c),lu.follow(()=>e.on.populate.fire(r)).catch(a)):(function({_novip:e},t,n,r){let o=[],i=e._versions,a=e._dbSchema=uP(e,e.idbdb,r),s=!1;return i.filter(e=>e._cfg.version>=t).forEach(i=>{o.push(()=>{let o=a,l=i._cfg.dbschema;uC(e,o,r),uC(e,l,r),a=e._dbSchema=l;let u=uD(o,l);u.add.forEach(e=>{uO(r,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=r.objectStore(e.name);e.add.forEach(e=>uk(t,e)),e.change.forEach(e=>{t.deleteIndex(e.name),uk(t,e)}),e.del.forEach(e=>t.deleteIndex(e))}});let c=i._cfg.contentUpgrade;if(c&&i._cfg.version>t){let t;u_(e,r),n._memoizedTables={},s=!0;let i=sp(l);u.del.forEach(e=>{i[e]=o[e]}),uS(e,[e.Transaction.prototype]),ux(e,[e.Transaction.prototype],a4(i),i),n.schema=i;let a=sO(c);a&&lj();let d=lu.follow(()=>{if((t=c(n))&&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 r;s&&lz||(r=i._cfg.dbschema,[].slice.call(t.db.objectStoreNames).forEach(e=>null==r[e]&&t.db.deleteObjectStore(e))),uS(e,[e.Transaction.prototype]),ux(e,[e.Transaction.prototype],e._storeNames,e._dbSchema),n.schema=e._dbSchema})}),(function e(){return o.length?lu.resolve(o.shift()(n.idbtrans)).then(e):lu.resolve()})().then(()=>{var e;a4(e=a).forEach(t=>{r.db.objectStoreNames.contains(t)||uO(r,t,e[t].primKey,e[t].indexes)})})})(e,i,r,c).catch(a)})}},o),u.onsuccess=lx(()=>{s=null;let r=e._novip.idbdb=u.result,o=sa(r.objectStoreNames);if(o.length>0)try{let t,i=r.transaction(1===o.length?o[0]:o,"readonly");n.autoSchema?function({_novip:e},t,n){e.verno=t.version/10;let r=e._dbSchema=uP(0,t,n);e._storeNames=sa(t.objectStoreNames,0),ux(e,[e._allTables],a4(r),r)}(e,r,i):(uC(e,e._dbSchema,i),((t=uD(uP(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.")),u_(e,i)}catch(e){}lK.push(e),r.onversionchange=lx(t=>{n.vcFired=!0,e.on("versionchange").fire(t)}),r.onclose=lx(t=>{e.on("close").fire(t)}),l&&function({indexedDB:e,IDBKeyRange:t},n){uR(e)||"__dbnames"===n||uT(e,t).put({name:n}).catch(sW)}(e._deps,a),t()},o)}))]).then(()=>(i(),n.onReadyBeingFired=[],lu.resolve(uA(()=>e.on.ready.fire(e.vip))).then(function t(){if(n.onReadyBeingFired.length>0){let r=n.onReadyBeingFired.reduce(sJ,sW);return n.onReadyBeingFired=[],lu.resolve(uA(()=>r(e.vip))).then(t)}}))).finally(()=>{n.onReadyBeingFired=null,n.isBeingOpened=!1}).then(()=>e).catch(t=>{n.dbOpenError=t;try{s&&s.abort()}catch(e){}return o===n.openCanceller&&e._close(),lV(t)}).finally(()=>{n.openComplete=!0,a()})}(this)}_close(){let e=this._state,t=lK.indexOf(this);if(t>=0&&lK.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,n)=>{e.cancelOpen=n})}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((n,r)=>{let o=()=>{this.close();var e=this._deps.indexedDB.deleteDatabase(this.name);e.onsuccess=lx(()=>{!function({indexedDB:e,IDBKeyRange:t},n){uR(e)||"__dbnames"===n||uT(e,t).delete(n).catch(sW)}(this._deps,this.name),n()}),e.onerror=uu(r),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 a4(this._allTables).map(e=>this._allTables[e])}transaction(){let e=uM.apply(this,arguments);return this._transaction.apply(this,e)}_transaction(e,t,n){let r,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||"readonly"===e)r="readonly";else{if("rw"!=e&&"readwrite"!=e)throw new sB.InvalidArgument("Invalid transaction mode: "+e);r="readwrite"}if(i){if("readonly"===i.mode&&"readwrite"===r){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,n)=>{n(e)}):lV(e)}let s=(function e(t,n,r,o,i){return lu.resolve().then(()=>{let a,s=li.transless||li,l=t._createTransaction(n,r,t._dbSchema,o);if(o)l.idbtrans=o.idbtrans;else try{l.create(),t._state.PR1398_maxLoop=3}catch(o){return o.name===sF.InvalidState&&t.isOpen()&&--t._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),t._close(),t.open().then(()=>e(t,n,r,null,i))):lV(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=uN(a))},{trans:l,transless:s});return(a&&"function"==typeof a.then?lu.resolve(a).then(e=>l.active?e:lV(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),lV(e)))})}).bind(null,this,r,o,i,n);return i?i._promise(r,s,"lock"):li.trans?l$(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 uJ="u">typeof Symbol&&"observable"in Symbol?Symbol.observable:"@@observable";class uQ{constructor(e){this._subscribe=e}subscribe(e,t,n){return this._subscribe(e&&"function"!=typeof e?e:{next:e,error:t,complete:n})}[uJ](){return this}}function uX(e,t){return a4(t).forEach(n=>{uz(e[n]||(e[n]=new uW),t[n])}),e}try{i={indexedDB:a2.indexedDB||a2.mozIndexedDB||a2.webkitIndexedDB||a2.msIndexedDB,IDBKeyRange:a2.IDBKeyRange||a2.webkitIDBKeyRange}}catch(e){i={indexedDB:null,IDBKeyRange:null}}function u0(e){let t=u1;try{u1=!0,ud.storagemutated.fire(e)}finally{u1=t}}a8(uY,{...sU,delete:e=>new uY(e,{addons:[]}).delete(),exists:e=>new uY(e,{addons:[]}).open().then(e=>(e.close(),!0)).catch("NoSuchDatabaseError",()=>!1),getDatabaseNames(e){try{return(function({indexedDB:e,IDBKeyRange:t}){return uR(e)?Promise.resolve(e.databases()).then(e=>e.map(e=>e.name).filter(e=>"__dbnames"!==e)):uT(e,t).toCollection().primaryKeys()})(uY.dependencies).then(e)}catch(e){return lV(new sB.MissingAPI)}},defineClass:()=>function(e){a6(this,e)},ignoreTransaction:e=>li.trans?l$(li.transless,e):e(),vip:uA,async:function(e){return function(){try{var t=uN(e.apply(this,arguments));return t&&"function"==typeof t.then?t:lu.resolve(t)}catch(e){return lV(e)}}},spawn:function(e,t,n){try{var r=uN(e.apply(n,t||[]));return r&&"function"==typeof r.then?r:lu.resolve(r)}catch(e){return lV(e)}},currentTransaction:{get:()=>li.trans||null},waitFor:function(e,t){let n=lu.resolve("function"==typeof e?uY.ignoreTransaction(e):e).timeout(t||6e4);return li.trans?li.trans.waitFor(n):n},Promise:lu,debug:{get:()=>sk,set:e=>{sk=e,sP="dexie"===e?()=>!0:lH}},derive:sn,extend:a6,props:a8,override:ss,Events:lJ,on:ud,liveQuery:function(e){return new uQ(t=>{let n=sO(e),r=!1,o={},i={},a={get closed(){return r},unsubscribe:()=>{r=!0,ud.storagemutated.unsubscribe(c)}};t.start&&t.start(a);let s=!1,l=!1;function u(){return a4(i).some(e=>o[e]&&function(e,t){let n=uH(t),r=n.next();if(r.done)return!1;let o=r.value,i=uH(e),a=i.next(o.from),s=a.value;for(;!r.done&&!a.done;){if(0>=l5(s.from,o.to)&&l5(s.to,o.from)>=0)return!0;0>l5(o.from,s.from)?o=(r=n.next(s.from)).value:s=(a=i.next(o.from)).value}return!1}(o[e],i[e]))}let c=e=>{uX(o,e),u()&&d()},d=()=>{let f,p;if(s||r)return;o={};let h={},m=(n&&lj(),f=()=>lC(e,{subscr:h,trans:null}),p=li.trans?l$(li.transless,f):f(),n&&p.then(lT,lT),p);l||(ud("storagemutated",c),l=!0),s=!0,Promise.resolve(m).then(e=>{s=!1,r||(u()?d():(o={},i=h,t.next&&t.next(e)))},e=>{s=!1,t.error&&t.error(e),a.unsubscribe()})};return d(),a})},extendObservabilitySet:uX,getByKeyPath:sd,setByKeyPath:sf,delByKeyPath:function(e,t){"string"==typeof t?sf(e,t,void 0):"length"in t&&[].map.call(t,function(t){sf(e,t,void 0)})},shallowClone:sp,deepClone:sv,getObjectDiff:uL,cmp:l5,asap:su,minKey:-1/0,addons:[],connections:lK,errnames:sF,dependencies:i,semVer:"3.2.2",version:"3.2.2".split(".").map(e=>parseInt(e)).reduce((e,t,n)=>e+t/Math.pow(10,2*n))}),uY.maxKey=uy(uY.dependencies.IDBKeyRange),"u">typeof dispatchEvent&&"u">typeof addEventListener&&(ud("storagemutated",e=>{if(!u1){let t;lz?(t=document.createEvent("CustomEvent")).initCustomEvent("x-storagemutated-1",!0,!0,e):t=new CustomEvent("x-storagemutated-1",{detail:e}),u1=!0,dispatchEvent(t),u1=!1}}),addEventListener("x-storagemutated-1",({detail:e})=>{u1||u0(e)}));let u1=!1;if("u">typeof BroadcastChannel){let e=new BroadcastChannel("x-storagemutated-1");ud("storagemutated",t=>{u1||e.postMessage(t)}),e.onmessage=e=>{e.data&&u0(e.data)}}else if("u">typeof self&&"u">typeof navigator){ud("storagemutated",e=>{try{u1||("u">typeof localStorage&&localStorage.setItem("x-storagemutated-1",JSON.stringify({trig:Math.random(),changedParts:e})),"object"==typeof self.clients&&[...self.clients.matchAll({includeUncontrolled:!0})].forEach(t=>t.postMessage({type:"x-storagemutated-1",changedParts:e})))}catch(e){}}),"u">typeof addEventListener&&addEventListener("storage",e=>{if("x-storagemutated-1"===e.key){let t=JSON.parse(e.newValue);t&&u0(t.changedParts)}});let e=self.document&&navigator.serviceWorker;e&&e.addEventListener("message",function({data:e}){e&&"x-storagemutated-1"===e.type&&u0(e.changedParts)})}function u2(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}lu.rejectionMapper=function(e,t){if(!e||e instanceof sM||e instanceof TypeError||e instanceof SyntaxError||!e.name||!sV[e.name])return e;var n=new sV[e.name](t||e.message,e);return"stack"in e&&st(n,"stack",{get:function(){return this.inner.stack}}),n},sP=lH;class u4 extends uY{constructor(){super("EsmOffline"),u2(this,"syncQueue",void 0),u2(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 u3(){return new u4}let u6=new u4,u5={},u7=Z("offline-synchronization",{});function u9(){return u7}async function u8(){if(u7.getState().synchronization)return;let e=await u6.syncQueue.count(),t={},n=Object.entries(u5),r=n.length,o={},i=new AbortController,a=()=>{let e=u7.getState().synchronization;u7.setState({synchronization:{...e,pendingCount:e.pendingCount-1}})};try{u7.setState({synchronization:{totalCount:e,pendingCount:e,abortController:i}});for(let e=0;e<r&&n.length>0;e++)for(let e=n.length;e--;){let[r,s]=n[e],l=s.dependsOn.map(e=>t[e]);l.every(Boolean)&&(o[r]={},await Promise.all(l),t[r]=ce(s,o,i,a),n.splice(e,1))}await Promise.allSettled(Object.values(t))}finally{u7.setState({synchronization:void 0})}}async function ce({type:e,dependsOn:t,process:n},r,o,i){let a=[],s=[],l=await ct();await u6.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:f,dependencies:p=[]}]=a[u];try{let i=await n(d,{abort:o,index:u,items:s,userId:l,dependencies:p.map(({id:e,type:n})=>t.includes(n)?r[n][e]:void 0)});void 0!==f&&(r[e][f]=i),await u6.syncQueue.delete(c)}catch(e){await u6.syncQueue.update(c,{lastError:{name:e?.name,message:e?.message??e?.toString()}})}finally{i()}}}async function ct(){let e=await oY();return e?.uuid||"*"}async function cn(e,t,n,r){let o=r&&r.id;return void 0!==o&&await u6.syncQueue.where({type:t,userId:e}).filter(e=>e?.descriptor.id===o).delete().catch(uY.errnames.DatabaseClosed),await u6.syncQueue.add({type:t,content:n,userId:e,descriptor:r||{},createdOn:new Date}).catch(uY.errnames.DatabaseClosed,()=>-1)}async function cr(e,t,n){let r=await ct();return await cn(r,e,t,n)}async function co(e,t){return(await ci(e,t)).map(e=>e.content)}async function ci(e,t){return await u6.syncQueue.where(t?{type:t,userId:e}:{userId:e}).toArray().catch(uY.errnames.DatabaseClosed,()=>[])}async function ca(e){let t=await ct();return await co(t,e)}async function cs(e){let t=await ct();return await ci(t,e)}async function cl(e){return await u6.syncQueue.get(e).catch(uY.errnames.DatabaseClosed,()=>void 0)}function cu(e){return!!u5[e]?.options.onBeginEditSyncItem}async function cc(e){let t=await cl(e);if(!t)throw Error(`No sync item with the ID ${e} exists.`);let n=u5[t.type]?.options.onBeginEditSyncItem;if(!n)throw Error(`A sync item with the ID ${e} exists, but the associated handler (if one exists) doesn't support editing the item. You can avoid this error by either verifying that sync items of this type can be edited via the "canEditSynchronizationItemsOfType(type: string)" function or alternatively ensure that the synchronizaton handler for sync items of type "${t.type}" supports editing items.`);n(t)}async function cd(e){await u6.syncQueue.delete(e).catch(uY.errnames.DatabaseClosed)}function cf(e,t,n,r={}){u5[e]={type:e,dependsOn:t,process:n,options:r}}let cp="u">typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),ch=new Uint8Array(16),cm=[];for(let e=0;e<256;++e)cm.push((e+256).toString(16).slice(1));let cy=function(e,t,n){if(cp&&!t&&!e)return cp();let r=(e=e||{}).random||(e.rng||function(){if(!a&&!(a="u">typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)))throw Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return a(ch)})();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,t){n=n||0;for(let e=0;e<16;++e)t[n+e]=r[e];return t}return function(e,t=0){return cm[e[t+0]]+cm[e[t+1]]+cm[e[t+2]]+cm[e[t+3]]+"-"+cm[e[t+4]]+cm[e[t+5]]+"-"+cm[e[t+6]]+cm[e[t+7]]+"-"+cm[e[t+8]]+cm[e[t+9]]+"-"+cm[e[t+10]]+cm[e[t+11]]+cm[e[t+12]]+cm[e[t+13]]+cm[e[t+14]]+cm[e[t+15]]}(r)},cg="OFFLINE+";function cb(){return cg+cy()}function cv(e){return e.startsWith(cg)}let cw={};function c_(){return Object.values(cw)}function cx(e){cw[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.`),cw[e.id]=e}async function cS(e){let t=await cT();return await cE(t,e)}async function cE(e,t){let n=new u4;return await n.dynamicOfflineData.where(t?{type:t,users:e}:{users:e}).toArray().catch(uY.errnames.DatabaseClosed,()=>[])}async function cD(e,t){let n=await cT();return await cO(n,e,t)}async function cO(e,t,n){let r=new u4,o=await r.dynamicOfflineData.get({type:t,identifier:n}).catch(uY.errnames.DatabaseClosed,()=>void 0);o?o.users.includes(e)||await r.dynamicOfflineData.update(o.id,{users:[...o.users,e]}).catch(uY.errnames.DatabaseClosed):await r.dynamicOfflineData.add({users:[e],type:t,identifier:n}).catch(uY.errnames.DatabaseClosed)}async function ck(e,t){let n=await cT();return await cP(n,e,t)}async function cP(e,t,n){let r=new u4,o=await r.dynamicOfflineData.get({type:t,identifier:n,users:e}).catch(uY.errnames.DatabaseClosed,()=>void 0);o&&(o.users.length>1?await r.dynamicOfflineData.update(o.id,{users:o.users.filter(t=>t!==e)}).catch(uY.errnames.DatabaseClosed):await r.dynamicOfflineData.delete(o.id).catch(uY.errnames.DatabaseClosed))}async function cC(e,t){let n=await cS(e);await Promise.all(n.map(async e=>cj(e.type,e.identifier,t)))}async function cj(e,t,n){await cD(e,t);let r=new u4,o=await cT(),i=await r.dynamicOfflineData.get({type:e,identifier:t}).catch(uY.errnames.DatabaseClosed,()=>void 0),a=c_().filter(t=>t.type===e);if(!i)return;let s=await Promise.all(a.map(async e=>{try{return e.sync(t,n),{id:e.id,error:void 0}}catch(n){let t=n.message?.toString()??n.toString();return{id:e.id,error:t}}})),l=s.filter(e=>!e.error).map(e=>e.id),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 r.dynamicOfflineData.update(i.id,{syncState:d}).catch(uY.errnames.DatabaseClosed)}async function cT(){let e=(await oY()).uuid;if(!e)throw Error("Using the dynamic offline data API requires a logged in user.");return e}let cR=Z("offline-patients",{offlinePatientDataSyncState:{},handlers:{}});function cA(){return cI(),cR}function cN(e,t){cI(),cx({type:"patient",displayName:t.displayName,id:e,isSynced:()=>Promise.resolve(!0),sync:(e,n)=>t.onOfflinePatientAdded({patientUuid:e,signal:n??new AbortController().signal})})}async function cM(e){cI(),await cj("patient",e)}function cI(){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 c$(e,t,n=!0){if(e){let r=null,[o,i]=await Promise.all([oF(`${oI}/Patient/${e}`,t).catch(e=>r=e),n?cL(e):Promise.resolve(null)]);if(o.ok)return o.data;if(i)return i;if(r)throw r}return null}async function cL(e){let t=(await ca("patient-registration")).find(t=>t.fhirPatient.id===e);return t?.fhirPatient??null}function cF(e,t){let n=new CustomEvent(`openmrs:${e}`,{detail:t??void 0,cancelable:!0,bubbles:!0});return window.dispatchEvent(n)}function cB(e,t){let n=e=>{t("detail"in e&&null!==e.detail?e.detail:void 0)};return window.addEventListener(`openmrs:${e}`,n),()=>{window.removeEventListener(`openmrs:${e}`,n)}}var cV=n(99549);function cU(e){return{uuid:e.uuid,display:e.display}}function cW(e=null,t=null){let n=new URLSearchParams;e&&n.set("tag",e),t&&n.set("q",t);let r=n.toString();return oB(`${oM}/location${r?"?"+r:""}`).pipe((0,cV.map)(e=>e.data.results.map(cU))).pipe((0,cV.take)(1))}function cK(e){return{uuid:e.uuid,display:e.display,name:e.name}}function cz(){return oB(`${oM}/visittype`).pipe((0,cV.map)(e=>e.data.results.map(cK))).pipe((0,cV.take)(1))}var cH=n(29827),cG=((es={}).NEWVISIT="startVisit",es.EDITVISIT="editVisit",es.LOADING="loadingVisit",es),cq=((el={}).NOTSTARTED="notStarted",el.ONGOING="ongoing",el);let cZ="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))",cY=function(){try{return JSON.parse(sessionStorage.getItem("openmrs:visitStoreState")||"null")}catch(e){return null}}()||{patientUuid:null,manuallySetVisitUuid:null};function cJ(){return J("visit",cY)}function cQ(e,t){cJ().setState({patientUuid:e,manuallySetVisitUuid:t})}function cX(e,t){return oF(`${oM}/visit`,{signal:t.signal,method:"POST",headers:{"Content-type":"application/json"},body:e})}function c0(e,t,n){return oF(`${oM}/visit/${e}`,{signal:n.signal,method:"POST",headers:{"Content-type":"application/json"},body:t})}function c1(e,t,n){return oF(`${oM}/visit?patient=${e}&v=${n??cZ}`,{signal:t.signal,method:"GET",headers:{"Content-type":"application/json"}})}cJ().subscribe(e=>{var t;t=e,sessionStorage.setItem("openmrs:visitStoreState",JSON.stringify(t))});let c2=new cH.t(null);class c4{static get version(){return"1.4.0"}static toString(){return"JavaScript Expression Parser (JSEP) v"+c4.version}static addUnaryOp(e){return c4.max_unop_len=Math.max(e.length,c4.max_unop_len),c4.unary_ops[e]=1,c4}static addBinaryOp(e,t,n){return c4.max_binop_len=Math.max(e.length,c4.max_binop_len),c4.binary_ops[e]=t,n?c4.right_associative.add(e):c4.right_associative.delete(e),c4}static addIdentifierChar(e){return c4.additional_identifier_chars.add(e),c4}static addLiteral(e,t){return c4.literals[e]=t,c4}static removeUnaryOp(e){return delete c4.unary_ops[e],e.length===c4.max_unop_len&&(c4.max_unop_len=c4.getMaxKeyLen(c4.unary_ops)),c4}static removeAllUnaryOps(){return c4.unary_ops={},c4.max_unop_len=0,c4}static removeIdentifierChar(e){return c4.additional_identifier_chars.delete(e),c4}static removeBinaryOp(e){return delete c4.binary_ops[e],e.length===c4.max_binop_len&&(c4.max_binop_len=c4.getMaxKeyLen(c4.binary_ops)),c4.right_associative.delete(e),c4}static removeAllBinaryOps(){return c4.binary_ops={},c4.max_binop_len=0,c4}static removeLiteral(e){return delete c4.literals[e],c4}static removeAllLiterals(){return c4.literals={},c4}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 c4(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 c4.binary_ops[e]||0}static isIdentifierStart(e){return e>=65&&e<=90||e>=97&&e<=122||e>=128&&!c4.binary_ops[String.fromCharCode(e)]||c4.additional_identifier_chars.has(String.fromCharCode(e))}static isIdentifierPart(e){return c4.isIdentifierStart(e)||c4.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(c4.hooks[e]){let n={context:this,node:t};return c4.hooks.run(e,n),n.node}return t}searchHook(e){if(c4.hooks[e]){let t={context:this};return c4.hooks[e].find(function(e){return e.call(t.context,t),t.node}),t.node}}gobbleSpaces(){let e=this.code;for(;e===c4.SPACE_CODE||e===c4.TAB_CODE||e===c4.LF_CODE||e===c4.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:c4.COMPOUND,body:e};return this.runHook("after-all",t)}gobbleExpressions(e){let t=[],n,r;for(;this.index<this.expr.length;)if((n=this.code)===c4.SEMCOL_CODE||n===c4.COMMA_CODE)this.index++;else if(r=this.gobbleExpression())t.push(r);else if(this.index<this.expr.length){if(n===e)break;this.throwError('Unexpected "'+this.char+'"')}return t}gobbleExpression(){let e=this.searchHook("gobble-expression")||this.gobbleBinaryExpression();return this.gobbleSpaces(),this.runHook("after-expression",e)}gobbleBinaryOp(){this.gobbleSpaces();let e=this.expr.substr(this.index,c4.max_binop_len),t=e.length;for(;t>0;){if(c4.binary_ops.hasOwnProperty(e)&&(!c4.isIdentifierStart(this.code)||this.index+e.length<this.expr.length&&!c4.isIdentifierPart(this.expr.charCodeAt(this.index+e.length))))return this.index+=t,e;e=e.substr(0,--t)}return!1}gobbleBinaryExpression(){let e,t,n,r,o,i,a,s,l;if(!(i=this.gobbleToken())||!(t=this.gobbleBinaryOp()))return i;for(o={value:t,prec:c4.binaryPrecedence(t),right_a:c4.right_associative.has(t)},(a=this.gobbleToken())||this.throwError("Expected expression after "+t),r=[i,o,a];t=this.gobbleBinaryOp();){if(0===(n=c4.binaryPrecedence(t))){this.index-=t.length;break}o={value:t,prec:n,right_a:c4.right_associative.has(t)},l=t;let s=e=>o.right_a&&e.right_a?n>e.prec:n<=e.prec;for(;r.length>2&&s(r[r.length-2]);)a=r.pop(),t=r.pop().value,i=r.pop(),e={type:c4.BINARY_EXP,operator:t,left:i,right:a},r.push(e);(e=this.gobbleToken())||this.throwError("Expected expression after "+l),r.push(o,e)}for(s=r.length-1,e=r[s];s>1;)e={type:c4.BINARY_EXP,operator:r[s-1].value,left:r[s-2],right:e},s-=2;return e}gobbleToken(){let e,t,n,r;if(this.gobbleSpaces(),r=this.searchHook("gobble-token"))return this.runHook("after-token",r);if(e=this.code,c4.isDecimalDigit(e)||e===c4.PERIOD_CODE)return this.gobbleNumericLiteral();if(e===c4.SQUOTE_CODE||e===c4.DQUOTE_CODE)r=this.gobbleStringLiteral();else if(e===c4.OBRACK_CODE)r=this.gobbleArray();else{for(n=(t=this.expr.substr(this.index,c4.max_unop_len)).length;n>0;){if(c4.unary_ops.hasOwnProperty(t)&&(!c4.isIdentifierStart(this.code)||this.index+t.length<this.expr.length&&!c4.isIdentifierPart(this.expr.charCodeAt(this.index+t.length)))){this.index+=n;let e=this.gobbleToken();return e||this.throwError("missing unaryOp argument"),this.runHook("after-token",{type:c4.UNARY_EXP,operator:t,argument:e,prefix:!0})}t=t.substr(0,--n)}c4.isIdentifierStart(e)?(r=this.gobbleIdentifier(),c4.literals.hasOwnProperty(r.name)?r={type:c4.LITERAL,value:c4.literals[r.name],raw:r.name}:r.name===c4.this_str&&(r={type:c4.THIS_EXP})):e===c4.OPAREN_CODE&&(r=this.gobbleGroup())}return r?(r=this.gobbleTokenProperty(r),this.runHook("after-token",r)):this.runHook("after-token",!1)}gobbleTokenProperty(e){this.gobbleSpaces();let t=this.code;for(;t===c4.PERIOD_CODE||t===c4.OBRACK_CODE||t===c4.OPAREN_CODE||t===c4.QUMARK_CODE;){let n;if(t===c4.QUMARK_CODE){if(this.expr.charCodeAt(this.index+1)!==c4.PERIOD_CODE)break;n=!0,this.index+=2,this.gobbleSpaces(),t=this.code}this.index++,t===c4.OBRACK_CODE?((e={type:c4.MEMBER_EXP,computed:!0,object:e,property:this.gobbleExpression()}).property||this.throwError('Unexpected "'+this.char+'"'),this.gobbleSpaces(),(t=this.code)!==c4.CBRACK_CODE&&this.throwError("Unclosed ["),this.index++):t===c4.OPAREN_CODE?e={type:c4.CALL_EXP,arguments:this.gobbleArguments(c4.CPAREN_CODE),callee:e}:(t===c4.PERIOD_CODE||n)&&(n&&this.index--,this.gobbleSpaces(),e={type:c4.MEMBER_EXP,computed:!1,object:e,property:this.gobbleIdentifier()}),n&&(e.optional=!0),this.gobbleSpaces(),t=this.code}return e}gobbleNumericLiteral(){let e="",t,n;for(;c4.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);if(this.code===c4.PERIOD_CODE)for(e+=this.expr.charAt(this.index++);c4.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++));c4.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);c4.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+e+this.char+")")}return n=this.code,c4.isIdentifierStart(n)?this.throwError("Variable names cannot start with a number ("+e+this.char+")"):(n===c4.PERIOD_CODE||1===e.length&&e.charCodeAt(0)===c4.PERIOD_CODE)&&this.throwError("Unexpected period"),{type:c4.LITERAL,value:parseFloat(e),raw:e}}gobbleStringLiteral(){let e="",t=this.index,n=this.expr.charAt(this.index++),r=!1;for(;this.index<this.expr.length;){let t=this.expr.charAt(this.index++);if(t===n){r=!0;break}if("\\"===t)switch(t=this.expr.charAt(this.index++)){case"n":e+="\n";break;case"r":e+="\r";break;case"t":e+=" ";break;case"b":e+="\b";break;case"f":e+="\f";break;case"v":e+="\v";break;default:e+=t}else e+=t}return r||this.throwError('Unclosed quote after "'+e+'"'),{type:c4.LITERAL,value:e,raw:this.expr.substring(t,this.index)}}gobbleIdentifier(){let e=this.code,t=this.index;for(c4.isIdentifierStart(e)?this.index++:this.throwError("Unexpected "+this.char);this.index<this.expr.length;)if(e=this.code,c4.isIdentifierPart(e))this.index++;else break;return{type:c4.IDENTIFIER,name:this.expr.slice(t,this.index)}}gobbleArguments(e){let t=[],n=!1,r=0;for(;this.index<this.expr.length;){this.gobbleSpaces();let o=this.code;if(o===e){n=!0,this.index++,e===c4.CPAREN_CODE&&r&&r>=t.length&&this.throwError("Unexpected token "+String.fromCharCode(e));break}if(o===c4.COMMA_CODE){if(this.index++,++r!==t.length){if(e===c4.CPAREN_CODE)this.throwError("Unexpected token ,");else if(e===c4.CBRACK_CODE)for(let e=t.length;e<r;e++)t.push(null)}}else if(t.length!==r&&0!==r)this.throwError("Expected comma");else{let e=this.gobbleExpression();e&&e.type!==c4.COMPOUND||this.throwError("Expected comma"),t.push(e)}}return n||this.throwError("Expected "+String.fromCharCode(e)),t}gobbleGroup(){this.index++;let e=this.gobbleExpressions(c4.CPAREN_CODE);if(this.code===c4.CPAREN_CODE)return(this.index++,1===e.length)?e[0]:!!e.length&&{type:c4.SEQUENCE_EXP,expressions:e};this.throwError("Unclosed (")}gobbleArray(){return this.index++,{type:c4.ARRAY_EXP,elements:this.gobbleArguments(c4.CBRACK_CODE)}}}Object.assign(c4,{hooks:new class{add(e,t,n){if("string"!=typeof arguments[0])for(let e in arguments[0])this.add(e,arguments[0][e],arguments[1]);else(Array.isArray(e)?e:[e]).forEach(function(e){this[e]=this[e]||[],t&&this[e][n?"unshift":"push"](t)},this)}run(e,t){this[e]=this[e]||[],this[e].forEach(function(e){e.call(t&&t.context?t.context:t,t)})}},plugins:new class{constructor(e){this.jsep=e,this.registered={}}register(...e){e.forEach(e=>{if("object"!=typeof e||!e.name||!e.init)throw Error("Invalid JSEP plugin format");this.registered[e.name]||(e.init(this.jsep),this.registered[e.name]=e)})}}(c4),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"}),c4.max_unop_len=c4.getMaxKeyLen(c4.unary_ops),c4.max_binop_len=c4.getMaxKeyLen(c4.binary_ops);let c3=e=>new c4(e).parse(),c6=Object.getOwnPropertyNames(class{});Object.getOwnPropertyNames(c4).filter(e=>!c6.includes(e)&&void 0===c3[e]).forEach(e=>{c3[e]=c4[e]}),c3.Jsep=c4,c3.plugins.register({name:"ternary",init(e){e.hooks.add("after-expression",function(t){if(t.node&&this.code===e.QUMARK_CODE){this.index++;let n=t.node,r=this.gobbleExpression();if(r||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===e.COLON_CODE){this.index++;let o=this.gobbleExpression();if(o||this.throwError("Expected expression"),t.node={type:"ConditionalExpression",test:n,consequent:r,alternate:o},n.operator&&e.binary_ops[n.operator]<=.9){let r=n;for(;r.right.operator&&e.binary_ops[r.right.operator]<=.9;)r=r.right;t.node.test=r.right,r.right=t.node,t.node=n}}else this.throwError("Expected :")}})}});let c5="ArrowFunctionExpression",c7={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)}},c9={...c7,Promise};function c8(e,t={}){return da(e,t,du)}async function de(e,t={}){return ds(e,t,du)}function dt(e,t={}){return da(e,t,dc)}function dn(e,t={}){return ds(e,t,dc)}function dr(e,t={}){return da(e,t,dd)}function di(e,t={}){return ds(e,t,dd)}function da(e,t={},n){if("string"!=typeof e&&("object"!=typeof e||!e||!("type"in e)))throw`Unknown expression type ${e}. Expressions must either be a string or pre-compiled string.`;if("string"==typeof e&&0===e.trim().length)throw{type:"Empty expression",message:"Expression cannot be an empty string"};null==t&&(t={});let r=dh(t,c7),o=df("string"==typeof e?c3(e):e,r);if(n(o))return o;throw{type:"Invalid result",message:"string"==typeof e?`The expression ${e} did not produce a valid result`:"The expression did not produce a valid result"}}async function ds(e,t={},n){if("string"!=typeof e&&("object"!=typeof e||!e||!("type"in e)))return Promise.reject(`Unknown expression type ${e}. Expressions must either be a string or pre-compiled string.`);if("string"==typeof e&&0===e.trim().length)throw{type:"Empty expression",message:"Expression cannot be an empty string"};null==t&&(t={});let r=dh(t,c9);return Promise.resolve(df("string"==typeof e?c3(e):e,r)).then(t=>{if(n(t))return t;throw{type:"Invalid result",message:"string"==typeof e?`The expression ${e} did not produce a valid result`:"The expression did not produce a valid result"}})}function dl(e){return c3(e)}function du(e){return"string"==typeof e||"number"==typeof e||"boolean"==typeof e||null==e||e instanceof Date}function dc(e){return"boolean"==typeof e}function dd(e){return"number"==typeof e}function df(e,t){switch(e.type){case"UnaryExpression":var n,r,o,i,a,s,l,u,c,d,f,p,h=e,m=t;let y=df(h.argument,m);switch(h.operator){case"+":return+y;case"-":return-y;case"~":return~y;case"!":return!y;default:throw`Expression evaluator does not support operator '${h.operator}''`}case"BinaryExpression":var g=e,b=t;let v=df(g.left,b),w=df(g.right,b);switch(g.operator){case"+":return v+w;case"-":return v-w;case"*":return v*w;case"/":return v/w;case"%":return v%w;case"**":return v**w;case"==":return v==w;case"===":return v===w;case"!=":return v!=w;case"!==":return v!==w;case">":return v>w;case">=":return v>=w;case"<":return v<w;case"<=":return v<=w;case"in":return v in w;case"&&":return v&&w;case"||":return v||w;case"??":return v??w;default:throw`Expression evaluator does not support operator '${g.operator}' operator`}case"ConditionalExpression":return n=e,r=t,df(n.test,r)?df(n.consequent,r):df(n.alternate,r);case"CallExpression":var x=e,S=t;let E=x.arguments?.map(dm(S)),D=df(x.callee,S);if(D){if("function"!=typeof D)throw`${dg(x.callee)} is not a function`}else throw`No function named ${dg(x.callee)} is defined in this context`;return D(...E);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,n,r)=>{let o=e[r];return function e(t){if("string"==typeof t||"number"==typeof t||"boolean"==typeof t||"function"==typeof t||null===t||t instanceof RegExp)return!0;if("object"==typeof t){for(let n of Object.keys(t))if(!e(t[n]))return!1;return!0}if(Array.isArray(t)){for(let n of t)if(!e(n))break}return!1}(o)&&t.push([n,o]),t},[]));return df(o.body,i.addVariables(t))}).bind(i.thisObj??null);case"MemberExpression":return function(e,t){let n,r=df(e.object,t);if(void 0===r)switch(e.object.type){case"Identifier":{let n=dp(e.object,t);throw ReferenceError(`ReferenceError: ${n} is not defined`)}case"MemberExpression":{let n=dp(e.property,t);throw TypeError(`TypeError: cannot read properties of undefined (reading '${n}')`)}default:throw`VisitMemberExpression does not support operator '${e.object.type}' type`}let o=r;if("string"==typeof r)o=String.prototype;else if("number"==typeof r)o=Number.prototype;else if("function"==typeof r);else if("object"!=typeof r)throw`VisitMemberExpression does not support member access on type ${typeof r}`;switch(t.thisObj=o,e.property.type){case"Identifier":case"MemberExpression":n=df(e.property,t);break;default:{let o=df(e.property,t);if(void 0===o)throw{type:"Illegal property access",message:"No property was supplied to the property access"};dy(o),n=r[o]}}return"function"==typeof n?n.bind(r):n}(e,t);case"ArrayExpression":return a=e,s=t,a.elements?.map(dm(s));case"SequenceExpression":let k;return l=e,u=t,(k=l.expressions.map(dm(u)))[k.length-1];case"NewExpression":var P=e,C=t;if(P.callee&&"Identifier"===P.callee.type){let e=P.arguments?.map(dm(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 dy((c=e).value),c.value;case"Identifier":var j=e,T=t;dy(j.name);let R=T.thisObj;if(R&&("object"==typeof R||"function"==typeof R)&&j.name in R){let e=R[j.name];return dy(e),e}if(T.variables&&j.name in T.variables){let e=T.variables[j.name];return dy(e),e}return j.name in T.globals?T.globals[j.name]:void 0;case"TemplateLiteral":let A,N;return d=e,f=t,A=d.expressions?.map(dm(f))??[],(N=d.quasis?.map(dm(f))??[]).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:(p=e).cooked,tail:p.tail};default:throw`Expression evaluator does not support expression of type '${e.type}'`}}function dp(e,t){switch(e.type){case"Literal":return e.value;case"Identifier":return e.name;case"MemberExpression":return dp(e.property,t);default:throw`VisitExpressionName does not support expression of type '${e.type}'`}}function dh(e,t){let n={thisObj:void 0,variables:{...e},globals:{...t},addVariables(e){return this.variables={...this.variables,...e},this}};return n.addVariables.bind(n),n}function dm(e){return function(t){return null===t?null:df(t,e)}}function dy(e){if("__proto__"===e||"prototype"===e||"constructor"===e)throw{type:"Illegal property access",message:`Cannot access the ${e} property of objects`}}function dg(e){return e?"MemberExpression"===e.type?e.property?.name:e.name:null}function db(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:{...c9},isLocalExpression:!1,variables:new Set};return dv("string"==typeof e?c3(e):e,t),[...t.variables]}function dv(e,t){switch(e.type){case"UnaryExpression":return r=e,o=t,dv(r.argument,o);case"BinaryExpression":return i=e,a=t,[dv(i.left,a),dv(i.right,a)].filter(Boolean);case"ConditionalExpression":return s=e,l=t,[dv(s.consequent,l),dv(s.test,l),dv(s.alternate,l)].filter(Boolean);case"CallExpression":let n;return u=e,c=t,n=dv(u.callee,c),u.arguments?.map(dw(c)),n;case"ArrowFunctionExpression":var r,o,i,a,s,l,u,c,d,f,p,h,m,y,g,b,v,w,x=e,S=t;let E={...S};E.isLocalExpression=!0;let D=x.params?.map(dw(E))??[],O=dv(x.body,E)??[];if(O&&Array.isArray(O))for(let e of O)D.includes(e)||S.variables.add(e);return;case"MemberExpression":let k;return d=e,f=t,dv(d.object,f),void((k={...f}).isLocalExpression=!0,dv(d.property,k));case"ArrayExpression":return p=e,h=t,void p.elements?.map(dw(h));case"SequenceExpression":return m=e,y=t,void m.expressions?.map(dw(y));case"NewExpression":return g=e,b=t,void g.arguments?.map(dw(b));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 v=e,w=t,void(v.expressions?.map(dw(w)),v.quasis?.map(dw(w)));default:throw`Expression evaluator does not support expression of type '${e.type}'`}}function dw(e){return function(t){return null===t?null:dv(t,e)}}c3.plugins.register({name:"arrow",init(e){e.addBinaryOp("=>",.1,!0),e.hooks.add("gobble-expression",function(t){if(this.gobbleSpaces(),this.code===e.OPAREN_CODE){let n=this.index;if(this.index++,this.gobbleSpaces(),this.code===e.CPAREN_CODE){this.index++;let e=this.gobbleBinaryOp();if("=>"===e){let n=this.gobbleBinaryExpression();n||this.throwError("Expected expression after "+e),t.node={type:c5,params:null,body:n};return}}this.index=n}}),e.hooks.add("after-expression",function(t){!function t(n){n&&(Object.values(n).forEach(e=>{e&&"object"==typeof e&&t(e)}),"=>"===n.operator&&(n.type=c5,n.params=n.left?[n.left]:null,n.body=n.right,n.params&&n.params[0].type===e.SEQUENCE_EXP&&(n.params=n.params[0].expressions),delete n.left,delete n.right,delete n.operator))}(t.node)})}}),c3.plugins.register({name:"new",init(e){e.addUnaryOp("new"),e.hooks.add("after-token",function(t){let n=t.node;if(n&&"new"===n.operator){n.argument&&[e.CALL_EXP,e.MEMBER_EXP].includes(n.argument.type)||this.throwError("Expected new function()"),t.node=n.argument;let r=t.node;for(;r.type===e.MEMBER_EXP||r.type===e.CALL_EXP&&r.callee.type===e.MEMBER_EXP;)r=r.type===e.MEMBER_EXP?r.object:r.callee.object;r.type="NewExpression"}})}}),c3.plugins.register({name:"numbers",init(e){function t(e){return"x"===e||"X"===e?(this.index+=2,[[48,57],[65,70],[97,102]]):"b"===e||"B"===e?(this.index+=2,[[48,49]]):"o"===e||"O"===e||e>="0"&&e<="7"?(this.index+=e<="7"?1:2,[[48,55]]):null}function n(t){let n=this.index,r="",o=()=>{for(;e.isDecimalDigit(this.code)||95===this.code;)95===this.code?this.index++:r+=this.expr.charAt(this.index++)};o(),this.code===e.PERIOD_CODE&&(r+=this.expr.charAt(this.index++),o());let i=this.char;("e"===i||"E"===i)&&(r+=this.expr.charAt(this.index++),("+"===(i=this.char)||"-"===i)&&(r+=this.expr.charAt(this.index++)),o(),e.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+r+this.char+")"));let a=this.code;if(e.isIdentifierStart(a))this.throwError("Variable names cannot start with a number ("+r+this.char+")");else if(a===e.PERIOD_CODE){r.length>1&&this.throwError(`Unexpected period ${JSON.stringify({chCode:a,number:r},null,2)}`),this.index=n;return}t.node={type:e.LITERAL,value:parseFloat(r),raw:this.expr.substring(n,this.index)}}e.hooks.add("gobble-token",function(r){if(48===this.code){var o,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,n.call(this,r);return}this.throwError("unexpected char within number")}r.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)&&n.call(this,r)})}}),c3.plugins.register({name:"regex",init(e){e.hooks.add("gobble-token",function(t){if(47===this.code){let n=++this.index,r=!1;for(;this.index<this.expr.length;){if(47===this.code&&!r){let r,o=this.expr.slice(n,this.index),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{r=new RegExp(o,i)}catch(e){this.throwError(e.message)}return t.node={type:e.LITERAL,value:r,raw:this.expr.slice(n-1,this.index)},t.node=this.gobbleTokenProperty(t.node),t.node}this.code===e.OBRACK_CODE?r=!0:r&&this.code===e.CBRACK_CODE&&(r=!1),this.index+=92===this.code?2:1}this.throwError("Unclosed Regex")}})}}),c3.plugins.register({name:"ternary",init(e){e.hooks.add("after-expression",function(t){if(t.node&&this.code===e.QUMARK_CODE){this.index++;let n=t.node,r=this.gobbleExpression();if(r||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===e.COLON_CODE){this.index++;let o=this.gobbleExpression();if(o||this.throwError("Expected expression"),t.node={type:"ConditionalExpression",test:n,consequent:r,alternate:o},n.operator&&e.binary_ops[n.operator]<=.9){let r=n;for(;r.right.operator&&e.binary_ops[r.right.operator]<=.9;)r=r.right;t.node.test=r.right,r.right=t.node,t.node=n}}else this.throwError("Expected :")}})}}),c3.plugins.register({name:"jsepTemplateLiteral",init(e){function t(e,n=!0){if(96===this.code){let t={type:"TemplateLiteral",quasis:[],expressions:[]},r="",o="",i=!1,a=this.expr.length,s=()=>t.quasis.push({type:"TemplateElement",value:{raw:o,cooked:r},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,n&&(e.node=this.gobbleTokenProperty(e.node)),e.node;if("$"===a&&"{"===this.expr.charAt(this.index+1))this.index+=2,s(),o="",r="",t.expressions.push(...this.gobbleExpressions(125)),125!==this.code&&this.throwError("unclosed ${");else if("\\"===a)switch(o+=a,a=this.expr.charAt(++this.index),o+=a,a){case"n":r+="\n";break;case"r":r+="\r";break;case"t":r+=" ";break;case"b":r+="\b";break;case"f":r+="\f";break;case"v":r+="\v";break;default:r+=a}else r+=a,o+=a}this.throwError("Unclosed `")}}e.hooks.add("gobble-token",t),e.hooks.add("after-token",function(n){if((n.node.type===e.IDENTIFIER||n.node.type===e.MEMBER_EXP)&&96===this.code)return n.node={type:"TaggedTemplateExpression",tag:n.node,quasi:t.bind(this)(n,!1)},n.node=this.gobbleTokenProperty(n.node),n.node})}}),c3.addBinaryOp("in",7),c3.addBinaryOp("??",1);let d_=J("feature-flags",{flags:function(){let e={};for(let t of Object.keys(localStorage))if(t.startsWith("openmrs:feature-flag:")){let n=t.replace("openmrs:feature-flag:",""),r=JSON.parse(localStorage.getItem(`openmrs:feature-flag-meta:${n}`)||"{}");e[n]={enabled:"true"===localStorage.getItem(t),...r}}return e}()});function dx(e,t,n){d_.setState(r=>({flags:{...r.flags,[e]:{enabled:r.flags[e]?.enabled??!1,label:t,description:n}}}))}function dS(){let e=d_.getState().flags;Object.keys(localStorage).filter(e=>e.startsWith("openmrs:feature-flag:")).forEach(t=>{let n=t.replace("openmrs:feature-flag:","");e[n]||(localStorage.removeItem(t),localStorage.removeItem(`openmrs:feature-flag-meta:${n}`))})}function dE(e){return d_.getState().flags[e].enabled}function dD(e,t){d_.subscribe(n=>{t(n.flags[e].enabled)})}function dO(e,t){d_.setState(n=>({flags:{...n.flags,[e]:{...n.flags[e],enabled:t}}}))}function dk(e){return!window.offlineEnabled||(e??navigator.onLine)}d_.subscribe(e=>{for(let[t,n]of Object.entries(e.flags))localStorage.setItem(`openmrs:feature-flag:${t}`,n.enabled.toString()),localStorage.setItem(`openmrs:feature-flag-meta:${t}`,JSON.stringify({label:n.label,description:n.description}))});var dP=e4(function(e,t,n){eH(e,t,n)});function dC(e=!0,t=!1){return dj(dk(),e,t)}function dj(e,t=!0,n=!1){return!!(e?t:n)}let dT=Z("extensionsInternal",{slots:{},extensions:{}}),dR=Z("extensionRenderings",{renderings:new Map}),dA=()=>J("extensionsInternal",{slots:{},extensions:{}}),dN=()=>J("extensionRenderings",{renderings:new Map});function dM(e){let t=dT.getState(),n=e(t);n!==t&&dT.setState(n)}let dI=null,d$=null;function dL(){let e=dR.getState();return dI&&e===d$||(dI=new Map(e.renderings),d$=e,function(e){for(let t of(dq.clear(),e.values()))dY(t,1);dZ=!0}(dI)),dI}function dF(e){d$={renderings:e},dR.setState(d$,!0)}function dB(e){let t=dL();t.has(e.renderingId)||(t.set(e.renderingId,e),dY(e,1),dF(t))}function dV(e){let t=dL(),n=t.get(e);n&&(t.delete(e),dY(n,-1),dF(t))}let dU=()=>J("extensions",{slots:{}}),dW=0,dK=new Set;function dz(e){dW++;try{return e()}finally{if(0==--dW&&dK.size>0){let e=Array.from(dK);for(let t of(dK.clear(),e))dH(t)}}}function dH(e){try{e()}catch(t){console.error(`The extension system's '${e.name}' recomputation failed`,t)}}function dG(e){dW>0?dK.add(e):dH(e)}let dq=new Map,dZ=!1;function dY(e,t){let n=JSON.stringify([e.slotName,e.extensionId,e.slotModuleName,e.extensionModuleName]),r=dq.get(n);if(!r){if(t<0)return;dq.set(n,{count:1,record:{slotModuleName:e.slotModuleName,extensionModuleName:e.extensionModuleName,slotName:e.slotName,extensionId:e.extensionId}}),dZ=!0;return}r.count+=t,r.count<1&&(dq.delete(n),dZ=!0)}function dJ(){var e,t;if(dL(),!dZ)return;dZ=!1;let n=Array.from(dq.values(),({record:e})=>e);n.sort(dQ),e=t4.getState().mountedExtensions,t=n,e.length===t.length&&e.every((e,n)=>0===dQ(e,t[n]))||t4.setState({mountedExtensions:n})}function dQ(e,t){return dX(e.slotName,t.slotName)||dX(e.extensionId,t.extensionId)||dX(e.slotModuleName,t.slotModuleName)||dX(e.extensionModuleName,t.extensionModuleName)}function dX(e,t){return e===t?0:e<t?-1:1}dJ(),dR.subscribe(()=>dG(dJ));let d0=dA(),d1=dU(),d2=t6(),d4=t9(),d3=new Set,d6=!1;function d5(e){if(null===e)d3=null;else if(null!==d3)for(let t of e)d3.add(t);dG(d7)}function d7(){if(!d6){d6=!0;try{for(let e=1;;e++){let t=d3;if(null!==t&&0===t.size)return;d3=new Set;try{!function(e,t,n,r,o,i=null){let a=d1.getState().slots,s={},l=!1,u=dk(),c=Object.entries(r.flags).filter(([,{enabled:e}])=>e).map(([e])=>e);for(let[r,d]of Object.entries(e.slots)){let f=a[r];if(f&&i&&!i.has(r)){s[r]=f;continue}let{config:p}=t7(t,d.name),h=function(e,t,n,r,o,i,a){let s=function(e,t){let n=e.add||[],r=e.remove||[],o=e.order||[],{extensions:i}=d0.getState();return[...t,...n].filter(e=>!r.includes(e)).sort((e,n)=>fl(e,o,i[ft(e)]?.order,t)-fl(n,o,i[ft(n)]?.order,t))}(n,t.slots[e].attachedIds),l=[];for(let u of s){let{config:s}=ne(r,e,u),c=nt(n,e,u),d=c?dP({},s,c):s,f=ft(u),p=t.extensions[f];if(p){let e=d?.["Display conditions"]?.privileges??p.privileges??[];if(e&&("string"==typeof e||Array.isArray(e)&&e.length>0)&&(!a?.user||!oZ(e,a.user))||p.featureFlag&&!o.includes(p.featureFlag)||window.offlineEnabled&&!dj(i,p.online,p.offline))continue;l.push({id:u,name:f,moduleName:p.moduleName,config:d,featureFlag:p.featureFlag,meta:p.meta,online:d?.["Display conditions"]?.online??p.online??!0,offline:d?.["Display conditions"]?.offline??p.offline??!1,displayConditionExpression:d?.["Display conditions"]?.expression||p.displayExpression})}}return l}(r,e,p,n,c,u,o.session);f&&f.moduleName===d.moduleName&&tm(f.candidateExtensions,h)?s[r]=f:(s[r]={moduleName:d.moduleName,candidateExtensions:h},l=!0)}(l||Object.keys(a).length!==Object.keys(s).length)&&d1.setState({slots:s})}(d0.getState(),d2.getState(),d4.getState(),d_.getState(),oU.getState(),t)}catch(e){throw d3=null===t||null===d3?null:new Set([...t,...d3]),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{d6=!1}}}function d9(e,t){let n=new Set;for(let r of Object.keys(e))e[r]!==t[r]&&n.add(r);for(let r of Object.keys(t))r in e||n.add(r);return n}function d8(){d5(null)}function fe(e,t){return{moduleName:t,name:e,attachedIds:[]}}function ft(e){let[t]=e.split("#");return t}function fn(e,t){let n=ft(t);return e.extensions[n]}function fr(e){return fn(d0.getState(),e)}d0.subscribe((e,t)=>{d5(e.extensions!==t.extensions?null:d9(e.slots,t.slots))}),d2.subscribe((e,t)=>{d5(d9(e.slots,t.slots))}),d4.subscribe((e,t)=>{d5(d9(e.configs,t.configs))}),d_.subscribe(()=>d5(null)),oU.subscribe(()=>d5(null)),d8(),b(d8);let fo=e=>dM(t=>({...t,extensions:{...t.extensions,[e.name]:{...e}}}));function fi(e,t){dM(n=>{let r=n.slots[e];return r?{...n,slots:{...n.slots,[e]:{...r,attachedIds:[...r.attachedIds,t]}}}:{...n,slots:{...n.slots,[e]:{...fe(e),attachedIds:[t]}}}})}function fa(e,t){dM(n=>{let r=n.slots[e];return r&&r.attachedIds.includes(t)?{...n,slots:{...n.slots,[e]:{...r,attachedIds:r.attachedIds.filter(e=>e!==t)}}}:n})}function fs(e){dM(t=>{let n=t.slots[e];return n?{...t,slots:{...t.slots,[e]:{...n,attachedIds:[]}}}:t})}function fl(e,t,n,r){let o=t.indexOf(e);if(-1!==o)return o;{if(void 0!==n)return 1e3+n;let t=r.indexOf(e);return -1!==t?2e3+t:3e3}}function fu(e,t){return function(e,t,n=null,r){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:n,...t}:{session:n});try{return!!dt(i,o)}catch(t){return console.error(`Error while evaluating expression '${i}' for ${e.id}`+(r?` in ${r}`:""),t),!1}})}(fc(e),t,oU.getState().session,e)}function fc(e){return d1.getState().slots[e]?.candidateExtensions??[]}let fd=(e,t)=>d0.setState(n=>{let r=n.slots[t]?.moduleName;if(r&&r!=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 ${r}.`),n;if(r&&r==e)return n;if(n.slots[t])return{...n,slots:{...n.slots,[t]:{...n.slots[t],moduleName:e}}};let o=fe(t,e);return{...n,slots:{...n.slots,[t]:{...o}}}}),ff=()=>{d3=null,dM(()=>({slots:{},extensions:{}})),dN().setState({renderings:new Map}),d1.setState({slots:{}})},fp=Z("left-nav",{slotName:null,basePath:window.spaBase,mode:"normal"});function fh({name:e,basePath:t,mode:n,componentContext:r,state:o}){fp.setState({slotName:e,basePath:t,mode:n??"normal",componentContext:r,state:o})}function fm(e){fp.getState().slotName===e&&fp.setState(fp.getInitialState(),!0)}let fy=Z("modalRegistry",{modals:{}});function fg(e){fy.setState(t=>(t.modals[e.name]=e,t))}function fb(e){let t=fy.getState().modals[e];if(!t){let n=fr(e);n&&(t={name:e,load:n.load,moduleName:n.moduleName},console.warn(`Modal ${e} was registered as an extension. This is deprecated and will be removed in the future. Please register it in the "modals" section of routes.json instead of the "extensions" section.`),fg(t))}return t}let fv=Z("workspaceRegistrations",{workspaces:{}}),fw=Z("workspaceGroups",{workspaceGroups:{}});function f_(e){fv.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 fx(e){fw.setState(t=>{let n=t.workspaceGroups[e.name];return n?{workspaceGroups:{...t.workspaceGroups,[e.name]:{...n,members:Array.from(new Set([...n.members,...e.members]))}}}:{workspaceGroups:{...t.workspaceGroups,[e.name]:{name:e.name,members:e.members}}}})}let fS=new Set;function fE(e){let t=fv.getState().workspaces;if(t[e])return t[e];{let t=fr(e);if(t){var n;let r;return fS.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.`),fS.add(e)),{name:t.name,title:(n=t,"string"==typeof(r=n?.meta?.title)?r:r&&"object"==typeof r?iB(n.moduleName,r.key,r.default):n.name),moduleName:t.moduleName,preferredWindowSize:t.meta?.screenSize??"normal",load:t.load,type:t.meta?.type??"form",canHide:t.meta?.canHide??!1,canMaximize:t.meta?.canMaximize??!1,width:t.meta?.width??"narrow",groups:t.meta?.groups??[]}}throw Error(`No workspace named '${e}' has been registered.`)}}function fD(e){let t=fw.getState().workspaceGroups;if(t[e])return t[e];throw Error(`No workspace group named '${e}' has been registered.`)}let fO=Z("workspace2",{registeredGroupsByName:{},registeredWindowsByName:{},registeredWorkspacesByName:{},openedGroup:null,openedWindows:[],workspaceTitleByWorkspaceName:{},isMostRecentlyOpenedWindowHidden:!1});function fk(e){let{registeredWorkspacesByName:t,registeredWindowsByName:n}=fO.getState(),r=t[e];if(r){let t=n[r.window];if(t)return t;throw Error(`No workspace window found with name: ${r.window} for workspace: ${e}`)}throw Error(`No workspace found with name: ${e}`)}function fP(e){let{registeredGroupsByName:t,registeredWindowsByName:n}=fO.getState(),r=n[e];if(r){let n=t[r.group];if(n)return n;throw Error(`No workspace group found with name: ${r.group} for window: ${e}`)}throw Error(`No workspace window found with name: ${e}`)}function fC(e){let{openedWindows:t}=fO.getState();return t.findIndex(t=>t.openedWorkspaces.find(t=>t.workspaceName===e))}function fj(e,t){if(0==t.length)return;let{registeredGroupsByName:n}=fO.getState(),r={...n};for(let n of t){if(r[n.name])throw Error(`Cannot register workspace group ${n.name} more than once`);r[n.name]={...n,moduleName:e}}fO.setState({registeredGroupsByName:r})}function fT(e,t){if(0==t.length)return;let{registeredWindowsByName:n}=fO.getState(),r={...n};for(let n of t){if(r[n.name])throw Error(`Cannot register workspace window ${n.name} more than once`);let t={...n,moduleName:e};r[n.name]=t}fO.setState({registeredWindowsByName:r})}function fR(e,t){if(0==t.length)return;let{registeredWorkspacesByName:n}=fO.getState(),r={...n};for(let n of t){if(r[n.name])throw Error(`Cannot register workspace ${n.name} more than once`);let t={...n,moduleName:e};r[n.name]=t}fO.setState({registeredWorkspacesByName:r})}let fA=0,fN=null,fM={bootstrap:15e3,mount:15e3,unmount:15e3};function fI(e){if(e.timeouts)return e;let t=e.name??"parcel",n=Object.fromEntries(Object.keys(fM).filter(t=>e[t]).map(n=>{var r,o;let i,a;return[n,(r=e[n],o=fM[n],i=Array.isArray(r)?r:[r],a=e=>i.reduce((r,o,i)=>r.then(()=>{let r=o(e);return"function"==typeof r?.then&&"function"==typeof r?.catch?r:Promise.reject(Error(`Lifecycle function ${n} at array index ${i} for parcel ${t} did not return a promise`))}),Promise.resolve(void 0)),e=>{let r,i=new Promise((e,i)=>{r=setTimeout(()=>i(Error(`Lifecycle function ${n} for parcel ${t} did not settle within ${o}ms`)),o)});return Promise.race([a(e),i]).finally(()=>clearTimeout(r))})]}));return{...e,...n}}async function f$(e,t){return(await (fN??(fN=new Promise((e,t)=>{r$({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),r$))),fN))("function"==typeof e?()=>e().then(fI):fI(e),t)}function fL(){return fF}function fF(e,t){let n,r=f$(e,t).then(e=>n=e);return{mount:()=>r.then(e=>e.mount()),unmount:()=>r.then(e=>e.unmount()),update:e=>r.then(t=>t.update?.(e)),getStatus:()=>n?.getStatus()??"LOADING_SOURCE_CODE",get loadPromise(){return r.then(e=>e.loadPromise)},get bootstrapPromise(){return r.then(e=>e.bootstrapPromise)},get mountPromise(){return r.then(e=>e.mountPromise)},get unmountPromise(){return r.then(e=>e.unmountPromise)}}}async function fB(e,t,n,r,o=e=>e,i={}){let a=ft(r),s=fr(r),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:f,load:p}=s;if(dC(d,f)){let s,d=fA++,f=`${t}/${r}-${d}`;e.dataset.extensionRenderingId=f;let h=e=>{try{dV(f)}catch(t){console.error(e,t)}};try{dB({renderingId:f,extensionName:a,extensionModuleName:c,extensionId:r,slotName:t,slotModuleName:n})}catch(e){throw h(`Recomputing configuration after registering '${r}' failed also failed`),e}try{s=await p()}catch(e){throw h(`Recomputing configuration after '${r}' failed to load also failed`),e}try{l=await f$(o({...s,name:`${t}/${a}-${d}`}),{...i,_meta:u,_extensionContext:{extensionId:r,extensionSlotName:t,extensionSlotModuleName:n,extensionModuleName:c},domElement:e})}catch(e){throw h(`Recomputing configuration after '${r}' failed to mount also failed`),e}l.mountPromise.then(void 0,e=>{console.error(`Extension '${r}' in slot '${t}' failed to mount`,e),h(`Recomputing configuration after '${r}' failed to mount also failed`)}),l.unmountPromise.then(()=>h(`Recomputing configuration after unmounting '${r}' failed`),e=>{console.error(`Extension '${r}' in slot '${t}' failed to unmount`,e),h(`Recomputing configuration after '${r}' failed to unmount also failed`)})}}else console.warn(`Tried to render ${r} into ${t} but no DOM element was available.`);return l}var fV=n(35399),fU=n.n(fV);let fW=(0,fV.createContext)({moduleName:"",featureName:""});function fK({to:e,templateParams:t,onBeforeNavigate:n,children:r,...o}){return(0,fV.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}`)},[]),fU().createElement("a",{onClick:r=>{0===r.button&&!r.ctrlKey&&!r.shiftKey&&!r.altKey&&!r.metaKey&&(r.preventDefault(),n?.(r),oD({to:e,templateParams:t})),0===r.button&&(r.ctrlKey||r.metaKey)&&n?.(r),0===r.button&&r.shiftKey&&n?.(r),1===r.button&&n?.(r)},href:oS(e,t),...o},r)}let fz=({state:e,children:t,...n})=>{let{extension:r}=(0,fV.useContext)(fW),o=(0,fV.useRef)(null),i=(0,fV.useRef)(Promise.resolve()),a=(0,fV.useRef)(!1),s=(0,fV.useRef)(!1),l=(0,fV.useRef)(e),u=(0,fV.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,fV.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 '${r?.extensionId}' failed to update`,e)}))},[]),d=(0,fV.useCallback)(t=>{t&&!o.current&&!s.current&&r?.extensionSlotName&&r.extensionSlotModuleName&&(s.current=!0,fB(t,r.extensionSlotName,r.extensionSlotModuleName,r.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,fV.useEffect)(()=>(a.current=!1,()=>{a.current=!0,u(o.current)}),[]),(0,fV.useEffect)(()=>{l.current=e,o.current&&c(o.current,e)},[e]),r?fU().createElement("div",{ref:d,"data-extension-id":r?.extensionId,style:{position:"relative"},...n}):null};function fH(e){let t=(0,fV.useRef)(e);return F(t.current,e)||(t.current=e),t.current}function fG(e,t){"function"==typeof t&&(t=t(e));let n={};for(let[r,o]of Object.entries(t)){let t=function(...t){e.setState(e=>o(e,...t))};n[r]=t}return n}let fq=e=>e;function fZ(e,t=fq,n){let r=(0,fV.useCallback)(t=>e.subscribe(t),[e]),o=(0,fV.useCallback)(()=>t(e.getState()),[e,t]),i=(0,fV.useSyncExternalStore)(r,o,o),a=(0,fV.useMemo)(()=>n?fG(e,n):null,[e,n]);return(0,fV.useMemo)(()=>a?{...i,...a}:i,[i,a])}function fY(e,t){return fZ(e,fq,t)}function fJ(e){return function(t){let n=(0,fV.useCallback)(t=>e.subscribe(t),[]),r=(0,fV.useCallback)(()=>e.getState(),[]),o=(0,fV.useSyncExternalStore)(n,r,r),i=(0,fV.useMemo)(()=>t?fG(e,t):null,[t]);return(0,fV.useMemo)(()=>i?{...o,...i}:o,[o,i])}}let fQ=[];Object.freeze(fQ);let fX={candidateExtensions:fQ};Object.freeze(fX);let f0=e=>{let t=(0,fV.useCallback)(t=>t.slots?.[e]??fX,[e]);return fZ(dU(),t)},f1=e=>e.session;function f2(e,t){let{candidateExtensions:n}=f0(e),r=fZ(oU,f1),o=fH(t);return(0,fV.useMemo)(()=>fu(e,o),[e,o,r,n])}function f4(e,t){let{moduleName:n}=(0,fV.useContext)(fW);if(!n)throw Error("ComponentContext has not been provided. This should come from @openmrs/esm-react-utils.");return(0,fV.useEffect)(()=>{fd(n,e)},[n,e]),{extensions:f2(e,t),extensionSlotName:e,extensionSlotModuleName:n}}function f3(e){return e}function f6({name:e,extensionSlotName:t,select:n=f3,children:r,state:o,style:i,...a}){if(r&&o)throw Error("Both children and state have been provided. If children are provided, the state must be passed as a prop to the `Extension` component.");let s=e??t,l=(0,fV.useRef)(null),{extensions:u,extensionSlotModuleName:c}=f4(s,o),d=(0,fV.useMemo)(()=>n(u),[n,u]),f=(0,fV.useMemo)(()=>{if("function"==typeof r&&!fU().isValidElement(r))return d.map(e=>r(e,o))},[r,d]);return fU().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)=>fU().createElement(fW.Provider,{key:e.id,value:{moduleName:c,featureName:"",extension:{extensionId:e.id,extensionSlotName:s,extensionSlotModuleName:c}}},f?.[t]??("function"!=typeof r?r:null)??fU().createElement(fz,{state:o}))))}var f5=n(25873);function f7(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function f9(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?f7(Object(n),!0).forEach(function(t){var r,o,i;r=e,o=t,i=n[t],o in r?Object.defineProperty(r,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[o]=i}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):f7(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function f8(e){return(f8="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 pe(e){return(pe="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 pt(e,t){var n;if("function"!=typeof(n=t.domElement?function(){return t.domElement}:t.domElementGetter?t.domElementGetter:e.domElementGetter?e.domElementGetter:function(e){var t=e.appName||e.name;if(!t)throw Error("single-spa's dom-element-getter-helpers was not given an application name as a prop, so it can't make a unique dom element container for the react application");var n="single-spa-application:".concat(t);return function(){var e=document.getElementById(n);return e||((e=document.createElement("div")).id=n,document.body.appendChild(e)),e}}(t)))throw Error("single-spa's dom-element-getter-helpers was given an invalid domElementGetter for application or parcel '".concat(t.name,"'. Expected a function, received ").concat(pe(n)));return function(){var e=n(t);if(!(e instanceof HTMLElement))throw Error("single-spa's dom-element-getter-helpers: domElementGetter returned an invalid dom element for application or parcel '".concat(t.name,"'. Expected HTMLElement, received ").concat(pe(e)));return e}}var pn=null;try{pn=require("react").createContext()}catch(e){}var pr={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 po(e,t){return e.rootComponent?Promise.resolve():e.loadRootComponent(t).then(function(t){e.rootComponent=t})}function pi(e,t){return new Promise(function(n,r){e.suppressComponentDidCatchWarning||!function(e){if(!(e&&"string"==typeof e.version&&e.version.indexOf(".")>=0))return!1;var t=e.version.slice(0,e.version.indexOf("."));try{return Number(t)>=16}catch(e){return!1}}(e.React)||e.errorBoundary||e.errorBoundaryClass||(e.rootComponent.prototype?e.rootComponent.prototype.componentDidCatch||console.warn("single-spa-react: ".concat(t.name||t.appName||t.childAppName,"'s rootComponent should implement componentDidCatch to avoid accidentally unmounting the entire single-spa application.")):console.warn("single-spa-react: ".concat(t.name||t.appName||t.childAppName,"'s rootComponent does not implement an error boundary. If using a functional component, consider providing an opts.errorBoundary to singleSpaReact(opts).")));var o,i=pu(e,t,function(){n(this)}),a=pt(e,t)(),s=function(e){var t=e.reactDom,n=e.renderType,r=e.elementToRender,o=e.domElement,i=t[n];if("function"!=typeof i)throw Error('renderType "'.concat(n,'" did not return a function.'));switch(n){case"createRoot":case"unstable_createRoot":case"createBlockingRoot":case"unstable_createBlockingRoot":var a=i(o);return a.render(r),a;case"hydrateRoot":return i(o,r);default:return i(r,o),null}}({elementToRender:i,domElement:a,reactDom:pl(e),renderType:"function"==typeof(o=e).renderType?o.renderType():o.renderType});e.domElements[t.name]=a,e.renderResults[t.name]=s})}function pa(e,t){return new Promise(function(n){e.unmountResolves[t.name]=n;var r=e.renderResults[t.name];r&&r.unmount?r.unmount():pl(e).unmountComponentAtNode(e.domElements[t.name]),delete e.domElements[t.name],delete e.renderResults[t.name]})}function ps(e,t){return new Promise(function(n){e.updateResolves[t.name]||(e.updateResolves[t.name]=[]),e.updateResolves[t.name].push(n);var r=pu(e,t,null),o=e.renderResults[t.name];if(o&&o.render)o.render(r);else{var i=pt(e,t)();pl(e).render(r,i)}})}function pl(e){return e.ReactDOMClient||e.ReactDOM}function pu(e,t,n){var r=e.React.createElement(e.rootComponent,t),o=pn?e.React.createElement(pn.Provider,{value:t},r):r;return(e.errorBoundary||t.errorBoundary||e.errorBoundaryClass||t.errorBoundaryClass)&&(e.errorBoundaryClass=e.errorBoundaryClass||t.errorBoundaryClass||function(e,t){function n(t){e.React.Component.apply(this,arguments),this.state={caughtError:null,caughtErrorInfo:null},n.displayName="SingleSpaReactErrorBoundary(".concat(t.name,")")}return n.prototype=Object.create(e.React.Component.prototype),n.prototype.render=function(){return this.state.caughtError?(e.errorBoundary||t.errorBoundary)(this.state.caughtError,this.state.caughtErrorInfo,this.props):this.props.children},n.prototype.componentDidCatch=function(e,t){this.setState({caughtError:e,caughtErrorInfo:t})},n}(e,t),o=e.React.createElement(e.errorBoundaryClass,t,o)),o=e.React.createElement(e.SingleSpaRoot,f9(f9({},t),{},{mountFinished:n,updateFinished:function(){e.updateResolves[t.name]&&(e.updateResolves[t.name].forEach(function(e){return e()}),delete e.updateResolves[t.name])},unmountFinished:function(){e.unmountResolves[t.name]&&(e.unmountResolves[t.name](),delete e.unmountResolves[t.name])}}),o)}var pc=n(27807),pd=n(71123),pf=n(43432);let pp={strictMode:!0,throwErrorsToConsole:!0,disableTranslations:!1},ph=new Map;(0,pf.initCache)(ph);let pm={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:()=>ph};function py(e){if("object"!=typeof e||"string"!=typeof e.featureName||"string"!=typeof e.moduleName)throw Error("Invalid options");let t=Object.assign({},pp,e),n={...pm,...t.swrConfig};return function(e){var r,o,i,a,s;return i=o=class extends(r=fU().Component){componentDidCatch(e,n){n&&n.componentStack&&(e.extra=Object.assign(e.extra||{},{componentStack:n.componentStack})),t.throwErrorsToConsole&&setTimeout(()=>{throw e}),this.setState({caughtError:e,caughtErrorInfo:n})}render(){if(this.state.caughtError)return fU().createElement("div",null,"An error has occurred. Please try reloading the page.");{let r=fU().createElement(fV.Suspense,{fallback:null},fU().createElement(pd.BE,{value:n},fU().createElement(fW.Provider,{value:this.state.config},t.disableTranslations?fU().createElement(e,this.props):fU().createElement(pc.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},fU().createElement(e,this.props)))));return t.strictMode&&fU().StrictMode?fU().createElement(fU().StrictMode,null,r):r}}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 pg(e,t){return function(e){if("object"!==f8(e))throw Error("single-spa-react requires a configuration object");var t,n=f9(f9({},pr),e);if(!n.React)throw Error("single-spa-react must be passed opts.React");if(!n.ReactDOM&&!n.ReactDOMClient)throw Error("single-spa-react must be passed opts.ReactDOM or opts.ReactDOMClient");if(n.renderType||(null!=(t=n.ReactDOMClient)&&t.createRoot?n.renderType="createRoot":n.renderType="render"),!n.rootComponent&&!n.loadRootComponent)throw Error("single-spa-react must be passed opts.rootComponent or opts.loadRootComponent");if(n.errorBoundary&&"function"!=typeof n.errorBoundary)throw Error("The errorBoundary opt for single-spa-react must either be omitted or be a function that returns React elements");!pn&&n.React.createContext&&(pn=n.React.createContext()),n.SingleSpaRoot=function(e){function t(e){t.displayName="SingleSpaRoot(".concat(e.name,")")}return t.prototype=Object.create(e.React.Component.prototype),t.prototype.componentDidMount=function(){setTimeout(this.props.mountFinished)},t.prototype.componentWillUnmount=function(){setTimeout(this.props.unmountFinished)},t.prototype.render=function(){return setTimeout(this.props.updateFinished),this.props.children},t}(n);var r={bootstrap:po.bind(null,n),mount:pi.bind(null,n),unmount:pa.bind(null,n)};return n.parcelCanUpdate&&(r.update=ps.bind(null,n)),r}({React:fU(),ReactDOMClient:f5,rootComponent:py(t)(e)})}function pb(e,t){return()=>e().then(({default:e})=>pg(e,t))}function pv(e,t){return()=>Promise.resolve(pg(e,t))}let pw=pb,p_=W()(()=>({}));Y("openmrs-app-context",p_);let px={};function pS(e,t=e=>e){let n=p_.getState();return e in n?Object.freeze(Object.assign({},t?t(n[e]):n[e])):null}function pE(e,t){p_.setState(n=>(e in n||(n[e]={}),n[e]=t(n[e]),Object.assign({},n)))}function pD(e){return null===e?null:Object.freeze(Object.assign({},e))}let pO=new Map;function pk(e,t){let n=(0,fV.useRef)(t??{}),r=(0,fV.useRef)(t=>pE(e,t)),o=(0,fV.useRef)(Symbol());return(0,fV.useEffect)(()=>{let n=t??{},r=o.current;return null===pS(e)?!function(e,t=px){p_.setState(n=>{if(e in n)throw Error(`Attempted to re-register namespace ${e} in the app context. Each namespace must be unregistered before the name can be registered again.`);return Object.assign({},n,{[e]:t===px?{}:t})})}(e,n):(console.warn(`Namespace ${e} is already registered in the app context. This is likely a race condition during navigation, but may indicate two components are trying to own the same namespace. Updating the existing context.`),pE(e,()=>n)),pO.set(e,r),()=>{pO.get(e)===r&&(p_.setState(t=>(e in t&&delete t[e],t)),pO.delete(e))}},[e]),(0,fV.useEffect)(()=>{let r=t??{};F(n.current,r)||(pE(e,()=>r),n.current=r)},[t]),r.current}function pP({namespace:e,value:t}){return pk(e,t),null}let pC=({children:e,value:t,fallback:n})=>t?fU().createElement(fU().Fragment,null,e):n?fU().createElement(fU().Fragment,null,n):null;function pj(){let e=(0,fV.useRef)();return(!e.current||e.current.signal.aborted)&&(e.current=new AbortController),(0,fV.useEffect)(()=>{let t=e.current;return()=>t?.abort()},[]),e.current}function pT(e,t=e=>e??{}){let[n,r]=(0,fV.useState)(()=>{if(pR(e))return;let n=pS(e);if(null!==n)return t?t(n):n});return(0,fV.useEffect)(()=>{if(pR(e))throw Error(`The namespace supplied to useAppContext must be a non-empty string, but was "${e}".`)},[e]),(0,fV.useEffect)(()=>{var n;let o;return(n=e=>{if(null==e)return void r(void 0);let n=t?t(e):e;r(e=>F(e,n)?e:n)})(pD(o=pS(e))),p_.subscribe(t=>{let r=e in t?t[e]:null;r!==o&&(o=r,n(pD(r)))})},[e,t]),n}function pR(e){return"string"!=typeof e||0===e.trim().length}function pA(e){let t=f2(e);return(0,fV.useMemo)(()=>t.map(e=>e.id),[t])}function pN(e){return f0(e).candidateExtensions}function pM(e,t){let{data:n,error:r,mutate:o,isLoading:i,isValidating:a}=(0,pd.Ay)(`${aD}?patient=${e}&includeEncounterless=${t}`,oF);return(0,fV.useMemo)(()=>({isLoading:i,data:n?.data.results??[],error:r,mutate:o,isValidating:a}),[n,r,i,a,o])}function pI(e){(0,fV.useEffect)(()=>{if(e){let e=window.getComputedStyle(document.body).overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=e}}},[e])}let p$={},pL=`No ComponentContext has been provided. This should come from "openmrsComponentDecorator".
15
+ ${this.stack}`}}let oU=Z("session",{loaded:!1,session:null}),oW=0;function oK(e={includeAuthStatus:!0}){return(oW<Date.now()-6e4||!oU.getState().loaded)&&oG(),new eg.c(t=>{let n=n=>{n.loaded&&(e.includeAuthStatus?t.next(n.session):t.next(n.session?.user))};return n(oU.getState()),oU.subscribe(n)})}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 n={};return e&&t&&(n.Authorization=`Basic ${window.btoa(`${e}:${t}`)}`),o0(oF(o$,{headers:n}))}function oq(){oU.setState({loaded:!0,session:{authenticated:!1,sessionId:""}})}function oZ(e,t){var n,r;if(void 0===t)return!e;if(!e)return!0;return n=e,r=t,("string"==typeof n?!ee(r.privileges.find(e=>n===e.display)):Array.isArray(n)?n.every(e=>!ee(r.privileges.find(t=>e===t.display))):(ee(n)||console.error(`Could not understand privileges "${n}"`),!0))||!ee(t.roles.find(e=>"System Developer"===e.display))}function oY(){let e,t;return new Promise(n=>{let r=r=>{r.loaded&&r.session.user&&(e=r.session.user,n(r.session.user),t&&t())};r(oU.getState()),e||(t=oU.subscribe(r))})}function oJ(){return new Promise((e,t)=>{oK().subscribe(t=>{e(t.sessionLocation)},t).unsubscribe()})}async function oQ(e,t){return o0(oF(o$,{method:"POST",body:{sessionLocation:e},headers:{"Content-Type":"application/json"},signal:t.signal}))}async function oX(e,t,n){return n||(n=new AbortController),await oF(`${oM}/user/${e}`,{method:"POST",body:{userProperties:t},headers:{"Content-Type":"application/json"},signal:n.signal}),oG()}function o0(e){return new Promise((t,n)=>{e.then(e=>{let r;"object"==typeof e?.data?(r={loaded:!0,session:e.data},oU.setState(r),t(r)):(r={loaded:!1,session:null},oU.setState(r),n(r))}).catch(e=>{I(`Failed to fetch new session information: ${e}`);let t={loaded:!1,session:null};oU.setState(t),n(t)})})}function o1(){return"development"===window.spaEnv||"true"===localStorage.getItem("openmrs:devtools")}oU.subscribe(e=>{e.loaded&&e.session&&oH(e.session)});let o2={"webservices.rest":"2.24.0",fhir2:"1.0.0-SNAPSHOT"};function o4(){nv("@openmrs/esm-api",oA),oG()}let o3={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,n=new Promise((n,r)=>{e=n,t=r});return n.resolve=e,n.reject=t,n},o7=e=>null==e?"":""+e,o9=/###/g,o8=e=>e&&e.indexOf("###")>-1?e.replace(o9,"."):e,ie=e=>!e||o6(e),it=(e,t,n)=>{let r=o6(t)?t.split("."):t,o=0;for(;o<r.length-1;){if(ie(e))return{};let t=o8(r[o]);!e[t]&&n&&(e[t]=new n),e=Object.prototype.hasOwnProperty.call(e,t)?e[t]:{},++o}return ie(e)?{}:{obj:e,k:o8(r[o])}},ir=(e,t,n)=>{let{obj:r,k:o}=it(e,t,Object);if(void 0!==r||1===t.length){r[o]=n;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}`]=n},io=(e,t)=>{let{obj:n,k:r}=it(e,t);if(n&&Object.prototype.hasOwnProperty.call(n,r))return n[r]},ii=(e,t,n)=>{for(let r in t)"__proto__"!==r&&"constructor"!==r&&(r in e?o6(e[r])||e[r]instanceof String||o6(t[r])||t[r]instanceof String?n&&(e[r]=t[r]):ii(e[r],t[r],n):e[r]=t[r]);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 n=new RegExp(e);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(e,n),this.regExpQueue.push(e),n}}(20),ic=(e,t,n=".")=>{if(!e)return;if(e[t]){if(!Object.prototype.hasOwnProperty.call(e,t))return;return e[t]}let r=t.split(n),o=e;for(let e=0;e<r.length;){let t;if(!o||"object"!=typeof o)return;let i="";for(let a=e;a<r.length;++a)if(a!==e&&(i+=n),i+=r[a],void 0!==(t=o[i])){if(["string","number","boolean"].indexOf(typeof t)>-1&&a<r.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,n,r){return r&&!this.debug?null:(o6(e[0])&&(e[0]=`${n}${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 iy{constructor(){this.observers={}}on(e,t){return e.split(" ").forEach(e=>{this.observers[e]||(this.observers[e]=new Map);let n=this.observers[e].get(t)||0;this.observers[e].set(t,n+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,n])=>{for(let r=0;r<n;r++)e(...t)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(([n,r])=>{for(let o=0;o<r;o++)n.apply(n,[e,...t])})}}class ig extends iy{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,n,r={}){let o,i=void 0!==r.keySeparator?r.keySeparator:this.options.keySeparator,a=void 0!==r.ignoreJSONStructure?r.ignoreJSONStructure:this.options.ignoreJSONStructure;e.indexOf(".")>-1?o=e.split("."):(o=[e,t],n&&(Array.isArray(n)?o.push(...n):o6(n)&&i?o.push(...n.split(i)):o.push(n)));let s=io(this.data,o);return(!s&&!t&&!n&&e.indexOf(".")>-1&&(e=o[0],t=o[1],n=o.slice(2).join(".")),!s&&a&&o6(n))?ic(this.data?.[e]?.[t],n,i):s}addResource(e,t,n,r,o={silent:!1}){let i=void 0!==o.keySeparator?o.keySeparator:this.options.keySeparator,a=[e,t];n&&(a=a.concat(i?n.split(i):n)),e.indexOf(".")>-1&&(a=e.split("."),r=t,t=a[1]),this.addNamespaces(t),ir(this.data,a,r),o.silent||this.emit("added",e,t,n,r)}addResources(e,t,n,r={silent:!1}){for(let r in n)(o6(n[r])||Array.isArray(n[r]))&&this.addResource(e,t,r,n[r],{silent:!0});r.silent||this.emit("added",e,t,n)}addResourceBundle(e,t,n,r,o,i={silent:!1,skipCopy:!1}){let a=[e,t];e.indexOf(".")>-1&&(a=e.split("."),r=n,n=t,t=a[1]),this.addNamespaces(t);let s=io(this.data,a)||{};i.skipCopy||(n=JSON.parse(JSON.stringify(n))),r?ii(s,n,o):s={...s,...n},ir(this.data,a,s),i.silent||this.emit("added",e,t,n)}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 ib={processors:{},addPostProcessor(e){this.processors[e.name]=e},handle(e,t,n,r,o){return e.forEach(e=>{t=this.processors[e]?.process(t,n,r,o)??t}),t}};let iv=Symbol("i18next/PATH_KEY");function iw(e,t){let n,r,o,{[iv]:i}=e((r=[],(o=Object.create(null)).get=(e,t)=>(n?.revoke?.(),t===iv)?r:(r.push(t),(n=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 iS extends iy{constructor(e,t={}){super(),((e,t,n)=>{e.forEach(e=>{t[e]&&(n[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 n={...t};if(null==e)return!1;let r=this.resolve(e,n);if(r?.res===void 0)return!1;let o=ix(r.res);return!1!==n.returnObjects||!o}extractFromKey(e,t){let n=void 0!==t.nsSeparator?t.nsSeparator:this.options.nsSeparator;void 0===n&&(n=":");let r=void 0!==t.keySeparator?t.keySeparator:this.options.keySeparator,o=t.ns||this.options.defaultNS||[],i=n&&e.indexOf(n)>-1,a=!this.options.userDefinedKeySeparator&&!t.keySeparator&&!this.options.userDefinedNsSeparator&&!t.nsSeparator&&!((e,t,n)=>{t=t||"",n=n||"";let r=il.filter(e=>0>t.indexOf(e)&&0>n.indexOf(e));if(0===r.length)return!0;let o=iu.getRegExp(`(${r.map(e=>"?"===e?"\\?":e).join("|")})`),i=!o.test(e);if(!i){let t=e.indexOf(n);t>0&&!o.test(e.substring(0,t))&&(i=!0)}return i})(e,n,r);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(n);(n!==r||n===r&&this.options.ns.indexOf(i[0])>-1)&&(o=i.shift()),e=i.join(r)}return{key:e,namespaces:o6(o)?[o]:o}}translate(e,t,n){let r="object"==typeof t?{...t}:t;if("object"!=typeof r&&this.options.overloadTranslationOptionHandler&&(r=this.options.overloadTranslationOptionHandler(arguments)),"object"==typeof r&&(r={...r}),r||(r={}),null==e)return"";"function"==typeof e&&(e=iw(e,{...this.options,...r})),Array.isArray(e)||(e=[String(e)]);let o=void 0!==r.returnDetails?r.returnDetails:this.options.returnDetails,i=void 0!==r.keySeparator?r.keySeparator:this.options.keySeparator,{key:a,namespaces:s}=this.extractFromKey(e[e.length-1],r),l=s[s.length-1],u=void 0!==r.nsSeparator?r.nsSeparator:this.options.nsSeparator;void 0===u&&(u=":");let c=r.lng||this.language,d=r.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(r)}:`${l}${u}${a}`:o?{res:a,usedKey:a,exactUsedKey:a,usedLng:c,usedNS:l,usedParams:this.getUsedParamsDetails(r)}:a;let f=this.resolve(e,r),p=f?.res,h=f?.usedKey||a,m=f?.exactUsedKey||a,y=void 0!==r.joinArrays?r.joinArrays:this.options.joinArrays,g=!this.i18nFormat||this.i18nFormat.handleAsObject,b=void 0!==r.count&&!o6(r.count),v=iS.hasDefaultValue(r),w=b?this.pluralResolver.getSuffix(c,r.count,r):"",x=r.ordinal&&b?this.pluralResolver.getSuffix(c,r.count,{ordinal:!1}):"",S=b&&!r.ordinal&&0===r.count,E=S&&r[`defaultValue${this.options.pluralSeparator}zero`]||r[`defaultValue${w}`]||r[`defaultValue${x}`]||r.defaultValue,D=p;g&&!p&&v&&(D=E);let O=ix(D),k=Object.prototype.toString.apply(D);if(g&&D&&O&&0>["[object Number]","[object Function]","[object RegExp]"].indexOf(k)&&!(o6(y)&&Array.isArray(D))){if(!r.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,{...r,ns:s}):`key '${a} (${this.language})' returned an object instead of string.`;return o?(f.res=e,f.usedParams=this.getUsedParamsDetails(r),f):e}if(i){let e=Array.isArray(D),t=e?[]:{},n=e?m:h;for(let e in D)if(Object.prototype.hasOwnProperty.call(D,e)){let o=`${n}${i}${e}`;v&&!p?t[e]=this.translate(o,{...r,defaultValue:ix(E)?E[e]:void 0,...{joinArrays:!1,ns:s}}):t[e]=this.translate(o,{...r,joinArrays:!1,ns:s}),t[e]===o&&(t[e]=D[e])}p=t}}else if(g&&o6(y)&&Array.isArray(p))(p=p.join(y))&&(p=this.extendTranslation(p,e,r,n));else{let t=!1,o=!1;!this.isValidLookup(p)&&v&&(t=!0,p=E),this.isValidLookup(p)||(o=!0,p=a);let s=(r.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&o?void 0:p,d=v&&E!==p&&this.options.updateMissing;if(o||t||d){if(this.logger.log(d?"updateKey":"missingKey",c,l,a,d?E:p),i){let e=this.resolve(a,{...r,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,r.lng||this.language);if("fallback"===this.options.saveMissingTo&&t&&t[0])for(let n=0;n<t.length;n++)e.push(t[n]);else"all"===this.options.saveMissingTo?e=this.languageUtils.toResolveHierarchy(r.lng||this.language):e.push(r.lng||this.language);let n=(e,t,n)=>{let o=v&&n!==p?n:s;this.options.missingKeyHandler?this.options.missingKeyHandler(e,l,t,o,d,r):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(e,l,t,o,d,r),this.emit("missingKey",e,l,t,p)};this.options.saveMissing&&(this.options.saveMissingPlurals&&b?e.forEach(e=>{let t=this.pluralResolver.getSuffixes(e,r);S&&r[`defaultValue${this.options.pluralSeparator}zero`]&&0>t.indexOf(`${this.options.pluralSeparator}zero`)&&t.push(`${this.options.pluralSeparator}zero`),t.forEach(t=>{n([e],a+t,r[`defaultValue${t}`]||E)})}):n(e,a,E))}p=this.extendTranslation(p,e,r,f,n),o&&p===a&&this.options.appendNamespaceToMissingKey&&(p=`${l}${u}${a}`),(o||t)&&this.options.parseMissingKeyHandler&&(p=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${l}${u}${a}`:a,t?p:void 0,r))}return o?(f.res=p,f.usedParams=this.getUsedParamsDetails(r),f):p}extendTranslation(e,t,n,r,o){if(this.i18nFormat?.parse)e=this.i18nFormat.parse(e,{...this.options.interpolation.defaultVariables,...n},n.lng||this.language||r.usedLng,r.usedNS,r.usedKey,{resolved:r});else if(!n.skipInterpolation){let i;n.interpolation&&this.interpolator.init({...n,...{interpolation:{...this.options.interpolation,...n.interpolation}}});let a=o6(e)&&(n?.interpolation?.skipOnVariables!==void 0?n.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);if(a){let t=e.match(this.interpolator.nestingRegexp);i=t&&t.length}let s=n.replace&&!o6(n.replace)?n.replace:n;if(this.options.interpolation.defaultVariables&&(s={...this.options.interpolation.defaultVariables,...s}),e=this.interpolator.interpolate(e,s,n.lng||this.language||r.usedLng,n),a){let t=e.match(this.interpolator.nestingRegexp);i<(t&&t.length)&&(n.nest=!1)}!n.lng&&r&&r.res&&(n.lng=this.language||r.usedLng),!1!==n.nest&&(e=this.interpolator.nest(e,(...e)=>o?.[0]!==e[0]||n.context?this.translate(...e,t):(this.logger.warn(`It seems you are nesting recursively key: ${e[0]} in key: ${t[0]}`),null),n)),n.interpolation&&this.interpolator.reset()}let i=n.postProcess||this.options.postProcess,a=o6(i)?[i]:i;return null!=e&&a?.length&&!1!==n.applyPostProcessor&&(e=ib.handle(a,e,t,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...r,usedParams:this.getUsedParamsDetails(n)},...n}:n,this)),e}resolve(e,t={}){let n,r,o,i,a;return o6(e)&&(e=[e]),e.forEach(e=>{if(this.isValidLookup(n))return;let s=this.extractFromKey(e,t),l=s.key;r=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,f=void 0!==t.context&&(o6(t.context)||"number"==typeof t.context)&&""!==t.context,p=t.lngs?t.lngs:this.languageUtils.toResolveHierarchy(t.lng||this.language,t.fallbackLng);u.forEach(e=>{this.isValidLookup(n)||(a=e,!i_[`${p[0]}-${e}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(a)&&(i_[`${p[0]}-${e}`]=!0,this.logger.warn(`key "${r}" for languages "${p.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!!!")),p.forEach(r=>{let a;if(this.isValidLookup(n))return;i=r;let s=[l];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(s,l,r,e,t);else{let e;c&&(e=this.pluralResolver.getSuffix(r,t.count,t));let n=`${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+n)),f){let r=`${l}${this.options.contextSeparator||"_"}${t.context}`;s.push(r),c&&(t.ordinal&&0===e.indexOf(o)&&s.push(r+e.replace(o,this.options.pluralSeparator)),s.push(r+e),d&&s.push(r+n))}}for(;a=s.pop();)this.isValidLookup(n)||(o=a,n=this.getResource(r,e,a,t))}))})}),{res:n,usedKey:r,exactUsedKey:o,usedLng:i,usedNS:a}}isValidLookup(e){return void 0!==e&&!(!this.options.returnNull&&null===e)&&!(!this.options.returnEmptyString&&""===e)}getResource(e,t,n,r={}){return this.i18nFormat?.getResource?this.i18nFormat.getResource(e,t,n,r):this.resourceStore.getResource(e,t,n,r)}getUsedParamsDetails(e={}){let t=e.replace&&!o6(e.replace),n=t?e.replace:e;if(t&&void 0!==e.count&&(n.count=e.count),this.options.interpolation.defaultVariables&&(n={...this.options.interpolation.defaultVariables,...n}),!t)for(let e of(n={...n},["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"]))delete n[e];return n}static hasDefaultValue(e){let t="defaultValue";for(let n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t===n.substring(0,t.length)&&void 0!==e[n])return!0;return!1}}class iE{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 n=this.formatLanguageCode(e);(!this.options.supportedLngs||this.isSupportedCode(n))&&(t=n)}),!t&&this.options.supportedLngs&&e.forEach(e=>{if(t)return;let n=this.getScriptPartFromCode(e);if(this.isSupportedCode(n))return t=n;let r=this.getLanguagePartFromCode(e);if(this.isSupportedCode(r))return t=r;t=this.options.supportedLngs.find(e=>{if(e===r||!(0>e.indexOf("-")&&0>r.indexOf("-"))&&(e.indexOf("-")>0&&0>r.indexOf("-")&&e.substring(0,e.indexOf("-"))===r||0===e.indexOf(r)&&r.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 n=e[t];return n||(n=e[this.getScriptPartFromCode(t)]),n||(n=e[this.formatLanguageCode(t)]),n||(n=e[this.getLanguagePartFromCode(t)]),n||(n=e.default),n||[]}toResolveHierarchy(e,t){let n=this.getFallbackCodes((!1===t?[]:t)||this.options.fallbackLng||[],e),r=[],o=e=>{e&&(this.isSupportedCode(e)?r.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)),n.forEach(e=>{0>r.indexOf(e)&&o(this.formatLanguageCode(e))}),r}}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 n,r=id("dev"===e?"en":e),o=t.ordinal?"ordinal":"cardinal",i=JSON.stringify({cleanedCode:r,type:o});if(i in this.pluralRulesCache)return this.pluralRulesCache[i];try{n=new Intl.PluralRules(r,{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 r=this.languageUtils.getLanguagePartFromCode(e);n=this.getRule(r,t)}return this.pluralRulesCache[i]=n,n}needsPlural(e,t={}){let n=this.getRule(e,t);return n||(n=this.getRule("dev",t)),n?.resolvedOptions().pluralCategories.length>1}getPluralFormsOfKey(e,t,n={}){return this.getSuffixes(e,n).map(e=>`${t}${e}`)}getSuffixes(e,t={}){let n=this.getRule(e,t);return(n||(n=this.getRule("dev",t)),n)?n.resolvedOptions().pluralCategories.sort((e,t)=>iD[e]-iD[t]).map(e=>`${this.options.prepend}${t.ordinal?`ordinal${this.options.prepend}`:""}${e}`):[]}getSuffix(e,t,n={}){let r=this.getRule(e,n);return r?`${this.options.prepend}${n.ordinal?`ordinal${this.options.prepend}`:""}${r.select(t)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix("dev",t,n))}}let iP=(e,t,n,r=".",o=!0)=>{let i,a=void 0!==(i=io(e,n))?i:io(t,n);return!a&&o&&o6(n)&&void 0===(a=ic(e,n,r))&&(a=ic(t,n,r)),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:n,useRawValueToEscape:r,prefix:o,prefixEscaped:i,suffix:a,suffixEscaped:s,formatSeparator:l,unescapeSuffix:u,unescapePrefix:c,nestingPrefix:d,nestingPrefixEscaped:f,nestingSuffix:p,nestingSuffixEscaped:h,nestingOptionsSeparator:m,maxReplaces:y,alwaysFormat:g}=e.interpolation;this.escape=void 0!==t?t:is,this.escapeValue=void 0===n||n,this.useRawValueToEscape=void 0!==r&&r,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,"\\$&"):f||"$t(".replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),this.nestingSuffix=p?p.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"):h||")".replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),this.nestingOptionsSeparator=m||",",this.maxReplaces=y||1e3,this.alwaysFormat=void 0!==g&&g,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,n,r){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,n,{...r,...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,n,{...r,...t,interpolationkey:i})};this.resetRegExp();let u=r?.missingInterpolationHandler||this.options.missingInterpolationHandler,c=r?.interpolation?.skipOnVariables!==void 0?r.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 n=o[1].trim();if(void 0===(i=l(n)))if("function"==typeof u){let t=u(e,o,r);i=o6(t)?t:""}else if(r&&Object.prototype.hasOwnProperty.call(r,n))i="";else if(c){i=o[0];continue}else this.logger.warn(`missed to pass in variable ${n} for interpolating ${e}`),i="";else o6(i)||this.useRawValueToEscape||(i=o7(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,n={}){let r,o,i,a=(e,t)=>{let n=this.nestingOptionsSeparator;if(0>e.indexOf(n))return e;let r=e.split(RegExp(`${n}[ ]*{`)),o=`{${r[1]}`;e=r[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}${n}${o}`}return i.defaultValue&&i.defaultValue.indexOf(this.prefix)>-1&&delete i.defaultValue,e};for(;r=this.nestingRegexp.exec(e);){let s=[];(i=(i={...n}).replace&&!o6(i.replace)?i.replace:i).applyPostProcessor=!1,delete i.defaultValue;let l=/{.*}/.test(r[1])?r[1].lastIndexOf("}")+1:r[1].indexOf(this.formatSeparator);if(-1!==l&&(s=r[1].slice(l).split(this.formatSeparator).map(e=>e.trim()).filter(Boolean),r[1]=r[1].slice(0,l)),(o=t(a.call(this,r[1].trim(),i),i))&&r[0]===e&&!o6(o))return o;o6(o)||(o=o7(o)),o||(this.logger.warn(`missed to resolve ${r[1]} for nesting ${e}`),o=""),s.length&&(o=s.reduce((e,t)=>this.format(e,t,n.lng,{...n,interpolationkey:r[1].trim()}),o.trim())),e=e.replace(r[0],o),this.regexp.lastIndex=0}return e}}let ij=e=>{let t={};return(n,r,o)=>{let i=o;o&&o.interpolationkey&&o.formatParams&&o.formatParams[o.interpolationkey]&&o[o.interpolationkey]&&(i={...i,[o.interpolationkey]:void 0});let a=r+JSON.stringify(i),s=t[a];return s||(s=e(id(r),o),t[a]=s),s(n)}},iT=e=>(t,n,r)=>e(id(n),r)(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 n=t.cacheInBuiltFormats?ij:iT;this.formats={number:n((e,t)=>{let n=new Intl.NumberFormat(e,{...t});return e=>n.format(e)}),currency:n((e,t)=>{let n=new Intl.NumberFormat(e,{...t,style:"currency"});return e=>n.format(e)}),datetime:n((e,t)=>{let n=new Intl.DateTimeFormat(e,{...t});return e=>n.format(e)}),relativetime:n((e,t)=>{let n=new Intl.RelativeTimeFormat(e,{...t});return e=>n.format(e,t.range||"day")}),list:n((e,t)=>{let n=new Intl.ListFormat(e,{...t});return e=>n.format(e)})}}add(e,t){this.formats[e.toLowerCase().trim()]=t}addCached(e,t){this.formats[e.toLowerCase().trim()]=ij(t)}format(e,t,n,r={}){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(),n={};if(e.indexOf("(")>-1){let r=e.split("(");t=r[0].toLowerCase().trim();let o=r[1].substring(0,r[1].length-1);"currency"===t&&0>o.indexOf(":")?n.currency||(n.currency=o.trim()):"relativetime"===t&&0>o.indexOf(":")?n.range||(n.range=o.trim()):o.split(";").forEach(e=>{if(e){let[t,...r]=e.split(":"),o=r.join(":").trim().replace(/^'+|'+$/g,""),i=t.trim();n[i]||(n[i]=o),"false"===o&&(n[i]=!1),"true"===o&&(n[i]=!0),isNaN(o)||(n[i]=parseInt(o,10))}})}return{formatName:t,formatOptions:n}})(t);if(this.formats[o]){let t=e;try{let a=r?.formatParams?.[r.interpolationkey]||{},s=a.locale||a.lng||r.locale||r.lng||n;t=this.formats[o](e,s,{...i,...r,...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 iy{constructor(e,t,n,r={}){super(),this.backend=e,this.store=t,this.services=n,this.languageUtils=n.languageUtils,this.options=r,this.logger=im.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=r.maxParallelReads||10,this.readingCalls=0,this.maxRetries=r.maxRetries>=0?r.maxRetries:5,this.retryTimeout=r.retryTimeout>=1?r.retryTimeout:350,this.state={},this.queue=[],this.backend?.init?.(n,r.backend,r)}queueLoad(e,t,n,r){let o={},i={},a={},s={};return e.forEach(e=>{let r=!0;t.forEach(t=>{let a=`${e}|${t}`;!n.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,r=!1,void 0===i[a]&&(i[a]=!0),void 0===o[a]&&(o[a]=!0),void 0===s[t]&&(s[t]=!0)))}),r||(a[e]=!0)}),(Object.keys(o).length||Object.keys(i).length)&&this.queue.push({pending:i,pendingCount:Object.keys(i).length,loaded:{},errors:[],callback:r}),{toLoad:Object.keys(o),pending:Object.keys(i),toLoadLanguages:Object.keys(a),toLoadNamespaces:Object.keys(s)}}loaded(e,t,n){let r=e.split("|"),o=r[0],i=r[1];t&&this.emit("failedLoading",o,i,t),!t&&n&&this.store.addResourceBundle(o,i,n,void 0,void 0,{skipCopy:!0}),this.state[e]=t?-1:2,t&&n&&(this.state[e]=0);let a={};this.queue.forEach(n=>{((e,t,n,r)=>{let{obj:o,k:i}=it(e,t,Object);o[i]=o[i]||[],o[i].push(n)})(n.loaded,[o],i),void 0!==n.pending[e]&&(delete n.pending[e],n.pendingCount--),t&&n.errors.push(t),0!==n.pendingCount||n.done||(Object.keys(n.loaded).forEach(e=>{a[e]||(a[e]={});let t=n.loaded[e];t.length&&t.forEach(t=>{void 0===a[e][t]&&(a[e][t]=!0)})}),n.done=!0,n.errors.length?n.callback(n.errors):n.callback())}),this.emit("loaded",a),this.queue=this.queue.filter(e=>!e.done)}read(e,t,n,r=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:n,tried:r,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&&r<this.maxRetries?setTimeout(()=>{this.read.call(this,e,t,n,r+1,2*o,i)},o):i(a,s)},s=this.backend[n].bind(this.backend);if(2===s.length){try{let n=s(e,t);n&&"function"==typeof n.then?n.then(e=>a(null,e)).catch(a):a(null,n)}catch(e){a(e)}return}return s(e,t,a)}prepareLoading(e,t,n={},r){if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),r&&r();o6(e)&&(e=this.languageUtils.toResolveHierarchy(e)),o6(t)&&(t=[t]);let o=this.queueLoad(e,t,n,r);if(!o.toLoad.length)return o.pending.length||r(),null;o.toLoad.forEach(e=>{this.loadOne(e)})}load(e,t,n){this.prepareLoading(e,t,{},n)}reload(e,t,n){this.prepareLoading(e,t,{reload:!0},n)}loadOne(e,t=""){let n=e.split("|"),r=n[0],o=n[1];this.read(r,o,"read",void 0,void 0,(n,i)=>{n&&this.logger.warn(`${t}loading namespace ${o} for language ${r} failed`,n),!n&&i&&this.logger.log(`${t}loaded namespace ${o} for language ${r}`,i),this.loaded(e,n,i)})}saveMissing(e,t,n,r,o,i={},a=()=>{}){if(this.services?.utils?.hasLoadedNamespace&&!this.services?.utils?.hasLoadedNamespace(t))return void this.logger.warn(`did not save key "${n}" 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!=n&&""!==n){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,n,r,s):l(e,t,n,r))&&"function"==typeof o.then?o.then(e=>a(null,e)).catch(a):a(null,o)}catch(e){a(e)}else l(e,t,n,r,a,s)}e&&e[0]&&this.store.addResource(e[0],t,n,r)}}}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 n=e[3]||e[2];Object.keys(n).forEach(e=>{t[e]=n[e]})}return t},interpolation:{escapeValue:!0,format:e=>e,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0},cacheInBuiltFormats:!0}),iM=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 i$ extends iy{constructor(e={},t){if(super(),this.options=iM(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 n=iN();this.options={...n,...this.options,...iM(e)},this.options.interpolation={...n.interpolation,...this.options.interpolation},void 0!==e.keySeparator&&(this.options.userDefinedKeySeparator=e.keySeparator),void 0!==e.nsSeparator&&(this.options.userDefinedNsSeparator=e.nsSeparator);let r=e=>e?"function"==typeof e?new e:e:null;if(!this.options.isClone){let e;this.modules.logger?im.init(r(this.modules.logger),this.options):im.init(null,this.options),e=this.modules.formatter?this.modules.formatter:iR;let t=new iE(this.options);this.store=new ig(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!==n.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===n.interpolation.format)&&(o.formatter=r(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(r(this.modules.backend),o.resourceStore,o,this.options),o.backendConnector.on("*",(e,...t)=>{this.emit(e,...t)}),this.modules.languageDetector&&(o.languageDetector=r(this.modules.languageDetector),o.languageDetector.init&&o.languageDetector.init(o,this.options.detection,this.options)),this.modules.i18nFormat&&(o.i18nFormat=r(this.modules.i18nFormat),o.i18nFormat.init&&o.i18nFormat.init(this)),this.translator=new iS(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,n)=>{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(n),t(e,n)};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 n=t,r=o6(e)?e:this.language;if("function"==typeof e&&(n=e),!this.options.resources||this.options.partialBundledLanguages){if(r?.toLowerCase()==="cimode"&&(!this.options.preload||0===this.options.preload.length))return n();let e=[],t=t=>{t&&"cimode"!==t&&this.services.languageUtils.toResolveHierarchy(t).forEach(t=>{"cimode"!==t&&0>e.indexOf(t)&&e.push(t)})};r?t(r):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),n(e)})}else n(null)}reloadResources(e,t,n){let r=o5();return"function"==typeof e&&(n=e,e=void 0),"function"==typeof t&&(n=t,t=void 0),e||(e=this.languages),t||(t=this.options.ns),n||(n=iI),this.services.backendConnector.reload(e,t,e=>{r.resolve(),n(e)}),r}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&&ib.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 n=o5();this.emit("languageChanging",e);let r=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&&(r(i),this.translator.changeLanguage(i),this.isLanguageChangingTo=void 0,this.emit("languageChanged",i),this.logger.log("languageChanged",i)):this.isLanguageChangingTo=void 0,n.resolve((...e)=>this.t(...e)),t&&t(o,(...e)=>this.t(...e))},i=t=>{e||t||!this.services.languageDetector||(t=[]);let n=o6(t)?t:t&&t[0],i=this.store.hasLanguageSomeTranslations(n)?n:this.services.languageUtils.getBestMatchFromCodes(o6(t)?[t]:t);i&&(this.language||r(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()),n}getFixedT(e,t,n){let r=(e,t,...o)=>{let i,a;(i="object"!=typeof t?this.options.overloadTranslationOptionHandler([e,t].concat(o)):{...t}).lng=i.lng||r.lng,i.lngs=i.lngs||r.lngs,i.ns=i.ns||r.ns,""!==i.keyPrefix&&(i.keyPrefix=i.keyPrefix||n||r.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)?r.lng=e:r.lngs=e,r.ns=t,r.keyPrefix=n,r}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 n=t.lng||this.resolvedLanguage||this.languages[0],r=!!this.options&&this.options.fallbackLng,o=this.languages[this.languages.length-1];if("cimode"===n.toLowerCase())return!0;let i=(e,t)=>{let n=this.services.backendConnector.state[`${e}|${t}`];return -1===n||0===n||2===n};if(t.precheck){let e=t.precheck(this,i);if(void 0!==e)return e}return!!(this.hasResourceBundle(n,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||i(n,e)&&(!r||i(o,e)))}loadNamespaces(e,t){let n=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=>{n.resolve(),t&&t(e)}),n):(t&&t(),Promise.resolve())}loadLanguages(e,t){let n=o5();o6(e)&&(e=[e]);let r=this.options.preload||[],o=e.filter(e=>0>r.indexOf(e)&&this.services.languageUtils.isSupportedCode(e));return o.length?(this.options.preload=r.concat(o),this.loadResources(e=>{n.resolve(),t&&t(e)}),n):(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 iE(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 i$(e,t)}cloneInstance(e={},t=iI){let n=e.forkResourceStore;n&&delete e.forkResourceStore;let r={...this.options,...e,isClone:!0},o=new i$(r);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)},n&&(o.store=new ig(Object.keys(this.store.data).reduce((e,t)=>(e[t]={...this.store.data[t]},e[t]=Object.keys(e[t]).reduce((n,r)=>(n[r]={...e[t][r]},n),e[t]),e),{}),r),o.services.resourceStore=o.store),o.translator=new iS(o.services,r),o.translator.on("*",(e,...t)=>{o.emit(e,...t)}),o.init(r,t),o.translator.options=r,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=i$.createInstance();iL.createInstance=i$.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,n,r){return iF.t(t,{ns:e,defaultValue:n,...r})}function iV(e,t,n){return o3[e]?iB("core",e,t??o3[e],n):(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=iZ().then(({map:e,complete:t})=>(t||(iG=null),e))),iG}async function iZ(){let e=document.querySelectorAll('script[type="systemjs-importmap"]'),t=[],n=!0;for(let r=0;r<e.length;r++){let o=e[r];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){n=!1,console.warn(`[import-maps] Failed to parse import map from script tag at index ${r}`,e)}}return{map:iY(t),complete:n}}function iY(e){let t={imports:{}};for(let n of e)n?.imports&&Object.assign(t.imports,n.imports);return t}function iJ(){let e={};try{let t=i2();for(let n=0;n<localStorage.length;n++){let r=localStorage.key(n);if(r?.startsWith(iU)){let n=r.slice(iU.length);if(!t.includes(n)){let t=localStorage.getItem(r);t&&(e[n]=t)}}}}catch(e){console.warn("[import-maps] Failed to read import-map overrides from localStorage",e)}return{imports:e}}async function iQ(){let e=await iq();return iz?iY([e,iH??iJ()]):e}async function iX(){return iq()}async function i0(){return iz?iY([await iq(),iJ()]):iq()}function i1(e){if(!iz)return{imports:{}};if(e){let e={};for(let t=0;t<localStorage.length;t++){let n=localStorage.key(t);if(n?.startsWith(iU)){let t=localStorage.getItem(n);t&&(e[n.slice(iU.length)]=t)}}return{imports:e}}return iJ()}function i2(){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 i4(e){return!!iz&&i2().includes(e)}function i3(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=i2().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 n=localStorage.key(t);n?.startsWith(iU)&&e.push(n)}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 i7(e){if(!iz)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{let t=i2().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 i8(){!i9&&(i9=!0,(iz="development"===window.spaEnv)&&(iH=iJ()))}function ae(e){return e.replace(/[\/\-@]/g,"_")}async function at(e,t="./start",r){var o;let i,a=!r?.maxLoadingTime||r.maxLoadingTime<=0?6e5:r.maxLoadingTime;await Promise.race([an(e,r?.importMap),new Promise((t,n)=>{i=setTimeout(()=>{var t;n(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(n.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 an(e,t){if("string"!=typeof e||0===e.trim().length){let e="Attempted to call importDynamic() without supplying a package to load";throw console.error(e),Error(e)}let n=ae(e);if(!window[n]){let n=t??await ar();if(!n.imports.hasOwnProperty(e)){let t=`Could not find the package ${e} defined in the current importmap`;throw console.error(t),Error(t)}let r=n.imports[e];r.startsWith("./")&&(r=window.spaBase+r.substring(1));let o=e in i1().imports;try{return await function(e){var t;let n=(t=window)[ao]??(t[ao]=new Map),r=n.get(e);if(r)return r;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,r)=>{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(),n.delete(e),o.remove();let i=`Failed to load script from ${e}`;console.error(i,t),r(t.message??i)}o.addEventListener("load",s),o.addEventListener("error",l),document.head.appendChild(o)});return n.set(e,i),i}(r)}catch(e){return o&&T({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:r}),actionButtonLabel:iV("resetOverrides","Reset overrides"),onActionButtonClick(){i5(),window.location.reload()}}),Promise.reject(e)}}return Promise.resolve()}async function ar(){return iQ()}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 af(){return ad??(ad=ap().then(({map:e,complete:t})=>(t||(ad=null),e))),ad}async function ap(){let e=document.querySelectorAll("script[type='openmrs-routes']"),t=[],n=!0;for(let r=0;r<e.length;r++){let o=e[r];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){n=!1,console.warn(`[route-maps] Failed to parse routes from script tag at index ${r}`,e)}}return{map:ah(t),complete:n}}function ah(e){let t={routes:{}};for(let n of e)n&&"object"==typeof n&&!Array.isArray(n)&&(Object.assign(t.routes,n.routes),void 0===t.version&&void 0!==n.version&&(t.version=n.version));return t}async function am(){let e={version:void 0,routes:{}};try{let t=[];for(let e=0;e<localStorage.length;e++){let n=localStorage.key(e);if(n?.startsWith(as)){let e=localStorage.getItem(n);e&&t.push({moduleName:n.slice(as.length),raw:e})}}for(let n of(await Promise.allSettled(t.map(async({moduleName:e,raw:t})=>{let n=JSON.parse(t);if(ai(n))return{moduleName:e,routes:n};if("string"==typeof n&&n.startsWith("http")){let t=await fetch(n),r=await t.json();if(ai(r))return{moduleName:e,routes:r};throw Error(`${n} did not resolve to a valid OpenmrsAppRoutes object`)}throw Error(`Override for ${e} is neither a valid routes object nor a URL`)}))))"fulfilled"===n.status?e.routes[n.value.moduleName]=n.value.routes:console.warn("[route-maps] Failed to load route override",n.reason)}catch(e){console.warn("[route-maps] Failed to read route overrides from localStorage",e)}return e}async function ay(){let e=await af();return au?ah([e,ac??await am()]):e}async function ag(){return af()}async function ab(){return au?ah([await af(),await am()]):af()}function av(){if(!au)return{};let e={};try{for(let t=0;t<localStorage.length;t++){let n=localStorage.key(t);if(n?.startsWith(as)){let t=localStorage.getItem(n);t&&(e[n.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 n=JSON.parse(t);if(!ai(n))return void console.error(`The supplied routes for ${e} is not a valid OpenmrsAppRoutes object`,t);localStorage.setItem(as+e,JSON.stringify(n))}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 n=localStorage.key(t);n?.startsWith(as)&&e.push(n)}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 aS=null;function aE(){return aS||(aS=(au="development"===window.spaEnv)?am().then(e=>{ac=e}):Promise.resolve())}let aD=`${oM}/attachment`;function aO(e,t){return oF(`${aD}/${e}`,{signal:t.signal})}function ak(e,t,n){return oF(`${aD}?patient=${e}&includeEncounterless=${t}`,{signal:n.signal})}async function aP(e,t){let n=new FormData;return n.append("fileCaption",t.fileDescription),n.append("patient",e),t.file?n.append("file",t.file,t.fileName):(n.append("file",new File([""],t.fileName),t.fileName),n.append("base64Content",t.base64Content)),oF(`${aD}`,{method:"POST",body:n})}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(n){var r=new MessageChannel;r.port1.onmessage=function(e){n(e.data)},e.postMessage(t,[r.port2])})}function aT(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function aR(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}try{self["workbox:core:6.5.4"]&&_()}catch(e){}var aA=function(){var e=this;this.promise=new Promise(function(t,n){e.resolve=t,e.reject=n})};function aN(e,t){var n=location.href;return new URL(e,n).href===new URL(t,n).href}var aM=function(e,t){this.type=e,Object.assign(this,t)};function aI(e,t,n){return n?t?t(e):e:(e&&e.then||(e=Promise.resolve(e)),t?e.then(t):e)}function a$(){}var aL={type:"SKIP_WAITING"};function aF(e,t){if(!t)return e&&e.then?e.then(a$):Promise.resolve()}var aB=function(e){function t(t,n){var r,o;return void 0===n&&(n={}),(r=e.call(this)||this).nn={},r.tn=0,r.rn=new aA,r.en=new aA,r.on=new aA,r.un=0,r.an=new Set,r.cn=function(){var e=r.fn,t=e.installing;r.tn>0||!aN(t.scriptURL,r.sn.toString())||performance.now()>r.un+6e4?(r.vn=t,e.removeEventListener("updatefound",r.cn)):(r.hn=t,r.an.add(t),r.rn.resolve(t)),++r.tn,t.addEventListener("statechange",r.ln)},r.ln=function(e){var t=r.fn,n=e.target,o=n.state,i=n===r.vn,a={sw:n,isExternal:i,originalEvent:e};!i&&r.mn&&(a.isUpdate=!0),r.dispatchEvent(new aM(o,a)),"installed"===o?r.wn=self.setTimeout(function(){"installed"===o&&t.waiting===n&&r.dispatchEvent(new aM("waiting",a))},200):"activating"===o&&(clearTimeout(r.wn),i||r.en.resolve(n))},r.dn=function(e){var t=r.hn,n=t!==navigator.serviceWorker.controller;r.dispatchEvent(new aM("controlling",{isExternal:n,originalEvent:e,sw:t,isUpdate:r.mn})),n||r.on.resolve(t)},o=function(e){var t=e.data,n=e.ports,o=e.source;return aI(r.getSW(),function(){r.an.has(o)&&r.dispatchEvent(new aM("message",{data:t,originalEvent:e,ports:n,sw:o}))})},r.gn=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];try{return Promise.resolve(o.apply(this,e))}catch(e){return Promise.reject(e)}},r.sn=t,r.nn=n,navigator.serviceWorker.addEventListener("message",r.gn),r}t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e;var n,r,o=t.prototype;return o.register=function(e){var t=(void 0===e?{}:e).immediate,n=void 0!==t&&t;try{var r,o,i,a=this;return r=function(){if(!n&&"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 aM("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=r())&&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 n=e()}catch(e){return t(e)}return n&&n.then?n.then(void 0,t):n}(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)}},n=[{key:"active",get:function(){return this.en.promise}},{key:"controlling",get:function(){return this.on.promise}}],aT(t.prototype,n),r&&aT(t,r),t}(function(){function e(){this.Pn=new Map}var t=e.prototype;return t.addEventListener=function(e,t){this.Sn(e).add(t)},t.removeEventListener=function(e,t){this.Sn(e).delete(t)},t.dispatchEvent=function(e){e.target=this;for(var t,n=function(e){var t;if("u"<typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(t=function(e){if(e){if("string"==typeof e)return 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 n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(t=e[Symbol.iterator]()).next.bind(t)}(this.Sn(e.type));!(t=n()).done;)(0,t.value)(e)},t.Sn=function(e){return this.Pn.has(e)||this.Pn.set(e,new Set),this.Pn.get(e)},e}());function aV(e,t){if(void 0!==f)return console.warn(`The application's Service Worker has already been registered. The new service worker at ${e} will not be registered.`),f;if(!("serviceWorker"in navigator))throw Error("Registering the Service Worker is not possible due to missing browser capabilities.");let n=new aB(e,t);return f=n.register().then(()=>n.controlling.then(()=>n))}function aU(){return f??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 aZ(){return new Promise(e=>{let t=indexedDB.open("test");t.onerror=()=>e(!0),t.onsuccess=()=>e(!1)})}async function aY(){return await aZ()||await aq()||await aG()}let aJ="openmrs3:offline-mode",aQ="unavailable";function aX(){return{current:aQ,notAvailable:"unavailable"===aQ,active:"on"===aQ}}function a0(e){"unavailable"!==aQ&&"unavailable"!==e&&(localStorage.setItem(aJ,"on"===e?"active":"disabled"),aQ=e)}async function a1(){await aY()||(aQ="active"===localStorage.getItem(aJ)?"on":"off"),navigator.onLine}let a2="u">typeof globalThis?globalThis:"u">typeof self?self:"u">typeof window?window:global,a4=Object.keys,a3=Array.isArray;function a6(e,t){return"object"!=typeof t||a4(t).forEach(function(n){e[n]=t[n]}),e}"u"<typeof Promise||a2.Promise||(a2.Promise=Promise);let a5=Object.getPrototypeOf,a7={}.hasOwnProperty;function a9(e,t){return a7.call(e,t)}function a8(e,t){"function"==typeof t&&(t=t(a5(e))),("u"<typeof Reflect?a4:Reflect.ownKeys)(t).forEach(n=>{st(e,n,t[n])})}let se=Object.defineProperty;function st(e,t,n,r){se(e,t,a6(n&&a9(n,"get")&&"function"==typeof n.get?{get:n.get,set:n.set,configurable:!0}:{value:n,configurable:!0,writable:!0},r))}function sn(e){return{from:function(t){return e.prototype=Object.create(t.prototype),st(e.prototype,"constructor",e),{extend:a8.bind(null,e.prototype)}}}}let sr=Object.getOwnPropertyDescriptor;function so(e,t){let n;return sr(e,t)||(n=a5(e))&&so(n,t)}let si=[].slice;function sa(e,t,n){return si.call(e,t,n)}function ss(e,t){return t(e)}function sl(e){if(!e)throw Error("Assertion Failed")}function su(e){a2.setImmediate?setImmediate(e):setTimeout(e,0)}function sc(e,t){return e.reduce((e,n,r)=>{var o=t(n,r);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 n=[],r=0,o=t.length;r<o;++r){var i=sd(e,t[r]);n.push(i)}return n}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 sf(e,t,n){if(e&&void 0!==t&&(!("isFrozen"in Object)||!Object.isFrozen(e)))if("string"!=typeof t&&"length"in t){sl("string"!=typeof n&&"length"in n);for(var r=0,o=t.length;r<o;++r)sf(e,t[r],n[r])}else{var i=t.indexOf(".");if(-1!==i){var a=t.substr(0,i),s=t.substr(i+1);if(""===s)void 0===n?a3(e)&&!isNaN(parseInt(a))?e.splice(a,1):delete e[a]:e[a]=n;else{var l=e[a];l&&a9(e,a)||(l=e[a]={}),sf(l,s,n)}}else void 0===n?a3(e)&&!isNaN(parseInt(t))?e.splice(t,1):delete e[t]:e[t]=n}}function sp(e){var t={};for(var n in e)a9(e,n)&&(t[n]=e[n]);return t}let sh=[].concat;function sm(e){return sh.apply([],e)}let sy="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=>a2[e]),sg=sy.map(e=>a2[e]);sc(sy,e=>[e,!0]);let sb=null;function sv(e){sb="u">typeof WeakMap&&new WeakMap;let t=function e(t){if(!t||"object"!=typeof t)return t;let n=sb&&sb.get(t);if(n)return n;if(a3(t)){n=[],sb&&sb.set(t,n);for(var r=0,o=t.length;r<o;++r)n.push(e(t[r]))}else if(sg.indexOf(t.constructor)>=0)n=t;else{let r=a5(t);for(var i in n=r===Object.prototype?{}:Object.create(r),sb&&sb.set(t,n),t)a9(t,i)&&(n[i]=e(t[i]))}return n}(e);return sb=null,t}let{toString:sw}={};function s_(e){return sw.call(e).slice(8,-1)}let sx="u">typeof Symbol?Symbol.iterator:"@@iterator",sS="symbol"==typeof sx?function(e){var t;return null!=e&&(t=e[sx])&&t.apply(e)}:function(){return null},sE={};function sD(e){var t,n,r,o;if(1==arguments.length){if(a3(e))return e.slice();if(this===sE&&"string"==typeof e)return[e];if(o=sS(e)){for(n=[];!(r=o.next()).done;)n.push(r.value);return n}if(null==e)return[e];if("number"==typeof(t=e.length)){for(n=Array(t);t--;)n[t]=e[t];return n}return[e]}for(t=arguments.length,n=Array(t);t--;)n[t]=arguments[t];return n}let 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 n=e.stack;return n?(t=t||0,0===n.indexOf(e.name)&&(t+=(e.name+e.message).split("\n").length),n.split("\n").slice(t).filter(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 sM(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,n)=>n.indexOf(e)===t).join("\n")}function s$(e,t,n,r){this._e=sj(),this.failures=t,this.failedKeys=r,this.successCount=n,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)}sn(sM).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}}),sn(s$).from(sM),sn(sL).from(sM);var sF=sA.reduce((e,t)=>(e[t]=t+"Error",e),{}),sB=sA.reduce((e,t)=>{var n=t+"Error";function r(e,r){this._e=sj(),this.name=n,e?"string"==typeof e?(this.message=`${e}${r?"\n "+r:""}`,this.inner=r||null):"object"==typeof e&&(this.message=`${e.name} ${e.message}`,this.inner=e):(this.message=sN[t]||n,this.inner=null)}return sn(r).from(sM),e[t]=r,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(n){return t(e(n))}}function sH(e,t){return function(){e.apply(this,arguments),t.apply(this,arguments)}}function sG(e,t){return e===sW?t:function(){var n=e.apply(this,arguments);void 0!==n&&(arguments[0]=n);var r=this.onsuccess,o=this.onerror;this.onsuccess=null,this.onerror=null;var i=t.apply(this,arguments);return r&&(this.onsuccess=this.onsuccess?sH(r,this.onsuccess):r),o&&(this.onerror=this.onerror?sH(o,this.onerror):o),void 0!==i?i:n}}function sq(e,t){return e===sW?t:function(){e.apply(this,arguments);var n=this.onsuccess,r=this.onerror;this.onsuccess=this.onerror=null,t.apply(this,arguments),n&&(this.onsuccess=this.onsuccess?sH(n,this.onsuccess):n),r&&(this.onerror=this.onerror?sH(r,this.onerror):r)}}function sZ(e,t){return e===sW?t:function(n){var r=e.apply(this,arguments);a6(n,r);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===r?void 0===a?void 0:a:a6(r,a)}}function sY(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 n=e.apply(this,arguments);if(n&&"function"==typeof n.then){for(var r=this,o=arguments.length,i=Array(o);o--;)i[o]=arguments[o];return n.then(function(){return t.apply(r,i)})}return t.apply(this,arguments)}}sU.ModifyError=s$,sU.DexieError=sM,sU.BulkError=sL;var sQ={};let[sX,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]})(),s2=s0&&s0.then,s4=sX&&sX.constructor,s3=!!s1;var s6=!1,s5=s1?()=>{s1.then(lg)}:a2.setImmediate?setImmediate.bind(null,lg):a2.MutationObserver?()=>{var e=document.createElement("div");new MutationObserver(()=>{lg(),e=null}).observe(e,{attributes:!0}),e.setAttribute("i","1")}:()=>{setTimeout(lg,0)},s7=function(e,t){la.push([e,t]),s8&&(s5(),s8=!1)},s9=!0,s8=!0,le=[],lt=[],ln=null,lr=sK,lo={id:"global",global:!0,ref:0,unhandleds:[],onunhandled:lB,pgp:!1,env:{},finalize:function(){this.unhandleds.forEach(e=>{try{lB(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!==sQ)throw TypeError("Not a function");return this._state=arguments[1],this._value=arguments[2],void(!1===this._state&&lf(this,this._value))}this._state=null,this._value=null,++t.ref,function e(t,n){try{n(n=>{if(null===t._state){if(n===t)throw TypeError("A promise cannot be resolved with itself.");var r=t._lib&&lb();n&&"function"==typeof n.then?e(t,(e,t)=>{n instanceof lu?n._then(e,t):n.then(e,t)}):(t._state=!0,t._value=n,lp(t)),r&&lv()}},lf.bind(null,t))}catch(e){lf(t,e)}}(this,e)}let lc={get:function(){var e=li,t=lk;function n(n,r){var o=!e.global&&(e!==li||t!==lk);let i=o&&!lT();var a=new lu((t,a)=>{lh(this,new ld(lL(n,e,o,i),lL(r,e,o,i),t,a,e))});return sk&&ly(a,this),a}return n.prototype=sQ,n},set:function(e){st(this,"then",e&&e.prototype===sQ?lc:{get:function(){return e},set:lc.set})}};function ld(e,t,n,r,o){this.onFulfilled="function"==typeof e?e:null,this.onRejected="function"==typeof t?t:null,this.resolve=n,this.reject=r,this.psd=o}function lf(e,t){if(lt.push(t),null===e._state){var n=e._lib&&lb();t=lr(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 n=so(t,"stack");t._promise=e,st(t,"stack",{get:()=>s6?n&&(n.get?n.get.apply(t):n.value):e.stack})}),le.some(t=>t._value===e._value)||le.push(e),lp(e),n&&lv()}}function lp(e){var t=e._listeners;e._listeners=[];for(var n=0,r=t.length;n<r;++n)lh(e,t[n]);var o=e._PSD;--o.ref||o.finalize(),0===ls&&(++ls,s7(()=>{0==--ls&&lw()},[]))}function lh(e,t){if(null!==e._state){var n=e._state?t.onFulfilled:t.onRejected;if(null===n)return(e._state?t.resolve:t.reject)(e._value);++t.psd.ref,++ls,s7(lm,[n,e,t])}else e._listeners.push(t)}function lm(e,t,n){try{ln=t;var r,o=t._value;t._state?r=e(o):(lt.length&&(lt=[]),r=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)),n.resolve(r)}catch(e){n.reject(e)}finally{ln=null,0==--ls&&lw(),--n.psd.ref||n.psd.finalize()}}function ly(e,t){var n=t?t._numPrev+1:0;n<100&&(e._prev=t,e._numPrev=n)}function lg(){lb()&&lv()}function lb(){var e=s9;return s9=!1,s8=!1,e}function lv(){var e,t,n;do for(;la.length>0;)for(e=la,la=[],n=e.length,t=0;t<n;++t){var r=e[t];r[0].apply(null,r[1])}while(la.length>0);s9=!0,s8=!0}function lw(){var e=le;le=[],e.forEach(e=>{e._PSD.onunhandled.call(null,e._value,e)});for(var t=ll.slice(0),n=t.length;n;)t[--n]()}function l_(e){return new lu(sQ,!1,e)}function lx(e,t){var n=li;return function(){var r=lb(),o=li;try{return lM(n,!0),e.apply(this,arguments)}catch(e){t&&t(e)}finally{lM(o,!1),r&&lv()}}}a8(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],n=arguments[1];return"function"==typeof t?this.then(null,e=>e instanceof t?n(e):l_(e)):this.then(null,e=>e&&e.name===t?n(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,n,r){if(n.length===r)return n;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=""),n.push(i+(a?": "+a:"")+o)}return sk&&((o=sT(t._stackHolder,2))&&-1===n.indexOf(o)&&n.push(o),t._prev&&e(t._prev,n,r)),n})(this,[],20).join("\nFrom previous: ");return null!==this._state&&(this._stack=e),e}finally{s6=!1}}},timeout:function(e,t){return e<1/0?new lu((n,r)=>{var o=setTimeout(()=>r(new sB.Timeout(t)),e);this.then(n,r).finally(clearTimeout.bind(null,o))}):this}}),"u">typeof Symbol&&Symbol.toStringTag&&st(lu.prototype,Symbol.toStringTag,"Dexie.Promise"),lo.env=lI(),a8(lu,{all:function(){var e=sD.apply(null,arguments).map(lR);return new lu(function(t,n){0===e.length&&t([]);var r=e.length;e.forEach((o,i)=>lu.resolve(o).then(n=>{e[i]=n,--r||t(e)},n))})},resolve:e=>{if(e instanceof lu)return e;if(e&&"function"==typeof e.then)return new lu((t,n)=>{e.then(t,n)});var t=new lu(sQ,!0,e);return ly(t,ln),t},reject:l_,race:function(){var e=sD.apply(null,arguments).map(lR);return new lu((t,n)=>{e.map(e=>lu.resolve(e).then(t,n))})},PSD:{get:()=>li,set:e=>li=e},totalEchoes:{get:()=>lk},newPSD:lC,usePSD:l$,scheduler:{get:()=>s7,set:e=>{s7=e}},rejectionMapper:{get:()=>lr,set:e=>{lr=e}},follow:(e,t)=>new lu((n,r)=>lC((t,n)=>{var r=li;r.unhandleds=[],r.onunhandled=n,r.finalize=sH(function(){var e;e=()=>{0===this.unhandleds.length?t():n(this.unhandleds[0])},ll.push(function t(){e(),ll.splice(ll.indexOf(t),1)}),++ls,s7(()=>{0==--ls&&lw()},[])},r.finalize),e()},t,n,r))}),s4&&(s4.allSettled&&st(lu,"allSettled",function(){let e=sD.apply(null,arguments).map(lR);return new lu(t=>{0===e.length&&t([]);let n=e.length,r=Array(n);e.forEach((e,o)=>lu.resolve(e).then(e=>r[o]={status:"fulfilled",value:e},e=>r[o]={status:"rejected",reason:e}).then(()=>--n||t(r)))})}),s4.any&&"u">typeof AggregateError&&st(lu,"any",function(){let e=sD.apply(null,arguments).map(lR);return new lu((t,n)=>{0===e.length&&n(AggregateError([]));let r=e.length,o=Array(r);e.forEach((e,i)=>lu.resolve(e).then(e=>t(e),e=>{o[i]=e,--r||n(AggregateError(o))}))})}));let lS={awaits:0,echoes:0,id:0};var lE=0,lD=[],lO=0,lk=0,lP=0;function lC(e,t,n,r){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=s3?{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=l$(i,e,n,r);return 0===i.ref&&i.finalize(),s}function lj(){return lS.id||(lS.id=++lE),++lS.awaits,lS.echoes+=100,lS.id}function lT(){return!!lS.awaits&&(0==--lS.awaits&&(lS.id=0),lS.echoes=100*lS.awaits,!0)}function lR(e){return lS.echoes&&e&&e.constructor===s4?(lj(),e.then(e=>(lT(),e),e=>(lT(),lV(e)))):e}function lA(e){++lk,lS.echoes&&0!=--lS.echoes||(lS.echoes=lS.id=0),lD.push(li),lM(e,!0)}function lN(){var e=lD[lD.length-1];lD.pop(),lM(e,!1)}function lM(e,t){var n,r=li;if((t?!lS.echoes||lO++&&e===li:!lO||--lO&&e===li)||(n=t?lA.bind(null,e):lN,s2.call(sX,n)),e!==li&&(li=e,r===lo&&(lo.env=lI()),s3)){var o=lo.env.Promise,i=e.env;s0.then=i.nthen,o.prototype.then=i.gthen,(r.global||e.global)&&(Object.defineProperty(a2,"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=a2.Promise;return s3?{Promise:e,PromiseProp:Object.getOwnPropertyDescriptor(a2,"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 l$(e,t,n,r,o){var i=li;try{return lM(e,!0),t(n,r,o)}finally{lM(i,!1)}}function lL(e,t,n,r){return"function"!=typeof e?e:function(){var o,i=li;n&&lj(),lM(t,!0);try{return e.apply(this,arguments)}finally{lM(i,!1),r&&(o=lT,s2.call(sX,o))}}}function lF(e,t){return function(n,r){return e.call(this,lL(n,t),lL(r,t))}}function lB(e,t){var n;try{n=t.onuncatched(e)}catch(e){}if(!1!==n)try{var r,o={promise:t,reason:e};if(a2.document&&document.createEvent?((r=document.createEvent("Event")).initEvent("unhandledrejection",!0,!0),a6(r,o)):a2.CustomEvent&&a6(r=new CustomEvent("unhandledrejection",{detail:o}),o),r&&a2.dispatchEvent&&(dispatchEvent(r),!a2.PromiseRejectionEvent&&a2.onunhandledrejection))try{a2.onunhandledrejection(r)}catch(e){}sk&&r&&!r.defaultPrevented&&console.warn(`Unhandled rejection: ${e.stack||e}`)}catch(e){}}-1===(""+s2).indexOf("[native code]")&&(lj=lT=sW);var lV=lu.reject;let lU=String.fromCharCode(65535),lW="Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.",lK=[],lz="u">typeof navigator&&/(MSIE|Trident|Edge)/.test(navigator.userAgent),lH=e=>!/(dexie\.js|dexie\.min\.js)/.test(e);function lG(e,t){return e?t?function(){return e.apply(this,arguments)&&t.apply(this,arguments)}:e:t}let lq={type:3,lower:-1/0,lowerOpen:!1,upper:[[]],upperOpen:!1};function lZ(e){return"string"!=typeof e||/\./.test(e)?e=>e:t=>(void 0===t[e]&&e in t&&delete(t=sv(t))[e],t)}class lY{_trans(e,t,n){let r=this._tx||li.trans,o=this.name;function i(e,n,r){if(!r.schema[o])throw new sB.NotFound("Table "+o+" not part of transaction");return t(r.idbtrans,r)}let a=lb();try{return r&&r.db===this.db?r===li.trans?r._promise(e,i,n):lC(()=>r._promise(e,i,n),{trans:r,transless:li.transless||li}):function e(t,n,r,o){if(t.idbdb&&(t._state.openComplete||li.letThrough||t._vip)){var i=t._createTransaction(n,r,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,n,r,o))):lV(i)}return i._promise(n,(e,t)=>lC(()=>(li.trans=i,o(e,t,i)))).then(e=>i._completion.then(()=>e))}if(t._state.openComplete)return lV(new sB.DatabaseClosed(t._state.dbOpenError));if(!t._state.isBeingOpened){if(!t._options.autoOpen)return lV(new sB.DatabaseClosed);t.open().catch(sW)}return t._state.dbReadyPromise.then(()=>e(t,n,r,o))}(this.db,e,[this.name],i)}finally{a&&lv()}}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(a3(e))return new this.db.WhereClause(this,`[${e.join("+")}]`);let t=a4(e);if(1===t.length)return this.where(t[0]).equals(e[t[0]]);let n=this.schema.indexes.concat(this.schema.primKey).filter(e=>e.compound&&t.every(t=>e.keyPath.indexOf(t)>=0)&&e.keyPath.every(e=>t.indexOf(e)>=0))[0];if(n&&this.db._maxKey!==lU)return this.where(n.name).equals(n.keyPath.map(t=>e[t]));!n&&sk&&console.warn(`The query ${JSON.stringify(e)} on ${this.name} would benefit of a compound index [${t.join("+")}]`);let{idxByName:r}=this.schema,o=this.db._deps.indexedDB;function i(e,t){try{return 0===o.cmp(e,t)}catch(e){return!1}}let[a,s]=t.reduce(([t,n],o)=>{let a=r[o],s=e[o];return[t||a,t||!a?lG(n,a&&a.multi?e=>{let t=sd(e,o);return a3(t)&&t.some(e=>i(s,e))}:e=>i(s,sd(e,o))):n]},[null,null]);return a?this.where(a.name).equals(e[a.keyPath]).filter(s):n?this.filter(s):this.where(t).equals("")}filter(e){return this.toCollection().and(e)}count(e){return this.toCollection().count(e)}offset(e){return this.toCollection().offset(e)}limit(e){return this.toCollection().limit(e)}each(e){return this.toCollection().each(e)}toArray(e){return this.toCollection().toArray(e)}toCollection(){return new this.db.Collection(new this.db.WhereClause(this))}orderBy(e){return new this.db.Collection(new this.db.WhereClause(this,a3(e)?`[${e.join("+")}]`:e))}reverse(){return this.toCollection().reverse()}mapToClass(e){this.schema.mappedClass=e;let t=t=>{if(!t)return t;let n=Object.create(e.prototype);for(var r in t)if(a9(t,r))try{n[r]=t[r]}catch(e){}return n};return this.schema.readHook&&this.hook.reading.unsubscribe(this.schema.readHook),this.schema.readHook=t,this.hook("reading",t),e}defineClass(){return this.mapToClass(function(e){a6(this,e)})}add(e,t){let{auto:n,keyPath:r}=this.schema.primKey,o=e;return r&&n&&(o=lZ(r)(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(r)try{sf(e,r,t)}catch(e){}return t})}update(e,t){if("object"!=typeof e||a3(e))return this.where(":id").equals(e).modify(t);{let n=sd(e,this.schema.primKey.keyPath);if(void 0===n)return lV(new sB.InvalidArgument("Given object does not contain its primary key"));try{"function"!=typeof t?a4(t).forEach(n=>{sf(e,n,t[n])}):t(e,{value:e,primKey:n})}catch(e){}return this.where(":id").equals(n).modify(t)}}put(e,t){let{auto:n,keyPath:r}=this.schema.primKey,o=e;return r&&n&&(o=lZ(r)(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(r)try{sf(e,r,t)}catch(e){}return t})}delete(e){return this._trans("readwrite",t=>this.core.mutate({trans:t,type:"delete",keys:[e]})).then(e=>e.numFailures?lu.reject(e.failures[0]):void 0)}clear(){return this._trans("readwrite",e=>this.core.mutate({trans:e,type:"deleteRange",range:lq})).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,n){let r=Array.isArray(t)?t:void 0,o=(n=n||(r?void 0:t))?n.allKeys:void 0;return this._trans("readwrite",t=>{let{auto:n,keyPath:i}=this.schema.primKey;if(i&&r)throw new sB.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(r&&r.length!==e.length)throw new sB.InvalidArgument("Arguments objects and keys must have the same length");let a=e.length,s=i&&n?e.map(lZ(i)):e;return this.core.mutate({trans:t,type:"add",keys:r,values:s,wantResults:o}).then(({numFailures:e,results:t,lastResult:n,failures:r})=>{if(0===e)return o?t:n;throw new sL(`${this.name}.bulkAdd(): ${e} of ${a} operations failed`,r)})})}bulkPut(e,t,n){let r=Array.isArray(t)?t:void 0,o=(n=n||(r?void 0:t))?n.allKeys:void 0;return this._trans("readwrite",t=>{let{auto:n,keyPath:i}=this.schema.primKey;if(i&&r)throw new sB.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(r&&r.length!==e.length)throw new sB.InvalidArgument("Arguments objects and keys must have the same length");let a=e.length,s=i&&n?e.map(lZ(i)):e;return this.core.mutate({trans:t,type:"put",keys:r,values:s,wantResults:o}).then(({numFailures:e,results:t,lastResult:n,failures:r})=>{if(0===e)return o?t:n;throw new sL(`${this.name}.bulkPut(): ${e} of ${a} operations failed`,r)})})}bulkDelete(e){let t=e.length;return this._trans("readwrite",t=>this.core.mutate({trans:t,type:"delete",keys:e})).then(({numFailures:e,lastResult:n,failures:r})=>{if(0===e)return n;throw new sL(`${this.name}.bulkDelete(): ${e} of ${t} operations failed`,r)})}}function lJ(e){var t={},n=function(n,r){if(r){for(var o=arguments.length,i=Array(o-1);--o;)i[o-1]=arguments[o];return t[n].subscribe.apply(null,i),e}if("string"==typeof n)return t[n]};n.addEventType=i;for(var r=1,o=arguments.length;r<o;++r)i(arguments[r]);return n;function i(e,r,o){if("object"==typeof e){var a;return void a4(a=e).forEach(function(e){var t=a[e];if(a3(t))i(e,a[e][0],a[e][1]);else{if("asap"!==t)throw new sB.InvalidArgument("Invalid event config");var n=i(e,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)})})})}})}r||(r=sY),o||(o=sW);var s={subscribers:[],fire:o,subscribe:function(e){-1===s.subscribers.indexOf(e)&&(s.subscribers.push(e),s.fire=r(s.fire,e))},unsubscribe:function(e){s.subscribers=s.subscribers.filter(function(t){return t!==e}),s.fire=s.subscribers.reduce(r,o)}};return t[e]=n[e]=s,s}}function lQ(e,t){return sn(t).from({prototype:e}),t}function lX(e,t){return!(e.filter||e.algorithm||e.or)&&(t?e.justLimit:!e.replayFilter)}function l0(e,t){e.filter=lG(e.filter,t)}function l1(e,t,n){var r=e.replayFilter;e.replayFilter=r?()=>lG(r(),t()):t,e.justLimit=n&&!r}function l2(e,t){if(e.isPrimKey)return t.primaryKey;let n=t.getIndexByKeyPath(e.index);if(!n)throw new sB.Schema("KeyPath "+e.index+" on object store "+t.name+" is not indexed");return n}function l4(e,t,n){let r=l2(e,t.schema);return t.openCursor({trans:n,values:!e.keysOnly,reverse:"prev"===e.dir,unique:!!e.unique,query:{index:r,range:e.range}})}function l3(e,t,n,r){let o=e.replayFilter?lG(e.filter,e.replayFilter()):e.filter;if(e.or){let i={},a=(e,n,r)=>{if(!o||o(n,r,e=>n.stop(e),e=>n.fail(e))){var a=n.primaryKey,s=""+a;"[object ArrayBuffer]"===s&&(s=""+new Uint8Array(a)),a9(i,s)||(i[s]=!0,t(e,n,r))}};return Promise.all([e.or._iterate(a,n),l6(l4(e,r,n),e.algorithm,a,!e.keysOnly&&e.valueMapper)])}return l6(l4(e,r,n),lG(e.algorithm,o),t,!e.keysOnly&&e.valueMapper)}function l6(e,t,n,r){var o=lx(r?(e,t,o)=>n(r(e),t,o):n);return e.then(e=>{if(e)return e.start(()=>{var n=()=>e.continue();t&&!t(e,e=>n=e,t=>{e.stop(t),n=sW},t=>{e.fail(t),n=sW})||o(e.value,e,e=>n=e),n()})})}function l5(e,t){try{let n=l7(e),r=l7(t);if(n!==r)return"Array"===n?1:"Array"===r?-1:"binary"===n?1:"binary"===r?-1:"string"===n?1:"string"===r?-1:"Date"===n?1:"Date"!==r?NaN:-1;switch(n){case"number":case"Date":case"string":return e>t?1:e<t?-1:0;case"binary":return function(e,t){let n=e.length,r=t.length,o=n<r?n:r;for(let n=0;n<o;++n)if(e[n]!==t[n])return e[n]<t[n]?-1:1;return n===r?0:n<r?-1:1}(l9(e),l9(t));case"Array":return function(e,t){let n=e.length,r=t.length,o=n<r?n:r;for(let n=0;n<o;++n){let r=l5(e[n],t[n]);if(0!==r)return r}return n===r?0:n<r?-1:1}(e,t)}}catch(e){}return NaN}function l7(e){let t=typeof e;if("object"!==t)return t;if(ArrayBuffer.isView(e))return"binary";let n=s_(e);return"ArrayBuffer"===n?"binary":n}function l9(e){return e instanceof Uint8Array?e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e)}class l8{_read(e,t){var n=this._ctx;return n.error?n.table._trans(null,lV.bind(null,n.error)):n.table._trans("readonly",e).then(t)}_write(e){var t=this._ctx;return t.error?t.table._trans(null,lV.bind(null,t.error)):t.table._trans("readwrite",e,"locked")}_addAlgorithm(e){var t=this._ctx;t.algorithm=lG(t.algorithm,e)}_iterate(e,t){return l3(this._ctx,e,t,this._ctx.table.core)}clone(e){var t=Object.create(this.constructor.prototype),n=Object.create(this._ctx);return e&&a6(n,e),t._ctx=n,t}raw(){return this._ctx.valueMapper=null,this}each(e){var t=this._ctx;return this._read(n=>l3(t,e,n,t.table.core))}count(e){return this._read(e=>{let t=this._ctx,n=t.table.core;if(lX(t,!0))return n.count({trans:e,query:{index:l2(t,n.schema),range:t.range}}).then(e=>Math.min(e,t.limit));var r=0;return l3(t,()=>(++r,!1),e,n).then(()=>r)}).then(e)}sortBy(e,t){let n=e.split(".").reverse(),r=n[0],o=n.length-1;function i(e,t){return t?i(e[n[t]],t-1):e[r]}var a="next"===this._ctx.dir?1:-1;function s(e,t){var n=i(e,o),r=i(t,o);return n<r?-a:n>r?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&&lX(t,!0)&&t.limit>0){let{valueMapper:n}=t,r=l2(t,t.table.core.schema);return t.table.core.query({trans:e,limit:t.limit,values:!0,query:{index:r,range:t.range}}).then(({result:e})=>n?e.map(n):e)}{let n=[];return l3(t,e=>n.push(e),e,t.table.core).then(()=>n)}},e)}offset(e){var t=this._ctx;return e<=0||(t.offset+=e,lX(t)?l1(t,()=>{var t=e;return(e,n)=>0===t||(1===t?--t:n(()=>{e.advance(t),t=0}),!1)}):l1(t,()=>{var t=e;return()=>--t<0})),this}limit(e){return this._ctx.limit=Math.min(this._ctx.limit,e),l1(this._ctx,()=>{var t=e;return function(e,n,r){return--t<=0&&n(r),t>=0}},!0),this}until(e,t){return l0(this._ctx,function(n,r,o){return!e(n.value)||(r(o),t)}),this}first(e){return this.limit(1).toArray(function(e){return e[0]}).then(e)}last(e){return this.reverse().first(e)}filter(e){var t;return l0(this._ctx,function(t){return e(t.value)}),(t=this._ctx).isMatch=lG(t.isMatch,e),this}and(e){return this.filter(e)}or(e){return new this.db.WhereClause(this._ctx.table,e,this)}reverse(){return this._ctx.dir="prev"===this._ctx.dir?"next":"prev",this._ondirectionchange&&this._ondirectionchange(this._ctx.dir),this}desc(){return this.reverse()}eachKey(e){var t=this._ctx;return t.keysOnly=!t.isMatch,this.each(function(t,n){e(n.key,n)})}eachUniqueKey(e){return this._ctx.unique="unique",this.eachKey(e)}eachPrimaryKey(e){var t=this._ctx;return t.keysOnly=!t.isMatch,this.each(function(t,n){e(n.primaryKey,n)})}keys(e){var t=this._ctx;t.keysOnly=!t.isMatch;var n=[];return this.each(function(e,t){n.push(t.key)}).then(function(){return n}).then(e)}primaryKeys(e){var t=this._ctx;if("next"===t.dir&&lX(t,!0)&&t.limit>0)return this._read(e=>{var n=l2(t,t.table.core.schema);return t.table.core.query({trans:e,values:!1,limit:t.limit,query:{index:n,range:t.range}})}).then(({result:e})=>e).then(e);t.keysOnly=!t.isMatch;var n=[];return this.each(function(e,t){n.push(t.primaryKey)}).then(function(){return n}).then(e)}uniqueKeys(e){return this._ctx.unique="unique",this.keys(e)}firstKey(e){return this.limit(1).keys(function(e){return e[0]}).then(e)}lastKey(e){return this.reverse().firstKey(e)}distinct(){var e=this._ctx,t=e.index&&e.table.schema.idxByName[e.index];if(!t||!t.multi)return this;var n={};return l0(this._ctx,function(e){var t=e.primaryKey.toString(),r=a9(n,t);return n[t]=!0,!r}),this}modify(e){var t=this._ctx;return this._write(n=>{var r;if("function"==typeof e)r=e;else{var o=a4(e),i=o.length;r=function(t){for(var n=!1,r=0;r<i;++r){var a=o[r],s=e[a];sd(t,a)!==s&&(sf(t,a,s),n=!0)}return n}}let a=t.table.core,{outbound:s,extractKey:l}=a.schema.primaryKey,u=this.db._options.modifyChunkSize||200,c=[],d=0,f=[],p=(e,t)=>{let{failures:n,numFailures:r}=t;for(let t of(d+=e-r,a4(n)))c.push(n[t])};return this.clone().primaryKeys().then(o=>{let i=c=>{let d=Math.min(u,o.length-c);return a.getMany({trans:n,keys:o.slice(c,c+d),cache:"immutable"}).then(f=>{let h=[],m=[],y=s?[]:null,g=[];for(let e=0;e<d;++e){let t=f[e],n={value:sv(t),primKey:o[c+e]};!1!==r.call(n,n.value,n)&&(null==n.value?g.push(o[c+e]):s||0===l5(l(t),l(n.value))?(m.push(n.value),s&&y.push(o[c+e])):(g.push(o[c+e]),h.push(n.value)))}let b=lX(t)&&t.limit===1/0&&("function"!=typeof e||e===ue)&&{index:t.index,range:t.range};return Promise.resolve(h.length>0&&a.mutate({trans:n,type:"add",values:h}).then(e=>{for(let t in e.failures)g.splice(parseInt(t),1);p(h.length,e)})).then(()=>(m.length>0||b&&"object"==typeof e)&&a.mutate({trans:n,type:"put",keys:y,values:m,criteria:b,changeSpec:"function"!=typeof e&&e}).then(e=>p(m.length,e))).then(()=>(g.length>0||b&&e===ue)&&a.mutate({trans:n,type:"delete",keys:g,criteria:b}).then(e=>p(g.length,e))).then(()=>o.length>c+d&&i(c+u))})};return i(0).then(()=>{if(c.length>0)throw new s$("Error modifying one or more objects",c,d,f);return o.length})})})}delete(){var e=this._ctx,t=e.range;return lX(e)&&(e.isPrimKey&&!lz||3===t.type)?this._write(n=>{let{primaryKey:r}=e.table.core.schema;return e.table.core.count({trans:n,query:{index:r,range:t}}).then(r=>e.table.core.mutate({trans:n,type:"deleteRange",range:t}).then(({failures:e,lastResult:t,results:n,numFailures:o})=>{if(o)throw new s$("Could not delete some values",Object.keys(e).map(t=>e[t]),r-o);return r-o}))}):this.modify(ue)}}let ue=(e,t)=>t.value=null;function ut(e,t){return e<t?-1:+(e!==t)}function un(e,t){return e>t?-1:+(e!==t)}function ur(e,t,n){var r=e instanceof ul?new e.Collection(e):e;return r._ctx.error=n?new n(t):TypeError(t),r}function uo(e){return new e.Collection(e,()=>us("")).limit(0)}function ui(e,t,n,r){var o,i,a,s,l,u,c,d=n.length;if(!n.every(e=>"string"==typeof e))return ur(e,"String expected.");function f(e){o="next"===e?e=>e.toUpperCase():e=>e.toLowerCase(),i="next"===e?e=>e.toLowerCase():e=>e.toUpperCase(),a="next"===e?ut:un;var t=n.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?"":r}f("next");var p=new e.Collection(e,()=>ua(s[0],l[d-1]+r));p._ondirectionchange=function(e){f(e)};var h=0;return p._addAlgorithm(function(e,n,r){var o=e.key;if("string"!=typeof o)return!1;var f=i(o);if(t(f,l,h))return!0;for(var p=null,m=h;m<d;++m){var y=function(e,t,n,r,o,i){for(var a=Math.min(e.length,r.length),s=-1,l=0;l<a;++l){var u=t[l];if(u!==r[l])return 0>o(e[l],n[l])?e.substr(0,l)+n[l]+n.substr(l+1):0>o(e[l],r[l])?e.substr(0,l)+r[l]+n.substr(l+1):s>=0?e.substr(0,s)+t[s]+n.substr(s+1):null;0>o(e[l],u)&&(s=l)}return a<r.length&&"next"===i?e+n.substr(e.length):a<e.length&&"prev"===i?e.substr(0,n.length):s<0?null:e.substr(0,s)+r[s]+n.substr(s+1)}(o,f,s[m],l[m],a,u);null===y&&null===p?h=m+1:(null===p||a(p,y)>0)&&(p=y)}return n(null!==p?function(){e.continue(p+c)}:r),!1}),p}function ua(e,t,n,r){return{type:2,lower:e,upper:t,lowerOpen:n,upperOpen:r}}function us(e){return{type:1,lower:e,upper:e}}class ul{get Collection(){return this._ctx.table.db.Collection}between(e,t,n,r){n=!1!==n,r=!0===r;try{return this._cmp(e,t)>0||0===this._cmp(e,t)&&(n||r)&&(!n||!r)?uo(this):new this.Collection(this,()=>ua(e,t,!n,!r))}catch(e){return ur(this,lW)}}equals(e){return null==e?ur(this,lW):new this.Collection(this,()=>us(e))}above(e){return null==e?ur(this,lW):new this.Collection(this,()=>ua(e,void 0,!0))}aboveOrEqual(e){return null==e?ur(this,lW):new this.Collection(this,()=>ua(e,void 0,!1))}below(e){return null==e?ur(this,lW):new this.Collection(this,()=>ua(void 0,e,!1,!0))}belowOrEqual(e){return null==e?ur(this,lW):new this.Collection(this,()=>ua(void 0,e))}startsWith(e){return"string"!=typeof e?ur(this,"String expected."):this.between(e,e+lU,!0,!0)}startsWithIgnoreCase(e){return""===e?this.startsWith(e):ui(this,(e,t)=>0===e.indexOf(t[0]),[e],lU)}equalsIgnoreCase(e){return ui(this,(e,t)=>e===t[0],[e],"")}anyOfIgnoreCase(){var e=sD.apply(sE,arguments);return 0===e.length?uo(this):ui(this,(e,t)=>-1!==t.indexOf(e),e,"")}startsWithAnyOfIgnoreCase(){var e=sD.apply(sE,arguments);return 0===e.length?uo(this):ui(this,(e,t)=>t.some(t=>0===e.indexOf(t)),e,lU)}anyOf(){let e=sD.apply(sE,arguments),t=this._cmp;try{e.sort(t)}catch(e){return ur(this,lW)}if(0===e.length)return uo(this);let n=new this.Collection(this,()=>ua(e[0],e[e.length-1]));n._ondirectionchange=n=>{t="next"===n?this._ascending:this._descending,e.sort(t)};let r=0;return n._addAlgorithm((n,o,i)=>{let a=n.key;for(;t(a,e[r])>0;)if(++r===e.length)return o(i),!1;return 0===t(a,e[r])||(o(()=>{n.continue(e[r])}),!1)}),n}notEqual(e){return this.inAnyRange([[-1/0,e],[e,this.db._maxKey]],{includeLowers:!1,includeUppers:!1})}noneOf(){let e=sD.apply(sE,arguments);if(0===e.length)return new this.Collection(this);try{e.sort(this._ascending)}catch(e){return ur(this,lW)}let t=e.reduce((e,t)=>e?e.concat([[e[e.length-1][1],t]]):[[-1/0,t]],null);return t.push([e[e.length-1],this.db._maxKey]),this.inAnyRange(t,{includeLowers:!1,includeUppers:!1})}inAnyRange(e,t){let n=this._cmp,r=this._ascending,o=this._descending,i=this._min,a=this._max;if(0===e.length)return uo(this);if(!e.every(e=>void 0!==e[0]&&void 0!==e[1]&&0>=r(e[0],e[1])))return ur(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=r;function d(e,t){return c(e[0],t[0])}try{(u=e.reduce(function(e,t){let r=0,o=e.length;for(;r<o;++r){let o=e[r];if(0>n(t[0],o[1])&&n(t[1],o[0])>0){o[0]=i(o[0],t[0]),o[1]=a(o[1],t[1]);break}}return r===o&&e.push(t),e},[])).sort(d)}catch(e){return ur(this,lW)}let f=0,p=l?e=>r(e,u[f][1])>0:e=>r(e,u[f][1])>=0,h=s?e=>o(e,u[f][0])>0:e=>o(e,u[f][0])>=0,m=p,y=new this.Collection(this,()=>ua(u[0][0],u[u.length-1][1],!s,!l));return y._ondirectionchange=e=>{"next"===e?(m=p,c=r):(m=h,c=o),u.sort(d)},y._addAlgorithm((e,t,n)=>{for(var o=e.key;m(o);)if(++f===u.length)return t(n),!1;return!!(!p(o)&&!h(o))||(0===this._cmp(o,u[f][1])||0===this._cmp(o,u[f][0])||t(()=>{c===r?e.continue(u[f][0]):e.continue(u[f][1])}),!1)}),y}startsWithAnyOf(){let e=sD.apply(sE,arguments);return e.every(e=>"string"==typeof e)?0===e.length?uo(this):this.inAnyRange(e.map(e=>[e,e+lU])):ur(this,"startsWithAnyOf() only works with strings")}}function uu(e){return lx(function(t){return uc(t),e(t.target.error),!1})}function uc(e){e.stopPropagation&&e.stopPropagation(),e.preventDefault&&e.preventDefault()}let ud=lJ(null,"storagemutated");class uf{_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{l$(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,n=this.db._state.dbOpenError;if(sl(!this.idbtrans),!e&&!t)switch(n&&n.name){case"DatabaseClosedError":throw new sB.DatabaseClosed(n);case"MissingAPIError":throw new sB.MissingAPI(n.message,n);default:throw new sB.OpenFailed(n)}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=>{uc(t),this._reject(e.error)}),e.onabort=lx(t=>{uc(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&&ud.storagemutated.fire(e.mutatedParts)}),this}_promise(e,t,n){if("readwrite"===e&&"readwrite"!==this.mode)return lV(new sB.ReadOnly("Transaction is readonly"));if(!this.active)return lV(new sB.TransactionInactive);if(this._locked())return new lu((r,o)=>{this._blockedFuncs.push([()=>{this._promise(e,t,n).then(r,o)},li])});if(n)return lC(()=>{var e=new lu((e,n)=>{this._lock();let r=t(e,n,this);r&&r.then&&r.then(e,n)});return e.finally(()=>this._unlock()),e._lib=!0,e});var r=new lu((e,n)=>{var r=t(e,n,this);r&&r.then&&r.then(e,n)});return r._lib=!0,r}_root(){return this.parent?this.parent._root():this}waitFor(e){var t=this._root();let n=lu.resolve(e);if(t._waitingFor)t._waitingFor=t._waitingFor.then(()=>n);else{t._waitingFor=n,t._waitingQueue=[];var r=t.idbtrans.objectStore(t.storeNames[0]);!function e(){for(++t._spinCount;t._waitingQueue.length;)t._waitingQueue.shift()();t._waitingFor&&(r.get(-1/0).onsuccess=e)}()}var o=t._waitingFor;return new lu((e,r)=>{n.then(n=>t._waitingQueue.push(lx(e.bind(null,n))),e=>t._waitingQueue.push(lx(r.bind(null,e)))).finally(()=>{t._waitingFor===o&&(t._waitingFor=null)})})}abort(){this.active&&(this.active=!1,this.idbtrans&&this.idbtrans.abort(),this._reject(new sB.Abort))}table(e){let t=this._memoizedTables||(this._memoizedTables={});if(a9(t,e))return t[e];let n=this.schema[e];if(!n)throw new sB.NotFound("Table "+e+" not part of transaction");let r=new this.db.Table(e,n,this);return r.core=this.db.core.table(e),t[e]=r,r}}function up(e,t,n,r,o,i,a){return{name:e,keyPath:t,unique:n,multi:r,auto:o,compound:i,src:(n&&!a?"&":"")+(r?"*":"")+(o?"++":"")+uh(t)}}function uh(e){return"string"==typeof e?e:e?"["+[].join.call(e,"+")+"]":""}function um(e,t,n){return{name:e,primKey:t,indexes:n,mappedClass:null,idxByName:sc(n,e=>[e.name,e])}}let uy=e=>{try{return e.only([[]]),uy=()=>[[]],[[]]}catch(e){return uy=()=>lU,lU}};function ug(e){return null==e?()=>{}:"string"==typeof e?1===e.split(".").length?t=>t[e]:t=>sd(t,e):t=>sd(t,e)}function ub(e){return[].slice.call(e)}let uv=0;function uw(e){return null==e?":id":"string"==typeof e?e:`[${e.join("+")}]`}function u_({_novip:e},t){let n=t.db,r=function(e,t,{IDBKeyRange:n,indexedDB:r},o){var i;return{dbcore:(i=function(e,t,n){let r;function o(e){if(3===e.type)return null;if(4===e.type)throw Error("Cannot convert never type to IDBKeyRange");let{lower:n,upper:r,lowerOpen:o,upperOpen:i}=e;return void 0===n?void 0===r?null:t.upperBound(r,!!i):void 0===r?t.lowerBound(n,!!o):t.bound(n,r,!!o,!!i)}let{schema:i,hasGetAll:a}=(r=ub(e.objectStoreNames),{schema:{name:e.name,tables:r.map(e=>n.objectStore(e)).map(e=>{let{keyPath:t,autoIncrement:n}=e,r=a3(t),o=null==t,i={},a={name:e.name,primaryKey:{name:null,isPrimaryKey:!0,outbound:o,compound:r,keyPath:t,autoIncrement:n,unique:!0,extractKey:ug(t)},indexes:ub(e.indexNames).map(t=>e.index(t)).map(e=>{let{name:t,unique:n,multiEntry:r,keyPath:o}=e,a={name:t,compound:a3(o),keyPath:o,unique:n,multiEntry:r,extractKey:ug(o)};return i[uw(o)]=a,a}),getIndexByKeyPath:e=>i[uw(e)]};return i[":id"]=a.primaryKey,null!=t&&(i[uw(t)]=a.primaryKey),a})},hasGetAll:r.length>0&&"getAll"in n.objectStore(r[0])&&!("u">typeof navigator&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604)}),s=i.tables.map(e=>{let t;return{name:t=e.name,schema:e,mutate:function({trans:e,type:n,keys:r,values:i,range:a}){return new Promise((s,l)=>{let u;s=lx(s);let c=e.objectStore(t),d=null==c.keyPath,f="put"===n||"add"===n;if(!f&&"delete"!==n&&"deleteRange"!==n)throw Error("Invalid operation type: "+n);let{length:p}=r||i||{length:1};if(r&&i&&r.length!==i.length)throw Error("Given keys array must have same length as given values array.");if(0===p)return s({numFailures:0,failures:{},results:[],lastResult:void 0});let h=[],m=[],y=0,g=e=>{++y,uc(e)};if("deleteRange"===n){if(4===a.type)return s({numFailures:y,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]=f?d?[i,r]:[i,null]:[r,null];if(f)for(let r=0;r<p;++r)h.push(u=t&&void 0!==t[r]?c[n](e[r],t[r]):c[n](e[r])),u.onerror=g;else for(let t=0;t<p;++t)h.push(u=c[n](e[t])),u.onerror=g}let b=e=>{let t=e.target.result;h.forEach((e,t)=>null!=e.error&&(m[t]=e.error)),s({numFailures:y,failures:m,results:"delete"===n?r:h.map(e=>e.result),lastResult:t})};u.onerror=e=>{g(e),b(e)},u.onsuccess=b})},getMany:({trans:e,keys:n})=>new Promise((r,o)=>{r=lx(r);let i=e.objectStore(t),a=n.length,s=Array(a),l,u=0,c=0,d=e=>{let t=e.target;s[t._pos]=t.result,++c===u&&r(s)},f=uu(o);for(let e=0;e<a;++e)null!=n[e]&&((l=i.get(n[e]))._pos=e,l.onsuccess=d,l.onerror=f,++u);0===u&&r(s)}),get:({trans:e,key:n})=>new Promise((r,o)=>{r=lx(r);let i=e.objectStore(t).get(n);i.onsuccess=e=>r(e.target.result),i.onerror=uu(o)}),query:e=>new Promise((n,r)=>{n=lx(n);let{trans:i,values:s,limit:l,query:u}=e,c=l===1/0?void 0:l,{index:d,range:f}=u,p=i.objectStore(t),h=d.isPrimaryKey?p:p.index(d.name),m=o(f);if(0===l)return n({result:[]});if(a){let e=s?h.getAll(m,c):h.getAllKeys(m,c);e.onsuccess=e=>n({result:e.target.result}),e.onerror=uu(r)}else{let e=0,t=!s&&"openKeyCursor"in h?h.openKeyCursor(m):h.openCursor(m),o=[];t.onsuccess=r=>{let i=t.result;return i?(o.push(s?i.value:i.primaryKey),++e===l?n({result:o}):void i.continue()):n({result:o})},t.onerror=uu(r)}}),openCursor:function({trans:e,values:n,query:r,reverse:i,unique:a}){return new Promise((s,l)=>{s=lx(s);let{index:u,range:c}=r,d=e.objectStore(t),f=u.isPrimaryKey?d:d.index(u.name),p=i?a?"prevunique":"prev":a?"nextunique":"next",h=!n&&"openKeyCursor"in f?f.openKeyCursor(o(c),p):f.openCursor(o(c),p);h.onerror=uu(l),h.onsuccess=lx(t=>{let n=h.result;if(!n)return void s(null);n.___id=++uv,n.done=!1;let r=n.continue.bind(n),o=n.continuePrimaryKey;o&&(o=o.bind(n));let i=n.advance.bind(n),a=()=>{throw Error("Cursor not stopped")};n.trans=e,n.stop=n.continue=n.continuePrimaryKey=n.advance=()=>{throw Error("Cursor not started")},n.fail=lx(l),n.next=function(){let e=1;return this.start(()=>e--?this.continue():this.stop()).then(()=>this)},n.start=e=>{let t=new Promise((e,t)=>{e=lx(e),h.onerror=uu(t),n.fail=t,n.stop=t=>{n.stop=n.continue=n.continuePrimaryKey=n.advance=a,e(t)}}),s=()=>{if(h.result)try{e()}catch(e){n.fail(e)}else n.done=!0,n.start=()=>{throw Error("Cursor behind last entry")},n.stop()};return h.onsuccess=lx(e=>{h.onsuccess=s,s()}),n.continue=r,n.continuePrimaryKey=o,n.advance=i,s(),t},s(n)},l)})},count({query:e,trans:n}){let{index:r,range:i}=e;return new Promise((e,a)=>{let s=n.objectStore(t),l=r.isPrimaryKey?s:s.index(r.name),u=o(i),c=u?l.count(u):l.count();c.onsuccess=lx(t=>e(t.target.result)),c.onerror=uu(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:uy(t),schema:i}}(t,n,o),e.dbcore.reduce((e,{create:t})=>({...e,...t(e)}),i))}}(e._middlewares,n,e._deps,t);e.core=r.dbcore,e.tables.forEach(t=>{let n=t.name;e.core.schema.tables.some(e=>e.name===n)&&(t.core=e.core.table(n),e[n]instanceof e.Table&&(e[n].core=t.core))})}function ux({_novip:e},t,n,r){n.forEach(n=>{let o=r[n];t.forEach(t=>{let r=so(t,n);(!r||"value"in r&&void 0===r.value)&&(t===e.Transaction.prototype||t instanceof e.Transaction?st(t,n,{get(){return this.table(n)},set(e){se(this,n,{value:e,writable:!0,configurable:!0,enumerable:!0})}}):t[n]=new e.Table(n,o))})})}function uS({_novip:e},t){t.forEach(t=>{for(let n in t)t[n]instanceof e.Table&&delete t[n]})}function uE(e,t){return e._cfg.version-t._cfg.version}function uD(e,t){let n,r={del:[],add:[],change:[]};for(n in e)t[n]||r.del.push(n);for(n in t){let o=e[n],i=t[n];if(o){let e={name:n,def:i,recreate:!1,del:[],add:[],change:[]};if(""+(o.primKey.keyPath||"")==""+(i.primKey.keyPath||"")&&(o.primKey.auto===i.primKey.auto||lz)){let t,n=o.idxByName,a=i.idxByName;for(t in n)a[t]||e.del.push(t);for(t in a){let r=n[t],o=a[t];r?r.src!==o.src&&e.change.push(o):e.add.push(o)}(e.del.length>0||e.add.length>0||e.change.length>0)&&r.change.push(e)}else e.recreate=!0,r.change.push(e)}else r.add.push([n,i])}return r}function uO(e,t,n,r){let o=e.db.createObjectStore(t,n.keyPath?{keyPath:n.keyPath,autoIncrement:n.auto}:{autoIncrement:n.auto});return r.forEach(e=>uk(o,e)),o}function uk(e,t){e.createIndex(t.name,t.keyPath,{unique:t.unique,multiEntry:t.multi})}function uP(e,t,n){let r={};return sa(t.objectStoreNames,0).forEach(e=>{let t=n.objectStore(e),o=t.keyPath,i=up(uh(o),o||"",!1,!1,!!t.autoIncrement,o&&"string"!=typeof o,!0),a=[];for(let e=0;e<t.indexNames.length;++e){let n=t.index(t.indexNames[e]);o=n.keyPath;var s=up(n.name,o,!!n.unique,!!n.multiEntry,!1,o&&"string"!=typeof o,!1);a.push(s)}r[e]=um(e,i,a)}),r}function uC({_novip:e},t,n){let r=n.db.objectStoreNames;for(let o=0;o<r.length;++o){let i=r[o],a=n.objectStore(i);e._hasGetAll="getAll"in a;for(let e=0;e<a.indexNames.length;++e){let n=a.indexNames[e],r=a.index(n).keyPath,o="string"==typeof r?r:"["+sa(r).join("+")+"]";if(t[i]){let e=t[i].idxByName[o];e&&(e.name=n,delete t[i].idxByName[o],t[i].idxByName[n]=e)}}}"u">typeof navigator&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&a2.WorkerGlobalScope&&a2 instanceof a2.WorkerGlobalScope&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604&&(e._hasGetAll=!1)}class uj{_parseStoresSpec(e,t){a4(e).forEach(n=>{if(null!==e[n]){var r=e[n].split(",").map((e,t)=>{let n=(e=e.trim()).replace(/([&*]|\+\+)/g,""),r=/^\[/.test(n)?n.match(/^\[(.*)\]$/)[1].split("+"):n;return up(n,r||null,/\&/.test(e),/\*/.test(e),/\+\+/.test(e),a3(r),0===t)}),o=r.shift();if(o.multi)throw new sB.Schema("Primary key cannot be multi-valued");r.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[n]=um(n,o,r)}})}stores(e){let t=this.db;this._cfg.storesSource=this._cfg.storesSource?a6(this._cfg.storesSource,e):e;let n=t._versions,r={},o={};return n.forEach(e=>{a6(r,e._cfg.storesSource),o=e._cfg.dbschema={},e._parseStoresSpec(r,o)}),t._dbSchema=o,uS(t,[t._allTables,t,t.Transaction.prototype]),ux(t,[t._allTables,t,t.Transaction.prototype,this._cfg.tables],a4(o),o),t._storeNames=a4(o),this}upgrade(e){return this._cfg.contentUpgrade=sJ(this._cfg.contentUpgrade||sW,e),this}}function uT(e,t){let n=e._dbNamesDB;return n||(n=e._dbNamesDB=new uY("__dbnames",{addons:[],indexedDB:e,IDBKeyRange:t})).version(1).stores({dbnames:"name"}),n.table("dbnames")}function uR(e){return e&&"function"==typeof e.databases}function uA(e){return lC(function(){return li.letThrough=!0,e()})}function uN(e){var t=t=>e.next(t),n=o(t),r=o(t=>e.throw(t));function o(e){return t=>{var o=e(t),i=o.value;return o.done?i:i&&"function"==typeof i.then?i.then(n,r):a3(i)?Promise.all(i).then(n,r):n(i)}}return o(t)()}function uM(e,t,n){var r=arguments.length;if(r<2)throw new sB.InvalidArgument("Too few arguments");for(var o=Array(r-1);--r;)o[r-1]=arguments[r];return n=o.pop(),[e,sm(o),n]}function uI(e,t,n){let r=a3(e)?e.slice():[e];for(let e=0;e<n;++e)r.push(t);return r}let u$={stack:"dbcore",name:"VirtualIndexMiddleware",level:1,create:function(e){return{...e,table(t){let n=e.table(t),{schema:r}=n,o={},i=[];function a(e,t,n){let r=uw(e),s=o[r]=o[r]||[],l=null==e?0:"string"==typeof e?1:e.length,u=t>0,c={...n,isVirtual:u,keyTail:t,keyLength:l,extractKey:ug(e),unique:!u&&n.unique};return s.push(c),c.isPrimaryKey||i.push(c),l>1&&a(2===l?e[0]:e.slice(0,l-1),t+1,n),s.sort((e,t)=>e.keyTail-t.keyTail),c}let s=a(r.primaryKey.keyPath,0,r.primaryKey);for(let e of(o[":id"]=[s],r.indexes))a(e.keyPath,0,e);function l(t){var n,r;let o=t.query.index;return o.isVirtual?{...t,query:{index:o,range:(n=t.query.range,r=o.keyTail,{type:1===n.type?2:n.type,lower:uI(n.lower,n.lowerOpen?e.MAX_KEY:e.MIN_KEY,r),lowerOpen:!0,upper:uI(n.upper,n.upperOpen?e.MIN_KEY:e.MAX_KEY,r),upperOpen:!0})}}:t}return{...n,schema:{...r,primaryKey:s,indexes:i,getIndexByKeyPath:function(e){let t=o[uw(e)];return t&&t[0]}},count:e=>n.count(l(e)),query:e=>n.query(l(e)),openCursor(t){let{keyTail:r,isVirtual:o,keyLength:i}=t.query.index;return o?n.openCursor(l(t)).then(n=>n&&Object.create(n,{continue:{value:function(o){null!=o?n.continue(uI(o,t.reverse?e.MAX_KEY:e.MIN_KEY,r)):t.unique?n.continue(n.key.slice(0,i).concat(t.reverse?e.MIN_KEY:e.MAX_KEY,r)):n.continue()}},continuePrimaryKey:{value(t,o){n.continuePrimaryKey(uI(t,e.MAX_KEY,r),o)}},primaryKey:{get:()=>n.primaryKey},key:{get(){let e=n.key;return 1===i?e[0]:e.slice(0,i)}},value:{get:()=>n.value}})):n.openCursor(t)}}}}}};function uL(e,t,n,r){return n=n||{},r=r||"",a4(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)?n[r+o]=t[o]:"Object"===e?uL(i,a,n,r+o+"."):i!==a&&(n[r+o]=t[o])}else i!==a&&(n[r+o]=t[o])}else n[r+o]=void 0}),a4(t).forEach(o=>{a9(e,o)||(n[r+o]=t[o])}),n}let uF={stack:"dbcore",name:"HooksMiddleware",level:2,create:e=>({...e,table(t){let n=e.table(t),{primaryKey:r}=n.schema;return{...n,mutate(e){let o=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 n.query({trans:t,values:!1,query:{index:r,range:o},limit:i}).then(({result:n})=>l({type:"delete",keys:n,trans:t}).then(r=>r.numFailures>0?Promise.reject(r.failures[0]):n.length<i?{failures:[],numFailures:0,lastResult:void 0}:e(t,{...o,lower:n[n.length-1],lowerOpen:!0},i)))})(e.trans,e.range,1e4),!0)}return n.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(r.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([]):n.getMany({trans:o.trans,keys:u,cache:"immutable"})).then(t=>{let o=u.map((n,o)=>{let u=t[o],c={onerror:null,onsuccess:null};if("delete"===e.type)i.fire.call(c,n,u,l);else if("add"===e.type||void 0===u){let t=a.fire.call(c,n,e.values[o],l);null==n&&null!=t&&(n=t,e.keys[o]=n,r.outbound||sf(e.values[o],r.keyPath,n))}else{let t=uL(u,e.values[o]),r=s.fire.call(c,t,n,u,l);if(r){let t=e.values[o];Object.keys(r).forEach(e=>{a9(t,e)?t[e]=r[e]:sf(t,e,r[e])})}}return c});return n.mutate(e).then(({failures:n,results:r,numFailures:i,lastResult:a})=>{for(let i=0;i<u.length;++i){let a=r?r[i]:u[i],s=o[i];null==a?s.onerror&&s.onerror(n[i]):s.onsuccess&&s.onsuccess("put"===e.type&&t[i]?e.values[i]:a)}return{failures:n,results:r,numFailures:i,lastResult:a}}).catch(e=>(o.forEach(t=>t.onerror&&t.onerror(e)),Promise.reject(e)))})}}}}})};function uB(e,t,n){try{if(!t||t.keys.length<e.length)return null;let r=[];for(let o=0,i=0;o<t.keys.length&&i<e.length;++o)0===l5(t.keys[o],e[i])&&(r.push(n?sv(t.values[o]):t.values[o]),++i);return r.length===e.length?r:null}catch(e){return null}}let uV={stack:"dbcore",level:-1,create:e=>({table:t=>{let n=e.table(t);return{...n,getMany:e=>{if(!e.cache)return n.getMany(e);let t=uB(e.keys,e.trans._cache,"clone"===e.cache);return t?lu.resolve(t):n.getMany(e).then(t=>(e.trans._cache={keys:e.keys,values:"clone"===e.cache?sv(t):t},t))},mutate:e=>("add"!==e.type&&(e.trans._cache=null),n.mutate(e))}}})};function uU(e){return!("from"in e)}let uW=function(e,t){if(!this){let t=new uW;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 uK(e,t,n){let r=l5(t,n);if(isNaN(r))return;if(r>0)throw RangeError();if(uU(e))return a6(e,{from:t,to:n,d:1});let o=e.l,i=e.r;if(0>l5(n,e.from))return o?uK(o,t,n):e.l={from:t,to:n,d:1,l:null,r:null},uG(e);if(l5(t,e.to)>0)return i?uK(i,t,n):e.r={from:t,to:n,d:1,l:null,r:null},uG(e);0>l5(t,e.from)&&(e.from=t,e.l=null,e.d=i?i.d+1:1),l5(n,e.to)>0&&(e.to=n,e.r=null,e.d=e.l?e.l.d+1:1);let a=!e.r;o&&!e.l&&uz(e,o),i&&a&&uz(e,i)}function uz(e,t){uU(t)||function e(t,{from:n,to:r,l:o,r:i}){uK(t,n,r),o&&e(t,o),i&&e(t,i)}(e,t)}function uH(e){let t=uU(e)?null:{s:0,n:e};return{next(e){let n=arguments.length>0;for(;t;)switch(t.s){case 0:if(t.s=1,n)for(;t.n.l&&0>l5(e,t.n.from);)t={up:t,n:t.n.l,s:1};else for(;t.n.l;)t={up:t,n:t.n.l,s:1};case 1:if(t.s=2,!n||0>=l5(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 uG(e){var t,n;let r=((null==(t=e.r)?void 0:t.d)||0)-((null==(n=e.l)?void 0:n.d)||0),o=r>1?"r":r<-1?"l":"";if(o){let t="r"===o?"l":"r",n={...e},r=e[o];e.from=r.from,e.to=r.to,e[o]=r[o],n[o]=r[t],e[t]=n,n.d=uq(n)}e.d=uq(e)}function uq({r:e,l:t}){return(e?t?Math.max(e.d,t.d):e.d:t?t.d:0)+1}a8(uW.prototype,{add(e){return uz(this,e),this},addKey(e){return uK(this,e,e),this},addKeys(e){return e.forEach(e=>uK(this,e,e)),this},[sx](){return uH(this)}});let uZ={stack:"dbcore",level:0,create:e=>{let t=e.schema.name,n=new uW(e.MIN_KEY,e.MAX_KEY);return{...e,table:r=>{let o=e.table(r),{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 n=`idb://${t}/${r}/${e}`;return s[n]||(s[n]=new uW)},u=l(""),c=l(":dels"),{type:d}=e,[f,p]="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(a3(f)){"delete"!==d&&(f=e.results),u.addKeys(f);let t=uB(f,h);t||"add"===d||c.addKeys(f),(t||p)&&i.indexes.forEach(function(e){let n=l(e.name||"");function r(t){return null!=t?e.extractKey(t):null}let o=t=>e.multiEntry&&a3(t)?t.forEach(e=>n.addKey(e)):n.addKey(t);(t||p).forEach((e,n)=>{let i=t&&r(t[n]),a=p&&r(p[n]);0!==l5(i,a)&&(null!=i&&o(i),null!=a&&o(a))})})}else if(f){let e={from:f.lower,to:f.upper};c.add(e),u.add(e)}else u.add(n),c.add(n),i.indexes.forEach(e=>l(e.name).add(n));return e})}},c=({query:{index:t,range:n}})=>{var r,o;return[t,new uW(null!=(r=n.lower)?r:e.MIN_KEY,null!=(o=n.upper)?o:e.MAX_KEY)]},d={get:e=>[a,new uW(e.key)],getMany:e=>[a,(new uW).addKeys(e.keys)],count:c,query:c,openCursor:c};return a4(d).forEach(e=>{u[e]=function(i){let{subscr:a}=li;if(a){let u=e=>{let n=`idb://${t}/${r}/${e}`;return a[n]||(a[n]=new uW)},c=u(""),f=u(":dels"),[p,h]=d[e](i);if(u(p.name||"").add(h),!p.isPrimaryKey){if("count"!==e){let t="query"===e&&l&&i.values&&o.query({...i,values:!1});return o[e].apply(this,arguments).then(n=>{if("query"===e){if(l&&i.values)return t.then(({result:e})=>(c.addKeys(e),n));let e=i.values?n.result.map(s):n.result;i.values?c.addKeys(e):f.addKeys(e)}else if("openCursor"===e){let e=i.values;return n&&Object.create(n,{key:{get:()=>(f.addKey(n.primaryKey),n.key)},primaryKey:{get(){let e=n.primaryKey;return f.addKey(e),e}},value:{get:()=>(e&&c.addKey(n.primaryKey),n.value)}})}return n})}f.add(n)}}return o[e].apply(this,arguments)}}),u}}}};class uY{constructor(e,t){var n;this._middlewares={},this.verno=0;const r=uY.dependencies;this._options=t={addons:uY.addons,autoOpen:!0,indexedDB:r.indexedDB,IDBKeyRange:r.IDBKeyRange,...t},this._deps={indexedDB:t.indexedDB,IDBKeyRange:t.IDBKeyRange};const{addons:o}=t;this._dbSchema={},this._versions=[],this._storeNames=[],this._allTables={},this.idbdb=null,this._novip=this;const 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=lJ(this,"populate","blocked","versionchange","close",{ready:[sJ,sW]}),this.on.ready.subscribe=ss(this.on.ready.subscribe,e=>(t,n)=>{uY.vip(()=>{let r=this._state;if(r.openComplete)r.dbOpenError||lu.resolve().then(t),n&&e(t);else if(r.onReadyBeingFired)r.onReadyBeingFired.push(t),n&&e(t);else{e(t);let r=this;n||e(function e(){r.on.ready.unsubscribe(t),r.on.ready.unsubscribe(e)})}})}),this.Collection=(n=this,lQ(l8.prototype,function(e,t){this.db=n;let r=lq,o=null;if(t)try{r=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:r,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 lQ(lY.prototype,function(t,n,r){this.db=e,this._tx=r,this.name=t,this.schema=n,this.hook=e._allTables[t]?e._allTables[t].hook:lJ(null,{creating:[sG,sW],reading:[sz,sK],updating:[sZ,sW],deleting:[sq,sW]})})}(this),this.Transaction=function(e){return lQ(uf.prototype,function(t,n,r,o,i){this.db=e,this.mode=t,this.storeNames=n,this.schema=r,this.chromeTransactionDurability=o,this.idbtrans=null,this.on=lJ(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(),lV(e)})})}(this),this.Version=function(e){return lQ(uj.prototype,function(t){this.db=e,this._cfg={version:t,storesSource:null,dbschema:{},tables:{},contentUpgrade:null}})}(this),this.WhereClause=function(e){return lQ(ul.prototype,function(t,n,r){this.db=e,this._ctx={table:t,index:":id"===n?null:n,or:r};let o=e._deps.indexedDB;if(!o)throw new 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=uy(t.IDBKeyRange),this._createTransaction=(e,t,n,r)=>new this.Transaction(e,t,n,this._options.chromeTransactionDurability,r),this._fireOnBlocked=e=>{this.on("blocked").fire(e),lK.filter(e=>e.name===this.name&&e!==this&&!e._state.vcFired).map(t=>t.on("versionchange").fire(e))},this.use(u$),this.use(uF),this.use(uZ),this.use(uV),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 n=t.filter(t=>t._cfg.version===e)[0];return n||(n=new this.Version(e),t.push(n),t.sort(uE),n.stores({}),this._state.autoSchema=!1,n)}_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:n,name:r}){r&&this.unuse({stack:e,name:r});let o=this._middlewares[e]||(this._middlewares[e]=[]);return o.push({stack:e,create:t,level:null==n?10:n,name:r}),o.sort((e,t)=>e.level-t.level),this}unuse({stack:e,name:t,create:n}){return e&&this._middlewares[e]&&(this._middlewares[e]=this._middlewares[e].filter(e=>n?e.create!==n:!!t&&e.name!==t)),this}open(){return function(e){var t;let n=e._state,{indexedDB:r}=e._deps;if(n.isBeingOpened||e.idbdb)return n.dbReadyPromise.then(()=>n.dbOpenError?lV(n.dbOpenError):e);sk&&(n.openCanceller._stackHolder=sj()),n.isBeingOpened=!0,n.dbOpenError=null,n.openComplete=!1;let o=n.openCanceller;function i(){if(n.openCanceller!==o)throw new sB.DatabaseClosed("db.open() was cancelled")}let a=n.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 n=function(){return indexedDB.databases().finally(e)};t=setInterval(n,100),n()}).finally(function(){return clearInterval(t)}):Promise.resolve()).then(()=>new lu((t,o)=>{if(i(),!r)throw new sB.MissingAPI;let a=e.name,u=n.autoSchema?r.open(a):r.open(a,Math.round(10*e.verno));if(!u)throw new sB.MissingAPI;u.onerror=uu(o),u.onblocked=lx(e._fireOnBlocked),u.onupgradeneeded=lx(t=>{if(s=u.transaction,n.autoSchema&&!e._options.allowEmptyDB){u.onerror=uc,s.abort(),u.result.close();let e=r.deleteDatabase(a);e.onsuccess=e.onerror=lx(()=>{o(new sB.NoSuchDatabase(`Database ${a} doesnt exist`))})}else{let n,r,a,f;s.onerror=uu(o);var i,c,d=t.oldVersion>0x4000000000000000?0:t.oldVersion;l=d<1,e._novip.idbdb=u.result,i=d/10,c=s,n=e._dbSchema,(r=e._createTransaction("readwrite",e._storeNames,n)).create(c),r._completion.catch(o),a=r._reject.bind(r),f=li.transless||li,lC(()=>{li.trans=r,li.transless=f,0===i?(a4(n).forEach(e=>{uO(c,e,n[e].primKey,n[e].indexes)}),u_(e,c),lu.follow(()=>e.on.populate.fire(r)).catch(a)):(function({_novip:e},t,n,r){let o=[],i=e._versions,a=e._dbSchema=uP(e,e.idbdb,r),s=!1;return i.filter(e=>e._cfg.version>=t).forEach(i=>{o.push(()=>{let o=a,l=i._cfg.dbschema;uC(e,o,r),uC(e,l,r),a=e._dbSchema=l;let u=uD(o,l);u.add.forEach(e=>{uO(r,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=r.objectStore(e.name);e.add.forEach(e=>uk(t,e)),e.change.forEach(e=>{t.deleteIndex(e.name),uk(t,e)}),e.del.forEach(e=>t.deleteIndex(e))}});let c=i._cfg.contentUpgrade;if(c&&i._cfg.version>t){let t;u_(e,r),n._memoizedTables={},s=!0;let i=sp(l);u.del.forEach(e=>{i[e]=o[e]}),uS(e,[e.Transaction.prototype]),ux(e,[e.Transaction.prototype],a4(i),i),n.schema=i;let a=sO(c);a&&lj();let d=lu.follow(()=>{if((t=c(n))&&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 r;s&&lz||(r=i._cfg.dbschema,[].slice.call(t.db.objectStoreNames).forEach(e=>null==r[e]&&t.db.deleteObjectStore(e))),uS(e,[e.Transaction.prototype]),ux(e,[e.Transaction.prototype],e._storeNames,e._dbSchema),n.schema=e._dbSchema})}),(function e(){return o.length?lu.resolve(o.shift()(n.idbtrans)).then(e):lu.resolve()})().then(()=>{var e;a4(e=a).forEach(t=>{r.db.objectStoreNames.contains(t)||uO(r,t,e[t].primKey,e[t].indexes)})})})(e,i,r,c).catch(a)})}},o),u.onsuccess=lx(()=>{s=null;let r=e._novip.idbdb=u.result,o=sa(r.objectStoreNames);if(o.length>0)try{let t,i=r.transaction(1===o.length?o[0]:o,"readonly");n.autoSchema?function({_novip:e},t,n){e.verno=t.version/10;let r=e._dbSchema=uP(0,t,n);e._storeNames=sa(t.objectStoreNames,0),ux(e,[e._allTables],a4(r),r)}(e,r,i):(uC(e,e._dbSchema,i),((t=uD(uP(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.")),u_(e,i)}catch(e){}lK.push(e),r.onversionchange=lx(t=>{n.vcFired=!0,e.on("versionchange").fire(t)}),r.onclose=lx(t=>{e.on("close").fire(t)}),l&&function({indexedDB:e,IDBKeyRange:t},n){uR(e)||"__dbnames"===n||uT(e,t).put({name:n}).catch(sW)}(e._deps,a),t()},o)}))]).then(()=>(i(),n.onReadyBeingFired=[],lu.resolve(uA(()=>e.on.ready.fire(e.vip))).then(function t(){if(n.onReadyBeingFired.length>0){let r=n.onReadyBeingFired.reduce(sJ,sW);return n.onReadyBeingFired=[],lu.resolve(uA(()=>r(e.vip))).then(t)}}))).finally(()=>{n.onReadyBeingFired=null,n.isBeingOpened=!1}).then(()=>e).catch(t=>{n.dbOpenError=t;try{s&&s.abort()}catch(e){}return o===n.openCanceller&&e._close(),lV(t)}).finally(()=>{n.openComplete=!0,a()})}(this)}_close(){let e=this._state,t=lK.indexOf(this);if(t>=0&&lK.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,n)=>{e.cancelOpen=n})}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((n,r)=>{let o=()=>{this.close();var e=this._deps.indexedDB.deleteDatabase(this.name);e.onsuccess=lx(()=>{!function({indexedDB:e,IDBKeyRange:t},n){uR(e)||"__dbnames"===n||uT(e,t).delete(n).catch(sW)}(this._deps,this.name),n()}),e.onerror=uu(r),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 a4(this._allTables).map(e=>this._allTables[e])}transaction(){let e=uM.apply(this,arguments);return this._transaction.apply(this,e)}_transaction(e,t,n){let r,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||"readonly"===e)r="readonly";else{if("rw"!=e&&"readwrite"!=e)throw new sB.InvalidArgument("Invalid transaction mode: "+e);r="readwrite"}if(i){if("readonly"===i.mode&&"readwrite"===r){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,n)=>{n(e)}):lV(e)}let s=(function e(t,n,r,o,i){return lu.resolve().then(()=>{let a,s=li.transless||li,l=t._createTransaction(n,r,t._dbSchema,o);if(o)l.idbtrans=o.idbtrans;else try{l.create(),t._state.PR1398_maxLoop=3}catch(o){return o.name===sF.InvalidState&&t.isOpen()&&--t._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),t._close(),t.open().then(()=>e(t,n,r,null,i))):lV(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=uN(a))},{trans:l,transless:s});return(a&&"function"==typeof a.then?lu.resolve(a).then(e=>l.active?e:lV(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),lV(e)))})}).bind(null,this,r,o,i,n);return i?i._promise(r,s,"lock"):li.trans?l$(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 uJ="u">typeof Symbol&&"observable"in Symbol?Symbol.observable:"@@observable";class uQ{constructor(e){this._subscribe=e}subscribe(e,t,n){return this._subscribe(e&&"function"!=typeof e?e:{next:e,error:t,complete:n})}[uJ](){return this}}function uX(e,t){return a4(t).forEach(n=>{uz(e[n]||(e[n]=new uW),t[n])}),e}try{i={indexedDB:a2.indexedDB||a2.mozIndexedDB||a2.webkitIndexedDB||a2.msIndexedDB,IDBKeyRange:a2.IDBKeyRange||a2.webkitIDBKeyRange}}catch(e){i={indexedDB:null,IDBKeyRange:null}}function u0(e){let t=u1;try{u1=!0,ud.storagemutated.fire(e)}finally{u1=t}}a8(uY,{...sU,delete:e=>new uY(e,{addons:[]}).delete(),exists:e=>new uY(e,{addons:[]}).open().then(e=>(e.close(),!0)).catch("NoSuchDatabaseError",()=>!1),getDatabaseNames(e){try{return(function({indexedDB:e,IDBKeyRange:t}){return uR(e)?Promise.resolve(e.databases()).then(e=>e.map(e=>e.name).filter(e=>"__dbnames"!==e)):uT(e,t).toCollection().primaryKeys()})(uY.dependencies).then(e)}catch(e){return lV(new sB.MissingAPI)}},defineClass:()=>function(e){a6(this,e)},ignoreTransaction:e=>li.trans?l$(li.transless,e):e(),vip:uA,async:function(e){return function(){try{var t=uN(e.apply(this,arguments));return t&&"function"==typeof t.then?t:lu.resolve(t)}catch(e){return lV(e)}}},spawn:function(e,t,n){try{var r=uN(e.apply(n,t||[]));return r&&"function"==typeof r.then?r:lu.resolve(r)}catch(e){return lV(e)}},currentTransaction:{get:()=>li.trans||null},waitFor:function(e,t){let n=lu.resolve("function"==typeof e?uY.ignoreTransaction(e):e).timeout(t||6e4);return li.trans?li.trans.waitFor(n):n},Promise:lu,debug:{get:()=>sk,set:e=>{sk=e,sP="dexie"===e?()=>!0:lH}},derive:sn,extend:a6,props:a8,override:ss,Events:lJ,on:ud,liveQuery:function(e){return new uQ(t=>{let n=sO(e),r=!1,o={},i={},a={get closed(){return r},unsubscribe:()=>{r=!0,ud.storagemutated.unsubscribe(c)}};t.start&&t.start(a);let s=!1,l=!1;function u(){return a4(i).some(e=>o[e]&&function(e,t){let n=uH(t),r=n.next();if(r.done)return!1;let o=r.value,i=uH(e),a=i.next(o.from),s=a.value;for(;!r.done&&!a.done;){if(0>=l5(s.from,o.to)&&l5(s.to,o.from)>=0)return!0;0>l5(o.from,s.from)?o=(r=n.next(s.from)).value:s=(a=i.next(o.from)).value}return!1}(o[e],i[e]))}let c=e=>{uX(o,e),u()&&d()},d=()=>{let f,p;if(s||r)return;o={};let h={},m=(n&&lj(),f=()=>lC(e,{subscr:h,trans:null}),p=li.trans?l$(li.transless,f):f(),n&&p.then(lT,lT),p);l||(ud("storagemutated",c),l=!0),s=!0,Promise.resolve(m).then(e=>{s=!1,r||(u()?d():(o={},i=h,t.next&&t.next(e)))},e=>{s=!1,t.error&&t.error(e),a.unsubscribe()})};return d(),a})},extendObservabilitySet:uX,getByKeyPath:sd,setByKeyPath:sf,delByKeyPath:function(e,t){"string"==typeof t?sf(e,t,void 0):"length"in t&&[].map.call(t,function(t){sf(e,t,void 0)})},shallowClone:sp,deepClone:sv,getObjectDiff:uL,cmp:l5,asap:su,minKey:-1/0,addons:[],connections:lK,errnames:sF,dependencies:i,semVer:"3.2.2",version:"3.2.2".split(".").map(e=>parseInt(e)).reduce((e,t,n)=>e+t/Math.pow(10,2*n))}),uY.maxKey=uy(uY.dependencies.IDBKeyRange),"u">typeof dispatchEvent&&"u">typeof addEventListener&&(ud("storagemutated",e=>{if(!u1){let t;lz?(t=document.createEvent("CustomEvent")).initCustomEvent("x-storagemutated-1",!0,!0,e):t=new CustomEvent("x-storagemutated-1",{detail:e}),u1=!0,dispatchEvent(t),u1=!1}}),addEventListener("x-storagemutated-1",({detail:e})=>{u1||u0(e)}));let u1=!1;if("u">typeof BroadcastChannel){let e=new BroadcastChannel("x-storagemutated-1");ud("storagemutated",t=>{u1||e.postMessage(t)}),e.onmessage=e=>{e.data&&u0(e.data)}}else if("u">typeof self&&"u">typeof navigator){ud("storagemutated",e=>{try{u1||("u">typeof localStorage&&localStorage.setItem("x-storagemutated-1",JSON.stringify({trig:Math.random(),changedParts:e})),"object"==typeof self.clients&&[...self.clients.matchAll({includeUncontrolled:!0})].forEach(t=>t.postMessage({type:"x-storagemutated-1",changedParts:e})))}catch(e){}}),"u">typeof addEventListener&&addEventListener("storage",e=>{if("x-storagemutated-1"===e.key){let t=JSON.parse(e.newValue);t&&u0(t.changedParts)}});let e=self.document&&navigator.serviceWorker;e&&e.addEventListener("message",function({data:e}){e&&"x-storagemutated-1"===e.type&&u0(e.changedParts)})}function u2(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}lu.rejectionMapper=function(e,t){if(!e||e instanceof sM||e instanceof TypeError||e instanceof SyntaxError||!e.name||!sV[e.name])return e;var n=new sV[e.name](t||e.message,e);return"stack"in e&&st(n,"stack",{get:function(){return this.inner.stack}}),n},sP=lH;class u4 extends uY{constructor(){super("EsmOffline"),u2(this,"syncQueue",void 0),u2(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 u3(){return new u4}let u6=new u4,u5={},u7=Z("offline-synchronization",{});function u9(){return u7}async function u8(){if(u7.getState().synchronization)return;let e=await u6.syncQueue.count(),t={},n=Object.entries(u5),r=n.length,o={},i=new AbortController,a=()=>{let e=u7.getState().synchronization;u7.setState({synchronization:{...e,pendingCount:e.pendingCount-1}})};try{u7.setState({synchronization:{totalCount:e,pendingCount:e,abortController:i}});for(let e=0;e<r&&n.length>0;e++)for(let e=n.length;e--;){let[r,s]=n[e],l=s.dependsOn.map(e=>t[e]);l.every(Boolean)&&(o[r]={},await Promise.all(l),t[r]=ce(s,o,i,a),n.splice(e,1))}await Promise.allSettled(Object.values(t))}finally{u7.setState({synchronization:void 0})}}async function ce({type:e,dependsOn:t,process:n},r,o,i){let a=[],s=[],l=await ct();await u6.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:f,dependencies:p=[]}]=a[u];try{let i=await n(d,{abort:o,index:u,items:s,userId:l,dependencies:p.map(({id:e,type:n})=>t.includes(n)?r[n][e]:void 0)});void 0!==f&&(r[e][f]=i),await u6.syncQueue.delete(c)}catch(e){await u6.syncQueue.update(c,{lastError:{name:e?.name,message:e?.message??e?.toString()}})}finally{i()}}}async function ct(){let e=await oY();return e?.uuid||"*"}async function cn(e,t,n,r){let o=r&&r.id;return void 0!==o&&await u6.syncQueue.where({type:t,userId:e}).filter(e=>e?.descriptor.id===o).delete().catch(uY.errnames.DatabaseClosed),await u6.syncQueue.add({type:t,content:n,userId:e,descriptor:r||{},createdOn:new Date}).catch(uY.errnames.DatabaseClosed,()=>-1)}async function cr(e,t,n){let r=await ct();return await cn(r,e,t,n)}async function co(e,t){return(await ci(e,t)).map(e=>e.content)}async function ci(e,t){return await u6.syncQueue.where(t?{type:t,userId:e}:{userId:e}).toArray().catch(uY.errnames.DatabaseClosed,()=>[])}async function ca(e){let t=await ct();return await co(t,e)}async function cs(e){let t=await ct();return await ci(t,e)}async function cl(e){return await u6.syncQueue.get(e).catch(uY.errnames.DatabaseClosed,()=>void 0)}function cu(e){return!!u5[e]?.options.onBeginEditSyncItem}async function cc(e){let t=await cl(e);if(!t)throw Error(`No sync item with the ID ${e} exists.`);let n=u5[t.type]?.options.onBeginEditSyncItem;if(!n)throw Error(`A sync item with the ID ${e} exists, but the associated handler (if one exists) doesn't support editing the item. You can avoid this error by either verifying that sync items of this type can be edited via the "canEditSynchronizationItemsOfType(type: string)" function or alternatively ensure that the synchronizaton handler for sync items of type "${t.type}" supports editing items.`);n(t)}async function cd(e){await u6.syncQueue.delete(e).catch(uY.errnames.DatabaseClosed)}function cf(e,t,n,r={}){u5[e]={type:e,dependsOn:t,process:n,options:r}}let cp="u">typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),ch=new Uint8Array(16),cm=[];for(let e=0;e<256;++e)cm.push((e+256).toString(16).slice(1));let cy=function(e,t,n){if(cp&&!t&&!e)return cp();let r=(e=e||{}).random||(e.rng||function(){if(!a&&!(a="u">typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)))throw Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return a(ch)})();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,t){n=n||0;for(let e=0;e<16;++e)t[n+e]=r[e];return t}return function(e,t=0){return cm[e[t+0]]+cm[e[t+1]]+cm[e[t+2]]+cm[e[t+3]]+"-"+cm[e[t+4]]+cm[e[t+5]]+"-"+cm[e[t+6]]+cm[e[t+7]]+"-"+cm[e[t+8]]+cm[e[t+9]]+"-"+cm[e[t+10]]+cm[e[t+11]]+cm[e[t+12]]+cm[e[t+13]]+cm[e[t+14]]+cm[e[t+15]]}(r)},cg="OFFLINE+";function cb(){return cg+cy()}function cv(e){return e.startsWith(cg)}let cw={};function c_(){return Object.values(cw)}function cx(e){cw[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.`),cw[e.id]=e}async function cS(e){let t=await cT();return await cE(t,e)}async function cE(e,t){let n=new u4;return await n.dynamicOfflineData.where(t?{type:t,users:e}:{users:e}).toArray().catch(uY.errnames.DatabaseClosed,()=>[])}async function cD(e,t){let n=await cT();return await cO(n,e,t)}async function cO(e,t,n){let r=new u4,o=await r.dynamicOfflineData.get({type:t,identifier:n}).catch(uY.errnames.DatabaseClosed,()=>void 0);o?o.users.includes(e)||await r.dynamicOfflineData.update(o.id,{users:[...o.users,e]}).catch(uY.errnames.DatabaseClosed):await r.dynamicOfflineData.add({users:[e],type:t,identifier:n}).catch(uY.errnames.DatabaseClosed)}async function ck(e,t){let n=await cT();return await cP(n,e,t)}async function cP(e,t,n){let r=new u4,o=await r.dynamicOfflineData.get({type:t,identifier:n,users:e}).catch(uY.errnames.DatabaseClosed,()=>void 0);o&&(o.users.length>1?await r.dynamicOfflineData.update(o.id,{users:o.users.filter(t=>t!==e)}).catch(uY.errnames.DatabaseClosed):await r.dynamicOfflineData.delete(o.id).catch(uY.errnames.DatabaseClosed))}async function cC(e,t){let n=await cS(e);await Promise.all(n.map(async e=>cj(e.type,e.identifier,t)))}async function cj(e,t,n){await cD(e,t);let r=new u4,o=await cT(),i=await r.dynamicOfflineData.get({type:e,identifier:t}).catch(uY.errnames.DatabaseClosed,()=>void 0),a=c_().filter(t=>t.type===e);if(!i)return;let s=await Promise.all(a.map(async e=>{try{return e.sync(t,n),{id:e.id,error:void 0}}catch(n){let t=n.message?.toString()??n.toString();return{id:e.id,error:t}}})),l=s.filter(e=>!e.error).map(e=>e.id),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 r.dynamicOfflineData.update(i.id,{syncState:d}).catch(uY.errnames.DatabaseClosed)}async function cT(){let e=(await oY()).uuid;if(!e)throw Error("Using the dynamic offline data API requires a logged in user.");return e}let cR=Z("offline-patients",{offlinePatientDataSyncState:{},handlers:{}});function cA(){return cI(),cR}function cN(e,t){cI(),cx({type:"patient",displayName:t.displayName,id:e,isSynced:()=>Promise.resolve(!0),sync:(e,n)=>t.onOfflinePatientAdded({patientUuid:e,signal:n??new AbortController().signal})})}async function cM(e){cI(),await cj("patient",e)}function cI(){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 c$(e,t,n=!0){if(e){let r=null,[o,i]=await Promise.all([oF(`${oI}/Patient/${e}`,t).catch(e=>r=e),n?cL(e):Promise.resolve(null)]);if(o.ok)return o.data;if(i)return i;if(r)throw r}return null}async function cL(e){let t=(await ca("patient-registration")).find(t=>t.fhirPatient.id===e);return t?.fhirPatient??null}function cF(e,t){let n=new CustomEvent(`openmrs:${e}`,{detail:t??void 0,cancelable:!0,bubbles:!0});return window.dispatchEvent(n)}function cB(e,t){let n=e=>{t("detail"in e&&null!==e.detail?e.detail:void 0)};return window.addEventListener(`openmrs:${e}`,n),()=>{window.removeEventListener(`openmrs:${e}`,n)}}var cV=n(99549);function cU(e){return{uuid:e.uuid,display:e.display}}function cW(e=null,t=null){let n=new URLSearchParams;e&&n.set("tag",e),t&&n.set("q",t);let r=n.toString();return oB(`${oM}/location${r?"?"+r:""}`).pipe((0,cV.map)(e=>e.data.results.map(cU))).pipe((0,cV.take)(1))}function cK(e){return{uuid:e.uuid,display:e.display,name:e.name}}function cz(){return oB(`${oM}/visittype`).pipe((0,cV.map)(e=>e.data.results.map(cK))).pipe((0,cV.take)(1))}var cH=n(29827),cG=((es={}).NEWVISIT="startVisit",es.EDITVISIT="editVisit",es.LOADING="loadingVisit",es),cq=((el={}).NOTSTARTED="notStarted",el.ONGOING="ongoing",el);let cZ="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))",cY=function(){try{return JSON.parse(sessionStorage.getItem("openmrs:visitStoreState")||"null")}catch(e){return null}}()||{patientUuid:null,manuallySetVisitUuid:null};function cJ(){return J("visit",cY)}function cQ(e,t){cJ().setState({patientUuid:e,manuallySetVisitUuid:t})}function cX(e,t){return oF(`${oM}/visit`,{signal:t.signal,method:"POST",headers:{"Content-type":"application/json"},body:e})}function c0(e,t,n){return oF(`${oM}/visit/${e}`,{signal:n.signal,method:"POST",headers:{"Content-type":"application/json"},body:t})}function c1(e,t,n){return oF(`${oM}/visit?patient=${e}&v=${n??cZ}`,{signal:t.signal,method:"GET",headers:{"Content-type":"application/json"}})}cJ().subscribe(e=>{var t;t=e,sessionStorage.setItem("openmrs:visitStoreState",JSON.stringify(t))});let c2=new cH.t(null);class c4{static get version(){return"1.4.0"}static toString(){return"JavaScript Expression Parser (JSEP) v"+c4.version}static addUnaryOp(e){return c4.max_unop_len=Math.max(e.length,c4.max_unop_len),c4.unary_ops[e]=1,c4}static addBinaryOp(e,t,n){return c4.max_binop_len=Math.max(e.length,c4.max_binop_len),c4.binary_ops[e]=t,n?c4.right_associative.add(e):c4.right_associative.delete(e),c4}static addIdentifierChar(e){return c4.additional_identifier_chars.add(e),c4}static addLiteral(e,t){return c4.literals[e]=t,c4}static removeUnaryOp(e){return delete c4.unary_ops[e],e.length===c4.max_unop_len&&(c4.max_unop_len=c4.getMaxKeyLen(c4.unary_ops)),c4}static removeAllUnaryOps(){return c4.unary_ops={},c4.max_unop_len=0,c4}static removeIdentifierChar(e){return c4.additional_identifier_chars.delete(e),c4}static removeBinaryOp(e){return delete c4.binary_ops[e],e.length===c4.max_binop_len&&(c4.max_binop_len=c4.getMaxKeyLen(c4.binary_ops)),c4.right_associative.delete(e),c4}static removeAllBinaryOps(){return c4.binary_ops={},c4.max_binop_len=0,c4}static removeLiteral(e){return delete c4.literals[e],c4}static removeAllLiterals(){return c4.literals={},c4}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 c4(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 c4.binary_ops[e]||0}static isIdentifierStart(e){return e>=65&&e<=90||e>=97&&e<=122||e>=128&&!c4.binary_ops[String.fromCharCode(e)]||c4.additional_identifier_chars.has(String.fromCharCode(e))}static isIdentifierPart(e){return c4.isIdentifierStart(e)||c4.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(c4.hooks[e]){let n={context:this,node:t};return c4.hooks.run(e,n),n.node}return t}searchHook(e){if(c4.hooks[e]){let t={context:this};return c4.hooks[e].find(function(e){return e.call(t.context,t),t.node}),t.node}}gobbleSpaces(){let e=this.code;for(;e===c4.SPACE_CODE||e===c4.TAB_CODE||e===c4.LF_CODE||e===c4.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:c4.COMPOUND,body:e};return this.runHook("after-all",t)}gobbleExpressions(e){let t=[],n,r;for(;this.index<this.expr.length;)if((n=this.code)===c4.SEMCOL_CODE||n===c4.COMMA_CODE)this.index++;else if(r=this.gobbleExpression())t.push(r);else if(this.index<this.expr.length){if(n===e)break;this.throwError('Unexpected "'+this.char+'"')}return t}gobbleExpression(){let e=this.searchHook("gobble-expression")||this.gobbleBinaryExpression();return this.gobbleSpaces(),this.runHook("after-expression",e)}gobbleBinaryOp(){this.gobbleSpaces();let e=this.expr.substr(this.index,c4.max_binop_len),t=e.length;for(;t>0;){if(c4.binary_ops.hasOwnProperty(e)&&(!c4.isIdentifierStart(this.code)||this.index+e.length<this.expr.length&&!c4.isIdentifierPart(this.expr.charCodeAt(this.index+e.length))))return this.index+=t,e;e=e.substr(0,--t)}return!1}gobbleBinaryExpression(){let e,t,n,r,o,i,a,s,l;if(!(i=this.gobbleToken())||!(t=this.gobbleBinaryOp()))return i;for(o={value:t,prec:c4.binaryPrecedence(t),right_a:c4.right_associative.has(t)},(a=this.gobbleToken())||this.throwError("Expected expression after "+t),r=[i,o,a];t=this.gobbleBinaryOp();){if(0===(n=c4.binaryPrecedence(t))){this.index-=t.length;break}o={value:t,prec:n,right_a:c4.right_associative.has(t)},l=t;let s=e=>o.right_a&&e.right_a?n>e.prec:n<=e.prec;for(;r.length>2&&s(r[r.length-2]);)a=r.pop(),t=r.pop().value,i=r.pop(),e={type:c4.BINARY_EXP,operator:t,left:i,right:a},r.push(e);(e=this.gobbleToken())||this.throwError("Expected expression after "+l),r.push(o,e)}for(s=r.length-1,e=r[s];s>1;)e={type:c4.BINARY_EXP,operator:r[s-1].value,left:r[s-2],right:e},s-=2;return e}gobbleToken(){let e,t,n,r;if(this.gobbleSpaces(),r=this.searchHook("gobble-token"))return this.runHook("after-token",r);if(e=this.code,c4.isDecimalDigit(e)||e===c4.PERIOD_CODE)return this.gobbleNumericLiteral();if(e===c4.SQUOTE_CODE||e===c4.DQUOTE_CODE)r=this.gobbleStringLiteral();else if(e===c4.OBRACK_CODE)r=this.gobbleArray();else{for(n=(t=this.expr.substr(this.index,c4.max_unop_len)).length;n>0;){if(c4.unary_ops.hasOwnProperty(t)&&(!c4.isIdentifierStart(this.code)||this.index+t.length<this.expr.length&&!c4.isIdentifierPart(this.expr.charCodeAt(this.index+t.length)))){this.index+=n;let e=this.gobbleToken();return e||this.throwError("missing unaryOp argument"),this.runHook("after-token",{type:c4.UNARY_EXP,operator:t,argument:e,prefix:!0})}t=t.substr(0,--n)}c4.isIdentifierStart(e)?(r=this.gobbleIdentifier(),c4.literals.hasOwnProperty(r.name)?r={type:c4.LITERAL,value:c4.literals[r.name],raw:r.name}:r.name===c4.this_str&&(r={type:c4.THIS_EXP})):e===c4.OPAREN_CODE&&(r=this.gobbleGroup())}return r?(r=this.gobbleTokenProperty(r),this.runHook("after-token",r)):this.runHook("after-token",!1)}gobbleTokenProperty(e){this.gobbleSpaces();let t=this.code;for(;t===c4.PERIOD_CODE||t===c4.OBRACK_CODE||t===c4.OPAREN_CODE||t===c4.QUMARK_CODE;){let n;if(t===c4.QUMARK_CODE){if(this.expr.charCodeAt(this.index+1)!==c4.PERIOD_CODE)break;n=!0,this.index+=2,this.gobbleSpaces(),t=this.code}this.index++,t===c4.OBRACK_CODE?((e={type:c4.MEMBER_EXP,computed:!0,object:e,property:this.gobbleExpression()}).property||this.throwError('Unexpected "'+this.char+'"'),this.gobbleSpaces(),(t=this.code)!==c4.CBRACK_CODE&&this.throwError("Unclosed ["),this.index++):t===c4.OPAREN_CODE?e={type:c4.CALL_EXP,arguments:this.gobbleArguments(c4.CPAREN_CODE),callee:e}:(t===c4.PERIOD_CODE||n)&&(n&&this.index--,this.gobbleSpaces(),e={type:c4.MEMBER_EXP,computed:!1,object:e,property:this.gobbleIdentifier()}),n&&(e.optional=!0),this.gobbleSpaces(),t=this.code}return e}gobbleNumericLiteral(){let e="",t,n;for(;c4.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);if(this.code===c4.PERIOD_CODE)for(e+=this.expr.charAt(this.index++);c4.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++));c4.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);c4.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+e+this.char+")")}return n=this.code,c4.isIdentifierStart(n)?this.throwError("Variable names cannot start with a number ("+e+this.char+")"):(n===c4.PERIOD_CODE||1===e.length&&e.charCodeAt(0)===c4.PERIOD_CODE)&&this.throwError("Unexpected period"),{type:c4.LITERAL,value:parseFloat(e),raw:e}}gobbleStringLiteral(){let e="",t=this.index,n=this.expr.charAt(this.index++),r=!1;for(;this.index<this.expr.length;){let t=this.expr.charAt(this.index++);if(t===n){r=!0;break}if("\\"===t)switch(t=this.expr.charAt(this.index++)){case"n":e+="\n";break;case"r":e+="\r";break;case"t":e+=" ";break;case"b":e+="\b";break;case"f":e+="\f";break;case"v":e+="\v";break;default:e+=t}else e+=t}return r||this.throwError('Unclosed quote after "'+e+'"'),{type:c4.LITERAL,value:e,raw:this.expr.substring(t,this.index)}}gobbleIdentifier(){let e=this.code,t=this.index;for(c4.isIdentifierStart(e)?this.index++:this.throwError("Unexpected "+this.char);this.index<this.expr.length;)if(e=this.code,c4.isIdentifierPart(e))this.index++;else break;return{type:c4.IDENTIFIER,name:this.expr.slice(t,this.index)}}gobbleArguments(e){let t=[],n=!1,r=0;for(;this.index<this.expr.length;){this.gobbleSpaces();let o=this.code;if(o===e){n=!0,this.index++,e===c4.CPAREN_CODE&&r&&r>=t.length&&this.throwError("Unexpected token "+String.fromCharCode(e));break}if(o===c4.COMMA_CODE){if(this.index++,++r!==t.length){if(e===c4.CPAREN_CODE)this.throwError("Unexpected token ,");else if(e===c4.CBRACK_CODE)for(let e=t.length;e<r;e++)t.push(null)}}else if(t.length!==r&&0!==r)this.throwError("Expected comma");else{let e=this.gobbleExpression();e&&e.type!==c4.COMPOUND||this.throwError("Expected comma"),t.push(e)}}return n||this.throwError("Expected "+String.fromCharCode(e)),t}gobbleGroup(){this.index++;let e=this.gobbleExpressions(c4.CPAREN_CODE);if(this.code===c4.CPAREN_CODE)return(this.index++,1===e.length)?e[0]:!!e.length&&{type:c4.SEQUENCE_EXP,expressions:e};this.throwError("Unclosed (")}gobbleArray(){return this.index++,{type:c4.ARRAY_EXP,elements:this.gobbleArguments(c4.CBRACK_CODE)}}}Object.assign(c4,{hooks:new class{add(e,t,n){if("string"!=typeof arguments[0])for(let e in arguments[0])this.add(e,arguments[0][e],arguments[1]);else(Array.isArray(e)?e:[e]).forEach(function(e){this[e]=this[e]||[],t&&this[e][n?"unshift":"push"](t)},this)}run(e,t){this[e]=this[e]||[],this[e].forEach(function(e){e.call(t&&t.context?t.context:t,t)})}},plugins:new class{constructor(e){this.jsep=e,this.registered={}}register(...e){e.forEach(e=>{if("object"!=typeof e||!e.name||!e.init)throw Error("Invalid JSEP plugin format");this.registered[e.name]||(e.init(this.jsep),this.registered[e.name]=e)})}}(c4),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"}),c4.max_unop_len=c4.getMaxKeyLen(c4.unary_ops),c4.max_binop_len=c4.getMaxKeyLen(c4.binary_ops);let c3=e=>new c4(e).parse(),c6=Object.getOwnPropertyNames(class{});Object.getOwnPropertyNames(c4).filter(e=>!c6.includes(e)&&void 0===c3[e]).forEach(e=>{c3[e]=c4[e]}),c3.Jsep=c4,c3.plugins.register({name:"ternary",init(e){e.hooks.add("after-expression",function(t){if(t.node&&this.code===e.QUMARK_CODE){this.index++;let n=t.node,r=this.gobbleExpression();if(r||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===e.COLON_CODE){this.index++;let o=this.gobbleExpression();if(o||this.throwError("Expected expression"),t.node={type:"ConditionalExpression",test:n,consequent:r,alternate:o},n.operator&&e.binary_ops[n.operator]<=.9){let r=n;for(;r.right.operator&&e.binary_ops[r.right.operator]<=.9;)r=r.right;t.node.test=r.right,r.right=t.node,t.node=n}}else this.throwError("Expected :")}})}});let c5="ArrowFunctionExpression",c7={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)}},c9={...c7,Promise};function c8(e,t={}){return da(e,t,du)}async function de(e,t={}){return ds(e,t,du)}function dt(e,t={}){return da(e,t,dc)}function dn(e,t={}){return ds(e,t,dc)}function dr(e,t={}){return da(e,t,dd)}function di(e,t={}){return ds(e,t,dd)}function da(e,t={},n){if("string"!=typeof e&&("object"!=typeof e||!e||!("type"in e)))throw`Unknown expression type ${e}. Expressions must either be a string or pre-compiled string.`;if("string"==typeof e&&0===e.trim().length)throw{type:"Empty expression",message:"Expression cannot be an empty string"};null==t&&(t={});let r=dh(t,c7),o=df("string"==typeof e?c3(e):e,r);if(n(o))return o;throw{type:"Invalid result",message:"string"==typeof e?`The expression ${e} did not produce a valid result`:"The expression did not produce a valid result"}}async function ds(e,t={},n){if("string"!=typeof e&&("object"!=typeof e||!e||!("type"in e)))return Promise.reject(`Unknown expression type ${e}. Expressions must either be a string or pre-compiled string.`);if("string"==typeof e&&0===e.trim().length)throw{type:"Empty expression",message:"Expression cannot be an empty string"};null==t&&(t={});let r=dh(t,c9);return Promise.resolve(df("string"==typeof e?c3(e):e,r)).then(t=>{if(n(t))return t;throw{type:"Invalid result",message:"string"==typeof e?`The expression ${e} did not produce a valid result`:"The expression did not produce a valid result"}})}function dl(e){return c3(e)}function du(e){return"string"==typeof e||"number"==typeof e||"boolean"==typeof e||null==e||e instanceof Date}function dc(e){return"boolean"==typeof e}function dd(e){return"number"==typeof e}function df(e,t){switch(e.type){case"UnaryExpression":var n,r,o,i,a,s,l,u,c,d,f,p,h=e,m=t;let y=df(h.argument,m);switch(h.operator){case"+":return+y;case"-":return-y;case"~":return~y;case"!":return!y;default:throw`Expression evaluator does not support operator '${h.operator}''`}case"BinaryExpression":var g=e,b=t;let v=df(g.left,b),w=df(g.right,b);switch(g.operator){case"+":return v+w;case"-":return v-w;case"*":return v*w;case"/":return v/w;case"%":return v%w;case"**":return v**w;case"==":return v==w;case"===":return v===w;case"!=":return v!=w;case"!==":return v!==w;case">":return v>w;case">=":return v>=w;case"<":return v<w;case"<=":return v<=w;case"in":return v in w;case"&&":return v&&w;case"||":return v||w;case"??":return v??w;default:throw`Expression evaluator does not support operator '${g.operator}' operator`}case"ConditionalExpression":return n=e,r=t,df(n.test,r)?df(n.consequent,r):df(n.alternate,r);case"CallExpression":var x=e,S=t;let E=x.arguments?.map(dm(S)),D=df(x.callee,S);if(D){if("function"!=typeof D)throw`${dg(x.callee)} is not a function`}else throw`No function named ${dg(x.callee)} is defined in this context`;return D(...E);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,n,r)=>{let o=e[r];return function e(t){if("string"==typeof t||"number"==typeof t||"boolean"==typeof t||"function"==typeof t||null===t||t instanceof RegExp)return!0;if("object"==typeof t){for(let n of Object.keys(t))if(!e(t[n]))return!1;return!0}if(Array.isArray(t)){for(let n of t)if(!e(n))break}return!1}(o)&&t.push([n,o]),t},[]));return df(o.body,i.addVariables(t))}).bind(i.thisObj??null);case"MemberExpression":return function(e,t){let n,r=df(e.object,t);if(void 0===r)switch(e.object.type){case"Identifier":{let n=dp(e.object,t);throw ReferenceError(`ReferenceError: ${n} is not defined`)}case"MemberExpression":{let n=dp(e.property,t);throw TypeError(`TypeError: cannot read properties of undefined (reading '${n}')`)}default:throw`VisitMemberExpression does not support operator '${e.object.type}' type`}let o=r;if("string"==typeof r)o=String.prototype;else if("number"==typeof r)o=Number.prototype;else if("function"==typeof r);else if("object"!=typeof r)throw`VisitMemberExpression does not support member access on type ${typeof r}`;switch(t.thisObj=o,e.property.type){case"Identifier":case"MemberExpression":n=df(e.property,t);break;default:{let o=df(e.property,t);if(void 0===o)throw{type:"Illegal property access",message:"No property was supplied to the property access"};dy(o),n=r[o]}}return"function"==typeof n?n.bind(r):n}(e,t);case"ArrayExpression":return a=e,s=t,a.elements?.map(dm(s));case"SequenceExpression":let k;return l=e,u=t,(k=l.expressions.map(dm(u)))[k.length-1];case"NewExpression":var P=e,C=t;if(P.callee&&"Identifier"===P.callee.type){let e=P.arguments?.map(dm(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 dy((c=e).value),c.value;case"Identifier":var j=e,T=t;dy(j.name);let R=T.thisObj;if(R&&("object"==typeof R||"function"==typeof R)&&j.name in R){let e=R[j.name];return dy(e),e}if(T.variables&&j.name in T.variables){let e=T.variables[j.name];return dy(e),e}return j.name in T.globals?T.globals[j.name]:void 0;case"TemplateLiteral":let A,N;return d=e,f=t,A=d.expressions?.map(dm(f))??[],(N=d.quasis?.map(dm(f))??[]).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:(p=e).cooked,tail:p.tail};default:throw`Expression evaluator does not support expression of type '${e.type}'`}}function dp(e,t){switch(e.type){case"Literal":return e.value;case"Identifier":return e.name;case"MemberExpression":return dp(e.property,t);default:throw`VisitExpressionName does not support expression of type '${e.type}'`}}function dh(e,t){let n={thisObj:void 0,variables:{...e},globals:{...t},addVariables(e){return this.variables={...this.variables,...e},this}};return n.addVariables.bind(n),n}function dm(e){return function(t){return null===t?null:df(t,e)}}function dy(e){if("__proto__"===e||"prototype"===e||"constructor"===e)throw{type:"Illegal property access",message:`Cannot access the ${e} property of objects`}}function dg(e){return e?"MemberExpression"===e.type?e.property?.name:e.name:null}function db(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:{...c9},isLocalExpression:!1,variables:new Set};return dv("string"==typeof e?c3(e):e,t),[...t.variables]}function dv(e,t){switch(e.type){case"UnaryExpression":return r=e,o=t,dv(r.argument,o);case"BinaryExpression":return i=e,a=t,[dv(i.left,a),dv(i.right,a)].filter(Boolean);case"ConditionalExpression":return s=e,l=t,[dv(s.consequent,l),dv(s.test,l),dv(s.alternate,l)].filter(Boolean);case"CallExpression":let n;return u=e,c=t,n=dv(u.callee,c),u.arguments?.map(dw(c)),n;case"ArrowFunctionExpression":var r,o,i,a,s,l,u,c,d,f,p,h,m,y,g,b,v,w,x=e,S=t;let E={...S};E.isLocalExpression=!0;let D=x.params?.map(dw(E))??[],O=dv(x.body,E)??[];if(O&&Array.isArray(O))for(let e of O)D.includes(e)||S.variables.add(e);return;case"MemberExpression":let k;return d=e,f=t,dv(d.object,f),void((k={...f}).isLocalExpression=!0,dv(d.property,k));case"ArrayExpression":return p=e,h=t,void p.elements?.map(dw(h));case"SequenceExpression":return m=e,y=t,void m.expressions?.map(dw(y));case"NewExpression":return g=e,b=t,void g.arguments?.map(dw(b));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 v=e,w=t,void(v.expressions?.map(dw(w)),v.quasis?.map(dw(w)));default:throw`Expression evaluator does not support expression of type '${e.type}'`}}function dw(e){return function(t){return null===t?null:dv(t,e)}}c3.plugins.register({name:"arrow",init(e){e.addBinaryOp("=>",.1,!0),e.hooks.add("gobble-expression",function(t){if(this.gobbleSpaces(),this.code===e.OPAREN_CODE){let n=this.index;if(this.index++,this.gobbleSpaces(),this.code===e.CPAREN_CODE){this.index++;let e=this.gobbleBinaryOp();if("=>"===e){let n=this.gobbleBinaryExpression();n||this.throwError("Expected expression after "+e),t.node={type:c5,params:null,body:n};return}}this.index=n}}),e.hooks.add("after-expression",function(t){!function t(n){n&&(Object.values(n).forEach(e=>{e&&"object"==typeof e&&t(e)}),"=>"===n.operator&&(n.type=c5,n.params=n.left?[n.left]:null,n.body=n.right,n.params&&n.params[0].type===e.SEQUENCE_EXP&&(n.params=n.params[0].expressions),delete n.left,delete n.right,delete n.operator))}(t.node)})}}),c3.plugins.register({name:"new",init(e){e.addUnaryOp("new"),e.hooks.add("after-token",function(t){let n=t.node;if(n&&"new"===n.operator){n.argument&&[e.CALL_EXP,e.MEMBER_EXP].includes(n.argument.type)||this.throwError("Expected new function()"),t.node=n.argument;let r=t.node;for(;r.type===e.MEMBER_EXP||r.type===e.CALL_EXP&&r.callee.type===e.MEMBER_EXP;)r=r.type===e.MEMBER_EXP?r.object:r.callee.object;r.type="NewExpression"}})}}),c3.plugins.register({name:"numbers",init(e){function t(e){return"x"===e||"X"===e?(this.index+=2,[[48,57],[65,70],[97,102]]):"b"===e||"B"===e?(this.index+=2,[[48,49]]):"o"===e||"O"===e||e>="0"&&e<="7"?(this.index+=e<="7"?1:2,[[48,55]]):null}function n(t){let n=this.index,r="",o=()=>{for(;e.isDecimalDigit(this.code)||95===this.code;)95===this.code?this.index++:r+=this.expr.charAt(this.index++)};o(),this.code===e.PERIOD_CODE&&(r+=this.expr.charAt(this.index++),o());let i=this.char;("e"===i||"E"===i)&&(r+=this.expr.charAt(this.index++),("+"===(i=this.char)||"-"===i)&&(r+=this.expr.charAt(this.index++)),o(),e.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+r+this.char+")"));let a=this.code;if(e.isIdentifierStart(a))this.throwError("Variable names cannot start with a number ("+r+this.char+")");else if(a===e.PERIOD_CODE){r.length>1&&this.throwError(`Unexpected period ${JSON.stringify({chCode:a,number:r},null,2)}`),this.index=n;return}t.node={type:e.LITERAL,value:parseFloat(r),raw:this.expr.substring(n,this.index)}}e.hooks.add("gobble-token",function(r){if(48===this.code){var o,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,n.call(this,r);return}this.throwError("unexpected char within number")}r.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)&&n.call(this,r)})}}),c3.plugins.register({name:"regex",init(e){e.hooks.add("gobble-token",function(t){if(47===this.code){let n=++this.index,r=!1;for(;this.index<this.expr.length;){if(47===this.code&&!r){let r,o=this.expr.slice(n,this.index),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{r=new RegExp(o,i)}catch(e){this.throwError(e.message)}return t.node={type:e.LITERAL,value:r,raw:this.expr.slice(n-1,this.index)},t.node=this.gobbleTokenProperty(t.node),t.node}this.code===e.OBRACK_CODE?r=!0:r&&this.code===e.CBRACK_CODE&&(r=!1),this.index+=92===this.code?2:1}this.throwError("Unclosed Regex")}})}}),c3.plugins.register({name:"ternary",init(e){e.hooks.add("after-expression",function(t){if(t.node&&this.code===e.QUMARK_CODE){this.index++;let n=t.node,r=this.gobbleExpression();if(r||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===e.COLON_CODE){this.index++;let o=this.gobbleExpression();if(o||this.throwError("Expected expression"),t.node={type:"ConditionalExpression",test:n,consequent:r,alternate:o},n.operator&&e.binary_ops[n.operator]<=.9){let r=n;for(;r.right.operator&&e.binary_ops[r.right.operator]<=.9;)r=r.right;t.node.test=r.right,r.right=t.node,t.node=n}}else this.throwError("Expected :")}})}}),c3.plugins.register({name:"jsepTemplateLiteral",init(e){function t(e,n=!0){if(96===this.code){let t={type:"TemplateLiteral",quasis:[],expressions:[]},r="",o="",i=!1,a=this.expr.length,s=()=>t.quasis.push({type:"TemplateElement",value:{raw:o,cooked:r},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,n&&(e.node=this.gobbleTokenProperty(e.node)),e.node;if("$"===a&&"{"===this.expr.charAt(this.index+1))this.index+=2,s(),o="",r="",t.expressions.push(...this.gobbleExpressions(125)),125!==this.code&&this.throwError("unclosed ${");else if("\\"===a)switch(o+=a,a=this.expr.charAt(++this.index),o+=a,a){case"n":r+="\n";break;case"r":r+="\r";break;case"t":r+=" ";break;case"b":r+="\b";break;case"f":r+="\f";break;case"v":r+="\v";break;default:r+=a}else r+=a,o+=a}this.throwError("Unclosed `")}}e.hooks.add("gobble-token",t),e.hooks.add("after-token",function(n){if((n.node.type===e.IDENTIFIER||n.node.type===e.MEMBER_EXP)&&96===this.code)return n.node={type:"TaggedTemplateExpression",tag:n.node,quasi:t.bind(this)(n,!1)},n.node=this.gobbleTokenProperty(n.node),n.node})}}),c3.addBinaryOp("in",7),c3.addBinaryOp("??",1);let d_=J("feature-flags",{flags:function(){let e={};for(let t of Object.keys(localStorage))if(t.startsWith("openmrs:feature-flag:")){let n=t.replace("openmrs:feature-flag:",""),r=JSON.parse(localStorage.getItem(`openmrs:feature-flag-meta:${n}`)||"{}");e[n]={enabled:"true"===localStorage.getItem(t),...r}}return e}()});function dx(e,t,n){d_.setState(r=>({flags:{...r.flags,[e]:{enabled:r.flags[e]?.enabled??!1,label:t,description:n}}}))}function dS(){let e=d_.getState().flags;Object.keys(localStorage).filter(e=>e.startsWith("openmrs:feature-flag:")).forEach(t=>{let n=t.replace("openmrs:feature-flag:","");e[n]||(localStorage.removeItem(t),localStorage.removeItem(`openmrs:feature-flag-meta:${n}`))})}function dE(e){return d_.getState().flags[e].enabled}function dD(e,t){d_.subscribe(n=>{t(n.flags[e].enabled)})}function dO(e,t){d_.setState(n=>({flags:{...n.flags,[e]:{...n.flags[e],enabled:t}}}))}function dk(e){return!window.offlineEnabled||(e??navigator.onLine)}d_.subscribe(e=>{for(let[t,n]of Object.entries(e.flags))localStorage.setItem(`openmrs:feature-flag:${t}`,n.enabled.toString()),localStorage.setItem(`openmrs:feature-flag-meta:${t}`,JSON.stringify({label:n.label,description:n.description}))});var dP=e4(function(e,t,n){eH(e,t,n)});function dC(e=!0,t=!1){return dj(dk(),e,t)}function dj(e,t=!0,n=!1){return!!(e?t:n)}let dT=Z("extensionsInternal",{slots:{},extensions:{}}),dR=Z("extensionRenderings",{renderings:new Map}),dA=()=>J("extensionsInternal",{slots:{},extensions:{}}),dN=()=>J("extensionRenderings",{renderings:new Map});function dM(e){let t=dT.getState(),n=e(t);n!==t&&dT.setState(n)}let dI=null,d$=null;function dL(){let e=dR.getState();return dI&&e===d$||(dI=new Map(e.renderings),d$=e,function(e){for(let t of(dq.clear(),e.values()))dY(t,1);dZ=!0}(dI)),dI}function dF(e){d$={renderings:e},dR.setState(d$,!0)}function dB(e){let t=dL();t.has(e.renderingId)||(t.set(e.renderingId,e),dY(e,1),dF(t))}function dV(e){let t=dL(),n=t.get(e);n&&(t.delete(e),dY(n,-1),dF(t))}let dU=()=>J("extensions",{slots:{}}),dW=0,dK=new Set;function dz(e){dW++;try{return e()}finally{if(0==--dW&&dK.size>0){let e=Array.from(dK);for(let t of(dK.clear(),e))dH(t)}}}function dH(e){try{e()}catch(t){console.error(`The extension system's '${e.name}' recomputation failed`,t)}}function dG(e){dW>0?dK.add(e):dH(e)}let dq=new Map,dZ=!1;function dY(e,t){let n=JSON.stringify([e.slotName,e.extensionId,e.slotModuleName,e.extensionModuleName]),r=dq.get(n);if(!r){if(t<0)return;dq.set(n,{count:1,record:{slotModuleName:e.slotModuleName,extensionModuleName:e.extensionModuleName,slotName:e.slotName,extensionId:e.extensionId}}),dZ=!0;return}r.count+=t,r.count<1&&(dq.delete(n),dZ=!0)}function dJ(){var e,t;if(dL(),!dZ)return;dZ=!1;let n=Array.from(dq.values(),({record:e})=>e);n.sort(dQ),e=t4.getState().mountedExtensions,t=n,e.length===t.length&&e.every((e,n)=>0===dQ(e,t[n]))||t4.setState({mountedExtensions:n})}function dQ(e,t){return dX(e.slotName,t.slotName)||dX(e.extensionId,t.extensionId)||dX(e.slotModuleName,t.slotModuleName)||dX(e.extensionModuleName,t.extensionModuleName)}function dX(e,t){return e===t?0:e<t?-1:1}dJ(),dR.subscribe(()=>dG(dJ));let d0=dA(),d1=dU(),d2=t6(),d4=t9(),d3=new Set,d6=!1;function d5(e){if(null===e)d3=null;else if(null!==d3)for(let t of e)d3.add(t);dG(d7)}function d7(){if(!d6){d6=!0;try{for(let e=1;;e++){let t=d3;if(null!==t&&0===t.size)return;d3=new Set;try{!function(e,t,n,r,o,i=null){let a=d1.getState().slots,s={},l=!1,u=dk(),c=Object.entries(r.flags).filter(([,{enabled:e}])=>e).map(([e])=>e);for(let[r,d]of Object.entries(e.slots)){let f=a[r];if(f&&i&&!i.has(r)){s[r]=f;continue}let{config:p}=t7(t,d.name),h=function(e,t,n,r,o,i,a){let s=function(e,t){let n=e.add||[],r=e.remove||[],o=e.order||[],{extensions:i}=d0.getState();return[...t,...n].filter(e=>!r.includes(e)).sort((e,n)=>fl(e,o,i[ft(e)]?.order,t)-fl(n,o,i[ft(n)]?.order,t))}(n,t.slots[e].attachedIds),l=[];for(let u of s){let{config:s}=ne(r,e,u),c=nt(n,e,u),d=c?dP({},s,c):s,f=ft(u),p=t.extensions[f];if(p){let e=d?.["Display conditions"]?.privileges??p.privileges??[];if(e&&("string"==typeof e||Array.isArray(e)&&e.length>0)&&(!a?.user||!oZ(e,a.user))||p.featureFlag&&!o.includes(p.featureFlag)||window.offlineEnabled&&!dj(i,p.online,p.offline))continue;l.push({id:u,name:f,moduleName:p.moduleName,config:d,featureFlag:p.featureFlag,meta:p.meta,online:d?.["Display conditions"]?.online??p.online??!0,offline:d?.["Display conditions"]?.offline??p.offline??!1,displayConditionExpression:d?.["Display conditions"]?.expression||p.displayExpression})}}return l}(r,e,p,n,c,u,o.session);f&&f.moduleName===d.moduleName&&tm(f.candidateExtensions,h)?s[r]=f:(s[r]={moduleName:d.moduleName,candidateExtensions:h},l=!0)}(l||Object.keys(a).length!==Object.keys(s).length)&&d1.setState({slots:s})}(d0.getState(),d2.getState(),d4.getState(),d_.getState(),oU.getState(),t)}catch(e){throw d3=null===t||null===d3?null:new Set([...t,...d3]),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{d6=!1}}}function d9(e,t){let n=new Set;for(let r of Object.keys(e))e[r]!==t[r]&&n.add(r);for(let r of Object.keys(t))r in e||n.add(r);return n}function d8(){d5(null)}function fe(e,t){return{moduleName:t,name:e,attachedIds:[]}}function ft(e){let[t]=e.split("#");return t}function fn(e,t){let n=ft(t);return e.extensions[n]}function fr(e){return fn(d0.getState(),e)}d0.subscribe((e,t)=>{d5(e.extensions!==t.extensions?null:d9(e.slots,t.slots))}),d2.subscribe((e,t)=>{d5(d9(e.slots,t.slots))}),d4.subscribe((e,t)=>{d5(d9(e.configs,t.configs))}),d_.subscribe(()=>d5(null)),oU.subscribe(()=>d5(null)),d8(),b(d8);let fo=e=>dM(t=>({...t,extensions:{...t.extensions,[e.name]:{...e}}}));function fi(e,t){dM(n=>{let r=n.slots[e];return r?{...n,slots:{...n.slots,[e]:{...r,attachedIds:[...r.attachedIds,t]}}}:{...n,slots:{...n.slots,[e]:{...fe(e),attachedIds:[t]}}}})}function fa(e,t){dM(n=>{let r=n.slots[e];return r&&r.attachedIds.includes(t)?{...n,slots:{...n.slots,[e]:{...r,attachedIds:r.attachedIds.filter(e=>e!==t)}}}:n})}function fs(e){dM(t=>{let n=t.slots[e];return n?{...t,slots:{...t.slots,[e]:{...n,attachedIds:[]}}}:t})}function fl(e,t,n,r){let o=t.indexOf(e);if(-1!==o)return o;{if(void 0!==n)return 1e3+n;let t=r.indexOf(e);return -1!==t?2e3+t:3e3}}function fu(e,t){return function(e,t,n=null,r){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:n,...t}:{session:n});try{return!!dt(i,o)}catch(t){return console.error(`Error while evaluating expression '${i}' for ${e.id}`+(r?` in ${r}`:""),t),!1}})}(fc(e),t,oU.getState().session,e)}function fc(e){return d1.getState().slots[e]?.candidateExtensions??[]}let fd=(e,t)=>d0.setState(n=>{let r=n.slots[t]?.moduleName;if(r&&r!=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 ${r}.`),n;if(r&&r==e)return n;if(n.slots[t])return{...n,slots:{...n.slots,[t]:{...n.slots[t],moduleName:e}}};let o=fe(t,e);return{...n,slots:{...n.slots,[t]:{...o}}}}),ff=()=>{d3=null,dM(()=>({slots:{},extensions:{}})),dN().setState({renderings:new Map}),d1.setState({slots:{}})},fp=Z("left-nav",{slotName:null,basePath:window.spaBase,mode:"normal"});function fh({name:e,basePath:t,mode:n,componentContext:r,state:o}){fp.setState({slotName:e,basePath:t,mode:n??"normal",componentContext:r,state:o})}function fm(e){fp.getState().slotName===e&&fp.setState(fp.getInitialState(),!0)}let fy=Z("modalRegistry",{modals:{}});function fg(e){fy.setState(t=>(t.modals[e.name]=e,t))}function fb(e){let t=fy.getState().modals[e];if(!t){let n=fr(e);n&&(t={name:e,load:n.load,moduleName:n.moduleName},console.warn(`Modal ${e} was registered as an extension. This is deprecated and will be removed in the future. Please register it in the "modals" section of routes.json instead of the "extensions" section.`),fg(t))}return t}let fv=Z("workspaceRegistrations",{workspaces:{}}),fw=Z("workspaceGroups",{workspaceGroups:{}});function f_(e){fv.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 fx(e){fw.setState(t=>{let n=t.workspaceGroups[e.name];return n?{workspaceGroups:{...t.workspaceGroups,[e.name]:{...n,members:Array.from(new Set([...n.members,...e.members]))}}}:{workspaceGroups:{...t.workspaceGroups,[e.name]:{name:e.name,members:e.members}}}})}let fS=new Set;function fE(e){let t=fv.getState().workspaces;if(t[e])return t[e];{let t=fr(e);if(t){var n;let r;return fS.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.`),fS.add(e)),{name:t.name,title:(n=t,"string"==typeof(r=n?.meta?.title)?r:r&&"object"==typeof r?iB(n.moduleName,r.key,r.default):n.name),moduleName:t.moduleName,preferredWindowSize:t.meta?.screenSize??"normal",load:t.load,type:t.meta?.type??"form",canHide:t.meta?.canHide??!1,canMaximize:t.meta?.canMaximize??!1,width:t.meta?.width??"narrow",groups:t.meta?.groups??[]}}throw Error(`No workspace named '${e}' has been registered.`)}}function fD(e){let t=fw.getState().workspaceGroups;if(t[e])return t[e];throw Error(`No workspace group named '${e}' has been registered.`)}let fO=Z("workspace2",{registeredGroupsByName:{},registeredWindowsByName:{},registeredWorkspacesByName:{},openedGroup:null,openedWindows:[],workspaceTitleByWorkspaceName:{},isMostRecentlyOpenedWindowHidden:!1});function fk(e){let{registeredWorkspacesByName:t,registeredWindowsByName:n}=fO.getState(),r=t[e];if(r){let t=n[r.window];if(t)return t;throw Error(`No workspace window found with name: ${r.window} for workspace: ${e}`)}throw Error(`No workspace found with name: ${e}`)}function fP(e){let{registeredGroupsByName:t,registeredWindowsByName:n}=fO.getState(),r=n[e];if(r){let n=t[r.group];if(n)return n;throw Error(`No workspace group found with name: ${r.group} for window: ${e}`)}throw Error(`No workspace window found with name: ${e}`)}function fC(e){let{openedWindows:t}=fO.getState();return t.findIndex(t=>t.openedWorkspaces.find(t=>t.workspaceName===e))}function fj(e,t){if(0==t.length)return;let{registeredGroupsByName:n}=fO.getState(),r={...n};for(let n of t){if(r[n.name])throw Error(`Cannot register workspace group ${n.name} more than once`);r[n.name]={...n,moduleName:e}}fO.setState({registeredGroupsByName:r})}function fT(e,t){if(0==t.length)return;let{registeredWindowsByName:n}=fO.getState(),r={...n};for(let n of t){if(r[n.name])throw Error(`Cannot register workspace window ${n.name} more than once`);let t={...n,moduleName:e};r[n.name]=t}fO.setState({registeredWindowsByName:r})}function fR(e,t){if(0==t.length)return;let{registeredWorkspacesByName:n}=fO.getState(),r={...n};for(let n of t){if(r[n.name])throw Error(`Cannot register workspace ${n.name} more than once`);let t={...n,moduleName:e};r[n.name]=t}fO.setState({registeredWorkspacesByName:r})}let fA=0,fN=null,fM={bootstrap:15e3,mount:15e3,unmount:15e3};function fI(e,t){if(e.timeouts)return e;let n=e.name??"parcel",r=Object.fromEntries(Object.keys(fM).filter(t=>e[t]).map(r=>{var o,i;let a,s;return[r,(o=e[r],i=fM[r],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 ${r} at array index ${i} for parcel ${n} did not return a promise`))}),Promise.resolve(void 0)),e=>{let o,a=new Promise((e,t)=>{o=setTimeout(()=>t(Error(`Lifecycle function ${r} for parcel ${n} did not settle within ${i}ms`)),i)});return Promise.race([s(e),a]).finally(()=>clearTimeout(o)).then(e=>(t(r,!1),e),e=>{throw t(r,!0),e})})]}));return{...e,...r}}async function f$(e,t){var n,r;let o,i,a,s,l,u=await (fN??(fN=new Promise((e,t)=>{r$({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),r$))),fN),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 r=u((n=d.onSettled,"function"==typeof e?()=>e().then(e=>fI(e,n)):fI(e,n)),c),s=e=>t=>e.call(r,d.retarget(t)).catch(e=>{throw"SKIP_BECAUSE_BROKEN"===r.getStatus()&&d.release(),e}),l=r.update&&s(r.update),Object.defineProperty(r,"update",{configurable:!0,enumerable:!0,get:()=>l,set:e=>{l=e&&s(e)}})}function fL(){return fF}function fF(e,t){let n,r=f$(e,t).then(e=>n=e);return{mount:()=>r.then(e=>e.mount()),unmount:()=>r.then(e=>e.unmount()),update:e=>r.then(t=>t.update?.(e)),getStatus:()=>n?.getStatus()??"LOADING_SOURCE_CODE",get loadPromise(){return r.then(e=>e.loadPromise)},get bootstrapPromise(){return r.then(e=>e.bootstrapPromise)},get mountPromise(){return r.then(e=>e.mountPromise)},get unmountPromise(){return r.then(e=>e.unmountPromise)}}}async function fB(e,t,n,r,o=e=>e,i={}){let a=ft(r),s=fr(r),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:f,load:p}=s;if(dC(d,f)){let s,d=fA++,f=`${t}/${r}-${d}`;e.dataset.extensionRenderingId=f;let h=e=>{try{dV(f)}catch(t){console.error(e,t)}};try{dB({renderingId:f,extensionName:a,extensionModuleName:c,extensionId:r,slotName:t,slotModuleName:n})}catch(e){throw h(`Recomputing configuration after registering '${r}' failed also failed`),e}try{s=await p()}catch(e){throw h(`Recomputing configuration after '${r}' failed to load also failed`),e}try{l=await f$(o({...s,name:`${t}/${a}-${d}`}),{...i,_meta:u,_extensionContext:{extensionId:r,extensionSlotName:t,extensionSlotModuleName:n,extensionModuleName:c},domElement:e})}catch(e){throw h(`Recomputing configuration after '${r}' failed to mount also failed`),e}l.mountPromise.then(void 0,e=>{console.error(`Extension '${r}' in slot '${t}' failed to mount`,e),h(`Recomputing configuration after '${r}' failed to mount also failed`)}),l.unmountPromise.then(()=>h(`Recomputing configuration after unmounting '${r}' failed`),e=>{console.error(`Extension '${r}' in slot '${t}' failed to unmount`,e),h(`Recomputing configuration after '${r}' failed to unmount also failed`)})}}else console.warn(`Tried to render ${r} into ${t} but no DOM element was available.`);return l}var fV=n(35399),fU=n.n(fV);let fW=(0,fV.createContext)({moduleName:"",featureName:""});function fK({to:e,templateParams:t,onBeforeNavigate:n,children:r,...o}){return(0,fV.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}`)},[]),fU().createElement("a",{onClick:r=>{0===r.button&&!r.ctrlKey&&!r.shiftKey&&!r.altKey&&!r.metaKey&&(r.preventDefault(),n?.(r),oD({to:e,templateParams:t})),0===r.button&&(r.ctrlKey||r.metaKey)&&n?.(r),0===r.button&&r.shiftKey&&n?.(r),1===r.button&&n?.(r)},href:oS(e,t),...o},r)}let fz=({state:e,children:t,...n})=>{let{extension:r}=(0,fV.useContext)(fW),o=(0,fV.useRef)(null),i=(0,fV.useRef)(Promise.resolve()),a=(0,fV.useRef)(!1),s=(0,fV.useRef)(!1),l=(0,fV.useRef)(e),u=(0,fV.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,fV.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 '${r?.extensionId}' failed to update`,e)}))},[]),d=(0,fV.useCallback)(t=>{t&&!o.current&&!s.current&&r?.extensionSlotName&&r.extensionSlotModuleName&&(s.current=!0,fB(t,r.extensionSlotName,r.extensionSlotModuleName,r.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,fV.useEffect)(()=>(a.current=!1,()=>{a.current=!0,u(o.current)}),[]),(0,fV.useEffect)(()=>{l.current=e,o.current&&c(o.current,e)},[e]),r?fU().createElement("div",{ref:d,"data-extension-id":r?.extensionId,style:{position:"relative"},...n}):null};function fH(e){let t=(0,fV.useRef)(e);return F(t.current,e)||(t.current=e),t.current}function fG(e,t){"function"==typeof t&&(t=t(e));let n={};for(let[r,o]of Object.entries(t)){let t=function(...t){e.setState(e=>o(e,...t))};n[r]=t}return n}let fq=e=>e;function fZ(e,t=fq,n){let r=(0,fV.useCallback)(t=>e.subscribe(t),[e]),o=(0,fV.useCallback)(()=>t(e.getState()),[e,t]),i=(0,fV.useSyncExternalStore)(r,o,o),a=(0,fV.useMemo)(()=>n?fG(e,n):null,[e,n]);return(0,fV.useMemo)(()=>a?{...i,...a}:i,[i,a])}function fY(e,t){return fZ(e,fq,t)}function fJ(e){return function(t){let n=(0,fV.useCallback)(t=>e.subscribe(t),[]),r=(0,fV.useCallback)(()=>e.getState(),[]),o=(0,fV.useSyncExternalStore)(n,r,r),i=(0,fV.useMemo)(()=>t?fG(e,t):null,[t]);return(0,fV.useMemo)(()=>i?{...o,...i}:o,[o,i])}}let fQ=[];Object.freeze(fQ);let fX={candidateExtensions:fQ};Object.freeze(fX);let f0=e=>{let t=(0,fV.useCallback)(t=>t.slots?.[e]??fX,[e]);return fZ(dU(),t)},f1=e=>e.session;function f2(e,t){let{candidateExtensions:n}=f0(e),r=fZ(oU,f1),o=fH(t);return(0,fV.useMemo)(()=>fu(e,o),[e,o,r,n])}function f4(e,t){let{moduleName:n}=(0,fV.useContext)(fW);if(!n)throw Error("ComponentContext has not been provided. This should come from @openmrs/esm-react-utils.");return(0,fV.useEffect)(()=>{fd(n,e)},[n,e]),{extensions:f2(e,t),extensionSlotName:e,extensionSlotModuleName:n}}function f3(e){return e}function f6({name:e,extensionSlotName:t,select:n=f3,children:r,state:o,style:i,...a}){if(r&&o)throw Error("Both children and state have been provided. If children are provided, the state must be passed as a prop to the `Extension` component.");let s=e??t,l=(0,fV.useRef)(null),{extensions:u,extensionSlotModuleName:c}=f4(s,o),d=(0,fV.useMemo)(()=>n(u),[n,u]),f=(0,fV.useMemo)(()=>{if("function"==typeof r&&!fU().isValidElement(r))return d.map(e=>r(e,o))},[r,d]);return fU().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)=>fU().createElement(fW.Provider,{key:e.id,value:{moduleName:c,featureName:"",extension:{extensionId:e.id,extensionSlotName:s,extensionSlotModuleName:c}}},f?.[t]??("function"!=typeof r?r:null)??fU().createElement(fz,{state:o}))))}var f5=n(25873);function f7(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function f9(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?f7(Object(n),!0).forEach(function(t){var r,o,i;r=e,o=t,i=n[t],o in r?Object.defineProperty(r,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[o]=i}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):f7(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function f8(e){return(f8="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 pe(e){return(pe="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 pt(e,t){var n;if("function"!=typeof(n=t.domElement?function(){return t.domElement}:t.domElementGetter?t.domElementGetter:e.domElementGetter?e.domElementGetter:function(e){var t=e.appName||e.name;if(!t)throw Error("single-spa's dom-element-getter-helpers was not given an application name as a prop, so it can't make a unique dom element container for the react application");var n="single-spa-application:".concat(t);return function(){var e=document.getElementById(n);return e||((e=document.createElement("div")).id=n,document.body.appendChild(e)),e}}(t)))throw Error("single-spa's dom-element-getter-helpers was given an invalid domElementGetter for application or parcel '".concat(t.name,"'. Expected a function, received ").concat(pe(n)));return function(){var e=n(t);if(!(e instanceof HTMLElement))throw Error("single-spa's dom-element-getter-helpers: domElementGetter returned an invalid dom element for application or parcel '".concat(t.name,"'. Expected HTMLElement, received ").concat(pe(e)));return e}}var pn=null;try{pn=require("react").createContext()}catch(e){}var pr={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 po(e,t){return e.rootComponent?Promise.resolve():e.loadRootComponent(t).then(function(t){e.rootComponent=t})}function pi(e,t){return new Promise(function(n,r){e.suppressComponentDidCatchWarning||!function(e){if(!(e&&"string"==typeof e.version&&e.version.indexOf(".")>=0))return!1;var t=e.version.slice(0,e.version.indexOf("."));try{return Number(t)>=16}catch(e){return!1}}(e.React)||e.errorBoundary||e.errorBoundaryClass||(e.rootComponent.prototype?e.rootComponent.prototype.componentDidCatch||console.warn("single-spa-react: ".concat(t.name||t.appName||t.childAppName,"'s rootComponent should implement componentDidCatch to avoid accidentally unmounting the entire single-spa application.")):console.warn("single-spa-react: ".concat(t.name||t.appName||t.childAppName,"'s rootComponent does not implement an error boundary. If using a functional component, consider providing an opts.errorBoundary to singleSpaReact(opts).")));var o,i=pu(e,t,function(){n(this)}),a=pt(e,t)(),s=function(e){var t=e.reactDom,n=e.renderType,r=e.elementToRender,o=e.domElement,i=t[n];if("function"!=typeof i)throw Error('renderType "'.concat(n,'" did not return a function.'));switch(n){case"createRoot":case"unstable_createRoot":case"createBlockingRoot":case"unstable_createBlockingRoot":var a=i(o);return a.render(r),a;case"hydrateRoot":return i(o,r);default:return i(r,o),null}}({elementToRender:i,domElement:a,reactDom:pl(e),renderType:"function"==typeof(o=e).renderType?o.renderType():o.renderType});e.domElements[t.name]=a,e.renderResults[t.name]=s})}function pa(e,t){return new Promise(function(n){e.unmountResolves[t.name]=n;var r=e.renderResults[t.name];r&&r.unmount?r.unmount():pl(e).unmountComponentAtNode(e.domElements[t.name]),delete e.domElements[t.name],delete e.renderResults[t.name]})}function ps(e,t){return new Promise(function(n){e.updateResolves[t.name]||(e.updateResolves[t.name]=[]),e.updateResolves[t.name].push(n);var r=pu(e,t,null),o=e.renderResults[t.name];if(o&&o.render)o.render(r);else{var i=pt(e,t)();pl(e).render(r,i)}})}function pl(e){return e.ReactDOMClient||e.ReactDOM}function pu(e,t,n){var r=e.React.createElement(e.rootComponent,t),o=pn?e.React.createElement(pn.Provider,{value:t},r):r;return(e.errorBoundary||t.errorBoundary||e.errorBoundaryClass||t.errorBoundaryClass)&&(e.errorBoundaryClass=e.errorBoundaryClass||t.errorBoundaryClass||function(e,t){function n(t){e.React.Component.apply(this,arguments),this.state={caughtError:null,caughtErrorInfo:null},n.displayName="SingleSpaReactErrorBoundary(".concat(t.name,")")}return n.prototype=Object.create(e.React.Component.prototype),n.prototype.render=function(){return this.state.caughtError?(e.errorBoundary||t.errorBoundary)(this.state.caughtError,this.state.caughtErrorInfo,this.props):this.props.children},n.prototype.componentDidCatch=function(e,t){this.setState({caughtError:e,caughtErrorInfo:t})},n}(e,t),o=e.React.createElement(e.errorBoundaryClass,t,o)),o=e.React.createElement(e.SingleSpaRoot,f9(f9({},t),{},{mountFinished:n,updateFinished:function(){e.updateResolves[t.name]&&(e.updateResolves[t.name].forEach(function(e){return e()}),delete e.updateResolves[t.name])},unmountFinished:function(){e.unmountResolves[t.name]&&(e.unmountResolves[t.name](),delete e.unmountResolves[t.name])}}),o)}var pc=n(27807),pd=n(71123),pf=n(43432);let pp={strictMode:!0,throwErrorsToConsole:!0,disableTranslations:!1},ph=new Map;(0,pf.initCache)(ph);let pm={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:()=>ph};function py(e){if("object"!=typeof e||"string"!=typeof e.featureName||"string"!=typeof e.moduleName)throw Error("Invalid options");let t=Object.assign({},pp,e),n={...pm,...t.swrConfig};return function(e){var r,o,i,a,s;return i=o=class extends(r=fU().Component){componentDidCatch(e,n){n&&n.componentStack&&(e.extra=Object.assign(e.extra||{},{componentStack:n.componentStack})),t.throwErrorsToConsole&&setTimeout(()=>{throw e}),this.setState({caughtError:e,caughtErrorInfo:n})}render(){if(this.state.caughtError)return fU().createElement("div",null,"An error has occurred. Please try reloading the page.");{let r=fU().createElement(fV.Suspense,{fallback:null},fU().createElement(pd.BE,{value:n},fU().createElement(fW.Provider,{value:this.state.config},t.disableTranslations?fU().createElement(e,this.props):fU().createElement(pc.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},fU().createElement(e,this.props)))));return t.strictMode&&fU().StrictMode?fU().createElement(fU().StrictMode,null,r):r}}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 pg(e,t){return function(e){if("object"!==f8(e))throw Error("single-spa-react requires a configuration object");var t,n=f9(f9({},pr),e);if(!n.React)throw Error("single-spa-react must be passed opts.React");if(!n.ReactDOM&&!n.ReactDOMClient)throw Error("single-spa-react must be passed opts.ReactDOM or opts.ReactDOMClient");if(n.renderType||(null!=(t=n.ReactDOMClient)&&t.createRoot?n.renderType="createRoot":n.renderType="render"),!n.rootComponent&&!n.loadRootComponent)throw Error("single-spa-react must be passed opts.rootComponent or opts.loadRootComponent");if(n.errorBoundary&&"function"!=typeof n.errorBoundary)throw Error("The errorBoundary opt for single-spa-react must either be omitted or be a function that returns React elements");!pn&&n.React.createContext&&(pn=n.React.createContext()),n.SingleSpaRoot=function(e){function t(e){t.displayName="SingleSpaRoot(".concat(e.name,")")}return t.prototype=Object.create(e.React.Component.prototype),t.prototype.componentDidMount=function(){setTimeout(this.props.mountFinished)},t.prototype.componentWillUnmount=function(){setTimeout(this.props.unmountFinished)},t.prototype.render=function(){return setTimeout(this.props.updateFinished),this.props.children},t}(n);var r={bootstrap:po.bind(null,n),mount:pi.bind(null,n),unmount:pa.bind(null,n)};return n.parcelCanUpdate&&(r.update=ps.bind(null,n)),r}({React:fU(),ReactDOMClient:f5,rootComponent:py(t)(e)})}function pb(e,t){return()=>e().then(({default:e})=>pg(e,t))}function pv(e,t){return()=>Promise.resolve(pg(e,t))}let pw=pb,p_=W()(()=>({}));Y("openmrs-app-context",p_);let px={};function pS(e,t=e=>e){let n=p_.getState();return e in n?Object.freeze(Object.assign({},t?t(n[e]):n[e])):null}function pE(e,t){p_.setState(n=>(e in n||(n[e]={}),n[e]=t(n[e]),Object.assign({},n)))}function pD(e){return null===e?null:Object.freeze(Object.assign({},e))}let pO=new Map;function pk(e,t){let n=(0,fV.useRef)(t??{}),r=(0,fV.useRef)(t=>pE(e,t)),o=(0,fV.useRef)(Symbol());return(0,fV.useEffect)(()=>{let n=t??{},r=o.current;return null===pS(e)?!function(e,t=px){p_.setState(n=>{if(e in n)throw Error(`Attempted to re-register namespace ${e} in the app context. Each namespace must be unregistered before the name can be registered again.`);return Object.assign({},n,{[e]:t===px?{}:t})})}(e,n):(console.warn(`Namespace ${e} is already registered in the app context. This is likely a race condition during navigation, but may indicate two components are trying to own the same namespace. Updating the existing context.`),pE(e,()=>n)),pO.set(e,r),()=>{pO.get(e)===r&&(p_.setState(t=>(e in t&&delete t[e],t)),pO.delete(e))}},[e]),(0,fV.useEffect)(()=>{let r=t??{};F(n.current,r)||(pE(e,()=>r),n.current=r)},[t]),r.current}function pP({namespace:e,value:t}){return pk(e,t),null}let pC=({children:e,value:t,fallback:n})=>t?fU().createElement(fU().Fragment,null,e):n?fU().createElement(fU().Fragment,null,n):null;function pj(){let e=(0,fV.useRef)();return(!e.current||e.current.signal.aborted)&&(e.current=new AbortController),(0,fV.useEffect)(()=>{let t=e.current;return()=>t?.abort()},[]),e.current}function pT(e,t=e=>e??{}){let[n,r]=(0,fV.useState)(()=>{if(pR(e))return;let n=pS(e);if(null!==n)return t?t(n):n});return(0,fV.useEffect)(()=>{if(pR(e))throw Error(`The namespace supplied to useAppContext must be a non-empty string, but was "${e}".`)},[e]),(0,fV.useEffect)(()=>{var n;let o;return(n=e=>{if(null==e)return void r(void 0);let n=t?t(e):e;r(e=>F(e,n)?e:n)})(pD(o=pS(e))),p_.subscribe(t=>{let r=e in t?t[e]:null;r!==o&&(o=r,n(pD(r)))})},[e,t]),n}function pR(e){return"string"!=typeof e||0===e.trim().length}function pA(e){let t=f2(e);return(0,fV.useMemo)(()=>t.map(e=>e.id),[t])}function pN(e){return f0(e).candidateExtensions}function pM(e,t){let{data:n,error:r,mutate:o,isLoading:i,isValidating:a}=(0,pd.Ay)(`${aD}?patient=${e}&includeEncounterless=${t}`,oF);return(0,fV.useMemo)(()=>({isLoading:i,data:n?.data.results??[],error:r,mutate:o,isValidating:a}),[n,r,i,a,o])}function pI(e){(0,fV.useEffect)(()=>{if(e){let e=window.getComputedStyle(document.body).overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=e}}},[e])}let p$={},pL=`No ComponentContext has been provided. This should come from "openmrsComponentDecorator".
16
16
  Usually this is already applied when using "getAsyncLifecycle" or "getSyncLifecycle".`;function pF(e){let{moduleName:t,extension:n}=(0,fV.useContext)(fW),r=e?.externalModuleName??t;if(!r&&!n)throw Error(pL);let o=function(e){let t=(0,fV.useMemo)(()=>t3(e),[e]),n=function(e){let[t,n]=(0,fV.useState)(()=>{let t=e.getState();return t.loaded&&t.config?t.config:null});return(0,fV.useEffect)(()=>e?.subscribe(e=>{e.loaded&&e.config&&n(e.config)}),[e]),t}(t);if(!n)throw p$[e]||(p$[e]=new Promise(e=>{let n=t.subscribe(t=>{t.loaded&&t.config&&(e(t.config),n())})})),p$[e];return n}(r),i=function(e){let t=(0,fV.useMemo)(t9,[]),n=function(e,t){let[n,r]=(0,fV.useState)(t?()=>{let n=ne(e.getState(),t.extensionSlotName,t.extensionId);if(n.loaded&&n.config)return n.config}:null);return(0,fV.useEffect)(()=>{if(t)return e.subscribe(e=>{let o=ne(e,t.extensionSlotName,t.extensionId);o.loaded&&o.config&&!tm(o.config,n)&&r(o.config)})},[e,t,n]),n}(t,e);if(!n&&e){let n=`${e.extensionSlotName}-${e.extensionId}`;throw!p$[n]&&t&&(p$[n]=new Promise(n=>{let r=t.subscribe(t=>{let o=ne(t,e.extensionSlotName,e.extensionId);o.loaded&&o.config&&(n(o.config),r())})})),p$[n]}return n||{}}(n);return(0,fV.useMemo)(()=>e?.externalModuleName&&r===e.externalModuleName?{...o}:{...o,...i},[r,e?.externalModuleName,o,i])}let pB=f2;function pV(){let[e,t]=(0,fV.useState)(dk());return(0,fV.useEffect)(()=>b(({online:e})=>t(e)),[]),e}function pU(e,t=300){let[n,r]=(0,fV.useState)(e);return(0,fV.useEffect)(()=>{let n=setTimeout(()=>{r(e)},t);return()=>{clearTimeout(n)}},[e,t]),n}var pW=n(13660),pK=n.n(pW);let pz=`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 pH(){let e=`${oM}/emrapi/configuration?v=${pz}`,t=pK()(e,oF);return(0,fV.useMemo)(()=>({emrConfiguration:t.data?.data,isLoadingEmrConfiguration:t.isLoading,mutateEmrConfiguration:t.mutate,errorFetchingEmrConfiguration:t.error}),[t])}let pG=fJ(dA());function pq(e){let t=f2(e);return(0,fV.useMemo)(()=>Object.fromEntries(t.map(e=>[e.name,e.meta])),[t])}let pZ=fJ(dU());function pY(e){let{flags:t}=fZ(d_);return t[e]?.enabled??!1}function pJ(){let[,e]=(0,fV.useState)(0);return(0,fV.useCallback)(()=>{e(e=>e+1)},[])}function pQ(e,t,n={}){return p0(e,t,pX,n)}let pX={getPaginatedUrl:(e,t,n)=>{if(!e)return null;{let r=new URL(oL(e.toString()),window.location.toString());return r.searchParams.set("limit",""+t),r.searchParams.set("startIndex",""+n),r.searchParams.set("totalCount","true"),r.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 p0(e,t,n,r={}){let{getPaginatedUrl:o,getTotalCount:i,getCurrentPageSize:a,getData:s}=n,{immutable:l,swrConfig:u}=r,c=r.fetcher??oF,[d,f]=(0,fV.useState)(1),p=(0,fV.useRef)(NaN),h=(0,fV.useRef)(NaN),m=(0,fV.useRef)(d),y=(0,fV.useRef)(!1),g=(0,fV.useRef)(!1),b=e?.toString()??"",[v,w]=(0,fV.useState)(b);b!==v&&(w(b),f(1),m.current=1,p.current=NaN,h.current=NaN,y.current=!1,g.current=!1);let x=(d-1)*t,S=(0,fV.useMemo)(()=>o(e,t,x),[e,t,x]),{data:E,...D}=(l?pK():pd.Ay)(S,c,u);E?.data&&(p.current=i(E?.data),h.current=a(E?.data),y.current=!0);let O=Math.ceil(p.current/t),k=(0,fV.useCallback)(e=>{if(!Number.isInteger(e)||e<1)return void console.warn(`useServerPagination: ignoring goTo(${e}); page must be a positive integer.`);let n=Math.ceil(p.current/t);!y.current||Number.isNaN(n)||e<=n?(m.current=e,f(e)):console.warn("Invalid attempt to go to out of bounds page: "+e)},[t]);(0,fV.useEffect)(()=>{if(!y.current)return;if(Number.isNaN(p.current)){g.current||(g.current=!0,console.warn(`useServerPagination: ${b} returned no total count, so out-of-range pages cannot be detected.`));return}let e=Math.max(1,Math.ceil(p.current/t));d>e&&(console.warn(`Invalid attempt to go to out of bounds page: ${d}; returning to page ${e}.`),m.current=e,f(e))},[d,t,b,E]);let P=(0,fV.useCallback)(()=>{k(m.current+1)},[k]),C=(0,fV.useCallback)(()=>{k(m.current-1)},[k]);return{data:s(E?.data),totalPages:O,totalCount:p.current,currentPage:d,currentPageSize:h.current,paginated:O>1,showNextButton:d<O,showPreviousButton:d>1,goTo:k,goToNext:P,goToPrevious:C,...D}}function p1(e,t,n={}){return p0(e,t,p2(),n)}function p2(){return{getPaginatedUrl:(e,t,n)=>{if(!e)return null;{let r=new URL(oL(e.toString()),window.location.toString());return r.searchParams.set("_count",""+t),r.searchParams.set("_getpagesoffset",""+n),r.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 p4=n(30682),p3=n.n(p4);function p6(e,t={}){return p5(e,pX,t)}function p5(e,t,n={}){let{swrInfiniteConfig:r,immutable:o}=n,{getNextUrl:i,getTotalCount:a,getData:s}=t,l=n.fetcher??oF,u=(0,fV.useCallback)((n,r)=>0==n?e?.toString()??null:t.getNextUrl(r.data),[e]),{data:c,size:d,setSize:f,...p}=p3()(u,l,{...r,...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:()=>{f((c?.length??0)+1)},nextUri:h,...p}}function p7(e,t={}){return p9(e,pX,t)}function p9(e,t,n={}){let r=p5(e,t,n),{hasMore:o,error:i,data:a,loadMore:s,isLoading:l,nextUri:u}=r;return((0,fV.useEffect)(()=>{o&&!i&&s()},[o,u]),n.partialData)?r:{...r,data:o||i?void 0:a,isLoading:l||o}}function p8(e,t={}){return p9(e,p2(),t)}function he(e,t={}){return p5(e,p2(),t)}function ht(){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 hn(){let[e,t]=(0,fV.useState)(ht);return(0,fV.useEffect)(()=>{let e=()=>{t(ht())};return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),e}let hr=e=>"small-desktop"===e||"large-desktop"===e;function ho(e){let t=(0,fV.useContext)(fW);(0,fV.useEffect)(()=>(t&&t.moduleName&&(e.componentContext=t),fh(e),()=>{fm(e.name)}),[t,e])}function hi(){return fZ(fp)}function ha(e=null,t=null){let[n,r]=(0,fV.useState)([]);return(0,fV.useEffect)(()=>{let n=cW(e,t).subscribe(e=>{r(e)},e=>{console.error(e)});return()=>n.unsubscribe()},[e,t]),n}function hs(e,t=!0){let n=(0,fV.useRef)(null);return(0,fV.useEffect)(()=>{let r=r=>{t&&n.current&&r.target&&r.target instanceof Node&&(n.current.contains(r.target)||e(r))};return window.addEventListener("mousedown",r),window.addEventListener("touchstart",r),()=>{window.removeEventListener("mousedown",r),window.removeEventListener("touchstart",r)}},[e,t]),n}function hl(e){let t=(0,fV.useRef)();return(0,fV.useEffect)(()=>{let n=new IntersectionObserver(t=>{for(let n of t)if(n.isIntersecting)return void e()},{threshold:1});return t.current&&n.observe(t.current),()=>{t.current&&n.unobserve(t.current)}},[t.current,e]),t}function hu(e,t={}){let{abortController:n,fetchInit:r,url:o,swrConfig:i}=t,a=pj(),s=(0,fV.useMemo)(()=>r?.signal??n?.signal??a.signal,[n?.signal,r?.signal,a.signal]),l=(0,fV.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),{...r,signal:s}),[s,r,o]);return(0,pd.Ay)(e,l,i)}function hc(e=[],t=10){let[n,r]=(0,fV.useState)(1),o=(0,fV.useMemo)(()=>"number"==typeof t&&t>0?Math.max(1,Math.ceil(e.length/t)):1,[e.length,t]);n>o&&r(o);let i=Math.min(Math.max(1,n),o),a=(0,fV.useMemo)(()=>{let n=(i-1)*t,r=(i+0)*t;return e.slice(n,r)},[e,i,t]),s=(0,fV.useCallback)(e=>{!Number.isInteger(e)||e<1?console.warn(`usePagination: ignoring goTo(${e}); page must be a positive integer.`):r(e)},[]),l=(0,fV.useCallback)(()=>{r(e=>e+1)},[]),u=(0,fV.useCallback)(()=>{r(e=>Math.max(1,e-1))},[]);return(0,fV.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 hd(e,t,n,r){return{pageSizes:(0,fV.useMemo)(()=>{let n=Math.ceil(t/e);return isNaN(n)&&(n=0),[...Array(n).keys()].map(t=>(t+1)*e)},[e,t]),pageItemsCount:(0,fV.useMemo)(()=>e>t?t:e*n>t?e*(n-1)+r:e*n,[e,t,n,r])}}function hf(){let e=/\/patient\/([a-zA-Z0-9\-]+)\/?/.exec(location.pathname);return e&&e[1]}function hp(e){let[t,n]=(0,fV.useState)(e??hf()),{data:r,error:o,isValidating:i}=(0,pd.Ay)(t?["patient",t]:null,()=>c$(t,{}));return(0,fV.useEffect)(()=>{let e=()=>{let e=hf();e!==t&&n(e)};return window.addEventListener("single-spa:routing-event",e),()=>window.removeEventListener("single-spa:routing-event",e)},[t]),(0,fV.useMemo)(()=>({isLoading:i&&!o&&!r,patient:r,patientUuid:t,error:o}),[i,o,r,t])}function hh(){let e=`${oM}/metadatamapping/termmapping?v=custom:(metadataUuid)&code=emr.primaryIdentifierType`,{data:t,error:n,isLoading:r}=(0,pd.Ay)(e,oF);return(0,fV.useMemo)(()=>({primaryIdentifierCode:t?.data?.results[0]?.metadataUuid,isLoading:r,error:n}),[t,n,r])}function hm(e){let{extensions:t,extensionSlotModuleName:n}=f4(e);return e?t.map(t=>({state:r})=>fU().createElement(fW.Provider,{value:{moduleName:n,featureName:"",extension:{extensionId:t.id,extensionSlotName:e,extensionSlotModuleName:n}}},fU().createElement(fz,{state:r}))):[]}function hy(){let e=(0,fV.useRef)(),[t,n]=(0,fV.useState)(null),r=null;if(!t){if(s){let e=oz().getState();e.loaded&&(r=e.session)}else s=new Promise(t=>{let n=({loaded:n,session:o})=>{n&&(t(o),r=o,e.current&&(e.current(),e.current=void 0))};n(oz().getState()),r||(e.current=oz().subscribe(n))});if(r)n(r);else throw s}(0,fV.useEffect)(()=>(e.current||(e.current=oz().subscribe(({loaded:e,session:t})=>{e&&(r=t,n(t))})),()=>{e.current&&(e.current(),e.current=void 0)}),[]);let o=t||r;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 hg=({privilege:e,fallback:t,children:n})=>{let[r,o]=(0,fV.useState)(null);return((0,fV.useEffect)(()=>{let e=oK({includeAuthStatus:!1}).subscribe(o);return()=>e.unsubscribe()},[]),r&&oZ(e,r))?fU().createElement(fU().Fragment,null,n):t?fU().createElement(fU().Fragment,null,t):null};var hb=n(80222),hv=n.n(hb),hw=n(85602);let h_=new Map;function hx(){for(let e of Array.from(h_.values()))e()}let hS={setVisitContext:(e,t)=>null==t?{manuallySetVisitUuid:null}:{manuallySetVisitUuid:t.uuid,patientUuid:t.patient?.uuid}};function hE(e){let t=(0,fV.useId)();return(0,fV.useEffect)(()=>{if(e)return h_.set(t,e),()=>{h_.delete(t)}},[t,e]),{...fY(cJ(),hS),mutateVisit:hx}}function hD(e,t=cZ){let n=(0,fV.useRef)(void 0),{patientUuid:r,manuallySetVisitUuid:o,setVisitContext:i}=hE((0,fV.useCallback)(()=>n.current?.(),[])),a=e&&r==e?o:null,s=`?patient=${e}&v=${t}&includeInactive=false`,l=`/${a}?v=${t}`,{data:u,error:c,mutate:d,isValidating:f}=(0,pd.Ay)(e?`${oM}/visit${s}`:null,oF),{data:p,error:h,mutate:m,isValidating:y}=(0,pd.Ay)(e&&a?`${oM}/visit${l}`:null,oF),g=(0,fV.useMemo)(()=>u?.data.results.find(e=>null===e.stopDatetime)??null,[u]),b=(0,fV.useMemo)(()=>a&&p?p.data:null,[p,a]),v=(0,fV.useRef)(null);(0,fV.useEffect)(()=>{!f&&g&&r===e&&null===o&&i(g),y||(v.current&&b&&v.current.uuid===b.uuid&&!v.current.stopDatetime&&b.stopDatetime&&i(null),v.current=b)},[b,o,g,f,y,r]);let w=(0,fV.useCallback)(()=>{d(),m()},[d,m]);(0,fV.useEffect)(()=>{n.current=w},[w]);let x=!!(!u||a&&!p),S=!!(a?h:c);return{error:c||h,mutate:w,isValidating:f||y,activeVisit:g,currentVisit:b,currentVisitIsRetrospective:!!a,isLoading:x&&!S}}function hO(){let[e,t]=(0,fV.useState)([]);return(0,fV.useEffect)(()=>{let e=cz().subscribe(e=>{t(e)},e=>console.error(e));return()=>e.unsubscribe()},[]),e}hv().extend(hw);let hk=new Map;async function hP(e,t){let n=t.indexOf("#"),r=n>=0,o=r?t.substring(0,n):e,i=r?t.substring(n+1):t,a=await at(o);return a&&Object.hasOwn(a,i)&&"function"==typeof a[i]?hj(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`),hC)}let hC={bootstrap:()=>Promise.resolve(),mount:()=>Promise.resolve(),unmount:()=>Promise.resolve()};async function hj(e,t){if(e in hk)await hk[e];else{let n=t??await at(e);await (hk[e]=new Promise((t,r)=>{if(Object.hasOwn(n,"startupApp")){let o=n.startupApp;if("function"==typeof o)return Promise.resolve(o()).then(()=>{n_(e),t(null)}).catch(r)}n_(e),t(null)}))}}function hT(e,t){let n=t.name;if(!n)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 ${n} from ${e} declares both a 'slots' property and