@openmrs/esm-stock-management-app 3.2.2-pre.1589 → 3.2.2-pre.1593

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/1170.js CHANGED
@@ -9,7 +9,7 @@ If you're the maintainer: the allowed types are ${Object.values(nG).join(", ")}.
9
9
  If you're the maintainer: all config elements must have a default. Received ${JSON.stringify(i)}`),s&&l&&![nG.Array,nG.Object].includes(l)&&console.error(`${e} has bad config schema definition for key '${r}'. ${a}.
10
10
 
11
11
  If you're the maintainer: the 'elements' key only works with '_type' equal to 'Array' or 'Object'. Received ${JSON.stringify(l)}`)}}function tm(e,n){return th(n.map(({[e]:n})=>n).filter(e=>!!e))}function th(e){return e.reduce((e,n)=>n9(e,n),{})}function tg(e,n,t=""){for(let a of Object.keys(n)){let o=n[a],r=t+"."+a,i=e[a];if(!e.hasOwnProperty(a)){("extensionSlots"!==a||""===t)&&tw(r,`Unknown config key '${r}' provided. Ignoring.`);continue}(function e(n,t,a){tb(a,n._type,t),tA(t)?n._type===nG.Object?function(n,t,a){if(n._elements)for(let o of Object.keys(t)){let r=t[o];e(n._elements,r,`${a}.${o}`)}}(n,t,a):n.hasOwnProperty("_default")||n.hasOwnProperty("_type")||tg(n,t,a):n._type===nG.Array&&function(n,t,a){if(tb(a,nG.Array,t)){if(t$(n._elements))for(let o=0;o<t.length;o++)e(n._elements,t[o],`${a}[${o}]`);for(let e=0;e<t.length;e++)tb(`${a}[${e}]`,n._elements?._type,t[e])}}(n,t,a)})(i,o,r)}}tt();function ty(e,n,t=""){if(e){if(n!==e._default&&t_(t,e._validators,n),tA(n))for(let a of Object.keys(n)){let o=n[a],r=t+"."+a,i=e[a];e._type===nG.Object&&e._elements?ty(e._elements,o,r):ty(i,o,r)}else if(Array.isArray(n)&&e._elements)for(let a=0;a<n.length;a++)ty(e._elements,n[a],`${t}[${a}]`)}}function tb(e,n,t){return!n||t_(e,[{Array:nU,Boolean:nq,ConceptUuid:nJ,Number:nH,Object:nY,String:nK,UUID:nJ,PersonAttributeTypeUuid:nJ,PatientIdentifierTypeUuid:nJ}[n]],t)}function t_(e,n,t){let a=!0;if(n)try{for(let o of n){let n=o(t);if("string"==typeof n){let o="object"==typeof t?`Invalid configuration for ${e}: ${n}`:`Invalid configuration value ${t} for ${e}: ${n}`;tw(e,o),a=!1}}}catch(n){console.error(`Skipping invalid validator at "${e}". Encountered error
12
- ${n}`)}return a}let tv=(e,n)=>{let t=structuredClone(n);if(!e)return t;for(let n of Object.keys(e)){let a=t[n],o=e[n];if(o&&(o.hasOwnProperty("_type")||o.hasOwnProperty("_default"))){t.hasOwnProperty(n)||(t[n]=o._default);let e=o._elements;if(a&&t$(e)){if(o._type===nG.Array&&Array.isArray(a)){let o=a.map(n=>tv(e,n));t[n]=o}else if(o._type===nG.Object)for(let n of Object.keys(a))a[n]=tv(e,a[n])}}else if(tA(o)){let e=a??{};tA(e)&&(t[n]=tv(o,e))}}return t};function t$(e){return!!e&&Object.keys(e).filter(e=>!["_default","_validators"].includes(e)).length>0}function tA(e){return"object"==typeof e&&!Array.isArray(e)&&null!==e}let tk=new Set;function tw(e,n){let t=`${e}:::${n}`;tk||(tk=new Set),tk.has(t)||(console.error(n),tk.add(t))}function tx(e){e?tk.forEach(n=>{n.startsWith(e)&&tk.delete(n)}):tk.clear()}function tC(){te.forEach(e=>e()),te.length=0,tt()}let tE={"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:nG.Object,_default:{},_validators:[nV(e=>Object.keys(e).every(e=>/^[a-z]{2,3}(-[A-Z]{2,3})?$/.test(e)),e=>{let n=Object.keys(e).filter(e=>!/^[a-z]{2,3}(-[A-Z]{2,3})?$/.test(e));return`The 'Translation overrides' object should have language codes for keys. Language codes must be in the form of a two-to-three letter language code optionally followed by a hyphen and a two-to-three letter country code. The following keys do not conform: ${n.join(", ")}.`})]}},tS={"Display conditions":{privileges:{_description:"The privilege(s) the user must have to use this extension",_type:nG.Array,_default:[]},expression:{_description:"The expression that determines whether the extension is displayed",_type:nG.String,_default:void 0}},...tE},tD=(e,n)=>nV(t=>e<=t&&t<=n,`must be between ${e} and ${n}`),tM=e=>{let n=e.concat(["openmrsBase","openmrsSpaBase"]);return nV(e=>{if(!e||"string"!=typeof e)return!1;let t=/\${(.*?)}/g,a=t.exec(e);for(;a;){if(!n.includes(a[1]))return!1;a=t.exec(e)}return!0},"Should be a URL or path. The allowed template parameters are "+n.map(e=>"${"+e+"}").join(", "))},tz=tM([]),tO=e=>nV(n=>e.includes(n),`Must be one of the following: '${e.join("', '")}'.`),tP={inRange:tD,isUrl:tz,isUrlWithTemplateParameters:tM,oneOf:tO};var tT=t(48067);let tB=V("breadcrumbs",[]);function tI(e){return tN([e])}function tN(e){let n=[...tj(),...e.map(e=>({matcher:e.matcher instanceof RegExp?e.matcher:"string"==typeof e.matcher?(0,tT.pathToRegexp)(e.matcher).regexp:(0,tT.pathToRegexp)(e.path).regexp,settings:e}))];tB.setState(n,!0)}function tj(){return tB.getState()}function tR(e,n){if(n)return function(e,n){let[t]=e.filter(e=>e.matcher.test(n));return t}(e,n)||function(e,n){let t=n.split("/");for(;t.length>1;){t.pop();let n=tR(e,t.join("/"));if(n)return n}}(e,n)}function tF(e,n){if(e.length>0){let t=tR(e,n);if(t){let n=[t],a=tR(e,t.settings.parent);for(;void 0!==a;)n.push(a),a=tR(e,a.settings.parent);return n.reverse()}}return[]}function tL(e){return tF(tj(),e)}var tW=Object.freeze({__proto__:null,get start(){return ot},get ensureJQuerySupport(){return aL},get setBootstrapMaxTime(){return aA},get setMountMaxTime(){return ak},get setUnmountMaxTime(){return aw},get setUnloadMaxTime(){return ax},get registerApplication(){return aX},get unregisterApplication(){return a0},get getMountedApps(){return aK},get getAppStatus(){return aJ},get unloadApplication(){return a1},get checkActivityFunctions(){return aQ},get getAppNames(){return aY},get pathToActiveWhen(){return a5},get navigateToUrl(){return aO},get patchHistoryApi(){return aj},get triggerAppChange(){return a7},get addErrorHandler(){return tH},get removeErrorHandler(){return tK},get mountRootParcel(){return ay},get NOT_LOADED(){return tZ},get LOADING_SOURCE_CODE(){return tX},get NOT_BOOTSTRAPPED(){return tQ},get BOOTSTRAPPING(){return t0},get NOT_MOUNTED(){return t1},get MOUNTING(){return t2},get UPDATING(){return t5},get LOAD_ERROR(){return t8},get MOUNTED(){return t3},get UNLOADING(){return t6},get UNMOUNTING(){return t4},get SKIP_BECAUSE_BROKEN(){return t7}}),tG=("u">typeof globalThis?globalThis:"u">typeof window?window:"u">typeof global?global:"u">typeof self?self:{}).CustomEvent,tV=!function(){try{var e=new tG("cat",{detail:{foo:"bar"}});return"cat"===e.type&&"bar"===e.detail.foo}catch(e){}return!1}()?"u">typeof document&&"function"==typeof document.createEvent?function(e,n){var t=document.createEvent("CustomEvent");return n?t.initCustomEvent(e,n.bubbles,n.cancelable,n.detail):t.initCustomEvent(e,!1,!1,void 0),t}:function(e,n){var t=document.createEventObject();return t.type=e,n?(t.bubbles=!!n.bubbles,t.cancelable=!!n.cancelable,t.detail=n.detail):(t.bubbles=!1,t.cancelable=!1,t.detail=void 0),t}:tG;let tU=[];function tq(e,n,t){let a=tJ(e,n,t);tU.length?tU.forEach(e=>e(a)):setTimeout(()=>{throw a})}function tH(e){if("function"!=typeof e)throw Error(tY(28,!1));tU.push(e)}function tK(e){if("function"!=typeof e)throw Error(tY(29,!1));let n=!1;return tU=tU.filter(t=>{let a=t===e;return n=n||a,!a}),n}function tY(e,n,...t){return`single-spa minified message #${e}: ${n?n+" ":""}See https://single-spa.js.org/error/?code=${e}${t.length?`&arg=${t.join("&arg=")}`:""}`}function tJ(e,n,t){let a,o=`${aa(n)} '${an(n)}' died in status ${n.status}: `;if(e instanceof Error){try{e.message=o+e.message}catch(e){}a=e}else{console.warn(tY(30,!1,n.status,an(n)));try{a=Error(o+JSON.stringify(e))}catch(n){a=e}}return a.appOrParcelName=an(n),n.status=t,a}let tZ="NOT_LOADED",tX="LOADING_SOURCE_CODE",tQ="NOT_BOOTSTRAPPED",t0="BOOTSTRAPPING",t1="NOT_MOUNTED",t2="MOUNTING",t3="MOUNTED",t5="UPDATING",t4="UNMOUNTING",t6="UNLOADING",t8="LOAD_ERROR",t7="SKIP_BECAUSE_BROKEN";function t9(e){return e.status===t3}function ae(e){try{return e.activeWhen(window.location)}catch(n){return tq(n,e,t7),!1}}function an(e){return e.name}function at(e){return!!e.unmountThisParcel}function aa(e){return at(e)?"parcel":"application"}function ao(){for(let e=arguments.length-1;e>0;e--)for(let n in arguments[e])"__proto__"!==n&&(arguments[e-1][n]=arguments[e][n]);return arguments[0]}function ar(e,n){for(let t=0;t<e.length;t++)if(n(e[t]))return e[t];return null}function ai(e){return e&&("function"==typeof e||Array.isArray(e)&&!ar(e,e=>"function"!=typeof e))}function as(e,n){let t=e[n]||[];0===(t=Array.isArray(t)?t:[t]).length&&(t=[()=>Promise.resolve()]);let a=aa(e),o=an(e);return function(e){return t.reduce((t,r,i)=>t.then(()=>{let t=r(e);return al(t)?t:Promise.reject(tY(15,!1,a,o,n,i))}),Promise.resolve())}}function al(e){return e&&"function"==typeof e.then&&"function"==typeof e.catch}let ac=[];function ap(e,n){return Promise.resolve().then(()=>e.status!==tQ?e:(e.status=t0,e.bootstrap?aC(e,"bootstrap").then(t).catch(t=>{if(n)throw tJ(t,e,t7);return tq(t,e,t7),e}):Promise.resolve().then(t)));function t(){return e.status=t1,e}}function au(e,n){return Promise.resolve().then(()=>{if(e.status!==t3)return e;return e.status=t4,Promise.all(Object.keys(e.parcels).map(n=>e.parcels[n].unmountThisParcel())).then(t,a=>t().then(()=>{let t=Error(a.message);if(n)throw tJ(t,e,t7);tq(t,e,t7)})).then(()=>e);function t(){return aC(e,"unmount").then(()=>{e.status=t1},t=>{if(n)throw tJ(t,e,t7);tq(t,e,t7)})}})}let ad=!1,af=!1;function am(e,n){return Promise.resolve().then(()=>e.status!==t1?e:(ad||(window.dispatchEvent(new tV("single-spa:before-first-mount")),ad=!0),e.status=t2,aC(e,"mount").then(()=>(e.status=t3,af||(window.dispatchEvent(new tV("single-spa:first-mount")),af=!0),e)).catch(t=>{return e.status=t3,au(e,!0).then(a,a);function a(){if(n)throw tJ(t,e,t7);return tq(t,e,t7),e}})))}let ah=0,ag={parcels:{}};function ay(){return ab.apply(ag,arguments)}function ab(e,n){let t,a,o,r=this;if(!e||"object"!=typeof e&&"function"!=typeof e)throw Error(tY(2,!1));if(e.name&&"string"!=typeof e.name)throw Error(tY(3,!1,typeof e.name));let i=ah++,s=e.name||`parcel-${i}`;if("object"!=typeof n)throw Error(tY(4,!1,s,typeof n));if(!n.domElement)throw Error(tY(5,!1,s));let l="function"==typeof e,c=l?e:()=>Promise.resolve(e),p={id:i,parcels:{},status:l?tX:tQ,customProps:n,parentName:an(r),unmountThisParcel:()=>f.then(()=>{if(p.status!==t3)throw Error(tY(6,!1,s,p.status));return au(p,!0)}).then(e=>(p.parentName&&delete r.parcels[p.id],e)).then(e=>(a(e),e)).catch(e=>{throw p.status=t7,o(e),e})};r.parcels[i]=p;let u=c();if(!u||"function"!=typeof u.then)throw Error(tY(7,!1));let d=(u=u.then(e=>{if(!e)throw Error(tY(8,!1));if(s=e.name||`parcel-${i}`,Object.prototype.hasOwnProperty.call(e,"bootstrap")&&!ai(e.bootstrap))throw Error(tY(9,!1,s));if(!ai(e.mount))throw Error(tY(10,!1,s));if(!ai(e.unmount))throw Error(tY(11,!1,s));if(e.update&&!ai(e.update))throw Error(tY(12,!1,s));let n=as(e,"bootstrap"),a=as(e,"mount"),o=as(e,"unmount");p.status=tQ,p.name=s,p.bootstrap=n,p.mount=a,p.unmount=o,p.timeouts=aE(e.timeouts),e.update&&(p.update=as(e,"update"),t.update=function(e){return p.customProps=e,a_(Promise.resolve().then(()=>{if(p.status!==t3)throw Error(tY(32,!1,an(p)));return p.status=t5,aC(p,"update").then(()=>(p.status=t3,p)).catch(e=>{throw tJ(e,p,t7)})}))})})).then(()=>ap(p,!0)),f=d.then(()=>am(p,!0)),m=new Promise((e,n)=>{a=e,o=n});return t={mount:()=>a_(Promise.resolve().then(()=>{if(p.status!==t1)throw Error(tY(13,!1,s,p.status));return r.parcels[i]=p,am(p)})),unmount:()=>a_(p.unmountThisParcel()),getStatus:()=>p.status,loadPromise:a_(u),bootstrapPromise:a_(d),mountPromise:a_(f),unmountPromise:a_(m)}}function a_(e){return e.then(()=>null)}function av(e){let n=an(e),t="function"==typeof e.customProps?e.customProps(n,window.location):e.customProps;("object"!=typeof t||null===t||Array.isArray(t))&&(t={},console.warn(tY(40,!1),n,t));let a=ao({},t,{name:n,mountParcel:ab.bind(e),singleSpa:tW});return at(e)&&(a.unmountSelf=e.unmountThisParcel),a}let a$={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 aA(e,n,t){if("number"!=typeof e||e<=0)throw Error(tY(16,!1));a$.bootstrap={millis:e,dieOnTimeout:n,warningMillis:t||1e3}}function ak(e,n,t){if("number"!=typeof e||e<=0)throw Error(tY(17,!1));a$.mount={millis:e,dieOnTimeout:n,warningMillis:t||1e3}}function aw(e,n,t){if("number"!=typeof e||e<=0)throw Error(tY(18,!1));a$.unmount={millis:e,dieOnTimeout:n,warningMillis:t||1e3}}function ax(e,n,t){if("number"!=typeof e||e<=0)throw Error(tY(19,!1));a$.unload={millis:e,dieOnTimeout:n,warningMillis:t||1e3}}function aC(e,n){let t=e.timeouts[n],a=t.warningMillis,o=aa(e);return new Promise((r,i)=>{let s=!1,l=!1;e[n](av(e)).then(e=>{s=!0,r(e)}).catch(e=>{s=!0,i(e)}),setTimeout(()=>p(1),a),setTimeout(()=>p(!0),t.millis);let c=tY(31,!1,n,o,an(e),t.millis);function p(e){s||(!0===e?(l=!0,t.dieOnTimeout?i(Error(c)):console.error(c)):!l&&(console.warn(c),e*a+a<t.millis&&setTimeout(()=>p(e+1),a)))}})}function aE(e){let n={};for(let t in a$)n[t]=ao({},a$[t],e&&e[t]||{});return n}function aS(e){return Promise.resolve().then(()=>{let n,t;return e.loadPromise?e.loadPromise:e.status!==tZ&&e.status!==t8?e:(e.status=tX,e.loadPromise=Promise.resolve().then(()=>{let a=e.loadApp(av(e));if(!al(a))throw t=!0,Error(tY(33,!1,an(e)));return a.then(t=>{let a;e.loadErrorTime=null,"object"!=typeof(n=t)&&(a=34),Object.prototype.hasOwnProperty.call(n,"bootstrap")&&!ai(n.bootstrap)&&(a=35),ai(n.mount)||(a=36),ai(n.unmount)||(a=37);let o=aa(n);if(a){let t;try{t=JSON.stringify(n)}catch(e){}return console.error(tY(a,!1,o,an(e),t),n),tq(void 0,e,t7),e}return n.devtools&&n.devtools.overlays&&(e.devtools.overlays=ao({},e.devtools.overlays,n.devtools.overlays)),e.status=tQ,e.bootstrap=as(n,"bootstrap"),e.mount=as(n,"mount"),e.unmount=as(n,"unmount"),e.unload=as(n,"unload"),e.timeouts=aE(n.timeouts),delete e.loadPromise,e})}).catch(n=>{let a;return delete e.loadPromise,t?a=t7:(a=t8,e.loadErrorTime=(new Date).getTime()),tq(n,e,a),e}))})}let aD="u">typeof window,aM={hashchange:[],popstate:[]},az=["hashchange","popstate"];function aO(e){let n;if("string"==typeof e)n=e;else if(this&&this.href)n=this.href;else{if(!(e&&e.currentTarget&&e.currentTarget.href&&e.preventDefault))throw Error(tY(14,!1));n=e.currentTarget.href,e.preventDefault()}let t=aR(window.location.href),a=aR(n);0===n.indexOf("#")?window.location.hash=a.hash:t.host!==a.host&&a.host?window.location.href=n:a.pathname===t.pathname&&a.search===t.search?window.location.hash=a.hash:window.history.pushState(null,null,n)}function aP(e){if(e){let n=e[0].type;az.indexOf(n)>=0&&aM[n].forEach(n=>{try{n.apply(this,e)}catch(e){setTimeout(()=>{throw e})}})}}function aT(){a9([],arguments)}function aB(e,n){return function(){let t=window.location.href,o=e.apply(this,arguments),r=window.location.href;return a&&t===r||window.dispatchEvent(function(e,n){let t;try{t=new PopStateEvent("popstate",{state:e})}catch(n){(t=document.createEvent("PopStateEvent")).initPopStateEvent("popstate",!1,!1,e)}return t.singleSpa=!0,t.singleSpaTrigger=n,t}(window.history.state,n)),o}}let aI=null,aN=!1;function aj(e){if(aN)throw Error(tY(43,!1));a=!e||!e.hasOwnProperty("urlRerouteOnly")||e.urlRerouteOnly,aN=!0,aI=window.history.replaceState,window.addEventListener("hashchange",aT),window.addEventListener("popstate",aT);let n=window.addEventListener,t=window.removeEventListener;window.addEventListener=function(e,t){if(!("function"==typeof t&&az.indexOf(e)>=0)||ar(aM[e],e=>e===t))return n.apply(this,arguments);aM[e].push(t)},window.removeEventListener=function(e,n){return"function"==typeof n&&az.indexOf(e)>=0&&(aM[e]=aM[e].filter(e=>e!==n)),t.apply(this,arguments)},window.history.pushState=aB(window.history.pushState,"pushState"),window.history.replaceState=aB(aI,"replaceState")}function aR(e){let n=document.createElement("a");return n.href=e,n}aD&&(window.singleSpaNavigate?console.warn(tY(41,!1)):window.singleSpaNavigate=aO);let aF=!1;function aL(e=window.jQuery){if(e||window.$&&window.$.fn&&window.$.fn.jquery&&(e=window.$),e&&!aF){let n=e.fn.on,t=e.fn.off;e.fn.on=function(e,t){return aW.call(this,n,window.addEventListener,e,t,arguments)},e.fn.off=function(e,n){return aW.call(this,t,window.removeEventListener,e,n,arguments)},aF=!0}}function aW(e,n,t,a,o){return"string"!=typeof t?e.apply(this,o):(t.split(/\s+/).forEach(e=>{az.indexOf(e)>=0&&(n(e,a),t=t.replace(e,""))}),""===t.trim()?this:e.apply(this,o))}let aG={};function aV(e){return Promise.resolve().then(()=>{let n=aG[an(e)];if(!n)return e;if(e.status===tZ)return aU(e,n),e;if(e.status===t6)return n.promise.then(()=>e);if(e.status!==t1&&e.status!==t8)return e;let t=e.status===t8?Promise.resolve():aC(e,"unload");return e.status=t6,t.then(()=>(aU(e,n),e)).catch(t=>(delete aG[an(e)],delete e.bootstrap,delete e.mount,delete e.unmount,delete e.unload,tq(t,e,t7),n.reject(t),e))})}function aU(e,n){delete aG[an(e)],delete e.bootstrap,delete e.mount,delete e.unmount,delete e.unload,e.status=tZ,n.resolve()}function aq(e,n,t,a){aG[an(e)]={app:e,resolve:t,reject:a},Object.defineProperty(aG[an(e)],"promise",{get:n})}let aH=[];function aK(){return aH.filter(t9).map(an)}function aY(){return aH.map(an)}function aJ(e){let n=ar(aH,n=>an(n)===e);return n?n.status:null}let aZ=!1;function aX(e,n,t,a){var o,r;let i,s,l=(i={name:null,loadApp:null,activeWhen:null,customProps:null},"object"==typeof e?(function(e){if(Array.isArray(e)||null===e)throw Error(tY(39,!1));let n=["name","app","activeWhen","customProps"],t=Object.keys(e).reduce((e,t)=>n.indexOf(t)>=0?e:e.concat(t),[]);if(0!==t.length)throw Error(tY(38,!1,n.join(", "),t.join(", ")));if("string"!=typeof e.name||0===e.name.length||"object"!=typeof e.app&&"function"!=typeof e.app)throw Error(tY(20,!1));let a=e=>"string"==typeof e||"function"==typeof e;if(!(a(e.activeWhen)||Array.isArray(e.activeWhen)&&e.activeWhen.every(a)))throw Error(tY(24,!1));if(!a3(e.customProps))throw Error(tY(22,!1))}(e),i.name=e.name,i.loadApp=e.app,i.activeWhen=e.activeWhen,i.customProps=e.customProps):(function(e,n,t,a){if("string"!=typeof e||0===e.length)throw Error(tY(20,!1));if(!n)throw Error(tY(23,!1));if("function"!=typeof t)throw Error(tY(24,!1));if(!a3(a))throw Error(tY(22,!1))}(e,n,t,a),i.name=e,i.loadApp=n,i.activeWhen=t,i.customProps=a),i.loadApp="function"!=typeof(o=i.loadApp)?()=>Promise.resolve(o):o,i.customProps=i.customProps||{},s=(s=Array.isArray(r=i.activeWhen)?r:[r]).map(e=>"function"==typeof e?e:a5(e)),i.activeWhen=e=>s.some(n=>n(e)),i);if(on||aZ||(aZ=!0,setTimeout(()=>{on||console.warn(tY(1,!1))},5e3)),-1!==aY().indexOf(l.name))throw Error(tY(21,!1,l.name));aH.push(ao({loadErrorTime:null,status:tZ,parcels:{},devtools:{overlays:{options:{},selectors:[]}}},l)),aD&&(aL(),a9())}function aQ(e=window.location){return aH.filter(n=>n.activeWhen(e)).map(an)}function a0(e){if(0===aH.filter(n=>an(n)===e).length)throw Error(tY(25,!1,e));return(aD?a1(e,{waitForUnmount:!1}):Promise.resolve()).then(()=>{let n=aH.map(an).indexOf(e);aH.splice(n,1)})}function a1(e,n={waitForUnmount:!1}){if("string"!=typeof e)throw Error(tY(26,!1));let t=ar(aH,n=>an(n)===e);if(!t)throw Error(tY(27,!1,e));let a=aG[an(t)];if(n&&n.waitForUnmount){if(a)return a.promise;{let e=new Promise((n,a)=>{aq(t,()=>e,n,a)});return e}}{let e;return a?(e=a.promise,a2(t,a.resolve,a.reject)):e=new Promise((n,a)=>{aq(t,()=>e,n,a),a2(t,n,a)}),e}}function a2(e,n,t){Promise.resolve().then(()=>{if(ar(aQ(),n=>n===an(e)))return a7()}).then(()=>au(e).then(aV).then(()=>{n(),setTimeout(()=>{a9()})})).catch(t)}function a3(e){return!e||"function"==typeof e||"object"==typeof e&&null!==e&&!Array.isArray(e)}function a5(e,n){let t=function(e,n){let t=0,a=!1,o="^";"/"!==e[0]&&(e="/"+e);for(let n=0;n<e.length;n++){let t=e[n],o=a&&"/"===t;(!a&&":"===t||o)&&r(n)}return r(e.length),RegExp(o,"i");function r(r){let i=e.slice(t,r).replace(/[|\\{}()[\]^$+*?.]/g,"\\$&");if(o+=a?"[^/]+/?":i,r===e.length)if(a)n&&(o+="$");else{let e=n?"":".*";o="/"===o.charAt(o.length-1)?`${o}${e}$`:`${o}(/${e})?(#.*)?$`}a=!a,t=r}}(e,n);return e=>{let n=e.origin;n||(n=`${e.protocol}//${e.host}`);let a=e.href.replace(n,"").replace(e.search,"").split("?")[0];return t.test(a)}}let a4=!1,a6=[],a8=aD&&window.location.href;function a7(){return a9()}function a9(e=[],n,t=!1){let a,o,r,i,s;if(a4)return new Promise((e,t)=>{a6.push({resolve:e,reject:t,eventArguments:n})});let{appsToUnload:l,appsToUnmount:c,appsToLoad:p,appsToMount:u}=(a=[],o=[],r=[],i=[],s=(new Date).getTime(),aH.forEach(e=>{let n=e.status!==t7&&ae(e);switch(e.status){case t8:n&&s-e.loadErrorTime>=200&&r.push(e);break;case tZ:case tX:n&&r.push(e);break;case tQ:case t1:!n&&aG[an(e)]?a.push(e):n&&i.push(e);break;case t3:n||o.push(e)}}),{appsToUnload:a,appsToUnmount:o,appsToLoad:r,appsToMount:i}),d,f=[],m=a8,h=a8=window.location.href;return on?(a4=!0,d=l.concat(p,c,u),Promise.resolve().then(()=>($(0===d.length?"before-no-app-change":"before-app-change",v(!0)),$("before-routing-event",v(!0,{cancelNavigation:g})),Promise.all(f).then(t=>{if(t.some(e=>e))return aI.call(window.history,history.state,"",m.substring(location.origin.length)),a8=location.href,a4=!1,a9(e,n,!0);let a=l.map(aV),o=Promise.all(c.map(au).map(e=>e.then(aV)).concat(a));o.then(()=>{$("before-mount-routing-event",v(!0))},e=>{throw e});let r=p.map(e=>aS(e).then(e=>oe(e,o))),i=u.filter(e=>0>p.indexOf(e)).map(e=>oe(e,o));return o.catch(e=>{throw b(),e}).then(()=>(b(),Promise.all(r.concat(i)).catch(n=>{throw e.forEach(e=>e.reject(n)),n}).then(y).then(()=>{},e=>{throw e})))})))):(d=p,Promise.resolve().then(()=>Promise.all(p.map(aS)).then(b).then(()=>[]).catch(e=>{throw b(),e}).finally(()=>{})));function g(e=!0){let n="function"==typeof(null==e?void 0:e.then)?e:Promise.resolve(e);f.push(n.catch(e=>(console.warn(Error(tY(42,!1))),console.warn(e),!1)))}function y(){let n=aK();e.forEach(e=>e.resolve(n));try{$(0===d.length?"no-app-change":"app-change",v()),$("routing-event",v())}catch(e){setTimeout(()=>{throw e})}if(a4=!1,a6.length>0){let e=a6;a6=[],a9(e)}return n}function b(){t||(e.forEach(e=>{aP(e.eventArguments)}),aP(n))}function v(e=!1,t){let a={},o={[t3]:[],[t1]:[],[tZ]:[],[t7]:[]};e?(p.concat(u).forEach((e,n)=>{i(e,t3)}),l.forEach(e=>{i(e,tZ)}),c.forEach(e=>{i(e,t1)})):d.forEach(e=>{i(e)});let r={detail:{newAppStatuses:a,appsByNewStatus:o,totalAppChanges:d.length,originalEvent:null==n?void 0:n[0],oldUrl:m,newUrl:h}};return t&&ao(r.detail,t),r;function i(e,n){let t=an(e);n=n||aJ(t),a[t]=n,(o[n]=o[n]||[]).push(t)}}function $(e,n){t||window.dispatchEvent(new tV(`single-spa:${e}`,n))}}function oe(e,n){return ae(e)?ap(e).then(e=>n.then(()=>ae(e)?am(e):e)):n.then(()=>e)}let on=!1;function ot(e){on=!0,aD&&(aj(e),a9())}function oa(e,n){let t=window.getOpenmrsSpaBase().replace(/\/$/,"");return oo(e,{openmrsBase:window.openmrsBase,openmrsSpaBase:t,...n}).replace(/^\/\//,"/")}function oo(e,n){return Object.keys(n).reduce((e,t)=>e.split("${"+t+"}").join(n[t]),e)}function or({to:e,templateParams:n}){let t=window.getOpenmrsSpaBase().replace(/\/$/,""),a=oa(e,n).replace(window.location.origin,"");a.startsWith(t)?aO(a):window.location.assign(a)}aD&&window.__SINGLE_SPA_DEVTOOLS__&&(window.__SINGLE_SPA_DEVTOOLS__.exposedMethods={getRawAppData:function(){return[...aH]},reroute:a9,NOT_LOADED:tZ,toLoadPromise:aS,toBootstrapPromise:ap,unregisterApplication:a0,getProfilerData:function(){return ac}});let oi="openmrs:history";function os(e){let n=JSON.parse(sessionStorage.getItem(oi)??"[]")||[];n.push(e),n.length>50&&(n=n.slice(-50)),sessionStorage.setItem(oi,JSON.stringify(n))}function ol(){0===JSON.parse(sessionStorage.getItem(oi)??"[]").length&&document.referrer&&os(document.referrer),window.addEventListener("single-spa:routing-event",e=>{let n=oc();e.detail.originalEvent?.singleSpaTrigger=="replaceState"?(n[n.length-1]=window.location.href,sessionStorage.setItem(oi,JSON.stringify(n))):!e.detail.originalEvent?.singleSpa&&n.includes(window.location.href)?op({toUrl:window.location.href}):n[n.length-1]!==window.location.href&&os(window.location.href)})}function oc(){return JSON.parse(sessionStorage.getItem(oi)??"[]")}function op({toUrl:e}){let n=oc(),t=n.lastIndexOf(e);if(-1!=t){let e=n.slice(0,t+1);or({to:n[t]}),sessionStorage.setItem(oi,JSON.stringify(e))}else throw Error(`URL ${e} not found in history; cannot go back to it.`)}function ou(){sessionStorage.removeItem(oi)}let od="${openmrsSpaBase}/login",of={redirectAuthFailure:{enabled:{_type:nG.Boolean,_default:!0,_description:"Whether to redirect logged-out users to `redirectAuthFailure.url`"},url:{_type:nG.String,_default:od,_validators:[tP.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:nG.Array,_default:[401],_elements:{_type:nG.Number,_validators:[tP.inRange(100,600)]},_description:"The HTTP error codes for which users will be redirected"},resolvePromise:{_type:nG.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:nG.Boolean,_default:!0,_description:"Whether openmrsFetch should support redirects returned from the backend"}};function om(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}let oh="/ws/rest/v1",og="/ws/fhir2/R4",oy=`${oh}/session`;function ob(e){return e&&e.startsWith("http")?e:("/"!==e[0]&&(e="/"+e),window.openmrsBase+e)}function o_(e,n={}){if("string"!=typeof e)throw Error("The first argument to @openmrs/api's openmrsFetch function must be a url string");if("object"!=typeof n)throw Error("The second argument to @openmrs/api's openmrsFetch function must be a plain object.");if(!window.openmrsBase)throw Error("@openmrs/api is running in a browser that doesn't have window.openmrsBase, which is provided by openmrs-module-spa's HTML file.");let t=ob(e);if(n.headers||(n.headers={}),ed(n.body)&&(n.body=JSON.stringify(n.body)),void 0===n.headers.Accept&&(n.headers.Accept="application/json"),null===n.headers.Accept&&delete n.headers.Accept,e.startsWith(oh)&&void 0===n.headers["Disable-WWW-Authenticate"]&&(n.headers["Disable-WWW-Authenticate"]="true"),e.startsWith(og)){let e=new URL(t,window.location.toString());e.searchParams.has("_summary")||(e.searchParams.set("_summary","data"),t=e.toString())}let a=Error();return window.fetch(t,n).then(async e=>{let{redirectAuthFailure:n,followRedirects:o}=await tc("@openmrs/esm-api");if(e.ok)if(204!==e.status)return e.clone().text().then(n=>{try{n&&(e.data=JSON.parse(n))}catch(e){}return e});else{if(o&&e.headers.has("location")){let n=e.headers.get("location");n&&or({to:n})}return e.data=null,e}return t===ob(oy)&&403===e.status||n.enabled&&n.errors.includes(e.status)?(ou(),or({to:n.url||e.headers.get("location")||od}),n.resolvePromise?Promise.resolve():new Promise(()=>{})):e.clone().text().then(n=>{let o=n;try{o=JSON.parse(n)}catch(e){}throw new o$(t,e,o,a)},n=>{throw new o$(t,e,null,a)})})}function ov(e,n={}){if("object"!=typeof n)throw Error("The second argument to openmrsObservableFetch must be either omitted or an object");let t=new AbortController;return n.signal=t.signal,new eo.Observable(a=>{let o=!1;return o_(e,n).then(e=>{o=!0,a.next(e),a.complete()},e=>{o=!0,a.error(e)}),()=>{o||t.abort()}})}class o$ extends Error{constructor(e,n,t,a){super(),om(this,"response",void 0),om(this,"responseBody",void 0),this.message=`Server responded with ${n.status} (${n.statusText}) for url ${e}. Check err.responseBody or network tab in dev tools for more info`,a.message=this.message,this.responseBody=t,this.response=n,this.stack=`Stacktrace for outgoing request:
12
+ ${n}`)}return a}let tv=(e,n)=>{let t=structuredClone(n);if(!e)return t;for(let n of Object.keys(e)){let a=t[n],o=e[n];if(o&&(o.hasOwnProperty("_type")||o.hasOwnProperty("_default"))){t.hasOwnProperty(n)||(t[n]=o._default);let e=o._elements;if(a&&t$(e)){if(o._type===nG.Array&&Array.isArray(a)){let o=a.map(n=>tv(e,n));t[n]=o}else if(o._type===nG.Object)for(let n of Object.keys(a))a[n]=tv(e,a[n])}}else if(tA(o)){let e=a??{};tA(e)&&(t[n]=tv(o,e))}}return t};function t$(e){return!!e&&Object.keys(e).filter(e=>!["_default","_validators"].includes(e)).length>0}function tA(e){return"object"==typeof e&&!Array.isArray(e)&&null!==e}let tk=new Set;function tw(e,n){let t=`${e}:::${n}`;tk||(tk=new Set),tk.has(t)||(console.error(n),tk.add(t))}function tx(e){e?tk.forEach(n=>{n.startsWith(e)&&tk.delete(n)}):tk.clear()}function tC(){te.forEach(e=>e()),te.length=0,tt()}let tE={"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:nG.Object,_default:{},_validators:[nV(e=>Object.keys(e).every(e=>/^[a-z]{2,3}(-[A-Z]{2,3})?$/.test(e)),e=>{let n=Object.keys(e).filter(e=>!/^[a-z]{2,3}(-[A-Z]{2,3})?$/.test(e));return`The 'Translation overrides' object should have language codes for keys. Language codes must be in the form of a two-to-three letter language code optionally followed by a hyphen and a two-to-three letter country code. The following keys do not conform: ${n.join(", ")}.`})]}},tS={"Display conditions":{privileges:{_description:"The privilege(s) the user must have to use this extension",_type:nG.Array,_default:[]},expression:{_description:"The expression that determines whether the extension is displayed",_type:nG.String,_default:void 0}},...tE},tD=(e,n)=>nV(t=>e<=t&&t<=n,`must be between ${e} and ${n}`),tM=e=>{let n=e.concat(["openmrsBase","openmrsSpaBase"]);return nV(e=>{if(!e||"string"!=typeof e)return!1;let t=/\${(.*?)}/g,a=t.exec(e);for(;a;){if(!n.includes(a[1]))return!1;a=t.exec(e)}return!0},"Should be a URL or path. The allowed template parameters are "+n.map(e=>"${"+e+"}").join(", "))},tz=tM([]),tO=e=>nV(n=>e.includes(n),`Must be one of the following: '${e.join("', '")}'.`),tP={inRange:tD,isUrl:tz,isUrlWithTemplateParameters:tM,oneOf:tO};var tT=t(48067);let tB=V("breadcrumbs",[]);function tI(e){return tN([e])}function tN(e){let n=[...tj(),...e.map(e=>({matcher:e.matcher instanceof RegExp?e.matcher:"string"==typeof e.matcher?(0,tT.pathToRegexp)(e.matcher).regexp:(0,tT.pathToRegexp)(e.path).regexp,settings:e}))];tB.setState(n,!0)}function tj(){return tB.getState()}function tR(e,n){if(n)return function(e,n){let[t]=e.filter(e=>e.matcher.test(n));return t}(e,n)||function(e,n){let t=n.split("/");for(;t.length>1;){t.pop();let n=tR(e,t.join("/"));if(n)return n}}(e,n)}function tF(e,n){if(e.length>0){let t=tR(e,n);if(t){let n=[t],a=tR(e,t.settings.parent);for(;void 0!==a;)n.push(a),a=tR(e,a.settings.parent);return n.reverse()}}return[]}function tL(e){return tF(tj(),e)}var tW=Object.freeze({__proto__:null,get start(){return ot},get ensureJQuerySupport(){return aL},get setBootstrapMaxTime(){return aA},get setMountMaxTime(){return ak},get setUnmountMaxTime(){return aw},get setUnloadMaxTime(){return ax},get registerApplication(){return aX},get unregisterApplication(){return a0},get getMountedApps(){return aK},get getAppStatus(){return aJ},get unloadApplication(){return a1},get checkActivityFunctions(){return aQ},get getAppNames(){return aY},get pathToActiveWhen(){return a5},get navigateToUrl(){return aO},get patchHistoryApi(){return aj},get triggerAppChange(){return a7},get addErrorHandler(){return tH},get removeErrorHandler(){return tK},get mountRootParcel(){return ay},get NOT_LOADED(){return tZ},get LOADING_SOURCE_CODE(){return tX},get NOT_BOOTSTRAPPED(){return tQ},get BOOTSTRAPPING(){return t0},get NOT_MOUNTED(){return t1},get MOUNTING(){return t2},get UPDATING(){return t5},get LOAD_ERROR(){return t8},get MOUNTED(){return t3},get UNLOADING(){return t6},get UNMOUNTING(){return t4},get SKIP_BECAUSE_BROKEN(){return t7}}),tG=("u">typeof globalThis?globalThis:"u">typeof window?window:"u">typeof global?global:"u">typeof self?self:{}).CustomEvent,tV=!function(){try{var e=new tG("cat",{detail:{foo:"bar"}});return"cat"===e.type&&"bar"===e.detail.foo}catch(e){}return!1}()?"u">typeof document&&"function"==typeof document.createEvent?function(e,n){var t=document.createEvent("CustomEvent");return n?t.initCustomEvent(e,n.bubbles,n.cancelable,n.detail):t.initCustomEvent(e,!1,!1,void 0),t}:function(e,n){var t=document.createEventObject();return t.type=e,n?(t.bubbles=!!n.bubbles,t.cancelable=!!n.cancelable,t.detail=n.detail):(t.bubbles=!1,t.cancelable=!1,t.detail=void 0),t}:tG;let tU=[];function tq(e,n,t){let a=tJ(e,n,t);tU.length?tU.forEach(e=>e(a)):setTimeout(()=>{throw a})}function tH(e){if("function"!=typeof e)throw Error(tY(28,!1));tU.push(e)}function tK(e){if("function"!=typeof e)throw Error(tY(29,!1));let n=!1;return tU=tU.filter(t=>{let a=t===e;return n=n||a,!a}),n}function tY(e,n,...t){return`single-spa minified message #${e}: ${n?n+" ":""}See https://single-spa.js.org/error/?code=${e}${t.length?`&arg=${t.join("&arg=")}`:""}`}function tJ(e,n,t){let a,o=`${aa(n)} '${an(n)}' died in status ${n.status}: `;if(e instanceof Error){try{e.message=o+e.message}catch(e){}a=e}else{console.warn(tY(30,!1,n.status,an(n)));try{a=Error(o+JSON.stringify(e))}catch(n){a=e}}return a.appOrParcelName=an(n),n.status=t,a}let tZ="NOT_LOADED",tX="LOADING_SOURCE_CODE",tQ="NOT_BOOTSTRAPPED",t0="BOOTSTRAPPING",t1="NOT_MOUNTED",t2="MOUNTING",t3="MOUNTED",t5="UPDATING",t4="UNMOUNTING",t6="UNLOADING",t8="LOAD_ERROR",t7="SKIP_BECAUSE_BROKEN";function t9(e){return e.status===t3}function ae(e){try{return e.activeWhen(window.location)}catch(n){return tq(n,e,t7),!1}}function an(e){return e.name}function at(e){return!!e.unmountThisParcel}function aa(e){return at(e)?"parcel":"application"}function ao(){for(let e=arguments.length-1;e>0;e--)for(let n in arguments[e])"__proto__"!==n&&(arguments[e-1][n]=arguments[e][n]);return arguments[0]}function ar(e,n){for(let t=0;t<e.length;t++)if(n(e[t]))return e[t];return null}function ai(e){return e&&("function"==typeof e||Array.isArray(e)&&!ar(e,e=>"function"!=typeof e))}function as(e,n){let t=e[n]||[];0===(t=Array.isArray(t)?t:[t]).length&&(t=[()=>Promise.resolve()]);let a=aa(e),o=an(e);return function(e){return t.reduce((t,r,i)=>t.then(()=>{let t=r(e);return al(t)?t:Promise.reject(tY(15,!1,a,o,n,i))}),Promise.resolve())}}function al(e){return e&&"function"==typeof e.then&&"function"==typeof e.catch}let ac=[];function ap(e,n){return Promise.resolve().then(()=>e.status!==tQ?e:(e.status=t0,e.bootstrap?aC(e,"bootstrap").then(t).catch(t=>{if(n)throw tJ(t,e,t7);return tq(t,e,t7),e}):Promise.resolve().then(t)));function t(){return e.status=t1,e}}function au(e,n){return Promise.resolve().then(()=>{if(e.status!==t3)return e;return e.status=t4,Promise.all(Object.keys(e.parcels).map(n=>e.parcels[n].unmountThisParcel())).then(t,a=>t().then(()=>{let t=Error(a.message);if(n)throw tJ(t,e,t7);tq(t,e,t7)})).then(()=>e);function t(){return aC(e,"unmount").then(()=>{e.status=t1},t=>{if(n)throw tJ(t,e,t7);tq(t,e,t7)})}})}let ad=!1,af=!1;function am(e,n){return Promise.resolve().then(()=>e.status!==t1?e:(ad||(window.dispatchEvent(new tV("single-spa:before-first-mount")),ad=!0),e.status=t2,aC(e,"mount").then(()=>(e.status=t3,af||(window.dispatchEvent(new tV("single-spa:first-mount")),af=!0),e)).catch(t=>{return e.status=t3,au(e,!0).then(a,a);function a(){if(n)throw tJ(t,e,t7);return tq(t,e,t7),e}})))}let ah=0,ag={parcels:{}};function ay(){return ab.apply(ag,arguments)}function ab(e,n){let t,a,o,r=this;if(!e||"object"!=typeof e&&"function"!=typeof e)throw Error(tY(2,!1));if(e.name&&"string"!=typeof e.name)throw Error(tY(3,!1,typeof e.name));let i=ah++,s=e.name||`parcel-${i}`;if("object"!=typeof n)throw Error(tY(4,!1,s,typeof n));if(!n.domElement)throw Error(tY(5,!1,s));let l="function"==typeof e,c=l?e:()=>Promise.resolve(e),p={id:i,parcels:{},status:l?tX:tQ,customProps:n,parentName:an(r),unmountThisParcel:()=>f.then(()=>{if(p.status!==t3)throw Error(tY(6,!1,s,p.status));return au(p,!0)}).then(e=>(p.parentName&&delete r.parcels[p.id],e)).then(e=>(a(e),e)).catch(e=>{throw p.status=t7,o(e),e})};r.parcels[i]=p;let u=c();if(!u||"function"!=typeof u.then)throw Error(tY(7,!1));let d=(u=u.then(e=>{if(!e)throw Error(tY(8,!1));if(s=e.name||`parcel-${i}`,Object.prototype.hasOwnProperty.call(e,"bootstrap")&&!ai(e.bootstrap))throw Error(tY(9,!1,s));if(!ai(e.mount))throw Error(tY(10,!1,s));if(!ai(e.unmount))throw Error(tY(11,!1,s));if(e.update&&!ai(e.update))throw Error(tY(12,!1,s));let n=as(e,"bootstrap"),a=as(e,"mount"),o=as(e,"unmount");p.status=tQ,p.name=s,p.bootstrap=n,p.mount=a,p.unmount=o,p.timeouts=aE(e.timeouts),e.update&&(p.update=as(e,"update"),t.update=function(e){return p.customProps=e,a_(Promise.resolve().then(()=>{if(p.status!==t3)throw Error(tY(32,!1,an(p)));return p.status=t5,aC(p,"update").then(()=>(p.status=t3,p)).catch(e=>{throw tJ(e,p,t7)})}))})})).then(()=>ap(p,!0)),f=d.then(()=>am(p,!0)),m=new Promise((e,n)=>{a=e,o=n});return t={mount:()=>a_(Promise.resolve().then(()=>{if(p.status!==t1)throw Error(tY(13,!1,s,p.status));return r.parcels[i]=p,am(p)})),unmount:()=>a_(p.unmountThisParcel()),getStatus:()=>p.status,loadPromise:a_(u),bootstrapPromise:a_(d),mountPromise:a_(f),unmountPromise:a_(m)}}function a_(e){return e.then(()=>null)}function av(e){let n=an(e),t="function"==typeof e.customProps?e.customProps(n,window.location):e.customProps;("object"!=typeof t||null===t||Array.isArray(t))&&(t={},console.warn(tY(40,!1),n,t));let a=ao({},t,{name:n,mountParcel:ab.bind(e),singleSpa:tW});return at(e)&&(a.unmountSelf=e.unmountThisParcel),a}let a$={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 aA(e,n,t){if("number"!=typeof e||e<=0)throw Error(tY(16,!1));a$.bootstrap={millis:e,dieOnTimeout:n,warningMillis:t||1e3}}function ak(e,n,t){if("number"!=typeof e||e<=0)throw Error(tY(17,!1));a$.mount={millis:e,dieOnTimeout:n,warningMillis:t||1e3}}function aw(e,n,t){if("number"!=typeof e||e<=0)throw Error(tY(18,!1));a$.unmount={millis:e,dieOnTimeout:n,warningMillis:t||1e3}}function ax(e,n,t){if("number"!=typeof e||e<=0)throw Error(tY(19,!1));a$.unload={millis:e,dieOnTimeout:n,warningMillis:t||1e3}}function aC(e,n){let t=e.timeouts[n],a=t.warningMillis,o=aa(e);return new Promise((r,i)=>{let s=!1,l=!1;e[n](av(e)).then(e=>{s=!0,r(e)}).catch(e=>{s=!0,i(e)}),setTimeout(()=>p(1),a),setTimeout(()=>p(!0),t.millis);let c=tY(31,!1,n,o,an(e),t.millis);function p(e){s||(!0===e?(l=!0,t.dieOnTimeout?i(Error(c)):console.error(c)):!l&&(console.warn(c),e*a+a<t.millis&&setTimeout(()=>p(e+1),a)))}})}function aE(e){let n={};for(let t in a$)n[t]=ao({},a$[t],e&&e[t]||{});return n}function aS(e){return Promise.resolve().then(()=>{let n,t;return e.loadPromise?e.loadPromise:e.status!==tZ&&e.status!==t8?e:(e.status=tX,e.loadPromise=Promise.resolve().then(()=>{let a=e.loadApp(av(e));if(!al(a))throw t=!0,Error(tY(33,!1,an(e)));return a.then(t=>{let a;e.loadErrorTime=null,"object"!=typeof(n=t)&&(a=34),Object.prototype.hasOwnProperty.call(n,"bootstrap")&&!ai(n.bootstrap)&&(a=35),ai(n.mount)||(a=36),ai(n.unmount)||(a=37);let o=aa(n);if(a){let t;try{t=JSON.stringify(n)}catch(e){}return console.error(tY(a,!1,o,an(e),t),n),tq(void 0,e,t7),e}return n.devtools&&n.devtools.overlays&&(e.devtools.overlays=ao({},e.devtools.overlays,n.devtools.overlays)),e.status=tQ,e.bootstrap=as(n,"bootstrap"),e.mount=as(n,"mount"),e.unmount=as(n,"unmount"),e.unload=as(n,"unload"),e.timeouts=aE(n.timeouts),delete e.loadPromise,e})}).catch(n=>{let a;return delete e.loadPromise,t?a=t7:(a=t8,e.loadErrorTime=(new Date).getTime()),tq(n,e,a),e}))})}let aD="u">typeof window,aM={hashchange:[],popstate:[]},az=["hashchange","popstate"];function aO(e){let n;if("string"==typeof e)n=e;else if(this&&this.href)n=this.href;else{if(!(e&&e.currentTarget&&e.currentTarget.href&&e.preventDefault))throw Error(tY(14,!1));n=e.currentTarget.href,e.preventDefault()}let t=aR(window.location.href),a=aR(n);0===n.indexOf("#")?window.location.hash=a.hash:t.host!==a.host&&a.host?window.location.href=n:a.pathname===t.pathname&&a.search===t.search?window.location.hash=a.hash:window.history.pushState(null,null,n)}function aP(e){if(e){let n=e[0].type;az.indexOf(n)>=0&&aM[n].forEach(n=>{try{n.apply(this,e)}catch(e){setTimeout(()=>{throw e})}})}}function aT(){a9([],arguments)}function aB(e,n){return function(){let t=window.location.href,o=e.apply(this,arguments),r=window.location.href;return a&&t===r||window.dispatchEvent(function(e,n){let t;try{t=new PopStateEvent("popstate",{state:e})}catch(n){(t=document.createEvent("PopStateEvent")).initPopStateEvent("popstate",!1,!1,e)}return t.singleSpa=!0,t.singleSpaTrigger=n,t}(window.history.state,n)),o}}let aI=null,aN=!1;function aj(e){if(aN)throw Error(tY(43,!1));a=!e||!e.hasOwnProperty("urlRerouteOnly")||e.urlRerouteOnly,aN=!0,aI=window.history.replaceState,window.addEventListener("hashchange",aT),window.addEventListener("popstate",aT);let n=window.addEventListener,t=window.removeEventListener;window.addEventListener=function(e,t){if(!("function"==typeof t&&az.indexOf(e)>=0)||ar(aM[e],e=>e===t))return n.apply(this,arguments);aM[e].push(t)},window.removeEventListener=function(e,n){return"function"==typeof n&&az.indexOf(e)>=0&&(aM[e]=aM[e].filter(e=>e!==n)),t.apply(this,arguments)},window.history.pushState=aB(window.history.pushState,"pushState"),window.history.replaceState=aB(aI,"replaceState")}function aR(e){let n=document.createElement("a");return n.href=e,n}aD&&(window.singleSpaNavigate?console.warn(tY(41,!1)):window.singleSpaNavigate=aO);let aF=!1;function aL(e=window.jQuery){if(e||window.$&&window.$.fn&&window.$.fn.jquery&&(e=window.$),e&&!aF){let n=e.fn.on,t=e.fn.off;e.fn.on=function(e,t){return aW.call(this,n,window.addEventListener,e,t,arguments)},e.fn.off=function(e,n){return aW.call(this,t,window.removeEventListener,e,n,arguments)},aF=!0}}function aW(e,n,t,a,o){return"string"!=typeof t?e.apply(this,o):(t.split(/\s+/).forEach(e=>{az.indexOf(e)>=0&&(n(e,a),t=t.replace(e,""))}),""===t.trim()?this:e.apply(this,o))}let aG={};function aV(e){return Promise.resolve().then(()=>{let n=aG[an(e)];if(!n)return e;if(e.status===tZ)return aU(e,n),e;if(e.status===t6)return n.promise.then(()=>e);if(e.status!==t1&&e.status!==t8)return e;let t=e.status===t8?Promise.resolve():aC(e,"unload");return e.status=t6,t.then(()=>(aU(e,n),e)).catch(t=>(delete aG[an(e)],delete e.bootstrap,delete e.mount,delete e.unmount,delete e.unload,tq(t,e,t7),n.reject(t),e))})}function aU(e,n){delete aG[an(e)],delete e.bootstrap,delete e.mount,delete e.unmount,delete e.unload,e.status=tZ,n.resolve()}function aq(e,n,t,a){aG[an(e)]={app:e,resolve:t,reject:a},Object.defineProperty(aG[an(e)],"promise",{get:n})}let aH=[];function aK(){return aH.filter(t9).map(an)}function aY(){return aH.map(an)}function aJ(e){let n=ar(aH,n=>an(n)===e);return n?n.status:null}let aZ=!1;function aX(e,n,t,a){var o,r;let i,s,l=(i={name:null,loadApp:null,activeWhen:null,customProps:null},"object"==typeof e?(function(e){if(Array.isArray(e)||null===e)throw Error(tY(39,!1));let n=["name","app","activeWhen","customProps"],t=Object.keys(e).reduce((e,t)=>n.indexOf(t)>=0?e:e.concat(t),[]);if(0!==t.length)throw Error(tY(38,!1,n.join(", "),t.join(", ")));if("string"!=typeof e.name||0===e.name.length||"object"!=typeof e.app&&"function"!=typeof e.app)throw Error(tY(20,!1));let a=e=>"string"==typeof e||"function"==typeof e;if(!(a(e.activeWhen)||Array.isArray(e.activeWhen)&&e.activeWhen.every(a)))throw Error(tY(24,!1));if(!a3(e.customProps))throw Error(tY(22,!1))}(e),i.name=e.name,i.loadApp=e.app,i.activeWhen=e.activeWhen,i.customProps=e.customProps):(function(e,n,t,a){if("string"!=typeof e||0===e.length)throw Error(tY(20,!1));if(!n)throw Error(tY(23,!1));if("function"!=typeof t)throw Error(tY(24,!1));if(!a3(a))throw Error(tY(22,!1))}(e,n,t,a),i.name=e,i.loadApp=n,i.activeWhen=t,i.customProps=a),i.loadApp="function"!=typeof(o=i.loadApp)?()=>Promise.resolve(o):o,i.customProps=i.customProps||{},s=(s=Array.isArray(r=i.activeWhen)?r:[r]).map(e=>"function"==typeof e?e:a5(e)),i.activeWhen=e=>s.some(n=>n(e)),i);if(on||aZ||(aZ=!0,setTimeout(()=>{on||console.warn(tY(1,!1))},5e3)),-1!==aY().indexOf(l.name))throw Error(tY(21,!1,l.name));aH.push(ao({loadErrorTime:null,status:tZ,parcels:{},devtools:{overlays:{options:{},selectors:[]}}},l)),aD&&(aL(),a9())}function aQ(e=window.location){return aH.filter(n=>n.activeWhen(e)).map(an)}function a0(e){if(0===aH.filter(n=>an(n)===e).length)throw Error(tY(25,!1,e));return(aD?a1(e,{waitForUnmount:!1}):Promise.resolve()).then(()=>{let n=aH.map(an).indexOf(e);aH.splice(n,1)})}function a1(e,n={waitForUnmount:!1}){if("string"!=typeof e)throw Error(tY(26,!1));let t=ar(aH,n=>an(n)===e);if(!t)throw Error(tY(27,!1,e));let a=aG[an(t)];if(n&&n.waitForUnmount){if(a)return a.promise;{let e=new Promise((n,a)=>{aq(t,()=>e,n,a)});return e}}{let e;return a?(e=a.promise,a2(t,a.resolve,a.reject)):e=new Promise((n,a)=>{aq(t,()=>e,n,a),a2(t,n,a)}),e}}function a2(e,n,t){Promise.resolve().then(()=>{if(ar(aQ(),n=>n===an(e)))return a7()}).then(()=>au(e).then(aV).then(()=>{n(),setTimeout(()=>{a9()})})).catch(t)}function a3(e){return!e||"function"==typeof e||"object"==typeof e&&null!==e&&!Array.isArray(e)}function a5(e,n){let t=function(e,n){let t=0,a=!1,o="^";"/"!==e[0]&&(e="/"+e);for(let n=0;n<e.length;n++){let t=e[n],o=a&&"/"===t;(!a&&":"===t||o)&&r(n)}return r(e.length),RegExp(o,"i");function r(r){let i=e.slice(t,r).replace(/[|\\{}()[\]^$+*?.]/g,"\\$&");if(o+=a?"[^/]+/?":i,r===e.length)if(a)n&&(o+="$");else{let e=n?"":".*";o="/"===o.charAt(o.length-1)?`${o}${e}$`:`${o}(/${e})?(#.*)?$`}a=!a,t=r}}(e,n);return e=>{let n=e.origin;n||(n=`${e.protocol}//${e.host}`);let a=e.href.replace(n,"").replace(e.search,"").split("?")[0];return t.test(a)}}let a4=!1,a6=[],a8=aD&&window.location.href;function a7(){return a9()}function a9(e=[],n,t=!1){let a,o,r,i,s;if(a4)return new Promise((e,t)=>{a6.push({resolve:e,reject:t,eventArguments:n})});let{appsToUnload:l,appsToUnmount:c,appsToLoad:p,appsToMount:u}=(a=[],o=[],r=[],i=[],s=(new Date).getTime(),aH.forEach(e=>{let n=e.status!==t7&&ae(e);switch(e.status){case t8:n&&s-e.loadErrorTime>=200&&r.push(e);break;case tZ:case tX:n&&r.push(e);break;case tQ:case t1:!n&&aG[an(e)]?a.push(e):n&&i.push(e);break;case t3:n||o.push(e)}}),{appsToUnload:a,appsToUnmount:o,appsToLoad:r,appsToMount:i}),d,f=[],m=a8,h=a8=window.location.href;return on?(a4=!0,d=l.concat(p,c,u),Promise.resolve().then(()=>($(0===d.length?"before-no-app-change":"before-app-change",v(!0)),$("before-routing-event",v(!0,{cancelNavigation:g})),Promise.all(f).then(t=>{if(t.some(e=>e))return aI.call(window.history,history.state,"",m.substring(location.origin.length)),a8=location.href,a4=!1,a9(e,n,!0);let a=l.map(aV),o=Promise.all(c.map(au).map(e=>e.then(aV)).concat(a));o.then(()=>{$("before-mount-routing-event",v(!0))},e=>{throw e});let r=p.map(e=>aS(e).then(e=>oe(e,o))),i=u.filter(e=>0>p.indexOf(e)).map(e=>oe(e,o));return o.catch(e=>{throw b(),e}).then(()=>(b(),Promise.all(r.concat(i)).catch(n=>{throw e.forEach(e=>e.reject(n)),n}).then(y).then(()=>{},e=>{throw e})))})))):(d=p,Promise.resolve().then(()=>Promise.all(p.map(aS)).then(b).then(()=>[]).catch(e=>{throw b(),e}).finally(()=>{})));function g(e=!0){let n="function"==typeof(null==e?void 0:e.then)?e:Promise.resolve(e);f.push(n.catch(e=>(console.warn(Error(tY(42,!1))),console.warn(e),!1)))}function y(){let n=aK();e.forEach(e=>e.resolve(n));try{$(0===d.length?"no-app-change":"app-change",v()),$("routing-event",v())}catch(e){setTimeout(()=>{throw e})}if(a4=!1,a6.length>0){let e=a6;a6=[],a9(e)}return n}function b(){t||(e.forEach(e=>{aP(e.eventArguments)}),aP(n))}function v(e=!1,t){let a={},o={[t3]:[],[t1]:[],[tZ]:[],[t7]:[]};e?(p.concat(u).forEach((e,n)=>{i(e,t3)}),l.forEach(e=>{i(e,tZ)}),c.forEach(e=>{i(e,t1)})):d.forEach(e=>{i(e)});let r={detail:{newAppStatuses:a,appsByNewStatus:o,totalAppChanges:d.length,originalEvent:null==n?void 0:n[0],oldUrl:m,newUrl:h}};return t&&ao(r.detail,t),r;function i(e,n){let t=an(e);n=n||aJ(t),a[t]=n,(o[n]=o[n]||[]).push(t)}}function $(e,n){t||window.dispatchEvent(new tV(`single-spa:${e}`,n))}}function oe(e,n){return ae(e)?ap(e).then(e=>n.then(()=>ae(e)?am(e):e)):n.then(()=>e)}let on=!1;function ot(e){on=!0,aD&&(aj(e),a9())}function oa(e,n){let t=window.getOpenmrsSpaBase().replace(/\/$/,"");return oo(e,{openmrsBase:window.openmrsBase,openmrsSpaBase:t,...n}).replace(/^\/\//,"/")}function oo(e,n){return Object.keys(n).reduce((e,t)=>e.split("${"+t+"}").join(n[t]),e)}function or({to:e,templateParams:n}){let t=window.getOpenmrsSpaBase().replace(/\/$/,""),a=oa(e,n).replace(window.location.origin,"");a.startsWith(t)?aO(a):window.location.assign(a)}aD&&window.__SINGLE_SPA_DEVTOOLS__&&(window.__SINGLE_SPA_DEVTOOLS__.exposedMethods={getRawAppData:function(){return[...aH]},reroute:a9,NOT_LOADED:tZ,toLoadPromise:aS,toBootstrapPromise:ap,unregisterApplication:a0,getProfilerData:function(){return ac}});let oi="openmrs:history";function os(e){let n=JSON.parse(sessionStorage.getItem(oi)??"[]")||[];n.push(e),n.length>50&&(n=n.slice(-50)),sessionStorage.setItem(oi,JSON.stringify(n))}function ol(){0===JSON.parse(sessionStorage.getItem(oi)??"[]").length&&document.referrer&&os(document.referrer),window.addEventListener("single-spa:routing-event",e=>{let n=oc();e.detail.originalEvent?.singleSpaTrigger=="replaceState"?(n[n.length-1]=window.location.href,sessionStorage.setItem(oi,JSON.stringify(n))):!e.detail.originalEvent?.singleSpa&&n.includes(window.location.href)?op({toUrl:window.location.href}):n[n.length-1]!==window.location.href&&os(window.location.href)})}function oc(){return JSON.parse(sessionStorage.getItem(oi)??"[]")}function op({toUrl:e}){let n=oc(),t=n.lastIndexOf(e);if(-1!=t){let e=n.slice(0,t+1);or({to:n[t]}),sessionStorage.setItem(oi,JSON.stringify(e))}else throw Error(`URL ${e} not found in history; cannot go back to it.`)}function ou(){sessionStorage.removeItem(oi)}let od="${openmrsSpaBase}/login",of={redirectAuthFailure:{enabled:{_type:nG.Boolean,_default:!0,_description:"Whether to redirect logged-out users to `redirectAuthFailure.url`"},url:{_type:nG.String,_default:od,_validators:[tP.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:nG.Array,_default:[401],_elements:{_type:nG.Number,_validators:[tP.inRange(100,600)]},_description:"The HTTP error codes for which users will be redirected"},resolvePromise:{_type:nG.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:nG.Boolean,_default:!0,_description:"Whether openmrsFetch should support redirects returned from the backend"}};function om(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}let oh="/ws/rest/v1",og="/ws/fhir2/R4",oy=`${oh}/session`;function ob(e){return e&&e.startsWith("http")?e:("/"!==e[0]&&(e="/"+e),window.openmrsBase+e)}function o_(e,n={}){if("string"!=typeof e)throw Error("The first argument to @openmrs/api's openmrsFetch function must be a url string");if("object"!=typeof n)throw Error("The second argument to @openmrs/api's openmrsFetch function must be a plain object.");if(!window.openmrsBase)throw Error("@openmrs/api is running in a browser that doesn't have window.openmrsBase, which is provided by openmrs-module-spa's HTML file.");let t=ob(e);if(n.headers||(n.headers={}),ed(n.body)&&(n.body=JSON.stringify(n.body)),void 0===n.headers.Accept&&(n.headers.Accept="application/json"),null===n.headers.Accept&&delete n.headers.Accept,e.startsWith(oh)&&void 0===n.headers["Disable-WWW-Authenticate"]&&(n.headers["Disable-WWW-Authenticate"]="true"),e.startsWith(og)){let e=new URL(t,window.location.toString());e.searchParams.has("_summary")||(e.searchParams.set("_summary","data"),t=e.toString())}let a=Error();return window.fetch(t,n).then(async e=>{let{redirectAuthFailure:n,followRedirects:o}=await tc("@openmrs/esm-api");if(e.ok){let n=e.headers.get("location");return(o&&n&&(t===ob(oy)||204===e.status)&&or({to:n}),204===e.status)?(e.data=null,e):e.clone().text().then(n=>{try{n&&(e.data=JSON.parse(n))}catch(e){}return e})}return t===ob(oy)&&403===e.status||n.enabled&&n.errors.includes(e.status)?(ou(),or({to:n.url||e.headers.get("location")||od}),n.resolvePromise?Promise.resolve():new Promise(()=>{})):e.clone().text().then(n=>{let o=n;try{o=JSON.parse(n)}catch(e){}throw new o$(t,e,o,a)},n=>{throw new o$(t,e,null,a)})})}function ov(e,n={}){if("object"!=typeof n)throw Error("The second argument to openmrsObservableFetch must be either omitted or an object");let t=new AbortController;return n.signal=t.signal,new eo.Observable(a=>{let o=!1;return o_(e,n).then(e=>{o=!0,a.next(e),a.complete()},e=>{o=!0,a.error(e)}),()=>{o||t.abort()}})}class o$ extends Error{constructor(e,n,t,a){super(),om(this,"response",void 0),om(this,"responseBody",void 0),this.message=`Server responded with ${n.status} (${n.statusText}) for url ${e}. Check err.responseBody or network tab in dev tools for more info`,a.message=this.message,this.responseBody=t,this.response=n,this.stack=`Stacktrace for outgoing request:
13
13
  ${a.stack}
