@openmrs/esm-implementer-tools-app 11.0.1-pre.5771 → 11.0.1-pre.5775

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.
@@ -5,4 +5,4 @@
5
5
  │ 5559.js (414.101 KiB)
6
6
  
7
7
 
8
- Rspack compiled with 1 warning in 23.45 s
8
+ Rspack compiled with 1 warning in 28.05 s
package/dist/7575.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 o}let eX=(e,t)=>{let n=structuredClone(t);if(!e)return n;for(let t of Object.keys(e)){let o=n[t],r=e[t];if(r&&(r.hasOwnProperty("_type")||r.hasOwnProperty("_default"))){n.hasOwnProperty(t)||(n[t]=r._default);let e=r._elements;if(o&&eY(e)){if(r._type===G.Array&&Array.isArray(o)){let r=o.map(t=>eX(e,t));n[t]=r}else if(r._type===G.Object)for(let t of Object.keys(o))o[t]=eX(e,o[t])}}else if(eZ(r)){let e=o??{};eZ(e)&&(n[t]=eX(r,e))}}return n};function eY(e){return!!e&&Object.keys(e).filter(e=>!["_default","_validators"].includes(e)).length>0}function eZ(e){return"object"==typeof e&&!Array.isArray(e)&&null!==e}function eQ(e,t){let n=`${e}:::${t}`;ex.has(n)||(console.error(t),ex.add(n))}function e0(e){e?ex.forEach(t=>{t.startsWith(e)&&ex.delete(t)}):ex.clear()}function e1(){eb.forEach(e=>e()),eb.length=0,eE.clear(),eD.clear(),eB.clear(),eU.clear(),eS=null,ek=new WeakMap,ej()}let e2={"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:G.Object,_default:{},_validators:[z(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(", ")}.`})]}},e5={"Display conditions":{privileges:{_description:"The privilege(s) the user must have to use this extension",_type:G.Array,_default:[]},expression:{_description:"The expression that determines whether the extension is displayed",_type:G.String,_default:void 0}},...e2},e6=(e,t)=>z(n=>e<=n&&n<=t,`must be between ${e} and ${t}`),e8=e=>{let t=e.concat(["openmrsBase","openmrsSpaBase"]);return z(e=>{if(!e||"string"!=typeof e)return!1;let n=/\${(.*?)}/g,o=n.exec(e);for(;o;){if(!t.includes(o[1]))return!1;o=n.exec(e)}return!0},"Should be a URL or path. The allowed template parameters are "+t.map(e=>"${"+e+"}").join(", "))},e4=e8([]),e3=e=>z(t=>e.includes(t),`Must be one of the following: '${e.join("', '")}'.`),e7={inRange:e6,isUrl:e4,isUrlWithTemplateParameters:e8,oneOf:e3};var e9=n(4913);let te=R("breadcrumbs",[]);function tt(e){return tn([e])}function tn(e){let t=[...to(),...e.map(e=>({matcher:e.matcher instanceof RegExp?e.matcher:"string"==typeof e.matcher?(0,e9.pathToRegexp)(e.matcher).regexp:(0,e9.pathToRegexp)(e.path).regexp,settings:e}))];te.setState(t,!0)}function to(){return te.getState()}function tr(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=tr(e,n.join("/"));if(t)return t}}(e,t)}function ti(e,t){if(e.length>0){let n=tr(e,t);if(n){let t=[n],o=tr(e,n.settings.parent);for(;void 0!==o;)t.push(o),o=tr(e,o.settings.parent);return t.reverse()}}return[]}function ts(e){return ti(to(),e)}var ta=n(2267);let tl={address1:"Address line 1",address2:"Address line 2",address3:"Address line 3",address4:"Address line 4",address5:"Address line 5",address6:"Address line 6",city:"City",cityVillage:"City",country:"Country",countyDistrict:"District",district:"District",postalCode:"Postal code",state:"State",stateProvince:"State",closeAllOpenedWorkspaces:"Discard changes in {{count}} workspaces",closingAllWorkspacesPromptBody:"There may be unsaved changes in the following workspaces. Do you want to discard changes in the following workspaces? {{workspaceNames}}",closingAllWorkspacesPromptTitle:"You have unsaved changes",discard:"Discard",hide:"Hide",maximize:"Maximize",minimize:"Minimize",openAnyway:"Open anyway",unsavedChangesInOpenedWorkspace:"You may have unsaved changes in the opened workspace. Do you want to discard these changes?",unsavedChangesInWorkspace:'There may be unsaved changes in "{{workspaceName}}". Please save them before opening another workspace.',unsavedChangesTitleText:"Unsaved changes",workspaceHeader:"Workspace header",discardUnsavedChangesPromptBodyMultiple:"{{count}} workspaces have unsaved changes. Closing them will discard the changes:",discardUnsavedChangesPromptBodySingle:"<strong>{{workspaceTitle}}</strong> has unsaved changes. Closing it will discard them.",discardUnsavedChangesPromptTitle:"Discard unsaved changes?",keepEditing:"Keep editing",abnormalValue:"Abnormal value",actions:"Actions",actionableNotification:"Actionable notification",address:"Address",age:"Age",applicationError:"Application Error",batchActionItemSelected:"{{totalSelected}} item selected",batchActionsItemsSelected:"{{totalSelected}} items selected",cancel:"Cancel",change:"Change",Clinic:"Clinic",clearDevOverrides:"Clear dev overrides",close:"Close",closesActionableNotification:"Close actionable notification",closeSnackbar:"Close snackbar",confirm:"Confirm",contactAdministratorIfIssuePersists:"Contact your system administrator if the problem persists.",contactDetails:"Contact details",copied:"Copied!",copyToClipboard:"Copy to clipboard",delete:"Delete",discardChanges:"Discard changes",edit:"Edit",emptyStateText:"There are no {{displayText}} to display",error:"Error",errorCopy:"Sorry, there was a problem displaying this information. You can try to reload this page, or contact the site administrator and quote the error code above.",errorLoadingLoginLocations:"Unable to load login locations. Please try again or contact support if the problem persists.",female:"Female",leftNavigation:"Left navigation",loading:"Loading",localVersion:"Local Build",male:"Male",navigateNonHttp:"Could not navigate to the requested page as it is not a safe URL",noResultsToDisplay:"No results to display",notAvailable:"Not available",other:"Other",paginationItemsCount:"{{pageItemsCount}} / {{totalItems}} items",paginationOfPages:"of {{count}} pages",patientAvatarAlt:"Avatar for {{patientName}}",patientIdentifierSticker:"Patient identifier sticker",patientLists:"Patient lists",patientPhotoAlt:"Profile photo of {{patientName}}",patientPhotoPlaceholder:"Photo placeholder for {{patientName}}",prereleaseVersion:"Prerelease",print:"Print",printError:"Print error",printErrorExplainer:"An error occurred in {{errorLocation}}",printIdentifierSticker:"Print identifier sticker",printing:"Printing",provisional:"Provisional",recordNewEntry:"Record {{displayText}}",relationships:"Relationships",reload:"Reload",resetOverrides:"Reset overrides",save:"Save",scriptLoadingFailed:"Error: Script failed to load",scriptLoadingError:"Failed to load overridden script from {{url}}. Please check that the bundled script is available at the expected URL. Click the button below to reset all import map overrides.",searchForLocation:"Search for a location",seeAll:"See all",seeMoreLists:"See {{count}} more lists",selectAll:"Select all",serverStartingUp:"The server is starting",serverStartingUpExplainer:"This can take a few minutes. OpenMRS will open automatically when the server is ready.",serverStartingUpSlowExplainer:"This is taking longer than usual. First startup after an upgrade can take 10 minutes or more. You can leave this page open.",sex:"Sex",showLess:"Show less",showMore:"Show more",snackbarNotification:"Snackbar notification",somethingWentWrongTryReloading:"Something went wrong. Please try reloading.",toggleDevTools:"Toggle dev tools",unknown:"Unknown",viewSetupProgress:"View setup progress",waitingForServer:"Waiting for the server",yearAbbreviation:"yr",yearsAbbreviation:"yrs"};var tc=n(2279);let tu=tc.Ay.default||tc.Ay;function td(e,t,n,o){return tu.t(t,{ns:e,defaultValue:n,...o})}function tm(e,t,n){return tl[e]?td("core",e,t??tl[e],n):(console.error(`O3 Core Translations does not provide key '${e}'. The key itself is being rendered as text.`),e)}function tp(e,t){let n=window.getOpenmrsSpaBase().replace(/\/$/,""),o=tf(e,{openmrsBase:window.openmrsBase,openmrsSpaBase:n,...t});return e.startsWith("//")?o:o.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(/\/$/,""),o=tp(e,t).replace(window.location.origin,""),r=new URL(o,window.location.origin);if("http:"!=r.protocol&&"https:"!=r.protocol)throw console.error(`Received request to navigate to non-http URL: ${r.toString()}`),Error(tm("navigateNonHttp"));o.startsWith(n)?(0,ta.EH)(o):window.location.assign(o)}tu.on("initialized",function(){window.i18next.loadNamespaces(["core"])});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 t_(){0===JSON.parse(sessionStorage.getItem(th)??"[]").length&&document.referrer&&tw(document.referrer),window.addEventListener("single-spa:routing-event",e=>{let t=ty();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 ty(){return JSON.parse(sessionStorage.getItem(th)??"[]")}function tv({toUrl:e}){let t=ty(),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",tS={redirectAuthFailure:{enabled:{_type:G.Boolean,_default:!0,_description:"Whether to redirect logged-out users to `redirectAuthFailure.url`"},url:{_type:G.String,_default:tx,_validators:[e7.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:G.Array,_default:[401],_elements:{_type:G.Number,_validators:[e7.inRange(100,600)]},_description:"The HTTP error codes for which users will be redirected"},resolvePromise:{_type:G.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:G.Boolean,_default:!0,_description:"Whether openmrsFetch should support redirects returned from the backend"}};function tk(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",tE=`${tj}/session`;function tC(e){return e&&e.startsWith("http")?e:("/"!==e[0]&&(e="/"+e),window.openmrsBase+e)}function tP(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=tC(e);t.headers||(t.headers={}),(0,U.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;let o=!1;try{let e=new URL(n,window.location.href),t=new URL(tC(tj),window.location.href),r=e.pathname.replace(/\/{2,}/g,"/"),i=t.pathname.replace(/\/{2,}/g,"/");o=e.origin===t.origin&&(r===i||r.startsWith(`${i}/`))}catch{}if(o){let e=!1;for(let[n,o]of Object.entries(t.headers))"disable-www-authenticate"===n.toLowerCase()&&(void 0===o?delete t.headers[n]:e=!0);e||(t.headers["Disable-WWW-Authenticate"]="true")}if(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:o,followRedirects:i}=await eM("@openmrs/esm-api");if(e.ok){let t=e.headers.get("location");return(i&&t&&(n===tC(tE)||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===tC(tE)&&403===e.status||o.enabled&&o.errors.includes(e.status))&&(tb(),tg({to:o.url||e.headers.get("location")||tx}),!0!==t.rejectAuthFailure)?o.resolvePromise?Promise.resolve():new Promise(()=>{}):e.clone().text().then(t=>{let o=t;try{o=JSON.parse(t)}catch(e){}throw new tI(n,e,o,r)},()=>{throw new tI(n,e,null,r)})})}class tI extends Error{constructor(e,t,n,o){super(),tk(this,"response",void 0),tk(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`,o.message=this.message,this.responseBody=n,this.response=t,this.stack=`Stacktrace for outgoing request:
13
13
  ${o.stack}
14
14
  Stacktrace for incoming response:
15
- ${this.stack}`}}let tO=R("session",{loaded:!1,session:null}),tA=0,tR=null;function t$(){return tR||(tO.getState().loaded&&tA>=Date.now()-6e4?null:tW())}function tT(e){let t=e?.includeAuthStatus??!0,n=e=>t?e:e.user,o=t$();return o?new Promise(e=>{let t=()=>{let t=tO.getState();t.loaded&&(r(),e(n(t.session)))},r=tO.subscribe(t);o.then(t,t)}):Promise.resolve(n(tO.getState().session))}function tM(){return t$(),tO}function tL(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){tA=Date.now(),r??(r=tA);let n={};e&&t&&(n.Authorization=`Basic ${window.btoa(`${e}:${t}`)}`);let o=tJ(tP(tE,{headers:n,rejectAuthFailure:!0})),i=()=>{tR===o&&(tR=null)};return o.then(i,i),tR=o,o}function tD(){tO.setState({loaded:!0,session:{authenticated:!1,sessionId:""}},!0)}function tU(e,t){var n,o;if(void 0===t)return!e;if(!e)return!0;return n=e,o=t,("string"==typeof n?!(0,D.A)(o.privileges.find(e=>n===e.display)):Array.isArray(n)?n.every(e=>!(0,D.A)(o.privileges.find(t=>e===t.display))):((0,D.A)(n)||console.error(`Could not understand privileges "${n}"`),!0))||!(0,D.A)(t.roles.find(e=>"System Developer"===e.display))}function tB(){let e,t;return new Promise(n=>{let o=o=>{o.loaded&&o.session.user&&(e=o.session.user,n(o.session.user),t&&t())};o(tO.getState()),e||(t=tO.subscribe(o))})}async function tF(){return(await tT()).sessionLocation}async function tH(e,t){return tJ(tP(tE,{method:"POST",body:{sessionLocation:e},headers:{"Content-Type":"application/json"},rejectAuthFailure:!0,signal:t?.signal}))}async function tV(e,t){return await tP(tE,{method:"POST",body:{locale:e},headers:{"Content-Type":"application/json"},signal:t?.signal}),tW()}async function tG(e,t,n){return n||(n=new AbortController),await tP(`${tj}/user/${e}`,{method:"POST",body:{userProperties:t},headers:{"Content-Type":"application/json"},signal:n.signal}),tW()}async function tz(e,t=!1){let n=await tP(t?`${tE}?rememberMe=true`:tE,{headers:{"X-Totp-Code":e}});return n.data?.authenticated?(await tW()).session:n.data}async function tq(){try{await tP(tE,{method:"DELETE",rejectAuthFailure:!0})}catch(e){if(!tK(e))throw e}tD(),await tW().catch(()=>{})}function tJ(e){return new Promise((t,n)=>{e.then(e=>{if("object"==typeof e?.data){let n={loaded:!0,session:e.data};tO.setState(n,!0),t(n)}else!function(e){if(!e?.redirected||!e.url)return!1;try{return new URL(e.url,window.location.href).pathname.replace(/\/+$/,"").endsWith("/initialsetup")}catch{return!1}}(e)?n(tX(Error("The session endpoint did not respond with a session"))):n(tX(Error("The server is still starting up"),!0))}).catch(e=>{var o,i;if(tK(e)){"object"==typeof(o=e.responseBody)&&null!==o&&!1===o.authenticated?tO.setState({loaded:!0,session:e.responseBody},!0):tD(),t(tO.getState());return}(i=e)instanceof tI&&502===i.response.status&&!tO.getState().loaded&&void 0!==r&&Date.now()-r<18e4?n(tX(e,!0)):(y(`Failed to fetch new session information: ${e}`),n(tX(e)))})})}function tK(e){return e instanceof tI&&(401===e.response.status||403===e.response.status)}function tX(e,t=!1){return tO.getState().loaded||tO.setState({loaded:!1,session:null,error:e instanceof Error?e:Error(String(e)),initializing:t},!0),tO.getState()}function tY(){return"development"===window.spaEnv||"true"===localStorage.getItem("openmrs:devtools")}tO.subscribe(e=>{e.loaded&&e.session&&tL(e.session)});let tZ={"webservices.rest":"2.24.0",fhir2:"1.0.0-SNAPSHOT"};function tQ(){eP("@openmrs/esm-api",tS),tW()}let t0="import-map-override:",t1="import-map-overrides-disabled",t2="import-map-overrides:change",t5=!1,t6=null,t8=null;async function t4(){return t8??(t8=t3().then(({map:e,complete:t})=>(t||(t8=null),e))),t8}async function t3(){let e=document.querySelectorAll('script[type="systemjs-importmap"]'),t=[],n=!0;for(let o=0;o<e.length;o++){let r=e[o];try{if(r.src){let e=await fetch(r.src);if(!e.ok)throw Error(`Request for ${r.src} returned ${e.status} ${e.statusText}`);t.push(await e.json())}else r.textContent&&t.push(JSON.parse(r.textContent))}catch(e){n=!1,console.warn(`[import-maps] Failed to parse import map from script tag at index ${o}`,e)}}return{map:t7(t),complete:n}}function t7(e){let t={imports:{}};for(let n of e)n?.imports&&Object.assign(t.imports,n.imports);return t}function t9(){let e={};try{let t=nr();for(let n=0;n<localStorage.length;n++){let o=localStorage.key(n);if(o?.startsWith(t0)){let n=o.slice(t0.length);if(!t.includes(n)){let t=localStorage.getItem(o);t&&(e[n]=t)}}}}catch(e){console.warn("[import-maps] Failed to read import-map overrides from localStorage",e)}return{imports:e}}async function ne(){let e=await t4();return t5?t7([e,t6??t9()]):e}async function nt(){return t4()}async function nn(){return t5?t7([await t4(),t9()]):t4()}function no(e){if(!t5)return{imports:{}};if(e){let e={};for(let t=0;t<localStorage.length;t++){let n=localStorage.key(t);if(n?.startsWith(t0)){let t=localStorage.getItem(n);t&&(e[n.slice(t0.length)]=t)}}return{imports:e}}return t9()}function nr(){if(!t5)return[];try{let e=localStorage.getItem(t1);if(e){let t=JSON.parse(e);if(Array.isArray(t))return t}}catch{}return[]}function ni(e){return!!t5&&nr().includes(e)}function ns(e,t){if(!t5)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{localStorage.setItem(t0+e,t),window.dispatchEvent(new CustomEvent(t2))}catch(e){console.warn("[import-maps] Failed to write import-map override to localStorage",e)}}function na(e){if(!t5)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{localStorage.removeItem(t0+e);let t=nr().filter(t=>t!==e);t.length>0?localStorage.setItem(t1,JSON.stringify(t)):localStorage.removeItem(t1),window.dispatchEvent(new CustomEvent(t2))}catch(e){console.warn("[import-maps] Failed to update import-map overrides in localStorage",e)}}function nl(){if(!t5)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(t0)&&e.push(n)}e.forEach(e=>localStorage.removeItem(e)),localStorage.removeItem(t1),window.dispatchEvent(new CustomEvent(t2))}catch(e){console.warn("[import-maps] Failed to clear import-map overrides from localStorage",e)}}function nc(e){if(!t5)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(t1,JSON.stringify(t)):localStorage.removeItem(t1),window.dispatchEvent(new CustomEvent(t2))}catch(e){console.warn("[import-maps] Failed to update import-map overrides in localStorage",e)}}let nu=!1;function nd(){!nu&&(nu=!0,(t5="development"===window.spaEnv)&&(t6=t9()))}function nm(e){return e.replace(/[\/\-@]/g,"_")}async function np(e,t="./start",o){var r;let i,s=!o?.maxLoadingTime||o.maxLoadingTime<=0?6e5:o.maxLoadingTime;await Promise.race([nf(e,o?.importMap),new Promise((t,n)=>{i=setTimeout(()=>{var t;n(Error(`Could not resolve requested script, ${e}, within ${(t=s)<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`}.`))},s)})]),i&&clearTimeout(i);let a=nm(e),l=window[a];if(!("object"==typeof(r=l)&&null!==r&&"init"in r&&"function"==typeof r.init&&"get"in r&&"function"==typeof r.get)){let e=`The global variable ${a} 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 nf(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=nm(e);if(!window[n]){let n=t??await ng();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 o=n.imports[e];o.startsWith("./")&&(o=window.spaBase+o.substring(1));let r=e in no().imports;try{return await function(e){var t;let n=(t=window)[nh]??(t[nh]=new Map),o=n.get(e);if(o)return o;if(document.head.querySelector(`script[src="${e}"]`))return console.warn(`Script at ${e} already loaded. Not loading it again.`),Promise.resolve();let r=document.createElement("script");r.src=e,r.type="text/javascript",r.async=!0;let i=new Promise((t,o)=>{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 s(){clearTimeout(i),r.removeEventListener("load",a),r.removeEventListener("error",l)}function a(){s(),t()}function l(t){s(),n.delete(e),r.remove();let i=`Failed to load script from ${e}`;console.error(i,t),o(t.message??i)}r.addEventListener("load",a),r.addEventListener("error",l),document.head.appendChild(r)});return n.set(e,i),i}(o)}catch(e){return r&&p({kind:"error",title:tm("scriptLoadingFailed","Error: Script failed to load"),description:tm("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:o}),actionButtonLabel:tm("resetOverrides","Reset overrides"),onActionButtonClick(){nl(),window.location.reload()}}),Promise.reject(e)}}return Promise.resolve()}async function ng(){return ne()}let nh=Symbol.for("__openmrs_script_loading");function nw(e){return!!e&&"object"==typeof e&&!(Object.hasOwn(e,"pages")&&(!e.pages||!Array.isArray(e.pages))||Object.hasOwn(e,"extensions")&&(!e.extensions||!Array.isArray(e.extensions))||Object.hasOwn(e,"modals")&&(!e.modals||!Array.isArray(e.modals))||Object.hasOwn(e,"workspaces2")&&(!e.workspaces2||!Array.isArray(e.workspaces2))||Object.hasOwn(e,"workspaceWindows2")&&(!e.workspaceWindows2||!Array.isArray(e.workspaceWindows2))||Object.hasOwn(e,"workspaceGroups2")&&(!e.workspaceGroups2||!Array.isArray(e.workspaceGroups2)))}function n_(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&&nw(t))}let ny="openmrs-routes:",nv="openmrs-routes:change",nb=!1,nx=null,nS=null;async function nk(){return nS??(nS=nj().then(({map:e,complete:t})=>(t||(nS=null),e))),nS}async function nj(){let e=document.querySelectorAll("script[type='openmrs-routes']"),t=[],n=!0;for(let o=0;o<e.length;o++){let r=e[o];try{let e;if(r.src){let t=await fetch(r.src);if(!t.ok)throw Error(`Request for ${r.src} returned ${t.status} ${t.statusText}`);e=await t.json()}else r.textContent&&(e=JSON.parse(r.textContent));e&&n_(e)&&t.push(e)}catch(e){n=!1,console.warn(`[route-maps] Failed to parse routes from script tag at index ${o}`,e)}}return{map:nN(t),complete:n}}function nN(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 nE(){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(nw(n))return{moduleName:e,routes:n};if("string"==typeof n&&n.startsWith("http")){let t=await fetch(n),o=await t.json();if(nw(o))return{moduleName:e,routes:o};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 nb?nN([e,nx??await nE()]):e}async function nP(){return nk()}async function nI(){return nb?nN([await nk(),await nE()]):nk()}function nO(){if(!nb)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 nA(e,t){if(!nb)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(!nw(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(!nw(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(nv))}catch(e){console.warn("[route-maps] Failed to write route override to localStorage",e)}}function nR(e){if(!nb)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{localStorage.removeItem(ny+e),window.dispatchEvent(new CustomEvent(nv))}catch(e){console.warn("[route-maps] Failed to remove route override from localStorage",e)}}function n$(){if(!nb)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(nv))}catch(e){console.warn("[route-maps] Failed to clear route overrides from localStorage",e)}}let nT=null;function nM(){return nT||(nT=(nb="development"===window.spaEnv)?nE().then(e=>{nx=e}):Promise.resolve())}let nL=`${tj}/attachment`;function nW(e,t){return tP(`${nL}/${e}`,{signal:t.signal})}function nD(e,t,n,o){return tP(nU(e,t,o),{signal:n.signal})}function nU(e,t,n){return n?`${nL}?patient=${e}&encounter=${n}`:`${nL}?patient=${e}&includeEncounterless=${t}`}async function nB(e,t,n){let o=new FormData;return o.append("fileCaption",t.fileDescription),o.append("patient",e),n&&o.append("encounter",n),t.file?o.append("file",t.file,t.fileName):(o.append("file",new File([""],t.fileName),t.fileName),o.append("base64Content",t.base64Content)),tP(`${nL}`,{method:"POST",body:o})}function nF(e,t){return tP(`${nL}/${e}`,{method:"DELETE",signal:t.signal})}async function nH(e,t){return e?(await tP(`${tN}/Patient/${e}`,t)).data:null}function nV(e,t){let n=new CustomEvent(`openmrs:${e}`,{detail:t??void 0,cancelable:!0,bubbles:!0});return window.dispatchEvent(n)}function nG(e,t){let n=e=>{t("detail"in e&&null!==e.detail?e.detail:void 0)};return window.addEventListener(`openmrs:${e}`,n),()=>{window.removeEventListener(`openmrs:${e}`,n)}}function nz(e){return{uuid:e.uuid,display:e.display}}function nq(e=null,t=null){let n=new URLSearchParams;e&&n.set("tag",e),t&&n.set("q",t);let o=n.toString();return tP(`${tj}/location${o?"?"+o:""}`).then(e=>e.data.results.map(nz))}function nJ(e){return{uuid:e.uuid,display:e.display,name:e.name}}let nK=`${tj}/visittype`;function nX(e=nK){return tP(e).then(e=>e.data.results.map(nJ))}var nY=((k={}).NEWVISIT="startVisit",k.EDITVISIT="editVisit",k.LOADING="loadingVisit",k),nZ=((j={}).NOTSTARTED="notStarted",j.ONGOING="ongoing",j);let nQ="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))",n0=function(){try{return JSON.parse(sessionStorage.getItem("openmrs:visitStoreState")||"null")}catch(e){return null}}()||{patientUuid:null,manuallySetVisitUuid:null};function n1(){return M("visit",n0)}function n2(e,t){n1().setState({patientUuid:e,manuallySetVisitUuid:t})}function n5(e,t){return tP(`${tj}/visit`,{signal:t.signal,method:"POST",headers:{"Content-type":"application/json"},body:e})}function n6(e,t,n){return tP(`${tj}/visit/${e}`,{signal:n.signal,method:"POST",headers:{"Content-type":"application/json"},body:t})}function n8(e,t,n){return tP(`${tj}/visit?patient=${e}&v=${n??nQ}`,{signal:t.signal,method:"GET",headers:{"Content-type":"application/json"}})}n1().subscribe(e=>{var t;t=e,sessionStorage.setItem("openmrs:visitStoreState",JSON.stringify(t))});var n4=n(9225),n3=n(6881),n7=n(6828),n9=n(1956),oe=n(3635),ot=n(7839),on=n(2298);let oo={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)}},or={...oo,Promise};function oi(e,t={}){return od(e,t,of)}async function os(e,t={}){return om(e,t,of)}function oa(e,t={}){return od(e,t,og)}function ol(e,t={}){return om(e,t,og)}function oc(e,t={}){return od(e,t,oh)}function ou(e,t={}){return om(e,t,oh)}function od(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 o=ob(t,oo),r=ow("string"==typeof e?(0,n4.A)(e):e,o);if(n(r))return r;throw{type:"Invalid result",message:"string"==typeof e?`The expression ${e} did not produce a valid result`:"The expression did not produce a valid result"}}async function om(e,t={},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 o=ob(t,or);return Promise.resolve(ow("string"==typeof e?(0,n4.A)(e):e,o)).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 op(e){return(0,n4.A)(e)}function of(e){return"string"==typeof e||"number"==typeof e||"boolean"==typeof e||null==e||e instanceof Date}function og(e){return"boolean"==typeof e}function oh(e){return"number"==typeof e}function ow(e,t){switch(e.type){case"UnaryExpression":var n,o,r,i,s,a,l,c,u,d,m,p,f,g=e,h=t;let w=ow(g.argument,h);switch(g.operator){case"+":return+w;case"-":return-w;case"~":return~w;case"!":return!w;default:throw`Expression evaluator does not support operator '${g.operator}''`}case"BinaryExpression":var _=e,y=t;switch(_.operator){case"&&":return ow(_.left,y)&&ow(_.right,y);case"||":return ow(_.left,y)||ow(_.right,y);case"??":return ow(_.left,y)??ow(_.right,y)}let v=ow(_.left,y),b=ow(_.right,y);switch(_.operator){case"+":return v+b;case"-":return v-b;case"*":return v*b;case"/":return v/b;case"%":return v%b;case"**":return v**b;case"==":return v==b;case"===":return v===b;case"!=":return v!=b;case"!==":return v!==b;case">":return v>b;case">=":return v>=b;case"<":return v<b;case"<=":return v<=b;case"in":return v in b;default:throw`Expression evaluator does not support operator '${_.operator}' operator`}case"ConditionalExpression":return n=e,o=t,ow(n.test,o)?ow(n.consequent,o):ow(n.alternate,o);case"CallExpression":return ok(oy(e,t));case"ArrowFunctionExpression":let x;return r=e,i=t,x=r.params?.map(e=>{if("Identifier"===e.type)return e.name;throw`Cannot handle parameter of type ${e.type}`})??[],(function(...e){if(e.length<x.length)throw`Required argument(s) ${x.slice(e.length,-1).join(", ")} were not provided`;let t=Object.fromEntries(x.reduce((t,n,o)=>{let r=e[o];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}(r)&&t.push([n,r]),t},[]));return ow(r.body,i.addVariables(t))}).bind(null);case"MemberExpression":return ok(ov(e,t));case"ArrayExpression":return s=e,a=t,s.elements?.map(oj(a));case"SequenceExpression":let S;return l=e,c=t,(S=l.expressions.map(oj(c)))[S.length-1];case"NewExpression":var k=e,j=t;if(k.callee&&"Identifier"===k.callee.type){let e=k.arguments?.map(oj(j));switch(k.callee.name){case"Date":return new Date(...e);case"RegExp":return new RegExp(...e);default:throw`Cannot instantiate object of type ${k.callee.name}`}}if(k.callee)throw"new must be called with either Date or RegExp";throw'Could not handle "new" without a specified class';case"Literal":return e.value;case"Identifier":return u=e,d=t,(oN(u.name),d.variables&&Object.hasOwn(d.variables,u.name))?d.variables[u.name]:Object.hasOwn(d.globals,u.name)?d.globals[u.name]:void 0;case"TemplateLiteral":let N,E;return m=e,p=t,N=m.expressions?.map(oj(p))??[],(E=m.quasis?.map(oj(p))??[]).filter(e=>!e.tail).map(e=>e.value).join("")+N.join("")+E.filter(e=>e.tail).map(e=>e.value).join("");case"TemplateElement":return{value:(f=e).cooked,tail:f.tail};default:throw`Expression evaluator does not support expression of type '${e.type}'`}}function o_(e,t){switch(e.type){case"Literal":return e.value;case"Identifier":return e.name;case"MemberExpression":return o_(e.property,t);default:throw`VisitExpressionName does not support expression of type '${e.type}'`}}function oy(e,t){let n=oS(e.callee,t);if(n===ox||e.optional&&null==n)return ox;let o=e.arguments?.map(oj(t));if(n){if("function"!=typeof n)throw`${oP(e.callee)} is not a function`}else throw`No function named ${oP(e.callee)} is defined in this context`;return n(...o)}function ov(e,t){let n=oS(e.object,t);if(n===ox||e.optional&&null==n)return ox;if(null===n)throw TypeError(`TypeError: cannot read properties of null (reading '${oC(e.property,t)}')`);if(void 0===n)switch(e.object.type){case"Identifier":{let n=o_(e.object,t);throw ReferenceError(`ReferenceError: ${n} is not defined`)}case"MemberExpression":throw TypeError(`TypeError: cannot read properties of undefined (reading '${oC(e.property,t)}')`);default:throw`VisitMemberExpression does not support operator '${e.object.type}' type`}if("object"!=typeof n&&"function"!=typeof n&&"string"!=typeof n&&"number"!=typeof n)throw`VisitMemberExpression does not support member access on type ${typeof n}`;let o=e.computed?function(e){if(void 0===e)throw{type:"Illegal property access",message:"No property was supplied to the property access"};if("string"!=typeof e&&"number"!=typeof e)throw{type:"Illegal property access",message:`Cannot use a value of type ${null===e?"null":typeof e} as a property name`};return e}(ow(e.property,t)):function(e){if("Identifier"!==e.type)throw`VisitMemberExpression does not support a property of type '${e.type}'`;return e.name}(e.property);oN(o),function(e,t){if(oE.has(String(t)))return;let n=Object(e);for(;null!==n;){if(Object.hasOwn(n,t)){if(n===Object.prototype||n===Function.prototype)throw{type:"Illegal property access",message:`Cannot access the ${t} property of objects`};return}n=Object.getPrototypeOf(n)}}(n,o);let r=n[o];return"function"==typeof r?r.bind(n):r}function ob(e,t){let n={variables:{...e},globals:{...t},addVariables(e){return this.variables={...this.variables,...e},this}};return n.addVariables.bind(n),n}n4.A.plugins.register(n3.A),n4.A.plugins.register(n7.A),n4.A.plugins.register(n9.A),n4.A.plugins.register(oe.A),n4.A.plugins.register(ot.A),n4.A.plugins.register(on.A),n4.A.addBinaryOp("in",7),n4.A.addBinaryOp("??",1);let ox=Symbol("optional chain short-circuited");function oS(e,t){switch(e.type){case"MemberExpression":return ov(e,t);case"CallExpression":return oy(e,t);default:return ow(e,t)}}function ok(e){return e===ox?void 0:e}function oj(e){return function(t){return null===t?null:ow(t,e)}}function oN(e){if("__proto__"===e||"prototype"===e||"constructor"===e)throw{type:"Illegal property access",message:`Cannot access the ${e} property of objects`}}let oE=new Set(["toString","valueOf","hasOwnProperty"]);function oC(e,t){try{return o_(e,t)}catch{return"<computed>"}}function oP(e){return e?"MemberExpression"===e.type?e.property?.name:e.name:null}function oI(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:{...or},isLocalExpression:!1,variables:new Set};return oO("string"==typeof e?(0,n4.A)(e):e,t),[...t.variables]}function oO(e,t){switch(e.type){case"UnaryExpression":return o=e,r=t,oO(o.argument,r);case"BinaryExpression":return i=e,s=t,[oO(i.left,s),oO(i.right,s)].filter(Boolean);case"ConditionalExpression":return a=e,l=t,[oO(a.consequent,l),oO(a.test,l),oO(a.alternate,l)].filter(Boolean);case"CallExpression":let n;return c=e,u=t,n=oO(c.callee,u),c.arguments?.map(oA(u)),n;case"ArrowFunctionExpression":var o,r,i,s,a,l,c,u,d,m,p,f,g,h,w,_,y=e,v=t;let b={...v};b.isLocalExpression=!0;let x=y.params?.map(oA(b))??[],S=oO(y.body,b)??[];if(S&&Array.isArray(S))for(let e of S)x.includes(e)||v.variables.add(e);return;case"MemberExpression":var k=e,j=t;if(oO(k.object,j),k.computed)return void oO(k.property,j);let N={...j};N.isLocalExpression=!0,oO(k.property,N);return;case"ArrayExpression":return d=e,m=t,void d.elements?.map(oA(m));case"SequenceExpression":return p=e,f=t,void p.expressions?.map(oA(f));case"NewExpression":return g=e,h=t,void g.arguments?.map(oA(h));case"Literal":case"TemplateElement":return;case"Identifier":var E=e,C=t;if(!(E.name in C.globals))if(C.isLocalExpression)return E.name;else C.variables.add(E.name);return;case"TemplateLiteral":return w=e,_=t,void(w.expressions?.map(oA(_)),w.quasis?.map(oA(_)));default:throw`Expression evaluator does not support expression of type '${e.type}'`}}function oA(e){return function(t){return null===t?null:oO(t,e)}}let oR=M("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:",""),o=JSON.parse(localStorage.getItem(`openmrs:feature-flag-meta:${n}`)||"{}");e[n]={enabled:"true"===localStorage.getItem(t),...o}}return e}()});function o$(e,t,n){oR.setState(o=>({flags:{...o.flags,[e]:{enabled:o.flags[e]?.enabled??!1,label:t,description:n}}}))}function oT(){let e=oR.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 oM(e){return oR.getState().flags[e].enabled}function oL(e,t){oR.subscribe(n=>{t(n.flags[e].enabled)})}function oW(e,t){oR.setState(n=>({flags:{...n.flags,[e]:{...n.flags[e],enabled:t}}}))}oR.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 oD=n(1216);let oU=R("extensionsInternal",{slots:{},extensions:{}}),oB=R("extensionRenderings",{renderings:new Map}),oF=()=>M("extensionsInternal",{slots:{},extensions:{}}),oH=()=>M("extensionRenderings",{renderings:new Map});function oV(e){let t=oU.getState(),n=e(t);n!==t&&oU.setState(n)}let oG=null,oz=null;function oq(){let e=oB.getState();return oG&&e===oz||(oG=new Map(e.renderings),oz=e,function(e){for(let t of(o5.clear(),e.values()))o8(t,1);o6=!0}(oG)),oG}function oJ(e){oz={renderings:e},oB.setState(oz,!0)}function oK(e){let t=oq();t.has(e.renderingId)||(t.set(e.renderingId,e),o8(e,1),oJ(t))}function oX(e){let t=oq(),n=t.get(e);n&&(t.delete(e),o8(n,-1),oJ(t))}let oY=()=>M("extensions",{slots:{}}),oZ=0,oQ=new Set;function o0(e){oZ++;try{return e()}finally{if(0==--oZ&&oQ.size>0){let e=Array.from(oQ);for(let t of(oQ.clear(),e))o1(t)}}}function o1(e){try{e()}catch(t){console.error(`The extension system's '${e.name}' recomputation failed`,t)}}function o2(e){oZ>0?oQ.add(e):o1(e)}let o5=new Map,o6=!1;function o8(e,t){let n=JSON.stringify([e.slotName,e.extensionId,e.slotModuleName,e.extensionModuleName]),o=o5.get(n);if(!o){if(t<0)return;o5.set(n,{count:1,record:{slotModuleName:e.slotModuleName,extensionModuleName:e.extensionModuleName,slotName:e.slotName,extensionId:e.extensionId}}),o6=!0;return}o.count+=t,o.count<1&&(o5.delete(n),o6=!0)}function o4(){var e,t;if(oq(),!o6)return;o6=!1;let n=Array.from(o5.values(),({record:e})=>e);n.sort(o3),e=et.getState().mountedExtensions,t=n,e.length===t.length&&e.every((e,n)=>0===o3(e,t[n]))||et.setState({mountedExtensions:n})}function o3(e,t){return o7(e.slotName,t.slotName)||o7(e.extensionId,t.extensionId)||o7(e.slotModuleName,t.slotModuleName)||o7(e.extensionModuleName,t.extensionModuleName)}function o7(e,t){return e===t?0:e<t?-1:1}o4(),oB.subscribe(()=>o2(o4));let o9=oF(),re=oY(),rt=eo(),rn=es(),ro=new Set,rr=!1;function ri(e){if(null===e)ro=null;else if(null!==ro)for(let t of e)ro.add(t);o2(rs)}function rs(){if(!rr){rr=!0;try{for(let e=1;;e++){let t=ro;if(null!==t&&0===t.size)return;ro=new Set;try{!function(e,t,n,o,r,i=null){let s=re.getState().slots,a={},l=!1,c=Object.entries(o.flags).filter(([,{enabled:e}])=>e).map(([e])=>e);for(let[o,u]of Object.entries(e.slots)){let d=s[o];if(d&&i&&!i.has(o)){a[o]=d;continue}let{config:m}=ei(t,u.name),p=function(e,t,n,o,r,i){let s=function(e,t){let n=e.add||[],o=e.remove||[],r=e.order||[],{extensions:i}=o9.getState(),s=new Set(o),a=[...t,...n].filter(e=>!s.has(e)),l=rh(r),c=rh(t),u=new Map(a.map(e=>[e,function(e,t,n,o){let r=t.get(e);if(void 0!==r)return r;{if(void 0!==n)return 1e3+n;let t=o.get(e);return void 0!==t?2e3+t:3e3}}(e,l,i[rc(e)]?.order,c)]));return a.sort((e,t)=>u.get(e)-u.get(t))}(n,t.slots[e].attachedIds),a=[];for(let l of s){let{config:s}=ea(o,e,l),c=el(n,e,l),u=c?(0,oD.A)({},s,c):s,d=rc(l),m=t.extensions[d];if(m){let e=u?.["Display conditions"]?.privileges??m.privileges??[];if(e&&("string"==typeof e||Array.isArray(e)&&e.length>0)&&(!i?.user||!tU(e,i.user))||m.featureFlag&&!r.includes(m.featureFlag))continue;a.push({id:l,name:d,moduleName:m.moduleName,config:u,featureFlag:m.featureFlag,meta:m.meta,displayConditionExpression:u?.["Display conditions"]?.expression||m.displayExpression})}}return a}(o,e,m,n,c,r.session);d&&d.moduleName===u.moduleName&&(0,F.A)(d.candidateExtensions,p)?a[o]=d:(a[o]={moduleName:u.moduleName,candidateExtensions:p},l=!0)}(l||Object.keys(s).length!==Object.keys(a).length)&&re.setState({slots:a})}(o9.getState(),rt.getState(),rn.getState(),oR.getState(),tO.getState(),t)}catch(e){throw ro=null===t||null===ro?null:new Set([...t,...ro]),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{rr=!1}}}function ra(e,t){let n=new Set;for(let o of Object.keys(e))e[o]!==t[o]&&n.add(o);for(let o of Object.keys(t))o in e||n.add(o);return n}function rl(e,t){return{moduleName:t,name:e,attachedIds:[]}}function rc(e){let[t]=e.split("#");return t}function ru(e,t){let n=rc(t);return e.extensions[n]}function rd(e){return ru(o9.getState(),e)}o9.subscribe((e,t)=>{ri(e.extensions!==t.extensions?null:ra(e.slots,t.slots))}),rt.subscribe((e,t)=>{ri(ra(e.slots,t.slots))}),rn.subscribe((e,t)=>{ri(ra(e.configs,t.configs))}),oR.subscribe(()=>ri(null)),tO.subscribe(()=>ri(null)),ri(null);let rm=e=>oV(t=>({...t,extensions:{...t.extensions,[e.name]:{...e}}}));function rp(e,t){oV(n=>{let o=n.slots[e];return o?{...n,slots:{...n.slots,[e]:{...o,attachedIds:[...o.attachedIds,t]}}}:{...n,slots:{...n.slots,[e]:{...rl(e),attachedIds:[t]}}}})}function rf(e,t){oV(n=>{let o=n.slots[e];return o&&o.attachedIds.includes(t)?{...n,slots:{...n.slots,[e]:{...o,attachedIds:o.attachedIds.filter(e=>e!==t)}}}:n})}function rg(e){oV(t=>{let n=t.slots[e];return n?{...t,slots:{...t.slots,[e]:{...n,attachedIds:[]}}}:t})}function rh(e){let t=new Map;return e.forEach((e,n)=>{t.has(e)||t.set(e,n)}),t}function rw(e,t){return function(e,t,n=null,o){let r;return e.filter(e=>{let i=e.displayConditionExpression;if("string"!=typeof i||0===i.trim().length)return!0;r??(r=t&&"object"==typeof t?{session:n,...t}:{session:n});try{return!!oa(i,r)}catch(t){return console.error(`Error while evaluating expression '${i}' for ${e.id}`+(o?` in ${o}`:""),t),!1}})}(r_(e),t,tO.getState().session,e)}function r_(e){return re.getState().slots[e]?.candidateExtensions??[]}let ry=(e,t)=>o9.setState(n=>{let o=n.slots[t]?.moduleName;if(o&&o!=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 ${o}.`),n;if(o&&o==e)return n;if(n.slots[t])return{...n,slots:{...n.slots,[t]:{...n.slots[t],moduleName:e}}};let r=rl(t,e);return{...n,slots:{...n.slots,[t]:{...r}}}}),rv=()=>{ro=null,oV(()=>({slots:{},extensions:{}})),oH().setState({renderings:new Map}),re.setState({slots:{}})},rb=R("left-nav",{slotName:null,basePath:window.spaBase,mode:"normal"});function rx({name:e,basePath:t,mode:n,componentContext:o,state:r}){rb.setState({slotName:e,basePath:t,mode:n??"normal",componentContext:o,state:r})}function rS(e){rb.getState().slotName===e&&rb.setState(rb.getInitialState(),!0)}let rk=R("modalRegistry",{modals:{}});function rj(e){rk.setState(t=>(t.modals[e.name]=e,t))}function rN(e){let t=rk.getState().modals[e];if(!t){let n=rd(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.`),rj(t))}return t}let rE=R("workspace2",{registeredGroupsByName:{},registeredWindowsByName:{},registeredWorkspacesByName:{},openedGroup:null,openedWindows:[],isMostRecentlyOpenedWindowHidden:!1});function rC(e){let{registeredWorkspacesByName:t,registeredWindowsByName:n}=rE.getState(),o=t[e];if(o){let t=n[o.window];if(t)return t;throw Error(`No workspace window found with name: ${o.window} for workspace: ${e}`)}throw Error(`No workspace found with name: ${e}`)}function rP(e){let{registeredGroupsByName:t,registeredWindowsByName:n}=rE.getState(),o=n[e];if(o){let n=t[o.group];if(n)return n;throw Error(`No workspace group found with name: ${o.group} for window: ${e}`)}throw Error(`No workspace window found with name: ${e}`)}function rI(e){let{openedWindows:t}=rE.getState();return t.findIndex(t=>t.openedWorkspaces.find(t=>t.workspaceName===e))}function rO(e,t){if(0==t.length)return;let{registeredGroupsByName:n}=rE.getState(),o={...n};for(let n of t){if(o[n.name])throw Error(`Cannot register workspace group ${n.name} more than once`);o[n.name]={...n,moduleName:e}}rE.setState({registeredGroupsByName:o})}function rA(e,t){if(0==t.length)return;let{registeredWindowsByName:n}=rE.getState(),o={...n};for(let n of t){if(o[n.name])throw Error(`Cannot register workspace window ${n.name} more than once`);let t={...n,moduleName:e};o[n.name]=t}rE.setState({registeredWindowsByName:o})}function rR(e,t){if(0==t.length)return;let{registeredWorkspacesByName:n}=rE.getState(),o={...n};for(let n of t){if(o[n.name])throw Error(`Cannot register workspace ${n.name} more than once`);let t={...n,moduleName:e};o[n.name]=t}rE.setState({registeredWorkspacesByName:o})}let r$=0,rT=null,rM={bootstrap:15e3,mount:15e3,unmount:15e3};function rL(e,t){if(e.timeouts)return e;let n=e.name??"parcel",o=Object.fromEntries(Object.keys(rM).filter(t=>e[t]).map(o=>{var r,i;let s,a;return[o,(r=e[o],i=rM[o],s=Array.isArray(r)?r:[r],a=e=>s.reduce((t,r,i)=>t.then(()=>{let t=r(e);return"function"==typeof t?.then&&"function"==typeof t?.catch?t:Promise.reject(Error(`Lifecycle function ${o} at array index ${i} for parcel ${n} did not return a promise`))}),Promise.resolve(void 0)),e=>{let r,s=new Promise((e,t)=>{r=setTimeout(()=>t(Error(`Lifecycle function ${o} for parcel ${n} did not settle within ${i}ms`)),i)});return Promise.race([a(e),s]).finally(()=>clearTimeout(r)).then(e=>(t(o,!1),e),e=>{throw t(o,!0),e})})]}));return{...e,...o}}async function rW(e,t){var n,o;let r,i,s,a,l,c=await (rT??(rT=new Promise((e,t)=>{(0,ta.xL)({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),ta.xL))),rT),u={...t},d=(r=u,i=!1,{retarget:e=>r={...e},release:s=()=>(function(e){for(let t of Object.keys(e))delete e[t]})(r),onSettled(e,t){switch(e){case"bootstrap":t&&s();return;case"mount":i||(i=t);return;case"unmount":(t||i)&&s();return}}});return o=c((n=d.onSettled,"function"==typeof e?()=>e().then(e=>rL(e,n)):rL(e,n)),u),a=e=>t=>e.call(o,d.retarget(t)).catch(e=>{throw"SKIP_BECAUSE_BROKEN"===o.getStatus()&&d.release(),e}),l=o.update&&a(o.update),Object.defineProperty(o,"update",{configurable:!0,enumerable:!0,get:()=>l,set:e=>{l=e&&a(e)}})}function rD(){return rU}function rU(e,t){let n,o=rW(e,t).then(e=>n=e);return{mount:()=>o.then(e=>e.mount()),unmount:()=>o.then(e=>e.unmount()),update:e=>o.then(t=>t.update?.(e)),getStatus:()=>n?.getStatus()??"LOADING_SOURCE_CODE",get loadPromise(){return o.then(e=>e.loadPromise)},get bootstrapPromise(){return o.then(e=>e.bootstrapPromise)},get mountPromise(){return o.then(e=>e.mountPromise)},get unmountPromise(){return o.then(e=>e.unmountPromise)}}}async function rB(e,t,n,o,r=e=>e,i={}){let s=rc(o),a=rd(o),l=null;if(e){let c;if(!a)throw Error(`Couldn't find extension '${s}' to attach to '${t}'`);let{meta:u,moduleName:d,load:m}=a,p=r$++,f=`${t}/${o}-${p}`;e.dataset.extensionRenderingId=f;let g=e=>{try{oX(f)}catch(t){console.error(e,t)}};try{oK({renderingId:f,extensionName:s,extensionModuleName:d,extensionId:o,slotName:t,slotModuleName:n})}catch(e){throw g(`Recomputing configuration after registering '${o}' failed also failed`),e}try{c=await m()}catch(e){throw g(`Recomputing configuration after '${o}' failed to load also failed`),e}try{l=await rW(r({...c,name:`${t}/${s}-${p}`}),{...i,_meta:u,_extensionContext:{extensionId:o,extensionSlotName:t,extensionSlotModuleName:n,extensionModuleName:d,extensionMeta:u},domElement:e})}catch(e){throw g(`Recomputing configuration after '${o}' failed to mount also failed`),e}l.mountPromise.then(void 0,e=>{console.error(`Extension '${o}' in slot '${t}' failed to mount`,e),g(`Recomputing configuration after '${o}' failed to mount also failed`)}),l.unmountPromise.then(()=>g(`Recomputing configuration after unmounting '${o}' failed`),e=>{console.error(`Extension '${o}' in slot '${t}' failed to unmount`,e),g(`Recomputing configuration after '${o}' failed to unmount also failed`)})}else console.warn(`Tried to render ${o} into ${t} but no DOM element was available.`);return l}var rF=n(6925),rH=n.n(rF);let rV=(0,rF.createContext)({moduleName:"",featureName:""});function rG({to:e,templateParams:t,onBeforeNavigate:n,children:o,...r}){return(0,rF.useEffect)(()=>{r.href&&console.warn(`ConfigurableLink does not support the href prop. Use the 'to' prop instead. The provided href value is '${r.href}'`),r.onClick&&console.warn(`ConfigurableLink does not support the onClick prop. Use the 'onBeforeNavigate' prop instead. The 'to' prop of the offending link is ${e}`)},[]),rH().createElement("a",{onClick:o=>{0===o.button&&!o.ctrlKey&&!o.shiftKey&&!o.altKey&&!o.metaKey&&(o.preventDefault(),n?.(o),tg({to:e,templateParams:t})),0===o.button&&(o.ctrlKey||o.metaKey)&&n?.(o),0===o.button&&o.shiftKey&&n?.(o),1===o.button&&n?.(o)},href:tp(e,t),...r},o)}let rz=({state:e,children:t,...n})=>{let{extension:o}=(0,rF.useContext)(rV),r=(0,rF.useRef)(null),i=(0,rF.useRef)(Promise.resolve()),s=(0,rF.useRef)(!1),a=(0,rF.useRef)(!1),l=(0,rF.useRef)(e),c=(0,rF.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,rF.useCallback)((e,t)=>{e.update&&"UNMOUNTING"!==e.getStatus()&&(i.current=Promise.all([e.mountPromise,i.current]).then(()=>{if(r.current?.getStatus()==="MOUNTED"&&r.current.update)return r.current.update({...t})}).catch(e=>{let t=r.current?.getStatus();"UNMOUNTING"!==t&&"NOT_MOUNTED"!==t&&"UNLOADING"!==t&&console.error(`The extension '${o?.extensionId}' failed to update`,e)}))},[]),d=(0,rF.useCallback)(t=>{t&&!r.current&&!a.current&&o?.extensionSlotName&&o.extensionSlotModuleName&&(a.current=!0,rB(t,o.extensionSlotName,o.extensionSlotModuleName,o.extensionId,void 0,e).then(t=>{(a.current=!1,r.current=t,s.current)?c(t):t&&l.current!==e&&u(t,l.current)},()=>{a.current=!1}))},[]);return(0,rF.useEffect)(()=>(s.current=!1,()=>{s.current=!0,c(r.current)}),[]),(0,rF.useEffect)(()=>{l.current=e,r.current&&u(r.current,e)},[e]),o?rH().createElement("div",{ref:d,"data-extension-id":o?.extensionId,style:{position:"relative"},...n}):null};function rq(e){let t=(0,rF.useRef)(e);return x(t.current,e)||(t.current=e),t.current}function rJ(e,t){"function"==typeof t&&(t=t(e));let n={};for(let[o,r]of Object.entries(t)){let t=function(...t){e.setState(e=>r(e,...t))};n[o]=t}return n}let rK=e=>e;function rX(e,t=rK,n){let o=(0,rF.useCallback)(t=>e.subscribe(t),[e]),r=(0,rF.useCallback)(()=>t(e.getState()),[e,t]),i=(0,rF.useSyncExternalStore)(o,r,r),s=(0,rF.useMemo)(()=>n?rJ(e,n):null,[e,n]);return(0,rF.useMemo)(()=>s?{...i,...s}:i,[i,s])}function rY(e,t){return rX(e,rK,t)}function rZ(e){return function(t){let n=(0,rF.useCallback)(t=>e.subscribe(t),[]),o=(0,rF.useCallback)(()=>e.getState(),[]),r=(0,rF.useSyncExternalStore)(n,o,o),i=(0,rF.useMemo)(()=>t?rJ(e,t):null,[t]);return(0,rF.useMemo)(()=>i?{...r,...i}:r,[r,i])}}let rQ=[];Object.freeze(rQ);let r0={candidateExtensions:rQ};Object.freeze(r0);let r1=e=>{let t=(0,rF.useCallback)(t=>t.slots?.[e]??r0,[e]);return rX(oY(),t)},r2=e=>e.session;function r5(e,t){let{candidateExtensions:n}=r1(e),o=rX(tO,r2),r=rq(t);return(0,rF.useMemo)(()=>rw(e,r),[e,r,o,n])}function r6(e,t){let{moduleName:n}=(0,rF.useContext)(rV);if(!n)throw Error("ComponentContext has not been provided. This should come from @openmrs/esm-react-utils.");return(0,rF.useEffect)(()=>{ry(n,e)},[n,e]),{extensions:r5(e,t),extensionSlotName:e,extensionSlotModuleName:n}}function r8(e){return e}function r4({name:e,extensionSlotName:t,select:n=r8,children:o,state:r,style:i,...s}){if(o&&r)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 a=e??t,l=(0,rF.useRef)(null),{extensions:c,extensionSlotModuleName:u}=r6(a,r),d=(0,rF.useMemo)(()=>n(c),[n,c]),m=(0,rF.useMemo)(()=>{if("function"==typeof o&&!rH().isValidElement(o))return d.map(e=>o(e,r))},[o,d]);return rH().createElement("div",{ref:l,"data-extension-slot-name":a,"data-extension-slot-module-name":u,style:{...i,position:"relative"},...s},a&&d?.map((e,t)=>rH().createElement(rV.Provider,{key:e.id,value:{moduleName:u,featureName:"",extension:{extensionId:e.id,extensionSlotName:a,extensionSlotModuleName:u,extensionMeta:e.meta}}},m?.[t]??("function"!=typeof o?o:null)??rH().createElement(rz,{state:r}))))}var r3=n(3776),r7=n(9568),r9=n(9737),ie=n(749),it=n.n(ie),io=n(5254);let ir={strictMode:!0,throwErrorsToConsole:!0,disableTranslations:!1},ii=new Map;(0,io.initCache)(ii);let is={errorRetryCount:3,fetcher:tP,focusThrottleInterval:18e5,revalidateIfStale:!0,revalidateOnFocus:!1,revalidateOnReconnect:!1,refreshInterval:0,shouldRetryOnError:e=>{if(e instanceof tI){let t=e.response.status;return!!(t>=500)||401===t||403===t||429===t}return!0},provider:()=>ii};function ia(e){if("object"!=typeof e||"string"!=typeof e.featureName||"string"!=typeof e.moduleName)throw Error("Invalid options");let t=Object.assign({},ir,e),n={...is,...t.swrConfig};return function(e){var o,r,i,s,a;return i=r=class extends(o=rH().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 rH().createElement("div",null,"An error has occurred. Please try reloading the page.");{let o=rH().createElement(rF.Suspense,{fallback:null},rH().createElement(ie.SWRConfig,{value:n},rH().createElement(rV.Provider,{value:this.state.config},t.disableTranslations?rH().createElement(e,this.props):rH().createElement(r9.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},rH().createElement(e,this.props)))));return t.strictMode&&rH().StrictMode?rH().createElement(rH().StrictMode,null,o):o}}constructor(e){super(e),this.state={caughtError:null,caughtErrorInfo:null,config:{moduleName:t.moduleName,featureName:t.featureName,extension:e._extensionContext}}}},s="displayName",a=`OpenmrsReactComponent(${t.featureName})`,s in i?Object.defineProperty(i,s,{value:a,enumerable:!0,configurable:!0,writable:!0}):i[s]=a,r}}function il(e,t){return(0,r7.A)({React:rH(),ReactDOMClient:r3,rootComponent:ia(t)(e)})}function ic(e,t){return()=>e().then(({default:e})=>il(e,t))}function iu(e,t){return()=>Promise.resolve(il(e,t))}let id=ic,im=(0,E.y)()(()=>({}));T("openmrs-app-context",im);let ip={};function ig(e,t=e=>e){let n=im.getState();return e in n?Object.freeze(Object.assign({},t?t(n[e]):n[e])):null}function ih(e,t){im.setState(n=>(e in n||(n[e]={}),n[e]=t(n[e]),Object.assign({},n)))}function iw(e){return null===e?null:Object.freeze(Object.assign({},e))}let i_=new Map;function iy(e,t){let n=(0,rF.useRef)(t??{}),o=(0,rF.useRef)(t=>ih(e,t)),r=(0,rF.useRef)(Symbol());return(0,rF.useEffect)(()=>{let n=t??{},o=r.current;return null===ig(e)?!function(e,t=ip){im.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===ip?{}: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.`),ih(e,()=>n)),i_.set(e,o),()=>{i_.get(e)===o&&(im.setState(t=>(e in t&&delete t[e],t)),i_.delete(e))}},[e]),(0,rF.useEffect)(()=>{let o=t??{};x(n.current,o)||(ih(e,()=>o),n.current=o)},[t]),o.current}function iv({namespace:e,value:t}){return iy(e,t),null}let ib=({children:e,value:t,fallback:n})=>t?rH().createElement(rH().Fragment,null,e):n?rH().createElement(rH().Fragment,null,n):null;function ix(){let e=(0,rF.useRef)();return(!e.current||e.current.signal.aborted)&&(e.current=new AbortController),(0,rF.useEffect)(()=>{let t=e.current;return()=>t?.abort()},[]),e.current}function iS(e,t=e=>e??{}){let[n,o]=(0,rF.useState)(()=>{if(ik(e))return;let n=ig(e);if(null!==n)return t?t(n):n});return(0,rF.useEffect)(()=>{if(ik(e))throw Error(`The namespace supplied to useAppContext must be a non-empty string, but was "${e}".`)},[e]),(0,rF.useEffect)(()=>{var n;let r;return(n=e=>{if(null==e)return void o(void 0);let n=t?t(e):e;o(e=>x(e,n)?e:n)})(iw(r=ig(e))),im.subscribe(t=>{let o=e in t?t[e]:null;o!==r&&(r=o,n(iw(o)))})},[e,t]),n}function ik(e){return"string"!=typeof e||0===e.trim().length}function ij(e){let t=r5(e);return(0,rF.useMemo)(()=>t.map(e=>e.id),[t])}function iN(e){return r1(e).candidateExtensions}function iE(e,t,n){let{data:o,error:r,mutate:i,isLoading:s,isValidating:a}=it()(e?nU(e,t,n):null,tP);return(0,rF.useMemo)(()=>({isLoading:s,data:o?.data.results??[],error:r,mutate:i,isValidating:a}),[o,r,s,a,i])}function iC(e){(0,rF.useEffect)(()=>{if(e){let e=window.getComputedStyle(document.body).overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=e}}},[e])}let iP={},iI=`No ComponentContext has been provided. This should come from "openmrsComponentDecorator".
15
+ ${this.stack}`}}let tO=R("session",{loaded:!1,session:null}),tA=0,tR=null;function t$(){return tR||(tO.getState().loaded&&tA>=Date.now()-6e4?null:tW())}function tT(e){let t=e?.includeAuthStatus??!0,n=e=>t?e:e.user,o=t$();return o?new Promise(e=>{let t=()=>{let t=tO.getState();t.loaded&&(r(),e(n(t.session)))},r=tO.subscribe(t);o.then(t,t)}):Promise.resolve(n(tO.getState().session))}function tM(){return t$(),tO}function tL(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){tA=Date.now(),r??(r=tA);let n={};e&&t&&(n.Authorization=`Basic ${window.btoa(`${e}:${t}`)}`);let o=tJ(tP(tE,{headers:n,rejectAuthFailure:!0})),i=()=>{tR===o&&(tR=null)};return o.then(i,i),tR=o,o}function tD(){tO.setState({loaded:!0,session:{authenticated:!1,sessionId:""}},!0)}function tU(e,t){var n,o;if(void 0===t)return!e;if(!e)return!0;return n=e,o=t,("string"==typeof n?!(0,D.A)(o.privileges.find(e=>n===e.display)):Array.isArray(n)?n.every(e=>!(0,D.A)(o.privileges.find(t=>e===t.display))):((0,D.A)(n)||console.error(`Could not understand privileges "${n}"`),!0))||!(0,D.A)(t.roles.find(e=>"System Developer"===e.display))}function tB(){let e,t;return new Promise(n=>{let o=o=>{o.loaded&&o.session.user&&(e=o.session.user,n(o.session.user),t&&t())};o(tO.getState()),e||(t=tO.subscribe(o))})}async function tF(){return(await tT()).sessionLocation}async function tH(e,t){return tJ(tP(tE,{method:"POST",body:{sessionLocation:e},headers:{"Content-Type":"application/json"},rejectAuthFailure:!0,signal:t?.signal}))}async function tV(e,t){return await tP(tE,{method:"POST",body:{locale:e},headers:{"Content-Type":"application/json"},signal:t?.signal}),tW()}async function tG(e,t,n){return n||(n=new AbortController),await tP(`${tj}/user/${e}`,{method:"POST",body:{userProperties:t},headers:{"Content-Type":"application/json"},signal:n.signal}),tW()}async function tz(e,t=!1){let n=await tP(t?`${tE}?rememberMe=true`:tE,{headers:{"X-Totp-Code":e}});return n.data?.authenticated?(await tW()).session:n.data}async function tq(){try{await tP(tE,{method:"DELETE",rejectAuthFailure:!0})}catch(e){if(!tK(e))throw e}tD(),await tW().catch(()=>{})}function tJ(e){return new Promise((t,n)=>{e.then(e=>{if("object"==typeof e?.data){let n={loaded:!0,session:e.data};tO.setState(n,!0),t(n)}else!function(e){if(!e?.redirected||!e.url)return!1;try{return new URL(e.url,window.location.href).pathname.replace(/\/+$/,"").endsWith("/initialsetup")}catch{return!1}}(e)?n(tX(Error("The session endpoint did not respond with a session"))):n(tX(Error("The server is still starting up"),!0))}).catch(e=>{var o,i;if(tK(e)){"object"==typeof(o=e.responseBody)&&null!==o&&!1===o.authenticated?tO.setState({loaded:!0,session:e.responseBody},!0):tD(),t(tO.getState());return}(i=e)instanceof tI&&502===i.response.status&&!tO.getState().loaded&&void 0!==r&&Date.now()-r<18e4?n(tX(e,!0)):(y(`Failed to fetch new session information: ${e}`),n(tX(e)))})})}function tK(e){return e instanceof tI&&(401===e.response.status||403===e.response.status)}function tX(e,t=!1){return tO.getState().loaded||tO.setState({loaded:!1,session:null,error:e instanceof Error?e:Error(String(e)),initializing:t},!0),tO.getState()}function tY(){return"development"===window.spaEnv||"true"===localStorage.getItem("openmrs:devtools")}tO.subscribe(e=>{e.loaded&&e.session&&tL(e.session)});let tZ={"webservices.rest":"2.24.0",fhir2:"1.0.0-SNAPSHOT"};function tQ(){eP("@openmrs/esm-api",tS),tW()}let t0="import-map-override:",t1="import-map-overrides-disabled",t2="import-map-overrides:change",t5=!1,t6=null,t8=null;async function t4(){return t8??(t8=t3().then(({map:e,complete:t})=>(t||(t8=null),e))),t8}async function t3(){let e=document.querySelectorAll('script[type="systemjs-importmap"]'),t=[],n=!0;for(let o=0;o<e.length;o++){let r=e[o];try{if(r.src){let e=await fetch(r.src);if(!e.ok)throw Error(`Request for ${r.src} returned ${e.status} ${e.statusText}`);t.push(await e.json())}else r.textContent&&t.push(JSON.parse(r.textContent))}catch(e){n=!1,console.warn(`[import-maps] Failed to parse import map from script tag at index ${o}`,e)}}return{map:t7(t),complete:n}}function t7(e){let t={imports:{}};for(let n of e)n?.imports&&Object.assign(t.imports,n.imports);return t}function t9(){let e={};try{let t=nr();for(let n=0;n<localStorage.length;n++){let o=localStorage.key(n);if(o?.startsWith(t0)){let n=o.slice(t0.length);if(!t.includes(n)){let t=localStorage.getItem(o);t&&(e[n]=t)}}}}catch(e){console.warn("[import-maps] Failed to read import-map overrides from localStorage",e)}return{imports:e}}async function ne(){let e=await t4();return t5?t7([e,t6??t9()]):e}async function nt(){return t4()}async function nn(){return t5?t7([await t4(),t9()]):t4()}function no(e){if(!t5)return{imports:{}};if(e){let e={};for(let t=0;t<localStorage.length;t++){let n=localStorage.key(t);if(n?.startsWith(t0)){let t=localStorage.getItem(n);t&&(e[n.slice(t0.length)]=t)}}return{imports:e}}return t9()}function nr(){if(!t5)return[];try{let e=localStorage.getItem(t1);if(e){let t=JSON.parse(e);if(Array.isArray(t))return t}}catch{}return[]}function ni(e){return!!t5&&nr().includes(e)}function ns(e,t){if(!t5)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{localStorage.setItem(t0+e,t),window.dispatchEvent(new CustomEvent(t2))}catch(e){console.warn("[import-maps] Failed to write import-map override to localStorage",e)}}function na(e){if(!t5)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{localStorage.removeItem(t0+e);let t=nr().filter(t=>t!==e);t.length>0?localStorage.setItem(t1,JSON.stringify(t)):localStorage.removeItem(t1),window.dispatchEvent(new CustomEvent(t2))}catch(e){console.warn("[import-maps] Failed to update import-map overrides in localStorage",e)}}function nl(){if(!t5)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(t0)&&e.push(n)}e.forEach(e=>localStorage.removeItem(e)),localStorage.removeItem(t1),window.dispatchEvent(new CustomEvent(t2))}catch(e){console.warn("[import-maps] Failed to clear import-map overrides from localStorage",e)}}function nc(e){if(!t5)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(t1,JSON.stringify(t)):localStorage.removeItem(t1),window.dispatchEvent(new CustomEvent(t2))}catch(e){console.warn("[import-maps] Failed to update import-map overrides in localStorage",e)}}let nu=!1;function nd(){!nu&&(nu=!0,(t5="development"===window.spaEnv)&&(t6=t9()))}function nm(e){return e.replace(/[\/\-@]/g,"_")}async function np(e,t="./start",o){var r;let i,s=!o?.maxLoadingTime||o.maxLoadingTime<=0?6e5:o.maxLoadingTime;await Promise.race([nf(e,o?.importMap),new Promise((t,n)=>{i=setTimeout(()=>{var t;n(Error(`Could not resolve requested script, ${e}, within ${(t=s)<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`}.`))},s)})]),i&&clearTimeout(i);let a=nm(e),l=window[a];if(!("object"==typeof(r=l)&&null!==r&&"init"in r&&"function"==typeof r.init&&"get"in r&&"function"==typeof r.get)){let e=`The global variable ${a} 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 nf(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=nm(e);if(!window[n]){let n=t??await ng();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 o=n.imports[e];o.startsWith("./")&&(o=window.spaBase+o.substring(1));let r=e in no().imports;try{return await function(e){var t;let n=(t=window)[nh]??(t[nh]=new Map),o=n.get(e);if(o)return o;if(document.head.querySelector(`script[src="${e}"]`))return console.warn(`Script at ${e} already loaded. Not loading it again.`),Promise.resolve();let r=document.createElement("script");r.src=e,r.type="text/javascript",r.async=!0;let i=new Promise((t,o)=>{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 s(){clearTimeout(i),r.removeEventListener("load",a),r.removeEventListener("error",l)}function a(){s(),t()}function l(t){s(),n.delete(e),r.remove();let i=`Failed to load script from ${e}`;console.error(i,t),o(t.message??i)}r.addEventListener("load",a),r.addEventListener("error",l),document.head.appendChild(r)});return n.set(e,i),i}(o)}catch(e){return r&&p({kind:"error",title:tm("scriptLoadingFailed","Error: Script failed to load"),description:tm("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:o}),actionButtonLabel:tm("resetOverrides","Reset overrides"),onActionButtonClick(){nl(),window.location.reload()}}),Promise.reject(e)}}return Promise.resolve()}async function ng(){return ne()}let nh=Symbol.for("__openmrs_script_loading");function nw(e){return!!e&&"object"==typeof e&&!(Object.hasOwn(e,"pages")&&(!e.pages||!Array.isArray(e.pages))||Object.hasOwn(e,"extensions")&&(!e.extensions||!Array.isArray(e.extensions))||Object.hasOwn(e,"modals")&&(!e.modals||!Array.isArray(e.modals))||Object.hasOwn(e,"workspaces2")&&(!e.workspaces2||!Array.isArray(e.workspaces2))||Object.hasOwn(e,"workspaceWindows2")&&(!e.workspaceWindows2||!Array.isArray(e.workspaceWindows2))||Object.hasOwn(e,"workspaceGroups2")&&(!e.workspaceGroups2||!Array.isArray(e.workspaceGroups2)))}function n_(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&&nw(t))}let ny="openmrs-routes:",nv="openmrs-routes:change",nb=!1,nx=null,nS=null;async function nk(){return nS??(nS=nj().then(({map:e,complete:t})=>(t||(nS=null),e))),nS}async function nj(){let e=document.querySelectorAll("script[type='openmrs-routes']"),t=[],n=!0;for(let o=0;o<e.length;o++){let r=e[o];try{let e;if(r.src){let t=await fetch(r.src);if(!t.ok)throw Error(`Request for ${r.src} returned ${t.status} ${t.statusText}`);e=await t.json()}else r.textContent&&(e=JSON.parse(r.textContent));e&&n_(e)&&t.push(e)}catch(e){n=!1,console.warn(`[route-maps] Failed to parse routes from script tag at index ${o}`,e)}}return{map:nN(t),complete:n}}function nN(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 nE(){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(nw(n))return{moduleName:e,routes:n};if("string"==typeof n&&n.startsWith("http")){let t=await fetch(n),o=await t.json();if(nw(o))return{moduleName:e,routes:o};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 nb?nN([e,nx??await nE()]):e}async function nP(){return nk()}async function nI(){return nb?nN([await nk(),await nE()]):nk()}function nO(){if(!nb)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 nA(e,t){if(!nb)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(!nw(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(!nw(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(nv))}catch(e){console.warn("[route-maps] Failed to write route override to localStorage",e)}}function nR(e){if(!nb)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{localStorage.removeItem(ny+e),window.dispatchEvent(new CustomEvent(nv))}catch(e){console.warn("[route-maps] Failed to remove route override from localStorage",e)}}function n$(){if(!nb)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(nv))}catch(e){console.warn("[route-maps] Failed to clear route overrides from localStorage",e)}}let nT=null;function nM(){return nT||(nT=(nb="development"===window.spaEnv)?nE().then(e=>{nx=e}):Promise.resolve())}let nL=`${tj}/attachment`;function nW(e,t){return tP(`${nL}/${e}`,{signal:t.signal})}function nD(e,t,n,o){return tP(nU(e,t,o),{signal:n.signal})}function nU(e,t,n){return n?`${nL}?patient=${e}&encounter=${n}`:`${nL}?patient=${e}&includeEncounterless=${t}`}async function nB(e,t,n){let o=new FormData;return o.append("fileCaption",t.fileDescription),o.append("patient",e),n&&o.append("encounter",n),t.file?o.append("file",t.file,t.fileName):(o.append("file",new File([""],t.fileName),t.fileName),o.append("base64Content",t.base64Content)),tP(`${nL}`,{method:"POST",body:o})}function nF(e,t){return tP(`${nL}/${e}`,{method:"DELETE",signal:t.signal})}async function nH(e,t){return e?(await tP(`${tN}/Patient/${e}`,t)).data:null}function nV(e,t){let n=new CustomEvent(`openmrs:${e}`,{detail:t??void 0,cancelable:!0,bubbles:!0});return window.dispatchEvent(n)}function nG(e,t){let n=e=>{t("detail"in e&&null!==e.detail?e.detail:void 0)};return window.addEventListener(`openmrs:${e}`,n),()=>{window.removeEventListener(`openmrs:${e}`,n)}}function nz(e){return{uuid:e.uuid,display:e.display}}function nq(e=null,t=null){let n=new URLSearchParams;e&&n.set("tag",e),t&&n.set("q",t);let o=n.toString();return tP(`${tj}/location${o?"?"+o:""}`).then(e=>e.data.results.map(nz))}function nJ(e){return{uuid:e.uuid,display:e.display,name:e.name}}let nK=`${tj}/visittype`;function nX(e=nK){return tP(e).then(e=>e.data.results.map(nJ))}var nY=((k={}).NEWVISIT="startVisit",k.EDITVISIT="editVisit",k.LOADING="loadingVisit",k),nZ=((j={}).NOTSTARTED="notStarted",j.ONGOING="ongoing",j);let nQ="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))",n0=function(){try{return JSON.parse(sessionStorage.getItem("openmrs:visitStoreState")||"null")}catch(e){return null}}()||{patientUuid:null,manuallySetVisitUuid:null};function n1(){return M("visit",n0)}function n2(e,t){n1().setState({patientUuid:e,manuallySetVisitUuid:t})}function n5(e,t){return tP(`${tj}/visit`,{signal:t.signal,method:"POST",headers:{"Content-type":"application/json"},body:e})}function n6(e,t,n){return tP(`${tj}/visit/${e}`,{signal:n.signal,method:"POST",headers:{"Content-type":"application/json"},body:t})}function n8(e,t,n){return tP(`${tj}/visit?patient=${e}&v=${n??nQ}`,{signal:t.signal,method:"GET",headers:{"Content-type":"application/json"}})}n1().subscribe(e=>{var t;t=e,sessionStorage.setItem("openmrs:visitStoreState",JSON.stringify(t))});var n4=n(9225),n3=n(6881),n7=n(6828),n9=n(1956),oe=n(3635),ot=n(7839),on=n(2298);let oo={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)}},or={...oo,Promise};function oi(e,t={}){return od(e,t,of)}async function os(e,t={}){return om(e,t,of)}function oa(e,t={}){return od(e,t,og)}function ol(e,t={}){return om(e,t,og)}function oc(e,t={}){return od(e,t,oh)}function ou(e,t={}){return om(e,t,oh)}function od(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 o=ob(t,oo),r=ow("string"==typeof e?(0,n4.A)(e):e,o);if(n(r))return r;throw{type:"Invalid result",message:"string"==typeof e?`The expression ${e} did not produce a valid result`:"The expression did not produce a valid result"}}async function om(e,t={},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 o=ob(t,or);return Promise.resolve(ow("string"==typeof e?(0,n4.A)(e):e,o)).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 op(e){return(0,n4.A)(e)}function of(e){return"string"==typeof e||"number"==typeof e||"boolean"==typeof e||null==e||e instanceof Date}function og(e){return"boolean"==typeof e}function oh(e){return"number"==typeof e}function ow(e,t){switch(e.type){case"UnaryExpression":var n,o,r,i,s,a,l,c,u,d,m,p,f,g=e,h=t;let w=ow(g.argument,h);switch(g.operator){case"+":return+w;case"-":return-w;case"~":return~w;case"!":return!w;default:throw`Expression evaluator does not support operator '${g.operator}''`}case"BinaryExpression":var _=e,y=t;switch(_.operator){case"&&":return ow(_.left,y)&&ow(_.right,y);case"||":return ow(_.left,y)||ow(_.right,y);case"??":return ow(_.left,y)??ow(_.right,y)}let v=ow(_.left,y),b=ow(_.right,y);switch(_.operator){case"+":return v+b;case"-":return v-b;case"*":return v*b;case"/":return v/b;case"%":return v%b;case"**":return v**b;case"==":return v==b;case"===":return v===b;case"!=":return v!=b;case"!==":return v!==b;case">":return v>b;case">=":return v>=b;case"<":return v<b;case"<=":return v<=b;case"in":return v in b;default:throw`Expression evaluator does not support operator '${_.operator}' operator`}case"ConditionalExpression":return n=e,o=t,ow(n.test,o)?ow(n.consequent,o):ow(n.alternate,o);case"CallExpression":return ok(oy(e,t));case"ArrowFunctionExpression":let x;return r=e,i=t,x=r.params?.map(e=>{if("Identifier"===e.type)return e.name;throw`Cannot handle parameter of type ${e.type}`})??[],(function(...e){if(e.length<x.length)throw`Required argument(s) ${x.slice(e.length,-1).join(", ")} were not provided`;let t=Object.fromEntries(x.reduce((t,n,o)=>{let r=e[o];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}(r)&&t.push([n,r]),t},[]));return ow(r.body,i.addVariables(t))}).bind(null);case"MemberExpression":return ok(ov(e,t));case"ArrayExpression":return s=e,a=t,s.elements?.map(oj(a));case"SequenceExpression":let S;return l=e,c=t,(S=l.expressions.map(oj(c)))[S.length-1];case"NewExpression":var k=e,j=t;if(k.callee&&"Identifier"===k.callee.type){let e=k.arguments?.map(oj(j));switch(k.callee.name){case"Date":return new Date(...e);case"RegExp":return new RegExp(...e);default:throw`Cannot instantiate object of type ${k.callee.name}`}}if(k.callee)throw"new must be called with either Date or RegExp";throw'Could not handle "new" without a specified class';case"Literal":return e.value;case"Identifier":return u=e,d=t,(oN(u.name),d.variables&&Object.hasOwn(d.variables,u.name))?d.variables[u.name]:Object.hasOwn(d.globals,u.name)?d.globals[u.name]:void 0;case"TemplateLiteral":let N,E;return m=e,p=t,N=m.expressions?.map(oj(p))??[],(E=m.quasis?.map(oj(p))??[]).filter(e=>!e.tail).map(e=>e.value).join("")+N.join("")+E.filter(e=>e.tail).map(e=>e.value).join("");case"TemplateElement":return{value:(f=e).cooked,tail:f.tail};default:throw`Expression evaluator does not support expression of type '${e.type}'`}}function o_(e,t){switch(e.type){case"Literal":return e.value;case"Identifier":return e.name;case"MemberExpression":return o_(e.property,t);default:throw`VisitExpressionName does not support expression of type '${e.type}'`}}function oy(e,t){let n=oS(e.callee,t);if(n===ox||e.optional&&null==n)return ox;let o=e.arguments?.map(oj(t));if(n){if("function"!=typeof n)throw`${oP(e.callee)} is not a function`}else throw`No function named ${oP(e.callee)} is defined in this context`;return n(...o)}function ov(e,t){let n=oS(e.object,t);if(n===ox||e.optional&&null==n)return ox;if(null===n)throw TypeError(`TypeError: cannot read properties of null (reading '${oC(e.property,t)}')`);if(void 0===n)switch(e.object.type){case"Identifier":{let n=o_(e.object,t);throw ReferenceError(`ReferenceError: ${n} is not defined`)}case"MemberExpression":throw TypeError(`TypeError: cannot read properties of undefined (reading '${oC(e.property,t)}')`);default:throw`VisitMemberExpression does not support operator '${e.object.type}' type`}if("object"!=typeof n&&"function"!=typeof n&&"string"!=typeof n&&"number"!=typeof n)throw`VisitMemberExpression does not support member access on type ${typeof n}`;let o=e.computed?function(e){if(void 0===e)throw{type:"Illegal property access",message:"No property was supplied to the property access"};if("string"!=typeof e&&"number"!=typeof e)throw{type:"Illegal property access",message:`Cannot use a value of type ${null===e?"null":typeof e} as a property name`};return e}(ow(e.property,t)):function(e){if("Identifier"!==e.type)throw`VisitMemberExpression does not support a property of type '${e.type}'`;return e.name}(e.property);oN(o),function(e,t){if(oE.has(String(t)))return;let n=Object(e);for(;null!==n;){if(Object.hasOwn(n,t)){if(n===Object.prototype||n===Function.prototype)throw{type:"Illegal property access",message:`Cannot access the ${t} property of objects`};return}n=Object.getPrototypeOf(n)}}(n,o);let r=n[o];return"function"==typeof r?r.bind(n):r}function ob(e,t){let n={variables:{...e},globals:{...t},addVariables(e){return this.variables={...this.variables,...e},this}};return n.addVariables.bind(n),n}n4.A.plugins.register(n3.A),n4.A.plugins.register(n7.A),n4.A.plugins.register(n9.A),n4.A.plugins.register(oe.A),n4.A.plugins.register(ot.A),n4.A.plugins.register(on.A),n4.A.addBinaryOp("in",7),n4.A.addBinaryOp("??",1);let ox=Symbol("optional chain short-circuited");function oS(e,t){switch(e.type){case"MemberExpression":return ov(e,t);case"CallExpression":return oy(e,t);default:return ow(e,t)}}function ok(e){return e===ox?void 0:e}function oj(e){return function(t){return null===t?null:ow(t,e)}}function oN(e){if("__proto__"===e||"prototype"===e||"constructor"===e)throw{type:"Illegal property access",message:`Cannot access the ${e} property of objects`}}let oE=new Set(["toString","valueOf","hasOwnProperty"]);function oC(e,t){try{return o_(e,t)}catch{return"<computed>"}}function oP(e){return e?"MemberExpression"===e.type?e.property?.name:e.name:null}function oI(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:{...or},boundNames:new Set,variables:new Set};return oO("string"==typeof e?(0,n4.A)(e):e,t),[...t.variables]}function oO(e,t){switch(e.type){case"UnaryExpression":return n=e,o=t,void oO(n.argument,o);case"BinaryExpression":return r=e,i=t,void(oO(r.left,i),oO(r.right,i));case"ConditionalExpression":return s=e,a=t,void(oO(s.consequent,a),oO(s.test,a),oO(s.alternate,a));case"CallExpression":return l=e,c=t,void(oO(l.callee,c),l.arguments?.map(oA(c)));case"ArrowFunctionExpression":var n,o,r,i,s,a,l,c,u,d,m,p,f,g,h,w,_,y,v,b,x=e,S=t;let k=new Set(S.boundNames);for(let e of x.params??[])e?.type==="Identifier"&&k.add(e.name);oO(x.body,{...S,boundNames:k});return;case"MemberExpression":return u=e,d=t,void(oO(u.object,d),u.computed&&oO(u.property,d));case"ArrayExpression":return m=e,p=t,void m.elements?.map(oA(p));case"SequenceExpression":return f=e,g=t,void f.expressions?.map(oA(g));case"NewExpression":return h=e,w=t,void h.arguments?.map(oA(w));case"Literal":case"TemplateElement":return;case"Identifier":return _=e,y=t,void(_.name in y.globals||y.boundNames.has(_.name)||y.variables.add(_.name));case"TemplateLiteral":return v=e,b=t,void(v.expressions?.map(oA(b)),v.quasis?.map(oA(b)));default:throw`Expression evaluator does not support expression of type '${e.type}'`}}function oA(e){return function(t){return null===t?null:oO(t,e)}}let oR=M("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:",""),o=JSON.parse(localStorage.getItem(`openmrs:feature-flag-meta:${n}`)||"{}");e[n]={enabled:"true"===localStorage.getItem(t),...o}}return e}()});function o$(e,t,n){oR.setState(o=>({flags:{...o.flags,[e]:{enabled:o.flags[e]?.enabled??!1,label:t,description:n}}}))}function oT(){let e=oR.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 oM(e){return oR.getState().flags[e].enabled}function oL(e,t){oR.subscribe(n=>{t(n.flags[e].enabled)})}function oW(e,t){oR.setState(n=>({flags:{...n.flags,[e]:{...n.flags[e],enabled:t}}}))}oR.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 oD=n(1216);let oU=R("extensionsInternal",{slots:{},extensions:{}}),oB=R("extensionRenderings",{renderings:new Map}),oF=()=>M("extensionsInternal",{slots:{},extensions:{}}),oH=()=>M("extensionRenderings",{renderings:new Map});function oV(e){let t=oU.getState(),n=e(t);n!==t&&oU.setState(n)}let oG=null,oz=null;function oq(){let e=oB.getState();return oG&&e===oz||(oG=new Map(e.renderings),oz=e,function(e){for(let t of(o5.clear(),e.values()))o8(t,1);o6=!0}(oG)),oG}function oJ(e){oz={renderings:e},oB.setState(oz,!0)}function oK(e){let t=oq();t.has(e.renderingId)||(t.set(e.renderingId,e),o8(e,1),oJ(t))}function oX(e){let t=oq(),n=t.get(e);n&&(t.delete(e),o8(n,-1),oJ(t))}let oY=()=>M("extensions",{slots:{}}),oZ=0,oQ=new Set;function o0(e){oZ++;try{return e()}finally{if(0==--oZ&&oQ.size>0){let e=Array.from(oQ);for(let t of(oQ.clear(),e))o1(t)}}}function o1(e){try{e()}catch(t){console.error(`The extension system's '${e.name}' recomputation failed`,t)}}function o2(e){oZ>0?oQ.add(e):o1(e)}let o5=new Map,o6=!1;function o8(e,t){let n=JSON.stringify([e.slotName,e.extensionId,e.slotModuleName,e.extensionModuleName]),o=o5.get(n);if(!o){if(t<0)return;o5.set(n,{count:1,record:{slotModuleName:e.slotModuleName,extensionModuleName:e.extensionModuleName,slotName:e.slotName,extensionId:e.extensionId}}),o6=!0;return}o.count+=t,o.count<1&&(o5.delete(n),o6=!0)}function o4(){var e,t;if(oq(),!o6)return;o6=!1;let n=Array.from(o5.values(),({record:e})=>e);n.sort(o3),e=et.getState().mountedExtensions,t=n,e.length===t.length&&e.every((e,n)=>0===o3(e,t[n]))||et.setState({mountedExtensions:n})}function o3(e,t){return o7(e.slotName,t.slotName)||o7(e.extensionId,t.extensionId)||o7(e.slotModuleName,t.slotModuleName)||o7(e.extensionModuleName,t.extensionModuleName)}function o7(e,t){return e===t?0:e<t?-1:1}o4(),oB.subscribe(()=>o2(o4));let o9=oF(),re=oY(),rt=eo(),rn=es(),ro=new Set,rr=!1;function ri(e){if(null===e)ro=null;else if(null!==ro)for(let t of e)ro.add(t);o2(rs)}function rs(){if(!rr){rr=!0;try{for(let e=1;;e++){let t=ro;if(null!==t&&0===t.size)return;ro=new Set;try{!function(e,t,n,o,r,i=null){let s=re.getState().slots,a={},l=!1,c=Object.entries(o.flags).filter(([,{enabled:e}])=>e).map(([e])=>e);for(let[o,u]of Object.entries(e.slots)){let d=s[o];if(d&&i&&!i.has(o)){a[o]=d;continue}let{config:m}=ei(t,u.name),p=function(e,t,n,o,r,i){let s=function(e,t){let n=e.add||[],o=e.remove||[],r=e.order||[],{extensions:i}=o9.getState(),s=new Set(o),a=[...t,...n].filter(e=>!s.has(e)),l=rh(r),c=rh(t),u=new Map(a.map(e=>[e,function(e,t,n,o){let r=t.get(e);if(void 0!==r)return r;{if(void 0!==n)return 1e3+n;let t=o.get(e);return void 0!==t?2e3+t:3e3}}(e,l,i[rc(e)]?.order,c)]));return a.sort((e,t)=>u.get(e)-u.get(t))}(n,t.slots[e].attachedIds),a=[];for(let l of s){let{config:s}=ea(o,e,l),c=el(n,e,l),u=c?(0,oD.A)({},s,c):s,d=rc(l),m=t.extensions[d];if(m){let e=u?.["Display conditions"]?.privileges??m.privileges??[];if(e&&("string"==typeof e||Array.isArray(e)&&e.length>0)&&(!i?.user||!tU(e,i.user))||m.featureFlag&&!r.includes(m.featureFlag))continue;a.push({id:l,name:d,moduleName:m.moduleName,config:u,featureFlag:m.featureFlag,meta:m.meta,displayConditionExpression:u?.["Display conditions"]?.expression||m.displayExpression})}}return a}(o,e,m,n,c,r.session);d&&d.moduleName===u.moduleName&&(0,F.A)(d.candidateExtensions,p)?a[o]=d:(a[o]={moduleName:u.moduleName,candidateExtensions:p},l=!0)}(l||Object.keys(s).length!==Object.keys(a).length)&&re.setState({slots:a})}(o9.getState(),rt.getState(),rn.getState(),oR.getState(),tO.getState(),t)}catch(e){throw ro=null===t||null===ro?null:new Set([...t,...ro]),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{rr=!1}}}function ra(e,t){let n=new Set;for(let o of Object.keys(e))e[o]!==t[o]&&n.add(o);for(let o of Object.keys(t))o in e||n.add(o);return n}function rl(e,t){return{moduleName:t,name:e,attachedIds:[]}}function rc(e){let[t]=e.split("#");return t}function ru(e,t){let n=rc(t);return e.extensions[n]}function rd(e){return ru(o9.getState(),e)}o9.subscribe((e,t)=>{ri(e.extensions!==t.extensions?null:ra(e.slots,t.slots))}),rt.subscribe((e,t)=>{ri(ra(e.slots,t.slots))}),rn.subscribe((e,t)=>{ri(ra(e.configs,t.configs))}),oR.subscribe(()=>ri(null)),tO.subscribe(()=>ri(null)),ri(null);let rm=e=>oV(t=>({...t,extensions:{...t.extensions,[e.name]:{...e}}}));function rp(e,t){oV(n=>{let o=n.slots[e];return o?{...n,slots:{...n.slots,[e]:{...o,attachedIds:[...o.attachedIds,t]}}}:{...n,slots:{...n.slots,[e]:{...rl(e),attachedIds:[t]}}}})}function rf(e,t){oV(n=>{let o=n.slots[e];return o&&o.attachedIds.includes(t)?{...n,slots:{...n.slots,[e]:{...o,attachedIds:o.attachedIds.filter(e=>e!==t)}}}:n})}function rg(e){oV(t=>{let n=t.slots[e];return n?{...t,slots:{...t.slots,[e]:{...n,attachedIds:[]}}}:t})}function rh(e){let t=new Map;return e.forEach((e,n)=>{t.has(e)||t.set(e,n)}),t}function rw(e,t){return function(e,t,n=null,o){let r;return e.filter(e=>{let i=e.displayConditionExpression;if("string"!=typeof i||0===i.trim().length)return!0;r??(r=t&&"object"==typeof t?{session:n,...t}:{session:n});try{return!!oa(i,r)}catch(t){return console.error(`Error while evaluating expression '${i}' for ${e.id}`+(o?` in ${o}`:""),t),!1}})}(r_(e),t,tO.getState().session,e)}function r_(e){return re.getState().slots[e]?.candidateExtensions??[]}let ry=(e,t)=>o9.setState(n=>{let o=n.slots[t]?.moduleName;if(o&&o!=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 ${o}.`),n;if(o&&o==e)return n;if(n.slots[t])return{...n,slots:{...n.slots,[t]:{...n.slots[t],moduleName:e}}};let r=rl(t,e);return{...n,slots:{...n.slots,[t]:{...r}}}}),rv=()=>{ro=null,oV(()=>({slots:{},extensions:{}})),oH().setState({renderings:new Map}),re.setState({slots:{}})},rb=R("left-nav",{slotName:null,basePath:window.spaBase,mode:"normal"});function rx({name:e,basePath:t,mode:n,componentContext:o,state:r}){rb.setState({slotName:e,basePath:t,mode:n??"normal",componentContext:o,state:r})}function rS(e){rb.getState().slotName===e&&rb.setState(rb.getInitialState(),!0)}let rk=R("modalRegistry",{modals:{}});function rj(e){rk.setState(t=>(t.modals[e.name]=e,t))}function rN(e){let t=rk.getState().modals[e];if(!t){let n=rd(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.`),rj(t))}return t}let rE=R("workspace2",{registeredGroupsByName:{},registeredWindowsByName:{},registeredWorkspacesByName:{},openedGroup:null,openedWindows:[],isMostRecentlyOpenedWindowHidden:!1});function rC(e){let{registeredWorkspacesByName:t,registeredWindowsByName:n}=rE.getState(),o=t[e];if(o){let t=n[o.window];if(t)return t;throw Error(`No workspace window found with name: ${o.window} for workspace: ${e}`)}throw Error(`No workspace found with name: ${e}`)}function rP(e){let{registeredGroupsByName:t,registeredWindowsByName:n}=rE.getState(),o=n[e];if(o){let n=t[o.group];if(n)return n;throw Error(`No workspace group found with name: ${o.group} for window: ${e}`)}throw Error(`No workspace window found with name: ${e}`)}function rI(e){let{openedWindows:t}=rE.getState();return t.findIndex(t=>t.openedWorkspaces.find(t=>t.workspaceName===e))}function rO(e,t){if(0==t.length)return;let{registeredGroupsByName:n}=rE.getState(),o={...n};for(let n of t){if(o[n.name])throw Error(`Cannot register workspace group ${n.name} more than once`);o[n.name]={...n,moduleName:e}}rE.setState({registeredGroupsByName:o})}function rA(e,t){if(0==t.length)return;let{registeredWindowsByName:n}=rE.getState(),o={...n};for(let n of t){if(o[n.name])throw Error(`Cannot register workspace window ${n.name} more than once`);let t={...n,moduleName:e};o[n.name]=t}rE.setState({registeredWindowsByName:o})}function rR(e,t){if(0==t.length)return;let{registeredWorkspacesByName:n}=rE.getState(),o={...n};for(let n of t){if(o[n.name])throw Error(`Cannot register workspace ${n.name} more than once`);let t={...n,moduleName:e};o[n.name]=t}rE.setState({registeredWorkspacesByName:o})}let r$=0,rT=null,rM={bootstrap:15e3,mount:15e3,unmount:15e3};function rL(e,t){if(e.timeouts)return e;let n=e.name??"parcel",o=Object.fromEntries(Object.keys(rM).filter(t=>e[t]).map(o=>{var r,i;let s,a;return[o,(r=e[o],i=rM[o],s=Array.isArray(r)?r:[r],a=e=>s.reduce((t,r,i)=>t.then(()=>{let t=r(e);return"function"==typeof t?.then&&"function"==typeof t?.catch?t:Promise.reject(Error(`Lifecycle function ${o} at array index ${i} for parcel ${n} did not return a promise`))}),Promise.resolve(void 0)),e=>{let r,s=new Promise((e,t)=>{r=setTimeout(()=>t(Error(`Lifecycle function ${o} for parcel ${n} did not settle within ${i}ms`)),i)});return Promise.race([a(e),s]).finally(()=>clearTimeout(r)).then(e=>(t(o,!1),e),e=>{throw t(o,!0),e})})]}));return{...e,...o}}async function rW(e,t){var n,o;let r,i,s,a,l,c=await (rT??(rT=new Promise((e,t)=>{(0,ta.xL)({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),ta.xL))),rT),u={...t},d=(r=u,i=!1,{retarget:e=>r={...e},release:s=()=>(function(e){for(let t of Object.keys(e))delete e[t]})(r),onSettled(e,t){switch(e){case"bootstrap":t&&s();return;case"mount":i||(i=t);return;case"unmount":(t||i)&&s();return}}});return o=c((n=d.onSettled,"function"==typeof e?()=>e().then(e=>rL(e,n)):rL(e,n)),u),a=e=>t=>e.call(o,d.retarget(t)).catch(e=>{throw"SKIP_BECAUSE_BROKEN"===o.getStatus()&&d.release(),e}),l=o.update&&a(o.update),Object.defineProperty(o,"update",{configurable:!0,enumerable:!0,get:()=>l,set:e=>{l=e&&a(e)}})}function rD(){return rU}function rU(e,t){let n,o=rW(e,t).then(e=>n=e);return{mount:()=>o.then(e=>e.mount()),unmount:()=>o.then(e=>e.unmount()),update:e=>o.then(t=>t.update?.(e)),getStatus:()=>n?.getStatus()??"LOADING_SOURCE_CODE",get loadPromise(){return o.then(e=>e.loadPromise)},get bootstrapPromise(){return o.then(e=>e.bootstrapPromise)},get mountPromise(){return o.then(e=>e.mountPromise)},get unmountPromise(){return o.then(e=>e.unmountPromise)}}}async function rB(e,t,n,o,r=e=>e,i={}){let s=rc(o),a=rd(o),l=null;if(e){let c;if(!a)throw Error(`Couldn't find extension '${s}' to attach to '${t}'`);let{meta:u,moduleName:d,load:m}=a,p=r$++,f=`${t}/${o}-${p}`;e.dataset.extensionRenderingId=f;let g=e=>{try{oX(f)}catch(t){console.error(e,t)}};try{oK({renderingId:f,extensionName:s,extensionModuleName:d,extensionId:o,slotName:t,slotModuleName:n})}catch(e){throw g(`Recomputing configuration after registering '${o}' failed also failed`),e}try{c=await m()}catch(e){throw g(`Recomputing configuration after '${o}' failed to load also failed`),e}try{l=await rW(r({...c,name:`${t}/${s}-${p}`}),{...i,_meta:u,_extensionContext:{extensionId:o,extensionSlotName:t,extensionSlotModuleName:n,extensionModuleName:d,extensionMeta:u},domElement:e})}catch(e){throw g(`Recomputing configuration after '${o}' failed to mount also failed`),e}l.mountPromise.then(void 0,e=>{console.error(`Extension '${o}' in slot '${t}' failed to mount`,e),g(`Recomputing configuration after '${o}' failed to mount also failed`)}),l.unmountPromise.then(()=>g(`Recomputing configuration after unmounting '${o}' failed`),e=>{console.error(`Extension '${o}' in slot '${t}' failed to unmount`,e),g(`Recomputing configuration after '${o}' failed to unmount also failed`)})}else console.warn(`Tried to render ${o} into ${t} but no DOM element was available.`);return l}var rF=n(6925),rH=n.n(rF);let rV=(0,rF.createContext)({moduleName:"",featureName:""});function rG({to:e,templateParams:t,onBeforeNavigate:n,children:o,...r}){return(0,rF.useEffect)(()=>{r.href&&console.warn(`ConfigurableLink does not support the href prop. Use the 'to' prop instead. The provided href value is '${r.href}'`),r.onClick&&console.warn(`ConfigurableLink does not support the onClick prop. Use the 'onBeforeNavigate' prop instead. The 'to' prop of the offending link is ${e}`)},[]),rH().createElement("a",{onClick:o=>{0===o.button&&!o.ctrlKey&&!o.shiftKey&&!o.altKey&&!o.metaKey&&(o.preventDefault(),n?.(o),tg({to:e,templateParams:t})),0===o.button&&(o.ctrlKey||o.metaKey)&&n?.(o),0===o.button&&o.shiftKey&&n?.(o),1===o.button&&n?.(o)},href:tp(e,t),...r},o)}let rz=({state:e,children:t,...n})=>{let{extension:o}=(0,rF.useContext)(rV),r=(0,rF.useRef)(null),i=(0,rF.useRef)(Promise.resolve()),s=(0,rF.useRef)(!1),a=(0,rF.useRef)(!1),l=(0,rF.useRef)(e),c=(0,rF.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,rF.useCallback)((e,t)=>{e.update&&"UNMOUNTING"!==e.getStatus()&&(i.current=Promise.all([e.mountPromise,i.current]).then(()=>{if(r.current?.getStatus()==="MOUNTED"&&r.current.update)return r.current.update({...t})}).catch(e=>{let t=r.current?.getStatus();"UNMOUNTING"!==t&&"NOT_MOUNTED"!==t&&"UNLOADING"!==t&&console.error(`The extension '${o?.extensionId}' failed to update`,e)}))},[]),d=(0,rF.useCallback)(t=>{t&&!r.current&&!a.current&&o?.extensionSlotName&&o.extensionSlotModuleName&&(a.current=!0,rB(t,o.extensionSlotName,o.extensionSlotModuleName,o.extensionId,void 0,e).then(t=>{(a.current=!1,r.current=t,s.current)?c(t):t&&l.current!==e&&u(t,l.current)},()=>{a.current=!1}))},[]);return(0,rF.useEffect)(()=>(s.current=!1,()=>{s.current=!0,c(r.current)}),[]),(0,rF.useEffect)(()=>{l.current=e,r.current&&u(r.current,e)},[e]),o?rH().createElement("div",{ref:d,"data-extension-id":o?.extensionId,style:{position:"relative"},...n}):null};function rq(e){let t=(0,rF.useRef)(e);return x(t.current,e)||(t.current=e),t.current}function rJ(e,t){"function"==typeof t&&(t=t(e));let n={};for(let[o,r]of Object.entries(t)){let t=function(...t){e.setState(e=>r(e,...t))};n[o]=t}return n}let rK=e=>e;function rX(e,t=rK,n){let o=(0,rF.useCallback)(t=>e.subscribe(t),[e]),r=(0,rF.useCallback)(()=>t(e.getState()),[e,t]),i=(0,rF.useSyncExternalStore)(o,r,r),s=(0,rF.useMemo)(()=>n?rJ(e,n):null,[e,n]);return(0,rF.useMemo)(()=>s?{...i,...s}:i,[i,s])}function rY(e,t){return rX(e,rK,t)}function rZ(e){return function(t){let n=(0,rF.useCallback)(t=>e.subscribe(t),[]),o=(0,rF.useCallback)(()=>e.getState(),[]),r=(0,rF.useSyncExternalStore)(n,o,o),i=(0,rF.useMemo)(()=>t?rJ(e,t):null,[t]);return(0,rF.useMemo)(()=>i?{...r,...i}:r,[r,i])}}let rQ=[];Object.freeze(rQ);let r0={candidateExtensions:rQ};Object.freeze(r0);let r1=e=>{let t=(0,rF.useCallback)(t=>t.slots?.[e]??r0,[e]);return rX(oY(),t)},r2=e=>e.session;function r5(e,t){let{candidateExtensions:n}=r1(e),o=rX(tO,r2),r=rq(t);return(0,rF.useMemo)(()=>rw(e,r),[e,r,o,n])}function r6(e,t){let{moduleName:n}=(0,rF.useContext)(rV);if(!n)throw Error("ComponentContext has not been provided. This should come from @openmrs/esm-react-utils.");return(0,rF.useEffect)(()=>{ry(n,e)},[n,e]),{extensions:r5(e,t),extensionSlotName:e,extensionSlotModuleName:n}}function r8(e){return e}function r4({name:e,extensionSlotName:t,select:n=r8,children:o,state:r,style:i,...s}){if(o&&r)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 a=e??t,l=(0,rF.useRef)(null),{extensions:c,extensionSlotModuleName:u}=r6(a,r),d=(0,rF.useMemo)(()=>n(c),[n,c]),m=(0,rF.useMemo)(()=>{if("function"==typeof o&&!rH().isValidElement(o))return d.map(e=>o(e,r))},[o,d]);return rH().createElement("div",{ref:l,"data-extension-slot-name":a,"data-extension-slot-module-name":u,style:{...i,position:"relative"},...s},a&&d?.map((e,t)=>rH().createElement(rV.Provider,{key:e.id,value:{moduleName:u,featureName:"",extension:{extensionId:e.id,extensionSlotName:a,extensionSlotModuleName:u,extensionMeta:e.meta}}},m?.[t]??("function"!=typeof o?o:null)??rH().createElement(rz,{state:r}))))}var r3=n(3776),r7=n(9568),r9=n(9737),ie=n(749),it=n.n(ie),io=n(5254);let ir={strictMode:!0,throwErrorsToConsole:!0,disableTranslations:!1},ii=new Map;(0,io.initCache)(ii);let is={errorRetryCount:3,fetcher:tP,focusThrottleInterval:18e5,revalidateIfStale:!0,revalidateOnFocus:!1,revalidateOnReconnect:!1,refreshInterval:0,shouldRetryOnError:e=>{if(e instanceof tI){let t=e.response.status;return!!(t>=500)||401===t||403===t||429===t}return!0},provider:()=>ii};function ia(e){if("object"!=typeof e||"string"!=typeof e.featureName||"string"!=typeof e.moduleName)throw Error("Invalid options");let t=Object.assign({},ir,e),n={...is,...t.swrConfig};return function(e){var o,r,i,s,a;return i=r=class extends(o=rH().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 rH().createElement("div",null,"An error has occurred. Please try reloading the page.");{let o=rH().createElement(rF.Suspense,{fallback:null},rH().createElement(ie.SWRConfig,{value:n},rH().createElement(rV.Provider,{value:this.state.config},t.disableTranslations?rH().createElement(e,this.props):rH().createElement(r9.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},rH().createElement(e,this.props)))));return t.strictMode&&rH().StrictMode?rH().createElement(rH().StrictMode,null,o):o}}constructor(e){super(e),this.state={caughtError:null,caughtErrorInfo:null,config:{moduleName:t.moduleName,featureName:t.featureName,extension:e._extensionContext}}}},s="displayName",a=`OpenmrsReactComponent(${t.featureName})`,s in i?Object.defineProperty(i,s,{value:a,enumerable:!0,configurable:!0,writable:!0}):i[s]=a,r}}function il(e,t){return(0,r7.A)({React:rH(),ReactDOMClient:r3,rootComponent:ia(t)(e)})}function ic(e,t){return()=>e().then(({default:e})=>il(e,t))}function iu(e,t){return()=>Promise.resolve(il(e,t))}let id=ic,im=(0,E.y)()(()=>({}));T("openmrs-app-context",im);let ip={};function ig(e,t=e=>e){let n=im.getState();return e in n?Object.freeze(Object.assign({},t?t(n[e]):n[e])):null}function ih(e,t){im.setState(n=>(e in n||(n[e]={}),n[e]=t(n[e]),Object.assign({},n)))}function iw(e){return null===e?null:Object.freeze(Object.assign({},e))}let i_=new Map;function iy(e,t){let n=(0,rF.useRef)(t??{}),o=(0,rF.useRef)(t=>ih(e,t)),r=(0,rF.useRef)(Symbol());return(0,rF.useEffect)(()=>{let n=t??{},o=r.current;return null===ig(e)?!function(e,t=ip){im.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===ip?{}: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.`),ih(e,()=>n)),i_.set(e,o),()=>{i_.get(e)===o&&(im.setState(t=>(e in t&&delete t[e],t)),i_.delete(e))}},[e]),(0,rF.useEffect)(()=>{let o=t??{};x(n.current,o)||(ih(e,()=>o),n.current=o)},[t]),o.current}function iv({namespace:e,value:t}){return iy(e,t),null}let ib=({children:e,value:t,fallback:n})=>t?rH().createElement(rH().Fragment,null,e):n?rH().createElement(rH().Fragment,null,n):null;function ix(){let e=(0,rF.useRef)();return(!e.current||e.current.signal.aborted)&&(e.current=new AbortController),(0,rF.useEffect)(()=>{let t=e.current;return()=>t?.abort()},[]),e.current}function iS(e,t=e=>e??{}){let[n,o]=(0,rF.useState)(()=>{if(ik(e))return;let n=ig(e);if(null!==n)return t?t(n):n});return(0,rF.useEffect)(()=>{if(ik(e))throw Error(`The namespace supplied to useAppContext must be a non-empty string, but was "${e}".`)},[e]),(0,rF.useEffect)(()=>{var n;let r;return(n=e=>{if(null==e)return void o(void 0);let n=t?t(e):e;o(e=>x(e,n)?e:n)})(iw(r=ig(e))),im.subscribe(t=>{let o=e in t?t[e]:null;o!==r&&(r=o,n(iw(o)))})},[e,t]),n}function ik(e){return"string"!=typeof e||0===e.trim().length}function ij(e){let t=r5(e);return(0,rF.useMemo)(()=>t.map(e=>e.id),[t])}function iN(e){return r1(e).candidateExtensions}function iE(e,t,n){let{data:o,error:r,mutate:i,isLoading:s,isValidating:a}=it()(e?nU(e,t,n):null,tP);return(0,rF.useMemo)(()=>({isLoading:s,data:o?.data.results??[],error:r,mutate:i,isValidating:a}),[o,r,s,a,i])}function iC(e){(0,rF.useEffect)(()=>{if(e){let e=window.getComputedStyle(document.body).overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=e}}},[e])}let iP={},iI=`No ComponentContext has been provided. This should come from "openmrsComponentDecorator".
16
16
  Usually this is already applied when using "getAsyncLifecycle" or "getSyncLifecycle".`;function iO(e,t,n){let o=iP[e];if(o)return o;let r=new Promise(e=>{let o=n(t.getState());if(o)return void e(o);let r=t.subscribe(t=>{let o=n(t);o&&(r(),e(o))})});return iP[e]=r,r.then(()=>{iP[e]===r&&delete iP[e]}),r}function iA(e){let{moduleName:t,extension:n}=(0,rF.useContext)(rV),o=e?.externalModuleName??t;if(!o&&!n)throw Error(iI);let r=function(e){let t=(0,rF.useMemo)(()=>en(e),[e]),n=function(e){let[t,n]=(0,rF.useState)(()=>{let t=e.getState();return t.loaded&&t.config?t.config:null});return(0,rF.useEffect)(()=>e?.subscribe(e=>{e.loaded&&e.config&&n(e.config)}),[e]),t}(t);if(!n)throw iO(e,t,e=>e.loaded?e.config:null);return n}(o),i=function(e){let t=(0,rF.useMemo)(es,[]),n=function(e,t){let[n,o]=(0,rF.useState)(t?()=>{let n=ea(e.getState(),t.extensionSlotName,t.extensionId);if(n.loaded&&n.config)return n.config}:null);return(0,rF.useEffect)(()=>{if(t)return e.subscribe(e=>{let r=ea(e,t.extensionSlotName,t.extensionId);r.loaded&&r.config&&!(0,F.A)(r.config,n)&&o(r.config)})},[e,t,n]),n}(t,e);if(!n&&e)throw iO(`${e.extensionSlotName}-${e.extensionId}`,t,t=>{let n=ea(t,e.extensionSlotName,e.extensionId);return n.loaded?n.config:null});return n||{}}(n);return(0,rF.useMemo)(()=>e?.externalModuleName&&o===e.externalModuleName?{...r}:{...r,...i},[o,e?.externalModuleName,r,i])}let iR=r5;function i$(e,t=300){let[n,o]=(0,rF.useState)(e);return(0,rF.useEffect)(()=>{let n=setTimeout(()=>{o(e)},t);return()=>{clearTimeout(n)}},[e,t]),n}var iT=n(8086),iM=n.n(iT);let iL=`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 iW(){let e=`${tj}/emrapi/configuration?v=${iL}`,t=iM()(e,tP);return(0,rF.useMemo)(()=>({emrConfiguration:t.data?.data,isLoadingEmrConfiguration:t.isLoading,mutateEmrConfiguration:t.mutate,errorFetchingEmrConfiguration:t.error}),[t])}function iD(){return(0,rF.useContext)(rV).extension}let iU=rZ(oF());function iB(e){let t=r5(e);return(0,rF.useMemo)(()=>Object.fromEntries(t.map(e=>[e.name,e.meta])),[t])}let iF=rZ(oY());function iH(e){let{flags:t}=rX(oR);return t[e]?.enabled??!1}function iV(){let[,e]=(0,rF.useState)(0);return(0,rF.useCallback)(()=>{e(e=>e+1)},[])}function iG(e,t,n={}){return iq(e,t,iz,n)}let iz={getPaginatedUrl:(e,t,n)=>{if(!e)return null;{let o=new URL(tC(e.toString()),window.location.toString());return o.searchParams.set("limit",""+t),o.searchParams.set("startIndex",""+n),o.searchParams.set("totalCount","true"),o.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 iq(e,t,n,o={}){let{getPaginatedUrl:r,getTotalCount:i,getCurrentPageSize:s,getData:a}=n,{immutable:l,swrConfig:c}=o,u=o.fetcher??tP,[d,m]=(0,rF.useState)(1),p=(0,rF.useRef)(NaN),f=(0,rF.useRef)(NaN),g=(0,rF.useRef)(d),h=(0,rF.useRef)(!1),w=(0,rF.useRef)(!1),_=e?.toString()??"",[y,v]=(0,rF.useState)(_);_!==y&&(v(_),m(1),g.current=1,p.current=NaN,f.current=NaN,h.current=!1,w.current=!1);let b=(d-1)*t,x=(0,rF.useMemo)(()=>r(e,t,b),[e,t,b]),{data:S,...k}=(l?iM():it())(x,u,c);S?.data&&(p.current=i(S?.data),f.current=s(S?.data),h.current=!0);let j=Math.ceil(p.current/t),N=(0,rF.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,rF.useEffect)(()=>{if(!h.current)return;if(Number.isNaN(p.current)){w.current||(w.current=!0,console.warn(`useServerPagination: ${_} 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,_,S]);let E=(0,rF.useCallback)(()=>{N(g.current+1)},[N]),C=(0,rF.useCallback)(()=>{N(g.current-1)},[N]);return{data:a(S?.data),totalPages:j,totalCount:p.current,currentPage:d,currentPageSize:f.current,paginated:j>1,showNextButton:d<j,showPreviousButton:d>1,goTo:N,goToNext:E,goToPrevious:C,...k}}function iJ(e,t,n={}){return iq(e,t,iK(),n)}function iK(){return{getPaginatedUrl:(e,t,n)=>{if(!e)return null;{let o=new URL(tC(e.toString()),window.location.toString());return o.searchParams.set("_count",""+t),o.searchParams.set("_getpagesoffset",""+n),o.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 iX=n(2216),iY=n.n(iX);function iZ(e,t={}){return iQ(e,iz,t)}function iQ(e,t,n={}){let{swrInfiniteConfig:o,immutable:r}=n,{getNextUrl:i,getTotalCount:s,getData:a}=t,l=n.fetcher??tP,c=(0,rF.useCallback)((n,o)=>0==n?e?.toString()??null:t.getNextUrl(o.data),[e]),{data:u,size:d,setSize:m,...p}=iY()(c,l,{...o,...r?{revalidateIfStale:!1,revalidateOnFocus:!1,revalidateOnReconnect:!1}:{}}),f=i(u?.[u.length-1].data),g=s(u?.[0]?.data);return{data:u?.flatMap(e=>a(e.data)),totalCount:g,hasMore:null!=f,loadMore:()=>{m((u?.length??0)+1)},nextUri:f,...p}}function i0(e,t={}){return i1(e,iz,t)}function i1(e,t,n={}){let o=iQ(e,t,n),{hasMore:r,error:i,data:s,loadMore:a,isLoading:l,nextUri:c}=o;return((0,rF.useEffect)(()=>{r&&!i&&a()},[r,c]),n.partialData)?o:{...o,data:r||i?void 0:s,isLoading:l||r}}function i2(e,t={}){return i1(e,iK(),t)}function i5(e,t={}){return iQ(e,iK(),t)}function i6(){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 i8(){let[e,t]=(0,rF.useState)(i6);return(0,rF.useEffect)(()=>{let e=()=>{t(i6())};return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),e}let i4=e=>"small-desktop"===e||"large-desktop"===e;function i3(e){let t=(0,rF.useContext)(rV);(0,rF.useEffect)(()=>(t&&t.moduleName&&(e.componentContext=t),rx(e),()=>{rS(e.name)}),[t,e])}function i7(){return rX(rb)}let i9=[];function se(e=null,t=null){let n=new URLSearchParams;e&&n.set("tag",e),t&&n.set("q",t);let o=n.toString(),{data:r}=i0(`${tj}/location${o?"?"+o:""}`,{immutable:!0});return r??i9}function st(e,t=!0){let n=(0,rF.useRef)(null);return(0,rF.useEffect)(()=>{let o=o=>{t&&n.current&&o.target&&o.target instanceof Node&&(n.current.contains(o.target)||e(o))};return window.addEventListener("mousedown",o),window.addEventListener("touchstart",o),()=>{window.removeEventListener("mousedown",o),window.removeEventListener("touchstart",o)}},[e,t]),n}function sn(e){let t=(0,rF.useRef)();return(0,rF.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 so(e,t={}){let{abortController:n,fetchInit:o,url:r,swrConfig:i}=t,s=ix(),a=(0,rF.useMemo)(()=>o?.signal??n?.signal??s.signal,[n?.signal,o?.signal,s.signal]),l=(0,rF.useCallback)(e=>tP(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,r),{...o,signal:a}),[a,o,r]);return it()(e,l,i)}function sr(e=[],t=10){let[n,o]=(0,rF.useState)(1),r=(0,rF.useMemo)(()=>"number"==typeof t&&t>0?Math.max(1,Math.ceil(e.length/t)):1,[e.length,t]);n>r&&o(r);let i=Math.min(Math.max(1,n),r),s=(0,rF.useMemo)(()=>{let n=(i-1)*t,o=(i+0)*t;return e.slice(n,o)},[e,i,t]),a=(0,rF.useCallback)(e=>{!Number.isInteger(e)||e<1?console.warn(`usePagination: ignoring goTo(${e}); page must be a positive integer.`):o(e)},[]),l=(0,rF.useCallback)(()=>{o(e=>e+1)},[]),c=(0,rF.useCallback)(()=>{o(e=>Math.max(1,e-1))},[]);return(0,rF.useMemo)(()=>({results:s,totalPages:r,currentPage:i,paginated:e.length>t,showNextButton:i<r,showPreviousButton:i>1,goTo:a,goToNext:l,goToPrevious:c}),[s,r,e.length,t,i,a,l,c])}function si(e,t,n,o){return{pageSizes:(0,rF.useMemo)(()=>{let n=Math.ceil(t/e);return isNaN(n)&&(n=0),[...Array(n).keys()].map(t=>(t+1)*e)},[e,t]),pageItemsCount:(0,rF.useMemo)(()=>e>t?t:e*n>t?e*(n-1)+o:e*n,[e,t,n,o])}}function ss(){let e=/\/patient\/([a-zA-Z0-9\-]+)\/?/.exec(location.pathname);return e&&e[1]}function sa(e){let[t,n]=(0,rF.useState)(e??ss()),{data:o,error:r,isValidating:i}=it()(t?["patient",t]:null,()=>nH(t,{}));return(0,rF.useEffect)(()=>{let e=()=>{let e=ss();e!==t&&n(e)};return window.addEventListener("single-spa:routing-event",e),()=>window.removeEventListener("single-spa:routing-event",e)},[t]),(0,rF.useMemo)(()=>({isLoading:i&&!r&&!o,patient:o,patientUuid:t,error:r}),[i,r,o,t])}function sl(){let e=`${tj}/metadatamapping/termmapping?v=custom:(metadataUuid)&code=emr.primaryIdentifierType`,{data:t,error:n,isLoading:o}=it()(e,tP);return(0,rF.useMemo)(()=>({primaryIdentifierCode:t?.data?.results[0]?.metadataUuid,isLoading:o,error:n}),[t,n,o])}function sc(e){let{extensions:t,extensionSlotModuleName:n}=r6(e);return e?t.map(t=>({state:o})=>rH().createElement(rV.Provider,{value:{moduleName:n,featureName:"",extension:{extensionId:t.id,extensionSlotName:e,extensionSlotModuleName:n,extensionMeta:t.meta}}},rH().createElement(rz,{state:o}))):[]}function su(){let e=(0,rF.useRef)(),[t,n]=(0,rF.useState)(null),o=null;if(!t){if(i){let e=tM().getState();e.loaded&&(o=e.session)}else i=new Promise(t=>{let n=({loaded:n,session:r})=>{n&&(t(r),o=r,e.current&&(e.current(),e.current=void 0))};n(tM().getState()),o||(e.current=tM().subscribe(n))});if(o)n(o);else throw i}(0,rF.useEffect)(()=>(e.current||(e.current=tM().subscribe(({loaded:e,session:t})=>{e&&(o=t,n(t))})),()=>{e.current&&(e.current(),e.current=void 0)}),[]);let r=t||o;if(!r)if(i)throw console.warn("useSession is in an unexpected state. Attempting to recover."),i;else throw Error("useSession is in an invalid state.");return r}let sd=({privilege:e,fallback:t,children:n})=>{let[o,r]=(0,rF.useState)(null);return((0,rF.useEffect)(()=>{let e=tM(),t=e.subscribe(({loaded:e,session:t})=>{r(e?t?.user??null:null)}),{loaded:n,session:o}=e.getState();return n&&r(o?.user??null),t},[]),o&&tU(e,o))?rH().createElement(rH().Fragment,null,n):t?rH().createElement(rH().Fragment,null,t):null};var sm=n(4343),sp=n.n(sm),sf=n(3355);let sg=new Map;function sh(){for(let e of Array.from(sg.values()))e()}let sw={setVisitContext:(e,t)=>null==t?{manuallySetVisitUuid:null}:{manuallySetVisitUuid:t.uuid,patientUuid:t.patient?.uuid}};function s_(e){let t=(0,rF.useId)();return(0,rF.useEffect)(()=>{if(e)return sg.set(t,e),()=>{sg.delete(t)}},[t,e]),{...rY(n1(),sw),mutateVisit:sh}}function sy(e,t=nQ){let n=(0,rF.useRef)(void 0),{patientUuid:o,manuallySetVisitUuid:r,setVisitContext:i}=s_((0,rF.useCallback)(()=>n.current?.(),[])),s=e&&o==e?r:null,a=`?patient=${e}&v=${t}&includeInactive=false`,l=`/${s}?v=${t}`,{data:c,error:u,mutate:d,isValidating:m}=it()(e?`${tj}/visit${a}`:null,tP),{data:p,error:f,mutate:g,isValidating:h}=it()(e&&s?`${tj}/visit${l}`:null,tP),w=(0,rF.useMemo)(()=>c?.data.results.find(e=>null===e.stopDatetime)??null,[c]),_=(0,rF.useMemo)(()=>s&&p?p.data:null,[p,s]),y=(0,rF.useRef)(null);(0,rF.useEffect)(()=>{!m&&w&&o===e&&null===r&&i(w),h||(y.current&&_&&y.current.uuid===_.uuid&&!y.current.stopDatetime&&_.stopDatetime&&i(null),y.current=_)},[_,r,w,m,h,o]);let v=(0,rF.useCallback)(()=>{d(),g()},[d,g]);(0,rF.useEffect)(()=>{n.current=v},[v]);let b=!!(!c||s&&!p),x=!!(s?f:u);return{error:u||f,mutate:v,isValidating:m||h,activeVisit:w,currentVisit:_,currentVisitIsRetrospective:!!s,isLoading:b&&!x}}sm.extend(sf);let sv=[];function sb(){let{data:e}=iM()(nK,nX);return e??sv}let sx=new Map;async function sS(e,t){let n=t.indexOf("#"),o=n>=0,r=o?t.substring(0,n):e,i=o?t.substring(n+1):t,s=await np(r);return s&&Object.hasOwn(s,i)&&"function"==typeof s[i]?sj(r,s).then(()=>s[i]()):(s?s&&Object.hasOwn(s,i)?console.warn(`The export ${t}, defined in ${e}'s routes.json, is not a function`):console.warn(`${r} does not define a component called "${i}", referenced in ${e}'s routes.json. This cannot be loaded.`):console.warn(`Unknown app ${r} for ${t} defined in ${e}'s routes.json`),sk)}let sk={bootstrap:()=>Promise.resolve(),mount:()=>Promise.resolve(),unmount:()=>Promise.resolve()};async function sj(e,t){if(e in sx)await sx[e];else{let n=t??await np(e);await (sx[e]=new Promise((t,o)=>{if(Object.hasOwn(n,"startupApp")){let r=n.startupApp;if("function"==typeof r)return Promise.resolve(r()).then(()=>{eO(e),t(null)}).catch(o)}eO(e),t(null)}))}}function sN(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