@openmrs/esm-help-menu-app 11.0.1-pre.5762 → 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.
- package/.turbo/turbo-build.log +1 -1
- package/dist/575.js +1 -1
- package/dist/575.js.map +1 -1
- package/dist/openmrs-esm-help-menu-app.js +2 -2
- package/dist/routes.json +1 -1
- package/package.json +3 -3
package/.turbo/turbo-build.log
CHANGED
package/dist/575.js
CHANGED
|
@@ -12,7 +12,7 @@ If you're the maintainer: the 'elements' key only works with '_type' equal to 'A
|
|
|
12
12
|
${t}`)}return r}let eX=(e,t)=>{let n=structuredClone(t);if(!e)return n;for(let t of Object.keys(e)){let r=n[t],o=e[t];if(o&&(o.hasOwnProperty("_type")||o.hasOwnProperty("_default"))){n.hasOwnProperty(t)||(n[t]=o._default);let e=o._elements;if(r&&eY(e)){if(o._type===G.Array&&Array.isArray(r)){let o=r.map(t=>eX(e,t));n[t]=o}else if(o._type===G.Object)for(let t of Object.keys(r))r[t]=eX(e,r[t])}}else if(eZ(o)){let e=r??{};eZ(e)&&(n[t]=eX(o,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,r=n.exec(e);for(;r;){if(!t.includes(r[1]))return!1;r=n.exec(e)}return!0},"Should be a URL or path. The allowed template parameters are "+t.map(e=>"${"+e+"}").join(", "))},e3=e8([]),e4=e=>z(t=>e.includes(t),`Must be one of the following: '${e.join("', '")}'.`),e7={inRange:e6,isUrl:e3,isUrlWithTemplateParameters:e8,oneOf:e4};var e9=n(4913);let te=R("breadcrumbs",[]);function tt(e){return tn([e])}function tn(e){let t=[...tr(),...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 tr(){return te.getState()}function to(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=to(e,n.join("/"));if(t)return t}}(e,t)}function ti(e,t){if(e.length>0){let n=to(e,t);if(n){let t=[n],r=to(e,n.settings.parent);for(;void 0!==r;)t.push(r),r=to(e,r.settings.parent);return t.reverse()}}return[]}function ta(e){return ti(tr(),e)}var ts=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,r){return tu.t(t,{ns:e,defaultValue:n,...r})}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(/\/$/,""),r=tf(e,{openmrsBase:window.openmrsBase,openmrsSpaBase:n,...t});return e.startsWith("//")?r:r.replace(/^\/\//,"/")}function tf(e,t){return Object.keys(t).reduce((e,n)=>e.split("${"+n+"}").join(t[n]),e)}function th({to:e,templateParams:t}){let n=window.getOpenmrsSpaBase().replace(/\/$/,""),r=tp(e,t).replace(window.location.origin,""),o=new URL(r,window.location.origin);if("http:"!=o.protocol&&"https:"!=o.protocol)throw console.error(`Received request to navigate to non-http URL: ${o.toString()}`),Error(tm("navigateNonHttp"));r.startsWith(n)?(0,ts.EH)(r):window.location.assign(r)}tu.on("initialized",function(){window.i18next.loadNamespaces(["core"])});let tg="openmrs:history";function tw(e){let t=JSON.parse(sessionStorage.getItem(tg)??"[]")||[];t.push(e),t.length>50&&(t=t.slice(-50)),sessionStorage.setItem(tg,JSON.stringify(t))}function t_(){0===JSON.parse(sessionStorage.getItem(tg)??"[]").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(tg,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(tg)??"[]")}function tv({toUrl:e}){let t=ty(),n=t.lastIndexOf(e);if(-1!=n){let e=t.slice(0,n+1);th({to:t[n]}),sessionStorage.setItem(tg,JSON.stringify(e))}else throw Error(`URL ${e} not found in history; cannot go back to it.`)}function tb(){sessionStorage.removeItem(tg)}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 r=!1;try{let e=new URL(n,window.location.href),t=new URL(tC(tj),window.location.href),o=e.pathname.replace(/\/{2,}/g,"/"),i=t.pathname.replace(/\/{2,}/g,"/");r=e.origin===t.origin&&(o===i||o.startsWith(`${i}/`))}catch{}if(r){let e=!1;for(let[n,r]of Object.entries(t.headers))"disable-www-authenticate"===n.toLowerCase()&&(void 0===r?delete t.headers[n]:e=!0);e||(t.headers["Disable-WWW-Authenticate"]="true")}if(e.startsWith(tN)){let e=new URL(n,window.location.toString());e.searchParams.has("_summary")||(e.searchParams.set("_summary","data"),n=e.toString())}let o=Error();return window.fetch(n,t).then(async e=>{let{redirectAuthFailure:r,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)&&th({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||r.enabled&&r.errors.includes(e.status))&&(tb(),th({to:r.url||e.headers.get("location")||tx}),!0!==t.rejectAuthFailure)?r.resolvePromise?Promise.resolve():new Promise(()=>{}):e.clone().text().then(t=>{let r=t;try{r=JSON.parse(t)}catch(e){}throw new tI(n,e,r,o)},()=>{throw new tI(n,e,null,o)})})}class tI extends Error{constructor(e,t,n,r){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`,r.message=this.message,this.responseBody=n,this.response=t,this.stack=`Stacktrace for outgoing request:
|
|
13
13
|
${r.stack}
|
|
14
14
|
Stacktrace for incoming response:
|
|
15
|
-
${this.stack}`}}let tA=R("session",{loaded:!1,session:null}),tO=0,tR=null;function t$(){return tR||(tA.getState().loaded&&tO>=Date.now()-6e4?null:tW())}function tT(e){let t=e?.includeAuthStatus??!0,n=e=>t?e:e.user,r=t$();return r?new Promise(e=>{let t=()=>{let t=tA.getState();t.loaded&&(o(),e(n(t.session)))},o=tA.subscribe(t);r.then(t,t)}):Promise.resolve(n(tA.getState().session))}function tM(){return t$(),tA}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){tO=Date.now(),o??(o=tO);let n={};e&&t&&(n.Authorization=`Basic ${window.btoa(`${e}:${t}`)}`);let r=tJ(tP(tE,{headers:n,rejectAuthFailure:!0})),i=()=>{tR===r&&(tR=null)};return r.then(i,i),tR=r,r}function tD(){tA.setState({loaded:!0,session:{authenticated:!1,sessionId:""}},!0)}function tU(e,t){var n,r;if(void 0===t)return!e;if(!e)return!0;return n=e,r=t,("string"==typeof n?!(0,D.A)(r.privileges.find(e=>n===e.display)):Array.isArray(n)?n.every(e=>!(0,D.A)(r.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 r=r=>{r.loaded&&r.session.user&&(e=r.session.user,n(r.session.user),t&&t())};r(tA.getState()),e||(t=tA.subscribe(r))})}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};tA.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 r,i;if(tK(e)){"object"==typeof(r=e.responseBody)&&null!==r&&!1===r.authenticated?tA.setState({loaded:!0,session:e.responseBody},!0):tD(),t(tA.getState());return}(i=e)instanceof tI&&502===i.response.status&&!tA.getState().loaded&&void 0!==o&&Date.now()-o<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 tA.getState().loaded||tA.setState({loaded:!1,session:null,error:e instanceof Error?e:Error(String(e)),initializing:t},!0),tA.getState()}function tY(){return"development"===window.spaEnv||"true"===localStorage.getItem("openmrs:devtools")}tA.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 t3(){return t8??(t8=t4().then(({map:e,complete:t})=>(t||(t8=null),e))),t8}async function t4(){let e=document.querySelectorAll('script[type="systemjs-importmap"]'),t=[],n=!0;for(let r=0;r<e.length;r++){let o=e[r];try{if(o.src){let e=await fetch(o.src);if(!e.ok)throw Error(`Request for ${o.src} returned ${e.status} ${e.statusText}`);t.push(await e.json())}else o.textContent&&t.push(JSON.parse(o.textContent))}catch(e){n=!1,console.warn(`[import-maps] Failed to parse import map from script tag at index ${r}`,e)}}return{map: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=no();for(let n=0;n<localStorage.length;n++){let r=localStorage.key(n);if(r?.startsWith(t0)){let n=r.slice(t0.length);if(!t.includes(n)){let t=localStorage.getItem(r);t&&(e[n]=t)}}}}catch(e){console.warn("[import-maps] Failed to read import-map overrides from localStorage",e)}return{imports:e}}async function ne(){let e=await t3();return t5?t7([e,t6??t9()]):e}async function nt(){return t3()}async function nn(){return t5?t7([await t3(),t9()]):t3()}function nr(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 no(){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&&no().includes(e)}function na(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 ns(e){if(!t5)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{localStorage.removeItem(t0+e);let t=no().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=no().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",r){var o;let i,a=!r?.maxLoadingTime||r.maxLoadingTime<=0?6e5:r.maxLoadingTime;await Promise.race([nf(e,r?.importMap),new Promise((t,n)=>{i=setTimeout(()=>{var t;n(Error(`Could not resolve requested script, ${e}, within ${(t=a)<1e3?`${t} milliseconds`:t<6e4?`${Math.floor(t/1e3)} seconds`:t<36e5?`${Math.floor(t/6e4)} minutes`:t<864e5?`${Math.floor(t/36e5)} hours`:`${Math.floor(t/864e5)} days`}.`))},a)})]),i&&clearTimeout(i);let s=nm(e),l=window[s];if(!("object"==typeof(o=l)&&null!==o&&"init"in o&&"function"==typeof o.init&&"get"in o&&"function"==typeof o.get)){let e=`The global variable ${s} does not refer to a federated module`;throw console.error(e),Error(e)}l.init(n.S.default);let c=(await l.get(t))();if("object"!=typeof c||null===c){let t=`Container for ${e} did not return an ESM module as expected`;throw console.error(t),Error(t)}return c}async function 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 nh();if(!n.imports.hasOwnProperty(e)){let t=`Could not find the package ${e} defined in the current importmap`;throw console.error(t),Error(t)}let r=n.imports[e];r.startsWith("./")&&(r=window.spaBase+r.substring(1));let o=e in nr().imports;try{return await function(e){var t;let n=(t=window)[ng]??(t[ng]=new Map),r=n.get(e);if(r)return r;if(document.head.querySelector(`script[src="${e}"]`))return console.warn(`Script at ${e} already loaded. Not loading it again.`),Promise.resolve();let o=document.createElement("script");o.src=e,o.type="text/javascript",o.async=!0;let i=new Promise((t,r)=>{let i=setTimeout(()=>{console.error(`The script at ${e} did not load within 5 seconds. This may indicate an issue with the imports in the script's entry-point file or with the script's bundler configuration.`)},5e3);function a(){clearTimeout(i),o.removeEventListener("load",s),o.removeEventListener("error",l)}function s(){a(),t()}function l(t){a(),n.delete(e),o.remove();let i=`Failed to load script from ${e}`;console.error(i,t),r(t.message??i)}o.addEventListener("load",s),o.addEventListener("error",l),document.head.appendChild(o)});return n.set(e,i),i}(r)}catch(e){return o&&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:r}),actionButtonLabel:tm("resetOverrides","Reset overrides"),onActionButtonClick(){nl(),window.location.reload()}}),Promise.reject(e)}}return Promise.resolve()}async function nh(){return ne()}let ng=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 r=0;r<e.length;r++){let o=e[r];try{let e;if(o.src){let t=await fetch(o.src);if(!t.ok)throw Error(`Request for ${o.src} returned ${t.status} ${t.statusText}`);e=await t.json()}else o.textContent&&(e=JSON.parse(o.textContent));e&&n_(e)&&t.push(e)}catch(e){n=!1,console.warn(`[route-maps] Failed to parse routes from script tag at index ${r}`,e)}}return{map: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),r=await t.json();if(nw(r))return{moduleName:e,routes:r};throw Error(`${n} did not resolve to a valid OpenmrsAppRoutes object`)}throw Error(`Override for ${e} is neither a valid routes object nor a URL`)}))))"fulfilled"===n.status?e.routes[n.value.moduleName]=n.value.routes:console.warn("[route-maps] Failed to load route override",n.reason)}catch(e){console.warn("[route-maps] Failed to read route overrides from localStorage",e)}return e}async function nC(){let e=await nk();return nb?nN([e,nx??await nE()]):e}async function nP(){return nk()}async function nI(){return nb?nN([await nk(),await nE()]):nk()}function nA(){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 nO(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,r){return tP(nU(e,t,r),{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 r=new FormData;return r.append("fileCaption",t.fileDescription),r.append("patient",e),n&&r.append("encounter",n),t.file?r.append("file",t.file,t.fileName):(r.append("file",new File([""],t.fileName),t.fileName),r.append("base64Content",t.base64Content)),tP(`${nL}`,{method:"POST",body:r})}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 r=n.toString();return tP(`${tj}/location${r?"?"+r:""}`).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 n3=n(9225),n4=n(6881),n7=n(6828),n9=n(1956),re=n(3635),rt=n(7839),rn=n(2298);let rr={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)}},ro={...rr,Promise};function ri(e,t={}){return rd(e,t,rf)}async function ra(e,t={}){return rm(e,t,rf)}function rs(e,t={}){return rd(e,t,rh)}function rl(e,t={}){return rm(e,t,rh)}function rc(e,t={}){return rd(e,t,rg)}function ru(e,t={}){return rm(e,t,rg)}function rd(e,t={},n){if("string"!=typeof e&&("object"!=typeof e||!e||!("type"in e)))throw`Unknown expression type ${e}. Expressions must either be a string or pre-compiled string.`;if("string"==typeof e&&0===e.trim().length)throw{type:"Empty expression",message:"Expression cannot be an empty string"};null==t&&(t={});let r=rb(t,rr),o=rw("string"==typeof e?(0,n3.A)(e):e,r);if(n(o))return o;throw{type:"Invalid result",message:"string"==typeof e?`The expression ${e} did not produce a valid result`:"The expression did not produce a valid result"}}async function rm(e,t={},n){if("string"!=typeof e&&("object"!=typeof e||!e||!("type"in e)))return Promise.reject(`Unknown expression type ${e}. Expressions must either be a string or pre-compiled string.`);if("string"==typeof e&&0===e.trim().length)throw{type:"Empty expression",message:"Expression cannot be an empty string"};null==t&&(t={});let r=rb(t,ro);return Promise.resolve(rw("string"==typeof e?(0,n3.A)(e):e,r)).then(t=>{if(n(t))return t;throw{type:"Invalid result",message:"string"==typeof e?`The expression ${e} did not produce a valid result`:"The expression did not produce a valid result"}})}function rp(e){return(0,n3.A)(e)}function rf(e){return"string"==typeof e||"number"==typeof e||"boolean"==typeof e||null==e||e instanceof Date}function rh(e){return"boolean"==typeof e}function rg(e){return"number"==typeof e}function rw(e,t){switch(e.type){case"UnaryExpression":var n,r,o,i,a,s,l,c,u,d,m,p,f,h=e,g=t;let w=rw(h.argument,g);switch(h.operator){case"+":return+w;case"-":return-w;case"~":return~w;case"!":return!w;default:throw`Expression evaluator does not support operator '${h.operator}''`}case"BinaryExpression":var _=e,y=t;switch(_.operator){case"&&":return rw(_.left,y)&&rw(_.right,y);case"||":return rw(_.left,y)||rw(_.right,y);case"??":return rw(_.left,y)??rw(_.right,y)}let v=rw(_.left,y),b=rw(_.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,r=t,rw(n.test,r)?rw(n.consequent,r):rw(n.alternate,r);case"CallExpression":return rk(ry(e,t));case"ArrowFunctionExpression":let x;return o=e,i=t,x=o.params?.map(e=>{if("Identifier"===e.type)return e.name;throw`Cannot handle parameter of type ${e.type}`})??[],(function(...e){if(e.length<x.length)throw`Required argument(s) ${x.slice(e.length,-1).join(", ")} were not provided`;let t=Object.fromEntries(x.reduce((t,n,r)=>{let o=e[r];return function e(t){if("string"==typeof t||"number"==typeof t||"boolean"==typeof t||"function"==typeof t||null===t||t instanceof RegExp)return!0;if("object"==typeof t){for(let n of Object.keys(t))if(!e(t[n]))return!1;return!0}if(Array.isArray(t)){for(let n of t)if(!e(n))break}return!1}(o)&&t.push([n,o]),t},[]));return rw(o.body,i.addVariables(t))}).bind(null);case"MemberExpression":return rk(rv(e,t));case"ArrayExpression":return a=e,s=t,a.elements?.map(rj(s));case"SequenceExpression":let S;return l=e,c=t,(S=l.expressions.map(rj(c)))[S.length-1];case"NewExpression":var k=e,j=t;if(k.callee&&"Identifier"===k.callee.type){let e=k.arguments?.map(rj(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,(rN(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(rj(p))??[],(E=m.quasis?.map(rj(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 r_(e,t){switch(e.type){case"Literal":return e.value;case"Identifier":return e.name;case"MemberExpression":return r_(e.property,t);default:throw`VisitExpressionName does not support expression of type '${e.type}'`}}function ry(e,t){let n=rS(e.callee,t);if(n===rx||e.optional&&null==n)return rx;let r=e.arguments?.map(rj(t));if(n){if("function"!=typeof n)throw`${rP(e.callee)} is not a function`}else throw`No function named ${rP(e.callee)} is defined in this context`;return n(...r)}function rv(e,t){let n=rS(e.object,t);if(n===rx||e.optional&&null==n)return rx;if(null===n)throw TypeError(`TypeError: cannot read properties of null (reading '${rC(e.property,t)}')`);if(void 0===n)switch(e.object.type){case"Identifier":{let n=r_(e.object,t);throw ReferenceError(`ReferenceError: ${n} is not defined`)}case"MemberExpression":throw TypeError(`TypeError: cannot read properties of undefined (reading '${rC(e.property,t)}')`);default:throw`VisitMemberExpression does not support operator '${e.object.type}' type`}if("object"!=typeof n&&"function"!=typeof n&&"string"!=typeof n&&"number"!=typeof n)throw`VisitMemberExpression does not support member access on type ${typeof n}`;let r=e.computed?function(e){if(void 0===e)throw{type:"Illegal property access",message:"No property was supplied to the property access"};if("string"!=typeof e&&"number"!=typeof e)throw{type:"Illegal property access",message:`Cannot use a value of type ${null===e?"null":typeof e} as a property name`};return e}(rw(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);rN(r),function(e,t){if(rE.has(String(t)))return;let n=Object(e);for(;null!==n;){if(Object.hasOwn(n,t)){if(n===Object.prototype||n===Function.prototype)throw{type:"Illegal property access",message:`Cannot access the ${t} property of objects`};return}n=Object.getPrototypeOf(n)}}(n,r);let o=n[r];return"function"==typeof o?o.bind(n):o}function rb(e,t){let n={variables:{...e},globals:{...t},addVariables(e){return this.variables={...this.variables,...e},this}};return n.addVariables.bind(n),n}n3.A.plugins.register(n4.A),n3.A.plugins.register(n7.A),n3.A.plugins.register(n9.A),n3.A.plugins.register(re.A),n3.A.plugins.register(rt.A),n3.A.plugins.register(rn.A),n3.A.addBinaryOp("in",7),n3.A.addBinaryOp("??",1);let rx=Symbol("optional chain short-circuited");function rS(e,t){switch(e.type){case"MemberExpression":return rv(e,t);case"CallExpression":return ry(e,t);default:return rw(e,t)}}function rk(e){return e===rx?void 0:e}function rj(e){return function(t){return null===t?null:rw(t,e)}}function rN(e){if("__proto__"===e||"prototype"===e||"constructor"===e)throw{type:"Illegal property access",message:`Cannot access the ${e} property of objects`}}let rE=new Set(["toString","valueOf","hasOwnProperty"]);function rC(e,t){try{return r_(e,t)}catch{return"<computed>"}}function rP(e){return e?"MemberExpression"===e.type?e.property?.name:e.name:null}function rI(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:{...ro},isLocalExpression:!1,variables:new Set};return rA("string"==typeof e?(0,n3.A)(e):e,t),[...t.variables]}function rA(e,t){switch(e.type){case"UnaryExpression":return r=e,o=t,rA(r.argument,o);case"BinaryExpression":return i=e,a=t,[rA(i.left,a),rA(i.right,a)].filter(Boolean);case"ConditionalExpression":return s=e,l=t,[rA(s.consequent,l),rA(s.test,l),rA(s.alternate,l)].filter(Boolean);case"CallExpression":let n;return c=e,u=t,n=rA(c.callee,u),c.arguments?.map(rO(u)),n;case"ArrowFunctionExpression":var r,o,i,a,s,l,c,u,d,m,p,f,h,g,w,_,y=e,v=t;let b={...v};b.isLocalExpression=!0;let x=y.params?.map(rO(b))??[],S=rA(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(rA(k.object,j),k.computed)return void rA(k.property,j);let N={...j};N.isLocalExpression=!0,rA(k.property,N);return;case"ArrayExpression":return d=e,m=t,void d.elements?.map(rO(m));case"SequenceExpression":return p=e,f=t,void p.expressions?.map(rO(f));case"NewExpression":return h=e,g=t,void h.arguments?.map(rO(g));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(rO(_)),w.quasis?.map(rO(_)));default:throw`Expression evaluator does not support expression of type '${e.type}'`}}function rO(e){return function(t){return null===t?null:rA(t,e)}}let rR=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:",""),r=JSON.parse(localStorage.getItem(`openmrs:feature-flag-meta:${n}`)||"{}");e[n]={enabled:"true"===localStorage.getItem(t),...r}}return e}()});function r$(e,t,n){rR.setState(r=>({flags:{...r.flags,[e]:{enabled:r.flags[e]?.enabled??!1,label:t,description:n}}}))}function rT(){let e=rR.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 rM(e){return rR.getState().flags[e].enabled}function rL(e,t){rR.subscribe(n=>{t(n.flags[e].enabled)})}function rW(e,t){rR.setState(n=>({flags:{...n.flags,[e]:{...n.flags[e],enabled:t}}}))}rR.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 rD=n(1216);let rU=R("extensionsInternal",{slots:{},extensions:{}}),rB=R("extensionRenderings",{renderings:new Map}),rF=()=>M("extensionsInternal",{slots:{},extensions:{}}),rH=()=>M("extensionRenderings",{renderings:new Map});function rV(e){let t=rU.getState(),n=e(t);n!==t&&rU.setState(n)}let rG=null,rz=null;function rq(){let e=rB.getState();return rG&&e===rz||(rG=new Map(e.renderings),rz=e,function(e){for(let t of(r5.clear(),e.values()))r8(t,1);r6=!0}(rG)),rG}function rJ(e){rz={renderings:e},rB.setState(rz,!0)}function rK(e){let t=rq();t.has(e.renderingId)||(t.set(e.renderingId,e),r8(e,1),rJ(t))}function rX(e){let t=rq(),n=t.get(e);n&&(t.delete(e),r8(n,-1),rJ(t))}let rY=()=>M("extensions",{slots:{}}),rZ=0,rQ=new Set;function r0(e){rZ++;try{return e()}finally{if(0==--rZ&&rQ.size>0){let e=Array.from(rQ);for(let t of(rQ.clear(),e))r1(t)}}}function r1(e){try{e()}catch(t){console.error(`The extension system's '${e.name}' recomputation failed`,t)}}function r2(e){rZ>0?rQ.add(e):r1(e)}let r5=new Map,r6=!1;function r8(e,t){let n=JSON.stringify([e.slotName,e.extensionId,e.slotModuleName,e.extensionModuleName]),r=r5.get(n);if(!r){if(t<0)return;r5.set(n,{count:1,record:{slotModuleName:e.slotModuleName,extensionModuleName:e.extensionModuleName,slotName:e.slotName,extensionId:e.extensionId}}),r6=!0;return}r.count+=t,r.count<1&&(r5.delete(n),r6=!0)}function r3(){var e,t;if(rq(),!r6)return;r6=!1;let n=Array.from(r5.values(),({record:e})=>e);n.sort(r4),e=et.getState().mountedExtensions,t=n,e.length===t.length&&e.every((e,n)=>0===r4(e,t[n]))||et.setState({mountedExtensions:n})}function r4(e,t){return r7(e.slotName,t.slotName)||r7(e.extensionId,t.extensionId)||r7(e.slotModuleName,t.slotModuleName)||r7(e.extensionModuleName,t.extensionModuleName)}function r7(e,t){return e===t?0:e<t?-1:1}r3(),rB.subscribe(()=>r2(r3));let r9=rF(),oe=rY(),ot=er(),on=ea(),or=new Set,oo=!1;function oi(e){if(null===e)or=null;else if(null!==or)for(let t of e)or.add(t);r2(oa)}function oa(){if(!oo){oo=!0;try{for(let e=1;;e++){let t=or;if(null!==t&&0===t.size)return;or=new Set;try{!function(e,t,n,r,o,i=null){let a=oe.getState().slots,s={},l=!1,c=Object.entries(r.flags).filter(([,{enabled:e}])=>e).map(([e])=>e);for(let[r,u]of Object.entries(e.slots)){let d=a[r];if(d&&i&&!i.has(r)){s[r]=d;continue}let{config:m}=ei(t,u.name),p=function(e,t,n,r,o,i){let a=function(e,t){let n=e.add||[],r=e.remove||[],o=e.order||[],{extensions:i}=r9.getState(),a=new Set(r),s=[...t,...n].filter(e=>!a.has(e)),l=og(o),c=og(t),u=new Map(s.map(e=>[e,function(e,t,n,r){let o=t.get(e);if(void 0!==o)return o;{if(void 0!==n)return 1e3+n;let t=r.get(e);return void 0!==t?2e3+t:3e3}}(e,l,i[oc(e)]?.order,c)]));return s.sort((e,t)=>u.get(e)-u.get(t))}(n,t.slots[e].attachedIds),s=[];for(let l of a){let{config:a}=es(r,e,l),c=el(n,e,l),u=c?(0,rD.A)({},a,c):a,d=oc(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&&!o.includes(m.featureFlag))continue;s.push({id:l,name:d,moduleName:m.moduleName,config:u,featureFlag:m.featureFlag,meta:m.meta,displayConditionExpression:u?.["Display conditions"]?.expression||m.displayExpression})}}return s}(r,e,m,n,c,o.session);d&&d.moduleName===u.moduleName&&(0,F.A)(d.candidateExtensions,p)?s[r]=d:(s[r]={moduleName:u.moduleName,candidateExtensions:p},l=!0)}(l||Object.keys(a).length!==Object.keys(s).length)&&oe.setState({slots:s})}(r9.getState(),ot.getState(),on.getState(),rR.getState(),tA.getState(),t)}catch(e){throw or=null===t||null===or?null:new Set([...t,...or]),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{oo=!1}}}function os(e,t){let n=new Set;for(let r of Object.keys(e))e[r]!==t[r]&&n.add(r);for(let r of Object.keys(t))r in e||n.add(r);return n}function ol(e,t){return{moduleName:t,name:e,attachedIds:[]}}function oc(e){let[t]=e.split("#");return t}function ou(e,t){let n=oc(t);return e.extensions[n]}function od(e){return ou(r9.getState(),e)}r9.subscribe((e,t)=>{oi(e.extensions!==t.extensions?null:os(e.slots,t.slots))}),ot.subscribe((e,t)=>{oi(os(e.slots,t.slots))}),on.subscribe((e,t)=>{oi(os(e.configs,t.configs))}),rR.subscribe(()=>oi(null)),tA.subscribe(()=>oi(null)),oi(null);let om=e=>rV(t=>({...t,extensions:{...t.extensions,[e.name]:{...e}}}));function op(e,t){rV(n=>{let r=n.slots[e];return r?{...n,slots:{...n.slots,[e]:{...r,attachedIds:[...r.attachedIds,t]}}}:{...n,slots:{...n.slots,[e]:{...ol(e),attachedIds:[t]}}}})}function of(e,t){rV(n=>{let r=n.slots[e];return r&&r.attachedIds.includes(t)?{...n,slots:{...n.slots,[e]:{...r,attachedIds:r.attachedIds.filter(e=>e!==t)}}}:n})}function oh(e){rV(t=>{let n=t.slots[e];return n?{...t,slots:{...t.slots,[e]:{...n,attachedIds:[]}}}:t})}function og(e){let t=new Map;return e.forEach((e,n)=>{t.has(e)||t.set(e,n)}),t}function ow(e,t){return function(e,t,n=null,r){let o;return e.filter(e=>{let i=e.displayConditionExpression;if("string"!=typeof i||0===i.trim().length)return!0;o??(o=t&&"object"==typeof t?{session:n,...t}:{session:n});try{return!!rs(i,o)}catch(t){return console.error(`Error while evaluating expression '${i}' for ${e.id}`+(r?` in ${r}`:""),t),!1}})}(o_(e),t,tA.getState().session,e)}function o_(e){return oe.getState().slots[e]?.candidateExtensions??[]}let oy=(e,t)=>r9.setState(n=>{let r=n.slots[t]?.moduleName;if(r&&r!=e)return console.warn(`An extension slot with the name '${t}' already exists. Refusing to register the same slot name twice (in "registerExtensionSlot"). The existing one is from module ${r}.`),n;if(r&&r==e)return n;if(n.slots[t])return{...n,slots:{...n.slots,[t]:{...n.slots[t],moduleName:e}}};let o=ol(t,e);return{...n,slots:{...n.slots,[t]:{...o}}}}),ov=()=>{or=null,rV(()=>({slots:{},extensions:{}})),rH().setState({renderings:new Map}),oe.setState({slots:{}})},ob=R("left-nav",{slotName:null,basePath:window.spaBase,mode:"normal"});function ox({name:e,basePath:t,mode:n,componentContext:r,state:o}){ob.setState({slotName:e,basePath:t,mode:n??"normal",componentContext:r,state:o})}function oS(e){ob.getState().slotName===e&&ob.setState(ob.getInitialState(),!0)}let ok=R("modalRegistry",{modals:{}});function oj(e){ok.setState(t=>(t.modals[e.name]=e,t))}function oN(e){let t=ok.getState().modals[e];if(!t){let n=od(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.`),oj(t))}return t}let oE=R("workspace2",{registeredGroupsByName:{},registeredWindowsByName:{},registeredWorkspacesByName:{},openedGroup:null,openedWindows:[],isMostRecentlyOpenedWindowHidden:!1});function oC(e){let{registeredWorkspacesByName:t,registeredWindowsByName:n}=oE.getState(),r=t[e];if(r){let t=n[r.window];if(t)return t;throw Error(`No workspace window found with name: ${r.window} for workspace: ${e}`)}throw Error(`No workspace found with name: ${e}`)}function oP(e){let{registeredGroupsByName:t,registeredWindowsByName:n}=oE.getState(),r=n[e];if(r){let n=t[r.group];if(n)return n;throw Error(`No workspace group found with name: ${r.group} for window: ${e}`)}throw Error(`No workspace window found with name: ${e}`)}function oI(e){let{openedWindows:t}=oE.getState();return t.findIndex(t=>t.openedWorkspaces.find(t=>t.workspaceName===e))}function oA(e,t){if(0==t.length)return;let{registeredGroupsByName:n}=oE.getState(),r={...n};for(let n of t){if(r[n.name])throw Error(`Cannot register workspace group ${n.name} more than once`);r[n.name]={...n,moduleName:e}}oE.setState({registeredGroupsByName:r})}function oO(e,t){if(0==t.length)return;let{registeredWindowsByName:n}=oE.getState(),r={...n};for(let n of t){if(r[n.name])throw Error(`Cannot register workspace window ${n.name} more than once`);let t={...n,moduleName:e};r[n.name]=t}oE.setState({registeredWindowsByName:r})}function oR(e,t){if(0==t.length)return;let{registeredWorkspacesByName:n}=oE.getState(),r={...n};for(let n of t){if(r[n.name])throw Error(`Cannot register workspace ${n.name} more than once`);let t={...n,moduleName:e};r[n.name]=t}oE.setState({registeredWorkspacesByName:r})}let o$=0,oT=null,oM={bootstrap:15e3,mount:15e3,unmount:15e3};function oL(e,t){if(e.timeouts)return e;let n=e.name??"parcel",r=Object.fromEntries(Object.keys(oM).filter(t=>e[t]).map(r=>{var o,i;let a,s;return[r,(o=e[r],i=oM[r],a=Array.isArray(o)?o:[o],s=e=>a.reduce((t,o,i)=>t.then(()=>{let t=o(e);return"function"==typeof t?.then&&"function"==typeof t?.catch?t:Promise.reject(Error(`Lifecycle function ${r} at array index ${i} for parcel ${n} did not return a promise`))}),Promise.resolve(void 0)),e=>{let o,a=new Promise((e,t)=>{o=setTimeout(()=>t(Error(`Lifecycle function ${r} for parcel ${n} did not settle within ${i}ms`)),i)});return Promise.race([s(e),a]).finally(()=>clearTimeout(o)).then(e=>(t(r,!1),e),e=>{throw t(r,!0),e})})]}));return{...e,...r}}async function oW(e,t){var n,r;let o,i,a,s,l,c=await (oT??(oT=new Promise((e,t)=>{(0,ts.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),ts.xL))),oT),u={...t},d=(o=u,i=!1,{retarget:e=>o={...e},release:a=()=>(function(e){for(let t of Object.keys(e))delete e[t]})(o),onSettled(e,t){switch(e){case"bootstrap":t&&a();return;case"mount":i||(i=t);return;case"unmount":(t||i)&&a();return}}});return r=c((n=d.onSettled,"function"==typeof e?()=>e().then(e=>oL(e,n)):oL(e,n)),u),s=e=>t=>e.call(r,d.retarget(t)).catch(e=>{throw"SKIP_BECAUSE_BROKEN"===r.getStatus()&&d.release(),e}),l=r.update&&s(r.update),Object.defineProperty(r,"update",{configurable:!0,enumerable:!0,get:()=>l,set:e=>{l=e&&s(e)}})}function oD(){return oU}function oU(e,t){let n,r=oW(e,t).then(e=>n=e);return{mount:()=>r.then(e=>e.mount()),unmount:()=>r.then(e=>e.unmount()),update:e=>r.then(t=>t.update?.(e)),getStatus:()=>n?.getStatus()??"LOADING_SOURCE_CODE",get loadPromise(){return r.then(e=>e.loadPromise)},get bootstrapPromise(){return r.then(e=>e.bootstrapPromise)},get mountPromise(){return r.then(e=>e.mountPromise)},get unmountPromise(){return r.then(e=>e.unmountPromise)}}}async function oB(e,t,n,r,o=e=>e,i={}){let a=oc(r),s=od(r),l=null;if(e){let c;if(!s)throw Error(`Couldn't find extension '${a}' to attach to '${t}'`);let{meta:u,moduleName:d,load:m}=s,p=o$++,f=`${t}/${r}-${p}`;e.dataset.extensionRenderingId=f;let h=e=>{try{rX(f)}catch(t){console.error(e,t)}};try{rK({renderingId:f,extensionName:a,extensionModuleName:d,extensionId:r,slotName:t,slotModuleName:n})}catch(e){throw h(`Recomputing configuration after registering '${r}' failed also failed`),e}try{c=await m()}catch(e){throw h(`Recomputing configuration after '${r}' failed to load also failed`),e}try{l=await oW(o({...c,name:`${t}/${a}-${p}`}),{...i,_meta:u,_extensionContext:{extensionId:r,extensionSlotName:t,extensionSlotModuleName:n,extensionModuleName:d,extensionMeta:u},domElement:e})}catch(e){throw h(`Recomputing configuration after '${r}' failed to mount also failed`),e}l.mountPromise.then(void 0,e=>{console.error(`Extension '${r}' in slot '${t}' failed to mount`,e),h(`Recomputing configuration after '${r}' failed to mount also failed`)}),l.unmountPromise.then(()=>h(`Recomputing configuration after unmounting '${r}' failed`),e=>{console.error(`Extension '${r}' in slot '${t}' failed to unmount`,e),h(`Recomputing configuration after '${r}' failed to unmount also failed`)})}else console.warn(`Tried to render ${r} into ${t} but no DOM element was available.`);return l}var oF=n(6925),oH=n.n(oF);let oV=(0,oF.createContext)({moduleName:"",featureName:""});function oG({to:e,templateParams:t,onBeforeNavigate:n,children:r,...o}){return(0,oF.useEffect)(()=>{o.href&&console.warn(`ConfigurableLink does not support the href prop. Use the 'to' prop instead. The provided href value is '${o.href}'`),o.onClick&&console.warn(`ConfigurableLink does not support the onClick prop. Use the 'onBeforeNavigate' prop instead. The 'to' prop of the offending link is ${e}`)},[]),oH().createElement("a",{onClick:r=>{0===r.button&&!r.ctrlKey&&!r.shiftKey&&!r.altKey&&!r.metaKey&&(r.preventDefault(),n?.(r),th({to:e,templateParams:t})),0===r.button&&(r.ctrlKey||r.metaKey)&&n?.(r),0===r.button&&r.shiftKey&&n?.(r),1===r.button&&n?.(r)},href:tp(e,t),...o},r)}let oz=({state:e,children:t,...n})=>{let{extension:r}=(0,oF.useContext)(oV),o=(0,oF.useRef)(null),i=(0,oF.useRef)(Promise.resolve()),a=(0,oF.useRef)(!1),s=(0,oF.useRef)(!1),l=(0,oF.useRef)(e),c=(0,oF.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,oF.useCallback)((e,t)=>{e.update&&"UNMOUNTING"!==e.getStatus()&&(i.current=Promise.all([e.mountPromise,i.current]).then(()=>{if(o.current?.getStatus()==="MOUNTED"&&o.current.update)return o.current.update({...t})}).catch(e=>{let t=o.current?.getStatus();"UNMOUNTING"!==t&&"NOT_MOUNTED"!==t&&"UNLOADING"!==t&&console.error(`The extension '${r?.extensionId}' failed to update`,e)}))},[]),d=(0,oF.useCallback)(t=>{t&&!o.current&&!s.current&&r?.extensionSlotName&&r.extensionSlotModuleName&&(s.current=!0,oB(t,r.extensionSlotName,r.extensionSlotModuleName,r.extensionId,void 0,e).then(t=>{(s.current=!1,o.current=t,a.current)?c(t):t&&l.current!==e&&u(t,l.current)},()=>{s.current=!1}))},[]);return(0,oF.useEffect)(()=>(a.current=!1,()=>{a.current=!0,c(o.current)}),[]),(0,oF.useEffect)(()=>{l.current=e,o.current&&u(o.current,e)},[e]),r?oH().createElement("div",{ref:d,"data-extension-id":r?.extensionId,style:{position:"relative"},...n}):null};function oq(e){let t=(0,oF.useRef)(e);return x(t.current,e)||(t.current=e),t.current}function oJ(e,t){"function"==typeof t&&(t=t(e));let n={};for(let[r,o]of Object.entries(t)){let t=function(...t){e.setState(e=>o(e,...t))};n[r]=t}return n}let oK=e=>e;function oX(e,t=oK,n){let r=(0,oF.useCallback)(t=>e.subscribe(t),[e]),o=(0,oF.useCallback)(()=>t(e.getState()),[e,t]),i=(0,oF.useSyncExternalStore)(r,o,o),a=(0,oF.useMemo)(()=>n?oJ(e,n):null,[e,n]);return(0,oF.useMemo)(()=>a?{...i,...a}:i,[i,a])}function oY(e,t){return oX(e,oK,t)}function oZ(e){return function(t){let n=(0,oF.useCallback)(t=>e.subscribe(t),[]),r=(0,oF.useCallback)(()=>e.getState(),[]),o=(0,oF.useSyncExternalStore)(n,r,r),i=(0,oF.useMemo)(()=>t?oJ(e,t):null,[t]);return(0,oF.useMemo)(()=>i?{...o,...i}:o,[o,i])}}let oQ=[];Object.freeze(oQ);let o0={candidateExtensions:oQ};Object.freeze(o0);let o1=e=>{let t=(0,oF.useCallback)(t=>t.slots?.[e]??o0,[e]);return oX(rY(),t)},o2=e=>e.session;function o5(e,t){let{candidateExtensions:n}=o1(e),r=oX(tA,o2),o=oq(t);return(0,oF.useMemo)(()=>ow(e,o),[e,o,r,n])}function o6(e,t){let{moduleName:n}=(0,oF.useContext)(oV);if(!n)throw Error("ComponentContext has not been provided. This should come from @openmrs/esm-react-utils.");return(0,oF.useEffect)(()=>{oy(n,e)},[n,e]),{extensions:o5(e,t),extensionSlotName:e,extensionSlotModuleName:n}}function o8(e){return e}function o3({name:e,extensionSlotName:t,select:n=o8,children:r,state:o,style:i,...a}){if(r&&o)throw Error("Both children and state have been provided. If children are provided, the state must be passed as a prop to the `Extension` component.");let s=e??t,l=(0,oF.useRef)(null),{extensions:c,extensionSlotModuleName:u}=o6(s,o),d=(0,oF.useMemo)(()=>n(c),[n,c]),m=(0,oF.useMemo)(()=>{if("function"==typeof r&&!oH().isValidElement(r))return d.map(e=>r(e,o))},[r,d]);return oH().createElement("div",{ref:l,"data-extension-slot-name":s,"data-extension-slot-module-name":u,style:{...i,position:"relative"},...a},s&&d?.map((e,t)=>oH().createElement(oV.Provider,{key:e.id,value:{moduleName:u,featureName:"",extension:{extensionId:e.id,extensionSlotName:s,extensionSlotModuleName:u,extensionMeta:e.meta}}},m?.[t]??("function"!=typeof r?r:null)??oH().createElement(oz,{state:o}))))}var o4=n(3776),o7=n(9568),o9=n(9737),ie=n(2324),it=n(242);let ir={strictMode:!0,throwErrorsToConsole:!0,disableTranslations:!1},io=new Map;(0,it.y)(io);let ii={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:()=>io};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={...ii,...t.swrConfig};return function(e){var r,o,i,a,s;return i=o=class extends(r=oH().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 oH().createElement("div",null,"An error has occurred. Please try reloading the page.");{let r=oH().createElement(oF.Suspense,{fallback:null},oH().createElement(ie.S,{value:n},oH().createElement(oV.Provider,{value:this.state.config},t.disableTranslations?oH().createElement(e,this.props):oH().createElement(o9.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},oH().createElement(e,this.props)))));return t.strictMode&&oH().StrictMode?oH().createElement(oH().StrictMode,null,r):r}}constructor(e){super(e),this.state={caughtError:null,caughtErrorInfo:null,config:{moduleName:t.moduleName,featureName:t.featureName,extension:e._extensionContext}}}},a="displayName",s=`OpenmrsReactComponent(${t.featureName})`,a in i?Object.defineProperty(i,a,{value:s,enumerable:!0,configurable:!0,writable:!0}):i[a]=s,o}}function is(e,t){return(0,o7.A)({React:oH(),ReactDOMClient:o4,rootComponent:ia(t)(e)})}function il(e,t){return()=>e().then(({default:e})=>is(e,t))}function ic(e,t){return()=>Promise.resolve(is(e,t))}let iu=il,id=(0,E.y)()(()=>({}));T("openmrs-app-context",id);let im={};function ip(e,t=e=>e){let n=id.getState();return e in n?Object.freeze(Object.assign({},t?t(n[e]):n[e])):null}function ih(e,t){id.setState(n=>(e in n||(n[e]={}),n[e]=t(n[e]),Object.assign({},n)))}function ig(e){return null===e?null:Object.freeze(Object.assign({},e))}let iw=new Map;function i_(e,t){let n=(0,oF.useRef)(t??{}),r=(0,oF.useRef)(t=>ih(e,t)),o=(0,oF.useRef)(Symbol());return(0,oF.useEffect)(()=>{let n=t??{},r=o.current;return null===ip(e)?!function(e,t=im){id.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===im?{}: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)),iw.set(e,r),()=>{iw.get(e)===r&&(id.setState(t=>(e in t&&delete t[e],t)),iw.delete(e))}},[e]),(0,oF.useEffect)(()=>{let r=t??{};x(n.current,r)||(ih(e,()=>r),n.current=r)},[t]),r.current}function iy({namespace:e,value:t}){return i_(e,t),null}let iv=({children:e,value:t,fallback:n})=>t?oH().createElement(oH().Fragment,null,e):n?oH().createElement(oH().Fragment,null,n):null;function ib(){let e=(0,oF.useRef)();return(!e.current||e.current.signal.aborted)&&(e.current=new AbortController),(0,oF.useEffect)(()=>{let t=e.current;return()=>t?.abort()},[]),e.current}function ix(e,t=e=>e??{}){let[n,r]=(0,oF.useState)(()=>{if(iS(e))return;let n=ip(e);if(null!==n)return t?t(n):n});return(0,oF.useEffect)(()=>{if(iS(e))throw Error(`The namespace supplied to useAppContext must be a non-empty string, but was "${e}".`)},[e]),(0,oF.useEffect)(()=>{var n;let o;return(n=e=>{if(null==e)return void r(void 0);let n=t?t(e):e;r(e=>x(e,n)?e:n)})(ig(o=ip(e))),id.subscribe(t=>{let r=e in t?t[e]:null;r!==o&&(o=r,n(ig(r)))})},[e,t]),n}function iS(e){return"string"!=typeof e||0===e.trim().length}function ik(e){let t=o5(e);return(0,oF.useMemo)(()=>t.map(e=>e.id),[t])}function ij(e){return o1(e).candidateExtensions}function iN(e,t,n){let{data:r,error:o,mutate:i,isLoading:a,isValidating:s}=(0,ie.u)(e?nU(e,t,n):null,tP);return(0,oF.useMemo)(()=>({isLoading:a,data:r?.data.results??[],error:o,mutate:i,isValidating:s}),[r,o,a,s,i])}function iE(e){(0,oF.useEffect)(()=>{if(e){let e=window.getComputedStyle(document.body).overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=e}}},[e])}let iC={},iP=`No ComponentContext has been provided. This should come from "openmrsComponentDecorator".
|
|
15
|
+
${this.stack}`}}let tA=R("session",{loaded:!1,session:null}),tO=0,tR=null;function t$(){return tR||(tA.getState().loaded&&tO>=Date.now()-6e4?null:tW())}function tT(e){let t=e?.includeAuthStatus??!0,n=e=>t?e:e.user,r=t$();return r?new Promise(e=>{let t=()=>{let t=tA.getState();t.loaded&&(o(),e(n(t.session)))},o=tA.subscribe(t);r.then(t,t)}):Promise.resolve(n(tA.getState().session))}function tM(){return t$(),tA}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){tO=Date.now(),o??(o=tO);let n={};e&&t&&(n.Authorization=`Basic ${window.btoa(`${e}:${t}`)}`);let r=tJ(tP(tE,{headers:n,rejectAuthFailure:!0})),i=()=>{tR===r&&(tR=null)};return r.then(i,i),tR=r,r}function tD(){tA.setState({loaded:!0,session:{authenticated:!1,sessionId:""}},!0)}function tU(e,t){var n,r;if(void 0===t)return!e;if(!e)return!0;return n=e,r=t,("string"==typeof n?!(0,D.A)(r.privileges.find(e=>n===e.display)):Array.isArray(n)?n.every(e=>!(0,D.A)(r.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 r=r=>{r.loaded&&r.session.user&&(e=r.session.user,n(r.session.user),t&&t())};r(tA.getState()),e||(t=tA.subscribe(r))})}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};tA.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 r,i;if(tK(e)){"object"==typeof(r=e.responseBody)&&null!==r&&!1===r.authenticated?tA.setState({loaded:!0,session:e.responseBody},!0):tD(),t(tA.getState());return}(i=e)instanceof tI&&502===i.response.status&&!tA.getState().loaded&&void 0!==o&&Date.now()-o<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 tA.getState().loaded||tA.setState({loaded:!1,session:null,error:e instanceof Error?e:Error(String(e)),initializing:t},!0),tA.getState()}function tY(){return"development"===window.spaEnv||"true"===localStorage.getItem("openmrs:devtools")}tA.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 t3(){return t8??(t8=t4().then(({map:e,complete:t})=>(t||(t8=null),e))),t8}async function t4(){let e=document.querySelectorAll('script[type="systemjs-importmap"]'),t=[],n=!0;for(let r=0;r<e.length;r++){let o=e[r];try{if(o.src){let e=await fetch(o.src);if(!e.ok)throw Error(`Request for ${o.src} returned ${e.status} ${e.statusText}`);t.push(await e.json())}else o.textContent&&t.push(JSON.parse(o.textContent))}catch(e){n=!1,console.warn(`[import-maps] Failed to parse import map from script tag at index ${r}`,e)}}return{map: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=no();for(let n=0;n<localStorage.length;n++){let r=localStorage.key(n);if(r?.startsWith(t0)){let n=r.slice(t0.length);if(!t.includes(n)){let t=localStorage.getItem(r);t&&(e[n]=t)}}}}catch(e){console.warn("[import-maps] Failed to read import-map overrides from localStorage",e)}return{imports:e}}async function ne(){let e=await t3();return t5?t7([e,t6??t9()]):e}async function nt(){return t3()}async function nn(){return t5?t7([await t3(),t9()]):t3()}function nr(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 no(){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&&no().includes(e)}function na(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 ns(e){if(!t5)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{localStorage.removeItem(t0+e);let t=no().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=no().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",r){var o;let i,a=!r?.maxLoadingTime||r.maxLoadingTime<=0?6e5:r.maxLoadingTime;await Promise.race([nf(e,r?.importMap),new Promise((t,n)=>{i=setTimeout(()=>{var t;n(Error(`Could not resolve requested script, ${e}, within ${(t=a)<1e3?`${t} milliseconds`:t<6e4?`${Math.floor(t/1e3)} seconds`:t<36e5?`${Math.floor(t/6e4)} minutes`:t<864e5?`${Math.floor(t/36e5)} hours`:`${Math.floor(t/864e5)} days`}.`))},a)})]),i&&clearTimeout(i);let s=nm(e),l=window[s];if(!("object"==typeof(o=l)&&null!==o&&"init"in o&&"function"==typeof o.init&&"get"in o&&"function"==typeof o.get)){let e=`The global variable ${s} does not refer to a federated module`;throw console.error(e),Error(e)}l.init(n.S.default);let c=(await l.get(t))();if("object"!=typeof c||null===c){let t=`Container for ${e} did not return an ESM module as expected`;throw console.error(t),Error(t)}return c}async function 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 nh();if(!n.imports.hasOwnProperty(e)){let t=`Could not find the package ${e} defined in the current importmap`;throw console.error(t),Error(t)}let r=n.imports[e];r.startsWith("./")&&(r=window.spaBase+r.substring(1));let o=e in nr().imports;try{return await function(e){var t;let n=(t=window)[ng]??(t[ng]=new Map),r=n.get(e);if(r)return r;if(document.head.querySelector(`script[src="${e}"]`))return console.warn(`Script at ${e} already loaded. Not loading it again.`),Promise.resolve();let o=document.createElement("script");o.src=e,o.type="text/javascript",o.async=!0;let i=new Promise((t,r)=>{let i=setTimeout(()=>{console.error(`The script at ${e} did not load within 5 seconds. This may indicate an issue with the imports in the script's entry-point file or with the script's bundler configuration.`)},5e3);function a(){clearTimeout(i),o.removeEventListener("load",s),o.removeEventListener("error",l)}function s(){a(),t()}function l(t){a(),n.delete(e),o.remove();let i=`Failed to load script from ${e}`;console.error(i,t),r(t.message??i)}o.addEventListener("load",s),o.addEventListener("error",l),document.head.appendChild(o)});return n.set(e,i),i}(r)}catch(e){return o&&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:r}),actionButtonLabel:tm("resetOverrides","Reset overrides"),onActionButtonClick(){nl(),window.location.reload()}}),Promise.reject(e)}}return Promise.resolve()}async function nh(){return ne()}let ng=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 r=0;r<e.length;r++){let o=e[r];try{let e;if(o.src){let t=await fetch(o.src);if(!t.ok)throw Error(`Request for ${o.src} returned ${t.status} ${t.statusText}`);e=await t.json()}else o.textContent&&(e=JSON.parse(o.textContent));e&&n_(e)&&t.push(e)}catch(e){n=!1,console.warn(`[route-maps] Failed to parse routes from script tag at index ${r}`,e)}}return{map: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),r=await t.json();if(nw(r))return{moduleName:e,routes:r};throw Error(`${n} did not resolve to a valid OpenmrsAppRoutes object`)}throw Error(`Override for ${e} is neither a valid routes object nor a URL`)}))))"fulfilled"===n.status?e.routes[n.value.moduleName]=n.value.routes:console.warn("[route-maps] Failed to load route override",n.reason)}catch(e){console.warn("[route-maps] Failed to read route overrides from localStorage",e)}return e}async function nC(){let e=await nk();return nb?nN([e,nx??await nE()]):e}async function nP(){return nk()}async function nI(){return nb?nN([await nk(),await nE()]):nk()}function nA(){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 nO(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,r){return tP(nU(e,t,r),{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 r=new FormData;return r.append("fileCaption",t.fileDescription),r.append("patient",e),n&&r.append("encounter",n),t.file?r.append("file",t.file,t.fileName):(r.append("file",new File([""],t.fileName),t.fileName),r.append("base64Content",t.base64Content)),tP(`${nL}`,{method:"POST",body:r})}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 r=n.toString();return tP(`${tj}/location${r?"?"+r:""}`).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 n3=n(9225),n4=n(6881),n7=n(6828),n9=n(1956),re=n(3635),rt=n(7839),rn=n(2298);let rr={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)}},ro={...rr,Promise};function ri(e,t={}){return rd(e,t,rf)}async function ra(e,t={}){return rm(e,t,rf)}function rs(e,t={}){return rd(e,t,rh)}function rl(e,t={}){return rm(e,t,rh)}function rc(e,t={}){return rd(e,t,rg)}function ru(e,t={}){return rm(e,t,rg)}function rd(e,t={},n){if("string"!=typeof e&&("object"!=typeof e||!e||!("type"in e)))throw`Unknown expression type ${e}. Expressions must either be a string or pre-compiled string.`;if("string"==typeof e&&0===e.trim().length)throw{type:"Empty expression",message:"Expression cannot be an empty string"};null==t&&(t={});let r=rb(t,rr),o=rw("string"==typeof e?(0,n3.A)(e):e,r);if(n(o))return o;throw{type:"Invalid result",message:"string"==typeof e?`The expression ${e} did not produce a valid result`:"The expression did not produce a valid result"}}async function rm(e,t={},n){if("string"!=typeof e&&("object"!=typeof e||!e||!("type"in e)))return Promise.reject(`Unknown expression type ${e}. Expressions must either be a string or pre-compiled string.`);if("string"==typeof e&&0===e.trim().length)throw{type:"Empty expression",message:"Expression cannot be an empty string"};null==t&&(t={});let r=rb(t,ro);return Promise.resolve(rw("string"==typeof e?(0,n3.A)(e):e,r)).then(t=>{if(n(t))return t;throw{type:"Invalid result",message:"string"==typeof e?`The expression ${e} did not produce a valid result`:"The expression did not produce a valid result"}})}function rp(e){return(0,n3.A)(e)}function rf(e){return"string"==typeof e||"number"==typeof e||"boolean"==typeof e||null==e||e instanceof Date}function rh(e){return"boolean"==typeof e}function rg(e){return"number"==typeof e}function rw(e,t){switch(e.type){case"UnaryExpression":var n,r,o,i,a,s,l,c,u,d,m,p,f,h=e,g=t;let w=rw(h.argument,g);switch(h.operator){case"+":return+w;case"-":return-w;case"~":return~w;case"!":return!w;default:throw`Expression evaluator does not support operator '${h.operator}''`}case"BinaryExpression":var _=e,y=t;switch(_.operator){case"&&":return rw(_.left,y)&&rw(_.right,y);case"||":return rw(_.left,y)||rw(_.right,y);case"??":return rw(_.left,y)??rw(_.right,y)}let v=rw(_.left,y),b=rw(_.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,r=t,rw(n.test,r)?rw(n.consequent,r):rw(n.alternate,r);case"CallExpression":return rk(ry(e,t));case"ArrowFunctionExpression":let x;return o=e,i=t,x=o.params?.map(e=>{if("Identifier"===e.type)return e.name;throw`Cannot handle parameter of type ${e.type}`})??[],(function(...e){if(e.length<x.length)throw`Required argument(s) ${x.slice(e.length,-1).join(", ")} were not provided`;let t=Object.fromEntries(x.reduce((t,n,r)=>{let o=e[r];return function e(t){if("string"==typeof t||"number"==typeof t||"boolean"==typeof t||"function"==typeof t||null===t||t instanceof RegExp)return!0;if("object"==typeof t){for(let n of Object.keys(t))if(!e(t[n]))return!1;return!0}if(Array.isArray(t)){for(let n of t)if(!e(n))break}return!1}(o)&&t.push([n,o]),t},[]));return rw(o.body,i.addVariables(t))}).bind(null);case"MemberExpression":return rk(rv(e,t));case"ArrayExpression":return a=e,s=t,a.elements?.map(rj(s));case"SequenceExpression":let S;return l=e,c=t,(S=l.expressions.map(rj(c)))[S.length-1];case"NewExpression":var k=e,j=t;if(k.callee&&"Identifier"===k.callee.type){let e=k.arguments?.map(rj(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,(rN(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(rj(p))??[],(E=m.quasis?.map(rj(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 r_(e,t){switch(e.type){case"Literal":return e.value;case"Identifier":return e.name;case"MemberExpression":return r_(e.property,t);default:throw`VisitExpressionName does not support expression of type '${e.type}'`}}function ry(e,t){let n=rS(e.callee,t);if(n===rx||e.optional&&null==n)return rx;let r=e.arguments?.map(rj(t));if(n){if("function"!=typeof n)throw`${rP(e.callee)} is not a function`}else throw`No function named ${rP(e.callee)} is defined in this context`;return n(...r)}function rv(e,t){let n=rS(e.object,t);if(n===rx||e.optional&&null==n)return rx;if(null===n)throw TypeError(`TypeError: cannot read properties of null (reading '${rC(e.property,t)}')`);if(void 0===n)switch(e.object.type){case"Identifier":{let n=r_(e.object,t);throw ReferenceError(`ReferenceError: ${n} is not defined`)}case"MemberExpression":throw TypeError(`TypeError: cannot read properties of undefined (reading '${rC(e.property,t)}')`);default:throw`VisitMemberExpression does not support operator '${e.object.type}' type`}if("object"!=typeof n&&"function"!=typeof n&&"string"!=typeof n&&"number"!=typeof n)throw`VisitMemberExpression does not support member access on type ${typeof n}`;let r=e.computed?function(e){if(void 0===e)throw{type:"Illegal property access",message:"No property was supplied to the property access"};if("string"!=typeof e&&"number"!=typeof e)throw{type:"Illegal property access",message:`Cannot use a value of type ${null===e?"null":typeof e} as a property name`};return e}(rw(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);rN(r),function(e,t){if(rE.has(String(t)))return;let n=Object(e);for(;null!==n;){if(Object.hasOwn(n,t)){if(n===Object.prototype||n===Function.prototype)throw{type:"Illegal property access",message:`Cannot access the ${t} property of objects`};return}n=Object.getPrototypeOf(n)}}(n,r);let o=n[r];return"function"==typeof o?o.bind(n):o}function rb(e,t){let n={variables:{...e},globals:{...t},addVariables(e){return this.variables={...this.variables,...e},this}};return n.addVariables.bind(n),n}n3.A.plugins.register(n4.A),n3.A.plugins.register(n7.A),n3.A.plugins.register(n9.A),n3.A.plugins.register(re.A),n3.A.plugins.register(rt.A),n3.A.plugins.register(rn.A),n3.A.addBinaryOp("in",7),n3.A.addBinaryOp("??",1);let rx=Symbol("optional chain short-circuited");function rS(e,t){switch(e.type){case"MemberExpression":return rv(e,t);case"CallExpression":return ry(e,t);default:return rw(e,t)}}function rk(e){return e===rx?void 0:e}function rj(e){return function(t){return null===t?null:rw(t,e)}}function rN(e){if("__proto__"===e||"prototype"===e||"constructor"===e)throw{type:"Illegal property access",message:`Cannot access the ${e} property of objects`}}let rE=new Set(["toString","valueOf","hasOwnProperty"]);function rC(e,t){try{return r_(e,t)}catch{return"<computed>"}}function rP(e){return e?"MemberExpression"===e.type?e.property?.name:e.name:null}function rI(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:{...ro},boundNames:new Set,variables:new Set};return rA("string"==typeof e?(0,n3.A)(e):e,t),[...t.variables]}function rA(e,t){switch(e.type){case"UnaryExpression":return n=e,r=t,void rA(n.argument,r);case"BinaryExpression":return o=e,i=t,void(rA(o.left,i),rA(o.right,i));case"ConditionalExpression":return a=e,s=t,void(rA(a.consequent,s),rA(a.test,s),rA(a.alternate,s));case"CallExpression":return l=e,c=t,void(rA(l.callee,c),l.arguments?.map(rO(c)));case"ArrowFunctionExpression":var n,r,o,i,a,s,l,c,u,d,m,p,f,h,g,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);rA(x.body,{...S,boundNames:k});return;case"MemberExpression":return u=e,d=t,void(rA(u.object,d),u.computed&&rA(u.property,d));case"ArrayExpression":return m=e,p=t,void m.elements?.map(rO(p));case"SequenceExpression":return f=e,h=t,void f.expressions?.map(rO(h));case"NewExpression":return g=e,w=t,void g.arguments?.map(rO(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(rO(b)),v.quasis?.map(rO(b)));default:throw`Expression evaluator does not support expression of type '${e.type}'`}}function rO(e){return function(t){return null===t?null:rA(t,e)}}let rR=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:",""),r=JSON.parse(localStorage.getItem(`openmrs:feature-flag-meta:${n}`)||"{}");e[n]={enabled:"true"===localStorage.getItem(t),...r}}return e}()});function r$(e,t,n){rR.setState(r=>({flags:{...r.flags,[e]:{enabled:r.flags[e]?.enabled??!1,label:t,description:n}}}))}function rT(){let e=rR.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 rM(e){return rR.getState().flags[e].enabled}function rL(e,t){rR.subscribe(n=>{t(n.flags[e].enabled)})}function rW(e,t){rR.setState(n=>({flags:{...n.flags,[e]:{...n.flags[e],enabled:t}}}))}rR.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 rD=n(1216);let rU=R("extensionsInternal",{slots:{},extensions:{}}),rB=R("extensionRenderings",{renderings:new Map}),rF=()=>M("extensionsInternal",{slots:{},extensions:{}}),rH=()=>M("extensionRenderings",{renderings:new Map});function rV(e){let t=rU.getState(),n=e(t);n!==t&&rU.setState(n)}let rG=null,rz=null;function rq(){let e=rB.getState();return rG&&e===rz||(rG=new Map(e.renderings),rz=e,function(e){for(let t of(r5.clear(),e.values()))r8(t,1);r6=!0}(rG)),rG}function rJ(e){rz={renderings:e},rB.setState(rz,!0)}function rK(e){let t=rq();t.has(e.renderingId)||(t.set(e.renderingId,e),r8(e,1),rJ(t))}function rX(e){let t=rq(),n=t.get(e);n&&(t.delete(e),r8(n,-1),rJ(t))}let rY=()=>M("extensions",{slots:{}}),rZ=0,rQ=new Set;function r0(e){rZ++;try{return e()}finally{if(0==--rZ&&rQ.size>0){let e=Array.from(rQ);for(let t of(rQ.clear(),e))r1(t)}}}function r1(e){try{e()}catch(t){console.error(`The extension system's '${e.name}' recomputation failed`,t)}}function r2(e){rZ>0?rQ.add(e):r1(e)}let r5=new Map,r6=!1;function r8(e,t){let n=JSON.stringify([e.slotName,e.extensionId,e.slotModuleName,e.extensionModuleName]),r=r5.get(n);if(!r){if(t<0)return;r5.set(n,{count:1,record:{slotModuleName:e.slotModuleName,extensionModuleName:e.extensionModuleName,slotName:e.slotName,extensionId:e.extensionId}}),r6=!0;return}r.count+=t,r.count<1&&(r5.delete(n),r6=!0)}function r3(){var e,t;if(rq(),!r6)return;r6=!1;let n=Array.from(r5.values(),({record:e})=>e);n.sort(r4),e=et.getState().mountedExtensions,t=n,e.length===t.length&&e.every((e,n)=>0===r4(e,t[n]))||et.setState({mountedExtensions:n})}function r4(e,t){return r7(e.slotName,t.slotName)||r7(e.extensionId,t.extensionId)||r7(e.slotModuleName,t.slotModuleName)||r7(e.extensionModuleName,t.extensionModuleName)}function r7(e,t){return e===t?0:e<t?-1:1}r3(),rB.subscribe(()=>r2(r3));let r9=rF(),oe=rY(),ot=er(),on=ea(),or=new Set,oo=!1;function oi(e){if(null===e)or=null;else if(null!==or)for(let t of e)or.add(t);r2(oa)}function oa(){if(!oo){oo=!0;try{for(let e=1;;e++){let t=or;if(null!==t&&0===t.size)return;or=new Set;try{!function(e,t,n,r,o,i=null){let a=oe.getState().slots,s={},l=!1,c=Object.entries(r.flags).filter(([,{enabled:e}])=>e).map(([e])=>e);for(let[r,u]of Object.entries(e.slots)){let d=a[r];if(d&&i&&!i.has(r)){s[r]=d;continue}let{config:m}=ei(t,u.name),p=function(e,t,n,r,o,i){let a=function(e,t){let n=e.add||[],r=e.remove||[],o=e.order||[],{extensions:i}=r9.getState(),a=new Set(r),s=[...t,...n].filter(e=>!a.has(e)),l=og(o),c=og(t),u=new Map(s.map(e=>[e,function(e,t,n,r){let o=t.get(e);if(void 0!==o)return o;{if(void 0!==n)return 1e3+n;let t=r.get(e);return void 0!==t?2e3+t:3e3}}(e,l,i[oc(e)]?.order,c)]));return s.sort((e,t)=>u.get(e)-u.get(t))}(n,t.slots[e].attachedIds),s=[];for(let l of a){let{config:a}=es(r,e,l),c=el(n,e,l),u=c?(0,rD.A)({},a,c):a,d=oc(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&&!o.includes(m.featureFlag))continue;s.push({id:l,name:d,moduleName:m.moduleName,config:u,featureFlag:m.featureFlag,meta:m.meta,displayConditionExpression:u?.["Display conditions"]?.expression||m.displayExpression})}}return s}(r,e,m,n,c,o.session);d&&d.moduleName===u.moduleName&&(0,F.A)(d.candidateExtensions,p)?s[r]=d:(s[r]={moduleName:u.moduleName,candidateExtensions:p},l=!0)}(l||Object.keys(a).length!==Object.keys(s).length)&&oe.setState({slots:s})}(r9.getState(),ot.getState(),on.getState(),rR.getState(),tA.getState(),t)}catch(e){throw or=null===t||null===or?null:new Set([...t,...or]),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{oo=!1}}}function os(e,t){let n=new Set;for(let r of Object.keys(e))e[r]!==t[r]&&n.add(r);for(let r of Object.keys(t))r in e||n.add(r);return n}function ol(e,t){return{moduleName:t,name:e,attachedIds:[]}}function oc(e){let[t]=e.split("#");return t}function ou(e,t){let n=oc(t);return e.extensions[n]}function od(e){return ou(r9.getState(),e)}r9.subscribe((e,t)=>{oi(e.extensions!==t.extensions?null:os(e.slots,t.slots))}),ot.subscribe((e,t)=>{oi(os(e.slots,t.slots))}),on.subscribe((e,t)=>{oi(os(e.configs,t.configs))}),rR.subscribe(()=>oi(null)),tA.subscribe(()=>oi(null)),oi(null);let om=e=>rV(t=>({...t,extensions:{...t.extensions,[e.name]:{...e}}}));function op(e,t){rV(n=>{let r=n.slots[e];return r?{...n,slots:{...n.slots,[e]:{...r,attachedIds:[...r.attachedIds,t]}}}:{...n,slots:{...n.slots,[e]:{...ol(e),attachedIds:[t]}}}})}function of(e,t){rV(n=>{let r=n.slots[e];return r&&r.attachedIds.includes(t)?{...n,slots:{...n.slots,[e]:{...r,attachedIds:r.attachedIds.filter(e=>e!==t)}}}:n})}function oh(e){rV(t=>{let n=t.slots[e];return n?{...t,slots:{...t.slots,[e]:{...n,attachedIds:[]}}}:t})}function og(e){let t=new Map;return e.forEach((e,n)=>{t.has(e)||t.set(e,n)}),t}function ow(e,t){return function(e,t,n=null,r){let o;return e.filter(e=>{let i=e.displayConditionExpression;if("string"!=typeof i||0===i.trim().length)return!0;o??(o=t&&"object"==typeof t?{session:n,...t}:{session:n});try{return!!rs(i,o)}catch(t){return console.error(`Error while evaluating expression '${i}' for ${e.id}`+(r?` in ${r}`:""),t),!1}})}(o_(e),t,tA.getState().session,e)}function o_(e){return oe.getState().slots[e]?.candidateExtensions??[]}let oy=(e,t)=>r9.setState(n=>{let r=n.slots[t]?.moduleName;if(r&&r!=e)return console.warn(`An extension slot with the name '${t}' already exists. Refusing to register the same slot name twice (in "registerExtensionSlot"). The existing one is from module ${r}.`),n;if(r&&r==e)return n;if(n.slots[t])return{...n,slots:{...n.slots,[t]:{...n.slots[t],moduleName:e}}};let o=ol(t,e);return{...n,slots:{...n.slots,[t]:{...o}}}}),ov=()=>{or=null,rV(()=>({slots:{},extensions:{}})),rH().setState({renderings:new Map}),oe.setState({slots:{}})},ob=R("left-nav",{slotName:null,basePath:window.spaBase,mode:"normal"});function ox({name:e,basePath:t,mode:n,componentContext:r,state:o}){ob.setState({slotName:e,basePath:t,mode:n??"normal",componentContext:r,state:o})}function oS(e){ob.getState().slotName===e&&ob.setState(ob.getInitialState(),!0)}let ok=R("modalRegistry",{modals:{}});function oj(e){ok.setState(t=>(t.modals[e.name]=e,t))}function oN(e){let t=ok.getState().modals[e];if(!t){let n=od(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.`),oj(t))}return t}let oE=R("workspace2",{registeredGroupsByName:{},registeredWindowsByName:{},registeredWorkspacesByName:{},openedGroup:null,openedWindows:[],isMostRecentlyOpenedWindowHidden:!1});function oC(e){let{registeredWorkspacesByName:t,registeredWindowsByName:n}=oE.getState(),r=t[e];if(r){let t=n[r.window];if(t)return t;throw Error(`No workspace window found with name: ${r.window} for workspace: ${e}`)}throw Error(`No workspace found with name: ${e}`)}function oP(e){let{registeredGroupsByName:t,registeredWindowsByName:n}=oE.getState(),r=n[e];if(r){let n=t[r.group];if(n)return n;throw Error(`No workspace group found with name: ${r.group} for window: ${e}`)}throw Error(`No workspace window found with name: ${e}`)}function oI(e){let{openedWindows:t}=oE.getState();return t.findIndex(t=>t.openedWorkspaces.find(t=>t.workspaceName===e))}function oA(e,t){if(0==t.length)return;let{registeredGroupsByName:n}=oE.getState(),r={...n};for(let n of t){if(r[n.name])throw Error(`Cannot register workspace group ${n.name} more than once`);r[n.name]={...n,moduleName:e}}oE.setState({registeredGroupsByName:r})}function oO(e,t){if(0==t.length)return;let{registeredWindowsByName:n}=oE.getState(),r={...n};for(let n of t){if(r[n.name])throw Error(`Cannot register workspace window ${n.name} more than once`);let t={...n,moduleName:e};r[n.name]=t}oE.setState({registeredWindowsByName:r})}function oR(e,t){if(0==t.length)return;let{registeredWorkspacesByName:n}=oE.getState(),r={...n};for(let n of t){if(r[n.name])throw Error(`Cannot register workspace ${n.name} more than once`);let t={...n,moduleName:e};r[n.name]=t}oE.setState({registeredWorkspacesByName:r})}let o$=0,oT=null,oM={bootstrap:15e3,mount:15e3,unmount:15e3};function oL(e,t){if(e.timeouts)return e;let n=e.name??"parcel",r=Object.fromEntries(Object.keys(oM).filter(t=>e[t]).map(r=>{var o,i;let a,s;return[r,(o=e[r],i=oM[r],a=Array.isArray(o)?o:[o],s=e=>a.reduce((t,o,i)=>t.then(()=>{let t=o(e);return"function"==typeof t?.then&&"function"==typeof t?.catch?t:Promise.reject(Error(`Lifecycle function ${r} at array index ${i} for parcel ${n} did not return a promise`))}),Promise.resolve(void 0)),e=>{let o,a=new Promise((e,t)=>{o=setTimeout(()=>t(Error(`Lifecycle function ${r} for parcel ${n} did not settle within ${i}ms`)),i)});return Promise.race([s(e),a]).finally(()=>clearTimeout(o)).then(e=>(t(r,!1),e),e=>{throw t(r,!0),e})})]}));return{...e,...r}}async function oW(e,t){var n,r;let o,i,a,s,l,c=await (oT??(oT=new Promise((e,t)=>{(0,ts.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),ts.xL))),oT),u={...t},d=(o=u,i=!1,{retarget:e=>o={...e},release:a=()=>(function(e){for(let t of Object.keys(e))delete e[t]})(o),onSettled(e,t){switch(e){case"bootstrap":t&&a();return;case"mount":i||(i=t);return;case"unmount":(t||i)&&a();return}}});return r=c((n=d.onSettled,"function"==typeof e?()=>e().then(e=>oL(e,n)):oL(e,n)),u),s=e=>t=>e.call(r,d.retarget(t)).catch(e=>{throw"SKIP_BECAUSE_BROKEN"===r.getStatus()&&d.release(),e}),l=r.update&&s(r.update),Object.defineProperty(r,"update",{configurable:!0,enumerable:!0,get:()=>l,set:e=>{l=e&&s(e)}})}function oD(){return oU}function oU(e,t){let n,r=oW(e,t).then(e=>n=e);return{mount:()=>r.then(e=>e.mount()),unmount:()=>r.then(e=>e.unmount()),update:e=>r.then(t=>t.update?.(e)),getStatus:()=>n?.getStatus()??"LOADING_SOURCE_CODE",get loadPromise(){return r.then(e=>e.loadPromise)},get bootstrapPromise(){return r.then(e=>e.bootstrapPromise)},get mountPromise(){return r.then(e=>e.mountPromise)},get unmountPromise(){return r.then(e=>e.unmountPromise)}}}async function oB(e,t,n,r,o=e=>e,i={}){let a=oc(r),s=od(r),l=null;if(e){let c;if(!s)throw Error(`Couldn't find extension '${a}' to attach to '${t}'`);let{meta:u,moduleName:d,load:m}=s,p=o$++,f=`${t}/${r}-${p}`;e.dataset.extensionRenderingId=f;let h=e=>{try{rX(f)}catch(t){console.error(e,t)}};try{rK({renderingId:f,extensionName:a,extensionModuleName:d,extensionId:r,slotName:t,slotModuleName:n})}catch(e){throw h(`Recomputing configuration after registering '${r}' failed also failed`),e}try{c=await m()}catch(e){throw h(`Recomputing configuration after '${r}' failed to load also failed`),e}try{l=await oW(o({...c,name:`${t}/${a}-${p}`}),{...i,_meta:u,_extensionContext:{extensionId:r,extensionSlotName:t,extensionSlotModuleName:n,extensionModuleName:d,extensionMeta:u},domElement:e})}catch(e){throw h(`Recomputing configuration after '${r}' failed to mount also failed`),e}l.mountPromise.then(void 0,e=>{console.error(`Extension '${r}' in slot '${t}' failed to mount`,e),h(`Recomputing configuration after '${r}' failed to mount also failed`)}),l.unmountPromise.then(()=>h(`Recomputing configuration after unmounting '${r}' failed`),e=>{console.error(`Extension '${r}' in slot '${t}' failed to unmount`,e),h(`Recomputing configuration after '${r}' failed to unmount also failed`)})}else console.warn(`Tried to render ${r} into ${t} but no DOM element was available.`);return l}var oF=n(6925),oH=n.n(oF);let oV=(0,oF.createContext)({moduleName:"",featureName:""});function oG({to:e,templateParams:t,onBeforeNavigate:n,children:r,...o}){return(0,oF.useEffect)(()=>{o.href&&console.warn(`ConfigurableLink does not support the href prop. Use the 'to' prop instead. The provided href value is '${o.href}'`),o.onClick&&console.warn(`ConfigurableLink does not support the onClick prop. Use the 'onBeforeNavigate' prop instead. The 'to' prop of the offending link is ${e}`)},[]),oH().createElement("a",{onClick:r=>{0===r.button&&!r.ctrlKey&&!r.shiftKey&&!r.altKey&&!r.metaKey&&(r.preventDefault(),n?.(r),th({to:e,templateParams:t})),0===r.button&&(r.ctrlKey||r.metaKey)&&n?.(r),0===r.button&&r.shiftKey&&n?.(r),1===r.button&&n?.(r)},href:tp(e,t),...o},r)}let oz=({state:e,children:t,...n})=>{let{extension:r}=(0,oF.useContext)(oV),o=(0,oF.useRef)(null),i=(0,oF.useRef)(Promise.resolve()),a=(0,oF.useRef)(!1),s=(0,oF.useRef)(!1),l=(0,oF.useRef)(e),c=(0,oF.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,oF.useCallback)((e,t)=>{e.update&&"UNMOUNTING"!==e.getStatus()&&(i.current=Promise.all([e.mountPromise,i.current]).then(()=>{if(o.current?.getStatus()==="MOUNTED"&&o.current.update)return o.current.update({...t})}).catch(e=>{let t=o.current?.getStatus();"UNMOUNTING"!==t&&"NOT_MOUNTED"!==t&&"UNLOADING"!==t&&console.error(`The extension '${r?.extensionId}' failed to update`,e)}))},[]),d=(0,oF.useCallback)(t=>{t&&!o.current&&!s.current&&r?.extensionSlotName&&r.extensionSlotModuleName&&(s.current=!0,oB(t,r.extensionSlotName,r.extensionSlotModuleName,r.extensionId,void 0,e).then(t=>{(s.current=!1,o.current=t,a.current)?c(t):t&&l.current!==e&&u(t,l.current)},()=>{s.current=!1}))},[]);return(0,oF.useEffect)(()=>(a.current=!1,()=>{a.current=!0,c(o.current)}),[]),(0,oF.useEffect)(()=>{l.current=e,o.current&&u(o.current,e)},[e]),r?oH().createElement("div",{ref:d,"data-extension-id":r?.extensionId,style:{position:"relative"},...n}):null};function oq(e){let t=(0,oF.useRef)(e);return x(t.current,e)||(t.current=e),t.current}function oJ(e,t){"function"==typeof t&&(t=t(e));let n={};for(let[r,o]of Object.entries(t)){let t=function(...t){e.setState(e=>o(e,...t))};n[r]=t}return n}let oK=e=>e;function oX(e,t=oK,n){let r=(0,oF.useCallback)(t=>e.subscribe(t),[e]),o=(0,oF.useCallback)(()=>t(e.getState()),[e,t]),i=(0,oF.useSyncExternalStore)(r,o,o),a=(0,oF.useMemo)(()=>n?oJ(e,n):null,[e,n]);return(0,oF.useMemo)(()=>a?{...i,...a}:i,[i,a])}function oY(e,t){return oX(e,oK,t)}function oZ(e){return function(t){let n=(0,oF.useCallback)(t=>e.subscribe(t),[]),r=(0,oF.useCallback)(()=>e.getState(),[]),o=(0,oF.useSyncExternalStore)(n,r,r),i=(0,oF.useMemo)(()=>t?oJ(e,t):null,[t]);return(0,oF.useMemo)(()=>i?{...o,...i}:o,[o,i])}}let oQ=[];Object.freeze(oQ);let o0={candidateExtensions:oQ};Object.freeze(o0);let o1=e=>{let t=(0,oF.useCallback)(t=>t.slots?.[e]??o0,[e]);return oX(rY(),t)},o2=e=>e.session;function o5(e,t){let{candidateExtensions:n}=o1(e),r=oX(tA,o2),o=oq(t);return(0,oF.useMemo)(()=>ow(e,o),[e,o,r,n])}function o6(e,t){let{moduleName:n}=(0,oF.useContext)(oV);if(!n)throw Error("ComponentContext has not been provided. This should come from @openmrs/esm-react-utils.");return(0,oF.useEffect)(()=>{oy(n,e)},[n,e]),{extensions:o5(e,t),extensionSlotName:e,extensionSlotModuleName:n}}function o8(e){return e}function o3({name:e,extensionSlotName:t,select:n=o8,children:r,state:o,style:i,...a}){if(r&&o)throw Error("Both children and state have been provided. If children are provided, the state must be passed as a prop to the `Extension` component.");let s=e??t,l=(0,oF.useRef)(null),{extensions:c,extensionSlotModuleName:u}=o6(s,o),d=(0,oF.useMemo)(()=>n(c),[n,c]),m=(0,oF.useMemo)(()=>{if("function"==typeof r&&!oH().isValidElement(r))return d.map(e=>r(e,o))},[r,d]);return oH().createElement("div",{ref:l,"data-extension-slot-name":s,"data-extension-slot-module-name":u,style:{...i,position:"relative"},...a},s&&d?.map((e,t)=>oH().createElement(oV.Provider,{key:e.id,value:{moduleName:u,featureName:"",extension:{extensionId:e.id,extensionSlotName:s,extensionSlotModuleName:u,extensionMeta:e.meta}}},m?.[t]??("function"!=typeof r?r:null)??oH().createElement(oz,{state:o}))))}var o4=n(3776),o7=n(9568),o9=n(9737),ie=n(2324),it=n(242);let ir={strictMode:!0,throwErrorsToConsole:!0,disableTranslations:!1},io=new Map;(0,it.y)(io);let ii={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:()=>io};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={...ii,...t.swrConfig};return function(e){var r,o,i,a,s;return i=o=class extends(r=oH().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 oH().createElement("div",null,"An error has occurred. Please try reloading the page.");{let r=oH().createElement(oF.Suspense,{fallback:null},oH().createElement(ie.S,{value:n},oH().createElement(oV.Provider,{value:this.state.config},t.disableTranslations?oH().createElement(e,this.props):oH().createElement(o9.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},oH().createElement(e,this.props)))));return t.strictMode&&oH().StrictMode?oH().createElement(oH().StrictMode,null,r):r}}constructor(e){super(e),this.state={caughtError:null,caughtErrorInfo:null,config:{moduleName:t.moduleName,featureName:t.featureName,extension:e._extensionContext}}}},a="displayName",s=`OpenmrsReactComponent(${t.featureName})`,a in i?Object.defineProperty(i,a,{value:s,enumerable:!0,configurable:!0,writable:!0}):i[a]=s,o}}function is(e,t){return(0,o7.A)({React:oH(),ReactDOMClient:o4,rootComponent:ia(t)(e)})}function il(e,t){return()=>e().then(({default:e})=>is(e,t))}function ic(e,t){return()=>Promise.resolve(is(e,t))}let iu=il,id=(0,E.y)()(()=>({}));T("openmrs-app-context",id);let im={};function ip(e,t=e=>e){let n=id.getState();return e in n?Object.freeze(Object.assign({},t?t(n[e]):n[e])):null}function ih(e,t){id.setState(n=>(e in n||(n[e]={}),n[e]=t(n[e]),Object.assign({},n)))}function ig(e){return null===e?null:Object.freeze(Object.assign({},e))}let iw=new Map;function i_(e,t){let n=(0,oF.useRef)(t??{}),r=(0,oF.useRef)(t=>ih(e,t)),o=(0,oF.useRef)(Symbol());return(0,oF.useEffect)(()=>{let n=t??{},r=o.current;return null===ip(e)?!function(e,t=im){id.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===im?{}: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)),iw.set(e,r),()=>{iw.get(e)===r&&(id.setState(t=>(e in t&&delete t[e],t)),iw.delete(e))}},[e]),(0,oF.useEffect)(()=>{let r=t??{};x(n.current,r)||(ih(e,()=>r),n.current=r)},[t]),r.current}function iy({namespace:e,value:t}){return i_(e,t),null}let iv=({children:e,value:t,fallback:n})=>t?oH().createElement(oH().Fragment,null,e):n?oH().createElement(oH().Fragment,null,n):null;function ib(){let e=(0,oF.useRef)();return(!e.current||e.current.signal.aborted)&&(e.current=new AbortController),(0,oF.useEffect)(()=>{let t=e.current;return()=>t?.abort()},[]),e.current}function ix(e,t=e=>e??{}){let[n,r]=(0,oF.useState)(()=>{if(iS(e))return;let n=ip(e);if(null!==n)return t?t(n):n});return(0,oF.useEffect)(()=>{if(iS(e))throw Error(`The namespace supplied to useAppContext must be a non-empty string, but was "${e}".`)},[e]),(0,oF.useEffect)(()=>{var n;let o;return(n=e=>{if(null==e)return void r(void 0);let n=t?t(e):e;r(e=>x(e,n)?e:n)})(ig(o=ip(e))),id.subscribe(t=>{let r=e in t?t[e]:null;r!==o&&(o=r,n(ig(r)))})},[e,t]),n}function iS(e){return"string"!=typeof e||0===e.trim().length}function ik(e){let t=o5(e);return(0,oF.useMemo)(()=>t.map(e=>e.id),[t])}function ij(e){return o1(e).candidateExtensions}function iN(e,t,n){let{data:r,error:o,mutate:i,isLoading:a,isValidating:s}=(0,ie.u)(e?nU(e,t,n):null,tP);return(0,oF.useMemo)(()=>({isLoading:a,data:r?.data.results??[],error:o,mutate:i,isValidating:s}),[r,o,a,s,i])}function iE(e){(0,oF.useEffect)(()=>{if(e){let e=window.getComputedStyle(document.body).overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=e}}},[e])}let iC={},iP=`No ComponentContext has been provided. This should come from "openmrsComponentDecorator".
|
|
16
16
|
Usually this is already applied when using "getAsyncLifecycle" or "getSyncLifecycle".`;function iI(e,t,n){let r=iC[e];if(r)return r;let o=new Promise(e=>{let r=n(t.getState());if(r)return void e(r);let o=t.subscribe(t=>{let r=n(t);r&&(o(),e(r))})});return iC[e]=o,o.then(()=>{iC[e]===o&&delete iC[e]}),o}function iA(e){let{moduleName:t,extension:n}=(0,oF.useContext)(oV),r=e?.externalModuleName??t;if(!r&&!n)throw Error(iP);let o=function(e){let t=(0,oF.useMemo)(()=>en(e),[e]),n=function(e){let[t,n]=(0,oF.useState)(()=>{let t=e.getState();return t.loaded&&t.config?t.config:null});return(0,oF.useEffect)(()=>e?.subscribe(e=>{e.loaded&&e.config&&n(e.config)}),[e]),t}(t);if(!n)throw iI(e,t,e=>e.loaded?e.config:null);return n}(r),i=function(e){let t=(0,oF.useMemo)(ea,[]),n=function(e,t){let[n,r]=(0,oF.useState)(t?()=>{let n=es(e.getState(),t.extensionSlotName,t.extensionId);if(n.loaded&&n.config)return n.config}:null);return(0,oF.useEffect)(()=>{if(t)return e.subscribe(e=>{let o=es(e,t.extensionSlotName,t.extensionId);o.loaded&&o.config&&!(0,F.A)(o.config,n)&&r(o.config)})},[e,t,n]),n}(t,e);if(!n&&e)throw iI(`${e.extensionSlotName}-${e.extensionId}`,t,t=>{let n=es(t,e.extensionSlotName,e.extensionId);return n.loaded?n.config:null});return n||{}}(n);return(0,oF.useMemo)(()=>e?.externalModuleName&&r===e.externalModuleName?{...o}:{...o,...i},[r,e?.externalModuleName,o,i])}let iO=o5;function iR(e,t=300){let[n,r]=(0,oF.useState)(e);return(0,oF.useEffect)(()=>{let n=setTimeout(()=>{r(e)},t);return()=>{clearTimeout(n)}},[e,t]),n}var i$=n(6269);let iT=`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 iM(){let e=`${tj}/emrapi/configuration?v=${iT}`,t=(0,i$.A)(e,tP);return(0,oF.useMemo)(()=>({emrConfiguration:t.data?.data,isLoadingEmrConfiguration:t.isLoading,mutateEmrConfiguration:t.mutate,errorFetchingEmrConfiguration:t.error}),[t])}function iL(){return(0,oF.useContext)(oV).extension}let iW=oZ(rF());function iD(e){let t=o5(e);return(0,oF.useMemo)(()=>Object.fromEntries(t.map(e=>[e.name,e.meta])),[t])}let iU=oZ(rY());function iB(e){let{flags:t}=oX(rR);return t[e]?.enabled??!1}function iF(){let[,e]=(0,oF.useState)(0);return(0,oF.useCallback)(()=>{e(e=>e+1)},[])}function iH(e,t,n={}){return iG(e,t,iV,n)}let iV={getPaginatedUrl:(e,t,n)=>{if(!e)return null;{let r=new URL(tC(e.toString()),window.location.toString());return r.searchParams.set("limit",""+t),r.searchParams.set("startIndex",""+n),r.searchParams.set("totalCount","true"),r.toString()}},getNextUrl:e=>{let t=e?.links?.find(e=>"next"==e.rel)?.uri;if(!t)return null;{let e=new URL(t);return e.host=window.location.host,e.protocol=window.location.protocol,e.toString()}},getTotalCount:e=>e?.totalCount??NaN,getCurrentPageSize:e=>e?.results?.length??NaN,getData:e=>e?.results};function iG(e,t,n,r={}){let{getPaginatedUrl:o,getTotalCount:i,getCurrentPageSize:a,getData:s}=n,{immutable:l,swrConfig:c}=r,u=r.fetcher??tP,[d,m]=(0,oF.useState)(1),p=(0,oF.useRef)(NaN),f=(0,oF.useRef)(NaN),h=(0,oF.useRef)(d),g=(0,oF.useRef)(!1),w=(0,oF.useRef)(!1),_=e?.toString()??"",[y,v]=(0,oF.useState)(_);_!==y&&(v(_),m(1),h.current=1,p.current=NaN,f.current=NaN,g.current=!1,w.current=!1);let b=(d-1)*t,x=(0,oF.useMemo)(()=>o(e,t,b),[e,t,b]),{data:S,...k}=(l?i$.A:ie.u)(x,u,c);S?.data&&(p.current=i(S?.data),f.current=a(S?.data),g.current=!0);let j=Math.ceil(p.current/t),N=(0,oF.useCallback)(e=>{if(!Number.isInteger(e)||e<1)return void console.warn(`useServerPagination: ignoring goTo(${e}); page must be a positive integer.`);let n=Math.ceil(p.current/t);!g.current||Number.isNaN(n)||e<=n?(h.current=e,m(e)):console.warn("Invalid attempt to go to out of bounds page: "+e)},[t]);(0,oF.useEffect)(()=>{if(!g.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}.`),h.current=e,m(e))},[d,t,_,S]);let E=(0,oF.useCallback)(()=>{N(h.current+1)},[N]),C=(0,oF.useCallback)(()=>{N(h.current-1)},[N]);return{data:s(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 iz(e,t,n={}){return iG(e,t,iq(),n)}function iq(){return{getPaginatedUrl:(e,t,n)=>{if(!e)return null;{let r=new URL(tC(e.toString()),window.location.toString());return r.searchParams.set("_count",""+t),r.searchParams.set("_getpagesoffset",""+n),r.toString()}},getNextUrl:e=>{let t=e?.link?.find(e=>"next"==e.relation)?.url;if(!t)return null;{let e=new URL(t);return e.host=window.location.host,e.protocol=window.location.protocol,e.toString()}},getTotalCount:e=>e?.total??NaN,getCurrentPageSize:e=>e?.entry?.length??NaN,getData:e=>e?.entry?.map(e=>e.resource)}}var iJ=n(3709);function iK(e,t={}){return iX(e,iV,t)}function iX(e,t,n={}){let{swrInfiniteConfig:r,immutable:o}=n,{getNextUrl:i,getTotalCount:a,getData:s}=t,l=n.fetcher??tP,c=(0,oF.useCallback)((n,r)=>0==n?e?.toString()??null:t.getNextUrl(r.data),[e]),{data:u,size:d,setSize:m,...p}=(0,iJ.Ay)(c,l,{...r,...o?{revalidateIfStale:!1,revalidateOnFocus:!1,revalidateOnReconnect:!1}:{}}),f=i(u?.[u.length-1].data),h=a(u?.[0]?.data);return{data:u?.flatMap(e=>s(e.data)),totalCount:h,hasMore:null!=f,loadMore:()=>{m((u?.length??0)+1)},nextUri:f,...p}}function iY(e,t={}){return iZ(e,iV,t)}function iZ(e,t,n={}){let r=iX(e,t,n),{hasMore:o,error:i,data:a,loadMore:s,isLoading:l,nextUri:c}=r;return((0,oF.useEffect)(()=>{o&&!i&&s()},[o,c]),n.partialData)?r:{...r,data:o||i?void 0:a,isLoading:l||o}}function iQ(e,t={}){return iZ(e,iq(),t)}function i0(e,t={}){return iX(e,iq(),t)}function i1(){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 i2(){let[e,t]=(0,oF.useState)(i1);return(0,oF.useEffect)(()=>{let e=()=>{t(i1())};return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),e}let i5=e=>"small-desktop"===e||"large-desktop"===e;function i6(e){let t=(0,oF.useContext)(oV);(0,oF.useEffect)(()=>(t&&t.moduleName&&(e.componentContext=t),ox(e),()=>{oS(e.name)}),[t,e])}function i8(){return oX(ob)}let i3=[];function i4(e=null,t=null){let n=new URLSearchParams;e&&n.set("tag",e),t&&n.set("q",t);let r=n.toString(),{data:o}=iY(`${tj}/location${r?"?"+r:""}`,{immutable:!0});return o??i3}function i7(e,t=!0){let n=(0,oF.useRef)(null);return(0,oF.useEffect)(()=>{let r=r=>{t&&n.current&&r.target&&r.target instanceof Node&&(n.current.contains(r.target)||e(r))};return window.addEventListener("mousedown",r),window.addEventListener("touchstart",r),()=>{window.removeEventListener("mousedown",r),window.removeEventListener("touchstart",r)}},[e,t]),n}function i9(e){let t=(0,oF.useRef)();return(0,oF.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 ae(e,t={}){let{abortController:n,fetchInit:r,url:o,swrConfig:i}=t,a=ib(),s=(0,oF.useMemo)(()=>r?.signal??n?.signal??a.signal,[n?.signal,r?.signal,a.signal]),l=(0,oF.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,o),{...r,signal:s}),[s,r,o]);return(0,ie.u)(e,l,i)}function at(e=[],t=10){let[n,r]=(0,oF.useState)(1),o=(0,oF.useMemo)(()=>"number"==typeof t&&t>0?Math.max(1,Math.ceil(e.length/t)):1,[e.length,t]);n>o&&r(o);let i=Math.min(Math.max(1,n),o),a=(0,oF.useMemo)(()=>{let n=(i-1)*t,r=(i+0)*t;return e.slice(n,r)},[e,i,t]),s=(0,oF.useCallback)(e=>{!Number.isInteger(e)||e<1?console.warn(`usePagination: ignoring goTo(${e}); page must be a positive integer.`):r(e)},[]),l=(0,oF.useCallback)(()=>{r(e=>e+1)},[]),c=(0,oF.useCallback)(()=>{r(e=>Math.max(1,e-1))},[]);return(0,oF.useMemo)(()=>({results:a,totalPages:o,currentPage:i,paginated:e.length>t,showNextButton:i<o,showPreviousButton:i>1,goTo:s,goToNext:l,goToPrevious:c}),[a,o,e.length,t,i,s,l,c])}function an(e,t,n,r){return{pageSizes:(0,oF.useMemo)(()=>{let n=Math.ceil(t/e);return isNaN(n)&&(n=0),[...Array(n).keys()].map(t=>(t+1)*e)},[e,t]),pageItemsCount:(0,oF.useMemo)(()=>e>t?t:e*n>t?e*(n-1)+r:e*n,[e,t,n,r])}}function ar(){let e=/\/patient\/([a-zA-Z0-9\-]+)\/?/.exec(location.pathname);return e&&e[1]}function ao(e){let[t,n]=(0,oF.useState)(e??ar()),{data:r,error:o,isValidating:i}=(0,ie.u)(t?["patient",t]:null,()=>nH(t,{}));return(0,oF.useEffect)(()=>{let e=()=>{let e=ar();e!==t&&n(e)};return window.addEventListener("single-spa:routing-event",e),()=>window.removeEventListener("single-spa:routing-event",e)},[t]),(0,oF.useMemo)(()=>({isLoading:i&&!o&&!r,patient:r,patientUuid:t,error:o}),[i,o,r,t])}function ai(){let e=`${tj}/metadatamapping/termmapping?v=custom:(metadataUuid)&code=emr.primaryIdentifierType`,{data:t,error:n,isLoading:r}=(0,ie.u)(e,tP);return(0,oF.useMemo)(()=>({primaryIdentifierCode:t?.data?.results[0]?.metadataUuid,isLoading:r,error:n}),[t,n,r])}function aa(e){let{extensions:t,extensionSlotModuleName:n}=o6(e);return e?t.map(t=>({state:r})=>oH().createElement(oV.Provider,{value:{moduleName:n,featureName:"",extension:{extensionId:t.id,extensionSlotName:e,extensionSlotModuleName:n,extensionMeta:t.meta}}},oH().createElement(oz,{state:r}))):[]}function as(){let e=(0,oF.useRef)(),[t,n]=(0,oF.useState)(null),r=null;if(!t){if(i){let e=tM().getState();e.loaded&&(r=e.session)}else i=new Promise(t=>{let n=({loaded:n,session:o})=>{n&&(t(o),r=o,e.current&&(e.current(),e.current=void 0))};n(tM().getState()),r||(e.current=tM().subscribe(n))});if(r)n(r);else throw i}(0,oF.useEffect)(()=>(e.current||(e.current=tM().subscribe(({loaded:e,session:t})=>{e&&(r=t,n(t))})),()=>{e.current&&(e.current(),e.current=void 0)}),[]);let o=t||r;if(!o)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 o}let al=({privilege:e,fallback:t,children:n})=>{let[r,o]=(0,oF.useState)(null);return((0,oF.useEffect)(()=>{let e=tM(),t=e.subscribe(({loaded:e,session:t})=>{o(e?t?.user??null:null)}),{loaded:n,session:r}=e.getState();return n&&o(r?.user??null),t},[]),r&&tU(e,r))?oH().createElement(oH().Fragment,null,n):t?oH().createElement(oH().Fragment,null,t):null};var ac=n(4343),au=n.n(ac),ad=n(3355);let am=new Map;function ap(){for(let e of Array.from(am.values()))e()}let af={setVisitContext:(e,t)=>null==t?{manuallySetVisitUuid:null}:{manuallySetVisitUuid:t.uuid,patientUuid:t.patient?.uuid}};function ah(e){let t=(0,oF.useId)();return(0,oF.useEffect)(()=>{if(e)return am.set(t,e),()=>{am.delete(t)}},[t,e]),{...oY(n1(),af),mutateVisit:ap}}function ag(e,t=nQ){let n=(0,oF.useRef)(void 0),{patientUuid:r,manuallySetVisitUuid:o,setVisitContext:i}=ah((0,oF.useCallback)(()=>n.current?.(),[])),a=e&&r==e?o:null,s=`?patient=${e}&v=${t}&includeInactive=false`,l=`/${a}?v=${t}`,{data:c,error:u,mutate:d,isValidating:m}=(0,ie.u)(e?`${tj}/visit${s}`:null,tP),{data:p,error:f,mutate:h,isValidating:g}=(0,ie.u)(e&&a?`${tj}/visit${l}`:null,tP),w=(0,oF.useMemo)(()=>c?.data.results.find(e=>null===e.stopDatetime)??null,[c]),_=(0,oF.useMemo)(()=>a&&p?p.data:null,[p,a]),y=(0,oF.useRef)(null);(0,oF.useEffect)(()=>{!m&&w&&r===e&&null===o&&i(w),g||(y.current&&_&&y.current.uuid===_.uuid&&!y.current.stopDatetime&&_.stopDatetime&&i(null),y.current=_)},[_,o,w,m,g,r]);let v=(0,oF.useCallback)(()=>{d(),h()},[d,h]);(0,oF.useEffect)(()=>{n.current=v},[v]);let b=!!(!c||a&&!p),x=!!(a?f:u);return{error:u||f,mutate:v,isValidating:m||g,activeVisit:w,currentVisit:_,currentVisitIsRetrospective:!!a,isLoading:b&&!x}}ac.extend(ad);let aw=[];function a_(){let{data:e}=(0,i$.A)(nK,nX);return e??aw}let ay=new Map;async function av(e,t){let n=t.indexOf("#"),r=n>=0,o=r?t.substring(0,n):e,i=r?t.substring(n+1):t,a=await np(o);return a&&Object.hasOwn(a,i)&&"function"==typeof a[i]?ax(o,a).then(()=>a[i]()):(a?a&&Object.hasOwn(a,i)?console.warn(`The export ${t}, defined in ${e}'s routes.json, is not a function`):console.warn(`${o} does not define a component called "${i}", referenced in ${e}'s routes.json. This cannot be loaded.`):console.warn(`Unknown app ${o} for ${t} defined in ${e}'s routes.json`),ab)}let ab={bootstrap:()=>Promise.resolve(),mount:()=>Promise.resolve(),unmount:()=>Promise.resolve()};async function ax(e,t){if(e in ay)await ay[e];else{let n=t??await np(e);await (ay[e]=new Promise((t,r)=>{if(Object.hasOwn(n,"startupApp")){let o=n.startupApp;if("function"==typeof o)return Promise.resolve(o()).then(()=>{eA(e),t(null)}).catch(r)}eA(e),t(null)}))}}function aS(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
|