@openmrs/esm-patient-programs-app 13.0.2-pre.12921 → 13.0.2-pre.12934

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/3187.js CHANGED
@@ -12,8 +12,8 @@ If you're the maintainer: the 'elements' key only works with '_type' equal to 'A
12
12
  ${t}`)}return n}let rL=(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&&rF(e)){if(a._type===tW.Array&&Array.isArray(n)){let a=n.map(t=>rL(e,t));r[t]=a}else if(a._type===tW.Object)for(let t of Object.keys(n))n[t]=rL(e,n[t])}}else if(rB(a)){let e=n??{};rB(e)&&(r[t]=rL(a,e))}}return r};function rF(e){return!!e&&Object.keys(e).filter(e=>!["_default","_validators"].includes(e)).length>0}function rB(e){return"object"==typeof e&&!Array.isArray(e)&&null!==e}function rV(e,t){let r=`${e}:::${t}`;rc.has(r)||(console.error(t),rc.add(r))}function rU(e){e?rc.forEach(t=>{t.startsWith(e)&&rc.delete(t)}):rc.clear()}function rW(){ru.forEach(e=>e()),ru.length=0,rh.clear(),rk.clear(),rR.clear(),rP.clear(),rd=null,rp=new WeakMap,rm()}let rH={"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:tW.Object,_default:{},_validators:[tH(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(", ")}.`})]}},rz={"Display conditions":{privileges:{_description:"The privilege(s) the user must have to use this extension",_type:tW.Array,_default:[]},expression:{_description:"The expression that determines whether the extension is displayed",_type:tW.String,_default:void 0}},...rH},rK=(e,t)=>tH(r=>e<=r&&r<=t,`must be between ${e} and ${t}`),rG=e=>{let t=e.concat(["openmrsBase","openmrsSpaBase"]);return tH(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(", "))},rZ=rG([]),rY=e=>tH(t=>e.includes(t),`Must be one of the following: '${e.join("', '")}'.`),rq={inRange:rK,isUrl:rZ,isUrlWithTemplateParameters:rG,oneOf:rY};var rJ=r(2034);let rX=V("breadcrumbs",[]);function rQ(e){return r0([e])}function r0(e){let t=[...r1(),...e.map(e=>({matcher:e.matcher instanceof RegExp?e.matcher:"string"==typeof e.matcher?(0,rJ.pathToRegexp)(e.matcher).regexp:(0,rJ.pathToRegexp)(e.path).regexp,settings:e}))];rX.setState(t,!0)}function r1(){return rX.getState()}function r4(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=r4(e,r.join("/"));if(t)return t}}(e,t)}function r2(e,t){if(e.length>0){let r=r4(e,t);if(r){let t=[r],n=r4(e,r.settings.parent);for(;void 0!==n;)t.push(n),n=r4(e,n.settings.parent);return t.reverse()}}return[]}function r3(e){return r2(r1(),e)}var r6=Object.freeze({__proto__:null,get start(){return ab},get ensureJQuerySupport(){return n3},get setBootstrapMaxTime(){return nF},get setMountMaxTime(){return nB},get setUnmountMaxTime(){return nV},get setUnloadMaxTime(){return nU},get registerApplication(){return ao},get unregisterApplication(){return as},get getMountedApps(){return at},get getAppStatus(){return an},get unloadApplication(){return al},get checkActivityFunctions(){return ai},get getAppNames(){return ar},get pathToActiveWhen(){return ad},get navigateToUrl(){return nY},get patchHistoryApi(){return n1},get triggerAppChange(){return ah},get addErrorHandler(){return ne},get removeErrorHandler(){return nt},get mountRootParcel(){return nI},get NOT_LOADED(){return na},get LOADING_SOURCE_CODE(){return no},get NOT_BOOTSTRAPPED(){return ni},get BOOTSTRAPPING(){return ns},get NOT_MOUNTED(){return nl},get MOUNTING(){return nu},get UPDATING(){return nd},get LOAD_ERROR(){return nf},get MOUNTED(){return nc},get UNLOADING(){return nm},get UNMOUNTING(){return np},get SKIP_BECAUSE_BROKEN(){return nh}}),r5=("u">typeof globalThis?globalThis:"u">typeof window?window:"u">typeof global?global:"u">typeof self?self:{}).CustomEvent,r9=!function(){try{var e=new r5("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}:r5;let r8=[];function r7(e,t,r){let n=nn(e,t,r);r8.length?r8.forEach(e=>e(n)):setTimeout(()=>{throw n})}function ne(e){if("function"!=typeof e)throw Error(nr(28,!1));r8.push(e)}function nt(e){if("function"!=typeof e)throw Error(nr(29,!1));let t=!1;return r8=r8.filter(r=>{let n=r===e;return t=t||n,!n}),t}function nr(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 nn(e,t,r){let n,a=`${nw(t)} '${nv(t)}' died in status ${t.status}: `;if(e instanceof Error){try{e.message=a+e.message}catch(e){}n=e}else{console.warn(nr(30,!1,t.status,nv(t)));try{n=Error(a+JSON.stringify(e))}catch(t){n=e}}return n.appOrParcelName=nv(t),t.status=r,n}let na="NOT_LOADED",no="LOADING_SOURCE_CODE",ni="NOT_BOOTSTRAPPED",ns="BOOTSTRAPPING",nl="NOT_MOUNTED",nu="MOUNTING",nc="MOUNTED",nd="UPDATING",np="UNMOUNTING",nm="UNLOADING",nf="LOAD_ERROR",nh="SKIP_BECAUSE_BROKEN";function ng(e){return e.status===nc}function ny(e){try{return e.activeWhen(window.location)}catch(t){return r7(t,e,nh),!1}}function nv(e){return e.name}function nb(e){return!!e.unmountThisParcel}function nw(e){return nb(e)?"parcel":"application"}function nE(){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 nx(e,t){for(let r=0;r<e.length;r++)if(t(e[r]))return e[r];return null}function nD(e){return e&&("function"==typeof e||Array.isArray(e)&&!nx(e,e=>"function"!=typeof e))}function nS(e,t){let r=e[t]||[];0===(r=Array.isArray(r)?r:[r]).length&&(r=[()=>Promise.resolve()]);let n=nw(e),a=nv(e);return function(e){return r.reduce((r,o,i)=>r.then(()=>{let r=o(e);return n_(r)?r:Promise.reject(nr(15,!1,n,a,t,i))}),Promise.resolve())}}function n_(e){return e&&"function"==typeof e.then&&"function"==typeof e.catch}let nC=[];function nk(e,t){return Promise.resolve().then(()=>e.status!==ni?e:(e.status=ns,e.bootstrap?nW(e,"bootstrap").then(r).catch(r=>{if(t)throw nn(r,e,nh);return r7(r,e,nh),e}):Promise.resolve().then(r)));function r(){return e.status=nl,e}}function nP(e,t){return Promise.resolve().then(()=>{if(e.status!==nc)return e;return e.status=np,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 nn(r,e,nh);r7(r,e,nh)})).then(()=>e);function r(){return nW(e,"unmount").then(()=>{e.status=nl},r=>{if(t)throw nn(r,e,nh);r7(r,e,nh)})}})}let nR=!1,nT=!1;function nO(e,t){return Promise.resolve().then(()=>e.status!==nl?e:(nR||(window.dispatchEvent(new r9("single-spa:before-first-mount")),nR=!0),e.status=nu,nW(e,"mount").then(()=>(e.status=nc,nT||(window.dispatchEvent(new r9("single-spa:first-mount")),nT=!0),e)).catch(r=>{return e.status=nc,nP(e,!0).then(n,n);function n(){if(t)throw nn(r,e,nh);return r7(r,e,nh),e}})))}let n$=0,nN={parcels:{}};function nI(){return nA.apply(nN,arguments)}function nA(e,t){let r,n,a,o=this;if(!e||"object"!=typeof e&&"function"!=typeof e)throw Error(nr(2,!1));if(e.name&&"string"!=typeof e.name)throw Error(nr(3,!1,typeof e.name));let i=n$++,s=e.name||`parcel-${i}`;if("object"!=typeof t)throw Error(nr(4,!1,s,typeof t));if(!t.domElement)throw Error(nr(5,!1,s));let l="function"==typeof e,u=l?e:()=>Promise.resolve(e),c={id:i,parcels:{},status:l?no:ni,customProps:t,parentName:nv(o),unmountThisParcel:()=>m.then(()=>{if(c.status!==nc)throw Error(nr(6,!1,s,c.status));return nP(c,!0)}).then(e=>(c.parentName&&delete o.parcels[c.id],e)).then(e=>(n(e),e)).catch(e=>{throw c.status=nh,a(e),e})};o.parcels[i]=c;let d=u();if(!d||"function"!=typeof d.then)throw Error(nr(7,!1));let p=(d=d.then(e=>{if(!e)throw Error(nr(8,!1));if(s=e.name||`parcel-${i}`,Object.prototype.hasOwnProperty.call(e,"bootstrap")&&!nD(e.bootstrap))throw Error(nr(9,!1,s));if(!nD(e.mount))throw Error(nr(10,!1,s));if(!nD(e.unmount))throw Error(nr(11,!1,s));if(e.update&&!nD(e.update))throw Error(nr(12,!1,s));let t=nS(e,"bootstrap"),n=nS(e,"mount"),a=nS(e,"unmount");c.status=ni,c.name=s,c.bootstrap=t,c.mount=n,c.unmount=a,c.timeouts=nH(e.timeouts),e.update&&(c.update=nS(e,"update"),r.update=function(e){return c.customProps=e,nM(Promise.resolve().then(()=>{if(c.status!==nc)throw Error(nr(32,!1,nv(c)));return c.status=nd,nW(c,"update").then(()=>(c.status=nc,c)).catch(e=>{throw nn(e,c,nh)})}))})})).then(()=>nk(c,!0)),m=p.then(()=>nO(c,!0)),f=new Promise((e,t)=>{n=e,a=t});return r={mount:()=>nM(Promise.resolve().then(()=>{if(c.status!==nl)throw Error(nr(13,!1,s,c.status));return o.parcels[i]=c,nO(c)})),unmount:()=>nM(c.unmountThisParcel()),getStatus:()=>c.status,loadPromise:nM(d),bootstrapPromise:nM(p),mountPromise:nM(m),unmountPromise:nM(f)}}function nM(e){return e.then(()=>null)}function nj(e){let t=nv(e),r="function"==typeof e.customProps?e.customProps(t,window.location):e.customProps;("object"!=typeof r||null===r||Array.isArray(r))&&(r={},console.warn(nr(40,!1),t,r));let n=nE({},r,{name:t,mountParcel:nA.bind(e),singleSpa:r6});return nb(e)&&(n.unmountSelf=e.unmountThisParcel),n}let nL={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 nF(e,t,r){if("number"!=typeof e||e<=0)throw Error(nr(16,!1));nL.bootstrap={millis:e,dieOnTimeout:t,warningMillis:r||1e3}}function nB(e,t,r){if("number"!=typeof e||e<=0)throw Error(nr(17,!1));nL.mount={millis:e,dieOnTimeout:t,warningMillis:r||1e3}}function nV(e,t,r){if("number"!=typeof e||e<=0)throw Error(nr(18,!1));nL.unmount={millis:e,dieOnTimeout:t,warningMillis:r||1e3}}function nU(e,t,r){if("number"!=typeof e||e<=0)throw Error(nr(19,!1));nL.unload={millis:e,dieOnTimeout:t,warningMillis:r||1e3}}function nW(e,t){let r=e.timeouts[t],n=r.warningMillis,a=nw(e);return new Promise((o,i)=>{let s=!1,l=!1;e[t](nj(e)).then(e=>{s=!0,o(e)}).catch(e=>{s=!0,i(e)}),setTimeout(()=>c(1),n),setTimeout(()=>c(!0),r.millis);let u=nr(31,!1,t,a,nv(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 nH(e){let t={};for(let r in nL)t[r]=nE({},nL[r],e&&e[r]||{});return t}function nz(e){return Promise.resolve().then(()=>{let t,r;return e.loadPromise?e.loadPromise:e.status!==na&&e.status!==nf?e:(e.status=no,e.loadPromise=Promise.resolve().then(()=>{let n=e.loadApp(nj(e));if(!n_(n))throw r=!0,Error(nr(33,!1,nv(e)));return n.then(r=>{let n;e.loadErrorTime=null,"object"!=typeof(t=r)&&(n=34),Object.prototype.hasOwnProperty.call(t,"bootstrap")&&!nD(t.bootstrap)&&(n=35),nD(t.mount)||(n=36),nD(t.unmount)||(n=37);let a=nw(t);if(n){let r;try{r=JSON.stringify(t)}catch(e){}return console.error(nr(n,!1,a,nv(e),r),t),r7(void 0,e,nh),e}return t.devtools&&t.devtools.overlays&&(e.devtools.overlays=nE({},e.devtools.overlays,t.devtools.overlays)),e.status=ni,e.bootstrap=nS(t,"bootstrap"),e.mount=nS(t,"mount"),e.unmount=nS(t,"unmount"),e.unload=nS(t,"unload"),e.timeouts=nH(t.timeouts),delete e.loadPromise,e})}).catch(t=>{let n;return delete e.loadPromise,r?n=nh:(n=nf,e.loadErrorTime=(new Date).getTime()),r7(t,e,n),e}))})}let nK="u">typeof window,nG={hashchange:[],popstate:[]},nZ=["hashchange","popstate"];function nY(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(nr(14,!1));t=e.currentTarget.href,e.preventDefault()}let r=n4(window.location.href),n=n4(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 nq(e){if(e){let t=e[0].type;nZ.indexOf(t)>=0&&nG[t].forEach(t=>{try{t.apply(this,e)}catch(e){setTimeout(()=>{throw e})}})}}function nJ(){ag([],arguments)}function nX(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 nQ=null,n0=!1;function n1(e){if(n0)throw Error(nr(43,!1));a=!e||!e.hasOwnProperty("urlRerouteOnly")||e.urlRerouteOnly,n0=!0,nQ=window.history.replaceState,window.addEventListener("hashchange",nJ),window.addEventListener("popstate",nJ);let t=window.addEventListener,r=window.removeEventListener;window.addEventListener=function(e,r){if(!("function"==typeof r&&nZ.indexOf(e)>=0)||nx(nG[e],e=>e===r))return t.apply(this,arguments);nG[e].push(r)},window.removeEventListener=function(e,t){return"function"==typeof t&&nZ.indexOf(e)>=0&&(nG[e]=nG[e].filter(e=>e!==t)),r.apply(this,arguments)},window.history.pushState=nX(window.history.pushState,"pushState"),window.history.replaceState=nX(nQ,"replaceState")}function n4(e){let t=document.createElement("a");return t.href=e,t}nK&&(window.singleSpaNavigate?console.warn(nr(41,!1)):window.singleSpaNavigate=nY);let n2=!1;function n3(e=window.jQuery){if(e||window.$&&window.$.fn&&window.$.fn.jquery&&(e=window.$),e&&!n2){let t=e.fn.on,r=e.fn.off;e.fn.on=function(e,r){return n6.call(this,t,window.addEventListener,e,r,arguments)},e.fn.off=function(e,t){return n6.call(this,r,window.removeEventListener,e,t,arguments)},n2=!0}}function n6(e,t,r,n,a){return"string"!=typeof r?e.apply(this,a):(r.split(/\s+/).forEach(e=>{nZ.indexOf(e)>=0&&(t(e,n),r=r.replace(e,""))}),""===r.trim()?this:e.apply(this,a))}let n5={};function n9(e){return Promise.resolve().then(()=>{let t=n5[nv(e)];if(!t)return e;if(e.status===na)return n8(e,t),e;if(e.status===nm)return t.promise.then(()=>e);if(e.status!==nl&&e.status!==nf)return e;let r=e.status===nf?Promise.resolve():nW(e,"unload");return e.status=nm,r.then(()=>(n8(e,t),e)).catch(r=>(delete n5[nv(e)],delete e.bootstrap,delete e.mount,delete e.unmount,delete e.unload,r7(r,e,nh),t.reject(r),e))})}function n8(e,t){delete n5[nv(e)],delete e.bootstrap,delete e.mount,delete e.unmount,delete e.unload,e.status=na,t.resolve()}function n7(e,t,r,n){n5[nv(e)]={app:e,resolve:r,reject:n},Object.defineProperty(n5[nv(e)],"promise",{get:t})}let ae=[];function at(){return ae.filter(ng).map(nv)}function ar(){return ae.map(nv)}function an(e){let t=nx(ae,t=>nv(t)===e);return t?t.status:null}let aa=!1;function ao(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(nr(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(nr(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(nr(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(nr(24,!1));if(!ac(e.customProps))throw Error(nr(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(nr(20,!1));if(!t)throw Error(nr(23,!1));if("function"!=typeof r)throw Error(nr(24,!1));if(!ac(n))throw Error(nr(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(av||aa||(aa=!0,setTimeout(()=>{av||console.warn(nr(1,!1))},5e3)),-1!==ar().indexOf(l.name))throw Error(nr(21,!1,l.name));ae.push(nE({loadErrorTime:null,status:na,parcels:{},devtools:{overlays:{options:{},selectors:[]}}},l)),nK&&(n3(),ag())}function ai(e=window.location){return ae.filter(t=>t.activeWhen(e)).map(nv)}function as(e){if(0===ae.filter(t=>nv(t)===e).length)throw Error(nr(25,!1,e));return(nK?al(e,{waitForUnmount:!1}):Promise.resolve()).then(()=>{let t=ae.map(nv).indexOf(e);ae.splice(t,1)})}function al(e,t={waitForUnmount:!1}){if("string"!=typeof e)throw Error(nr(26,!1));let r=nx(ae,t=>nv(t)===e);if(!r)throw Error(nr(27,!1,e));let n=n5[nv(r)];if(t&&t.waitForUnmount){if(n)return n.promise;{let e=new Promise((t,n)=>{n7(r,()=>e,t,n)});return e}}{let e;return n?(e=n.promise,au(r,n.resolve,n.reject)):e=new Promise((t,n)=>{n7(r,()=>e,t,n),au(r,t,n)}),e}}function au(e,t,r){Promise.resolve().then(()=>{if(nx(ai(),t=>t===nv(e)))return ah()}).then(()=>nP(e).then(n9).then(()=>{t(),setTimeout(()=>{ag()})})).catch(r)}function ac(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 ap=!1,am=[],af=nK&&window.location.href;function ah(){return ag()}function ag(e=[],t,r=!1){let n,a,o,i,s;if(ap)return new Promise((e,r)=>{am.push({resolve:e,reject:r,eventArguments:t})});let{appsToUnload:l,appsToUnmount:u,appsToLoad:c,appsToMount:d}=(n=[],a=[],o=[],i=[],s=(new Date).getTime(),ae.forEach(e=>{let t=e.status!==nh&&ny(e);switch(e.status){case nf:t&&s-e.loadErrorTime>=200&&o.push(e);break;case na:case no:t&&o.push(e);break;case ni:case nl:!t&&n5[nv(e)]?n.push(e):t&&i.push(e);break;case nc:t||a.push(e)}}),{appsToUnload:n,appsToUnmount:a,appsToLoad:o,appsToMount:i}),p,m=[],f=af,h=af=window.location.href;return av?(ap=!0,p=l.concat(c,u,d),Promise.resolve().then(()=>(w(0===p.length?"before-no-app-change":"before-app-change",b(!0)),w("before-routing-event",b(!0,{cancelNavigation:g})),Promise.all(m).then(r=>{if(r.some(e=>e))return nQ.call(window.history,history.state,"",f.substring(location.origin.length)),af=location.href,ap=!1,ag(e,t,!0);let n=l.map(n9),a=Promise.all(u.map(nP).map(e=>e.then(n9)).concat(n));a.then(()=>{w("before-mount-routing-event",b(!0))},e=>{throw e});let o=c.map(e=>nz(e).then(e=>ay(e,a))),i=d.filter(e=>0>c.indexOf(e)).map(e=>ay(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})))})))):(p=c,Promise.resolve().then(()=>Promise.all(c.map(nz)).then(v).then(()=>[]).catch(e=>{throw v(),e}).finally(()=>{})));function g(e=!0){let t="function"==typeof(null==e?void 0:e.then)?e:Promise.resolve(e);m.push(t.catch(e=>(console.warn(Error(nr(42,!1))),console.warn(e),!1)))}function y(){let t=at();e.forEach(e=>e.resolve(t));try{w(0===p.length?"no-app-change":"app-change",b()),w("routing-event",b())}catch(e){setTimeout(()=>{throw e})}if(ap=!1,am.length>0){let e=am;am=[],ag(e)}return t}function v(){r||(e.forEach(e=>{nq(e.eventArguments)}),nq(t))}function b(e=!1,r){let n={},a={[nc]:[],[nl]:[],[na]:[],[nh]:[]};e?(c.concat(d).forEach((e,t)=>{i(e,nc)}),l.forEach(e=>{i(e,na)}),u.forEach(e=>{i(e,nl)})):p.forEach(e=>{i(e)});let o={detail:{newAppStatuses:n,appsByNewStatus:a,totalAppChanges:p.length,originalEvent:null==t?void 0:t[0],oldUrl:f,newUrl:h}};return r&&nE(o.detail,r),o;function i(e,t){let r=nv(e);t=t||an(r),n[r]=t,(a[t]=a[t]||[]).push(r)}}function w(e,t){r||window.dispatchEvent(new r9(`single-spa:${e}`,t))}}function ay(e,t){return ny(e)?nk(e).then(e=>t.then(()=>ny(e)?nO(e):e)):t.then(()=>e)}let av=!1;function ab(e){av=!0,nK&&(n1(e),ag())}nK&&window.__SINGLE_SPA_DEVTOOLS__&&(window.__SINGLE_SPA_DEVTOOLS__.exposedMethods={getRawAppData:function(){return[...ae]},reroute:ag,NOT_LOADED:na,toLoadPromise:nz,toBootstrapPromise:nk,unregisterApplication:as,getProfilerData:function(){return nC}});let aw={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"},aE=e=>"string"==typeof e,ax=()=>{let e,t,r=new Promise((r,n)=>{e=r,t=n});return r.resolve=e,r.reject=t,r},aD=e=>null==e?"":""+e,aS=/###/g,a_=e=>e&&e.indexOf("###")>-1?e.replace(aS,"."):e,aC=e=>!e||aE(e),ak=(e,t,r)=>{let n=aE(t)?t.split("."):t,a=0;for(;a<n.length-1;){if(aC(e))return{};let t=a_(n[a]);!e[t]&&r&&(e[t]=new r),e=Object.prototype.hasOwnProperty.call(e,t)?e[t]:{},++a}return aC(e)?{}:{obj:e,k:a_(n[a])}},aP=(e,t,r)=>{let{obj:n,k:a}=ak(e,t,Object);if(void 0!==n||1===t.length){n[a]=r;return}let o=t[t.length-1],i=t.slice(0,t.length-1),s=ak(e,i,Object);for(;void 0===s.obj&&i.length;)o=`${i[i.length-1]}.${o}`,s=ak(e,i=i.slice(0,i.length-1),Object),s?.obj&&void 0!==s.obj[`${s.k}.${o}`]&&(s.obj=void 0);s.obj[`${s.k}.${o}`]=r},aR=(e,t)=>{let{obj:r,k:n}=ak(e,t);if(r&&Object.prototype.hasOwnProperty.call(r,n))return r[n]},aT=(e,t,r)=>{for(let n in t)"__proto__"!==n&&"constructor"!==n&&(n in e?aE(e[n])||e[n]instanceof String||aE(t[n])||t[n]instanceof String?r&&(e[n]=t[n]):aT(e[n],t[n],r):e[n]=t[n]);return e};var aO={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};let a$=e=>aE(e)?e.replace(/[&<>"'\/]/g,e=>aO[e]):e,aN=[" ",",","?","!",";"],aI=new class{constructor(e){this.capacity=e,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(e){let t=this.regExpMap.get(e);if(void 0!==t)return t;let r=new RegExp(e);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(e,r),this.regExpQueue.push(e),r}}(20),aA=(e,t,r=".")=>{if(!e)return;if(e[t]){if(!Object.prototype.hasOwnProperty.call(e,t))return;return e[t]}let n=t.split(r),a=e;for(let e=0;e<n.length;){let t;if(!a||"object"!=typeof a)return;let o="";for(let i=e;i<n.length;++i)if(i!==e&&(o+=r),o+=n[i],void 0!==(t=a[o])){if(["string","number","boolean"].indexOf(typeof t)>-1&&i<n.length-1)continue;e+=i-e+1;break}a=t}return a},aM=e=>e?.replace("_","-"),aj={type:"logger",log(e){this.output("log",e)},warn(e){this.output("warn",e)},error(e){this.output("error",e)},output(e,t){console?.[e]?.apply?.(console,t)}};class aL{constructor(e,t={}){this.init(e,t)}init(e,t={}){this.prefix=t.prefix||"i18next:",this.logger=e||aj,this.options=t,this.debug=t.debug}log(...e){return this.forward(e,"log","",!0)}warn(...e){return this.forward(e,"warn","",!0)}error(...e){return this.forward(e,"error","")}deprecate(...e){return this.forward(e,"warn","WARNING DEPRECATED: ",!0)}forward(e,t,r,n){return n&&!this.debug?null:(aE(e[0])&&(e[0]=`${r}${this.prefix} ${e[0]}`),this.logger[t](e))}create(e){return new aL(this.logger,{...{prefix:`${this.prefix}:${e}:`},...this.options})}clone(e){return(e=e||this.options).prefix=e.prefix||this.prefix,new aL(this.logger,e)}}var aF=new aL;class aB{constructor(){this.observers={}}on(e,t){return e.split(" ").forEach(e=>{this.observers[e]||(this.observers[e]=new Map);let r=this.observers[e].get(t)||0;this.observers[e].set(t,r+1)}),this}off(e,t){if(this.observers[e]){if(!t)return void delete this.observers[e];this.observers[e].delete(t)}}emit(e,...t){this.observers[e]&&Array.from(this.observers[e].entries()).forEach(([e,r])=>{for(let n=0;n<r;n++)e(...t)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(([r,n])=>{for(let a=0;a<n;a++)r.apply(r,[e,...t])})}}class aV extends aB{constructor(e,t={ns:["translation"],defaultNS:"translation"}){super(),this.data=e||{},this.options=t,void 0===this.options.keySeparator&&(this.options.keySeparator="."),void 0===this.options.ignoreJSONStructure&&(this.options.ignoreJSONStructure=!0)}addNamespaces(e){0>this.options.ns.indexOf(e)&&this.options.ns.push(e)}removeNamespaces(e){let t=this.options.ns.indexOf(e);t>-1&&this.options.ns.splice(t,1)}getResource(e,t,r,n={}){let a,o=void 0!==n.keySeparator?n.keySeparator:this.options.keySeparator,i=void 0!==n.ignoreJSONStructure?n.ignoreJSONStructure:this.options.ignoreJSONStructure;e.indexOf(".")>-1?a=e.split("."):(a=[e,t],r&&(Array.isArray(r)?a.push(...r):aE(r)&&o?a.push(...r.split(o)):a.push(r)));let s=aR(this.data,a);return(!s&&!t&&!r&&e.indexOf(".")>-1&&(e=a[0],t=a[1],r=a.slice(2).join(".")),!s&&i&&aE(r))?aA(this.data?.[e]?.[t],r,o):s}addResource(e,t,r,n,a={silent:!1}){let o=void 0!==a.keySeparator?a.keySeparator:this.options.keySeparator,i=[e,t];r&&(i=i.concat(o?r.split(o):r)),e.indexOf(".")>-1&&(i=e.split("."),n=t,t=i[1]),this.addNamespaces(t),aP(this.data,i,n),a.silent||this.emit("added",e,t,r,n)}addResources(e,t,r,n={silent:!1}){for(let n in r)(aE(r[n])||Array.isArray(r[n]))&&this.addResource(e,t,n,r[n],{silent:!0});n.silent||this.emit("added",e,t,r)}addResourceBundle(e,t,r,n,a,o={silent:!1,skipCopy:!1}){let i=[e,t];e.indexOf(".")>-1&&(i=e.split("."),n=r,r=t,t=i[1]),this.addNamespaces(t);let s=aR(this.data,i)||{};o.skipCopy||(r=JSON.parse(JSON.stringify(r))),n?aT(s,r,a):s={...s,...r},aP(this.data,i,s),o.silent||this.emit("added",e,t,r)}removeResourceBundle(e,t){this.hasResourceBundle(e,t)&&delete this.data[e][t],this.removeNamespaces(t),this.emit("removed",e,t)}hasResourceBundle(e,t){return void 0!==this.getResource(e,t)}getResourceBundle(e,t){return t||(t=this.options.defaultNS),this.getResource(e,t)}getDataByLanguage(e){return this.data[e]}hasLanguageSomeTranslations(e){let t=this.getDataByLanguage(e);return!!(t&&Object.keys(t)||[]).find(e=>t[e]&&Object.keys(t[e]).length>0)}toJSON(){return this.data}}var aU={processors:{},addPostProcessor(e){this.processors[e.name]=e},handle(e,t,r,n,a){return e.forEach(e=>{t=this.processors[e]?.process(t,r,n,a)??t}),t}};let aW=Symbol("i18next/PATH_KEY");function aH(e,t){let r,n,a,{[aW]:o}=e((n=[],(a=Object.create(null)).get=(e,t)=>(r?.revoke?.(),t===aW)?n:(n.push(t),(r=Proxy.revocable(e,a)).proxy),Proxy.revocable(Object.create(null),a).proxy));return o.join(t?.keySeparator??".")}let az={},aK=e=>!aE(e)&&"boolean"!=typeof e&&"number"!=typeof e;class aG extends aB{constructor(e,t={}){super(),((e,t,r)=>{e.forEach(e=>{t[e]&&(r[e]=t[e])})})(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=t,void 0===this.options.keySeparator&&(this.options.keySeparator="."),this.logger=aF.create("translator")}changeLanguage(e){e&&(this.language=e)}exists(e,t={interpolation:{}}){let r={...t};if(null==e)return!1;let n=this.resolve(e,r);if(n?.res===void 0)return!1;let a=aK(n.res);return!1!==r.returnObjects||!a}extractFromKey(e,t){let r=void 0!==t.nsSeparator?t.nsSeparator:this.options.nsSeparator;void 0===r&&(r=":");let n=void 0!==t.keySeparator?t.keySeparator:this.options.keySeparator,a=t.ns||this.options.defaultNS||[],o=r&&e.indexOf(r)>-1,i=!this.options.userDefinedKeySeparator&&!t.keySeparator&&!this.options.userDefinedNsSeparator&&!t.nsSeparator&&!((e,t,r)=>{t=t||"",r=r||"";let n=aN.filter(e=>0>t.indexOf(e)&&0>r.indexOf(e));if(0===n.length)return!0;let a=aI.getRegExp(`(${n.map(e=>"?"===e?"\\?":e).join("|")})`),o=!a.test(e);if(!o){let t=e.indexOf(r);t>0&&!a.test(e.substring(0,t))&&(o=!0)}return o})(e,r,n);if(o&&!i){let t=e.match(this.interpolator.nestingRegexp);if(t&&t.length>0)return{key:e,namespaces:aE(a)?[a]:a};let o=e.split(r);(r!==n||r===n&&this.options.ns.indexOf(o[0])>-1)&&(a=o.shift()),e=o.join(n)}return{key:e,namespaces:aE(a)?[a]:a}}translate(e,t,r){let n="object"==typeof t?{...t}:t;if("object"!=typeof n&&this.options.overloadTranslationOptionHandler&&(n=this.options.overloadTranslationOptionHandler(arguments)),"object"==typeof n&&(n={...n}),n||(n={}),null==e)return"";"function"==typeof e&&(e=aH(e,{...this.options,...n})),Array.isArray(e)||(e=[String(e)]);let a=void 0!==n.returnDetails?n.returnDetails:this.options.returnDetails,o=void 0!==n.keySeparator?n.keySeparator:this.options.keySeparator,{key:i,namespaces:s}=this.extractFromKey(e[e.length-1],n),l=s[s.length-1],u=void 0!==n.nsSeparator?n.nsSeparator:this.options.nsSeparator;void 0===u&&(u=":");let c=n.lng||this.language,d=n.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(c?.toLowerCase()==="cimode")return d?a?{res:`${l}${u}${i}`,usedKey:i,exactUsedKey:i,usedLng:c,usedNS:l,usedParams:this.getUsedParamsDetails(n)}:`${l}${u}${i}`:a?{res:i,usedKey:i,exactUsedKey:i,usedLng:c,usedNS:l,usedParams:this.getUsedParamsDetails(n)}:i;let p=this.resolve(e,n),m=p?.res,f=p?.usedKey||i,h=p?.exactUsedKey||i,g=void 0!==n.joinArrays?n.joinArrays:this.options.joinArrays,y=!this.i18nFormat||this.i18nFormat.handleAsObject,v=void 0!==n.count&&!aE(n.count),b=aG.hasDefaultValue(n),w=v?this.pluralResolver.getSuffix(c,n.count,n):"",E=n.ordinal&&v?this.pluralResolver.getSuffix(c,n.count,{ordinal:!1}):"",x=v&&!n.ordinal&&0===n.count,D=x&&n[`defaultValue${this.options.pluralSeparator}zero`]||n[`defaultValue${w}`]||n[`defaultValue${E}`]||n.defaultValue,S=m;y&&!m&&b&&(S=D);let _=aK(S),C=Object.prototype.toString.apply(S);if(y&&S&&_&&0>["[object Number]","[object Function]","[object RegExp]"].indexOf(C)&&!(aE(g)&&Array.isArray(S))){if(!n.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");let e=this.options.returnedObjectHandler?this.options.returnedObjectHandler(f,S,{...n,ns:s}):`key '${i} (${this.language})' returned an object instead of string.`;return a?(p.res=e,p.usedParams=this.getUsedParamsDetails(n),p):e}if(o){let e=Array.isArray(S),t=e?[]:{},r=e?h:f;for(let e in S)if(Object.prototype.hasOwnProperty.call(S,e)){let a=`${r}${o}${e}`;b&&!m?t[e]=this.translate(a,{...n,defaultValue:aK(D)?D[e]:void 0,...{joinArrays:!1,ns:s}}):t[e]=this.translate(a,{...n,joinArrays:!1,ns:s}),t[e]===a&&(t[e]=S[e])}m=t}}else if(y&&aE(g)&&Array.isArray(m))(m=m.join(g))&&(m=this.extendTranslation(m,e,n,r));else{let t=!1,a=!1;!this.isValidLookup(m)&&b&&(t=!0,m=D),this.isValidLookup(m)||(a=!0,m=i);let s=(n.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&a?void 0:m,d=b&&D!==m&&this.options.updateMissing;if(a||t||d){if(this.logger.log(d?"updateKey":"missingKey",c,l,i,d?D:m),o){let e=this.resolve(i,{...n,keySeparator:!1});e&&e.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}let e=[],t=this.languageUtils.getFallbackCodes(this.options.fallbackLng,n.lng||this.language);if("fallback"===this.options.saveMissingTo&&t&&t[0])for(let r=0;r<t.length;r++)e.push(t[r]);else"all"===this.options.saveMissingTo?e=this.languageUtils.toResolveHierarchy(n.lng||this.language):e.push(n.lng||this.language);let r=(e,t,r)=>{let a=b&&r!==m?r:s;this.options.missingKeyHandler?this.options.missingKeyHandler(e,l,t,a,d,n):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(e,l,t,a,d,n),this.emit("missingKey",e,l,t,m)};this.options.saveMissing&&(this.options.saveMissingPlurals&&v?e.forEach(e=>{let t=this.pluralResolver.getSuffixes(e,n);x&&n[`defaultValue${this.options.pluralSeparator}zero`]&&0>t.indexOf(`${this.options.pluralSeparator}zero`)&&t.push(`${this.options.pluralSeparator}zero`),t.forEach(t=>{r([e],i+t,n[`defaultValue${t}`]||D)})}):r(e,i,D))}m=this.extendTranslation(m,e,n,p,r),a&&m===i&&this.options.appendNamespaceToMissingKey&&(m=`${l}${u}${i}`),(a||t)&&this.options.parseMissingKeyHandler&&(m=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${l}${u}${i}`:i,t?m:void 0,n))}return a?(p.res=m,p.usedParams=this.getUsedParamsDetails(n),p):m}extendTranslation(e,t,r,n,a){if(this.i18nFormat?.parse)e=this.i18nFormat.parse(e,{...this.options.interpolation.defaultVariables,...r},r.lng||this.language||n.usedLng,n.usedNS,n.usedKey,{resolved:n});else if(!r.skipInterpolation){let o;r.interpolation&&this.interpolator.init({...r,...{interpolation:{...this.options.interpolation,...r.interpolation}}});let i=aE(e)&&(r?.interpolation?.skipOnVariables!==void 0?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);if(i){let t=e.match(this.interpolator.nestingRegexp);o=t&&t.length}let s=r.replace&&!aE(r.replace)?r.replace:r;if(this.options.interpolation.defaultVariables&&(s={...this.options.interpolation.defaultVariables,...s}),e=this.interpolator.interpolate(e,s,r.lng||this.language||n.usedLng,r),i){let t=e.match(this.interpolator.nestingRegexp);o<(t&&t.length)&&(r.nest=!1)}!r.lng&&n&&n.res&&(r.lng=this.language||n.usedLng),!1!==r.nest&&(e=this.interpolator.nest(e,(...e)=>a?.[0]!==e[0]||r.context?this.translate(...e,t):(this.logger.warn(`It seems you are nesting recursively key: ${e[0]} in key: ${t[0]}`),null),r)),r.interpolation&&this.interpolator.reset()}let o=r.postProcess||this.options.postProcess,i=aE(o)?[o]:o;return null!=e&&i?.length&&!1!==r.applyPostProcessor&&(e=aU.handle(i,e,t,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...n,usedParams:this.getUsedParamsDetails(r)},...r}:r,this)),e}resolve(e,t={}){let r,n,a,o,i;return aE(e)&&(e=[e]),e.forEach(e=>{if(this.isValidLookup(r))return;let s=this.extractFromKey(e,t),l=s.key;n=l;let u=s.namespaces;this.options.fallbackNS&&(u=u.concat(this.options.fallbackNS));let c=void 0!==t.count&&!aE(t.count),d=c&&!t.ordinal&&0===t.count,p=void 0!==t.context&&(aE(t.context)||"number"==typeof t.context)&&""!==t.context,m=t.lngs?t.lngs:this.languageUtils.toResolveHierarchy(t.lng||this.language,t.fallbackLng);u.forEach(e=>{this.isValidLookup(r)||(i=e,!az[`${m[0]}-${e}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(i)&&(az[`${m[0]}-${e}`]=!0,this.logger.warn(`key "${n}" for languages "${m.join(", ")}" won't get resolved as namespace "${i}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),m.forEach(n=>{let i;if(this.isValidLookup(r))return;o=n;let s=[l];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(s,l,n,e,t);else{let e;c&&(e=this.pluralResolver.getSuffix(n,t.count,t));let r=`${this.options.pluralSeparator}zero`,a=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(c&&(t.ordinal&&0===e.indexOf(a)&&s.push(l+e.replace(a,this.options.pluralSeparator)),s.push(l+e),d&&s.push(l+r)),p){let n=`${l}${this.options.contextSeparator||"_"}${t.context}`;s.push(n),c&&(t.ordinal&&0===e.indexOf(a)&&s.push(n+e.replace(a,this.options.pluralSeparator)),s.push(n+e),d&&s.push(n+r))}}for(;i=s.pop();)this.isValidLookup(r)||(a=i,r=this.getResource(n,e,i,t))}))})}),{res:r,usedKey:n,exactUsedKey:a,usedLng:o,usedNS:i}}isValidLookup(e){return void 0!==e&&!(!this.options.returnNull&&null===e)&&!(!this.options.returnEmptyString&&""===e)}getResource(e,t,r,n={}){return this.i18nFormat?.getResource?this.i18nFormat.getResource(e,t,r,n):this.resourceStore.getResource(e,t,r,n)}getUsedParamsDetails(e={}){let t=e.replace&&!aE(e.replace),r=t?e.replace:e;if(t&&void 0!==e.count&&(r.count=e.count),this.options.interpolation.defaultVariables&&(r={...this.options.interpolation.defaultVariables,...r}),!t)for(let e of(r={...r},["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"]))delete r[e];return r}static hasDefaultValue(e){let t="defaultValue";for(let r in e)if(Object.prototype.hasOwnProperty.call(e,r)&&t===r.substring(0,t.length)&&void 0!==e[r])return!0;return!1}}class aZ{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=aF.create("languageUtils")}getScriptPartFromCode(e){if(!(e=aM(e))||0>e.indexOf("-"))return null;let t=e.split("-");return 2===t.length||(t.pop(),"x"===t[t.length-1].toLowerCase())?null:this.formatLanguageCode(t.join("-"))}getLanguagePartFromCode(e){if(!(e=aM(e))||0>e.indexOf("-"))return e;let t=e.split("-");return this.formatLanguageCode(t[0])}formatLanguageCode(e){if(aE(e)&&e.indexOf("-")>-1){let t;try{t=Intl.getCanonicalLocales(e)[0]}catch(e){}return(t&&this.options.lowerCaseLng&&(t=t.toLowerCase()),t)?t:this.options.lowerCaseLng?e.toLowerCase():e}return this.options.cleanCode||this.options.lowerCaseLng?e.toLowerCase():e}isSupportedCode(e){return("languageOnly"===this.options.load||this.options.nonExplicitSupportedLngs)&&(e=this.getLanguagePartFromCode(e)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(e)>-1}getBestMatchFromCodes(e){let t;return e?(e.forEach(e=>{if(t)return;let r=this.formatLanguageCode(e);(!this.options.supportedLngs||this.isSupportedCode(r))&&(t=r)}),!t&&this.options.supportedLngs&&e.forEach(e=>{if(t)return;let r=this.getScriptPartFromCode(e);if(this.isSupportedCode(r))return t=r;let n=this.getLanguagePartFromCode(e);if(this.isSupportedCode(n))return t=n;t=this.options.supportedLngs.find(e=>{if(e===n||!(0>e.indexOf("-")&&0>n.indexOf("-"))&&(e.indexOf("-")>0&&0>n.indexOf("-")&&e.substring(0,e.indexOf("-"))===n||0===e.indexOf(n)&&n.length>1))return e})}),t||(t=this.getFallbackCodes(this.options.fallbackLng)[0]),t):null}getFallbackCodes(e,t){if(!e)return[];if("function"==typeof e&&(e=e(t)),aE(e)&&(e=[e]),Array.isArray(e))return e;if(!t)return e.default||[];let r=e[t];return r||(r=e[this.getScriptPartFromCode(t)]),r||(r=e[this.formatLanguageCode(t)]),r||(r=e[this.getLanguagePartFromCode(t)]),r||(r=e.default),r||[]}toResolveHierarchy(e,t){let r=this.getFallbackCodes((!1===t?[]:t)||this.options.fallbackLng||[],e),n=[],a=e=>{e&&(this.isSupportedCode(e)?n.push(e):this.logger.warn(`rejecting language code not found in supportedLngs: ${e}`))};return aE(e)&&(e.indexOf("-")>-1||e.indexOf("_")>-1)?("languageOnly"!==this.options.load&&a(this.formatLanguageCode(e)),"languageOnly"!==this.options.load&&"currentOnly"!==this.options.load&&a(this.getScriptPartFromCode(e)),"currentOnly"!==this.options.load&&a(this.getLanguagePartFromCode(e))):aE(e)&&a(this.formatLanguageCode(e)),r.forEach(e=>{0>n.indexOf(e)&&a(this.formatLanguageCode(e))}),n}}let aY={zero:0,one:1,two:2,few:3,many:4,other:5},aq={select:e=>1===e?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class aJ{constructor(e,t={}){this.languageUtils=e,this.options=t,this.logger=aF.create("pluralResolver"),this.pluralRulesCache={}}addRule(e,t){this.rules[e]=t}clearCache(){this.pluralRulesCache={}}getRule(e,t={}){let r,n=aM("dev"===e?"en":e),a=t.ordinal?"ordinal":"cardinal",o=JSON.stringify({cleanedCode:n,type:a});if(o in this.pluralRulesCache)return this.pluralRulesCache[o];try{r=new Intl.PluralRules(n,{type:a})}catch(a){if(!Intl)return this.logger.error("No Intl support, please use an Intl polyfill!"),aq;if(!e.match(/-|_/))return aq;let n=this.languageUtils.getLanguagePartFromCode(e);r=this.getRule(n,t)}return this.pluralRulesCache[o]=r,r}needsPlural(e,t={}){let r=this.getRule(e,t);return r||(r=this.getRule("dev",t)),r?.resolvedOptions().pluralCategories.length>1}getPluralFormsOfKey(e,t,r={}){return this.getSuffixes(e,r).map(e=>`${t}${e}`)}getSuffixes(e,t={}){let r=this.getRule(e,t);return(r||(r=this.getRule("dev",t)),r)?r.resolvedOptions().pluralCategories.sort((e,t)=>aY[e]-aY[t]).map(e=>`${this.options.prepend}${t.ordinal?`ordinal${this.options.prepend}`:""}${e}`):[]}getSuffix(e,t,r={}){let n=this.getRule(e,r);return n?`${this.options.prepend}${r.ordinal?`ordinal${this.options.prepend}`:""}${n.select(t)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix("dev",t,r))}}let aX=(e,t,r,n=".",a=!0)=>{let o,i=void 0!==(o=aR(e,r))?o:aR(t,r);return!i&&a&&aE(r)&&void 0===(i=aA(e,r,n))&&(i=aA(t,r,n)),i};class aQ{constructor(e={}){this.logger=aF.create("interpolator"),this.options=e,this.format=e?.interpolation?.format||(e=>e),this.init(e)}init(e={}){e.interpolation||(e.interpolation={escapeValue:!0});let{escape:t,escapeValue:r,useRawValueToEscape:n,prefix:a,prefixEscaped:o,suffix:i,suffixEscaped:s,formatSeparator:l,unescapeSuffix:u,unescapePrefix:c,nestingPrefix:d,nestingPrefixEscaped:p,nestingSuffix:m,nestingSuffixEscaped:f,nestingOptionsSeparator:h,maxReplaces:g,alwaysFormat:y}=e.interpolation;this.escape=void 0!==t?t:a$,this.escapeValue=void 0===r||r,this.useRawValueToEscape=void 0!==n&&n,this.prefix=a?a.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"):o||"{{",this.suffix=i?i.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"):s||"}}",this.formatSeparator=l||",",this.unescapePrefix=u?"":c||"-",this.unescapeSuffix=this.unescapePrefix?"":u||"",this.nestingPrefix=d?d.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"):p||"$t(".replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),this.nestingSuffix=m?m.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"):f||")".replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),this.nestingOptionsSeparator=h||",",this.maxReplaces=g||1e3,this.alwaysFormat=void 0!==y&&y,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){let e=(e,t)=>e?.source===t?(e.lastIndex=0,e):RegExp(t,"g");this.regexp=e(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=e(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=e(this.nestingRegexp,`${this.nestingPrefix}((?:[^()"']+|"[^"]*"|'[^']*'|\\((?:[^()]|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`)}interpolate(e,t,r,n){let a,o,i,s=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},l=e=>{if(0>e.indexOf(this.formatSeparator)){let a=aX(t,s,e,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(a,void 0,r,{...n,...t,interpolationkey:e}):a}let a=e.split(this.formatSeparator),o=a.shift().trim(),i=a.join(this.formatSeparator).trim();return this.format(aX(t,s,o,this.options.keySeparator,this.options.ignoreJSONStructure),i,r,{...n,...t,interpolationkey:o})};this.resetRegExp();let u=n?.missingInterpolationHandler||this.options.missingInterpolationHandler,c=n?.interpolation?.skipOnVariables!==void 0?n.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:e=>e.replace(/\$/g,"$$$$")},{regex:this.regexp,safeValue:e=>this.escapeValue?this.escape(e).replace(/\$/g,"$$$$"):e.replace(/\$/g,"$$$$")}].forEach(t=>{for(i=0;a=t.regex.exec(e);){let r=a[1].trim();if(void 0===(o=l(r)))if("function"==typeof u){let t=u(e,a,n);o=aE(t)?t:""}else if(n&&Object.prototype.hasOwnProperty.call(n,r))o="";else if(c){o=a[0];continue}else this.logger.warn(`missed to pass in variable ${r} for interpolating ${e}`),o="";else aE(o)||this.useRawValueToEscape||(o=aD(o));let s=t.safeValue(o);if(e=e.replace(a[0],s),c?(t.regex.lastIndex+=o.length,t.regex.lastIndex-=a[0].length):t.regex.lastIndex=0,++i>=this.maxReplaces)break}}),e}nest(e,t,r={}){let n,a,o,i=(e,t)=>{let r=this.nestingOptionsSeparator;if(0>e.indexOf(r))return e;let n=e.split(RegExp(`${r}[ ]*{`)),a=`{${n[1]}`;e=n[0];let i=(a=this.interpolate(a,o)).match(/'/g),s=a.match(/"/g);((i?.length??0)%2!=0||s)&&s.length%2==0||(a=a.replace(/'/g,'"'));try{o=JSON.parse(a),t&&(o={...t,...o})}catch(t){return this.logger.warn(`failed parsing options string in nesting for key ${e}`,t),`${e}${r}${a}`}return o.defaultValue&&o.defaultValue.indexOf(this.prefix)>-1&&delete o.defaultValue,e};for(;n=this.nestingRegexp.exec(e);){let s=[];(o=(o={...r}).replace&&!aE(o.replace)?o.replace:o).applyPostProcessor=!1,delete o.defaultValue;let l=/{.*}/.test(n[1])?n[1].lastIndexOf("}")+1:n[1].indexOf(this.formatSeparator);if(-1!==l&&(s=n[1].slice(l).split(this.formatSeparator).map(e=>e.trim()).filter(Boolean),n[1]=n[1].slice(0,l)),(a=t(i.call(this,n[1].trim(),o),o))&&n[0]===e&&!aE(a))return a;aE(a)||(a=aD(a)),a||(this.logger.warn(`missed to resolve ${n[1]} for nesting ${e}`),a=""),s.length&&(a=s.reduce((e,t)=>this.format(e,t,r.lng,{...r,interpolationkey:n[1].trim()}),a.trim())),e=e.replace(n[0],a),this.regexp.lastIndex=0}return e}}let a0=e=>{let t={};return(r,n,a)=>{let o=a;a&&a.interpolationkey&&a.formatParams&&a.formatParams[a.interpolationkey]&&a[a.interpolationkey]&&(o={...o,[a.interpolationkey]:void 0});let i=n+JSON.stringify(o),s=t[i];return s||(s=e(aM(n),a),t[i]=s),s(r)}},a1=e=>(t,r,n)=>e(aM(r),n)(t);class a4{constructor(e={}){this.logger=aF.create("formatter"),this.options=e,this.init(e)}init(e,t={interpolation:{}}){this.formatSeparator=t.interpolation.formatSeparator||",";let r=t.cacheInBuiltFormats?a0:a1;this.formats={number:r((e,t)=>{let r=new Intl.NumberFormat(e,{...t});return e=>r.format(e)}),currency:r((e,t)=>{let r=new Intl.NumberFormat(e,{...t,style:"currency"});return e=>r.format(e)}),datetime:r((e,t)=>{let r=new Intl.DateTimeFormat(e,{...t});return e=>r.format(e)}),relativetime:r((e,t)=>{let r=new Intl.RelativeTimeFormat(e,{...t});return e=>r.format(e,t.range||"day")}),list:r((e,t)=>{let r=new Intl.ListFormat(e,{...t});return e=>r.format(e)})}}add(e,t){this.formats[e.toLowerCase().trim()]=t}addCached(e,t){this.formats[e.toLowerCase().trim()]=a0(t)}format(e,t,r,n={}){let a=t.split(this.formatSeparator);if(a.length>1&&a[0].indexOf("(")>1&&0>a[0].indexOf(")")&&a.find(e=>e.indexOf(")")>-1)){let e=a.findIndex(e=>e.indexOf(")")>-1);a[0]=[a[0],...a.splice(1,e)].join(this.formatSeparator)}return a.reduce((e,t)=>{let{formatName:a,formatOptions:o}=(e=>{let t=e.toLowerCase().trim(),r={};if(e.indexOf("(")>-1){let n=e.split("(");t=n[0].toLowerCase().trim();let a=n[1].substring(0,n[1].length-1);"currency"===t&&0>a.indexOf(":")?r.currency||(r.currency=a.trim()):"relativetime"===t&&0>a.indexOf(":")?r.range||(r.range=a.trim()):a.split(";").forEach(e=>{if(e){let[t,...n]=e.split(":"),a=n.join(":").trim().replace(/^'+|'+$/g,""),o=t.trim();r[o]||(r[o]=a),"false"===a&&(r[o]=!1),"true"===a&&(r[o]=!0),isNaN(a)||(r[o]=parseInt(a,10))}})}return{formatName:t,formatOptions:r}})(t);if(this.formats[a]){let t=e;try{let i=n?.formatParams?.[n.interpolationkey]||{},s=i.locale||i.lng||n.locale||n.lng||r;t=this.formats[a](e,s,{...o,...n,...i})}catch(e){this.logger.warn(e)}return t}return this.logger.warn(`there was no format function for ${a}`),e},e)}}class a2 extends aB{constructor(e,t,r,n={}){super(),this.backend=e,this.store=t,this.services=r,this.languageUtils=r.languageUtils,this.options=n,this.logger=aF.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=n.maxParallelReads||10,this.readingCalls=0,this.maxRetries=n.maxRetries>=0?n.maxRetries:5,this.retryTimeout=n.retryTimeout>=1?n.retryTimeout:350,this.state={},this.queue=[],this.backend?.init?.(r,n.backend,n)}queueLoad(e,t,r,n){let a={},o={},i={},s={};return e.forEach(e=>{let n=!0;t.forEach(t=>{let i=`${e}|${t}`;!r.reload&&this.store.hasResourceBundle(e,t)?this.state[i]=2:this.state[i]<0||(1===this.state[i]?void 0===o[i]&&(o[i]=!0):(this.state[i]=1,n=!1,void 0===o[i]&&(o[i]=!0),void 0===a[i]&&(a[i]=!0),void 0===s[t]&&(s[t]=!0)))}),n||(i[e]=!0)}),(Object.keys(a).length||Object.keys(o).length)&&this.queue.push({pending:o,pendingCount:Object.keys(o).length,loaded:{},errors:[],callback:n}),{toLoad:Object.keys(a),pending:Object.keys(o),toLoadLanguages:Object.keys(i),toLoadNamespaces:Object.keys(s)}}loaded(e,t,r){let n=e.split("|"),a=n[0],o=n[1];t&&this.emit("failedLoading",a,o,t),!t&&r&&this.store.addResourceBundle(a,o,r,void 0,void 0,{skipCopy:!0}),this.state[e]=t?-1:2,t&&r&&(this.state[e]=0);let i={};this.queue.forEach(r=>{((e,t,r,n)=>{let{obj:a,k:o}=ak(e,t,Object);a[o]=a[o]||[],a[o].push(r)})(r.loaded,[a],o),void 0!==r.pending[e]&&(delete r.pending[e],r.pendingCount--),t&&r.errors.push(t),0!==r.pendingCount||r.done||(Object.keys(r.loaded).forEach(e=>{i[e]||(i[e]={});let t=r.loaded[e];t.length&&t.forEach(t=>{void 0===i[e][t]&&(i[e][t]=!0)})}),r.done=!0,r.errors.length?r.callback(r.errors):r.callback())}),this.emit("loaded",i),this.queue=this.queue.filter(e=>!e.done)}read(e,t,r,n=0,a=this.retryTimeout,o){if(!e.length)return o(null,{});if(this.readingCalls>=this.maxParallelReads)return void this.waitingReads.push({lng:e,ns:t,fcName:r,tried:n,wait:a,callback:o});this.readingCalls++;let i=(i,s)=>{if(this.readingCalls--,this.waitingReads.length>0){let e=this.waitingReads.shift();this.read(e.lng,e.ns,e.fcName,e.tried,e.wait,e.callback)}i&&s&&n<this.maxRetries?setTimeout(()=>{this.read.call(this,e,t,r,n+1,2*a,o)},a):o(i,s)},s=this.backend[r].bind(this.backend);if(2===s.length){try{let r=s(e,t);r&&"function"==typeof r.then?r.then(e=>i(null,e)).catch(i):i(null,r)}catch(e){i(e)}return}return s(e,t,i)}prepareLoading(e,t,r={},n){if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),n&&n();aE(e)&&(e=this.languageUtils.toResolveHierarchy(e)),aE(t)&&(t=[t]);let a=this.queueLoad(e,t,r,n);if(!a.toLoad.length)return a.pending.length||n(),null;a.toLoad.forEach(e=>{this.loadOne(e)})}load(e,t,r){this.prepareLoading(e,t,{},r)}reload(e,t,r){this.prepareLoading(e,t,{reload:!0},r)}loadOne(e,t=""){let r=e.split("|"),n=r[0],a=r[1];this.read(n,a,"read",void 0,void 0,(r,o)=>{r&&this.logger.warn(`${t}loading namespace ${a} for language ${n} failed`,r),!r&&o&&this.logger.log(`${t}loaded namespace ${a} for language ${n}`,o),this.loaded(e,r,o)})}saveMissing(e,t,r,n,a,o={},i=()=>{}){if(this.services?.utils?.hasLoadedNamespace&&!this.services?.utils?.hasLoadedNamespace(t))return void this.logger.warn(`did not save key "${r}" as the namespace "${t}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");if(null!=r&&""!==r){if(this.backend?.create){let s={...o,isUpdate:a},l=this.backend.create.bind(this.backend);if(l.length<6)try{let a;(a=5===l.length?l(e,t,r,n,s):l(e,t,r,n))&&"function"==typeof a.then?a.then(e=>i(null,e)).catch(i):i(null,a)}catch(e){i(e)}else l(e,t,r,n,i,s)}e&&e[0]&&this.store.addResource(e[0],t,r,n)}}}let a3=()=>({debug:!1,initAsync:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:e=>{let t={};if("object"==typeof e[1]&&(t=e[1]),aE(e[1])&&(t.defaultValue=e[1]),aE(e[2])&&(t.tDescription=e[2]),"object"==typeof e[2]||"object"==typeof e[3]){let r=e[3]||e[2];Object.keys(r).forEach(e=>{t[e]=r[e]})}return t},interpolation:{escapeValue:!0,format:e=>e,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0},cacheInBuiltFormats:!0}),a6=e=>(aE(e.ns)&&(e.ns=[e.ns]),aE(e.fallbackLng)&&(e.fallbackLng=[e.fallbackLng]),aE(e.fallbackNS)&&(e.fallbackNS=[e.fallbackNS]),e.supportedLngs?.indexOf?.("cimode")<0&&(e.supportedLngs=e.supportedLngs.concat(["cimode"])),"boolean"==typeof e.initImmediate&&(e.initAsync=e.initImmediate),e),a5=()=>{};class a9 extends aB{constructor(e={},t){if(super(),this.options=a6(e),this.services={},this.logger=aF,this.modules={external:[]},(e=>{Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach(t=>{"function"==typeof e[t]&&(e[t]=e[t].bind(e))})})(this),t&&!this.isInitialized&&!e.isClone){if(!this.options.initAsync)return this.init(e,t),this;setTimeout(()=>{this.init(e,t)},0)}}init(e={},t){this.isInitializing=!0,"function"==typeof e&&(t=e,e={}),null==e.defaultNS&&e.ns&&(aE(e.ns)?e.defaultNS=e.ns:0>e.ns.indexOf("translation")&&(e.defaultNS=e.ns[0]));let r=a3();this.options={...r,...this.options,...a6(e)},this.options.interpolation={...r.interpolation,...this.options.interpolation},void 0!==e.keySeparator&&(this.options.userDefinedKeySeparator=e.keySeparator),void 0!==e.nsSeparator&&(this.options.userDefinedNsSeparator=e.nsSeparator);let n=e=>e?"function"==typeof e?new e:e:null;if(!this.options.isClone){let e;this.modules.logger?aF.init(n(this.modules.logger),this.options):aF.init(null,this.options),e=this.modules.formatter?this.modules.formatter:a4;let t=new aZ(this.options);this.store=new aV(this.options.resources,this.options);let a=this.services;a.logger=aF,a.resourceStore=this.store,a.languageUtils=t,a.pluralResolver=new aJ(t,{prepend:this.options.pluralSeparator,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),this.options.interpolation.format&&this.options.interpolation.format!==r.interpolation.format&&this.logger.deprecate("init: you are still using the legacy format function, please use the new approach: https://www.i18next.com/translation-function/formatting"),e&&(!this.options.interpolation.format||this.options.interpolation.format===r.interpolation.format)&&(a.formatter=n(e),a.formatter.init&&a.formatter.init(a,this.options),this.options.interpolation.format=a.formatter.format.bind(a.formatter)),a.interpolator=new aQ(this.options),a.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},a.backendConnector=new a2(n(this.modules.backend),a.resourceStore,a,this.options),a.backendConnector.on("*",(e,...t)=>{this.emit(e,...t)}),this.modules.languageDetector&&(a.languageDetector=n(this.modules.languageDetector),a.languageDetector.init&&a.languageDetector.init(a,this.options.detection,this.options)),this.modules.i18nFormat&&(a.i18nFormat=n(this.modules.i18nFormat),a.i18nFormat.init&&a.i18nFormat.init(this)),this.translator=new aG(this.services,this.options),this.translator.on("*",(e,...t)=>{this.emit(e,...t)}),this.modules.external.forEach(e=>{e.init&&e.init(this)})}if(this.format=this.options.interpolation.format,t||(t=a5),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){let e=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);e.length>0&&"dev"!==e[0]&&(this.options.lng=e[0])}this.services.languageDetector||this.options.lng||this.logger.warn("init: no languageDetector is used and no lng is defined"),["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach(e=>{this[e]=(...t)=>this.store[e](...t)}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(e=>{this[e]=(...t)=>(this.store[e](...t),this)});let a=ax(),o=()=>{let e=(e,r)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=!0,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),a.resolve(r),t(e,r)};if(this.languages&&!this.isInitialized)return e(null,this.t.bind(this));this.changeLanguage(this.options.lng,e)};return this.options.resources||!this.options.initAsync?o():setTimeout(o,0),a}loadResources(e,t=a5){let r=t,n=aE(e)?e:this.language;if("function"==typeof e&&(r=e),!this.options.resources||this.options.partialBundledLanguages){if(n?.toLowerCase()==="cimode"&&(!this.options.preload||0===this.options.preload.length))return r();let e=[],t=t=>{t&&"cimode"!==t&&this.services.languageUtils.toResolveHierarchy(t).forEach(t=>{"cimode"!==t&&0>e.indexOf(t)&&e.push(t)})};n?t(n):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(e=>t(e)),this.options.preload?.forEach?.(e=>t(e)),this.services.backendConnector.load(e,this.options.ns,e=>{e||this.resolvedLanguage||!this.language||this.setResolvedLanguage(this.language),r(e)})}else r(null)}reloadResources(e,t,r){let n=ax();return"function"==typeof e&&(r=e,e=void 0),"function"==typeof t&&(r=t,t=void 0),e||(e=this.languages),t||(t=this.options.ns),r||(r=a5),this.services.backendConnector.reload(e,t,e=>{n.resolve(),r(e)}),n}use(e){if(!e)throw Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!e.type)throw Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return"backend"===e.type&&(this.modules.backend=e),("logger"===e.type||e.log&&e.warn&&e.error)&&(this.modules.logger=e),"languageDetector"===e.type&&(this.modules.languageDetector=e),"i18nFormat"===e.type&&(this.modules.i18nFormat=e),"postProcessor"===e.type&&aU.addPostProcessor(e),"formatter"===e.type&&(this.modules.formatter=e),"3rdParty"===e.type&&this.modules.external.push(e),this}setResolvedLanguage(e){if(e&&this.languages&&!(["cimode","dev"].indexOf(e)>-1)){for(let e=0;e<this.languages.length;e++){let t=this.languages[e];if(!(["cimode","dev"].indexOf(t)>-1)&&this.store.hasLanguageSomeTranslations(t)){this.resolvedLanguage=t;break}}!this.resolvedLanguage&&0>this.languages.indexOf(e)&&this.store.hasLanguageSomeTranslations(e)&&(this.resolvedLanguage=e,this.languages.unshift(e))}}changeLanguage(e,t){this.isLanguageChangingTo=e;let r=ax();this.emit("languageChanging",e);let n=e=>{this.language=e,this.languages=this.services.languageUtils.toResolveHierarchy(e),this.resolvedLanguage=void 0,this.setResolvedLanguage(e)},a=(a,o)=>{o?this.isLanguageChangingTo===e&&(n(o),this.translator.changeLanguage(o),this.isLanguageChangingTo=void 0,this.emit("languageChanged",o),this.logger.log("languageChanged",o)):this.isLanguageChangingTo=void 0,r.resolve((...e)=>this.t(...e)),t&&t(a,(...e)=>this.t(...e))},o=t=>{e||t||!this.services.languageDetector||(t=[]);let r=aE(t)?t:t&&t[0],o=this.store.hasLanguageSomeTranslations(r)?r:this.services.languageUtils.getBestMatchFromCodes(aE(t)?[t]:t);o&&(this.language||n(o),this.translator.language||this.translator.changeLanguage(o),this.services.languageDetector?.cacheUserLanguage?.(o)),this.loadResources(o,e=>{a(e,o)})};return e||!this.services.languageDetector||this.services.languageDetector.async?!e&&this.services.languageDetector&&this.services.languageDetector.async?0===this.services.languageDetector.detect.length?this.services.languageDetector.detect().then(o):this.services.languageDetector.detect(o):o(e):o(this.services.languageDetector.detect()),r}getFixedT(e,t,r){let n=(e,t,...a)=>{let o,i;(o="object"!=typeof t?this.options.overloadTranslationOptionHandler([e,t].concat(a)):{...t}).lng=o.lng||n.lng,o.lngs=o.lngs||n.lngs,o.ns=o.ns||n.ns,""!==o.keyPrefix&&(o.keyPrefix=o.keyPrefix||r||n.keyPrefix);let s=this.options.keySeparator||".";return o.keyPrefix&&Array.isArray(e)?i=e.map(e=>("function"==typeof e&&(e=aH(e,{...this.options,...t})),`${o.keyPrefix}${s}${e}`)):("function"==typeof e&&(e=aH(e,{...this.options,...t})),i=o.keyPrefix?`${o.keyPrefix}${s}${e}`:e),this.t(i,o)};return aE(e)?n.lng=e:n.lngs=e,n.ns=t,n.keyPrefix=r,n}t(...e){return this.translator?.translate(...e)}exists(...e){return this.translator?.exists(...e)}setDefaultNamespace(e){this.options.defaultNS=e}hasLoadedNamespace(e,t={}){if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;let r=t.lng||this.resolvedLanguage||this.languages[0],n=!!this.options&&this.options.fallbackLng,a=this.languages[this.languages.length-1];if("cimode"===r.toLowerCase())return!0;let o=(e,t)=>{let r=this.services.backendConnector.state[`${e}|${t}`];return -1===r||0===r||2===r};if(t.precheck){let e=t.precheck(this,o);if(void 0!==e)return e}return!!(this.hasResourceBundle(r,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||o(r,e)&&(!n||o(a,e)))}loadNamespaces(e,t){let r=ax();return this.options.ns?(aE(e)&&(e=[e]),e.forEach(e=>{0>this.options.ns.indexOf(e)&&this.options.ns.push(e)}),this.loadResources(e=>{r.resolve(),t&&t(e)}),r):(t&&t(),Promise.resolve())}loadLanguages(e,t){let r=ax();aE(e)&&(e=[e]);let n=this.options.preload||[],a=e.filter(e=>0>n.indexOf(e)&&this.services.languageUtils.isSupportedCode(e));return a.length?(this.options.preload=n.concat(a),this.loadResources(e=>{r.resolve(),t&&t(e)}),r):(t&&t(),Promise.resolve())}dir(e){if(e||(e=this.resolvedLanguage||(this.languages?.length>0?this.languages[0]:this.language)),!e)return"rtl";try{let t=new Intl.Locale(e);if(t&&t.getTextInfo){let e=t.getTextInfo();if(e&&e.direction)return e.direction}}catch(e){}let t=this.services?.languageUtils||new aZ(a3());return e.toLowerCase().indexOf("-latn")>1?"ltr":["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"].indexOf(t.getLanguagePartFromCode(e))>-1||e.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(e={},t){return new a9(e,t)}cloneInstance(e={},t=a5){let r=e.forkResourceStore;r&&delete e.forkResourceStore;let n={...this.options,...e,isClone:!0},a=new a9(n);return(void 0!==e.debug||void 0!==e.prefix)&&(a.logger=a.logger.clone(e)),["store","services","language"].forEach(e=>{a[e]=this[e]}),a.services={...this.services},a.services.utils={hasLoadedNamespace:a.hasLoadedNamespace.bind(a)},r&&(a.store=new aV(Object.keys(this.store.data).reduce((e,t)=>(e[t]={...this.store.data[t]},e[t]=Object.keys(e[t]).reduce((r,n)=>(r[n]={...e[t][n]},r),e[t]),e),{}),n),a.services.resourceStore=a.store),a.translator=new aG(a.services,n),a.translator.on("*",(e,...t)=>{a.emit(e,...t)}),a.init(n,t),a.translator.options=n,a.translator.backendConnector.services.utils={hasLoadedNamespace:a.hasLoadedNamespace.bind(a)},a}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}let a8=a9.createInstance();a8.createInstance=a9.createInstance,a8.createInstance,a8.dir,a8.init,a8.loadResources,a8.reloadResources,a8.use,a8.changeLanguage,a8.getFixedT,a8.t,a8.exists,a8.setDefaultNamespace,a8.hasLoadedNamespace,a8.loadNamespaces,a8.loadLanguages;let a7=a8.default||a8;function oe(e,t,r,n){return a7.t(t,{ns:e,defaultValue:r,...n})}function ot(e,t,r){return aw[e]?oe("core",e,t??aw[e],r):(console.error(`O3 Core Translations does not provide key '${e}'. The key itself is being rendered as text.`),e)}function or(e,t){let r=window.getOpenmrsSpaBase().replace(/\/$/,""),n=on(e,{openmrsBase:window.openmrsBase,openmrsSpaBase:r,...t});return e.startsWith("//")?n:n.replace(/^\/\//,"/")}function on(e,t){return Object.keys(t).reduce((e,r)=>e.split("${"+r+"}").join(t[r]),e)}function oa({to:e,templateParams:t}){let r=window.getOpenmrsSpaBase().replace(/\/$/,""),n=or(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(ot("navigateNonHttp"));n.startsWith(r)?nY(n):window.location.assign(n)}a7.on("initialized",function(){window.i18next.loadNamespaces(["core"])});let oo="openmrs:history";function oi(e){let t=JSON.parse(sessionStorage.getItem(oo)??"[]")||[];t.push(e),t.length>50&&(t=t.slice(-50)),sessionStorage.setItem(oo,JSON.stringify(t))}function os(){0===JSON.parse(sessionStorage.getItem(oo)??"[]").length&&document.referrer&&oi(document.referrer),window.addEventListener("single-spa:routing-event",e=>{let t=ol();e.detail.originalEvent?.singleSpaTrigger=="replaceState"?(t[t.length-1]=window.location.href,sessionStorage.setItem(oo,JSON.stringify(t))):!e.detail.originalEvent?.singleSpa&&t.includes(window.location.href)?ou({toUrl:window.location.href}):t[t.length-1]!==window.location.href&&oi(window.location.href)})}function ol(){return JSON.parse(sessionStorage.getItem(oo)??"[]")}function ou({toUrl:e}){let t=ol(),r=t.lastIndexOf(e);if(-1!=r){let e=t.slice(0,r+1);oa({to:t[r]}),sessionStorage.setItem(oo,JSON.stringify(e))}else throw Error(`URL ${e} not found in history; cannot go back to it.`)}function oc(){sessionStorage.removeItem(oo)}let od="${openmrsSpaBase}/login",op={redirectAuthFailure:{enabled:{_type:tW.Boolean,_default:!0,_description:"Whether to redirect logged-out users to `redirectAuthFailure.url`"},url:{_type:tW.String,_default:od,_validators:[rq.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:tW.Array,_default:[401],_elements:{_type:tW.Number,_validators:[rq.inRange(100,600)]},_description:"The HTTP error codes for which users will be redirected"},resolvePromise:{_type:tW.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:tW.Boolean,_default:!0,_description:"Whether openmrsFetch should support redirects returned from the backend"}};function om(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}let of="/ws/rest/v1",oh="/ws/fhir2/R4",og=`${of}/session`;function oy(e){return e&&e.startsWith("http")?e:("/"!==e[0]&&(e="/"+e),window.openmrsBase+e)}function ov(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=oy(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(oy(of),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(oh)){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 rS("@openmrs/esm-api");if(e.ok){let t=e.headers.get("location");return(o&&t&&(r===oy(og)||204===e.status)&&oa({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===oy(og)&&403===e.status||n.enabled&&n.errors.includes(e.status))&&(oc(),oa({to:n.url||e.headers.get("location")||od}),!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 ob(r,e,n,a)},()=>{throw new ob(r,e,null,a)})})}class ob extends Error{constructor(e,t,r,n){super(),om(this,"response",void 0),om(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 ow=V("session",{loaded:!1,session:null}),oE=0,ox=null;function oD(){return ox||(ow.getState().loaded&&oE>=Date.now()-6e4?null:ok())}function oS(e){let t=e?.includeAuthStatus??!0,r=e=>t?e:e.user,n=oD();return n?new Promise(e=>{let t=()=>{let t=ow.getState();t.loaded&&(a(),e(r(t.session)))},a=ow.subscribe(t);n.then(t,t)}):Promise.resolve(r(ow.getState().session))}function o_(){return oD(),ow}function oC(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 ok(e,t){oE=Date.now(),o??(o=oE);let r={};e&&t&&(r.Authorization=`Basic ${window.btoa(`${e}:${t}`)}`);let n=oj(ov(og,{headers:r,rejectAuthFailure:!0})),a=()=>{ox===n&&(ox=null)};return n.then(a,a),ox=n,n}function oP(){ow.setState({loaded:!0,session:{authenticated:!1,sessionId:""}},!0)}function oR(e,t){var r,n;if(void 0===t)return!e;if(!e)return!0;return r=e,n=t,("string"==typeof r?!G(n.privileges.find(e=>r===e.display)):Array.isArray(r)?r.every(e=>!G(n.privileges.find(t=>e===t.display))):(G(r)||console.error(`Could not understand privileges "${r}"`),!0))||!G(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(ow.getState()),e||(t=ow.subscribe(n))})}async function oO(){return(await oS()).sessionLocation}async function o$(e,t){return oj(ov(og,{method:"POST",body:{sessionLocation:e},headers:{"Content-Type":"application/json"},rejectAuthFailure:!0,signal:t?.signal}))}async function oN(e,t){return await ov(og,{method:"POST",body:{locale:e},headers:{"Content-Type":"application/json"},signal:t?.signal}),ok()}async function oI(e,t,r){return r||(r=new AbortController),await ov(`${of}/user/${e}`,{method:"POST",body:{userProperties:t},headers:{"Content-Type":"application/json"},signal:r.signal}),ok()}async function oA(e,t=!1){let r=await ov(t?`${og}?rememberMe=true`:og,{headers:{"X-Totp-Code":e}});return r.data?.authenticated?(await ok()).session:r.data}async function oM(){try{await ov(og,{method:"DELETE",rejectAuthFailure:!0})}catch(e){if(!oL(e))throw e}oP(),await ok().catch(()=>{})}function oj(e){return new Promise((t,r)=>{e.then(e=>{if("object"==typeof e?.data){let r={loaded:!0,session:e.data};ow.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(oF(Error("The session endpoint did not respond with a session"))):r(oF(Error("The server is still starting up"),!0))}).catch(e=>{var n,a;if(oL(e)){"object"==typeof(n=e.responseBody)&&null!==n&&!1===n.authenticated?ow.setState({loaded:!0,session:e.responseBody},!0):oP(),t(ow.getState());return}(a=e)instanceof ob&&502===a.response.status&&!ow.getState().loaded&&void 0!==o&&Date.now()-o<18e4?r(oF(e,!0)):(P(`Failed to fetch new session information: ${e}`),r(oF(e)))})})}function oL(e){return e instanceof ob&&(401===e.response.status||403===e.response.status)}function oF(e,t=!1){return ow.getState().loaded||ow.setState({loaded:!1,session:null,error:e instanceof Error?e:Error(String(e)),initializing:t},!0),ow.getState()}function oB(){return"development"===window.spaEnv||"true"===localStorage.getItem("openmrs:devtools")}ow.subscribe(e=>{e.loaded&&e.session&&oC(e.session)});let oV={"webservices.rest":"2.24.0",fhir2:"1.0.0-SNAPSHOT"};function oU(){ry("@openmrs/esm-api",op),ok()}let oW="import-map-override:",oH="import-map-overrides-disabled",oz="import-map-overrides:change",oK=!1,oG=null,oZ=null;async function oY(){return oZ??(oZ=oq().then(({map:e,complete:t})=>(t||(oZ=null),e))),oZ}async function oq(){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:oJ(t),complete:r}}function oJ(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=o2();for(let r=0;r<localStorage.length;r++){let n=localStorage.key(r);if(n?.startsWith(oW)){let r=n.slice(oW.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 oQ(){let e=await oY();return oK?oJ([e,oG??oX()]):e}async function o0(){return oY()}async function o1(){return oK?oJ([await oY(),oX()]):oY()}function o4(e){if(!oK)return{imports:{}};if(e){let e={};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)}}return{imports:e}}return oX()}function o2(){if(!oK)return[];try{let e=localStorage.getItem(oH);if(e){let t=JSON.parse(e);if(Array.isArray(t))return t}}catch{}return[]}function o3(e){return!!oK&&o2().includes(e)}function o6(e,t){if(!oK)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{localStorage.setItem(oW+e,t),window.dispatchEvent(new CustomEvent(oz))}catch(e){console.warn("[import-maps] Failed to write import-map override to localStorage",e)}}function o5(e){if(!oK)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{localStorage.removeItem(oW+e);let t=o2().filter(t=>t!==e);t.length>0?localStorage.setItem(oH,JSON.stringify(t)):localStorage.removeItem(oH),window.dispatchEvent(new CustomEvent(oz))}catch(e){console.warn("[import-maps] Failed to update import-map overrides in localStorage",e)}}function o9(){if(!oK)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(oW)&&e.push(r)}e.forEach(e=>localStorage.removeItem(e)),localStorage.removeItem(oH),window.dispatchEvent(new CustomEvent(oz))}catch(e){console.warn("[import-maps] Failed to clear import-map overrides from localStorage",e)}}function o8(e){if(!oK)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{let t=o2().filter(t=>t!==e);t.length>0?localStorage.setItem(oH,JSON.stringify(t)):localStorage.removeItem(oH),window.dispatchEvent(new CustomEvent(oz))}catch(e){console.warn("[import-maps] Failed to update import-map overrides in localStorage",e)}}let o7=!1;function ie(){!o7&&(o7=!0,(oK="development"===window.spaEnv)&&(oG=oX()))}function it(e){return e.replace(/[\/\-@]/g,"_")}async function ir(e,t="./start",n){var a;let o,i=!n?.maxLoadingTime||n.maxLoadingTime<=0?6e5:n.maxLoadingTime;await Promise.race([ia(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=it(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 ia(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=it(e);if(!window[r]){let r=t??await io();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 o4().imports;try{return await function(e){var t;let r=(t=window)[ii]??(t[ii]=new Map),n=r.get(e);if(n)return n;if(document.head.querySelector(`script[src="${e}"]`))return console.warn(`Script at ${e} already loaded. Not loading it again.`),Promise.resolve();let a=document.createElement("script");a.src=e,a.type="text/javascript",a.async=!0;let o=new Promise((t,n)=>{let o=setTimeout(()=>{console.error(`The script at ${e} did not load within 5 seconds. This may indicate an issue with the imports in the script's entry-point file or with the script's bundler configuration.`)},5e3);function i(){clearTimeout(o),a.removeEventListener("load",s),a.removeEventListener("error",l)}function s(){i(),t()}function l(t){i(),r.delete(e),a.remove();let o=`Failed to load script from ${e}`;console.error(o,t),n(t.message??o)}a.addEventListener("load",s),a.addEventListener("error",l),document.head.appendChild(a)});return r.set(e,o),o}(n)}catch(e){return a&&x({kind:"error",title:ot("scriptLoadingFailed","Error: Script failed to load"),description:ot("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:ot("resetOverrides","Reset overrides"),onActionButtonClick(){o9(),window.location.reload()}}),Promise.reject(e)}}return Promise.resolve()}async function io(){return oQ()}let ii=Symbol.for("__openmrs_script_loading");function is(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 il(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&&is(t))}let iu="openmrs-routes:",ic="openmrs-routes:change",id=!1,ip=null,im=null;async function ih(){return im??(im=ig().then(({map:e,complete:t})=>(t||(im=null),e))),im}async function ig(){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&&il(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:iy(t),complete:r}}function iy(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 iv(){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(iu)){let e=localStorage.getItem(r);e&&t.push({moduleName:r.slice(iu.length),raw:e})}}for(let r of(await Promise.allSettled(t.map(async({moduleName:e,raw:t})=>{let r=JSON.parse(t);if(is(r))return{moduleName:e,routes:r};if("string"==typeof r&&r.startsWith("http")){let t=await fetch(r),n=await t.json();if(is(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 ib(){let e=await ih();return id?iy([e,ip??await iv()]):e}async function iw(){return ih()}async function iE(){return id?iy([await ih(),await iv()]):ih()}function ix(){if(!id)return{};let e={};try{for(let t=0;t<localStorage.length;t++){let r=localStorage.key(t);if(r?.startsWith(iu)){let t=localStorage.getItem(r);t&&(e[r.slice(iu.length)]=t)}}}catch(e){console.warn("[route-maps] Failed to read route overrides from localStorage",e)}return e}function iD(e,t){if(!id)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{if("string"==typeof t)if(t.startsWith("http"))localStorage.setItem(iu+e,JSON.stringify(t));else{let r=JSON.parse(t);if(!is(r))return void console.error(`The supplied routes for ${e} is not a valid OpenmrsAppRoutes object`,t);localStorage.setItem(iu+e,JSON.stringify(r))}else if(t instanceof URL)localStorage.setItem(iu+e,JSON.stringify(t.toString()));else{if(!is(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(iu+e,JSON.stringify(t))}window.dispatchEvent(new CustomEvent(ic))}catch(e){console.warn("[route-maps] Failed to write route override to localStorage",e)}}function iS(e){if(!id)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{localStorage.removeItem(iu+e),window.dispatchEvent(new CustomEvent(ic))}catch(e){console.warn("[route-maps] Failed to remove route override from localStorage",e)}}function i_(){if(!id)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(iu)&&e.push(r)}e.forEach(e=>localStorage.removeItem(e)),window.dispatchEvent(new CustomEvent(ic))}catch(e){console.warn("[route-maps] Failed to clear route overrides from localStorage",e)}}let iC=null;function ik(){return iC||(iC=(id="development"===window.spaEnv)?iv().then(e=>{ip=e}):Promise.resolve())}let iP=`${of}/attachment`;function iR(e,t){return ov(`${iP}/${e}`,{signal:t.signal})}function iT(e,t,r,n){return ov(iO(e,t,n),{signal:r.signal})}function iO(e,t,r){return r?`${iP}?patient=${e}&encounter=${r}`:`${iP}?patient=${e}&includeEncounterless=${t}`}async function i$(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)),ov(`${iP}`,{method:"POST",body:n})}function iN(e,t){return ov(`${iP}/${e}`,{method:"DELETE",signal:t.signal})}async function iI(e,t){return e?(await ov(`${oh}/Patient/${e}`,t)).data:null}function iA(e,t){let r=new CustomEvent(`openmrs:${e}`,{detail:t??void 0,cancelable:!0,bubbles:!0});return window.dispatchEvent(r)}function iM(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 ij(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 ov(`${of}/location${n?"?"+n:""}`).then(e=>e.data.results.map(ij))}function iF(e){return{uuid:e.uuid,display:e.display,name:e.name}}let iB=`${of}/visittype`;function iV(e=iB){return ov(e).then(e=>e.data.results.map(iF))}var iU=((X={}).NEWVISIT="startVisit",X.EDITVISIT="editVisit",X.LOADING="loadingVisit",X),iW=((Q={}).NOTSTARTED="notStarted",Q.ONGOING="ongoing",Q);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))",iz=function(){try{return JSON.parse(sessionStorage.getItem("openmrs:visitStoreState")||"null")}catch(e){return null}}()||{patientUuid:null,manuallySetVisitUuid:null};function iK(){return H("visit",iz)}function iG(e,t){iK().setState({patientUuid:e,manuallySetVisitUuid:t})}function iZ(e,t){return ov(`${of}/visit`,{signal:t.signal,method:"POST",headers:{"Content-type":"application/json"},body:e})}function iY(e,t,r){return ov(`${of}/visit/${e}`,{signal:r.signal,method:"POST",headers:{"Content-type":"application/json"},body:t})}function iq(e,t,r){return ov(`${of}/visit?patient=${e}&v=${r??iH}`,{signal:t.signal,method:"GET",headers:{"Content-type":"application/json"}})}iK().subscribe(e=>{var t;t=e,sessionStorage.setItem("openmrs:visitStoreState",JSON.stringify(t))});class iJ{static get version(){return"1.4.0"}static toString(){return"JavaScript Expression Parser (JSEP) v"+iJ.version}static addUnaryOp(e){return iJ.max_unop_len=Math.max(e.length,iJ.max_unop_len),iJ.unary_ops[e]=1,iJ}static addBinaryOp(e,t,r){return iJ.max_binop_len=Math.max(e.length,iJ.max_binop_len),iJ.binary_ops[e]=t,r?iJ.right_associative.add(e):iJ.right_associative.delete(e),iJ}static addIdentifierChar(e){return iJ.additional_identifier_chars.add(e),iJ}static addLiteral(e,t){return iJ.literals[e]=t,iJ}static removeUnaryOp(e){return delete iJ.unary_ops[e],e.length===iJ.max_unop_len&&(iJ.max_unop_len=iJ.getMaxKeyLen(iJ.unary_ops)),iJ}static removeAllUnaryOps(){return iJ.unary_ops={},iJ.max_unop_len=0,iJ}static removeIdentifierChar(e){return iJ.additional_identifier_chars.delete(e),iJ}static removeBinaryOp(e){return delete iJ.binary_ops[e],e.length===iJ.max_binop_len&&(iJ.max_binop_len=iJ.getMaxKeyLen(iJ.binary_ops)),iJ.right_associative.delete(e),iJ}static removeAllBinaryOps(){return iJ.binary_ops={},iJ.max_binop_len=0,iJ}static removeLiteral(e){return delete iJ.literals[e],iJ}static removeAllLiterals(){return iJ.literals={},iJ}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 iJ(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 iJ.binary_ops[e]||0}static isIdentifierStart(e){return e>=65&&e<=90||e>=97&&e<=122||e>=128&&!iJ.binary_ops[String.fromCharCode(e)]||iJ.additional_identifier_chars.has(String.fromCharCode(e))}static isIdentifierPart(e){return iJ.isIdentifierStart(e)||iJ.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(iJ.hooks[e]){let r={context:this,node:t};return iJ.hooks.run(e,r),r.node}return t}searchHook(e){if(iJ.hooks[e]){let t={context:this};return iJ.hooks[e].find(function(e){return e.call(t.context,t),t.node}),t.node}}gobbleSpaces(){let e=this.code;for(;e===iJ.SPACE_CODE||e===iJ.TAB_CODE||e===iJ.LF_CODE||e===iJ.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:iJ.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)===iJ.SEMCOL_CODE||r===iJ.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,iJ.max_binop_len),t=e.length;for(;t>0;){if(iJ.binary_ops.hasOwnProperty(e)&&(!iJ.isIdentifierStart(this.code)||this.index+e.length<this.expr.length&&!iJ.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:iJ.binaryPrecedence(t),right_a:iJ.right_associative.has(t)},(i=this.gobbleToken())||this.throwError("Expected expression after "+t),n=[o,a,i];t=this.gobbleBinaryOp();){if(0===(r=iJ.binaryPrecedence(t))){this.index-=t.length;break}a={value:t,prec:r,right_a:iJ.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:iJ.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:iJ.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,iJ.isDecimalDigit(e)||e===iJ.PERIOD_CODE)return this.gobbleNumericLiteral();if(e===iJ.SQUOTE_CODE||e===iJ.DQUOTE_CODE)n=this.gobbleStringLiteral();else if(e===iJ.OBRACK_CODE)n=this.gobbleArray();else{for(r=(t=this.expr.substr(this.index,iJ.max_unop_len)).length;r>0;){if(iJ.unary_ops.hasOwnProperty(t)&&(!iJ.isIdentifierStart(this.code)||this.index+t.length<this.expr.length&&!iJ.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:iJ.UNARY_EXP,operator:t,argument:e,prefix:!0})}t=t.substr(0,--r)}iJ.isIdentifierStart(e)?(n=this.gobbleIdentifier(),iJ.literals.hasOwnProperty(n.name)?n={type:iJ.LITERAL,value:iJ.literals[n.name],raw:n.name}:n.name===iJ.this_str&&(n={type:iJ.THIS_EXP})):e===iJ.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===iJ.PERIOD_CODE||t===iJ.OBRACK_CODE||t===iJ.OPAREN_CODE||t===iJ.QUMARK_CODE;){let r;if(t===iJ.QUMARK_CODE){if(this.expr.charCodeAt(this.index+1)!==iJ.PERIOD_CODE)break;r=!0,this.index+=2,this.gobbleSpaces(),t=this.code}this.index++,t===iJ.OBRACK_CODE?((e={type:iJ.MEMBER_EXP,computed:!0,object:e,property:this.gobbleExpression()}).property||this.throwError('Unexpected "'+this.char+'"'),this.gobbleSpaces(),(t=this.code)!==iJ.CBRACK_CODE&&this.throwError("Unclosed ["),this.index++):t===iJ.OPAREN_CODE?e={type:iJ.CALL_EXP,arguments:this.gobbleArguments(iJ.CPAREN_CODE),callee:e}:(t===iJ.PERIOD_CODE||r)&&(r&&this.index--,this.gobbleSpaces(),e={type:iJ.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(;iJ.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);if(this.code===iJ.PERIOD_CODE)for(e+=this.expr.charAt(this.index++);iJ.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++));iJ.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);iJ.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+e+this.char+")")}return r=this.code,iJ.isIdentifierStart(r)?this.throwError("Variable names cannot start with a number ("+e+this.char+")"):(r===iJ.PERIOD_CODE||1===e.length&&e.charCodeAt(0)===iJ.PERIOD_CODE)&&this.throwError("Unexpected period"),{type:iJ.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:iJ.LITERAL,value:e,raw:this.expr.substring(t,this.index)}}gobbleIdentifier(){let e=this.code,t=this.index;for(iJ.isIdentifierStart(e)?this.index++:this.throwError("Unexpected "+this.char);this.index<this.expr.length;)if(e=this.code,iJ.isIdentifierPart(e))this.index++;else break;return{type:iJ.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===iJ.CPAREN_CODE&&n&&n>=t.length&&this.throwError("Unexpected token "+String.fromCharCode(e));break}if(a===iJ.COMMA_CODE){if(this.index++,++n!==t.length){if(e===iJ.CPAREN_CODE)this.throwError("Unexpected token ,");else if(e===iJ.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!==iJ.COMPOUND||this.throwError("Expected comma"),t.push(e)}}return r||this.throwError("Expected "+String.fromCharCode(e)),t}gobbleGroup(){this.index++;let e=this.gobbleExpressions(iJ.CPAREN_CODE);if(this.code===iJ.CPAREN_CODE)return(this.index++,1===e.length)?e[0]:!!e.length&&{type:iJ.SEQUENCE_EXP,expressions:e};this.throwError("Unclosed (")}gobbleArray(){return this.index++,{type:iJ.ARRAY_EXP,elements:this.gobbleArguments(iJ.CBRACK_CODE)}}}Object.assign(iJ,{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)})}}(iJ),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"}),iJ.max_unop_len=iJ.getMaxKeyLen(iJ.unary_ops),iJ.max_binop_len=iJ.getMaxKeyLen(iJ.binary_ops);let iX=e=>new iJ(e).parse(),iQ=Object.getOwnPropertyNames(class{});Object.getOwnPropertyNames(iJ).filter(e=>!iQ.includes(e)&&void 0===iX[e]).forEach(e=>{iX[e]=iJ[e]}),iX.Jsep=iJ,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 i0="ArrowFunctionExpression",i1={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)}},i4={...i1,Promise};function i2(e,t={}){return i7(e,t,sr)}async function i3(e,t={}){return se(e,t,sr)}function i6(e,t={}){return i7(e,t,sn)}function i5(e,t={}){return se(e,t,sn)}function i9(e,t={}){return i7(e,t,sa)}function i8(e,t={}){return se(e,t,sa)}function i7(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=su(t,i1),a=so("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 se(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=su(t,i4);return Promise.resolve(so("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 st(e){return iX(e)}function sr(e){return"string"==typeof e||"number"==typeof e||"boolean"==typeof e||null==e||e instanceof Date}function sn(e){return"boolean"==typeof e}function sa(e){return"number"==typeof e}function so(e,t){switch(e.type){case"UnaryExpression":var r,n,a,o,i,s,l,u,c,d,p,m,f,h=e,g=t;let y=so(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 so(v.left,b)&&so(v.right,b);case"||":return so(v.left,b)||so(v.right,b);case"??":return so(v.left,b)??so(v.right,b)}let w=so(v.left,b),E=so(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,so(r.test,n)?so(r.consequent,n):so(r.alternate,n);case"CallExpression":return sp(ss(e,t));case"ArrowFunctionExpression":let x;return a=e,o=t,x=a.params?.map(e=>{if("Identifier"===e.type)return e.name;throw`Cannot handle parameter of type ${e.type}`})??[],(function(...e){if(e.length<x.length)throw`Required argument(s) ${x.slice(e.length,-1).join(", ")} were not provided`;let t=Object.fromEntries(x.reduce((t,r,n)=>{let a=e[n];return function e(t){if("string"==typeof t||"number"==typeof t||"boolean"==typeof t||"function"==typeof t||null===t||t instanceof RegExp)return!0;if("object"==typeof t){for(let r of Object.keys(t))if(!e(t[r]))return!1;return!0}if(Array.isArray(t)){for(let r of t)if(!e(r))break}return!1}(a)&&t.push([r,a]),t},[]));return so(a.body,o.addVariables(t))}).bind(null);case"MemberExpression":return sp(sl(e,t));case"ArrayExpression":return i=e,s=t,i.elements?.map(sm(s));case"SequenceExpression":let D;return l=e,u=t,(D=l.expressions.map(sm(u)))[D.length-1];case"NewExpression":var S=e,_=t;if(S.callee&&"Identifier"===S.callee.type){let e=S.arguments?.map(sm(_));switch(S.callee.name){case"Date":return new Date(...e);case"RegExp":return new RegExp(...e);default:throw`Cannot instantiate object of type ${S.callee.name}`}}if(S.callee)throw"new must be called with either Date or RegExp";throw'Could not handle "new" without a specified class';case"Literal":return e.value;case"Identifier":return c=e,d=t,(sf(c.name),d.variables&&Object.hasOwn(d.variables,c.name))?d.variables[c.name]:Object.hasOwn(d.globals,c.name)?d.globals[c.name]:void 0;case"TemplateLiteral":let C,k;return p=e,m=t,C=p.expressions?.map(sm(m))??[],(k=p.quasis?.map(sm(m))??[]).filter(e=>!e.tail).map(e=>e.value).join("")+C.join("")+k.filter(e=>e.tail).map(e=>e.value).join("");case"TemplateElement":return{value:(f=e).cooked,tail:f.tail};default:throw`Expression evaluator does not support expression of type '${e.type}'`}}function si(e,t){switch(e.type){case"Literal":return e.value;case"Identifier":return e.name;case"MemberExpression":return si(e.property,t);default:throw`VisitExpressionName does not support expression of type '${e.type}'`}}function ss(e,t){let r=sd(e.callee,t);if(r===sc||e.optional&&null==r)return sc;let n=e.arguments?.map(sm(t));if(r){if("function"!=typeof r)throw`${sy(e.callee)} is not a function`}else throw`No function named ${sy(e.callee)} is defined in this context`;return r(...n)}function sl(e,t){let r=sd(e.object,t);if(r===sc||e.optional&&null==r)return sc;if(null===r)throw TypeError(`TypeError: cannot read properties of null (reading '${sg(e.property,t)}')`);if(void 0===r)switch(e.object.type){case"Identifier":{let r=si(e.object,t);throw ReferenceError(`ReferenceError: ${r} is not defined`)}case"MemberExpression":throw TypeError(`TypeError: cannot read properties of undefined (reading '${sg(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}(so(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);sf(n),function(e,t){if(sh.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 su(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:i0,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=i0,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 sc=Symbol("optional chain short-circuited");function sd(e,t){switch(e.type){case"MemberExpression":return sl(e,t);case"CallExpression":return ss(e,t);default:return so(e,t)}}function sp(e){return e===sc?void 0:e}function sm(e){return function(t){return null===t?null:so(t,e)}}function sf(e){if("__proto__"===e||"prototype"===e||"constructor"===e)throw{type:"Illegal property access",message:`Cannot access the ${e} property of objects`}}let sh=new Set(["toString","valueOf","hasOwnProperty"]);function sg(e,t){try{return si(e,t)}catch{return"<computed>"}}function sy(e){return e?"MemberExpression"===e.type?e.property?.name:e.name:null}function sv(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:{...i4},boundNames:new Set,variables:new Set};return sb("string"==typeof e?iX(e):e,t),[...t.variables]}function sb(e,t){switch(e.type){case"UnaryExpression":return r=e,n=t,void sb(r.argument,n);case"BinaryExpression":return a=e,o=t,void(sb(a.left,o),sb(a.right,o));case"ConditionalExpression":return i=e,s=t,void(sb(i.consequent,s),sb(i.test,s),sb(i.alternate,s));case"CallExpression":return l=e,u=t,void(sb(l.callee,u),l.arguments?.map(sw(u)));case"ArrowFunctionExpression":var r,n,a,o,i,s,l,u,c,d,p,m,f,h,g,y,v,b,w,E,x=e,D=t;let S=new Set(D.boundNames);for(let e of x.params??[])e?.type==="Identifier"&&S.add(e.name);sb(x.body,{...D,boundNames:S});return;case"MemberExpression":return c=e,d=t,void(sb(c.object,d),c.computed&&sb(c.property,d));case"ArrayExpression":return p=e,m=t,void p.elements?.map(sw(m));case"SequenceExpression":return f=e,h=t,void f.expressions?.map(sw(h));case"NewExpression":return g=e,y=t,void g.arguments?.map(sw(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(sw(E)),w.quasis?.map(sw(E)));default:throw`Expression evaluator does not support expression of type '${e.type}'`}}function sw(e){return function(t){return null===t?null:sb(t,e)}}let sE=H("feature-flags",{flags:function(){let e={};for(let t of Object.keys(localStorage))if(t.startsWith("openmrs:feature-flag:")){let r=t.replace("openmrs:feature-flag:",""),n=JSON.parse(localStorage.getItem(`openmrs:feature-flag-meta:${r}`)||"{}");e[r]={enabled:"true"===localStorage.getItem(t),...n}}return e}()});function sx(e,t,r){sE.setState(n=>({flags:{...n.flags,[e]:{enabled:n.flags[e]?.enabled??!1,label:t,description:r}}}))}function sD(){let e=sE.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 sS(e){return sE.getState().flags[e].enabled}function s_(e,t){sE.subscribe(r=>{t(r.flags[e].enabled)})}function sC(e,t){sE.setState(r=>({flags:{...r.flags,[e]:{...r.flags[e],enabled:t}}}))}sE.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 sk=e5(function(e,t,r){eq(e,t,r)});let sP=V("extensionsInternal",{slots:{},extensions:{}}),sR=V("extensionRenderings",{renderings:new Map}),sT=()=>H("extensionsInternal",{slots:{},extensions:{}}),sO=()=>H("extensionRenderings",{renderings:new Map});function s$(e){let t=sP.getState(),r=e(t);r!==t&&sP.setState(r)}let sN=null,sI=null;function sA(){let e=sR.getState();return sN&&e===sI||(sN=new Map(e.renderings),sI=e,function(e){for(let t of(sz.clear(),e.values()))sG(t,1);sK=!0}(sN)),sN}function sM(e){sI={renderings:e},sR.setState(sI,!0)}function sj(e){let t=sA();t.has(e.renderingId)||(t.set(e.renderingId,e),sG(e,1),sM(t))}function sL(e){let t=sA(),r=t.get(e);r&&(t.delete(e),sG(r,-1),sM(t))}let sF=()=>H("extensions",{slots:{}}),sB=0,sV=new Set;function sU(e){sB++;try{return e()}finally{if(0==--sB&&sV.size>0){let e=Array.from(sV);for(let t of(sV.clear(),e))sW(t)}}}function sW(e){try{e()}catch(t){console.error(`The extension system's '${e.name}' recomputation failed`,t)}}function sH(e){sB>0?sV.add(e):sW(e)}let sz=new Map,sK=!1;function sG(e,t){let r=JSON.stringify([e.slotName,e.extensionId,e.slotModuleName,e.extensionModuleName]),n=sz.get(r);if(!n){if(t<0)return;sz.set(r,{count:1,record:{slotModuleName:e.slotModuleName,extensionModuleName:e.extensionModuleName,slotName:e.slotName,extensionId:e.extensionId}}),sK=!0;return}n.count+=t,n.count<1&&(sz.delete(r),sK=!0)}function sZ(){var e,t;if(sA(),!sK)return;sK=!1;let r=Array.from(sz.values(),({record:e})=>e);r.sort(sY),e=tQ.getState().mountedExtensions,t=r,e.length===t.length&&e.every((e,r)=>0===sY(e,t[r]))||tQ.setState({mountedExtensions:r})}function sY(e,t){return sq(e.slotName,t.slotName)||sq(e.extensionId,t.extensionId)||sq(e.slotModuleName,t.slotModuleName)||sq(e.extensionModuleName,t.extensionModuleName)}function sq(e,t){return e===t?0:e<t?-1:1}sZ(),sR.subscribe(()=>sH(sZ));let sJ=sT(),sX=sF(),sQ=t1(),s0=t3(),s1=new Set,s4=!1;function s2(e){if(null===e)s1=null;else if(null!==s1)for(let t of e)s1.add(t);sH(s3)}function s3(){if(!s4){s4=!0;try{for(let e=1;;e++){let t=s1;if(null!==t&&0===t.size)return;s1=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:p}=t2(t,c.name),m=function(e,t,r,n,a,o){let i=function(e,t){let r=e.add||[],n=e.remove||[],a=e.order||[],{extensions:o}=sJ.getState(),i=new Set(n),s=[...t,...r].filter(e=>!i.has(e)),l=la(a),u=la(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[s9(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}=t6(n,e,l),u=t5(r,e,l),c=u?sk({},i,u):i,d=s9(l),p=t.extensions[d];if(p){let e=c?.["Display conditions"]?.privileges??p.privileges??[];if(e&&("string"==typeof e||Array.isArray(e)&&e.length>0)&&(!o?.user||!oR(e,o.user))||p.featureFlag&&!a.includes(p.featureFlag))continue;s.push({id:l,name:d,moduleName:p.moduleName,config:c,featureFlag:p.featureFlag,meta:p.meta,displayConditionExpression:c?.["Display conditions"]?.expression||p.displayExpression})}}return s}(n,e,p,r,u,a.session);d&&d.moduleName===c.moduleName&&e7(d.candidateExtensions,m)?s[n]=d:(s[n]={moduleName:c.moduleName,candidateExtensions:m},l=!0)}(l||Object.keys(i).length!==Object.keys(s).length)&&sX.setState({slots:s})}(sJ.getState(),sQ.getState(),s0.getState(),sE.getState(),ow.getState(),t)}catch(e){throw s1=null===t||null===s1?null:new Set([...t,...s1]),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{s4=!1}}}function s6(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 s5(e,t){return{moduleName:t,name:e,attachedIds:[]}}function s9(e){let[t]=e.split("#");return t}function s8(e,t){let r=s9(t);return e.extensions[r]}function s7(e){return s8(sJ.getState(),e)}sJ.subscribe((e,t)=>{s2(e.extensions!==t.extensions?null:s6(e.slots,t.slots))}),sQ.subscribe((e,t)=>{s2(s6(e.slots,t.slots))}),s0.subscribe((e,t)=>{s2(s6(e.configs,t.configs))}),sE.subscribe(()=>s2(null)),ow.subscribe(()=>s2(null)),s2(null);let le=e=>s$(t=>({...t,extensions:{...t.extensions,[e.name]:{...e}}}));function lt(e,t){s$(r=>{let n=r.slots[e];return n?{...r,slots:{...r.slots,[e]:{...n,attachedIds:[...n.attachedIds,t]}}}:{...r,slots:{...r.slots,[e]:{...s5(e),attachedIds:[t]}}}})}function lr(e,t){s$(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 ln(e){s$(t=>{let r=t.slots[e];return r?{...t,slots:{...t.slots,[e]:{...r,attachedIds:[]}}}:t})}function la(e){let t=new Map;return e.forEach((e,r)=>{t.has(e)||t.set(e,r)}),t}function lo(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!!i6(o,a)}catch(t){return console.error(`Error while evaluating expression '${o}' for ${e.id}`+(n?` in ${n}`:""),t),!1}})}(li(e),t,ow.getState().session,e)}function li(e){return sX.getState().slots[e]?.candidateExtensions??[]}let ls=(e,t)=>sJ.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=s5(t,e);return{...r,slots:{...r.slots,[t]:{...a}}}}),ll=()=>{s1=null,s$(()=>({slots:{},extensions:{}})),sO().setState({renderings:new Map}),sX.setState({slots:{}})},lu=V("left-nav",{slotName:null,basePath:window.spaBase,mode:"normal"});function lc({name:e,basePath:t,mode:r,componentContext:n,state:a}){lu.setState({slotName:e,basePath:t,mode:r??"normal",componentContext:n,state:a})}function ld(e){lu.getState().slotName===e&&lu.setState(lu.getInitialState(),!0)}let lp=V("modalRegistry",{modals:{}});function lm(e){lp.setState(t=>(t.modals[e.name]=e,t))}function lf(e){let t=lp.getState().modals[e];if(!t){let r=s7(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.`),lm(t))}return t}let lh=V("workspace2",{registeredGroupsByName:{},registeredWindowsByName:{},registeredWorkspacesByName:{},openedGroup:null,openedWindows:[],isMostRecentlyOpenedWindowHidden:!1});function lg(e){let{registeredWorkspacesByName:t,registeredWindowsByName:r}=lh.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 ly(e){let{registeredGroupsByName:t,registeredWindowsByName:r}=lh.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 lv(e){let{openedWindows:t}=lh.getState();return t.findIndex(t=>t.openedWorkspaces.find(t=>t.workspaceName===e))}function lb(e,t){if(0==t.length)return;let{registeredGroupsByName:r}=lh.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}}lh.setState({registeredGroupsByName:n})}function lw(e,t){if(0==t.length)return;let{registeredWindowsByName:r}=lh.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}lh.setState({registeredWindowsByName:n})}function lE(e,t){if(0==t.length)return;let{registeredWorkspacesByName:r}=lh.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}lh.setState({registeredWorkspacesByName:n})}let lx=0,lD=null,lS={bootstrap:15e3,mount:15e3,unmount:15e3};function l_(e,t){if(e.timeouts)return e;let r=e.name??"parcel",n=Object.fromEntries(Object.keys(lS).filter(t=>e[t]).map(n=>{var a,o;let i,s;return[n,(a=e[n],o=lS[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 lC(e,t){var r,n;let a,o,i,s,l,u=await (lD??(lD=new Promise((e,t)=>{nI({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),nI))),lD),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=>l_(e,r)):l_(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 lk(){return lP}function lP(e,t){let r,n=lC(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 lR(e,t,r,n,a=e=>e,o={}){let i=s9(n),s=s7(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:p}=s,m=lx++,f=`${t}/${n}-${m}`;e.dataset.extensionRenderingId=f;let h=e=>{try{sL(f)}catch(t){console.error(e,t)}};try{sj({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 p()}catch(e){throw h(`Recomputing configuration after '${n}' failed to load also failed`),e}try{l=await lC(a({...u,name:`${t}/${i}-${m}`}),{...o,_meta:c,_extensionContext:{extensionId:n,extensionSlotName:t,extensionSlotModuleName:r,extensionModuleName:d,extensionMeta:c},domElement:e})}catch(e){throw h(`Recomputing configuration after '${n}' failed to mount also failed`),e}l.mountPromise.then(void 0,e=>{console.error(`Extension '${n}' in slot '${t}' failed to mount`,e),h(`Recomputing configuration after '${n}' failed to mount also failed`)}),l.unmountPromise.then(()=>h(`Recomputing configuration after unmounting '${n}' failed`),e=>{console.error(`Extension '${n}' in slot '${t}' failed to unmount`,e),h(`Recomputing configuration after '${n}' failed to unmount also failed`)})}else console.warn(`Tried to render ${n} into ${t} but no DOM element was available.`);return l}var lT=r(5399),lO=r.n(lT);let l$=(0,lT.createContext)({moduleName:"",featureName:""});var lN=r(3338);function lI({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}`)},[]),(0,lN.jsx)("a",{onClick:n=>{0===n.button&&!n.ctrlKey&&!n.shiftKey&&!n.altKey&&!n.metaKey&&(n.preventDefault(),r?.(n),oa({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:or(e,t),...a,children:n})}let lA=({state:e,children:t,...r})=>{let{extension:n}=(0,lT.useContext)(l$),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,lR(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?(0,lN.jsx)("div",{ref:d,"data-extension-id":n?.extensionId,style:{position:"relative"},...r}):null};function lM(e){let t=(0,lT.useRef)(e);return O(t.current,e)||(t.current=e),t.current}function lj(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 lF(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?lj(e,r):null,[e,r]);return(0,lT.useMemo)(()=>i?{...o,...i}:o,[o,i])}function lB(e,t){return lF(e,lL,t)}function lV(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?lj(e,t):null,[t]);return(0,lT.useMemo)(()=>o?{...a,...o}:a,[a,o])}}let lU=[];Object.freeze(lU);let lW={candidateExtensions:lU};Object.freeze(lW);let lH=e=>{let t=(0,lT.useCallback)(t=>t.slots?.[e]??lW,[e]);return lF(sF(),t)},lz=e=>e.session;function lK(e,t){let{candidateExtensions:r}=lH(e),n=lF(ow,lz),a=lM(t);return(0,lT.useMemo)(()=>lo(e,a),[e,a,n,r])}function lG(e,t){let{moduleName:r}=(0,lT.useContext)(l$);if(!r)throw Error("ComponentContext has not been provided. This should come from @openmrs/esm-react-utils.");return(0,lT.useEffect)(()=>{ls(r,e)},[r,e]),{extensions:lK(e,t),extensionSlotName:e,extensionSlotModuleName:r}}function lZ(e){return e}function lY({name:e,extensionSlotName:t,select:r=lZ,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}=lG(s,a),d=(0,lT.useMemo)(()=>r(u),[r,u]),p=(0,lT.useMemo)(()=>{if("function"==typeof n&&!lO().isValidElement(n))return d.map(e=>n(e,a))},[n,d]);return(0,lN.jsx)("div",{ref:l,"data-extension-slot-name":s,"data-extension-slot-module-name":c,style:{...o,position:"relative"},...i,children:s&&d?.map((e,t)=>(0,lN.jsx)(l$.Provider,{value:{moduleName:c,featureName:"",extension:{extensionId:e.id,extensionSlotName:s,extensionSlotModuleName:c,extensionMeta:e.meta}},children:p?.[t]??("function"!=typeof n?n:null)??(0,lN.jsx)(lA,{state:a})},e.id))})}var lq=r(6442),lJ=r.n(lq);function lX(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 lQ(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?lX(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)):lX(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function l0(e){return(l0="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 l1(e){return(l1="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 l4(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(l1(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(l1(e)));return e}}var l2=null;try{l2=require("react").createContext()}catch(e){}var l3={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 l6(e,t){return e.rootComponent?Promise.resolve():e.loadRootComponent(t).then(function(t){e.rootComponent=t})}function l5(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=ue(e,t,function(){r(this)}),i=l4(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:l7(e),renderType:"function"==typeof(a=e).renderType?a.renderType():a.renderType});e.domElements[t.name]=i,e.renderResults[t.name]=s})}function l9(e,t){return new Promise(function(r){e.unmountResolves[t.name]=r;var n=e.renderResults[t.name];n&&n.unmount?n.unmount():l7(e).unmountComponentAtNode(e.domElements[t.name]),delete e.domElements[t.name],delete e.renderResults[t.name]})}function l8(e,t){return new Promise(function(r){e.updateResolves[t.name]||(e.updateResolves[t.name]=[]),e.updateResolves[t.name].push(r);var n=ue(e,t,null),a=e.renderResults[t.name];if(a&&a.render)a.render(n);else{var o=l4(e,t)();l7(e).render(n,o)}})}function l7(e){return e.ReactDOMClient||e.ReactDOM}function ue(e,t,r){var n=e.React.createElement(e.rootComponent,t),a=l2?e.React.createElement(l2.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,lQ(lQ({},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 ut=r(7807),ur=r(1619),un=r.n(ur),ua=r(3432);let uo={strictMode:!0,throwErrorsToConsole:!0,disableTranslations:!1},ui=new Map;(0,ua.initCache)(ui);let us={errorRetryCount:3,fetcher:ov,focusThrottleInterval:18e5,revalidateIfStale:!0,revalidateOnFocus:!1,revalidateOnReconnect:!1,refreshInterval:0,shouldRetryOnError:e=>{if(e instanceof ob){let t=e.response.status;return!!(t>=500)||401===t||403===t||429===t}return!0},provider:()=>ui};function ul(e){if("object"!=typeof e||"string"!=typeof e.featureName||"string"!=typeof e.moduleName)throw Error("Invalid options");let t=Object.assign({},uo,e),r={...us,...t.swrConfig};return function(e){var n,a,o,i,s;return o=a=class extends(n=lO().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(0,lN.jsx)("div",{children:"An error has occurred. Please try reloading the page."});{let n=(0,lN.jsx)(lT.Suspense,{fallback:null,children:(0,lN.jsx)(ur.SWRConfig,{value:r,children:(0,lN.jsx)(l$.Provider,{value:this.state.config,children:t.disableTranslations?(0,lN.jsx)(e,{...this.props}):(0,lN.jsx)(ut.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,children:(0,lN.jsx)(e,{...this.props})})})})});return t.strictMode&&lO().StrictMode?(0,lN.jsx)(lO().StrictMode,{children: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 uu(e,t){return function(e){if("object"!==l0(e))throw Error("single-spa-react requires a configuration object");var t,r=lQ(lQ({},l3),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");!l2&&r.React.createContext&&(l2=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:l6.bind(null,r),mount:l5.bind(null,r),unmount:l9.bind(null,r)};return r.parcelCanUpdate&&(n.update=l8.bind(null,r)),n}({React:lO(),ReactDOMClient:lJ(),rootComponent:ul(t)(e)})}function uc(e,t){return()=>e().then(({default:e})=>uu(e,t))}function ud(e,t){return()=>Promise.resolve(uu(e,t))}let up=uc,um=A()(()=>({}));W("openmrs-app-context",um);let uf={};function uh(e,t=e=>e){let r=um.getState();return e in r?Object.freeze(Object.assign({},t?t(r[e]):r[e])):null}function ug(e,t){um.setState(r=>(e in r||(r[e]={}),r[e]=t(r[e]),Object.assign({},r)))}function uy(e){return null===e?null:Object.freeze(Object.assign({},e))}let uv=new Map;function ub(e,t){let r=(0,lT.useRef)(t??{}),n=(0,lT.useRef)(t=>ug(e,t)),a=(0,lT.useRef)(Symbol());return(0,lT.useEffect)(()=>{let r=t??{},n=a.current;return null===uh(e)?!function(e,t=uf){um.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===uf?{}: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.`),ug(e,()=>r)),uv.set(e,n),()=>{uv.get(e)===n&&(um.setState(t=>(e in t&&delete t[e],t)),uv.delete(e))}},[e]),(0,lT.useEffect)(()=>{let n=t??{};O(r.current,n)||(ug(e,()=>n),r.current=n)},[t]),n.current}function uw({namespace:e,value:t}){return ub(e,t),null}let uE=({children:e,value:t,fallback:r})=>t?(0,lN.jsx)(lN.Fragment,{children:e}):r?(0,lN.jsx)(lN.Fragment,{children:r}):null;function ux(){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 uD(e,t=e=>e??{}){let[r,n]=(0,lT.useState)(()=>{if(uS(e))return;let r=uh(e);if(null!==r)return t?t(r):r});return(0,lT.useEffect)(()=>{if(uS(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=>O(e,r)?e:r)})(uy(a=uh(e))),um.subscribe(t=>{let n=e in t?t[e]:null;n!==a&&(a=n,r(uy(n)))})},[e,t]),r}function uS(e){return"string"!=typeof e||0===e.trim().length}function u_(e){let t=lK(e);return(0,lT.useMemo)(()=>t.map(e=>e.id),[t])}function uC(e){return lH(e).candidateExtensions}function uk(e,t,r){let{data:n,error:a,mutate:o,isLoading:i,isValidating:s}=un()(e?iO(e,t,r):null,ov);return(0,lT.useMemo)(()=>({isLoading:i,data:n?.data.results??[],error:a,mutate:o,isValidating:s}),[n,a,i,s,o])}function uP(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 uR={},uT=`No ComponentContext has been provided. This should come from "openmrsComponentDecorator".
16
- Usually this is already applied when using "getAsyncLifecycle" or "getSyncLifecycle".`;function uO(e,t,r){let n=uR[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 uR[e]=a,a.then(()=>{uR[e]===a&&delete uR[e]}),a}function u$(e){let{moduleName:t,extension:r}=(0,lT.useContext)(l$),n=e?.externalModuleName??t;if(!n&&!r)throw Error(uT);let a=function(e){let t=(0,lT.useMemo)(()=>t0(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 uO(e,t,e=>e.loaded?e.config:null);return r}(n),o=function(e){let t=(0,lT.useMemo)(t3,[]),r=function(e,t){let[r,n]=(0,lT.useState)(t?()=>{let r=t6(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=t6(e,t.extensionSlotName,t.extensionId);a.loaded&&a.config&&!e7(a.config,r)&&n(a.config)})},[e,t,r]),r}(t,e);if(!r&&e)throw uO(`${e.extensionSlotName}-${e.extensionId}`,t,t=>{let r=t6(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 uN=lK;function uI(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(3660),uM=r.n(uA);let uj=`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 uL(){let e=`${of}/emrapi/configuration?v=${uj}`,t=uM()(e,ov);return(0,lT.useMemo)(()=>({emrConfiguration:t.data?.data,isLoadingEmrConfiguration:t.isLoading,mutateEmrConfiguration:t.mutate,errorFetchingEmrConfiguration:t.error}),[t])}function uF(){return(0,lT.useContext)(l$).extension}let uB=lV(sT());function uV(e){let t=lK(e);return(0,lT.useMemo)(()=>Object.fromEntries(t.map(e=>[e.name,e.meta])),[t])}let uU=lV(sF());function uW(e){let{flags:t}=lF(sE);return t[e]?.enabled??!1}function uH(){let[,e]=(0,lT.useState)(0);return(0,lT.useCallback)(()=>{e(e=>e+1)},[])}function uz(e,t,r={}){return uG(e,t,uK,r)}let uK={getPaginatedUrl:(e,t,r)=>{if(!e)return null;{let n=new URL(oy(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??ov,[d,p]=(0,lT.useState)(1),m=(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),p(1),h.current=1,m.current=NaN,f.current=NaN,g.current=!1,y.current=!1);let E=(d-1)*t,x=(0,lT.useMemo)(()=>a(e,t,E),[e,t,E]),{data:D,...S}=(l?uM():un())(x,c,u);D?.data&&(m.current=o(D?.data),f.current=i(D?.data),g.current=!0);let _=Math.ceil(m.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(m.current/t);!g.current||Number.isNaN(r)||e<=r?(h.current=e,p(e)):console.warn("Invalid attempt to go to out of bounds page: "+e)},[t]);(0,lT.useEffect)(()=>{if(!g.current)return;if(Number.isNaN(m.current)){y.current||(y.current=!0,console.warn(`useServerPagination: ${v} returned no total count, so out-of-range pages cannot be detected.`));return}let e=Math.max(1,Math.ceil(m.current/t));d>e&&(console.warn(`Invalid attempt to go to out of bounds page: ${d}; returning to page ${e}.`),h.current=e,p(e))},[d,t,v,D]);let k=(0,lT.useCallback)(()=>{C(h.current+1)},[C]),P=(0,lT.useCallback)(()=>{C(h.current-1)},[C]);return{data:s(D?.data),totalPages:_,totalCount:m.current,currentPage:d,currentPageSize:f.current,paginated:_>1,showNextButton:d<_,showPreviousButton:d>1,goTo:C,goToNext:k,goToPrevious:P,...S}}function uZ(e,t,r={}){return uG(e,t,uY(),r)}function uY(){return{getPaginatedUrl:(e,t,r)=>{if(!e)return null;{let n=new URL(oy(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 uq=r(682),uJ=r.n(uq);function uX(e,t={}){return uQ(e,uK,t)}function uQ(e,t,r={}){let{swrInfiniteConfig:n,immutable:a}=r,{getNextUrl:o,getTotalCount:i,getData:s}=t,l=r.fetcher??ov,u=(0,lT.useCallback)((r,n)=>0==r?e?.toString()??null:t.getNextUrl(n.data),[e]),{data:c,size:d,setSize:p,...m}=uJ()(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:()=>{p((c?.length??0)+1)},nextUri:f,...m}}function u0(e,t={}){return u1(e,uK,t)}function u1(e,t,r={}){let n=uQ(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 u4(e,t={}){return u1(e,uY(),t)}function u2(e,t={}){return uQ(e,uY(),t)}function u3(){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 u6(){let[e,t]=(0,lT.useState)(u3);return(0,lT.useEffect)(()=>{let e=()=>{t(u3())};return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),e}let u5=e=>"small-desktop"===e||"large-desktop"===e;function u9(e){let t=(0,lT.useContext)(l$);(0,lT.useEffect)(()=>(t&&t.moduleName&&(e.componentContext=t),lc(e),()=>{ld(e.name)}),[t,e])}function u8(){return lF(lu)}let u7=[];function ce(e=null,t=null){let r=new URLSearchParams;e&&r.set("tag",e),t&&r.set("q",t);let n=r.toString(),{data:a}=u0(`${of}/location${n?"?"+n:""}`,{immutable:!0});return a??u7}function ct(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 cr(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 cn(e,t={}){let{abortController:r,fetchInit:n,url:a,swrConfig:o}=t,i=ux(),s=(0,lT.useMemo)(()=>n?.signal??r?.signal??i.signal,[r?.signal,n?.signal,i.signal]),l=(0,lT.useCallback)(e=>ov(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 un()(e,l,o)}function ca(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 co(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 ci(){let e=/\/patient\/([a-zA-Z0-9\-]+)\/?/.exec(location.pathname);return e&&e[1]}function cs(e){let[t,r]=(0,lT.useState)(e??ci()),{data:n,error:a,isValidating:o}=un()(t?["patient",t]:null,()=>iI(t,{}));return(0,lT.useEffect)(()=>{let e=()=>{let e=ci();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 cl(){let e=`${of}/metadatamapping/termmapping?v=custom:(metadataUuid)&code=emr.primaryIdentifierType`,{data:t,error:r,isLoading:n}=un()(e,ov);return(0,lT.useMemo)(()=>({primaryIdentifierCode:t?.data?.results[0]?.metadataUuid,isLoading:n,error:r}),[t,r,n])}function cu(e,t,r,n){let a=e?.slotName===t&&e.slotModuleName===r?e.components:null,o=new Map;for(let e of n)o.set(e,a?.get(e)??function(e,t,r){let n=s9(r),a=e=>e.extensions[n]?.meta,o=({state:n})=>{let o=lF(sT(),a),i=(0,lT.useMemo)(()=>({moduleName:t,featureName:"",extension:{extensionId:r,extensionSlotName:e,extensionSlotModuleName:t,extensionMeta:o}}),[o]);return(0,lN.jsx)(l$.Provider,{value:i,children:(0,lN.jsx)(lA,{state:n})})};return o.displayName=`RenderableExtension(${r})`,o}(t,r,e));return{slotName:t,slotModuleName:r,components:o}}function cc(e){let{extensions:t,extensionSlotModuleName:r}=lG(e),n=(0,lT.useMemo)(()=>new Set(e?t.map(e=>e.id):[]),[e,t]),[a,o]=(0,lT.useState)(()=>cu(null,e,r,n)),i=a;return a.slotName===e&&a.slotModuleName===r&&a.components.size===n.size&&[...n].every(e=>a.components.has(e))||o(i=cu(a,e,r,n)),(0,lT.useMemo)(()=>e?t.flatMap(e=>{let t=i.components.get(e.id);return t?[t]:[]}):[],[e,t,i])}function cd(){let e=(0,lT.useRef)(),[t,r]=(0,lT.useState)(null),n=null;if(!t){if(i){let e=o_().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(o_().getState()),n||(e.current=o_().subscribe(r))});if(n)r(n);else throw i}(0,lT.useEffect)(()=>(e.current||(e.current=o_().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 cp=({privilege:e,fallback:t,children:r})=>{let[n,a]=(0,lT.useState)(null);return((0,lT.useEffect)(()=>{let e=o_(),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&&oR(e,n))?(0,lN.jsx)(lN.Fragment,{children:r}):t?(0,lN.jsx)(lN.Fragment,{children:t}):null};var cm=r(222),cf=r.n(cm),ch=r(5602);let cg=new Map;function cy(){for(let e of Array.from(cg.values()))e()}let cv={setVisitContext:(e,t)=>null==t?{manuallySetVisitUuid:null}:{manuallySetVisitUuid:t.uuid,patientUuid:t.patient?.uuid}};function cb(e){let t=(0,lT.useId)();return(0,lT.useEffect)(()=>{if(e)return cg.set(t,e),()=>{cg.delete(t)}},[t,e]),{...lB(iK(),cv),mutateVisit:cy}}function cw(e,t=iH){let r=(0,lT.useRef)(void 0),{patientUuid:n,manuallySetVisitUuid:a,setVisitContext:o}=cb((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:p}=un()(e?`${of}/visit${s}`:null,ov),{data:m,error:f,mutate:h,isValidating:g}=un()(e&&i?`${of}/visit${l}`:null,ov),y=(0,lT.useMemo)(()=>u?.data.results.find(e=>null===e.stopDatetime)??null,[u]),v=(0,lT.useMemo)(()=>i&&m?m.data:null,[m,i]),b=(0,lT.useRef)(null);(0,lT.useEffect)(()=>{!p&&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,p,g,n]);let w=(0,lT.useCallback)(()=>{d(),h()},[d,h]);(0,lT.useEffect)(()=>{r.current=w},[w]);let E=!!(!u||i&&!m),x=!!(i?f:c);return{error:c||f,mutate:w,isValidating:p||g,activeVisit:y,currentVisit:v,currentVisitIsRetrospective:!!i,isLoading:E&&!x}}cf().extend(ch);let cE=[];function cx(){let{data:e}=uM()(iB,iV);return e??cE}let cD=new Map;async function cS(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 ir(a);return i&&Object.hasOwn(i,o)&&"function"==typeof i[o]?cC(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`),c_)}let c_={bootstrap:()=>Promise.resolve(),mount:()=>Promise.resolve(),unmount:()=>Promise.resolve()};async function cC(e,t){if(e in cD)await cD[e];else{let r=t??await ir(e);await (cD[e]=new Promise((t,n)=>{if(Object.hasOwn(r,"startupApp")){let a=r.startupApp;if("function"==typeof a)return Promise.resolve(a()).then(()=>{rb(e),t(null)}).catch(n)}rb(e),t(null)}))}}function ck(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
15
+ ${this.stack}`}}let ow=V("session",{loaded:!1,session:null}),oE=0,ox=null;function oD(){return ox||(ow.getState().loaded&&oE>=Date.now()-6e4?null:ok())}function oS(e){let t=e?.includeAuthStatus??!0,r=e=>t?e:e.user,n=oD();return n?new Promise(e=>{let t=()=>{let t=ow.getState();t.loaded&&(a(),e(r(t.session)))},a=ow.subscribe(t);n.then(t,t)}):Promise.resolve(r(ow.getState().session))}function o_(){return oD(),ow}function oC(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 ok(e,t){oE=Date.now(),o??(o=oE);let r={};e&&t&&(r.Authorization=`Basic ${window.btoa(`${e}:${t}`)}`);let n=oj(ov(og,{headers:r,rejectAuthFailure:!0})),a=()=>{ox===n&&(ox=null)};return n.then(a,a),ox=n,n}function oP(){ow.setState({loaded:!0,session:{authenticated:!1,sessionId:""}},!0)}function oR(e,t){var r,n;if(void 0===t)return!e;if(!e)return!0;return r=e,n=t,("string"==typeof r?!G(n.privileges.find(e=>r===e.display)):Array.isArray(r)?r.every(e=>!G(n.privileges.find(t=>e===t.display))):(G(r)||console.error(`Could not understand privileges "${r}"`),!0))||!G(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(ow.getState()),e||(t=ow.subscribe(n))})}async function oO(){return(await oS()).sessionLocation}async function o$(e,t){return oj(ov(og,{method:"POST",body:{sessionLocation:e},headers:{"Content-Type":"application/json"},rejectAuthFailure:!0,signal:t?.signal}))}async function oN(e,t){return await ov(og,{method:"POST",body:{locale:e},headers:{"Content-Type":"application/json"},signal:t?.signal}),ok()}async function oI(e,t,r){return r||(r=new AbortController),await ov(`${of}/user/${e}`,{method:"POST",body:{userProperties:t},headers:{"Content-Type":"application/json"},signal:r.signal}),ok()}async function oA(e,t=!1){let r=await ov(t?`${og}?rememberMe=true`:og,{headers:{"X-Totp-Code":e}});return r.data?.authenticated?(await ok()).session:r.data}async function oM(){try{await ov(og,{method:"DELETE",rejectAuthFailure:!0})}catch(e){if(!oL(e))throw e}oP(),await ok().catch(()=>{})}function oj(e){return new Promise((t,r)=>{e.then(e=>{if("object"==typeof e?.data){let r={loaded:!0,session:e.data};ow.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(oF(Error("The session endpoint did not respond with a session"))):r(oF(Error("The server is still starting up"),!0))}).catch(e=>{var n,a;if(oL(e)){"object"==typeof(n=e.responseBody)&&null!==n&&!1===n.authenticated?ow.setState({loaded:!0,session:e.responseBody},!0):oP(),t(ow.getState());return}(a=e)instanceof ob&&502===a.response.status&&!ow.getState().loaded&&void 0!==o&&Date.now()-o<18e4?r(oF(e,!0)):(P(`Failed to fetch new session information: ${e}`),r(oF(e)))})})}function oL(e){return e instanceof ob&&(401===e.response.status||403===e.response.status)}function oF(e,t=!1){return ow.getState().loaded||ow.setState({loaded:!1,session:null,error:e instanceof Error?e:Error(String(e)),initializing:t},!0),ow.getState()}function oB(){return"development"===window.spaEnv||"true"===localStorage.getItem("openmrs:devtools")}ow.subscribe(e=>{e.loaded&&e.session&&oC(e.session)});let oV={"webservices.rest":"2.24.0",fhir2:"1.0.0-SNAPSHOT"};function oU(){ry("@openmrs/esm-api",op),ok()}let oW="import-map-override:",oH="import-map-overrides-disabled",oz="import-map-overrides:change",oK=!1,oG=null,oZ=null;async function oY(){return oZ??(oZ=oq().then(({map:e,complete:t})=>(t||(oZ=null),e))),oZ}async function oq(){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:oJ(t),complete:r}}function oJ(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=o2();for(let r=0;r<localStorage.length;r++){let n=localStorage.key(r);if(n?.startsWith(oW)){let r=n.slice(oW.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 oQ(){let e=await oY();return oK?oJ([e,oG??oX()]):e}async function o0(){return oY()}async function o1(){return oK?oJ([await oY(),oX()]):oY()}function o4(e){if(!oK)return{imports:{}};if(e){let e={};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)}}return{imports:e}}return oX()}function o2(){if(!oK)return[];try{let e=localStorage.getItem(oH);if(e){let t=JSON.parse(e);if(Array.isArray(t))return t}}catch{}return[]}function o3(e){return!!oK&&o2().includes(e)}function o6(e,t){if(!oK)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{localStorage.setItem(oW+e,t),window.dispatchEvent(new CustomEvent(oz))}catch(e){console.warn("[import-maps] Failed to write import-map override to localStorage",e)}}function o5(e){if(!oK)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{localStorage.removeItem(oW+e);let t=o2().filter(t=>t!==e);t.length>0?localStorage.setItem(oH,JSON.stringify(t)):localStorage.removeItem(oH),window.dispatchEvent(new CustomEvent(oz))}catch(e){console.warn("[import-maps] Failed to update import-map overrides in localStorage",e)}}function o9(){if(!oK)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(oW)&&e.push(r)}e.forEach(e=>localStorage.removeItem(e)),localStorage.removeItem(oH),window.dispatchEvent(new CustomEvent(oz))}catch(e){console.warn("[import-maps] Failed to clear import-map overrides from localStorage",e)}}function o8(e){if(!oK)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{let t=o2().filter(t=>t!==e);t.length>0?localStorage.setItem(oH,JSON.stringify(t)):localStorage.removeItem(oH),window.dispatchEvent(new CustomEvent(oz))}catch(e){console.warn("[import-maps] Failed to update import-map overrides in localStorage",e)}}let o7=!1;function ie(){!o7&&(o7=!0,(oK="development"===window.spaEnv)&&(oG=oX()))}function it(e){return e.replace(/[\/\-@]/g,"_")}async function ir(e,t="./start",n){var a;let o,i=!n?.maxLoadingTime||n.maxLoadingTime<=0?6e5:n.maxLoadingTime;await Promise.race([ia(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=it(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 ia(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=it(e);if(!window[r]){let r=t??await io();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 o4().imports;try{return await function(e){var t;let r=(t=window)[ii]??(t[ii]=new Map),n=r.get(e);if(n)return n;if(document.head.querySelector(`script[src="${e}"]`))return console.warn(`Script at ${e} already loaded. Not loading it again.`),Promise.resolve();let a=document.createElement("script");a.src=e,a.type="text/javascript",a.async=!0;let o=new Promise((t,n)=>{let o=setTimeout(()=>{console.error(`The script at ${e} did not load within 5 seconds. This may indicate an issue with the imports in the script's entry-point file or with the script's bundler configuration.`)},5e3);function i(){clearTimeout(o),a.removeEventListener("load",s),a.removeEventListener("error",l)}function s(){i(),t()}function l(t){i(),r.delete(e),a.remove();let o=`Failed to load script from ${e}`;console.error(o,t),n(t.message??o)}a.addEventListener("load",s),a.addEventListener("error",l),document.head.appendChild(a)});return r.set(e,o),o}(n)}catch(e){return a&&x({kind:"error",title:ot("scriptLoadingFailed","Error: Script failed to load"),description:ot("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:ot("resetOverrides","Reset overrides"),onActionButtonClick(){o9(),window.location.reload()}}),Promise.reject(e)}}return Promise.resolve()}async function io(){return oQ()}let ii=Symbol.for("__openmrs_script_loading");function is(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 il(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&&is(t))}let iu="openmrs-routes:",ic="openmrs-routes:change",id=!1,ip=null,im=null;async function ih(){return im??(im=ig().then(({map:e,complete:t})=>(t||(im=null),e))),im}async function ig(){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&&il(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:iy(t),complete:r}}function iy(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 iv(){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(iu)){let e=localStorage.getItem(r);e&&t.push({moduleName:r.slice(iu.length),raw:e})}}for(let r of(await Promise.allSettled(t.map(async({moduleName:e,raw:t})=>{let r=JSON.parse(t);if(is(r))return{moduleName:e,routes:r};if("string"==typeof r&&r.startsWith("http")){let t=await fetch(r),n=await t.json();if(is(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 ib(){let e=await ih();return id?iy([e,ip??await iv()]):e}async function iw(){return ih()}async function iE(){return id?iy([await ih(),await iv()]):ih()}function ix(){if(!id)return{};let e={};try{for(let t=0;t<localStorage.length;t++){let r=localStorage.key(t);if(r?.startsWith(iu)){let t=localStorage.getItem(r);t&&(e[r.slice(iu.length)]=t)}}}catch(e){console.warn("[route-maps] Failed to read route overrides from localStorage",e)}return e}function iD(e,t){if(!id)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{if("string"==typeof t)if(t.startsWith("http"))localStorage.setItem(iu+e,JSON.stringify(t));else{let r=JSON.parse(t);if(!is(r))return void console.error(`The supplied routes for ${e} is not a valid OpenmrsAppRoutes object`,t);localStorage.setItem(iu+e,JSON.stringify(r))}else if(t instanceof URL)localStorage.setItem(iu+e,JSON.stringify(t.toString()));else{if(!is(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(iu+e,JSON.stringify(t))}window.dispatchEvent(new CustomEvent(ic))}catch(e){console.warn("[route-maps] Failed to write route override to localStorage",e)}}function iS(e){if(!id)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{localStorage.removeItem(iu+e),window.dispatchEvent(new CustomEvent(ic))}catch(e){console.warn("[route-maps] Failed to remove route override from localStorage",e)}}function i_(){if(!id)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(iu)&&e.push(r)}e.forEach(e=>localStorage.removeItem(e)),window.dispatchEvent(new CustomEvent(ic))}catch(e){console.warn("[route-maps] Failed to clear route overrides from localStorage",e)}}let iC=null;function ik(){return iC||(iC=(id="development"===window.spaEnv)?iv().then(e=>{ip=e}):Promise.resolve())}let iP=`${of}/attachment`;function iR(e,t){return ov(`${iP}/${e}`,{signal:t.signal})}function iT(e,t,r,n){return ov(iO(e,t,n),{signal:r.signal})}function iO(e,t,r){return r?`${iP}?patient=${e}&encounter=${r}`:`${iP}?patient=${e}&includeEncounterless=${t}`}async function i$(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)),ov(`${iP}`,{method:"POST",body:n})}function iN(e,t){return ov(`${iP}/${e}`,{method:"DELETE",signal:t.signal})}async function iI(e,t){return e?(await ov(`${oh}/Patient/${e}`,t)).data:null}function iA(e,t){let r=new CustomEvent(`openmrs:${e}`,{detail:t??void 0,cancelable:!0,bubbles:!0});return window.dispatchEvent(r)}function iM(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 ij(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 ov(`${of}/location${n?"?"+n:""}`).then(e=>e.data.results.map(ij))}function iF(e){return{uuid:e.uuid,display:e.display,name:e.name}}let iB=`${of}/visittype`;function iV(e=iB){return ov(e).then(e=>e.data.results.map(iF))}var iU=((X={}).NEWVISIT="startVisit",X.EDITVISIT="editVisit",X.LOADING="loadingVisit",X),iW=((Q={}).NOTSTARTED="notStarted",Q.ONGOING="ongoing",Q);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))",iz=function(){try{return JSON.parse(sessionStorage.getItem("openmrs:visitStoreState")||"null")}catch(e){return null}}()||{patientUuid:null,manuallySetVisitUuid:null};function iK(){return H("visit",iz)}function iG(e,t){iK().setState({patientUuid:e,manuallySetVisitUuid:t})}function iZ(e,t){return ov(`${of}/visit`,{signal:t.signal,method:"POST",headers:{"Content-type":"application/json"},body:e})}function iY(e,t,r){return ov(`${of}/visit/${e}`,{signal:r.signal,method:"POST",headers:{"Content-type":"application/json"},body:t})}function iq(e,t,r){return ov(`${of}/visit?patient=${e}&v=${r??iH}`,{signal:t.signal,method:"GET",headers:{"Content-type":"application/json"}})}iK().subscribe(e=>{var t;t=e,sessionStorage.setItem("openmrs:visitStoreState",JSON.stringify(t))});class iJ{static get version(){return"1.4.0"}static toString(){return"JavaScript Expression Parser (JSEP) v"+iJ.version}static addUnaryOp(e){return iJ.max_unop_len=Math.max(e.length,iJ.max_unop_len),iJ.unary_ops[e]=1,iJ}static addBinaryOp(e,t,r){return iJ.max_binop_len=Math.max(e.length,iJ.max_binop_len),iJ.binary_ops[e]=t,r?iJ.right_associative.add(e):iJ.right_associative.delete(e),iJ}static addIdentifierChar(e){return iJ.additional_identifier_chars.add(e),iJ}static addLiteral(e,t){return iJ.literals[e]=t,iJ}static removeUnaryOp(e){return delete iJ.unary_ops[e],e.length===iJ.max_unop_len&&(iJ.max_unop_len=iJ.getMaxKeyLen(iJ.unary_ops)),iJ}static removeAllUnaryOps(){return iJ.unary_ops={},iJ.max_unop_len=0,iJ}static removeIdentifierChar(e){return iJ.additional_identifier_chars.delete(e),iJ}static removeBinaryOp(e){return delete iJ.binary_ops[e],e.length===iJ.max_binop_len&&(iJ.max_binop_len=iJ.getMaxKeyLen(iJ.binary_ops)),iJ.right_associative.delete(e),iJ}static removeAllBinaryOps(){return iJ.binary_ops={},iJ.max_binop_len=0,iJ}static removeLiteral(e){return delete iJ.literals[e],iJ}static removeAllLiterals(){return iJ.literals={},iJ}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 iJ(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 iJ.binary_ops[e]||0}static isIdentifierStart(e){return e>=65&&e<=90||e>=97&&e<=122||e>=128&&!iJ.binary_ops[String.fromCharCode(e)]||iJ.additional_identifier_chars.has(String.fromCharCode(e))}static isIdentifierPart(e){return iJ.isIdentifierStart(e)||iJ.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(iJ.hooks[e]){let r={context:this,node:t};return iJ.hooks.run(e,r),r.node}return t}searchHook(e){if(iJ.hooks[e]){let t={context:this};return iJ.hooks[e].find(function(e){return e.call(t.context,t),t.node}),t.node}}gobbleSpaces(){let e=this.code;for(;e===iJ.SPACE_CODE||e===iJ.TAB_CODE||e===iJ.LF_CODE||e===iJ.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:iJ.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)===iJ.SEMCOL_CODE||r===iJ.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,iJ.max_binop_len),t=e.length;for(;t>0;){if(iJ.binary_ops.hasOwnProperty(e)&&(!iJ.isIdentifierStart(this.code)||this.index+e.length<this.expr.length&&!iJ.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:iJ.binaryPrecedence(t),right_a:iJ.right_associative.has(t)},(i=this.gobbleToken())||this.throwError("Expected expression after "+t),n=[o,a,i];t=this.gobbleBinaryOp();){if(0===(r=iJ.binaryPrecedence(t))){this.index-=t.length;break}a={value:t,prec:r,right_a:iJ.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:iJ.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:iJ.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,iJ.isDecimalDigit(e)||e===iJ.PERIOD_CODE)return this.gobbleNumericLiteral();if(e===iJ.SQUOTE_CODE||e===iJ.DQUOTE_CODE)n=this.gobbleStringLiteral();else if(e===iJ.OBRACK_CODE)n=this.gobbleArray();else{for(r=(t=this.expr.substr(this.index,iJ.max_unop_len)).length;r>0;){if(iJ.unary_ops.hasOwnProperty(t)&&(!iJ.isIdentifierStart(this.code)||this.index+t.length<this.expr.length&&!iJ.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:iJ.UNARY_EXP,operator:t,argument:e,prefix:!0})}t=t.substr(0,--r)}iJ.isIdentifierStart(e)?(n=this.gobbleIdentifier(),iJ.literals.hasOwnProperty(n.name)?n={type:iJ.LITERAL,value:iJ.literals[n.name],raw:n.name}:n.name===iJ.this_str&&(n={type:iJ.THIS_EXP})):e===iJ.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===iJ.PERIOD_CODE||t===iJ.OBRACK_CODE||t===iJ.OPAREN_CODE||t===iJ.QUMARK_CODE;){let r;if(t===iJ.QUMARK_CODE){if(this.expr.charCodeAt(this.index+1)!==iJ.PERIOD_CODE)break;r=!0,this.index+=2,this.gobbleSpaces(),t=this.code}this.index++,t===iJ.OBRACK_CODE?((e={type:iJ.MEMBER_EXP,computed:!0,object:e,property:this.gobbleExpression()}).property||this.throwError('Unexpected "'+this.char+'"'),this.gobbleSpaces(),(t=this.code)!==iJ.CBRACK_CODE&&this.throwError("Unclosed ["),this.index++):t===iJ.OPAREN_CODE?e={type:iJ.CALL_EXP,arguments:this.gobbleArguments(iJ.CPAREN_CODE),callee:e}:(t===iJ.PERIOD_CODE||r)&&(r&&this.index--,this.gobbleSpaces(),e={type:iJ.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(;iJ.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);if(this.code===iJ.PERIOD_CODE)for(e+=this.expr.charAt(this.index++);iJ.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++));iJ.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);iJ.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+e+this.char+")")}return r=this.code,iJ.isIdentifierStart(r)?this.throwError("Variable names cannot start with a number ("+e+this.char+")"):(r===iJ.PERIOD_CODE||1===e.length&&e.charCodeAt(0)===iJ.PERIOD_CODE)&&this.throwError("Unexpected period"),{type:iJ.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:iJ.LITERAL,value:e,raw:this.expr.substring(t,this.index)}}gobbleIdentifier(){let e=this.code,t=this.index;for(iJ.isIdentifierStart(e)?this.index++:this.throwError("Unexpected "+this.char);this.index<this.expr.length;)if(e=this.code,iJ.isIdentifierPart(e))this.index++;else break;return{type:iJ.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===iJ.CPAREN_CODE&&n&&n>=t.length&&this.throwError("Unexpected token "+String.fromCharCode(e));break}if(a===iJ.COMMA_CODE){if(this.index++,++n!==t.length){if(e===iJ.CPAREN_CODE)this.throwError("Unexpected token ,");else if(e===iJ.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!==iJ.COMPOUND||this.throwError("Expected comma"),t.push(e)}}return r||this.throwError("Expected "+String.fromCharCode(e)),t}gobbleGroup(){this.index++;let e=this.gobbleExpressions(iJ.CPAREN_CODE);if(this.code===iJ.CPAREN_CODE)return(this.index++,1===e.length)?e[0]:!!e.length&&{type:iJ.SEQUENCE_EXP,expressions:e};this.throwError("Unclosed (")}gobbleArray(){return this.index++,{type:iJ.ARRAY_EXP,elements:this.gobbleArguments(iJ.CBRACK_CODE)}}}Object.assign(iJ,{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)})}}(iJ),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"}),iJ.max_unop_len=iJ.getMaxKeyLen(iJ.unary_ops),iJ.max_binop_len=iJ.getMaxKeyLen(iJ.binary_ops);let iX=e=>new iJ(e).parse(),iQ=Object.getOwnPropertyNames(class{});Object.getOwnPropertyNames(iJ).filter(e=>!iQ.includes(e)&&void 0===iX[e]).forEach(e=>{iX[e]=iJ[e]}),iX.Jsep=iJ,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 i0="ArrowFunctionExpression",i1={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)}},i4={...i1,Promise};function i2(e,t={}){return i7(e,t,sr)}async function i3(e,t={}){return se(e,t,sr)}function i6(e,t={}){return i7(e,t,sn)}function i5(e,t={}){return se(e,t,sn)}function i9(e,t={}){return i7(e,t,sa)}function i8(e,t={}){return se(e,t,sa)}function i7(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=su(t,i1),a=so("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 se(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=su(t,i4);return Promise.resolve(so("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 st(e){return iX(e)}function sr(e){return"string"==typeof e||"number"==typeof e||"boolean"==typeof e||null==e||e instanceof Date}function sn(e){return"boolean"==typeof e}function sa(e){return"number"==typeof e}function so(e,t){switch(e.type){case"UnaryExpression":var r,n,a,o,i,s,l,u,c,d,p,m,f,h=e,g=t;let y=so(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 so(v.left,b)&&so(v.right,b);case"||":return so(v.left,b)||so(v.right,b);case"??":return so(v.left,b)??so(v.right,b)}let w=so(v.left,b),E=so(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,so(r.test,n)?so(r.consequent,n):so(r.alternate,n);case"CallExpression":return sp(ss(e,t));case"ArrowFunctionExpression":let x;return a=e,o=t,x=a.params?.map(e=>{if("Identifier"===e.type)return e.name;throw`Cannot handle parameter of type ${e.type}`})??[],(function(...e){if(e.length<x.length)throw`Required argument(s) ${x.slice(e.length,-1).join(", ")} were not provided`;let t=Object.fromEntries(x.reduce((t,r,n)=>{let a=e[n];return function e(t){if("string"==typeof t||"number"==typeof t||"boolean"==typeof t||"function"==typeof t||null===t||t instanceof RegExp)return!0;if("object"==typeof t){for(let r of Object.keys(t))if(!e(t[r]))return!1;return!0}if(Array.isArray(t)){for(let r of t)if(!e(r))break}return!1}(a)&&t.push([r,a]),t},[]));return so(a.body,o.addVariables(t))}).bind(null);case"MemberExpression":return sp(sl(e,t));case"ArrayExpression":return i=e,s=t,i.elements?.map(sm(s));case"SequenceExpression":let D;return l=e,u=t,(D=l.expressions.map(sm(u)))[D.length-1];case"NewExpression":var S=e,_=t;if(S.callee&&"Identifier"===S.callee.type){let e=S.arguments?.map(sm(_));switch(S.callee.name){case"Date":return new Date(...e);case"RegExp":return new RegExp(...e);default:throw`Cannot instantiate object of type ${S.callee.name}`}}if(S.callee)throw"new must be called with either Date or RegExp";throw'Could not handle "new" without a specified class';case"Literal":return e.value;case"Identifier":return c=e,d=t,(sf(c.name),d.variables&&Object.hasOwn(d.variables,c.name))?d.variables[c.name]:Object.hasOwn(d.globals,c.name)?d.globals[c.name]:void 0;case"TemplateLiteral":let C,k;return p=e,m=t,C=p.expressions?.map(sm(m))??[],(k=p.quasis?.map(sm(m))??[]).filter(e=>!e.tail).map(e=>e.value).join("")+C.join("")+k.filter(e=>e.tail).map(e=>e.value).join("");case"TemplateElement":return{value:(f=e).cooked,tail:f.tail};default:throw`Expression evaluator does not support expression of type '${e.type}'`}}function si(e,t){switch(e.type){case"Literal":return e.value;case"Identifier":return e.name;case"MemberExpression":return si(e.property,t);default:throw`VisitExpressionName does not support expression of type '${e.type}'`}}function ss(e,t){let r=sd(e.callee,t);if(r===sc||e.optional&&null==r)return sc;let n=e.arguments?.map(sm(t));if(r){if("function"!=typeof r)throw`${sy(e.callee)} is not a function`}else throw`No function named ${sy(e.callee)} is defined in this context`;return r(...n)}function sl(e,t){let r=sd(e.object,t);if(r===sc||e.optional&&null==r)return sc;if(null===r)throw TypeError(`TypeError: cannot read properties of null (reading '${sg(e.property,t)}')`);if(void 0===r)switch(e.object.type){case"Identifier":{let r=si(e.object,t);throw ReferenceError(`ReferenceError: ${r} is not defined`)}case"MemberExpression":throw TypeError(`TypeError: cannot read properties of undefined (reading '${sg(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}(so(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);sf(n),function(e,t){if(sh.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 su(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:i0,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=i0,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 sc=Symbol("optional chain short-circuited");function sd(e,t){switch(e.type){case"MemberExpression":return sl(e,t);case"CallExpression":return ss(e,t);default:return so(e,t)}}function sp(e){return e===sc?void 0:e}function sm(e){return function(t){return null===t?null:so(t,e)}}function sf(e){if("__proto__"===e||"prototype"===e||"constructor"===e)throw{type:"Illegal property access",message:`Cannot access the ${e} property of objects`}}let sh=new Set(["toString","valueOf","hasOwnProperty"]);function sg(e,t){try{return si(e,t)}catch{return"<computed>"}}function sy(e){return e?"MemberExpression"===e.type?e.property?.name:e.name:null}function sv(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:{...i4},boundNames:new Set,variables:new Set};return sb("string"==typeof e?iX(e):e,t),[...t.variables]}function sb(e,t){switch(e.type){case"UnaryExpression":return r=e,n=t,void sb(r.argument,n);case"BinaryExpression":return a=e,o=t,void(sb(a.left,o),sb(a.right,o));case"ConditionalExpression":return i=e,s=t,void(sb(i.consequent,s),sb(i.test,s),sb(i.alternate,s));case"CallExpression":return l=e,u=t,void(sb(l.callee,u),l.arguments?.map(sw(u)));case"ArrowFunctionExpression":var r,n,a,o,i,s,l,u,c,d,p,m,f,h,g,y,v,b,w,E,x=e,D=t;let S=new Set(D.boundNames);for(let e of x.params??[])e?.type==="Identifier"&&S.add(e.name);sb(x.body,{...D,boundNames:S});return;case"MemberExpression":return c=e,d=t,void(sb(c.object,d),c.computed&&sb(c.property,d));case"ArrayExpression":return p=e,m=t,void p.elements?.map(sw(m));case"SequenceExpression":return f=e,h=t,void f.expressions?.map(sw(h));case"NewExpression":return g=e,y=t,void g.arguments?.map(sw(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(sw(E)),w.quasis?.map(sw(E)));default:throw`Expression evaluator does not support expression of type '${e.type}'`}}function sw(e){return function(t){return null===t?null:sb(t,e)}}let sE=H("feature-flags",{flags:function(){let e={};for(let t of Object.keys(localStorage))if(t.startsWith("openmrs:feature-flag:")){let r=t.replace("openmrs:feature-flag:",""),n=JSON.parse(localStorage.getItem(`openmrs:feature-flag-meta:${r}`)||"{}");e[r]={enabled:"true"===localStorage.getItem(t),...n}}return e}()});function sx(e,t,r){sE.setState(n=>({flags:{...n.flags,[e]:{enabled:n.flags[e]?.enabled??!1,label:t,description:r}}}))}function sD(){let e=sE.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 sS(e){return sE.getState().flags[e].enabled}function s_(e,t){sE.subscribe(r=>{t(r.flags[e].enabled)})}function sC(e,t){sE.setState(r=>({flags:{...r.flags,[e]:{...r.flags[e],enabled:t}}}))}sE.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 sk=e5(function(e,t,r){eq(e,t,r)});let sP=V("extensionsInternal",{slots:{},extensions:{}}),sR=V("extensionRenderings",{renderings:new Map}),sT=()=>H("extensionsInternal",{slots:{},extensions:{}}),sO=()=>H("extensionRenderings",{renderings:new Map});function s$(e){let t=sP.getState(),r=e(t);r!==t&&sP.setState(r)}let sN=null,sI=null;function sA(){let e=sR.getState();return sN&&e===sI||(sN=new Map(e.renderings),sI=e,function(e){for(let t of(sz.clear(),e.values()))sG(t,1);sK=!0}(sN)),sN}function sM(e){sI={renderings:e},sR.setState(sI,!0)}function sj(e){let t=sA();t.has(e.renderingId)||(t.set(e.renderingId,e),sG(e,1),sM(t))}function sL(e){let t=sA(),r=t.get(e);r&&(t.delete(e),sG(r,-1),sM(t))}let sF=()=>H("extensions",{slots:{}}),sB=0,sV=new Set;function sU(e){sB++;try{return e()}finally{if(0==--sB&&sV.size>0){let e=Array.from(sV);for(let t of(sV.clear(),e))sW(t)}}}function sW(e){try{e()}catch(t){console.error(`The extension system's '${e.name}' recomputation failed`,t)}}function sH(e){sB>0?sV.add(e):sW(e)}let sz=new Map,sK=!1;function sG(e,t){let r=JSON.stringify([e.slotName,e.extensionId,e.slotModuleName,e.extensionModuleName]),n=sz.get(r);if(!n){if(t<0)return;sz.set(r,{count:1,record:{slotModuleName:e.slotModuleName,extensionModuleName:e.extensionModuleName,slotName:e.slotName,extensionId:e.extensionId}}),sK=!0;return}n.count+=t,n.count<1&&(sz.delete(r),sK=!0)}function sZ(){var e,t;if(sA(),!sK)return;sK=!1;let r=Array.from(sz.values(),({record:e})=>e);r.sort(sY),e=tQ.getState().mountedExtensions,t=r,e.length===t.length&&e.every((e,r)=>0===sY(e,t[r]))||tQ.setState({mountedExtensions:r})}function sY(e,t){return sq(e.slotName,t.slotName)||sq(e.extensionId,t.extensionId)||sq(e.slotModuleName,t.slotModuleName)||sq(e.extensionModuleName,t.extensionModuleName)}function sq(e,t){return e===t?0:e<t?-1:1}sZ(),sR.subscribe(()=>sH(sZ));let sJ=sT(),sX=sF(),sQ=t1(),s0=t3(),s1=new Set,s4=!1;function s2(e){if(null===e)s1=null;else if(null!==s1)for(let t of e)s1.add(t);sH(s3)}function s3(){if(!s4){s4=!0;try{for(let e=1;;e++){let t=s1;if(null!==t&&0===t.size)return;s1=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:p}=t2(t,c.name),m=function(e,t,r,n,a,o){let i=function(e,t){let r=e.add||[],n=e.remove||[],a=e.order||[],{extensions:o}=sJ.getState(),i=new Set(n),s=[...t,...r].filter(e=>!i.has(e)),l=la(a),u=la(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[s9(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}=t6(n,e,l),u=t5(r,e,l),c=u?sk({},i,u):i,d=s9(l),p=t.extensions[d];if(p){let e=c?.["Display conditions"]?.privileges??p.privileges??[];if(e&&("string"==typeof e||Array.isArray(e)&&e.length>0)&&(!o?.user||!oR(e,o.user))||p.featureFlag&&!a.includes(p.featureFlag))continue;s.push({id:l,name:d,moduleName:p.moduleName,config:c,featureFlag:p.featureFlag,meta:p.meta,displayConditionExpression:c?.["Display conditions"]?.expression||p.displayExpression})}}return s}(n,e,p,r,u,a.session);d&&d.moduleName===c.moduleName&&e7(d.candidateExtensions,m)?s[n]=d:(s[n]={moduleName:c.moduleName,candidateExtensions:m},l=!0)}(l||Object.keys(i).length!==Object.keys(s).length)&&sX.setState({slots:s})}(sJ.getState(),sQ.getState(),s0.getState(),sE.getState(),ow.getState(),t)}catch(e){throw s1=null===t||null===s1?null:new Set([...t,...s1]),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{s4=!1}}}function s6(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 s5(e,t){return{moduleName:t,name:e,attachedIds:[]}}function s9(e){let[t]=e.split("#");return t}function s8(e,t){let r=s9(t);return e.extensions[r]}function s7(e){return s8(sJ.getState(),e)}sJ.subscribe((e,t)=>{s2(e.extensions!==t.extensions?null:s6(e.slots,t.slots))}),sQ.subscribe((e,t)=>{s2(s6(e.slots,t.slots))}),s0.subscribe((e,t)=>{s2(s6(e.configs,t.configs))}),sE.subscribe(()=>s2(null)),ow.subscribe(()=>s2(null)),s2(null);let le=e=>s$(t=>({...t,extensions:{...t.extensions,[e.name]:{...e}}}));function lt(e,t){s$(r=>{let n=r.slots[e];return n?{...r,slots:{...r.slots,[e]:{...n,attachedIds:[...n.attachedIds,t]}}}:{...r,slots:{...r.slots,[e]:{...s5(e),attachedIds:[t]}}}})}function lr(e,t){s$(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 ln(e){s$(t=>{let r=t.slots[e];return r?{...t,slots:{...t.slots,[e]:{...r,attachedIds:[]}}}:t})}function la(e){let t=new Map;return e.forEach((e,r)=>{t.has(e)||t.set(e,r)}),t}function lo(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!!i6(o,a)}catch(t){return console.error(`Error while evaluating expression '${o}' for ${e.id}`+(n?` in ${n}`:""),t),!1}})}(li(e),t,ow.getState().session,e)}function li(e){return sX.getState().slots[e]?.candidateExtensions??[]}let ls=(e,t)=>sJ.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=s5(t,e);return{...r,slots:{...r.slots,[t]:{...a}}}}),ll=()=>{s1=null,s$(()=>({slots:{},extensions:{}})),sO().setState({renderings:new Map}),sX.setState({slots:{}})},lu=V("left-nav",{slotName:null,basePath:window.spaBase,mode:"normal"});function lc({name:e,basePath:t,mode:r,componentContext:n,state:a}){lu.setState({slotName:e,basePath:t,mode:r??"normal",componentContext:n,state:a})}function ld(e){lu.getState().slotName===e&&lu.setState(lu.getInitialState(),!0)}let lp=V("modalRegistry",{modals:{}});function lm(e){lp.setState(t=>(t.modals[e.name]=e,t))}function lf(e){let t=lp.getState().modals[e];if(!t){let r=s7(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.`),lm(t))}return t}let lh=V("workspace2",{registeredGroupsByName:{},registeredWindowsByName:{},registeredWorkspacesByName:{},openedGroup:null,openedWindows:[],isMostRecentlyOpenedWindowHidden:!1});function lg(e){let{registeredWorkspacesByName:t,registeredWindowsByName:r}=lh.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 ly(e){let{registeredGroupsByName:t,registeredWindowsByName:r}=lh.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 lv(e){let{openedWindows:t}=lh.getState();return t.findIndex(t=>t.openedWorkspaces.find(t=>t.workspaceName===e))}function lb(e,t){if(0==t.length)return;let{registeredGroupsByName:r}=lh.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}}lh.setState({registeredGroupsByName:n})}function lw(e,t){if(0==t.length)return;let{registeredWindowsByName:r}=lh.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}lh.setState({registeredWindowsByName:n})}function lE(e,t){if(0==t.length)return;let{registeredWorkspacesByName:r}=lh.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}lh.setState({registeredWorkspacesByName:n})}let lx=0,lD=null,lS={bootstrap:15e3,mount:15e3,unmount:15e3};function l_(e,t){if(e.timeouts)return e;let r=e.name??"parcel",n=Object.fromEntries(Object.keys(lS).filter(t=>e[t]).map(n=>{var a,o;let i,s;return[n,(a=e[n],o=lS[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 lC(e,t){var r,n;let a,o,i,s,l,u=await (lD??(lD=new Promise((e,t)=>{nI({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),nI))),lD),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=>l_(e,r)):l_(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 lk(){return lP}function lP(e,t){let r,n=lC(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 lR(e,t,r,n,a=e=>e,o={}){let i=s9(n),s=s7(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:p}=s,m=lx++,f=`${t}/${n}-${m}`;e.dataset.extensionRenderingId=f;let h=e=>{try{sL(f)}catch(t){console.error(e,t)}};try{sj({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 p()}catch(e){throw h(`Recomputing configuration after '${n}' failed to load also failed`),e}try{l=await lC(a({...u,name:`${t}/${i}-${m}`}),{...o,_meta:c,_extensionContext:{extensionId:n,extensionSlotName:t,extensionSlotModuleName:r,extensionModuleName:d,extensionMeta:c},domElement:e})}catch(e){throw h(`Recomputing configuration after '${n}' failed to mount also failed`),e}l.mountPromise.then(void 0,e=>{console.error(`Extension '${n}' in slot '${t}' failed to mount`,e),h(`Recomputing configuration after '${n}' failed to mount also failed`)}),l.unmountPromise.then(()=>h(`Recomputing configuration after unmounting '${n}' failed`),e=>{console.error(`Extension '${n}' in slot '${t}' failed to unmount`,e),h(`Recomputing configuration after '${n}' failed to unmount also failed`)})}else console.warn(`Tried to render ${n} into ${t} but no DOM element was available.`);return l}var lT=r(5399),lO=r.n(lT);let l$=(0,lT.createContext)({moduleName:"",featureName:""});var lN=r(3338);function lI({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}`)},[]),(0,lN.jsx)("a",{onClick:n=>{0===n.button&&!n.ctrlKey&&!n.shiftKey&&!n.altKey&&!n.metaKey&&(n.preventDefault(),r?.(n),oa({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:or(e,t),...a,children:n})}let lA=({state:e,children:t,...r})=>{let{extension:n}=(0,lT.useContext)(l$),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,lR(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?(0,lN.jsx)("div",{ref:d,"data-extension-id":n?.extensionId,style:{position:"relative"},...r}):null};function lM(e){let t=(0,lT.useRef)(e);return O(t.current,e)||(t.current=e),t.current}function lj(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 lF(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?lj(e,r):null,[e,r]);return(0,lT.useMemo)(()=>i?{...o,...i}:o,[o,i])}function lB(e,t){return lF(e,lL,t)}function lV(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?lj(e,t):null,[t]);return(0,lT.useMemo)(()=>o?{...a,...o}:a,[a,o])}}let lU=[];Object.freeze(lU);let lW={candidateExtensions:lU};Object.freeze(lW);let lH=e=>{let t=(0,lT.useCallback)(t=>t.slots?.[e]??lW,[e]);return lF(sF(),t)},lz=e=>e.session;function lK(e,t){let{candidateExtensions:r}=lH(e),n=lF(ow,lz),a=lM(t);return(0,lT.useMemo)(()=>lo(e,a),[e,a,n,r])}function lG(e,t){let{moduleName:r}=(0,lT.useContext)(l$);if(!r)throw Error("ComponentContext has not been provided. This should come from @openmrs/esm-react-utils.");return(0,lT.useEffect)(()=>{ls(r,e)},[r,e]),{extensions:lK(e,t),extensionSlotName:e,extensionSlotModuleName:r}}function lZ(e){return e}function lY({name:e,extensionSlotName:t,select:r=lZ,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}=lG(s,a),d=(0,lT.useMemo)(()=>r(u),[r,u]),p=(0,lT.useMemo)(()=>{if("function"==typeof n&&!lO().isValidElement(n))return d.map(e=>n(e,a))},[n,d]);return(0,lN.jsx)("div",{ref:l,"data-extension-slot-name":s,"data-extension-slot-module-name":c,style:{...o,position:"relative"},...i,children:s&&d?.map((e,t)=>(0,lN.jsx)(l$.Provider,{value:{moduleName:c,featureName:"",extension:{extensionId:e.id,extensionSlotName:s,extensionSlotModuleName:c,extensionMeta:e.meta}},children:p?.[t]??("function"!=typeof n?n:null)??(0,lN.jsx)(lA,{state:a})},e.id))})}var lq=r(6442),lJ=r.n(lq);function lX(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 lQ(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?lX(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)):lX(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function l0(e){return(l0="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 l1(e){return(l1="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 l4(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(l1(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(l1(e)));return e}}var l2=null;try{l2=require("react").createContext()}catch(e){}var l3={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 l6(e,t){return e.rootComponent?Promise.resolve():e.loadRootComponent(t).then(function(t){e.rootComponent=t})}function l5(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=ue(e,t,function(){r(this)}),i=l4(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:l7(e),renderType:"function"==typeof(a=e).renderType?a.renderType():a.renderType});e.domElements[t.name]=i,e.renderResults[t.name]=s})}function l9(e,t){return new Promise(function(r){e.unmountResolves[t.name]=r;var n=e.renderResults[t.name];n&&n.unmount?n.unmount():l7(e).unmountComponentAtNode(e.domElements[t.name]),delete e.domElements[t.name],delete e.renderResults[t.name]})}function l8(e,t){return new Promise(function(r){e.updateResolves[t.name]||(e.updateResolves[t.name]=[]),e.updateResolves[t.name].push(r);var n=ue(e,t,null),a=e.renderResults[t.name];if(a&&a.render)a.render(n);else{var o=l4(e,t)();l7(e).render(n,o)}})}function l7(e){return e.ReactDOMClient||e.ReactDOM}function ue(e,t,r){var n=e.React.createElement(e.rootComponent,t),a=l2?e.React.createElement(l2.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,lQ(lQ({},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 ut=r(7807),ur=r(1619),un=r.n(ur),ua=r(3432);let uo={strictMode:!0,throwErrorsToConsole:!0,disableTranslations:!1},ui=new Map;(0,ua.initCache)(ui);let us={errorRetryCount:3,fetcher:ov,focusThrottleInterval:18e5,revalidateIfStale:!0,revalidateOnFocus:!1,revalidateOnReconnect:!1,refreshInterval:0,shouldRetryOnError:e=>{if(e instanceof ob){let t=e.response.status;return!!(t>=500)||401===t||403===t||429===t}return!0},provider:()=>ui};function ul(e){if("object"!=typeof e||"string"!=typeof e.featureName||"string"!=typeof e.moduleName)throw Error("Invalid options");let t=Object.assign({},uo,e),r={...us,...t.swrConfig};return function(e){var n,a,o,i,s;return o=a=class extends(n=lO().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(0,lN.jsx)("div",{children:"An error has occurred. Please try reloading the page."});{let n=(0,lN.jsx)(lT.Suspense,{fallback:null,children:(0,lN.jsx)(ur.SWRConfig,{value:r,children:(0,lN.jsx)(l$.Provider,{value:this.state.config,children:t.disableTranslations?(0,lN.jsx)(e,{...this.props}):(0,lN.jsx)(ut.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,children:(0,lN.jsx)(e,{...this.props})})})})});return t.strictMode&&lO().StrictMode?(0,lN.jsx)(lO().StrictMode,{children: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 uu(e,t){return function(e){if("object"!==l0(e))throw Error("single-spa-react requires a configuration object");var t,r=lQ(lQ({},l3),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");!l2&&r.React.createContext&&(l2=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:l6.bind(null,r),mount:l5.bind(null,r),unmount:l9.bind(null,r)};return r.parcelCanUpdate&&(n.update=l8.bind(null,r)),n}({React:lO(),ReactDOMClient:lJ(),rootComponent:ul(t)(e)})}function uc(e,t){return()=>e().then(({default:e})=>uu(e,t))}function ud(e,t){return()=>Promise.resolve(uu(e,t))}let up=uc,um=A()(()=>({}));W("openmrs-app-context",um);let uf={};function uh(e,t=e=>e){let r=um.getState();return e in r?Object.freeze(Object.assign({},t?t(r[e]):r[e])):null}function ug(e,t){um.setState(r=>(e in r||(r[e]={}),r[e]=t(r[e]),Object.assign({},r)))}function uy(e){return null===e?null:Object.freeze(Object.assign({},e))}let uv=new Map;function ub(e,t){let r=(0,lT.useRef)(t??{}),n=(0,lT.useRef)(t=>ug(e,t)),a=(0,lT.useRef)(Symbol());return(0,lT.useEffect)(()=>{let r=t??{},n=a.current;return null===uh(e)?!function(e,t=uf){um.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===uf?{}: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.`),ug(e,()=>r)),uv.set(e,n),()=>{uv.get(e)===n&&(um.setState(t=>(e in t&&delete t[e],t)),uv.delete(e))}},[e]),(0,lT.useEffect)(()=>{let n=t??{};O(r.current,n)||(ug(e,()=>n),r.current=n)},[t]),n.current}function uw({namespace:e,value:t}){return ub(e,t),null}let uE=({children:e,value:t,fallback:r})=>t?(0,lN.jsx)(lN.Fragment,{children:e}):r?(0,lN.jsx)(lN.Fragment,{children:r}):null;function ux(){let e=(0,lT.useRef)(null);return(!e.current||e.current.signal.aborted)&&(e.current=new AbortController),(0,lT.useEffect)(()=>{let t=e.current;return()=>t?.abort()},[]),e.current}function uD(e,t=e=>e??{}){let[r,n]=(0,lT.useState)(()=>{if(uS(e))return;let r=uh(e);if(null!==r)return t?t(r):r});return(0,lT.useEffect)(()=>{if(uS(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=>O(e,r)?e:r)})(uy(a=uh(e))),um.subscribe(t=>{let n=e in t?t[e]:null;n!==a&&(a=n,r(uy(n)))})},[e,t]),r}function uS(e){return"string"!=typeof e||0===e.trim().length}function u_(e){let t=lK(e);return(0,lT.useMemo)(()=>t.map(e=>e.id),[t])}function uC(e){return lH(e).candidateExtensions}function uk(e,t,r){let{data:n,error:a,mutate:o,isLoading:i,isValidating:s}=un()(e?iO(e,t,r):null,ov);return(0,lT.useMemo)(()=>({isLoading:i,data:n?.data.results??[],error:a,mutate:o,isValidating:s}),[n,a,i,s,o])}function uP(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 uR={},uT=`No ComponentContext has been provided. This should come from "openmrsComponentDecorator".
16
+ Usually this is already applied when using "getAsyncLifecycle" or "getSyncLifecycle".`;function uO(e,t,r){let n=uR[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 uR[e]=a,a.then(()=>{uR[e]===a&&delete uR[e]}),a}function u$(e){let{moduleName:t,extension:r}=(0,lT.useContext)(l$),n=e?.externalModuleName??t;if(!n&&!r)throw Error(uT);let a=function(e){let t=(0,lT.useMemo)(()=>t0(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 uO(e,t,e=>e.loaded?e.config:null);return r}(n),o=function(e){let t=(0,lT.useMemo)(t3,[]),r=function(e,t){let[r,n]=(0,lT.useState)(t?()=>{let r=t6(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=t6(e,t.extensionSlotName,t.extensionId);a.loaded&&a.config&&!e7(a.config,r)&&n(a.config)})},[e,t,r]),r}(t,e);if(!r&&e)throw uO(`${e.extensionSlotName}-${e.extensionId}`,t,t=>{let r=t6(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 uN=lK;function uI(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(3660),uM=r.n(uA);let uj=`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 uL(){let e=`${of}/emrapi/configuration?v=${uj}`,t=uM()(e,ov);return(0,lT.useMemo)(()=>({emrConfiguration:t.data?.data,isLoadingEmrConfiguration:t.isLoading,mutateEmrConfiguration:t.mutate,errorFetchingEmrConfiguration:t.error}),[t])}function uF(){return(0,lT.useContext)(l$).extension}let uB=lV(sT());function uV(e){let t=lK(e);return(0,lT.useMemo)(()=>Object.fromEntries(t.map(e=>[e.name,e.meta])),[t])}let uU=lV(sF());function uW(e){let{flags:t}=lF(sE);return t[e]?.enabled??!1}function uH(){let[,e]=(0,lT.useState)(0);return(0,lT.useCallback)(()=>{e(e=>e+1)},[])}function uz(e,t,r={}){return uG(e,t,uK,r)}let uK={getPaginatedUrl:(e,t,r)=>{if(!e)return null;{let n=new URL(oy(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??ov,[d,p]=(0,lT.useState)(1),m=(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),p(1),h.current=1,m.current=NaN,f.current=NaN,g.current=!1,y.current=!1);let E=(d-1)*t,x=(0,lT.useMemo)(()=>a(e,t,E),[e,t,E]),{data:D,...S}=(l?uM():un())(x,c,u);D?.data&&(m.current=o(D?.data),f.current=i(D?.data),g.current=!0);let _=Math.ceil(m.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(m.current/t);!g.current||Number.isNaN(r)||e<=r?(h.current=e,p(e)):console.warn("Invalid attempt to go to out of bounds page: "+e)},[t]);(0,lT.useEffect)(()=>{if(!g.current)return;if(Number.isNaN(m.current)){y.current||(y.current=!0,console.warn(`useServerPagination: ${v} returned no total count, so out-of-range pages cannot be detected.`));return}let e=Math.max(1,Math.ceil(m.current/t));d>e&&(console.warn(`Invalid attempt to go to out of bounds page: ${d}; returning to page ${e}.`),h.current=e,p(e))},[d,t,v,D]);let k=(0,lT.useCallback)(()=>{C(h.current+1)},[C]),P=(0,lT.useCallback)(()=>{C(h.current-1)},[C]);return{data:s(D?.data),totalPages:_,totalCount:m.current,currentPage:d,currentPageSize:f.current,paginated:_>1,showNextButton:d<_,showPreviousButton:d>1,goTo:C,goToNext:k,goToPrevious:P,...S}}function uZ(e,t,r={}){return uG(e,t,uY(),r)}function uY(){return{getPaginatedUrl:(e,t,r)=>{if(!e)return null;{let n=new URL(oy(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 uq=r(682),uJ=r.n(uq);function uX(e,t={}){return uQ(e,uK,t)}function uQ(e,t,r={}){let{swrInfiniteConfig:n,immutable:a}=r,{getNextUrl:o,getTotalCount:i,getData:s}=t,l=r.fetcher??ov,u=(0,lT.useCallback)((r,n)=>0==r?e?.toString()??null:t.getNextUrl(n.data),[e]),{data:c,size:d,setSize:p,...m}=uJ()(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:()=>{p((c?.length??0)+1)},nextUri:f,...m}}function u0(e,t={}){return u1(e,uK,t)}function u1(e,t,r={}){let n=uQ(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 u4(e,t={}){return u1(e,uY(),t)}function u2(e,t={}){return uQ(e,uY(),t)}function u3(){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 u6(){let[e,t]=(0,lT.useState)(u3);return(0,lT.useEffect)(()=>{let e=()=>{t(u3())};return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),e}let u5=e=>"small-desktop"===e||"large-desktop"===e;function u9(e){let t=(0,lT.useContext)(l$);(0,lT.useEffect)(()=>(t&&t.moduleName&&(e.componentContext=t),lc(e),()=>{ld(e.name)}),[t,e])}function u8(){return lF(lu)}let u7=[];function ce(e=null,t=null){let r=new URLSearchParams;e&&r.set("tag",e),t&&r.set("q",t);let n=r.toString(),{data:a}=u0(`${of}/location${n?"?"+n:""}`,{immutable:!0});return a??u7}function ct(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 cr(e){let t=(0,lT.useRef)(null);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 cn(e,t={}){let{abortController:r,fetchInit:n,url:a,swrConfig:o}=t,i=ux(),s=(0,lT.useMemo)(()=>n?.signal??r?.signal??i.signal,[r?.signal,n?.signal,i.signal]),l=(0,lT.useCallback)(e=>ov(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 un()(e,l,o)}function ca(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 co(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 ci(){let e=/\/patient\/([a-zA-Z0-9\-]+)\/?/.exec(location.pathname);return e&&e[1]}function cs(e){let[t,r]=(0,lT.useState)(e??ci()),{data:n,error:a,isValidating:o}=un()(t?["patient",t]:null,()=>iI(t,{}));return(0,lT.useEffect)(()=>{let e=()=>{let e=ci();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 cl(){let e=`${of}/metadatamapping/termmapping?v=custom:(metadataUuid)&code=emr.primaryIdentifierType`,{data:t,error:r,isLoading:n}=un()(e,ov);return(0,lT.useMemo)(()=>({primaryIdentifierCode:t?.data?.results[0]?.metadataUuid,isLoading:n,error:r}),[t,r,n])}function cu(e,t,r,n){let a=e?.slotName===t&&e.slotModuleName===r?e.components:null,o=new Map;for(let e of n)o.set(e,a?.get(e)??function(e,t,r){let n=s9(r),a=e=>e.extensions[n]?.meta,o=({state:n})=>{let o=lF(sT(),a),i=(0,lT.useMemo)(()=>({moduleName:t,featureName:"",extension:{extensionId:r,extensionSlotName:e,extensionSlotModuleName:t,extensionMeta:o}}),[o]);return(0,lN.jsx)(l$.Provider,{value:i,children:(0,lN.jsx)(lA,{state:n})})};return o.displayName=`RenderableExtension(${r})`,o}(t,r,e));return{slotName:t,slotModuleName:r,components:o}}function cc(e){let{extensions:t,extensionSlotModuleName:r}=lG(e),n=(0,lT.useMemo)(()=>new Set(e?t.map(e=>e.id):[]),[e,t]),[a,o]=(0,lT.useState)(()=>cu(null,e,r,n)),i=a;return a.slotName===e&&a.slotModuleName===r&&a.components.size===n.size&&[...n].every(e=>a.components.has(e))||o(i=cu(a,e,r,n)),(0,lT.useMemo)(()=>e?t.flatMap(e=>{let t=i.components.get(e.id);return t?[t]:[]}):[],[e,t,i])}function cd(){let e=(0,lT.useRef)(null),[t,r]=(0,lT.useState)(null),n=null;if(!t){if(i){let e=o_().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=null))};r(o_().getState()),n||(e.current=o_().subscribe(r))});if(n)r(n);else throw i}(0,lT.useEffect)(()=>(e.current||(e.current=o_().subscribe(({loaded:e,session:t})=>{e&&(n=t,r(t))})),()=>{e.current&&(e.current(),e.current=null)}),[]);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 cp=({privilege:e,fallback:t,children:r})=>{let[n,a]=(0,lT.useState)(null);return((0,lT.useEffect)(()=>{let e=o_(),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&&oR(e,n))?(0,lN.jsx)(lN.Fragment,{children:r}):t?(0,lN.jsx)(lN.Fragment,{children:t}):null};var cm=r(222),cf=r.n(cm),ch=r(5602);let cg=new Map;function cy(){for(let e of Array.from(cg.values()))e()}let cv={setVisitContext:(e,t)=>null==t?{manuallySetVisitUuid:null}:{manuallySetVisitUuid:t.uuid,patientUuid:t.patient?.uuid}};function cb(e){let t=(0,lT.useId)();return(0,lT.useEffect)(()=>{if(e)return cg.set(t,e),()=>{cg.delete(t)}},[t,e]),{...lB(iK(),cv),mutateVisit:cy}}function cw(e,t=iH){let r=(0,lT.useRef)(void 0),{patientUuid:n,manuallySetVisitUuid:a,setVisitContext:o}=cb((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:p}=un()(e?`${of}/visit${s}`:null,ov),{data:m,error:f,mutate:h,isValidating:g}=un()(e&&i?`${of}/visit${l}`:null,ov),y=(0,lT.useMemo)(()=>u?.data.results.find(e=>null===e.stopDatetime)??null,[u]),v=(0,lT.useMemo)(()=>i&&m?m.data:null,[m,i]),b=(0,lT.useRef)(null);(0,lT.useEffect)(()=>{!p&&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,p,g,n]);let w=(0,lT.useCallback)(()=>{d(),h()},[d,h]);(0,lT.useEffect)(()=>{r.current=w},[w]);let E=!!(!u||i&&!m),x=!!(i?f:c);return{error:c||f,mutate:w,isValidating:p||g,activeVisit:y,currentVisit:v,currentVisitIsRetrospective:!!i,isLoading:E&&!x}}cf().extend(ch);let cE=[];function cx(){let{data:e}=uM()(iB,iV);return e??cE}let cD=new Map;async function cS(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 ir(a);return i&&Object.hasOwn(i,o)&&"function"==typeof i[o]?cC(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`),c_)}let c_={bootstrap:()=>Promise.resolve(),mount:()=>Promise.resolve(),unmount:()=>Promise.resolve()};async function cC(e,t){if(e in cD)await cD[e];else{let r=t??await ir(e);await (cD[e]=new Promise((t,n)=>{if(Object.hasOwn(r,"startupApp")){let a=r.startupApp;if("function"==typeof a)return Promise.resolve(a()).then(()=>{rb(e),t(null)}).catch(n)}rb(e),t(null)}))}}function ck(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
19
19
  a 'slot' property. Only the 'slots' property will be honored.`);let n=t.slots?t.slots:t.slot?[t.slot]:[];if(!t.component)return void console.error(`The extension ${r} from ${e} is missing a 'component' entry and thus cannot be registered.
@@ -36,4 +36,4 @@ To fix this, ensure that you define the "component" field inside the page defini
36
36
  * {
37
37
  overscroll-behavior: contain;
38
38
  }
39
- }`.trim(),document.head.prepend(n),o=HTMLElement.prototype.focus,HTMLElement.prototype.focus=function(e){let t=((e=document)=>e.activeElement)(),r=null!=t&&bm(t);o.call(this,{...e,preventScroll:!0}),e&&e.preventScroll||bv(this,r)},i=pO(by(document,"touchstart",t=>{let n=ms(t);e=gg(n)?n:gy(n,!0),r=!1;let a=n.ownerDocument.defaultView.getSelection();a&&!a.isCollapsed&&a.containsNode(n,!0)&&(r=!0),t.composedPath().some(e=>e instanceof HTMLInputElement&&"range"===e.type)&&(r=!0),"selectionStart"in n&&"selectionEnd"in n&&n.selectionStart<n.selectionEnd&&n.ownerDocument.activeElement===n&&(r=!0)},{passive:!1,capture:!0}),by(document,"touchmove",t=>{if(2!==t.touches.length&&!r){if(!e||e===document.documentElement||e===document.body)return void t.preventDefault();e.scrollHeight===e.clientHeight&&e.scrollWidth===e.clientWidth&&t.preventDefault()}},{passive:!1,capture:!0}),by(document,"blur",e=>{let t=ms(e),r=e.relatedTarget;if(r&&bm(r))r.focus({preventScroll:!0}),bv(r,bm(t));else if(!r){let e=t.parentElement?.closest("[tabindex]");e?.focus({preventScroll:!0})}},!0)),()=>{t(),i(),n.remove(),HTMLElement.prototype.focus=o}):pO((s=window.innerWidth-document.documentElement.clientWidth)>0&&("scrollbarGutter"in document.documentElement.style?bg(document.documentElement,"scrollbarGutter","stable"):bg(document.documentElement,"paddingRight",`${s}px`)),bg(document.documentElement,"overflow","hidden"))),()=>{0==--bh&&c()}}},[t])}({isDisabled:o||!t.isOpen}),(0,lT.useEffect)(()=>{if(t.isOpen&&n.current)if(o){var e,r,i=a?.current??n.current;let t=vJ[vJ.length-1];return t&&!t.visibleNodes.has(i)?(t.visibleNodes.add(i),()=>{t.visibleNodes.delete(i)}):void 0}else{let t,o,i,s,l,u,c,d,p,m,f;return e=[a?.current??n.current],o=(r={shouldUseInert:!0})instanceof(t=mo(e?.[0])).Element?{root:r}:r,i=o?.root??document.body,s=o?.shouldUseInert&&vY,l=new Set(e),u=new Set,c=(e,r)=>{s&&e instanceof t.HTMLElement?e.inert=r:r?e.setAttribute("aria-hidden","true"):(e.removeAttribute("aria-hidden"),e instanceof t.HTMLElement&&(e.inert=!1))},d=e=>{for(let t of e.querySelectorAll("[data-live-announcer], [data-react-aria-top-layer]"))l.add(t);let t=e=>{if(u.has(e)||l.has(e)||e.parentElement&&u.has(e.parentElement)&&"row"!==e.parentElement.getAttribute("role"))return NodeFilter.FILTER_REJECT;for(let t of l)if(mi(e,t))return NodeFilter.FILTER_SKIP;return NodeFilter.FILTER_ACCEPT},r=y$(ma(e),e,NodeFilter.SHOW_ELEMENT,{acceptNode:t}),n=t(e);if(n===NodeFilter.FILTER_ACCEPT&&p(e),n!==NodeFilter.FILTER_REJECT){let e=r.nextNode();for(;null!=e;)p(e),e=r.nextNode()}},p=e=>{let r=vq.get(e)??0;(s&&e instanceof t.HTMLElement?e.inert:"true"===e.getAttribute("aria-hidden"))&&0===r||(0===r&&c(e,!0),u.add(e),vq.set(e,r+1))},vJ.length&&vJ[vJ.length-1].disconnect(),d(i),(m=new MutationObserver(e=>{for(let r of e)if("childList"===r.type&&r.target.isConnected&&![...l,...u].some(e=>mi(e,r.target)))for(let e of r.addedNodes){var t;(e instanceof HTMLElement||e instanceof SVGElement)&&("true"===(t=e).dataset.liveAnnouncer||void 0!==t.dataset.reactAriaTopLayer)?l.add(e):e instanceof Element&&d(e)}})).observe(i,{childList:!0,subtree:!0}),f={visibleNodes:l,hiddenNodes:u,observe(){m.observe(i,{childList:!0,subtree:!0})},disconnect(){m.disconnect()}},vJ.push(f),()=>{for(let e of(m.disconnect(),u)){let t=vq.get(e);null!=t&&(1===t?(c(e,!1),vq.delete(e)):vq.set(e,t-1))}f===vJ[vJ.length-1]?(vJ.pop(),vJ.length&&vJ[vJ.length-1].observe()):vJ.splice(vJ.indexOf(f),1)}}},[o,t.isOpen,n,a]),{popoverProps:pG(d,m),arrowProps:f,underlayProps:p,placement:h,triggerAnchorPoint:g}}({...n,offset:null!=(a=n.offset)?a:8,arrowSize:s,groupRef:p?d:u},e),y=n.popoverRef,v=bx(y,!!g)||n.isEntering||!1,b=pq({...n,defaultClassName:"react-aria-Popover",values:{trigger:n.trigger||null,placement:g,isEntering:v,isExiting:t}}),w=!n.isNonModal||"SubmenuTrigger"===n.trigger,[E,x]=(0,lT.useState)(!1);p$(()=>{y.current&&x(w&&!y.current.querySelector("[role=dialog]"))},[y,w]),(0,lT.useEffect)(()=>{var e;let t,r;E&&y.current&&!y.current.contains(document.activeElement)&&(r=((e=document)=>e.activeElement)(t=ma(e=y.current)),"virtual"===b_?mQ(()=>{((e=document)=>e.activeElement)(t)===r&&e.isConnected&&mr(e)}):mr(e))},[E,y]);let D={...m.style,...b.style},S=lO().createElement("div",{...pG(mt(n),m),...b,role:E?"dialog":void 0,tabIndex:E?-1:void 0,"aria-label":n["aria-label"],"aria-labelledby":n["aria-labelledby"],ref:y,slot:n.slot||void 0,style:D,dir:n.dir,"data-trigger":n.trigger,"data-placement":g,"data-entering":v||void 0,"data-exiting":t||void 0},!n.isNonModal&&lO().createElement(bE,{onDismiss:e.close}),lO().createElement(vZ.Provider,{value:{...h,placement:g,ref:i}},b.children),lO().createElement(bE,{onDismiss:e.close}));return p?lO().createElement(vL,{...n,shouldContainFocus:E,isExiting:t,portalContainer:null!=(o=null!=r?r:null==d?void 0:d.current)?o:void 0},S):lO().createElement(vL,{...n,shouldContainFocus:E,isExiting:t,portalContainer:r},!n.isNonModal&&e.isOpen&&lO().createElement("div",{"data-testid":"underlay",...f,style:{position:"fixed",inset:0}}),lO().createElement("div",{ref:u,style:{display:"contents"}},lO().createElement(bB.Provider,{value:u},S)))}function bW(e){return e?.start!=null&&null!=e.end}let bH=(0,lT.createContext)(null),bz=(0,lT.createContext)(null),bK=(0,lT.createContext)(null),bG=(0,lT.createContext)(null),bZ=(0,lT.forwardRef)(function(e,t){var r,n;[e,t]=pX(e,t,bH);let{validationBehavior:a}=pJ(vz)||{},o=null!=(n=null!=(r=e.validationBehavior)?r:a)?n:"native",i=function(e){let t=bL(e),[r,n]=yc(e.value,e.defaultValue||null,e.onChange),[a]=(0,lT.useState)(r),o=r||e.placeholderValue||null,[i,s]=vv(o,e.granularity),l=null!=r?r.toDate(s??"UTC"):null,u="hour"===i||"minute"===i||"second"===i,c=e.shouldCloseOnSelect??!0,[d,p]=(0,lT.useState)(null),[m,f]=(0,lT.useState)(null);if(r&&(d=r,"hour"in r&&(m=r)),o&&!(i in o))throw Error("Invalid granularity "+i+" for value "+o.toString());let h=r?.calendar.identifier==="gregory"&&"BC"===r.era,g=(0,lT.useMemo)(()=>({granularity:i,timeZone:s,hideTimeZone:e.hideTimeZone,hourCycle:e.hourCycle,shouldForceLeadingZeros:e.shouldForceLeadingZeros,showEra:h}),[i,e.hourCycle,e.shouldForceLeadingZeros,s,e.hideTimeZone,h]),{minValue:y,maxValue:v,isDateUnavailable:b}=e,w=(0,lT.useMemo)(()=>vp(r,y,v,b,g),[r,y,v,b,g]),E=vo({...e,value:r,builtinValidation:w}),x=E.displayValidation.isInvalid,D=e.validationState||(x?"invalid":null),S=(e,t)=>{n("timeZone"in t?t.set(hK(e)):hG(e,t)),p(null),f(null),E.commitValidation()};return{...E,value:r,defaultValue:e.defaultValue??a,setValue:n,dateValue:d,timeValue:m,setDateValue:r=>{let a="function"==typeof c?c():c;u?m||a?S(r,m||vg(e.defaultValue||e.placeholderValue)):p(r):(n(r),E.commitValidation()),a&&t.setOpen(!1)},setTimeValue:e=>{d&&e?S(d,e):f(e)},granularity:i,hasTime:u,...t,setOpen(n){!n&&!r&&d&&u&&S(d,m||vg(e.defaultValue||e.placeholderValue)),t.setOpen(n)},validationState:D,isInvalid:x,formatValue:(e,t)=>l?new f1(e,vh(t,g)).format(l):"",getDateFormatter:(e,t)=>new f1(e,vh({},{...g,...t}))}}({...e,validationBehavior:o}),s=(0,lT.useRef)(null),[l,u]=pQ(!e["aria-label"]&&!e["aria-labelledby"]),{groupProps:c,labelProps:d,fieldProps:p,buttonProps:m,dialogProps:f,calendarProps:h,descriptionProps:g,errorMessageProps:y,...v}=function(e,t,r){var n;let a=pH(),o=pH(),i=pH(),s=hi((n=yQ)&&n.__esModule?n.default:n,"@react-aria/datepicker"),{isInvalid:l,validationErrors:u,validationDetails:c}=t.displayValidation,{labelProps:d,fieldProps:p,descriptionProps:m,errorMessageProps:f}=y4({...e,labelElementType:"span",isInvalid:l,errorMessage:e.errorMessage||u}),h=y0(t,r),g=p["aria-labelledby"]||p.id,{locale:y}=fZ(),v=t.formatValue(y,{month:"long"}),b=gD(v?s.format("selectedDateDescription",{date:v}):""),w=[b["aria-describedby"],p["aria-describedby"]].filter(Boolean).join(" ")||void 0,E=mt(e),x=(0,lT.useMemo)(()=>yZ(r),[r]),D=(0,lT.useRef)(!1),{focusWithinProps:S}=fw({...e,isDisabled:t.isOpen,onBlurWithin:t=>{mi(document.getElementById(o),t.relatedTarget)||(D.current=!1,e.onBlur?.(t),e.onFocusChange?.(!1))},onFocusWithin:t=>{D.current||(D.current=!0,e.onFocus?.(t),e.onFocusChange?.(!0))}});return{groupProps:pG(E,h,p,b,S,{role:"group","aria-disabled":e.isDisabled||null,"aria-labelledby":g,"aria-describedby":w,onKeyDown(r){!t.isOpen&&e.onKeyDown&&e.onKeyDown(r)},onKeyUp(r){!t.isOpen&&e.onKeyUp&&e.onKeyUp(r)}}),labelProps:{...d,onClick:()=>{x.focusFirst()}},fieldProps:{...p,id:i,[y5]:"presentation","aria-describedby":w,value:t.value,defaultValue:t.defaultValue,onChange:t.setValue,placeholderValue:e.placeholderValue,hideTimeZone:e.hideTimeZone,hourCycle:e.hourCycle,shouldForceLeadingZeros:e.shouldForceLeadingZeros,granularity:e.granularity,isDisabled:e.isDisabled,isReadOnly:e.isReadOnly,isRequired:e.isRequired,validationBehavior:e.validationBehavior,[va]:t,autoFocus:e.autoFocus,name:e.name,form:e.form},descriptionProps:m,errorMessageProps:f,buttonProps:{...b,id:a,"aria-haspopup":"dialog","aria-label":s.format("calendar"),"aria-labelledby":`${a} ${g}`,"aria-describedby":w,"aria-expanded":t.isOpen,isDisabled:e.isDisabled||e.isReadOnly,onPress:()=>t.setOpen(!0)},dialogProps:{id:o,"aria-labelledby":`${a} ${g}`},calendarProps:{autoFocus:!0,value:t.dateValue,onChange:t.setDateValue,minValue:e.minValue,maxValue:e.maxValue,isDisabled:e.isDisabled,isReadOnly:e.isReadOnly,isDateUnavailable:e.isDateUnavailable,defaultFocusedValue:t.dateValue?void 0:e.placeholderValue,isInvalid:t.isInvalid,errorMessage:"function"==typeof e.errorMessage?e.errorMessage(t.displayValidation):e.errorMessage||t.displayValidation.validationErrors.join(" "),firstDayOfWeek:e.firstDayOfWeek,pageBehavior:e.pageBehavior},isInvalid:l,validationErrors:u,validationDetails:c}}({...p0(e),label:u,validationBehavior:o},i,s),[b,w]=(0,lT.useState)(null),E=(0,lT.useCallback)(()=>{s.current&&w(s.current.offsetWidth+"px")},[]);bs({ref:s,onResize:E});let{focusProps:x,isFocused:D,isFocusVisible:S}=fE({within:!0}),_=pq({...e,values:{state:i,isFocusWithin:D,isFocusVisible:S,isDisabled:e.isDisabled||!1,isInvalid:i.isInvalid,isOpen:i.isOpen},defaultClassName:"react-aria-DatePicker"}),C=mt(e);return delete C.id,lO().createElement(pY,{values:[[bK,i],[yP,{...c,ref:s,isInvalid:i.isInvalid}],[vP,p],[fT,{...m,isPressed:i.isOpen}],[vK,{...d,ref:l,elementType:"span"}],[yg,h],[vB,i],[bF,{trigger:"DatePicker",triggerRef:s,placement:"bottom start",style:{"--trigger-width":b}}],[vF,f],[fN,{slots:{description:g,errorMessage:y}}],[vU,v]]},lO().createElement("div",{...x,...C,..._,ref:t,slot:e.slot||void 0,"data-focus-within":D||void 0,"data-invalid":i.isInvalid||void 0,"data-focus-visible":S||void 0,"data-disabled":e.isDisabled||void 0,"data-open":i.isOpen||void 0}))}),bY=(0,lT.forwardRef)(function(e,t){var r,n;[e,t]=pX(e,t,bz);let{validationBehavior:a}=pJ(vz)||{},o=null!=(n=null!=(r=e.validationBehavior)?r:a)?n:"native",i=function(e){let t=bL(e),[r,n]=yc(e.value,e.defaultValue||null,e.onChange),[a]=(0,lT.useState)(r),[o,i]=(0,lT.useState)(()=>r||{start:null,end:null});null==r&&o.start&&o.end&&i(o={start:null,end:null});let s=r||o,l=e=>{i(s=e||{start:null,end:null}),bW(s)?n(s):n(null)},[u,c]=vv(s?.start||s?.end||e.placeholderValue||null,e.granularity),d="hour"===u||"minute"===u||"second"===u,p=e.shouldCloseOnSelect??!0,[m,f]=(0,lT.useState)(null),[h,g]=(0,lT.useState)(null);s&&bW(s)&&(m=s,"hour"in s.start&&(h=s));let y=(e,t)=>{l({start:"timeZone"in t.start?t.start.set(hK(e.start)):hG(e.start,t.start),end:"timeZone"in t.end?t.end.set(hK(e.end)):hG(e.end,t.end)}),f(null),g(null),C.commitValidation()},v=r=>{let n="function"==typeof p?p():p;d?bW(r)&&(n||h?.start&&h?.end)?y(r,{start:h?.start||vg(e.placeholderValue),end:h?.end||vg(e.placeholderValue)}):f(r):bW(r)?(l(r),C.commitValidation()):f(r),n&&t.setOpen(!1)},b=e=>{bW(m)&&bW(e)?y(m,e):g(e)},w=s?.start?.calendar.identifier==="gregory"&&"BC"===s.start.era||s?.end?.calendar.identifier==="gregory"&&"BC"===s.end.era,E=(0,lT.useMemo)(()=>({granularity:u,timeZone:c,hideTimeZone:e.hideTimeZone,hourCycle:e.hourCycle,shouldForceLeadingZeros:e.shouldForceLeadingZeros,showEra:w}),[u,e.hourCycle,e.shouldForceLeadingZeros,c,e.hideTimeZone,w]),{minValue:x,maxValue:D,isDateUnavailable:S}=e,_=(0,lT.useMemo)(()=>{var e;let t;return e=s,t=vu(vp(e?.start??null,x,D,S,E),vp(e?.end??null,x,D,S,E)),e?.end!=null&&null!=e.start&&0>e.end.compare(e.start)&&(t=vu(t,{isInvalid:!0,validationErrors:[(he.getGlobalDictionaryForPackage("@react-stately/datepicker")||vc).getStringForLocale("rangeReversed",vd())],validationDetails:{...ve,rangeUnderflow:!0,rangeOverflow:!0,valid:!1}})),t},[s,x,D,S,E]),C=vo({...e,value:r,name:(0,lT.useMemo)(()=>[e.startName,e.endName].filter(e=>null!=e),[e.startName,e.endName]),builtinValidation:_}),k=C.displayValidation.isInvalid,P=e.validationState||(k?"invalid":null);return{...C,value:s,defaultValue:e.defaultValue??a,setValue:l,dateRange:m,timeRange:h,granularity:u,hasTime:d,setDate(e,t){"start"===e?v({start:t,end:m?.end??null}):v({start:m?.start??null,end:t})},setTime(e,t){"start"===e?b({start:t,end:h?.end??null}):b({start:h?.start??null,end:t})},setDateTime(e,t){"start"===e?l({start:t,end:s?.end??null}):l({start:s?.start??null,end:t})},setDateRange:v,setTimeRange:b,...t,setOpen(r){!r&&!(s?.start&&s?.end)&&bW(m)&&d&&y(m,{start:h?.start||vg(e.placeholderValue),end:h?.end||vg(e.placeholderValue)}),t.setOpen(r)},validationState:P,isInvalid:k,formatValue(t,r){let n;if(!s||!s.start||!s.end)return null;let a="timeZone"in s.start?s.start.timeZone:void 0,o=e.granularity||(s.start&&"minute"in s.start?"minute":"day"),i="timeZone"in s.end?s.end.timeZone:void 0,l=e.granularity||(s.end&&"minute"in s.end?"minute":"day"),u=vh(r,{granularity:o,timeZone:a,hideTimeZone:e.hideTimeZone,hourCycle:e.hourCycle,showEra:"gregory"===s.start.calendar.identifier&&"BC"===s.start.era||"gregory"===s.end.calendar.identifier&&"BC"===s.end.era}),c=s.start.toDate(a||"UTC"),d=s.end.toDate(i||"UTC"),p=new f1(t,u);if(a===i&&o===l&&0!==s.start.compare(s.end)){try{let e=p.formatRangeToParts(c,d),t=-1;for(let r=0;r<e.length;r++){let n=e[r];if("shared"===n.source&&"literal"===n.type)t=r;else if("endRange"===n.source)break}let r="",n="";for(let a=0;a<e.length;a++)a<t?r+=e[a].value:a>t&&(n+=e[a].value);return{start:r,end:n}}catch{}n=p}else n=new f1(t,vh(r,{granularity:l,timeZone:i,hideTimeZone:e.hideTimeZone,hourCycle:e.hourCycle}));return{start:p.format(c),end:n.format(d)}},getDateFormatter:(e,t)=>new f1(e,vh({},{...E,...t}))}}({...e,validationBehavior:o}),s=(0,lT.useRef)(null),[l,u]=pQ(!e["aria-label"]&&!e["aria-labelledby"]),{groupProps:c,labelProps:d,startFieldProps:p,endFieldProps:m,buttonProps:f,dialogProps:h,calendarProps:g,descriptionProps:y,errorMessageProps:v,...b}=function(e,t,r){var n;let a=hi((n=yQ)&&n.__esModule?n.default:n,"@react-aria/datepicker"),{isInvalid:o,validationErrors:i,validationDetails:s}=t.displayValidation,{labelProps:l,fieldProps:u,descriptionProps:c,errorMessageProps:d}=y4({...e,labelElementType:"span",isInvalid:o,errorMessage:e.errorMessage||i}),p=u["aria-labelledby"]||u.id,{locale:m}=fZ(),f=t.formatValue(m,{month:"long"}),h=gD(f?a.format("selectedRangeDescription",{startDate:f.start,endDate:f.end}):""),g={"aria-label":a.format("startDate"),"aria-labelledby":p},y={"aria-label":a.format("endDate"),"aria-labelledby":p},v=pH(),b=pH(),w=y0(t,r),E=[h["aria-describedby"],u["aria-describedby"]].filter(Boolean).join(" ")||void 0,x=(0,lT.useMemo)(()=>yZ(r,{accept:e=>e.id!==v}),[r,v]),D={[y9]:x,[y5]:"presentation","aria-describedby":E,placeholderValue:e.placeholderValue,hideTimeZone:e.hideTimeZone,hourCycle:e.hourCycle,granularity:e.granularity,shouldForceLeadingZeros:e.shouldForceLeadingZeros,isDisabled:e.isDisabled,isReadOnly:e.isReadOnly,isRequired:e.isRequired,validationBehavior:e.validationBehavior},S=mt(e),_=(0,lT.useRef)(!1),{focusWithinProps:C}=fw({...e,isDisabled:t.isOpen,onBlurWithin:t=>{mi(document.getElementById(b),t.relatedTarget)||(_.current=!1,e.onBlur?.(t),e.onFocusChange?.(!1))},onFocusWithin:t=>{_.current||(_.current=!0,e.onFocus?.(t),e.onFocusChange?.(!0))}}),k=(0,lT.useRef)(vr),P=(0,lT.useRef)(vr);return{groupProps:pG(S,w,u,h,C,{role:"group","aria-disabled":e.isDisabled||null,"aria-describedby":E,onKeyDown(r){!t.isOpen&&e.onKeyDown&&e.onKeyDown(r)},onKeyUp(r){!t.isOpen&&e.onKeyUp&&e.onKeyUp(r)}}),labelProps:{...l,onClick:()=>{x.focusFirst()}},buttonProps:{...h,id:v,"aria-haspopup":"dialog","aria-label":a.format("calendar"),"aria-labelledby":`${v} ${p}`,"aria-describedby":E,"aria-expanded":t.isOpen,isDisabled:e.isDisabled||e.isReadOnly,onPress:()=>t.setOpen(!0)},dialogProps:{id:b,"aria-labelledby":`${v} ${p}`},startFieldProps:{...g,...D,value:t.value?.start??null,defaultValue:t.defaultValue?.start,onChange:e=>t.setDateTime("start",e),autoFocus:e.autoFocus,name:e.startName,form:e.form,[va]:{realtimeValidation:t.realtimeValidation,displayValidation:t.displayValidation,updateValidation(e){k.current=e,t.updateValidation(vu(e,P.current))},resetValidation:t.resetValidation,commitValidation:t.commitValidation}},endFieldProps:{...y,...D,value:t.value?.end??null,defaultValue:t.defaultValue?.end,onChange:e=>t.setDateTime("end",e),name:e.endName,form:e.form,[va]:{realtimeValidation:t.realtimeValidation,displayValidation:t.displayValidation,updateValidation(e){P.current=e,t.updateValidation(vu(k.current,e))},resetValidation:t.resetValidation,commitValidation:t.commitValidation}},descriptionProps:c,errorMessageProps:d,calendarProps:{autoFocus:!0,value:t.dateRange?.start&&t.dateRange.end?t.dateRange:null,onChange:t.setDateRange,minValue:e.minValue,maxValue:e.maxValue,isDisabled:e.isDisabled,isReadOnly:e.isReadOnly,isDateUnavailable:e.isDateUnavailable,allowsNonContiguousRanges:e.allowsNonContiguousRanges,defaultFocusedValue:t.dateRange?void 0:e.placeholderValue,isInvalid:t.isInvalid,errorMessage:"function"==typeof e.errorMessage?e.errorMessage(t.displayValidation):e.errorMessage||t.displayValidation.validationErrors.join(" "),firstDayOfWeek:e.firstDayOfWeek,pageBehavior:e.pageBehavior},isInvalid:o,validationErrors:i,validationDetails:s}}({...p0(e),label:u,validationBehavior:o},i,s),[w,E]=(0,lT.useState)(null),x=(0,lT.useCallback)(()=>{s.current&&E(s.current.offsetWidth+"px")},[]);bs({ref:s,onResize:x});let{focusProps:D,isFocused:S,isFocusVisible:_}=fE({within:!0}),C=pq({...e,values:{state:i,isFocusWithin:S,isFocusVisible:_,isDisabled:e.isDisabled||!1,isInvalid:i.isInvalid,isOpen:i.isOpen},defaultClassName:"react-aria-DateRangePicker"}),k=mt(e);return delete k.id,lO().createElement(pY,{values:[[bG,i],[yP,{...c,ref:s,isInvalid:i.isInvalid}],[fT,{...f,isPressed:i.isOpen}],[vK,{...d,ref:l,elementType:"span"}],[yy,g],[vB,i],[bF,{trigger:"DateRangePicker",triggerRef:s,placement:"bottom start",style:{"--trigger-width":w}}],[vF,h],[vP,{slots:{start:p,end:m}}],[fN,{slots:{description:y,errorMessage:v}}],[vU,b]]},lO().createElement("div",{...D,...k,...C,ref:t,slot:e.slot||void 0,"data-focus-within":S||void 0,"data-invalid":i.isInvalid||void 0,"data-focus-visible":_||void 0,"data-disabled":e.isDisabled||void 0,"data-open":i.isOpen||void 0}))});function bq(e){return lO().createElement(fG,e)}function bJ(e,t,r=!1){if(null==e)return r?e:void 0;if("string"==typeof e&&!e)return r?null:void 0;if(e instanceof hI||e instanceof hM||e instanceof hj)return t?hZ(e,t):e;{let r=cf()(e).toDate(),n=new hI(r.getFullYear(),r.getMonth()+1,r.getDate());return t?hZ(n,t):n}}function bX(e){if(e)return e.toDate(h5())}function bQ(e){if("string"==typeof e&&0!==e.trim().length)try{return new Intl.Locale(e.replace(/[_@]/g,"-")).toString()}catch{return}}function b0(e){let t=e??"",r=bQ(t);if(!r)return t;try{return new Intl.DisplayNames([r],{type:"language"}).of(r)??t}catch{return t}}function b1(){let e=window.i18next.language,t=bQ(e)??e;return"ht"===t&&(t="fr-HT"),t}if("u">typeof navigator){let e=navigator;et=Array.isArray(e.languages)?e.languages[0]:e.language}else if("u">typeof process){let e=process.env;et=e.LC_ALL||e.LC_MESSAGES||e.LANG||e.LANGUAGE}var b4=function(e){e=(e=e.replace(/_/g,"-")).replace(/[.:][\w-]*$/,"");try{return new Intl.Locale(e).baseName}catch{return"en-US"}}(et||"en-US"),b2=class extends Date{invalid=null;isValid(){return!Number.isNaN(this.valueOf())}},b3={};for(let e=1;e<100;e++)b3[(e<=9?"0":"")+e]=e+(e>51?1900:2e3);var b6={arab:1632,arabext:1776,bali:6992,beng:2534,deva:2406,fullwide:65296,gujr:2790,khmr:6112,knda:3302,laoo:3792,limb:6470,mlym:3430,mong:6160,mymr:4160,orya:2918,tamldec:3046,telu:3174,thai:3664,tibt:3872},b5="[1234567890一二三四五六七八九〇\\d]",b9={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,"0":0,"1":1,"2":2,"3":3,"4":4,"5":5,"6":6,"7":7,"8":8,"9":9,〇:0,一:1,二:2,三:3,四:4,五:5,六:6,七:7,八:8,九:9},b8={},b7={"Eastern Daylight Time":-240,"Eastern Standard Time":-300,"Central Daylight Time":-300,"Central Standard Time":-360,"Mountain Daylight Time":-360,"Mountain Standard Time":-420,"Pacific Daylight Time":-420,"Pacific Standard Time":-480,"Coordinated Universal Time":0,ACDT:630,ACST:570,ACT:480,ADT:-180,AEDT:660,AEST:600,AFT:270,AKDT:-480,AKST:-540,AMST:-180,AMT:-240,ART:-180,AST:180,AWDT:540,AWST:480,AZOST:-60,AZT:240,BDT:360,BIOT:360,BIT:-720,BOT:-240,BRST:-120,BRT:-180,BTT:360,CAT:120,CCT:390,CDT:-300,CEDT:120,CEST:120,CET:60,CHADT:825,CHAST:765,CHOT:480,ChST:600,CHUT:600,CIST:-480,CIT:480,CKT:-600,CLST:-180,CLT:-240,COST:-240,COT:-300,CST:-360,CT:480,CVT:-60,CXT:420,DAVT:420,DDUT:600,DFT:60,EASST:-300,EAST:-360,EAT:180,ECT:-300,EDT:-240,EEDT:180,EEST:180,EET:120,EGST:0,EGT:-60,EIT:540,EST:-300,FET:180,FJT:720,FKST:-180,FKT:-240,FNT:-120,GALT:-360,GAMT:-540,GET:240,GFT:-180,GILT:720,GIT:-540,GMT:0,GST:-120,GYT:-240,HADT:-540,HAEC:120,HAST:-600,HKT:480,HMT:300,HOVT:420,HST:-600,IBST:0,ICT:420,IDT:180,IOT:180,IRDT:270,IRKT:480,IRST:210,IST:120,JST:540,KGT:360,KOST:660,KRAT:420,KST:540,LHST:630,LINT:840,MAGT:720,MART:-510,MAWT:300,MDT:-360,MET:60,MEST:120,MHT:720,MIST:660,MIT:-510,MMT:390,MSK:180,MST:-420,MUT:240,MVT:300,MYT:480,NCT:660,NDT:-90,NFT:660,NPT:345,NST:-150,NT:-150,NUT:-660,NZDT:780,NZST:720,OMST:360,ORAT:300,PDT:-420,PET:-300,PETT:720,PGT:600,PHOT:780,PKT:300,PMDT:-120,PMST:-180,PONT:660,PST:-480,PYST:-180,PYT:-240,RET:240,ROTT:-180,SAKT:660,SAMT:240,SAST:120,SBT:660,SCT:240,SGT:480,SLST:330,SRET:660,SRT:-180,SST:480,SYOT:180,TAHT:-600,THA:420,TFT:300,TJT:300,TKT:780,TLT:540,TMT:300,TOT:780,TVT:720,UCT:0,ULAT:480,USZ1:120,UTC:0,UYST:-120,UYT:-180,UZT:300,VET:-240,VLAT:600,VOLT:240,VOST:360,VUT:660,WAKT:720,WAST:120,WAT:60,WEDT:60,WEST:60,WET:0,WIT:420,WST:480,YAKT:540,YEKT:300},we={zone:b7,year:b3,meridiem:{am:0,pm:12,"a.m.":0,"p.m.":12},month:{january:1,jan:1,february:2,feb:2,march:3,mar:3,april:4,apr:4,may:5,june:6,jun:6,july:7,jul:7,august:8,aug:8,september:9,sep:9,october:10,oct:10,november:11,nov:11,december:12,dec:12},dayname:{sunday:0,sun:0,monday:1,mon:1,tuesday:2,tue:2,wednesday:3,wed:3,thursday:4,thu:4,friday:5,fri:5,saturday:6,sat:6},digit:{}},wt={MONTHNAME:"january|february|march|april|may|june|july|august|september|october|november|december|jan\\.?|feb\\.?|mar\\.?|apr\\.?|may\\.?|jun\\.?|jul\\.?|aug\\.?|sep\\.?|oct\\.?|nov\\.?|dec\\.?",DAYNAME:"sunday|monday|tuesday|wednesday|thursday|friday|saturday|sun\\.?|mon\\.?|tue\\.?|wed\\.?|thu\\.?|fri\\.?|sat\\.?",ZONE:"\\(?(?:"+Object.keys(b7).join("|")+")\\)?",MERIDIEM:"am|pm|a.m.|p.m.",ORDINAL:"st|nd|rd|th|\\.",YEAR:"\\d{4}|\\d{2}",YEAR2:"\\d{2}",YEAR4:"\\d{4}",YEAR6:"-\\d{6}|\\+?\\d{5,6}",MONTH:"1[0-2]|0?[1-9]",MONTH2:"1[0-2]|0[1-9]",DAY:"3[01]|[12]\\d|0?[1-9]",DAY2:"3[01]|[12]\\d|0[1-9]",OFFSET:"(?:GMT)?[\xb1−+-](?:[01]\\d[0-5]\\d|[01]\\d:[0-5]\\d|[01]?\\d)",H24:"[01]\\d|2[0-3]",H12:"0?[1-9]|1[012]",MIN:"[0-5]\\d",SEC:"[0-5]\\d|60",MS:"\\d{9}|\\d{6}|\\d{1,3}",GAP:"[\\s/.,-]{1,}"},wr={...wt,YEAR:"*{4}|*{2}",YEAR4:"*{4}",YEAR6:"-*{6}|\\+?*{5,6}",MONTH:"*{1,2}",MONTH2:"*{2}",DAY:"*{1,2}",DAY2:"*{2}",OFFSET:"(?:GMT)?[\xb1−+-](?:*{4}|*{2}:*{2}|*{1,2})",H24:"*{2}",H12:"*{1,2}",MIN:"*{2}",SEC:"*{2}",MS:"*{9}|*{6}|*{3}"},wn={},wa=class e{locale;lookups;vars;numberingSystem;baseName;dateOptions;static factory(t=b4){return wn[t.toLowerCase()]||(wn[t.toLowerCase()]=new e(t)),wn[t.toLowerCase()]}constructor(e=b4){this.locale=e,this.lookups={...we},this.vars={...wt};let t=new Intl.NumberFormat(this.locale);this.numberingSystem=t.resolvedOptions().numberingSystem,this.dateOptions=new Intl.DateTimeFormat(this.locale).resolvedOptions(),this.baseName=new Intl.Locale(this.locale).baseName,this.build()}toInt(e){if("number"==typeof e)return e;if("string"!=typeof e)return;if("latn"===this.numberingSystem&&!this.baseName.startsWith("zh")){let t=parseInt(e,10);if(!isNaN(t))return t}let t="";for(let r=0;r<e.length;r++)t+=String(this.lookups.digit[e[r]]);return parseInt(t,10)}millisecondToInt(e){if("number"==typeof e)return e;if("string"!=typeof e)return;let t=e.slice(0,3);return 1===t.length?100*this.toInt(t):2===t.length?10*this.toInt(t):this.toInt(t)}monthNameToInt(e){if("string"!=typeof e)return;let t=e.toLocaleLowerCase(this.locale).replace(/\.$/,"");return this.lookups.month[t]||12}h12ToInt(e,t){if("string"!=typeof e)return;let r=this.lookups.meridiem[t?.toLowerCase()]||0,n=this.toInt(e);return n<12&&12===r&&(n+=12),12===n&&0===r&&(n=0),n}zoneToOffset(e){if("string"==typeof e)return e=e.replace(/[^a-z\s]/gi,""),this.lookups.zone[e]}offsetToMinutes(e){if("string"!=typeof e)return;let t=e.match(/^(?:GMT)?([±−+-])(..?):?(..)?$/);if(t){let[,e,r,n]=t;return("-"===e||"−"===e?-1:1)*(60*this.toInt(r)+this.toInt(n||0))}return 0}build(){"latn"===this.dateOptions.numberingSystem?this.lookups.digit=b9:this.buildNumbers(),/^en/i.test(this.locale)||(this.buildMonthNames(),this.buildDaynames(),/zh/i.test(this.locale)||this.buildMeridiems())}buildNumbers(){let{group:e,lookup:t}=function(e){if(b8[e])return b8[e];if("fullwide"===e||"hanidec"===e)return{group:b5,lookup:{...b9}};let t=b6[e];if(!t)return{group:"\\d",lookup:{...b9}};let r=String.fromCharCode(t),n=String.fromCharCode(t+9),a={};for(let e=0;e<10;e++)a[String.fromCharCode(t+e)]=e;return b8[e]={group:`[${r}-${n}]`,lookup:a},b8[e]}(this.numberingSystem);for(let r in this.lookups.digit=t,wr)wr.hasOwnProperty(r)&&(this.vars[r]=wr[r].replace(/\*/g,e))}buildMonthNames(){let e={},t={};if(/^fi/i.test(this.locale))"tammi|helmi|maalis|huhti|touko|kes\xe4|hein\xe4|elo|syys|loka|marras|joulu".split("|").forEach((r,n)=>{["","k","kuu","kuuta"].forEach((a,o)=>{e[r+a+(o<2?"\\.?":"")]=!0,t[r+a]=n+1})});else{let r=[],n=e=>"month"===e.type;for(let e=0;e<12;e++)r.push(new Date(2017,e,1));for(let a of["full","long","medium"]){let o=Intl.DateTimeFormat(this.locale,{dateStyle:a});for(let i=0;i<12;i++){let s=o.formatToParts(r[i]).find(n).value.toLocaleLowerCase(this.locale);/^\d+$/.test(s)||(/^ko/i.test(this.locale)&&(s+="월"),"medium"===a?(s=s.replace(/\.$/,""),e[`${s}\\.?`]=!0):e[s]=!0,t[s]=i+1)}}let a=Intl.DateTimeFormat(this.locale,{month:"short"});for(let o=0;o<12;o++){let i=a.formatToParts(r[o]).find(n).value.toLocaleLowerCase(this.locale);i=i.replace(/\.$/,""),e[`${i}\\.?`]=!0,t[i]=o+1}}this.vars.MONTHNAME=Object.keys(e).join("|"),this.lookups.month=t}buildDaynames(){let e=[],t=e=>"weekday"===e.type;for(let t=0;t<7;t++)e.push(new Date(2017,0,t+1));let r=[],n={};for(let a of["long","short"]){let o=Intl.DateTimeFormat(this.locale,{weekday:a});for(let i=0;i<7;i++){let s=o.formatToParts(e[i]).find(t).value.toLocaleLowerCase(this.locale);"short"===a?(s=s.replace(/\.$/,""),r.push(`${s}\\.?`)):r.push(s),n[s]=i}}this.vars.DAYNAME=r.join("|"),this.lookups.dayname=n}buildMeridiems(){let e=[new Date(2017,0,1),new Date(2017,0,1,23,0,0)],t=e=>"dayPeriod"===e.type,r=[],n={},a=Intl.DateTimeFormat(this.locale,{timeStyle:"long"});for(let o=0;o<2;o++){let i=a.formatToParts(e[o]).find(t);if(!i)return;let s=i.value.toLocaleLowerCase(this.locale);r.push(s),n[s]=12*o}this.vars.MERIDIEM=r.join("|"),this.lookups.meridiem=n}compile(e){return RegExp(e.replace(/_([A-Z0-9]+)_/g,(e,t)=>{if(!this.vars[t])throw Error(`Template string contains invalid variable _${t}_`);return this.vars[t]}),"i")}},wo=["ee-TG","en-AS","en-CA","en-FM","en-GH","en-GU","en-KE","en-KY","en-MH","en-MP","en-US","en-VI","en-WS","jp-JP","sm-AS","sm-SM"],wi={y:"year",M:"month",d:"day",w:"week",h:"hour",m:"minute",s:"second",ms:"millisecond"},ws=()=>new Date;function wl(e){return function(t){let r={};for(let n=0,a=e.length;n<a;n++){let a=e[n];a&&(r[a]=t[n])}return r}}var wu=class{doneChecker;fallback;patterns;formatter;constructor({doneChecker:e,fallback:t,patterns:r,formatter:n}){this.doneChecker=e,this.fallback=t,this.patterns=r,this.formatter=n}attempt(e){if("string"!=typeof e)return this.fallback(e);let t=e.trim(),r={},n=!1;for(let e of this.patterns){let a=t.match(e.regex);if(!a)continue;n=!0;let o=e.handler(a);if(o){for(let[e,t]of Object.entries(o))e in r||void 0===t||(r[e]=t);if(t=(t=t.slice(0,a.index)+t.slice(a.index+a[0].length+1)).trim(),this.doneChecker(r,t))break}}return n?this.formatter(r):this.fallback(e)}},wc=["year","month","day","hour","minute","second","millisecond","offset"],wd={};function wp(e,t){return""===t||/^\s+$/.test(t)||"year"in e&&("month"in e||"monthname"in e)&&"day"in e&&"hour"in e&&"minute"in e&&"second"in e&&"millisecond"in e&&("zone"in e||"offset"in e)}var wm=[[/([^\d.]+)(\d{1,2})\.(\d{2})\.(\d{2})(\D|$)/,"$1$2:$3:$4$5"],[/([^\d.]+)(\d{1,2})\.(\d{2})(\D|$)/,"$1$2:$3$4"]],wf={ar:[[/ /g," "]],bn:[[/,/g,""]],zh:[[/早上\s*([\d:]+)/,"$1am"],[/凌晨\s*([\d:]+)/,"$1am"],[/上午\s*([\d:]+)/,"$1am"],[/下午\s*([\d:]+)/,"$1pm"],[/晚上\s*([\d:]+)/,"$1pm"]],he:[[/ב/gi,""]],de:[[/ um /g," "]],pt:[[/\sde /gi," "]],es:[[/\sde /gi," "]],da:[[/\sden /gi," "],...wm],ru:[[/ г\./g,""]],th:[[/\s*นาฬิกา\s*/i,":"],[/\s*นาที\s*/i,":"],[/\s*วินาที\s*/i," "]],ko:[[/\s*시\s*/,":"],[/\s*분\s*/,":"],[/\s*초\s*/,""],[/(오전|오후)\s*([\d:]+)/,"$2$1"],[/(\d{4})\. (\d{1,2})\. (\d{1,2})\./,"$1-$2-$3"]],fi:wm,id:wm,fr:[[/(\d{2}) h /,"$1:"],[/(\d{2}) min /,"$1:"],[/(\d{2}) s /,"$1"]]};function wh(e,t=b4){let r=function(e){if(!wd[e]){var t,r;let n,a,o=wa.factory(e);wd[e]=new wu({doneChecker:wp,fallback:(t=e,function(e){let r=String(e).slice(0,50);return""===r&&(r="(empty string)"),{invalid:`Unable to parse "${r}" with locale "${t}"`}}),patterns:(n=[{name:"timestampWithOffset",regex:o.compile("^(_YEAR4_)-(_MONTH_)-(_DAY_)[T ](_H24_):(_MIN_):(_SEC_)(?:.(_MS_))? ?(_OFFSET_|Z)?$"),handler:wl(["","year","month","day","hour","minute","second","millisecond","offset"])},{name:"timestampWithZone",regex:o.compile("^(_YEAR4_)-(_MONTH_)-(_DAY_)[T ](_H24_):(_MIN_):(_SEC_)(?:.(_MS_))?\\s*(_ZONE_)$"),handler:wl(["","year","month","day","hour","minute","second","millisecond","zone"])},{name:"timestampWithOffsetAndZone",regex:o.compile("^(_YEAR4_)-(_MONTH_)-(_DAY_)[T ](_H24_):(_MIN_):(_SEC_)(?:.(_MS_))? (_OFFSET_|Z)\\s*(_ZONE_)$"),handler:wl(["","year","month","day","hour","minute","second","millisecond","offset"])},{name:"chinese",regex:o.compile(`^(${b5}{2,4})\\s*\u5E74\\s*(${b5}{1,2})\\s*\u6708\\s*(${b5}{1,2})\\s*\u65E5$`),handler:wl(["","year","month","day"])},{name:"korean",regex:o.compile("^(_YEAR_)년\\s*(_MONTH_)월\\s*(_DAY_)일$"),handler:wl(["","year","month","day"])},{name:"twitter",regex:/^(?:sun|mon|tue|wed|thu|fri|sat) (jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec) (\d{2}) (\d{2}):(\d{2}):(\d{2}) ([+-]\d{4}) (\d{4})$/i,handler:wl(["","monthname","day","hour","minute","second","offset","year"])},{name:"today",regex:/^(now|today|tomorrow|yesterday)$/i,handler:function(e){let t=ws(),r=e[1].toLowerCase();switch(r){case"tomorrow":t.setUTCDate(t.getUTCDate()+1);break;case"yesterday":t.setUTCDate(t.getUTCDate()-1)}let n={year:t.getUTCFullYear(),month:t.getUTCMonth()+1,day:t.getUTCDate()};return"now"===r&&(n.hour=t.getUTCHours(),n.minute=t.getUTCMinutes(),n.second=t.getUTCSeconds(),n.millisecond=t.getUTCMilliseconds()),console.log("today=>",r,n),n}},{name:"ago",regex:/^(\+|-|in|) ?([\d.]+) ?(years?|months?|weeks?|days?|hours?|minutes?|seconds?|milliseconds?|ms|s|m|h|w|d|M|y)( ago)?$/i,handler:function([,e,t,r,n]){t=parseFloat(t),"week"===(r=r.length<=2?wi[r]:(r=r.replace(/s$/,"")).toLowerCase())&&(r="day",t*=7),("-"===e||n)&&(t*=-1);let a=ws();return"millisecond"===r?a.setUTCMilliseconds(a.getUTCMilliseconds()+t):"second"===r?a.setUTCSeconds(a.getUTCSeconds()+t):"minute"===r?a.setUTCMinutes(a.getUTCMinutes()+t):"hour"===r?a.setUTCHours(a.getUTCHours()+t):"day"===r?a.setUTCDate(a.getUTCDate()+t):"month"===r?a.setUTCMonth(a.getUTCMonth()+t):"year"===r&&a.setUTCFullYear(a.getUTCFullYear()+t),{year:a.getUTCFullYear(),month:a.getUTCMonth()+1,day:a.getUTCDate(),hour:a.getUTCHours(),minute:a.getUTCMinutes(),second:a.getUTCSeconds(),millisecond:a.getUTCMilliseconds()}}},{name:"atSeconds",regex:/^@(\d+)$/,handler:function(e){let t=new Date(1e3*parseInt(e[1],10));return{year:t.getUTCFullYear(),month:t.getUTCMonth()+1,day:t.getUTCDate(),hour:t.getUTCHours(),minute:t.getUTCMinutes(),second:t.getUTCSeconds()}}},{name:"microsoftJson",regex:/^\/Date\((\d+)([+-]\d{4})?\)\/$/,handler:function(e){let t=new Date(parseInt(e[1],10));return{year:t.getUTCFullYear(),month:t.getUTCMonth()+1,day:t.getUTCDate(),hour:t.getUTCHours(),minute:t.getUTCMinutes(),second:t.getUTCSeconds(),millisecond:t.getUTCMilliseconds(),offset:e[2]}}},{name:"full24",regex:o.compile("(?:^|[\\sT])(_H24_):(_MIN_):(_SEC_)(?:\\.(_MS_))?(Z)?$"),handler:wl(["","hour","minute","second","millisecond","zone"])},{name:"zone24",regex:o.compile("(_H24_):(_MIN_):(_SEC_)(?:\\.(_MS_))?[\\s\\[(]*(_ZONE_)?[\\s\\])]*$"),handler:wl(["","hour","minute","second","millisecond","zone"])},{name:"hms12",regex:o.compile("(_H12_):(_MIN_):(_SEC_)\\s*(_MERIDIEM_)"),handler:wl(["","hour","minute","second","meridiem"])},{name:"hms24",regex:o.compile("(_H24_):(_MIN_):(_SEC_)(?:\\.(_MS_))?"),handler:wl(["","hour","minute","second","millisecond"])},{name:"hm12",regex:o.compile("(_H12_):(_MIN_)\\s*(_MERIDIEM_)"),handler:wl(["","hour","minute","meridiem"])},{name:"hm24",regex:o.compile("(_H24_):(_MIN_)"),handler:wl(["","hour","minute"])},{name:"h12",regex:o.compile("(_H12_)\\s*(_MERIDIEM_)"),handler:wl(["","hour","meridiem"])},{name:"8digit",regex:/^((?:19|20)\d{2})(\d{2})(\d{2})$/,handler:wl(["","year","month","day"])},{name:"yearMonthnameDay",regex:o.compile("(_YEAR4_)[\\s.-]+(_MONTHNAME_)[\\s,.-]+(_DAY_)(_ORDINAL_)?"),handler:wl(["","year","monthname","day"])},{name:"dayMonthnameYear",regex:o.compile("(_DAY_)(_ORDINAL_)?[\\s.-]*(_MONTHNAME_)[\\s,.-]+(_YEAR_)"),handler:wl(["","day","","monthname","year"])},{name:"monthnameDayYear",regex:o.compile("(_MONTHNAME_)[\\s.-]*(_DAY_)(_ORDINAL_)?[\\s,.-]+(_YEAR_)"),handler:wl(["","monthname","day","","year"])},{name:"dayMonthname",regex:o.compile("\\b(_DAY_)(_ORDINAL_)?[\\s.-]*(_MONTHNAME_)\\b"),handler:wl(["","day","","monthname"])},{name:"monthnameDay",regex:o.compile("\\b(_MONTHNAME_)[\\s.-]*(_DAY_)(_ORDINAL_)?\\b"),handler:wl(["","monthname","day"])},{name:"hmsNoMeridiem",regex:o.compile("\\b(_H12_|_H24_):(_MIN_):(_SEC_)\\b"),handler:wl(["","hour","minute","second"])},{name:"hmNoMeridiem",regex:o.compile("\\b(_H12_|_H24_):(_MIN_)\\b"),handler:wl(["","hour","minute"])},{name:"ymd",regex:o.compile("(_YEAR4_)([.-])(_MONTH_)\\2+(_DAY_)"),handler:wl(["","year","","month","day"])},{name:"mdy",regex:o.compile("(_MONTH_)([/-])(_DAY_)\\2(_YEAR_)"),handler:wl(["","month","","day","year"])},{name:"dmy",regex:o.compile("(_DAY_)(?:_ORDINAL_)?[./\\s-]+(_MONTH_)[./\\s-]+(_YEAR_)"),handler:wl(["","day","month","year"])},{name:"yearLoose",regex:o.compile("_YEAR4_"),handler:wl(["year"])},{name:"dayMonthnameLoose",regex:o.compile("(_DAY_)[\\s.]*(_MONTHNAME_)"),handler:wl(["","day","monthname"])},{name:"monthnameDayLoose",regex:o.compile("(_MONTHNAME_)[\\s.]*(_DAY_)"),handler:wl(["","monthname","day"])},{name:"monthname",regex:o.compile("_MONTHNAME_"),handler:wl(["monthname"])},{name:"year4",regex:o.compile("_YEAR4_"),handler:wl(["year"])},{name:"md",regex:o.compile("(_MONTH_)[/-](_DAY_)"),handler:wl(["","month","day"])},{name:"dm",regex:o.compile("(_DAY_)(?:_ORDINAL_)?[./\\s-]+(_MONTH_)"),handler:wl(["","day","month"])},{name:"day",regex:o.compile("_DAY_"),handler:wl(["day"])},{name:"year2",regex:o.compile("_YEAR2_"),handler:wl(["year"])},{name:"onlyZone",regex:o.compile("_ZONE_"),handler:wl(["zone"])}],a=o.baseName.slice(0,5),wo.includes(a)?n:n.filter(e=>!["mdy","md"].includes(e.name))),formatter:(r=o,function(e){let t={};for(let[n,a]of Object.entries(e))if("monthname"===n){if(a){let e=r.monthNameToInt(a);void 0!==e&&(t.month=e)}}else if("hour"===n&&e.meridiem){let n=r.h12ToInt(a,e.meridiem);void 0!==n&&(t.hour=n)}else if("zone"===n){if(a){let e=r.zoneToOffset(a);void 0!==e&&(t.offset=e)}}else if("offset"===n){let e=r.offsetToMinutes(a);void 0!==e&&(t.offset=e)}else if("millisecond"===n){let e=r.millisecondToInt(a);"number"==typeof e&&(t.millisecond=e)}else if(wc.includes(n)){let e=r.toInt(a);"number"==typeof e&&(t[n]=e)}return t.year<100&&(t.year=b3[t.year]),t.year&&"buddhist"===r.dateOptions.calendar&&(t.year-=543),t})})}return wd[e]}(t),n=function(e,t){let r=wf[t.slice(0,2).toLowerCase()];if(!r)return e;for(let[t,n]of r)e=e.replace(t,n);return e}(e,t);return r.attempt(n)}function wg(e){e.month&&e.day&&void 0===e.year&&(e.year=new Date().getFullYear()),60===e.second&&(e.second=59);let t=new b2(e.year,e.month-1,e.day,e.hour||0,e.minute||0,e.second||0,e.millisecond||0);return"number"==typeof e.offset?new b2(t.valueOf()-60*e.offset*1e3):t}function wy(e,t=b4){let r=wh(e,t),n=r.invalid?new b2(NaN):wg(r);return n.isValid()||(n.invalid=`Unable to parse date "${e}"`),n}function wv(e,t=b4){return e instanceof Date?new b2(e.valueOf()):"number"==typeof e?new b2(e):wy(e,t)}Date.fromString=b2.fromString=wy,Date.fromAny=b2.fromAny=wv,"u">typeof window&&(window.anyDateParser={fromString:wy,fromAny:wv,fromObject:wg,attempt:wh});var wb=r(4397),ww=r(7657);let wE=function(e){return null==e};function wx(e,t){var r=function(e,t){if(!t.has(e))throw TypeError("attempted to get private field on non-instance");return t.get(e)}(e,t);return r.get?r.get.call(e):r.value}cf().extend(ch),cf().extend(ww),cf().extend(wb);let wD="YYYY-MM-DDTHH:mm:ss.SSSZZ",wS=/^(\d{4})(?:-(\d{2})(?:-(\d{2}))?)?$/;function w_(e,t){let r=wS.exec(e);if(!r)return wh(e,t);let n=Number(r[1]),a=void 0===r[2]?void 0:Number(r[2]),o=void 0===r[3]?void 0:Number(r[3]),i=new Date(0);return(i.setUTCFullYear(n,(a??1)-1,o??1),i.getUTCFullYear()!==n||i.getUTCMonth()!==(a??1)-1||i.getUTCDate()!==(o??1))?{invalid:`Invalid ISO calendar date '${e}'`}:{year:n,...void 0!==a&&{month:a},...void 0!==o&&{day:o}}}function wC(e){return null!=e&&28===e.trim().length&&"T"===(e=e.trim())[10]&&":"===e[13]&&":"===e[16]&&"."===e[19]&&("+"===e[23]||"-"===e[23])&&cf()(e,wD).isValid()}function wk(e){return cf()(e).isToday()}function wP(e){return wC(e)?cf()(e,wD).toDate():null}function wR(e,t=!1){let r=cf()(e);return t&&(r=r.utc()),r.format(wD)}function wT(e){return cf()(e).toDate()}var wO=new WeakMap;let w$=new class{register(e,t){wx(this,wO).set(e,t)}getCalendar(e){if(!e)return;if(e.calendar)return e.calendar;if(e.region){let t=`${e.language}-${e.region}`;if(wx(this,wO).has(t))return wx(this,wO).get(t)}if(e.language&&wx(this,wO).has(e.language))return wx(this,wO).get(e.language);let t=new Intl.DateTimeFormat(e.toString()).resolvedOptions().calendar;return wx(this,wO).set(`${e.language}${e.region?`-${e.region}`:""}`,t),t}constructor(){!function(e,t,r){if(t.has(e))throw TypeError("Cannot initialize the same private elements twice on an object");t.set(e,r)}(this,wO,{writable:!0,value:new Map})}};function wN(e,t){w$.register(e,t)}function wI(e){let t=e??b1();return w$.getCalendar(t instanceof Intl.Locale?t:new Intl.Locale(t))}let wA={mode:"standard",time:"for today",day:!0,month:!0,year:!0,noToday:!1};function wM(e,t={}){let r=w_(e,b1());if(r.invalid)return console.warn(`Could not parse invalid date '${e}'`),null;!wE(r.day)&&wE(r.month)&&(r=Object.assign({},tU(r,"day"),{month:r.day})),r.month&&(r.month-=1),r.day&&(r=Object.assign({},tU(r,"day"),{date:r.day}));let n=cf()().set(r).toDate();return wE(r.year)&&(t.year=!1),wE(r.month)&&(t.month=!1),wE(r.date)&&(t.day=!1),wj(n,t)}function wj(e,t){let r,n=t?.locale??b1(),a=new Intl.Locale(n),{calendar:o,mode:i,time:s,day:l,month:u,year:c,noToday:d,numberingSystem:p}={...wA,...{noToday:"am"===a.language},...t},m={calendar:o??wI(a),year:c?"numeric":void 0,month:u?"short":void 0,day:l?"2-digit":void 0,numberingSystem:p},f=cf()(e).isToday();if(f&&!d)r=(r=new Intl.RelativeTimeFormat(n,{numeric:"auto"}).format(0,"day"))[0].toLocaleUpperCase(n)+r.slice(1);else{"en"===a.language&&(n="en-GB");let t=new Intl.DateTimeFormat(n,m).formatToParts(e);("en"===a.language||"am"===a.language)&&"standard"==i&&c&&l&&(t=t.map(wL("-"))),"wide"==i&&(t=t.map(wL(" — "))),"ethiopic"===m.calendar&&(t=t.filter((e,t,r)=>"era"!==e.type&&("literal"!==e.type||!(t<r.length-1)||"era"!==r[t+1].type))),r=t.map(e=>e.value).join("")}return(!0===s||f&&"for today"===s)&&(r+=`, ${wF(e)}`),r}let wL=e=>(t,r,n)=>"literal"!==t.type||" "!==t.value||r<n.length-1&&"era"===n[r+1].type?t:{type:"literal",value:e};function wF(e){return e.toLocaleTimeString(b1(),{hour:"2-digit",minute:"2-digit"})}function wB(e,t){return wj(e,{...t,time:!0})}function wV(e,t){let r=wI("string"==typeof t?new Intl.Locale(t):t);return r?hZ(e,yt(r)):e}function wU(e,t){return new Intl.DurationFormat(b1(),t).format(e)}function wW(e,t){if(null==e)return null;if("string"==typeof e){let r=w_(e,b1());return r.invalid?(console.warn(`Could not interpret '${e}' as a date`),null):(r.day&&!r.month&&(r={...tU(r,"day"),...{month:r.day}}),r.month&&(r.month-=1),r.day&&(r={...tU(r,"day"),...{date:r.day}}),cf()(t).set(r))}return cf()(e)}let wH=["years","months","days","hours","minutes","seconds"],wz={second:"seconds",minute:"minutes",hour:"hours",day:"days",month:"months",year:"years"},wK={seconds:45,minutes:45,hours:22,days:26,months:11,years:1/0};function wG(e,t=cf()(),r){let n,a=cf()(t),o=wW(e,a);if(null==o)return null;if("string"==typeof r){let e=wz[r]??r;return{[e]:a.diff(o,e)}}let{thresholds:i,largestUnit:s,smallestUnit:l}=r??{};if(void 0!==s||void 0!==l){let e,t=l?wz[l]??l:void 0;return e="auto"===s||void 0===s?function(e,t,r){let n=wH.indexOf(r);for(let a=0;a<wH.length;a++){let o=wH[a];if(t.diff(e,o)>0)return a<=n?o:r}return r}(o,a,t??"seconds"):wz[s]??s,function(e,t,r,n){let a=wH.indexOf(r),o=wH.indexOf(n),i=wH.slice(a,o+1),s={},l=e;for(let e of i){let r=t.diff(l,e);s[e]=r,l=l.add(r,e)}return s}(o,a,e,t??e)}let u=(n=function(e){let t={...wK};if(e)for(let[r,n]of Object.entries(e))void 0!==n&&(t[wz[r]??r]=n);return t}(i),a.diff(o,"seconds")<n.seconds?"seconds":a.diff(o,"minutes")<n.minutes?"minutes":a.diff(o,"hours")<n.hours?"hours":a.diff(o,"days")<n.days?"days":a.diff(o,"months")<n.months?"months":"years");return{[u]:a.diff(o,u)}}let wZ={style:"short",localeMatcher:"lookup"};function wY(e,t=cf()(),r){let n=wG(e,t,r);return null==n?null:wU(n,"object"==typeof r&&r.formatOptions?{...wZ,...r.formatOptions}:wZ)}let wq=(0,lT.createContext)(null);function wJ(){let e=u$({externalModuleName:"@openmrs/esm-styleguide"}).preferredDateLocale,t=(0,lT.useMemo)(()=>{let t=b1();return e[t]&&(t=e[t]),t},[window.i18next.language]),r=(0,lT.useMemo)(()=>{let e=wI(t);return void 0!==e?yt(e):void 0},[t]),n=(0,lT.useMemo)(()=>new Intl.Locale(t,{calendar:r?.identifier}),[t,r]),a=(0,lT.useMemo)(()=>r?hZ(h4(h5()),r):h4(h5()),[r]);return{calendar:r,intlLocale:n,today_:a}}let wX=new hI(1793,1,1);var wQ={};function w0(){return"u">typeof window&&window.InputEvent&&"function"==typeof InputEvent.prototype.getTargetRanges}function w1(e={}){let{locale:t}=fZ();return(0,lT.useMemo)(()=>new(0,vD.K)(t,e),[t,e])}wQ={"ar-AE":{decrease:e=>`\u{62E}\u{641}\u{636} ${e.fieldLabel}`,increase:e=>`\u{632}\u{64A}\u{627}\u{62F}\u{629} ${e.fieldLabel}`,numberField:"حقل رقمي"},"bg-BG":{decrease:e=>`\u{41D}\u{430}\u{43C}\u{430}\u{43B}\u{44F}\u{432}\u{430}\u{43D}\u{435} ${e.fieldLabel}`,increase:e=>`\u{423}\u{441}\u{438}\u{43B}\u{432}\u{430}\u{43D}\u{435} ${e.fieldLabel}`,numberField:"Номер на полето"},"cs-CZ":{decrease:e=>`Sn\xed\u{17E}it ${e.fieldLabel}`,increase:e=>`Zv\xfd\u{161}it ${e.fieldLabel}`,numberField:"Č\xedseln\xe9 pole"},"da-DK":{decrease:e=>`Reducer ${e.fieldLabel}`,increase:e=>`\xd8g ${e.fieldLabel}`,numberField:"Talfelt"},"de-DE":{decrease:e=>`${e.fieldLabel} verringern`,increase:e=>`${e.fieldLabel} erh\xf6hen`,numberField:"Nummernfeld"},"el-GR":{decrease:e=>`\u{39C}\u{3B5}\u{3AF}\u{3C9}\u{3C3}\u{3B7} ${e.fieldLabel}`,increase:e=>`\u{391}\u{3CD}\u{3BE}\u{3B7}\u{3C3}\u{3B7} ${e.fieldLabel}`,numberField:"Πεδίο αριθμού"},"en-US":{decrease:e=>`Decrease ${e.fieldLabel}`,increase:e=>`Increase ${e.fieldLabel}`,numberField:"Number field"},"es-ES":{decrease:e=>`Reducir ${e.fieldLabel}`,increase:e=>`Aumentar ${e.fieldLabel}`,numberField:"Campo de n\xfamero"},"et-EE":{decrease:e=>`V\xe4henda ${e.fieldLabel}`,increase:e=>`Suurenda ${e.fieldLabel}`,numberField:"Numbri v\xe4li"},"fi-FI":{decrease:e=>`V\xe4henn\xe4 ${e.fieldLabel}`,increase:e=>`Lis\xe4\xe4 ${e.fieldLabel}`,numberField:"Numerokentt\xe4"},"fr-FR":{decrease:e=>`Diminuer ${e.fieldLabel}`,increase:e=>`Augmenter ${e.fieldLabel}`,numberField:"Champ de nombre"},"he-IL":{decrease:e=>`\u{5D4}\u{5E7}\u{5D8}\u{5DF} ${e.fieldLabel}`,increase:e=>`\u{5D4}\u{5D2}\u{5D3}\u{5DC} ${e.fieldLabel}`,numberField:"שדה מספר"},"hr-HR":{decrease:e=>`Smanji ${e.fieldLabel}`,increase:e=>`Pove\u{107}aj ${e.fieldLabel}`,numberField:"Polje broja"},"hu-HU":{decrease:e=>`${e.fieldLabel} cs\xf6kkent\xe9se`,increase:e=>`${e.fieldLabel} n\xf6vel\xe9se`,numberField:"Sz\xe1mmező"},"it-IT":{decrease:e=>`Riduci ${e.fieldLabel}`,increase:e=>`Aumenta ${e.fieldLabel}`,numberField:"Campo numero"},"ja-JP":{decrease:e=>`${e.fieldLabel}\u{3092}\u{7E2E}\u{5C0F}`,increase:e=>`${e.fieldLabel}\u{3092}\u{62E1}\u{5927}`,numberField:"数値フィールド"},"ko-KR":{decrease:e=>`${e.fieldLabel} \u{AC10}\u{C18C}`,increase:e=>`${e.fieldLabel} \u{C99D}\u{AC00}`,numberField:"번호 필드"},"lt-LT":{decrease:e=>`Suma\u{17E}inti ${e.fieldLabel}`,increase:e=>`Padidinti ${e.fieldLabel}`,numberField:"Numerio laukas"},"lv-LV":{decrease:e=>`Samazin\u{101}\u{161}ana ${e.fieldLabel}`,increase:e=>`Palielin\u{101}\u{161}ana ${e.fieldLabel}`,numberField:"Skaitļu lauks"},"nb-NO":{decrease:e=>`Reduser ${e.fieldLabel}`,increase:e=>`\xd8k ${e.fieldLabel}`,numberField:"Tallfelt"},"nl-NL":{decrease:e=>`${e.fieldLabel} verlagen`,increase:e=>`${e.fieldLabel} verhogen`,numberField:"Getalveld"},"pl-PL":{decrease:e=>`Zmniejsz ${e.fieldLabel}`,increase:e=>`Zwi\u{119}ksz ${e.fieldLabel}`,numberField:"Pole numeru"},"pt-BR":{decrease:e=>`Diminuir ${e.fieldLabel}`,increase:e=>`Aumentar ${e.fieldLabel}`,numberField:"Campo de n\xfamero"},"pt-PT":{decrease:e=>`Diminuir ${e.fieldLabel}`,increase:e=>`Aumentar ${e.fieldLabel}`,numberField:"Campo num\xe9rico"},"ro-RO":{decrease:e=>`Sc\u{103}dere ${e.fieldLabel}`,increase:e=>`Cre\u{219}tere ${e.fieldLabel}`,numberField:"C\xe2mp numeric"},"ru-RU":{decrease:e=>`\u{423}\u{43C}\u{435}\u{43D}\u{44C}\u{448}\u{435}\u{43D}\u{438}\u{435} ${e.fieldLabel}`,increase:e=>`\u{423}\u{432}\u{435}\u{43B}\u{438}\u{447}\u{435}\u{43D}\u{438}\u{435} ${e.fieldLabel}`,numberField:"Числовое поле"},"sk-SK":{decrease:e=>`Zn\xed\u{17E}i\u{165} ${e.fieldLabel}`,increase:e=>`Zv\xfd\u{161}i\u{165} ${e.fieldLabel}`,numberField:"Č\xedseln\xe9 pole"},"sl-SI":{decrease:e=>`Upadati ${e.fieldLabel}`,increase:e=>`Pove\u{10D}ajte ${e.fieldLabel}`,numberField:"Številčno polje"},"sr-SP":{decrease:e=>`Smanji ${e.fieldLabel}`,increase:e=>`Pove\u{107}aj ${e.fieldLabel}`,numberField:"Polje broja"},"sv-SE":{decrease:e=>`Minska ${e.fieldLabel}`,increase:e=>`\xd6ka ${e.fieldLabel}`,numberField:"Nummerf\xe4lt"},"tr-TR":{decrease:e=>`${e.fieldLabel} azalt`,increase:e=>`${e.fieldLabel} artt\u{131}r`,numberField:"Sayı alanı"},"uk-UA":{decrease:e=>`\u{417}\u{43C}\u{435}\u{43D}\u{448}\u{438}\u{442}\u{438} ${e.fieldLabel}`,increase:e=>`\u{417}\u{431}\u{456}\u{43B}\u{44C}\u{448}\u{438}\u{442}\u{438} ${e.fieldLabel}`,numberField:"Поле номера"},"zh-CN":{decrease:e=>`\u{964D}\u{4F4E} ${e.fieldLabel}`,increase:e=>`\u{63D0}\u{9AD8} ${e.fieldLabel}`,numberField:"数字字段"},"zh-TW":{decrease:e=>`\u{7E2E}\u{5C0F} ${e.fieldLabel}`,increase:e=>`\u{653E}\u{5927} ${e.fieldLabel}`,numberField:"數字欄位"}};var w4={};w4={"ar-AE":{Empty:"فارغ"},"bg-BG":{Empty:"Изпразни"},"cs-CZ":{Empty:"Pr\xe1zdn\xe9"},"da-DK":{Empty:"Tom"},"de-DE":{Empty:"Leer"},"el-GR":{Empty:"Άδειο"},"en-US":{Empty:"Empty"},"es-ES":{Empty:"Vac\xedo"},"et-EE":{Empty:"T\xfchjenda"},"fi-FI":{Empty:"Tyhj\xe4"},"fr-FR":{Empty:"Vide"},"he-IL":{Empty:"ריק"},"hr-HR":{Empty:"Prazno"},"hu-HU":{Empty:"\xdcres"},"it-IT":{Empty:"Vuoto"},"ja-JP":{Empty:"空"},"ko-KR":{Empty:"비어 있음"},"lt-LT":{Empty:"Tuščias"},"lv-LV":{Empty:"Tukšs"},"nb-NO":{Empty:"Tom"},"nl-NL":{Empty:"Leeg"},"pl-PL":{Empty:"Pusty"},"pt-BR":{Empty:"Vazio"},"pt-PT":{Empty:"Vazio"},"ro-RO":{Empty:"Gol"},"ru-RU":{Empty:"Не заполнено"},"sk-SK":{Empty:"Pr\xe1zdne"},"sl-SI":{Empty:"Prazen"},"sr-SP":{Empty:"Prazno"},"sv-SE":{Empty:"Tomt"},"tr-TR":{Empty:"Boş"},"uk-UA":{Empty:"Пусто"},"zh-CN":{Empty:"空"},"zh-TW":{Empty:"空白"}};let w2=()=>{};function w3(e){var t;let r=(0,lT.useRef)(void 0),{value:n,textValue:a,minValue:o,maxValue:i,isDisabled:s,isReadOnly:l,isRequired:u,onIncrement:c,onIncrementPage:d,onDecrement:p,onDecrementPage:m,onDecrementToMin:f,onIncrementToMax:h}=e,g=hi((t=w4)&&t.__esModule?t.default:t,"@react-aria/spinbutton"),y=(0,lT.useRef)(!1),v=(0,lT.useCallback)(()=>{clearTimeout(r.current),y.current=!1},[]),b=fo(()=>{v()});(0,lT.useEffect)(()=>()=>b(),[]);let w=(0,lT.useRef)(!1),E=()=>{w.current=!0},x=()=>{w.current=!1},D=""===a?g.format("Empty"):(a||`${n}`).replace("-","−");(0,lT.useEffect)(()=>{w.current&&(fY&&fY.clear("assertive"),fq(D,"assertive"))},[D]);let S=(0,lT.useCallback)(()=>{v()},[v]),_=fo(c??w2),C=fo(p??w2),k=fo(()=>{(void 0===i||isNaN(i)||void 0===n||isNaN(n)||n<i)&&(_(),P(60))}),P=fo(e=>{b(),y.current=!0,r.current=window.setTimeout(k,e)}),R=fo(()=>{(void 0===o||isNaN(o)||void 0===n||isNaN(n)||n>o)&&(C(),T(60))}),T=fo(e=>{b(),y.current=!0,r.current=window.setTimeout(R,e)}),O=e=>{e.preventDefault()},{addGlobalListener:$,removeAllGlobalListeners:N}=fi(),I=(0,lT.useRef)(!1),[A,M]=(0,lT.useState)(null);(0,lT.useEffect)(()=>{"touch"===A?P(600):A&&P(400)},[A]);let[j,L]=(0,lT.useState)(null);return(0,lT.useEffect)(()=>{"touch"===j?T(600):j&&T(400)},[j]),{spinButtonProps:{role:"spinbutton","aria-valuenow":void 0===n||isNaN(n)?void 0:n,"aria-valuetext":D,"aria-valuemin":o,"aria-valuemax":i,"aria-disabled":s||void 0,"aria-readonly":l||void 0,"aria-required":u||void 0,onKeyDown:e=>{if(!e.ctrlKey&&!e.metaKey&&!e.shiftKey&&!e.altKey&&!l&&!e.nativeEvent.isComposing)switch(e.key){case"PageUp":if(d){e.preventDefault(),d?.();break}case"ArrowUp":case"Up":c&&(e.preventDefault(),c?.());break;case"PageDown":if(m){e.preventDefault(),m?.();break}case"ArrowDown":case"Down":p&&(e.preventDefault(),p?.());break;case"Home":f&&(e.preventDefault(),f?.());break;case"End":h&&(e.preventDefault(),h?.())}},onFocus:E,onBlur:x},incrementButtonProps:{onPressStart:e=>{v(),"touch"!==e.pointerType?(c?.(),M("mouse")):($(window,"pointercancel",S,{capture:!0}),I.current=!1,M("touch")),$(window,"contextmenu",O)},onPressUp:e=>{v(),"touch"===e.pointerType&&(I.current=!0),N(),M(null)},onPressEnd:e=>{v(),"touch"===e.pointerType&&!y.current&&I.current&&c?.(),I.current=!1,M(null)},onFocus:E,onBlur:x},decrementButtonProps:{onPressStart:e=>{v(),"touch"!==e.pointerType?(p?.(),L("mouse")):($(window,"pointercancel",S,{capture:!0}),I.current=!1,L("touch"))},onPressUp:e=>{v(),"touch"===e.pointerType&&(I.current=!0),N(),L(null)},onPressEnd:e=>{v(),"touch"===e.pointerType&&!y.current&&I.current&&p?.(),I.current=!1,L(null)},onFocus:E,onBlur:x}}}let w6=null;var w5=r(2103);function w9(e,t,r){let n="+"===e?t+r:t-r;if(t%1!=0||r%1!=0){let a=t.toString().split("."),o=r.toString().split("."),i=Math.pow(10,Math.max(a[1]&&a[1].length||0,o[1]&&o[1].length||0));t=Math.round(t*i),r=Math.round(r*i),n=("+"===e?t+r:t-r)/i}return n}let w8=(0,lT.createContext)(null),w7=(0,lT.createContext)(null),Ee=(0,lT.forwardRef)(function(e,t){var r,n;[e,t]=pX(e,t,w8);let{validationBehavior:a}=pJ(vz)||{},o=null!=(n=null!=(r=e.validationBehavior)?r:a)?n:"native",{locale:i}=fZ(),s=function(e){let{minValue:t,maxValue:r,step:n,formatOptions:a,value:o,defaultValue:i=NaN,onChange:s,locale:l,isDisabled:u,isReadOnly:c,commitBehavior:d="snap"}=e;null===o&&(o=NaN);let p=(0,lT.useCallback)(e=>void 0===n||isNaN(n)?vX(e,t,r):v0(e,t,r,n),[n,t,r]);void 0===o||isNaN(o)||"snap"!==d||(o=p(o)),isNaN(i)||"snap"!==d||(i=p(i));let[m,f]=yc(o,isNaN(i)?NaN:i,s),[h]=(0,lT.useState)(m),[g,y]=(0,lT.useState)(()=>isNaN(m)?"":new(0,vD.K)(l,a).format(m)),v=(0,lT.useMemo)(()=>new(0,w5.d)(l,a),[l,a]),b=(0,lT.useMemo)(()=>v.getNumberingSystem(g),[v,g]),w=(0,lT.useMemo)(()=>new(0,vD.K)(l,{...a,numberingSystem:b}),[l,a,b]),E=(0,lT.useMemo)(()=>w.resolvedOptions(),[w]),x=(0,lT.useCallback)(e=>isNaN(e)||null===e?"":w.format(e),[w]),D=vo({...e,value:m}),S=void 0===n||isNaN(n)?1:n;"percent"===E.style&&(void 0===n||isNaN(n))&&(S=.01);let[_,C]=(0,lT.useState)(m),[k,P]=(0,lT.useState)(l),[R,T]=(0,lT.useState)(a);Object.is(m,_)&&l===k&&a===R||(y(x(m)),C(m),P(l),T(a));let O=(0,lT.useMemo)(()=>v.parse(g),[v,g]),$=(e,n=0)=>{if(isNaN(O))return v0(isNaN(n)?0:n,t,r,S);{let n=v0(O,t,r,S);return"+"===e&&n>O||"-"===e&&n<O?n:v0(w9(e,O,S),t,r,S)}},N=(0,lT.useMemo)(()=>!u&&!c&&(isNaN(O)||void 0===r||isNaN(r)||v0(O,t,r,S)>O||w9("+",O,S)<=r),[u,c,t,r,S,O]),I=(0,lT.useMemo)(()=>!u&&!c&&(isNaN(O)||void 0===t||isNaN(t)||v0(O,t,r,S)<O||w9("-",O,S)>=t),[u,c,t,r,S,O]);return{...D,validate:e=>v.isValidPartialNumber(e,t,r),increment:()=>{let e=$("+",t);e===m&&y(x(e)),f(e),D.commitValidation()},incrementToMax:()=>{null!=r&&(f(v0(r,t,r,S)),D.commitValidation())},decrement:()=>{let e=$("-",r);e===m&&y(x(e)),f(e),D.commitValidation()},decrementToMin:()=>{null!=t&&(f(t),D.commitValidation())},canIncrement:N,canDecrement:I,minValue:t,maxValue:r,numberValue:O,defaultNumberValue:isNaN(i)?h:i,setNumberValue:f,setInputValue:y,inputValue:g,commit:e=>{let t=void 0===e?g:e,r=O;if(void 0!==e&&(r=v.parse(t)),!t.length){f(NaN),y(void 0===o?"":x(m));return}if(isNaN(r))return void y(x(m));let n="snap"===d?p(r):r,a=(n=v.parse(x(n)))!==m;f(n),y(x(void 0===o?n:m)),a&&D.commitValidation()}}}({...e,locale:i,validationBehavior:o}),l=(0,lT.useRef)(null),[u,c]=pQ(!e["aria-label"]&&!e["aria-labelledby"]),{labelProps:d,groupProps:p,inputProps:m,incrementButtonProps:f,decrementButtonProps:h,descriptionProps:g,errorMessageProps:y,...v}=function(e,t,r){var n,a,o,i,s,l,u,c,d;let p,{id:m,decrementAriaLabel:f,incrementAriaLabel:h,isDisabled:g,isReadOnly:y,isRequired:v,minValue:b,maxValue:w,autoFocus:E,label:x,formatOptions:D,onBlur:S=()=>{},onFocus:_,onFocusChange:C,onKeyDown:k,onKeyUp:P,description:R,errorMessage:T,isWheelDisabled:O,...$}=e,{increment:N,incrementToMax:I,decrement:A,decrementToMin:M,numberValue:j,inputValue:L,commit:F,commitValidation:B}=t,V=hi((n=wQ)&&n.__esModule?n.default:n,"@react-aria/numberfield"),U=(0,lT.useCallback)(()=>{let e=r.current?.value??"";(0,fs.flushSync)(()=>{F()}),r.current?.value!==e&&fq(r.current?.value??"","assertive")},[F,r]),W=pH(m),{focusProps:H}=m1({onBlur(){U()}}),z=w1(D),K=(0,lT.useMemo)(()=>z.resolvedOptions(),[z]),G=w1({...D,currencySign:void 0}),Z=(0,lT.useMemo)(()=>isNaN(j)?"":G.format(j),[G,j]),{spinButtonProps:Y,incrementButtonProps:q,decrementButtonProps:J}=w3({isDisabled:g,isReadOnly:y,isRequired:v,maxValue:w,minValue:b,onIncrement:N,onIncrementToMax:I,onDecrement:A,onDecrementToMin:M,value:j,textValue:Z}),[X,Q]=(0,lT.useState)(!1),{focusWithinProps:ee}=fw({isDisabled:g,onFocusWithinChange:Q});!function(e,t){let{onScroll:r,isDisabled:n}=e,a=(0,lT.useCallback)(e=>{!e.ctrlKey&&(e.preventDefault(),e.stopPropagation(),r&&r({deltaX:e.deltaX,deltaY:e.deltaY}))},[r]);gh(t,"wheel",n?void 0:a)}({onScroll:(0,lT.useCallback)(e=>{!(Math.abs(e.deltaY)<=Math.abs(e.deltaX))&&(e.deltaY>0?N():e.deltaY<0&&A())},[A,N]),isDisabled:O||g||y||!X},r);let et=(K.maximumFractionDigits??0)>0,er=void 0===t.minValue||isNaN(t.minValue)||t.minValue<0,en="numeric";m_()?er?en="text":et&&(en="decimal"):mT()&&(er?en="numeric":et&&(en="decimal"));let ea=mt(e),eo=(0,lT.useCallback)(e=>{e.nativeEvent.isComposing||("Enter"===e.key?((0,fs.flushSync)(()=>{F()}),B()):e.continuePropagation())},[F,B]),{isInvalid:ei,validationErrors:es,validationDetails:el}=t.displayValidation,{labelProps:eu,inputProps:ec,descriptionProps:ed,errorMessageProps:ep}=function(e,t,r){let n=fo(e=>{let n=r.current;if(!n)return;let a=null;switch(e.inputType){case"historyUndo":case"historyRedo":case"insertLineBreak":return;case"deleteContent":case"deleteByCut":case"deleteByDrag":a=n.value.slice(0,n.selectionStart)+n.value.slice(n.selectionEnd);break;case"deleteContentForward":a=n.selectionEnd===n.selectionStart?n.value.slice(0,n.selectionStart)+n.value.slice(n.selectionEnd+1):n.value.slice(0,n.selectionStart)+n.value.slice(n.selectionEnd);break;case"deleteContentBackward":a=n.selectionEnd===n.selectionStart?n.value.slice(0,n.selectionStart-1)+n.value.slice(n.selectionStart):n.value.slice(0,n.selectionStart)+n.value.slice(n.selectionEnd);break;case"deleteSoftLineBackward":case"deleteHardLineBackward":a=n.value.slice(n.selectionStart);break;default:null!=e.data&&(a=n.value.slice(0,n.selectionStart)+e.data+n.value.slice(n.selectionEnd))}null!=a&&t.validate(a)||e.preventDefault()});(0,lT.useEffect)(()=>{if(!w0()||!r.current)return;let e=r.current;return e.addEventListener("beforeinput",n,!1),()=>{e.removeEventListener("beforeinput",n,!1)}},[r]);let a=w0()?null:e=>{let r=ms(e).value.slice(0,ms(e).selectionStart)+e.data+ms(e).value.slice(ms(e).selectionEnd);t.validate(r)||e.preventDefault()},{labelProps:o,inputProps:i,descriptionProps:s,errorMessageProps:l,...u}=function(e,t){let{inputElementType:r="input",isDisabled:n=!1,isRequired:a=!1,isReadOnly:o=!1,type:i="text",validationBehavior:s="aria"}=e,[l,u]=yc(e.value,e.defaultValue||"",e.onChange),{focusableProps:c}=m6(e,t),d=vo({...e,value:l}),{isInvalid:p,validationErrors:m,validationDetails:f}=d.displayValidation,{labelProps:h,fieldProps:g,descriptionProps:y,errorMessageProps:v}=y4({...e,isInvalid:p,errorMessage:e.errorMessage||m}),b=mt(e,{labelable:!0}),w={type:i,pattern:e.pattern},[E]=(0,lT.useState)(l);return y2(t,e.defaultValue??E,u),y3(e,d,t),{labelProps:h,inputProps:pG(b,"input"===r?w:void 0,{disabled:n,readOnly:o,required:a&&"native"===s,"aria-required":a&&"aria"===s||void 0,"aria-invalid":p||void 0,"aria-errormessage":e["aria-errormessage"],"aria-activedescendant":e["aria-activedescendant"],"aria-autocomplete":e["aria-autocomplete"],"aria-haspopup":e["aria-haspopup"],"aria-controls":e["aria-controls"],value:l,onChange:e=>u(ms(e).value),autoComplete:e.autoComplete,autoCapitalize:e.autoCapitalize,maxLength:e.maxLength,minLength:e.minLength,name:e.name,form:e.form,placeholder:e.placeholder,inputMode:e.inputMode,autoCorrect:e.autoCorrect,spellCheck:e.spellCheck,[parseInt(lO().version,10)>=17?"enterKeyHint":"enterkeyhint"]:e.enterKeyHint,onCopy:e.onCopy,onCut:e.onCut,onPaste:e.onPaste,onCompositionEnd:e.onCompositionEnd,onCompositionStart:e.onCompositionStart,onCompositionUpdate:e.onCompositionUpdate,onSelect:e.onSelect,onBeforeInput:e.onBeforeInput,onInput:e.onInput,...c,...g}),descriptionProps:y,errorMessageProps:v,isInvalid:p,validationErrors:m,validationDetails:f}}(e,r),c=(0,lT.useRef)(null);return{inputProps:pG(i,{onBeforeInput:a,onCompositionStart(){let{value:e,selectionStart:t,selectionEnd:n}=r.current;c.current={value:e,selectionStart:t,selectionEnd:n}},onCompositionEnd(){if(r.current&&!t.validate(r.current.value)){let{value:e,selectionStart:n,selectionEnd:a}=c.current;r.current.value=e,r.current.setSelectionRange(n,a),t.setInputValue(e)}}}),labelProps:o,descriptionProps:s,errorMessageProps:l,...u}}({...$,...ea,name:void 0,form:void 0,label:x,autoFocus:E,isDisabled:g,isReadOnly:y,isRequired:v,validate:void 0,[va]:t,value:L,defaultValue:"!",autoComplete:"off","aria-label":e["aria-label"]||void 0,"aria-labelledby":e["aria-labelledby"]||void 0,id:W,type:"text",inputMode:en,onChange:e=>{t.validate(e)&&t.setInputValue(e)},onBlur:S,onFocus:_,onFocusChange:C,onKeyDown:(0,lT.useMemo)(()=>pO(eo,k),[eo,k]),onKeyUp:P,onPaste:t=>{e.onPaste?.(t);let r=ms(t);r&&(r.selectionEnd??-1)-(r.selectionStart??0)===r.value.length&&(t.preventDefault(),F(t.clipboardData?.getData?.("text/plain")?.trim()??""))},description:R,errorMessage:T},t,r);y2(r,t.defaultNumberValue,t.setNumberValue),a=t,o=e.validationBehavior,i=e.commitBehavior,s=r,l=t.minValue,u=t.maxValue,c=e.step,d=t.numberValue,p$(()=>{let e=s.current;if("validate"!==i||a.realtimeValidation.isInvalid||!e||e.disabled||(!w6&&"u">typeof document&&((w6=document.createElement("input")).type="number"),!w6))return;w6.min=null==l||isNaN(l)?"":String(l),w6.max=null==u||isNaN(u)?"":String(u),w6.step=null==c||isNaN(c)?"":String(c),w6.value=null==d||isNaN(d)?"":String(d);let t=e.validity.valid&&w6.validity.valid,r=e.validationMessage||w6.validationMessage,n={isInvalid:!t,validationErrors:r?[r]:[],validationDetails:{badInput:e.validity.badInput,customError:e.validity.customError,patternMismatch:e.validity.patternMismatch,rangeOverflow:w6.validity.rangeOverflow,rangeUnderflow:w6.validity.rangeUnderflow,stepMismatch:w6.validity.stepMismatch,tooLong:e.validity.tooLong,tooShort:e.validity.tooShort,typeMismatch:e.validity.typeMismatch,valueMissing:e.validity.valueMissing,valid:t}};a.updateValidation(n),"native"!==o||w6.validity.valid||e.setCustomValidity(w6.validationMessage)});let em=pG(Y,H,ec,{role:null,"aria-roledescription":mk()?null:V.format("numberField"),"aria-valuemax":null,"aria-valuemin":null,"aria-valuenow":null,"aria-valuetext":null,autoCorrect:"off",spellCheck:"false"});"native"===e.validationBehavior&&(em["aria-required"]=void 0);let ef=e=>{((e=document)=>e.activeElement)()!==r.current&&("mouse"===e.pointerType?r.current?.focus():e.target.focus())},eh=e["aria-label"]||("string"==typeof e.label?e.label:"");eh||(p=null!=e.label?eu.id:e["aria-labelledby"]);let eg=pH(),ey=pH(),ev=pG(q,{"aria-label":h||V.format("increase",{fieldLabel:eh}).trim(),id:p&&!h?eg:null,"aria-labelledby":p&&!h?`${eg} ${p}`:null,"aria-controls":W,excludeFromTabOrder:!0,preventFocusOnPress:!0,allowFocusWhenDisabled:!0,isDisabled:!t.canIncrement,onPressStart:ef}),eb=pG(J,{"aria-label":f||V.format("decrease",{fieldLabel:eh}).trim(),id:p&&!f?ey:null,"aria-labelledby":p&&!f?`${ey} ${p}`:null,"aria-controls":W,excludeFromTabOrder:!0,preventFocusOnPress:!0,allowFocusWhenDisabled:!0,isDisabled:!t.canDecrement,onPressStart:ef});return{groupProps:{...ee,role:"group","aria-disabled":g,"aria-invalid":ei?"true":void 0},labelProps:eu,inputProps:em,incrementButtonProps:ev,decrementButtonProps:eb,errorMessageProps:ep,descriptionProps:ed,isInvalid:ei,validationErrors:es,validationDetails:el}}({...p0(e),label:c,validationBehavior:o},s,l),b=pq({...e,values:{state:s,isDisabled:e.isDisabled||!1,isInvalid:v.isInvalid||!1,isRequired:e.isRequired||!1},defaultClassName:"react-aria-NumberField"}),w=mt(e);return delete w.id,lO().createElement(pY,{values:[[w7,s],[yP,p],[yT,{...m,ref:l}],[vK,{...d,ref:u}],[fT,{slots:{increment:f,decrement:h}}],[fN,{slots:{description:g,errorMessage:y}}],[vU,v]]},lO().createElement("div",{...w,...b,ref:t,slot:e.slot||void 0,"data-disabled":e.isDisabled||void 0,"data-required":e.isRequired||void 0,"data-invalid":v.isInvalid||void 0}),e.name&&lO().createElement("input",{type:"hidden",name:e.name,value:isNaN(s.numberValue)?"":s.numberValue}))});function Et(e,t){return Number.parseInt(wj(e,{calendar:t.calendar,locale:t.baseName,day:!1,month:!1,noToday:!0,numberingSystem:"latn"}))}let Er=(0,lT.forwardRef)(function(e,t){let{className:r}=e,n=(0,lT.useContext)(yv),a=(0,lT.useContext)(yb),o=n??a,i=(0,lT.useContext)(wq),s=h5(),l=wj(o.visibleRange.start.toDate(s),{calendar:i.calendar,locale:i.baseName,day:!1,year:!1,noToday:!0}),u=Et(o.visibleRange.start.toDate(s),i),c=o.maxValue?Et(o.maxValue.toDate(s),i):void 0,d=o.minValue?Et(o.minValue.toDate(s),i):void 0,p=(0,lT.useCallback)(e=>{o.setFocusedDate(o.focusedDate.cycle("year",e-o.focusedDate.year))},[]);return o&&(0,lN.jsxs)("span",{ref:t,className:r,children:[(0,lN.jsx)("span",{children:l}),(0,lN.jsxs)(Ee,{formatOptions:{useGrouping:!1},maxValue:c,minValue:d,onChange:p,value:u,children:[(0,lN.jsx)(yO,{}),(0,lN.jsxs)(yR,{children:[(0,lN.jsx)(fO,{slot:"increment",children:(0,lN.jsx)(dr,{size:8})}),(0,lN.jsx)(fO,{slot:"decrement",children:(0,lN.jsx)(c7,{size:8})})]})]})]})}),En="-esm-patient-programs__datepicker-module__inputGroup___gBam-",Ea="-esm-patient-programs__datepicker-module__inputSegment___wIJDZ",Eo="-esm-patient-programs__datepicker-module__dateInputWrapper___LiY68",Ei="-esm-patient-programs__datepicker-module__invalidText___A4cv4",Es="-esm-patient-programs__datepicker-module__flatButton___HcpME",El="-esm-patient-programs__datepicker-module__flatButtonMd___eFpyF",Eu="-esm-patient-programs__datepicker-module__flatButtonSm___tsawR",Ec="-esm-patient-programs__datepicker-module__flatButtonLg___4HG5y";function Ed({children:e}){let t=(0,lT.useContext)(bK),r=(0,lT.useContext)(bG),n=t??r,a=ct(()=>n?.close());return(0,lN.jsx)(vV,{className:"-esm-patient-programs__datepicker-module__dialog___DaqYi",ref:a,children:e})}let Ep=(0,lT.forwardRef)(function({variant:e,today_:t,minDate:r,maxDate:n},a){let o="range"===e;return(0,lN.jsx)(bV,{ref:a,className:"-esm-patient-programs__datepicker-module__popover___nAPzC",placement:"bottom start",offset:1,isNonModal:!0,children:(0,lN.jsx)(Ed,{children:(0,lN.jsxs)(o?yE:yw,{...o?{minValue:r,maxValue:n,className:"cds--date-picker__calendar"}:{},children:[(0,lN.jsxs)("header",{className:"-esm-patient-programs__datepicker-module__header___rPv3L",children:[(0,lN.jsx)(fO,{className:cM()(Es,El),slot:"previous",children:(0,lN.jsx)(dc,{size:16})}),(0,lN.jsx)(Er,{className:"-esm-patient-programs__datepicker-module__monthYear___Rw4qE"}),(0,lN.jsx)(fO,{className:cM()(Es,El),slot:"next",children:(0,lN.jsx)(dd,{size:16})})]}),(0,lN.jsx)(yD,{className:"-esm-patient-programs__datepicker-module__calendarGrid___yKV-n",children:e=>(0,lN.jsx)(yk,{className:cM()("cds--date-picker__day",{"-esm-patient-programs__datepicker-module__today___KzMTn":0===t.compare(e)}),date:e},e.toString())})]})})})}),Em=(0,lT.forwardRef)(function(e,t){let r=(0,lT.useContext)(bK),[n,a]=pX({slot:e.slot},t,vP),{locale:o}=fZ(),i=vk({...n,locale:o,createCalendar:yt}),s=(0,lT.useRef)(null),{fieldProps:l,inputProps:u}=y8({...n,inputRef:s},i,a),c=(0,lT.useCallback)(()=>{i.isDisabled||r.toggle()},[]);return(0,lN.jsxs)(pY,{values:[[vR,i],[yT,{...u,ref:s}],[yP,{...l,ref:a,isInvalid:i.isInvalid}]],children:[(0,lN.jsx)(yR,{...e,id:e.id,ref:t,slot:e.slot||void 0,className:e.className,isDisabled:i.isDisabled,isInvalid:i.isInvalid,onClick:c,children:i.segments.map((t,r)=>(0,lT.cloneElement)(e.children(t),{key:r}))}),(0,lN.jsx)(yO,{})]})}),Ef=(0,lT.forwardRef)(function(e,t){let r=(0,lT.useContext)(bK),n=(0,lT.useContext)(bG);return(r??n).isInvalid?(0,lN.jsx)(pv,{ref:t,size:16,...e}):(0,lN.jsx)(c8,{ref:t,size:16,...e})});class Eh{constructor(e,t){this.locale=e,this.dictionary=t}of(e){return this.dictionary.getStringForLocale(e,this.locale)}}let Eg=new Map,Ey=(0,lT.forwardRef)(function({segment:e,...t},r){let n=(0,lT.useContext)(vR),a=pP(r),{segmentProps:o}=function(e,t,r){let n,a,o,i,s=(0,lT.useRef)(""),{locale:l,direction:u}=fZ(),c=function(){var e;let{locale:t}=fZ(),r=ho((e=yQ)&&e.__esModule?e.default:e,"@react-aria/datepicker");return(0,lT.useMemo)(()=>{try{return new Intl.DisplayNames(t,{type:"dateTimeField"})}catch{return new Eh(t,r)}},[t,r])}(),{ariaLabel:d,ariaLabelledBy:p,ariaDescribedBy:m,focusManager:f}=y6.get(t),h=e.isPlaceholder?"":e.text,g=(0,lT.useMemo)(()=>t.dateFormatter.resolvedOptions(),[t.dateFormatter]),y=f5({month:"long",timeZone:g.timeZone}),v=f5({hour:"numeric",hour12:g.hour12,timeZone:g.timeZone});if("month"!==e.type||e.isPlaceholder)"hour"!==e.type||e.isPlaceholder||(h=v.format(t.dateValue));else{let e=y.format(t.dateValue);h=e!==h?`${h} \u{2013} ${e}`:e}let{spinButtonProps:b}=w3({value:e.value??void 0,textValue:h,minValue:e.minValue,maxValue:e.maxValue,isDisabled:t.isDisabled,isReadOnly:t.isReadOnly||!e.isEditable,isRequired:t.isRequired,onIncrement:()=>{s.current="",t.increment(e.type)},onDecrement:()=>{s.current="",t.decrement(e.type)},onIncrementPage:()=>{s.current="",t.incrementPage(e.type)},onDecrementPage:()=>{s.current="",t.decrementPage(e.type)},onIncrementToMax:()=>{s.current="",t.incrementToMax(e.type)},onDecrementToMin:()=>{s.current="",t.decrementToMin(e.type)}}),w=(0,lT.useMemo)(()=>new(0,w5.d)(l,{maximumFractionDigits:0}),[l]),E=()=>{if(e.text===e.placeholder&&f.focusPrevious(),!w.isValidPartialNumber(e.text)||t.isReadOnly||e.isPlaceholder)("dayPeriod"===e.type||"era"===e.type)&&t.clearSegment(e.type);else{let r=e.text.slice(0,-1),n=w.parse(r);0===(r=0===n?"":r).length||0===n?t.clearSegment(e.type):t.setSegment(e.type,n),s.current=r}},{startsWith:x}=(n=function(e){let{locale:t}=fZ(),r=t+(e?Object.entries(e).sort((e,t)=>e[0]<t[0]?-1:1).join():"");if(Eg.has(r))return Eg.get(r);let n=new Intl.Collator(t,e);return Eg.set(r,n),n}({usage:"search",sensitivity:"base"}),a=(0,lT.useCallback)((e,t)=>0===t.length||(e=e.normalize("NFC"),t=t.normalize("NFC"),0===n.compare(e.slice(0,t.length),t)),[n]),o=(0,lT.useCallback)((e,t)=>0===t.length||(e=e.normalize("NFC"),t=t.normalize("NFC"),0===n.compare(e.slice(-t.length),t)),[n]),i=(0,lT.useCallback)((e,t)=>{if(0===t.length)return!0;e=e.normalize("NFC");let r=0,a=(t=t.normalize("NFC")).length;for(;r+a<=e.length;r++){let o=e.slice(r,r+a);if(0===n.compare(t,o))return!0}return!1},[n]),(0,lT.useMemo)(()=>({startsWith:a,endsWith:o,contains:i}),[a,o,i])),D=f5({hour:"numeric",hour12:!0}),S=(0,lT.useMemo)(()=>{let e=new Date;return e.setHours(0),D.formatToParts(e).find(e=>"dayPeriod"===e.type).value},[D]),_=(0,lT.useMemo)(()=>{let e=new Date;return e.setHours(12),D.formatToParts(e).find(e=>"dayPeriod"===e.type).value},[D]),C=f5({year:"numeric",era:"narrow",timeZone:"UTC"}),k=(0,lT.useMemo)(()=>{if("era"!==e.type)return[];let r=hZ(new hI(1,1,1),t.calendar),n=t.calendar.getEras().map(e=>{let t=r.set({year:1,month:1,day:1,era:e}).toDate("UTC");return{era:e,formatted:C.formatToParts(t).find(e=>"era"===e.type).value}}),a=function(e){e.sort();let t=e[0],r=e[e.length-1];for(let e=0;e<t.length;e++)if(t[e]!==r[e])return e;return 0}(n.map(e=>e.formatted));if(a)for(let e of n)e.formatted=e.formatted.slice(a);return n},[C,t.calendar,e.type]),P=r=>{if(t.isDisabled||t.isReadOnly)return;let n=s.current+r;switch(e.type){case"dayPeriod":if(x(S,r))t.setSegment("dayPeriod",0);else if(x(_,r))t.setSegment("dayPeriod",1);else break;f.focusNext();break;case"era":{let e=k.find(e=>x(e.formatted,r));e&&(t.setSegment("era",e.era),f.focusNext());break}case"day":case"hour":case"minute":case"second":case"month":case"year":{if(!w.isValidPartialNumber(n))return;let a=w.parse(n),o=a;if(void 0!==e.maxValue&&a>e.maxValue&&(o=w.parse(r)),isNaN(a))return;t.setSegment(e.type,o),void 0!==e.maxValue&&(Number(a+"0")>e.maxValue||n.length>=String(e.maxValue).length)?(s.current="",f.focusNext()):s.current=n}}};gh((0,lT.useRef)("u">typeof document?document:null),"selectionchange",()=>{let e=window.getSelection();e?.anchorNode&&mi(r.current,e?.anchorNode)&&e.collapse(r.current)});let R=(0,lT.useRef)("");gh(r,"beforeinput",n=>{if(r.current)switch(n.preventDefault(),n.inputType){case"deleteContentBackward":case"deleteContentForward":w.isValidPartialNumber(e.text)&&!t.isReadOnly&&E();break;case"insertCompositionText":R.current=r.current.textContent,r.current.textContent=r.current.textContent;break;default:null!=n.data&&P(n.data)}}),gh(r,"input",e=>{let{inputType:t,data:n}=e;"insertCompositionText"===t&&(r.current&&(r.current.textContent=R.current),null!=n&&(x(S,n)||x(_,n))&&P(n))}),p$(()=>{let e=r.current;return()=>{((e=document)=>e.activeElement)()===e&&(f.focusPrevious()||f.focusNext())}},[r,f]);let T=mk()||"timeZoneName"===e.type?{role:"textbox","aria-valuemax":null,"aria-valuemin":null,"aria-valuetext":null,"aria-valuenow":null}:{};e===(0,lT.useMemo)(()=>t.segments.find(e=>e.isEditable),[t.segments])||t.isInvalid||(m=void 0);let O=pH(),$=!t.isDisabled&&!t.isReadOnly&&e.isEditable,N="literal"===e.type?"":c.of(e.type),I=gc({"aria-label":`${N}${d?`, ${d}`:""}${p?", ":""}`,"aria-labelledby":p});if("literal"===e.type)return{segmentProps:{"aria-hidden":!0}};let A={caretColor:"transparent"};if("rtl"===u){A.unicodeBidi="embed";let t=g[e.type];("numeric"===t||"2-digit"===t)&&(A.direction="ltr")}return{segmentProps:pG(b,I,{id:O,...T,"aria-invalid":t.isInvalid?"true":void 0,"aria-describedby":m,"aria-readonly":t.isReadOnly||!e.isEditable?"true":void 0,"data-placeholder":e.isPlaceholder||void 0,contentEditable:$,suppressContentEditableWarning:$,spellCheck:$?"false":void 0,autoCorrect:$?"off":void 0,[parseInt(lO().version,10)>=17?"enterKeyHint":"enterkeyhint"]:$?"next":void 0,inputMode:t.isDisabled||"dayPeriod"===e.type||"era"===e.type||!$?void 0:"numeric",tabIndex:t.isDisabled?void 0:0,onKeyDown:e=>{if("a"===e.key&&(mS()?e.metaKey:e.ctrlKey)&&e.preventDefault(),!e.ctrlKey&&!e.metaKey&&!e.shiftKey&&!e.altKey)switch(e.key){case"Backspace":case"Delete":e.preventDefault(),e.stopPropagation(),E()}},onFocus:()=>{s.current="",r.current&&gw(r.current,{containingElement:gy(r.current)});let e=window.getSelection();e?.collapse(r.current)},style:A,onPointerDown(e){e.stopPropagation()},onMouseDown(e){e.stopPropagation()}})}}(e,n,a),{focusProps:i,isFocused:s,isFocusVisible:l}=fE(),{hoverProps:u,isHovered:c}=fC({...t,isDisabled:n.isDisabled||"literal"===e.type}),d=function(e){let{className:t,style:r,children:n,defaultClassName:a,defaultChildren:o,defaultStyle:i,values:s}=e;return(0,lT.useMemo)(()=>{let e,l,u;return e="function"==typeof t?t({...s,defaultClassName:a}):t,l="function"==typeof r?r({...s,defaultStyle:i||{}}):r,u="function"==typeof n?n({...s,defaultChildren:o}):null==n?o:n,{className:e??a,style:l||i?{...i,...l}:void 0,children:u??o,"data-rac":""}},[t,r,n,a,o,i,s])}({...t,values:{...e,isReadOnly:!e.isEditable,isInvalid:n.isInvalid,isDisabled:n.isDisabled,isHovered:c,isFocused:s,isFocusVisible:l},defaultChildren:e.text}),p=(0,lT.useCallback)(e=>{e.stopPropagation()},[]);return(0,lN.jsx)("span",{...pG(mt(t),o,i,u),...d,ref:a,style:o.style,"data-placeholder":e.isPlaceholder||void 0,"data-invalid":n.isInvalid||void 0,"data-readonly":!e.isEditable||void 0,"data-disabled":n.isDisabled||void 0,"data-type":e.type,"data-hovered":c||void 0,"data-focused":s||void 0,"data-focus-visible":l||void 0,onClick:p})}),Ev={short:!1,size:"md"},Eb=(0,lT.forwardRef)(function(e,t){let{className:r,defaultValue:n,isDisabled:a,invalid:o,invalidText:i,isInvalid:s,label:l,labelText:u,light:c,maxDate:d,minDate:p,onChange:m,onChangeRaw:f,short:h,size:g,value:y,...v}={...Ev,...e},{calendar:b,intlLocale:w,today_:E}=wJ(),x=(0,lT.useId)(),D=!!(u??l),S=(0,lT.useMemo)(()=>bJ(n,b),[n,b]),_=(0,lT.useMemo)(()=>bJ(y,b,!0),[y,b]),C=(0,lT.useMemo)(()=>bJ(d,b),[d,b]),k=(0,lT.useMemo)(()=>bJ(p??wX,b),[p,b]),P=(0,lT.useMemo)(()=>o||s,[o,s]),R=(0,lT.useMemo)(()=>(f&&m&&console.error("An OpenmrsDatePicker component was created with both onChange and onChangeRaw handlers defined. Only onChangeRaw will be used."),f??(e=>m?.(bX(e)))),[f,m]);return(0,lN.jsx)(bq,{locale:w.toString(),children:(0,lN.jsx)("div",{className:cM()("cds--form-item",r),children:(0,lN.jsx)(pY,{values:[[wq,w]],children:(0,lN.jsxs)(bZ,{className:cM()("cds--date-picker","cds--date-picker--single",{"cds--date-picker--short":h,"cds--date-picker--light":c}),defaultValue:S,isDisabled:a,isInvalid:P,maxValue:C,minValue:k,value:_,shouldForceLeadingZeros:"en"===w.language||void 0,...v,onChange:R,children:[(0,lN.jsxs)("div",{className:"cds--date-picker-container",children:[D&&(0,lN.jsx)(vG,{className:cM()("cds--label",{"cds--label--disabled":a}),htmlFor:x,children:u??l}),(0,lN.jsxs)(yR,{className:En,children:[(0,lN.jsx)(Em,{id:D?x:void 0,ref:t,className:cM()("cds--date-picker-input__wrapper","-esm-patient-programs__datepicker-module__inputWrapper___uKdT1",{"-esm-patient-programs__datepicker-module__inputWrapperSm___0RXJc":"sm"===g,"-esm-patient-programs__datepicker-module__inputWrapperMd___4Vff1":"md"===g||!g||0===g.length,"-esm-patient-programs__datepicker-module__inputWrapperLg___VCRm5":"lg"===g}),children:e=>"era"!==e.type?(0,lN.jsx)(Ey,{className:Ea,segment:e}):(0,lN.jsx)(lO().Fragment,{})}),(0,lN.jsx)(fO,{className:cM()(Es,{[Eu]:"sm"===g,[El]:"md"===g||!g||0===g.length,[Ec]:"lg"===g}),children:(0,lN.jsx)(Ef,{})})]}),(0,lN.jsx)(vW,{className:Ei,children:i})]}),(0,lN.jsx)(Ep,{variant:"single",today_:E})]})})})})}),Ew=(0,lT.forwardRef)(function({className:e,defaultValue:t,invalid:r,invalidText:n,isDisabled:a,isInvalid:o,label:i,labelText:s,light:l,maxDate:u,minDate:c,onChange:d,onChangeRaw:p,size:m="md",value:f,...h},g){let{calendar:y,intlLocale:v,today_:b}=wJ(),w=(0,lT.useId)(),E=!!(s??i),x=(0,lT.useMemo)(()=>{if(f)return{start:bJ(f[0],y,!1),end:bJ(f[1],y,!1)}},[f,y]),D=(0,lT.useMemo)(()=>{if(t)return{start:bJ(t[0],y,!1),end:bJ(t[1],y,!1)}},[t,y]),S=(0,lT.useMemo)(()=>bJ(c??wX,y,!0),[c,y]),_=(0,lT.useMemo)(()=>bJ(u,y,!0),[u,y]),C=(0,lT.useMemo)(()=>r||o,[r,o]),k=(0,lT.useMemo)(()=>(p&&d&&console.error("An OpenmrsDateRangePicker component was created with both onChange and onChangeRaw handlers defined. Only onChangeRaw will be used."),p??(e=>d?.([bX(e.start),bX(e.end)]))),[p,d]);return(0,lN.jsx)(bq,{locale:v.toString(),children:(0,lN.jsx)("div",{className:cM()("cds--form-item",e),children:(0,lN.jsx)(pY,{values:[[wq,v]],children:(0,lN.jsx)(bY,{id:E?w:void 0,className:cM()("cds--date-picker",{"cds--date-picker--light":l,"cds--date-picker--disabled":a}),isInvalid:C,shouldForceLeadingZeros:"en"===v.language||void 0,maxValue:_,minValue:S,value:x,defaultValue:D,ref:g,isDisabled:a,...h,onChange:k,children:(0,lN.jsxs)("div",{className:"cds--date-picker-container",children:[E&&(0,lN.jsx)(vG,{className:cM()("cds--label",{"cds--label--disabled":a}),htmlFor:w,children:s??i}),(0,lN.jsxs)(yR,{className:En,children:[(0,lN.jsxs)("div",{className:cM()("-esm-patient-programs__datepicker-module__inputsWrapper___xXRQI",{"-esm-patient-programs__datepicker-module__inputsWrapperSm___nL+b6":"sm"===m,"-esm-patient-programs__datepicker-module__inputsWrapperMd___Kgcps":"md"===m||!m||0===m.length,"-esm-patient-programs__datepicker-module__inputsWrapperLg___raaSN":"lg"===m}),children:[(0,lN.jsx)(vO,{className:cM()("cds--date-picker-input__wrapper","-esm-patient-programs__datepicker-module__startInput___cWw-5",Eo),slot:"start",children:e=>(0,lN.jsx)(Ey,{className:Ea,segment:e})}),(0,lN.jsx)("div",{className:"-esm-patient-programs__datepicker-module__separator___Ddb4g",children:(0,lN.jsx)("span",{"aria-hidden":"true","data-readonly":!0,children:"–"})}),(0,lN.jsx)(vO,{className:cM()("cds--date-picker-input__wrapper","-esm-patient-programs__datepicker-module__endInput___xdYOl",Eo),slot:"end",children:e=>(0,lN.jsx)(Ey,{className:Ea,segment:e})})]}),(0,lN.jsx)(fO,{className:cM()(Es,{[Eu]:"sm"===m,[El]:"md"===m||!m||0===m.length,[Ec]:"lg"===m}),children:(0,lN.jsx)(Ef,{})})]}),(0,lN.jsx)(vW,{className:Ei,children:n}),(0,lN.jsx)(Ep,{variant:"range",today_:b,minDate:S,maxDate:_})]})})})})})}),EE=lO().createContext(null);function Ex(e){let{children:t}=e,r=(0,lT.useContext)(EE),[n,a]=(0,lT.useState)(0),o=(0,lT.useMemo)(()=>({parent:r,modalCount:n,addModal(){a(e=>e+1),r&&r.addModal()},removeModal(){a(e=>e-1),r&&r.removeModal()}}),[r,n]);return lO().createElement(EE.Provider,{value:o},t)}function ED(e){let t,{modalProviderProps:r}={modalProviderProps:{"aria-hidden":!!(t=(0,lT.useContext)(EE))&&t.modalCount>0||void 0}};return lO().createElement("div",{"data-overlay-container":!0,...e,...r})}function ES(e){return lO().createElement(Ex,null,lO().createElement(ED,e))}function E_(e){let t=pV(),{portalContainer:r=t?null:document.body,...n}=e,{getContainer:a}=vM();if(!e.portalContainer&&a&&(r=a()),lO().useEffect(()=>{if(r?.closest("[data-overlay-container]"))throw Error("An OverlayContainer must not be inside another container. Please change the portalContainer prop.")},[r]),!r)return null;let o=lO().createElement(ES,n);return fl().createPortal(o,r)}let EC=lO().createContext(null),Ek=lO().forwardRef(function(e,t){let{children:r,...n}=e,a=pP(t),o={...n,ref:a};return lO().createElement(EC.Provider,{value:o},r)}),EP={},ER=0,ET=!1,EO=null,E$=null;function EN(e={}){let{delay:t=1500,closeDelay:r=500}=e,{isOpen:n,open:a,close:o}=bL(e),i=(0,lT.useMemo)(()=>`${++ER}`,[]),s=(0,lT.useRef)(null),l=(0,lT.useRef)(o),u=()=>{EP[i]=p},c=()=>{for(let e in EP)e!==i&&(EP[e](!0),delete EP[e])},d=()=>{s.current&&clearTimeout(s.current),s.current=null,c(),u(),ET=!0,a(),EO&&(clearTimeout(EO),EO=null),E$&&(clearTimeout(E$),E$=null)},p=e=>{e||r<=0?(s.current&&clearTimeout(s.current),s.current=null,l.current()):s.current||(s.current=setTimeout(()=>{s.current=null,l.current()},r)),EO&&(clearTimeout(EO),EO=null),ET&&(E$&&clearTimeout(E$),E$=setTimeout(()=>{delete EP[i],E$=null,ET=!1},Math.max(500,r)))};return(0,lT.useEffect)(()=>{l.current=o},[o]),(0,lT.useEffect)(()=>()=>{s.current&&clearTimeout(s.current),EP[i]&&delete EP[i]},[i]),{isOpen:n,open:e=>{e||!(t>0)||s.current?d():(c(),u(),n||ET?n||d():(EO&&clearTimeout(EO),EO=setTimeout(()=>{EO=null,ET=!0,d()},t)))},close:p}}let EI=(0,lT.createContext)(null),EA=(0,lT.createContext)(null);function EM(e){let t=EN(e),r=(0,lT.useRef)(null),{triggerProps:n,tooltipProps:a}=function(e,t,r){let{isDisabled:n,trigger:a,shouldCloseOnPress:o=!0}=e,i=pH(),s=(0,lT.useRef)(!1),l=(0,lT.useRef)(!1),u=()=>{(s.current||l.current)&&t.open(l.current)},c=e=>{s.current||l.current||t.close(e)};(0,lT.useEffect)(()=>{let e=e=>{r&&r.current&&"Escape"===e.key&&(e.stopPropagation(),t.close(!0))};if(t.isOpen)return document.addEventListener("keydown",e,!0),()=>{document.removeEventListener("keydown",e,!0)}},[r,t]);let d=()=>{o&&(l.current=!1,s.current=!1,c(!0))},{hoverProps:p}=fC({isDisabled:n,onHoverStart:()=>{"focus"!==a&&("pointer"===mI?s.current=!0:s.current=!1,u())},onHoverEnd:()=>{"focus"!==a&&(l.current=!1,s.current=!1,c())}}),{focusableProps:m}=m6({isDisabled:n,onFocus:()=>{mZ()&&(l.current=!0,u())},onBlur:()=>{l.current=!1,s.current=!1,c(!0)}},r);return{triggerProps:{"aria-describedby":t.isOpen?i:void 0,...pG(m,p,{onPointerDown:d,onKeyDown:d}),tabIndex:void 0},tooltipProps:{id:i}}}(e,t,r);return lO().createElement(pY,{values:[[EI,t],[EA,{...a,triggerRef:r}]]},lO().createElement(Ek,{...n,ref:r},e.children))}let Ej=(0,lT.forwardRef)(function({UNSTABLE_portalContainer:e,...t},r){[t,r]=pX(t,r,EA);let n=(0,lT.useContext)(EI),a=EN(t),o=null==t.isOpen&&null==t.defaultOpen&&n?n:a,i=bD(r,o.isOpen)||t.isExiting||!1;return o.isOpen||i?lO().createElement(E_,{portalContainer:e},lO().createElement(EL,{...t,tooltipRef:r,isExiting:i})):null});function EL(e){let t=(0,lT.useContext)(EI),r=(0,lT.useRef)(null),[n,a]=(0,lT.useState)(0);p$(()=>{r.current&&t.isOpen&&a(r.current.getBoundingClientRect().width)},[t.isOpen,r]);let{overlayProps:o,arrowProps:i,placement:s}=bu({placement:e.placement||"top",targetRef:e.triggerRef,overlayRef:e.tooltipRef,offset:e.offset,crossOffset:e.crossOffset,isOpen:t.isOpen,arrowSize:n,arrowBoundaryOffset:e.arrowBoundaryOffset,shouldFlip:e.shouldFlip,onClose:()=>t.close(!0)}),l=bx(e.tooltipRef,!!s)||e.isEntering||!1,u=pq({...e,defaultClassName:"react-aria-Tooltip",values:{placement:s,isEntering:l,isExiting:e.isExiting,state:t}}),{tooltipProps:c}=function(e,t){let r=mt(e,{labelable:!0}),{hoverProps:n}=fC({onHoverStart:()=>t?.open(!0),onHoverEnd:()=>t?.close()});return{tooltipProps:pG(r,n,{role:"tooltip"})}}(e=pG(e,o),t);return lO().createElement("div",{...c,ref:e.tooltipRef,...u,style:{...o.style,...u.style},"data-placement":null!=s?s:void 0,"data-entering":l||void 0,"data-exiting":e.isExiting||void 0},lO().createElement(vZ.Provider,{value:{...i,placement:s,ref:r}},u.children))}let EF=({diagnoses:e,showCertainty:t=!1})=>{let{diagnosisTags:r}=u$({externalModuleName:"@openmrs/esm-styleguide"});return(0,lN.jsx)("div",{className:"-esm-patient-programs__diagnosis-tags-module__container___1iigI",children:e.map(e=>{let n=t&&"PROVISIONAL"===e.certainty,a=1===e.rank?r?.primaryColor??"blue":r?.secondaryColor??"gray";return(0,lN.jsx)(EB,{color:a,isProvisional:n,name:e.display},e.uuid)})})};function EB({color:e,isProvisional:t,name:r}){let[n,a]=(0,lT.useState)(!1),[o,i]=(0,lT.useState)(!1),[s,l]=(0,lT.useState)(!1),u=s||o,c=(0,lT.useRef)(null);(0,lT.useLayoutEffect)(()=>{let e=c.current;if(!e)return;let t=()=>{let t=e.scrollWidth>e.clientWidth;l(t),t||a(!1)};t();let r=new ResizeObserver(t);return r.observe(e),()=>r.disconnect()},[r,t,u]);let d=cM()("cds--tag","cds--tag--md","cds--layout--size-md",`cds--tag--${e}`,"-esm-patient-programs__diagnosis-tags-module__diagnosisTag___mQ28X"),p=(0,lN.jsxs)(lN.Fragment,{children:[t&&(0,lN.jsxs)(lN.Fragment,{children:[(0,lN.jsx)("span",{"aria-hidden":"true",className:"-esm-patient-programs__diagnosis-tags-module__provisionalMark___S+J53",children:"?"}),(0,lN.jsxs)("span",{className:"cds--visually-hidden",children:[ot("provisional","Provisional")," "]})]}),(0,lN.jsx)("span",{ref:c,className:"cds--tag__label",children:r})]});return u?(0,lN.jsxs)(EM,{delay:0,closeDelay:150,isOpen:n,onOpenChange:a,children:[(0,lN.jsx)(fO,{className:d,"data-testid":"diagnosis-tag",onFocusChange:i,onPress:()=>a(!0),children:p}),(0,lN.jsx)(Ej,{className:"-esm-patient-programs__diagnosis-tags-module__tagTooltip___50O3+",placement:"bottom",offset:4,containerPadding:8,children:r})]}):(0,lN.jsx)("span",{className:d,"data-testid":"diagnosis-tag",children:p})}let EV={action:"-esm-patient-programs__empty-card-module__action___oG778",content:"-esm-patient-programs__empty-card-module__content___YUXvR",desktopHeading:"-esm-patient-programs__empty-card-module__desktopHeading___EljiH",tabletHeading:"-esm-patient-programs__empty-card-module__tabletHeading___8mc7w",tile:"-esm-patient-programs__empty-card-module__tile___3-rRO"},EU=({width:e="64",height:t="64"})=>(0,lN.jsx)("svg",{width:e,height:t,viewBox:"0 0 64 64",children:(0,lN.jsx)("use",{href:"#omrs-empty-data-illustration"})}),EW=e=>{let t="tablet"===u6(),r=e.launchForm;return(0,lN.jsx)(cV.Layer,{className:EV.layer,children:(0,lN.jsxs)(cV.Tile,{className:EV.tile,children:[(0,lN.jsx)("div",{className:t?EV.tabletHeading:EV.desktopHeading,children:(0,lN.jsx)("h4",{children:e.headerTitle})}),(0,lN.jsx)(EU,{}),(0,lN.jsx)("p",{className:EV.content,children:ot("emptyStateText","There are no {{displayText}} to display",{displayText:e.displayText})}),(0,lN.jsx)("p",{className:EV.action,children:r&&(0,lN.jsx)(cV.Button,{onClick:()=>r(),kind:"ghost",size:t?"lg":"sm",children:ot("recordNewEntry","Record {{ displayText }}",{displayText:e.displayText})})})]})})},EH=({error:e,headerTitle:t})=>{let r="tablet"===u6();return(0,lN.jsx)(cV.Layer,{children:(0,lN.jsxs)(cV.Tile,{className:"-esm-patient-programs__error-state-module__tile___mzWLn",children:[(0,lN.jsx)("div",{className:r?"-esm-patient-programs__error-state-module__tabletHeading___l7Cpn":"-esm-patient-programs__error-state-module__desktopHeading___p57fl",children:(0,lN.jsx)("h4",{children:t})}),(0,lN.jsxs)("p",{className:"-esm-patient-programs__error-state-module__errorMessage___0fU6v",children:[ot("error","Error")," ",`${e?.response?.status}: `,e?.response?.statusText]}),(0,lN.jsx)("p",{className:"-esm-patient-programs__error-state-module__errorCopy___xkVog",children:ot("errorCopy")})]})})},Ez=EH,EK=lO().forwardRef((e,t)=>{let{slotName:r,basePath:n,componentContext:a,state:o}=u8(),i=window.location??{pathname:""},s=lK(r??"");return e.isChildOfHeader&&r&&s.length>0?(0,lN.jsxs)(cV.SideNav,{"aria-label":ot("leftNavigation","Left navigation"),className:"-esm-patient-programs__left-nav-module__leftNav___czP9T",expanded:!0,isFixedNav:!0,ref:t,...e,children:[(0,lN.jsx)(lY,{name:"global-nav-menu-slot"}),r?(0,lN.jsx)(uE,{value:a,fallback:(0,lN.jsx)(lY,{name:r,state:{basePath:n,currentPath:i,...o}}),children:(0,lN.jsx)(l$.Provider,{value:a,children:(0,lN.jsx)(lY,{name:r,state:{basePath:n,currentPath:i,...o}})})}):null]}):null}),EG=({selectedLocationUuid:e,defaultLocationUuid:t,locationTag:r,locationsPerRequest:n=50,onChange:a})=>{let[o,i]=(0,lT.useState)(""),s=(0,lT.useId)(),{location:l}=function(e){let t=e?`/ws/fhir2/R4/Location?_id=${e}`:null,{data:r,error:n,isLoading:a}=uM()(t,ov,{shouldRetryOnError:e=>!!e?.response?.status&&e.response.status>=500});return(0,lT.useMemo)(()=>({location:r?.data?.entry?r.data.entry[0]:null,error:t?n:null,isLoading:!!t&&a}),[r,a,n,t])}(t),{locations:u,isLoading:c,hasMore:d,loadingNewData:p,error:m,setPage:f}=function(e,t=0,r=""){let n=uI(r),{data:a,isLoading:o,isValidating:i,setSize:s,error:l}=uJ()(function(r,a){if(a){let e=a.data?.link?.find(e=>"next"===e.relation);if(!e)return null;let t=new URL(e.url);return t.origin===window.location.origin?e.url:new URL(`${t.pathname}${t.search?`?${t.search}`:""}`,window.location.origin).toString()}let o=`${oh}/Location?`,i=new URLSearchParams;return i.append("_summary","data"),t&&i.append("_count",""+t),r&&i.append("_getpagesoffset",""+r*t),e&&i.append("_tag",e),"string"==typeof n&&""!==n&&i.append("name:contains",n),o+i.toString()},ov);return(0,lT.useMemo)(()=>({locations:a?.length?a?.flatMap(e=>e?.data?.entry??[]):[],isLoading:o,totalResults:a?.[0]?.data?.total,hasMore:!!a?.length&&a?.[a.length-1]?.data?.link?.some(e=>"next"===e.relation),loadingNewData:i,error:l||null,setPage:s}),[o,a,i,s,l])}(r,n,o),h=(0,lT.useMemo)(()=>l&&!o&&t?[l,...u.filter(({resource:e})=>e.id!==t)]:u??[],[l,u,t,o]),g=(0,lT.useCallback)(e=>{a(),i(e.trim())},[a]),y=cr((0,lT.useCallback)(()=>{!p&&d&&f(e=>e+1)},[p,d,f])),v=d?Math.max(0,Math.floor(h.length-n/2)):-1;return(0,lN.jsxs)(lN.Fragment,{children:[(0,lN.jsx)(cV.Search,{"aria-describedby":m?`${s}-error`:void 0,labelText:ot("searchForLocation"),id:s,placeholder:ot("searchForLocation"),onChange:e=>g(e.target.value),size:"lg"}),m&&(0,lN.jsx)("div",{className:"-esm-patient-programs__location-picker-module__errorNotification___NfvTe",id:`${s}-error`,children:(0,lN.jsx)(cV.InlineNotification,{kind:"error",subtitle:ot("errorLoadingLoginLocations","Unable to load login locations. Please try again or contact support if the problem persists."),title:ot("error","Error")})}),(0,lN.jsx)("div",{className:"-esm-patient-programs__location-picker-module__searchResults___agplm",children:c?(0,lN.jsx)("div",{className:"-esm-patient-programs__location-picker-module__loadingContainer___EHghS",children:Array.from({length:5}).map((e,t)=>(0,lN.jsx)(cV.RadioButtonSkeleton,{className:"-esm-patient-programs__location-picker-module__radioButtonSkeleton___up5rH",role:"progressbar"},t))}):(0,lN.jsxs)(lN.Fragment,{children:[(0,lN.jsx)("div",{className:"-esm-patient-programs__location-picker-module__locationResultsContainer___06YOS",children:h.length>0?(0,lN.jsx)(cV.RadioButtonGroup,{name:"loginLocations",onChange:e=>{a(e?.toString())},orientation:"vertical",valueSelected:e,children:h.map((e,t)=>(0,lN.jsx)(cV.RadioButton,{className:"-esm-patient-programs__location-picker-module__locationRadioButton___yKif7",id:e.resource.id,labelText:(0,lN.jsx)("span",{ref:t===v?y:null,children:e.resource.name}),name:e.resource.name,value:e.resource.id},e.resource.id))}):(0,lN.jsx)("div",{className:"-esm-patient-programs__location-picker-module__emptyState___cPWp8",children:(0,lN.jsx)("p",{className:"-esm-patient-programs__location-picker-module__locationNotFound___b14++",children:ot("noResultsToDisplay")})})}),p&&(0,lN.jsx)("div",{className:"-esm-patient-programs__location-picker-module__loadingIcon___GVlrq",children:(0,lN.jsx)(cV.InlineLoading,{description:ot("loading")})})]})})]})},EZ=V("modalState",{modalContainer:null,modalStack:[]}),EY=0;async function Eq(e,t,r={}){let n=lf(t),a=null;if(e){if(!n)throw Error(`No modal named '${t}' has been registered.`);let{load:o}=n,i=await o(),s=EY++;a=await lC({...i,name:`${t}-${s}`},{...r,domElement:e})}else P(`Failed to launch modal. Please notify your administrator. Modal name: ${t}`);return a}function EJ(e){return"TO_BE_DELETED"===e.state||"DELETED"===e.state}function EX(e,t){t?.unmount&&(t.unmountPromise?.catch(()=>{}),t.unmount().catch(t=>{console.error(`The modal '${e}' failed to unmount`,t)}))}function EQ(e){return e.find(e=>!EJ(e))}function E0(e,t){e.container&&(e.container.style.visibility=t?"unset":"hidden")}let E1=window.getComputedStyle(document.body).overflow;function E4({modalStack:e,modalContainer:t}){if(t)if(e.length){t.style.visibility||(addEventListener("keydown",E3),document.body.style.overflow="hidden",t.style.visibility="unset");let r=EQ(e);e.forEach(e=>{switch(e.state){case"NEW":{let r=function({size:e}){let t=document.createElement("div");return t.className=`cds--modal-container cds--modal-container--${e}`,t.setAttribute("role","dialog"),t.setAttribute("tabindex","-1"),t.setAttribute("aria-modal","true"),t}({size:e.props?.size??"md"});e.container=r,e.state="MOUNTING",Eq(r,e.modalName,e.props).then(n=>{EJ(e)?EX(e.modalName,n):n?(e.parcel=n,t.prepend(r),E0(e,EQ(EZ.getState().modalStack)===e),n.mountPromise.then(()=>{EJ(e)||(e.state="MOUNTED")},t=>{P(t),e.parcel=null,E2(e)})):E2(e)},t=>{P(t),E2(e)});break}case"MOUNTING":case"MOUNTED":E0(e,e===r);break;case"TO_BE_DELETED":e.state="DELETED",e.onClose(),EX(e.modalName,e.parcel),e.container?.remove(),setTimeout(()=>{let t=EZ.getState();EZ.setState({...t,modalStack:t.modalStack.filter(t=>t!==e)})},0)}})}else t.style.removeProperty("visibility"),document.body.style.overflow=E1,removeEventListener("keydown",E3)}function E2(e){if(EJ(e))return;e.state="TO_BE_DELETED";let t=EZ.getState();EZ.setState({...t,modalStack:[...t.modalStack]})}function E3(e){"Escape"===e.key&&function(){let[e]=EZ.getState().modalStack;e&&E2(e)}()}function E6(e){EZ.subscribe(E4),EZ.setState({...EZ.getState(),modalContainer:e})}function E5(e,t={},r=()=>{}){let n=()=>{let e=EZ.getState().modalStack.find(e=>e.onClose===r);e&&E2(e)};if(lf(e)){var a;let o,i;a={state:"NEW",onClose:r,modalName:e,props:{close:n,...t}},i=[a,...(o=EZ.getState()).modalStack],EZ.setState({...o,modalStack:i})}else P(`Failed to launch modal. Please notify your administrator. Modal name: "${e}"`);return n}var E9=r(3264),E8=Object.prototype.hasOwnProperty;let E7=function(e){if(null==e)return!0;if((0,eM.A)(e)&&((0,eA.A)(e)||"string"==typeof e||"function"==typeof e.splice||(0,ej.A)(e)||(0,eF.A)(e)||(0,eI.A)(e)))return!e.length;var t=(0,tc.A)(e);if("[object Map]"==t||"[object Set]"==t)return!e.size;if((0,e$.A)(e))return!(0,E9.A)(e).length;for(var r in e)if(E8.call(e,r))return!1;return!0},xe=({notification:e})=>{let{description:t,action:r,kind:n,critical:a,title:o,onAction:i}=e;return(0,lN.jsx)(cV.ActionableNotification,{actionButtonLabel:r,kind:n||"info",lowContrast:a,subtitle:t,title:o||"",inline:!0,onActionButtonClick:i})},xt=({subject:e})=>{let[t,r]=(0,lT.useState)([]);return(0,lT.useEffect)(()=>{let t=e.subscribe(e=>r(t=>[...t.filter(t=>t.description!==e.description||t.action!==e.action||t.kind!==e.kind||t.title!==e.title),e]));return()=>t.unsubscribe()},[e]),(0,lN.jsx)(lN.Fragment,{children:t.map(e=>(0,lN.jsx)(xe,{notification:e},e.id))})},xr=({notification:e})=>{let{actionButtonLabel:t,onActionButtonClick:r=()=>{},subtitle:n,kind:a,title:o,critical:i,progressActionLabel:s,id:l,...u}=e,[c,d]=(0,lT.useState)(t);return(0,lN.jsx)(cV.ActionableNotification,{kind:a||"info",actionButtonLabel:c,ariaLabel:ot("closesActionableNotification","Closes actionable notification"),onActionButtonClick:()=>{r(),s&&d(s)},statusIconDescription:ot("actionableNotification","Actionable notification"),subtitle:n,title:o,lowContrast:i,inline:!0,...u})},xn=({subject:e})=>{let[t,r]=(0,lT.useState)([]);return(0,lT.useEffect)(()=>{let t=e.subscribe(e=>r(t=>[...t.filter(t=>t.subtitle!==e.subtitle||t.actionButtonLabel!==e.actionButtonLabel||t.onActionButtonClick!==e.onActionButtonClick||t.kind!==e.kind||t.title!==e.title),e]));return()=>t.unsubscribe()},[e]),(0,lN.jsx)(lN.Fragment,{children:t.map(e=>(0,lN.jsx)(xr,{notification:e},e.id))})};class xa{subscribe(e){return this.listeners.add(e),{unsubscribe:()=>{this.listeners.delete(e)}}}next(e){for(let t of[...this.listeners])t(e)}constructor(){!function(e,t,r){t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r}(this,"listeners",new Set)}}let xo=new xa,xi=0,xs=new xa,xl=0;function xu(e){e&&(0,lq.createRoot)(e).render((0,lN.jsx)(xt,{subject:xo}))}function xc(e){var t;e&&("string"==typeof(t=e.description)?t.trim().length>0:"object"==typeof t&&(t instanceof Error||!E7(t)))?(e.description instanceof Error&&(e.description=e.description.toLocaleString()),setTimeout(()=>{xo.next({...e,id:xi++})},0)):console.error("showNotification must be called with an object having a 'description' property that is a non-empty string or object")}function xd(e){e&&(0,lq.createRoot)(e).render((0,lN.jsx)(xn,{subject:xs}))}function xp(e){var t;e&&("string"==typeof(t=e.actionButtonLabel)?t.trim().length>0:"object"==typeof t&&!E7(t))?setTimeout(()=>{xs.next({...e,id:xl++})},0):console.error("showActionableNotification must be called with an actionButtonLabel that is a non-empty string")}let xm=["NORMAL","HIGH","CRITICALLY_HIGH","OFF_SCALE_HIGH","LOW","CRITICALLY_LOW","OFF_SCALE_LOW"],xf=["critically_low","critically_high","high","low","normal","off_scale_low","off_scale_high"],xh={container:"-esm-patient-programs__numeric-observation-module__container___gS0Wg",card:"-esm-patient-programs__numeric-observation-module__card___w0fF5","abnormal-value":"-esm-patient-programs__numeric-observation-module__abnormal-value___xuX3W","critical-value":"-esm-patient-programs__numeric-observation-module__critical-value___Jynsn",cell:"-esm-patient-programs__numeric-observation-module__cell___tMhBJ","critically-high":"-esm-patient-programs__numeric-observation-module__critically-high___3L2wx","critically-low":"-esm-patient-programs__numeric-observation-module__critically-low___XP+HX",high:"-esm-patient-programs__numeric-observation-module__high___JV9do",low:"-esm-patient-programs__numeric-observation-module__low___-uDKD","label-container":"-esm-patient-programs__numeric-observation-module__label-container___vTf2y","value-container":"-esm-patient-programs__numeric-observation-module__value-container___xTUIC",label:"-esm-patient-programs__numeric-observation-module__label___-pfmb",value:"-esm-patient-programs__numeric-observation-module__value___1A4zt",units:"-esm-patient-programs__numeric-observation-module__units___SzvX+","pad-right":"-esm-patient-programs__numeric-observation-module__pad-right___ND9XL","off-scale-low":"-esm-patient-programs__numeric-observation-module__off-scale-low___gFAv9","off-scale-high":"-esm-patient-programs__numeric-observation-module__off-scale-high___aSEmX",arrow:"-esm-patient-programs__numeric-observation-module__arrow___9bvsX"},xg=({value:e,unit:t,label:r,interpretation:n,referenceRange:a,conceptUuid:o,variant:i="card",patientUuid:s})=>{let l=(0,lT.useId)(),{referenceRange:u,isLoading:c}=function(e,t){let r=null;e&&(r=t?`${of}/conceptreferencerange/?patient=${t}&concept=${e}&v=full`:`${of}/conceptreferencerange/?concept=${e}&v=full`);let{data:n,error:a,isLoading:o}=uM()(r,ov),i=n?.data?.results?.[0];return{referenceRange:i?{hiNormal:i.hiNormal??null,hiAbsolute:i.hiAbsolute??null,hiCritical:i.hiCritical??null,lowNormal:i.lowNormal??null,lowAbsolute:i.lowAbsolute??null,lowCritical:i.lowCritical??null}:void 0,error:a,isLoading:o}}(a||n?void 0:o,s),d=a??u,p=(0,lT.useMemo)(()=>{if(n)return n?"--"===n?"normal":xm.includes(n)?n.toLowerCase():xf.includes(n)?n:"normal":void 0;if(d&&!c){if(!d||null==e||""===e)return"normal";let t="string"==typeof e?Number.parseFloat(e):e;return Number.isNaN(t)?"normal":null!==d.hiAbsolute&&void 0!==d.hiAbsolute&&t>d.hiAbsolute?"off_scale_high":null!==d.hiCritical&&void 0!==d.hiCritical&&t>=d.hiCritical?"critically_high":null!==d.hiNormal&&void 0!==d.hiNormal&&t>d.hiNormal?"high":null!==d.lowAbsolute&&void 0!==d.lowAbsolute&&t<d.lowAbsolute?"off_scale_low":null!==d.lowCritical&&void 0!==d.lowCritical&&t<=d.lowCritical?"critically_low":null!==d.lowNormal&&void 0!==d.lowNormal&&t<d.lowNormal?"low":"normal"}return"normal"},[n,d,e,c])??"normal",m="critically_low"===p||"critically_high"===p||"off_scale_low"===p||"off_scale_high"===p,f="normal"!==p,h=r?`omrs-numeric-obs-label-${r.replaceAll(/\s+/g,"-").toLowerCase()}-${l}`:void 0,g=`omrs-numeric-obs-value-${l}`,y=`omrs-numeric-obs-unit-${l}`,v=null!=e&&""!==e,b=v?e:ot("notAvailable","Not available"),w=cM()({[xh["critically-low"]]:"critically_low"===p||"off_scale_low"===p,[xh["critically-high"]]:"critically_high"===p||"off_scale_high"===p,[xh.low]:"low"===p,[xh.high]:"high"===p,[xh["off-scale-low"]]:"off_scale_low"===p,[xh["off-scale-high"]]:"off_scale_high"===p}),E=cM()({[xh.container]:!0,[xh.card]:!0,[xh["critical-value"]]:m,[xh["abnormal-value"]]:f&&!m}),x=cM()({[xh.cell]:!0,[w]:!0});return"cell"===i?(0,lN.jsxs)("div",{className:x,children:[b,v&&t?` ${t}`:""]}):(0,lN.jsxs)("section",{className:E,"data-testid":"numeric-observation-card",children:[r&&(0,lN.jsxs)("div",{className:xh["label-container"],children:[(0,lN.jsx)("span",{id:h,className:xh.label,children:r}),f&&(0,lN.jsx)("span",{className:xh[p.replace("_","-")],title:ot("abnormalValue","Abnormal value")})]}),(0,lN.jsxs)("div",{className:xh["value-container"],children:[(0,lN.jsx)("span",{id:g,"aria-labelledby":h&&y?`${h} ${y}`:h||y||void 0,className:xh.value,children:b}),v&&t&&(0,lN.jsx)("span",{id:y,className:xh.units,children:t})]})]})},xy="-esm-patient-programs__page-header-module__pageHeader___6TOjO",xv=e=>{if("children"in e){let{children:t,className:r,...n}=e;return(0,lN.jsx)("div",{className:cM()(xy,r),...n,children:t})}{let{title:t,illustration:r,className:n,...a}=e;return(0,lN.jsx)("div",{className:cM()(xy,n),...a,children:(0,lN.jsx)(xb,{title:t,illustration:r})})}},xb=({title:e,illustration:t,className:r})=>{let[n,a]=(0,lT.useState)(null);return(0,lT.useEffect)(()=>{rS("@openmrs/esm-styleguide").then(e=>{a(e)})},[]),(0,lN.jsxs)("div",{className:cM()("-esm-patient-programs__page-header-module__pageHeaderContent___mCImT",r),children:[t,(0,lN.jsxs)("div",{className:"-esm-patient-programs__page-header-module__pageLabels___kqDS+",children:[n?.implementationName&&(0,lN.jsx)("p",{children:ot(n.implementationName)}),(0,lN.jsx)("h1",{className:"-esm-patient-programs__page-header-module__pageName___SbZBC",children:e})]})]})},xw=({totalItems:e,pageSize:t,onPageNumberChange:r,pageNumber:n,dashboardLinkUrl:a,currentItems:o,dashboardLinkLabel:i})=>{let{pageSizes:s,pageItemsCount:l}=co(t,e,n,o),u="tablet"===u6(),c=ot("paginationItemsCount","{{pageItemsCount}} / {{totalItems}} items",{totalItems:e,pageItemsCount:l});return(0,lN.jsx)(lN.Fragment,{children:e>0&&(0,lN.jsxs)("div",{className:cM()({"-esm-patient-programs__pagination-module__tablet___82gj1":u,"-esm-patient-programs__pagination-module__desktop___6yI8e":!u}),children:[(0,lN.jsxs)("div",{children:[c,a&&(0,lN.jsx)(lI,{to:a,className:"-esm-patient-programs__pagination-module__configurableLink___oIqma",children:i??ot("seeAll","See all")})]}),(0,lN.jsx)(cV.Pagination,{className:"-esm-patient-programs__pagination-module__pagination___A-Lcg",page:n,pageSize:t,pageSizes:s,totalItems:e,onChange:r,pageRangeText:(e,t)=>ot("paginationOfPages","of {{count}} pages",{count:t}),size:u?"lg":"sm"})]})})};function xE(e){return xD(x_(e,"usual","official"))}function xx(e){return xE(e)}function xD(e){var t;let r;return e?e.text??(r=(t=e).given??[],(t.family?r.concat(t.family):r).join(" ")):""}function xS(e){return xD(e)}function x_(e,...t){for(let r of(0==t.length&&(t=["usual"]),t)){let t=e.name?.find(e=>{var t,n;return t=e,n=r,t.use?t.use===n:"usual"===n});if(t)return t}}function xC(e,t=cf()()){let r=cf()(t),n=wW(e,r);if(null==n)return null;let a=r.diff(n,"hours"),o=r.diff(n,"days"),i=r.diff(n,"weeks"),s=r.diff(n,"months"),l=r.diff(n,"years"),u={};if(a<2)u.minutes=r.diff(n,"minutes");else if(o<2)u.hours=a;else if(i<4)u.days=o;else if(l<1){let e=r.subtract(i,"weeks").diff(n,"days");u.weeks=i,u.days=e}else if(l<2){let e=r.subtract(s,"months").diff(n,"days");u.months=s,u.days=e}else if(l<18){let e=r.subtract(l,"year").diff(n,"months");u.years=l,u.months=e}else u.years=l;return u}function xk(e,t=cf()()){let r=xC(e,t);if(null==r)return null;let n={style:"short",localeMatcher:"lookup"};return"minutes"in r&&0===r.minutes&&(n.minutesDisplay="always"),wU(r,n)}let xP={container:"-esm-patient-programs__patient-banner-patient-info-module__container___iC32K",activePatientContainer:"-esm-patient-programs__patient-banner-patient-info-module__activePatientContainer___OoDPd",patientBanner:"-esm-patient-programs__patient-banner-patient-info-module__patientBanner___swajU",patientName:"-esm-patient-programs__patient-banner-patient-info-module__patientName___+2+Xi",patientAvatar:"-esm-patient-programs__patient-banner-patient-info-module__patientAvatar___Rdf75",patientAvatarButton:"-esm-patient-programs__patient-banner-patient-info-module__patientAvatarButton___A1q8c",patientInfo:"-esm-patient-programs__patient-banner-patient-info-module__patientInfo___L-cOQ",demographics:"-esm-patient-programs__patient-banner-patient-info-module__demographics___IDhb0",row:"-esm-patient-programs__patient-banner-patient-info-module__row___TP7gU",flexRow:"-esm-patient-programs__patient-banner-patient-info-module__flexRow___vNMt2",tagsSlot:"-esm-patient-programs__patient-banner-patient-info-module__tagsSlot___0Dvjn",identifiers:"-esm-patient-programs__patient-banner-patient-info-module__identifiers___d3GTJ",identifier:"-esm-patient-programs__patient-banner-patient-info-module__identifier___kc6eq",primaryIdentifier:"-esm-patient-programs__patient-banner-patient-info-module__primaryIdentifier___ZxRUU",secondaryIdentifier:"-esm-patient-programs__patient-banner-patient-info-module__secondaryIdentifier___eQh8x",value:"-esm-patient-programs__patient-banner-patient-info-module__value___CoAOR",tag:"-esm-patient-programs__patient-banner-patient-info-module__tag___InccN",gender:"-esm-patient-programs__patient-banner-patient-info-module__gender___vfinx",separator:"-esm-patient-programs__patient-banner-patient-info-module__separator___3OIBl",tooltipPadding:"-esm-patient-programs__patient-banner-patient-info-module__tooltipPadding___hBqWG",tooltipSmallText:"-esm-patient-programs__patient-banner-patient-info-module__tooltipSmallText___bPnkq",actionsButtonText:"-esm-patient-programs__patient-banner-patient-info-module__actionsButtonText___VNvm7"};function xR({showIdentifierLabel:e,type:t,value:r}){return(0,lN.jsx)("span",{className:xP.primaryIdentifier,children:(0,lN.jsxs)(cV.Tag,{className:xP.tag,type:"gray",children:[e&&t?.text&&(0,lN.jsxs)("span",{className:xP.label,children:[t.text,": "]}),(0,lN.jsx)("span",{className:xP.value,children:r})]})})}function xT({showIdentifierLabel:e,type:t,value:r}){return(0,lN.jsxs)(cV.FormLabel,{className:xP.secondaryIdentifier,id:`patient-banner-identifier-${r}`,children:[e&&(0,lN.jsxs)("span",{className:xP.label,children:[t?.text,": "]}),(0,lN.jsx)("span",{className:xP.value,children:r})]})}function xO({identifiers:e,showIdentifierLabel:t}){let{excludePatientIdentifierCodeTypes:r}=u$(),{primaryIdentifierCode:n}=cl(),a=e?.filter(e=>{let t=e.type?.coding?.[0]?.code;return t&&!r?.uuids.includes(t)})??[];return(0,lN.jsx)(lN.Fragment,{children:a?.length?a.map(({value:e,type:r},o)=>(0,lN.jsxs)(lO().Fragment,{children:[(0,lN.jsx)("span",{className:xP.identifier,children:r?.coding?.[0]?.code===n?(0,lN.jsx)(xR,{showIdentifierLabel:t,type:r,value:e}):(0,lN.jsx)(xT,{showIdentifierLabel:t,type:r,value:e})}),o<a.length-1&&(0,lN.jsx)("span",{className:xP.separator,children:"\xb7"})]},e)):""})}let x$={Female:dD,Male:dS,Other:d_,Unknown:dC},xN=({gender:e})=>{let t=x$[e];return t?(0,lN.jsx)(t,{fill:"#525252"}):null},xI={male:"Male",female:"Female",other:"Other",unknown:"Unknown"};function xA({patient:e,renderedFrom:t}){var r;let n,a,o=xE(e),i=e?.gender&&(a=xI[n=(r=e.gender).toLowerCase()]??"Unknown",{displayText:ot(n,r),iconKey:a}),s=(0,lT.useMemo)(()=>({patientUuid:e.id,patient:e,renderedFrom:t}),[e.id,e,t]);return(0,lN.jsxs)("div",{className:xP.patientInfo,children:[(0,lN.jsx)("div",{className:cM()(xP.row,xP.patientNameRow),children:(0,lN.jsxs)("div",{className:xP.flexRow,children:[(0,lN.jsx)("span",{className:xP.patientName,children:o}),i&&(0,lN.jsxs)("div",{className:xP.gender,children:[(0,lN.jsx)(xN,{gender:i.iconKey}),(0,lN.jsx)("span",{children:i.displayText})]}),(0,lN.jsx)(lY,{className:xP.tagsSlot,name:"patient-banner-tags-slot",state:s})]})}),(0,lN.jsxs)("div",{className:xP.demographics,children:[e.birthDate&&(0,lN.jsxs)(lN.Fragment,{children:[(0,lN.jsx)("span",{children:xk(e.birthDate)}),(0,lN.jsx)("span",{className:xP.separator,children:"\xb7"}),(0,lN.jsx)("span",{children:wM(e.birthDate,{time:!1,noToday:!0})}),(0,lN.jsx)("span",{className:xP.separator,children:"\xb7"})]}),(0,lN.jsx)(xO,{identifiers:e.identifier,showIdentifierLabel:!0}),(0,lN.jsx)(lY,{className:xP.extensionSlot,name:"patient-banner-bottom-slot",state:s})]})]})}var xM=r(8282);function xj({patient:e,patientUuid:t,actionsSlotName:r,additionalActionsSlotState:n}){let[a,o]=(0,lT.useState)(!1),{extensions:i}=lG(r),s="tablet"===u6(),l=ct(()=>o(!1),a),u=(0,lT.useRef)(null),c=(0,lT.useRef)(null),d=(0,lT.useId)(),p=`patient-actions-menu-trigger-${d}`,m=`patient-actions-menu-${d}`,f=(0,lT.useCallback)(()=>o(e=>!e),[]),h=(0,lT.useCallback)(()=>{o(!1),u.current?.focus()},[]),g=(0,lT.useCallback)(e=>{if("Escape"===e.key&&a){e.stopPropagation(),h();return}if(("ArrowDown"===e.key||"ArrowUp"===e.key)&&a){e.preventDefault();let t=c.current?.querySelectorAll('[role="menuitem"]:not([disabled])');if(!t?.length)return;let r=document.activeElement?.closest?.('[role="menuitem"]')??document.activeElement,n=Array.from(t).indexOf(r);if(-1===n)return void t["ArrowDown"===e.key?0:t.length-1]?.focus();let a=n+("ArrowDown"===e.key?1:-1),o=a<0?t.length-1:a>=t.length?0:a;t[o]?.focus()}},[h,a]);(0,lT.useEffect)(()=>{if(a&&c.current){let e=c.current.querySelector('[role="menuitem"]:not([disabled])');e?.focus()}},[a]);let y=(0,lT.useMemo)(()=>({patientUuid:t,patient:e,closeMenu:h,...n}),[t,e,h,n]);return 0===i.length?null:(0,lN.jsx)("div",{className:"-esm-patient-programs__patient-banner-actions-menu-module__overflowMenuContainer___FbFcO",children:(0,lN.jsxs)("div",{"data-overflow-menu":!0,className:cM()("cds--overflow-menu",cH),ref:l,children:[(0,lN.jsxs)("button",{className:cM()("cds--btn","cds--btn--ghost","cds--overflow-menu__trigger",{"cds--overflow-menu--open":a},cG),"aria-controls":m,"aria-expanded":a,"aria-haspopup":"true",id:p,onClick:f,onKeyDown:g,ref:u,children:[(0,lN.jsx)("span",{className:"-esm-patient-programs__patient-banner-actions-menu-module__actionsButtonText___hk4xW",children:ot("actions","Actions")})," ",(0,lN.jsx)(xM.CH,{size:16,style:{marginLeft:"0.5rem",fill:"#78A9FF"}})]}),(0,lN.jsxs)("div",{className:cM()("cds--overflow-menu-options","cds--overflow-menu--flip",cz,{[cK]:a}),"aria-labelledby":p,"data-floating-menu-direction":"bottom",id:m,onKeyDown:g,ref:c,role:"menu",tabIndex:-1,children:[(0,lN.jsx)("ul",{className:cM()("cds--overflow-menu-options__content",{"cds--overflow-menu-options--lg":s}),children:(0,lN.jsx)(lY,{name:r,state:y},r)}),(0,lN.jsx)("span",{})]})]})})}var xL=r(5570),xF=r.n(xL);function xB(e){let{patientPhotoConceptUuid:t}=u$({externalModuleName:"@openmrs/esm-styleguide"}),r=t?`${of}/obs?patient=${e}&concept=${t}&v=full`:null,{data:n,error:a,isLoading:o}=un()(e?r:null,ov),i=n?.data?.results[0];return{data:i?{dateTime:i?.obsDatetime,imageSrc:i?.value?.links?.uri}:null,error:a,isLoading:o}}let xV=({width:e=56,height:t=56,"aria-label":r})=>{let{t:n}=(0,ut.useTranslation)();return(0,lN.jsxs)("svg",{"aria-label":r??n("patientPhotoPlaceholder","Patient photo placeholder"),width:e,height:t,fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,lN.jsx)("path",{fill:"#ffffff",d:"M0 0h56v56H0z"}),(0,lN.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m36.75 20.134-.884-.884L19.25 35.866l.884.884 1.25-1.25H34.25a1.252 1.252 0 0 0 1.25-1.25V21.384l1.25-1.25Zm-2.5 14.116H22.634l4.87-4.87 1.487 1.486a1.25 1.25 0 0 0 1.768 0l.991-.991 2.5 2.498v1.877Zm0-3.645-1.616-1.616a1.25 1.25 0 0 0-1.768 0l-.991.991-1.486-1.486 5.861-5.86v7.971Zm-12.5 1.145v-1.875l3.125-3.123.858.859.885-.885-.86-.86a1.25 1.25 0 0 0-1.767 0l-2.241 2.242V21.75h10V20.5h-10c-.69 0-1.25.56-1.25 1.25v10h1.25Z",fill:"#8D8D8D"})]})},xU="-esm-patient-programs__patient-photo-module__avatar___thboZ";function xW({patientUuid:e,patientName:t,alt:r}){let{data:n,isLoading:a}=xB(e),[o,i]=(0,lT.useState)(null),[s,l]=(0,lT.useState)(!1),u=(0,lT.useMemo)(()=>xF().generate(e),[e]);(0,lT.useEffect)(()=>{if(n?.imageSrc){let e=new URL(n.imageSrc,window.location.origin).pathname;l(!0);let t=!1,r=new Image;return r.onload=()=>{t||(i(e),l(!1))},r.onerror=()=>{t||(i(null),l(!1))},r.src=e,()=>{t=!0}}i(null),l(!1)},[n?.imageSrc]);let c=(0,lT.useMemo)(()=>r||(o?ot("patientPhotoAlt","Profile photo of {{patientName}}",{patientName:t}):ot("patientAvatarAlt","Avatar for {{patientName}}",{patientName:t})),[r,o,t]);return a||s?(0,lN.jsx)(cV.SkeletonIcon,{className:"-esm-patient-programs__patient-photo-module__skeleton___WWtyX","data-testid":"skeleton-icon"}):n?.imageSrc&&!o?(0,lN.jsx)(xV,{"aria-label":ot("patientPhotoPlaceholder","Photo placeholder for {{patientName}}",{patientName:t})}):o?(0,lN.jsx)("div",{"aria-label":c,children:(0,lN.jsx)("img",{className:xU,src:o,alt:c,title:t})}):(0,lN.jsx)("div",{"aria-label":c,children:(0,lN.jsx)("div",{className:xU,title:t,style:{backgroundImage:u.toDataUrl(),backgroundRepeat:"no-repeat",backgroundSize:"cover"},children:(0,lN.jsx)("span",{className:"-esm-patient-programs__patient-photo-module__initials___xLeEF",children:function(e,t=3){return e.split(/\s+/).filter(Boolean).slice(0,t).map(e=>e[0]).join("")}(t)})})})}let xH=["omrs-pict-appointments","omrs-pict-assessment-1","omrs-pict-assessment-2","omrs-pict-blood-bank","omrs-pict-cardiology","omrs-pict-cohorts","omrs-pict-concept-dictionary","omrs-pict-ct-scan","omrs-pict-data-entry","omrs-pict-dentistry","omrs-pict-digital-trust","omrs-pict-emergency-department","omrs-pict-facility","omrs-pict-geriatrics","omrs-pict-gynaecology","omrs-pict-in-patient","omrs-pict-laboratory","omrs-pict-labs-2","omrs-pict-metadata-export","omrs-pict-obstetrics","omrs-pict-patient-documents","omrs-pict-patient-search","omrs-pict-patients","omrs-pict-payments-desk","omrs-pict-pharmacy","omrs-pict-pharmacy-2","omrs-pict-registration","omrs-pict-reports","omrs-pict-service-queues","omrs-pict-stock-management","omrs-pict-system-administration","omrs-pict-transfer","omrs-pict-triage","omrs-pict-x-ray"],xz=(0,lT.memo)((0,lT.forwardRef)(function(e,t){return(0,lN.jsx)(Db,{ref:t,pictogram:"omrs-pict-appointments",pictogramProps:e})})),xK=xz,xG=(0,lT.memo)((0,lT.forwardRef)(function(e,t){return(0,lN.jsx)(Db,{ref:t,pictogram:"omrs-pict-assessment-1",pictogramProps:e})})),xZ=(0,lT.memo)((0,lT.forwardRef)(function(e,t){return(0,lN.jsx)(Db,{ref:t,pictogram:"omrs-pict-assessment-2",pictogramProps:e})})),xY=(0,lT.memo)((0,lT.forwardRef)(function(e,t){return(0,lN.jsx)(Db,{ref:t,pictogram:"omrs-pict-blood-bank",pictogramProps:e})})),xq=(0,lT.memo)((0,lT.forwardRef)(function(e,t){return(0,lN.jsx)(Db,{ref:t,pictogram:"omrs-pict-cardiology",pictogramProps:e})})),xJ=(0,lT.memo)((0,lT.forwardRef)(function(e,t){return(0,lN.jsx)(Db,{ref:t,pictogram:"omrs-pict-cohorts",pictogramProps:e})})),xX=(0,lT.memo)((0,lT.forwardRef)(function(e,t){return(0,lN.jsx)(Db,{ref:t,pictogram:"omrs-pict-concept-dictionary",pictogramProps:e})})),xQ=(0,lT.memo)((0,lT.forwardRef)(function(e,t){return(0,lN.jsx)(Db,{ref:t,pictogram:"omrs-pict-ct-scan",pictogramProps:e})})),x0=(0,lT.memo)((0,lT.forwardRef)(function(e,t){return(0,lN.jsx)(Db,{ref:t,pictogram:"omrs-pict-data-entry",pictogramProps:e})})),x1=(0,lT.memo)((0,lT.forwardRef)(function(e,t){return(0,lN.jsx)(Db,{ref:t,pictogram:"omrs-pict-dentistry",pictogramProps:e})})),x4=(0,lT.memo)((0,lT.forwardRef)(function(e,t){return(0,lN.jsx)(Db,{ref:t,pictogram:"omrs-pict-digital-trust",pictogramProps:e})})),x2=(0,lT.memo)((0,lT.forwardRef)(function(e,t){return(0,lN.jsx)(Db,{ref:t,pictogram:"omrs-pict-emergency-department",pictogramProps:e})})),x3=(0,lT.memo)((0,lT.forwardRef)(function(e,t){return(0,lN.jsx)(Db,{ref:t,pictogram:"omrs-pict-facility",pictogramProps:e})})),x6=(0,lT.memo)((0,lT.forwardRef)(function(e,t){return(0,lN.jsx)(Db,{ref:t,pictogram:"omrs-pict-geriatrics",pictogramProps:e})})),x5=(0,lT.memo)((0,lT.forwardRef)(function(e,t){return(0,lN.jsx)(Db,{ref:t,pictogram:"omrs-pict-gynaecology",pictogramProps:e})})),x9=(0,lT.memo)((0,lT.forwardRef)(function(e,t){return(0,lN.jsx)(Db,{ref:t,pictogram:"omrs-pict-in-patient",pictogramProps:e})})),x8=(0,lT.memo)((0,lT.forwardRef)(function(e,t){return(0,lN.jsx)(Db,{ref:t,pictogram:"omrs-pict-laboratory",pictogramProps:e})})),x7=(0,lT.memo)((0,lT.forwardRef)(function(e,t){return(0,lN.jsx)(Db,{ref:t,pictogram:"omrs-pict-labs-2",pictogramProps:e})})),De=(0,lT.memo)((0,lT.forwardRef)(function(e,t){return(0,lN.jsx)(Db,{ref:t,pictogram:"omrs-pict-metadata-export",pictogramProps:e})})),Dt=(0,lT.memo)((0,lT.forwardRef)(function(e,t){return(0,lN.jsx)(Db,{ref:t,pictogram:"omrs-pict-obstetrics",pictogramProps:e})})),Dr=(0,lT.memo)((0,lT.forwardRef)(function(e,t){return(0,lN.jsx)(Db,{ref:t,pictogram:"omrs-pict-patient-documents",pictogramProps:e})})),Dn=(0,lT.memo)((0,lT.forwardRef)(function(e,t){return(0,lN.jsx)(Db,{ref:t,pictogram:"omrs-pict-patient-search",pictogramProps:e})})),Da=(0,lT.memo)((0,lT.forwardRef)(function(e,t){return(0,lN.jsx)(Db,{ref:t,pictogram:"omrs-pict-patients",pictogramProps:e})})),Do=(0,lT.memo)((0,lT.forwardRef)(function(e,t){return(0,lN.jsx)(Db,{ref:t,pictogram:"omrs-pict-payments-desk",pictogramProps:e})})),Di=(0,lT.memo)((0,lT.forwardRef)(function(e,t){return(0,lN.jsx)(Db,{ref:t,pictogram:"omrs-pict-pharmacy",pictogramProps:e})})),Ds=(0,lT.memo)((0,lT.forwardRef)(function(e,t){return(0,lN.jsx)(Db,{ref:t,pictogram:"omrs-pict-pharmacy-2",pictogramProps:e})})),Dl=(0,lT.memo)((0,lT.forwardRef)(function(e,t){return(0,lN.jsx)(Db,{ref:t,pictogram:"omrs-pict-registration",pictogramProps:e})})),Du=(0,lT.memo)((0,lT.forwardRef)(function(e,t){return(0,lN.jsx)(Db,{ref:t,pictogram:"omrs-pict-reports",pictogramProps:e})})),Dc=(0,lT.memo)((0,lT.forwardRef)(function(e,t){return(0,lN.jsx)(Db,{ref:t,pictogram:"omrs-pict-service-queues",pictogramProps:e})})),Dd=(0,lT.memo)((0,lT.forwardRef)(function(e,t){return(0,lN.jsx)(Db,{ref:t,pictogram:"omrs-pict-stock-management",pictogramProps:e})})),Dp=(0,lT.memo)((0,lT.forwardRef)(function(e,t){return(0,lN.jsx)(Db,{ref:t,pictogram:"omrs-pict-system-administration",pictogramProps:e})})),Dm=(0,lT.memo)((0,lT.forwardRef)(function(e,t){return(0,lN.jsx)(Db,{ref:t,pictogram:"omrs-pict-transfer",pictogramProps:e})})),Df=(0,lT.memo)((0,lT.forwardRef)(function(e,t){return(0,lN.jsx)(Db,{ref:t,pictogram:"omrs-pict-triage",pictogramProps:e})})),Dh=(0,lT.memo)((0,lT.forwardRef)(function(e,t){return(0,lN.jsx)(Db,{ref:t,pictogram:"omrs-pict-x-ray",pictogramProps:e})})),Dg=x3,Dy=Da,Dv=(0,lT.memo)((0,lT.forwardRef)(function({pictogram:e,fallback:t,...r},n){let a=(0,lT.useRef)(document.getElementById(e));return(0,lT.useEffect)(()=>{let t=document.getElementById("omrs-svgs-container"),r=new MutationObserver(t=>{for(let r of t)"childList"===r.type&&(a.current=document.getElementById(e))});return t&&r.observe(t,{childList:!0}),()=>r.disconnect()},[e]),(0,lN.jsx)(uE,{value:a.current,fallback:t,children:(0,lN.jsx)(Db,{ref:n,pictogram:e,pictogramProps:r})})})),Db=(0,lT.memo)((0,lT.forwardRef)(function({pictogram:e,pictogramProps:t},r){let{className:n,size:a}=Object.assign({},{size:92},t);return(a<=26||a>144)&&(console.error(`Invalid size '${a}' specified for ${e}. Defaulting to 92.`),a=92),(0,lN.jsx)("svg",{ref:r,className:cM()("-esm-patient-programs__pictograms-module__pictogram___ooPKM",n),height:a,width:a,children:(0,lN.jsx)("use",{href:`#${e}`})})})),Dw=({children:e})=>"tablet"===u6()?(0,lN.jsx)(cV.Layer,{children:e}):(0,lN.jsx)(lN.Fragment,{children:e}),DE=({snackbar:e,closeSnackbar:t})=>{let{actionButtonLabel:r="",kind:n="success",onActionButtonClick:a=()=>{},isLowContrast:o="error"!==n,progressActionLabel:i,subtitle:s="",timeoutInMs:l=5e3,autoClose:u="error"!==n,title:c,id:d,...p}=e,[m,f]=(0,lT.useState)(r),[h,g]=(0,lT.useState)(!0),[y,v]=(0,lT.useState)(!1),b=(0,lT.useCallback)(()=>{setTimeout(t,250)},[t]),w=(0,lT.useCallback)(()=>{v(!0),b()},[b]);return(0,lT.useEffect)(()=>{if(u){let e=setTimeout(w,l);return()=>clearTimeout(e)}},[l,u,w]),(0,lT.useEffect)(()=>{g(!1),window.setTimeout(()=>{g(!0)},0)},[]),(0,lN.jsx)(cV.ActionableNotification,{actionButtonLabel:m,"aria-label":ot("closeSnackbar","Close snackbar"),className:cM()("-esm-patient-programs__snackbar-module__slideIn___senVE",{"-esm-patient-programs__snackbar-module__animated___8eltL":h,"-esm-patient-programs__snackbar-module__slideOut___BIIXm":y}),kind:n,lowContrast:o,onActionButtonClick:()=>{a(),w(),i&&f(i)},onClose:b,statusIconDescription:ot("snackbarNotification","Snackbar notification"),subtitle:s,title:c,...p})},Dx=({subject:e})=>{let[t,r]=(0,lT.useState)([]),n=(0,lT.useCallback)(e=>{r(t=>t.filter(t=>t!==e))},[]);return(0,lT.useEffect)(()=>{let t=e.subscribe(e=>r(t=>[...t.filter(t=>t.subtitle!==e.subtitle||t.actionButtonLabel!==e.actionButtonLabel||t.onActionButtonClick!==e.onActionButtonClick||t.kind!==e.kind||t.title!==e.title),e]));return()=>t.unsubscribe()},[e]),(0,lN.jsx)(lN.Fragment,{children:t.map(e=>(0,lN.jsx)(DE,{snackbar:e,closeSnackbar:()=>n(e)},e.id))})},DD=new xa,DS=0;function D_(e){e&&(0,lq.createRoot)(e).render((0,lN.jsx)(Dx,{subject:DD}))}function DC(e){var t;e&&"string"==typeof(t=e.title)&&t.trim().length>0?setTimeout(()=>{DD.next({...e,id:DS++})},0):console.error("showSnackbar must be called with an object having a 'title' property that is a non-empty string")}let Dk=({toast:e,closeToast:t})=>{let{description:r,kind:n,critical:a,title:o,actionButtonLabel:i,onActionButtonClick:s=()=>{}}=e,l=(0,lT.useCallback)(()=>{s(),t()},[t,s]);return(0,lN.jsx)("div",{children:(0,lN.jsx)(cV.ActionableNotification,{actionButtonLabel:i,kind:n||"info",lowContrast:a,subtitle:r,title:o||"",onActionButtonClick:l,onClose:t})})},DP=({subject:e})=>{let[t,r]=(0,lT.useState)([]),n=(0,lT.useCallback)(e=>{r(t=>t.filter(t=>t!==e))},[]);return(0,lT.useEffect)(()=>{let t=e.subscribe(e=>r(t=>[...t.filter(t=>t.description!==e.description||t.kind!==e.kind||t.title!==e.title||t.actionButtonLabel!==e.actionButtonLabel||t.onActionButtonClick!==e.onActionButtonClick),e]));return()=>t.unsubscribe()},[e]),(0,lN.jsx)(lN.Fragment,{children:t.map(e=>(0,lN.jsx)(Dk,{toast:e,closeToast:()=>n(e)},e.id))})},DR=new xa,DT=0;function DO(e){e&&(0,lq.createRoot)(e).render((0,lN.jsx)(DP,{subject:DR}))}function D$(e){var t;e&&("string"==typeof(t=e.description)?t.trim().length>0:"object"==typeof t&&!E7(t))?setTimeout(()=>{DR.next({...e,id:DT++})},0):console.error("showToast must be called with an object having a 'description' property that is a non-empty string or object")}let DN="u">typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),DI=new Uint8Array(16),DA=[];for(let e=0;e<256;++e)DA.push((e+256).toString(16).slice(1));let DM=function(e,t,r){if(DN&&!t&&!e)return DN();let n=(e=e||{}).random??e.rng?.()??function(){if(!d){if("u"<typeof crypto||!crypto.getRandomValues)throw Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");d=crypto.getRandomValues.bind(crypto)}return d(DI)}();if(n.length<16)throw Error("Random bytes length must be >= 16");if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,t){if((r=r||0)<0||r+16>t.length)throw RangeError(`UUID byte range ${r}:${r+15} is out of buffer bounds`);for(let e=0;e<16;++e)t[r+e]=n[e];return t}return function(e,t=0){return(DA[e[t+0]]+DA[e[t+1]]+DA[e[t+2]]+DA[e[t+3]]+"-"+DA[e[t+4]]+DA[e[t+5]]+"-"+DA[e[t+6]]+DA[e[t+7]]+"-"+DA[e[t+8]]+DA[e[t+9]]+"-"+DA[e[t+10]]+DA[e[t+11]]+DA[e[t+12]]+DA[e[t+13]]+DA[e[t+14]]+DA[e[t+15]]).toLowerCase()}(n)};async function Dj(e,t){let{openedGroup:r}=lh.getState();if(r){if(r.groupName===e&&DB(r.props,t))return!0;else if(!await DW({reason:"CLOSE_WORKSPACE_GROUP",explicit:!1}))return!1}return lh.setState(r=>({...r,openedGroup:{groupName:e,props:t},openedWindows:[]})),!0}async function DL(e){let{openedGroup:t,openedWindows:r}=lh.getState();if(t){if(r.length>0&&!(e||await DW({reason:"CLOSE_WORKSPACE_GROUP",explicit:!0})))return!1;lh.setState(e=>({...e,openedGroup:null,openedWindows:[]}))}return!0}async function DF(e,t=null,r=null,n=null){let a=lh.getState();if(!a.registeredWorkspacesByName[e])throw Error(`Unable to launch workspace ${e}. Workspace is not registered`);let o=lg(e);if(!o)throw Error(`Unable to launch workspace ${e}. Workspace is not registered to a workspace window`);let{openedGroup:i}=a,{name:s}=o,l=ly(s);if(!l)throw Error(`Unable to launch workspace ${e}. Workspace window ${o.name} is not registered to a workspace group`);let u=lv(e);if(i&&(i.groupName!==l.name||!DB(i.props,n)))return!!await DW({reason:"CLOSE_WORKSPACE_GROUP",explicit:!0})&&(lh.setState({...a,openedGroup:{groupName:l.name,props:n},openedWindows:[{windowName:s,openedWorkspaces:[D0(e,t)],props:r,maximized:!1}],isMostRecentlyOpenedWindowHidden:!1}),!0);if(u>=0){let n=a.openedWindows[u],o=a.openedGroup?.props??{},i=a.isMostRecentlyOpenedWindowHidden,{openedWorkspaces:c}=n;if(DB(n.props,r)){let d=c.find(t=>t.workspaceName===e);return d&&DB(d.props,t)?((i||u!==a.openedWindows.length-1)&&lh.setState(DY.restoreWindow(a,s)),!0):!!await DW({reason:"CLOSE_WORKSPACE",explicit:!1,windowName:s,workspaceName:e})&&(lh.setState({...a,openedGroup:{groupName:l.name,props:a?.openedGroup?.props??o},openedWindows:[...a.openedWindows.filter((e,t)=>t!==u),{windowName:s,openedWorkspaces:[D0(e,t)],props:n?.props??r,maximized:!1}],isMostRecentlyOpenedWindowHidden:!1}),!0)}return!!await DW({reason:"CLOSE_WINDOW",explicit:!1,windowName:s})&&(lh.setState({...a,openedGroup:{groupName:l.name,props:o??a?.openedGroup?.props},openedWindows:[...a.openedWindows.filter((e,t)=>t!==u),{windowName:s,openedWorkspaces:[D0(e,t)],props:r,maximized:!1}],isMostRecentlyOpenedWindowHidden:!1}),!0)}return"closable"!=l.persistence?(lh.setState({...a,openedGroup:{groupName:l.name,props:n??a?.openedGroup?.props??null},openedWindows:[...a.openedWindows,{windowName:s,openedWorkspaces:[D0(e,t)],props:r,maximized:!1}],isMostRecentlyOpenedWindowHidden:!1}),!0):!!await DW({reason:"CLOSE_OTHER_WINDOWS",explicit:!1,windowNameToSpare:o.name})&&(lh.setState({...a,openedGroup:{groupName:l.name,props:n??a?.openedGroup?.props??null},openedWindows:[{windowName:s,openedWorkspaces:[D0(e,t)],props:r,maximized:!1}],isMostRecentlyOpenedWindowHidden:!1}),!0)}function DB(e,t){return null==e||null==t||O(e,t)}function DV(e,t){let r=[];for(let n=e.openedWorkspaces.length-1;n>=0;n--){let a=e.openedWorkspaces[n];if(a.hasUnsavedChanges&&r.push(a),t&&a.workspaceName===t)break}return r}function DU(e){return 0===e.length?Promise.resolve(!0):new Promise(t=>{let r=E5("workspace2-close-prompt",{size:"sm",onConfirm:()=>{r(),t(!0)},onCancel:()=>{r(),t(!1)},affectedWorkspaceTitles:e.map(e=>e.title??"")})})}function DW(e){let{openedWindows:t}=lh.getState(),r=[];switch(e.reason){case"CLOSE_WORKSPACE_GROUP":r=t.flatMap(e=>DV(e));break;case"CLOSE_WINDOW":{let n=t.find(t=>t.windowName===e.windowName);if(!n)throw Error(`Window ${e.windowName} not found in opened windows.`);r=DV(n);break}case"CLOSE_WORKSPACE":{let n=t.find(t=>t.windowName===e.windowName);if(!n)throw Error(`Window ${e.windowName} not found in opened windows.`);r=DV(n,e.workspaceName);break}case"CLOSE_OTHER_WINDOWS":r=t.filter(t=>t.windowName!==e.windowNameToSpare).flatMap(e=>DV(e))}return DU(r)}function DH(e,t){return DU(DV(e,t))}function Dz(e,t){let r=e.openedWorkspaces.findIndex(e=>e.workspaceName===t);return r<0?e:0===r?null:{...e,openedWorkspaces:e.openedWorkspaces.slice(0,r)}}function DK(e,t,r,n){let{registeredWorkspacesByName:a}=lh.getState(),o=a[r];if(!o)throw Error(`No workspace named "${r}" registered`);let i=a[t];if(!i)throw Error(`No workspace named "${t}" registered`);if(i.window!==o.window)throw Error(`Child workspace ${r} does not belong to the same workspace window as parent workspace ${t}`);if(o.window!==e.windowName)throw Error(`Cannot open child workspace ${r} as window ${o.window} is not opened`);let{openedWorkspaces:s}=e,l=s.findIndex(e=>e.workspaceName===t);if(-1===l)throw Error(`Cannot open child workspace ${r} from parent workspace ${t} as the parent is not opened within the workspace window`);let u=s.slice(0,l+1);return{...e,openedWorkspaces:[...u,D0(r,n)]}}function DG(e,t,r){let n=e.openedWorkspaces.findIndex(e=>e.uuid===t);if(n<0)return e;let a=e.openedWorkspaces[n];if(Object.keys(r).every(e=>a[e]===r[e]))return e;let o=[...e.openedWorkspaces];return o[n]={...a,...r},{...e,openedWorkspaces:o}}function DZ(e,t,r){let n=e.openedWindows.findIndex(e=>e.openedWorkspaces.some(e=>e.uuid===t));if(n<0)return e;let a=e.openedWindows[n],o=DG(a,t,r);if(o===a)return e;let i=[...e.openedWindows];return i[n]=o,{...e,openedWindows:i}}let DY={setWindowMaximized(e,t,r){let n=e.openedWindows.findIndex(e=>e.windowName===t),a=[...e.openedWindows],o={...a[n],maximized:r};return a[n]=o,{...e,openedWindows:a}},hideWindow:e=>({...e,isMostRecentlyOpenedWindowHidden:!0}),restoreWindow(e,t){let r=e.openedWindows.findIndex(e=>e.windowName===t),n=e.openedWindows[r],a=[...e.openedWindows.filter((e,t)=>t!==r),n];return{...e,openedWindows:a,isMostRecentlyOpenedWindowHidden:!1}},closeWorkspace(e,t){let r=e.openedWindows.findIndex(e=>e.openedWorkspaces.some(e=>e.workspaceName===t));if(r<0)return e;let n=Dz(e.openedWindows[r],t),a=[...e.openedWindows],o=e.isMostRecentlyOpenedWindowHidden;if(null===n){let t=r===e.openedWindows.length-1;a.splice(r,1),t&&a.length>0&&(o=!1)}else a[r]=n;return{...e,openedWindows:a,isMostRecentlyOpenedWindowHidden:o}},openChildWorkspace(e,t,r,n){let a=e.registeredWorkspacesByName[r];if(!a)throw Error(`No workspace named "${r}" registered`);let o=e.openedWindows.findIndex(e=>e.windowName===a.window);if(-1==o)throw Error(`Cannot open child workspace ${r} as window ${a.window} is not opened`);let i=[...e.openedWindows];return i[o]=DK(e.openedWindows[o],t,r,n),{...e,openedWindows:i}},setHasUnsavedChanges:(e,t,r)=>DZ(e,t,{hasUnsavedChanges:r}),setWorkspaceTitle:(e,t,r)=>DZ(e,t,{title:r})};function Dq(){return lB(lh,DY)}let DJ=()=>(0,lT.useContext)(l2),DX=()=>Object.keys(lh.getState().registeredWorkspacesByName);function DQ(e,t,r){let n=e.openedWorkspaces[e.openedWorkspaces.length-1];return(n?t[n.workspaceName]?.width:void 0)??r[e.windowName]?.width??"narrow"}function D0(e,t){return{workspaceName:e,props:t??{},hasUnsavedChanges:!1,uuid:DM()}}function D1(e,t,r){let n=lh.getState().registeredWorkspacesByName[e];return n?{windowName:n.window,openedWorkspaces:[D0(e,t)],props:r??null,maximized:!1}:null}let D4=({title:e,children:t,hasUnsavedChanges:r=!1})=>{let{setHasUnsavedChanges:n,setWorkspaceTitle:a}=DJ();return(0,lT.useEffect)(()=>{n(r??!1)},[r,n]),(0,lT.useEffect)(()=>{a(e)},[e,a]),(0,lN.jsx)(lN.Fragment,{children:t})};function D2(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 D3(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?D2(Object(r),!0).forEach(function(t){D5(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):D2(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function D6(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function D5(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function D9(e){return(D9=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function D8(e,t){return(D8=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function D7(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}var Se=function(e){var t=lT.Component;if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");i.prototype=Object.create(t&&t.prototype,{constructor:{value:i,writable:!0,configurable:!0}}),t&&D8(i,t);var r,n,a,o=(r=function(){if("u"<typeof Reflect||!Reflect.construct||Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}(),function(){var e,t=D9(i);e=r?Reflect.construct(t,arguments,D9(this).constructor):t.apply(this,arguments);if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw TypeError("Derived constructors may only return object or undefined");return D7(this)});function i(e){var t;if(function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,i),D5(D7(t=o.call(this,e)),"handleRef",function(e){t.el=e}),D5(D7(t),"addThingToDo",function(e,r){t.state.hasError&&"unmount"!==e||(t.nextThingToDo=(t.nextThingToDo||Promise.resolve()).then(function(){if(!t.unmounted||"unmount"===e)return r.apply(void 0,arguments)}).catch(function(r){throw t.nextThingToDo=Promise.resolve(),t.setState({hasError:!0}),r&&r.message&&(r.message="During '".concat(e,"', parcel threw an error: ").concat(r.message)),t.props.handleError?t.props.handleError(r):setTimeout(function(){throw r}),r}))}),D5(D7(t),"getParcelProps",function(){var e=D3(D3({},t.props),{},{domElement:t.el});return delete e.mountParcel,delete e.config,delete e.wrapWith,delete e.wrapStyle,delete e.appendTo,delete e.handleError,delete e.parcelDidMount,e}),t.state={hasError:!1},!e.config)throw Error("single-spa-react's Parcel component requires the 'config' prop to either be a parcel config or a loading function that returns a promise. See https://github.com/single-spa/single-spa-react");return t}return n=[{key:"componentDidMount",value:function(){var e=this;this.unmounted=!1,this.addThingToDo("mount",function(){var t,r=e.props.mountParcel||e.mountParcel;if(!r)throw Error("\n <Parcel /> was not passed a mountParcel prop, nor is it rendered where mountParcel is within the React context.\n If you are using <Parcel /> within a module that is not a single-spa application, you will need to import mountRootParcel from single-spa and pass it into <Parcel /> as a mountParcel prop \n ");return e.el?t=e.el:(e.createdDomElement=t=document.createElement(e.props.wrapWith),Object.keys(e.props.wrapStyle).forEach(function(r){t.style[r]=e.props.wrapStyle[r]}),e.props.appendTo.appendChild(t)),e.parcel=r(e.props.config,D3({domElement:t},e.getParcelProps())),e.parcel.mountPromise.then(e.props.parcelDidMount),e.parcel.mountPromise})}},{key:"componentDidUpdate",value:function(){var e=this;this.addThingToDo("update",function(){if(e.parcel&&e.parcel.update)return e.parcel.update(e.getParcelProps())})}},{key:"componentWillUnmount",value:function(){var e=this;this.addThingToDo("unmount",function(){if(e.parcel&&"MOUNTED"===e.parcel.getStatus())return e.parcel.unmount()}),this.createdDomElement&&this.createdDomElement.parentNode.removeChild(this.createdDomElement),this.unmounted=!0}},{key:"render",value:function(){var e=this;if(this.props.appendTo)return l2&&l2.Consumer?lT.createElement(l2.Consumer,null,function(t){return e.mountParcel=t?t.mountParcel:null,null}):null;var t=l2&&l2.Consumer?lT.createElement(l2.Consumer,null,function(t){return e.mountParcel=t?t.mountParcel:null,null}):void 0;return lT.createElement(this.props.wrapWith,{ref:this.handleRef,style:this.props.wrapStyle,className:this.props.wrapClassName},t)}}],D6(i.prototype,n),a&&D6(i,a),i}();D5(Se,"defaultProps",{wrapWith:"div",wrapStyle:{},parcelDidMount:function(){}});var St=r(8742);let Sr=lO().forwardRef(function({children:e,size:t=16,...r},n){return 16===t||"16"===t||"16px"===t?lO().createElement(St.A,{width:t,height:t,ref:n,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 16 16",fill:"currentColor",...r},er||(er=lO().createElement("path",{d:"M2 9L2 10 5.3 10 1 14.3 1.7 15 6 10.7 6 14 7 14 7 9zM14 7L14 6 10.7 6 15 1.7 14.3 1 10 5.3 10 2 9 2 9 7z"})),e):lO().createElement(St.A,{width:t,height:t,ref:n,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",fill:"currentColor",...r},en||(en=lO().createElement("path",{d:"M4 18L4 20 10.586 20 2 28.582 3.414 30 12 21.414 12 28 14 28 14 18 4 18zM30 3.416L28.592 2 20 10.586 20 4 18 4 18 14 28 14 28 12 21.414 12 30 3.416z"})),e)});var Sn=r(4240),Sa=r(8622);let So={workspaceOuterContainer:"-esm-patient-programs__workspace2-module__workspaceOuterContainer___jaqGm",narrowWorkspace:"-esm-patient-programs__workspace2-module__narrowWorkspace___o1wsL",widerWorkspace:"-esm-patient-programs__workspace2-module__widerWorkspace___gdEOi",extraWideWorkspace:"-esm-patient-programs__workspace2-module__extraWideWorkspace___U9xlJ",workspaceMiddleContainer:"-esm-patient-programs__workspace2-module__workspaceMiddleContainer___0AdtX",maximized:"-esm-patient-programs__workspace2-module__maximized___aKCbE",hidden:"-esm-patient-programs__workspace2-module__hidden___n1US5",workspaceInnerContainer:"-esm-patient-programs__workspace2-module__workspaceInnerContainer___1g+qk",workspaceSpacer:"-esm-patient-programs__workspace2-module__workspaceSpacer___P2T9y",loader:"-esm-patient-programs__workspace2-module__loader___fCfzZ",hiddenExtraWorkspace:"-esm-patient-programs__workspace2-module__hiddenExtraWorkspace___hvPSi",header:"-esm-patient-programs__workspace2-module__header___MXXx9",headerButtons:"-esm-patient-programs__workspace2-module__headerButtons___sJdnC",workspaceContent:"-esm-patient-programs__workspace2-module__workspaceContent___6NuXT",overlayHeaderSpacer:"-esm-patient-programs__workspace2-module__overlayHeaderSpacer___PLO6T",isActionMenuOpened:"-esm-patient-programs__workspace2-module__isActionMenuOpened___X3Vj6",showActionMenu:"-esm-patient-programs__workspace2-module__showActionMenu___HSun1",marginWorkspaceContent:"-esm-patient-programs__workspace2-module__marginWorkspaceContent___DCfWz",workspaceContainerWithActionMenu:"-esm-patient-programs__workspace2-module__workspaceContainerWithActionMenu___G9MdI",workspaceFixedContainer:"-esm-patient-programs__workspace2-module__workspaceFixedContainer___uIldI",workspaceContainerWithoutActionMenu:"-esm-patient-programs__workspace2-module__workspaceContainerWithoutActionMenu___lBudZ"},Si=e=>e.registeredWorkspacesByName,Ss=({lifeCycle:e,openedWorkspace:t,openedWindow:r,groupProps:n,actions:a,renderChrome:o,isRootWorkspace:i,isLeafWorkspace:s,showActionMenu:l})=>{let u=(0,lT.useMemo)(()=>t&&{closeWorkspace:async(e={})=>{let{closeWindow:n=!1,discardUnsavedChanges:o=!1}=e;return n?!!(o||await a.promptForClosingWorkspaces())&&(a.closeWorkspace(r.openedWorkspaces[0].workspaceName),!0):!!(o||await a.promptForClosingWorkspaces(t.workspaceName))&&(a.closeWorkspace(t.workspaceName),!0)},launchChildWorkspace:async(e,n)=>{let o=t.workspaceName,{openedWorkspaces:i}=r,s=i.findIndex(e=>e.workspaceName===o);-1===s||s!==i.length-1&&i.slice(s+1).some(e=>e.hasUnsavedChanges)&&!await a.promptForClosingWorkspaces(i[s+1].workspaceName)||a.openChildWorkspace(o,e,n||{})},setWorkspaceTitle:e=>a.setWorkspaceTitle(t.uuid,e),setHasUnsavedChanges:e=>a.setHasUnsavedChanges(t.uuid,e),workspaceName:t.workspaceName,workspaceProps:t.props,windowProps:r.props,groupProps:n,workspaceMeta:lh.getState().registeredWorkspacesByName[t.workspaceName]?.meta??{},isRootWorkspace:i,isLeafWorkspace:s,windowName:r.windowName,showActionMenu:l},[t,r,n,a,i,s,l]),c=!o&&!s,d=(0,lT.useMemo)(()=>e?(0,lN.jsx)(Se,{config:e,mountParcel:lP,wrapWith:"div",wrapClassName:cM()(So.workspaceContent,{[So.hiddenExtraWorkspace]:c}),...u},t.workspaceName):null===e?(0,lN.jsx)("div",{className:cM()(So.workspaceContent,{[So.hiddenExtraWorkspace]:c}),children:(0,lN.jsx)(cV.InlineNotification,{kind:"error",title:ot("error"),subtitle:ot("somethingWentWrongTryReloading"),hideCloseButton:!0})}):null,[e,t.workspaceName,u,c]);return o?(0,lN.jsx)("div",{children:(0,lN.jsx)(Sl,{openedWorkspace:t,openedWindow:r,isRootWorkspace:i,showActionMenu:l,closeWindow:()=>u.closeWorkspace({closeWindow:!0}),children:d})}):d??(0,lN.jsx)(cV.InlineLoading,{className:cM()(So.loader,{[So.hiddenExtraWorkspace]:c}),description:`${ot("loading")}`})},Sl=({openedWorkspace:e,openedWindow:t,isRootWorkspace:r,showActionMenu:n,closeWindow:a,children:o})=>{let i=u6(),{openedGroup:s,openedWindows:l,registeredWindowsByName:u,registeredWorkspacesByName:c,registeredGroupsByName:d,isMostRecentlyOpenedWindowHidden:p,setWindowMaximized:m,hideWindow:f}=Dq(),h=t.windowName,{maximized:g}=t,y=e.title??"",v=u[h],b=DQ(t,c,u),w=v?.icon,E=v?.canMaximize,x=!!s&&d[s.groupName]?.persistence==="closable",D=!!w&&!x,S=l.findIndex(e=>e.windowName===h)<l.length-1||p,_=Object.values(u).some(e=>e.group===s?.groupName&&void 0!==e.icon);return(0,lN.jsxs)("div",{className:cM()(So.workspaceOuterContainer,{[So.narrowWorkspace]:"narrow"===b,[So.widerWorkspace]:"wider"===b,[So.extraWideWorkspace]:"extra-wide"===b,[So.isActionMenuOpened]:_}),children:[(0,lN.jsx)("div",{className:cM()(So.workspaceSpacer,{[So.hidden]:S})}),(0,lN.jsx)("div",{className:cM()(So.workspaceMiddleContainer,{[So.maximized]:g,[So.hidden]:S,[So.isRootWorkspace]:r,[So.showActionMenu]:n}),children:(0,lN.jsx)("div",{className:cM()(So.workspaceInnerContainer,{[So.maximized]:g,[So.hidden]:S,[So.isRootWorkspace]:r}),children:o?(0,lN.jsxs)(lN.Fragment,{children:[(0,lN.jsxs)(cV.Header,{"aria-label":ot("workspaceHeader"),className:So.header,children:[(0,lN.jsx)(cV.HeaderName,{prefix:"",children:y}),(0,lN.jsx)("div",{className:So.overlayHeaderSpacer}),(0,lN.jsx)(cV.HeaderGlobalBar,{className:So.headerButtons,children:u5(i)?(0,lN.jsxs)(lN.Fragment,{children:[(E||g)&&(0,lN.jsx)(cV.HeaderGlobalAction,{"aria-label":g?ot("minimize"):ot("maximize"),onClick:()=>m(h,!g),children:g?(0,lN.jsx)(Sr,{}):(0,lN.jsx)(Sn.hz,{})}),D&&(0,lN.jsx)(cV.HeaderGlobalAction,{"aria-label":ot("hide"),onClick:()=>f(),children:(0,lN.jsx)(c3,{})}),!x&&(0,lN.jsx)(cV.HeaderGlobalAction,{"aria-label":ot("close"),onClick:a,children:(0,lN.jsx)(dm,{})})]}):(0,lN.jsxs)(lN.Fragment,{children:[D&&(0,lN.jsx)(cV.HeaderGlobalAction,{"aria-label":ot("hide"),onClick:()=>f(),children:(0,lN.jsx)(Sa.d3,{})}),(0,lN.jsx)(cV.HeaderGlobalAction,{"aria-label":ot("close"),onClick:()=>{x?DL():a()},children:(0,lN.jsx)(dm,{})})]})})]}),o]}):(0,lN.jsx)(cV.InlineLoading,{className:So.loader,description:`${ot("loading")} ...`})})})]})},Su=({openedWindow:e,groupProps:t,actions:r,renderChrome:n,showActionMenu:a})=>{let{openedWorkspaces:o}=e,[i,s]=(0,lT.useState)({}),l=lF(lh,Si),u=(0,lT.useRef)(new Set);return(0,lT.useEffect)(()=>{let e=!1;return Promise.all(o.map(async t=>{let r=l[t.workspaceName];if(!r)return null;let{moduleName:n,component:a}=r;try{return[t.uuid,await cS(n,a)]}catch(r){return e||u.current.has(t.uuid)||(u.current.add(t.uuid),P(r)),[t.uuid,null]}})).then(t=>{e||s(Object.fromEntries(t.filter(e=>null!=e)))},P),()=>{e=!0}},[o,l]),(0,lN.jsx)(lN.Fragment,{children:o.map((s,l)=>(0,lN.jsx)(Ss,{openedWorkspace:s,openedWindow:e,groupProps:t,actions:r,renderChrome:n,lifeCycle:i[s.uuid],isRootWorkspace:0===l,isLeafWorkspace:l===o.length-1,showActionMenu:a},s.uuid))})},Sc=e=>e.registeredWorkspacesByName,Sd=({name:e,workspaceProps:t,windowProps:r,groupProps:n,onWindowChanged:a})=>{let o=lF(lh,Sc),i=lF(lh,t=>{let r=t.registeredWorkspacesByName[e]?.window;return r?t.registeredWindowsByName[r]:void 0}),s={name:e,workspaceProps:t,windowProps:r,groupProps:n},l=(0,lT.useRef)(),u=(0,lT.useRef)(null);if(!l.current){let a=D1(e,t,r);l.current=U({openedWindow:a,groupProps:n??null}),a&&(u.current=s)}let c=l.current;(0,lT.useEffect)(()=>{let a=u.current;if(a&&a.name===e&&O(a.workspaceProps,t)&&O(a.windowProps,r)&&O(a.groupProps,n))return;let o=D1(e,t,r);c.setState({openedWindow:o,groupProps:n??null},!0),u.current=o?s:null},[e,t,r,n,o,c]);let d=(0,lT.useMemo)(()=>(function(e){function t(t){e.setState(e=>{if(!e.openedWindow)return e;let r=t(e.openedWindow);return r===e.openedWindow?e:{...e,openedWindow:r}})}return{closeWorkspace(e){t(t=>Dz(t,e))},openChildWorkspace(e,r,n){t(t=>DK(t,e,r,n))},setWorkspaceTitle(e,r){t(t=>DG(t,e,{title:r}))},setHasUnsavedChanges(e,r){t(t=>DG(t,e,{hasUnsavedChanges:r}))},promptForClosingWorkspaces(t){let{openedWindow:r}=e.getState();return r?DH(r,t):Promise.resolve(!0)}}})(c),[c]),{openedWindow:p,groupProps:m}=lF(c),f=p?.openedWorkspaces[p.openedWorkspaces.length-1],h=f?.workspaceName??null,g=f?.title??"",y=p?.openedWorkspaces.some(e=>e.hasUnsavedChanges)??!1,v=i?.width??"narrow",b=(0,lT.useRef)(a);return(0,lT.useEffect)(()=>{b.current=a}),(0,lT.useEffect)(()=>{b.current?.({workspaceName:h,windowWidth:v,title:g,hasUnsavedChanges:y})},[h,v,g,y]),(0,lN.jsx)("div",{className:"-esm-patient-programs__exported-workspace-module__exportedWorkspace___3vwoL",children:p?(0,lN.jsx)(Su,{openedWindow:p,groupProps:m,actions:d,renderChrome:!1,showActionMenu:!1}):null})},Sp="-esm-patient-programs__action-menu-button2-module__container___pahg-",Sm="-esm-patient-programs__action-menu-button2-module__elementContainer___PzOdc",Sf="-esm-patient-programs__action-menu-button2-module__active___4O4Bs",Sh="-esm-patient-programs__action-menu-button2-module__focused___+k5kD";function Sg({getIcon:e,hasUnsavedChanges:t,tagContent:r}){return(0,lN.jsxs)(lN.Fragment,{children:[e({size:16}),t?(0,lN.jsx)("span",{className:"-esm-patient-programs__action-menu-button2-module__interruptedTag___mS2yr",children:"!"}):(0,lN.jsx)("span",{className:"-esm-patient-programs__action-menu-button2-module__countTag___rb5CW",children:r})]})}let Sy=({icon:e,label:t,tagContent:r,workspaceToLaunch:n,onBeforeWorkspaceLaunch:a,hidden:o,disabled:i})=>{let s=u6(),{openedWindows:l,restoreWindow:u,hideWindow:c,isMostRecentlyOpenedWindowHidden:d}=Dq(),{extension:p}=(0,lT.useContext)(l$),m=l.findIndex(e=>e.windowName===p?.extensionId),f=l[m],h=null!=f,g=h&&(m<l.length-1||d),y=h&&!g,v=f?.openedWorkspaces.some(e=>e.hasUnsavedChanges)??!1,b=async()=>{if(h)g?u(f.windowName):c();else if(await (a?.()??!0)){let{workspaceName:e,workspaceProps:t,windowProps:r}=n;DF(e,t,r)}};return o?.(l)?null:"tablet"===s||"phone"===s?(0,lN.jsxs)(cV.Button,{className:cM()(Sp,{[Sf]:h&&!y,[Sh]:y}),iconDescription:t,kind:"ghost",onClick:b,role:"button",tabIndex:0,size:"md",disabled:i?.(l),children:[(0,lN.jsx)("span",{className:Sm,children:(0,lN.jsx)(Sg,{hasUnsavedChanges:v,getIcon:e,tagContent:r})}),(0,lN.jsx)("span",{children:t})]}):(0,lN.jsx)(cV.IconButton,{align:"left","aria-label":t,className:cM()(Sp,{[Sf]:h&&!y,[Sh]:y}),enterDelayMs:300,kind:"ghost",label:t,onClick:b,size:"md",disabled:i?.(l),children:(0,lN.jsx)("div",{className:Sm,children:(0,lN.jsx)(Sg,{hasUnsavedChanges:v,getIcon:e,tagContent:r})})})};function Sv({showContactDetails:e,toggleContactDetails:t,className:r}){return(0,lN.jsx)(cV.Button,{className:r,iconDescription:"Toggle contact details",kind:"ghost",onClick:t,renderIcon:e?dp:du,children:e?ot("showLess","Show less"):ot("showMore","Show more")})}let Sb={contactDetails:"-esm-patient-programs__patient-banner-contact-details-module__contactDetails___rhdjA",deceased:"-esm-patient-programs__patient-banner-contact-details-module__deceased___K4NPg",heading:"-esm-patient-programs__patient-banner-contact-details-module__heading___zj6Zt",row:"-esm-patient-programs__patient-banner-contact-details-module__row___+Bx+P",col:"-esm-patient-programs__patient-banner-contact-details-module__col___0H31P",relationship:"-esm-patient-programs__patient-banner-contact-details-module__relationship___CZmay"},Sw=({patientUuid:e})=>{let{cohorts:t=[],isLoading:r}=function(e){let t=e?`${of}/cohortm/cohortmember?patient=${e}&v=custom:(uuid,patient:ref,cohort:(uuid,name,startDate,endDate))`:null,{data:r,isLoading:n}=un()(t,ov),a=r?.data?.results.map(e=>({uuid:e.cohort.uuid,name:e.cohort.name,startDate:e.cohort.startDate,endDate:e.cohort.endDate}));return(0,lT.useMemo)(()=>({cohorts:a,isLoading:n}),[n,a])}(e);return(0,lN.jsxs)(lN.Fragment,{children:[(0,lN.jsxs)("p",{className:Sb.heading,children:[ot("patientLists","Patient Lists")," (",t?.length??0,")"]}),r?(0,lN.jsx)(cV.InlineLoading,{description:`${ot("loading","Loading")} ...`,role:"progressbar"}):(0,lN.jsxs)("ul",{children:[(()=>{if(t?.length>0){let e=t.sort((e,t)=>wT(e?.startDate).getTime()-wT(t?.startDate).getTime()).slice(0,3);return e?.map(e=>(0,lN.jsx)("li",{children:(0,lN.jsx)(lI,{to:`${window.spaBase}/home/patient-lists/${e.uuid}`,children:e.name},e.uuid)},e.uuid))}return(0,lN.jsx)("li",{children:"--"})})(),t.length>3&&(0,lN.jsx)("li",{className:Sb.link,children:(0,lN.jsx)(lI,{to:`${window.spaBase}/home/patient-lists`,children:ot("seeMoreLists","See {{count}} more lists",{count:t?.length-3})})})]})]})},SE=({patientId:e})=>{let{patient:t,isLoading:r}=cs(e),n=t?.address?.find(e=>"home"===e.use),a=e=>e.split("#")[1];return r?(0,lN.jsx)(cV.InlineLoading,{description:`${ot("loading","Loading")} ...`,role:"progressbar"}):(0,lN.jsxs)(lN.Fragment,{children:[(0,lN.jsx)("p",{className:Sb.heading,children:ot("address","Address")}),(0,lN.jsx)("ul",{children:n?Object.entries(n).filter(([e])=>"id"!==e&&"use"!==e).map(([e,t])=>"extension"===e?n.extension?.[0]?.extension?.map((t,r)=>(0,lN.jsxs)("li",{children:[ot(a(t.url),a(t.url)),": ",t.valueString]},`address-${e}-${r}`)):(0,lN.jsxs)("li",{children:[ot(e,e),": ",t]},`address-${e}`)):(0,lN.jsx)("li",{children:"--"})})]})},Sx=({patientUuid:e})=>{let{isLoading:t,contactAttributes:r}=(e=>{let{contactAttributeTypes:t=[]}=u$({externalModuleName:"@openmrs/esm-patient-banner-app"}),{attributes:r,error:n,isLoading:a}=(e=>{let{data:t,error:r,isLoading:n}=uM()(`${of}/patient/${e}?v=custom:(uuid,display,identifiers:(identifier,uuid,preferred,location:(uuid,name),identifierType:(uuid,name,format,formatDescription,validator)),person:(uuid,display,gender,birthdate,dead,age,deathDate,birthdateEstimated,causeOfDeath,preferredName:(uuid,preferred,givenName,middleName,familyName),attributes,preferredAddress:(uuid,preferred,address1,address2,cityVillage,longitude,stateProvince,latitude,country,postalCode,countyDistrict,address3,address4,address5,address6,address7)))`,ov);return{isLoading:n,attributes:t?.data.person.attributes??[],error:r}})(e);return{contactAttributes:(0,lT.useMemo)(()=>r.filter(({attributeType:e})=>t?.some(t=>e.uuid===t)),[r,t]),isLoading:a,error:n}})(e),n=(0,lT.useMemo)(()=>r?[...r?.map(e=>[e.attributeType.display?ot(e.attributeType.display,e.attributeType.display):"",e.value])]:[],[r]);return(0,lN.jsxs)(lN.Fragment,{children:[(0,lN.jsx)("p",{className:Sb.heading,children:ot("contactDetails","Contact Details")}),t?(0,lN.jsx)(cV.InlineLoading,{description:`${ot("loading","Loading")} ...`,role:"progressbar"}):(0,lN.jsx)("ul",{children:n.length?n.map(([e,t],r)=>(0,lN.jsxs)("li",{children:[e,": ",t]},`${e}-${t}-${r}`)):(0,lN.jsx)("li",{children:"--"})})]})},SD=({patientId:e})=>{let{data:t,isLoading:r}=function(e){let t=`${of}/relationship?v=custom:(display,uuid,personA:(age,display,birthdate,uuid),personB:(age,display,birthdate,uuid),relationshipType:(uuid,display,description,aIsToB,bIsToA))&person=${e}`,{data:r,error:n,isLoading:a,isValidating:o}=un()(e?t:null,ov),i=r?.data?.results?.length?function(e,t){let r=[];for(let n of t)e===n.personA.uuid?r.push({uuid:`${n.uuid}`,display:n.personB.display,relativeAge:n.personB.age,relativeUuid:n.personB.uuid,relationshipType:n.relationshipType.bIsToA}):r.push({uuid:`${n.uuid}`,display:n.personA.display,relativeAge:n.personA.age,relativeUuid:n.personA.uuid,relationshipType:n.relationshipType.aIsToB});return r}(e,r.data.results):null;return{data:r?i:null,error:n,isLoading:a,isValidating:o}}(e);return(0,lN.jsxs)(lN.Fragment,{children:[(0,lN.jsx)("p",{className:Sb.heading,children:ot("relationships","Relationships")}),r?(0,lN.jsx)(cV.InlineLoading,{description:`${ot("loading","Loading")} ...`,role:"progressbar"}):(0,lN.jsx)("ul",{children:t&&t.length>0?(0,lN.jsx)(lN.Fragment,{children:t.map(e=>(0,lN.jsxs)("li",{className:Sb.relationship,children:[(0,lN.jsx)("div",{children:(0,lN.jsx)(lI,{to:`${window.spaBase}/patient/${e.relativeUuid}/chart`,children:e.display})}),(0,lN.jsx)("div",{children:e.relationshipType}),(0,lN.jsx)("div",{children:`${e.relativeAge?e.relativeAge:"--"} ${e.relativeAge?1===e.relativeAge?ot("yearAbbreviation","yr"):ot("yearsAbbreviation","yrs"):""}`})]},e.uuid))}):(0,lN.jsx)("li",{children:"--"})})]})};function SS({patientId:e,deceased:t}){return(0,lN.jsxs)("div",{className:cM()(Sb.contactDetails,{[Sb.deceased]:t}),children:[(0,lN.jsxs)("div",{className:Sb.row,children:[(0,lN.jsx)("div",{className:Sb.col,children:(0,lN.jsx)(SE,{patientId:e})}),(0,lN.jsx)("div",{className:Sb.col,children:(0,lN.jsx)(Sx,{patientUuid:e})})]}),(0,lN.jsxs)("div",{className:Sb.row,children:[(0,lN.jsx)("div",{className:Sb.col,children:(0,lN.jsx)(SD,{patientId:e})}),(0,lN.jsx)("div",{className:Sb.col,children:(0,lN.jsx)(Sw,{patientUuid:e})})]})]})}function S_(e){let t=document.querySelector("template#loading-spinner");if(t){let r=t.content.cloneNode(!0),n=Array.prototype.map.call(r.childNodes,e=>e);return e.appendChild(r),()=>n.forEach(e=>e.remove())}return()=>{}}let SC="-esm-patient-programs__action-menu2-module__container___5s3CM";function Sk({workspaceGroup:e,groupProps:t}){let r=u6(),{persistence:n}=e;return(0,lN.jsx)("aside",{className:"-esm-patient-programs__action-menu2-module__sideRail___qwAz4",children:(0,lN.jsxs)("div",{className:SC,children:["closable"==n&&u5(r)&&(0,lN.jsx)(cV.IconButton,{align:"left",onClick:()=>DL(),label:ot("close"),kind:"ghost",children:(0,lN.jsx)(dm,{})}),(0,lN.jsx)(l$.Provider,{value:{moduleName:e.moduleName,featureName:e.name},children:(0,lN.jsx)(lY,{className:SC,name:e.name,state:{groupProps:t}})})]})})}function SP(e){let t=new URL(e,window.location.origin).pathname,r=new URL(window.getOpenmrsSpaBase?.()??"/",window.location.origin).pathname,n=r.endsWith("/")?r.slice(0,-1):r,a=null;return n?n===t?a="/":t.startsWith(`${n}/`)&&(a=t.slice(n.length)):a=t,{full:t,spaRelative:a}}function SR(e){e&&(0,lq.createRoot)(e).render((0,lN.jsx)(ST,{}))}function ST(){let{openedGroup:e,openedWindows:t,registeredGroupsByName:r,registeredWindowsByName:n}=Dq();if((0,lT.useEffect)(()=>iM("before-page-changed",t=>{let{newPage:n,cancelNavigation:a,oldUrl:o,newUrl:i}=t;if(!e)return;if(n)return void a(DL().then(e=>!e));let s=r[e.groupName],l=s?.scopePattern;l&&function(e,t,r){try{let n=new RegExp(e),a=SP(t),o=SP(r);if(null===a.spaRelative||null===o.spaRelative)return!0;let i=n.exec(a.spaRelative),s=n.exec(o.spaRelative);if(i&&s||(i=n.exec(a.full),s=n.exec(o.full)),!i||!s)return!0;if(i.length>1)return!i.slice(1).every((e,t)=>e===s[t+1]);return!1}catch{return!0}}(l,o,i)&&a(DL().then(e=>!e))}),[e,r]),!e)return null;let a=r[e.groupName],o=t.some(e=>e.maximized),{name:i}=a,s=Object.values(n).filter(e=>e.group===i&&void 0!==e.icon).sort((e,t)=>(e.order??Number.MAX_VALUE)-(t.order??Number.MAX_VALUE)).length>0;return(0,lN.jsxs)("div",{className:cM()("-esm-patient-programs__workspace-windows-and-menu-module__workspaceWindowsAndMenuContainer___gN2f4",{"-esm-patient-programs__workspace-windows-and-menu-module__overlay___fqI+X":a.overlay,"-esm-patient-programs__workspace-windows-and-menu-module__hasMaximizedWindow___J7wBw":o}),children:[(0,lN.jsx)("div",{className:"-esm-patient-programs__workspace-windows-and-menu-module__workspaceWindowsContainer___zpk7G",children:t.map(t=>(0,lN.jsx)(SO,{openedWindow:t,groupProps:e.props,showActionMenu:s},t.windowName))}),s&&(0,lN.jsx)(Sk,{workspaceGroup:a,groupProps:e.props})]})}function SO({openedWindow:e,groupProps:t,showActionMenu:r}){let{windowName:n}=e,a=(0,lT.useMemo)(()=>({closeWorkspace(e){lh.setState(t=>DY.closeWorkspace(t,e))},openChildWorkspace(e,t,r){lh.setState(n=>DY.openChildWorkspace(n,e,t,r))},setWorkspaceTitle(e,t){lh.setState(r=>DY.setWorkspaceTitle(r,e,t))},setHasUnsavedChanges(e,t){lh.setState(r=>DY.setHasUnsavedChanges(r,e,t))},promptForClosingWorkspaces(e){let t=lh.getState().openedWindows.find(e=>e.windowName===n);return t?DH(t,e):Promise.resolve(!0)}}),[n]);return(0,lN.jsx)(Su,{openedWindow:e,groupProps:t,actions:a,renderChrome:!0,showActionMenu:r})}function S$(e,t,r){if(null==e)return r;let n=bQ(e);if(!n)return console.warn(`matchLocale: invalid requested locale tag: ${JSON.stringify(e)}`),r;let a=[];for(let e of t){let t=bQ(e);if(!t){console.warn(`matchLocale: skipping invalid available locale tag: ${JSON.stringify(e)}`);continue}a.push({canonical:t,original:e})}let o=n;for(;o;){let e=a.find(e=>e.canonical===o);if(e)return e.original;let t=o+"-",r=a.find(e=>e.canonical.startsWith(t));if(r)return r.original;if("ht"===o){o="fr-HT";continue}let n=o.lastIndexOf("-");if(-1===n)break;let i=(o=o.slice(0,n)).lastIndexOf("-");-1!==i&&o.length-i==2&&(o=o.slice(0,i))}return r}function SN(e=window.localStorage){try{return e.getItem("test"),!0}catch{return!1}}function SI(e){return!!e&&e.constructor===Object}var SA=r(7229);function SM(e){let[t,r,n]=e.split(".");return`${t}.${r}.${n}`}function Sj(e,t){return SA(function(e){let t=e.indexOf("-");if(t>=0){let r=SM(e.slice(0,t)),n=e.slice(t+1);return`${r}-${n}`}return SM(e)}(t),e,{includePrerelease:!0})}async function SL(e,t={}){let r,{shouldRetry:n,getDelay:a,onError:o}=t;n=n??(e=>e<=5),a=a??(e=>(function(e,t=!1){return 1e3*Math.pow(2,t?e+1:e)})(e));let i=0;do try{return await SF(a(i)),await e()}catch(e){o?.(e,i),r=e}while(n(i++));throw r}async function SF(e){if(!(e<=0))return new Promise(t=>setTimeout(t,e))}function SB(e,t,r,n){}function SV(e){}function SU(e){return Promise.resolve([])}function SW(e){return Promise.resolve([])}function SH(e){return Promise.resolve({success:!1,result:void 0,error:"No service worker has been registered. Offline-related features have been removed from the framework."})}function Sz(e){return()=>{}}function SK(){return!0}},670(e,t,r){"use strict";r.d(t,{A:()=>n});let n=function(e,t,r){for(var n=-1,a=Object(e),o=r(e),i=o.length;i--;){var s=o[++n];if(!1===t(a[s],s,a))break}return e}}}]);
39
+ }`.trim(),document.head.prepend(n),o=HTMLElement.prototype.focus,HTMLElement.prototype.focus=function(e){let t=((e=document)=>e.activeElement)(),r=null!=t&&bm(t);o.call(this,{...e,preventScroll:!0}),e&&e.preventScroll||bv(this,r)},i=pO(by(document,"touchstart",t=>{let n=ms(t);e=gg(n)?n:gy(n,!0),r=!1;let a=n.ownerDocument.defaultView.getSelection();a&&!a.isCollapsed&&a.containsNode(n,!0)&&(r=!0),t.composedPath().some(e=>e instanceof HTMLInputElement&&"range"===e.type)&&(r=!0),"selectionStart"in n&&"selectionEnd"in n&&n.selectionStart<n.selectionEnd&&n.ownerDocument.activeElement===n&&(r=!0)},{passive:!1,capture:!0}),by(document,"touchmove",t=>{if(2!==t.touches.length&&!r){if(!e||e===document.documentElement||e===document.body)return void t.preventDefault();e.scrollHeight===e.clientHeight&&e.scrollWidth===e.clientWidth&&t.preventDefault()}},{passive:!1,capture:!0}),by(document,"blur",e=>{let t=ms(e),r=e.relatedTarget;if(r&&bm(r))r.focus({preventScroll:!0}),bv(r,bm(t));else if(!r){let e=t.parentElement?.closest("[tabindex]");e?.focus({preventScroll:!0})}},!0)),()=>{t(),i(),n.remove(),HTMLElement.prototype.focus=o}):pO((s=window.innerWidth-document.documentElement.clientWidth)>0&&("scrollbarGutter"in document.documentElement.style?bg(document.documentElement,"scrollbarGutter","stable"):bg(document.documentElement,"paddingRight",`${s}px`)),bg(document.documentElement,"overflow","hidden"))),()=>{0==--bh&&c()}}},[t])}({isDisabled:o||!t.isOpen}),(0,lT.useEffect)(()=>{if(t.isOpen&&n.current)if(o){var e,r,i=a?.current??n.current;let t=vJ[vJ.length-1];return t&&!t.visibleNodes.has(i)?(t.visibleNodes.add(i),()=>{t.visibleNodes.delete(i)}):void 0}else{let t,o,i,s,l,u,c,d,p,m,f;return e=[a?.current??n.current],o=(r={shouldUseInert:!0})instanceof(t=mo(e?.[0])).Element?{root:r}:r,i=o?.root??document.body,s=o?.shouldUseInert&&vY,l=new Set(e),u=new Set,c=(e,r)=>{s&&e instanceof t.HTMLElement?e.inert=r:r?e.setAttribute("aria-hidden","true"):(e.removeAttribute("aria-hidden"),e instanceof t.HTMLElement&&(e.inert=!1))},d=e=>{for(let t of e.querySelectorAll("[data-live-announcer], [data-react-aria-top-layer]"))l.add(t);let t=e=>{if(u.has(e)||l.has(e)||e.parentElement&&u.has(e.parentElement)&&"row"!==e.parentElement.getAttribute("role"))return NodeFilter.FILTER_REJECT;for(let t of l)if(mi(e,t))return NodeFilter.FILTER_SKIP;return NodeFilter.FILTER_ACCEPT},r=y$(ma(e),e,NodeFilter.SHOW_ELEMENT,{acceptNode:t}),n=t(e);if(n===NodeFilter.FILTER_ACCEPT&&p(e),n!==NodeFilter.FILTER_REJECT){let e=r.nextNode();for(;null!=e;)p(e),e=r.nextNode()}},p=e=>{let r=vq.get(e)??0;(s&&e instanceof t.HTMLElement?e.inert:"true"===e.getAttribute("aria-hidden"))&&0===r||(0===r&&c(e,!0),u.add(e),vq.set(e,r+1))},vJ.length&&vJ[vJ.length-1].disconnect(),d(i),(m=new MutationObserver(e=>{for(let r of e)if("childList"===r.type&&r.target.isConnected&&![...l,...u].some(e=>mi(e,r.target)))for(let e of r.addedNodes){var t;(e instanceof HTMLElement||e instanceof SVGElement)&&("true"===(t=e).dataset.liveAnnouncer||void 0!==t.dataset.reactAriaTopLayer)?l.add(e):e instanceof Element&&d(e)}})).observe(i,{childList:!0,subtree:!0}),f={visibleNodes:l,hiddenNodes:u,observe(){m.observe(i,{childList:!0,subtree:!0})},disconnect(){m.disconnect()}},vJ.push(f),()=>{for(let e of(m.disconnect(),u)){let t=vq.get(e);null!=t&&(1===t?(c(e,!1),vq.delete(e)):vq.set(e,t-1))}f===vJ[vJ.length-1]?(vJ.pop(),vJ.length&&vJ[vJ.length-1].observe()):vJ.splice(vJ.indexOf(f),1)}}},[o,t.isOpen,n,a]),{popoverProps:pG(d,m),arrowProps:f,underlayProps:p,placement:h,triggerAnchorPoint:g}}({...n,offset:null!=(a=n.offset)?a:8,arrowSize:s,groupRef:p?d:u},e),y=n.popoverRef,v=bx(y,!!g)||n.isEntering||!1,b=pq({...n,defaultClassName:"react-aria-Popover",values:{trigger:n.trigger||null,placement:g,isEntering:v,isExiting:t}}),w=!n.isNonModal||"SubmenuTrigger"===n.trigger,[E,x]=(0,lT.useState)(!1);p$(()=>{y.current&&x(w&&!y.current.querySelector("[role=dialog]"))},[y,w]),(0,lT.useEffect)(()=>{var e;let t,r;E&&y.current&&!y.current.contains(document.activeElement)&&(r=((e=document)=>e.activeElement)(t=ma(e=y.current)),"virtual"===b_?mQ(()=>{((e=document)=>e.activeElement)(t)===r&&e.isConnected&&mr(e)}):mr(e))},[E,y]);let D={...m.style,...b.style},S=lO().createElement("div",{...pG(mt(n),m),...b,role:E?"dialog":void 0,tabIndex:E?-1:void 0,"aria-label":n["aria-label"],"aria-labelledby":n["aria-labelledby"],ref:y,slot:n.slot||void 0,style:D,dir:n.dir,"data-trigger":n.trigger,"data-placement":g,"data-entering":v||void 0,"data-exiting":t||void 0},!n.isNonModal&&lO().createElement(bE,{onDismiss:e.close}),lO().createElement(vZ.Provider,{value:{...h,placement:g,ref:i}},b.children),lO().createElement(bE,{onDismiss:e.close}));return p?lO().createElement(vL,{...n,shouldContainFocus:E,isExiting:t,portalContainer:null!=(o=null!=r?r:null==d?void 0:d.current)?o:void 0},S):lO().createElement(vL,{...n,shouldContainFocus:E,isExiting:t,portalContainer:r},!n.isNonModal&&e.isOpen&&lO().createElement("div",{"data-testid":"underlay",...f,style:{position:"fixed",inset:0}}),lO().createElement("div",{ref:u,style:{display:"contents"}},lO().createElement(bB.Provider,{value:u},S)))}function bW(e){return e?.start!=null&&null!=e.end}let bH=(0,lT.createContext)(null),bz=(0,lT.createContext)(null),bK=(0,lT.createContext)(null),bG=(0,lT.createContext)(null),bZ=(0,lT.forwardRef)(function(e,t){var r,n;[e,t]=pX(e,t,bH);let{validationBehavior:a}=pJ(vz)||{},o=null!=(n=null!=(r=e.validationBehavior)?r:a)?n:"native",i=function(e){let t=bL(e),[r,n]=yc(e.value,e.defaultValue||null,e.onChange),[a]=(0,lT.useState)(r),o=r||e.placeholderValue||null,[i,s]=vv(o,e.granularity),l=null!=r?r.toDate(s??"UTC"):null,u="hour"===i||"minute"===i||"second"===i,c=e.shouldCloseOnSelect??!0,[d,p]=(0,lT.useState)(null),[m,f]=(0,lT.useState)(null);if(r&&(d=r,"hour"in r&&(m=r)),o&&!(i in o))throw Error("Invalid granularity "+i+" for value "+o.toString());let h=r?.calendar.identifier==="gregory"&&"BC"===r.era,g=(0,lT.useMemo)(()=>({granularity:i,timeZone:s,hideTimeZone:e.hideTimeZone,hourCycle:e.hourCycle,shouldForceLeadingZeros:e.shouldForceLeadingZeros,showEra:h}),[i,e.hourCycle,e.shouldForceLeadingZeros,s,e.hideTimeZone,h]),{minValue:y,maxValue:v,isDateUnavailable:b}=e,w=(0,lT.useMemo)(()=>vp(r,y,v,b,g),[r,y,v,b,g]),E=vo({...e,value:r,builtinValidation:w}),x=E.displayValidation.isInvalid,D=e.validationState||(x?"invalid":null),S=(e,t)=>{n("timeZone"in t?t.set(hK(e)):hG(e,t)),p(null),f(null),E.commitValidation()};return{...E,value:r,defaultValue:e.defaultValue??a,setValue:n,dateValue:d,timeValue:m,setDateValue:r=>{let a="function"==typeof c?c():c;u?m||a?S(r,m||vg(e.defaultValue||e.placeholderValue)):p(r):(n(r),E.commitValidation()),a&&t.setOpen(!1)},setTimeValue:e=>{d&&e?S(d,e):f(e)},granularity:i,hasTime:u,...t,setOpen(n){!n&&!r&&d&&u&&S(d,m||vg(e.defaultValue||e.placeholderValue)),t.setOpen(n)},validationState:D,isInvalid:x,formatValue:(e,t)=>l?new f1(e,vh(t,g)).format(l):"",getDateFormatter:(e,t)=>new f1(e,vh({},{...g,...t}))}}({...e,validationBehavior:o}),s=(0,lT.useRef)(null),[l,u]=pQ(!e["aria-label"]&&!e["aria-labelledby"]),{groupProps:c,labelProps:d,fieldProps:p,buttonProps:m,dialogProps:f,calendarProps:h,descriptionProps:g,errorMessageProps:y,...v}=function(e,t,r){var n;let a=pH(),o=pH(),i=pH(),s=hi((n=yQ)&&n.__esModule?n.default:n,"@react-aria/datepicker"),{isInvalid:l,validationErrors:u,validationDetails:c}=t.displayValidation,{labelProps:d,fieldProps:p,descriptionProps:m,errorMessageProps:f}=y4({...e,labelElementType:"span",isInvalid:l,errorMessage:e.errorMessage||u}),h=y0(t,r),g=p["aria-labelledby"]||p.id,{locale:y}=fZ(),v=t.formatValue(y,{month:"long"}),b=gD(v?s.format("selectedDateDescription",{date:v}):""),w=[b["aria-describedby"],p["aria-describedby"]].filter(Boolean).join(" ")||void 0,E=mt(e),x=(0,lT.useMemo)(()=>yZ(r),[r]),D=(0,lT.useRef)(!1),{focusWithinProps:S}=fw({...e,isDisabled:t.isOpen,onBlurWithin:t=>{mi(document.getElementById(o),t.relatedTarget)||(D.current=!1,e.onBlur?.(t),e.onFocusChange?.(!1))},onFocusWithin:t=>{D.current||(D.current=!0,e.onFocus?.(t),e.onFocusChange?.(!0))}});return{groupProps:pG(E,h,p,b,S,{role:"group","aria-disabled":e.isDisabled||null,"aria-labelledby":g,"aria-describedby":w,onKeyDown(r){!t.isOpen&&e.onKeyDown&&e.onKeyDown(r)},onKeyUp(r){!t.isOpen&&e.onKeyUp&&e.onKeyUp(r)}}),labelProps:{...d,onClick:()=>{x.focusFirst()}},fieldProps:{...p,id:i,[y5]:"presentation","aria-describedby":w,value:t.value,defaultValue:t.defaultValue,onChange:t.setValue,placeholderValue:e.placeholderValue,hideTimeZone:e.hideTimeZone,hourCycle:e.hourCycle,shouldForceLeadingZeros:e.shouldForceLeadingZeros,granularity:e.granularity,isDisabled:e.isDisabled,isReadOnly:e.isReadOnly,isRequired:e.isRequired,validationBehavior:e.validationBehavior,[va]:t,autoFocus:e.autoFocus,name:e.name,form:e.form},descriptionProps:m,errorMessageProps:f,buttonProps:{...b,id:a,"aria-haspopup":"dialog","aria-label":s.format("calendar"),"aria-labelledby":`${a} ${g}`,"aria-describedby":w,"aria-expanded":t.isOpen,isDisabled:e.isDisabled||e.isReadOnly,onPress:()=>t.setOpen(!0)},dialogProps:{id:o,"aria-labelledby":`${a} ${g}`},calendarProps:{autoFocus:!0,value:t.dateValue,onChange:t.setDateValue,minValue:e.minValue,maxValue:e.maxValue,isDisabled:e.isDisabled,isReadOnly:e.isReadOnly,isDateUnavailable:e.isDateUnavailable,defaultFocusedValue:t.dateValue?void 0:e.placeholderValue,isInvalid:t.isInvalid,errorMessage:"function"==typeof e.errorMessage?e.errorMessage(t.displayValidation):e.errorMessage||t.displayValidation.validationErrors.join(" "),firstDayOfWeek:e.firstDayOfWeek,pageBehavior:e.pageBehavior},isInvalid:l,validationErrors:u,validationDetails:c}}({...p0(e),label:u,validationBehavior:o},i,s),[b,w]=(0,lT.useState)(null),E=(0,lT.useCallback)(()=>{s.current&&w(s.current.offsetWidth+"px")},[]);bs({ref:s,onResize:E});let{focusProps:x,isFocused:D,isFocusVisible:S}=fE({within:!0}),_=pq({...e,values:{state:i,isFocusWithin:D,isFocusVisible:S,isDisabled:e.isDisabled||!1,isInvalid:i.isInvalid,isOpen:i.isOpen},defaultClassName:"react-aria-DatePicker"}),C=mt(e);return delete C.id,lO().createElement(pY,{values:[[bK,i],[yP,{...c,ref:s,isInvalid:i.isInvalid}],[vP,p],[fT,{...m,isPressed:i.isOpen}],[vK,{...d,ref:l,elementType:"span"}],[yg,h],[vB,i],[bF,{trigger:"DatePicker",triggerRef:s,placement:"bottom start",style:{"--trigger-width":b}}],[vF,f],[fN,{slots:{description:g,errorMessage:y}}],[vU,v]]},lO().createElement("div",{...x,...C,..._,ref:t,slot:e.slot||void 0,"data-focus-within":D||void 0,"data-invalid":i.isInvalid||void 0,"data-focus-visible":S||void 0,"data-disabled":e.isDisabled||void 0,"data-open":i.isOpen||void 0}))}),bY=(0,lT.forwardRef)(function(e,t){var r,n;[e,t]=pX(e,t,bz);let{validationBehavior:a}=pJ(vz)||{},o=null!=(n=null!=(r=e.validationBehavior)?r:a)?n:"native",i=function(e){let t=bL(e),[r,n]=yc(e.value,e.defaultValue||null,e.onChange),[a]=(0,lT.useState)(r),[o,i]=(0,lT.useState)(()=>r||{start:null,end:null});null==r&&o.start&&o.end&&i(o={start:null,end:null});let s=r||o,l=e=>{i(s=e||{start:null,end:null}),bW(s)?n(s):n(null)},[u,c]=vv(s?.start||s?.end||e.placeholderValue||null,e.granularity),d="hour"===u||"minute"===u||"second"===u,p=e.shouldCloseOnSelect??!0,[m,f]=(0,lT.useState)(null),[h,g]=(0,lT.useState)(null);s&&bW(s)&&(m=s,"hour"in s.start&&(h=s));let y=(e,t)=>{l({start:"timeZone"in t.start?t.start.set(hK(e.start)):hG(e.start,t.start),end:"timeZone"in t.end?t.end.set(hK(e.end)):hG(e.end,t.end)}),f(null),g(null),C.commitValidation()},v=r=>{let n="function"==typeof p?p():p;d?bW(r)&&(n||h?.start&&h?.end)?y(r,{start:h?.start||vg(e.placeholderValue),end:h?.end||vg(e.placeholderValue)}):f(r):bW(r)?(l(r),C.commitValidation()):f(r),n&&t.setOpen(!1)},b=e=>{bW(m)&&bW(e)?y(m,e):g(e)},w=s?.start?.calendar.identifier==="gregory"&&"BC"===s.start.era||s?.end?.calendar.identifier==="gregory"&&"BC"===s.end.era,E=(0,lT.useMemo)(()=>({granularity:u,timeZone:c,hideTimeZone:e.hideTimeZone,hourCycle:e.hourCycle,shouldForceLeadingZeros:e.shouldForceLeadingZeros,showEra:w}),[u,e.hourCycle,e.shouldForceLeadingZeros,c,e.hideTimeZone,w]),{minValue:x,maxValue:D,isDateUnavailable:S}=e,_=(0,lT.useMemo)(()=>{var e;let t;return e=s,t=vu(vp(e?.start??null,x,D,S,E),vp(e?.end??null,x,D,S,E)),e?.end!=null&&null!=e.start&&0>e.end.compare(e.start)&&(t=vu(t,{isInvalid:!0,validationErrors:[(he.getGlobalDictionaryForPackage("@react-stately/datepicker")||vc).getStringForLocale("rangeReversed",vd())],validationDetails:{...ve,rangeUnderflow:!0,rangeOverflow:!0,valid:!1}})),t},[s,x,D,S,E]),C=vo({...e,value:r,name:(0,lT.useMemo)(()=>[e.startName,e.endName].filter(e=>null!=e),[e.startName,e.endName]),builtinValidation:_}),k=C.displayValidation.isInvalid,P=e.validationState||(k?"invalid":null);return{...C,value:s,defaultValue:e.defaultValue??a,setValue:l,dateRange:m,timeRange:h,granularity:u,hasTime:d,setDate(e,t){"start"===e?v({start:t,end:m?.end??null}):v({start:m?.start??null,end:t})},setTime(e,t){"start"===e?b({start:t,end:h?.end??null}):b({start:h?.start??null,end:t})},setDateTime(e,t){"start"===e?l({start:t,end:s?.end??null}):l({start:s?.start??null,end:t})},setDateRange:v,setTimeRange:b,...t,setOpen(r){!r&&!(s?.start&&s?.end)&&bW(m)&&d&&y(m,{start:h?.start||vg(e.placeholderValue),end:h?.end||vg(e.placeholderValue)}),t.setOpen(r)},validationState:P,isInvalid:k,formatValue(t,r){let n;if(!s||!s.start||!s.end)return null;let a="timeZone"in s.start?s.start.timeZone:void 0,o=e.granularity||(s.start&&"minute"in s.start?"minute":"day"),i="timeZone"in s.end?s.end.timeZone:void 0,l=e.granularity||(s.end&&"minute"in s.end?"minute":"day"),u=vh(r,{granularity:o,timeZone:a,hideTimeZone:e.hideTimeZone,hourCycle:e.hourCycle,showEra:"gregory"===s.start.calendar.identifier&&"BC"===s.start.era||"gregory"===s.end.calendar.identifier&&"BC"===s.end.era}),c=s.start.toDate(a||"UTC"),d=s.end.toDate(i||"UTC"),p=new f1(t,u);if(a===i&&o===l&&0!==s.start.compare(s.end)){try{let e=p.formatRangeToParts(c,d),t=-1;for(let r=0;r<e.length;r++){let n=e[r];if("shared"===n.source&&"literal"===n.type)t=r;else if("endRange"===n.source)break}let r="",n="";for(let a=0;a<e.length;a++)a<t?r+=e[a].value:a>t&&(n+=e[a].value);return{start:r,end:n}}catch{}n=p}else n=new f1(t,vh(r,{granularity:l,timeZone:i,hideTimeZone:e.hideTimeZone,hourCycle:e.hourCycle}));return{start:p.format(c),end:n.format(d)}},getDateFormatter:(e,t)=>new f1(e,vh({},{...E,...t}))}}({...e,validationBehavior:o}),s=(0,lT.useRef)(null),[l,u]=pQ(!e["aria-label"]&&!e["aria-labelledby"]),{groupProps:c,labelProps:d,startFieldProps:p,endFieldProps:m,buttonProps:f,dialogProps:h,calendarProps:g,descriptionProps:y,errorMessageProps:v,...b}=function(e,t,r){var n;let a=hi((n=yQ)&&n.__esModule?n.default:n,"@react-aria/datepicker"),{isInvalid:o,validationErrors:i,validationDetails:s}=t.displayValidation,{labelProps:l,fieldProps:u,descriptionProps:c,errorMessageProps:d}=y4({...e,labelElementType:"span",isInvalid:o,errorMessage:e.errorMessage||i}),p=u["aria-labelledby"]||u.id,{locale:m}=fZ(),f=t.formatValue(m,{month:"long"}),h=gD(f?a.format("selectedRangeDescription",{startDate:f.start,endDate:f.end}):""),g={"aria-label":a.format("startDate"),"aria-labelledby":p},y={"aria-label":a.format("endDate"),"aria-labelledby":p},v=pH(),b=pH(),w=y0(t,r),E=[h["aria-describedby"],u["aria-describedby"]].filter(Boolean).join(" ")||void 0,x=(0,lT.useMemo)(()=>yZ(r,{accept:e=>e.id!==v}),[r,v]),D={[y9]:x,[y5]:"presentation","aria-describedby":E,placeholderValue:e.placeholderValue,hideTimeZone:e.hideTimeZone,hourCycle:e.hourCycle,granularity:e.granularity,shouldForceLeadingZeros:e.shouldForceLeadingZeros,isDisabled:e.isDisabled,isReadOnly:e.isReadOnly,isRequired:e.isRequired,validationBehavior:e.validationBehavior},S=mt(e),_=(0,lT.useRef)(!1),{focusWithinProps:C}=fw({...e,isDisabled:t.isOpen,onBlurWithin:t=>{mi(document.getElementById(b),t.relatedTarget)||(_.current=!1,e.onBlur?.(t),e.onFocusChange?.(!1))},onFocusWithin:t=>{_.current||(_.current=!0,e.onFocus?.(t),e.onFocusChange?.(!0))}}),k=(0,lT.useRef)(vr),P=(0,lT.useRef)(vr);return{groupProps:pG(S,w,u,h,C,{role:"group","aria-disabled":e.isDisabled||null,"aria-describedby":E,onKeyDown(r){!t.isOpen&&e.onKeyDown&&e.onKeyDown(r)},onKeyUp(r){!t.isOpen&&e.onKeyUp&&e.onKeyUp(r)}}),labelProps:{...l,onClick:()=>{x.focusFirst()}},buttonProps:{...h,id:v,"aria-haspopup":"dialog","aria-label":a.format("calendar"),"aria-labelledby":`${v} ${p}`,"aria-describedby":E,"aria-expanded":t.isOpen,isDisabled:e.isDisabled||e.isReadOnly,onPress:()=>t.setOpen(!0)},dialogProps:{id:b,"aria-labelledby":`${v} ${p}`},startFieldProps:{...g,...D,value:t.value?.start??null,defaultValue:t.defaultValue?.start,onChange:e=>t.setDateTime("start",e),autoFocus:e.autoFocus,name:e.startName,form:e.form,[va]:{realtimeValidation:t.realtimeValidation,displayValidation:t.displayValidation,updateValidation(e){k.current=e,t.updateValidation(vu(e,P.current))},resetValidation:t.resetValidation,commitValidation:t.commitValidation}},endFieldProps:{...y,...D,value:t.value?.end??null,defaultValue:t.defaultValue?.end,onChange:e=>t.setDateTime("end",e),name:e.endName,form:e.form,[va]:{realtimeValidation:t.realtimeValidation,displayValidation:t.displayValidation,updateValidation(e){P.current=e,t.updateValidation(vu(k.current,e))},resetValidation:t.resetValidation,commitValidation:t.commitValidation}},descriptionProps:c,errorMessageProps:d,calendarProps:{autoFocus:!0,value:t.dateRange?.start&&t.dateRange.end?t.dateRange:null,onChange:t.setDateRange,minValue:e.minValue,maxValue:e.maxValue,isDisabled:e.isDisabled,isReadOnly:e.isReadOnly,isDateUnavailable:e.isDateUnavailable,allowsNonContiguousRanges:e.allowsNonContiguousRanges,defaultFocusedValue:t.dateRange?void 0:e.placeholderValue,isInvalid:t.isInvalid,errorMessage:"function"==typeof e.errorMessage?e.errorMessage(t.displayValidation):e.errorMessage||t.displayValidation.validationErrors.join(" "),firstDayOfWeek:e.firstDayOfWeek,pageBehavior:e.pageBehavior},isInvalid:o,validationErrors:i,validationDetails:s}}({...p0(e),label:u,validationBehavior:o},i,s),[w,E]=(0,lT.useState)(null),x=(0,lT.useCallback)(()=>{s.current&&E(s.current.offsetWidth+"px")},[]);bs({ref:s,onResize:x});let{focusProps:D,isFocused:S,isFocusVisible:_}=fE({within:!0}),C=pq({...e,values:{state:i,isFocusWithin:S,isFocusVisible:_,isDisabled:e.isDisabled||!1,isInvalid:i.isInvalid,isOpen:i.isOpen},defaultClassName:"react-aria-DateRangePicker"}),k=mt(e);return delete k.id,lO().createElement(pY,{values:[[bG,i],[yP,{...c,ref:s,isInvalid:i.isInvalid}],[fT,{...f,isPressed:i.isOpen}],[vK,{...d,ref:l,elementType:"span"}],[yy,g],[vB,i],[bF,{trigger:"DateRangePicker",triggerRef:s,placement:"bottom start",style:{"--trigger-width":w}}],[vF,h],[vP,{slots:{start:p,end:m}}],[fN,{slots:{description:y,errorMessage:v}}],[vU,b]]},lO().createElement("div",{...D,...k,...C,ref:t,slot:e.slot||void 0,"data-focus-within":S||void 0,"data-invalid":i.isInvalid||void 0,"data-focus-visible":_||void 0,"data-disabled":e.isDisabled||void 0,"data-open":i.isOpen||void 0}))});function bq(e){return lO().createElement(fG,e)}function bJ(e,t,r=!1){if(null==e)return r?e:void 0;if("string"==typeof e&&!e)return r?null:void 0;if(e instanceof hI||e instanceof hM||e instanceof hj)return t?hZ(e,t):e;{let r=cf()(e).toDate(),n=new hI(r.getFullYear(),r.getMonth()+1,r.getDate());return t?hZ(n,t):n}}function bX(e){if(e)return e.toDate(h5())}function bQ(e){if("string"==typeof e&&0!==e.trim().length)try{return new Intl.Locale(e.replace(/[_@]/g,"-")).toString()}catch{return}}function b0(e){let t=e??"",r=bQ(t);if(!r)return t;try{return new Intl.DisplayNames([r],{type:"language"}).of(r)??t}catch{return t}}function b1(){let e=window.i18next.language,t=bQ(e)??e;return"ht"===t&&(t="fr-HT"),t}if("u">typeof navigator){let e=navigator;et=Array.isArray(e.languages)?e.languages[0]:e.language}else if("u">typeof process){let e=process.env;et=e.LC_ALL||e.LC_MESSAGES||e.LANG||e.LANGUAGE}var b4=function(e){e=(e=e.replace(/_/g,"-")).replace(/[.:][\w-]*$/,"");try{return new Intl.Locale(e).baseName}catch{return"en-US"}}(et||"en-US"),b2=class extends Date{invalid=null;isValid(){return!Number.isNaN(this.valueOf())}},b3={};for(let e=1;e<100;e++)b3[(e<=9?"0":"")+e]=e+(e>51?1900:2e3);var b6={arab:1632,arabext:1776,bali:6992,beng:2534,deva:2406,fullwide:65296,gujr:2790,khmr:6112,knda:3302,laoo:3792,limb:6470,mlym:3430,mong:6160,mymr:4160,orya:2918,tamldec:3046,telu:3174,thai:3664,tibt:3872},b5="[1234567890一二三四五六七八九〇\\d]",b9={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,"0":0,"1":1,"2":2,"3":3,"4":4,"5":5,"6":6,"7":7,"8":8,"9":9,〇:0,一:1,二:2,三:3,四:4,五:5,六:6,七:7,八:8,九:9},b8={},b7={"Eastern Daylight Time":-240,"Eastern Standard Time":-300,"Central Daylight Time":-300,"Central Standard Time":-360,"Mountain Daylight Time":-360,"Mountain Standard Time":-420,"Pacific Daylight Time":-420,"Pacific Standard Time":-480,"Coordinated Universal Time":0,ACDT:630,ACST:570,ACT:480,ADT:-180,AEDT:660,AEST:600,AFT:270,AKDT:-480,AKST:-540,AMST:-180,AMT:-240,ART:-180,AST:180,AWDT:540,AWST:480,AZOST:-60,AZT:240,BDT:360,BIOT:360,BIT:-720,BOT:-240,BRST:-120,BRT:-180,BTT:360,CAT:120,CCT:390,CDT:-300,CEDT:120,CEST:120,CET:60,CHADT:825,CHAST:765,CHOT:480,ChST:600,CHUT:600,CIST:-480,CIT:480,CKT:-600,CLST:-180,CLT:-240,COST:-240,COT:-300,CST:-360,CT:480,CVT:-60,CXT:420,DAVT:420,DDUT:600,DFT:60,EASST:-300,EAST:-360,EAT:180,ECT:-300,EDT:-240,EEDT:180,EEST:180,EET:120,EGST:0,EGT:-60,EIT:540,EST:-300,FET:180,FJT:720,FKST:-180,FKT:-240,FNT:-120,GALT:-360,GAMT:-540,GET:240,GFT:-180,GILT:720,GIT:-540,GMT:0,GST:-120,GYT:-240,HADT:-540,HAEC:120,HAST:-600,HKT:480,HMT:300,HOVT:420,HST:-600,IBST:0,ICT:420,IDT:180,IOT:180,IRDT:270,IRKT:480,IRST:210,IST:120,JST:540,KGT:360,KOST:660,KRAT:420,KST:540,LHST:630,LINT:840,MAGT:720,MART:-510,MAWT:300,MDT:-360,MET:60,MEST:120,MHT:720,MIST:660,MIT:-510,MMT:390,MSK:180,MST:-420,MUT:240,MVT:300,MYT:480,NCT:660,NDT:-90,NFT:660,NPT:345,NST:-150,NT:-150,NUT:-660,NZDT:780,NZST:720,OMST:360,ORAT:300,PDT:-420,PET:-300,PETT:720,PGT:600,PHOT:780,PKT:300,PMDT:-120,PMST:-180,PONT:660,PST:-480,PYST:-180,PYT:-240,RET:240,ROTT:-180,SAKT:660,SAMT:240,SAST:120,SBT:660,SCT:240,SGT:480,SLST:330,SRET:660,SRT:-180,SST:480,SYOT:180,TAHT:-600,THA:420,TFT:300,TJT:300,TKT:780,TLT:540,TMT:300,TOT:780,TVT:720,UCT:0,ULAT:480,USZ1:120,UTC:0,UYST:-120,UYT:-180,UZT:300,VET:-240,VLAT:600,VOLT:240,VOST:360,VUT:660,WAKT:720,WAST:120,WAT:60,WEDT:60,WEST:60,WET:0,WIT:420,WST:480,YAKT:540,YEKT:300},we={zone:b7,year:b3,meridiem:{am:0,pm:12,"a.m.":0,"p.m.":12},month:{january:1,jan:1,february:2,feb:2,march:3,mar:3,april:4,apr:4,may:5,june:6,jun:6,july:7,jul:7,august:8,aug:8,september:9,sep:9,october:10,oct:10,november:11,nov:11,december:12,dec:12},dayname:{sunday:0,sun:0,monday:1,mon:1,tuesday:2,tue:2,wednesday:3,wed:3,thursday:4,thu:4,friday:5,fri:5,saturday:6,sat:6},digit:{}},wt={MONTHNAME:"january|february|march|april|may|june|july|august|september|october|november|december|jan\\.?|feb\\.?|mar\\.?|apr\\.?|may\\.?|jun\\.?|jul\\.?|aug\\.?|sep\\.?|oct\\.?|nov\\.?|dec\\.?",DAYNAME:"sunday|monday|tuesday|wednesday|thursday|friday|saturday|sun\\.?|mon\\.?|tue\\.?|wed\\.?|thu\\.?|fri\\.?|sat\\.?",ZONE:"\\(?(?:"+Object.keys(b7).join("|")+")\\)?",MERIDIEM:"am|pm|a.m.|p.m.",ORDINAL:"st|nd|rd|th|\\.",YEAR:"\\d{4}|\\d{2}",YEAR2:"\\d{2}",YEAR4:"\\d{4}",YEAR6:"-\\d{6}|\\+?\\d{5,6}",MONTH:"1[0-2]|0?[1-9]",MONTH2:"1[0-2]|0[1-9]",DAY:"3[01]|[12]\\d|0?[1-9]",DAY2:"3[01]|[12]\\d|0[1-9]",OFFSET:"(?:GMT)?[\xb1−+-](?:[01]\\d[0-5]\\d|[01]\\d:[0-5]\\d|[01]?\\d)",H24:"[01]\\d|2[0-3]",H12:"0?[1-9]|1[012]",MIN:"[0-5]\\d",SEC:"[0-5]\\d|60",MS:"\\d{9}|\\d{6}|\\d{1,3}",GAP:"[\\s/.,-]{1,}"},wr={...wt,YEAR:"*{4}|*{2}",YEAR4:"*{4}",YEAR6:"-*{6}|\\+?*{5,6}",MONTH:"*{1,2}",MONTH2:"*{2}",DAY:"*{1,2}",DAY2:"*{2}",OFFSET:"(?:GMT)?[\xb1−+-](?:*{4}|*{2}:*{2}|*{1,2})",H24:"*{2}",H12:"*{1,2}",MIN:"*{2}",SEC:"*{2}",MS:"*{9}|*{6}|*{3}"},wn={},wa=class e{locale;lookups;vars;numberingSystem;baseName;dateOptions;static factory(t=b4){return wn[t.toLowerCase()]||(wn[t.toLowerCase()]=new e(t)),wn[t.toLowerCase()]}constructor(e=b4){this.locale=e,this.lookups={...we},this.vars={...wt};let t=new Intl.NumberFormat(this.locale);this.numberingSystem=t.resolvedOptions().numberingSystem,this.dateOptions=new Intl.DateTimeFormat(this.locale).resolvedOptions(),this.baseName=new Intl.Locale(this.locale).baseName,this.build()}toInt(e){if("number"==typeof e)return e;if("string"!=typeof e)return;if("latn"===this.numberingSystem&&!this.baseName.startsWith("zh")){let t=parseInt(e,10);if(!isNaN(t))return t}let t="";for(let r=0;r<e.length;r++)t+=String(this.lookups.digit[e[r]]);return parseInt(t,10)}millisecondToInt(e){if("number"==typeof e)return e;if("string"!=typeof e)return;let t=e.slice(0,3);return 1===t.length?100*this.toInt(t):2===t.length?10*this.toInt(t):this.toInt(t)}monthNameToInt(e){if("string"!=typeof e)return;let t=e.toLocaleLowerCase(this.locale).replace(/\.$/,"");return this.lookups.month[t]||12}h12ToInt(e,t){if("string"!=typeof e)return;let r=this.lookups.meridiem[t?.toLowerCase()]||0,n=this.toInt(e);return n<12&&12===r&&(n+=12),12===n&&0===r&&(n=0),n}zoneToOffset(e){if("string"==typeof e)return e=e.replace(/[^a-z\s]/gi,""),this.lookups.zone[e]}offsetToMinutes(e){if("string"!=typeof e)return;let t=e.match(/^(?:GMT)?([±−+-])(..?):?(..)?$/);if(t){let[,e,r,n]=t;return("-"===e||"−"===e?-1:1)*(60*this.toInt(r)+this.toInt(n||0))}return 0}build(){"latn"===this.dateOptions.numberingSystem?this.lookups.digit=b9:this.buildNumbers(),/^en/i.test(this.locale)||(this.buildMonthNames(),this.buildDaynames(),/zh/i.test(this.locale)||this.buildMeridiems())}buildNumbers(){let{group:e,lookup:t}=function(e){if(b8[e])return b8[e];if("fullwide"===e||"hanidec"===e)return{group:b5,lookup:{...b9}};let t=b6[e];if(!t)return{group:"\\d",lookup:{...b9}};let r=String.fromCharCode(t),n=String.fromCharCode(t+9),a={};for(let e=0;e<10;e++)a[String.fromCharCode(t+e)]=e;return b8[e]={group:`[${r}-${n}]`,lookup:a},b8[e]}(this.numberingSystem);for(let r in this.lookups.digit=t,wr)wr.hasOwnProperty(r)&&(this.vars[r]=wr[r].replace(/\*/g,e))}buildMonthNames(){let e={},t={};if(/^fi/i.test(this.locale))"tammi|helmi|maalis|huhti|touko|kes\xe4|hein\xe4|elo|syys|loka|marras|joulu".split("|").forEach((r,n)=>{["","k","kuu","kuuta"].forEach((a,o)=>{e[r+a+(o<2?"\\.?":"")]=!0,t[r+a]=n+1})});else{let r=[],n=e=>"month"===e.type;for(let e=0;e<12;e++)r.push(new Date(2017,e,1));for(let a of["full","long","medium"]){let o=Intl.DateTimeFormat(this.locale,{dateStyle:a});for(let i=0;i<12;i++){let s=o.formatToParts(r[i]).find(n).value.toLocaleLowerCase(this.locale);/^\d+$/.test(s)||(/^ko/i.test(this.locale)&&(s+="월"),"medium"===a?(s=s.replace(/\.$/,""),e[`${s}\\.?`]=!0):e[s]=!0,t[s]=i+1)}}let a=Intl.DateTimeFormat(this.locale,{month:"short"});for(let o=0;o<12;o++){let i=a.formatToParts(r[o]).find(n).value.toLocaleLowerCase(this.locale);i=i.replace(/\.$/,""),e[`${i}\\.?`]=!0,t[i]=o+1}}this.vars.MONTHNAME=Object.keys(e).join("|"),this.lookups.month=t}buildDaynames(){let e=[],t=e=>"weekday"===e.type;for(let t=0;t<7;t++)e.push(new Date(2017,0,t+1));let r=[],n={};for(let a of["long","short"]){let o=Intl.DateTimeFormat(this.locale,{weekday:a});for(let i=0;i<7;i++){let s=o.formatToParts(e[i]).find(t).value.toLocaleLowerCase(this.locale);"short"===a?(s=s.replace(/\.$/,""),r.push(`${s}\\.?`)):r.push(s),n[s]=i}}this.vars.DAYNAME=r.join("|"),this.lookups.dayname=n}buildMeridiems(){let e=[new Date(2017,0,1),new Date(2017,0,1,23,0,0)],t=e=>"dayPeriod"===e.type,r=[],n={},a=Intl.DateTimeFormat(this.locale,{timeStyle:"long"});for(let o=0;o<2;o++){let i=a.formatToParts(e[o]).find(t);if(!i)return;let s=i.value.toLocaleLowerCase(this.locale);r.push(s),n[s]=12*o}this.vars.MERIDIEM=r.join("|"),this.lookups.meridiem=n}compile(e){return RegExp(e.replace(/_([A-Z0-9]+)_/g,(e,t)=>{if(!this.vars[t])throw Error(`Template string contains invalid variable _${t}_`);return this.vars[t]}),"i")}},wo=["ee-TG","en-AS","en-CA","en-FM","en-GH","en-GU","en-KE","en-KY","en-MH","en-MP","en-US","en-VI","en-WS","jp-JP","sm-AS","sm-SM"],wi={y:"year",M:"month",d:"day",w:"week",h:"hour",m:"minute",s:"second",ms:"millisecond"},ws=()=>new Date;function wl(e){return function(t){let r={};for(let n=0,a=e.length;n<a;n++){let a=e[n];a&&(r[a]=t[n])}return r}}var wu=class{doneChecker;fallback;patterns;formatter;constructor({doneChecker:e,fallback:t,patterns:r,formatter:n}){this.doneChecker=e,this.fallback=t,this.patterns=r,this.formatter=n}attempt(e){if("string"!=typeof e)return this.fallback(e);let t=e.trim(),r={},n=!1;for(let e of this.patterns){let a=t.match(e.regex);if(!a)continue;n=!0;let o=e.handler(a);if(o){for(let[e,t]of Object.entries(o))e in r||void 0===t||(r[e]=t);if(t=(t=t.slice(0,a.index)+t.slice(a.index+a[0].length+1)).trim(),this.doneChecker(r,t))break}}return n?this.formatter(r):this.fallback(e)}},wc=["year","month","day","hour","minute","second","millisecond","offset"],wd={};function wp(e,t){return""===t||/^\s+$/.test(t)||"year"in e&&("month"in e||"monthname"in e)&&"day"in e&&"hour"in e&&"minute"in e&&"second"in e&&"millisecond"in e&&("zone"in e||"offset"in e)}var wm=[[/([^\d.]+)(\d{1,2})\.(\d{2})\.(\d{2})(\D|$)/,"$1$2:$3:$4$5"],[/([^\d.]+)(\d{1,2})\.(\d{2})(\D|$)/,"$1$2:$3$4"]],wf={ar:[[/ /g," "]],bn:[[/,/g,""]],zh:[[/早上\s*([\d:]+)/,"$1am"],[/凌晨\s*([\d:]+)/,"$1am"],[/上午\s*([\d:]+)/,"$1am"],[/下午\s*([\d:]+)/,"$1pm"],[/晚上\s*([\d:]+)/,"$1pm"]],he:[[/ב/gi,""]],de:[[/ um /g," "]],pt:[[/\sde /gi," "]],es:[[/\sde /gi," "]],da:[[/\sden /gi," "],...wm],ru:[[/ г\./g,""]],th:[[/\s*นาฬิกา\s*/i,":"],[/\s*นาที\s*/i,":"],[/\s*วินาที\s*/i," "]],ko:[[/\s*시\s*/,":"],[/\s*분\s*/,":"],[/\s*초\s*/,""],[/(오전|오후)\s*([\d:]+)/,"$2$1"],[/(\d{4})\. (\d{1,2})\. (\d{1,2})\./,"$1-$2-$3"]],fi:wm,id:wm,fr:[[/(\d{2}) h /,"$1:"],[/(\d{2}) min /,"$1:"],[/(\d{2}) s /,"$1"]]};function wh(e,t=b4){let r=function(e){if(!wd[e]){var t,r;let n,a,o=wa.factory(e);wd[e]=new wu({doneChecker:wp,fallback:(t=e,function(e){let r=String(e).slice(0,50);return""===r&&(r="(empty string)"),{invalid:`Unable to parse "${r}" with locale "${t}"`}}),patterns:(n=[{name:"timestampWithOffset",regex:o.compile("^(_YEAR4_)-(_MONTH_)-(_DAY_)[T ](_H24_):(_MIN_):(_SEC_)(?:.(_MS_))? ?(_OFFSET_|Z)?$"),handler:wl(["","year","month","day","hour","minute","second","millisecond","offset"])},{name:"timestampWithZone",regex:o.compile("^(_YEAR4_)-(_MONTH_)-(_DAY_)[T ](_H24_):(_MIN_):(_SEC_)(?:.(_MS_))?\\s*(_ZONE_)$"),handler:wl(["","year","month","day","hour","minute","second","millisecond","zone"])},{name:"timestampWithOffsetAndZone",regex:o.compile("^(_YEAR4_)-(_MONTH_)-(_DAY_)[T ](_H24_):(_MIN_):(_SEC_)(?:.(_MS_))? (_OFFSET_|Z)\\s*(_ZONE_)$"),handler:wl(["","year","month","day","hour","minute","second","millisecond","offset"])},{name:"chinese",regex:o.compile(`^(${b5}{2,4})\\s*\u5E74\\s*(${b5}{1,2})\\s*\u6708\\s*(${b5}{1,2})\\s*\u65E5$`),handler:wl(["","year","month","day"])},{name:"korean",regex:o.compile("^(_YEAR_)년\\s*(_MONTH_)월\\s*(_DAY_)일$"),handler:wl(["","year","month","day"])},{name:"twitter",regex:/^(?:sun|mon|tue|wed|thu|fri|sat) (jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec) (\d{2}) (\d{2}):(\d{2}):(\d{2}) ([+-]\d{4}) (\d{4})$/i,handler:wl(["","monthname","day","hour","minute","second","offset","year"])},{name:"today",regex:/^(now|today|tomorrow|yesterday)$/i,handler:function(e){let t=ws(),r=e[1].toLowerCase();switch(r){case"tomorrow":t.setUTCDate(t.getUTCDate()+1);break;case"yesterday":t.setUTCDate(t.getUTCDate()-1)}let n={year:t.getUTCFullYear(),month:t.getUTCMonth()+1,day:t.getUTCDate()};return"now"===r&&(n.hour=t.getUTCHours(),n.minute=t.getUTCMinutes(),n.second=t.getUTCSeconds(),n.millisecond=t.getUTCMilliseconds()),console.log("today=>",r,n),n}},{name:"ago",regex:/^(\+|-|in|) ?([\d.]+) ?(years?|months?|weeks?|days?|hours?|minutes?|seconds?|milliseconds?|ms|s|m|h|w|d|M|y)( ago)?$/i,handler:function([,e,t,r,n]){t=parseFloat(t),"week"===(r=r.length<=2?wi[r]:(r=r.replace(/s$/,"")).toLowerCase())&&(r="day",t*=7),("-"===e||n)&&(t*=-1);let a=ws();return"millisecond"===r?a.setUTCMilliseconds(a.getUTCMilliseconds()+t):"second"===r?a.setUTCSeconds(a.getUTCSeconds()+t):"minute"===r?a.setUTCMinutes(a.getUTCMinutes()+t):"hour"===r?a.setUTCHours(a.getUTCHours()+t):"day"===r?a.setUTCDate(a.getUTCDate()+t):"month"===r?a.setUTCMonth(a.getUTCMonth()+t):"year"===r&&a.setUTCFullYear(a.getUTCFullYear()+t),{year:a.getUTCFullYear(),month:a.getUTCMonth()+1,day:a.getUTCDate(),hour:a.getUTCHours(),minute:a.getUTCMinutes(),second:a.getUTCSeconds(),millisecond:a.getUTCMilliseconds()}}},{name:"atSeconds",regex:/^@(\d+)$/,handler:function(e){let t=new Date(1e3*parseInt(e[1],10));return{year:t.getUTCFullYear(),month:t.getUTCMonth()+1,day:t.getUTCDate(),hour:t.getUTCHours(),minute:t.getUTCMinutes(),second:t.getUTCSeconds()}}},{name:"microsoftJson",regex:/^\/Date\((\d+)([+-]\d{4})?\)\/$/,handler:function(e){let t=new Date(parseInt(e[1],10));return{year:t.getUTCFullYear(),month:t.getUTCMonth()+1,day:t.getUTCDate(),hour:t.getUTCHours(),minute:t.getUTCMinutes(),second:t.getUTCSeconds(),millisecond:t.getUTCMilliseconds(),offset:e[2]}}},{name:"full24",regex:o.compile("(?:^|[\\sT])(_H24_):(_MIN_):(_SEC_)(?:\\.(_MS_))?(Z)?$"),handler:wl(["","hour","minute","second","millisecond","zone"])},{name:"zone24",regex:o.compile("(_H24_):(_MIN_):(_SEC_)(?:\\.(_MS_))?[\\s\\[(]*(_ZONE_)?[\\s\\])]*$"),handler:wl(["","hour","minute","second","millisecond","zone"])},{name:"hms12",regex:o.compile("(_H12_):(_MIN_):(_SEC_)\\s*(_MERIDIEM_)"),handler:wl(["","hour","minute","second","meridiem"])},{name:"hms24",regex:o.compile("(_H24_):(_MIN_):(_SEC_)(?:\\.(_MS_))?"),handler:wl(["","hour","minute","second","millisecond"])},{name:"hm12",regex:o.compile("(_H12_):(_MIN_)\\s*(_MERIDIEM_)"),handler:wl(["","hour","minute","meridiem"])},{name:"hm24",regex:o.compile("(_H24_):(_MIN_)"),handler:wl(["","hour","minute"])},{name:"h12",regex:o.compile("(_H12_)\\s*(_MERIDIEM_)"),handler:wl(["","hour","meridiem"])},{name:"8digit",regex:/^((?:19|20)\d{2})(\d{2})(\d{2})$/,handler:wl(["","year","month","day"])},{name:"yearMonthnameDay",regex:o.compile("(_YEAR4_)[\\s.-]+(_MONTHNAME_)[\\s,.-]+(_DAY_)(_ORDINAL_)?"),handler:wl(["","year","monthname","day"])},{name:"dayMonthnameYear",regex:o.compile("(_DAY_)(_ORDINAL_)?[\\s.-]*(_MONTHNAME_)[\\s,.-]+(_YEAR_)"),handler:wl(["","day","","monthname","year"])},{name:"monthnameDayYear",regex:o.compile("(_MONTHNAME_)[\\s.-]*(_DAY_)(_ORDINAL_)?[\\s,.-]+(_YEAR_)"),handler:wl(["","monthname","day","","year"])},{name:"dayMonthname",regex:o.compile("\\b(_DAY_)(_ORDINAL_)?[\\s.-]*(_MONTHNAME_)\\b"),handler:wl(["","day","","monthname"])},{name:"monthnameDay",regex:o.compile("\\b(_MONTHNAME_)[\\s.-]*(_DAY_)(_ORDINAL_)?\\b"),handler:wl(["","monthname","day"])},{name:"hmsNoMeridiem",regex:o.compile("\\b(_H12_|_H24_):(_MIN_):(_SEC_)\\b"),handler:wl(["","hour","minute","second"])},{name:"hmNoMeridiem",regex:o.compile("\\b(_H12_|_H24_):(_MIN_)\\b"),handler:wl(["","hour","minute"])},{name:"ymd",regex:o.compile("(_YEAR4_)([.-])(_MONTH_)\\2+(_DAY_)"),handler:wl(["","year","","month","day"])},{name:"mdy",regex:o.compile("(_MONTH_)([/-])(_DAY_)\\2(_YEAR_)"),handler:wl(["","month","","day","year"])},{name:"dmy",regex:o.compile("(_DAY_)(?:_ORDINAL_)?[./\\s-]+(_MONTH_)[./\\s-]+(_YEAR_)"),handler:wl(["","day","month","year"])},{name:"yearLoose",regex:o.compile("_YEAR4_"),handler:wl(["year"])},{name:"dayMonthnameLoose",regex:o.compile("(_DAY_)[\\s.]*(_MONTHNAME_)"),handler:wl(["","day","monthname"])},{name:"monthnameDayLoose",regex:o.compile("(_MONTHNAME_)[\\s.]*(_DAY_)"),handler:wl(["","monthname","day"])},{name:"monthname",regex:o.compile("_MONTHNAME_"),handler:wl(["monthname"])},{name:"year4",regex:o.compile("_YEAR4_"),handler:wl(["year"])},{name:"md",regex:o.compile("(_MONTH_)[/-](_DAY_)"),handler:wl(["","month","day"])},{name:"dm",regex:o.compile("(_DAY_)(?:_ORDINAL_)?[./\\s-]+(_MONTH_)"),handler:wl(["","day","month"])},{name:"day",regex:o.compile("_DAY_"),handler:wl(["day"])},{name:"year2",regex:o.compile("_YEAR2_"),handler:wl(["year"])},{name:"onlyZone",regex:o.compile("_ZONE_"),handler:wl(["zone"])}],a=o.baseName.slice(0,5),wo.includes(a)?n:n.filter(e=>!["mdy","md"].includes(e.name))),formatter:(r=o,function(e){let t={};for(let[n,a]of Object.entries(e))if("monthname"===n){if(a){let e=r.monthNameToInt(a);void 0!==e&&(t.month=e)}}else if("hour"===n&&e.meridiem){let n=r.h12ToInt(a,e.meridiem);void 0!==n&&(t.hour=n)}else if("zone"===n){if(a){let e=r.zoneToOffset(a);void 0!==e&&(t.offset=e)}}else if("offset"===n){let e=r.offsetToMinutes(a);void 0!==e&&(t.offset=e)}else if("millisecond"===n){let e=r.millisecondToInt(a);"number"==typeof e&&(t.millisecond=e)}else if(wc.includes(n)){let e=r.toInt(a);"number"==typeof e&&(t[n]=e)}return t.year<100&&(t.year=b3[t.year]),t.year&&"buddhist"===r.dateOptions.calendar&&(t.year-=543),t})})}return wd[e]}(t),n=function(e,t){let r=wf[t.slice(0,2).toLowerCase()];if(!r)return e;for(let[t,n]of r)e=e.replace(t,n);return e}(e,t);return r.attempt(n)}function wg(e){e.month&&e.day&&void 0===e.year&&(e.year=new Date().getFullYear()),60===e.second&&(e.second=59);let t=new b2(e.year,e.month-1,e.day,e.hour||0,e.minute||0,e.second||0,e.millisecond||0);return"number"==typeof e.offset?new b2(t.valueOf()-60*e.offset*1e3):t}function wy(e,t=b4){let r=wh(e,t),n=r.invalid?new b2(NaN):wg(r);return n.isValid()||(n.invalid=`Unable to parse date "${e}"`),n}function wv(e,t=b4){return e instanceof Date?new b2(e.valueOf()):"number"==typeof e?new b2(e):wy(e,t)}Date.fromString=b2.fromString=wy,Date.fromAny=b2.fromAny=wv,"u">typeof window&&(window.anyDateParser={fromString:wy,fromAny:wv,fromObject:wg,attempt:wh});var wb=r(4397),ww=r(7657);let wE=function(e){return null==e};function wx(e,t){var r=function(e,t){if(!t.has(e))throw TypeError("attempted to get private field on non-instance");return t.get(e)}(e,t);return r.get?r.get.call(e):r.value}cf().extend(ch),cf().extend(ww),cf().extend(wb);let wD="YYYY-MM-DDTHH:mm:ss.SSSZZ",wS=/^(\d{4})(?:-(\d{2})(?:-(\d{2}))?)?$/;function w_(e,t){let r=wS.exec(e);if(!r)return wh(e,t);let n=Number(r[1]),a=void 0===r[2]?void 0:Number(r[2]),o=void 0===r[3]?void 0:Number(r[3]),i=new Date(0);return(i.setUTCFullYear(n,(a??1)-1,o??1),i.getUTCFullYear()!==n||i.getUTCMonth()!==(a??1)-1||i.getUTCDate()!==(o??1))?{invalid:`Invalid ISO calendar date '${e}'`}:{year:n,...void 0!==a&&{month:a},...void 0!==o&&{day:o}}}function wC(e){return null!=e&&28===e.trim().length&&"T"===(e=e.trim())[10]&&":"===e[13]&&":"===e[16]&&"."===e[19]&&("+"===e[23]||"-"===e[23])&&cf()(e,wD).isValid()}function wk(e){return cf()(e).isToday()}function wP(e){return wC(e)?cf()(e,wD).toDate():null}function wR(e,t=!1){let r=cf()(e);return t&&(r=r.utc()),r.format(wD)}function wT(e){return cf()(e).toDate()}var wO=new WeakMap;let w$=new class{register(e,t){wx(this,wO).set(e,t)}getCalendar(e){if(!e)return;if(e.calendar)return e.calendar;if(e.region){let t=`${e.language}-${e.region}`;if(wx(this,wO).has(t))return wx(this,wO).get(t)}if(e.language&&wx(this,wO).has(e.language))return wx(this,wO).get(e.language);let t=new Intl.DateTimeFormat(e.toString()).resolvedOptions().calendar;return wx(this,wO).set(`${e.language}${e.region?`-${e.region}`:""}`,t),t}constructor(){!function(e,t,r){if(t.has(e))throw TypeError("Cannot initialize the same private elements twice on an object");t.set(e,r)}(this,wO,{writable:!0,value:new Map})}};function wN(e,t){w$.register(e,t)}function wI(e){let t=e??b1();return w$.getCalendar(t instanceof Intl.Locale?t:new Intl.Locale(t))}let wA={mode:"standard",time:"for today",day:!0,month:!0,year:!0,noToday:!1};function wM(e,t={}){let r=w_(e,b1());if(r.invalid)return console.warn(`Could not parse invalid date '${e}'`),null;!wE(r.day)&&wE(r.month)&&(r=Object.assign({},tU(r,"day"),{month:r.day})),r.month&&(r.month-=1),r.day&&(r=Object.assign({},tU(r,"day"),{date:r.day}));let n=cf()().set(r).toDate();return wE(r.year)&&(t.year=!1),wE(r.month)&&(t.month=!1),wE(r.date)&&(t.day=!1),wj(n,t)}function wj(e,t){let r,n=t?.locale??b1(),a=new Intl.Locale(n),{calendar:o,mode:i,time:s,day:l,month:u,year:c,noToday:d,numberingSystem:p}={...wA,...{noToday:"am"===a.language},...t},m={calendar:o??wI(a),year:c?"numeric":void 0,month:u?"short":void 0,day:l?"2-digit":void 0,numberingSystem:p},f=cf()(e).isToday();if(f&&!d)r=(r=new Intl.RelativeTimeFormat(n,{numeric:"auto"}).format(0,"day"))[0].toLocaleUpperCase(n)+r.slice(1);else{"en"===a.language&&(n="en-GB");let t=new Intl.DateTimeFormat(n,m).formatToParts(e);("en"===a.language||"am"===a.language)&&"standard"==i&&c&&l&&(t=t.map(wL("-"))),"wide"==i&&(t=t.map(wL(" — "))),"ethiopic"===m.calendar&&(t=t.filter((e,t,r)=>"era"!==e.type&&("literal"!==e.type||!(t<r.length-1)||"era"!==r[t+1].type))),r=t.map(e=>e.value).join("")}return(!0===s||f&&"for today"===s)&&(r+=`, ${wF(e)}`),r}let wL=e=>(t,r,n)=>"literal"!==t.type||" "!==t.value||r<n.length-1&&"era"===n[r+1].type?t:{type:"literal",value:e};function wF(e){return e.toLocaleTimeString(b1(),{hour:"2-digit",minute:"2-digit"})}function wB(e,t){return wj(e,{...t,time:!0})}function wV(e,t){let r=wI("string"==typeof t?new Intl.Locale(t):t);return r?hZ(e,yt(r)):e}function wU(e,t){return new Intl.DurationFormat(b1(),t).format(e)}function wW(e,t){if(null==e)return null;if("string"==typeof e){let r=w_(e,b1());return r.invalid?(console.warn(`Could not interpret '${e}' as a date`),null):(r.day&&!r.month&&(r={...tU(r,"day"),...{month:r.day}}),r.month&&(r.month-=1),r.day&&(r={...tU(r,"day"),...{date:r.day}}),cf()(t).set(r))}return cf()(e)}let wH=["years","months","days","hours","minutes","seconds"],wz={second:"seconds",minute:"minutes",hour:"hours",day:"days",month:"months",year:"years"},wK={seconds:45,minutes:45,hours:22,days:26,months:11,years:1/0};function wG(e,t=cf()(),r){let n,a=cf()(t),o=wW(e,a);if(null==o)return null;if("string"==typeof r){let e=wz[r]??r;return{[e]:a.diff(o,e)}}let{thresholds:i,largestUnit:s,smallestUnit:l}=r??{};if(void 0!==s||void 0!==l){let e,t=l?wz[l]??l:void 0;return e="auto"===s||void 0===s?function(e,t,r){let n=wH.indexOf(r);for(let a=0;a<wH.length;a++){let o=wH[a];if(t.diff(e,o)>0)return a<=n?o:r}return r}(o,a,t??"seconds"):wz[s]??s,function(e,t,r,n){let a=wH.indexOf(r),o=wH.indexOf(n),i=wH.slice(a,o+1),s={},l=e;for(let e of i){let r=t.diff(l,e);s[e]=r,l=l.add(r,e)}return s}(o,a,e,t??e)}let u=(n=function(e){let t={...wK};if(e)for(let[r,n]of Object.entries(e))void 0!==n&&(t[wz[r]??r]=n);return t}(i),a.diff(o,"seconds")<n.seconds?"seconds":a.diff(o,"minutes")<n.minutes?"minutes":a.diff(o,"hours")<n.hours?"hours":a.diff(o,"days")<n.days?"days":a.diff(o,"months")<n.months?"months":"years");return{[u]:a.diff(o,u)}}let wZ={style:"short",localeMatcher:"lookup"};function wY(e,t=cf()(),r){let n=wG(e,t,r);return null==n?null:wU(n,"object"==typeof r&&r.formatOptions?{...wZ,...r.formatOptions}:wZ)}let wq=(0,lT.createContext)(null);function wJ(){let e=u$({externalModuleName:"@openmrs/esm-styleguide"}).preferredDateLocale,t=(0,lT.useMemo)(()=>{let t=b1();return e[t]&&(t=e[t]),t},[window.i18next.language]),r=(0,lT.useMemo)(()=>{let e=wI(t);return void 0!==e?yt(e):void 0},[t]),n=(0,lT.useMemo)(()=>new Intl.Locale(t,{calendar:r?.identifier}),[t,r]),a=(0,lT.useMemo)(()=>r?hZ(h4(h5()),r):h4(h5()),[r]);return{calendar:r,intlLocale:n,today_:a}}let wX=new hI(1793,1,1);var wQ={};function w0(){return"u">typeof window&&window.InputEvent&&"function"==typeof InputEvent.prototype.getTargetRanges}function w1(e={}){let{locale:t}=fZ();return(0,lT.useMemo)(()=>new(0,vD.K)(t,e),[t,e])}wQ={"ar-AE":{decrease:e=>`\u{62E}\u{641}\u{636} ${e.fieldLabel}`,increase:e=>`\u{632}\u{64A}\u{627}\u{62F}\u{629} ${e.fieldLabel}`,numberField:"حقل رقمي"},"bg-BG":{decrease:e=>`\u{41D}\u{430}\u{43C}\u{430}\u{43B}\u{44F}\u{432}\u{430}\u{43D}\u{435} ${e.fieldLabel}`,increase:e=>`\u{423}\u{441}\u{438}\u{43B}\u{432}\u{430}\u{43D}\u{435} ${e.fieldLabel}`,numberField:"Номер на полето"},"cs-CZ":{decrease:e=>`Sn\xed\u{17E}it ${e.fieldLabel}`,increase:e=>`Zv\xfd\u{161}it ${e.fieldLabel}`,numberField:"Č\xedseln\xe9 pole"},"da-DK":{decrease:e=>`Reducer ${e.fieldLabel}`,increase:e=>`\xd8g ${e.fieldLabel}`,numberField:"Talfelt"},"de-DE":{decrease:e=>`${e.fieldLabel} verringern`,increase:e=>`${e.fieldLabel} erh\xf6hen`,numberField:"Nummernfeld"},"el-GR":{decrease:e=>`\u{39C}\u{3B5}\u{3AF}\u{3C9}\u{3C3}\u{3B7} ${e.fieldLabel}`,increase:e=>`\u{391}\u{3CD}\u{3BE}\u{3B7}\u{3C3}\u{3B7} ${e.fieldLabel}`,numberField:"Πεδίο αριθμού"},"en-US":{decrease:e=>`Decrease ${e.fieldLabel}`,increase:e=>`Increase ${e.fieldLabel}`,numberField:"Number field"},"es-ES":{decrease:e=>`Reducir ${e.fieldLabel}`,increase:e=>`Aumentar ${e.fieldLabel}`,numberField:"Campo de n\xfamero"},"et-EE":{decrease:e=>`V\xe4henda ${e.fieldLabel}`,increase:e=>`Suurenda ${e.fieldLabel}`,numberField:"Numbri v\xe4li"},"fi-FI":{decrease:e=>`V\xe4henn\xe4 ${e.fieldLabel}`,increase:e=>`Lis\xe4\xe4 ${e.fieldLabel}`,numberField:"Numerokentt\xe4"},"fr-FR":{decrease:e=>`Diminuer ${e.fieldLabel}`,increase:e=>`Augmenter ${e.fieldLabel}`,numberField:"Champ de nombre"},"he-IL":{decrease:e=>`\u{5D4}\u{5E7}\u{5D8}\u{5DF} ${e.fieldLabel}`,increase:e=>`\u{5D4}\u{5D2}\u{5D3}\u{5DC} ${e.fieldLabel}`,numberField:"שדה מספר"},"hr-HR":{decrease:e=>`Smanji ${e.fieldLabel}`,increase:e=>`Pove\u{107}aj ${e.fieldLabel}`,numberField:"Polje broja"},"hu-HU":{decrease:e=>`${e.fieldLabel} cs\xf6kkent\xe9se`,increase:e=>`${e.fieldLabel} n\xf6vel\xe9se`,numberField:"Sz\xe1mmező"},"it-IT":{decrease:e=>`Riduci ${e.fieldLabel}`,increase:e=>`Aumenta ${e.fieldLabel}`,numberField:"Campo numero"},"ja-JP":{decrease:e=>`${e.fieldLabel}\u{3092}\u{7E2E}\u{5C0F}`,increase:e=>`${e.fieldLabel}\u{3092}\u{62E1}\u{5927}`,numberField:"数値フィールド"},"ko-KR":{decrease:e=>`${e.fieldLabel} \u{AC10}\u{C18C}`,increase:e=>`${e.fieldLabel} \u{C99D}\u{AC00}`,numberField:"번호 필드"},"lt-LT":{decrease:e=>`Suma\u{17E}inti ${e.fieldLabel}`,increase:e=>`Padidinti ${e.fieldLabel}`,numberField:"Numerio laukas"},"lv-LV":{decrease:e=>`Samazin\u{101}\u{161}ana ${e.fieldLabel}`,increase:e=>`Palielin\u{101}\u{161}ana ${e.fieldLabel}`,numberField:"Skaitļu lauks"},"nb-NO":{decrease:e=>`Reduser ${e.fieldLabel}`,increase:e=>`\xd8k ${e.fieldLabel}`,numberField:"Tallfelt"},"nl-NL":{decrease:e=>`${e.fieldLabel} verlagen`,increase:e=>`${e.fieldLabel} verhogen`,numberField:"Getalveld"},"pl-PL":{decrease:e=>`Zmniejsz ${e.fieldLabel}`,increase:e=>`Zwi\u{119}ksz ${e.fieldLabel}`,numberField:"Pole numeru"},"pt-BR":{decrease:e=>`Diminuir ${e.fieldLabel}`,increase:e=>`Aumentar ${e.fieldLabel}`,numberField:"Campo de n\xfamero"},"pt-PT":{decrease:e=>`Diminuir ${e.fieldLabel}`,increase:e=>`Aumentar ${e.fieldLabel}`,numberField:"Campo num\xe9rico"},"ro-RO":{decrease:e=>`Sc\u{103}dere ${e.fieldLabel}`,increase:e=>`Cre\u{219}tere ${e.fieldLabel}`,numberField:"C\xe2mp numeric"},"ru-RU":{decrease:e=>`\u{423}\u{43C}\u{435}\u{43D}\u{44C}\u{448}\u{435}\u{43D}\u{438}\u{435} ${e.fieldLabel}`,increase:e=>`\u{423}\u{432}\u{435}\u{43B}\u{438}\u{447}\u{435}\u{43D}\u{438}\u{435} ${e.fieldLabel}`,numberField:"Числовое поле"},"sk-SK":{decrease:e=>`Zn\xed\u{17E}i\u{165} ${e.fieldLabel}`,increase:e=>`Zv\xfd\u{161}i\u{165} ${e.fieldLabel}`,numberField:"Č\xedseln\xe9 pole"},"sl-SI":{decrease:e=>`Upadati ${e.fieldLabel}`,increase:e=>`Pove\u{10D}ajte ${e.fieldLabel}`,numberField:"Številčno polje"},"sr-SP":{decrease:e=>`Smanji ${e.fieldLabel}`,increase:e=>`Pove\u{107}aj ${e.fieldLabel}`,numberField:"Polje broja"},"sv-SE":{decrease:e=>`Minska ${e.fieldLabel}`,increase:e=>`\xd6ka ${e.fieldLabel}`,numberField:"Nummerf\xe4lt"},"tr-TR":{decrease:e=>`${e.fieldLabel} azalt`,increase:e=>`${e.fieldLabel} artt\u{131}r`,numberField:"Sayı alanı"},"uk-UA":{decrease:e=>`\u{417}\u{43C}\u{435}\u{43D}\u{448}\u{438}\u{442}\u{438} ${e.fieldLabel}`,increase:e=>`\u{417}\u{431}\u{456}\u{43B}\u{44C}\u{448}\u{438}\u{442}\u{438} ${e.fieldLabel}`,numberField:"Поле номера"},"zh-CN":{decrease:e=>`\u{964D}\u{4F4E} ${e.fieldLabel}`,increase:e=>`\u{63D0}\u{9AD8} ${e.fieldLabel}`,numberField:"数字字段"},"zh-TW":{decrease:e=>`\u{7E2E}\u{5C0F} ${e.fieldLabel}`,increase:e=>`\u{653E}\u{5927} ${e.fieldLabel}`,numberField:"數字欄位"}};var w4={};w4={"ar-AE":{Empty:"فارغ"},"bg-BG":{Empty:"Изпразни"},"cs-CZ":{Empty:"Pr\xe1zdn\xe9"},"da-DK":{Empty:"Tom"},"de-DE":{Empty:"Leer"},"el-GR":{Empty:"Άδειο"},"en-US":{Empty:"Empty"},"es-ES":{Empty:"Vac\xedo"},"et-EE":{Empty:"T\xfchjenda"},"fi-FI":{Empty:"Tyhj\xe4"},"fr-FR":{Empty:"Vide"},"he-IL":{Empty:"ריק"},"hr-HR":{Empty:"Prazno"},"hu-HU":{Empty:"\xdcres"},"it-IT":{Empty:"Vuoto"},"ja-JP":{Empty:"空"},"ko-KR":{Empty:"비어 있음"},"lt-LT":{Empty:"Tuščias"},"lv-LV":{Empty:"Tukšs"},"nb-NO":{Empty:"Tom"},"nl-NL":{Empty:"Leeg"},"pl-PL":{Empty:"Pusty"},"pt-BR":{Empty:"Vazio"},"pt-PT":{Empty:"Vazio"},"ro-RO":{Empty:"Gol"},"ru-RU":{Empty:"Не заполнено"},"sk-SK":{Empty:"Pr\xe1zdne"},"sl-SI":{Empty:"Prazen"},"sr-SP":{Empty:"Prazno"},"sv-SE":{Empty:"Tomt"},"tr-TR":{Empty:"Boş"},"uk-UA":{Empty:"Пусто"},"zh-CN":{Empty:"空"},"zh-TW":{Empty:"空白"}};let w2=()=>{};function w3(e){var t;let r=(0,lT.useRef)(void 0),{value:n,textValue:a,minValue:o,maxValue:i,isDisabled:s,isReadOnly:l,isRequired:u,onIncrement:c,onIncrementPage:d,onDecrement:p,onDecrementPage:m,onDecrementToMin:f,onIncrementToMax:h}=e,g=hi((t=w4)&&t.__esModule?t.default:t,"@react-aria/spinbutton"),y=(0,lT.useRef)(!1),v=(0,lT.useCallback)(()=>{clearTimeout(r.current),y.current=!1},[]),b=fo(()=>{v()});(0,lT.useEffect)(()=>()=>b(),[]);let w=(0,lT.useRef)(!1),E=()=>{w.current=!0},x=()=>{w.current=!1},D=""===a?g.format("Empty"):(a||`${n}`).replace("-","−");(0,lT.useEffect)(()=>{w.current&&(fY&&fY.clear("assertive"),fq(D,"assertive"))},[D]);let S=(0,lT.useCallback)(()=>{v()},[v]),_=fo(c??w2),C=fo(p??w2),k=fo(()=>{(void 0===i||isNaN(i)||void 0===n||isNaN(n)||n<i)&&(_(),P(60))}),P=fo(e=>{b(),y.current=!0,r.current=window.setTimeout(k,e)}),R=fo(()=>{(void 0===o||isNaN(o)||void 0===n||isNaN(n)||n>o)&&(C(),T(60))}),T=fo(e=>{b(),y.current=!0,r.current=window.setTimeout(R,e)}),O=e=>{e.preventDefault()},{addGlobalListener:$,removeAllGlobalListeners:N}=fi(),I=(0,lT.useRef)(!1),[A,M]=(0,lT.useState)(null);(0,lT.useEffect)(()=>{"touch"===A?P(600):A&&P(400)},[A]);let[j,L]=(0,lT.useState)(null);return(0,lT.useEffect)(()=>{"touch"===j?T(600):j&&T(400)},[j]),{spinButtonProps:{role:"spinbutton","aria-valuenow":void 0===n||isNaN(n)?void 0:n,"aria-valuetext":D,"aria-valuemin":o,"aria-valuemax":i,"aria-disabled":s||void 0,"aria-readonly":l||void 0,"aria-required":u||void 0,onKeyDown:e=>{if(!e.ctrlKey&&!e.metaKey&&!e.shiftKey&&!e.altKey&&!l&&!e.nativeEvent.isComposing)switch(e.key){case"PageUp":if(d){e.preventDefault(),d?.();break}case"ArrowUp":case"Up":c&&(e.preventDefault(),c?.());break;case"PageDown":if(m){e.preventDefault(),m?.();break}case"ArrowDown":case"Down":p&&(e.preventDefault(),p?.());break;case"Home":f&&(e.preventDefault(),f?.());break;case"End":h&&(e.preventDefault(),h?.())}},onFocus:E,onBlur:x},incrementButtonProps:{onPressStart:e=>{v(),"touch"!==e.pointerType?(c?.(),M("mouse")):($(window,"pointercancel",S,{capture:!0}),I.current=!1,M("touch")),$(window,"contextmenu",O)},onPressUp:e=>{v(),"touch"===e.pointerType&&(I.current=!0),N(),M(null)},onPressEnd:e=>{v(),"touch"===e.pointerType&&!y.current&&I.current&&c?.(),I.current=!1,M(null)},onFocus:E,onBlur:x},decrementButtonProps:{onPressStart:e=>{v(),"touch"!==e.pointerType?(p?.(),L("mouse")):($(window,"pointercancel",S,{capture:!0}),I.current=!1,L("touch"))},onPressUp:e=>{v(),"touch"===e.pointerType&&(I.current=!0),N(),L(null)},onPressEnd:e=>{v(),"touch"===e.pointerType&&!y.current&&I.current&&p?.(),I.current=!1,L(null)},onFocus:E,onBlur:x}}}let w6=null;var w5=r(2103);function w9(e,t,r){let n="+"===e?t+r:t-r;if(t%1!=0||r%1!=0){let a=t.toString().split("."),o=r.toString().split("."),i=Math.pow(10,Math.max(a[1]&&a[1].length||0,o[1]&&o[1].length||0));t=Math.round(t*i),r=Math.round(r*i),n=("+"===e?t+r:t-r)/i}return n}let w8=(0,lT.createContext)(null),w7=(0,lT.createContext)(null),Ee=(0,lT.forwardRef)(function(e,t){var r,n;[e,t]=pX(e,t,w8);let{validationBehavior:a}=pJ(vz)||{},o=null!=(n=null!=(r=e.validationBehavior)?r:a)?n:"native",{locale:i}=fZ(),s=function(e){let{minValue:t,maxValue:r,step:n,formatOptions:a,value:o,defaultValue:i=NaN,onChange:s,locale:l,isDisabled:u,isReadOnly:c,commitBehavior:d="snap"}=e;null===o&&(o=NaN);let p=(0,lT.useCallback)(e=>void 0===n||isNaN(n)?vX(e,t,r):v0(e,t,r,n),[n,t,r]);void 0===o||isNaN(o)||"snap"!==d||(o=p(o)),isNaN(i)||"snap"!==d||(i=p(i));let[m,f]=yc(o,isNaN(i)?NaN:i,s),[h]=(0,lT.useState)(m),[g,y]=(0,lT.useState)(()=>isNaN(m)?"":new(0,vD.K)(l,a).format(m)),v=(0,lT.useMemo)(()=>new(0,w5.d)(l,a),[l,a]),b=(0,lT.useMemo)(()=>v.getNumberingSystem(g),[v,g]),w=(0,lT.useMemo)(()=>new(0,vD.K)(l,{...a,numberingSystem:b}),[l,a,b]),E=(0,lT.useMemo)(()=>w.resolvedOptions(),[w]),x=(0,lT.useCallback)(e=>isNaN(e)||null===e?"":w.format(e),[w]),D=vo({...e,value:m}),S=void 0===n||isNaN(n)?1:n;"percent"===E.style&&(void 0===n||isNaN(n))&&(S=.01);let[_,C]=(0,lT.useState)(m),[k,P]=(0,lT.useState)(l),[R,T]=(0,lT.useState)(a);Object.is(m,_)&&l===k&&a===R||(y(x(m)),C(m),P(l),T(a));let O=(0,lT.useMemo)(()=>v.parse(g),[v,g]),$=(e,n=0)=>{if(isNaN(O))return v0(isNaN(n)?0:n,t,r,S);{let n=v0(O,t,r,S);return"+"===e&&n>O||"-"===e&&n<O?n:v0(w9(e,O,S),t,r,S)}},N=(0,lT.useMemo)(()=>!u&&!c&&(isNaN(O)||void 0===r||isNaN(r)||v0(O,t,r,S)>O||w9("+",O,S)<=r),[u,c,t,r,S,O]),I=(0,lT.useMemo)(()=>!u&&!c&&(isNaN(O)||void 0===t||isNaN(t)||v0(O,t,r,S)<O||w9("-",O,S)>=t),[u,c,t,r,S,O]);return{...D,validate:e=>v.isValidPartialNumber(e,t,r),increment:()=>{let e=$("+",t);e===m&&y(x(e)),f(e),D.commitValidation()},incrementToMax:()=>{null!=r&&(f(v0(r,t,r,S)),D.commitValidation())},decrement:()=>{let e=$("-",r);e===m&&y(x(e)),f(e),D.commitValidation()},decrementToMin:()=>{null!=t&&(f(t),D.commitValidation())},canIncrement:N,canDecrement:I,minValue:t,maxValue:r,numberValue:O,defaultNumberValue:isNaN(i)?h:i,setNumberValue:f,setInputValue:y,inputValue:g,commit:e=>{let t=void 0===e?g:e,r=O;if(void 0!==e&&(r=v.parse(t)),!t.length){f(NaN),y(void 0===o?"":x(m));return}if(isNaN(r))return void y(x(m));let n="snap"===d?p(r):r,a=(n=v.parse(x(n)))!==m;f(n),y(x(void 0===o?n:m)),a&&D.commitValidation()}}}({...e,locale:i,validationBehavior:o}),l=(0,lT.useRef)(null),[u,c]=pQ(!e["aria-label"]&&!e["aria-labelledby"]),{labelProps:d,groupProps:p,inputProps:m,incrementButtonProps:f,decrementButtonProps:h,descriptionProps:g,errorMessageProps:y,...v}=function(e,t,r){var n,a,o,i,s,l,u,c,d;let p,{id:m,decrementAriaLabel:f,incrementAriaLabel:h,isDisabled:g,isReadOnly:y,isRequired:v,minValue:b,maxValue:w,autoFocus:E,label:x,formatOptions:D,onBlur:S=()=>{},onFocus:_,onFocusChange:C,onKeyDown:k,onKeyUp:P,description:R,errorMessage:T,isWheelDisabled:O,...$}=e,{increment:N,incrementToMax:I,decrement:A,decrementToMin:M,numberValue:j,inputValue:L,commit:F,commitValidation:B}=t,V=hi((n=wQ)&&n.__esModule?n.default:n,"@react-aria/numberfield"),U=(0,lT.useCallback)(()=>{let e=r.current?.value??"";(0,fs.flushSync)(()=>{F()}),r.current?.value!==e&&fq(r.current?.value??"","assertive")},[F,r]),W=pH(m),{focusProps:H}=m1({onBlur(){U()}}),z=w1(D),K=(0,lT.useMemo)(()=>z.resolvedOptions(),[z]),G=w1({...D,currencySign:void 0}),Z=(0,lT.useMemo)(()=>isNaN(j)?"":G.format(j),[G,j]),{spinButtonProps:Y,incrementButtonProps:q,decrementButtonProps:J}=w3({isDisabled:g,isReadOnly:y,isRequired:v,maxValue:w,minValue:b,onIncrement:N,onIncrementToMax:I,onDecrement:A,onDecrementToMin:M,value:j,textValue:Z}),[X,Q]=(0,lT.useState)(!1),{focusWithinProps:ee}=fw({isDisabled:g,onFocusWithinChange:Q});!function(e,t){let{onScroll:r,isDisabled:n}=e,a=(0,lT.useCallback)(e=>{!e.ctrlKey&&(e.preventDefault(),e.stopPropagation(),r&&r({deltaX:e.deltaX,deltaY:e.deltaY}))},[r]);gh(t,"wheel",n?void 0:a)}({onScroll:(0,lT.useCallback)(e=>{!(Math.abs(e.deltaY)<=Math.abs(e.deltaX))&&(e.deltaY>0?N():e.deltaY<0&&A())},[A,N]),isDisabled:O||g||y||!X},r);let et=(K.maximumFractionDigits??0)>0,er=void 0===t.minValue||isNaN(t.minValue)||t.minValue<0,en="numeric";m_()?er?en="text":et&&(en="decimal"):mT()&&(er?en="numeric":et&&(en="decimal"));let ea=mt(e),eo=(0,lT.useCallback)(e=>{e.nativeEvent.isComposing||("Enter"===e.key?((0,fs.flushSync)(()=>{F()}),B()):e.continuePropagation())},[F,B]),{isInvalid:ei,validationErrors:es,validationDetails:el}=t.displayValidation,{labelProps:eu,inputProps:ec,descriptionProps:ed,errorMessageProps:ep}=function(e,t,r){let n=fo(e=>{let n=r.current;if(!n)return;let a=null;switch(e.inputType){case"historyUndo":case"historyRedo":case"insertLineBreak":return;case"deleteContent":case"deleteByCut":case"deleteByDrag":a=n.value.slice(0,n.selectionStart)+n.value.slice(n.selectionEnd);break;case"deleteContentForward":a=n.selectionEnd===n.selectionStart?n.value.slice(0,n.selectionStart)+n.value.slice(n.selectionEnd+1):n.value.slice(0,n.selectionStart)+n.value.slice(n.selectionEnd);break;case"deleteContentBackward":a=n.selectionEnd===n.selectionStart?n.value.slice(0,n.selectionStart-1)+n.value.slice(n.selectionStart):n.value.slice(0,n.selectionStart)+n.value.slice(n.selectionEnd);break;case"deleteSoftLineBackward":case"deleteHardLineBackward":a=n.value.slice(n.selectionStart);break;default:null!=e.data&&(a=n.value.slice(0,n.selectionStart)+e.data+n.value.slice(n.selectionEnd))}null!=a&&t.validate(a)||e.preventDefault()});(0,lT.useEffect)(()=>{if(!w0()||!r.current)return;let e=r.current;return e.addEventListener("beforeinput",n,!1),()=>{e.removeEventListener("beforeinput",n,!1)}},[r]);let a=w0()?null:e=>{let r=ms(e).value.slice(0,ms(e).selectionStart)+e.data+ms(e).value.slice(ms(e).selectionEnd);t.validate(r)||e.preventDefault()},{labelProps:o,inputProps:i,descriptionProps:s,errorMessageProps:l,...u}=function(e,t){let{inputElementType:r="input",isDisabled:n=!1,isRequired:a=!1,isReadOnly:o=!1,type:i="text",validationBehavior:s="aria"}=e,[l,u]=yc(e.value,e.defaultValue||"",e.onChange),{focusableProps:c}=m6(e,t),d=vo({...e,value:l}),{isInvalid:p,validationErrors:m,validationDetails:f}=d.displayValidation,{labelProps:h,fieldProps:g,descriptionProps:y,errorMessageProps:v}=y4({...e,isInvalid:p,errorMessage:e.errorMessage||m}),b=mt(e,{labelable:!0}),w={type:i,pattern:e.pattern},[E]=(0,lT.useState)(l);return y2(t,e.defaultValue??E,u),y3(e,d,t),{labelProps:h,inputProps:pG(b,"input"===r?w:void 0,{disabled:n,readOnly:o,required:a&&"native"===s,"aria-required":a&&"aria"===s||void 0,"aria-invalid":p||void 0,"aria-errormessage":e["aria-errormessage"],"aria-activedescendant":e["aria-activedescendant"],"aria-autocomplete":e["aria-autocomplete"],"aria-haspopup":e["aria-haspopup"],"aria-controls":e["aria-controls"],value:l,onChange:e=>u(ms(e).value),autoComplete:e.autoComplete,autoCapitalize:e.autoCapitalize,maxLength:e.maxLength,minLength:e.minLength,name:e.name,form:e.form,placeholder:e.placeholder,inputMode:e.inputMode,autoCorrect:e.autoCorrect,spellCheck:e.spellCheck,[parseInt(lO().version,10)>=17?"enterKeyHint":"enterkeyhint"]:e.enterKeyHint,onCopy:e.onCopy,onCut:e.onCut,onPaste:e.onPaste,onCompositionEnd:e.onCompositionEnd,onCompositionStart:e.onCompositionStart,onCompositionUpdate:e.onCompositionUpdate,onSelect:e.onSelect,onBeforeInput:e.onBeforeInput,onInput:e.onInput,...c,...g}),descriptionProps:y,errorMessageProps:v,isInvalid:p,validationErrors:m,validationDetails:f}}(e,r),c=(0,lT.useRef)(null);return{inputProps:pG(i,{onBeforeInput:a,onCompositionStart(){let{value:e,selectionStart:t,selectionEnd:n}=r.current;c.current={value:e,selectionStart:t,selectionEnd:n}},onCompositionEnd(){if(r.current&&!t.validate(r.current.value)){let{value:e,selectionStart:n,selectionEnd:a}=c.current;r.current.value=e,r.current.setSelectionRange(n,a),t.setInputValue(e)}}}),labelProps:o,descriptionProps:s,errorMessageProps:l,...u}}({...$,...ea,name:void 0,form:void 0,label:x,autoFocus:E,isDisabled:g,isReadOnly:y,isRequired:v,validate:void 0,[va]:t,value:L,defaultValue:"!",autoComplete:"off","aria-label":e["aria-label"]||void 0,"aria-labelledby":e["aria-labelledby"]||void 0,id:W,type:"text",inputMode:en,onChange:e=>{t.validate(e)&&t.setInputValue(e)},onBlur:S,onFocus:_,onFocusChange:C,onKeyDown:(0,lT.useMemo)(()=>pO(eo,k),[eo,k]),onKeyUp:P,onPaste:t=>{e.onPaste?.(t);let r=ms(t);r&&(r.selectionEnd??-1)-(r.selectionStart??0)===r.value.length&&(t.preventDefault(),F(t.clipboardData?.getData?.("text/plain")?.trim()??""))},description:R,errorMessage:T},t,r);y2(r,t.defaultNumberValue,t.setNumberValue),a=t,o=e.validationBehavior,i=e.commitBehavior,s=r,l=t.minValue,u=t.maxValue,c=e.step,d=t.numberValue,p$(()=>{let e=s.current;if("validate"!==i||a.realtimeValidation.isInvalid||!e||e.disabled||(!w6&&"u">typeof document&&((w6=document.createElement("input")).type="number"),!w6))return;w6.min=null==l||isNaN(l)?"":String(l),w6.max=null==u||isNaN(u)?"":String(u),w6.step=null==c||isNaN(c)?"":String(c),w6.value=null==d||isNaN(d)?"":String(d);let t=e.validity.valid&&w6.validity.valid,r=e.validationMessage||w6.validationMessage,n={isInvalid:!t,validationErrors:r?[r]:[],validationDetails:{badInput:e.validity.badInput,customError:e.validity.customError,patternMismatch:e.validity.patternMismatch,rangeOverflow:w6.validity.rangeOverflow,rangeUnderflow:w6.validity.rangeUnderflow,stepMismatch:w6.validity.stepMismatch,tooLong:e.validity.tooLong,tooShort:e.validity.tooShort,typeMismatch:e.validity.typeMismatch,valueMissing:e.validity.valueMissing,valid:t}};a.updateValidation(n),"native"!==o||w6.validity.valid||e.setCustomValidity(w6.validationMessage)});let em=pG(Y,H,ec,{role:null,"aria-roledescription":mk()?null:V.format("numberField"),"aria-valuemax":null,"aria-valuemin":null,"aria-valuenow":null,"aria-valuetext":null,autoCorrect:"off",spellCheck:"false"});"native"===e.validationBehavior&&(em["aria-required"]=void 0);let ef=e=>{((e=document)=>e.activeElement)()!==r.current&&("mouse"===e.pointerType?r.current?.focus():e.target.focus())},eh=e["aria-label"]||("string"==typeof e.label?e.label:"");eh||(p=null!=e.label?eu.id:e["aria-labelledby"]);let eg=pH(),ey=pH(),ev=pG(q,{"aria-label":h||V.format("increase",{fieldLabel:eh}).trim(),id:p&&!h?eg:null,"aria-labelledby":p&&!h?`${eg} ${p}`:null,"aria-controls":W,excludeFromTabOrder:!0,preventFocusOnPress:!0,allowFocusWhenDisabled:!0,isDisabled:!t.canIncrement,onPressStart:ef}),eb=pG(J,{"aria-label":f||V.format("decrease",{fieldLabel:eh}).trim(),id:p&&!f?ey:null,"aria-labelledby":p&&!f?`${ey} ${p}`:null,"aria-controls":W,excludeFromTabOrder:!0,preventFocusOnPress:!0,allowFocusWhenDisabled:!0,isDisabled:!t.canDecrement,onPressStart:ef});return{groupProps:{...ee,role:"group","aria-disabled":g,"aria-invalid":ei?"true":void 0},labelProps:eu,inputProps:em,incrementButtonProps:ev,decrementButtonProps:eb,errorMessageProps:ep,descriptionProps:ed,isInvalid:ei,validationErrors:es,validationDetails:el}}({...p0(e),label:c,validationBehavior:o},s,l),b=pq({...e,values:{state:s,isDisabled:e.isDisabled||!1,isInvalid:v.isInvalid||!1,isRequired:e.isRequired||!1},defaultClassName:"react-aria-NumberField"}),w=mt(e);return delete w.id,lO().createElement(pY,{values:[[w7,s],[yP,p],[yT,{...m,ref:l}],[vK,{...d,ref:u}],[fT,{slots:{increment:f,decrement:h}}],[fN,{slots:{description:g,errorMessage:y}}],[vU,v]]},lO().createElement("div",{...w,...b,ref:t,slot:e.slot||void 0,"data-disabled":e.isDisabled||void 0,"data-required":e.isRequired||void 0,"data-invalid":v.isInvalid||void 0}),e.name&&lO().createElement("input",{type:"hidden",name:e.name,value:isNaN(s.numberValue)?"":s.numberValue}))});function Et(e,t){return Number.parseInt(wj(e,{calendar:t.calendar,locale:t.baseName,day:!1,month:!1,noToday:!0,numberingSystem:"latn"}))}let Er=(0,lT.forwardRef)(function(e,t){let{className:r}=e,n=(0,lT.useContext)(yv),a=(0,lT.useContext)(yb),o=n??a,i=(0,lT.useContext)(wq),s=h5(),l=wj(o.visibleRange.start.toDate(s),{calendar:i.calendar,locale:i.baseName,day:!1,year:!1,noToday:!0}),u=Et(o.visibleRange.start.toDate(s),i),c=o.maxValue?Et(o.maxValue.toDate(s),i):void 0,d=o.minValue?Et(o.minValue.toDate(s),i):void 0,p=(0,lT.useCallback)(e=>{o.setFocusedDate(o.focusedDate.cycle("year",e-o.focusedDate.year))},[]);return o&&(0,lN.jsxs)("span",{ref:t,className:r,children:[(0,lN.jsx)("span",{children:l}),(0,lN.jsxs)(Ee,{formatOptions:{useGrouping:!1},maxValue:c,minValue:d,onChange:p,value:u,children:[(0,lN.jsx)(yO,{}),(0,lN.jsxs)(yR,{children:[(0,lN.jsx)(fO,{slot:"increment",children:(0,lN.jsx)(dr,{size:8})}),(0,lN.jsx)(fO,{slot:"decrement",children:(0,lN.jsx)(c7,{size:8})})]})]})]})}),En="-esm-patient-programs__datepicker-module__inputGroup___gBam-",Ea="-esm-patient-programs__datepicker-module__inputSegment___wIJDZ",Eo="-esm-patient-programs__datepicker-module__dateInputWrapper___LiY68",Ei="-esm-patient-programs__datepicker-module__invalidText___A4cv4",Es="-esm-patient-programs__datepicker-module__flatButton___HcpME",El="-esm-patient-programs__datepicker-module__flatButtonMd___eFpyF",Eu="-esm-patient-programs__datepicker-module__flatButtonSm___tsawR",Ec="-esm-patient-programs__datepicker-module__flatButtonLg___4HG5y";function Ed({children:e}){let t=(0,lT.useContext)(bK),r=(0,lT.useContext)(bG),n=t??r,a=ct(()=>n?.close());return(0,lN.jsx)(vV,{className:"-esm-patient-programs__datepicker-module__dialog___DaqYi",ref:a,children:e})}let Ep=(0,lT.forwardRef)(function({variant:e,today_:t,minDate:r,maxDate:n},a){let o="range"===e;return(0,lN.jsx)(bV,{ref:a,className:"-esm-patient-programs__datepicker-module__popover___nAPzC",placement:"bottom start",offset:1,isNonModal:!0,children:(0,lN.jsx)(Ed,{children:(0,lN.jsxs)(o?yE:yw,{...o?{minValue:r,maxValue:n,className:"cds--date-picker__calendar"}:{},children:[(0,lN.jsxs)("header",{className:"-esm-patient-programs__datepicker-module__header___rPv3L",children:[(0,lN.jsx)(fO,{className:cM()(Es,El),slot:"previous",children:(0,lN.jsx)(dc,{size:16})}),(0,lN.jsx)(Er,{className:"-esm-patient-programs__datepicker-module__monthYear___Rw4qE"}),(0,lN.jsx)(fO,{className:cM()(Es,El),slot:"next",children:(0,lN.jsx)(dd,{size:16})})]}),(0,lN.jsx)(yD,{className:"-esm-patient-programs__datepicker-module__calendarGrid___yKV-n",children:e=>(0,lN.jsx)(yk,{className:cM()("cds--date-picker__day",{"-esm-patient-programs__datepicker-module__today___KzMTn":0===t.compare(e)}),date:e},e.toString())})]})})})}),Em=(0,lT.forwardRef)(function(e,t){let r=(0,lT.useContext)(bK),[n,a]=pX({slot:e.slot},t,vP),{locale:o}=fZ(),i=vk({...n,locale:o,createCalendar:yt}),s=(0,lT.useRef)(null),{fieldProps:l,inputProps:u}=y8({...n,inputRef:s},i,a),c=(0,lT.useCallback)(()=>{i.isDisabled||r.toggle()},[]);return(0,lN.jsxs)(pY,{values:[[vR,i],[yT,{...u,ref:s}],[yP,{...l,ref:a,isInvalid:i.isInvalid}]],children:[(0,lN.jsx)(yR,{...e,id:e.id,ref:t,slot:e.slot||void 0,className:e.className,isDisabled:i.isDisabled,isInvalid:i.isInvalid,onClick:c,children:i.segments.map((t,r)=>(0,lT.cloneElement)(e.children(t),{key:r}))}),(0,lN.jsx)(yO,{})]})}),Ef=(0,lT.forwardRef)(function(e,t){let r=(0,lT.useContext)(bK),n=(0,lT.useContext)(bG);return(r??n).isInvalid?(0,lN.jsx)(pv,{ref:t,size:16,...e}):(0,lN.jsx)(c8,{ref:t,size:16,...e})});class Eh{constructor(e,t){this.locale=e,this.dictionary=t}of(e){return this.dictionary.getStringForLocale(e,this.locale)}}let Eg=new Map,Ey=(0,lT.forwardRef)(function({segment:e,...t},r){let n=(0,lT.useContext)(vR),a=pP(r),{segmentProps:o}=function(e,t,r){let n,a,o,i,s=(0,lT.useRef)(""),{locale:l,direction:u}=fZ(),c=function(){var e;let{locale:t}=fZ(),r=ho((e=yQ)&&e.__esModule?e.default:e,"@react-aria/datepicker");return(0,lT.useMemo)(()=>{try{return new Intl.DisplayNames(t,{type:"dateTimeField"})}catch{return new Eh(t,r)}},[t,r])}(),{ariaLabel:d,ariaLabelledBy:p,ariaDescribedBy:m,focusManager:f}=y6.get(t),h=e.isPlaceholder?"":e.text,g=(0,lT.useMemo)(()=>t.dateFormatter.resolvedOptions(),[t.dateFormatter]),y=f5({month:"long",timeZone:g.timeZone}),v=f5({hour:"numeric",hour12:g.hour12,timeZone:g.timeZone});if("month"!==e.type||e.isPlaceholder)"hour"!==e.type||e.isPlaceholder||(h=v.format(t.dateValue));else{let e=y.format(t.dateValue);h=e!==h?`${h} \u{2013} ${e}`:e}let{spinButtonProps:b}=w3({value:e.value??void 0,textValue:h,minValue:e.minValue,maxValue:e.maxValue,isDisabled:t.isDisabled,isReadOnly:t.isReadOnly||!e.isEditable,isRequired:t.isRequired,onIncrement:()=>{s.current="",t.increment(e.type)},onDecrement:()=>{s.current="",t.decrement(e.type)},onIncrementPage:()=>{s.current="",t.incrementPage(e.type)},onDecrementPage:()=>{s.current="",t.decrementPage(e.type)},onIncrementToMax:()=>{s.current="",t.incrementToMax(e.type)},onDecrementToMin:()=>{s.current="",t.decrementToMin(e.type)}}),w=(0,lT.useMemo)(()=>new(0,w5.d)(l,{maximumFractionDigits:0}),[l]),E=()=>{if(e.text===e.placeholder&&f.focusPrevious(),!w.isValidPartialNumber(e.text)||t.isReadOnly||e.isPlaceholder)("dayPeriod"===e.type||"era"===e.type)&&t.clearSegment(e.type);else{let r=e.text.slice(0,-1),n=w.parse(r);0===(r=0===n?"":r).length||0===n?t.clearSegment(e.type):t.setSegment(e.type,n),s.current=r}},{startsWith:x}=(n=function(e){let{locale:t}=fZ(),r=t+(e?Object.entries(e).sort((e,t)=>e[0]<t[0]?-1:1).join():"");if(Eg.has(r))return Eg.get(r);let n=new Intl.Collator(t,e);return Eg.set(r,n),n}({usage:"search",sensitivity:"base"}),a=(0,lT.useCallback)((e,t)=>0===t.length||(e=e.normalize("NFC"),t=t.normalize("NFC"),0===n.compare(e.slice(0,t.length),t)),[n]),o=(0,lT.useCallback)((e,t)=>0===t.length||(e=e.normalize("NFC"),t=t.normalize("NFC"),0===n.compare(e.slice(-t.length),t)),[n]),i=(0,lT.useCallback)((e,t)=>{if(0===t.length)return!0;e=e.normalize("NFC");let r=0,a=(t=t.normalize("NFC")).length;for(;r+a<=e.length;r++){let o=e.slice(r,r+a);if(0===n.compare(t,o))return!0}return!1},[n]),(0,lT.useMemo)(()=>({startsWith:a,endsWith:o,contains:i}),[a,o,i])),D=f5({hour:"numeric",hour12:!0}),S=(0,lT.useMemo)(()=>{let e=new Date;return e.setHours(0),D.formatToParts(e).find(e=>"dayPeriod"===e.type).value},[D]),_=(0,lT.useMemo)(()=>{let e=new Date;return e.setHours(12),D.formatToParts(e).find(e=>"dayPeriod"===e.type).value},[D]),C=f5({year:"numeric",era:"narrow",timeZone:"UTC"}),k=(0,lT.useMemo)(()=>{if("era"!==e.type)return[];let r=hZ(new hI(1,1,1),t.calendar),n=t.calendar.getEras().map(e=>{let t=r.set({year:1,month:1,day:1,era:e}).toDate("UTC");return{era:e,formatted:C.formatToParts(t).find(e=>"era"===e.type).value}}),a=function(e){e.sort();let t=e[0],r=e[e.length-1];for(let e=0;e<t.length;e++)if(t[e]!==r[e])return e;return 0}(n.map(e=>e.formatted));if(a)for(let e of n)e.formatted=e.formatted.slice(a);return n},[C,t.calendar,e.type]),P=r=>{if(t.isDisabled||t.isReadOnly)return;let n=s.current+r;switch(e.type){case"dayPeriod":if(x(S,r))t.setSegment("dayPeriod",0);else if(x(_,r))t.setSegment("dayPeriod",1);else break;f.focusNext();break;case"era":{let e=k.find(e=>x(e.formatted,r));e&&(t.setSegment("era",e.era),f.focusNext());break}case"day":case"hour":case"minute":case"second":case"month":case"year":{if(!w.isValidPartialNumber(n))return;let a=w.parse(n),o=a;if(void 0!==e.maxValue&&a>e.maxValue&&(o=w.parse(r)),isNaN(a))return;t.setSegment(e.type,o),void 0!==e.maxValue&&(Number(a+"0")>e.maxValue||n.length>=String(e.maxValue).length)?(s.current="",f.focusNext()):s.current=n}}};gh((0,lT.useRef)("u">typeof document?document:null),"selectionchange",()=>{let e=window.getSelection();e?.anchorNode&&mi(r.current,e?.anchorNode)&&e.collapse(r.current)});let R=(0,lT.useRef)("");gh(r,"beforeinput",n=>{if(r.current)switch(n.preventDefault(),n.inputType){case"deleteContentBackward":case"deleteContentForward":w.isValidPartialNumber(e.text)&&!t.isReadOnly&&E();break;case"insertCompositionText":R.current=r.current.textContent,r.current.textContent=r.current.textContent;break;default:null!=n.data&&P(n.data)}}),gh(r,"input",e=>{let{inputType:t,data:n}=e;"insertCompositionText"===t&&(r.current&&(r.current.textContent=R.current),null!=n&&(x(S,n)||x(_,n))&&P(n))}),p$(()=>{let e=r.current;return()=>{((e=document)=>e.activeElement)()===e&&(f.focusPrevious()||f.focusNext())}},[r,f]);let T=mk()||"timeZoneName"===e.type?{role:"textbox","aria-valuemax":null,"aria-valuemin":null,"aria-valuetext":null,"aria-valuenow":null}:{};e===(0,lT.useMemo)(()=>t.segments.find(e=>e.isEditable),[t.segments])||t.isInvalid||(m=void 0);let O=pH(),$=!t.isDisabled&&!t.isReadOnly&&e.isEditable,N="literal"===e.type?"":c.of(e.type),I=gc({"aria-label":`${N}${d?`, ${d}`:""}${p?", ":""}`,"aria-labelledby":p});if("literal"===e.type)return{segmentProps:{"aria-hidden":!0}};let A={caretColor:"transparent"};if("rtl"===u){A.unicodeBidi="embed";let t=g[e.type];("numeric"===t||"2-digit"===t)&&(A.direction="ltr")}return{segmentProps:pG(b,I,{id:O,...T,"aria-invalid":t.isInvalid?"true":void 0,"aria-describedby":m,"aria-readonly":t.isReadOnly||!e.isEditable?"true":void 0,"data-placeholder":e.isPlaceholder||void 0,contentEditable:$,suppressContentEditableWarning:$,spellCheck:$?"false":void 0,autoCorrect:$?"off":void 0,[parseInt(lO().version,10)>=17?"enterKeyHint":"enterkeyhint"]:$?"next":void 0,inputMode:t.isDisabled||"dayPeriod"===e.type||"era"===e.type||!$?void 0:"numeric",tabIndex:t.isDisabled?void 0:0,onKeyDown:e=>{if("a"===e.key&&(mS()?e.metaKey:e.ctrlKey)&&e.preventDefault(),!e.ctrlKey&&!e.metaKey&&!e.shiftKey&&!e.altKey)switch(e.key){case"Backspace":case"Delete":e.preventDefault(),e.stopPropagation(),E()}},onFocus:()=>{s.current="",r.current&&gw(r.current,{containingElement:gy(r.current)});let e=window.getSelection();e?.collapse(r.current)},style:A,onPointerDown(e){e.stopPropagation()},onMouseDown(e){e.stopPropagation()}})}}(e,n,a),{focusProps:i,isFocused:s,isFocusVisible:l}=fE(),{hoverProps:u,isHovered:c}=fC({...t,isDisabled:n.isDisabled||"literal"===e.type}),d=function(e){let{className:t,style:r,children:n,defaultClassName:a,defaultChildren:o,defaultStyle:i,values:s}=e;return(0,lT.useMemo)(()=>{let e,l,u;return e="function"==typeof t?t({...s,defaultClassName:a}):t,l="function"==typeof r?r({...s,defaultStyle:i||{}}):r,u="function"==typeof n?n({...s,defaultChildren:o}):null==n?o:n,{className:e??a,style:l||i?{...i,...l}:void 0,children:u??o,"data-rac":""}},[t,r,n,a,o,i,s])}({...t,values:{...e,isReadOnly:!e.isEditable,isInvalid:n.isInvalid,isDisabled:n.isDisabled,isHovered:c,isFocused:s,isFocusVisible:l},defaultChildren:e.text}),p=(0,lT.useCallback)(e=>{e.stopPropagation()},[]);return(0,lN.jsx)("span",{...pG(mt(t),o,i,u),...d,ref:a,style:o.style,"data-placeholder":e.isPlaceholder||void 0,"data-invalid":n.isInvalid||void 0,"data-readonly":!e.isEditable||void 0,"data-disabled":n.isDisabled||void 0,"data-type":e.type,"data-hovered":c||void 0,"data-focused":s||void 0,"data-focus-visible":l||void 0,onClick:p})}),Ev={short:!1,size:"md"},Eb=(0,lT.forwardRef)(function(e,t){let{className:r,defaultValue:n,isDisabled:a,invalid:o,invalidText:i,isInvalid:s,label:l,labelText:u,light:c,maxDate:d,minDate:p,onChange:m,onChangeRaw:f,short:h,size:g,value:y,...v}={...Ev,...e},{calendar:b,intlLocale:w,today_:E}=wJ(),x=(0,lT.useId)(),D=!!(u??l),S=(0,lT.useMemo)(()=>bJ(n,b),[n,b]),_=(0,lT.useMemo)(()=>bJ(y,b,!0),[y,b]),C=(0,lT.useMemo)(()=>bJ(d,b),[d,b]),k=(0,lT.useMemo)(()=>bJ(p??wX,b),[p,b]),P=(0,lT.useMemo)(()=>o||s,[o,s]),R=(0,lT.useMemo)(()=>(f&&m&&console.error("An OpenmrsDatePicker component was created with both onChange and onChangeRaw handlers defined. Only onChangeRaw will be used."),f??(e=>m?.(bX(e)))),[f,m]);return(0,lN.jsx)(bq,{locale:w.toString(),children:(0,lN.jsx)("div",{className:cM()("cds--form-item",r),children:(0,lN.jsx)(pY,{values:[[wq,w]],children:(0,lN.jsxs)(bZ,{className:cM()("cds--date-picker","cds--date-picker--single",{"cds--date-picker--short":h,"cds--date-picker--light":c}),defaultValue:S,isDisabled:a,isInvalid:P,maxValue:C,minValue:k,value:_,shouldForceLeadingZeros:"en"===w.language||void 0,...v,onChange:R,children:[(0,lN.jsxs)("div",{className:"cds--date-picker-container",children:[D&&(0,lN.jsx)(vG,{className:cM()("cds--label",{"cds--label--disabled":a}),htmlFor:x,children:u??l}),(0,lN.jsxs)(yR,{className:En,children:[(0,lN.jsx)(Em,{id:D?x:void 0,ref:t,className:cM()("cds--date-picker-input__wrapper","-esm-patient-programs__datepicker-module__inputWrapper___uKdT1",{"-esm-patient-programs__datepicker-module__inputWrapperSm___0RXJc":"sm"===g,"-esm-patient-programs__datepicker-module__inputWrapperMd___4Vff1":"md"===g||!g||0===g.length,"-esm-patient-programs__datepicker-module__inputWrapperLg___VCRm5":"lg"===g}),children:e=>"era"!==e.type?(0,lN.jsx)(Ey,{className:Ea,segment:e}):(0,lN.jsx)(lO().Fragment,{})}),(0,lN.jsx)(fO,{className:cM()(Es,{[Eu]:"sm"===g,[El]:"md"===g||!g||0===g.length,[Ec]:"lg"===g}),children:(0,lN.jsx)(Ef,{})})]}),(0,lN.jsx)(vW,{className:Ei,children:i})]}),(0,lN.jsx)(Ep,{variant:"single",today_:E})]})})})})}),Ew=(0,lT.forwardRef)(function({className:e,defaultValue:t,invalid:r,invalidText:n,isDisabled:a,isInvalid:o,label:i,labelText:s,light:l,maxDate:u,minDate:c,onChange:d,onChangeRaw:p,size:m="md",value:f,...h},g){let{calendar:y,intlLocale:v,today_:b}=wJ(),w=(0,lT.useId)(),E=!!(s??i),x=(0,lT.useMemo)(()=>{if(f)return{start:bJ(f[0],y,!1),end:bJ(f[1],y,!1)}},[f,y]),D=(0,lT.useMemo)(()=>{if(t)return{start:bJ(t[0],y,!1),end:bJ(t[1],y,!1)}},[t,y]),S=(0,lT.useMemo)(()=>bJ(c??wX,y,!0),[c,y]),_=(0,lT.useMemo)(()=>bJ(u,y,!0),[u,y]),C=(0,lT.useMemo)(()=>r||o,[r,o]),k=(0,lT.useMemo)(()=>(p&&d&&console.error("An OpenmrsDateRangePicker component was created with both onChange and onChangeRaw handlers defined. Only onChangeRaw will be used."),p??(e=>d?.([bX(e.start),bX(e.end)]))),[p,d]);return(0,lN.jsx)(bq,{locale:v.toString(),children:(0,lN.jsx)("div",{className:cM()("cds--form-item",e),children:(0,lN.jsx)(pY,{values:[[wq,v]],children:(0,lN.jsx)(bY,{id:E?w:void 0,className:cM()("cds--date-picker",{"cds--date-picker--light":l,"cds--date-picker--disabled":a}),isInvalid:C,shouldForceLeadingZeros:"en"===v.language||void 0,maxValue:_,minValue:S,value:x,defaultValue:D,ref:g,isDisabled:a,...h,onChange:k,children:(0,lN.jsxs)("div",{className:"cds--date-picker-container",children:[E&&(0,lN.jsx)(vG,{className:cM()("cds--label",{"cds--label--disabled":a}),htmlFor:w,children:s??i}),(0,lN.jsxs)(yR,{className:En,children:[(0,lN.jsxs)("div",{className:cM()("-esm-patient-programs__datepicker-module__inputsWrapper___xXRQI",{"-esm-patient-programs__datepicker-module__inputsWrapperSm___nL+b6":"sm"===m,"-esm-patient-programs__datepicker-module__inputsWrapperMd___Kgcps":"md"===m||!m||0===m.length,"-esm-patient-programs__datepicker-module__inputsWrapperLg___raaSN":"lg"===m}),children:[(0,lN.jsx)(vO,{className:cM()("cds--date-picker-input__wrapper","-esm-patient-programs__datepicker-module__startInput___cWw-5",Eo),slot:"start",children:e=>(0,lN.jsx)(Ey,{className:Ea,segment:e})}),(0,lN.jsx)("div",{className:"-esm-patient-programs__datepicker-module__separator___Ddb4g",children:(0,lN.jsx)("span",{"aria-hidden":"true","data-readonly":!0,children:"–"})}),(0,lN.jsx)(vO,{className:cM()("cds--date-picker-input__wrapper","-esm-patient-programs__datepicker-module__endInput___xdYOl",Eo),slot:"end",children:e=>(0,lN.jsx)(Ey,{className:Ea,segment:e})})]}),(0,lN.jsx)(fO,{className:cM()(Es,{[Eu]:"sm"===m,[El]:"md"===m||!m||0===m.length,[Ec]:"lg"===m}),children:(0,lN.jsx)(Ef,{})})]}),(0,lN.jsx)(vW,{className:Ei,children:n}),(0,lN.jsx)(Ep,{variant:"range",today_:b,minDate:S,maxDate:_})]})})})})})}),EE=lO().createContext(null);function Ex(e){let{children:t}=e,r=(0,lT.useContext)(EE),[n,a]=(0,lT.useState)(0),o=(0,lT.useMemo)(()=>({parent:r,modalCount:n,addModal(){a(e=>e+1),r&&r.addModal()},removeModal(){a(e=>e-1),r&&r.removeModal()}}),[r,n]);return lO().createElement(EE.Provider,{value:o},t)}function ED(e){let t,{modalProviderProps:r}={modalProviderProps:{"aria-hidden":!!(t=(0,lT.useContext)(EE))&&t.modalCount>0||void 0}};return lO().createElement("div",{"data-overlay-container":!0,...e,...r})}function ES(e){return lO().createElement(Ex,null,lO().createElement(ED,e))}function E_(e){let t=pV(),{portalContainer:r=t?null:document.body,...n}=e,{getContainer:a}=vM();if(!e.portalContainer&&a&&(r=a()),lO().useEffect(()=>{if(r?.closest("[data-overlay-container]"))throw Error("An OverlayContainer must not be inside another container. Please change the portalContainer prop.")},[r]),!r)return null;let o=lO().createElement(ES,n);return fl().createPortal(o,r)}let EC=lO().createContext(null),Ek=lO().forwardRef(function(e,t){let{children:r,...n}=e,a=pP(t),o={...n,ref:a};return lO().createElement(EC.Provider,{value:o},r)}),EP={},ER=0,ET=!1,EO=null,E$=null;function EN(e={}){let{delay:t=1500,closeDelay:r=500}=e,{isOpen:n,open:a,close:o}=bL(e),i=(0,lT.useMemo)(()=>`${++ER}`,[]),s=(0,lT.useRef)(null),l=(0,lT.useRef)(o),u=()=>{EP[i]=p},c=()=>{for(let e in EP)e!==i&&(EP[e](!0),delete EP[e])},d=()=>{s.current&&clearTimeout(s.current),s.current=null,c(),u(),ET=!0,a(),EO&&(clearTimeout(EO),EO=null),E$&&(clearTimeout(E$),E$=null)},p=e=>{e||r<=0?(s.current&&clearTimeout(s.current),s.current=null,l.current()):s.current||(s.current=setTimeout(()=>{s.current=null,l.current()},r)),EO&&(clearTimeout(EO),EO=null),ET&&(E$&&clearTimeout(E$),E$=setTimeout(()=>{delete EP[i],E$=null,ET=!1},Math.max(500,r)))};return(0,lT.useEffect)(()=>{l.current=o},[o]),(0,lT.useEffect)(()=>()=>{s.current&&clearTimeout(s.current),EP[i]&&delete EP[i]},[i]),{isOpen:n,open:e=>{e||!(t>0)||s.current?d():(c(),u(),n||ET?n||d():(EO&&clearTimeout(EO),EO=setTimeout(()=>{EO=null,ET=!0,d()},t)))},close:p}}let EI=(0,lT.createContext)(null),EA=(0,lT.createContext)(null);function EM(e){let t=EN(e),r=(0,lT.useRef)(null),{triggerProps:n,tooltipProps:a}=function(e,t,r){let{isDisabled:n,trigger:a,shouldCloseOnPress:o=!0}=e,i=pH(),s=(0,lT.useRef)(!1),l=(0,lT.useRef)(!1),u=()=>{(s.current||l.current)&&t.open(l.current)},c=e=>{s.current||l.current||t.close(e)};(0,lT.useEffect)(()=>{let e=e=>{r&&r.current&&"Escape"===e.key&&(e.stopPropagation(),t.close(!0))};if(t.isOpen)return document.addEventListener("keydown",e,!0),()=>{document.removeEventListener("keydown",e,!0)}},[r,t]);let d=()=>{o&&(l.current=!1,s.current=!1,c(!0))},{hoverProps:p}=fC({isDisabled:n,onHoverStart:()=>{"focus"!==a&&("pointer"===mI?s.current=!0:s.current=!1,u())},onHoverEnd:()=>{"focus"!==a&&(l.current=!1,s.current=!1,c())}}),{focusableProps:m}=m6({isDisabled:n,onFocus:()=>{mZ()&&(l.current=!0,u())},onBlur:()=>{l.current=!1,s.current=!1,c(!0)}},r);return{triggerProps:{"aria-describedby":t.isOpen?i:void 0,...pG(m,p,{onPointerDown:d,onKeyDown:d}),tabIndex:void 0},tooltipProps:{id:i}}}(e,t,r);return lO().createElement(pY,{values:[[EI,t],[EA,{...a,triggerRef:r}]]},lO().createElement(Ek,{...n,ref:r},e.children))}let Ej=(0,lT.forwardRef)(function({UNSTABLE_portalContainer:e,...t},r){[t,r]=pX(t,r,EA);let n=(0,lT.useContext)(EI),a=EN(t),o=null==t.isOpen&&null==t.defaultOpen&&n?n:a,i=bD(r,o.isOpen)||t.isExiting||!1;return o.isOpen||i?lO().createElement(E_,{portalContainer:e},lO().createElement(EL,{...t,tooltipRef:r,isExiting:i})):null});function EL(e){let t=(0,lT.useContext)(EI),r=(0,lT.useRef)(null),[n,a]=(0,lT.useState)(0);p$(()=>{r.current&&t.isOpen&&a(r.current.getBoundingClientRect().width)},[t.isOpen,r]);let{overlayProps:o,arrowProps:i,placement:s}=bu({placement:e.placement||"top",targetRef:e.triggerRef,overlayRef:e.tooltipRef,offset:e.offset,crossOffset:e.crossOffset,isOpen:t.isOpen,arrowSize:n,arrowBoundaryOffset:e.arrowBoundaryOffset,shouldFlip:e.shouldFlip,onClose:()=>t.close(!0)}),l=bx(e.tooltipRef,!!s)||e.isEntering||!1,u=pq({...e,defaultClassName:"react-aria-Tooltip",values:{placement:s,isEntering:l,isExiting:e.isExiting,state:t}}),{tooltipProps:c}=function(e,t){let r=mt(e,{labelable:!0}),{hoverProps:n}=fC({onHoverStart:()=>t?.open(!0),onHoverEnd:()=>t?.close()});return{tooltipProps:pG(r,n,{role:"tooltip"})}}(e=pG(e,o),t);return lO().createElement("div",{...c,ref:e.tooltipRef,...u,style:{...o.style,...u.style},"data-placement":null!=s?s:void 0,"data-entering":l||void 0,"data-exiting":e.isExiting||void 0},lO().createElement(vZ.Provider,{value:{...i,placement:s,ref:r}},u.children))}let EF=({diagnoses:e,showCertainty:t=!1})=>{let{diagnosisTags:r}=u$({externalModuleName:"@openmrs/esm-styleguide"});return(0,lN.jsx)("div",{className:"-esm-patient-programs__diagnosis-tags-module__container___1iigI",children:e.map(e=>{let n=t&&"PROVISIONAL"===e.certainty,a=1===e.rank?r?.primaryColor??"blue":r?.secondaryColor??"gray";return(0,lN.jsx)(EB,{color:a,isProvisional:n,name:e.display},e.uuid)})})};function EB({color:e,isProvisional:t,name:r}){let[n,a]=(0,lT.useState)(!1),[o,i]=(0,lT.useState)(!1),[s,l]=(0,lT.useState)(!1),u=s||o,c=(0,lT.useRef)(null);(0,lT.useLayoutEffect)(()=>{let e=c.current;if(!e)return;let t=()=>{let t=e.scrollWidth>e.clientWidth;l(t),t||a(!1)};t();let r=new ResizeObserver(t);return r.observe(e),()=>r.disconnect()},[r,t,u]);let d=cM()("cds--tag","cds--tag--md","cds--layout--size-md",`cds--tag--${e}`,"-esm-patient-programs__diagnosis-tags-module__diagnosisTag___mQ28X"),p=(0,lN.jsxs)(lN.Fragment,{children:[t&&(0,lN.jsxs)(lN.Fragment,{children:[(0,lN.jsx)("span",{"aria-hidden":"true",className:"-esm-patient-programs__diagnosis-tags-module__provisionalMark___S+J53",children:"?"}),(0,lN.jsxs)("span",{className:"cds--visually-hidden",children:[ot("provisional","Provisional")," "]})]}),(0,lN.jsx)("span",{ref:c,className:"cds--tag__label",children:r})]});return u?(0,lN.jsxs)(EM,{delay:0,closeDelay:150,isOpen:n,onOpenChange:a,children:[(0,lN.jsx)(fO,{className:d,"data-testid":"diagnosis-tag",onFocusChange:i,onPress:()=>a(!0),children:p}),(0,lN.jsx)(Ej,{className:"-esm-patient-programs__diagnosis-tags-module__tagTooltip___50O3+",placement:"bottom",offset:4,containerPadding:8,children:r})]}):(0,lN.jsx)("span",{className:d,"data-testid":"diagnosis-tag",children:p})}let EV={action:"-esm-patient-programs__empty-card-module__action___oG778",content:"-esm-patient-programs__empty-card-module__content___YUXvR",desktopHeading:"-esm-patient-programs__empty-card-module__desktopHeading___EljiH",tabletHeading:"-esm-patient-programs__empty-card-module__tabletHeading___8mc7w",tile:"-esm-patient-programs__empty-card-module__tile___3-rRO"},EU=({width:e="64",height:t="64"})=>(0,lN.jsx)("svg",{width:e,height:t,viewBox:"0 0 64 64",children:(0,lN.jsx)("use",{href:"#omrs-empty-data-illustration"})}),EW=e=>{let t="tablet"===u6(),r=e.launchForm;return(0,lN.jsx)(cV.Layer,{className:EV.layer,children:(0,lN.jsxs)(cV.Tile,{className:EV.tile,children:[(0,lN.jsx)("div",{className:t?EV.tabletHeading:EV.desktopHeading,children:(0,lN.jsx)("h4",{children:e.headerTitle})}),(0,lN.jsx)(EU,{}),(0,lN.jsx)("p",{className:EV.content,children:ot("emptyStateText","There are no {{displayText}} to display",{displayText:e.displayText})}),(0,lN.jsx)("p",{className:EV.action,children:r&&(0,lN.jsx)(cV.Button,{onClick:()=>r(),kind:"ghost",size:t?"lg":"sm",children:ot("recordNewEntry","Record {{ displayText }}",{displayText:e.displayText})})})]})})},EH=({error:e,headerTitle:t})=>{let r="tablet"===u6();return(0,lN.jsx)(cV.Layer,{children:(0,lN.jsxs)(cV.Tile,{className:"-esm-patient-programs__error-state-module__tile___mzWLn",children:[(0,lN.jsx)("div",{className:r?"-esm-patient-programs__error-state-module__tabletHeading___l7Cpn":"-esm-patient-programs__error-state-module__desktopHeading___p57fl",children:(0,lN.jsx)("h4",{children:t})}),(0,lN.jsxs)("p",{className:"-esm-patient-programs__error-state-module__errorMessage___0fU6v",children:[ot("error","Error")," ",`${e?.response?.status}: `,e?.response?.statusText]}),(0,lN.jsx)("p",{className:"-esm-patient-programs__error-state-module__errorCopy___xkVog",children:ot("errorCopy")})]})})},Ez=EH,EK=lO().forwardRef((e,t)=>{let{slotName:r,basePath:n,componentContext:a,state:o}=u8(),i=window.location??{pathname:""},s=lK(r??"");return e.isChildOfHeader&&r&&s.length>0?(0,lN.jsxs)(cV.SideNav,{"aria-label":ot("leftNavigation","Left navigation"),className:"-esm-patient-programs__left-nav-module__leftNav___czP9T",expanded:!0,isFixedNav:!0,ref:t,...e,children:[(0,lN.jsx)(lY,{name:"global-nav-menu-slot"}),r?(0,lN.jsx)(uE,{value:a,fallback:(0,lN.jsx)(lY,{name:r,state:{basePath:n,currentPath:i,...o}}),children:(0,lN.jsx)(l$.Provider,{value:a,children:(0,lN.jsx)(lY,{name:r,state:{basePath:n,currentPath:i,...o}})})}):null]}):null}),EG=({selectedLocationUuid:e,defaultLocationUuid:t,locationTag:r,locationsPerRequest:n=50,onChange:a})=>{let[o,i]=(0,lT.useState)(""),s=(0,lT.useId)(),{location:l}=function(e){let t=e?`/ws/fhir2/R4/Location?_id=${e}`:null,{data:r,error:n,isLoading:a}=uM()(t,ov,{shouldRetryOnError:e=>!!e?.response?.status&&e.response.status>=500});return(0,lT.useMemo)(()=>({location:r?.data?.entry?r.data.entry[0]:null,error:t?n:null,isLoading:!!t&&a}),[r,a,n,t])}(t),{locations:u,isLoading:c,hasMore:d,loadingNewData:p,error:m,setPage:f}=function(e,t=0,r=""){let n=uI(r),{data:a,isLoading:o,isValidating:i,setSize:s,error:l}=uJ()(function(r,a){if(a){let e=a.data?.link?.find(e=>"next"===e.relation);if(!e)return null;let t=new URL(e.url);return t.origin===window.location.origin?e.url:new URL(`${t.pathname}${t.search?`?${t.search}`:""}`,window.location.origin).toString()}let o=`${oh}/Location?`,i=new URLSearchParams;return i.append("_summary","data"),t&&i.append("_count",""+t),r&&i.append("_getpagesoffset",""+r*t),e&&i.append("_tag",e),"string"==typeof n&&""!==n&&i.append("name:contains",n),o+i.toString()},ov);return(0,lT.useMemo)(()=>({locations:a?.length?a?.flatMap(e=>e?.data?.entry??[]):[],isLoading:o,totalResults:a?.[0]?.data?.total,hasMore:!!a?.length&&a?.[a.length-1]?.data?.link?.some(e=>"next"===e.relation),loadingNewData:i,error:l||null,setPage:s}),[o,a,i,s,l])}(r,n,o),h=(0,lT.useMemo)(()=>l&&!o&&t?[l,...u.filter(({resource:e})=>e.id!==t)]:u??[],[l,u,t,o]),g=(0,lT.useCallback)(e=>{a(),i(e.trim())},[a]),y=cr((0,lT.useCallback)(()=>{!p&&d&&f(e=>e+1)},[p,d,f])),v=d?Math.max(0,Math.floor(h.length-n/2)):-1;return(0,lN.jsxs)(lN.Fragment,{children:[(0,lN.jsx)(cV.Search,{"aria-describedby":m?`${s}-error`:void 0,labelText:ot("searchForLocation"),id:s,placeholder:ot("searchForLocation"),onChange:e=>g(e.target.value),size:"lg"}),m&&(0,lN.jsx)("div",{className:"-esm-patient-programs__location-picker-module__errorNotification___NfvTe",id:`${s}-error`,children:(0,lN.jsx)(cV.InlineNotification,{kind:"error",subtitle:ot("errorLoadingLoginLocations","Unable to load login locations. Please try again or contact support if the problem persists."),title:ot("error","Error")})}),(0,lN.jsx)("div",{className:"-esm-patient-programs__location-picker-module__searchResults___agplm",children:c?(0,lN.jsx)("div",{className:"-esm-patient-programs__location-picker-module__loadingContainer___EHghS",children:Array.from({length:5}).map((e,t)=>(0,lN.jsx)(cV.RadioButtonSkeleton,{className:"-esm-patient-programs__location-picker-module__radioButtonSkeleton___up5rH",role:"progressbar"},t))}):(0,lN.jsxs)(lN.Fragment,{children:[(0,lN.jsx)("div",{className:"-esm-patient-programs__location-picker-module__locationResultsContainer___06YOS",children:h.length>0?(0,lN.jsx)(cV.RadioButtonGroup,{name:"loginLocations",onChange:e=>{a(e?.toString())},orientation:"vertical",valueSelected:e,children:h.map((e,t)=>(0,lN.jsx)(cV.RadioButton,{className:"-esm-patient-programs__location-picker-module__locationRadioButton___yKif7",id:e.resource.id,labelText:(0,lN.jsx)("span",{ref:t===v?y:null,children:e.resource.name}),name:e.resource.name,value:e.resource.id},e.resource.id))}):(0,lN.jsx)("div",{className:"-esm-patient-programs__location-picker-module__emptyState___cPWp8",children:(0,lN.jsx)("p",{className:"-esm-patient-programs__location-picker-module__locationNotFound___b14++",children:ot("noResultsToDisplay")})})}),p&&(0,lN.jsx)("div",{className:"-esm-patient-programs__location-picker-module__loadingIcon___GVlrq",children:(0,lN.jsx)(cV.InlineLoading,{description:ot("loading")})})]})})]})},EZ=V("modalState",{modalContainer:null,modalStack:[]}),EY=0;async function Eq(e,t,r={}){let n=lf(t),a=null;if(e){if(!n)throw Error(`No modal named '${t}' has been registered.`);let{load:o}=n,i=await o(),s=EY++;a=await lC({...i,name:`${t}-${s}`},{...r,domElement:e})}else P(`Failed to launch modal. Please notify your administrator. Modal name: ${t}`);return a}function EJ(e){return"TO_BE_DELETED"===e.state||"DELETED"===e.state}function EX(e,t){t?.unmount&&(t.unmountPromise?.catch(()=>{}),t.unmount().catch(t=>{console.error(`The modal '${e}' failed to unmount`,t)}))}function EQ(e){return e.find(e=>!EJ(e))}function E0(e,t){e.container&&(e.container.style.visibility=t?"unset":"hidden")}let E1=window.getComputedStyle(document.body).overflow;function E4({modalStack:e,modalContainer:t}){if(t)if(e.length){t.style.visibility||(addEventListener("keydown",E3),document.body.style.overflow="hidden",t.style.visibility="unset");let r=EQ(e);e.forEach(e=>{switch(e.state){case"NEW":{let r=function({size:e}){let t=document.createElement("div");return t.className=`cds--modal-container cds--modal-container--${e}`,t.setAttribute("role","dialog"),t.setAttribute("tabindex","-1"),t.setAttribute("aria-modal","true"),t}({size:e.props?.size??"md"});e.container=r,e.state="MOUNTING",Eq(r,e.modalName,e.props).then(n=>{EJ(e)?EX(e.modalName,n):n?(e.parcel=n,t.prepend(r),E0(e,EQ(EZ.getState().modalStack)===e),n.mountPromise.then(()=>{EJ(e)||(e.state="MOUNTED")},t=>{P(t),e.parcel=null,E2(e)})):E2(e)},t=>{P(t),E2(e)});break}case"MOUNTING":case"MOUNTED":E0(e,e===r);break;case"TO_BE_DELETED":e.state="DELETED",e.onClose(),EX(e.modalName,e.parcel),e.container?.remove(),setTimeout(()=>{let t=EZ.getState();EZ.setState({...t,modalStack:t.modalStack.filter(t=>t!==e)})},0)}})}else t.style.removeProperty("visibility"),document.body.style.overflow=E1,removeEventListener("keydown",E3)}function E2(e){if(EJ(e))return;e.state="TO_BE_DELETED";let t=EZ.getState();EZ.setState({...t,modalStack:[...t.modalStack]})}function E3(e){"Escape"===e.key&&function(){let[e]=EZ.getState().modalStack;e&&E2(e)}()}function E6(e){EZ.subscribe(E4),EZ.setState({...EZ.getState(),modalContainer:e})}function E5(e,t={},r=()=>{}){let n=()=>{let e=EZ.getState().modalStack.find(e=>e.onClose===r);e&&E2(e)};if(lf(e)){var a;let o,i;a={state:"NEW",onClose:r,modalName:e,props:{close:n,...t}},i=[a,...(o=EZ.getState()).modalStack],EZ.setState({...o,modalStack:i})}else P(`Failed to launch modal. Please notify your administrator. Modal name: "${e}"`);return n}var E9=r(3264),E8=Object.prototype.hasOwnProperty;let E7=function(e){if(null==e)return!0;if((0,eM.A)(e)&&((0,eA.A)(e)||"string"==typeof e||"function"==typeof e.splice||(0,ej.A)(e)||(0,eF.A)(e)||(0,eI.A)(e)))return!e.length;var t=(0,tc.A)(e);if("[object Map]"==t||"[object Set]"==t)return!e.size;if((0,e$.A)(e))return!(0,E9.A)(e).length;for(var r in e)if(E8.call(e,r))return!1;return!0},xe=({notification:e})=>{let{description:t,action:r,kind:n,critical:a,title:o,onAction:i}=e;return(0,lN.jsx)(cV.ActionableNotification,{actionButtonLabel:r,kind:n||"info",lowContrast:a,subtitle:t,title:o||"",inline:!0,onActionButtonClick:i})},xt=({subject:e})=>{let[t,r]=(0,lT.useState)([]);return(0,lT.useEffect)(()=>{let t=e.subscribe(e=>r(t=>[...t.filter(t=>t.description!==e.description||t.action!==e.action||t.kind!==e.kind||t.title!==e.title),e]));return()=>t.unsubscribe()},[e]),(0,lN.jsx)(lN.Fragment,{children:t.map(e=>(0,lN.jsx)(xe,{notification:e},e.id))})},xr=({notification:e})=>{let{actionButtonLabel:t,onActionButtonClick:r=()=>{},subtitle:n,kind:a,title:o,critical:i,progressActionLabel:s,id:l,...u}=e,[c,d]=(0,lT.useState)(t);return(0,lN.jsx)(cV.ActionableNotification,{kind:a||"info",actionButtonLabel:c,"aria-label":ot("closesActionableNotification","Closes actionable notification"),onActionButtonClick:()=>{r(),s&&d(s)},statusIconDescription:ot("actionableNotification","Actionable notification"),subtitle:n,title:o,lowContrast:i,inline:!0,...u})},xn=({subject:e})=>{let[t,r]=(0,lT.useState)([]);return(0,lT.useEffect)(()=>{let t=e.subscribe(e=>r(t=>[...t.filter(t=>t.subtitle!==e.subtitle||t.actionButtonLabel!==e.actionButtonLabel||t.onActionButtonClick!==e.onActionButtonClick||t.kind!==e.kind||t.title!==e.title),e]));return()=>t.unsubscribe()},[e]),(0,lN.jsx)(lN.Fragment,{children:t.map(e=>(0,lN.jsx)(xr,{notification:e},e.id))})};class xa{subscribe(e){return this.listeners.add(e),{unsubscribe:()=>{this.listeners.delete(e)}}}next(e){for(let t of[...this.listeners])t(e)}constructor(){!function(e,t,r){t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r}(this,"listeners",new Set)}}let xo=new xa,xi=0,xs=new xa,xl=0;function xu(e){e&&(0,lq.createRoot)(e).render((0,lN.jsx)(xt,{subject:xo}))}function xc(e){var t;e&&("string"==typeof(t=e.description)?t.trim().length>0:"object"==typeof t&&(t instanceof Error||!E7(t)))?(e.description instanceof Error&&(e.description=e.description.toLocaleString()),setTimeout(()=>{xo.next({...e,id:xi++})},0)):console.error("showNotification must be called with an object having a 'description' property that is a non-empty string or object")}function xd(e){e&&(0,lq.createRoot)(e).render((0,lN.jsx)(xn,{subject:xs}))}function xp(e){var t;e&&("string"==typeof(t=e.actionButtonLabel)?t.trim().length>0:"object"==typeof t&&!E7(t))?setTimeout(()=>{xs.next({...e,id:xl++})},0):console.error("showActionableNotification must be called with an actionButtonLabel that is a non-empty string")}let xm=["NORMAL","HIGH","CRITICALLY_HIGH","OFF_SCALE_HIGH","LOW","CRITICALLY_LOW","OFF_SCALE_LOW"],xf=["critically_low","critically_high","high","low","normal","off_scale_low","off_scale_high"],xh={container:"-esm-patient-programs__numeric-observation-module__container___gS0Wg",card:"-esm-patient-programs__numeric-observation-module__card___w0fF5","abnormal-value":"-esm-patient-programs__numeric-observation-module__abnormal-value___xuX3W","critical-value":"-esm-patient-programs__numeric-observation-module__critical-value___Jynsn",cell:"-esm-patient-programs__numeric-observation-module__cell___tMhBJ","critically-high":"-esm-patient-programs__numeric-observation-module__critically-high___3L2wx","critically-low":"-esm-patient-programs__numeric-observation-module__critically-low___XP+HX",high:"-esm-patient-programs__numeric-observation-module__high___JV9do",low:"-esm-patient-programs__numeric-observation-module__low___-uDKD","label-container":"-esm-patient-programs__numeric-observation-module__label-container___vTf2y","value-container":"-esm-patient-programs__numeric-observation-module__value-container___xTUIC",label:"-esm-patient-programs__numeric-observation-module__label___-pfmb",value:"-esm-patient-programs__numeric-observation-module__value___1A4zt",units:"-esm-patient-programs__numeric-observation-module__units___SzvX+","pad-right":"-esm-patient-programs__numeric-observation-module__pad-right___ND9XL","off-scale-low":"-esm-patient-programs__numeric-observation-module__off-scale-low___gFAv9","off-scale-high":"-esm-patient-programs__numeric-observation-module__off-scale-high___aSEmX",arrow:"-esm-patient-programs__numeric-observation-module__arrow___9bvsX"},xg=({value:e,unit:t,label:r,interpretation:n,referenceRange:a,conceptUuid:o,variant:i="card",patientUuid:s})=>{let l=(0,lT.useId)(),{referenceRange:u,isLoading:c}=function(e,t){let r=null;e&&(r=t?`${of}/conceptreferencerange/?patient=${t}&concept=${e}&v=full`:`${of}/conceptreferencerange/?concept=${e}&v=full`);let{data:n,error:a,isLoading:o}=uM()(r,ov),i=n?.data?.results?.[0];return{referenceRange:i?{hiNormal:i.hiNormal??null,hiAbsolute:i.hiAbsolute??null,hiCritical:i.hiCritical??null,lowNormal:i.lowNormal??null,lowAbsolute:i.lowAbsolute??null,lowCritical:i.lowCritical??null}:void 0,error:a,isLoading:o}}(a||n?void 0:o,s),d=a??u,p=(0,lT.useMemo)(()=>{if(n)return n?"--"===n?"normal":xm.includes(n)?n.toLowerCase():xf.includes(n)?n:"normal":void 0;if(d&&!c){if(!d||null==e||""===e)return"normal";let t="string"==typeof e?Number.parseFloat(e):e;return Number.isNaN(t)?"normal":null!==d.hiAbsolute&&void 0!==d.hiAbsolute&&t>d.hiAbsolute?"off_scale_high":null!==d.hiCritical&&void 0!==d.hiCritical&&t>=d.hiCritical?"critically_high":null!==d.hiNormal&&void 0!==d.hiNormal&&t>d.hiNormal?"high":null!==d.lowAbsolute&&void 0!==d.lowAbsolute&&t<d.lowAbsolute?"off_scale_low":null!==d.lowCritical&&void 0!==d.lowCritical&&t<=d.lowCritical?"critically_low":null!==d.lowNormal&&void 0!==d.lowNormal&&t<d.lowNormal?"low":"normal"}return"normal"},[n,d,e,c])??"normal",m="critically_low"===p||"critically_high"===p||"off_scale_low"===p||"off_scale_high"===p,f="normal"!==p,h=r?`omrs-numeric-obs-label-${r.replaceAll(/\s+/g,"-").toLowerCase()}-${l}`:void 0,g=`omrs-numeric-obs-value-${l}`,y=`omrs-numeric-obs-unit-${l}`,v=null!=e&&""!==e,b=v?e:ot("notAvailable","Not available"),w=cM()({[xh["critically-low"]]:"critically_low"===p||"off_scale_low"===p,[xh["critically-high"]]:"critically_high"===p||"off_scale_high"===p,[xh.low]:"low"===p,[xh.high]:"high"===p,[xh["off-scale-low"]]:"off_scale_low"===p,[xh["off-scale-high"]]:"off_scale_high"===p}),E=cM()({[xh.container]:!0,[xh.card]:!0,[xh["critical-value"]]:m,[xh["abnormal-value"]]:f&&!m}),x=cM()({[xh.cell]:!0,[w]:!0});return"cell"===i?(0,lN.jsxs)("div",{className:x,children:[b,v&&t?` ${t}`:""]}):(0,lN.jsxs)("section",{className:E,"data-testid":"numeric-observation-card",children:[r&&(0,lN.jsxs)("div",{className:xh["label-container"],children:[(0,lN.jsx)("span",{id:h,className:xh.label,children:r}),f&&(0,lN.jsx)("span",{className:xh[p.replace("_","-")],title:ot("abnormalValue","Abnormal value")})]}),(0,lN.jsxs)("div",{className:xh["value-container"],children:[(0,lN.jsx)("span",{id:g,"aria-labelledby":h&&y?`${h} ${y}`:h||y||void 0,className:xh.value,children:b}),v&&t&&(0,lN.jsx)("span",{id:y,className:xh.units,children:t})]})]})},xy="-esm-patient-programs__page-header-module__pageHeader___6TOjO",xv=e=>{if("children"in e){let{children:t,className:r,...n}=e;return(0,lN.jsx)("div",{className:cM()(xy,r),...n,children:t})}{let{title:t,illustration:r,className:n,...a}=e;return(0,lN.jsx)("div",{className:cM()(xy,n),...a,children:(0,lN.jsx)(xb,{title:t,illustration:r})})}},xb=({title:e,illustration:t,className:r})=>{let[n,a]=(0,lT.useState)(null);return(0,lT.useEffect)(()=>{rS("@openmrs/esm-styleguide").then(e=>{a(e)})},[]),(0,lN.jsxs)("div",{className:cM()("-esm-patient-programs__page-header-module__pageHeaderContent___mCImT",r),children:[t,(0,lN.jsxs)("div",{className:"-esm-patient-programs__page-header-module__pageLabels___kqDS+",children:[n?.implementationName&&(0,lN.jsx)("p",{children:ot(n.implementationName)}),(0,lN.jsx)("h1",{className:"-esm-patient-programs__page-header-module__pageName___SbZBC",children:e})]})]})},xw=({totalItems:e,pageSize:t,onPageNumberChange:r,pageNumber:n,dashboardLinkUrl:a,currentItems:o,dashboardLinkLabel:i})=>{let{pageSizes:s,pageItemsCount:l}=co(t,e,n,o),u="tablet"===u6(),c=ot("paginationItemsCount","{{pageItemsCount}} / {{totalItems}} items",{totalItems:e,pageItemsCount:l});return(0,lN.jsx)(lN.Fragment,{children:e>0&&(0,lN.jsxs)("div",{className:cM()({"-esm-patient-programs__pagination-module__tablet___82gj1":u,"-esm-patient-programs__pagination-module__desktop___6yI8e":!u}),children:[(0,lN.jsxs)("div",{children:[c,a&&(0,lN.jsx)(lI,{to:a,className:"-esm-patient-programs__pagination-module__configurableLink___oIqma",children:i??ot("seeAll","See all")})]}),(0,lN.jsx)(cV.Pagination,{className:"-esm-patient-programs__pagination-module__pagination___A-Lcg",page:n,pageSize:t,pageSizes:s,totalItems:e,onChange:r,pageRangeText:(e,t)=>ot("paginationOfPages","of {{count}} pages",{count:t}),size:u?"lg":"sm"})]})})};function xE(e){return xD(x_(e,"usual","official"))}function xx(e){return xE(e)}function xD(e){var t;let r;return e?e.text??(r=(t=e).given??[],(t.family?r.concat(t.family):r).join(" ")):""}function xS(e){return xD(e)}function x_(e,...t){for(let r of(0==t.length&&(t=["usual"]),t)){let t=e.name?.find(e=>{var t,n;return t=e,n=r,t.use?t.use===n:"usual"===n});if(t)return t}}function xC(e,t=cf()()){let r=cf()(t),n=wW(e,r);if(null==n)return null;let a=r.diff(n,"hours"),o=r.diff(n,"days"),i=r.diff(n,"weeks"),s=r.diff(n,"months"),l=r.diff(n,"years"),u={};if(a<2)u.minutes=r.diff(n,"minutes");else if(o<2)u.hours=a;else if(i<4)u.days=o;else if(l<1){let e=r.subtract(i,"weeks").diff(n,"days");u.weeks=i,u.days=e}else if(l<2){let e=r.subtract(s,"months").diff(n,"days");u.months=s,u.days=e}else if(l<18){let e=r.subtract(l,"year").diff(n,"months");u.years=l,u.months=e}else u.years=l;return u}function xk(e,t=cf()()){let r=xC(e,t);if(null==r)return null;let n={style:"short",localeMatcher:"lookup"};return"minutes"in r&&0===r.minutes&&(n.minutesDisplay="always"),wU(r,n)}let xP={container:"-esm-patient-programs__patient-banner-patient-info-module__container___iC32K",activePatientContainer:"-esm-patient-programs__patient-banner-patient-info-module__activePatientContainer___OoDPd",patientBanner:"-esm-patient-programs__patient-banner-patient-info-module__patientBanner___swajU",patientName:"-esm-patient-programs__patient-banner-patient-info-module__patientName___+2+Xi",patientAvatar:"-esm-patient-programs__patient-banner-patient-info-module__patientAvatar___Rdf75",patientAvatarButton:"-esm-patient-programs__patient-banner-patient-info-module__patientAvatarButton___A1q8c",patientInfo:"-esm-patient-programs__patient-banner-patient-info-module__patientInfo___L-cOQ",demographics:"-esm-patient-programs__patient-banner-patient-info-module__demographics___IDhb0",row:"-esm-patient-programs__patient-banner-patient-info-module__row___TP7gU",flexRow:"-esm-patient-programs__patient-banner-patient-info-module__flexRow___vNMt2",tagsSlot:"-esm-patient-programs__patient-banner-patient-info-module__tagsSlot___0Dvjn",identifiers:"-esm-patient-programs__patient-banner-patient-info-module__identifiers___d3GTJ",identifier:"-esm-patient-programs__patient-banner-patient-info-module__identifier___kc6eq",primaryIdentifier:"-esm-patient-programs__patient-banner-patient-info-module__primaryIdentifier___ZxRUU",secondaryIdentifier:"-esm-patient-programs__patient-banner-patient-info-module__secondaryIdentifier___eQh8x",value:"-esm-patient-programs__patient-banner-patient-info-module__value___CoAOR",tag:"-esm-patient-programs__patient-banner-patient-info-module__tag___InccN",gender:"-esm-patient-programs__patient-banner-patient-info-module__gender___vfinx",separator:"-esm-patient-programs__patient-banner-patient-info-module__separator___3OIBl",tooltipPadding:"-esm-patient-programs__patient-banner-patient-info-module__tooltipPadding___hBqWG",tooltipSmallText:"-esm-patient-programs__patient-banner-patient-info-module__tooltipSmallText___bPnkq",actionsButtonText:"-esm-patient-programs__patient-banner-patient-info-module__actionsButtonText___VNvm7"};function xR({showIdentifierLabel:e,type:t,value:r}){return(0,lN.jsx)("span",{className:xP.primaryIdentifier,children:(0,lN.jsxs)(cV.Tag,{className:xP.tag,type:"gray",children:[e&&t?.text&&(0,lN.jsxs)("span",{className:xP.label,children:[t.text,": "]}),(0,lN.jsx)("span",{className:xP.value,children:r})]})})}function xT({showIdentifierLabel:e,type:t,value:r}){return(0,lN.jsxs)(cV.FormLabel,{className:xP.secondaryIdentifier,id:`patient-banner-identifier-${r}`,children:[e&&(0,lN.jsxs)("span",{className:xP.label,children:[t?.text,": "]}),(0,lN.jsx)("span",{className:xP.value,children:r})]})}function xO({identifiers:e,showIdentifierLabel:t}){let{excludePatientIdentifierCodeTypes:r}=u$(),{primaryIdentifierCode:n}=cl(),a=e?.filter(e=>{let t=e.type?.coding?.[0]?.code;return t&&!r?.uuids.includes(t)})??[];return(0,lN.jsx)(lN.Fragment,{children:a?.length?a.map(({value:e,type:r},o)=>(0,lN.jsxs)(lO().Fragment,{children:[(0,lN.jsx)("span",{className:xP.identifier,children:r?.coding?.[0]?.code===n?(0,lN.jsx)(xR,{showIdentifierLabel:t,type:r,value:e}):(0,lN.jsx)(xT,{showIdentifierLabel:t,type:r,value:e})}),o<a.length-1&&(0,lN.jsx)("span",{className:xP.separator,children:"\xb7"})]},e)):""})}let x$={Female:dD,Male:dS,Other:d_,Unknown:dC},xN=({gender:e})=>{let t=x$[e];return t?(0,lN.jsx)(t,{fill:"#525252"}):null},xI={male:"Male",female:"Female",other:"Other",unknown:"Unknown"};function xA({patient:e,renderedFrom:t}){var r;let n,a,o=xE(e),i=e?.gender&&(a=xI[n=(r=e.gender).toLowerCase()]??"Unknown",{displayText:ot(n,r),iconKey:a}),s=(0,lT.useMemo)(()=>({patientUuid:e.id,patient:e,renderedFrom:t}),[e.id,e,t]);return(0,lN.jsxs)("div",{className:xP.patientInfo,children:[(0,lN.jsx)("div",{className:cM()(xP.row,xP.patientNameRow),children:(0,lN.jsxs)("div",{className:xP.flexRow,children:[(0,lN.jsx)("span",{className:xP.patientName,children:o}),i&&(0,lN.jsxs)("div",{className:xP.gender,children:[(0,lN.jsx)(xN,{gender:i.iconKey}),(0,lN.jsx)("span",{children:i.displayText})]}),(0,lN.jsx)(lY,{className:xP.tagsSlot,name:"patient-banner-tags-slot",state:s})]})}),(0,lN.jsxs)("div",{className:xP.demographics,children:[e.birthDate&&(0,lN.jsxs)(lN.Fragment,{children:[(0,lN.jsx)("span",{children:xk(e.birthDate)}),(0,lN.jsx)("span",{className:xP.separator,children:"\xb7"}),(0,lN.jsx)("span",{children:wM(e.birthDate,{time:!1,noToday:!0})}),(0,lN.jsx)("span",{className:xP.separator,children:"\xb7"})]}),(0,lN.jsx)(xO,{identifiers:e.identifier,showIdentifierLabel:!0}),(0,lN.jsx)(lY,{className:xP.extensionSlot,name:"patient-banner-bottom-slot",state:s})]})]})}var xM=r(8282);function xj({patient:e,patientUuid:t,actionsSlotName:r,additionalActionsSlotState:n}){let[a,o]=(0,lT.useState)(!1),{extensions:i}=lG(r),s="tablet"===u6(),l=ct(()=>o(!1),a),u=(0,lT.useRef)(null),c=(0,lT.useRef)(null),d=(0,lT.useId)(),p=`patient-actions-menu-trigger-${d}`,m=`patient-actions-menu-${d}`,f=(0,lT.useCallback)(()=>o(e=>!e),[]),h=(0,lT.useCallback)(()=>{o(!1),u.current?.focus()},[]),g=(0,lT.useCallback)(e=>{if("Escape"===e.key&&a){e.stopPropagation(),h();return}if(("ArrowDown"===e.key||"ArrowUp"===e.key)&&a){e.preventDefault();let t=c.current?.querySelectorAll('[role="menuitem"]:not([disabled])');if(!t?.length)return;let r=document.activeElement?.closest?.('[role="menuitem"]')??document.activeElement,n=Array.from(t).indexOf(r);if(-1===n)return void t["ArrowDown"===e.key?0:t.length-1]?.focus();let a=n+("ArrowDown"===e.key?1:-1),o=a<0?t.length-1:a>=t.length?0:a;t[o]?.focus()}},[h,a]);(0,lT.useEffect)(()=>{if(a&&c.current){let e=c.current.querySelector('[role="menuitem"]:not([disabled])');e?.focus()}},[a]);let y=(0,lT.useMemo)(()=>({patientUuid:t,patient:e,closeMenu:h,...n}),[t,e,h,n]);return 0===i.length?null:(0,lN.jsx)("div",{className:"-esm-patient-programs__patient-banner-actions-menu-module__overflowMenuContainer___FbFcO",children:(0,lN.jsxs)("div",{"data-overflow-menu":!0,className:cM()("cds--overflow-menu",cH),ref:l,children:[(0,lN.jsxs)("button",{className:cM()("cds--btn","cds--btn--ghost","cds--overflow-menu__trigger",{"cds--overflow-menu--open":a},cG),"aria-controls":m,"aria-expanded":a,"aria-haspopup":"true",id:p,onClick:f,onKeyDown:g,ref:u,children:[(0,lN.jsx)("span",{className:"-esm-patient-programs__patient-banner-actions-menu-module__actionsButtonText___hk4xW",children:ot("actions","Actions")})," ",(0,lN.jsx)(xM.CH,{size:16,style:{marginLeft:"0.5rem",fill:"#78A9FF"}})]}),(0,lN.jsxs)("div",{className:cM()("cds--overflow-menu-options","cds--overflow-menu--flip",cz,{[cK]:a}),"aria-labelledby":p,"data-floating-menu-direction":"bottom",id:m,onKeyDown:g,ref:c,role:"menu",tabIndex:-1,children:[(0,lN.jsx)("ul",{className:cM()("cds--overflow-menu-options__content",{"cds--overflow-menu-options--lg":s}),children:(0,lN.jsx)(lY,{name:r,state:y},r)}),(0,lN.jsx)("span",{})]})]})})}var xL=r(5570),xF=r.n(xL);function xB(e){let{patientPhotoConceptUuid:t}=u$({externalModuleName:"@openmrs/esm-styleguide"}),r=t?`${of}/obs?patient=${e}&concept=${t}&v=full`:null,{data:n,error:a,isLoading:o}=un()(e?r:null,ov),i=n?.data?.results[0];return{data:i?{dateTime:i?.obsDatetime,imageSrc:i?.value?.links?.uri}:null,error:a,isLoading:o}}let xV=({width:e=56,height:t=56,"aria-label":r})=>{let{t:n}=(0,ut.useTranslation)();return(0,lN.jsxs)("svg",{"aria-label":r??n("patientPhotoPlaceholder","Patient photo placeholder"),width:e,height:t,fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,lN.jsx)("path",{fill:"#ffffff",d:"M0 0h56v56H0z"}),(0,lN.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m36.75 20.134-.884-.884L19.25 35.866l.884.884 1.25-1.25H34.25a1.252 1.252 0 0 0 1.25-1.25V21.384l1.25-1.25Zm-2.5 14.116H22.634l4.87-4.87 1.487 1.486a1.25 1.25 0 0 0 1.768 0l.991-.991 2.5 2.498v1.877Zm0-3.645-1.616-1.616a1.25 1.25 0 0 0-1.768 0l-.991.991-1.486-1.486 5.861-5.86v7.971Zm-12.5 1.145v-1.875l3.125-3.123.858.859.885-.885-.86-.86a1.25 1.25 0 0 0-1.767 0l-2.241 2.242V21.75h10V20.5h-10c-.69 0-1.25.56-1.25 1.25v10h1.25Z",fill:"#8D8D8D"})]})},xU="-esm-patient-programs__patient-photo-module__avatar___thboZ";function xW({patientUuid:e,patientName:t,alt:r}){let{data:n,isLoading:a}=xB(e),[o,i]=(0,lT.useState)(null),[s,l]=(0,lT.useState)(!1),u=(0,lT.useMemo)(()=>xF().generate(e),[e]);(0,lT.useEffect)(()=>{if(n?.imageSrc){let e=new URL(n.imageSrc,window.location.origin).pathname;l(!0);let t=!1,r=new Image;return r.onload=()=>{t||(i(e),l(!1))},r.onerror=()=>{t||(i(null),l(!1))},r.src=e,()=>{t=!0}}i(null),l(!1)},[n?.imageSrc]);let c=(0,lT.useMemo)(()=>r||(o?ot("patientPhotoAlt","Profile photo of {{patientName}}",{patientName:t}):ot("patientAvatarAlt","Avatar for {{patientName}}",{patientName:t})),[r,o,t]);return a||s?(0,lN.jsx)(cV.SkeletonIcon,{className:"-esm-patient-programs__patient-photo-module__skeleton___WWtyX","data-testid":"skeleton-icon"}):n?.imageSrc&&!o?(0,lN.jsx)(xV,{"aria-label":ot("patientPhotoPlaceholder","Photo placeholder for {{patientName}}",{patientName:t})}):o?(0,lN.jsx)("div",{"aria-label":c,children:(0,lN.jsx)("img",{className:xU,src:o,alt:c,title:t})}):(0,lN.jsx)("div",{"aria-label":c,children:(0,lN.jsx)("div",{className:xU,title:t,style:{backgroundImage:u.toDataUrl(),backgroundRepeat:"no-repeat",backgroundSize:"cover"},children:(0,lN.jsx)("span",{className:"-esm-patient-programs__patient-photo-module__initials___xLeEF",children:function(e,t=3){return e.split(/\s+/).filter(Boolean).slice(0,t).map(e=>e[0]).join("")}(t)})})})}let xH=["omrs-pict-appointments","omrs-pict-assessment-1","omrs-pict-assessment-2","omrs-pict-blood-bank","omrs-pict-cardiology","omrs-pict-cohorts","omrs-pict-concept-dictionary","omrs-pict-ct-scan","omrs-pict-data-entry","omrs-pict-dentistry","omrs-pict-digital-trust","omrs-pict-emergency-department","omrs-pict-facility","omrs-pict-geriatrics","omrs-pict-gynaecology","omrs-pict-in-patient","omrs-pict-laboratory","omrs-pict-labs-2","omrs-pict-metadata-export","omrs-pict-obstetrics","omrs-pict-patient-documents","omrs-pict-patient-search","omrs-pict-patients","omrs-pict-payments-desk","omrs-pict-pharmacy","omrs-pict-pharmacy-2","omrs-pict-registration","omrs-pict-reports","omrs-pict-service-queues","omrs-pict-stock-management","omrs-pict-system-administration","omrs-pict-transfer","omrs-pict-triage","omrs-pict-x-ray"],xz=(0,lT.memo)((0,lT.forwardRef)(function(e,t){return(0,lN.jsx)(Db,{ref:t,pictogram:"omrs-pict-appointments",pictogramProps:e})})),xK=xz,xG=(0,lT.memo)((0,lT.forwardRef)(function(e,t){return(0,lN.jsx)(Db,{ref:t,pictogram:"omrs-pict-assessment-1",pictogramProps:e})})),xZ=(0,lT.memo)((0,lT.forwardRef)(function(e,t){return(0,lN.jsx)(Db,{ref:t,pictogram:"omrs-pict-assessment-2",pictogramProps:e})})),xY=(0,lT.memo)((0,lT.forwardRef)(function(e,t){return(0,lN.jsx)(Db,{ref:t,pictogram:"omrs-pict-blood-bank",pictogramProps:e})})),xq=(0,lT.memo)((0,lT.forwardRef)(function(e,t){return(0,lN.jsx)(Db,{ref:t,pictogram:"omrs-pict-cardiology",pictogramProps:e})})),xJ=(0,lT.memo)((0,lT.forwardRef)(function(e,t){return(0,lN.jsx)(Db,{ref:t,pictogram:"omrs-pict-cohorts",pictogramProps:e})})),xX=(0,lT.memo)((0,lT.forwardRef)(function(e,t){return(0,lN.jsx)(Db,{ref:t,pictogram:"omrs-pict-concept-dictionary",pictogramProps:e})})),xQ=(0,lT.memo)((0,lT.forwardRef)(function(e,t){return(0,lN.jsx)(Db,{ref:t,pictogram:"omrs-pict-ct-scan",pictogramProps:e})})),x0=(0,lT.memo)((0,lT.forwardRef)(function(e,t){return(0,lN.jsx)(Db,{ref:t,pictogram:"omrs-pict-data-entry",pictogramProps:e})})),x1=(0,lT.memo)((0,lT.forwardRef)(function(e,t){return(0,lN.jsx)(Db,{ref:t,pictogram:"omrs-pict-dentistry",pictogramProps:e})})),x4=(0,lT.memo)((0,lT.forwardRef)(function(e,t){return(0,lN.jsx)(Db,{ref:t,pictogram:"omrs-pict-digital-trust",pictogramProps:e})})),x2=(0,lT.memo)((0,lT.forwardRef)(function(e,t){return(0,lN.jsx)(Db,{ref:t,pictogram:"omrs-pict-emergency-department",pictogramProps:e})})),x3=(0,lT.memo)((0,lT.forwardRef)(function(e,t){return(0,lN.jsx)(Db,{ref:t,pictogram:"omrs-pict-facility",pictogramProps:e})})),x6=(0,lT.memo)((0,lT.forwardRef)(function(e,t){return(0,lN.jsx)(Db,{ref:t,pictogram:"omrs-pict-geriatrics",pictogramProps:e})})),x5=(0,lT.memo)((0,lT.forwardRef)(function(e,t){return(0,lN.jsx)(Db,{ref:t,pictogram:"omrs-pict-gynaecology",pictogramProps:e})})),x9=(0,lT.memo)((0,lT.forwardRef)(function(e,t){return(0,lN.jsx)(Db,{ref:t,pictogram:"omrs-pict-in-patient",pictogramProps:e})})),x8=(0,lT.memo)((0,lT.forwardRef)(function(e,t){return(0,lN.jsx)(Db,{ref:t,pictogram:"omrs-pict-laboratory",pictogramProps:e})})),x7=(0,lT.memo)((0,lT.forwardRef)(function(e,t){return(0,lN.jsx)(Db,{ref:t,pictogram:"omrs-pict-labs-2",pictogramProps:e})})),De=(0,lT.memo)((0,lT.forwardRef)(function(e,t){return(0,lN.jsx)(Db,{ref:t,pictogram:"omrs-pict-metadata-export",pictogramProps:e})})),Dt=(0,lT.memo)((0,lT.forwardRef)(function(e,t){return(0,lN.jsx)(Db,{ref:t,pictogram:"omrs-pict-obstetrics",pictogramProps:e})})),Dr=(0,lT.memo)((0,lT.forwardRef)(function(e,t){return(0,lN.jsx)(Db,{ref:t,pictogram:"omrs-pict-patient-documents",pictogramProps:e})})),Dn=(0,lT.memo)((0,lT.forwardRef)(function(e,t){return(0,lN.jsx)(Db,{ref:t,pictogram:"omrs-pict-patient-search",pictogramProps:e})})),Da=(0,lT.memo)((0,lT.forwardRef)(function(e,t){return(0,lN.jsx)(Db,{ref:t,pictogram:"omrs-pict-patients",pictogramProps:e})})),Do=(0,lT.memo)((0,lT.forwardRef)(function(e,t){return(0,lN.jsx)(Db,{ref:t,pictogram:"omrs-pict-payments-desk",pictogramProps:e})})),Di=(0,lT.memo)((0,lT.forwardRef)(function(e,t){return(0,lN.jsx)(Db,{ref:t,pictogram:"omrs-pict-pharmacy",pictogramProps:e})})),Ds=(0,lT.memo)((0,lT.forwardRef)(function(e,t){return(0,lN.jsx)(Db,{ref:t,pictogram:"omrs-pict-pharmacy-2",pictogramProps:e})})),Dl=(0,lT.memo)((0,lT.forwardRef)(function(e,t){return(0,lN.jsx)(Db,{ref:t,pictogram:"omrs-pict-registration",pictogramProps:e})})),Du=(0,lT.memo)((0,lT.forwardRef)(function(e,t){return(0,lN.jsx)(Db,{ref:t,pictogram:"omrs-pict-reports",pictogramProps:e})})),Dc=(0,lT.memo)((0,lT.forwardRef)(function(e,t){return(0,lN.jsx)(Db,{ref:t,pictogram:"omrs-pict-service-queues",pictogramProps:e})})),Dd=(0,lT.memo)((0,lT.forwardRef)(function(e,t){return(0,lN.jsx)(Db,{ref:t,pictogram:"omrs-pict-stock-management",pictogramProps:e})})),Dp=(0,lT.memo)((0,lT.forwardRef)(function(e,t){return(0,lN.jsx)(Db,{ref:t,pictogram:"omrs-pict-system-administration",pictogramProps:e})})),Dm=(0,lT.memo)((0,lT.forwardRef)(function(e,t){return(0,lN.jsx)(Db,{ref:t,pictogram:"omrs-pict-transfer",pictogramProps:e})})),Df=(0,lT.memo)((0,lT.forwardRef)(function(e,t){return(0,lN.jsx)(Db,{ref:t,pictogram:"omrs-pict-triage",pictogramProps:e})})),Dh=(0,lT.memo)((0,lT.forwardRef)(function(e,t){return(0,lN.jsx)(Db,{ref:t,pictogram:"omrs-pict-x-ray",pictogramProps:e})})),Dg=x3,Dy=Da,Dv=(0,lT.memo)((0,lT.forwardRef)(function({pictogram:e,fallback:t,...r},n){let a=(0,lT.useRef)(document.getElementById(e));return(0,lT.useEffect)(()=>{let t=document.getElementById("omrs-svgs-container"),r=new MutationObserver(t=>{for(let r of t)"childList"===r.type&&(a.current=document.getElementById(e))});return t&&r.observe(t,{childList:!0}),()=>r.disconnect()},[e]),(0,lN.jsx)(uE,{value:a.current,fallback:t,children:(0,lN.jsx)(Db,{ref:n,pictogram:e,pictogramProps:r})})})),Db=(0,lT.memo)((0,lT.forwardRef)(function({pictogram:e,pictogramProps:t},r){let{className:n,size:a}=Object.assign({},{size:92},t);return(a<=26||a>144)&&(console.error(`Invalid size '${a}' specified for ${e}. Defaulting to 92.`),a=92),(0,lN.jsx)("svg",{ref:r,className:cM()("-esm-patient-programs__pictograms-module__pictogram___ooPKM",n),height:a,width:a,children:(0,lN.jsx)("use",{href:`#${e}`})})})),Dw=({children:e})=>"tablet"===u6()?(0,lN.jsx)(cV.Layer,{children:e}):(0,lN.jsx)(lN.Fragment,{children:e}),DE=({snackbar:e,closeSnackbar:t})=>{let{actionButtonLabel:r="",kind:n="success",onActionButtonClick:a=()=>{},isLowContrast:o="error"!==n,progressActionLabel:i,subtitle:s="",timeoutInMs:l=5e3,autoClose:u="error"!==n,title:c,id:d,...p}=e,[m,f]=(0,lT.useState)(r),[h,g]=(0,lT.useState)(!0),[y,v]=(0,lT.useState)(!1),b=(0,lT.useCallback)(()=>{setTimeout(t,250)},[t]),w=(0,lT.useCallback)(()=>{v(!0),b()},[b]);return(0,lT.useEffect)(()=>{if(u){let e=setTimeout(w,l);return()=>clearTimeout(e)}},[l,u,w]),(0,lT.useEffect)(()=>{g(!1),window.setTimeout(()=>{g(!0)},0)},[]),(0,lN.jsx)(cV.ActionableNotification,{actionButtonLabel:m,"aria-label":ot("closeSnackbar","Close snackbar"),className:cM()("-esm-patient-programs__snackbar-module__slideIn___senVE",{"-esm-patient-programs__snackbar-module__animated___8eltL":h,"-esm-patient-programs__snackbar-module__slideOut___BIIXm":y}),kind:n,lowContrast:o,onActionButtonClick:()=>{a(),w(),i&&f(i)},onClose:b,statusIconDescription:ot("snackbarNotification","Snackbar notification"),subtitle:s,title:c,...p})},Dx=({subject:e})=>{let[t,r]=(0,lT.useState)([]),n=(0,lT.useCallback)(e=>{r(t=>t.filter(t=>t!==e))},[]);return(0,lT.useEffect)(()=>{let t=e.subscribe(e=>r(t=>[...t.filter(t=>t.subtitle!==e.subtitle||t.actionButtonLabel!==e.actionButtonLabel||t.onActionButtonClick!==e.onActionButtonClick||t.kind!==e.kind||t.title!==e.title),e]));return()=>t.unsubscribe()},[e]),(0,lN.jsx)(lN.Fragment,{children:t.map(e=>(0,lN.jsx)(DE,{snackbar:e,closeSnackbar:()=>n(e)},e.id))})},DD=new xa,DS=0;function D_(e){e&&(0,lq.createRoot)(e).render((0,lN.jsx)(Dx,{subject:DD}))}function DC(e){var t;e&&"string"==typeof(t=e.title)&&t.trim().length>0?setTimeout(()=>{DD.next({...e,id:DS++})},0):console.error("showSnackbar must be called with an object having a 'title' property that is a non-empty string")}let Dk=({toast:e,closeToast:t})=>{let{description:r,kind:n,critical:a,title:o,actionButtonLabel:i,onActionButtonClick:s=()=>{}}=e,l=(0,lT.useCallback)(()=>{s(),t()},[t,s]);return(0,lN.jsx)("div",{children:(0,lN.jsx)(cV.ActionableNotification,{actionButtonLabel:i,kind:n||"info",lowContrast:a,subtitle:r,title:o||"",onActionButtonClick:l,onClose:t})})},DP=({subject:e})=>{let[t,r]=(0,lT.useState)([]),n=(0,lT.useCallback)(e=>{r(t=>t.filter(t=>t!==e))},[]);return(0,lT.useEffect)(()=>{let t=e.subscribe(e=>r(t=>[...t.filter(t=>t.description!==e.description||t.kind!==e.kind||t.title!==e.title||t.actionButtonLabel!==e.actionButtonLabel||t.onActionButtonClick!==e.onActionButtonClick),e]));return()=>t.unsubscribe()},[e]),(0,lN.jsx)(lN.Fragment,{children:t.map(e=>(0,lN.jsx)(Dk,{toast:e,closeToast:()=>n(e)},e.id))})},DR=new xa,DT=0;function DO(e){e&&(0,lq.createRoot)(e).render((0,lN.jsx)(DP,{subject:DR}))}function D$(e){var t;e&&("string"==typeof(t=e.description)?t.trim().length>0:"object"==typeof t&&!E7(t))?setTimeout(()=>{DR.next({...e,id:DT++})},0):console.error("showToast must be called with an object having a 'description' property that is a non-empty string or object")}let DN="u">typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),DI=new Uint8Array(16),DA=[];for(let e=0;e<256;++e)DA.push((e+256).toString(16).slice(1));let DM=function(e,t,r){if(DN&&!t&&!e)return DN();let n=(e=e||{}).random??e.rng?.()??function(){if(!d){if("u"<typeof crypto||!crypto.getRandomValues)throw Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");d=crypto.getRandomValues.bind(crypto)}return d(DI)}();if(n.length<16)throw Error("Random bytes length must be >= 16");if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,t){if((r=r||0)<0||r+16>t.length)throw RangeError(`UUID byte range ${r}:${r+15} is out of buffer bounds`);for(let e=0;e<16;++e)t[r+e]=n[e];return t}return function(e,t=0){return(DA[e[t+0]]+DA[e[t+1]]+DA[e[t+2]]+DA[e[t+3]]+"-"+DA[e[t+4]]+DA[e[t+5]]+"-"+DA[e[t+6]]+DA[e[t+7]]+"-"+DA[e[t+8]]+DA[e[t+9]]+"-"+DA[e[t+10]]+DA[e[t+11]]+DA[e[t+12]]+DA[e[t+13]]+DA[e[t+14]]+DA[e[t+15]]).toLowerCase()}(n)};async function Dj(e,t){let{openedGroup:r}=lh.getState();if(r){if(r.groupName===e&&DB(r.props,t))return!0;else if(!await DW({reason:"CLOSE_WORKSPACE_GROUP",explicit:!1}))return!1}return lh.setState(r=>({...r,openedGroup:{groupName:e,props:t},openedWindows:[]})),!0}async function DL(e){let{openedGroup:t,openedWindows:r}=lh.getState();if(t){if(r.length>0&&!(e||await DW({reason:"CLOSE_WORKSPACE_GROUP",explicit:!0})))return!1;lh.setState(e=>({...e,openedGroup:null,openedWindows:[]}))}return!0}async function DF(e,t=null,r=null,n=null){let a=lh.getState();if(!a.registeredWorkspacesByName[e])throw Error(`Unable to launch workspace ${e}. Workspace is not registered`);let o=lg(e);if(!o)throw Error(`Unable to launch workspace ${e}. Workspace is not registered to a workspace window`);let{openedGroup:i}=a,{name:s}=o,l=ly(s);if(!l)throw Error(`Unable to launch workspace ${e}. Workspace window ${o.name} is not registered to a workspace group`);let u=lv(e);if(i&&(i.groupName!==l.name||!DB(i.props,n)))return!!await DW({reason:"CLOSE_WORKSPACE_GROUP",explicit:!0})&&(lh.setState({...a,openedGroup:{groupName:l.name,props:n},openedWindows:[{windowName:s,openedWorkspaces:[D0(e,t)],props:r,maximized:!1}],isMostRecentlyOpenedWindowHidden:!1}),!0);if(u>=0){let n=a.openedWindows[u],o=a.openedGroup?.props??{},i=a.isMostRecentlyOpenedWindowHidden,{openedWorkspaces:c}=n;if(DB(n.props,r)){let d=c.find(t=>t.workspaceName===e);return d&&DB(d.props,t)?((i||u!==a.openedWindows.length-1)&&lh.setState(DY.restoreWindow(a,s)),!0):!!await DW({reason:"CLOSE_WORKSPACE",explicit:!1,windowName:s,workspaceName:e})&&(lh.setState({...a,openedGroup:{groupName:l.name,props:a?.openedGroup?.props??o},openedWindows:[...a.openedWindows.filter((e,t)=>t!==u),{windowName:s,openedWorkspaces:[D0(e,t)],props:n?.props??r,maximized:!1}],isMostRecentlyOpenedWindowHidden:!1}),!0)}return!!await DW({reason:"CLOSE_WINDOW",explicit:!1,windowName:s})&&(lh.setState({...a,openedGroup:{groupName:l.name,props:o??a?.openedGroup?.props},openedWindows:[...a.openedWindows.filter((e,t)=>t!==u),{windowName:s,openedWorkspaces:[D0(e,t)],props:r,maximized:!1}],isMostRecentlyOpenedWindowHidden:!1}),!0)}return"closable"!=l.persistence?(lh.setState({...a,openedGroup:{groupName:l.name,props:n??a?.openedGroup?.props??null},openedWindows:[...a.openedWindows,{windowName:s,openedWorkspaces:[D0(e,t)],props:r,maximized:!1}],isMostRecentlyOpenedWindowHidden:!1}),!0):!!await DW({reason:"CLOSE_OTHER_WINDOWS",explicit:!1,windowNameToSpare:o.name})&&(lh.setState({...a,openedGroup:{groupName:l.name,props:n??a?.openedGroup?.props??null},openedWindows:[{windowName:s,openedWorkspaces:[D0(e,t)],props:r,maximized:!1}],isMostRecentlyOpenedWindowHidden:!1}),!0)}function DB(e,t){return null==e||null==t||O(e,t)}function DV(e,t){let r=[];for(let n=e.openedWorkspaces.length-1;n>=0;n--){let a=e.openedWorkspaces[n];if(a.hasUnsavedChanges&&r.push(a),t&&a.workspaceName===t)break}return r}function DU(e){return 0===e.length?Promise.resolve(!0):new Promise(t=>{let r=E5("workspace2-close-prompt",{size:"sm",onConfirm:()=>{r(),t(!0)},onCancel:()=>{r(),t(!1)},affectedWorkspaceTitles:e.map(e=>e.title??"")})})}function DW(e){let{openedWindows:t}=lh.getState(),r=[];switch(e.reason){case"CLOSE_WORKSPACE_GROUP":r=t.flatMap(e=>DV(e));break;case"CLOSE_WINDOW":{let n=t.find(t=>t.windowName===e.windowName);if(!n)throw Error(`Window ${e.windowName} not found in opened windows.`);r=DV(n);break}case"CLOSE_WORKSPACE":{let n=t.find(t=>t.windowName===e.windowName);if(!n)throw Error(`Window ${e.windowName} not found in opened windows.`);r=DV(n,e.workspaceName);break}case"CLOSE_OTHER_WINDOWS":r=t.filter(t=>t.windowName!==e.windowNameToSpare).flatMap(e=>DV(e))}return DU(r)}function DH(e,t){return DU(DV(e,t))}function Dz(e,t){let r=e.openedWorkspaces.findIndex(e=>e.workspaceName===t);return r<0?e:0===r?null:{...e,openedWorkspaces:e.openedWorkspaces.slice(0,r)}}function DK(e,t,r,n){let{registeredWorkspacesByName:a}=lh.getState(),o=a[r];if(!o)throw Error(`No workspace named "${r}" registered`);let i=a[t];if(!i)throw Error(`No workspace named "${t}" registered`);if(i.window!==o.window)throw Error(`Child workspace ${r} does not belong to the same workspace window as parent workspace ${t}`);if(o.window!==e.windowName)throw Error(`Cannot open child workspace ${r} as window ${o.window} is not opened`);let{openedWorkspaces:s}=e,l=s.findIndex(e=>e.workspaceName===t);if(-1===l)throw Error(`Cannot open child workspace ${r} from parent workspace ${t} as the parent is not opened within the workspace window`);let u=s.slice(0,l+1);return{...e,openedWorkspaces:[...u,D0(r,n)]}}function DG(e,t,r){let n=e.openedWorkspaces.findIndex(e=>e.uuid===t);if(n<0)return e;let a=e.openedWorkspaces[n];if(Object.keys(r).every(e=>a[e]===r[e]))return e;let o=[...e.openedWorkspaces];return o[n]={...a,...r},{...e,openedWorkspaces:o}}function DZ(e,t,r){let n=e.openedWindows.findIndex(e=>e.openedWorkspaces.some(e=>e.uuid===t));if(n<0)return e;let a=e.openedWindows[n],o=DG(a,t,r);if(o===a)return e;let i=[...e.openedWindows];return i[n]=o,{...e,openedWindows:i}}let DY={setWindowMaximized(e,t,r){let n=e.openedWindows.findIndex(e=>e.windowName===t),a=[...e.openedWindows],o={...a[n],maximized:r};return a[n]=o,{...e,openedWindows:a}},hideWindow:e=>({...e,isMostRecentlyOpenedWindowHidden:!0}),restoreWindow(e,t){let r=e.openedWindows.findIndex(e=>e.windowName===t),n=e.openedWindows[r],a=[...e.openedWindows.filter((e,t)=>t!==r),n];return{...e,openedWindows:a,isMostRecentlyOpenedWindowHidden:!1}},closeWorkspace(e,t){let r=e.openedWindows.findIndex(e=>e.openedWorkspaces.some(e=>e.workspaceName===t));if(r<0)return e;let n=Dz(e.openedWindows[r],t),a=[...e.openedWindows],o=e.isMostRecentlyOpenedWindowHidden;if(null===n){let t=r===e.openedWindows.length-1;a.splice(r,1),t&&a.length>0&&(o=!1)}else a[r]=n;return{...e,openedWindows:a,isMostRecentlyOpenedWindowHidden:o}},openChildWorkspace(e,t,r,n){let a=e.registeredWorkspacesByName[r];if(!a)throw Error(`No workspace named "${r}" registered`);let o=e.openedWindows.findIndex(e=>e.windowName===a.window);if(-1==o)throw Error(`Cannot open child workspace ${r} as window ${a.window} is not opened`);let i=[...e.openedWindows];return i[o]=DK(e.openedWindows[o],t,r,n),{...e,openedWindows:i}},setHasUnsavedChanges:(e,t,r)=>DZ(e,t,{hasUnsavedChanges:r}),setWorkspaceTitle:(e,t,r)=>DZ(e,t,{title:r})};function Dq(){return lB(lh,DY)}let DJ=()=>(0,lT.useContext)(l2),DX=()=>Object.keys(lh.getState().registeredWorkspacesByName);function DQ(e,t,r){let n=e.openedWorkspaces[e.openedWorkspaces.length-1];return(n?t[n.workspaceName]?.width:void 0)??r[e.windowName]?.width??"narrow"}function D0(e,t){return{workspaceName:e,props:t??{},hasUnsavedChanges:!1,uuid:DM()}}function D1(e,t,r){let n=lh.getState().registeredWorkspacesByName[e];return n?{windowName:n.window,openedWorkspaces:[D0(e,t)],props:r??null,maximized:!1}:null}let D4=({title:e,children:t,hasUnsavedChanges:r=!1})=>{let{setHasUnsavedChanges:n,setWorkspaceTitle:a}=DJ();return(0,lT.useEffect)(()=>{n(r??!1)},[r,n]),(0,lT.useEffect)(()=>{a(e)},[e,a]),(0,lN.jsx)(lN.Fragment,{children:t})};function D2(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 D3(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?D2(Object(r),!0).forEach(function(t){D5(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):D2(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function D6(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function D5(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function D9(e){return(D9=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function D8(e,t){return(D8=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function D7(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}var Se=function(e){var t=lT.Component;if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");i.prototype=Object.create(t&&t.prototype,{constructor:{value:i,writable:!0,configurable:!0}}),t&&D8(i,t);var r,n,a,o=(r=function(){if("u"<typeof Reflect||!Reflect.construct||Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}(),function(){var e,t=D9(i);e=r?Reflect.construct(t,arguments,D9(this).constructor):t.apply(this,arguments);if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw TypeError("Derived constructors may only return object or undefined");return D7(this)});function i(e){var t;if(function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,i),D5(D7(t=o.call(this,e)),"handleRef",function(e){t.el=e}),D5(D7(t),"addThingToDo",function(e,r){t.state.hasError&&"unmount"!==e||(t.nextThingToDo=(t.nextThingToDo||Promise.resolve()).then(function(){if(!t.unmounted||"unmount"===e)return r.apply(void 0,arguments)}).catch(function(r){throw t.nextThingToDo=Promise.resolve(),t.setState({hasError:!0}),r&&r.message&&(r.message="During '".concat(e,"', parcel threw an error: ").concat(r.message)),t.props.handleError?t.props.handleError(r):setTimeout(function(){throw r}),r}))}),D5(D7(t),"getParcelProps",function(){var e=D3(D3({},t.props),{},{domElement:t.el});return delete e.mountParcel,delete e.config,delete e.wrapWith,delete e.wrapStyle,delete e.appendTo,delete e.handleError,delete e.parcelDidMount,e}),t.state={hasError:!1},!e.config)throw Error("single-spa-react's Parcel component requires the 'config' prop to either be a parcel config or a loading function that returns a promise. See https://github.com/single-spa/single-spa-react");return t}return n=[{key:"componentDidMount",value:function(){var e=this;this.unmounted=!1,this.addThingToDo("mount",function(){var t,r=e.props.mountParcel||e.mountParcel;if(!r)throw Error("\n <Parcel /> was not passed a mountParcel prop, nor is it rendered where mountParcel is within the React context.\n If you are using <Parcel /> within a module that is not a single-spa application, you will need to import mountRootParcel from single-spa and pass it into <Parcel /> as a mountParcel prop \n ");return e.el?t=e.el:(e.createdDomElement=t=document.createElement(e.props.wrapWith),Object.keys(e.props.wrapStyle).forEach(function(r){t.style[r]=e.props.wrapStyle[r]}),e.props.appendTo.appendChild(t)),e.parcel=r(e.props.config,D3({domElement:t},e.getParcelProps())),e.parcel.mountPromise.then(e.props.parcelDidMount),e.parcel.mountPromise})}},{key:"componentDidUpdate",value:function(){var e=this;this.addThingToDo("update",function(){if(e.parcel&&e.parcel.update)return e.parcel.update(e.getParcelProps())})}},{key:"componentWillUnmount",value:function(){var e=this;this.addThingToDo("unmount",function(){if(e.parcel&&"MOUNTED"===e.parcel.getStatus())return e.parcel.unmount()}),this.createdDomElement&&this.createdDomElement.parentNode.removeChild(this.createdDomElement),this.unmounted=!0}},{key:"render",value:function(){var e=this;if(this.props.appendTo)return l2&&l2.Consumer?lT.createElement(l2.Consumer,null,function(t){return e.mountParcel=t?t.mountParcel:null,null}):null;var t=l2&&l2.Consumer?lT.createElement(l2.Consumer,null,function(t){return e.mountParcel=t?t.mountParcel:null,null}):void 0;return lT.createElement(this.props.wrapWith,{ref:this.handleRef,style:this.props.wrapStyle,className:this.props.wrapClassName},t)}}],D6(i.prototype,n),a&&D6(i,a),i}();D5(Se,"defaultProps",{wrapWith:"div",wrapStyle:{},parcelDidMount:function(){}});var St=r(8742);let Sr=lO().forwardRef(function({children:e,size:t=16,...r},n){return 16===t||"16"===t||"16px"===t?lO().createElement(St.A,{width:t,height:t,ref:n,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 16 16",fill:"currentColor",...r},er||(er=lO().createElement("path",{d:"M2 9L2 10 5.3 10 1 14.3 1.7 15 6 10.7 6 14 7 14 7 9zM14 7L14 6 10.7 6 15 1.7 14.3 1 10 5.3 10 2 9 2 9 7z"})),e):lO().createElement(St.A,{width:t,height:t,ref:n,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",fill:"currentColor",...r},en||(en=lO().createElement("path",{d:"M4 18L4 20 10.586 20 2 28.582 3.414 30 12 21.414 12 28 14 28 14 18 4 18zM30 3.416L28.592 2 20 10.586 20 4 18 4 18 14 28 14 28 12 21.414 12 30 3.416z"})),e)});var Sn=r(4240),Sa=r(8622);let So={workspaceOuterContainer:"-esm-patient-programs__workspace2-module__workspaceOuterContainer___jaqGm",narrowWorkspace:"-esm-patient-programs__workspace2-module__narrowWorkspace___o1wsL",widerWorkspace:"-esm-patient-programs__workspace2-module__widerWorkspace___gdEOi",extraWideWorkspace:"-esm-patient-programs__workspace2-module__extraWideWorkspace___U9xlJ",workspaceMiddleContainer:"-esm-patient-programs__workspace2-module__workspaceMiddleContainer___0AdtX",maximized:"-esm-patient-programs__workspace2-module__maximized___aKCbE",hidden:"-esm-patient-programs__workspace2-module__hidden___n1US5",workspaceInnerContainer:"-esm-patient-programs__workspace2-module__workspaceInnerContainer___1g+qk",workspaceSpacer:"-esm-patient-programs__workspace2-module__workspaceSpacer___P2T9y",loader:"-esm-patient-programs__workspace2-module__loader___fCfzZ",hiddenExtraWorkspace:"-esm-patient-programs__workspace2-module__hiddenExtraWorkspace___hvPSi",header:"-esm-patient-programs__workspace2-module__header___MXXx9",headerButtons:"-esm-patient-programs__workspace2-module__headerButtons___sJdnC",workspaceContent:"-esm-patient-programs__workspace2-module__workspaceContent___6NuXT",overlayHeaderSpacer:"-esm-patient-programs__workspace2-module__overlayHeaderSpacer___PLO6T",isActionMenuOpened:"-esm-patient-programs__workspace2-module__isActionMenuOpened___X3Vj6",showActionMenu:"-esm-patient-programs__workspace2-module__showActionMenu___HSun1",marginWorkspaceContent:"-esm-patient-programs__workspace2-module__marginWorkspaceContent___DCfWz",workspaceContainerWithActionMenu:"-esm-patient-programs__workspace2-module__workspaceContainerWithActionMenu___G9MdI",workspaceFixedContainer:"-esm-patient-programs__workspace2-module__workspaceFixedContainer___uIldI",workspaceContainerWithoutActionMenu:"-esm-patient-programs__workspace2-module__workspaceContainerWithoutActionMenu___lBudZ"},Si=e=>e.registeredWorkspacesByName,Ss=({lifeCycle:e,openedWorkspace:t,openedWindow:r,groupProps:n,actions:a,renderChrome:o,isRootWorkspace:i,isLeafWorkspace:s,showActionMenu:l})=>{let u=(0,lT.useMemo)(()=>t&&{closeWorkspace:async(e={})=>{let{closeWindow:n=!1,discardUnsavedChanges:o=!1}=e;return n?!!(o||await a.promptForClosingWorkspaces())&&(a.closeWorkspace(r.openedWorkspaces[0].workspaceName),!0):!!(o||await a.promptForClosingWorkspaces(t.workspaceName))&&(a.closeWorkspace(t.workspaceName),!0)},launchChildWorkspace:async(e,n)=>{let o=t.workspaceName,{openedWorkspaces:i}=r,s=i.findIndex(e=>e.workspaceName===o);-1===s||s!==i.length-1&&i.slice(s+1).some(e=>e.hasUnsavedChanges)&&!await a.promptForClosingWorkspaces(i[s+1].workspaceName)||a.openChildWorkspace(o,e,n||{})},setWorkspaceTitle:e=>a.setWorkspaceTitle(t.uuid,e),setHasUnsavedChanges:e=>a.setHasUnsavedChanges(t.uuid,e),workspaceName:t.workspaceName,workspaceProps:t.props,windowProps:r.props,groupProps:n,workspaceMeta:lh.getState().registeredWorkspacesByName[t.workspaceName]?.meta??{},isRootWorkspace:i,isLeafWorkspace:s,windowName:r.windowName,showActionMenu:l},[t,r,n,a,i,s,l]),c=!o&&!s,d=(0,lT.useMemo)(()=>e?(0,lN.jsx)(Se,{config:e,mountParcel:lP,wrapWith:"div",wrapClassName:cM()(So.workspaceContent,{[So.hiddenExtraWorkspace]:c}),...u},t.workspaceName):null===e?(0,lN.jsx)("div",{className:cM()(So.workspaceContent,{[So.hiddenExtraWorkspace]:c}),children:(0,lN.jsx)(cV.InlineNotification,{kind:"error",title:ot("error"),subtitle:ot("somethingWentWrongTryReloading"),hideCloseButton:!0})}):null,[e,t.workspaceName,u,c]);return o?(0,lN.jsx)("div",{children:(0,lN.jsx)(Sl,{openedWorkspace:t,openedWindow:r,isRootWorkspace:i,showActionMenu:l,closeWindow:()=>u.closeWorkspace({closeWindow:!0}),children:d})}):d??(0,lN.jsx)(cV.InlineLoading,{className:cM()(So.loader,{[So.hiddenExtraWorkspace]:c}),description:`${ot("loading")}`})},Sl=({openedWorkspace:e,openedWindow:t,isRootWorkspace:r,showActionMenu:n,closeWindow:a,children:o})=>{let i=u6(),{openedGroup:s,openedWindows:l,registeredWindowsByName:u,registeredWorkspacesByName:c,registeredGroupsByName:d,isMostRecentlyOpenedWindowHidden:p,setWindowMaximized:m,hideWindow:f}=Dq(),h=t.windowName,{maximized:g}=t,y=e.title??"",v=u[h],b=DQ(t,c,u),w=v?.icon,E=v?.canMaximize,x=!!s&&d[s.groupName]?.persistence==="closable",D=!!w&&!x,S=l.findIndex(e=>e.windowName===h)<l.length-1||p,_=Object.values(u).some(e=>e.group===s?.groupName&&void 0!==e.icon);return(0,lN.jsxs)("div",{className:cM()(So.workspaceOuterContainer,{[So.narrowWorkspace]:"narrow"===b,[So.widerWorkspace]:"wider"===b,[So.extraWideWorkspace]:"extra-wide"===b,[So.isActionMenuOpened]:_}),children:[(0,lN.jsx)("div",{className:cM()(So.workspaceSpacer,{[So.hidden]:S})}),(0,lN.jsx)("div",{className:cM()(So.workspaceMiddleContainer,{[So.maximized]:g,[So.hidden]:S,[So.isRootWorkspace]:r,[So.showActionMenu]:n}),children:(0,lN.jsx)("div",{className:cM()(So.workspaceInnerContainer,{[So.maximized]:g,[So.hidden]:S,[So.isRootWorkspace]:r}),children:o?(0,lN.jsxs)(lN.Fragment,{children:[(0,lN.jsxs)(cV.Header,{"aria-label":ot("workspaceHeader"),className:So.header,children:[(0,lN.jsx)(cV.HeaderName,{prefix:"",children:y}),(0,lN.jsx)("div",{className:So.overlayHeaderSpacer}),(0,lN.jsx)(cV.HeaderGlobalBar,{className:So.headerButtons,children:u5(i)?(0,lN.jsxs)(lN.Fragment,{children:[(E||g)&&(0,lN.jsx)(cV.HeaderGlobalAction,{"aria-label":g?ot("minimize"):ot("maximize"),onClick:()=>m(h,!g),children:g?(0,lN.jsx)(Sr,{}):(0,lN.jsx)(Sn.hz,{})}),D&&(0,lN.jsx)(cV.HeaderGlobalAction,{"aria-label":ot("hide"),onClick:()=>f(),children:(0,lN.jsx)(c3,{})}),!x&&(0,lN.jsx)(cV.HeaderGlobalAction,{"aria-label":ot("close"),onClick:a,children:(0,lN.jsx)(dm,{})})]}):(0,lN.jsxs)(lN.Fragment,{children:[D&&(0,lN.jsx)(cV.HeaderGlobalAction,{"aria-label":ot("hide"),onClick:()=>f(),children:(0,lN.jsx)(Sa.d3,{})}),(0,lN.jsx)(cV.HeaderGlobalAction,{"aria-label":ot("close"),onClick:()=>{x?DL():a()},children:(0,lN.jsx)(dm,{})})]})})]}),o]}):(0,lN.jsx)(cV.InlineLoading,{className:So.loader,description:`${ot("loading")} ...`})})})]})},Su=({openedWindow:e,groupProps:t,actions:r,renderChrome:n,showActionMenu:a})=>{let{openedWorkspaces:o}=e,[i,s]=(0,lT.useState)({}),l=lF(lh,Si),u=(0,lT.useRef)(new Set);return(0,lT.useEffect)(()=>{let e=!1;return Promise.all(o.map(async t=>{let r=l[t.workspaceName];if(!r)return null;let{moduleName:n,component:a}=r;try{return[t.uuid,await cS(n,a)]}catch(r){return e||u.current.has(t.uuid)||(u.current.add(t.uuid),P(r)),[t.uuid,null]}})).then(t=>{e||s(Object.fromEntries(t.filter(e=>null!=e)))},P),()=>{e=!0}},[o,l]),(0,lN.jsx)(lN.Fragment,{children:o.map((s,l)=>(0,lN.jsx)(Ss,{openedWorkspace:s,openedWindow:e,groupProps:t,actions:r,renderChrome:n,lifeCycle:i[s.uuid],isRootWorkspace:0===l,isLeafWorkspace:l===o.length-1,showActionMenu:a},s.uuid))})},Sc=e=>e.registeredWorkspacesByName,Sd=({name:e,workspaceProps:t,windowProps:r,groupProps:n,onWindowChanged:a})=>{let o=lF(lh,Sc),i=lF(lh,t=>{let r=t.registeredWorkspacesByName[e]?.window;return r?t.registeredWindowsByName[r]:void 0}),s={name:e,workspaceProps:t,windowProps:r,groupProps:n},l=(0,lT.useRef)(null),u=(0,lT.useRef)(null);if(!l.current){let a=D1(e,t,r);l.current=U({openedWindow:a,groupProps:n??null}),a&&(u.current=s)}let c=l.current;(0,lT.useEffect)(()=>{let a=u.current;if(a&&a.name===e&&O(a.workspaceProps,t)&&O(a.windowProps,r)&&O(a.groupProps,n))return;let o=D1(e,t,r);c.setState({openedWindow:o,groupProps:n??null},!0),u.current=o?s:null},[e,t,r,n,o,c]);let d=(0,lT.useMemo)(()=>(function(e){function t(t){e.setState(e=>{if(!e.openedWindow)return e;let r=t(e.openedWindow);return r===e.openedWindow?e:{...e,openedWindow:r}})}return{closeWorkspace(e){t(t=>Dz(t,e))},openChildWorkspace(e,r,n){t(t=>DK(t,e,r,n))},setWorkspaceTitle(e,r){t(t=>DG(t,e,{title:r}))},setHasUnsavedChanges(e,r){t(t=>DG(t,e,{hasUnsavedChanges:r}))},promptForClosingWorkspaces(t){let{openedWindow:r}=e.getState();return r?DH(r,t):Promise.resolve(!0)}}})(c),[c]),{openedWindow:p,groupProps:m}=lF(c),f=p?.openedWorkspaces[p.openedWorkspaces.length-1],h=f?.workspaceName??null,g=f?.title??"",y=p?.openedWorkspaces.some(e=>e.hasUnsavedChanges)??!1,v=i?.width??"narrow",b=(0,lT.useRef)(a);return(0,lT.useEffect)(()=>{b.current=a}),(0,lT.useEffect)(()=>{b.current?.({workspaceName:h,windowWidth:v,title:g,hasUnsavedChanges:y})},[h,v,g,y]),(0,lN.jsx)("div",{className:"-esm-patient-programs__exported-workspace-module__exportedWorkspace___3vwoL",children:p?(0,lN.jsx)(Su,{openedWindow:p,groupProps:m,actions:d,renderChrome:!1,showActionMenu:!1}):null})},Sp="-esm-patient-programs__action-menu-button2-module__container___pahg-",Sm="-esm-patient-programs__action-menu-button2-module__elementContainer___PzOdc",Sf="-esm-patient-programs__action-menu-button2-module__active___4O4Bs",Sh="-esm-patient-programs__action-menu-button2-module__focused___+k5kD";function Sg({getIcon:e,hasUnsavedChanges:t,tagContent:r}){return(0,lN.jsxs)(lN.Fragment,{children:[e({size:16}),t?(0,lN.jsx)("span",{className:"-esm-patient-programs__action-menu-button2-module__interruptedTag___mS2yr",children:"!"}):(0,lN.jsx)("span",{className:"-esm-patient-programs__action-menu-button2-module__countTag___rb5CW",children:r})]})}let Sy=({icon:e,label:t,tagContent:r,workspaceToLaunch:n,onBeforeWorkspaceLaunch:a,hidden:o,disabled:i})=>{let s=u6(),{openedWindows:l,restoreWindow:u,hideWindow:c,isMostRecentlyOpenedWindowHidden:d}=Dq(),{extension:p}=(0,lT.useContext)(l$),m=l.findIndex(e=>e.windowName===p?.extensionId),f=l[m],h=null!=f,g=h&&(m<l.length-1||d),y=h&&!g,v=f?.openedWorkspaces.some(e=>e.hasUnsavedChanges)??!1,b=async()=>{if(h)g?u(f.windowName):c();else if(await (a?.()??!0)){let{workspaceName:e,workspaceProps:t,windowProps:r}=n;DF(e,t,r)}};return o?.(l)?null:"tablet"===s||"phone"===s?(0,lN.jsxs)(cV.Button,{className:cM()(Sp,{[Sf]:h&&!y,[Sh]:y}),iconDescription:t,kind:"ghost",onClick:b,role:"button",tabIndex:0,size:"md",disabled:i?.(l),children:[(0,lN.jsx)("span",{className:Sm,children:(0,lN.jsx)(Sg,{hasUnsavedChanges:v,getIcon:e,tagContent:r})}),(0,lN.jsx)("span",{children:t})]}):(0,lN.jsx)(cV.IconButton,{align:"left","aria-label":t,className:cM()(Sp,{[Sf]:h&&!y,[Sh]:y}),enterDelayMs:300,kind:"ghost",label:t,onClick:b,size:"md",disabled:i?.(l),children:(0,lN.jsx)("div",{className:Sm,children:(0,lN.jsx)(Sg,{hasUnsavedChanges:v,getIcon:e,tagContent:r})})})};function Sv({showContactDetails:e,toggleContactDetails:t,className:r}){return(0,lN.jsx)(cV.Button,{className:r,iconDescription:"Toggle contact details",kind:"ghost",onClick:t,renderIcon:e?dp:du,children:e?ot("showLess","Show less"):ot("showMore","Show more")})}let Sb={contactDetails:"-esm-patient-programs__patient-banner-contact-details-module__contactDetails___rhdjA",deceased:"-esm-patient-programs__patient-banner-contact-details-module__deceased___K4NPg",heading:"-esm-patient-programs__patient-banner-contact-details-module__heading___zj6Zt",row:"-esm-patient-programs__patient-banner-contact-details-module__row___+Bx+P",col:"-esm-patient-programs__patient-banner-contact-details-module__col___0H31P",relationship:"-esm-patient-programs__patient-banner-contact-details-module__relationship___CZmay"},Sw=({patientUuid:e})=>{let{cohorts:t=[],isLoading:r}=function(e){let t=e?`${of}/cohortm/cohortmember?patient=${e}&v=custom:(uuid,patient:ref,cohort:(uuid,name,startDate,endDate))`:null,{data:r,isLoading:n}=un()(t,ov),a=r?.data?.results.map(e=>({uuid:e.cohort.uuid,name:e.cohort.name,startDate:e.cohort.startDate,endDate:e.cohort.endDate}));return(0,lT.useMemo)(()=>({cohorts:a,isLoading:n}),[n,a])}(e);return(0,lN.jsxs)(lN.Fragment,{children:[(0,lN.jsxs)("p",{className:Sb.heading,children:[ot("patientLists","Patient Lists")," (",t?.length??0,")"]}),r?(0,lN.jsx)(cV.InlineLoading,{description:`${ot("loading","Loading")} ...`,role:"progressbar"}):(0,lN.jsxs)("ul",{children:[(()=>{if(t?.length>0){let e=t.sort((e,t)=>wT(e?.startDate).getTime()-wT(t?.startDate).getTime()).slice(0,3);return e?.map(e=>(0,lN.jsx)("li",{children:(0,lN.jsx)(lI,{to:`${window.spaBase}/home/patient-lists/${e.uuid}`,children:e.name},e.uuid)},e.uuid))}return(0,lN.jsx)("li",{children:"--"})})(),t.length>3&&(0,lN.jsx)("li",{className:Sb.link,children:(0,lN.jsx)(lI,{to:`${window.spaBase}/home/patient-lists`,children:ot("seeMoreLists","See {{count}} more lists",{count:t?.length-3})})})]})]})},SE=({patientId:e})=>{let{patient:t,isLoading:r}=cs(e),n=t?.address?.find(e=>"home"===e.use),a=e=>e.split("#")[1];return r?(0,lN.jsx)(cV.InlineLoading,{description:`${ot("loading","Loading")} ...`,role:"progressbar"}):(0,lN.jsxs)(lN.Fragment,{children:[(0,lN.jsx)("p",{className:Sb.heading,children:ot("address","Address")}),(0,lN.jsx)("ul",{children:n?Object.entries(n).filter(([e])=>"id"!==e&&"use"!==e).map(([e,t])=>"extension"===e?n.extension?.[0]?.extension?.map((t,r)=>(0,lN.jsxs)("li",{children:[ot(a(t.url),a(t.url)),": ",t.valueString]},`address-${e}-${r}`)):(0,lN.jsxs)("li",{children:[ot(e,e),": ",t]},`address-${e}`)):(0,lN.jsx)("li",{children:"--"})})]})},Sx=({patientUuid:e})=>{let{isLoading:t,contactAttributes:r}=(e=>{let{contactAttributeTypes:t=[]}=u$({externalModuleName:"@openmrs/esm-patient-banner-app"}),{attributes:r,error:n,isLoading:a}=(e=>{let{data:t,error:r,isLoading:n}=uM()(`${of}/patient/${e}?v=custom:(uuid,display,identifiers:(identifier,uuid,preferred,location:(uuid,name),identifierType:(uuid,name,format,formatDescription,validator)),person:(uuid,display,gender,birthdate,dead,age,deathDate,birthdateEstimated,causeOfDeath,preferredName:(uuid,preferred,givenName,middleName,familyName),attributes,preferredAddress:(uuid,preferred,address1,address2,cityVillage,longitude,stateProvince,latitude,country,postalCode,countyDistrict,address3,address4,address5,address6,address7)))`,ov);return{isLoading:n,attributes:t?.data.person.attributes??[],error:r}})(e);return{contactAttributes:(0,lT.useMemo)(()=>r.filter(({attributeType:e})=>t?.some(t=>e.uuid===t)),[r,t]),isLoading:a,error:n}})(e),n=(0,lT.useMemo)(()=>r?[...r?.map(e=>[e.attributeType.display?ot(e.attributeType.display,e.attributeType.display):"",e.value])]:[],[r]);return(0,lN.jsxs)(lN.Fragment,{children:[(0,lN.jsx)("p",{className:Sb.heading,children:ot("contactDetails","Contact Details")}),t?(0,lN.jsx)(cV.InlineLoading,{description:`${ot("loading","Loading")} ...`,role:"progressbar"}):(0,lN.jsx)("ul",{children:n.length?n.map(([e,t],r)=>(0,lN.jsxs)("li",{children:[e,": ",t]},`${e}-${t}-${r}`)):(0,lN.jsx)("li",{children:"--"})})]})},SD=({patientId:e})=>{let{data:t,isLoading:r}=function(e){let t=`${of}/relationship?v=custom:(display,uuid,personA:(age,display,birthdate,uuid),personB:(age,display,birthdate,uuid),relationshipType:(uuid,display,description,aIsToB,bIsToA))&person=${e}`,{data:r,error:n,isLoading:a,isValidating:o}=un()(e?t:null,ov),i=r?.data?.results?.length?function(e,t){let r=[];for(let n of t)e===n.personA.uuid?r.push({uuid:`${n.uuid}`,display:n.personB.display,relativeAge:n.personB.age,relativeUuid:n.personB.uuid,relationshipType:n.relationshipType.bIsToA}):r.push({uuid:`${n.uuid}`,display:n.personA.display,relativeAge:n.personA.age,relativeUuid:n.personA.uuid,relationshipType:n.relationshipType.aIsToB});return r}(e,r.data.results):null;return{data:r?i:null,error:n,isLoading:a,isValidating:o}}(e);return(0,lN.jsxs)(lN.Fragment,{children:[(0,lN.jsx)("p",{className:Sb.heading,children:ot("relationships","Relationships")}),r?(0,lN.jsx)(cV.InlineLoading,{description:`${ot("loading","Loading")} ...`,role:"progressbar"}):(0,lN.jsx)("ul",{children:t&&t.length>0?(0,lN.jsx)(lN.Fragment,{children:t.map(e=>(0,lN.jsxs)("li",{className:Sb.relationship,children:[(0,lN.jsx)("div",{children:(0,lN.jsx)(lI,{to:`${window.spaBase}/patient/${e.relativeUuid}/chart`,children:e.display})}),(0,lN.jsx)("div",{children:e.relationshipType}),(0,lN.jsx)("div",{children:`${e.relativeAge?e.relativeAge:"--"} ${e.relativeAge?1===e.relativeAge?ot("yearAbbreviation","yr"):ot("yearsAbbreviation","yrs"):""}`})]},e.uuid))}):(0,lN.jsx)("li",{children:"--"})})]})};function SS({patientId:e,deceased:t}){return(0,lN.jsxs)("div",{className:cM()(Sb.contactDetails,{[Sb.deceased]:t}),children:[(0,lN.jsxs)("div",{className:Sb.row,children:[(0,lN.jsx)("div",{className:Sb.col,children:(0,lN.jsx)(SE,{patientId:e})}),(0,lN.jsx)("div",{className:Sb.col,children:(0,lN.jsx)(Sx,{patientUuid:e})})]}),(0,lN.jsxs)("div",{className:Sb.row,children:[(0,lN.jsx)("div",{className:Sb.col,children:(0,lN.jsx)(SD,{patientId:e})}),(0,lN.jsx)("div",{className:Sb.col,children:(0,lN.jsx)(Sw,{patientUuid:e})})]})]})}function S_(e){let t=document.querySelector("template#loading-spinner");if(t){let r=t.content.cloneNode(!0),n=Array.prototype.map.call(r.childNodes,e=>e);return e.appendChild(r),()=>n.forEach(e=>e.remove())}return()=>{}}let SC="-esm-patient-programs__action-menu2-module__container___5s3CM";function Sk({workspaceGroup:e,groupProps:t}){let r=u6(),{persistence:n}=e;return(0,lN.jsx)("aside",{className:"-esm-patient-programs__action-menu2-module__sideRail___qwAz4",children:(0,lN.jsxs)("div",{className:SC,children:["closable"==n&&u5(r)&&(0,lN.jsx)(cV.IconButton,{align:"left",onClick:()=>DL(),label:ot("close"),kind:"ghost",children:(0,lN.jsx)(dm,{})}),(0,lN.jsx)(l$.Provider,{value:{moduleName:e.moduleName,featureName:e.name},children:(0,lN.jsx)(lY,{className:SC,name:e.name,state:{groupProps:t}})})]})})}function SP(e){let t=new URL(e,window.location.origin).pathname,r=new URL(window.getOpenmrsSpaBase?.()??"/",window.location.origin).pathname,n=r.endsWith("/")?r.slice(0,-1):r,a=null;return n?n===t?a="/":t.startsWith(`${n}/`)&&(a=t.slice(n.length)):a=t,{full:t,spaRelative:a}}function SR(e){e&&(0,lq.createRoot)(e).render((0,lN.jsx)(ST,{}))}function ST(){let{openedGroup:e,openedWindows:t,registeredGroupsByName:r,registeredWindowsByName:n}=Dq();if((0,lT.useEffect)(()=>iM("before-page-changed",t=>{let{newPage:n,cancelNavigation:a,oldUrl:o,newUrl:i}=t;if(!e)return;if(n)return void a(DL().then(e=>!e));let s=r[e.groupName],l=s?.scopePattern;l&&function(e,t,r){try{let n=new RegExp(e),a=SP(t),o=SP(r);if(null===a.spaRelative||null===o.spaRelative)return!0;let i=n.exec(a.spaRelative),s=n.exec(o.spaRelative);if(i&&s||(i=n.exec(a.full),s=n.exec(o.full)),!i||!s)return!0;if(i.length>1)return!i.slice(1).every((e,t)=>e===s[t+1]);return!1}catch{return!0}}(l,o,i)&&a(DL().then(e=>!e))}),[e,r]),!e)return null;let a=r[e.groupName],o=t.some(e=>e.maximized),{name:i}=a,s=Object.values(n).filter(e=>e.group===i&&void 0!==e.icon).sort((e,t)=>(e.order??Number.MAX_VALUE)-(t.order??Number.MAX_VALUE)).length>0;return(0,lN.jsxs)("div",{className:cM()("-esm-patient-programs__workspace-windows-and-menu-module__workspaceWindowsAndMenuContainer___gN2f4",{"-esm-patient-programs__workspace-windows-and-menu-module__overlay___fqI+X":a.overlay,"-esm-patient-programs__workspace-windows-and-menu-module__hasMaximizedWindow___J7wBw":o}),children:[(0,lN.jsx)("div",{className:"-esm-patient-programs__workspace-windows-and-menu-module__workspaceWindowsContainer___zpk7G",children:t.map(t=>(0,lN.jsx)(SO,{openedWindow:t,groupProps:e.props,showActionMenu:s},t.windowName))}),s&&(0,lN.jsx)(Sk,{workspaceGroup:a,groupProps:e.props})]})}function SO({openedWindow:e,groupProps:t,showActionMenu:r}){let{windowName:n}=e,a=(0,lT.useMemo)(()=>({closeWorkspace(e){lh.setState(t=>DY.closeWorkspace(t,e))},openChildWorkspace(e,t,r){lh.setState(n=>DY.openChildWorkspace(n,e,t,r))},setWorkspaceTitle(e,t){lh.setState(r=>DY.setWorkspaceTitle(r,e,t))},setHasUnsavedChanges(e,t){lh.setState(r=>DY.setHasUnsavedChanges(r,e,t))},promptForClosingWorkspaces(e){let t=lh.getState().openedWindows.find(e=>e.windowName===n);return t?DH(t,e):Promise.resolve(!0)}}),[n]);return(0,lN.jsx)(Su,{openedWindow:e,groupProps:t,actions:a,renderChrome:!0,showActionMenu:r})}function S$(e,t,r){if(null==e)return r;let n=bQ(e);if(!n)return console.warn(`matchLocale: invalid requested locale tag: ${JSON.stringify(e)}`),r;let a=[];for(let e of t){let t=bQ(e);if(!t){console.warn(`matchLocale: skipping invalid available locale tag: ${JSON.stringify(e)}`);continue}a.push({canonical:t,original:e})}let o=n;for(;o;){let e=a.find(e=>e.canonical===o);if(e)return e.original;let t=o+"-",r=a.find(e=>e.canonical.startsWith(t));if(r)return r.original;if("ht"===o){o="fr-HT";continue}let n=o.lastIndexOf("-");if(-1===n)break;let i=(o=o.slice(0,n)).lastIndexOf("-");-1!==i&&o.length-i==2&&(o=o.slice(0,i))}return r}function SN(e=window.localStorage){try{return e.getItem("test"),!0}catch{return!1}}function SI(e){return!!e&&e.constructor===Object}var SA=r(7229);function SM(e){let[t,r,n]=e.split(".");return`${t}.${r}.${n}`}function Sj(e,t){return SA(function(e){let t=e.indexOf("-");if(t>=0){let r=SM(e.slice(0,t)),n=e.slice(t+1);return`${r}-${n}`}return SM(e)}(t),e,{includePrerelease:!0})}async function SL(e,t={}){let r,{shouldRetry:n,getDelay:a,onError:o}=t;n=n??(e=>e<=5),a=a??(e=>(function(e,t=!1){return 1e3*Math.pow(2,t?e+1:e)})(e));let i=0;do try{return await SF(a(i)),await e()}catch(e){o?.(e,i),r=e}while(n(i++));throw r}async function SF(e){if(!(e<=0))return new Promise(t=>setTimeout(t,e))}function SB(e,t,r,n){}function SV(e){}function SU(e){return Promise.resolve([])}function SW(e){return Promise.resolve([])}function SH(e){return Promise.resolve({success:!1,result:void 0,error:"No service worker has been registered. Offline-related features have been removed from the framework."})}function Sz(e){return()=>{}}function SK(){return!0}},670(e,t,r){"use strict";r.d(t,{A:()=>n});let n=function(e,t,r){for(var n=-1,a=Object(e),o=r(e),i=o.length;i--;){var s=o[++n];if(!1===t(a[s],s,a))break}return e}}}]);