@openmrs/esm-report-builder 0.1.1-pre.138 → 0.1.1-pre.141
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/2720.js
CHANGED
|
@@ -9,7 +9,7 @@ If you're the maintainer: the allowed types are ${Object.values(nc).join(", ")}.
|
|
|
9
9
|
If you're the maintainer: all config elements must have a default. Received ${JSON.stringify(i)}`),s&&l&&![nc.Array,nc.Object].includes(l)&&console.error(`${e} has bad config schema definition for key '${o}'. ${n}.
|
|
10
10
|
|
|
11
11
|
If you're the maintainer: the 'elements' key only works with '_type' equal to 'Array' or 'Object'. Received ${JSON.stringify(l)}`)}}function n9(e,t){return n8(t.map(({[e]:t})=>t).filter(e=>!!e))}function n8(e){return e.reduce((e,t)=>tK(e,t,nF),{})}function n7(e,t,r=""){for(let n of Object.keys(t)){let a=t[n],o=r+"."+n,i=e[n];if(!e.hasOwnProperty(n)){("extensionSlots"!==n||""===r)&&as(o,`Unknown config key '${o}' provided. Ignoring.`);continue}(function e(t,r,n){at(n,t._type,r),ao(r)?t._type===nc.Object?function(t,r,n){if(t._elements)for(let a of Object.keys(r)){let o=r[a];e(t._elements,o,`${n}.${a}`)}}(t,r,n):t.hasOwnProperty("_default")||t.hasOwnProperty("_type")||n7(t,r,n):t._type===nc.Array&&function(t,r,n){if(at(n,nc.Array,r)){if(aa(t._elements))for(let a=0;a<r.length;a++)e(t._elements,r[a],`${n}[${a}]`);for(let e=0;e<r.length;e++)at(`${n}[${e}]`,t._elements?._type,r[e])}}(t,r,n)})(i,a,o)}}function ae(e,t,r=""){if(e){if(t!==e._default&&ar(r,e._validators,t),ao(t))for(let n of Object.keys(t)){let a=t[n],o=r+"."+n,i=e[n];e._type===nc.Object&&e._elements?ae(e._elements,a,o):ae(i,a,o)}else if(Array.isArray(t)&&e._elements)for(let n=0;n<t.length;n++)ae(e._elements,t[n],`${r}[${n}]`)}}function at(e,t,r){return!t||ar(e,[{Array:nm,Boolean:np,ConceptUuid:ny,Number:nf,Object:ng,String:nh,UUID:ny,PersonAttributeTypeUuid:ny,PatientIdentifierTypeUuid:ny}[t]],r)}function ar(e,t,r){let n=!0;if(t)try{for(let a of t){let t=a(r);if("string"==typeof t){let a="object"==typeof r?`Invalid configuration for ${e}: ${t}`:`Invalid configuration value ${r} for ${e}: ${t}`;as(e,a),n=!1}}}catch(t){console.error(`Skipping invalid validator at "${e}". Encountered error
|
|
12
|
-
${t}`)}return n}let an=(e,t)=>{let r=structuredClone(t);if(!e)return r;for(let t of Object.keys(e)){let n=r[t],a=e[t];if(a&&(a.hasOwnProperty("_type")||a.hasOwnProperty("_default"))){r.hasOwnProperty(t)||(r[t]=a._default);let e=a._elements;if(n&&aa(e)){if(a._type===nc.Array&&Array.isArray(n)){let a=n.map(t=>an(e,t));r[t]=a}else if(a._type===nc.Object)for(let t of Object.keys(n))n[t]=an(e,n[t])}}else if(ao(a)){let e=n??{};ao(e)&&(r[t]=an(a,e))}}return r};function aa(e){return!!e&&Object.keys(e).filter(e=>!["_default","_validators"].includes(e)).length>0}function ao(e){return"object"==typeof e&&!Array.isArray(e)&&null!==e}let ai=new Set;function as(e,t){let r=`${e}:::${t}`;ai||(ai=new Set),ai.has(r)||(console.error(t),ai.add(r))}function al(e){e?ai.forEach(t=>{t.startsWith(e)&&ai.delete(t)}):ai.clear()}function au(){nV.forEach(e=>e()),nV.length=0,nz.clear(),n4.clear(),n3.clear(),n2.clear(),nW()}let ac={"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:nc.Object,_default:{},_validators:[nd(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(", ")}.`})]}},ad={"Display conditions":{privileges:{_description:"The privilege(s) the user must have to use this extension",_type:nc.Array,_default:[]},expression:{_description:"The expression that determines whether the extension is displayed",_type:nc.String,_default:void 0}},...ac},am=(e,t)=>nd(r=>e<=r&&r<=t,`must be between ${e} and ${t}`),ap=e=>{let t=e.concat(["openmrsBase","openmrsSpaBase"]);return nd(e=>{if(!e||"string"!=typeof e)return!1;let r=/\${(.*?)}/g,n=r.exec(e);for(;n;){if(!t.includes(n[1]))return!1;n=r.exec(e)}return!0},"Should be a URL or path. The allowed template parameters are "+t.map(e=>"${"+e+"}").join(", "))},af=ap([]),ah=e=>nd(t=>e.includes(t),`Must be one of the following: '${e.join("', '")}'.`),ag={inRange:am,isUrl:af,isUrlWithTemplateParameters:ap,oneOf:ah};var ay=r(8067);let av=F("breadcrumbs",[]);function ab(e){return aw([e])}function aw(e){let t=[...aE(),...e.map(e=>({matcher:e.matcher instanceof RegExp?e.matcher:"string"==typeof e.matcher?(0,ay.pathToRegexp)(e.matcher).regexp:(0,ay.pathToRegexp)(e.path).regexp,settings:e}))];av.setState(t,!0)}function aE(){return av.getState()}function a_(e,t){if(t)return function(e,t){let[r]=e.filter(e=>e.matcher.test(t));return r}(e,t)||function(e,t){let r=t.split("/");for(;r.length>1;){r.pop();let t=a_(e,r.join("/"));if(t)return t}}(e,t)}function ax(e,t){if(e.length>0){let r=a_(e,t);if(r){let t=[r],n=a_(e,r.settings.parent);for(;void 0!==n;)t.push(n),n=a_(e,n.settings.parent);return t.reverse()}}return[]}function aD(e){return ax(aE(),e)}var aS=r(366);let aC={address1:"Address line 1",address2:"Address line 2",address3:"Address line 3",address4:"Address line 4",address5:"Address line 5",address6:"Address line 6",city:"City",cityVillage:"City",country:"Country",countyDistrict:"District",district:"District",postalCode:"Postal code",state:"State",stateProvince:"State",closeAllOpenedWorkspaces:"Discard changes in {{count}} workspaces",closingAllWorkspacesPromptBody:"There may be unsaved changes in the following workspaces. Do you want to discard changes in the following workspaces? {{workspaceNames}}",closingAllWorkspacesPromptTitle:"You have unsaved changes",discard:"Discard",hide:"Hide",maximize:"Maximize",minimize:"Minimize",openAnyway:"Open anyway",unsavedChangesInOpenedWorkspace:"You may have unsaved changes in the opened workspace. Do you want to discard these changes?",unsavedChangesInWorkspace:'There may be unsaved changes in "{{workspaceName}}". Please save them before opening another workspace.',unsavedChangesTitleText:"Unsaved changes",workspaceHeader:"Workspace header",discardUnsavedChangesPromptBodyMultiple:"{{count}} workspaces have unsaved changes. Closing them will discard the changes:",discardUnsavedChangesPromptBodySingle:"<strong>{{workspaceTitle}}</strong> has unsaved changes. Closing it will discard them.",discardUnsavedChangesPromptTitle:"Discard unsaved changes?",keepEditing:"Keep editing",abnormalValue:"Abnormal value",actions:"Actions",actionableNotification:"Actionable notification",address:"Address",age:"Age",batchActionItemSelected:"{{totalSelected}} item selected",batchActionsItemsSelected:"{{totalSelected}} items selected",cancel:"Cancel",change:"Change",Clinic:"Clinic",close:"Close",closesActionableNotification:"Close actionable notification",closeSnackbar:"Close snackbar",confirm:"Confirm",contactAdministratorIfIssuePersists:"Contact your system administrator if the problem persists.",contactDetails:"Contact details",delete:"Delete",discardChanges:"Discard changes",edit:"Edit",emptyStateText:"There are no {{displayText}} to display",error:"Error",errorCopy:"Sorry, there was a problem displaying this information. You can try to reload this page, or contact the site administrator and quote the error code above.",errorLoadingLoginLocations:"Unable to load login locations. Please try again or contact support if the problem persists.",female:"Female",leftNavigation:"Left navigation",loading:"Loading",localVersion:"Local Build",male:"Male",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",recordNewEntry:"Record {{displayText}}",relationships:"Relationships",resetOverrides:"Reset overrides",save:"Save",scriptLoadingFailed:"Error: Script failed to load",scriptLoadingError:"Failed to load overridden script from {{url}}. Please check that the bundled script is available at the expected URL. Click the button below to reset all import map overrides.",searchForLocation:"Search for a location",seeAll:"See all",seeMoreLists:"See {{count}} more lists",selectAll:"Select all",sex:"Sex",showLess:"Show less",showMore:"Show more",snackbarNotification:"Snackbar notification",toggleDevTools:"Toggle dev tools",unknown:"Unknown",yearAbbreviation:"yr",yearsAbbreviation:"yrs"};var ak=r(2635);let aP=ak.Ay.default||ak.Ay;function aR(e,t,r,n){return aP.t(t,{ns:e,defaultValue:r,...n})}function aT(e,t,r){return aC[e]?aR("core",e,t??aC[e],r):(console.error(`O3 Core Translations does not provide key '${e}'. The key itself is being rendered as text.`),e)}function a$(e,t){let r=window.getOpenmrsSpaBase().replace(/\/$/,""),n=aN(e,{openmrsBase:window.openmrsBase,openmrsSpaBase:r,...t});return e.startsWith("//")?n:n.replace(/^\/\//,"/")}function aN(e,t){return Object.keys(t).reduce((e,r)=>e.split("${"+r+"}").join(t[r]),e)}function aO({to:e,templateParams:t}){let r=window.getOpenmrsSpaBase().replace(/\/$/,""),n=a$(e,t).replace(window.location.origin,""),a=new URL(n,window.location.origin);if("http:"!=a.protocol&&"https:"!=a.protocol)throw console.error(`Received request to navigate to non-http URL: ${a.toString()}`),Error(aT("navigateNonHttp"));n.startsWith(r)?(0,aS.navigateToUrl)(n):window.location.assign(n)}aP.on("initialized",function(){window.i18next.loadNamespaces(["core"])});let aI="openmrs:history";function aj(e){let t=JSON.parse(sessionStorage.getItem(aI)??"[]")||[];t.push(e),t.length>50&&(t=t.slice(-50)),sessionStorage.setItem(aI,JSON.stringify(t))}function aM(){0===JSON.parse(sessionStorage.getItem(aI)??"[]").length&&document.referrer&&aj(document.referrer),window.addEventListener("single-spa:routing-event",e=>{let t=aA();e.detail.originalEvent?.singleSpaTrigger=="replaceState"?(t[t.length-1]=window.location.href,sessionStorage.setItem(aI,JSON.stringify(t))):!e.detail.originalEvent?.singleSpa&&t.includes(window.location.href)?aL({toUrl:window.location.href}):t[t.length-1]!==window.location.href&&aj(window.location.href)})}function aA(){return JSON.parse(sessionStorage.getItem(aI)??"[]")}function aL({toUrl:e}){let t=aA(),r=t.lastIndexOf(e);if(-1!=r){let e=t.slice(0,r+1);aO({to:t[r]}),sessionStorage.setItem(aI,JSON.stringify(e))}else throw Error(`URL ${e} not found in history; cannot go back to it.`)}function aF(){sessionStorage.removeItem(aI)}let aB="${openmrsSpaBase}/login",aV={redirectAuthFailure:{enabled:{_type:nc.Boolean,_default:!0,_description:"Whether to redirect logged-out users to `redirectAuthFailure.url`"},url:{_type:nc.String,_default:aB,_validators:[ag.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:nc.Array,_default:[401],_elements:{_type:nc.Number,_validators:[ag.inRange(100,600)]},_description:"The HTTP error codes for which users will be redirected"},resolvePromise:{_type:nc.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:nc.Boolean,_default:!0,_description:"Whether openmrsFetch should support redirects returned from the backend"}};function aU(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}let aW="/ws/rest/v1",aH="/ws/fhir2/R4",az=`${aW}/session`;function aK(e){return e&&e.startsWith("http")?e:("/"!==e[0]&&(e="/"+e),window.openmrsBase+e)}function aG(e,t={}){if("string"!=typeof e)throw Error("The first argument to @openmrs/api's openmrsFetch function must be a url string");if("object"!=typeof t)throw Error("The second argument to @openmrs/api's openmrsFetch function must be a plain object.");if(!window.openmrsBase)throw Error("@openmrs/api is running in a browser that doesn't have window.openmrsBase, which is provided by openmrs-module-spa's HTML file.");let r=aK(e);if(t.headers||(t.headers={}),e_(t.body)&&(t.body=JSON.stringify(t.body)),void 0===t.headers.Accept&&(t.headers.Accept="application/json"),null===t.headers.Accept&&delete t.headers.Accept,e.startsWith(aW)&&void 0===t.headers["Disable-WWW-Authenticate"]&&(t.headers["Disable-WWW-Authenticate"]="true"),e.startsWith(aH)){let e=new URL(r,window.location.toString());e.searchParams.has("_summary")||(e.searchParams.set("_summary","data"),r=e.toString())}let n=Error();return window.fetch(r,t).then(async e=>{let{redirectAuthFailure:t,followRedirects:a}=await nQ("@openmrs/esm-api");if(e.ok){let t=e.headers.get("location");return(a&&t&&(r===aK(az)||204===e.status)&&aO({to:t}),204===e.status)?(e.data=null,e):e.clone().text().then(t=>{try{t&&(e.data=JSON.parse(t))}catch(e){}return e})}return r===aK(az)&&403===e.status||t.enabled&&t.errors.includes(e.status)?(aF(),aO({to:t.url||e.headers.get("location")||aB}),t.resolvePromise?Promise.resolve():new Promise(()=>{})):e.clone().text().then(t=>{let a=t;try{a=JSON.parse(t)}catch(e){}throw new aZ(r,e,a,n)},t=>{throw new aZ(r,e,null,n)})})}class aZ extends Error{constructor(e,t,r,n){super(),aU(this,"response",void 0),aU(this,"responseBody",void 0),this.message=`Server responded with ${t.status} (${t.statusText}) for url ${e}. Check err.responseBody or network tab in dev tools for more info`,n.message=this.message,this.responseBody=r,this.response=t,this.stack=`Stacktrace for outgoing request:
|
|
12
|
+
${t}`)}return n}let an=(e,t)=>{let r=structuredClone(t);if(!e)return r;for(let t of Object.keys(e)){let n=r[t],a=e[t];if(a&&(a.hasOwnProperty("_type")||a.hasOwnProperty("_default"))){r.hasOwnProperty(t)||(r[t]=a._default);let e=a._elements;if(n&&aa(e)){if(a._type===nc.Array&&Array.isArray(n)){let a=n.map(t=>an(e,t));r[t]=a}else if(a._type===nc.Object)for(let t of Object.keys(n))n[t]=an(e,n[t])}}else if(ao(a)){let e=n??{};ao(e)&&(r[t]=an(a,e))}}return r};function aa(e){return!!e&&Object.keys(e).filter(e=>!["_default","_validators"].includes(e)).length>0}function ao(e){return"object"==typeof e&&!Array.isArray(e)&&null!==e}let ai=new Set;function as(e,t){let r=`${e}:::${t}`;ai||(ai=new Set),ai.has(r)||(console.error(t),ai.add(r))}function al(e){e?ai.forEach(t=>{t.startsWith(e)&&ai.delete(t)}):ai.clear()}function au(){nV.forEach(e=>e()),nV.length=0,nz.clear(),n4.clear(),n3.clear(),n2.clear(),nW()}let ac={"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:nc.Object,_default:{},_validators:[nd(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(", ")}.`})]}},ad={"Display conditions":{privileges:{_description:"The privilege(s) the user must have to use this extension",_type:nc.Array,_default:[]},expression:{_description:"The expression that determines whether the extension is displayed",_type:nc.String,_default:void 0}},...ac},am=(e,t)=>nd(r=>e<=r&&r<=t,`must be between ${e} and ${t}`),ap=e=>{let t=e.concat(["openmrsBase","openmrsSpaBase"]);return nd(e=>{if(!e||"string"!=typeof e)return!1;let r=/\${(.*?)}/g,n=r.exec(e);for(;n;){if(!t.includes(n[1]))return!1;n=r.exec(e)}return!0},"Should be a URL or path. The allowed template parameters are "+t.map(e=>"${"+e+"}").join(", "))},af=ap([]),ah=e=>nd(t=>e.includes(t),`Must be one of the following: '${e.join("', '")}'.`),ag={inRange:am,isUrl:af,isUrlWithTemplateParameters:ap,oneOf:ah};var ay=r(8067);let av=F("breadcrumbs",[]);function ab(e){return aw([e])}function aw(e){let t=[...aE(),...e.map(e=>({matcher:e.matcher instanceof RegExp?e.matcher:"string"==typeof e.matcher?(0,ay.pathToRegexp)(e.matcher).regexp:(0,ay.pathToRegexp)(e.path).regexp,settings:e}))];av.setState(t,!0)}function aE(){return av.getState()}function a_(e,t){if(t)return function(e,t){let[r]=e.filter(e=>e.matcher.test(t));return r}(e,t)||function(e,t){let r=t.split("/");for(;r.length>1;){r.pop();let t=a_(e,r.join("/"));if(t)return t}}(e,t)}function ax(e,t){if(e.length>0){let r=a_(e,t);if(r){let t=[r],n=a_(e,r.settings.parent);for(;void 0!==n;)t.push(n),n=a_(e,n.settings.parent);return t.reverse()}}return[]}function aD(e){return ax(aE(),e)}var aS=r(366);let aC={address1:"Address line 1",address2:"Address line 2",address3:"Address line 3",address4:"Address line 4",address5:"Address line 5",address6:"Address line 6",city:"City",cityVillage:"City",country:"Country",countyDistrict:"District",district:"District",postalCode:"Postal code",state:"State",stateProvince:"State",closeAllOpenedWorkspaces:"Discard changes in {{count}} workspaces",closingAllWorkspacesPromptBody:"There may be unsaved changes in the following workspaces. Do you want to discard changes in the following workspaces? {{workspaceNames}}",closingAllWorkspacesPromptTitle:"You have unsaved changes",discard:"Discard",hide:"Hide",maximize:"Maximize",minimize:"Minimize",openAnyway:"Open anyway",unsavedChangesInOpenedWorkspace:"You may have unsaved changes in the opened workspace. Do you want to discard these changes?",unsavedChangesInWorkspace:'There may be unsaved changes in "{{workspaceName}}". Please save them before opening another workspace.',unsavedChangesTitleText:"Unsaved changes",workspaceHeader:"Workspace header",discardUnsavedChangesPromptBodyMultiple:"{{count}} workspaces have unsaved changes. Closing them will discard the changes:",discardUnsavedChangesPromptBodySingle:"<strong>{{workspaceTitle}}</strong> has unsaved changes. Closing it will discard them.",discardUnsavedChangesPromptTitle:"Discard unsaved changes?",keepEditing:"Keep editing",abnormalValue:"Abnormal value",actions:"Actions",actionableNotification:"Actionable notification",address:"Address",age:"Age",batchActionItemSelected:"{{totalSelected}} item selected",batchActionsItemsSelected:"{{totalSelected}} items selected",cancel:"Cancel",change:"Change",Clinic:"Clinic",close:"Close",closesActionableNotification:"Close actionable notification",closeSnackbar:"Close snackbar",confirm:"Confirm",contactAdministratorIfIssuePersists:"Contact your system administrator if the problem persists.",contactDetails:"Contact details",delete:"Delete",discardChanges:"Discard changes",edit:"Edit",emptyStateText:"There are no {{displayText}} to display",error:"Error",errorCopy:"Sorry, there was a problem displaying this information. You can try to reload this page, or contact the site administrator and quote the error code above.",errorLoadingLoginLocations:"Unable to load login locations. Please try again or contact support if the problem persists.",female:"Female",leftNavigation:"Left navigation",loading:"Loading",localVersion:"Local Build",male:"Male",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",recordNewEntry:"Record {{displayText}}",relationships:"Relationships",resetOverrides:"Reset overrides",save:"Save",scriptLoadingFailed:"Error: Script failed to load",scriptLoadingError:"Failed to load overridden script from {{url}}. Please check that the bundled script is available at the expected URL. Click the button below to reset all import map overrides.",searchForLocation:"Search for a location",seeAll:"See all",seeMoreLists:"See {{count}} more lists",selectAll:"Select all",sex:"Sex",showLess:"Show less",showMore:"Show more",snackbarNotification:"Snackbar notification",toggleDevTools:"Toggle dev tools",unknown:"Unknown",yearAbbreviation:"yr",yearsAbbreviation:"yrs"};var ak=r(2635);let aP=ak.Ay.default||ak.Ay;function aR(e,t,r,n){return aP.t(t,{ns:e,defaultValue:r,...n})}function aT(e,t,r){return aC[e]?aR("core",e,t??aC[e],r):(console.error(`O3 Core Translations does not provide key '${e}'. The key itself is being rendered as text.`),e)}function a$(e,t){let r=window.getOpenmrsSpaBase().replace(/\/$/,""),n=aN(e,{openmrsBase:window.openmrsBase,openmrsSpaBase:r,...t});return e.startsWith("//")?n:n.replace(/^\/\//,"/")}function aN(e,t){return Object.keys(t).reduce((e,r)=>e.split("${"+r+"}").join(t[r]),e)}function aO({to:e,templateParams:t}){let r=window.getOpenmrsSpaBase().replace(/\/$/,""),n=a$(e,t).replace(window.location.origin,""),a=new URL(n,window.location.origin);if("http:"!=a.protocol&&"https:"!=a.protocol)throw console.error(`Received request to navigate to non-http URL: ${a.toString()}`),Error(aT("navigateNonHttp"));n.startsWith(r)?(0,aS.navigateToUrl)(n):window.location.assign(n)}aP.on("initialized",function(){window.i18next.loadNamespaces(["core"])});let aI="openmrs:history";function aj(e){let t=JSON.parse(sessionStorage.getItem(aI)??"[]")||[];t.push(e),t.length>50&&(t=t.slice(-50)),sessionStorage.setItem(aI,JSON.stringify(t))}function aM(){0===JSON.parse(sessionStorage.getItem(aI)??"[]").length&&document.referrer&&aj(document.referrer),window.addEventListener("single-spa:routing-event",e=>{let t=aA();e.detail.originalEvent?.singleSpaTrigger=="replaceState"?(t[t.length-1]=window.location.href,sessionStorage.setItem(aI,JSON.stringify(t))):!e.detail.originalEvent?.singleSpa&&t.includes(window.location.href)?aL({toUrl:window.location.href}):t[t.length-1]!==window.location.href&&aj(window.location.href)})}function aA(){return JSON.parse(sessionStorage.getItem(aI)??"[]")}function aL({toUrl:e}){let t=aA(),r=t.lastIndexOf(e);if(-1!=r){let e=t.slice(0,r+1);aO({to:t[r]}),sessionStorage.setItem(aI,JSON.stringify(e))}else throw Error(`URL ${e} not found in history; cannot go back to it.`)}function aF(){sessionStorage.removeItem(aI)}let aB="${openmrsSpaBase}/login",aV={redirectAuthFailure:{enabled:{_type:nc.Boolean,_default:!0,_description:"Whether to redirect logged-out users to `redirectAuthFailure.url`"},url:{_type:nc.String,_default:aB,_validators:[ag.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:nc.Array,_default:[401],_elements:{_type:nc.Number,_validators:[ag.inRange(100,600)]},_description:"The HTTP error codes for which users will be redirected"},resolvePromise:{_type:nc.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:nc.Boolean,_default:!0,_description:"Whether openmrsFetch should support redirects returned from the backend"}};function aU(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}let aW="/ws/rest/v1",aH="/ws/fhir2/R4",az=`${aW}/session`;function aK(e){return e&&e.startsWith("http")?e:("/"!==e[0]&&(e="/"+e),window.openmrsBase+e)}function aG(e,t={}){if("string"!=typeof e)throw Error("The first argument to @openmrs/api's openmrsFetch function must be a url string");if("object"!=typeof t)throw Error("The second argument to @openmrs/api's openmrsFetch function must be a plain object.");if(!window.openmrsBase)throw Error("@openmrs/api is running in a browser that doesn't have window.openmrsBase, which is provided by openmrs-module-spa's HTML file.");let r=aK(e);t.headers||(t.headers={}),e_(t.body)&&(t.body=JSON.stringify(t.body)),void 0===t.headers.Accept&&(t.headers.Accept="application/json"),null===t.headers.Accept&&delete t.headers.Accept;let n=!1;try{let e=new URL(r,window.location.href),t=new URL(aK(aW),window.location.href),a=e.pathname.replace(/\/{2,}/g,"/"),o=t.pathname.replace(/\/{2,}/g,"/");n=e.origin===t.origin&&(a===o||a.startsWith(`${o}/`))}catch{}if(n){let e=!1;for(let[r,n]of Object.entries(t.headers))"disable-www-authenticate"===r.toLowerCase()&&(void 0===n?delete t.headers[r]:e=!0);e||(t.headers["Disable-WWW-Authenticate"]="true")}if(e.startsWith(aH)){let e=new URL(r,window.location.toString());e.searchParams.has("_summary")||(e.searchParams.set("_summary","data"),r=e.toString())}let a=Error();return window.fetch(r,t).then(async e=>{let{redirectAuthFailure:t,followRedirects:n}=await nQ("@openmrs/esm-api");if(e.ok){let t=e.headers.get("location");return(n&&t&&(r===aK(az)||204===e.status)&&aO({to:t}),204===e.status)?(e.data=null,e):e.clone().text().then(t=>{try{t&&(e.data=JSON.parse(t))}catch(e){}return e})}return r===aK(az)&&403===e.status||t.enabled&&t.errors.includes(e.status)?(aF(),aO({to:t.url||e.headers.get("location")||aB}),t.resolvePromise?Promise.resolve():new Promise(()=>{})):e.clone().text().then(t=>{let n=t;try{n=JSON.parse(t)}catch(e){}throw new aZ(r,e,n,a)},t=>{throw new aZ(r,e,null,a)})})}class aZ extends Error{constructor(e,t,r,n){super(),aU(this,"response",void 0),aU(this,"responseBody",void 0),this.message=`Server responded with ${t.status} (${t.statusText}) for url ${e}. Check err.responseBody or network tab in dev tools for more info`,n.message=this.message,this.responseBody=r,this.response=t,this.stack=`Stacktrace for outgoing request:
|
|
13
13
|
${n.stack}
|
|
14
14
|
Stacktrace for incoming response:
|
|
15
15
|
${this.stack}`}}let aY=F("session",{loaded:!1,session:null}),aq=0,aJ=null;function aX(){return aJ||(aY.getState().loaded&&aq>=Date.now()-6e4?null:a4())}function aQ(e){let t=e?.includeAuthStatus??!0,r=e=>t?e:e.user;return aX()?new Promise(e=>{let t=aY.subscribe(n=>{n.loaded&&(t(),e(r(n.session)))})}):Promise.resolve(r(aY.getState().session))}function a0(){return aX(),aY}function a1(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 a4(e,t){aq=Date.now();let r={};e&&t&&(r.Authorization=`Basic ${window.btoa(`${e}:${t}`)}`);let n=a7(aG(az,{headers:r})),a=()=>{aJ===n&&(aJ=null)};return n.then(a,a),aJ=n,n}function a2(){aY.setState({loaded:!0,session:{authenticated:!1,sessionId:""}})}function a3(e,t){var r,n;if(void 0===t)return!e;if(!e)return!0;return r=e,n=t,("string"==typeof r?!H(n.privileges.find(e=>r===e.display)):Array.isArray(r)?r.every(e=>!H(n.privileges.find(t=>e===t.display))):(H(r)||console.error(`Could not understand privileges "${r}"`),!0))||!H(t.roles.find(e=>"System Developer"===e.display))}function a6(){let e,t;return new Promise(r=>{let n=n=>{n.loaded&&n.session.user&&(e=n.session.user,r(n.session.user),t&&t())};n(aY.getState()),e||(t=aY.subscribe(n))})}async function a5(){return(await aQ()).sessionLocation}async function a9(e,t){return a7(aG(az,{method:"POST",body:{sessionLocation:e},headers:{"Content-Type":"application/json"},signal:t.signal}))}async function a8(e,t,r){return r||(r=new AbortController),await aG(`${aW}/user/${e}`,{method:"POST",body:{userProperties:t},headers:{"Content-Type":"application/json"},signal:r.signal}),a4()}function a7(e){return new Promise((t,r)=>{e.then(e=>{let n;"object"==typeof e?.data?(n={loaded:!0,session:e.data},aY.setState(n),t(n)):(n={loaded:!1,session:null},aY.setState(n),r(n))}).catch(e=>{C(`Failed to fetch new session information: ${e}`);let t={loaded:!1,session:null};aY.setState(t),r(t)})})}function oe(){return"development"===window.spaEnv||"true"===localStorage.getItem("openmrs:devtools")}aY.subscribe(e=>{e.loaded&&e.session&&a1(e.session)});let ot={"webservices.rest":"2.24.0",fhir2:"1.0.0-SNAPSHOT"};function or(){nK("@openmrs/esm-api",aV),a4()}let on="import-map-override:",oa="import-map-overrides-disabled",oo="import-map-overrides:change",oi=!1,os=null,ol=null;async function ou(){return ol??(ol=oc().then(({map:e,complete:t})=>(t||(ol=null),e))),ol}async function oc(){let e=document.querySelectorAll('script[type="systemjs-importmap"]'),t=[],r=!0;for(let n=0;n<e.length;n++){let a=e[n];try{if(a.src){let e=await fetch(a.src);if(!e.ok)throw Error(`Request for ${a.src} returned ${e.status} ${e.statusText}`);t.push(await e.json())}else a.textContent&&t.push(JSON.parse(a.textContent))}catch(e){r=!1,console.warn(`[import-maps] Failed to parse import map from script tag at index ${n}`,e)}}return{map:od(t),complete:r}}function od(e){let t={imports:{}};for(let r of e)r?.imports&&Object.assign(t.imports,r.imports);return t}function om(){let e={};try{let t=oy();for(let r=0;r<localStorage.length;r++){let n=localStorage.key(r);if(n?.startsWith(on)){let r=n.slice(on.length);if(!t.includes(r)){let t=localStorage.getItem(n);t&&(e[r]=t)}}}}catch(e){console.warn("[import-maps] Failed to read import-map overrides from localStorage",e)}return{imports:e}}async function op(){let e=await ou();return oi?od([e,os??om()]):e}async function of(){return ou()}async function oh(){return oi?od([await ou(),om()]):ou()}function og(e){if(!oi)return{imports:{}};if(e){let e={};for(let t=0;t<localStorage.length;t++){let r=localStorage.key(t);if(r?.startsWith(on)){let t=localStorage.getItem(r);t&&(e[r.slice(on.length)]=t)}}return{imports:e}}return om()}function oy(){if(!oi)return[];try{let e=localStorage.getItem(oa);if(e){let t=JSON.parse(e);if(Array.isArray(t))return t}}catch{}return[]}function ov(e){return!!oi&&oy().includes(e)}function ob(e,t){if(!oi)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{localStorage.setItem(on+e,t),window.dispatchEvent(new CustomEvent(oo))}catch(e){console.warn("[import-maps] Failed to write import-map override to localStorage",e)}}function ow(e){if(!oi)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{localStorage.removeItem(on+e);let t=oy().filter(t=>t!==e);t.length>0?localStorage.setItem(oa,JSON.stringify(t)):localStorage.removeItem(oa),window.dispatchEvent(new CustomEvent(oo))}catch(e){console.warn("[import-maps] Failed to update import-map overrides in localStorage",e)}}function oE(){if(!oi)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{let e=[];for(let t=0;t<localStorage.length;t++){let r=localStorage.key(t);r?.startsWith(on)&&e.push(r)}e.forEach(e=>localStorage.removeItem(e)),localStorage.removeItem(oa),window.dispatchEvent(new CustomEvent(oo))}catch(e){console.warn("[import-maps] Failed to clear import-map overrides from localStorage",e)}}function o_(e){if(!oi)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{let t=oy().filter(t=>t!==e);t.length>0?localStorage.setItem(oa,JSON.stringify(t)):localStorage.removeItem(oa),window.dispatchEvent(new CustomEvent(oo))}catch(e){console.warn("[import-maps] Failed to update import-map overrides in localStorage",e)}}let ox=!1;function oD(){!ox&&(ox=!0,(oi="development"===window.spaEnv)&&(os=om()))}function oS(e){return e.replace(/[\/\-@]/g,"_")}async function oC(e,t="./start",n){var a;let o,i=!n?.maxLoadingTime||n.maxLoadingTime<=0?6e5:n.maxLoadingTime;await Promise.race([ok(e,n?.importMap),new Promise((t,r)=>{o=setTimeout(()=>{var t;r(Error(`Could not resolve requested script, ${e}, within ${(t=i)<1e3?`${t} milliseconds`:t<6e4?`${Math.floor(t/1e3)} seconds`:t<36e5?`${Math.floor(t/6e4)} minutes`:t<864e5?`${Math.floor(t/36e5)} hours`:`${Math.floor(t/864e5)} days`}.`))},i)})]),o&&clearTimeout(o);let s=oS(e),l=window[s];if(!("object"==typeof(a=l)&&null!==a&&"init"in a&&"function"==typeof a.init&&"get"in a&&"function"==typeof a.get)){let e=`The global variable ${s} does not refer to a federated module`;throw console.error(e),Error(e)}l.init(r.S.default);let u=(await l.get(t))();if("object"!=typeof u||null===u){let t=`Container for ${e} did not return an ESM module as expected`;throw console.error(t),Error(t)}return u}async function ok(e,t){if("string"!=typeof e||0===e.trim().length){let e="Attempted to call importDynamic() without supplying a package to load";throw console.error(e),Error(e)}let r=oS(e);if(!window[r]){let r=t??await oP();if(!r.imports.hasOwnProperty(e)){let t=`Could not find the package ${e} defined in the current importmap`;throw console.error(t),Error(t)}let n=r.imports[e];n.startsWith("./")&&(n=window.spaBase+n.substring(1));let a=e in og().imports;try{return await function(e){var t;let r=(t=window)[oR]??(t[oR]=new Map),n=r.get(e);if(n)return n;if(document.head.querySelector(`script[src="${e}"]`))return console.warn(`Script at ${e} already loaded. Not loading it again.`),Promise.resolve();let a=document.createElement("script");a.src=e,a.type="text/javascript",a.async=!0;let o=new Promise((t,n)=>{let o=setTimeout(()=>{console.error(`The script at ${e} did not load within 5 seconds. This may indicate an issue with the imports in the script's entry-point file or with the script's bundler configuration.`)},5e3);function i(){clearTimeout(o),a.removeEventListener("load",s),a.removeEventListener("error",l)}function s(){i(),t()}function l(t){i(),r.delete(e),a.remove();let o=`Failed to load script from ${e}`;console.error(o,t),n(t.message??o)}a.addEventListener("load",s),a.addEventListener("error",l),document.head.appendChild(a)});return r.set(e,o),o}(n)}catch(e){return a&&w({kind:"error",title:aT("scriptLoadingFailed","Error: Script failed to load"),description:aT("scriptLoadingError","Failed to load overridden script from {{- url}}. Please check that the bundled script is available at the expected URL. Click the button below to reset all import map overrides.",{url:n}),actionButtonLabel:aT("resetOverrides","Reset overrides"),onActionButtonClick(){oE(),window.location.reload()}}),Promise.reject(e)}}return Promise.resolve()}async function oP(){return op()}let oR=Symbol.for("__openmrs_script_loading");function oT(e){return!!e&&"object"==typeof e&&!(Object.hasOwn(e,"pages")&&(!e.pages||!Array.isArray(e.pages))||Object.hasOwn(e,"extensions")&&(!e.extensions||!Array.isArray(e.extensions))||Object.hasOwn(e,"workspaces")&&(!e.workspaces||!Array.isArray(e.workspaces))||Object.hasOwn(e,"modals")&&(!e.modals||!Array.isArray(e.modals)))}function o$(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&&oT(t))}let oN="openmrs-routes:",oO="openmrs-routes:change",oI=!1,oj=null,oM=null;async function oA(){return oM??(oM=oL().then(({map:e,complete:t})=>(t||(oM=null),e))),oM}async function oL(){let e=document.querySelectorAll("script[type='openmrs-routes']"),t=[],r=!0;for(let n=0;n<e.length;n++){let a=e[n];try{let e;if(a.src){let t=await fetch(a.src);if(!t.ok)throw Error(`Request for ${a.src} returned ${t.status} ${t.statusText}`);e=await t.json()}else a.textContent&&(e=JSON.parse(a.textContent));e&&o$(e)&&t.push(e)}catch(e){r=!1,console.warn(`[route-maps] Failed to parse routes from script tag at index ${n}`,e)}}return{map:oF(t),complete:r}}function oF(e){let t={routes:{}};for(let r of e)r&&"object"==typeof r&&!Array.isArray(r)&&(Object.assign(t.routes,r.routes),void 0===t.version&&void 0!==r.version&&(t.version=r.version));return t}async function oB(){let e={version:void 0,routes:{}};try{let t=[];for(let e=0;e<localStorage.length;e++){let r=localStorage.key(e);if(r?.startsWith(oN)){let e=localStorage.getItem(r);e&&t.push({moduleName:r.slice(oN.length),raw:e})}}for(let r of(await Promise.allSettled(t.map(async({moduleName:e,raw:t})=>{let r=JSON.parse(t);if(oT(r))return{moduleName:e,routes:r};if("string"==typeof r&&r.startsWith("http")){let t=await fetch(r),n=await t.json();if(oT(n))return{moduleName:e,routes:n};throw Error(`${r} did not resolve to a valid OpenmrsAppRoutes object`)}throw Error(`Override for ${e} is neither a valid routes object nor a URL`)}))))"fulfilled"===r.status?e.routes[r.value.moduleName]=r.value.routes:console.warn("[route-maps] Failed to load route override",r.reason)}catch(e){console.warn("[route-maps] Failed to read route overrides from localStorage",e)}return e}async function oV(){let e=await oA();return oI?oF([e,oj??await oB()]):e}async function oU(){return oA()}async function oW(){return oI?oF([await oA(),await oB()]):oA()}function oH(){if(!oI)return{};let e={};try{for(let t=0;t<localStorage.length;t++){let r=localStorage.key(t);if(r?.startsWith(oN)){let t=localStorage.getItem(r);t&&(e[r.slice(oN.length)]=t)}}}catch(e){console.warn("[route-maps] Failed to read route overrides from localStorage",e)}return e}function oz(e,t){if(!oI)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{if("string"==typeof t)if(t.startsWith("http"))localStorage.setItem(oN+e,JSON.stringify(t));else{let r=JSON.parse(t);if(!oT(r))return void console.error(`The supplied routes for ${e} is not a valid OpenmrsAppRoutes object`,t);localStorage.setItem(oN+e,JSON.stringify(r))}else if(t instanceof URL)localStorage.setItem(oN+e,JSON.stringify(t.toString()));else{if(!oT(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(oN+e,JSON.stringify(t))}window.dispatchEvent(new CustomEvent(oO))}catch(e){console.warn("[route-maps] Failed to write route override to localStorage",e)}}function oK(e){if(!oI)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{localStorage.removeItem(oN+e),window.dispatchEvent(new CustomEvent(oO))}catch(e){console.warn("[route-maps] Failed to remove route override from localStorage",e)}}function oG(){if(!oI)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{let e=[];for(let t=0;t<localStorage.length;t++){let r=localStorage.key(t);r?.startsWith(oN)&&e.push(r)}e.forEach(e=>localStorage.removeItem(e)),window.dispatchEvent(new CustomEvent(oO))}catch(e){console.warn("[route-maps] Failed to clear route overrides from localStorage",e)}}let oZ=null;function oY(){return oZ||(oZ=(oI="development"===window.spaEnv)?oB().then(e=>{oj=e}):Promise.resolve())}let oq=`${aW}/attachment`;function oJ(e,t){return aG(`${oq}/${e}`,{signal:t.signal})}function oX(e,t,r,n){return aG(oQ(e,t,n),{signal:r.signal})}function oQ(e,t,r){return r?`${oq}?patient=${e}&encounter=${r}`:`${oq}?patient=${e}&includeEncounterless=${t}`}async function o0(e,t,r){let n=new FormData;return n.append("fileCaption",t.fileDescription),n.append("patient",e),r&&n.append("encounter",r),t.file?n.append("file",t.file,t.fileName):(n.append("file",new File([""],t.fileName),t.fileName),n.append("base64Content",t.base64Content)),aG(`${oq}`,{method:"POST",body:n})}function o1(e,t){return aG(`${oq}/${e}`,{method:"DELETE",signal:t.signal})}async function o4(e,t){return e?(await aG(`${aH}/Patient/${e}`,t)).data:null}function o2(e,t){let r=new CustomEvent(`openmrs:${e}`,{detail:t??void 0,cancelable:!0,bubbles:!0});return window.dispatchEvent(r)}function o3(e,t){let r=e=>{t("detail"in e&&null!==e.detail?e.detail:void 0)};return window.addEventListener(`openmrs:${e}`,r),()=>{window.removeEventListener(`openmrs:${e}`,r)}}function o6(e){return{uuid:e.uuid,display:e.display}}function o5(e=null,t=null){let r=new URLSearchParams;e&&r.set("tag",e),t&&r.set("q",t);let n=r.toString();return aG(`${aW}/location${n?"?"+n:""}`).then(e=>e.data.results.map(o6))}function o9(e){return{uuid:e.uuid,display:e.display,name:e.name}}let o8=`${aW}/visittype`;function o7(e=o8){return aG(e).then(e=>e.data.results.map(o9))}var ie=((Q={}).NEWVISIT="startVisit",Q.EDITVISIT="editVisit",Q.LOADING="loadingVisit",Q),it=((ee={}).NOTSTARTED="notStarted",ee.ONGOING="ongoing",ee);let ir="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))",ia=function(){try{return JSON.parse(sessionStorage.getItem("openmrs:visitStoreState")||"null")}catch(e){return null}}()||{patientUuid:null,manuallySetVisitUuid:null};function io(){return V("visit",ia)}function ii(e,t){io().setState({patientUuid:e,manuallySetVisitUuid:t})}function is(e,t){return aG(`${aW}/visit`,{signal:t.signal,method:"POST",headers:{"Content-type":"application/json"},body:e})}function il(e,t,r){return aG(`${aW}/visit/${e}`,{signal:r.signal,method:"POST",headers:{"Content-type":"application/json"},body:t})}function iu(e,t,r){return aG(`${aW}/visit?patient=${e}&v=${r??ir}`,{signal:t.signal,method:"GET",headers:{"Content-type":"application/json"}})}io().subscribe(e=>{var t;t=e,sessionStorage.setItem("openmrs:visitStoreState",JSON.stringify(t))});class ic{static get version(){return"1.4.0"}static toString(){return"JavaScript Expression Parser (JSEP) v"+ic.version}static addUnaryOp(e){return ic.max_unop_len=Math.max(e.length,ic.max_unop_len),ic.unary_ops[e]=1,ic}static addBinaryOp(e,t,r){return ic.max_binop_len=Math.max(e.length,ic.max_binop_len),ic.binary_ops[e]=t,r?ic.right_associative.add(e):ic.right_associative.delete(e),ic}static addIdentifierChar(e){return ic.additional_identifier_chars.add(e),ic}static addLiteral(e,t){return ic.literals[e]=t,ic}static removeUnaryOp(e){return delete ic.unary_ops[e],e.length===ic.max_unop_len&&(ic.max_unop_len=ic.getMaxKeyLen(ic.unary_ops)),ic}static removeAllUnaryOps(){return ic.unary_ops={},ic.max_unop_len=0,ic}static removeIdentifierChar(e){return ic.additional_identifier_chars.delete(e),ic}static removeBinaryOp(e){return delete ic.binary_ops[e],e.length===ic.max_binop_len&&(ic.max_binop_len=ic.getMaxKeyLen(ic.binary_ops)),ic.right_associative.delete(e),ic}static removeAllBinaryOps(){return ic.binary_ops={},ic.max_binop_len=0,ic}static removeLiteral(e){return delete ic.literals[e],ic}static removeAllLiterals(){return ic.literals={},ic}get char(){return this.expr.charAt(this.index)}get code(){return this.expr.charCodeAt(this.index)}constructor(e){this.expr=e,this.index=0}static parse(e){return new ic(e).parse()}static getMaxKeyLen(e){return Math.max(0,...Object.keys(e).map(e=>e.length))}static isDecimalDigit(e){return e>=48&&e<=57}static binaryPrecedence(e){return ic.binary_ops[e]||0}static isIdentifierStart(e){return e>=65&&e<=90||e>=97&&e<=122||e>=128&&!ic.binary_ops[String.fromCharCode(e)]||ic.additional_identifier_chars.has(String.fromCharCode(e))}static isIdentifierPart(e){return ic.isIdentifierStart(e)||ic.isDecimalDigit(e)}throwError(e){let t=Error(e+" at character "+this.index);throw t.index=this.index,t.description=e,t}runHook(e,t){if(ic.hooks[e]){let r={context:this,node:t};return ic.hooks.run(e,r),r.node}return t}searchHook(e){if(ic.hooks[e]){let t={context:this};return ic.hooks[e].find(function(e){return e.call(t.context,t),t.node}),t.node}}gobbleSpaces(){let e=this.code;for(;e===ic.SPACE_CODE||e===ic.TAB_CODE||e===ic.LF_CODE||e===ic.CR_CODE;)e=this.expr.charCodeAt(++this.index);this.runHook("gobble-spaces")}parse(){this.runHook("before-all");let e=this.gobbleExpressions(),t=1===e.length?e[0]:{type:ic.COMPOUND,body:e};return this.runHook("after-all",t)}gobbleExpressions(e){let t=[],r,n;for(;this.index<this.expr.length;)if((r=this.code)===ic.SEMCOL_CODE||r===ic.COMMA_CODE)this.index++;else if(n=this.gobbleExpression())t.push(n);else if(this.index<this.expr.length){if(r===e)break;this.throwError('Unexpected "'+this.char+'"')}return t}gobbleExpression(){let e=this.searchHook("gobble-expression")||this.gobbleBinaryExpression();return this.gobbleSpaces(),this.runHook("after-expression",e)}gobbleBinaryOp(){this.gobbleSpaces();let e=this.expr.substr(this.index,ic.max_binop_len),t=e.length;for(;t>0;){if(ic.binary_ops.hasOwnProperty(e)&&(!ic.isIdentifierStart(this.code)||this.index+e.length<this.expr.length&&!ic.isIdentifierPart(this.expr.charCodeAt(this.index+e.length))))return this.index+=t,e;e=e.substr(0,--t)}return!1}gobbleBinaryExpression(){let e,t,r,n,a,o,i,s,l;if(!(o=this.gobbleToken())||!(t=this.gobbleBinaryOp()))return o;for(a={value:t,prec:ic.binaryPrecedence(t),right_a:ic.right_associative.has(t)},(i=this.gobbleToken())||this.throwError("Expected expression after "+t),n=[o,a,i];t=this.gobbleBinaryOp();){if(0===(r=ic.binaryPrecedence(t))){this.index-=t.length;break}a={value:t,prec:r,right_a:ic.right_associative.has(t)},l=t;let s=e=>a.right_a&&e.right_a?r>e.prec:r<=e.prec;for(;n.length>2&&s(n[n.length-2]);)i=n.pop(),t=n.pop().value,o=n.pop(),e={type:ic.BINARY_EXP,operator:t,left:o,right:i},n.push(e);(e=this.gobbleToken())||this.throwError("Expected expression after "+l),n.push(a,e)}for(s=n.length-1,e=n[s];s>1;)e={type:ic.BINARY_EXP,operator:n[s-1].value,left:n[s-2],right:e},s-=2;return e}gobbleToken(){let e,t,r,n;if(this.gobbleSpaces(),n=this.searchHook("gobble-token"))return this.runHook("after-token",n);if(e=this.code,ic.isDecimalDigit(e)||e===ic.PERIOD_CODE)return this.gobbleNumericLiteral();if(e===ic.SQUOTE_CODE||e===ic.DQUOTE_CODE)n=this.gobbleStringLiteral();else if(e===ic.OBRACK_CODE)n=this.gobbleArray();else{for(r=(t=this.expr.substr(this.index,ic.max_unop_len)).length;r>0;){if(ic.unary_ops.hasOwnProperty(t)&&(!ic.isIdentifierStart(this.code)||this.index+t.length<this.expr.length&&!ic.isIdentifierPart(this.expr.charCodeAt(this.index+t.length)))){this.index+=r;let e=this.gobbleToken();return e||this.throwError("missing unaryOp argument"),this.runHook("after-token",{type:ic.UNARY_EXP,operator:t,argument:e,prefix:!0})}t=t.substr(0,--r)}ic.isIdentifierStart(e)?(n=this.gobbleIdentifier(),ic.literals.hasOwnProperty(n.name)?n={type:ic.LITERAL,value:ic.literals[n.name],raw:n.name}:n.name===ic.this_str&&(n={type:ic.THIS_EXP})):e===ic.OPAREN_CODE&&(n=this.gobbleGroup())}return n?(n=this.gobbleTokenProperty(n),this.runHook("after-token",n)):this.runHook("after-token",!1)}gobbleTokenProperty(e){this.gobbleSpaces();let t=this.code;for(;t===ic.PERIOD_CODE||t===ic.OBRACK_CODE||t===ic.OPAREN_CODE||t===ic.QUMARK_CODE;){let r;if(t===ic.QUMARK_CODE){if(this.expr.charCodeAt(this.index+1)!==ic.PERIOD_CODE)break;r=!0,this.index+=2,this.gobbleSpaces(),t=this.code}this.index++,t===ic.OBRACK_CODE?((e={type:ic.MEMBER_EXP,computed:!0,object:e,property:this.gobbleExpression()}).property||this.throwError('Unexpected "'+this.char+'"'),this.gobbleSpaces(),(t=this.code)!==ic.CBRACK_CODE&&this.throwError("Unclosed ["),this.index++):t===ic.OPAREN_CODE?e={type:ic.CALL_EXP,arguments:this.gobbleArguments(ic.CPAREN_CODE),callee:e}:(t===ic.PERIOD_CODE||r)&&(r&&this.index--,this.gobbleSpaces(),e={type:ic.MEMBER_EXP,computed:!1,object:e,property:this.gobbleIdentifier()}),r&&(e.optional=!0),this.gobbleSpaces(),t=this.code}return e}gobbleNumericLiteral(){let e="",t,r;for(;ic.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);if(this.code===ic.PERIOD_CODE)for(e+=this.expr.charAt(this.index++);ic.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);if("e"===(t=this.char)||"E"===t){for(e+=this.expr.charAt(this.index++),("+"===(t=this.char)||"-"===t)&&(e+=this.expr.charAt(this.index++));ic.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);ic.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+e+this.char+")")}return r=this.code,ic.isIdentifierStart(r)?this.throwError("Variable names cannot start with a number ("+e+this.char+")"):(r===ic.PERIOD_CODE||1===e.length&&e.charCodeAt(0)===ic.PERIOD_CODE)&&this.throwError("Unexpected period"),{type:ic.LITERAL,value:parseFloat(e),raw:e}}gobbleStringLiteral(){let e="",t=this.index,r=this.expr.charAt(this.index++),n=!1;for(;this.index<this.expr.length;){let t=this.expr.charAt(this.index++);if(t===r){n=!0;break}if("\\"===t)switch(t=this.expr.charAt(this.index++)){case"n":e+="\n";break;case"r":e+="\r";break;case"t":e+=" ";break;case"b":e+="\b";break;case"f":e+="\f";break;case"v":e+="\v";break;default:e+=t}else e+=t}return n||this.throwError('Unclosed quote after "'+e+'"'),{type:ic.LITERAL,value:e,raw:this.expr.substring(t,this.index)}}gobbleIdentifier(){let e=this.code,t=this.index;for(ic.isIdentifierStart(e)?this.index++:this.throwError("Unexpected "+this.char);this.index<this.expr.length;)if(e=this.code,ic.isIdentifierPart(e))this.index++;else break;return{type:ic.IDENTIFIER,name:this.expr.slice(t,this.index)}}gobbleArguments(e){let t=[],r=!1,n=0;for(;this.index<this.expr.length;){this.gobbleSpaces();let a=this.code;if(a===e){r=!0,this.index++,e===ic.CPAREN_CODE&&n&&n>=t.length&&this.throwError("Unexpected token "+String.fromCharCode(e));break}if(a===ic.COMMA_CODE){if(this.index++,++n!==t.length){if(e===ic.CPAREN_CODE)this.throwError("Unexpected token ,");else if(e===ic.CBRACK_CODE)for(let e=t.length;e<n;e++)t.push(null)}}else if(t.length!==n&&0!==n)this.throwError("Expected comma");else{let e=this.gobbleExpression();e&&e.type!==ic.COMPOUND||this.throwError("Expected comma"),t.push(e)}}return r||this.throwError("Expected "+String.fromCharCode(e)),t}gobbleGroup(){this.index++;let e=this.gobbleExpressions(ic.CPAREN_CODE);if(this.code===ic.CPAREN_CODE)return(this.index++,1===e.length)?e[0]:!!e.length&&{type:ic.SEQUENCE_EXP,expressions:e};this.throwError("Unclosed (")}gobbleArray(){return this.index++,{type:ic.ARRAY_EXP,elements:this.gobbleArguments(ic.CBRACK_CODE)}}}Object.assign(ic,{hooks:new class{add(e,t,r){if("string"!=typeof arguments[0])for(let e in arguments[0])this.add(e,arguments[0][e],arguments[1]);else(Array.isArray(e)?e:[e]).forEach(function(e){this[e]=this[e]||[],t&&this[e][r?"unshift":"push"](t)},this)}run(e,t){this[e]=this[e]||[],this[e].forEach(function(e){e.call(t&&t.context?t.context:t,t)})}},plugins:new class{constructor(e){this.jsep=e,this.registered={}}register(...e){e.forEach(e=>{if("object"!=typeof e||!e.name||!e.init)throw Error("Invalid JSEP plugin format");this.registered[e.name]||(e.init(this.jsep),this.registered[e.name]=e)})}}(ic),COMPOUND:"Compound",SEQUENCE_EXP:"SequenceExpression",IDENTIFIER:"Identifier",MEMBER_EXP:"MemberExpression",LITERAL:"Literal",THIS_EXP:"ThisExpression",CALL_EXP:"CallExpression",UNARY_EXP:"UnaryExpression",BINARY_EXP:"BinaryExpression",ARRAY_EXP:"ArrayExpression",TAB_CODE:9,LF_CODE:10,CR_CODE:13,SPACE_CODE:32,PERIOD_CODE:46,COMMA_CODE:44,SQUOTE_CODE:39,DQUOTE_CODE:34,OPAREN_CODE:40,CPAREN_CODE:41,OBRACK_CODE:91,CBRACK_CODE:93,QUMARK_CODE:63,SEMCOL_CODE:59,COLON_CODE:58,unary_ops:{"-":1,"!":1,"~":1,"+":1},binary_ops:{"||":1,"??":1,"&&":2,"|":3,"^":4,"&":5,"==":6,"!=":6,"===":6,"!==":6,"<":7,">":7,"<=":7,">=":7,"<<":8,">>":8,">>>":8,"+":9,"-":9,"*":10,"/":10,"%":10,"**":11},right_associative:new Set(["**"]),additional_identifier_chars:new Set(["$","_"]),literals:{true:!0,false:!1,null:null},this_str:"this"}),ic.max_unop_len=ic.getMaxKeyLen(ic.unary_ops),ic.max_binop_len=ic.getMaxKeyLen(ic.binary_ops);let id=e=>new ic(e).parse(),im=Object.getOwnPropertyNames(class{});Object.getOwnPropertyNames(ic).filter(e=>!im.includes(e)&&void 0===id[e]).forEach(e=>{id[e]=ic[e]}),id.Jsep=ic,id.plugins.register({name:"ternary",init(e){e.hooks.add("after-expression",function(t){if(t.node&&this.code===e.QUMARK_CODE){this.index++;let r=t.node,n=this.gobbleExpression();if(n||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===e.COLON_CODE){this.index++;let a=this.gobbleExpression();if(a||this.throwError("Expected expression"),t.node={type:"ConditionalExpression",test:r,consequent:n,alternate:a},r.operator&&e.binary_ops[r.operator]<=.9){let n=r;for(;n.right.operator&&e.binary_ops[n.right.operator]<=.9;)n=n.right;t.node.test=n.right,n.right=t.node,t.node=r}}else this.throwError("Expected :")}})}});let ip="ArrowFunctionExpression",ih={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)}},ig={...ih,Promise};function iy(e,t={}){return ix(e,t,iC)}async function iv(e,t={}){return iD(e,t,iC)}function ib(e,t={}){return ix(e,t,ik)}function iw(e,t={}){return iD(e,t,ik)}function iE(e,t={}){return ix(e,t,iP)}function i_(e,t={}){return iD(e,t,iP)}function ix(e,t={},r){if("string"!=typeof e&&("object"!=typeof e||!e||!("type"in e)))throw`Unknown expression type ${e}. Expressions must either be a string or pre-compiled string.`;if("string"==typeof e&&0===e.trim().length)throw{type:"Empty expression",message:"Expression cannot be an empty string"};null==t&&(t={});let n=iO(t,ih),a=iR("string"==typeof e?id(e):e,n);if(r(a))return a;throw{type:"Invalid result",message:"string"==typeof e?`The expression ${e} did not produce a valid result`:"The expression did not produce a valid result"}}async function iD(e,t={},r){if("string"!=typeof e&&("object"!=typeof e||!e||!("type"in e)))return Promise.reject(`Unknown expression type ${e}. Expressions must either be a string or pre-compiled string.`);if("string"==typeof e&&0===e.trim().length)throw{type:"Empty expression",message:"Expression cannot be an empty string"};null==t&&(t={});let n=iO(t,ig);return Promise.resolve(iR("string"==typeof e?id(e):e,n)).then(t=>{if(r(t))return t;throw{type:"Invalid result",message:"string"==typeof e?`The expression ${e} did not produce a valid result`:"The expression did not produce a valid result"}})}function iS(e){return id(e)}function iC(e){return"string"==typeof e||"number"==typeof e||"boolean"==typeof e||null==e||e instanceof Date}function ik(e){return"boolean"==typeof e}function iP(e){return"number"==typeof e}function iR(e,t){switch(e.type){case"UnaryExpression":var r,n,a,o,i,s,l,u,c,d,m,p,f,h=e,g=t;let y=iR(h.argument,g);switch(h.operator){case"+":return+y;case"-":return-y;case"~":return~y;case"!":return!y;default:throw`Expression evaluator does not support operator '${h.operator}''`}case"BinaryExpression":var v=e,b=t;switch(v.operator){case"&&":return iR(v.left,b)&&iR(v.right,b);case"||":return iR(v.left,b)||iR(v.right,b);case"??":return iR(v.left,b)??iR(v.right,b)}let w=iR(v.left,b),E=iR(v.right,b);switch(v.operator){case"+":return w+E;case"-":return w-E;case"*":return w*E;case"/":return w/E;case"%":return w%E;case"**":return w**E;case"==":return w==E;case"===":return w===E;case"!=":return w!=E;case"!==":return w!==E;case">":return w>E;case">=":return w>=E;case"<":return w<E;case"<=":return w<=E;case"in":return w in E;default:throw`Expression evaluator does not support operator '${v.operator}' operator`}case"ConditionalExpression":return r=e,n=t,iR(r.test,n)?iR(r.consequent,n):iR(r.alternate,n);case"CallExpression":return iM(i$(e,t));case"ArrowFunctionExpression":let _;return a=e,o=t,_=a.params?.map(e=>{if("Identifier"===e.type)return e.name;throw`Cannot handle parameter of type ${e.type}`})??[],(function(...e){if(e.length<_.length)throw`Required argument(s) ${_.slice(e.length,-1).join(", ")} were not provided`;let t=Object.fromEntries(_.reduce((t,r,n)=>{let a=e[n];return function e(t){if("string"==typeof t||"number"==typeof t||"boolean"==typeof t||"function"==typeof t||null===t||t instanceof RegExp)return!0;if("object"==typeof t){for(let r of Object.keys(t))if(!e(t[r]))return!1;return!0}if(Array.isArray(t)){for(let r of t)if(!e(r))break}return!1}(a)&&t.push([r,a]),t},[]));return iR(a.body,o.addVariables(t))}).bind(null);case"MemberExpression":return iM(iN(e,t));case"ArrayExpression":return i=e,s=t,i.elements?.map(iA(s));case"SequenceExpression":let x;return l=e,u=t,(x=l.expressions.map(iA(u)))[x.length-1];case"NewExpression":var D=e,S=t;if(D.callee&&"Identifier"===D.callee.type){let e=D.arguments?.map(iA(S));switch(D.callee.name){case"Date":return new Date(...e);case"RegExp":return new RegExp(...e);default:throw`Cannot instantiate object of type ${D.callee.name}`}}if(D.callee)throw"new must be called with either Date or RegExp";throw'Could not handle "new" without a specified class';case"Literal":return e.value;case"Identifier":return c=e,d=t,(iL(c.name),d.variables&&Object.hasOwn(d.variables,c.name))?d.variables[c.name]:Object.hasOwn(d.globals,c.name)?d.globals[c.name]:void 0;case"TemplateLiteral":let C,k;return m=e,p=t,C=m.expressions?.map(iA(p))??[],(k=m.quasis?.map(iA(p))??[]).filter(e=>!e.tail).map(e=>e.value).join("")+C.join("")+k.filter(e=>e.tail).map(e=>e.value).join("");case"TemplateElement":return{value:(f=e).cooked,tail:f.tail};default:throw`Expression evaluator does not support expression of type '${e.type}'`}}function iT(e,t){switch(e.type){case"Literal":return e.value;case"Identifier":return e.name;case"MemberExpression":return iT(e.property,t);default:throw`VisitExpressionName does not support expression of type '${e.type}'`}}function i$(e,t){let r=ij(e.callee,t);if(r===iI||e.optional&&null==r)return iI;let n=e.arguments?.map(iA(t));if(r){if("function"!=typeof r)throw`${iV(e.callee)} is not a function`}else throw`No function named ${iV(e.callee)} is defined in this context`;return r(...n)}function iN(e,t){let r=ij(e.object,t);if(r===iI||e.optional&&null==r)return iI;if(null===r)throw TypeError(`TypeError: cannot read properties of null (reading '${iB(e.property,t)}')`);if(void 0===r)switch(e.object.type){case"Identifier":{let r=iT(e.object,t);throw ReferenceError(`ReferenceError: ${r} is not defined`)}case"MemberExpression":throw TypeError(`TypeError: cannot read properties of undefined (reading '${iB(e.property,t)}')`);default:throw`VisitMemberExpression does not support operator '${e.object.type}' type`}if("object"!=typeof r&&"function"!=typeof r&&"string"!=typeof r&&"number"!=typeof r)throw`VisitMemberExpression does not support member access on type ${typeof r}`;let n=e.computed?function(e){if(void 0===e)throw{type:"Illegal property access",message:"No property was supplied to the property access"};if("string"!=typeof e&&"number"!=typeof e)throw{type:"Illegal property access",message:`Cannot use a value of type ${null===e?"null":typeof e} as a property name`};return e}(iR(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);iL(n),function(e,t){if(iF.has(String(t)))return;let r=Object(e);for(;null!==r;){if(Object.hasOwn(r,t)){if(r===Object.prototype||r===Function.prototype)throw{type:"Illegal property access",message:`Cannot access the ${t} property of objects`};return}r=Object.getPrototypeOf(r)}}(r,n);let a=r[n];return"function"==typeof a?a.bind(r):a}function iO(e,t){let r={variables:{...e},globals:{...t},addVariables(e){return this.variables={...this.variables,...e},this}};return r.addVariables.bind(r),r}id.plugins.register({name:"arrow",init(e){e.addBinaryOp("=>",.1,!0),e.hooks.add("gobble-expression",function(t){if(this.gobbleSpaces(),this.code===e.OPAREN_CODE){let r=this.index;if(this.index++,this.gobbleSpaces(),this.code===e.CPAREN_CODE){this.index++;let e=this.gobbleBinaryOp();if("=>"===e){let r=this.gobbleBinaryExpression();r||this.throwError("Expected expression after "+e),t.node={type:ip,params:null,body:r};return}}this.index=r}}),e.hooks.add("after-expression",function(t){!function t(r){r&&(Object.values(r).forEach(e=>{e&&"object"==typeof e&&t(e)}),"=>"===r.operator&&(r.type=ip,r.params=r.left?[r.left]:null,r.body=r.right,r.params&&r.params[0].type===e.SEQUENCE_EXP&&(r.params=r.params[0].expressions),delete r.left,delete r.right,delete r.operator))}(t.node)})}}),id.plugins.register({name:"new",init(e){e.addUnaryOp("new"),e.hooks.add("after-token",function(t){let r=t.node;if(r&&"new"===r.operator){r.argument&&[e.CALL_EXP,e.MEMBER_EXP].includes(r.argument.type)||this.throwError("Expected new function()"),t.node=r.argument;let n=t.node;for(;n.type===e.MEMBER_EXP||n.type===e.CALL_EXP&&n.callee.type===e.MEMBER_EXP;)n=n.type===e.MEMBER_EXP?n.object:n.callee.object;n.type="NewExpression"}})}}),id.plugins.register({name:"numbers",init(e){function t(e){return"x"===e||"X"===e?(this.index+=2,[[48,57],[65,70],[97,102]]):"b"===e||"B"===e?(this.index+=2,[[48,49]]):"o"===e||"O"===e||e>="0"&&e<="7"?(this.index+=e<="7"?1:2,[[48,55]]):null}function r(t){let r=this.index,n="",a=()=>{for(;e.isDecimalDigit(this.code)||95===this.code;)95===this.code?this.index++:n+=this.expr.charAt(this.index++)};a(),this.code===e.PERIOD_CODE&&(n+=this.expr.charAt(this.index++),a());let o=this.char;("e"===o||"E"===o)&&(n+=this.expr.charAt(this.index++),("+"===(o=this.char)||"-"===o)&&(n+=this.expr.charAt(this.index++)),a(),e.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+n+this.char+")"));let i=this.code;if(e.isIdentifierStart(i))this.throwError("Variable names cannot start with a number ("+n+this.char+")");else if(i===e.PERIOD_CODE){n.length>1&&this.throwError(`Unexpected period ${JSON.stringify({chCode:i,number:n},null,2)}`),this.index=r;return}t.node={type:e.LITERAL,value:parseFloat(n),raw:this.expr.substring(r,this.index)}}e.hooks.add("gobble-token",function(n){if(48===this.code){var a,o,i;let s=this.index,l=this.expr.charAt(this.index+1),u=t.call(this,l);if(!u)return;let c="";for(;a=this.code,o=u,95===a||o.some(([e,t])=>a>=e&&a<=t);)95===this.code?this.index++:c+=this.expr.charAt(this.index++);if(e.isIdentifierPart(this.code)){if(e.isDecimalDigit(this.code)&&e.isDecimalDigit(l.charCodeAt(0))){this.index=s+1,r.call(this,n);return}this.throwError("unexpected char within number")}n.node={type:e.LITERAL,value:parseInt(c,"x"===(i=l)||"X"===i?16:"b"===i||"B"===i?2:8),raw:this.expr.substring(s,this.index)}}else(e.isDecimalDigit(this.code)||this.code===e.PERIOD_CODE)&&r.call(this,n)})}}),id.plugins.register({name:"regex",init(e){e.hooks.add("gobble-token",function(t){if(47===this.code){let r=++this.index,n=!1;for(;this.index<this.expr.length;){if(47===this.code&&!n){let n,a=this.expr.slice(r,this.index),o="";for(;++this.index<this.expr.length;){let e=this.code;if(e>=97&&e<=122||e>=65&&e<=90||e>=48&&e<=57)o+=this.char;else break}try{n=new RegExp(a,o)}catch(e){this.throwError(e.message)}return t.node={type:e.LITERAL,value:n,raw:this.expr.slice(r-1,this.index)},t.node=this.gobbleTokenProperty(t.node),t.node}this.code===e.OBRACK_CODE?n=!0:n&&this.code===e.CBRACK_CODE&&(n=!1),this.index+=92===this.code?2:1}this.throwError("Unclosed Regex")}})}}),id.plugins.register({name:"ternary",init(e){e.hooks.add("after-expression",function(t){if(t.node&&this.code===e.QUMARK_CODE){this.index++;let r=t.node,n=this.gobbleExpression();if(n||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===e.COLON_CODE){this.index++;let a=this.gobbleExpression();if(a||this.throwError("Expected expression"),t.node={type:"ConditionalExpression",test:r,consequent:n,alternate:a},r.operator&&e.binary_ops[r.operator]<=.9){let n=r;for(;n.right.operator&&e.binary_ops[n.right.operator]<=.9;)n=n.right;t.node.test=n.right,n.right=t.node,t.node=r}}else this.throwError("Expected :")}})}}),id.plugins.register({name:"jsepTemplateLiteral",init(e){function t(e,r=!0){if(96===this.code){let t={type:"TemplateLiteral",quasis:[],expressions:[]},n="",a="",o=!1,i=this.expr.length,s=()=>t.quasis.push({type:"TemplateElement",value:{raw:a,cooked:n},tail:o});for(;this.index<i;){let i=this.expr.charAt(++this.index);if("`"===i)return this.index+=1,o=!0,s(),e.node=t,r&&(e.node=this.gobbleTokenProperty(e.node)),e.node;if("$"===i&&"{"===this.expr.charAt(this.index+1))this.index+=2,s(),a="",n="",t.expressions.push(...this.gobbleExpressions(125)),125!==this.code&&this.throwError("unclosed ${");else if("\\"===i)switch(a+=i,i=this.expr.charAt(++this.index),a+=i,i){case"n":n+="\n";break;case"r":n+="\r";break;case"t":n+=" ";break;case"b":n+="\b";break;case"f":n+="\f";break;case"v":n+="\v";break;default:n+=i}else n+=i,a+=i}this.throwError("Unclosed `")}}e.hooks.add("gobble-token",t),e.hooks.add("after-token",function(r){if((r.node.type===e.IDENTIFIER||r.node.type===e.MEMBER_EXP)&&96===this.code)return r.node={type:"TaggedTemplateExpression",tag:r.node,quasi:t.bind(this)(r,!1)},r.node=this.gobbleTokenProperty(r.node),r.node})}}),id.addBinaryOp("in",7),id.addBinaryOp("??",1);let iI=Symbol("optional chain short-circuited");function ij(e,t){switch(e.type){case"MemberExpression":return iN(e,t);case"CallExpression":return i$(e,t);default:return iR(e,t)}}function iM(e){return e===iI?void 0:e}function iA(e){return function(t){return null===t?null:iR(t,e)}}function iL(e){if("__proto__"===e||"prototype"===e||"constructor"===e)throw{type:"Illegal property access",message:`Cannot access the ${e} property of objects`}}let iF=new Set(["toString","valueOf","hasOwnProperty"]);function iB(e,t){try{return iT(e,t)}catch{return"<computed>"}}function iV(e){return e?"MemberExpression"===e.type?e.property?.name:e.name:null}function iU(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:{...ig},isLocalExpression:!1,variables:new Set};return iW("string"==typeof e?id(e):e,t),[...t.variables]}function iW(e,t){switch(e.type){case"UnaryExpression":return n=e,a=t,iW(n.argument,a);case"BinaryExpression":return o=e,i=t,[iW(o.left,i),iW(o.right,i)].filter(Boolean);case"ConditionalExpression":return s=e,l=t,[iW(s.consequent,l),iW(s.test,l),iW(s.alternate,l)].filter(Boolean);case"CallExpression":let r;return u=e,c=t,r=iW(u.callee,c),u.arguments?.map(iH(c)),r;case"ArrowFunctionExpression":var n,a,o,i,s,l,u,c,d,m,p,f,h,g,y,v,b=e,w=t;let E={...w};E.isLocalExpression=!0;let _=b.params?.map(iH(E))??[],x=iW(b.body,E)??[];if(x&&Array.isArray(x))for(let e of x)_.includes(e)||w.variables.add(e);return;case"MemberExpression":var D=e,S=t;if(iW(D.object,S),D.computed)return void iW(D.property,S);let C={...S};C.isLocalExpression=!0,iW(D.property,C);return;case"ArrayExpression":return d=e,m=t,void d.elements?.map(iH(m));case"SequenceExpression":return p=e,f=t,void p.expressions?.map(iH(f));case"NewExpression":return h=e,g=t,void h.arguments?.map(iH(g));case"Literal":case"TemplateElement":return;case"Identifier":var k=e,P=t;if(!(k.name in P.globals))if(P.isLocalExpression)return k.name;else P.variables.add(k.name);return;case"TemplateLiteral":return y=e,v=t,void(y.expressions?.map(iH(v)),y.quasis?.map(iH(v)));default:throw`Expression evaluator does not support expression of type '${e.type}'`}}function iH(e){return function(t){return null===t?null:iW(t,e)}}let iz=V("feature-flags",{flags:function(){let e={};for(let t of Object.keys(localStorage))if(t.startsWith("openmrs:feature-flag:")){let r=t.replace("openmrs:feature-flag:",""),n=JSON.parse(localStorage.getItem(`openmrs:feature-flag-meta:${r}`)||"{}");e[r]={enabled:"true"===localStorage.getItem(t),...n}}return e}()});function iK(e,t,r){iz.setState(n=>({flags:{...n.flags,[e]:{enabled:n.flags[e]?.enabled??!1,label:t,description:r}}}))}function iG(){let e=iz.getState().flags;Object.keys(localStorage).filter(e=>e.startsWith("openmrs:feature-flag:")).forEach(t=>{let r=t.replace("openmrs:feature-flag:","");e[r]||(localStorage.removeItem(t),localStorage.removeItem(`openmrs:feature-flag-meta:${r}`))})}function iZ(e){return iz.getState().flags[e].enabled}function iY(e,t){iz.subscribe(r=>{t(r.flags[e].enabled)})}function iq(e,t){iz.setState(r=>({flags:{...r.flags,[e]:{...r.flags[e],enabled:t}}}))}iz.subscribe(e=>{for(let[t,r]of Object.entries(e.flags))localStorage.setItem(`openmrs:feature-flag:${t}`,r.enabled.toString()),localStorage.setItem(`openmrs:feature-flag-meta:${t}`,JSON.stringify({label:r.label,description:r.description}))});var iJ=tz(function(e,t,r){tA(e,t,r)});let iX=F("extensionsInternal",{slots:{},extensions:{}}),iQ=F("extensionRenderings",{renderings:new Map}),i0=()=>V("extensionsInternal",{slots:{},extensions:{}}),i1=()=>V("extensionRenderings",{renderings:new Map});function i4(e){let t=iX.getState(),r=e(t);r!==t&&iX.setState(r)}let i2=null,i3=null;function i6(){let e=iQ.getState();return i2&&e===i3||(i2=new Map(e.renderings),i3=e,function(e){for(let t of(so.clear(),e.values()))ss(t,1);si=!0}(i2)),i2}function i5(e){i3={renderings:e},iQ.setState(i3,!0)}function i9(e){let t=i6();t.has(e.renderingId)||(t.set(e.renderingId,e),ss(e,1),i5(t))}function i8(e){let t=i6(),r=t.get(e);r&&(t.delete(e),ss(r,-1),i5(t))}let i7=()=>V("extensions",{slots:{}}),se=0,st=new Set;function sr(e){se++;try{return e()}finally{if(0==--se&&st.size>0){let e=Array.from(st);for(let t of(st.clear(),e))sn(t)}}}function sn(e){try{e()}catch(t){console.error(`The extension system's '${e.name}' recomputation failed`,t)}}function sa(e){se>0?st.add(e):sn(e)}let so=new Map,si=!1;function ss(e,t){let r=JSON.stringify([e.slotName,e.extensionId,e.slotModuleName,e.extensionModuleName]),n=so.get(r);if(!n){if(t<0)return;so.set(r,{count:1,record:{slotModuleName:e.slotModuleName,extensionModuleName:e.extensionModuleName,slotName:e.slotName,extensionId:e.extensionId}}),si=!0;return}n.count+=t,n.count<1&&(so.delete(r),si=!0)}function sl(){var e,t;if(i6(),!si)return;si=!1;let r=Array.from(so.values(),({record:e})=>e);r.sort(su),e=nw.getState().mountedExtensions,t=r,e.length===t.length&&e.every((e,r)=>0===su(e,t[r]))||nw.setState({mountedExtensions:r})}function su(e,t){return sc(e.slotName,t.slotName)||sc(e.extensionId,t.extensionId)||sc(e.slotModuleName,t.slotModuleName)||sc(e.extensionModuleName,t.extensionModuleName)}function sc(e,t){return e===t?0:e<t?-1:1}sl(),iQ.subscribe(()=>sa(sl));let sd=i0(),sm=i7(),sp=n_(),sf=nS(),sh=new Set,sg=!1;function sy(e){if(null===e)sh=null;else if(null!==sh)for(let t of e)sh.add(t);sa(sv)}function sv(){if(!sg){sg=!0;try{for(let e=1;;e++){let t=sh;if(null!==t&&0===t.size)return;sh=new Set;try{!function(e,t,r,n,a,o=null){let i=sm.getState().slots,s={},l=!1,u=Object.entries(n.flags).filter(([,{enabled:e}])=>e).map(([e])=>e);for(let[n,c]of Object.entries(e.slots)){let d=i[n];if(d&&o&&!o.has(n)){s[n]=d;continue}let{config:m}=nD(t,c.name),p=function(e,t,r,n,a,o){let i=function(e,t){let r=e.add||[],n=e.remove||[],a=e.order||[],{extensions:o}=sd.getState();return[...t,...r].filter(e=>!n.includes(e)).sort((e,r)=>sP(e,a,o[sE(e)]?.order,t)-sP(r,a,o[sE(r)]?.order,t))}(r,t.slots[e].attachedIds),s=[];for(let l of i){let{config:i}=nk(n,e,l),u=nP(r,e,l),c=u?iJ({},i,u):i,d=sE(l),m=t.extensions[d];if(m){let e=c?.["Display conditions"]?.privileges??m.privileges??[];if(e&&("string"==typeof e||Array.isArray(e)&&e.length>0)&&(!o?.user||!a3(e,o.user))||m.featureFlag&&!a.includes(m.featureFlag))continue;s.push({id:l,name:d,moduleName:m.moduleName,config:c,featureFlag:m.featureFlag,meta:m.meta,displayConditionExpression:c?.["Display conditions"]?.expression||m.displayExpression})}}return s}(n,e,m,r,u,a.session);d&&d.moduleName===c.moduleName&&rC(d.candidateExtensions,p)?s[n]=d:(s[n]={moduleName:c.moduleName,candidateExtensions:p},l=!0)}(l||Object.keys(i).length!==Object.keys(s).length)&&sm.setState({slots:s})}(sd.getState(),sp.getState(),sf.getState(),iz.getState(),aY.getState(),t)}catch(e){throw sh=null===t||null===sh?null:new Set([...t,...sh]),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{sg=!1}}}function sb(e,t){let r=new Set;for(let n of Object.keys(e))e[n]!==t[n]&&r.add(n);for(let n of Object.keys(t))n in e||r.add(n);return r}function sw(e,t){return{moduleName:t,name:e,attachedIds:[]}}function sE(e){let[t]=e.split("#");return t}function s_(e,t){let r=sE(t);return e.extensions[r]}function sx(e){return s_(sd.getState(),e)}sd.subscribe((e,t)=>{sy(e.extensions!==t.extensions?null:sb(e.slots,t.slots))}),sp.subscribe((e,t)=>{sy(sb(e.slots,t.slots))}),sf.subscribe((e,t)=>{sy(sb(e.configs,t.configs))}),iz.subscribe(()=>sy(null)),aY.subscribe(()=>sy(null)),sy(null);let sD=e=>i4(t=>({...t,extensions:{...t.extensions,[e.name]:{...e}}}));function sS(e,t){i4(r=>{let n=r.slots[e];return n?{...r,slots:{...r.slots,[e]:{...n,attachedIds:[...n.attachedIds,t]}}}:{...r,slots:{...r.slots,[e]:{...sw(e),attachedIds:[t]}}}})}function sC(e,t){i4(r=>{let n=r.slots[e];return n&&n.attachedIds.includes(t)?{...r,slots:{...r.slots,[e]:{...n,attachedIds:n.attachedIds.filter(e=>e!==t)}}}:r})}function sk(e){i4(t=>{let r=t.slots[e];return r?{...t,slots:{...t.slots,[e]:{...r,attachedIds:[]}}}:t})}function sP(e,t,r,n){let a=t.indexOf(e);if(-1!==a)return a;{if(void 0!==r)return 1e3+r;let t=n.indexOf(e);return -1!==t?2e3+t:3e3}}function sR(e,t){return function(e,t,r=null,n){let a;return e.filter(e=>{let o=e.displayConditionExpression;if("string"!=typeof o||0===o.trim().length)return!0;a??(a=t&&"object"==typeof t?{session:r,...t}:{session:r});try{return!!ib(o,a)}catch(t){return console.error(`Error while evaluating expression '${o}' for ${e.id}`+(n?` in ${n}`:""),t),!1}})}(sT(e),t,aY.getState().session,e)}function sT(e){return sm.getState().slots[e]?.candidateExtensions??[]}let s$=(e,t)=>sd.setState(r=>{let n=r.slots[t]?.moduleName;if(n&&n!=e)return console.warn(`An extension slot with the name '${t}' already exists. Refusing to register the same slot name twice (in "registerExtensionSlot"). The existing one is from module ${n}.`),r;if(n&&n==e)return r;if(r.slots[t])return{...r,slots:{...r.slots,[t]:{...r.slots[t],moduleName:e}}};let a=sw(t,e);return{...r,slots:{...r.slots,[t]:{...a}}}}),sN=()=>{sh=null,i4(()=>({slots:{},extensions:{}})),i1().setState({renderings:new Map}),sm.setState({slots:{}})},sO=F("left-nav",{slotName:null,basePath:window.spaBase,mode:"normal"});function sI({name:e,basePath:t,mode:r,componentContext:n,state:a}){sO.setState({slotName:e,basePath:t,mode:r??"normal",componentContext:n,state:a})}function sj(e){sO.getState().slotName===e&&sO.setState(sO.getInitialState(),!0)}let sM=F("modalRegistry",{modals:{}});function sA(e){sM.setState(t=>(t.modals[e.name]=e,t))}function sL(e){let t=sM.getState().modals[e];if(!t){let r=sx(e);r&&(t={name:e,load:r.load,moduleName:r.moduleName},console.warn(`Modal ${e} was registered as an extension. This is deprecated and will be removed in the future. Please register it in the "modals" section of routes.json instead of the "extensions" section.`),sA(t))}return t}let sF=F("workspaceRegistrations",{workspaces:{}}),sB=F("workspaceGroups",{workspaceGroups:{}});function sV(e){sF.setState(t=>({workspaces:{...t.workspaces,[e.name]:{...e,load:e.load,preferredWindowSize:e.preferredWindowSize??"normal",type:e.type??"form",canHide:e.canHide??!1,canMaximize:e.canMaximize??!1,width:e.width??"narrow",groups:e.groups??[]}}}))}function sU(e){sB.setState(t=>{let r=t.workspaceGroups[e.name];return r?{workspaceGroups:{...t.workspaceGroups,[e.name]:{...r,members:Array.from(new Set([...r.members,...e.members]))}}}:{workspaceGroups:{...t.workspaceGroups,[e.name]:{name:e.name,members:e.members}}}})}let sW=new Set;function sH(e){let t=sF.getState().workspaces;if(t[e])return t[e];{let t=sx(e);if(t){var r;let n;return sW.has(e)||(console.warn(`The workspace '${e}' is registered as an extension. This is deprecated. Please register it in the "workspaces" section of the routes.json file.`),sW.add(e)),{name:t.name,title:(r=t,"string"==typeof(n=r?.meta?.title)?n:n&&"object"==typeof n?aR(r.moduleName,n.key,n.default):r.name),moduleName:t.moduleName,preferredWindowSize:t.meta?.screenSize??"normal",load:t.load,type:t.meta?.type??"form",canHide:t.meta?.canHide??!1,canMaximize:t.meta?.canMaximize??!1,width:t.meta?.width??"narrow",groups:t.meta?.groups??[]}}throw Error(`No workspace named '${e}' has been registered.`)}}function sz(e){let t=sB.getState().workspaceGroups;if(t[e])return t[e];throw Error(`No workspace group named '${e}' has been registered.`)}let sK=F("workspace2",{registeredGroupsByName:{},registeredWindowsByName:{},registeredWorkspacesByName:{},openedGroup:null,openedWindows:[],workspaceTitleByWorkspaceName:{},isMostRecentlyOpenedWindowHidden:!1});function sG(e){let{registeredWorkspacesByName:t,registeredWindowsByName:r}=sK.getState(),n=t[e];if(n){let t=r[n.window];if(t)return t;throw Error(`No workspace window found with name: ${n.window} for workspace: ${e}`)}throw Error(`No workspace found with name: ${e}`)}function sZ(e){let{registeredGroupsByName:t,registeredWindowsByName:r}=sK.getState(),n=r[e];if(n){let r=t[n.group];if(r)return r;throw Error(`No workspace group found with name: ${n.group} for window: ${e}`)}throw Error(`No workspace window found with name: ${e}`)}function sY(e){let{openedWindows:t}=sK.getState();return t.findIndex(t=>t.openedWorkspaces.find(t=>t.workspaceName===e))}function sq(e,t){if(0==t.length)return;let{registeredGroupsByName:r}=sK.getState(),n={...r};for(let r of t){if(n[r.name])throw Error(`Cannot register workspace group ${r.name} more than once`);n[r.name]={...r,moduleName:e}}sK.setState({registeredGroupsByName:n})}function sJ(e,t){if(0==t.length)return;let{registeredWindowsByName:r}=sK.getState(),n={...r};for(let r of t){if(n[r.name])throw Error(`Cannot register workspace window ${r.name} more than once`);let t={...r,moduleName:e};n[r.name]=t}sK.setState({registeredWindowsByName:n})}function sX(e,t){if(0==t.length)return;let{registeredWorkspacesByName:r}=sK.getState(),n={...r};for(let r of t){if(n[r.name])throw Error(`Cannot register workspace ${r.name} more than once`);let t={...r,moduleName:e};n[r.name]=t}sK.setState({registeredWorkspacesByName:n})}let sQ=0,s0=null,s1={bootstrap:15e3,mount:15e3,unmount:15e3};function s4(e,t){if(e.timeouts)return e;let r=e.name??"parcel",n=Object.fromEntries(Object.keys(s1).filter(t=>e[t]).map(n=>{var a,o;let i,s;return[n,(a=e[n],o=s1[n],i=Array.isArray(a)?a:[a],s=e=>i.reduce((t,a,o)=>t.then(()=>{let t=a(e);return"function"==typeof t?.then&&"function"==typeof t?.catch?t:Promise.reject(Error(`Lifecycle function ${n} at array index ${o} for parcel ${r} did not return a promise`))}),Promise.resolve(void 0)),e=>{let a,i=new Promise((e,t)=>{a=setTimeout(()=>t(Error(`Lifecycle function ${n} for parcel ${r} did not settle within ${o}ms`)),o)});return Promise.race([s(e),i]).finally(()=>clearTimeout(a)).then(e=>(t(n,!1),e),e=>{throw t(n,!0),e})})]}));return{...e,...n}}async function s2(e,t){var r,n;let a,o,i,s,l,u=await (s0??(s0=new Promise((e,t)=>{(0,aS.mountRootParcel)({name:"openmrs-extension-host",bootstrap:()=>Promise.resolve(),mount:t=>(e(t.mountParcel),Promise.resolve()),unmount:()=>Promise.resolve()},{domElement:document.createElement("div")}).mountPromise.catch(t)}).catch(e=>(console.error("The host parcel used to mount extensions could not be mounted. Falling back to mounting extensions as root parcels, which leaks their DOM elements.",e),aS.mountRootParcel))),s0),c={...t},d=(a=c,o=!1,{retarget:e=>a={...e},release:i=()=>(function(e){for(let t of Object.keys(e))delete e[t]})(a),onSettled(e,t){switch(e){case"bootstrap":t&&i();return;case"mount":o||(o=t);return;case"unmount":(t||o)&&i();return}}});return n=u((r=d.onSettled,"function"==typeof e?()=>e().then(e=>s4(e,r)):s4(e,r)),c),s=e=>t=>e.call(n,d.retarget(t)).catch(e=>{throw"SKIP_BECAUSE_BROKEN"===n.getStatus()&&d.release(),e}),l=n.update&&s(n.update),Object.defineProperty(n,"update",{configurable:!0,enumerable:!0,get:()=>l,set:e=>{l=e&&s(e)}})}function s3(){return s6}function s6(e,t){let r,n=s2(e,t).then(e=>r=e);return{mount:()=>n.then(e=>e.mount()),unmount:()=>n.then(e=>e.unmount()),update:e=>n.then(t=>t.update?.(e)),getStatus:()=>r?.getStatus()??"LOADING_SOURCE_CODE",get loadPromise(){return n.then(e=>e.loadPromise)},get bootstrapPromise(){return n.then(e=>e.bootstrapPromise)},get mountPromise(){return n.then(e=>e.mountPromise)},get unmountPromise(){return n.then(e=>e.unmountPromise)}}}async function s5(e,t,r,n,a=e=>e,o={}){let i=sE(n),s=sx(n),l=null;if(e){let u;if(!s)throw Error(`Couldn't find extension '${i}' to attach to '${t}'`);let{meta:c,moduleName:d,load:m}=s,p=sQ++,f=`${t}/${n}-${p}`;e.dataset.extensionRenderingId=f;let h=e=>{try{i8(f)}catch(t){console.error(e,t)}};try{i9({renderingId:f,extensionName:i,extensionModuleName:d,extensionId:n,slotName:t,slotModuleName:r})}catch(e){throw h(`Recomputing configuration after registering '${n}' failed also failed`),e}try{u=await m()}catch(e){throw h(`Recomputing configuration after '${n}' failed to load also failed`),e}try{l=await s2(a({...u,name:`${t}/${i}-${p}`}),{...o,_meta:c,_extensionContext:{extensionId:n,extensionSlotName:t,extensionSlotModuleName:r,extensionModuleName:d,extensionMeta:c},domElement:e})}catch(e){throw h(`Recomputing configuration after '${n}' failed to mount also failed`),e}l.mountPromise.then(void 0,e=>{console.error(`Extension '${n}' in slot '${t}' failed to mount`,e),h(`Recomputing configuration after '${n}' failed to mount also failed`)}),l.unmountPromise.then(()=>h(`Recomputing configuration after unmounting '${n}' failed`),e=>{console.error(`Extension '${n}' in slot '${t}' failed to unmount`,e),h(`Recomputing configuration after '${n}' failed to unmount also failed`)})}else console.warn(`Tried to render ${n} into ${t} but no DOM element was available.`);return l}var s9=r(4587),s8=r.n(s9);let s7=(0,s9.createContext)({moduleName:"",featureName:""});function le({to:e,templateParams:t,onBeforeNavigate:r,children:n,...a}){return(0,s9.useEffect)(()=>{a.href&&console.warn(`ConfigurableLink does not support the href prop. Use the 'to' prop instead. The provided href value is '${a.href}'`),a.onClick&&console.warn(`ConfigurableLink does not support the onClick prop. Use the 'onBeforeNavigate' prop instead. The 'to' prop of the offending link is ${e}`)},[]),s8().createElement("a",{onClick:n=>{0===n.button&&!n.ctrlKey&&!n.shiftKey&&!n.altKey&&!n.metaKey&&(n.preventDefault(),r?.(n),aO({to:e,templateParams:t})),0===n.button&&(n.ctrlKey||n.metaKey)&&r?.(n),0===n.button&&n.shiftKey&&r?.(n),1===n.button&&r?.(n)},href:a$(e,t),...a},n)}let lt=({state:e,children:t,...r})=>{let{extension:n}=(0,s9.useContext)(s7),a=(0,s9.useRef)(null),o=(0,s9.useRef)(Promise.resolve()),i=(0,s9.useRef)(!1),s=(0,s9.useRef)(!1),l=(0,s9.useRef)(e),u=(0,s9.useCallback)(e=>{if(!e)return;let t=()=>{"MOUNTED"===e.getStatus()&&e.unmount()};switch(e.getStatus()){case"MOUNTED":e.unmount();break;case"UPDATING":o.current?.then(t,t);break;default:e.mountPromise.then(t,()=>{})}},[]),c=(0,s9.useCallback)((e,t)=>{e.update&&"UNMOUNTING"!==e.getStatus()&&(o.current=Promise.all([e.mountPromise,o.current]).then(()=>{if(a.current?.getStatus()==="MOUNTED"&&a.current.update)return a.current.update({...t})}).catch(e=>{let t=a.current?.getStatus();"UNMOUNTING"!==t&&"NOT_MOUNTED"!==t&&"UNLOADING"!==t&&console.error(`The extension '${n?.extensionId}' failed to update`,e)}))},[]),d=(0,s9.useCallback)(t=>{t&&!a.current&&!s.current&&n?.extensionSlotName&&n.extensionSlotModuleName&&(s.current=!0,s5(t,n.extensionSlotName,n.extensionSlotModuleName,n.extensionId,void 0,e).then(t=>{(s.current=!1,a.current=t,i.current)?u(t):t&&l.current!==e&&c(t,l.current)},()=>{s.current=!1}))},[]);return(0,s9.useEffect)(()=>(i.current=!1,()=>{i.current=!0,u(a.current)}),[]),(0,s9.useEffect)(()=>{l.current=e,a.current&&c(a.current,e)},[e]),n?s8().createElement("div",{ref:d,"data-extension-id":n?.extensionId,style:{position:"relative"},...r}):null};function lr(e){let t=(0,s9.useRef)(e);return R(t.current,e)||(t.current=e),t.current}function ln(e,t){"function"==typeof t&&(t=t(e));let r={};for(let[n,a]of Object.entries(t)){let t=function(...t){e.setState(e=>a(e,...t))};r[n]=t}return r}let la=e=>e;function lo(e,t=la,r){let n=(0,s9.useCallback)(t=>e.subscribe(t),[e]),a=(0,s9.useCallback)(()=>t(e.getState()),[e,t]),o=(0,s9.useSyncExternalStore)(n,a,a),i=(0,s9.useMemo)(()=>r?ln(e,r):null,[e,r]);return(0,s9.useMemo)(()=>i?{...o,...i}:o,[o,i])}function li(e,t){return lo(e,la,t)}function ls(e){return function(t){let r=(0,s9.useCallback)(t=>e.subscribe(t),[]),n=(0,s9.useCallback)(()=>e.getState(),[]),a=(0,s9.useSyncExternalStore)(r,n,n),o=(0,s9.useMemo)(()=>t?ln(e,t):null,[t]);return(0,s9.useMemo)(()=>o?{...a,...o}:a,[a,o])}}let ll=[];Object.freeze(ll);let lu={candidateExtensions:ll};Object.freeze(lu);let lc=e=>{let t=(0,s9.useCallback)(t=>t.slots?.[e]??lu,[e]);return lo(i7(),t)},ld=e=>e.session;function lm(e,t){let{candidateExtensions:r}=lc(e),n=lo(aY,ld),a=lr(t);return(0,s9.useMemo)(()=>sR(e,a),[e,a,n,r])}function lp(e,t){let{moduleName:r}=(0,s9.useContext)(s7);if(!r)throw Error("ComponentContext has not been provided. This should come from @openmrs/esm-react-utils.");return(0,s9.useEffect)(()=>{s$(r,e)},[r,e]),{extensions:lm(e,t),extensionSlotName:e,extensionSlotModuleName:r}}function lf(e){return e}function lh({name:e,extensionSlotName:t,select:r=lf,children:n,state:a,style:o,...i}){if(n&&a)throw Error("Both children and state have been provided. If children are provided, the state must be passed as a prop to the `Extension` component.");let s=e??t,l=(0,s9.useRef)(null),{extensions:u,extensionSlotModuleName:c}=lp(s,a),d=(0,s9.useMemo)(()=>r(u),[r,u]),m=(0,s9.useMemo)(()=>{if("function"==typeof n&&!s8().isValidElement(n))return d.map(e=>n(e,a))},[n,d]);return s8().createElement("div",{ref:l,"data-extension-slot-name":s,"data-extension-slot-module-name":c,style:{...o,position:"relative"},...i},s&&d?.map((e,t)=>s8().createElement(s7.Provider,{key:e.id,value:{moduleName:c,featureName:"",extension:{extensionId:e.id,extensionSlotName:s,extensionSlotModuleName:c,extensionMeta:e.meta}}},m?.[t]??("function"!=typeof n?n:null)??s8().createElement(lt,{state:a}))))}var lg=r(5338);function ly(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function lv(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ly(Object(r),!0).forEach(function(t){var n,a,o;n=e,a=t,o=r[t],a in n?Object.defineProperty(n,a,{value:o,enumerable:!0,configurable:!0,writable:!0}):n[a]=o}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ly(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function lb(e){return(lb="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function lw(e){return(lw="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function lE(e,t){var r;if("function"!=typeof(r=t.domElement?function(){return t.domElement}:t.domElementGetter?t.domElementGetter:e.domElementGetter?e.domElementGetter:function(e){var t=e.appName||e.name;if(!t)throw Error("single-spa's dom-element-getter-helpers was not given an application name as a prop, so it can't make a unique dom element container for the react application");var r="single-spa-application:".concat(t);return function(){var e=document.getElementById(r);return e||((e=document.createElement("div")).id=r,document.body.appendChild(e)),e}}(t)))throw Error("single-spa's dom-element-getter-helpers was given an invalid domElementGetter for application or parcel '".concat(t.name,"'. Expected a function, received ").concat(lw(r)));return function(){var e=r(t);if(!(e instanceof HTMLElement))throw Error("single-spa's dom-element-getter-helpers: domElementGetter returned an invalid dom element for application or parcel '".concat(t.name,"'. Expected HTMLElement, received ").concat(lw(e)));return e}}var l_=null;try{l_=require("react").createContext()}catch(e){}var lx={React:null,ReactDOM:null,ReactDOMClient:null,rootComponent:null,loadRootComponent:null,errorBoundary:null,errorBoundaryClass:null,domElementGetter:null,parcelCanUpdate:!0,suppressComponentDidCatchWarning:!1,domElements:{},renderResults:{},updateResolves:{},unmountResolves:{}};function lD(e,t){return e.rootComponent?Promise.resolve():e.loadRootComponent(t).then(function(t){e.rootComponent=t})}function lS(e,t){return new Promise(function(r,n){e.suppressComponentDidCatchWarning||!function(e){if(!(e&&"string"==typeof e.version&&e.version.indexOf(".")>=0))return!1;var t=e.version.slice(0,e.version.indexOf("."));try{return Number(t)>=16}catch(e){return!1}}(e.React)||e.errorBoundary||e.errorBoundaryClass||(e.rootComponent.prototype?e.rootComponent.prototype.componentDidCatch||console.warn("single-spa-react: ".concat(t.name||t.appName||t.childAppName,"'s rootComponent should implement componentDidCatch to avoid accidentally unmounting the entire single-spa application.")):console.warn("single-spa-react: ".concat(t.name||t.appName||t.childAppName,"'s rootComponent does not implement an error boundary. If using a functional component, consider providing an opts.errorBoundary to singleSpaReact(opts).")));var a,o=lR(e,t,function(){r(this)}),i=lE(e,t)(),s=function(e){var t=e.reactDom,r=e.renderType,n=e.elementToRender,a=e.domElement,o=t[r];if("function"!=typeof o)throw Error('renderType "'.concat(r,'" did not return a function.'));switch(r){case"createRoot":case"unstable_createRoot":case"createBlockingRoot":case"unstable_createBlockingRoot":var i=o(a);return i.render(n),i;case"hydrateRoot":return o(a,n);default:return o(n,a),null}}({elementToRender:o,domElement:i,reactDom:lP(e),renderType:"function"==typeof(a=e).renderType?a.renderType():a.renderType});e.domElements[t.name]=i,e.renderResults[t.name]=s})}function lC(e,t){return new Promise(function(r){e.unmountResolves[t.name]=r;var n=e.renderResults[t.name];n&&n.unmount?n.unmount():lP(e).unmountComponentAtNode(e.domElements[t.name]),delete e.domElements[t.name],delete e.renderResults[t.name]})}function lk(e,t){return new Promise(function(r){e.updateResolves[t.name]||(e.updateResolves[t.name]=[]),e.updateResolves[t.name].push(r);var n=lR(e,t,null),a=e.renderResults[t.name];if(a&&a.render)a.render(n);else{var o=lE(e,t)();lP(e).render(n,o)}})}function lP(e){return e.ReactDOMClient||e.ReactDOM}function lR(e,t,r){var n=e.React.createElement(e.rootComponent,t),a=l_?e.React.createElement(l_.Provider,{value:t},n):n;return(e.errorBoundary||t.errorBoundary||e.errorBoundaryClass||t.errorBoundaryClass)&&(e.errorBoundaryClass=e.errorBoundaryClass||t.errorBoundaryClass||function(e,t){function r(t){e.React.Component.apply(this,arguments),this.state={caughtError:null,caughtErrorInfo:null},r.displayName="SingleSpaReactErrorBoundary(".concat(t.name,")")}return r.prototype=Object.create(e.React.Component.prototype),r.prototype.render=function(){return this.state.caughtError?(e.errorBoundary||t.errorBoundary)(this.state.caughtError,this.state.caughtErrorInfo,this.props):this.props.children},r.prototype.componentDidCatch=function(e,t){this.setState({caughtError:e,caughtErrorInfo:t})},r}(e,t),a=e.React.createElement(e.errorBoundaryClass,t,a)),a=e.React.createElement(e.SingleSpaRoot,lv(lv({},t),{},{mountFinished:r,updateFinished:function(){e.updateResolves[t.name]&&(e.updateResolves[t.name].forEach(function(e){return e()}),delete e.updateResolves[t.name])},unmountFinished:function(){e.unmountResolves[t.name]&&(e.unmountResolves[t.name](),delete e.unmountResolves[t.name])}}),a)}var lT=r(587),l$=r(2272),lN=r(8444);let lO={strictMode:!0,throwErrorsToConsole:!0,disableTranslations:!1},lI=new Map;(0,lN.y)(lI);let lj={errorRetryCount:3,fetcher:aG,focusThrottleInterval:18e5,revalidateIfStale:!0,revalidateOnFocus:!1,revalidateOnReconnect:!1,refreshInterval:0,shouldRetryOnError:e=>{if(e instanceof aZ){let t=e.response.status;return!!(t>=500)||401===t||403===t||429===t}return!0},provider:()=>lI};function lM(e){if("object"!=typeof e||"string"!=typeof e.featureName||"string"!=typeof e.moduleName)throw Error("Invalid options");let t=Object.assign({},lO,e),r={...lj,...t.swrConfig};return function(e){var n,a,o,i,s;return o=a=class extends(n=s8().Component){componentDidCatch(e,r){r&&r.componentStack&&(e.extra=Object.assign(e.extra||{},{componentStack:r.componentStack})),t.throwErrorsToConsole&&setTimeout(()=>{throw e}),this.setState({caughtError:e,caughtErrorInfo:r})}render(){if(this.state.caughtError)return s8().createElement("div",null,"An error has occurred. Please try reloading the page.");{let n=s8().createElement(s9.Suspense,{fallback:null},s8().createElement(l$.S,{value:r},s8().createElement(s7.Provider,{value:this.state.config},t.disableTranslations?s8().createElement(e,this.props):s8().createElement(lT.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},s8().createElement(e,this.props)))));return t.strictMode&&s8().StrictMode?s8().createElement(s8().StrictMode,null,n):n}}constructor(e){super(e),this.state={caughtError:null,caughtErrorInfo:null,config:{moduleName:t.moduleName,featureName:t.featureName,extension:e._extensionContext}}}},i="displayName",s=`OpenmrsReactComponent(${t.featureName})`,i in o?Object.defineProperty(o,i,{value:s,enumerable:!0,configurable:!0,writable:!0}):o[i]=s,a}}function lA(e,t){return function(e){if("object"!==lb(e))throw Error("single-spa-react requires a configuration object");var t,r=lv(lv({},lx),e);if(!r.React)throw Error("single-spa-react must be passed opts.React");if(!r.ReactDOM&&!r.ReactDOMClient)throw Error("single-spa-react must be passed opts.ReactDOM or opts.ReactDOMClient");if(r.renderType||(null!=(t=r.ReactDOMClient)&&t.createRoot?r.renderType="createRoot":r.renderType="render"),!r.rootComponent&&!r.loadRootComponent)throw Error("single-spa-react must be passed opts.rootComponent or opts.loadRootComponent");if(r.errorBoundary&&"function"!=typeof r.errorBoundary)throw Error("The errorBoundary opt for single-spa-react must either be omitted or be a function that returns React elements");!l_&&r.React.createContext&&(l_=r.React.createContext()),r.SingleSpaRoot=function(e){function t(e){t.displayName="SingleSpaRoot(".concat(e.name,")")}return t.prototype=Object.create(e.React.Component.prototype),t.prototype.componentDidMount=function(){setTimeout(this.props.mountFinished)},t.prototype.componentWillUnmount=function(){setTimeout(this.props.unmountFinished)},t.prototype.render=function(){return setTimeout(this.props.updateFinished),this.props.children},t}(r);var n={bootstrap:lD.bind(null,r),mount:lS.bind(null,r),unmount:lC.bind(null,r)};return r.parcelCanUpdate&&(n.update=lk.bind(null,r)),n}({React:s8(),ReactDOMClient:lg,rootComponent:lM(t)(e)})}function lL(e,t){return()=>e().then(({default:e})=>lA(e,t))}function lF(e,t){return()=>Promise.resolve(lA(e,t))}let lB=lL,lV=O()(()=>({}));B("openmrs-app-context",lV);let lU={};function lW(e,t=e=>e){let r=lV.getState();return e in r?Object.freeze(Object.assign({},t?t(r[e]):r[e])):null}function lH(e,t){lV.setState(r=>(e in r||(r[e]={}),r[e]=t(r[e]),Object.assign({},r)))}function lz(e){return null===e?null:Object.freeze(Object.assign({},e))}let lK=new Map;function lG(e,t){let r=(0,s9.useRef)(t??{}),n=(0,s9.useRef)(t=>lH(e,t)),a=(0,s9.useRef)(Symbol());return(0,s9.useEffect)(()=>{let r=t??{},n=a.current;return null===lW(e)?!function(e,t=lU){lV.setState(r=>{if(e in r)throw Error(`Attempted to re-register namespace ${e} in the app context. Each namespace must be unregistered before the name can be registered again.`);return Object.assign({},r,{[e]:t===lU?{}:t})})}(e,r):(console.warn(`Namespace ${e} is already registered in the app context. This is likely a race condition during navigation, but may indicate two components are trying to own the same namespace. Updating the existing context.`),lH(e,()=>r)),lK.set(e,n),()=>{lK.get(e)===n&&(lV.setState(t=>(e in t&&delete t[e],t)),lK.delete(e))}},[e]),(0,s9.useEffect)(()=>{let n=t??{};R(r.current,n)||(lH(e,()=>n),r.current=n)},[t]),n.current}function lZ({namespace:e,value:t}){return lG(e,t),null}let lY=({children:e,value:t,fallback:r})=>t?s8().createElement(s8().Fragment,null,e):r?s8().createElement(s8().Fragment,null,r):null;function lq(){let e=(0,s9.useRef)();return(!e.current||e.current.signal.aborted)&&(e.current=new AbortController),(0,s9.useEffect)(()=>{let t=e.current;return()=>t?.abort()},[]),e.current}function lJ(e,t=e=>e??{}){let[r,n]=(0,s9.useState)(()=>{if(lX(e))return;let r=lW(e);if(null!==r)return t?t(r):r});return(0,s9.useEffect)(()=>{if(lX(e))throw Error(`The namespace supplied to useAppContext must be a non-empty string, but was "${e}".`)},[e]),(0,s9.useEffect)(()=>{var r;let a;return(r=e=>{if(null==e)return void n(void 0);let r=t?t(e):e;n(e=>R(e,r)?e:r)})(lz(a=lW(e))),lV.subscribe(t=>{let n=e in t?t[e]:null;n!==a&&(a=n,r(lz(n)))})},[e,t]),r}function lX(e){return"string"!=typeof e||0===e.trim().length}function lQ(e){let t=lm(e);return(0,s9.useMemo)(()=>t.map(e=>e.id),[t])}function l0(e){return lc(e).candidateExtensions}function l1(e,t,r){let{data:n,error:a,mutate:o,isLoading:i,isValidating:s}=(0,l$.u)(e?oQ(e,t,r):null,aG);return(0,s9.useMemo)(()=>({isLoading:i,data:n?.data.results??[],error:a,mutate:o,isValidating:s}),[n,a,i,s,o])}function l4(e){(0,s9.useEffect)(()=>{if(e){let e=window.getComputedStyle(document.body).overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=e}}},[e])}let l2={},l3=`No ComponentContext has been provided. This should come from "openmrsComponentDecorator".
|