@openmrs/esm-primary-navigation-app 10.0.1-pre.5393 → 10.0.1-pre.5396

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.
@@ -4,4 +4,4 @@
4
4
  │ 1407.js (665.473 KiB)
5
5
  
6
6
 
7
- Rspack compiled with 1 warning in 7.98 s
7
+ Rspack compiled with 1 warning in 22.51 s
package/dist/9893.js CHANGED
@@ -12,7 +12,7 @@ If you're the maintainer: the 'elements' key only works with '_type' equal to 'A
12
12
  ${t}`)}return r}let e0=(e,t)=>{let n=structuredClone(t);if(!e)return n;for(let t of Object.keys(e)){let r=n[t],o=e[t];if(o&&(o.hasOwnProperty("_type")||o.hasOwnProperty("_default"))){n.hasOwnProperty(t)||(n[t]=o._default);let e=o._elements;if(r&&e1(e)){if(o._type===Q.Array&&Array.isArray(r)){let o=r.map(t=>e0(e,t));n[t]=o}else if(o._type===Q.Object)for(let t of Object.keys(r))r[t]=e0(e,r[t])}}else if(e2(o)){let e=r??{};e2(e)&&(n[t]=e0(o,e))}}return n};function e1(e){return!!e&&Object.keys(e).filter(e=>!["_default","_validators"].includes(e)).length>0}function e2(e){return"object"==typeof e&&!Array.isArray(e)&&null!==e}let e5=new Set;function e6(e,t){let n=`${e}:::${t}`;e5||(e5=new Set),e5.has(n)||(console.error(t),e5.add(n))}function e3(e){e?e5.forEach(t=>{t.startsWith(e)&&e5.delete(t)}):e5.clear()}function e8(){eE.forEach(e=>e()),eE.length=0,eP.clear(),eH.clear(),eG.clear(),ez.clear(),eI()}let e4={"Translation overrides":{_description:"Per-language overrides for frontend translations should be keyed by language code and each language dictionary contains the translation key and the display value",_type:Q.Object,_default:{},_validators:[Y(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(", ")}.`})]}},e7={"Display conditions":{privileges:{_description:"The privilege(s) the user must have to use this extension",_type:Q.Array,_default:[]},expression:{_description:"The expression that determines whether the extension is displayed",_type:Q.String,_default:void 0}},...e4},e9=(e,t)=>Y(n=>e<=n&&n<=t,`must be between ${e} and ${t}`),te=e=>{let t=e.concat(["openmrsBase","openmrsSpaBase"]);return Y(e=>{if(!e||"string"!=typeof e)return!1;let n=/\${(.*?)}/g,r=n.exec(e);for(;r;){if(!t.includes(r[1]))return!1;r=n.exec(e)}return!0},"Should be a URL or path. The allowed template parameters are "+t.map(e=>"${"+e+"}").join(", "))},tt=te([]),tn=e=>Y(t=>e.includes(t),`Must be one of the following: '${e.join("', '")}'.`),tr={inRange:e9,isUrl:tt,isUrlWithTemplateParameters:te,oneOf:tn};var to=n(64913);let ti=L("breadcrumbs",[]);function ta(e){return ts([e])}function ts(e){let t=[...tl(),...e.map(e=>({matcher:e.matcher instanceof RegExp?e.matcher:"string"==typeof e.matcher?(0,to.pathToRegexp)(e.matcher).regexp:(0,to.pathToRegexp)(e.path).regexp,settings:e}))];ti.setState(t,!0)}function tl(){return ti.getState()}function tc(e,t){if(t)return function(e,t){let[n]=e.filter(e=>e.matcher.test(t));return n}(e,t)||function(e,t){let n=t.split("/");for(;n.length>1;){n.pop();let t=tc(e,n.join("/"));if(t)return t}}(e,t)}function tu(e,t){if(e.length>0){let n=tc(e,t);if(n){let t=[n],r=tc(e,n.settings.parent);for(;void 0!==r;)t.push(r),r=tc(e,r.settings.parent);return t.reverse()}}return[]}function td(e){return tu(tl(),e)}var tm=n(480);function tp(e,t){let n=window.getOpenmrsSpaBase().replace(/\/$/,"");return tf(e,{openmrsBase:window.openmrsBase,openmrsSpaBase:n,...t}).replace(/^\/\//,"/")}function tf(e,t){return Object.keys(t).reduce((e,n)=>e.split("${"+n+"}").join(t[n]),e)}function tg({to:e,templateParams:t}){let n=window.getOpenmrsSpaBase().replace(/\/$/,""),r=tp(e,t).replace(window.location.origin,"");r.startsWith(n)?(0,tm.navigateToUrl)(r):window.location.assign(r)}let th="openmrs:history";function tw(e){let t=JSON.parse(sessionStorage.getItem(th)??"[]")||[];t.push(e),t.length>50&&(t=t.slice(-50)),sessionStorage.setItem(th,JSON.stringify(t))}function ty(){0===JSON.parse(sessionStorage.getItem(th)??"[]").length&&document.referrer&&tw(document.referrer),window.addEventListener("single-spa:routing-event",e=>{let t=t_();e.detail.originalEvent?.singleSpaTrigger=="replaceState"?(t[t.length-1]=window.location.href,sessionStorage.setItem(th,JSON.stringify(t))):!e.detail.originalEvent?.singleSpa&&t.includes(window.location.href)?tv({toUrl:window.location.href}):t[t.length-1]!==window.location.href&&tw(window.location.href)})}function t_(){return JSON.parse(sessionStorage.getItem(th)??"[]")}function tv({toUrl:e}){let t=t_(),n=t.lastIndexOf(e);if(-1!=n){let e=t.slice(0,n+1);tg({to:t[n]}),sessionStorage.setItem(th,JSON.stringify(e))}else throw Error(`URL ${e} not found in history; cannot go back to it.`)}function tb(){sessionStorage.removeItem(th)}let tx="${openmrsSpaBase}/login",tk={redirectAuthFailure:{enabled:{_type:Q.Boolean,_default:!0,_description:"Whether to redirect logged-out users to `redirectAuthFailure.url`"},url:{_type:Q.String,_default:tx,_validators:[tr.isUrl],_description:"The url to which users will be redirected when they are logged out. If set to blank, the `location` header from the response will be used."},errors:{_type:Q.Array,_default:[401],_elements:{_type:Q.Number,_validators:[tr.inRange(100,600)]},_description:"The HTTP error codes for which users will be redirected"},resolvePromise:{_type:Q.Boolean,_default:!1,_description:"Changes how requests that fail authentication are handled. Try messing with this if redirects to the login page aren't working correctly."}},followRedirects:{_type:Q.Boolean,_default:!0,_description:"Whether openmrsFetch should support redirects returned from the backend"}};function tS(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}let tj="/ws/rest/v1",tN="/ws/fhir2/R4",tC=`${tj}/session`;function tE(e){return e&&e.startsWith("http")?e:("/"!==e[0]&&(e="/"+e),window.openmrsBase+e)}function tA(e,t={}){if("string"!=typeof e)throw Error("The first argument to @openmrs/api's openmrsFetch function must be a url string");if("object"!=typeof t)throw Error("The second argument to @openmrs/api's openmrsFetch function must be a plain object.");if(!window.openmrsBase)throw Error("@openmrs/api is running in a browser that doesn't have window.openmrsBase, which is provided by openmrs-module-spa's HTML file.");let n=tE(e);if(t.headers||(t.headers={}),(0,V.A)(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,e.startsWith(tj)&&void 0===t.headers["Disable-WWW-Authenticate"]&&(t.headers["Disable-WWW-Authenticate"]="true"),e.startsWith(tN)){let e=new URL(n,window.location.toString());e.searchParams.has("_summary")||(e.searchParams.set("_summary","data"),n=e.toString())}let r=Error();return window.fetch(n,t).then(async e=>{let{redirectAuthFailure:t,followRedirects:o}=await eB("@openmrs/esm-api");if(e.ok){let t=e.headers.get("location");return(o&&t&&(n===tE(tC)||204===e.status)&&tg({to:t}),204===e.status)?(e.data=null,e):e.clone().text().then(t=>{try{t&&(e.data=JSON.parse(t))}catch(e){}return e})}return n===tE(tC)&&403===e.status||t.enabled&&t.errors.includes(e.status)?(tb(),tg({to:t.url||e.headers.get("location")||tx}),t.resolvePromise?Promise.resolve():new Promise(()=>{})):e.clone().text().then(t=>{let o=t;try{o=JSON.parse(t)}catch(e){}throw new tO(n,e,o,r)},t=>{throw new tO(n,e,null,r)})})}function tI(e,t={}){if("object"!=typeof t)throw Error("The second argument to openmrsObservableFetch must be either omitted or an object");let n=new AbortController;return t.signal=n.signal,new G.Observable(r=>{let o=!1;return tA(e,t).then(e=>{o=!0,r.next(e),r.complete()},e=>{o=!0,r.error(e)}),()=>{o||n.abort()}})}class tO extends Error{constructor(e,t,n,r){super(),tS(this,"response",void 0),tS(this,"responseBody",void 0),this.message=`Server responded with ${t.status} (${t.statusText}) for url ${e}. Check err.responseBody or network tab in dev tools for more info`,r.message=this.message,this.responseBody=n,this.response=t,this.stack=`Stacktrace for outgoing request:
13
13
  ${r.stack}
14
14
  Stacktrace for incoming response:
15
- ${this.stack}`}}let tP=L("session",{loaded:!1,session:null}),tT=0;function tR(e={includeAuthStatus:!0}){return(tT<Date.now()-6e4||!tP.getState().loaded)&&tW(),new G.Observable(t=>{let n=n=>{n.loaded&&(e.includeAuthStatus?t.next(n.session):t.next(n.session?.user))};return n(tP.getState()),tP.subscribe(n)})}function t$(){return(tT<Date.now()-6e4||!tP.getState().loaded)&&tW(),tP}function tM(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 tW(e,t){tT=Date.now();let n={};return e&&t&&(n.Authorization=`Basic ${window.btoa(`${e}:${t}`)}`),tz(tA(tC,{headers:n}))}function tD(){tP.setState({loaded:!0,session:{authenticated:!1,sessionId:""}})}function tL(e,t){var n,r;if(void 0===t)return!e;if(!e)return!0;return n=e,r=t,("string"==typeof n?!(0,z.A)(r.privileges.find(e=>n===e.display)):Array.isArray(n)?n.every(e=>!(0,z.A)(r.privileges.find(t=>e===t.display))):((0,z.A)(n)||console.error(`Could not understand privileges "${n}"`),!0))||!(0,z.A)(t.roles.find(e=>"System Developer"===e.display))}function tB(){let e,t;return new Promise(n=>{let r=r=>{r.loaded&&r.session.user&&(e=r.session.user,n(r.session.user),t&&t())};r(tP.getState()),e||(t=tP.subscribe(r))})}function tU(){return new Promise((e,t)=>{tR().subscribe(t=>{e(t.sessionLocation)},t).unsubscribe()})}async function tF(e,t){return tz(tA(tC,{method:"POST",body:{sessionLocation:e},headers:{"Content-Type":"application/json"},signal:t.signal}))}async function tH(e,t,n){return n||(n=new AbortController),await tA(`${tj}/user/${e}`,{method:"POST",body:{userProperties:t},headers:{"Content-Type":"application/json"},signal:n.signal}),tW()}function tz(e){return new Promise((t,n)=>{e.then(e=>{let r;"object"==typeof e?.data?(r={loaded:!0,session:e.data},tP.setState(r),t(r)):(r={loaded:!1,session:null},tP.setState(r),n(r))}).catch(e=>{j(`Failed to fetch new session information: ${e}`);let t={loaded:!1,session:null};tP.setState(t),n(t)})})}function tG(){return"development"===window.spaEnv||"true"===localStorage.getItem("openmrs:devtools")}tP.subscribe(e=>{e.loaded&&e.session&&tM(e.session)});let tV={"webservices.rest":"2.24.0",fhir2:"1.0.0-SNAPSHOT"};function tJ(){eT("@openmrs/esm-api",tk),tW()}let tq={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",batchActionItemSelected:"{{totalSelected}} item selected",batchActionsItemsSelected:"{{totalSelected}} items selected",cancel:"Cancel",change:"Change",Clinic:"Clinic",close:"Close",closesActionableNotification:"Close actionable notification",closeSnackbar:"Close snackbar",confirm:"Confirm",contactAdministratorIfIssuePersists:"Contact your system administrator if the problem persists.",contactDetails:"Contact details",delete:"Delete",discardChanges:"Discard changes",edit:"Edit",emptyStateText:"There are no {{displayText}} to display",error:"Error",errorCopy:"Sorry, there was a problem displaying this information. You can try to reload this page, or contact the site administrator and quote the error code above.",errorLoadingLoginLocations:"Unable to load login locations. Please try again or contact support if the problem persists.",female:"Female",leftNavigation:"Left navigation",loading:"Loading",localVersion:"Local Build",male:"Male",noResultsToDisplay:"No results to display",notAvailable:"Not available",other:"Other",paginationItemsCount:"{{pageItemsCount}} / {{totalItems}} items",paginationOfPages:"of {{count}} pages",patientAvatarAlt:"Avatar for {{patientName}}",patientIdentifierSticker:"Patient identifier sticker",patientLists:"Patient lists",patientPhotoAlt:"Profile photo of {{patientName}}",patientPhotoPlaceholder:"Photo placeholder for {{patientName}}",prereleaseVersion:"Prerelease",print:"Print",printError:"Print error",printErrorExplainer:"An error occurred in {{errorLocation}}",printIdentifierSticker:"Print identifier sticker",printing:"Printing",recordNewEntry:"Record {{displayText}}",relationships:"Relationships",resetOverrides:"Reset overrides",save:"Save",scriptLoadingFailed:"Error: Script failed to load",scriptLoadingError:"Failed to load overridden script from {{url}}. Please check that the bundled script is available at the expected URL. Click the button below to reset all import map overrides.",searchForLocation:"Search for a location",seeAll:"See all",seeMoreLists:"See {{count}} more lists",selectAll:"Select all",sex:"Sex",showLess:"Show less",showMore:"Show more",snackbarNotification:"Snackbar notification",toggleDevTools:"Toggle dev tools",unknown:"Unknown",yearAbbreviation:"yr",yearsAbbreviation:"yrs"};var tK=n(12279);let tX=tK.Ay.default||tK.Ay;function tQ(e,t,n,r){return tX.t(t,{ns:e,defaultValue:n,...r})}function tY(e,t,n){return tq[e]?tQ("core",e,t??tq[e],n):(console.error(`O3 Core Translations does not provide key '${e}'. The key itself is being rendered as text.`),e)}tX.on("initialized",function(){window.i18next.loadNamespaces(["core"])});let tZ="import-map-override:",t0="import-map-overrides-disabled",t1="import-map-overrides:change",t2=!1,t5=null,t6=null;async function t3(){return t6??(t6=t8().then(({map:e,complete:t})=>(t||(t6=null),e))),t6}async function t8(){let e=document.querySelectorAll('script[type="systemjs-importmap"]'),t=[],n=!0;for(let r=0;r<e.length;r++){let o=e[r];try{if(o.src){let e=await fetch(o.src);if(!e.ok)throw Error(`Request for ${o.src} returned ${e.status} ${e.statusText}`);t.push(await e.json())}else o.textContent&&t.push(JSON.parse(o.textContent))}catch(e){n=!1,console.warn(`[import-maps] Failed to parse import map from script tag at index ${r}`,e)}}return{map:t4(t),complete:n}}function t4(e){let t={imports:{}};for(let n of e)n?.imports&&Object.assign(t.imports,n.imports);return t}function t7(){let e={};try{let t=nr();for(let n=0;n<localStorage.length;n++){let r=localStorage.key(n);if(r?.startsWith(tZ)){let n=r.slice(tZ.length);if(!t.includes(n)){let t=localStorage.getItem(r);t&&(e[n]=t)}}}}catch(e){console.warn("[import-maps] Failed to read import-map overrides from localStorage",e)}return{imports:e}}async function t9(){let e=await t3();return t2?t4([e,t5??t7()]):e}async function ne(){return t3()}async function nt(){return t2?t4([await t3(),t7()]):t3()}function nn(e){if(!t2)return{imports:{}};if(e){let e={};for(let t=0;t<localStorage.length;t++){let n=localStorage.key(t);if(n?.startsWith(tZ)){let t=localStorage.getItem(n);t&&(e[n.slice(tZ.length)]=t)}}return{imports:e}}return t7()}function nr(){if(!t2)return[];try{let e=localStorage.getItem(t0);if(e){let t=JSON.parse(e);if(Array.isArray(t))return t}}catch{}return[]}function no(e){return!!t2&&nr().includes(e)}function ni(e,t){if(!t2)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{localStorage.setItem(tZ+e,t),window.dispatchEvent(new CustomEvent(t1))}catch(e){console.warn("[import-maps] Failed to write import-map override to localStorage",e)}}function na(e){if(!t2)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{localStorage.removeItem(tZ+e);let t=nr().filter(t=>t!==e);t.length>0?localStorage.setItem(t0,JSON.stringify(t)):localStorage.removeItem(t0),window.dispatchEvent(new CustomEvent(t1))}catch(e){console.warn("[import-maps] Failed to update import-map overrides in localStorage",e)}}function ns(){if(!t2)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{let e=[];for(let t=0;t<localStorage.length;t++){let n=localStorage.key(t);n?.startsWith(tZ)&&e.push(n)}e.forEach(e=>localStorage.removeItem(e)),localStorage.removeItem(t0),window.dispatchEvent(new CustomEvent(t1))}catch(e){console.warn("[import-maps] Failed to clear import-map overrides from localStorage",e)}}function nl(e){if(!t2)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{let t=nr().filter(t=>t!==e);t.length>0?localStorage.setItem(t0,JSON.stringify(t)):localStorage.removeItem(t0),window.dispatchEvent(new CustomEvent(t1))}catch(e){console.warn("[import-maps] Failed to update import-map overrides in localStorage",e)}}let nc=!1;function nu(){!nc&&(nc=!0,(t2="development"===window.spaEnv)&&(t5=t7()))}function nd(e){return e.replace(/[\/\-@]/g,"_")}async function nm(e,t="./start",r){var o;let i,a=!r?.maxLoadingTime||r.maxLoadingTime<=0?6e5:r.maxLoadingTime;await Promise.race([np(e,r?.importMap),new Promise((t,n)=>{i=setTimeout(()=>{var t;n(Error(`Could not resolve requested script, ${e}, within ${(t=a)<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`}.`))},a)})]),i&&clearTimeout(i);let s=nd(e),l=window[s];if(!("object"==typeof(o=l)&&null!==o&&"init"in o&&"function"==typeof o.init&&"get"in o&&"function"==typeof o.get)){let e=`The global variable ${s} does not refer to a federated module`;throw console.error(e),Error(e)}l.init(n.S.default);let c=(await l.get(t))();if("object"!=typeof c||null===c){let t=`Container for ${e} did not return an ESM module as expected`;throw console.error(t),Error(t)}return c}async function np(e,t){if("string"!=typeof e||0===e.trim().length){let e="Attempted to call importDynamic() without supplying a package to load";throw console.error(e),Error(e)}let n=nd(e);if(!window[n]){let n=t??await nf();if(!n.imports.hasOwnProperty(e)){let t=`Could not find the package ${e} defined in the current importmap`;throw console.error(t),Error(t)}let r=n.imports[e];r.startsWith("./")&&(r=window.spaBase+r.substring(1));let o=e in nn().imports;try{return await function(e){var t;let n=(t=window)[ng]??(t[ng]=new Map),r=n.get(e);if(r)return r;if(document.head.querySelector(`script[src="${e}"]`))return console.warn(`Script at ${e} already loaded. Not loading it again.`),Promise.resolve();let o=document.createElement("script");o.src=e,o.type="text/javascript",o.async=!0;let i=new Promise((t,r)=>{let i=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 a(){clearTimeout(i),o.removeEventListener("load",s),o.removeEventListener("error",l)}function s(){a(),t()}function l(t){a(),n.delete(e),o.remove();let i=`Failed to load script from ${e}`;console.error(i,t),r(t.message??i)}o.addEventListener("load",s),o.addEventListener("error",l),document.head.appendChild(o)});return n.set(e,i),i}(r)}catch(e){return o&&v({kind:"error",title:tY("scriptLoadingFailed","Error: Script failed to load"),description:tY("scriptLoadingError","Failed to load overridden script from {{- url}}. Please check that the bundled script is available at the expected URL. Click the button below to reset all import map overrides.",{url:r}),actionButtonLabel:tY("resetOverrides","Reset overrides"),onActionButtonClick(){ns(),window.location.reload()}}),Promise.reject(e)}}return Promise.resolve()}async function nf(){return t9()}let ng=Symbol.for("__openmrs_script_loading");function nh(e){return!!e&&"object"==typeof e&&!(Object.hasOwn(e,"pages")&&(!e.pages||!Array.isArray(e.pages))||Object.hasOwn(e,"extensions")&&(!e.extensions||!Array.isArray(e.extensions))||Object.hasOwn(e,"workspaces")&&(!e.workspaces||!Array.isArray(e.workspaces))||Object.hasOwn(e,"modals")&&(!e.modals||!Array.isArray(e.modals)))}function nw(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&&nh(t))}let ny="openmrs-routes:",n_="openmrs-routes:change",nv=!1,nb=null,nx=null;async function nk(){return nx??(nx=nS().then(({map:e,complete:t})=>(t||(nx=null),e))),nx}async function nS(){let e=document.querySelectorAll("script[type='openmrs-routes']"),t=[],n=!0;for(let r=0;r<e.length;r++){let o=e[r];try{let e;if(o.src){let t=await fetch(o.src);if(!t.ok)throw Error(`Request for ${o.src} returned ${t.status} ${t.statusText}`);e=await t.json()}else o.textContent&&(e=JSON.parse(o.textContent));e&&nw(e)&&t.push(e)}catch(e){n=!1,console.warn(`[route-maps] Failed to parse routes from script tag at index ${r}`,e)}}return{map:nj(t),complete:n}}function nj(e){let t={routes:{}};for(let n of e)n&&"object"==typeof n&&!Array.isArray(n)&&(Object.assign(t.routes,n.routes),void 0===t.version&&void 0!==n.version&&(t.version=n.version));return t}async function nN(){let e={version:void 0,routes:{}};try{let t=[];for(let e=0;e<localStorage.length;e++){let n=localStorage.key(e);if(n?.startsWith(ny)){let e=localStorage.getItem(n);e&&t.push({moduleName:n.slice(ny.length),raw:e})}}for(let n of(await Promise.allSettled(t.map(async({moduleName:e,raw:t})=>{let n=JSON.parse(t);if(nh(n))return{moduleName:e,routes:n};if("string"==typeof n&&n.startsWith("http")){let t=await fetch(n),r=await t.json();if(nh(r))return{moduleName:e,routes:r};throw Error(`${n} did not resolve to a valid OpenmrsAppRoutes object`)}throw Error(`Override for ${e} is neither a valid routes object nor a URL`)}))))"fulfilled"===n.status?e.routes[n.value.moduleName]=n.value.routes:console.warn("[route-maps] Failed to load route override",n.reason)}catch(e){console.warn("[route-maps] Failed to read route overrides from localStorage",e)}return e}async function nC(){let e=await nk();return nv?nj([e,nb??await nN()]):e}async function nE(){return nk()}async function nA(){return nv?nj([await nk(),await nN()]):nk()}function nI(){if(!nv)return{};let e={};try{for(let t=0;t<localStorage.length;t++){let n=localStorage.key(t);if(n?.startsWith(ny)){let t=localStorage.getItem(n);t&&(e[n.slice(ny.length)]=t)}}}catch(e){console.warn("[route-maps] Failed to read route overrides from localStorage",e)}return e}function nO(e,t){if(!nv)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{if("string"==typeof t)if(t.startsWith("http"))localStorage.setItem(ny+e,JSON.stringify(t));else{let n=JSON.parse(t);if(!nh(n))return void console.error(`The supplied routes for ${e} is not a valid OpenmrsAppRoutes object`,t);localStorage.setItem(ny+e,JSON.stringify(n))}else if(t instanceof URL)localStorage.setItem(ny+e,JSON.stringify(t.toString()));else{if(!nh(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(ny+e,JSON.stringify(t))}window.dispatchEvent(new CustomEvent(n_))}catch(e){console.warn("[route-maps] Failed to write route override to localStorage",e)}}function nP(e){if(!nv)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{localStorage.removeItem(ny+e),window.dispatchEvent(new CustomEvent(n_))}catch(e){console.warn("[route-maps] Failed to remove route override from localStorage",e)}}function nT(){if(!nv)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{let e=[];for(let t=0;t<localStorage.length;t++){let n=localStorage.key(t);n?.startsWith(ny)&&e.push(n)}e.forEach(e=>localStorage.removeItem(e)),window.dispatchEvent(new CustomEvent(n_))}catch(e){console.warn("[route-maps] Failed to clear route overrides from localStorage",e)}}let nR=null;function n$(){return nR||(nR=(nv="development"===window.spaEnv)?nN().then(e=>{nb=e}):Promise.resolve())}let nM=`${tj}/attachment`;function nW(e,t){return tA(`${nM}/${e}`,{signal:t.signal})}function nD(e,t,n){return tA(`${nM}?patient=${e}&includeEncounterless=${t}`,{signal:n.signal})}async function nL(e,t){let n=new FormData;return n.append("fileCaption",t.fileDescription),n.append("patient",e),t.file?n.append("file",t.file,t.fileName):(n.append("file",new File([""],t.fileName),t.fileName),n.append("base64Content",t.base64Content)),tA(`${nM}`,{method:"POST",body:n})}function nB(e,t){return tA(`${nM}/${e}`,{method:"DELETE",signal:t.signal})}var nU=n(68798);function nF(e,t){if(void 0!==i)return console.warn(`The application's Service Worker has already been registered. The new service worker at ${e} will not be registered.`),i;if(!("serviceWorker"in navigator))throw Error("Registering the Service Worker is not possible due to missing browser capabilities.");let n=new nU.JK(e,t);return i=n.register().then(()=>n.controlling.then(()=>n))}function nH(){return i??Promise.resolve(void 0)}let nz="x-omrs-offline-response-body",nG="x-omrs-offline-response-status",nV="x-omrs-offline-caching-strategy";async function nJ(e){let t=await nH();return t?await t.messageSW(e):{success:!1,result:void 0,error:"No service worker has been registered. This is typically the case when the application has been built without offline-related features."}}async function nq(){let e=window.sessionStorage;try{e.setItem("someKeyHere","test"),e.removeItem("someKeyHere")}catch(t){if(t.code===DOMException.QUOTA_EXCEEDED_ERR&&0===e.length)return!0}return!1}async function nK(){return!window.indexedDB}async function nX(){return new Promise(e=>{let t=indexedDB.open("test");t.onerror=()=>e(!0),t.onsuccess=()=>e(!1)})}async function nQ(){return await nX()||await nK()||await nq()}let nY="openmrs3:offline-mode",nZ="unavailable";function n0(){return{current:nZ,notAvailable:"unavailable"===nZ,active:"on"===nZ}}function n1(e){"unavailable"!==nZ&&"unavailable"!==e&&(localStorage.setItem(nY,"on"===e?"active":"disabled"),nZ=e)}async function n2(){await nQ()||(nZ="active"===localStorage.getItem(nY)?"on":"off"),navigator.onLine}var n5=n(98442);function n6(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class n3 extends n5.Ay{constructor(){super("EsmOffline"),n6(this,"syncQueue",void 0),n6(this,"dynamicOfflineData",void 0),this.version(4).stores({syncQueue:"++id,userId,type,[userId+type]",dynamicOfflineData:"++id,type,identifier,*users,&[type+identifier]"}),this.syncQueue=this.table("syncQueue"),this.dynamicOfflineData=this.table("dynamicOfflineData")}}function n8(){return new n3}let n4=new n3,n7={},n9=L("offline-synchronization",{});function re(){return n9}async function rt(){if(n9.getState().synchronization)return;let e=await n4.syncQueue.count(),t={},n=Object.entries(n7),r=n.length,o={},i=new AbortController,a=()=>{let e=n9.getState().synchronization;n9.setState({synchronization:{...e,pendingCount:e.pendingCount-1}})};try{n9.setState({synchronization:{totalCount:e,pendingCount:e,abortController:i}});for(let e=0;e<r&&n.length>0;e++)for(let e=n.length;e--;){let[r,s]=n[e],l=s.dependsOn.map(e=>t[e]);l.every(Boolean)&&(o[r]={},await Promise.all(l),t[r]=rn(s,o,i,a),n.splice(e,1))}await Promise.allSettled(Object.values(t))}finally{n9.setState({synchronization:void 0})}}async function rn({type:e,dependsOn:t,process:n},r,o,i){let a=[],s=[],l=await rr();await n4.syncQueue.where({type:e,userId:l}).each((e,t)=>{a.push([t.primaryKey,e.content,e.descriptor]),s.push(e.content)});for(let c=0;c<a.length;c++){let[u,d,{id:m,dependencies:p=[]}]=a[c];try{let i=await n(d,{abort:o,index:c,items:s,userId:l,dependencies:p.map(({id:e,type:n})=>t.includes(n)?r[n][e]:void 0)});void 0!==m&&(r[e][m]=i),await n4.syncQueue.delete(u)}catch(e){await n4.syncQueue.update(u,{lastError:{name:e?.name,message:e?.message??e?.toString()}})}finally{i()}}}async function rr(){let e=await tB();return e?.uuid||"*"}async function ro(e,t,n,r){let o=r&&r.id;return void 0!==o&&await n4.syncQueue.where({type:t,userId:e}).filter(e=>e?.descriptor.id===o).delete().catch(n5.Ay.errnames.DatabaseClosed),await n4.syncQueue.add({type:t,content:n,userId:e,descriptor:r||{},createdOn:new Date}).catch(n5.Ay.errnames.DatabaseClosed,()=>-1)}async function ri(e,t,n){let r=await rr();return await ro(r,e,t,n)}async function ra(e,t){return(await rs(e,t)).map(e=>e.content)}async function rs(e,t){return await n4.syncQueue.where(t?{type:t,userId:e}:{userId:e}).toArray().catch(n5.Ay.errnames.DatabaseClosed,()=>[])}async function rl(e){let t=await rr();return await ra(t,e)}async function rc(e){let t=await rr();return await rs(t,e)}async function ru(e){return await n4.syncQueue.get(e).catch(n5.Ay.errnames.DatabaseClosed,()=>void 0)}function rd(e){return!!n7[e]?.options.onBeginEditSyncItem}async function rm(e){let t=await ru(e);if(!t)throw Error(`No sync item with the ID ${e} exists.`);let n=n7[t.type]?.options.onBeginEditSyncItem;if(!n)throw Error(`A sync item with the ID ${e} exists, but the associated handler (if one exists) doesn't support editing the item. You can avoid this error by either verifying that sync items of this type can be edited via the "canEditSynchronizationItemsOfType(type: string)" function or alternatively ensure that the synchronizaton handler for sync items of type "${t.type}" supports editing items.`);n(t)}async function rp(e){await n4.syncQueue.delete(e).catch(n5.Ay.errnames.DatabaseClosed)}function rf(e,t,n,r={}){n7[e]={type:e,dependsOn:t,process:n,options:r}}var rg=n(71301);let rh="OFFLINE+";function rw(){return rh+(0,rg.A)()}function ry(e){return e.startsWith(rh)}let r_={};function rv(){return Object.values(r_)}function rb(e){r_[e.id]&&console.warn(`[setupDynamicOfflineDataHandler] Another second handler with the ID "${e.id}" was registered. This handler will override the previous one. This could be unintended as the previous handler might run different flows than the newly registered one. If this is the case, ensure that you are setting up the handlers with different IDs.`),r_[e.id]=e}async function rx(e){let t=await rI();return await rk(t,e)}async function rk(e,t){let n=new n3;return await n.dynamicOfflineData.where(t?{type:t,users:e}:{users:e}).toArray().catch(n5.Ay.errnames.DatabaseClosed,()=>[])}async function rS(e,t){let n=await rI();return await rj(n,e,t)}async function rj(e,t,n){let r=new n3,o=await r.dynamicOfflineData.get({type:t,identifier:n}).catch(n5.Ay.errnames.DatabaseClosed,()=>void 0);o?o.users.includes(e)||await r.dynamicOfflineData.update(o.id,{users:[...o.users,e]}).catch(n5.Ay.errnames.DatabaseClosed):await r.dynamicOfflineData.add({users:[e],type:t,identifier:n}).catch(n5.Ay.errnames.DatabaseClosed)}async function rN(e,t){let n=await rI();return await rC(n,e,t)}async function rC(e,t,n){let r=new n3,o=await r.dynamicOfflineData.get({type:t,identifier:n,users:e}).catch(n5.Ay.errnames.DatabaseClosed,()=>void 0);o&&(o.users.length>1?await r.dynamicOfflineData.update(o.id,{users:o.users.filter(t=>t!==e)}).catch(n5.Ay.errnames.DatabaseClosed):await r.dynamicOfflineData.delete(o.id).catch(n5.Ay.errnames.DatabaseClosed))}async function rE(e,t){let n=await rx(e);await Promise.all(n.map(async e=>rA(e.type,e.identifier,t)))}async function rA(e,t,n){await rS(e,t);let r=new n3,o=await rI(),i=await r.dynamicOfflineData.get({type:e,identifier:t}).catch(n5.Ay.errnames.DatabaseClosed,()=>void 0),a=rv().filter(t=>t.type===e);if(!i)return;let s=await Promise.all(a.map(async e=>{try{return e.sync(t,n),{id:e.id,error:void 0}}catch(n){let t=n.message?.toString()??n.toString();return{id:e.id,error:t}}})),l=s.filter(e=>!e.error).map(e=>e.id),c=s.filter(e=>e.error).map(e=>e.id),u=s.filter(e=>e.error).map(e=>({handlerId:e.id,message:e.error})),d={syncedOn:new Date,syncedBy:o,succeededHandlers:l,erroredHandlers:c,errors:u};i.id&&await r.dynamicOfflineData.update(i.id,{syncState:d}).catch(n5.Ay.errnames.DatabaseClosed)}async function rI(){let e=(await tB()).uuid;if(!e)throw Error("Using the dynamic offline data API requires a logged in user.");return e}let rO=L("offline-patients",{offlinePatientDataSyncState:{},handlers:{}});function rP(){return r$(),rO}function rT(e,t){r$(),rb({type:"patient",displayName:t.displayName,id:e,isSynced:()=>Promise.resolve(!0),sync:(e,n)=>t.onOfflinePatientAdded({patientUuid:e,signal:n??new AbortController().signal})})}async function rR(e){r$(),await rA("patient",e)}function r$(){console.warn("The offline patient API has been deprecated and will be removed in a future release. To prevent future crashes, the functions remain available for the moment, but any invocations should be migrated ASAP.")}async function rM(e,t,n=!0){if(e){let r=null,[o,i]=await Promise.all([tA(`${tN}/Patient/${e}`,t).catch(e=>r=e),n?rW(e):Promise.resolve(null)]);if(o.ok)return o.data;if(i)return i;if(r)throw r}return null}async function rW(e){let t=(await rl("patient-registration")).find(t=>t.fhirPatient.id===e);return t?.fhirPatient??null}function rD(e,t){let n=new CustomEvent(`openmrs:${e}`,{detail:t??void 0,cancelable:!0,bubbles:!0});return window.dispatchEvent(n)}function rL(e,t){let n=e=>{t("detail"in e&&null!==e.detail?e.detail:void 0)};return window.addEventListener(`openmrs:${e}`,n),()=>{window.removeEventListener(`openmrs:${e}`,n)}}var rB=n(83492);function rU(e){return{uuid:e.uuid,display:e.display}}function rF(e=null,t=null){let n=new URLSearchParams;e&&n.set("tag",e),t&&n.set("q",t);let r=n.toString();return tI(`${tj}/location${r?"?"+r:""}`).pipe((0,rB.map)(e=>e.data.results.map(rU))).pipe((0,rB.take)(1))}function rH(e){return{uuid:e.uuid,display:e.display,name:e.name}}function rz(){return tI(`${tj}/visittype`).pipe((0,rB.map)(e=>e.data.results.map(rH))).pipe((0,rB.take)(1))}var rG=((I={}).NEWVISIT="startVisit",I.EDITVISIT="editVisit",I.LOADING="loadingVisit",I),rV=((O={}).NOTSTARTED="notStarted",O.ONGOING="ongoing",O);let rJ="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))",rq=function(){try{return JSON.parse(sessionStorage.getItem("openmrs:visitStoreState")||"null")}catch(e){return null}}()||{patientUuid:null,manuallySetVisitUuid:null};function rK(){return U("visit",rq)}function rX(e,t){rK().setState({patientUuid:e,manuallySetVisitUuid:t})}function rQ(e,t){return tA(`${tj}/visit`,{signal:t.signal,method:"POST",headers:{"Content-type":"application/json"},body:e})}function rY(e,t,n){return tA(`${tj}/visit/${e}`,{signal:n.signal,method:"POST",headers:{"Content-type":"application/json"},body:t})}function rZ(e,t,n){return tA(`${tj}/visit?patient=${e}&v=${n??rJ}`,{signal:t.signal,method:"GET",headers:{"Content-type":"application/json"}})}rK().subscribe(e=>{var t;t=e,sessionStorage.setItem("openmrs:visitStoreState",JSON.stringify(t))});let r0=new G.BehaviorSubject(null);var r1=n(79225),r2=n(76881),r5=n(56828),r6=n(91956),r3=n(73635),r8=n(7839),r4=n(32298);let r7={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)}},r9={...r7,Promise};function oe(e,t={}){return oa(e,t,oc)}async function ot(e,t={}){return os(e,t,oc)}function on(e,t={}){return oa(e,t,ou)}function or(e,t={}){return os(e,t,ou)}function oo(e,t={}){return oa(e,t,od)}function oi(e,t={}){return os(e,t,od)}function oa(e,t={},n){if("string"!=typeof e&&("object"!=typeof e||!e||!("type"in e)))throw`Unknown expression type ${e}. Expressions must either be a string or pre-compiled string.`;if("string"==typeof e&&0===e.trim().length)throw{type:"Empty expression",message:"Expression cannot be an empty string"};null==t&&(t={});let r=of(t,r7),o=om("string"==typeof e?(0,r1.A)(e):e,r);if(n(o))return o;throw{type:"Invalid result",message:"string"==typeof e?`The expression ${e} did not produce a valid result`:"The expression did not produce a valid result"}}async function os(e,t={},n){if("string"!=typeof e&&("object"!=typeof e||!e||!("type"in e)))return Promise.reject(`Unknown expression type ${e}. Expressions must either be a string or pre-compiled string.`);if("string"==typeof e&&0===e.trim().length)throw{type:"Empty expression",message:"Expression cannot be an empty string"};null==t&&(t={});let r=of(t,r9);return Promise.resolve(om("string"==typeof e?(0,r1.A)(e):e,r)).then(t=>{if(n(t))return t;throw{type:"Invalid result",message:"string"==typeof e?`The expression ${e} did not produce a valid result`:"The expression did not produce a valid result"}})}function ol(e){return(0,r1.A)(e)}function oc(e){return"string"==typeof e||"number"==typeof e||"boolean"==typeof e||null==e||e instanceof Date}function ou(e){return"boolean"==typeof e}function od(e){return"number"==typeof e}function om(e,t){switch(e.type){case"UnaryExpression":var n,r,o,i,a,s,l,c,u,d,m,p,f=e,g=t;let h=om(f.argument,g);switch(f.operator){case"+":return+h;case"-":return-h;case"~":return~h;case"!":return!h;default:throw`Expression evaluator does not support operator '${f.operator}''`}case"BinaryExpression":var w=e,y=t;let _=om(w.left,y),v=om(w.right,y);switch(w.operator){case"+":return _+v;case"-":return _-v;case"*":return _*v;case"/":return _/v;case"%":return _%v;case"**":return _**v;case"==":return _==v;case"===":return _===v;case"!=":return _!=v;case"!==":return _!==v;case">":return _>v;case">=":return _>=v;case"<":return _<v;case"<=":return _<=v;case"in":return _ in v;case"&&":return _&&v;case"||":return _||v;case"??":return _??v;default:throw`Expression evaluator does not support operator '${w.operator}' operator`}case"ConditionalExpression":return n=e,r=t,om(n.test,r)?om(n.consequent,r):om(n.alternate,r);case"CallExpression":var b=e,x=t;let k=b.arguments?.map(og(x)),S=om(b.callee,x);if(S){if("function"!=typeof S)throw`${ow(b.callee)} is not a function`}else throw`No function named ${ow(b.callee)} is defined in this context`;return S(...k);case"ArrowFunctionExpression":let j;return o=e,i=t,j=o.params?.map(e=>{if("Identifier"===e.type)return e.name;throw`Cannot handle parameter of type ${e.type}`})??[],(function(...e){if(e.length<j.length)throw`Required argument(s) ${j.slice(e.length,-1).join(", ")} were not provided`;let t=Object.fromEntries(j.reduce((t,n,r)=>{let o=e[r];return function e(t){if("string"==typeof t||"number"==typeof t||"boolean"==typeof t||"function"==typeof t||null===t||t instanceof RegExp)return!0;if("object"==typeof t){for(let n of Object.keys(t))if(!e(t[n]))return!1;return!0}if(Array.isArray(t)){for(let n of t)if(!e(n))break}return!1}(o)&&t.push([n,o]),t},[]));return om(o.body,i.addVariables(t))}).bind(i.thisObj??null);case"MemberExpression":return function(e,t){let n,r=om(e.object,t);if(void 0===r)switch(e.object.type){case"Identifier":{let n=op(e.object,t);throw ReferenceError(`ReferenceError: ${n} is not defined`)}case"MemberExpression":{let n=op(e.property,t);throw TypeError(`TypeError: cannot read properties of undefined (reading '${n}')`)}default:throw`VisitMemberExpression does not support operator '${e.object.type}' type`}let o=r;if("string"==typeof r)o=String.prototype;else if("number"==typeof r)o=Number.prototype;else if("function"==typeof r);else if("object"!=typeof r)throw`VisitMemberExpression does not support member access on type ${typeof r}`;switch(t.thisObj=o,e.property.type){case"Identifier":case"MemberExpression":n=om(e.property,t);break;default:{let o=om(e.property,t);if(void 0===o)throw{type:"Illegal property access",message:"No property was supplied to the property access"};oh(o),n=r[o]}}return"function"==typeof n?n.bind(r):n}(e,t);case"ArrayExpression":return a=e,s=t,a.elements?.map(og(s));case"SequenceExpression":let N;return l=e,c=t,(N=l.expressions.map(og(c)))[N.length-1];case"NewExpression":var C=e,E=t;if(C.callee&&"Identifier"===C.callee.type){let e=C.arguments?.map(og(E));switch(C.callee.name){case"Date":return new Date(...e);case"RegExp":return new RegExp(...e);default:throw`Cannot instantiate object of type ${C.callee.name}`}}if(C.callee)throw"new must be called with either Date or RegExp";throw'Could not handle "new" without a specified class';case"Literal":return oh((u=e).value),u.value;case"Identifier":var A=e,I=t;oh(A.name);let O=I.thisObj;if(O&&("object"==typeof O||"function"==typeof O)&&A.name in O){let e=O[A.name];return oh(e),e}if(I.variables&&A.name in I.variables){let e=I.variables[A.name];return oh(e),e}return A.name in I.globals?I.globals[A.name]:void 0;case"TemplateLiteral":let P,T;return d=e,m=t,P=d.expressions?.map(og(m))??[],(T=d.quasis?.map(og(m))??[]).filter(e=>!e.tail).map(e=>e.value).join("")+P.join("")+T.filter(e=>e.tail).map(e=>e.value).join("");case"TemplateElement":return{value:(p=e).cooked,tail:p.tail};default:throw`Expression evaluator does not support expression of type '${e.type}'`}}function op(e,t){switch(e.type){case"Literal":return e.value;case"Identifier":return e.name;case"MemberExpression":return op(e.property,t);default:throw`VisitExpressionName does not support expression of type '${e.type}'`}}function of(e,t){let n={thisObj:void 0,variables:{...e},globals:{...t},addVariables(e){return this.variables={...this.variables,...e},this}};return n.addVariables.bind(n),n}function og(e){return function(t){return null===t?null:om(t,e)}}function oh(e){if("__proto__"===e||"prototype"===e||"constructor"===e)throw{type:"Illegal property access",message:`Cannot access the ${e} property of objects`}}function ow(e){return e?"MemberExpression"===e.type?e.property?.name:e.name:null}function oy(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:{...r9},isLocalExpression:!1,variables:new Set};return o_("string"==typeof e?(0,r1.A)(e):e,t),[...t.variables]}function o_(e,t){switch(e.type){case"UnaryExpression":return r=e,o=t,o_(r.argument,o);case"BinaryExpression":return i=e,a=t,[o_(i.left,a),o_(i.right,a)].filter(Boolean);case"ConditionalExpression":return s=e,l=t,[o_(s.consequent,l),o_(s.test,l),o_(s.alternate,l)].filter(Boolean);case"CallExpression":let n;return c=e,u=t,n=o_(c.callee,u),c.arguments?.map(ov(u)),n;case"ArrowFunctionExpression":var r,o,i,a,s,l,c,u,d,m,p,f,g,h,w,y,_,v,b=e,x=t;let k={...x};k.isLocalExpression=!0;let S=b.params?.map(ov(k))??[],j=o_(b.body,k)??[];if(j&&Array.isArray(j))for(let e of j)S.includes(e)||x.variables.add(e);return;case"MemberExpression":let N;return d=e,m=t,o_(d.object,m),void((N={...m}).isLocalExpression=!0,o_(d.property,N));case"ArrayExpression":return p=e,f=t,void p.elements?.map(ov(f));case"SequenceExpression":return g=e,h=t,void g.expressions?.map(ov(h));case"NewExpression":return w=e,y=t,void w.arguments?.map(ov(y));case"Literal":case"TemplateElement":return;case"Identifier":var C=e,E=t;if(!(C.name in E.globals))if(E.isLocalExpression)return C.name;else E.variables.add(C.name);return;case"TemplateLiteral":return _=e,v=t,void(_.expressions?.map(ov(v)),_.quasis?.map(ov(v)));default:throw`Expression evaluator does not support expression of type '${e.type}'`}}function ov(e){return function(t){return null===t?null:o_(t,e)}}r1.A.plugins.register(r2.A),r1.A.plugins.register(r5.A),r1.A.plugins.register(r6.A),r1.A.plugins.register(r3.A),r1.A.plugins.register(r8.A),r1.A.plugins.register(r4.A),r1.A.addBinaryOp("in",7),r1.A.addBinaryOp("??",1);let ob=U("feature-flags",{flags:function(){let e={};for(let t of Object.keys(localStorage))if(t.startsWith("openmrs:feature-flag:")){let n=t.replace("openmrs:feature-flag:",""),r=JSON.parse(localStorage.getItem(`openmrs:feature-flag-meta:${n}`)||"{}");e[n]={enabled:"true"===localStorage.getItem(t),...r}}return e}()});function ox(e,t,n){ob.setState(r=>({flags:{...r.flags,[e]:{enabled:r.flags[e]?.enabled??!1,label:t,description:n}}}))}function ok(){let e=ob.getState().flags;Object.keys(localStorage).filter(e=>e.startsWith("openmrs:feature-flag:")).forEach(t=>{let n=t.replace("openmrs:feature-flag:","");e[n]||(localStorage.removeItem(t),localStorage.removeItem(`openmrs:feature-flag-meta:${n}`))})}function oS(e){return ob.getState().flags[e].enabled}function oj(e,t){ob.subscribe(n=>{t(n.flags[e].enabled)})}function oN(e,t){ob.setState(n=>({flags:{...n.flags,[e]:{...n.flags[e],enabled:t}}}))}function oC(e){return!window.offlineEnabled||(e??navigator.onLine)}ob.subscribe(e=>{for(let[t,n]of Object.entries(e.flags))localStorage.setItem(`openmrs:feature-flag:${t}`,n.enabled.toString()),localStorage.setItem(`openmrs:feature-flag-meta:${t}`,JSON.stringify({label:n.label,description:n.description}))});var oE=n(11216);function oA(e=!0,t=!1){return oI(oC(),e,t)}function oI(e,t=!0,n=!1){return!!(e?t:n)}let oO=L("extensionsInternal",{slots:{},extensions:{}}),oP=L("extensionRenderings",{renderings:new Map}),oT=()=>U("extensionsInternal",{slots:{},extensions:{}}),oR=()=>U("extensionRenderings",{renderings:new Map});function o$(e){let t=oO.getState(),n=e(t);n!==t&&oO.setState(n)}let oM=null,oW=null;function oD(){let e=oP.getState();return oM&&e===oW||(oM=new Map(e.renderings),oW=e,function(e){for(let t of(oq.clear(),e.values()))oX(t,1);oK=!0}(oM)),oM}function oL(e){oW={renderings:e},oP.setState(oW,!0)}function oB(e){let t=oD();t.has(e.renderingId)||(t.set(e.renderingId,e),oX(e,1),oL(t))}function oU(e){let t=oD(),n=t.get(e);n&&(t.delete(e),oX(n,-1),oL(t))}let oF=()=>U("extensions",{slots:{}}),oH=0,oz=new Set;function oG(e){oH++;try{return e()}finally{if(0==--oH&&oz.size>0){let e=Array.from(oz);for(let t of(oz.clear(),e))oV(t)}}}function oV(e){try{e()}catch(t){console.error(`The extension system's '${e.name}' recomputation failed`,t)}}function oJ(e){oH>0?oz.add(e):oV(e)}let oq=new Map,oK=!1;function oX(e,t){let n=JSON.stringify([e.slotName,e.extensionId,e.slotModuleName,e.extensionModuleName]),r=oq.get(n);if(!r){if(t<0)return;oq.set(n,{count:1,record:{slotModuleName:e.slotModuleName,extensionModuleName:e.extensionModuleName,slotName:e.slotName,extensionId:e.extensionId}}),oK=!0;return}r.count+=t,r.count<1&&(oq.delete(n),oK=!0)}function oQ(){var e,t;if(oD(),!oK)return;oK=!1;let n=Array.from(oq.values(),({record:e})=>e);n.sort(oY),e=es.getState().mountedExtensions,t=n,e.length===t.length&&e.every((e,n)=>0===oY(e,t[n]))||es.setState({mountedExtensions:n})}function oY(e,t){return oZ(e.slotName,t.slotName)||oZ(e.extensionId,t.extensionId)||oZ(e.slotModuleName,t.slotModuleName)||oZ(e.extensionModuleName,t.extensionModuleName)}function oZ(e,t){return e===t?0:e<t?-1:1}oQ(),oP.subscribe(()=>oJ(oQ));let o0=oT(),o1=oF(),o2=ec(),o5=em(),o6=new Set,o3=!1;function o8(e){if(null===e)o6=null;else if(null!==o6)for(let t of e)o6.add(t);oJ(o4)}function o4(){if(!o3){o3=!0;try{for(let e=1;;e++){let t=o6;if(null!==t&&0===t.size)return;o6=new Set;try{!function(e,t,n,r,o,i=null){let a=o1.getState().slots,s={},l=!1,c=oC(),u=Object.entries(r.flags).filter(([,{enabled:e}])=>e).map(([e])=>e);for(let[r,d]of Object.entries(e.slots)){let m=a[r];if(m&&i&&!i.has(r)){s[r]=m;continue}let{config:p}=ed(t,d.name),f=function(e,t,n,r,o,i,a){let s=function(e,t){let n=e.add||[],r=e.remove||[],o=e.order||[],{extensions:i}=o0.getState();return[...t,...n].filter(e=>!r.includes(e)).sort((e,n)=>ic(e,o,i[it(e)]?.order,t)-ic(n,o,i[it(n)]?.order,t))}(n,t.slots[e].attachedIds),l=[];for(let c of s){let{config:s}=ef(r,e,c),u=eg(n,e,c),d=u?(0,oE.A)({},s,u):s,m=it(c),p=t.extensions[m];if(p){let e=d?.["Display conditions"]?.privileges??p.privileges??[];if(e&&("string"==typeof e||Array.isArray(e)&&e.length>0)&&(!a?.user||!tL(e,a.user))||p.featureFlag&&!o.includes(p.featureFlag)||window.offlineEnabled&&!oI(i,p.online,p.offline))continue;l.push({id:c,name:m,moduleName:p.moduleName,config:d,featureFlag:p.featureFlag,meta:p.meta,online:d?.["Display conditions"]?.online??p.online??!0,offline:d?.["Display conditions"]?.offline??p.offline??!1,displayConditionExpression:d?.["Display conditions"]?.expression||p.displayExpression})}}return l}(r,e,p,n,u,c,o.session);m&&m.moduleName===d.moduleName&&(0,q.A)(m.candidateExtensions,f)?s[r]=m:(s[r]={moduleName:d.moduleName,candidateExtensions:f},l=!0)}(l||Object.keys(a).length!==Object.keys(s).length)&&o1.setState({slots:s})}(o0.getState(),o2.getState(),o5.getState(),ob.getState(),tP.getState(),t)}catch(e){throw o6=null===t||null===o6?null:new Set([...t,...o6]),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{o3=!1}}}function o7(e,t){let n=new Set;for(let r of Object.keys(e))e[r]!==t[r]&&n.add(r);for(let r of Object.keys(t))r in e||n.add(r);return n}function o9(){o8(null)}function ie(e,t){return{moduleName:t,name:e,attachedIds:[]}}function it(e){let[t]=e.split("#");return t}function ir(e,t){let n=it(t);return e.extensions[n]}function io(e){return ir(o0.getState(),e)}o0.subscribe((e,t)=>{o8(e.extensions!==t.extensions?null:o7(e.slots,t.slots))}),o2.subscribe((e,t)=>{o8(o7(e.slots,t.slots))}),o5.subscribe((e,t)=>{o8(o7(e.configs,t.configs))}),ob.subscribe(()=>o8(null)),tP.subscribe(()=>o8(null)),o9(),l(o9);let ii=e=>o$(t=>({...t,extensions:{...t.extensions,[e.name]:{...e}}}));function ia(e,t){o$(n=>{let r=n.slots[e];return r?{...n,slots:{...n.slots,[e]:{...r,attachedIds:[...r.attachedIds,t]}}}:{...n,slots:{...n.slots,[e]:{...ie(e),attachedIds:[t]}}}})}function is(e,t){o$(n=>{let r=n.slots[e];return r&&r.attachedIds.includes(t)?{...n,slots:{...n.slots,[e]:{...r,attachedIds:r.attachedIds.filter(e=>e!==t)}}}:n})}function il(e){o$(t=>{let n=t.slots[e];return n?{...t,slots:{...t.slots,[e]:{...n,attachedIds:[]}}}:t})}function ic(e,t,n,r){let o=t.indexOf(e);if(-1!==o)return o;{if(void 0!==n)return 1e3+n;let t=r.indexOf(e);return -1!==t?2e3+t:3e3}}function iu(e,t){return function(e,t,n=null,r){let o;return e.filter(e=>{let i=e.displayConditionExpression;if("string"!=typeof i||0===i.trim().length)return!0;o??(o=t&&"object"==typeof t?{session:n,...t}:{session:n});try{return!!on(i,o)}catch(t){return console.error(`Error while evaluating expression '${i}' for ${e.id}`+(r?` in ${r}`:""),t),!1}})}(id(e),t,tP.getState().session,e)}function id(e){return o1.getState().slots[e]?.candidateExtensions??[]}let im=(e,t)=>o0.setState(n=>{let r=n.slots[t]?.moduleName;if(r&&r!=e)return console.warn(`An extension slot with the name '${t}' already exists. Refusing to register the same slot name twice (in "registerExtensionSlot"). The existing one is from module ${r}.`),n;if(r&&r==e)return n;if(n.slots[t])return{...n,slots:{...n.slots,[t]:{...n.slots[t],moduleName:e}}};let o=ie(t,e);return{...n,slots:{...n.slots,[t]:{...o}}}}),ip=()=>{o6=null,o$(()=>({slots:{},extensions:{}})),oR().setState({renderings:new Map}),o1.setState({slots:{}})},ig=L("left-nav",{slotName:null,basePath:window.spaBase,mode:"normal"});function ih({name:e,basePath:t,mode:n,componentContext:r,state:o}){ig.setState({slotName:e,basePath:t,mode:n??"normal",componentContext:r,state:o})}function iw(e){ig.getState().slotName===e&&ig.setState(ig.getInitialState(),!0)}let iy=L("modalRegistry",{modals:{}});function i_(e){iy.setState(t=>(t.modals[e.name]=e,t))}function iv(e){let t=iy.getState().modals[e];if(!t){let n=io(e);n&&(t={name:e,load:n.load,moduleName:n.moduleName},console.warn(`Modal ${e} was registered as an extension. This is deprecated and will be removed in the future. Please register it in the "modals" section of routes.json instead of the "extensions" section.`),i_(t))}return t}let ib=L("workspaceRegistrations",{workspaces:{}}),ix=L("workspaceGroups",{workspaceGroups:{}});function ik(e){ib.setState(t=>({workspaces:{...t.workspaces,[e.name]:{...e,load:e.load,preferredWindowSize:e.preferredWindowSize??"normal",type:e.type??"form",canHide:e.canHide??!1,canMaximize:e.canMaximize??!1,width:e.width??"narrow",groups:e.groups??[]}}}))}function iS(e){ix.setState(t=>{let n=t.workspaceGroups[e.name];return n?{workspaceGroups:{...t.workspaceGroups,[e.name]:{...n,members:Array.from(new Set([...n.members,...e.members]))}}}:{workspaceGroups:{...t.workspaceGroups,[e.name]:{name:e.name,members:e.members}}}})}let ij=new Set;function iN(e){let t=ib.getState().workspaces;if(t[e])return t[e];{let t=io(e);if(t){var n;let r;return ij.has(e)||(console.warn(`The workspace '${e}' is registered as an extension. This is deprecated. Please register it in the "workspaces" section of the routes.json file.`),ij.add(e)),{name:t.name,title:(n=t,"string"==typeof(r=n?.meta?.title)?r:r&&"object"==typeof r?tQ(n.moduleName,r.key,r.default):n.name),moduleName:t.moduleName,preferredWindowSize:t.meta?.screenSize??"normal",load:t.load,type:t.meta?.type??"form",canHide:t.meta?.canHide??!1,canMaximize:t.meta?.canMaximize??!1,width:t.meta?.width??"narrow",groups:t.meta?.groups??[]}}throw Error(`No workspace named '${e}' has been registered.`)}}function iC(e){let t=ix.getState().workspaceGroups;if(t[e])return t[e];throw Error(`No workspace group named '${e}' has been registered.`)}let iE=L("workspace2",{registeredGroupsByName:{},registeredWindowsByName:{},registeredWorkspacesByName:{},openedGroup:null,openedWindows:[],workspaceTitleByWorkspaceName:{},isMostRecentlyOpenedWindowHidden:!1});function iA(e){let{registeredWorkspacesByName:t,registeredWindowsByName:n}=iE.getState(),r=t[e];if(r){let t=n[r.window];if(t)return t;throw Error(`No workspace window found with name: ${r.window} for workspace: ${e}`)}throw Error(`No workspace found with name: ${e}`)}function iI(e){let{registeredGroupsByName:t,registeredWindowsByName:n}=iE.getState(),r=n[e];if(r){let n=t[r.group];if(n)return n;throw Error(`No workspace group found with name: ${r.group} for window: ${e}`)}throw Error(`No workspace window found with name: ${e}`)}function iO(e){let{openedWindows:t}=iE.getState();return t.findIndex(t=>t.openedWorkspaces.find(t=>t.workspaceName===e))}function iP(e,t){if(0==t.length)return;let{registeredGroupsByName:n}=iE.getState(),r={...n};for(let n of t){if(r[n.name])throw Error(`Cannot register workspace group ${n.name} more than once`);r[n.name]={...n,moduleName:e}}iE.setState({registeredGroupsByName:r})}function iT(e,t){if(0==t.length)return;let{registeredWindowsByName:n}=iE.getState(),r={...n};for(let n of t){if(r[n.name])throw Error(`Cannot register workspace window ${n.name} more than once`);let t={...n,moduleName:e};r[n.name]=t}iE.setState({registeredWindowsByName:r})}function iR(e,t){if(0==t.length)return;let{registeredWorkspacesByName:n}=iE.getState(),r={...n};for(let n of t){if(r[n.name])throw Error(`Cannot register workspace ${n.name} more than once`);let t={...n,moduleName:e};r[n.name]=t}iE.setState({registeredWorkspacesByName:r})}let i$=0,iM=null,iW={bootstrap:15e3,mount:15e3,unmount:15e3};function iD(e){if(e.timeouts)return e;let t=e.name??"parcel",n=Object.fromEntries(Object.keys(iW).filter(t=>e[t]).map(n=>{var r,o;let i,a;return[n,(r=e[n],o=iW[n],i=Array.isArray(r)?r:[r],a=e=>i.reduce((r,o,i)=>r.then(()=>{let r=o(e);return"function"==typeof r?.then&&"function"==typeof r?.catch?r:Promise.reject(Error(`Lifecycle function ${n} at array index ${i} for parcel ${t} did not return a promise`))}),Promise.resolve(void 0)),e=>{let r,i=new Promise((e,i)=>{r=setTimeout(()=>i(Error(`Lifecycle function ${n} for parcel ${t} did not settle within ${o}ms`)),o)});return Promise.race([a(e),i]).finally(()=>clearTimeout(r))})]}));return{...e,...n}}async function iL(e,t){return(await (iM??(iM=new Promise((e,t)=>{(0,tm.mountRootParcel)({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),tm.mountRootParcel))),iM))("function"==typeof e?()=>e().then(iD):iD(e),t)}function iB(){return iU}function iU(e,t){let n,r=iL(e,t).then(e=>n=e);return{mount:()=>r.then(e=>e.mount()),unmount:()=>r.then(e=>e.unmount()),update:e=>r.then(t=>t.update?.(e)),getStatus:()=>n?.getStatus()??"LOADING_SOURCE_CODE",get loadPromise(){return r.then(e=>e.loadPromise)},get bootstrapPromise(){return r.then(e=>e.bootstrapPromise)},get mountPromise(){return r.then(e=>e.mountPromise)},get unmountPromise(){return r.then(e=>e.unmountPromise)}}}async function iF(e,t,n,r,o=e=>e,i={}){let a=it(r),s=io(r),l=null;if(e){if(!s)throw Error(`Couldn't find extension '${a}' to attach to '${t}'`);let{meta:c,moduleName:u,online:d,offline:m,load:p}=s;if(oA(d,m)){let s,d=i$++,m=`${t}/${r}-${d}`;e.dataset.extensionRenderingId=m;let f=e=>{try{oU(m)}catch(t){console.error(e,t)}};try{oB({renderingId:m,extensionName:a,extensionModuleName:u,extensionId:r,slotName:t,slotModuleName:n})}catch(e){throw f(`Recomputing configuration after registering '${r}' failed also failed`),e}try{s=await p()}catch(e){throw f(`Recomputing configuration after '${r}' failed to load also failed`),e}try{l=await iL(o({...s,name:`${t}/${a}-${d}`}),{...i,_meta:c,_extensionContext:{extensionId:r,extensionSlotName:t,extensionSlotModuleName:n,extensionModuleName:u},domElement:e})}catch(e){throw f(`Recomputing configuration after '${r}' failed to mount also failed`),e}l.mountPromise.then(void 0,e=>{console.error(`Extension '${r}' in slot '${t}' failed to mount`,e),f(`Recomputing configuration after '${r}' failed to mount also failed`)}),l.unmountPromise.then(()=>f(`Recomputing configuration after unmounting '${r}' failed`),e=>{console.error(`Extension '${r}' in slot '${t}' failed to unmount`,e),f(`Recomputing configuration after '${r}' failed to unmount also failed`)})}}else console.warn(`Tried to render ${r} into ${t} but no DOM element was available.`);return l}var iH=n(46925),iz=n.n(iH);let iG=(0,iH.createContext)({moduleName:"",featureName:""});function iV({to:e,templateParams:t,onBeforeNavigate:n,children:r,...o}){return(0,iH.useEffect)(()=>{o.href&&console.warn(`ConfigurableLink does not support the href prop. Use the 'to' prop instead. The provided href value is '${o.href}'`),o.onClick&&console.warn(`ConfigurableLink does not support the onClick prop. Use the 'onBeforeNavigate' prop instead. The 'to' prop of the offending link is ${e}`)},[]),iz().createElement("a",{onClick:r=>{0===r.button&&!r.ctrlKey&&!r.shiftKey&&!r.altKey&&!r.metaKey&&(r.preventDefault(),n?.(r),tg({to:e,templateParams:t})),0===r.button&&(r.ctrlKey||r.metaKey)&&n?.(r),0===r.button&&r.shiftKey&&n?.(r),1===r.button&&n?.(r)},href:tp(e,t),...o},r)}let iJ=({state:e,children:t,...n})=>{let{extension:r}=(0,iH.useContext)(iG),o=(0,iH.useRef)(null),i=(0,iH.useRef)(Promise.resolve()),a=(0,iH.useRef)(!1),s=(0,iH.useRef)(!1),l=(0,iH.useRef)(e),c=(0,iH.useCallback)(e=>{if(!e)return;let t=()=>{"MOUNTED"===e.getStatus()&&e.unmount()};switch(e.getStatus()){case"MOUNTED":e.unmount();break;case"UPDATING":i.current?.then(t,t);break;default:e.mountPromise.then(t,()=>{})}},[]),u=(0,iH.useCallback)((e,t)=>{e.update&&"UNMOUNTING"!==e.getStatus()&&(i.current=Promise.all([e.mountPromise,i.current]).then(()=>{if(o.current?.getStatus()==="MOUNTED"&&o.current.update)return o.current.update({...t})}).catch(e=>{let t=o.current?.getStatus();"UNMOUNTING"!==t&&"NOT_MOUNTED"!==t&&"UNLOADING"!==t&&console.error(`The extension '${r?.extensionId}' failed to update`,e)}))},[]),d=(0,iH.useCallback)(t=>{t&&!o.current&&!s.current&&r?.extensionSlotName&&r.extensionSlotModuleName&&(s.current=!0,iF(t,r.extensionSlotName,r.extensionSlotModuleName,r.extensionId,void 0,e).then(t=>{(s.current=!1,o.current=t,a.current)?c(t):t&&l.current!==e&&u(t,l.current)},()=>{s.current=!1}))},[]);return(0,iH.useEffect)(()=>(a.current=!1,()=>{a.current=!0,c(o.current)}),[]),(0,iH.useEffect)(()=>{l.current=e,o.current&&u(o.current,e)},[e]),r?iz().createElement("div",{ref:d,"data-extension-id":r?.extensionId,style:{position:"relative"},...n}):null};function iq(e){let t=(0,iH.useRef)(e);return E(t.current,e)||(t.current=e),t.current}function iK(e,t){"function"==typeof t&&(t=t(e));let n={};for(let[r,o]of Object.entries(t)){let t=function(...t){e.setState(e=>o(e,...t))};n[r]=t}return n}let iX=e=>e;function iQ(e,t=iX,n){let r=(0,iH.useCallback)(t=>e.subscribe(t),[e]),o=(0,iH.useCallback)(()=>t(e.getState()),[e,t]),i=(0,iH.useSyncExternalStore)(r,o,o),a=(0,iH.useMemo)(()=>n?iK(e,n):null,[e,n]);return(0,iH.useMemo)(()=>a?{...i,...a}:i,[i,a])}function iY(e,t){return iQ(e,iX,t)}function iZ(e){return function(t){let n=(0,iH.useCallback)(t=>e.subscribe(t),[]),r=(0,iH.useCallback)(()=>e.getState(),[]),o=(0,iH.useSyncExternalStore)(n,r,r),i=(0,iH.useMemo)(()=>t?iK(e,t):null,[t]);return(0,iH.useMemo)(()=>i?{...o,...i}:o,[o,i])}}let i0=[];Object.freeze(i0);let i1={candidateExtensions:i0};Object.freeze(i1);let i2=e=>{let t=(0,iH.useCallback)(t=>t.slots?.[e]??i1,[e]);return iQ(oF(),t)},i5=e=>e.session;function i6(e,t){let{candidateExtensions:n}=i2(e),r=iQ(tP,i5),o=iq(t);return(0,iH.useMemo)(()=>iu(e,o),[e,o,r,n])}function i3(e,t){let{moduleName:n}=(0,iH.useContext)(iG);if(!n)throw Error("ComponentContext has not been provided. This should come from @openmrs/esm-react-utils.");return(0,iH.useEffect)(()=>{im(n,e)},[n,e]),{extensions:i6(e,t),extensionSlotName:e,extensionSlotModuleName:n}}function i8(e){return e}function i4({name:e,extensionSlotName:t,select:n=i8,children:r,state:o,style:i,...a}){if(r&&o)throw Error("Both children and state have been provided. If children are provided, the state must be passed as a prop to the `Extension` component.");let s=e??t,l=(0,iH.useRef)(null),{extensions:c,extensionSlotModuleName:u}=i3(s,o),d=(0,iH.useMemo)(()=>n(c),[n,c]),m=(0,iH.useMemo)(()=>{if("function"==typeof r&&!iz().isValidElement(r))return d.map(e=>r(e,o))},[r,d]);return iz().createElement("div",{ref:l,"data-extension-slot-name":s,"data-extension-slot-module-name":u,style:{...i,position:"relative"},...a},s&&d?.map((e,t)=>iz().createElement(iG.Provider,{key:e.id,value:{moduleName:u,featureName:"",extension:{extensionId:e.id,extensionSlotName:s,extensionSlotModuleName:u}}},m?.[t]??("function"!=typeof r?r:null)??iz().createElement(iJ,{state:o}))))}var i7=n(63776),i9=n(69568),ae=n(99737),at=n(47488),an=n(51405);let ar={strictMode:!0,throwErrorsToConsole:!0,disableTranslations:!1},ao=new Map;(0,an.r2)(ao);let ai={errorRetryCount:3,fetcher:tA,focusThrottleInterval:18e5,revalidateIfStale:!0,revalidateOnFocus:!1,revalidateOnReconnect:!1,refreshInterval:0,shouldRetryOnError:e=>{if(e instanceof tO){let t=e.response.status;return!!(t>=500)||401===t||403===t||429===t}return!0},provider:()=>ao};function aa(e){if("object"!=typeof e||"string"!=typeof e.featureName||"string"!=typeof e.moduleName)throw Error("Invalid options");let t=Object.assign({},ar,e),n={...ai,...t.swrConfig};return function(e){var r,o,i,a,s;return i=o=class extends(r=iz().Component){componentDidCatch(e,n){n&&n.componentStack&&(e.extra=Object.assign(e.extra||{},{componentStack:n.componentStack})),t.throwErrorsToConsole&&setTimeout(()=>{throw e}),this.setState({caughtError:e,caughtErrorInfo:n})}render(){if(this.state.caughtError)return iz().createElement("div",null,"An error has occurred. Please try reloading the page.");{let r=iz().createElement(iH.Suspense,{fallback:null},iz().createElement(at.BE,{value:n},iz().createElement(iG.Provider,{value:this.state.config},t.disableTranslations?iz().createElement(e,this.props):iz().createElement(ae.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},iz().createElement(e,this.props)))));return t.strictMode&&iz().StrictMode?iz().createElement(iz().StrictMode,null,r):r}}constructor(e){super(e),this.state={caughtError:null,caughtErrorInfo:null,config:{moduleName:t.moduleName,featureName:t.featureName,extension:e._extensionContext}}}},a="displayName",s=`OpenmrsReactComponent(${t.featureName})`,a in i?Object.defineProperty(i,a,{value:s,enumerable:!0,configurable:!0,writable:!0}):i[a]=s,o}}function as(e,t){return(0,i9.A)({React:iz(),ReactDOMClient:i7,rootComponent:aa(t)(e)})}function al(e,t){return()=>e().then(({default:e})=>as(e,t))}function ac(e,t){return()=>Promise.resolve(as(e,t))}let au=al,ad=(0,T.y)()(()=>({}));B("openmrs-app-context",ad);let am={};function ap(e,t=e=>e){let n=ad.getState();return e in n?Object.freeze(Object.assign({},t?t(n[e]):n[e])):null}function af(e,t){ad.setState(n=>(e in n||(n[e]={}),n[e]=t(n[e]),Object.assign({},n)))}function ag(e){return null===e?null:Object.freeze(Object.assign({},e))}let ah=new Map;function aw(e,t){let n=(0,iH.useRef)(t??{}),r=(0,iH.useRef)(t=>af(e,t)),o=(0,iH.useRef)(Symbol());return(0,iH.useEffect)(()=>{let n=t??{},r=o.current;return null===ap(e)?!function(e,t=am){ad.setState(n=>{if(e in n)throw Error(`Attempted to re-register namespace ${e} in the app context. Each namespace must be unregistered before the name can be registered again.`);return Object.assign({},n,{[e]:t===am?{}:t})})}(e,n):(console.warn(`Namespace ${e} is already registered in the app context. This is likely a race condition during navigation, but may indicate two components are trying to own the same namespace. Updating the existing context.`),af(e,()=>n)),ah.set(e,r),()=>{ah.get(e)===r&&(ad.setState(t=>(e in t&&delete t[e],t)),ah.delete(e))}},[e]),(0,iH.useEffect)(()=>{let r=t??{};E(n.current,r)||(af(e,()=>r),n.current=r)},[t]),r.current}function ay({namespace:e,value:t}){return aw(e,t),null}let a_=({children:e,value:t,fallback:n})=>t?iz().createElement(iz().Fragment,null,e):n?iz().createElement(iz().Fragment,null,n):null;function av(){let e=(0,iH.useRef)();return(!e.current||e.current.signal.aborted)&&(e.current=new AbortController),(0,iH.useEffect)(()=>{let t=e.current;return()=>t?.abort()},[]),e.current}function ab(e,t=e=>e??{}){let[n,r]=(0,iH.useState)(()=>{if(ax(e))return;let n=ap(e);if(null!==n)return t?t(n):n});return(0,iH.useEffect)(()=>{if(ax(e))throw Error(`The namespace supplied to useAppContext must be a non-empty string, but was "${e}".`)},[e]),(0,iH.useEffect)(()=>{var n;let o;return(n=e=>{if(null==e)return void r(void 0);let n=t?t(e):e;r(e=>E(e,n)?e:n)})(ag(o=ap(e))),ad.subscribe(t=>{let r=e in t?t[e]:null;r!==o&&(o=r,n(ag(r)))})},[e,t]),n}function ax(e){return"string"!=typeof e||0===e.trim().length}function ak(e){let t=i6(e);return(0,iH.useMemo)(()=>t.map(e=>e.id),[t])}function aS(e){return i2(e).candidateExtensions}function aj(e,t){let{data:n,error:r,mutate:o,isLoading:i,isValidating:a}=(0,at.Ay)(`${nM}?patient=${e}&includeEncounterless=${t}`,tA);return(0,iH.useMemo)(()=>({isLoading:i,data:n?.data.results??[],error:r,mutate:o,isValidating:a}),[n,r,i,a,o])}function aN(e){(0,iH.useEffect)(()=>{if(e){let e=window.getComputedStyle(document.body).overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=e}}},[e])}let aC={},aE=`No ComponentContext has been provided. This should come from "openmrsComponentDecorator".
15
+ ${this.stack}`}}let tP=L("session",{loaded:!1,session:null}),tT=0;function tR(e={includeAuthStatus:!0}){return(tT<Date.now()-6e4||!tP.getState().loaded)&&tW(),new G.Observable(t=>{let n=n=>{n.loaded&&(e.includeAuthStatus?t.next(n.session):t.next(n.session?.user))};return n(tP.getState()),tP.subscribe(n)})}function t$(){return(tT<Date.now()-6e4||!tP.getState().loaded)&&tW(),tP}function tM(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 tW(e,t){tT=Date.now();let n={};return e&&t&&(n.Authorization=`Basic ${window.btoa(`${e}:${t}`)}`),tz(tA(tC,{headers:n}))}function tD(){tP.setState({loaded:!0,session:{authenticated:!1,sessionId:""}})}function tL(e,t){var n,r;if(void 0===t)return!e;if(!e)return!0;return n=e,r=t,("string"==typeof n?!(0,z.A)(r.privileges.find(e=>n===e.display)):Array.isArray(n)?n.every(e=>!(0,z.A)(r.privileges.find(t=>e===t.display))):((0,z.A)(n)||console.error(`Could not understand privileges "${n}"`),!0))||!(0,z.A)(t.roles.find(e=>"System Developer"===e.display))}function tB(){let e,t;return new Promise(n=>{let r=r=>{r.loaded&&r.session.user&&(e=r.session.user,n(r.session.user),t&&t())};r(tP.getState()),e||(t=tP.subscribe(r))})}function tU(){return new Promise((e,t)=>{tR().subscribe(t=>{e(t.sessionLocation)},t).unsubscribe()})}async function tF(e,t){return tz(tA(tC,{method:"POST",body:{sessionLocation:e},headers:{"Content-Type":"application/json"},signal:t.signal}))}async function tH(e,t,n){return n||(n=new AbortController),await tA(`${tj}/user/${e}`,{method:"POST",body:{userProperties:t},headers:{"Content-Type":"application/json"},signal:n.signal}),tW()}function tz(e){return new Promise((t,n)=>{e.then(e=>{let r;"object"==typeof e?.data?(r={loaded:!0,session:e.data},tP.setState(r),t(r)):(r={loaded:!1,session:null},tP.setState(r),n(r))}).catch(e=>{j(`Failed to fetch new session information: ${e}`);let t={loaded:!1,session:null};tP.setState(t),n(t)})})}function tG(){return"development"===window.spaEnv||"true"===localStorage.getItem("openmrs:devtools")}tP.subscribe(e=>{e.loaded&&e.session&&tM(e.session)});let tV={"webservices.rest":"2.24.0",fhir2:"1.0.0-SNAPSHOT"};function tJ(){eT("@openmrs/esm-api",tk),tW()}let tq={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",batchActionItemSelected:"{{totalSelected}} item selected",batchActionsItemsSelected:"{{totalSelected}} items selected",cancel:"Cancel",change:"Change",Clinic:"Clinic",close:"Close",closesActionableNotification:"Close actionable notification",closeSnackbar:"Close snackbar",confirm:"Confirm",contactAdministratorIfIssuePersists:"Contact your system administrator if the problem persists.",contactDetails:"Contact details",delete:"Delete",discardChanges:"Discard changes",edit:"Edit",emptyStateText:"There are no {{displayText}} to display",error:"Error",errorCopy:"Sorry, there was a problem displaying this information. You can try to reload this page, or contact the site administrator and quote the error code above.",errorLoadingLoginLocations:"Unable to load login locations. Please try again or contact support if the problem persists.",female:"Female",leftNavigation:"Left navigation",loading:"Loading",localVersion:"Local Build",male:"Male",noResultsToDisplay:"No results to display",notAvailable:"Not available",other:"Other",paginationItemsCount:"{{pageItemsCount}} / {{totalItems}} items",paginationOfPages:"of {{count}} pages",patientAvatarAlt:"Avatar for {{patientName}}",patientIdentifierSticker:"Patient identifier sticker",patientLists:"Patient lists",patientPhotoAlt:"Profile photo of {{patientName}}",patientPhotoPlaceholder:"Photo placeholder for {{patientName}}",prereleaseVersion:"Prerelease",print:"Print",printError:"Print error",printErrorExplainer:"An error occurred in {{errorLocation}}",printIdentifierSticker:"Print identifier sticker",printing:"Printing",recordNewEntry:"Record {{displayText}}",relationships:"Relationships",resetOverrides:"Reset overrides",save:"Save",scriptLoadingFailed:"Error: Script failed to load",scriptLoadingError:"Failed to load overridden script from {{url}}. Please check that the bundled script is available at the expected URL. Click the button below to reset all import map overrides.",searchForLocation:"Search for a location",seeAll:"See all",seeMoreLists:"See {{count}} more lists",selectAll:"Select all",sex:"Sex",showLess:"Show less",showMore:"Show more",snackbarNotification:"Snackbar notification",toggleDevTools:"Toggle dev tools",unknown:"Unknown",yearAbbreviation:"yr",yearsAbbreviation:"yrs"};var tK=n(12279);let tX=tK.Ay.default||tK.Ay;function tQ(e,t,n,r){return tX.t(t,{ns:e,defaultValue:n,...r})}function tY(e,t,n){return tq[e]?tQ("core",e,t??tq[e],n):(console.error(`O3 Core Translations does not provide key '${e}'. The key itself is being rendered as text.`),e)}tX.on("initialized",function(){window.i18next.loadNamespaces(["core"])});let tZ="import-map-override:",t0="import-map-overrides-disabled",t1="import-map-overrides:change",t2=!1,t5=null,t6=null;async function t3(){return t6??(t6=t8().then(({map:e,complete:t})=>(t||(t6=null),e))),t6}async function t8(){let e=document.querySelectorAll('script[type="systemjs-importmap"]'),t=[],n=!0;for(let r=0;r<e.length;r++){let o=e[r];try{if(o.src){let e=await fetch(o.src);if(!e.ok)throw Error(`Request for ${o.src} returned ${e.status} ${e.statusText}`);t.push(await e.json())}else o.textContent&&t.push(JSON.parse(o.textContent))}catch(e){n=!1,console.warn(`[import-maps] Failed to parse import map from script tag at index ${r}`,e)}}return{map:t4(t),complete:n}}function t4(e){let t={imports:{}};for(let n of e)n?.imports&&Object.assign(t.imports,n.imports);return t}function t7(){let e={};try{let t=nr();for(let n=0;n<localStorage.length;n++){let r=localStorage.key(n);if(r?.startsWith(tZ)){let n=r.slice(tZ.length);if(!t.includes(n)){let t=localStorage.getItem(r);t&&(e[n]=t)}}}}catch(e){console.warn("[import-maps] Failed to read import-map overrides from localStorage",e)}return{imports:e}}async function t9(){let e=await t3();return t2?t4([e,t5??t7()]):e}async function ne(){return t3()}async function nt(){return t2?t4([await t3(),t7()]):t3()}function nn(e){if(!t2)return{imports:{}};if(e){let e={};for(let t=0;t<localStorage.length;t++){let n=localStorage.key(t);if(n?.startsWith(tZ)){let t=localStorage.getItem(n);t&&(e[n.slice(tZ.length)]=t)}}return{imports:e}}return t7()}function nr(){if(!t2)return[];try{let e=localStorage.getItem(t0);if(e){let t=JSON.parse(e);if(Array.isArray(t))return t}}catch{}return[]}function no(e){return!!t2&&nr().includes(e)}function ni(e,t){if(!t2)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{localStorage.setItem(tZ+e,t),window.dispatchEvent(new CustomEvent(t1))}catch(e){console.warn("[import-maps] Failed to write import-map override to localStorage",e)}}function na(e){if(!t2)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{localStorage.removeItem(tZ+e);let t=nr().filter(t=>t!==e);t.length>0?localStorage.setItem(t0,JSON.stringify(t)):localStorage.removeItem(t0),window.dispatchEvent(new CustomEvent(t1))}catch(e){console.warn("[import-maps] Failed to update import-map overrides in localStorage",e)}}function ns(){if(!t2)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{let e=[];for(let t=0;t<localStorage.length;t++){let n=localStorage.key(t);n?.startsWith(tZ)&&e.push(n)}e.forEach(e=>localStorage.removeItem(e)),localStorage.removeItem(t0),window.dispatchEvent(new CustomEvent(t1))}catch(e){console.warn("[import-maps] Failed to clear import-map overrides from localStorage",e)}}function nl(e){if(!t2)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{let t=nr().filter(t=>t!==e);t.length>0?localStorage.setItem(t0,JSON.stringify(t)):localStorage.removeItem(t0),window.dispatchEvent(new CustomEvent(t1))}catch(e){console.warn("[import-maps] Failed to update import-map overrides in localStorage",e)}}let nc=!1;function nu(){!nc&&(nc=!0,(t2="development"===window.spaEnv)&&(t5=t7()))}function nd(e){return e.replace(/[\/\-@]/g,"_")}async function nm(e,t="./start",r){var o;let i,a=!r?.maxLoadingTime||r.maxLoadingTime<=0?6e5:r.maxLoadingTime;await Promise.race([np(e,r?.importMap),new Promise((t,n)=>{i=setTimeout(()=>{var t;n(Error(`Could not resolve requested script, ${e}, within ${(t=a)<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`}.`))},a)})]),i&&clearTimeout(i);let s=nd(e),l=window[s];if(!("object"==typeof(o=l)&&null!==o&&"init"in o&&"function"==typeof o.init&&"get"in o&&"function"==typeof o.get)){let e=`The global variable ${s} does not refer to a federated module`;throw console.error(e),Error(e)}l.init(n.S.default);let c=(await l.get(t))();if("object"!=typeof c||null===c){let t=`Container for ${e} did not return an ESM module as expected`;throw console.error(t),Error(t)}return c}async function np(e,t){if("string"!=typeof e||0===e.trim().length){let e="Attempted to call importDynamic() without supplying a package to load";throw console.error(e),Error(e)}let n=nd(e);if(!window[n]){let n=t??await nf();if(!n.imports.hasOwnProperty(e)){let t=`Could not find the package ${e} defined in the current importmap`;throw console.error(t),Error(t)}let r=n.imports[e];r.startsWith("./")&&(r=window.spaBase+r.substring(1));let o=e in nn().imports;try{return await function(e){var t;let n=(t=window)[ng]??(t[ng]=new Map),r=n.get(e);if(r)return r;if(document.head.querySelector(`script[src="${e}"]`))return console.warn(`Script at ${e} already loaded. Not loading it again.`),Promise.resolve();let o=document.createElement("script");o.src=e,o.type="text/javascript",o.async=!0;let i=new Promise((t,r)=>{let i=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 a(){clearTimeout(i),o.removeEventListener("load",s),o.removeEventListener("error",l)}function s(){a(),t()}function l(t){a(),n.delete(e),o.remove();let i=`Failed to load script from ${e}`;console.error(i,t),r(t.message??i)}o.addEventListener("load",s),o.addEventListener("error",l),document.head.appendChild(o)});return n.set(e,i),i}(r)}catch(e){return o&&v({kind:"error",title:tY("scriptLoadingFailed","Error: Script failed to load"),description:tY("scriptLoadingError","Failed to load overridden script from {{- url}}. Please check that the bundled script is available at the expected URL. Click the button below to reset all import map overrides.",{url:r}),actionButtonLabel:tY("resetOverrides","Reset overrides"),onActionButtonClick(){ns(),window.location.reload()}}),Promise.reject(e)}}return Promise.resolve()}async function nf(){return t9()}let ng=Symbol.for("__openmrs_script_loading");function nh(e){return!!e&&"object"==typeof e&&!(Object.hasOwn(e,"pages")&&(!e.pages||!Array.isArray(e.pages))||Object.hasOwn(e,"extensions")&&(!e.extensions||!Array.isArray(e.extensions))||Object.hasOwn(e,"workspaces")&&(!e.workspaces||!Array.isArray(e.workspaces))||Object.hasOwn(e,"modals")&&(!e.modals||!Array.isArray(e.modals)))}function nw(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&&nh(t))}let ny="openmrs-routes:",n_="openmrs-routes:change",nv=!1,nb=null,nx=null;async function nk(){return nx??(nx=nS().then(({map:e,complete:t})=>(t||(nx=null),e))),nx}async function nS(){let e=document.querySelectorAll("script[type='openmrs-routes']"),t=[],n=!0;for(let r=0;r<e.length;r++){let o=e[r];try{let e;if(o.src){let t=await fetch(o.src);if(!t.ok)throw Error(`Request for ${o.src} returned ${t.status} ${t.statusText}`);e=await t.json()}else o.textContent&&(e=JSON.parse(o.textContent));e&&nw(e)&&t.push(e)}catch(e){n=!1,console.warn(`[route-maps] Failed to parse routes from script tag at index ${r}`,e)}}return{map:nj(t),complete:n}}function nj(e){let t={routes:{}};for(let n of e)n&&"object"==typeof n&&!Array.isArray(n)&&(Object.assign(t.routes,n.routes),void 0===t.version&&void 0!==n.version&&(t.version=n.version));return t}async function nN(){let e={version:void 0,routes:{}};try{let t=[];for(let e=0;e<localStorage.length;e++){let n=localStorage.key(e);if(n?.startsWith(ny)){let e=localStorage.getItem(n);e&&t.push({moduleName:n.slice(ny.length),raw:e})}}for(let n of(await Promise.allSettled(t.map(async({moduleName:e,raw:t})=>{let n=JSON.parse(t);if(nh(n))return{moduleName:e,routes:n};if("string"==typeof n&&n.startsWith("http")){let t=await fetch(n),r=await t.json();if(nh(r))return{moduleName:e,routes:r};throw Error(`${n} did not resolve to a valid OpenmrsAppRoutes object`)}throw Error(`Override for ${e} is neither a valid routes object nor a URL`)}))))"fulfilled"===n.status?e.routes[n.value.moduleName]=n.value.routes:console.warn("[route-maps] Failed to load route override",n.reason)}catch(e){console.warn("[route-maps] Failed to read route overrides from localStorage",e)}return e}async function nC(){let e=await nk();return nv?nj([e,nb??await nN()]):e}async function nE(){return nk()}async function nA(){return nv?nj([await nk(),await nN()]):nk()}function nI(){if(!nv)return{};let e={};try{for(let t=0;t<localStorage.length;t++){let n=localStorage.key(t);if(n?.startsWith(ny)){let t=localStorage.getItem(n);t&&(e[n.slice(ny.length)]=t)}}}catch(e){console.warn("[route-maps] Failed to read route overrides from localStorage",e)}return e}function nO(e,t){if(!nv)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{if("string"==typeof t)if(t.startsWith("http"))localStorage.setItem(ny+e,JSON.stringify(t));else{let n=JSON.parse(t);if(!nh(n))return void console.error(`The supplied routes for ${e} is not a valid OpenmrsAppRoutes object`,t);localStorage.setItem(ny+e,JSON.stringify(n))}else if(t instanceof URL)localStorage.setItem(ny+e,JSON.stringify(t.toString()));else{if(!nh(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(ny+e,JSON.stringify(t))}window.dispatchEvent(new CustomEvent(n_))}catch(e){console.warn("[route-maps] Failed to write route override to localStorage",e)}}function nP(e){if(!nv)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{localStorage.removeItem(ny+e),window.dispatchEvent(new CustomEvent(n_))}catch(e){console.warn("[route-maps] Failed to remove route override from localStorage",e)}}function nT(){if(!nv)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{let e=[];for(let t=0;t<localStorage.length;t++){let n=localStorage.key(t);n?.startsWith(ny)&&e.push(n)}e.forEach(e=>localStorage.removeItem(e)),window.dispatchEvent(new CustomEvent(n_))}catch(e){console.warn("[route-maps] Failed to clear route overrides from localStorage",e)}}let nR=null;function n$(){return nR||(nR=(nv="development"===window.spaEnv)?nN().then(e=>{nb=e}):Promise.resolve())}let nM=`${tj}/attachment`;function nW(e,t){return tA(`${nM}/${e}`,{signal:t.signal})}function nD(e,t,n){return tA(`${nM}?patient=${e}&includeEncounterless=${t}`,{signal:n.signal})}async function nL(e,t){let n=new FormData;return n.append("fileCaption",t.fileDescription),n.append("patient",e),t.file?n.append("file",t.file,t.fileName):(n.append("file",new File([""],t.fileName),t.fileName),n.append("base64Content",t.base64Content)),tA(`${nM}`,{method:"POST",body:n})}function nB(e,t){return tA(`${nM}/${e}`,{method:"DELETE",signal:t.signal})}var nU=n(68798);function nF(e,t){if(void 0!==i)return console.warn(`The application's Service Worker has already been registered. The new service worker at ${e} will not be registered.`),i;if(!("serviceWorker"in navigator))throw Error("Registering the Service Worker is not possible due to missing browser capabilities.");let n=new nU.JK(e,t);return i=n.register().then(()=>n.controlling.then(()=>n))}function nH(){return i??Promise.resolve(void 0)}let nz="x-omrs-offline-response-body",nG="x-omrs-offline-response-status",nV="x-omrs-offline-caching-strategy";async function nJ(e){let t=await nH();return t?await t.messageSW(e):{success:!1,result:void 0,error:"No service worker has been registered. This is typically the case when the application has been built without offline-related features."}}async function nq(){let e=window.sessionStorage;try{e.setItem("someKeyHere","test"),e.removeItem("someKeyHere")}catch(t){if(t.code===DOMException.QUOTA_EXCEEDED_ERR&&0===e.length)return!0}return!1}async function nK(){return!window.indexedDB}async function nX(){return new Promise(e=>{let t=indexedDB.open("test");t.onerror=()=>e(!0),t.onsuccess=()=>e(!1)})}async function nQ(){return await nX()||await nK()||await nq()}let nY="openmrs3:offline-mode",nZ="unavailable";function n0(){return{current:nZ,notAvailable:"unavailable"===nZ,active:"on"===nZ}}function n1(e){"unavailable"!==nZ&&"unavailable"!==e&&(localStorage.setItem(nY,"on"===e?"active":"disabled"),nZ=e)}async function n2(){await nQ()||(nZ="active"===localStorage.getItem(nY)?"on":"off"),navigator.onLine}var n5=n(98442);function n6(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class n3 extends n5.Ay{constructor(){super("EsmOffline"),n6(this,"syncQueue",void 0),n6(this,"dynamicOfflineData",void 0),this.version(4).stores({syncQueue:"++id,userId,type,[userId+type]",dynamicOfflineData:"++id,type,identifier,*users,&[type+identifier]"}),this.syncQueue=this.table("syncQueue"),this.dynamicOfflineData=this.table("dynamicOfflineData")}}function n8(){return new n3}let n4=new n3,n7={},n9=L("offline-synchronization",{});function re(){return n9}async function rt(){if(n9.getState().synchronization)return;let e=await n4.syncQueue.count(),t={},n=Object.entries(n7),r=n.length,o={},i=new AbortController,a=()=>{let e=n9.getState().synchronization;n9.setState({synchronization:{...e,pendingCount:e.pendingCount-1}})};try{n9.setState({synchronization:{totalCount:e,pendingCount:e,abortController:i}});for(let e=0;e<r&&n.length>0;e++)for(let e=n.length;e--;){let[r,s]=n[e],l=s.dependsOn.map(e=>t[e]);l.every(Boolean)&&(o[r]={},await Promise.all(l),t[r]=rn(s,o,i,a),n.splice(e,1))}await Promise.allSettled(Object.values(t))}finally{n9.setState({synchronization:void 0})}}async function rn({type:e,dependsOn:t,process:n},r,o,i){let a=[],s=[],l=await rr();await n4.syncQueue.where({type:e,userId:l}).each((e,t)=>{a.push([t.primaryKey,e.content,e.descriptor]),s.push(e.content)});for(let c=0;c<a.length;c++){let[u,d,{id:m,dependencies:p=[]}]=a[c];try{let i=await n(d,{abort:o,index:c,items:s,userId:l,dependencies:p.map(({id:e,type:n})=>t.includes(n)?r[n][e]:void 0)});void 0!==m&&(r[e][m]=i),await n4.syncQueue.delete(u)}catch(e){await n4.syncQueue.update(u,{lastError:{name:e?.name,message:e?.message??e?.toString()}})}finally{i()}}}async function rr(){let e=await tB();return e?.uuid||"*"}async function ro(e,t,n,r){let o=r&&r.id;return void 0!==o&&await n4.syncQueue.where({type:t,userId:e}).filter(e=>e?.descriptor.id===o).delete().catch(n5.Ay.errnames.DatabaseClosed),await n4.syncQueue.add({type:t,content:n,userId:e,descriptor:r||{},createdOn:new Date}).catch(n5.Ay.errnames.DatabaseClosed,()=>-1)}async function ri(e,t,n){let r=await rr();return await ro(r,e,t,n)}async function ra(e,t){return(await rs(e,t)).map(e=>e.content)}async function rs(e,t){return await n4.syncQueue.where(t?{type:t,userId:e}:{userId:e}).toArray().catch(n5.Ay.errnames.DatabaseClosed,()=>[])}async function rl(e){let t=await rr();return await ra(t,e)}async function rc(e){let t=await rr();return await rs(t,e)}async function ru(e){return await n4.syncQueue.get(e).catch(n5.Ay.errnames.DatabaseClosed,()=>void 0)}function rd(e){return!!n7[e]?.options.onBeginEditSyncItem}async function rm(e){let t=await ru(e);if(!t)throw Error(`No sync item with the ID ${e} exists.`);let n=n7[t.type]?.options.onBeginEditSyncItem;if(!n)throw Error(`A sync item with the ID ${e} exists, but the associated handler (if one exists) doesn't support editing the item. You can avoid this error by either verifying that sync items of this type can be edited via the "canEditSynchronizationItemsOfType(type: string)" function or alternatively ensure that the synchronizaton handler for sync items of type "${t.type}" supports editing items.`);n(t)}async function rp(e){await n4.syncQueue.delete(e).catch(n5.Ay.errnames.DatabaseClosed)}function rf(e,t,n,r={}){n7[e]={type:e,dependsOn:t,process:n,options:r}}var rg=n(71301);let rh="OFFLINE+";function rw(){return rh+(0,rg.A)()}function ry(e){return e.startsWith(rh)}let r_={};function rv(){return Object.values(r_)}function rb(e){r_[e.id]&&console.warn(`[setupDynamicOfflineDataHandler] Another second handler with the ID "${e.id}" was registered. This handler will override the previous one. This could be unintended as the previous handler might run different flows than the newly registered one. If this is the case, ensure that you are setting up the handlers with different IDs.`),r_[e.id]=e}async function rx(e){let t=await rI();return await rk(t,e)}async function rk(e,t){let n=new n3;return await n.dynamicOfflineData.where(t?{type:t,users:e}:{users:e}).toArray().catch(n5.Ay.errnames.DatabaseClosed,()=>[])}async function rS(e,t){let n=await rI();return await rj(n,e,t)}async function rj(e,t,n){let r=new n3,o=await r.dynamicOfflineData.get({type:t,identifier:n}).catch(n5.Ay.errnames.DatabaseClosed,()=>void 0);o?o.users.includes(e)||await r.dynamicOfflineData.update(o.id,{users:[...o.users,e]}).catch(n5.Ay.errnames.DatabaseClosed):await r.dynamicOfflineData.add({users:[e],type:t,identifier:n}).catch(n5.Ay.errnames.DatabaseClosed)}async function rN(e,t){let n=await rI();return await rC(n,e,t)}async function rC(e,t,n){let r=new n3,o=await r.dynamicOfflineData.get({type:t,identifier:n,users:e}).catch(n5.Ay.errnames.DatabaseClosed,()=>void 0);o&&(o.users.length>1?await r.dynamicOfflineData.update(o.id,{users:o.users.filter(t=>t!==e)}).catch(n5.Ay.errnames.DatabaseClosed):await r.dynamicOfflineData.delete(o.id).catch(n5.Ay.errnames.DatabaseClosed))}async function rE(e,t){let n=await rx(e);await Promise.all(n.map(async e=>rA(e.type,e.identifier,t)))}async function rA(e,t,n){await rS(e,t);let r=new n3,o=await rI(),i=await r.dynamicOfflineData.get({type:e,identifier:t}).catch(n5.Ay.errnames.DatabaseClosed,()=>void 0),a=rv().filter(t=>t.type===e);if(!i)return;let s=await Promise.all(a.map(async e=>{try{return e.sync(t,n),{id:e.id,error:void 0}}catch(n){let t=n.message?.toString()??n.toString();return{id:e.id,error:t}}})),l=s.filter(e=>!e.error).map(e=>e.id),c=s.filter(e=>e.error).map(e=>e.id),u=s.filter(e=>e.error).map(e=>({handlerId:e.id,message:e.error})),d={syncedOn:new Date,syncedBy:o,succeededHandlers:l,erroredHandlers:c,errors:u};i.id&&await r.dynamicOfflineData.update(i.id,{syncState:d}).catch(n5.Ay.errnames.DatabaseClosed)}async function rI(){let e=(await tB()).uuid;if(!e)throw Error("Using the dynamic offline data API requires a logged in user.");return e}let rO=L("offline-patients",{offlinePatientDataSyncState:{},handlers:{}});function rP(){return r$(),rO}function rT(e,t){r$(),rb({type:"patient",displayName:t.displayName,id:e,isSynced:()=>Promise.resolve(!0),sync:(e,n)=>t.onOfflinePatientAdded({patientUuid:e,signal:n??new AbortController().signal})})}async function rR(e){r$(),await rA("patient",e)}function r$(){console.warn("The offline patient API has been deprecated and will be removed in a future release. To prevent future crashes, the functions remain available for the moment, but any invocations should be migrated ASAP.")}async function rM(e,t,n=!0){if(e){let r=null,[o,i]=await Promise.all([tA(`${tN}/Patient/${e}`,t).catch(e=>r=e),n?rW(e):Promise.resolve(null)]);if(o.ok)return o.data;if(i)return i;if(r)throw r}return null}async function rW(e){let t=(await rl("patient-registration")).find(t=>t.fhirPatient.id===e);return t?.fhirPatient??null}function rD(e,t){let n=new CustomEvent(`openmrs:${e}`,{detail:t??void 0,cancelable:!0,bubbles:!0});return window.dispatchEvent(n)}function rL(e,t){let n=e=>{t("detail"in e&&null!==e.detail?e.detail:void 0)};return window.addEventListener(`openmrs:${e}`,n),()=>{window.removeEventListener(`openmrs:${e}`,n)}}var rB=n(83492);function rU(e){return{uuid:e.uuid,display:e.display}}function rF(e=null,t=null){let n=new URLSearchParams;e&&n.set("tag",e),t&&n.set("q",t);let r=n.toString();return tI(`${tj}/location${r?"?"+r:""}`).pipe((0,rB.map)(e=>e.data.results.map(rU))).pipe((0,rB.take)(1))}function rH(e){return{uuid:e.uuid,display:e.display,name:e.name}}function rz(){return tI(`${tj}/visittype`).pipe((0,rB.map)(e=>e.data.results.map(rH))).pipe((0,rB.take)(1))}var rG=((I={}).NEWVISIT="startVisit",I.EDITVISIT="editVisit",I.LOADING="loadingVisit",I),rV=((O={}).NOTSTARTED="notStarted",O.ONGOING="ongoing",O);let rJ="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))",rq=function(){try{return JSON.parse(sessionStorage.getItem("openmrs:visitStoreState")||"null")}catch(e){return null}}()||{patientUuid:null,manuallySetVisitUuid:null};function rK(){return U("visit",rq)}function rX(e,t){rK().setState({patientUuid:e,manuallySetVisitUuid:t})}function rQ(e,t){return tA(`${tj}/visit`,{signal:t.signal,method:"POST",headers:{"Content-type":"application/json"},body:e})}function rY(e,t,n){return tA(`${tj}/visit/${e}`,{signal:n.signal,method:"POST",headers:{"Content-type":"application/json"},body:t})}function rZ(e,t,n){return tA(`${tj}/visit?patient=${e}&v=${n??rJ}`,{signal:t.signal,method:"GET",headers:{"Content-type":"application/json"}})}rK().subscribe(e=>{var t;t=e,sessionStorage.setItem("openmrs:visitStoreState",JSON.stringify(t))});let r0=new G.BehaviorSubject(null);var r1=n(79225),r2=n(76881),r5=n(56828),r6=n(91956),r3=n(73635),r8=n(7839),r4=n(32298);let r7={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)}},r9={...r7,Promise};function oe(e,t={}){return oa(e,t,oc)}async function ot(e,t={}){return os(e,t,oc)}function on(e,t={}){return oa(e,t,ou)}function or(e,t={}){return os(e,t,ou)}function oo(e,t={}){return oa(e,t,od)}function oi(e,t={}){return os(e,t,od)}function oa(e,t={},n){if("string"!=typeof e&&("object"!=typeof e||!e||!("type"in e)))throw`Unknown expression type ${e}. Expressions must either be a string or pre-compiled string.`;if("string"==typeof e&&0===e.trim().length)throw{type:"Empty expression",message:"Expression cannot be an empty string"};null==t&&(t={});let r=of(t,r7),o=om("string"==typeof e?(0,r1.A)(e):e,r);if(n(o))return o;throw{type:"Invalid result",message:"string"==typeof e?`The expression ${e} did not produce a valid result`:"The expression did not produce a valid result"}}async function os(e,t={},n){if("string"!=typeof e&&("object"!=typeof e||!e||!("type"in e)))return Promise.reject(`Unknown expression type ${e}. Expressions must either be a string or pre-compiled string.`);if("string"==typeof e&&0===e.trim().length)throw{type:"Empty expression",message:"Expression cannot be an empty string"};null==t&&(t={});let r=of(t,r9);return Promise.resolve(om("string"==typeof e?(0,r1.A)(e):e,r)).then(t=>{if(n(t))return t;throw{type:"Invalid result",message:"string"==typeof e?`The expression ${e} did not produce a valid result`:"The expression did not produce a valid result"}})}function ol(e){return(0,r1.A)(e)}function oc(e){return"string"==typeof e||"number"==typeof e||"boolean"==typeof e||null==e||e instanceof Date}function ou(e){return"boolean"==typeof e}function od(e){return"number"==typeof e}function om(e,t){switch(e.type){case"UnaryExpression":var n,r,o,i,a,s,l,c,u,d,m,p,f=e,g=t;let h=om(f.argument,g);switch(f.operator){case"+":return+h;case"-":return-h;case"~":return~h;case"!":return!h;default:throw`Expression evaluator does not support operator '${f.operator}''`}case"BinaryExpression":var w=e,y=t;let _=om(w.left,y),v=om(w.right,y);switch(w.operator){case"+":return _+v;case"-":return _-v;case"*":return _*v;case"/":return _/v;case"%":return _%v;case"**":return _**v;case"==":return _==v;case"===":return _===v;case"!=":return _!=v;case"!==":return _!==v;case">":return _>v;case">=":return _>=v;case"<":return _<v;case"<=":return _<=v;case"in":return _ in v;case"&&":return _&&v;case"||":return _||v;case"??":return _??v;default:throw`Expression evaluator does not support operator '${w.operator}' operator`}case"ConditionalExpression":return n=e,r=t,om(n.test,r)?om(n.consequent,r):om(n.alternate,r);case"CallExpression":var b=e,x=t;let k=b.arguments?.map(og(x)),S=om(b.callee,x);if(S){if("function"!=typeof S)throw`${ow(b.callee)} is not a function`}else throw`No function named ${ow(b.callee)} is defined in this context`;return S(...k);case"ArrowFunctionExpression":let j;return o=e,i=t,j=o.params?.map(e=>{if("Identifier"===e.type)return e.name;throw`Cannot handle parameter of type ${e.type}`})??[],(function(...e){if(e.length<j.length)throw`Required argument(s) ${j.slice(e.length,-1).join(", ")} were not provided`;let t=Object.fromEntries(j.reduce((t,n,r)=>{let o=e[r];return function e(t){if("string"==typeof t||"number"==typeof t||"boolean"==typeof t||"function"==typeof t||null===t||t instanceof RegExp)return!0;if("object"==typeof t){for(let n of Object.keys(t))if(!e(t[n]))return!1;return!0}if(Array.isArray(t)){for(let n of t)if(!e(n))break}return!1}(o)&&t.push([n,o]),t},[]));return om(o.body,i.addVariables(t))}).bind(i.thisObj??null);case"MemberExpression":return function(e,t){let n,r=om(e.object,t);if(void 0===r)switch(e.object.type){case"Identifier":{let n=op(e.object,t);throw ReferenceError(`ReferenceError: ${n} is not defined`)}case"MemberExpression":{let n=op(e.property,t);throw TypeError(`TypeError: cannot read properties of undefined (reading '${n}')`)}default:throw`VisitMemberExpression does not support operator '${e.object.type}' type`}let o=r;if("string"==typeof r)o=String.prototype;else if("number"==typeof r)o=Number.prototype;else if("function"==typeof r);else if("object"!=typeof r)throw`VisitMemberExpression does not support member access on type ${typeof r}`;switch(t.thisObj=o,e.property.type){case"Identifier":case"MemberExpression":n=om(e.property,t);break;default:{let o=om(e.property,t);if(void 0===o)throw{type:"Illegal property access",message:"No property was supplied to the property access"};oh(o),n=r[o]}}return"function"==typeof n?n.bind(r):n}(e,t);case"ArrayExpression":return a=e,s=t,a.elements?.map(og(s));case"SequenceExpression":let N;return l=e,c=t,(N=l.expressions.map(og(c)))[N.length-1];case"NewExpression":var C=e,E=t;if(C.callee&&"Identifier"===C.callee.type){let e=C.arguments?.map(og(E));switch(C.callee.name){case"Date":return new Date(...e);case"RegExp":return new RegExp(...e);default:throw`Cannot instantiate object of type ${C.callee.name}`}}if(C.callee)throw"new must be called with either Date or RegExp";throw'Could not handle "new" without a specified class';case"Literal":return oh((u=e).value),u.value;case"Identifier":var A=e,I=t;oh(A.name);let O=I.thisObj;if(O&&("object"==typeof O||"function"==typeof O)&&A.name in O){let e=O[A.name];return oh(e),e}if(I.variables&&A.name in I.variables){let e=I.variables[A.name];return oh(e),e}return A.name in I.globals?I.globals[A.name]:void 0;case"TemplateLiteral":let P,T;return d=e,m=t,P=d.expressions?.map(og(m))??[],(T=d.quasis?.map(og(m))??[]).filter(e=>!e.tail).map(e=>e.value).join("")+P.join("")+T.filter(e=>e.tail).map(e=>e.value).join("");case"TemplateElement":return{value:(p=e).cooked,tail:p.tail};default:throw`Expression evaluator does not support expression of type '${e.type}'`}}function op(e,t){switch(e.type){case"Literal":return e.value;case"Identifier":return e.name;case"MemberExpression":return op(e.property,t);default:throw`VisitExpressionName does not support expression of type '${e.type}'`}}function of(e,t){let n={thisObj:void 0,variables:{...e},globals:{...t},addVariables(e){return this.variables={...this.variables,...e},this}};return n.addVariables.bind(n),n}function og(e){return function(t){return null===t?null:om(t,e)}}function oh(e){if("__proto__"===e||"prototype"===e||"constructor"===e)throw{type:"Illegal property access",message:`Cannot access the ${e} property of objects`}}function ow(e){return e?"MemberExpression"===e.type?e.property?.name:e.name:null}function oy(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:{...r9},isLocalExpression:!1,variables:new Set};return o_("string"==typeof e?(0,r1.A)(e):e,t),[...t.variables]}function o_(e,t){switch(e.type){case"UnaryExpression":return r=e,o=t,o_(r.argument,o);case"BinaryExpression":return i=e,a=t,[o_(i.left,a),o_(i.right,a)].filter(Boolean);case"ConditionalExpression":return s=e,l=t,[o_(s.consequent,l),o_(s.test,l),o_(s.alternate,l)].filter(Boolean);case"CallExpression":let n;return c=e,u=t,n=o_(c.callee,u),c.arguments?.map(ov(u)),n;case"ArrowFunctionExpression":var r,o,i,a,s,l,c,u,d,m,p,f,g,h,w,y,_,v,b=e,x=t;let k={...x};k.isLocalExpression=!0;let S=b.params?.map(ov(k))??[],j=o_(b.body,k)??[];if(j&&Array.isArray(j))for(let e of j)S.includes(e)||x.variables.add(e);return;case"MemberExpression":let N;return d=e,m=t,o_(d.object,m),void((N={...m}).isLocalExpression=!0,o_(d.property,N));case"ArrayExpression":return p=e,f=t,void p.elements?.map(ov(f));case"SequenceExpression":return g=e,h=t,void g.expressions?.map(ov(h));case"NewExpression":return w=e,y=t,void w.arguments?.map(ov(y));case"Literal":case"TemplateElement":return;case"Identifier":var C=e,E=t;if(!(C.name in E.globals))if(E.isLocalExpression)return C.name;else E.variables.add(C.name);return;case"TemplateLiteral":return _=e,v=t,void(_.expressions?.map(ov(v)),_.quasis?.map(ov(v)));default:throw`Expression evaluator does not support expression of type '${e.type}'`}}function ov(e){return function(t){return null===t?null:o_(t,e)}}r1.A.plugins.register(r2.A),r1.A.plugins.register(r5.A),r1.A.plugins.register(r6.A),r1.A.plugins.register(r3.A),r1.A.plugins.register(r8.A),r1.A.plugins.register(r4.A),r1.A.addBinaryOp("in",7),r1.A.addBinaryOp("??",1);let ob=U("feature-flags",{flags:function(){let e={};for(let t of Object.keys(localStorage))if(t.startsWith("openmrs:feature-flag:")){let n=t.replace("openmrs:feature-flag:",""),r=JSON.parse(localStorage.getItem(`openmrs:feature-flag-meta:${n}`)||"{}");e[n]={enabled:"true"===localStorage.getItem(t),...r}}return e}()});function ox(e,t,n){ob.setState(r=>({flags:{...r.flags,[e]:{enabled:r.flags[e]?.enabled??!1,label:t,description:n}}}))}function ok(){let e=ob.getState().flags;Object.keys(localStorage).filter(e=>e.startsWith("openmrs:feature-flag:")).forEach(t=>{let n=t.replace("openmrs:feature-flag:","");e[n]||(localStorage.removeItem(t),localStorage.removeItem(`openmrs:feature-flag-meta:${n}`))})}function oS(e){return ob.getState().flags[e].enabled}function oj(e,t){ob.subscribe(n=>{t(n.flags[e].enabled)})}function oN(e,t){ob.setState(n=>({flags:{...n.flags,[e]:{...n.flags[e],enabled:t}}}))}function oC(e){return!window.offlineEnabled||(e??navigator.onLine)}ob.subscribe(e=>{for(let[t,n]of Object.entries(e.flags))localStorage.setItem(`openmrs:feature-flag:${t}`,n.enabled.toString()),localStorage.setItem(`openmrs:feature-flag-meta:${t}`,JSON.stringify({label:n.label,description:n.description}))});var oE=n(11216);function oA(e=!0,t=!1){return oI(oC(),e,t)}function oI(e,t=!0,n=!1){return!!(e?t:n)}let oO=L("extensionsInternal",{slots:{},extensions:{}}),oP=L("extensionRenderings",{renderings:new Map}),oT=()=>U("extensionsInternal",{slots:{},extensions:{}}),oR=()=>U("extensionRenderings",{renderings:new Map});function o$(e){let t=oO.getState(),n=e(t);n!==t&&oO.setState(n)}let oM=null,oW=null;function oD(){let e=oP.getState();return oM&&e===oW||(oM=new Map(e.renderings),oW=e,function(e){for(let t of(oq.clear(),e.values()))oX(t,1);oK=!0}(oM)),oM}function oL(e){oW={renderings:e},oP.setState(oW,!0)}function oB(e){let t=oD();t.has(e.renderingId)||(t.set(e.renderingId,e),oX(e,1),oL(t))}function oU(e){let t=oD(),n=t.get(e);n&&(t.delete(e),oX(n,-1),oL(t))}let oF=()=>U("extensions",{slots:{}}),oH=0,oz=new Set;function oG(e){oH++;try{return e()}finally{if(0==--oH&&oz.size>0){let e=Array.from(oz);for(let t of(oz.clear(),e))oV(t)}}}function oV(e){try{e()}catch(t){console.error(`The extension system's '${e.name}' recomputation failed`,t)}}function oJ(e){oH>0?oz.add(e):oV(e)}let oq=new Map,oK=!1;function oX(e,t){let n=JSON.stringify([e.slotName,e.extensionId,e.slotModuleName,e.extensionModuleName]),r=oq.get(n);if(!r){if(t<0)return;oq.set(n,{count:1,record:{slotModuleName:e.slotModuleName,extensionModuleName:e.extensionModuleName,slotName:e.slotName,extensionId:e.extensionId}}),oK=!0;return}r.count+=t,r.count<1&&(oq.delete(n),oK=!0)}function oQ(){var e,t;if(oD(),!oK)return;oK=!1;let n=Array.from(oq.values(),({record:e})=>e);n.sort(oY),e=es.getState().mountedExtensions,t=n,e.length===t.length&&e.every((e,n)=>0===oY(e,t[n]))||es.setState({mountedExtensions:n})}function oY(e,t){return oZ(e.slotName,t.slotName)||oZ(e.extensionId,t.extensionId)||oZ(e.slotModuleName,t.slotModuleName)||oZ(e.extensionModuleName,t.extensionModuleName)}function oZ(e,t){return e===t?0:e<t?-1:1}oQ(),oP.subscribe(()=>oJ(oQ));let o0=oT(),o1=oF(),o2=ec(),o5=em(),o6=new Set,o3=!1;function o8(e){if(null===e)o6=null;else if(null!==o6)for(let t of e)o6.add(t);oJ(o4)}function o4(){if(!o3){o3=!0;try{for(let e=1;;e++){let t=o6;if(null!==t&&0===t.size)return;o6=new Set;try{!function(e,t,n,r,o,i=null){let a=o1.getState().slots,s={},l=!1,c=oC(),u=Object.entries(r.flags).filter(([,{enabled:e}])=>e).map(([e])=>e);for(let[r,d]of Object.entries(e.slots)){let m=a[r];if(m&&i&&!i.has(r)){s[r]=m;continue}let{config:p}=ed(t,d.name),f=function(e,t,n,r,o,i,a){let s=function(e,t){let n=e.add||[],r=e.remove||[],o=e.order||[],{extensions:i}=o0.getState();return[...t,...n].filter(e=>!r.includes(e)).sort((e,n)=>ic(e,o,i[it(e)]?.order,t)-ic(n,o,i[it(n)]?.order,t))}(n,t.slots[e].attachedIds),l=[];for(let c of s){let{config:s}=ef(r,e,c),u=eg(n,e,c),d=u?(0,oE.A)({},s,u):s,m=it(c),p=t.extensions[m];if(p){let e=d?.["Display conditions"]?.privileges??p.privileges??[];if(e&&("string"==typeof e||Array.isArray(e)&&e.length>0)&&(!a?.user||!tL(e,a.user))||p.featureFlag&&!o.includes(p.featureFlag)||window.offlineEnabled&&!oI(i,p.online,p.offline))continue;l.push({id:c,name:m,moduleName:p.moduleName,config:d,featureFlag:p.featureFlag,meta:p.meta,online:d?.["Display conditions"]?.online??p.online??!0,offline:d?.["Display conditions"]?.offline??p.offline??!1,displayConditionExpression:d?.["Display conditions"]?.expression||p.displayExpression})}}return l}(r,e,p,n,u,c,o.session);m&&m.moduleName===d.moduleName&&(0,q.A)(m.candidateExtensions,f)?s[r]=m:(s[r]={moduleName:d.moduleName,candidateExtensions:f},l=!0)}(l||Object.keys(a).length!==Object.keys(s).length)&&o1.setState({slots:s})}(o0.getState(),o2.getState(),o5.getState(),ob.getState(),tP.getState(),t)}catch(e){throw o6=null===t||null===o6?null:new Set([...t,...o6]),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{o3=!1}}}function o7(e,t){let n=new Set;for(let r of Object.keys(e))e[r]!==t[r]&&n.add(r);for(let r of Object.keys(t))r in e||n.add(r);return n}function o9(){o8(null)}function ie(e,t){return{moduleName:t,name:e,attachedIds:[]}}function it(e){let[t]=e.split("#");return t}function ir(e,t){let n=it(t);return e.extensions[n]}function io(e){return ir(o0.getState(),e)}o0.subscribe((e,t)=>{o8(e.extensions!==t.extensions?null:o7(e.slots,t.slots))}),o2.subscribe((e,t)=>{o8(o7(e.slots,t.slots))}),o5.subscribe((e,t)=>{o8(o7(e.configs,t.configs))}),ob.subscribe(()=>o8(null)),tP.subscribe(()=>o8(null)),o9(),l(o9);let ii=e=>o$(t=>({...t,extensions:{...t.extensions,[e.name]:{...e}}}));function ia(e,t){o$(n=>{let r=n.slots[e];return r?{...n,slots:{...n.slots,[e]:{...r,attachedIds:[...r.attachedIds,t]}}}:{...n,slots:{...n.slots,[e]:{...ie(e),attachedIds:[t]}}}})}function is(e,t){o$(n=>{let r=n.slots[e];return r&&r.attachedIds.includes(t)?{...n,slots:{...n.slots,[e]:{...r,attachedIds:r.attachedIds.filter(e=>e!==t)}}}:n})}function il(e){o$(t=>{let n=t.slots[e];return n?{...t,slots:{...t.slots,[e]:{...n,attachedIds:[]}}}:t})}function ic(e,t,n,r){let o=t.indexOf(e);if(-1!==o)return o;{if(void 0!==n)return 1e3+n;let t=r.indexOf(e);return -1!==t?2e3+t:3e3}}function iu(e,t){return function(e,t,n=null,r){let o;return e.filter(e=>{let i=e.displayConditionExpression;if("string"!=typeof i||0===i.trim().length)return!0;o??(o=t&&"object"==typeof t?{session:n,...t}:{session:n});try{return!!on(i,o)}catch(t){return console.error(`Error while evaluating expression '${i}' for ${e.id}`+(r?` in ${r}`:""),t),!1}})}(id(e),t,tP.getState().session,e)}function id(e){return o1.getState().slots[e]?.candidateExtensions??[]}let im=(e,t)=>o0.setState(n=>{let r=n.slots[t]?.moduleName;if(r&&r!=e)return console.warn(`An extension slot with the name '${t}' already exists. Refusing to register the same slot name twice (in "registerExtensionSlot"). The existing one is from module ${r}.`),n;if(r&&r==e)return n;if(n.slots[t])return{...n,slots:{...n.slots,[t]:{...n.slots[t],moduleName:e}}};let o=ie(t,e);return{...n,slots:{...n.slots,[t]:{...o}}}}),ip=()=>{o6=null,o$(()=>({slots:{},extensions:{}})),oR().setState({renderings:new Map}),o1.setState({slots:{}})},ig=L("left-nav",{slotName:null,basePath:window.spaBase,mode:"normal"});function ih({name:e,basePath:t,mode:n,componentContext:r,state:o}){ig.setState({slotName:e,basePath:t,mode:n??"normal",componentContext:r,state:o})}function iw(e){ig.getState().slotName===e&&ig.setState(ig.getInitialState(),!0)}let iy=L("modalRegistry",{modals:{}});function i_(e){iy.setState(t=>(t.modals[e.name]=e,t))}function iv(e){let t=iy.getState().modals[e];if(!t){let n=io(e);n&&(t={name:e,load:n.load,moduleName:n.moduleName},console.warn(`Modal ${e} was registered as an extension. This is deprecated and will be removed in the future. Please register it in the "modals" section of routes.json instead of the "extensions" section.`),i_(t))}return t}let ib=L("workspaceRegistrations",{workspaces:{}}),ix=L("workspaceGroups",{workspaceGroups:{}});function ik(e){ib.setState(t=>({workspaces:{...t.workspaces,[e.name]:{...e,load:e.load,preferredWindowSize:e.preferredWindowSize??"normal",type:e.type??"form",canHide:e.canHide??!1,canMaximize:e.canMaximize??!1,width:e.width??"narrow",groups:e.groups??[]}}}))}function iS(e){ix.setState(t=>{let n=t.workspaceGroups[e.name];return n?{workspaceGroups:{...t.workspaceGroups,[e.name]:{...n,members:Array.from(new Set([...n.members,...e.members]))}}}:{workspaceGroups:{...t.workspaceGroups,[e.name]:{name:e.name,members:e.members}}}})}let ij=new Set;function iN(e){let t=ib.getState().workspaces;if(t[e])return t[e];{let t=io(e);if(t){var n;let r;return ij.has(e)||(console.warn(`The workspace '${e}' is registered as an extension. This is deprecated. Please register it in the "workspaces" section of the routes.json file.`),ij.add(e)),{name:t.name,title:(n=t,"string"==typeof(r=n?.meta?.title)?r:r&&"object"==typeof r?tQ(n.moduleName,r.key,r.default):n.name),moduleName:t.moduleName,preferredWindowSize:t.meta?.screenSize??"normal",load:t.load,type:t.meta?.type??"form",canHide:t.meta?.canHide??!1,canMaximize:t.meta?.canMaximize??!1,width:t.meta?.width??"narrow",groups:t.meta?.groups??[]}}throw Error(`No workspace named '${e}' has been registered.`)}}function iC(e){let t=ix.getState().workspaceGroups;if(t[e])return t[e];throw Error(`No workspace group named '${e}' has been registered.`)}let iE=L("workspace2",{registeredGroupsByName:{},registeredWindowsByName:{},registeredWorkspacesByName:{},openedGroup:null,openedWindows:[],workspaceTitleByWorkspaceName:{},isMostRecentlyOpenedWindowHidden:!1});function iA(e){let{registeredWorkspacesByName:t,registeredWindowsByName:n}=iE.getState(),r=t[e];if(r){let t=n[r.window];if(t)return t;throw Error(`No workspace window found with name: ${r.window} for workspace: ${e}`)}throw Error(`No workspace found with name: ${e}`)}function iI(e){let{registeredGroupsByName:t,registeredWindowsByName:n}=iE.getState(),r=n[e];if(r){let n=t[r.group];if(n)return n;throw Error(`No workspace group found with name: ${r.group} for window: ${e}`)}throw Error(`No workspace window found with name: ${e}`)}function iO(e){let{openedWindows:t}=iE.getState();return t.findIndex(t=>t.openedWorkspaces.find(t=>t.workspaceName===e))}function iP(e,t){if(0==t.length)return;let{registeredGroupsByName:n}=iE.getState(),r={...n};for(let n of t){if(r[n.name])throw Error(`Cannot register workspace group ${n.name} more than once`);r[n.name]={...n,moduleName:e}}iE.setState({registeredGroupsByName:r})}function iT(e,t){if(0==t.length)return;let{registeredWindowsByName:n}=iE.getState(),r={...n};for(let n of t){if(r[n.name])throw Error(`Cannot register workspace window ${n.name} more than once`);let t={...n,moduleName:e};r[n.name]=t}iE.setState({registeredWindowsByName:r})}function iR(e,t){if(0==t.length)return;let{registeredWorkspacesByName:n}=iE.getState(),r={...n};for(let n of t){if(r[n.name])throw Error(`Cannot register workspace ${n.name} more than once`);let t={...n,moduleName:e};r[n.name]=t}iE.setState({registeredWorkspacesByName:r})}let i$=0,iM=null,iW={bootstrap:15e3,mount:15e3,unmount:15e3};function iD(e,t){if(e.timeouts)return e;let n=e.name??"parcel",r=Object.fromEntries(Object.keys(iW).filter(t=>e[t]).map(r=>{var o,i;let a,s;return[r,(o=e[r],i=iW[r],a=Array.isArray(o)?o:[o],s=e=>a.reduce((t,o,i)=>t.then(()=>{let t=o(e);return"function"==typeof t?.then&&"function"==typeof t?.catch?t:Promise.reject(Error(`Lifecycle function ${r} at array index ${i} for parcel ${n} did not return a promise`))}),Promise.resolve(void 0)),e=>{let o,a=new Promise((e,t)=>{o=setTimeout(()=>t(Error(`Lifecycle function ${r} for parcel ${n} did not settle within ${i}ms`)),i)});return Promise.race([s(e),a]).finally(()=>clearTimeout(o)).then(e=>(t(r,!1),e),e=>{throw t(r,!0),e})})]}));return{...e,...r}}async function iL(e,t){var n,r;let o,i,a,s,l,c=await (iM??(iM=new Promise((e,t)=>{(0,tm.mountRootParcel)({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),tm.mountRootParcel))),iM),u={...t},d=(o=u,i=!1,{retarget:e=>o={...e},release:a=()=>(function(e){for(let t of Object.keys(e))delete e[t]})(o),onSettled(e,t){switch(e){case"bootstrap":t&&a();return;case"mount":i||(i=t);return;case"unmount":(t||i)&&a();return}}});return r=c((n=d.onSettled,"function"==typeof e?()=>e().then(e=>iD(e,n)):iD(e,n)),u),s=e=>t=>e.call(r,d.retarget(t)).catch(e=>{throw"SKIP_BECAUSE_BROKEN"===r.getStatus()&&d.release(),e}),l=r.update&&s(r.update),Object.defineProperty(r,"update",{configurable:!0,enumerable:!0,get:()=>l,set:e=>{l=e&&s(e)}})}function iB(){return iU}function iU(e,t){let n,r=iL(e,t).then(e=>n=e);return{mount:()=>r.then(e=>e.mount()),unmount:()=>r.then(e=>e.unmount()),update:e=>r.then(t=>t.update?.(e)),getStatus:()=>n?.getStatus()??"LOADING_SOURCE_CODE",get loadPromise(){return r.then(e=>e.loadPromise)},get bootstrapPromise(){return r.then(e=>e.bootstrapPromise)},get mountPromise(){return r.then(e=>e.mountPromise)},get unmountPromise(){return r.then(e=>e.unmountPromise)}}}async function iF(e,t,n,r,o=e=>e,i={}){let a=it(r),s=io(r),l=null;if(e){if(!s)throw Error(`Couldn't find extension '${a}' to attach to '${t}'`);let{meta:c,moduleName:u,online:d,offline:m,load:p}=s;if(oA(d,m)){let s,d=i$++,m=`${t}/${r}-${d}`;e.dataset.extensionRenderingId=m;let f=e=>{try{oU(m)}catch(t){console.error(e,t)}};try{oB({renderingId:m,extensionName:a,extensionModuleName:u,extensionId:r,slotName:t,slotModuleName:n})}catch(e){throw f(`Recomputing configuration after registering '${r}' failed also failed`),e}try{s=await p()}catch(e){throw f(`Recomputing configuration after '${r}' failed to load also failed`),e}try{l=await iL(o({...s,name:`${t}/${a}-${d}`}),{...i,_meta:c,_extensionContext:{extensionId:r,extensionSlotName:t,extensionSlotModuleName:n,extensionModuleName:u},domElement:e})}catch(e){throw f(`Recomputing configuration after '${r}' failed to mount also failed`),e}l.mountPromise.then(void 0,e=>{console.error(`Extension '${r}' in slot '${t}' failed to mount`,e),f(`Recomputing configuration after '${r}' failed to mount also failed`)}),l.unmountPromise.then(()=>f(`Recomputing configuration after unmounting '${r}' failed`),e=>{console.error(`Extension '${r}' in slot '${t}' failed to unmount`,e),f(`Recomputing configuration after '${r}' failed to unmount also failed`)})}}else console.warn(`Tried to render ${r} into ${t} but no DOM element was available.`);return l}var iH=n(46925),iz=n.n(iH);let iG=(0,iH.createContext)({moduleName:"",featureName:""});function iV({to:e,templateParams:t,onBeforeNavigate:n,children:r,...o}){return(0,iH.useEffect)(()=>{o.href&&console.warn(`ConfigurableLink does not support the href prop. Use the 'to' prop instead. The provided href value is '${o.href}'`),o.onClick&&console.warn(`ConfigurableLink does not support the onClick prop. Use the 'onBeforeNavigate' prop instead. The 'to' prop of the offending link is ${e}`)},[]),iz().createElement("a",{onClick:r=>{0===r.button&&!r.ctrlKey&&!r.shiftKey&&!r.altKey&&!r.metaKey&&(r.preventDefault(),n?.(r),tg({to:e,templateParams:t})),0===r.button&&(r.ctrlKey||r.metaKey)&&n?.(r),0===r.button&&r.shiftKey&&n?.(r),1===r.button&&n?.(r)},href:tp(e,t),...o},r)}let iJ=({state:e,children:t,...n})=>{let{extension:r}=(0,iH.useContext)(iG),o=(0,iH.useRef)(null),i=(0,iH.useRef)(Promise.resolve()),a=(0,iH.useRef)(!1),s=(0,iH.useRef)(!1),l=(0,iH.useRef)(e),c=(0,iH.useCallback)(e=>{if(!e)return;let t=()=>{"MOUNTED"===e.getStatus()&&e.unmount()};switch(e.getStatus()){case"MOUNTED":e.unmount();break;case"UPDATING":i.current?.then(t,t);break;default:e.mountPromise.then(t,()=>{})}},[]),u=(0,iH.useCallback)((e,t)=>{e.update&&"UNMOUNTING"!==e.getStatus()&&(i.current=Promise.all([e.mountPromise,i.current]).then(()=>{if(o.current?.getStatus()==="MOUNTED"&&o.current.update)return o.current.update({...t})}).catch(e=>{let t=o.current?.getStatus();"UNMOUNTING"!==t&&"NOT_MOUNTED"!==t&&"UNLOADING"!==t&&console.error(`The extension '${r?.extensionId}' failed to update`,e)}))},[]),d=(0,iH.useCallback)(t=>{t&&!o.current&&!s.current&&r?.extensionSlotName&&r.extensionSlotModuleName&&(s.current=!0,iF(t,r.extensionSlotName,r.extensionSlotModuleName,r.extensionId,void 0,e).then(t=>{(s.current=!1,o.current=t,a.current)?c(t):t&&l.current!==e&&u(t,l.current)},()=>{s.current=!1}))},[]);return(0,iH.useEffect)(()=>(a.current=!1,()=>{a.current=!0,c(o.current)}),[]),(0,iH.useEffect)(()=>{l.current=e,o.current&&u(o.current,e)},[e]),r?iz().createElement("div",{ref:d,"data-extension-id":r?.extensionId,style:{position:"relative"},...n}):null};function iq(e){let t=(0,iH.useRef)(e);return E(t.current,e)||(t.current=e),t.current}function iK(e,t){"function"==typeof t&&(t=t(e));let n={};for(let[r,o]of Object.entries(t)){let t=function(...t){e.setState(e=>o(e,...t))};n[r]=t}return n}let iX=e=>e;function iQ(e,t=iX,n){let r=(0,iH.useCallback)(t=>e.subscribe(t),[e]),o=(0,iH.useCallback)(()=>t(e.getState()),[e,t]),i=(0,iH.useSyncExternalStore)(r,o,o),a=(0,iH.useMemo)(()=>n?iK(e,n):null,[e,n]);return(0,iH.useMemo)(()=>a?{...i,...a}:i,[i,a])}function iY(e,t){return iQ(e,iX,t)}function iZ(e){return function(t){let n=(0,iH.useCallback)(t=>e.subscribe(t),[]),r=(0,iH.useCallback)(()=>e.getState(),[]),o=(0,iH.useSyncExternalStore)(n,r,r),i=(0,iH.useMemo)(()=>t?iK(e,t):null,[t]);return(0,iH.useMemo)(()=>i?{...o,...i}:o,[o,i])}}let i0=[];Object.freeze(i0);let i1={candidateExtensions:i0};Object.freeze(i1);let i2=e=>{let t=(0,iH.useCallback)(t=>t.slots?.[e]??i1,[e]);return iQ(oF(),t)},i5=e=>e.session;function i6(e,t){let{candidateExtensions:n}=i2(e),r=iQ(tP,i5),o=iq(t);return(0,iH.useMemo)(()=>iu(e,o),[e,o,r,n])}function i3(e,t){let{moduleName:n}=(0,iH.useContext)(iG);if(!n)throw Error("ComponentContext has not been provided. This should come from @openmrs/esm-react-utils.");return(0,iH.useEffect)(()=>{im(n,e)},[n,e]),{extensions:i6(e,t),extensionSlotName:e,extensionSlotModuleName:n}}function i8(e){return e}function i4({name:e,extensionSlotName:t,select:n=i8,children:r,state:o,style:i,...a}){if(r&&o)throw Error("Both children and state have been provided. If children are provided, the state must be passed as a prop to the `Extension` component.");let s=e??t,l=(0,iH.useRef)(null),{extensions:c,extensionSlotModuleName:u}=i3(s,o),d=(0,iH.useMemo)(()=>n(c),[n,c]),m=(0,iH.useMemo)(()=>{if("function"==typeof r&&!iz().isValidElement(r))return d.map(e=>r(e,o))},[r,d]);return iz().createElement("div",{ref:l,"data-extension-slot-name":s,"data-extension-slot-module-name":u,style:{...i,position:"relative"},...a},s&&d?.map((e,t)=>iz().createElement(iG.Provider,{key:e.id,value:{moduleName:u,featureName:"",extension:{extensionId:e.id,extensionSlotName:s,extensionSlotModuleName:u}}},m?.[t]??("function"!=typeof r?r:null)??iz().createElement(iJ,{state:o}))))}var i7=n(63776),i9=n(69568),ae=n(99737),at=n(47488),an=n(51405);let ar={strictMode:!0,throwErrorsToConsole:!0,disableTranslations:!1},ao=new Map;(0,an.r2)(ao);let ai={errorRetryCount:3,fetcher:tA,focusThrottleInterval:18e5,revalidateIfStale:!0,revalidateOnFocus:!1,revalidateOnReconnect:!1,refreshInterval:0,shouldRetryOnError:e=>{if(e instanceof tO){let t=e.response.status;return!!(t>=500)||401===t||403===t||429===t}return!0},provider:()=>ao};function aa(e){if("object"!=typeof e||"string"!=typeof e.featureName||"string"!=typeof e.moduleName)throw Error("Invalid options");let t=Object.assign({},ar,e),n={...ai,...t.swrConfig};return function(e){var r,o,i,a,s;return i=o=class extends(r=iz().Component){componentDidCatch(e,n){n&&n.componentStack&&(e.extra=Object.assign(e.extra||{},{componentStack:n.componentStack})),t.throwErrorsToConsole&&setTimeout(()=>{throw e}),this.setState({caughtError:e,caughtErrorInfo:n})}render(){if(this.state.caughtError)return iz().createElement("div",null,"An error has occurred. Please try reloading the page.");{let r=iz().createElement(iH.Suspense,{fallback:null},iz().createElement(at.BE,{value:n},iz().createElement(iG.Provider,{value:this.state.config},t.disableTranslations?iz().createElement(e,this.props):iz().createElement(ae.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},iz().createElement(e,this.props)))));return t.strictMode&&iz().StrictMode?iz().createElement(iz().StrictMode,null,r):r}}constructor(e){super(e),this.state={caughtError:null,caughtErrorInfo:null,config:{moduleName:t.moduleName,featureName:t.featureName,extension:e._extensionContext}}}},a="displayName",s=`OpenmrsReactComponent(${t.featureName})`,a in i?Object.defineProperty(i,a,{value:s,enumerable:!0,configurable:!0,writable:!0}):i[a]=s,o}}function as(e,t){return(0,i9.A)({React:iz(),ReactDOMClient:i7,rootComponent:aa(t)(e)})}function al(e,t){return()=>e().then(({default:e})=>as(e,t))}function ac(e,t){return()=>Promise.resolve(as(e,t))}let au=al,ad=(0,T.y)()(()=>({}));B("openmrs-app-context",ad);let am={};function ap(e,t=e=>e){let n=ad.getState();return e in n?Object.freeze(Object.assign({},t?t(n[e]):n[e])):null}function af(e,t){ad.setState(n=>(e in n||(n[e]={}),n[e]=t(n[e]),Object.assign({},n)))}function ag(e){return null===e?null:Object.freeze(Object.assign({},e))}let ah=new Map;function aw(e,t){let n=(0,iH.useRef)(t??{}),r=(0,iH.useRef)(t=>af(e,t)),o=(0,iH.useRef)(Symbol());return(0,iH.useEffect)(()=>{let n=t??{},r=o.current;return null===ap(e)?!function(e,t=am){ad.setState(n=>{if(e in n)throw Error(`Attempted to re-register namespace ${e} in the app context. Each namespace must be unregistered before the name can be registered again.`);return Object.assign({},n,{[e]:t===am?{}:t})})}(e,n):(console.warn(`Namespace ${e} is already registered in the app context. This is likely a race condition during navigation, but may indicate two components are trying to own the same namespace. Updating the existing context.`),af(e,()=>n)),ah.set(e,r),()=>{ah.get(e)===r&&(ad.setState(t=>(e in t&&delete t[e],t)),ah.delete(e))}},[e]),(0,iH.useEffect)(()=>{let r=t??{};E(n.current,r)||(af(e,()=>r),n.current=r)},[t]),r.current}function ay({namespace:e,value:t}){return aw(e,t),null}let a_=({children:e,value:t,fallback:n})=>t?iz().createElement(iz().Fragment,null,e):n?iz().createElement(iz().Fragment,null,n):null;function av(){let e=(0,iH.useRef)();return(!e.current||e.current.signal.aborted)&&(e.current=new AbortController),(0,iH.useEffect)(()=>{let t=e.current;return()=>t?.abort()},[]),e.current}function ab(e,t=e=>e??{}){let[n,r]=(0,iH.useState)(()=>{if(ax(e))return;let n=ap(e);if(null!==n)return t?t(n):n});return(0,iH.useEffect)(()=>{if(ax(e))throw Error(`The namespace supplied to useAppContext must be a non-empty string, but was "${e}".`)},[e]),(0,iH.useEffect)(()=>{var n;let o;return(n=e=>{if(null==e)return void r(void 0);let n=t?t(e):e;r(e=>E(e,n)?e:n)})(ag(o=ap(e))),ad.subscribe(t=>{let r=e in t?t[e]:null;r!==o&&(o=r,n(ag(r)))})},[e,t]),n}function ax(e){return"string"!=typeof e||0===e.trim().length}function ak(e){let t=i6(e);return(0,iH.useMemo)(()=>t.map(e=>e.id),[t])}function aS(e){return i2(e).candidateExtensions}function aj(e,t){let{data:n,error:r,mutate:o,isLoading:i,isValidating:a}=(0,at.Ay)(`${nM}?patient=${e}&includeEncounterless=${t}`,tA);return(0,iH.useMemo)(()=>({isLoading:i,data:n?.data.results??[],error:r,mutate:o,isValidating:a}),[n,r,i,a,o])}function aN(e){(0,iH.useEffect)(()=>{if(e){let e=window.getComputedStyle(document.body).overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=e}}},[e])}let aC={},aE=`No ComponentContext has been provided. This should come from "openmrsComponentDecorator".
16
16
  Usually this is already applied when using "getAsyncLifecycle" or "getSyncLifecycle".`;function aA(e){let{moduleName:t,extension:n}=(0,iH.useContext)(iG),r=e?.externalModuleName??t;if(!r&&!n)throw Error(aE);let o=function(e){let t=(0,iH.useMemo)(()=>el(e),[e]),n=function(e){let[t,n]=(0,iH.useState)(()=>{let t=e.getState();return t.loaded&&t.config?t.config:null});return(0,iH.useEffect)(()=>e?.subscribe(e=>{e.loaded&&e.config&&n(e.config)}),[e]),t}(t);if(!n)throw aC[e]||(aC[e]=new Promise(e=>{let n=t.subscribe(t=>{t.loaded&&t.config&&(e(t.config),n())})})),aC[e];return n}(r),i=function(e){let t=(0,iH.useMemo)(em,[]),n=function(e,t){let[n,r]=(0,iH.useState)(t?()=>{let n=ef(e.getState(),t.extensionSlotName,t.extensionId);if(n.loaded&&n.config)return n.config}:null);return(0,iH.useEffect)(()=>{if(t)return e.subscribe(e=>{let o=ef(e,t.extensionSlotName,t.extensionId);o.loaded&&o.config&&!(0,q.A)(o.config,n)&&r(o.config)})},[e,t,n]),n}(t,e);if(!n&&e){let n=`${e.extensionSlotName}-${e.extensionId}`;throw!aC[n]&&t&&(aC[n]=new Promise(n=>{let r=t.subscribe(t=>{let o=ef(t,e.extensionSlotName,e.extensionId);o.loaded&&o.config&&(n(o.config),r())})})),aC[n]}return n||{}}(n);return(0,iH.useMemo)(()=>e?.externalModuleName&&r===e.externalModuleName?{...o}:{...o,...i},[r,e?.externalModuleName,o,i])}let aI=i6;function aO(){let[e,t]=(0,iH.useState)(oC());return(0,iH.useEffect)(()=>l(({online:e})=>t(e)),[]),e}function aP(e,t=300){let[n,r]=(0,iH.useState)(e);return(0,iH.useEffect)(()=>{let n=setTimeout(()=>{r(e)},t);return()=>{clearTimeout(n)}},[e,t]),n}var aT=n(96269);let aR=`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 a$(){let e=`${tj}/emrapi/configuration?v=${aR}`,t=(0,aT.A)(e,tA);return(0,iH.useMemo)(()=>({emrConfiguration:t.data?.data,isLoadingEmrConfiguration:t.isLoading,mutateEmrConfiguration:t.mutate,errorFetchingEmrConfiguration:t.error}),[t])}let aM=iZ(oT());function aW(e){let t=i6(e);return(0,iH.useMemo)(()=>Object.fromEntries(t.map(e=>[e.name,e.meta])),[t])}let aD=iZ(oF());function aL(e){let{flags:t}=iQ(ob);return t[e]?.enabled??!1}function aB(){let[,e]=(0,iH.useState)(0);return(0,iH.useCallback)(()=>{e(e=>e+1)},[])}function aU(e,t,n={}){return aH(e,t,aF,n)}let aF={getPaginatedUrl:(e,t,n)=>{if(!e)return null;{let r=new URL(tE(e.toString()),window.location.toString());return r.searchParams.set("limit",""+t),r.searchParams.set("startIndex",""+n),r.searchParams.set("totalCount","true"),r.toString()}},getNextUrl:e=>{let t=e?.links?.find(e=>"next"==e.rel)?.uri;if(!t)return null;{let e=new URL(t);return e.host=window.location.host,e.protocol=window.location.protocol,e.toString()}},getTotalCount:e=>e?.totalCount??NaN,getCurrentPageSize:e=>e?.results?.length??NaN,getData:e=>e?.results};function aH(e,t,n,r={}){let{getPaginatedUrl:o,getTotalCount:i,getCurrentPageSize:a,getData:s}=n,{immutable:l,swrConfig:c}=r,u=r.fetcher??tA,[d,m]=(0,iH.useState)(1),p=(0,iH.useRef)(NaN),f=(0,iH.useRef)(NaN),g=(0,iH.useRef)(d),h=(0,iH.useRef)(!1),w=(0,iH.useRef)(!1),y=e?.toString()??"",[_,v]=(0,iH.useState)(y);y!==_&&(v(y),m(1),g.current=1,p.current=NaN,f.current=NaN,h.current=!1,w.current=!1);let b=(d-1)*t,x=(0,iH.useMemo)(()=>o(e,t,b),[e,t,b]),{data:k,...S}=(l?aT.A:at.Ay)(x,u,c);k?.data&&(p.current=i(k?.data),f.current=a(k?.data),h.current=!0);let j=Math.ceil(p.current/t),N=(0,iH.useCallback)(e=>{if(!Number.isInteger(e)||e<1)return void console.warn(`useServerPagination: ignoring goTo(${e}); page must be a positive integer.`);let n=Math.ceil(p.current/t);!h.current||Number.isNaN(n)||e<=n?(g.current=e,m(e)):console.warn("Invalid attempt to go to out of bounds page: "+e)},[t]);(0,iH.useEffect)(()=>{if(!h.current)return;if(Number.isNaN(p.current)){w.current||(w.current=!0,console.warn(`useServerPagination: ${y} returned no total count, so out-of-range pages cannot be detected.`));return}let e=Math.max(1,Math.ceil(p.current/t));d>e&&(console.warn(`Invalid attempt to go to out of bounds page: ${d}; returning to page ${e}.`),g.current=e,m(e))},[d,t,y,k]);let C=(0,iH.useCallback)(()=>{N(g.current+1)},[N]),E=(0,iH.useCallback)(()=>{N(g.current-1)},[N]);return{data:s(k?.data),totalPages:j,totalCount:p.current,currentPage:d,currentPageSize:f.current,paginated:j>1,showNextButton:d<j,showPreviousButton:d>1,goTo:N,goToNext:C,goToPrevious:E,...S}}function az(e,t,n={}){return aH(e,t,aG(),n)}function aG(){return{getPaginatedUrl:(e,t,n)=>{if(!e)return null;{let r=new URL(tE(e.toString()),window.location.toString());return r.searchParams.set("_count",""+t),r.searchParams.set("_getpagesoffset",""+n),r.toString()}},getNextUrl:e=>{let t=e?.link?.find(e=>"next"==e.relation)?.url;if(!t)return null;{let e=new URL(t);return e.host=window.location.host,e.protocol=window.location.protocol,e.toString()}},getTotalCount:e=>e?.total??NaN,getCurrentPageSize:e=>e?.entry?.length??NaN,getData:e=>e?.entry?.map(e=>e.resource)}}var aV=n(13709);function aJ(e,t={}){return aq(e,aF,t)}function aq(e,t,n={}){let{swrInfiniteConfig:r,immutable:o}=n,{getNextUrl:i,getTotalCount:a,getData:s}=t,l=n.fetcher??tA,c=(0,iH.useCallback)((n,r)=>0==n?e?.toString()??null:t.getNextUrl(r.data),[e]),{data:u,size:d,setSize:m,...p}=(0,aV.Ay)(c,l,{...r,...o?{revalidateIfStale:!1,revalidateOnFocus:!1,revalidateOnReconnect:!1}:{}}),f=i(u?.[u.length-1].data),g=a(u?.[0]?.data);return{data:u?.flatMap(e=>s(e.data)),totalCount:g,hasMore:null!=f,loadMore:()=>{m((u?.length??0)+1)},nextUri:f,...p}}function aK(e,t={}){return aX(e,aF,t)}function aX(e,t,n={}){let r=aq(e,t,n),{hasMore:o,error:i,data:a,loadMore:s,isLoading:l,nextUri:c}=r;return((0,iH.useEffect)(()=>{o&&!i&&s()},[o,c]),n.partialData)?r:{...r,data:o||i?void 0:a,isLoading:l||o}}function aQ(e,t={}){return aX(e,aG(),t)}function aY(e,t={}){return aq(e,aG(),t)}function aZ(){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 a0(){let[e,t]=(0,iH.useState)(aZ);return(0,iH.useEffect)(()=>{let e=()=>{t(aZ())};return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),e}let a1=e=>"small-desktop"===e||"large-desktop"===e;function a2(e){let t=(0,iH.useContext)(iG);(0,iH.useEffect)(()=>(t&&t.moduleName&&(e.componentContext=t),ih(e),()=>{iw(e.name)}),[t,e])}function a5(){return iQ(ig)}function a6(e=null,t=null){let[n,r]=(0,iH.useState)([]);return(0,iH.useEffect)(()=>{let n=rF(e,t).subscribe(e=>{r(e)},e=>{console.error(e)});return()=>n.unsubscribe()},[e,t]),n}function a3(e,t=!0){let n=(0,iH.useRef)(null);return(0,iH.useEffect)(()=>{let r=r=>{t&&n.current&&r.target&&r.target instanceof Node&&(n.current.contains(r.target)||e(r))};return window.addEventListener("mousedown",r),window.addEventListener("touchstart",r),()=>{window.removeEventListener("mousedown",r),window.removeEventListener("touchstart",r)}},[e,t]),n}function a8(e){let t=(0,iH.useRef)();return(0,iH.useEffect)(()=>{let n=new IntersectionObserver(t=>{for(let n of t)if(n.isIntersecting)return void e()},{threshold:1});return t.current&&n.observe(t.current),()=>{t.current&&n.unobserve(t.current)}},[t.current,e]),t}function a4(e,t={}){let{abortController:n,fetchInit:r,url:o,swrConfig:i}=t,a=av(),s=(0,iH.useMemo)(()=>r?.signal??n?.signal??a.signal,[n?.signal,r?.signal,a.signal]),l=(0,iH.useCallback)(e=>tA(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,o),{...r,signal:s}),[s,r,o]);return(0,at.Ay)(e,l,i)}function a7(e=[],t=10){let[n,r]=(0,iH.useState)(1),o=(0,iH.useMemo)(()=>"number"==typeof t&&t>0?Math.max(1,Math.ceil(e.length/t)):1,[e.length,t]);n>o&&r(o);let i=Math.min(Math.max(1,n),o),a=(0,iH.useMemo)(()=>{let n=(i-1)*t,r=(i+0)*t;return e.slice(n,r)},[e,i,t]),s=(0,iH.useCallback)(e=>{!Number.isInteger(e)||e<1?console.warn(`usePagination: ignoring goTo(${e}); page must be a positive integer.`):r(e)},[]),l=(0,iH.useCallback)(()=>{r(e=>e+1)},[]),c=(0,iH.useCallback)(()=>{r(e=>Math.max(1,e-1))},[]);return(0,iH.useMemo)(()=>({results:a,totalPages:o,currentPage:i,paginated:e.length>t,showNextButton:i<o,showPreviousButton:i>1,goTo:s,goToNext:l,goToPrevious:c}),[a,o,e.length,t,i,s,l,c])}function a9(e,t,n,r){return{pageSizes:(0,iH.useMemo)(()=>{let n=Math.ceil(t/e);return isNaN(n)&&(n=0),[...Array(n).keys()].map(t=>(t+1)*e)},[e,t]),pageItemsCount:(0,iH.useMemo)(()=>e>t?t:e*n>t?e*(n-1)+r:e*n,[e,t,n,r])}}function se(){let e=/\/patient\/([a-zA-Z0-9\-]+)\/?/.exec(location.pathname);return e&&e[1]}function st(e){let[t,n]=(0,iH.useState)(e??se()),{data:r,error:o,isValidating:i}=(0,at.Ay)(t?["patient",t]:null,()=>rM(t,{}));return(0,iH.useEffect)(()=>{let e=()=>{let e=se();e!==t&&n(e)};return window.addEventListener("single-spa:routing-event",e),()=>window.removeEventListener("single-spa:routing-event",e)},[t]),(0,iH.useMemo)(()=>({isLoading:i&&!o&&!r,patient:r,patientUuid:t,error:o}),[i,o,r,t])}function sn(){let e=`${tj}/metadatamapping/termmapping?v=custom:(metadataUuid)&code=emr.primaryIdentifierType`,{data:t,error:n,isLoading:r}=(0,at.Ay)(e,tA);return(0,iH.useMemo)(()=>({primaryIdentifierCode:t?.data?.results[0]?.metadataUuid,isLoading:r,error:n}),[t,n,r])}function sr(e){let{extensions:t,extensionSlotModuleName:n}=i3(e);return e?t.map(t=>({state:r})=>iz().createElement(iG.Provider,{value:{moduleName:n,featureName:"",extension:{extensionId:t.id,extensionSlotName:e,extensionSlotModuleName:n}}},iz().createElement(iJ,{state:r}))):[]}function so(){let e=(0,iH.useRef)(),[t,n]=(0,iH.useState)(null),r=null;if(!t){if(o){let e=t$().getState();e.loaded&&(r=e.session)}else o=new Promise(t=>{let n=({loaded:n,session:o})=>{n&&(t(o),r=o,e.current&&(e.current(),e.current=void 0))};n(t$().getState()),r||(e.current=t$().subscribe(n))});if(r)n(r);else throw o}(0,iH.useEffect)(()=>(e.current||(e.current=t$().subscribe(({loaded:e,session:t})=>{e&&(r=t,n(t))})),()=>{e.current&&(e.current(),e.current=void 0)}),[]);let i=t||r;if(!i)if(o)throw console.warn("useSession is in an unexpected state. Attempting to recover."),o;else throw Error("useSession is in an invalid state.");return i}let si=({privilege:e,fallback:t,children:n})=>{let[r,o]=(0,iH.useState)(null);return((0,iH.useEffect)(()=>{let e=tR({includeAuthStatus:!1}).subscribe(o);return()=>e.unsubscribe()},[]),r&&tL(e,r))?iz().createElement(iz().Fragment,null,n):t?iz().createElement(iz().Fragment,null,t):null};var sa=n(94343),ss=n.n(sa),sl=n(93355);let sc=new Map;function su(){for(let e of Array.from(sc.values()))e()}let sd={setVisitContext:(e,t)=>null==t?{manuallySetVisitUuid:null}:{manuallySetVisitUuid:t.uuid,patientUuid:t.patient?.uuid}};function sm(e){let t=(0,iH.useId)();return(0,iH.useEffect)(()=>{if(e)return sc.set(t,e),()=>{sc.delete(t)}},[t,e]),{...iY(rK(),sd),mutateVisit:su}}function sp(e,t=rJ){let n=(0,iH.useRef)(void 0),{patientUuid:r,manuallySetVisitUuid:o,setVisitContext:i}=sm((0,iH.useCallback)(()=>n.current?.(),[])),a=e&&r==e?o:null,s=`?patient=${e}&v=${t}&includeInactive=false`,l=`/${a}?v=${t}`,{data:c,error:u,mutate:d,isValidating:m}=(0,at.Ay)(e?`${tj}/visit${s}`:null,tA),{data:p,error:f,mutate:g,isValidating:h}=(0,at.Ay)(e&&a?`${tj}/visit${l}`:null,tA),w=(0,iH.useMemo)(()=>c?.data.results.find(e=>null===e.stopDatetime)??null,[c]),y=(0,iH.useMemo)(()=>a&&p?p.data:null,[p,a]),_=(0,iH.useRef)(null);(0,iH.useEffect)(()=>{!m&&w&&r===e&&null===o&&i(w),h||(_.current&&y&&_.current.uuid===y.uuid&&!_.current.stopDatetime&&y.stopDatetime&&i(null),_.current=y)},[y,o,w,m,h,r]);let v=(0,iH.useCallback)(()=>{d(),g()},[d,g]);(0,iH.useEffect)(()=>{n.current=v},[v]);let b=!!(!c||a&&!p),x=!!(a?f:u);return{error:u||f,mutate:v,isValidating:m||h,activeVisit:w,currentVisit:y,currentVisitIsRetrospective:!!a,isLoading:b&&!x}}function sf(){let[e,t]=(0,iH.useState)([]);return(0,iH.useEffect)(()=>{let e=rz().subscribe(e=>{t(e)},e=>console.error(e));return()=>e.unsubscribe()},[]),e}sa.extend(sl);let sg=new Map;async function sh(e,t){let n=t.indexOf("#"),r=n>=0,o=r?t.substring(0,n):e,i=r?t.substring(n+1):t,a=await nm(o);return a&&Object.hasOwn(a,i)&&"function"==typeof a[i]?sy(o,a).then(()=>a[i]()):(a?a&&Object.hasOwn(a,i)?console.warn(`The export ${t}, defined in ${e}'s routes.json, is not a function`):console.warn(`${o} does not define a component called "${i}", referenced in ${e}'s routes.json. This cannot be loaded.`):console.warn(`Unknown app ${o} for ${t} defined in ${e}'s routes.json`),sw)}let sw={bootstrap:()=>Promise.resolve(),mount:()=>Promise.resolve(),unmount:()=>Promise.resolve()};async function sy(e,t){if(e in sg)await sg[e];else{let n=t??await nm(e);await (sg[e]=new Promise((t,r)=>{if(Object.hasOwn(n,"startupApp")){let o=n.startupApp;if("function"==typeof o)return Promise.resolve(o()).then(()=>{e$(e),t(null)}).catch(r)}e$(e),t(null)}))}}function s_(e,t){let n=t.name;if(!n)return void console.error(`An extension definition in ${e} is missing an name and thus cannot be
17
17
  registered. To fix this, ensure that you define the "name" field inside the
18
18
  extension definition.`,t);t.slots&&t.slot&&console.warn(`The extension ${n} from ${e} declares both a 'slots' property and