@openmrs/esm-reports-app 4.5.1-pre.959 → 4.5.1-pre.965
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/dist/1776.js +1 -1
- package/dist/1776.js.map +1 -1
- package/dist/openmrs-esm-reports-app.js +2 -2
- package/dist/routes.json +1 -1
- package/package.json +1 -1
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
[1m[33mWARNING[39m[22m in [33mâš [0m asset size limit: The following asset(s) exceed the recommended size limit (244.141 KiB). This can impact web performance.
|
|
2
2
|
│ Assets:
|
|
3
|
-
│ 1776.js (558.
|
|
3
|
+
│ 1776.js (558.041 KiB)
|
|
4
4
|
│ 1305.js (631.698 KiB)
|
|
5
5
|
[0m
|
|
6
6
|
|
|
7
|
-
Rspack compiled with [1m[33m1 warning[39m[22m in 21.
|
|
7
|
+
Rspack compiled with [1m[33m1 warning[39m[22m in 21.68 s
|
package/dist/1776.js
CHANGED
|
@@ -12,7 +12,7 @@ If you're the maintainer: the 'elements' key only works with '_type' equal to 'A
|
|
|
12
12
|
${t}`)}return n}let rY=(e,t)=>{let r=structuredClone(t);if(!e)return r;for(let t of Object.keys(e)){let n=r[t],a=e[t];if(a&&(a.hasOwnProperty("_type")||a.hasOwnProperty("_default"))){r.hasOwnProperty(t)||(r[t]=a._default);let e=a._elements;if(n&&rq(e)){if(a._type===t0.Array&&Array.isArray(n)){let a=n.map(t=>rY(e,t));r[t]=a}else if(a._type===t0.Object)for(let t of Object.keys(n))n[t]=rY(e,n[t])}}else if(rJ(a)){let e=n??{};rJ(e)&&(r[t]=rY(a,e))}}return r};function rq(e){return!!e&&Object.keys(e).filter(e=>!["_default","_validators"].includes(e)).length>0}function rJ(e){return"object"==typeof e&&!Array.isArray(e)&&null!==e}function rX(e,t){let r=`${e}:::${t}`;rE.has(r)||(console.error(t),rE.add(r))}function rQ(e){e?rE.forEach(t=>{t.startsWith(e)&&rE.delete(t)}):rE.clear()}function r0(){rw.forEach(e=>e()),rw.length=0,rC.clear(),rL.clear(),rB.clear(),rF.clear(),rD=null,rx=new WeakMap,r_()}let r1={"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:t0.Object,_default:{},_validators:[t1(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(", ")}.`})]}},r4={"Display conditions":{privileges:{_description:"The privilege(s) the user must have to use this extension",_type:t0.Array,_default:[]},expression:{_description:"The expression that determines whether the extension is displayed",_type:t0.String,_default:void 0}},...r1},r2=(e,t)=>t1(r=>e<=r&&r<=t,`must be between ${e} and ${t}`),r3=e=>{let t=e.concat(["openmrsBase","openmrsSpaBase"]);return t1(e=>{if(!e||"string"!=typeof e)return!1;let r=/\${(.*?)}/g,n=r.exec(e);for(;n;){if(!t.includes(n[1]))return!1;n=r.exec(e)}return!0},"Should be a URL or path. The allowed template parameters are "+t.map(e=>"${"+e+"}").join(", "))},r6=r3([]),r5=e=>t1(t=>e.includes(t),`Must be one of the following: '${e.join("', '")}'.`),r9={inRange:r2,isUrl:r6,isUrlWithTemplateParameters:r3,oneOf:r5};var r8=r(2034);let r7=B("breadcrumbs",[]);function ne(e){return nt([e])}function nt(e){let t=[...nr(),...e.map(e=>({matcher:e.matcher instanceof RegExp?e.matcher:"string"==typeof e.matcher?(0,r8.pathToRegexp)(e.matcher).regexp:(0,r8.pathToRegexp)(e.path).regexp,settings:e}))];r7.setState(t,!0)}function nr(){return r7.getState()}function nn(e,t){if(t)return function(e,t){let[r]=e.filter(e=>e.matcher.test(t));return r}(e,t)||function(e,t){let r=t.split("/");for(;r.length>1;){r.pop();let t=nn(e,r.join("/"));if(t)return t}}(e,t)}function na(e,t){if(e.length>0){let r=nn(e,t);if(r){let t=[r],n=nn(e,r.settings.parent);for(;void 0!==n;)t.push(n),n=nn(e,n.settings.parent);return t.reverse()}}return[]}function no(e){return na(nr(),e)}var ni=Object.freeze({__proto__:null,get start(){return aT},get ensureJQuerySupport(){return ao},get setBootstrapMaxTime(){return nq},get setMountMaxTime(){return nJ},get setUnmountMaxTime(){return nX},get setUnloadMaxTime(){return nQ},get registerApplication(){return ag},get unregisterApplication(){return av},get getMountedApps(){return am},get getAppStatus(){return af},get unloadApplication(){return ab},get checkActivityFunctions(){return ay},get getAppNames(){return ap},get pathToActiveWhen(){return aD},get navigateToUrl(){return n5},get patchHistoryApi(){return ar},get triggerAppChange(){return aC},get addErrorHandler(){return nd},get removeErrorHandler(){return nm},get mountRootParcel(){return nz},get NOT_LOADED(){return nh},get LOADING_SOURCE_CODE(){return ng},get NOT_BOOTSTRAPPED(){return ny},get BOOTSTRAPPING(){return nv},get NOT_MOUNTED(){return nb},get MOUNTING(){return nw},get UPDATING(){return nD},get LOAD_ERROR(){return nS},get MOUNTED(){return nE},get UNLOADING(){return n_},get UNMOUNTING(){return nx},get SKIP_BECAUSE_BROKEN(){return nC}}),ns=("u">typeof globalThis?globalThis:"u">typeof window?window:"u">typeof global?global:"u">typeof self?self:{}).CustomEvent,nl=!function(){try{var e=new ns("cat",{detail:{foo:"bar"}});return"cat"===e.type&&"bar"===e.detail.foo}catch(e){}return!1}()?"u">typeof document&&"function"==typeof document.createEvent?function(e,t){var r=document.createEvent("CustomEvent");return t?r.initCustomEvent(e,t.bubbles,t.cancelable,t.detail):r.initCustomEvent(e,!1,!1,void 0),r}:function(e,t){var r=document.createEventObject();return r.type=e,t?(r.bubbles=!!t.bubbles,r.cancelable=!!t.cancelable,r.detail=t.detail):(r.bubbles=!1,r.cancelable=!1,r.detail=void 0),r}:ns;let nu=[];function nc(e,t,r){let n=nf(e,t,r);nu.length?nu.forEach(e=>e(n)):setTimeout(()=>{throw n})}function nd(e){if("function"!=typeof e)throw Error(np(28,!1));nu.push(e)}function nm(e){if("function"!=typeof e)throw Error(np(29,!1));let t=!1;return nu=nu.filter(r=>{let n=r===e;return t=t||n,!n}),t}function np(e,t,...r){return`single-spa minified message #${e}: ${t?t+" ":""}See https://single-spa.js.org/error/?code=${e}${r.length?`&arg=${r.join("&arg=")}`:""}`}function nf(e,t,r){let n,a=`${nN(t)} '${nR(t)}' died in status ${t.status}: `;if(e instanceof Error){try{e.message=a+e.message}catch(e){}n=e}else{console.warn(np(30,!1,t.status,nR(t)));try{n=Error(a+JSON.stringify(e))}catch(t){n=e}}return n.appOrParcelName=nR(t),t.status=r,n}let nh="NOT_LOADED",ng="LOADING_SOURCE_CODE",ny="NOT_BOOTSTRAPPED",nv="BOOTSTRAPPING",nb="NOT_MOUNTED",nw="MOUNTING",nE="MOUNTED",nD="UPDATING",nx="UNMOUNTING",n_="UNLOADING",nS="LOAD_ERROR",nC="SKIP_BECAUSE_BROKEN";function nP(e){return e.status===nE}function nk(e){try{return e.activeWhen(window.location)}catch(t){return nc(t,e,nC),!1}}function nR(e){return e.name}function nT(e){return!!e.unmountThisParcel}function nN(e){return nT(e)?"parcel":"application"}function nO(){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 n$(e,t){for(let r=0;r<e.length;r++)if(t(e[r]))return e[r];return null}function nA(e){return e&&("function"==typeof e||Array.isArray(e)&&!n$(e,e=>"function"!=typeof e))}function nI(e,t){let r=e[t]||[];0===(r=Array.isArray(r)?r:[r]).length&&(r=[()=>Promise.resolve()]);let n=nN(e),a=nR(e);return function(e){return r.reduce((r,o,i)=>r.then(()=>{let r=o(e);return nj(r)?r:Promise.reject(np(15,!1,n,a,t,i))}),Promise.resolve())}}function nj(e){return e&&"function"==typeof e.then&&"function"==typeof e.catch}let nM=[];function nL(e,t){return Promise.resolve().then(()=>e.status!==ny?e:(e.status=nv,e.bootstrap?n0(e,"bootstrap").then(r).catch(r=>{if(t)throw nf(r,e,nC);return nc(r,e,nC),e}):Promise.resolve().then(r)));function r(){return e.status=nb,e}}function nF(e,t){return Promise.resolve().then(()=>{if(e.status!==nE)return e;return e.status=nx,Promise.all(Object.keys(e.parcels).map(t=>e.parcels[t].unmountThisParcel())).then(r,n=>r().then(()=>{let r=Error(n.message);if(t)throw nf(r,e,nC);nc(r,e,nC)})).then(()=>e);function r(){return n0(e,"unmount").then(()=>{e.status=nb},r=>{if(t)throw nf(r,e,nC);nc(r,e,nC)})}})}let nB=!1,nU=!1;function nV(e,t){return Promise.resolve().then(()=>e.status!==nb?e:(nB||(window.dispatchEvent(new nl("single-spa:before-first-mount")),nB=!0),e.status=nw,n0(e,"mount").then(()=>(e.status=nE,nU||(window.dispatchEvent(new nl("single-spa:first-mount")),nU=!0),e)).catch(r=>{return e.status=nE,nF(e,!0).then(n,n);function n(){if(t)throw nf(r,e,nC);return nc(r,e,nC),e}})))}let nW=0,nH={parcels:{}};function nz(){return nK.apply(nH,arguments)}function nK(e,t){let r,n,a,o=this;if(!e||"object"!=typeof e&&"function"!=typeof e)throw Error(np(2,!1));if(e.name&&"string"!=typeof e.name)throw Error(np(3,!1,typeof e.name));let i=nW++,s=e.name||`parcel-${i}`;if("object"!=typeof t)throw Error(np(4,!1,s,typeof t));if(!t.domElement)throw Error(np(5,!1,s));let l="function"==typeof e,u=l?e:()=>Promise.resolve(e),c={id:i,parcels:{},status:l?ng:ny,customProps:t,parentName:nR(o),unmountThisParcel:()=>p.then(()=>{if(c.status!==nE)throw Error(np(6,!1,s,c.status));return nF(c,!0)}).then(e=>(c.parentName&&delete o.parcels[c.id],e)).then(e=>(n(e),e)).catch(e=>{throw c.status=nC,a(e),e})};o.parcels[i]=c;let d=u();if(!d||"function"!=typeof d.then)throw Error(np(7,!1));let m=(d=d.then(e=>{if(!e)throw Error(np(8,!1));if(s=e.name||`parcel-${i}`,Object.prototype.hasOwnProperty.call(e,"bootstrap")&&!nA(e.bootstrap))throw Error(np(9,!1,s));if(!nA(e.mount))throw Error(np(10,!1,s));if(!nA(e.unmount))throw Error(np(11,!1,s));if(e.update&&!nA(e.update))throw Error(np(12,!1,s));let t=nI(e,"bootstrap"),n=nI(e,"mount"),a=nI(e,"unmount");c.status=ny,c.name=s,c.bootstrap=t,c.mount=n,c.unmount=a,c.timeouts=n1(e.timeouts),e.update&&(c.update=nI(e,"update"),r.update=function(e){return c.customProps=e,nG(Promise.resolve().then(()=>{if(c.status!==nE)throw Error(np(32,!1,nR(c)));return c.status=nD,n0(c,"update").then(()=>(c.status=nE,c)).catch(e=>{throw nf(e,c,nC)})}))})})).then(()=>nL(c,!0)),p=m.then(()=>nV(c,!0)),f=new Promise((e,t)=>{n=e,a=t});return r={mount:()=>nG(Promise.resolve().then(()=>{if(c.status!==nb)throw Error(np(13,!1,s,c.status));return o.parcels[i]=c,nV(c)})),unmount:()=>nG(c.unmountThisParcel()),getStatus:()=>c.status,loadPromise:nG(d),bootstrapPromise:nG(m),mountPromise:nG(p),unmountPromise:nG(f)}}function nG(e){return e.then(()=>null)}function nZ(e){let t=nR(e),r="function"==typeof e.customProps?e.customProps(t,window.location):e.customProps;("object"!=typeof r||null===r||Array.isArray(r))&&(r={},console.warn(np(40,!1),t,r));let n=nO({},r,{name:t,mountParcel:nK.bind(e),singleSpa:ni});return nT(e)&&(n.unmountSelf=e.unmountThisParcel),n}let nY={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 nq(e,t,r){if("number"!=typeof e||e<=0)throw Error(np(16,!1));nY.bootstrap={millis:e,dieOnTimeout:t,warningMillis:r||1e3}}function nJ(e,t,r){if("number"!=typeof e||e<=0)throw Error(np(17,!1));nY.mount={millis:e,dieOnTimeout:t,warningMillis:r||1e3}}function nX(e,t,r){if("number"!=typeof e||e<=0)throw Error(np(18,!1));nY.unmount={millis:e,dieOnTimeout:t,warningMillis:r||1e3}}function nQ(e,t,r){if("number"!=typeof e||e<=0)throw Error(np(19,!1));nY.unload={millis:e,dieOnTimeout:t,warningMillis:r||1e3}}function n0(e,t){let r=e.timeouts[t],n=r.warningMillis,a=nN(e);return new Promise((o,i)=>{let s=!1,l=!1;e[t](nZ(e)).then(e=>{s=!0,o(e)}).catch(e=>{s=!0,i(e)}),setTimeout(()=>c(1),n),setTimeout(()=>c(!0),r.millis);let u=np(31,!1,t,a,nR(e),r.millis);function c(e){s||(!0===e?(l=!0,r.dieOnTimeout?i(Error(u)):console.error(u)):!l&&(console.warn(u),e*n+n<r.millis&&setTimeout(()=>c(e+1),n)))}})}function n1(e){let t={};for(let r in nY)t[r]=nO({},nY[r],e&&e[r]||{});return t}function n4(e){return Promise.resolve().then(()=>{let t,r;return e.loadPromise?e.loadPromise:e.status!==nh&&e.status!==nS?e:(e.status=ng,e.loadPromise=Promise.resolve().then(()=>{let n=e.loadApp(nZ(e));if(!nj(n))throw r=!0,Error(np(33,!1,nR(e)));return n.then(r=>{let n;e.loadErrorTime=null,"object"!=typeof(t=r)&&(n=34),Object.prototype.hasOwnProperty.call(t,"bootstrap")&&!nA(t.bootstrap)&&(n=35),nA(t.mount)||(n=36),nA(t.unmount)||(n=37);let a=nN(t);if(n){let r;try{r=JSON.stringify(t)}catch(e){}return console.error(np(n,!1,a,nR(e),r),t),nc(void 0,e,nC),e}return t.devtools&&t.devtools.overlays&&(e.devtools.overlays=nO({},e.devtools.overlays,t.devtools.overlays)),e.status=ny,e.bootstrap=nI(t,"bootstrap"),e.mount=nI(t,"mount"),e.unmount=nI(t,"unmount"),e.unload=nI(t,"unload"),e.timeouts=n1(t.timeouts),delete e.loadPromise,e})}).catch(t=>{let n;return delete e.loadPromise,r?n=nC:(n=nS,e.loadErrorTime=(new Date).getTime()),nc(t,e,n),e}))})}let n2="u">typeof window,n3={hashchange:[],popstate:[]},n6=["hashchange","popstate"];function n5(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(np(14,!1));t=e.currentTarget.href,e.preventDefault()}let r=an(window.location.href),n=an(t);0===t.indexOf("#")?window.location.hash=n.hash:r.host!==n.host&&n.host?window.location.href=t:n.pathname===r.pathname&&n.search===r.search?window.location.hash=n.hash:window.history.pushState(null,null,t)}function n9(e){if(e){let t=e[0].type;n6.indexOf(t)>=0&&n3[t].forEach(t=>{try{t.apply(this,e)}catch(e){setTimeout(()=>{throw e})}})}}function n8(){aP([],arguments)}function n7(e,t){return function(){let r=window.location.href,n=e.apply(this,arguments),o=window.location.href;return a&&r===o||window.dispatchEvent(function(e,t){let r;try{r=new PopStateEvent("popstate",{state:e})}catch(t){(r=document.createEvent("PopStateEvent")).initPopStateEvent("popstate",!1,!1,e)}return r.singleSpa=!0,r.singleSpaTrigger=t,r}(window.history.state,t)),n}}let ae=null,at=!1;function ar(e){if(at)throw Error(np(43,!1));a=!e||!e.hasOwnProperty("urlRerouteOnly")||e.urlRerouteOnly,at=!0,ae=window.history.replaceState,window.addEventListener("hashchange",n8),window.addEventListener("popstate",n8);let t=window.addEventListener,r=window.removeEventListener;window.addEventListener=function(e,r){if(!("function"==typeof r&&n6.indexOf(e)>=0)||n$(n3[e],e=>e===r))return t.apply(this,arguments);n3[e].push(r)},window.removeEventListener=function(e,t){return"function"==typeof t&&n6.indexOf(e)>=0&&(n3[e]=n3[e].filter(e=>e!==t)),r.apply(this,arguments)},window.history.pushState=n7(window.history.pushState,"pushState"),window.history.replaceState=n7(ae,"replaceState")}function an(e){let t=document.createElement("a");return t.href=e,t}n2&&(window.singleSpaNavigate?console.warn(np(41,!1)):window.singleSpaNavigate=n5);let aa=!1;function ao(e=window.jQuery){if(e||window.$&&window.$.fn&&window.$.fn.jquery&&(e=window.$),e&&!aa){let t=e.fn.on,r=e.fn.off;e.fn.on=function(e,r){return ai.call(this,t,window.addEventListener,e,r,arguments)},e.fn.off=function(e,t){return ai.call(this,r,window.removeEventListener,e,t,arguments)},aa=!0}}function ai(e,t,r,n,a){return"string"!=typeof r?e.apply(this,a):(r.split(/\s+/).forEach(e=>{n6.indexOf(e)>=0&&(t(e,n),r=r.replace(e,""))}),""===r.trim()?this:e.apply(this,a))}let as={};function al(e){return Promise.resolve().then(()=>{let t=as[nR(e)];if(!t)return e;if(e.status===nh)return au(e,t),e;if(e.status===n_)return t.promise.then(()=>e);if(e.status!==nb&&e.status!==nS)return e;let r=e.status===nS?Promise.resolve():n0(e,"unload");return e.status=n_,r.then(()=>(au(e,t),e)).catch(r=>(delete as[nR(e)],delete e.bootstrap,delete e.mount,delete e.unmount,delete e.unload,nc(r,e,nC),t.reject(r),e))})}function au(e,t){delete as[nR(e)],delete e.bootstrap,delete e.mount,delete e.unmount,delete e.unload,e.status=nh,t.resolve()}function ac(e,t,r,n){as[nR(e)]={app:e,resolve:r,reject:n},Object.defineProperty(as[nR(e)],"promise",{get:t})}let ad=[];function am(){return ad.filter(nP).map(nR)}function ap(){return ad.map(nR)}function af(e){let t=n$(ad,t=>nR(t)===e);return t?t.status:null}let ah=!1;function ag(e,t,r,n){var a,o;let i,s,l=(i={name:null,loadApp:null,activeWhen:null,customProps:null},"object"==typeof e?(function(e){if(Array.isArray(e)||null===e)throw Error(np(39,!1));let t=["name","app","activeWhen","customProps"],r=Object.keys(e).reduce((e,r)=>t.indexOf(r)>=0?e:e.concat(r),[]);if(0!==r.length)throw Error(np(38,!1,t.join(", "),r.join(", ")));if("string"!=typeof e.name||0===e.name.length||"object"!=typeof e.app&&"function"!=typeof e.app)throw Error(np(20,!1));let n=e=>"string"==typeof e||"function"==typeof e;if(!(n(e.activeWhen)||Array.isArray(e.activeWhen)&&e.activeWhen.every(n)))throw Error(np(24,!1));if(!aE(e.customProps))throw Error(np(22,!1))}(e),i.name=e.name,i.loadApp=e.app,i.activeWhen=e.activeWhen,i.customProps=e.customProps):(function(e,t,r,n){if("string"!=typeof e||0===e.length)throw Error(np(20,!1));if(!t)throw Error(np(23,!1));if("function"!=typeof r)throw Error(np(24,!1));if(!aE(n))throw Error(np(22,!1))}(e,t,r,n),i.name=e,i.loadApp=t,i.activeWhen=r,i.customProps=n),i.loadApp="function"!=typeof(a=i.loadApp)?()=>Promise.resolve(a):a,i.customProps=i.customProps||{},s=(s=Array.isArray(o=i.activeWhen)?o:[o]).map(e=>"function"==typeof e?e:aD(e)),i.activeWhen=e=>s.some(t=>t(e)),i);if(aR||ah||(ah=!0,setTimeout(()=>{aR||console.warn(np(1,!1))},5e3)),-1!==ap().indexOf(l.name))throw Error(np(21,!1,l.name));ad.push(nO({loadErrorTime:null,status:nh,parcels:{},devtools:{overlays:{options:{},selectors:[]}}},l)),n2&&(ao(),aP())}function ay(e=window.location){return ad.filter(t=>t.activeWhen(e)).map(nR)}function av(e){if(0===ad.filter(t=>nR(t)===e).length)throw Error(np(25,!1,e));return(n2?ab(e,{waitForUnmount:!1}):Promise.resolve()).then(()=>{let t=ad.map(nR).indexOf(e);ad.splice(t,1)})}function ab(e,t={waitForUnmount:!1}){if("string"!=typeof e)throw Error(np(26,!1));let r=n$(ad,t=>nR(t)===e);if(!r)throw Error(np(27,!1,e));let n=as[nR(r)];if(t&&t.waitForUnmount){if(n)return n.promise;{let e=new Promise((t,n)=>{ac(r,()=>e,t,n)});return e}}{let e;return n?(e=n.promise,aw(r,n.resolve,n.reject)):e=new Promise((t,n)=>{ac(r,()=>e,t,n),aw(r,t,n)}),e}}function aw(e,t,r){Promise.resolve().then(()=>{if(n$(ay(),t=>t===nR(e)))return aC()}).then(()=>nF(e).then(al).then(()=>{t(),setTimeout(()=>{aP()})})).catch(r)}function aE(e){return!e||"function"==typeof e||"object"==typeof e&&null!==e&&!Array.isArray(e)}function aD(e,t){let r=function(e,t){let r=0,n=!1,a="^";"/"!==e[0]&&(e="/"+e);for(let t=0;t<e.length;t++){let r=e[t],a=n&&"/"===r;(!n&&":"===r||a)&&o(t)}return o(e.length),RegExp(a,"i");function o(o){let i=e.slice(r,o).replace(/[|\\{}()[\]^$+*?.]/g,"\\$&");if(a+=n?"[^/]+/?":i,o===e.length)if(n)t&&(a+="$");else{let e=t?"":".*";a="/"===a.charAt(a.length-1)?`${a}${e}$`:`${a}(/${e})?(#.*)?$`}n=!n,r=o}}(e,t);return e=>{let t=e.origin;t||(t=`${e.protocol}//${e.host}`);let n=e.href.replace(t,"").replace(e.search,"").split("?")[0];return r.test(n)}}let ax=!1,a_=[],aS=n2&&window.location.href;function aC(){return aP()}function aP(e=[],t,r=!1){let n,a,o,i,s;if(ax)return new Promise((e,r)=>{a_.push({resolve:e,reject:r,eventArguments:t})});let{appsToUnload:l,appsToUnmount:u,appsToLoad:c,appsToMount:d}=(n=[],a=[],o=[],i=[],s=(new Date).getTime(),ad.forEach(e=>{let t=e.status!==nC&&nk(e);switch(e.status){case nS:t&&s-e.loadErrorTime>=200&&o.push(e);break;case nh:case ng:t&&o.push(e);break;case ny:case nb:!t&&as[nR(e)]?n.push(e):t&&i.push(e);break;case nE:t||a.push(e)}}),{appsToUnload:n,appsToUnmount:a,appsToLoad:o,appsToMount:i}),m,p=[],f=aS,h=aS=window.location.href;return aR?(ax=!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(r=>{if(r.some(e=>e))return ae.call(window.history,history.state,"",f.substring(location.origin.length)),aS=location.href,ax=!1,aP(e,t,!0);let n=l.map(al),a=Promise.all(u.map(nF).map(e=>e.then(al)).concat(n));a.then(()=>{w("before-mount-routing-event",b(!0))},e=>{throw e});let o=c.map(e=>n4(e).then(e=>ak(e,a))),i=d.filter(e=>0>c.indexOf(e)).map(e=>ak(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(n4)).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(np(42,!1))),console.warn(e),!1)))}function y(){let t=am();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(ax=!1,a_.length>0){let e=a_;a_=[],aP(e)}return t}function v(){r||(e.forEach(e=>{n9(e.eventArguments)}),n9(t))}function b(e=!1,r){let n={},a={[nE]:[],[nb]:[],[nh]:[],[nC]:[]};e?(c.concat(d).forEach((e,t)=>{i(e,nE)}),l.forEach(e=>{i(e,nh)}),u.forEach(e=>{i(e,nb)})):m.forEach(e=>{i(e)});let o={detail:{newAppStatuses:n,appsByNewStatus:a,totalAppChanges:m.length,originalEvent:null==t?void 0:t[0],oldUrl:f,newUrl:h}};return r&&nO(o.detail,r),o;function i(e,t){let r=nR(e);t=t||af(r),n[r]=t,(a[t]=a[t]||[]).push(r)}}function w(e,t){r||window.dispatchEvent(new nl(`single-spa:${e}`,t))}}function ak(e,t){return nk(e)?nL(e).then(e=>t.then(()=>nk(e)?nV(e):e)):t.then(()=>e)}let aR=!1;function aT(e){aR=!0,n2&&(ar(e),aP())}n2&&window.__SINGLE_SPA_DEVTOOLS__&&(window.__SINGLE_SPA_DEVTOOLS__.exposedMethods={getRawAppData:function(){return[...ad]},reroute:aP,NOT_LOADED:nh,toLoadPromise:n4,toBootstrapPromise:nL,unregisterApplication:av,getProfilerData:function(){return nM}});let aN={address1:"Address line 1",address2:"Address line 2",address3:"Address line 3",address4:"Address line 4",address5:"Address line 5",address6:"Address line 6",city:"City",cityVillage:"City",country:"Country",countyDistrict:"District",district:"District",postalCode:"Postal code",state:"State",stateProvince:"State",closeAllOpenedWorkspaces:"Discard changes in {{count}} workspaces",closingAllWorkspacesPromptBody:"There may be unsaved changes in the following workspaces. Do you want to discard changes in the following workspaces? {{workspaceNames}}",closingAllWorkspacesPromptTitle:"You have unsaved changes",discard:"Discard",hide:"Hide",maximize:"Maximize",minimize:"Minimize",openAnyway:"Open anyway",unsavedChangesInOpenedWorkspace:"You may have unsaved changes in the opened workspace. Do you want to discard these changes?",unsavedChangesInWorkspace:'There may be unsaved changes in "{{workspaceName}}". Please save them before opening another workspace.',unsavedChangesTitleText:"Unsaved changes",workspaceHeader:"Workspace header",discardUnsavedChangesPromptBodyMultiple:"{{count}} workspaces have unsaved changes. Closing them will discard the changes:",discardUnsavedChangesPromptBodySingle:"<strong>{{workspaceTitle}}</strong> has unsaved changes. Closing it will discard them.",discardUnsavedChangesPromptTitle:"Discard unsaved changes?",keepEditing:"Keep editing",abnormalValue:"Abnormal value",actions:"Actions",actionableNotification:"Actionable notification",address:"Address",age:"Age",applicationError:"Application Error",batchActionItemSelected:"{{totalSelected}} item selected",batchActionsItemsSelected:"{{totalSelected}} items selected",cancel:"Cancel",change:"Change",Clinic:"Clinic",clearDevOverrides:"Clear dev overrides",close:"Close",closesActionableNotification:"Close actionable notification",closeSnackbar:"Close snackbar",confirm:"Confirm",contactAdministratorIfIssuePersists:"Contact your system administrator if the problem persists.",contactDetails:"Contact details",copied:"Copied!",copyToClipboard:"Copy to clipboard",delete:"Delete",discardChanges:"Discard changes",edit:"Edit",emptyStateText:"There are no {{displayText}} to display",error:"Error",errorCopy:"Sorry, there was a problem displaying this information. You can try to reload this page, or contact the site administrator and quote the error code above.",errorLoadingLoginLocations:"Unable to load login locations. Please try again or contact support if the problem persists.",female:"Female",leftNavigation:"Left navigation",loading:"Loading",localVersion:"Local Build",male:"Male",navigateNonHttp:"Could not navigate to the requested page as it is not a safe URL",noResultsToDisplay:"No results to display",notAvailable:"Not available",other:"Other",paginationItemsCount:"{{pageItemsCount}} / {{totalItems}} items",paginationOfPages:"of {{count}} pages",patientAvatarAlt:"Avatar for {{patientName}}",patientIdentifierSticker:"Patient identifier sticker",patientLists:"Patient lists",patientPhotoAlt:"Profile photo of {{patientName}}",patientPhotoPlaceholder:"Photo placeholder for {{patientName}}",prereleaseVersion:"Prerelease",print:"Print",printError:"Print error",printErrorExplainer:"An error occurred in {{errorLocation}}",printIdentifierSticker:"Print identifier sticker",printing:"Printing",provisional:"Provisional",recordNewEntry:"Record {{displayText}}",relationships:"Relationships",reload:"Reload",resetOverrides:"Reset overrides",save:"Save",scriptLoadingFailed:"Error: Script failed to load",scriptLoadingError:"Failed to load overridden script from {{url}}. Please check that the bundled script is available at the expected URL. Click the button below to reset all import map overrides.",searchForLocation:"Search for a location",seeAll:"See all",seeMoreLists:"See {{count}} more lists",selectAll:"Select all",serverStartingUp:"The server is starting",serverStartingUpExplainer:"This can take a few minutes. OpenMRS will open automatically when the server is ready.",serverStartingUpSlowExplainer:"This is taking longer than usual. First startup after an upgrade can take 10 minutes or more. You can leave this page open.",sex:"Sex",showLess:"Show less",showMore:"Show more",snackbarNotification:"Snackbar notification",somethingWentWrongTryReloading:"Something went wrong. Please try reloading.",toggleDevTools:"Toggle dev tools",unknown:"Unknown",viewSetupProgress:"View setup progress",waitingForServer:"Waiting for the server",yearAbbreviation:"yr",yearsAbbreviation:"yrs"};var aO=r(4557),a$=r.n(aO);let aA=a$().default||a$();function aI(e,t,r,n){return aA.t(t,{ns:e,defaultValue:r,...n})}function aj(e,t,r){return aN[e]?aI("core",e,t??aN[e],r):(console.error(`O3 Core Translations does not provide key '${e}'. The key itself is being rendered as text.`),e)}function aM(e,t){let r=window.getOpenmrsSpaBase().replace(/\/$/,""),n=aL(e,{openmrsBase:window.openmrsBase,openmrsSpaBase:r,...t});return e.startsWith("//")?n:n.replace(/^\/\//,"/")}function aL(e,t){return Object.keys(t).reduce((e,r)=>e.split("${"+r+"}").join(t[r]),e)}function aF({to:e,templateParams:t}){let r=window.getOpenmrsSpaBase().replace(/\/$/,""),n=aM(e,t).replace(window.location.origin,""),a=new URL(n,window.location.origin);if("http:"!=a.protocol&&"https:"!=a.protocol)throw console.error(`Received request to navigate to non-http URL: ${a.toString()}`),Error(aj("navigateNonHttp"));n.startsWith(r)?n5(n):window.location.assign(n)}aA.on("initialized",function(){window.i18next.loadNamespaces(["core"])});let aB="openmrs:history";function aU(e){let t=JSON.parse(sessionStorage.getItem(aB)??"[]")||[];t.push(e),t.length>50&&(t=t.slice(-50)),sessionStorage.setItem(aB,JSON.stringify(t))}function aV(){0===JSON.parse(sessionStorage.getItem(aB)??"[]").length&&document.referrer&&aU(document.referrer),window.addEventListener("single-spa:routing-event",e=>{let t=aW();e.detail.originalEvent?.singleSpaTrigger=="replaceState"?(t[t.length-1]=window.location.href,sessionStorage.setItem(aB,JSON.stringify(t))):!e.detail.originalEvent?.singleSpa&&t.includes(window.location.href)?aH({toUrl:window.location.href}):t[t.length-1]!==window.location.href&&aU(window.location.href)})}function aW(){return JSON.parse(sessionStorage.getItem(aB)??"[]")}function aH({toUrl:e}){let t=aW(),r=t.lastIndexOf(e);if(-1!=r){let e=t.slice(0,r+1);aF({to:t[r]}),sessionStorage.setItem(aB,JSON.stringify(e))}else throw Error(`URL ${e} not found in history; cannot go back to it.`)}function az(){sessionStorage.removeItem(aB)}let aK="${openmrsSpaBase}/login",aG={redirectAuthFailure:{enabled:{_type:t0.Boolean,_default:!0,_description:"Whether to redirect logged-out users to `redirectAuthFailure.url`"},url:{_type:t0.String,_default:aK,_validators:[r9.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:t0.Array,_default:[401],_elements:{_type:t0.Number,_validators:[r9.inRange(100,600)]},_description:"The HTTP error codes for which users will be redirected"},resolvePromise:{_type:t0.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:t0.Boolean,_default:!0,_description:"Whether openmrsFetch should support redirects returned from the backend"}};function aZ(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}let aY="/ws/rest/v1",aq="/ws/fhir2/R4",aJ=`${aY}/session`;function aX(e){return e&&e.startsWith("http")?e:("/"!==e[0]&&(e="/"+e),window.openmrsBase+e)}function aQ(e,t={}){if("string"!=typeof e)throw Error("The first argument to @openmrs/api's openmrsFetch function must be a url string");if("object"!=typeof t)throw Error("The second argument to @openmrs/api's openmrsFetch function must be a plain object.");if(!window.openmrsBase)throw Error("@openmrs/api is running in a browser that doesn't have window.openmrsBase, which is provided by openmrs-module-spa's HTML file.");let r=aX(e);t.headers||(t.headers={}),ed(t.body)&&(t.body=JSON.stringify(t.body)),void 0===t.headers.Accept&&(t.headers.Accept="application/json"),null===t.headers.Accept&&delete t.headers.Accept;let n=!1;try{let e=new URL(r,window.location.href),t=new URL(aX(aY),window.location.href),a=e.pathname.replace(/\/{2,}/g,"/"),o=t.pathname.replace(/\/{2,}/g,"/");n=e.origin===t.origin&&(a===o||a.startsWith(`${o}/`))}catch{}if(n){let e=!1;for(let[r,n]of Object.entries(t.headers))"disable-www-authenticate"===r.toLowerCase()&&(void 0===n?delete t.headers[r]:e=!0);e||(t.headers["Disable-WWW-Authenticate"]="true")}if(e.startsWith(aq)){let e=new URL(r,window.location.toString());e.searchParams.has("_summary")||(e.searchParams.set("_summary","data"),r=e.toString())}let a=Error();return window.fetch(r,t).then(async e=>{let{redirectAuthFailure:n,followRedirects:o}=await rI("@openmrs/esm-api");if(e.ok){let t=e.headers.get("location");return(o&&t&&(r===aX(aJ)||204===e.status)&&aF({to:t}),204===e.status)?(e.data=null,e):e.clone().text().then(t=>{try{t&&(e.data=JSON.parse(t))}catch(e){}return e})}return(r===aX(aJ)&&403===e.status||n.enabled&&n.errors.includes(e.status))&&(az(),aF({to:n.url||e.headers.get("location")||aK}),!0!==t.rejectAuthFailure)?n.resolvePromise?Promise.resolve():new Promise(()=>{}):e.clone().text().then(t=>{let n=t;try{n=JSON.parse(t)}catch(e){}throw new a0(r,e,n,a)},()=>{throw new a0(r,e,null,a)})})}class a0 extends Error{constructor(e,t,r,n){super(),aZ(this,"response",void 0),aZ(this,"responseBody",void 0),this.message=`Server responded with ${t.status} (${t.statusText}) for url ${e}. Check err.responseBody or network tab in dev tools for more info`,n.message=this.message,this.responseBody=r,this.response=t,this.stack=`Stacktrace for outgoing request:
|
|
13
13
|
${n.stack}
|
|
14
14
|
Stacktrace for incoming response:
|
|
15
|
-
${this.stack}`}}let a1=B("session",{loaded:!1,session:null}),a4=0,a2=null;function a3(){return a2||(a1.getState().loaded&&a4>=Date.now()-6e4?null:a8())}function a6(e){let t=e?.includeAuthStatus??!0,r=e=>t?e:e.user,n=a3();return n?new Promise(e=>{let t=()=>{let t=a1.getState();t.loaded&&(a(),e(r(t.session)))},a=a1.subscribe(t);n.then(t,t)}):Promise.resolve(r(a1.getState().session))}function a5(){return a3(),a1}function a9(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 a8(e,t){a4=Date.now(),o??(o=a4);let r={};e&&t&&(r.Authorization=`Basic ${window.btoa(`${e}:${t}`)}`);let n=ol(aQ(aJ,{headers:r,rejectAuthFailure:!0})),a=()=>{a2===n&&(a2=null)};return n.then(a,a),a2=n,n}function a7(){a1.setState({loaded:!0,session:{authenticated:!1,sessionId:""}},!0)}function oe(e,t){var r,n;if(void 0===t)return!e;if(!e)return!0;return r=e,n=t,("string"==typeof r?!K(n.privileges.find(e=>r===e.display)):Array.isArray(r)?r.every(e=>!K(n.privileges.find(t=>e===t.display))):(K(r)||console.error(`Could not understand privileges "${r}"`),!0))||!K(t.roles.find(e=>"System Developer"===e.display))}function ot(){let e,t;return new Promise(r=>{let n=n=>{n.loaded&&n.session.user&&(e=n.session.user,r(n.session.user),t&&t())};n(a1.getState()),e||(t=a1.subscribe(n))})}async function or(){return(await a6()).sessionLocation}async function on(e,t){return ol(aQ(aJ,{method:"POST",body:{sessionLocation:e},headers:{"Content-Type":"application/json"},rejectAuthFailure:!0,signal:t?.signal}))}async function oa(e,t){return await aQ(aJ,{method:"POST",body:{locale:e},headers:{"Content-Type":"application/json"},signal:t?.signal}),a8()}async function oo(e,t,r){return r||(r=new AbortController),await aQ(`${aY}/user/${e}`,{method:"POST",body:{userProperties:t},headers:{"Content-Type":"application/json"},signal:r.signal}),a8()}async function oi(e,t=!1){let r=await aQ(t?`${aJ}?rememberMe=true`:aJ,{headers:{"X-Totp-Code":e}});return r.data?.authenticated?(await a8()).session:r.data}async function os(){try{await aQ(aJ,{method:"DELETE",rejectAuthFailure:!0})}catch(e){if(!ou(e))throw e}a7(),await a8().catch(()=>{})}function ol(e){return new Promise((t,r)=>{e.then(e=>{if("object"==typeof e?.data){let r={loaded:!0,session:e.data};a1.setState(r,!0),t(r)}else!function(e){if(!e?.redirected||!e.url)return!1;try{return new URL(e.url,window.location.href).pathname.replace(/\/+$/,"").endsWith("/initialsetup")}catch{return!1}}(e)?r(oc(Error("The session endpoint did not respond with a session"))):r(oc(Error("The server is still starting up"),!0))}).catch(e=>{var n,a;if(ou(e)){"object"==typeof(n=e.responseBody)&&null!==n&&!1===n.authenticated?a1.setState({loaded:!0,session:e.responseBody},!0):a7(),t(a1.getState());return}(a=e)instanceof a0&&502===a.response.status&&!a1.getState().loaded&&void 0!==o&&Date.now()-o<18e4?r(oc(e,!0)):(P(`Failed to fetch new session information: ${e}`),r(oc(e)))})})}function ou(e){return e instanceof a0&&(401===e.response.status||403===e.response.status)}function oc(e,t=!1){return a1.getState().loaded||a1.setState({loaded:!1,session:null,error:e instanceof Error?e:Error(String(e)),initializing:t},!0),a1.getState()}function od(){return"development"===window.spaEnv||"true"===localStorage.getItem("openmrs:devtools")}a1.subscribe(e=>{e.loaded&&e.session&&a9(e.session)});let om={"webservices.rest":"2.24.0",fhir2:"1.0.0-SNAPSHOT"};function op(){rk("@openmrs/esm-api",aG),a8()}let of="import-map-override:",oh="import-map-overrides-disabled",og="import-map-overrides:change",oy=!1,ov=null,ob=null;async function ow(){return ob??(ob=oE().then(({map:e,complete:t})=>(t||(ob=null),e))),ob}async function oE(){let e=document.querySelectorAll('script[type="systemjs-importmap"]'),t=[],r=!0;for(let n=0;n<e.length;n++){let a=e[n];try{if(a.src){let e=await fetch(a.src);if(!e.ok)throw Error(`Request for ${a.src} returned ${e.status} ${e.statusText}`);t.push(await e.json())}else a.textContent&&t.push(JSON.parse(a.textContent))}catch(e){r=!1,console.warn(`[import-maps] Failed to parse import map from script tag at index ${n}`,e)}}return{map:oD(t),complete:r}}function oD(e){let t={imports:{}};for(let r of e)r?.imports&&Object.assign(t.imports,r.imports);return t}function ox(){let e={};try{let t=ok();for(let r=0;r<localStorage.length;r++){let n=localStorage.key(r);if(n?.startsWith(of)){let r=n.slice(of.length);if(!t.includes(r)){let t=localStorage.getItem(n);t&&(e[r]=t)}}}}catch(e){console.warn("[import-maps] Failed to read import-map overrides from localStorage",e)}return{imports:e}}async function o_(){let e=await ow();return oy?oD([e,ov??ox()]):e}async function oS(){return ow()}async function oC(){return oy?oD([await ow(),ox()]):ow()}function oP(e){if(!oy)return{imports:{}};if(e){let e={};for(let t=0;t<localStorage.length;t++){let r=localStorage.key(t);if(r?.startsWith(of)){let t=localStorage.getItem(r);t&&(e[r.slice(of.length)]=t)}}return{imports:e}}return ox()}function ok(){if(!oy)return[];try{let e=localStorage.getItem(oh);if(e){let t=JSON.parse(e);if(Array.isArray(t))return t}}catch{}return[]}function oR(e){return!!oy&&ok().includes(e)}function oT(e,t){if(!oy)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{localStorage.setItem(of+e,t),window.dispatchEvent(new CustomEvent(og))}catch(e){console.warn("[import-maps] Failed to write import-map override to localStorage",e)}}function oN(e){if(!oy)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{localStorage.removeItem(of+e);let t=ok().filter(t=>t!==e);t.length>0?localStorage.setItem(oh,JSON.stringify(t)):localStorage.removeItem(oh),window.dispatchEvent(new CustomEvent(og))}catch(e){console.warn("[import-maps] Failed to update import-map overrides in localStorage",e)}}function oO(){if(!oy)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{let e=[];for(let t=0;t<localStorage.length;t++){let r=localStorage.key(t);r?.startsWith(of)&&e.push(r)}e.forEach(e=>localStorage.removeItem(e)),localStorage.removeItem(oh),window.dispatchEvent(new CustomEvent(og))}catch(e){console.warn("[import-maps] Failed to clear import-map overrides from localStorage",e)}}function o$(e){if(!oy)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{let t=ok().filter(t=>t!==e);t.length>0?localStorage.setItem(oh,JSON.stringify(t)):localStorage.removeItem(oh),window.dispatchEvent(new CustomEvent(og))}catch(e){console.warn("[import-maps] Failed to update import-map overrides in localStorage",e)}}let oA=!1;function oI(){!oA&&(oA=!0,(oy="development"===window.spaEnv)&&(ov=ox()))}function oj(e){return e.replace(/[\/\-@]/g,"_")}async function oM(e,t="./start",n){var a;let o,i=!n?.maxLoadingTime||n.maxLoadingTime<=0?6e5:n.maxLoadingTime;await Promise.race([oL(e,n?.importMap),new Promise((t,r)=>{o=setTimeout(()=>{var t;r(Error(`Could not resolve requested script, ${e}, within ${(t=i)<1e3?`${t} milliseconds`:t<6e4?`${Math.floor(t/1e3)} seconds`:t<36e5?`${Math.floor(t/6e4)} minutes`:t<864e5?`${Math.floor(t/36e5)} hours`:`${Math.floor(t/864e5)} days`}.`))},i)})]),o&&clearTimeout(o);let s=oj(e),l=window[s];if(!("object"==typeof(a=l)&&null!==a&&"init"in a&&"function"==typeof a.init&&"get"in a&&"function"==typeof a.get)){let e=`The global variable ${s} does not refer to a federated module`;throw console.error(e),Error(e)}l.init(r.S.default);let u=(await l.get(t))();if("object"!=typeof u||null===u){let t=`Container for ${e} did not return an ESM module as expected`;throw console.error(t),Error(t)}return u}async function oL(e,t){if("string"!=typeof e||0===e.trim().length){let e="Attempted to call importDynamic() without supplying a package to load";throw console.error(e),Error(e)}let r=oj(e);if(!window[r]){let r=t??await oF();if(!r.imports.hasOwnProperty(e)){let t=`Could not find the package ${e} defined in the current importmap`;throw console.error(t),Error(t)}let n=r.imports[e];n.startsWith("./")&&(n=window.spaBase+n.substring(1));let a=e in oP().imports;try{return await function(e){var t;let r=(t=window)[oB]??(t[oB]=new Map),n=r.get(e);if(n)return n;if(document.head.querySelector(`script[src="${e}"]`))return console.warn(`Script at ${e} already loaded. Not loading it again.`),Promise.resolve();let a=document.createElement("script");a.src=e,a.type="text/javascript",a.async=!0;let o=new Promise((t,n)=>{let o=setTimeout(()=>{console.error(`The script at ${e} did not load within 5 seconds. This may indicate an issue with the imports in the script's entry-point file or with the script's bundler configuration.`)},5e3);function i(){clearTimeout(o),a.removeEventListener("load",s),a.removeEventListener("error",l)}function s(){i(),t()}function l(t){i(),r.delete(e),a.remove();let o=`Failed to load script from ${e}`;console.error(o,t),n(t.message??o)}a.addEventListener("load",s),a.addEventListener("error",l),document.head.appendChild(a)});return r.set(e,o),o}(n)}catch(e){return a&&E({kind:"error",title:aj("scriptLoadingFailed","Error: Script failed to load"),description:aj("scriptLoadingError","Failed to load overridden script from {{- url}}. Please check that the bundled script is available at the expected URL. Click the button below to reset all import map overrides.",{url:n}),actionButtonLabel:aj("resetOverrides","Reset overrides"),onActionButtonClick(){oO(),window.location.reload()}}),Promise.reject(e)}}return Promise.resolve()}async function oF(){return o_()}let oB=Symbol.for("__openmrs_script_loading");function oU(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 oV(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&&oU(t))}let oW="openmrs-routes:",oH="openmrs-routes:change",oz=!1,oK=null,oG=null;async function oZ(){return oG??(oG=oY().then(({map:e,complete:t})=>(t||(oG=null),e))),oG}async function oY(){let e=document.querySelectorAll("script[type='openmrs-routes']"),t=[],r=!0;for(let n=0;n<e.length;n++){let a=e[n];try{let e;if(a.src){let t=await fetch(a.src);if(!t.ok)throw Error(`Request for ${a.src} returned ${t.status} ${t.statusText}`);e=await t.json()}else a.textContent&&(e=JSON.parse(a.textContent));e&&oV(e)&&t.push(e)}catch(e){r=!1,console.warn(`[route-maps] Failed to parse routes from script tag at index ${n}`,e)}}return{map:oq(t),complete:r}}function oq(e){let t={routes:{}};for(let r of e)r&&"object"==typeof r&&!Array.isArray(r)&&(Object.assign(t.routes,r.routes),void 0===t.version&&void 0!==r.version&&(t.version=r.version));return t}async function oJ(){let e={version:void 0,routes:{}};try{let t=[];for(let e=0;e<localStorage.length;e++){let r=localStorage.key(e);if(r?.startsWith(oW)){let e=localStorage.getItem(r);e&&t.push({moduleName:r.slice(oW.length),raw:e})}}for(let r of(await Promise.allSettled(t.map(async({moduleName:e,raw:t})=>{let r=JSON.parse(t);if(oU(r))return{moduleName:e,routes:r};if("string"==typeof r&&r.startsWith("http")){let t=await fetch(r),n=await t.json();if(oU(n))return{moduleName:e,routes:n};throw Error(`${r} did not resolve to a valid OpenmrsAppRoutes object`)}throw Error(`Override for ${e} is neither a valid routes object nor a URL`)}))))"fulfilled"===r.status?e.routes[r.value.moduleName]=r.value.routes:console.warn("[route-maps] Failed to load route override",r.reason)}catch(e){console.warn("[route-maps] Failed to read route overrides from localStorage",e)}return e}async function oX(){let e=await oZ();return oz?oq([e,oK??await oJ()]):e}async function oQ(){return oZ()}async function o0(){return oz?oq([await oZ(),await oJ()]):oZ()}function o1(){if(!oz)return{};let e={};try{for(let t=0;t<localStorage.length;t++){let r=localStorage.key(t);if(r?.startsWith(oW)){let t=localStorage.getItem(r);t&&(e[r.slice(oW.length)]=t)}}}catch(e){console.warn("[route-maps] Failed to read route overrides from localStorage",e)}return e}function o4(e,t){if(!oz)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{if("string"==typeof t)if(t.startsWith("http"))localStorage.setItem(oW+e,JSON.stringify(t));else{let r=JSON.parse(t);if(!oU(r))return void console.error(`The supplied routes for ${e} is not a valid OpenmrsAppRoutes object`,t);localStorage.setItem(oW+e,JSON.stringify(r))}else if(t instanceof URL)localStorage.setItem(oW+e,JSON.stringify(t.toString()));else{if(!oU(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(oW+e,JSON.stringify(t))}window.dispatchEvent(new CustomEvent(oH))}catch(e){console.warn("[route-maps] Failed to write route override to localStorage",e)}}function o2(e){if(!oz)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{localStorage.removeItem(oW+e),window.dispatchEvent(new CustomEvent(oH))}catch(e){console.warn("[route-maps] Failed to remove route override from localStorage",e)}}function o3(){if(!oz)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{let e=[];for(let t=0;t<localStorage.length;t++){let r=localStorage.key(t);r?.startsWith(oW)&&e.push(r)}e.forEach(e=>localStorage.removeItem(e)),window.dispatchEvent(new CustomEvent(oH))}catch(e){console.warn("[route-maps] Failed to clear route overrides from localStorage",e)}}let o6=null;function o5(){return o6||(o6=(oz="development"===window.spaEnv)?oJ().then(e=>{oK=e}):Promise.resolve())}let o9=`${aY}/attachment`;function o8(e,t){return aQ(`${o9}/${e}`,{signal:t.signal})}function o7(e,t,r,n){return aQ(ie(e,t,n),{signal:r.signal})}function ie(e,t,r){return r?`${o9}?patient=${e}&encounter=${r}`:`${o9}?patient=${e}&includeEncounterless=${t}`}async function it(e,t,r){let n=new FormData;return n.append("fileCaption",t.fileDescription),n.append("patient",e),r&&n.append("encounter",r),t.file?n.append("file",t.file,t.fileName):(n.append("file",new File([""],t.fileName),t.fileName),n.append("base64Content",t.base64Content)),aQ(`${o9}`,{method:"POST",body:n})}function ir(e,t){return aQ(`${o9}/${e}`,{method:"DELETE",signal:t.signal})}async function ia(e,t){return e?(await aQ(`${aq}/Patient/${e}`,t)).data:null}function io(e,t){let r=new CustomEvent(`openmrs:${e}`,{detail:t??void 0,cancelable:!0,bubbles:!0});return window.dispatchEvent(r)}function ii(e,t){let r=e=>{t("detail"in e&&null!==e.detail?e.detail:void 0)};return window.addEventListener(`openmrs:${e}`,r),()=>{window.removeEventListener(`openmrs:${e}`,r)}}function is(e){return{uuid:e.uuid,display:e.display}}function il(e=null,t=null){let r=new URLSearchParams;e&&r.set("tag",e),t&&r.set("q",t);let n=r.toString();return aQ(`${aY}/location${n?"?"+n:""}`).then(e=>e.data.results.map(is))}function iu(e){return{uuid:e.uuid,display:e.display,name:e.name}}let ic=`${aY}/visittype`;function id(e=ic){return aQ(e).then(e=>e.data.results.map(iu))}var im=((ee={}).NEWVISIT="startVisit",ee.EDITVISIT="editVisit",ee.LOADING="loadingVisit",ee),ip=((et={}).NOTSTARTED="notStarted",et.ONGOING="ongoing",et);let ih="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))",ig=function(){try{return JSON.parse(sessionStorage.getItem("openmrs:visitStoreState")||"null")}catch(e){return null}}()||{patientUuid:null,manuallySetVisitUuid:null};function iy(){return W("visit",ig)}function iv(e,t){iy().setState({patientUuid:e,manuallySetVisitUuid:t})}function ib(e,t){return aQ(`${aY}/visit`,{signal:t.signal,method:"POST",headers:{"Content-type":"application/json"},body:e})}function iw(e,t,r){return aQ(`${aY}/visit/${e}`,{signal:r.signal,method:"POST",headers:{"Content-type":"application/json"},body:t})}function iE(e,t,r){return aQ(`${aY}/visit?patient=${e}&v=${r??ih}`,{signal:t.signal,method:"GET",headers:{"Content-type":"application/json"}})}iy().subscribe(e=>{var t;t=e,sessionStorage.setItem("openmrs:visitStoreState",JSON.stringify(t))});class iD{static get version(){return"1.4.0"}static toString(){return"JavaScript Expression Parser (JSEP) v"+iD.version}static addUnaryOp(e){return iD.max_unop_len=Math.max(e.length,iD.max_unop_len),iD.unary_ops[e]=1,iD}static addBinaryOp(e,t,r){return iD.max_binop_len=Math.max(e.length,iD.max_binop_len),iD.binary_ops[e]=t,r?iD.right_associative.add(e):iD.right_associative.delete(e),iD}static addIdentifierChar(e){return iD.additional_identifier_chars.add(e),iD}static addLiteral(e,t){return iD.literals[e]=t,iD}static removeUnaryOp(e){return delete iD.unary_ops[e],e.length===iD.max_unop_len&&(iD.max_unop_len=iD.getMaxKeyLen(iD.unary_ops)),iD}static removeAllUnaryOps(){return iD.unary_ops={},iD.max_unop_len=0,iD}static removeIdentifierChar(e){return iD.additional_identifier_chars.delete(e),iD}static removeBinaryOp(e){return delete iD.binary_ops[e],e.length===iD.max_binop_len&&(iD.max_binop_len=iD.getMaxKeyLen(iD.binary_ops)),iD.right_associative.delete(e),iD}static removeAllBinaryOps(){return iD.binary_ops={},iD.max_binop_len=0,iD}static removeLiteral(e){return delete iD.literals[e],iD}static removeAllLiterals(){return iD.literals={},iD}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 iD(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 iD.binary_ops[e]||0}static isIdentifierStart(e){return e>=65&&e<=90||e>=97&&e<=122||e>=128&&!iD.binary_ops[String.fromCharCode(e)]||iD.additional_identifier_chars.has(String.fromCharCode(e))}static isIdentifierPart(e){return iD.isIdentifierStart(e)||iD.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(iD.hooks[e]){let r={context:this,node:t};return iD.hooks.run(e,r),r.node}return t}searchHook(e){if(iD.hooks[e]){let t={context:this};return iD.hooks[e].find(function(e){return e.call(t.context,t),t.node}),t.node}}gobbleSpaces(){let e=this.code;for(;e===iD.SPACE_CODE||e===iD.TAB_CODE||e===iD.LF_CODE||e===iD.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:iD.COMPOUND,body:e};return this.runHook("after-all",t)}gobbleExpressions(e){let t=[],r,n;for(;this.index<this.expr.length;)if((r=this.code)===iD.SEMCOL_CODE||r===iD.COMMA_CODE)this.index++;else if(n=this.gobbleExpression())t.push(n);else if(this.index<this.expr.length){if(r===e)break;this.throwError('Unexpected "'+this.char+'"')}return t}gobbleExpression(){let e=this.searchHook("gobble-expression")||this.gobbleBinaryExpression();return this.gobbleSpaces(),this.runHook("after-expression",e)}gobbleBinaryOp(){this.gobbleSpaces();let e=this.expr.substr(this.index,iD.max_binop_len),t=e.length;for(;t>0;){if(iD.binary_ops.hasOwnProperty(e)&&(!iD.isIdentifierStart(this.code)||this.index+e.length<this.expr.length&&!iD.isIdentifierPart(this.expr.charCodeAt(this.index+e.length))))return this.index+=t,e;e=e.substr(0,--t)}return!1}gobbleBinaryExpression(){let e,t,r,n,a,o,i,s,l;if(!(o=this.gobbleToken())||!(t=this.gobbleBinaryOp()))return o;for(a={value:t,prec:iD.binaryPrecedence(t),right_a:iD.right_associative.has(t)},(i=this.gobbleToken())||this.throwError("Expected expression after "+t),n=[o,a,i];t=this.gobbleBinaryOp();){if(0===(r=iD.binaryPrecedence(t))){this.index-=t.length;break}a={value:t,prec:r,right_a:iD.right_associative.has(t)},l=t;let s=e=>a.right_a&&e.right_a?r>e.prec:r<=e.prec;for(;n.length>2&&s(n[n.length-2]);)i=n.pop(),t=n.pop().value,o=n.pop(),e={type:iD.BINARY_EXP,operator:t,left:o,right:i},n.push(e);(e=this.gobbleToken())||this.throwError("Expected expression after "+l),n.push(a,e)}for(s=n.length-1,e=n[s];s>1;)e={type:iD.BINARY_EXP,operator:n[s-1].value,left:n[s-2],right:e},s-=2;return e}gobbleToken(){let e,t,r,n;if(this.gobbleSpaces(),n=this.searchHook("gobble-token"))return this.runHook("after-token",n);if(e=this.code,iD.isDecimalDigit(e)||e===iD.PERIOD_CODE)return this.gobbleNumericLiteral();if(e===iD.SQUOTE_CODE||e===iD.DQUOTE_CODE)n=this.gobbleStringLiteral();else if(e===iD.OBRACK_CODE)n=this.gobbleArray();else{for(r=(t=this.expr.substr(this.index,iD.max_unop_len)).length;r>0;){if(iD.unary_ops.hasOwnProperty(t)&&(!iD.isIdentifierStart(this.code)||this.index+t.length<this.expr.length&&!iD.isIdentifierPart(this.expr.charCodeAt(this.index+t.length)))){this.index+=r;let e=this.gobbleToken();return e||this.throwError("missing unaryOp argument"),this.runHook("after-token",{type:iD.UNARY_EXP,operator:t,argument:e,prefix:!0})}t=t.substr(0,--r)}iD.isIdentifierStart(e)?(n=this.gobbleIdentifier(),iD.literals.hasOwnProperty(n.name)?n={type:iD.LITERAL,value:iD.literals[n.name],raw:n.name}:n.name===iD.this_str&&(n={type:iD.THIS_EXP})):e===iD.OPAREN_CODE&&(n=this.gobbleGroup())}return n?(n=this.gobbleTokenProperty(n),this.runHook("after-token",n)):this.runHook("after-token",!1)}gobbleTokenProperty(e){this.gobbleSpaces();let t=this.code;for(;t===iD.PERIOD_CODE||t===iD.OBRACK_CODE||t===iD.OPAREN_CODE||t===iD.QUMARK_CODE;){let r;if(t===iD.QUMARK_CODE){if(this.expr.charCodeAt(this.index+1)!==iD.PERIOD_CODE)break;r=!0,this.index+=2,this.gobbleSpaces(),t=this.code}this.index++,t===iD.OBRACK_CODE?((e={type:iD.MEMBER_EXP,computed:!0,object:e,property:this.gobbleExpression()}).property||this.throwError('Unexpected "'+this.char+'"'),this.gobbleSpaces(),(t=this.code)!==iD.CBRACK_CODE&&this.throwError("Unclosed ["),this.index++):t===iD.OPAREN_CODE?e={type:iD.CALL_EXP,arguments:this.gobbleArguments(iD.CPAREN_CODE),callee:e}:(t===iD.PERIOD_CODE||r)&&(r&&this.index--,this.gobbleSpaces(),e={type:iD.MEMBER_EXP,computed:!1,object:e,property:this.gobbleIdentifier()}),r&&(e.optional=!0),this.gobbleSpaces(),t=this.code}return e}gobbleNumericLiteral(){let e="",t,r;for(;iD.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);if(this.code===iD.PERIOD_CODE)for(e+=this.expr.charAt(this.index++);iD.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++));iD.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);iD.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+e+this.char+")")}return r=this.code,iD.isIdentifierStart(r)?this.throwError("Variable names cannot start with a number ("+e+this.char+")"):(r===iD.PERIOD_CODE||1===e.length&&e.charCodeAt(0)===iD.PERIOD_CODE)&&this.throwError("Unexpected period"),{type:iD.LITERAL,value:parseFloat(e),raw:e}}gobbleStringLiteral(){let e="",t=this.index,r=this.expr.charAt(this.index++),n=!1;for(;this.index<this.expr.length;){let t=this.expr.charAt(this.index++);if(t===r){n=!0;break}if("\\"===t)switch(t=this.expr.charAt(this.index++)){case"n":e+="\n";break;case"r":e+="\r";break;case"t":e+=" ";break;case"b":e+="\b";break;case"f":e+="\f";break;case"v":e+="\v";break;default:e+=t}else e+=t}return n||this.throwError('Unclosed quote after "'+e+'"'),{type:iD.LITERAL,value:e,raw:this.expr.substring(t,this.index)}}gobbleIdentifier(){let e=this.code,t=this.index;for(iD.isIdentifierStart(e)?this.index++:this.throwError("Unexpected "+this.char);this.index<this.expr.length;)if(e=this.code,iD.isIdentifierPart(e))this.index++;else break;return{type:iD.IDENTIFIER,name:this.expr.slice(t,this.index)}}gobbleArguments(e){let t=[],r=!1,n=0;for(;this.index<this.expr.length;){this.gobbleSpaces();let a=this.code;if(a===e){r=!0,this.index++,e===iD.CPAREN_CODE&&n&&n>=t.length&&this.throwError("Unexpected token "+String.fromCharCode(e));break}if(a===iD.COMMA_CODE){if(this.index++,++n!==t.length){if(e===iD.CPAREN_CODE)this.throwError("Unexpected token ,");else if(e===iD.CBRACK_CODE)for(let e=t.length;e<n;e++)t.push(null)}}else if(t.length!==n&&0!==n)this.throwError("Expected comma");else{let e=this.gobbleExpression();e&&e.type!==iD.COMPOUND||this.throwError("Expected comma"),t.push(e)}}return r||this.throwError("Expected "+String.fromCharCode(e)),t}gobbleGroup(){this.index++;let e=this.gobbleExpressions(iD.CPAREN_CODE);if(this.code===iD.CPAREN_CODE)return(this.index++,1===e.length)?e[0]:!!e.length&&{type:iD.SEQUENCE_EXP,expressions:e};this.throwError("Unclosed (")}gobbleArray(){return this.index++,{type:iD.ARRAY_EXP,elements:this.gobbleArguments(iD.CBRACK_CODE)}}}Object.assign(iD,{hooks:new class{add(e,t,r){if("string"!=typeof arguments[0])for(let e in arguments[0])this.add(e,arguments[0][e],arguments[1]);else(Array.isArray(e)?e:[e]).forEach(function(e){this[e]=this[e]||[],t&&this[e][r?"unshift":"push"](t)},this)}run(e,t){this[e]=this[e]||[],this[e].forEach(function(e){e.call(t&&t.context?t.context:t,t)})}},plugins:new class{constructor(e){this.jsep=e,this.registered={}}register(...e){e.forEach(e=>{if("object"!=typeof e||!e.name||!e.init)throw Error("Invalid JSEP plugin format");this.registered[e.name]||(e.init(this.jsep),this.registered[e.name]=e)})}}(iD),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"}),iD.max_unop_len=iD.getMaxKeyLen(iD.unary_ops),iD.max_binop_len=iD.getMaxKeyLen(iD.binary_ops);let ix=e=>new iD(e).parse(),i_=Object.getOwnPropertyNames(class{});Object.getOwnPropertyNames(iD).filter(e=>!i_.includes(e)&&void 0===ix[e]).forEach(e=>{ix[e]=iD[e]}),ix.Jsep=iD,ix.plugins.register({name:"ternary",init(e){e.hooks.add("after-expression",function(t){if(t.node&&this.code===e.QUMARK_CODE){this.index++;let r=t.node,n=this.gobbleExpression();if(n||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===e.COLON_CODE){this.index++;let a=this.gobbleExpression();if(a||this.throwError("Expected expression"),t.node={type:"ConditionalExpression",test:r,consequent:n,alternate:a},r.operator&&e.binary_ops[r.operator]<=.9){let n=r;for(;n.right.operator&&e.binary_ops[n.right.operator]<=.9;)n=n.right;t.node.test=n.right,n.right=t.node,t.node=r}}else this.throwError("Expected :")}})}});let iS="ArrowFunctionExpression",iC={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)}},iP={...iC,Promise};function ik(e,t={}){return iA(e,t,iM)}async function iR(e,t={}){return iI(e,t,iM)}function iT(e,t={}){return iA(e,t,iL)}function iN(e,t={}){return iI(e,t,iL)}function iO(e,t={}){return iA(e,t,iF)}function i$(e,t={}){return iI(e,t,iF)}function iA(e,t={},r){if("string"!=typeof e&&("object"!=typeof e||!e||!("type"in e)))throw`Unknown expression type ${e}. Expressions must either be a string or pre-compiled string.`;if("string"==typeof e&&0===e.trim().length)throw{type:"Empty expression",message:"Expression cannot be an empty string"};null==t&&(t={});let n=iH(t,iC),a=iB("string"==typeof e?ix(e):e,n);if(r(a))return a;throw{type:"Invalid result",message:"string"==typeof e?`The expression ${e} did not produce a valid result`:"The expression did not produce a valid result"}}async function iI(e,t={},r){if("string"!=typeof e&&("object"!=typeof e||!e||!("type"in e)))return Promise.reject(`Unknown expression type ${e}. Expressions must either be a string or pre-compiled string.`);if("string"==typeof e&&0===e.trim().length)throw{type:"Empty expression",message:"Expression cannot be an empty string"};null==t&&(t={});let n=iH(t,iP);return Promise.resolve(iB("string"==typeof e?ix(e):e,n)).then(t=>{if(r(t))return t;throw{type:"Invalid result",message:"string"==typeof e?`The expression ${e} did not produce a valid result`:"The expression did not produce a valid result"}})}function ij(e){return ix(e)}function iM(e){return"string"==typeof e||"number"==typeof e||"boolean"==typeof e||null==e||e instanceof Date}function iL(e){return"boolean"==typeof e}function iF(e){return"number"==typeof e}function iB(e,t){switch(e.type){case"UnaryExpression":var r,n,a,o,i,s,l,u,c,d,m,p,f,h=e,g=t;let y=iB(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 iB(v.left,b)&&iB(v.right,b);case"||":return iB(v.left,b)||iB(v.right,b);case"??":return iB(v.left,b)??iB(v.right,b)}let w=iB(v.left,b),E=iB(v.right,b);switch(v.operator){case"+":return w+E;case"-":return w-E;case"*":return w*E;case"/":return w/E;case"%":return w%E;case"**":return w**E;case"==":return w==E;case"===":return w===E;case"!=":return w!=E;case"!==":return w!==E;case">":return w>E;case">=":return w>=E;case"<":return w<E;case"<=":return w<=E;case"in":return w in E;default:throw`Expression evaluator does not support operator '${v.operator}' operator`}case"ConditionalExpression":return r=e,n=t,iB(r.test,n)?iB(r.consequent,n):iB(r.alternate,n);case"CallExpression":return iG(iV(e,t));case"ArrowFunctionExpression":let D;return a=e,o=t,D=a.params?.map(e=>{if("Identifier"===e.type)return e.name;throw`Cannot handle parameter of type ${e.type}`})??[],(function(...e){if(e.length<D.length)throw`Required argument(s) ${D.slice(e.length,-1).join(", ")} were not provided`;let t=Object.fromEntries(D.reduce((t,r,n)=>{let a=e[n];return function e(t){if("string"==typeof t||"number"==typeof t||"boolean"==typeof t||"function"==typeof t||null===t||t instanceof RegExp)return!0;if("object"==typeof t){for(let r of Object.keys(t))if(!e(t[r]))return!1;return!0}if(Array.isArray(t)){for(let r of t)if(!e(r))break}return!1}(a)&&t.push([r,a]),t},[]));return iB(a.body,o.addVariables(t))}).bind(null);case"MemberExpression":return iG(iW(e,t));case"ArrayExpression":return i=e,s=t,i.elements?.map(iZ(s));case"SequenceExpression":let x;return l=e,u=t,(x=l.expressions.map(iZ(u)))[x.length-1];case"NewExpression":var _=e,S=t;if(_.callee&&"Identifier"===_.callee.type){let e=_.arguments?.map(iZ(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,(iY(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,P;return m=e,p=t,C=m.expressions?.map(iZ(p))??[],(P=m.quasis?.map(iZ(p))??[]).filter(e=>!e.tail).map(e=>e.value).join("")+C.join("")+P.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 iU(e,t){switch(e.type){case"Literal":return e.value;case"Identifier":return e.name;case"MemberExpression":return iU(e.property,t);default:throw`VisitExpressionName does not support expression of type '${e.type}'`}}function iV(e,t){let r=iK(e.callee,t);if(r===iz||e.optional&&null==r)return iz;let n=e.arguments?.map(iZ(t));if(r){if("function"!=typeof r)throw`${iX(e.callee)} is not a function`}else throw`No function named ${iX(e.callee)} is defined in this context`;return r(...n)}function iW(e,t){let r=iK(e.object,t);if(r===iz||e.optional&&null==r)return iz;if(null===r)throw TypeError(`TypeError: cannot read properties of null (reading '${iJ(e.property,t)}')`);if(void 0===r)switch(e.object.type){case"Identifier":{let r=iU(e.object,t);throw ReferenceError(`ReferenceError: ${r} is not defined`)}case"MemberExpression":throw TypeError(`TypeError: cannot read properties of undefined (reading '${iJ(e.property,t)}')`);default:throw`VisitMemberExpression does not support operator '${e.object.type}' type`}if("object"!=typeof r&&"function"!=typeof r&&"string"!=typeof r&&"number"!=typeof r)throw`VisitMemberExpression does not support member access on type ${typeof r}`;let n=e.computed?function(e){if(void 0===e)throw{type:"Illegal property access",message:"No property was supplied to the property access"};if("string"!=typeof e&&"number"!=typeof e)throw{type:"Illegal property access",message:`Cannot use a value of type ${null===e?"null":typeof e} as a property name`};return e}(iB(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);iY(n),function(e,t){if(iq.has(String(t)))return;let r=Object(e);for(;null!==r;){if(Object.hasOwn(r,t)){if(r===Object.prototype||r===Function.prototype)throw{type:"Illegal property access",message:`Cannot access the ${t} property of objects`};return}r=Object.getPrototypeOf(r)}}(r,n);let a=r[n];return"function"==typeof a?a.bind(r):a}function iH(e,t){let r={variables:{...e},globals:{...t},addVariables(e){return this.variables={...this.variables,...e},this}};return r.addVariables.bind(r),r}ix.plugins.register({name:"arrow",init(e){e.addBinaryOp("=>",.1,!0),e.hooks.add("gobble-expression",function(t){if(this.gobbleSpaces(),this.code===e.OPAREN_CODE){let r=this.index;if(this.index++,this.gobbleSpaces(),this.code===e.CPAREN_CODE){this.index++;let e=this.gobbleBinaryOp();if("=>"===e){let r=this.gobbleBinaryExpression();r||this.throwError("Expected expression after "+e),t.node={type:iS,params:null,body:r};return}}this.index=r}}),e.hooks.add("after-expression",function(t){!function t(r){r&&(Object.values(r).forEach(e=>{e&&"object"==typeof e&&t(e)}),"=>"===r.operator&&(r.type=iS,r.params=r.left?[r.left]:null,r.body=r.right,r.params&&r.params[0].type===e.SEQUENCE_EXP&&(r.params=r.params[0].expressions),delete r.left,delete r.right,delete r.operator))}(t.node)})}}),ix.plugins.register({name:"new",init(e){e.addUnaryOp("new"),e.hooks.add("after-token",function(t){let r=t.node;if(r&&"new"===r.operator){r.argument&&[e.CALL_EXP,e.MEMBER_EXP].includes(r.argument.type)||this.throwError("Expected new function()"),t.node=r.argument;let n=t.node;for(;n.type===e.MEMBER_EXP||n.type===e.CALL_EXP&&n.callee.type===e.MEMBER_EXP;)n=n.type===e.MEMBER_EXP?n.object:n.callee.object;n.type="NewExpression"}})}}),ix.plugins.register({name:"numbers",init(e){function t(e){return"x"===e||"X"===e?(this.index+=2,[[48,57],[65,70],[97,102]]):"b"===e||"B"===e?(this.index+=2,[[48,49]]):"o"===e||"O"===e||e>="0"&&e<="7"?(this.index+=e<="7"?1:2,[[48,55]]):null}function r(t){let r=this.index,n="",a=()=>{for(;e.isDecimalDigit(this.code)||95===this.code;)95===this.code?this.index++:n+=this.expr.charAt(this.index++)};a(),this.code===e.PERIOD_CODE&&(n+=this.expr.charAt(this.index++),a());let o=this.char;("e"===o||"E"===o)&&(n+=this.expr.charAt(this.index++),("+"===(o=this.char)||"-"===o)&&(n+=this.expr.charAt(this.index++)),a(),e.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+n+this.char+")"));let i=this.code;if(e.isIdentifierStart(i))this.throwError("Variable names cannot start with a number ("+n+this.char+")");else if(i===e.PERIOD_CODE){n.length>1&&this.throwError(`Unexpected period ${JSON.stringify({chCode:i,number:n},null,2)}`),this.index=r;return}t.node={type:e.LITERAL,value:parseFloat(n),raw:this.expr.substring(r,this.index)}}e.hooks.add("gobble-token",function(n){if(48===this.code){var a,o,i;let s=this.index,l=this.expr.charAt(this.index+1),u=t.call(this,l);if(!u)return;let c="";for(;a=this.code,o=u,95===a||o.some(([e,t])=>a>=e&&a<=t);)95===this.code?this.index++:c+=this.expr.charAt(this.index++);if(e.isIdentifierPart(this.code)){if(e.isDecimalDigit(this.code)&&e.isDecimalDigit(l.charCodeAt(0))){this.index=s+1,r.call(this,n);return}this.throwError("unexpected char within number")}n.node={type:e.LITERAL,value:parseInt(c,"x"===(i=l)||"X"===i?16:"b"===i||"B"===i?2:8),raw:this.expr.substring(s,this.index)}}else(e.isDecimalDigit(this.code)||this.code===e.PERIOD_CODE)&&r.call(this,n)})}}),ix.plugins.register({name:"regex",init(e){e.hooks.add("gobble-token",function(t){if(47===this.code){let r=++this.index,n=!1;for(;this.index<this.expr.length;){if(47===this.code&&!n){let n,a=this.expr.slice(r,this.index),o="";for(;++this.index<this.expr.length;){let e=this.code;if(e>=97&&e<=122||e>=65&&e<=90||e>=48&&e<=57)o+=this.char;else break}try{n=new RegExp(a,o)}catch(e){this.throwError(e.message)}return t.node={type:e.LITERAL,value:n,raw:this.expr.slice(r-1,this.index)},t.node=this.gobbleTokenProperty(t.node),t.node}this.code===e.OBRACK_CODE?n=!0:n&&this.code===e.CBRACK_CODE&&(n=!1),this.index+=92===this.code?2:1}this.throwError("Unclosed Regex")}})}}),ix.plugins.register({name:"ternary",init(e){e.hooks.add("after-expression",function(t){if(t.node&&this.code===e.QUMARK_CODE){this.index++;let r=t.node,n=this.gobbleExpression();if(n||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===e.COLON_CODE){this.index++;let a=this.gobbleExpression();if(a||this.throwError("Expected expression"),t.node={type:"ConditionalExpression",test:r,consequent:n,alternate:a},r.operator&&e.binary_ops[r.operator]<=.9){let n=r;for(;n.right.operator&&e.binary_ops[n.right.operator]<=.9;)n=n.right;t.node.test=n.right,n.right=t.node,t.node=r}}else this.throwError("Expected :")}})}}),ix.plugins.register({name:"jsepTemplateLiteral",init(e){function t(e,r=!0){if(96===this.code){let t={type:"TemplateLiteral",quasis:[],expressions:[]},n="",a="",o=!1,i=this.expr.length,s=()=>t.quasis.push({type:"TemplateElement",value:{raw:a,cooked:n},tail:o});for(;this.index<i;){let i=this.expr.charAt(++this.index);if("`"===i)return this.index+=1,o=!0,s(),e.node=t,r&&(e.node=this.gobbleTokenProperty(e.node)),e.node;if("$"===i&&"{"===this.expr.charAt(this.index+1))this.index+=2,s(),a="",n="",t.expressions.push(...this.gobbleExpressions(125)),125!==this.code&&this.throwError("unclosed ${");else if("\\"===i)switch(a+=i,i=this.expr.charAt(++this.index),a+=i,i){case"n":n+="\n";break;case"r":n+="\r";break;case"t":n+=" ";break;case"b":n+="\b";break;case"f":n+="\f";break;case"v":n+="\v";break;default:n+=i}else n+=i,a+=i}this.throwError("Unclosed `")}}e.hooks.add("gobble-token",t),e.hooks.add("after-token",function(r){if((r.node.type===e.IDENTIFIER||r.node.type===e.MEMBER_EXP)&&96===this.code)return r.node={type:"TaggedTemplateExpression",tag:r.node,quasi:t.bind(this)(r,!1)},r.node=this.gobbleTokenProperty(r.node),r.node})}}),ix.addBinaryOp("in",7),ix.addBinaryOp("??",1);let iz=Symbol("optional chain short-circuited");function iK(e,t){switch(e.type){case"MemberExpression":return iW(e,t);case"CallExpression":return iV(e,t);default:return iB(e,t)}}function iG(e){return e===iz?void 0:e}function iZ(e){return function(t){return null===t?null:iB(t,e)}}function iY(e){if("__proto__"===e||"prototype"===e||"constructor"===e)throw{type:"Illegal property access",message:`Cannot access the ${e} property of objects`}}let iq=new Set(["toString","valueOf","hasOwnProperty"]);function iJ(e,t){try{return iU(e,t)}catch{return"<computed>"}}function iX(e){return e?"MemberExpression"===e.type?e.property?.name:e.name:null}function iQ(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:{...iP},isLocalExpression:!1,variables:new Set};return i0("string"==typeof e?ix(e):e,t),[...t.variables]}function i0(e,t){switch(e.type){case"UnaryExpression":return n=e,a=t,i0(n.argument,a);case"BinaryExpression":return o=e,i=t,[i0(o.left,i),i0(o.right,i)].filter(Boolean);case"ConditionalExpression":return s=e,l=t,[i0(s.consequent,l),i0(s.test,l),i0(s.alternate,l)].filter(Boolean);case"CallExpression":let r;return u=e,c=t,r=i0(u.callee,c),u.arguments?.map(i1(c)),r;case"ArrowFunctionExpression":var n,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 D=b.params?.map(i1(E))??[],x=i0(b.body,E)??[];if(x&&Array.isArray(x))for(let e of x)D.includes(e)||w.variables.add(e);return;case"MemberExpression":var _=e,S=t;if(i0(_.object,S),_.computed)return void i0(_.property,S);let C={...S};C.isLocalExpression=!0,i0(_.property,C);return;case"ArrayExpression":return d=e,m=t,void d.elements?.map(i1(m));case"SequenceExpression":return p=e,f=t,void p.expressions?.map(i1(f));case"NewExpression":return h=e,g=t,void h.arguments?.map(i1(g));case"Literal":case"TemplateElement":return;case"Identifier":var P=e,k=t;if(!(P.name in k.globals))if(k.isLocalExpression)return P.name;else k.variables.add(P.name);return;case"TemplateLiteral":return y=e,v=t,void(y.expressions?.map(i1(v)),y.quasis?.map(i1(v)));default:throw`Expression evaluator does not support expression of type '${e.type}'`}}function i1(e){return function(t){return null===t?null:i0(t,e)}}let i4=W("feature-flags",{flags:function(){let e={};for(let t of Object.keys(localStorage))if(t.startsWith("openmrs:feature-flag:")){let r=t.replace("openmrs:feature-flag:",""),n=JSON.parse(localStorage.getItem(`openmrs:feature-flag-meta:${r}`)||"{}");e[r]={enabled:"true"===localStorage.getItem(t),...n}}return e}()});function i2(e,t,r){i4.setState(n=>({flags:{...n.flags,[e]:{enabled:n.flags[e]?.enabled??!1,label:t,description:r}}}))}function i3(){let e=i4.getState().flags;Object.keys(localStorage).filter(e=>e.startsWith("openmrs:feature-flag:")).forEach(t=>{let r=t.replace("openmrs:feature-flag:","");e[r]||(localStorage.removeItem(t),localStorage.removeItem(`openmrs:feature-flag-meta:${r}`))})}function i6(e){return i4.getState().flags[e].enabled}function i5(e,t){i4.subscribe(r=>{t(r.flags[e].enabled)})}function i9(e,t){i4.setState(r=>({flags:{...r.flags,[e]:{...r.flags[e],enabled:t}}}))}i4.subscribe(e=>{for(let[t,r]of Object.entries(e.flags))localStorage.setItem(`openmrs:feature-flag:${t}`,r.enabled.toString()),localStorage.setItem(`openmrs:feature-flag-meta:${t}`,JSON.stringify({label:r.label,description:r.description}))});var i8=e6(function(e,t,r){eq(e,t,r)});let i7=B("extensionsInternal",{slots:{},extensions:{}}),se=B("extensionRenderings",{renderings:new Map}),st=()=>W("extensionsInternal",{slots:{},extensions:{}}),sr=()=>W("extensionRenderings",{renderings:new Map});function sn(e){let t=i7.getState(),r=e(t);r!==t&&i7.setState(r)}let sa=null,so=null;function si(){let e=se.getState();return sa&&e===so||(sa=new Map(e.renderings),so=e,function(e){for(let t of(sg.clear(),e.values()))sv(t,1);sy=!0}(sa)),sa}function ss(e){so={renderings:e},se.setState(so,!0)}function sl(e){let t=si();t.has(e.renderingId)||(t.set(e.renderingId,e),sv(e,1),ss(t))}function su(e){let t=si(),r=t.get(e);r&&(t.delete(e),sv(r,-1),ss(t))}let sc=()=>W("extensions",{slots:{}}),sd=0,sm=new Set;function sp(e){sd++;try{return e()}finally{if(0==--sd&&sm.size>0){let e=Array.from(sm);for(let t of(sm.clear(),e))sf(t)}}}function sf(e){try{e()}catch(t){console.error(`The extension system's '${e.name}' recomputation failed`,t)}}function sh(e){sd>0?sm.add(e):sf(e)}let sg=new Map,sy=!1;function sv(e,t){let r=JSON.stringify([e.slotName,e.extensionId,e.slotModuleName,e.extensionModuleName]),n=sg.get(r);if(!n){if(t<0)return;sg.set(r,{count:1,record:{slotModuleName:e.slotModuleName,extensionModuleName:e.extensionModuleName,slotName:e.slotName,extensionId:e.extensionId}}),sy=!0;return}n.count+=t,n.count<1&&(sg.delete(r),sy=!0)}function sb(){var e,t;if(si(),!sy)return;sy=!1;let r=Array.from(sg.values(),({record:e})=>e);r.sort(sw),e=re.getState().mountedExtensions,t=r,e.length===t.length&&e.every((e,r)=>0===sw(e,t[r]))||re.setState({mountedExtensions:r})}function sw(e,t){return sE(e.slotName,t.slotName)||sE(e.extensionId,t.extensionId)||sE(e.slotModuleName,t.slotModuleName)||sE(e.extensionModuleName,t.extensionModuleName)}function sE(e,t){return e===t?0:e<t?-1:1}sb(),se.subscribe(()=>sh(sb));let sD=st(),sx=sc(),s_=rr(),sS=ro(),sC=new Set,sP=!1;function sk(e){if(null===e)sC=null;else if(null!==sC)for(let t of e)sC.add(t);sh(sR)}function sR(){if(!sP){sP=!0;try{for(let e=1;;e++){let t=sC;if(null!==t&&0===t.size)return;sC=new Set;try{!function(e,t,r,n,a,o=null){let i=sx.getState().slots,s={},l=!1,u=Object.entries(n.flags).filter(([,{enabled:e}])=>e).map(([e])=>e);for(let[n,c]of Object.entries(e.slots)){let d=i[n];if(d&&o&&!o.has(n)){s[n]=d;continue}let{config:m}=ra(t,c.name),p=function(e,t,r,n,a,o){let i=function(e,t){let r=e.add||[],n=e.remove||[],a=e.order||[],{extensions:o}=sD.getState(),i=new Set(n),s=[...t,...r].filter(e=>!i.has(e)),l=sF(a),u=sF(t),c=new Map(s.map(e=>[e,function(e,t,r,n){let a=t.get(e);if(void 0!==a)return a;{if(void 0!==r)return 1e3+r;let t=n.get(e);return void 0!==t?2e3+t:3e3}}(e,l,o[sO(e)]?.order,u)]));return s.sort((e,t)=>c.get(e)-c.get(t))}(r,t.slots[e].attachedIds),s=[];for(let l of i){let{config:i}=ri(n,e,l),u=rs(r,e,l),c=u?i8({},i,u):i,d=sO(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||!oe(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}(n,e,m,r,u,a.session);d&&d.moduleName===c.moduleName&&(0,e9.A)(d.candidateExtensions,p)?s[n]=d:(s[n]={moduleName:c.moduleName,candidateExtensions:p},l=!0)}(l||Object.keys(i).length!==Object.keys(s).length)&&sx.setState({slots:s})}(sD.getState(),s_.getState(),sS.getState(),i4.getState(),a1.getState(),t)}catch(e){throw sC=null===t||null===sC?null:new Set([...t,...sC]),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{sP=!1}}}function sT(e,t){let r=new Set;for(let n of Object.keys(e))e[n]!==t[n]&&r.add(n);for(let n of Object.keys(t))n in e||r.add(n);return r}function sN(e,t){return{moduleName:t,name:e,attachedIds:[]}}function sO(e){let[t]=e.split("#");return t}function s$(e,t){let r=sO(t);return e.extensions[r]}function sA(e){return s$(sD.getState(),e)}sD.subscribe((e,t)=>{sk(e.extensions!==t.extensions?null:sT(e.slots,t.slots))}),s_.subscribe((e,t)=>{sk(sT(e.slots,t.slots))}),sS.subscribe((e,t)=>{sk(sT(e.configs,t.configs))}),i4.subscribe(()=>sk(null)),a1.subscribe(()=>sk(null)),sk(null);let sI=e=>sn(t=>({...t,extensions:{...t.extensions,[e.name]:{...e}}}));function sj(e,t){sn(r=>{let n=r.slots[e];return n?{...r,slots:{...r.slots,[e]:{...n,attachedIds:[...n.attachedIds,t]}}}:{...r,slots:{...r.slots,[e]:{...sN(e),attachedIds:[t]}}}})}function sM(e,t){sn(r=>{let n=r.slots[e];return n&&n.attachedIds.includes(t)?{...r,slots:{...r.slots,[e]:{...n,attachedIds:n.attachedIds.filter(e=>e!==t)}}}:r})}function sL(e){sn(t=>{let r=t.slots[e];return r?{...t,slots:{...t.slots,[e]:{...r,attachedIds:[]}}}:t})}function sF(e){let t=new Map;return e.forEach((e,r)=>{t.has(e)||t.set(e,r)}),t}function sB(e,t){return function(e,t,r=null,n){let a;return e.filter(e=>{let o=e.displayConditionExpression;if("string"!=typeof o||0===o.trim().length)return!0;a??(a=t&&"object"==typeof t?{session:r,...t}:{session:r});try{return!!iT(o,a)}catch(t){return console.error(`Error while evaluating expression '${o}' for ${e.id}`+(n?` in ${n}`:""),t),!1}})}(sU(e),t,a1.getState().session,e)}function sU(e){return sx.getState().slots[e]?.candidateExtensions??[]}let sV=(e,t)=>sD.setState(r=>{let n=r.slots[t]?.moduleName;if(n&&n!=e)return console.warn(`An extension slot with the name '${t}' already exists. Refusing to register the same slot name twice (in "registerExtensionSlot"). The existing one is from module ${n}.`),r;if(n&&n==e)return r;if(r.slots[t])return{...r,slots:{...r.slots,[t]:{...r.slots[t],moduleName:e}}};let a=sN(t,e);return{...r,slots:{...r.slots,[t]:{...a}}}}),sW=()=>{sC=null,sn(()=>({slots:{},extensions:{}})),sr().setState({renderings:new Map}),sx.setState({slots:{}})},sH=B("left-nav",{slotName:null,basePath:window.spaBase,mode:"normal"});function sz({name:e,basePath:t,mode:r,componentContext:n,state:a}){sH.setState({slotName:e,basePath:t,mode:r??"normal",componentContext:n,state:a})}function sK(e){sH.getState().slotName===e&&sH.setState(sH.getInitialState(),!0)}let sG=B("modalRegistry",{modals:{}});function sZ(e){sG.setState(t=>(t.modals[e.name]=e,t))}function sY(e){let t=sG.getState().modals[e];if(!t){let r=sA(e);r&&(t={name:e,load:r.load,moduleName:r.moduleName},console.warn(`Modal ${e} was registered as an extension. This is deprecated and will be removed in the future. Please register it in the "modals" section of routes.json instead of the "extensions" section.`),sZ(t))}return t}let sq=B("workspace2",{registeredGroupsByName:{},registeredWindowsByName:{},registeredWorkspacesByName:{},openedGroup:null,openedWindows:[],isMostRecentlyOpenedWindowHidden:!1});function sJ(e){let{registeredWorkspacesByName:t,registeredWindowsByName:r}=sq.getState(),n=t[e];if(n){let t=r[n.window];if(t)return t;throw Error(`No workspace window found with name: ${n.window} for workspace: ${e}`)}throw Error(`No workspace found with name: ${e}`)}function sX(e){let{registeredGroupsByName:t,registeredWindowsByName:r}=sq.getState(),n=r[e];if(n){let r=t[n.group];if(r)return r;throw Error(`No workspace group found with name: ${n.group} for window: ${e}`)}throw Error(`No workspace window found with name: ${e}`)}function sQ(e){let{openedWindows:t}=sq.getState();return t.findIndex(t=>t.openedWorkspaces.find(t=>t.workspaceName===e))}function s0(e,t){if(0==t.length)return;let{registeredGroupsByName:r}=sq.getState(),n={...r};for(let r of t){if(n[r.name])throw Error(`Cannot register workspace group ${r.name} more than once`);n[r.name]={...r,moduleName:e}}sq.setState({registeredGroupsByName:n})}function s1(e,t){if(0==t.length)return;let{registeredWindowsByName:r}=sq.getState(),n={...r};for(let r of t){if(n[r.name])throw Error(`Cannot register workspace window ${r.name} more than once`);let t={...r,moduleName:e};n[r.name]=t}sq.setState({registeredWindowsByName:n})}function s4(e,t){if(0==t.length)return;let{registeredWorkspacesByName:r}=sq.getState(),n={...r};for(let r of t){if(n[r.name])throw Error(`Cannot register workspace ${r.name} more than once`);let t={...r,moduleName:e};n[r.name]=t}sq.setState({registeredWorkspacesByName:n})}let s2=0,s3=null,s6={bootstrap:15e3,mount:15e3,unmount:15e3};function s5(e,t){if(e.timeouts)return e;let r=e.name??"parcel",n=Object.fromEntries(Object.keys(s6).filter(t=>e[t]).map(n=>{var a,o;let i,s;return[n,(a=e[n],o=s6[n],i=Array.isArray(a)?a:[a],s=e=>i.reduce((t,a,o)=>t.then(()=>{let t=a(e);return"function"==typeof t?.then&&"function"==typeof t?.catch?t:Promise.reject(Error(`Lifecycle function ${n} at array index ${o} for parcel ${r} did not return a promise`))}),Promise.resolve(void 0)),e=>{let a,i=new Promise((e,t)=>{a=setTimeout(()=>t(Error(`Lifecycle function ${n} for parcel ${r} did not settle within ${o}ms`)),o)});return Promise.race([s(e),i]).finally(()=>clearTimeout(a)).then(e=>(t(n,!1),e),e=>{throw t(n,!0),e})})]}));return{...e,...n}}async function s9(e,t){var r,n;let a,o,i,s,l,u=await (s3??(s3=new Promise((e,t)=>{nz({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),nz))),s3),c={...t},d=(a=c,o=!1,{retarget:e=>a={...e},release:i=()=>(function(e){for(let t of Object.keys(e))delete e[t]})(a),onSettled(e,t){switch(e){case"bootstrap":t&&i();return;case"mount":o||(o=t);return;case"unmount":(t||o)&&i();return}}});return n=u((r=d.onSettled,"function"==typeof e?()=>e().then(e=>s5(e,r)):s5(e,r)),c),s=e=>t=>e.call(n,d.retarget(t)).catch(e=>{throw"SKIP_BECAUSE_BROKEN"===n.getStatus()&&d.release(),e}),l=n.update&&s(n.update),Object.defineProperty(n,"update",{configurable:!0,enumerable:!0,get:()=>l,set:e=>{l=e&&s(e)}})}function s8(){return s7}function s7(e,t){let r,n=s9(e,t).then(e=>r=e);return{mount:()=>n.then(e=>e.mount()),unmount:()=>n.then(e=>e.unmount()),update:e=>n.then(t=>t.update?.(e)),getStatus:()=>r?.getStatus()??"LOADING_SOURCE_CODE",get loadPromise(){return n.then(e=>e.loadPromise)},get bootstrapPromise(){return n.then(e=>e.bootstrapPromise)},get mountPromise(){return n.then(e=>e.mountPromise)},get unmountPromise(){return n.then(e=>e.unmountPromise)}}}async function le(e,t,r,n,a=e=>e,o={}){let i=sO(n),s=sA(n),l=null;if(e){let u;if(!s)throw Error(`Couldn't find extension '${i}' to attach to '${t}'`);let{meta:c,moduleName:d,load:m}=s,p=s2++,f=`${t}/${n}-${p}`;e.dataset.extensionRenderingId=f;let h=e=>{try{su(f)}catch(t){console.error(e,t)}};try{sl({renderingId:f,extensionName:i,extensionModuleName:d,extensionId:n,slotName:t,slotModuleName:r})}catch(e){throw h(`Recomputing configuration after registering '${n}' failed also failed`),e}try{u=await m()}catch(e){throw h(`Recomputing configuration after '${n}' failed to load also failed`),e}try{l=await s9(a({...u,name:`${t}/${i}-${p}`}),{...o,_meta:c,_extensionContext:{extensionId:n,extensionSlotName:t,extensionSlotModuleName:r,extensionModuleName:d,extensionMeta:c},domElement:e})}catch(e){throw h(`Recomputing configuration after '${n}' failed to mount also failed`),e}l.mountPromise.then(void 0,e=>{console.error(`Extension '${n}' in slot '${t}' failed to mount`,e),h(`Recomputing configuration after '${n}' failed to mount also failed`)}),l.unmountPromise.then(()=>h(`Recomputing configuration after unmounting '${n}' failed`),e=>{console.error(`Extension '${n}' in slot '${t}' failed to unmount`,e),h(`Recomputing configuration after '${n}' failed to unmount also failed`)})}else console.warn(`Tried to render ${n} into ${t} but no DOM element was available.`);return l}var lt=r(2491),lr=r.n(lt);let ln=(0,lt.createContext)({moduleName:"",featureName:""});function la({to:e,templateParams:t,onBeforeNavigate:r,children:n,...a}){return(0,lt.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}`)},[]),lr().createElement("a",{onClick:n=>{0===n.button&&!n.ctrlKey&&!n.shiftKey&&!n.altKey&&!n.metaKey&&(n.preventDefault(),r?.(n),aF({to:e,templateParams:t})),0===n.button&&(n.ctrlKey||n.metaKey)&&r?.(n),0===n.button&&n.shiftKey&&r?.(n),1===n.button&&r?.(n)},href:aM(e,t),...a},n)}let lo=({state:e,children:t,...r})=>{let{extension:n}=(0,lt.useContext)(ln),a=(0,lt.useRef)(null),o=(0,lt.useRef)(Promise.resolve()),i=(0,lt.useRef)(!1),s=(0,lt.useRef)(!1),l=(0,lt.useRef)(e),u=(0,lt.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,lt.useCallback)((e,t)=>{e.update&&"UNMOUNTING"!==e.getStatus()&&(o.current=Promise.all([e.mountPromise,o.current]).then(()=>{if(a.current?.getStatus()==="MOUNTED"&&a.current.update)return a.current.update({...t})}).catch(e=>{let t=a.current?.getStatus();"UNMOUNTING"!==t&&"NOT_MOUNTED"!==t&&"UNLOADING"!==t&&console.error(`The extension '${n?.extensionId}' failed to update`,e)}))},[]),d=(0,lt.useCallback)(t=>{t&&!a.current&&!s.current&&n?.extensionSlotName&&n.extensionSlotModuleName&&(s.current=!0,le(t,n.extensionSlotName,n.extensionSlotModuleName,n.extensionId,void 0,e).then(t=>{(s.current=!1,a.current=t,i.current)?u(t):t&&l.current!==e&&c(t,l.current)},()=>{s.current=!1}))},[]);return(0,lt.useEffect)(()=>(i.current=!1,()=>{i.current=!0,u(a.current)}),[]),(0,lt.useEffect)(()=>{l.current=e,a.current&&c(a.current,e)},[e]),n?lr().createElement("div",{ref:d,"data-extension-id":n?.extensionId,style:{position:"relative"},...r}):null};function li(e){let t=(0,lt.useRef)(e);return T(t.current,e)||(t.current=e),t.current}function ls(e,t){"function"==typeof t&&(t=t(e));let r={};for(let[n,a]of Object.entries(t)){let t=function(...t){e.setState(e=>a(e,...t))};r[n]=t}return r}let ll=e=>e;function lu(e,t=ll,r){let n=(0,lt.useCallback)(t=>e.subscribe(t),[e]),a=(0,lt.useCallback)(()=>t(e.getState()),[e,t]),o=(0,lt.useSyncExternalStore)(n,a,a),i=(0,lt.useMemo)(()=>r?ls(e,r):null,[e,r]);return(0,lt.useMemo)(()=>i?{...o,...i}:o,[o,i])}function lc(e,t){return lu(e,ll,t)}function ld(e){return function(t){let r=(0,lt.useCallback)(t=>e.subscribe(t),[]),n=(0,lt.useCallback)(()=>e.getState(),[]),a=(0,lt.useSyncExternalStore)(r,n,n),o=(0,lt.useMemo)(()=>t?ls(e,t):null,[t]);return(0,lt.useMemo)(()=>o?{...a,...o}:a,[a,o])}}let lm=[];Object.freeze(lm);let lp={candidateExtensions:lm};Object.freeze(lp);let lf=e=>{let t=(0,lt.useCallback)(t=>t.slots?.[e]??lp,[e]);return lu(sc(),t)},lh=e=>e.session;function lg(e,t){let{candidateExtensions:r}=lf(e),n=lu(a1,lh),a=li(t);return(0,lt.useMemo)(()=>sB(e,a),[e,a,n,r])}function ly(e,t){let{moduleName:r}=(0,lt.useContext)(ln);if(!r)throw Error("ComponentContext has not been provided. This should come from @openmrs/esm-react-utils.");return(0,lt.useEffect)(()=>{sV(r,e)},[r,e]),{extensions:lg(e,t),extensionSlotName:e,extensionSlotModuleName:r}}function lv(e){return e}function lb({name:e,extensionSlotName:t,select:r=lv,children:n,state:a,style:o,...i}){if(n&&a)throw Error("Both children and state have been provided. If children are provided, the state must be passed as a prop to the `Extension` component.");let s=e??t,l=(0,lt.useRef)(null),{extensions:u,extensionSlotModuleName:c}=ly(s,a),d=(0,lt.useMemo)(()=>r(u),[r,u]),m=(0,lt.useMemo)(()=>{if("function"==typeof n&&!lr().isValidElement(n))return d.map(e=>n(e,a))},[n,d]);return lr().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)=>lr().createElement(ln.Provider,{key:e.id,value:{moduleName:c,featureName:"",extension:{extensionId:e.id,extensionSlotName:s,extensionSlotModuleName:c,extensionMeta:e.meta}}},m?.[t]??("function"!=typeof n?n:null)??lr().createElement(lo,{state:a}))))}var lw=r(5873);function lE(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function lD(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?lE(Object(r),!0).forEach(function(t){var n,a,o;n=e,a=t,o=r[t],a in n?Object.defineProperty(n,a,{value:o,enumerable:!0,configurable:!0,writable:!0}):n[a]=o}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):lE(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function lx(e){return(lx="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 l_(e){return(l_="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 lS(e,t){var r;if("function"!=typeof(r=t.domElement?function(){return t.domElement}:t.domElementGetter?t.domElementGetter:e.domElementGetter?e.domElementGetter:function(e){var t=e.appName||e.name;if(!t)throw Error("single-spa's dom-element-getter-helpers was not given an application name as a prop, so it can't make a unique dom element container for the react application");var r="single-spa-application:".concat(t);return function(){var e=document.getElementById(r);return e||((e=document.createElement("div")).id=r,document.body.appendChild(e)),e}}(t)))throw Error("single-spa's dom-element-getter-helpers was given an invalid domElementGetter for application or parcel '".concat(t.name,"'. Expected a function, received ").concat(l_(r)));return function(){var e=r(t);if(!(e instanceof HTMLElement))throw Error("single-spa's dom-element-getter-helpers: domElementGetter returned an invalid dom element for application or parcel '".concat(t.name,"'. Expected HTMLElement, received ").concat(l_(e)));return e}}var lC=null;try{lC=require("react").createContext()}catch(e){}var lP={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 lk(e,t){return e.rootComponent?Promise.resolve():e.loadRootComponent(t).then(function(t){e.rootComponent=t})}function lR(e,t){return new Promise(function(r,n){e.suppressComponentDidCatchWarning||!function(e){if(!(e&&"string"==typeof e.version&&e.version.indexOf(".")>=0))return!1;var t=e.version.slice(0,e.version.indexOf("."));try{return Number(t)>=16}catch(e){return!1}}(e.React)||e.errorBoundary||e.errorBoundaryClass||(e.rootComponent.prototype?e.rootComponent.prototype.componentDidCatch||console.warn("single-spa-react: ".concat(t.name||t.appName||t.childAppName,"'s rootComponent should implement componentDidCatch to avoid accidentally unmounting the entire single-spa application.")):console.warn("single-spa-react: ".concat(t.name||t.appName||t.childAppName,"'s rootComponent does not implement an error boundary. If using a functional component, consider providing an opts.errorBoundary to singleSpaReact(opts).")));var a,o=l$(e,t,function(){r(this)}),i=lS(e,t)(),s=function(e){var t=e.reactDom,r=e.renderType,n=e.elementToRender,a=e.domElement,o=t[r];if("function"!=typeof o)throw Error('renderType "'.concat(r,'" did not return a function.'));switch(r){case"createRoot":case"unstable_createRoot":case"createBlockingRoot":case"unstable_createBlockingRoot":var i=o(a);return i.render(n),i;case"hydrateRoot":return o(a,n);default:return o(n,a),null}}({elementToRender:o,domElement:i,reactDom:lO(e),renderType:"function"==typeof(a=e).renderType?a.renderType():a.renderType});e.domElements[t.name]=i,e.renderResults[t.name]=s})}function lT(e,t){return new Promise(function(r){e.unmountResolves[t.name]=r;var n=e.renderResults[t.name];n&&n.unmount?n.unmount():lO(e).unmountComponentAtNode(e.domElements[t.name]),delete e.domElements[t.name],delete e.renderResults[t.name]})}function lN(e,t){return new Promise(function(r){e.updateResolves[t.name]||(e.updateResolves[t.name]=[]),e.updateResolves[t.name].push(r);var n=l$(e,t,null),a=e.renderResults[t.name];if(a&&a.render)a.render(n);else{var o=lS(e,t)();lO(e).render(n,o)}})}function lO(e){return e.ReactDOMClient||e.ReactDOM}function l$(e,t,r){var n=e.React.createElement(e.rootComponent,t),a=lC?e.React.createElement(lC.Provider,{value:t},n):n;return(e.errorBoundary||t.errorBoundary||e.errorBoundaryClass||t.errorBoundaryClass)&&(e.errorBoundaryClass=e.errorBoundaryClass||t.errorBoundaryClass||function(e,t){function r(t){e.React.Component.apply(this,arguments),this.state={caughtError:null,caughtErrorInfo:null},r.displayName="SingleSpaReactErrorBoundary(".concat(t.name,")")}return r.prototype=Object.create(e.React.Component.prototype),r.prototype.render=function(){return this.state.caughtError?(e.errorBoundary||t.errorBoundary)(this.state.caughtError,this.state.caughtErrorInfo,this.props):this.props.children},r.prototype.componentDidCatch=function(e,t){this.setState({caughtError:e,caughtErrorInfo:t})},r}(e,t),a=e.React.createElement(e.errorBoundaryClass,t,a)),a=e.React.createElement(e.SingleSpaRoot,lD(lD({},t),{},{mountFinished:r,updateFinished:function(){e.updateResolves[t.name]&&(e.updateResolves[t.name].forEach(function(e){return e()}),delete e.updateResolves[t.name])},unmountFinished:function(){e.unmountResolves[t.name]&&(e.unmountResolves[t.name](),delete e.unmountResolves[t.name])}}),a)}var lA=r(4011),lI=r(5327),lj=r.n(lI),lM=r(3780);let lL={strictMode:!0,throwErrorsToConsole:!0,disableTranslations:!1},lF=new Map;(0,lM.initCache)(lF);let lB={errorRetryCount:3,fetcher:aQ,focusThrottleInterval:18e5,revalidateIfStale:!0,revalidateOnFocus:!1,revalidateOnReconnect:!1,refreshInterval:0,shouldRetryOnError:e=>{if(e instanceof a0){let t=e.response.status;return!!(t>=500)||401===t||403===t||429===t}return!0},provider:()=>lF};function lU(e){if("object"!=typeof e||"string"!=typeof e.featureName||"string"!=typeof e.moduleName)throw Error("Invalid options");let t=Object.assign({},lL,e),r={...lB,...t.swrConfig};return function(e){var n,a,o,i,s;return o=a=class extends(n=lr().Component){componentDidCatch(e,r){r&&r.componentStack&&(e.extra=Object.assign(e.extra||{},{componentStack:r.componentStack})),t.throwErrorsToConsole&&setTimeout(()=>{throw e}),this.setState({caughtError:e,caughtErrorInfo:r})}render(){if(this.state.caughtError)return lr().createElement("div",null,"An error has occurred. Please try reloading the page.");{let n=lr().createElement(lt.Suspense,{fallback:null},lr().createElement(lI.SWRConfig,{value:r},lr().createElement(ln.Provider,{value:this.state.config},t.disableTranslations?lr().createElement(e,this.props):lr().createElement(lA.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},lr().createElement(e,this.props)))));return t.strictMode&&lr().StrictMode?lr().createElement(lr().StrictMode,null,n):n}}constructor(e){super(e),this.state={caughtError:null,caughtErrorInfo:null,config:{moduleName:t.moduleName,featureName:t.featureName,extension:e._extensionContext}}}},i="displayName",s=`OpenmrsReactComponent(${t.featureName})`,i in o?Object.defineProperty(o,i,{value:s,enumerable:!0,configurable:!0,writable:!0}):o[i]=s,a}}function lV(e,t){return function(e){if("object"!==lx(e))throw Error("single-spa-react requires a configuration object");var t,r=lD(lD({},lP),e);if(!r.React)throw Error("single-spa-react must be passed opts.React");if(!r.ReactDOM&&!r.ReactDOMClient)throw Error("single-spa-react must be passed opts.ReactDOM or opts.ReactDOMClient");if(r.renderType||(null!=(t=r.ReactDOMClient)&&t.createRoot?r.renderType="createRoot":r.renderType="render"),!r.rootComponent&&!r.loadRootComponent)throw Error("single-spa-react must be passed opts.rootComponent or opts.loadRootComponent");if(r.errorBoundary&&"function"!=typeof r.errorBoundary)throw Error("The errorBoundary opt for single-spa-react must either be omitted or be a function that returns React elements");!lC&&r.React.createContext&&(lC=r.React.createContext()),r.SingleSpaRoot=function(e){function t(e){t.displayName="SingleSpaRoot(".concat(e.name,")")}return t.prototype=Object.create(e.React.Component.prototype),t.prototype.componentDidMount=function(){setTimeout(this.props.mountFinished)},t.prototype.componentWillUnmount=function(){setTimeout(this.props.unmountFinished)},t.prototype.render=function(){return setTimeout(this.props.updateFinished),this.props.children},t}(r);var n={bootstrap:lk.bind(null,r),mount:lR.bind(null,r),unmount:lT.bind(null,r)};return r.parcelCanUpdate&&(n.update=lN.bind(null,r)),n}({React:lr(),ReactDOMClient:lw,rootComponent:lU(t)(e)})}function lW(e,t){return()=>e().then(({default:e})=>lV(e,t))}function lH(e,t){return()=>Promise.resolve(lV(e,t))}let lz=lW,lK=A()(()=>({}));V("openmrs-app-context",lK);let lG={};function lZ(e,t=e=>e){let r=lK.getState();return e in r?Object.freeze(Object.assign({},t?t(r[e]):r[e])):null}function lY(e,t){lK.setState(r=>(e in r||(r[e]={}),r[e]=t(r[e]),Object.assign({},r)))}function lq(e){return null===e?null:Object.freeze(Object.assign({},e))}let lJ=new Map;function lX(e,t){let r=(0,lt.useRef)(t??{}),n=(0,lt.useRef)(t=>lY(e,t)),a=(0,lt.useRef)(Symbol());return(0,lt.useEffect)(()=>{let r=t??{},n=a.current;return null===lZ(e)?!function(e,t=lG){lK.setState(r=>{if(e in r)throw Error(`Attempted to re-register namespace ${e} in the app context. Each namespace must be unregistered before the name can be registered again.`);return Object.assign({},r,{[e]:t===lG?{}:t})})}(e,r):(console.warn(`Namespace ${e} is already registered in the app context. This is likely a race condition during navigation, but may indicate two components are trying to own the same namespace. Updating the existing context.`),lY(e,()=>r)),lJ.set(e,n),()=>{lJ.get(e)===n&&(lK.setState(t=>(e in t&&delete t[e],t)),lJ.delete(e))}},[e]),(0,lt.useEffect)(()=>{let n=t??{};T(r.current,n)||(lY(e,()=>n),r.current=n)},[t]),n.current}function lQ({namespace:e,value:t}){return lX(e,t),null}let l0=({children:e,value:t,fallback:r})=>t?lr().createElement(lr().Fragment,null,e):r?lr().createElement(lr().Fragment,null,r):null;function l1(){let e=(0,lt.useRef)();return(!e.current||e.current.signal.aborted)&&(e.current=new AbortController),(0,lt.useEffect)(()=>{let t=e.current;return()=>t?.abort()},[]),e.current}function l4(e,t=e=>e??{}){let[r,n]=(0,lt.useState)(()=>{if(l2(e))return;let r=lZ(e);if(null!==r)return t?t(r):r});return(0,lt.useEffect)(()=>{if(l2(e))throw Error(`The namespace supplied to useAppContext must be a non-empty string, but was "${e}".`)},[e]),(0,lt.useEffect)(()=>{var r;let a;return(r=e=>{if(null==e)return void n(void 0);let r=t?t(e):e;n(e=>T(e,r)?e:r)})(lq(a=lZ(e))),lK.subscribe(t=>{let n=e in t?t[e]:null;n!==a&&(a=n,r(lq(n)))})},[e,t]),r}function l2(e){return"string"!=typeof e||0===e.trim().length}function l3(e){let t=lg(e);return(0,lt.useMemo)(()=>t.map(e=>e.id),[t])}function l6(e){return lf(e).candidateExtensions}function l5(e,t,r){let{data:n,error:a,mutate:o,isLoading:i,isValidating:s}=lj()(e?ie(e,t,r):null,aQ);return(0,lt.useMemo)(()=>({isLoading:i,data:n?.data.results??[],error:a,mutate:o,isValidating:s}),[n,a,i,s,o])}function l9(e){(0,lt.useEffect)(()=>{if(e){let e=window.getComputedStyle(document.body).overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=e}}},[e])}let l8={},l7=`No ComponentContext has been provided. This should come from "openmrsComponentDecorator".
|
|
15
|
+
${this.stack}`}}let a1=B("session",{loaded:!1,session:null}),a4=0,a2=null;function a3(){return a2||(a1.getState().loaded&&a4>=Date.now()-6e4?null:a8())}function a6(e){let t=e?.includeAuthStatus??!0,r=e=>t?e:e.user,n=a3();return n?new Promise(e=>{let t=()=>{let t=a1.getState();t.loaded&&(a(),e(r(t.session)))},a=a1.subscribe(t);n.then(t,t)}):Promise.resolve(r(a1.getState().session))}function a5(){return a3(),a1}function a9(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 a8(e,t){a4=Date.now(),o??(o=a4);let r={};e&&t&&(r.Authorization=`Basic ${window.btoa(`${e}:${t}`)}`);let n=ol(aQ(aJ,{headers:r,rejectAuthFailure:!0})),a=()=>{a2===n&&(a2=null)};return n.then(a,a),a2=n,n}function a7(){a1.setState({loaded:!0,session:{authenticated:!1,sessionId:""}},!0)}function oe(e,t){var r,n;if(void 0===t)return!e;if(!e)return!0;return r=e,n=t,("string"==typeof r?!K(n.privileges.find(e=>r===e.display)):Array.isArray(r)?r.every(e=>!K(n.privileges.find(t=>e===t.display))):(K(r)||console.error(`Could not understand privileges "${r}"`),!0))||!K(t.roles.find(e=>"System Developer"===e.display))}function ot(){let e,t;return new Promise(r=>{let n=n=>{n.loaded&&n.session.user&&(e=n.session.user,r(n.session.user),t&&t())};n(a1.getState()),e||(t=a1.subscribe(n))})}async function or(){return(await a6()).sessionLocation}async function on(e,t){return ol(aQ(aJ,{method:"POST",body:{sessionLocation:e},headers:{"Content-Type":"application/json"},rejectAuthFailure:!0,signal:t?.signal}))}async function oa(e,t){return await aQ(aJ,{method:"POST",body:{locale:e},headers:{"Content-Type":"application/json"},signal:t?.signal}),a8()}async function oo(e,t,r){return r||(r=new AbortController),await aQ(`${aY}/user/${e}`,{method:"POST",body:{userProperties:t},headers:{"Content-Type":"application/json"},signal:r.signal}),a8()}async function oi(e,t=!1){let r=await aQ(t?`${aJ}?rememberMe=true`:aJ,{headers:{"X-Totp-Code":e}});return r.data?.authenticated?(await a8()).session:r.data}async function os(){try{await aQ(aJ,{method:"DELETE",rejectAuthFailure:!0})}catch(e){if(!ou(e))throw e}a7(),await a8().catch(()=>{})}function ol(e){return new Promise((t,r)=>{e.then(e=>{if("object"==typeof e?.data){let r={loaded:!0,session:e.data};a1.setState(r,!0),t(r)}else!function(e){if(!e?.redirected||!e.url)return!1;try{return new URL(e.url,window.location.href).pathname.replace(/\/+$/,"").endsWith("/initialsetup")}catch{return!1}}(e)?r(oc(Error("The session endpoint did not respond with a session"))):r(oc(Error("The server is still starting up"),!0))}).catch(e=>{var n,a;if(ou(e)){"object"==typeof(n=e.responseBody)&&null!==n&&!1===n.authenticated?a1.setState({loaded:!0,session:e.responseBody},!0):a7(),t(a1.getState());return}(a=e)instanceof a0&&502===a.response.status&&!a1.getState().loaded&&void 0!==o&&Date.now()-o<18e4?r(oc(e,!0)):(P(`Failed to fetch new session information: ${e}`),r(oc(e)))})})}function ou(e){return e instanceof a0&&(401===e.response.status||403===e.response.status)}function oc(e,t=!1){return a1.getState().loaded||a1.setState({loaded:!1,session:null,error:e instanceof Error?e:Error(String(e)),initializing:t},!0),a1.getState()}function od(){return"development"===window.spaEnv||"true"===localStorage.getItem("openmrs:devtools")}a1.subscribe(e=>{e.loaded&&e.session&&a9(e.session)});let om={"webservices.rest":"2.24.0",fhir2:"1.0.0-SNAPSHOT"};function op(){rk("@openmrs/esm-api",aG),a8()}let of="import-map-override:",oh="import-map-overrides-disabled",og="import-map-overrides:change",oy=!1,ov=null,ob=null;async function ow(){return ob??(ob=oE().then(({map:e,complete:t})=>(t||(ob=null),e))),ob}async function oE(){let e=document.querySelectorAll('script[type="systemjs-importmap"]'),t=[],r=!0;for(let n=0;n<e.length;n++){let a=e[n];try{if(a.src){let e=await fetch(a.src);if(!e.ok)throw Error(`Request for ${a.src} returned ${e.status} ${e.statusText}`);t.push(await e.json())}else a.textContent&&t.push(JSON.parse(a.textContent))}catch(e){r=!1,console.warn(`[import-maps] Failed to parse import map from script tag at index ${n}`,e)}}return{map:oD(t),complete:r}}function oD(e){let t={imports:{}};for(let r of e)r?.imports&&Object.assign(t.imports,r.imports);return t}function ox(){let e={};try{let t=ok();for(let r=0;r<localStorage.length;r++){let n=localStorage.key(r);if(n?.startsWith(of)){let r=n.slice(of.length);if(!t.includes(r)){let t=localStorage.getItem(n);t&&(e[r]=t)}}}}catch(e){console.warn("[import-maps] Failed to read import-map overrides from localStorage",e)}return{imports:e}}async function o_(){let e=await ow();return oy?oD([e,ov??ox()]):e}async function oS(){return ow()}async function oC(){return oy?oD([await ow(),ox()]):ow()}function oP(e){if(!oy)return{imports:{}};if(e){let e={};for(let t=0;t<localStorage.length;t++){let r=localStorage.key(t);if(r?.startsWith(of)){let t=localStorage.getItem(r);t&&(e[r.slice(of.length)]=t)}}return{imports:e}}return ox()}function ok(){if(!oy)return[];try{let e=localStorage.getItem(oh);if(e){let t=JSON.parse(e);if(Array.isArray(t))return t}}catch{}return[]}function oR(e){return!!oy&&ok().includes(e)}function oT(e,t){if(!oy)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{localStorage.setItem(of+e,t),window.dispatchEvent(new CustomEvent(og))}catch(e){console.warn("[import-maps] Failed to write import-map override to localStorage",e)}}function oN(e){if(!oy)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{localStorage.removeItem(of+e);let t=ok().filter(t=>t!==e);t.length>0?localStorage.setItem(oh,JSON.stringify(t)):localStorage.removeItem(oh),window.dispatchEvent(new CustomEvent(og))}catch(e){console.warn("[import-maps] Failed to update import-map overrides in localStorage",e)}}function oO(){if(!oy)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{let e=[];for(let t=0;t<localStorage.length;t++){let r=localStorage.key(t);r?.startsWith(of)&&e.push(r)}e.forEach(e=>localStorage.removeItem(e)),localStorage.removeItem(oh),window.dispatchEvent(new CustomEvent(og))}catch(e){console.warn("[import-maps] Failed to clear import-map overrides from localStorage",e)}}function o$(e){if(!oy)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{let t=ok().filter(t=>t!==e);t.length>0?localStorage.setItem(oh,JSON.stringify(t)):localStorage.removeItem(oh),window.dispatchEvent(new CustomEvent(og))}catch(e){console.warn("[import-maps] Failed to update import-map overrides in localStorage",e)}}let oA=!1;function oI(){!oA&&(oA=!0,(oy="development"===window.spaEnv)&&(ov=ox()))}function oj(e){return e.replace(/[\/\-@]/g,"_")}async function oM(e,t="./start",n){var a;let o,i=!n?.maxLoadingTime||n.maxLoadingTime<=0?6e5:n.maxLoadingTime;await Promise.race([oL(e,n?.importMap),new Promise((t,r)=>{o=setTimeout(()=>{var t;r(Error(`Could not resolve requested script, ${e}, within ${(t=i)<1e3?`${t} milliseconds`:t<6e4?`${Math.floor(t/1e3)} seconds`:t<36e5?`${Math.floor(t/6e4)} minutes`:t<864e5?`${Math.floor(t/36e5)} hours`:`${Math.floor(t/864e5)} days`}.`))},i)})]),o&&clearTimeout(o);let s=oj(e),l=window[s];if(!("object"==typeof(a=l)&&null!==a&&"init"in a&&"function"==typeof a.init&&"get"in a&&"function"==typeof a.get)){let e=`The global variable ${s} does not refer to a federated module`;throw console.error(e),Error(e)}l.init(r.S.default);let u=(await l.get(t))();if("object"!=typeof u||null===u){let t=`Container for ${e} did not return an ESM module as expected`;throw console.error(t),Error(t)}return u}async function oL(e,t){if("string"!=typeof e||0===e.trim().length){let e="Attempted to call importDynamic() without supplying a package to load";throw console.error(e),Error(e)}let r=oj(e);if(!window[r]){let r=t??await oF();if(!r.imports.hasOwnProperty(e)){let t=`Could not find the package ${e} defined in the current importmap`;throw console.error(t),Error(t)}let n=r.imports[e];n.startsWith("./")&&(n=window.spaBase+n.substring(1));let a=e in oP().imports;try{return await function(e){var t;let r=(t=window)[oB]??(t[oB]=new Map),n=r.get(e);if(n)return n;if(document.head.querySelector(`script[src="${e}"]`))return console.warn(`Script at ${e} already loaded. Not loading it again.`),Promise.resolve();let a=document.createElement("script");a.src=e,a.type="text/javascript",a.async=!0;let o=new Promise((t,n)=>{let o=setTimeout(()=>{console.error(`The script at ${e} did not load within 5 seconds. This may indicate an issue with the imports in the script's entry-point file or with the script's bundler configuration.`)},5e3);function i(){clearTimeout(o),a.removeEventListener("load",s),a.removeEventListener("error",l)}function s(){i(),t()}function l(t){i(),r.delete(e),a.remove();let o=`Failed to load script from ${e}`;console.error(o,t),n(t.message??o)}a.addEventListener("load",s),a.addEventListener("error",l),document.head.appendChild(a)});return r.set(e,o),o}(n)}catch(e){return a&&E({kind:"error",title:aj("scriptLoadingFailed","Error: Script failed to load"),description:aj("scriptLoadingError","Failed to load overridden script from {{- url}}. Please check that the bundled script is available at the expected URL. Click the button below to reset all import map overrides.",{url:n}),actionButtonLabel:aj("resetOverrides","Reset overrides"),onActionButtonClick(){oO(),window.location.reload()}}),Promise.reject(e)}}return Promise.resolve()}async function oF(){return o_()}let oB=Symbol.for("__openmrs_script_loading");function oU(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 oV(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&&oU(t))}let oW="openmrs-routes:",oH="openmrs-routes:change",oz=!1,oK=null,oG=null;async function oZ(){return oG??(oG=oY().then(({map:e,complete:t})=>(t||(oG=null),e))),oG}async function oY(){let e=document.querySelectorAll("script[type='openmrs-routes']"),t=[],r=!0;for(let n=0;n<e.length;n++){let a=e[n];try{let e;if(a.src){let t=await fetch(a.src);if(!t.ok)throw Error(`Request for ${a.src} returned ${t.status} ${t.statusText}`);e=await t.json()}else a.textContent&&(e=JSON.parse(a.textContent));e&&oV(e)&&t.push(e)}catch(e){r=!1,console.warn(`[route-maps] Failed to parse routes from script tag at index ${n}`,e)}}return{map:oq(t),complete:r}}function oq(e){let t={routes:{}};for(let r of e)r&&"object"==typeof r&&!Array.isArray(r)&&(Object.assign(t.routes,r.routes),void 0===t.version&&void 0!==r.version&&(t.version=r.version));return t}async function oJ(){let e={version:void 0,routes:{}};try{let t=[];for(let e=0;e<localStorage.length;e++){let r=localStorage.key(e);if(r?.startsWith(oW)){let e=localStorage.getItem(r);e&&t.push({moduleName:r.slice(oW.length),raw:e})}}for(let r of(await Promise.allSettled(t.map(async({moduleName:e,raw:t})=>{let r=JSON.parse(t);if(oU(r))return{moduleName:e,routes:r};if("string"==typeof r&&r.startsWith("http")){let t=await fetch(r),n=await t.json();if(oU(n))return{moduleName:e,routes:n};throw Error(`${r} did not resolve to a valid OpenmrsAppRoutes object`)}throw Error(`Override for ${e} is neither a valid routes object nor a URL`)}))))"fulfilled"===r.status?e.routes[r.value.moduleName]=r.value.routes:console.warn("[route-maps] Failed to load route override",r.reason)}catch(e){console.warn("[route-maps] Failed to read route overrides from localStorage",e)}return e}async function oX(){let e=await oZ();return oz?oq([e,oK??await oJ()]):e}async function oQ(){return oZ()}async function o0(){return oz?oq([await oZ(),await oJ()]):oZ()}function o1(){if(!oz)return{};let e={};try{for(let t=0;t<localStorage.length;t++){let r=localStorage.key(t);if(r?.startsWith(oW)){let t=localStorage.getItem(r);t&&(e[r.slice(oW.length)]=t)}}}catch(e){console.warn("[route-maps] Failed to read route overrides from localStorage",e)}return e}function o4(e,t){if(!oz)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{if("string"==typeof t)if(t.startsWith("http"))localStorage.setItem(oW+e,JSON.stringify(t));else{let r=JSON.parse(t);if(!oU(r))return void console.error(`The supplied routes for ${e} is not a valid OpenmrsAppRoutes object`,t);localStorage.setItem(oW+e,JSON.stringify(r))}else if(t instanceof URL)localStorage.setItem(oW+e,JSON.stringify(t.toString()));else{if(!oU(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(oW+e,JSON.stringify(t))}window.dispatchEvent(new CustomEvent(oH))}catch(e){console.warn("[route-maps] Failed to write route override to localStorage",e)}}function o2(e){if(!oz)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{localStorage.removeItem(oW+e),window.dispatchEvent(new CustomEvent(oH))}catch(e){console.warn("[route-maps] Failed to remove route override from localStorage",e)}}function o3(){if(!oz)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{let e=[];for(let t=0;t<localStorage.length;t++){let r=localStorage.key(t);r?.startsWith(oW)&&e.push(r)}e.forEach(e=>localStorage.removeItem(e)),window.dispatchEvent(new CustomEvent(oH))}catch(e){console.warn("[route-maps] Failed to clear route overrides from localStorage",e)}}let o6=null;function o5(){return o6||(o6=(oz="development"===window.spaEnv)?oJ().then(e=>{oK=e}):Promise.resolve())}let o9=`${aY}/attachment`;function o8(e,t){return aQ(`${o9}/${e}`,{signal:t.signal})}function o7(e,t,r,n){return aQ(ie(e,t,n),{signal:r.signal})}function ie(e,t,r){return r?`${o9}?patient=${e}&encounter=${r}`:`${o9}?patient=${e}&includeEncounterless=${t}`}async function it(e,t,r){let n=new FormData;return n.append("fileCaption",t.fileDescription),n.append("patient",e),r&&n.append("encounter",r),t.file?n.append("file",t.file,t.fileName):(n.append("file",new File([""],t.fileName),t.fileName),n.append("base64Content",t.base64Content)),aQ(`${o9}`,{method:"POST",body:n})}function ir(e,t){return aQ(`${o9}/${e}`,{method:"DELETE",signal:t.signal})}async function ia(e,t){return e?(await aQ(`${aq}/Patient/${e}`,t)).data:null}function io(e,t){let r=new CustomEvent(`openmrs:${e}`,{detail:t??void 0,cancelable:!0,bubbles:!0});return window.dispatchEvent(r)}function ii(e,t){let r=e=>{t("detail"in e&&null!==e.detail?e.detail:void 0)};return window.addEventListener(`openmrs:${e}`,r),()=>{window.removeEventListener(`openmrs:${e}`,r)}}function is(e){return{uuid:e.uuid,display:e.display}}function il(e=null,t=null){let r=new URLSearchParams;e&&r.set("tag",e),t&&r.set("q",t);let n=r.toString();return aQ(`${aY}/location${n?"?"+n:""}`).then(e=>e.data.results.map(is))}function iu(e){return{uuid:e.uuid,display:e.display,name:e.name}}let ic=`${aY}/visittype`;function id(e=ic){return aQ(e).then(e=>e.data.results.map(iu))}var im=((ee={}).NEWVISIT="startVisit",ee.EDITVISIT="editVisit",ee.LOADING="loadingVisit",ee),ip=((et={}).NOTSTARTED="notStarted",et.ONGOING="ongoing",et);let ih="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))",ig=function(){try{return JSON.parse(sessionStorage.getItem("openmrs:visitStoreState")||"null")}catch(e){return null}}()||{patientUuid:null,manuallySetVisitUuid:null};function iy(){return W("visit",ig)}function iv(e,t){iy().setState({patientUuid:e,manuallySetVisitUuid:t})}function ib(e,t){return aQ(`${aY}/visit`,{signal:t.signal,method:"POST",headers:{"Content-type":"application/json"},body:e})}function iw(e,t,r){return aQ(`${aY}/visit/${e}`,{signal:r.signal,method:"POST",headers:{"Content-type":"application/json"},body:t})}function iE(e,t,r){return aQ(`${aY}/visit?patient=${e}&v=${r??ih}`,{signal:t.signal,method:"GET",headers:{"Content-type":"application/json"}})}iy().subscribe(e=>{var t;t=e,sessionStorage.setItem("openmrs:visitStoreState",JSON.stringify(t))});class iD{static get version(){return"1.4.0"}static toString(){return"JavaScript Expression Parser (JSEP) v"+iD.version}static addUnaryOp(e){return iD.max_unop_len=Math.max(e.length,iD.max_unop_len),iD.unary_ops[e]=1,iD}static addBinaryOp(e,t,r){return iD.max_binop_len=Math.max(e.length,iD.max_binop_len),iD.binary_ops[e]=t,r?iD.right_associative.add(e):iD.right_associative.delete(e),iD}static addIdentifierChar(e){return iD.additional_identifier_chars.add(e),iD}static addLiteral(e,t){return iD.literals[e]=t,iD}static removeUnaryOp(e){return delete iD.unary_ops[e],e.length===iD.max_unop_len&&(iD.max_unop_len=iD.getMaxKeyLen(iD.unary_ops)),iD}static removeAllUnaryOps(){return iD.unary_ops={},iD.max_unop_len=0,iD}static removeIdentifierChar(e){return iD.additional_identifier_chars.delete(e),iD}static removeBinaryOp(e){return delete iD.binary_ops[e],e.length===iD.max_binop_len&&(iD.max_binop_len=iD.getMaxKeyLen(iD.binary_ops)),iD.right_associative.delete(e),iD}static removeAllBinaryOps(){return iD.binary_ops={},iD.max_binop_len=0,iD}static removeLiteral(e){return delete iD.literals[e],iD}static removeAllLiterals(){return iD.literals={},iD}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 iD(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 iD.binary_ops[e]||0}static isIdentifierStart(e){return e>=65&&e<=90||e>=97&&e<=122||e>=128&&!iD.binary_ops[String.fromCharCode(e)]||iD.additional_identifier_chars.has(String.fromCharCode(e))}static isIdentifierPart(e){return iD.isIdentifierStart(e)||iD.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(iD.hooks[e]){let r={context:this,node:t};return iD.hooks.run(e,r),r.node}return t}searchHook(e){if(iD.hooks[e]){let t={context:this};return iD.hooks[e].find(function(e){return e.call(t.context,t),t.node}),t.node}}gobbleSpaces(){let e=this.code;for(;e===iD.SPACE_CODE||e===iD.TAB_CODE||e===iD.LF_CODE||e===iD.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:iD.COMPOUND,body:e};return this.runHook("after-all",t)}gobbleExpressions(e){let t=[],r,n;for(;this.index<this.expr.length;)if((r=this.code)===iD.SEMCOL_CODE||r===iD.COMMA_CODE)this.index++;else if(n=this.gobbleExpression())t.push(n);else if(this.index<this.expr.length){if(r===e)break;this.throwError('Unexpected "'+this.char+'"')}return t}gobbleExpression(){let e=this.searchHook("gobble-expression")||this.gobbleBinaryExpression();return this.gobbleSpaces(),this.runHook("after-expression",e)}gobbleBinaryOp(){this.gobbleSpaces();let e=this.expr.substr(this.index,iD.max_binop_len),t=e.length;for(;t>0;){if(iD.binary_ops.hasOwnProperty(e)&&(!iD.isIdentifierStart(this.code)||this.index+e.length<this.expr.length&&!iD.isIdentifierPart(this.expr.charCodeAt(this.index+e.length))))return this.index+=t,e;e=e.substr(0,--t)}return!1}gobbleBinaryExpression(){let e,t,r,n,a,o,i,s,l;if(!(o=this.gobbleToken())||!(t=this.gobbleBinaryOp()))return o;for(a={value:t,prec:iD.binaryPrecedence(t),right_a:iD.right_associative.has(t)},(i=this.gobbleToken())||this.throwError("Expected expression after "+t),n=[o,a,i];t=this.gobbleBinaryOp();){if(0===(r=iD.binaryPrecedence(t))){this.index-=t.length;break}a={value:t,prec:r,right_a:iD.right_associative.has(t)},l=t;let s=e=>a.right_a&&e.right_a?r>e.prec:r<=e.prec;for(;n.length>2&&s(n[n.length-2]);)i=n.pop(),t=n.pop().value,o=n.pop(),e={type:iD.BINARY_EXP,operator:t,left:o,right:i},n.push(e);(e=this.gobbleToken())||this.throwError("Expected expression after "+l),n.push(a,e)}for(s=n.length-1,e=n[s];s>1;)e={type:iD.BINARY_EXP,operator:n[s-1].value,left:n[s-2],right:e},s-=2;return e}gobbleToken(){let e,t,r,n;if(this.gobbleSpaces(),n=this.searchHook("gobble-token"))return this.runHook("after-token",n);if(e=this.code,iD.isDecimalDigit(e)||e===iD.PERIOD_CODE)return this.gobbleNumericLiteral();if(e===iD.SQUOTE_CODE||e===iD.DQUOTE_CODE)n=this.gobbleStringLiteral();else if(e===iD.OBRACK_CODE)n=this.gobbleArray();else{for(r=(t=this.expr.substr(this.index,iD.max_unop_len)).length;r>0;){if(iD.unary_ops.hasOwnProperty(t)&&(!iD.isIdentifierStart(this.code)||this.index+t.length<this.expr.length&&!iD.isIdentifierPart(this.expr.charCodeAt(this.index+t.length)))){this.index+=r;let e=this.gobbleToken();return e||this.throwError("missing unaryOp argument"),this.runHook("after-token",{type:iD.UNARY_EXP,operator:t,argument:e,prefix:!0})}t=t.substr(0,--r)}iD.isIdentifierStart(e)?(n=this.gobbleIdentifier(),iD.literals.hasOwnProperty(n.name)?n={type:iD.LITERAL,value:iD.literals[n.name],raw:n.name}:n.name===iD.this_str&&(n={type:iD.THIS_EXP})):e===iD.OPAREN_CODE&&(n=this.gobbleGroup())}return n?(n=this.gobbleTokenProperty(n),this.runHook("after-token",n)):this.runHook("after-token",!1)}gobbleTokenProperty(e){this.gobbleSpaces();let t=this.code;for(;t===iD.PERIOD_CODE||t===iD.OBRACK_CODE||t===iD.OPAREN_CODE||t===iD.QUMARK_CODE;){let r;if(t===iD.QUMARK_CODE){if(this.expr.charCodeAt(this.index+1)!==iD.PERIOD_CODE)break;r=!0,this.index+=2,this.gobbleSpaces(),t=this.code}this.index++,t===iD.OBRACK_CODE?((e={type:iD.MEMBER_EXP,computed:!0,object:e,property:this.gobbleExpression()}).property||this.throwError('Unexpected "'+this.char+'"'),this.gobbleSpaces(),(t=this.code)!==iD.CBRACK_CODE&&this.throwError("Unclosed ["),this.index++):t===iD.OPAREN_CODE?e={type:iD.CALL_EXP,arguments:this.gobbleArguments(iD.CPAREN_CODE),callee:e}:(t===iD.PERIOD_CODE||r)&&(r&&this.index--,this.gobbleSpaces(),e={type:iD.MEMBER_EXP,computed:!1,object:e,property:this.gobbleIdentifier()}),r&&(e.optional=!0),this.gobbleSpaces(),t=this.code}return e}gobbleNumericLiteral(){let e="",t,r;for(;iD.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);if(this.code===iD.PERIOD_CODE)for(e+=this.expr.charAt(this.index++);iD.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++));iD.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);iD.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+e+this.char+")")}return r=this.code,iD.isIdentifierStart(r)?this.throwError("Variable names cannot start with a number ("+e+this.char+")"):(r===iD.PERIOD_CODE||1===e.length&&e.charCodeAt(0)===iD.PERIOD_CODE)&&this.throwError("Unexpected period"),{type:iD.LITERAL,value:parseFloat(e),raw:e}}gobbleStringLiteral(){let e="",t=this.index,r=this.expr.charAt(this.index++),n=!1;for(;this.index<this.expr.length;){let t=this.expr.charAt(this.index++);if(t===r){n=!0;break}if("\\"===t)switch(t=this.expr.charAt(this.index++)){case"n":e+="\n";break;case"r":e+="\r";break;case"t":e+=" ";break;case"b":e+="\b";break;case"f":e+="\f";break;case"v":e+="\v";break;default:e+=t}else e+=t}return n||this.throwError('Unclosed quote after "'+e+'"'),{type:iD.LITERAL,value:e,raw:this.expr.substring(t,this.index)}}gobbleIdentifier(){let e=this.code,t=this.index;for(iD.isIdentifierStart(e)?this.index++:this.throwError("Unexpected "+this.char);this.index<this.expr.length;)if(e=this.code,iD.isIdentifierPart(e))this.index++;else break;return{type:iD.IDENTIFIER,name:this.expr.slice(t,this.index)}}gobbleArguments(e){let t=[],r=!1,n=0;for(;this.index<this.expr.length;){this.gobbleSpaces();let a=this.code;if(a===e){r=!0,this.index++,e===iD.CPAREN_CODE&&n&&n>=t.length&&this.throwError("Unexpected token "+String.fromCharCode(e));break}if(a===iD.COMMA_CODE){if(this.index++,++n!==t.length){if(e===iD.CPAREN_CODE)this.throwError("Unexpected token ,");else if(e===iD.CBRACK_CODE)for(let e=t.length;e<n;e++)t.push(null)}}else if(t.length!==n&&0!==n)this.throwError("Expected comma");else{let e=this.gobbleExpression();e&&e.type!==iD.COMPOUND||this.throwError("Expected comma"),t.push(e)}}return r||this.throwError("Expected "+String.fromCharCode(e)),t}gobbleGroup(){this.index++;let e=this.gobbleExpressions(iD.CPAREN_CODE);if(this.code===iD.CPAREN_CODE)return(this.index++,1===e.length)?e[0]:!!e.length&&{type:iD.SEQUENCE_EXP,expressions:e};this.throwError("Unclosed (")}gobbleArray(){return this.index++,{type:iD.ARRAY_EXP,elements:this.gobbleArguments(iD.CBRACK_CODE)}}}Object.assign(iD,{hooks:new class{add(e,t,r){if("string"!=typeof arguments[0])for(let e in arguments[0])this.add(e,arguments[0][e],arguments[1]);else(Array.isArray(e)?e:[e]).forEach(function(e){this[e]=this[e]||[],t&&this[e][r?"unshift":"push"](t)},this)}run(e,t){this[e]=this[e]||[],this[e].forEach(function(e){e.call(t&&t.context?t.context:t,t)})}},plugins:new class{constructor(e){this.jsep=e,this.registered={}}register(...e){e.forEach(e=>{if("object"!=typeof e||!e.name||!e.init)throw Error("Invalid JSEP plugin format");this.registered[e.name]||(e.init(this.jsep),this.registered[e.name]=e)})}}(iD),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"}),iD.max_unop_len=iD.getMaxKeyLen(iD.unary_ops),iD.max_binop_len=iD.getMaxKeyLen(iD.binary_ops);let ix=e=>new iD(e).parse(),i_=Object.getOwnPropertyNames(class{});Object.getOwnPropertyNames(iD).filter(e=>!i_.includes(e)&&void 0===ix[e]).forEach(e=>{ix[e]=iD[e]}),ix.Jsep=iD,ix.plugins.register({name:"ternary",init(e){e.hooks.add("after-expression",function(t){if(t.node&&this.code===e.QUMARK_CODE){this.index++;let r=t.node,n=this.gobbleExpression();if(n||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===e.COLON_CODE){this.index++;let a=this.gobbleExpression();if(a||this.throwError("Expected expression"),t.node={type:"ConditionalExpression",test:r,consequent:n,alternate:a},r.operator&&e.binary_ops[r.operator]<=.9){let n=r;for(;n.right.operator&&e.binary_ops[n.right.operator]<=.9;)n=n.right;t.node.test=n.right,n.right=t.node,t.node=r}}else this.throwError("Expected :")}})}});let iS="ArrowFunctionExpression",iC={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)}},iP={...iC,Promise};function ik(e,t={}){return iA(e,t,iM)}async function iR(e,t={}){return iI(e,t,iM)}function iT(e,t={}){return iA(e,t,iL)}function iN(e,t={}){return iI(e,t,iL)}function iO(e,t={}){return iA(e,t,iF)}function i$(e,t={}){return iI(e,t,iF)}function iA(e,t={},r){if("string"!=typeof e&&("object"!=typeof e||!e||!("type"in e)))throw`Unknown expression type ${e}. Expressions must either be a string or pre-compiled string.`;if("string"==typeof e&&0===e.trim().length)throw{type:"Empty expression",message:"Expression cannot be an empty string"};null==t&&(t={});let n=iH(t,iC),a=iB("string"==typeof e?ix(e):e,n);if(r(a))return a;throw{type:"Invalid result",message:"string"==typeof e?`The expression ${e} did not produce a valid result`:"The expression did not produce a valid result"}}async function iI(e,t={},r){if("string"!=typeof e&&("object"!=typeof e||!e||!("type"in e)))return Promise.reject(`Unknown expression type ${e}. Expressions must either be a string or pre-compiled string.`);if("string"==typeof e&&0===e.trim().length)throw{type:"Empty expression",message:"Expression cannot be an empty string"};null==t&&(t={});let n=iH(t,iP);return Promise.resolve(iB("string"==typeof e?ix(e):e,n)).then(t=>{if(r(t))return t;throw{type:"Invalid result",message:"string"==typeof e?`The expression ${e} did not produce a valid result`:"The expression did not produce a valid result"}})}function ij(e){return ix(e)}function iM(e){return"string"==typeof e||"number"==typeof e||"boolean"==typeof e||null==e||e instanceof Date}function iL(e){return"boolean"==typeof e}function iF(e){return"number"==typeof e}function iB(e,t){switch(e.type){case"UnaryExpression":var r,n,a,o,i,s,l,u,c,d,m,p,f,h=e,g=t;let y=iB(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 iB(v.left,b)&&iB(v.right,b);case"||":return iB(v.left,b)||iB(v.right,b);case"??":return iB(v.left,b)??iB(v.right,b)}let w=iB(v.left,b),E=iB(v.right,b);switch(v.operator){case"+":return w+E;case"-":return w-E;case"*":return w*E;case"/":return w/E;case"%":return w%E;case"**":return w**E;case"==":return w==E;case"===":return w===E;case"!=":return w!=E;case"!==":return w!==E;case">":return w>E;case">=":return w>=E;case"<":return w<E;case"<=":return w<=E;case"in":return w in E;default:throw`Expression evaluator does not support operator '${v.operator}' operator`}case"ConditionalExpression":return r=e,n=t,iB(r.test,n)?iB(r.consequent,n):iB(r.alternate,n);case"CallExpression":return iG(iV(e,t));case"ArrowFunctionExpression":let D;return a=e,o=t,D=a.params?.map(e=>{if("Identifier"===e.type)return e.name;throw`Cannot handle parameter of type ${e.type}`})??[],(function(...e){if(e.length<D.length)throw`Required argument(s) ${D.slice(e.length,-1).join(", ")} were not provided`;let t=Object.fromEntries(D.reduce((t,r,n)=>{let a=e[n];return function e(t){if("string"==typeof t||"number"==typeof t||"boolean"==typeof t||"function"==typeof t||null===t||t instanceof RegExp)return!0;if("object"==typeof t){for(let r of Object.keys(t))if(!e(t[r]))return!1;return!0}if(Array.isArray(t)){for(let r of t)if(!e(r))break}return!1}(a)&&t.push([r,a]),t},[]));return iB(a.body,o.addVariables(t))}).bind(null);case"MemberExpression":return iG(iW(e,t));case"ArrayExpression":return i=e,s=t,i.elements?.map(iZ(s));case"SequenceExpression":let x;return l=e,u=t,(x=l.expressions.map(iZ(u)))[x.length-1];case"NewExpression":var _=e,S=t;if(_.callee&&"Identifier"===_.callee.type){let e=_.arguments?.map(iZ(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,(iY(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,P;return m=e,p=t,C=m.expressions?.map(iZ(p))??[],(P=m.quasis?.map(iZ(p))??[]).filter(e=>!e.tail).map(e=>e.value).join("")+C.join("")+P.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 iU(e,t){switch(e.type){case"Literal":return e.value;case"Identifier":return e.name;case"MemberExpression":return iU(e.property,t);default:throw`VisitExpressionName does not support expression of type '${e.type}'`}}function iV(e,t){let r=iK(e.callee,t);if(r===iz||e.optional&&null==r)return iz;let n=e.arguments?.map(iZ(t));if(r){if("function"!=typeof r)throw`${iX(e.callee)} is not a function`}else throw`No function named ${iX(e.callee)} is defined in this context`;return r(...n)}function iW(e,t){let r=iK(e.object,t);if(r===iz||e.optional&&null==r)return iz;if(null===r)throw TypeError(`TypeError: cannot read properties of null (reading '${iJ(e.property,t)}')`);if(void 0===r)switch(e.object.type){case"Identifier":{let r=iU(e.object,t);throw ReferenceError(`ReferenceError: ${r} is not defined`)}case"MemberExpression":throw TypeError(`TypeError: cannot read properties of undefined (reading '${iJ(e.property,t)}')`);default:throw`VisitMemberExpression does not support operator '${e.object.type}' type`}if("object"!=typeof r&&"function"!=typeof r&&"string"!=typeof r&&"number"!=typeof r)throw`VisitMemberExpression does not support member access on type ${typeof r}`;let n=e.computed?function(e){if(void 0===e)throw{type:"Illegal property access",message:"No property was supplied to the property access"};if("string"!=typeof e&&"number"!=typeof e)throw{type:"Illegal property access",message:`Cannot use a value of type ${null===e?"null":typeof e} as a property name`};return e}(iB(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);iY(n),function(e,t){if(iq.has(String(t)))return;let r=Object(e);for(;null!==r;){if(Object.hasOwn(r,t)){if(r===Object.prototype||r===Function.prototype)throw{type:"Illegal property access",message:`Cannot access the ${t} property of objects`};return}r=Object.getPrototypeOf(r)}}(r,n);let a=r[n];return"function"==typeof a?a.bind(r):a}function iH(e,t){let r={variables:{...e},globals:{...t},addVariables(e){return this.variables={...this.variables,...e},this}};return r.addVariables.bind(r),r}ix.plugins.register({name:"arrow",init(e){e.addBinaryOp("=>",.1,!0),e.hooks.add("gobble-expression",function(t){if(this.gobbleSpaces(),this.code===e.OPAREN_CODE){let r=this.index;if(this.index++,this.gobbleSpaces(),this.code===e.CPAREN_CODE){this.index++;let e=this.gobbleBinaryOp();if("=>"===e){let r=this.gobbleBinaryExpression();r||this.throwError("Expected expression after "+e),t.node={type:iS,params:null,body:r};return}}this.index=r}}),e.hooks.add("after-expression",function(t){!function t(r){r&&(Object.values(r).forEach(e=>{e&&"object"==typeof e&&t(e)}),"=>"===r.operator&&(r.type=iS,r.params=r.left?[r.left]:null,r.body=r.right,r.params&&r.params[0].type===e.SEQUENCE_EXP&&(r.params=r.params[0].expressions),delete r.left,delete r.right,delete r.operator))}(t.node)})}}),ix.plugins.register({name:"new",init(e){e.addUnaryOp("new"),e.hooks.add("after-token",function(t){let r=t.node;if(r&&"new"===r.operator){r.argument&&[e.CALL_EXP,e.MEMBER_EXP].includes(r.argument.type)||this.throwError("Expected new function()"),t.node=r.argument;let n=t.node;for(;n.type===e.MEMBER_EXP||n.type===e.CALL_EXP&&n.callee.type===e.MEMBER_EXP;)n=n.type===e.MEMBER_EXP?n.object:n.callee.object;n.type="NewExpression"}})}}),ix.plugins.register({name:"numbers",init(e){function t(e){return"x"===e||"X"===e?(this.index+=2,[[48,57],[65,70],[97,102]]):"b"===e||"B"===e?(this.index+=2,[[48,49]]):"o"===e||"O"===e||e>="0"&&e<="7"?(this.index+=e<="7"?1:2,[[48,55]]):null}function r(t){let r=this.index,n="",a=()=>{for(;e.isDecimalDigit(this.code)||95===this.code;)95===this.code?this.index++:n+=this.expr.charAt(this.index++)};a(),this.code===e.PERIOD_CODE&&(n+=this.expr.charAt(this.index++),a());let o=this.char;("e"===o||"E"===o)&&(n+=this.expr.charAt(this.index++),("+"===(o=this.char)||"-"===o)&&(n+=this.expr.charAt(this.index++)),a(),e.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+n+this.char+")"));let i=this.code;if(e.isIdentifierStart(i))this.throwError("Variable names cannot start with a number ("+n+this.char+")");else if(i===e.PERIOD_CODE){n.length>1&&this.throwError(`Unexpected period ${JSON.stringify({chCode:i,number:n},null,2)}`),this.index=r;return}t.node={type:e.LITERAL,value:parseFloat(n),raw:this.expr.substring(r,this.index)}}e.hooks.add("gobble-token",function(n){if(48===this.code){var a,o,i;let s=this.index,l=this.expr.charAt(this.index+1),u=t.call(this,l);if(!u)return;let c="";for(;a=this.code,o=u,95===a||o.some(([e,t])=>a>=e&&a<=t);)95===this.code?this.index++:c+=this.expr.charAt(this.index++);if(e.isIdentifierPart(this.code)){if(e.isDecimalDigit(this.code)&&e.isDecimalDigit(l.charCodeAt(0))){this.index=s+1,r.call(this,n);return}this.throwError("unexpected char within number")}n.node={type:e.LITERAL,value:parseInt(c,"x"===(i=l)||"X"===i?16:"b"===i||"B"===i?2:8),raw:this.expr.substring(s,this.index)}}else(e.isDecimalDigit(this.code)||this.code===e.PERIOD_CODE)&&r.call(this,n)})}}),ix.plugins.register({name:"regex",init(e){e.hooks.add("gobble-token",function(t){if(47===this.code){let r=++this.index,n=!1;for(;this.index<this.expr.length;){if(47===this.code&&!n){let n,a=this.expr.slice(r,this.index),o="";for(;++this.index<this.expr.length;){let e=this.code;if(e>=97&&e<=122||e>=65&&e<=90||e>=48&&e<=57)o+=this.char;else break}try{n=new RegExp(a,o)}catch(e){this.throwError(e.message)}return t.node={type:e.LITERAL,value:n,raw:this.expr.slice(r-1,this.index)},t.node=this.gobbleTokenProperty(t.node),t.node}this.code===e.OBRACK_CODE?n=!0:n&&this.code===e.CBRACK_CODE&&(n=!1),this.index+=92===this.code?2:1}this.throwError("Unclosed Regex")}})}}),ix.plugins.register({name:"ternary",init(e){e.hooks.add("after-expression",function(t){if(t.node&&this.code===e.QUMARK_CODE){this.index++;let r=t.node,n=this.gobbleExpression();if(n||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===e.COLON_CODE){this.index++;let a=this.gobbleExpression();if(a||this.throwError("Expected expression"),t.node={type:"ConditionalExpression",test:r,consequent:n,alternate:a},r.operator&&e.binary_ops[r.operator]<=.9){let n=r;for(;n.right.operator&&e.binary_ops[n.right.operator]<=.9;)n=n.right;t.node.test=n.right,n.right=t.node,t.node=r}}else this.throwError("Expected :")}})}}),ix.plugins.register({name:"jsepTemplateLiteral",init(e){function t(e,r=!0){if(96===this.code){let t={type:"TemplateLiteral",quasis:[],expressions:[]},n="",a="",o=!1,i=this.expr.length,s=()=>t.quasis.push({type:"TemplateElement",value:{raw:a,cooked:n},tail:o});for(;this.index<i;){let i=this.expr.charAt(++this.index);if("`"===i)return this.index+=1,o=!0,s(),e.node=t,r&&(e.node=this.gobbleTokenProperty(e.node)),e.node;if("$"===i&&"{"===this.expr.charAt(this.index+1))this.index+=2,s(),a="",n="",t.expressions.push(...this.gobbleExpressions(125)),125!==this.code&&this.throwError("unclosed ${");else if("\\"===i)switch(a+=i,i=this.expr.charAt(++this.index),a+=i,i){case"n":n+="\n";break;case"r":n+="\r";break;case"t":n+=" ";break;case"b":n+="\b";break;case"f":n+="\f";break;case"v":n+="\v";break;default:n+=i}else n+=i,a+=i}this.throwError("Unclosed `")}}e.hooks.add("gobble-token",t),e.hooks.add("after-token",function(r){if((r.node.type===e.IDENTIFIER||r.node.type===e.MEMBER_EXP)&&96===this.code)return r.node={type:"TaggedTemplateExpression",tag:r.node,quasi:t.bind(this)(r,!1)},r.node=this.gobbleTokenProperty(r.node),r.node})}}),ix.addBinaryOp("in",7),ix.addBinaryOp("??",1);let iz=Symbol("optional chain short-circuited");function iK(e,t){switch(e.type){case"MemberExpression":return iW(e,t);case"CallExpression":return iV(e,t);default:return iB(e,t)}}function iG(e){return e===iz?void 0:e}function iZ(e){return function(t){return null===t?null:iB(t,e)}}function iY(e){if("__proto__"===e||"prototype"===e||"constructor"===e)throw{type:"Illegal property access",message:`Cannot access the ${e} property of objects`}}let iq=new Set(["toString","valueOf","hasOwnProperty"]);function iJ(e,t){try{return iU(e,t)}catch{return"<computed>"}}function iX(e){return e?"MemberExpression"===e.type?e.property?.name:e.name:null}function iQ(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:{...iP},boundNames:new Set,variables:new Set};return i0("string"==typeof e?ix(e):e,t),[...t.variables]}function i0(e,t){switch(e.type){case"UnaryExpression":return r=e,n=t,void i0(r.argument,n);case"BinaryExpression":return a=e,o=t,void(i0(a.left,o),i0(a.right,o));case"ConditionalExpression":return i=e,s=t,void(i0(i.consequent,s),i0(i.test,s),i0(i.alternate,s));case"CallExpression":return l=e,u=t,void(i0(l.callee,u),l.arguments?.map(i1(u)));case"ArrowFunctionExpression":var r,n,a,o,i,s,l,u,c,d,m,p,f,h,g,y,v,b,w,E,D=e,x=t;let _=new Set(x.boundNames);for(let e of D.params??[])e?.type==="Identifier"&&_.add(e.name);i0(D.body,{...x,boundNames:_});return;case"MemberExpression":return c=e,d=t,void(i0(c.object,d),c.computed&&i0(c.property,d));case"ArrayExpression":return m=e,p=t,void m.elements?.map(i1(p));case"SequenceExpression":return f=e,h=t,void f.expressions?.map(i1(h));case"NewExpression":return g=e,y=t,void g.arguments?.map(i1(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(i1(E)),w.quasis?.map(i1(E)));default:throw`Expression evaluator does not support expression of type '${e.type}'`}}function i1(e){return function(t){return null===t?null:i0(t,e)}}let i4=W("feature-flags",{flags:function(){let e={};for(let t of Object.keys(localStorage))if(t.startsWith("openmrs:feature-flag:")){let r=t.replace("openmrs:feature-flag:",""),n=JSON.parse(localStorage.getItem(`openmrs:feature-flag-meta:${r}`)||"{}");e[r]={enabled:"true"===localStorage.getItem(t),...n}}return e}()});function i2(e,t,r){i4.setState(n=>({flags:{...n.flags,[e]:{enabled:n.flags[e]?.enabled??!1,label:t,description:r}}}))}function i3(){let e=i4.getState().flags;Object.keys(localStorage).filter(e=>e.startsWith("openmrs:feature-flag:")).forEach(t=>{let r=t.replace("openmrs:feature-flag:","");e[r]||(localStorage.removeItem(t),localStorage.removeItem(`openmrs:feature-flag-meta:${r}`))})}function i6(e){return i4.getState().flags[e].enabled}function i5(e,t){i4.subscribe(r=>{t(r.flags[e].enabled)})}function i9(e,t){i4.setState(r=>({flags:{...r.flags,[e]:{...r.flags[e],enabled:t}}}))}i4.subscribe(e=>{for(let[t,r]of Object.entries(e.flags))localStorage.setItem(`openmrs:feature-flag:${t}`,r.enabled.toString()),localStorage.setItem(`openmrs:feature-flag-meta:${t}`,JSON.stringify({label:r.label,description:r.description}))});var i8=e6(function(e,t,r){eq(e,t,r)});let i7=B("extensionsInternal",{slots:{},extensions:{}}),se=B("extensionRenderings",{renderings:new Map}),st=()=>W("extensionsInternal",{slots:{},extensions:{}}),sr=()=>W("extensionRenderings",{renderings:new Map});function sn(e){let t=i7.getState(),r=e(t);r!==t&&i7.setState(r)}let sa=null,so=null;function si(){let e=se.getState();return sa&&e===so||(sa=new Map(e.renderings),so=e,function(e){for(let t of(sg.clear(),e.values()))sv(t,1);sy=!0}(sa)),sa}function ss(e){so={renderings:e},se.setState(so,!0)}function sl(e){let t=si();t.has(e.renderingId)||(t.set(e.renderingId,e),sv(e,1),ss(t))}function su(e){let t=si(),r=t.get(e);r&&(t.delete(e),sv(r,-1),ss(t))}let sc=()=>W("extensions",{slots:{}}),sd=0,sm=new Set;function sp(e){sd++;try{return e()}finally{if(0==--sd&&sm.size>0){let e=Array.from(sm);for(let t of(sm.clear(),e))sf(t)}}}function sf(e){try{e()}catch(t){console.error(`The extension system's '${e.name}' recomputation failed`,t)}}function sh(e){sd>0?sm.add(e):sf(e)}let sg=new Map,sy=!1;function sv(e,t){let r=JSON.stringify([e.slotName,e.extensionId,e.slotModuleName,e.extensionModuleName]),n=sg.get(r);if(!n){if(t<0)return;sg.set(r,{count:1,record:{slotModuleName:e.slotModuleName,extensionModuleName:e.extensionModuleName,slotName:e.slotName,extensionId:e.extensionId}}),sy=!0;return}n.count+=t,n.count<1&&(sg.delete(r),sy=!0)}function sb(){var e,t;if(si(),!sy)return;sy=!1;let r=Array.from(sg.values(),({record:e})=>e);r.sort(sw),e=re.getState().mountedExtensions,t=r,e.length===t.length&&e.every((e,r)=>0===sw(e,t[r]))||re.setState({mountedExtensions:r})}function sw(e,t){return sE(e.slotName,t.slotName)||sE(e.extensionId,t.extensionId)||sE(e.slotModuleName,t.slotModuleName)||sE(e.extensionModuleName,t.extensionModuleName)}function sE(e,t){return e===t?0:e<t?-1:1}sb(),se.subscribe(()=>sh(sb));let sD=st(),sx=sc(),s_=rr(),sS=ro(),sC=new Set,sP=!1;function sk(e){if(null===e)sC=null;else if(null!==sC)for(let t of e)sC.add(t);sh(sR)}function sR(){if(!sP){sP=!0;try{for(let e=1;;e++){let t=sC;if(null!==t&&0===t.size)return;sC=new Set;try{!function(e,t,r,n,a,o=null){let i=sx.getState().slots,s={},l=!1,u=Object.entries(n.flags).filter(([,{enabled:e}])=>e).map(([e])=>e);for(let[n,c]of Object.entries(e.slots)){let d=i[n];if(d&&o&&!o.has(n)){s[n]=d;continue}let{config:m}=ra(t,c.name),p=function(e,t,r,n,a,o){let i=function(e,t){let r=e.add||[],n=e.remove||[],a=e.order||[],{extensions:o}=sD.getState(),i=new Set(n),s=[...t,...r].filter(e=>!i.has(e)),l=sF(a),u=sF(t),c=new Map(s.map(e=>[e,function(e,t,r,n){let a=t.get(e);if(void 0!==a)return a;{if(void 0!==r)return 1e3+r;let t=n.get(e);return void 0!==t?2e3+t:3e3}}(e,l,o[sO(e)]?.order,u)]));return s.sort((e,t)=>c.get(e)-c.get(t))}(r,t.slots[e].attachedIds),s=[];for(let l of i){let{config:i}=ri(n,e,l),u=rs(r,e,l),c=u?i8({},i,u):i,d=sO(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||!oe(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}(n,e,m,r,u,a.session);d&&d.moduleName===c.moduleName&&(0,e9.A)(d.candidateExtensions,p)?s[n]=d:(s[n]={moduleName:c.moduleName,candidateExtensions:p},l=!0)}(l||Object.keys(i).length!==Object.keys(s).length)&&sx.setState({slots:s})}(sD.getState(),s_.getState(),sS.getState(),i4.getState(),a1.getState(),t)}catch(e){throw sC=null===t||null===sC?null:new Set([...t,...sC]),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{sP=!1}}}function sT(e,t){let r=new Set;for(let n of Object.keys(e))e[n]!==t[n]&&r.add(n);for(let n of Object.keys(t))n in e||r.add(n);return r}function sN(e,t){return{moduleName:t,name:e,attachedIds:[]}}function sO(e){let[t]=e.split("#");return t}function s$(e,t){let r=sO(t);return e.extensions[r]}function sA(e){return s$(sD.getState(),e)}sD.subscribe((e,t)=>{sk(e.extensions!==t.extensions?null:sT(e.slots,t.slots))}),s_.subscribe((e,t)=>{sk(sT(e.slots,t.slots))}),sS.subscribe((e,t)=>{sk(sT(e.configs,t.configs))}),i4.subscribe(()=>sk(null)),a1.subscribe(()=>sk(null)),sk(null);let sI=e=>sn(t=>({...t,extensions:{...t.extensions,[e.name]:{...e}}}));function sj(e,t){sn(r=>{let n=r.slots[e];return n?{...r,slots:{...r.slots,[e]:{...n,attachedIds:[...n.attachedIds,t]}}}:{...r,slots:{...r.slots,[e]:{...sN(e),attachedIds:[t]}}}})}function sM(e,t){sn(r=>{let n=r.slots[e];return n&&n.attachedIds.includes(t)?{...r,slots:{...r.slots,[e]:{...n,attachedIds:n.attachedIds.filter(e=>e!==t)}}}:r})}function sL(e){sn(t=>{let r=t.slots[e];return r?{...t,slots:{...t.slots,[e]:{...r,attachedIds:[]}}}:t})}function sF(e){let t=new Map;return e.forEach((e,r)=>{t.has(e)||t.set(e,r)}),t}function sB(e,t){return function(e,t,r=null,n){let a;return e.filter(e=>{let o=e.displayConditionExpression;if("string"!=typeof o||0===o.trim().length)return!0;a??(a=t&&"object"==typeof t?{session:r,...t}:{session:r});try{return!!iT(o,a)}catch(t){return console.error(`Error while evaluating expression '${o}' for ${e.id}`+(n?` in ${n}`:""),t),!1}})}(sU(e),t,a1.getState().session,e)}function sU(e){return sx.getState().slots[e]?.candidateExtensions??[]}let sV=(e,t)=>sD.setState(r=>{let n=r.slots[t]?.moduleName;if(n&&n!=e)return console.warn(`An extension slot with the name '${t}' already exists. Refusing to register the same slot name twice (in "registerExtensionSlot"). The existing one is from module ${n}.`),r;if(n&&n==e)return r;if(r.slots[t])return{...r,slots:{...r.slots,[t]:{...r.slots[t],moduleName:e}}};let a=sN(t,e);return{...r,slots:{...r.slots,[t]:{...a}}}}),sW=()=>{sC=null,sn(()=>({slots:{},extensions:{}})),sr().setState({renderings:new Map}),sx.setState({slots:{}})},sH=B("left-nav",{slotName:null,basePath:window.spaBase,mode:"normal"});function sz({name:e,basePath:t,mode:r,componentContext:n,state:a}){sH.setState({slotName:e,basePath:t,mode:r??"normal",componentContext:n,state:a})}function sK(e){sH.getState().slotName===e&&sH.setState(sH.getInitialState(),!0)}let sG=B("modalRegistry",{modals:{}});function sZ(e){sG.setState(t=>(t.modals[e.name]=e,t))}function sY(e){let t=sG.getState().modals[e];if(!t){let r=sA(e);r&&(t={name:e,load:r.load,moduleName:r.moduleName},console.warn(`Modal ${e} was registered as an extension. This is deprecated and will be removed in the future. Please register it in the "modals" section of routes.json instead of the "extensions" section.`),sZ(t))}return t}let sq=B("workspace2",{registeredGroupsByName:{},registeredWindowsByName:{},registeredWorkspacesByName:{},openedGroup:null,openedWindows:[],isMostRecentlyOpenedWindowHidden:!1});function sJ(e){let{registeredWorkspacesByName:t,registeredWindowsByName:r}=sq.getState(),n=t[e];if(n){let t=r[n.window];if(t)return t;throw Error(`No workspace window found with name: ${n.window} for workspace: ${e}`)}throw Error(`No workspace found with name: ${e}`)}function sX(e){let{registeredGroupsByName:t,registeredWindowsByName:r}=sq.getState(),n=r[e];if(n){let r=t[n.group];if(r)return r;throw Error(`No workspace group found with name: ${n.group} for window: ${e}`)}throw Error(`No workspace window found with name: ${e}`)}function sQ(e){let{openedWindows:t}=sq.getState();return t.findIndex(t=>t.openedWorkspaces.find(t=>t.workspaceName===e))}function s0(e,t){if(0==t.length)return;let{registeredGroupsByName:r}=sq.getState(),n={...r};for(let r of t){if(n[r.name])throw Error(`Cannot register workspace group ${r.name} more than once`);n[r.name]={...r,moduleName:e}}sq.setState({registeredGroupsByName:n})}function s1(e,t){if(0==t.length)return;let{registeredWindowsByName:r}=sq.getState(),n={...r};for(let r of t){if(n[r.name])throw Error(`Cannot register workspace window ${r.name} more than once`);let t={...r,moduleName:e};n[r.name]=t}sq.setState({registeredWindowsByName:n})}function s4(e,t){if(0==t.length)return;let{registeredWorkspacesByName:r}=sq.getState(),n={...r};for(let r of t){if(n[r.name])throw Error(`Cannot register workspace ${r.name} more than once`);let t={...r,moduleName:e};n[r.name]=t}sq.setState({registeredWorkspacesByName:n})}let s2=0,s3=null,s6={bootstrap:15e3,mount:15e3,unmount:15e3};function s5(e,t){if(e.timeouts)return e;let r=e.name??"parcel",n=Object.fromEntries(Object.keys(s6).filter(t=>e[t]).map(n=>{var a,o;let i,s;return[n,(a=e[n],o=s6[n],i=Array.isArray(a)?a:[a],s=e=>i.reduce((t,a,o)=>t.then(()=>{let t=a(e);return"function"==typeof t?.then&&"function"==typeof t?.catch?t:Promise.reject(Error(`Lifecycle function ${n} at array index ${o} for parcel ${r} did not return a promise`))}),Promise.resolve(void 0)),e=>{let a,i=new Promise((e,t)=>{a=setTimeout(()=>t(Error(`Lifecycle function ${n} for parcel ${r} did not settle within ${o}ms`)),o)});return Promise.race([s(e),i]).finally(()=>clearTimeout(a)).then(e=>(t(n,!1),e),e=>{throw t(n,!0),e})})]}));return{...e,...n}}async function s9(e,t){var r,n;let a,o,i,s,l,u=await (s3??(s3=new Promise((e,t)=>{nz({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),nz))),s3),c={...t},d=(a=c,o=!1,{retarget:e=>a={...e},release:i=()=>(function(e){for(let t of Object.keys(e))delete e[t]})(a),onSettled(e,t){switch(e){case"bootstrap":t&&i();return;case"mount":o||(o=t);return;case"unmount":(t||o)&&i();return}}});return n=u((r=d.onSettled,"function"==typeof e?()=>e().then(e=>s5(e,r)):s5(e,r)),c),s=e=>t=>e.call(n,d.retarget(t)).catch(e=>{throw"SKIP_BECAUSE_BROKEN"===n.getStatus()&&d.release(),e}),l=n.update&&s(n.update),Object.defineProperty(n,"update",{configurable:!0,enumerable:!0,get:()=>l,set:e=>{l=e&&s(e)}})}function s8(){return s7}function s7(e,t){let r,n=s9(e,t).then(e=>r=e);return{mount:()=>n.then(e=>e.mount()),unmount:()=>n.then(e=>e.unmount()),update:e=>n.then(t=>t.update?.(e)),getStatus:()=>r?.getStatus()??"LOADING_SOURCE_CODE",get loadPromise(){return n.then(e=>e.loadPromise)},get bootstrapPromise(){return n.then(e=>e.bootstrapPromise)},get mountPromise(){return n.then(e=>e.mountPromise)},get unmountPromise(){return n.then(e=>e.unmountPromise)}}}async function le(e,t,r,n,a=e=>e,o={}){let i=sO(n),s=sA(n),l=null;if(e){let u;if(!s)throw Error(`Couldn't find extension '${i}' to attach to '${t}'`);let{meta:c,moduleName:d,load:m}=s,p=s2++,f=`${t}/${n}-${p}`;e.dataset.extensionRenderingId=f;let h=e=>{try{su(f)}catch(t){console.error(e,t)}};try{sl({renderingId:f,extensionName:i,extensionModuleName:d,extensionId:n,slotName:t,slotModuleName:r})}catch(e){throw h(`Recomputing configuration after registering '${n}' failed also failed`),e}try{u=await m()}catch(e){throw h(`Recomputing configuration after '${n}' failed to load also failed`),e}try{l=await s9(a({...u,name:`${t}/${i}-${p}`}),{...o,_meta:c,_extensionContext:{extensionId:n,extensionSlotName:t,extensionSlotModuleName:r,extensionModuleName:d,extensionMeta:c},domElement:e})}catch(e){throw h(`Recomputing configuration after '${n}' failed to mount also failed`),e}l.mountPromise.then(void 0,e=>{console.error(`Extension '${n}' in slot '${t}' failed to mount`,e),h(`Recomputing configuration after '${n}' failed to mount also failed`)}),l.unmountPromise.then(()=>h(`Recomputing configuration after unmounting '${n}' failed`),e=>{console.error(`Extension '${n}' in slot '${t}' failed to unmount`,e),h(`Recomputing configuration after '${n}' failed to unmount also failed`)})}else console.warn(`Tried to render ${n} into ${t} but no DOM element was available.`);return l}var lt=r(2491),lr=r.n(lt);let ln=(0,lt.createContext)({moduleName:"",featureName:""});function la({to:e,templateParams:t,onBeforeNavigate:r,children:n,...a}){return(0,lt.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}`)},[]),lr().createElement("a",{onClick:n=>{0===n.button&&!n.ctrlKey&&!n.shiftKey&&!n.altKey&&!n.metaKey&&(n.preventDefault(),r?.(n),aF({to:e,templateParams:t})),0===n.button&&(n.ctrlKey||n.metaKey)&&r?.(n),0===n.button&&n.shiftKey&&r?.(n),1===n.button&&r?.(n)},href:aM(e,t),...a},n)}let lo=({state:e,children:t,...r})=>{let{extension:n}=(0,lt.useContext)(ln),a=(0,lt.useRef)(null),o=(0,lt.useRef)(Promise.resolve()),i=(0,lt.useRef)(!1),s=(0,lt.useRef)(!1),l=(0,lt.useRef)(e),u=(0,lt.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,lt.useCallback)((e,t)=>{e.update&&"UNMOUNTING"!==e.getStatus()&&(o.current=Promise.all([e.mountPromise,o.current]).then(()=>{if(a.current?.getStatus()==="MOUNTED"&&a.current.update)return a.current.update({...t})}).catch(e=>{let t=a.current?.getStatus();"UNMOUNTING"!==t&&"NOT_MOUNTED"!==t&&"UNLOADING"!==t&&console.error(`The extension '${n?.extensionId}' failed to update`,e)}))},[]),d=(0,lt.useCallback)(t=>{t&&!a.current&&!s.current&&n?.extensionSlotName&&n.extensionSlotModuleName&&(s.current=!0,le(t,n.extensionSlotName,n.extensionSlotModuleName,n.extensionId,void 0,e).then(t=>{(s.current=!1,a.current=t,i.current)?u(t):t&&l.current!==e&&c(t,l.current)},()=>{s.current=!1}))},[]);return(0,lt.useEffect)(()=>(i.current=!1,()=>{i.current=!0,u(a.current)}),[]),(0,lt.useEffect)(()=>{l.current=e,a.current&&c(a.current,e)},[e]),n?lr().createElement("div",{ref:d,"data-extension-id":n?.extensionId,style:{position:"relative"},...r}):null};function li(e){let t=(0,lt.useRef)(e);return T(t.current,e)||(t.current=e),t.current}function ls(e,t){"function"==typeof t&&(t=t(e));let r={};for(let[n,a]of Object.entries(t)){let t=function(...t){e.setState(e=>a(e,...t))};r[n]=t}return r}let ll=e=>e;function lu(e,t=ll,r){let n=(0,lt.useCallback)(t=>e.subscribe(t),[e]),a=(0,lt.useCallback)(()=>t(e.getState()),[e,t]),o=(0,lt.useSyncExternalStore)(n,a,a),i=(0,lt.useMemo)(()=>r?ls(e,r):null,[e,r]);return(0,lt.useMemo)(()=>i?{...o,...i}:o,[o,i])}function lc(e,t){return lu(e,ll,t)}function ld(e){return function(t){let r=(0,lt.useCallback)(t=>e.subscribe(t),[]),n=(0,lt.useCallback)(()=>e.getState(),[]),a=(0,lt.useSyncExternalStore)(r,n,n),o=(0,lt.useMemo)(()=>t?ls(e,t):null,[t]);return(0,lt.useMemo)(()=>o?{...a,...o}:a,[a,o])}}let lm=[];Object.freeze(lm);let lp={candidateExtensions:lm};Object.freeze(lp);let lf=e=>{let t=(0,lt.useCallback)(t=>t.slots?.[e]??lp,[e]);return lu(sc(),t)},lh=e=>e.session;function lg(e,t){let{candidateExtensions:r}=lf(e),n=lu(a1,lh),a=li(t);return(0,lt.useMemo)(()=>sB(e,a),[e,a,n,r])}function ly(e,t){let{moduleName:r}=(0,lt.useContext)(ln);if(!r)throw Error("ComponentContext has not been provided. This should come from @openmrs/esm-react-utils.");return(0,lt.useEffect)(()=>{sV(r,e)},[r,e]),{extensions:lg(e,t),extensionSlotName:e,extensionSlotModuleName:r}}function lv(e){return e}function lb({name:e,extensionSlotName:t,select:r=lv,children:n,state:a,style:o,...i}){if(n&&a)throw Error("Both children and state have been provided. If children are provided, the state must be passed as a prop to the `Extension` component.");let s=e??t,l=(0,lt.useRef)(null),{extensions:u,extensionSlotModuleName:c}=ly(s,a),d=(0,lt.useMemo)(()=>r(u),[r,u]),m=(0,lt.useMemo)(()=>{if("function"==typeof n&&!lr().isValidElement(n))return d.map(e=>n(e,a))},[n,d]);return lr().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)=>lr().createElement(ln.Provider,{key:e.id,value:{moduleName:c,featureName:"",extension:{extensionId:e.id,extensionSlotName:s,extensionSlotModuleName:c,extensionMeta:e.meta}}},m?.[t]??("function"!=typeof n?n:null)??lr().createElement(lo,{state:a}))))}var lw=r(5873);function lE(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function lD(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?lE(Object(r),!0).forEach(function(t){var n,a,o;n=e,a=t,o=r[t],a in n?Object.defineProperty(n,a,{value:o,enumerable:!0,configurable:!0,writable:!0}):n[a]=o}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):lE(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function lx(e){return(lx="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 l_(e){return(l_="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 lS(e,t){var r;if("function"!=typeof(r=t.domElement?function(){return t.domElement}:t.domElementGetter?t.domElementGetter:e.domElementGetter?e.domElementGetter:function(e){var t=e.appName||e.name;if(!t)throw Error("single-spa's dom-element-getter-helpers was not given an application name as a prop, so it can't make a unique dom element container for the react application");var r="single-spa-application:".concat(t);return function(){var e=document.getElementById(r);return e||((e=document.createElement("div")).id=r,document.body.appendChild(e)),e}}(t)))throw Error("single-spa's dom-element-getter-helpers was given an invalid domElementGetter for application or parcel '".concat(t.name,"'. Expected a function, received ").concat(l_(r)));return function(){var e=r(t);if(!(e instanceof HTMLElement))throw Error("single-spa's dom-element-getter-helpers: domElementGetter returned an invalid dom element for application or parcel '".concat(t.name,"'. Expected HTMLElement, received ").concat(l_(e)));return e}}var lC=null;try{lC=require("react").createContext()}catch(e){}var lP={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 lk(e,t){return e.rootComponent?Promise.resolve():e.loadRootComponent(t).then(function(t){e.rootComponent=t})}function lR(e,t){return new Promise(function(r,n){e.suppressComponentDidCatchWarning||!function(e){if(!(e&&"string"==typeof e.version&&e.version.indexOf(".")>=0))return!1;var t=e.version.slice(0,e.version.indexOf("."));try{return Number(t)>=16}catch(e){return!1}}(e.React)||e.errorBoundary||e.errorBoundaryClass||(e.rootComponent.prototype?e.rootComponent.prototype.componentDidCatch||console.warn("single-spa-react: ".concat(t.name||t.appName||t.childAppName,"'s rootComponent should implement componentDidCatch to avoid accidentally unmounting the entire single-spa application.")):console.warn("single-spa-react: ".concat(t.name||t.appName||t.childAppName,"'s rootComponent does not implement an error boundary. If using a functional component, consider providing an opts.errorBoundary to singleSpaReact(opts).")));var a,o=l$(e,t,function(){r(this)}),i=lS(e,t)(),s=function(e){var t=e.reactDom,r=e.renderType,n=e.elementToRender,a=e.domElement,o=t[r];if("function"!=typeof o)throw Error('renderType "'.concat(r,'" did not return a function.'));switch(r){case"createRoot":case"unstable_createRoot":case"createBlockingRoot":case"unstable_createBlockingRoot":var i=o(a);return i.render(n),i;case"hydrateRoot":return o(a,n);default:return o(n,a),null}}({elementToRender:o,domElement:i,reactDom:lO(e),renderType:"function"==typeof(a=e).renderType?a.renderType():a.renderType});e.domElements[t.name]=i,e.renderResults[t.name]=s})}function lT(e,t){return new Promise(function(r){e.unmountResolves[t.name]=r;var n=e.renderResults[t.name];n&&n.unmount?n.unmount():lO(e).unmountComponentAtNode(e.domElements[t.name]),delete e.domElements[t.name],delete e.renderResults[t.name]})}function lN(e,t){return new Promise(function(r){e.updateResolves[t.name]||(e.updateResolves[t.name]=[]),e.updateResolves[t.name].push(r);var n=l$(e,t,null),a=e.renderResults[t.name];if(a&&a.render)a.render(n);else{var o=lS(e,t)();lO(e).render(n,o)}})}function lO(e){return e.ReactDOMClient||e.ReactDOM}function l$(e,t,r){var n=e.React.createElement(e.rootComponent,t),a=lC?e.React.createElement(lC.Provider,{value:t},n):n;return(e.errorBoundary||t.errorBoundary||e.errorBoundaryClass||t.errorBoundaryClass)&&(e.errorBoundaryClass=e.errorBoundaryClass||t.errorBoundaryClass||function(e,t){function r(t){e.React.Component.apply(this,arguments),this.state={caughtError:null,caughtErrorInfo:null},r.displayName="SingleSpaReactErrorBoundary(".concat(t.name,")")}return r.prototype=Object.create(e.React.Component.prototype),r.prototype.render=function(){return this.state.caughtError?(e.errorBoundary||t.errorBoundary)(this.state.caughtError,this.state.caughtErrorInfo,this.props):this.props.children},r.prototype.componentDidCatch=function(e,t){this.setState({caughtError:e,caughtErrorInfo:t})},r}(e,t),a=e.React.createElement(e.errorBoundaryClass,t,a)),a=e.React.createElement(e.SingleSpaRoot,lD(lD({},t),{},{mountFinished:r,updateFinished:function(){e.updateResolves[t.name]&&(e.updateResolves[t.name].forEach(function(e){return e()}),delete e.updateResolves[t.name])},unmountFinished:function(){e.unmountResolves[t.name]&&(e.unmountResolves[t.name](),delete e.unmountResolves[t.name])}}),a)}var lA=r(4011),lI=r(5327),lj=r.n(lI),lM=r(3780);let lL={strictMode:!0,throwErrorsToConsole:!0,disableTranslations:!1},lF=new Map;(0,lM.initCache)(lF);let lB={errorRetryCount:3,fetcher:aQ,focusThrottleInterval:18e5,revalidateIfStale:!0,revalidateOnFocus:!1,revalidateOnReconnect:!1,refreshInterval:0,shouldRetryOnError:e=>{if(e instanceof a0){let t=e.response.status;return!!(t>=500)||401===t||403===t||429===t}return!0},provider:()=>lF};function lU(e){if("object"!=typeof e||"string"!=typeof e.featureName||"string"!=typeof e.moduleName)throw Error("Invalid options");let t=Object.assign({},lL,e),r={...lB,...t.swrConfig};return function(e){var n,a,o,i,s;return o=a=class extends(n=lr().Component){componentDidCatch(e,r){r&&r.componentStack&&(e.extra=Object.assign(e.extra||{},{componentStack:r.componentStack})),t.throwErrorsToConsole&&setTimeout(()=>{throw e}),this.setState({caughtError:e,caughtErrorInfo:r})}render(){if(this.state.caughtError)return lr().createElement("div",null,"An error has occurred. Please try reloading the page.");{let n=lr().createElement(lt.Suspense,{fallback:null},lr().createElement(lI.SWRConfig,{value:r},lr().createElement(ln.Provider,{value:this.state.config},t.disableTranslations?lr().createElement(e,this.props):lr().createElement(lA.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},lr().createElement(e,this.props)))));return t.strictMode&&lr().StrictMode?lr().createElement(lr().StrictMode,null,n):n}}constructor(e){super(e),this.state={caughtError:null,caughtErrorInfo:null,config:{moduleName:t.moduleName,featureName:t.featureName,extension:e._extensionContext}}}},i="displayName",s=`OpenmrsReactComponent(${t.featureName})`,i in o?Object.defineProperty(o,i,{value:s,enumerable:!0,configurable:!0,writable:!0}):o[i]=s,a}}function lV(e,t){return function(e){if("object"!==lx(e))throw Error("single-spa-react requires a configuration object");var t,r=lD(lD({},lP),e);if(!r.React)throw Error("single-spa-react must be passed opts.React");if(!r.ReactDOM&&!r.ReactDOMClient)throw Error("single-spa-react must be passed opts.ReactDOM or opts.ReactDOMClient");if(r.renderType||(null!=(t=r.ReactDOMClient)&&t.createRoot?r.renderType="createRoot":r.renderType="render"),!r.rootComponent&&!r.loadRootComponent)throw Error("single-spa-react must be passed opts.rootComponent or opts.loadRootComponent");if(r.errorBoundary&&"function"!=typeof r.errorBoundary)throw Error("The errorBoundary opt for single-spa-react must either be omitted or be a function that returns React elements");!lC&&r.React.createContext&&(lC=r.React.createContext()),r.SingleSpaRoot=function(e){function t(e){t.displayName="SingleSpaRoot(".concat(e.name,")")}return t.prototype=Object.create(e.React.Component.prototype),t.prototype.componentDidMount=function(){setTimeout(this.props.mountFinished)},t.prototype.componentWillUnmount=function(){setTimeout(this.props.unmountFinished)},t.prototype.render=function(){return setTimeout(this.props.updateFinished),this.props.children},t}(r);var n={bootstrap:lk.bind(null,r),mount:lR.bind(null,r),unmount:lT.bind(null,r)};return r.parcelCanUpdate&&(n.update=lN.bind(null,r)),n}({React:lr(),ReactDOMClient:lw,rootComponent:lU(t)(e)})}function lW(e,t){return()=>e().then(({default:e})=>lV(e,t))}function lH(e,t){return()=>Promise.resolve(lV(e,t))}let lz=lW,lK=A()(()=>({}));V("openmrs-app-context",lK);let lG={};function lZ(e,t=e=>e){let r=lK.getState();return e in r?Object.freeze(Object.assign({},t?t(r[e]):r[e])):null}function lY(e,t){lK.setState(r=>(e in r||(r[e]={}),r[e]=t(r[e]),Object.assign({},r)))}function lq(e){return null===e?null:Object.freeze(Object.assign({},e))}let lJ=new Map;function lX(e,t){let r=(0,lt.useRef)(t??{}),n=(0,lt.useRef)(t=>lY(e,t)),a=(0,lt.useRef)(Symbol());return(0,lt.useEffect)(()=>{let r=t??{},n=a.current;return null===lZ(e)?!function(e,t=lG){lK.setState(r=>{if(e in r)throw Error(`Attempted to re-register namespace ${e} in the app context. Each namespace must be unregistered before the name can be registered again.`);return Object.assign({},r,{[e]:t===lG?{}:t})})}(e,r):(console.warn(`Namespace ${e} is already registered in the app context. This is likely a race condition during navigation, but may indicate two components are trying to own the same namespace. Updating the existing context.`),lY(e,()=>r)),lJ.set(e,n),()=>{lJ.get(e)===n&&(lK.setState(t=>(e in t&&delete t[e],t)),lJ.delete(e))}},[e]),(0,lt.useEffect)(()=>{let n=t??{};T(r.current,n)||(lY(e,()=>n),r.current=n)},[t]),n.current}function lQ({namespace:e,value:t}){return lX(e,t),null}let l0=({children:e,value:t,fallback:r})=>t?lr().createElement(lr().Fragment,null,e):r?lr().createElement(lr().Fragment,null,r):null;function l1(){let e=(0,lt.useRef)();return(!e.current||e.current.signal.aborted)&&(e.current=new AbortController),(0,lt.useEffect)(()=>{let t=e.current;return()=>t?.abort()},[]),e.current}function l4(e,t=e=>e??{}){let[r,n]=(0,lt.useState)(()=>{if(l2(e))return;let r=lZ(e);if(null!==r)return t?t(r):r});return(0,lt.useEffect)(()=>{if(l2(e))throw Error(`The namespace supplied to useAppContext must be a non-empty string, but was "${e}".`)},[e]),(0,lt.useEffect)(()=>{var r;let a;return(r=e=>{if(null==e)return void n(void 0);let r=t?t(e):e;n(e=>T(e,r)?e:r)})(lq(a=lZ(e))),lK.subscribe(t=>{let n=e in t?t[e]:null;n!==a&&(a=n,r(lq(n)))})},[e,t]),r}function l2(e){return"string"!=typeof e||0===e.trim().length}function l3(e){let t=lg(e);return(0,lt.useMemo)(()=>t.map(e=>e.id),[t])}function l6(e){return lf(e).candidateExtensions}function l5(e,t,r){let{data:n,error:a,mutate:o,isLoading:i,isValidating:s}=lj()(e?ie(e,t,r):null,aQ);return(0,lt.useMemo)(()=>({isLoading:i,data:n?.data.results??[],error:a,mutate:o,isValidating:s}),[n,a,i,s,o])}function l9(e){(0,lt.useEffect)(()=>{if(e){let e=window.getComputedStyle(document.body).overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=e}}},[e])}let l8={},l7=`No ComponentContext has been provided. This should come from "openmrsComponentDecorator".
|
|
16
16
|
Usually this is already applied when using "getAsyncLifecycle" or "getSyncLifecycle".`;function ue(e,t,r){let n=l8[e];if(n)return n;let a=new Promise(e=>{let n=r(t.getState());if(n)return void e(n);let a=t.subscribe(t=>{let n=r(t);n&&(a(),e(n))})});return l8[e]=a,a.then(()=>{l8[e]===a&&delete l8[e]}),a}function ut(e){let{moduleName:t,extension:r}=(0,lt.useContext)(ln),n=e?.externalModuleName??t;if(!n&&!r)throw Error(l7);let a=function(e){let t=(0,lt.useMemo)(()=>rt(e),[e]),r=function(e){let[t,r]=(0,lt.useState)(()=>{let t=e.getState();return t.loaded&&t.config?t.config:null});return(0,lt.useEffect)(()=>e?.subscribe(e=>{e.loaded&&e.config&&r(e.config)}),[e]),t}(t);if(!r)throw ue(e,t,e=>e.loaded?e.config:null);return r}(n),o=function(e){let t=(0,lt.useMemo)(ro,[]),r=function(e,t){let[r,n]=(0,lt.useState)(t?()=>{let r=ri(e.getState(),t.extensionSlotName,t.extensionId);if(r.loaded&&r.config)return r.config}:null);return(0,lt.useEffect)(()=>{if(t)return e.subscribe(e=>{let a=ri(e,t.extensionSlotName,t.extensionId);a.loaded&&a.config&&!(0,e9.A)(a.config,r)&&n(a.config)})},[e,t,r]),r}(t,e);if(!r&&e)throw ue(`${e.extensionSlotName}-${e.extensionId}`,t,t=>{let r=ri(t,e.extensionSlotName,e.extensionId);return r.loaded?r.config:null});return r||{}}(r);return(0,lt.useMemo)(()=>e?.externalModuleName&&n===e.externalModuleName?{...a}:{...a,...o},[n,e?.externalModuleName,a,o])}let ur=lg;function un(e,t=300){let[r,n]=(0,lt.useState)(e);return(0,lt.useEffect)(()=>{let r=setTimeout(()=>{n(e)},t);return()=>{clearTimeout(r)}},[e,t]),r}var ua=r(9256),uo=r.n(ua);let ui=`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 us(){let e=`${aY}/emrapi/configuration?v=${ui}`,t=uo()(e,aQ);return(0,lt.useMemo)(()=>({emrConfiguration:t.data?.data,isLoadingEmrConfiguration:t.isLoading,mutateEmrConfiguration:t.mutate,errorFetchingEmrConfiguration:t.error}),[t])}function ul(){return(0,lt.useContext)(ln).extension}let uu=ld(st());function uc(e){let t=lg(e);return(0,lt.useMemo)(()=>Object.fromEntries(t.map(e=>[e.name,e.meta])),[t])}let ud=ld(sc());function um(e){let{flags:t}=lu(i4);return t[e]?.enabled??!1}function up(){let[,e]=(0,lt.useState)(0);return(0,lt.useCallback)(()=>{e(e=>e+1)},[])}function uf(e,t,r={}){return ug(e,t,uh,r)}let uh={getPaginatedUrl:(e,t,r)=>{if(!e)return null;{let n=new URL(aX(e.toString()),window.location.toString());return n.searchParams.set("limit",""+t),n.searchParams.set("startIndex",""+r),n.searchParams.set("totalCount","true"),n.toString()}},getNextUrl:e=>{let t=e?.links?.find(e=>"next"==e.rel)?.uri;if(!t)return null;{let e=new URL(t);return e.host=window.location.host,e.protocol=window.location.protocol,e.toString()}},getTotalCount:e=>e?.totalCount??NaN,getCurrentPageSize:e=>e?.results?.length??NaN,getData:e=>e?.results};function ug(e,t,r,n={}){let{getPaginatedUrl:a,getTotalCount:o,getCurrentPageSize:i,getData:s}=r,{immutable:l,swrConfig:u}=n,c=n.fetcher??aQ,[d,m]=(0,lt.useState)(1),p=(0,lt.useRef)(NaN),f=(0,lt.useRef)(NaN),h=(0,lt.useRef)(d),g=(0,lt.useRef)(!1),y=(0,lt.useRef)(!1),v=e?.toString()??"",[b,w]=(0,lt.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,D=(0,lt.useMemo)(()=>a(e,t,E),[e,t,E]),{data:x,..._}=(l?uo():lj())(D,c,u);x?.data&&(p.current=o(x?.data),f.current=i(x?.data),g.current=!0);let S=Math.ceil(p.current/t),C=(0,lt.useCallback)(e=>{if(!Number.isInteger(e)||e<1)return void console.warn(`useServerPagination: ignoring goTo(${e}); page must be a positive integer.`);let r=Math.ceil(p.current/t);!g.current||Number.isNaN(r)||e<=r?(h.current=e,m(e)):console.warn("Invalid attempt to go to out of bounds page: "+e)},[t]);(0,lt.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,x]);let P=(0,lt.useCallback)(()=>{C(h.current+1)},[C]),k=(0,lt.useCallback)(()=>{C(h.current-1)},[C]);return{data:s(x?.data),totalPages:S,totalCount:p.current,currentPage:d,currentPageSize:f.current,paginated:S>1,showNextButton:d<S,showPreviousButton:d>1,goTo:C,goToNext:P,goToPrevious:k,..._}}function uy(e,t,r={}){return ug(e,t,uv(),r)}function uv(){return{getPaginatedUrl:(e,t,r)=>{if(!e)return null;{let n=new URL(aX(e.toString()),window.location.toString());return n.searchParams.set("_count",""+t),n.searchParams.set("_getpagesoffset",""+r),n.toString()}},getNextUrl:e=>{let t=e?.link?.find(e=>"next"==e.relation)?.url;if(!t)return null;{let e=new URL(t);return e.host=window.location.host,e.protocol=window.location.protocol,e.toString()}},getTotalCount:e=>e?.total??NaN,getCurrentPageSize:e=>e?.entry?.length??NaN,getData:e=>e?.entry?.map(e=>e.resource)}}var ub=r(6038),uw=r.n(ub);function uE(e,t={}){return uD(e,uh,t)}function uD(e,t,r={}){let{swrInfiniteConfig:n,immutable:a}=r,{getNextUrl:o,getTotalCount:i,getData:s}=t,l=r.fetcher??aQ,u=(0,lt.useCallback)((r,n)=>0==r?e?.toString()??null:t.getNextUrl(n.data),[e]),{data:c,size:d,setSize:m,...p}=uw()(u,l,{...n,...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 ux(e,t={}){return u_(e,uh,t)}function u_(e,t,r={}){let n=uD(e,t,r),{hasMore:a,error:o,data:i,loadMore:s,isLoading:l,nextUri:u}=n;return((0,lt.useEffect)(()=>{a&&!o&&s()},[a,u]),r.partialData)?n:{...n,data:a||o?void 0:i,isLoading:l||a}}function uS(e,t={}){return u_(e,uv(),t)}function uC(e,t={}){return uD(e,uv(),t)}function uP(){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 uk(){let[e,t]=(0,lt.useState)(uP);return(0,lt.useEffect)(()=>{let e=()=>{t(uP())};return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),e}let uR=e=>"small-desktop"===e||"large-desktop"===e;function uT(e){let t=(0,lt.useContext)(ln);(0,lt.useEffect)(()=>(t&&t.moduleName&&(e.componentContext=t),sz(e),()=>{sK(e.name)}),[t,e])}function uN(){return lu(sH)}let uO=[];function u$(e=null,t=null){let r=new URLSearchParams;e&&r.set("tag",e),t&&r.set("q",t);let n=r.toString(),{data:a}=ux(`${aY}/location${n?"?"+n:""}`,{immutable:!0});return a??uO}function uA(e,t=!0){let r=(0,lt.useRef)(null);return(0,lt.useEffect)(()=>{let n=n=>{t&&r.current&&n.target&&n.target instanceof Node&&(r.current.contains(n.target)||e(n))};return window.addEventListener("mousedown",n),window.addEventListener("touchstart",n),()=>{window.removeEventListener("mousedown",n),window.removeEventListener("touchstart",n)}},[e,t]),r}function uI(e){let t=(0,lt.useRef)();return(0,lt.useEffect)(()=>{let r=new IntersectionObserver(t=>{for(let r of t)if(r.isIntersecting)return void e()},{threshold:1});return t.current&&r.observe(t.current),()=>{t.current&&r.unobserve(t.current)}},[t.current,e]),t}function uj(e,t={}){let{abortController:r,fetchInit:n,url:a,swrConfig:o}=t,i=l1(),s=(0,lt.useMemo)(()=>n?.signal??r?.signal??i.signal,[r?.signal,n?.signal,i.signal]),l=(0,lt.useCallback)(e=>aQ(function(e,t){if(t)return"function"==typeof t?t(e):t;if("string"==typeof e)return e;throw Error(`When using useOpenmrsSWR with a key that is not a string, you must provide a url() function that converts the key to a valid url. The key for this hook is ${e}.`)}(e,a),{...n,signal:s}),[s,n,a]);return lj()(e,l,o)}function uM(e=[],t=10){let[r,n]=(0,lt.useState)(1),a=(0,lt.useMemo)(()=>"number"==typeof t&&t>0?Math.max(1,Math.ceil(e.length/t)):1,[e.length,t]);r>a&&n(a);let o=Math.min(Math.max(1,r),a),i=(0,lt.useMemo)(()=>{let r=(o-1)*t,n=(o+0)*t;return e.slice(r,n)},[e,o,t]),s=(0,lt.useCallback)(e=>{!Number.isInteger(e)||e<1?console.warn(`usePagination: ignoring goTo(${e}); page must be a positive integer.`):n(e)},[]),l=(0,lt.useCallback)(()=>{n(e=>e+1)},[]),u=(0,lt.useCallback)(()=>{n(e=>Math.max(1,e-1))},[]);return(0,lt.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 uL(e,t,r,n){return{pageSizes:(0,lt.useMemo)(()=>{let r=Math.ceil(t/e);return isNaN(r)&&(r=0),[...Array(r).keys()].map(t=>(t+1)*e)},[e,t]),pageItemsCount:(0,lt.useMemo)(()=>e>t?t:e*r>t?e*(r-1)+n:e*r,[e,t,r,n])}}function uF(){let e=/\/patient\/([a-zA-Z0-9\-]+)\/?/.exec(location.pathname);return e&&e[1]}function uB(e){let[t,r]=(0,lt.useState)(e??uF()),{data:n,error:a,isValidating:o}=lj()(t?["patient",t]:null,()=>ia(t,{}));return(0,lt.useEffect)(()=>{let e=()=>{let e=uF();e!==t&&r(e)};return window.addEventListener("single-spa:routing-event",e),()=>window.removeEventListener("single-spa:routing-event",e)},[t]),(0,lt.useMemo)(()=>({isLoading:o&&!a&&!n,patient:n,patientUuid:t,error:a}),[o,a,n,t])}function uU(){let e=`${aY}/metadatamapping/termmapping?v=custom:(metadataUuid)&code=emr.primaryIdentifierType`,{data:t,error:r,isLoading:n}=lj()(e,aQ);return(0,lt.useMemo)(()=>({primaryIdentifierCode:t?.data?.results[0]?.metadataUuid,isLoading:n,error:r}),[t,r,n])}function uV(e){let{extensions:t,extensionSlotModuleName:r}=ly(e);return e?t.map(t=>({state:n})=>lr().createElement(ln.Provider,{value:{moduleName:r,featureName:"",extension:{extensionId:t.id,extensionSlotName:e,extensionSlotModuleName:r,extensionMeta:t.meta}}},lr().createElement(lo,{state:n}))):[]}function uW(){let e=(0,lt.useRef)(),[t,r]=(0,lt.useState)(null),n=null;if(!t){if(i){let e=a5().getState();e.loaded&&(n=e.session)}else i=new Promise(t=>{let r=({loaded:r,session:a})=>{r&&(t(a),n=a,e.current&&(e.current(),e.current=void 0))};r(a5().getState()),n||(e.current=a5().subscribe(r))});if(n)r(n);else throw i}(0,lt.useEffect)(()=>(e.current||(e.current=a5().subscribe(({loaded:e,session:t})=>{e&&(n=t,r(t))})),()=>{e.current&&(e.current(),e.current=void 0)}),[]);let a=t||n;if(!a)if(i)throw console.warn("useSession is in an unexpected state. Attempting to recover."),i;else throw Error("useSession is in an invalid state.");return a}let uH=({privilege:e,fallback:t,children:r})=>{let[n,a]=(0,lt.useState)(null);return((0,lt.useEffect)(()=>{let e=a5(),t=e.subscribe(({loaded:e,session:t})=>{a(e?t?.user??null:null)}),{loaded:r,session:n}=e.getState();return r&&a(n?.user??null),t},[]),n&&oe(e,n))?lr().createElement(lr().Fragment,null,r):t?lr().createElement(lr().Fragment,null,t):null};var uz=r(4274),uK=r.n(uz),uG=r(5602);let uZ=new Map;function uY(){for(let e of Array.from(uZ.values()))e()}let uq={setVisitContext:(e,t)=>null==t?{manuallySetVisitUuid:null}:{manuallySetVisitUuid:t.uuid,patientUuid:t.patient?.uuid}};function uJ(e){let t=(0,lt.useId)();return(0,lt.useEffect)(()=>{if(e)return uZ.set(t,e),()=>{uZ.delete(t)}},[t,e]),{...lc(iy(),uq),mutateVisit:uY}}function uX(e,t=ih){let r=(0,lt.useRef)(void 0),{patientUuid:n,manuallySetVisitUuid:a,setVisitContext:o}=uJ((0,lt.useCallback)(()=>r.current?.(),[])),i=e&&n==e?a:null,s=`?patient=${e}&v=${t}&includeInactive=false`,l=`/${i}?v=${t}`,{data:u,error:c,mutate:d,isValidating:m}=lj()(e?`${aY}/visit${s}`:null,aQ),{data:p,error:f,mutate:h,isValidating:g}=lj()(e&&i?`${aY}/visit${l}`:null,aQ),y=(0,lt.useMemo)(()=>u?.data.results.find(e=>null===e.stopDatetime)??null,[u]),v=(0,lt.useMemo)(()=>i&&p?p.data:null,[p,i]),b=(0,lt.useRef)(null);(0,lt.useEffect)(()=>{!m&&y&&n===e&&null===a&&o(y),g||(b.current&&v&&b.current.uuid===v.uuid&&!b.current.stopDatetime&&v.stopDatetime&&o(null),b.current=v)},[v,a,y,m,g,n]);let w=(0,lt.useCallback)(()=>{d(),h()},[d,h]);(0,lt.useEffect)(()=>{r.current=w},[w]);let E=!!(!u||i&&!p),D=!!(i?f:c);return{error:c||f,mutate:w,isValidating:m||g,activeVisit:y,currentVisit:v,currentVisitIsRetrospective:!!i,isLoading:E&&!D}}uK().extend(uG);let uQ=[];function u0(){let{data:e}=uo()(ic,id);return e??uQ}let u1=new Map;async function u4(e,t){let r=t.indexOf("#"),n=r>=0,a=n?t.substring(0,r):e,o=n?t.substring(r+1):t,i=await oM(a);return i&&Object.hasOwn(i,o)&&"function"==typeof i[o]?u3(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`),u2)}let u2={bootstrap:()=>Promise.resolve(),mount:()=>Promise.resolve(),unmount:()=>Promise.resolve()};async function u3(e,t){if(e in u1)await u1[e];else{let r=t??await oM(e);await (u1[e]=new Promise((t,n)=>{if(Object.hasOwn(r,"startupApp")){let a=r.startupApp;if("function"==typeof a)return Promise.resolve(a()).then(()=>{rT(e),t(null)}).catch(n)}rT(e),t(null)}))}}function u6(e,t){let r=t.name;if(!r)return void console.error(`An extension definition in ${e} is missing an name and thus cannot be
|
|
17
17
|
registered. To fix this, ensure that you define the "name" field inside the
|
|
18
18
|
extension definition.`,t);t.slots&&t.slot&&console.warn(`The extension ${r} from ${e} declares both a 'slots' property and
|