@openmrs/esm-fast-data-entry-app 1.6.1-pre.997 → 1.6.1-pre.999
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/6685.js +1 -1
- package/dist/6685.js.map +1 -1
- package/dist/openmrs-esm-fast-data-entry-app.js +2 -2
- package/dist/routes.json +1 -1
- package/package.json +1 -1
package/dist/6685.js
CHANGED
|
@@ -12,7 +12,7 @@ If you're the maintainer: the 'elements' key only works with '_type' equal to 'A
|
|
|
12
12
|
${t}`)}return n}let e3=(e,t)=>{let r=structuredClone(t);if(!e)return r;for(let t of Object.keys(e)){let n=r[t],a=e[t];if(a&&(a.hasOwnProperty("_type")||a.hasOwnProperty("_default"))){r.hasOwnProperty(t)||(r[t]=a._default);let e=a._elements;if(n&&e6(e)){if(a._type===Q.Array&&Array.isArray(n)){let a=n.map(t=>e3(e,t));r[t]=a}else if(a._type===Q.Object)for(let t of Object.keys(n))n[t]=e3(e,n[t])}}else if(e5(a)){let e=n??{};e5(e)&&(r[t]=e3(a,e))}}return r};function e6(e){return!!e&&Object.keys(e).filter(e=>!["_default","_validators"].includes(e)).length>0}function e5(e){return"object"==typeof e&&!Array.isArray(e)&&null!==e}function e9(e,t){let r=`${e}:::${t}`;eO.has(r)||(console.error(t),eO.add(r))}function e8(e){e?eO.forEach(t=>{t.startsWith(e)&&eO.delete(t)}):eO.clear()}function e7(){eR.forEach(e=>e()),eR.length=0,eM.clear(),eG.clear(),eY.clear(),eZ.clear(),eT=null,eN=new WeakMap,e$()}let te={"Translation overrides":{_description:"Per-language overrides for frontend translations should be keyed by language code and each language dictionary contains the translation key and the display value",_type:Q.Object,_default:{},_validators:[ee(e=>Object.keys(e).every(e=>/^[a-z]{2,3}(-[A-Z]{2,3})?$/.test(e)),e=>{let t=Object.keys(e).filter(e=>!/^[a-z]{2,3}(-[A-Z]{2,3})?$/.test(e));return`The 'Translation overrides' object should have language codes for keys. Language codes must be in the form of a two-to-three letter language code optionally followed by a hyphen and a two-to-three letter country code. The following keys do not conform: ${t.join(", ")}.`})]}},tt={"Display conditions":{privileges:{_description:"The privilege(s) the user must have to use this extension",_type:Q.Array,_default:[]},expression:{_description:"The expression that determines whether the extension is displayed",_type:Q.String,_default:void 0}},...te},tr=(e,t)=>ee(r=>e<=r&&r<=t,`must be between ${e} and ${t}`),tn=e=>{let t=e.concat(["openmrsBase","openmrsSpaBase"]);return ee(e=>{if(!e||"string"!=typeof e)return!1;let r=/\${(.*?)}/g,n=r.exec(e);for(;n;){if(!t.includes(n[1]))return!1;n=r.exec(e)}return!0},"Should be a URL or path. The allowed template parameters are "+t.map(e=>"${"+e+"}").join(", "))},ta=tn([]),to=e=>ee(t=>e.includes(t),`Must be one of the following: '${e.join("', '")}'.`),ti={inRange:tr,isUrl:ta,isUrlWithTemplateParameters:tn,oneOf:to};var ts=r(8067);let tl=V("breadcrumbs",[]);function tu(e){return tc([e])}function tc(e){let t=[...td(),...e.map(e=>({matcher:e.matcher instanceof RegExp?e.matcher:"string"==typeof e.matcher?(0,ts.pathToRegexp)(e.matcher).regexp:(0,ts.pathToRegexp)(e.path).regexp,settings:e}))];tl.setState(t,!0)}function td(){return tl.getState()}function tf(e,t){if(t)return function(e,t){let[r]=e.filter(e=>e.matcher.test(t));return r}(e,t)||function(e,t){let r=t.split("/");for(;r.length>1;){r.pop();let t=tf(e,r.join("/"));if(t)return t}}(e,t)}function tm(e,t){if(e.length>0){let r=tf(e,t);if(r){let t=[r],n=tf(e,r.settings.parent);for(;void 0!==n;)t.push(n),n=tf(e,n.settings.parent);return t.reverse()}}return[]}function tp(e){return tm(td(),e)}var th=Object.freeze({__proto__:null,get start(){return rF},get ensureJQuerySupport(){return rp},get setBootstrapMaxTime(){return t6},get setMountMaxTime(){return t5},get setUnmountMaxTime(){return t9},get setUnloadMaxTime(){return t8},get registerApplication(){return r_},get unregisterApplication(){return rk},get getMountedApps(){return rE},get getAppStatus(){return rD},get unloadApplication(){return rP},get checkActivityFunctions(){return rC},get getAppNames(){return rx},get pathToActiveWhen(){return rT},get navigateToUrl(){return ro},get patchHistoryApi(){return rd},get triggerAppChange(){return rM},get addErrorHandler(){return tw},get removeErrorHandler(){return tE},get mountRootParcel(){return t0},get NOT_LOADED(){return tS},get LOADING_SOURCE_CODE(){return t_},get NOT_BOOTSTRAPPED(){return tC},get BOOTSTRAPPING(){return tk},get NOT_MOUNTED(){return tP},get MOUNTING(){return tR},get UPDATING(){return tT},get LOAD_ERROR(){return tI},get MOUNTED(){return tO},get UNLOADING(){return t$},get UNMOUNTING(){return tN},get SKIP_BECAUSE_BROKEN(){return tM}}),tg=("u">typeof globalThis?globalThis:"u">typeof window?window:"u">typeof global?global:"u">typeof self?self:{}).CustomEvent,ty=!function(){try{var e=new tg("cat",{detail:{foo:"bar"}});return"cat"===e.type&&"bar"===e.detail.foo}catch(e){}return!1}()?"u">typeof document&&"function"==typeof document.createEvent?function(e,t){var r=document.createEvent("CustomEvent");return t?r.initCustomEvent(e,t.bubbles,t.cancelable,t.detail):r.initCustomEvent(e,!1,!1,void 0),r}:function(e,t){var r=document.createEventObject();return r.type=e,t?(r.bubbles=!!t.bubbles,r.cancelable=!!t.cancelable,r.detail=t.detail):(r.bubbles=!1,r.cancelable=!1,r.detail=void 0),r}:tg;let tv=[];function tb(e,t,r){let n=tD(e,t,r);tv.length?tv.forEach(e=>e(n)):setTimeout(()=>{throw n})}function tw(e){if("function"!=typeof e)throw Error(tx(28,!1));tv.push(e)}function tE(e){if("function"!=typeof e)throw Error(tx(29,!1));let t=!1;return tv=tv.filter(r=>{let n=r===e;return t=t||n,!n}),t}function tx(e,t,...r){return`single-spa minified message #${e}: ${t?t+" ":""}See https://single-spa.js.org/error/?code=${e}${r.length?`&arg=${r.join("&arg=")}`:""}`}function tD(e,t,r){let n,a=`${tB(t)} '${tL(t)}' died in status ${t.status}: `;if(e instanceof Error){try{e.message=a+e.message}catch(e){}n=e}else{console.warn(tx(30,!1,t.status,tL(t)));try{n=Error(a+JSON.stringify(e))}catch(t){n=e}}return n.appOrParcelName=tL(t),t.status=r,n}let tS="NOT_LOADED",t_="LOADING_SOURCE_CODE",tC="NOT_BOOTSTRAPPED",tk="BOOTSTRAPPING",tP="NOT_MOUNTED",tR="MOUNTING",tO="MOUNTED",tT="UPDATING",tN="UNMOUNTING",t$="UNLOADING",tI="LOAD_ERROR",tM="SKIP_BECAUSE_BROKEN";function tA(e){return e.status===tO}function tj(e){try{return e.activeWhen(window.location)}catch(t){return tb(t,e,tM),!1}}function tL(e){return e.name}function tF(e){return!!e.unmountThisParcel}function tB(e){return tF(e)?"parcel":"application"}function tV(){for(let e=arguments.length-1;e>0;e--)for(let t in arguments[e])"__proto__"!==t&&(arguments[e-1][t]=arguments[e][t]);return arguments[0]}function tU(e,t){for(let r=0;r<e.length;r++)if(t(e[r]))return e[r];return null}function tW(e){return e&&("function"==typeof e||Array.isArray(e)&&!tU(e,e=>"function"!=typeof e))}function tH(e,t){let r=e[t]||[];0===(r=Array.isArray(r)?r:[r]).length&&(r=[()=>Promise.resolve()]);let n=tB(e),a=tL(e);return function(e){return r.reduce((r,o,i)=>r.then(()=>{let r=o(e);return tz(r)?r:Promise.reject(tx(15,!1,n,a,t,i))}),Promise.resolve())}}function tz(e){return e&&"function"==typeof e.then&&"function"==typeof e.catch}let tK=[];function tG(e,t){return Promise.resolve().then(()=>e.status!==tC?e:(e.status=tk,e.bootstrap?t7(e,"bootstrap").then(r).catch(r=>{if(t)throw tD(r,e,tM);return tb(r,e,tM),e}):Promise.resolve().then(r)));function r(){return e.status=tP,e}}function tZ(e,t){return Promise.resolve().then(()=>{if(e.status!==tO)return e;return e.status=tN,Promise.all(Object.keys(e.parcels).map(t=>e.parcels[t].unmountThisParcel())).then(r,n=>r().then(()=>{let r=Error(n.message);if(t)throw tD(r,e,tM);tb(r,e,tM)})).then(()=>e);function r(){return t7(e,"unmount").then(()=>{e.status=tP},r=>{if(t)throw tD(r,e,tM);tb(r,e,tM)})}})}let tY=!1,tq=!1;function tJ(e,t){return Promise.resolve().then(()=>e.status!==tP?e:(tY||(window.dispatchEvent(new ty("single-spa:before-first-mount")),tY=!0),e.status=tR,t7(e,"mount").then(()=>(e.status=tO,tq||(window.dispatchEvent(new ty("single-spa:first-mount")),tq=!0),e)).catch(r=>{return e.status=tO,tZ(e,!0).then(n,n);function n(){if(t)throw tD(r,e,tM);return tb(r,e,tM),e}})))}let tX=0,tQ={parcels:{}};function t0(){return t1.apply(tQ,arguments)}function t1(e,t){let r,n,a,o=this;if(!e||"object"!=typeof e&&"function"!=typeof e)throw Error(tx(2,!1));if(e.name&&"string"!=typeof e.name)throw Error(tx(3,!1,typeof e.name));let i=tX++,s=e.name||`parcel-${i}`;if("object"!=typeof t)throw Error(tx(4,!1,s,typeof t));if(!t.domElement)throw Error(tx(5,!1,s));let l="function"==typeof e,u=l?e:()=>Promise.resolve(e),c={id:i,parcels:{},status:l?t_:tC,customProps:t,parentName:tL(o),unmountThisParcel:()=>m.then(()=>{if(c.status!==tO)throw Error(tx(6,!1,s,c.status));return tZ(c,!0)}).then(e=>(c.parentName&&delete o.parcels[c.id],e)).then(e=>(n(e),e)).catch(e=>{throw c.status=tM,a(e),e})};o.parcels[i]=c;let d=u();if(!d||"function"!=typeof d.then)throw Error(tx(7,!1));let f=(d=d.then(e=>{if(!e)throw Error(tx(8,!1));if(s=e.name||`parcel-${i}`,Object.prototype.hasOwnProperty.call(e,"bootstrap")&&!tW(e.bootstrap))throw Error(tx(9,!1,s));if(!tW(e.mount))throw Error(tx(10,!1,s));if(!tW(e.unmount))throw Error(tx(11,!1,s));if(e.update&&!tW(e.update))throw Error(tx(12,!1,s));let t=tH(e,"bootstrap"),n=tH(e,"mount"),a=tH(e,"unmount");c.status=tC,c.name=s,c.bootstrap=t,c.mount=n,c.unmount=a,c.timeouts=re(e.timeouts),e.update&&(c.update=tH(e,"update"),r.update=function(e){return c.customProps=e,t2(Promise.resolve().then(()=>{if(c.status!==tO)throw Error(tx(32,!1,tL(c)));return c.status=tT,t7(c,"update").then(()=>(c.status=tO,c)).catch(e=>{throw tD(e,c,tM)})}))})})).then(()=>tG(c,!0)),m=f.then(()=>tJ(c,!0)),p=new Promise((e,t)=>{n=e,a=t});return r={mount:()=>t2(Promise.resolve().then(()=>{if(c.status!==tP)throw Error(tx(13,!1,s,c.status));return o.parcels[i]=c,tJ(c)})),unmount:()=>t2(c.unmountThisParcel()),getStatus:()=>c.status,loadPromise:t2(d),bootstrapPromise:t2(f),mountPromise:t2(m),unmountPromise:t2(p)}}function t2(e){return e.then(()=>null)}function t4(e){let t=tL(e),r="function"==typeof e.customProps?e.customProps(t,window.location):e.customProps;("object"!=typeof r||null===r||Array.isArray(r))&&(r={},console.warn(tx(40,!1),t,r));let n=tV({},r,{name:t,mountParcel:t1.bind(e),singleSpa:th});return tF(e)&&(n.unmountSelf=e.unmountThisParcel),n}let t3={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 t6(e,t,r){if("number"!=typeof e||e<=0)throw Error(tx(16,!1));t3.bootstrap={millis:e,dieOnTimeout:t,warningMillis:r||1e3}}function t5(e,t,r){if("number"!=typeof e||e<=0)throw Error(tx(17,!1));t3.mount={millis:e,dieOnTimeout:t,warningMillis:r||1e3}}function t9(e,t,r){if("number"!=typeof e||e<=0)throw Error(tx(18,!1));t3.unmount={millis:e,dieOnTimeout:t,warningMillis:r||1e3}}function t8(e,t,r){if("number"!=typeof e||e<=0)throw Error(tx(19,!1));t3.unload={millis:e,dieOnTimeout:t,warningMillis:r||1e3}}function t7(e,t){let r=e.timeouts[t],n=r.warningMillis,a=tB(e);return new Promise((o,i)=>{let s=!1,l=!1;e[t](t4(e)).then(e=>{s=!0,o(e)}).catch(e=>{s=!0,i(e)}),setTimeout(()=>c(1),n),setTimeout(()=>c(!0),r.millis);let u=tx(31,!1,t,a,tL(e),r.millis);function c(e){s||(!0===e?(l=!0,r.dieOnTimeout?i(Error(u)):console.error(u)):!l&&(console.warn(u),e*n+n<r.millis&&setTimeout(()=>c(e+1),n)))}})}function re(e){let t={};for(let r in t3)t[r]=tV({},t3[r],e&&e[r]||{});return t}function rt(e){return Promise.resolve().then(()=>{let t,r;return e.loadPromise?e.loadPromise:e.status!==tS&&e.status!==tI?e:(e.status=t_,e.loadPromise=Promise.resolve().then(()=>{let n=e.loadApp(t4(e));if(!tz(n))throw r=!0,Error(tx(33,!1,tL(e)));return n.then(r=>{let n;e.loadErrorTime=null,"object"!=typeof(t=r)&&(n=34),Object.prototype.hasOwnProperty.call(t,"bootstrap")&&!tW(t.bootstrap)&&(n=35),tW(t.mount)||(n=36),tW(t.unmount)||(n=37);let a=tB(t);if(n){let r;try{r=JSON.stringify(t)}catch(e){}return console.error(tx(n,!1,a,tL(e),r),t),tb(void 0,e,tM),e}return t.devtools&&t.devtools.overlays&&(e.devtools.overlays=tV({},e.devtools.overlays,t.devtools.overlays)),e.status=tC,e.bootstrap=tH(t,"bootstrap"),e.mount=tH(t,"mount"),e.unmount=tH(t,"unmount"),e.unload=tH(t,"unload"),e.timeouts=re(t.timeouts),delete e.loadPromise,e})}).catch(t=>{let n;return delete e.loadPromise,r?n=tM:(n=tI,e.loadErrorTime=(new Date).getTime()),tb(t,e,n),e}))})}let rr="u">typeof window,rn={hashchange:[],popstate:[]},ra=["hashchange","popstate"];function ro(e){let t;if("string"==typeof e)t=e;else if(this&&this.href)t=this.href;else{if(!(e&&e.currentTarget&&e.currentTarget.href&&e.preventDefault))throw Error(tx(14,!1));t=e.currentTarget.href,e.preventDefault()}let r=rf(window.location.href),n=rf(t);0===t.indexOf("#")?window.location.hash=n.hash:r.host!==n.host&&n.host?window.location.href=t:n.pathname===r.pathname&&n.search===r.search?window.location.hash=n.hash:window.history.pushState(null,null,t)}function ri(e){if(e){let t=e[0].type;ra.indexOf(t)>=0&&rn[t].forEach(t=>{try{t.apply(this,e)}catch(e){setTimeout(()=>{throw e})}})}}function rs(){rA([],arguments)}function rl(e,t){return function(){let r=window.location.href,n=e.apply(this,arguments),o=window.location.href;return a&&r===o||window.dispatchEvent(function(e,t){let r;try{r=new PopStateEvent("popstate",{state:e})}catch(t){(r=document.createEvent("PopStateEvent")).initPopStateEvent("popstate",!1,!1,e)}return r.singleSpa=!0,r.singleSpaTrigger=t,r}(window.history.state,t)),n}}let ru=null,rc=!1;function rd(e){if(rc)throw Error(tx(43,!1));a=!e||!e.hasOwnProperty("urlRerouteOnly")||e.urlRerouteOnly,rc=!0,ru=window.history.replaceState,window.addEventListener("hashchange",rs),window.addEventListener("popstate",rs);let t=window.addEventListener,r=window.removeEventListener;window.addEventListener=function(e,r){if(!("function"==typeof r&&ra.indexOf(e)>=0)||tU(rn[e],e=>e===r))return t.apply(this,arguments);rn[e].push(r)},window.removeEventListener=function(e,t){return"function"==typeof t&&ra.indexOf(e)>=0&&(rn[e]=rn[e].filter(e=>e!==t)),r.apply(this,arguments)},window.history.pushState=rl(window.history.pushState,"pushState"),window.history.replaceState=rl(ru,"replaceState")}function rf(e){let t=document.createElement("a");return t.href=e,t}rr&&(window.singleSpaNavigate?console.warn(tx(41,!1)):window.singleSpaNavigate=ro);let rm=!1;function rp(e=window.jQuery){if(e||window.$&&window.$.fn&&window.$.fn.jquery&&(e=window.$),e&&!rm){let t=e.fn.on,r=e.fn.off;e.fn.on=function(e,r){return rh.call(this,t,window.addEventListener,e,r,arguments)},e.fn.off=function(e,t){return rh.call(this,r,window.removeEventListener,e,t,arguments)},rm=!0}}function rh(e,t,r,n,a){return"string"!=typeof r?e.apply(this,a):(r.split(/\s+/).forEach(e=>{ra.indexOf(e)>=0&&(t(e,n),r=r.replace(e,""))}),""===r.trim()?this:e.apply(this,a))}let rg={};function ry(e){return Promise.resolve().then(()=>{let t=rg[tL(e)];if(!t)return e;if(e.status===tS)return rv(e,t),e;if(e.status===t$)return t.promise.then(()=>e);if(e.status!==tP&&e.status!==tI)return e;let r=e.status===tI?Promise.resolve():t7(e,"unload");return e.status=t$,r.then(()=>(rv(e,t),e)).catch(r=>(delete rg[tL(e)],delete e.bootstrap,delete e.mount,delete e.unmount,delete e.unload,tb(r,e,tM),t.reject(r),e))})}function rv(e,t){delete rg[tL(e)],delete e.bootstrap,delete e.mount,delete e.unmount,delete e.unload,e.status=tS,t.resolve()}function rb(e,t,r,n){rg[tL(e)]={app:e,resolve:r,reject:n},Object.defineProperty(rg[tL(e)],"promise",{get:t})}let rw=[];function rE(){return rw.filter(tA).map(tL)}function rx(){return rw.map(tL)}function rD(e){let t=tU(rw,t=>tL(t)===e);return t?t.status:null}let rS=!1;function r_(e,t,r,n){var a,o;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(tx(39,!1));let t=["name","app","activeWhen","customProps"],r=Object.keys(e).reduce((e,r)=>t.indexOf(r)>=0?e:e.concat(r),[]);if(0!==r.length)throw Error(tx(38,!1,t.join(", "),r.join(", ")));if("string"!=typeof e.name||0===e.name.length||"object"!=typeof e.app&&"function"!=typeof e.app)throw Error(tx(20,!1));let n=e=>"string"==typeof e||"function"==typeof e;if(!(n(e.activeWhen)||Array.isArray(e.activeWhen)&&e.activeWhen.every(n)))throw Error(tx(24,!1));if(!rO(e.customProps))throw Error(tx(22,!1))}(e),i.name=e.name,i.loadApp=e.app,i.activeWhen=e.activeWhen,i.customProps=e.customProps):(function(e,t,r,n){if("string"!=typeof e||0===e.length)throw Error(tx(20,!1));if(!t)throw Error(tx(23,!1));if("function"!=typeof r)throw Error(tx(24,!1));if(!rO(n))throw Error(tx(22,!1))}(e,t,r,n),i.name=e,i.loadApp=t,i.activeWhen=r,i.customProps=n),i.loadApp="function"!=typeof(a=i.loadApp)?()=>Promise.resolve(a):a,i.customProps=i.customProps||{},s=(s=Array.isArray(o=i.activeWhen)?o:[o]).map(e=>"function"==typeof e?e:rT(e)),i.activeWhen=e=>s.some(t=>t(e)),i);if(rL||rS||(rS=!0,setTimeout(()=>{rL||console.warn(tx(1,!1))},5e3)),-1!==rx().indexOf(l.name))throw Error(tx(21,!1,l.name));rw.push(tV({loadErrorTime:null,status:tS,parcels:{},devtools:{overlays:{options:{},selectors:[]}}},l)),rr&&(rp(),rA())}function rC(e=window.location){return rw.filter(t=>t.activeWhen(e)).map(tL)}function rk(e){if(0===rw.filter(t=>tL(t)===e).length)throw Error(tx(25,!1,e));return(rr?rP(e,{waitForUnmount:!1}):Promise.resolve()).then(()=>{let t=rw.map(tL).indexOf(e);rw.splice(t,1)})}function rP(e,t={waitForUnmount:!1}){if("string"!=typeof e)throw Error(tx(26,!1));let r=tU(rw,t=>tL(t)===e);if(!r)throw Error(tx(27,!1,e));let n=rg[tL(r)];if(t&&t.waitForUnmount){if(n)return n.promise;{let e=new Promise((t,n)=>{rb(r,()=>e,t,n)});return e}}{let e;return n?(e=n.promise,rR(r,n.resolve,n.reject)):e=new Promise((t,n)=>{rb(r,()=>e,t,n),rR(r,t,n)}),e}}function rR(e,t,r){Promise.resolve().then(()=>{if(tU(rC(),t=>t===tL(e)))return rM()}).then(()=>tZ(e).then(ry).then(()=>{t(),setTimeout(()=>{rA()})})).catch(r)}function rO(e){return!e||"function"==typeof e||"object"==typeof e&&null!==e&&!Array.isArray(e)}function rT(e,t){let r=function(e,t){let r=0,n=!1,a="^";"/"!==e[0]&&(e="/"+e);for(let t=0;t<e.length;t++){let r=e[t],a=n&&"/"===r;(!n&&":"===r||a)&&o(t)}return o(e.length),RegExp(a,"i");function o(o){let i=e.slice(r,o).replace(/[|\\{}()[\]^$+*?.]/g,"\\$&");if(a+=n?"[^/]+/?":i,o===e.length)if(n)t&&(a+="$");else{let e=t?"":".*";a="/"===a.charAt(a.length-1)?`${a}${e}$`:`${a}(/${e})?(#.*)?$`}n=!n,r=o}}(e,t);return e=>{let t=e.origin;t||(t=`${e.protocol}//${e.host}`);let n=e.href.replace(t,"").replace(e.search,"").split("?")[0];return r.test(n)}}let rN=!1,r$=[],rI=rr&&window.location.href;function rM(){return rA()}function rA(e=[],t,r=!1){let n,a,o,i,s;if(rN)return new Promise((e,r)=>{r$.push({resolve:e,reject:r,eventArguments:t})});let{appsToUnload:l,appsToUnmount:u,appsToLoad:c,appsToMount:d}=(n=[],a=[],o=[],i=[],s=(new Date).getTime(),rw.forEach(e=>{let t=e.status!==tM&&tj(e);switch(e.status){case tI:t&&s-e.loadErrorTime>=200&&o.push(e);break;case tS:case t_:t&&o.push(e);break;case tC:case tP:!t&&rg[tL(e)]?n.push(e):t&&i.push(e);break;case tO:t||a.push(e)}}),{appsToUnload:n,appsToUnmount:a,appsToLoad:o,appsToMount:i}),f,m=[],p=rI,h=rI=window.location.href;return rL?(rN=!0,f=l.concat(c,u,d),Promise.resolve().then(()=>(w(0===f.length?"before-no-app-change":"before-app-change",b(!0)),w("before-routing-event",b(!0,{cancelNavigation:g})),Promise.all(m).then(r=>{if(r.some(e=>e))return ru.call(window.history,history.state,"",p.substring(location.origin.length)),rI=location.href,rN=!1,rA(e,t,!0);let n=l.map(ry),a=Promise.all(u.map(tZ).map(e=>e.then(ry)).concat(n));a.then(()=>{w("before-mount-routing-event",b(!0))},e=>{throw e});let o=c.map(e=>rt(e).then(e=>rj(e,a))),i=d.filter(e=>0>c.indexOf(e)).map(e=>rj(e,a));return a.catch(e=>{throw v(),e}).then(()=>(v(),Promise.all(o.concat(i)).catch(t=>{throw e.forEach(e=>e.reject(t)),t}).then(y).then(()=>{},e=>{throw e})))})))):(f=c,Promise.resolve().then(()=>Promise.all(c.map(rt)).then(v).then(()=>[]).catch(e=>{throw v(),e}).finally(()=>{})));function g(e=!0){let t="function"==typeof(null==e?void 0:e.then)?e:Promise.resolve(e);m.push(t.catch(e=>(console.warn(Error(tx(42,!1))),console.warn(e),!1)))}function y(){let t=rE();e.forEach(e=>e.resolve(t));try{w(0===f.length?"no-app-change":"app-change",b()),w("routing-event",b())}catch(e){setTimeout(()=>{throw e})}if(rN=!1,r$.length>0){let e=r$;r$=[],rA(e)}return t}function v(){r||(e.forEach(e=>{ri(e.eventArguments)}),ri(t))}function b(e=!1,r){let n={},a={[tO]:[],[tP]:[],[tS]:[],[tM]:[]};e?(c.concat(d).forEach((e,t)=>{i(e,tO)}),l.forEach(e=>{i(e,tS)}),u.forEach(e=>{i(e,tP)})):f.forEach(e=>{i(e)});let o={detail:{newAppStatuses:n,appsByNewStatus:a,totalAppChanges:f.length,originalEvent:null==t?void 0:t[0],oldUrl:p,newUrl:h}};return r&&tV(o.detail,r),o;function i(e,t){let r=tL(e);t=t||rD(r),n[r]=t,(a[t]=a[t]||[]).push(r)}}function w(e,t){r||window.dispatchEvent(new ty(`single-spa:${e}`,t))}}function rj(e,t){return tj(e)?tG(e).then(e=>t.then(()=>tj(e)?tJ(e):e)):t.then(()=>e)}let rL=!1;function rF(e){rL=!0,rr&&(rd(e),rA())}rr&&window.__SINGLE_SPA_DEVTOOLS__&&(window.__SINGLE_SPA_DEVTOOLS__.exposedMethods={getRawAppData:function(){return[...rw]},reroute:rA,NOT_LOADED:tS,toLoadPromise:rt,toBootstrapPromise:tG,unregisterApplication:rk,getProfilerData:function(){return tK}});let rB={address1:"Address line 1",address2:"Address line 2",address3:"Address line 3",address4:"Address line 4",address5:"Address line 5",address6:"Address line 6",city:"City",cityVillage:"City",country:"Country",countyDistrict:"District",district:"District",postalCode:"Postal code",state:"State",stateProvince:"State",closeAllOpenedWorkspaces:"Discard changes in {{count}} workspaces",closingAllWorkspacesPromptBody:"There may be unsaved changes in the following workspaces. Do you want to discard changes in the following workspaces? {{workspaceNames}}",closingAllWorkspacesPromptTitle:"You have unsaved changes",discard:"Discard",hide:"Hide",maximize:"Maximize",minimize:"Minimize",openAnyway:"Open anyway",unsavedChangesInOpenedWorkspace:"You may have unsaved changes in the opened workspace. Do you want to discard these changes?",unsavedChangesInWorkspace:'There may be unsaved changes in "{{workspaceName}}". Please save them before opening another workspace.',unsavedChangesTitleText:"Unsaved changes",workspaceHeader:"Workspace header",discardUnsavedChangesPromptBodyMultiple:"{{count}} workspaces have unsaved changes. Closing them will discard the changes:",discardUnsavedChangesPromptBodySingle:"<strong>{{workspaceTitle}}</strong> has unsaved changes. Closing it will discard them.",discardUnsavedChangesPromptTitle:"Discard unsaved changes?",keepEditing:"Keep editing",abnormalValue:"Abnormal value",actions:"Actions",actionableNotification:"Actionable notification",address:"Address",age:"Age",applicationError:"Application Error",batchActionItemSelected:"{{totalSelected}} item selected",batchActionsItemsSelected:"{{totalSelected}} items selected",cancel:"Cancel",change:"Change",Clinic:"Clinic",clearDevOverrides:"Clear dev overrides",close:"Close",closesActionableNotification:"Close actionable notification",closeSnackbar:"Close snackbar",confirm:"Confirm",contactAdministratorIfIssuePersists:"Contact your system administrator if the problem persists.",contactDetails:"Contact details",copied:"Copied!",copyToClipboard:"Copy to clipboard",delete:"Delete",discardChanges:"Discard changes",edit:"Edit",emptyStateText:"There are no {{displayText}} to display",error:"Error",errorCopy:"Sorry, there was a problem displaying this information. You can try to reload this page, or contact the site administrator and quote the error code above.",errorLoadingLoginLocations:"Unable to load login locations. Please try again or contact support if the problem persists.",female:"Female",leftNavigation:"Left navigation",loading:"Loading",localVersion:"Local Build",male:"Male",navigateNonHttp:"Could not navigate to the requested page as it is not a safe URL",noResultsToDisplay:"No results to display",notAvailable:"Not available",other:"Other",paginationItemsCount:"{{pageItemsCount}} / {{totalItems}} items",paginationOfPages:"of {{count}} pages",patientAvatarAlt:"Avatar for {{patientName}}",patientIdentifierSticker:"Patient identifier sticker",patientLists:"Patient lists",patientPhotoAlt:"Profile photo of {{patientName}}",patientPhotoPlaceholder:"Photo placeholder for {{patientName}}",prereleaseVersion:"Prerelease",print:"Print",printError:"Print error",printErrorExplainer:"An error occurred in {{errorLocation}}",printIdentifierSticker:"Print identifier sticker",printing:"Printing",provisional:"Provisional",recordNewEntry:"Record {{displayText}}",relationships:"Relationships",reload:"Reload",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",serverStartingUp:"The server is starting",serverStartingUpExplainer:"This can take a few minutes. OpenMRS will open automatically when the server is ready.",serverStartingUpSlowExplainer:"This is taking longer than usual. First startup after an upgrade can take 10 minutes or more. You can leave this page open.",sex:"Sex",showLess:"Show less",showMore:"Show more",snackbarNotification:"Snackbar notification",somethingWentWrongTryReloading:"Something went wrong. Please try reloading.",toggleDevTools:"Toggle dev tools",unknown:"Unknown",viewSetupProgress:"View setup progress",waitingForServer:"Waiting for the server",yearAbbreviation:"yr",yearsAbbreviation:"yrs"};var rV=r(2284),rU=r(3029),rW=r(2901);function rH(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}var rz=r(3662);function rK(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&(0,rz.A)(e,t)}function rG(e,t){if(t&&("object"==(0,rV.A)(t)||"function"==typeof t))return t;if(void 0!==t)throw TypeError("Derived constructors may only return object or undefined");return rH(e)}function rZ(e){return(rZ=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var rY=r(4467),rq=r(6369),rJ=r(3612),rX=r(6562);function rQ(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function r0(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?rQ(Object(r),!0).forEach(function(t){(0,rY.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):rQ(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var r1={type:"logger",log:function(e){this.output("log",e)},warn:function(e){this.output("warn",e)},error:function(e){this.output("error",e)},output:function(e,t){console&&console[e]&&console[e].apply(console,t)}},r2=new(function(){function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};(0,rU.A)(this,e),this.init(t,r)}return(0,rW.A)(e,[{key:"init",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.prefix=t.prefix||"i18next:",this.logger=e||r1,this.options=t,this.debug=t.debug}},{key:"setDebug",value:function(e){this.debug=e}},{key:"log",value:function(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return this.forward(t,"log","",!0)}},{key:"warn",value:function(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return this.forward(t,"warn","",!0)}},{key:"error",value:function(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return this.forward(t,"error","")}},{key:"deprecate",value:function(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return this.forward(t,"warn","WARNING DEPRECATED: ",!0)}},{key:"forward",value:function(e,t,r,n){return n&&!this.debug?null:("string"==typeof e[0]&&(e[0]="".concat(r).concat(this.prefix," ").concat(e[0])),this.logger[t](e))}},{key:"create",value:function(t){return new e(this.logger,r0(r0({},{prefix:"".concat(this.prefix,":").concat(t,":")}),this.options))}},{key:"clone",value:function(t){return(t=t||this.options).prefix=t.prefix||this.prefix,new e(this.logger,t)}}]),e}()),r4=function(){function e(){(0,rU.A)(this,e),this.observers={}}return(0,rW.A)(e,[{key:"on",value:function(e,t){var r=this;return e.split(" ").forEach(function(e){r.observers[e]=r.observers[e]||[],r.observers[e].push(t)}),this}},{key:"off",value:function(e,t){if(this.observers[e]){if(!t)return void delete this.observers[e];this.observers[e]=this.observers[e].filter(function(e){return e!==t})}}},{key:"emit",value:function(e){for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];this.observers[e]&&[].concat(this.observers[e]).forEach(function(e){e.apply(void 0,r)}),this.observers["*"]&&[].concat(this.observers["*"]).forEach(function(t){t.apply(t,[e].concat(r))})}}]),e}();function r3(){var e,t,r=new Promise(function(r,n){e=r,t=n});return r.resolve=e,r.reject=t,r}function r6(e){return null==e?"":""+e}function r5(e,t,r){function n(e){return e&&e.indexOf("###")>-1?e.replace(/###/g,"."):e}function a(){return!e||"string"==typeof e}for(var o="string"!=typeof t?[].concat(t):t.split(".");o.length>1;){if(a())return{};var i=n(o.shift());!e[i]&&r&&(e[i]=new r),e=Object.prototype.hasOwnProperty.call(e,i)?e[i]:{}}return a()?{}:{obj:e,k:n(o.shift())}}function r9(e,t,r){var n=r5(e,t,Object);n.obj[n.k]=r}function r8(e,t){var r=r5(e,t),n=r.obj,a=r.k;if(n)return n[a]}function r7(e,t,r){var n=r8(e,r);return void 0!==n?n:r8(t,r)}function ne(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")}var nt={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};function nr(e){return"string"==typeof e?e.replace(/[&<>"'\/]/g,function(e){return nt[e]}):e}var nn="u">typeof window&&window.navigator&&void 0===window.navigator.userAgentData&&window.navigator.userAgent&&window.navigator.userAgent.indexOf("MSIE")>-1,na=[" ",",","?","!",";"];function no(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function ni(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?no(Object(r),!0).forEach(function(t){(0,rY.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):no(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var ns=function(e){rK(n,e);var t,r=(t=function(){if("u"<typeof Reflect||!Reflect.construct||Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}(),function(){var e,r=rZ(n);return e=t?Reflect.construct(r,arguments,rZ(this).constructor):r.apply(this,arguments),rG(this,e)});function n(e){var t,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{ns:["translation"],defaultNS:"translation"};return(0,rU.A)(this,n),t=r.call(this),nn&&r4.call(rH(t)),t.data=e||{},t.options=a,void 0===t.options.keySeparator&&(t.options.keySeparator="."),void 0===t.options.ignoreJSONStructure&&(t.options.ignoreJSONStructure=!0),t}return(0,rW.A)(n,[{key:"addNamespaces",value:function(e){0>this.options.ns.indexOf(e)&&this.options.ns.push(e)}},{key:"removeNamespaces",value:function(e){var t=this.options.ns.indexOf(e);t>-1&&this.options.ns.splice(t,1)}},{key:"getResource",value:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},a=void 0!==n.keySeparator?n.keySeparator:this.options.keySeparator,o=void 0!==n.ignoreJSONStructure?n.ignoreJSONStructure:this.options.ignoreJSONStructure,i=[e,t];r&&"string"!=typeof r&&(i=i.concat(r)),r&&"string"==typeof r&&(i=i.concat(a?r.split(a):r)),e.indexOf(".")>-1&&(i=e.split("."));var s=r8(this.data,i);return s||!o||"string"!=typeof r?s:function e(t,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:".";if(t){if(t[r])return t[r];for(var a=r.split(n),o=t,i=0;i<a.length;++i){if(!o||"string"==typeof o[a[i]]&&i+1<a.length)return;if(void 0===o[a[i]]){for(var s=2,l=a.slice(i,i+s).join(n),u=o[l];void 0===u&&a.length>i+s;)s++,u=o[l=a.slice(i,i+s).join(n)];if(void 0===u)return;if(null===u)return null;if(r.endsWith(l)){if("string"==typeof u)return u;if(l&&"string"==typeof u[l])return u[l]}var c=a.slice(i+s).join(n);if(c)return e(u,c,n);return}o=o[a[i]]}return o}}(this.data&&this.data[e]&&this.data[e][t],r,a)}},{key:"addResource",value:function(e,t,r,n){var a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{silent:!1},o=this.options.keySeparator;void 0===o&&(o=".");var i=[e,t];r&&(i=i.concat(o?r.split(o):r)),e.indexOf(".")>-1&&(i=e.split("."),n=t,t=i[1]),this.addNamespaces(t),r9(this.data,i,n),a.silent||this.emit("added",e,t,r,n)}},{key:"addResources",value:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{silent:!1};for(var a in r)("string"==typeof r[a]||"[object Array]"===Object.prototype.toString.apply(r[a]))&&this.addResource(e,t,a,r[a],{silent:!0});n.silent||this.emit("added",e,t,r)}},{key:"addResourceBundle",value:function(e,t,r,n,a){var o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{silent:!1},i=[e,t];e.indexOf(".")>-1&&(i=e.split("."),n=r,r=t,t=i[1]),this.addNamespaces(t);var s=r8(this.data,i)||{};n?function e(t,r,n){for(var a in r)"__proto__"!==a&&"constructor"!==a&&(a in t?"string"==typeof t[a]||t[a]instanceof String||"string"==typeof r[a]||r[a]instanceof String?n&&(t[a]=r[a]):e(t[a],r[a],n):t[a]=r[a]);return t}(s,r,a):s=ni(ni({},s),r),r9(this.data,i,s),o.silent||this.emit("added",e,t,r)}},{key:"removeResourceBundle",value:function(e,t){this.hasResourceBundle(e,t)&&delete this.data[e][t],this.removeNamespaces(t),this.emit("removed",e,t)}},{key:"hasResourceBundle",value:function(e,t){return void 0!==this.getResource(e,t)}},{key:"getResourceBundle",value:function(e,t){return(t||(t=this.options.defaultNS),"v1"===this.options.compatibilityAPI)?ni(ni({},{}),this.getResource(e,t)):this.getResource(e,t)}},{key:"getDataByLanguage",value:function(e){return this.data[e]}},{key:"hasLanguageSomeTranslations",value:function(e){var t=this.getDataByLanguage(e);return!!(t&&Object.keys(t)||[]).find(function(e){return t[e]&&Object.keys(t[e]).length>0})}},{key:"toJSON",value:function(){return this.data}}]),n}(r4),nl={processors:{},addPostProcessor:function(e){this.processors[e.name]=e},handle:function(e,t,r,n,a){var o=this;return e.forEach(function(e){o.processors[e]&&(t=o.processors[e].process(t,r,n,a))}),t}};function nu(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function nc(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?nu(Object(r),!0).forEach(function(t){(0,rY.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):nu(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var nd={},nf=function(e){rK(n,e);var t,r=(t=function(){if("u"<typeof Reflect||!Reflect.construct||Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}(),function(){var e,r=rZ(n);return e=t?Reflect.construct(r,arguments,rZ(this).constructor):r.apply(this,arguments),rG(this,e)});function n(e){var t,a,o,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return(0,rU.A)(this,n),o=r.call(this),nn&&r4.call(rH(o)),t=["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],a=rH(o),t.forEach(function(t){e[t]&&(a[t]=e[t])}),o.options=i,void 0===o.options.keySeparator&&(o.options.keySeparator="."),o.logger=r2.create("translator"),o}return(0,rW.A)(n,[{key:"changeLanguage",value:function(e){e&&(this.language=e)}},{key:"exists",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{interpolation:{}};if(null==e)return!1;var r=this.resolve(e,t);return r&&void 0!==r.res}},{key:"extractFromKey",value:function(e,t){var r=void 0!==t.nsSeparator?t.nsSeparator:this.options.nsSeparator;void 0===r&&(r=":");var n=void 0!==t.keySeparator?t.keySeparator:this.options.keySeparator,a=t.ns||this.options.defaultNS||[],o=r&&e.indexOf(r)>-1,i=!this.options.userDefinedKeySeparator&&!t.keySeparator&&!this.options.userDefinedNsSeparator&&!t.nsSeparator&&!function(e,t,r){t=t||"",r=r||"";var n=na.filter(function(e){return 0>t.indexOf(e)&&0>r.indexOf(e)});if(0===n.length)return!0;var a=new RegExp("(".concat(n.map(function(e){return"?"===e?"\\?":e}).join("|"),")")),o=!a.test(e);if(!o){var i=e.indexOf(r);i>0&&!a.test(e.substring(0,i))&&(o=!0)}return o}(e,r,n);if(o&&!i){var s=e.match(this.interpolator.nestingRegexp);if(s&&s.length>0)return{key:e,namespaces:a};var l=e.split(r);(r!==n||r===n&&this.options.ns.indexOf(l[0])>-1)&&(a=l.shift()),e=l.join(n)}return"string"==typeof a&&(a=[a]),{key:e,namespaces:a}}},{key:"translate",value:function(e,t,r){var a=this;if("object"!==(0,rV.A)(t)&&this.options.overloadTranslationOptionHandler&&(t=this.options.overloadTranslationOptionHandler(arguments)),t||(t={}),null==e)return"";Array.isArray(e)||(e=[String(e)]);var o=void 0!==t.returnDetails?t.returnDetails:this.options.returnDetails,i=void 0!==t.keySeparator?t.keySeparator:this.options.keySeparator,s=this.extractFromKey(e[e.length-1],t),l=s.key,u=s.namespaces,c=u[u.length-1],d=t.lng||this.language,f=t.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(d&&"cimode"===d.toLowerCase()){if(f){var m=t.nsSeparator||this.options.nsSeparator;return o?(p.res="".concat(c).concat(m).concat(l),p):"".concat(c).concat(m).concat(l)}return o?(p.res=l,p):l}var p=this.resolve(e,t),h=p&&p.res,g=p&&p.usedKey||l,y=p&&p.exactUsedKey||l,v=Object.prototype.toString.apply(h),b=void 0!==t.joinArrays?t.joinArrays:this.options.joinArrays,w=!this.i18nFormat||this.i18nFormat.handleAsObject,E="string"!=typeof h&&"boolean"!=typeof h&&"number"!=typeof h;if(w&&h&&E&&0>["[object Number]","[object Function]","[object RegExp]"].indexOf(v)&&("string"!=typeof b||"[object Array]"!==v)){if(!t.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");var x=this.options.returnedObjectHandler?this.options.returnedObjectHandler(g,h,nc(nc({},t),{},{ns:u})):"key '".concat(l," (").concat(this.language,")' returned an object instead of string.");return o?(p.res=x,p):x}if(i){var D="[object Array]"===v,S=D?[]:{},_=D?y:g;for(var C in h)if(Object.prototype.hasOwnProperty.call(h,C)){var k="".concat(_).concat(i).concat(C);S[C]=this.translate(k,nc(nc({},t),{joinArrays:!1,ns:u})),S[C]===k&&(S[C]=h[C])}h=S}}else if(w&&"string"==typeof b&&"[object Array]"===v)(h=h.join(b))&&(h=this.extendTranslation(h,e,t,r));else{var P=!1,R=!1,O=void 0!==t.count&&"string"!=typeof t.count,T=n.hasDefaultValue(t),N=O?this.pluralResolver.getSuffix(d,t.count,t):"",$=t["defaultValue".concat(N)]||t.defaultValue;!this.isValidLookup(h)&&T&&(P=!0,h=$),this.isValidLookup(h)||(R=!0,h=l);var I=(t.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&R?void 0:h,M=T&&$!==h&&this.options.updateMissing;if(R||P||M){if(this.logger.log(M?"updateKey":"missingKey",d,c,l,M?$:h),i){var A=this.resolve(l,nc(nc({},t),{},{keySeparator:!1}));A&&A.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.")}var j=[],L=this.languageUtils.getFallbackCodes(this.options.fallbackLng,t.lng||this.language);if("fallback"===this.options.saveMissingTo&&L&&L[0])for(var F=0;F<L.length;F++)j.push(L[F]);else"all"===this.options.saveMissingTo?j=this.languageUtils.toResolveHierarchy(t.lng||this.language):j.push(t.lng||this.language);var B=function(e,r,n){var o=T&&n!==h?n:I;a.options.missingKeyHandler?a.options.missingKeyHandler(e,c,r,o,M,t):a.backendConnector&&a.backendConnector.saveMissing&&a.backendConnector.saveMissing(e,c,r,o,M,t),a.emit("missingKey",e,c,r,h)};this.options.saveMissing&&(this.options.saveMissingPlurals&&O?j.forEach(function(e){a.pluralResolver.getSuffixes(e,t).forEach(function(r){B([e],l+r,t["defaultValue".concat(r)]||$)})}):B(j,l,$))}h=this.extendTranslation(h,e,t,p,r),R&&h===l&&this.options.appendNamespaceToMissingKey&&(h="".concat(c,":").concat(l)),(R||P)&&this.options.parseMissingKeyHandler&&(h="v1"!==this.options.compatibilityAPI?this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?"".concat(c,":").concat(l):l,P?h:void 0):this.options.parseMissingKeyHandler(h))}return o?(p.res=h,p):h}},{key:"extendTranslation",value:function(e,t,r,n,a){var o=this;if(this.i18nFormat&&this.i18nFormat.parse)e=this.i18nFormat.parse(e,nc(nc({},this.options.interpolation.defaultVariables),r),n.usedLng,n.usedNS,n.usedKey,{resolved:n});else if(!r.skipInterpolation){r.interpolation&&this.interpolator.init(nc(nc({},r),{interpolation:nc(nc({},this.options.interpolation),r.interpolation)}));var i,s="string"==typeof e&&(r&&r.interpolation&&void 0!==r.interpolation.skipOnVariables?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);if(s){var l=e.match(this.interpolator.nestingRegexp);i=l&&l.length}var u=r.replace&&"string"!=typeof r.replace?r.replace:r;if(this.options.interpolation.defaultVariables&&(u=nc(nc({},this.options.interpolation.defaultVariables),u)),e=this.interpolator.interpolate(e,u,r.lng||this.language,r),s){var c=e.match(this.interpolator.nestingRegexp);i<(c&&c.length)&&(r.nest=!1)}!1!==r.nest&&(e=this.interpolator.nest(e,function(){for(var e=arguments.length,n=Array(e),i=0;i<e;i++)n[i]=arguments[i];return a&&a[0]===n[0]&&!r.context?(o.logger.warn("It seems you are nesting recursively key: ".concat(n[0]," in key: ").concat(t[0])),null):o.translate.apply(o,n.concat([t]))},r)),r.interpolation&&this.interpolator.reset()}var d=r.postProcess||this.options.postProcess,f="string"==typeof d?[d]:d;return null!=e&&f&&f.length&&!1!==r.applyPostProcessor&&(e=nl.handle(f,e,t,this.options&&this.options.postProcessPassResolved?nc({i18nResolved:n},r):r,this)),e}},{key:"resolve",value:function(e){var t,r,n,a,o,i=this,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return"string"==typeof e&&(e=[e]),e.forEach(function(e){if(!i.isValidLookup(t)){var l=i.extractFromKey(e,s),u=l.key;r=u;var c=l.namespaces;i.options.fallbackNS&&(c=c.concat(i.options.fallbackNS));var d=void 0!==s.count&&"string"!=typeof s.count,f=d&&!s.ordinal&&0===s.count&&i.pluralResolver.shouldUseIntlApi(),m=void 0!==s.context&&("string"==typeof s.context||"number"==typeof s.context)&&""!==s.context,p=s.lngs?s.lngs:i.languageUtils.toResolveHierarchy(s.lng||i.language,s.fallbackLng);c.forEach(function(e){i.isValidLookup(t)||(o=e,!nd["".concat(p[0],"-").concat(e)]&&i.utils&&i.utils.hasLoadedNamespace&&!i.utils.hasLoadedNamespace(o)&&(nd["".concat(p[0],"-").concat(e)]=!0,i.logger.warn('key "'.concat(r,'" for languages "').concat(p.join(", "),'" won\'t get resolved as namespace "').concat(o,'" was not yet loaded'),"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),p.forEach(function(r){if(!i.isValidLookup(t)){a=r;var o,l=[u];if(i.i18nFormat&&i.i18nFormat.addLookupKeys)i.i18nFormat.addLookupKeys(l,u,r,e,s);else{d&&(c=i.pluralResolver.getSuffix(r,s.count,s));var c,p="".concat(i.options.pluralSeparator,"zero");if(d&&(l.push(u+c),f&&l.push(u+p)),m){var h="".concat(u).concat(i.options.contextSeparator).concat(s.context);l.push(h),d&&(l.push(h+c),f&&l.push(h+p))}}for(;o=l.pop();)i.isValidLookup(t)||(n=o,t=i.getResource(r,e,o,s))}}))})}}),{res:t,usedKey:r,exactUsedKey:n,usedLng:a,usedNS:o}}},{key:"isValidLookup",value:function(e){return void 0!==e&&!(!this.options.returnNull&&null===e)&&!(!this.options.returnEmptyString&&""===e)}},{key:"getResource",value:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return this.i18nFormat&&this.i18nFormat.getResource?this.i18nFormat.getResource(e,t,r,n):this.resourceStore.getResource(e,t,r,n)}}],[{key:"hasDefaultValue",value:function(e){var t="defaultValue";for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)&&t===r.substring(0,t.length)&&void 0!==e[r])return!0;return!1}}]),n}(r4);function nm(e){return e.charAt(0).toUpperCase()+e.slice(1)}var np=function(){function e(t){(0,rU.A)(this,e),this.options=t,this.supportedLngs=this.options.supportedLngs||!1,this.logger=r2.create("languageUtils")}return(0,rW.A)(e,[{key:"getScriptPartFromCode",value:function(e){if(!e||0>e.indexOf("-"))return null;var t=e.split("-");return 2===t.length||(t.pop(),"x"===t[t.length-1].toLowerCase())?null:this.formatLanguageCode(t.join("-"))}},{key:"getLanguagePartFromCode",value:function(e){if(!e||0>e.indexOf("-"))return e;var t=e.split("-");return this.formatLanguageCode(t[0])}},{key:"formatLanguageCode",value:function(e){if("string"==typeof e&&e.indexOf("-")>-1){var t=["hans","hant","latn","cyrl","cans","mong","arab"],r=e.split("-");return this.options.lowerCaseLng?r=r.map(function(e){return e.toLowerCase()}):2===r.length?(r[0]=r[0].toLowerCase(),r[1]=r[1].toUpperCase(),t.indexOf(r[1].toLowerCase())>-1&&(r[1]=nm(r[1].toLowerCase()))):3===r.length&&(r[0]=r[0].toLowerCase(),2===r[1].length&&(r[1]=r[1].toUpperCase()),"sgn"!==r[0]&&2===r[2].length&&(r[2]=r[2].toUpperCase()),t.indexOf(r[1].toLowerCase())>-1&&(r[1]=nm(r[1].toLowerCase())),t.indexOf(r[2].toLowerCase())>-1&&(r[2]=nm(r[2].toLowerCase()))),r.join("-")}return this.options.cleanCode||this.options.lowerCaseLng?e.toLowerCase():e}},{key:"isSupportedCode",value:function(e){return("languageOnly"===this.options.load||this.options.nonExplicitSupportedLngs)&&(e=this.getLanguagePartFromCode(e)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(e)>-1}},{key:"getBestMatchFromCodes",value:function(e){var t,r=this;return e?(e.forEach(function(e){if(!t){var n=r.formatLanguageCode(e);(!r.options.supportedLngs||r.isSupportedCode(n))&&(t=n)}}),!t&&this.options.supportedLngs&&e.forEach(function(e){if(!t){var n=r.getLanguagePartFromCode(e);if(r.isSupportedCode(n))return t=n;t=r.options.supportedLngs.find(function(e){if(0===e.indexOf(n))return e})}}),t||(t=this.getFallbackCodes(this.options.fallbackLng)[0]),t):null}},{key:"getFallbackCodes",value:function(e,t){if(!e)return[];if("function"==typeof e&&(e=e(t)),"string"==typeof e&&(e=[e]),"[object Array]"===Object.prototype.toString.apply(e))return e;if(!t)return e.default||[];var r=e[t];return r||(r=e[this.getScriptPartFromCode(t)]),r||(r=e[this.formatLanguageCode(t)]),r||(r=e[this.getLanguagePartFromCode(t)]),r||(r=e.default),r||[]}},{key:"toResolveHierarchy",value:function(e,t){var r=this,n=this.getFallbackCodes(t||this.options.fallbackLng||[],e),a=[],o=function(e){e&&(r.isSupportedCode(e)?a.push(e):r.logger.warn("rejecting language code not found in supportedLngs: ".concat(e)))};return"string"==typeof e&&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))):"string"==typeof e&&o(this.formatLanguageCode(e)),n.forEach(function(e){0>a.indexOf(e)&&o(r.formatLanguageCode(e))}),a}}]),e}(),nh=[{lngs:["ach","ak","am","arn","br","fil","gun","ln","mfe","mg","mi","oc","pt","pt-BR","tg","tl","ti","tr","uz","wa"],nr:[1,2],fc:1},{lngs:["af","an","ast","az","bg","bn","ca","da","de","dev","el","en","eo","es","et","eu","fi","fo","fur","fy","gl","gu","ha","hi","hu","hy","ia","it","kk","kn","ku","lb","mai","ml","mn","mr","nah","nap","nb","ne","nl","nn","no","nso","pa","pap","pms","ps","pt-PT","rm","sco","se","si","so","son","sq","sv","sw","ta","te","tk","ur","yo"],nr:[1,2],fc:2},{lngs:["ay","bo","cgg","fa","ht","id","ja","jbo","ka","km","ko","ky","lo","ms","sah","su","th","tt","ug","vi","wo","zh"],nr:[1],fc:3},{lngs:["be","bs","cnr","dz","hr","ru","sr","uk"],nr:[1,2,5],fc:4},{lngs:["ar"],nr:[0,1,2,3,11,100],fc:5},{lngs:["cs","sk"],nr:[1,2,5],fc:6},{lngs:["csb","pl"],nr:[1,2,5],fc:7},{lngs:["cy"],nr:[1,2,3,8],fc:8},{lngs:["fr"],nr:[1,2],fc:9},{lngs:["ga"],nr:[1,2,3,7,11],fc:10},{lngs:["gd"],nr:[1,2,3,20],fc:11},{lngs:["is"],nr:[1,2],fc:12},{lngs:["jv"],nr:[0,1],fc:13},{lngs:["kw"],nr:[1,2,3,4],fc:14},{lngs:["lt"],nr:[1,2,10],fc:15},{lngs:["lv"],nr:[1,2,0],fc:16},{lngs:["mk"],nr:[1,2],fc:17},{lngs:["mnk"],nr:[0,1,2],fc:18},{lngs:["mt"],nr:[1,2,11,20],fc:19},{lngs:["or"],nr:[2,1],fc:2},{lngs:["ro"],nr:[1,2,20],fc:20},{lngs:["sl"],nr:[5,1,2,3],fc:21},{lngs:["he","iw"],nr:[1,2,20,21],fc:22}],ng={1:function(e){return Number(e>1)},2:function(e){return Number(1!=e)},3:function(e){return 0},4:function(e){return Number(e%10==1&&e%100!=11?0:e%10>=2&&e%10<=4&&(e%100<10||e%100>=20)?1:2)},5:function(e){return Number(0==e?0:1==e?1:2==e?2:e%100>=3&&e%100<=10?3:e%100>=11?4:5)},6:function(e){return Number(1==e?0:e>=2&&e<=4?1:2)},7:function(e){return Number(1==e?0:e%10>=2&&e%10<=4&&(e%100<10||e%100>=20)?1:2)},8:function(e){return Number(1==e?0:2==e?1:8!=e&&11!=e?2:3)},9:function(e){return Number(e>=2)},10:function(e){return Number(1==e?0:2==e?1:e<7?2:e<11?3:4)},11:function(e){return Number(1==e||11==e?0:2==e||12==e?1:e>2&&e<20?2:3)},12:function(e){return Number(e%10!=1||e%100==11)},13:function(e){return Number(0!==e)},14:function(e){return Number(1==e?0:2==e?1:3==e?2:3)},15:function(e){return Number(e%10==1&&e%100!=11?0:e%10>=2&&(e%100<10||e%100>=20)?1:2)},16:function(e){return Number(e%10==1&&e%100!=11?0:0!==e?1:2)},17:function(e){return Number(+(1!=e&&(e%10!=1||e%100==11)))},18:function(e){return Number(0==e?0:1==e?1:2)},19:function(e){return Number(1==e?0:0==e||e%100>1&&e%100<11?1:e%100>10&&e%100<20?2:3)},20:function(e){return Number(1==e?0:0==e||e%100>0&&e%100<20?1:2)},21:function(e){return Number(e%100==1?1:e%100==2?2:3*(e%100==3||e%100==4))},22:function(e){return Number(1==e?0:2==e?1:(e<0||e>10)&&e%10==0?2:3)}},ny=["v1","v2","v3"],nv={zero:0,one:1,two:2,few:3,many:4,other:5},nb=function(){function e(t){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};(0,rU.A)(this,e),this.languageUtils=t,this.options=n,this.logger=r2.create("pluralResolver"),(!this.options.compatibilityJSON||"v4"===this.options.compatibilityJSON)&&("u"<typeof Intl||!Intl.PluralRules)&&(this.options.compatibilityJSON="v3",this.logger.error("Your environment seems not to be Intl API compatible, use an Intl.PluralRules polyfill. Will fallback to the compatibilityJSON v3 format handling.")),this.rules=(r={},nh.forEach(function(e){e.lngs.forEach(function(t){r[t]={numbers:e.nr,plurals:ng[e.fc]}})}),r)}return(0,rW.A)(e,[{key:"addRule",value:function(e,t){this.rules[e]=t}},{key:"getRule",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(this.shouldUseIntlApi())try{return new Intl.PluralRules(e,{type:t.ordinal?"ordinal":"cardinal"})}catch(e){return}return this.rules[e]||this.rules[this.languageUtils.getLanguagePartFromCode(e)]}},{key:"needsPlural",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=this.getRule(e,t);return this.shouldUseIntlApi()?r&&r.resolvedOptions().pluralCategories.length>1:r&&r.numbers.length>1}},{key:"getPluralFormsOfKey",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.getSuffixes(e,r).map(function(e){return"".concat(t).concat(e)})}},{key:"getSuffixes",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=this.getRule(e,r);return n?this.shouldUseIntlApi()?n.resolvedOptions().pluralCategories.sort(function(e,t){return nv[e]-nv[t]}).map(function(e){return"".concat(t.options.prepend).concat(e)}):n.numbers.map(function(n){return t.getSuffix(e,n,r)}):[]}},{key:"getSuffix",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=this.getRule(e,r);return n?this.shouldUseIntlApi()?"".concat(this.options.prepend).concat(n.select(t)):this.getSuffixRetroCompatible(n,t):(this.logger.warn("no plural rule found for: ".concat(e)),"")}},{key:"getSuffixRetroCompatible",value:function(e,t){var r=this,n=e.noAbs?e.plurals(t):e.plurals(Math.abs(t)),a=e.numbers[n];this.options.simplifyPluralSuffix&&2===e.numbers.length&&1===e.numbers[0]&&(2===a?a="plural":1===a&&(a=""));var o=function(){return r.options.prepend&&a.toString()?r.options.prepend+a.toString():a.toString()};return"v1"===this.options.compatibilityJSON?1===a?"":"number"==typeof a?"_plural_".concat(a.toString()):o():"v2"===this.options.compatibilityJSON||this.options.simplifyPluralSuffix&&2===e.numbers.length&&1===e.numbers[0]?o():this.options.prepend&&n.toString()?this.options.prepend+n.toString():n.toString()}},{key:"shouldUseIntlApi",value:function(){return!ny.includes(this.options.compatibilityJSON)}}]),e}();function nw(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function nE(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?nw(Object(r),!0).forEach(function(t){(0,rY.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):nw(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var nx=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};(0,rU.A)(this,e),this.logger=r2.create("interpolator"),this.options=t,this.format=t.interpolation&&t.interpolation.format||function(e){return e},this.init(t)}return(0,rW.A)(e,[{key:"init",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};e.interpolation||(e.interpolation={escapeValue:!0});var t=e.interpolation;this.escape=void 0!==t.escape?t.escape:nr,this.escapeValue=void 0===t.escapeValue||t.escapeValue,this.useRawValueToEscape=void 0!==t.useRawValueToEscape&&t.useRawValueToEscape,this.prefix=t.prefix?ne(t.prefix):t.prefixEscaped||"{{",this.suffix=t.suffix?ne(t.suffix):t.suffixEscaped||"}}",this.formatSeparator=t.formatSeparator?t.formatSeparator:t.formatSeparator||",",this.unescapePrefix=t.unescapeSuffix?"":t.unescapePrefix||"-",this.unescapeSuffix=this.unescapePrefix?"":t.unescapeSuffix||"",this.nestingPrefix=t.nestingPrefix?ne(t.nestingPrefix):t.nestingPrefixEscaped||ne("$t("),this.nestingSuffix=t.nestingSuffix?ne(t.nestingSuffix):t.nestingSuffixEscaped||ne(")"),this.nestingOptionsSeparator=t.nestingOptionsSeparator?t.nestingOptionsSeparator:t.nestingOptionsSeparator||",",this.maxReplaces=t.maxReplaces?t.maxReplaces:1e3,this.alwaysFormat=void 0!==t.alwaysFormat&&t.alwaysFormat,this.resetRegExp()}},{key:"reset",value:function(){this.options&&this.init(this.options)}},{key:"resetRegExp",value:function(){var e="".concat(this.prefix,"(.+?)").concat(this.suffix);this.regexp=RegExp(e,"g");var t="".concat(this.prefix).concat(this.unescapePrefix,"(.+?)").concat(this.unescapeSuffix).concat(this.suffix);this.regexpUnescape=RegExp(t,"g");var r="".concat(this.nestingPrefix,"(.+?)").concat(this.nestingSuffix);this.nestingRegexp=RegExp(r,"g")}},{key:"interpolate",value:function(e,t,r,n){var a,o,i,s=this,l=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{};function u(e){return e.replace(/\$/g,"$$$$")}var c=function(e){if(0>e.indexOf(s.formatSeparator)){var a=r7(t,l,e);return s.alwaysFormat?s.format(a,void 0,r,nE(nE(nE({},n),t),{},{interpolationkey:e})):a}var o=e.split(s.formatSeparator),i=o.shift().trim(),u=o.join(s.formatSeparator).trim();return s.format(r7(t,l,i),u,r,nE(nE(nE({},n),t),{},{interpolationkey:i}))};this.resetRegExp();var d=n&&n.missingInterpolationHandler||this.options.missingInterpolationHandler,f=n&&n.interpolation&&void 0!==n.interpolation.skipOnVariables?n.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:function(e){return u(e)}},{regex:this.regexp,safeValue:function(e){return s.escapeValue?u(s.escape(e)):u(e)}}].forEach(function(t){for(i=0;a=t.regex.exec(e);){var r=a[1].trim();if(void 0===(o=c(r)))if("function"==typeof d){var l=d(e,a,n);o="string"==typeof l?l:""}else if(n&&n.hasOwnProperty(r))o="";else if(f){o=a[0];continue}else s.logger.warn("missed to pass in variable ".concat(r," for interpolating ").concat(e)),o="";else"string"==typeof o||s.useRawValueToEscape||(o=r6(o));var u=t.safeValue(o);if(e=e.replace(a[0],u),f?(t.regex.lastIndex+=o.length,t.regex.lastIndex-=a[0].length):t.regex.lastIndex=0,++i>=s.maxReplaces)break}}),e}},{key:"nest",value:function(e,t){var r,n,a=this,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=nE({},o);function s(e,t){var r=this.nestingOptionsSeparator;if(0>e.indexOf(r))return e;var n=e.split(new RegExp("".concat(r,"[ ]*{"))),a="{".concat(n[1]);e=n[0];var o=(a=this.interpolate(a,i)).match(/'/g),s=a.match(/"/g);(o&&o.length%2==0&&!s||s.length%2!=0)&&(a=a.replace(/'/g,'"'));try{i=JSON.parse(a),t&&(i=nE(nE({},t),i))}catch(t){return this.logger.warn("failed parsing options string in nesting for key ".concat(e),t),"".concat(e).concat(r).concat(a)}return delete i.defaultValue,e}for(i.applyPostProcessor=!1,delete i.defaultValue;r=this.nestingRegexp.exec(e);){var l=[],u=!1;if(-1!==r[0].indexOf(this.formatSeparator)&&!/{.*}/.test(r[1])){var c=r[1].split(this.formatSeparator).map(function(e){return e.trim()});r[1]=c.shift(),l=c,u=!0}if((n=t(s.call(this,r[1].trim(),i),i))&&r[0]===e&&"string"!=typeof n)return n;"string"!=typeof n&&(n=r6(n)),n||(this.logger.warn("missed to resolve ".concat(r[1]," for nesting ").concat(e)),n=""),u&&(n=l.reduce(function(e,t){return a.format(e,t,o.lng,nE(nE({},o),{},{interpolationkey:r[1].trim()}))},n.trim())),e=e.replace(r[0],n),this.regexp.lastIndex=0}return e}}]),e}();function nD(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function nS(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?nD(Object(r),!0).forEach(function(t){(0,rY.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):nD(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function n_(e){var t={};return function(r,n,a){var o=n+JSON.stringify(a),i=t[o];return i||(i=e(n,a),t[o]=i),i(r)}}var nC=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};(0,rU.A)(this,e),this.logger=r2.create("formatter"),this.options=t,this.formats={number:n_(function(e,t){var r=new Intl.NumberFormat(e,t);return function(e){return r.format(e)}}),currency:n_(function(e,t){var r=new Intl.NumberFormat(e,nS(nS({},t),{},{style:"currency"}));return function(e){return r.format(e)}}),datetime:n_(function(e,t){var r=new Intl.DateTimeFormat(e,nS({},t));return function(e){return r.format(e)}}),relativetime:n_(function(e,t){var r=new Intl.RelativeTimeFormat(e,nS({},t));return function(e){return r.format(e,t.range||"day")}}),list:n_(function(e,t){var r=new Intl.ListFormat(e,nS({},t));return function(e){return r.format(e)}})},this.init(t)}return(0,rW.A)(e,[{key:"init",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{interpolation:{}},r=t.interpolation;this.formatSeparator=r.formatSeparator?r.formatSeparator:r.formatSeparator||","}},{key:"add",value:function(e,t){this.formats[e.toLowerCase().trim()]=t}},{key:"addCached",value:function(e,t){this.formats[e.toLowerCase().trim()]=n_(t)}},{key:"format",value:function(e,t,r,n){var a=this;return t.split(this.formatSeparator).reduce(function(e,t){var o=function(e){var t=e.toLowerCase().trim(),r={};if(e.indexOf("(")>-1){var n=e.split("(");t=n[0].toLowerCase().trim();var a=n[1].substring(0,n[1].length-1);"currency"===t&&0>a.indexOf(":")?r.currency||(r.currency=a.trim()):"relativetime"===t&&0>a.indexOf(":")?r.range||(r.range=a.trim()):a.split(";").forEach(function(e){if(e){var t,n=(t=e.split(":"),(0,rq.A)(t)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(t)||(0,rJ.A)(t)||(0,rX.A)()),a=n[0],o=n.slice(1).join(":").trim().replace(/^'+|'+$/g,"");r[a.trim()]||(r[a.trim()]=o),"false"===o&&(r[a.trim()]=!1),"true"===o&&(r[a.trim()]=!0),isNaN(o)||(r[a.trim()]=parseInt(o,10))}})}return{formatName:t,formatOptions:r}}(t),i=o.formatName,s=o.formatOptions;if(a.formats[i]){var l=e;try{var u=n&&n.formatParams&&n.formatParams[n.interpolationkey]||{},c=u.locale||u.lng||n.locale||n.lng||r;l=a.formats[i](e,c,nS(nS(nS({},s),n),u))}catch(e){a.logger.warn(e)}return l}return a.logger.warn("there was no format function for ".concat(i)),e},e)}}]),e}();function nk(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function nP(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?nk(Object(r),!0).forEach(function(t){(0,rY.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):nk(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var nR=function(e){rK(n,e);var t,r=(t=function(){if("u"<typeof Reflect||!Reflect.construct||Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}(),function(){var e,r=rZ(n);return e=t?Reflect.construct(r,arguments,rZ(this).constructor):r.apply(this,arguments),rG(this,e)});function n(e,t,a){var o,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return(0,rU.A)(this,n),o=r.call(this),nn&&r4.call(rH(o)),o.backend=e,o.store=t,o.services=a,o.languageUtils=a.languageUtils,o.options=i,o.logger=r2.create("backendConnector"),o.waitingReads=[],o.maxParallelReads=i.maxParallelReads||10,o.readingCalls=0,o.maxRetries=i.maxRetries>=0?i.maxRetries:5,o.retryTimeout=i.retryTimeout>=1?i.retryTimeout:350,o.state={},o.queue=[],o.backend&&o.backend.init&&o.backend.init(a,i.backend,i),o}return(0,rW.A)(n,[{key:"queueLoad",value:function(e,t,r,n){var a=this,o={},i={},s={},l={};return e.forEach(function(e){var n=!0;t.forEach(function(t){var s="".concat(e,"|").concat(t);!r.reload&&a.store.hasResourceBundle(e,t)?a.state[s]=2:a.state[s]<0||(1===a.state[s]?void 0===i[s]&&(i[s]=!0):(a.state[s]=1,n=!1,void 0===i[s]&&(i[s]=!0),void 0===o[s]&&(o[s]=!0),void 0===l[t]&&(l[t]=!0)))}),n||(s[e]=!0)}),(Object.keys(o).length||Object.keys(i).length)&&this.queue.push({pending:i,pendingCount:Object.keys(i).length,loaded:{},errors:[],callback:n}),{toLoad:Object.keys(o),pending:Object.keys(i),toLoadLanguages:Object.keys(s),toLoadNamespaces:Object.keys(l)}}},{key:"loaded",value:function(e,t,r){var n=e.split("|"),a=n[0],o=n[1];t&&this.emit("failedLoading",a,o,t),r&&this.store.addResourceBundle(a,o,r),this.state[e]=t?-1:2;var i={};this.queue.forEach(function(r){var n,s,l,u;n=r.loaded,(l=(s=r5(n,[a],Object)).obj)[u=s.k]=l[u]||[],l[u].push(o),void 0!==r.pending[e]&&(delete r.pending[e],r.pendingCount--),t&&r.errors.push(t),0!==r.pendingCount||r.done||(Object.keys(r.loaded).forEach(function(e){i[e]||(i[e]={});var t=r.loaded[e];t.length&&t.forEach(function(t){void 0===i[e][t]&&(i[e][t]=!0)})}),r.done=!0,r.errors.length?r.callback(r.errors):r.callback())}),this.emit("loaded",i),this.queue=this.queue.filter(function(e){return!e.done})}},{key:"read",value:function(e,t,r){var n=this,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:this.retryTimeout,i=arguments.length>5?arguments[5]:void 0;return e.length?this.readingCalls>=this.maxParallelReads?void this.waitingReads.push({lng:e,ns:t,fcName:r,tried:a,wait:o,callback:i}):(this.readingCalls++,this.backend[r](e,t,function(s,l){if(n.readingCalls--,n.waitingReads.length>0){var u=n.waitingReads.shift();n.read(u.lng,u.ns,u.fcName,u.tried,u.wait,u.callback)}s&&l&&a<n.maxRetries?setTimeout(function(){n.read.call(n,e,t,r,a+1,2*o,i)},o):i(s,l)})):i(null,{})}},{key:"prepareLoading",value:function(e,t){var r=this,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a=arguments.length>3?arguments[3]:void 0;if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),a&&a();"string"==typeof e&&(e=this.languageUtils.toResolveHierarchy(e)),"string"==typeof t&&(t=[t]);var o=this.queueLoad(e,t,n,a);if(!o.toLoad.length)return o.pending.length||a(),null;o.toLoad.forEach(function(e){r.loadOne(e)})}},{key:"load",value:function(e,t,r){this.prepareLoading(e,t,{},r)}},{key:"reload",value:function(e,t,r){this.prepareLoading(e,t,{reload:!0},r)}},{key:"loadOne",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=e.split("|"),a=n[0],o=n[1];this.read(a,o,"read",void 0,void 0,function(n,i){n&&t.logger.warn("".concat(r,"loading namespace ").concat(o," for language ").concat(a," failed"),n),!n&&i&&t.logger.log("".concat(r,"loaded namespace ").concat(o," for language ").concat(a),i),t.loaded(e,n,i)})}},{key:"saveMissing",value:function(e,t,r,n,a){var o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{};this.services.utils&&this.services.utils.hasLoadedNamespace&&!this.services.utils.hasLoadedNamespace(t)?this.logger.warn('did not save key "'.concat(r,'" as the namespace "').concat(t,'" was not yet loaded'),"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!"):null==r||""===r||(this.backend&&this.backend.create&&this.backend.create(e,t,r,n,null,nP(nP({},o),{},{isUpdate:a})),e&&e[0]&&this.store.addResource(e[0],t,r,n))}}]),n}(r4);function nO(e){return"string"==typeof e.ns&&(e.ns=[e.ns]),"string"==typeof e.fallbackLng&&(e.fallbackLng=[e.fallbackLng]),"string"==typeof e.fallbackNS&&(e.fallbackNS=[e.fallbackNS]),e.supportedLngs&&0>e.supportedLngs.indexOf("cimode")&&(e.supportedLngs=e.supportedLngs.concat(["cimode"])),e}function nT(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function nN(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?nT(Object(r),!0).forEach(function(t){(0,rY.A)(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):nT(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function n$(){}var nI=function(e){rK(n,e);var t,r=(t=function(){if("u"<typeof Reflect||!Reflect.construct||Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}(),function(){var e,r=rZ(n);return e=t?Reflect.construct(r,arguments,rZ(this).constructor):r.apply(this,arguments),rG(this,e)});function n(){var e,t,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},o=arguments.length>1?arguments[1]:void 0;if((0,rU.A)(this,n),t=r.call(this),nn&&r4.call(rH(t)),t.options=nO(a),t.services={},t.logger=r2,t.modules={external:[]},Object.getOwnPropertyNames(Object.getPrototypeOf(e=rH(t))).forEach(function(t){"function"==typeof e[t]&&(e[t]=e[t].bind(e))}),o&&!t.isInitialized&&!a.isClone){if(!t.options.initImmediate)return t.init(a,o),rG(t,rH(t));setTimeout(function(){t.init(a,o)},0)}return t}return(0,rW.A)(n,[{key:"init",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0;"function"==typeof t&&(r=t,t={}),!t.defaultNS&&!1!==t.defaultNS&&t.ns&&("string"==typeof t.ns?t.defaultNS=t.ns:0>t.ns.indexOf("translation")&&(t.defaultNS=t.ns[0]));var n={debug:!1,initImmediate:!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:!0,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:function(e){var t={};if("object"===(0,rV.A)(e[1])&&(t=e[1]),"string"==typeof e[1]&&(t.defaultValue=e[1]),"string"==typeof e[2]&&(t.tDescription=e[2]),"object"===(0,rV.A)(e[2])||"object"===(0,rV.A)(e[3])){var r=e[3]||e[2];Object.keys(r).forEach(function(e){t[e]=r[e]})}return t},interpolation:{escapeValue:!0,format:function(e,t,r,n){return e},prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0}};function a(e){return e?"function"==typeof e?new e:e:null}if(this.options=nN(nN(nN({},n),this.options),nO(t)),"v1"!==this.options.compatibilityAPI&&(this.options.interpolation=nN(nN({},n.interpolation),this.options.interpolation)),void 0!==t.keySeparator&&(this.options.userDefinedKeySeparator=t.keySeparator),void 0!==t.nsSeparator&&(this.options.userDefinedNsSeparator=t.nsSeparator),!this.options.isClone){this.modules.logger?r2.init(a(this.modules.logger),this.options):r2.init(null,this.options),this.modules.formatter?o=this.modules.formatter:"u">typeof Intl&&(o=nC);var o,i=new np(this.options);this.store=new ns(this.options.resources,this.options);var s=this.services;s.logger=r2,s.resourceStore=this.store,s.languageUtils=i,s.pluralResolver=new nb(i,{prepend:this.options.pluralSeparator,compatibilityJSON:this.options.compatibilityJSON,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),o&&(!this.options.interpolation.format||this.options.interpolation.format===n.interpolation.format)&&(s.formatter=a(o),s.formatter.init(s,this.options),this.options.interpolation.format=s.formatter.format.bind(s.formatter)),s.interpolator=new nx(this.options),s.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},s.backendConnector=new nR(a(this.modules.backend),s.resourceStore,s,this.options),s.backendConnector.on("*",function(t){for(var r=arguments.length,n=Array(r>1?r-1:0),a=1;a<r;a++)n[a-1]=arguments[a];e.emit.apply(e,[t].concat(n))}),this.modules.languageDetector&&(s.languageDetector=a(this.modules.languageDetector),s.languageDetector.init(s,this.options.detection,this.options)),this.modules.i18nFormat&&(s.i18nFormat=a(this.modules.i18nFormat),s.i18nFormat.init&&s.i18nFormat.init(this)),this.translator=new nf(this.services,this.options),this.translator.on("*",function(t){for(var r=arguments.length,n=Array(r>1?r-1:0),a=1;a<r;a++)n[a-1]=arguments[a];e.emit.apply(e,[t].concat(n))}),this.modules.external.forEach(function(t){t.init&&t.init(e)})}if(this.format=this.options.interpolation.format,r||(r=n$),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){var l=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);l.length>0&&"dev"!==l[0]&&(this.options.lng=l[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(function(t){e[t]=function(){var r;return(r=e.store)[t].apply(r,arguments)}}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(function(t){e[t]=function(){var r;return(r=e.store)[t].apply(r,arguments),e}});var u=r3(),c=function(){var t=function(t,n){e.isInitialized&&!e.initializedStoreOnce&&e.logger.warn("init: i18next is already initialized. You should call init just once!"),e.isInitialized=!0,e.options.isClone||e.logger.log("initialized",e.options),e.emit("initialized",e.options),u.resolve(n),r(t,n)};if(e.languages&&"v1"!==e.options.compatibilityAPI&&!e.isInitialized)return t(null,e.t.bind(e));e.changeLanguage(e.options.lng,t)};return this.options.resources||!this.options.initImmediate?c():setTimeout(c,0),u}},{key:"loadResources",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:n$,n=r,a="string"==typeof e?e:this.language;if("function"==typeof e&&(n=e),!this.options.resources||this.options.partialBundledLanguages){if(a&&"cimode"===a.toLowerCase())return n();var o=[],i=function(e){e&&t.services.languageUtils.toResolveHierarchy(e).forEach(function(e){0>o.indexOf(e)&&o.push(e)})};a?i(a):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(function(e){return i(e)}),this.options.preload&&this.options.preload.forEach(function(e){return i(e)}),this.services.backendConnector.load(o,this.options.ns,function(e){e||t.resolvedLanguage||!t.language||t.setResolvedLanguage(t.language),n(e)})}else n(null)}},{key:"reloadResources",value:function(e,t,r){var n=r3();return e||(e=this.languages),t||(t=this.options.ns),r||(r=n$),this.services.backendConnector.reload(e,t,function(e){n.resolve(),r(e)}),n}},{key:"use",value:function(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&&nl.addPostProcessor(e),"formatter"===e.type&&(this.modules.formatter=e),"3rdParty"===e.type&&this.modules.external.push(e),this}},{key:"setResolvedLanguage",value:function(e){if(e&&this.languages&&!(["cimode","dev"].indexOf(e)>-1))for(var t=0;t<this.languages.length;t++){var r=this.languages[t];if(!(["cimode","dev"].indexOf(r)>-1)&&this.store.hasLanguageSomeTranslations(r)){this.resolvedLanguage=r;break}}}},{key:"changeLanguage",value:function(e,t){var r=this;this.isLanguageChangingTo=e;var n=r3();this.emit("languageChanging",e);var a=function(e){r.language=e,r.languages=r.services.languageUtils.toResolveHierarchy(e),r.resolvedLanguage=void 0,r.setResolvedLanguage(e)},o=function(e,o){o?(a(o),r.translator.changeLanguage(o),r.isLanguageChangingTo=void 0,r.emit("languageChanged",o),r.logger.log("languageChanged",o)):r.isLanguageChangingTo=void 0,n.resolve(function(){return r.t.apply(r,arguments)}),t&&t(e,function(){return r.t.apply(r,arguments)})},i=function(t){e||t||!r.services.languageDetector||(t=[]);var n="string"==typeof t?t:r.services.languageUtils.getBestMatchFromCodes(t);n&&(r.language||a(n),r.translator.language||r.translator.changeLanguage(n),r.services.languageDetector&&r.services.languageDetector.cacheUserLanguage(n)),r.loadResources(n,function(e){o(e,n)})};return e||!this.services.languageDetector||this.services.languageDetector.async?!e&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect(i):i(e):i(this.services.languageDetector.detect()),n}},{key:"getFixedT",value:function(e,t,r){var n=this,a=function e(t,a){if("object"!==(0,rV.A)(a)){for(var o,i=arguments.length,s=Array(i>2?i-2:0),l=2;l<i;l++)s[l-2]=arguments[l];o=n.options.overloadTranslationOptionHandler([t,a].concat(s))}else o=nN({},a);o.lng=o.lng||e.lng,o.lngs=o.lngs||e.lngs,o.ns=o.ns||e.ns,o.keyPrefix=o.keyPrefix||r||e.keyPrefix;var u=n.options.keySeparator||".",c=o.keyPrefix?"".concat(o.keyPrefix).concat(u).concat(t):t;return n.t(c,o)};return"string"==typeof e?a.lng=e:a.lngs=e,a.ns=t,a.keyPrefix=r,a}},{key:"t",value:function(){var e;return this.translator&&(e=this.translator).translate.apply(e,arguments)}},{key:"exists",value:function(){var e;return this.translator&&(e=this.translator).exists.apply(e,arguments)}},{key:"setDefaultNamespace",value:function(e){this.options.defaultNS=e}},{key:"hasLoadedNamespace",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};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;var n=this.resolvedLanguage||this.languages[0],a=!!this.options&&this.options.fallbackLng,o=this.languages[this.languages.length-1];if("cimode"===n.toLowerCase())return!0;var i=function(e,r){var n=t.services.backendConnector.state["".concat(e,"|").concat(r)];return -1===n||2===n};if(r.precheck){var s=r.precheck(this,i);if(void 0!==s)return s}return!!(this.hasResourceBundle(n,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||i(n,e)&&(!a||i(o,e)))}},{key:"loadNamespaces",value:function(e,t){var r=this,n=r3();return this.options.ns?("string"==typeof e&&(e=[e]),e.forEach(function(e){0>r.options.ns.indexOf(e)&&r.options.ns.push(e)}),this.loadResources(function(e){n.resolve(),t&&t(e)}),n):(t&&t(),Promise.resolve())}},{key:"loadLanguages",value:function(e,t){var r=r3();"string"==typeof e&&(e=[e]);var n=this.options.preload||[],a=e.filter(function(e){return 0>n.indexOf(e)});return a.length?(this.options.preload=n.concat(a),this.loadResources(function(e){r.resolve(),t&&t(e)}),r):(t&&t(),Promise.resolve())}},{key:"dir",value:function(e){return(e||(e=this.resolvedLanguage||(this.languages&&this.languages.length>0?this.languages[0]:this.language)),e)?["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(this.services.languageUtils.getLanguagePartFromCode(e))>-1||e.toLowerCase().indexOf("-arab")>1?"rtl":"ltr":"rtl"}},{key:"cloneInstance",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:n$,a=nN(nN(nN({},this.options),t),{isClone:!0}),o=new n(a);return(void 0!==t.debug||void 0!==t.prefix)&&(o.logger=o.logger.clone(t)),["store","services","language"].forEach(function(t){o[t]=e[t]}),o.services=nN({},this.services),o.services.utils={hasLoadedNamespace:o.hasLoadedNamespace.bind(o)},o.translator=new nf(o.services,o.options),o.translator.on("*",function(e){for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];o.emit.apply(o,[e].concat(r))}),o.init(a,r),o.translator.options=o.options,o.translator.backendConnector.services.utils={hasLoadedNamespace:o.hasLoadedNamespace.bind(o)},o}},{key:"toJSON",value:function(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}]),n}(r4);(0,rY.A)(nI,"createInstance",function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;return new nI(e,t)});var nM=nI.createInstance();nM.createInstance=nI.createInstance,nM.createInstance,nM.init,nM.loadResources,nM.reloadResources,nM.use,nM.changeLanguage,nM.getFixedT,nM.t,nM.exists,nM.setDefaultNamespace,nM.hasLoadedNamespace,nM.loadNamespaces,nM.loadLanguages;let nA=nM.default||nM;function nj(e,t,r,n){return nA.t(t,{ns:e,defaultValue:r,...n})}function nL(e,t,r){return rB[e]?nj("core",e,t??rB[e],r):(console.error(`O3 Core Translations does not provide key '${e}'. The key itself is being rendered as text.`),e)}function nF(e,t){let r=window.getOpenmrsSpaBase().replace(/\/$/,""),n=nB(e,{openmrsBase:window.openmrsBase,openmrsSpaBase:r,...t});return e.startsWith("//")?n:n.replace(/^\/\//,"/")}function nB(e,t){return Object.keys(t).reduce((e,r)=>e.split("${"+r+"}").join(t[r]),e)}function nV({to:e,templateParams:t}){let r=window.getOpenmrsSpaBase().replace(/\/$/,""),n=nF(e,t).replace(window.location.origin,""),a=new URL(n,window.location.origin);if("http:"!=a.protocol&&"https:"!=a.protocol)throw console.error(`Received request to navigate to non-http URL: ${a.toString()}`),Error(nL("navigateNonHttp"));n.startsWith(r)?ro(n):window.location.assign(n)}nA.on("initialized",function(){window.i18next.loadNamespaces(["core"])});let nU="openmrs:history";function nW(e){let t=JSON.parse(sessionStorage.getItem(nU)??"[]")||[];t.push(e),t.length>50&&(t=t.slice(-50)),sessionStorage.setItem(nU,JSON.stringify(t))}function nH(){0===JSON.parse(sessionStorage.getItem(nU)??"[]").length&&document.referrer&&nW(document.referrer),window.addEventListener("single-spa:routing-event",e=>{let t=nz();e.detail.originalEvent?.singleSpaTrigger=="replaceState"?(t[t.length-1]=window.location.href,sessionStorage.setItem(nU,JSON.stringify(t))):!e.detail.originalEvent?.singleSpa&&t.includes(window.location.href)?nK({toUrl:window.location.href}):t[t.length-1]!==window.location.href&&nW(window.location.href)})}function nz(){return JSON.parse(sessionStorage.getItem(nU)??"[]")}function nK({toUrl:e}){let t=nz(),r=t.lastIndexOf(e);if(-1!=r){let e=t.slice(0,r+1);nV({to:t[r]}),sessionStorage.setItem(nU,JSON.stringify(e))}else throw Error(`URL ${e} not found in history; cannot go back to it.`)}function nG(){sessionStorage.removeItem(nU)}let nZ="${openmrsSpaBase}/login",nY={redirectAuthFailure:{enabled:{_type:Q.Boolean,_default:!0,_description:"Whether to redirect logged-out users to `redirectAuthFailure.url`"},url:{_type:Q.String,_default:nZ,_validators:[ti.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:Q.Array,_default:[401],_elements:{_type:Q.Number,_validators:[ti.inRange(100,600)]},_description:"The HTTP error codes for which users will be redirected"},resolvePromise:{_type:Q.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:Q.Boolean,_default:!0,_description:"Whether openmrsFetch should support redirects returned from the backend"}};function nq(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}let nJ="/ws/rest/v1",nX="/ws/fhir2/R4",nQ=`${nJ}/session`;function n0(e){return e&&e.startsWith("http")?e:("/"!==e[0]&&(e="/"+e),window.openmrsBase+e)}function n1(e,t={}){if("string"!=typeof e)throw Error("The first argument to @openmrs/api's openmrsFetch function must be a url string");if("object"!=typeof t)throw Error("The second argument to @openmrs/api's openmrsFetch function must be a plain object.");if(!window.openmrsBase)throw Error("@openmrs/api is running in a browser that doesn't have window.openmrsBase, which is provided by openmrs-module-spa's HTML file.");let r=n0(e);t.headers||(t.headers={}),(0,X.isPlainObject)(t.body)&&(t.body=JSON.stringify(t.body)),void 0===t.headers.Accept&&(t.headers.Accept="application/json"),null===t.headers.Accept&&delete t.headers.Accept;let n=!1;try{let e=new URL(r,window.location.href),t=new URL(n0(nJ),window.location.href),a=e.pathname.replace(/\/{2,}/g,"/"),o=t.pathname.replace(/\/{2,}/g,"/");n=e.origin===t.origin&&(a===o||a.startsWith(`${o}/`))}catch{}if(n){let e=!1;for(let[r,n]of Object.entries(t.headers))"disable-www-authenticate"===r.toLowerCase()&&(void 0===n?delete t.headers[r]:e=!0);e||(t.headers["Disable-WWW-Authenticate"]="true")}if(e.startsWith(nX)){let e=new URL(r,window.location.toString());e.searchParams.has("_summary")||(e.searchParams.set("_summary","data"),r=e.toString())}let a=Error();return window.fetch(r,t).then(async e=>{let{redirectAuthFailure:n,followRedirects:o}=await eH("@openmrs/esm-api");if(e.ok){let t=e.headers.get("location");return(o&&t&&(r===n0(nQ)||204===e.status)&&nV({to:t}),204===e.status)?(e.data=null,e):e.clone().text().then(t=>{try{t&&(e.data=JSON.parse(t))}catch(e){}return e})}return(r===n0(nQ)&&403===e.status||n.enabled&&n.errors.includes(e.status))&&(nG(),nV({to:n.url||e.headers.get("location")||nZ}),!0!==t.rejectAuthFailure)?n.resolvePromise?Promise.resolve():new Promise(()=>{}):e.clone().text().then(t=>{let n=t;try{n=JSON.parse(t)}catch(e){}throw new n2(r,e,n,a)},()=>{throw new n2(r,e,null,a)})})}class n2 extends Error{constructor(e,t,r,n){super(),nq(this,"response",void 0),nq(this,"responseBody",void 0),this.message=`Server responded with ${t.status} (${t.statusText}) for url ${e}. Check err.responseBody or network tab in dev tools for more info`,n.message=this.message,this.responseBody=r,this.response=t,this.stack=`Stacktrace for outgoing request:
|
|
13
13
|
${n.stack}
|
|
14
14
|
Stacktrace for incoming response:
|
|
15
|
-
${this.stack}`}}let n4=V("session",{loaded:!1,session:null}),n3=0,n6=null;function n5(){return n6||(n4.getState().loaded&&n3>=Date.now()-6e4?null:ae())}function n9(e){let t=e?.includeAuthStatus??!0,r=e=>t?e:e.user,n=n5();return n?new Promise(e=>{let t=()=>{let t=n4.getState();t.loaded&&(a(),e(r(t.session)))},a=n4.subscribe(t);n.then(t,t)}):Promise.resolve(r(n4.getState().session))}function n8(){return n5(),n4}function n7(e){let t=e.locale??e.user?.userProperties?.defaultLocale;t&&t.includes("_")&&(t=t.replaceAll("_","-")),function(e){if(void 0===e||"string"!=typeof e)return!1;try{new Intl.Locale(e)}catch(e){return!1}return!0}(t)&&t!==document.documentElement.getAttribute("lang")&&document.documentElement.setAttribute("lang",t)}function ae(e,t){n3=Date.now(),o??(o=n3);let r={};e&&t&&(r.Authorization=`Basic ${window.btoa(`${e}:${t}`)}`);let n=ac(n1(nQ,{headers:r,rejectAuthFailure:!0})),a=()=>{n6===n&&(n6=null)};return n.then(a,a),n6=n,n}function at(){n4.setState({loaded:!0,session:{authenticated:!1,sessionId:""}},!0)}function ar(e,t){var r,n;if(void 0===t)return!e;if(!e)return!0;return r=e,n=t,("string"==typeof r?!(0,X.isUndefined)(n.privileges.find(e=>r===e.display)):Array.isArray(r)?r.every(e=>!(0,X.isUndefined)(n.privileges.find(t=>e===t.display))):((0,X.isUndefined)(r)||console.error(`Could not understand privileges "${r}"`),!0))||!(0,X.isUndefined)(t.roles.find(e=>"System Developer"===e.display))}function an(){let e,t;return new Promise(r=>{let n=n=>{n.loaded&&n.session.user&&(e=n.session.user,r(n.session.user),t&&t())};n(n4.getState()),e||(t=n4.subscribe(n))})}async function aa(){return(await n9()).sessionLocation}async function ao(e,t){return ac(n1(nQ,{method:"POST",body:{sessionLocation:e},headers:{"Content-Type":"application/json"},rejectAuthFailure:!0,signal:t?.signal}))}async function ai(e,t){return await n1(nQ,{method:"POST",body:{locale:e},headers:{"Content-Type":"application/json"},signal:t?.signal}),ae()}async function as(e,t,r){return r||(r=new AbortController),await n1(`${nJ}/user/${e}`,{method:"POST",body:{userProperties:t},headers:{"Content-Type":"application/json"},signal:r.signal}),ae()}async function al(e,t=!1){let r=await n1(t?`${nQ}?rememberMe=true`:nQ,{headers:{"X-Totp-Code":e}});return r.data?.authenticated?(await ae()).session:r.data}async function au(){try{await n1(nQ,{method:"DELETE",rejectAuthFailure:!0})}catch(e){if(!ad(e))throw e}at(),await ae().catch(()=>{})}function ac(e){return new Promise((t,r)=>{e.then(e=>{if("object"==typeof e?.data){let r={loaded:!0,session:e.data};n4.setState(r,!0),t(r)}else!function(e){if(!e?.redirected||!e.url)return!1;try{return new URL(e.url,window.location.href).pathname.replace(/\/+$/,"").endsWith("/initialsetup")}catch{return!1}}(e)?r(af(Error("The session endpoint did not respond with a session"))):r(af(Error("The server is still starting up"),!0))}).catch(e=>{var n,a;if(ad(e)){"object"==typeof(n=e.responseBody)&&null!==n&&!1===n.authenticated?n4.setState({loaded:!0,session:e.responseBody},!0):at(),t(n4.getState());return}(a=e)instanceof n2&&502===a.response.status&&!n4.getState().loaded&&void 0!==o&&Date.now()-o<18e4?r(af(e,!0)):(P(`Failed to fetch new session information: ${e}`),r(af(e)))})})}function ad(e){return e instanceof n2&&(401===e.response.status||403===e.response.status)}function af(e,t=!1){return n4.getState().loaded||n4.setState({loaded:!1,session:null,error:e instanceof Error?e:Error(String(e)),initializing:t},!0),n4.getState()}function am(){return"development"===window.spaEnv||"true"===localStorage.getItem("openmrs:devtools")}n4.subscribe(e=>{e.loaded&&e.session&&n7(e.session)});let ap={"webservices.rest":"2.24.0",fhir2:"1.0.0-SNAPSHOT"};function ah(){ej("@openmrs/esm-api",nY),ae()}let ag="import-map-override:",ay="import-map-overrides-disabled",av="import-map-overrides:change",ab=!1,aw=null,aE=null;async function ax(){return aE??(aE=aD().then(({map:e,complete:t})=>(t||(aE=null),e))),aE}async function aD(){let e=document.querySelectorAll('script[type="systemjs-importmap"]'),t=[],r=!0;for(let n=0;n<e.length;n++){let a=e[n];try{if(a.src){let e=await fetch(a.src);if(!e.ok)throw Error(`Request for ${a.src} returned ${e.status} ${e.statusText}`);t.push(await e.json())}else a.textContent&&t.push(JSON.parse(a.textContent))}catch(e){r=!1,console.warn(`[import-maps] Failed to parse import map from script tag at index ${n}`,e)}}return{map:aS(t),complete:r}}function aS(e){let t={imports:{}};for(let r of e)r?.imports&&Object.assign(t.imports,r.imports);return t}function a_(){let e={};try{let t=aO();for(let r=0;r<localStorage.length;r++){let n=localStorage.key(r);if(n?.startsWith(ag)){let r=n.slice(ag.length);if(!t.includes(r)){let t=localStorage.getItem(n);t&&(e[r]=t)}}}}catch(e){console.warn("[import-maps] Failed to read import-map overrides from localStorage",e)}return{imports:e}}async function aC(){let e=await ax();return ab?aS([e,aw??a_()]):e}async function ak(){return ax()}async function aP(){return ab?aS([await ax(),a_()]):ax()}function aR(e){if(!ab)return{imports:{}};if(e){let e={};for(let t=0;t<localStorage.length;t++){let r=localStorage.key(t);if(r?.startsWith(ag)){let t=localStorage.getItem(r);t&&(e[r.slice(ag.length)]=t)}}return{imports:e}}return a_()}function aO(){if(!ab)return[];try{let e=localStorage.getItem(ay);if(e){let t=JSON.parse(e);if(Array.isArray(t))return t}}catch{}return[]}function aT(e){return!!ab&&aO().includes(e)}function aN(e,t){if(!ab)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{localStorage.setItem(ag+e,t),window.dispatchEvent(new CustomEvent(av))}catch(e){console.warn("[import-maps] Failed to write import-map override to localStorage",e)}}function a$(e){if(!ab)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{localStorage.removeItem(ag+e);let t=aO().filter(t=>t!==e);t.length>0?localStorage.setItem(ay,JSON.stringify(t)):localStorage.removeItem(ay),window.dispatchEvent(new CustomEvent(av))}catch(e){console.warn("[import-maps] Failed to update import-map overrides in localStorage",e)}}function aI(){if(!ab)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{let e=[];for(let t=0;t<localStorage.length;t++){let r=localStorage.key(t);r?.startsWith(ag)&&e.push(r)}e.forEach(e=>localStorage.removeItem(e)),localStorage.removeItem(ay),window.dispatchEvent(new CustomEvent(av))}catch(e){console.warn("[import-maps] Failed to clear import-map overrides from localStorage",e)}}function aM(e){if(!ab)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{let t=aO().filter(t=>t!==e);t.length>0?localStorage.setItem(ay,JSON.stringify(t)):localStorage.removeItem(ay),window.dispatchEvent(new CustomEvent(av))}catch(e){console.warn("[import-maps] Failed to update import-map overrides in localStorage",e)}}let aA=!1;function aj(){!aA&&(aA=!0,(ab="development"===window.spaEnv)&&(aw=a_()))}function aL(e){return e.replace(/[\/\-@]/g,"_")}async function aF(e,t="./start",n){var a;let o,i=!n?.maxLoadingTime||n.maxLoadingTime<=0?6e5:n.maxLoadingTime;await Promise.race([aB(e,n?.importMap),new Promise((t,r)=>{o=setTimeout(()=>{var t;r(Error(`Could not resolve requested script, ${e}, within ${(t=i)<1e3?`${t} milliseconds`:t<6e4?`${Math.floor(t/1e3)} seconds`:t<36e5?`${Math.floor(t/6e4)} minutes`:t<864e5?`${Math.floor(t/36e5)} hours`:`${Math.floor(t/864e5)} days`}.`))},i)})]),o&&clearTimeout(o);let s=aL(e),l=window[s];if(!("object"==typeof(a=l)&&null!==a&&"init"in a&&"function"==typeof a.init&&"get"in a&&"function"==typeof a.get)){let e=`The global variable ${s} does not refer to a federated module`;throw console.error(e),Error(e)}l.init(r.S.default);let u=(await l.get(t))();if("object"!=typeof u||null===u){let t=`Container for ${e} did not return an ESM module as expected`;throw console.error(t),Error(t)}return u}async function aB(e,t){if("string"!=typeof e||0===e.trim().length){let e="Attempted to call importDynamic() without supplying a package to load";throw console.error(e),Error(e)}let r=aL(e);if(!window[r]){let r=t??await aV();if(!r.imports.hasOwnProperty(e)){let t=`Could not find the package ${e} defined in the current importmap`;throw console.error(t),Error(t)}let n=r.imports[e];n.startsWith("./")&&(n=window.spaBase+n.substring(1));let a=e in aR().imports;try{return await function(e){var t;let r=(t=window)[aU]??(t[aU]=new Map),n=r.get(e);if(n)return n;if(document.head.querySelector(`script[src="${e}"]`))return console.warn(`Script at ${e} already loaded. Not loading it again.`),Promise.resolve();let a=document.createElement("script");a.src=e,a.type="text/javascript",a.async=!0;let o=new Promise((t,n)=>{let o=setTimeout(()=>{console.error(`The script at ${e} did not load within 5 seconds. This may indicate an issue with the imports in the script's entry-point file or with the script's bundler configuration.`)},5e3);function i(){clearTimeout(o),a.removeEventListener("load",s),a.removeEventListener("error",l)}function s(){i(),t()}function l(t){i(),r.delete(e),a.remove();let o=`Failed to load script from ${e}`;console.error(o,t),n(t.message??o)}a.addEventListener("load",s),a.addEventListener("error",l),document.head.appendChild(a)});return r.set(e,o),o}(n)}catch(e){return a&&x({kind:"error",title:nL("scriptLoadingFailed","Error: Script failed to load"),description:nL("scriptLoadingError","Failed to load overridden script from {{- url}}. Please check that the bundled script is available at the expected URL. Click the button below to reset all import map overrides.",{url:n}),actionButtonLabel:nL("resetOverrides","Reset overrides"),onActionButtonClick(){aI(),window.location.reload()}}),Promise.reject(e)}}return Promise.resolve()}async function aV(){return aC()}let aU=Symbol.for("__openmrs_script_loading");function aW(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,"modals")&&(!e.modals||!Array.isArray(e.modals))||Object.hasOwn(e,"workspaces2")&&(!e.workspaces2||!Array.isArray(e.workspaces2))||Object.hasOwn(e,"workspaceWindows2")&&(!e.workspaceWindows2||!Array.isArray(e.workspaceWindows2))||Object.hasOwn(e,"workspaceGroups2")&&(!e.workspaceGroups2||!Array.isArray(e.workspaceGroups2)))}function aH(e){return!!e&&"object"==typeof e&&"routes"in e&&!!e.routes&&"object"==typeof e.routes&&Object.entries(e.routes).every(([e,t])=>"string"==typeof e&&aW(t))}let az="openmrs-routes:",aK="openmrs-routes:change",aG=!1,aZ=null,aY=null;async function aq(){return aY??(aY=aJ().then(({map:e,complete:t})=>(t||(aY=null),e))),aY}async function aJ(){let e=document.querySelectorAll("script[type='openmrs-routes']"),t=[],r=!0;for(let n=0;n<e.length;n++){let a=e[n];try{let e;if(a.src){let t=await fetch(a.src);if(!t.ok)throw Error(`Request for ${a.src} returned ${t.status} ${t.statusText}`);e=await t.json()}else a.textContent&&(e=JSON.parse(a.textContent));e&&aH(e)&&t.push(e)}catch(e){r=!1,console.warn(`[route-maps] Failed to parse routes from script tag at index ${n}`,e)}}return{map:aX(t),complete:r}}function aX(e){let t={routes:{}};for(let r of e)r&&"object"==typeof r&&!Array.isArray(r)&&(Object.assign(t.routes,r.routes),void 0===t.version&&void 0!==r.version&&(t.version=r.version));return t}async function aQ(){let e={version:void 0,routes:{}};try{let t=[];for(let e=0;e<localStorage.length;e++){let r=localStorage.key(e);if(r?.startsWith(az)){let e=localStorage.getItem(r);e&&t.push({moduleName:r.slice(az.length),raw:e})}}for(let r of(await Promise.allSettled(t.map(async({moduleName:e,raw:t})=>{let r=JSON.parse(t);if(aW(r))return{moduleName:e,routes:r};if("string"==typeof r&&r.startsWith("http")){let t=await fetch(r),n=await t.json();if(aW(n))return{moduleName:e,routes:n};throw Error(`${r} did not resolve to a valid OpenmrsAppRoutes object`)}throw Error(`Override for ${e} is neither a valid routes object nor a URL`)}))))"fulfilled"===r.status?e.routes[r.value.moduleName]=r.value.routes:console.warn("[route-maps] Failed to load route override",r.reason)}catch(e){console.warn("[route-maps] Failed to read route overrides from localStorage",e)}return e}async function a0(){let e=await aq();return aG?aX([e,aZ??await aQ()]):e}async function a1(){return aq()}async function a2(){return aG?aX([await aq(),await aQ()]):aq()}function a4(){if(!aG)return{};let e={};try{for(let t=0;t<localStorage.length;t++){let r=localStorage.key(t);if(r?.startsWith(az)){let t=localStorage.getItem(r);t&&(e[r.slice(az.length)]=t)}}}catch(e){console.warn("[route-maps] Failed to read route overrides from localStorage",e)}return e}function a3(e,t){if(!aG)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{if("string"==typeof t)if(t.startsWith("http"))localStorage.setItem(az+e,JSON.stringify(t));else{let r=JSON.parse(t);if(!aW(r))return void console.error(`The supplied routes for ${e} is not a valid OpenmrsAppRoutes object`,t);localStorage.setItem(az+e,JSON.stringify(r))}else if(t instanceof URL)localStorage.setItem(az+e,JSON.stringify(t.toString()));else{if(!aW(t))return void console.error(`Override for ${e} is not in a valid format. Expected either a Javascript Object, a JSON string of a Javascript object, or a URL`,t);localStorage.setItem(az+e,JSON.stringify(t))}window.dispatchEvent(new CustomEvent(aK))}catch(e){console.warn("[route-maps] Failed to write route override to localStorage",e)}}function a6(e){if(!aG)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{localStorage.removeItem(az+e),window.dispatchEvent(new CustomEvent(aK))}catch(e){console.warn("[route-maps] Failed to remove route override from localStorage",e)}}function a5(){if(!aG)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{let e=[];for(let t=0;t<localStorage.length;t++){let r=localStorage.key(t);r?.startsWith(az)&&e.push(r)}e.forEach(e=>localStorage.removeItem(e)),window.dispatchEvent(new CustomEvent(aK))}catch(e){console.warn("[route-maps] Failed to clear route overrides from localStorage",e)}}let a9=null;function a8(){return a9||(a9=(aG="development"===window.spaEnv)?aQ().then(e=>{aZ=e}):Promise.resolve())}let a7=`${nJ}/attachment`;function oe(e,t){return n1(`${a7}/${e}`,{signal:t.signal})}function ot(e,t,r,n){return n1(or(e,t,n),{signal:r.signal})}function or(e,t,r){return r?`${a7}?patient=${e}&encounter=${r}`:`${a7}?patient=${e}&includeEncounterless=${t}`}async function on(e,t,r){let n=new FormData;return n.append("fileCaption",t.fileDescription),n.append("patient",e),r&&n.append("encounter",r),t.file?n.append("file",t.file,t.fileName):(n.append("file",new File([""],t.fileName),t.fileName),n.append("base64Content",t.base64Content)),n1(`${a7}`,{method:"POST",body:n})}function oa(e,t){return n1(`${a7}/${e}`,{method:"DELETE",signal:t.signal})}async function oo(e,t){return e?(await n1(`${nX}/Patient/${e}`,t)).data:null}function oi(e,t){let r=new CustomEvent(`openmrs:${e}`,{detail:t??void 0,cancelable:!0,bubbles:!0});return window.dispatchEvent(r)}function os(e,t){let r=e=>{t("detail"in e&&null!==e.detail?e.detail:void 0)};return window.addEventListener(`openmrs:${e}`,r),()=>{window.removeEventListener(`openmrs:${e}`,r)}}function ol(e){return{uuid:e.uuid,display:e.display}}function ou(e=null,t=null){let r=new URLSearchParams;e&&r.set("tag",e),t&&r.set("q",t);let n=r.toString();return n1(`${nJ}/location${n?"?"+n:""}`).then(e=>e.data.results.map(ol))}function oc(e){return{uuid:e.uuid,display:e.display,name:e.name}}let od=`${nJ}/visittype`;function of(e=od){return n1(e).then(e=>e.data.results.map(oc))}var om=((Z={}).NEWVISIT="startVisit",Z.EDITVISIT="editVisit",Z.LOADING="loadingVisit",Z),op=((Y={}).NOTSTARTED="notStarted",Y.ONGOING="ongoing",Y);let oh="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))",og=function(){try{return JSON.parse(sessionStorage.getItem("openmrs:visitStoreState")||"null")}catch(e){return null}}()||{patientUuid:null,manuallySetVisitUuid:null};function oy(){return H("visit",og)}function ov(e,t){oy().setState({patientUuid:e,manuallySetVisitUuid:t})}function ob(e,t){return n1(`${nJ}/visit`,{signal:t.signal,method:"POST",headers:{"Content-type":"application/json"},body:e})}function ow(e,t,r){return n1(`${nJ}/visit/${e}`,{signal:r.signal,method:"POST",headers:{"Content-type":"application/json"},body:t})}function oE(e,t,r){return n1(`${nJ}/visit?patient=${e}&v=${r??oh}`,{signal:t.signal,method:"GET",headers:{"Content-type":"application/json"}})}oy().subscribe(e=>{var t;t=e,sessionStorage.setItem("openmrs:visitStoreState",JSON.stringify(t))});class ox{static get version(){return"1.4.0"}static toString(){return"JavaScript Expression Parser (JSEP) v"+ox.version}static addUnaryOp(e){return ox.max_unop_len=Math.max(e.length,ox.max_unop_len),ox.unary_ops[e]=1,ox}static addBinaryOp(e,t,r){return ox.max_binop_len=Math.max(e.length,ox.max_binop_len),ox.binary_ops[e]=t,r?ox.right_associative.add(e):ox.right_associative.delete(e),ox}static addIdentifierChar(e){return ox.additional_identifier_chars.add(e),ox}static addLiteral(e,t){return ox.literals[e]=t,ox}static removeUnaryOp(e){return delete ox.unary_ops[e],e.length===ox.max_unop_len&&(ox.max_unop_len=ox.getMaxKeyLen(ox.unary_ops)),ox}static removeAllUnaryOps(){return ox.unary_ops={},ox.max_unop_len=0,ox}static removeIdentifierChar(e){return ox.additional_identifier_chars.delete(e),ox}static removeBinaryOp(e){return delete ox.binary_ops[e],e.length===ox.max_binop_len&&(ox.max_binop_len=ox.getMaxKeyLen(ox.binary_ops)),ox.right_associative.delete(e),ox}static removeAllBinaryOps(){return ox.binary_ops={},ox.max_binop_len=0,ox}static removeLiteral(e){return delete ox.literals[e],ox}static removeAllLiterals(){return ox.literals={},ox}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 ox(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 ox.binary_ops[e]||0}static isIdentifierStart(e){return e>=65&&e<=90||e>=97&&e<=122||e>=128&&!ox.binary_ops[String.fromCharCode(e)]||ox.additional_identifier_chars.has(String.fromCharCode(e))}static isIdentifierPart(e){return ox.isIdentifierStart(e)||ox.isDecimalDigit(e)}throwError(e){let t=Error(e+" at character "+this.index);throw t.index=this.index,t.description=e,t}runHook(e,t){if(ox.hooks[e]){let r={context:this,node:t};return ox.hooks.run(e,r),r.node}return t}searchHook(e){if(ox.hooks[e]){let t={context:this};return ox.hooks[e].find(function(e){return e.call(t.context,t),t.node}),t.node}}gobbleSpaces(){let e=this.code;for(;e===ox.SPACE_CODE||e===ox.TAB_CODE||e===ox.LF_CODE||e===ox.CR_CODE;)e=this.expr.charCodeAt(++this.index);this.runHook("gobble-spaces")}parse(){this.runHook("before-all");let e=this.gobbleExpressions(),t=1===e.length?e[0]:{type:ox.COMPOUND,body:e};return this.runHook("after-all",t)}gobbleExpressions(e){let t=[],r,n;for(;this.index<this.expr.length;)if((r=this.code)===ox.SEMCOL_CODE||r===ox.COMMA_CODE)this.index++;else if(n=this.gobbleExpression())t.push(n);else if(this.index<this.expr.length){if(r===e)break;this.throwError('Unexpected "'+this.char+'"')}return t}gobbleExpression(){let e=this.searchHook("gobble-expression")||this.gobbleBinaryExpression();return this.gobbleSpaces(),this.runHook("after-expression",e)}gobbleBinaryOp(){this.gobbleSpaces();let e=this.expr.substr(this.index,ox.max_binop_len),t=e.length;for(;t>0;){if(ox.binary_ops.hasOwnProperty(e)&&(!ox.isIdentifierStart(this.code)||this.index+e.length<this.expr.length&&!ox.isIdentifierPart(this.expr.charCodeAt(this.index+e.length))))return this.index+=t,e;e=e.substr(0,--t)}return!1}gobbleBinaryExpression(){let e,t,r,n,a,o,i,s,l;if(!(o=this.gobbleToken())||!(t=this.gobbleBinaryOp()))return o;for(a={value:t,prec:ox.binaryPrecedence(t),right_a:ox.right_associative.has(t)},(i=this.gobbleToken())||this.throwError("Expected expression after "+t),n=[o,a,i];t=this.gobbleBinaryOp();){if(0===(r=ox.binaryPrecedence(t))){this.index-=t.length;break}a={value:t,prec:r,right_a:ox.right_associative.has(t)},l=t;let s=e=>a.right_a&&e.right_a?r>e.prec:r<=e.prec;for(;n.length>2&&s(n[n.length-2]);)i=n.pop(),t=n.pop().value,o=n.pop(),e={type:ox.BINARY_EXP,operator:t,left:o,right:i},n.push(e);(e=this.gobbleToken())||this.throwError("Expected expression after "+l),n.push(a,e)}for(s=n.length-1,e=n[s];s>1;)e={type:ox.BINARY_EXP,operator:n[s-1].value,left:n[s-2],right:e},s-=2;return e}gobbleToken(){let e,t,r,n;if(this.gobbleSpaces(),n=this.searchHook("gobble-token"))return this.runHook("after-token",n);if(e=this.code,ox.isDecimalDigit(e)||e===ox.PERIOD_CODE)return this.gobbleNumericLiteral();if(e===ox.SQUOTE_CODE||e===ox.DQUOTE_CODE)n=this.gobbleStringLiteral();else if(e===ox.OBRACK_CODE)n=this.gobbleArray();else{for(r=(t=this.expr.substr(this.index,ox.max_unop_len)).length;r>0;){if(ox.unary_ops.hasOwnProperty(t)&&(!ox.isIdentifierStart(this.code)||this.index+t.length<this.expr.length&&!ox.isIdentifierPart(this.expr.charCodeAt(this.index+t.length)))){this.index+=r;let e=this.gobbleToken();return e||this.throwError("missing unaryOp argument"),this.runHook("after-token",{type:ox.UNARY_EXP,operator:t,argument:e,prefix:!0})}t=t.substr(0,--r)}ox.isIdentifierStart(e)?(n=this.gobbleIdentifier(),ox.literals.hasOwnProperty(n.name)?n={type:ox.LITERAL,value:ox.literals[n.name],raw:n.name}:n.name===ox.this_str&&(n={type:ox.THIS_EXP})):e===ox.OPAREN_CODE&&(n=this.gobbleGroup())}return n?(n=this.gobbleTokenProperty(n),this.runHook("after-token",n)):this.runHook("after-token",!1)}gobbleTokenProperty(e){this.gobbleSpaces();let t=this.code;for(;t===ox.PERIOD_CODE||t===ox.OBRACK_CODE||t===ox.OPAREN_CODE||t===ox.QUMARK_CODE;){let r;if(t===ox.QUMARK_CODE){if(this.expr.charCodeAt(this.index+1)!==ox.PERIOD_CODE)break;r=!0,this.index+=2,this.gobbleSpaces(),t=this.code}this.index++,t===ox.OBRACK_CODE?((e={type:ox.MEMBER_EXP,computed:!0,object:e,property:this.gobbleExpression()}).property||this.throwError('Unexpected "'+this.char+'"'),this.gobbleSpaces(),(t=this.code)!==ox.CBRACK_CODE&&this.throwError("Unclosed ["),this.index++):t===ox.OPAREN_CODE?e={type:ox.CALL_EXP,arguments:this.gobbleArguments(ox.CPAREN_CODE),callee:e}:(t===ox.PERIOD_CODE||r)&&(r&&this.index--,this.gobbleSpaces(),e={type:ox.MEMBER_EXP,computed:!1,object:e,property:this.gobbleIdentifier()}),r&&(e.optional=!0),this.gobbleSpaces(),t=this.code}return e}gobbleNumericLiteral(){let e="",t,r;for(;ox.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);if(this.code===ox.PERIOD_CODE)for(e+=this.expr.charAt(this.index++);ox.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);if("e"===(t=this.char)||"E"===t){for(e+=this.expr.charAt(this.index++),("+"===(t=this.char)||"-"===t)&&(e+=this.expr.charAt(this.index++));ox.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);ox.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+e+this.char+")")}return r=this.code,ox.isIdentifierStart(r)?this.throwError("Variable names cannot start with a number ("+e+this.char+")"):(r===ox.PERIOD_CODE||1===e.length&&e.charCodeAt(0)===ox.PERIOD_CODE)&&this.throwError("Unexpected period"),{type:ox.LITERAL,value:parseFloat(e),raw:e}}gobbleStringLiteral(){let e="",t=this.index,r=this.expr.charAt(this.index++),n=!1;for(;this.index<this.expr.length;){let t=this.expr.charAt(this.index++);if(t===r){n=!0;break}if("\\"===t)switch(t=this.expr.charAt(this.index++)){case"n":e+="\n";break;case"r":e+="\r";break;case"t":e+=" ";break;case"b":e+="\b";break;case"f":e+="\f";break;case"v":e+="\v";break;default:e+=t}else e+=t}return n||this.throwError('Unclosed quote after "'+e+'"'),{type:ox.LITERAL,value:e,raw:this.expr.substring(t,this.index)}}gobbleIdentifier(){let e=this.code,t=this.index;for(ox.isIdentifierStart(e)?this.index++:this.throwError("Unexpected "+this.char);this.index<this.expr.length;)if(e=this.code,ox.isIdentifierPart(e))this.index++;else break;return{type:ox.IDENTIFIER,name:this.expr.slice(t,this.index)}}gobbleArguments(e){let t=[],r=!1,n=0;for(;this.index<this.expr.length;){this.gobbleSpaces();let a=this.code;if(a===e){r=!0,this.index++,e===ox.CPAREN_CODE&&n&&n>=t.length&&this.throwError("Unexpected token "+String.fromCharCode(e));break}if(a===ox.COMMA_CODE){if(this.index++,++n!==t.length){if(e===ox.CPAREN_CODE)this.throwError("Unexpected token ,");else if(e===ox.CBRACK_CODE)for(let e=t.length;e<n;e++)t.push(null)}}else if(t.length!==n&&0!==n)this.throwError("Expected comma");else{let e=this.gobbleExpression();e&&e.type!==ox.COMPOUND||this.throwError("Expected comma"),t.push(e)}}return r||this.throwError("Expected "+String.fromCharCode(e)),t}gobbleGroup(){this.index++;let e=this.gobbleExpressions(ox.CPAREN_CODE);if(this.code===ox.CPAREN_CODE)return(this.index++,1===e.length)?e[0]:!!e.length&&{type:ox.SEQUENCE_EXP,expressions:e};this.throwError("Unclosed (")}gobbleArray(){return this.index++,{type:ox.ARRAY_EXP,elements:this.gobbleArguments(ox.CBRACK_CODE)}}}Object.assign(ox,{hooks:new class{add(e,t,r){if("string"!=typeof arguments[0])for(let e in arguments[0])this.add(e,arguments[0][e],arguments[1]);else(Array.isArray(e)?e:[e]).forEach(function(e){this[e]=this[e]||[],t&&this[e][r?"unshift":"push"](t)},this)}run(e,t){this[e]=this[e]||[],this[e].forEach(function(e){e.call(t&&t.context?t.context:t,t)})}},plugins:new class{constructor(e){this.jsep=e,this.registered={}}register(...e){e.forEach(e=>{if("object"!=typeof e||!e.name||!e.init)throw Error("Invalid JSEP plugin format");this.registered[e.name]||(e.init(this.jsep),this.registered[e.name]=e)})}}(ox),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"}),ox.max_unop_len=ox.getMaxKeyLen(ox.unary_ops),ox.max_binop_len=ox.getMaxKeyLen(ox.binary_ops);let oD=e=>new ox(e).parse(),oS=Object.getOwnPropertyNames(class{});Object.getOwnPropertyNames(ox).filter(e=>!oS.includes(e)&&void 0===oD[e]).forEach(e=>{oD[e]=ox[e]}),oD.Jsep=ox,oD.plugins.register({name:"ternary",init(e){e.hooks.add("after-expression",function(t){if(t.node&&this.code===e.QUMARK_CODE){this.index++;let r=t.node,n=this.gobbleExpression();if(n||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===e.COLON_CODE){this.index++;let a=this.gobbleExpression();if(a||this.throwError("Expected expression"),t.node={type:"ConditionalExpression",test:r,consequent:n,alternate:a},r.operator&&e.binary_ops[r.operator]<=.9){let n=r;for(;n.right.operator&&e.binary_ops[n.right.operator]<=.9;)n=n.right;t.node.test=n.right,n.right=t.node,t.node=r}}else this.throwError("Expected :")}})}});let o_="ArrowFunctionExpression",oC={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)}},ok={...oC,Promise};function oP(e,t={}){return oI(e,t,oj)}async function oR(e,t={}){return oM(e,t,oj)}function oO(e,t={}){return oI(e,t,oL)}function oT(e,t={}){return oM(e,t,oL)}function oN(e,t={}){return oI(e,t,oF)}function o$(e,t={}){return oM(e,t,oF)}function oI(e,t={},r){if("string"!=typeof e&&("object"!=typeof e||!e||!("type"in e)))throw`Unknown expression type ${e}. Expressions must either be a string or pre-compiled string.`;if("string"==typeof e&&0===e.trim().length)throw{type:"Empty expression",message:"Expression cannot be an empty string"};null==t&&(t={});let n=oH(t,oC),a=oB("string"==typeof e?oD(e):e,n);if(r(a))return a;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 oM(e,t={},r){if("string"!=typeof e&&("object"!=typeof e||!e||!("type"in e)))return Promise.reject(`Unknown expression type ${e}. Expressions must either be a string or pre-compiled string.`);if("string"==typeof e&&0===e.trim().length)throw{type:"Empty expression",message:"Expression cannot be an empty string"};null==t&&(t={});let n=oH(t,ok);return Promise.resolve(oB("string"==typeof e?oD(e):e,n)).then(t=>{if(r(t))return t;throw{type:"Invalid result",message:"string"==typeof e?`The expression ${e} did not produce a valid result`:"The expression did not produce a valid result"}})}function oA(e){return oD(e)}function oj(e){return"string"==typeof e||"number"==typeof e||"boolean"==typeof e||null==e||e instanceof Date}function oL(e){return"boolean"==typeof e}function oF(e){return"number"==typeof e}function oB(e,t){switch(e.type){case"UnaryExpression":var r,n,a,o,i,s,l,u,c,d,f,m,p,h=e,g=t;let y=oB(h.argument,g);switch(h.operator){case"+":return+y;case"-":return-y;case"~":return~y;case"!":return!y;default:throw`Expression evaluator does not support operator '${h.operator}''`}case"BinaryExpression":var v=e,b=t;switch(v.operator){case"&&":return oB(v.left,b)&&oB(v.right,b);case"||":return oB(v.left,b)||oB(v.right,b);case"??":return oB(v.left,b)??oB(v.right,b)}let w=oB(v.left,b),E=oB(v.right,b);switch(v.operator){case"+":return w+E;case"-":return w-E;case"*":return w*E;case"/":return w/E;case"%":return w%E;case"**":return w**E;case"==":return w==E;case"===":return w===E;case"!=":return w!=E;case"!==":return w!==E;case">":return w>E;case">=":return w>=E;case"<":return w<E;case"<=":return w<=E;case"in":return w in E;default:throw`Expression evaluator does not support operator '${v.operator}' operator`}case"ConditionalExpression":return r=e,n=t,oB(r.test,n)?oB(r.consequent,n):oB(r.alternate,n);case"CallExpression":return oG(oU(e,t));case"ArrowFunctionExpression":let x;return a=e,o=t,x=a.params?.map(e=>{if("Identifier"===e.type)return e.name;throw`Cannot handle parameter of type ${e.type}`})??[],(function(...e){if(e.length<x.length)throw`Required argument(s) ${x.slice(e.length,-1).join(", ")} were not provided`;let t=Object.fromEntries(x.reduce((t,r,n)=>{let a=e[n];return function e(t){if("string"==typeof t||"number"==typeof t||"boolean"==typeof t||"function"==typeof t||null===t||t instanceof RegExp)return!0;if("object"==typeof t){for(let r of Object.keys(t))if(!e(t[r]))return!1;return!0}if(Array.isArray(t)){for(let r of t)if(!e(r))break}return!1}(a)&&t.push([r,a]),t},[]));return oB(a.body,o.addVariables(t))}).bind(null);case"MemberExpression":return oG(oW(e,t));case"ArrayExpression":return i=e,s=t,i.elements?.map(oZ(s));case"SequenceExpression":let D;return l=e,u=t,(D=l.expressions.map(oZ(u)))[D.length-1];case"NewExpression":var S=e,_=t;if(S.callee&&"Identifier"===S.callee.type){let e=S.arguments?.map(oZ(_));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 e.value;case"Identifier":return c=e,d=t,(oY(c.name),d.variables&&Object.hasOwn(d.variables,c.name))?d.variables[c.name]:Object.hasOwn(d.globals,c.name)?d.globals[c.name]:void 0;case"TemplateLiteral":let C,k;return f=e,m=t,C=f.expressions?.map(oZ(m))??[],(k=f.quasis?.map(oZ(m))??[]).filter(e=>!e.tail).map(e=>e.value).join("")+C.join("")+k.filter(e=>e.tail).map(e=>e.value).join("");case"TemplateElement":return{value:(p=e).cooked,tail:p.tail};default:throw`Expression evaluator does not support expression of type '${e.type}'`}}function oV(e,t){switch(e.type){case"Literal":return e.value;case"Identifier":return e.name;case"MemberExpression":return oV(e.property,t);default:throw`VisitExpressionName does not support expression of type '${e.type}'`}}function oU(e,t){let r=oK(e.callee,t);if(r===oz||e.optional&&null==r)return oz;let n=e.arguments?.map(oZ(t));if(r){if("function"!=typeof r)throw`${oX(e.callee)} is not a function`}else throw`No function named ${oX(e.callee)} is defined in this context`;return r(...n)}function oW(e,t){let r=oK(e.object,t);if(r===oz||e.optional&&null==r)return oz;if(null===r)throw TypeError(`TypeError: cannot read properties of null (reading '${oJ(e.property,t)}')`);if(void 0===r)switch(e.object.type){case"Identifier":{let r=oV(e.object,t);throw ReferenceError(`ReferenceError: ${r} is not defined`)}case"MemberExpression":throw TypeError(`TypeError: cannot read properties of undefined (reading '${oJ(e.property,t)}')`);default:throw`VisitMemberExpression does not support operator '${e.object.type}' type`}if("object"!=typeof r&&"function"!=typeof r&&"string"!=typeof r&&"number"!=typeof r)throw`VisitMemberExpression does not support member access on type ${typeof r}`;let n=e.computed?function(e){if(void 0===e)throw{type:"Illegal property access",message:"No property was supplied to the property access"};if("string"!=typeof e&&"number"!=typeof e)throw{type:"Illegal property access",message:`Cannot use a value of type ${null===e?"null":typeof e} as a property name`};return e}(oB(e.property,t)):function(e){if("Identifier"!==e.type)throw`VisitMemberExpression does not support a property of type '${e.type}'`;return e.name}(e.property);oY(n),function(e,t){if(oq.has(String(t)))return;let r=Object(e);for(;null!==r;){if(Object.hasOwn(r,t)){if(r===Object.prototype||r===Function.prototype)throw{type:"Illegal property access",message:`Cannot access the ${t} property of objects`};return}r=Object.getPrototypeOf(r)}}(r,n);let a=r[n];return"function"==typeof a?a.bind(r):a}function oH(e,t){let r={variables:{...e},globals:{...t},addVariables(e){return this.variables={...this.variables,...e},this}};return r.addVariables.bind(r),r}oD.plugins.register({name:"arrow",init(e){e.addBinaryOp("=>",.1,!0),e.hooks.add("gobble-expression",function(t){if(this.gobbleSpaces(),this.code===e.OPAREN_CODE){let r=this.index;if(this.index++,this.gobbleSpaces(),this.code===e.CPAREN_CODE){this.index++;let e=this.gobbleBinaryOp();if("=>"===e){let r=this.gobbleBinaryExpression();r||this.throwError("Expected expression after "+e),t.node={type:o_,params:null,body:r};return}}this.index=r}}),e.hooks.add("after-expression",function(t){!function t(r){r&&(Object.values(r).forEach(e=>{e&&"object"==typeof e&&t(e)}),"=>"===r.operator&&(r.type=o_,r.params=r.left?[r.left]:null,r.body=r.right,r.params&&r.params[0].type===e.SEQUENCE_EXP&&(r.params=r.params[0].expressions),delete r.left,delete r.right,delete r.operator))}(t.node)})}}),oD.plugins.register({name:"new",init(e){e.addUnaryOp("new"),e.hooks.add("after-token",function(t){let r=t.node;if(r&&"new"===r.operator){r.argument&&[e.CALL_EXP,e.MEMBER_EXP].includes(r.argument.type)||this.throwError("Expected new function()"),t.node=r.argument;let n=t.node;for(;n.type===e.MEMBER_EXP||n.type===e.CALL_EXP&&n.callee.type===e.MEMBER_EXP;)n=n.type===e.MEMBER_EXP?n.object:n.callee.object;n.type="NewExpression"}})}}),oD.plugins.register({name:"numbers",init(e){function t(e){return"x"===e||"X"===e?(this.index+=2,[[48,57],[65,70],[97,102]]):"b"===e||"B"===e?(this.index+=2,[[48,49]]):"o"===e||"O"===e||e>="0"&&e<="7"?(this.index+=e<="7"?1:2,[[48,55]]):null}function r(t){let r=this.index,n="",a=()=>{for(;e.isDecimalDigit(this.code)||95===this.code;)95===this.code?this.index++:n+=this.expr.charAt(this.index++)};a(),this.code===e.PERIOD_CODE&&(n+=this.expr.charAt(this.index++),a());let o=this.char;("e"===o||"E"===o)&&(n+=this.expr.charAt(this.index++),("+"===(o=this.char)||"-"===o)&&(n+=this.expr.charAt(this.index++)),a(),e.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+n+this.char+")"));let i=this.code;if(e.isIdentifierStart(i))this.throwError("Variable names cannot start with a number ("+n+this.char+")");else if(i===e.PERIOD_CODE){n.length>1&&this.throwError(`Unexpected period ${JSON.stringify({chCode:i,number:n},null,2)}`),this.index=r;return}t.node={type:e.LITERAL,value:parseFloat(n),raw:this.expr.substring(r,this.index)}}e.hooks.add("gobble-token",function(n){if(48===this.code){var a,o,i;let s=this.index,l=this.expr.charAt(this.index+1),u=t.call(this,l);if(!u)return;let c="";for(;a=this.code,o=u,95===a||o.some(([e,t])=>a>=e&&a<=t);)95===this.code?this.index++:c+=this.expr.charAt(this.index++);if(e.isIdentifierPart(this.code)){if(e.isDecimalDigit(this.code)&&e.isDecimalDigit(l.charCodeAt(0))){this.index=s+1,r.call(this,n);return}this.throwError("unexpected char within number")}n.node={type:e.LITERAL,value:parseInt(c,"x"===(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)&&r.call(this,n)})}}),oD.plugins.register({name:"regex",init(e){e.hooks.add("gobble-token",function(t){if(47===this.code){let r=++this.index,n=!1;for(;this.index<this.expr.length;){if(47===this.code&&!n){let n,a=this.expr.slice(r,this.index),o="";for(;++this.index<this.expr.length;){let e=this.code;if(e>=97&&e<=122||e>=65&&e<=90||e>=48&&e<=57)o+=this.char;else break}try{n=new RegExp(a,o)}catch(e){this.throwError(e.message)}return t.node={type:e.LITERAL,value:n,raw:this.expr.slice(r-1,this.index)},t.node=this.gobbleTokenProperty(t.node),t.node}this.code===e.OBRACK_CODE?n=!0:n&&this.code===e.CBRACK_CODE&&(n=!1),this.index+=92===this.code?2:1}this.throwError("Unclosed Regex")}})}}),oD.plugins.register({name:"ternary",init(e){e.hooks.add("after-expression",function(t){if(t.node&&this.code===e.QUMARK_CODE){this.index++;let r=t.node,n=this.gobbleExpression();if(n||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===e.COLON_CODE){this.index++;let a=this.gobbleExpression();if(a||this.throwError("Expected expression"),t.node={type:"ConditionalExpression",test:r,consequent:n,alternate:a},r.operator&&e.binary_ops[r.operator]<=.9){let n=r;for(;n.right.operator&&e.binary_ops[n.right.operator]<=.9;)n=n.right;t.node.test=n.right,n.right=t.node,t.node=r}}else this.throwError("Expected :")}})}}),oD.plugins.register({name:"jsepTemplateLiteral",init(e){function t(e,r=!0){if(96===this.code){let t={type:"TemplateLiteral",quasis:[],expressions:[]},n="",a="",o=!1,i=this.expr.length,s=()=>t.quasis.push({type:"TemplateElement",value:{raw:a,cooked:n},tail:o});for(;this.index<i;){let i=this.expr.charAt(++this.index);if("`"===i)return this.index+=1,o=!0,s(),e.node=t,r&&(e.node=this.gobbleTokenProperty(e.node)),e.node;if("$"===i&&"{"===this.expr.charAt(this.index+1))this.index+=2,s(),a="",n="",t.expressions.push(...this.gobbleExpressions(125)),125!==this.code&&this.throwError("unclosed ${");else if("\\"===i)switch(a+=i,i=this.expr.charAt(++this.index),a+=i,i){case"n":n+="\n";break;case"r":n+="\r";break;case"t":n+=" ";break;case"b":n+="\b";break;case"f":n+="\f";break;case"v":n+="\v";break;default:n+=i}else n+=i,a+=i}this.throwError("Unclosed `")}}e.hooks.add("gobble-token",t),e.hooks.add("after-token",function(r){if((r.node.type===e.IDENTIFIER||r.node.type===e.MEMBER_EXP)&&96===this.code)return r.node={type:"TaggedTemplateExpression",tag:r.node,quasi:t.bind(this)(r,!1)},r.node=this.gobbleTokenProperty(r.node),r.node})}}),oD.addBinaryOp("in",7),oD.addBinaryOp("??",1);let oz=Symbol("optional chain short-circuited");function oK(e,t){switch(e.type){case"MemberExpression":return oW(e,t);case"CallExpression":return oU(e,t);default:return oB(e,t)}}function oG(e){return e===oz?void 0:e}function oZ(e){return function(t){return null===t?null:oB(t,e)}}function oY(e){if("__proto__"===e||"prototype"===e||"constructor"===e)throw{type:"Illegal property access",message:`Cannot access the ${e} property of objects`}}let oq=new Set(["toString","valueOf","hasOwnProperty"]);function oJ(e,t){try{return oV(e,t)}catch{return"<computed>"}}function oX(e){return e?"MemberExpression"===e.type?e.property?.name:e.name:null}function oQ(e){if("string"!=typeof e&&("object"!=typeof e||!e||!("type"in e)))throw`Unknown expression type ${e}. Expressions must either be a string or pre-compiled string.`;let t={globals:{...ok},isLocalExpression:!1,variables:new Set};return o0("string"==typeof e?oD(e):e,t),[...t.variables]}function o0(e,t){switch(e.type){case"UnaryExpression":return n=e,a=t,o0(n.argument,a);case"BinaryExpression":return o=e,i=t,[o0(o.left,i),o0(o.right,i)].filter(Boolean);case"ConditionalExpression":return s=e,l=t,[o0(s.consequent,l),o0(s.test,l),o0(s.alternate,l)].filter(Boolean);case"CallExpression":let r;return u=e,c=t,r=o0(u.callee,c),u.arguments?.map(o1(c)),r;case"ArrowFunctionExpression":var n,a,o,i,s,l,u,c,d,f,m,p,h,g,y,v,b=e,w=t;let E={...w};E.isLocalExpression=!0;let x=b.params?.map(o1(E))??[],D=o0(b.body,E)??[];if(D&&Array.isArray(D))for(let e of D)x.includes(e)||w.variables.add(e);return;case"MemberExpression":var S=e,_=t;if(o0(S.object,_),S.computed)return void o0(S.property,_);let C={..._};C.isLocalExpression=!0,o0(S.property,C);return;case"ArrayExpression":return d=e,f=t,void d.elements?.map(o1(f));case"SequenceExpression":return m=e,p=t,void m.expressions?.map(o1(p));case"NewExpression":return h=e,g=t,void h.arguments?.map(o1(g));case"Literal":case"TemplateElement":return;case"Identifier":var k=e,P=t;if(!(k.name in P.globals))if(P.isLocalExpression)return k.name;else P.variables.add(k.name);return;case"TemplateLiteral":return y=e,v=t,void(y.expressions?.map(o1(v)),y.quasis?.map(o1(v)));default:throw`Expression evaluator does not support expression of type '${e.type}'`}}function o1(e){return function(t){return null===t?null:o0(t,e)}}let o2=H("feature-flags",{flags:function(){let e={};for(let t of Object.keys(localStorage))if(t.startsWith("openmrs:feature-flag:")){let r=t.replace("openmrs:feature-flag:",""),n=JSON.parse(localStorage.getItem(`openmrs:feature-flag-meta:${r}`)||"{}");e[r]={enabled:"true"===localStorage.getItem(t),...n}}return e}()});function o4(e,t,r){o2.setState(n=>({flags:{...n.flags,[e]:{enabled:n.flags[e]?.enabled??!1,label:t,description:r}}}))}function o3(){let e=o2.getState().flags;Object.keys(localStorage).filter(e=>e.startsWith("openmrs:feature-flag:")).forEach(t=>{let r=t.replace("openmrs:feature-flag:","");e[r]||(localStorage.removeItem(t),localStorage.removeItem(`openmrs:feature-flag-meta:${r}`))})}function o6(e){return o2.getState().flags[e].enabled}function o5(e,t){o2.subscribe(r=>{t(r.flags[e].enabled)})}function o9(e,t){o2.setState(r=>({flags:{...r.flags,[e]:{...r.flags[e],enabled:t}}}))}o2.subscribe(e=>{for(let[t,r]of Object.entries(e.flags))localStorage.setItem(`openmrs:feature-flag:${t}`,r.enabled.toString()),localStorage.setItem(`openmrs:feature-flag-meta:${t}`,JSON.stringify({label:r.label,description:r.description}))});let o8=V("extensionsInternal",{slots:{},extensions:{}}),o7=V("extensionRenderings",{renderings:new Map}),ie=()=>H("extensionsInternal",{slots:{},extensions:{}}),it=()=>H("extensionRenderings",{renderings:new Map});function ir(e){let t=o8.getState(),r=e(t);r!==t&&o8.setState(r)}let ia=null,io=null;function ii(){let e=o7.getState();return ia&&e===io||(ia=new Map(e.renderings),io=e,function(e){for(let t of(iy.clear(),e.values()))ib(t,1);iv=!0}(ia)),ia}function is(e){io={renderings:e},o7.setState(io,!0)}function il(e){let t=ii();t.has(e.renderingId)||(t.set(e.renderingId,e),ib(e,1),is(t))}function iu(e){let t=ii(),r=t.get(e);r&&(t.delete(e),ib(r,-1),is(t))}let ic=()=>H("extensions",{slots:{}}),id=0,im=new Set;function ip(e){id++;try{return e()}finally{if(0==--id&&im.size>0){let e=Array.from(im);for(let t of(im.clear(),e))ih(t)}}}function ih(e){try{e()}catch(t){console.error(`The extension system's '${e.name}' recomputation failed`,t)}}function ig(e){id>0?im.add(e):ih(e)}let iy=new Map,iv=!1;function ib(e,t){let r=JSON.stringify([e.slotName,e.extensionId,e.slotModuleName,e.extensionModuleName]),n=iy.get(r);if(!n){if(t<0)return;iy.set(r,{count:1,record:{slotModuleName:e.slotModuleName,extensionModuleName:e.extensionModuleName,slotName:e.slotName,extensionId:e.extensionId}}),iv=!0;return}n.count+=t,n.count<1&&(iy.delete(r),iv=!0)}function iw(){var e,t;if(ii(),!iv)return;iv=!1;let r=Array.from(iy.values(),({record:e})=>e);r.sort(iE),e=eu.getState().mountedExtensions,t=r,e.length===t.length&&e.every((e,r)=>0===iE(e,t[r]))||eu.setState({mountedExtensions:r})}function iE(e,t){return ix(e.slotName,t.slotName)||ix(e.extensionId,t.extensionId)||ix(e.slotModuleName,t.slotModuleName)||ix(e.extensionModuleName,t.extensionModuleName)}function ix(e,t){return e===t?0:e<t?-1:1}iw(),o7.subscribe(()=>ig(iw));let iD=ie(),iS=ic(),i_=ed(),iC=ep(),ik=new Set,iP=!1;function iR(e){if(null===e)ik=null;else if(null!==ik)for(let t of e)ik.add(t);ig(iO)}function iO(){if(!iP){iP=!0;try{for(let e=1;;e++){let t=ik;if(null!==t&&0===t.size)return;ik=new Set;try{!function(e,t,r,n,a,o=null){let i=iS.getState().slots,s={},l=!1,u=Object.entries(n.flags).filter(([,{enabled:e}])=>e).map(([e])=>e);for(let[n,c]of Object.entries(e.slots)){let d=i[n];if(d&&o&&!o.has(n)){s[n]=d;continue}let{config:f}=em(t,c.name),m=function(e,t,r,n,a,o){let i=function(e,t){let r=e.add||[],n=e.remove||[],a=e.order||[],{extensions:o}=iD.getState(),i=new Set(n),s=[...t,...r].filter(e=>!i.has(e)),l=iB(a),u=iB(t),c=new Map(s.map(e=>[e,function(e,t,r,n){let a=t.get(e);if(void 0!==a)return a;{if(void 0!==r)return 1e3+r;let t=n.get(e);return void 0!==t?2e3+t:3e3}}(e,l,o[i$(e)]?.order,u)]));return s.sort((e,t)=>c.get(e)-c.get(t))}(r,t.slots[e].attachedIds),s=[];for(let l of i){let{config:i}=eh(n,e,l),u=eg(r,e,l),c=u?(0,X.merge)({},i,u):i,d=i$(l),f=t.extensions[d];if(f){let e=c?.["Display conditions"]?.privileges??f.privileges??[];if(e&&("string"==typeof e||Array.isArray(e)&&e.length>0)&&(!o?.user||!ar(e,o.user))||f.featureFlag&&!a.includes(f.featureFlag))continue;s.push({id:l,name:d,moduleName:f.moduleName,config:c,featureFlag:f.featureFlag,meta:f.meta,displayConditionExpression:c?.["Display conditions"]?.expression||f.displayExpression})}}return s}(n,e,f,r,u,a.session);d&&d.moduleName===c.moduleName&&(0,X.isEqual)(d.candidateExtensions,m)?s[n]=d:(s[n]={moduleName:c.moduleName,candidateExtensions:m},l=!0)}(l||Object.keys(i).length!==Object.keys(s).length)&&iS.setState({slots:s})}(iD.getState(),i_.getState(),iC.getState(),o2.getState(),n4.getState(),t)}catch(e){throw ik=null===t||null===ik?null:new Set([...t,...ik]),e}if(e>=20)return void console.error("The extension system stopped recomputing after 20 passes because something keeps invalidating slots in response to the extension store being written. Some slots are left stale until the next write.")}}finally{iP=!1}}}function iT(e,t){let r=new Set;for(let n of Object.keys(e))e[n]!==t[n]&&r.add(n);for(let n of Object.keys(t))n in e||r.add(n);return r}function iN(e,t){return{moduleName:t,name:e,attachedIds:[]}}function i$(e){let[t]=e.split("#");return t}function iI(e,t){let r=i$(t);return e.extensions[r]}function iM(e){return iI(iD.getState(),e)}iD.subscribe((e,t)=>{iR(e.extensions!==t.extensions?null:iT(e.slots,t.slots))}),i_.subscribe((e,t)=>{iR(iT(e.slots,t.slots))}),iC.subscribe((e,t)=>{iR(iT(e.configs,t.configs))}),o2.subscribe(()=>iR(null)),n4.subscribe(()=>iR(null)),iR(null);let iA=e=>ir(t=>({...t,extensions:{...t.extensions,[e.name]:{...e}}}));function ij(e,t){ir(r=>{let n=r.slots[e];return n?{...r,slots:{...r.slots,[e]:{...n,attachedIds:[...n.attachedIds,t]}}}:{...r,slots:{...r.slots,[e]:{...iN(e),attachedIds:[t]}}}})}function iL(e,t){ir(r=>{let n=r.slots[e];return n&&n.attachedIds.includes(t)?{...r,slots:{...r.slots,[e]:{...n,attachedIds:n.attachedIds.filter(e=>e!==t)}}}:r})}function iF(e){ir(t=>{let r=t.slots[e];return r?{...t,slots:{...t.slots,[e]:{...r,attachedIds:[]}}}:t})}function iB(e){let t=new Map;return e.forEach((e,r)=>{t.has(e)||t.set(e,r)}),t}function iV(e,t){return function(e,t,r=null,n){let a;return e.filter(e=>{let o=e.displayConditionExpression;if("string"!=typeof o||0===o.trim().length)return!0;a??(a=t&&"object"==typeof t?{session:r,...t}:{session:r});try{return!!oO(o,a)}catch(t){return console.error(`Error while evaluating expression '${o}' for ${e.id}`+(n?` in ${n}`:""),t),!1}})}(iU(e),t,n4.getState().session,e)}function iU(e){return iS.getState().slots[e]?.candidateExtensions??[]}let iW=(e,t)=>iD.setState(r=>{let n=r.slots[t]?.moduleName;if(n&&n!=e)return console.warn(`An extension slot with the name '${t}' already exists. Refusing to register the same slot name twice (in "registerExtensionSlot"). The existing one is from module ${n}.`),r;if(n&&n==e)return r;if(r.slots[t])return{...r,slots:{...r.slots,[t]:{...r.slots[t],moduleName:e}}};let a=iN(t,e);return{...r,slots:{...r.slots,[t]:{...a}}}}),iH=()=>{ik=null,ir(()=>({slots:{},extensions:{}})),it().setState({renderings:new Map}),iS.setState({slots:{}})},iz=V("left-nav",{slotName:null,basePath:window.spaBase,mode:"normal"});function iK({name:e,basePath:t,mode:r,componentContext:n,state:a}){iz.setState({slotName:e,basePath:t,mode:r??"normal",componentContext:n,state:a})}function iG(e){iz.getState().slotName===e&&iz.setState(iz.getInitialState(),!0)}let iZ=V("modalRegistry",{modals:{}});function iY(e){iZ.setState(t=>(t.modals[e.name]=e,t))}function iq(e){let t=iZ.getState().modals[e];if(!t){let r=iM(e);r&&(t={name:e,load:r.load,moduleName:r.moduleName},console.warn(`Modal ${e} was registered as an extension. This is deprecated and will be removed in the future. Please register it in the "modals" section of routes.json instead of the "extensions" section.`),iY(t))}return t}let iJ=V("workspace2",{registeredGroupsByName:{},registeredWindowsByName:{},registeredWorkspacesByName:{},openedGroup:null,openedWindows:[],isMostRecentlyOpenedWindowHidden:!1});function iX(e){let{registeredWorkspacesByName:t,registeredWindowsByName:r}=iJ.getState(),n=t[e];if(n){let t=r[n.window];if(t)return t;throw Error(`No workspace window found with name: ${n.window} for workspace: ${e}`)}throw Error(`No workspace found with name: ${e}`)}function iQ(e){let{registeredGroupsByName:t,registeredWindowsByName:r}=iJ.getState(),n=r[e];if(n){let r=t[n.group];if(r)return r;throw Error(`No workspace group found with name: ${n.group} for window: ${e}`)}throw Error(`No workspace window found with name: ${e}`)}function i0(e){let{openedWindows:t}=iJ.getState();return t.findIndex(t=>t.openedWorkspaces.find(t=>t.workspaceName===e))}function i1(e,t){if(0==t.length)return;let{registeredGroupsByName:r}=iJ.getState(),n={...r};for(let r of t){if(n[r.name])throw Error(`Cannot register workspace group ${r.name} more than once`);n[r.name]={...r,moduleName:e}}iJ.setState({registeredGroupsByName:n})}function i2(e,t){if(0==t.length)return;let{registeredWindowsByName:r}=iJ.getState(),n={...r};for(let r of t){if(n[r.name])throw Error(`Cannot register workspace window ${r.name} more than once`);let t={...r,moduleName:e};n[r.name]=t}iJ.setState({registeredWindowsByName:n})}function i4(e,t){if(0==t.length)return;let{registeredWorkspacesByName:r}=iJ.getState(),n={...r};for(let r of t){if(n[r.name])throw Error(`Cannot register workspace ${r.name} more than once`);let t={...r,moduleName:e};n[r.name]=t}iJ.setState({registeredWorkspacesByName:n})}let i3=0,i6=null,i5={bootstrap:15e3,mount:15e3,unmount:15e3};function i9(e,t){if(e.timeouts)return e;let r=e.name??"parcel",n=Object.fromEntries(Object.keys(i5).filter(t=>e[t]).map(n=>{var a,o;let i,s;return[n,(a=e[n],o=i5[n],i=Array.isArray(a)?a:[a],s=e=>i.reduce((t,a,o)=>t.then(()=>{let t=a(e);return"function"==typeof t?.then&&"function"==typeof t?.catch?t:Promise.reject(Error(`Lifecycle function ${n} at array index ${o} for parcel ${r} did not return a promise`))}),Promise.resolve(void 0)),e=>{let a,i=new Promise((e,t)=>{a=setTimeout(()=>t(Error(`Lifecycle function ${n} for parcel ${r} did not settle within ${o}ms`)),o)});return Promise.race([s(e),i]).finally(()=>clearTimeout(a)).then(e=>(t(n,!1),e),e=>{throw t(n,!0),e})})]}));return{...e,...n}}async function i8(e,t){var r,n;let a,o,i,s,l,u=await (i6??(i6=new Promise((e,t)=>{t0({name:"openmrs-extension-host",bootstrap:()=>Promise.resolve(),mount:t=>(e(t.mountParcel),Promise.resolve()),unmount:()=>Promise.resolve()},{domElement:document.createElement("div")}).mountPromise.catch(t)}).catch(e=>(console.error("The host parcel used to mount extensions could not be mounted. Falling back to mounting extensions as root parcels, which leaks their DOM elements.",e),t0))),i6),c={...t},d=(a=c,o=!1,{retarget:e=>a={...e},release:i=()=>(function(e){for(let t of Object.keys(e))delete e[t]})(a),onSettled(e,t){switch(e){case"bootstrap":t&&i();return;case"mount":o||(o=t);return;case"unmount":(t||o)&&i();return}}});return n=u((r=d.onSettled,"function"==typeof e?()=>e().then(e=>i9(e,r)):i9(e,r)),c),s=e=>t=>e.call(n,d.retarget(t)).catch(e=>{throw"SKIP_BECAUSE_BROKEN"===n.getStatus()&&d.release(),e}),l=n.update&&s(n.update),Object.defineProperty(n,"update",{configurable:!0,enumerable:!0,get:()=>l,set:e=>{l=e&&s(e)}})}function i7(){return se}function se(e,t){let r,n=i8(e,t).then(e=>r=e);return{mount:()=>n.then(e=>e.mount()),unmount:()=>n.then(e=>e.unmount()),update:e=>n.then(t=>t.update?.(e)),getStatus:()=>r?.getStatus()??"LOADING_SOURCE_CODE",get loadPromise(){return n.then(e=>e.loadPromise)},get bootstrapPromise(){return n.then(e=>e.bootstrapPromise)},get mountPromise(){return n.then(e=>e.mountPromise)},get unmountPromise(){return n.then(e=>e.unmountPromise)}}}async function st(e,t,r,n,a=e=>e,o={}){let i=i$(n),s=iM(n),l=null;if(e){let u;if(!s)throw Error(`Couldn't find extension '${i}' to attach to '${t}'`);let{meta:c,moduleName:d,load:f}=s,m=i3++,p=`${t}/${n}-${m}`;e.dataset.extensionRenderingId=p;let h=e=>{try{iu(p)}catch(t){console.error(e,t)}};try{il({renderingId:p,extensionName:i,extensionModuleName:d,extensionId:n,slotName:t,slotModuleName:r})}catch(e){throw h(`Recomputing configuration after registering '${n}' failed also failed`),e}try{u=await f()}catch(e){throw h(`Recomputing configuration after '${n}' failed to load also failed`),e}try{l=await i8(a({...u,name:`${t}/${i}-${m}`}),{...o,_meta:c,_extensionContext:{extensionId:n,extensionSlotName:t,extensionSlotModuleName:r,extensionModuleName:d,extensionMeta:c},domElement:e})}catch(e){throw h(`Recomputing configuration after '${n}' failed to mount also failed`),e}l.mountPromise.then(void 0,e=>{console.error(`Extension '${n}' in slot '${t}' failed to mount`,e),h(`Recomputing configuration after '${n}' failed to mount also failed`)}),l.unmountPromise.then(()=>h(`Recomputing configuration after unmounting '${n}' failed`),e=>{console.error(`Extension '${n}' in slot '${t}' failed to unmount`,e),h(`Recomputing configuration after '${n}' failed to unmount also failed`)})}else console.warn(`Tried to render ${n} into ${t} but no DOM element was available.`);return l}var sr=r(7979),sn=r.n(sr);let sa=(0,sr.createContext)({moduleName:"",featureName:""});function so({to:e,templateParams:t,onBeforeNavigate:r,children:n,...a}){return(0,sr.useEffect)(()=>{a.href&&console.warn(`ConfigurableLink does not support the href prop. Use the 'to' prop instead. The provided href value is '${a.href}'`),a.onClick&&console.warn(`ConfigurableLink does not support the onClick prop. Use the 'onBeforeNavigate' prop instead. The 'to' prop of the offending link is ${e}`)},[]),sn().createElement("a",{onClick:n=>{0===n.button&&!n.ctrlKey&&!n.shiftKey&&!n.altKey&&!n.metaKey&&(n.preventDefault(),r?.(n),nV({to:e,templateParams:t})),0===n.button&&(n.ctrlKey||n.metaKey)&&r?.(n),0===n.button&&n.shiftKey&&r?.(n),1===n.button&&r?.(n)},href:nF(e,t),...a},n)}let si=({state:e,children:t,...r})=>{let{extension:n}=(0,sr.useContext)(sa),a=(0,sr.useRef)(null),o=(0,sr.useRef)(Promise.resolve()),i=(0,sr.useRef)(!1),s=(0,sr.useRef)(!1),l=(0,sr.useRef)(e),u=(0,sr.useCallback)(e=>{if(!e)return;let t=()=>{"MOUNTED"===e.getStatus()&&e.unmount()};switch(e.getStatus()){case"MOUNTED":e.unmount();break;case"UPDATING":o.current?.then(t,t);break;default:e.mountPromise.then(t,()=>{})}},[]),c=(0,sr.useCallback)((e,t)=>{e.update&&"UNMOUNTING"!==e.getStatus()&&(o.current=Promise.all([e.mountPromise,o.current]).then(()=>{if(a.current?.getStatus()==="MOUNTED"&&a.current.update)return a.current.update({...t})}).catch(e=>{let t=a.current?.getStatus();"UNMOUNTING"!==t&&"NOT_MOUNTED"!==t&&"UNLOADING"!==t&&console.error(`The extension '${n?.extensionId}' failed to update`,e)}))},[]),d=(0,sr.useCallback)(t=>{t&&!a.current&&!s.current&&n?.extensionSlotName&&n.extensionSlotModuleName&&(s.current=!0,st(t,n.extensionSlotName,n.extensionSlotModuleName,n.extensionId,void 0,e).then(t=>{(s.current=!1,a.current=t,i.current)?u(t):t&&l.current!==e&&c(t,l.current)},()=>{s.current=!1}))},[]);return(0,sr.useEffect)(()=>(i.current=!1,()=>{i.current=!0,u(a.current)}),[]),(0,sr.useEffect)(()=>{l.current=e,a.current&&c(a.current,e)},[e]),n?sn().createElement("div",{ref:d,"data-extension-id":n?.extensionId,style:{position:"relative"},...r}):null};function ss(e){let t=(0,sr.useRef)(e);return T(t.current,e)||(t.current=e),t.current}function sl(e,t){"function"==typeof t&&(t=t(e));let r={};for(let[n,a]of Object.entries(t)){let t=function(...t){e.setState(e=>a(e,...t))};r[n]=t}return r}let su=e=>e;function sc(e,t=su,r){let n=(0,sr.useCallback)(t=>e.subscribe(t),[e]),a=(0,sr.useCallback)(()=>t(e.getState()),[e,t]),o=(0,sr.useSyncExternalStore)(n,a,a),i=(0,sr.useMemo)(()=>r?sl(e,r):null,[e,r]);return(0,sr.useMemo)(()=>i?{...o,...i}:o,[o,i])}function sd(e,t){return sc(e,su,t)}function sf(e){return function(t){let r=(0,sr.useCallback)(t=>e.subscribe(t),[]),n=(0,sr.useCallback)(()=>e.getState(),[]),a=(0,sr.useSyncExternalStore)(r,n,n),o=(0,sr.useMemo)(()=>t?sl(e,t):null,[t]);return(0,sr.useMemo)(()=>o?{...a,...o}:a,[a,o])}}let sm=[];Object.freeze(sm);let sp={candidateExtensions:sm};Object.freeze(sp);let sh=e=>{let t=(0,sr.useCallback)(t=>t.slots?.[e]??sp,[e]);return sc(ic(),t)},sg=e=>e.session;function sy(e,t){let{candidateExtensions:r}=sh(e),n=sc(n4,sg),a=ss(t);return(0,sr.useMemo)(()=>iV(e,a),[e,a,n,r])}function sv(e,t){let{moduleName:r}=(0,sr.useContext)(sa);if(!r)throw Error("ComponentContext has not been provided. This should come from @openmrs/esm-react-utils.");return(0,sr.useEffect)(()=>{iW(r,e)},[r,e]),{extensions:sy(e,t),extensionSlotName:e,extensionSlotModuleName:r}}function sb(e){return e}function sw({name:e,extensionSlotName:t,select:r=sb,children:n,state:a,style:o,...i}){if(n&&a)throw Error("Both children and state have been provided. If children are provided, the state must be passed as a prop to the `Extension` component.");let s=e??t,l=(0,sr.useRef)(null),{extensions:u,extensionSlotModuleName:c}=sv(s,a),d=(0,sr.useMemo)(()=>r(u),[r,u]),f=(0,sr.useMemo)(()=>{if("function"==typeof n&&!sn().isValidElement(n))return d.map(e=>n(e,a))},[n,d]);return sn().createElement("div",{ref:l,"data-extension-slot-name":s,"data-extension-slot-module-name":c,style:{...o,position:"relative"},...i},s&&d?.map((e,t)=>sn().createElement(sa.Provider,{key:e.id,value:{moduleName:c,featureName:"",extension:{extensionId:e.id,extensionSlotName:s,extensionSlotModuleName:c,extensionMeta:e.meta}}},f?.[t]??("function"!=typeof n?n:null)??sn().createElement(si,{state:a}))))}var sE=r(5338);function sx(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function sD(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?sx(Object(r),!0).forEach(function(t){var n,a,o;n=e,a=t,o=r[t],a in n?Object.defineProperty(n,a,{value:o,enumerable:!0,configurable:!0,writable:!0}):n[a]=o}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):sx(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function sS(e){return(sS="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 s_(e){return(s_="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 sC(e,t){var r;if("function"!=typeof(r=t.domElement?function(){return t.domElement}:t.domElementGetter?t.domElementGetter:e.domElementGetter?e.domElementGetter:function(e){var t=e.appName||e.name;if(!t)throw Error("single-spa's dom-element-getter-helpers was not given an application name as a prop, so it can't make a unique dom element container for the react application");var r="single-spa-application:".concat(t);return function(){var e=document.getElementById(r);return e||((e=document.createElement("div")).id=r,document.body.appendChild(e)),e}}(t)))throw Error("single-spa's dom-element-getter-helpers was given an invalid domElementGetter for application or parcel '".concat(t.name,"'. Expected a function, received ").concat(s_(r)));return function(){var e=r(t);if(!(e instanceof HTMLElement))throw Error("single-spa's dom-element-getter-helpers: domElementGetter returned an invalid dom element for application or parcel '".concat(t.name,"'. Expected HTMLElement, received ").concat(s_(e)));return e}}var sk=null;try{sk=require("react").createContext()}catch(e){}var sP={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 sR(e,t){return e.rootComponent?Promise.resolve():e.loadRootComponent(t).then(function(t){e.rootComponent=t})}function sO(e,t){return new Promise(function(r,n){e.suppressComponentDidCatchWarning||!function(e){if(!(e&&"string"==typeof e.version&&e.version.indexOf(".")>=0))return!1;var t=e.version.slice(0,e.version.indexOf("."));try{return Number(t)>=16}catch(e){return!1}}(e.React)||e.errorBoundary||e.errorBoundaryClass||(e.rootComponent.prototype?e.rootComponent.prototype.componentDidCatch||console.warn("single-spa-react: ".concat(t.name||t.appName||t.childAppName,"'s rootComponent should implement componentDidCatch to avoid accidentally unmounting the entire single-spa application.")):console.warn("single-spa-react: ".concat(t.name||t.appName||t.childAppName,"'s rootComponent does not implement an error boundary. If using a functional component, consider providing an opts.errorBoundary to singleSpaReact(opts).")));var a,o=sI(e,t,function(){r(this)}),i=sC(e,t)(),s=function(e){var t=e.reactDom,r=e.renderType,n=e.elementToRender,a=e.domElement,o=t[r];if("function"!=typeof o)throw Error('renderType "'.concat(r,'" did not return a function.'));switch(r){case"createRoot":case"unstable_createRoot":case"createBlockingRoot":case"unstable_createBlockingRoot":var i=o(a);return i.render(n),i;case"hydrateRoot":return o(a,n);default:return o(n,a),null}}({elementToRender:o,domElement:i,reactDom:s$(e),renderType:"function"==typeof(a=e).renderType?a.renderType():a.renderType});e.domElements[t.name]=i,e.renderResults[t.name]=s})}function sT(e,t){return new Promise(function(r){e.unmountResolves[t.name]=r;var n=e.renderResults[t.name];n&&n.unmount?n.unmount():s$(e).unmountComponentAtNode(e.domElements[t.name]),delete e.domElements[t.name],delete e.renderResults[t.name]})}function sN(e,t){return new Promise(function(r){e.updateResolves[t.name]||(e.updateResolves[t.name]=[]),e.updateResolves[t.name].push(r);var n=sI(e,t,null),a=e.renderResults[t.name];if(a&&a.render)a.render(n);else{var o=sC(e,t)();s$(e).render(n,o)}})}function s$(e){return e.ReactDOMClient||e.ReactDOM}function sI(e,t,r){var n=e.React.createElement(e.rootComponent,t),a=sk?e.React.createElement(sk.Provider,{value:t},n):n;return(e.errorBoundary||t.errorBoundary||e.errorBoundaryClass||t.errorBoundaryClass)&&(e.errorBoundaryClass=e.errorBoundaryClass||t.errorBoundaryClass||function(e,t){function r(t){e.React.Component.apply(this,arguments),this.state={caughtError:null,caughtErrorInfo:null},r.displayName="SingleSpaReactErrorBoundary(".concat(t.name,")")}return r.prototype=Object.create(e.React.Component.prototype),r.prototype.render=function(){return this.state.caughtError?(e.errorBoundary||t.errorBoundary)(this.state.caughtError,this.state.caughtErrorInfo,this.props):this.props.children},r.prototype.componentDidCatch=function(e,t){this.setState({caughtError:e,caughtErrorInfo:t})},r}(e,t),a=e.React.createElement(e.errorBoundaryClass,t,a)),a=e.React.createElement(e.SingleSpaRoot,sD(sD({},t),{},{mountFinished:r,updateFinished:function(){e.updateResolves[t.name]&&(e.updateResolves[t.name].forEach(function(e){return e()}),delete e.updateResolves[t.name])},unmountFinished:function(){e.unmountResolves[t.name]&&(e.unmountResolves[t.name](),delete e.unmountResolves[t.name])}}),a)}var sM=r(3826),sA=r(1943),sj=r.n(sA),sL=r(7956);let sF={strictMode:!0,throwErrorsToConsole:!0,disableTranslations:!1},sB=new Map;(0,sL.initCache)(sB);let sV={errorRetryCount:3,fetcher:n1,focusThrottleInterval:18e5,revalidateIfStale:!0,revalidateOnFocus:!1,revalidateOnReconnect:!1,refreshInterval:0,shouldRetryOnError:e=>{if(e instanceof n2){let t=e.response.status;return!!(t>=500)||401===t||403===t||429===t}return!0},provider:()=>sB};function sU(e){if("object"!=typeof e||"string"!=typeof e.featureName||"string"!=typeof e.moduleName)throw Error("Invalid options");let t=Object.assign({},sF,e),r={...sV,...t.swrConfig};return function(e){var n,a,o,i,s;return o=a=class extends(n=sn().Component){componentDidCatch(e,r){r&&r.componentStack&&(e.extra=Object.assign(e.extra||{},{componentStack:r.componentStack})),t.throwErrorsToConsole&&setTimeout(()=>{throw e}),this.setState({caughtError:e,caughtErrorInfo:r})}render(){if(this.state.caughtError)return sn().createElement("div",null,"An error has occurred. Please try reloading the page.");{let n=sn().createElement(sr.Suspense,{fallback:null},sn().createElement(sA.SWRConfig,{value:r},sn().createElement(sa.Provider,{value:this.state.config},t.disableTranslations?sn().createElement(e,this.props):sn().createElement(sM.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},sn().createElement(e,this.props)))));return t.strictMode&&sn().StrictMode?sn().createElement(sn().StrictMode,null,n):n}}constructor(e){super(e),this.state={caughtError:null,caughtErrorInfo:null,config:{moduleName:t.moduleName,featureName:t.featureName,extension:e._extensionContext}}}},i="displayName",s=`OpenmrsReactComponent(${t.featureName})`,i in o?Object.defineProperty(o,i,{value:s,enumerable:!0,configurable:!0,writable:!0}):o[i]=s,a}}function sW(e,t){return function(e){if("object"!==sS(e))throw Error("single-spa-react requires a configuration object");var t,r=sD(sD({},sP),e);if(!r.React)throw Error("single-spa-react must be passed opts.React");if(!r.ReactDOM&&!r.ReactDOMClient)throw Error("single-spa-react must be passed opts.ReactDOM or opts.ReactDOMClient");if(r.renderType||(null!=(t=r.ReactDOMClient)&&t.createRoot?r.renderType="createRoot":r.renderType="render"),!r.rootComponent&&!r.loadRootComponent)throw Error("single-spa-react must be passed opts.rootComponent or opts.loadRootComponent");if(r.errorBoundary&&"function"!=typeof r.errorBoundary)throw Error("The errorBoundary opt for single-spa-react must either be omitted or be a function that returns React elements");!sk&&r.React.createContext&&(sk=r.React.createContext()),r.SingleSpaRoot=function(e){function t(e){t.displayName="SingleSpaRoot(".concat(e.name,")")}return t.prototype=Object.create(e.React.Component.prototype),t.prototype.componentDidMount=function(){setTimeout(this.props.mountFinished)},t.prototype.componentWillUnmount=function(){setTimeout(this.props.unmountFinished)},t.prototype.render=function(){return setTimeout(this.props.updateFinished),this.props.children},t}(r);var n={bootstrap:sR.bind(null,r),mount:sO.bind(null,r),unmount:sT.bind(null,r)};return r.parcelCanUpdate&&(n.update=sN.bind(null,r)),n}({React:sn(),ReactDOMClient:sE,rootComponent:sU(t)(e)})}function sH(e,t){return()=>e().then(({default:e})=>sW(e,t))}function sz(e,t){return()=>Promise.resolve(sW(e,t))}let sK=sH,sG=M()(()=>({}));W("openmrs-app-context",sG);let sZ={};function sY(e,t=e=>e){let r=sG.getState();return e in r?Object.freeze(Object.assign({},t?t(r[e]):r[e])):null}function sq(e,t){sG.setState(r=>(e in r||(r[e]={}),r[e]=t(r[e]),Object.assign({},r)))}function sJ(e){return null===e?null:Object.freeze(Object.assign({},e))}let sX=new Map;function sQ(e,t){let r=(0,sr.useRef)(t??{}),n=(0,sr.useRef)(t=>sq(e,t)),a=(0,sr.useRef)(Symbol());return(0,sr.useEffect)(()=>{let r=t??{},n=a.current;return null===sY(e)?!function(e,t=sZ){sG.setState(r=>{if(e in r)throw Error(`Attempted to re-register namespace ${e} in the app context. Each namespace must be unregistered before the name can be registered again.`);return Object.assign({},r,{[e]:t===sZ?{}:t})})}(e,r):(console.warn(`Namespace ${e} is already registered in the app context. This is likely a race condition during navigation, but may indicate two components are trying to own the same namespace. Updating the existing context.`),sq(e,()=>r)),sX.set(e,n),()=>{sX.get(e)===n&&(sG.setState(t=>(e in t&&delete t[e],t)),sX.delete(e))}},[e]),(0,sr.useEffect)(()=>{let n=t??{};T(r.current,n)||(sq(e,()=>n),r.current=n)},[t]),n.current}function s0({namespace:e,value:t}){return sQ(e,t),null}let s1=({children:e,value:t,fallback:r})=>t?sn().createElement(sn().Fragment,null,e):r?sn().createElement(sn().Fragment,null,r):null;function s2(){let e=(0,sr.useRef)();return(!e.current||e.current.signal.aborted)&&(e.current=new AbortController),(0,sr.useEffect)(()=>{let t=e.current;return()=>t?.abort()},[]),e.current}function s4(e,t=e=>e??{}){let[r,n]=(0,sr.useState)(()=>{if(s3(e))return;let r=sY(e);if(null!==r)return t?t(r):r});return(0,sr.useEffect)(()=>{if(s3(e))throw Error(`The namespace supplied to useAppContext must be a non-empty string, but was "${e}".`)},[e]),(0,sr.useEffect)(()=>{var r;let a;return(r=e=>{if(null==e)return void n(void 0);let r=t?t(e):e;n(e=>T(e,r)?e:r)})(sJ(a=sY(e))),sG.subscribe(t=>{let n=e in t?t[e]:null;n!==a&&(a=n,r(sJ(n)))})},[e,t]),r}function s3(e){return"string"!=typeof e||0===e.trim().length}function s6(e){let t=sy(e);return(0,sr.useMemo)(()=>t.map(e=>e.id),[t])}function s5(e){return sh(e).candidateExtensions}function s9(e,t,r){let{data:n,error:a,mutate:o,isLoading:i,isValidating:s}=sj()(e?or(e,t,r):null,n1);return(0,sr.useMemo)(()=>({isLoading:i,data:n?.data.results??[],error:a,mutate:o,isValidating:s}),[n,a,i,s,o])}function s8(e){(0,sr.useEffect)(()=>{if(e){let e=window.getComputedStyle(document.body).overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=e}}},[e])}let s7={},le=`No ComponentContext has been provided. This should come from "openmrsComponentDecorator".
|
|
15
|
+
${this.stack}`}}let n4=V("session",{loaded:!1,session:null}),n3=0,n6=null;function n5(){return n6||(n4.getState().loaded&&n3>=Date.now()-6e4?null:ae())}function n9(e){let t=e?.includeAuthStatus??!0,r=e=>t?e:e.user,n=n5();return n?new Promise(e=>{let t=()=>{let t=n4.getState();t.loaded&&(a(),e(r(t.session)))},a=n4.subscribe(t);n.then(t,t)}):Promise.resolve(r(n4.getState().session))}function n8(){return n5(),n4}function n7(e){let t=e.locale??e.user?.userProperties?.defaultLocale;t&&t.includes("_")&&(t=t.replaceAll("_","-")),function(e){if(void 0===e||"string"!=typeof e)return!1;try{new Intl.Locale(e)}catch(e){return!1}return!0}(t)&&t!==document.documentElement.getAttribute("lang")&&document.documentElement.setAttribute("lang",t)}function ae(e,t){n3=Date.now(),o??(o=n3);let r={};e&&t&&(r.Authorization=`Basic ${window.btoa(`${e}:${t}`)}`);let n=ac(n1(nQ,{headers:r,rejectAuthFailure:!0})),a=()=>{n6===n&&(n6=null)};return n.then(a,a),n6=n,n}function at(){n4.setState({loaded:!0,session:{authenticated:!1,sessionId:""}},!0)}function ar(e,t){var r,n;if(void 0===t)return!e;if(!e)return!0;return r=e,n=t,("string"==typeof r?!(0,X.isUndefined)(n.privileges.find(e=>r===e.display)):Array.isArray(r)?r.every(e=>!(0,X.isUndefined)(n.privileges.find(t=>e===t.display))):((0,X.isUndefined)(r)||console.error(`Could not understand privileges "${r}"`),!0))||!(0,X.isUndefined)(t.roles.find(e=>"System Developer"===e.display))}function an(){let e,t;return new Promise(r=>{let n=n=>{n.loaded&&n.session.user&&(e=n.session.user,r(n.session.user),t&&t())};n(n4.getState()),e||(t=n4.subscribe(n))})}async function aa(){return(await n9()).sessionLocation}async function ao(e,t){return ac(n1(nQ,{method:"POST",body:{sessionLocation:e},headers:{"Content-Type":"application/json"},rejectAuthFailure:!0,signal:t?.signal}))}async function ai(e,t){return await n1(nQ,{method:"POST",body:{locale:e},headers:{"Content-Type":"application/json"},signal:t?.signal}),ae()}async function as(e,t,r){return r||(r=new AbortController),await n1(`${nJ}/user/${e}`,{method:"POST",body:{userProperties:t},headers:{"Content-Type":"application/json"},signal:r.signal}),ae()}async function al(e,t=!1){let r=await n1(t?`${nQ}?rememberMe=true`:nQ,{headers:{"X-Totp-Code":e}});return r.data?.authenticated?(await ae()).session:r.data}async function au(){try{await n1(nQ,{method:"DELETE",rejectAuthFailure:!0})}catch(e){if(!ad(e))throw e}at(),await ae().catch(()=>{})}function ac(e){return new Promise((t,r)=>{e.then(e=>{if("object"==typeof e?.data){let r={loaded:!0,session:e.data};n4.setState(r,!0),t(r)}else!function(e){if(!e?.redirected||!e.url)return!1;try{return new URL(e.url,window.location.href).pathname.replace(/\/+$/,"").endsWith("/initialsetup")}catch{return!1}}(e)?r(af(Error("The session endpoint did not respond with a session"))):r(af(Error("The server is still starting up"),!0))}).catch(e=>{var n,a;if(ad(e)){"object"==typeof(n=e.responseBody)&&null!==n&&!1===n.authenticated?n4.setState({loaded:!0,session:e.responseBody},!0):at(),t(n4.getState());return}(a=e)instanceof n2&&502===a.response.status&&!n4.getState().loaded&&void 0!==o&&Date.now()-o<18e4?r(af(e,!0)):(P(`Failed to fetch new session information: ${e}`),r(af(e)))})})}function ad(e){return e instanceof n2&&(401===e.response.status||403===e.response.status)}function af(e,t=!1){return n4.getState().loaded||n4.setState({loaded:!1,session:null,error:e instanceof Error?e:Error(String(e)),initializing:t},!0),n4.getState()}function am(){return"development"===window.spaEnv||"true"===localStorage.getItem("openmrs:devtools")}n4.subscribe(e=>{e.loaded&&e.session&&n7(e.session)});let ap={"webservices.rest":"2.24.0",fhir2:"1.0.0-SNAPSHOT"};function ah(){ej("@openmrs/esm-api",nY),ae()}let ag="import-map-override:",ay="import-map-overrides-disabled",av="import-map-overrides:change",ab=!1,aw=null,aE=null;async function ax(){return aE??(aE=aD().then(({map:e,complete:t})=>(t||(aE=null),e))),aE}async function aD(){let e=document.querySelectorAll('script[type="systemjs-importmap"]'),t=[],r=!0;for(let n=0;n<e.length;n++){let a=e[n];try{if(a.src){let e=await fetch(a.src);if(!e.ok)throw Error(`Request for ${a.src} returned ${e.status} ${e.statusText}`);t.push(await e.json())}else a.textContent&&t.push(JSON.parse(a.textContent))}catch(e){r=!1,console.warn(`[import-maps] Failed to parse import map from script tag at index ${n}`,e)}}return{map:aS(t),complete:r}}function aS(e){let t={imports:{}};for(let r of e)r?.imports&&Object.assign(t.imports,r.imports);return t}function a_(){let e={};try{let t=aO();for(let r=0;r<localStorage.length;r++){let n=localStorage.key(r);if(n?.startsWith(ag)){let r=n.slice(ag.length);if(!t.includes(r)){let t=localStorage.getItem(n);t&&(e[r]=t)}}}}catch(e){console.warn("[import-maps] Failed to read import-map overrides from localStorage",e)}return{imports:e}}async function aC(){let e=await ax();return ab?aS([e,aw??a_()]):e}async function ak(){return ax()}async function aP(){return ab?aS([await ax(),a_()]):ax()}function aR(e){if(!ab)return{imports:{}};if(e){let e={};for(let t=0;t<localStorage.length;t++){let r=localStorage.key(t);if(r?.startsWith(ag)){let t=localStorage.getItem(r);t&&(e[r.slice(ag.length)]=t)}}return{imports:e}}return a_()}function aO(){if(!ab)return[];try{let e=localStorage.getItem(ay);if(e){let t=JSON.parse(e);if(Array.isArray(t))return t}}catch{}return[]}function aT(e){return!!ab&&aO().includes(e)}function aN(e,t){if(!ab)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{localStorage.setItem(ag+e,t),window.dispatchEvent(new CustomEvent(av))}catch(e){console.warn("[import-maps] Failed to write import-map override to localStorage",e)}}function a$(e){if(!ab)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{localStorage.removeItem(ag+e);let t=aO().filter(t=>t!==e);t.length>0?localStorage.setItem(ay,JSON.stringify(t)):localStorage.removeItem(ay),window.dispatchEvent(new CustomEvent(av))}catch(e){console.warn("[import-maps] Failed to update import-map overrides in localStorage",e)}}function aI(){if(!ab)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{let e=[];for(let t=0;t<localStorage.length;t++){let r=localStorage.key(t);r?.startsWith(ag)&&e.push(r)}e.forEach(e=>localStorage.removeItem(e)),localStorage.removeItem(ay),window.dispatchEvent(new CustomEvent(av))}catch(e){console.warn("[import-maps] Failed to clear import-map overrides from localStorage",e)}}function aM(e){if(!ab)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{let t=aO().filter(t=>t!==e);t.length>0?localStorage.setItem(ay,JSON.stringify(t)):localStorage.removeItem(ay),window.dispatchEvent(new CustomEvent(av))}catch(e){console.warn("[import-maps] Failed to update import-map overrides in localStorage",e)}}let aA=!1;function aj(){!aA&&(aA=!0,(ab="development"===window.spaEnv)&&(aw=a_()))}function aL(e){return e.replace(/[\/\-@]/g,"_")}async function aF(e,t="./start",n){var a;let o,i=!n?.maxLoadingTime||n.maxLoadingTime<=0?6e5:n.maxLoadingTime;await Promise.race([aB(e,n?.importMap),new Promise((t,r)=>{o=setTimeout(()=>{var t;r(Error(`Could not resolve requested script, ${e}, within ${(t=i)<1e3?`${t} milliseconds`:t<6e4?`${Math.floor(t/1e3)} seconds`:t<36e5?`${Math.floor(t/6e4)} minutes`:t<864e5?`${Math.floor(t/36e5)} hours`:`${Math.floor(t/864e5)} days`}.`))},i)})]),o&&clearTimeout(o);let s=aL(e),l=window[s];if(!("object"==typeof(a=l)&&null!==a&&"init"in a&&"function"==typeof a.init&&"get"in a&&"function"==typeof a.get)){let e=`The global variable ${s} does not refer to a federated module`;throw console.error(e),Error(e)}l.init(r.S.default);let u=(await l.get(t))();if("object"!=typeof u||null===u){let t=`Container for ${e} did not return an ESM module as expected`;throw console.error(t),Error(t)}return u}async function aB(e,t){if("string"!=typeof e||0===e.trim().length){let e="Attempted to call importDynamic() without supplying a package to load";throw console.error(e),Error(e)}let r=aL(e);if(!window[r]){let r=t??await aV();if(!r.imports.hasOwnProperty(e)){let t=`Could not find the package ${e} defined in the current importmap`;throw console.error(t),Error(t)}let n=r.imports[e];n.startsWith("./")&&(n=window.spaBase+n.substring(1));let a=e in aR().imports;try{return await function(e){var t;let r=(t=window)[aU]??(t[aU]=new Map),n=r.get(e);if(n)return n;if(document.head.querySelector(`script[src="${e}"]`))return console.warn(`Script at ${e} already loaded. Not loading it again.`),Promise.resolve();let a=document.createElement("script");a.src=e,a.type="text/javascript",a.async=!0;let o=new Promise((t,n)=>{let o=setTimeout(()=>{console.error(`The script at ${e} did not load within 5 seconds. This may indicate an issue with the imports in the script's entry-point file or with the script's bundler configuration.`)},5e3);function i(){clearTimeout(o),a.removeEventListener("load",s),a.removeEventListener("error",l)}function s(){i(),t()}function l(t){i(),r.delete(e),a.remove();let o=`Failed to load script from ${e}`;console.error(o,t),n(t.message??o)}a.addEventListener("load",s),a.addEventListener("error",l),document.head.appendChild(a)});return r.set(e,o),o}(n)}catch(e){return a&&x({kind:"error",title:nL("scriptLoadingFailed","Error: Script failed to load"),description:nL("scriptLoadingError","Failed to load overridden script from {{- url}}. Please check that the bundled script is available at the expected URL. Click the button below to reset all import map overrides.",{url:n}),actionButtonLabel:nL("resetOverrides","Reset overrides"),onActionButtonClick(){aI(),window.location.reload()}}),Promise.reject(e)}}return Promise.resolve()}async function aV(){return aC()}let aU=Symbol.for("__openmrs_script_loading");function aW(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,"modals")&&(!e.modals||!Array.isArray(e.modals))||Object.hasOwn(e,"workspaces2")&&(!e.workspaces2||!Array.isArray(e.workspaces2))||Object.hasOwn(e,"workspaceWindows2")&&(!e.workspaceWindows2||!Array.isArray(e.workspaceWindows2))||Object.hasOwn(e,"workspaceGroups2")&&(!e.workspaceGroups2||!Array.isArray(e.workspaceGroups2)))}function aH(e){return!!e&&"object"==typeof e&&"routes"in e&&!!e.routes&&"object"==typeof e.routes&&Object.entries(e.routes).every(([e,t])=>"string"==typeof e&&aW(t))}let az="openmrs-routes:",aK="openmrs-routes:change",aG=!1,aZ=null,aY=null;async function aq(){return aY??(aY=aJ().then(({map:e,complete:t})=>(t||(aY=null),e))),aY}async function aJ(){let e=document.querySelectorAll("script[type='openmrs-routes']"),t=[],r=!0;for(let n=0;n<e.length;n++){let a=e[n];try{let e;if(a.src){let t=await fetch(a.src);if(!t.ok)throw Error(`Request for ${a.src} returned ${t.status} ${t.statusText}`);e=await t.json()}else a.textContent&&(e=JSON.parse(a.textContent));e&&aH(e)&&t.push(e)}catch(e){r=!1,console.warn(`[route-maps] Failed to parse routes from script tag at index ${n}`,e)}}return{map:aX(t),complete:r}}function aX(e){let t={routes:{}};for(let r of e)r&&"object"==typeof r&&!Array.isArray(r)&&(Object.assign(t.routes,r.routes),void 0===t.version&&void 0!==r.version&&(t.version=r.version));return t}async function aQ(){let e={version:void 0,routes:{}};try{let t=[];for(let e=0;e<localStorage.length;e++){let r=localStorage.key(e);if(r?.startsWith(az)){let e=localStorage.getItem(r);e&&t.push({moduleName:r.slice(az.length),raw:e})}}for(let r of(await Promise.allSettled(t.map(async({moduleName:e,raw:t})=>{let r=JSON.parse(t);if(aW(r))return{moduleName:e,routes:r};if("string"==typeof r&&r.startsWith("http")){let t=await fetch(r),n=await t.json();if(aW(n))return{moduleName:e,routes:n};throw Error(`${r} did not resolve to a valid OpenmrsAppRoutes object`)}throw Error(`Override for ${e} is neither a valid routes object nor a URL`)}))))"fulfilled"===r.status?e.routes[r.value.moduleName]=r.value.routes:console.warn("[route-maps] Failed to load route override",r.reason)}catch(e){console.warn("[route-maps] Failed to read route overrides from localStorage",e)}return e}async function a0(){let e=await aq();return aG?aX([e,aZ??await aQ()]):e}async function a1(){return aq()}async function a2(){return aG?aX([await aq(),await aQ()]):aq()}function a4(){if(!aG)return{};let e={};try{for(let t=0;t<localStorage.length;t++){let r=localStorage.key(t);if(r?.startsWith(az)){let t=localStorage.getItem(r);t&&(e[r.slice(az.length)]=t)}}}catch(e){console.warn("[route-maps] Failed to read route overrides from localStorage",e)}return e}function a3(e,t){if(!aG)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{if("string"==typeof t)if(t.startsWith("http"))localStorage.setItem(az+e,JSON.stringify(t));else{let r=JSON.parse(t);if(!aW(r))return void console.error(`The supplied routes for ${e} is not a valid OpenmrsAppRoutes object`,t);localStorage.setItem(az+e,JSON.stringify(r))}else if(t instanceof URL)localStorage.setItem(az+e,JSON.stringify(t.toString()));else{if(!aW(t))return void console.error(`Override for ${e} is not in a valid format. Expected either a Javascript Object, a JSON string of a Javascript object, or a URL`,t);localStorage.setItem(az+e,JSON.stringify(t))}window.dispatchEvent(new CustomEvent(aK))}catch(e){console.warn("[route-maps] Failed to write route override to localStorage",e)}}function a6(e){if(!aG)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{localStorage.removeItem(az+e),window.dispatchEvent(new CustomEvent(aK))}catch(e){console.warn("[route-maps] Failed to remove route override from localStorage",e)}}function a5(){if(!aG)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{let e=[];for(let t=0;t<localStorage.length;t++){let r=localStorage.key(t);r?.startsWith(az)&&e.push(r)}e.forEach(e=>localStorage.removeItem(e)),window.dispatchEvent(new CustomEvent(aK))}catch(e){console.warn("[route-maps] Failed to clear route overrides from localStorage",e)}}let a9=null;function a8(){return a9||(a9=(aG="development"===window.spaEnv)?aQ().then(e=>{aZ=e}):Promise.resolve())}let a7=`${nJ}/attachment`;function oe(e,t){return n1(`${a7}/${e}`,{signal:t.signal})}function ot(e,t,r,n){return n1(or(e,t,n),{signal:r.signal})}function or(e,t,r){return r?`${a7}?patient=${e}&encounter=${r}`:`${a7}?patient=${e}&includeEncounterless=${t}`}async function on(e,t,r){let n=new FormData;return n.append("fileCaption",t.fileDescription),n.append("patient",e),r&&n.append("encounter",r),t.file?n.append("file",t.file,t.fileName):(n.append("file",new File([""],t.fileName),t.fileName),n.append("base64Content",t.base64Content)),n1(`${a7}`,{method:"POST",body:n})}function oa(e,t){return n1(`${a7}/${e}`,{method:"DELETE",signal:t.signal})}async function oo(e,t){return e?(await n1(`${nX}/Patient/${e}`,t)).data:null}function oi(e,t){let r=new CustomEvent(`openmrs:${e}`,{detail:t??void 0,cancelable:!0,bubbles:!0});return window.dispatchEvent(r)}function os(e,t){let r=e=>{t("detail"in e&&null!==e.detail?e.detail:void 0)};return window.addEventListener(`openmrs:${e}`,r),()=>{window.removeEventListener(`openmrs:${e}`,r)}}function ol(e){return{uuid:e.uuid,display:e.display}}function ou(e=null,t=null){let r=new URLSearchParams;e&&r.set("tag",e),t&&r.set("q",t);let n=r.toString();return n1(`${nJ}/location${n?"?"+n:""}`).then(e=>e.data.results.map(ol))}function oc(e){return{uuid:e.uuid,display:e.display,name:e.name}}let od=`${nJ}/visittype`;function of(e=od){return n1(e).then(e=>e.data.results.map(oc))}var om=((Z={}).NEWVISIT="startVisit",Z.EDITVISIT="editVisit",Z.LOADING="loadingVisit",Z),op=((Y={}).NOTSTARTED="notStarted",Y.ONGOING="ongoing",Y);let oh="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))",og=function(){try{return JSON.parse(sessionStorage.getItem("openmrs:visitStoreState")||"null")}catch(e){return null}}()||{patientUuid:null,manuallySetVisitUuid:null};function oy(){return H("visit",og)}function ov(e,t){oy().setState({patientUuid:e,manuallySetVisitUuid:t})}function ob(e,t){return n1(`${nJ}/visit`,{signal:t.signal,method:"POST",headers:{"Content-type":"application/json"},body:e})}function ow(e,t,r){return n1(`${nJ}/visit/${e}`,{signal:r.signal,method:"POST",headers:{"Content-type":"application/json"},body:t})}function oE(e,t,r){return n1(`${nJ}/visit?patient=${e}&v=${r??oh}`,{signal:t.signal,method:"GET",headers:{"Content-type":"application/json"}})}oy().subscribe(e=>{var t;t=e,sessionStorage.setItem("openmrs:visitStoreState",JSON.stringify(t))});class ox{static get version(){return"1.4.0"}static toString(){return"JavaScript Expression Parser (JSEP) v"+ox.version}static addUnaryOp(e){return ox.max_unop_len=Math.max(e.length,ox.max_unop_len),ox.unary_ops[e]=1,ox}static addBinaryOp(e,t,r){return ox.max_binop_len=Math.max(e.length,ox.max_binop_len),ox.binary_ops[e]=t,r?ox.right_associative.add(e):ox.right_associative.delete(e),ox}static addIdentifierChar(e){return ox.additional_identifier_chars.add(e),ox}static addLiteral(e,t){return ox.literals[e]=t,ox}static removeUnaryOp(e){return delete ox.unary_ops[e],e.length===ox.max_unop_len&&(ox.max_unop_len=ox.getMaxKeyLen(ox.unary_ops)),ox}static removeAllUnaryOps(){return ox.unary_ops={},ox.max_unop_len=0,ox}static removeIdentifierChar(e){return ox.additional_identifier_chars.delete(e),ox}static removeBinaryOp(e){return delete ox.binary_ops[e],e.length===ox.max_binop_len&&(ox.max_binop_len=ox.getMaxKeyLen(ox.binary_ops)),ox.right_associative.delete(e),ox}static removeAllBinaryOps(){return ox.binary_ops={},ox.max_binop_len=0,ox}static removeLiteral(e){return delete ox.literals[e],ox}static removeAllLiterals(){return ox.literals={},ox}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 ox(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 ox.binary_ops[e]||0}static isIdentifierStart(e){return e>=65&&e<=90||e>=97&&e<=122||e>=128&&!ox.binary_ops[String.fromCharCode(e)]||ox.additional_identifier_chars.has(String.fromCharCode(e))}static isIdentifierPart(e){return ox.isIdentifierStart(e)||ox.isDecimalDigit(e)}throwError(e){let t=Error(e+" at character "+this.index);throw t.index=this.index,t.description=e,t}runHook(e,t){if(ox.hooks[e]){let r={context:this,node:t};return ox.hooks.run(e,r),r.node}return t}searchHook(e){if(ox.hooks[e]){let t={context:this};return ox.hooks[e].find(function(e){return e.call(t.context,t),t.node}),t.node}}gobbleSpaces(){let e=this.code;for(;e===ox.SPACE_CODE||e===ox.TAB_CODE||e===ox.LF_CODE||e===ox.CR_CODE;)e=this.expr.charCodeAt(++this.index);this.runHook("gobble-spaces")}parse(){this.runHook("before-all");let e=this.gobbleExpressions(),t=1===e.length?e[0]:{type:ox.COMPOUND,body:e};return this.runHook("after-all",t)}gobbleExpressions(e){let t=[],r,n;for(;this.index<this.expr.length;)if((r=this.code)===ox.SEMCOL_CODE||r===ox.COMMA_CODE)this.index++;else if(n=this.gobbleExpression())t.push(n);else if(this.index<this.expr.length){if(r===e)break;this.throwError('Unexpected "'+this.char+'"')}return t}gobbleExpression(){let e=this.searchHook("gobble-expression")||this.gobbleBinaryExpression();return this.gobbleSpaces(),this.runHook("after-expression",e)}gobbleBinaryOp(){this.gobbleSpaces();let e=this.expr.substr(this.index,ox.max_binop_len),t=e.length;for(;t>0;){if(ox.binary_ops.hasOwnProperty(e)&&(!ox.isIdentifierStart(this.code)||this.index+e.length<this.expr.length&&!ox.isIdentifierPart(this.expr.charCodeAt(this.index+e.length))))return this.index+=t,e;e=e.substr(0,--t)}return!1}gobbleBinaryExpression(){let e,t,r,n,a,o,i,s,l;if(!(o=this.gobbleToken())||!(t=this.gobbleBinaryOp()))return o;for(a={value:t,prec:ox.binaryPrecedence(t),right_a:ox.right_associative.has(t)},(i=this.gobbleToken())||this.throwError("Expected expression after "+t),n=[o,a,i];t=this.gobbleBinaryOp();){if(0===(r=ox.binaryPrecedence(t))){this.index-=t.length;break}a={value:t,prec:r,right_a:ox.right_associative.has(t)},l=t;let s=e=>a.right_a&&e.right_a?r>e.prec:r<=e.prec;for(;n.length>2&&s(n[n.length-2]);)i=n.pop(),t=n.pop().value,o=n.pop(),e={type:ox.BINARY_EXP,operator:t,left:o,right:i},n.push(e);(e=this.gobbleToken())||this.throwError("Expected expression after "+l),n.push(a,e)}for(s=n.length-1,e=n[s];s>1;)e={type:ox.BINARY_EXP,operator:n[s-1].value,left:n[s-2],right:e},s-=2;return e}gobbleToken(){let e,t,r,n;if(this.gobbleSpaces(),n=this.searchHook("gobble-token"))return this.runHook("after-token",n);if(e=this.code,ox.isDecimalDigit(e)||e===ox.PERIOD_CODE)return this.gobbleNumericLiteral();if(e===ox.SQUOTE_CODE||e===ox.DQUOTE_CODE)n=this.gobbleStringLiteral();else if(e===ox.OBRACK_CODE)n=this.gobbleArray();else{for(r=(t=this.expr.substr(this.index,ox.max_unop_len)).length;r>0;){if(ox.unary_ops.hasOwnProperty(t)&&(!ox.isIdentifierStart(this.code)||this.index+t.length<this.expr.length&&!ox.isIdentifierPart(this.expr.charCodeAt(this.index+t.length)))){this.index+=r;let e=this.gobbleToken();return e||this.throwError("missing unaryOp argument"),this.runHook("after-token",{type:ox.UNARY_EXP,operator:t,argument:e,prefix:!0})}t=t.substr(0,--r)}ox.isIdentifierStart(e)?(n=this.gobbleIdentifier(),ox.literals.hasOwnProperty(n.name)?n={type:ox.LITERAL,value:ox.literals[n.name],raw:n.name}:n.name===ox.this_str&&(n={type:ox.THIS_EXP})):e===ox.OPAREN_CODE&&(n=this.gobbleGroup())}return n?(n=this.gobbleTokenProperty(n),this.runHook("after-token",n)):this.runHook("after-token",!1)}gobbleTokenProperty(e){this.gobbleSpaces();let t=this.code;for(;t===ox.PERIOD_CODE||t===ox.OBRACK_CODE||t===ox.OPAREN_CODE||t===ox.QUMARK_CODE;){let r;if(t===ox.QUMARK_CODE){if(this.expr.charCodeAt(this.index+1)!==ox.PERIOD_CODE)break;r=!0,this.index+=2,this.gobbleSpaces(),t=this.code}this.index++,t===ox.OBRACK_CODE?((e={type:ox.MEMBER_EXP,computed:!0,object:e,property:this.gobbleExpression()}).property||this.throwError('Unexpected "'+this.char+'"'),this.gobbleSpaces(),(t=this.code)!==ox.CBRACK_CODE&&this.throwError("Unclosed ["),this.index++):t===ox.OPAREN_CODE?e={type:ox.CALL_EXP,arguments:this.gobbleArguments(ox.CPAREN_CODE),callee:e}:(t===ox.PERIOD_CODE||r)&&(r&&this.index--,this.gobbleSpaces(),e={type:ox.MEMBER_EXP,computed:!1,object:e,property:this.gobbleIdentifier()}),r&&(e.optional=!0),this.gobbleSpaces(),t=this.code}return e}gobbleNumericLiteral(){let e="",t,r;for(;ox.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);if(this.code===ox.PERIOD_CODE)for(e+=this.expr.charAt(this.index++);ox.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);if("e"===(t=this.char)||"E"===t){for(e+=this.expr.charAt(this.index++),("+"===(t=this.char)||"-"===t)&&(e+=this.expr.charAt(this.index++));ox.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);ox.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+e+this.char+")")}return r=this.code,ox.isIdentifierStart(r)?this.throwError("Variable names cannot start with a number ("+e+this.char+")"):(r===ox.PERIOD_CODE||1===e.length&&e.charCodeAt(0)===ox.PERIOD_CODE)&&this.throwError("Unexpected period"),{type:ox.LITERAL,value:parseFloat(e),raw:e}}gobbleStringLiteral(){let e="",t=this.index,r=this.expr.charAt(this.index++),n=!1;for(;this.index<this.expr.length;){let t=this.expr.charAt(this.index++);if(t===r){n=!0;break}if("\\"===t)switch(t=this.expr.charAt(this.index++)){case"n":e+="\n";break;case"r":e+="\r";break;case"t":e+=" ";break;case"b":e+="\b";break;case"f":e+="\f";break;case"v":e+="\v";break;default:e+=t}else e+=t}return n||this.throwError('Unclosed quote after "'+e+'"'),{type:ox.LITERAL,value:e,raw:this.expr.substring(t,this.index)}}gobbleIdentifier(){let e=this.code,t=this.index;for(ox.isIdentifierStart(e)?this.index++:this.throwError("Unexpected "+this.char);this.index<this.expr.length;)if(e=this.code,ox.isIdentifierPart(e))this.index++;else break;return{type:ox.IDENTIFIER,name:this.expr.slice(t,this.index)}}gobbleArguments(e){let t=[],r=!1,n=0;for(;this.index<this.expr.length;){this.gobbleSpaces();let a=this.code;if(a===e){r=!0,this.index++,e===ox.CPAREN_CODE&&n&&n>=t.length&&this.throwError("Unexpected token "+String.fromCharCode(e));break}if(a===ox.COMMA_CODE){if(this.index++,++n!==t.length){if(e===ox.CPAREN_CODE)this.throwError("Unexpected token ,");else if(e===ox.CBRACK_CODE)for(let e=t.length;e<n;e++)t.push(null)}}else if(t.length!==n&&0!==n)this.throwError("Expected comma");else{let e=this.gobbleExpression();e&&e.type!==ox.COMPOUND||this.throwError("Expected comma"),t.push(e)}}return r||this.throwError("Expected "+String.fromCharCode(e)),t}gobbleGroup(){this.index++;let e=this.gobbleExpressions(ox.CPAREN_CODE);if(this.code===ox.CPAREN_CODE)return(this.index++,1===e.length)?e[0]:!!e.length&&{type:ox.SEQUENCE_EXP,expressions:e};this.throwError("Unclosed (")}gobbleArray(){return this.index++,{type:ox.ARRAY_EXP,elements:this.gobbleArguments(ox.CBRACK_CODE)}}}Object.assign(ox,{hooks:new class{add(e,t,r){if("string"!=typeof arguments[0])for(let e in arguments[0])this.add(e,arguments[0][e],arguments[1]);else(Array.isArray(e)?e:[e]).forEach(function(e){this[e]=this[e]||[],t&&this[e][r?"unshift":"push"](t)},this)}run(e,t){this[e]=this[e]||[],this[e].forEach(function(e){e.call(t&&t.context?t.context:t,t)})}},plugins:new class{constructor(e){this.jsep=e,this.registered={}}register(...e){e.forEach(e=>{if("object"!=typeof e||!e.name||!e.init)throw Error("Invalid JSEP plugin format");this.registered[e.name]||(e.init(this.jsep),this.registered[e.name]=e)})}}(ox),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"}),ox.max_unop_len=ox.getMaxKeyLen(ox.unary_ops),ox.max_binop_len=ox.getMaxKeyLen(ox.binary_ops);let oD=e=>new ox(e).parse(),oS=Object.getOwnPropertyNames(class{});Object.getOwnPropertyNames(ox).filter(e=>!oS.includes(e)&&void 0===oD[e]).forEach(e=>{oD[e]=ox[e]}),oD.Jsep=ox,oD.plugins.register({name:"ternary",init(e){e.hooks.add("after-expression",function(t){if(t.node&&this.code===e.QUMARK_CODE){this.index++;let r=t.node,n=this.gobbleExpression();if(n||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===e.COLON_CODE){this.index++;let a=this.gobbleExpression();if(a||this.throwError("Expected expression"),t.node={type:"ConditionalExpression",test:r,consequent:n,alternate:a},r.operator&&e.binary_ops[r.operator]<=.9){let n=r;for(;n.right.operator&&e.binary_ops[n.right.operator]<=.9;)n=n.right;t.node.test=n.right,n.right=t.node,t.node=r}}else this.throwError("Expected :")}})}});let o_="ArrowFunctionExpression",oC={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)}},ok={...oC,Promise};function oP(e,t={}){return oI(e,t,oj)}async function oR(e,t={}){return oM(e,t,oj)}function oO(e,t={}){return oI(e,t,oL)}function oT(e,t={}){return oM(e,t,oL)}function oN(e,t={}){return oI(e,t,oF)}function o$(e,t={}){return oM(e,t,oF)}function oI(e,t={},r){if("string"!=typeof e&&("object"!=typeof e||!e||!("type"in e)))throw`Unknown expression type ${e}. Expressions must either be a string or pre-compiled string.`;if("string"==typeof e&&0===e.trim().length)throw{type:"Empty expression",message:"Expression cannot be an empty string"};null==t&&(t={});let n=oH(t,oC),a=oB("string"==typeof e?oD(e):e,n);if(r(a))return a;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 oM(e,t={},r){if("string"!=typeof e&&("object"!=typeof e||!e||!("type"in e)))return Promise.reject(`Unknown expression type ${e}. Expressions must either be a string or pre-compiled string.`);if("string"==typeof e&&0===e.trim().length)throw{type:"Empty expression",message:"Expression cannot be an empty string"};null==t&&(t={});let n=oH(t,ok);return Promise.resolve(oB("string"==typeof e?oD(e):e,n)).then(t=>{if(r(t))return t;throw{type:"Invalid result",message:"string"==typeof e?`The expression ${e} did not produce a valid result`:"The expression did not produce a valid result"}})}function oA(e){return oD(e)}function oj(e){return"string"==typeof e||"number"==typeof e||"boolean"==typeof e||null==e||e instanceof Date}function oL(e){return"boolean"==typeof e}function oF(e){return"number"==typeof e}function oB(e,t){switch(e.type){case"UnaryExpression":var r,n,a,o,i,s,l,u,c,d,f,m,p,h=e,g=t;let y=oB(h.argument,g);switch(h.operator){case"+":return+y;case"-":return-y;case"~":return~y;case"!":return!y;default:throw`Expression evaluator does not support operator '${h.operator}''`}case"BinaryExpression":var v=e,b=t;switch(v.operator){case"&&":return oB(v.left,b)&&oB(v.right,b);case"||":return oB(v.left,b)||oB(v.right,b);case"??":return oB(v.left,b)??oB(v.right,b)}let w=oB(v.left,b),E=oB(v.right,b);switch(v.operator){case"+":return w+E;case"-":return w-E;case"*":return w*E;case"/":return w/E;case"%":return w%E;case"**":return w**E;case"==":return w==E;case"===":return w===E;case"!=":return w!=E;case"!==":return w!==E;case">":return w>E;case">=":return w>=E;case"<":return w<E;case"<=":return w<=E;case"in":return w in E;default:throw`Expression evaluator does not support operator '${v.operator}' operator`}case"ConditionalExpression":return r=e,n=t,oB(r.test,n)?oB(r.consequent,n):oB(r.alternate,n);case"CallExpression":return oG(oU(e,t));case"ArrowFunctionExpression":let x;return a=e,o=t,x=a.params?.map(e=>{if("Identifier"===e.type)return e.name;throw`Cannot handle parameter of type ${e.type}`})??[],(function(...e){if(e.length<x.length)throw`Required argument(s) ${x.slice(e.length,-1).join(", ")} were not provided`;let t=Object.fromEntries(x.reduce((t,r,n)=>{let a=e[n];return function e(t){if("string"==typeof t||"number"==typeof t||"boolean"==typeof t||"function"==typeof t||null===t||t instanceof RegExp)return!0;if("object"==typeof t){for(let r of Object.keys(t))if(!e(t[r]))return!1;return!0}if(Array.isArray(t)){for(let r of t)if(!e(r))break}return!1}(a)&&t.push([r,a]),t},[]));return oB(a.body,o.addVariables(t))}).bind(null);case"MemberExpression":return oG(oW(e,t));case"ArrayExpression":return i=e,s=t,i.elements?.map(oZ(s));case"SequenceExpression":let D;return l=e,u=t,(D=l.expressions.map(oZ(u)))[D.length-1];case"NewExpression":var S=e,_=t;if(S.callee&&"Identifier"===S.callee.type){let e=S.arguments?.map(oZ(_));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 e.value;case"Identifier":return c=e,d=t,(oY(c.name),d.variables&&Object.hasOwn(d.variables,c.name))?d.variables[c.name]:Object.hasOwn(d.globals,c.name)?d.globals[c.name]:void 0;case"TemplateLiteral":let C,k;return f=e,m=t,C=f.expressions?.map(oZ(m))??[],(k=f.quasis?.map(oZ(m))??[]).filter(e=>!e.tail).map(e=>e.value).join("")+C.join("")+k.filter(e=>e.tail).map(e=>e.value).join("");case"TemplateElement":return{value:(p=e).cooked,tail:p.tail};default:throw`Expression evaluator does not support expression of type '${e.type}'`}}function oV(e,t){switch(e.type){case"Literal":return e.value;case"Identifier":return e.name;case"MemberExpression":return oV(e.property,t);default:throw`VisitExpressionName does not support expression of type '${e.type}'`}}function oU(e,t){let r=oK(e.callee,t);if(r===oz||e.optional&&null==r)return oz;let n=e.arguments?.map(oZ(t));if(r){if("function"!=typeof r)throw`${oX(e.callee)} is not a function`}else throw`No function named ${oX(e.callee)} is defined in this context`;return r(...n)}function oW(e,t){let r=oK(e.object,t);if(r===oz||e.optional&&null==r)return oz;if(null===r)throw TypeError(`TypeError: cannot read properties of null (reading '${oJ(e.property,t)}')`);if(void 0===r)switch(e.object.type){case"Identifier":{let r=oV(e.object,t);throw ReferenceError(`ReferenceError: ${r} is not defined`)}case"MemberExpression":throw TypeError(`TypeError: cannot read properties of undefined (reading '${oJ(e.property,t)}')`);default:throw`VisitMemberExpression does not support operator '${e.object.type}' type`}if("object"!=typeof r&&"function"!=typeof r&&"string"!=typeof r&&"number"!=typeof r)throw`VisitMemberExpression does not support member access on type ${typeof r}`;let n=e.computed?function(e){if(void 0===e)throw{type:"Illegal property access",message:"No property was supplied to the property access"};if("string"!=typeof e&&"number"!=typeof e)throw{type:"Illegal property access",message:`Cannot use a value of type ${null===e?"null":typeof e} as a property name`};return e}(oB(e.property,t)):function(e){if("Identifier"!==e.type)throw`VisitMemberExpression does not support a property of type '${e.type}'`;return e.name}(e.property);oY(n),function(e,t){if(oq.has(String(t)))return;let r=Object(e);for(;null!==r;){if(Object.hasOwn(r,t)){if(r===Object.prototype||r===Function.prototype)throw{type:"Illegal property access",message:`Cannot access the ${t} property of objects`};return}r=Object.getPrototypeOf(r)}}(r,n);let a=r[n];return"function"==typeof a?a.bind(r):a}function oH(e,t){let r={variables:{...e},globals:{...t},addVariables(e){return this.variables={...this.variables,...e},this}};return r.addVariables.bind(r),r}oD.plugins.register({name:"arrow",init(e){e.addBinaryOp("=>",.1,!0),e.hooks.add("gobble-expression",function(t){if(this.gobbleSpaces(),this.code===e.OPAREN_CODE){let r=this.index;if(this.index++,this.gobbleSpaces(),this.code===e.CPAREN_CODE){this.index++;let e=this.gobbleBinaryOp();if("=>"===e){let r=this.gobbleBinaryExpression();r||this.throwError("Expected expression after "+e),t.node={type:o_,params:null,body:r};return}}this.index=r}}),e.hooks.add("after-expression",function(t){!function t(r){r&&(Object.values(r).forEach(e=>{e&&"object"==typeof e&&t(e)}),"=>"===r.operator&&(r.type=o_,r.params=r.left?[r.left]:null,r.body=r.right,r.params&&r.params[0].type===e.SEQUENCE_EXP&&(r.params=r.params[0].expressions),delete r.left,delete r.right,delete r.operator))}(t.node)})}}),oD.plugins.register({name:"new",init(e){e.addUnaryOp("new"),e.hooks.add("after-token",function(t){let r=t.node;if(r&&"new"===r.operator){r.argument&&[e.CALL_EXP,e.MEMBER_EXP].includes(r.argument.type)||this.throwError("Expected new function()"),t.node=r.argument;let n=t.node;for(;n.type===e.MEMBER_EXP||n.type===e.CALL_EXP&&n.callee.type===e.MEMBER_EXP;)n=n.type===e.MEMBER_EXP?n.object:n.callee.object;n.type="NewExpression"}})}}),oD.plugins.register({name:"numbers",init(e){function t(e){return"x"===e||"X"===e?(this.index+=2,[[48,57],[65,70],[97,102]]):"b"===e||"B"===e?(this.index+=2,[[48,49]]):"o"===e||"O"===e||e>="0"&&e<="7"?(this.index+=e<="7"?1:2,[[48,55]]):null}function r(t){let r=this.index,n="",a=()=>{for(;e.isDecimalDigit(this.code)||95===this.code;)95===this.code?this.index++:n+=this.expr.charAt(this.index++)};a(),this.code===e.PERIOD_CODE&&(n+=this.expr.charAt(this.index++),a());let o=this.char;("e"===o||"E"===o)&&(n+=this.expr.charAt(this.index++),("+"===(o=this.char)||"-"===o)&&(n+=this.expr.charAt(this.index++)),a(),e.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+n+this.char+")"));let i=this.code;if(e.isIdentifierStart(i))this.throwError("Variable names cannot start with a number ("+n+this.char+")");else if(i===e.PERIOD_CODE){n.length>1&&this.throwError(`Unexpected period ${JSON.stringify({chCode:i,number:n},null,2)}`),this.index=r;return}t.node={type:e.LITERAL,value:parseFloat(n),raw:this.expr.substring(r,this.index)}}e.hooks.add("gobble-token",function(n){if(48===this.code){var a,o,i;let s=this.index,l=this.expr.charAt(this.index+1),u=t.call(this,l);if(!u)return;let c="";for(;a=this.code,o=u,95===a||o.some(([e,t])=>a>=e&&a<=t);)95===this.code?this.index++:c+=this.expr.charAt(this.index++);if(e.isIdentifierPart(this.code)){if(e.isDecimalDigit(this.code)&&e.isDecimalDigit(l.charCodeAt(0))){this.index=s+1,r.call(this,n);return}this.throwError("unexpected char within number")}n.node={type:e.LITERAL,value:parseInt(c,"x"===(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)&&r.call(this,n)})}}),oD.plugins.register({name:"regex",init(e){e.hooks.add("gobble-token",function(t){if(47===this.code){let r=++this.index,n=!1;for(;this.index<this.expr.length;){if(47===this.code&&!n){let n,a=this.expr.slice(r,this.index),o="";for(;++this.index<this.expr.length;){let e=this.code;if(e>=97&&e<=122||e>=65&&e<=90||e>=48&&e<=57)o+=this.char;else break}try{n=new RegExp(a,o)}catch(e){this.throwError(e.message)}return t.node={type:e.LITERAL,value:n,raw:this.expr.slice(r-1,this.index)},t.node=this.gobbleTokenProperty(t.node),t.node}this.code===e.OBRACK_CODE?n=!0:n&&this.code===e.CBRACK_CODE&&(n=!1),this.index+=92===this.code?2:1}this.throwError("Unclosed Regex")}})}}),oD.plugins.register({name:"ternary",init(e){e.hooks.add("after-expression",function(t){if(t.node&&this.code===e.QUMARK_CODE){this.index++;let r=t.node,n=this.gobbleExpression();if(n||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===e.COLON_CODE){this.index++;let a=this.gobbleExpression();if(a||this.throwError("Expected expression"),t.node={type:"ConditionalExpression",test:r,consequent:n,alternate:a},r.operator&&e.binary_ops[r.operator]<=.9){let n=r;for(;n.right.operator&&e.binary_ops[n.right.operator]<=.9;)n=n.right;t.node.test=n.right,n.right=t.node,t.node=r}}else this.throwError("Expected :")}})}}),oD.plugins.register({name:"jsepTemplateLiteral",init(e){function t(e,r=!0){if(96===this.code){let t={type:"TemplateLiteral",quasis:[],expressions:[]},n="",a="",o=!1,i=this.expr.length,s=()=>t.quasis.push({type:"TemplateElement",value:{raw:a,cooked:n},tail:o});for(;this.index<i;){let i=this.expr.charAt(++this.index);if("`"===i)return this.index+=1,o=!0,s(),e.node=t,r&&(e.node=this.gobbleTokenProperty(e.node)),e.node;if("$"===i&&"{"===this.expr.charAt(this.index+1))this.index+=2,s(),a="",n="",t.expressions.push(...this.gobbleExpressions(125)),125!==this.code&&this.throwError("unclosed ${");else if("\\"===i)switch(a+=i,i=this.expr.charAt(++this.index),a+=i,i){case"n":n+="\n";break;case"r":n+="\r";break;case"t":n+=" ";break;case"b":n+="\b";break;case"f":n+="\f";break;case"v":n+="\v";break;default:n+=i}else n+=i,a+=i}this.throwError("Unclosed `")}}e.hooks.add("gobble-token",t),e.hooks.add("after-token",function(r){if((r.node.type===e.IDENTIFIER||r.node.type===e.MEMBER_EXP)&&96===this.code)return r.node={type:"TaggedTemplateExpression",tag:r.node,quasi:t.bind(this)(r,!1)},r.node=this.gobbleTokenProperty(r.node),r.node})}}),oD.addBinaryOp("in",7),oD.addBinaryOp("??",1);let oz=Symbol("optional chain short-circuited");function oK(e,t){switch(e.type){case"MemberExpression":return oW(e,t);case"CallExpression":return oU(e,t);default:return oB(e,t)}}function oG(e){return e===oz?void 0:e}function oZ(e){return function(t){return null===t?null:oB(t,e)}}function oY(e){if("__proto__"===e||"prototype"===e||"constructor"===e)throw{type:"Illegal property access",message:`Cannot access the ${e} property of objects`}}let oq=new Set(["toString","valueOf","hasOwnProperty"]);function oJ(e,t){try{return oV(e,t)}catch{return"<computed>"}}function oX(e){return e?"MemberExpression"===e.type?e.property?.name:e.name:null}function oQ(e){if("string"!=typeof e&&("object"!=typeof e||!e||!("type"in e)))throw`Unknown expression type ${e}. Expressions must either be a string or pre-compiled string.`;let t={globals:{...ok},boundNames:new Set,variables:new Set};return o0("string"==typeof e?oD(e):e,t),[...t.variables]}function o0(e,t){switch(e.type){case"UnaryExpression":return r=e,n=t,void o0(r.argument,n);case"BinaryExpression":return a=e,o=t,void(o0(a.left,o),o0(a.right,o));case"ConditionalExpression":return i=e,s=t,void(o0(i.consequent,s),o0(i.test,s),o0(i.alternate,s));case"CallExpression":return l=e,u=t,void(o0(l.callee,u),l.arguments?.map(o1(u)));case"ArrowFunctionExpression":var r,n,a,o,i,s,l,u,c,d,f,m,p,h,g,y,v,b,w,E,x=e,D=t;let S=new Set(D.boundNames);for(let e of x.params??[])e?.type==="Identifier"&&S.add(e.name);o0(x.body,{...D,boundNames:S});return;case"MemberExpression":return c=e,d=t,void(o0(c.object,d),c.computed&&o0(c.property,d));case"ArrayExpression":return f=e,m=t,void f.elements?.map(o1(m));case"SequenceExpression":return p=e,h=t,void p.expressions?.map(o1(h));case"NewExpression":return g=e,y=t,void g.arguments?.map(o1(y));case"Literal":case"TemplateElement":return;case"Identifier":return v=e,b=t,void(v.name in b.globals||b.boundNames.has(v.name)||b.variables.add(v.name));case"TemplateLiteral":return w=e,E=t,void(w.expressions?.map(o1(E)),w.quasis?.map(o1(E)));default:throw`Expression evaluator does not support expression of type '${e.type}'`}}function o1(e){return function(t){return null===t?null:o0(t,e)}}let o2=H("feature-flags",{flags:function(){let e={};for(let t of Object.keys(localStorage))if(t.startsWith("openmrs:feature-flag:")){let r=t.replace("openmrs:feature-flag:",""),n=JSON.parse(localStorage.getItem(`openmrs:feature-flag-meta:${r}`)||"{}");e[r]={enabled:"true"===localStorage.getItem(t),...n}}return e}()});function o4(e,t,r){o2.setState(n=>({flags:{...n.flags,[e]:{enabled:n.flags[e]?.enabled??!1,label:t,description:r}}}))}function o3(){let e=o2.getState().flags;Object.keys(localStorage).filter(e=>e.startsWith("openmrs:feature-flag:")).forEach(t=>{let r=t.replace("openmrs:feature-flag:","");e[r]||(localStorage.removeItem(t),localStorage.removeItem(`openmrs:feature-flag-meta:${r}`))})}function o6(e){return o2.getState().flags[e].enabled}function o5(e,t){o2.subscribe(r=>{t(r.flags[e].enabled)})}function o9(e,t){o2.setState(r=>({flags:{...r.flags,[e]:{...r.flags[e],enabled:t}}}))}o2.subscribe(e=>{for(let[t,r]of Object.entries(e.flags))localStorage.setItem(`openmrs:feature-flag:${t}`,r.enabled.toString()),localStorage.setItem(`openmrs:feature-flag-meta:${t}`,JSON.stringify({label:r.label,description:r.description}))});let o8=V("extensionsInternal",{slots:{},extensions:{}}),o7=V("extensionRenderings",{renderings:new Map}),ie=()=>H("extensionsInternal",{slots:{},extensions:{}}),it=()=>H("extensionRenderings",{renderings:new Map});function ir(e){let t=o8.getState(),r=e(t);r!==t&&o8.setState(r)}let ia=null,io=null;function ii(){let e=o7.getState();return ia&&e===io||(ia=new Map(e.renderings),io=e,function(e){for(let t of(iy.clear(),e.values()))ib(t,1);iv=!0}(ia)),ia}function is(e){io={renderings:e},o7.setState(io,!0)}function il(e){let t=ii();t.has(e.renderingId)||(t.set(e.renderingId,e),ib(e,1),is(t))}function iu(e){let t=ii(),r=t.get(e);r&&(t.delete(e),ib(r,-1),is(t))}let ic=()=>H("extensions",{slots:{}}),id=0,im=new Set;function ip(e){id++;try{return e()}finally{if(0==--id&&im.size>0){let e=Array.from(im);for(let t of(im.clear(),e))ih(t)}}}function ih(e){try{e()}catch(t){console.error(`The extension system's '${e.name}' recomputation failed`,t)}}function ig(e){id>0?im.add(e):ih(e)}let iy=new Map,iv=!1;function ib(e,t){let r=JSON.stringify([e.slotName,e.extensionId,e.slotModuleName,e.extensionModuleName]),n=iy.get(r);if(!n){if(t<0)return;iy.set(r,{count:1,record:{slotModuleName:e.slotModuleName,extensionModuleName:e.extensionModuleName,slotName:e.slotName,extensionId:e.extensionId}}),iv=!0;return}n.count+=t,n.count<1&&(iy.delete(r),iv=!0)}function iw(){var e,t;if(ii(),!iv)return;iv=!1;let r=Array.from(iy.values(),({record:e})=>e);r.sort(iE),e=eu.getState().mountedExtensions,t=r,e.length===t.length&&e.every((e,r)=>0===iE(e,t[r]))||eu.setState({mountedExtensions:r})}function iE(e,t){return ix(e.slotName,t.slotName)||ix(e.extensionId,t.extensionId)||ix(e.slotModuleName,t.slotModuleName)||ix(e.extensionModuleName,t.extensionModuleName)}function ix(e,t){return e===t?0:e<t?-1:1}iw(),o7.subscribe(()=>ig(iw));let iD=ie(),iS=ic(),i_=ed(),iC=ep(),ik=new Set,iP=!1;function iR(e){if(null===e)ik=null;else if(null!==ik)for(let t of e)ik.add(t);ig(iO)}function iO(){if(!iP){iP=!0;try{for(let e=1;;e++){let t=ik;if(null!==t&&0===t.size)return;ik=new Set;try{!function(e,t,r,n,a,o=null){let i=iS.getState().slots,s={},l=!1,u=Object.entries(n.flags).filter(([,{enabled:e}])=>e).map(([e])=>e);for(let[n,c]of Object.entries(e.slots)){let d=i[n];if(d&&o&&!o.has(n)){s[n]=d;continue}let{config:f}=em(t,c.name),m=function(e,t,r,n,a,o){let i=function(e,t){let r=e.add||[],n=e.remove||[],a=e.order||[],{extensions:o}=iD.getState(),i=new Set(n),s=[...t,...r].filter(e=>!i.has(e)),l=iB(a),u=iB(t),c=new Map(s.map(e=>[e,function(e,t,r,n){let a=t.get(e);if(void 0!==a)return a;{if(void 0!==r)return 1e3+r;let t=n.get(e);return void 0!==t?2e3+t:3e3}}(e,l,o[i$(e)]?.order,u)]));return s.sort((e,t)=>c.get(e)-c.get(t))}(r,t.slots[e].attachedIds),s=[];for(let l of i){let{config:i}=eh(n,e,l),u=eg(r,e,l),c=u?(0,X.merge)({},i,u):i,d=i$(l),f=t.extensions[d];if(f){let e=c?.["Display conditions"]?.privileges??f.privileges??[];if(e&&("string"==typeof e||Array.isArray(e)&&e.length>0)&&(!o?.user||!ar(e,o.user))||f.featureFlag&&!a.includes(f.featureFlag))continue;s.push({id:l,name:d,moduleName:f.moduleName,config:c,featureFlag:f.featureFlag,meta:f.meta,displayConditionExpression:c?.["Display conditions"]?.expression||f.displayExpression})}}return s}(n,e,f,r,u,a.session);d&&d.moduleName===c.moduleName&&(0,X.isEqual)(d.candidateExtensions,m)?s[n]=d:(s[n]={moduleName:c.moduleName,candidateExtensions:m},l=!0)}(l||Object.keys(i).length!==Object.keys(s).length)&&iS.setState({slots:s})}(iD.getState(),i_.getState(),iC.getState(),o2.getState(),n4.getState(),t)}catch(e){throw ik=null===t||null===ik?null:new Set([...t,...ik]),e}if(e>=20)return void console.error("The extension system stopped recomputing after 20 passes because something keeps invalidating slots in response to the extension store being written. Some slots are left stale until the next write.")}}finally{iP=!1}}}function iT(e,t){let r=new Set;for(let n of Object.keys(e))e[n]!==t[n]&&r.add(n);for(let n of Object.keys(t))n in e||r.add(n);return r}function iN(e,t){return{moduleName:t,name:e,attachedIds:[]}}function i$(e){let[t]=e.split("#");return t}function iI(e,t){let r=i$(t);return e.extensions[r]}function iM(e){return iI(iD.getState(),e)}iD.subscribe((e,t)=>{iR(e.extensions!==t.extensions?null:iT(e.slots,t.slots))}),i_.subscribe((e,t)=>{iR(iT(e.slots,t.slots))}),iC.subscribe((e,t)=>{iR(iT(e.configs,t.configs))}),o2.subscribe(()=>iR(null)),n4.subscribe(()=>iR(null)),iR(null);let iA=e=>ir(t=>({...t,extensions:{...t.extensions,[e.name]:{...e}}}));function ij(e,t){ir(r=>{let n=r.slots[e];return n?{...r,slots:{...r.slots,[e]:{...n,attachedIds:[...n.attachedIds,t]}}}:{...r,slots:{...r.slots,[e]:{...iN(e),attachedIds:[t]}}}})}function iL(e,t){ir(r=>{let n=r.slots[e];return n&&n.attachedIds.includes(t)?{...r,slots:{...r.slots,[e]:{...n,attachedIds:n.attachedIds.filter(e=>e!==t)}}}:r})}function iF(e){ir(t=>{let r=t.slots[e];return r?{...t,slots:{...t.slots,[e]:{...r,attachedIds:[]}}}:t})}function iB(e){let t=new Map;return e.forEach((e,r)=>{t.has(e)||t.set(e,r)}),t}function iV(e,t){return function(e,t,r=null,n){let a;return e.filter(e=>{let o=e.displayConditionExpression;if("string"!=typeof o||0===o.trim().length)return!0;a??(a=t&&"object"==typeof t?{session:r,...t}:{session:r});try{return!!oO(o,a)}catch(t){return console.error(`Error while evaluating expression '${o}' for ${e.id}`+(n?` in ${n}`:""),t),!1}})}(iU(e),t,n4.getState().session,e)}function iU(e){return iS.getState().slots[e]?.candidateExtensions??[]}let iW=(e,t)=>iD.setState(r=>{let n=r.slots[t]?.moduleName;if(n&&n!=e)return console.warn(`An extension slot with the name '${t}' already exists. Refusing to register the same slot name twice (in "registerExtensionSlot"). The existing one is from module ${n}.`),r;if(n&&n==e)return r;if(r.slots[t])return{...r,slots:{...r.slots,[t]:{...r.slots[t],moduleName:e}}};let a=iN(t,e);return{...r,slots:{...r.slots,[t]:{...a}}}}),iH=()=>{ik=null,ir(()=>({slots:{},extensions:{}})),it().setState({renderings:new Map}),iS.setState({slots:{}})},iz=V("left-nav",{slotName:null,basePath:window.spaBase,mode:"normal"});function iK({name:e,basePath:t,mode:r,componentContext:n,state:a}){iz.setState({slotName:e,basePath:t,mode:r??"normal",componentContext:n,state:a})}function iG(e){iz.getState().slotName===e&&iz.setState(iz.getInitialState(),!0)}let iZ=V("modalRegistry",{modals:{}});function iY(e){iZ.setState(t=>(t.modals[e.name]=e,t))}function iq(e){let t=iZ.getState().modals[e];if(!t){let r=iM(e);r&&(t={name:e,load:r.load,moduleName:r.moduleName},console.warn(`Modal ${e} was registered as an extension. This is deprecated and will be removed in the future. Please register it in the "modals" section of routes.json instead of the "extensions" section.`),iY(t))}return t}let iJ=V("workspace2",{registeredGroupsByName:{},registeredWindowsByName:{},registeredWorkspacesByName:{},openedGroup:null,openedWindows:[],isMostRecentlyOpenedWindowHidden:!1});function iX(e){let{registeredWorkspacesByName:t,registeredWindowsByName:r}=iJ.getState(),n=t[e];if(n){let t=r[n.window];if(t)return t;throw Error(`No workspace window found with name: ${n.window} for workspace: ${e}`)}throw Error(`No workspace found with name: ${e}`)}function iQ(e){let{registeredGroupsByName:t,registeredWindowsByName:r}=iJ.getState(),n=r[e];if(n){let r=t[n.group];if(r)return r;throw Error(`No workspace group found with name: ${n.group} for window: ${e}`)}throw Error(`No workspace window found with name: ${e}`)}function i0(e){let{openedWindows:t}=iJ.getState();return t.findIndex(t=>t.openedWorkspaces.find(t=>t.workspaceName===e))}function i1(e,t){if(0==t.length)return;let{registeredGroupsByName:r}=iJ.getState(),n={...r};for(let r of t){if(n[r.name])throw Error(`Cannot register workspace group ${r.name} more than once`);n[r.name]={...r,moduleName:e}}iJ.setState({registeredGroupsByName:n})}function i2(e,t){if(0==t.length)return;let{registeredWindowsByName:r}=iJ.getState(),n={...r};for(let r of t){if(n[r.name])throw Error(`Cannot register workspace window ${r.name} more than once`);let t={...r,moduleName:e};n[r.name]=t}iJ.setState({registeredWindowsByName:n})}function i4(e,t){if(0==t.length)return;let{registeredWorkspacesByName:r}=iJ.getState(),n={...r};for(let r of t){if(n[r.name])throw Error(`Cannot register workspace ${r.name} more than once`);let t={...r,moduleName:e};n[r.name]=t}iJ.setState({registeredWorkspacesByName:n})}let i3=0,i6=null,i5={bootstrap:15e3,mount:15e3,unmount:15e3};function i9(e,t){if(e.timeouts)return e;let r=e.name??"parcel",n=Object.fromEntries(Object.keys(i5).filter(t=>e[t]).map(n=>{var a,o;let i,s;return[n,(a=e[n],o=i5[n],i=Array.isArray(a)?a:[a],s=e=>i.reduce((t,a,o)=>t.then(()=>{let t=a(e);return"function"==typeof t?.then&&"function"==typeof t?.catch?t:Promise.reject(Error(`Lifecycle function ${n} at array index ${o} for parcel ${r} did not return a promise`))}),Promise.resolve(void 0)),e=>{let a,i=new Promise((e,t)=>{a=setTimeout(()=>t(Error(`Lifecycle function ${n} for parcel ${r} did not settle within ${o}ms`)),o)});return Promise.race([s(e),i]).finally(()=>clearTimeout(a)).then(e=>(t(n,!1),e),e=>{throw t(n,!0),e})})]}));return{...e,...n}}async function i8(e,t){var r,n;let a,o,i,s,l,u=await (i6??(i6=new Promise((e,t)=>{t0({name:"openmrs-extension-host",bootstrap:()=>Promise.resolve(),mount:t=>(e(t.mountParcel),Promise.resolve()),unmount:()=>Promise.resolve()},{domElement:document.createElement("div")}).mountPromise.catch(t)}).catch(e=>(console.error("The host parcel used to mount extensions could not be mounted. Falling back to mounting extensions as root parcels, which leaks their DOM elements.",e),t0))),i6),c={...t},d=(a=c,o=!1,{retarget:e=>a={...e},release:i=()=>(function(e){for(let t of Object.keys(e))delete e[t]})(a),onSettled(e,t){switch(e){case"bootstrap":t&&i();return;case"mount":o||(o=t);return;case"unmount":(t||o)&&i();return}}});return n=u((r=d.onSettled,"function"==typeof e?()=>e().then(e=>i9(e,r)):i9(e,r)),c),s=e=>t=>e.call(n,d.retarget(t)).catch(e=>{throw"SKIP_BECAUSE_BROKEN"===n.getStatus()&&d.release(),e}),l=n.update&&s(n.update),Object.defineProperty(n,"update",{configurable:!0,enumerable:!0,get:()=>l,set:e=>{l=e&&s(e)}})}function i7(){return se}function se(e,t){let r,n=i8(e,t).then(e=>r=e);return{mount:()=>n.then(e=>e.mount()),unmount:()=>n.then(e=>e.unmount()),update:e=>n.then(t=>t.update?.(e)),getStatus:()=>r?.getStatus()??"LOADING_SOURCE_CODE",get loadPromise(){return n.then(e=>e.loadPromise)},get bootstrapPromise(){return n.then(e=>e.bootstrapPromise)},get mountPromise(){return n.then(e=>e.mountPromise)},get unmountPromise(){return n.then(e=>e.unmountPromise)}}}async function st(e,t,r,n,a=e=>e,o={}){let i=i$(n),s=iM(n),l=null;if(e){let u;if(!s)throw Error(`Couldn't find extension '${i}' to attach to '${t}'`);let{meta:c,moduleName:d,load:f}=s,m=i3++,p=`${t}/${n}-${m}`;e.dataset.extensionRenderingId=p;let h=e=>{try{iu(p)}catch(t){console.error(e,t)}};try{il({renderingId:p,extensionName:i,extensionModuleName:d,extensionId:n,slotName:t,slotModuleName:r})}catch(e){throw h(`Recomputing configuration after registering '${n}' failed also failed`),e}try{u=await f()}catch(e){throw h(`Recomputing configuration after '${n}' failed to load also failed`),e}try{l=await i8(a({...u,name:`${t}/${i}-${m}`}),{...o,_meta:c,_extensionContext:{extensionId:n,extensionSlotName:t,extensionSlotModuleName:r,extensionModuleName:d,extensionMeta:c},domElement:e})}catch(e){throw h(`Recomputing configuration after '${n}' failed to mount also failed`),e}l.mountPromise.then(void 0,e=>{console.error(`Extension '${n}' in slot '${t}' failed to mount`,e),h(`Recomputing configuration after '${n}' failed to mount also failed`)}),l.unmountPromise.then(()=>h(`Recomputing configuration after unmounting '${n}' failed`),e=>{console.error(`Extension '${n}' in slot '${t}' failed to unmount`,e),h(`Recomputing configuration after '${n}' failed to unmount also failed`)})}else console.warn(`Tried to render ${n} into ${t} but no DOM element was available.`);return l}var sr=r(7979),sn=r.n(sr);let sa=(0,sr.createContext)({moduleName:"",featureName:""});function so({to:e,templateParams:t,onBeforeNavigate:r,children:n,...a}){return(0,sr.useEffect)(()=>{a.href&&console.warn(`ConfigurableLink does not support the href prop. Use the 'to' prop instead. The provided href value is '${a.href}'`),a.onClick&&console.warn(`ConfigurableLink does not support the onClick prop. Use the 'onBeforeNavigate' prop instead. The 'to' prop of the offending link is ${e}`)},[]),sn().createElement("a",{onClick:n=>{0===n.button&&!n.ctrlKey&&!n.shiftKey&&!n.altKey&&!n.metaKey&&(n.preventDefault(),r?.(n),nV({to:e,templateParams:t})),0===n.button&&(n.ctrlKey||n.metaKey)&&r?.(n),0===n.button&&n.shiftKey&&r?.(n),1===n.button&&r?.(n)},href:nF(e,t),...a},n)}let si=({state:e,children:t,...r})=>{let{extension:n}=(0,sr.useContext)(sa),a=(0,sr.useRef)(null),o=(0,sr.useRef)(Promise.resolve()),i=(0,sr.useRef)(!1),s=(0,sr.useRef)(!1),l=(0,sr.useRef)(e),u=(0,sr.useCallback)(e=>{if(!e)return;let t=()=>{"MOUNTED"===e.getStatus()&&e.unmount()};switch(e.getStatus()){case"MOUNTED":e.unmount();break;case"UPDATING":o.current?.then(t,t);break;default:e.mountPromise.then(t,()=>{})}},[]),c=(0,sr.useCallback)((e,t)=>{e.update&&"UNMOUNTING"!==e.getStatus()&&(o.current=Promise.all([e.mountPromise,o.current]).then(()=>{if(a.current?.getStatus()==="MOUNTED"&&a.current.update)return a.current.update({...t})}).catch(e=>{let t=a.current?.getStatus();"UNMOUNTING"!==t&&"NOT_MOUNTED"!==t&&"UNLOADING"!==t&&console.error(`The extension '${n?.extensionId}' failed to update`,e)}))},[]),d=(0,sr.useCallback)(t=>{t&&!a.current&&!s.current&&n?.extensionSlotName&&n.extensionSlotModuleName&&(s.current=!0,st(t,n.extensionSlotName,n.extensionSlotModuleName,n.extensionId,void 0,e).then(t=>{(s.current=!1,a.current=t,i.current)?u(t):t&&l.current!==e&&c(t,l.current)},()=>{s.current=!1}))},[]);return(0,sr.useEffect)(()=>(i.current=!1,()=>{i.current=!0,u(a.current)}),[]),(0,sr.useEffect)(()=>{l.current=e,a.current&&c(a.current,e)},[e]),n?sn().createElement("div",{ref:d,"data-extension-id":n?.extensionId,style:{position:"relative"},...r}):null};function ss(e){let t=(0,sr.useRef)(e);return T(t.current,e)||(t.current=e),t.current}function sl(e,t){"function"==typeof t&&(t=t(e));let r={};for(let[n,a]of Object.entries(t)){let t=function(...t){e.setState(e=>a(e,...t))};r[n]=t}return r}let su=e=>e;function sc(e,t=su,r){let n=(0,sr.useCallback)(t=>e.subscribe(t),[e]),a=(0,sr.useCallback)(()=>t(e.getState()),[e,t]),o=(0,sr.useSyncExternalStore)(n,a,a),i=(0,sr.useMemo)(()=>r?sl(e,r):null,[e,r]);return(0,sr.useMemo)(()=>i?{...o,...i}:o,[o,i])}function sd(e,t){return sc(e,su,t)}function sf(e){return function(t){let r=(0,sr.useCallback)(t=>e.subscribe(t),[]),n=(0,sr.useCallback)(()=>e.getState(),[]),a=(0,sr.useSyncExternalStore)(r,n,n),o=(0,sr.useMemo)(()=>t?sl(e,t):null,[t]);return(0,sr.useMemo)(()=>o?{...a,...o}:a,[a,o])}}let sm=[];Object.freeze(sm);let sp={candidateExtensions:sm};Object.freeze(sp);let sh=e=>{let t=(0,sr.useCallback)(t=>t.slots?.[e]??sp,[e]);return sc(ic(),t)},sg=e=>e.session;function sy(e,t){let{candidateExtensions:r}=sh(e),n=sc(n4,sg),a=ss(t);return(0,sr.useMemo)(()=>iV(e,a),[e,a,n,r])}function sv(e,t){let{moduleName:r}=(0,sr.useContext)(sa);if(!r)throw Error("ComponentContext has not been provided. This should come from @openmrs/esm-react-utils.");return(0,sr.useEffect)(()=>{iW(r,e)},[r,e]),{extensions:sy(e,t),extensionSlotName:e,extensionSlotModuleName:r}}function sb(e){return e}function sw({name:e,extensionSlotName:t,select:r=sb,children:n,state:a,style:o,...i}){if(n&&a)throw Error("Both children and state have been provided. If children are provided, the state must be passed as a prop to the `Extension` component.");let s=e??t,l=(0,sr.useRef)(null),{extensions:u,extensionSlotModuleName:c}=sv(s,a),d=(0,sr.useMemo)(()=>r(u),[r,u]),f=(0,sr.useMemo)(()=>{if("function"==typeof n&&!sn().isValidElement(n))return d.map(e=>n(e,a))},[n,d]);return sn().createElement("div",{ref:l,"data-extension-slot-name":s,"data-extension-slot-module-name":c,style:{...o,position:"relative"},...i},s&&d?.map((e,t)=>sn().createElement(sa.Provider,{key:e.id,value:{moduleName:c,featureName:"",extension:{extensionId:e.id,extensionSlotName:s,extensionSlotModuleName:c,extensionMeta:e.meta}}},f?.[t]??("function"!=typeof n?n:null)??sn().createElement(si,{state:a}))))}var sE=r(5338);function sx(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function sD(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?sx(Object(r),!0).forEach(function(t){var n,a,o;n=e,a=t,o=r[t],a in n?Object.defineProperty(n,a,{value:o,enumerable:!0,configurable:!0,writable:!0}):n[a]=o}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):sx(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function sS(e){return(sS="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 s_(e){return(s_="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 sC(e,t){var r;if("function"!=typeof(r=t.domElement?function(){return t.domElement}:t.domElementGetter?t.domElementGetter:e.domElementGetter?e.domElementGetter:function(e){var t=e.appName||e.name;if(!t)throw Error("single-spa's dom-element-getter-helpers was not given an application name as a prop, so it can't make a unique dom element container for the react application");var r="single-spa-application:".concat(t);return function(){var e=document.getElementById(r);return e||((e=document.createElement("div")).id=r,document.body.appendChild(e)),e}}(t)))throw Error("single-spa's dom-element-getter-helpers was given an invalid domElementGetter for application or parcel '".concat(t.name,"'. Expected a function, received ").concat(s_(r)));return function(){var e=r(t);if(!(e instanceof HTMLElement))throw Error("single-spa's dom-element-getter-helpers: domElementGetter returned an invalid dom element for application or parcel '".concat(t.name,"'. Expected HTMLElement, received ").concat(s_(e)));return e}}var sk=null;try{sk=require("react").createContext()}catch(e){}var sP={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 sR(e,t){return e.rootComponent?Promise.resolve():e.loadRootComponent(t).then(function(t){e.rootComponent=t})}function sO(e,t){return new Promise(function(r,n){e.suppressComponentDidCatchWarning||!function(e){if(!(e&&"string"==typeof e.version&&e.version.indexOf(".")>=0))return!1;var t=e.version.slice(0,e.version.indexOf("."));try{return Number(t)>=16}catch(e){return!1}}(e.React)||e.errorBoundary||e.errorBoundaryClass||(e.rootComponent.prototype?e.rootComponent.prototype.componentDidCatch||console.warn("single-spa-react: ".concat(t.name||t.appName||t.childAppName,"'s rootComponent should implement componentDidCatch to avoid accidentally unmounting the entire single-spa application.")):console.warn("single-spa-react: ".concat(t.name||t.appName||t.childAppName,"'s rootComponent does not implement an error boundary. If using a functional component, consider providing an opts.errorBoundary to singleSpaReact(opts).")));var a,o=sI(e,t,function(){r(this)}),i=sC(e,t)(),s=function(e){var t=e.reactDom,r=e.renderType,n=e.elementToRender,a=e.domElement,o=t[r];if("function"!=typeof o)throw Error('renderType "'.concat(r,'" did not return a function.'));switch(r){case"createRoot":case"unstable_createRoot":case"createBlockingRoot":case"unstable_createBlockingRoot":var i=o(a);return i.render(n),i;case"hydrateRoot":return o(a,n);default:return o(n,a),null}}({elementToRender:o,domElement:i,reactDom:s$(e),renderType:"function"==typeof(a=e).renderType?a.renderType():a.renderType});e.domElements[t.name]=i,e.renderResults[t.name]=s})}function sT(e,t){return new Promise(function(r){e.unmountResolves[t.name]=r;var n=e.renderResults[t.name];n&&n.unmount?n.unmount():s$(e).unmountComponentAtNode(e.domElements[t.name]),delete e.domElements[t.name],delete e.renderResults[t.name]})}function sN(e,t){return new Promise(function(r){e.updateResolves[t.name]||(e.updateResolves[t.name]=[]),e.updateResolves[t.name].push(r);var n=sI(e,t,null),a=e.renderResults[t.name];if(a&&a.render)a.render(n);else{var o=sC(e,t)();s$(e).render(n,o)}})}function s$(e){return e.ReactDOMClient||e.ReactDOM}function sI(e,t,r){var n=e.React.createElement(e.rootComponent,t),a=sk?e.React.createElement(sk.Provider,{value:t},n):n;return(e.errorBoundary||t.errorBoundary||e.errorBoundaryClass||t.errorBoundaryClass)&&(e.errorBoundaryClass=e.errorBoundaryClass||t.errorBoundaryClass||function(e,t){function r(t){e.React.Component.apply(this,arguments),this.state={caughtError:null,caughtErrorInfo:null},r.displayName="SingleSpaReactErrorBoundary(".concat(t.name,")")}return r.prototype=Object.create(e.React.Component.prototype),r.prototype.render=function(){return this.state.caughtError?(e.errorBoundary||t.errorBoundary)(this.state.caughtError,this.state.caughtErrorInfo,this.props):this.props.children},r.prototype.componentDidCatch=function(e,t){this.setState({caughtError:e,caughtErrorInfo:t})},r}(e,t),a=e.React.createElement(e.errorBoundaryClass,t,a)),a=e.React.createElement(e.SingleSpaRoot,sD(sD({},t),{},{mountFinished:r,updateFinished:function(){e.updateResolves[t.name]&&(e.updateResolves[t.name].forEach(function(e){return e()}),delete e.updateResolves[t.name])},unmountFinished:function(){e.unmountResolves[t.name]&&(e.unmountResolves[t.name](),delete e.unmountResolves[t.name])}}),a)}var sM=r(3826),sA=r(1943),sj=r.n(sA),sL=r(7956);let sF={strictMode:!0,throwErrorsToConsole:!0,disableTranslations:!1},sB=new Map;(0,sL.initCache)(sB);let sV={errorRetryCount:3,fetcher:n1,focusThrottleInterval:18e5,revalidateIfStale:!0,revalidateOnFocus:!1,revalidateOnReconnect:!1,refreshInterval:0,shouldRetryOnError:e=>{if(e instanceof n2){let t=e.response.status;return!!(t>=500)||401===t||403===t||429===t}return!0},provider:()=>sB};function sU(e){if("object"!=typeof e||"string"!=typeof e.featureName||"string"!=typeof e.moduleName)throw Error("Invalid options");let t=Object.assign({},sF,e),r={...sV,...t.swrConfig};return function(e){var n,a,o,i,s;return o=a=class extends(n=sn().Component){componentDidCatch(e,r){r&&r.componentStack&&(e.extra=Object.assign(e.extra||{},{componentStack:r.componentStack})),t.throwErrorsToConsole&&setTimeout(()=>{throw e}),this.setState({caughtError:e,caughtErrorInfo:r})}render(){if(this.state.caughtError)return sn().createElement("div",null,"An error has occurred. Please try reloading the page.");{let n=sn().createElement(sr.Suspense,{fallback:null},sn().createElement(sA.SWRConfig,{value:r},sn().createElement(sa.Provider,{value:this.state.config},t.disableTranslations?sn().createElement(e,this.props):sn().createElement(sM.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},sn().createElement(e,this.props)))));return t.strictMode&&sn().StrictMode?sn().createElement(sn().StrictMode,null,n):n}}constructor(e){super(e),this.state={caughtError:null,caughtErrorInfo:null,config:{moduleName:t.moduleName,featureName:t.featureName,extension:e._extensionContext}}}},i="displayName",s=`OpenmrsReactComponent(${t.featureName})`,i in o?Object.defineProperty(o,i,{value:s,enumerable:!0,configurable:!0,writable:!0}):o[i]=s,a}}function sW(e,t){return function(e){if("object"!==sS(e))throw Error("single-spa-react requires a configuration object");var t,r=sD(sD({},sP),e);if(!r.React)throw Error("single-spa-react must be passed opts.React");if(!r.ReactDOM&&!r.ReactDOMClient)throw Error("single-spa-react must be passed opts.ReactDOM or opts.ReactDOMClient");if(r.renderType||(null!=(t=r.ReactDOMClient)&&t.createRoot?r.renderType="createRoot":r.renderType="render"),!r.rootComponent&&!r.loadRootComponent)throw Error("single-spa-react must be passed opts.rootComponent or opts.loadRootComponent");if(r.errorBoundary&&"function"!=typeof r.errorBoundary)throw Error("The errorBoundary opt for single-spa-react must either be omitted or be a function that returns React elements");!sk&&r.React.createContext&&(sk=r.React.createContext()),r.SingleSpaRoot=function(e){function t(e){t.displayName="SingleSpaRoot(".concat(e.name,")")}return t.prototype=Object.create(e.React.Component.prototype),t.prototype.componentDidMount=function(){setTimeout(this.props.mountFinished)},t.prototype.componentWillUnmount=function(){setTimeout(this.props.unmountFinished)},t.prototype.render=function(){return setTimeout(this.props.updateFinished),this.props.children},t}(r);var n={bootstrap:sR.bind(null,r),mount:sO.bind(null,r),unmount:sT.bind(null,r)};return r.parcelCanUpdate&&(n.update=sN.bind(null,r)),n}({React:sn(),ReactDOMClient:sE,rootComponent:sU(t)(e)})}function sH(e,t){return()=>e().then(({default:e})=>sW(e,t))}function sz(e,t){return()=>Promise.resolve(sW(e,t))}let sK=sH,sG=M()(()=>({}));W("openmrs-app-context",sG);let sZ={};function sY(e,t=e=>e){let r=sG.getState();return e in r?Object.freeze(Object.assign({},t?t(r[e]):r[e])):null}function sq(e,t){sG.setState(r=>(e in r||(r[e]={}),r[e]=t(r[e]),Object.assign({},r)))}function sJ(e){return null===e?null:Object.freeze(Object.assign({},e))}let sX=new Map;function sQ(e,t){let r=(0,sr.useRef)(t??{}),n=(0,sr.useRef)(t=>sq(e,t)),a=(0,sr.useRef)(Symbol());return(0,sr.useEffect)(()=>{let r=t??{},n=a.current;return null===sY(e)?!function(e,t=sZ){sG.setState(r=>{if(e in r)throw Error(`Attempted to re-register namespace ${e} in the app context. Each namespace must be unregistered before the name can be registered again.`);return Object.assign({},r,{[e]:t===sZ?{}:t})})}(e,r):(console.warn(`Namespace ${e} is already registered in the app context. This is likely a race condition during navigation, but may indicate two components are trying to own the same namespace. Updating the existing context.`),sq(e,()=>r)),sX.set(e,n),()=>{sX.get(e)===n&&(sG.setState(t=>(e in t&&delete t[e],t)),sX.delete(e))}},[e]),(0,sr.useEffect)(()=>{let n=t??{};T(r.current,n)||(sq(e,()=>n),r.current=n)},[t]),n.current}function s0({namespace:e,value:t}){return sQ(e,t),null}let s1=({children:e,value:t,fallback:r})=>t?sn().createElement(sn().Fragment,null,e):r?sn().createElement(sn().Fragment,null,r):null;function s2(){let e=(0,sr.useRef)();return(!e.current||e.current.signal.aborted)&&(e.current=new AbortController),(0,sr.useEffect)(()=>{let t=e.current;return()=>t?.abort()},[]),e.current}function s4(e,t=e=>e??{}){let[r,n]=(0,sr.useState)(()=>{if(s3(e))return;let r=sY(e);if(null!==r)return t?t(r):r});return(0,sr.useEffect)(()=>{if(s3(e))throw Error(`The namespace supplied to useAppContext must be a non-empty string, but was "${e}".`)},[e]),(0,sr.useEffect)(()=>{var r;let a;return(r=e=>{if(null==e)return void n(void 0);let r=t?t(e):e;n(e=>T(e,r)?e:r)})(sJ(a=sY(e))),sG.subscribe(t=>{let n=e in t?t[e]:null;n!==a&&(a=n,r(sJ(n)))})},[e,t]),r}function s3(e){return"string"!=typeof e||0===e.trim().length}function s6(e){let t=sy(e);return(0,sr.useMemo)(()=>t.map(e=>e.id),[t])}function s5(e){return sh(e).candidateExtensions}function s9(e,t,r){let{data:n,error:a,mutate:o,isLoading:i,isValidating:s}=sj()(e?or(e,t,r):null,n1);return(0,sr.useMemo)(()=>({isLoading:i,data:n?.data.results??[],error:a,mutate:o,isValidating:s}),[n,a,i,s,o])}function s8(e){(0,sr.useEffect)(()=>{if(e){let e=window.getComputedStyle(document.body).overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=e}}},[e])}let s7={},le=`No ComponentContext has been provided. This should come from "openmrsComponentDecorator".
|
|
16
16
|
Usually this is already applied when using "getAsyncLifecycle" or "getSyncLifecycle".`;function lt(e,t,r){let n=s7[e];if(n)return n;let a=new Promise(e=>{let n=r(t.getState());if(n)return void e(n);let a=t.subscribe(t=>{let n=r(t);n&&(a(),e(n))})});return s7[e]=a,a.then(()=>{s7[e]===a&&delete s7[e]}),a}function lr(e){let{moduleName:t,extension:r}=(0,sr.useContext)(sa),n=e?.externalModuleName??t;if(!n&&!r)throw Error(le);let a=function(e){let t=(0,sr.useMemo)(()=>ec(e),[e]),r=function(e){let[t,r]=(0,sr.useState)(()=>{let t=e.getState();return t.loaded&&t.config?t.config:null});return(0,sr.useEffect)(()=>e?.subscribe(e=>{e.loaded&&e.config&&r(e.config)}),[e]),t}(t);if(!r)throw lt(e,t,e=>e.loaded?e.config:null);return r}(n),o=function(e){let t=(0,sr.useMemo)(ep,[]),r=function(e,t){let[r,n]=(0,sr.useState)(t?()=>{let r=eh(e.getState(),t.extensionSlotName,t.extensionId);if(r.loaded&&r.config)return r.config}:null);return(0,sr.useEffect)(()=>{if(t)return e.subscribe(e=>{let a=eh(e,t.extensionSlotName,t.extensionId);a.loaded&&a.config&&!(0,X.isEqual)(a.config,r)&&n(a.config)})},[e,t,r]),r}(t,e);if(!r&&e)throw lt(`${e.extensionSlotName}-${e.extensionId}`,t,t=>{let r=eh(t,e.extensionSlotName,e.extensionId);return r.loaded?r.config:null});return r||{}}(r);return(0,sr.useMemo)(()=>e?.externalModuleName&&n===e.externalModuleName?{...a}:{...a,...o},[n,e?.externalModuleName,a,o])}let ln=sy;function la(e,t=300){let[r,n]=(0,sr.useState)(e);return(0,sr.useEffect)(()=>{let r=setTimeout(()=>{n(e)},t);return()=>{clearTimeout(r)}},[e,t]),r}var lo=r(6088),li=r.n(lo);let ls=`custom:${[["admissionDecisionConcept","ref"],["admissionEncounterType","ref"],["admissionForm","ref"],["atFacilityVisitType","ref"],["bedAssignmentEncounterType","ref"],["cancelADTRequestEncounterType","ref"],["checkInClerkEncounterRole","ref"],["checkInEncounterType","ref"],["clinicianEncounterRole","ref"],["conceptSourcesForDiagnosisSearch","ref"],["consultEncounterType","ref"],["consultFreeTextCommentsConcept","ref"],["denyAdmissionConcept","ref"],["diagnosisMetadata","ref"],["diagnosisSets","ref"],["dischargeForm","ref"],["dispositionDescriptor","ref"],["dispositions","ref"],["emrApiConceptSource","ref"],["exitFromInpatientEncounterType","ref"],["extraPatientIdentifierTypes","ref"],["fullPrivilegeLevel","ref"],["highPrivilegeLevel","ref"],["identifierTypesToSearch","ref"],["inpatientNoteEncounterType","ref"],["lastViewedPatientSizeLimit","ref"],["metadataSourceName","ref"],["motherChildRelationshipType","ref"],["narrowerThanConceptMapType","ref"],["nonDiagnosisConceptSets","ref"],["orderingProviderEncounterRole","ref"],["patientDiedConcept","ref"],["personImageDirectory","ref"],["primaryIdentifierType","ref"],["sameAsConceptMapType","ref"],["suppressedDiagnosisConcepts","ref"],["supportsAdmissionLocationTag","(uuid,display,name,links)"],["supportsLoginLocationTag","(uuid,display,name,links)"],["supportsTransferLocationTag","(uuid,display,name,links)"],["supportsVisitsLocationTag","(uuid,display,name,links)"],["telephoneAttributeType","ref"],["testPatientPersonAttributeType","ref"],["transferForm","ref"],["transferRequestEncounterType","ref"],["transferWithinHospitalEncounterType","ref"],["unknownCauseOfDeathConcept","ref"],["unknownLocation","ref"],["unknownPatientPersonAttributeType","ref"],["unknownProvider","ref"],["visitAssignmentHandlerAdjustEncounterTimeOfDayIfNecessary","ref"],["visitExpireHours","ref"],["visitNoteEncounterType","ref"]].map(([e,t])=>`${e}:${t}`).join(",")}`;function ll(){let e=`${nJ}/emrapi/configuration?v=${ls}`,t=li()(e,n1);return(0,sr.useMemo)(()=>({emrConfiguration:t.data?.data,isLoadingEmrConfiguration:t.isLoading,mutateEmrConfiguration:t.mutate,errorFetchingEmrConfiguration:t.error}),[t])}function lu(){return(0,sr.useContext)(sa).extension}let lc=sf(ie());function ld(e){let t=sy(e);return(0,sr.useMemo)(()=>Object.fromEntries(t.map(e=>[e.name,e.meta])),[t])}let lf=sf(ic());function lm(e){let{flags:t}=sc(o2);return t[e]?.enabled??!1}function lp(){let[,e]=(0,sr.useState)(0);return(0,sr.useCallback)(()=>{e(e=>e+1)},[])}function lh(e,t,r={}){return ly(e,t,lg,r)}let lg={getPaginatedUrl:(e,t,r)=>{if(!e)return null;{let n=new URL(n0(e.toString()),window.location.toString());return n.searchParams.set("limit",""+t),n.searchParams.set("startIndex",""+r),n.searchParams.set("totalCount","true"),n.toString()}},getNextUrl:e=>{let t=e?.links?.find(e=>"next"==e.rel)?.uri;if(!t)return null;{let e=new URL(t);return e.host=window.location.host,e.protocol=window.location.protocol,e.toString()}},getTotalCount:e=>e?.totalCount??NaN,getCurrentPageSize:e=>e?.results?.length??NaN,getData:e=>e?.results};function ly(e,t,r,n={}){let{getPaginatedUrl:a,getTotalCount:o,getCurrentPageSize:i,getData:s}=r,{immutable:l,swrConfig:u}=n,c=n.fetcher??n1,[d,f]=(0,sr.useState)(1),m=(0,sr.useRef)(NaN),p=(0,sr.useRef)(NaN),h=(0,sr.useRef)(d),g=(0,sr.useRef)(!1),y=(0,sr.useRef)(!1),v=e?.toString()??"",[b,w]=(0,sr.useState)(v);v!==b&&(w(v),f(1),h.current=1,m.current=NaN,p.current=NaN,g.current=!1,y.current=!1);let E=(d-1)*t,x=(0,sr.useMemo)(()=>a(e,t,E),[e,t,E]),{data:D,...S}=(l?li():sj())(x,c,u);D?.data&&(m.current=o(D?.data),p.current=i(D?.data),g.current=!0);let _=Math.ceil(m.current/t),C=(0,sr.useCallback)(e=>{if(!Number.isInteger(e)||e<1)return void console.warn(`useServerPagination: ignoring goTo(${e}); page must be a positive integer.`);let r=Math.ceil(m.current/t);!g.current||Number.isNaN(r)||e<=r?(h.current=e,f(e)):console.warn("Invalid attempt to go to out of bounds page: "+e)},[t]);(0,sr.useEffect)(()=>{if(!g.current)return;if(Number.isNaN(m.current)){y.current||(y.current=!0,console.warn(`useServerPagination: ${v} returned no total count, so out-of-range pages cannot be detected.`));return}let e=Math.max(1,Math.ceil(m.current/t));d>e&&(console.warn(`Invalid attempt to go to out of bounds page: ${d}; returning to page ${e}.`),h.current=e,f(e))},[d,t,v,D]);let k=(0,sr.useCallback)(()=>{C(h.current+1)},[C]),P=(0,sr.useCallback)(()=>{C(h.current-1)},[C]);return{data:s(D?.data),totalPages:_,totalCount:m.current,currentPage:d,currentPageSize:p.current,paginated:_>1,showNextButton:d<_,showPreviousButton:d>1,goTo:C,goToNext:k,goToPrevious:P,...S}}function lv(e,t,r={}){return ly(e,t,lb(),r)}function lb(){return{getPaginatedUrl:(e,t,r)=>{if(!e)return null;{let n=new URL(n0(e.toString()),window.location.toString());return n.searchParams.set("_count",""+t),n.searchParams.set("_getpagesoffset",""+r),n.toString()}},getNextUrl:e=>{let t=e?.link?.find(e=>"next"==e.relation)?.url;if(!t)return null;{let e=new URL(t);return e.host=window.location.host,e.protocol=window.location.protocol,e.toString()}},getTotalCount:e=>e?.total??NaN,getCurrentPageSize:e=>e?.entry?.length??NaN,getData:e=>e?.entry?.map(e=>e.resource)}}var lw=r(2398),lE=r.n(lw);function lx(e,t={}){return lD(e,lg,t)}function lD(e,t,r={}){let{swrInfiniteConfig:n,immutable:a}=r,{getNextUrl:o,getTotalCount:i,getData:s}=t,l=r.fetcher??n1,u=(0,sr.useCallback)((r,n)=>0==r?e?.toString()??null:t.getNextUrl(n.data),[e]),{data:c,size:d,setSize:f,...m}=lE()(u,l,{...n,...a?{revalidateIfStale:!1,revalidateOnFocus:!1,revalidateOnReconnect:!1}:{}}),p=o(c?.[c.length-1].data),h=i(c?.[0]?.data);return{data:c?.flatMap(e=>s(e.data)),totalCount:h,hasMore:null!=p,loadMore:()=>{f((c?.length??0)+1)},nextUri:p,...m}}function lS(e,t={}){return l_(e,lg,t)}function l_(e,t,r={}){let n=lD(e,t,r),{hasMore:a,error:o,data:i,loadMore:s,isLoading:l,nextUri:u}=n;return((0,sr.useEffect)(()=>{a&&!o&&s()},[a,u]),r.partialData)?n:{...n,data:a||o?void 0:i,isLoading:l||a}}function lC(e,t={}){return l_(e,lb(),t)}function lk(e,t={}){return lD(e,lb(),t)}function lP(){let e="tablet";return document.body.classList.forEach(t=>{switch(t){case"omrs-breakpoint-lt-tablet":e="phone";break;case"omrs-breakpoint-gt-small-desktop":e="large-desktop";break;case"omrs-breakpoint-gt-tablet":e="small-desktop"}}),e}function lR(){let[e,t]=(0,sr.useState)(lP);return(0,sr.useEffect)(()=>{let e=()=>{t(lP())};return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),e}let lO=e=>"small-desktop"===e||"large-desktop"===e;function lT(e){let t=(0,sr.useContext)(sa);(0,sr.useEffect)(()=>(t&&t.moduleName&&(e.componentContext=t),iK(e),()=>{iG(e.name)}),[t,e])}function lN(){return sc(iz)}let l$=[];function lI(e=null,t=null){let r=new URLSearchParams;e&&r.set("tag",e),t&&r.set("q",t);let n=r.toString(),{data:a}=lS(`${nJ}/location${n?"?"+n:""}`,{immutable:!0});return a??l$}function lM(e,t=!0){let r=(0,sr.useRef)(null);return(0,sr.useEffect)(()=>{let n=n=>{t&&r.current&&n.target&&n.target instanceof Node&&(r.current.contains(n.target)||e(n))};return window.addEventListener("mousedown",n),window.addEventListener("touchstart",n),()=>{window.removeEventListener("mousedown",n),window.removeEventListener("touchstart",n)}},[e,t]),r}function lA(e){let t=(0,sr.useRef)();return(0,sr.useEffect)(()=>{let r=new IntersectionObserver(t=>{for(let r of t)if(r.isIntersecting)return void e()},{threshold:1});return t.current&&r.observe(t.current),()=>{t.current&&r.unobserve(t.current)}},[t.current,e]),t}function lj(e,t={}){let{abortController:r,fetchInit:n,url:a,swrConfig:o}=t,i=s2(),s=(0,sr.useMemo)(()=>n?.signal??r?.signal??i.signal,[r?.signal,n?.signal,i.signal]),l=(0,sr.useCallback)(e=>n1(function(e,t){if(t)return"function"==typeof t?t(e):t;if("string"==typeof e)return e;throw Error(`When using useOpenmrsSWR with a key that is not a string, you must provide a url() function that converts the key to a valid url. The key for this hook is ${e}.`)}(e,a),{...n,signal:s}),[s,n,a]);return sj()(e,l,o)}function lL(e=[],t=10){let[r,n]=(0,sr.useState)(1),a=(0,sr.useMemo)(()=>"number"==typeof t&&t>0?Math.max(1,Math.ceil(e.length/t)):1,[e.length,t]);r>a&&n(a);let o=Math.min(Math.max(1,r),a),i=(0,sr.useMemo)(()=>{let r=(o-1)*t,n=(o+0)*t;return e.slice(r,n)},[e,o,t]),s=(0,sr.useCallback)(e=>{!Number.isInteger(e)||e<1?console.warn(`usePagination: ignoring goTo(${e}); page must be a positive integer.`):n(e)},[]),l=(0,sr.useCallback)(()=>{n(e=>e+1)},[]),u=(0,sr.useCallback)(()=>{n(e=>Math.max(1,e-1))},[]);return(0,sr.useMemo)(()=>({results:i,totalPages:a,currentPage:o,paginated:e.length>t,showNextButton:o<a,showPreviousButton:o>1,goTo:s,goToNext:l,goToPrevious:u}),[i,a,e.length,t,o,s,l,u])}function lF(e,t,r,n){return{pageSizes:(0,sr.useMemo)(()=>{let r=Math.ceil(t/e);return isNaN(r)&&(r=0),[...Array(r).keys()].map(t=>(t+1)*e)},[e,t]),pageItemsCount:(0,sr.useMemo)(()=>e>t?t:e*r>t?e*(r-1)+n:e*r,[e,t,r,n])}}function lB(){let e=/\/patient\/([a-zA-Z0-9\-]+)\/?/.exec(location.pathname);return e&&e[1]}function lV(e){let[t,r]=(0,sr.useState)(e??lB()),{data:n,error:a,isValidating:o}=sj()(t?["patient",t]:null,()=>oo(t,{}));return(0,sr.useEffect)(()=>{let e=()=>{let e=lB();e!==t&&r(e)};return window.addEventListener("single-spa:routing-event",e),()=>window.removeEventListener("single-spa:routing-event",e)},[t]),(0,sr.useMemo)(()=>({isLoading:o&&!a&&!n,patient:n,patientUuid:t,error:a}),[o,a,n,t])}function lU(){let e=`${nJ}/metadatamapping/termmapping?v=custom:(metadataUuid)&code=emr.primaryIdentifierType`,{data:t,error:r,isLoading:n}=sj()(e,n1);return(0,sr.useMemo)(()=>({primaryIdentifierCode:t?.data?.results[0]?.metadataUuid,isLoading:n,error:r}),[t,r,n])}function lW(e){let{extensions:t,extensionSlotModuleName:r}=sv(e);return e?t.map(t=>({state:n})=>sn().createElement(sa.Provider,{value:{moduleName:r,featureName:"",extension:{extensionId:t.id,extensionSlotName:e,extensionSlotModuleName:r,extensionMeta:t.meta}}},sn().createElement(si,{state:n}))):[]}function lH(){let e=(0,sr.useRef)(),[t,r]=(0,sr.useState)(null),n=null;if(!t){if(i){let e=n8().getState();e.loaded&&(n=e.session)}else i=new Promise(t=>{let r=({loaded:r,session:a})=>{r&&(t(a),n=a,e.current&&(e.current(),e.current=void 0))};r(n8().getState()),n||(e.current=n8().subscribe(r))});if(n)r(n);else throw i}(0,sr.useEffect)(()=>(e.current||(e.current=n8().subscribe(({loaded:e,session:t})=>{e&&(n=t,r(t))})),()=>{e.current&&(e.current(),e.current=void 0)}),[]);let a=t||n;if(!a)if(i)throw console.warn("useSession is in an unexpected state. Attempting to recover."),i;else throw Error("useSession is in an invalid state.");return a}let lz=({privilege:e,fallback:t,children:r})=>{let[n,a]=(0,sr.useState)(null);return((0,sr.useEffect)(()=>{let e=n8(),t=e.subscribe(({loaded:e,session:t})=>{a(e?t?.user??null:null)}),{loaded:r,session:n}=e.getState();return r&&a(n?.user??null),t},[]),n&&ar(e,n))?sn().createElement(sn().Fragment,null,r):t?sn().createElement(sn().Fragment,null,t):null};var lK=r(6734),lG=r.n(lK),lZ=r(7581);let lY=new Map;function lq(){for(let e of Array.from(lY.values()))e()}let lJ={setVisitContext:(e,t)=>null==t?{manuallySetVisitUuid:null}:{manuallySetVisitUuid:t.uuid,patientUuid:t.patient?.uuid}};function lX(e){let t=(0,sr.useId)();return(0,sr.useEffect)(()=>{if(e)return lY.set(t,e),()=>{lY.delete(t)}},[t,e]),{...sd(oy(),lJ),mutateVisit:lq}}function lQ(e,t=oh){let r=(0,sr.useRef)(void 0),{patientUuid:n,manuallySetVisitUuid:a,setVisitContext:o}=lX((0,sr.useCallback)(()=>r.current?.(),[])),i=e&&n==e?a:null,s=`?patient=${e}&v=${t}&includeInactive=false`,l=`/${i}?v=${t}`,{data:u,error:c,mutate:d,isValidating:f}=sj()(e?`${nJ}/visit${s}`:null,n1),{data:m,error:p,mutate:h,isValidating:g}=sj()(e&&i?`${nJ}/visit${l}`:null,n1),y=(0,sr.useMemo)(()=>u?.data.results.find(e=>null===e.stopDatetime)??null,[u]),v=(0,sr.useMemo)(()=>i&&m?m.data:null,[m,i]),b=(0,sr.useRef)(null);(0,sr.useEffect)(()=>{!f&&y&&n===e&&null===a&&o(y),g||(b.current&&v&&b.current.uuid===v.uuid&&!b.current.stopDatetime&&v.stopDatetime&&o(null),b.current=v)},[v,a,y,f,g,n]);let w=(0,sr.useCallback)(()=>{d(),h()},[d,h]);(0,sr.useEffect)(()=>{r.current=w},[w]);let E=!!(!u||i&&!m),x=!!(i?p:c);return{error:c||p,mutate:w,isValidating:f||g,activeVisit:y,currentVisit:v,currentVisitIsRetrospective:!!i,isLoading:E&&!x}}lK.extend(lZ);let l0=[];function l1(){let{data:e}=li()(od,of);return e??l0}let l2=new Map;async function l4(e,t){let r=t.indexOf("#"),n=r>=0,a=n?t.substring(0,r):e,o=n?t.substring(r+1):t,i=await aF(a);return i&&Object.hasOwn(i,o)&&"function"==typeof i[o]?l6(a,i).then(()=>i[o]()):(i?i&&Object.hasOwn(i,o)?console.warn(`The export ${t}, defined in ${e}'s routes.json, is not a function`):console.warn(`${a} does not define a component called "${o}", referenced in ${e}'s routes.json. This cannot be loaded.`):console.warn(`Unknown app ${a} for ${t} defined in ${e}'s routes.json`),l3)}let l3={bootstrap:()=>Promise.resolve(),mount:()=>Promise.resolve(),unmount:()=>Promise.resolve()};async function l6(e,t){if(e in l2)await l2[e];else{let r=t??await aF(e);await (l2[e]=new Promise((t,n)=>{if(Object.hasOwn(r,"startupApp")){let a=r.startupApp;if("function"==typeof a)return Promise.resolve(a()).then(()=>{eF(e),t(null)}).catch(n)}eF(e),t(null)}))}}function l5(e,t){let r=t.name;if(!r)return void console.error(`An extension definition in ${e} is missing an name and thus cannot be
|
|
17
17
|
registered. To fix this, ensure that you define the "name" field inside the
|
|
18
18
|
extension definition.`,t);t.slots&&t.slot&&console.warn(`The extension ${r} from ${e} declares both a 'slots' property and
|