@openmrs/esm-user-onboarding-app 4.1.1-pre.607 → 4.1.1-pre.611
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/5995.js
CHANGED
|
@@ -9,7 +9,7 @@ If you're the maintainer: the allowed types are ${Object.values(ry).join(", ")}.
|
|
|
9
9
|
If you're the maintainer: all config elements must have a default. Received ${JSON.stringify(i)}`),s&&l&&![ry.Array,ry.Object].includes(l)&&console.error(`${e} has bad config schema definition for key '${a}'. ${r}.
|
|
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 rZ(e,n){return r0(n.map(({[e]:n})=>n).filter(e=>!!e))}function r0(e){return e.reduce((e,n)=>rB(e,n),{})}function r1(e,n,t=""){for(let r of Object.keys(n)){let o=n[r],a=t+"."+r,i=e[r];if(!e.hasOwnProperty(r)){("extensionSlots"!==r||""===t)&&r9(a,`Unknown config key '${a}' provided. Ignoring.`);continue}(function e(n,t,r){r3(r,n._type,t),r8(t)?n._type===ry.Object?function(n,t,r){if(n._elements)for(let o of Object.keys(t)){let a=t[o];e(n._elements,a,`${r}.${o}`)}}(n,t,r):n.hasOwnProperty("_default")||n.hasOwnProperty("_type")||r1(n,t,r):n._type===ry.Array&&function(n,t,r){if(r3(r,ry.Array,t)){if(r6(n._elements))for(let o=0;o<t.length;o++)e(n._elements,t[o],`${r}[${o}]`);for(let e=0;e<t.length;e++)r3(`${r}[${e}]`,n._elements?._type,t[e])}}(n,t,r)})(i,o,a)}}rL();function r2(e,n,t=""){if(e){if(n!==e._default&&r4(t,e._validators,n),r8(n))for(let r of Object.keys(n)){let o=n[r],a=t+"."+r,i=e[r];e._type===ry.Object&&e._elements?r2(e._elements,o,a):r2(i,o,a)}else if(Array.isArray(n)&&e._elements)for(let r=0;r<n.length;r++)r2(e._elements,n[r],`${t}[${r}]`)}}function r3(e,n,t){return!n||r4(e,[{Array:rv,Boolean:r$,ConceptUuid:rk,Number:rA,Object:rx,String:rw,UUID:rk,PersonAttributeTypeUuid:rk,PatientIdentifierTypeUuid:rk}[n]],t)}function r4(e,n,t){let r=!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}`;r9(e,o),r=!1}}}catch(n){console.error(`Skipping invalid validator at "${e}". Encountered error
|
|
12
|
-
${n}`)}return r}let r5=(e,n)=>{let t=structuredClone(n);if(!e)return t;for(let n of Object.keys(e)){let r=t[n],o=e[n];if(o&&(o.hasOwnProperty("_type")||o.hasOwnProperty("_default"))){t.hasOwnProperty(n)||(t[n]=o._default);let e=o._elements;if(r&&r6(e)){if(o._type===ry.Array&&Array.isArray(r)){let o=r.map(n=>r5(e,n));t[n]=o}else if(o._type===ry.Object)for(let n of Object.keys(r))r[n]=r5(e,r[n])}}else if(r8(o)){let e=r??{};r8(e)&&(t[n]=r5(o,e))}}return t};function r6(e){return!!e&&Object.keys(e).filter(e=>!["_default","_validators"].includes(e)).length>0}function r8(e){return"object"==typeof e&&!Array.isArray(e)&&null!==e}let r7=new Set;function r9(e,n){let t=`${e}:::${n}`;r7||(r7=new Set),r7.has(t)||(console.error(n),r7.add(t))}function oe(e){e?r7.forEach(n=>{n.startsWith(e)&&r7.delete(n)}):r7.clear()}function on(){rR.forEach(e=>e()),rR.length=0,rL()}let ot={"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:ry.Object,_default:{},_validators:[r_(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(", ")}.`})]}},or={"Display conditions":{privileges:{_description:"The privilege(s) the user must have to use this extension",_type:ry.Array,_default:[]},expression:{_description:"The expression that determines whether the extension is displayed",_type:ry.String,_default:void 0}},...ot},oo=(e,n)=>r_(t=>e<=t&&t<=n,`must be between ${e} and ${n}`),oa=e=>{let n=e.concat(["openmrsBase","openmrsSpaBase"]);return r_(e=>{if(!e||"string"!=typeof e)return!1;let t=/\${(.*?)}/g,r=t.exec(e);for(;r;){if(!n.includes(r[1]))return!1;r=t.exec(e)}return!0},"Should be a URL or path. The allowed template parameters are "+n.map(e=>"${"+e+"}").join(", "))},oi=oa([]),os=e=>r_(n=>e.includes(n),`Must be one of the following: '${e.join("', '")}'.`),ol={inRange:oo,isUrl:oi,isUrlWithTemplateParameters:oa,oneOf:os};var oc=t(8067);let ou=G("breadcrumbs",[]);function op(e){return od([e])}function od(e){let n=[...of(),...e.map(e=>({matcher:e.matcher instanceof RegExp?e.matcher:"string"==typeof e.matcher?(0,oc.pathToRegexp)(e.matcher).regexp:(0,oc.pathToRegexp)(e.path).regexp,settings:e}))];ou.setState(n,!0)}function of(){return ou.getState()}function oh(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=oh(e,t.join("/"));if(n)return n}}(e,n)}function og(e,n){if(e.length>0){let t=oh(e,n);if(t){let n=[t],r=oh(e,t.settings.parent);for(;void 0!==r;)n.push(r),r=oh(e,r.settings.parent);return n.reverse()}}return[]}function om(e){return og(of(),e)}var ob=Object.freeze({__proto__:null,get start(){return aL},get ensureJQuerySupport(){return am},get setBootstrapMaxTime(){return o8},get setMountMaxTime(){return o7},get setUnmountMaxTime(){return o9},get setUnloadMaxTime(){return ae},get registerApplication(){return aE},get unregisterApplication(){return aD},get getMountedApps(){return aw},get getAppStatus(){return ak},get unloadApplication(){return az},get checkActivityFunctions(){return aS},get getAppNames(){return ax},get pathToActiveWhen(){return aP},get navigateToUrl(){return as},get patchHistoryApi(){return af},get triggerAppChange(){return aN},get addErrorHandler(){return oA},get removeErrorHandler(){return ow},get mountRootParcel(){return o2},get NOT_LOADED(){return oC},get LOADING_SOURCE_CODE(){return oE},get NOT_BOOTSTRAPPED(){return oS},get BOOTSTRAPPING(){return oD},get NOT_MOUNTED(){return oz},get MOUNTING(){return oM},get UPDATING(){return oP},get LOAD_ERROR(){return oj},get MOUNTED(){return oO},get UNLOADING(){return oI},get UNMOUNTING(){return oT},get SKIP_BECAUSE_BROKEN(){return oN}}),oy=("u">typeof globalThis?globalThis:"u">typeof window?window:"u">typeof global?global:"u">typeof self?self:{}).CustomEvent,o_=!function(){try{var e=new oy("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}:oy;let ov=[];function o$(e,n,t){let r=ok(e,n,t);ov.length?ov.forEach(e=>e(r)):setTimeout(()=>{throw r})}function oA(e){if("function"!=typeof e)throw Error(ox(28,!1));ov.push(e)}function ow(e){if("function"!=typeof e)throw Error(ox(29,!1));let n=!1;return ov=ov.filter(t=>{let r=t===e;return n=n||r,!r}),n}function ox(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 ok(e,n,t){let r,o=`${oW(n)} '${oF(n)}' died in status ${n.status}: `;if(e instanceof Error){try{e.message=o+e.message}catch(e){}r=e}else{console.warn(ox(30,!1,n.status,oF(n)));try{r=Error(o+JSON.stringify(e))}catch(n){r=e}}return r.appOrParcelName=oF(n),n.status=t,r}let oC="NOT_LOADED",oE="LOADING_SOURCE_CODE",oS="NOT_BOOTSTRAPPED",oD="BOOTSTRAPPING",oz="NOT_MOUNTED",oM="MOUNTING",oO="MOUNTED",oP="UPDATING",oT="UNMOUNTING",oI="UNLOADING",oj="LOAD_ERROR",oN="SKIP_BECAUSE_BROKEN";function oB(e){return e.status===oO}function oR(e){try{return e.activeWhen(window.location)}catch(n){return o$(n,e,oN),!1}}function oF(e){return e.name}function oL(e){return!!e.unmountThisParcel}function oW(e){return oL(e)?"parcel":"application"}function oV(){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 oG(e,n){for(let t=0;t<e.length;t++)if(n(e[t]))return e[t];return null}function oH(e){return e&&("function"==typeof e||Array.isArray(e)&&!oG(e,e=>"function"!=typeof e))}function oU(e,n){let t=e[n]||[];0===(t=Array.isArray(t)?t:[t]).length&&(t=[()=>Promise.resolve()]);let r=oW(e),o=oF(e);return function(e){return t.reduce((t,a,i)=>t.then(()=>{let t=a(e);return oq(t)?t:Promise.reject(ox(15,!1,r,o,n,i))}),Promise.resolve())}}function oq(e){return e&&"function"==typeof e.then&&"function"==typeof e.catch}let oK=[];function oY(e,n){return Promise.resolve().then(()=>e.status!==oS?e:(e.status=oD,e.bootstrap?an(e,"bootstrap").then(t).catch(t=>{if(n)throw ok(t,e,oN);return o$(t,e,oN),e}):Promise.resolve().then(t)));function t(){return e.status=oz,e}}function oJ(e,n){return Promise.resolve().then(()=>{if(e.status!==oO)return e;return e.status=oT,Promise.all(Object.keys(e.parcels).map(n=>e.parcels[n].unmountThisParcel())).then(t,r=>t().then(()=>{let t=Error(r.message);if(n)throw ok(t,e,oN);o$(t,e,oN)})).then(()=>e);function t(){return an(e,"unmount").then(()=>{e.status=oz},t=>{if(n)throw ok(t,e,oN);o$(t,e,oN)})}})}let oQ=!1,oX=!1;function oZ(e,n){return Promise.resolve().then(()=>e.status!==oz?e:(oQ||(window.dispatchEvent(new o_("single-spa:before-first-mount")),oQ=!0),e.status=oM,an(e,"mount").then(()=>(e.status=oO,oX||(window.dispatchEvent(new o_("single-spa:first-mount")),oX=!0),e)).catch(t=>{return e.status=oO,oJ(e,!0).then(r,r);function r(){if(n)throw ok(t,e,oN);return o$(t,e,oN),e}})))}let o0=0,o1={parcels:{}};function o2(){return o3.apply(o1,arguments)}function o3(e,n){let t,r,o,a=this;if(!e||"object"!=typeof e&&"function"!=typeof e)throw Error(ox(2,!1));if(e.name&&"string"!=typeof e.name)throw Error(ox(3,!1,typeof e.name));let i=o0++,s=e.name||`parcel-${i}`;if("object"!=typeof n)throw Error(ox(4,!1,s,typeof n));if(!n.domElement)throw Error(ox(5,!1,s));let l="function"==typeof e,c=l?e:()=>Promise.resolve(e),u={id:i,parcels:{},status:l?oE:oS,customProps:n,parentName:oF(a),unmountThisParcel:()=>f.then(()=>{if(u.status!==oO)throw Error(ox(6,!1,s,u.status));return oJ(u,!0)}).then(e=>(u.parentName&&delete a.parcels[u.id],e)).then(e=>(r(e),e)).catch(e=>{throw u.status=oN,o(e),e})};a.parcels[i]=u;let p=c();if(!p||"function"!=typeof p.then)throw Error(ox(7,!1));let d=(p=p.then(e=>{if(!e)throw Error(ox(8,!1));if(s=e.name||`parcel-${i}`,Object.prototype.hasOwnProperty.call(e,"bootstrap")&&!oH(e.bootstrap))throw Error(ox(9,!1,s));if(!oH(e.mount))throw Error(ox(10,!1,s));if(!oH(e.unmount))throw Error(ox(11,!1,s));if(e.update&&!oH(e.update))throw Error(ox(12,!1,s));let n=oU(e,"bootstrap"),r=oU(e,"mount"),o=oU(e,"unmount");u.status=oS,u.name=s,u.bootstrap=n,u.mount=r,u.unmount=o,u.timeouts=at(e.timeouts),e.update&&(u.update=oU(e,"update"),t.update=function(e){return u.customProps=e,o4(Promise.resolve().then(()=>{if(u.status!==oO)throw Error(ox(32,!1,oF(u)));return u.status=oP,an(u,"update").then(()=>(u.status=oO,u)).catch(e=>{throw ok(e,u,oN)})}))})})).then(()=>oY(u,!0)),f=d.then(()=>oZ(u,!0)),h=new Promise((e,n)=>{r=e,o=n});return t={mount:()=>o4(Promise.resolve().then(()=>{if(u.status!==oz)throw Error(ox(13,!1,s,u.status));return a.parcels[i]=u,oZ(u)})),unmount:()=>o4(u.unmountThisParcel()),getStatus:()=>u.status,loadPromise:o4(p),bootstrapPromise:o4(d),mountPromise:o4(f),unmountPromise:o4(h)}}function o4(e){return e.then(()=>null)}function o5(e){let n=oF(e),t="function"==typeof e.customProps?e.customProps(n,window.location):e.customProps;("object"!=typeof t||null===t||Array.isArray(t))&&(t={},console.warn(ox(40,!1),n,t));let r=oV({},t,{name:n,mountParcel:o3.bind(e),singleSpa:ob});return oL(e)&&(r.unmountSelf=e.unmountThisParcel),r}let o6={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 o8(e,n,t){if("number"!=typeof e||e<=0)throw Error(ox(16,!1));o6.bootstrap={millis:e,dieOnTimeout:n,warningMillis:t||1e3}}function o7(e,n,t){if("number"!=typeof e||e<=0)throw Error(ox(17,!1));o6.mount={millis:e,dieOnTimeout:n,warningMillis:t||1e3}}function o9(e,n,t){if("number"!=typeof e||e<=0)throw Error(ox(18,!1));o6.unmount={millis:e,dieOnTimeout:n,warningMillis:t||1e3}}function ae(e,n,t){if("number"!=typeof e||e<=0)throw Error(ox(19,!1));o6.unload={millis:e,dieOnTimeout:n,warningMillis:t||1e3}}function an(e,n){let t=e.timeouts[n],r=t.warningMillis,o=oW(e);return new Promise((a,i)=>{let s=!1,l=!1;e[n](o5(e)).then(e=>{s=!0,a(e)}).catch(e=>{s=!0,i(e)}),setTimeout(()=>u(1),r),setTimeout(()=>u(!0),t.millis);let c=ox(31,!1,n,o,oF(e),t.millis);function u(e){s||(!0===e?(l=!0,t.dieOnTimeout?i(Error(c)):console.error(c)):!l&&(console.warn(c),e*r+r<t.millis&&setTimeout(()=>u(e+1),r)))}})}function at(e){let n={};for(let t in o6)n[t]=oV({},o6[t],e&&e[t]||{});return n}function ar(e){return Promise.resolve().then(()=>{let n,t;return e.loadPromise?e.loadPromise:e.status!==oC&&e.status!==oj?e:(e.status=oE,e.loadPromise=Promise.resolve().then(()=>{let r=e.loadApp(o5(e));if(!oq(r))throw t=!0,Error(ox(33,!1,oF(e)));return r.then(t=>{let r;e.loadErrorTime=null,"object"!=typeof(n=t)&&(r=34),Object.prototype.hasOwnProperty.call(n,"bootstrap")&&!oH(n.bootstrap)&&(r=35),oH(n.mount)||(r=36),oH(n.unmount)||(r=37);let o=oW(n);if(r){let t;try{t=JSON.stringify(n)}catch(e){}return console.error(ox(r,!1,o,oF(e),t),n),o$(void 0,e,oN),e}return n.devtools&&n.devtools.overlays&&(e.devtools.overlays=oV({},e.devtools.overlays,n.devtools.overlays)),e.status=oS,e.bootstrap=oU(n,"bootstrap"),e.mount=oU(n,"mount"),e.unmount=oU(n,"unmount"),e.unload=oU(n,"unload"),e.timeouts=at(n.timeouts),delete e.loadPromise,e})}).catch(n=>{let r;return delete e.loadPromise,t?r=oN:(r=oj,e.loadErrorTime=(new Date).getTime()),o$(n,e,r),e}))})}let ao="u">typeof window,aa={hashchange:[],popstate:[]},ai=["hashchange","popstate"];function as(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(ox(14,!1));n=e.currentTarget.href,e.preventDefault()}let t=ah(window.location.href),r=ah(n);0===n.indexOf("#")?window.location.hash=r.hash:t.host!==r.host&&r.host?window.location.href=n:r.pathname===t.pathname&&r.search===t.search?window.location.hash=r.hash:window.history.pushState(null,null,n)}function al(e){if(e){let n=e[0].type;ai.indexOf(n)>=0&&aa[n].forEach(n=>{try{n.apply(this,e)}catch(e){setTimeout(()=>{throw e})}})}}function ac(){aB([],arguments)}function au(e,n){return function(){let t=window.location.href,o=e.apply(this,arguments),a=window.location.href;return r&&t===a||window.dispatchEvent(function(e,n){let t;try{t=new PopStateEvent("popstate",{state:e})}catch(n){(t=document.createEvent("PopStateEvent")).initPopStateEvent("popstate",!1,!1,e)}return t.singleSpa=!0,t.singleSpaTrigger=n,t}(window.history.state,n)),o}}let ap=null,ad=!1;function af(e){if(ad)throw Error(ox(43,!1));r=!e||!e.hasOwnProperty("urlRerouteOnly")||e.urlRerouteOnly,ad=!0,ap=window.history.replaceState,window.addEventListener("hashchange",ac),window.addEventListener("popstate",ac);let n=window.addEventListener,t=window.removeEventListener;window.addEventListener=function(e,t){if(!("function"==typeof t&&ai.indexOf(e)>=0)||oG(aa[e],e=>e===t))return n.apply(this,arguments);aa[e].push(t)},window.removeEventListener=function(e,n){return"function"==typeof n&&ai.indexOf(e)>=0&&(aa[e]=aa[e].filter(e=>e!==n)),t.apply(this,arguments)},window.history.pushState=au(window.history.pushState,"pushState"),window.history.replaceState=au(ap,"replaceState")}function ah(e){let n=document.createElement("a");return n.href=e,n}ao&&(window.singleSpaNavigate?console.warn(ox(41,!1)):window.singleSpaNavigate=as);let ag=!1;function am(e=window.jQuery){if(e||window.$&&window.$.fn&&window.$.fn.jquery&&(e=window.$),e&&!ag){let n=e.fn.on,t=e.fn.off;e.fn.on=function(e,t){return ab.call(this,n,window.addEventListener,e,t,arguments)},e.fn.off=function(e,n){return ab.call(this,t,window.removeEventListener,e,n,arguments)},ag=!0}}function ab(e,n,t,r,o){return"string"!=typeof t?e.apply(this,o):(t.split(/\s+/).forEach(e=>{ai.indexOf(e)>=0&&(n(e,r),t=t.replace(e,""))}),""===t.trim()?this:e.apply(this,o))}let ay={};function a_(e){return Promise.resolve().then(()=>{let n=ay[oF(e)];if(!n)return e;if(e.status===oC)return av(e,n),e;if(e.status===oI)return n.promise.then(()=>e);if(e.status!==oz&&e.status!==oj)return e;let t=e.status===oj?Promise.resolve():an(e,"unload");return e.status=oI,t.then(()=>(av(e,n),e)).catch(t=>(delete ay[oF(e)],delete e.bootstrap,delete e.mount,delete e.unmount,delete e.unload,o$(t,e,oN),n.reject(t),e))})}function av(e,n){delete ay[oF(e)],delete e.bootstrap,delete e.mount,delete e.unmount,delete e.unload,e.status=oC,n.resolve()}function a$(e,n,t,r){ay[oF(e)]={app:e,resolve:t,reject:r},Object.defineProperty(ay[oF(e)],"promise",{get:n})}let aA=[];function aw(){return aA.filter(oB).map(oF)}function ax(){return aA.map(oF)}function ak(e){let n=oG(aA,n=>oF(n)===e);return n?n.status:null}let aC=!1;function aE(e,n,t,r){var o,a;let i,s,l=(i={name:null,loadApp:null,activeWhen:null,customProps:null},"object"==typeof e?(function(e){if(Array.isArray(e)||null===e)throw Error(ox(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(ox(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(ox(20,!1));let r=e=>"string"==typeof e||"function"==typeof e;if(!(r(e.activeWhen)||Array.isArray(e.activeWhen)&&e.activeWhen.every(r)))throw Error(ox(24,!1));if(!aO(e.customProps))throw Error(ox(22,!1))}(e),i.name=e.name,i.loadApp=e.app,i.activeWhen=e.activeWhen,i.customProps=e.customProps):(function(e,n,t,r){if("string"!=typeof e||0===e.length)throw Error(ox(20,!1));if(!n)throw Error(ox(23,!1));if("function"!=typeof t)throw Error(ox(24,!1));if(!aO(r))throw Error(ox(22,!1))}(e,n,t,r),i.name=e,i.loadApp=n,i.activeWhen=t,i.customProps=r),i.loadApp="function"!=typeof(o=i.loadApp)?()=>Promise.resolve(o):o,i.customProps=i.customProps||{},s=(s=Array.isArray(a=i.activeWhen)?a:[a]).map(e=>"function"==typeof e?e:aP(e)),i.activeWhen=e=>s.some(n=>n(e)),i);if(aF||aC||(aC=!0,setTimeout(()=>{aF||console.warn(ox(1,!1))},5e3)),-1!==ax().indexOf(l.name))throw Error(ox(21,!1,l.name));aA.push(oV({loadErrorTime:null,status:oC,parcels:{},devtools:{overlays:{options:{},selectors:[]}}},l)),ao&&(am(),aB())}function aS(e=window.location){return aA.filter(n=>n.activeWhen(e)).map(oF)}function aD(e){if(0===aA.filter(n=>oF(n)===e).length)throw Error(ox(25,!1,e));return(ao?az(e,{waitForUnmount:!1}):Promise.resolve()).then(()=>{let n=aA.map(oF).indexOf(e);aA.splice(n,1)})}function az(e,n={waitForUnmount:!1}){if("string"!=typeof e)throw Error(ox(26,!1));let t=oG(aA,n=>oF(n)===e);if(!t)throw Error(ox(27,!1,e));let r=ay[oF(t)];if(n&&n.waitForUnmount){if(r)return r.promise;{let e=new Promise((n,r)=>{a$(t,()=>e,n,r)});return e}}{let e;return r?(e=r.promise,aM(t,r.resolve,r.reject)):e=new Promise((n,r)=>{a$(t,()=>e,n,r),aM(t,n,r)}),e}}function aM(e,n,t){Promise.resolve().then(()=>{if(oG(aS(),n=>n===oF(e)))return aN()}).then(()=>oJ(e).then(a_).then(()=>{n(),setTimeout(()=>{aB()})})).catch(t)}function aO(e){return!e||"function"==typeof e||"object"==typeof e&&null!==e&&!Array.isArray(e)}function aP(e,n){let t=function(e,n){let t=0,r=!1,o="^";"/"!==e[0]&&(e="/"+e);for(let n=0;n<e.length;n++){let t=e[n],o=r&&"/"===t;(!r&&":"===t||o)&&a(n)}return a(e.length),RegExp(o,"i");function a(a){let i=e.slice(t,a).replace(/[|\\{}()[\]^$+*?.]/g,"\\$&");if(o+=r?"[^/]+/?":i,a===e.length)if(r)n&&(o+="$");else{let e=n?"":".*";o="/"===o.charAt(o.length-1)?`${o}${e}$`:`${o}(/${e})?(#.*)?$`}r=!r,t=a}}(e,n);return e=>{let n=e.origin;n||(n=`${e.protocol}//${e.host}`);let r=e.href.replace(n,"").replace(e.search,"").split("?")[0];return t.test(r)}}let aT=!1,aI=[],aj=ao&&window.location.href;function aN(){return aB()}function aB(e=[],n,t=!1){let r,o,a,i,s;if(aT)return new Promise((e,t)=>{aI.push({resolve:e,reject:t,eventArguments:n})});let{appsToUnload:l,appsToUnmount:c,appsToLoad:u,appsToMount:p}=(r=[],o=[],a=[],i=[],s=(new Date).getTime(),aA.forEach(e=>{let n=e.status!==oN&&oR(e);switch(e.status){case oj:n&&s-e.loadErrorTime>=200&&a.push(e);break;case oC:case oE:n&&a.push(e);break;case oS:case oz:!n&&ay[oF(e)]?r.push(e):n&&i.push(e);break;case oO:n||o.push(e)}}),{appsToUnload:r,appsToUnmount:o,appsToLoad:a,appsToMount:i}),d,f=[],h=aj,g=aj=window.location.href;return aF?(aT=!0,d=l.concat(u,c,p),Promise.resolve().then(()=>($(0===d.length?"before-no-app-change":"before-app-change",v(!0)),$("before-routing-event",v(!0,{cancelNavigation:m})),Promise.all(f).then(t=>{if(t.some(e=>e))return ap.call(window.history,history.state,"",h.substring(location.origin.length)),aj=location.href,aT=!1,aB(e,n,!0);let r=l.map(a_),o=Promise.all(c.map(oJ).map(e=>e.then(a_)).concat(r));o.then(()=>{$("before-mount-routing-event",v(!0))},e=>{throw e});let a=u.map(e=>ar(e).then(e=>aR(e,o))),i=p.filter(e=>0>u.indexOf(e)).map(e=>aR(e,o));return o.catch(e=>{throw y(),e}).then(()=>(y(),Promise.all(a.concat(i)).catch(n=>{throw e.forEach(e=>e.reject(n)),n}).then(b).then(()=>{},e=>{throw e})))})))):(d=u,Promise.resolve().then(()=>Promise.all(u.map(ar)).then(y).then(()=>[]).catch(e=>{throw y(),e}).finally(()=>{})));function m(e=!0){let n="function"==typeof(null==e?void 0:e.then)?e:Promise.resolve(e);f.push(n.catch(e=>(console.warn(Error(ox(42,!1))),console.warn(e),!1)))}function b(){let n=aw();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(aT=!1,aI.length>0){let e=aI;aI=[],aB(e)}return n}function y(){t||(e.forEach(e=>{al(e.eventArguments)}),al(n))}function v(e=!1,t){let r={},o={[oO]:[],[oz]:[],[oC]:[],[oN]:[]};e?(u.concat(p).forEach((e,n)=>{i(e,oO)}),l.forEach(e=>{i(e,oC)}),c.forEach(e=>{i(e,oz)})):d.forEach(e=>{i(e)});let a={detail:{newAppStatuses:r,appsByNewStatus:o,totalAppChanges:d.length,originalEvent:null==n?void 0:n[0],oldUrl:h,newUrl:g}};return t&&oV(a.detail,t),a;function i(e,n){let t=oF(e);n=n||ak(t),r[t]=n,(o[n]=o[n]||[]).push(t)}}function $(e,n){t||window.dispatchEvent(new o_(`single-spa:${e}`,n))}}function aR(e,n){return oR(e)?oY(e).then(e=>n.then(()=>oR(e)?oZ(e):e)):n.then(()=>e)}let aF=!1;function aL(e){aF=!0,ao&&(af(e),aB())}function aW(e,n){let t=window.getOpenmrsSpaBase().replace(/\/$/,"");return aV(e,{openmrsBase:window.openmrsBase,openmrsSpaBase:t,...n}).replace(/^\/\//,"/")}function aV(e,n){return Object.keys(n).reduce((e,t)=>e.split("${"+t+"}").join(n[t]),e)}function aG({to:e,templateParams:n}){let t=window.getOpenmrsSpaBase().replace(/\/$/,""),r=aW(e,n).replace(window.location.origin,"");r.startsWith(t)?as(r):window.location.assign(r)}ao&&window.__SINGLE_SPA_DEVTOOLS__&&(window.__SINGLE_SPA_DEVTOOLS__.exposedMethods={getRawAppData:function(){return[...aA]},reroute:aB,NOT_LOADED:oC,toLoadPromise:ar,toBootstrapPromise:oY,unregisterApplication:aD,getProfilerData:function(){return oK}});let aH="openmrs:history";function aU(e){let n=JSON.parse(sessionStorage.getItem(aH)??"[]")||[];n.push(e),n.length>50&&(n=n.slice(-50)),sessionStorage.setItem(aH,JSON.stringify(n))}function aq(){0===JSON.parse(sessionStorage.getItem(aH)??"[]").length&&document.referrer&&aU(document.referrer),window.addEventListener("single-spa:routing-event",e=>{let n=aK();e.detail.originalEvent?.singleSpaTrigger=="replaceState"?(n[n.length-1]=window.location.href,sessionStorage.setItem(aH,JSON.stringify(n))):!e.detail.originalEvent?.singleSpa&&n.includes(window.location.href)?aY({toUrl:window.location.href}):n[n.length-1]!==window.location.href&&aU(window.location.href)})}function aK(){return JSON.parse(sessionStorage.getItem(aH)??"[]")}function aY({toUrl:e}){let n=aK(),t=n.lastIndexOf(e);if(-1!=t){let e=n.slice(0,t+1);aG({to:n[t]}),sessionStorage.setItem(aH,JSON.stringify(e))}else throw Error(`URL ${e} not found in history; cannot go back to it.`)}function aJ(){sessionStorage.removeItem(aH)}let aQ="${openmrsSpaBase}/login",aX={redirectAuthFailure:{enabled:{_type:ry.Boolean,_default:!0,_description:"Whether to redirect logged-out users to `redirectAuthFailure.url`"},url:{_type:ry.String,_default:aQ,_validators:[ol.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:ry.Array,_default:[401],_elements:{_type:ry.Number,_validators:[ol.inRange(100,600)]},_description:"The HTTP error codes for which users will be redirected"},resolvePromise:{_type:ry.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:ry.Boolean,_default:!0,_description:"Whether openmrsFetch should support redirects returned from the backend"}};function aZ(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}let a0="/ws/rest/v1",a1="/ws/fhir2/R4",a2=`${a0}/session`;function a3(e){return e&&e.startsWith("http")?e:("/"!==e[0]&&(e="/"+e),window.openmrsBase+e)}function a4(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=a3(e);if(n.headers||(n.headers={}),eM(n.body)&&(n.body=JSON.stringify(n.body)),void 0===n.headers.Accept&&(n.headers.Accept="application/json"),null===n.headers.Accept&&delete n.headers.Accept,e.startsWith(a0)&&void 0===n.headers["Disable-WWW-Authenticate"]&&(n.headers["Disable-WWW-Authenticate"]="true"),e.startsWith(a1)){let e=new URL(t,window.location.toString());e.searchParams.has("_summary")||(e.searchParams.set("_summary","data"),t=e.toString())}let r=Error();return window.fetch(t,n).then(async e=>{let{redirectAuthFailure:n,followRedirects:o}=await rK("@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&&aG({to:n})}return e.data=null,e}return t===a3(a2)&&403===e.status||n.enabled&&n.errors.includes(e.status)?(aJ(),aG({to:n.url||e.headers.get("location")||aQ}),n.resolvePromise?Promise.resolve():new Promise(()=>{})):e.clone().text().then(n=>{let o=n;try{o=JSON.parse(n)}catch(e){}throw new a6(t,e,o,r)},n=>{throw new a6(t,e,null,r)})})}function a5(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 ep.Observable(r=>{let o=!1;return a4(e,n).then(e=>{o=!0,r.next(e),r.complete()},e=>{o=!0,r.error(e)}),()=>{o||t.abort()}})}class a6 extends Error{constructor(e,n,t,r){super(),aZ(this,"response",void 0),aZ(this,"responseBody",void 0),this.message=`Server responded with ${n.status} (${n.statusText}) for url ${e}. Check err.responseBody or network tab in dev tools for more info`,r.message=this.message,this.responseBody=t,this.response=n,this.stack=`Stacktrace for outgoing request:
|
|
12
|
+
${n}`)}return r}let r5=(e,n)=>{let t=structuredClone(n);if(!e)return t;for(let n of Object.keys(e)){let r=t[n],o=e[n];if(o&&(o.hasOwnProperty("_type")||o.hasOwnProperty("_default"))){t.hasOwnProperty(n)||(t[n]=o._default);let e=o._elements;if(r&&r6(e)){if(o._type===ry.Array&&Array.isArray(r)){let o=r.map(n=>r5(e,n));t[n]=o}else if(o._type===ry.Object)for(let n of Object.keys(r))r[n]=r5(e,r[n])}}else if(r8(o)){let e=r??{};r8(e)&&(t[n]=r5(o,e))}}return t};function r6(e){return!!e&&Object.keys(e).filter(e=>!["_default","_validators"].includes(e)).length>0}function r8(e){return"object"==typeof e&&!Array.isArray(e)&&null!==e}let r7=new Set;function r9(e,n){let t=`${e}:::${n}`;r7||(r7=new Set),r7.has(t)||(console.error(n),r7.add(t))}function oe(e){e?r7.forEach(n=>{n.startsWith(e)&&r7.delete(n)}):r7.clear()}function on(){rR.forEach(e=>e()),rR.length=0,rL()}let ot={"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:ry.Object,_default:{},_validators:[r_(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(", ")}.`})]}},or={"Display conditions":{privileges:{_description:"The privilege(s) the user must have to use this extension",_type:ry.Array,_default:[]},expression:{_description:"The expression that determines whether the extension is displayed",_type:ry.String,_default:void 0}},...ot},oo=(e,n)=>r_(t=>e<=t&&t<=n,`must be between ${e} and ${n}`),oa=e=>{let n=e.concat(["openmrsBase","openmrsSpaBase"]);return r_(e=>{if(!e||"string"!=typeof e)return!1;let t=/\${(.*?)}/g,r=t.exec(e);for(;r;){if(!n.includes(r[1]))return!1;r=t.exec(e)}return!0},"Should be a URL or path. The allowed template parameters are "+n.map(e=>"${"+e+"}").join(", "))},oi=oa([]),os=e=>r_(n=>e.includes(n),`Must be one of the following: '${e.join("', '")}'.`),ol={inRange:oo,isUrl:oi,isUrlWithTemplateParameters:oa,oneOf:os};var oc=t(8067);let ou=G("breadcrumbs",[]);function op(e){return od([e])}function od(e){let n=[...of(),...e.map(e=>({matcher:e.matcher instanceof RegExp?e.matcher:"string"==typeof e.matcher?(0,oc.pathToRegexp)(e.matcher).regexp:(0,oc.pathToRegexp)(e.path).regexp,settings:e}))];ou.setState(n,!0)}function of(){return ou.getState()}function oh(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=oh(e,t.join("/"));if(n)return n}}(e,n)}function og(e,n){if(e.length>0){let t=oh(e,n);if(t){let n=[t],r=oh(e,t.settings.parent);for(;void 0!==r;)n.push(r),r=oh(e,r.settings.parent);return n.reverse()}}return[]}function om(e){return og(of(),e)}var ob=Object.freeze({__proto__:null,get start(){return aL},get ensureJQuerySupport(){return am},get setBootstrapMaxTime(){return o8},get setMountMaxTime(){return o7},get setUnmountMaxTime(){return o9},get setUnloadMaxTime(){return ae},get registerApplication(){return aE},get unregisterApplication(){return aD},get getMountedApps(){return aw},get getAppStatus(){return ak},get unloadApplication(){return az},get checkActivityFunctions(){return aS},get getAppNames(){return ax},get pathToActiveWhen(){return aP},get navigateToUrl(){return as},get patchHistoryApi(){return af},get triggerAppChange(){return aN},get addErrorHandler(){return oA},get removeErrorHandler(){return ow},get mountRootParcel(){return o2},get NOT_LOADED(){return oC},get LOADING_SOURCE_CODE(){return oE},get NOT_BOOTSTRAPPED(){return oS},get BOOTSTRAPPING(){return oD},get NOT_MOUNTED(){return oz},get MOUNTING(){return oM},get UPDATING(){return oP},get LOAD_ERROR(){return oj},get MOUNTED(){return oO},get UNLOADING(){return oI},get UNMOUNTING(){return oT},get SKIP_BECAUSE_BROKEN(){return oN}}),oy=("u">typeof globalThis?globalThis:"u">typeof window?window:"u">typeof global?global:"u">typeof self?self:{}).CustomEvent,o_=!function(){try{var e=new oy("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}:oy;let ov=[];function o$(e,n,t){let r=ok(e,n,t);ov.length?ov.forEach(e=>e(r)):setTimeout(()=>{throw r})}function oA(e){if("function"!=typeof e)throw Error(ox(28,!1));ov.push(e)}function ow(e){if("function"!=typeof e)throw Error(ox(29,!1));let n=!1;return ov=ov.filter(t=>{let r=t===e;return n=n||r,!r}),n}function ox(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 ok(e,n,t){let r,o=`${oW(n)} '${oF(n)}' died in status ${n.status}: `;if(e instanceof Error){try{e.message=o+e.message}catch(e){}r=e}else{console.warn(ox(30,!1,n.status,oF(n)));try{r=Error(o+JSON.stringify(e))}catch(n){r=e}}return r.appOrParcelName=oF(n),n.status=t,r}let oC="NOT_LOADED",oE="LOADING_SOURCE_CODE",oS="NOT_BOOTSTRAPPED",oD="BOOTSTRAPPING",oz="NOT_MOUNTED",oM="MOUNTING",oO="MOUNTED",oP="UPDATING",oT="UNMOUNTING",oI="UNLOADING",oj="LOAD_ERROR",oN="SKIP_BECAUSE_BROKEN";function oB(e){return e.status===oO}function oR(e){try{return e.activeWhen(window.location)}catch(n){return o$(n,e,oN),!1}}function oF(e){return e.name}function oL(e){return!!e.unmountThisParcel}function oW(e){return oL(e)?"parcel":"application"}function oV(){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 oG(e,n){for(let t=0;t<e.length;t++)if(n(e[t]))return e[t];return null}function oH(e){return e&&("function"==typeof e||Array.isArray(e)&&!oG(e,e=>"function"!=typeof e))}function oU(e,n){let t=e[n]||[];0===(t=Array.isArray(t)?t:[t]).length&&(t=[()=>Promise.resolve()]);let r=oW(e),o=oF(e);return function(e){return t.reduce((t,a,i)=>t.then(()=>{let t=a(e);return oq(t)?t:Promise.reject(ox(15,!1,r,o,n,i))}),Promise.resolve())}}function oq(e){return e&&"function"==typeof e.then&&"function"==typeof e.catch}let oK=[];function oY(e,n){return Promise.resolve().then(()=>e.status!==oS?e:(e.status=oD,e.bootstrap?an(e,"bootstrap").then(t).catch(t=>{if(n)throw ok(t,e,oN);return o$(t,e,oN),e}):Promise.resolve().then(t)));function t(){return e.status=oz,e}}function oJ(e,n){return Promise.resolve().then(()=>{if(e.status!==oO)return e;return e.status=oT,Promise.all(Object.keys(e.parcels).map(n=>e.parcels[n].unmountThisParcel())).then(t,r=>t().then(()=>{let t=Error(r.message);if(n)throw ok(t,e,oN);o$(t,e,oN)})).then(()=>e);function t(){return an(e,"unmount").then(()=>{e.status=oz},t=>{if(n)throw ok(t,e,oN);o$(t,e,oN)})}})}let oQ=!1,oX=!1;function oZ(e,n){return Promise.resolve().then(()=>e.status!==oz?e:(oQ||(window.dispatchEvent(new o_("single-spa:before-first-mount")),oQ=!0),e.status=oM,an(e,"mount").then(()=>(e.status=oO,oX||(window.dispatchEvent(new o_("single-spa:first-mount")),oX=!0),e)).catch(t=>{return e.status=oO,oJ(e,!0).then(r,r);function r(){if(n)throw ok(t,e,oN);return o$(t,e,oN),e}})))}let o0=0,o1={parcels:{}};function o2(){return o3.apply(o1,arguments)}function o3(e,n){let t,r,o,a=this;if(!e||"object"!=typeof e&&"function"!=typeof e)throw Error(ox(2,!1));if(e.name&&"string"!=typeof e.name)throw Error(ox(3,!1,typeof e.name));let i=o0++,s=e.name||`parcel-${i}`;if("object"!=typeof n)throw Error(ox(4,!1,s,typeof n));if(!n.domElement)throw Error(ox(5,!1,s));let l="function"==typeof e,c=l?e:()=>Promise.resolve(e),u={id:i,parcels:{},status:l?oE:oS,customProps:n,parentName:oF(a),unmountThisParcel:()=>f.then(()=>{if(u.status!==oO)throw Error(ox(6,!1,s,u.status));return oJ(u,!0)}).then(e=>(u.parentName&&delete a.parcels[u.id],e)).then(e=>(r(e),e)).catch(e=>{throw u.status=oN,o(e),e})};a.parcels[i]=u;let p=c();if(!p||"function"!=typeof p.then)throw Error(ox(7,!1));let d=(p=p.then(e=>{if(!e)throw Error(ox(8,!1));if(s=e.name||`parcel-${i}`,Object.prototype.hasOwnProperty.call(e,"bootstrap")&&!oH(e.bootstrap))throw Error(ox(9,!1,s));if(!oH(e.mount))throw Error(ox(10,!1,s));if(!oH(e.unmount))throw Error(ox(11,!1,s));if(e.update&&!oH(e.update))throw Error(ox(12,!1,s));let n=oU(e,"bootstrap"),r=oU(e,"mount"),o=oU(e,"unmount");u.status=oS,u.name=s,u.bootstrap=n,u.mount=r,u.unmount=o,u.timeouts=at(e.timeouts),e.update&&(u.update=oU(e,"update"),t.update=function(e){return u.customProps=e,o4(Promise.resolve().then(()=>{if(u.status!==oO)throw Error(ox(32,!1,oF(u)));return u.status=oP,an(u,"update").then(()=>(u.status=oO,u)).catch(e=>{throw ok(e,u,oN)})}))})})).then(()=>oY(u,!0)),f=d.then(()=>oZ(u,!0)),h=new Promise((e,n)=>{r=e,o=n});return t={mount:()=>o4(Promise.resolve().then(()=>{if(u.status!==oz)throw Error(ox(13,!1,s,u.status));return a.parcels[i]=u,oZ(u)})),unmount:()=>o4(u.unmountThisParcel()),getStatus:()=>u.status,loadPromise:o4(p),bootstrapPromise:o4(d),mountPromise:o4(f),unmountPromise:o4(h)}}function o4(e){return e.then(()=>null)}function o5(e){let n=oF(e),t="function"==typeof e.customProps?e.customProps(n,window.location):e.customProps;("object"!=typeof t||null===t||Array.isArray(t))&&(t={},console.warn(ox(40,!1),n,t));let r=oV({},t,{name:n,mountParcel:o3.bind(e),singleSpa:ob});return oL(e)&&(r.unmountSelf=e.unmountThisParcel),r}let o6={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 o8(e,n,t){if("number"!=typeof e||e<=0)throw Error(ox(16,!1));o6.bootstrap={millis:e,dieOnTimeout:n,warningMillis:t||1e3}}function o7(e,n,t){if("number"!=typeof e||e<=0)throw Error(ox(17,!1));o6.mount={millis:e,dieOnTimeout:n,warningMillis:t||1e3}}function o9(e,n,t){if("number"!=typeof e||e<=0)throw Error(ox(18,!1));o6.unmount={millis:e,dieOnTimeout:n,warningMillis:t||1e3}}function ae(e,n,t){if("number"!=typeof e||e<=0)throw Error(ox(19,!1));o6.unload={millis:e,dieOnTimeout:n,warningMillis:t||1e3}}function an(e,n){let t=e.timeouts[n],r=t.warningMillis,o=oW(e);return new Promise((a,i)=>{let s=!1,l=!1;e[n](o5(e)).then(e=>{s=!0,a(e)}).catch(e=>{s=!0,i(e)}),setTimeout(()=>u(1),r),setTimeout(()=>u(!0),t.millis);let c=ox(31,!1,n,o,oF(e),t.millis);function u(e){s||(!0===e?(l=!0,t.dieOnTimeout?i(Error(c)):console.error(c)):!l&&(console.warn(c),e*r+r<t.millis&&setTimeout(()=>u(e+1),r)))}})}function at(e){let n={};for(let t in o6)n[t]=oV({},o6[t],e&&e[t]||{});return n}function ar(e){return Promise.resolve().then(()=>{let n,t;return e.loadPromise?e.loadPromise:e.status!==oC&&e.status!==oj?e:(e.status=oE,e.loadPromise=Promise.resolve().then(()=>{let r=e.loadApp(o5(e));if(!oq(r))throw t=!0,Error(ox(33,!1,oF(e)));return r.then(t=>{let r;e.loadErrorTime=null,"object"!=typeof(n=t)&&(r=34),Object.prototype.hasOwnProperty.call(n,"bootstrap")&&!oH(n.bootstrap)&&(r=35),oH(n.mount)||(r=36),oH(n.unmount)||(r=37);let o=oW(n);if(r){let t;try{t=JSON.stringify(n)}catch(e){}return console.error(ox(r,!1,o,oF(e),t),n),o$(void 0,e,oN),e}return n.devtools&&n.devtools.overlays&&(e.devtools.overlays=oV({},e.devtools.overlays,n.devtools.overlays)),e.status=oS,e.bootstrap=oU(n,"bootstrap"),e.mount=oU(n,"mount"),e.unmount=oU(n,"unmount"),e.unload=oU(n,"unload"),e.timeouts=at(n.timeouts),delete e.loadPromise,e})}).catch(n=>{let r;return delete e.loadPromise,t?r=oN:(r=oj,e.loadErrorTime=(new Date).getTime()),o$(n,e,r),e}))})}let ao="u">typeof window,aa={hashchange:[],popstate:[]},ai=["hashchange","popstate"];function as(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(ox(14,!1));n=e.currentTarget.href,e.preventDefault()}let t=ah(window.location.href),r=ah(n);0===n.indexOf("#")?window.location.hash=r.hash:t.host!==r.host&&r.host?window.location.href=n:r.pathname===t.pathname&&r.search===t.search?window.location.hash=r.hash:window.history.pushState(null,null,n)}function al(e){if(e){let n=e[0].type;ai.indexOf(n)>=0&&aa[n].forEach(n=>{try{n.apply(this,e)}catch(e){setTimeout(()=>{throw e})}})}}function ac(){aB([],arguments)}function au(e,n){return function(){let t=window.location.href,o=e.apply(this,arguments),a=window.location.href;return r&&t===a||window.dispatchEvent(function(e,n){let t;try{t=new PopStateEvent("popstate",{state:e})}catch(n){(t=document.createEvent("PopStateEvent")).initPopStateEvent("popstate",!1,!1,e)}return t.singleSpa=!0,t.singleSpaTrigger=n,t}(window.history.state,n)),o}}let ap=null,ad=!1;function af(e){if(ad)throw Error(ox(43,!1));r=!e||!e.hasOwnProperty("urlRerouteOnly")||e.urlRerouteOnly,ad=!0,ap=window.history.replaceState,window.addEventListener("hashchange",ac),window.addEventListener("popstate",ac);let n=window.addEventListener,t=window.removeEventListener;window.addEventListener=function(e,t){if(!("function"==typeof t&&ai.indexOf(e)>=0)||oG(aa[e],e=>e===t))return n.apply(this,arguments);aa[e].push(t)},window.removeEventListener=function(e,n){return"function"==typeof n&&ai.indexOf(e)>=0&&(aa[e]=aa[e].filter(e=>e!==n)),t.apply(this,arguments)},window.history.pushState=au(window.history.pushState,"pushState"),window.history.replaceState=au(ap,"replaceState")}function ah(e){let n=document.createElement("a");return n.href=e,n}ao&&(window.singleSpaNavigate?console.warn(ox(41,!1)):window.singleSpaNavigate=as);let ag=!1;function am(e=window.jQuery){if(e||window.$&&window.$.fn&&window.$.fn.jquery&&(e=window.$),e&&!ag){let n=e.fn.on,t=e.fn.off;e.fn.on=function(e,t){return ab.call(this,n,window.addEventListener,e,t,arguments)},e.fn.off=function(e,n){return ab.call(this,t,window.removeEventListener,e,n,arguments)},ag=!0}}function ab(e,n,t,r,o){return"string"!=typeof t?e.apply(this,o):(t.split(/\s+/).forEach(e=>{ai.indexOf(e)>=0&&(n(e,r),t=t.replace(e,""))}),""===t.trim()?this:e.apply(this,o))}let ay={};function a_(e){return Promise.resolve().then(()=>{let n=ay[oF(e)];if(!n)return e;if(e.status===oC)return av(e,n),e;if(e.status===oI)return n.promise.then(()=>e);if(e.status!==oz&&e.status!==oj)return e;let t=e.status===oj?Promise.resolve():an(e,"unload");return e.status=oI,t.then(()=>(av(e,n),e)).catch(t=>(delete ay[oF(e)],delete e.bootstrap,delete e.mount,delete e.unmount,delete e.unload,o$(t,e,oN),n.reject(t),e))})}function av(e,n){delete ay[oF(e)],delete e.bootstrap,delete e.mount,delete e.unmount,delete e.unload,e.status=oC,n.resolve()}function a$(e,n,t,r){ay[oF(e)]={app:e,resolve:t,reject:r},Object.defineProperty(ay[oF(e)],"promise",{get:n})}let aA=[];function aw(){return aA.filter(oB).map(oF)}function ax(){return aA.map(oF)}function ak(e){let n=oG(aA,n=>oF(n)===e);return n?n.status:null}let aC=!1;function aE(e,n,t,r){var o,a;let i,s,l=(i={name:null,loadApp:null,activeWhen:null,customProps:null},"object"==typeof e?(function(e){if(Array.isArray(e)||null===e)throw Error(ox(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(ox(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(ox(20,!1));let r=e=>"string"==typeof e||"function"==typeof e;if(!(r(e.activeWhen)||Array.isArray(e.activeWhen)&&e.activeWhen.every(r)))throw Error(ox(24,!1));if(!aO(e.customProps))throw Error(ox(22,!1))}(e),i.name=e.name,i.loadApp=e.app,i.activeWhen=e.activeWhen,i.customProps=e.customProps):(function(e,n,t,r){if("string"!=typeof e||0===e.length)throw Error(ox(20,!1));if(!n)throw Error(ox(23,!1));if("function"!=typeof t)throw Error(ox(24,!1));if(!aO(r))throw Error(ox(22,!1))}(e,n,t,r),i.name=e,i.loadApp=n,i.activeWhen=t,i.customProps=r),i.loadApp="function"!=typeof(o=i.loadApp)?()=>Promise.resolve(o):o,i.customProps=i.customProps||{},s=(s=Array.isArray(a=i.activeWhen)?a:[a]).map(e=>"function"==typeof e?e:aP(e)),i.activeWhen=e=>s.some(n=>n(e)),i);if(aF||aC||(aC=!0,setTimeout(()=>{aF||console.warn(ox(1,!1))},5e3)),-1!==ax().indexOf(l.name))throw Error(ox(21,!1,l.name));aA.push(oV({loadErrorTime:null,status:oC,parcels:{},devtools:{overlays:{options:{},selectors:[]}}},l)),ao&&(am(),aB())}function aS(e=window.location){return aA.filter(n=>n.activeWhen(e)).map(oF)}function aD(e){if(0===aA.filter(n=>oF(n)===e).length)throw Error(ox(25,!1,e));return(ao?az(e,{waitForUnmount:!1}):Promise.resolve()).then(()=>{let n=aA.map(oF).indexOf(e);aA.splice(n,1)})}function az(e,n={waitForUnmount:!1}){if("string"!=typeof e)throw Error(ox(26,!1));let t=oG(aA,n=>oF(n)===e);if(!t)throw Error(ox(27,!1,e));let r=ay[oF(t)];if(n&&n.waitForUnmount){if(r)return r.promise;{let e=new Promise((n,r)=>{a$(t,()=>e,n,r)});return e}}{let e;return r?(e=r.promise,aM(t,r.resolve,r.reject)):e=new Promise((n,r)=>{a$(t,()=>e,n,r),aM(t,n,r)}),e}}function aM(e,n,t){Promise.resolve().then(()=>{if(oG(aS(),n=>n===oF(e)))return aN()}).then(()=>oJ(e).then(a_).then(()=>{n(),setTimeout(()=>{aB()})})).catch(t)}function aO(e){return!e||"function"==typeof e||"object"==typeof e&&null!==e&&!Array.isArray(e)}function aP(e,n){let t=function(e,n){let t=0,r=!1,o="^";"/"!==e[0]&&(e="/"+e);for(let n=0;n<e.length;n++){let t=e[n],o=r&&"/"===t;(!r&&":"===t||o)&&a(n)}return a(e.length),RegExp(o,"i");function a(a){let i=e.slice(t,a).replace(/[|\\{}()[\]^$+*?.]/g,"\\$&");if(o+=r?"[^/]+/?":i,a===e.length)if(r)n&&(o+="$");else{let e=n?"":".*";o="/"===o.charAt(o.length-1)?`${o}${e}$`:`${o}(/${e})?(#.*)?$`}r=!r,t=a}}(e,n);return e=>{let n=e.origin;n||(n=`${e.protocol}//${e.host}`);let r=e.href.replace(n,"").replace(e.search,"").split("?")[0];return t.test(r)}}let aT=!1,aI=[],aj=ao&&window.location.href;function aN(){return aB()}function aB(e=[],n,t=!1){let r,o,a,i,s;if(aT)return new Promise((e,t)=>{aI.push({resolve:e,reject:t,eventArguments:n})});let{appsToUnload:l,appsToUnmount:c,appsToLoad:u,appsToMount:p}=(r=[],o=[],a=[],i=[],s=(new Date).getTime(),aA.forEach(e=>{let n=e.status!==oN&&oR(e);switch(e.status){case oj:n&&s-e.loadErrorTime>=200&&a.push(e);break;case oC:case oE:n&&a.push(e);break;case oS:case oz:!n&&ay[oF(e)]?r.push(e):n&&i.push(e);break;case oO:n||o.push(e)}}),{appsToUnload:r,appsToUnmount:o,appsToLoad:a,appsToMount:i}),d,f=[],h=aj,g=aj=window.location.href;return aF?(aT=!0,d=l.concat(u,c,p),Promise.resolve().then(()=>($(0===d.length?"before-no-app-change":"before-app-change",v(!0)),$("before-routing-event",v(!0,{cancelNavigation:m})),Promise.all(f).then(t=>{if(t.some(e=>e))return ap.call(window.history,history.state,"",h.substring(location.origin.length)),aj=location.href,aT=!1,aB(e,n,!0);let r=l.map(a_),o=Promise.all(c.map(oJ).map(e=>e.then(a_)).concat(r));o.then(()=>{$("before-mount-routing-event",v(!0))},e=>{throw e});let a=u.map(e=>ar(e).then(e=>aR(e,o))),i=p.filter(e=>0>u.indexOf(e)).map(e=>aR(e,o));return o.catch(e=>{throw y(),e}).then(()=>(y(),Promise.all(a.concat(i)).catch(n=>{throw e.forEach(e=>e.reject(n)),n}).then(b).then(()=>{},e=>{throw e})))})))):(d=u,Promise.resolve().then(()=>Promise.all(u.map(ar)).then(y).then(()=>[]).catch(e=>{throw y(),e}).finally(()=>{})));function m(e=!0){let n="function"==typeof(null==e?void 0:e.then)?e:Promise.resolve(e);f.push(n.catch(e=>(console.warn(Error(ox(42,!1))),console.warn(e),!1)))}function b(){let n=aw();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(aT=!1,aI.length>0){let e=aI;aI=[],aB(e)}return n}function y(){t||(e.forEach(e=>{al(e.eventArguments)}),al(n))}function v(e=!1,t){let r={},o={[oO]:[],[oz]:[],[oC]:[],[oN]:[]};e?(u.concat(p).forEach((e,n)=>{i(e,oO)}),l.forEach(e=>{i(e,oC)}),c.forEach(e=>{i(e,oz)})):d.forEach(e=>{i(e)});let a={detail:{newAppStatuses:r,appsByNewStatus:o,totalAppChanges:d.length,originalEvent:null==n?void 0:n[0],oldUrl:h,newUrl:g}};return t&&oV(a.detail,t),a;function i(e,n){let t=oF(e);n=n||ak(t),r[t]=n,(o[n]=o[n]||[]).push(t)}}function $(e,n){t||window.dispatchEvent(new o_(`single-spa:${e}`,n))}}function aR(e,n){return oR(e)?oY(e).then(e=>n.then(()=>oR(e)?oZ(e):e)):n.then(()=>e)}let aF=!1;function aL(e){aF=!0,ao&&(af(e),aB())}function aW(e,n){let t=window.getOpenmrsSpaBase().replace(/\/$/,"");return aV(e,{openmrsBase:window.openmrsBase,openmrsSpaBase:t,...n}).replace(/^\/\//,"/")}function aV(e,n){return Object.keys(n).reduce((e,t)=>e.split("${"+t+"}").join(n[t]),e)}function aG({to:e,templateParams:n}){let t=window.getOpenmrsSpaBase().replace(/\/$/,""),r=aW(e,n).replace(window.location.origin,"");r.startsWith(t)?as(r):window.location.assign(r)}ao&&window.__SINGLE_SPA_DEVTOOLS__&&(window.__SINGLE_SPA_DEVTOOLS__.exposedMethods={getRawAppData:function(){return[...aA]},reroute:aB,NOT_LOADED:oC,toLoadPromise:ar,toBootstrapPromise:oY,unregisterApplication:aD,getProfilerData:function(){return oK}});let aH="openmrs:history";function aU(e){let n=JSON.parse(sessionStorage.getItem(aH)??"[]")||[];n.push(e),n.length>50&&(n=n.slice(-50)),sessionStorage.setItem(aH,JSON.stringify(n))}function aq(){0===JSON.parse(sessionStorage.getItem(aH)??"[]").length&&document.referrer&&aU(document.referrer),window.addEventListener("single-spa:routing-event",e=>{let n=aK();e.detail.originalEvent?.singleSpaTrigger=="replaceState"?(n[n.length-1]=window.location.href,sessionStorage.setItem(aH,JSON.stringify(n))):!e.detail.originalEvent?.singleSpa&&n.includes(window.location.href)?aY({toUrl:window.location.href}):n[n.length-1]!==window.location.href&&aU(window.location.href)})}function aK(){return JSON.parse(sessionStorage.getItem(aH)??"[]")}function aY({toUrl:e}){let n=aK(),t=n.lastIndexOf(e);if(-1!=t){let e=n.slice(0,t+1);aG({to:n[t]}),sessionStorage.setItem(aH,JSON.stringify(e))}else throw Error(`URL ${e} not found in history; cannot go back to it.`)}function aJ(){sessionStorage.removeItem(aH)}let aQ="${openmrsSpaBase}/login",aX={redirectAuthFailure:{enabled:{_type:ry.Boolean,_default:!0,_description:"Whether to redirect logged-out users to `redirectAuthFailure.url`"},url:{_type:ry.String,_default:aQ,_validators:[ol.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:ry.Array,_default:[401],_elements:{_type:ry.Number,_validators:[ol.inRange(100,600)]},_description:"The HTTP error codes for which users will be redirected"},resolvePromise:{_type:ry.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:ry.Boolean,_default:!0,_description:"Whether openmrsFetch should support redirects returned from the backend"}};function aZ(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}let a0="/ws/rest/v1",a1="/ws/fhir2/R4",a2=`${a0}/session`;function a3(e){return e&&e.startsWith("http")?e:("/"!==e[0]&&(e="/"+e),window.openmrsBase+e)}function a4(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=a3(e);if(n.headers||(n.headers={}),eM(n.body)&&(n.body=JSON.stringify(n.body)),void 0===n.headers.Accept&&(n.headers.Accept="application/json"),null===n.headers.Accept&&delete n.headers.Accept,e.startsWith(a0)&&void 0===n.headers["Disable-WWW-Authenticate"]&&(n.headers["Disable-WWW-Authenticate"]="true"),e.startsWith(a1)){let e=new URL(t,window.location.toString());e.searchParams.has("_summary")||(e.searchParams.set("_summary","data"),t=e.toString())}let r=Error();return window.fetch(t,n).then(async e=>{let{redirectAuthFailure:n,followRedirects:o}=await rK("@openmrs/esm-api");if(e.ok){let n=e.headers.get("location");return(o&&n&&(t===a3(a2)||204===e.status)&&aG({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===a3(a2)&&403===e.status||n.enabled&&n.errors.includes(e.status)?(aJ(),aG({to:n.url||e.headers.get("location")||aQ}),n.resolvePromise?Promise.resolve():new Promise(()=>{})):e.clone().text().then(n=>{let o=n;try{o=JSON.parse(n)}catch(e){}throw new a6(t,e,o,r)},n=>{throw new a6(t,e,null,r)})})}function a5(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 ep.Observable(r=>{let o=!1;return a4(e,n).then(e=>{o=!0,r.next(e),r.complete()},e=>{o=!0,r.error(e)}),()=>{o||t.abort()}})}class a6 extends Error{constructor(e,n,t,r){super(),aZ(this,"response",void 0),aZ(this,"responseBody",void 0),this.message=`Server responded with ${n.status} (${n.statusText}) for url ${e}. Check err.responseBody or network tab in dev tools for more info`,r.message=this.message,this.responseBody=t,this.response=n,this.stack=`Stacktrace for outgoing request:
|
|
13
13
|
${r.stack}
|
|
14
14
|
Stacktrace for incoming response:
|
|
15
15
|
${this.stack}`}}let a8=G("session",{loaded:!1,session:null}),a7=0;function a9(e={includeAuthStatus:!0}){return(a7<Date.now()-6e4||!a8.getState().loaded)&&ir(),new ep.Observable(n=>{let t=t=>{t.loaded&&(e.includeAuthStatus?n.next(t.session):n.next(t.session?.user))};return t(a8.getState()),a8.subscribe(t)})}function ie(){return(a7<Date.now()-6e4||!a8.getState().loaded)&&ir(),a8}function it(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 ir(e,n){a7=Date.now();let t={};return e&&n&&(t.Authorization=`Basic ${window.btoa(`${e}:${n}`)}`),iu(a4(a2,{headers:t}))}function io(){a8.setState({loaded:!0,session:{authenticated:!1,sessionId:""}})}function ia(e,n){var t,r;if(void 0===n)return!e;if(!e)return!0;return t=e,r=n,("string"==typeof t?!Y(r.privileges.find(e=>t===e.display)):Array.isArray(t)?t.every(e=>!Y(r.privileges.find(n=>e===n.display))):(Y(t)||console.error(`Could not understand privileges "${t}"`),!0))||!Y(n.roles.find(e=>"System Developer"===e.display))}function ii(){let e,n;return new Promise(t=>{let r=r=>{r.loaded&&r.session.user&&(e=r.session.user,t(r.session.user),n&&n())};r(a8.getState()),e||(n=a8.subscribe(r))})}function is(){return new Promise((e,n)=>{a9().subscribe(n=>{e(n.sessionLocation)},n).unsubscribe()})}async function il(e,n){return iu(a4(a2,{method:"POST",body:{sessionLocation:e},headers:{"Content-Type":"application/json"},signal:n.signal}))}async function ic(e,n,t){return t||(t=new AbortController),await a4(`${a0}/user/${e}`,{method:"POST",body:{userProperties:n},headers:{"Content-Type":"application/json"},signal:t.signal}),ir()}function iu(e){return new Promise((n,t)=>{e.then(e=>{let r;"object"==typeof e?.data?(r={loaded:!0,session:e.data},a8.setState(r),n(r)):(r={loaded:!1,session:null},a8.setState(r),t(r))}).catch(e=>{T(`Failed to fetch new session information: ${e}`);let n={loaded:!1,session:null};a8.setState(n),t(n)})})}function ip(){return"development"===window.spaEnv||"true"===localStorage.getItem("openmrs:devtools")}a8.subscribe(e=>{e.loaded&&e.session&&it(e.session)});let id={"webservices.rest":"2.24.0",fhir2:"1.0.0-SNAPSHOT"};function ih(){rW("@openmrs/esm-api",aX),ir()}let ig={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"},im=e=>"string"==typeof e,ib=()=>{let e,n,t=new Promise((t,r)=>{e=t,n=r});return t.resolve=e,t.reject=n,t},iy=e=>null==e?"":""+e,i_=/###/g,iv=e=>e&&e.indexOf("###")>-1?e.replace(i_,"."):e,i$=e=>!e||im(e),iA=(e,n,t)=>{let r=im(n)?n.split("."):n,o=0;for(;o<r.length-1;){if(i$(e))return{};let n=iv(r[o]);!e[n]&&t&&(e[n]=new t),e=Object.prototype.hasOwnProperty.call(e,n)?e[n]:{},++o}return i$(e)?{}:{obj:e,k:iv(r[o])}},iw=(e,n,t)=>{let{obj:r,k:o}=iA(e,n,Object);if(void 0!==r||1===n.length){r[o]=t;return}let a=n[n.length-1],i=n.slice(0,n.length-1),s=iA(e,i,Object);for(;void 0===s.obj&&i.length;)a=`${i[i.length-1]}.${a}`,s=iA(e,i=i.slice(0,i.length-1),Object),s?.obj&&void 0!==s.obj[`${s.k}.${a}`]&&(s.obj=void 0);s.obj[`${s.k}.${a}`]=t},ix=(e,n)=>{let{obj:t,k:r}=iA(e,n);if(t&&Object.prototype.hasOwnProperty.call(t,r))return t[r]},ik=(e,n,t)=>{for(let r in n)"__proto__"!==r&&"constructor"!==r&&(r in e?im(e[r])||e[r]instanceof String||im(n[r])||n[r]instanceof String?t&&(e[r]=n[r]):ik(e[r],n[r],t):e[r]=n[r]);return e};var iC={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};let iE=e=>im(e)?e.replace(/[&<>"'\/]/g,e=>iC[e]):e,iS=[" ",",","?","!",";"],iD=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),iz=(e,n,t=".")=>{if(!e)return;if(e[n]){if(!Object.prototype.hasOwnProperty.call(e,n))return;return e[n]}let r=n.split(t),o=e;for(let e=0;e<r.length;){let n;if(!o||"object"!=typeof o)return;let a="";for(let i=e;i<r.length;++i)if(i!==e&&(a+=t),a+=r[i],void 0!==(n=o[a])){if(["string","number","boolean"].indexOf(typeof n)>-1&&i<r.length-1)continue;e+=i-e+1;break}o=n}return o},iM=e=>e?.replace("_","-"),iO={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 iP{constructor(e,n={}){this.init(e,n)}init(e,n={}){this.prefix=n.prefix||"i18next:",this.logger=e||iO,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,r){return r&&!this.debug?null:(im(e[0])&&(e[0]=`${t}${this.prefix} ${e[0]}`),this.logger[n](e))}create(e){return new iP(this.logger,{...{prefix:`${this.prefix}:${e}:`},...this.options})}clone(e){return(e=e||this.options).prefix=e.prefix||this.prefix,new iP(this.logger,e)}}var iT=new iP;class iI{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 r=0;r<t;r++)e(...n)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(([t,r])=>{for(let o=0;o<r;o++)t.apply(t,[e,...n])})}}class ij extends iI{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,r={}){let o,a=void 0!==r.keySeparator?r.keySeparator:this.options.keySeparator,i=void 0!==r.ignoreJSONStructure?r.ignoreJSONStructure:this.options.ignoreJSONStructure;e.indexOf(".")>-1?o=e.split("."):(o=[e,n],t&&(Array.isArray(t)?o.push(...t):im(t)&&a?o.push(...t.split(a)):o.push(t)));let s=ix(this.data,o);return(!s&&!n&&!t&&e.indexOf(".")>-1&&(e=o[0],n=o[1],t=o.slice(2).join(".")),!s&&i&&im(t))?iz(this.data?.[e]?.[n],t,a):s}addResource(e,n,t,r,o={silent:!1}){let a=void 0!==o.keySeparator?o.keySeparator:this.options.keySeparator,i=[e,n];t&&(i=i.concat(a?t.split(a):t)),e.indexOf(".")>-1&&(i=e.split("."),r=n,n=i[1]),this.addNamespaces(n),iw(this.data,i,r),o.silent||this.emit("added",e,n,t,r)}addResources(e,n,t,r={silent:!1}){for(let r in t)(im(t[r])||Array.isArray(t[r]))&&this.addResource(e,n,r,t[r],{silent:!0});r.silent||this.emit("added",e,n,t)}addResourceBundle(e,n,t,r,o,a={silent:!1,skipCopy:!1}){let i=[e,n];e.indexOf(".")>-1&&(i=e.split("."),r=t,t=n,n=i[1]),this.addNamespaces(n);let s=ix(this.data,i)||{};a.skipCopy||(t=JSON.parse(JSON.stringify(t))),r?ik(s,t,o):s={...s,...t},iw(this.data,i,s),a.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 iN={processors:{},addPostProcessor(e){this.processors[e.name]=e},handle(e,n,t,r,o){return e.forEach(e=>{n=this.processors[e]?.process(n,t,r,o)??n}),n}};let iB=Symbol("i18next/PATH_KEY");function iR(e,n){let t,r,o,{[iB]:a}=e((r=[],(o=Object.create(null)).get=(e,n)=>(t?.revoke?.(),n===iB)?r:(r.push(n),(t=Proxy.revocable(e,o)).proxy),Proxy.revocable(Object.create(null),o).proxy));return a.join(n?.keySeparator??".")}let iF={},iL=e=>!im(e)&&"boolean"!=typeof e&&"number"!=typeof e;class iW extends iI{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=iT.create("translator")}changeLanguage(e){e&&(this.language=e)}exists(e,n={interpolation:{}}){let t={...n};if(null==e)return!1;let r=this.resolve(e,t);if(r?.res===void 0)return!1;let o=iL(r.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 r=void 0!==n.keySeparator?n.keySeparator:this.options.keySeparator,o=n.ns||this.options.defaultNS||[],a=t&&e.indexOf(t)>-1,i=!this.options.userDefinedKeySeparator&&!n.keySeparator&&!this.options.userDefinedNsSeparator&&!n.nsSeparator&&!((e,n,t)=>{n=n||"",t=t||"";let r=iS.filter(e=>0>n.indexOf(e)&&0>t.indexOf(e));if(0===r.length)return!0;let o=iD.getRegExp(`(${r.map(e=>"?"===e?"\\?":e).join("|")})`),a=!o.test(e);if(!a){let n=e.indexOf(t);n>0&&!o.test(e.substring(0,n))&&(a=!0)}return a})(e,t,r);if(a&&!i){let n=e.match(this.interpolator.nestingRegexp);if(n&&n.length>0)return{key:e,namespaces:im(o)?[o]:o};let a=e.split(t);(t!==r||t===r&&this.options.ns.indexOf(a[0])>-1)&&(o=a.shift()),e=a.join(r)}return{key:e,namespaces:im(o)?[o]:o}}translate(e,n,t){let r="object"==typeof n?{...n}:n;if("object"!=typeof r&&this.options.overloadTranslationOptionHandler&&(r=this.options.overloadTranslationOptionHandler(arguments)),"object"==typeof r&&(r={...r}),r||(r={}),null==e)return"";"function"==typeof e&&(e=iR(e,{...this.options,...r})),Array.isArray(e)||(e=[String(e)]);let o=void 0!==r.returnDetails?r.returnDetails:this.options.returnDetails,a=void 0!==r.keySeparator?r.keySeparator:this.options.keySeparator,{key:i,namespaces:s}=this.extractFromKey(e[e.length-1],r),l=s[s.length-1],c=void 0!==r.nsSeparator?r.nsSeparator:this.options.nsSeparator;void 0===c&&(c=":");let u=r.lng||this.language,p=r.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(u?.toLowerCase()==="cimode")return p?o?{res:`${l}${c}${i}`,usedKey:i,exactUsedKey:i,usedLng:u,usedNS:l,usedParams:this.getUsedParamsDetails(r)}:`${l}${c}${i}`:o?{res:i,usedKey:i,exactUsedKey:i,usedLng:u,usedNS:l,usedParams:this.getUsedParamsDetails(r)}:i;let d=this.resolve(e,r),f=d?.res,h=d?.usedKey||i,g=d?.exactUsedKey||i,m=void 0!==r.joinArrays?r.joinArrays:this.options.joinArrays,b=!this.i18nFormat||this.i18nFormat.handleAsObject,y=void 0!==r.count&&!im(r.count),v=iW.hasDefaultValue(r),$=y?this.pluralResolver.getSuffix(u,r.count,r):"",A=r.ordinal&&y?this.pluralResolver.getSuffix(u,r.count,{ordinal:!1}):"",w=y&&!r.ordinal&&0===r.count,x=w&&r[`defaultValue${this.options.pluralSeparator}zero`]||r[`defaultValue${$}`]||r[`defaultValue${A}`]||r.defaultValue,k=f;b&&!f&&v&&(k=x);let C=iL(k),E=Object.prototype.toString.apply(k);if(b&&k&&C&&0>["[object Number]","[object Function]","[object RegExp]"].indexOf(E)&&!(im(m)&&Array.isArray(k))){if(!r.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");let e=this.options.returnedObjectHandler?this.options.returnedObjectHandler(h,k,{...r,ns:s}):`key '${i} (${this.language})' returned an object instead of string.`;return o?(d.res=e,d.usedParams=this.getUsedParamsDetails(r),d):e}if(a){let e=Array.isArray(k),n=e?[]:{},t=e?g:h;for(let e in k)if(Object.prototype.hasOwnProperty.call(k,e)){let o=`${t}${a}${e}`;v&&!f?n[e]=this.translate(o,{...r,defaultValue:iL(x)?x[e]:void 0,...{joinArrays:!1,ns:s}}):n[e]=this.translate(o,{...r,joinArrays:!1,ns:s}),n[e]===o&&(n[e]=k[e])}f=n}}else if(b&&im(m)&&Array.isArray(f))(f=f.join(m))&&(f=this.extendTranslation(f,e,r,t));else{let n=!1,o=!1;!this.isValidLookup(f)&&v&&(n=!0,f=x),this.isValidLookup(f)||(o=!0,f=i);let s=(r.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&o?void 0:f,p=v&&x!==f&&this.options.updateMissing;if(o||n||p){if(this.logger.log(p?"updateKey":"missingKey",u,l,i,p?x:f),a){let e=this.resolve(i,{...r,keySeparator:!1});e&&e.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}let e=[],n=this.languageUtils.getFallbackCodes(this.options.fallbackLng,r.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(r.lng||this.language):e.push(r.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,p,r):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(e,l,n,o,p,r),this.emit("missingKey",e,l,n,f)};this.options.saveMissing&&(this.options.saveMissingPlurals&&y?e.forEach(e=>{let n=this.pluralResolver.getSuffixes(e,r);w&&r[`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,r[`defaultValue${n}`]||x)})}):t(e,i,x))}f=this.extendTranslation(f,e,r,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,r))}return o?(d.res=f,d.usedParams=this.getUsedParamsDetails(r),d):f}extendTranslation(e,n,t,r,o){if(this.i18nFormat?.parse)e=this.i18nFormat.parse(e,{...this.options.interpolation.defaultVariables,...t},t.lng||this.language||r.usedLng,r.usedNS,r.usedKey,{resolved:r});else if(!t.skipInterpolation){let a;t.interpolation&&this.interpolator.init({...t,...{interpolation:{...this.options.interpolation,...t.interpolation}}});let i=im(e)&&(t?.interpolation?.skipOnVariables!==void 0?t.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);if(i){let n=e.match(this.interpolator.nestingRegexp);a=n&&n.length}let s=t.replace&&!im(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||r.usedLng,t),i){let n=e.match(this.interpolator.nestingRegexp);a<(n&&n.length)&&(t.nest=!1)}!t.lng&&r&&r.res&&(t.lng=this.language||r.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 a=t.postProcess||this.options.postProcess,i=im(a)?[a]:a;return null!=e&&i?.length&&!1!==t.applyPostProcessor&&(e=iN.handle(i,e,n,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...r,usedParams:this.getUsedParamsDetails(t)},...t}:t,this)),e}resolve(e,n={}){let t,r,o,a,i;return im(e)&&(e=[e]),e.forEach(e=>{if(this.isValidLookup(t))return;let s=this.extractFromKey(e,n),l=s.key;r=l;let c=s.namespaces;this.options.fallbackNS&&(c=c.concat(this.options.fallbackNS));let u=void 0!==n.count&&!im(n.count),p=u&&!n.ordinal&&0===n.count,d=void 0!==n.context&&(im(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,!iF[`${f[0]}-${e}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(i)&&(iF[`${f[0]}-${e}`]=!0,this.logger.warn(`key "${r}" 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(r=>{let i;if(this.isValidLookup(t))return;a=r;let s=[l];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(s,l,r,e,n);else{let e;u&&(e=this.pluralResolver.getSuffix(r,n.count,n));let t=`${this.options.pluralSeparator}zero`,o=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(u&&(n.ordinal&&0===e.indexOf(o)&&s.push(l+e.replace(o,this.options.pluralSeparator)),s.push(l+e),p&&s.push(l+t)),d){let r=`${l}${this.options.contextSeparator||"_"}${n.context}`;s.push(r),u&&(n.ordinal&&0===e.indexOf(o)&&s.push(r+e.replace(o,this.options.pluralSeparator)),s.push(r+e),p&&s.push(r+t))}}for(;i=s.pop();)this.isValidLookup(t)||(o=i,t=this.getResource(r,e,i,n))}))})}),{res:t,usedKey:r,exactUsedKey:o,usedLng:a,usedNS:i}}isValidLookup(e){return void 0!==e&&!(!this.options.returnNull&&null===e)&&!(!this.options.returnEmptyString&&""===e)}getResource(e,n,t,r={}){return this.i18nFormat?.getResource?this.i18nFormat.getResource(e,n,t,r):this.resourceStore.getResource(e,n,t,r)}getUsedParamsDetails(e={}){let n=e.replace&&!im(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 iV{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=iT.create("languageUtils")}getScriptPartFromCode(e){if(!(e=iM(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=iM(e))||0>e.indexOf("-"))return e;let n=e.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(e){if(im(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 r=this.getLanguagePartFromCode(e);if(this.isSupportedCode(r))return n=r;n=this.options.supportedLngs.find(e=>{if(e===r||!(0>e.indexOf("-")&&0>r.indexOf("-"))&&(e.indexOf("-")>0&&0>r.indexOf("-")&&e.substring(0,e.indexOf("-"))===r||0===e.indexOf(r)&&r.length>1))return e})}),n||(n=this.getFallbackCodes(this.options.fallbackLng)[0]),n):null}getFallbackCodes(e,n){if(!e)return[];if("function"==typeof e&&(e=e(n)),im(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),r=[],o=e=>{e&&(this.isSupportedCode(e)?r.push(e):this.logger.warn(`rejecting language code not found in supportedLngs: ${e}`))};return im(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))):im(e)&&o(this.formatLanguageCode(e)),t.forEach(e=>{0>r.indexOf(e)&&o(this.formatLanguageCode(e))}),r}}let iG={zero:0,one:1,two:2,few:3,many:4,other:5},iH={select:e=>1===e?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class iU{constructor(e,n={}){this.languageUtils=e,this.options=n,this.logger=iT.create("pluralResolver"),this.pluralRulesCache={}}addRule(e,n){this.rules[e]=n}clearCache(){this.pluralRulesCache={}}getRule(e,n={}){let t,r=iM("dev"===e?"en":e),o=n.ordinal?"ordinal":"cardinal",a=JSON.stringify({cleanedCode:r,type:o});if(a in this.pluralRulesCache)return this.pluralRulesCache[a];try{t=new Intl.PluralRules(r,{type:o})}catch(o){if(!Intl)return this.logger.error("No Intl support, please use an Intl polyfill!"),iH;if(!e.match(/-|_/))return iH;let r=this.languageUtils.getLanguagePartFromCode(e);t=this.getRule(r,n)}return this.pluralRulesCache[a]=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)=>iG[e]-iG[n]).map(e=>`${this.options.prepend}${n.ordinal?`ordinal${this.options.prepend}`:""}${e}`):[]}getSuffix(e,n,t={}){let r=this.getRule(e,t);return r?`${this.options.prepend}${t.ordinal?`ordinal${this.options.prepend}`:""}${r.select(n)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix("dev",n,t))}}let iq=(e,n,t,r=".",o=!0)=>{let a,i=void 0!==(a=ix(e,t))?a:ix(n,t);return!i&&o&&im(t)&&void 0===(i=iz(e,t,r))&&(i=iz(n,t,r)),i};class iK{constructor(e={}){this.logger=iT.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:r,prefix:o,prefixEscaped:a,suffix:i,suffixEscaped:s,formatSeparator:l,unescapeSuffix:c,unescapePrefix:u,nestingPrefix:p,nestingPrefixEscaped:d,nestingSuffix:f,nestingSuffixEscaped:h,nestingOptionsSeparator:g,maxReplaces:m,alwaysFormat:b}=e.interpolation;this.escape=void 0!==n?n:iE,this.escapeValue=void 0===t||t,this.useRawValueToEscape=void 0!==r&&r,this.prefix=o?o.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"):a||"{{",this.suffix=i?i.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"):s||"}}",this.formatSeparator=l||",",this.unescapePrefix=c?"":u||"-",this.unescapeSuffix=this.unescapePrefix?"":c||"",this.nestingPrefix=p?p.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"):d||"$t(".replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),this.nestingSuffix=f?f.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"):h||")".replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),this.nestingOptionsSeparator=g||",",this.maxReplaces=m||1e3,this.alwaysFormat=void 0!==b&&b,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){let e=(e,n)=>e?.source===n?(e.lastIndex=0,e):RegExp(n,"g");this.regexp=e(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=e(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=e(this.nestingRegexp,`${this.nestingPrefix}((?:[^()"']+|"[^"]*"|'[^']*'|\\((?:[^()]|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`)}interpolate(e,n,t,r){let o,a,i,s=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},l=e=>{if(0>e.indexOf(this.formatSeparator)){let o=iq(n,s,e,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(o,void 0,t,{...r,...n,interpolationkey:e}):o}let o=e.split(this.formatSeparator),a=o.shift().trim(),i=o.join(this.formatSeparator).trim();return this.format(iq(n,s,a,this.options.keySeparator,this.options.ignoreJSONStructure),i,t,{...r,...n,interpolationkey:a})};this.resetRegExp();let c=r?.missingInterpolationHandler||this.options.missingInterpolationHandler,u=r?.interpolation?.skipOnVariables!==void 0?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:e=>e.replace(/\$/g,"$$$$")},{regex:this.regexp,safeValue:e=>this.escapeValue?this.escape(e).replace(/\$/g,"$$$$"):e.replace(/\$/g,"$$$$")}].forEach(n=>{for(i=0;o=n.regex.exec(e);){let t=o[1].trim();if(void 0===(a=l(t)))if("function"==typeof c){let n=c(e,o,r);a=im(n)?n:""}else if(r&&Object.prototype.hasOwnProperty.call(r,t))a="";else if(u){a=o[0];continue}else this.logger.warn(`missed to pass in variable ${t} for interpolating ${e}`),a="";else im(a)||this.useRawValueToEscape||(a=iy(a));let s=n.safeValue(a);if(e=e.replace(o[0],s),u?(n.regex.lastIndex+=a.length,n.regex.lastIndex-=o[0].length):n.regex.lastIndex=0,++i>=this.maxReplaces)break}}),e}nest(e,n,t={}){let r,o,a,i=(e,n)=>{let t=this.nestingOptionsSeparator;if(0>e.indexOf(t))return e;let r=e.split(RegExp(`${t}[ ]*{`)),o=`{${r[1]}`;e=r[0];let i=(o=this.interpolate(o,a)).match(/'/g),s=o.match(/"/g);((i?.length??0)%2!=0||s)&&s.length%2==0||(o=o.replace(/'/g,'"'));try{a=JSON.parse(o),n&&(a={...n,...a})}catch(n){return this.logger.warn(`failed parsing options string in nesting for key ${e}`,n),`${e}${t}${o}`}return a.defaultValue&&a.defaultValue.indexOf(this.prefix)>-1&&delete a.defaultValue,e};for(;r=this.nestingRegexp.exec(e);){let s=[];(a=(a={...t}).replace&&!im(a.replace)?a.replace:a).applyPostProcessor=!1,delete a.defaultValue;let l=/{.*}/.test(r[1])?r[1].lastIndexOf("}")+1:r[1].indexOf(this.formatSeparator);if(-1!==l&&(s=r[1].slice(l).split(this.formatSeparator).map(e=>e.trim()).filter(Boolean),r[1]=r[1].slice(0,l)),(o=n(i.call(this,r[1].trim(),a),a))&&r[0]===e&&!im(o))return o;im(o)||(o=iy(o)),o||(this.logger.warn(`missed to resolve ${r[1]} for nesting ${e}`),o=""),s.length&&(o=s.reduce((e,n)=>this.format(e,n,t.lng,{...t,interpolationkey:r[1].trim()}),o.trim())),e=e.replace(r[0],o),this.regexp.lastIndex=0}return e}}let iY=e=>{let n={};return(t,r,o)=>{let a=o;o&&o.interpolationkey&&o.formatParams&&o.formatParams[o.interpolationkey]&&o[o.interpolationkey]&&(a={...a,[o.interpolationkey]:void 0});let i=r+JSON.stringify(a),s=n[i];return s||(s=e(iM(r),o),n[i]=s),s(t)}},iJ=e=>(n,t,r)=>e(iM(t),r)(n);class iQ{constructor(e={}){this.logger=iT.create("formatter"),this.options=e,this.init(e)}init(e,n={interpolation:{}}){this.formatSeparator=n.interpolation.formatSeparator||",";let t=n.cacheInBuiltFormats?iY:iJ;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()]=iY(n)}format(e,n,t,r={}){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:a}=(e=>{let n=e.toLowerCase().trim(),t={};if(e.indexOf("(")>-1){let r=e.split("(");n=r[0].toLowerCase().trim();let o=r[1].substring(0,r[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,...r]=e.split(":"),o=r.join(":").trim().replace(/^'+|'+$/g,""),a=n.trim();t[a]||(t[a]=o),"false"===o&&(t[a]=!1),"true"===o&&(t[a]=!0),isNaN(o)||(t[a]=parseInt(o,10))}})}return{formatName:n,formatOptions:t}})(n);if(this.formats[o]){let n=e;try{let i=r?.formatParams?.[r.interpolationkey]||{},s=i.locale||i.lng||r.locale||r.lng||t;n=this.formats[o](e,s,{...a,...r,...i})}catch(e){this.logger.warn(e)}return n}return this.logger.warn(`there was no format function for ${o}`),e},e)}}class iX extends iI{constructor(e,n,t,r={}){super(),this.backend=e,this.store=n,this.services=t,this.languageUtils=t.languageUtils,this.options=r,this.logger=iT.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=r.maxParallelReads||10,this.readingCalls=0,this.maxRetries=r.maxRetries>=0?r.maxRetries:5,this.retryTimeout=r.retryTimeout>=1?r.retryTimeout:350,this.state={},this.queue=[],this.backend?.init?.(t,r.backend,r)}queueLoad(e,n,t,r){let o={},a={},i={},s={};return e.forEach(e=>{let r=!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===a[i]&&(a[i]=!0):(this.state[i]=1,r=!1,void 0===a[i]&&(a[i]=!0),void 0===o[i]&&(o[i]=!0),void 0===s[n]&&(s[n]=!0)))}),r||(i[e]=!0)}),(Object.keys(o).length||Object.keys(a).length)&&this.queue.push({pending:a,pendingCount:Object.keys(a).length,loaded:{},errors:[],callback:r}),{toLoad:Object.keys(o),pending:Object.keys(a),toLoadLanguages:Object.keys(i),toLoadNamespaces:Object.keys(s)}}loaded(e,n,t){let r=e.split("|"),o=r[0],a=r[1];n&&this.emit("failedLoading",o,a,n),!n&&t&&this.store.addResourceBundle(o,a,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,r)=>{let{obj:o,k:a}=iA(e,n,Object);o[a]=o[a]||[],o[a].push(t)})(t.loaded,[o],a),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,r=0,o=this.retryTimeout,a){if(!e.length)return a(null,{});if(this.readingCalls>=this.maxParallelReads)return void this.waitingReads.push({lng:e,ns:n,fcName:t,tried:r,wait:o,callback:a});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&&r<this.maxRetries?setTimeout(()=>{this.read.call(this,e,n,t,r+1,2*o,a)},o):a(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={},r){if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),r&&r();im(e)&&(e=this.languageUtils.toResolveHierarchy(e)),im(n)&&(n=[n]);let o=this.queueLoad(e,n,t,r);if(!o.toLoad.length)return o.pending.length||r(),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("|"),r=t[0],o=t[1];this.read(r,o,"read",void 0,void 0,(t,a)=>{t&&this.logger.warn(`${n}loading namespace ${o} for language ${r} failed`,t),!t&&a&&this.logger.log(`${n}loaded namespace ${o} for language ${r}`,a),this.loaded(e,t,a)})}saveMissing(e,n,t,r,o,a={},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={...a,isUpdate:o},l=this.backend.create.bind(this.backend);if(l.length<6)try{let o;(o=5===l.length?l(e,n,t,r,s):l(e,n,t,r))&&"function"==typeof o.then?o.then(e=>i(null,e)).catch(i):i(null,o)}catch(e){i(e)}else l(e,n,t,r,i,s)}e&&e[0]&&this.store.addResource(e[0],n,t,r)}}}let iZ=()=>({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]),im(e[1])&&(n.defaultValue=e[1]),im(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}),i0=e=>(im(e.ns)&&(e.ns=[e.ns]),im(e.fallbackLng)&&(e.fallbackLng=[e.fallbackLng]),im(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),i1=()=>{};class i2 extends iI{constructor(e={},n){if(super(),this.options=i0(e),this.services={},this.logger=iT,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&&(im(e.ns)?e.defaultNS=e.ns:0>e.ns.indexOf("translation")&&(e.defaultNS=e.ns[0]));let t=iZ();this.options={...t,...this.options,...i0(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 r=e=>e?"function"==typeof e?new e:e:null;if(!this.options.isClone){let e;this.modules.logger?iT.init(r(this.modules.logger),this.options):iT.init(null,this.options),e=this.modules.formatter?this.modules.formatter:iQ;let n=new iV(this.options);this.store=new ij(this.options.resources,this.options);let o=this.services;o.logger=iT,o.resourceStore=this.store,o.languageUtils=n,o.pluralResolver=new iU(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=r(e),o.formatter.init&&o.formatter.init(o,this.options),this.options.interpolation.format=o.formatter.format.bind(o.formatter)),o.interpolator=new iK(this.options),o.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},o.backendConnector=new iX(r(this.modules.backend),o.resourceStore,o,this.options),o.backendConnector.on("*",(e,...n)=>{this.emit(e,...n)}),this.modules.languageDetector&&(o.languageDetector=r(this.modules.languageDetector),o.languageDetector.init&&o.languageDetector.init(o,this.options.detection,this.options)),this.modules.i18nFormat&&(o.i18nFormat=r(this.modules.i18nFormat),o.i18nFormat.init&&o.i18nFormat.init(this)),this.translator=new iW(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=i1),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=ib(),a=()=>{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?a():setTimeout(a,0),o}loadResources(e,n=i1){let t=n,r=im(e)?e:this.language;if("function"==typeof e&&(t=e),!this.options.resources||this.options.partialBundledLanguages){if(r?.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)})};r?n(r):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 r=ib();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=i1),this.services.backendConnector.reload(e,n,e=>{r.resolve(),t(e)}),r}use(e){if(!e)throw Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!e.type)throw Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return"backend"===e.type&&(this.modules.backend=e),("logger"===e.type||e.log&&e.warn&&e.error)&&(this.modules.logger=e),"languageDetector"===e.type&&(this.modules.languageDetector=e),"i18nFormat"===e.type&&(this.modules.i18nFormat=e),"postProcessor"===e.type&&iN.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=ib();this.emit("languageChanging",e);let r=e=>{this.language=e,this.languages=this.services.languageUtils.toResolveHierarchy(e),this.resolvedLanguage=void 0,this.setResolvedLanguage(e)},o=(o,a)=>{a?this.isLanguageChangingTo===e&&(r(a),this.translator.changeLanguage(a),this.isLanguageChangingTo=void 0,this.emit("languageChanged",a),this.logger.log("languageChanged",a)):this.isLanguageChangingTo=void 0,t.resolve((...e)=>this.t(...e)),n&&n(o,(...e)=>this.t(...e))},a=n=>{e||n||!this.services.languageDetector||(n=[]);let t=im(n)?n:n&&n[0],a=this.store.hasLanguageSomeTranslations(t)?t:this.services.languageUtils.getBestMatchFromCodes(im(n)?[n]:n);a&&(this.language||r(a),this.translator.language||this.translator.changeLanguage(a),this.services.languageDetector?.cacheUserLanguage?.(a)),this.loadResources(a,e=>{o(e,a)})};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(a):this.services.languageDetector.detect(a):a(e):a(this.services.languageDetector.detect()),t}getFixedT(e,n,t){let r=(e,n,...o)=>{let a,i;(a="object"!=typeof n?this.options.overloadTranslationOptionHandler([e,n].concat(o)):{...n}).lng=a.lng||r.lng,a.lngs=a.lngs||r.lngs,a.ns=a.ns||r.ns,""!==a.keyPrefix&&(a.keyPrefix=a.keyPrefix||t||r.keyPrefix);let s=this.options.keySeparator||".";return a.keyPrefix&&Array.isArray(e)?i=e.map(e=>("function"==typeof e&&(e=iR(e,{...this.options,...n})),`${a.keyPrefix}${s}${e}`)):("function"==typeof e&&(e=iR(e,{...this.options,...n})),i=a.keyPrefix?`${a.keyPrefix}${s}${e}`:e),this.t(i,a)};return im(e)?r.lng=e:r.lngs=e,r.ns=n,r.keyPrefix=t,r}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],r=!!this.options&&this.options.fallbackLng,o=this.languages[this.languages.length-1];if("cimode"===t.toLowerCase())return!0;let a=(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,a);if(void 0!==e)return e}return!!(this.hasResourceBundle(t,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||a(t,e)&&(!r||a(o,e)))}loadNamespaces(e,n){let t=ib();return this.options.ns?(im(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=ib();im(e)&&(e=[e]);let r=this.options.preload||[],o=e.filter(e=>0>r.indexOf(e)&&this.services.languageUtils.isSupportedCode(e));return o.length?(this.options.preload=r.concat(o),this.loadResources(e=>{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 iV(iZ());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 i2(e,n)}cloneInstance(e={},n=i1){let t=e.forkResourceStore;t&&delete e.forkResourceStore;let r={...this.options,...e,isClone:!0},o=new i2(r);return(void 0!==e.debug||void 0!==e.prefix)&&(o.logger=o.logger.clone(e)),["store","services","language"].forEach(e=>{o[e]=this[e]}),o.services={...this.services},o.services.utils={hasLoadedNamespace:o.hasLoadedNamespace.bind(o)},t&&(o.store=new ij(Object.keys(this.store.data).reduce((e,n)=>(e[n]={...this.store.data[n]},e[n]=Object.keys(e[n]).reduce((t,r)=>(t[r]={...e[n][r]},t),e[n]),e),{}),r),o.services.resourceStore=o.store),o.translator=new iW(o.services,r),o.translator.on("*",(e,...n)=>{o.emit(e,...n)}),o.init(r,n),o.translator.options=r,o.translator.backendConnector.services.utils={hasLoadedNamespace:o.hasLoadedNamespace.bind(o)},o}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}let i3=i2.createInstance();i3.createInstance=i2.createInstance,i3.createInstance,i3.dir,i3.init,i3.loadResources,i3.reloadResources,i3.use,i3.changeLanguage,i3.getFixedT,i3.t,i3.exists,i3.setDefaultNamespace,i3.hasLoadedNamespace,i3.loadNamespaces,i3.loadLanguages;let i4=i3.default||i3;function i5(e,n,t,r){return i4.t(n,{ns:e,defaultValue:t,...r})}function i6(e,n,t){return ig[e]?i5("core",e,n??ig[e],t):(console.error(`O3 Core Translations does not provide key '${e}'. The key itself is being rendered as text.`),e)}i4.on("initialized",function(){window.i18next.loadNamespaces(["core"])});let i8="import-map-override:",i7="import-map-overrides-disabled",i9="import-map-overrides:change",se=!1,sn=null;async function st(){let e=document.querySelectorAll('script[type="systemjs-importmap"]'),n=[];for(let t=0;t<e.length;t++){let r=e[t];try{if(r.src){let e=await fetch(r.src);n.push(await e.json())}else r.textContent&&n.push(JSON.parse(r.textContent))}catch(e){console.warn(`[import-maps] Failed to parse import map from script tag at index ${t}`,e)}}return sr(n)}function sr(e){let n={imports:{}};for(let t of e)t?.imports&&Object.assign(n.imports,t.imports);return n}function so(){let e={};try{let n=sc();for(let t=0;t<localStorage.length;t++){let r=localStorage.key(t);if(r?.startsWith(i8)){let t=r.slice(i8.length);if(!n.includes(t)){let n=localStorage.getItem(r);n&&(e[t]=n)}}}}catch(e){console.warn("[import-maps] Failed to read import-map overrides from localStorage",e)}return{imports:e}}async function sa(){let e=await st();return se?sr([e,sn??so()]):e}async function si(){return st()}async function ss(){return se?sr([await st(),so()]):st()}function sl(e){if(!se)return{imports:{}};if(e){let e={};for(let n=0;n<localStorage.length;n++){let t=localStorage.key(n);if(t?.startsWith(i8)){let n=localStorage.getItem(t);n&&(e[t.slice(i8.length)]=n)}}return{imports:e}}return so()}function sc(){if(!se)return[];try{let e=localStorage.getItem(i7);if(e){let n=JSON.parse(e);if(Array.isArray(n))return n}}catch{}return[]}function su(e){return!!se&&sc().includes(e)}function sp(e,n){if(!se)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{localStorage.setItem(i8+e,n),window.dispatchEvent(new CustomEvent(i9))}catch(e){console.warn("[import-maps] Failed to write import-map override to localStorage",e)}}function sd(e){if(!se)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{localStorage.removeItem(i8+e);let n=sc().filter(n=>n!==e);n.length>0?localStorage.setItem(i7,JSON.stringify(n)):localStorage.removeItem(i7),window.dispatchEvent(new CustomEvent(i9))}catch(e){console.warn("[import-maps] Failed to update import-map overrides in localStorage",e)}}function sf(){if(!se)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(i8)&&e.push(t)}e.forEach(e=>localStorage.removeItem(e)),localStorage.removeItem(i7),window.dispatchEvent(new CustomEvent(i9))}catch(e){console.warn("[import-maps] Failed to clear import-map overrides from localStorage",e)}}function sh(e){if(!se)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{let n=sc().filter(n=>n!==e);n.length>0?localStorage.setItem(i7,JSON.stringify(n)):localStorage.removeItem(i7),window.dispatchEvent(new CustomEvent(i9))}catch(e){console.warn("[import-maps] Failed to update import-map overrides in localStorage",e)}}let sg=!1;function sm(){!sg&&(sg=!0,(se="development"===window.spaEnv)&&(sn=so()))}function sb(e){return e.replace(/[\/\-@]/g,"_")}async function sy(e,n="./start",r){var o;let a,i=!r?.maxLoadingTime||r.maxLoadingTime<=0?6e5:r.maxLoadingTime;await Promise.race([s_(e,r?.importMap),new Promise((n,t)=>{a=setTimeout(()=>{var n;t(Error(`Could not resolve requested script, ${e}, within ${(n=i)<1e3?`${n} milliseconds`:n<6e4?`${Math.floor(n/1e3)} seconds`:n<36e5?`${Math.floor(n/6e4)} minutes`:n<864e5?`${Math.floor(n/36e5)} hours`:`${Math.floor(n/864e5)} days`}.`))},i)})]),a&&clearTimeout(a);let s=sb(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 s_(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=sb(e);if(!window[t]){let t=n??await sv();if(!t.imports.hasOwnProperty(e)){let n=`Could not find the package ${e} defined in the current importmap`;throw console.error(n),Error(n)}let r=t.imports[e];r.startsWith("./")&&(r=window.spaBase+r.substring(1));let o=e in sl().imports;try{return await new Promise((e,n)=>{!function(e,n,t){let r=document.head.querySelector(`script[src="${e}"]`),o=window[s$];if(o||(o=window[s$]=new Set([])),r)if(o.has(e)){let e,o,a;a=()=>{e&&r.removeEventListener("load",e),o&&r.removeEventListener("error",o)},e=()=>{a(),n(null)},o=e=>{a(),t(e.message)},r.addEventListener("load",e),r.addEventListener("error",o)}else console.warn(`Script at ${e} already loaded. Not loading it again.`),n(null);else{let r,a,i;o.add(e);let s=document.createElement("script");s.src=e,s.type="text/javascript",s.async=!0;let l=setTimeout(()=>{console.error(`The script at ${e} did not load within 5 seconds. This may indicate an issue with the imports in the script's entry-point file or with the script's bundler configuration.`)},5e3);i=()=>{clearTimeout(l),o.delete(e),r&&s.removeEventListener("load",r),a&&s.removeEventListener("error",a)},r=()=>{i(),n(null)},a=n=>{i();let r=`Failed to load script from ${e}`;console.error(r,n),t(n.message??r)},s.addEventListener("load",r),s.addEventListener("error",a),document.head.appendChild(s)}}(r,e,n)})}catch(e){return o&&D({kind:"error",title:i6("scriptLoadingFailed","Error: Script failed to load"),description:i6("scriptLoadingError","Failed to load overridden script from {{- url}}. Please check that the bundled script is available at the expected URL. Click the button below to reset all import map overrides.",{url:r}),actionButtonLabel:i6("resetOverrides","Reset overrides"),onActionButtonClick(){sf(),window.location.reload()}}),Promise.reject(e)}}return Promise.resolve()}async function sv(){return sa()}let s$=Symbol("__openmrs_script_loading");function sA(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 sw(e){return!!e&&"object"==typeof e&&Object.entries(e).every(([e,n])=>"string"==typeof e&&sA(n))}let sx="openmrs-routes:",sk="openmrs-routes:change",sC=!1,sE=null;async function sS(){let e=document.querySelectorAll("script[type='openmrs-routes']"),n=[];for(let t=0;t<e.length;t++){let r=e[t];try{let e;if(r.src){let n=await fetch(r.src);e=await n.json()}else r.textContent&&(e=JSON.parse(r.textContent));e&&sw(e)&&n.push(e)}catch(e){console.warn(`[route-maps] Failed to parse routes from script tag at index ${t}`,e)}}return sD(n)}function sD(e){let n={};for(let t of e)t&&"object"==typeof t&&Object.assign(n,t);return n}async function sz(){let e={};try{let n=[];for(let e=0;e<localStorage.length;e++){let t=localStorage.key(e);if(t?.startsWith(sx)){let e=localStorage.getItem(t);e&&n.push({moduleName:t.slice(sx.length),raw:e})}}for(let t of(await Promise.allSettled(n.map(async({moduleName:e,raw:n})=>{let t=JSON.parse(n);if(sA(t))return{moduleName:e,routes:t};if("string"==typeof t&&t.startsWith("http")){let n=await fetch(t),r=await n.json();if(sA(r))return{moduleName:e,routes:r};throw Error(`${t} did not resolve to a valid OpenmrsAppRoutes object`)}throw Error(`Override for ${e} is neither a valid routes object nor a URL`)}))))"fulfilled"===t.status?e[t.value.moduleName]=t.value.routes:console.warn("[route-maps] Failed to load route override",t.reason)}catch(e){console.warn("[route-maps] Failed to read route overrides from localStorage",e)}return e}async function sM(){let e=await sS();return sC?sD([e,sE??await sz()]):e}async function sO(){return sS()}async function sP(){return sC?sD([await sS(),await sz()]):sS()}function sT(){if(!sC)return{};let e={};try{for(let n=0;n<localStorage.length;n++){let t=localStorage.key(n);if(t?.startsWith(sx)){let n=localStorage.getItem(t);n&&(e[t.slice(sx.length)]=n)}}}catch(e){console.warn("[route-maps] Failed to read route overrides from localStorage",e)}return e}function sI(e,n){if(!sC)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{if("string"==typeof n)if(n.startsWith("http"))localStorage.setItem(sx+e,JSON.stringify(n));else{let t=JSON.parse(n);if(!sA(t))return void console.error(`The supplied routes for ${e} is not a valid OpenmrsAppRoutes object`,n);localStorage.setItem(sx+e,JSON.stringify(t))}else if(n instanceof URL)localStorage.setItem(sx+e,JSON.stringify(n.toString()));else{if(!sA(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(sx+e,JSON.stringify(n))}window.dispatchEvent(new CustomEvent(sk))}catch(e){console.warn("[route-maps] Failed to write route override to localStorage",e)}}function sj(e){if(!sC)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{localStorage.removeItem(sx+e),window.dispatchEvent(new CustomEvent(sk))}catch(e){console.warn("[route-maps] Failed to remove route override from localStorage",e)}}function sN(){if(!sC)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(sx)&&e.push(t)}e.forEach(e=>localStorage.removeItem(e)),window.dispatchEvent(new CustomEvent(sk))}catch(e){console.warn("[route-maps] Failed to clear route overrides from localStorage",e)}}let sB=null;function sR(){return sB||(sB=(sC="development"===window.spaEnv)?sz().then(e=>{sE=e}):Promise.resolve())}let sF=`${a0}/attachment`;function sL(e,n){return a4(`${sF}/${e}`,{signal:n.signal})}function sW(e,n,t){return a4(`${sF}?patient=${e}&includeEncounterless=${n}`,{signal:t.signal})}async function sV(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)),a4(`${sF}`,{method:"POST",body:t})}function sG(e,n){return a4(`${sF}/${e}`,{method:"DELETE",signal:n.signal})}try{self["workbox:window:6.5.4"]&&_()}catch(e){}function sH(e,n){return new Promise(function(t){var r=new MessageChannel;r.port1.onmessage=function(e){t(e.data)},e.postMessage(n,[r.port2])})}function sU(e,n){for(var t=0;t<n.length;t++){var r=n[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function sq(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=Array(n);t<n;t++)r[t]=e[t];return r}try{self["workbox:core:6.5.4"]&&_()}catch(e){}var sK=function(){var e=this;this.promise=new Promise(function(n,t){e.resolve=n,e.reject=t})};function sY(e,n){var t=location.href;return new URL(e,t).href===new URL(n,t).href}var sJ=function(e,n){this.type=e,Object.assign(this,n)};function sQ(e,n,t){return t?n?n(e):e:(e&&e.then||(e=Promise.resolve(e)),n?e.then(n):e)}function sX(){}var sZ={type:"SKIP_WAITING"};function s0(e,n){if(!n)return e&&e.then?e.then(sX):Promise.resolve()}var s1=function(e){function n(n,t){var r,o;return void 0===t&&(t={}),(r=e.call(this)||this).nn={},r.tn=0,r.rn=new sK,r.en=new sK,r.on=new sK,r.un=0,r.an=new Set,r.cn=function(){var e=r.fn,n=e.installing;r.tn>0||!sY(n.scriptURL,r.sn.toString())||performance.now()>r.un+6e4?(r.vn=n,e.removeEventListener("updatefound",r.cn)):(r.hn=n,r.an.add(n),r.rn.resolve(n)),++r.tn,n.addEventListener("statechange",r.ln)},r.ln=function(e){var n=r.fn,t=e.target,o=t.state,a=t===r.vn,i={sw:t,isExternal:a,originalEvent:e};!a&&r.mn&&(i.isUpdate=!0),r.dispatchEvent(new sJ(o,i)),"installed"===o?r.wn=self.setTimeout(function(){"installed"===o&&n.waiting===t&&r.dispatchEvent(new sJ("waiting",i))},200):"activating"===o&&(clearTimeout(r.wn),a||r.en.resolve(t))},r.dn=function(e){var n=r.hn,t=n!==navigator.serviceWorker.controller;r.dispatchEvent(new sJ("controlling",{isExternal:t,originalEvent:e,sw:n,isUpdate:r.mn})),t||r.on.resolve(n)},o=function(e){var n=e.data,t=e.ports,o=e.source;return sQ(r.getSW(),function(){r.an.has(o)&&r.dispatchEvent(new sJ("message",{data:n,originalEvent:e,ports:t,sw:o}))})},r.gn=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];try{return Promise.resolve(o.apply(this,e))}catch(e){return Promise.reject(e)}},r.sn=n,r.nn=t,navigator.serviceWorker.addEventListener("message",r.gn),r}n.prototype=Object.create(e.prototype),n.prototype.constructor=n,n.__proto__=e;var t,r,o=n.prototype;return o.register=function(e){var n=(void 0===e?{}:e).immediate,t=void 0!==n&&n;try{var r,o,a,i=this;return r=function(){if(!t&&"complete"!==document.readyState)return s0(new Promise(function(e){return window.addEventListener("load",e)}))},o=function(){return i.mn=!!navigator.serviceWorker.controller,i.yn=i.pn(),sQ(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&&sY(n.scriptURL,i.sn.toString())&&(i.hn=n,Promise.resolve().then(function(){i.dispatchEvent(new sJ("waiting",{sw:n,wasWaitingBeforeRegister:!0}))}).then(function(){})),i.hn&&(i.rn.resolve(i.hn),i.an.add(i.hn)),i.fn.addEventListener("updatefound",i.cn),navigator.serviceWorker.addEventListener("controllerchange",i.dn),i.fn})},(a=r())&&a.then?a.then(o):o(a)}catch(e){return Promise.reject(e)}},o.update=function(){try{return this.fn?s0(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 sQ(this.getSW(),function(n){return sH(n,e)})}catch(e){return Promise.reject(e)}},o.messageSkipWaiting=function(){this.fn&&this.fn.waiting&&sH(this.fn.waiting,sZ)},o.pn=function(){var e=navigator.serviceWorker.controller;return e&&sY(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 sQ(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}}],sU(n.prototype,t),r&&sU(n,r),n}(function(){function e(){this.Pn=new Map}var n=e.prototype;return n.addEventListener=function(e,n){this.Sn(e).add(n)},n.removeEventListener=function(e,n){this.Sn(e).delete(n)},n.dispatchEvent=function(e){e.target=this;for(var n,t=function(e){var n;if("u"<typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e){if(e){if("string"==typeof e)return sq(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)?sq(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 s2(e,n){if(void 0!==p)return console.warn(`The application's Service Worker has already been registered. The new service worker at ${e} will not be registered.`),p;if(!("serviceWorker"in navigator))throw Error("Registering the Service Worker is not possible due to missing browser capabilities.");let t=new s1(e,n);return p=t.register().then(()=>t.controlling.then(()=>t))}function s3(){return p??Promise.resolve(void 0)}let s4="x-omrs-offline-response-body",s5="x-omrs-offline-response-status",s6="x-omrs-offline-caching-strategy";async function s8(e){let n=await s3();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 s7(){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 s9(){return!window.indexedDB}async function le(){return new Promise(e=>{let n=indexedDB.open("test");n.onerror=()=>e(!0),n.onsuccess=()=>e(!1)})}async function ln(){return await le()||await s9()||await s7()}let lt="openmrs3:offline-mode",lr="unavailable";function lo(){return{current:lr,notAvailable:"unavailable"===lr,active:"on"===lr}}function la(e){"unavailable"!==lr&&"unavailable"!==e&&(localStorage.setItem(lt,"on"===e?"active":"disabled"),lr=e)}async function li(){await ln()||(lr="active"===localStorage.getItem(lt)?"on":"off"),navigator.onLine}let ls="u">typeof globalThis?globalThis:"u">typeof self?self:"u">typeof window?window:global,ll=Object.keys,lc=Array.isArray;function lu(e,n){return"object"!=typeof n||ll(n).forEach(function(t){e[t]=n[t]}),e}"u"<typeof Promise||ls.Promise||(ls.Promise=Promise);let lp=Object.getPrototypeOf,ld={}.hasOwnProperty;function lf(e,n){return ld.call(e,n)}function lh(e,n){"function"==typeof n&&(n=n(lp(e))),("u"<typeof Reflect?ll:Reflect.ownKeys)(n).forEach(t=>{lm(e,t,n[t])})}let lg=Object.defineProperty;function lm(e,n,t,r){lg(e,n,lu(t&&lf(t,"get")&&"function"==typeof t.get?{get:t.get,set:t.set,configurable:!0}:{value:t,configurable:!0,writable:!0},r))}function lb(e){return{from:function(n){return e.prototype=Object.create(n.prototype),lm(e.prototype,"constructor",e),{extend:lh.bind(null,e.prototype)}}}}let ly=Object.getOwnPropertyDescriptor;function l_(e,n){let t;return ly(e,n)||(t=lp(e))&&l_(t,n)}let lv=[].slice;function l$(e,n,t){return lv.call(e,n,t)}function lA(e,n){return n(e)}function lw(e){if(!e)throw Error("Assertion Failed")}function lx(e){ls.setImmediate?setImmediate(e):setTimeout(e,0)}function lk(e,n){return e.reduce((e,t,r)=>{var o=n(t,r);return o&&(e[o[0]]=o[1]),e},{})}function lC(e,n){if("string"==typeof n&&lf(e,n))return e[n];if(!n)return e;if("string"!=typeof n){for(var t=[],r=0,o=n.length;r<o;++r){var a=lC(e,n[r]);t.push(a)}return t}var i=n.indexOf(".");if(-1!==i){var s=e[n.substr(0,i)];return null==s?void 0:lC(s,n.substr(i+1))}}function lE(e,n,t){if(e&&void 0!==n&&(!("isFrozen"in Object)||!Object.isFrozen(e)))if("string"!=typeof n&&"length"in n){lw("string"!=typeof t&&"length"in t);for(var r=0,o=n.length;r<o;++r)lE(e,n[r],t[r])}else{var a=n.indexOf(".");if(-1!==a){var i=n.substr(0,a),s=n.substr(a+1);if(""===s)void 0===t?lc(e)&&!isNaN(parseInt(i))?e.splice(i,1):delete e[i]:e[i]=t;else{var l=e[i];l&&lf(e,i)||(l=e[i]={}),lE(l,s,t)}}else void 0===t?lc(e)&&!isNaN(parseInt(n))?e.splice(n,1):delete e[n]:e[n]=t}}function lS(e){var n={};for(var t in e)lf(e,t)&&(n[t]=e[t]);return n}let lD=[].concat;function lz(e){return lD.apply([],e)}let lM="BigUint64Array,BigInt64Array,Array,Boolean,String,Date,RegExp,Blob,File,FileList,FileSystemFileHandle,FileSystemDirectoryHandle,ArrayBuffer,DataView,Uint8ClampedArray,ImageBitmap,ImageData,Map,Set,CryptoKey".split(",").concat(lz([8,16,32,64].map(e=>["Int","Uint","Float"].map(n=>n+e+"Array")))).filter(e=>ls[e]),lO=lM.map(e=>ls[e]);lk(lM,e=>[e,!0]);let lP=null;function lT(e){lP="u">typeof WeakMap&&new WeakMap;let n=function e(n){if(!n||"object"!=typeof n)return n;let t=lP&&lP.get(n);if(t)return t;if(lc(n)){t=[],lP&&lP.set(n,t);for(var r=0,o=n.length;r<o;++r)t.push(e(n[r]))}else if(lO.indexOf(n.constructor)>=0)t=n;else{let r=lp(n);for(var a in t=r===Object.prototype?{}:Object.create(r),lP&&lP.set(n,t),n)lf(n,a)&&(t[a]=e(n[a]))}return t}(e);return lP=null,n}let{toString:lI}={};function lj(e){return lI.call(e).slice(8,-1)}let lN="u">typeof Symbol?Symbol.iterator:"@@iterator",lB="symbol"==typeof lN?function(e){var n;return null!=e&&(n=e[lN])&&n.apply(e)}:function(){return null},lR={};function lF(e){var n,t,r,o;if(1==arguments.length){if(lc(e))return e.slice();if(this===lR&&"string"==typeof e)return[e];if(o=lB(e)){for(t=[];!(r=o.next()).done;)t.push(r.value);return t}if(null==e)return[e];if("number"==typeof(n=e.length)){for(t=Array(n);n--;)t[n]=e[n];return t}return[e]}for(n=arguments.length,t=Array(n);n--;)t[n]=arguments[n];return t}let lL="u">typeof Symbol?e=>"AsyncFunction"===e[Symbol.toStringTag]:()=>!1;var lW="u">typeof location&&/^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href),lV=()=>!0;let lG=!Error("").stack;function lH(){if(lG)try{throw lH.arguments,Error()}catch(e){return e}return Error()}function lU(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(lV).map(e=>"\n"+e).join("")):""}var lq=["Unknown","Constraint","Data","TransactionInactive","ReadOnly","Version","NotFound","InvalidState","InvalidAccess","Abort","Timeout","QuotaExceeded","Syntax","DataClone"],lK=["Modify","Bulk","OpenFailed","VersionChange","Schema","Upgrade","InvalidTable","MissingAPI","NoSuchDatabase","InvalidArgument","SubTransaction","Unsupported","Internal","DatabaseClosed","PrematureCommit","ForeignAwait"].concat(lq),lY={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 lJ(e,n){this._e=lH(),this.name=e,this.message=n}function lQ(e,n){return e+". Errors: "+Object.keys(n).map(e=>n[e].toString()).filter((e,n,t)=>t.indexOf(e)===n).join("\n")}function lX(e,n,t,r){this._e=lH(),this.failures=n,this.failedKeys=r,this.successCount=t,this.message=lQ(e,n)}function lZ(e,n){this._e=lH(),this.name="BulkError",this.failures=Object.keys(n).map(e=>n[e]),this.failuresByPos=n,this.message=lQ(e,n)}lb(lJ).from(Error).extend({stack:{get:function(){return this._stack||(this._stack=this.name+": "+this.message+lU(this._e,2))}},toString:function(){return this.name+": "+this.message}}),lb(lX).from(lJ),lb(lZ).from(lJ);var l0=lK.reduce((e,n)=>(e[n]=n+"Error",e),{}),l1=lK.reduce((e,n)=>{var t=n+"Error";function r(e,r){this._e=lH(),this.name=t,e?"string"==typeof e?(this.message=`${e}${r?"\n "+r:""}`,this.inner=r||null):"object"==typeof e&&(this.message=`${e.name} ${e.message}`,this.inner=e):(this.message=lY[n]||t,this.inner=null)}return lb(r).from(lJ),e[n]=r,e},{});l1.Syntax=SyntaxError,l1.Type=TypeError,l1.Range=RangeError;var l2=lq.reduce((e,n)=>(e[n+"Error"]=l1[n],e),{}),l3=lK.reduce((e,n)=>(-1===["Syntax","Type","Range"].indexOf(n)&&(e[n+"Error"]=l1[n]),e),{});function l4(){}function l5(e){return e}function l6(e,n){return null==e||e===l5?n:function(t){return n(e(t))}}function l8(e,n){return function(){e.apply(this,arguments),n.apply(this,arguments)}}function l7(e,n){return e===l4?n:function(){var t=e.apply(this,arguments);void 0!==t&&(arguments[0]=t);var r=this.onsuccess,o=this.onerror;this.onsuccess=null,this.onerror=null;var a=n.apply(this,arguments);return r&&(this.onsuccess=this.onsuccess?l8(r,this.onsuccess):r),o&&(this.onerror=this.onerror?l8(o,this.onerror):o),void 0!==a?a:t}}function l9(e,n){return e===l4?n:function(){e.apply(this,arguments);var t=this.onsuccess,r=this.onerror;this.onsuccess=this.onerror=null,n.apply(this,arguments),t&&(this.onsuccess=this.onsuccess?l8(t,this.onsuccess):t),r&&(this.onerror=this.onerror?l8(r,this.onerror):r)}}function ce(e,n){return e===l4?n:function(t){var r=e.apply(this,arguments);lu(t,r);var o=this.onsuccess,a=this.onerror;this.onsuccess=null,this.onerror=null;var i=n.apply(this,arguments);return o&&(this.onsuccess=this.onsuccess?l8(o,this.onsuccess):o),a&&(this.onerror=this.onerror?l8(a,this.onerror):a),void 0===r?void 0===i?void 0:i:lu(r,i)}}function cn(e,n){return e===l4?n:function(){return!1!==n.apply(this,arguments)&&e.apply(this,arguments)}}function ct(e,n){return e===l4?n:function(){var t=e.apply(this,arguments);if(t&&"function"==typeof t.then){for(var r=this,o=arguments.length,a=Array(o);o--;)a[o]=arguments[o];return t.then(function(){return n.apply(r,a)})}return n.apply(this,arguments)}}l3.ModifyError=lX,l3.DexieError=lJ,l3.BulkError=lZ;var cr={};let[co,ca,ci]="u"<typeof Promise?[]:(()=>{let e=Promise.resolve();if("u"<typeof crypto||!crypto.subtle)return[e,lp(e),e];let n=crypto.subtle.digest("SHA-512",new Uint8Array([0]));return[n,lp(n),e]})(),cs=ca&&ca.then,cl=co&&co.constructor,cc=!!ci;var cu=!1,cp=ci?()=>{ci.then(cO)}:ls.setImmediate?setImmediate.bind(null,cO):ls.MutationObserver?()=>{var e=document.createElement("div");new MutationObserver(()=>{cO(),e=null}).observe(e,{attributes:!0}),e.setAttribute("i","1")}:()=>{setTimeout(cO,0)},cd=function(e,n){c$.push([e,n]),ch&&(cp(),ch=!1)},cf=!0,ch=!0,cg=[],cm=[],cb=null,cy=l5,c_={id:"global",global:!0,ref:0,unhandleds:[],onunhandled:c2,pgp:!1,env:{},finalize:function(){this.unhandleds.forEach(e=>{try{c2(e[0],e[1])}catch(e){}})}},cv=c_,c$=[],cA=0,cw=[];function cx(e){if("object"!=typeof this)throw TypeError("Promises must be constructed via new");this._listeners=[],this.onuncatched=l4,this._lib=!1;var n=this._PSD=cv;if(lW&&(this._stackHolder=lH(),this._prev=null,this._numPrev=0),"function"!=typeof e){if(e!==cr)throw TypeError("Not a function");return this._state=arguments[1],this._value=arguments[2],void(!1===this._state&&cE(this,this._value))}this._state=null,this._value=null,++n.ref,function e(n,t){try{t(t=>{if(null===n._state){if(t===n)throw TypeError("A promise cannot be resolved with itself.");var r=n._lib&&cP();t&&"function"==typeof t.then?e(n,(e,n)=>{t instanceof cx?t._then(e,n):t.then(e,n)}):(n._state=!0,n._value=t,cS(n)),r&&cT()}},cE.bind(null,n))}catch(e){cE(n,e)}}(this,e)}let ck={get:function(){var e=cv,n=cW;function t(t,r){var o=!e.global&&(e!==cv||n!==cW);let a=o&&!cU();var i=new cx((n,i)=>{cD(this,new cC(cZ(t,e,o,a),cZ(r,e,o,a),n,i,e))});return lW&&cM(i,this),i}return t.prototype=cr,t},set:function(e){lm(this,"then",e&&e.prototype===cr?ck:{get:function(){return e},set:ck.set})}};function cC(e,n,t,r,o){this.onFulfilled="function"==typeof e?e:null,this.onRejected="function"==typeof n?n:null,this.resolve=t,this.reject=r,this.psd=o}function cE(e,n){if(cm.push(n),null===e._state){var t=e._lib&&cP();n=cy(n),e._state=!1,e._value=n,lW&&null!==n&&"object"==typeof n&&!n._promise&&function(e){try{e.apply(null,void 0)}catch(e){}}(()=>{var t=l_(n,"stack");n._promise=e,lm(n,"stack",{get:()=>cu?t&&(t.get?t.get.apply(n):t.value):e.stack})}),cg.some(n=>n._value===e._value)||cg.push(e),cS(e),t&&cT()}}function cS(e){var n=e._listeners;e._listeners=[];for(var t=0,r=n.length;t<r;++t)cD(e,n[t]);var o=e._PSD;--o.ref||o.finalize(),0===cA&&(++cA,cd(()=>{0==--cA&&cI()},[]))}function cD(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,++cA,cd(cz,[t,e,n])}else e._listeners.push(n)}function cz(e,n,t){try{cb=n;var r,o=n._value;n._state?r=e(o):(cm.length&&(cm=[]),r=e(o),-1===cm.indexOf(o)&&function(e){for(var n=cg.length;n;)if(cg[--n]._value===e._value)return void cg.splice(n,1)}(n)),t.resolve(r)}catch(e){t.reject(e)}finally{cb=null,0==--cA&&cI(),--t.psd.ref||t.psd.finalize()}}function cM(e,n){var t=n?n._numPrev+1:0;t<100&&(e._prev=n,e._numPrev=t)}function cO(){cP()&&cT()}function cP(){var e=cf;return cf=!1,ch=!1,e}function cT(){var e,n,t;do for(;c$.length>0;)for(e=c$,c$=[],t=e.length,n=0;n<t;++n){var r=e[n];r[0].apply(null,r[1])}while(c$.length>0);cf=!0,ch=!0}function cI(){var e=cg;cg=[],e.forEach(e=>{e._PSD.onunhandled.call(null,e._value,e)});for(var n=cw.slice(0),t=n.length;t;)n[--t]()}function cj(e){return new cx(cr,!1,e)}function cN(e,n){var t=cv;return function(){var r=cP(),o=cv;try{return cJ(t,!0),e.apply(this,arguments)}catch(e){n&&n(e)}finally{cJ(o,!1),r&&cT()}}}lh(cx.prototype,{then:ck,_then:function(e,n){cD(this,new cC(null,null,e,n,cv))},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):cj(e)):this.then(null,e=>e&&e.name===n?t(e):cj(e))},finally:function(e){return this.then(n=>(e(),n),n=>(e(),cj(n)))},stack:{get:function(){if(this._stack)return this._stack;try{cu=!0;var e=(function e(n,t,r){if(t.length===r)return t;var o="";if(!1===n._state){var a,i,s=n._value;null!=s?(a=s.name||"Error",i=s.message||s,o=lU(s,0)):(a=s,i=""),t.push(a+(i?": "+i:"")+o)}return lW&&((o=lU(n._stackHolder,2))&&-1===t.indexOf(o)&&t.push(o),n._prev&&e(n._prev,t,r)),t})(this,[],20).join("\nFrom previous: ");return null!==this._state&&(this._stack=e),e}finally{cu=!1}}},timeout:function(e,n){return e<1/0?new cx((t,r)=>{var o=setTimeout(()=>r(new l1.Timeout(n)),e);this.then(t,r).finally(clearTimeout.bind(null,o))}):this}}),"u">typeof Symbol&&Symbol.toStringTag&&lm(cx.prototype,Symbol.toStringTag,"Dexie.Promise"),c_.env=cQ(),lh(cx,{all:function(){var e=lF.apply(null,arguments).map(cq);return new cx(function(n,t){0===e.length&&n([]);var r=e.length;e.forEach((o,a)=>cx.resolve(o).then(t=>{e[a]=t,--r||n(e)},t))})},resolve:e=>{if(e instanceof cx)return e;if(e&&"function"==typeof e.then)return new cx((n,t)=>{e.then(n,t)});var n=new cx(cr,!0,e);return cM(n,cb),n},reject:cj,race:function(){var e=lF.apply(null,arguments).map(cq);return new cx((n,t)=>{e.map(e=>cx.resolve(e).then(n,t))})},PSD:{get:()=>cv,set:e=>cv=e},totalEchoes:{get:()=>cW},newPSD:cG,usePSD:cX,scheduler:{get:()=>cd,set:e=>{cd=e}},rejectionMapper:{get:()=>cy,set:e=>{cy=e}},follow:(e,n)=>new cx((t,r)=>cG((n,t)=>{var r=cv;r.unhandleds=[],r.onunhandled=t,r.finalize=l8(function(){var e;e=()=>{0===this.unhandleds.length?n():t(this.unhandleds[0])},cw.push(function n(){e(),cw.splice(cw.indexOf(n),1)}),++cA,cd(()=>{0==--cA&&cI()},[])},r.finalize),e()},n,t,r))}),cl&&(cl.allSettled&&lm(cx,"allSettled",function(){let e=lF.apply(null,arguments).map(cq);return new cx(n=>{0===e.length&&n([]);let t=e.length,r=Array(t);e.forEach((e,o)=>cx.resolve(e).then(e=>r[o]={status:"fulfilled",value:e},e=>r[o]={status:"rejected",reason:e}).then(()=>--t||n(r)))})}),cl.any&&"u">typeof AggregateError&&lm(cx,"any",function(){let e=lF.apply(null,arguments).map(cq);return new cx((n,t)=>{0===e.length&&t(AggregateError([]));let r=e.length,o=Array(r);e.forEach((e,a)=>cx.resolve(e).then(e=>n(e),e=>{o[a]=e,--r||t(AggregateError(o))}))})}));let cB={awaits:0,echoes:0,id:0};var cR=0,cF=[],cL=0,cW=0,cV=0;function cG(e,n,t,r){var o=cv,a=Object.create(o);a.parent=o,a.ref=0,a.global=!1,a.id=++cV;var i=c_.env;a.env=cc?{Promise:cx,PromiseProp:{value:cx,configurable:!0,writable:!0},all:cx.all,race:cx.race,allSettled:cx.allSettled,any:cx.any,resolve:cx.resolve,reject:cx.reject,nthen:c0(i.nthen,a),gthen:c0(i.gthen,a)}:{},n&&lu(a,n),++o.ref,a.finalize=function(){--this.parent.ref||this.parent.finalize()};var s=cX(a,e,t,r);return 0===a.ref&&a.finalize(),s}function cH(){return cB.id||(cB.id=++cR),++cB.awaits,cB.echoes+=100,cB.id}function cU(){return!!cB.awaits&&(0==--cB.awaits&&(cB.id=0),cB.echoes=100*cB.awaits,!0)}function cq(e){return cB.echoes&&e&&e.constructor===cl?(cH(),e.then(e=>(cU(),e),e=>(cU(),c3(e)))):e}function cK(e){++cW,cB.echoes&&0!=--cB.echoes||(cB.echoes=cB.id=0),cF.push(cv),cJ(e,!0)}function cY(){var e=cF[cF.length-1];cF.pop(),cJ(e,!1)}function cJ(e,n){var t,r=cv;if((n?!cB.echoes||cL++&&e===cv:!cL||--cL&&e===cv)||(t=n?cK.bind(null,e):cY,cs.call(co,t)),e!==cv&&(cv=e,r===c_&&(c_.env=cQ()),cc)){var o=c_.env.Promise,a=e.env;ca.then=a.nthen,o.prototype.then=a.gthen,(r.global||e.global)&&(Object.defineProperty(ls,"Promise",a.PromiseProp),o.all=a.all,o.race=a.race,o.resolve=a.resolve,o.reject=a.reject,a.allSettled&&(o.allSettled=a.allSettled),a.any&&(o.any=a.any))}}function cQ(){var e=ls.Promise;return cc?{Promise:e,PromiseProp:Object.getOwnPropertyDescriptor(ls,"Promise"),all:e.all,race:e.race,allSettled:e.allSettled,any:e.any,resolve:e.resolve,reject:e.reject,nthen:ca.then,gthen:e.prototype.then}:{}}function cX(e,n,t,r,o){var a=cv;try{return cJ(e,!0),n(t,r,o)}finally{cJ(a,!1)}}function cZ(e,n,t,r){return"function"!=typeof e?e:function(){var o,a=cv;t&&cH(),cJ(n,!0);try{return e.apply(this,arguments)}finally{cJ(a,!1),r&&(o=cU,cs.call(co,o))}}}function c0(e,n){return function(t,r){return e.call(this,cZ(t,n),cZ(r,n))}}-1===(""+cs).indexOf("[native code]")&&(cH=cU=l4);let c1="unhandledrejection";function c2(e,n){var t;try{t=n.onuncatched(e)}catch(e){}if(!1!==t)try{var r,o={promise:n,reason:e};if(ls.document&&document.createEvent?((r=document.createEvent("Event")).initEvent(c1,!0,!0),lu(r,o)):ls.CustomEvent&&lu(r=new CustomEvent(c1,{detail:o}),o),r&&ls.dispatchEvent&&(dispatchEvent(r),!ls.PromiseRejectionEvent&&ls.onunhandledrejection))try{ls.onunhandledrejection(r)}catch(e){}lW&&r&&!r.defaultPrevented&&console.warn(`Unhandled rejection: ${e.stack||e}`)}catch(e){}}var c3=cx.reject;let c4="3.2.7",c5=String.fromCharCode(65535),c6=-1/0,c8="Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.",c7="String expected.",c9=[],ue="u">typeof navigator&&/(MSIE|Trident|Edge)/.test(navigator.userAgent),un=e=>!/(dexie\.js|dexie\.min\.js)/.test(e),ut="__dbnames",ur="readonly",uo="readwrite";function ua(e,n){return e?n?function(){return e.apply(this,arguments)&&n.apply(this,arguments)}:e:n}let ui={type:3,lower:-1/0,lowerOpen:!1,upper:[[]],upperOpen:!1};function us(e){return"string"!=typeof e||/\./.test(e)?e=>e:n=>(void 0===n[e]&&e in n&&delete(n=lT(n))[e],n)}class ul{_trans(e,n,t){let r=this._tx||cv.trans,o=this.name;function a(e,t,r){if(!r.schema[o])throw new l1.NotFound("Table "+o+" not part of transaction");return n(r.idbtrans,r)}let i=cP();try{return r&&r.db===this.db?r===cv.trans?r._promise(e,a,t):cG(()=>r._promise(e,a,t),{trans:r,transless:cv.transless||cv}):function e(n,t,r,o){if(n.idbdb&&(n._state.openComplete||cv.letThrough||n._vip)){var a=n._createTransaction(t,r,n._dbSchema);try{a.create(),n._state.PR1398_maxLoop=3}catch(a){return a.name===l0.InvalidState&&n.isOpen()&&--n._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),n._close(),n.open().then(()=>e(n,t,r,o))):c3(a)}return a._promise(t,(e,n)=>cG(()=>(cv.trans=a,o(e,n,a)))).then(e=>a._completion.then(()=>e))}if(n._state.openComplete)return c3(new l1.DatabaseClosed(n._state.dbOpenError));if(!n._state.isBeingOpened){if(!n._options.autoOpen)return c3(new l1.DatabaseClosed);n.open().catch(l4)}return n._state.dbReadyPromise.then(()=>e(n,t,r,o))}(this.db,e,[this.name],a)}finally{i&&cT()}}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(lc(e))return new this.db.WhereClause(this,`[${e.join("+")}]`);let n=ll(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=>{if(e.compound&&n.every(n=>e.keyPath.indexOf(n)>=0)){for(let t=0;t<n.length;++t)if(-1===n.indexOf(e.keyPath[t]))return!1;return!0}return!1}).sort((e,n)=>e.keyPath.length-n.keyPath.length)[0];if(t&&this.db._maxKey!==c5){let r=t.keyPath.slice(0,n.length);return this.where(r).equals(r.map(n=>e[n]))}!t&&lW&&console.warn(`The query ${JSON.stringify(e)} on ${this.name} would benefit of a compound index [${n.join("+")}]`);let{idxByName:r}=this.schema,o=this.db._deps.indexedDB;function a(e,n){try{return 0===o.cmp(e,n)}catch(e){return!1}}let[i,s]=n.reduce(([n,t],o)=>{let i=r[o],s=e[o];return[n||i,n||!i?ua(t,i&&i.multi?e=>{let n=lC(e,o);return lc(n)&&n.some(e=>a(s,e))}:e=>a(s,lC(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,lc(e)?`[${e.join("+")}]`:e))}reverse(){return this.toCollection().reverse()}mapToClass(e){this.schema.mappedClass=e;let n=n=>{if(!n)return n;let t=Object.create(e.prototype);for(var r in n)if(lf(n,r))try{t[r]=n[r]}catch(e){}return t};return this.schema.readHook&&this.hook.reading.unsubscribe(this.schema.readHook),this.schema.readHook=n,this.hook("reading",n),e}defineClass(){return this.mapToClass(function(e){lu(this,e)})}add(e,n){let{auto:t,keyPath:r}=this.schema.primKey,o=e;return r&&t&&(o=us(r)(e)),this._trans("readwrite",e=>this.core.mutate({trans:e,type:"add",keys:null!=n?[n]:null,values:[o]})).then(e=>e.numFailures?cx.reject(e.failures[0]):e.lastResult).then(n=>{if(r)try{lE(e,r,n)}catch(e){}return n})}update(e,n){if("object"!=typeof e||lc(e))return this.where(":id").equals(e).modify(n);{let t=lC(e,this.schema.primKey.keyPath);if(void 0===t)return c3(new l1.InvalidArgument("Given object does not contain its primary key"));try{"function"!=typeof n?ll(n).forEach(t=>{lE(e,t,n[t])}):n(e,{value:e,primKey:t})}catch(e){}return this.where(":id").equals(t).modify(n)}}put(e,n){let{auto:t,keyPath:r}=this.schema.primKey,o=e;return r&&t&&(o=us(r)(e)),this._trans("readwrite",e=>this.core.mutate({trans:e,type:"put",values:[o],keys:null!=n?[n]:null})).then(e=>e.numFailures?cx.reject(e.failures[0]):e.lastResult).then(n=>{if(r)try{lE(e,r,n)}catch(e){}return n})}delete(e){return this._trans("readwrite",n=>this.core.mutate({trans:n,type:"delete",keys:[e]})).then(e=>e.numFailures?cx.reject(e.failures[0]):void 0)}clear(){return this._trans("readwrite",e=>this.core.mutate({trans:e,type:"deleteRange",range:ui})).then(e=>e.numFailures?cx.reject(e.failures[0]):void 0)}bulkGet(e){return this._trans("readonly",n=>this.core.getMany({keys:e,trans:n}).then(e=>e.map(e=>this.hook.reading.fire(e))))}bulkAdd(e,n,t){let r=Array.isArray(n)?n:void 0,o=(t=t||(r?void 0:n))?t.allKeys:void 0;return this._trans("readwrite",n=>{let{auto:t,keyPath:a}=this.schema.primKey;if(a&&r)throw new l1.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(r&&r.length!==e.length)throw new l1.InvalidArgument("Arguments objects and keys must have the same length");let i=e.length,s=a&&t?e.map(us(a)):e;return this.core.mutate({trans:n,type:"add",keys:r,values:s,wantResults:o}).then(({numFailures:e,results:n,lastResult:t,failures:r})=>{if(0===e)return o?n:t;throw new lZ(`${this.name}.bulkAdd(): ${e} of ${i} operations failed`,r)})})}bulkPut(e,n,t){let r=Array.isArray(n)?n:void 0,o=(t=t||(r?void 0:n))?t.allKeys:void 0;return this._trans("readwrite",n=>{let{auto:t,keyPath:a}=this.schema.primKey;if(a&&r)throw new l1.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(r&&r.length!==e.length)throw new l1.InvalidArgument("Arguments objects and keys must have the same length");let i=e.length,s=a&&t?e.map(us(a)):e;return this.core.mutate({trans:n,type:"put",keys:r,values:s,wantResults:o}).then(({numFailures:e,results:n,lastResult:t,failures:r})=>{if(0===e)return o?n:t;throw new lZ(`${this.name}.bulkPut(): ${e} of ${i} operations failed`,r)})})}bulkDelete(e){let n=e.length;return this._trans("readwrite",n=>this.core.mutate({trans:n,type:"delete",keys:e})).then(({numFailures:e,lastResult:t,failures:r})=>{if(0===e)return t;throw new lZ(`${this.name}.bulkDelete(): ${e} of ${n} operations failed`,r)})}}function uc(e){var n={},t=function(t,r){if(r){for(var o=arguments.length,a=Array(o-1);--o;)a[o-1]=arguments[o];return n[t].subscribe.apply(null,a),e}if("string"==typeof t)return n[t]};t.addEventType=a;for(var r=1,o=arguments.length;r<o;++r)a(arguments[r]);return t;function a(e,r,o){if("object"!=typeof e){r||(r=cn),o||(o=l4);var i={subscribers:[],fire:o,subscribe:function(e){-1===i.subscribers.indexOf(e)&&(i.subscribers.push(e),i.fire=r(i.fire,e))},unsubscribe:function(e){i.subscribers=i.subscribers.filter(function(n){return n!==e}),i.fire=i.subscribers.reduce(r,o)}};return n[e]=t[e]=i,i}ll(e).forEach(function(n){var t=e[n];if(lc(t))a(n,e[n][0],e[n][1]);else{if("asap"!==t)throw new l1.InvalidArgument("Invalid event config");var r=a(n,l5,function(){for(var e=arguments.length,n=Array(e);e--;)n[e]=arguments[e];r.subscribers.forEach(function(e){lx(function(){e.apply(null,n)})})})}})}}function uu(e,n){return lb(n).from({prototype:e}),n}function up(e,n){return!(e.filter||e.algorithm||e.or)&&(n?e.justLimit:!e.replayFilter)}function ud(e,n){e.filter=ua(e.filter,n)}function uf(e,n,t){var r=e.replayFilter;e.replayFilter=r?()=>ua(r(),n()):n,e.justLimit=t&&!r}function uh(e,n){if(e.isPrimKey)return n.primaryKey;let t=n.getIndexByKeyPath(e.index);if(!t)throw new l1.Schema("KeyPath "+e.index+" on object store "+n.name+" is not indexed");return t}function ug(e,n,t){let r=uh(e,n.schema);return n.openCursor({trans:t,values:!e.keysOnly,reverse:"prev"===e.dir,unique:!!e.unique,query:{index:r,range:e.range}})}function um(e,n,t,r){let o=e.replayFilter?ua(e.filter,e.replayFilter()):e.filter;if(e.or){let a={},i=(e,t,r)=>{if(!o||o(t,r,e=>t.stop(e),e=>t.fail(e))){var i=t.primaryKey,s=""+i;"[object ArrayBuffer]"===s&&(s=""+new Uint8Array(i)),lf(a,s)||(a[s]=!0,n(e,t,r))}};return Promise.all([e.or._iterate(i,t),ub(ug(e,r,t),e.algorithm,i,!e.keysOnly&&e.valueMapper)])}return ub(ug(e,r,t),ua(e.algorithm,o),n,!e.keysOnly&&e.valueMapper)}function ub(e,n,t,r){var o=cN(r?(e,n,o)=>t(r(e),n,o):t);return e.then(e=>{if(e)return e.start(()=>{var t=()=>e.continue();n&&!n(e,e=>t=e,n=>{e.stop(n),t=l4},n=>{e.fail(n),t=l4})||o(e.value,e,e=>t=e),t()})})}function uy(e,n){try{let t=u_(e),r=u_(n);if(t!==r)return"Array"===t?1:"Array"===r?-1:"binary"===t?1:"binary"===r?-1:"string"===t?1:"string"===r?-1:"Date"===t?1:"Date"!==r?NaN:-1;switch(t){case"number":case"Date":case"string":return e>n?1:e<n?-1:0;case"binary":return function(e,n){let t=e.length,r=n.length,o=t<r?t:r;for(let t=0;t<o;++t)if(e[t]!==n[t])return e[t]<n[t]?-1:1;return t===r?0:t<r?-1:1}(uv(e),uv(n));case"Array":return function(e,n){let t=e.length,r=n.length,o=t<r?t:r;for(let t=0;t<o;++t){let r=uy(e[t],n[t]);if(0!==r)return r}return t===r?0:t<r?-1:1}(e,n)}}catch(e){}return NaN}function u_(e){let n=typeof e;if("object"!==n)return n;if(ArrayBuffer.isView(e))return"binary";let t=lj(e);return"ArrayBuffer"===t?"binary":t}function uv(e){return e instanceof Uint8Array?e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e)}class u${_read(e,n){var t=this._ctx;return t.error?t.table._trans(null,c3.bind(null,t.error)):t.table._trans("readonly",e).then(n)}_write(e){var n=this._ctx;return n.error?n.table._trans(null,c3.bind(null,n.error)):n.table._trans("readwrite",e,"locked")}_addAlgorithm(e){var n=this._ctx;n.algorithm=ua(n.algorithm,e)}_iterate(e,n){return um(this._ctx,e,n,this._ctx.table.core)}clone(e){var n=Object.create(this.constructor.prototype),t=Object.create(this._ctx);return e&&lu(t,e),n._ctx=t,n}raw(){return this._ctx.valueMapper=null,this}each(e){var n=this._ctx;return this._read(t=>um(n,e,t,n.table.core))}count(e){return this._read(e=>{let n=this._ctx,t=n.table.core;if(up(n,!0))return t.count({trans:e,query:{index:uh(n,t.schema),range:n.range}}).then(e=>Math.min(e,n.limit));var r=0;return um(n,()=>(++r,!1),e,t).then(()=>r)}).then(e)}sortBy(e,n){let t=e.split(".").reverse(),r=t[0],o=t.length-1;function a(e,n){return n?a(e[t[n]],n-1):e[r]}var i="next"===this._ctx.dir?1:-1;function s(e,n){var t=a(e,o),r=a(n,o);return t<r?-i:t>r?i:0}return this.toArray(function(e){return e.sort(s)}).then(n)}toArray(e){return this._read(e=>{var n=this._ctx;if("next"===n.dir&&up(n,!0)&&n.limit>0){let{valueMapper:t}=n,r=uh(n,n.table.core.schema);return n.table.core.query({trans:e,limit:n.limit,values:!0,query:{index:r,range:n.range}}).then(({result:e})=>t?e.map(t):e)}{let t=[];return um(n,e=>t.push(e),e,n.table.core).then(()=>t)}},e)}offset(e){var n=this._ctx;return e<=0||(n.offset+=e,up(n)?uf(n,()=>{var n=e;return(e,t)=>0===n||(1===n?--n:t(()=>{e.advance(n),n=0}),!1)}):uf(n,()=>{var n=e;return()=>--n<0})),this}limit(e){return this._ctx.limit=Math.min(this._ctx.limit,e),uf(this._ctx,()=>{var n=e;return function(e,t,r){return--n<=0&&t(r),n>=0}},!0),this}until(e,n){return ud(this._ctx,function(t,r,o){return!e(t.value)||(r(o),n)}),this}first(e){return this.limit(1).toArray(function(e){return e[0]}).then(e)}last(e){return this.reverse().first(e)}filter(e){var n;return ud(this._ctx,function(n){return e(n.value)}),(n=this._ctx).isMatch=ua(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&&up(n,!0)&&n.limit>0)return this._read(e=>{var t=uh(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 ud(this._ctx,function(e){var n=e.primaryKey.toString(),r=lf(t,n);return t[n]=!0,!r}),this}modify(e){var n=this._ctx;return this._write(t=>{var r;if("function"==typeof e)r=e;else{var o=ll(e),a=o.length;r=function(n){for(var t=!1,r=0;r<a;++r){var i=o[r],s=e[i];lC(n,i)!==s&&(lE(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,u=[],p=0,d=[],f=(e,n)=>{let{failures:t,numFailures:r}=n;for(let n of(p+=e-r,ll(t)))u.push(t[n])};return this.clone().primaryKeys().then(o=>{let a=u=>{let p=Math.min(c,o.length-u);return i.getMany({trans:t,keys:o.slice(u,u+p),cache:"immutable"}).then(d=>{let h=[],g=[],m=s?[]:null,b=[];for(let e=0;e<p;++e){let n=d[e],t={value:lT(n),primKey:o[u+e]};!1!==r.call(t,t.value,t)&&(null==t.value?b.push(o[u+e]):s||0===uy(l(n),l(t.value))?(g.push(t.value),s&&m.push(o[u+e])):(b.push(o[u+e]),h.push(t.value)))}let y=up(n)&&n.limit===1/0&&("function"!=typeof e||e===uA)&&{index:n.index,range:n.range};return Promise.resolve(h.length>0&&i.mutate({trans:t,type:"add",values:h}).then(e=>{for(let n in e.failures)b.splice(parseInt(n),1);f(h.length,e)})).then(()=>(g.length>0||y&&"object"==typeof e)&&i.mutate({trans:t,type:"put",keys:m,values:g,criteria:y,changeSpec:"function"!=typeof e&&e}).then(e=>f(g.length,e))).then(()=>(b.length>0||y&&e===uA)&&i.mutate({trans:t,type:"delete",keys:b,criteria:y}).then(e=>f(b.length,e))).then(()=>o.length>u+p&&a(u+c))})};return a(0).then(()=>{if(u.length>0)throw new lX("Error modifying one or more objects",u,p,d);return o.length})})})}delete(){var e=this._ctx,n=e.range;return up(e)&&(e.isPrimKey&&!ue||3===n.type)?this._write(t=>{let{primaryKey:r}=e.table.core.schema;return e.table.core.count({trans:t,query:{index:r,range:n}}).then(r=>e.table.core.mutate({trans:t,type:"deleteRange",range:n}).then(({failures:e,lastResult:n,results:t,numFailures:o})=>{if(o)throw new lX("Could not delete some values",Object.keys(e).map(n=>e[n]),r-o);return r-o}))}):this.modify(uA)}}let uA=(e,n)=>n.value=null;function uw(e,n){return e<n?-1:+(e!==n)}function ux(e,n){return e>n?-1:+(e!==n)}function uk(e,n,t){var r=e instanceof uz?new e.Collection(e):e;return r._ctx.error=t?new t(n):TypeError(n),r}function uC(e){return new e.Collection(e,()=>uD("")).limit(0)}function uE(e,n,t,r){var o,a,i,s,l,c,u,p=t.length;if(!t.every(e=>"string"==typeof e))return uk(e,c7);function d(e){o="next"===e?e=>e.toUpperCase():e=>e.toLowerCase(),a="next"===e?e=>e.toLowerCase():e=>e.toUpperCase(),i="next"===e?uw:ux;var n=t.map(function(e){return{lower:a(e),upper:o(e)}}).sort(function(e,n){return i(e.lower,n.lower)});s=n.map(function(e){return e.upper}),l=n.map(function(e){return e.lower}),c=e,u="next"===e?"":r}d("next");var f=new e.Collection(e,()=>uS(s[0],l[p-1]+r));f._ondirectionchange=function(e){d(e)};var h=0;return f._addAlgorithm(function(e,t,r){var o=e.key;if("string"!=typeof o)return!1;var d=a(o);if(n(d,l,h))return!0;for(var f=null,g=h;g<p;++g){var m=function(e,n,t,r,o,a){for(var i=Math.min(e.length,r.length),s=-1,l=0;l<i;++l){var c=n[l];if(c!==r[l])return 0>o(e[l],t[l])?e.substr(0,l)+t[l]+t.substr(l+1):0>o(e[l],r[l])?e.substr(0,l)+r[l]+t.substr(l+1):s>=0?e.substr(0,s)+n[s]+t.substr(s+1):null;0>o(e[l],c)&&(s=l)}return i<r.length&&"next"===a?e+t.substr(e.length):i<e.length&&"prev"===a?e.substr(0,t.length):s<0?null:e.substr(0,s)+r[s]+t.substr(s+1)}(o,d,s[g],l[g],i,c);null===m&&null===f?h=g+1:(null===f||i(f,m)>0)&&(f=m)}return t(null!==f?function(){e.continue(f+u)}:r),!1}),f}function uS(e,n,t,r){return{type:2,lower:e,upper:n,lowerOpen:t,upperOpen:r}}function uD(e){return{type:1,lower:e,upper:e}}class uz{get Collection(){return this._ctx.table.db.Collection}between(e,n,t,r){t=!1!==t,r=!0===r;try{return this._cmp(e,n)>0||0===this._cmp(e,n)&&(t||r)&&(!t||!r)?uC(this):new this.Collection(this,()=>uS(e,n,!t,!r))}catch(e){return uk(this,c8)}}equals(e){return null==e?uk(this,c8):new this.Collection(this,()=>uD(e))}above(e){return null==e?uk(this,c8):new this.Collection(this,()=>uS(e,void 0,!0))}aboveOrEqual(e){return null==e?uk(this,c8):new this.Collection(this,()=>uS(e,void 0,!1))}below(e){return null==e?uk(this,c8):new this.Collection(this,()=>uS(void 0,e,!1,!0))}belowOrEqual(e){return null==e?uk(this,c8):new this.Collection(this,()=>uS(void 0,e))}startsWith(e){return"string"!=typeof e?uk(this,c7):this.between(e,e+c5,!0,!0)}startsWithIgnoreCase(e){return""===e?this.startsWith(e):uE(this,(e,n)=>0===e.indexOf(n[0]),[e],c5)}equalsIgnoreCase(e){return uE(this,(e,n)=>e===n[0],[e],"")}anyOfIgnoreCase(){var e=lF.apply(lR,arguments);return 0===e.length?uC(this):uE(this,(e,n)=>-1!==n.indexOf(e),e,"")}startsWithAnyOfIgnoreCase(){var e=lF.apply(lR,arguments);return 0===e.length?uC(this):uE(this,(e,n)=>n.some(n=>0===e.indexOf(n)),e,c5)}anyOf(){let e=lF.apply(lR,arguments),n=this._cmp;try{e.sort(n)}catch(e){return uk(this,c8)}if(0===e.length)return uC(this);let t=new this.Collection(this,()=>uS(e[0],e[e.length-1]));t._ondirectionchange=t=>{n="next"===t?this._ascending:this._descending,e.sort(n)};let r=0;return t._addAlgorithm((t,o,a)=>{let i=t.key;for(;n(i,e[r])>0;)if(++r===e.length)return o(a),!1;return 0===n(i,e[r])||(o(()=>{t.continue(e[r])}),!1)}),t}notEqual(e){return this.inAnyRange([[c6,e],[e,this.db._maxKey]],{includeLowers:!1,includeUppers:!1})}noneOf(){let e=lF.apply(lR,arguments);if(0===e.length)return new this.Collection(this);try{e.sort(this._ascending)}catch(e){return uk(this,c8)}let n=e.reduce((e,n)=>e?e.concat([[e[e.length-1][1],n]]):[[c6,n]],null);return n.push([e[e.length-1],this.db._maxKey]),this.inAnyRange(n,{includeLowers:!1,includeUppers:!1})}inAnyRange(e,n){let t=this._cmp,r=this._ascending,o=this._descending,a=this._min,i=this._max;if(0===e.length)return uC(this);if(!e.every(e=>void 0!==e[0]&&void 0!==e[1]&&0>=r(e[0],e[1])))return uk(this,"First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower",l1.InvalidArgument);let s=!n||!1!==n.includeLowers,l=n&&!0===n.includeUppers,c,u=r;function p(e,n){return u(e[0],n[0])}try{(c=e.reduce(function(e,n){let r=0,o=e.length;for(;r<o;++r){let o=e[r];if(0>t(n[0],o[1])&&t(n[1],o[0])>0){o[0]=a(o[0],n[0]),o[1]=i(o[1],n[1]);break}}return r===o&&e.push(n),e},[])).sort(p)}catch(e){return uk(this,c8)}let d=0,f=l?e=>r(e,c[d][1])>0:e=>r(e,c[d][1])>=0,h=s?e=>o(e,c[d][0])>0:e=>o(e,c[d][0])>=0,g=f,m=new this.Collection(this,()=>uS(c[0][0],c[c.length-1][1],!s,!l));return m._ondirectionchange=e=>{"next"===e?(g=f,u=r):(g=h,u=o),c.sort(p)},m._addAlgorithm((e,n,t)=>{for(var o=e.key;g(o);)if(++d===c.length)return n(t),!1;return!!(!f(o)&&!h(o))||(0===this._cmp(o,c[d][1])||0===this._cmp(o,c[d][0])||n(()=>{u===r?e.continue(c[d][0]):e.continue(c[d][1])}),!1)}),m}startsWithAnyOf(){let e=lF.apply(lR,arguments);return e.every(e=>"string"==typeof e)?0===e.length?uC(this):this.inAnyRange(e.map(e=>[e,e+c5])):uk(this,"startsWithAnyOf() only works with strings")}}function uM(e){return cN(function(n){return uO(n),e(n.target.error),!1})}function uO(e){e.stopPropagation&&e.stopPropagation(),e.preventDefault&&e.preventDefault()}let uP="storagemutated",uT="x-storagemutated-1",uI=uc(null,uP);class uj{_lock(){return lw(!cv.global),++this._reculock,1!==this._reculock||cv.global||(cv.lockOwnerFor=this),this}_unlock(){if(lw(!cv.global),0==--this._reculock)for(cv.global||(cv.lockOwnerFor=null);this._blockedFuncs.length>0&&!this._locked();){var e=this._blockedFuncs.shift();try{cX(e[1],e[0])}catch(e){}}return this}_locked(){return this._reculock&&cv.lockOwnerFor!==this}create(e){if(!this.mode)return this;let n=this.db.idbdb,t=this.db._state.dbOpenError;if(lw(!this.idbtrans),!e&&!n)switch(t&&t.name){case"DatabaseClosedError":throw new l1.DatabaseClosed(t);case"MissingAPIError":throw new l1.MissingAPI(t.message,t);default:throw new l1.OpenFailed(t)}if(!this.active)throw new l1.TransactionInactive;return lw(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=cN(n=>{uO(n),this._reject(e.error)}),e.onabort=cN(n=>{uO(n),this.active&&this._reject(new l1.Abort(e.error)),this.active=!1,this.on("abort").fire(n)}),e.oncomplete=cN(()=>{this.active=!1,this._resolve(),"mutatedParts"in e&&uI.storagemutated.fire(e.mutatedParts)}),this}_promise(e,n,t){if("readwrite"===e&&"readwrite"!==this.mode)return c3(new l1.ReadOnly("Transaction is readonly"));if(!this.active)return c3(new l1.TransactionInactive);if(this._locked())return new cx((r,o)=>{this._blockedFuncs.push([()=>{this._promise(e,n,t).then(r,o)},cv])});if(t)return cG(()=>{var e=new cx((e,t)=>{this._lock();let r=n(e,t,this);r&&r.then&&r.then(e,t)});return e.finally(()=>this._unlock()),e._lib=!0,e});var r=new cx((e,t)=>{var r=n(e,t,this);r&&r.then&&r.then(e,t)});return r._lib=!0,r}_root(){return this.parent?this.parent._root():this}waitFor(e){var n=this._root();let t=cx.resolve(e);if(n._waitingFor)n._waitingFor=n._waitingFor.then(()=>t);else{n._waitingFor=t,n._waitingQueue=[];var r=n.idbtrans.objectStore(n.storeNames[0]);!function e(){for(++n._spinCount;n._waitingQueue.length;)n._waitingQueue.shift()();n._waitingFor&&(r.get(-1/0).onsuccess=e)}()}var o=n._waitingFor;return new cx((e,r)=>{t.then(t=>n._waitingQueue.push(cN(e.bind(null,t))),e=>n._waitingQueue.push(cN(r.bind(null,e)))).finally(()=>{n._waitingFor===o&&(n._waitingFor=null)})})}abort(){this.active&&(this.active=!1,this.idbtrans&&this.idbtrans.abort(),this._reject(new l1.Abort))}table(e){let n=this._memoizedTables||(this._memoizedTables={});if(lf(n,e))return n[e];let t=this.schema[e];if(!t)throw new l1.NotFound("Table "+e+" not part of transaction");let r=new this.db.Table(e,t,this);return r.core=this.db.core.table(e),n[e]=r,r}}function uN(e,n,t,r,o,a,i){return{name:e,keyPath:n,unique:t,multi:r,auto:o,compound:a,src:(t&&!i?"&":"")+(r?"*":"")+(o?"++":"")+uB(n)}}function uB(e){return"string"==typeof e?e:e?"["+[].join.call(e,"+")+"]":""}function uR(e,n,t){return{name:e,primKey:n,indexes:t,mappedClass:null,idxByName:lk(t,e=>[e.name,e])}}let uF=e=>{try{return e.only([[]]),uF=()=>[[]],[[]]}catch(e){return uF=()=>c5,c5}};function uL(e){return null==e?()=>{}:"string"==typeof e?1===e.split(".").length?n=>n[e]:n=>lC(n,e):n=>lC(n,e)}function uW(e){return[].slice.call(e)}let uV=0;function uG(e){return null==e?":id":"string"==typeof e?e:`[${e.join("+")}]`}function uH({_novip:e},n){let t=n.db,r=function(e,n,{IDBKeyRange:t,indexedDB:r},o){var a;return{dbcore:(a=function(e,n,t){let r;function o(e){if(3===e.type)return null;if(4===e.type)throw Error("Cannot convert never type to IDBKeyRange");let{lower:t,upper:r,lowerOpen:o,upperOpen:a}=e;return void 0===t?void 0===r?null:n.upperBound(r,!!a):void 0===r?n.lowerBound(t,!!o):n.bound(t,r,!!o,!!a)}let{schema:a,hasGetAll:i}=(r=uW(e.objectStoreNames),{schema:{name:e.name,tables:r.map(e=>t.objectStore(e)).map(e=>{let{keyPath:n,autoIncrement:t}=e,r=lc(n),o=null==n,a={},i={name:e.name,primaryKey:{name:null,isPrimaryKey:!0,outbound:o,compound:r,keyPath:n,autoIncrement:t,unique:!0,extractKey:uL(n)},indexes:uW(e.indexNames).map(n=>e.index(n)).map(e=>{let{name:n,unique:t,multiEntry:r,keyPath:o}=e,i={name:n,compound:lc(o),keyPath:o,unique:t,multiEntry:r,extractKey:uL(o)};return a[uG(o)]=i,i}),getIndexByKeyPath:e=>a[uG(e)]};return a[":id"]=i.primaryKey,null!=n&&(a[uG(n)]=i.primaryKey),i})},hasGetAll:r.length>0&&"getAll"in t.objectStore(r[0])&&!("u">typeof navigator&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604)}),s=a.tables.map(e=>{let n;return{name:n=e.name,schema:e,mutate:function({trans:e,type:t,keys:r,values:a,range:i}){return new Promise((s,l)=>{let c;s=cN(s);let u=e.objectStore(n),p=null==u.keyPath,d="put"===t||"add"===t;if(!d&&"delete"!==t&&"deleteRange"!==t)throw Error("Invalid operation type: "+t);let{length:f}=r||a||{length:1};if(r&&a&&r.length!==a.length)throw Error("Given keys array must have same length as given values array.");if(0===f)return s({numFailures:0,failures:{},results:[],lastResult:void 0});let h=[],g=[],m=0,b=e=>{++m,uO(e)};if("deleteRange"===t){if(4===i.type)return s({numFailures:m,failures:g,results:[],lastResult:void 0});3===i.type?h.push(c=u.clear()):h.push(c=u.delete(o(i)))}else{let[e,n]=d?p?[a,r]:[a,null]:[r,null];if(d)for(let r=0;r<f;++r)h.push(c=n&&void 0!==n[r]?u[t](e[r],n[r]):u[t](e[r])),c.onerror=b;else for(let n=0;n<f;++n)h.push(c=u[t](e[n])),c.onerror=b}let y=e=>{let n=e.target.result;h.forEach((e,n)=>null!=e.error&&(g[n]=e.error)),s({numFailures:m,failures:g,results:"delete"===t?r:h.map(e=>e.result),lastResult:n})};c.onerror=e=>{b(e),y(e)},c.onsuccess=y})},getMany:({trans:e,keys:t})=>new Promise((r,o)=>{r=cN(r);let a=e.objectStore(n),i=t.length,s=Array(i),l,c=0,u=0,p=e=>{let n=e.target;s[n._pos]=n.result,++u===c&&r(s)},d=uM(o);for(let e=0;e<i;++e)null!=t[e]&&((l=a.get(t[e]))._pos=e,l.onsuccess=p,l.onerror=d,++c);0===c&&r(s)}),get:({trans:e,key:t})=>new Promise((r,o)=>{r=cN(r);let a=e.objectStore(n).get(t);a.onsuccess=e=>r(e.target.result),a.onerror=uM(o)}),query:e=>new Promise((t,r)=>{t=cN(t);let{trans:a,values:s,limit:l,query:c}=e,u=l===1/0?void 0:l,{index:p,range:d}=c,f=a.objectStore(n),h=p.isPrimaryKey?f:f.index(p.name),g=o(d);if(0===l)return t({result:[]});if(i){let e=s?h.getAll(g,u):h.getAllKeys(g,u);e.onsuccess=e=>t({result:e.target.result}),e.onerror=uM(r)}else{let e=0,n=!s&&"openKeyCursor"in h?h.openKeyCursor(g):h.openCursor(g),o=[];n.onsuccess=r=>{let a=n.result;return a?(o.push(s?a.value:a.primaryKey),++e===l?t({result:o}):void a.continue()):t({result:o})},n.onerror=uM(r)}}),openCursor:function({trans:e,values:t,query:r,reverse:a,unique:i}){return new Promise((s,l)=>{s=cN(s);let{index:c,range:u}=r,p=e.objectStore(n),d=c.isPrimaryKey?p:p.index(c.name),f=a?i?"prevunique":"prev":i?"nextunique":"next",h=!t&&"openKeyCursor"in d?d.openKeyCursor(o(u),f):d.openCursor(o(u),f);h.onerror=uM(l),h.onsuccess=cN(n=>{let t=h.result;if(!t)return void s(null);t.___id=++uV,t.done=!1;let r=t.continue.bind(t),o=t.continuePrimaryKey;o&&(o=o.bind(t));let a=t.advance.bind(t),i=()=>{throw Error("Cursor not stopped")};t.trans=e,t.stop=t.continue=t.continuePrimaryKey=t.advance=()=>{throw Error("Cursor not started")},t.fail=cN(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=cN(e),h.onerror=uM(n),t.fail=n,t.stop=n=>{t.stop=t.continue=t.continuePrimaryKey=t.advance=i,e(n)}}),s=()=>{if(h.result)try{e()}catch(e){t.fail(e)}else t.done=!0,t.start=()=>{throw Error("Cursor behind last entry")},t.stop()};return h.onsuccess=cN(e=>{h.onsuccess=s,s()}),t.continue=r,t.continuePrimaryKey=o,t.advance=a,s(),n},s(t)},l)})},count({query:e,trans:t}){let{index:r,range:a}=e;return new Promise((e,i)=>{let s=t.objectStore(n),l=r.isPrimaryKey?s:s.index(r.name),c=o(a),u=c?l.count(c):l.count();u.onsuccess=cN(n=>e(n.target.result)),u.onerror=uM(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:uF(n),schema:a}}(n,t,o),e.dbcore.reduce((e,{create:n})=>({...e,...n(e)}),a))}}(e._middlewares,t,e._deps,n);e.core=r.dbcore,e.tables.forEach(n=>{let t=n.name;e.core.schema.tables.some(e=>e.name===t)&&(n.core=e.core.table(t),e[t]instanceof e.Table&&(e[t].core=n.core))})}function uU({_novip:e},n,t,r){t.forEach(t=>{let o=r[t];n.forEach(n=>{let r=l_(n,t);(!r||"value"in r&&void 0===r.value)&&(n===e.Transaction.prototype||n instanceof e.Transaction?lm(n,t,{get(){return this.table(t)},set(e){lg(this,t,{value:e,writable:!0,configurable:!0,enumerable:!0})}}):n[t]=new e.Table(t,o))})})}function uq({_novip:e},n){n.forEach(n=>{for(let t in n)n[t]instanceof e.Table&&delete n[t]})}function uK(e,n){return e._cfg.version-n._cfg.version}function uY(e,n){let t,r={del:[],add:[],change:[]};for(t in e)n[t]||r.del.push(t);for(t in n){let o=e[t],a=n[t];if(o){let e={name:t,def:a,recreate:!1,del:[],add:[],change:[]};if(""+(o.primKey.keyPath||"")==""+(a.primKey.keyPath||"")&&(o.primKey.auto===a.primKey.auto||ue)){let n,t=o.idxByName,i=a.idxByName;for(n in t)i[n]||e.del.push(n);for(n in i){let r=t[n],o=i[n];r?r.src!==o.src&&e.change.push(o):e.add.push(o)}(e.del.length>0||e.add.length>0||e.change.length>0)&&r.change.push(e)}else e.recreate=!0,r.change.push(e)}else r.add.push([t,a])}return r}function uJ(e,n,t,r){let o=e.db.createObjectStore(n,t.keyPath?{keyPath:t.keyPath,autoIncrement:t.auto}:{autoIncrement:t.auto});return r.forEach(e=>uQ(o,e)),o}function uQ(e,n){e.createIndex(n.name,n.keyPath,{unique:n.unique,multiEntry:n.multi})}function uX(e,n,t){let r={};return l$(n.objectStoreNames,0).forEach(e=>{let n=t.objectStore(e),o=n.keyPath,a=uN(uB(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=uN(t.name,o,!!t.unique,!!t.multiEntry,!1,o&&"string"!=typeof o,!1);i.push(s)}r[e]=uR(e,a,i)}),r}function uZ({_novip:e},n,t){let r=t.db.objectStoreNames;for(let o=0;o<r.length;++o){let a=r[o],i=t.objectStore(a);e._hasGetAll="getAll"in i;for(let e=0;e<i.indexNames.length;++e){let t=i.indexNames[e],r=i.index(t).keyPath,o="string"==typeof r?r:"["+l$(r).join("+")+"]";if(n[a]){let e=n[a].idxByName[o];e&&(e.name=t,delete n[a].idxByName[o],n[a].idxByName[t]=e)}}}"u">typeof navigator&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&ls.WorkerGlobalScope&&ls instanceof ls.WorkerGlobalScope&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604&&(e._hasGetAll=!1)}class u0{_parseStoresSpec(e,n){ll(e).forEach(t=>{if(null!==e[t]){var r=e[t].split(",").map((e,n)=>{let t=(e=e.trim()).replace(/([&*]|\+\+)/g,""),r=/^\[/.test(t)?t.match(/^\[(.*)\]$/)[1].split("+"):t;return uN(t,r||null,/\&/.test(e),/\*/.test(e),/\+\+/.test(e),lc(r),0===n)}),o=r.shift();if(o.multi)throw new l1.Schema("Primary key cannot be multi-valued");r.forEach(e=>{if(e.auto)throw new l1.Schema("Only primary key can be marked as autoIncrement (++)");if(!e.keyPath)throw new l1.Schema("Index must have a name and cannot be an empty string")}),n[t]=uR(t,o,r)}})}stores(e){let n=this.db;this._cfg.storesSource=this._cfg.storesSource?lu(this._cfg.storesSource,e):e;let t=n._versions,r={},o={};return t.forEach(e=>{lu(r,e._cfg.storesSource),o=e._cfg.dbschema={},e._parseStoresSpec(r,o)}),n._dbSchema=o,uq(n,[n._allTables,n,n.Transaction.prototype]),uU(n,[n._allTables,n,n.Transaction.prototype,this._cfg.tables],ll(o),o),n._storeNames=ll(o),this}upgrade(e){return this._cfg.contentUpgrade=ct(this._cfg.contentUpgrade||l4,e),this}}function u1(e,n){let t=e._dbNamesDB;return t||(t=e._dbNamesDB=new pu(ut,{addons:[],indexedDB:e,IDBKeyRange:n})).version(1).stores({dbnames:"name"}),t.table("dbnames")}function u2(e){return e&&"function"==typeof e.databases}function u3(e){return cG(function(){return cv.letThrough=!0,e()})}function u4(e){var n=n=>e.next(n),t=o(n),r=o(n=>e.throw(n));function o(e){return n=>{var o=e(n),a=o.value;return o.done?a:a&&"function"==typeof a.then?a.then(t,r):lc(a)?Promise.all(a).then(t,r):t(a)}}return o(n)()}function u5(e,n,t){var r=arguments.length;if(r<2)throw new l1.InvalidArgument("Too few arguments");for(var o=Array(r-1);--r;)o[r-1]=arguments[r];return t=o.pop(),[e,lz(o),t]}function u6(e,n,t){let r=lc(e)?e.slice():[e];for(let e=0;e<t;++e)r.push(n);return r}let u8={stack:"dbcore",name:"VirtualIndexMiddleware",level:1,create:function(e){return{...e,table(n){let t=e.table(n),{schema:r}=t,o={},a=[];function i(e,n,t){let r=uG(e),s=o[r]=o[r]||[],l=null==e?0:"string"==typeof e?1:e.length,c=n>0,u={...t,isVirtual:c,keyTail:n,keyLength:l,extractKey:uL(e),unique:!c&&t.unique};return s.push(u),u.isPrimaryKey||a.push(u),l>1&&i(2===l?e[0]:e.slice(0,l-1),n+1,t),s.sort((e,n)=>e.keyTail-n.keyTail),u}let s=i(r.primaryKey.keyPath,0,r.primaryKey);for(let e of(o[":id"]=[s],r.indexes))i(e.keyPath,0,e);function l(n){var t,r;let o=n.query.index;return o.isVirtual?{...n,query:{index:o,range:(t=n.query.range,r=o.keyTail,{type:1===t.type?2:t.type,lower:u6(t.lower,t.lowerOpen?e.MAX_KEY:e.MIN_KEY,r),lowerOpen:!0,upper:u6(t.upper,t.upperOpen?e.MIN_KEY:e.MAX_KEY,r),upperOpen:!0})}}:n}return{...t,schema:{...r,primaryKey:s,indexes:a,getIndexByKeyPath:function(e){let n=o[uG(e)];return n&&n[0]}},count:e=>t.count(l(e)),query:e=>t.query(l(e)),openCursor(n){let{keyTail:r,isVirtual:o,keyLength:a}=n.query.index;return o?t.openCursor(l(n)).then(t=>t&&Object.create(t,{continue:{value:function(o){null!=o?t.continue(u6(o,n.reverse?e.MAX_KEY:e.MIN_KEY,r)):n.unique?t.continue(t.key.slice(0,a).concat(n.reverse?e.MIN_KEY:e.MAX_KEY,r)):t.continue()}},continuePrimaryKey:{value(n,o){t.continuePrimaryKey(u6(n,e.MAX_KEY,r),o)}},primaryKey:{get:()=>t.primaryKey},key:{get(){let e=t.key;return 1===a?e[0]:e.slice(0,a)}},value:{get:()=>t.value}})):t.openCursor(n)}}}}}};function u7(e,n,t,r){return t=t||{},r=r||"",ll(e).forEach(o=>{if(lf(n,o)){var a=e[o],i=n[o];if("object"==typeof a&&"object"==typeof i&&a&&i){let e=lj(a);e!==lj(i)?t[r+o]=n[o]:"Object"===e?u7(a,i,t,r+o+"."):a!==i&&(t[r+o]=n[o])}else a!==i&&(t[r+o]=n[o])}else t[r+o]=void 0}),ll(n).forEach(o=>{lf(e,o)||(t[r+o]=n[o])}),t}let u9={stack:"dbcore",name:"HooksMiddleware",level:2,create:e=>({...e,table(n){let t=e.table(n),{primaryKey:r}=t.schema;return{...t,mutate(e){let o=cv.trans,{deleting:a,creating:i,updating:s}=o.table(n).hook;switch(e.type){case"add":if(i.fire===l4)break;return o._promise("readwrite",()=>l(e),!0);case"put":if(i.fire===l4&&s.fire===l4)break;return o._promise("readwrite",()=>l(e),!0);case"delete":if(a.fire===l4)break;return o._promise("readwrite",()=>l(e),!0);case"deleteRange":if(a.fire===l4)break;return o._promise("readwrite",()=>(function e(n,o,a){return t.query({trans:n,values:!1,query:{index:r,range:o},limit:a}).then(({result:t})=>l({type:"delete",keys:t,trans:n}).then(r=>r.numFailures>0?Promise.reject(r.failures[0]):t.length<a?{failures:[],numFailures:0,lastResult:void 0}:e(n,{...o,lower:t[t.length-1],lowerOpen:!0},a)))})(e.trans,e.range,1e4),!0)}return t.mutate(e);function l(e){var n,o;let l=cv.trans,c=e.keys||("delete"===(n=e).type?n.keys:n.keys||n.values.map(r.extractKey));if(!c)throw Error("Keys missing");return"delete"!==(e="add"===e.type||"put"===e.type?{...e,keys:c}:{...e}).type&&(e.values=[...e.values]),e.keys&&(e.keys=[...e.keys]),("add"===(o=e).type?Promise.resolve([]):t.getMany({trans:o.trans,keys:c,cache:"immutable"})).then(n=>{let o=c.map((t,o)=>{let c=n[o],u={onerror:null,onsuccess:null};if("delete"===e.type)a.fire.call(u,t,c,l);else if("add"===e.type||void 0===c){let n=i.fire.call(u,t,e.values[o],l);null==t&&null!=n&&(t=n,e.keys[o]=t,r.outbound||lE(e.values[o],r.keyPath,t))}else{let n=u7(c,e.values[o]),r=s.fire.call(u,n,t,c,l);if(r){let n=e.values[o];Object.keys(r).forEach(e=>{lf(n,e)?n[e]=r[e]:lE(n,e,r[e])})}}return u});return t.mutate(e).then(({failures:t,results:r,numFailures:a,lastResult:i})=>{for(let a=0;a<c.length;++a){let i=r?r[a]:c[a],s=o[a];null==i?s.onerror&&s.onerror(t[a]):s.onsuccess&&s.onsuccess("put"===e.type&&n[a]?e.values[a]:i)}return{failures:t,results:r,numFailures:a,lastResult:i}}).catch(e=>(o.forEach(n=>n.onerror&&n.onerror(e)),Promise.reject(e)))})}}}}})};function pe(e,n,t){try{if(!n||n.keys.length<e.length)return null;let r=[];for(let o=0,a=0;o<n.keys.length&&a<e.length;++o)0===uy(n.keys[o],e[a])&&(r.push(t?lT(n.values[o]):n.values[o]),++a);return r.length===e.length?r:null}catch(e){return null}}let pn={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=pe(e.keys,e.trans._cache,"clone"===e.cache);return n?cx.resolve(n):t.getMany(e).then(n=>(e.trans._cache={keys:e.keys,values:"clone"===e.cache?lT(n):n},n))},mutate:e=>("add"!==e.type&&(e.trans._cache=null),t.mutate(e))}}})};function pt(e){return!("from"in e)}let pr=function(e,n){if(!this){let n=new pr;return e&&"d"in e&&lu(n,e),n}lu(this,arguments.length?{d:1,from:e,to:arguments.length>1?n:e}:{d:0})};function po(e,n,t){let r=uy(n,t);if(isNaN(r))return;if(r>0)throw RangeError();if(pt(e))return lu(e,{from:n,to:t,d:1});let o=e.l,a=e.r;if(0>uy(t,e.from))return o?po(o,n,t):e.l={from:n,to:t,d:1,l:null,r:null},ps(e);if(uy(n,e.to)>0)return a?po(a,n,t):e.r={from:n,to:t,d:1,l:null,r:null},ps(e);0>uy(n,e.from)&&(e.from=n,e.l=null,e.d=a?a.d+1:1),uy(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&&pa(e,o),a&&i&&pa(e,a)}function pa(e,n){pt(n)||function e(n,{from:t,to:r,l:o,r:a}){po(n,t,r),o&&e(n,o),a&&e(n,a)}(e,n)}function pi(e){let n=pt(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>uy(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>=uy(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 ps(e){var n,t;let r=((null==(n=e.r)?void 0:n.d)||0)-((null==(t=e.l)?void 0:t.d)||0),o=r>1?"r":r<-1?"l":"";if(o){let n="r"===o?"l":"r",t={...e},r=e[o];e.from=r.from,e.to=r.to,e[o]=r[o],t[o]=r[n],e[n]=t,t.d=pl(t)}e.d=pl(e)}function pl({r:e,l:n}){return(e?n?Math.max(e.d,n.d):e.d:n?n.d:0)+1}lh(pr.prototype,{add(e){return pa(this,e),this},addKey(e){return po(this,e,e),this},addKeys(e){return e.forEach(e=>po(this,e,e)),this},[lN](){return pi(this)}});let pc={stack:"dbcore",level:0,create:e=>{let n=e.schema.name,t=new pr(e.MIN_KEY,e.MAX_KEY);return{...e,table:r=>{let o=e.table(r),{schema:a}=o,{primaryKey:i}=a,{extractKey:s,outbound:l}=i,c={...o,mutate:e=>{let i=e.trans,s=i.mutatedParts||(i.mutatedParts={}),l=e=>{let t=`idb://${n}/${r}/${e}`;return s[t]||(s[t]=new pr)},c=l(""),u=l(":dels"),{type:p}=e,[d,f]="deleteRange"===e.type?[e.range]:"delete"===e.type?[e.keys]:e.values.length<50?[[],e.values]:[],h=e.trans._cache;return o.mutate(e).then(e=>{if(lc(d)){"delete"!==p&&(d=e.results),c.addKeys(d);let n=pe(d,h);n||"add"===p||u.addKeys(d),(n||f)&&a.indexes.forEach(function(e){let t=l(e.name||"");function r(n){return null!=n?e.extractKey(n):null}let o=n=>e.multiEntry&&lc(n)?n.forEach(e=>t.addKey(e)):t.addKey(n);(n||f).forEach((e,t)=>{let a=n&&r(n[t]),i=f&&r(f[t]);0!==uy(a,i)&&(null!=a&&o(a),null!=i&&o(i))})})}else if(d){let e={from:d.lower,to:d.upper};u.add(e),c.add(e)}else c.add(t),u.add(t),a.indexes.forEach(e=>l(e.name).add(t));return e})}},u=({query:{index:n,range:t}})=>{var r,o;return[n,new pr(null!=(r=t.lower)?r:e.MIN_KEY,null!=(o=t.upper)?o:e.MAX_KEY)]},p={get:e=>[i,new pr(e.key)],getMany:e=>[i,(new pr).addKeys(e.keys)],count:u,query:u,openCursor:u};return ll(p).forEach(e=>{c[e]=function(a){let{subscr:i}=cv;if(i){let c=e=>{let t=`idb://${n}/${r}/${e}`;return i[t]||(i[t]=new pr)},u=c(""),d=c(":dels"),[f,h]=p[e](a);if(c(f.name||"").add(h),!f.isPrimaryKey){if("count"!==e){let n="query"===e&&l&&a.values&&o.query({...a,values:!1});return o[e].apply(this,arguments).then(t=>{if("query"===e){if(l&&a.values)return n.then(({result:e})=>(u.addKeys(e),t));let e=a.values?t.result.map(s):t.result;a.values?u.addKeys(e):d.addKeys(e)}else if("openCursor"===e){let e=a.values;return t&&Object.create(t,{key:{get:()=>(d.addKey(t.primaryKey),t.key)},primaryKey:{get(){let e=t.primaryKey;return d.addKey(e),e}},value:{get:()=>(e&&u.addKey(t.primaryKey),t.value)}})}return t})}d.add(t)}}return o[e].apply(this,arguments)}}),c}}}};class pu{constructor(e,n){var t;this._middlewares={},this.verno=0;const r=pu.dependencies;this._options=n={addons:pu.addons,autoOpen:!0,indexedDB:r.indexedDB,IDBKeyRange:r.IDBKeyRange,...n},this._deps={indexedDB:n.indexedDB,IDBKeyRange:n.IDBKeyRange};const{addons:o}=n;this._dbSchema={},this._versions=[],this._storeNames=[],this._allTables={},this.idbdb=null,this._novip=this;const a={dbOpenError:null,isBeingOpened:!1,onReadyBeingFired:null,openComplete:!1,dbReadyResolve:l4,dbReadyPromise:null,cancelOpen:l4,openCanceller:null,autoSchema:!0,PR1398_maxLoop:3};a.dbReadyPromise=new cx(e=>{a.dbReadyResolve=e}),a.openCanceller=new cx((e,n)=>{a.cancelOpen=n}),this._state=a,this.name=e,this.on=uc(this,"populate","blocked","versionchange","close",{ready:[ct,l4]}),this.on.ready.subscribe=lA(this.on.ready.subscribe,e=>(n,t)=>{pu.vip(()=>{let r=this._state;if(r.openComplete)r.dbOpenError||cx.resolve().then(n),t&&e(n);else if(r.onReadyBeingFired)r.onReadyBeingFired.push(n),t&&e(n);else{e(n);let r=this;t||e(function e(){r.on.ready.unsubscribe(n),r.on.ready.unsubscribe(e)})}})}),this.Collection=(t=this,uu(u$.prototype,function(e,n){this.db=t;let r=ui,o=null;if(n)try{r=n()}catch(e){o=e}let a=e._ctx,i=a.table,s=i.hook.reading.fire;this._ctx={table:i,index:a.index,isPrimKey:!a.index||i.schema.primKey.keyPath&&a.index===i.schema.primKey.name,range:r,keysOnly:!1,dir:"next",unique:"",algorithm:null,filter:null,replayFilter:null,justLimit:!0,isMatch:null,offset:0,limit:1/0,error:o,or:a.or,valueMapper:s!==l5?s:null}})),this.Table=function(e){return uu(ul.prototype,function(n,t,r){this.db=e,this._tx=r,this.name=n,this.schema=t,this.hook=e._allTables[n]?e._allTables[n].hook:uc(null,{creating:[l7,l4],reading:[l6,l5],updating:[ce,l4],deleting:[l9,l4]})})}(this),this.Transaction=function(e){return uu(uj.prototype,function(n,t,r,o,a){this.db=e,this.mode=n,this.storeNames=t,this.schema=r,this.chromeTransactionDurability=o,this.idbtrans=null,this.on=uc(this,"complete","error","abort"),this.parent=a||null,this.active=!0,this._reculock=0,this._blockedFuncs=[],this._resolve=null,this._reject=null,this._waitingFor=null,this._waitingQueue=null,this._spinCount=0,this._completion=new cx((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(),c3(e)})})}(this),this.Version=function(e){return uu(u0.prototype,function(n){this.db=e,this._cfg={version:n,storesSource:null,dbschema:{},tables:{},contentUpgrade:null}})}(this),this.WhereClause=function(e){return uu(uz.prototype,function(n,t,r){this.db=e,this._ctx={table:n,index:":id"===t?null:t,or:r};let o=e._deps.indexedDB;if(!o)throw new l1.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=uF(n.IDBKeyRange),this._createTransaction=(e,n,t,r)=>new this.Transaction(e,n,t,this._options.chromeTransactionDurability,r),this._fireOnBlocked=e=>{this.on("blocked").fire(e),c9.filter(e=>e.name===this.name&&e!==this&&!e._state.vcFired).map(n=>n.on("versionchange").fire(e))},this.use(u8),this.use(u9),this.use(pc),this.use(pn),this.vip=Object.create(this,{_vip:{value:!0}}),o.forEach(e=>e(this))}version(e){if(isNaN(e)||e<.1)throw new l1.Type("Given version is not a positive number");if(e=Math.round(10*e)/10,this.idbdb||this._state.isBeingOpened)throw new l1.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(uK),t.stores({}),this._state.autoSchema=!1,t)}_whenReady(e){return this.idbdb&&(this._state.openComplete||cv.letThrough||this._vip)?e():new cx((e,n)=>{if(this._state.openComplete)return n(new l1.DatabaseClosed(this._state.dbOpenError));if(!this._state.isBeingOpened){if(!this._options.autoOpen)return void n(new l1.DatabaseClosed);this.open().catch(l4)}this._state.dbReadyPromise.then(e,n)}).then(e)}use({stack:e,create:n,level:t,name:r}){r&&this.unuse({stack:e,name:r});let o=this._middlewares[e]||(this._middlewares[e]=[]);return o.push({stack:e,create:n,level:null==t?10:t,name:r}),o.sort((e,n)=>e.level-n.level),this}unuse({stack:e,name:n,create:t}){return e&&this._middlewares[e]&&(this._middlewares[e]=this._middlewares[e].filter(e=>t?e.create!==t:!!n&&e.name!==n)),this}open(){return function(e){var n;let t=e._state,{indexedDB:r}=e._deps;if(t.isBeingOpened||e.idbdb)return t.dbReadyPromise.then(()=>t.dbOpenError?c3(t.dbOpenError):e);lW&&(t.openCanceller._stackHolder=lH()),t.isBeingOpened=!0,t.dbOpenError=null,t.openComplete=!1;let o=t.openCanceller;function a(){if(t.openCanceller!==o)throw new l1.DatabaseClosed("db.open() was cancelled")}let i=t.dbReadyResolve,s=null,l=!1,c=()=>new cx((n,o)=>{if(a(),!r)throw new l1.MissingAPI;let i=e.name,c=t.autoSchema?r.open(i):r.open(i,Math.round(10*e.verno));if(!c)throw new l1.MissingAPI;c.onerror=uM(o),c.onblocked=cN(e._fireOnBlocked),c.onupgradeneeded=cN(n=>{if(s=c.transaction,t.autoSchema&&!e._options.allowEmptyDB){c.onerror=uO,s.abort(),c.result.close();let e=r.deleteDatabase(i);e.onsuccess=e.onerror=cN(()=>{o(new l1.NoSuchDatabase(`Database ${i} doesnt exist`))})}else{let t,r,i,d;s.onerror=uM(o);var a,u,p=n.oldVersion>0x4000000000000000?0:n.oldVersion;l=p<1,e._novip.idbdb=c.result,a=p/10,u=s,t=e._dbSchema,(r=e._createTransaction("readwrite",e._storeNames,t)).create(u),r._completion.catch(o),i=r._reject.bind(r),d=cv.transless||cv,cG(()=>{cv.trans=r,cv.transless=d,0===a?(ll(t).forEach(e=>{uJ(u,e,t[e].primKey,t[e].indexes)}),uH(e,u),cx.follow(()=>e.on.populate.fire(r)).catch(i)):(function({_novip:e},n,t,r){let o=[],a=e._versions,i=e._dbSchema=uX(e,e.idbdb,r),s=!1;return a.filter(e=>e._cfg.version>=n).forEach(a=>{o.push(()=>{let o=i,l=a._cfg.dbschema;uZ(e,o,r),uZ(e,l,r),i=e._dbSchema=l;let c=uY(o,l);c.add.forEach(e=>{uJ(r,e[0],e[1].primKey,e[1].indexes)}),c.change.forEach(e=>{if(e.recreate)throw new l1.Upgrade("Not yet support for changing primary key");{let n=r.objectStore(e.name);e.add.forEach(e=>uQ(n,e)),e.change.forEach(e=>{n.deleteIndex(e.name),uQ(n,e)}),e.del.forEach(e=>n.deleteIndex(e))}});let u=a._cfg.contentUpgrade;if(u&&a._cfg.version>n){let n;uH(e,r),t._memoizedTables={},s=!0;let a=lS(l);c.del.forEach(e=>{a[e]=o[e]}),uq(e,[e.Transaction.prototype]),uU(e,[e.Transaction.prototype],ll(a),a),t.schema=a;let i=lL(u);i&&cH();let p=cx.follow(()=>{if((n=u(t))&&i){var e=cU.bind(null,null);n.then(e,e)}});return n&&"function"==typeof n.then?cx.resolve(n):p.then(()=>n)}}),o.push(n=>{var r;s&&ue||(r=a._cfg.dbschema,[].slice.call(n.db.objectStoreNames).forEach(e=>null==r[e]&&n.db.deleteObjectStore(e))),uq(e,[e.Transaction.prototype]),uU(e,[e.Transaction.prototype],e._storeNames,e._dbSchema),t.schema=e._dbSchema})}),(function e(){return o.length?cx.resolve(o.shift()(t.idbtrans)).then(e):cx.resolve()})().then(()=>{var e;ll(e=i).forEach(n=>{r.db.objectStoreNames.contains(n)||uJ(r,n,e[n].primKey,e[n].indexes)})})})(e,a,r,u).catch(i)})}},o),c.onsuccess=cN(()=>{s=null;let r=e._novip.idbdb=c.result,o=l$(r.objectStoreNames);if(o.length>0)try{let n,a=r.transaction(1===o.length?o[0]:o,"readonly");t.autoSchema?function({_novip:e},n,t){e.verno=n.version/10;let r=e._dbSchema=uX(0,n,t);e._storeNames=l$(n.objectStoreNames,0),uU(e,[e._allTables],ll(r),r)}(e,r,a):(uZ(e,e._dbSchema,a),((n=uY(uX(0,e.idbdb,a),e._dbSchema)).add.length||n.change.some(e=>e.add.length||e.change.length))&&console.warn("Dexie SchemaDiff: Schema was extended without increasing the number passed to db.version(). Some queries may fail.")),uH(e,a)}catch(e){}c9.push(e),r.onversionchange=cN(n=>{t.vcFired=!0,e.on("versionchange").fire(n)}),r.onclose=cN(n=>{e.on("close").fire(n)}),l&&function({indexedDB:e,IDBKeyRange:n},t){u2(e)||t===ut||u1(e,n).put({name:t}).catch(l4)}(e._deps,i),n()},o)}).catch(e=>e&&"UnknownError"===e.name&&t.PR1398_maxLoop>0?(t.PR1398_maxLoop--,console.warn("Dexie: Workaround for Chrome UnknownError on open()"),c()):cx.reject(e));return cx.race([o,("u"<typeof navigator?cx.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(c)]).then(()=>(a(),t.onReadyBeingFired=[],cx.resolve(u3(()=>e.on.ready.fire(e.vip))).then(function n(){if(t.onReadyBeingFired.length>0){let r=t.onReadyBeingFired.reduce(ct,l4);return t.onReadyBeingFired=[],cx.resolve(u3(()=>r(e.vip))).then(n)}}))).finally(()=>{t.onReadyBeingFired=null,t.isBeingOpened=!1}).then(()=>e).catch(n=>{t.dbOpenError=n;try{s&&s.abort()}catch(e){}return o===t.openCanceller&&e._close(),c3(n)}).finally(()=>{t.openComplete=!0,i()})}(this)}_close(){let e=this._state,n=c9.indexOf(this);if(n>=0&&c9.splice(n,1),this.idbdb){try{this.idbdb.close()}catch(e){}this._novip.idbdb=null}e.dbReadyPromise=new cx(n=>{e.dbReadyResolve=n}),e.openCanceller=new cx((n,t)=>{e.cancelOpen=t})}close(){this._close();let e=this._state;this._options.autoOpen=!1,e.dbOpenError=new l1.DatabaseClosed,e.isBeingOpened&&e.cancelOpen(e.dbOpenError)}delete(){let e=arguments.length>0,n=this._state;return new cx((t,r)=>{let o=()=>{this.close();var e=this._deps.indexedDB.deleteDatabase(this.name);e.onsuccess=cN(()=>{!function({indexedDB:e,IDBKeyRange:n},t){u2(e)||t===ut||u1(e,n).delete(t).catch(l4)}(this._deps,this.name),t()}),e.onerror=uM(r),e.onblocked=this._fireOnBlocked};if(e)throw new l1.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 ll(this._allTables).map(e=>this._allTables[e])}transaction(){let e=u5.apply(this,arguments);return this._transaction.apply(this,e)}_transaction(e,n,t){let r,o,a=cv.trans;a&&a.db===this&&-1===e.indexOf("!")||(a=null);let i=-1!==e.indexOf("?");e=e.replace("!","").replace("?","");try{if(o=n.map(e=>{var n=e instanceof this.Table?e.name:e;if("string"!=typeof n)throw TypeError("Invalid table argument to Dexie.transaction(). Only Table or String are allowed");return n}),"r"==e||e===ur)r=ur;else{if("rw"!=e&&e!=uo)throw new l1.InvalidArgument("Invalid transaction mode: "+e);r=uo}if(a){if(a.mode===ur&&r===uo){if(!i)throw new l1.SubTransaction("Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY");a=null}a&&o.forEach(e=>{if(a&&-1===a.storeNames.indexOf(e)){if(!i)throw new l1.SubTransaction("Table "+e+" not included in parent transaction.");a=null}}),i&&a&&!a.active&&(a=null)}}catch(e){return a?a._promise(null,(n,t)=>{t(e)}):c3(e)}let s=(function e(n,t,r,o,a){return cx.resolve().then(()=>{let i,s=cv.transless||cv,l=n._createTransaction(t,r,n._dbSchema,o);if(o)l.idbtrans=o.idbtrans;else try{l.create(),n._state.PR1398_maxLoop=3}catch(o){return o.name===l0.InvalidState&&n.isOpen()&&--n._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),n._close(),n.open().then(()=>e(n,t,r,null,a))):c3(o)}let c=lL(a);c&&cH();let u=cx.follow(()=>{if(i=a.call(l,l))if(c){var e=cU.bind(null,null);i.then(e,e)}else"function"==typeof i.next&&"function"==typeof i.throw&&(i=u4(i))},{trans:l,transless:s});return(i&&"function"==typeof i.then?cx.resolve(i).then(e=>l.active?e:c3(new l1.PrematureCommit("Transaction committed too early. See http://bit.ly/2kdckMn"))):u.then(()=>i)).then(e=>(o&&l._resolve(),l._completion.then(()=>e))).catch(e=>(l._reject(e),c3(e)))})}).bind(null,this,r,o,a,t);return a?a._promise(r,s,"lock"):cv.trans?cX(cv.transless,()=>this._whenReady(s)):this._whenReady(s)}table(e){if(!lf(this._allTables,e))throw new l1.InvalidTable(`Table ${e} does not exist`);return this._allTables[e]}}let pp="u">typeof Symbol&&"observable"in Symbol?Symbol.observable:"@@observable";class pd{constructor(e){this._subscribe=e}subscribe(e,n,t){return this._subscribe(e&&"function"!=typeof e?e:{next:e,error:n,complete:t})}[pp](){return this}}function pf(e,n){return ll(n).forEach(t=>{pa(e[t]||(e[t]=new pr),n[t])}),e}try{o={indexedDB:ls.indexedDB||ls.mozIndexedDB||ls.webkitIndexedDB||ls.msIndexedDB,IDBKeyRange:ls.IDBKeyRange||ls.webkitIDBKeyRange}}catch(e){o={indexedDB:null,IDBKeyRange:null}}function ph(e){let n=pg;try{pg=!0,uI.storagemutated.fire(e)}finally{pg=n}}lh(pu,{...l3,delete:e=>new pu(e,{addons:[]}).delete(),exists:e=>new pu(e,{addons:[]}).open().then(e=>(e.close(),!0)).catch("NoSuchDatabaseError",()=>!1),getDatabaseNames(e){try{return(function({indexedDB:e,IDBKeyRange:n}){return u2(e)?Promise.resolve(e.databases()).then(e=>e.map(e=>e.name).filter(e=>e!==ut)):u1(e,n).toCollection().primaryKeys()})(pu.dependencies).then(e)}catch(e){return c3(new l1.MissingAPI)}},defineClass:()=>function(e){lu(this,e)},ignoreTransaction:e=>cv.trans?cX(cv.transless,e):e(),vip:u3,async:function(e){return function(){try{var n=u4(e.apply(this,arguments));return n&&"function"==typeof n.then?n:cx.resolve(n)}catch(e){return c3(e)}}},spawn:function(e,n,t){try{var r=u4(e.apply(t,n||[]));return r&&"function"==typeof r.then?r:cx.resolve(r)}catch(e){return c3(e)}},currentTransaction:{get:()=>cv.trans||null},waitFor:function(e,n){let t=cx.resolve("function"==typeof e?pu.ignoreTransaction(e):e).timeout(n||6e4);return cv.trans?cv.trans.waitFor(t):t},Promise:cx,debug:{get:()=>lW,set:e=>{lW=e,lV="dexie"===e?()=>!0:un}},derive:lb,extend:lu,props:lh,override:lA,Events:uc,on:uI,liveQuery:function(e){let n,t=!1,r=new pd(r=>{let o=lL(e),a=!1,i={},s={},l={get closed(){return a},unsubscribe:()=>{a=!0,uI.storagemutated.unsubscribe(d)}};r.start&&r.start(l);let c=!1,u=!1;function p(){return ll(s).some(e=>i[e]&&function(e,n){let t=pi(n),r=t.next();if(r.done)return!1;let o=r.value,a=pi(e),i=a.next(o.from),s=i.value;for(;!r.done&&!i.done;){if(0>=uy(s.from,o.to)&&uy(s.to,o.from)>=0)return!0;0>uy(o.from,s.from)?o=(r=t.next(s.from)).value:s=(i=a.next(o.from)).value}return!1}(i[e],s[e]))}let d=e=>{pf(i,e),p()&&f()},f=()=>{let h,g;if(c||a)return;i={};let m={},b=(o&&cH(),h=()=>cG(e,{subscr:m,trans:null}),g=cv.trans?cX(cv.transless,h):h(),o&&g.then(cU,cU),g);u||(uI(uP,d),u=!0),c=!0,Promise.resolve(b).then(e=>{t=!0,n=e,c=!1,a||(p()?f():(i={},s=m,r.next&&r.next(e)))},e=>{c=!1,t=!1,r.error&&r.error(e),l.unsubscribe()})};return f(),l});return r.hasValue=()=>t,r.getValue=()=>n,r},extendObservabilitySet:pf,getByKeyPath:lC,setByKeyPath:lE,delByKeyPath:function(e,n){"string"==typeof n?lE(e,n,void 0):"length"in n&&[].map.call(n,function(n){lE(e,n,void 0)})},shallowClone:lS,deepClone:lT,getObjectDiff:u7,cmp:uy,asap:lx,minKey:c6,addons:[],connections:c9,errnames:l0,dependencies:o,semVer:c4,version:c4.split(".").map(e=>parseInt(e)).reduce((e,n,t)=>e+n/Math.pow(10,2*t))}),pu.maxKey=uF(pu.dependencies.IDBKeyRange),"u">typeof dispatchEvent&&"u">typeof addEventListener&&(uI(uP,e=>{if(!pg){let n;ue?(n=document.createEvent("CustomEvent")).initCustomEvent(uT,!0,!0,e):n=new CustomEvent(uT,{detail:e}),pg=!0,dispatchEvent(n),pg=!1}}),addEventListener(uT,({detail:e})=>{pg||ph(e)}));let pg=!1;if("u">typeof BroadcastChannel){let e=new BroadcastChannel(uT);"function"==typeof e.unref&&e.unref(),uI(uP,n=>{pg||e.postMessage(n)}),e.onmessage=e=>{e.data&&ph(e.data)}}else if("u">typeof self&&"u">typeof navigator){uI(uP,e=>{try{pg||("u">typeof localStorage&&localStorage.setItem(uT,JSON.stringify({trig:Math.random(),changedParts:e})),"object"==typeof self.clients&&[...self.clients.matchAll({includeUncontrolled:!0})].forEach(n=>n.postMessage({type:uT,changedParts:e})))}catch(e){}}),"u">typeof addEventListener&&addEventListener("storage",e=>{if(e.key===uT){let n=JSON.parse(e.newValue);n&&ph(n.changedParts)}});let e=self.document&&navigator.serviceWorker;e&&e.addEventListener("message",function({data:e}){e&&e.type===uT&&ph(e.changedParts)})}function pm(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}cx.rejectionMapper=function(e,n){if(!e||e instanceof lJ||e instanceof TypeError||e instanceof SyntaxError||!e.name||!l2[e.name])return e;var t=new l2[e.name](n||e.message,e);return"stack"in e&&lm(t,"stack",{get:function(){return this.inner.stack}}),t},lV=un;class pb extends pu{constructor(){super("EsmOffline"),pm(this,"syncQueue",void 0),pm(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 py(){return new pb}let p_=new pb,pv={},p$=G("offline-synchronization",{});function pA(){return p$}async function pw(){if(p$.getState().synchronization)return;let e=await p_.syncQueue.count(),n={},t=Object.entries(pv),r=t.length,o={},a=new AbortController,i=()=>{let e=p$.getState().synchronization;p$.setState({synchronization:{...e,pendingCount:e.pendingCount-1}})};try{p$.setState({synchronization:{totalCount:e,pendingCount:e,abortController:a}});for(let e=0;e<r&&t.length>0;e++)for(let e=t.length;e--;){let[r,s]=t[e],l=s.dependsOn.map(e=>n[e]);l.every(Boolean)&&(o[r]={},await Promise.all(l),n[r]=px(s,o,a,i),t.splice(e,1))}await Promise.allSettled(Object.values(n))}finally{p$.setState({synchronization:void 0})}}async function px({type:e,dependsOn:n,process:t},r,o,a){let i=[],s=[],l=await pk();await p_.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[u,p,{id:d,dependencies:f=[]}]=i[c];try{let a=await t(p,{abort:o,index:c,items:s,userId:l,dependencies:f.map(({id:e,type:t})=>n.includes(t)?r[t][e]:void 0)});void 0!==d&&(r[e][d]=a),await p_.syncQueue.delete(u)}catch(e){await p_.syncQueue.update(u,{lastError:{name:e?.name,message:e?.message??e?.toString()}})}finally{a()}}}async function pk(){let e=await ii();return e?.uuid||"*"}async function pC(e,n,t,r){let o=r&&r.id;return void 0!==o&&await p_.syncQueue.where({type:n,userId:e}).filter(e=>e?.descriptor.id===o).delete().catch(pu.errnames.DatabaseClosed),await p_.syncQueue.add({type:n,content:t,userId:e,descriptor:r||{},createdOn:new Date}).catch(pu.errnames.DatabaseClosed,()=>-1)}async function pE(e,n,t){let r=await pk();return await pC(r,e,n,t)}async function pS(e,n){return(await pD(e,n)).map(e=>e.content)}async function pD(e,n){return await p_.syncQueue.where(n?{type:n,userId:e}:{userId:e}).toArray().catch(pu.errnames.DatabaseClosed,()=>[])}async function pz(e){let n=await pk();return await pS(n,e)}async function pM(e){let n=await pk();return await pD(n,e)}async function pO(e){return await p_.syncQueue.get(e).catch(pu.errnames.DatabaseClosed,()=>void 0)}function pP(e){return!!pv[e]?.options.onBeginEditSyncItem}async function pT(e){let n=await pO(e);if(!n)throw Error(`No sync item with the ID ${e} exists.`);let t=pv[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 pI(e){await p_.syncQueue.delete(e).catch(pu.errnames.DatabaseClosed)}function pj(e,n,t,r={}){pv[e]={type:e,dependsOn:n,process:t,options:r}}let pN="u">typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),pB=new Uint8Array(16),pR=[];for(let e=0;e<256;++e)pR.push((e+256).toString(16).slice(1));let pF=function(e,n,t){if(pN&&!n&&!e)return pN();let r=(e=e||{}).random||(e.rng||function(){if(!a&&!(a="u">typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)))throw Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return a(pB)})();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,n){t=t||0;for(let e=0;e<16;++e)n[t+e]=r[e];return n}return function(e,n=0){return pR[e[n+0]]+pR[e[n+1]]+pR[e[n+2]]+pR[e[n+3]]+"-"+pR[e[n+4]]+pR[e[n+5]]+"-"+pR[e[n+6]]+pR[e[n+7]]+"-"+pR[e[n+8]]+pR[e[n+9]]+"-"+pR[e[n+10]]+pR[e[n+11]]+pR[e[n+12]]+pR[e[n+13]]+pR[e[n+14]]+pR[e[n+15]]}(r)},pL="OFFLINE+";function pW(){return pL+pF()}function pV(e){return e.startsWith(pL)}let pG={};function pH(){return Object.values(pG)}function pU(e){pG[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.`),pG[e.id]=e}async function pq(e){let n=await p1();return await pK(n,e)}async function pK(e,n){let t=new pb;return await t.dynamicOfflineData.where(n?{type:n,users:e}:{users:e}).toArray().catch(pu.errnames.DatabaseClosed,()=>[])}async function pY(e,n){let t=await p1();return await pJ(t,e,n)}async function pJ(e,n,t){let r=new pb,o=await r.dynamicOfflineData.get({type:n,identifier:t}).catch(pu.errnames.DatabaseClosed,()=>void 0);o?o.users.includes(e)||await r.dynamicOfflineData.update(o.id,{users:[...o.users,e]}).catch(pu.errnames.DatabaseClosed):await r.dynamicOfflineData.add({users:[e],type:n,identifier:t}).catch(pu.errnames.DatabaseClosed)}async function pQ(e,n){let t=await p1();return await pX(t,e,n)}async function pX(e,n,t){let r=new pb,o=await r.dynamicOfflineData.get({type:n,identifier:t,users:e}).catch(pu.errnames.DatabaseClosed,()=>void 0);o&&(o.users.length>1?await r.dynamicOfflineData.update(o.id,{users:o.users.filter(n=>n!==e)}).catch(pu.errnames.DatabaseClosed):await r.dynamicOfflineData.delete(o.id).catch(pu.errnames.DatabaseClosed))}async function pZ(e,n){let t=await pq(e);await Promise.all(t.map(async e=>p0(e.type,e.identifier,n)))}async function p0(e,n,t){await pY(e,n);let r=new pb,o=await p1(),a=await r.dynamicOfflineData.get({type:e,identifier:n}).catch(pu.errnames.DatabaseClosed,()=>void 0),i=pH().filter(n=>n.type===e);if(!a)return;let s=await Promise.all(i.map(async e=>{try{return e.sync(n,t),{id:e.id,error:void 0}}catch(t){let n=t.message?.toString()??t.toString();return{id:e.id,error:n}}})),l=s.filter(e=>!e.error).map(e=>e.id),c=s.filter(e=>e.error).map(e=>e.id),u=s.filter(e=>e.error).map(e=>({handlerId:e.id,message:e.error})),p={syncedOn:new Date,syncedBy:o,succeededHandlers:l,erroredHandlers:c,errors:u};a.id&&await r.dynamicOfflineData.update(a.id,{syncState:p}).catch(pu.errnames.DatabaseClosed)}async function p1(){let e=(await ii()).uuid;if(!e)throw Error("Using the dynamic offline data API requires a logged in user.");return e}let p2=G("offline-patients",{offlinePatientDataSyncState:{},handlers:{}});function p3(){return p6(),p2}function p4(e,n){p6(),pU({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 p5(e){p6(),await p0("patient",e)}function p6(){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 p8(e,n,t=!0){if(e){let r=null,[o,a]=await Promise.all([a4(`${a1}/Patient/${e}`,n).catch(e=>r=e),t?p7(e):Promise.resolve(null)]);if(o.ok)return o.data;if(a)return a;if(r)throw r}return null}async function p7(e){let n=(await pz("patient-registration")).find(n=>n.fhirPatient.id===e);return n?.fhirPatient??null}function p9(e,n){let t=new CustomEvent(`openmrs:${e}`,{detail:n??void 0,cancelable:!0,bubbles:!0});return window.dispatchEvent(t)}function de(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 dn=t(6170);function dt(e){return{uuid:e.uuid,display:e.display}}function dr(e=null,n=null){let t=new URLSearchParams;e&&t.set("tag",e),n&&t.set("q",n);let r=t.toString();return a5(`${a0}/location${r?"?"+r:""}`).pipe((0,dn.map)(e=>e.data.results.map(dt))).pipe((0,dn.take)(1))}function da(e){return{uuid:e.uuid,display:e.display,name:e.name}}function di(){return a5(`${a0}/visittype`).pipe((0,dn.map)(e=>e.data.results.map(da))).pipe((0,dn.take)(1))}var ds=((eo={}).NEWVISIT="startVisit",eo.EDITVISIT="editVisit",eo.LOADING="loadingVisit",eo),dl=((ea={}).NOTSTARTED="notStarted",ea.ONGOING="ongoing",ea);let dc="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))",du=function(){try{return JSON.parse(sessionStorage.getItem("openmrs:visitStoreState")||"null")}catch(e){return null}}()||{patientUuid:null,manuallySetVisitUuid:null,mutateVisitCallbacks:{}};function dp(){return U("visit",du)}function dd(e,n){dp().setState({patientUuid:e,manuallySetVisitUuid:n})}function df(e,n){return a4(`${a0}/visit`,{signal:n.signal,method:"POST",headers:{"Content-type":"application/json"},body:e})}function dh(e,n,t){return a4(`${a0}/visit/${e}`,{signal:t.signal,method:"POST",headers:{"Content-type":"application/json"},body:n})}function dg(e,n,t){return a4(`${a0}/visit?patient=${e}&v=${t??dc}`,{signal:n.signal,method:"GET",headers:{"Content-type":"application/json"}})}dp().subscribe(e=>{var n;n=e,sessionStorage.setItem("openmrs:visitStoreState",JSON.stringify(n))});let dm=new ep.BehaviorSubject(null);class db{static get version(){return"1.4.0"}static toString(){return"JavaScript Expression Parser (JSEP) v"+db.version}static addUnaryOp(e){return db.max_unop_len=Math.max(e.length,db.max_unop_len),db.unary_ops[e]=1,db}static addBinaryOp(e,n,t){return db.max_binop_len=Math.max(e.length,db.max_binop_len),db.binary_ops[e]=n,t?db.right_associative.add(e):db.right_associative.delete(e),db}static addIdentifierChar(e){return db.additional_identifier_chars.add(e),db}static addLiteral(e,n){return db.literals[e]=n,db}static removeUnaryOp(e){return delete db.unary_ops[e],e.length===db.max_unop_len&&(db.max_unop_len=db.getMaxKeyLen(db.unary_ops)),db}static removeAllUnaryOps(){return db.unary_ops={},db.max_unop_len=0,db}static removeIdentifierChar(e){return db.additional_identifier_chars.delete(e),db}static removeBinaryOp(e){return delete db.binary_ops[e],e.length===db.max_binop_len&&(db.max_binop_len=db.getMaxKeyLen(db.binary_ops)),db.right_associative.delete(e),db}static removeAllBinaryOps(){return db.binary_ops={},db.max_binop_len=0,db}static removeLiteral(e){return delete db.literals[e],db}static removeAllLiterals(){return db.literals={},db}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 db(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 db.binary_ops[e]||0}static isIdentifierStart(e){return e>=65&&e<=90||e>=97&&e<=122||e>=128&&!db.binary_ops[String.fromCharCode(e)]||db.additional_identifier_chars.has(String.fromCharCode(e))}static isIdentifierPart(e){return db.isIdentifierStart(e)||db.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(db.hooks[e]){let t={context:this,node:n};return db.hooks.run(e,t),t.node}return n}searchHook(e){if(db.hooks[e]){let n={context:this};return db.hooks[e].find(function(e){return e.call(n.context,n),n.node}),n.node}}gobbleSpaces(){let e=this.code;for(;e===db.SPACE_CODE||e===db.TAB_CODE||e===db.LF_CODE||e===db.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:db.COMPOUND,body:e};return this.runHook("after-all",n)}gobbleExpressions(e){let n=[],t,r;for(;this.index<this.expr.length;)if((t=this.code)===db.SEMCOL_CODE||t===db.COMMA_CODE)this.index++;else if(r=this.gobbleExpression())n.push(r);else if(this.index<this.expr.length){if(t===e)break;this.throwError('Unexpected "'+this.char+'"')}return n}gobbleExpression(){let e=this.searchHook("gobble-expression")||this.gobbleBinaryExpression();return this.gobbleSpaces(),this.runHook("after-expression",e)}gobbleBinaryOp(){this.gobbleSpaces();let e=this.expr.substr(this.index,db.max_binop_len),n=e.length;for(;n>0;){if(db.binary_ops.hasOwnProperty(e)&&(!db.isIdentifierStart(this.code)||this.index+e.length<this.expr.length&&!db.isIdentifierPart(this.expr.charCodeAt(this.index+e.length))))return this.index+=n,e;e=e.substr(0,--n)}return!1}gobbleBinaryExpression(){let e,n,t,r,o,a,i,s,l;if(!(a=this.gobbleToken())||!(n=this.gobbleBinaryOp()))return a;for(o={value:n,prec:db.binaryPrecedence(n),right_a:db.right_associative.has(n)},(i=this.gobbleToken())||this.throwError("Expected expression after "+n),r=[a,o,i];n=this.gobbleBinaryOp();){if(0===(t=db.binaryPrecedence(n))){this.index-=n.length;break}o={value:n,prec:t,right_a:db.right_associative.has(n)},l=n;let s=e=>o.right_a&&e.right_a?t>e.prec:t<=e.prec;for(;r.length>2&&s(r[r.length-2]);)i=r.pop(),n=r.pop().value,a=r.pop(),e={type:db.BINARY_EXP,operator:n,left:a,right:i},r.push(e);(e=this.gobbleToken())||this.throwError("Expected expression after "+l),r.push(o,e)}for(s=r.length-1,e=r[s];s>1;)e={type:db.BINARY_EXP,operator:r[s-1].value,left:r[s-2],right:e},s-=2;return e}gobbleToken(){let e,n,t,r;if(this.gobbleSpaces(),r=this.searchHook("gobble-token"))return this.runHook("after-token",r);if(e=this.code,db.isDecimalDigit(e)||e===db.PERIOD_CODE)return this.gobbleNumericLiteral();if(e===db.SQUOTE_CODE||e===db.DQUOTE_CODE)r=this.gobbleStringLiteral();else if(e===db.OBRACK_CODE)r=this.gobbleArray();else{for(t=(n=this.expr.substr(this.index,db.max_unop_len)).length;t>0;){if(db.unary_ops.hasOwnProperty(n)&&(!db.isIdentifierStart(this.code)||this.index+n.length<this.expr.length&&!db.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:db.UNARY_EXP,operator:n,argument:e,prefix:!0})}n=n.substr(0,--t)}db.isIdentifierStart(e)?(r=this.gobbleIdentifier(),db.literals.hasOwnProperty(r.name)?r={type:db.LITERAL,value:db.literals[r.name],raw:r.name}:r.name===db.this_str&&(r={type:db.THIS_EXP})):e===db.OPAREN_CODE&&(r=this.gobbleGroup())}return r?(r=this.gobbleTokenProperty(r),this.runHook("after-token",r)):this.runHook("after-token",!1)}gobbleTokenProperty(e){this.gobbleSpaces();let n=this.code;for(;n===db.PERIOD_CODE||n===db.OBRACK_CODE||n===db.OPAREN_CODE||n===db.QUMARK_CODE;){let t;if(n===db.QUMARK_CODE){if(this.expr.charCodeAt(this.index+1)!==db.PERIOD_CODE)break;t=!0,this.index+=2,this.gobbleSpaces(),n=this.code}this.index++,n===db.OBRACK_CODE?((e={type:db.MEMBER_EXP,computed:!0,object:e,property:this.gobbleExpression()}).property||this.throwError('Unexpected "'+this.char+'"'),this.gobbleSpaces(),(n=this.code)!==db.CBRACK_CODE&&this.throwError("Unclosed ["),this.index++):n===db.OPAREN_CODE?e={type:db.CALL_EXP,arguments:this.gobbleArguments(db.CPAREN_CODE),callee:e}:(n===db.PERIOD_CODE||t)&&(t&&this.index--,this.gobbleSpaces(),e={type:db.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(;db.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);if(this.code===db.PERIOD_CODE)for(e+=this.expr.charAt(this.index++);db.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++));db.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);db.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+e+this.char+")")}return t=this.code,db.isIdentifierStart(t)?this.throwError("Variable names cannot start with a number ("+e+this.char+")"):(t===db.PERIOD_CODE||1===e.length&&e.charCodeAt(0)===db.PERIOD_CODE)&&this.throwError("Unexpected period"),{type:db.LITERAL,value:parseFloat(e),raw:e}}gobbleStringLiteral(){let e="",n=this.index,t=this.expr.charAt(this.index++),r=!1;for(;this.index<this.expr.length;){let n=this.expr.charAt(this.index++);if(n===t){r=!0;break}if("\\"===n)switch(n=this.expr.charAt(this.index++)){case"n":e+="\n";break;case"r":e+="\r";break;case"t":e+=" ";break;case"b":e+="\b";break;case"f":e+="\f";break;case"v":e+="\v";break;default:e+=n}else e+=n}return r||this.throwError('Unclosed quote after "'+e+'"'),{type:db.LITERAL,value:e,raw:this.expr.substring(n,this.index)}}gobbleIdentifier(){let e=this.code,n=this.index;for(db.isIdentifierStart(e)?this.index++:this.throwError("Unexpected "+this.char);this.index<this.expr.length;)if(e=this.code,db.isIdentifierPart(e))this.index++;else break;return{type:db.IDENTIFIER,name:this.expr.slice(n,this.index)}}gobbleArguments(e){let n=[],t=!1,r=0;for(;this.index<this.expr.length;){this.gobbleSpaces();let o=this.code;if(o===e){t=!0,this.index++,e===db.CPAREN_CODE&&r&&r>=n.length&&this.throwError("Unexpected token "+String.fromCharCode(e));break}if(o===db.COMMA_CODE){if(this.index++,++r!==n.length){if(e===db.CPAREN_CODE)this.throwError("Unexpected token ,");else if(e===db.CBRACK_CODE)for(let e=n.length;e<r;e++)n.push(null)}}else if(n.length!==r&&0!==r)this.throwError("Expected comma");else{let e=this.gobbleExpression();e&&e.type!==db.COMPOUND||this.throwError("Expected comma"),n.push(e)}}return t||this.throwError("Expected "+String.fromCharCode(e)),n}gobbleGroup(){this.index++;let e=this.gobbleExpressions(db.CPAREN_CODE);if(this.code===db.CPAREN_CODE)return(this.index++,1===e.length)?e[0]:!!e.length&&{type:db.SEQUENCE_EXP,expressions:e};this.throwError("Unclosed (")}gobbleArray(){return this.index++,{type:db.ARRAY_EXP,elements:this.gobbleArguments(db.CBRACK_CODE)}}}Object.assign(db,{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)})}}(db),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"}),db.max_unop_len=db.getMaxKeyLen(db.unary_ops),db.max_binop_len=db.getMaxKeyLen(db.binary_ops);let dy=e=>new db(e).parse(),d_=Object.getOwnPropertyNames(class{});Object.getOwnPropertyNames(db).filter(e=>!d_.includes(e)&&void 0===dy[e]).forEach(e=>{dy[e]=db[e]}),dy.Jsep=db,dy.plugins.register({name:"ternary",init(e){e.hooks.add("after-expression",function(n){if(n.node&&this.code===e.QUMARK_CODE){this.index++;let t=n.node,r=this.gobbleExpression();if(r||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===e.COLON_CODE){this.index++;let o=this.gobbleExpression();if(o||this.throwError("Expected expression"),n.node={type:"ConditionalExpression",test:t,consequent:r,alternate:o},t.operator&&e.binary_ops[t.operator]<=.9){let r=t;for(;r.right.operator&&e.binary_ops[r.right.operator]<=.9;)r=r.right;n.node.test=r.right,r.right=n.node,n.node=t}}else this.throwError("Expected :")}})}});let dv="ArrowFunctionExpression",d$={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)}},dA={...d$,Promise};function dw(e,n={}){return dD(e,n,dO)}async function dx(e,n={}){return dz(e,n,dO)}function dk(e,n={}){return dD(e,n,dP)}function dC(e,n={}){return dz(e,n,dP)}function dE(e,n={}){return dD(e,n,dT)}function dS(e,n={}){return dz(e,n,dT)}function dD(e,n={},t){if("string"!=typeof e&&("object"!=typeof e||!e||!("type"in e)))throw`Unknown expression type ${e}. Expressions must either be a string or pre-compiled string.`;if("string"==typeof e&&0===e.trim().length)throw{type:"Empty expression",message:"Expression cannot be an empty string"};null==n&&(n={});let r=dN(n,d$),o=dI("string"==typeof e?dy(e):e,r);if(t(o))return o;throw{type:"Invalid result",message:"string"==typeof e?`The expression ${e} did not produce a valid result`:"The expression did not produce a valid result"}}async function dz(e,n={},t){if("string"!=typeof e&&("object"!=typeof e||!e||!("type"in e)))return Promise.reject(`Unknown expression type ${e}. Expressions must either be a string or pre-compiled string.`);if("string"==typeof e&&0===e.trim().length)throw{type:"Empty expression",message:"Expression cannot be an empty string"};null==n&&(n={});let r=dN(n,dA);return Promise.resolve(dI("string"==typeof e?dy(e):e,r)).then(n=>{if(t(n))return n;throw{type:"Invalid result",message:"string"==typeof e?`The expression ${e} did not produce a valid result`:"The expression did not produce a valid result"}})}function dM(e){return dy(e)}function dO(e){return"string"==typeof e||"number"==typeof e||"boolean"==typeof e||null==e||e instanceof Date}function dP(e){return"boolean"==typeof e}function dT(e){return"number"==typeof e}function dI(e,n){switch(e.type){case"UnaryExpression":var t,r,o,a,i,s,l,c,u,p,d,f,h=e,g=n;let m=dI(h.argument,g);switch(h.operator){case"+":return+m;case"-":return-m;case"~":return~m;case"!":return!m;default:throw`Expression evaluator does not support operator '${h.operator}''`}case"BinaryExpression":var b=e,y=n;let v=dI(b.left,y),$=dI(b.right,y);switch(b.operator){case"+":return v+$;case"-":return v-$;case"*":return v*$;case"/":return v/$;case"%":return v%$;case"**":return v**$;case"==":return v==$;case"===":return v===$;case"!=":return v!=$;case"!==":return v!==$;case">":return v>$;case">=":return v>=$;case"<":return v<$;case"<=":return v<=$;case"in":return v in $;case"&&":return v&&$;case"||":return v||$;case"??":return v??$;default:throw`Expression evaluator does not support operator '${b.operator}' operator`}case"ConditionalExpression":return t=e,r=n,dI(t.test,r)?dI(t.consequent,r):dI(t.alternate,r);case"CallExpression":var A=e,w=n;let x=A.arguments?.map(dB(w)),k=dI(A.callee,w);if(k){if("function"!=typeof k)throw`${dF(A.callee)} is not a function`}else throw`No function named ${dF(A.callee)} is defined in this context`;return k(...x);case"ArrowFunctionExpression":let C;return o=e,a=n,C=o.params?.map(e=>{if("Identifier"===e.type)return e.name;throw`Cannot handle parameter of type ${e.type}`})??[],(function(...e){if(e.length<C.length)throw`Required argument(s) ${C.slice(e.length,-1).join(", ")} were not provided`;let n=Object.fromEntries(C.reduce((n,t,r)=>{let o=e[r];return function e(n){if("string"==typeof n||"number"==typeof n||"boolean"==typeof n||"function"==typeof n||null===n||n instanceof RegExp)return!0;if("object"==typeof n){for(let t of Object.keys(n))if(!e(n[t]))return!1;return!0}if(Array.isArray(n)){for(let t of n)if(!e(t))break}return!1}(o)&&n.push([t,o]),n},[]));return dI(o.body,a.addVariables(n))}).bind(a.thisObj??null);case"MemberExpression":return function(e,n){let t,r=dI(e.object,n);if(void 0===r)switch(e.object.type){case"Identifier":{let t=dj(e.object,n);throw ReferenceError(`ReferenceError: ${t} is not defined`)}case"MemberExpression":{let t=dj(e.property,n);throw TypeError(`TypeError: cannot read properties of undefined (reading '${t}')`)}default:throw`VisitMemberExpression does not support operator '${e.object.type}' type`}let o=r;if("string"==typeof r)o=String.prototype;else if("number"==typeof r)o=Number.prototype;else if("function"==typeof r);else if("object"!=typeof r)throw`VisitMemberExpression does not support member access on type ${typeof r}`;switch(n.thisObj=o,e.property.type){case"Identifier":case"MemberExpression":t=dI(e.property,n);break;default:{let o=dI(e.property,n);if(void 0===o)throw{type:"Illegal property access",message:"No property was supplied to the property access"};dR(o),t=r[o]}}return"function"==typeof t?t.bind(r):t}(e,n);case"ArrayExpression":return i=e,s=n,i.elements?.map(dB(s));case"SequenceExpression":let E;return l=e,c=n,(E=l.expressions.map(dB(c)))[E.length-1];case"NewExpression":var S=e,D=n;if(S.callee&&"Identifier"===S.callee.type){let e=S.arguments?.map(dB(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 dR((u=e).value),u.value;case"Identifier":var z=e,M=n;dR(z.name);let O=M.thisObj;if(O&&("object"==typeof O||"function"==typeof O)&&z.name in O){let e=O[z.name];return dR(e),e}if(M.variables&&z.name in M.variables){let e=M.variables[z.name];return dR(e),e}return z.name in M.globals?M.globals[z.name]:void 0;case"TemplateLiteral":let P,T;return p=e,d=n,P=p.expressions?.map(dB(d))??[],(T=p.quasis?.map(dB(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 dj(e,n){switch(e.type){case"Literal":return e.value;case"Identifier":return e.name;case"MemberExpression":return dj(e.property,n);default:throw`VisitExpressionName does not support expression of type '${e.type}'`}}function dN(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 dB(e){return function(n){return null===n?null:dI(n,e)}}function dR(e){if("__proto__"===e||"prototype"===e||"constructor"===e)throw{type:"Illegal property access",message:`Cannot access the ${e} property of objects`}}function dF(e){return e?"MemberExpression"===e.type?e.property?.name:e.name:null}function dL(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:{...dA},isLocalExpression:!1,variables:new Set};return dW("string"==typeof e?dy(e):e,n),[...n.variables]}function dW(e,n){switch(e.type){case"UnaryExpression":return r=e,o=n,dW(r.argument,o);case"BinaryExpression":return a=e,i=n,[dW(a.left,i),dW(a.right,i)].filter(Boolean);case"ConditionalExpression":return s=e,l=n,[dW(s.consequent,l),dW(s.test,l),dW(s.alternate,l)].filter(Boolean);case"CallExpression":let t;return c=e,u=n,t=dW(c.callee,u),c.arguments?.map(dV(u)),t;case"ArrowFunctionExpression":var r,o,a,i,s,l,c,u,p,d,f,h,g,m,b,y,v,$,A=e,w=n;let x={...w};x.isLocalExpression=!0;let k=A.params?.map(dV(x))??[],C=dW(A.body,x)??[];if(C&&Array.isArray(C))for(let e of C)k.includes(e)||w.variables.add(e);return;case"MemberExpression":let E;return p=e,d=n,dW(p.object,d),void((E={...d}).isLocalExpression=!0,dW(p.property,E));case"ArrayExpression":return f=e,h=n,void f.elements?.map(dV(h));case"SequenceExpression":return g=e,m=n,void g.expressions?.map(dV(m));case"NewExpression":return b=e,y=n,void b.arguments?.map(dV(y));case"Literal":case"TemplateElement":return;case"Identifier":var S=e,D=n;if(!(S.name in D.globals))if(D.isLocalExpression)return S.name;else D.variables.add(S.name);return;case"TemplateLiteral":return v=e,$=n,void(v.expressions?.map(dV($)),v.quasis?.map(dV($)));default:throw`Expression evaluator does not support expression of type '${e.type}'`}}function dV(e){return function(n){return null===n?null:dW(n,e)}}dy.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:dv,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=dv,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)})}}),dy.plugins.register({name:"new",init(e){e.addUnaryOp("new"),e.hooks.add("after-token",function(n){let t=n.node;if(t&&"new"===t.operator){t.argument&&[e.CALL_EXP,e.MEMBER_EXP].includes(t.argument.type)||this.throwError("Expected new function()"),n.node=t.argument;let r=n.node;for(;r.type===e.MEMBER_EXP||r.type===e.CALL_EXP&&r.callee.type===e.MEMBER_EXP;)r=r.type===e.MEMBER_EXP?r.object:r.callee.object;r.type="NewExpression"}})}}),dy.plugins.register({name:"numbers",init(e){function n(e){return"x"===e||"X"===e?(this.index+=2,[[48,57],[65,70],[97,102]]):"b"===e||"B"===e?(this.index+=2,[[48,49]]):"o"===e||"O"===e||e>="0"&&e<="7"?(this.index+=e<="7"?1:2,[[48,55]]):null}function t(n){let t=this.index,r="",o=()=>{for(;e.isDecimalDigit(this.code)||95===this.code;)95===this.code?this.index++:r+=this.expr.charAt(this.index++)};o(),this.code===e.PERIOD_CODE&&(r+=this.expr.charAt(this.index++),o());let a=this.char;("e"===a||"E"===a)&&(r+=this.expr.charAt(this.index++),("+"===(a=this.char)||"-"===a)&&(r+=this.expr.charAt(this.index++)),o(),e.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+r+this.char+")"));let i=this.code;if(e.isIdentifierStart(i))this.throwError("Variable names cannot start with a number ("+r+this.char+")");else if(i===e.PERIOD_CODE){r.length>1&&this.throwError(`Unexpected period ${JSON.stringify({chCode:i,number:r},null,2)}`),this.index=t;return}n.node={type:e.LITERAL,value:parseFloat(r),raw:this.expr.substring(t,this.index)}}e.hooks.add("gobble-token",function(r){if(48===this.code){var o,a,i;let s=this.index,l=this.expr.charAt(this.index+1),c=n.call(this,l);if(!c)return;let u="";for(;o=this.code,a=c,95===o||a.some(([e,n])=>o>=e&&o<=n);)95===this.code?this.index++:u+=this.expr.charAt(this.index++);if(e.isIdentifierPart(this.code)){if(e.isDecimalDigit(this.code)&&e.isDecimalDigit(l.charCodeAt(0))){this.index=s+1,t.call(this,r);return}this.throwError("unexpected char within number")}r.node={type:e.LITERAL,value:parseInt(u,"x"===(i=l)||"X"===i?16:"b"===i||"B"===i?2:8),raw:this.expr.substring(s,this.index)}}else(e.isDecimalDigit(this.code)||this.code===e.PERIOD_CODE)&&t.call(this,r)})}}),dy.plugins.register({name:"regex",init(e){e.hooks.add("gobble-token",function(n){if(47===this.code){let t=++this.index,r=!1;for(;this.index<this.expr.length;){if(47===this.code&&!r){let r,o=this.expr.slice(t,this.index),a="";for(;++this.index<this.expr.length;){let e=this.code;if(e>=97&&e<=122||e>=65&&e<=90||e>=48&&e<=57)a+=this.char;else break}try{r=new RegExp(o,a)}catch(e){this.throwError(e.message)}return n.node={type:e.LITERAL,value:r,raw:this.expr.slice(t-1,this.index)},n.node=this.gobbleTokenProperty(n.node),n.node}this.code===e.OBRACK_CODE?r=!0:r&&this.code===e.CBRACK_CODE&&(r=!1),this.index+=92===this.code?2:1}this.throwError("Unclosed Regex")}})}}),dy.plugins.register({name:"ternary",init(e){e.hooks.add("after-expression",function(n){if(n.node&&this.code===e.QUMARK_CODE){this.index++;let t=n.node,r=this.gobbleExpression();if(r||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===e.COLON_CODE){this.index++;let o=this.gobbleExpression();if(o||this.throwError("Expected expression"),n.node={type:"ConditionalExpression",test:t,consequent:r,alternate:o},t.operator&&e.binary_ops[t.operator]<=.9){let r=t;for(;r.right.operator&&e.binary_ops[r.right.operator]<=.9;)r=r.right;n.node.test=r.right,r.right=n.node,n.node=t}}else this.throwError("Expected :")}})}}),dy.plugins.register({name:"jsepTemplateLiteral",init(e){function n(e,t=!0){if(96===this.code){let n={type:"TemplateLiteral",quasis:[],expressions:[]},r="",o="",a=!1,i=this.expr.length,s=()=>n.quasis.push({type:"TemplateElement",value:{raw:o,cooked:r},tail:a});for(;this.index<i;){let i=this.expr.charAt(++this.index);if("`"===i)return this.index+=1,a=!0,s(),e.node=n,t&&(e.node=this.gobbleTokenProperty(e.node)),e.node;if("$"===i&&"{"===this.expr.charAt(this.index+1))this.index+=2,s(),o="",r="",n.expressions.push(...this.gobbleExpressions(125)),125!==this.code&&this.throwError("unclosed ${");else if("\\"===i)switch(o+=i,i=this.expr.charAt(++this.index),o+=i,i){case"n":r+="\n";break;case"r":r+="\r";break;case"t":r+=" ";break;case"b":r+="\b";break;case"f":r+="\f";break;case"v":r+="\v";break;default:r+=i}else r+=i,o+=i}this.throwError("Unclosed `")}}e.hooks.add("gobble-token",n),e.hooks.add("after-token",function(t){if((t.node.type===e.IDENTIFIER||t.node.type===e.MEMBER_EXP)&&96===this.code)return t.node={type:"TaggedTemplateExpression",tag:t.node,quasi:n.bind(this)(t,!1)},t.node=this.gobbleTokenProperty(t.node),t.node})}}),dy.addBinaryOp("in",7),dy.addBinaryOp("??",1);let dG=U("feature-flags",{flags:function(){let e={};for(let n of Object.keys(localStorage))if(n.startsWith("openmrs:feature-flag:")){let t=n.replace("openmrs:feature-flag:",""),r=JSON.parse(localStorage.getItem(`openmrs:feature-flag-meta:${t}`)||"{}");e[t]={enabled:"true"===localStorage.getItem(n),...r}}return e}()});function dH(e,n,t){dG.setState(r=>({flags:{...r.flags,[e]:{enabled:r.flags[e]?.enabled??!1,label:n,description:t}}}))}function dU(){let e=dG.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 dq(e){return dG.getState().flags[e].enabled}function dK(e,n){dG.subscribe(t=>{n(t.flags[e].enabled)})}function dY(e,n){dG.setState(t=>({flags:{...t.flags,[e]:{...t.flags[e],enabled:n}}}))}function dJ(e){return!window.offlineEnabled||(e??navigator.onLine)}dG.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 dQ=n0(function(e,n,t){nU(e,n,t)});function dX(e=!0,n=!1){return dZ(dJ(),e,n)}function dZ(e,n=!0,t=!1){return!!(e?n:t)}let d0=G("extensionsInternal",{slots:{},extensions:{}}),d1=()=>U("extensionsInternal",{slots:{},extensions:{}});function d2(e){let n=d0.getState(),t=e(n);t!==n&&d0.setState(t)}let d3=()=>U("extensions",{slots:{}});function d4(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});tI(rS.getState().mountedExtensions,n)||rS.setState({mountedExtensions:n})}d4(d0.getState()),d0.subscribe(d4);let d5=d1(),d6=d3(),d8=rz(),d7=rP();function d9(e,n,t,r,o){let a={},i=dJ(),s=Object.entries(r.flags).filter(([,{enabled:e}])=>e).map(([e])=>e);for(let[r,l]of Object.entries(e.slots)){let{config:c}=rO(n,l.name),u=fu(r,e,c,t,s,i,o.session);a[r]={moduleName:l.moduleName,assignedExtensions:u}}tI(d6.getState().slots,a)||d6.setState({slots:a})}function fe(){d9(d5.getState(),d8.getState(),d7.getState(),dG.getState(),a8.getState())}function fn(e,n,t){return{moduleName:n,name:e,attachedIds:[],config:null,state:t}}function ft(e){let[n]=e.split("#");return n}function fr(e,n){let t=ft(n);return e.extensions[t]}function fo(e){return fr(d5.getState(),e)}d5.subscribe(e=>{d9(e,d8.getState(),d7.getState(),dG.getState(),a8.getState())}),d8.subscribe(e=>{d9(d5.getState(),e,d7.getState(),dG.getState(),a8.getState())}),d7.subscribe(e=>{d9(d5.getState(),d8.getState(),e,dG.getState(),a8.getState())}),dG.subscribe(e=>{d9(d5.getState(),d8.getState(),d7.getState(),e,a8.getState())}),a8.subscribe(e=>{d9(d5.getState(),d8.getState(),d7.getState(),dG.getState(),e)}),fe(),m(fe);let fa=e=>d5.setState(n=>(n.extensions[e.name]={...e,instances:[]},n));function fi(e,n){d2(t=>{let r=t.slots[e];return r?{...t,slots:{...t.slots,[e]:{...r,attachedIds:[...r.attachedIds,n]}}}:{...t,slots:{...t.slots,[e]:{...fn(e),attachedIds:[n]}}}})}function fs(e,n){d2(t=>{let r=t.slots[e];return r&&r.attachedIds.includes(n)?{...t,slots:{...t.slots,[e]:{...r,attachedIds:r.attachedIds.filter(e=>e!==n)}}}:t})}function fl(e){d2(n=>{let t=n.slots[e];return t?{...n,slots:{...n.slots,[e]:{...t,attachedIds:[]}}}:n})}function fc(e,n,t,r){let o=n.indexOf(e);if(-1!==o)return o;{if(void 0!==t)return 1e3+t;let n=r.indexOf(e);return -1!==n?2e3+n:-1}}function fu(e,n,t,r,o,a,i){let s=function(e,n){let t=e.add||[],r=e.remove||[],o=e.order||[],{extensions:a}=d5.getState();return[...n,...t].filter(e=>!r.includes(e)).sort((e,t)=>{let r=fc(e,o,a[ft(e)]?.order,n),i=fc(t,o,a[ft(t)]?.order,n);return -1===i?-1:-1===r?1:r-i})}(t,n.slots[e].attachedIds),l=[],c=n.slots[e]?.state,u=c&&"object"==typeof c?{session:i,...c}:{session:i};for(let c of s){let{config:s}=rI(r,e,c),p=dQ(s,rj(t,e,c)),d=ft(c),f=n.extensions[d];if(f){let n=p?.["Display conditions"]?.privileges??f.privileges??[];if(n&&("string"==typeof n||Array.isArray(n)&&n.length>0)&&(!i?.user||!ia(n,i.user)))continue;let t=p?.["Display conditions"]?.expression||f.displayExpression;if(void 0!==t&&"string"==typeof t&&t.trim().length>0)try{if(!dk(t,u))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&&!dZ(a,f.online,f.offline))continue;l.push({id:c,name:d,moduleName:f.moduleName,config:p,featureFlag:f.featureFlag,meta:f.meta,online:p?.["Display conditions"]?.online??f.online??!0,offline:p?.["Display conditions"]?.offline??f.offline??!1})}}return l}function fp(e){let n=d5.getState(),{config:t}=rM(e),r=d7.getState(),o=dG.getState(),a=a8.getState(),i=dJ();return fu(e,n,t,r,Object.entries(o.flags).filter(([,{enabled:e}])=>e).map(([e])=>e),i,a.session)}let fd=(e,n,t)=>d5.setState(r=>{let o=r.slots[n]?.moduleName;if(o&&o!=e)return console.warn(`An extension slot with the name '${n}' already exists. Refusing to register the same slot name twice (in "registerExtensionSlot"). The existing one is from module ${o}.`),r;if(o&&o==e)return r;if(r.slots[n])return{...r,slots:{...r.slots,[n]:{...r.slots[n],moduleName:e,state:t}}};let a=fn(n,e,t);return{...r,slots:{...r.slots,[n]:{...a}}}});function ff(e,n,t=!1){d5.setState(r=>{let o=t?dQ(r.slots[e].state,n):n;return{...r,slots:{...r.slots,[e]:{...r.slots[e],state:o}}}})}let fh=()=>d6.setState(()=>({slots:{},extensions:{}})),fg=G("left-nav",{slotName:null,basePath:window.spaBase,mode:"normal"});function fm({name:e,basePath:n,mode:t,componentContext:r,state:o}){fg.setState({slotName:e,basePath:n,mode:t??"normal",componentContext:r,state:o})}function fb(e){fg.getState().slotName===e&&fg.setState(fg.getInitialState(),!0)}let fy=G("modalRegistry",{modals:{}});function f_(e){fy.setState(n=>(n.modals[e.name]=e,n))}function fv(e){let n=fy.getState().modals[e];if(!n){let t=fo(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.`),f_(n))}return n}let f$=G("workspaceRegistrations",{workspaces:{}}),fA=G("workspaceGroups",{workspaceGroups:{}});function fw(e){f$.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 fx(e){fA.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 fk=new Set;function fC(e){let n=f$.getState().workspaces;if(n[e])return n[e];{let n=fo(e);if(n){var t;let r;return fk.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.`),fk.add(e)),{name:n.name,title:(t=n,"string"==typeof(r=t?.meta?.title)?r:r&&"object"==typeof r?i5(t.moduleName,r.key,r.default):t.name),moduleName:n.moduleName,preferredWindowSize:n.meta?.screenSize??"normal",load:n.load,type:n.meta?.type??"form",canHide:n.meta?.canHide??!1,canMaximize:n.meta?.canMaximize??!1,width:n.meta?.width??"narrow",groups:n.meta?.groups??[]}}throw Error(`No workspace named '${e}' has been registered.`)}}function fE(e){let n=fA.getState().workspaceGroups;if(n[e])return n[e];throw Error(`No workspace group named '${e}' has been registered.`)}let fS=G("workspace2",{registeredGroupsByName:{},registeredWindowsByName:{},registeredWorkspacesByName:{},openedGroup:null,openedWindows:[],workspaceTitleByWorkspaceName:{},isMostRecentlyOpenedWindowHidden:!1});function fD(e){let{registeredWorkspacesByName:n,registeredWindowsByName:t}=fS.getState(),r=n[e];if(r){let n=t[r.window];if(n)return n;throw Error(`No workspace window found with name: ${r.window} for workspace: ${e}`)}throw Error(`No workspace found with name: ${e}`)}function fz(e){let{registeredGroupsByName:n,registeredWindowsByName:t}=fS.getState(),r=t[e];if(r){let t=n[r.group];if(t)return t;throw Error(`No workspace group found with name: ${r.group} for window: ${e}`)}throw Error(`No workspace window found with name: ${e}`)}function fM(e){let{openedWindows:n}=fS.getState();return n.findIndex(n=>n.openedWorkspaces.find(n=>n.workspaceName===e))}function fO(e,n){if(0==n.length)return;let{registeredGroupsByName:t}=fS.getState(),r={...t};for(let t of n){if(r[t.name])throw Error(`Cannot register workspace group ${t.name} more than once`);r[t.name]={...t,moduleName:e}}fS.setState({registeredGroupsByName:r})}function fP(e,n){if(0==n.length)return;let{registeredWindowsByName:t}=fS.getState(),r={...t};for(let t of n){if(r[t.name])throw Error(`Cannot register workspace window ${t.name} more than once`);let n={...t,moduleName:e};r[t.name]=n}fS.setState({registeredWindowsByName:r})}function fT(e,n){if(0==n.length)return;let{registeredWorkspacesByName:t}=fS.getState(),r={...t};for(let t of n){if(r[t.name])throw Error(`Cannot register workspace ${t.name} more than once`);let n={...t,moduleName:e};r[t.name]=n}fS.setState({registeredWorkspacesByName:r})}let fI=0;async function fj(e,n,t,r,o=e=>e,a={}){let i=ft(r),s=fo(r),l=null;if(e){if(!s)throw Error(`Couldn't find extension '${i}' to attach to '${n}'`);let{meta:c,moduleName:u,online:p,offline:d,load:f}=s;if(dX(p,d)){d2(o=>({...o,extensions:{...o.extensions,[i]:{...o.extensions[i],instances:[...o.extensions[i].instances,{domElement:e,id:r,slotName:n,slotModuleName:t}]}}}));let s=await f(),p=fI++;l=o2(o({...s,name:`${n}/${i}-${p}`}),{...a,_meta:c,_extensionContext:{extensionId:r,extensionSlotName:n,extensionSlotModuleName:t,extensionModuleName:u},domElement:e})}}else console.warn(`Tried to render ${r} into ${n} but no DOM element was available.`);return l}var fN=t(6711),fB=t.n(fN);let fR=(0,fN.createContext)({moduleName:"",featureName:""});function fF({to:e,templateParams:n,onBeforeNavigate:t,children:r,...o}){return(0,fN.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}`)},[]),fB().createElement("a",{onClick:r=>{0===r.button&&!r.ctrlKey&&!r.shiftKey&&!r.altKey&&!r.metaKey&&(r.preventDefault(),t?.(r),aG({to:e,templateParams:n})),0===r.button&&(r.ctrlKey||r.metaKey)&&t?.(r),0===r.button&&r.shiftKey&&t?.(r),1===r.button&&t?.(r)},href:aW(e,n),...o},r)}let fL=({state:e,children:n,...t})=>{let{extension:r}=(0,fN.useContext)(fR),o=(0,fN.useRef)(null),a=(0,fN.useRef)(Promise.resolve()),i=(0,fN.useCallback)(n=>{r?.extensionSlotName&&r.extensionSlotModuleName&&r.extensionSlotModuleName&&!o.current&&fj(n,r.extensionSlotName,r.extensionSlotModuleName,r.extensionId,void 0,e).then(e=>{o.current=e})},[]);return(0,fN.useEffect)(()=>()=>{if(o&&o.current)switch(o.current.getStatus()){case"MOUNTING":o.current.mountPromise.then(()=>{o.current?.getStatus()==="MOUNTED"&&o.current.unmount()});break;case"MOUNTED":o.current.unmount();break;case"UPDATING":a.current&&a.current.then(()=>{o.current?.getStatus()==="MOUNTED"&&o.current.unmount()})}},[]),(0,fN.useEffect)(()=>{o.current&&o.current.update&&"UNMOUNTING"!==o.current.getStatus()&&Promise.all([o.current.mountPromise,a.current]).then(()=>{o?.current?.getStatus()==="MOUNTED"&&o.current.update&&(a.current=o.current.update({...e}).catch(e=>{if(!(e instanceof Error)||!e.message.includes("minified message #32")||o.current?.getStatus()==="MOUNTED")throw e}))})},[e]),r?fB().createElement("div",{ref:i,"data-extension-id":r?.extensionId,style:{position:"relative"},...t}):null};function fW(e,n){"function"==typeof n&&(n=n(e));let t={};for(let[r,o]of Object.entries(n)){let n=function(...n){e.setState(e=>o(e,...n))};t[r]=n}return t}let fV=()=>e=>e;function fG(e,n=fV(),t){let r=(0,fN.useCallback)(n=>e.subscribe(n),[e]),o=(0,fN.useCallback)(()=>n(e.getState()),[e,n]),a=(0,fN.useSyncExternalStore)(r,o,o),i=(0,fN.useMemo)(()=>t?fW(e,t):{},[e,t]);return{...a,...i}}function fH(e,n){return fG(e,fV(),n)}function fU(e){return function(n){let t=(0,fN.useCallback)(n=>e.subscribe(n),[]),r=(0,fN.useCallback)(()=>e.getState(),[]),o=(0,fN.useSyncExternalStore)(t,r,r),a=(0,fN.useMemo)(()=>n?fW(e,n):{},[n]);return{...o,...a}}}let fq=e=>fG(d3(),n=>n.slots?.[e]);function fK(e){let n=fq(e);return n?.assignedExtensions??[]}function fY(e,n){let{moduleName:t}=(0,fN.useContext)(fR),r=(0,fN.useRef)(!0);if(!t)throw Error("ComponentContext has not been provided. This should come from @openmrs/esm-react-utils.");return(0,fN.useEffect)(()=>{fd(t,e,n),r.current=!1},[]),(0,fN.useEffect)(()=>{r.current||ff(e,n)},[e,n]),{extensions:fK(e),extensionSlotName:e,extensionSlotModuleName:t}}function fJ(e){return e}function fQ({name:e,extensionSlotName:n,select:t=fJ,children:r,state:o,style:a,...i}){if(r&&o)throw Error("Both children and state have been provided. If children are provided, the state must be passed as a prop to the `Extension` component.");let s=e??n,l=(0,fN.useRef)(null),{extensions:c,extensionSlotModuleName:u}=fY(s,o),p=(0,fN.useMemo)(()=>t(c),[t,c]),d=(0,fN.useMemo)(()=>{if("function"==typeof r&&!fB().isValidElement(r))return p.map(e=>r(e,o))},[r,p]);return fB().createElement("div",{ref:l,"data-extension-slot-name":s,"data-extension-slot-module-name":u,style:{...a,position:"relative"},...i},s&&p?.map((e,n)=>fB().createElement(fR.Provider,{key:e.id,value:{moduleName:u,featureName:"",extension:{extensionId:e.id,extensionSlotName:s,extensionSlotModuleName:u}}},d?.[n]??("function"!=typeof r?r:null)??fB().createElement(fL,{state:o}))))}var fX=t(5338);function fZ(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),t.push.apply(t,r)}return t}function f0(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?fZ(Object(t),!0).forEach(function(n){var r,o,a;r=e,o=n,a=t[n],o in r?Object.defineProperty(r,o,{value:a,enumerable:!0,configurable:!0,writable:!0}):r[o]=a}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):fZ(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})}return e}function f1(e){return(f1="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 f2(e){return(f2="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 f3(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(f2(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(f2(e)));return e}}var f4=null;try{f4=require("react").createContext()}catch(e){}var f5={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 f6(e,n){return e.rootComponent?Promise.resolve():e.loadRootComponent(n).then(function(n){e.rootComponent=n})}function f8(e,n){return new Promise(function(t,r){e.suppressComponentDidCatchWarning||!function(e){if(!(e&&"string"==typeof e.version&&e.version.indexOf(".")>=0))return!1;var n=e.version.slice(0,e.version.indexOf("."));try{return Number(n)>=16}catch(e){return!1}}(e.React)||e.errorBoundary||e.errorBoundaryClass||(e.rootComponent.prototype?e.rootComponent.prototype.componentDidCatch||console.warn("single-spa-react: ".concat(n.name||n.appName||n.childAppName,"'s rootComponent should implement componentDidCatch to avoid accidentally unmounting the entire single-spa application.")):console.warn("single-spa-react: ".concat(n.name||n.appName||n.childAppName,"'s rootComponent does not implement an error boundary. If using a functional component, consider providing an opts.errorBoundary to singleSpaReact(opts).")));var o,a=hn(e,n,function(){t(this)}),i=f3(e,n)(),s=function(e){var n=e.reactDom,t=e.renderType,r=e.elementToRender,o=e.domElement,a=n[t];if("function"!=typeof a)throw Error('renderType "'.concat(t,'" did not return a function.'));switch(t){case"createRoot":case"unstable_createRoot":case"createBlockingRoot":case"unstable_createBlockingRoot":var i=a(o);return i.render(r),i;case"hydrateRoot":return a(o,r);default:return a(r,o),null}}({elementToRender:a,domElement:i,reactDom:he(e),renderType:"function"==typeof(o=e).renderType?o.renderType():o.renderType});e.domElements[n.name]=i,e.renderResults[n.name]=s})}function f7(e,n){return new Promise(function(t){e.unmountResolves[n.name]=t;var r=e.renderResults[n.name];r&&r.unmount?r.unmount():he(e).unmountComponentAtNode(e.domElements[n.name]),delete e.domElements[n.name],delete e.renderResults[n.name]})}function f9(e,n){return new Promise(function(t){e.updateResolves[n.name]||(e.updateResolves[n.name]=[]),e.updateResolves[n.name].push(t);var r=hn(e,n,null),o=e.renderResults[n.name];if(o&&o.render)o.render(r);else{var a=f3(e,n)();he(e).render(r,a)}})}function he(e){return e.ReactDOMClient||e.ReactDOM}function hn(e,n,t){var r=e.React.createElement(e.rootComponent,n),o=f4?e.React.createElement(f4.Provider,{value:n},r):r;return(e.errorBoundary||n.errorBoundary||e.errorBoundaryClass||n.errorBoundaryClass)&&(e.errorBoundaryClass=e.errorBoundaryClass||n.errorBoundaryClass||function(e,n){function t(n){e.React.Component.apply(this,arguments),this.state={caughtError:null,caughtErrorInfo:null},t.displayName="SingleSpaReactErrorBoundary(".concat(n.name,")")}return t.prototype=Object.create(e.React.Component.prototype),t.prototype.render=function(){return this.state.caughtError?(e.errorBoundary||n.errorBoundary)(this.state.caughtError,this.state.caughtErrorInfo,this.props):this.props.children},t.prototype.componentDidCatch=function(e,n){this.setState({caughtError:e,caughtErrorInfo:n})},t}(e,n),o=e.React.createElement(e.errorBoundaryClass,n,o)),o=e.React.createElement(e.SingleSpaRoot,f0(f0({},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 ht=t(7775),hr=t(9888);let ho=()=>{},ha=ho(),hi=Object,hs=e=>e===ha,hl=(e,n)=>({...e,...n}),hc=new WeakMap,hu=0,hp=e=>{let n,t,r=typeof e,o=e&&e.constructor,a=o==Date;if(hi(e)!==e||a||o==RegExp)n=a?e.toJSON():"symbol"==r?e.toString():"string"==r?JSON.stringify(e):""+e;else{if(n=hc.get(e))return n;if(n=++hu+"~",hc.set(e,n),o==Array){for(t=0,n="@";t<e.length;t++)n+=hp(e[t])+",";hc.set(e,n)}if(o==hi){n="#";let r=hi.keys(e).sort();for(;!hs(t=r.pop());)hs(e[t])||(n+=t+":"+hp(e[t])+",");hc.set(e,n)}}return n},hd=new WeakMap,hf={},hh={},hg="undefined",hm=typeof window!=hg,hb=typeof document!=hg,hy=(e,n)=>{let t=hd.get(e);return[()=>!hs(n)&&e.get(n)||hf,r=>{if(!hs(n)){let o=e.get(n);n in hh||(hh[n]=o),t[5](n,hl(o,r),o||hf)}},t[6],()=>!hs(n)&&n in hh?hh[n]:!hs(n)&&e.get(n)||hf]},h_=!0,[hv,h$]=hm&&window.addEventListener?[window.addEventListener.bind(window),window.removeEventListener.bind(window)]:[ho,ho],hA={initFocus:e=>(hb&&document.addEventListener("visibilitychange",e),hv("focus",e),()=>{hb&&document.removeEventListener("visibilitychange",e),h$("focus",e)}),initReconnect:e=>{let n=()=>{h_=!0,e()},t=()=>{h_=!1};return hv("online",n),hv("offline",t),()=>{h$("online",n),h$("offline",t)}}},hw=!fB().useId,hx=!hm||"Deno"in window,hk=e=>hm&&typeof window.requestAnimationFrame!=hg?window.requestAnimationFrame(e):setTimeout(e,1),hC=hx?fN.useEffect:fN.useLayoutEffect,hE="u">typeof navigator&&navigator.connection,hS=!hx&&hE&&(["slow-2g","2g"].includes(hE.effectiveType)||hE.saveData),hD=e=>{if("function"==typeof e)try{e=e()}catch(n){e=""}let n=e;return[e="string"==typeof e?e:(Array.isArray(e)?e.length:e)?hp(e):"",n]},hz=0,hM=()=>++hz;async function hO(...e){let[n,t,r,o]=e,a=hl({populateCache:!0,throwOnError:!0},"boolean"==typeof o?{revalidate:o}:o||{}),i=a.populateCache,s=a.rollbackOnError,l=a.optimisticData,c=a.throwOnError;if("function"==typeof t){let e=[];for(let r of n.keys())!/^\$(inf|sub)\$/.test(r)&&t(n.get(r)._k)&&e.push(r);return Promise.all(e.map(u))}return u(t);async function u(t){let o,[u]=hD(t);if(!u)return;let[p,d]=hy(n,u),[f,h,g,m]=hd.get(n),b=()=>{let e=f[u];return("function"==typeof a.revalidate?a.revalidate(p().data,t):!1!==a.revalidate)&&(delete g[u],delete m[u],e&&e[0])?e[0](2).then(()=>p().data):p().data};if(e.length<3)return b();let y=r,v=hM();h[u]=[v,0];let $=!hs(l),A=p(),w=A.data,x=A._c,k=hs(x)?w:x;if($&&d({data:l="function"==typeof l?l(k,w):l,_c:k}),"function"==typeof y)try{y=y(k)}catch(e){o=e}if(y&&"function"==typeof y.then){let e;if(y=await y.catch(e=>{o=e}),v!==h[u][0]){if(o)throw o;return y}o&&$&&(e=o,"function"==typeof s?s(e):!1!==s)&&(i=!0,d({data:k,_c:ha}))}if(i&&!o&&("function"==typeof i?d({data:i(y,k),error:ha,_c:ha}):d({data:y,error:ha,_c:ha})),h[u][1]=hM(),Promise.resolve(b()).then(()=>{d({_c:ha})}),o){if(c)throw o;return}return y}}let hP=(e,n)=>{for(let t in e)e[t][0]&&e[t][0](n)},hT=(e,n)=>{if(!hd.has(e)){let t=hl(hA,n),r={},o=hO.bind(ha,e),a=ho,i={},s=(e,n)=>{let t=i[e]||[];return i[e]=t,t.push(n),()=>t.splice(t.indexOf(n),1)},l=(n,t,r)=>{e.set(n,t);let o=i[n];if(o)for(let e of o)e(t,r)},c=()=>{if(!hd.has(e)&&(hd.set(e,[r,{},{},{},o,l,s]),!hx)){let n=t.initFocus(setTimeout.bind(ha,hP.bind(ha,r,0))),o=t.initReconnect(setTimeout.bind(ha,hP.bind(ha,r,1)));a=()=>{n&&n(),o&&o(),hd.delete(e)}}};return c(),[e,o,c,a]}return[e,hd.get(e)[4]]},[hI,hj]=hT(new Map),hN=hl({onLoadingSlow:ho,onSuccess:ho,onError:ho,onErrorRetry:(e,n,t,r,o)=>{let a=t.errorRetryCount,i=o.retryCount,s=~~((Math.random()+.5)*(1<<(i<8?i:8)))*t.errorRetryInterval;(hs(a)||!(i>a))&&setTimeout(r,s,o)},onDiscarded:ho,revalidateOnFocus:!0,revalidateOnReconnect:!0,revalidateIfStale:!0,shouldRetryOnError:!0,errorRetryInterval:hS?1e4:5e3,focusThrottleInterval:5e3,dedupingInterval:2e3,loadingTimeout:hS?5e3:3e3,compare:(e,n)=>hp(e)==hp(n),isPaused:()=>!1,cache:hI,mutate:hj,fallback:{}},{isOnline:()=>h_,isVisible:()=>{let e=hb&&document.visibilityState;return hs(e)||"hidden"!==e}}),hB=(e,n)=>{let t=hl(e,n);if(n){let{use:r,fallback:o}=e,{use:a,fallback:i}=n;r&&a&&(t.use=r.concat(a)),o&&i&&(t.fallback=hl(o,i))}return t},hR=(0,fN.createContext)({}),hF=e=>{let{value:n}=e,t=(0,fN.useContext)(hR),r="function"==typeof n,o=(0,fN.useMemo)(()=>r?n(t):n,[r,t,n]),a=(0,fN.useMemo)(()=>r?o:hB(t,o),[r,t,o]),i=o&&o.provider,s=(0,fN.useRef)(ha);i&&!s.current&&(s.current=hT(i(a.cache||hI),o));let l=s.current;return l&&(a.cache=l[0],a.mutate=l[1]),hC(()=>{if(l)return l[2]&&l[2](),l[3]},[]),(0,fN.createElement)(hR.Provider,hl(e,{value:a}))},hL="$inf$",hW=hm&&window.__SWR_DEVTOOLS_USE__,hV=hW?window.__SWR_DEVTOOLS_USE__:[],hG=e=>"function"==typeof e[1]?[e[0],e[1],e[2]||{}]:[e[0],null,(null===e[1]?e[2]:e[1])||{}],hH=hV.concat(e=>(n,t,r)=>{let o=t&&((...e)=>{let[r]=hD(n),[,,,o]=hd.get(hI);if(r.startsWith(hL))return t(...e);let a=o[r];return hs(a)?t(...e):(delete o[r],a)});return e(n,o,r)}),hU=e=>function(...n){let t=hl(hN,(0,fN.useContext)(hR)),[r,o,a]=hG(n),i=hB(t,a),s=e,{use:l}=i,c=(l||[]).concat(hH);for(let e=c.length;e--;)s=c[e](s);return s(r,o||i.fetcher||null,i)},hq=(e,n,t)=>{let r=n[e]||(n[e]=[]);return r.push(t),()=>{let e=r.indexOf(t);e>=0&&(r[e]=r[r.length-1],r.pop())}},hK=(e,n)=>(...t)=>{let[r,o,a]=hG(t),i=(a.use||[]).concat(n);return e(r,o,{...a,use:i})};hW&&(window.__SWR_DEVTOOLS_REACT__=fB());let hY=fB().use||(e=>{if("pending"===e.status)throw e;if("fulfilled"===e.status)return e.value;if("rejected"===e.status)throw e.reason;throw e.status="pending",e.then(n=>{e.status="fulfilled",e.value=n},n=>{e.status="rejected",e.reason=n}),e}),hJ={dedupe:!0},hQ=hi.defineProperty(hF,"defaultValue",{value:hN}),hX=hU((e,n,t)=>{let{cache:r,compare:o,suspense:a,fallbackData:i,revalidateOnMount:s,revalidateIfStale:l,refreshInterval:c,refreshWhenHidden:u,refreshWhenOffline:p,keepPreviousData:d}=t,[f,h,g,m]=hd.get(r),[b,y]=hD(e),v=(0,fN.useRef)(!1),$=(0,fN.useRef)(!1),A=(0,fN.useRef)(b),w=(0,fN.useRef)(n),x=(0,fN.useRef)(t),k=()=>x.current.isVisible()&&x.current.isOnline(),[C,E,S,D]=hy(r,b),z=(0,fN.useRef)({}).current,M=hs(i)?t.fallback[b]:i,O=(e,n)=>{for(let t in z)if("data"===t){if(!o(e[t],n[t])&&(!hs(e[t])||!o(L,n[t])))return!1}else if(n[t]!==e[t])return!1;return!0},P=(0,fN.useMemo)(()=>{let e=!!b&&!!n&&(hs(s)?!x.current.isPaused()&&!a&&(!!hs(l)||l):s),t=n=>{let t=hl(n);return(delete t._k,e)?{isValidating:!0,isLoading:!0,...t}:t},r=C(),o=D(),i=t(r),c=r===o?i:t(o),u=i;return[()=>{let e=t(C());return O(e,u)?(u.data=e.data,u.isLoading=e.isLoading,u.isValidating=e.isValidating,u.error=e.error,u):(u=e,e)},()=>c]},[r,b]),T=(0,hr.useSyncExternalStore)((0,fN.useCallback)(e=>S(b,(n,t)=>{O(t,n)||e()}),[r,b]),P[0],P[1]),I=!v.current,j=f[b]&&f[b].length>0,N=T.data,B=hs(N)?M:N,R=T.error,F=(0,fN.useRef)(B),L=d?hs(N)?F.current:N:B,W=(!j||!!hs(R))&&(I&&!hs(s)?s:!x.current.isPaused()&&(a?!hs(B)&&l:hs(B)||l)),V=!!(b&&n&&I&&W),G=hs(T.isValidating)?V:T.isValidating,H=hs(T.isLoading)?V:T.isLoading,U=(0,fN.useCallback)(async e=>{let n,r,a=w.current;if(!b||!a||$.current||x.current.isPaused())return!1;let i=!0,s=e||{},l=!g[b]||!s.dedupe,c=()=>hw?!$.current&&b===A.current&&v.current:b===A.current,u={isValidating:!1,isLoading:!1},p=()=>{E(u)},d=()=>{let e=g[b];e&&e[1]===r&&delete g[b]},m={isValidating:!0};hs(C().data)&&(m.isLoading=!0);try{if(l&&(E(m),t.loadingTimeout&&hs(C().data)&&setTimeout(()=>{i&&c()&&x.current.onLoadingSlow(b,t)},t.loadingTimeout),g[b]=[a(y),hM()]),[n,r]=g[b],n=await n,l&&setTimeout(d,t.dedupingInterval),!g[b]||g[b][1]!==r)return l&&c()&&x.current.onDiscarded(b),!1;u.error=ha;let e=h[b];if(!hs(e)&&(r<=e[0]||r<=e[1]||0===e[1]))return p(),l&&c()&&x.current.onDiscarded(b),!1;let s=C().data;u.data=o(s,n)?s:n,l&&c()&&x.current.onSuccess(n,b,t)}catch(t){d();let e=x.current,{shouldRetryOnError:n}=e;!e.isPaused()&&(u.error=t,l&&c())&&(e.onError(t,b,e),(!0===n||"function"==typeof n&&n(t))&&(!x.current.revalidateOnFocus||!x.current.revalidateOnReconnect||k())&&e.onErrorRetry(t,b,e,e=>{let n=f[b];n&&n[0]&&n[0](3,e)},{retryCount:(s.retryCount||0)+1,dedupe:!0}))}return i=!1,p(),!0},[b,r]),q=(0,fN.useCallback)((...e)=>hO(r,A.current,...e),[]);if(hC(()=>{w.current=n,x.current=t,hs(N)||(F.current=N)}),hC(()=>{if(!b)return;let e=U.bind(ha,hJ),n=0,t=hq(b,f,(t,r={})=>{if(0==t){let t=Date.now();x.current.revalidateOnFocus&&t>n&&k()&&(n=t+x.current.focusThrottleInterval,e())}else if(1==t)x.current.revalidateOnReconnect&&k()&&e();else if(2==t)return U();else if(3==t)return U(r)});return $.current=!1,A.current=b,v.current=!0,E({_k:y}),W&&(hs(B)||hx?e():hk(e)),()=>{$.current=!0,t()}},[b]),hC(()=>{let e;function n(){let n="function"==typeof c?c(C().data):c;n&&-1!==e&&(e=setTimeout(t,n))}function t(){!C().error&&(u||x.current.isVisible())&&(p||x.current.isOnline())?U(hJ).then(n):n()}return n(),()=>{e&&(clearTimeout(e),e=-1)}},[c,u,p,b]),(0,fN.useDebugValue)(L),a&&hs(B)&&b){if(!hw&&hx)throw Error("Fallback data is required when using suspense in SSR.");w.current=n,x.current=t,$.current=!1;let e=m[b];if(hs(e)||hY(q(e)),hs(R)){let e=U(hJ);hs(L)||(e.status="fulfilled",e.value=!0),hY(e)}else throw R}return{mutate:q,get data(){return z.data=!0,L},get error(){return z.error=!0,R},get isValidating(){return z.isValidating=!0,G},get isLoading(){return z.isLoading=!0,H}}}),hZ={strictMode:!0,throwErrorsToConsole:!0,disableTranslations:!1},h0=new Map;hT(h0);let h1={errorRetryCount:3,fetcher:a4,focusThrottleInterval:18e5,revalidateIfStale:!0,revalidateOnFocus:!1,revalidateOnReconnect:!1,refreshInterval:0,shouldRetryOnError:e=>{if(e instanceof a6){let n=e.response.status;return!!(n>=500)||401===n||403===n||429===n}return!0},provider:()=>h0};function h2(e){if("object"!=typeof e||"string"!=typeof e.featureName||"string"!=typeof e.moduleName)throw Error("Invalid options");let n=Object.assign({},hZ,e),t={...h1,...n.swrConfig};return function(e){var r,o,a,i,s;return a=o=class extends(r=fB().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 fB().createElement("div",null,"An error has occurred. Please try reloading the page.");{let r=fB().createElement(fN.Suspense,{fallback:null},fB().createElement(hQ,{value:t},fB().createElement(fR.Provider,{value:this.state.config},n.disableTranslations?fB().createElement(e,this.props):fB().createElement(ht.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},fB().createElement(e,this.props)))));return n.strictMode&&fB().StrictMode?fB().createElement(fB().StrictMode,null,r):r}}constructor(e){super(e),this.state={caughtError:null,caughtErrorInfo:null,config:{moduleName:n.moduleName,featureName:n.featureName,extension:e._extensionContext}}}},i="displayName",s=`OpenmrsReactComponent(${n.featureName})`,i in a?Object.defineProperty(a,i,{value:s,enumerable:!0,configurable:!0,writable:!0}):a[i]=s,o}}function h3(e,n){return function(e){if("object"!==f1(e))throw Error("single-spa-react requires a configuration object");var n,t=f0(f0({},f5),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");!f4&&t.React.createContext&&(f4=t.React.createContext()),t.SingleSpaRoot=function(e){function n(e){n.displayName="SingleSpaRoot(".concat(e.name,")")}return n.prototype=Object.create(e.React.Component.prototype),n.prototype.componentDidMount=function(){setTimeout(this.props.mountFinished)},n.prototype.componentWillUnmount=function(){setTimeout(this.props.unmountFinished)},n.prototype.render=function(){return setTimeout(this.props.updateFinished),this.props.children},n}(t);var r={bootstrap:f6.bind(null,t),mount:f8.bind(null,t),unmount:f7.bind(null,t)};return t.parcelCanUpdate&&(r.update=f9.bind(null,t)),r}({React:fB(),ReactDOMClient:fX,rootComponent:h2(n)(e)})}function h4(e,n){return()=>e().then(({default:e})=>h3(e,n))}function h5(e,n){return()=>Promise.resolve(h3(e,n))}let h6=h4,h8=L()(()=>({}));H("openmrs-app-context",h8);let h7={};function h9(e,n=e=>e){let t=h8.getState();return e in t?Object.freeze(Object.assign({},n?n(t[e]):t[e])):null}function ge(e,n){h8.setState(t=>(e in t||(t[e]={}),t[e]=n(t[e]),Object.assign({},t)))}function gn(e){return null===e?null:Object.freeze(Object.assign({},e))}let gt=new Map;function gr(e,n){let t=(0,fN.useRef)(n??{}),r=(0,fN.useRef)(n=>ge(e,n)),o=(0,fN.useRef)(Symbol());return(0,fN.useEffect)(()=>{let t=n??{},r=o.current;return null===h9(e)?!function(e,n=h7){h8.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===h7?{}: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.`),ge(e,()=>t)),gt.set(e,r),()=>{gt.get(e)===r&&(h8.setState(n=>(e in n&&delete n[e],n)),gt.delete(e))}},[e]),(0,fN.useEffect)(()=>{let r=n??{};N(t.current,r)||(ge(e,()=>r),t.current=r)},[n]),r.current}function go({namespace:e,value:n}){return gr(e,n),null}let ga=({children:e,value:n,fallback:t})=>n?fB().createElement(fB().Fragment,null,e):t?fB().createElement(fB().Fragment,null,t):null;function gi(){let e=(0,fN.useRef)();return(!e.current||e.current.signal.aborted)&&(e.current=new AbortController),(0,fN.useEffect)(()=>{let n=e.current;return()=>n?.abort()},[]),e.current}function gs(e,n=e=>e??{}){let[t,r]=(0,fN.useState)(()=>{if(gl(e))return;let t=h9(e);if(null!==t)return n?n(t):t});return(0,fN.useEffect)(()=>{if(gl(e))throw Error(`The namespace supplied to useAppContext must be a non-empty string, but was "${e}".`)},[e]),(0,fN.useEffect)(()=>{var t;let o;return(t=e=>{if(null==e)return void r(void 0);let t=n?n(e):e;r(e=>N(e,t)?e:t)})(gn(o=h9(e))),h8.subscribe(n=>{let r=e in n?n[e]:null;r!==o&&(o=r,t(gn(r)))})},[e,n]),t}function gl(e){return"string"!=typeof e||0===e.trim().length}function gc(e){let[n,t]=(0,fN.useState)([]);return(0,fN.useEffect)(()=>d3().subscribe(r=>{let o=r.slots[e]?.assignedExtensions.map(e=>e.id)??[];tI(o,n)||t(o)}),[]),n}function gu(e,n){let{data:t,error:r,mutate:o,isLoading:a,isValidating:i}=hX(`${sF}?patient=${e}&includeEncounterless=${n}`,a4);return(0,fN.useMemo)(()=>({isLoading:a,data:t?.data.results??[],error:r,mutate:o,isValidating:i}),[t,r,a,i,o])}function gp(e){(0,fN.useEffect)(()=>{if(e){let e=window.getComputedStyle(document.body).overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=e}}},[e])}let gd={},gf=`No ComponentContext has been provided. This should come from "openmrsComponentDecorator".
|