14
14
  Stacktrace for incoming response:
15
15
  ${this.stack}`}}let oA=V("session",{loaded:!1,session:null}),ok=0;function ow(e={includeAuthStatus:!0}){return(ok<Date.now()-6e4||!oA.getState().loaded)&&oE(),new eo.Observable(n=>{let t=t=>{t.loaded&&(e.includeAuthStatus?n.next(t.session):n.next(t.session?.user))};return t(oA.getState()),oA.subscribe(t)})}function ox(){return(ok<Date.now()-6e4||!oA.getState().loaded)&&oE(),oA}function oC(e){let n=e.locale??e.user?.userProperties?.defaultLocale;n&&n.includes("_")&&(n=n.replaceAll("_","-")),function(e){if(void 0===e||"string"!=typeof e)return!1;try{new Intl.Locale(e)}catch(e){return!1}return!0}(n)&&n!==document.documentElement.getAttribute("lang")&&document.documentElement.setAttribute("lang",n)}function oE(e,n){ok=Date.now();let t={};return e&&n&&(t.Authorization=`Basic ${window.btoa(`${e}:${n}`)}`),oT(o_(oy,{headers:t}))}function oS(){oA.setState({loaded:!0,session:{authenticated:!1,sessionId:""}})}function oD(e,n){var t,a;if(void 0===n)return!e;if(!e)return!0;return t=e,a=n,("string"==typeof t?!Y(a.privileges.find(e=>t===e.display)):Array.isArray(t)?t.every(e=>!Y(a.privileges.find(n=>e===n.display))):(Y(t)||console.error(`Could not understand privileges "${t}"`),!0))||!Y(n.roles.find(e=>"System Developer"===e.display))}function oM(){let e,n;return new Promise(t=>{let a=a=>{a.loaded&&a.session.user&&(e=a.session.user,t(a.session.user),n&&n())};a(oA.getState()),e||(n=oA.subscribe(a))})}function oz(){return new Promise((e,n)=>{ow().subscribe(n=>{e(n.sessionLocation)},n).unsubscribe()})}async function oO(e,n){return oT(o_(oy,{method:"POST",body:{sessionLocation:e},headers:{"Content-Type":"application/json"},signal:n.signal}))}async function oP(e,n,t){return t||(t=new AbortController),await o_(`${oh}/user/${e}`,{method:"POST",body:{userProperties:n},headers:{"Content-Type":"application/json"},signal:t.signal}),oE()}function oT(e){return new Promise((n,t)=>{e.then(e=>{let a;"object"==typeof e?.data?(a={loaded:!0,session:e.data},oA.setState(a),n(a)):(a={loaded:!1,session:null},oA.setState(a),t(a))}).catch(e=>{T(`Failed to fetch new session information: ${e}`);let n={loaded:!1,session:null};oA.setState(n),t(n)})})}function oB(){return"development"===window.spaEnv||"true"===localStorage.getItem("openmrs:devtools")}oA.subscribe(e=>{e.loaded&&e.session&&oC(e.session)});let oI={"webservices.rest":"2.24.0",fhir2:"1.0.0-SNAPSHOT"};function oN(){ta("@openmrs/esm-api",of),oE()}let oj={address1:"Address line 1",address2:"Address line 2",address3:"Address line 3",address4:"Address line 4",address5:"Address line 5",address6:"Address line 6",city:"City",cityVillage:"City",country:"Country",countyDistrict:"District",district:"District",postalCode:"Postal code",state:"State",stateProvince:"State",closeAllOpenedWorkspaces:"Discard changes in {{count}} workspaces",closingAllWorkspacesPromptBody:"There may be unsaved changes in the following workspaces. Do you want to discard changes in the following workspaces? {{workspaceNames}}",closingAllWorkspacesPromptTitle:"You have unsaved changes",discard:"Discard",hide:"Hide",maximize:"Maximize",minimize:"Minimize",openAnyway:"Open anyway",unsavedChangesInOpenedWorkspace:"You may have unsaved changes in the opened workspace. Do you want to discard these changes?",unsavedChangesInWorkspace:'There may be unsaved changes in "{{workspaceName}}". Please save them before opening another workspace.',unsavedChangesTitleText:"Unsaved changes",workspaceHeader:"Workspace header",closeWorkspaces2PromptTitle:"Close workspace(s)",closeWorkspaces2PromptBody:"You are about to close the following workspace(s), which might have unsaved changes:",abnormalValue:"Abnormal value",actions:"Actions",actionableNotification:"Actionable notification",address:"Address",age:"Age",batchActionItemSelected:"{{totalSelected}} item selected",batchActionsItemsSelected:"{{totalSelected}} items selected",cancel:"Cancel",change:"Change",Clinic:"Clinic",close:"Close",closesActionableNotification:"Close actionable notification",closeSnackbar:"Close snackbar",confirm:"Confirm",contactAdministratorIfIssuePersists:"Contact your system administrator if the problem persists.",contactDetails:"Contact details",delete:"Delete",discardChanges:"Discard changes",edit:"Edit",emptyStateText:"There are no {{displayText}} to display",error:"Error",errorCopy:"Sorry, there was a problem displaying this information. You can try to reload this page, or contact the site administrator and quote the error code above.",errorLoadingLoginLocations:"Unable to load login locations. Please try again or contact support if the problem persists.",female:"Female",leftNavigation:"Left navigation",loading:"Loading",male:"Male",noResultsToDisplay:"No results to display",notAvailable:"Not available",other:"Other",paginationItemsCount:"{{pageItemsCount}} / {{totalItems}} items",paginationOfPages:"of {{count}} pages",patientAvatarAlt:"Avatar for {{patientName}}",patientIdentifierSticker:"Patient identifier sticker",patientLists:"Patient lists",patientPhotoAlt:"Profile photo of {{patientName}}",patientPhotoPlaceholder:"Photo placeholder for {{patientName}}",print:"Print",printError:"Print error",printErrorExplainer:"An error occurred in {{errorLocation}}",printIdentifierSticker:"Print identifier sticker",printing:"Printing",recordNewEntry:"Record {{displayText}}",relationships:"Relationships",resetOverrides:"Reset overrides",save:"Save",scriptLoadingFailed:"Error: Script failed to load",scriptLoadingError:"Failed to load overridden script from {{url}}. Please check that the bundled script is available at the expected URL. Click the button below to reset all import map overrides.",searchForLocation:"Search for a location",seeAll:"See all",seeMoreLists:"See {{count}} more lists",selectAll:"Select all",sex:"Sex",showLess:"Show less",showMore:"Show more",snackbarNotification:"Snackbar notification",toggleDevTools:"Toggle dev tools",unknown:"Unknown",yearAbbreviation:"yr",yearsAbbreviation:"yrs"},oR=e=>"string"==typeof e,oF=()=>{let e,n,t=new Promise((t,a)=>{e=t,n=a});return t.resolve=e,t.reject=n,t},oL=e=>null==e?"":""+e,oW=/###/g,oG=e=>e&&e.indexOf("###")>-1?e.replace(oW,"."):e,oV=e=>!e||oR(e),oU=(e,n,t)=>{let a=oR(n)?n.split("."):n,o=0;for(;o<a.length-1;){if(oV(e))return{};let n=oG(a[o]);!e[n]&&t&&(e[n]=new t),e=Object.prototype.hasOwnProperty.call(e,n)?e[n]:{},++o}return oV(e)?{}:{obj:e,k:oG(a[o])}},oq=(e,n,t)=>{let{obj:a,k:o}=oU(e,n,Object);if(void 0!==a||1===n.length){a[o]=t;return}let r=n[n.length-1],i=n.slice(0,n.length-1),s=oU(e,i,Object);for(;void 0===s.obj&&i.length;)r=`${i[i.length-1]}.${r}`,s=oU(e,i=i.slice(0,i.length-1),Object),s?.obj&&void 0!==s.obj[`${s.k}.${r}`]&&(s.obj=void 0);s.obj[`${s.k}.${r}`]=t},oH=(e,n)=>{let{obj:t,k:a}=oU(e,n);if(t&&Object.prototype.hasOwnProperty.call(t,a))return t[a]},oK=(e,n,t)=>{for(let a in n)"__proto__"!==a&&"constructor"!==a&&(a in e?oR(e[a])||e[a]instanceof String||oR(n[a])||n[a]instanceof String?t&&(e[a]=n[a]):oK(e[a],n[a],t):e[a]=n[a]);return e};var oY={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};let oJ=e=>oR(e)?e.replace(/[&<>"'\/]/g,e=>oY[e]):e,oZ=[" ",",","?","!",";"],oX=new class{constructor(e){this.capacity=e,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(e){let n=this.regExpMap.get(e);if(void 0!==n)return n;let t=new RegExp(e);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(e,t),this.regExpQueue.push(e),t}}(20),oQ=(e,n,t=".")=>{if(!e)return;if(e[n]){if(!Object.prototype.hasOwnProperty.call(e,n))return;return e[n]}let a=n.split(t),o=e;for(let e=0;e<a.length;){let n;if(!o||"object"!=typeof o)return;let r="";for(let i=e;i<a.length;++i)if(i!==e&&(r+=t),r+=a[i],void 0!==(n=o[r])){if(["string","number","boolean"].indexOf(typeof n)>-1&&i<a.length-1)continue;e+=i-e+1;break}o=n}return o},o0=e=>e?.replace("_","-"),o1={type:"logger",log(e){this.output("log",e)},warn(e){this.output("warn",e)},error(e){this.output("error",e)},output(e,n){console?.[e]?.apply?.(console,n)}};class o2{constructor(e,n={}){this.init(e,n)}init(e,n={}){this.prefix=n.prefix||"i18next:",this.logger=e||o1,this.options=n,this.debug=n.debug}log(...e){return this.forward(e,"log","",!0)}warn(...e){return this.forward(e,"warn","",!0)}error(...e){return this.forward(e,"error","")}deprecate(...e){return this.forward(e,"warn","WARNING DEPRECATED: ",!0)}forward(e,n,t,a){return a&&!this.debug?null:(oR(e[0])&&(e[0]=`${t}${this.prefix} ${e[0]}`),this.logger[n](e))}create(e){return new o2(this.logger,{...{prefix:`${this.prefix}:${e}:`},...this.options})}clone(e){return(e=e||this.options).prefix=e.prefix||this.prefix,new o2(this.logger,e)}}var o3=new o2;class o5{constructor(){this.observers={}}on(e,n){return e.split(" ").forEach(e=>{this.observers[e]||(this.observers[e]=new Map);let t=this.observers[e].get(n)||0;this.observers[e].set(n,t+1)}),this}off(e,n){if(this.observers[e]){if(!n)return void delete this.observers[e];this.observers[e].delete(n)}}emit(e,...n){this.observers[e]&&Array.from(this.observers[e].entries()).forEach(([e,t])=>{for(let a=0;a<t;a++)e(...n)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(([t,a])=>{for(let o=0;o<a;o++)t.apply(t,[e,...n])})}}class o4 extends o5{constructor(e,n={ns:["translation"],defaultNS:"translation"}){super(),this.data=e||{},this.options=n,void 0===this.options.keySeparator&&(this.options.keySeparator="."),void 0===this.options.ignoreJSONStructure&&(this.options.ignoreJSONStructure=!0)}addNamespaces(e){0>this.options.ns.indexOf(e)&&this.options.ns.push(e)}removeNamespaces(e){let n=this.options.ns.indexOf(e);n>-1&&this.options.ns.splice(n,1)}getResource(e,n,t,a={}){let o,r=void 0!==a.keySeparator?a.keySeparator:this.options.keySeparator,i=void 0!==a.ignoreJSONStructure?a.ignoreJSONStructure:this.options.ignoreJSONStructure;e.indexOf(".")>-1?o=e.split("."):(o=[e,n],t&&(Array.isArray(t)?o.push(...t):oR(t)&&r?o.push(...t.split(r)):o.push(t)));let s=oH(this.data,o);return(!s&&!n&&!t&&e.indexOf(".")>-1&&(e=o[0],n=o[1],t=o.slice(2).join(".")),!s&&i&&oR(t))?oQ(this.data?.[e]?.[n],t,r):s}addResource(e,n,t,a,o={silent:!1}){let r=void 0!==o.keySeparator?o.keySeparator:this.options.keySeparator,i=[e,n];t&&(i=i.concat(r?t.split(r):t)),e.indexOf(".")>-1&&(i=e.split("."),a=n,n=i[1]),this.addNamespaces(n),oq(this.data,i,a),o.silent||this.emit("added",e,n,t,a)}addResources(e,n,t,a={silent:!1}){for(let a in t)(oR(t[a])||Array.isArray(t[a]))&&this.addResource(e,n,a,t[a],{silent:!0});a.silent||this.emit("added",e,n,t)}addResourceBundle(e,n,t,a,o,r={silent:!1,skipCopy:!1}){let i=[e,n];e.indexOf(".")>-1&&(i=e.split("."),a=t,t=n,n=i[1]),this.addNamespaces(n);let s=oH(this.data,i)||{};r.skipCopy||(t=JSON.parse(JSON.stringify(t))),a?oK(s,t,o):s={...s,...t},oq(this.data,i,s),r.silent||this.emit("added",e,n,t)}removeResourceBundle(e,n){this.hasResourceBundle(e,n)&&delete this.data[e][n],this.removeNamespaces(n),this.emit("removed",e,n)}hasResourceBundle(e,n){return void 0!==this.getResource(e,n)}getResourceBundle(e,n){return n||(n=this.options.defaultNS),this.getResource(e,n)}getDataByLanguage(e){return this.data[e]}hasLanguageSomeTranslations(e){let n=this.getDataByLanguage(e);return!!(n&&Object.keys(n)||[]).find(e=>n[e]&&Object.keys(n[e]).length>0)}toJSON(){return this.data}}var o6={processors:{},addPostProcessor(e){this.processors[e.name]=e},handle(e,n,t,a,o){return e.forEach(e=>{n=this.processors[e]?.process(n,t,a,o)??n}),n}};let o8=Symbol("i18next/PATH_KEY");function o7(e,n){let t,a,o,{[o8]:r}=e((a=[],(o=Object.create(null)).get=(e,n)=>(t?.revoke?.(),n===o8)?a:(a.push(n),(t=Proxy.revocable(e,o)).proxy),Proxy.revocable(Object.create(null),o).proxy));return r.join(n?.keySeparator??".")}let o9={},re=e=>!oR(e)&&"boolean"!=typeof e&&"number"!=typeof e;class rn extends o5{constructor(e,n={}){super(),((e,n,t)=>{e.forEach(e=>{n[e]&&(t[e]=n[e])})})(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=n,void 0===this.options.keySeparator&&(this.options.keySeparator="."),this.logger=o3.create("translator")}changeLanguage(e){e&&(this.language=e)}exists(e,n={interpolation:{}}){let t={...n};if(null==e)return!1;let a=this.resolve(e,t);if(a?.res===void 0)return!1;let o=re(a.res);return!1!==t.returnObjects||!o}extractFromKey(e,n){let t=void 0!==n.nsSeparator?n.nsSeparator:this.options.nsSeparator;void 0===t&&(t=":");let a=void 0!==n.keySeparator?n.keySeparator:this.options.keySeparator,o=n.ns||this.options.defaultNS||[],r=t&&e.indexOf(t)>-1,i=!this.options.userDefinedKeySeparator&&!n.keySeparator&&!this.options.userDefinedNsSeparator&&!n.nsSeparator&&!((e,n,t)=>{n=n||"",t=t||"";let a=oZ.filter(e=>0>n.indexOf(e)&&0>t.indexOf(e));if(0===a.length)return!0;let o=oX.getRegExp(`(${a.map(e=>"?"===e?"\\?":e).join("|")})`),r=!o.test(e);if(!r){let n=e.indexOf(t);n>0&&!o.test(e.substring(0,n))&&(r=!0)}return r})(e,t,a);if(r&&!i){let n=e.match(this.interpolator.nestingRegexp);if(n&&n.length>0)return{key:e,namespaces:oR(o)?[o]:o};let r=e.split(t);(t!==a||t===a&&this.options.ns.indexOf(r[0])>-1)&&(o=r.shift()),e=r.join(a)}return{key:e,namespaces:oR(o)?[o]:o}}translate(e,n,t){let a="object"==typeof n?{...n}:n;if("object"!=typeof a&&this.options.overloadTranslationOptionHandler&&(a=this.options.overloadTranslationOptionHandler(arguments)),"object"==typeof a&&(a={...a}),a||(a={}),null==e)return"";"function"==typeof e&&(e=o7(e,{...this.options,...a})),Array.isArray(e)||(e=[String(e)]);let o=void 0!==a.returnDetails?a.returnDetails:this.options.returnDetails,r=void 0!==a.keySeparator?a.keySeparator:this.options.keySeparator,{key:i,namespaces:s}=this.extractFromKey(e[e.length-1],a),l=s[s.length-1],c=void 0!==a.nsSeparator?a.nsSeparator:this.options.nsSeparator;void 0===c&&(c=":");let p=a.lng||this.language,u=a.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(p?.toLowerCase()==="cimode")return u?o?{res:`${l}${c}${i}`,usedKey:i,exactUsedKey:i,usedLng:p,usedNS:l,usedParams:this.getUsedParamsDetails(a)}:`${l}${c}${i}`:o?{res:i,usedKey:i,exactUsedKey:i,usedLng:p,usedNS:l,usedParams:this.getUsedParamsDetails(a)}:i;let d=this.resolve(e,a),f=d?.res,m=d?.usedKey||i,h=d?.exactUsedKey||i,g=void 0!==a.joinArrays?a.joinArrays:this.options.joinArrays,y=!this.i18nFormat||this.i18nFormat.handleAsObject,b=void 0!==a.count&&!oR(a.count),v=rn.hasDefaultValue(a),$=b?this.pluralResolver.getSuffix(p,a.count,a):"",A=a.ordinal&&b?this.pluralResolver.getSuffix(p,a.count,{ordinal:!1}):"",k=b&&!a.ordinal&&0===a.count,w=k&&a[`defaultValue${this.options.pluralSeparator}zero`]||a[`defaultValue${$}`]||a[`defaultValue${A}`]||a.defaultValue,x=f;y&&!f&&v&&(x=w);let C=re(x),E=Object.prototype.toString.apply(x);if(y&&x&&C&&0>["[object Number]","[object Function]","[object RegExp]"].indexOf(E)&&!(oR(g)&&Array.isArray(x))){if(!a.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(m,x,{...a,ns:s}):`key '${i} (${this.language})' returned an object instead of string.`;return o?(d.res=e,d.usedParams=this.getUsedParamsDetails(a),d):e}if(r){let e=Array.isArray(x),n=e?[]:{},t=e?h:m;for(let e in x)if(Object.prototype.hasOwnProperty.call(x,e)){let o=`${t}${r}${e}`;v&&!f?n[e]=this.translate(o,{...a,defaultValue:re(w)?w[e]:void 0,...{joinArrays:!1,ns:s}}):n[e]=this.translate(o,{...a,joinArrays:!1,ns:s}),n[e]===o&&(n[e]=x[e])}f=n}}else if(y&&oR(g)&&Array.isArray(f))(f=f.join(g))&&(f=this.extendTranslation(f,e,a,t));else{let n=!1,o=!1;!this.isValidLookup(f)&&v&&(n=!0,f=w),this.isValidLookup(f)||(o=!0,f=i);let s=(a.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&o?void 0:f,u=v&&w!==f&&this.options.updateMissing;if(o||n||u){if(this.logger.log(u?"updateKey":"missingKey",p,l,i,u?w:f),r){let e=this.resolve(i,{...a,keySeparator:!1});e&&e.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}let e=[],n=this.languageUtils.getFallbackCodes(this.options.fallbackLng,a.lng||this.language);if("fallback"===this.options.saveMissingTo&&n&&n[0])for(let t=0;t<n.length;t++)e.push(n[t]);else"all"===this.options.saveMissingTo?e=this.languageUtils.toResolveHierarchy(a.lng||this.language):e.push(a.lng||this.language);let t=(e,n,t)=>{let o=v&&t!==f?t:s;this.options.missingKeyHandler?this.options.missingKeyHandler(e,l,n,o,u,a):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(e,l,n,o,u,a),this.emit("missingKey",e,l,n,f)};this.options.saveMissing&&(this.options.saveMissingPlurals&&b?e.forEach(e=>{let n=this.pluralResolver.getSuffixes(e,a);k&&a[`defaultValue${this.options.pluralSeparator}zero`]&&0>n.indexOf(`${this.options.pluralSeparator}zero`)&&n.push(`${this.options.pluralSeparator}zero`),n.forEach(n=>{t([e],i+n,a[`defaultValue${n}`]||w)})}):t(e,i,w))}f=this.extendTranslation(f,e,a,d,t),o&&f===i&&this.options.appendNamespaceToMissingKey&&(f=`${l}${c}${i}`),(o||n)&&this.options.parseMissingKeyHandler&&(f=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${l}${c}${i}`:i,n?f:void 0,a))}return o?(d.res=f,d.usedParams=this.getUsedParamsDetails(a),d):f}extendTranslation(e,n,t,a,o){if(this.i18nFormat?.parse)e=this.i18nFormat.parse(e,{...this.options.interpolation.defaultVariables,...t},t.lng||this.language||a.usedLng,a.usedNS,a.usedKey,{resolved:a});else if(!t.skipInterpolation){let r;t.interpolation&&this.interpolator.init({...t,...{interpolation:{...this.options.interpolation,...t.interpolation}}});let i=oR(e)&&(t?.interpolation?.skipOnVariables!==void 0?t.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);if(i){let n=e.match(this.interpolator.nestingRegexp);r=n&&n.length}let s=t.replace&&!oR(t.replace)?t.replace:t;if(this.options.interpolation.defaultVariables&&(s={...this.options.interpolation.defaultVariables,...s}),e=this.interpolator.interpolate(e,s,t.lng||this.language||a.usedLng,t),i){let n=e.match(this.interpolator.nestingRegexp);r<(n&&n.length)&&(t.nest=!1)}!t.lng&&a&&a.res&&(t.lng=this.language||a.usedLng),!1!==t.nest&&(e=this.interpolator.nest(e,(...e)=>o?.[0]!==e[0]||t.context?this.translate(...e,n):(this.logger.warn(`It seems you are nesting recursively key: ${e[0]} in key: ${n[0]}`),null),t)),t.interpolation&&this.interpolator.reset()}let r=t.postProcess||this.options.postProcess,i=oR(r)?[r]:r;return null!=e&&i?.length&&!1!==t.applyPostProcessor&&(e=o6.handle(i,e,n,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...a,usedParams:this.getUsedParamsDetails(t)},...t}:t,this)),e}resolve(e,n={}){let t,a,o,r,i;return oR(e)&&(e=[e]),e.forEach(e=>{if(this.isValidLookup(t))return;let s=this.extractFromKey(e,n),l=s.key;a=l;let c=s.namespaces;this.options.fallbackNS&&(c=c.concat(this.options.fallbackNS));let p=void 0!==n.count&&!oR(n.count),u=p&&!n.ordinal&&0===n.count,d=void 0!==n.context&&(oR(n.context)||"number"==typeof n.context)&&""!==n.context,f=n.lngs?n.lngs:this.languageUtils.toResolveHierarchy(n.lng||this.language,n.fallbackLng);c.forEach(e=>{this.isValidLookup(t)||(i=e,!o9[`${f[0]}-${e}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(i)&&(o9[`${f[0]}-${e}`]=!0,this.logger.warn(`key "${a}" for languages "${f.join(", ")}" won't get resolved as namespace "${i}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),f.forEach(a=>{let i;if(this.isValidLookup(t))return;r=a;let s=[l];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(s,l,a,e,n);else{let e;p&&(e=this.pluralResolver.getSuffix(a,n.count,n));let t=`${this.options.pluralSeparator}zero`,o=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(p&&(n.ordinal&&0===e.indexOf(o)&&s.push(l+e.replace(o,this.options.pluralSeparator)),s.push(l+e),u&&s.push(l+t)),d){let a=`${l}${this.options.contextSeparator||"_"}${n.context}`;s.push(a),p&&(n.ordinal&&0===e.indexOf(o)&&s.push(a+e.replace(o,this.options.pluralSeparator)),s.push(a+e),u&&s.push(a+t))}}for(;i=s.pop();)this.isValidLookup(t)||(o=i,t=this.getResource(a,e,i,n))}))})}),{res:t,usedKey:a,exactUsedKey:o,usedLng:r,usedNS:i}}isValidLookup(e){return void 0!==e&&!(!this.options.returnNull&&null===e)&&!(!this.options.returnEmptyString&&""===e)}getResource(e,n,t,a={}){return this.i18nFormat?.getResource?this.i18nFormat.getResource(e,n,t,a):this.resourceStore.getResource(e,n,t,a)}getUsedParamsDetails(e={}){let n=e.replace&&!oR(e.replace),t=n?e.replace:e;if(n&&void 0!==e.count&&(t.count=e.count),this.options.interpolation.defaultVariables&&(t={...this.options.interpolation.defaultVariables,...t}),!n)for(let e of(t={...t},["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"]))delete t[e];return t}static hasDefaultValue(e){let n="defaultValue";for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&n===t.substring(0,n.length)&&void 0!==e[t])return!0;return!1}}class rt{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=o3.create("languageUtils")}getScriptPartFromCode(e){if(!(e=o0(e))||0>e.indexOf("-"))return null;let n=e.split("-");return 2===n.length||(n.pop(),"x"===n[n.length-1].toLowerCase())?null:this.formatLanguageCode(n.join("-"))}getLanguagePartFromCode(e){if(!(e=o0(e))||0>e.indexOf("-"))return e;let n=e.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(e){if(oR(e)&&e.indexOf("-")>-1){let n;try{n=Intl.getCanonicalLocales(e)[0]}catch(e){}return(n&&this.options.lowerCaseLng&&(n=n.toLowerCase()),n)?n:this.options.lowerCaseLng?e.toLowerCase():e}return this.options.cleanCode||this.options.lowerCaseLng?e.toLowerCase():e}isSupportedCode(e){return("languageOnly"===this.options.load||this.options.nonExplicitSupportedLngs)&&(e=this.getLanguagePartFromCode(e)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(e)>-1}getBestMatchFromCodes(e){let n;return e?(e.forEach(e=>{if(n)return;let t=this.formatLanguageCode(e);(!this.options.supportedLngs||this.isSupportedCode(t))&&(n=t)}),!n&&this.options.supportedLngs&&e.forEach(e=>{if(n)return;let t=this.getScriptPartFromCode(e);if(this.isSupportedCode(t))return n=t;let a=this.getLanguagePartFromCode(e);if(this.isSupportedCode(a))return n=a;n=this.options.supportedLngs.find(e=>{if(e===a||!(0>e.indexOf("-")&&0>a.indexOf("-"))&&(e.indexOf("-")>0&&0>a.indexOf("-")&&e.substring(0,e.indexOf("-"))===a||0===e.indexOf(a)&&a.length>1))return e})}),n||(n=this.getFallbackCodes(this.options.fallbackLng)[0]),n):null}getFallbackCodes(e,n){if(!e)return[];if("function"==typeof e&&(e=e(n)),oR(e)&&(e=[e]),Array.isArray(e))return e;if(!n)return e.default||[];let t=e[n];return t||(t=e[this.getScriptPartFromCode(n)]),t||(t=e[this.formatLanguageCode(n)]),t||(t=e[this.getLanguagePartFromCode(n)]),t||(t=e.default),t||[]}toResolveHierarchy(e,n){let t=this.getFallbackCodes((!1===n?[]:n)||this.options.fallbackLng||[],e),a=[],o=e=>{e&&(this.isSupportedCode(e)?a.push(e):this.logger.warn(`rejecting language code not found in supportedLngs: ${e}`))};return oR(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))):oR(e)&&o(this.formatLanguageCode(e)),t.forEach(e=>{0>a.indexOf(e)&&o(this.formatLanguageCode(e))}),a}}let ra={zero:0,one:1,two:2,few:3,many:4,other:5},ro={select:e=>1===e?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class rr{constructor(e,n={}){this.languageUtils=e,this.options=n,this.logger=o3.create("pluralResolver"),this.pluralRulesCache={}}addRule(e,n){this.rules[e]=n}clearCache(){this.pluralRulesCache={}}getRule(e,n={}){let t,a=o0("dev"===e?"en":e),o=n.ordinal?"ordinal":"cardinal",r=JSON.stringify({cleanedCode:a,type:o});if(r in this.pluralRulesCache)return this.pluralRulesCache[r];try{t=new Intl.PluralRules(a,{type:o})}catch(o){if(!Intl)return this.logger.error("No Intl support, please use an Intl polyfill!"),ro;if(!e.match(/-|_/))return ro;let a=this.languageUtils.getLanguagePartFromCode(e);t=this.getRule(a,n)}return this.pluralRulesCache[r]=t,t}needsPlural(e,n={}){let t=this.getRule(e,n);return t||(t=this.getRule("dev",n)),t?.resolvedOptions().pluralCategories.length>1}getPluralFormsOfKey(e,n,t={}){return this.getSuffixes(e,t).map(e=>`${n}${e}`)}getSuffixes(e,n={}){let t=this.getRule(e,n);return(t||(t=this.getRule("dev",n)),t)?t.resolvedOptions().pluralCategories.sort((e,n)=>ra[e]-ra[n]).map(e=>`${this.options.prepend}${n.ordinal?`ordinal${this.options.prepend}`:""}${e}`):[]}getSuffix(e,n,t={}){let a=this.getRule(e,t);return a?`${this.options.prepend}${t.ordinal?`ordinal${this.options.prepend}`:""}${a.select(n)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix("dev",n,t))}}let ri=(e,n,t,a=".",o=!0)=>{let r,i=void 0!==(r=oH(e,t))?r:oH(n,t);return!i&&o&&oR(t)&&void 0===(i=oQ(e,t,a))&&(i=oQ(n,t,a)),i};class rs{constructor(e={}){this.logger=o3.create("interpolator"),this.options=e,this.format=e?.interpolation?.format||(e=>e),this.init(e)}init(e={}){e.interpolation||(e.interpolation={escapeValue:!0});let{escape:n,escapeValue:t,useRawValueToEscape:a,prefix:o,prefixEscaped:r,suffix:i,suffixEscaped:s,formatSeparator:l,unescapeSuffix:c,unescapePrefix:p,nestingPrefix:u,nestingPrefixEscaped:d,nestingSuffix:f,nestingSuffixEscaped:m,nestingOptionsSeparator:h,maxReplaces:g,alwaysFormat:y}=e.interpolation;this.escape=void 0!==n?n:oJ,this.escapeValue=void 0===t||t,this.useRawValueToEscape=void 0!==a&&a,this.prefix=o?o.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"):r||"{{",this.suffix=i?i.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"):s||"}}",this.formatSeparator=l||",",this.unescapePrefix=c?"":p||"-",this.unescapeSuffix=this.unescapePrefix?"":c||"",this.nestingPrefix=u?u.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"):d||"$t(".replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),this.nestingSuffix=f?f.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"):m||")".replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),this.nestingOptionsSeparator=h||",",this.maxReplaces=g||1e3,this.alwaysFormat=void 0!==y&&y,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){let e=(e,n)=>e?.source===n?(e.lastIndex=0,e):RegExp(n,"g");this.regexp=e(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=e(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=e(this.nestingRegexp,`${this.nestingPrefix}((?:[^()"']+|"[^"]*"|'[^']*'|\\((?:[^()]|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`)}interpolate(e,n,t,a){let o,r,i,s=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},l=e=>{if(0>e.indexOf(this.formatSeparator)){let o=ri(n,s,e,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(o,void 0,t,{...a,...n,interpolationkey:e}):o}let o=e.split(this.formatSeparator),r=o.shift().trim(),i=o.join(this.formatSeparator).trim();return this.format(ri(n,s,r,this.options.keySeparator,this.options.ignoreJSONStructure),i,t,{...a,...n,interpolationkey:r})};this.resetRegExp();let c=a?.missingInterpolationHandler||this.options.missingInterpolationHandler,p=a?.interpolation?.skipOnVariables!==void 0?a.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:e=>e.replace(/\$/g,"$$$$")},{regex:this.regexp,safeValue:e=>this.escapeValue?this.escape(e).replace(/\$/g,"$$$$"):e.replace(/\$/g,"$$$$")}].forEach(n=>{for(i=0;o=n.regex.exec(e);){let t=o[1].trim();if(void 0===(r=l(t)))if("function"==typeof c){let n=c(e,o,a);r=oR(n)?n:""}else if(a&&Object.prototype.hasOwnProperty.call(a,t))r="";else if(p){r=o[0];continue}else this.logger.warn(`missed to pass in variable ${t} for interpolating ${e}`),r="";else oR(r)||this.useRawValueToEscape||(r=oL(r));let s=n.safeValue(r);if(e=e.replace(o[0],s),p?(n.regex.lastIndex+=r.length,n.regex.lastIndex-=o[0].length):n.regex.lastIndex=0,++i>=this.maxReplaces)break}}),e}nest(e,n,t={}){let a,o,r,i=(e,n)=>{let t=this.nestingOptionsSeparator;if(0>e.indexOf(t))return e;let a=e.split(RegExp(`${t}[ ]*{`)),o=`{${a[1]}`;e=a[0];let i=(o=this.interpolate(o,r)).match(/'/g),s=o.match(/"/g);((i?.length??0)%2!=0||s)&&s.length%2==0||(o=o.replace(/'/g,'"'));try{r=JSON.parse(o),n&&(r={...n,...r})}catch(n){return this.logger.warn(`failed parsing options string in nesting for key ${e}`,n),`${e}${t}${o}`}return r.defaultValue&&r.defaultValue.indexOf(this.prefix)>-1&&delete r.defaultValue,e};for(;a=this.nestingRegexp.exec(e);){let s=[];(r=(r={...t}).replace&&!oR(r.replace)?r.replace:r).applyPostProcessor=!1,delete r.defaultValue;let l=/{.*}/.test(a[1])?a[1].lastIndexOf("}")+1:a[1].indexOf(this.formatSeparator);if(-1!==l&&(s=a[1].slice(l).split(this.formatSeparator).map(e=>e.trim()).filter(Boolean),a[1]=a[1].slice(0,l)),(o=n(i.call(this,a[1].trim(),r),r))&&a[0]===e&&!oR(o))return o;oR(o)||(o=oL(o)),o||(this.logger.warn(`missed to resolve ${a[1]} for nesting ${e}`),o=""),s.length&&(o=s.reduce((e,n)=>this.format(e,n,t.lng,{...t,interpolationkey:a[1].trim()}),o.trim())),e=e.replace(a[0],o),this.regexp.lastIndex=0}return e}}let rl=e=>{let n={};return(t,a,o)=>{let r=o;o&&o.interpolationkey&&o.formatParams&&o.formatParams[o.interpolationkey]&&o[o.interpolationkey]&&(r={...r,[o.interpolationkey]:void 0});let i=a+JSON.stringify(r),s=n[i];return s||(s=e(o0(a),o),n[i]=s),s(t)}},rc=e=>(n,t,a)=>e(o0(t),a)(n);class rp{constructor(e={}){this.logger=o3.create("formatter"),this.options=e,this.init(e)}init(e,n={interpolation:{}}){this.formatSeparator=n.interpolation.formatSeparator||",";let t=n.cacheInBuiltFormats?rl:rc;this.formats={number:t((e,n)=>{let t=new Intl.NumberFormat(e,{...n});return e=>t.format(e)}),currency:t((e,n)=>{let t=new Intl.NumberFormat(e,{...n,style:"currency"});return e=>t.format(e)}),datetime:t((e,n)=>{let t=new Intl.DateTimeFormat(e,{...n});return e=>t.format(e)}),relativetime:t((e,n)=>{let t=new Intl.RelativeTimeFormat(e,{...n});return e=>t.format(e,n.range||"day")}),list:t((e,n)=>{let t=new Intl.ListFormat(e,{...n});return e=>t.format(e)})}}add(e,n){this.formats[e.toLowerCase().trim()]=n}addCached(e,n){this.formats[e.toLowerCase().trim()]=rl(n)}format(e,n,t,a={}){let o=n.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,n)=>{let{formatName:o,formatOptions:r}=(e=>{let n=e.toLowerCase().trim(),t={};if(e.indexOf("(")>-1){let a=e.split("(");n=a[0].toLowerCase().trim();let o=a[1].substring(0,a[1].length-1);"currency"===n&&0>o.indexOf(":")?t.currency||(t.currency=o.trim()):"relativetime"===n&&0>o.indexOf(":")?t.range||(t.range=o.trim()):o.split(";").forEach(e=>{if(e){let[n,...a]=e.split(":"),o=a.join(":").trim().replace(/^'+|'+$/g,""),r=n.trim();t[r]||(t[r]=o),"false"===o&&(t[r]=!1),"true"===o&&(t[r]=!0),isNaN(o)||(t[r]=parseInt(o,10))}})}return{formatName:n,formatOptions:t}})(n);if(this.formats[o]){let n=e;try{let i=a?.formatParams?.[a.interpolationkey]||{},s=i.locale||i.lng||a.locale||a.lng||t;n=this.formats[o](e,s,{...r,...a,...i})}catch(e){this.logger.warn(e)}return n}return this.logger.warn(`there was no format function for ${o}`),e},e)}}class ru extends o5{constructor(e,n,t,a={}){super(),this.backend=e,this.store=n,this.services=t,this.languageUtils=t.languageUtils,this.options=a,this.logger=o3.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=a.maxParallelReads||10,this.readingCalls=0,this.maxRetries=a.maxRetries>=0?a.maxRetries:5,this.retryTimeout=a.retryTimeout>=1?a.retryTimeout:350,this.state={},this.queue=[],this.backend?.init?.(t,a.backend,a)}queueLoad(e,n,t,a){let o={},r={},i={},s={};return e.forEach(e=>{let a=!0;n.forEach(n=>{let i=`${e}|${n}`;!t.reload&&this.store.hasResourceBundle(e,n)?this.state[i]=2:this.state[i]<0||(1===this.state[i]?void 0===r[i]&&(r[i]=!0):(this.state[i]=1,a=!1,void 0===r[i]&&(r[i]=!0),void 0===o[i]&&(o[i]=!0),void 0===s[n]&&(s[n]=!0)))}),a||(i[e]=!0)}),(Object.keys(o).length||Object.keys(r).length)&&this.queue.push({pending:r,pendingCount:Object.keys(r).length,loaded:{},errors:[],callback:a}),{toLoad:Object.keys(o),pending:Object.keys(r),toLoadLanguages:Object.keys(i),toLoadNamespaces:Object.keys(s)}}loaded(e,n,t){let a=e.split("|"),o=a[0],r=a[1];n&&this.emit("failedLoading",o,r,n),!n&&t&&this.store.addResourceBundle(o,r,t,void 0,void 0,{skipCopy:!0}),this.state[e]=n?-1:2,n&&t&&(this.state[e]=0);let i={};this.queue.forEach(t=>{((e,n,t,a)=>{let{obj:o,k:r}=oU(e,n,Object);o[r]=o[r]||[],o[r].push(t)})(t.loaded,[o],r),void 0!==t.pending[e]&&(delete t.pending[e],t.pendingCount--),n&&t.errors.push(n),0!==t.pendingCount||t.done||(Object.keys(t.loaded).forEach(e=>{i[e]||(i[e]={});let n=t.loaded[e];n.length&&n.forEach(n=>{void 0===i[e][n]&&(i[e][n]=!0)})}),t.done=!0,t.errors.length?t.callback(t.errors):t.callback())}),this.emit("loaded",i),this.queue=this.queue.filter(e=>!e.done)}read(e,n,t,a=0,o=this.retryTimeout,r){if(!e.length)return r(null,{});if(this.readingCalls>=this.maxParallelReads)return void this.waitingReads.push({lng:e,ns:n,fcName:t,tried:a,wait:o,callback:r});this.readingCalls++;let i=(i,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)}i&&s&&a<this.maxRetries?setTimeout(()=>{this.read.call(this,e,n,t,a+1,2*o,r)},o):r(i,s)},s=this.backend[t].bind(this.backend);if(2===s.length){try{let t=s(e,n);t&&"function"==typeof t.then?t.then(e=>i(null,e)).catch(i):i(null,t)}catch(e){i(e)}return}return s(e,n,i)}prepareLoading(e,n,t={},a){if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),a&&a();oR(e)&&(e=this.languageUtils.toResolveHierarchy(e)),oR(n)&&(n=[n]);let o=this.queueLoad(e,n,t,a);if(!o.toLoad.length)return o.pending.length||a(),null;o.toLoad.forEach(e=>{this.loadOne(e)})}load(e,n,t){this.prepareLoading(e,n,{},t)}reload(e,n,t){this.prepareLoading(e,n,{reload:!0},t)}loadOne(e,n=""){let t=e.split("|"),a=t[0],o=t[1];this.read(a,o,"read",void 0,void 0,(t,r)=>{t&&this.logger.warn(`${n}loading namespace ${o} for language ${a} failed`,t),!t&&r&&this.logger.log(`${n}loaded namespace ${o} for language ${a}`,r),this.loaded(e,t,r)})}saveMissing(e,n,t,a,o,r={},i=()=>{}){if(this.services?.utils?.hasLoadedNamespace&&!this.services?.utils?.hasLoadedNamespace(n))return void this.logger.warn(`did not save key "${t}" as the namespace "${n}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");if(null!=t&&""!==t){if(this.backend?.create){let s={...r,isUpdate:o},l=this.backend.create.bind(this.backend);if(l.length<6)try{let o;(o=5===l.length?l(e,n,t,a,s):l(e,n,t,a))&&"function"==typeof o.then?o.then(e=>i(null,e)).catch(i):i(null,o)}catch(e){i(e)}else l(e,n,t,a,i,s)}e&&e[0]&&this.store.addResource(e[0],n,t,a)}}}let rd=()=>({debug:!1,initAsync:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:e=>{let n={};if("object"==typeof e[1]&&(n=e[1]),oR(e[1])&&(n.defaultValue=e[1]),oR(e[2])&&(n.tDescription=e[2]),"object"==typeof e[2]||"object"==typeof e[3]){let t=e[3]||e[2];Object.keys(t).forEach(e=>{n[e]=t[e]})}return n},interpolation:{escapeValue:!0,format:e=>e,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0},cacheInBuiltFormats:!0}),rf=e=>(oR(e.ns)&&(e.ns=[e.ns]),oR(e.fallbackLng)&&(e.fallbackLng=[e.fallbackLng]),oR(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),rm=()=>{};class rh extends o5{constructor(e={},n){if(super(),this.options=rf(e),this.services={},this.logger=o3,this.modules={external:[]},(e=>{Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach(n=>{"function"==typeof e[n]&&(e[n]=e[n].bind(e))})})(this),n&&!this.isInitialized&&!e.isClone){if(!this.options.initAsync)return this.init(e,n),this;setTimeout(()=>{this.init(e,n)},0)}}init(e={},n){this.isInitializing=!0,"function"==typeof e&&(n=e,e={}),null==e.defaultNS&&e.ns&&(oR(e.ns)?e.defaultNS=e.ns:0>e.ns.indexOf("translation")&&(e.defaultNS=e.ns[0]));let t=rd();this.options={...t,...this.options,...rf(e)},this.options.interpolation={...t.interpolation,...this.options.interpolation},void 0!==e.keySeparator&&(this.options.userDefinedKeySeparator=e.keySeparator),void 0!==e.nsSeparator&&(this.options.userDefinedNsSeparator=e.nsSeparator);let a=e=>e?"function"==typeof e?new e:e:null;if(!this.options.isClone){let e;this.modules.logger?o3.init(a(this.modules.logger),this.options):o3.init(null,this.options),e=this.modules.formatter?this.modules.formatter:rp;let n=new rt(this.options);this.store=new o4(this.options.resources,this.options);let o=this.services;o.logger=o3,o.resourceStore=this.store,o.languageUtils=n,o.pluralResolver=new rr(n,{prepend:this.options.pluralSeparator,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),this.options.interpolation.format&&this.options.interpolation.format!==t.interpolation.format&&this.logger.deprecate("init: you are still using the legacy format function, please use the new approach: https://www.i18next.com/translation-function/formatting"),e&&(!this.options.interpolation.format||this.options.interpolation.format===t.interpolation.format)&&(o.formatter=a(e),o.formatter.init&&o.formatter.init(o,this.options),this.options.interpolation.format=o.formatter.format.bind(o.formatter)),o.interpolator=new rs(this.options),o.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},o.backendConnector=new ru(a(this.modules.backend),o.resourceStore,o,this.options),o.backendConnector.on("*",(e,...n)=>{this.emit(e,...n)}),this.modules.languageDetector&&(o.languageDetector=a(this.modules.languageDetector),o.languageDetector.init&&o.languageDetector.init(o,this.options.detection,this.options)),this.modules.i18nFormat&&(o.i18nFormat=a(this.modules.i18nFormat),o.i18nFormat.init&&o.i18nFormat.init(this)),this.translator=new rn(this.services,this.options),this.translator.on("*",(e,...n)=>{this.emit(e,...n)}),this.modules.external.forEach(e=>{e.init&&e.init(this)})}if(this.format=this.options.interpolation.format,n||(n=rm),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){let e=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);e.length>0&&"dev"!==e[0]&&(this.options.lng=e[0])}this.services.languageDetector||this.options.lng||this.logger.warn("init: no languageDetector is used and no lng is defined"),["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach(e=>{this[e]=(...n)=>this.store[e](...n)}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(e=>{this[e]=(...n)=>(this.store[e](...n),this)});let o=oF(),r=()=>{let e=(e,t)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=!0,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),o.resolve(t),n(e,t)};if(this.languages&&!this.isInitialized)return e(null,this.t.bind(this));this.changeLanguage(this.options.lng,e)};return this.options.resources||!this.options.initAsync?r():setTimeout(r,0),o}loadResources(e,n=rm){let t=n,a=oR(e)?e:this.language;if("function"==typeof e&&(t=e),!this.options.resources||this.options.partialBundledLanguages){if(a?.toLowerCase()==="cimode"&&(!this.options.preload||0===this.options.preload.length))return t();let e=[],n=n=>{n&&"cimode"!==n&&this.services.languageUtils.toResolveHierarchy(n).forEach(n=>{"cimode"!==n&&0>e.indexOf(n)&&e.push(n)})};a?n(a):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(e=>n(e)),this.options.preload?.forEach?.(e=>n(e)),this.services.backendConnector.load(e,this.options.ns,e=>{e||this.resolvedLanguage||!this.language||this.setResolvedLanguage(this.language),t(e)})}else t(null)}reloadResources(e,n,t){let a=oF();return"function"==typeof e&&(t=e,e=void 0),"function"==typeof n&&(t=n,n=void 0),e||(e=this.languages),n||(n=this.options.ns),t||(t=rm),this.services.backendConnector.reload(e,n,e=>{a.resolve(),t(e)}),a}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&&o6.addPostProcessor(e),"formatter"===e.type&&(this.modules.formatter=e),"3rdParty"===e.type&&this.modules.external.push(e),this}setResolvedLanguage(e){if(e&&this.languages&&!(["cimode","dev"].indexOf(e)>-1)){for(let e=0;e<this.languages.length;e++){let n=this.languages[e];if(!(["cimode","dev"].indexOf(n)>-1)&&this.store.hasLanguageSomeTranslations(n)){this.resolvedLanguage=n;break}}!this.resolvedLanguage&&0>this.languages.indexOf(e)&&this.store.hasLanguageSomeTranslations(e)&&(this.resolvedLanguage=e,this.languages.unshift(e))}}changeLanguage(e,n){this.isLanguageChangingTo=e;let t=oF();this.emit("languageChanging",e);let a=e=>{this.language=e,this.languages=this.services.languageUtils.toResolveHierarchy(e),this.resolvedLanguage=void 0,this.setResolvedLanguage(e)},o=(o,r)=>{r?this.isLanguageChangingTo===e&&(a(r),this.translator.changeLanguage(r),this.isLanguageChangingTo=void 0,this.emit("languageChanged",r),this.logger.log("languageChanged",r)):this.isLanguageChangingTo=void 0,t.resolve((...e)=>this.t(...e)),n&&n(o,(...e)=>this.t(...e))},r=n=>{e||n||!this.services.languageDetector||(n=[]);let t=oR(n)?n:n&&n[0],r=this.store.hasLanguageSomeTranslations(t)?t:this.services.languageUtils.getBestMatchFromCodes(oR(n)?[n]:n);r&&(this.language||a(r),this.translator.language||this.translator.changeLanguage(r),this.services.languageDetector?.cacheUserLanguage?.(r)),this.loadResources(r,e=>{o(e,r)})};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(r):this.services.languageDetector.detect(r):r(e):r(this.services.languageDetector.detect()),t}getFixedT(e,n,t){let a=(e,n,...o)=>{let r,i;(r="object"!=typeof n?this.options.overloadTranslationOptionHandler([e,n].concat(o)):{...n}).lng=r.lng||a.lng,r.lngs=r.lngs||a.lngs,r.ns=r.ns||a.ns,""!==r.keyPrefix&&(r.keyPrefix=r.keyPrefix||t||a.keyPrefix);let s=this.options.keySeparator||".";return r.keyPrefix&&Array.isArray(e)?i=e.map(e=>("function"==typeof e&&(e=o7(e,{...this.options,...n})),`${r.keyPrefix}${s}${e}`)):("function"==typeof e&&(e=o7(e,{...this.options,...n})),i=r.keyPrefix?`${r.keyPrefix}${s}${e}`:e),this.t(i,r)};return oR(e)?a.lng=e:a.lngs=e,a.ns=n,a.keyPrefix=t,a}t(...e){return this.translator?.translate(...e)}exists(...e){return this.translator?.exists(...e)}setDefaultNamespace(e){this.options.defaultNS=e}hasLoadedNamespace(e,n={}){if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;let t=n.lng||this.resolvedLanguage||this.languages[0],a=!!this.options&&this.options.fallbackLng,o=this.languages[this.languages.length-1];if("cimode"===t.toLowerCase())return!0;let r=(e,n)=>{let t=this.services.backendConnector.state[`${e}|${n}`];return -1===t||0===t||2===t};if(n.precheck){let e=n.precheck(this,r);if(void 0!==e)return e}return!!(this.hasResourceBundle(t,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||r(t,e)&&(!a||r(o,e)))}loadNamespaces(e,n){let t=oF();return this.options.ns?(oR(e)&&(e=[e]),e.forEach(e=>{0>this.options.ns.indexOf(e)&&this.options.ns.push(e)}),this.loadResources(e=>{t.resolve(),n&&n(e)}),t):(n&&n(),Promise.resolve())}loadLanguages(e,n){let t=oF();oR(e)&&(e=[e]);let a=this.options.preload||[],o=e.filter(e=>0>a.indexOf(e)&&this.services.languageUtils.isSupportedCode(e));return o.length?(this.options.preload=a.concat(o),this.loadResources(e=>{t.resolve(),n&&n(e)}),t):(n&&n(),Promise.resolve())}dir(e){if(e||(e=this.resolvedLanguage||(this.languages?.length>0?this.languages[0]:this.language)),!e)return"rtl";try{let n=new Intl.Locale(e);if(n&&n.getTextInfo){let e=n.getTextInfo();if(e&&e.direction)return e.direction}}catch(e){}let n=this.services?.languageUtils||new rt(rd());return e.toLowerCase().indexOf("-latn")>1?"ltr":["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"].indexOf(n.getLanguagePartFromCode(e))>-1||e.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(e={},n){return new rh(e,n)}cloneInstance(e={},n=rm){let t=e.forkResourceStore;t&&delete e.forkResourceStore;let a={...this.options,...e,isClone:!0},o=new rh(a);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)},t&&(o.store=new o4(Object.keys(this.store.data).reduce((e,n)=>(e[n]={...this.store.data[n]},e[n]=Object.keys(e[n]).reduce((t,a)=>(t[a]={...e[n][a]},t),e[n]),e),{}),a),o.services.resourceStore=o.store),o.translator=new rn(o.services,a),o.translator.on("*",(e,...n)=>{o.emit(e,...n)}),o.init(a,n),o.translator.options=a,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 rg=rh.createInstance();rg.createInstance=rh.createInstance,rg.createInstance,rg.dir,rg.init,rg.loadResources,rg.reloadResources,rg.use,rg.changeLanguage,rg.getFixedT,rg.t,rg.exists,rg.setDefaultNamespace,rg.hasLoadedNamespace,rg.loadNamespaces,rg.loadLanguages;let ry=rg.default||rg;function rb(e,n,t,a){return ry.t(n,{ns:e,defaultValue:t,...a})}function r_(e,n,t){return oj[e]?rb("core",e,n??oj[e],t):(console.error(`O3 Core Translations does not provide key '${e}'. The key itself is being rendered as text.`),e)}ry.on("initialized",function(){window.i18next.loadNamespaces(["core"])});let rv="import-map-override:",r$="import-map-overrides-disabled",rA="import-map-overrides:change",rk=!1,rw=null;async function rx(){let e=document.querySelectorAll('script[type="systemjs-importmap"]'),n=[];for(let t=0;t<e.length;t++){let a=e[t];try{if(a.src){let e=await fetch(a.src);n.push(await e.json())}else a.textContent&&n.push(JSON.parse(a.textContent))}catch(e){console.warn(`[import-maps] Failed to parse import map from script tag at index ${t}`,e)}}return rC(n)}function rC(e){let n={imports:{}};for(let t of e)t?.imports&&Object.assign(n.imports,t.imports);return n}function rE(){let e={};try{let n=rO();for(let t=0;t<localStorage.length;t++){let a=localStorage.key(t);if(a?.startsWith(rv)){let t=a.slice(rv.length);if(!n.includes(t)){let n=localStorage.getItem(a);n&&(e[t]=n)}}}}catch(e){console.warn("[import-maps] Failed to read import-map overrides from localStorage",e)}return{imports:e}}async function rS(){let e=await rx();return rk?rC([e,rw??rE()]):e}async function rD(){return rx()}async function rM(){return rk?rC([await rx(),rE()]):rx()}function rz(e){if(!rk)return{imports:{}};if(e){let e={};for(let n=0;n<localStorage.length;n++){let t=localStorage.key(n);if(t?.startsWith(rv)){let n=localStorage.getItem(t);n&&(e[t.slice(rv.length)]=n)}}return{imports:e}}return rE()}function rO(){if(!rk)return[];try{let e=localStorage.getItem(r$);if(e){let n=JSON.parse(e);if(Array.isArray(n))return n}}catch{}return[]}function rP(e){return!!rk&&rO().includes(e)}function rT(e,n){if(!rk)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{localStorage.setItem(rv+e,n),window.dispatchEvent(new CustomEvent(rA))}catch(e){console.warn("[import-maps] Failed to write import-map override to localStorage",e)}}function rB(e){if(!rk)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{localStorage.removeItem(rv+e);let n=rO().filter(n=>n!==e);n.length>0?localStorage.setItem(r$,JSON.stringify(n)):localStorage.removeItem(r$),window.dispatchEvent(new CustomEvent(rA))}catch(e){console.warn("[import-maps] Failed to update import-map overrides in localStorage",e)}}function rI(){if(!rk)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{let e=[];for(let n=0;n<localStorage.length;n++){let t=localStorage.key(n);t?.startsWith(rv)&&e.push(t)}e.forEach(e=>localStorage.removeItem(e)),localStorage.removeItem(r$),window.dispatchEvent(new CustomEvent(rA))}catch(e){console.warn("[import-maps] Failed to clear import-map overrides from localStorage",e)}}function rN(e){if(!rk)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{let n=rO().filter(n=>n!==e);n.length>0?localStorage.setItem(r$,JSON.stringify(n)):localStorage.removeItem(r$),window.dispatchEvent(new CustomEvent(rA))}catch(e){console.warn("[import-maps] Failed to update import-map overrides in localStorage",e)}}let rj=!1;function rR(){!rj&&(rj=!0,(rk="development"===window.spaEnv)&&(rw=rE()))}function rF(e){return e.replace(/[\/\-@]/g,"_")}async function rL(e,n="./start",a){var o;let r,i=!a?.maxLoadingTime||a.maxLoadingTime<=0?6e5:a.maxLoadingTime;await Promise.race([rW(e,a?.importMap),new Promise((n,t)=>{r=setTimeout(()=>{var n;t(Error(`Could not resolve requested script, ${e}, within ${(n=i)<1e3?`${n} milliseconds`:n<6e4?`${Math.floor(n/1e3)} seconds`:n<36e5?`${Math.floor(n/6e4)} minutes`:n<864e5?`${Math.floor(n/36e5)} hours`:`${Math.floor(n/864e5)} days`}.`))},i)})]),r&&clearTimeout(r);let s=rF(e),l=window[s];if(!("object"==typeof(o=l)&&null!==o&&"init"in o&&"function"==typeof o.init&&"get"in o&&"function"==typeof o.get)){let e=`The global variable ${s} does not refer to a federated module`;throw console.error(e),Error(e)}l.init(t.S.default);let c=(await l.get(n))();if("object"!=typeof c||null===c){let n=`Container for ${e} did not return an ESM module as expected`;throw console.error(n),Error(n)}return c}async function rW(e,n){if("string"!=typeof e||0===e.trim().length){let e="Attempted to call importDynamic() without supplying a package to load";throw console.error(e),Error(e)}let t=rF(e);if(!window[t]){let t=n??await rG();if(!t.imports.hasOwnProperty(e)){let n=`Could not find the package ${e} defined in the current importmap`;throw console.error(n),Error(n)}let a=t.imports[e];a.startsWith("./")&&(a=window.spaBase+a.substring(1));let o=e in rz().imports;try{return await new Promise((e,n)=>{!function(e,n,t){let a=document.head.querySelector(`script[src="${e}"]`),o=window[rV];if(o||(o=window[rV]=new Set([])),a)if(o.has(e)){let e,o,r;r=()=>{e&&a.removeEventListener("load",e),o&&a.removeEventListener("error",o)},e=()=>{r(),n(null)},o=e=>{r(),t(e.message)},a.addEventListener("load",e),a.addEventListener("error",o)}else console.warn(`Script at ${e} already loaded. Not loading it again.`),n(null);else{let a,r,i;o.add(e);let s=document.createElement("script");s.src=e,s.type="text/javascript",s.async=!0;let l=setTimeout(()=>{console.error(`The script at ${e} did not load within 5 seconds. This may indicate an issue with the imports in the script's entry-point file or with the script's bundler configuration.`)},5e3);i=()=>{clearTimeout(l),o.delete(e),a&&s.removeEventListener("load",a),r&&s.removeEventListener("error",r)},a=()=>{i(),n(null)},r=n=>{i();let a=`Failed to load script from ${e}`;console.error(a,n),t(n.message??a)},s.addEventListener("load",a),s.addEventListener("error",r),document.head.appendChild(s)}}(a,e,n)})}catch(e){return o&&D({kind:"error",title:r_("scriptLoadingFailed","Error: Script failed to load"),description:r_("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:a}),actionButtonLabel:r_("resetOverrides","Reset overrides"),onActionButtonClick(){rI(),window.location.reload()}}),Promise.reject(e)}}return Promise.resolve()}async function rG(){return rS()}let rV=Symbol("__openmrs_script_loading");function rU(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 rq(e){return!!e&&"object"==typeof e&&Object.entries(e).every(([e,n])=>"string"==typeof e&&rU(n))}let rH="openmrs-routes:",rK="openmrs-routes:change",rY=!1,rJ=null;async function rZ(){let e=document.querySelectorAll("script[type='openmrs-routes']"),n=[];for(let t=0;t<e.length;t++){let a=e[t];try{let e;if(a.src){let n=await fetch(a.src);e=await n.json()}else a.textContent&&(e=JSON.parse(a.textContent));e&&rq(e)&&n.push(e)}catch(e){console.warn(`[route-maps] Failed to parse routes from script tag at index ${t}`,e)}}return rX(n)}function rX(e){let n={};for(let t of e)t&&"object"==typeof t&&Object.assign(n,t);return n}async function rQ(){let e={};try{let n=[];for(let e=0;e<localStorage.length;e++){let t=localStorage.key(e);if(t?.startsWith(rH)){let e=localStorage.getItem(t);e&&n.push({moduleName:t.slice(rH.length),raw:e})}}for(let t of(await Promise.allSettled(n.map(async({moduleName:e,raw:n})=>{let t=JSON.parse(n);if(rU(t))return{moduleName:e,routes:t};if("string"==typeof t&&t.startsWith("http")){let n=await fetch(t),a=await n.json();if(rU(a))return{moduleName:e,routes:a};throw Error(`${t} did not resolve to a valid OpenmrsAppRoutes object`)}throw Error(`Override for ${e} is neither a valid routes object nor a URL`)}))))"fulfilled"===t.status?e[t.value.moduleName]=t.value.routes:console.warn("[route-maps] Failed to load route override",t.reason)}catch(e){console.warn("[route-maps] Failed to read route overrides from localStorage",e)}return e}async function r0(){let e=await rZ();return rY?rX([e,rJ??await rQ()]):e}async function r1(){return rZ()}async function r2(){return rY?rX([await rZ(),await rQ()]):rZ()}function r3(){if(!rY)return{};let e={};try{for(let n=0;n<localStorage.length;n++){let t=localStorage.key(n);if(t?.startsWith(rH)){let n=localStorage.getItem(t);n&&(e[t.slice(rH.length)]=n)}}}catch(e){console.warn("[route-maps] Failed to read route overrides from localStorage",e)}return e}function r5(e,n){if(!rY)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{if("string"==typeof n)if(n.startsWith("http"))localStorage.setItem(rH+e,JSON.stringify(n));else{let t=JSON.parse(n);if(!rU(t))return void console.error(`The supplied routes for ${e} is not a valid OpenmrsAppRoutes object`,n);localStorage.setItem(rH+e,JSON.stringify(t))}else if(n instanceof URL)localStorage.setItem(rH+e,JSON.stringify(n.toString()));else{if(!rU(n))return void console.error(`Override for ${e} is not in a valid format. Expected either a Javascript Object, a JSON string of a Javascript object, or a URL`,n);localStorage.setItem(rH+e,JSON.stringify(n))}window.dispatchEvent(new CustomEvent(rK))}catch(e){console.warn("[route-maps] Failed to write route override to localStorage",e)}}function r4(e){if(!rY)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{localStorage.removeItem(rH+e),window.dispatchEvent(new CustomEvent(rK))}catch(e){console.warn("[route-maps] Failed to remove route override from localStorage",e)}}function r6(){if(!rY)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{let e=[];for(let n=0;n<localStorage.length;n++){let t=localStorage.key(n);t?.startsWith(rH)&&e.push(t)}e.forEach(e=>localStorage.removeItem(e)),window.dispatchEvent(new CustomEvent(rK))}catch(e){console.warn("[route-maps] Failed to clear route overrides from localStorage",e)}}let r8=null;function r7(){return r8||(r8=(rY="development"===window.spaEnv)?rQ().then(e=>{rJ=e}):Promise.resolve())}let r9=`${oh}/attachment`;function ie(e,n){return o_(`${r9}/${e}`,{signal:n.signal})}function it(e,n,t){return o_(`${r9}?patient=${e}&includeEncounterless=${n}`,{signal:t.signal})}async function ia(e,n){let t=new FormData;return t.append("fileCaption",n.fileDescription),t.append("patient",e),n.file?t.append("file",n.file,n.fileName):(t.append("file",new File([""],n.fileName),n.fileName),t.append("base64Content",n.base64Content)),o_(`${r9}`,{method:"POST",body:t})}function io(e,n){return o_(`${r9}/${e}`,{method:"DELETE",signal:n.signal})}try{self["workbox:window:6.5.4"]&&_()}catch(e){}function ir(e,n){return new Promise(function(t){var a=new MessageChannel;a.port1.onmessage=function(e){t(e.data)},e.postMessage(n,[a.port2])})}function ii(e,n){for(var t=0;t<n.length;t++){var a=n[t];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}function is(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,a=Array(n);t<n;t++)a[t]=e[t];return a}try{self["workbox:core:6.5.4"]&&_()}catch(e){}var il=function(){var e=this;this.promise=new Promise(function(n,t){e.resolve=n,e.reject=t})};function ic(e,n){var t=location.href;return new URL(e,t).href===new URL(n,t).href}var ip=function(e,n){this.type=e,Object.assign(this,n)};function iu(e,n,t){return t?n?n(e):e:(e&&e.then||(e=Promise.resolve(e)),n?e.then(n):e)}function id(){}var im={type:"SKIP_WAITING"};function ih(e,n){if(!n)return e&&e.then?e.then(id):Promise.resolve()}var ig=function(e){function n(n,t){var a,o;return void 0===t&&(t={}),(a=e.call(this)||this).nn={},a.tn=0,a.rn=new il,a.en=new il,a.on=new il,a.un=0,a.an=new Set,a.cn=function(){var e=a.fn,n=e.installing;a.tn>0||!ic(n.scriptURL,a.sn.toString())||performance.now()>a.un+6e4?(a.vn=n,e.removeEventListener("updatefound",a.cn)):(a.hn=n,a.an.add(n),a.rn.resolve(n)),++a.tn,n.addEventListener("statechange",a.ln)},a.ln=function(e){var n=a.fn,t=e.target,o=t.state,r=t===a.vn,i={sw:t,isExternal:r,originalEvent:e};!r&&a.mn&&(i.isUpdate=!0),a.dispatchEvent(new ip(o,i)),"installed"===o?a.wn=self.setTimeout(function(){"installed"===o&&n.waiting===t&&a.dispatchEvent(new ip("waiting",i))},200):"activating"===o&&(clearTimeout(a.wn),r||a.en.resolve(t))},a.dn=function(e){var n=a.hn,t=n!==navigator.serviceWorker.controller;a.dispatchEvent(new ip("controlling",{isExternal:t,originalEvent:e,sw:n,isUpdate:a.mn})),t||a.on.resolve(n)},o=function(e){var n=e.data,t=e.ports,o=e.source;return iu(a.getSW(),function(){a.an.has(o)&&a.dispatchEvent(new ip("message",{data:n,originalEvent:e,ports:t,sw:o}))})},a.gn=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];try{return Promise.resolve(o.apply(this,e))}catch(e){return Promise.reject(e)}},a.sn=n,a.nn=t,navigator.serviceWorker.addEventListener("message",a.gn),a}n.prototype=Object.create(e.prototype),n.prototype.constructor=n,n.__proto__=e;var t,a,o=n.prototype;return o.register=function(e){var n=(void 0===e?{}:e).immediate,t=void 0!==n&&n;try{var a,o,r,i=this;return a=function(){if(!t&&"complete"!==document.readyState)return ih(new Promise(function(e){return window.addEventListener("load",e)}))},o=function(){return i.mn=!!navigator.serviceWorker.controller,i.yn=i.pn(),iu(i.bn(),function(e){i.fn=e,i.yn&&(i.hn=i.yn,i.en.resolve(i.yn),i.on.resolve(i.yn),i.yn.addEventListener("statechange",i.ln,{once:!0}));var n=i.fn.waiting;return n&&ic(n.scriptURL,i.sn.toString())&&(i.hn=n,Promise.resolve().then(function(){i.dispatchEvent(new ip("waiting",{sw:n,wasWaitingBeforeRegister:!0}))}).then(function(){})),i.hn&&(i.rn.resolve(i.hn),i.an.add(i.hn)),i.fn.addEventListener("updatefound",i.cn),navigator.serviceWorker.addEventListener("controllerchange",i.dn),i.fn})},(r=a())&&r.then?r.then(o):o(r)}catch(e){return Promise.reject(e)}},o.update=function(){try{return this.fn?ih(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 iu(this.getSW(),function(n){return ir(n,e)})}catch(e){return Promise.reject(e)}},o.messageSkipWaiting=function(){this.fn&&this.fn.waiting&&ir(this.fn.waiting,im)},o.pn=function(){var e=navigator.serviceWorker.controller;return e&&ic(e.scriptURL,this.sn.toString())?e:void 0},o.bn=function(){try{var e=this;return function(e,n){try{var t=e()}catch(e){return n(e)}return t&&t.then?t.then(void 0,n):t}(function(){return iu(navigator.serviceWorker.register(e.sn,e.nn),function(n){return e.un=performance.now(),n})},function(e){throw e})}catch(e){return Promise.reject(e)}},t=[{key:"active",get:function(){return this.en.promise}},{key:"controlling",get:function(){return this.on.promise}}],ii(n.prototype,t),a&&ii(n,a),n}(function(){function e(){this.Pn=new Map}var n=e.prototype;return n.addEventListener=function(e,n){this.Sn(e).add(n)},n.removeEventListener=function(e,n){this.Sn(e).delete(n)},n.dispatchEvent=function(e){e.target=this;for(var n,t=function(e){var n;if("u"<typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e){if(e){if("string"==typeof e)return is(e,void 0);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?is(e,void 0):void 0}}(e))){n&&(e=n);var t=0;return function(){return t>=e.length?{done:!0}:{done:!1,value:e[t++]}}}throw TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(n=e[Symbol.iterator]()).next.bind(n)}(this.Sn(e.type));!(n=t()).done;)(0,n.value)(e)},n.Sn=function(e){return this.Pn.has(e)||this.Pn.set(e,new Set),this.Pn.get(e)},e}());function iy(e,n){if(void 0!==u)return console.warn(`The application's Service Worker has already been registered. The new service worker at ${e} will not be registered.`),u;if(!("serviceWorker"in navigator))throw Error("Registering the Service Worker is not possible due to missing browser capabilities.");let t=new ig(e,n);return u=t.register().then(()=>t.controlling.then(()=>t))}function ib(){return u??Promise.resolve(void 0)}let i_="x-omrs-offline-response-body",iv="x-omrs-offline-response-status",i$="x-omrs-offline-caching-strategy";async function iA(e){let n=await ib();return n?await n.messageSW(e):{success:!1,result:void 0,error:"No service worker has been registered. This is typically the case when the application has been built without offline-related features."}}async function ik(){let e=window.sessionStorage;try{e.setItem("someKeyHere","test"),e.removeItem("someKeyHere")}catch(n){if(n.code===DOMException.QUOTA_EXCEEDED_ERR&&0===e.length)return!0}return!1}async function iw(){return!window.indexedDB}async function ix(){return new Promise(e=>{let n=indexedDB.open("test");n.onerror=()=>e(!0),n.onsuccess=()=>e(!1)})}async function iC(){return await ix()||await iw()||await ik()}let iE="openmrs3:offline-mode",iS="unavailable";function iD(){return{current:iS,notAvailable:"unavailable"===iS,active:"on"===iS}}function iM(e){"unavailable"!==iS&&"unavailable"!==e&&(localStorage.setItem(iE,"on"===e?"active":"disabled"),iS=e)}async function iz(){await iC()||(iS="active"===localStorage.getItem(iE)?"on":"off"),navigator.onLine}let iO="u">typeof globalThis?globalThis:"u">typeof self?self:"u">typeof window?window:global,iP=Object.keys,iT=Array.isArray;function iB(e,n){return"object"!=typeof n||iP(n).forEach(function(t){e[t]=n[t]}),e}"u"<typeof Promise||iO.Promise||(iO.Promise=Promise);let iI=Object.getPrototypeOf,iN={}.hasOwnProperty;function ij(e,n){return iN.call(e,n)}function iR(e,n){"function"==typeof n&&(n=n(iI(e))),("u"<typeof Reflect?iP:Reflect.ownKeys)(n).forEach(t=>{iL(e,t,n[t])})}let iF=Object.defineProperty;function iL(e,n,t,a){iF(e,n,iB(t&&ij(t,"get")&&"function"==typeof t.get?{get:t.get,set:t.set,configurable:!0}:{value:t,configurable:!0,writable:!0},a))}function iW(e){return{from:function(n){return e.prototype=Object.create(n.prototype),iL(e.prototype,"constructor",e),{extend:iR.bind(null,e.prototype)}}}}let iG=Object.getOwnPropertyDescriptor;function iV(e,n){let t;return iG(e,n)||(t=iI(e))&&iV(t,n)}let iU=[].slice;function iq(e,n,t){return iU.call(e,n,t)}function iH(e,n){return n(e)}function iK(e){if(!e)throw Error("Assertion Failed")}function iY(e){iO.setImmediate?setImmediate(e):setTimeout(e,0)}function iJ(e,n){return e.reduce((e,t,a)=>{var o=n(t,a);return o&&(e[o[0]]=o[1]),e},{})}function iZ(e,n){if(ij(e,n))return e[n];if(!n)return e;if("string"!=typeof n){for(var t=[],a=0,o=n.length;a<o;++a){var r=iZ(e,n[a]);t.push(r)}return t}var i=n.indexOf(".");if(-1!==i){var s=e[n.substr(0,i)];return void 0===s?void 0:iZ(s,n.substr(i+1))}}function iX(e,n,t){if(e&&void 0!==n&&(!("isFrozen"in Object)||!Object.isFrozen(e)))if("string"!=typeof n&&"length"in n){iK("string"!=typeof t&&"length"in t);for(var a=0,o=n.length;a<o;++a)iX(e,n[a],t[a])}else{var r=n.indexOf(".");if(-1!==r){var i=n.substr(0,r),s=n.substr(r+1);if(""===s)void 0===t?iT(e)&&!isNaN(parseInt(i))?e.splice(i,1):delete e[i]:e[i]=t;else{var l=e[i];l&&ij(e,i)||(l=e[i]={}),iX(l,s,t)}}else void 0===t?iT(e)&&!isNaN(parseInt(n))?e.splice(n,1):delete e[n]:e[n]=t}}function iQ(e){var n={};for(var t in e)ij(e,t)&&(n[t]=e[t]);return n}let i0=[].concat;function i1(e){return i0.apply([],e)}let i2="Boolean,String,Date,RegExp,Blob,File,FileList,FileSystemFileHandle,ArrayBuffer,DataView,Uint8ClampedArray,ImageBitmap,ImageData,Map,Set,CryptoKey".split(",").concat(i1([8,16,32,64].map(e=>["Int","Uint","Float"].map(n=>n+e+"Array")))).filter(e=>iO[e]),i3=i2.map(e=>iO[e]);iJ(i2,e=>[e,!0]);let i5=null;function i4(e){i5="u">typeof WeakMap&&new WeakMap;let n=function e(n){if(!n||"object"!=typeof n)return n;let t=i5&&i5.get(n);if(t)return t;if(iT(n)){t=[],i5&&i5.set(n,t);for(var a=0,o=n.length;a<o;++a)t.push(e(n[a]))}else if(i3.indexOf(n.constructor)>=0)t=n;else{let a=iI(n);for(var r in t=a===Object.prototype?{}:Object.create(a),i5&&i5.set(n,t),n)ij(n,r)&&(t[r]=e(n[r]))}return t}(e);return i5=null,n}let{toString:i6}={};function i8(e){return i6.call(e).slice(8,-1)}let i7="u">typeof Symbol?Symbol.iterator:"@@iterator",i9="symbol"==typeof i7?function(e){var n;return null!=e&&(n=e[i7])&&n.apply(e)}:function(){return null},se={};function sn(e){var n,t,a,o;if(1==arguments.length){if(iT(e))return e.slice();if(this===se&&"string"==typeof e)return[e];if(o=i9(e)){for(t=[];!(a=o.next()).done;)t.push(a.value);return t}if(null==e)return[e];if("number"==typeof(n=e.length)){for(t=Array(n);n--;)t[n]=e[n];return t}return[e]}for(n=arguments.length,t=Array(n);n--;)t[n]=arguments[n];return t}let st="u">typeof Symbol?e=>"AsyncFunction"===e[Symbol.toStringTag]:()=>!1;var sa="u">typeof location&&/^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href),so=()=>!0;let sr=!Error("").stack;function si(){if(sr)try{throw si.arguments,Error()}catch(e){return e}return Error()}function ss(e,n){var t=e.stack;return t?(n=n||0,0===t.indexOf(e.name)&&(n+=(e.name+e.message).split("\n").length),t.split("\n").slice(n).filter(so).map(e=>"\n"+e).join("")):""}var sl=["Unknown","Constraint","Data","TransactionInactive","ReadOnly","Version","NotFound","InvalidState","InvalidAccess","Abort","Timeout","QuotaExceeded","Syntax","DataClone"],sc=["Modify","Bulk","OpenFailed","VersionChange","Schema","Upgrade","InvalidTable","MissingAPI","NoSuchDatabase","InvalidArgument","SubTransaction","Unsupported","Internal","DatabaseClosed","PrematureCommit","ForeignAwait"].concat(sl),sp={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 su(e,n){this._e=si(),this.name=e,this.message=n}function sd(e,n){return e+". Errors: "+Object.keys(n).map(e=>n[e].toString()).filter((e,n,t)=>t.indexOf(e)===n).join("\n")}function sf(e,n,t,a){this._e=si(),this.failures=n,this.failedKeys=a,this.successCount=t,this.message=sd(e,n)}function sm(e,n){this._e=si(),this.name="BulkError",this.failures=Object.keys(n).map(e=>n[e]),this.failuresByPos=n,this.message=sd(e,n)}iW(su).from(Error).extend({stack:{get:function(){return this._stack||(this._stack=this.name+": "+this.message+ss(this._e,2))}},toString:function(){return this.name+": "+this.message}}),iW(sf).from(su),iW(sm).from(su);var sh=sc.reduce((e,n)=>(e[n]=n+"Error",e),{}),sg=sc.reduce((e,n)=>{var t=n+"Error";function a(e,a){this._e=si(),this.name=t,e?"string"==typeof e?(this.message=`${e}${a?"\n "+a:""}`,this.inner=a||null):"object"==typeof e&&(this.message=`${e.name} ${e.message}`,this.inner=e):(this.message=sp[n]||t,this.inner=null)}return iW(a).from(su),e[n]=a,e},{});sg.Syntax=SyntaxError,sg.Type=TypeError,sg.Range=RangeError;var sy=sl.reduce((e,n)=>(e[n+"Error"]=sg[n],e),{}),sb=sc.reduce((e,n)=>(-1===["Syntax","Type","Range"].indexOf(n)&&(e[n+"Error"]=sg[n]),e),{});function s_(){}function sv(e){return e}function s$(e,n){return null==e||e===sv?n:function(t){return n(e(t))}}function sA(e,n){return function(){e.apply(this,arguments),n.apply(this,arguments)}}function sk(e,n){return e===s_?n:function(){var t=e.apply(this,arguments);void 0!==t&&(arguments[0]=t);var a=this.onsuccess,o=this.onerror;this.onsuccess=null,this.onerror=null;var r=n.apply(this,arguments);return a&&(this.onsuccess=this.onsuccess?sA(a,this.onsuccess):a),o&&(this.onerror=this.onerror?sA(o,this.onerror):o),void 0!==r?r:t}}function sw(e,n){return e===s_?n:function(){e.apply(this,arguments);var t=this.onsuccess,a=this.onerror;this.onsuccess=this.onerror=null,n.apply(this,arguments),t&&(this.onsuccess=this.onsuccess?sA(t,this.onsuccess):t),a&&(this.onerror=this.onerror?sA(a,this.onerror):a)}}function sx(e,n){return e===s_?n:function(t){var a=e.apply(this,arguments);iB(t,a);var o=this.onsuccess,r=this.onerror;this.onsuccess=null,this.onerror=null;var i=n.apply(this,arguments);return o&&(this.onsuccess=this.onsuccess?sA(o,this.onsuccess):o),r&&(this.onerror=this.onerror?sA(r,this.onerror):r),void 0===a?void 0===i?void 0:i:iB(a,i)}}function sC(e,n){return e===s_?n:function(){return!1!==n.apply(this,arguments)&&e.apply(this,arguments)}}function sE(e,n){return e===s_?n:function(){var t=e.apply(this,arguments);if(t&&"function"==typeof t.then){for(var a=this,o=arguments.length,r=Array(o);o--;)r[o]=arguments[o];return t.then(function(){return n.apply(a,r)})}return n.apply(this,arguments)}}sb.ModifyError=sf,sb.DexieError=su,sb.BulkError=sm;var sS={};let[sD,sM,sz]="u"<typeof Promise?[]:(()=>{let e=Promise.resolve();if("u"<typeof crypto||!crypto.subtle)return[e,iI(e),e];let n=crypto.subtle.digest("SHA-512",new Uint8Array([0]));return[n,iI(n),e]})(),sO=sM&&sM.then,sP=sD&&sD.constructor,sT=!!sz;var sB=!1,sI=sz?()=>{sz.then(s3)}:iO.setImmediate?setImmediate.bind(null,s3):iO.MutationObserver?()=>{var e=document.createElement("div");new MutationObserver(()=>{s3(),e=null}).observe(e,{attributes:!0}),e.setAttribute("i","1")}:()=>{setTimeout(s3,0)},sN=function(e,n){sq.push([e,n]),sR&&(sI(),sR=!1)},sj=!0,sR=!0,sF=[],sL=[],sW=null,sG=sv,sV={id:"global",global:!0,ref:0,unhandleds:[],onunhandled:ly,pgp:!1,env:{},finalize:function(){this.unhandleds.forEach(e=>{try{ly(e[0],e[1])}catch(e){}})}},sU=sV,sq=[],sH=0,sK=[];function sY(e){if("object"!=typeof this)throw TypeError("Promises must be constructed via new");this._listeners=[],this.onuncatched=s_,this._lib=!1;var n=this._PSD=sU;if(sa&&(this._stackHolder=si(),this._prev=null,this._numPrev=0),"function"!=typeof e){if(e!==sS)throw TypeError("Not a function");return this._state=arguments[1],this._value=arguments[2],void(!1===this._state&&sX(this,this._value))}this._state=null,this._value=null,++n.ref,function e(n,t){try{t(t=>{if(null===n._state){if(t===n)throw TypeError("A promise cannot be resolved with itself.");var a=n._lib&&s5();t&&"function"==typeof t.then?e(n,(e,n)=>{t instanceof sY?t._then(e,n):t.then(e,n)}):(n._state=!0,n._value=t,sQ(n)),a&&s4()}},sX.bind(null,n))}catch(e){sX(n,e)}}(this,e)}let sJ={get:function(){var e=sU,n=la;function t(t,a){var o=!e.global&&(e!==sU||n!==la);let r=o&&!ls();var i=new sY((n,i)=>{s0(this,new sZ(lm(t,e,o,r),lm(a,e,o,r),n,i,e))});return sa&&s2(i,this),i}return t.prototype=sS,t},set:function(e){iL(this,"then",e&&e.prototype===sS?sJ:{get:function(){return e},set:sJ.set})}};function sZ(e,n,t,a,o){this.onFulfilled="function"==typeof e?e:null,this.onRejected="function"==typeof n?n:null,this.resolve=t,this.reject=a,this.psd=o}function sX(e,n){if(sL.push(n),null===e._state){var t=e._lib&&s5();n=sG(n),e._state=!1,e._value=n,sa&&null!==n&&"object"==typeof n&&!n._promise&&function(e){try{e.apply(null,void 0)}catch(e){}}(()=>{var t=iV(n,"stack");n._promise=e,iL(n,"stack",{get:()=>sB?t&&(t.get?t.get.apply(n):t.value):e.stack})}),sF.some(n=>n._value===e._value)||sF.push(e),sQ(e),t&&s4()}}function sQ(e){var n=e._listeners;e._listeners=[];for(var t=0,a=n.length;t<a;++t)s0(e,n[t]);var o=e._PSD;--o.ref||o.finalize(),0===sH&&(++sH,sN(()=>{0==--sH&&s6()},[]))}function s0(e,n){if(null!==e._state){var t=e._state?n.onFulfilled:n.onRejected;if(null===t)return(e._state?n.resolve:n.reject)(e._value);++n.psd.ref,++sH,sN(s1,[t,e,n])}else e._listeners.push(n)}function s1(e,n,t){try{sW=n;var a,o=n._value;n._state?a=e(o):(sL.length&&(sL=[]),a=e(o),-1===sL.indexOf(o)&&function(e){for(var n=sF.length;n;)if(sF[--n]._value===e._value)return void sF.splice(n,1)}(n)),t.resolve(a)}catch(e){t.reject(e)}finally{sW=null,0==--sH&&s6(),--t.psd.ref||t.psd.finalize()}}function s2(e,n){var t=n?n._numPrev+1:0;t<100&&(e._prev=n,e._numPrev=t)}function s3(){s5()&&s4()}function s5(){var e=sj;return sj=!1,sR=!1,e}function s4(){var e,n,t;do for(;sq.length>0;)for(e=sq,sq=[],t=e.length,n=0;n<t;++n){var a=e[n];a[0].apply(null,a[1])}while(sq.length>0);sj=!0,sR=!0}function s6(){var e=sF;sF=[],e.forEach(e=>{e._PSD.onunhandled.call(null,e._value,e)});for(var n=sK.slice(0),t=n.length;t;)n[--t]()}function s8(e){return new sY(sS,!1,e)}function s7(e,n){var t=sU;return function(){var a=s5(),o=sU;try{return lu(t,!0),e.apply(this,arguments)}catch(e){n&&n(e)}finally{lu(o,!1),a&&s4()}}}iR(sY.prototype,{then:sJ,_then:function(e,n){s0(this,new sZ(null,null,e,n,sU))},catch:function(e){if(1==arguments.length)return this.then(null,e);var n=arguments[0],t=arguments[1];return"function"==typeof n?this.then(null,e=>e instanceof n?t(e):s8(e)):this.then(null,e=>e&&e.name===n?t(e):s8(e))},finally:function(e){return this.then(n=>(e(),n),n=>(e(),s8(n)))},stack:{get:function(){if(this._stack)return this._stack;try{sB=!0;var e=(function e(n,t,a){if(t.length===a)return t;var o="";if(!1===n._state){var r,i,s=n._value;null!=s?(r=s.name||"Error",i=s.message||s,o=ss(s,0)):(r=s,i=""),t.push(r+(i?": "+i:"")+o)}return sa&&((o=ss(n._stackHolder,2))&&-1===t.indexOf(o)&&t.push(o),n._prev&&e(n._prev,t,a)),t})(this,[],20).join("\nFrom previous: ");return null!==this._state&&(this._stack=e),e}finally{sB=!1}}},timeout:function(e,n){return e<1/0?new sY((t,a)=>{var o=setTimeout(()=>a(new sg.Timeout(n)),e);this.then(t,a).finally(clearTimeout.bind(null,o))}):this}}),"u">typeof Symbol&&Symbol.toStringTag&&iL(sY.prototype,Symbol.toStringTag,"Dexie.Promise"),sV.env=ld(),iR(sY,{all:function(){var e=sn.apply(null,arguments).map(ll);return new sY(function(n,t){0===e.length&&n([]);var a=e.length;e.forEach((o,r)=>sY.resolve(o).then(t=>{e[r]=t,--a||n(e)},t))})},resolve:e=>{if(e instanceof sY)return e;if(e&&"function"==typeof e.then)return new sY((n,t)=>{e.then(n,t)});var n=new sY(sS,!0,e);return s2(n,sW),n},reject:s8,race:function(){var e=sn.apply(null,arguments).map(ll);return new sY((n,t)=>{e.map(e=>sY.resolve(e).then(n,t))})},PSD:{get:()=>sU,set:e=>sU=e},totalEchoes:{get:()=>la},newPSD:lr,usePSD:lf,scheduler:{get:()=>sN,set:e=>{sN=e}},rejectionMapper:{get:()=>sG,set:e=>{sG=e}},follow:(e,n)=>new sY((t,a)=>lr((n,t)=>{var a=sU;a.unhandleds=[],a.onunhandled=t,a.finalize=sA(function(){var e;e=()=>{0===this.unhandleds.length?n():t(this.unhandleds[0])},sK.push(function n(){e(),sK.splice(sK.indexOf(n),1)}),++sH,sN(()=>{0==--sH&&s6()},[])},a.finalize),e()},n,t,a))}),sP&&(sP.allSettled&&iL(sY,"allSettled",function(){let e=sn.apply(null,arguments).map(ll);return new sY(n=>{0===e.length&&n([]);let t=e.length,a=Array(t);e.forEach((e,o)=>sY.resolve(e).then(e=>a[o]={status:"fulfilled",value:e},e=>a[o]={status:"rejected",reason:e}).then(()=>--t||n(a)))})}),sP.any&&"u">typeof AggregateError&&iL(sY,"any",function(){let e=sn.apply(null,arguments).map(ll);return new sY((n,t)=>{0===e.length&&t(AggregateError([]));let a=e.length,o=Array(a);e.forEach((e,r)=>sY.resolve(e).then(e=>n(e),e=>{o[r]=e,--a||t(AggregateError(o))}))})}));let s9={awaits:0,echoes:0,id:0};var le=0,ln=[],lt=0,la=0,lo=0;function lr(e,n,t,a){var o=sU,r=Object.create(o);r.parent=o,r.ref=0,r.global=!1,r.id=++lo;var i=sV.env;r.env=sT?{Promise:sY,PromiseProp:{value:sY,configurable:!0,writable:!0},all:sY.all,race:sY.race,allSettled:sY.allSettled,any:sY.any,resolve:sY.resolve,reject:sY.reject,nthen:lh(i.nthen,r),gthen:lh(i.gthen,r)}:{},n&&iB(r,n),++o.ref,r.finalize=function(){--this.parent.ref||this.parent.finalize()};var s=lf(r,e,t,a);return 0===r.ref&&r.finalize(),s}function li(){return s9.id||(s9.id=++le),++s9.awaits,s9.echoes+=100,s9.id}function ls(){return!!s9.awaits&&(0==--s9.awaits&&(s9.id=0),s9.echoes=100*s9.awaits,!0)}function ll(e){return s9.echoes&&e&&e.constructor===sP?(li(),e.then(e=>(ls(),e),e=>(ls(),lb(e)))):e}function lc(e){++la,s9.echoes&&0!=--s9.echoes||(s9.echoes=s9.id=0),ln.push(sU),lu(e,!0)}function lp(){var e=ln[ln.length-1];ln.pop(),lu(e,!1)}function lu(e,n){var t,a=sU;if((n?!s9.echoes||lt++&&e===sU:!lt||--lt&&e===sU)||(t=n?lc.bind(null,e):lp,sO.call(sD,t)),e!==sU&&(sU=e,a===sV&&(sV.env=ld()),sT)){var o=sV.env.Promise,r=e.env;sM.then=r.nthen,o.prototype.then=r.gthen,(a.global||e.global)&&(Object.defineProperty(iO,"Promise",r.PromiseProp),o.all=r.all,o.race=r.race,o.resolve=r.resolve,o.reject=r.reject,r.allSettled&&(o.allSettled=r.allSettled),r.any&&(o.any=r.any))}}function ld(){var e=iO.Promise;return sT?{Promise:e,PromiseProp:Object.getOwnPropertyDescriptor(iO,"Promise"),all:e.all,race:e.race,allSettled:e.allSettled,any:e.any,resolve:e.resolve,reject:e.reject,nthen:sM.then,gthen:e.prototype.then}:{}}function lf(e,n,t,a,o){var r=sU;try{return lu(e,!0),n(t,a,o)}finally{lu(r,!1)}}function lm(e,n,t,a){return"function"!=typeof e?e:function(){var o,r=sU;t&&li(),lu(n,!0);try{return e.apply(this,arguments)}finally{lu(r,!1),a&&(o=ls,sO.call(sD,o))}}}function lh(e,n){return function(t,a){return e.call(this,lm(t,n),lm(a,n))}}-1===(""+sO).indexOf("[native code]")&&(li=ls=s_);let lg="unhandledrejection";function ly(e,n){var t;try{t=n.onuncatched(e)}catch(e){}if(!1!==t)try{var a,o={promise:n,reason:e};if(iO.document&&document.createEvent?((a=document.createEvent("Event")).initEvent(lg,!0,!0),iB(a,o)):iO.CustomEvent&&iB(a=new CustomEvent(lg,{detail:o}),o),a&&iO.dispatchEvent&&(dispatchEvent(a),!iO.PromiseRejectionEvent&&iO.onunhandledrejection))try{iO.onunhandledrejection(a)}catch(e){}sa&&a&&!a.defaultPrevented&&console.warn(`Unhandled rejection: ${e.stack||e}`)}catch(e){}}var lb=sY.reject;let l_="3.2.4",lv=String.fromCharCode(65535),l$=-1/0,lA="Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.",lk="String expected.",lw=[],lx="u">typeof navigator&&/(MSIE|Trident|Edge)/.test(navigator.userAgent),lC=e=>!/(dexie\.js|dexie\.min\.js)/.test(e),lE="__dbnames",lS="readonly",lD="readwrite";function lM(e,n){return e?n?function(){return e.apply(this,arguments)&&n.apply(this,arguments)}:e:n}let lz={type:3,lower:-1/0,lowerOpen:!1,upper:[[]],upperOpen:!1};function lO(e){return"string"!=typeof e||/\./.test(e)?e=>e:n=>(void 0===n[e]&&e in n&&delete(n=i4(n))[e],n)}class lP{_trans(e,n,t){let a=this._tx||sU.trans,o=this.name;function r(e,t,a){if(!a.schema[o])throw new sg.NotFound("Table "+o+" not part of transaction");return n(a.idbtrans,a)}let i=s5();try{return a&&a.db===this.db?a===sU.trans?a._promise(e,r,t):lr(()=>a._promise(e,r,t),{trans:a,transless:sU.transless||sU}):function e(n,t,a,o){if(n.idbdb&&(n._state.openComplete||sU.letThrough||n._vip)){var r=n._createTransaction(t,a,n._dbSchema);try{r.create(),n._state.PR1398_maxLoop=3}catch(r){return r.name===sh.InvalidState&&n.isOpen()&&--n._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),n._close(),n.open().then(()=>e(n,t,a,o))):lb(r)}return r._promise(t,(e,n)=>lr(()=>(sU.trans=r,o(e,n,r)))).then(e=>r._completion.then(()=>e))}if(n._state.openComplete)return lb(new sg.DatabaseClosed(n._state.dbOpenError));if(!n._state.isBeingOpened){if(!n._options.autoOpen)return lb(new sg.DatabaseClosed);n.open().catch(s_)}return n._state.dbReadyPromise.then(()=>e(n,t,a,o))}(this.db,e,[this.name],r)}finally{i&&s4()}}get(e,n){return e&&e.constructor===Object?this.where(e).first(n):this._trans("readonly",n=>this.core.get({trans:n,key:e}).then(e=>this.hook.reading.fire(e))).then(n)}where(e){if("string"==typeof e)return new this.db.WhereClause(this,e);if(iT(e))return new this.db.WhereClause(this,`[${e.join("+")}]`);let n=iP(e);if(1===n.length)return this.where(n[0]).equals(e[n[0]]);let t=this.schema.indexes.concat(this.schema.primKey).filter(e=>e.compound&&n.every(n=>e.keyPath.indexOf(n)>=0)&&e.keyPath.every(e=>n.indexOf(e)>=0))[0];if(t&&this.db._maxKey!==lv)return this.where(t.name).equals(t.keyPath.map(n=>e[n]));!t&&sa&&console.warn(`The query ${JSON.stringify(e)} on ${this.name} would benefit of a compound index [${n.join("+")}]`);let{idxByName:a}=this.schema,o=this.db._deps.indexedDB;function r(e,n){try{return 0===o.cmp(e,n)}catch(e){return!1}}let[i,s]=n.reduce(([n,t],o)=>{let i=a[o],s=e[o];return[n||i,n||!i?lM(t,i&&i.multi?e=>{let n=iZ(e,o);return iT(n)&&n.some(e=>r(s,e))}:e=>r(s,iZ(e,o))):t]},[null,null]);return i?this.where(i.name).equals(e[i.keyPath]).filter(s):t?this.filter(s):this.where(n).equals("")}filter(e){return this.toCollection().and(e)}count(e){return this.toCollection().count(e)}offset(e){return this.toCollection().offset(e)}limit(e){return this.toCollection().limit(e)}each(e){return this.toCollection().each(e)}toArray(e){return this.toCollection().toArray(e)}toCollection(){return new this.db.Collection(new this.db.WhereClause(this))}orderBy(e){return new this.db.Collection(new this.db.WhereClause(this,iT(e)?`[${e.join("+")}]`:e))}reverse(){return this.toCollection().reverse()}mapToClass(e){this.schema.mappedClass=e;let n=n=>{if(!n)return n;let t=Object.create(e.prototype);for(var a in n)if(ij(n,a))try{t[a]=n[a]}catch(e){}return t};return this.schema.readHook&&this.hook.reading.unsubscribe(this.schema.readHook),this.schema.readHook=n,this.hook("reading",n),e}defineClass(){return this.mapToClass(function(e){iB(this,e)})}add(e,n){let{auto:t,keyPath:a}=this.schema.primKey,o=e;return a&&t&&(o=lO(a)(e)),this._trans("readwrite",e=>this.core.mutate({trans:e,type:"add",keys:null!=n?[n]:null,values:[o]})).then(e=>e.numFailures?sY.reject(e.failures[0]):e.lastResult).then(n=>{if(a)try{iX(e,a,n)}catch(e){}return n})}update(e,n){if("object"!=typeof e||iT(e))return this.where(":id").equals(e).modify(n);{let t=iZ(e,this.schema.primKey.keyPath);if(void 0===t)return lb(new sg.InvalidArgument("Given object does not contain its primary key"));try{"function"!=typeof n?iP(n).forEach(t=>{iX(e,t,n[t])}):n(e,{value:e,primKey:t})}catch(e){}return this.where(":id").equals(t).modify(n)}}put(e,n){let{auto:t,keyPath:a}=this.schema.primKey,o=e;return a&&t&&(o=lO(a)(e)),this._trans("readwrite",e=>this.core.mutate({trans:e,type:"put",values:[o],keys:null!=n?[n]:null})).then(e=>e.numFailures?sY.reject(e.failures[0]):e.lastResult).then(n=>{if(a)try{iX(e,a,n)}catch(e){}return n})}delete(e){return this._trans("readwrite",n=>this.core.mutate({trans:n,type:"delete",keys:[e]})).then(e=>e.numFailures?sY.reject(e.failures[0]):void 0)}clear(){return this._trans("readwrite",e=>this.core.mutate({trans:e,type:"deleteRange",range:lz})).then(e=>e.numFailures?sY.reject(e.failures[0]):void 0)}bulkGet(e){return this._trans("readonly",n=>this.core.getMany({keys:e,trans:n}).then(e=>e.map(e=>this.hook.reading.fire(e))))}bulkAdd(e,n,t){let a=Array.isArray(n)?n:void 0,o=(t=t||(a?void 0:n))?t.allKeys:void 0;return this._trans("readwrite",n=>{let{auto:t,keyPath:r}=this.schema.primKey;if(r&&a)throw new sg.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(a&&a.length!==e.length)throw new sg.InvalidArgument("Arguments objects and keys must have the same length");let i=e.length,s=r&&t?e.map(lO(r)):e;return this.core.mutate({trans:n,type:"add",keys:a,values:s,wantResults:o}).then(({numFailures:e,results:n,lastResult:t,failures:a})=>{if(0===e)return o?n:t;throw new sm(`${this.name}.bulkAdd(): ${e} of ${i} operations failed`,a)})})}bulkPut(e,n,t){let a=Array.isArray(n)?n:void 0,o=(t=t||(a?void 0:n))?t.allKeys:void 0;return this._trans("readwrite",n=>{let{auto:t,keyPath:r}=this.schema.primKey;if(r&&a)throw new sg.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(a&&a.length!==e.length)throw new sg.InvalidArgument("Arguments objects and keys must have the same length");let i=e.length,s=r&&t?e.map(lO(r)):e;return this.core.mutate({trans:n,type:"put",keys:a,values:s,wantResults:o}).then(({numFailures:e,results:n,lastResult:t,failures:a})=>{if(0===e)return o?n:t;throw new sm(`${this.name}.bulkPut(): ${e} of ${i} operations failed`,a)})})}bulkDelete(e){let n=e.length;return this._trans("readwrite",n=>this.core.mutate({trans:n,type:"delete",keys:e})).then(({numFailures:e,lastResult:t,failures:a})=>{if(0===e)return t;throw new sm(`${this.name}.bulkDelete(): ${e} of ${n} operations failed`,a)})}}function lT(e){var n={},t=function(t,a){if(a){for(var o=arguments.length,r=Array(o-1);--o;)r[o-1]=arguments[o];return n[t].subscribe.apply(null,r),e}if("string"==typeof t)return n[t]};t.addEventType=r;for(var a=1,o=arguments.length;a<o;++a)r(arguments[a]);return t;function r(e,a,o){if("object"!=typeof e){a||(a=sC),o||(o=s_);var i={subscribers:[],fire:o,subscribe:function(e){-1===i.subscribers.indexOf(e)&&(i.subscribers.push(e),i.fire=a(i.fire,e))},unsubscribe:function(e){i.subscribers=i.subscribers.filter(function(n){return n!==e}),i.fire=i.subscribers.reduce(a,o)}};return n[e]=t[e]=i,i}iP(e).forEach(function(n){var t=e[n];if(iT(t))r(n,e[n][0],e[n][1]);else{if("asap"!==t)throw new sg.InvalidArgument("Invalid event config");var a=r(n,sv,function(){for(var e=arguments.length,n=Array(e);e--;)n[e]=arguments[e];a.subscribers.forEach(function(e){iY(function(){e.apply(null,n)})})})}})}}function lB(e,n){return iW(n).from({prototype:e}),n}function lI(e,n){return!(e.filter||e.algorithm||e.or)&&(n?e.justLimit:!e.replayFilter)}function lN(e,n){e.filter=lM(e.filter,n)}function lj(e,n,t){var a=e.replayFilter;e.replayFilter=a?()=>lM(a(),n()):n,e.justLimit=t&&!a}function lR(e,n){if(e.isPrimKey)return n.primaryKey;let t=n.getIndexByKeyPath(e.index);if(!t)throw new sg.Schema("KeyPath "+e.index+" on object store "+n.name+" is not indexed");return t}function lF(e,n,t){let a=lR(e,n.schema);return n.openCursor({trans:t,values:!e.keysOnly,reverse:"prev"===e.dir,unique:!!e.unique,query:{index:a,range:e.range}})}function lL(e,n,t,a){let o=e.replayFilter?lM(e.filter,e.replayFilter()):e.filter;if(e.or){let r={},i=(e,t,a)=>{if(!o||o(t,a,e=>t.stop(e),e=>t.fail(e))){var i=t.primaryKey,s=""+i;"[object ArrayBuffer]"===s&&(s=""+new Uint8Array(i)),ij(r,s)||(r[s]=!0,n(e,t,a))}};return Promise.all([e.or._iterate(i,t),lW(lF(e,a,t),e.algorithm,i,!e.keysOnly&&e.valueMapper)])}return lW(lF(e,a,t),lM(e.algorithm,o),n,!e.keysOnly&&e.valueMapper)}function lW(e,n,t,a){var o=s7(a?(e,n,o)=>t(a(e),n,o):t);return e.then(e=>{if(e)return e.start(()=>{var t=()=>e.continue();n&&!n(e,e=>t=e,n=>{e.stop(n),t=s_},n=>{e.fail(n),t=s_})||o(e.value,e,e=>t=e),t()})})}function lG(e,n){try{let t=lV(e),a=lV(n);if(t!==a)return"Array"===t?1:"Array"===a?-1:"binary"===t?1:"binary"===a?-1:"string"===t?1:"string"===a?-1:"Date"===t?1:"Date"!==a?NaN:-1;switch(t){case"number":case"Date":case"string":return e>n?1:e<n?-1:0;case"binary":return function(e,n){let t=e.length,a=n.length,o=t<a?t:a;for(let t=0;t<o;++t)if(e[t]!==n[t])return e[t]<n[t]?-1:1;return t===a?0:t<a?-1:1}(lU(e),lU(n));case"Array":return function(e,n){let t=e.length,a=n.length,o=t<a?t:a;for(let t=0;t<o;++t){let a=lG(e[t],n[t]);if(0!==a)return a}return t===a?0:t<a?-1:1}(e,n)}}catch(e){}return NaN}function lV(e){let n=typeof e;if("object"!==n)return n;if(ArrayBuffer.isView(e))return"binary";let t=i8(e);return"ArrayBuffer"===t?"binary":t}function lU(e){return e instanceof Uint8Array?e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e)}class lq{_read(e,n){var t=this._ctx;return t.error?t.table._trans(null,lb.bind(null,t.error)):t.table._trans("readonly",e).then(n)}_write(e){var n=this._ctx;return n.error?n.table._trans(null,lb.bind(null,n.error)):n.table._trans("readwrite",e,"locked")}_addAlgorithm(e){var n=this._ctx;n.algorithm=lM(n.algorithm,e)}_iterate(e,n){return lL(this._ctx,e,n,this._ctx.table.core)}clone(e){var n=Object.create(this.constructor.prototype),t=Object.create(this._ctx);return e&&iB(t,e),n._ctx=t,n}raw(){return this._ctx.valueMapper=null,this}each(e){var n=this._ctx;return this._read(t=>lL(n,e,t,n.table.core))}count(e){return this._read(e=>{let n=this._ctx,t=n.table.core;if(lI(n,!0))return t.count({trans:e,query:{index:lR(n,t.schema),range:n.range}}).then(e=>Math.min(e,n.limit));var a=0;return lL(n,()=>(++a,!1),e,t).then(()=>a)}).then(e)}sortBy(e,n){let t=e.split(".").reverse(),a=t[0],o=t.length-1;function r(e,n){return n?r(e[t[n]],n-1):e[a]}var i="next"===this._ctx.dir?1:-1;function s(e,n){var t=r(e,o),a=r(n,o);return t<a?-i:t>a?i:0}return this.toArray(function(e){return e.sort(s)}).then(n)}toArray(e){return this._read(e=>{var n=this._ctx;if("next"===n.dir&&lI(n,!0)&&n.limit>0){let{valueMapper:t}=n,a=lR(n,n.table.core.schema);return n.table.core.query({trans:e,limit:n.limit,values:!0,query:{index:a,range:n.range}}).then(({result:e})=>t?e.map(t):e)}{let t=[];return lL(n,e=>t.push(e),e,n.table.core).then(()=>t)}},e)}offset(e){var n=this._ctx;return e<=0||(n.offset+=e,lI(n)?lj(n,()=>{var n=e;return(e,t)=>0===n||(1===n?--n:t(()=>{e.advance(n),n=0}),!1)}):lj(n,()=>{var n=e;return()=>--n<0})),this}limit(e){return this._ctx.limit=Math.min(this._ctx.limit,e),lj(this._ctx,()=>{var n=e;return function(e,t,a){return--n<=0&&t(a),n>=0}},!0),this}until(e,n){return lN(this._ctx,function(t,a,o){return!e(t.value)||(a(o),n)}),this}first(e){return this.limit(1).toArray(function(e){return e[0]}).then(e)}last(e){return this.reverse().first(e)}filter(e){var n;return lN(this._ctx,function(n){return e(n.value)}),(n=this._ctx).isMatch=lM(n.isMatch,e),this}and(e){return this.filter(e)}or(e){return new this.db.WhereClause(this._ctx.table,e,this)}reverse(){return this._ctx.dir="prev"===this._ctx.dir?"next":"prev",this._ondirectionchange&&this._ondirectionchange(this._ctx.dir),this}desc(){return this.reverse()}eachKey(e){var n=this._ctx;return n.keysOnly=!n.isMatch,this.each(function(n,t){e(t.key,t)})}eachUniqueKey(e){return this._ctx.unique="unique",this.eachKey(e)}eachPrimaryKey(e){var n=this._ctx;return n.keysOnly=!n.isMatch,this.each(function(n,t){e(t.primaryKey,t)})}keys(e){var n=this._ctx;n.keysOnly=!n.isMatch;var t=[];return this.each(function(e,n){t.push(n.key)}).then(function(){return t}).then(e)}primaryKeys(e){var n=this._ctx;if("next"===n.dir&&lI(n,!0)&&n.limit>0)return this._read(e=>{var t=lR(n,n.table.core.schema);return n.table.core.query({trans:e,values:!1,limit:n.limit,query:{index:t,range:n.range}})}).then(({result:e})=>e).then(e);n.keysOnly=!n.isMatch;var t=[];return this.each(function(e,n){t.push(n.primaryKey)}).then(function(){return t}).then(e)}uniqueKeys(e){return this._ctx.unique="unique",this.keys(e)}firstKey(e){return this.limit(1).keys(function(e){return e[0]}).then(e)}lastKey(e){return this.reverse().firstKey(e)}distinct(){var e=this._ctx,n=e.index&&e.table.schema.idxByName[e.index];if(!n||!n.multi)return this;var t={};return lN(this._ctx,function(e){var n=e.primaryKey.toString(),a=ij(t,n);return t[n]=!0,!a}),this}modify(e){var n=this._ctx;return this._write(t=>{var a;if("function"==typeof e)a=e;else{var o=iP(e),r=o.length;a=function(n){for(var t=!1,a=0;a<r;++a){var i=o[a],s=e[i];iZ(n,i)!==s&&(iX(n,i,s),t=!0)}return t}}let i=n.table.core,{outbound:s,extractKey:l}=i.schema.primaryKey,c=this.db._options.modifyChunkSize||200,p=[],u=0,d=[],f=(e,n)=>{let{failures:t,numFailures:a}=n;for(let n of(u+=e-a,iP(t)))p.push(t[n])};return this.clone().primaryKeys().then(o=>{let r=p=>{let u=Math.min(c,o.length-p);return i.getMany({trans:t,keys:o.slice(p,p+u),cache:"immutable"}).then(d=>{let m=[],h=[],g=s?[]:null,y=[];for(let e=0;e<u;++e){let n=d[e],t={value:i4(n),primKey:o[p+e]};!1!==a.call(t,t.value,t)&&(null==t.value?y.push(o[p+e]):s||0===lG(l(n),l(t.value))?(h.push(t.value),s&&g.push(o[p+e])):(y.push(o[p+e]),m.push(t.value)))}let b=lI(n)&&n.limit===1/0&&("function"!=typeof e||e===lH)&&{index:n.index,range:n.range};return Promise.resolve(m.length>0&&i.mutate({trans:t,type:"add",values:m}).then(e=>{for(let n in e.failures)y.splice(parseInt(n),1);f(m.length,e)})).then(()=>(h.length>0||b&&"object"==typeof e)&&i.mutate({trans:t,type:"put",keys:g,values:h,criteria:b,changeSpec:"function"!=typeof e&&e}).then(e=>f(h.length,e))).then(()=>(y.length>0||b&&e===lH)&&i.mutate({trans:t,type:"delete",keys:y,criteria:b}).then(e=>f(y.length,e))).then(()=>o.length>p+u&&r(p+c))})};return r(0).then(()=>{if(p.length>0)throw new sf("Error modifying one or more objects",p,u,d);return o.length})})})}delete(){var e=this._ctx,n=e.range;return lI(e)&&(e.isPrimKey&&!lx||3===n.type)?this._write(t=>{let{primaryKey:a}=e.table.core.schema;return e.table.core.count({trans:t,query:{index:a,range:n}}).then(a=>e.table.core.mutate({trans:t,type:"deleteRange",range:n}).then(({failures:e,lastResult:n,results:t,numFailures:o})=>{if(o)throw new sf("Could not delete some values",Object.keys(e).map(n=>e[n]),a-o);return a-o}))}):this.modify(lH)}}let lH=(e,n)=>n.value=null;function lK(e,n){return e<n?-1:+(e!==n)}function lY(e,n){return e>n?-1:+(e!==n)}function lJ(e,n,t){var a=e instanceof l1?new e.Collection(e):e;return a._ctx.error=t?new t(n):TypeError(n),a}function lZ(e){return new e.Collection(e,()=>l0("")).limit(0)}function lX(e,n,t,a){var o,r,i,s,l,c,p,u=t.length;if(!t.every(e=>"string"==typeof e))return lJ(e,lk);function d(e){o="next"===e?e=>e.toUpperCase():e=>e.toLowerCase(),r="next"===e?e=>e.toLowerCase():e=>e.toUpperCase(),i="next"===e?lK:lY;var n=t.map(function(e){return{lower:r(e),upper:o(e)}}).sort(function(e,n){return i(e.lower,n.lower)});s=n.map(function(e){return e.upper}),l=n.map(function(e){return e.lower}),c=e,p="next"===e?"":a}d("next");var f=new e.Collection(e,()=>lQ(s[0],l[u-1]+a));f._ondirectionchange=function(e){d(e)};var m=0;return f._addAlgorithm(function(e,t,a){var o=e.key;if("string"!=typeof o)return!1;var d=r(o);if(n(d,l,m))return!0;for(var f=null,h=m;h<u;++h){var g=function(e,n,t,a,o,r){for(var i=Math.min(e.length,a.length),s=-1,l=0;l<i;++l){var c=n[l];if(c!==a[l])return 0>o(e[l],t[l])?e.substr(0,l)+t[l]+t.substr(l+1):0>o(e[l],a[l])?e.substr(0,l)+a[l]+t.substr(l+1):s>=0?e.substr(0,s)+n[s]+t.substr(s+1):null;0>o(e[l],c)&&(s=l)}return i<a.length&&"next"===r?e+t.substr(e.length):i<e.length&&"prev"===r?e.substr(0,t.length):s<0?null:e.substr(0,s)+a[s]+t.substr(s+1)}(o,d,s[h],l[h],i,c);null===g&&null===f?m=h+1:(null===f||i(f,g)>0)&&(f=g)}return t(null!==f?function(){e.continue(f+p)}:a),!1}),f}function lQ(e,n,t,a){return{type:2,lower:e,upper:n,lowerOpen:t,upperOpen:a}}function l0(e){return{type:1,lower:e,upper:e}}class l1{get Collection(){return this._ctx.table.db.Collection}between(e,n,t,a){t=!1!==t,a=!0===a;try{return this._cmp(e,n)>0||0===this._cmp(e,n)&&(t||a)&&(!t||!a)?lZ(this):new this.Collection(this,()=>lQ(e,n,!t,!a))}catch(e){return lJ(this,lA)}}equals(e){return null==e?lJ(this,lA):new this.Collection(this,()=>l0(e))}above(e){return null==e?lJ(this,lA):new this.Collection(this,()=>lQ(e,void 0,!0))}aboveOrEqual(e){return null==e?lJ(this,lA):new this.Collection(this,()=>lQ(e,void 0,!1))}below(e){return null==e?lJ(this,lA):new this.Collection(this,()=>lQ(void 0,e,!1,!0))}belowOrEqual(e){return null==e?lJ(this,lA):new this.Collection(this,()=>lQ(void 0,e))}startsWith(e){return"string"!=typeof e?lJ(this,lk):this.between(e,e+lv,!0,!0)}startsWithIgnoreCase(e){return""===e?this.startsWith(e):lX(this,(e,n)=>0===e.indexOf(n[0]),[e],lv)}equalsIgnoreCase(e){return lX(this,(e,n)=>e===n[0],[e],"")}anyOfIgnoreCase(){var e=sn.apply(se,arguments);return 0===e.length?lZ(this):lX(this,(e,n)=>-1!==n.indexOf(e),e,"")}startsWithAnyOfIgnoreCase(){var e=sn.apply(se,arguments);return 0===e.length?lZ(this):lX(this,(e,n)=>n.some(n=>0===e.indexOf(n)),e,lv)}anyOf(){let e=sn.apply(se,arguments),n=this._cmp;try{e.sort(n)}catch(e){return lJ(this,lA)}if(0===e.length)return lZ(this);let t=new this.Collection(this,()=>lQ(e[0],e[e.length-1]));t._ondirectionchange=t=>{n="next"===t?this._ascending:this._descending,e.sort(n)};let a=0;return t._addAlgorithm((t,o,r)=>{let i=t.key;for(;n(i,e[a])>0;)if(++a===e.length)return o(r),!1;return 0===n(i,e[a])||(o(()=>{t.continue(e[a])}),!1)}),t}notEqual(e){return this.inAnyRange([[l$,e],[e,this.db._maxKey]],{includeLowers:!1,includeUppers:!1})}noneOf(){let e=sn.apply(se,arguments);if(0===e.length)return new this.Collection(this);try{e.sort(this._ascending)}catch(e){return lJ(this,lA)}let n=e.reduce((e,n)=>e?e.concat([[e[e.length-1][1],n]]):[[l$,n]],null);return n.push([e[e.length-1],this.db._maxKey]),this.inAnyRange(n,{includeLowers:!1,includeUppers:!1})}inAnyRange(e,n){let t=this._cmp,a=this._ascending,o=this._descending,r=this._min,i=this._max;if(0===e.length)return lZ(this);if(!e.every(e=>void 0!==e[0]&&void 0!==e[1]&&0>=a(e[0],e[1])))return lJ(this,"First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower",sg.InvalidArgument);let s=!n||!1!==n.includeLowers,l=n&&!0===n.includeUppers,c,p=a;function u(e,n){return p(e[0],n[0])}try{(c=e.reduce(function(e,n){let a=0,o=e.length;for(;a<o;++a){let o=e[a];if(0>t(n[0],o[1])&&t(n[1],o[0])>0){o[0]=r(o[0],n[0]),o[1]=i(o[1],n[1]);break}}return a===o&&e.push(n),e},[])).sort(u)}catch(e){return lJ(this,lA)}let d=0,f=l?e=>a(e,c[d][1])>0:e=>a(e,c[d][1])>=0,m=s?e=>o(e,c[d][0])>0:e=>o(e,c[d][0])>=0,h=f,g=new this.Collection(this,()=>lQ(c[0][0],c[c.length-1][1],!s,!l));return g._ondirectionchange=e=>{"next"===e?(h=f,p=a):(h=m,p=o),c.sort(u)},g._addAlgorithm((e,n,t)=>{for(var o=e.key;h(o);)if(++d===c.length)return n(t),!1;return!!(!f(o)&&!m(o))||(0===this._cmp(o,c[d][1])||0===this._cmp(o,c[d][0])||n(()=>{p===a?e.continue(c[d][0]):e.continue(c[d][1])}),!1)}),g}startsWithAnyOf(){let e=sn.apply(se,arguments);return e.every(e=>"string"==typeof e)?0===e.length?lZ(this):this.inAnyRange(e.map(e=>[e,e+lv])):lJ(this,"startsWithAnyOf() only works with strings")}}function l2(e){return s7(function(n){return l3(n),e(n.target.error),!1})}function l3(e){e.stopPropagation&&e.stopPropagation(),e.preventDefault&&e.preventDefault()}let l5="storagemutated",l4="x-storagemutated-1",l6=lT(null,l5);class l8{_lock(){return iK(!sU.global),++this._reculock,1!==this._reculock||sU.global||(sU.lockOwnerFor=this),this}_unlock(){if(iK(!sU.global),0==--this._reculock)for(sU.global||(sU.lockOwnerFor=null);this._blockedFuncs.length>0&&!this._locked();){var e=this._blockedFuncs.shift();try{lf(e[1],e[0])}catch(e){}}return this}_locked(){return this._reculock&&sU.lockOwnerFor!==this}create(e){if(!this.mode)return this;let n=this.db.idbdb,t=this.db._state.dbOpenError;if(iK(!this.idbtrans),!e&&!n)switch(t&&t.name){case"DatabaseClosedError":throw new sg.DatabaseClosed(t);case"MissingAPIError":throw new sg.MissingAPI(t.message,t);default:throw new sg.OpenFailed(t)}if(!this.active)throw new sg.TransactionInactive;return iK(null===this._completion._state),(e=this.idbtrans=e||(this.db.core?this.db.core.transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability}):n.transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability}))).onerror=s7(n=>{l3(n),this._reject(e.error)}),e.onabort=s7(n=>{l3(n),this.active&&this._reject(new sg.Abort(e.error)),this.active=!1,this.on("abort").fire(n)}),e.oncomplete=s7(()=>{this.active=!1,this._resolve(),"mutatedParts"in e&&l6.storagemutated.fire(e.mutatedParts)}),this}_promise(e,n,t){if("readwrite"===e&&"readwrite"!==this.mode)return lb(new sg.ReadOnly("Transaction is readonly"));if(!this.active)return lb(new sg.TransactionInactive);if(this._locked())return new sY((a,o)=>{this._blockedFuncs.push([()=>{this._promise(e,n,t).then(a,o)},sU])});if(t)return lr(()=>{var e=new sY((e,t)=>{this._lock();let a=n(e,t,this);a&&a.then&&a.then(e,t)});return e.finally(()=>this._unlock()),e._lib=!0,e});var a=new sY((e,t)=>{var a=n(e,t,this);a&&a.then&&a.then(e,t)});return a._lib=!0,a}_root(){return this.parent?this.parent._root():this}waitFor(e){var n=this._root();let t=sY.resolve(e);if(n._waitingFor)n._waitingFor=n._waitingFor.then(()=>t);else{n._waitingFor=t,n._waitingQueue=[];var a=n.idbtrans.objectStore(n.storeNames[0]);!function e(){for(++n._spinCount;n._waitingQueue.length;)n._waitingQueue.shift()();n._waitingFor&&(a.get(-1/0).onsuccess=e)}()}var o=n._waitingFor;return new sY((e,a)=>{t.then(t=>n._waitingQueue.push(s7(e.bind(null,t))),e=>n._waitingQueue.push(s7(a.bind(null,e)))).finally(()=>{n._waitingFor===o&&(n._waitingFor=null)})})}abort(){this.active&&(this.active=!1,this.idbtrans&&this.idbtrans.abort(),this._reject(new sg.Abort))}table(e){let n=this._memoizedTables||(this._memoizedTables={});if(ij(n,e))return n[e];let t=this.schema[e];if(!t)throw new sg.NotFound("Table "+e+" not part of transaction");let a=new this.db.Table(e,t,this);return a.core=this.db.core.table(e),n[e]=a,a}}function l7(e,n,t,a,o,r,i){return{name:e,keyPath:n,unique:t,multi:a,auto:o,compound:r,src:(t&&!i?"&":"")+(a?"*":"")+(o?"++":"")+l9(n)}}function l9(e){return"string"==typeof e?e:e?"["+[].join.call(e,"+")+"]":""}function ce(e,n,t){return{name:e,primKey:n,indexes:t,mappedClass:null,idxByName:iJ(t,e=>[e.name,e])}}let cn=e=>{try{return e.only([[]]),cn=()=>[[]],[[]]}catch(e){return cn=()=>lv,lv}};function ct(e){return null==e?()=>{}:"string"==typeof e?1===e.split(".").length?n=>n[e]:n=>iZ(n,e):n=>iZ(n,e)}function ca(e){return[].slice.call(e)}let co=0;function cr(e){return null==e?":id":"string"==typeof e?e:`[${e.join("+")}]`}function ci({_novip:e},n){let t=n.db,a=function(e,n,{IDBKeyRange:t,indexedDB:a},o){var r;return{dbcore:(r=function(e,n,t){let a;function o(e){if(3===e.type)return null;if(4===e.type)throw Error("Cannot convert never type to IDBKeyRange");let{lower:t,upper:a,lowerOpen:o,upperOpen:r}=e;return void 0===t?void 0===a?null:n.upperBound(a,!!r):void 0===a?n.lowerBound(t,!!o):n.bound(t,a,!!o,!!r)}let{schema:r,hasGetAll:i}=(a=ca(e.objectStoreNames),{schema:{name:e.name,tables:a.map(e=>t.objectStore(e)).map(e=>{let{keyPath:n,autoIncrement:t}=e,a=iT(n),o=null==n,r={},i={name:e.name,primaryKey:{name:null,isPrimaryKey:!0,outbound:o,compound:a,keyPath:n,autoIncrement:t,unique:!0,extractKey:ct(n)},indexes:ca(e.indexNames).map(n=>e.index(n)).map(e=>{let{name:n,unique:t,multiEntry:a,keyPath:o}=e,i={name:n,compound:iT(o),keyPath:o,unique:t,multiEntry:a,extractKey:ct(o)};return r[cr(o)]=i,i}),getIndexByKeyPath:e=>r[cr(e)]};return r[":id"]=i.primaryKey,null!=n&&(r[cr(n)]=i.primaryKey),i})},hasGetAll:a.length>0&&"getAll"in t.objectStore(a[0])&&!("u">typeof navigator&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604)}),s=r.tables.map(e=>{let n;return{name:n=e.name,schema:e,mutate:function({trans:e,type:t,keys:a,values:r,range:i}){return new Promise((s,l)=>{let c;s=s7(s);let p=e.objectStore(n),u=null==p.keyPath,d="put"===t||"add"===t;if(!d&&"delete"!==t&&"deleteRange"!==t)throw Error("Invalid operation type: "+t);let{length:f}=a||r||{length:1};if(a&&r&&a.length!==r.length)throw Error("Given keys array must have same length as given values array.");if(0===f)return s({numFailures:0,failures:{},results:[],lastResult:void 0});let m=[],h=[],g=0,y=e=>{++g,l3(e)};if("deleteRange"===t){if(4===i.type)return s({numFailures:g,failures:h,results:[],lastResult:void 0});3===i.type?m.push(c=p.clear()):m.push(c=p.delete(o(i)))}else{let[e,n]=d?u?[r,a]:[r,null]:[a,null];if(d)for(let a=0;a<f;++a)m.push(c=n&&void 0!==n[a]?p[t](e[a],n[a]):p[t](e[a])),c.onerror=y;else for(let n=0;n<f;++n)m.push(c=p[t](e[n])),c.onerror=y}let b=e=>{let n=e.target.result;m.forEach((e,n)=>null!=e.error&&(h[n]=e.error)),s({numFailures:g,failures:h,results:"delete"===t?a:m.map(e=>e.result),lastResult:n})};c.onerror=e=>{y(e),b(e)},c.onsuccess=b})},getMany:({trans:e,keys:t})=>new Promise((a,o)=>{a=s7(a);let r=e.objectStore(n),i=t.length,s=Array(i),l,c=0,p=0,u=e=>{let n=e.target;s[n._pos]=n.result,++p===c&&a(s)},d=l2(o);for(let e=0;e<i;++e)null!=t[e]&&((l=r.get(t[e]))._pos=e,l.onsuccess=u,l.onerror=d,++c);0===c&&a(s)}),get:({trans:e,key:t})=>new Promise((a,o)=>{a=s7(a);let r=e.objectStore(n).get(t);r.onsuccess=e=>a(e.target.result),r.onerror=l2(o)}),query:e=>new Promise((t,a)=>{t=s7(t);let{trans:r,values:s,limit:l,query:c}=e,p=l===1/0?void 0:l,{index:u,range:d}=c,f=r.objectStore(n),m=u.isPrimaryKey?f:f.index(u.name),h=o(d);if(0===l)return t({result:[]});if(i){let e=s?m.getAll(h,p):m.getAllKeys(h,p);e.onsuccess=e=>t({result:e.target.result}),e.onerror=l2(a)}else{let e=0,n=!s&&"openKeyCursor"in m?m.openKeyCursor(h):m.openCursor(h),o=[];n.onsuccess=a=>{let r=n.result;return r?(o.push(s?r.value:r.primaryKey),++e===l?t({result:o}):void r.continue()):t({result:o})},n.onerror=l2(a)}}),openCursor:function({trans:e,values:t,query:a,reverse:r,unique:i}){return new Promise((s,l)=>{s=s7(s);let{index:c,range:p}=a,u=e.objectStore(n),d=c.isPrimaryKey?u:u.index(c.name),f=r?i?"prevunique":"prev":i?"nextunique":"next",m=!t&&"openKeyCursor"in d?d.openKeyCursor(o(p),f):d.openCursor(o(p),f);m.onerror=l2(l),m.onsuccess=s7(n=>{let t=m.result;if(!t)return void s(null);t.___id=++co,t.done=!1;let a=t.continue.bind(t),o=t.continuePrimaryKey;o&&(o=o.bind(t));let r=t.advance.bind(t),i=()=>{throw Error("Cursor not stopped")};t.trans=e,t.stop=t.continue=t.continuePrimaryKey=t.advance=()=>{throw Error("Cursor not started")},t.fail=s7(l),t.next=function(){let e=1;return this.start(()=>e--?this.continue():this.stop()).then(()=>this)},t.start=e=>{let n=new Promise((e,n)=>{e=s7(e),m.onerror=l2(n),t.fail=n,t.stop=n=>{t.stop=t.continue=t.continuePrimaryKey=t.advance=i,e(n)}}),s=()=>{if(m.result)try{e()}catch(e){t.fail(e)}else t.done=!0,t.start=()=>{throw Error("Cursor behind last entry")},t.stop()};return m.onsuccess=s7(e=>{m.onsuccess=s,s()}),t.continue=a,t.continuePrimaryKey=o,t.advance=r,s(),n},s(t)},l)})},count({query:e,trans:t}){let{index:a,range:r}=e;return new Promise((e,i)=>{let s=t.objectStore(n),l=a.isPrimaryKey?s:s.index(a.name),c=o(r),p=c?l.count(c):l.count();p.onsuccess=s7(n=>e(n.target.result)),p.onerror=l2(i)})}}}),l={};return s.forEach(e=>l[e.name]=e),{stack:"dbcore",transaction:e.transaction.bind(e),table(e){if(!l[e])throw Error(`Table '${e}' not found`);return l[e]},MIN_KEY:-1/0,MAX_KEY:cn(n),schema:r}}(n,t,o),e.dbcore.reduce((e,{create:n})=>({...e,...n(e)}),r))}}(e._middlewares,t,e._deps,n);e.core=a.dbcore,e.tables.forEach(n=>{let t=n.name;e.core.schema.tables.some(e=>e.name===t)&&(n.core=e.core.table(t),e[t]instanceof e.Table&&(e[t].core=n.core))})}function cs({_novip:e},n,t,a){t.forEach(t=>{let o=a[t];n.forEach(n=>{let a=iV(n,t);(!a||"value"in a&&void 0===a.value)&&(n===e.Transaction.prototype||n instanceof e.Transaction?iL(n,t,{get(){return this.table(t)},set(e){iF(this,t,{value:e,writable:!0,configurable:!0,enumerable:!0})}}):n[t]=new e.Table(t,o))})})}function cl({_novip:e},n){n.forEach(n=>{for(let t in n)n[t]instanceof e.Table&&delete n[t]})}function cc(e,n){return e._cfg.version-n._cfg.version}function cp(e,n){let t,a={del:[],add:[],change:[]};for(t in e)n[t]||a.del.push(t);for(t in n){let o=e[t],r=n[t];if(o){let e={name:t,def:r,recreate:!1,del:[],add:[],change:[]};if(""+(o.primKey.keyPath||"")==""+(r.primKey.keyPath||"")&&(o.primKey.auto===r.primKey.auto||lx)){let n,t=o.idxByName,i=r.idxByName;for(n in t)i[n]||e.del.push(n);for(n in i){let a=t[n],o=i[n];a?a.src!==o.src&&e.change.push(o):e.add.push(o)}(e.del.length>0||e.add.length>0||e.change.length>0)&&a.change.push(e)}else e.recreate=!0,a.change.push(e)}else a.add.push([t,r])}return a}function cu(e,n,t,a){let o=e.db.createObjectStore(n,t.keyPath?{keyPath:t.keyPath,autoIncrement:t.auto}:{autoIncrement:t.auto});return a.forEach(e=>cd(o,e)),o}function cd(e,n){e.createIndex(n.name,n.keyPath,{unique:n.unique,multiEntry:n.multi})}function cf(e,n,t){let a={};return iq(n.objectStoreNames,0).forEach(e=>{let n=t.objectStore(e),o=n.keyPath,r=l7(l9(o),o||"",!1,!1,!!n.autoIncrement,o&&"string"!=typeof o,!0),i=[];for(let e=0;e<n.indexNames.length;++e){let t=n.index(n.indexNames[e]);o=t.keyPath;var s=l7(t.name,o,!!t.unique,!!t.multiEntry,!1,o&&"string"!=typeof o,!1);i.push(s)}a[e]=ce(e,r,i)}),a}function cm({_novip:e},n,t){let a=t.db.objectStoreNames;for(let o=0;o<a.length;++o){let r=a[o],i=t.objectStore(r);e._hasGetAll="getAll"in i;for(let e=0;e<i.indexNames.length;++e){let t=i.indexNames[e],a=i.index(t).keyPath,o="string"==typeof a?a:"["+iq(a).join("+")+"]";if(n[r]){let e=n[r].idxByName[o];e&&(e.name=t,delete n[r].idxByName[o],n[r].idxByName[t]=e)}}}"u">typeof navigator&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&iO.WorkerGlobalScope&&iO instanceof iO.WorkerGlobalScope&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604&&(e._hasGetAll=!1)}class ch{_parseStoresSpec(e,n){iP(e).forEach(t=>{if(null!==e[t]){var a=e[t].split(",").map((e,n)=>{let t=(e=e.trim()).replace(/([&*]|\+\+)/g,""),a=/^\[/.test(t)?t.match(/^\[(.*)\]$/)[1].split("+"):t;return l7(t,a||null,/\&/.test(e),/\*/.test(e),/\+\+/.test(e),iT(a),0===n)}),o=a.shift();if(o.multi)throw new sg.Schema("Primary key cannot be multi-valued");a.forEach(e=>{if(e.auto)throw new sg.Schema("Only primary key can be marked as autoIncrement (++)");if(!e.keyPath)throw new sg.Schema("Index must have a name and cannot be an empty string")}),n[t]=ce(t,o,a)}})}stores(e){let n=this.db;this._cfg.storesSource=this._cfg.storesSource?iB(this._cfg.storesSource,e):e;let t=n._versions,a={},o={};return t.forEach(e=>{iB(a,e._cfg.storesSource),o=e._cfg.dbschema={},e._parseStoresSpec(a,o)}),n._dbSchema=o,cl(n,[n._allTables,n,n.Transaction.prototype]),cs(n,[n._allTables,n,n.Transaction.prototype,this._cfg.tables],iP(o),o),n._storeNames=iP(o),this}upgrade(e){return this._cfg.contentUpgrade=sE(this._cfg.contentUpgrade||s_,e),this}}function cg(e,n){let t=e._dbNamesDB;return t||(t=e._dbNamesDB=new cB(lE,{addons:[],indexedDB:e,IDBKeyRange:n})).version(1).stores({dbnames:"name"}),t.table("dbnames")}function cy(e){return e&&"function"==typeof e.databases}function cb(e){return lr(function(){return sU.letThrough=!0,e()})}function c_(e){var n=n=>e.next(n),t=o(n),a=o(n=>e.throw(n));function o(e){return n=>{var o=e(n),r=o.value;return o.done?r:r&&"function"==typeof r.then?r.then(t,a):iT(r)?Promise.all(r).then(t,a):t(r)}}return o(n)()}function cv(e,n,t){var a=arguments.length;if(a<2)throw new sg.InvalidArgument("Too few arguments");for(var o=Array(a-1);--a;)o[a-1]=arguments[a];return t=o.pop(),[e,i1(o),t]}function c$(e,n,t){let a=iT(e)?e.slice():[e];for(let e=0;e<t;++e)a.push(n);return a}let cA={stack:"dbcore",name:"VirtualIndexMiddleware",level:1,create:function(e){return{...e,table(n){let t=e.table(n),{schema:a}=t,o={},r=[];function i(e,n,t){let a=cr(e),s=o[a]=o[a]||[],l=null==e?0:"string"==typeof e?1:e.length,c=n>0,p={...t,isVirtual:c,keyTail:n,keyLength:l,extractKey:ct(e),unique:!c&&t.unique};return s.push(p),p.isPrimaryKey||r.push(p),l>1&&i(2===l?e[0]:e.slice(0,l-1),n+1,t),s.sort((e,n)=>e.keyTail-n.keyTail),p}let s=i(a.primaryKey.keyPath,0,a.primaryKey);for(let e of(o[":id"]=[s],a.indexes))i(e.keyPath,0,e);function l(n){var t,a;let o=n.query.index;return o.isVirtual?{...n,query:{index:o,range:(t=n.query.range,a=o.keyTail,{type:1===t.type?2:t.type,lower:c$(t.lower,t.lowerOpen?e.MAX_KEY:e.MIN_KEY,a),lowerOpen:!0,upper:c$(t.upper,t.upperOpen?e.MIN_KEY:e.MAX_KEY,a),upperOpen:!0})}}:n}return{...t,schema:{...a,primaryKey:s,indexes:r,getIndexByKeyPath:function(e){let n=o[cr(e)];return n&&n[0]}},count:e=>t.count(l(e)),query:e=>t.query(l(e)),openCursor(n){let{keyTail:a,isVirtual:o,keyLength:r}=n.query.index;return o?t.openCursor(l(n)).then(t=>t&&Object.create(t,{continue:{value:function(o){null!=o?t.continue(c$(o,n.reverse?e.MAX_KEY:e.MIN_KEY,a)):n.unique?t.continue(t.key.slice(0,r).concat(n.reverse?e.MIN_KEY:e.MAX_KEY,a)):t.continue()}},continuePrimaryKey:{value(n,o){t.continuePrimaryKey(c$(n,e.MAX_KEY,a),o)}},primaryKey:{get:()=>t.primaryKey},key:{get(){let e=t.key;return 1===r?e[0]:e.slice(0,r)}},value:{get:()=>t.value}})):t.openCursor(n)}}}}}};function ck(e,n,t,a){return t=t||{},a=a||"",iP(e).forEach(o=>{if(ij(n,o)){var r=e[o],i=n[o];if("object"==typeof r&&"object"==typeof i&&r&&i){let e=i8(r);e!==i8(i)?t[a+o]=n[o]:"Object"===e?ck(r,i,t,a+o+"."):r!==i&&(t[a+o]=n[o])}else r!==i&&(t[a+o]=n[o])}else t[a+o]=void 0}),iP(n).forEach(o=>{ij(e,o)||(t[a+o]=n[o])}),t}let cw={stack:"dbcore",name:"HooksMiddleware",level:2,create:e=>({...e,table(n){let t=e.table(n),{primaryKey:a}=t.schema;return{...t,mutate(e){let o=sU.trans,{deleting:r,creating:i,updating:s}=o.table(n).hook;switch(e.type){case"add":if(i.fire===s_)break;return o._promise("readwrite",()=>l(e),!0);case"put":if(i.fire===s_&&s.fire===s_)break;return o._promise("readwrite",()=>l(e),!0);case"delete":if(r.fire===s_)break;return o._promise("readwrite",()=>l(e),!0);case"deleteRange":if(r.fire===s_)break;return o._promise("readwrite",()=>(function e(n,o,r){return t.query({trans:n,values:!1,query:{index:a,range:o},limit:r}).then(({result:t})=>l({type:"delete",keys:t,trans:n}).then(a=>a.numFailures>0?Promise.reject(a.failures[0]):t.length<r?{failures:[],numFailures:0,lastResult:void 0}:e(n,{...o,lower:t[t.length-1],lowerOpen:!0},r)))})(e.trans,e.range,1e4),!0)}return t.mutate(e);function l(e){var n,o;let l=sU.trans,c=e.keys||("delete"===(n=e).type?n.keys:n.keys||n.values.map(a.extractKey));if(!c)throw Error("Keys missing");return"delete"!==(e="add"===e.type||"put"===e.type?{...e,keys:c}:{...e}).type&&(e.values=[...e.values]),e.keys&&(e.keys=[...e.keys]),("add"===(o=e).type?Promise.resolve([]):t.getMany({trans:o.trans,keys:c,cache:"immutable"})).then(n=>{let o=c.map((t,o)=>{let c=n[o],p={onerror:null,onsuccess:null};if("delete"===e.type)r.fire.call(p,t,c,l);else if("add"===e.type||void 0===c){let n=i.fire.call(p,t,e.values[o],l);null==t&&null!=n&&(t=n,e.keys[o]=t,a.outbound||iX(e.values[o],a.keyPath,t))}else{let n=ck(c,e.values[o]),a=s.fire.call(p,n,t,c,l);if(a){let n=e.values[o];Object.keys(a).forEach(e=>{ij(n,e)?n[e]=a[e]:iX(n,e,a[e])})}}return p});return t.mutate(e).then(({failures:t,results:a,numFailures:r,lastResult:i})=>{for(let r=0;r<c.length;++r){let i=a?a[r]:c[r],s=o[r];null==i?s.onerror&&s.onerror(t[r]):s.onsuccess&&s.onsuccess("put"===e.type&&n[r]?e.values[r]:i)}return{failures:t,results:a,numFailures:r,lastResult:i}}).catch(e=>(o.forEach(n=>n.onerror&&n.onerror(e)),Promise.reject(e)))})}}}}})};function cx(e,n,t){try{if(!n||n.keys.length<e.length)return null;let a=[];for(let o=0,r=0;o<n.keys.length&&r<e.length;++o)0===lG(n.keys[o],e[r])&&(a.push(t?i4(n.values[o]):n.values[o]),++r);return a.length===e.length?a:null}catch(e){return null}}let cC={stack:"dbcore",level:-1,create:e=>({table:n=>{let t=e.table(n);return{...t,getMany:e=>{if(!e.cache)return t.getMany(e);let n=cx(e.keys,e.trans._cache,"clone"===e.cache);return n?sY.resolve(n):t.getMany(e).then(n=>(e.trans._cache={keys:e.keys,values:"clone"===e.cache?i4(n):n},n))},mutate:e=>("add"!==e.type&&(e.trans._cache=null),t.mutate(e))}}})};function cE(e){return!("from"in e)}let cS=function(e,n){if(!this){let n=new cS;return e&&"d"in e&&iB(n,e),n}iB(this,arguments.length?{d:1,from:e,to:arguments.length>1?n:e}:{d:0})};function cD(e,n,t){let a=lG(n,t);if(isNaN(a))return;if(a>0)throw RangeError();if(cE(e))return iB(e,{from:n,to:t,d:1});let o=e.l,r=e.r;if(0>lG(t,e.from))return o?cD(o,n,t):e.l={from:n,to:t,d:1,l:null,r:null},cO(e);if(lG(n,e.to)>0)return r?cD(r,n,t):e.r={from:n,to:t,d:1,l:null,r:null},cO(e);0>lG(n,e.from)&&(e.from=n,e.l=null,e.d=r?r.d+1:1),lG(t,e.to)>0&&(e.to=t,e.r=null,e.d=e.l?e.l.d+1:1);let i=!e.r;o&&!e.l&&cM(e,o),r&&i&&cM(e,r)}function cM(e,n){cE(n)||function e(n,{from:t,to:a,l:o,r:r}){cD(n,t,a),o&&e(n,o),r&&e(n,r)}(e,n)}function cz(e){let n=cE(e)?null:{s:0,n:e};return{next(e){let t=arguments.length>0;for(;n;)switch(n.s){case 0:if(n.s=1,t)for(;n.n.l&&0>lG(e,n.n.from);)n={up:n,n:n.n.l,s:1};else for(;n.n.l;)n={up:n,n:n.n.l,s:1};case 1:if(n.s=2,!t||0>=lG(e,n.n.to))return{value:n.n,done:!1};case 2:if(n.n.r){n.s=3,n={up:n,n:n.n.r,s:0};continue}case 3:n=n.up}return{done:!0}}}}function cO(e){var n,t;let a=((null==(n=e.r)?void 0:n.d)||0)-((null==(t=e.l)?void 0:t.d)||0),o=a>1?"r":a<-1?"l":"";if(o){let n="r"===o?"l":"r",t={...e},a=e[o];e.from=a.from,e.to=a.to,e[o]=a[o],t[o]=a[n],e[n]=t,t.d=cP(t)}e.d=cP(e)}function cP({r:e,l:n}){return(e?n?Math.max(e.d,n.d):e.d:n?n.d:0)+1}iR(cS.prototype,{add(e){return cM(this,e),this},addKey(e){return cD(this,e,e),this},addKeys(e){return e.forEach(e=>cD(this,e,e)),this},[i7](){return cz(this)}});let cT={stack:"dbcore",level:0,create:e=>{let n=e.schema.name,t=new cS(e.MIN_KEY,e.MAX_KEY);return{...e,table:a=>{let o=e.table(a),{schema:r}=o,{primaryKey:i}=r,{extractKey:s,outbound:l}=i,c={...o,mutate:e=>{let i=e.trans,s=i.mutatedParts||(i.mutatedParts={}),l=e=>{let t=`idb://${n}/${a}/${e}`;return s[t]||(s[t]=new cS)},c=l(""),p=l(":dels"),{type:u}=e,[d,f]="deleteRange"===e.type?[e.range]:"delete"===e.type?[e.keys]:e.values.length<50?[[],e.values]:[],m=e.trans._cache;return o.mutate(e).then(e=>{if(iT(d)){"delete"!==u&&(d=e.results),c.addKeys(d);let n=cx(d,m);n||"add"===u||p.addKeys(d),(n||f)&&r.indexes.forEach(function(e){let t=l(e.name||"");function a(n){return null!=n?e.extractKey(n):null}let o=n=>e.multiEntry&&iT(n)?n.forEach(e=>t.addKey(e)):t.addKey(n);(n||f).forEach((e,t)=>{let r=n&&a(n[t]),i=f&&a(f[t]);0!==lG(r,i)&&(null!=r&&o(r),null!=i&&o(i))})})}else if(d){let e={from:d.lower,to:d.upper};p.add(e),c.add(e)}else c.add(t),p.add(t),r.indexes.forEach(e=>l(e.name).add(t));return e})}},p=({query:{index:n,range:t}})=>{var a,o;return[n,new cS(null!=(a=t.lower)?a:e.MIN_KEY,null!=(o=t.upper)?o:e.MAX_KEY)]},u={get:e=>[i,new cS(e.key)],getMany:e=>[i,(new cS).addKeys(e.keys)],count:p,query:p,openCursor:p};return iP(u).forEach(e=>{c[e]=function(r){let{subscr:i}=sU;if(i){let c=e=>{let t=`idb://${n}/${a}/${e}`;return i[t]||(i[t]=new cS)},p=c(""),d=c(":dels"),[f,m]=u[e](r);if(c(f.name||"").add(m),!f.isPrimaryKey){if("count"!==e){let n="query"===e&&l&&r.values&&o.query({...r,values:!1});return o[e].apply(this,arguments).then(t=>{if("query"===e){if(l&&r.values)return n.then(({result:e})=>(p.addKeys(e),t));let e=r.values?t.result.map(s):t.result;r.values?p.addKeys(e):d.addKeys(e)}else if("openCursor"===e){let e=r.values;return t&&Object.create(t,{key:{get:()=>(d.addKey(t.primaryKey),t.key)},primaryKey:{get(){let e=t.primaryKey;return d.addKey(e),e}},value:{get:()=>(e&&p.addKey(t.primaryKey),t.value)}})}return t})}d.add(t)}}return o[e].apply(this,arguments)}}),c}}}};class cB{constructor(e,n){var t;this._middlewares={},this.verno=0;const a=cB.dependencies;this._options=n={addons:cB.addons,autoOpen:!0,indexedDB:a.indexedDB,IDBKeyRange:a.IDBKeyRange,...n},this._deps={indexedDB:n.indexedDB,IDBKeyRange:n.IDBKeyRange};const{addons:o}=n;this._dbSchema={},this._versions=[],this._storeNames=[],this._allTables={},this.idbdb=null,this._novip=this;const r={dbOpenError:null,isBeingOpened:!1,onReadyBeingFired:null,openComplete:!1,dbReadyResolve:s_,dbReadyPromise:null,cancelOpen:s_,openCanceller:null,autoSchema:!0,PR1398_maxLoop:3};r.dbReadyPromise=new sY(e=>{r.dbReadyResolve=e}),r.openCanceller=new sY((e,n)=>{r.cancelOpen=n}),this._state=r,this.name=e,this.on=lT(this,"populate","blocked","versionchange","close",{ready:[sE,s_]}),this.on.ready.subscribe=iH(this.on.ready.subscribe,e=>(n,t)=>{cB.vip(()=>{let a=this._state;if(a.openComplete)a.dbOpenError||sY.resolve().then(n),t&&e(n);else if(a.onReadyBeingFired)a.onReadyBeingFired.push(n),t&&e(n);else{e(n);let a=this;t||e(function e(){a.on.ready.unsubscribe(n),a.on.ready.unsubscribe(e)})}})}),this.Collection=(t=this,lB(lq.prototype,function(e,n){this.db=t;let a=lz,o=null;if(n)try{a=n()}catch(e){o=e}let r=e._ctx,i=r.table,s=i.hook.reading.fire;this._ctx={table:i,index:r.index,isPrimKey:!r.index||i.schema.primKey.keyPath&&r.index===i.schema.primKey.name,range:a,keysOnly:!1,dir:"next",unique:"",algorithm:null,filter:null,replayFilter:null,justLimit:!0,isMatch:null,offset:0,limit:1/0,error:o,or:r.or,valueMapper:s!==sv?s:null}})),this.Table=function(e){return lB(lP.prototype,function(n,t,a){this.db=e,this._tx=a,this.name=n,this.schema=t,this.hook=e._allTables[n]?e._allTables[n].hook:lT(null,{creating:[sk,s_],reading:[s$,sv],updating:[sx,s_],deleting:[sw,s_]})})}(this),this.Transaction=function(e){return lB(l8.prototype,function(n,t,a,o,r){this.db=e,this.mode=n,this.storeNames=t,this.schema=a,this.chromeTransactionDurability=o,this.idbtrans=null,this.on=lT(this,"complete","error","abort"),this.parent=r||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 sY((e,n)=>{this._resolve=e,this._reject=n}),this._completion.then(()=>{this.active=!1,this.on.complete.fire()},e=>{var n=this.active;return this.active=!1,this.on.error.fire(e),this.parent?this.parent._reject(e):n&&this.idbtrans&&this.idbtrans.abort(),lb(e)})})}(this),this.Version=function(e){return lB(ch.prototype,function(n){this.db=e,this._cfg={version:n,storesSource:null,dbschema:{},tables:{},contentUpgrade:null}})}(this),this.WhereClause=function(e){return lB(l1.prototype,function(n,t,a){this.db=e,this._ctx={table:n,index:":id"===t?null:t,or:a};let o=e._deps.indexedDB;if(!o)throw new sg.MissingAPI;this._cmp=this._ascending=o.cmp.bind(o),this._descending=(e,n)=>o.cmp(n,e),this._max=(e,n)=>o.cmp(e,n)>0?e:n,this._min=(e,n)=>0>o.cmp(e,n)?e:n,this._IDBKeyRange=e._deps.IDBKeyRange})}(this),this.on("versionchange",e=>{e.newVersion>0?console.warn(`Another connection wants to upgrade database '${this.name}'. Closing db now to resume the upgrade.`):console.warn(`Another connection wants to delete database '${this.name}'. Closing db now to resume the delete request.`),this.close()}),this.on("blocked",e=>{!e.newVersion||e.newVersion<e.oldVersion?console.warn(`Dexie.delete('${this.name}') was blocked`):console.warn(`Upgrade '${this.name}' blocked by other connection holding version ${e.oldVersion/10}`)}),this._maxKey=cn(n.IDBKeyRange),this._createTransaction=(e,n,t,a)=>new this.Transaction(e,n,t,this._options.chromeTransactionDurability,a),this._fireOnBlocked=e=>{this.on("blocked").fire(e),lw.filter(e=>e.name===this.name&&e!==this&&!e._state.vcFired).map(n=>n.on("versionchange").fire(e))},this.use(cA),this.use(cw),this.use(cT),this.use(cC),this.vip=Object.create(this,{_vip:{value:!0}}),o.forEach(e=>e(this))}version(e){if(isNaN(e)||e<.1)throw new sg.Type("Given version is not a positive number");if(e=Math.round(10*e)/10,this.idbdb||this._state.isBeingOpened)throw new sg.Schema("Cannot add version when database is open");this.verno=Math.max(this.verno,e);let n=this._versions;var t=n.filter(n=>n._cfg.version===e)[0];return t||(t=new this.Version(e),n.push(t),n.sort(cc),t.stores({}),this._state.autoSchema=!1,t)}_whenReady(e){return this.idbdb&&(this._state.openComplete||sU.letThrough||this._vip)?e():new sY((e,n)=>{if(this._state.openComplete)return n(new sg.DatabaseClosed(this._state.dbOpenError));if(!this._state.isBeingOpened){if(!this._options.autoOpen)return void n(new sg.DatabaseClosed);this.open().catch(s_)}this._state.dbReadyPromise.then(e,n)}).then(e)}use({stack:e,create:n,level:t,name:a}){a&&this.unuse({stack:e,name:a});let o=this._middlewares[e]||(this._middlewares[e]=[]);return o.push({stack:e,create:n,level:null==t?10:t,name:a}),o.sort((e,n)=>e.level-n.level),this}unuse({stack:e,name:n,create:t}){return e&&this._middlewares[e]&&(this._middlewares[e]=this._middlewares[e].filter(e=>t?e.create!==t:!!n&&e.name!==n)),this}open(){return function(e){var n;let t=e._state,{indexedDB:a}=e._deps;if(t.isBeingOpened||e.idbdb)return t.dbReadyPromise.then(()=>t.dbOpenError?lb(t.dbOpenError):e);sa&&(t.openCanceller._stackHolder=si()),t.isBeingOpened=!0,t.dbOpenError=null,t.openComplete=!1;let o=t.openCanceller;function r(){if(t.openCanceller!==o)throw new sg.DatabaseClosed("db.open() was cancelled")}let i=t.dbReadyResolve,s=null,l=!1;return sY.race([o,("u"<typeof navigator?sY.resolve():!navigator.userAgentData&&/Safari\//.test(navigator.userAgent)&&!/Chrom(e|ium)\//.test(navigator.userAgent)&&indexedDB.databases?new Promise(function(e){var t=function(){return indexedDB.databases().finally(e)};n=setInterval(t,100),t()}).finally(function(){return clearInterval(n)}):Promise.resolve()).then(()=>new sY((n,o)=>{if(r(),!a)throw new sg.MissingAPI;let i=e.name,c=t.autoSchema?a.open(i):a.open(i,Math.round(10*e.verno));if(!c)throw new sg.MissingAPI;c.onerror=l2(o),c.onblocked=s7(e._fireOnBlocked),c.onupgradeneeded=s7(n=>{if(s=c.transaction,t.autoSchema&&!e._options.allowEmptyDB){c.onerror=l3,s.abort(),c.result.close();let e=a.deleteDatabase(i);e.onsuccess=e.onerror=s7(()=>{o(new sg.NoSuchDatabase(`Database ${i} doesnt exist`))})}else{let t,a,i,d;s.onerror=l2(o);var r,p,u=n.oldVersion>0x4000000000000000?0:n.oldVersion;l=u<1,e._novip.idbdb=c.result,r=u/10,p=s,t=e._dbSchema,(a=e._createTransaction("readwrite",e._storeNames,t)).create(p),a._completion.catch(o),i=a._reject.bind(a),d=sU.transless||sU,lr(()=>{sU.trans=a,sU.transless=d,0===r?(iP(t).forEach(e=>{cu(p,e,t[e].primKey,t[e].indexes)}),ci(e,p),sY.follow(()=>e.on.populate.fire(a)).catch(i)):(function({_novip:e},n,t,a){let o=[],r=e._versions,i=e._dbSchema=cf(e,e.idbdb,a),s=!1;return r.filter(e=>e._cfg.version>=n).forEach(r=>{o.push(()=>{let o=i,l=r._cfg.dbschema;cm(e,o,a),cm(e,l,a),i=e._dbSchema=l;let c=cp(o,l);c.add.forEach(e=>{cu(a,e[0],e[1].primKey,e[1].indexes)}),c.change.forEach(e=>{if(e.recreate)throw new sg.Upgrade("Not yet support for changing primary key");{let n=a.objectStore(e.name);e.add.forEach(e=>cd(n,e)),e.change.forEach(e=>{n.deleteIndex(e.name),cd(n,e)}),e.del.forEach(e=>n.deleteIndex(e))}});let p=r._cfg.contentUpgrade;if(p&&r._cfg.version>n){let n;ci(e,a),t._memoizedTables={},s=!0;let r=iQ(l);c.del.forEach(e=>{r[e]=o[e]}),cl(e,[e.Transaction.prototype]),cs(e,[e.Transaction.prototype],iP(r),r),t.schema=r;let i=st(p);i&&li();let u=sY.follow(()=>{if((n=p(t))&&i){var e=ls.bind(null,null);n.then(e,e)}});return n&&"function"==typeof n.then?sY.resolve(n):u.then(()=>n)}}),o.push(n=>{var a;s&&lx||(a=r._cfg.dbschema,[].slice.call(n.db.objectStoreNames).forEach(e=>null==a[e]&&n.db.deleteObjectStore(e))),cl(e,[e.Transaction.prototype]),cs(e,[e.Transaction.prototype],e._storeNames,e._dbSchema),t.schema=e._dbSchema})}),(function e(){return o.length?sY.resolve(o.shift()(t.idbtrans)).then(e):sY.resolve()})().then(()=>{var e;iP(e=i).forEach(n=>{a.db.objectStoreNames.contains(n)||cu(a,n,e[n].primKey,e[n].indexes)})})})(e,r,a,p).catch(i)})}},o),c.onsuccess=s7(()=>{s=null;let a=e._novip.idbdb=c.result,o=iq(a.objectStoreNames);if(o.length>0)try{let n,r=a.transaction(1===o.length?o[0]:o,"readonly");t.autoSchema?function({_novip:e},n,t){e.verno=n.version/10;let a=e._dbSchema=cf(0,n,t);e._storeNames=iq(n.objectStoreNames,0),cs(e,[e._allTables],iP(a),a)}(e,a,r):(cm(e,e._dbSchema,r),((n=cp(cf(0,e.idbdb,r),e._dbSchema)).add.length||n.change.some(e=>e.add.length||e.change.length))&&console.warn("Dexie SchemaDiff: Schema was extended without increasing the number passed to db.version(). Some queries may fail.")),ci(e,r)}catch(e){}lw.push(e),a.onversionchange=s7(n=>{t.vcFired=!0,e.on("versionchange").fire(n)}),a.onclose=s7(n=>{e.on("close").fire(n)}),l&&function({indexedDB:e,IDBKeyRange:n},t){cy(e)||t===lE||cg(e,n).put({name:t}).catch(s_)}(e._deps,i),n()},o)}))]).then(()=>(r(),t.onReadyBeingFired=[],sY.resolve(cb(()=>e.on.ready.fire(e.vip))).then(function n(){if(t.onReadyBeingFired.length>0){let a=t.onReadyBeingFired.reduce(sE,s_);return t.onReadyBeingFired=[],sY.resolve(cb(()=>a(e.vip))).then(n)}}))).finally(()=>{t.onReadyBeingFired=null,t.isBeingOpened=!1}).then(()=>e).catch(n=>{t.dbOpenError=n;try{s&&s.abort()}catch(e){}return o===t.openCanceller&&e._close(),lb(n)}).finally(()=>{t.openComplete=!0,i()})}(this)}_close(){let e=this._state,n=lw.indexOf(this);if(n>=0&&lw.splice(n,1),this.idbdb){try{this.idbdb.close()}catch(e){}this._novip.idbdb=null}e.dbReadyPromise=new sY(n=>{e.dbReadyResolve=n}),e.openCanceller=new sY((n,t)=>{e.cancelOpen=t})}close(){this._close();let e=this._state;this._options.autoOpen=!1,e.dbOpenError=new sg.DatabaseClosed,e.isBeingOpened&&e.cancelOpen(e.dbOpenError)}delete(){let e=arguments.length>0,n=this._state;return new sY((t,a)=>{let o=()=>{this.close();var e=this._deps.indexedDB.deleteDatabase(this.name);e.onsuccess=s7(()=>{!function({indexedDB:e,IDBKeyRange:n},t){cy(e)||t===lE||cg(e,n).delete(t).catch(s_)}(this._deps,this.name),t()}),e.onerror=l2(a),e.onblocked=this._fireOnBlocked};if(e)throw new sg.InvalidArgument("Arguments not allowed in db.delete()");n.isBeingOpened?n.dbReadyPromise.then(o):o()})}backendDB(){return this.idbdb}isOpen(){return null!==this.idbdb}hasBeenClosed(){let e=this._state.dbOpenError;return e&&"DatabaseClosed"===e.name}hasFailed(){return null!==this._state.dbOpenError}dynamicallyOpened(){return this._state.autoSchema}get tables(){return iP(this._allTables).map(e=>this._allTables[e])}transaction(){let e=cv.apply(this,arguments);return this._transaction.apply(this,e)}_transaction(e,n,t){let a,o,r=sU.trans;r&&r.db===this&&-1===e.indexOf("!")||(r=null);let i=-1!==e.indexOf("?");e=e.replace("!","").replace("?","");try{if(o=n.map(e=>{var n=e instanceof this.Table?e.name:e;if("string"!=typeof n)throw TypeError("Invalid table argument to Dexie.transaction(). Only Table or String are allowed");return n}),"r"==e||e===lS)a=lS;else{if("rw"!=e&&e!=lD)throw new sg.InvalidArgument("Invalid transaction mode: "+e);a=lD}if(r){if(r.mode===lS&&a===lD){if(!i)throw new sg.SubTransaction("Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY");r=null}r&&o.forEach(e=>{if(r&&-1===r.storeNames.indexOf(e)){if(!i)throw new sg.SubTransaction("Table "+e+" not included in parent transaction.");r=null}}),i&&r&&!r.active&&(r=null)}}catch(e){return r?r._promise(null,(n,t)=>{t(e)}):lb(e)}let s=(function e(n,t,a,o,r){return sY.resolve().then(()=>{let i,s=sU.transless||sU,l=n._createTransaction(t,a,n._dbSchema,o);if(o)l.idbtrans=o.idbtrans;else try{l.create(),n._state.PR1398_maxLoop=3}catch(o){return o.name===sh.InvalidState&&n.isOpen()&&--n._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),n._close(),n.open().then(()=>e(n,t,a,null,r))):lb(o)}let c=st(r);c&&li();let p=sY.follow(()=>{if(i=r.call(l,l))if(c){var e=ls.bind(null,null);i.then(e,e)}else"function"==typeof i.next&&"function"==typeof i.throw&&(i=c_(i))},{trans:l,transless:s});return(i&&"function"==typeof i.then?sY.resolve(i).then(e=>l.active?e:lb(new sg.PrematureCommit("Transaction committed too early. See http://bit.ly/2kdckMn"))):p.then(()=>i)).then(e=>(o&&l._resolve(),l._completion.then(()=>e))).catch(e=>(l._reject(e),lb(e)))})}).bind(null,this,a,o,r,t);return r?r._promise(a,s,"lock"):sU.trans?lf(sU.transless,()=>this._whenReady(s)):this._whenReady(s)}table(e){if(!ij(this._allTables,e))throw new sg.InvalidTable(`Table ${e} does not exist`);return this._allTables[e]}}let cI="u">typeof Symbol&&"observable"in Symbol?Symbol.observable:"@@observable";class cN{constructor(e){this._subscribe=e}subscribe(e,n,t){return this._subscribe(e&&"function"!=typeof e?e:{next:e,error:n,complete:t})}[cI](){return this}}function cj(e,n){return iP(n).forEach(t=>{cM(e[t]||(e[t]=new cS),n[t])}),e}try{o={indexedDB:iO.indexedDB||iO.mozIndexedDB||iO.webkitIndexedDB||iO.msIndexedDB,IDBKeyRange:iO.IDBKeyRange||iO.webkitIDBKeyRange}}catch(e){o={indexedDB:null,IDBKeyRange:null}}function cR(e){let n=cF;try{cF=!0,l6.storagemutated.fire(e)}finally{cF=n}}iR(cB,{...sb,delete:e=>new cB(e,{addons:[]}).delete(),exists:e=>new cB(e,{addons:[]}).open().then(e=>(e.close(),!0)).catch("NoSuchDatabaseError",()=>!1),getDatabaseNames(e){try{return(function({indexedDB:e,IDBKeyRange:n}){return cy(e)?Promise.resolve(e.databases()).then(e=>e.map(e=>e.name).filter(e=>e!==lE)):cg(e,n).toCollection().primaryKeys()})(cB.dependencies).then(e)}catch(e){return lb(new sg.MissingAPI)}},defineClass:()=>function(e){iB(this,e)},ignoreTransaction:e=>sU.trans?lf(sU.transless,e):e(),vip:cb,async:function(e){return function(){try{var n=c_(e.apply(this,arguments));return n&&"function"==typeof n.then?n:sY.resolve(n)}catch(e){return lb(e)}}},spawn:function(e,n,t){try{var a=c_(e.apply(t,n||[]));return a&&"function"==typeof a.then?a:sY.resolve(a)}catch(e){return lb(e)}},currentTransaction:{get:()=>sU.trans||null},waitFor:function(e,n){let t=sY.resolve("function"==typeof e?cB.ignoreTransaction(e):e).timeout(n||6e4);return sU.trans?sU.trans.waitFor(t):t},Promise:sY,debug:{get:()=>sa,set:e=>{sa=e,so="dexie"===e?()=>!0:lC}},derive:iW,extend:iB,props:iR,override:iH,Events:lT,on:l6,liveQuery:function(e){let n,t=!1,a=new cN(a=>{let o=st(e),r=!1,i={},s={},l={get closed(){return r},unsubscribe:()=>{r=!0,l6.storagemutated.unsubscribe(d)}};a.start&&a.start(l);let c=!1,p=!1;function u(){return iP(s).some(e=>i[e]&&function(e,n){let t=cz(n),a=t.next();if(a.done)return!1;let o=a.value,r=cz(e),i=r.next(o.from),s=i.value;for(;!a.done&&!i.done;){if(0>=lG(s.from,o.to)&&lG(s.to,o.from)>=0)return!0;0>lG(o.from,s.from)?o=(a=t.next(s.from)).value:s=(i=r.next(o.from)).value}return!1}(i[e],s[e]))}let d=e=>{cj(i,e),u()&&f()},f=()=>{let m,h;if(c||r)return;i={};let g={},y=(o&&li(),m=()=>lr(e,{subscr:g,trans:null}),h=sU.trans?lf(sU.transless,m):m(),o&&h.then(ls,ls),h);p||(l6(l5,d),p=!0),c=!0,Promise.resolve(y).then(e=>{t=!0,n=e,c=!1,r||(u()?f():(i={},s=g,a.next&&a.next(e)))},e=>{c=!1,t=!1,a.error&&a.error(e),l.unsubscribe()})};return f(),l});return a.hasValue=()=>t,a.getValue=()=>n,a},extendObservabilitySet:cj,getByKeyPath:iZ,setByKeyPath:iX,delByKeyPath:function(e,n){"string"==typeof n?iX(e,n,void 0):"length"in n&&[].map.call(n,function(n){iX(e,n,void 0)})},shallowClone:iQ,deepClone:i4,getObjectDiff:ck,cmp:lG,asap:iY,minKey:l$,addons:[],connections:lw,errnames:sh,dependencies:o,semVer:l_,version:l_.split(".").map(e=>parseInt(e)).reduce((e,n,t)=>e+n/Math.pow(10,2*t))}),cB.maxKey=cn(cB.dependencies.IDBKeyRange),"u">typeof dispatchEvent&&"u">typeof addEventListener&&(l6(l5,e=>{if(!cF){let n;lx?(n=document.createEvent("CustomEvent")).initCustomEvent(l4,!0,!0,e):n=new CustomEvent(l4,{detail:e}),cF=!0,dispatchEvent(n),cF=!1}}),addEventListener(l4,({detail:e})=>{cF||cR(e)}));let cF=!1;if("u">typeof BroadcastChannel){let e=new BroadcastChannel(l4);"function"==typeof e.unref&&e.unref(),l6(l5,n=>{cF||e.postMessage(n)}),e.onmessage=e=>{e.data&&cR(e.data)}}else if("u">typeof self&&"u">typeof navigator){l6(l5,e=>{try{cF||("u">typeof localStorage&&localStorage.setItem(l4,JSON.stringify({trig:Math.random(),changedParts:e})),"object"==typeof self.clients&&[...self.clients.matchAll({includeUncontrolled:!0})].forEach(n=>n.postMessage({type:l4,changedParts:e})))}catch(e){}}),"u">typeof addEventListener&&addEventListener("storage",e=>{if(e.key===l4){let n=JSON.parse(e.newValue);n&&cR(n.changedParts)}});let e=self.document&&navigator.serviceWorker;e&&e.addEventListener("message",function({data:e}){e&&e.type===l4&&cR(e.changedParts)})}function cL(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}sY.rejectionMapper=function(e,n){if(!e||e instanceof su||e instanceof TypeError||e instanceof SyntaxError||!e.name||!sy[e.name])return e;var t=new sy[e.name](n||e.message,e);return"stack"in e&&iL(t,"stack",{get:function(){return this.inner.stack}}),t},so=lC;class cW extends cB{constructor(){super("EsmOffline"),cL(this,"syncQueue",void 0),cL(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 cG(){return new cW}let cV=new cW,cU={},cq=V("offline-synchronization",{});function cH(){return cq}async function cK(){if(cq.getState().synchronization)return;let e=await cV.syncQueue.count(),n={},t=Object.entries(cU),a=t.length,o={},r=new AbortController,i=()=>{let e=cq.getState().synchronization;cq.setState({synchronization:{...e,pendingCount:e.pendingCount-1}})};try{cq.setState({synchronization:{totalCount:e,pendingCount:e,abortController:r}});for(let e=0;e<a&&t.length>0;e++)for(let e=t.length;e--;){let[a,s]=t[e],l=s.dependsOn.map(e=>n[e]);l.every(Boolean)&&(o[a]={},await Promise.all(l),n[a]=cY(s,o,r,i),t.splice(e,1))}await Promise.allSettled(Object.values(n))}finally{cq.setState({synchronization:void 0})}}async function cY({type:e,dependsOn:n,process:t},a,o,r){let i=[],s=[],l=await cJ();await cV.syncQueue.where({type:e,userId:l}).each((e,n)=>{i.push([n.primaryKey,e.content,e.descriptor]),s.push(e.content)});for(let c=0;c<i.length;c++){let[p,u,{id:d,dependencies:f=[]}]=i[c];try{let r=await t(u,{abort:o,index:c,items:s,userId:l,dependencies:f.map(({id:e,type:t})=>n.includes(t)?a[t][e]:void 0)});void 0!==d&&(a[e][d]=r),await cV.syncQueue.delete(p)}catch(e){await cV.syncQueue.update(p,{lastError:{name:e?.name,message:e?.message??e?.toString()}})}finally{r()}}}async function cJ(){let e=await oM();return e?.uuid||"*"}async function cZ(e,n,t,a){let o=a&&a.id;return void 0!==o&&await cV.syncQueue.where({type:n,userId:e}).filter(e=>e?.descriptor.id===o).delete().catch(cB.errnames.DatabaseClosed),await cV.syncQueue.add({type:n,content:t,userId:e,descriptor:a||{},createdOn:new Date}).catch(cB.errnames.DatabaseClosed,()=>-1)}async function cX(e,n,t){let a=await cJ();return await cZ(a,e,n,t)}async function cQ(e,n){return(await c0(e,n)).map(e=>e.content)}async function c0(e,n){return await cV.syncQueue.where(n?{type:n,userId:e}:{userId:e}).toArray().catch(cB.errnames.DatabaseClosed,()=>[])}async function c1(e){let n=await cJ();return await cQ(n,e)}async function c2(e){let n=await cJ();return await c0(n,e)}async function c3(e){return await cV.syncQueue.get(e).catch(cB.errnames.DatabaseClosed,()=>void 0)}function c5(e){return!!cU[e]?.options.onBeginEditSyncItem}async function c4(e){let n=await c3(e);if(!n)throw Error(`No sync item with the ID ${e} exists.`);let t=cU[n.type]?.options.onBeginEditSyncItem;if(!t)throw Error(`A sync item with the ID ${e} exists, but the associated handler (if one exists) doesn't support editing the item. You can avoid this error by either verifying that sync items of this type can be edited via the "canEditSynchronizationItemsOfType(type: string)" function or alternatively ensure that the synchronizaton handler for sync items of type "${n.type}" supports editing items.`);t(n)}async function c6(e){await cV.syncQueue.delete(e).catch(cB.errnames.DatabaseClosed)}function c8(e,n,t,a={}){cU[e]={type:e,dependsOn:n,process:t,options:a}}let c7="u">typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),c9=new Uint8Array(16),pe=[];for(let e=0;e<256;++e)pe.push((e+256).toString(16).slice(1));let pn=function(e,n,t){if(c7&&!n&&!e)return c7();let a=(e=e||{}).random||(e.rng||function(){if(!r&&!(r="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 r(c9)})();if(a[6]=15&a[6]|64,a[8]=63&a[8]|128,n){t=t||0;for(let e=0;e<16;++e)n[t+e]=a[e];return n}return function(e,n=0){return pe[e[n+0]]+pe[e[n+1]]+pe[e[n+2]]+pe[e[n+3]]+"-"+pe[e[n+4]]+pe[e[n+5]]+"-"+pe[e[n+6]]+pe[e[n+7]]+"-"+pe[e[n+8]]+pe[e[n+9]]+"-"+pe[e[n+10]]+pe[e[n+11]]+pe[e[n+12]]+pe[e[n+13]]+pe[e[n+14]]+pe[e[n+15]]}(a)},pt="OFFLINE+";function pa(){return pt+pn()}function po(e){return e.startsWith(pt)}let pr={};function pi(){return Object.values(pr)}function ps(e){pr[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.`),pr[e.id]=e}async function pl(e){let n=await pg();return await pc(n,e)}async function pc(e,n){let t=new cW;return await t.dynamicOfflineData.where(n?{type:n,users:e}:{users:e}).toArray().catch(cB.errnames.DatabaseClosed,()=>[])}async function pp(e,n){let t=await pg();return await pu(t,e,n)}async function pu(e,n,t){let a=new cW,o=await a.dynamicOfflineData.get({type:n,identifier:t}).catch(cB.errnames.DatabaseClosed,()=>void 0);o?o.users.includes(e)||await a.dynamicOfflineData.update(o.id,{users:[...o.users,e]}).catch(cB.errnames.DatabaseClosed):await a.dynamicOfflineData.add({users:[e],type:n,identifier:t}).catch(cB.errnames.DatabaseClosed)}async function pd(e,n){let t=await pg();return await pf(t,e,n)}async function pf(e,n,t){let a=new cW,o=await a.dynamicOfflineData.get({type:n,identifier:t,users:e}).catch(cB.errnames.DatabaseClosed,()=>void 0);o&&(o.users.length>1?await a.dynamicOfflineData.update(o.id,{users:o.users.filter(n=>n!==e)}).catch(cB.errnames.DatabaseClosed):await a.dynamicOfflineData.delete(o.id).catch(cB.errnames.DatabaseClosed))}async function pm(e,n){let t=await pl(e);await Promise.all(t.map(async e=>ph(e.type,e.identifier,n)))}async function ph(e,n,t){await pp(e,n);let a=new cW,o=await pg(),r=await a.dynamicOfflineData.get({type:e,identifier:n}).catch(cB.errnames.DatabaseClosed,()=>void 0),i=pi().filter(n=>n.type===e);if(!r)return;let s=await Promise.all(i.map(async e=>{try{return e.sync(n,t),{id:e.id,error:void 0}}catch(t){let n=t.message?.toString()??t.toString();return{id:e.id,error:n}}})),l=s.filter(e=>!e.error).map(e=>e.id),c=s.filter(e=>e.error).map(e=>e.id),p=s.filter(e=>e.error).map(e=>({handlerId:e.id,message:e.error})),u={syncedOn:new Date,syncedBy:o,succeededHandlers:l,erroredHandlers:c,errors:p};r.id&&await a.dynamicOfflineData.update(r.id,{syncState:u}).catch(cB.errnames.DatabaseClosed)}async function pg(){let e=(await oM()).uuid;if(!e)throw Error("Using the dynamic offline data API requires a logged in user.");return e}let py=V("offline-patients",{offlinePatientDataSyncState:{},handlers:{}});function pb(){return p$(),py}function p_(e,n){p$(),ps({type:"patient",displayName:n.displayName,id:e,isSynced:()=>Promise.resolve(!0),sync:(e,t)=>n.onOfflinePatientAdded({patientUuid:e,signal:t??new AbortController().signal})})}async function pv(e){p$(),await ph("patient",e)}function p$(){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 pA(e,n,t=!0){if(e){let a=null,[o,r]=await Promise.all([o_(`${og}/Patient/${e}`,n).catch(e=>a=e),t?pk(e):Promise.resolve(null)]);if(o.ok)return o.data;if(r)return r;if(a)throw a}return null}async function pk(e){let n=(await c1("patient-registration")).find(n=>n.fhirPatient.id===e);return n?.fhirPatient??null}function pw(e,n){let t=new CustomEvent(`openmrs:${e}`,{detail:n??void 0,cancelable:!0,bubbles:!0});return window.dispatchEvent(t)}function px(e,n){let t=e=>{n("detail"in e&&null!==e.detail?e.detail:void 0)};return window.addEventListener(`openmrs:${e}`,t),()=>{window.removeEventListener(`openmrs:${e}`,t)}}var pC=t(56170);function pE(e){return{uuid:e.uuid,display:e.display}}function pS(e=null,n=null){let t=new URLSearchParams;e&&t.set("tag",e),n&&t.set("q",n);let a=t.toString();return ov(`${oh}/location${a?"?"+a:""}`).pipe((0,pC.map)(e=>e.data.results.map(pE))).pipe((0,pC.take)(1))}function pD(e){return{uuid:e.uuid,display:e.display,name:e.name}}function pM(){return ov(`${oh}/visittype`).pipe((0,pC.map)(e=>e.data.results.map(pD))).pipe((0,pC.take)(1))}var pz=((ee={}).NEWVISIT="startVisit",ee.EDITVISIT="editVisit",ee.LOADING="loadingVisit",ee),pO=((en={}).NOTSTARTED="notStarted",en.ONGOING="ongoing",en);let pP="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))",pT=function(){try{return JSON.parse(sessionStorage.getItem("openmrs:visitStoreState")||"null")}catch(e){return null}}()||{patientUuid:null,manuallySetVisitUuid:null,mutateVisitCallbacks:{}};function pB(){return q("visit",pT)}function pI(e,n){pB().setState({patientUuid:e,manuallySetVisitUuid:n})}function pN(e,n){return o_(`${oh}/visit`,{signal:n.signal,method:"POST",headers:{"Content-type":"application/json"},body:e})}function pj(e,n,t){return o_(`${oh}/visit/${e}`,{signal:t.signal,method:"POST",headers:{"Content-type":"application/json"},body:n})}function pR(e,n,t){return o_(`${oh}/visit?patient=${e}&v=${t??pP}`,{signal:n.signal,method:"GET",headers:{"Content-type":"application/json"}})}pB().subscribe(e=>{var n;n=e,sessionStorage.setItem("openmrs:visitStoreState",JSON.stringify(n))});let pF=new eo.BehaviorSubject(null);class pL{static get version(){return"1.4.0"}static toString(){return"JavaScript Expression Parser (JSEP) v"+pL.version}static addUnaryOp(e){return pL.max_unop_len=Math.max(e.length,pL.max_unop_len),pL.unary_ops[e]=1,pL}static addBinaryOp(e,n,t){return pL.max_binop_len=Math.max(e.length,pL.max_binop_len),pL.binary_ops[e]=n,t?pL.right_associative.add(e):pL.right_associative.delete(e),pL}static addIdentifierChar(e){return pL.additional_identifier_chars.add(e),pL}static addLiteral(e,n){return pL.literals[e]=n,pL}static removeUnaryOp(e){return delete pL.unary_ops[e],e.length===pL.max_unop_len&&(pL.max_unop_len=pL.getMaxKeyLen(pL.unary_ops)),pL}static removeAllUnaryOps(){return pL.unary_ops={},pL.max_unop_len=0,pL}static removeIdentifierChar(e){return pL.additional_identifier_chars.delete(e),pL}static removeBinaryOp(e){return delete pL.binary_ops[e],e.length===pL.max_binop_len&&(pL.max_binop_len=pL.getMaxKeyLen(pL.binary_ops)),pL.right_associative.delete(e),pL}static removeAllBinaryOps(){return pL.binary_ops={},pL.max_binop_len=0,pL}static removeLiteral(e){return delete pL.literals[e],pL}static removeAllLiterals(){return pL.literals={},pL}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 pL(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 pL.binary_ops[e]||0}static isIdentifierStart(e){return e>=65&&e<=90||e>=97&&e<=122||e>=128&&!pL.binary_ops[String.fromCharCode(e)]||pL.additional_identifier_chars.has(String.fromCharCode(e))}static isIdentifierPart(e){return pL.isIdentifierStart(e)||pL.isDecimalDigit(e)}throwError(e){let n=Error(e+" at character "+this.index);throw n.index=this.index,n.description=e,n}runHook(e,n){if(pL.hooks[e]){let t={context:this,node:n};return pL.hooks.run(e,t),t.node}return n}searchHook(e){if(pL.hooks[e]){let n={context:this};return pL.hooks[e].find(function(e){return e.call(n.context,n),n.node}),n.node}}gobbleSpaces(){let e=this.code;for(;e===pL.SPACE_CODE||e===pL.TAB_CODE||e===pL.LF_CODE||e===pL.CR_CODE;)e=this.expr.charCodeAt(++this.index);this.runHook("gobble-spaces")}parse(){this.runHook("before-all");let e=this.gobbleExpressions(),n=1===e.length?e[0]:{type:pL.COMPOUND,body:e};return this.runHook("after-all",n)}gobbleExpressions(e){let n=[],t,a;for(;this.index<this.expr.length;)if((t=this.code)===pL.SEMCOL_CODE||t===pL.COMMA_CODE)this.index++;else if(a=this.gobbleExpression())n.push(a);else if(this.index<this.expr.length){if(t===e)break;this.throwError('Unexpected "'+this.char+'"')}return n}gobbleExpression(){let e=this.searchHook("gobble-expression")||this.gobbleBinaryExpression();return this.gobbleSpaces(),this.runHook("after-expression",e)}gobbleBinaryOp(){this.gobbleSpaces();let e=this.expr.substr(this.index,pL.max_binop_len),n=e.length;for(;n>0;){if(pL.binary_ops.hasOwnProperty(e)&&(!pL.isIdentifierStart(this.code)||this.index+e.length<this.expr.length&&!pL.isIdentifierPart(this.expr.charCodeAt(this.index+e.length))))return this.index+=n,e;e=e.substr(0,--n)}return!1}gobbleBinaryExpression(){let e,n,t,a,o,r,i,s,l;if(!(r=this.gobbleToken())||!(n=this.gobbleBinaryOp()))return r;for(o={value:n,prec:pL.binaryPrecedence(n),right_a:pL.right_associative.has(n)},(i=this.gobbleToken())||this.throwError("Expected expression after "+n),a=[r,o,i];n=this.gobbleBinaryOp();){if(0===(t=pL.binaryPrecedence(n))){this.index-=n.length;break}o={value:n,prec:t,right_a:pL.right_associative.has(n)},l=n;let s=e=>o.right_a&&e.right_a?t>e.prec:t<=e.prec;for(;a.length>2&&s(a[a.length-2]);)i=a.pop(),n=a.pop().value,r=a.pop(),e={type:pL.BINARY_EXP,operator:n,left:r,right:i},a.push(e);(e=this.gobbleToken())||this.throwError("Expected expression after "+l),a.push(o,e)}for(s=a.length-1,e=a[s];s>1;)e={type:pL.BINARY_EXP,operator:a[s-1].value,left:a[s-2],right:e},s-=2;return e}gobbleToken(){let e,n,t,a;if(this.gobbleSpaces(),a=this.searchHook("gobble-token"))return this.runHook("after-token",a);if(e=this.code,pL.isDecimalDigit(e)||e===pL.PERIOD_CODE)return this.gobbleNumericLiteral();if(e===pL.SQUOTE_CODE||e===pL.DQUOTE_CODE)a=this.gobbleStringLiteral();else if(e===pL.OBRACK_CODE)a=this.gobbleArray();else{for(t=(n=this.expr.substr(this.index,pL.max_unop_len)).length;t>0;){if(pL.unary_ops.hasOwnProperty(n)&&(!pL.isIdentifierStart(this.code)||this.index+n.length<this.expr.length&&!pL.isIdentifierPart(this.expr.charCodeAt(this.index+n.length)))){this.index+=t;let e=this.gobbleToken();return e||this.throwError("missing unaryOp argument"),this.runHook("after-token",{type:pL.UNARY_EXP,operator:n,argument:e,prefix:!0})}n=n.substr(0,--t)}pL.isIdentifierStart(e)?(a=this.gobbleIdentifier(),pL.literals.hasOwnProperty(a.name)?a={type:pL.LITERAL,value:pL.literals[a.name],raw:a.name}:a.name===pL.this_str&&(a={type:pL.THIS_EXP})):e===pL.OPAREN_CODE&&(a=this.gobbleGroup())}return a?(a=this.gobbleTokenProperty(a),this.runHook("after-token",a)):this.runHook("after-token",!1)}gobbleTokenProperty(e){this.gobbleSpaces();let n=this.code;for(;n===pL.PERIOD_CODE||n===pL.OBRACK_CODE||n===pL.OPAREN_CODE||n===pL.QUMARK_CODE;){let t;if(n===pL.QUMARK_CODE){if(this.expr.charCodeAt(this.index+1)!==pL.PERIOD_CODE)break;t=!0,this.index+=2,this.gobbleSpaces(),n=this.code}this.index++,n===pL.OBRACK_CODE?((e={type:pL.MEMBER_EXP,computed:!0,object:e,property:this.gobbleExpression()}).property||this.throwError('Unexpected "'+this.char+'"'),this.gobbleSpaces(),(n=this.code)!==pL.CBRACK_CODE&&this.throwError("Unclosed ["),this.index++):n===pL.OPAREN_CODE?e={type:pL.CALL_EXP,arguments:this.gobbleArguments(pL.CPAREN_CODE),callee:e}:(n===pL.PERIOD_CODE||t)&&(t&&this.index--,this.gobbleSpaces(),e={type:pL.MEMBER_EXP,computed:!1,object:e,property:this.gobbleIdentifier()}),t&&(e.optional=!0),this.gobbleSpaces(),n=this.code}return e}gobbleNumericLiteral(){let e="",n,t;for(;pL.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);if(this.code===pL.PERIOD_CODE)for(e+=this.expr.charAt(this.index++);pL.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);if("e"===(n=this.char)||"E"===n){for(e+=this.expr.charAt(this.index++),("+"===(n=this.char)||"-"===n)&&(e+=this.expr.charAt(this.index++));pL.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);pL.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+e+this.char+")")}return t=this.code,pL.isIdentifierStart(t)?this.throwError("Variable names cannot start with a number ("+e+this.char+")"):(t===pL.PERIOD_CODE||1===e.length&&e.charCodeAt(0)===pL.PERIOD_CODE)&&this.throwError("Unexpected period"),{type:pL.LITERAL,value:parseFloat(e),raw:e}}gobbleStringLiteral(){let e="",n=this.index,t=this.expr.charAt(this.index++),a=!1;for(;this.index<this.expr.length;){let n=this.expr.charAt(this.index++);if(n===t){a=!0;break}if("\\"===n)switch(n=this.expr.charAt(this.index++)){case"n":e+="\n";break;case"r":e+="\r";break;case"t":e+=" ";break;case"b":e+="\b";break;case"f":e+="\f";break;case"v":e+="\v";break;default:e+=n}else e+=n}return a||this.throwError('Unclosed quote after "'+e+'"'),{type:pL.LITERAL,value:e,raw:this.expr.substring(n,this.index)}}gobbleIdentifier(){let e=this.code,n=this.index;for(pL.isIdentifierStart(e)?this.index++:this.throwError("Unexpected "+this.char);this.index<this.expr.length;)if(e=this.code,pL.isIdentifierPart(e))this.index++;else break;return{type:pL.IDENTIFIER,name:this.expr.slice(n,this.index)}}gobbleArguments(e){let n=[],t=!1,a=0;for(;this.index<this.expr.length;){this.gobbleSpaces();let o=this.code;if(o===e){t=!0,this.index++,e===pL.CPAREN_CODE&&a&&a>=n.length&&this.throwError("Unexpected token "+String.fromCharCode(e));break}if(o===pL.COMMA_CODE){if(this.index++,++a!==n.length){if(e===pL.CPAREN_CODE)this.throwError("Unexpected token ,");else if(e===pL.CBRACK_CODE)for(let e=n.length;e<a;e++)n.push(null)}}else if(n.length!==a&&0!==a)this.throwError("Expected comma");else{let e=this.gobbleExpression();e&&e.type!==pL.COMPOUND||this.throwError("Expected comma"),n.push(e)}}return t||this.throwError("Expected "+String.fromCharCode(e)),n}gobbleGroup(){this.index++;let e=this.gobbleExpressions(pL.CPAREN_CODE);if(this.code===pL.CPAREN_CODE)return(this.index++,1===e.length)?e[0]:!!e.length&&{type:pL.SEQUENCE_EXP,expressions:e};this.throwError("Unclosed (")}gobbleArray(){return this.index++,{type:pL.ARRAY_EXP,elements:this.gobbleArguments(pL.CBRACK_CODE)}}}Object.assign(pL,{hooks:new class{add(e,n,t){if("string"!=typeof arguments[0])for(let e in arguments[0])this.add(e,arguments[0][e],arguments[1]);else(Array.isArray(e)?e:[e]).forEach(function(e){this[e]=this[e]||[],n&&this[e][t?"unshift":"push"](n)},this)}run(e,n){this[e]=this[e]||[],this[e].forEach(function(e){e.call(n&&n.context?n.context:n,n)})}},plugins:new class{constructor(e){this.jsep=e,this.registered={}}register(...e){e.forEach(e=>{if("object"!=typeof e||!e.name||!e.init)throw Error("Invalid JSEP plugin format");this.registered[e.name]||(e.init(this.jsep),this.registered[e.name]=e)})}}(pL),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"}),pL.max_unop_len=pL.getMaxKeyLen(pL.unary_ops),pL.max_binop_len=pL.getMaxKeyLen(pL.binary_ops);let pW=e=>new pL(e).parse(),pG=Object.getOwnPropertyNames(class{});Object.getOwnPropertyNames(pL).filter(e=>!pG.includes(e)&&void 0===pW[e]).forEach(e=>{pW[e]=pL[e]}),pW.Jsep=pL,pW.plugins.register({name:"ternary",init(e){e.hooks.add("after-expression",function(n){if(n.node&&this.code===e.QUMARK_CODE){this.index++;let t=n.node,a=this.gobbleExpression();if(a||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===e.COLON_CODE){this.index++;let o=this.gobbleExpression();if(o||this.throwError("Expected expression"),n.node={type:"ConditionalExpression",test:t,consequent:a,alternate:o},t.operator&&e.binary_ops[t.operator]<=.9){let a=t;for(;a.right.operator&&e.binary_ops[a.right.operator]<=.9;)a=a.right;n.node.test=a.right,a.right=n.node,n.node=t}}else this.throwError("Expected :")}})}});let pV="ArrowFunctionExpression",pU={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)}},pq={...pU,Promise};function pH(e,n={}){return pQ(e,n,p2)}async function pK(e,n={}){return p0(e,n,p2)}function pY(e,n={}){return pQ(e,n,p3)}function pJ(e,n={}){return p0(e,n,p3)}function pZ(e,n={}){return pQ(e,n,p5)}function pX(e,n={}){return p0(e,n,p5)}function pQ(e,n={},t){if("string"!=typeof e&&("object"!=typeof e||!e||!("type"in e)))throw`Unknown expression type ${e}. Expressions must either be a string or pre-compiled string.`;if("string"==typeof e&&0===e.trim().length)throw{type:"Empty expression",message:"Expression cannot be an empty string"};null==n&&(n={});let a=p8(n,pU),o=p4("string"==typeof e?pW(e):e,a);if(t(o))return o;throw{type:"Invalid result",message:"string"==typeof e?`The expression ${e} did not produce a valid result`:"The expression did not produce a valid result"}}async function p0(e,n={},t){if("string"!=typeof e&&("object"!=typeof e||!e||!("type"in e)))return Promise.reject(`Unknown expression type ${e}. Expressions must either be a string or pre-compiled string.`);if("string"==typeof e&&0===e.trim().length)throw{type:"Empty expression",message:"Expression cannot be an empty string"};null==n&&(n={});let a=p8(n,pq);return Promise.resolve(p4("string"==typeof e?pW(e):e,a)).then(n=>{if(t(n))return n;throw{type:"Invalid result",message:"string"==typeof e?`The expression ${e} did not produce a valid result`:"The expression did not produce a valid result"}})}function p1(e){return pW(e)}function p2(e){return"string"==typeof e||"number"==typeof e||"boolean"==typeof e||null==e||e instanceof Date}function p3(e){return"boolean"==typeof e}function p5(e){return"number"==typeof e}function p4(e,n){switch(e.type){case"UnaryExpression":var t,a,o,r,i,s,l,c,p,u,d,f,m=e,h=n;let g=p4(m.argument,h);switch(m.operator){case"+":return+g;case"-":return-g;case"~":return~g;case"!":return!g;default:throw`Expression evaluator does not support operator '${m.operator}''`}case"BinaryExpression":var y=e,b=n;let v=p4(y.left,b),$=p4(y.right,b);switch(y.operator){case"+":return v+$;case"-":return v-$;case"*":return v*$;case"/":return v/$;case"%":return v%$;case"**":return v**$;case"==":return v==$;case"===":return v===$;case"!=":return v!=$;case"!==":return v!==$;case">":return v>$;case">=":return v>=$;case"<":return v<$;case"<=":return v<=$;case"in":return v in $;case"&&":return v&&$;case"||":return v||$;case"??":return v??$;default:throw`Expression evaluator does not support operator '${y.operator}' operator`}case"ConditionalExpression":return t=e,a=n,p4(t.test,a)?p4(t.consequent,a):p4(t.alternate,a);case"CallExpression":var A=e,k=n;let w=A.arguments?.map(p7(k)),x=p4(A.callee,k);if(x){if("function"!=typeof x)throw`${ue(A.callee)} is not a function`}else throw`No function named ${ue(A.callee)} is defined in this context`;return x(...w);case"ArrowFunctionExpression":let C;return o=e,r=n,C=o.params?.map(e=>{if("Identifier"===e.type)return e.name;throw`Cannot handle parameter of type ${e.type}`})??[],(function(...e){if(e.length<C.length)throw`Required argument(s) ${C.slice(e.length,-1).join(", ")} were not provided`;let n=Object.fromEntries(C.reduce((n,t,a)=>{let o=e[a];return function e(n){if("string"==typeof n||"number"==typeof n||"boolean"==typeof n||"function"==typeof n||null===n||n instanceof RegExp)return!0;if("object"==typeof n){for(let t of Object.keys(n))if(!e(n[t]))return!1;return!0}if(Array.isArray(n)){for(let t of n)if(!e(t))break}return!1}(o)&&n.push([t,o]),n},[]));return p4(o.body,r.addVariables(n))}).bind(r.thisObj??null);case"MemberExpression":return function(e,n){let t,a=p4(e.object,n);if(void 0===a)switch(e.object.type){case"Identifier":{let t=p6(e.object,n);throw ReferenceError(`ReferenceError: ${t} is not defined`)}case"MemberExpression":{let t=p6(e.property,n);throw TypeError(`TypeError: cannot read properties of undefined (reading '${t}')`)}default:throw`VisitMemberExpression does not support operator '${e.object.type}' type`}let o=a;if("string"==typeof a)o=String.prototype;else if("number"==typeof a)o=Number.prototype;else if("function"==typeof a);else if("object"!=typeof a)throw`VisitMemberExpression does not support member access on type ${typeof a}`;switch(n.thisObj=o,e.property.type){case"Identifier":case"MemberExpression":t=p4(e.property,n);break;default:{let o=p4(e.property,n);if(void 0===o)throw{type:"Illegal property access",message:"No property was supplied to the property access"};p9(o),t=a[o]}}return"function"==typeof t?t.bind(a):t}(e,n);case"ArrayExpression":return i=e,s=n,i.elements?.map(p7(s));case"SequenceExpression":let E;return l=e,c=n,(E=l.expressions.map(p7(c)))[E.length-1];case"NewExpression":var S=e,D=n;if(S.callee&&"Identifier"===S.callee.type){let e=S.arguments?.map(p7(D));switch(S.callee.name){case"Date":return new Date(...e);case"RegExp":return new RegExp(...e);default:throw`Cannot instantiate object of type ${S.callee.name}`}}if(S.callee)throw"new must be called with either Date or RegExp";throw'Could not handle "new" without a specified class';case"Literal":return p9((p=e).value),p.value;case"Identifier":var M=e,z=n;p9(M.name);let O=z.thisObj;if(O&&("object"==typeof O||"function"==typeof O)&&M.name in O){let e=O[M.name];return p9(e),e}if(z.variables&&M.name in z.variables){let e=z.variables[M.name];return p9(e),e}return M.name in z.globals?z.globals[M.name]:void 0;case"TemplateLiteral":let P,T;return u=e,d=n,P=u.expressions?.map(p7(d))??[],(T=u.quasis?.map(p7(d))??[]).filter(e=>!e.tail).map(e=>e.value).join("")+P.join("")+T.filter(e=>e.tail).map(e=>e.value).join("");case"TemplateElement":return{value:(f=e).cooked,tail:f.tail};default:throw`Expression evaluator does not support expression of type '${e.type}'`}}function p6(e,n){switch(e.type){case"Literal":return e.value;case"Identifier":return e.name;case"MemberExpression":return p6(e.property,n);default:throw`VisitExpressionName does not support expression of type '${e.type}'`}}function p8(e,n){let t={thisObj:void 0,variables:{...e},globals:{...n},addVariables(e){return this.variables={...this.variables,...e},this}};return t.addVariables.bind(t),t}function p7(e){return function(n){return null===n?null:p4(n,e)}}function p9(e){if("__proto__"===e||"prototype"===e||"constructor"===e)throw{type:"Illegal property access",message:`Cannot access the ${e} property of objects`}}function ue(e){return e?"MemberExpression"===e.type?e.property?.name:e.name:null}function un(e){if("string"!=typeof e&&("object"!=typeof e||!e||!("type"in e)))throw`Unknown expression type ${e}. Expressions must either be a string or pre-compiled string.`;let n={globals:{...pq},isLocalExpression:!1,variables:new Set};return ut("string"==typeof e?pW(e):e,n),[...n.variables]}function ut(e,n){switch(e.type){case"UnaryExpression":return a=e,o=n,ut(a.argument,o);case"BinaryExpression":return r=e,i=n,[ut(r.left,i),ut(r.right,i)].filter(Boolean);case"ConditionalExpression":return s=e,l=n,[ut(s.consequent,l),ut(s.test,l),ut(s.alternate,l)].filter(Boolean);case"CallExpression":let t;return c=e,p=n,t=ut(c.callee,p),c.arguments?.map(ua(p)),t;case"ArrowFunctionExpression":var a,o,r,i,s,l,c,p,u,d,f,m,h,g,y,b,v,$,A=e,k=n;let w={...k};w.isLocalExpression=!0;let x=A.params?.map(ua(w))??[],C=ut(A.body,w)??[];if(C&&Array.isArray(C))for(let e of C)x.includes(e)||k.variables.add(e);return;case"MemberExpression":let E;return u=e,d=n,ut(u.object,d),void((E={...d}).isLocalExpression=!0,ut(u.property,E));case"ArrayExpression":return f=e,m=n,void f.elements?.map(ua(m));case"SequenceExpression":return h=e,g=n,void h.expressions?.map(ua(g));case"NewExpression":return y=e,b=n,void y.arguments?.map(ua(b));case"Literal":case"TemplateElement":return;case"Identifier":var S=e,D=n;if(!(S.name in D.globals))if(D.isLocalExpression)return S.name;else D.variables.add(S.name);return;case"TemplateLiteral":return v=e,$=n,void(v.expressions?.map(ua($)),v.quasis?.map(ua($)));default:throw`Expression evaluator does not support expression of type '${e.type}'`}}function ua(e){return function(n){return null===n?null:ut(n,e)}}pW.plugins.register({name:"arrow",init(e){e.addBinaryOp("=>",.1,!0),e.hooks.add("gobble-expression",function(n){if(this.gobbleSpaces(),this.code===e.OPAREN_CODE){let t=this.index;if(this.index++,this.gobbleSpaces(),this.code===e.CPAREN_CODE){this.index++;let e=this.gobbleBinaryOp();if("=>"===e){let t=this.gobbleBinaryExpression();t||this.throwError("Expected expression after "+e),n.node={type:pV,params:null,body:t};return}}this.index=t}}),e.hooks.add("after-expression",function(n){!function n(t){t&&(Object.values(t).forEach(e=>{e&&"object"==typeof e&&n(e)}),"=>"===t.operator&&(t.type=pV,t.params=t.left?[t.left]:null,t.body=t.right,t.params&&t.params[0].type===e.SEQUENCE_EXP&&(t.params=t.params[0].expressions),delete t.left,delete t.right,delete t.operator))}(n.node)})}}),pW.plugins.register({name:"new",init(e){e.addUnaryOp("new"),e.hooks.add("after-token",function(n){let t=n.node;if(t&&"new"===t.operator){t.argument&&[e.CALL_EXP,e.MEMBER_EXP].includes(t.argument.type)||this.throwError("Expected new function()"),n.node=t.argument;let a=n.node;for(;a.type===e.MEMBER_EXP||a.type===e.CALL_EXP&&a.callee.type===e.MEMBER_EXP;)a=a.type===e.MEMBER_EXP?a.object:a.callee.object;a.type="NewExpression"}})}}),pW.plugins.register({name:"numbers",init(e){function n(e){return"x"===e||"X"===e?(this.index+=2,[[48,57],[65,70],[97,102]]):"b"===e||"B"===e?(this.index+=2,[[48,49]]):"o"===e||"O"===e||e>="0"&&e<="7"?(this.index+=e<="7"?1:2,[[48,55]]):null}function t(n){let t=this.index,a="",o=()=>{for(;e.isDecimalDigit(this.code)||95===this.code;)95===this.code?this.index++:a+=this.expr.charAt(this.index++)};o(),this.code===e.PERIOD_CODE&&(a+=this.expr.charAt(this.index++),o());let r=this.char;("e"===r||"E"===r)&&(a+=this.expr.charAt(this.index++),("+"===(r=this.char)||"-"===r)&&(a+=this.expr.charAt(this.index++)),o(),e.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+a+this.char+")"));let i=this.code;if(e.isIdentifierStart(i))this.throwError("Variable names cannot start with a number ("+a+this.char+")");else if(i===e.PERIOD_CODE){a.length>1&&this.throwError(`Unexpected period ${JSON.stringify({chCode:i,number:a},null,2)}`),this.index=t;return}n.node={type:e.LITERAL,value:parseFloat(a),raw:this.expr.substring(t,this.index)}}e.hooks.add("gobble-token",function(a){if(48===this.code){var o,r,i;let s=this.index,l=this.expr.charAt(this.index+1),c=n.call(this,l);if(!c)return;let p="";for(;o=this.code,r=c,95===o||r.some(([e,n])=>o>=e&&o<=n);)95===this.code?this.index++:p+=this.expr.charAt(this.index++);if(e.isIdentifierPart(this.code)){if(e.isDecimalDigit(this.code)&&e.isDecimalDigit(l.charCodeAt(0))){this.index=s+1,t.call(this,a);return}this.throwError("unexpected char within number")}a.node={type:e.LITERAL,value:parseInt(p,"x"===(i=l)||"X"===i?16:"b"===i||"B"===i?2:8),raw:this.expr.substring(s,this.index)}}else(e.isDecimalDigit(this.code)||this.code===e.PERIOD_CODE)&&t.call(this,a)})}}),pW.plugins.register({name:"regex",init(e){e.hooks.add("gobble-token",function(n){if(47===this.code){let t=++this.index,a=!1;for(;this.index<this.expr.length;){if(47===this.code&&!a){let a,o=this.expr.slice(t,this.index),r="";for(;++this.index<this.expr.length;){let e=this.code;if(e>=97&&e<=122||e>=65&&e<=90||e>=48&&e<=57)r+=this.char;else break}try{a=new RegExp(o,r)}catch(e){this.throwError(e.message)}return n.node={type:e.LITERAL,value:a,raw:this.expr.slice(t-1,this.index)},n.node=this.gobbleTokenProperty(n.node),n.node}this.code===e.OBRACK_CODE?a=!0:a&&this.code===e.CBRACK_CODE&&(a=!1),this.index+=92===this.code?2:1}this.throwError("Unclosed Regex")}})}}),pW.plugins.register({name:"ternary",init(e){e.hooks.add("after-expression",function(n){if(n.node&&this.code===e.QUMARK_CODE){this.index++;let t=n.node,a=this.gobbleExpression();if(a||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===e.COLON_CODE){this.index++;let o=this.gobbleExpression();if(o||this.throwError("Expected expression"),n.node={type:"ConditionalExpression",test:t,consequent:a,alternate:o},t.operator&&e.binary_ops[t.operator]<=.9){let a=t;for(;a.right.operator&&e.binary_ops[a.right.operator]<=.9;)a=a.right;n.node.test=a.right,a.right=n.node,n.node=t}}else this.throwError("Expected :")}})}}),pW.plugins.register({name:"jsepTemplateLiteral",init(e){function n(e,t=!0){if(96===this.code){let n={type:"TemplateLiteral",quasis:[],expressions:[]},a="",o="",r=!1,i=this.expr.length,s=()=>n.quasis.push({type:"TemplateElement",value:{raw:o,cooked:a},tail:r});for(;this.index<i;){let i=this.expr.charAt(++this.index);if("`"===i)return this.index+=1,r=!0,s(),e.node=n,t&&(e.node=this.gobbleTokenProperty(e.node)),e.node;if("$"===i&&"{"===this.expr.charAt(this.index+1))this.index+=2,s(),o="",a="",n.expressions.push(...this.gobbleExpressions(125)),125!==this.code&&this.throwError("unclosed ${");else if("\\"===i)switch(o+=i,i=this.expr.charAt(++this.index),o+=i,i){case"n":a+="\n";break;case"r":a+="\r";break;case"t":a+=" ";break;case"b":a+="\b";break;case"f":a+="\f";break;case"v":a+="\v";break;default:a+=i}else a+=i,o+=i}this.throwError("Unclosed `")}}e.hooks.add("gobble-token",n),e.hooks.add("after-token",function(t){if((t.node.type===e.IDENTIFIER||t.node.type===e.MEMBER_EXP)&&96===this.code)return t.node={type:"TaggedTemplateExpression",tag:t.node,quasi:n.bind(this)(t,!1)},t.node=this.gobbleTokenProperty(t.node),t.node})}}),pW.addBinaryOp("in",7),pW.addBinaryOp("??",1);let uo=q("feature-flags",{flags:function(){let e={};for(let n of Object.keys(localStorage))if(n.startsWith("openmrs:feature-flag:")){let t=n.replace("openmrs:feature-flag:",""),a=JSON.parse(localStorage.getItem(`openmrs:feature-flag-meta:${t}`)||"{}");e[t]={enabled:"true"===localStorage.getItem(n),...a}}return e}()});function ur(e,n,t){uo.setState(a=>({flags:{...a.flags,[e]:{enabled:a.flags[e]?.enabled??!1,label:n,description:t}}}))}function ui(){let e=uo.getState().flags;Object.keys(localStorage).filter(e=>e.startsWith("openmrs:feature-flag:")).forEach(n=>{let t=n.replace("openmrs:feature-flag:","");e[t]||(localStorage.removeItem(n),localStorage.removeItem(`openmrs:feature-flag-meta:${t}`))})}function us(e){return uo.getState().flags[e].enabled}function ul(e,n){uo.subscribe(t=>{n(t.flags[e].enabled)})}function uc(e,n){uo.setState(t=>({flags:{...t.flags,[e]:{...t.flags[e],enabled:n}}}))}function up(e){return!window.offlineEnabled||(e??navigator.onLine)}uo.subscribe(e=>{for(let[n,t]of Object.entries(e.flags))localStorage.setItem(`openmrs:feature-flag:${n}`,t.enabled.toString()),localStorage.setItem(`openmrs:feature-flag-meta:${n}`,JSON.stringify({label:t.label,description:t.description}))});var uu=e8(function(e,n,t){eZ(e,n,t)});function ud(e=!0,n=!1){return uf(up(),e,n)}function uf(e,n=!0,t=!1){return!!(e?n:t)}let um=V("extensionsInternal",{slots:{},extensions:{}}),uh=()=>q("extensionsInternal",{slots:{},extensions:{}});function ug(e){let n=um.getState(),t=e(n);t!==n&&um.setState(t)}let uy=()=>q("extensions",{slots:{}});function ub(e){let n=[];for(let t of Object.values(e.extensions))for(let e of t.instances)n.push({slotModuleName:e.slotModuleName,extensionModuleName:t.moduleName,slotName:e.slotName,extensionId:e.id});ne(nQ.getState().mountedExtensions,n)||nQ.setState({mountedExtensions:n})}ub(um.getState()),um.subscribe(ub);let u_=uh(),uv=uy(),u$=n1(),uA=n5();function uk(e,n,t,a,o){let r={},i=up(),s=Object.entries(a.flags).filter(([,{enabled:e}])=>e).map(([e])=>e);for(let[a,l]of Object.entries(e.slots)){let{config:c}=n3(n,l.name),p=uT(a,e,c,t,s,i,o.session);r[a]={moduleName:l.moduleName,assignedExtensions:p}}ne(uv.getState().slots,r)||uv.setState({slots:r})}function uw(){uk(u_.getState(),u$.getState(),uA.getState(),uo.getState(),oA.getState())}function ux(e,n,t){return{moduleName:n,name:e,attachedIds:[],config:null,state:t}}function uC(e){let[n]=e.split("#");return n}function uE(e,n){let t=uC(n);return e.extensions[t]}function uS(e){return uE(u_.getState(),e)}u_.subscribe(e=>{uk(e,u$.getState(),uA.getState(),uo.getState(),oA.getState())}),u$.subscribe(e=>{uk(u_.getState(),e,uA.getState(),uo.getState(),oA.getState())}),uA.subscribe(e=>{uk(u_.getState(),u$.getState(),e,uo.getState(),oA.getState())}),uo.subscribe(e=>{uk(u_.getState(),u$.getState(),uA.getState(),e,oA.getState())}),oA.subscribe(e=>{uk(u_.getState(),u$.getState(),uA.getState(),uo.getState(),e)}),uw(),g(uw);let uD=e=>u_.setState(n=>(n.extensions[e.name]={...e,instances:[]},n));function uM(e,n){ug(t=>{let a=t.slots[e];return a?{...t,slots:{...t.slots,[e]:{...a,attachedIds:[...a.attachedIds,n]}}}:{...t,slots:{...t.slots,[e]:{...ux(e),attachedIds:[n]}}}})}function uz(e,n){ug(t=>{let a=t.slots[e];return a&&a.attachedIds.includes(n)?{...t,slots:{...t.slots,[e]:{...a,attachedIds:a.attachedIds.filter(e=>e!==n)}}}:t})}function uO(e){ug(n=>{let t=n.slots[e];return t?{...n,slots:{...n.slots,[e]:{...t,attachedIds:[]}}}:n})}function uP(e,n,t,a){let o=n.indexOf(e);if(-1!==o)return o;{if(void 0!==t)return 1e3+t;let n=a.indexOf(e);return -1!==n?2e3+n:-1}}function uT(e,n,t,a,o,r,i){let s=function(e,n){let t=e.add||[],a=e.remove||[],o=e.order||[],{extensions:r}=u_.getState();return[...n,...t].filter(e=>!a.includes(e)).sort((e,t)=>{let a=uP(e,o,r[uC(e)]?.order,n),i=uP(t,o,r[uC(t)]?.order,n);return -1===i?-1:-1===a?1:a-i})}(t,n.slots[e].attachedIds),l=[],c=n.slots[e]?.state,p=c&&"object"==typeof c?{session:i,...c}:{session:i};for(let c of s){let{config:s}=n6(a,e,c),u=uu(s,n8(t,e,c)),d=uC(c),f=n.extensions[d];if(f){let n=u?.["Display conditions"]?.privileges??f.privileges??[];if(n&&("string"==typeof n||Array.isArray(n)&&n.length>0)&&(!i?.user||!oD(n,i.user)))continue;let t=u?.["Display conditions"]?.expression||f.displayExpression;if(void 0!==t&&"string"==typeof t&&t.trim().length>0)try{if(!pY(t,p))continue}catch(n){console.error(`Error while evaluating expression '${t}' for extension ${d} in slot ${e}`,n);continue}if(f.featureFlag&&!o.includes(f.featureFlag)||window.offlineEnabled&&!uf(r,f.online,f.offline))continue;l.push({id:c,name:d,moduleName:f.moduleName,config:u,featureFlag:f.featureFlag,meta:f.meta,online:u?.["Display conditions"]?.online??f.online??!0,offline:u?.["Display conditions"]?.offline??f.offline??!1})}}return l}function uB(e){let n=u_.getState(),{config:t}=n2(e),a=uA.getState(),o=uo.getState(),r=oA.getState(),i=up();return uT(e,n,t,a,Object.entries(o.flags).filter(([,{enabled:e}])=>e).map(([e])=>e),i,r.session)}let uI=(e,n,t)=>u_.setState(a=>{let o=a.slots[n]?.moduleName;if(o&&o!=e)return console.warn(`An extension slot with the name '${n}' already exists. Refusing to register the same slot name twice (in "registerExtensionSlot"). The existing one is from module ${o}.`),a;if(o&&o==e)return a;if(a.slots[n])return{...a,slots:{...a.slots,[n]:{...a.slots[n],moduleName:e,state:t}}};let r=ux(n,e,t);return{...a,slots:{...a.slots,[n]:{...r}}}});function uN(e,n,t=!1){u_.setState(a=>{let o=t?uu(a.slots[e].state,n):n;return{...a,slots:{...a.slots,[e]:{...a.slots[e],state:o}}}})}let uj=()=>uv.setState(()=>({slots:{},extensions:{}})),uR=V("left-nav",{slotName:null,basePath:window.spaBase,mode:"normal"});function uF({name:e,basePath:n,mode:t,componentContext:a,state:o}){uR.setState({slotName:e,basePath:n,mode:t??"normal",componentContext:a,state:o})}function uL(e){uR.getState().slotName===e&&uR.setState(uR.getInitialState(),!0)}let uW=V("modalRegistry",{modals:{}});function uG(e){uW.setState(n=>(n.modals[e.name]=e,n))}function uV(e){let n=uW.getState().modals[e];if(!n){let t=uS(e);t&&(n={name:e,load:t.load,moduleName:t.moduleName},console.warn(`Modal ${e} was registered as an extension. This is deprecated and will be removed in the future. Please register it in the "modals" section of routes.json instead of the "extensions" section.`),uG(n))}return n}let uU=V("workspaceRegistrations",{workspaces:{}}),uq=V("workspaceGroups",{workspaceGroups:{}});function uH(e){uU.setState(n=>({workspaces:{...n.workspaces,[e.name]:{...e,load:e.load,preferredWindowSize:e.preferredWindowSize??"normal",type:e.type??"form",canHide:e.canHide??!1,canMaximize:e.canMaximize??!1,width:e.width??"narrow",groups:e.groups??[]}}}))}function uK(e){uq.setState(n=>{let t=n.workspaceGroups[e.name];return t?{workspaceGroups:{...n.workspaceGroups,[e.name]:{...t,members:Array.from(new Set([...t.members,...e.members]))}}}:{workspaceGroups:{...n.workspaceGroups,[e.name]:{name:e.name,members:e.members}}}})}let uY=new Set;function uJ(e){let n=uU.getState().workspaces;if(n[e])return n[e];{let n=uS(e);if(n){var t;let a;return uY.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.`),uY.add(e)),{name:n.name,title:(t=n,"string"==typeof(a=t?.meta?.title)?a:a&&"object"==typeof a?rb(t.moduleName,a.key,a.default):t.name),moduleName:n.moduleName,preferredWindowSize:n.meta?.screenSize??"normal",load:n.load,type:n.meta?.type??"form",canHide:n.meta?.canHide??!1,canMaximize:n.meta?.canMaximize??!1,width:n.meta?.width??"narrow",groups:n.meta?.groups??[]}}throw Error(`No workspace named '${e}' has been registered.`)}}function uZ(e){let n=uq.getState().workspaceGroups;if(n[e])return n[e];throw Error(`No workspace group named '${e}' has been registered.`)}let uX=V("workspace2",{registeredGroupsByName:{},registeredWindowsByName:{},registeredWorkspacesByName:{},openedGroup:null,openedWindows:[],workspaceTitleByWorkspaceName:{},isMostRecentlyOpenedWindowHidden:!1});function uQ(e){let{registeredWorkspacesByName:n,registeredWindowsByName:t}=uX.getState(),a=n[e];if(a){let n=t[a.window];if(n)return n;throw Error(`No workspace window found with name: ${a.window} for workspace: ${e}`)}throw Error(`No workspace found with name: ${e}`)}function u0(e){let{registeredGroupsByName:n,registeredWindowsByName:t}=uX.getState(),a=t[e];if(a){let t=n[a.group];if(t)return t;throw Error(`No workspace group found with name: ${a.group} for window: ${e}`)}throw Error(`No workspace window found with name: ${e}`)}function u1(e){let{openedWindows:n}=uX.getState();return n.findIndex(n=>n.openedWorkspaces.find(n=>n.workspaceName===e))}function u2(e,n){if(0==n.length)return;let{registeredGroupsByName:t}=uX.getState(),a={...t};for(let t of n){if(a[t.name])throw Error(`Cannot register workspace group ${t.name} more than once`);a[t.name]={...t,moduleName:e}}uX.setState({registeredGroupsByName:a})}function u3(e,n){if(0==n.length)return;let{registeredWindowsByName:t}=uX.getState(),a={...t};for(let t of n){if(a[t.name])throw Error(`Cannot register workspace window ${t.name} more than once`);let n={...t,moduleName:e};a[t.name]=n}uX.setState({registeredWindowsByName:a})}function u5(e,n){if(0==n.length)return;let{registeredWorkspacesByName:t}=uX.getState(),a={...t};for(let t of n){if(a[t.name])throw Error(`Cannot register workspace ${t.name} more than once`);let n={...t,moduleName:e};a[t.name]=n}uX.setState({registeredWorkspacesByName:a})}let u4=0;async function u6(e,n,t,a,o=e=>e,r={}){let i=uC(a),s=uS(a),l=null;if(e){if(!s)throw Error(`Couldn't find extension '${i}' to attach to '${n}'`);let{meta:c,moduleName:p,online:u,offline:d,load:f}=s;if(ud(u,d)){ug(o=>({...o,extensions:{...o.extensions,[i]:{...o.extensions[i],instances:[...o.extensions[i].instances,{domElement:e,id:a,slotName:n,slotModuleName:t}]}}}));let s=await f(),u=u4++;l=ay(o({...s,name:`${n}/${i}-${u}`}),{...r,_meta:c,_extensionContext:{extensionId:a,extensionSlotName:n,extensionSlotModuleName:t,extensionModuleName:p},domElement:e})}}else console.warn(`Tried to render ${a} into ${n} but no DOM element was available.`);return l}var u8=t(60695),u7=t.n(u8);let u9=(0,u8.createContext)({moduleName:"",featureName:""});function de({to:e,templateParams:n,onBeforeNavigate:t,children:a,...o}){return(0,u8.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}`)},[]),u7().createElement("a",{onClick:a=>{0===a.button&&!a.ctrlKey&&!a.shiftKey&&!a.altKey&&!a.metaKey&&(a.preventDefault(),t?.(a),or({to:e,templateParams:n})),0===a.button&&(a.ctrlKey||a.metaKey)&&t?.(a),0===a.button&&a.shiftKey&&t?.(a),1===a.button&&t?.(a)},href:oa(e,n),...o},a)}let dn=({state:e,children:n,...t})=>{let{extension:a}=(0,u8.useContext)(u9),o=(0,u8.useRef)(null),r=(0,u8.useRef)(Promise.resolve()),i=(0,u8.useCallback)(n=>{a?.extensionSlotName&&a.extensionSlotModuleName&&a.extensionSlotModuleName&&!o.current&&u6(n,a.extensionSlotName,a.extensionSlotModuleName,a.extensionId,void 0,e).then(e=>{o.current=e})},[]);return(0,u8.useEffect)(()=>()=>{if(o&&o.current)switch(o.current.getStatus()){case"MOUNTING":o.current.mountPromise.then(()=>{o.current?.getStatus()==="MOUNTED"&&o.current.unmount()});break;case"MOUNTED":o.current.unmount();break;case"UPDATING":r.current&&r.current.then(()=>{o.current?.getStatus()==="MOUNTED"&&o.current.unmount()})}},[]),(0,u8.useEffect)(()=>{o.current&&o.current.update&&"UNMOUNTING"!==o.current.getStatus()&&Promise.all([o.current.mountPromise,r.current]).then(()=>{o?.current?.getStatus()==="MOUNTED"&&o.current.update&&(r.current=o.current.update({...e}).catch(e=>{if(!(e instanceof Error)||!e.message.includes("minified message #32")||o.current?.getStatus()==="MOUNTED")throw e}))})},[e]),a?u7().createElement("div",{ref:i,"data-extension-id":a?.extensionId,style:{position:"relative"},...t}):null};function dt(e,n){"function"==typeof n&&(n=n(e));let t={};for(let[a,o]of Object.entries(n)){let n=function(...n){e.setState(e=>o(e,...n))};t[a]=n}return t}let da=()=>e=>e;function dr(e,n=da(),t){let a=(0,u8.useCallback)(n=>e.subscribe(n),[e]),o=(0,u8.useCallback)(()=>n(e.getState()),[e,n]),r=(0,u8.useSyncExternalStore)(a,o,o),i=(0,u8.useMemo)(()=>t?dt(e,t):{},[e,t]);return{...r,...i}}function di(e,n){return dr(e,da(),n)}function ds(e){return function(n){let t=(0,u8.useCallback)(n=>e.subscribe(n),[]),a=(0,u8.useCallback)(()=>e.getState(),[]),o=(0,u8.useSyncExternalStore)(t,a,a),r=(0,u8.useMemo)(()=>n?dt(e,n):{},[n]);return{...o,...r}}}let dl=e=>dr(uy(),n=>n.slots?.[e]);function dc(e){let n=dl(e);return n?.assignedExtensions??[]}function dp(e,n){let{moduleName:t}=(0,u8.useContext)(u9),a=(0,u8.useRef)(!0);if(!t)throw Error("ComponentContext has not been provided. This should come from @openmrs/esm-react-utils.");return(0,u8.useEffect)(()=>{uI(t,e,n),a.current=!1},[]),(0,u8.useEffect)(()=>{a.current||uN(e,n)},[e,n]),{extensions:dc(e),extensionSlotName:e,extensionSlotModuleName:t}}function du(e){return e}function dd({name:e,extensionSlotName:n,select:t=du,children:a,state:o,style:r,...i}){if(a&&o)throw Error("Both children and state have been provided. If children are provided, the state must be passed as a prop to the `Extension` component.");let s=e??n,l=(0,u8.useRef)(null),{extensions:c,extensionSlotModuleName:p}=dp(s,o),u=(0,u8.useMemo)(()=>t(c),[t,c]),d=(0,u8.useMemo)(()=>{if("function"==typeof a&&!u7().isValidElement(a))return u.map(e=>a(e,o))},[a,u]);return u7().createElement("div",{ref:l,"data-extension-slot-name":s,"data-extension-slot-module-name":p,style:{...r,position:"relative"},...i},s&&u?.map((e,n)=>u7().createElement(u9.Provider,{key:e.id,value:{moduleName:p,featureName:"",extension:{extensionId:e.id,extensionSlotName:s,extensionSlotModuleName:p}}},d?.[n]??("function"!=typeof a?a:null)??u7().createElement(dn,{state:o}))))}var df=t(5338);function dm(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);n&&(a=a.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),t.push.apply(t,a)}return t}function dh(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?dm(Object(t),!0).forEach(function(n){var a,o,r;a=e,o=n,r=t[n],o in a?Object.defineProperty(a,o,{value:r,enumerable:!0,configurable:!0,writable:!0}):a[o]=r}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):dm(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})}return e}function dg(e){return(dg="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 dy(e){return(dy="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 db(e,n){var t;if("function"!=typeof(t=n.domElement?function(){return n.domElement}:n.domElementGetter?n.domElementGetter:e.domElementGetter?e.domElementGetter:function(e){var n=e.appName||e.name;if(!n)throw Error("single-spa's dom-element-getter-helpers was not given an application name as a prop, so it can't make a unique dom element container for the react application");var t="single-spa-application:".concat(n);return function(){var e=document.getElementById(t);return e||((e=document.createElement("div")).id=t,document.body.appendChild(e)),e}}(n)))throw Error("single-spa's dom-element-getter-helpers was given an invalid domElementGetter for application or parcel '".concat(n.name,"'. Expected a function, received ").concat(dy(t)));return function(){var e=t(n);if(!(e instanceof HTMLElement))throw Error("single-spa's dom-element-getter-helpers: domElementGetter returned an invalid dom element for application or parcel '".concat(n.name,"'. Expected HTMLElement, received ").concat(dy(e)));return e}}var d_=null;try{d_=require("react").createContext()}catch(e){}var dv={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 d$(e,n){return e.rootComponent?Promise.resolve():e.loadRootComponent(n).then(function(n){e.rootComponent=n})}function dA(e,n){return new Promise(function(t,a){e.suppressComponentDidCatchWarning||!function(e){if(!(e&&"string"==typeof e.version&&e.version.indexOf(".")>=0))return!1;var n=e.version.slice(0,e.version.indexOf("."));try{return Number(n)>=16}catch(e){return!1}}(e.React)||e.errorBoundary||e.errorBoundaryClass||(e.rootComponent.prototype?e.rootComponent.prototype.componentDidCatch||console.warn("single-spa-react: ".concat(n.name||n.appName||n.childAppName,"'s rootComponent should implement componentDidCatch to avoid accidentally unmounting the entire single-spa application.")):console.warn("single-spa-react: ".concat(n.name||n.appName||n.childAppName,"'s rootComponent does not implement an error boundary. If using a functional component, consider providing an opts.errorBoundary to singleSpaReact(opts).")));var o,r=dC(e,n,function(){t(this)}),i=db(e,n)(),s=function(e){var n=e.reactDom,t=e.renderType,a=e.elementToRender,o=e.domElement,r=n[t];if("function"!=typeof r)throw Error('renderType "'.concat(t,'" did not return a function.'));switch(t){case"createRoot":case"unstable_createRoot":case"createBlockingRoot":case"unstable_createBlockingRoot":var i=r(o);return i.render(a),i;case"hydrateRoot":return r(o,a);default:return r(a,o),null}}({elementToRender:r,domElement:i,reactDom:dx(e),renderType:"function"==typeof(o=e).renderType?o.renderType():o.renderType});e.domElements[n.name]=i,e.renderResults[n.name]=s})}function dk(e,n){return new Promise(function(t){e.unmountResolves[n.name]=t;var a=e.renderResults[n.name];a&&a.unmount?a.unmount():dx(e).unmountComponentAtNode(e.domElements[n.name]),delete e.domElements[n.name],delete e.renderResults[n.name]})}function dw(e,n){return new Promise(function(t){e.updateResolves[n.name]||(e.updateResolves[n.name]=[]),e.updateResolves[n.name].push(t);var a=dC(e,n,null),o=e.renderResults[n.name];if(o&&o.render)o.render(a);else{var r=db(e,n)();dx(e).render(a,r)}})}function dx(e){return e.ReactDOMClient||e.ReactDOM}function dC(e,n,t){var a=e.React.createElement(e.rootComponent,n),o=d_?e.React.createElement(d_.Provider,{value:n},a):a;return(e.errorBoundary||n.errorBoundary||e.errorBoundaryClass||n.errorBoundaryClass)&&(e.errorBoundaryClass=e.errorBoundaryClass||n.errorBoundaryClass||function(e,n){function t(n){e.React.Component.apply(this,arguments),this.state={caughtError:null,caughtErrorInfo:null},t.displayName="SingleSpaReactErrorBoundary(".concat(n.name,")")}return t.prototype=Object.create(e.React.Component.prototype),t.prototype.render=function(){return this.state.caughtError?(e.errorBoundary||n.errorBoundary)(this.state.caughtError,this.state.caughtErrorInfo,this.props):this.props.children},t.prototype.componentDidCatch=function(e,n){this.setState({caughtError:e,caughtErrorInfo:n})},t}(e,n),o=e.React.createElement(e.errorBoundaryClass,n,o)),o=e.React.createElement(e.SingleSpaRoot,dh(dh({},n),{},{mountFinished:t,updateFinished:function(){e.updateResolves[n.name]&&(e.updateResolves[n.name].forEach(function(e){return e()}),delete e.updateResolves[n.name])},unmountFinished:function(){e.unmountResolves[n.name]&&(e.unmountResolves[n.name](),delete e.unmountResolves[n.name])}}),o)}var dE=t(70287),dS=t(59324),dD=t(32108);let dM={strictMode:!0,throwErrorsToConsole:!0,disableTranslations:!1},dz=new Map;(0,dD.initCache)(dz);let dO={errorRetryCount:3,fetcher:o_,focusThrottleInterval:18e5,revalidateIfStale:!0,revalidateOnFocus:!1,revalidateOnReconnect:!1,refreshInterval:0,shouldRetryOnError:e=>{if(e instanceof o$){let n=e.response.status;return!!(n>=500)||401===n||403===n||429===n}return!0},provider:()=>dz};function dP(e){if("object"!=typeof e||"string"!=typeof e.featureName||"string"!=typeof e.moduleName)throw Error("Invalid options");let n=Object.assign({},dM,e),t={...dO,...n.swrConfig};return function(e){var a,o,r,i,s;return r=o=class extends(a=u7().Component){componentDidCatch(e,t){t&&t.componentStack&&(e.extra=Object.assign(e.extra||{},{componentStack:t.componentStack})),n.throwErrorsToConsole&&setTimeout(()=>{throw e}),this.setState({caughtError:e,caughtErrorInfo:t})}render(){if(this.state.caughtError)return u7().createElement("div",null,"An error has occurred. Please try reloading the page.");{let a=u7().createElement(u8.Suspense,{fallback:null},u7().createElement(dS.BE,{value:t},u7().createElement(u9.Provider,{value:this.state.config},n.disableTranslations?u7().createElement(e,this.props):u7().createElement(dE.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},u7().createElement(e,this.props)))));return n.strictMode&&u7().StrictMode?u7().createElement(u7().StrictMode,null,a):a}}constructor(e){super(e),this.state={caughtError:null,caughtErrorInfo:null,config:{moduleName:n.moduleName,featureName:n.featureName,extension:e._extensionContext}}}},i="displayName",s=`OpenmrsReactComponent(${n.featureName})`,i in r?Object.defineProperty(r,i,{value:s,enumerable:!0,configurable:!0,writable:!0}):r[i]=s,o}}function dT(e,n){return function(e){if("object"!==dg(e))throw Error("single-spa-react requires a configuration object");var n,t=dh(dh({},dv),e);if(!t.React)throw Error("single-spa-react must be passed opts.React");if(!t.ReactDOM&&!t.ReactDOMClient)throw Error("single-spa-react must be passed opts.ReactDOM or opts.ReactDOMClient");if(t.renderType||(null!=(n=t.ReactDOMClient)&&n.createRoot?t.renderType="createRoot":t.renderType="render"),!t.rootComponent&&!t.loadRootComponent)throw Error("single-spa-react must be passed opts.rootComponent or opts.loadRootComponent");if(t.errorBoundary&&"function"!=typeof t.errorBoundary)throw Error("The errorBoundary opt for single-spa-react must either be omitted or be a function that returns React elements");!d_&&t.React.createContext&&(d_=t.React.createContext()),t.SingleSpaRoot=function(e){function n(e){n.displayName="SingleSpaRoot(".concat(e.name,")")}return n.prototype=Object.create(e.React.Component.prototype),n.prototype.componentDidMount=function(){setTimeout(this.props.mountFinished)},n.prototype.componentWillUnmount=function(){setTimeout(this.props.unmountFinished)},n.prototype.render=function(){return setTimeout(this.props.updateFinished),this.props.children},n}(t);var a={bootstrap:d$.bind(null,t),mount:dA.bind(null,t),unmount:dk.bind(null,t)};return t.parcelCanUpdate&&(a.update=dw.bind(null,t)),a}({React:u7(),ReactDOMClient:df,rootComponent:dP(n)(e)})}function dB(e,n){return()=>e().then(({default:e})=>dT(e,n))}function dI(e,n){return()=>Promise.resolve(dT(e,n))}let dN=dB,dj=L()(()=>({}));U("openmrs-app-context",dj);let dR={};function dF(e,n=e=>e){let t=dj.getState();return e in t?Object.freeze(Object.assign({},n?n(t[e]):t[e])):null}function dL(e,n){dj.setState(t=>(e in t||(t[e]={}),t[e]=n(t[e]),Object.assign({},t)))}function dW(e){return null===e?null:Object.freeze(Object.assign({},e))}let dG=new Map;function dV(e,n){let t=(0,u8.useRef)(n??{}),a=(0,u8.useRef)(n=>dL(e,n)),o=(0,u8.useRef)(Symbol());return(0,u8.useEffect)(()=>{let t=n??{},a=o.current;return null===dF(e)?!function(e,n=dR){dj.setState(t=>{if(e in t)throw Error(`Attempted to re-register namespace ${e} in the app context. Each namespace must be unregistered before the name can be registered again.`);return Object.assign({},t,{[e]:n===dR?{}:n})})}(e,t):(console.warn(`Namespace ${e} is already registered in the app context. This is likely a race condition during navigation, but may indicate two components are trying to own the same namespace. Updating the existing context.`),dL(e,()=>t)),dG.set(e,a),()=>{dG.get(e)===a&&(dj.setState(n=>(e in n&&delete n[e],n)),dG.delete(e))}},[e]),(0,u8.useEffect)(()=>{let a=n??{};N(t.current,a)||(dL(e,()=>a),t.current=a)},[n]),a.current}function dU({namespace:e,value:n}){return dV(e,n),null}let dq=({children:e,value:n,fallback:t})=>n?u7().createElement(u7().Fragment,null,e):t?u7().createElement(u7().Fragment,null,t):null;function dH(){let e=(0,u8.useRef)();return(!e.current||e.current.signal.aborted)&&(e.current=new AbortController),(0,u8.useEffect)(()=>{let n=e.current;return()=>n?.abort()},[]),e.current}function dK(e,n=e=>e??{}){let[t,a]=(0,u8.useState)(()=>{if(dY(e))return;let t=dF(e);if(null!==t)return n?n(t):t});return(0,u8.useEffect)(()=>{if(dY(e))throw Error(`The namespace supplied to useAppContext must be a non-empty string, but was "${e}".`)},[e]),(0,u8.useEffect)(()=>{var t;let o;return(t=e=>{if(null==e)return void a(void 0);let t=n?n(e):e;a(e=>N(e,t)?e:t)})(dW(o=dF(e))),dj.subscribe(n=>{let a=e in n?n[e]:null;a!==o&&(o=a,t(dW(a)))})},[e,n]),t}function dY(e){return"string"!=typeof e||0===e.trim().length}function dJ(e){let[n,t]=(0,u8.useState)([]);return(0,u8.useEffect)(()=>uy().subscribe(a=>{let o=a.slots[e]?.assignedExtensions.map(e=>e.id)??[];ne(o,n)||t(o)}),[]),n}function dZ(e,n){let{data:t,error:a,mutate:o,isLoading:r,isValidating:i}=(0,dS.Ay)(`${r9}?patient=${e}&includeEncounterless=${n}`,o_);return(0,u8.useMemo)(()=>({isLoading:r,data:t?.data.results??[],error:a,mutate:o,isValidating:i}),[t,a,r,i,o])}function dX(e){(0,u8.useEffect)(()=>{if(e){let e=window.getComputedStyle(document.body).overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=e}}},[e])}let dQ={},d0=`No ComponentContext has been provided. This should come from "openmrsComponentDecorator".