@openmrs/esm-patient-documents-admin-app 4.5.1-pre.959 → 4.6.0
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/.turbo/turbo-build.log +2 -2
- package/.turbo/turbo-lint.log +0 -0
- package/.turbo/turbo-test.log +31 -0
- package/.turbo/turbo-typescript.log +0 -0
- package/dist/65.js +1 -1
- package/dist/65.js.map +1 -1
- package/dist/openmrs-esm-patient-documents-admin-app.js +2 -2
- package/dist/openmrs-esm-patient-documents-admin-app.js.map +1 -1
- package/dist/routes.json +1 -1
- package/package.json +2 -3
package/dist/65.js
CHANGED
|
@@ -12,7 +12,7 @@ If you're the maintainer: the 'elements' key only works with '_type' equal to 'A
|
|
|
12
12
|
${t}`)}return r}let ao=(e,t)=>{let n=structuredClone(t);if(!e)return n;for(let t of Object.keys(e)){let r=n[t],a=e[t];if(a&&(a.hasOwnProperty("_type")||a.hasOwnProperty("_default"))){n.hasOwnProperty(t)||(n[t]=a._default);let e=a._elements;if(r&&ai(e)){if(a._type===rc.Array&&Array.isArray(r)){let a=r.map(t=>ao(e,t));n[t]=a}else if(a._type===rc.Object)for(let t of Object.keys(r))r[t]=ao(e,r[t])}}else if(as(a)){let e=r??{};as(e)&&(n[t]=ao(a,e))}}return n};function ai(e){return!!e&&Object.keys(e).filter(e=>!["_default","_validators"].includes(e)).length>0}function as(e){return"object"==typeof e&&!Array.isArray(e)&&null!==e}function al(e,t){let n=`${e}:::${t}`;rU.has(n)||(console.error(t),rU.add(n))}function au(e){e?rU.forEach(t=>{t.startsWith(e)&&rU.delete(t)}):rU.clear()}function ac(){rB.forEach(e=>e()),rB.length=0,rK.clear(),r3.clear(),r5.clear(),r6.clear(),rV=null,rW=new WeakMap,rH()}let ad={"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:rc.Object,_default:{},_validators:[rd(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(", ")}.`})]}},am={"Display conditions":{privileges:{_description:"The privilege(s) the user must have to use this extension",_type:rc.Array,_default:[]},expression:{_description:"The expression that determines whether the extension is displayed",_type:rc.String,_default:void 0}},...ad},ap=(e,t)=>rd(n=>e<=n&&n<=t,`must be between ${e} and ${t}`),af=e=>{let t=e.concat(["openmrsBase","openmrsSpaBase"]);return rd(e=>{if(!e||"string"!=typeof e)return!1;let n=/\${(.*?)}/g,r=n.exec(e);for(;r;){if(!t.includes(r[1]))return!1;r=n.exec(e)}return!0},"Should be a URL or path. The allowed template parameters are "+t.map(e=>"${"+e+"}").join(", "))},ah=af([]),ag=e=>rd(t=>e.includes(t),`Must be one of the following: '${e.join("', '")}'.`),ay={inRange:ap,isUrl:ah,isUrlWithTemplateParameters:af,oneOf:ag};var av=n(2034);let ab=B("breadcrumbs",[]);function aw(e){return aE([e])}function aE(e){let t=[...ax(),...e.map(e=>({matcher:e.matcher instanceof RegExp?e.matcher:"string"==typeof e.matcher?(0,av.pathToRegexp)(e.matcher).regexp:(0,av.pathToRegexp)(e.path).regexp,settings:e}))];ab.setState(t,!0)}function ax(){return ab.getState()}function aD(e,t){if(t)return function(e,t){let[n]=e.filter(e=>e.matcher.test(t));return n}(e,t)||function(e,t){let n=t.split("/");for(;n.length>1;){n.pop();let t=aD(e,n.join("/"));if(t)return t}}(e,t)}function a_(e,t){if(e.length>0){let n=aD(e,t);if(n){let t=[n],r=aD(e,n.settings.parent);for(;void 0!==r;)t.push(r),r=aD(e,r.settings.parent);return t.reverse()}}return[]}function aS(e){return a_(ax(),e)}var aC=Object.freeze({__proto__:null,get start(){return oq},get ensureJQuerySupport(){return oS},get setBootstrapMaxTime(){return oi},get setMountMaxTime(){return os},get setUnmountMaxTime(){return ol},get setUnloadMaxTime(){return ou},get registerApplication(){return oA},get unregisterApplication(){return oL},get getMountedApps(){return o$},get getAppStatus(){return oj},get unloadApplication(){return oF},get checkActivityFunctions(){return oM},get getAppNames(){return oN},get pathToActiveWhen(){return oV},get navigateToUrl(){return og},get patchHistoryApi(){return ox},get triggerAppChange(){return oK},get addErrorHandler(){return aO},get removeErrorHandler(){return a$},get mountRootParcel(){return ot},get NOT_LOADED(){return aI},get LOADING_SOURCE_CODE(){return aA},get NOT_BOOTSTRAPPED(){return aM},get BOOTSTRAPPING(){return aL},get NOT_MOUNTED(){return aF},get MOUNTING(){return aB},get UPDATING(){return aV},get LOAD_ERROR(){return az},get MOUNTED(){return aU},get UNLOADING(){return aH},get UNMOUNTING(){return aW},get SKIP_BECAUSE_BROKEN(){return aK}}),ak=("u">typeof globalThis?globalThis:"u">typeof window?window:"u">typeof global?global:"u">typeof self?self:{}).CustomEvent,aP=!function(){try{var e=new ak("cat",{detail:{foo:"bar"}});return"cat"===e.type&&"bar"===e.detail.foo}catch(e){}return!1}()?"u">typeof document&&"function"==typeof document.createEvent?function(e,t){var n=document.createEvent("CustomEvent");return t?n.initCustomEvent(e,t.bubbles,t.cancelable,t.detail):n.initCustomEvent(e,!1,!1,void 0),n}:function(e,t){var n=document.createEventObject();return n.type=e,t?(n.bubbles=!!t.bubbles,n.cancelable=!!t.cancelable,n.detail=t.detail):(n.bubbles=!1,n.cancelable=!1,n.detail=void 0),n}:ak;let aR=[];function aT(e,t,n){let r=aj(e,t,n);aR.length?aR.forEach(e=>e(r)):setTimeout(()=>{throw r})}function aO(e){if("function"!=typeof e)throw Error(aN(28,!1));aR.push(e)}function a$(e){if("function"!=typeof e)throw Error(aN(29,!1));let t=!1;return aR=aR.filter(n=>{let r=n===e;return t=t||r,!r}),t}function aN(e,t,...n){return`single-spa minified message #${e}: ${t?t+" ":""}See https://single-spa.js.org/error/?code=${e}${n.length?`&arg=${n.join("&arg=")}`:""}`}function aj(e,t,n){let r,a=`${aJ(t)} '${aY(t)}' died in status ${t.status}: `;if(e instanceof Error){try{e.message=a+e.message}catch(e){}r=e}else{console.warn(aN(30,!1,t.status,aY(t)));try{r=Error(a+JSON.stringify(e))}catch(t){r=e}}return r.appOrParcelName=aY(t),t.status=n,r}let aI="NOT_LOADED",aA="LOADING_SOURCE_CODE",aM="NOT_BOOTSTRAPPED",aL="BOOTSTRAPPING",aF="NOT_MOUNTED",aB="MOUNTING",aU="MOUNTED",aV="UPDATING",aW="UNMOUNTING",aH="UNLOADING",az="LOAD_ERROR",aK="SKIP_BECAUSE_BROKEN";function aG(e){return e.status===aU}function aZ(e){try{return e.activeWhen(window.location)}catch(t){return aT(t,e,aK),!1}}function aY(e){return e.name}function aq(e){return!!e.unmountThisParcel}function aJ(e){return aq(e)?"parcel":"application"}function aX(){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 aQ(e,t){for(let n=0;n<e.length;n++)if(t(e[n]))return e[n];return null}function a0(e){return e&&("function"==typeof e||Array.isArray(e)&&!aQ(e,e=>"function"!=typeof e))}function a1(e,t){let n=e[t]||[];0===(n=Array.isArray(n)?n:[n]).length&&(n=[()=>Promise.resolve()]);let r=aJ(e),a=aY(e);return function(e){return n.reduce((n,o,i)=>n.then(()=>{let n=o(e);return a4(n)?n:Promise.reject(aN(15,!1,r,a,t,i))}),Promise.resolve())}}function a4(e){return e&&"function"==typeof e.then&&"function"==typeof e.catch}let a2=[];function a3(e,t){return Promise.resolve().then(()=>e.status!==aM?e:(e.status=aL,e.bootstrap?oc(e,"bootstrap").then(n).catch(n=>{if(t)throw aj(n,e,aK);return aT(n,e,aK),e}):Promise.resolve().then(n)));function n(){return e.status=aF,e}}function a6(e,t){return Promise.resolve().then(()=>{if(e.status!==aU)return e;return e.status=aW,Promise.all(Object.keys(e.parcels).map(t=>e.parcels[t].unmountThisParcel())).then(n,r=>n().then(()=>{let n=Error(r.message);if(t)throw aj(n,e,aK);aT(n,e,aK)})).then(()=>e);function n(){return oc(e,"unmount").then(()=>{e.status=aF},n=>{if(t)throw aj(n,e,aK);aT(n,e,aK)})}})}let a5=!1,a9=!1;function a8(e,t){return Promise.resolve().then(()=>e.status!==aF?e:(a5||(window.dispatchEvent(new aP("single-spa:before-first-mount")),a5=!0),e.status=aB,oc(e,"mount").then(()=>(e.status=aU,a9||(window.dispatchEvent(new aP("single-spa:first-mount")),a9=!0),e)).catch(n=>{return e.status=aU,a6(e,!0).then(r,r);function r(){if(t)throw aj(n,e,aK);return aT(n,e,aK),e}})))}let a7=0,oe={parcels:{}};function ot(){return on.apply(oe,arguments)}function on(e,t){let n,r,a,o=this;if(!e||"object"!=typeof e&&"function"!=typeof e)throw Error(aN(2,!1));if(e.name&&"string"!=typeof e.name)throw Error(aN(3,!1,typeof e.name));let i=a7++,s=e.name||`parcel-${i}`;if("object"!=typeof t)throw Error(aN(4,!1,s,typeof t));if(!t.domElement)throw Error(aN(5,!1,s));let l="function"==typeof e,u=l?e:()=>Promise.resolve(e),c={id:i,parcels:{},status:l?aA:aM,customProps:t,parentName:aY(o),unmountThisParcel:()=>p.then(()=>{if(c.status!==aU)throw Error(aN(6,!1,s,c.status));return a6(c,!0)}).then(e=>(c.parentName&&delete o.parcels[c.id],e)).then(e=>(r(e),e)).catch(e=>{throw c.status=aK,a(e),e})};o.parcels[i]=c;let d=u();if(!d||"function"!=typeof d.then)throw Error(aN(7,!1));let m=(d=d.then(e=>{if(!e)throw Error(aN(8,!1));if(s=e.name||`parcel-${i}`,Object.prototype.hasOwnProperty.call(e,"bootstrap")&&!a0(e.bootstrap))throw Error(aN(9,!1,s));if(!a0(e.mount))throw Error(aN(10,!1,s));if(!a0(e.unmount))throw Error(aN(11,!1,s));if(e.update&&!a0(e.update))throw Error(aN(12,!1,s));let t=a1(e,"bootstrap"),r=a1(e,"mount"),a=a1(e,"unmount");c.status=aM,c.name=s,c.bootstrap=t,c.mount=r,c.unmount=a,c.timeouts=od(e.timeouts),e.update&&(c.update=a1(e,"update"),n.update=function(e){return c.customProps=e,or(Promise.resolve().then(()=>{if(c.status!==aU)throw Error(aN(32,!1,aY(c)));return c.status=aV,oc(c,"update").then(()=>(c.status=aU,c)).catch(e=>{throw aj(e,c,aK)})}))})})).then(()=>a3(c,!0)),p=m.then(()=>a8(c,!0)),f=new Promise((e,t)=>{r=e,a=t});return n={mount:()=>or(Promise.resolve().then(()=>{if(c.status!==aF)throw Error(aN(13,!1,s,c.status));return o.parcels[i]=c,a8(c)})),unmount:()=>or(c.unmountThisParcel()),getStatus:()=>c.status,loadPromise:or(d),bootstrapPromise:or(m),mountPromise:or(p),unmountPromise:or(f)}}function or(e){return e.then(()=>null)}function oa(e){let t=aY(e),n="function"==typeof e.customProps?e.customProps(t,window.location):e.customProps;("object"!=typeof n||null===n||Array.isArray(n))&&(n={},console.warn(aN(40,!1),t,n));let r=aX({},n,{name:t,mountParcel:on.bind(e),singleSpa:aC});return aq(e)&&(r.unmountSelf=e.unmountThisParcel),r}let oo={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 oi(e,t,n){if("number"!=typeof e||e<=0)throw Error(aN(16,!1));oo.bootstrap={millis:e,dieOnTimeout:t,warningMillis:n||1e3}}function os(e,t,n){if("number"!=typeof e||e<=0)throw Error(aN(17,!1));oo.mount={millis:e,dieOnTimeout:t,warningMillis:n||1e3}}function ol(e,t,n){if("number"!=typeof e||e<=0)throw Error(aN(18,!1));oo.unmount={millis:e,dieOnTimeout:t,warningMillis:n||1e3}}function ou(e,t,n){if("number"!=typeof e||e<=0)throw Error(aN(19,!1));oo.unload={millis:e,dieOnTimeout:t,warningMillis:n||1e3}}function oc(e,t){let n=e.timeouts[t],r=n.warningMillis,a=aJ(e);return new Promise((o,i)=>{let s=!1,l=!1;e[t](oa(e)).then(e=>{s=!0,o(e)}).catch(e=>{s=!0,i(e)}),setTimeout(()=>c(1),r),setTimeout(()=>c(!0),n.millis);let u=aN(31,!1,t,a,aY(e),n.millis);function c(e){s||(!0===e?(l=!0,n.dieOnTimeout?i(Error(u)):console.error(u)):!l&&(console.warn(u),e*r+r<n.millis&&setTimeout(()=>c(e+1),r)))}})}function od(e){let t={};for(let n in oo)t[n]=aX({},oo[n],e&&e[n]||{});return t}function om(e){return Promise.resolve().then(()=>{let t,n;return e.loadPromise?e.loadPromise:e.status!==aI&&e.status!==az?e:(e.status=aA,e.loadPromise=Promise.resolve().then(()=>{let r=e.loadApp(oa(e));if(!a4(r))throw n=!0,Error(aN(33,!1,aY(e)));return r.then(n=>{let r;e.loadErrorTime=null,"object"!=typeof(t=n)&&(r=34),Object.prototype.hasOwnProperty.call(t,"bootstrap")&&!a0(t.bootstrap)&&(r=35),a0(t.mount)||(r=36),a0(t.unmount)||(r=37);let a=aJ(t);if(r){let n;try{n=JSON.stringify(t)}catch(e){}return console.error(aN(r,!1,a,aY(e),n),t),aT(void 0,e,aK),e}return t.devtools&&t.devtools.overlays&&(e.devtools.overlays=aX({},e.devtools.overlays,t.devtools.overlays)),e.status=aM,e.bootstrap=a1(t,"bootstrap"),e.mount=a1(t,"mount"),e.unmount=a1(t,"unmount"),e.unload=a1(t,"unload"),e.timeouts=od(t.timeouts),delete e.loadPromise,e})}).catch(t=>{let r;return delete e.loadPromise,n?r=aK:(r=az,e.loadErrorTime=(new Date).getTime()),aT(t,e,r),e}))})}let op="u">typeof window,of={hashchange:[],popstate:[]},oh=["hashchange","popstate"];function og(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(aN(14,!1));t=e.currentTarget.href,e.preventDefault()}let n=oD(window.location.href),r=oD(t);0===t.indexOf("#")?window.location.hash=r.hash:n.host!==r.host&&r.host?window.location.href=t:r.pathname===n.pathname&&r.search===n.search?window.location.hash=r.hash:window.history.pushState(null,null,t)}function oy(e){if(e){let t=e[0].type;oh.indexOf(t)>=0&&of[t].forEach(t=>{try{t.apply(this,e)}catch(e){setTimeout(()=>{throw e})}})}}function ov(){oG([],arguments)}function ob(e,t){return function(){let n=window.location.href,r=e.apply(this,arguments),o=window.location.href;return a&&n===o||window.dispatchEvent(function(e,t){let n;try{n=new PopStateEvent("popstate",{state:e})}catch(t){(n=document.createEvent("PopStateEvent")).initPopStateEvent("popstate",!1,!1,e)}return n.singleSpa=!0,n.singleSpaTrigger=t,n}(window.history.state,t)),r}}let ow=null,oE=!1;function ox(e){if(oE)throw Error(aN(43,!1));a=!e||!e.hasOwnProperty("urlRerouteOnly")||e.urlRerouteOnly,oE=!0,ow=window.history.replaceState,window.addEventListener("hashchange",ov),window.addEventListener("popstate",ov);let t=window.addEventListener,n=window.removeEventListener;window.addEventListener=function(e,n){if(!("function"==typeof n&&oh.indexOf(e)>=0)||aQ(of[e],e=>e===n))return t.apply(this,arguments);of[e].push(n)},window.removeEventListener=function(e,t){return"function"==typeof t&&oh.indexOf(e)>=0&&(of[e]=of[e].filter(e=>e!==t)),n.apply(this,arguments)},window.history.pushState=ob(window.history.pushState,"pushState"),window.history.replaceState=ob(ow,"replaceState")}function oD(e){let t=document.createElement("a");return t.href=e,t}op&&(window.singleSpaNavigate?console.warn(aN(41,!1)):window.singleSpaNavigate=og);let o_=!1;function oS(e=window.jQuery){if(e||window.$&&window.$.fn&&window.$.fn.jquery&&(e=window.$),e&&!o_){let t=e.fn.on,n=e.fn.off;e.fn.on=function(e,n){return oC.call(this,t,window.addEventListener,e,n,arguments)},e.fn.off=function(e,t){return oC.call(this,n,window.removeEventListener,e,t,arguments)},o_=!0}}function oC(e,t,n,r,a){return"string"!=typeof n?e.apply(this,a):(n.split(/\s+/).forEach(e=>{oh.indexOf(e)>=0&&(t(e,r),n=n.replace(e,""))}),""===n.trim()?this:e.apply(this,a))}let ok={};function oP(e){return Promise.resolve().then(()=>{let t=ok[aY(e)];if(!t)return e;if(e.status===aI)return oR(e,t),e;if(e.status===aH)return t.promise.then(()=>e);if(e.status!==aF&&e.status!==az)return e;let n=e.status===az?Promise.resolve():oc(e,"unload");return e.status=aH,n.then(()=>(oR(e,t),e)).catch(n=>(delete ok[aY(e)],delete e.bootstrap,delete e.mount,delete e.unmount,delete e.unload,aT(n,e,aK),t.reject(n),e))})}function oR(e,t){delete ok[aY(e)],delete e.bootstrap,delete e.mount,delete e.unmount,delete e.unload,e.status=aI,t.resolve()}function oT(e,t,n,r){ok[aY(e)]={app:e,resolve:n,reject:r},Object.defineProperty(ok[aY(e)],"promise",{get:t})}let oO=[];function o$(){return oO.filter(aG).map(aY)}function oN(){return oO.map(aY)}function oj(e){let t=aQ(oO,t=>aY(t)===e);return t?t.status:null}let oI=!1;function oA(e,t,n,r){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(aN(39,!1));let t=["name","app","activeWhen","customProps"],n=Object.keys(e).reduce((e,n)=>t.indexOf(n)>=0?e:e.concat(n),[]);if(0!==n.length)throw Error(aN(38,!1,t.join(", "),n.join(", ")));if("string"!=typeof e.name||0===e.name.length||"object"!=typeof e.app&&"function"!=typeof e.app)throw Error(aN(20,!1));let r=e=>"string"==typeof e||"function"==typeof e;if(!(r(e.activeWhen)||Array.isArray(e.activeWhen)&&e.activeWhen.every(r)))throw Error(aN(24,!1));if(!oU(e.customProps))throw Error(aN(22,!1))}(e),i.name=e.name,i.loadApp=e.app,i.activeWhen=e.activeWhen,i.customProps=e.customProps):(function(e,t,n,r){if("string"!=typeof e||0===e.length)throw Error(aN(20,!1));if(!t)throw Error(aN(23,!1));if("function"!=typeof n)throw Error(aN(24,!1));if(!oU(r))throw Error(aN(22,!1))}(e,t,n,r),i.name=e,i.loadApp=t,i.activeWhen=n,i.customProps=r),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:oV(e)),i.activeWhen=e=>s.some(t=>t(e)),i);if(oY||oI||(oI=!0,setTimeout(()=>{oY||console.warn(aN(1,!1))},5e3)),-1!==oN().indexOf(l.name))throw Error(aN(21,!1,l.name));oO.push(aX({loadErrorTime:null,status:aI,parcels:{},devtools:{overlays:{options:{},selectors:[]}}},l)),op&&(oS(),oG())}function oM(e=window.location){return oO.filter(t=>t.activeWhen(e)).map(aY)}function oL(e){if(0===oO.filter(t=>aY(t)===e).length)throw Error(aN(25,!1,e));return(op?oF(e,{waitForUnmount:!1}):Promise.resolve()).then(()=>{let t=oO.map(aY).indexOf(e);oO.splice(t,1)})}function oF(e,t={waitForUnmount:!1}){if("string"!=typeof e)throw Error(aN(26,!1));let n=aQ(oO,t=>aY(t)===e);if(!n)throw Error(aN(27,!1,e));let r=ok[aY(n)];if(t&&t.waitForUnmount){if(r)return r.promise;{let e=new Promise((t,r)=>{oT(n,()=>e,t,r)});return e}}{let e;return r?(e=r.promise,oB(n,r.resolve,r.reject)):e=new Promise((t,r)=>{oT(n,()=>e,t,r),oB(n,t,r)}),e}}function oB(e,t,n){Promise.resolve().then(()=>{if(aQ(oM(),t=>t===aY(e)))return oK()}).then(()=>a6(e).then(oP).then(()=>{t(),setTimeout(()=>{oG()})})).catch(n)}function oU(e){return!e||"function"==typeof e||"object"==typeof e&&null!==e&&!Array.isArray(e)}function oV(e,t){let n=function(e,t){let n=0,r=!1,a="^";"/"!==e[0]&&(e="/"+e);for(let t=0;t<e.length;t++){let n=e[t],a=r&&"/"===n;(!r&&":"===n||a)&&o(t)}return o(e.length),RegExp(a,"i");function o(o){let i=e.slice(n,o).replace(/[|\\{}()[\]^$+*?.]/g,"\\$&");if(a+=r?"[^/]+/?":i,o===e.length)if(r)t&&(a+="$");else{let e=t?"":".*";a="/"===a.charAt(a.length-1)?`${a}${e}$`:`${a}(/${e})?(#.*)?$`}r=!r,n=o}}(e,t);return e=>{let t=e.origin;t||(t=`${e.protocol}//${e.host}`);let r=e.href.replace(t,"").replace(e.search,"").split("?")[0];return n.test(r)}}let oW=!1,oH=[],oz=op&&window.location.href;function oK(){return oG()}function oG(e=[],t,n=!1){let r,a,o,i,s;if(oW)return new Promise((e,n)=>{oH.push({resolve:e,reject:n,eventArguments:t})});let{appsToUnload:l,appsToUnmount:u,appsToLoad:c,appsToMount:d}=(r=[],a=[],o=[],i=[],s=(new Date).getTime(),oO.forEach(e=>{let t=e.status!==aK&&aZ(e);switch(e.status){case az:t&&s-e.loadErrorTime>=200&&o.push(e);break;case aI:case aA:t&&o.push(e);break;case aM:case aF:!t&&ok[aY(e)]?r.push(e):t&&i.push(e);break;case aU:t||a.push(e)}}),{appsToUnload:r,appsToUnmount:a,appsToLoad:o,appsToMount:i}),m,p=[],f=oz,h=oz=window.location.href;return oY?(oW=!0,m=l.concat(c,u,d),Promise.resolve().then(()=>(w(0===m.length?"before-no-app-change":"before-app-change",b(!0)),w("before-routing-event",b(!0,{cancelNavigation:g})),Promise.all(p).then(n=>{if(n.some(e=>e))return ow.call(window.history,history.state,"",f.substring(location.origin.length)),oz=location.href,oW=!1,oG(e,t,!0);let r=l.map(oP),a=Promise.all(u.map(a6).map(e=>e.then(oP)).concat(r));a.then(()=>{w("before-mount-routing-event",b(!0))},e=>{throw e});let o=c.map(e=>om(e).then(e=>oZ(e,a))),i=d.filter(e=>0>c.indexOf(e)).map(e=>oZ(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})))})))):(m=c,Promise.resolve().then(()=>Promise.all(c.map(om)).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);p.push(t.catch(e=>(console.warn(Error(aN(42,!1))),console.warn(e),!1)))}function y(){let t=o$();e.forEach(e=>e.resolve(t));try{w(0===m.length?"no-app-change":"app-change",b()),w("routing-event",b())}catch(e){setTimeout(()=>{throw e})}if(oW=!1,oH.length>0){let e=oH;oH=[],oG(e)}return t}function v(){n||(e.forEach(e=>{oy(e.eventArguments)}),oy(t))}function b(e=!1,n){let r={},a={[aU]:[],[aF]:[],[aI]:[],[aK]:[]};e?(c.concat(d).forEach((e,t)=>{i(e,aU)}),l.forEach(e=>{i(e,aI)}),u.forEach(e=>{i(e,aF)})):m.forEach(e=>{i(e)});let o={detail:{newAppStatuses:r,appsByNewStatus:a,totalAppChanges:m.length,originalEvent:null==t?void 0:t[0],oldUrl:f,newUrl:h}};return n&&aX(o.detail,n),o;function i(e,t){let n=aY(e);t=t||oj(n),r[n]=t,(a[t]=a[t]||[]).push(n)}}function w(e,t){n||window.dispatchEvent(new aP(`single-spa:${e}`,t))}}function oZ(e,t){return aZ(e)?a3(e).then(e=>t.then(()=>aZ(e)?a8(e):e)):t.then(()=>e)}let oY=!1;function oq(e){oY=!0,op&&(ox(e),oG())}op&&window.__SINGLE_SPA_DEVTOOLS__&&(window.__SINGLE_SPA_DEVTOOLS__.exposedMethods={getRawAppData:function(){return[...oO]},reroute:oG,NOT_LOADED:aI,toLoadPromise:om,toBootstrapPromise:a3,unregisterApplication:oL,getProfilerData:function(){return a2}});let oJ={address1:"Address line 1",address2:"Address line 2",address3:"Address line 3",address4:"Address line 4",address5:"Address line 5",address6:"Address line 6",city:"City",cityVillage:"City",country:"Country",countyDistrict:"District",district:"District",postalCode:"Postal code",state:"State",stateProvince:"State",closeAllOpenedWorkspaces:"Discard changes in {{count}} workspaces",closingAllWorkspacesPromptBody:"There may be unsaved changes in the following workspaces. Do you want to discard changes in the following workspaces? {{workspaceNames}}",closingAllWorkspacesPromptTitle:"You have unsaved changes",discard:"Discard",hide:"Hide",maximize:"Maximize",minimize:"Minimize",openAnyway:"Open anyway",unsavedChangesInOpenedWorkspace:"You may have unsaved changes in the opened workspace. Do you want to discard these changes?",unsavedChangesInWorkspace:'There may be unsaved changes in "{{workspaceName}}". Please save them before opening another workspace.',unsavedChangesTitleText:"Unsaved changes",workspaceHeader:"Workspace header",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"},oX=e=>"string"==typeof e,oQ=()=>{let e,t,n=new Promise((n,r)=>{e=n,t=r});return n.resolve=e,n.reject=t,n},o0=e=>null==e?"":""+e,o1=/###/g,o4=e=>e&&e.indexOf("###")>-1?e.replace(o1,"."):e,o2=e=>!e||oX(e),o3=(e,t,n)=>{let r=oX(t)?t.split("."):t,a=0;for(;a<r.length-1;){if(o2(e))return{};let t=o4(r[a]);!e[t]&&n&&(e[t]=new n),e=Object.prototype.hasOwnProperty.call(e,t)?e[t]:{},++a}return o2(e)?{}:{obj:e,k:o4(r[a])}},o6=(e,t,n)=>{let{obj:r,k:a}=o3(e,t,Object);if(void 0!==r||1===t.length){r[a]=n;return}let o=t[t.length-1],i=t.slice(0,t.length-1),s=o3(e,i,Object);for(;void 0===s.obj&&i.length;)o=`${i[i.length-1]}.${o}`,s=o3(e,i=i.slice(0,i.length-1),Object),s?.obj&&void 0!==s.obj[`${s.k}.${o}`]&&(s.obj=void 0);s.obj[`${s.k}.${o}`]=n},o5=(e,t)=>{let{obj:n,k:r}=o3(e,t);if(n&&Object.prototype.hasOwnProperty.call(n,r))return n[r]},o9=(e,t,n)=>{for(let r in t)"__proto__"!==r&&"constructor"!==r&&(r in e?oX(e[r])||e[r]instanceof String||oX(t[r])||t[r]instanceof String?n&&(e[r]=t[r]):o9(e[r],t[r],n):e[r]=t[r]);return e};var o8={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};let o7=e=>oX(e)?e.replace(/[&<>"'\/]/g,e=>o8[e]):e,ie=[" ",",","?","!",";"],it=new class{constructor(e){this.capacity=e,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(e){let t=this.regExpMap.get(e);if(void 0!==t)return t;let n=new RegExp(e);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(e,n),this.regExpQueue.push(e),n}}(20),ir=(e,t,n=".")=>{if(!e)return;if(e[t]){if(!Object.prototype.hasOwnProperty.call(e,t))return;return e[t]}let r=t.split(n),a=e;for(let e=0;e<r.length;){let t;if(!a||"object"!=typeof a)return;let o="";for(let i=e;i<r.length;++i)if(i!==e&&(o+=n),o+=r[i],void 0!==(t=a[o])){if(["string","number","boolean"].indexOf(typeof t)>-1&&i<r.length-1)continue;e+=i-e+1;break}a=t}return a},ia=e=>e?.replace("_","-"),io={type:"logger",log(e){this.output("log",e)},warn(e){this.output("warn",e)},error(e){this.output("error",e)},output(e,t){console?.[e]?.apply?.(console,t)}};class ii{constructor(e,t={}){this.init(e,t)}init(e,t={}){this.prefix=t.prefix||"i18next:",this.logger=e||io,this.options=t,this.debug=t.debug}log(...e){return this.forward(e,"log","",!0)}warn(...e){return this.forward(e,"warn","",!0)}error(...e){return this.forward(e,"error","")}deprecate(...e){return this.forward(e,"warn","WARNING DEPRECATED: ",!0)}forward(e,t,n,r){return r&&!this.debug?null:(oX(e[0])&&(e[0]=`${n}${this.prefix} ${e[0]}`),this.logger[t](e))}create(e){return new ii(this.logger,{...{prefix:`${this.prefix}:${e}:`},...this.options})}clone(e){return(e=e||this.options).prefix=e.prefix||this.prefix,new ii(this.logger,e)}}var is=new ii;class il{constructor(){this.observers={}}on(e,t){return e.split(" ").forEach(e=>{this.observers[e]||(this.observers[e]=new Map);let n=this.observers[e].get(t)||0;this.observers[e].set(t,n+1)}),this}off(e,t){if(this.observers[e]){if(!t)return void delete this.observers[e];this.observers[e].delete(t)}}emit(e,...t){this.observers[e]&&Array.from(this.observers[e].entries()).forEach(([e,n])=>{for(let r=0;r<n;r++)e(...t)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(([n,r])=>{for(let a=0;a<r;a++)n.apply(n,[e,...t])})}}class iu extends il{constructor(e,t={ns:["translation"],defaultNS:"translation"}){super(),this.data=e||{},this.options=t,void 0===this.options.keySeparator&&(this.options.keySeparator="."),void 0===this.options.ignoreJSONStructure&&(this.options.ignoreJSONStructure=!0)}addNamespaces(e){0>this.options.ns.indexOf(e)&&this.options.ns.push(e)}removeNamespaces(e){let t=this.options.ns.indexOf(e);t>-1&&this.options.ns.splice(t,1)}getResource(e,t,n,r={}){let a,o=void 0!==r.keySeparator?r.keySeparator:this.options.keySeparator,i=void 0!==r.ignoreJSONStructure?r.ignoreJSONStructure:this.options.ignoreJSONStructure;e.indexOf(".")>-1?a=e.split("."):(a=[e,t],n&&(Array.isArray(n)?a.push(...n):oX(n)&&o?a.push(...n.split(o)):a.push(n)));let s=o5(this.data,a);return(!s&&!t&&!n&&e.indexOf(".")>-1&&(e=a[0],t=a[1],n=a.slice(2).join(".")),!s&&i&&oX(n))?ir(this.data?.[e]?.[t],n,o):s}addResource(e,t,n,r,a={silent:!1}){let o=void 0!==a.keySeparator?a.keySeparator:this.options.keySeparator,i=[e,t];n&&(i=i.concat(o?n.split(o):n)),e.indexOf(".")>-1&&(i=e.split("."),r=t,t=i[1]),this.addNamespaces(t),o6(this.data,i,r),a.silent||this.emit("added",e,t,n,r)}addResources(e,t,n,r={silent:!1}){for(let r in n)(oX(n[r])||Array.isArray(n[r]))&&this.addResource(e,t,r,n[r],{silent:!0});r.silent||this.emit("added",e,t,n)}addResourceBundle(e,t,n,r,a,o={silent:!1,skipCopy:!1}){let i=[e,t];e.indexOf(".")>-1&&(i=e.split("."),r=n,n=t,t=i[1]),this.addNamespaces(t);let s=o5(this.data,i)||{};o.skipCopy||(n=JSON.parse(JSON.stringify(n))),r?o9(s,n,a):s={...s,...n},o6(this.data,i,s),o.silent||this.emit("added",e,t,n)}removeResourceBundle(e,t){this.hasResourceBundle(e,t)&&delete this.data[e][t],this.removeNamespaces(t),this.emit("removed",e,t)}hasResourceBundle(e,t){return void 0!==this.getResource(e,t)}getResourceBundle(e,t){return t||(t=this.options.defaultNS),this.getResource(e,t)}getDataByLanguage(e){return this.data[e]}hasLanguageSomeTranslations(e){let t=this.getDataByLanguage(e);return!!(t&&Object.keys(t)||[]).find(e=>t[e]&&Object.keys(t[e]).length>0)}toJSON(){return this.data}}var ic={processors:{},addPostProcessor(e){this.processors[e.name]=e},handle(e,t,n,r,a){return e.forEach(e=>{t=this.processors[e]?.process(t,n,r,a)??t}),t}};let id=Symbol("i18next/PATH_KEY");function im(e,t){let n,r,a,{[id]:o}=e((r=[],(a=Object.create(null)).get=(e,t)=>(n?.revoke?.(),t===id)?r:(r.push(t),(n=Proxy.revocable(e,a)).proxy),Proxy.revocable(Object.create(null),a).proxy));return o.join(t?.keySeparator??".")}let ip={},ih=e=>!oX(e)&&"boolean"!=typeof e&&"number"!=typeof e;class ig extends il{constructor(e,t={}){super(),((e,t,n)=>{e.forEach(e=>{t[e]&&(n[e]=t[e])})})(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=t,void 0===this.options.keySeparator&&(this.options.keySeparator="."),this.logger=is.create("translator")}changeLanguage(e){e&&(this.language=e)}exists(e,t={interpolation:{}}){let n={...t};if(null==e)return!1;let r=this.resolve(e,n);if(r?.res===void 0)return!1;let a=ih(r.res);return!1!==n.returnObjects||!a}extractFromKey(e,t){let n=void 0!==t.nsSeparator?t.nsSeparator:this.options.nsSeparator;void 0===n&&(n=":");let r=void 0!==t.keySeparator?t.keySeparator:this.options.keySeparator,a=t.ns||this.options.defaultNS||[],o=n&&e.indexOf(n)>-1,i=!this.options.userDefinedKeySeparator&&!t.keySeparator&&!this.options.userDefinedNsSeparator&&!t.nsSeparator&&!((e,t,n)=>{t=t||"",n=n||"";let r=ie.filter(e=>0>t.indexOf(e)&&0>n.indexOf(e));if(0===r.length)return!0;let a=it.getRegExp(`(${r.map(e=>"?"===e?"\\?":e).join("|")})`),o=!a.test(e);if(!o){let t=e.indexOf(n);t>0&&!a.test(e.substring(0,t))&&(o=!0)}return o})(e,n,r);if(o&&!i){let t=e.match(this.interpolator.nestingRegexp);if(t&&t.length>0)return{key:e,namespaces:oX(a)?[a]:a};let o=e.split(n);(n!==r||n===r&&this.options.ns.indexOf(o[0])>-1)&&(a=o.shift()),e=o.join(r)}return{key:e,namespaces:oX(a)?[a]:a}}translate(e,t,n){let r="object"==typeof t?{...t}:t;if("object"!=typeof r&&this.options.overloadTranslationOptionHandler&&(r=this.options.overloadTranslationOptionHandler(arguments)),"object"==typeof r&&(r={...r}),r||(r={}),null==e)return"";"function"==typeof e&&(e=im(e,{...this.options,...r})),Array.isArray(e)||(e=[String(e)]);let a=void 0!==r.returnDetails?r.returnDetails:this.options.returnDetails,o=void 0!==r.keySeparator?r.keySeparator:this.options.keySeparator,{key:i,namespaces:s}=this.extractFromKey(e[e.length-1],r),l=s[s.length-1],u=void 0!==r.nsSeparator?r.nsSeparator:this.options.nsSeparator;void 0===u&&(u=":");let c=r.lng||this.language,d=r.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(c?.toLowerCase()==="cimode")return d?a?{res:`${l}${u}${i}`,usedKey:i,exactUsedKey:i,usedLng:c,usedNS:l,usedParams:this.getUsedParamsDetails(r)}:`${l}${u}${i}`:a?{res:i,usedKey:i,exactUsedKey:i,usedLng:c,usedNS:l,usedParams:this.getUsedParamsDetails(r)}:i;let m=this.resolve(e,r),p=m?.res,f=m?.usedKey||i,h=m?.exactUsedKey||i,g=void 0!==r.joinArrays?r.joinArrays:this.options.joinArrays,y=!this.i18nFormat||this.i18nFormat.handleAsObject,v=void 0!==r.count&&!oX(r.count),b=ig.hasDefaultValue(r),w=v?this.pluralResolver.getSuffix(c,r.count,r):"",E=r.ordinal&&v?this.pluralResolver.getSuffix(c,r.count,{ordinal:!1}):"",x=v&&!r.ordinal&&0===r.count,D=x&&r[`defaultValue${this.options.pluralSeparator}zero`]||r[`defaultValue${w}`]||r[`defaultValue${E}`]||r.defaultValue,_=p;y&&!p&&b&&(_=D);let S=ih(_),C=Object.prototype.toString.apply(_);if(y&&_&&S&&0>["[object Number]","[object Function]","[object RegExp]"].indexOf(C)&&!(oX(g)&&Array.isArray(_))){if(!r.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");let e=this.options.returnedObjectHandler?this.options.returnedObjectHandler(f,_,{...r,ns:s}):`key '${i} (${this.language})' returned an object instead of string.`;return a?(m.res=e,m.usedParams=this.getUsedParamsDetails(r),m):e}if(o){let e=Array.isArray(_),t=e?[]:{},n=e?h:f;for(let e in _)if(Object.prototype.hasOwnProperty.call(_,e)){let a=`${n}${o}${e}`;b&&!p?t[e]=this.translate(a,{...r,defaultValue:ih(D)?D[e]:void 0,...{joinArrays:!1,ns:s}}):t[e]=this.translate(a,{...r,joinArrays:!1,ns:s}),t[e]===a&&(t[e]=_[e])}p=t}}else if(y&&oX(g)&&Array.isArray(p))(p=p.join(g))&&(p=this.extendTranslation(p,e,r,n));else{let t=!1,a=!1;!this.isValidLookup(p)&&b&&(t=!0,p=D),this.isValidLookup(p)||(a=!0,p=i);let s=(r.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&a?void 0:p,d=b&&D!==p&&this.options.updateMissing;if(a||t||d){if(this.logger.log(d?"updateKey":"missingKey",c,l,i,d?D:p),o){let e=this.resolve(i,{...r,keySeparator:!1});e&&e.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}let e=[],t=this.languageUtils.getFallbackCodes(this.options.fallbackLng,r.lng||this.language);if("fallback"===this.options.saveMissingTo&&t&&t[0])for(let n=0;n<t.length;n++)e.push(t[n]);else"all"===this.options.saveMissingTo?e=this.languageUtils.toResolveHierarchy(r.lng||this.language):e.push(r.lng||this.language);let n=(e,t,n)=>{let a=b&&n!==p?n:s;this.options.missingKeyHandler?this.options.missingKeyHandler(e,l,t,a,d,r):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(e,l,t,a,d,r),this.emit("missingKey",e,l,t,p)};this.options.saveMissing&&(this.options.saveMissingPlurals&&v?e.forEach(e=>{let t=this.pluralResolver.getSuffixes(e,r);x&&r[`defaultValue${this.options.pluralSeparator}zero`]&&0>t.indexOf(`${this.options.pluralSeparator}zero`)&&t.push(`${this.options.pluralSeparator}zero`),t.forEach(t=>{n([e],i+t,r[`defaultValue${t}`]||D)})}):n(e,i,D))}p=this.extendTranslation(p,e,r,m,n),a&&p===i&&this.options.appendNamespaceToMissingKey&&(p=`${l}${u}${i}`),(a||t)&&this.options.parseMissingKeyHandler&&(p=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${l}${u}${i}`:i,t?p:void 0,r))}return a?(m.res=p,m.usedParams=this.getUsedParamsDetails(r),m):p}extendTranslation(e,t,n,r,a){if(this.i18nFormat?.parse)e=this.i18nFormat.parse(e,{...this.options.interpolation.defaultVariables,...n},n.lng||this.language||r.usedLng,r.usedNS,r.usedKey,{resolved:r});else if(!n.skipInterpolation){let o;n.interpolation&&this.interpolator.init({...n,...{interpolation:{...this.options.interpolation,...n.interpolation}}});let i=oX(e)&&(n?.interpolation?.skipOnVariables!==void 0?n.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);if(i){let t=e.match(this.interpolator.nestingRegexp);o=t&&t.length}let s=n.replace&&!oX(n.replace)?n.replace:n;if(this.options.interpolation.defaultVariables&&(s={...this.options.interpolation.defaultVariables,...s}),e=this.interpolator.interpolate(e,s,n.lng||this.language||r.usedLng,n),i){let t=e.match(this.interpolator.nestingRegexp);o<(t&&t.length)&&(n.nest=!1)}!n.lng&&r&&r.res&&(n.lng=this.language||r.usedLng),!1!==n.nest&&(e=this.interpolator.nest(e,(...e)=>a?.[0]!==e[0]||n.context?this.translate(...e,t):(this.logger.warn(`It seems you are nesting recursively key: ${e[0]} in key: ${t[0]}`),null),n)),n.interpolation&&this.interpolator.reset()}let o=n.postProcess||this.options.postProcess,i=oX(o)?[o]:o;return null!=e&&i?.length&&!1!==n.applyPostProcessor&&(e=ic.handle(i,e,t,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...r,usedParams:this.getUsedParamsDetails(n)},...n}:n,this)),e}resolve(e,t={}){let n,r,a,o,i;return oX(e)&&(e=[e]),e.forEach(e=>{if(this.isValidLookup(n))return;let s=this.extractFromKey(e,t),l=s.key;r=l;let u=s.namespaces;this.options.fallbackNS&&(u=u.concat(this.options.fallbackNS));let c=void 0!==t.count&&!oX(t.count),d=c&&!t.ordinal&&0===t.count,m=void 0!==t.context&&(oX(t.context)||"number"==typeof t.context)&&""!==t.context,p=t.lngs?t.lngs:this.languageUtils.toResolveHierarchy(t.lng||this.language,t.fallbackLng);u.forEach(e=>{this.isValidLookup(n)||(i=e,!ip[`${p[0]}-${e}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(i)&&(ip[`${p[0]}-${e}`]=!0,this.logger.warn(`key "${r}" for languages "${p.join(", ")}" won't get resolved as namespace "${i}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),p.forEach(r=>{let i;if(this.isValidLookup(n))return;o=r;let s=[l];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(s,l,r,e,t);else{let e;c&&(e=this.pluralResolver.getSuffix(r,t.count,t));let n=`${this.options.pluralSeparator}zero`,a=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(c&&(t.ordinal&&0===e.indexOf(a)&&s.push(l+e.replace(a,this.options.pluralSeparator)),s.push(l+e),d&&s.push(l+n)),m){let r=`${l}${this.options.contextSeparator||"_"}${t.context}`;s.push(r),c&&(t.ordinal&&0===e.indexOf(a)&&s.push(r+e.replace(a,this.options.pluralSeparator)),s.push(r+e),d&&s.push(r+n))}}for(;i=s.pop();)this.isValidLookup(n)||(a=i,n=this.getResource(r,e,i,t))}))})}),{res:n,usedKey:r,exactUsedKey:a,usedLng:o,usedNS:i}}isValidLookup(e){return void 0!==e&&!(!this.options.returnNull&&null===e)&&!(!this.options.returnEmptyString&&""===e)}getResource(e,t,n,r={}){return this.i18nFormat?.getResource?this.i18nFormat.getResource(e,t,n,r):this.resourceStore.getResource(e,t,n,r)}getUsedParamsDetails(e={}){let t=e.replace&&!oX(e.replace),n=t?e.replace:e;if(t&&void 0!==e.count&&(n.count=e.count),this.options.interpolation.defaultVariables&&(n={...this.options.interpolation.defaultVariables,...n}),!t)for(let e of(n={...n},["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"]))delete n[e];return n}static hasDefaultValue(e){let t="defaultValue";for(let n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t===n.substring(0,t.length)&&void 0!==e[n])return!0;return!1}}class iy{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=is.create("languageUtils")}getScriptPartFromCode(e){if(!(e=ia(e))||0>e.indexOf("-"))return null;let t=e.split("-");return 2===t.length||(t.pop(),"x"===t[t.length-1].toLowerCase())?null:this.formatLanguageCode(t.join("-"))}getLanguagePartFromCode(e){if(!(e=ia(e))||0>e.indexOf("-"))return e;let t=e.split("-");return this.formatLanguageCode(t[0])}formatLanguageCode(e){if(oX(e)&&e.indexOf("-")>-1){let t;try{t=Intl.getCanonicalLocales(e)[0]}catch(e){}return(t&&this.options.lowerCaseLng&&(t=t.toLowerCase()),t)?t:this.options.lowerCaseLng?e.toLowerCase():e}return this.options.cleanCode||this.options.lowerCaseLng?e.toLowerCase():e}isSupportedCode(e){return("languageOnly"===this.options.load||this.options.nonExplicitSupportedLngs)&&(e=this.getLanguagePartFromCode(e)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(e)>-1}getBestMatchFromCodes(e){let t;return e?(e.forEach(e=>{if(t)return;let n=this.formatLanguageCode(e);(!this.options.supportedLngs||this.isSupportedCode(n))&&(t=n)}),!t&&this.options.supportedLngs&&e.forEach(e=>{if(t)return;let n=this.getScriptPartFromCode(e);if(this.isSupportedCode(n))return t=n;let r=this.getLanguagePartFromCode(e);if(this.isSupportedCode(r))return t=r;t=this.options.supportedLngs.find(e=>{if(e===r||!(0>e.indexOf("-")&&0>r.indexOf("-"))&&(e.indexOf("-")>0&&0>r.indexOf("-")&&e.substring(0,e.indexOf("-"))===r||0===e.indexOf(r)&&r.length>1))return e})}),t||(t=this.getFallbackCodes(this.options.fallbackLng)[0]),t):null}getFallbackCodes(e,t){if(!e)return[];if("function"==typeof e&&(e=e(t)),oX(e)&&(e=[e]),Array.isArray(e))return e;if(!t)return e.default||[];let n=e[t];return n||(n=e[this.getScriptPartFromCode(t)]),n||(n=e[this.formatLanguageCode(t)]),n||(n=e[this.getLanguagePartFromCode(t)]),n||(n=e.default),n||[]}toResolveHierarchy(e,t){let n=this.getFallbackCodes((!1===t?[]:t)||this.options.fallbackLng||[],e),r=[],a=e=>{e&&(this.isSupportedCode(e)?r.push(e):this.logger.warn(`rejecting language code not found in supportedLngs: ${e}`))};return oX(e)&&(e.indexOf("-")>-1||e.indexOf("_")>-1)?("languageOnly"!==this.options.load&&a(this.formatLanguageCode(e)),"languageOnly"!==this.options.load&&"currentOnly"!==this.options.load&&a(this.getScriptPartFromCode(e)),"currentOnly"!==this.options.load&&a(this.getLanguagePartFromCode(e))):oX(e)&&a(this.formatLanguageCode(e)),n.forEach(e=>{0>r.indexOf(e)&&a(this.formatLanguageCode(e))}),r}}let iv={zero:0,one:1,two:2,few:3,many:4,other:5},ib={select:e=>1===e?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class iw{constructor(e,t={}){this.languageUtils=e,this.options=t,this.logger=is.create("pluralResolver"),this.pluralRulesCache={}}addRule(e,t){this.rules[e]=t}clearCache(){this.pluralRulesCache={}}getRule(e,t={}){let n,r=ia("dev"===e?"en":e),a=t.ordinal?"ordinal":"cardinal",o=JSON.stringify({cleanedCode:r,type:a});if(o in this.pluralRulesCache)return this.pluralRulesCache[o];try{n=new Intl.PluralRules(r,{type:a})}catch(a){if(!Intl)return this.logger.error("No Intl support, please use an Intl polyfill!"),ib;if(!e.match(/-|_/))return ib;let r=this.languageUtils.getLanguagePartFromCode(e);n=this.getRule(r,t)}return this.pluralRulesCache[o]=n,n}needsPlural(e,t={}){let n=this.getRule(e,t);return n||(n=this.getRule("dev",t)),n?.resolvedOptions().pluralCategories.length>1}getPluralFormsOfKey(e,t,n={}){return this.getSuffixes(e,n).map(e=>`${t}${e}`)}getSuffixes(e,t={}){let n=this.getRule(e,t);return(n||(n=this.getRule("dev",t)),n)?n.resolvedOptions().pluralCategories.sort((e,t)=>iv[e]-iv[t]).map(e=>`${this.options.prepend}${t.ordinal?`ordinal${this.options.prepend}`:""}${e}`):[]}getSuffix(e,t,n={}){let r=this.getRule(e,n);return r?`${this.options.prepend}${n.ordinal?`ordinal${this.options.prepend}`:""}${r.select(t)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix("dev",t,n))}}let iE=(e,t,n,r=".",a=!0)=>{let o,i=void 0!==(o=o5(e,n))?o:o5(t,n);return!i&&a&&oX(n)&&void 0===(i=ir(e,n,r))&&(i=ir(t,n,r)),i};class ix{constructor(e={}){this.logger=is.create("interpolator"),this.options=e,this.format=e?.interpolation?.format||(e=>e),this.init(e)}init(e={}){e.interpolation||(e.interpolation={escapeValue:!0});let{escape:t,escapeValue:n,useRawValueToEscape:r,prefix:a,prefixEscaped:o,suffix:i,suffixEscaped:s,formatSeparator:l,unescapeSuffix:u,unescapePrefix:c,nestingPrefix:d,nestingPrefixEscaped:m,nestingSuffix:p,nestingSuffixEscaped:f,nestingOptionsSeparator:h,maxReplaces:g,alwaysFormat:y}=e.interpolation;this.escape=void 0!==t?t:o7,this.escapeValue=void 0===n||n,this.useRawValueToEscape=void 0!==r&&r,this.prefix=a?a.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"):o||"{{",this.suffix=i?i.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"):s||"}}",this.formatSeparator=l||",",this.unescapePrefix=u?"":c||"-",this.unescapeSuffix=this.unescapePrefix?"":u||"",this.nestingPrefix=d?d.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"):m||"$t(".replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),this.nestingSuffix=p?p.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"):f||")".replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),this.nestingOptionsSeparator=h||",",this.maxReplaces=g||1e3,this.alwaysFormat=void 0!==y&&y,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){let e=(e,t)=>e?.source===t?(e.lastIndex=0,e):RegExp(t,"g");this.regexp=e(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=e(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=e(this.nestingRegexp,`${this.nestingPrefix}((?:[^()"']+|"[^"]*"|'[^']*'|\\((?:[^()]|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`)}interpolate(e,t,n,r){let a,o,i,s=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},l=e=>{if(0>e.indexOf(this.formatSeparator)){let a=iE(t,s,e,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(a,void 0,n,{...r,...t,interpolationkey:e}):a}let a=e.split(this.formatSeparator),o=a.shift().trim(),i=a.join(this.formatSeparator).trim();return this.format(iE(t,s,o,this.options.keySeparator,this.options.ignoreJSONStructure),i,n,{...r,...t,interpolationkey:o})};this.resetRegExp();let u=r?.missingInterpolationHandler||this.options.missingInterpolationHandler,c=r?.interpolation?.skipOnVariables!==void 0?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:e=>e.replace(/\$/g,"$$$$")},{regex:this.regexp,safeValue:e=>this.escapeValue?this.escape(e).replace(/\$/g,"$$$$"):e.replace(/\$/g,"$$$$")}].forEach(t=>{for(i=0;a=t.regex.exec(e);){let n=a[1].trim();if(void 0===(o=l(n)))if("function"==typeof u){let t=u(e,a,r);o=oX(t)?t:""}else if(r&&Object.prototype.hasOwnProperty.call(r,n))o="";else if(c){o=a[0];continue}else this.logger.warn(`missed to pass in variable ${n} for interpolating ${e}`),o="";else oX(o)||this.useRawValueToEscape||(o=o0(o));let s=t.safeValue(o);if(e=e.replace(a[0],s),c?(t.regex.lastIndex+=o.length,t.regex.lastIndex-=a[0].length):t.regex.lastIndex=0,++i>=this.maxReplaces)break}}),e}nest(e,t,n={}){let r,a,o,i=(e,t)=>{let n=this.nestingOptionsSeparator;if(0>e.indexOf(n))return e;let r=e.split(RegExp(`${n}[ ]*{`)),a=`{${r[1]}`;e=r[0];let i=(a=this.interpolate(a,o)).match(/'/g),s=a.match(/"/g);((i?.length??0)%2!=0||s)&&s.length%2==0||(a=a.replace(/'/g,'"'));try{o=JSON.parse(a),t&&(o={...t,...o})}catch(t){return this.logger.warn(`failed parsing options string in nesting for key ${e}`,t),`${e}${n}${a}`}return o.defaultValue&&o.defaultValue.indexOf(this.prefix)>-1&&delete o.defaultValue,e};for(;r=this.nestingRegexp.exec(e);){let s=[];(o=(o={...n}).replace&&!oX(o.replace)?o.replace:o).applyPostProcessor=!1,delete o.defaultValue;let l=/{.*}/.test(r[1])?r[1].lastIndexOf("}")+1:r[1].indexOf(this.formatSeparator);if(-1!==l&&(s=r[1].slice(l).split(this.formatSeparator).map(e=>e.trim()).filter(Boolean),r[1]=r[1].slice(0,l)),(a=t(i.call(this,r[1].trim(),o),o))&&r[0]===e&&!oX(a))return a;oX(a)||(a=o0(a)),a||(this.logger.warn(`missed to resolve ${r[1]} for nesting ${e}`),a=""),s.length&&(a=s.reduce((e,t)=>this.format(e,t,n.lng,{...n,interpolationkey:r[1].trim()}),a.trim())),e=e.replace(r[0],a),this.regexp.lastIndex=0}return e}}let iD=e=>{let t={};return(n,r,a)=>{let o=a;a&&a.interpolationkey&&a.formatParams&&a.formatParams[a.interpolationkey]&&a[a.interpolationkey]&&(o={...o,[a.interpolationkey]:void 0});let i=r+JSON.stringify(o),s=t[i];return s||(s=e(ia(r),a),t[i]=s),s(n)}},i_=e=>(t,n,r)=>e(ia(n),r)(t);class iS{constructor(e={}){this.logger=is.create("formatter"),this.options=e,this.init(e)}init(e,t={interpolation:{}}){this.formatSeparator=t.interpolation.formatSeparator||",";let n=t.cacheInBuiltFormats?iD:i_;this.formats={number:n((e,t)=>{let n=new Intl.NumberFormat(e,{...t});return e=>n.format(e)}),currency:n((e,t)=>{let n=new Intl.NumberFormat(e,{...t,style:"currency"});return e=>n.format(e)}),datetime:n((e,t)=>{let n=new Intl.DateTimeFormat(e,{...t});return e=>n.format(e)}),relativetime:n((e,t)=>{let n=new Intl.RelativeTimeFormat(e,{...t});return e=>n.format(e,t.range||"day")}),list:n((e,t)=>{let n=new Intl.ListFormat(e,{...t});return e=>n.format(e)})}}add(e,t){this.formats[e.toLowerCase().trim()]=t}addCached(e,t){this.formats[e.toLowerCase().trim()]=iD(t)}format(e,t,n,r={}){let a=t.split(this.formatSeparator);if(a.length>1&&a[0].indexOf("(")>1&&0>a[0].indexOf(")")&&a.find(e=>e.indexOf(")")>-1)){let e=a.findIndex(e=>e.indexOf(")")>-1);a[0]=[a[0],...a.splice(1,e)].join(this.formatSeparator)}return a.reduce((e,t)=>{let{formatName:a,formatOptions:o}=(e=>{let t=e.toLowerCase().trim(),n={};if(e.indexOf("(")>-1){let r=e.split("(");t=r[0].toLowerCase().trim();let a=r[1].substring(0,r[1].length-1);"currency"===t&&0>a.indexOf(":")?n.currency||(n.currency=a.trim()):"relativetime"===t&&0>a.indexOf(":")?n.range||(n.range=a.trim()):a.split(";").forEach(e=>{if(e){let[t,...r]=e.split(":"),a=r.join(":").trim().replace(/^'+|'+$/g,""),o=t.trim();n[o]||(n[o]=a),"false"===a&&(n[o]=!1),"true"===a&&(n[o]=!0),isNaN(a)||(n[o]=parseInt(a,10))}})}return{formatName:t,formatOptions:n}})(t);if(this.formats[a]){let t=e;try{let i=r?.formatParams?.[r.interpolationkey]||{},s=i.locale||i.lng||r.locale||r.lng||n;t=this.formats[a](e,s,{...o,...r,...i})}catch(e){this.logger.warn(e)}return t}return this.logger.warn(`there was no format function for ${a}`),e},e)}}class iC extends il{constructor(e,t,n,r={}){super(),this.backend=e,this.store=t,this.services=n,this.languageUtils=n.languageUtils,this.options=r,this.logger=is.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=r.maxParallelReads||10,this.readingCalls=0,this.maxRetries=r.maxRetries>=0?r.maxRetries:5,this.retryTimeout=r.retryTimeout>=1?r.retryTimeout:350,this.state={},this.queue=[],this.backend?.init?.(n,r.backend,r)}queueLoad(e,t,n,r){let a={},o={},i={},s={};return e.forEach(e=>{let r=!0;t.forEach(t=>{let i=`${e}|${t}`;!n.reload&&this.store.hasResourceBundle(e,t)?this.state[i]=2:this.state[i]<0||(1===this.state[i]?void 0===o[i]&&(o[i]=!0):(this.state[i]=1,r=!1,void 0===o[i]&&(o[i]=!0),void 0===a[i]&&(a[i]=!0),void 0===s[t]&&(s[t]=!0)))}),r||(i[e]=!0)}),(Object.keys(a).length||Object.keys(o).length)&&this.queue.push({pending:o,pendingCount:Object.keys(o).length,loaded:{},errors:[],callback:r}),{toLoad:Object.keys(a),pending:Object.keys(o),toLoadLanguages:Object.keys(i),toLoadNamespaces:Object.keys(s)}}loaded(e,t,n){let r=e.split("|"),a=r[0],o=r[1];t&&this.emit("failedLoading",a,o,t),!t&&n&&this.store.addResourceBundle(a,o,n,void 0,void 0,{skipCopy:!0}),this.state[e]=t?-1:2,t&&n&&(this.state[e]=0);let i={};this.queue.forEach(n=>{((e,t,n,r)=>{let{obj:a,k:o}=o3(e,t,Object);a[o]=a[o]||[],a[o].push(n)})(n.loaded,[a],o),void 0!==n.pending[e]&&(delete n.pending[e],n.pendingCount--),t&&n.errors.push(t),0!==n.pendingCount||n.done||(Object.keys(n.loaded).forEach(e=>{i[e]||(i[e]={});let t=n.loaded[e];t.length&&t.forEach(t=>{void 0===i[e][t]&&(i[e][t]=!0)})}),n.done=!0,n.errors.length?n.callback(n.errors):n.callback())}),this.emit("loaded",i),this.queue=this.queue.filter(e=>!e.done)}read(e,t,n,r=0,a=this.retryTimeout,o){if(!e.length)return o(null,{});if(this.readingCalls>=this.maxParallelReads)return void this.waitingReads.push({lng:e,ns:t,fcName:n,tried:r,wait:a,callback:o});this.readingCalls++;let i=(i,s)=>{if(this.readingCalls--,this.waitingReads.length>0){let e=this.waitingReads.shift();this.read(e.lng,e.ns,e.fcName,e.tried,e.wait,e.callback)}i&&s&&r<this.maxRetries?setTimeout(()=>{this.read.call(this,e,t,n,r+1,2*a,o)},a):o(i,s)},s=this.backend[n].bind(this.backend);if(2===s.length){try{let n=s(e,t);n&&"function"==typeof n.then?n.then(e=>i(null,e)).catch(i):i(null,n)}catch(e){i(e)}return}return s(e,t,i)}prepareLoading(e,t,n={},r){if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),r&&r();oX(e)&&(e=this.languageUtils.toResolveHierarchy(e)),oX(t)&&(t=[t]);let a=this.queueLoad(e,t,n,r);if(!a.toLoad.length)return a.pending.length||r(),null;a.toLoad.forEach(e=>{this.loadOne(e)})}load(e,t,n){this.prepareLoading(e,t,{},n)}reload(e,t,n){this.prepareLoading(e,t,{reload:!0},n)}loadOne(e,t=""){let n=e.split("|"),r=n[0],a=n[1];this.read(r,a,"read",void 0,void 0,(n,o)=>{n&&this.logger.warn(`${t}loading namespace ${a} for language ${r} failed`,n),!n&&o&&this.logger.log(`${t}loaded namespace ${a} for language ${r}`,o),this.loaded(e,n,o)})}saveMissing(e,t,n,r,a,o={},i=()=>{}){if(this.services?.utils?.hasLoadedNamespace&&!this.services?.utils?.hasLoadedNamespace(t))return void this.logger.warn(`did not save key "${n}" as the namespace "${t}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");if(null!=n&&""!==n){if(this.backend?.create){let s={...o,isUpdate:a},l=this.backend.create.bind(this.backend);if(l.length<6)try{let a;(a=5===l.length?l(e,t,n,r,s):l(e,t,n,r))&&"function"==typeof a.then?a.then(e=>i(null,e)).catch(i):i(null,a)}catch(e){i(e)}else l(e,t,n,r,i,s)}e&&e[0]&&this.store.addResource(e[0],t,n,r)}}}let ik=()=>({debug:!1,initAsync:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:e=>{let t={};if("object"==typeof e[1]&&(t=e[1]),oX(e[1])&&(t.defaultValue=e[1]),oX(e[2])&&(t.tDescription=e[2]),"object"==typeof e[2]||"object"==typeof e[3]){let n=e[3]||e[2];Object.keys(n).forEach(e=>{t[e]=n[e]})}return t},interpolation:{escapeValue:!0,format:e=>e,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0},cacheInBuiltFormats:!0}),iP=e=>(oX(e.ns)&&(e.ns=[e.ns]),oX(e.fallbackLng)&&(e.fallbackLng=[e.fallbackLng]),oX(e.fallbackNS)&&(e.fallbackNS=[e.fallbackNS]),e.supportedLngs?.indexOf?.("cimode")<0&&(e.supportedLngs=e.supportedLngs.concat(["cimode"])),"boolean"==typeof e.initImmediate&&(e.initAsync=e.initImmediate),e),iR=()=>{};class iT extends il{constructor(e={},t){if(super(),this.options=iP(e),this.services={},this.logger=is,this.modules={external:[]},(e=>{Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach(t=>{"function"==typeof e[t]&&(e[t]=e[t].bind(e))})})(this),t&&!this.isInitialized&&!e.isClone){if(!this.options.initAsync)return this.init(e,t),this;setTimeout(()=>{this.init(e,t)},0)}}init(e={},t){this.isInitializing=!0,"function"==typeof e&&(t=e,e={}),null==e.defaultNS&&e.ns&&(oX(e.ns)?e.defaultNS=e.ns:0>e.ns.indexOf("translation")&&(e.defaultNS=e.ns[0]));let n=ik();this.options={...n,...this.options,...iP(e)},this.options.interpolation={...n.interpolation,...this.options.interpolation},void 0!==e.keySeparator&&(this.options.userDefinedKeySeparator=e.keySeparator),void 0!==e.nsSeparator&&(this.options.userDefinedNsSeparator=e.nsSeparator);let r=e=>e?"function"==typeof e?new e:e:null;if(!this.options.isClone){let e;this.modules.logger?is.init(r(this.modules.logger),this.options):is.init(null,this.options),e=this.modules.formatter?this.modules.formatter:iS;let t=new iy(this.options);this.store=new iu(this.options.resources,this.options);let a=this.services;a.logger=is,a.resourceStore=this.store,a.languageUtils=t,a.pluralResolver=new iw(t,{prepend:this.options.pluralSeparator,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),this.options.interpolation.format&&this.options.interpolation.format!==n.interpolation.format&&this.logger.deprecate("init: you are still using the legacy format function, please use the new approach: https://www.i18next.com/translation-function/formatting"),e&&(!this.options.interpolation.format||this.options.interpolation.format===n.interpolation.format)&&(a.formatter=r(e),a.formatter.init&&a.formatter.init(a,this.options),this.options.interpolation.format=a.formatter.format.bind(a.formatter)),a.interpolator=new ix(this.options),a.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},a.backendConnector=new iC(r(this.modules.backend),a.resourceStore,a,this.options),a.backendConnector.on("*",(e,...t)=>{this.emit(e,...t)}),this.modules.languageDetector&&(a.languageDetector=r(this.modules.languageDetector),a.languageDetector.init&&a.languageDetector.init(a,this.options.detection,this.options)),this.modules.i18nFormat&&(a.i18nFormat=r(this.modules.i18nFormat),a.i18nFormat.init&&a.i18nFormat.init(this)),this.translator=new ig(this.services,this.options),this.translator.on("*",(e,...t)=>{this.emit(e,...t)}),this.modules.external.forEach(e=>{e.init&&e.init(this)})}if(this.format=this.options.interpolation.format,t||(t=iR),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){let e=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);e.length>0&&"dev"!==e[0]&&(this.options.lng=e[0])}this.services.languageDetector||this.options.lng||this.logger.warn("init: no languageDetector is used and no lng is defined"),["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach(e=>{this[e]=(...t)=>this.store[e](...t)}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(e=>{this[e]=(...t)=>(this.store[e](...t),this)});let a=oQ(),o=()=>{let e=(e,n)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=!0,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),a.resolve(n),t(e,n)};if(this.languages&&!this.isInitialized)return e(null,this.t.bind(this));this.changeLanguage(this.options.lng,e)};return this.options.resources||!this.options.initAsync?o():setTimeout(o,0),a}loadResources(e,t=iR){let n=t,r=oX(e)?e:this.language;if("function"==typeof e&&(n=e),!this.options.resources||this.options.partialBundledLanguages){if(r?.toLowerCase()==="cimode"&&(!this.options.preload||0===this.options.preload.length))return n();let e=[],t=t=>{t&&"cimode"!==t&&this.services.languageUtils.toResolveHierarchy(t).forEach(t=>{"cimode"!==t&&0>e.indexOf(t)&&e.push(t)})};r?t(r):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(e=>t(e)),this.options.preload?.forEach?.(e=>t(e)),this.services.backendConnector.load(e,this.options.ns,e=>{e||this.resolvedLanguage||!this.language||this.setResolvedLanguage(this.language),n(e)})}else n(null)}reloadResources(e,t,n){let r=oQ();return"function"==typeof e&&(n=e,e=void 0),"function"==typeof t&&(n=t,t=void 0),e||(e=this.languages),t||(t=this.options.ns),n||(n=iR),this.services.backendConnector.reload(e,t,e=>{r.resolve(),n(e)}),r}use(e){if(!e)throw Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!e.type)throw Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return"backend"===e.type&&(this.modules.backend=e),("logger"===e.type||e.log&&e.warn&&e.error)&&(this.modules.logger=e),"languageDetector"===e.type&&(this.modules.languageDetector=e),"i18nFormat"===e.type&&(this.modules.i18nFormat=e),"postProcessor"===e.type&&ic.addPostProcessor(e),"formatter"===e.type&&(this.modules.formatter=e),"3rdParty"===e.type&&this.modules.external.push(e),this}setResolvedLanguage(e){if(e&&this.languages&&!(["cimode","dev"].indexOf(e)>-1)){for(let e=0;e<this.languages.length;e++){let t=this.languages[e];if(!(["cimode","dev"].indexOf(t)>-1)&&this.store.hasLanguageSomeTranslations(t)){this.resolvedLanguage=t;break}}!this.resolvedLanguage&&0>this.languages.indexOf(e)&&this.store.hasLanguageSomeTranslations(e)&&(this.resolvedLanguage=e,this.languages.unshift(e))}}changeLanguage(e,t){this.isLanguageChangingTo=e;let n=oQ();this.emit("languageChanging",e);let r=e=>{this.language=e,this.languages=this.services.languageUtils.toResolveHierarchy(e),this.resolvedLanguage=void 0,this.setResolvedLanguage(e)},a=(a,o)=>{o?this.isLanguageChangingTo===e&&(r(o),this.translator.changeLanguage(o),this.isLanguageChangingTo=void 0,this.emit("languageChanged",o),this.logger.log("languageChanged",o)):this.isLanguageChangingTo=void 0,n.resolve((...e)=>this.t(...e)),t&&t(a,(...e)=>this.t(...e))},o=t=>{e||t||!this.services.languageDetector||(t=[]);let n=oX(t)?t:t&&t[0],o=this.store.hasLanguageSomeTranslations(n)?n:this.services.languageUtils.getBestMatchFromCodes(oX(t)?[t]:t);o&&(this.language||r(o),this.translator.language||this.translator.changeLanguage(o),this.services.languageDetector?.cacheUserLanguage?.(o)),this.loadResources(o,e=>{a(e,o)})};return e||!this.services.languageDetector||this.services.languageDetector.async?!e&&this.services.languageDetector&&this.services.languageDetector.async?0===this.services.languageDetector.detect.length?this.services.languageDetector.detect().then(o):this.services.languageDetector.detect(o):o(e):o(this.services.languageDetector.detect()),n}getFixedT(e,t,n){let r=(e,t,...a)=>{let o,i;(o="object"!=typeof t?this.options.overloadTranslationOptionHandler([e,t].concat(a)):{...t}).lng=o.lng||r.lng,o.lngs=o.lngs||r.lngs,o.ns=o.ns||r.ns,""!==o.keyPrefix&&(o.keyPrefix=o.keyPrefix||n||r.keyPrefix);let s=this.options.keySeparator||".";return o.keyPrefix&&Array.isArray(e)?i=e.map(e=>("function"==typeof e&&(e=im(e,{...this.options,...t})),`${o.keyPrefix}${s}${e}`)):("function"==typeof e&&(e=im(e,{...this.options,...t})),i=o.keyPrefix?`${o.keyPrefix}${s}${e}`:e),this.t(i,o)};return oX(e)?r.lng=e:r.lngs=e,r.ns=t,r.keyPrefix=n,r}t(...e){return this.translator?.translate(...e)}exists(...e){return this.translator?.exists(...e)}setDefaultNamespace(e){this.options.defaultNS=e}hasLoadedNamespace(e,t={}){if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;let n=t.lng||this.resolvedLanguage||this.languages[0],r=!!this.options&&this.options.fallbackLng,a=this.languages[this.languages.length-1];if("cimode"===n.toLowerCase())return!0;let o=(e,t)=>{let n=this.services.backendConnector.state[`${e}|${t}`];return -1===n||0===n||2===n};if(t.precheck){let e=t.precheck(this,o);if(void 0!==e)return e}return!!(this.hasResourceBundle(n,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||o(n,e)&&(!r||o(a,e)))}loadNamespaces(e,t){let n=oQ();return this.options.ns?(oX(e)&&(e=[e]),e.forEach(e=>{0>this.options.ns.indexOf(e)&&this.options.ns.push(e)}),this.loadResources(e=>{n.resolve(),t&&t(e)}),n):(t&&t(),Promise.resolve())}loadLanguages(e,t){let n=oQ();oX(e)&&(e=[e]);let r=this.options.preload||[],a=e.filter(e=>0>r.indexOf(e)&&this.services.languageUtils.isSupportedCode(e));return a.length?(this.options.preload=r.concat(a),this.loadResources(e=>{n.resolve(),t&&t(e)}),n):(t&&t(),Promise.resolve())}dir(e){if(e||(e=this.resolvedLanguage||(this.languages?.length>0?this.languages[0]:this.language)),!e)return"rtl";try{let t=new Intl.Locale(e);if(t&&t.getTextInfo){let e=t.getTextInfo();if(e&&e.direction)return e.direction}}catch(e){}let t=this.services?.languageUtils||new iy(ik());return e.toLowerCase().indexOf("-latn")>1?"ltr":["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"].indexOf(t.getLanguagePartFromCode(e))>-1||e.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(e={},t){return new iT(e,t)}cloneInstance(e={},t=iR){let n=e.forkResourceStore;n&&delete e.forkResourceStore;let r={...this.options,...e,isClone:!0},a=new iT(r);return(void 0!==e.debug||void 0!==e.prefix)&&(a.logger=a.logger.clone(e)),["store","services","language"].forEach(e=>{a[e]=this[e]}),a.services={...this.services},a.services.utils={hasLoadedNamespace:a.hasLoadedNamespace.bind(a)},n&&(a.store=new iu(Object.keys(this.store.data).reduce((e,t)=>(e[t]={...this.store.data[t]},e[t]=Object.keys(e[t]).reduce((n,r)=>(n[r]={...e[t][r]},n),e[t]),e),{}),r),a.services.resourceStore=a.store),a.translator=new ig(a.services,r),a.translator.on("*",(e,...t)=>{a.emit(e,...t)}),a.init(r,t),a.translator.options=r,a.translator.backendConnector.services.utils={hasLoadedNamespace:a.hasLoadedNamespace.bind(a)},a}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}let iO=iT.createInstance();iO.createInstance=iT.createInstance,iO.createInstance,iO.dir,iO.init,iO.loadResources,iO.reloadResources,iO.use,iO.changeLanguage,iO.getFixedT,iO.t,iO.exists,iO.setDefaultNamespace,iO.hasLoadedNamespace,iO.loadNamespaces,iO.loadLanguages;let i$=iO.default||iO;function iN(e,t,n,r){return i$.t(t,{ns:e,defaultValue:n,...r})}function ij(e,t,n){return oJ[e]?iN("core",e,t??oJ[e],n):(console.error(`O3 Core Translations does not provide key '${e}'. The key itself is being rendered as text.`),e)}function iI(e,t){let n=window.getOpenmrsSpaBase().replace(/\/$/,""),r=iA(e,{openmrsBase:window.openmrsBase,openmrsSpaBase:n,...t});return e.startsWith("//")?r:r.replace(/^\/\//,"/")}function iA(e,t){return Object.keys(t).reduce((e,n)=>e.split("${"+n+"}").join(t[n]),e)}function iM({to:e,templateParams:t}){let n=window.getOpenmrsSpaBase().replace(/\/$/,""),r=iI(e,t).replace(window.location.origin,""),a=new URL(r,window.location.origin);if("http:"!=a.protocol&&"https:"!=a.protocol)throw console.error(`Received request to navigate to non-http URL: ${a.toString()}`),Error(ij("navigateNonHttp"));r.startsWith(n)?og(r):window.location.assign(r)}i$.on("initialized",function(){window.i18next.loadNamespaces(["core"])});let iL="openmrs:history";function iF(e){let t=JSON.parse(sessionStorage.getItem(iL)??"[]")||[];t.push(e),t.length>50&&(t=t.slice(-50)),sessionStorage.setItem(iL,JSON.stringify(t))}function iB(){0===JSON.parse(sessionStorage.getItem(iL)??"[]").length&&document.referrer&&iF(document.referrer),window.addEventListener("single-spa:routing-event",e=>{let t=iU();e.detail.originalEvent?.singleSpaTrigger=="replaceState"?(t[t.length-1]=window.location.href,sessionStorage.setItem(iL,JSON.stringify(t))):!e.detail.originalEvent?.singleSpa&&t.includes(window.location.href)?iV({toUrl:window.location.href}):t[t.length-1]!==window.location.href&&iF(window.location.href)})}function iU(){return JSON.parse(sessionStorage.getItem(iL)??"[]")}function iV({toUrl:e}){let t=iU(),n=t.lastIndexOf(e);if(-1!=n){let e=t.slice(0,n+1);iM({to:t[n]}),sessionStorage.setItem(iL,JSON.stringify(e))}else throw Error(`URL ${e} not found in history; cannot go back to it.`)}function iW(){sessionStorage.removeItem(iL)}let iH="${openmrsSpaBase}/login",iz={redirectAuthFailure:{enabled:{_type:rc.Boolean,_default:!0,_description:"Whether to redirect logged-out users to `redirectAuthFailure.url`"},url:{_type:rc.String,_default:iH,_validators:[ay.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:rc.Array,_default:[401],_elements:{_type:rc.Number,_validators:[ay.inRange(100,600)]},_description:"The HTTP error codes for which users will be redirected"},resolvePromise:{_type:rc.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:rc.Boolean,_default:!0,_description:"Whether openmrsFetch should support redirects returned from the backend"}};function iK(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}let iG="/ws/rest/v1",iZ="/ws/fhir2/R4",iY=`${iG}/session`;function iq(e){return e&&e.startsWith("http")?e:("/"!==e[0]&&(e="/"+e),window.openmrsBase+e)}function iJ(e,t={}){if("string"!=typeof e)throw Error("The first argument to @openmrs/api's openmrsFetch function must be a url string");if("object"!=typeof t)throw Error("The second argument to @openmrs/api's openmrsFetch function must be a plain object.");if(!window.openmrsBase)throw Error("@openmrs/api is running in a browser that doesn't have window.openmrsBase, which is provided by openmrs-module-spa's HTML file.");let n=iq(e);t.headers||(t.headers={}),e_(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 r=!1;try{let e=new URL(n,window.location.href),t=new URL(iq(iG),window.location.href),a=e.pathname.replace(/\/{2,}/g,"/"),o=t.pathname.replace(/\/{2,}/g,"/");r=e.origin===t.origin&&(a===o||a.startsWith(`${o}/`))}catch{}if(r){let e=!1;for(let[n,r]of Object.entries(t.headers))"disable-www-authenticate"===n.toLowerCase()&&(void 0===r?delete t.headers[n]:e=!0);e||(t.headers["Disable-WWW-Authenticate"]="true")}if(e.startsWith(iZ)){let e=new URL(n,window.location.toString());e.searchParams.has("_summary")||(e.searchParams.set("_summary","data"),n=e.toString())}let a=Error();return window.fetch(n,t).then(async e=>{let{redirectAuthFailure:r,followRedirects:o}=await r1("@openmrs/esm-api");if(e.ok){let t=e.headers.get("location");return(o&&t&&(n===iq(iY)||204===e.status)&&iM({to:t}),204===e.status)?(e.data=null,e):e.clone().text().then(t=>{try{t&&(e.data=JSON.parse(t))}catch(e){}return e})}return(n===iq(iY)&&403===e.status||r.enabled&&r.errors.includes(e.status))&&(iW(),iM({to:r.url||e.headers.get("location")||iH}),!0!==t.rejectAuthFailure)?r.resolvePromise?Promise.resolve():new Promise(()=>{}):e.clone().text().then(t=>{let r=t;try{r=JSON.parse(t)}catch(e){}throw new iX(n,e,r,a)},()=>{throw new iX(n,e,null,a)})})}class iX extends Error{constructor(e,t,n,r){super(),iK(this,"response",void 0),iK(this,"responseBody",void 0),this.message=`Server responded with ${t.status} (${t.statusText}) for url ${e}. Check err.responseBody or network tab in dev tools for more info`,r.message=this.message,this.responseBody=n,this.response=t,this.stack=`Stacktrace for outgoing request:
|
|
13
13
|
${r.stack}
|
|
14
14
|
Stacktrace for incoming response:
|
|
15
|
-
${this.stack}`}}let iQ=B("session",{loaded:!1,session:null}),i0=0,i1=null;function i4(){return i1||(iQ.getState().loaded&&i0>=Date.now()-6e4?null:i5())}function i2(e){let t=e?.includeAuthStatus??!0,n=e=>t?e:e.user,r=i4();return r?new Promise(e=>{let t=()=>{let t=iQ.getState();t.loaded&&(a(),e(n(t.session)))},a=iQ.subscribe(t);r.then(t,t)}):Promise.resolve(n(iQ.getState().session))}function i3(){return i4(),iQ}function i6(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 i5(e,t){i0=Date.now(),o??(o=i0);let n={};e&&t&&(n.Authorization=`Basic ${window.btoa(`${e}:${t}`)}`);let r=si(iJ(iY,{headers:n,rejectAuthFailure:!0})),a=()=>{i1===r&&(i1=null)};return r.then(a,a),i1=r,r}function i9(){iQ.setState({loaded:!0,session:{authenticated:!1,sessionId:""}},!0)}function i8(e,t){var n,r;if(void 0===t)return!e;if(!e)return!0;return n=e,r=t,("string"==typeof n?!K(r.privileges.find(e=>n===e.display)):Array.isArray(n)?n.every(e=>!K(r.privileges.find(t=>e===t.display))):(K(n)||console.error(`Could not understand privileges "${n}"`),!0))||!K(t.roles.find(e=>"System Developer"===e.display))}function i7(){let e,t;return new Promise(n=>{let r=r=>{r.loaded&&r.session.user&&(e=r.session.user,n(r.session.user),t&&t())};r(iQ.getState()),e||(t=iQ.subscribe(r))})}async function se(){return(await i2()).sessionLocation}async function st(e,t){return si(iJ(iY,{method:"POST",body:{sessionLocation:e},headers:{"Content-Type":"application/json"},rejectAuthFailure:!0,signal:t?.signal}))}async function sn(e,t){return await iJ(iY,{method:"POST",body:{locale:e},headers:{"Content-Type":"application/json"},signal:t?.signal}),i5()}async function sr(e,t,n){return n||(n=new AbortController),await iJ(`${iG}/user/${e}`,{method:"POST",body:{userProperties:t},headers:{"Content-Type":"application/json"},signal:n.signal}),i5()}async function sa(e,t=!1){let n=await iJ(t?`${iY}?rememberMe=true`:iY,{headers:{"X-Totp-Code":e}});return n.data?.authenticated?(await i5()).session:n.data}async function so(){try{await iJ(iY,{method:"DELETE",rejectAuthFailure:!0})}catch(e){if(!ss(e))throw e}i9(),await i5().catch(()=>{})}function si(e){return new Promise((t,n)=>{e.then(e=>{if("object"==typeof e?.data){let n={loaded:!0,session:e.data};iQ.setState(n,!0),t(n)}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)?n(sl(Error("The session endpoint did not respond with a session"))):n(sl(Error("The server is still starting up"),!0))}).catch(e=>{var r,a;if(ss(e)){"object"==typeof(r=e.responseBody)&&null!==r&&!1===r.authenticated?iQ.setState({loaded:!0,session:e.responseBody},!0):i9(),t(iQ.getState());return}(a=e)instanceof iX&&502===a.response.status&&!iQ.getState().loaded&&void 0!==o&&Date.now()-o<18e4?n(sl(e,!0)):(k(`Failed to fetch new session information: ${e}`),n(sl(e)))})})}function ss(e){return e instanceof iX&&(401===e.response.status||403===e.response.status)}function sl(e,t=!1){return iQ.getState().loaded||iQ.setState({loaded:!1,session:null,error:e instanceof Error?e:Error(String(e)),initializing:t},!0),iQ.getState()}function su(){return"development"===window.spaEnv||"true"===localStorage.getItem("openmrs:devtools")}iQ.subscribe(e=>{e.loaded&&e.session&&i6(e.session)});let sc={"webservices.rest":"2.24.0",fhir2:"1.0.0-SNAPSHOT"};function sd(){rZ("@openmrs/esm-api",iz),i5()}let sm="import-map-override:",sp="import-map-overrides-disabled",sf="import-map-overrides:change",sh=!1,sg=null,sy=null;async function sv(){return sy??(sy=sb().then(({map:e,complete:t})=>(t||(sy=null),e))),sy}async function sb(){let e=document.querySelectorAll('script[type="systemjs-importmap"]'),t=[],n=!0;for(let r=0;r<e.length;r++){let a=e[r];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){n=!1,console.warn(`[import-maps] Failed to parse import map from script tag at index ${r}`,e)}}return{map:sw(t),complete:n}}function sw(e){let t={imports:{}};for(let n of e)n?.imports&&Object.assign(t.imports,n.imports);return t}function sE(){let e={};try{let t=sC();for(let n=0;n<localStorage.length;n++){let r=localStorage.key(n);if(r?.startsWith(sm)){let n=r.slice(sm.length);if(!t.includes(n)){let t=localStorage.getItem(r);t&&(e[n]=t)}}}}catch(e){console.warn("[import-maps] Failed to read import-map overrides from localStorage",e)}return{imports:e}}async function sx(){let e=await sv();return sh?sw([e,sg??sE()]):e}async function sD(){return sv()}async function s_(){return sh?sw([await sv(),sE()]):sv()}function sS(e){if(!sh)return{imports:{}};if(e){let e={};for(let t=0;t<localStorage.length;t++){let n=localStorage.key(t);if(n?.startsWith(sm)){let t=localStorage.getItem(n);t&&(e[n.slice(sm.length)]=t)}}return{imports:e}}return sE()}function sC(){if(!sh)return[];try{let e=localStorage.getItem(sp);if(e){let t=JSON.parse(e);if(Array.isArray(t))return t}}catch{}return[]}function sk(e){return!!sh&&sC().includes(e)}function sP(e,t){if(!sh)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{localStorage.setItem(sm+e,t),window.dispatchEvent(new CustomEvent(sf))}catch(e){console.warn("[import-maps] Failed to write import-map override to localStorage",e)}}function sR(e){if(!sh)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{localStorage.removeItem(sm+e);let t=sC().filter(t=>t!==e);t.length>0?localStorage.setItem(sp,JSON.stringify(t)):localStorage.removeItem(sp),window.dispatchEvent(new CustomEvent(sf))}catch(e){console.warn("[import-maps] Failed to update import-map overrides in localStorage",e)}}function sT(){if(!sh)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{let e=[];for(let t=0;t<localStorage.length;t++){let n=localStorage.key(t);n?.startsWith(sm)&&e.push(n)}e.forEach(e=>localStorage.removeItem(e)),localStorage.removeItem(sp),window.dispatchEvent(new CustomEvent(sf))}catch(e){console.warn("[import-maps] Failed to clear import-map overrides from localStorage",e)}}function sO(e){if(!sh)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{let t=sC().filter(t=>t!==e);t.length>0?localStorage.setItem(sp,JSON.stringify(t)):localStorage.removeItem(sp),window.dispatchEvent(new CustomEvent(sf))}catch(e){console.warn("[import-maps] Failed to update import-map overrides in localStorage",e)}}let s$=!1;function sN(){!s$&&(s$=!0,(sh="development"===window.spaEnv)&&(sg=sE()))}function sj(e){return e.replace(/[\/\-@]/g,"_")}async function sI(e,t="./start",r){var a;let o,i=!r?.maxLoadingTime||r.maxLoadingTime<=0?6e5:r.maxLoadingTime;await Promise.race([sA(e,r?.importMap),new Promise((t,n)=>{o=setTimeout(()=>{var t;n(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=sj(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(n.S.default);let u=(await l.get(t))();if("object"!=typeof u||null===u){let t=`Container for ${e} did not return an ESM module as expected`;throw console.error(t),Error(t)}return u}async function sA(e,t){if("string"!=typeof e||0===e.trim().length){let e="Attempted to call importDynamic() without supplying a package to load";throw console.error(e),Error(e)}let n=sj(e);if(!window[n]){let n=t??await sM();if(!n.imports.hasOwnProperty(e)){let t=`Could not find the package ${e} defined in the current importmap`;throw console.error(t),Error(t)}let r=n.imports[e];r.startsWith("./")&&(r=window.spaBase+r.substring(1));let a=e in sS().imports;try{return await function(e){var t;let n=(t=window)[sL]??(t[sL]=new Map),r=n.get(e);if(r)return r;if(document.head.querySelector(`script[src="${e}"]`))return console.warn(`Script at ${e} already loaded. Not loading it again.`),Promise.resolve();let a=document.createElement("script");a.src=e,a.type="text/javascript",a.async=!0;let o=new Promise((t,r)=>{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(),n.delete(e),a.remove();let o=`Failed to load script from ${e}`;console.error(o,t),r(t.message??o)}a.addEventListener("load",s),a.addEventListener("error",l),document.head.appendChild(a)});return n.set(e,o),o}(r)}catch(e){return a&&E({kind:"error",title:ij("scriptLoadingFailed","Error: Script failed to load"),description:ij("scriptLoadingError","Failed to load overridden script from {{- url}}. Please check that the bundled script is available at the expected URL. Click the button below to reset all import map overrides.",{url:r}),actionButtonLabel:ij("resetOverrides","Reset overrides"),onActionButtonClick(){sT(),window.location.reload()}}),Promise.reject(e)}}return Promise.resolve()}async function sM(){return sx()}let sL=Symbol.for("__openmrs_script_loading");function sF(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 sB(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&&sF(t))}let sU="openmrs-routes:",sV="openmrs-routes:change",sW=!1,sH=null,sz=null;async function sK(){return sz??(sz=sG().then(({map:e,complete:t})=>(t||(sz=null),e))),sz}async function sG(){let e=document.querySelectorAll("script[type='openmrs-routes']"),t=[],n=!0;for(let r=0;r<e.length;r++){let a=e[r];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&&sB(e)&&t.push(e)}catch(e){n=!1,console.warn(`[route-maps] Failed to parse routes from script tag at index ${r}`,e)}}return{map:sZ(t),complete:n}}function sZ(e){let t={routes:{}};for(let n of e)n&&"object"==typeof n&&!Array.isArray(n)&&(Object.assign(t.routes,n.routes),void 0===t.version&&void 0!==n.version&&(t.version=n.version));return t}async function sY(){let e={version:void 0,routes:{}};try{let t=[];for(let e=0;e<localStorage.length;e++){let n=localStorage.key(e);if(n?.startsWith(sU)){let e=localStorage.getItem(n);e&&t.push({moduleName:n.slice(sU.length),raw:e})}}for(let n of(await Promise.allSettled(t.map(async({moduleName:e,raw:t})=>{let n=JSON.parse(t);if(sF(n))return{moduleName:e,routes:n};if("string"==typeof n&&n.startsWith("http")){let t=await fetch(n),r=await t.json();if(sF(r))return{moduleName:e,routes:r};throw Error(`${n} did not resolve to a valid OpenmrsAppRoutes object`)}throw Error(`Override for ${e} is neither a valid routes object nor a URL`)}))))"fulfilled"===n.status?e.routes[n.value.moduleName]=n.value.routes:console.warn("[route-maps] Failed to load route override",n.reason)}catch(e){console.warn("[route-maps] Failed to read route overrides from localStorage",e)}return e}async function sq(){let e=await sK();return sW?sZ([e,sH??await sY()]):e}async function sJ(){return sK()}async function sX(){return sW?sZ([await sK(),await sY()]):sK()}function sQ(){if(!sW)return{};let e={};try{for(let t=0;t<localStorage.length;t++){let n=localStorage.key(t);if(n?.startsWith(sU)){let t=localStorage.getItem(n);t&&(e[n.slice(sU.length)]=t)}}}catch(e){console.warn("[route-maps] Failed to read route overrides from localStorage",e)}return e}function s0(e,t){if(!sW)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{if("string"==typeof t)if(t.startsWith("http"))localStorage.setItem(sU+e,JSON.stringify(t));else{let n=JSON.parse(t);if(!sF(n))return void console.error(`The supplied routes for ${e} is not a valid OpenmrsAppRoutes object`,t);localStorage.setItem(sU+e,JSON.stringify(n))}else if(t instanceof URL)localStorage.setItem(sU+e,JSON.stringify(t.toString()));else{if(!sF(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(sU+e,JSON.stringify(t))}window.dispatchEvent(new CustomEvent(sV))}catch(e){console.warn("[route-maps] Failed to write route override to localStorage",e)}}function s1(e){if(!sW)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{localStorage.removeItem(sU+e),window.dispatchEvent(new CustomEvent(sV))}catch(e){console.warn("[route-maps] Failed to remove route override from localStorage",e)}}function s4(){if(!sW)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{let e=[];for(let t=0;t<localStorage.length;t++){let n=localStorage.key(t);n?.startsWith(sU)&&e.push(n)}e.forEach(e=>localStorage.removeItem(e)),window.dispatchEvent(new CustomEvent(sV))}catch(e){console.warn("[route-maps] Failed to clear route overrides from localStorage",e)}}let s2=null;function s3(){return s2||(s2=(sW="development"===window.spaEnv)?sY().then(e=>{sH=e}):Promise.resolve())}let s6=`${iG}/attachment`;function s5(e,t){return iJ(`${s6}/${e}`,{signal:t.signal})}function s9(e,t,n,r){return iJ(s8(e,t,r),{signal:n.signal})}function s8(e,t,n){return n?`${s6}?patient=${e}&encounter=${n}`:`${s6}?patient=${e}&includeEncounterless=${t}`}async function s7(e,t,n){let r=new FormData;return r.append("fileCaption",t.fileDescription),r.append("patient",e),n&&r.append("encounter",n),t.file?r.append("file",t.file,t.fileName):(r.append("file",new File([""],t.fileName),t.fileName),r.append("base64Content",t.base64Content)),iJ(`${s6}`,{method:"POST",body:r})}function le(e,t){return iJ(`${s6}/${e}`,{method:"DELETE",signal:t.signal})}async function lt(e,t){return e?(await iJ(`${iZ}/Patient/${e}`,t)).data:null}function ln(e,t){let n=new CustomEvent(`openmrs:${e}`,{detail:t??void 0,cancelable:!0,bubbles:!0});return window.dispatchEvent(n)}function lr(e,t){let n=e=>{t("detail"in e&&null!==e.detail?e.detail:void 0)};return window.addEventListener(`openmrs:${e}`,n),()=>{window.removeEventListener(`openmrs:${e}`,n)}}function la(e){return{uuid:e.uuid,display:e.display}}function lo(e=null,t=null){let n=new URLSearchParams;e&&n.set("tag",e),t&&n.set("q",t);let r=n.toString();return iJ(`${iG}/location${r?"?"+r:""}`).then(e=>e.data.results.map(la))}function li(e){return{uuid:e.uuid,display:e.display,name:e.name}}let ls=`${iG}/visittype`;function ll(e=ls){return iJ(e).then(e=>e.data.results.map(li))}var lu=((et={}).NEWVISIT="startVisit",et.EDITVISIT="editVisit",et.LOADING="loadingVisit",et),lc=((en={}).NOTSTARTED="notStarted",en.ONGOING="ongoing",en);let ld="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))",lm=function(){try{return JSON.parse(sessionStorage.getItem("openmrs:visitStoreState")||"null")}catch(e){return null}}()||{patientUuid:null,manuallySetVisitUuid:null};function lp(){return W("visit",lm)}function lf(e,t){lp().setState({patientUuid:e,manuallySetVisitUuid:t})}function lh(e,t){return iJ(`${iG}/visit`,{signal:t.signal,method:"POST",headers:{"Content-type":"application/json"},body:e})}function lg(e,t,n){return iJ(`${iG}/visit/${e}`,{signal:n.signal,method:"POST",headers:{"Content-type":"application/json"},body:t})}function ly(e,t,n){return iJ(`${iG}/visit?patient=${e}&v=${n??ld}`,{signal:t.signal,method:"GET",headers:{"Content-type":"application/json"}})}lp().subscribe(e=>{var t;t=e,sessionStorage.setItem("openmrs:visitStoreState",JSON.stringify(t))});class lv{static get version(){return"1.4.0"}static toString(){return"JavaScript Expression Parser (JSEP) v"+lv.version}static addUnaryOp(e){return lv.max_unop_len=Math.max(e.length,lv.max_unop_len),lv.unary_ops[e]=1,lv}static addBinaryOp(e,t,n){return lv.max_binop_len=Math.max(e.length,lv.max_binop_len),lv.binary_ops[e]=t,n?lv.right_associative.add(e):lv.right_associative.delete(e),lv}static addIdentifierChar(e){return lv.additional_identifier_chars.add(e),lv}static addLiteral(e,t){return lv.literals[e]=t,lv}static removeUnaryOp(e){return delete lv.unary_ops[e],e.length===lv.max_unop_len&&(lv.max_unop_len=lv.getMaxKeyLen(lv.unary_ops)),lv}static removeAllUnaryOps(){return lv.unary_ops={},lv.max_unop_len=0,lv}static removeIdentifierChar(e){return lv.additional_identifier_chars.delete(e),lv}static removeBinaryOp(e){return delete lv.binary_ops[e],e.length===lv.max_binop_len&&(lv.max_binop_len=lv.getMaxKeyLen(lv.binary_ops)),lv.right_associative.delete(e),lv}static removeAllBinaryOps(){return lv.binary_ops={},lv.max_binop_len=0,lv}static removeLiteral(e){return delete lv.literals[e],lv}static removeAllLiterals(){return lv.literals={},lv}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 lv(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 lv.binary_ops[e]||0}static isIdentifierStart(e){return e>=65&&e<=90||e>=97&&e<=122||e>=128&&!lv.binary_ops[String.fromCharCode(e)]||lv.additional_identifier_chars.has(String.fromCharCode(e))}static isIdentifierPart(e){return lv.isIdentifierStart(e)||lv.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(lv.hooks[e]){let n={context:this,node:t};return lv.hooks.run(e,n),n.node}return t}searchHook(e){if(lv.hooks[e]){let t={context:this};return lv.hooks[e].find(function(e){return e.call(t.context,t),t.node}),t.node}}gobbleSpaces(){let e=this.code;for(;e===lv.SPACE_CODE||e===lv.TAB_CODE||e===lv.LF_CODE||e===lv.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:lv.COMPOUND,body:e};return this.runHook("after-all",t)}gobbleExpressions(e){let t=[],n,r;for(;this.index<this.expr.length;)if((n=this.code)===lv.SEMCOL_CODE||n===lv.COMMA_CODE)this.index++;else if(r=this.gobbleExpression())t.push(r);else if(this.index<this.expr.length){if(n===e)break;this.throwError('Unexpected "'+this.char+'"')}return t}gobbleExpression(){let e=this.searchHook("gobble-expression")||this.gobbleBinaryExpression();return this.gobbleSpaces(),this.runHook("after-expression",e)}gobbleBinaryOp(){this.gobbleSpaces();let e=this.expr.substr(this.index,lv.max_binop_len),t=e.length;for(;t>0;){if(lv.binary_ops.hasOwnProperty(e)&&(!lv.isIdentifierStart(this.code)||this.index+e.length<this.expr.length&&!lv.isIdentifierPart(this.expr.charCodeAt(this.index+e.length))))return this.index+=t,e;e=e.substr(0,--t)}return!1}gobbleBinaryExpression(){let e,t,n,r,a,o,i,s,l;if(!(o=this.gobbleToken())||!(t=this.gobbleBinaryOp()))return o;for(a={value:t,prec:lv.binaryPrecedence(t),right_a:lv.right_associative.has(t)},(i=this.gobbleToken())||this.throwError("Expected expression after "+t),r=[o,a,i];t=this.gobbleBinaryOp();){if(0===(n=lv.binaryPrecedence(t))){this.index-=t.length;break}a={value:t,prec:n,right_a:lv.right_associative.has(t)},l=t;let s=e=>a.right_a&&e.right_a?n>e.prec:n<=e.prec;for(;r.length>2&&s(r[r.length-2]);)i=r.pop(),t=r.pop().value,o=r.pop(),e={type:lv.BINARY_EXP,operator:t,left:o,right:i},r.push(e);(e=this.gobbleToken())||this.throwError("Expected expression after "+l),r.push(a,e)}for(s=r.length-1,e=r[s];s>1;)e={type:lv.BINARY_EXP,operator:r[s-1].value,left:r[s-2],right:e},s-=2;return e}gobbleToken(){let e,t,n,r;if(this.gobbleSpaces(),r=this.searchHook("gobble-token"))return this.runHook("after-token",r);if(e=this.code,lv.isDecimalDigit(e)||e===lv.PERIOD_CODE)return this.gobbleNumericLiteral();if(e===lv.SQUOTE_CODE||e===lv.DQUOTE_CODE)r=this.gobbleStringLiteral();else if(e===lv.OBRACK_CODE)r=this.gobbleArray();else{for(n=(t=this.expr.substr(this.index,lv.max_unop_len)).length;n>0;){if(lv.unary_ops.hasOwnProperty(t)&&(!lv.isIdentifierStart(this.code)||this.index+t.length<this.expr.length&&!lv.isIdentifierPart(this.expr.charCodeAt(this.index+t.length)))){this.index+=n;let e=this.gobbleToken();return e||this.throwError("missing unaryOp argument"),this.runHook("after-token",{type:lv.UNARY_EXP,operator:t,argument:e,prefix:!0})}t=t.substr(0,--n)}lv.isIdentifierStart(e)?(r=this.gobbleIdentifier(),lv.literals.hasOwnProperty(r.name)?r={type:lv.LITERAL,value:lv.literals[r.name],raw:r.name}:r.name===lv.this_str&&(r={type:lv.THIS_EXP})):e===lv.OPAREN_CODE&&(r=this.gobbleGroup())}return r?(r=this.gobbleTokenProperty(r),this.runHook("after-token",r)):this.runHook("after-token",!1)}gobbleTokenProperty(e){this.gobbleSpaces();let t=this.code;for(;t===lv.PERIOD_CODE||t===lv.OBRACK_CODE||t===lv.OPAREN_CODE||t===lv.QUMARK_CODE;){let n;if(t===lv.QUMARK_CODE){if(this.expr.charCodeAt(this.index+1)!==lv.PERIOD_CODE)break;n=!0,this.index+=2,this.gobbleSpaces(),t=this.code}this.index++,t===lv.OBRACK_CODE?((e={type:lv.MEMBER_EXP,computed:!0,object:e,property:this.gobbleExpression()}).property||this.throwError('Unexpected "'+this.char+'"'),this.gobbleSpaces(),(t=this.code)!==lv.CBRACK_CODE&&this.throwError("Unclosed ["),this.index++):t===lv.OPAREN_CODE?e={type:lv.CALL_EXP,arguments:this.gobbleArguments(lv.CPAREN_CODE),callee:e}:(t===lv.PERIOD_CODE||n)&&(n&&this.index--,this.gobbleSpaces(),e={type:lv.MEMBER_EXP,computed:!1,object:e,property:this.gobbleIdentifier()}),n&&(e.optional=!0),this.gobbleSpaces(),t=this.code}return e}gobbleNumericLiteral(){let e="",t,n;for(;lv.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);if(this.code===lv.PERIOD_CODE)for(e+=this.expr.charAt(this.index++);lv.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++));lv.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);lv.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+e+this.char+")")}return n=this.code,lv.isIdentifierStart(n)?this.throwError("Variable names cannot start with a number ("+e+this.char+")"):(n===lv.PERIOD_CODE||1===e.length&&e.charCodeAt(0)===lv.PERIOD_CODE)&&this.throwError("Unexpected period"),{type:lv.LITERAL,value:parseFloat(e),raw:e}}gobbleStringLiteral(){let e="",t=this.index,n=this.expr.charAt(this.index++),r=!1;for(;this.index<this.expr.length;){let t=this.expr.charAt(this.index++);if(t===n){r=!0;break}if("\\"===t)switch(t=this.expr.charAt(this.index++)){case"n":e+="\n";break;case"r":e+="\r";break;case"t":e+=" ";break;case"b":e+="\b";break;case"f":e+="\f";break;case"v":e+="\v";break;default:e+=t}else e+=t}return r||this.throwError('Unclosed quote after "'+e+'"'),{type:lv.LITERAL,value:e,raw:this.expr.substring(t,this.index)}}gobbleIdentifier(){let e=this.code,t=this.index;for(lv.isIdentifierStart(e)?this.index++:this.throwError("Unexpected "+this.char);this.index<this.expr.length;)if(e=this.code,lv.isIdentifierPart(e))this.index++;else break;return{type:lv.IDENTIFIER,name:this.expr.slice(t,this.index)}}gobbleArguments(e){let t=[],n=!1,r=0;for(;this.index<this.expr.length;){this.gobbleSpaces();let a=this.code;if(a===e){n=!0,this.index++,e===lv.CPAREN_CODE&&r&&r>=t.length&&this.throwError("Unexpected token "+String.fromCharCode(e));break}if(a===lv.COMMA_CODE){if(this.index++,++r!==t.length){if(e===lv.CPAREN_CODE)this.throwError("Unexpected token ,");else if(e===lv.CBRACK_CODE)for(let e=t.length;e<r;e++)t.push(null)}}else if(t.length!==r&&0!==r)this.throwError("Expected comma");else{let e=this.gobbleExpression();e&&e.type!==lv.COMPOUND||this.throwError("Expected comma"),t.push(e)}}return n||this.throwError("Expected "+String.fromCharCode(e)),t}gobbleGroup(){this.index++;let e=this.gobbleExpressions(lv.CPAREN_CODE);if(this.code===lv.CPAREN_CODE)return(this.index++,1===e.length)?e[0]:!!e.length&&{type:lv.SEQUENCE_EXP,expressions:e};this.throwError("Unclosed (")}gobbleArray(){return this.index++,{type:lv.ARRAY_EXP,elements:this.gobbleArguments(lv.CBRACK_CODE)}}}Object.assign(lv,{hooks:new class{add(e,t,n){if("string"!=typeof arguments[0])for(let e in arguments[0])this.add(e,arguments[0][e],arguments[1]);else(Array.isArray(e)?e:[e]).forEach(function(e){this[e]=this[e]||[],t&&this[e][n?"unshift":"push"](t)},this)}run(e,t){this[e]=this[e]||[],this[e].forEach(function(e){e.call(t&&t.context?t.context:t,t)})}},plugins:new class{constructor(e){this.jsep=e,this.registered={}}register(...e){e.forEach(e=>{if("object"!=typeof e||!e.name||!e.init)throw Error("Invalid JSEP plugin format");this.registered[e.name]||(e.init(this.jsep),this.registered[e.name]=e)})}}(lv),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"}),lv.max_unop_len=lv.getMaxKeyLen(lv.unary_ops),lv.max_binop_len=lv.getMaxKeyLen(lv.binary_ops);let lb=e=>new lv(e).parse(),lw=Object.getOwnPropertyNames(class{});Object.getOwnPropertyNames(lv).filter(e=>!lw.includes(e)&&void 0===lb[e]).forEach(e=>{lb[e]=lv[e]}),lb.Jsep=lv,lb.plugins.register({name:"ternary",init(e){e.hooks.add("after-expression",function(t){if(t.node&&this.code===e.QUMARK_CODE){this.index++;let n=t.node,r=this.gobbleExpression();if(r||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===e.COLON_CODE){this.index++;let a=this.gobbleExpression();if(a||this.throwError("Expected expression"),t.node={type:"ConditionalExpression",test:n,consequent:r,alternate:a},n.operator&&e.binary_ops[n.operator]<=.9){let r=n;for(;r.right.operator&&e.binary_ops[r.right.operator]<=.9;)r=r.right;t.node.test=r.right,r.right=t.node,t.node=n}}else this.throwError("Expected :")}})}});let lE="ArrowFunctionExpression",lx={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)}},lD={...lx,Promise};function l_(e,t={}){return lT(e,t,lN)}async function lS(e,t={}){return lO(e,t,lN)}function lC(e,t={}){return lT(e,t,lj)}function lk(e,t={}){return lO(e,t,lj)}function lP(e,t={}){return lT(e,t,lI)}function lR(e,t={}){return lO(e,t,lI)}function lT(e,t={},n){if("string"!=typeof e&&("object"!=typeof e||!e||!("type"in e)))throw`Unknown expression type ${e}. Expressions must either be a string or pre-compiled string.`;if("string"==typeof e&&0===e.trim().length)throw{type:"Empty expression",message:"Expression cannot be an empty string"};null==t&&(t={});let r=lB(t,lx),a=lA("string"==typeof e?lb(e):e,r);if(n(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 lO(e,t={},n){if("string"!=typeof e&&("object"!=typeof e||!e||!("type"in e)))return Promise.reject(`Unknown expression type ${e}. Expressions must either be a string or pre-compiled string.`);if("string"==typeof e&&0===e.trim().length)throw{type:"Empty expression",message:"Expression cannot be an empty string"};null==t&&(t={});let r=lB(t,lD);return Promise.resolve(lA("string"==typeof e?lb(e):e,r)).then(t=>{if(n(t))return t;throw{type:"Invalid result",message:"string"==typeof e?`The expression ${e} did not produce a valid result`:"The expression did not produce a valid result"}})}function l$(e){return lb(e)}function lN(e){return"string"==typeof e||"number"==typeof e||"boolean"==typeof e||null==e||e instanceof Date}function lj(e){return"boolean"==typeof e}function lI(e){return"number"==typeof e}function lA(e,t){switch(e.type){case"UnaryExpression":var n,r,a,o,i,s,l,u,c,d,m,p,f,h=e,g=t;let y=lA(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 lA(v.left,b)&&lA(v.right,b);case"||":return lA(v.left,b)||lA(v.right,b);case"??":return lA(v.left,b)??lA(v.right,b)}let w=lA(v.left,b),E=lA(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 n=e,r=t,lA(n.test,r)?lA(n.consequent,r):lA(n.alternate,r);case"CallExpression":return lW(lL(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,n,r)=>{let a=e[r];return function e(t){if("string"==typeof t||"number"==typeof t||"boolean"==typeof t||"function"==typeof t||null===t||t instanceof RegExp)return!0;if("object"==typeof t){for(let n of Object.keys(t))if(!e(t[n]))return!1;return!0}if(Array.isArray(t)){for(let n of t)if(!e(n))break}return!1}(a)&&t.push([n,a]),t},[]));return lA(a.body,o.addVariables(t))}).bind(null);case"MemberExpression":return lW(lF(e,t));case"ArrayExpression":return i=e,s=t,i.elements?.map(lH(s));case"SequenceExpression":let D;return l=e,u=t,(D=l.expressions.map(lH(u)))[D.length-1];case"NewExpression":var _=e,S=t;if(_.callee&&"Identifier"===_.callee.type){let e=_.arguments?.map(lH(S));switch(_.callee.name){case"Date":return new Date(...e);case"RegExp":return new RegExp(...e);default:throw`Cannot instantiate object of type ${_.callee.name}`}}if(_.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,(lz(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 m=e,p=t,C=m.expressions?.map(lH(p))??[],(k=m.quasis?.map(lH(p))??[]).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:(f=e).cooked,tail:f.tail};default:throw`Expression evaluator does not support expression of type '${e.type}'`}}function lM(e,t){switch(e.type){case"Literal":return e.value;case"Identifier":return e.name;case"MemberExpression":return lM(e.property,t);default:throw`VisitExpressionName does not support expression of type '${e.type}'`}}function lL(e,t){let n=lV(e.callee,t);if(n===lU||e.optional&&null==n)return lU;let r=e.arguments?.map(lH(t));if(n){if("function"!=typeof n)throw`${lZ(e.callee)} is not a function`}else throw`No function named ${lZ(e.callee)} is defined in this context`;return n(...r)}function lF(e,t){let n=lV(e.object,t);if(n===lU||e.optional&&null==n)return lU;if(null===n)throw TypeError(`TypeError: cannot read properties of null (reading '${lG(e.property,t)}')`);if(void 0===n)switch(e.object.type){case"Identifier":{let n=lM(e.object,t);throw ReferenceError(`ReferenceError: ${n} is not defined`)}case"MemberExpression":throw TypeError(`TypeError: cannot read properties of undefined (reading '${lG(e.property,t)}')`);default:throw`VisitMemberExpression does not support operator '${e.object.type}' type`}if("object"!=typeof n&&"function"!=typeof n&&"string"!=typeof n&&"number"!=typeof n)throw`VisitMemberExpression does not support member access on type ${typeof n}`;let r=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}(lA(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);lz(r),function(e,t){if(lK.has(String(t)))return;let n=Object(e);for(;null!==n;){if(Object.hasOwn(n,t)){if(n===Object.prototype||n===Function.prototype)throw{type:"Illegal property access",message:`Cannot access the ${t} property of objects`};return}n=Object.getPrototypeOf(n)}}(n,r);let a=n[r];return"function"==typeof a?a.bind(n):a}function lB(e,t){let n={variables:{...e},globals:{...t},addVariables(e){return this.variables={...this.variables,...e},this}};return n.addVariables.bind(n),n}lb.plugins.register({name:"arrow",init(e){e.addBinaryOp("=>",.1,!0),e.hooks.add("gobble-expression",function(t){if(this.gobbleSpaces(),this.code===e.OPAREN_CODE){let n=this.index;if(this.index++,this.gobbleSpaces(),this.code===e.CPAREN_CODE){this.index++;let e=this.gobbleBinaryOp();if("=>"===e){let n=this.gobbleBinaryExpression();n||this.throwError("Expected expression after "+e),t.node={type:lE,params:null,body:n};return}}this.index=n}}),e.hooks.add("after-expression",function(t){!function t(n){n&&(Object.values(n).forEach(e=>{e&&"object"==typeof e&&t(e)}),"=>"===n.operator&&(n.type=lE,n.params=n.left?[n.left]:null,n.body=n.right,n.params&&n.params[0].type===e.SEQUENCE_EXP&&(n.params=n.params[0].expressions),delete n.left,delete n.right,delete n.operator))}(t.node)})}}),lb.plugins.register({name:"new",init(e){e.addUnaryOp("new"),e.hooks.add("after-token",function(t){let n=t.node;if(n&&"new"===n.operator){n.argument&&[e.CALL_EXP,e.MEMBER_EXP].includes(n.argument.type)||this.throwError("Expected new function()"),t.node=n.argument;let r=t.node;for(;r.type===e.MEMBER_EXP||r.type===e.CALL_EXP&&r.callee.type===e.MEMBER_EXP;)r=r.type===e.MEMBER_EXP?r.object:r.callee.object;r.type="NewExpression"}})}}),lb.plugins.register({name:"numbers",init(e){function t(e){return"x"===e||"X"===e?(this.index+=2,[[48,57],[65,70],[97,102]]):"b"===e||"B"===e?(this.index+=2,[[48,49]]):"o"===e||"O"===e||e>="0"&&e<="7"?(this.index+=e<="7"?1:2,[[48,55]]):null}function n(t){let n=this.index,r="",a=()=>{for(;e.isDecimalDigit(this.code)||95===this.code;)95===this.code?this.index++:r+=this.expr.charAt(this.index++)};a(),this.code===e.PERIOD_CODE&&(r+=this.expr.charAt(this.index++),a());let o=this.char;("e"===o||"E"===o)&&(r+=this.expr.charAt(this.index++),("+"===(o=this.char)||"-"===o)&&(r+=this.expr.charAt(this.index++)),a(),e.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+r+this.char+")"));let i=this.code;if(e.isIdentifierStart(i))this.throwError("Variable names cannot start with a number ("+r+this.char+")");else if(i===e.PERIOD_CODE){r.length>1&&this.throwError(`Unexpected period ${JSON.stringify({chCode:i,number:r},null,2)}`),this.index=n;return}t.node={type:e.LITERAL,value:parseFloat(r),raw:this.expr.substring(n,this.index)}}e.hooks.add("gobble-token",function(r){if(48===this.code){var 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,n.call(this,r);return}this.throwError("unexpected char within number")}r.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)&&n.call(this,r)})}}),lb.plugins.register({name:"regex",init(e){e.hooks.add("gobble-token",function(t){if(47===this.code){let n=++this.index,r=!1;for(;this.index<this.expr.length;){if(47===this.code&&!r){let r,a=this.expr.slice(n,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{r=new RegExp(a,o)}catch(e){this.throwError(e.message)}return t.node={type:e.LITERAL,value:r,raw:this.expr.slice(n-1,this.index)},t.node=this.gobbleTokenProperty(t.node),t.node}this.code===e.OBRACK_CODE?r=!0:r&&this.code===e.CBRACK_CODE&&(r=!1),this.index+=92===this.code?2:1}this.throwError("Unclosed Regex")}})}}),lb.plugins.register({name:"ternary",init(e){e.hooks.add("after-expression",function(t){if(t.node&&this.code===e.QUMARK_CODE){this.index++;let n=t.node,r=this.gobbleExpression();if(r||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===e.COLON_CODE){this.index++;let a=this.gobbleExpression();if(a||this.throwError("Expected expression"),t.node={type:"ConditionalExpression",test:n,consequent:r,alternate:a},n.operator&&e.binary_ops[n.operator]<=.9){let r=n;for(;r.right.operator&&e.binary_ops[r.right.operator]<=.9;)r=r.right;t.node.test=r.right,r.right=t.node,t.node=n}}else this.throwError("Expected :")}})}}),lb.plugins.register({name:"jsepTemplateLiteral",init(e){function t(e,n=!0){if(96===this.code){let t={type:"TemplateLiteral",quasis:[],expressions:[]},r="",a="",o=!1,i=this.expr.length,s=()=>t.quasis.push({type:"TemplateElement",value:{raw:a,cooked:r},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,n&&(e.node=this.gobbleTokenProperty(e.node)),e.node;if("$"===i&&"{"===this.expr.charAt(this.index+1))this.index+=2,s(),a="",r="",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":r+="\n";break;case"r":r+="\r";break;case"t":r+=" ";break;case"b":r+="\b";break;case"f":r+="\f";break;case"v":r+="\v";break;default:r+=i}else r+=i,a+=i}this.throwError("Unclosed `")}}e.hooks.add("gobble-token",t),e.hooks.add("after-token",function(n){if((n.node.type===e.IDENTIFIER||n.node.type===e.MEMBER_EXP)&&96===this.code)return n.node={type:"TaggedTemplateExpression",tag:n.node,quasi:t.bind(this)(n,!1)},n.node=this.gobbleTokenProperty(n.node),n.node})}}),lb.addBinaryOp("in",7),lb.addBinaryOp("??",1);let lU=Symbol("optional chain short-circuited");function lV(e,t){switch(e.type){case"MemberExpression":return lF(e,t);case"CallExpression":return lL(e,t);default:return lA(e,t)}}function lW(e){return e===lU?void 0:e}function lH(e){return function(t){return null===t?null:lA(t,e)}}function lz(e){if("__proto__"===e||"prototype"===e||"constructor"===e)throw{type:"Illegal property access",message:`Cannot access the ${e} property of objects`}}let lK=new Set(["toString","valueOf","hasOwnProperty"]);function lG(e,t){try{return lM(e,t)}catch{return"<computed>"}}function lZ(e){return e?"MemberExpression"===e.type?e.property?.name:e.name:null}function lY(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:{...lD},isLocalExpression:!1,variables:new Set};return lq("string"==typeof e?lb(e):e,t),[...t.variables]}function lq(e,t){switch(e.type){case"UnaryExpression":return r=e,a=t,lq(r.argument,a);case"BinaryExpression":return o=e,i=t,[lq(o.left,i),lq(o.right,i)].filter(Boolean);case"ConditionalExpression":return s=e,l=t,[lq(s.consequent,l),lq(s.test,l),lq(s.alternate,l)].filter(Boolean);case"CallExpression":let n;return u=e,c=t,n=lq(u.callee,c),u.arguments?.map(lJ(c)),n;case"ArrowFunctionExpression":var r,a,o,i,s,l,u,c,d,m,p,f,h,g,y,v,b=e,w=t;let E={...w};E.isLocalExpression=!0;let x=b.params?.map(lJ(E))??[],D=lq(b.body,E)??[];if(D&&Array.isArray(D))for(let e of D)x.includes(e)||w.variables.add(e);return;case"MemberExpression":var _=e,S=t;if(lq(_.object,S),_.computed)return void lq(_.property,S);let C={...S};C.isLocalExpression=!0,lq(_.property,C);return;case"ArrayExpression":return d=e,m=t,void d.elements?.map(lJ(m));case"SequenceExpression":return p=e,f=t,void p.expressions?.map(lJ(f));case"NewExpression":return h=e,g=t,void h.arguments?.map(lJ(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(lJ(v)),y.quasis?.map(lJ(v)));default:throw`Expression evaluator does not support expression of type '${e.type}'`}}function lJ(e){return function(t){return null===t?null:lq(t,e)}}let lX=W("feature-flags",{flags:function(){let e={};for(let t of Object.keys(localStorage))if(t.startsWith("openmrs:feature-flag:")){let n=t.replace("openmrs:feature-flag:",""),r=JSON.parse(localStorage.getItem(`openmrs:feature-flag-meta:${n}`)||"{}");e[n]={enabled:"true"===localStorage.getItem(t),...r}}return e}()});function lQ(e,t,n){lX.setState(r=>({flags:{...r.flags,[e]:{enabled:r.flags[e]?.enabled??!1,label:t,description:n}}}))}function l0(){let e=lX.getState().flags;Object.keys(localStorage).filter(e=>e.startsWith("openmrs:feature-flag:")).forEach(t=>{let n=t.replace("openmrs:feature-flag:","");e[n]||(localStorage.removeItem(t),localStorage.removeItem(`openmrs:feature-flag-meta:${n}`))})}function l1(e){return lX.getState().flags[e].enabled}function l4(e,t){lX.subscribe(n=>{t(n.flags[e].enabled)})}function l2(e,t){lX.setState(n=>({flags:{...n.flags,[e]:{...n.flags[e],enabled:t}}}))}lX.subscribe(e=>{for(let[t,n]of Object.entries(e.flags))localStorage.setItem(`openmrs:feature-flag:${t}`,n.enabled.toString()),localStorage.setItem(`openmrs:feature-flag-meta:${t}`,JSON.stringify({label:n.label,description:n.description}))});var l3=tG(function(e,t,n){tF(e,t,n)});let l6=B("extensionsInternal",{slots:{},extensions:{}}),l5=B("extensionRenderings",{renderings:new Map}),l9=()=>W("extensionsInternal",{slots:{},extensions:{}}),l8=()=>W("extensionRenderings",{renderings:new Map});function l7(e){let t=l6.getState(),n=e(t);n!==t&&l6.setState(n)}let ue=null,ut=null;function un(){let e=l5.getState();return ue&&e===ut||(ue=new Map(e.renderings),ut=e,function(e){for(let t of(um.clear(),e.values()))uf(t,1);up=!0}(ue)),ue}function ur(e){ut={renderings:e},l5.setState(ut,!0)}function ua(e){let t=un();t.has(e.renderingId)||(t.set(e.renderingId,e),uf(e,1),ur(t))}function uo(e){let t=un(),n=t.get(e);n&&(t.delete(e),uf(n,-1),ur(t))}let ui=()=>W("extensions",{slots:{}}),us=0,ul=new Set;function uu(e){us++;try{return e()}finally{if(0==--us&&ul.size>0){let e=Array.from(ul);for(let t of(ul.clear(),e))uc(t)}}}function uc(e){try{e()}catch(t){console.error(`The extension system's '${e.name}' recomputation failed`,t)}}function ud(e){us>0?ul.add(e):uc(e)}let um=new Map,up=!1;function uf(e,t){let n=JSON.stringify([e.slotName,e.extensionId,e.slotModuleName,e.extensionModuleName]),r=um.get(n);if(!r){if(t<0)return;um.set(n,{count:1,record:{slotModuleName:e.slotModuleName,extensionModuleName:e.extensionModuleName,slotName:e.slotName,extensionId:e.extensionId}}),up=!0;return}r.count+=t,r.count<1&&(um.delete(n),up=!0)}function uh(){var e,t;if(un(),!up)return;up=!1;let n=Array.from(um.values(),({record:e})=>e);n.sort(ug),e=rw.getState().mountedExtensions,t=n,e.length===t.length&&e.every((e,n)=>0===ug(e,t[n]))||rw.setState({mountedExtensions:n})}function ug(e,t){return uy(e.slotName,t.slotName)||uy(e.extensionId,t.extensionId)||uy(e.slotModuleName,t.slotModuleName)||uy(e.extensionModuleName,t.extensionModuleName)}function uy(e,t){return e===t?0:e<t?-1:1}uh(),l5.subscribe(()=>ud(uh));let uv=l9(),ub=ui(),uw=rx(),uE=rS(),ux=new Set,uD=!1;function u_(e){if(null===e)ux=null;else if(null!==ux)for(let t of e)ux.add(t);ud(uS)}function uS(){if(!uD){uD=!0;try{for(let e=1;;e++){let t=ux;if(null!==t&&0===t.size)return;ux=new Set;try{!function(e,t,n,r,a,o=null){let i=ub.getState().slots,s={},l=!1,u=Object.entries(r.flags).filter(([,{enabled:e}])=>e).map(([e])=>e);for(let[r,c]of Object.entries(e.slots)){let d=i[r];if(d&&o&&!o.has(r)){s[r]=d;continue}let{config:m}=r_(t,c.name),p=function(e,t,n,r,a,o){let i=function(e,t){let n=e.add||[],r=e.remove||[],a=e.order||[],{extensions:o}=uv.getState(),i=new Set(r),s=[...t,...n].filter(e=>!i.has(e)),l=uI(a),u=uI(t),c=new Map(s.map(e=>[e,function(e,t,n,r){let a=t.get(e);if(void 0!==a)return a;{if(void 0!==n)return 1e3+n;let t=r.get(e);return void 0!==t?2e3+t:3e3}}(e,l,o[uP(e)]?.order,u)]));return s.sort((e,t)=>c.get(e)-c.get(t))}(n,t.slots[e].attachedIds),s=[];for(let l of i){let{config:i}=rC(r,e,l),u=rk(n,e,l),c=u?l3({},i,u):i,d=uP(l),m=t.extensions[d];if(m){let e=c?.["Display conditions"]?.privileges??m.privileges??[];if(e&&("string"==typeof e||Array.isArray(e)&&e.length>0)&&(!o?.user||!i8(e,o.user))||m.featureFlag&&!a.includes(m.featureFlag))continue;s.push({id:l,name:d,moduleName:m.moduleName,config:c,featureFlag:m.featureFlag,meta:m.meta,displayConditionExpression:c?.["Display conditions"]?.expression||m.displayExpression})}}return s}(r,e,m,n,u,a.session);d&&d.moduleName===c.moduleName&&nP(d.candidateExtensions,p)?s[r]=d:(s[r]={moduleName:c.moduleName,candidateExtensions:p},l=!0)}(l||Object.keys(i).length!==Object.keys(s).length)&&ub.setState({slots:s})}(uv.getState(),uw.getState(),uE.getState(),lX.getState(),iQ.getState(),t)}catch(e){throw ux=null===t||null===ux?null:new Set([...t,...ux]),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{uD=!1}}}function uC(e,t){let n=new Set;for(let r of Object.keys(e))e[r]!==t[r]&&n.add(r);for(let r of Object.keys(t))r in e||n.add(r);return n}function uk(e,t){return{moduleName:t,name:e,attachedIds:[]}}function uP(e){let[t]=e.split("#");return t}function uR(e,t){let n=uP(t);return e.extensions[n]}function uT(e){return uR(uv.getState(),e)}uv.subscribe((e,t)=>{u_(e.extensions!==t.extensions?null:uC(e.slots,t.slots))}),uw.subscribe((e,t)=>{u_(uC(e.slots,t.slots))}),uE.subscribe((e,t)=>{u_(uC(e.configs,t.configs))}),lX.subscribe(()=>u_(null)),iQ.subscribe(()=>u_(null)),u_(null);let uO=e=>l7(t=>({...t,extensions:{...t.extensions,[e.name]:{...e}}}));function u$(e,t){l7(n=>{let r=n.slots[e];return r?{...n,slots:{...n.slots,[e]:{...r,attachedIds:[...r.attachedIds,t]}}}:{...n,slots:{...n.slots,[e]:{...uk(e),attachedIds:[t]}}}})}function uN(e,t){l7(n=>{let r=n.slots[e];return r&&r.attachedIds.includes(t)?{...n,slots:{...n.slots,[e]:{...r,attachedIds:r.attachedIds.filter(e=>e!==t)}}}:n})}function uj(e){l7(t=>{let n=t.slots[e];return n?{...t,slots:{...t.slots,[e]:{...n,attachedIds:[]}}}:t})}function uI(e){let t=new Map;return e.forEach((e,n)=>{t.has(e)||t.set(e,n)}),t}function uA(e,t){return function(e,t,n=null,r){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:n,...t}:{session:n});try{return!!lC(o,a)}catch(t){return console.error(`Error while evaluating expression '${o}' for ${e.id}`+(r?` in ${r}`:""),t),!1}})}(uM(e),t,iQ.getState().session,e)}function uM(e){return ub.getState().slots[e]?.candidateExtensions??[]}let uL=(e,t)=>uv.setState(n=>{let r=n.slots[t]?.moduleName;if(r&&r!=e)return console.warn(`An extension slot with the name '${t}' already exists. Refusing to register the same slot name twice (in "registerExtensionSlot"). The existing one is from module ${r}.`),n;if(r&&r==e)return n;if(n.slots[t])return{...n,slots:{...n.slots,[t]:{...n.slots[t],moduleName:e}}};let a=uk(t,e);return{...n,slots:{...n.slots,[t]:{...a}}}}),uF=()=>{ux=null,l7(()=>({slots:{},extensions:{}})),l8().setState({renderings:new Map}),ub.setState({slots:{}})},uB=B("left-nav",{slotName:null,basePath:window.spaBase,mode:"normal"});function uU({name:e,basePath:t,mode:n,componentContext:r,state:a}){uB.setState({slotName:e,basePath:t,mode:n??"normal",componentContext:r,state:a})}function uV(e){uB.getState().slotName===e&&uB.setState(uB.getInitialState(),!0)}let uW=B("modalRegistry",{modals:{}});function uH(e){uW.setState(t=>(t.modals[e.name]=e,t))}function uz(e){let t=uW.getState().modals[e];if(!t){let n=uT(e);n&&(t={name:e,load:n.load,moduleName:n.moduleName},console.warn(`Modal ${e} was registered as an extension. This is deprecated and will be removed in the future. Please register it in the "modals" section of routes.json instead of the "extensions" section.`),uH(t))}return t}let uK=B("workspace2",{registeredGroupsByName:{},registeredWindowsByName:{},registeredWorkspacesByName:{},openedGroup:null,openedWindows:[],isMostRecentlyOpenedWindowHidden:!1});function uG(e){let{registeredWorkspacesByName:t,registeredWindowsByName:n}=uK.getState(),r=t[e];if(r){let t=n[r.window];if(t)return t;throw Error(`No workspace window found with name: ${r.window} for workspace: ${e}`)}throw Error(`No workspace found with name: ${e}`)}function uZ(e){let{registeredGroupsByName:t,registeredWindowsByName:n}=uK.getState(),r=n[e];if(r){let n=t[r.group];if(n)return n;throw Error(`No workspace group found with name: ${r.group} for window: ${e}`)}throw Error(`No workspace window found with name: ${e}`)}function uY(e){let{openedWindows:t}=uK.getState();return t.findIndex(t=>t.openedWorkspaces.find(t=>t.workspaceName===e))}function uq(e,t){if(0==t.length)return;let{registeredGroupsByName:n}=uK.getState(),r={...n};for(let n of t){if(r[n.name])throw Error(`Cannot register workspace group ${n.name} more than once`);r[n.name]={...n,moduleName:e}}uK.setState({registeredGroupsByName:r})}function uJ(e,t){if(0==t.length)return;let{registeredWindowsByName:n}=uK.getState(),r={...n};for(let n of t){if(r[n.name])throw Error(`Cannot register workspace window ${n.name} more than once`);let t={...n,moduleName:e};r[n.name]=t}uK.setState({registeredWindowsByName:r})}function uX(e,t){if(0==t.length)return;let{registeredWorkspacesByName:n}=uK.getState(),r={...n};for(let n of t){if(r[n.name])throw Error(`Cannot register workspace ${n.name} more than once`);let t={...n,moduleName:e};r[n.name]=t}uK.setState({registeredWorkspacesByName:r})}let uQ=0,u0=null,u1={bootstrap:15e3,mount:15e3,unmount:15e3};function u4(e,t){if(e.timeouts)return e;let n=e.name??"parcel",r=Object.fromEntries(Object.keys(u1).filter(t=>e[t]).map(r=>{var a,o;let i,s;return[r,(a=e[r],o=u1[r],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 ${r} at array index ${o} for parcel ${n} did not return a promise`))}),Promise.resolve(void 0)),e=>{let a,i=new Promise((e,t)=>{a=setTimeout(()=>t(Error(`Lifecycle function ${r} for parcel ${n} did not settle within ${o}ms`)),o)});return Promise.race([s(e),i]).finally(()=>clearTimeout(a)).then(e=>(t(r,!1),e),e=>{throw t(r,!0),e})})]}));return{...e,...r}}async function u2(e,t){var n,r;let a,o,i,s,l,u=await (u0??(u0=new Promise((e,t)=>{ot({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),ot))),u0),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 r=u((n=d.onSettled,"function"==typeof e?()=>e().then(e=>u4(e,n)):u4(e,n)),c),s=e=>t=>e.call(r,d.retarget(t)).catch(e=>{throw"SKIP_BECAUSE_BROKEN"===r.getStatus()&&d.release(),e}),l=r.update&&s(r.update),Object.defineProperty(r,"update",{configurable:!0,enumerable:!0,get:()=>l,set:e=>{l=e&&s(e)}})}function u3(){return u6}function u6(e,t){let n,r=u2(e,t).then(e=>n=e);return{mount:()=>r.then(e=>e.mount()),unmount:()=>r.then(e=>e.unmount()),update:e=>r.then(t=>t.update?.(e)),getStatus:()=>n?.getStatus()??"LOADING_SOURCE_CODE",get loadPromise(){return r.then(e=>e.loadPromise)},get bootstrapPromise(){return r.then(e=>e.bootstrapPromise)},get mountPromise(){return r.then(e=>e.mountPromise)},get unmountPromise(){return r.then(e=>e.unmountPromise)}}}async function u5(e,t,n,r,a=e=>e,o={}){let i=uP(r),s=uT(r),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:m}=s,p=uQ++,f=`${t}/${r}-${p}`;e.dataset.extensionRenderingId=f;let h=e=>{try{uo(f)}catch(t){console.error(e,t)}};try{ua({renderingId:f,extensionName:i,extensionModuleName:d,extensionId:r,slotName:t,slotModuleName:n})}catch(e){throw h(`Recomputing configuration after registering '${r}' failed also failed`),e}try{u=await m()}catch(e){throw h(`Recomputing configuration after '${r}' failed to load also failed`),e}try{l=await u2(a({...u,name:`${t}/${i}-${p}`}),{...o,_meta:c,_extensionContext:{extensionId:r,extensionSlotName:t,extensionSlotModuleName:n,extensionModuleName:d,extensionMeta:c},domElement:e})}catch(e){throw h(`Recomputing configuration after '${r}' failed to mount also failed`),e}l.mountPromise.then(void 0,e=>{console.error(`Extension '${r}' in slot '${t}' failed to mount`,e),h(`Recomputing configuration after '${r}' failed to mount also failed`)}),l.unmountPromise.then(()=>h(`Recomputing configuration after unmounting '${r}' failed`),e=>{console.error(`Extension '${r}' in slot '${t}' failed to unmount`,e),h(`Recomputing configuration after '${r}' failed to unmount also failed`)})}else console.warn(`Tried to render ${r} into ${t} but no DOM element was available.`);return l}var u9=n(2491),u8=n.n(u9);let u7=(0,u9.createContext)({moduleName:"",featureName:""});function ce({to:e,templateParams:t,onBeforeNavigate:n,children:r,...a}){return(0,u9.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}`)},[]),u8().createElement("a",{onClick:r=>{0===r.button&&!r.ctrlKey&&!r.shiftKey&&!r.altKey&&!r.metaKey&&(r.preventDefault(),n?.(r),iM({to:e,templateParams:t})),0===r.button&&(r.ctrlKey||r.metaKey)&&n?.(r),0===r.button&&r.shiftKey&&n?.(r),1===r.button&&n?.(r)},href:iI(e,t),...a},r)}let ct=({state:e,children:t,...n})=>{let{extension:r}=(0,u9.useContext)(u7),a=(0,u9.useRef)(null),o=(0,u9.useRef)(Promise.resolve()),i=(0,u9.useRef)(!1),s=(0,u9.useRef)(!1),l=(0,u9.useRef)(e),u=(0,u9.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,u9.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 '${r?.extensionId}' failed to update`,e)}))},[]),d=(0,u9.useCallback)(t=>{t&&!a.current&&!s.current&&r?.extensionSlotName&&r.extensionSlotModuleName&&(s.current=!0,u5(t,r.extensionSlotName,r.extensionSlotModuleName,r.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,u9.useEffect)(()=>(i.current=!1,()=>{i.current=!0,u(a.current)}),[]),(0,u9.useEffect)(()=>{l.current=e,a.current&&c(a.current,e)},[e]),r?u8().createElement("div",{ref:d,"data-extension-id":r?.extensionId,style:{position:"relative"},...n}):null};function cn(e){let t=(0,u9.useRef)(e);return T(t.current,e)||(t.current=e),t.current}function cr(e,t){"function"==typeof t&&(t=t(e));let n={};for(let[r,a]of Object.entries(t)){let t=function(...t){e.setState(e=>a(e,...t))};n[r]=t}return n}let ca=e=>e;function co(e,t=ca,n){let r=(0,u9.useCallback)(t=>e.subscribe(t),[e]),a=(0,u9.useCallback)(()=>t(e.getState()),[e,t]),o=(0,u9.useSyncExternalStore)(r,a,a),i=(0,u9.useMemo)(()=>n?cr(e,n):null,[e,n]);return(0,u9.useMemo)(()=>i?{...o,...i}:o,[o,i])}function ci(e,t){return co(e,ca,t)}function cs(e){return function(t){let n=(0,u9.useCallback)(t=>e.subscribe(t),[]),r=(0,u9.useCallback)(()=>e.getState(),[]),a=(0,u9.useSyncExternalStore)(n,r,r),o=(0,u9.useMemo)(()=>t?cr(e,t):null,[t]);return(0,u9.useMemo)(()=>o?{...a,...o}:a,[a,o])}}let cl=[];Object.freeze(cl);let cu={candidateExtensions:cl};Object.freeze(cu);let cc=e=>{let t=(0,u9.useCallback)(t=>t.slots?.[e]??cu,[e]);return co(ui(),t)},cd=e=>e.session;function cm(e,t){let{candidateExtensions:n}=cc(e),r=co(iQ,cd),a=cn(t);return(0,u9.useMemo)(()=>uA(e,a),[e,a,r,n])}function cp(e,t){let{moduleName:n}=(0,u9.useContext)(u7);if(!n)throw Error("ComponentContext has not been provided. This should come from @openmrs/esm-react-utils.");return(0,u9.useEffect)(()=>{uL(n,e)},[n,e]),{extensions:cm(e,t),extensionSlotName:e,extensionSlotModuleName:n}}function cf(e){return e}function ch({name:e,extensionSlotName:t,select:n=cf,children:r,state:a,style:o,...i}){if(r&&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,u9.useRef)(null),{extensions:u,extensionSlotModuleName:c}=cp(s,a),d=(0,u9.useMemo)(()=>n(u),[n,u]),m=(0,u9.useMemo)(()=>{if("function"==typeof r&&!u8().isValidElement(r))return d.map(e=>r(e,a))},[r,d]);return u8().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)=>u8().createElement(u7.Provider,{key:e.id,value:{moduleName:c,featureName:"",extension:{extensionId:e.id,extensionSlotName:s,extensionSlotModuleName:c,extensionMeta:e.meta}}},m?.[t]??("function"!=typeof r?r:null)??u8().createElement(ct,{state:a}))))}var cg=n(5873);function cy(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function cv(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?cy(Object(n),!0).forEach(function(t){var r,a,o;r=e,a=t,o=n[t],a in r?Object.defineProperty(r,a,{value:o,enumerable:!0,configurable:!0,writable:!0}):r[a]=o}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):cy(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function cb(e){return(cb="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 cw(e){return(cw="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 cE(e,t){var n;if("function"!=typeof(n=t.domElement?function(){return t.domElement}:t.domElementGetter?t.domElementGetter:e.domElementGetter?e.domElementGetter:function(e){var t=e.appName||e.name;if(!t)throw Error("single-spa's dom-element-getter-helpers was not given an application name as a prop, so it can't make a unique dom element container for the react application");var n="single-spa-application:".concat(t);return function(){var e=document.getElementById(n);return e||((e=document.createElement("div")).id=n,document.body.appendChild(e)),e}}(t)))throw Error("single-spa's dom-element-getter-helpers was given an invalid domElementGetter for application or parcel '".concat(t.name,"'. Expected a function, received ").concat(cw(n)));return function(){var e=n(t);if(!(e instanceof HTMLElement))throw Error("single-spa's dom-element-getter-helpers: domElementGetter returned an invalid dom element for application or parcel '".concat(t.name,"'. Expected HTMLElement, received ").concat(cw(e)));return e}}var cx=null;try{cx=require("react").createContext()}catch(e){}var cD={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 c_(e,t){return e.rootComponent?Promise.resolve():e.loadRootComponent(t).then(function(t){e.rootComponent=t})}function cS(e,t){return new Promise(function(n,r){e.suppressComponentDidCatchWarning||!function(e){if(!(e&&"string"==typeof e.version&&e.version.indexOf(".")>=0))return!1;var t=e.version.slice(0,e.version.indexOf("."));try{return Number(t)>=16}catch(e){return!1}}(e.React)||e.errorBoundary||e.errorBoundaryClass||(e.rootComponent.prototype?e.rootComponent.prototype.componentDidCatch||console.warn("single-spa-react: ".concat(t.name||t.appName||t.childAppName,"'s rootComponent should implement componentDidCatch to avoid accidentally unmounting the entire single-spa application.")):console.warn("single-spa-react: ".concat(t.name||t.appName||t.childAppName,"'s rootComponent does not implement an error boundary. If using a functional component, consider providing an opts.errorBoundary to singleSpaReact(opts).")));var a,o=cR(e,t,function(){n(this)}),i=cE(e,t)(),s=function(e){var t=e.reactDom,n=e.renderType,r=e.elementToRender,a=e.domElement,o=t[n];if("function"!=typeof o)throw Error('renderType "'.concat(n,'" did not return a function.'));switch(n){case"createRoot":case"unstable_createRoot":case"createBlockingRoot":case"unstable_createBlockingRoot":var i=o(a);return i.render(r),i;case"hydrateRoot":return o(a,r);default:return o(r,a),null}}({elementToRender:o,domElement:i,reactDom:cP(e),renderType:"function"==typeof(a=e).renderType?a.renderType():a.renderType});e.domElements[t.name]=i,e.renderResults[t.name]=s})}function cC(e,t){return new Promise(function(n){e.unmountResolves[t.name]=n;var r=e.renderResults[t.name];r&&r.unmount?r.unmount():cP(e).unmountComponentAtNode(e.domElements[t.name]),delete e.domElements[t.name],delete e.renderResults[t.name]})}function ck(e,t){return new Promise(function(n){e.updateResolves[t.name]||(e.updateResolves[t.name]=[]),e.updateResolves[t.name].push(n);var r=cR(e,t,null),a=e.renderResults[t.name];if(a&&a.render)a.render(r);else{var o=cE(e,t)();cP(e).render(r,o)}})}function cP(e){return e.ReactDOMClient||e.ReactDOM}function cR(e,t,n){var r=e.React.createElement(e.rootComponent,t),a=cx?e.React.createElement(cx.Provider,{value:t},r):r;return(e.errorBoundary||t.errorBoundary||e.errorBoundaryClass||t.errorBoundaryClass)&&(e.errorBoundaryClass=e.errorBoundaryClass||t.errorBoundaryClass||function(e,t){function n(t){e.React.Component.apply(this,arguments),this.state={caughtError:null,caughtErrorInfo:null},n.displayName="SingleSpaReactErrorBoundary(".concat(t.name,")")}return n.prototype=Object.create(e.React.Component.prototype),n.prototype.render=function(){return this.state.caughtError?(e.errorBoundary||t.errorBoundary)(this.state.caughtError,this.state.caughtErrorInfo,this.props):this.props.children},n.prototype.componentDidCatch=function(e,t){this.setState({caughtError:e,caughtErrorInfo:t})},n}(e,t),a=e.React.createElement(e.errorBoundaryClass,t,a)),a=e.React.createElement(e.SingleSpaRoot,cv(cv({},t),{},{mountFinished:n,updateFinished:function(){e.updateResolves[t.name]&&(e.updateResolves[t.name].forEach(function(e){return e()}),delete e.updateResolves[t.name])},unmountFinished:function(){e.unmountResolves[t.name]&&(e.unmountResolves[t.name](),delete e.unmountResolves[t.name])}}),a)}var cT=n(4011),cO=n(5327),c$=n.n(cO),cN=n(3780);let cj={strictMode:!0,throwErrorsToConsole:!0,disableTranslations:!1},cI=new Map;(0,cN.initCache)(cI);let cA={errorRetryCount:3,fetcher:iJ,focusThrottleInterval:18e5,revalidateIfStale:!0,revalidateOnFocus:!1,revalidateOnReconnect:!1,refreshInterval:0,shouldRetryOnError:e=>{if(e instanceof iX){let t=e.response.status;return!!(t>=500)||401===t||403===t||429===t}return!0},provider:()=>cI};function cM(e){if("object"!=typeof e||"string"!=typeof e.featureName||"string"!=typeof e.moduleName)throw Error("Invalid options");let t=Object.assign({},cj,e),n={...cA,...t.swrConfig};return function(e){var r,a,o,i,s;return o=a=class extends(r=u8().Component){componentDidCatch(e,n){n&&n.componentStack&&(e.extra=Object.assign(e.extra||{},{componentStack:n.componentStack})),t.throwErrorsToConsole&&setTimeout(()=>{throw e}),this.setState({caughtError:e,caughtErrorInfo:n})}render(){if(this.state.caughtError)return u8().createElement("div",null,"An error has occurred. Please try reloading the page.");{let r=u8().createElement(u9.Suspense,{fallback:null},u8().createElement(cO.SWRConfig,{value:n},u8().createElement(u7.Provider,{value:this.state.config},t.disableTranslations?u8().createElement(e,this.props):u8().createElement(cT.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},u8().createElement(e,this.props)))));return t.strictMode&&u8().StrictMode?u8().createElement(u8().StrictMode,null,r):r}}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 cL(e,t){return function(e){if("object"!==cb(e))throw Error("single-spa-react requires a configuration object");var t,n=cv(cv({},cD),e);if(!n.React)throw Error("single-spa-react must be passed opts.React");if(!n.ReactDOM&&!n.ReactDOMClient)throw Error("single-spa-react must be passed opts.ReactDOM or opts.ReactDOMClient");if(n.renderType||(null!=(t=n.ReactDOMClient)&&t.createRoot?n.renderType="createRoot":n.renderType="render"),!n.rootComponent&&!n.loadRootComponent)throw Error("single-spa-react must be passed opts.rootComponent or opts.loadRootComponent");if(n.errorBoundary&&"function"!=typeof n.errorBoundary)throw Error("The errorBoundary opt for single-spa-react must either be omitted or be a function that returns React elements");!cx&&n.React.createContext&&(cx=n.React.createContext()),n.SingleSpaRoot=function(e){function t(e){t.displayName="SingleSpaRoot(".concat(e.name,")")}return t.prototype=Object.create(e.React.Component.prototype),t.prototype.componentDidMount=function(){setTimeout(this.props.mountFinished)},t.prototype.componentWillUnmount=function(){setTimeout(this.props.unmountFinished)},t.prototype.render=function(){return setTimeout(this.props.updateFinished),this.props.children},t}(n);var r={bootstrap:c_.bind(null,n),mount:cS.bind(null,n),unmount:cC.bind(null,n)};return n.parcelCanUpdate&&(r.update=ck.bind(null,n)),r}({React:u8(),ReactDOMClient:cg,rootComponent:cM(t)(e)})}function cF(e,t){return()=>e().then(({default:e})=>cL(e,t))}function cB(e,t){return()=>Promise.resolve(cL(e,t))}let cU=cF,cV=j()(()=>({}));V("openmrs-app-context",cV);let cW={};function cH(e,t=e=>e){let n=cV.getState();return e in n?Object.freeze(Object.assign({},t?t(n[e]):n[e])):null}function cz(e,t){cV.setState(n=>(e in n||(n[e]={}),n[e]=t(n[e]),Object.assign({},n)))}function cK(e){return null===e?null:Object.freeze(Object.assign({},e))}let cG=new Map;function cZ(e,t){let n=(0,u9.useRef)(t??{}),r=(0,u9.useRef)(t=>cz(e,t)),a=(0,u9.useRef)(Symbol());return(0,u9.useEffect)(()=>{let n=t??{},r=a.current;return null===cH(e)?!function(e,t=cW){cV.setState(n=>{if(e in n)throw Error(`Attempted to re-register namespace ${e} in the app context. Each namespace must be unregistered before the name can be registered again.`);return Object.assign({},n,{[e]:t===cW?{}:t})})}(e,n):(console.warn(`Namespace ${e} is already registered in the app context. This is likely a race condition during navigation, but may indicate two components are trying to own the same namespace. Updating the existing context.`),cz(e,()=>n)),cG.set(e,r),()=>{cG.get(e)===r&&(cV.setState(t=>(e in t&&delete t[e],t)),cG.delete(e))}},[e]),(0,u9.useEffect)(()=>{let r=t??{};T(n.current,r)||(cz(e,()=>r),n.current=r)},[t]),r.current}function cY({namespace:e,value:t}){return cZ(e,t),null}let cq=({children:e,value:t,fallback:n})=>t?u8().createElement(u8().Fragment,null,e):n?u8().createElement(u8().Fragment,null,n):null;function cJ(){let e=(0,u9.useRef)();return(!e.current||e.current.signal.aborted)&&(e.current=new AbortController),(0,u9.useEffect)(()=>{let t=e.current;return()=>t?.abort()},[]),e.current}function cX(e,t=e=>e??{}){let[n,r]=(0,u9.useState)(()=>{if(cQ(e))return;let n=cH(e);if(null!==n)return t?t(n):n});return(0,u9.useEffect)(()=>{if(cQ(e))throw Error(`The namespace supplied to useAppContext must be a non-empty string, but was "${e}".`)},[e]),(0,u9.useEffect)(()=>{var n;let a;return(n=e=>{if(null==e)return void r(void 0);let n=t?t(e):e;r(e=>T(e,n)?e:n)})(cK(a=cH(e))),cV.subscribe(t=>{let r=e in t?t[e]:null;r!==a&&(a=r,n(cK(r)))})},[e,t]),n}function cQ(e){return"string"!=typeof e||0===e.trim().length}function c0(e){let t=cm(e);return(0,u9.useMemo)(()=>t.map(e=>e.id),[t])}function c1(e){return cc(e).candidateExtensions}function c4(e,t,n){let{data:r,error:a,mutate:o,isLoading:i,isValidating:s}=c$()(e?s8(e,t,n):null,iJ);return(0,u9.useMemo)(()=>({isLoading:i,data:r?.data.results??[],error:a,mutate:o,isValidating:s}),[r,a,i,s,o])}function c2(e){(0,u9.useEffect)(()=>{if(e){let e=window.getComputedStyle(document.body).overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=e}}},[e])}let c3={},c6=`No ComponentContext has been provided. This should come from "openmrsComponentDecorator".
|
|
15
|
+
${this.stack}`}}let iQ=B("session",{loaded:!1,session:null}),i0=0,i1=null;function i4(){return i1||(iQ.getState().loaded&&i0>=Date.now()-6e4?null:i5())}function i2(e){let t=e?.includeAuthStatus??!0,n=e=>t?e:e.user,r=i4();return r?new Promise(e=>{let t=()=>{let t=iQ.getState();t.loaded&&(a(),e(n(t.session)))},a=iQ.subscribe(t);r.then(t,t)}):Promise.resolve(n(iQ.getState().session))}function i3(){return i4(),iQ}function i6(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 i5(e,t){i0=Date.now(),o??(o=i0);let n={};e&&t&&(n.Authorization=`Basic ${window.btoa(`${e}:${t}`)}`);let r=si(iJ(iY,{headers:n,rejectAuthFailure:!0})),a=()=>{i1===r&&(i1=null)};return r.then(a,a),i1=r,r}function i9(){iQ.setState({loaded:!0,session:{authenticated:!1,sessionId:""}},!0)}function i8(e,t){var n,r;if(void 0===t)return!e;if(!e)return!0;return n=e,r=t,("string"==typeof n?!K(r.privileges.find(e=>n===e.display)):Array.isArray(n)?n.every(e=>!K(r.privileges.find(t=>e===t.display))):(K(n)||console.error(`Could not understand privileges "${n}"`),!0))||!K(t.roles.find(e=>"System Developer"===e.display))}function i7(){let e,t;return new Promise(n=>{let r=r=>{r.loaded&&r.session.user&&(e=r.session.user,n(r.session.user),t&&t())};r(iQ.getState()),e||(t=iQ.subscribe(r))})}async function se(){return(await i2()).sessionLocation}async function st(e,t){return si(iJ(iY,{method:"POST",body:{sessionLocation:e},headers:{"Content-Type":"application/json"},rejectAuthFailure:!0,signal:t?.signal}))}async function sn(e,t){return await iJ(iY,{method:"POST",body:{locale:e},headers:{"Content-Type":"application/json"},signal:t?.signal}),i5()}async function sr(e,t,n){return n||(n=new AbortController),await iJ(`${iG}/user/${e}`,{method:"POST",body:{userProperties:t},headers:{"Content-Type":"application/json"},signal:n.signal}),i5()}async function sa(e,t=!1){let n=await iJ(t?`${iY}?rememberMe=true`:iY,{headers:{"X-Totp-Code":e}});return n.data?.authenticated?(await i5()).session:n.data}async function so(){try{await iJ(iY,{method:"DELETE",rejectAuthFailure:!0})}catch(e){if(!ss(e))throw e}i9(),await i5().catch(()=>{})}function si(e){return new Promise((t,n)=>{e.then(e=>{if("object"==typeof e?.data){let n={loaded:!0,session:e.data};iQ.setState(n,!0),t(n)}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)?n(sl(Error("The session endpoint did not respond with a session"))):n(sl(Error("The server is still starting up"),!0))}).catch(e=>{var r,a;if(ss(e)){"object"==typeof(r=e.responseBody)&&null!==r&&!1===r.authenticated?iQ.setState({loaded:!0,session:e.responseBody},!0):i9(),t(iQ.getState());return}(a=e)instanceof iX&&502===a.response.status&&!iQ.getState().loaded&&void 0!==o&&Date.now()-o<18e4?n(sl(e,!0)):(k(`Failed to fetch new session information: ${e}`),n(sl(e)))})})}function ss(e){return e instanceof iX&&(401===e.response.status||403===e.response.status)}function sl(e,t=!1){return iQ.getState().loaded||iQ.setState({loaded:!1,session:null,error:e instanceof Error?e:Error(String(e)),initializing:t},!0),iQ.getState()}function su(){return"development"===window.spaEnv||"true"===localStorage.getItem("openmrs:devtools")}iQ.subscribe(e=>{e.loaded&&e.session&&i6(e.session)});let sc={"webservices.rest":"2.24.0",fhir2:"1.0.0-SNAPSHOT"};function sd(){rZ("@openmrs/esm-api",iz),i5()}let sm="import-map-override:",sp="import-map-overrides-disabled",sf="import-map-overrides:change",sh=!1,sg=null,sy=null;async function sv(){return sy??(sy=sb().then(({map:e,complete:t})=>(t||(sy=null),e))),sy}async function sb(){let e=document.querySelectorAll('script[type="systemjs-importmap"]'),t=[],n=!0;for(let r=0;r<e.length;r++){let a=e[r];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){n=!1,console.warn(`[import-maps] Failed to parse import map from script tag at index ${r}`,e)}}return{map:sw(t),complete:n}}function sw(e){let t={imports:{}};for(let n of e)n?.imports&&Object.assign(t.imports,n.imports);return t}function sE(){let e={};try{let t=sC();for(let n=0;n<localStorage.length;n++){let r=localStorage.key(n);if(r?.startsWith(sm)){let n=r.slice(sm.length);if(!t.includes(n)){let t=localStorage.getItem(r);t&&(e[n]=t)}}}}catch(e){console.warn("[import-maps] Failed to read import-map overrides from localStorage",e)}return{imports:e}}async function sx(){let e=await sv();return sh?sw([e,sg??sE()]):e}async function sD(){return sv()}async function s_(){return sh?sw([await sv(),sE()]):sv()}function sS(e){if(!sh)return{imports:{}};if(e){let e={};for(let t=0;t<localStorage.length;t++){let n=localStorage.key(t);if(n?.startsWith(sm)){let t=localStorage.getItem(n);t&&(e[n.slice(sm.length)]=t)}}return{imports:e}}return sE()}function sC(){if(!sh)return[];try{let e=localStorage.getItem(sp);if(e){let t=JSON.parse(e);if(Array.isArray(t))return t}}catch{}return[]}function sk(e){return!!sh&&sC().includes(e)}function sP(e,t){if(!sh)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{localStorage.setItem(sm+e,t),window.dispatchEvent(new CustomEvent(sf))}catch(e){console.warn("[import-maps] Failed to write import-map override to localStorage",e)}}function sR(e){if(!sh)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{localStorage.removeItem(sm+e);let t=sC().filter(t=>t!==e);t.length>0?localStorage.setItem(sp,JSON.stringify(t)):localStorage.removeItem(sp),window.dispatchEvent(new CustomEvent(sf))}catch(e){console.warn("[import-maps] Failed to update import-map overrides in localStorage",e)}}function sT(){if(!sh)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{let e=[];for(let t=0;t<localStorage.length;t++){let n=localStorage.key(t);n?.startsWith(sm)&&e.push(n)}e.forEach(e=>localStorage.removeItem(e)),localStorage.removeItem(sp),window.dispatchEvent(new CustomEvent(sf))}catch(e){console.warn("[import-maps] Failed to clear import-map overrides from localStorage",e)}}function sO(e){if(!sh)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{let t=sC().filter(t=>t!==e);t.length>0?localStorage.setItem(sp,JSON.stringify(t)):localStorage.removeItem(sp),window.dispatchEvent(new CustomEvent(sf))}catch(e){console.warn("[import-maps] Failed to update import-map overrides in localStorage",e)}}let s$=!1;function sN(){!s$&&(s$=!0,(sh="development"===window.spaEnv)&&(sg=sE()))}function sj(e){return e.replace(/[\/\-@]/g,"_")}async function sI(e,t="./start",r){var a;let o,i=!r?.maxLoadingTime||r.maxLoadingTime<=0?6e5:r.maxLoadingTime;await Promise.race([sA(e,r?.importMap),new Promise((t,n)=>{o=setTimeout(()=>{var t;n(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=sj(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(n.S.default);let u=(await l.get(t))();if("object"!=typeof u||null===u){let t=`Container for ${e} did not return an ESM module as expected`;throw console.error(t),Error(t)}return u}async function sA(e,t){if("string"!=typeof e||0===e.trim().length){let e="Attempted to call importDynamic() without supplying a package to load";throw console.error(e),Error(e)}let n=sj(e);if(!window[n]){let n=t??await sM();if(!n.imports.hasOwnProperty(e)){let t=`Could not find the package ${e} defined in the current importmap`;throw console.error(t),Error(t)}let r=n.imports[e];r.startsWith("./")&&(r=window.spaBase+r.substring(1));let a=e in sS().imports;try{return await function(e){var t;let n=(t=window)[sL]??(t[sL]=new Map),r=n.get(e);if(r)return r;if(document.head.querySelector(`script[src="${e}"]`))return console.warn(`Script at ${e} already loaded. Not loading it again.`),Promise.resolve();let a=document.createElement("script");a.src=e,a.type="text/javascript",a.async=!0;let o=new Promise((t,r)=>{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(),n.delete(e),a.remove();let o=`Failed to load script from ${e}`;console.error(o,t),r(t.message??o)}a.addEventListener("load",s),a.addEventListener("error",l),document.head.appendChild(a)});return n.set(e,o),o}(r)}catch(e){return a&&E({kind:"error",title:ij("scriptLoadingFailed","Error: Script failed to load"),description:ij("scriptLoadingError","Failed to load overridden script from {{- url}}. Please check that the bundled script is available at the expected URL. Click the button below to reset all import map overrides.",{url:r}),actionButtonLabel:ij("resetOverrides","Reset overrides"),onActionButtonClick(){sT(),window.location.reload()}}),Promise.reject(e)}}return Promise.resolve()}async function sM(){return sx()}let sL=Symbol.for("__openmrs_script_loading");function sF(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 sB(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&&sF(t))}let sU="openmrs-routes:",sV="openmrs-routes:change",sW=!1,sH=null,sz=null;async function sK(){return sz??(sz=sG().then(({map:e,complete:t})=>(t||(sz=null),e))),sz}async function sG(){let e=document.querySelectorAll("script[type='openmrs-routes']"),t=[],n=!0;for(let r=0;r<e.length;r++){let a=e[r];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&&sB(e)&&t.push(e)}catch(e){n=!1,console.warn(`[route-maps] Failed to parse routes from script tag at index ${r}`,e)}}return{map:sZ(t),complete:n}}function sZ(e){let t={routes:{}};for(let n of e)n&&"object"==typeof n&&!Array.isArray(n)&&(Object.assign(t.routes,n.routes),void 0===t.version&&void 0!==n.version&&(t.version=n.version));return t}async function sY(){let e={version:void 0,routes:{}};try{let t=[];for(let e=0;e<localStorage.length;e++){let n=localStorage.key(e);if(n?.startsWith(sU)){let e=localStorage.getItem(n);e&&t.push({moduleName:n.slice(sU.length),raw:e})}}for(let n of(await Promise.allSettled(t.map(async({moduleName:e,raw:t})=>{let n=JSON.parse(t);if(sF(n))return{moduleName:e,routes:n};if("string"==typeof n&&n.startsWith("http")){let t=await fetch(n),r=await t.json();if(sF(r))return{moduleName:e,routes:r};throw Error(`${n} did not resolve to a valid OpenmrsAppRoutes object`)}throw Error(`Override for ${e} is neither a valid routes object nor a URL`)}))))"fulfilled"===n.status?e.routes[n.value.moduleName]=n.value.routes:console.warn("[route-maps] Failed to load route override",n.reason)}catch(e){console.warn("[route-maps] Failed to read route overrides from localStorage",e)}return e}async function sq(){let e=await sK();return sW?sZ([e,sH??await sY()]):e}async function sJ(){return sK()}async function sX(){return sW?sZ([await sK(),await sY()]):sK()}function sQ(){if(!sW)return{};let e={};try{for(let t=0;t<localStorage.length;t++){let n=localStorage.key(t);if(n?.startsWith(sU)){let t=localStorage.getItem(n);t&&(e[n.slice(sU.length)]=t)}}}catch(e){console.warn("[route-maps] Failed to read route overrides from localStorage",e)}return e}function s0(e,t){if(!sW)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{if("string"==typeof t)if(t.startsWith("http"))localStorage.setItem(sU+e,JSON.stringify(t));else{let n=JSON.parse(t);if(!sF(n))return void console.error(`The supplied routes for ${e} is not a valid OpenmrsAppRoutes object`,t);localStorage.setItem(sU+e,JSON.stringify(n))}else if(t instanceof URL)localStorage.setItem(sU+e,JSON.stringify(t.toString()));else{if(!sF(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(sU+e,JSON.stringify(t))}window.dispatchEvent(new CustomEvent(sV))}catch(e){console.warn("[route-maps] Failed to write route override to localStorage",e)}}function s1(e){if(!sW)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{localStorage.removeItem(sU+e),window.dispatchEvent(new CustomEvent(sV))}catch(e){console.warn("[route-maps] Failed to remove route override from localStorage",e)}}function s4(){if(!sW)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{let e=[];for(let t=0;t<localStorage.length;t++){let n=localStorage.key(t);n?.startsWith(sU)&&e.push(n)}e.forEach(e=>localStorage.removeItem(e)),window.dispatchEvent(new CustomEvent(sV))}catch(e){console.warn("[route-maps] Failed to clear route overrides from localStorage",e)}}let s2=null;function s3(){return s2||(s2=(sW="development"===window.spaEnv)?sY().then(e=>{sH=e}):Promise.resolve())}let s6=`${iG}/attachment`;function s5(e,t){return iJ(`${s6}/${e}`,{signal:t.signal})}function s9(e,t,n,r){return iJ(s8(e,t,r),{signal:n.signal})}function s8(e,t,n){return n?`${s6}?patient=${e}&encounter=${n}`:`${s6}?patient=${e}&includeEncounterless=${t}`}async function s7(e,t,n){let r=new FormData;return r.append("fileCaption",t.fileDescription),r.append("patient",e),n&&r.append("encounter",n),t.file?r.append("file",t.file,t.fileName):(r.append("file",new File([""],t.fileName),t.fileName),r.append("base64Content",t.base64Content)),iJ(`${s6}`,{method:"POST",body:r})}function le(e,t){return iJ(`${s6}/${e}`,{method:"DELETE",signal:t.signal})}async function lt(e,t){return e?(await iJ(`${iZ}/Patient/${e}`,t)).data:null}function ln(e,t){let n=new CustomEvent(`openmrs:${e}`,{detail:t??void 0,cancelable:!0,bubbles:!0});return window.dispatchEvent(n)}function lr(e,t){let n=e=>{t("detail"in e&&null!==e.detail?e.detail:void 0)};return window.addEventListener(`openmrs:${e}`,n),()=>{window.removeEventListener(`openmrs:${e}`,n)}}function la(e){return{uuid:e.uuid,display:e.display}}function lo(e=null,t=null){let n=new URLSearchParams;e&&n.set("tag",e),t&&n.set("q",t);let r=n.toString();return iJ(`${iG}/location${r?"?"+r:""}`).then(e=>e.data.results.map(la))}function li(e){return{uuid:e.uuid,display:e.display,name:e.name}}let ls=`${iG}/visittype`;function ll(e=ls){return iJ(e).then(e=>e.data.results.map(li))}var lu=((et={}).NEWVISIT="startVisit",et.EDITVISIT="editVisit",et.LOADING="loadingVisit",et),lc=((en={}).NOTSTARTED="notStarted",en.ONGOING="ongoing",en);let ld="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))",lm=function(){try{return JSON.parse(sessionStorage.getItem("openmrs:visitStoreState")||"null")}catch(e){return null}}()||{patientUuid:null,manuallySetVisitUuid:null};function lp(){return W("visit",lm)}function lf(e,t){lp().setState({patientUuid:e,manuallySetVisitUuid:t})}function lh(e,t){return iJ(`${iG}/visit`,{signal:t.signal,method:"POST",headers:{"Content-type":"application/json"},body:e})}function lg(e,t,n){return iJ(`${iG}/visit/${e}`,{signal:n.signal,method:"POST",headers:{"Content-type":"application/json"},body:t})}function ly(e,t,n){return iJ(`${iG}/visit?patient=${e}&v=${n??ld}`,{signal:t.signal,method:"GET",headers:{"Content-type":"application/json"}})}lp().subscribe(e=>{var t;t=e,sessionStorage.setItem("openmrs:visitStoreState",JSON.stringify(t))});class lv{static get version(){return"1.4.0"}static toString(){return"JavaScript Expression Parser (JSEP) v"+lv.version}static addUnaryOp(e){return lv.max_unop_len=Math.max(e.length,lv.max_unop_len),lv.unary_ops[e]=1,lv}static addBinaryOp(e,t,n){return lv.max_binop_len=Math.max(e.length,lv.max_binop_len),lv.binary_ops[e]=t,n?lv.right_associative.add(e):lv.right_associative.delete(e),lv}static addIdentifierChar(e){return lv.additional_identifier_chars.add(e),lv}static addLiteral(e,t){return lv.literals[e]=t,lv}static removeUnaryOp(e){return delete lv.unary_ops[e],e.length===lv.max_unop_len&&(lv.max_unop_len=lv.getMaxKeyLen(lv.unary_ops)),lv}static removeAllUnaryOps(){return lv.unary_ops={},lv.max_unop_len=0,lv}static removeIdentifierChar(e){return lv.additional_identifier_chars.delete(e),lv}static removeBinaryOp(e){return delete lv.binary_ops[e],e.length===lv.max_binop_len&&(lv.max_binop_len=lv.getMaxKeyLen(lv.binary_ops)),lv.right_associative.delete(e),lv}static removeAllBinaryOps(){return lv.binary_ops={},lv.max_binop_len=0,lv}static removeLiteral(e){return delete lv.literals[e],lv}static removeAllLiterals(){return lv.literals={},lv}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 lv(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 lv.binary_ops[e]||0}static isIdentifierStart(e){return e>=65&&e<=90||e>=97&&e<=122||e>=128&&!lv.binary_ops[String.fromCharCode(e)]||lv.additional_identifier_chars.has(String.fromCharCode(e))}static isIdentifierPart(e){return lv.isIdentifierStart(e)||lv.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(lv.hooks[e]){let n={context:this,node:t};return lv.hooks.run(e,n),n.node}return t}searchHook(e){if(lv.hooks[e]){let t={context:this};return lv.hooks[e].find(function(e){return e.call(t.context,t),t.node}),t.node}}gobbleSpaces(){let e=this.code;for(;e===lv.SPACE_CODE||e===lv.TAB_CODE||e===lv.LF_CODE||e===lv.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:lv.COMPOUND,body:e};return this.runHook("after-all",t)}gobbleExpressions(e){let t=[],n,r;for(;this.index<this.expr.length;)if((n=this.code)===lv.SEMCOL_CODE||n===lv.COMMA_CODE)this.index++;else if(r=this.gobbleExpression())t.push(r);else if(this.index<this.expr.length){if(n===e)break;this.throwError('Unexpected "'+this.char+'"')}return t}gobbleExpression(){let e=this.searchHook("gobble-expression")||this.gobbleBinaryExpression();return this.gobbleSpaces(),this.runHook("after-expression",e)}gobbleBinaryOp(){this.gobbleSpaces();let e=this.expr.substr(this.index,lv.max_binop_len),t=e.length;for(;t>0;){if(lv.binary_ops.hasOwnProperty(e)&&(!lv.isIdentifierStart(this.code)||this.index+e.length<this.expr.length&&!lv.isIdentifierPart(this.expr.charCodeAt(this.index+e.length))))return this.index+=t,e;e=e.substr(0,--t)}return!1}gobbleBinaryExpression(){let e,t,n,r,a,o,i,s,l;if(!(o=this.gobbleToken())||!(t=this.gobbleBinaryOp()))return o;for(a={value:t,prec:lv.binaryPrecedence(t),right_a:lv.right_associative.has(t)},(i=this.gobbleToken())||this.throwError("Expected expression after "+t),r=[o,a,i];t=this.gobbleBinaryOp();){if(0===(n=lv.binaryPrecedence(t))){this.index-=t.length;break}a={value:t,prec:n,right_a:lv.right_associative.has(t)},l=t;let s=e=>a.right_a&&e.right_a?n>e.prec:n<=e.prec;for(;r.length>2&&s(r[r.length-2]);)i=r.pop(),t=r.pop().value,o=r.pop(),e={type:lv.BINARY_EXP,operator:t,left:o,right:i},r.push(e);(e=this.gobbleToken())||this.throwError("Expected expression after "+l),r.push(a,e)}for(s=r.length-1,e=r[s];s>1;)e={type:lv.BINARY_EXP,operator:r[s-1].value,left:r[s-2],right:e},s-=2;return e}gobbleToken(){let e,t,n,r;if(this.gobbleSpaces(),r=this.searchHook("gobble-token"))return this.runHook("after-token",r);if(e=this.code,lv.isDecimalDigit(e)||e===lv.PERIOD_CODE)return this.gobbleNumericLiteral();if(e===lv.SQUOTE_CODE||e===lv.DQUOTE_CODE)r=this.gobbleStringLiteral();else if(e===lv.OBRACK_CODE)r=this.gobbleArray();else{for(n=(t=this.expr.substr(this.index,lv.max_unop_len)).length;n>0;){if(lv.unary_ops.hasOwnProperty(t)&&(!lv.isIdentifierStart(this.code)||this.index+t.length<this.expr.length&&!lv.isIdentifierPart(this.expr.charCodeAt(this.index+t.length)))){this.index+=n;let e=this.gobbleToken();return e||this.throwError("missing unaryOp argument"),this.runHook("after-token",{type:lv.UNARY_EXP,operator:t,argument:e,prefix:!0})}t=t.substr(0,--n)}lv.isIdentifierStart(e)?(r=this.gobbleIdentifier(),lv.literals.hasOwnProperty(r.name)?r={type:lv.LITERAL,value:lv.literals[r.name],raw:r.name}:r.name===lv.this_str&&(r={type:lv.THIS_EXP})):e===lv.OPAREN_CODE&&(r=this.gobbleGroup())}return r?(r=this.gobbleTokenProperty(r),this.runHook("after-token",r)):this.runHook("after-token",!1)}gobbleTokenProperty(e){this.gobbleSpaces();let t=this.code;for(;t===lv.PERIOD_CODE||t===lv.OBRACK_CODE||t===lv.OPAREN_CODE||t===lv.QUMARK_CODE;){let n;if(t===lv.QUMARK_CODE){if(this.expr.charCodeAt(this.index+1)!==lv.PERIOD_CODE)break;n=!0,this.index+=2,this.gobbleSpaces(),t=this.code}this.index++,t===lv.OBRACK_CODE?((e={type:lv.MEMBER_EXP,computed:!0,object:e,property:this.gobbleExpression()}).property||this.throwError('Unexpected "'+this.char+'"'),this.gobbleSpaces(),(t=this.code)!==lv.CBRACK_CODE&&this.throwError("Unclosed ["),this.index++):t===lv.OPAREN_CODE?e={type:lv.CALL_EXP,arguments:this.gobbleArguments(lv.CPAREN_CODE),callee:e}:(t===lv.PERIOD_CODE||n)&&(n&&this.index--,this.gobbleSpaces(),e={type:lv.MEMBER_EXP,computed:!1,object:e,property:this.gobbleIdentifier()}),n&&(e.optional=!0),this.gobbleSpaces(),t=this.code}return e}gobbleNumericLiteral(){let e="",t,n;for(;lv.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);if(this.code===lv.PERIOD_CODE)for(e+=this.expr.charAt(this.index++);lv.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++));lv.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);lv.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+e+this.char+")")}return n=this.code,lv.isIdentifierStart(n)?this.throwError("Variable names cannot start with a number ("+e+this.char+")"):(n===lv.PERIOD_CODE||1===e.length&&e.charCodeAt(0)===lv.PERIOD_CODE)&&this.throwError("Unexpected period"),{type:lv.LITERAL,value:parseFloat(e),raw:e}}gobbleStringLiteral(){let e="",t=this.index,n=this.expr.charAt(this.index++),r=!1;for(;this.index<this.expr.length;){let t=this.expr.charAt(this.index++);if(t===n){r=!0;break}if("\\"===t)switch(t=this.expr.charAt(this.index++)){case"n":e+="\n";break;case"r":e+="\r";break;case"t":e+=" ";break;case"b":e+="\b";break;case"f":e+="\f";break;case"v":e+="\v";break;default:e+=t}else e+=t}return r||this.throwError('Unclosed quote after "'+e+'"'),{type:lv.LITERAL,value:e,raw:this.expr.substring(t,this.index)}}gobbleIdentifier(){let e=this.code,t=this.index;for(lv.isIdentifierStart(e)?this.index++:this.throwError("Unexpected "+this.char);this.index<this.expr.length;)if(e=this.code,lv.isIdentifierPart(e))this.index++;else break;return{type:lv.IDENTIFIER,name:this.expr.slice(t,this.index)}}gobbleArguments(e){let t=[],n=!1,r=0;for(;this.index<this.expr.length;){this.gobbleSpaces();let a=this.code;if(a===e){n=!0,this.index++,e===lv.CPAREN_CODE&&r&&r>=t.length&&this.throwError("Unexpected token "+String.fromCharCode(e));break}if(a===lv.COMMA_CODE){if(this.index++,++r!==t.length){if(e===lv.CPAREN_CODE)this.throwError("Unexpected token ,");else if(e===lv.CBRACK_CODE)for(let e=t.length;e<r;e++)t.push(null)}}else if(t.length!==r&&0!==r)this.throwError("Expected comma");else{let e=this.gobbleExpression();e&&e.type!==lv.COMPOUND||this.throwError("Expected comma"),t.push(e)}}return n||this.throwError("Expected "+String.fromCharCode(e)),t}gobbleGroup(){this.index++;let e=this.gobbleExpressions(lv.CPAREN_CODE);if(this.code===lv.CPAREN_CODE)return(this.index++,1===e.length)?e[0]:!!e.length&&{type:lv.SEQUENCE_EXP,expressions:e};this.throwError("Unclosed (")}gobbleArray(){return this.index++,{type:lv.ARRAY_EXP,elements:this.gobbleArguments(lv.CBRACK_CODE)}}}Object.assign(lv,{hooks:new class{add(e,t,n){if("string"!=typeof arguments[0])for(let e in arguments[0])this.add(e,arguments[0][e],arguments[1]);else(Array.isArray(e)?e:[e]).forEach(function(e){this[e]=this[e]||[],t&&this[e][n?"unshift":"push"](t)},this)}run(e,t){this[e]=this[e]||[],this[e].forEach(function(e){e.call(t&&t.context?t.context:t,t)})}},plugins:new class{constructor(e){this.jsep=e,this.registered={}}register(...e){e.forEach(e=>{if("object"!=typeof e||!e.name||!e.init)throw Error("Invalid JSEP plugin format");this.registered[e.name]||(e.init(this.jsep),this.registered[e.name]=e)})}}(lv),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"}),lv.max_unop_len=lv.getMaxKeyLen(lv.unary_ops),lv.max_binop_len=lv.getMaxKeyLen(lv.binary_ops);let lb=e=>new lv(e).parse(),lw=Object.getOwnPropertyNames(class{});Object.getOwnPropertyNames(lv).filter(e=>!lw.includes(e)&&void 0===lb[e]).forEach(e=>{lb[e]=lv[e]}),lb.Jsep=lv,lb.plugins.register({name:"ternary",init(e){e.hooks.add("after-expression",function(t){if(t.node&&this.code===e.QUMARK_CODE){this.index++;let n=t.node,r=this.gobbleExpression();if(r||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===e.COLON_CODE){this.index++;let a=this.gobbleExpression();if(a||this.throwError("Expected expression"),t.node={type:"ConditionalExpression",test:n,consequent:r,alternate:a},n.operator&&e.binary_ops[n.operator]<=.9){let r=n;for(;r.right.operator&&e.binary_ops[r.right.operator]<=.9;)r=r.right;t.node.test=r.right,r.right=t.node,t.node=n}}else this.throwError("Expected :")}})}});let lE="ArrowFunctionExpression",lx={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)}},lD={...lx,Promise};function l_(e,t={}){return lT(e,t,lN)}async function lS(e,t={}){return lO(e,t,lN)}function lC(e,t={}){return lT(e,t,lj)}function lk(e,t={}){return lO(e,t,lj)}function lP(e,t={}){return lT(e,t,lI)}function lR(e,t={}){return lO(e,t,lI)}function lT(e,t={},n){if("string"!=typeof e&&("object"!=typeof e||!e||!("type"in e)))throw`Unknown expression type ${e}. Expressions must either be a string or pre-compiled string.`;if("string"==typeof e&&0===e.trim().length)throw{type:"Empty expression",message:"Expression cannot be an empty string"};null==t&&(t={});let r=lB(t,lx),a=lA("string"==typeof e?lb(e):e,r);if(n(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 lO(e,t={},n){if("string"!=typeof e&&("object"!=typeof e||!e||!("type"in e)))return Promise.reject(`Unknown expression type ${e}. Expressions must either be a string or pre-compiled string.`);if("string"==typeof e&&0===e.trim().length)throw{type:"Empty expression",message:"Expression cannot be an empty string"};null==t&&(t={});let r=lB(t,lD);return Promise.resolve(lA("string"==typeof e?lb(e):e,r)).then(t=>{if(n(t))return t;throw{type:"Invalid result",message:"string"==typeof e?`The expression ${e} did not produce a valid result`:"The expression did not produce a valid result"}})}function l$(e){return lb(e)}function lN(e){return"string"==typeof e||"number"==typeof e||"boolean"==typeof e||null==e||e instanceof Date}function lj(e){return"boolean"==typeof e}function lI(e){return"number"==typeof e}function lA(e,t){switch(e.type){case"UnaryExpression":var n,r,a,o,i,s,l,u,c,d,m,p,f,h=e,g=t;let y=lA(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 lA(v.left,b)&&lA(v.right,b);case"||":return lA(v.left,b)||lA(v.right,b);case"??":return lA(v.left,b)??lA(v.right,b)}let w=lA(v.left,b),E=lA(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 n=e,r=t,lA(n.test,r)?lA(n.consequent,r):lA(n.alternate,r);case"CallExpression":return lW(lL(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,n,r)=>{let a=e[r];return function e(t){if("string"==typeof t||"number"==typeof t||"boolean"==typeof t||"function"==typeof t||null===t||t instanceof RegExp)return!0;if("object"==typeof t){for(let n of Object.keys(t))if(!e(t[n]))return!1;return!0}if(Array.isArray(t)){for(let n of t)if(!e(n))break}return!1}(a)&&t.push([n,a]),t},[]));return lA(a.body,o.addVariables(t))}).bind(null);case"MemberExpression":return lW(lF(e,t));case"ArrayExpression":return i=e,s=t,i.elements?.map(lH(s));case"SequenceExpression":let D;return l=e,u=t,(D=l.expressions.map(lH(u)))[D.length-1];case"NewExpression":var _=e,S=t;if(_.callee&&"Identifier"===_.callee.type){let e=_.arguments?.map(lH(S));switch(_.callee.name){case"Date":return new Date(...e);case"RegExp":return new RegExp(...e);default:throw`Cannot instantiate object of type ${_.callee.name}`}}if(_.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,(lz(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 m=e,p=t,C=m.expressions?.map(lH(p))??[],(k=m.quasis?.map(lH(p))??[]).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:(f=e).cooked,tail:f.tail};default:throw`Expression evaluator does not support expression of type '${e.type}'`}}function lM(e,t){switch(e.type){case"Literal":return e.value;case"Identifier":return e.name;case"MemberExpression":return lM(e.property,t);default:throw`VisitExpressionName does not support expression of type '${e.type}'`}}function lL(e,t){let n=lV(e.callee,t);if(n===lU||e.optional&&null==n)return lU;let r=e.arguments?.map(lH(t));if(n){if("function"!=typeof n)throw`${lZ(e.callee)} is not a function`}else throw`No function named ${lZ(e.callee)} is defined in this context`;return n(...r)}function lF(e,t){let n=lV(e.object,t);if(n===lU||e.optional&&null==n)return lU;if(null===n)throw TypeError(`TypeError: cannot read properties of null (reading '${lG(e.property,t)}')`);if(void 0===n)switch(e.object.type){case"Identifier":{let n=lM(e.object,t);throw ReferenceError(`ReferenceError: ${n} is not defined`)}case"MemberExpression":throw TypeError(`TypeError: cannot read properties of undefined (reading '${lG(e.property,t)}')`);default:throw`VisitMemberExpression does not support operator '${e.object.type}' type`}if("object"!=typeof n&&"function"!=typeof n&&"string"!=typeof n&&"number"!=typeof n)throw`VisitMemberExpression does not support member access on type ${typeof n}`;let r=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}(lA(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);lz(r),function(e,t){if(lK.has(String(t)))return;let n=Object(e);for(;null!==n;){if(Object.hasOwn(n,t)){if(n===Object.prototype||n===Function.prototype)throw{type:"Illegal property access",message:`Cannot access the ${t} property of objects`};return}n=Object.getPrototypeOf(n)}}(n,r);let a=n[r];return"function"==typeof a?a.bind(n):a}function lB(e,t){let n={variables:{...e},globals:{...t},addVariables(e){return this.variables={...this.variables,...e},this}};return n.addVariables.bind(n),n}lb.plugins.register({name:"arrow",init(e){e.addBinaryOp("=>",.1,!0),e.hooks.add("gobble-expression",function(t){if(this.gobbleSpaces(),this.code===e.OPAREN_CODE){let n=this.index;if(this.index++,this.gobbleSpaces(),this.code===e.CPAREN_CODE){this.index++;let e=this.gobbleBinaryOp();if("=>"===e){let n=this.gobbleBinaryExpression();n||this.throwError("Expected expression after "+e),t.node={type:lE,params:null,body:n};return}}this.index=n}}),e.hooks.add("after-expression",function(t){!function t(n){n&&(Object.values(n).forEach(e=>{e&&"object"==typeof e&&t(e)}),"=>"===n.operator&&(n.type=lE,n.params=n.left?[n.left]:null,n.body=n.right,n.params&&n.params[0].type===e.SEQUENCE_EXP&&(n.params=n.params[0].expressions),delete n.left,delete n.right,delete n.operator))}(t.node)})}}),lb.plugins.register({name:"new",init(e){e.addUnaryOp("new"),e.hooks.add("after-token",function(t){let n=t.node;if(n&&"new"===n.operator){n.argument&&[e.CALL_EXP,e.MEMBER_EXP].includes(n.argument.type)||this.throwError("Expected new function()"),t.node=n.argument;let r=t.node;for(;r.type===e.MEMBER_EXP||r.type===e.CALL_EXP&&r.callee.type===e.MEMBER_EXP;)r=r.type===e.MEMBER_EXP?r.object:r.callee.object;r.type="NewExpression"}})}}),lb.plugins.register({name:"numbers",init(e){function t(e){return"x"===e||"X"===e?(this.index+=2,[[48,57],[65,70],[97,102]]):"b"===e||"B"===e?(this.index+=2,[[48,49]]):"o"===e||"O"===e||e>="0"&&e<="7"?(this.index+=e<="7"?1:2,[[48,55]]):null}function n(t){let n=this.index,r="",a=()=>{for(;e.isDecimalDigit(this.code)||95===this.code;)95===this.code?this.index++:r+=this.expr.charAt(this.index++)};a(),this.code===e.PERIOD_CODE&&(r+=this.expr.charAt(this.index++),a());let o=this.char;("e"===o||"E"===o)&&(r+=this.expr.charAt(this.index++),("+"===(o=this.char)||"-"===o)&&(r+=this.expr.charAt(this.index++)),a(),e.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+r+this.char+")"));let i=this.code;if(e.isIdentifierStart(i))this.throwError("Variable names cannot start with a number ("+r+this.char+")");else if(i===e.PERIOD_CODE){r.length>1&&this.throwError(`Unexpected period ${JSON.stringify({chCode:i,number:r},null,2)}`),this.index=n;return}t.node={type:e.LITERAL,value:parseFloat(r),raw:this.expr.substring(n,this.index)}}e.hooks.add("gobble-token",function(r){if(48===this.code){var 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,n.call(this,r);return}this.throwError("unexpected char within number")}r.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)&&n.call(this,r)})}}),lb.plugins.register({name:"regex",init(e){e.hooks.add("gobble-token",function(t){if(47===this.code){let n=++this.index,r=!1;for(;this.index<this.expr.length;){if(47===this.code&&!r){let r,a=this.expr.slice(n,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{r=new RegExp(a,o)}catch(e){this.throwError(e.message)}return t.node={type:e.LITERAL,value:r,raw:this.expr.slice(n-1,this.index)},t.node=this.gobbleTokenProperty(t.node),t.node}this.code===e.OBRACK_CODE?r=!0:r&&this.code===e.CBRACK_CODE&&(r=!1),this.index+=92===this.code?2:1}this.throwError("Unclosed Regex")}})}}),lb.plugins.register({name:"ternary",init(e){e.hooks.add("after-expression",function(t){if(t.node&&this.code===e.QUMARK_CODE){this.index++;let n=t.node,r=this.gobbleExpression();if(r||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===e.COLON_CODE){this.index++;let a=this.gobbleExpression();if(a||this.throwError("Expected expression"),t.node={type:"ConditionalExpression",test:n,consequent:r,alternate:a},n.operator&&e.binary_ops[n.operator]<=.9){let r=n;for(;r.right.operator&&e.binary_ops[r.right.operator]<=.9;)r=r.right;t.node.test=r.right,r.right=t.node,t.node=n}}else this.throwError("Expected :")}})}}),lb.plugins.register({name:"jsepTemplateLiteral",init(e){function t(e,n=!0){if(96===this.code){let t={type:"TemplateLiteral",quasis:[],expressions:[]},r="",a="",o=!1,i=this.expr.length,s=()=>t.quasis.push({type:"TemplateElement",value:{raw:a,cooked:r},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,n&&(e.node=this.gobbleTokenProperty(e.node)),e.node;if("$"===i&&"{"===this.expr.charAt(this.index+1))this.index+=2,s(),a="",r="",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":r+="\n";break;case"r":r+="\r";break;case"t":r+=" ";break;case"b":r+="\b";break;case"f":r+="\f";break;case"v":r+="\v";break;default:r+=i}else r+=i,a+=i}this.throwError("Unclosed `")}}e.hooks.add("gobble-token",t),e.hooks.add("after-token",function(n){if((n.node.type===e.IDENTIFIER||n.node.type===e.MEMBER_EXP)&&96===this.code)return n.node={type:"TaggedTemplateExpression",tag:n.node,quasi:t.bind(this)(n,!1)},n.node=this.gobbleTokenProperty(n.node),n.node})}}),lb.addBinaryOp("in",7),lb.addBinaryOp("??",1);let lU=Symbol("optional chain short-circuited");function lV(e,t){switch(e.type){case"MemberExpression":return lF(e,t);case"CallExpression":return lL(e,t);default:return lA(e,t)}}function lW(e){return e===lU?void 0:e}function lH(e){return function(t){return null===t?null:lA(t,e)}}function lz(e){if("__proto__"===e||"prototype"===e||"constructor"===e)throw{type:"Illegal property access",message:`Cannot access the ${e} property of objects`}}let lK=new Set(["toString","valueOf","hasOwnProperty"]);function lG(e,t){try{return lM(e,t)}catch{return"<computed>"}}function lZ(e){return e?"MemberExpression"===e.type?e.property?.name:e.name:null}function lY(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:{...lD},boundNames:new Set,variables:new Set};return lq("string"==typeof e?lb(e):e,t),[...t.variables]}function lq(e,t){switch(e.type){case"UnaryExpression":return n=e,r=t,void lq(n.argument,r);case"BinaryExpression":return a=e,o=t,void(lq(a.left,o),lq(a.right,o));case"ConditionalExpression":return i=e,s=t,void(lq(i.consequent,s),lq(i.test,s),lq(i.alternate,s));case"CallExpression":return l=e,u=t,void(lq(l.callee,u),l.arguments?.map(lJ(u)));case"ArrowFunctionExpression":var n,r,a,o,i,s,l,u,c,d,m,p,f,h,g,y,v,b,w,E,x=e,D=t;let _=new Set(D.boundNames);for(let e of x.params??[])e?.type==="Identifier"&&_.add(e.name);lq(x.body,{...D,boundNames:_});return;case"MemberExpression":return c=e,d=t,void(lq(c.object,d),c.computed&&lq(c.property,d));case"ArrayExpression":return m=e,p=t,void m.elements?.map(lJ(p));case"SequenceExpression":return f=e,h=t,void f.expressions?.map(lJ(h));case"NewExpression":return g=e,y=t,void g.arguments?.map(lJ(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(lJ(E)),w.quasis?.map(lJ(E)));default:throw`Expression evaluator does not support expression of type '${e.type}'`}}function lJ(e){return function(t){return null===t?null:lq(t,e)}}let lX=W("feature-flags",{flags:function(){let e={};for(let t of Object.keys(localStorage))if(t.startsWith("openmrs:feature-flag:")){let n=t.replace("openmrs:feature-flag:",""),r=JSON.parse(localStorage.getItem(`openmrs:feature-flag-meta:${n}`)||"{}");e[n]={enabled:"true"===localStorage.getItem(t),...r}}return e}()});function lQ(e,t,n){lX.setState(r=>({flags:{...r.flags,[e]:{enabled:r.flags[e]?.enabled??!1,label:t,description:n}}}))}function l0(){let e=lX.getState().flags;Object.keys(localStorage).filter(e=>e.startsWith("openmrs:feature-flag:")).forEach(t=>{let n=t.replace("openmrs:feature-flag:","");e[n]||(localStorage.removeItem(t),localStorage.removeItem(`openmrs:feature-flag-meta:${n}`))})}function l1(e){return lX.getState().flags[e].enabled}function l4(e,t){lX.subscribe(n=>{t(n.flags[e].enabled)})}function l2(e,t){lX.setState(n=>({flags:{...n.flags,[e]:{...n.flags[e],enabled:t}}}))}lX.subscribe(e=>{for(let[t,n]of Object.entries(e.flags))localStorage.setItem(`openmrs:feature-flag:${t}`,n.enabled.toString()),localStorage.setItem(`openmrs:feature-flag-meta:${t}`,JSON.stringify({label:n.label,description:n.description}))});var l3=tG(function(e,t,n){tF(e,t,n)});let l6=B("extensionsInternal",{slots:{},extensions:{}}),l5=B("extensionRenderings",{renderings:new Map}),l9=()=>W("extensionsInternal",{slots:{},extensions:{}}),l8=()=>W("extensionRenderings",{renderings:new Map});function l7(e){let t=l6.getState(),n=e(t);n!==t&&l6.setState(n)}let ue=null,ut=null;function un(){let e=l5.getState();return ue&&e===ut||(ue=new Map(e.renderings),ut=e,function(e){for(let t of(um.clear(),e.values()))uf(t,1);up=!0}(ue)),ue}function ur(e){ut={renderings:e},l5.setState(ut,!0)}function ua(e){let t=un();t.has(e.renderingId)||(t.set(e.renderingId,e),uf(e,1),ur(t))}function uo(e){let t=un(),n=t.get(e);n&&(t.delete(e),uf(n,-1),ur(t))}let ui=()=>W("extensions",{slots:{}}),us=0,ul=new Set;function uu(e){us++;try{return e()}finally{if(0==--us&&ul.size>0){let e=Array.from(ul);for(let t of(ul.clear(),e))uc(t)}}}function uc(e){try{e()}catch(t){console.error(`The extension system's '${e.name}' recomputation failed`,t)}}function ud(e){us>0?ul.add(e):uc(e)}let um=new Map,up=!1;function uf(e,t){let n=JSON.stringify([e.slotName,e.extensionId,e.slotModuleName,e.extensionModuleName]),r=um.get(n);if(!r){if(t<0)return;um.set(n,{count:1,record:{slotModuleName:e.slotModuleName,extensionModuleName:e.extensionModuleName,slotName:e.slotName,extensionId:e.extensionId}}),up=!0;return}r.count+=t,r.count<1&&(um.delete(n),up=!0)}function uh(){var e,t;if(un(),!up)return;up=!1;let n=Array.from(um.values(),({record:e})=>e);n.sort(ug),e=rw.getState().mountedExtensions,t=n,e.length===t.length&&e.every((e,n)=>0===ug(e,t[n]))||rw.setState({mountedExtensions:n})}function ug(e,t){return uy(e.slotName,t.slotName)||uy(e.extensionId,t.extensionId)||uy(e.slotModuleName,t.slotModuleName)||uy(e.extensionModuleName,t.extensionModuleName)}function uy(e,t){return e===t?0:e<t?-1:1}uh(),l5.subscribe(()=>ud(uh));let uv=l9(),ub=ui(),uw=rx(),uE=rS(),ux=new Set,uD=!1;function u_(e){if(null===e)ux=null;else if(null!==ux)for(let t of e)ux.add(t);ud(uS)}function uS(){if(!uD){uD=!0;try{for(let e=1;;e++){let t=ux;if(null!==t&&0===t.size)return;ux=new Set;try{!function(e,t,n,r,a,o=null){let i=ub.getState().slots,s={},l=!1,u=Object.entries(r.flags).filter(([,{enabled:e}])=>e).map(([e])=>e);for(let[r,c]of Object.entries(e.slots)){let d=i[r];if(d&&o&&!o.has(r)){s[r]=d;continue}let{config:m}=r_(t,c.name),p=function(e,t,n,r,a,o){let i=function(e,t){let n=e.add||[],r=e.remove||[],a=e.order||[],{extensions:o}=uv.getState(),i=new Set(r),s=[...t,...n].filter(e=>!i.has(e)),l=uI(a),u=uI(t),c=new Map(s.map(e=>[e,function(e,t,n,r){let a=t.get(e);if(void 0!==a)return a;{if(void 0!==n)return 1e3+n;let t=r.get(e);return void 0!==t?2e3+t:3e3}}(e,l,o[uP(e)]?.order,u)]));return s.sort((e,t)=>c.get(e)-c.get(t))}(n,t.slots[e].attachedIds),s=[];for(let l of i){let{config:i}=rC(r,e,l),u=rk(n,e,l),c=u?l3({},i,u):i,d=uP(l),m=t.extensions[d];if(m){let e=c?.["Display conditions"]?.privileges??m.privileges??[];if(e&&("string"==typeof e||Array.isArray(e)&&e.length>0)&&(!o?.user||!i8(e,o.user))||m.featureFlag&&!a.includes(m.featureFlag))continue;s.push({id:l,name:d,moduleName:m.moduleName,config:c,featureFlag:m.featureFlag,meta:m.meta,displayConditionExpression:c?.["Display conditions"]?.expression||m.displayExpression})}}return s}(r,e,m,n,u,a.session);d&&d.moduleName===c.moduleName&&nP(d.candidateExtensions,p)?s[r]=d:(s[r]={moduleName:c.moduleName,candidateExtensions:p},l=!0)}(l||Object.keys(i).length!==Object.keys(s).length)&&ub.setState({slots:s})}(uv.getState(),uw.getState(),uE.getState(),lX.getState(),iQ.getState(),t)}catch(e){throw ux=null===t||null===ux?null:new Set([...t,...ux]),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{uD=!1}}}function uC(e,t){let n=new Set;for(let r of Object.keys(e))e[r]!==t[r]&&n.add(r);for(let r of Object.keys(t))r in e||n.add(r);return n}function uk(e,t){return{moduleName:t,name:e,attachedIds:[]}}function uP(e){let[t]=e.split("#");return t}function uR(e,t){let n=uP(t);return e.extensions[n]}function uT(e){return uR(uv.getState(),e)}uv.subscribe((e,t)=>{u_(e.extensions!==t.extensions?null:uC(e.slots,t.slots))}),uw.subscribe((e,t)=>{u_(uC(e.slots,t.slots))}),uE.subscribe((e,t)=>{u_(uC(e.configs,t.configs))}),lX.subscribe(()=>u_(null)),iQ.subscribe(()=>u_(null)),u_(null);let uO=e=>l7(t=>({...t,extensions:{...t.extensions,[e.name]:{...e}}}));function u$(e,t){l7(n=>{let r=n.slots[e];return r?{...n,slots:{...n.slots,[e]:{...r,attachedIds:[...r.attachedIds,t]}}}:{...n,slots:{...n.slots,[e]:{...uk(e),attachedIds:[t]}}}})}function uN(e,t){l7(n=>{let r=n.slots[e];return r&&r.attachedIds.includes(t)?{...n,slots:{...n.slots,[e]:{...r,attachedIds:r.attachedIds.filter(e=>e!==t)}}}:n})}function uj(e){l7(t=>{let n=t.slots[e];return n?{...t,slots:{...t.slots,[e]:{...n,attachedIds:[]}}}:t})}function uI(e){let t=new Map;return e.forEach((e,n)=>{t.has(e)||t.set(e,n)}),t}function uA(e,t){return function(e,t,n=null,r){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:n,...t}:{session:n});try{return!!lC(o,a)}catch(t){return console.error(`Error while evaluating expression '${o}' for ${e.id}`+(r?` in ${r}`:""),t),!1}})}(uM(e),t,iQ.getState().session,e)}function uM(e){return ub.getState().slots[e]?.candidateExtensions??[]}let uL=(e,t)=>uv.setState(n=>{let r=n.slots[t]?.moduleName;if(r&&r!=e)return console.warn(`An extension slot with the name '${t}' already exists. Refusing to register the same slot name twice (in "registerExtensionSlot"). The existing one is from module ${r}.`),n;if(r&&r==e)return n;if(n.slots[t])return{...n,slots:{...n.slots,[t]:{...n.slots[t],moduleName:e}}};let a=uk(t,e);return{...n,slots:{...n.slots,[t]:{...a}}}}),uF=()=>{ux=null,l7(()=>({slots:{},extensions:{}})),l8().setState({renderings:new Map}),ub.setState({slots:{}})},uB=B("left-nav",{slotName:null,basePath:window.spaBase,mode:"normal"});function uU({name:e,basePath:t,mode:n,componentContext:r,state:a}){uB.setState({slotName:e,basePath:t,mode:n??"normal",componentContext:r,state:a})}function uV(e){uB.getState().slotName===e&&uB.setState(uB.getInitialState(),!0)}let uW=B("modalRegistry",{modals:{}});function uH(e){uW.setState(t=>(t.modals[e.name]=e,t))}function uz(e){let t=uW.getState().modals[e];if(!t){let n=uT(e);n&&(t={name:e,load:n.load,moduleName:n.moduleName},console.warn(`Modal ${e} was registered as an extension. This is deprecated and will be removed in the future. Please register it in the "modals" section of routes.json instead of the "extensions" section.`),uH(t))}return t}let uK=B("workspace2",{registeredGroupsByName:{},registeredWindowsByName:{},registeredWorkspacesByName:{},openedGroup:null,openedWindows:[],isMostRecentlyOpenedWindowHidden:!1});function uG(e){let{registeredWorkspacesByName:t,registeredWindowsByName:n}=uK.getState(),r=t[e];if(r){let t=n[r.window];if(t)return t;throw Error(`No workspace window found with name: ${r.window} for workspace: ${e}`)}throw Error(`No workspace found with name: ${e}`)}function uZ(e){let{registeredGroupsByName:t,registeredWindowsByName:n}=uK.getState(),r=n[e];if(r){let n=t[r.group];if(n)return n;throw Error(`No workspace group found with name: ${r.group} for window: ${e}`)}throw Error(`No workspace window found with name: ${e}`)}function uY(e){let{openedWindows:t}=uK.getState();return t.findIndex(t=>t.openedWorkspaces.find(t=>t.workspaceName===e))}function uq(e,t){if(0==t.length)return;let{registeredGroupsByName:n}=uK.getState(),r={...n};for(let n of t){if(r[n.name])throw Error(`Cannot register workspace group ${n.name} more than once`);r[n.name]={...n,moduleName:e}}uK.setState({registeredGroupsByName:r})}function uJ(e,t){if(0==t.length)return;let{registeredWindowsByName:n}=uK.getState(),r={...n};for(let n of t){if(r[n.name])throw Error(`Cannot register workspace window ${n.name} more than once`);let t={...n,moduleName:e};r[n.name]=t}uK.setState({registeredWindowsByName:r})}function uX(e,t){if(0==t.length)return;let{registeredWorkspacesByName:n}=uK.getState(),r={...n};for(let n of t){if(r[n.name])throw Error(`Cannot register workspace ${n.name} more than once`);let t={...n,moduleName:e};r[n.name]=t}uK.setState({registeredWorkspacesByName:r})}let uQ=0,u0=null,u1={bootstrap:15e3,mount:15e3,unmount:15e3};function u4(e,t){if(e.timeouts)return e;let n=e.name??"parcel",r=Object.fromEntries(Object.keys(u1).filter(t=>e[t]).map(r=>{var a,o;let i,s;return[r,(a=e[r],o=u1[r],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 ${r} at array index ${o} for parcel ${n} did not return a promise`))}),Promise.resolve(void 0)),e=>{let a,i=new Promise((e,t)=>{a=setTimeout(()=>t(Error(`Lifecycle function ${r} for parcel ${n} did not settle within ${o}ms`)),o)});return Promise.race([s(e),i]).finally(()=>clearTimeout(a)).then(e=>(t(r,!1),e),e=>{throw t(r,!0),e})})]}));return{...e,...r}}async function u2(e,t){var n,r;let a,o,i,s,l,u=await (u0??(u0=new Promise((e,t)=>{ot({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),ot))),u0),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 r=u((n=d.onSettled,"function"==typeof e?()=>e().then(e=>u4(e,n)):u4(e,n)),c),s=e=>t=>e.call(r,d.retarget(t)).catch(e=>{throw"SKIP_BECAUSE_BROKEN"===r.getStatus()&&d.release(),e}),l=r.update&&s(r.update),Object.defineProperty(r,"update",{configurable:!0,enumerable:!0,get:()=>l,set:e=>{l=e&&s(e)}})}function u3(){return u6}function u6(e,t){let n,r=u2(e,t).then(e=>n=e);return{mount:()=>r.then(e=>e.mount()),unmount:()=>r.then(e=>e.unmount()),update:e=>r.then(t=>t.update?.(e)),getStatus:()=>n?.getStatus()??"LOADING_SOURCE_CODE",get loadPromise(){return r.then(e=>e.loadPromise)},get bootstrapPromise(){return r.then(e=>e.bootstrapPromise)},get mountPromise(){return r.then(e=>e.mountPromise)},get unmountPromise(){return r.then(e=>e.unmountPromise)}}}async function u5(e,t,n,r,a=e=>e,o={}){let i=uP(r),s=uT(r),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:m}=s,p=uQ++,f=`${t}/${r}-${p}`;e.dataset.extensionRenderingId=f;let h=e=>{try{uo(f)}catch(t){console.error(e,t)}};try{ua({renderingId:f,extensionName:i,extensionModuleName:d,extensionId:r,slotName:t,slotModuleName:n})}catch(e){throw h(`Recomputing configuration after registering '${r}' failed also failed`),e}try{u=await m()}catch(e){throw h(`Recomputing configuration after '${r}' failed to load also failed`),e}try{l=await u2(a({...u,name:`${t}/${i}-${p}`}),{...o,_meta:c,_extensionContext:{extensionId:r,extensionSlotName:t,extensionSlotModuleName:n,extensionModuleName:d,extensionMeta:c},domElement:e})}catch(e){throw h(`Recomputing configuration after '${r}' failed to mount also failed`),e}l.mountPromise.then(void 0,e=>{console.error(`Extension '${r}' in slot '${t}' failed to mount`,e),h(`Recomputing configuration after '${r}' failed to mount also failed`)}),l.unmountPromise.then(()=>h(`Recomputing configuration after unmounting '${r}' failed`),e=>{console.error(`Extension '${r}' in slot '${t}' failed to unmount`,e),h(`Recomputing configuration after '${r}' failed to unmount also failed`)})}else console.warn(`Tried to render ${r} into ${t} but no DOM element was available.`);return l}var u9=n(2491),u8=n.n(u9);let u7=(0,u9.createContext)({moduleName:"",featureName:""});function ce({to:e,templateParams:t,onBeforeNavigate:n,children:r,...a}){return(0,u9.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}`)},[]),u8().createElement("a",{onClick:r=>{0===r.button&&!r.ctrlKey&&!r.shiftKey&&!r.altKey&&!r.metaKey&&(r.preventDefault(),n?.(r),iM({to:e,templateParams:t})),0===r.button&&(r.ctrlKey||r.metaKey)&&n?.(r),0===r.button&&r.shiftKey&&n?.(r),1===r.button&&n?.(r)},href:iI(e,t),...a},r)}let ct=({state:e,children:t,...n})=>{let{extension:r}=(0,u9.useContext)(u7),a=(0,u9.useRef)(null),o=(0,u9.useRef)(Promise.resolve()),i=(0,u9.useRef)(!1),s=(0,u9.useRef)(!1),l=(0,u9.useRef)(e),u=(0,u9.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,u9.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 '${r?.extensionId}' failed to update`,e)}))},[]),d=(0,u9.useCallback)(t=>{t&&!a.current&&!s.current&&r?.extensionSlotName&&r.extensionSlotModuleName&&(s.current=!0,u5(t,r.extensionSlotName,r.extensionSlotModuleName,r.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,u9.useEffect)(()=>(i.current=!1,()=>{i.current=!0,u(a.current)}),[]),(0,u9.useEffect)(()=>{l.current=e,a.current&&c(a.current,e)},[e]),r?u8().createElement("div",{ref:d,"data-extension-id":r?.extensionId,style:{position:"relative"},...n}):null};function cn(e){let t=(0,u9.useRef)(e);return T(t.current,e)||(t.current=e),t.current}function cr(e,t){"function"==typeof t&&(t=t(e));let n={};for(let[r,a]of Object.entries(t)){let t=function(...t){e.setState(e=>a(e,...t))};n[r]=t}return n}let ca=e=>e;function co(e,t=ca,n){let r=(0,u9.useCallback)(t=>e.subscribe(t),[e]),a=(0,u9.useCallback)(()=>t(e.getState()),[e,t]),o=(0,u9.useSyncExternalStore)(r,a,a),i=(0,u9.useMemo)(()=>n?cr(e,n):null,[e,n]);return(0,u9.useMemo)(()=>i?{...o,...i}:o,[o,i])}function ci(e,t){return co(e,ca,t)}function cs(e){return function(t){let n=(0,u9.useCallback)(t=>e.subscribe(t),[]),r=(0,u9.useCallback)(()=>e.getState(),[]),a=(0,u9.useSyncExternalStore)(n,r,r),o=(0,u9.useMemo)(()=>t?cr(e,t):null,[t]);return(0,u9.useMemo)(()=>o?{...a,...o}:a,[a,o])}}let cl=[];Object.freeze(cl);let cu={candidateExtensions:cl};Object.freeze(cu);let cc=e=>{let t=(0,u9.useCallback)(t=>t.slots?.[e]??cu,[e]);return co(ui(),t)},cd=e=>e.session;function cm(e,t){let{candidateExtensions:n}=cc(e),r=co(iQ,cd),a=cn(t);return(0,u9.useMemo)(()=>uA(e,a),[e,a,r,n])}function cp(e,t){let{moduleName:n}=(0,u9.useContext)(u7);if(!n)throw Error("ComponentContext has not been provided. This should come from @openmrs/esm-react-utils.");return(0,u9.useEffect)(()=>{uL(n,e)},[n,e]),{extensions:cm(e,t),extensionSlotName:e,extensionSlotModuleName:n}}function cf(e){return e}function ch({name:e,extensionSlotName:t,select:n=cf,children:r,state:a,style:o,...i}){if(r&&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,u9.useRef)(null),{extensions:u,extensionSlotModuleName:c}=cp(s,a),d=(0,u9.useMemo)(()=>n(u),[n,u]),m=(0,u9.useMemo)(()=>{if("function"==typeof r&&!u8().isValidElement(r))return d.map(e=>r(e,a))},[r,d]);return u8().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)=>u8().createElement(u7.Provider,{key:e.id,value:{moduleName:c,featureName:"",extension:{extensionId:e.id,extensionSlotName:s,extensionSlotModuleName:c,extensionMeta:e.meta}}},m?.[t]??("function"!=typeof r?r:null)??u8().createElement(ct,{state:a}))))}var cg=n(5873);function cy(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function cv(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?cy(Object(n),!0).forEach(function(t){var r,a,o;r=e,a=t,o=n[t],a in r?Object.defineProperty(r,a,{value:o,enumerable:!0,configurable:!0,writable:!0}):r[a]=o}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):cy(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function cb(e){return(cb="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 cw(e){return(cw="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 cE(e,t){var n;if("function"!=typeof(n=t.domElement?function(){return t.domElement}:t.domElementGetter?t.domElementGetter:e.domElementGetter?e.domElementGetter:function(e){var t=e.appName||e.name;if(!t)throw Error("single-spa's dom-element-getter-helpers was not given an application name as a prop, so it can't make a unique dom element container for the react application");var n="single-spa-application:".concat(t);return function(){var e=document.getElementById(n);return e||((e=document.createElement("div")).id=n,document.body.appendChild(e)),e}}(t)))throw Error("single-spa's dom-element-getter-helpers was given an invalid domElementGetter for application or parcel '".concat(t.name,"'. Expected a function, received ").concat(cw(n)));return function(){var e=n(t);if(!(e instanceof HTMLElement))throw Error("single-spa's dom-element-getter-helpers: domElementGetter returned an invalid dom element for application or parcel '".concat(t.name,"'. Expected HTMLElement, received ").concat(cw(e)));return e}}var cx=null;try{cx=require("react").createContext()}catch(e){}var cD={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 c_(e,t){return e.rootComponent?Promise.resolve():e.loadRootComponent(t).then(function(t){e.rootComponent=t})}function cS(e,t){return new Promise(function(n,r){e.suppressComponentDidCatchWarning||!function(e){if(!(e&&"string"==typeof e.version&&e.version.indexOf(".")>=0))return!1;var t=e.version.slice(0,e.version.indexOf("."));try{return Number(t)>=16}catch(e){return!1}}(e.React)||e.errorBoundary||e.errorBoundaryClass||(e.rootComponent.prototype?e.rootComponent.prototype.componentDidCatch||console.warn("single-spa-react: ".concat(t.name||t.appName||t.childAppName,"'s rootComponent should implement componentDidCatch to avoid accidentally unmounting the entire single-spa application.")):console.warn("single-spa-react: ".concat(t.name||t.appName||t.childAppName,"'s rootComponent does not implement an error boundary. If using a functional component, consider providing an opts.errorBoundary to singleSpaReact(opts).")));var a,o=cR(e,t,function(){n(this)}),i=cE(e,t)(),s=function(e){var t=e.reactDom,n=e.renderType,r=e.elementToRender,a=e.domElement,o=t[n];if("function"!=typeof o)throw Error('renderType "'.concat(n,'" did not return a function.'));switch(n){case"createRoot":case"unstable_createRoot":case"createBlockingRoot":case"unstable_createBlockingRoot":var i=o(a);return i.render(r),i;case"hydrateRoot":return o(a,r);default:return o(r,a),null}}({elementToRender:o,domElement:i,reactDom:cP(e),renderType:"function"==typeof(a=e).renderType?a.renderType():a.renderType});e.domElements[t.name]=i,e.renderResults[t.name]=s})}function cC(e,t){return new Promise(function(n){e.unmountResolves[t.name]=n;var r=e.renderResults[t.name];r&&r.unmount?r.unmount():cP(e).unmountComponentAtNode(e.domElements[t.name]),delete e.domElements[t.name],delete e.renderResults[t.name]})}function ck(e,t){return new Promise(function(n){e.updateResolves[t.name]||(e.updateResolves[t.name]=[]),e.updateResolves[t.name].push(n);var r=cR(e,t,null),a=e.renderResults[t.name];if(a&&a.render)a.render(r);else{var o=cE(e,t)();cP(e).render(r,o)}})}function cP(e){return e.ReactDOMClient||e.ReactDOM}function cR(e,t,n){var r=e.React.createElement(e.rootComponent,t),a=cx?e.React.createElement(cx.Provider,{value:t},r):r;return(e.errorBoundary||t.errorBoundary||e.errorBoundaryClass||t.errorBoundaryClass)&&(e.errorBoundaryClass=e.errorBoundaryClass||t.errorBoundaryClass||function(e,t){function n(t){e.React.Component.apply(this,arguments),this.state={caughtError:null,caughtErrorInfo:null},n.displayName="SingleSpaReactErrorBoundary(".concat(t.name,")")}return n.prototype=Object.create(e.React.Component.prototype),n.prototype.render=function(){return this.state.caughtError?(e.errorBoundary||t.errorBoundary)(this.state.caughtError,this.state.caughtErrorInfo,this.props):this.props.children},n.prototype.componentDidCatch=function(e,t){this.setState({caughtError:e,caughtErrorInfo:t})},n}(e,t),a=e.React.createElement(e.errorBoundaryClass,t,a)),a=e.React.createElement(e.SingleSpaRoot,cv(cv({},t),{},{mountFinished:n,updateFinished:function(){e.updateResolves[t.name]&&(e.updateResolves[t.name].forEach(function(e){return e()}),delete e.updateResolves[t.name])},unmountFinished:function(){e.unmountResolves[t.name]&&(e.unmountResolves[t.name](),delete e.unmountResolves[t.name])}}),a)}var cT=n(4011),cO=n(5327),c$=n.n(cO),cN=n(3780);let cj={strictMode:!0,throwErrorsToConsole:!0,disableTranslations:!1},cI=new Map;(0,cN.initCache)(cI);let cA={errorRetryCount:3,fetcher:iJ,focusThrottleInterval:18e5,revalidateIfStale:!0,revalidateOnFocus:!1,revalidateOnReconnect:!1,refreshInterval:0,shouldRetryOnError:e=>{if(e instanceof iX){let t=e.response.status;return!!(t>=500)||401===t||403===t||429===t}return!0},provider:()=>cI};function cM(e){if("object"!=typeof e||"string"!=typeof e.featureName||"string"!=typeof e.moduleName)throw Error("Invalid options");let t=Object.assign({},cj,e),n={...cA,...t.swrConfig};return function(e){var r,a,o,i,s;return o=a=class extends(r=u8().Component){componentDidCatch(e,n){n&&n.componentStack&&(e.extra=Object.assign(e.extra||{},{componentStack:n.componentStack})),t.throwErrorsToConsole&&setTimeout(()=>{throw e}),this.setState({caughtError:e,caughtErrorInfo:n})}render(){if(this.state.caughtError)return u8().createElement("div",null,"An error has occurred. Please try reloading the page.");{let r=u8().createElement(u9.Suspense,{fallback:null},u8().createElement(cO.SWRConfig,{value:n},u8().createElement(u7.Provider,{value:this.state.config},t.disableTranslations?u8().createElement(e,this.props):u8().createElement(cT.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},u8().createElement(e,this.props)))));return t.strictMode&&u8().StrictMode?u8().createElement(u8().StrictMode,null,r):r}}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 cL(e,t){return function(e){if("object"!==cb(e))throw Error("single-spa-react requires a configuration object");var t,n=cv(cv({},cD),e);if(!n.React)throw Error("single-spa-react must be passed opts.React");if(!n.ReactDOM&&!n.ReactDOMClient)throw Error("single-spa-react must be passed opts.ReactDOM or opts.ReactDOMClient");if(n.renderType||(null!=(t=n.ReactDOMClient)&&t.createRoot?n.renderType="createRoot":n.renderType="render"),!n.rootComponent&&!n.loadRootComponent)throw Error("single-spa-react must be passed opts.rootComponent or opts.loadRootComponent");if(n.errorBoundary&&"function"!=typeof n.errorBoundary)throw Error("The errorBoundary opt for single-spa-react must either be omitted or be a function that returns React elements");!cx&&n.React.createContext&&(cx=n.React.createContext()),n.SingleSpaRoot=function(e){function t(e){t.displayName="SingleSpaRoot(".concat(e.name,")")}return t.prototype=Object.create(e.React.Component.prototype),t.prototype.componentDidMount=function(){setTimeout(this.props.mountFinished)},t.prototype.componentWillUnmount=function(){setTimeout(this.props.unmountFinished)},t.prototype.render=function(){return setTimeout(this.props.updateFinished),this.props.children},t}(n);var r={bootstrap:c_.bind(null,n),mount:cS.bind(null,n),unmount:cC.bind(null,n)};return n.parcelCanUpdate&&(r.update=ck.bind(null,n)),r}({React:u8(),ReactDOMClient:cg,rootComponent:cM(t)(e)})}function cF(e,t){return()=>e().then(({default:e})=>cL(e,t))}function cB(e,t){return()=>Promise.resolve(cL(e,t))}let cU=cF,cV=j()(()=>({}));V("openmrs-app-context",cV);let cW={};function cH(e,t=e=>e){let n=cV.getState();return e in n?Object.freeze(Object.assign({},t?t(n[e]):n[e])):null}function cz(e,t){cV.setState(n=>(e in n||(n[e]={}),n[e]=t(n[e]),Object.assign({},n)))}function cK(e){return null===e?null:Object.freeze(Object.assign({},e))}let cG=new Map;function cZ(e,t){let n=(0,u9.useRef)(t??{}),r=(0,u9.useRef)(t=>cz(e,t)),a=(0,u9.useRef)(Symbol());return(0,u9.useEffect)(()=>{let n=t??{},r=a.current;return null===cH(e)?!function(e,t=cW){cV.setState(n=>{if(e in n)throw Error(`Attempted to re-register namespace ${e} in the app context. Each namespace must be unregistered before the name can be registered again.`);return Object.assign({},n,{[e]:t===cW?{}:t})})}(e,n):(console.warn(`Namespace ${e} is already registered in the app context. This is likely a race condition during navigation, but may indicate two components are trying to own the same namespace. Updating the existing context.`),cz(e,()=>n)),cG.set(e,r),()=>{cG.get(e)===r&&(cV.setState(t=>(e in t&&delete t[e],t)),cG.delete(e))}},[e]),(0,u9.useEffect)(()=>{let r=t??{};T(n.current,r)||(cz(e,()=>r),n.current=r)},[t]),r.current}function cY({namespace:e,value:t}){return cZ(e,t),null}let cq=({children:e,value:t,fallback:n})=>t?u8().createElement(u8().Fragment,null,e):n?u8().createElement(u8().Fragment,null,n):null;function cJ(){let e=(0,u9.useRef)();return(!e.current||e.current.signal.aborted)&&(e.current=new AbortController),(0,u9.useEffect)(()=>{let t=e.current;return()=>t?.abort()},[]),e.current}function cX(e,t=e=>e??{}){let[n,r]=(0,u9.useState)(()=>{if(cQ(e))return;let n=cH(e);if(null!==n)return t?t(n):n});return(0,u9.useEffect)(()=>{if(cQ(e))throw Error(`The namespace supplied to useAppContext must be a non-empty string, but was "${e}".`)},[e]),(0,u9.useEffect)(()=>{var n;let a;return(n=e=>{if(null==e)return void r(void 0);let n=t?t(e):e;r(e=>T(e,n)?e:n)})(cK(a=cH(e))),cV.subscribe(t=>{let r=e in t?t[e]:null;r!==a&&(a=r,n(cK(r)))})},[e,t]),n}function cQ(e){return"string"!=typeof e||0===e.trim().length}function c0(e){let t=cm(e);return(0,u9.useMemo)(()=>t.map(e=>e.id),[t])}function c1(e){return cc(e).candidateExtensions}function c4(e,t,n){let{data:r,error:a,mutate:o,isLoading:i,isValidating:s}=c$()(e?s8(e,t,n):null,iJ);return(0,u9.useMemo)(()=>({isLoading:i,data:r?.data.results??[],error:a,mutate:o,isValidating:s}),[r,a,i,s,o])}function c2(e){(0,u9.useEffect)(()=>{if(e){let e=window.getComputedStyle(document.body).overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=e}}},[e])}let c3={},c6=`No ComponentContext has been provided. This should come from "openmrsComponentDecorator".
|
|
16
16
|
Usually this is already applied when using "getAsyncLifecycle" or "getSyncLifecycle".`;function c5(e,t,n){let r=c3[e];if(r)return r;let a=new Promise(e=>{let r=n(t.getState());if(r)return void e(r);let a=t.subscribe(t=>{let r=n(t);r&&(a(),e(r))})});return c3[e]=a,a.then(()=>{c3[e]===a&&delete c3[e]}),a}function c9(e){let{moduleName:t,extension:n}=(0,u9.useContext)(u7),r=e?.externalModuleName??t;if(!r&&!n)throw Error(c6);let a=function(e){let t=(0,u9.useMemo)(()=>rE(e),[e]),n=function(e){let[t,n]=(0,u9.useState)(()=>{let t=e.getState();return t.loaded&&t.config?t.config:null});return(0,u9.useEffect)(()=>e?.subscribe(e=>{e.loaded&&e.config&&n(e.config)}),[e]),t}(t);if(!n)throw c5(e,t,e=>e.loaded?e.config:null);return n}(r),o=function(e){let t=(0,u9.useMemo)(rS,[]),n=function(e,t){let[n,r]=(0,u9.useState)(t?()=>{let n=rC(e.getState(),t.extensionSlotName,t.extensionId);if(n.loaded&&n.config)return n.config}:null);return(0,u9.useEffect)(()=>{if(t)return e.subscribe(e=>{let a=rC(e,t.extensionSlotName,t.extensionId);a.loaded&&a.config&&!nP(a.config,n)&&r(a.config)})},[e,t,n]),n}(t,e);if(!n&&e)throw c5(`${e.extensionSlotName}-${e.extensionId}`,t,t=>{let n=rC(t,e.extensionSlotName,e.extensionId);return n.loaded?n.config:null});return n||{}}(n);return(0,u9.useMemo)(()=>e?.externalModuleName&&r===e.externalModuleName?{...a}:{...a,...o},[r,e?.externalModuleName,a,o])}let c8=cm;function c7(e,t=300){let[n,r]=(0,u9.useState)(e);return(0,u9.useEffect)(()=>{let n=setTimeout(()=>{r(e)},t);return()=>{clearTimeout(n)}},[e,t]),n}var de=n(9256),dt=n.n(de);let dn=`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 dr(){let e=`${iG}/emrapi/configuration?v=${dn}`,t=dt()(e,iJ);return(0,u9.useMemo)(()=>({emrConfiguration:t.data?.data,isLoadingEmrConfiguration:t.isLoading,mutateEmrConfiguration:t.mutate,errorFetchingEmrConfiguration:t.error}),[t])}function da(){return(0,u9.useContext)(u7).extension}let di=cs(l9());function ds(e){let t=cm(e);return(0,u9.useMemo)(()=>Object.fromEntries(t.map(e=>[e.name,e.meta])),[t])}let dl=cs(ui());function du(e){let{flags:t}=co(lX);return t[e]?.enabled??!1}function dc(){let[,e]=(0,u9.useState)(0);return(0,u9.useCallback)(()=>{e(e=>e+1)},[])}function dd(e,t,n={}){return dp(e,t,dm,n)}let dm={getPaginatedUrl:(e,t,n)=>{if(!e)return null;{let r=new URL(iq(e.toString()),window.location.toString());return r.searchParams.set("limit",""+t),r.searchParams.set("startIndex",""+n),r.searchParams.set("totalCount","true"),r.toString()}},getNextUrl:e=>{let t=e?.links?.find(e=>"next"==e.rel)?.uri;if(!t)return null;{let e=new URL(t);return e.host=window.location.host,e.protocol=window.location.protocol,e.toString()}},getTotalCount:e=>e?.totalCount??NaN,getCurrentPageSize:e=>e?.results?.length??NaN,getData:e=>e?.results};function dp(e,t,n,r={}){let{getPaginatedUrl:a,getTotalCount:o,getCurrentPageSize:i,getData:s}=n,{immutable:l,swrConfig:u}=r,c=r.fetcher??iJ,[d,m]=(0,u9.useState)(1),p=(0,u9.useRef)(NaN),f=(0,u9.useRef)(NaN),h=(0,u9.useRef)(d),g=(0,u9.useRef)(!1),y=(0,u9.useRef)(!1),v=e?.toString()??"",[b,w]=(0,u9.useState)(v);v!==b&&(w(v),m(1),h.current=1,p.current=NaN,f.current=NaN,g.current=!1,y.current=!1);let E=(d-1)*t,x=(0,u9.useMemo)(()=>a(e,t,E),[e,t,E]),{data:D,..._}=(l?dt():c$())(x,c,u);D?.data&&(p.current=o(D?.data),f.current=i(D?.data),g.current=!0);let S=Math.ceil(p.current/t),C=(0,u9.useCallback)(e=>{if(!Number.isInteger(e)||e<1)return void console.warn(`useServerPagination: ignoring goTo(${e}); page must be a positive integer.`);let n=Math.ceil(p.current/t);!g.current||Number.isNaN(n)||e<=n?(h.current=e,m(e)):console.warn("Invalid attempt to go to out of bounds page: "+e)},[t]);(0,u9.useEffect)(()=>{if(!g.current)return;if(Number.isNaN(p.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(p.current/t));d>e&&(console.warn(`Invalid attempt to go to out of bounds page: ${d}; returning to page ${e}.`),h.current=e,m(e))},[d,t,v,D]);let k=(0,u9.useCallback)(()=>{C(h.current+1)},[C]),P=(0,u9.useCallback)(()=>{C(h.current-1)},[C]);return{data:s(D?.data),totalPages:S,totalCount:p.current,currentPage:d,currentPageSize:f.current,paginated:S>1,showNextButton:d<S,showPreviousButton:d>1,goTo:C,goToNext:k,goToPrevious:P,..._}}function df(e,t,n={}){return dp(e,t,dh(),n)}function dh(){return{getPaginatedUrl:(e,t,n)=>{if(!e)return null;{let r=new URL(iq(e.toString()),window.location.toString());return r.searchParams.set("_count",""+t),r.searchParams.set("_getpagesoffset",""+n),r.toString()}},getNextUrl:e=>{let t=e?.link?.find(e=>"next"==e.relation)?.url;if(!t)return null;{let e=new URL(t);return e.host=window.location.host,e.protocol=window.location.protocol,e.toString()}},getTotalCount:e=>e?.total??NaN,getCurrentPageSize:e=>e?.entry?.length??NaN,getData:e=>e?.entry?.map(e=>e.resource)}}var dg=n(6038),dy=n.n(dg);function dv(e,t={}){return db(e,dm,t)}function db(e,t,n={}){let{swrInfiniteConfig:r,immutable:a}=n,{getNextUrl:o,getTotalCount:i,getData:s}=t,l=n.fetcher??iJ,u=(0,u9.useCallback)((n,r)=>0==n?e?.toString()??null:t.getNextUrl(r.data),[e]),{data:c,size:d,setSize:m,...p}=dy()(u,l,{...r,...a?{revalidateIfStale:!1,revalidateOnFocus:!1,revalidateOnReconnect:!1}:{}}),f=o(c?.[c.length-1].data),h=i(c?.[0]?.data);return{data:c?.flatMap(e=>s(e.data)),totalCount:h,hasMore:null!=f,loadMore:()=>{m((c?.length??0)+1)},nextUri:f,...p}}function dw(e,t={}){return dE(e,dm,t)}function dE(e,t,n={}){let r=db(e,t,n),{hasMore:a,error:o,data:i,loadMore:s,isLoading:l,nextUri:u}=r;return((0,u9.useEffect)(()=>{a&&!o&&s()},[a,u]),n.partialData)?r:{...r,data:a||o?void 0:i,isLoading:l||a}}function dx(e,t={}){return dE(e,dh(),t)}function dD(e,t={}){return db(e,dh(),t)}function d_(){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 dS(){let[e,t]=(0,u9.useState)(d_);return(0,u9.useEffect)(()=>{let e=()=>{t(d_())};return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),e}let dC=e=>"small-desktop"===e||"large-desktop"===e;function dk(e){let t=(0,u9.useContext)(u7);(0,u9.useEffect)(()=>(t&&t.moduleName&&(e.componentContext=t),uU(e),()=>{uV(e.name)}),[t,e])}function dP(){return co(uB)}let dR=[];function dT(e=null,t=null){let n=new URLSearchParams;e&&n.set("tag",e),t&&n.set("q",t);let r=n.toString(),{data:a}=dw(`${iG}/location${r?"?"+r:""}`,{immutable:!0});return a??dR}function dO(e,t=!0){let n=(0,u9.useRef)(null);return(0,u9.useEffect)(()=>{let r=r=>{t&&n.current&&r.target&&r.target instanceof Node&&(n.current.contains(r.target)||e(r))};return window.addEventListener("mousedown",r),window.addEventListener("touchstart",r),()=>{window.removeEventListener("mousedown",r),window.removeEventListener("touchstart",r)}},[e,t]),n}function d$(e){let t=(0,u9.useRef)();return(0,u9.useEffect)(()=>{let n=new IntersectionObserver(t=>{for(let n of t)if(n.isIntersecting)return void e()},{threshold:1});return t.current&&n.observe(t.current),()=>{t.current&&n.unobserve(t.current)}},[t.current,e]),t}function dN(e,t={}){let{abortController:n,fetchInit:r,url:a,swrConfig:o}=t,i=cJ(),s=(0,u9.useMemo)(()=>r?.signal??n?.signal??i.signal,[n?.signal,r?.signal,i.signal]),l=(0,u9.useCallback)(e=>iJ(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),{...r,signal:s}),[s,r,a]);return c$()(e,l,o)}function dj(e=[],t=10){let[n,r]=(0,u9.useState)(1),a=(0,u9.useMemo)(()=>"number"==typeof t&&t>0?Math.max(1,Math.ceil(e.length/t)):1,[e.length,t]);n>a&&r(a);let o=Math.min(Math.max(1,n),a),i=(0,u9.useMemo)(()=>{let n=(o-1)*t,r=(o+0)*t;return e.slice(n,r)},[e,o,t]),s=(0,u9.useCallback)(e=>{!Number.isInteger(e)||e<1?console.warn(`usePagination: ignoring goTo(${e}); page must be a positive integer.`):r(e)},[]),l=(0,u9.useCallback)(()=>{r(e=>e+1)},[]),u=(0,u9.useCallback)(()=>{r(e=>Math.max(1,e-1))},[]);return(0,u9.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 dI(e,t,n,r){return{pageSizes:(0,u9.useMemo)(()=>{let n=Math.ceil(t/e);return isNaN(n)&&(n=0),[...Array(n).keys()].map(t=>(t+1)*e)},[e,t]),pageItemsCount:(0,u9.useMemo)(()=>e>t?t:e*n>t?e*(n-1)+r:e*n,[e,t,n,r])}}function dA(){let e=/\/patient\/([a-zA-Z0-9\-]+)\/?/.exec(location.pathname);return e&&e[1]}function dM(e){let[t,n]=(0,u9.useState)(e??dA()),{data:r,error:a,isValidating:o}=c$()(t?["patient",t]:null,()=>lt(t,{}));return(0,u9.useEffect)(()=>{let e=()=>{let e=dA();e!==t&&n(e)};return window.addEventListener("single-spa:routing-event",e),()=>window.removeEventListener("single-spa:routing-event",e)},[t]),(0,u9.useMemo)(()=>({isLoading:o&&!a&&!r,patient:r,patientUuid:t,error:a}),[o,a,r,t])}function dL(){let e=`${iG}/metadatamapping/termmapping?v=custom:(metadataUuid)&code=emr.primaryIdentifierType`,{data:t,error:n,isLoading:r}=c$()(e,iJ);return(0,u9.useMemo)(()=>({primaryIdentifierCode:t?.data?.results[0]?.metadataUuid,isLoading:r,error:n}),[t,n,r])}function dF(e){let{extensions:t,extensionSlotModuleName:n}=cp(e);return e?t.map(t=>({state:r})=>u8().createElement(u7.Provider,{value:{moduleName:n,featureName:"",extension:{extensionId:t.id,extensionSlotName:e,extensionSlotModuleName:n,extensionMeta:t.meta}}},u8().createElement(ct,{state:r}))):[]}function dB(){let e=(0,u9.useRef)(),[t,n]=(0,u9.useState)(null),r=null;if(!t){if(i){let e=i3().getState();e.loaded&&(r=e.session)}else i=new Promise(t=>{let n=({loaded:n,session:a})=>{n&&(t(a),r=a,e.current&&(e.current(),e.current=void 0))};n(i3().getState()),r||(e.current=i3().subscribe(n))});if(r)n(r);else throw i}(0,u9.useEffect)(()=>(e.current||(e.current=i3().subscribe(({loaded:e,session:t})=>{e&&(r=t,n(t))})),()=>{e.current&&(e.current(),e.current=void 0)}),[]);let a=t||r;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 dU=({privilege:e,fallback:t,children:n})=>{let[r,a]=(0,u9.useState)(null);return((0,u9.useEffect)(()=>{let e=i3(),t=e.subscribe(({loaded:e,session:t})=>{a(e?t?.user??null:null)}),{loaded:n,session:r}=e.getState();return n&&a(r?.user??null),t},[]),r&&i8(e,r))?u8().createElement(u8().Fragment,null,n):t?u8().createElement(u8().Fragment,null,t):null};var dV=n(4274),dW=n.n(dV),dH=n(5602);let dz=new Map;function dK(){for(let e of Array.from(dz.values()))e()}let dG={setVisitContext:(e,t)=>null==t?{manuallySetVisitUuid:null}:{manuallySetVisitUuid:t.uuid,patientUuid:t.patient?.uuid}};function dZ(e){let t=(0,u9.useId)();return(0,u9.useEffect)(()=>{if(e)return dz.set(t,e),()=>{dz.delete(t)}},[t,e]),{...ci(lp(),dG),mutateVisit:dK}}function dY(e,t=ld){let n=(0,u9.useRef)(void 0),{patientUuid:r,manuallySetVisitUuid:a,setVisitContext:o}=dZ((0,u9.useCallback)(()=>n.current?.(),[])),i=e&&r==e?a:null,s=`?patient=${e}&v=${t}&includeInactive=false`,l=`/${i}?v=${t}`,{data:u,error:c,mutate:d,isValidating:m}=c$()(e?`${iG}/visit${s}`:null,iJ),{data:p,error:f,mutate:h,isValidating:g}=c$()(e&&i?`${iG}/visit${l}`:null,iJ),y=(0,u9.useMemo)(()=>u?.data.results.find(e=>null===e.stopDatetime)??null,[u]),v=(0,u9.useMemo)(()=>i&&p?p.data:null,[p,i]),b=(0,u9.useRef)(null);(0,u9.useEffect)(()=>{!m&&y&&r===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,m,g,r]);let w=(0,u9.useCallback)(()=>{d(),h()},[d,h]);(0,u9.useEffect)(()=>{n.current=w},[w]);let E=!!(!u||i&&!p),x=!!(i?f:c);return{error:c||f,mutate:w,isValidating:m||g,activeVisit:y,currentVisit:v,currentVisitIsRetrospective:!!i,isLoading:E&&!x}}dW().extend(dH);let dq=[];function dJ(){let{data:e}=dt()(ls,ll);return e??dq}let dX=new Map;async function dQ(e,t){let n=t.indexOf("#"),r=n>=0,a=r?t.substring(0,n):e,o=r?t.substring(n+1):t,i=await sI(a);return i&&Object.hasOwn(i,o)&&"function"==typeof i[o]?d1(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`),d0)}let d0={bootstrap:()=>Promise.resolve(),mount:()=>Promise.resolve(),unmount:()=>Promise.resolve()};async function d1(e,t){if(e in dX)await dX[e];else{let n=t??await sI(e);await (dX[e]=new Promise((t,r)=>{if(Object.hasOwn(n,"startupApp")){let a=n.startupApp;if("function"==typeof a)return Promise.resolve(a()).then(()=>{rq(e),t(null)}).catch(r)}rq(e),t(null)}))}}function d4(e,t){let n=t.name;if(!n)return void console.error(`An extension definition in ${e} is missing an name and thus cannot be
|
|
17
17
|
registered. To fix this, ensure that you define the "name" field inside the
|
|
18
18
|
extension definition.`,t);t.slots&&t.slot&&console.warn(`The extension ${n} from ${e} declares both a 'slots' property and
|