@openmrs/esm-patient-chart-app 13.0.2-pre.12921 → 13.0.2-pre.12936

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/5891.js CHANGED
@@ -12,8 +12,8 @@ If you're the maintainer: the 'elements' key only works with '_type' equal to 'A
12
12
  ${t}`)}return n}let rj=(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&&rL(e)){if(a._type===tU.Array&&Array.isArray(n)){let a=n.map(t=>rj(e,t));r[t]=a}else if(a._type===tU.Object)for(let t of Object.keys(n))n[t]=rj(e,n[t])}}else if(rF(a)){let e=n??{};rF(e)&&(r[t]=rj(a,e))}}return r};function rL(e){return!!e&&Object.keys(e).filter(e=>!["_default","_validators"].includes(e)).length>0}function rF(e){return"object"==typeof e&&!Array.isArray(e)&&null!==e}function rB(e,t){let r=`${e}:::${t}`;ru.has(r)||(console.error(t),ru.add(r))}function rV(e){e?ru.forEach(t=>{t.startsWith(e)&&ru.delete(t)}):ru.clear()}function rU(){rl.forEach(e=>e()),rl.length=0,rf.clear(),rC.clear(),rP.clear(),rk.clear(),rc=null,rd=new WeakMap,rm()}let rW={"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:tU.Object,_default:{},_validators:[tW(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(", ")}.`})]}},rH={"Display conditions":{privileges:{_description:"The privilege(s) the user must have to use this extension",_type:tU.Array,_default:[]},expression:{_description:"The expression that determines whether the extension is displayed",_type:tU.String,_default:void 0}},...rW},rz=(e,t)=>tW(r=>e<=r&&r<=t,`must be between ${e} and ${t}`),rK=e=>{let t=e.concat(["openmrsBase","openmrsSpaBase"]);return tW(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(", "))},rG=rK([]),rZ=e=>tW(t=>e.includes(t),`Must be one of the following: '${e.join("', '")}'.`),rY={inRange:rz,isUrl:rG,isUrlWithTemplateParameters:rK,oneOf:rZ};var rq=r(2034);let rJ=B("breadcrumbs",[]);function rX(e){return rQ([e])}function rQ(e){let t=[...r0(),...e.map(e=>({matcher:e.matcher instanceof RegExp?e.matcher:"string"==typeof e.matcher?(0,rq.pathToRegexp)(e.matcher).regexp:(0,rq.pathToRegexp)(e.path).regexp,settings:e}))];rJ.setState(t,!0)}function r0(){return rJ.getState()}function r1(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=r1(e,r.join("/"));if(t)return t}}(e,t)}function r4(e,t){if(e.length>0){let r=r1(e,t);if(r){let t=[r],n=r1(e,r.settings.parent);for(;void 0!==n;)t.push(n),n=r1(e,n.settings.parent);return t.reverse()}}return[]}function r2(e){return r4(r0(),e)}var r3=r(9374);let r6={address1:"Address line 1",address2:"Address line 2",address3:"Address line 3",address4:"Address line 4",address5:"Address line 5",address6:"Address line 6",city:"City",cityVillage:"City",country:"Country",countyDistrict:"District",district:"District",postalCode:"Postal code",state:"State",stateProvince:"State",closeAllOpenedWorkspaces:"Discard changes in {{count}} workspaces",closingAllWorkspacesPromptBody:"There may be unsaved changes in the following workspaces. Do you want to discard changes in the following workspaces? {{workspaceNames}}",closingAllWorkspacesPromptTitle:"You have unsaved changes",discard:"Discard",hide:"Hide",maximize:"Maximize",minimize:"Minimize",openAnyway:"Open anyway",unsavedChangesInOpenedWorkspace:"You may have unsaved changes in the opened workspace. Do you want to discard these changes?",unsavedChangesInWorkspace:'There may be unsaved changes in "{{workspaceName}}". Please save them before opening another workspace.',unsavedChangesTitleText:"Unsaved changes",workspaceHeader:"Workspace header",discardUnsavedChangesPromptBodyMultiple:"{{count}} workspaces have unsaved changes. Closing them will discard the changes:",discardUnsavedChangesPromptBodySingle:"<strong>{{workspaceTitle}}</strong> has unsaved changes. Closing it will discard them.",discardUnsavedChangesPromptTitle:"Discard unsaved changes?",keepEditing:"Keep editing",abnormalValue:"Abnormal value",actions:"Actions",actionableNotification:"Actionable notification",address:"Address",age:"Age",applicationError:"Application Error",batchActionItemSelected:"{{totalSelected}} item selected",batchActionsItemsSelected:"{{totalSelected}} items selected",cancel:"Cancel",change:"Change",Clinic:"Clinic",clearDevOverrides:"Clear dev overrides",close:"Close",closesActionableNotification:"Close actionable notification",closeSnackbar:"Close snackbar",confirm:"Confirm",contactAdministratorIfIssuePersists:"Contact your system administrator if the problem persists.",contactDetails:"Contact details",copied:"Copied!",copyToClipboard:"Copy to clipboard",delete:"Delete",discardChanges:"Discard changes",edit:"Edit",emptyStateText:"There are no {{displayText}} to display",error:"Error",errorCopy:"Sorry, there was a problem displaying this information. You can try to reload this page, or contact the site administrator and quote the error code above.",errorLoadingLoginLocations:"Unable to load login locations. Please try again or contact support if the problem persists.",female:"Female",leftNavigation:"Left navigation",loading:"Loading",localVersion:"Local Build",male:"Male",navigateNonHttp:"Could not navigate to the requested page as it is not a safe URL",noResultsToDisplay:"No results to display",notAvailable:"Not available",other:"Other",paginationItemsCount:"{{pageItemsCount}} / {{totalItems}} items",paginationOfPages:"of {{count}} pages",patientAvatarAlt:"Avatar for {{patientName}}",patientIdentifierSticker:"Patient identifier sticker",patientLists:"Patient lists",patientPhotoAlt:"Profile photo of {{patientName}}",patientPhotoPlaceholder:"Photo placeholder for {{patientName}}",prereleaseVersion:"Prerelease",print:"Print",printError:"Print error",printErrorExplainer:"An error occurred in {{errorLocation}}",printIdentifierSticker:"Print identifier sticker",printing:"Printing",provisional:"Provisional",recordNewEntry:"Record {{displayText}}",relationships:"Relationships",reload:"Reload",resetOverrides:"Reset overrides",save:"Save",scriptLoadingFailed:"Error: Script failed to load",scriptLoadingError:"Failed to load overridden script from {{url}}. Please check that the bundled script is available at the expected URL. Click the button below to reset all import map overrides.",searchForLocation:"Search for a location",seeAll:"See all",seeMoreLists:"See {{count}} more lists",selectAll:"Select all",serverStartingUp:"The server is starting",serverStartingUpExplainer:"This can take a few minutes. OpenMRS will open automatically when the server is ready.",serverStartingUpSlowExplainer:"This is taking longer than usual. First startup after an upgrade can take 10 minutes or more. You can leave this page open.",sex:"Sex",showLess:"Show less",showMore:"Show more",snackbarNotification:"Snackbar notification",somethingWentWrongTryReloading:"Something went wrong. Please try reloading.",toggleDevTools:"Toggle dev tools",unknown:"Unknown",viewSetupProgress:"View setup progress",waitingForServer:"Waiting for the server",yearAbbreviation:"yr",yearsAbbreviation:"yrs"},r5=e=>"string"==typeof e,r9=()=>{let e,t,r=new Promise((r,n)=>{e=r,t=n});return r.resolve=e,r.reject=t,r},r8=e=>null==e?"":""+e,r7=/###/g,ne=e=>e&&e.indexOf("###")>-1?e.replace(r7,"."):e,nt=e=>!e||r5(e),nr=(e,t,r)=>{let n=r5(t)?t.split("."):t,a=0;for(;a<n.length-1;){if(nt(e))return{};let t=ne(n[a]);!e[t]&&r&&(e[t]=new r),e=Object.prototype.hasOwnProperty.call(e,t)?e[t]:{},++a}return nt(e)?{}:{obj:e,k:ne(n[a])}},nn=(e,t,r)=>{let{obj:n,k:a}=nr(e,t,Object);if(void 0!==n||1===t.length){n[a]=r;return}let o=t[t.length-1],i=t.slice(0,t.length-1),s=nr(e,i,Object);for(;void 0===s.obj&&i.length;)o=`${i[i.length-1]}.${o}`,s=nr(e,i=i.slice(0,i.length-1),Object),s?.obj&&void 0!==s.obj[`${s.k}.${o}`]&&(s.obj=void 0);s.obj[`${s.k}.${o}`]=r},na=(e,t)=>{let{obj:r,k:n}=nr(e,t);if(r&&Object.prototype.hasOwnProperty.call(r,n))return r[n]},no=(e,t,r)=>{for(let n in t)"__proto__"!==n&&"constructor"!==n&&(n in e?r5(e[n])||e[n]instanceof String||r5(t[n])||t[n]instanceof String?r&&(e[n]=t[n]):no(e[n],t[n],r):e[n]=t[n]);return e};var ni={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};let ns=e=>r5(e)?e.replace(/[&<>"'\/]/g,e=>ni[e]):e,nl=[" ",",","?","!",";"],nu=new class{constructor(e){this.capacity=e,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(e){let t=this.regExpMap.get(e);if(void 0!==t)return t;let r=new RegExp(e);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(e,r),this.regExpQueue.push(e),r}}(20),nc=(e,t,r=".")=>{if(!e)return;if(e[t]){if(!Object.prototype.hasOwnProperty.call(e,t))return;return e[t]}let n=t.split(r),a=e;for(let e=0;e<n.length;){let t;if(!a||"object"!=typeof a)return;let o="";for(let i=e;i<n.length;++i)if(i!==e&&(o+=r),o+=n[i],void 0!==(t=a[o])){if(["string","number","boolean"].indexOf(typeof t)>-1&&i<n.length-1)continue;e+=i-e+1;break}a=t}return a},nd=e=>e?.replace("_","-"),nm={type:"logger",log(e){this.output("log",e)},warn(e){this.output("warn",e)},error(e){this.output("error",e)},output(e,t){console?.[e]?.apply?.(console,t)}};class np{constructor(e,t={}){this.init(e,t)}init(e,t={}){this.prefix=t.prefix||"i18next:",this.logger=e||nm,this.options=t,this.debug=t.debug}log(...e){return this.forward(e,"log","",!0)}warn(...e){return this.forward(e,"warn","",!0)}error(...e){return this.forward(e,"error","")}deprecate(...e){return this.forward(e,"warn","WARNING DEPRECATED: ",!0)}forward(e,t,r,n){return n&&!this.debug?null:(r5(e[0])&&(e[0]=`${r}${this.prefix} ${e[0]}`),this.logger[t](e))}create(e){return new np(this.logger,{...{prefix:`${this.prefix}:${e}:`},...this.options})}clone(e){return(e=e||this.options).prefix=e.prefix||this.prefix,new np(this.logger,e)}}var nf=new np;class nh{constructor(){this.observers={}}on(e,t){return e.split(" ").forEach(e=>{this.observers[e]||(this.observers[e]=new Map);let r=this.observers[e].get(t)||0;this.observers[e].set(t,r+1)}),this}off(e,t){if(this.observers[e]){if(!t)return void delete this.observers[e];this.observers[e].delete(t)}}emit(e,...t){this.observers[e]&&Array.from(this.observers[e].entries()).forEach(([e,r])=>{for(let n=0;n<r;n++)e(...t)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(([r,n])=>{for(let a=0;a<n;a++)r.apply(r,[e,...t])})}}class ng extends nh{constructor(e,t={ns:["translation"],defaultNS:"translation"}){super(),this.data=e||{},this.options=t,void 0===this.options.keySeparator&&(this.options.keySeparator="."),void 0===this.options.ignoreJSONStructure&&(this.options.ignoreJSONStructure=!0)}addNamespaces(e){0>this.options.ns.indexOf(e)&&this.options.ns.push(e)}removeNamespaces(e){let t=this.options.ns.indexOf(e);t>-1&&this.options.ns.splice(t,1)}getResource(e,t,r,n={}){let a,o=void 0!==n.keySeparator?n.keySeparator:this.options.keySeparator,i=void 0!==n.ignoreJSONStructure?n.ignoreJSONStructure:this.options.ignoreJSONStructure;e.indexOf(".")>-1?a=e.split("."):(a=[e,t],r&&(Array.isArray(r)?a.push(...r):r5(r)&&o?a.push(...r.split(o)):a.push(r)));let s=na(this.data,a);return(!s&&!t&&!r&&e.indexOf(".")>-1&&(e=a[0],t=a[1],r=a.slice(2).join(".")),!s&&i&&r5(r))?nc(this.data?.[e]?.[t],r,o):s}addResource(e,t,r,n,a={silent:!1}){let o=void 0!==a.keySeparator?a.keySeparator:this.options.keySeparator,i=[e,t];r&&(i=i.concat(o?r.split(o):r)),e.indexOf(".")>-1&&(i=e.split("."),n=t,t=i[1]),this.addNamespaces(t),nn(this.data,i,n),a.silent||this.emit("added",e,t,r,n)}addResources(e,t,r,n={silent:!1}){for(let n in r)(r5(r[n])||Array.isArray(r[n]))&&this.addResource(e,t,n,r[n],{silent:!0});n.silent||this.emit("added",e,t,r)}addResourceBundle(e,t,r,n,a,o={silent:!1,skipCopy:!1}){let i=[e,t];e.indexOf(".")>-1&&(i=e.split("."),n=r,r=t,t=i[1]),this.addNamespaces(t);let s=na(this.data,i)||{};o.skipCopy||(r=JSON.parse(JSON.stringify(r))),n?no(s,r,a):s={...s,...r},nn(this.data,i,s),o.silent||this.emit("added",e,t,r)}removeResourceBundle(e,t){this.hasResourceBundle(e,t)&&delete this.data[e][t],this.removeNamespaces(t),this.emit("removed",e,t)}hasResourceBundle(e,t){return void 0!==this.getResource(e,t)}getResourceBundle(e,t){return t||(t=this.options.defaultNS),this.getResource(e,t)}getDataByLanguage(e){return this.data[e]}hasLanguageSomeTranslations(e){let t=this.getDataByLanguage(e);return!!(t&&Object.keys(t)||[]).find(e=>t[e]&&Object.keys(t[e]).length>0)}toJSON(){return this.data}}var ny={processors:{},addPostProcessor(e){this.processors[e.name]=e},handle(e,t,r,n,a){return e.forEach(e=>{t=this.processors[e]?.process(t,r,n,a)??t}),t}};let nv=Symbol("i18next/PATH_KEY");function nb(e,t){let r,n,a,{[nv]:o}=e((n=[],(a=Object.create(null)).get=(e,t)=>(r?.revoke?.(),t===nv)?n:(n.push(t),(r=Proxy.revocable(e,a)).proxy),Proxy.revocable(Object.create(null),a).proxy));return o.join(t?.keySeparator??".")}let nw={},nx=e=>!r5(e)&&"boolean"!=typeof e&&"number"!=typeof e;class nE extends nh{constructor(e,t={}){super(),((e,t,r)=>{e.forEach(e=>{t[e]&&(r[e]=t[e])})})(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=t,void 0===this.options.keySeparator&&(this.options.keySeparator="."),this.logger=nf.create("translator")}changeLanguage(e){e&&(this.language=e)}exists(e,t={interpolation:{}}){let r={...t};if(null==e)return!1;let n=this.resolve(e,r);if(n?.res===void 0)return!1;let a=nx(n.res);return!1!==r.returnObjects||!a}extractFromKey(e,t){let r=void 0!==t.nsSeparator?t.nsSeparator:this.options.nsSeparator;void 0===r&&(r=":");let n=void 0!==t.keySeparator?t.keySeparator:this.options.keySeparator,a=t.ns||this.options.defaultNS||[],o=r&&e.indexOf(r)>-1,i=!this.options.userDefinedKeySeparator&&!t.keySeparator&&!this.options.userDefinedNsSeparator&&!t.nsSeparator&&!((e,t,r)=>{t=t||"",r=r||"";let n=nl.filter(e=>0>t.indexOf(e)&&0>r.indexOf(e));if(0===n.length)return!0;let a=nu.getRegExp(`(${n.map(e=>"?"===e?"\\?":e).join("|")})`),o=!a.test(e);if(!o){let t=e.indexOf(r);t>0&&!a.test(e.substring(0,t))&&(o=!0)}return o})(e,r,n);if(o&&!i){let t=e.match(this.interpolator.nestingRegexp);if(t&&t.length>0)return{key:e,namespaces:r5(a)?[a]:a};let o=e.split(r);(r!==n||r===n&&this.options.ns.indexOf(o[0])>-1)&&(a=o.shift()),e=o.join(n)}return{key:e,namespaces:r5(a)?[a]:a}}translate(e,t,r){let n="object"==typeof t?{...t}:t;if("object"!=typeof n&&this.options.overloadTranslationOptionHandler&&(n=this.options.overloadTranslationOptionHandler(arguments)),"object"==typeof n&&(n={...n}),n||(n={}),null==e)return"";"function"==typeof e&&(e=nb(e,{...this.options,...n})),Array.isArray(e)||(e=[String(e)]);let a=void 0!==n.returnDetails?n.returnDetails:this.options.returnDetails,o=void 0!==n.keySeparator?n.keySeparator:this.options.keySeparator,{key:i,namespaces:s}=this.extractFromKey(e[e.length-1],n),l=s[s.length-1],u=void 0!==n.nsSeparator?n.nsSeparator:this.options.nsSeparator;void 0===u&&(u=":");let c=n.lng||this.language,d=n.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(c?.toLowerCase()==="cimode")return d?a?{res:`${l}${u}${i}`,usedKey:i,exactUsedKey:i,usedLng:c,usedNS:l,usedParams:this.getUsedParamsDetails(n)}:`${l}${u}${i}`:a?{res:i,usedKey:i,exactUsedKey:i,usedLng:c,usedNS:l,usedParams:this.getUsedParamsDetails(n)}:i;let m=this.resolve(e,n),p=m?.res,f=m?.usedKey||i,h=m?.exactUsedKey||i,g=void 0!==n.joinArrays?n.joinArrays:this.options.joinArrays,y=!this.i18nFormat||this.i18nFormat.handleAsObject,v=void 0!==n.count&&!r5(n.count),b=nE.hasDefaultValue(n),w=v?this.pluralResolver.getSuffix(c,n.count,n):"",x=n.ordinal&&v?this.pluralResolver.getSuffix(c,n.count,{ordinal:!1}):"",E=v&&!n.ordinal&&0===n.count,D=E&&n[`defaultValue${this.options.pluralSeparator}zero`]||n[`defaultValue${w}`]||n[`defaultValue${x}`]||n.defaultValue,S=p;y&&!p&&b&&(S=D);let _=nx(S),C=Object.prototype.toString.apply(S);if(y&&S&&_&&0>["[object Number]","[object Function]","[object RegExp]"].indexOf(C)&&!(r5(g)&&Array.isArray(S))){if(!n.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");let e=this.options.returnedObjectHandler?this.options.returnedObjectHandler(f,S,{...n,ns:s}):`key '${i} (${this.language})' returned an object instead of string.`;return a?(m.res=e,m.usedParams=this.getUsedParamsDetails(n),m):e}if(o){let e=Array.isArray(S),t=e?[]:{},r=e?h:f;for(let e in S)if(Object.prototype.hasOwnProperty.call(S,e)){let a=`${r}${o}${e}`;b&&!p?t[e]=this.translate(a,{...n,defaultValue:nx(D)?D[e]:void 0,...{joinArrays:!1,ns:s}}):t[e]=this.translate(a,{...n,joinArrays:!1,ns:s}),t[e]===a&&(t[e]=S[e])}p=t}}else if(y&&r5(g)&&Array.isArray(p))(p=p.join(g))&&(p=this.extendTranslation(p,e,n,r));else{let t=!1,a=!1;!this.isValidLookup(p)&&b&&(t=!0,p=D),this.isValidLookup(p)||(a=!0,p=i);let s=(n.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&a?void 0:p,d=b&&D!==p&&this.options.updateMissing;if(a||t||d){if(this.logger.log(d?"updateKey":"missingKey",c,l,i,d?D:p),o){let e=this.resolve(i,{...n,keySeparator:!1});e&&e.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}let e=[],t=this.languageUtils.getFallbackCodes(this.options.fallbackLng,n.lng||this.language);if("fallback"===this.options.saveMissingTo&&t&&t[0])for(let r=0;r<t.length;r++)e.push(t[r]);else"all"===this.options.saveMissingTo?e=this.languageUtils.toResolveHierarchy(n.lng||this.language):e.push(n.lng||this.language);let r=(e,t,r)=>{let a=b&&r!==p?r:s;this.options.missingKeyHandler?this.options.missingKeyHandler(e,l,t,a,d,n):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(e,l,t,a,d,n),this.emit("missingKey",e,l,t,p)};this.options.saveMissing&&(this.options.saveMissingPlurals&&v?e.forEach(e=>{let t=this.pluralResolver.getSuffixes(e,n);E&&n[`defaultValue${this.options.pluralSeparator}zero`]&&0>t.indexOf(`${this.options.pluralSeparator}zero`)&&t.push(`${this.options.pluralSeparator}zero`),t.forEach(t=>{r([e],i+t,n[`defaultValue${t}`]||D)})}):r(e,i,D))}p=this.extendTranslation(p,e,n,m,r),a&&p===i&&this.options.appendNamespaceToMissingKey&&(p=`${l}${u}${i}`),(a||t)&&this.options.parseMissingKeyHandler&&(p=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${l}${u}${i}`:i,t?p:void 0,n))}return a?(m.res=p,m.usedParams=this.getUsedParamsDetails(n),m):p}extendTranslation(e,t,r,n,a){if(this.i18nFormat?.parse)e=this.i18nFormat.parse(e,{...this.options.interpolation.defaultVariables,...r},r.lng||this.language||n.usedLng,n.usedNS,n.usedKey,{resolved:n});else if(!r.skipInterpolation){let o;r.interpolation&&this.interpolator.init({...r,...{interpolation:{...this.options.interpolation,...r.interpolation}}});let i=r5(e)&&(r?.interpolation?.skipOnVariables!==void 0?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);if(i){let t=e.match(this.interpolator.nestingRegexp);o=t&&t.length}let s=r.replace&&!r5(r.replace)?r.replace:r;if(this.options.interpolation.defaultVariables&&(s={...this.options.interpolation.defaultVariables,...s}),e=this.interpolator.interpolate(e,s,r.lng||this.language||n.usedLng,r),i){let t=e.match(this.interpolator.nestingRegexp);o<(t&&t.length)&&(r.nest=!1)}!r.lng&&n&&n.res&&(r.lng=this.language||n.usedLng),!1!==r.nest&&(e=this.interpolator.nest(e,(...e)=>a?.[0]!==e[0]||r.context?this.translate(...e,t):(this.logger.warn(`It seems you are nesting recursively key: ${e[0]} in key: ${t[0]}`),null),r)),r.interpolation&&this.interpolator.reset()}let o=r.postProcess||this.options.postProcess,i=r5(o)?[o]:o;return null!=e&&i?.length&&!1!==r.applyPostProcessor&&(e=ny.handle(i,e,t,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...n,usedParams:this.getUsedParamsDetails(r)},...r}:r,this)),e}resolve(e,t={}){let r,n,a,o,i;return r5(e)&&(e=[e]),e.forEach(e=>{if(this.isValidLookup(r))return;let s=this.extractFromKey(e,t),l=s.key;n=l;let u=s.namespaces;this.options.fallbackNS&&(u=u.concat(this.options.fallbackNS));let c=void 0!==t.count&&!r5(t.count),d=c&&!t.ordinal&&0===t.count,m=void 0!==t.context&&(r5(t.context)||"number"==typeof t.context)&&""!==t.context,p=t.lngs?t.lngs:this.languageUtils.toResolveHierarchy(t.lng||this.language,t.fallbackLng);u.forEach(e=>{this.isValidLookup(r)||(i=e,!nw[`${p[0]}-${e}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(i)&&(nw[`${p[0]}-${e}`]=!0,this.logger.warn(`key "${n}" for languages "${p.join(", ")}" won't get resolved as namespace "${i}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),p.forEach(n=>{let i;if(this.isValidLookup(r))return;o=n;let s=[l];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(s,l,n,e,t);else{let e;c&&(e=this.pluralResolver.getSuffix(n,t.count,t));let r=`${this.options.pluralSeparator}zero`,a=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(c&&(t.ordinal&&0===e.indexOf(a)&&s.push(l+e.replace(a,this.options.pluralSeparator)),s.push(l+e),d&&s.push(l+r)),m){let n=`${l}${this.options.contextSeparator||"_"}${t.context}`;s.push(n),c&&(t.ordinal&&0===e.indexOf(a)&&s.push(n+e.replace(a,this.options.pluralSeparator)),s.push(n+e),d&&s.push(n+r))}}for(;i=s.pop();)this.isValidLookup(r)||(a=i,r=this.getResource(n,e,i,t))}))})}),{res:r,usedKey:n,exactUsedKey:a,usedLng:o,usedNS:i}}isValidLookup(e){return void 0!==e&&!(!this.options.returnNull&&null===e)&&!(!this.options.returnEmptyString&&""===e)}getResource(e,t,r,n={}){return this.i18nFormat?.getResource?this.i18nFormat.getResource(e,t,r,n):this.resourceStore.getResource(e,t,r,n)}getUsedParamsDetails(e={}){let t=e.replace&&!r5(e.replace),r=t?e.replace:e;if(t&&void 0!==e.count&&(r.count=e.count),this.options.interpolation.defaultVariables&&(r={...this.options.interpolation.defaultVariables,...r}),!t)for(let e of(r={...r},["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"]))delete r[e];return r}static hasDefaultValue(e){let t="defaultValue";for(let r in e)if(Object.prototype.hasOwnProperty.call(e,r)&&t===r.substring(0,t.length)&&void 0!==e[r])return!0;return!1}}class nD{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=nf.create("languageUtils")}getScriptPartFromCode(e){if(!(e=nd(e))||0>e.indexOf("-"))return null;let t=e.split("-");return 2===t.length||(t.pop(),"x"===t[t.length-1].toLowerCase())?null:this.formatLanguageCode(t.join("-"))}getLanguagePartFromCode(e){if(!(e=nd(e))||0>e.indexOf("-"))return e;let t=e.split("-");return this.formatLanguageCode(t[0])}formatLanguageCode(e){if(r5(e)&&e.indexOf("-")>-1){let t;try{t=Intl.getCanonicalLocales(e)[0]}catch(e){}return(t&&this.options.lowerCaseLng&&(t=t.toLowerCase()),t)?t:this.options.lowerCaseLng?e.toLowerCase():e}return this.options.cleanCode||this.options.lowerCaseLng?e.toLowerCase():e}isSupportedCode(e){return("languageOnly"===this.options.load||this.options.nonExplicitSupportedLngs)&&(e=this.getLanguagePartFromCode(e)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(e)>-1}getBestMatchFromCodes(e){let t;return e?(e.forEach(e=>{if(t)return;let r=this.formatLanguageCode(e);(!this.options.supportedLngs||this.isSupportedCode(r))&&(t=r)}),!t&&this.options.supportedLngs&&e.forEach(e=>{if(t)return;let r=this.getScriptPartFromCode(e);if(this.isSupportedCode(r))return t=r;let n=this.getLanguagePartFromCode(e);if(this.isSupportedCode(n))return t=n;t=this.options.supportedLngs.find(e=>{if(e===n||!(0>e.indexOf("-")&&0>n.indexOf("-"))&&(e.indexOf("-")>0&&0>n.indexOf("-")&&e.substring(0,e.indexOf("-"))===n||0===e.indexOf(n)&&n.length>1))return e})}),t||(t=this.getFallbackCodes(this.options.fallbackLng)[0]),t):null}getFallbackCodes(e,t){if(!e)return[];if("function"==typeof e&&(e=e(t)),r5(e)&&(e=[e]),Array.isArray(e))return e;if(!t)return e.default||[];let r=e[t];return r||(r=e[this.getScriptPartFromCode(t)]),r||(r=e[this.formatLanguageCode(t)]),r||(r=e[this.getLanguagePartFromCode(t)]),r||(r=e.default),r||[]}toResolveHierarchy(e,t){let r=this.getFallbackCodes((!1===t?[]:t)||this.options.fallbackLng||[],e),n=[],a=e=>{e&&(this.isSupportedCode(e)?n.push(e):this.logger.warn(`rejecting language code not found in supportedLngs: ${e}`))};return r5(e)&&(e.indexOf("-")>-1||e.indexOf("_")>-1)?("languageOnly"!==this.options.load&&a(this.formatLanguageCode(e)),"languageOnly"!==this.options.load&&"currentOnly"!==this.options.load&&a(this.getScriptPartFromCode(e)),"currentOnly"!==this.options.load&&a(this.getLanguagePartFromCode(e))):r5(e)&&a(this.formatLanguageCode(e)),r.forEach(e=>{0>n.indexOf(e)&&a(this.formatLanguageCode(e))}),n}}let nS={zero:0,one:1,two:2,few:3,many:4,other:5},n_={select:e=>1===e?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class nC{constructor(e,t={}){this.languageUtils=e,this.options=t,this.logger=nf.create("pluralResolver"),this.pluralRulesCache={}}addRule(e,t){this.rules[e]=t}clearCache(){this.pluralRulesCache={}}getRule(e,t={}){let r,n=nd("dev"===e?"en":e),a=t.ordinal?"ordinal":"cardinal",o=JSON.stringify({cleanedCode:n,type:a});if(o in this.pluralRulesCache)return this.pluralRulesCache[o];try{r=new Intl.PluralRules(n,{type:a})}catch(a){if(!Intl)return this.logger.error("No Intl support, please use an Intl polyfill!"),n_;if(!e.match(/-|_/))return n_;let n=this.languageUtils.getLanguagePartFromCode(e);r=this.getRule(n,t)}return this.pluralRulesCache[o]=r,r}needsPlural(e,t={}){let r=this.getRule(e,t);return r||(r=this.getRule("dev",t)),r?.resolvedOptions().pluralCategories.length>1}getPluralFormsOfKey(e,t,r={}){return this.getSuffixes(e,r).map(e=>`${t}${e}`)}getSuffixes(e,t={}){let r=this.getRule(e,t);return(r||(r=this.getRule("dev",t)),r)?r.resolvedOptions().pluralCategories.sort((e,t)=>nS[e]-nS[t]).map(e=>`${this.options.prepend}${t.ordinal?`ordinal${this.options.prepend}`:""}${e}`):[]}getSuffix(e,t,r={}){let n=this.getRule(e,r);return n?`${this.options.prepend}${r.ordinal?`ordinal${this.options.prepend}`:""}${n.select(t)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix("dev",t,r))}}let nk=(e,t,r,n=".",a=!0)=>{let o,i=void 0!==(o=na(e,r))?o:na(t,r);return!i&&a&&r5(r)&&void 0===(i=nc(e,r,n))&&(i=nc(t,r,n)),i};class nP{constructor(e={}){this.logger=nf.create("interpolator"),this.options=e,this.format=e?.interpolation?.format||(e=>e),this.init(e)}init(e={}){e.interpolation||(e.interpolation={escapeValue:!0});let{escape:t,escapeValue:r,useRawValueToEscape:n,prefix:a,prefixEscaped:o,suffix:i,suffixEscaped:s,formatSeparator:l,unescapeSuffix:u,unescapePrefix:c,nestingPrefix:d,nestingPrefixEscaped:m,nestingSuffix:p,nestingSuffixEscaped:f,nestingOptionsSeparator:h,maxReplaces:g,alwaysFormat:y}=e.interpolation;this.escape=void 0!==t?t:ns,this.escapeValue=void 0===r||r,this.useRawValueToEscape=void 0!==n&&n,this.prefix=a?a.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"):o||"{{",this.suffix=i?i.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"):s||"}}",this.formatSeparator=l||",",this.unescapePrefix=u?"":c||"-",this.unescapeSuffix=this.unescapePrefix?"":u||"",this.nestingPrefix=d?d.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"):m||"$t(".replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),this.nestingSuffix=p?p.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"):f||")".replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),this.nestingOptionsSeparator=h||",",this.maxReplaces=g||1e3,this.alwaysFormat=void 0!==y&&y,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){let e=(e,t)=>e?.source===t?(e.lastIndex=0,e):RegExp(t,"g");this.regexp=e(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=e(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=e(this.nestingRegexp,`${this.nestingPrefix}((?:[^()"']+|"[^"]*"|'[^']*'|\\((?:[^()]|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`)}interpolate(e,t,r,n){let a,o,i,s=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},l=e=>{if(0>e.indexOf(this.formatSeparator)){let a=nk(t,s,e,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(a,void 0,r,{...n,...t,interpolationkey:e}):a}let a=e.split(this.formatSeparator),o=a.shift().trim(),i=a.join(this.formatSeparator).trim();return this.format(nk(t,s,o,this.options.keySeparator,this.options.ignoreJSONStructure),i,r,{...n,...t,interpolationkey:o})};this.resetRegExp();let u=n?.missingInterpolationHandler||this.options.missingInterpolationHandler,c=n?.interpolation?.skipOnVariables!==void 0?n.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:e=>e.replace(/\$/g,"$$$$")},{regex:this.regexp,safeValue:e=>this.escapeValue?this.escape(e).replace(/\$/g,"$$$$"):e.replace(/\$/g,"$$$$")}].forEach(t=>{for(i=0;a=t.regex.exec(e);){let r=a[1].trim();if(void 0===(o=l(r)))if("function"==typeof u){let t=u(e,a,n);o=r5(t)?t:""}else if(n&&Object.prototype.hasOwnProperty.call(n,r))o="";else if(c){o=a[0];continue}else this.logger.warn(`missed to pass in variable ${r} for interpolating ${e}`),o="";else r5(o)||this.useRawValueToEscape||(o=r8(o));let s=t.safeValue(o);if(e=e.replace(a[0],s),c?(t.regex.lastIndex+=o.length,t.regex.lastIndex-=a[0].length):t.regex.lastIndex=0,++i>=this.maxReplaces)break}}),e}nest(e,t,r={}){let n,a,o,i=(e,t)=>{let r=this.nestingOptionsSeparator;if(0>e.indexOf(r))return e;let n=e.split(RegExp(`${r}[ ]*{`)),a=`{${n[1]}`;e=n[0];let i=(a=this.interpolate(a,o)).match(/'/g),s=a.match(/"/g);((i?.length??0)%2!=0||s)&&s.length%2==0||(a=a.replace(/'/g,'"'));try{o=JSON.parse(a),t&&(o={...t,...o})}catch(t){return this.logger.warn(`failed parsing options string in nesting for key ${e}`,t),`${e}${r}${a}`}return o.defaultValue&&o.defaultValue.indexOf(this.prefix)>-1&&delete o.defaultValue,e};for(;n=this.nestingRegexp.exec(e);){let s=[];(o=(o={...r}).replace&&!r5(o.replace)?o.replace:o).applyPostProcessor=!1,delete o.defaultValue;let l=/{.*}/.test(n[1])?n[1].lastIndexOf("}")+1:n[1].indexOf(this.formatSeparator);if(-1!==l&&(s=n[1].slice(l).split(this.formatSeparator).map(e=>e.trim()).filter(Boolean),n[1]=n[1].slice(0,l)),(a=t(i.call(this,n[1].trim(),o),o))&&n[0]===e&&!r5(a))return a;r5(a)||(a=r8(a)),a||(this.logger.warn(`missed to resolve ${n[1]} for nesting ${e}`),a=""),s.length&&(a=s.reduce((e,t)=>this.format(e,t,r.lng,{...r,interpolationkey:n[1].trim()}),a.trim())),e=e.replace(n[0],a),this.regexp.lastIndex=0}return e}}let nR=e=>{let t={};return(r,n,a)=>{let o=a;a&&a.interpolationkey&&a.formatParams&&a.formatParams[a.interpolationkey]&&a[a.interpolationkey]&&(o={...o,[a.interpolationkey]:void 0});let i=n+JSON.stringify(o),s=t[i];return s||(s=e(nd(n),a),t[i]=s),s(r)}},nT=e=>(t,r,n)=>e(nd(r),n)(t);class n${constructor(e={}){this.logger=nf.create("formatter"),this.options=e,this.init(e)}init(e,t={interpolation:{}}){this.formatSeparator=t.interpolation.formatSeparator||",";let r=t.cacheInBuiltFormats?nR:nT;this.formats={number:r((e,t)=>{let r=new Intl.NumberFormat(e,{...t});return e=>r.format(e)}),currency:r((e,t)=>{let r=new Intl.NumberFormat(e,{...t,style:"currency"});return e=>r.format(e)}),datetime:r((e,t)=>{let r=new Intl.DateTimeFormat(e,{...t});return e=>r.format(e)}),relativetime:r((e,t)=>{let r=new Intl.RelativeTimeFormat(e,{...t});return e=>r.format(e,t.range||"day")}),list:r((e,t)=>{let r=new Intl.ListFormat(e,{...t});return e=>r.format(e)})}}add(e,t){this.formats[e.toLowerCase().trim()]=t}addCached(e,t){this.formats[e.toLowerCase().trim()]=nR(t)}format(e,t,r,n={}){let a=t.split(this.formatSeparator);if(a.length>1&&a[0].indexOf("(")>1&&0>a[0].indexOf(")")&&a.find(e=>e.indexOf(")")>-1)){let e=a.findIndex(e=>e.indexOf(")")>-1);a[0]=[a[0],...a.splice(1,e)].join(this.formatSeparator)}return a.reduce((e,t)=>{let{formatName:a,formatOptions:o}=(e=>{let t=e.toLowerCase().trim(),r={};if(e.indexOf("(")>-1){let n=e.split("(");t=n[0].toLowerCase().trim();let a=n[1].substring(0,n[1].length-1);"currency"===t&&0>a.indexOf(":")?r.currency||(r.currency=a.trim()):"relativetime"===t&&0>a.indexOf(":")?r.range||(r.range=a.trim()):a.split(";").forEach(e=>{if(e){let[t,...n]=e.split(":"),a=n.join(":").trim().replace(/^'+|'+$/g,""),o=t.trim();r[o]||(r[o]=a),"false"===a&&(r[o]=!1),"true"===a&&(r[o]=!0),isNaN(a)||(r[o]=parseInt(a,10))}})}return{formatName:t,formatOptions:r}})(t);if(this.formats[a]){let t=e;try{let i=n?.formatParams?.[n.interpolationkey]||{},s=i.locale||i.lng||n.locale||n.lng||r;t=this.formats[a](e,s,{...o,...n,...i})}catch(e){this.logger.warn(e)}return t}return this.logger.warn(`there was no format function for ${a}`),e},e)}}class nN extends nh{constructor(e,t,r,n={}){super(),this.backend=e,this.store=t,this.services=r,this.languageUtils=r.languageUtils,this.options=n,this.logger=nf.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=n.maxParallelReads||10,this.readingCalls=0,this.maxRetries=n.maxRetries>=0?n.maxRetries:5,this.retryTimeout=n.retryTimeout>=1?n.retryTimeout:350,this.state={},this.queue=[],this.backend?.init?.(r,n.backend,n)}queueLoad(e,t,r,n){let a={},o={},i={},s={};return e.forEach(e=>{let n=!0;t.forEach(t=>{let i=`${e}|${t}`;!r.reload&&this.store.hasResourceBundle(e,t)?this.state[i]=2:this.state[i]<0||(1===this.state[i]?void 0===o[i]&&(o[i]=!0):(this.state[i]=1,n=!1,void 0===o[i]&&(o[i]=!0),void 0===a[i]&&(a[i]=!0),void 0===s[t]&&(s[t]=!0)))}),n||(i[e]=!0)}),(Object.keys(a).length||Object.keys(o).length)&&this.queue.push({pending:o,pendingCount:Object.keys(o).length,loaded:{},errors:[],callback:n}),{toLoad:Object.keys(a),pending:Object.keys(o),toLoadLanguages:Object.keys(i),toLoadNamespaces:Object.keys(s)}}loaded(e,t,r){let n=e.split("|"),a=n[0],o=n[1];t&&this.emit("failedLoading",a,o,t),!t&&r&&this.store.addResourceBundle(a,o,r,void 0,void 0,{skipCopy:!0}),this.state[e]=t?-1:2,t&&r&&(this.state[e]=0);let i={};this.queue.forEach(r=>{((e,t,r,n)=>{let{obj:a,k:o}=nr(e,t,Object);a[o]=a[o]||[],a[o].push(r)})(r.loaded,[a],o),void 0!==r.pending[e]&&(delete r.pending[e],r.pendingCount--),t&&r.errors.push(t),0!==r.pendingCount||r.done||(Object.keys(r.loaded).forEach(e=>{i[e]||(i[e]={});let t=r.loaded[e];t.length&&t.forEach(t=>{void 0===i[e][t]&&(i[e][t]=!0)})}),r.done=!0,r.errors.length?r.callback(r.errors):r.callback())}),this.emit("loaded",i),this.queue=this.queue.filter(e=>!e.done)}read(e,t,r,n=0,a=this.retryTimeout,o){if(!e.length)return o(null,{});if(this.readingCalls>=this.maxParallelReads)return void this.waitingReads.push({lng:e,ns:t,fcName:r,tried:n,wait:a,callback:o});this.readingCalls++;let i=(i,s)=>{if(this.readingCalls--,this.waitingReads.length>0){let e=this.waitingReads.shift();this.read(e.lng,e.ns,e.fcName,e.tried,e.wait,e.callback)}i&&s&&n<this.maxRetries?setTimeout(()=>{this.read.call(this,e,t,r,n+1,2*a,o)},a):o(i,s)},s=this.backend[r].bind(this.backend);if(2===s.length){try{let r=s(e,t);r&&"function"==typeof r.then?r.then(e=>i(null,e)).catch(i):i(null,r)}catch(e){i(e)}return}return s(e,t,i)}prepareLoading(e,t,r={},n){if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),n&&n();r5(e)&&(e=this.languageUtils.toResolveHierarchy(e)),r5(t)&&(t=[t]);let a=this.queueLoad(e,t,r,n);if(!a.toLoad.length)return a.pending.length||n(),null;a.toLoad.forEach(e=>{this.loadOne(e)})}load(e,t,r){this.prepareLoading(e,t,{},r)}reload(e,t,r){this.prepareLoading(e,t,{reload:!0},r)}loadOne(e,t=""){let r=e.split("|"),n=r[0],a=r[1];this.read(n,a,"read",void 0,void 0,(r,o)=>{r&&this.logger.warn(`${t}loading namespace ${a} for language ${n} failed`,r),!r&&o&&this.logger.log(`${t}loaded namespace ${a} for language ${n}`,o),this.loaded(e,r,o)})}saveMissing(e,t,r,n,a,o={},i=()=>{}){if(this.services?.utils?.hasLoadedNamespace&&!this.services?.utils?.hasLoadedNamespace(t))return void this.logger.warn(`did not save key "${r}" as the namespace "${t}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");if(null!=r&&""!==r){if(this.backend?.create){let s={...o,isUpdate:a},l=this.backend.create.bind(this.backend);if(l.length<6)try{let a;(a=5===l.length?l(e,t,r,n,s):l(e,t,r,n))&&"function"==typeof a.then?a.then(e=>i(null,e)).catch(i):i(null,a)}catch(e){i(e)}else l(e,t,r,n,i,s)}e&&e[0]&&this.store.addResource(e[0],t,r,n)}}}let nO=()=>({debug:!1,initAsync:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:e=>{let t={};if("object"==typeof e[1]&&(t=e[1]),r5(e[1])&&(t.defaultValue=e[1]),r5(e[2])&&(t.tDescription=e[2]),"object"==typeof e[2]||"object"==typeof e[3]){let r=e[3]||e[2];Object.keys(r).forEach(e=>{t[e]=r[e]})}return t},interpolation:{escapeValue:!0,format:e=>e,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0},cacheInBuiltFormats:!0}),nI=e=>(r5(e.ns)&&(e.ns=[e.ns]),r5(e.fallbackLng)&&(e.fallbackLng=[e.fallbackLng]),r5(e.fallbackNS)&&(e.fallbackNS=[e.fallbackNS]),e.supportedLngs?.indexOf?.("cimode")<0&&(e.supportedLngs=e.supportedLngs.concat(["cimode"])),"boolean"==typeof e.initImmediate&&(e.initAsync=e.initImmediate),e),nA=()=>{};class nM extends nh{constructor(e={},t){if(super(),this.options=nI(e),this.services={},this.logger=nf,this.modules={external:[]},(e=>{Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach(t=>{"function"==typeof e[t]&&(e[t]=e[t].bind(e))})})(this),t&&!this.isInitialized&&!e.isClone){if(!this.options.initAsync)return this.init(e,t),this;setTimeout(()=>{this.init(e,t)},0)}}init(e={},t){this.isInitializing=!0,"function"==typeof e&&(t=e,e={}),null==e.defaultNS&&e.ns&&(r5(e.ns)?e.defaultNS=e.ns:0>e.ns.indexOf("translation")&&(e.defaultNS=e.ns[0]));let r=nO();this.options={...r,...this.options,...nI(e)},this.options.interpolation={...r.interpolation,...this.options.interpolation},void 0!==e.keySeparator&&(this.options.userDefinedKeySeparator=e.keySeparator),void 0!==e.nsSeparator&&(this.options.userDefinedNsSeparator=e.nsSeparator);let n=e=>e?"function"==typeof e?new e:e:null;if(!this.options.isClone){let e;this.modules.logger?nf.init(n(this.modules.logger),this.options):nf.init(null,this.options),e=this.modules.formatter?this.modules.formatter:n$;let t=new nD(this.options);this.store=new ng(this.options.resources,this.options);let a=this.services;a.logger=nf,a.resourceStore=this.store,a.languageUtils=t,a.pluralResolver=new nC(t,{prepend:this.options.pluralSeparator,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),this.options.interpolation.format&&this.options.interpolation.format!==r.interpolation.format&&this.logger.deprecate("init: you are still using the legacy format function, please use the new approach: https://www.i18next.com/translation-function/formatting"),e&&(!this.options.interpolation.format||this.options.interpolation.format===r.interpolation.format)&&(a.formatter=n(e),a.formatter.init&&a.formatter.init(a,this.options),this.options.interpolation.format=a.formatter.format.bind(a.formatter)),a.interpolator=new nP(this.options),a.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},a.backendConnector=new nN(n(this.modules.backend),a.resourceStore,a,this.options),a.backendConnector.on("*",(e,...t)=>{this.emit(e,...t)}),this.modules.languageDetector&&(a.languageDetector=n(this.modules.languageDetector),a.languageDetector.init&&a.languageDetector.init(a,this.options.detection,this.options)),this.modules.i18nFormat&&(a.i18nFormat=n(this.modules.i18nFormat),a.i18nFormat.init&&a.i18nFormat.init(this)),this.translator=new nE(this.services,this.options),this.translator.on("*",(e,...t)=>{this.emit(e,...t)}),this.modules.external.forEach(e=>{e.init&&e.init(this)})}if(this.format=this.options.interpolation.format,t||(t=nA),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){let e=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);e.length>0&&"dev"!==e[0]&&(this.options.lng=e[0])}this.services.languageDetector||this.options.lng||this.logger.warn("init: no languageDetector is used and no lng is defined"),["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach(e=>{this[e]=(...t)=>this.store[e](...t)}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(e=>{this[e]=(...t)=>(this.store[e](...t),this)});let a=r9(),o=()=>{let e=(e,r)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=!0,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),a.resolve(r),t(e,r)};if(this.languages&&!this.isInitialized)return e(null,this.t.bind(this));this.changeLanguage(this.options.lng,e)};return this.options.resources||!this.options.initAsync?o():setTimeout(o,0),a}loadResources(e,t=nA){let r=t,n=r5(e)?e:this.language;if("function"==typeof e&&(r=e),!this.options.resources||this.options.partialBundledLanguages){if(n?.toLowerCase()==="cimode"&&(!this.options.preload||0===this.options.preload.length))return r();let e=[],t=t=>{t&&"cimode"!==t&&this.services.languageUtils.toResolveHierarchy(t).forEach(t=>{"cimode"!==t&&0>e.indexOf(t)&&e.push(t)})};n?t(n):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(e=>t(e)),this.options.preload?.forEach?.(e=>t(e)),this.services.backendConnector.load(e,this.options.ns,e=>{e||this.resolvedLanguage||!this.language||this.setResolvedLanguage(this.language),r(e)})}else r(null)}reloadResources(e,t,r){let n=r9();return"function"==typeof e&&(r=e,e=void 0),"function"==typeof t&&(r=t,t=void 0),e||(e=this.languages),t||(t=this.options.ns),r||(r=nA),this.services.backendConnector.reload(e,t,e=>{n.resolve(),r(e)}),n}use(e){if(!e)throw Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!e.type)throw Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return"backend"===e.type&&(this.modules.backend=e),("logger"===e.type||e.log&&e.warn&&e.error)&&(this.modules.logger=e),"languageDetector"===e.type&&(this.modules.languageDetector=e),"i18nFormat"===e.type&&(this.modules.i18nFormat=e),"postProcessor"===e.type&&ny.addPostProcessor(e),"formatter"===e.type&&(this.modules.formatter=e),"3rdParty"===e.type&&this.modules.external.push(e),this}setResolvedLanguage(e){if(e&&this.languages&&!(["cimode","dev"].indexOf(e)>-1)){for(let e=0;e<this.languages.length;e++){let t=this.languages[e];if(!(["cimode","dev"].indexOf(t)>-1)&&this.store.hasLanguageSomeTranslations(t)){this.resolvedLanguage=t;break}}!this.resolvedLanguage&&0>this.languages.indexOf(e)&&this.store.hasLanguageSomeTranslations(e)&&(this.resolvedLanguage=e,this.languages.unshift(e))}}changeLanguage(e,t){this.isLanguageChangingTo=e;let r=r9();this.emit("languageChanging",e);let n=e=>{this.language=e,this.languages=this.services.languageUtils.toResolveHierarchy(e),this.resolvedLanguage=void 0,this.setResolvedLanguage(e)},a=(a,o)=>{o?this.isLanguageChangingTo===e&&(n(o),this.translator.changeLanguage(o),this.isLanguageChangingTo=void 0,this.emit("languageChanged",o),this.logger.log("languageChanged",o)):this.isLanguageChangingTo=void 0,r.resolve((...e)=>this.t(...e)),t&&t(a,(...e)=>this.t(...e))},o=t=>{e||t||!this.services.languageDetector||(t=[]);let r=r5(t)?t:t&&t[0],o=this.store.hasLanguageSomeTranslations(r)?r:this.services.languageUtils.getBestMatchFromCodes(r5(t)?[t]:t);o&&(this.language||n(o),this.translator.language||this.translator.changeLanguage(o),this.services.languageDetector?.cacheUserLanguage?.(o)),this.loadResources(o,e=>{a(e,o)})};return e||!this.services.languageDetector||this.services.languageDetector.async?!e&&this.services.languageDetector&&this.services.languageDetector.async?0===this.services.languageDetector.detect.length?this.services.languageDetector.detect().then(o):this.services.languageDetector.detect(o):o(e):o(this.services.languageDetector.detect()),r}getFixedT(e,t,r){let n=(e,t,...a)=>{let o,i;(o="object"!=typeof t?this.options.overloadTranslationOptionHandler([e,t].concat(a)):{...t}).lng=o.lng||n.lng,o.lngs=o.lngs||n.lngs,o.ns=o.ns||n.ns,""!==o.keyPrefix&&(o.keyPrefix=o.keyPrefix||r||n.keyPrefix);let s=this.options.keySeparator||".";return o.keyPrefix&&Array.isArray(e)?i=e.map(e=>("function"==typeof e&&(e=nb(e,{...this.options,...t})),`${o.keyPrefix}${s}${e}`)):("function"==typeof e&&(e=nb(e,{...this.options,...t})),i=o.keyPrefix?`${o.keyPrefix}${s}${e}`:e),this.t(i,o)};return r5(e)?n.lng=e:n.lngs=e,n.ns=t,n.keyPrefix=r,n}t(...e){return this.translator?.translate(...e)}exists(...e){return this.translator?.exists(...e)}setDefaultNamespace(e){this.options.defaultNS=e}hasLoadedNamespace(e,t={}){if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;let r=t.lng||this.resolvedLanguage||this.languages[0],n=!!this.options&&this.options.fallbackLng,a=this.languages[this.languages.length-1];if("cimode"===r.toLowerCase())return!0;let o=(e,t)=>{let r=this.services.backendConnector.state[`${e}|${t}`];return -1===r||0===r||2===r};if(t.precheck){let e=t.precheck(this,o);if(void 0!==e)return e}return!!(this.hasResourceBundle(r,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||o(r,e)&&(!n||o(a,e)))}loadNamespaces(e,t){let r=r9();return this.options.ns?(r5(e)&&(e=[e]),e.forEach(e=>{0>this.options.ns.indexOf(e)&&this.options.ns.push(e)}),this.loadResources(e=>{r.resolve(),t&&t(e)}),r):(t&&t(),Promise.resolve())}loadLanguages(e,t){let r=r9();r5(e)&&(e=[e]);let n=this.options.preload||[],a=e.filter(e=>0>n.indexOf(e)&&this.services.languageUtils.isSupportedCode(e));return a.length?(this.options.preload=n.concat(a),this.loadResources(e=>{r.resolve(),t&&t(e)}),r):(t&&t(),Promise.resolve())}dir(e){if(e||(e=this.resolvedLanguage||(this.languages?.length>0?this.languages[0]:this.language)),!e)return"rtl";try{let t=new Intl.Locale(e);if(t&&t.getTextInfo){let e=t.getTextInfo();if(e&&e.direction)return e.direction}}catch(e){}let t=this.services?.languageUtils||new nD(nO());return e.toLowerCase().indexOf("-latn")>1?"ltr":["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"].indexOf(t.getLanguagePartFromCode(e))>-1||e.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(e={},t){return new nM(e,t)}cloneInstance(e={},t=nA){let r=e.forkResourceStore;r&&delete e.forkResourceStore;let n={...this.options,...e,isClone:!0},a=new nM(n);return(void 0!==e.debug||void 0!==e.prefix)&&(a.logger=a.logger.clone(e)),["store","services","language"].forEach(e=>{a[e]=this[e]}),a.services={...this.services},a.services.utils={hasLoadedNamespace:a.hasLoadedNamespace.bind(a)},r&&(a.store=new ng(Object.keys(this.store.data).reduce((e,t)=>(e[t]={...this.store.data[t]},e[t]=Object.keys(e[t]).reduce((r,n)=>(r[n]={...e[t][n]},r),e[t]),e),{}),n),a.services.resourceStore=a.store),a.translator=new nE(a.services,n),a.translator.on("*",(e,...t)=>{a.emit(e,...t)}),a.init(n,t),a.translator.options=n,a.translator.backendConnector.services.utils={hasLoadedNamespace:a.hasLoadedNamespace.bind(a)},a}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}let nj=nM.createInstance();nj.createInstance=nM.createInstance,nj.createInstance,nj.dir,nj.init,nj.loadResources,nj.reloadResources,nj.use,nj.changeLanguage,nj.getFixedT,nj.t,nj.exists,nj.setDefaultNamespace,nj.hasLoadedNamespace,nj.loadNamespaces,nj.loadLanguages;let nL=nj.default||nj;function nF(e,t,r,n){return nL.t(t,{ns:e,defaultValue:r,...n})}function nB(e,t,r){return r6[e]?nF("core",e,t??r6[e],r):(console.error(`O3 Core Translations does not provide key '${e}'. The key itself is being rendered as text.`),e)}function nV(e,t){let r=window.getOpenmrsSpaBase().replace(/\/$/,""),n=nU(e,{openmrsBase:window.openmrsBase,openmrsSpaBase:r,...t});return e.startsWith("//")?n:n.replace(/^\/\//,"/")}function nU(e,t){return Object.keys(t).reduce((e,r)=>e.split("${"+r+"}").join(t[r]),e)}function nW({to:e,templateParams:t}){let r=window.getOpenmrsSpaBase().replace(/\/$/,""),n=nV(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(nB("navigateNonHttp"));n.startsWith(r)?(0,r3.navigateToUrl)(n):window.location.assign(n)}nL.on("initialized",function(){window.i18next.loadNamespaces(["core"])});let nH="openmrs:history";function nz(e){let t=JSON.parse(sessionStorage.getItem(nH)??"[]")||[];t.push(e),t.length>50&&(t=t.slice(-50)),sessionStorage.setItem(nH,JSON.stringify(t))}function nK(){0===JSON.parse(sessionStorage.getItem(nH)??"[]").length&&document.referrer&&nz(document.referrer),window.addEventListener("single-spa:routing-event",e=>{let t=nG();e.detail.originalEvent?.singleSpaTrigger=="replaceState"?(t[t.length-1]=window.location.href,sessionStorage.setItem(nH,JSON.stringify(t))):!e.detail.originalEvent?.singleSpa&&t.includes(window.location.href)?nZ({toUrl:window.location.href}):t[t.length-1]!==window.location.href&&nz(window.location.href)})}function nG(){return JSON.parse(sessionStorage.getItem(nH)??"[]")}function nZ({toUrl:e}){let t=nG(),r=t.lastIndexOf(e);if(-1!=r){let e=t.slice(0,r+1);nW({to:t[r]}),sessionStorage.setItem(nH,JSON.stringify(e))}else throw Error(`URL ${e} not found in history; cannot go back to it.`)}function nY(){sessionStorage.removeItem(nH)}let nq="${openmrsSpaBase}/login",nJ={redirectAuthFailure:{enabled:{_type:tU.Boolean,_default:!0,_description:"Whether to redirect logged-out users to `redirectAuthFailure.url`"},url:{_type:tU.String,_default:nq,_validators:[rY.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:tU.Array,_default:[401],_elements:{_type:tU.Number,_validators:[rY.inRange(100,600)]},_description:"The HTTP error codes for which users will be redirected"},resolvePromise:{_type:tU.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:tU.Boolean,_default:!0,_description:"Whether openmrsFetch should support redirects returned from the backend"}};function nX(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}let nQ="/ws/rest/v1",n0="/ws/fhir2/R4",n1=`${nQ}/session`;function n4(e){return e&&e.startsWith("http")?e:("/"!==e[0]&&(e="/"+e),window.openmrsBase+e)}function n2(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=n4(e);t.headers||(t.headers={}),ec(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(n4(nQ),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(n0)){let e=new URL(r,window.location.toString());e.searchParams.has("_summary")||(e.searchParams.set("_summary","data"),r=e.toString())}let a=Error();return window.fetch(r,t).then(async e=>{let{redirectAuthFailure:n,followRedirects:o}=await rD("@openmrs/esm-api");if(e.ok){let t=e.headers.get("location");return(o&&t&&(r===n4(n1)||204===e.status)&&nW({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===n4(n1)&&403===e.status||n.enabled&&n.errors.includes(e.status))&&(nY(),nW({to:n.url||e.headers.get("location")||nq}),!0!==t.rejectAuthFailure)?n.resolvePromise?Promise.resolve():new Promise(()=>{}):e.clone().text().then(t=>{let n=t;try{n=JSON.parse(t)}catch(e){}throw new n3(r,e,n,a)},()=>{throw new n3(r,e,null,a)})})}class n3 extends Error{constructor(e,t,r,n){super(),nX(this,"response",void 0),nX(this,"responseBody",void 0),this.message=`Server responded with ${t.status} (${t.statusText}) for url ${e}. Check err.responseBody or network tab in dev tools for more info`,n.message=this.message,this.responseBody=r,this.response=t,this.stack=`Stacktrace for outgoing request:
13
13
  ${n.stack}
14
14
  Stacktrace for incoming response:
15
- ${this.stack}`}}let n6=B("session",{loaded:!1,session:null}),n5=0,n9=null;function n8(){return n9||(n6.getState().loaded&&n5>=Date.now()-6e4?null:ar())}function n7(e){let t=e?.includeAuthStatus??!0,r=e=>t?e:e.user,n=n8();return n?new Promise(e=>{let t=()=>{let t=n6.getState();t.loaded&&(a(),e(r(t.session)))},a=n6.subscribe(t);n.then(t,t)}):Promise.resolve(r(n6.getState().session))}function ae(){return n8(),n6}function at(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 ar(e,t){n5=Date.now(),a??(a=n5);let r={};e&&t&&(r.Authorization=`Basic ${window.btoa(`${e}:${t}`)}`);let n=am(n2(n1,{headers:r,rejectAuthFailure:!0})),o=()=>{n9===n&&(n9=null)};return n.then(o,o),n9=n,n}function an(){n6.setState({loaded:!0,session:{authenticated:!1,sessionId:""}},!0)}function aa(e,t){var r,n;if(void 0===t)return!e;if(!e)return!0;return r=e,n=t,("string"==typeof r?!K(n.privileges.find(e=>r===e.display)):Array.isArray(r)?r.every(e=>!K(n.privileges.find(t=>e===t.display))):(K(r)||console.error(`Could not understand privileges "${r}"`),!0))||!K(t.roles.find(e=>"System Developer"===e.display))}function ao(){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(n6.getState()),e||(t=n6.subscribe(n))})}async function ai(){return(await n7()).sessionLocation}async function as(e,t){return am(n2(n1,{method:"POST",body:{sessionLocation:e},headers:{"Content-Type":"application/json"},rejectAuthFailure:!0,signal:t?.signal}))}async function al(e,t){return await n2(n1,{method:"POST",body:{locale:e},headers:{"Content-Type":"application/json"},signal:t?.signal}),ar()}async function au(e,t,r){return r||(r=new AbortController),await n2(`${nQ}/user/${e}`,{method:"POST",body:{userProperties:t},headers:{"Content-Type":"application/json"},signal:r.signal}),ar()}async function ac(e,t=!1){let r=await n2(t?`${n1}?rememberMe=true`:n1,{headers:{"X-Totp-Code":e}});return r.data?.authenticated?(await ar()).session:r.data}async function ad(){try{await n2(n1,{method:"DELETE",rejectAuthFailure:!0})}catch(e){if(!ap(e))throw e}an(),await ar().catch(()=>{})}function am(e){return new Promise((t,r)=>{e.then(e=>{if("object"==typeof e?.data){let r={loaded:!0,session:e.data};n6.setState(r,!0),t(r)}else!function(e){if(!e?.redirected||!e.url)return!1;try{return new URL(e.url,window.location.href).pathname.replace(/\/+$/,"").endsWith("/initialsetup")}catch{return!1}}(e)?r(af(Error("The session endpoint did not respond with a session"))):r(af(Error("The server is still starting up"),!0))}).catch(e=>{var n,o;if(ap(e)){"object"==typeof(n=e.responseBody)&&null!==n&&!1===n.authenticated?n6.setState({loaded:!0,session:e.responseBody},!0):an(),t(n6.getState());return}(o=e)instanceof n3&&502===o.response.status&&!n6.getState().loaded&&void 0!==a&&Date.now()-a<18e4?r(af(e,!0)):(k(`Failed to fetch new session information: ${e}`),r(af(e)))})})}function ap(e){return e instanceof n3&&(401===e.response.status||403===e.response.status)}function af(e,t=!1){return n6.getState().loaded||n6.setState({loaded:!1,session:null,error:e instanceof Error?e:Error(String(e)),initializing:t},!0),n6.getState()}function ah(){return"development"===window.spaEnv||"true"===localStorage.getItem("openmrs:devtools")}n6.subscribe(e=>{e.loaded&&e.session&&at(e.session)});let ag={"webservices.rest":"2.24.0",fhir2:"1.0.0-SNAPSHOT"};function ay(){rg("@openmrs/esm-api",nJ),ar()}let av="import-map-override:",ab="import-map-overrides-disabled",aw="import-map-overrides:change",ax=!1,aE=null,aD=null;async function aS(){return aD??(aD=a_().then(({map:e,complete:t})=>(t||(aD=null),e))),aD}async function a_(){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:aC(t),complete:r}}function aC(e){let t={imports:{}};for(let r of e)r?.imports&&Object.assign(t.imports,r.imports);return t}function ak(){let e={};try{let t=aN();for(let r=0;r<localStorage.length;r++){let n=localStorage.key(r);if(n?.startsWith(av)){let r=n.slice(av.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 aP(){let e=await aS();return ax?aC([e,aE??ak()]):e}async function aR(){return aS()}async function aT(){return ax?aC([await aS(),ak()]):aS()}function a$(e){if(!ax)return{imports:{}};if(e){let e={};for(let t=0;t<localStorage.length;t++){let r=localStorage.key(t);if(r?.startsWith(av)){let t=localStorage.getItem(r);t&&(e[r.slice(av.length)]=t)}}return{imports:e}}return ak()}function aN(){if(!ax)return[];try{let e=localStorage.getItem(ab);if(e){let t=JSON.parse(e);if(Array.isArray(t))return t}}catch{}return[]}function aO(e){return!!ax&&aN().includes(e)}function aI(e,t){if(!ax)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{localStorage.setItem(av+e,t),window.dispatchEvent(new CustomEvent(aw))}catch(e){console.warn("[import-maps] Failed to write import-map override to localStorage",e)}}function aA(e){if(!ax)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{localStorage.removeItem(av+e);let t=aN().filter(t=>t!==e);t.length>0?localStorage.setItem(ab,JSON.stringify(t)):localStorage.removeItem(ab),window.dispatchEvent(new CustomEvent(aw))}catch(e){console.warn("[import-maps] Failed to update import-map overrides in localStorage",e)}}function aM(){if(!ax)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(av)&&e.push(r)}e.forEach(e=>localStorage.removeItem(e)),localStorage.removeItem(ab),window.dispatchEvent(new CustomEvent(aw))}catch(e){console.warn("[import-maps] Failed to clear import-map overrides from localStorage",e)}}function aj(e){if(!ax)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{let t=aN().filter(t=>t!==e);t.length>0?localStorage.setItem(ab,JSON.stringify(t)):localStorage.removeItem(ab),window.dispatchEvent(new CustomEvent(aw))}catch(e){console.warn("[import-maps] Failed to update import-map overrides in localStorage",e)}}let aL=!1;function aF(){!aL&&(aL=!0,(ax="development"===window.spaEnv)&&(aE=ak()))}function aB(e){return e.replace(/[\/\-@]/g,"_")}async function aV(e,t="./start",n){var a;let o,i=!n?.maxLoadingTime||n.maxLoadingTime<=0?6e5:n.maxLoadingTime;await Promise.race([aU(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=aB(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 aU(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=aB(e);if(!window[r]){let r=t??await aW();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 a$().imports;try{return await function(e){var t;let r=(t=window)[aH]??(t[aH]=new Map),n=r.get(e);if(n)return n;if(document.head.querySelector(`script[src="${e}"]`))return console.warn(`Script at ${e} already loaded. Not loading it again.`),Promise.resolve();let a=document.createElement("script");a.src=e,a.type="text/javascript",a.async=!0;let o=new Promise((t,n)=>{let o=setTimeout(()=>{console.error(`The script at ${e} did not load within 5 seconds. This may indicate an issue with the imports in the script's entry-point file or with the script's bundler configuration.`)},5e3);function i(){clearTimeout(o),a.removeEventListener("load",s),a.removeEventListener("error",l)}function s(){i(),t()}function l(t){i(),r.delete(e),a.remove();let o=`Failed to load script from ${e}`;console.error(o,t),n(t.message??o)}a.addEventListener("load",s),a.addEventListener("error",l),document.head.appendChild(a)});return r.set(e,o),o}(n)}catch(e){return a&&x({kind:"error",title:nB("scriptLoadingFailed","Error: Script failed to load"),description:nB("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:nB("resetOverrides","Reset overrides"),onActionButtonClick(){aM(),window.location.reload()}}),Promise.reject(e)}}return Promise.resolve()}async function aW(){return aP()}let aH=Symbol.for("__openmrs_script_loading");function az(e){return!!e&&"object"==typeof e&&!(Object.hasOwn(e,"pages")&&(!e.pages||!Array.isArray(e.pages))||Object.hasOwn(e,"extensions")&&(!e.extensions||!Array.isArray(e.extensions))||Object.hasOwn(e,"modals")&&(!e.modals||!Array.isArray(e.modals))||Object.hasOwn(e,"workspaces2")&&(!e.workspaces2||!Array.isArray(e.workspaces2))||Object.hasOwn(e,"workspaceWindows2")&&(!e.workspaceWindows2||!Array.isArray(e.workspaceWindows2))||Object.hasOwn(e,"workspaceGroups2")&&(!e.workspaceGroups2||!Array.isArray(e.workspaceGroups2)))}function aK(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&&az(t))}let aG="openmrs-routes:",aZ="openmrs-routes:change",aY=!1,aq=null,aJ=null;async function aX(){return aJ??(aJ=aQ().then(({map:e,complete:t})=>(t||(aJ=null),e))),aJ}async function aQ(){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&&aK(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:a0(t),complete:r}}function a0(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 a1(){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(aG)){let e=localStorage.getItem(r);e&&t.push({moduleName:r.slice(aG.length),raw:e})}}for(let r of(await Promise.allSettled(t.map(async({moduleName:e,raw:t})=>{let r=JSON.parse(t);if(az(r))return{moduleName:e,routes:r};if("string"==typeof r&&r.startsWith("http")){let t=await fetch(r),n=await t.json();if(az(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 a4(){let e=await aX();return aY?a0([e,aq??await a1()]):e}async function a2(){return aX()}async function a3(){return aY?a0([await aX(),await a1()]):aX()}function a6(){if(!aY)return{};let e={};try{for(let t=0;t<localStorage.length;t++){let r=localStorage.key(t);if(r?.startsWith(aG)){let t=localStorage.getItem(r);t&&(e[r.slice(aG.length)]=t)}}}catch(e){console.warn("[route-maps] Failed to read route overrides from localStorage",e)}return e}function a5(e,t){if(!aY)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{if("string"==typeof t)if(t.startsWith("http"))localStorage.setItem(aG+e,JSON.stringify(t));else{let r=JSON.parse(t);if(!az(r))return void console.error(`The supplied routes for ${e} is not a valid OpenmrsAppRoutes object`,t);localStorage.setItem(aG+e,JSON.stringify(r))}else if(t instanceof URL)localStorage.setItem(aG+e,JSON.stringify(t.toString()));else{if(!az(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(aG+e,JSON.stringify(t))}window.dispatchEvent(new CustomEvent(aZ))}catch(e){console.warn("[route-maps] Failed to write route override to localStorage",e)}}function a9(e){if(!aY)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{localStorage.removeItem(aG+e),window.dispatchEvent(new CustomEvent(aZ))}catch(e){console.warn("[route-maps] Failed to remove route override from localStorage",e)}}function a8(){if(!aY)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(aG)&&e.push(r)}e.forEach(e=>localStorage.removeItem(e)),window.dispatchEvent(new CustomEvent(aZ))}catch(e){console.warn("[route-maps] Failed to clear route overrides from localStorage",e)}}let a7=null;function oe(){return a7||(a7=(aY="development"===window.spaEnv)?a1().then(e=>{aq=e}):Promise.resolve())}let ot=`${nQ}/attachment`;function or(e,t){return n2(`${ot}/${e}`,{signal:t.signal})}function on(e,t,r,n){return n2(oa(e,t,n),{signal:r.signal})}function oa(e,t,r){return r?`${ot}?patient=${e}&encounter=${r}`:`${ot}?patient=${e}&includeEncounterless=${t}`}async function oo(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)),n2(`${ot}`,{method:"POST",body:n})}function oi(e,t){return n2(`${ot}/${e}`,{method:"DELETE",signal:t.signal})}async function os(e,t){return e?(await n2(`${n0}/Patient/${e}`,t)).data:null}function ol(e,t){let r=new CustomEvent(`openmrs:${e}`,{detail:t??void 0,cancelable:!0,bubbles:!0});return window.dispatchEvent(r)}function ou(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 oc(e){return{uuid:e.uuid,display:e.display}}function od(e=null,t=null){let r=new URLSearchParams;e&&r.set("tag",e),t&&r.set("q",t);let n=r.toString();return n2(`${nQ}/location${n?"?"+n:""}`).then(e=>e.data.results.map(oc))}function om(e){return{uuid:e.uuid,display:e.display,name:e.name}}let op=`${nQ}/visittype`;function of(e=op){return n2(e).then(e=>e.data.results.map(om))}var oh=((J={}).NEWVISIT="startVisit",J.EDITVISIT="editVisit",J.LOADING="loadingVisit",J),og=((X={}).NOTSTARTED="notStarted",X.ONGOING="ongoing",X);let oy="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))",ov=function(){try{return JSON.parse(sessionStorage.getItem("openmrs:visitStoreState")||"null")}catch(e){return null}}()||{patientUuid:null,manuallySetVisitUuid:null};function ob(){return W("visit",ov)}function ow(e,t){ob().setState({patientUuid:e,manuallySetVisitUuid:t})}function ox(e,t){return n2(`${nQ}/visit`,{signal:t.signal,method:"POST",headers:{"Content-type":"application/json"},body:e})}function oE(e,t,r){return n2(`${nQ}/visit/${e}`,{signal:r.signal,method:"POST",headers:{"Content-type":"application/json"},body:t})}function oD(e,t,r){return n2(`${nQ}/visit?patient=${e}&v=${r??oy}`,{signal:t.signal,method:"GET",headers:{"Content-type":"application/json"}})}ob().subscribe(e=>{var t;t=e,sessionStorage.setItem("openmrs:visitStoreState",JSON.stringify(t))});class oS{static get version(){return"1.4.0"}static toString(){return"JavaScript Expression Parser (JSEP) v"+oS.version}static addUnaryOp(e){return oS.max_unop_len=Math.max(e.length,oS.max_unop_len),oS.unary_ops[e]=1,oS}static addBinaryOp(e,t,r){return oS.max_binop_len=Math.max(e.length,oS.max_binop_len),oS.binary_ops[e]=t,r?oS.right_associative.add(e):oS.right_associative.delete(e),oS}static addIdentifierChar(e){return oS.additional_identifier_chars.add(e),oS}static addLiteral(e,t){return oS.literals[e]=t,oS}static removeUnaryOp(e){return delete oS.unary_ops[e],e.length===oS.max_unop_len&&(oS.max_unop_len=oS.getMaxKeyLen(oS.unary_ops)),oS}static removeAllUnaryOps(){return oS.unary_ops={},oS.max_unop_len=0,oS}static removeIdentifierChar(e){return oS.additional_identifier_chars.delete(e),oS}static removeBinaryOp(e){return delete oS.binary_ops[e],e.length===oS.max_binop_len&&(oS.max_binop_len=oS.getMaxKeyLen(oS.binary_ops)),oS.right_associative.delete(e),oS}static removeAllBinaryOps(){return oS.binary_ops={},oS.max_binop_len=0,oS}static removeLiteral(e){return delete oS.literals[e],oS}static removeAllLiterals(){return oS.literals={},oS}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 oS(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 oS.binary_ops[e]||0}static isIdentifierStart(e){return e>=65&&e<=90||e>=97&&e<=122||e>=128&&!oS.binary_ops[String.fromCharCode(e)]||oS.additional_identifier_chars.has(String.fromCharCode(e))}static isIdentifierPart(e){return oS.isIdentifierStart(e)||oS.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(oS.hooks[e]){let r={context:this,node:t};return oS.hooks.run(e,r),r.node}return t}searchHook(e){if(oS.hooks[e]){let t={context:this};return oS.hooks[e].find(function(e){return e.call(t.context,t),t.node}),t.node}}gobbleSpaces(){let e=this.code;for(;e===oS.SPACE_CODE||e===oS.TAB_CODE||e===oS.LF_CODE||e===oS.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:oS.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)===oS.SEMCOL_CODE||r===oS.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,oS.max_binop_len),t=e.length;for(;t>0;){if(oS.binary_ops.hasOwnProperty(e)&&(!oS.isIdentifierStart(this.code)||this.index+e.length<this.expr.length&&!oS.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:oS.binaryPrecedence(t),right_a:oS.right_associative.has(t)},(i=this.gobbleToken())||this.throwError("Expected expression after "+t),n=[o,a,i];t=this.gobbleBinaryOp();){if(0===(r=oS.binaryPrecedence(t))){this.index-=t.length;break}a={value:t,prec:r,right_a:oS.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:oS.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:oS.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,oS.isDecimalDigit(e)||e===oS.PERIOD_CODE)return this.gobbleNumericLiteral();if(e===oS.SQUOTE_CODE||e===oS.DQUOTE_CODE)n=this.gobbleStringLiteral();else if(e===oS.OBRACK_CODE)n=this.gobbleArray();else{for(r=(t=this.expr.substr(this.index,oS.max_unop_len)).length;r>0;){if(oS.unary_ops.hasOwnProperty(t)&&(!oS.isIdentifierStart(this.code)||this.index+t.length<this.expr.length&&!oS.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:oS.UNARY_EXP,operator:t,argument:e,prefix:!0})}t=t.substr(0,--r)}oS.isIdentifierStart(e)?(n=this.gobbleIdentifier(),oS.literals.hasOwnProperty(n.name)?n={type:oS.LITERAL,value:oS.literals[n.name],raw:n.name}:n.name===oS.this_str&&(n={type:oS.THIS_EXP})):e===oS.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===oS.PERIOD_CODE||t===oS.OBRACK_CODE||t===oS.OPAREN_CODE||t===oS.QUMARK_CODE;){let r;if(t===oS.QUMARK_CODE){if(this.expr.charCodeAt(this.index+1)!==oS.PERIOD_CODE)break;r=!0,this.index+=2,this.gobbleSpaces(),t=this.code}this.index++,t===oS.OBRACK_CODE?((e={type:oS.MEMBER_EXP,computed:!0,object:e,property:this.gobbleExpression()}).property||this.throwError('Unexpected "'+this.char+'"'),this.gobbleSpaces(),(t=this.code)!==oS.CBRACK_CODE&&this.throwError("Unclosed ["),this.index++):t===oS.OPAREN_CODE?e={type:oS.CALL_EXP,arguments:this.gobbleArguments(oS.CPAREN_CODE),callee:e}:(t===oS.PERIOD_CODE||r)&&(r&&this.index--,this.gobbleSpaces(),e={type:oS.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(;oS.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);if(this.code===oS.PERIOD_CODE)for(e+=this.expr.charAt(this.index++);oS.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++));oS.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);oS.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+e+this.char+")")}return r=this.code,oS.isIdentifierStart(r)?this.throwError("Variable names cannot start with a number ("+e+this.char+")"):(r===oS.PERIOD_CODE||1===e.length&&e.charCodeAt(0)===oS.PERIOD_CODE)&&this.throwError("Unexpected period"),{type:oS.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:oS.LITERAL,value:e,raw:this.expr.substring(t,this.index)}}gobbleIdentifier(){let e=this.code,t=this.index;for(oS.isIdentifierStart(e)?this.index++:this.throwError("Unexpected "+this.char);this.index<this.expr.length;)if(e=this.code,oS.isIdentifierPart(e))this.index++;else break;return{type:oS.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===oS.CPAREN_CODE&&n&&n>=t.length&&this.throwError("Unexpected token "+String.fromCharCode(e));break}if(a===oS.COMMA_CODE){if(this.index++,++n!==t.length){if(e===oS.CPAREN_CODE)this.throwError("Unexpected token ,");else if(e===oS.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!==oS.COMPOUND||this.throwError("Expected comma"),t.push(e)}}return r||this.throwError("Expected "+String.fromCharCode(e)),t}gobbleGroup(){this.index++;let e=this.gobbleExpressions(oS.CPAREN_CODE);if(this.code===oS.CPAREN_CODE)return(this.index++,1===e.length)?e[0]:!!e.length&&{type:oS.SEQUENCE_EXP,expressions:e};this.throwError("Unclosed (")}gobbleArray(){return this.index++,{type:oS.ARRAY_EXP,elements:this.gobbleArguments(oS.CBRACK_CODE)}}}Object.assign(oS,{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)})}}(oS),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"}),oS.max_unop_len=oS.getMaxKeyLen(oS.unary_ops),oS.max_binop_len=oS.getMaxKeyLen(oS.binary_ops);let o_=e=>new oS(e).parse(),oC=Object.getOwnPropertyNames(class{});Object.getOwnPropertyNames(oS).filter(e=>!oC.includes(e)&&void 0===o_[e]).forEach(e=>{o_[e]=oS[e]}),o_.Jsep=oS,o_.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 ok="ArrowFunctionExpression",oP={Array,Boolean,Symbol,Infinity,NaN,Math,Number,BigInt,String,RegExp,JSON,isFinite,isNaN,parseFloat,parseInt,decodeURI,encodeURI,encodeURIComponent,Object:{__proto__:void 0,assign:Object.assign.bind(null),fromEntries:Object.fromEntries.bind(null),hasOwn:Object.hasOwn.bind(null),keys:Object.keys.bind(null),is:Object.is.bind(null),values:Object.values.bind(null)}},oR={...oP,Promise};function oT(e,t={}){return oM(e,t,oF)}async function o$(e,t={}){return oj(e,t,oF)}function oN(e,t={}){return oM(e,t,oB)}function oO(e,t={}){return oj(e,t,oB)}function oI(e,t={}){return oM(e,t,oV)}function oA(e,t={}){return oj(e,t,oV)}function oM(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=oK(t,oP),a=oU("string"==typeof e?o_(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 oj(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=oK(t,oR);return Promise.resolve(oU("string"==typeof e?o_(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 oL(e){return o_(e)}function oF(e){return"string"==typeof e||"number"==typeof e||"boolean"==typeof e||null==e||e instanceof Date}function oB(e){return"boolean"==typeof e}function oV(e){return"number"==typeof e}function oU(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=oU(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 oU(v.left,b)&&oU(v.right,b);case"||":return oU(v.left,b)||oU(v.right,b);case"??":return oU(v.left,b)??oU(v.right,b)}let w=oU(v.left,b),x=oU(v.right,b);switch(v.operator){case"+":return w+x;case"-":return w-x;case"*":return w*x;case"/":return w/x;case"%":return w%x;case"**":return w**x;case"==":return w==x;case"===":return w===x;case"!=":return w!=x;case"!==":return w!==x;case">":return w>x;case">=":return w>=x;case"<":return w<x;case"<=":return w<=x;case"in":return w in x;default:throw`Expression evaluator does not support operator '${v.operator}' operator`}case"ConditionalExpression":return r=e,n=t,oU(r.test,n)?oU(r.consequent,n):oU(r.alternate,n);case"CallExpression":return oY(oH(e,t));case"ArrowFunctionExpression":let E;return a=e,o=t,E=a.params?.map(e=>{if("Identifier"===e.type)return e.name;throw`Cannot handle parameter of type ${e.type}`})??[],(function(...e){if(e.length<E.length)throw`Required argument(s) ${E.slice(e.length,-1).join(", ")} were not provided`;let t=Object.fromEntries(E.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 oU(a.body,o.addVariables(t))}).bind(null);case"MemberExpression":return oY(oz(e,t));case"ArrayExpression":return i=e,s=t,i.elements?.map(oq(s));case"SequenceExpression":let D;return l=e,u=t,(D=l.expressions.map(oq(u)))[D.length-1];case"NewExpression":var S=e,_=t;if(S.callee&&"Identifier"===S.callee.type){let e=S.arguments?.map(oq(_));switch(S.callee.name){case"Date":return new Date(...e);case"RegExp":return new RegExp(...e);default:throw`Cannot instantiate object of type ${S.callee.name}`}}if(S.callee)throw"new must be called with either Date or RegExp";throw'Could not handle "new" without a specified class';case"Literal":return e.value;case"Identifier":return c=e,d=t,(oJ(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(oq(p))??[],(k=m.quasis?.map(oq(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 oW(e,t){switch(e.type){case"Literal":return e.value;case"Identifier":return e.name;case"MemberExpression":return oW(e.property,t);default:throw`VisitExpressionName does not support expression of type '${e.type}'`}}function oH(e,t){let r=oZ(e.callee,t);if(r===oG||e.optional&&null==r)return oG;let n=e.arguments?.map(oq(t));if(r){if("function"!=typeof r)throw`${o0(e.callee)} is not a function`}else throw`No function named ${o0(e.callee)} is defined in this context`;return r(...n)}function oz(e,t){let r=oZ(e.object,t);if(r===oG||e.optional&&null==r)return oG;if(null===r)throw TypeError(`TypeError: cannot read properties of null (reading '${oQ(e.property,t)}')`);if(void 0===r)switch(e.object.type){case"Identifier":{let r=oW(e.object,t);throw ReferenceError(`ReferenceError: ${r} is not defined`)}case"MemberExpression":throw TypeError(`TypeError: cannot read properties of undefined (reading '${oQ(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}(oU(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);oJ(n),function(e,t){if(oX.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 oK(e,t){let r={variables:{...e},globals:{...t},addVariables(e){return this.variables={...this.variables,...e},this}};return r.addVariables.bind(r),r}o_.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:ok,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=ok,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)})}}),o_.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"}})}}),o_.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)})}}),o_.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")}})}}),o_.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 :")}})}}),o_.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})}}),o_.addBinaryOp("in",7),o_.addBinaryOp("??",1);let oG=Symbol("optional chain short-circuited");function oZ(e,t){switch(e.type){case"MemberExpression":return oz(e,t);case"CallExpression":return oH(e,t);default:return oU(e,t)}}function oY(e){return e===oG?void 0:e}function oq(e){return function(t){return null===t?null:oU(t,e)}}function oJ(e){if("__proto__"===e||"prototype"===e||"constructor"===e)throw{type:"Illegal property access",message:`Cannot access the ${e} property of objects`}}let oX=new Set(["toString","valueOf","hasOwnProperty"]);function oQ(e,t){try{return oW(e,t)}catch{return"<computed>"}}function o0(e){return e?"MemberExpression"===e.type?e.property?.name:e.name:null}function o1(e){if("string"!=typeof e&&("object"!=typeof e||!e||!("type"in e)))throw`Unknown expression type ${e}. Expressions must either be a string or pre-compiled string.`;let t={globals:{...oR},boundNames:new Set,variables:new Set};return o4("string"==typeof e?o_(e):e,t),[...t.variables]}function o4(e,t){switch(e.type){case"UnaryExpression":return r=e,n=t,void o4(r.argument,n);case"BinaryExpression":return a=e,o=t,void(o4(a.left,o),o4(a.right,o));case"ConditionalExpression":return i=e,s=t,void(o4(i.consequent,s),o4(i.test,s),o4(i.alternate,s));case"CallExpression":return l=e,u=t,void(o4(l.callee,u),l.arguments?.map(o2(u)));case"ArrowFunctionExpression":var r,n,a,o,i,s,l,u,c,d,m,p,f,h,g,y,v,b,w,x,E=e,D=t;let S=new Set(D.boundNames);for(let e of E.params??[])e?.type==="Identifier"&&S.add(e.name);o4(E.body,{...D,boundNames:S});return;case"MemberExpression":return c=e,d=t,void(o4(c.object,d),c.computed&&o4(c.property,d));case"ArrayExpression":return m=e,p=t,void m.elements?.map(o2(p));case"SequenceExpression":return f=e,h=t,void f.expressions?.map(o2(h));case"NewExpression":return g=e,y=t,void g.arguments?.map(o2(y));case"Literal":case"TemplateElement":return;case"Identifier":return v=e,b=t,void(v.name in b.globals||b.boundNames.has(v.name)||b.variables.add(v.name));case"TemplateLiteral":return w=e,x=t,void(w.expressions?.map(o2(x)),w.quasis?.map(o2(x)));default:throw`Expression evaluator does not support expression of type '${e.type}'`}}function o2(e){return function(t){return null===t?null:o4(t,e)}}let o3=W("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 o6(e,t,r){o3.setState(n=>({flags:{...n.flags,[e]:{enabled:n.flags[e]?.enabled??!1,label:t,description:r}}}))}function o5(){let e=o3.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 o9(e){return o3.getState().flags[e].enabled}function o8(e,t){o3.subscribe(r=>{t(r.flags[e].enabled)})}function o7(e,t){o3.setState(r=>({flags:{...r.flags,[e]:{...r.flags[e],enabled:t}}}))}o3.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 ie=e6(function(e,t,r){eY(e,t,r)});let it=B("extensionsInternal",{slots:{},extensions:{}}),ir=B("extensionRenderings",{renderings:new Map}),ia=()=>W("extensionsInternal",{slots:{},extensions:{}}),io=()=>W("extensionRenderings",{renderings:new Map});function ii(e){let t=it.getState(),r=e(t);r!==t&&it.setState(r)}let is=null,il=null;function iu(){let e=ir.getState();return is&&e===il||(is=new Map(e.renderings),il=e,function(e){for(let t of(iw.clear(),e.values()))iE(t,1);ix=!0}(is)),is}function ic(e){il={renderings:e},ir.setState(il,!0)}function id(e){let t=iu();t.has(e.renderingId)||(t.set(e.renderingId,e),iE(e,1),ic(t))}function im(e){let t=iu(),r=t.get(e);r&&(t.delete(e),iE(r,-1),ic(t))}let ip=()=>W("extensions",{slots:{}}),ih=0,ig=new Set;function iy(e){ih++;try{return e()}finally{if(0==--ih&&ig.size>0){let e=Array.from(ig);for(let t of(ig.clear(),e))iv(t)}}}function iv(e){try{e()}catch(t){console.error(`The extension system's '${e.name}' recomputation failed`,t)}}function ib(e){ih>0?ig.add(e):iv(e)}let iw=new Map,ix=!1;function iE(e,t){let r=JSON.stringify([e.slotName,e.extensionId,e.slotModuleName,e.extensionModuleName]),n=iw.get(r);if(!n){if(t<0)return;iw.set(r,{count:1,record:{slotModuleName:e.slotModuleName,extensionModuleName:e.extensionModuleName,slotName:e.slotName,extensionId:e.extensionId}}),ix=!0;return}n.count+=t,n.count<1&&(iw.delete(r),ix=!0)}function iD(){var e,t;if(iu(),!ix)return;ix=!1;let r=Array.from(iw.values(),({record:e})=>e);r.sort(iS),e=tX.getState().mountedExtensions,t=r,e.length===t.length&&e.every((e,r)=>0===iS(e,t[r]))||tX.setState({mountedExtensions:r})}function iS(e,t){return i_(e.slotName,t.slotName)||i_(e.extensionId,t.extensionId)||i_(e.slotModuleName,t.slotModuleName)||i_(e.extensionModuleName,t.extensionModuleName)}function i_(e,t){return e===t?0:e<t?-1:1}iD(),ir.subscribe(()=>ib(iD));let iC=ia(),ik=ip(),iP=t0(),iR=t2(),iT=new Set,i$=!1;function iN(e){if(null===e)iT=null;else if(null!==iT)for(let t of e)iT.add(t);ib(iO)}function iO(){if(!i$){i$=!0;try{for(let e=1;;e++){let t=iT;if(null!==t&&0===t.size)return;iT=new Set;try{!function(e,t,r,n,a,o=null){let i=ik.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}=t4(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}=iC.getState(),i=new Set(n),s=[...t,...r].filter(e=>!i.has(e)),l=iW(a),u=iW(t),c=new Map(s.map(e=>[e,function(e,t,r,n){let a=t.get(e);if(void 0!==a)return a;{if(void 0!==r)return 1e3+r;let t=n.get(e);return void 0!==t?2e3+t:3e3}}(e,l,o[iM(e)]?.order,u)]));return s.sort((e,t)=>c.get(e)-c.get(t))}(r,t.slots[e].attachedIds),s=[];for(let l of i){let{config:i}=t3(n,e,l),u=t6(r,e,l),c=u?ie({},i,u):i,d=iM(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||!aa(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&&e8(d.candidateExtensions,p)?s[n]=d:(s[n]={moduleName:c.moduleName,candidateExtensions:p},l=!0)}(l||Object.keys(i).length!==Object.keys(s).length)&&ik.setState({slots:s})}(iC.getState(),iP.getState(),iR.getState(),o3.getState(),n6.getState(),t)}catch(e){throw iT=null===t||null===iT?null:new Set([...t,...iT]),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{i$=!1}}}function iI(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 iA(e,t){return{moduleName:t,name:e,attachedIds:[]}}function iM(e){let[t]=e.split("#");return t}function ij(e,t){let r=iM(t);return e.extensions[r]}function iL(e){return ij(iC.getState(),e)}iC.subscribe((e,t)=>{iN(e.extensions!==t.extensions?null:iI(e.slots,t.slots))}),iP.subscribe((e,t)=>{iN(iI(e.slots,t.slots))}),iR.subscribe((e,t)=>{iN(iI(e.configs,t.configs))}),o3.subscribe(()=>iN(null)),n6.subscribe(()=>iN(null)),iN(null);let iF=e=>ii(t=>({...t,extensions:{...t.extensions,[e.name]:{...e}}}));function iB(e,t){ii(r=>{let n=r.slots[e];return n?{...r,slots:{...r.slots,[e]:{...n,attachedIds:[...n.attachedIds,t]}}}:{...r,slots:{...r.slots,[e]:{...iA(e),attachedIds:[t]}}}})}function iV(e,t){ii(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 iU(e){ii(t=>{let r=t.slots[e];return r?{...t,slots:{...t.slots,[e]:{...r,attachedIds:[]}}}:t})}function iW(e){let t=new Map;return e.forEach((e,r)=>{t.has(e)||t.set(e,r)}),t}function iH(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!!oN(o,a)}catch(t){return console.error(`Error while evaluating expression '${o}' for ${e.id}`+(n?` in ${n}`:""),t),!1}})}(iz(e),t,n6.getState().session,e)}function iz(e){return ik.getState().slots[e]?.candidateExtensions??[]}let iK=(e,t)=>iC.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=iA(t,e);return{...r,slots:{...r.slots,[t]:{...a}}}}),iG=()=>{iT=null,ii(()=>({slots:{},extensions:{}})),io().setState({renderings:new Map}),ik.setState({slots:{}})},iZ=B("left-nav",{slotName:null,basePath:window.spaBase,mode:"normal"});function iY({name:e,basePath:t,mode:r,componentContext:n,state:a}){iZ.setState({slotName:e,basePath:t,mode:r??"normal",componentContext:n,state:a})}function iq(e){iZ.getState().slotName===e&&iZ.setState(iZ.getInitialState(),!0)}let iJ=B("modalRegistry",{modals:{}});function iX(e){iJ.setState(t=>(t.modals[e.name]=e,t))}function iQ(e){let t=iJ.getState().modals[e];if(!t){let r=iL(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.`),iX(t))}return t}let i0=B("workspace2",{registeredGroupsByName:{},registeredWindowsByName:{},registeredWorkspacesByName:{},openedGroup:null,openedWindows:[],isMostRecentlyOpenedWindowHidden:!1});function i1(e){let{registeredWorkspacesByName:t,registeredWindowsByName:r}=i0.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 i4(e){let{registeredGroupsByName:t,registeredWindowsByName:r}=i0.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 i2(e){let{openedWindows:t}=i0.getState();return t.findIndex(t=>t.openedWorkspaces.find(t=>t.workspaceName===e))}function i3(e,t){if(0==t.length)return;let{registeredGroupsByName:r}=i0.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}}i0.setState({registeredGroupsByName:n})}function i6(e,t){if(0==t.length)return;let{registeredWindowsByName:r}=i0.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}i0.setState({registeredWindowsByName:n})}function i5(e,t){if(0==t.length)return;let{registeredWorkspacesByName:r}=i0.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}i0.setState({registeredWorkspacesByName:n})}let i9=0,i8=null,i7={bootstrap:15e3,mount:15e3,unmount:15e3};function se(e,t){if(e.timeouts)return e;let r=e.name??"parcel",n=Object.fromEntries(Object.keys(i7).filter(t=>e[t]).map(n=>{var a,o;let i,s;return[n,(a=e[n],o=i7[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 st(e,t){var r,n;let a,o,i,s,l,u=await (i8??(i8=new Promise((e,t)=>{(0,r3.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),r3.mountRootParcel))),i8),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=>se(e,r)):se(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 sr(){return sn}function sn(e,t){let r,n=st(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 sa(e,t,r,n,a=e=>e,o={}){let i=iM(n),s=iL(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=i9++,f=`${t}/${n}-${p}`;e.dataset.extensionRenderingId=f;let h=e=>{try{im(f)}catch(t){console.error(e,t)}};try{id({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 st(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 so=r(5399),si=r.n(so);let ss=(0,so.createContext)({moduleName:"",featureName:""});var sl=r(3338);function su({to:e,templateParams:t,onBeforeNavigate:r,children:n,...a}){return(0,so.useEffect)(()=>{a.href&&console.warn(`ConfigurableLink does not support the href prop. Use the 'to' prop instead. The provided href value is '${a.href}'`),a.onClick&&console.warn(`ConfigurableLink does not support the onClick prop. Use the 'onBeforeNavigate' prop instead. The 'to' prop of the offending link is ${e}`)},[]),(0,sl.jsx)("a",{onClick:n=>{0===n.button&&!n.ctrlKey&&!n.shiftKey&&!n.altKey&&!n.metaKey&&(n.preventDefault(),r?.(n),nW({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:nV(e,t),...a,children:n})}let sc=({state:e,children:t,...r})=>{let{extension:n}=(0,so.useContext)(ss),a=(0,so.useRef)(null),o=(0,so.useRef)(Promise.resolve()),i=(0,so.useRef)(!1),s=(0,so.useRef)(!1),l=(0,so.useRef)(e),u=(0,so.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,so.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,so.useCallback)(t=>{t&&!a.current&&!s.current&&n?.extensionSlotName&&n.extensionSlotModuleName&&(s.current=!0,sa(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,so.useEffect)(()=>(i.current=!1,()=>{i.current=!0,u(a.current)}),[]),(0,so.useEffect)(()=>{l.current=e,a.current&&c(a.current,e)},[e]),n?(0,sl.jsx)("div",{ref:d,"data-extension-id":n?.extensionId,style:{position:"relative"},...r}):null};function sd(e){let t=(0,so.useRef)(e);return T(t.current,e)||(t.current=e),t.current}function sm(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 sp=e=>e;function sf(e,t=sp,r){let n=(0,so.useCallback)(t=>e.subscribe(t),[e]),a=(0,so.useCallback)(()=>t(e.getState()),[e,t]),o=(0,so.useSyncExternalStore)(n,a,a),i=(0,so.useMemo)(()=>r?sm(e,r):null,[e,r]);return(0,so.useMemo)(()=>i?{...o,...i}:o,[o,i])}function sh(e,t){return sf(e,sp,t)}function sg(e){return function(t){let r=(0,so.useCallback)(t=>e.subscribe(t),[]),n=(0,so.useCallback)(()=>e.getState(),[]),a=(0,so.useSyncExternalStore)(r,n,n),o=(0,so.useMemo)(()=>t?sm(e,t):null,[t]);return(0,so.useMemo)(()=>o?{...a,...o}:a,[a,o])}}let sy=[];Object.freeze(sy);let sv={candidateExtensions:sy};Object.freeze(sv);let sb=e=>{let t=(0,so.useCallback)(t=>t.slots?.[e]??sv,[e]);return sf(ip(),t)},sw=e=>e.session;function sx(e,t){let{candidateExtensions:r}=sb(e),n=sf(n6,sw),a=sd(t);return(0,so.useMemo)(()=>iH(e,a),[e,a,n,r])}function sE(e,t){let{moduleName:r}=(0,so.useContext)(ss);if(!r)throw Error("ComponentContext has not been provided. This should come from @openmrs/esm-react-utils.");return(0,so.useEffect)(()=>{iK(r,e)},[r,e]),{extensions:sx(e,t),extensionSlotName:e,extensionSlotModuleName:r}}function sD(e){return e}function sS({name:e,extensionSlotName:t,select:r=sD,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,so.useRef)(null),{extensions:u,extensionSlotModuleName:c}=sE(s,a),d=(0,so.useMemo)(()=>r(u),[r,u]),m=(0,so.useMemo)(()=>{if("function"==typeof n&&!si().isValidElement(n))return d.map(e=>n(e,a))},[n,d]);return(0,sl.jsx)("div",{ref:l,"data-extension-slot-name":s,"data-extension-slot-module-name":c,style:{...o,position:"relative"},...i,children:s&&d?.map((e,t)=>(0,sl.jsx)(ss.Provider,{value:{moduleName:c,featureName:"",extension:{extensionId:e.id,extensionSlotName:s,extensionSlotModuleName:c,extensionMeta:e.meta}},children:m?.[t]??("function"!=typeof n?n:null)??(0,sl.jsx)(sc,{state:a})},e.id))})}var s_=r(6442),sC=r.n(s_),sk=r(4229),sP=r.n(sk),sR=r(7807),sT=r(1619),s$=r.n(sT),sN=r(3432);let sO={strictMode:!0,throwErrorsToConsole:!0,disableTranslations:!1},sI=new Map;(0,sN.initCache)(sI);let sA={errorRetryCount:3,fetcher:n2,focusThrottleInterval:18e5,revalidateIfStale:!0,revalidateOnFocus:!1,revalidateOnReconnect:!1,refreshInterval:0,shouldRetryOnError:e=>{if(e instanceof n3){let t=e.response.status;return!!(t>=500)||401===t||403===t||429===t}return!0},provider:()=>sI};function sM(e){if("object"!=typeof e||"string"!=typeof e.featureName||"string"!=typeof e.moduleName)throw Error("Invalid options");let t=Object.assign({},sO,e),r={...sA,...t.swrConfig};return function(e){var n,a,o,i,s;return o=a=class extends(n=si().Component){componentDidCatch(e,r){r&&r.componentStack&&(e.extra=Object.assign(e.extra||{},{componentStack:r.componentStack})),t.throwErrorsToConsole&&setTimeout(()=>{throw e}),this.setState({caughtError:e,caughtErrorInfo:r})}render(){if(this.state.caughtError)return(0,sl.jsx)("div",{children:"An error has occurred. Please try reloading the page."});{let n=(0,sl.jsx)(so.Suspense,{fallback:null,children:(0,sl.jsx)(sT.SWRConfig,{value:r,children:(0,sl.jsx)(ss.Provider,{value:this.state.config,children:t.disableTranslations?(0,sl.jsx)(e,{...this.props}):(0,sl.jsx)(sR.I18nextProvider,{i18n:window.i18next,defaultNS:this.state.config.extension?`${this.state.config.moduleName}___${this.state.config.extension.extensionSlotName}___${this.state.config.extension.extensionId}`:this.state.config.moduleName,children:(0,sl.jsx)(e,{...this.props})})})})});return t.strictMode&&si().StrictMode?(0,sl.jsx)(si().StrictMode,{children:n}):n}}constructor(e){super(e),this.state={caughtError:null,caughtErrorInfo:null,config:{moduleName:t.moduleName,featureName:t.featureName,extension:e._extensionContext}}}},i="displayName",s=`OpenmrsReactComponent(${t.featureName})`,i in o?Object.defineProperty(o,i,{value:s,enumerable:!0,configurable:!0,writable:!0}):o[i]=s,a}}function sj(e,t){return sP()({React:si(),ReactDOMClient:sC(),rootComponent:sM(t)(e)})}function sL(e,t){return()=>e().then(({default:e})=>sj(e,t))}function sF(e,t){return()=>Promise.resolve(sj(e,t))}let sB=sL,sV=I()(()=>({}));U("openmrs-app-context",sV);let sU={};function sW(e,t=e=>e){let r=sV.getState();return e in r?Object.freeze(Object.assign({},t?t(r[e]):r[e])):null}function sH(e,t){sV.setState(r=>(e in r||(r[e]={}),r[e]=t(r[e]),Object.assign({},r)))}function sz(e){return null===e?null:Object.freeze(Object.assign({},e))}let sK=new Map;function sG(e,t){let r=(0,so.useRef)(t??{}),n=(0,so.useRef)(t=>sH(e,t)),a=(0,so.useRef)(Symbol());return(0,so.useEffect)(()=>{let r=t??{},n=a.current;return null===sW(e)?!function(e,t=sU){sV.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===sU?{}: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.`),sH(e,()=>r)),sK.set(e,n),()=>{sK.get(e)===n&&(sV.setState(t=>(e in t&&delete t[e],t)),sK.delete(e))}},[e]),(0,so.useEffect)(()=>{let n=t??{};T(r.current,n)||(sH(e,()=>n),r.current=n)},[t]),n.current}function sZ({namespace:e,value:t}){return sG(e,t),null}let sY=({children:e,value:t,fallback:r})=>t?(0,sl.jsx)(sl.Fragment,{children:e}):r?(0,sl.jsx)(sl.Fragment,{children:r}):null;function sq(){let e=(0,so.useRef)();return(!e.current||e.current.signal.aborted)&&(e.current=new AbortController),(0,so.useEffect)(()=>{let t=e.current;return()=>t?.abort()},[]),e.current}function sJ(e,t=e=>e??{}){let[r,n]=(0,so.useState)(()=>{if(sX(e))return;let r=sW(e);if(null!==r)return t?t(r):r});return(0,so.useEffect)(()=>{if(sX(e))throw Error(`The namespace supplied to useAppContext must be a non-empty string, but was "${e}".`)},[e]),(0,so.useEffect)(()=>{var r;let a;return(r=e=>{if(null==e)return void n(void 0);let r=t?t(e):e;n(e=>T(e,r)?e:r)})(sz(a=sW(e))),sV.subscribe(t=>{let n=e in t?t[e]:null;n!==a&&(a=n,r(sz(n)))})},[e,t]),r}function sX(e){return"string"!=typeof e||0===e.trim().length}function sQ(e){let t=sx(e);return(0,so.useMemo)(()=>t.map(e=>e.id),[t])}function s0(e){return sb(e).candidateExtensions}function s1(e,t,r){let{data:n,error:a,mutate:o,isLoading:i,isValidating:s}=s$()(e?oa(e,t,r):null,n2);return(0,so.useMemo)(()=>({isLoading:i,data:n?.data.results??[],error:a,mutate:o,isValidating:s}),[n,a,i,s,o])}function s4(e){(0,so.useEffect)(()=>{if(e){let e=window.getComputedStyle(document.body).overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=e}}},[e])}let s2={},s3=`No ComponentContext has been provided. This should come from "openmrsComponentDecorator".
16
- Usually this is already applied when using "getAsyncLifecycle" or "getSyncLifecycle".`;function s6(e,t,r){let n=s2[e];if(n)return n;let a=new Promise(e=>{let n=r(t.getState());if(n)return void e(n);let a=t.subscribe(t=>{let n=r(t);n&&(a(),e(n))})});return s2[e]=a,a.then(()=>{s2[e]===a&&delete s2[e]}),a}function s5(e){let{moduleName:t,extension:r}=(0,so.useContext)(ss),n=e?.externalModuleName??t;if(!n&&!r)throw Error(s3);let a=function(e){let t=(0,so.useMemo)(()=>tQ(e),[e]),r=function(e){let[t,r]=(0,so.useState)(()=>{let t=e.getState();return t.loaded&&t.config?t.config:null});return(0,so.useEffect)(()=>e?.subscribe(e=>{e.loaded&&e.config&&r(e.config)}),[e]),t}(t);if(!r)throw s6(e,t,e=>e.loaded?e.config:null);return r}(n),o=function(e){let t=(0,so.useMemo)(t2,[]),r=function(e,t){let[r,n]=(0,so.useState)(t?()=>{let r=t3(e.getState(),t.extensionSlotName,t.extensionId);if(r.loaded&&r.config)return r.config}:null);return(0,so.useEffect)(()=>{if(t)return e.subscribe(e=>{let a=t3(e,t.extensionSlotName,t.extensionId);a.loaded&&a.config&&!e8(a.config,r)&&n(a.config)})},[e,t,r]),r}(t,e);if(!r&&e)throw s6(`${e.extensionSlotName}-${e.extensionId}`,t,t=>{let r=t3(t,e.extensionSlotName,e.extensionId);return r.loaded?r.config:null});return r||{}}(r);return(0,so.useMemo)(()=>e?.externalModuleName&&n===e.externalModuleName?{...a}:{...a,...o},[n,e?.externalModuleName,a,o])}let s9=sx;function s8(e,t=300){let[r,n]=(0,so.useState)(e);return(0,so.useEffect)(()=>{let r=setTimeout(()=>{n(e)},t);return()=>{clearTimeout(r)}},[e,t]),r}var s7=r(3660),le=r.n(s7);let lt=`custom:${[["admissionDecisionConcept","ref"],["admissionEncounterType","ref"],["admissionForm","ref"],["atFacilityVisitType","ref"],["bedAssignmentEncounterType","ref"],["cancelADTRequestEncounterType","ref"],["checkInClerkEncounterRole","ref"],["checkInEncounterType","ref"],["clinicianEncounterRole","ref"],["conceptSourcesForDiagnosisSearch","ref"],["consultEncounterType","ref"],["consultFreeTextCommentsConcept","ref"],["denyAdmissionConcept","ref"],["diagnosisMetadata","ref"],["diagnosisSets","ref"],["dischargeForm","ref"],["dispositionDescriptor","ref"],["dispositions","ref"],["emrApiConceptSource","ref"],["exitFromInpatientEncounterType","ref"],["extraPatientIdentifierTypes","ref"],["fullPrivilegeLevel","ref"],["highPrivilegeLevel","ref"],["identifierTypesToSearch","ref"],["inpatientNoteEncounterType","ref"],["lastViewedPatientSizeLimit","ref"],["metadataSourceName","ref"],["motherChildRelationshipType","ref"],["narrowerThanConceptMapType","ref"],["nonDiagnosisConceptSets","ref"],["orderingProviderEncounterRole","ref"],["patientDiedConcept","ref"],["personImageDirectory","ref"],["primaryIdentifierType","ref"],["sameAsConceptMapType","ref"],["suppressedDiagnosisConcepts","ref"],["supportsAdmissionLocationTag","(uuid,display,name,links)"],["supportsLoginLocationTag","(uuid,display,name,links)"],["supportsTransferLocationTag","(uuid,display,name,links)"],["supportsVisitsLocationTag","(uuid,display,name,links)"],["telephoneAttributeType","ref"],["testPatientPersonAttributeType","ref"],["transferForm","ref"],["transferRequestEncounterType","ref"],["transferWithinHospitalEncounterType","ref"],["unknownCauseOfDeathConcept","ref"],["unknownLocation","ref"],["unknownPatientPersonAttributeType","ref"],["unknownProvider","ref"],["visitAssignmentHandlerAdjustEncounterTimeOfDayIfNecessary","ref"],["visitExpireHours","ref"],["visitNoteEncounterType","ref"]].map(([e,t])=>`${e}:${t}`).join(",")}`;function lr(){let e=`${nQ}/emrapi/configuration?v=${lt}`,t=le()(e,n2);return(0,so.useMemo)(()=>({emrConfiguration:t.data?.data,isLoadingEmrConfiguration:t.isLoading,mutateEmrConfiguration:t.mutate,errorFetchingEmrConfiguration:t.error}),[t])}function ln(){return(0,so.useContext)(ss).extension}let la=sg(ia());function lo(e){let t=sx(e);return(0,so.useMemo)(()=>Object.fromEntries(t.map(e=>[e.name,e.meta])),[t])}let li=sg(ip());function ls(e){let{flags:t}=sf(o3);return t[e]?.enabled??!1}function ll(){let[,e]=(0,so.useState)(0);return(0,so.useCallback)(()=>{e(e=>e+1)},[])}function lu(e,t,r={}){return ld(e,t,lc,r)}let lc={getPaginatedUrl:(e,t,r)=>{if(!e)return null;{let n=new URL(n4(e.toString()),window.location.toString());return n.searchParams.set("limit",""+t),n.searchParams.set("startIndex",""+r),n.searchParams.set("totalCount","true"),n.toString()}},getNextUrl:e=>{let t=e?.links?.find(e=>"next"==e.rel)?.uri;if(!t)return null;{let e=new URL(t);return e.host=window.location.host,e.protocol=window.location.protocol,e.toString()}},getTotalCount:e=>e?.totalCount??NaN,getCurrentPageSize:e=>e?.results?.length??NaN,getData:e=>e?.results};function ld(e,t,r,n={}){let{getPaginatedUrl:a,getTotalCount:o,getCurrentPageSize:i,getData:s}=r,{immutable:l,swrConfig:u}=n,c=n.fetcher??n2,[d,m]=(0,so.useState)(1),p=(0,so.useRef)(NaN),f=(0,so.useRef)(NaN),h=(0,so.useRef)(d),g=(0,so.useRef)(!1),y=(0,so.useRef)(!1),v=e?.toString()??"",[b,w]=(0,so.useState)(v);v!==b&&(w(v),m(1),h.current=1,p.current=NaN,f.current=NaN,g.current=!1,y.current=!1);let x=(d-1)*t,E=(0,so.useMemo)(()=>a(e,t,x),[e,t,x]),{data:D,...S}=(l?le():s$())(E,c,u);D?.data&&(p.current=o(D?.data),f.current=i(D?.data),g.current=!0);let _=Math.ceil(p.current/t),C=(0,so.useCallback)(e=>{if(!Number.isInteger(e)||e<1)return void console.warn(`useServerPagination: ignoring goTo(${e}); page must be a positive integer.`);let r=Math.ceil(p.current/t);!g.current||Number.isNaN(r)||e<=r?(h.current=e,m(e)):console.warn("Invalid attempt to go to out of bounds page: "+e)},[t]);(0,so.useEffect)(()=>{if(!g.current)return;if(Number.isNaN(p.current)){y.current||(y.current=!0,console.warn(`useServerPagination: ${v} returned no total count, so out-of-range pages cannot be detected.`));return}let e=Math.max(1,Math.ceil(p.current/t));d>e&&(console.warn(`Invalid attempt to go to out of bounds page: ${d}; returning to page ${e}.`),h.current=e,m(e))},[d,t,v,D]);let k=(0,so.useCallback)(()=>{C(h.current+1)},[C]),P=(0,so.useCallback)(()=>{C(h.current-1)},[C]);return{data:s(D?.data),totalPages:_,totalCount:p.current,currentPage:d,currentPageSize:f.current,paginated:_>1,showNextButton:d<_,showPreviousButton:d>1,goTo:C,goToNext:k,goToPrevious:P,...S}}function lm(e,t,r={}){return ld(e,t,lp(),r)}function lp(){return{getPaginatedUrl:(e,t,r)=>{if(!e)return null;{let n=new URL(n4(e.toString()),window.location.toString());return n.searchParams.set("_count",""+t),n.searchParams.set("_getpagesoffset",""+r),n.toString()}},getNextUrl:e=>{let t=e?.link?.find(e=>"next"==e.relation)?.url;if(!t)return null;{let e=new URL(t);return e.host=window.location.host,e.protocol=window.location.protocol,e.toString()}},getTotalCount:e=>e?.total??NaN,getCurrentPageSize:e=>e?.entry?.length??NaN,getData:e=>e?.entry?.map(e=>e.resource)}}var lf=r(682),lh=r.n(lf);function lg(e,t={}){return ly(e,lc,t)}function ly(e,t,r={}){let{swrInfiniteConfig:n,immutable:a}=r,{getNextUrl:o,getTotalCount:i,getData:s}=t,l=r.fetcher??n2,u=(0,so.useCallback)((r,n)=>0==r?e?.toString()??null:t.getNextUrl(n.data),[e]),{data:c,size:d,setSize:m,...p}=lh()(u,l,{...n,...a?{revalidateIfStale:!1,revalidateOnFocus:!1,revalidateOnReconnect:!1}:{}}),f=o(c?.[c.length-1].data),h=i(c?.[0]?.data);return{data:c?.flatMap(e=>s(e.data)),totalCount:h,hasMore:null!=f,loadMore:()=>{m((c?.length??0)+1)},nextUri:f,...p}}function lv(e,t={}){return lb(e,lc,t)}function lb(e,t,r={}){let n=ly(e,t,r),{hasMore:a,error:o,data:i,loadMore:s,isLoading:l,nextUri:u}=n;return((0,so.useEffect)(()=>{a&&!o&&s()},[a,u]),r.partialData)?n:{...n,data:a||o?void 0:i,isLoading:l||a}}function lw(e,t={}){return lb(e,lp(),t)}function lx(e,t={}){return ly(e,lp(),t)}function lE(){let e="tablet";return document.body.classList.forEach(t=>{switch(t){case"omrs-breakpoint-lt-tablet":e="phone";break;case"omrs-breakpoint-gt-small-desktop":e="large-desktop";break;case"omrs-breakpoint-gt-tablet":e="small-desktop"}}),e}function lD(){let[e,t]=(0,so.useState)(lE);return(0,so.useEffect)(()=>{let e=()=>{t(lE())};return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),e}let lS=e=>"small-desktop"===e||"large-desktop"===e;function l_(e){let t=(0,so.useContext)(ss);(0,so.useEffect)(()=>(t&&t.moduleName&&(e.componentContext=t),iY(e),()=>{iq(e.name)}),[t,e])}function lC(){return sf(iZ)}let lk=[];function lP(e=null,t=null){let r=new URLSearchParams;e&&r.set("tag",e),t&&r.set("q",t);let n=r.toString(),{data:a}=lv(`${nQ}/location${n?"?"+n:""}`,{immutable:!0});return a??lk}function lR(e,t=!0){let r=(0,so.useRef)(null);return(0,so.useEffect)(()=>{let n=n=>{t&&r.current&&n.target&&n.target instanceof Node&&(r.current.contains(n.target)||e(n))};return window.addEventListener("mousedown",n),window.addEventListener("touchstart",n),()=>{window.removeEventListener("mousedown",n),window.removeEventListener("touchstart",n)}},[e,t]),r}function lT(e){let t=(0,so.useRef)();return(0,so.useEffect)(()=>{let r=new IntersectionObserver(t=>{for(let r of t)if(r.isIntersecting)return void e()},{threshold:1});return t.current&&r.observe(t.current),()=>{t.current&&r.unobserve(t.current)}},[t.current,e]),t}function l$(e,t={}){let{abortController:r,fetchInit:n,url:a,swrConfig:o}=t,i=sq(),s=(0,so.useMemo)(()=>n?.signal??r?.signal??i.signal,[r?.signal,n?.signal,i.signal]),l=(0,so.useCallback)(e=>n2(function(e,t){if(t)return"function"==typeof t?t(e):t;if("string"==typeof e)return e;throw Error(`When using useOpenmrsSWR with a key that is not a string, you must provide a url() function that converts the key to a valid url. The key for this hook is ${e}.`)}(e,a),{...n,signal:s}),[s,n,a]);return s$()(e,l,o)}function lN(e=[],t=10){let[r,n]=(0,so.useState)(1),a=(0,so.useMemo)(()=>"number"==typeof t&&t>0?Math.max(1,Math.ceil(e.length/t)):1,[e.length,t]);r>a&&n(a);let o=Math.min(Math.max(1,r),a),i=(0,so.useMemo)(()=>{let r=(o-1)*t,n=(o+0)*t;return e.slice(r,n)},[e,o,t]),s=(0,so.useCallback)(e=>{!Number.isInteger(e)||e<1?console.warn(`usePagination: ignoring goTo(${e}); page must be a positive integer.`):n(e)},[]),l=(0,so.useCallback)(()=>{n(e=>e+1)},[]),u=(0,so.useCallback)(()=>{n(e=>Math.max(1,e-1))},[]);return(0,so.useMemo)(()=>({results:i,totalPages:a,currentPage:o,paginated:e.length>t,showNextButton:o<a,showPreviousButton:o>1,goTo:s,goToNext:l,goToPrevious:u}),[i,a,e.length,t,o,s,l,u])}function lO(e,t,r,n){return{pageSizes:(0,so.useMemo)(()=>{let r=Math.ceil(t/e);return isNaN(r)&&(r=0),[...Array(r).keys()].map(t=>(t+1)*e)},[e,t]),pageItemsCount:(0,so.useMemo)(()=>e>t?t:e*r>t?e*(r-1)+n:e*r,[e,t,r,n])}}function lI(){let e=/\/patient\/([a-zA-Z0-9\-]+)\/?/.exec(location.pathname);return e&&e[1]}function lA(e){let[t,r]=(0,so.useState)(e??lI()),{data:n,error:a,isValidating:o}=s$()(t?["patient",t]:null,()=>os(t,{}));return(0,so.useEffect)(()=>{let e=()=>{let e=lI();e!==t&&r(e)};return window.addEventListener("single-spa:routing-event",e),()=>window.removeEventListener("single-spa:routing-event",e)},[t]),(0,so.useMemo)(()=>({isLoading:o&&!a&&!n,patient:n,patientUuid:t,error:a}),[o,a,n,t])}function lM(){let e=`${nQ}/metadatamapping/termmapping?v=custom:(metadataUuid)&code=emr.primaryIdentifierType`,{data:t,error:r,isLoading:n}=s$()(e,n2);return(0,so.useMemo)(()=>({primaryIdentifierCode:t?.data?.results[0]?.metadataUuid,isLoading:n,error:r}),[t,r,n])}function lj(e,t,r,n){let a=e?.slotName===t&&e.slotModuleName===r?e.components:null,o=new Map;for(let e of n)o.set(e,a?.get(e)??function(e,t,r){let n=iM(r),a=e=>e.extensions[n]?.meta,o=({state:n})=>{let o=sf(ia(),a),i=(0,so.useMemo)(()=>({moduleName:t,featureName:"",extension:{extensionId:r,extensionSlotName:e,extensionSlotModuleName:t,extensionMeta:o}}),[o]);return(0,sl.jsx)(ss.Provider,{value:i,children:(0,sl.jsx)(sc,{state:n})})};return o.displayName=`RenderableExtension(${r})`,o}(t,r,e));return{slotName:t,slotModuleName:r,components:o}}function lL(e){let{extensions:t,extensionSlotModuleName:r}=sE(e),n=(0,so.useMemo)(()=>new Set(e?t.map(e=>e.id):[]),[e,t]),[a,o]=(0,so.useState)(()=>lj(null,e,r,n)),i=a;return a.slotName===e&&a.slotModuleName===r&&a.components.size===n.size&&[...n].every(e=>a.components.has(e))||o(i=lj(a,e,r,n)),(0,so.useMemo)(()=>e?t.flatMap(e=>{let t=i.components.get(e.id);return t?[t]:[]}):[],[e,t,i])}function lF(){let e=(0,so.useRef)(),[t,r]=(0,so.useState)(null),n=null;if(!t){if(o){let e=ae().getState();e.loaded&&(n=e.session)}else o=new Promise(t=>{let r=({loaded:r,session:a})=>{r&&(t(a),n=a,e.current&&(e.current(),e.current=void 0))};r(ae().getState()),n||(e.current=ae().subscribe(r))});if(n)r(n);else throw o}(0,so.useEffect)(()=>(e.current||(e.current=ae().subscribe(({loaded:e,session:t})=>{e&&(n=t,r(t))})),()=>{e.current&&(e.current(),e.current=void 0)}),[]);let a=t||n;if(!a)if(o)throw console.warn("useSession is in an unexpected state. Attempting to recover."),o;else throw Error("useSession is in an invalid state.");return a}let lB=({privilege:e,fallback:t,children:r})=>{let[n,a]=(0,so.useState)(null);return((0,so.useEffect)(()=>{let e=ae(),t=e.subscribe(({loaded:e,session:t})=>{a(e?t?.user??null:null)}),{loaded:r,session:n}=e.getState();return r&&a(n?.user??null),t},[]),n&&aa(e,n))?(0,sl.jsx)(sl.Fragment,{children:r}):t?(0,sl.jsx)(sl.Fragment,{children:t}):null};var lV=r(222),lU=r.n(lV),lW=r(5602);let lH=new Map;function lz(){for(let e of Array.from(lH.values()))e()}let lK={setVisitContext:(e,t)=>null==t?{manuallySetVisitUuid:null}:{manuallySetVisitUuid:t.uuid,patientUuid:t.patient?.uuid}};function lG(e){let t=(0,so.useId)();return(0,so.useEffect)(()=>{if(e)return lH.set(t,e),()=>{lH.delete(t)}},[t,e]),{...sh(ob(),lK),mutateVisit:lz}}function lZ(e,t=oy){let r=(0,so.useRef)(void 0),{patientUuid:n,manuallySetVisitUuid:a,setVisitContext:o}=lG((0,so.useCallback)(()=>r.current?.(),[])),i=e&&n==e?a:null,s=`?patient=${e}&v=${t}&includeInactive=false`,l=`/${i}?v=${t}`,{data:u,error:c,mutate:d,isValidating:m}=s$()(e?`${nQ}/visit${s}`:null,n2),{data:p,error:f,mutate:h,isValidating:g}=s$()(e&&i?`${nQ}/visit${l}`:null,n2),y=(0,so.useMemo)(()=>u?.data.results.find(e=>null===e.stopDatetime)??null,[u]),v=(0,so.useMemo)(()=>i&&p?p.data:null,[p,i]),b=(0,so.useRef)(null);(0,so.useEffect)(()=>{!m&&y&&n===e&&null===a&&o(y),g||(b.current&&v&&b.current.uuid===v.uuid&&!b.current.stopDatetime&&v.stopDatetime&&o(null),b.current=v)},[v,a,y,m,g,n]);let w=(0,so.useCallback)(()=>{d(),h()},[d,h]);(0,so.useEffect)(()=>{r.current=w},[w]);let x=!!(!u||i&&!p),E=!!(i?f:c);return{error:c||f,mutate:w,isValidating:m||g,activeVisit:y,currentVisit:v,currentVisitIsRetrospective:!!i,isLoading:x&&!E}}lU().extend(lW);let lY=[];function lq(){let{data:e}=le()(op,of);return e??lY}let lJ=new Map;async function lX(e,t){let r=t.indexOf("#"),n=r>=0,a=n?t.substring(0,r):e,o=n?t.substring(r+1):t,i=await aV(a);return i&&Object.hasOwn(i,o)&&"function"==typeof i[o]?l0(a,i).then(()=>i[o]()):(i?i&&Object.hasOwn(i,o)?console.warn(`The export ${t}, defined in ${e}'s routes.json, is not a function`):console.warn(`${a} does not define a component called "${o}", referenced in ${e}'s routes.json. This cannot be loaded.`):console.warn(`Unknown app ${a} for ${t} defined in ${e}'s routes.json`),lQ)}let lQ={bootstrap:()=>Promise.resolve(),mount:()=>Promise.resolve(),unmount:()=>Promise.resolve()};async function l0(e,t){if(e in lJ)await lJ[e];else{let r=t??await aV(e);await (lJ[e]=new Promise((t,n)=>{if(Object.hasOwn(r,"startupApp")){let a=r.startupApp;if("function"==typeof a)return Promise.resolve(a()).then(()=>{rv(e),t(null)}).catch(n)}rv(e),t(null)}))}}function l1(e,t){let r=t.name;if(!r)return void console.error(`An extension definition in ${e} is missing an name and thus cannot be
15
+ ${this.stack}`}}let n6=B("session",{loaded:!1,session:null}),n5=0,n9=null;function n8(){return n9||(n6.getState().loaded&&n5>=Date.now()-6e4?null:ar())}function n7(e){let t=e?.includeAuthStatus??!0,r=e=>t?e:e.user,n=n8();return n?new Promise(e=>{let t=()=>{let t=n6.getState();t.loaded&&(a(),e(r(t.session)))},a=n6.subscribe(t);n.then(t,t)}):Promise.resolve(r(n6.getState().session))}function ae(){return n8(),n6}function at(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 ar(e,t){n5=Date.now(),a??(a=n5);let r={};e&&t&&(r.Authorization=`Basic ${window.btoa(`${e}:${t}`)}`);let n=am(n2(n1,{headers:r,rejectAuthFailure:!0})),o=()=>{n9===n&&(n9=null)};return n.then(o,o),n9=n,n}function an(){n6.setState({loaded:!0,session:{authenticated:!1,sessionId:""}},!0)}function aa(e,t){var r,n;if(void 0===t)return!e;if(!e)return!0;return r=e,n=t,("string"==typeof r?!K(n.privileges.find(e=>r===e.display)):Array.isArray(r)?r.every(e=>!K(n.privileges.find(t=>e===t.display))):(K(r)||console.error(`Could not understand privileges "${r}"`),!0))||!K(t.roles.find(e=>"System Developer"===e.display))}function ao(){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(n6.getState()),e||(t=n6.subscribe(n))})}async function ai(){return(await n7()).sessionLocation}async function as(e,t){return am(n2(n1,{method:"POST",body:{sessionLocation:e},headers:{"Content-Type":"application/json"},rejectAuthFailure:!0,signal:t?.signal}))}async function al(e,t){return await n2(n1,{method:"POST",body:{locale:e},headers:{"Content-Type":"application/json"},signal:t?.signal}),ar()}async function au(e,t,r){return r||(r=new AbortController),await n2(`${nQ}/user/${e}`,{method:"POST",body:{userProperties:t},headers:{"Content-Type":"application/json"},signal:r.signal}),ar()}async function ac(e,t=!1){let r=await n2(t?`${n1}?rememberMe=true`:n1,{headers:{"X-Totp-Code":e}});return r.data?.authenticated?(await ar()).session:r.data}async function ad(){try{await n2(n1,{method:"DELETE",rejectAuthFailure:!0})}catch(e){if(!ap(e))throw e}an(),await ar().catch(()=>{})}function am(e){return new Promise((t,r)=>{e.then(e=>{if("object"==typeof e?.data){let r={loaded:!0,session:e.data};n6.setState(r,!0),t(r)}else!function(e){if(!e?.redirected||!e.url)return!1;try{return new URL(e.url,window.location.href).pathname.replace(/\/+$/,"").endsWith("/initialsetup")}catch{return!1}}(e)?r(af(Error("The session endpoint did not respond with a session"))):r(af(Error("The server is still starting up"),!0))}).catch(e=>{var n,o;if(ap(e)){"object"==typeof(n=e.responseBody)&&null!==n&&!1===n.authenticated?n6.setState({loaded:!0,session:e.responseBody},!0):an(),t(n6.getState());return}(o=e)instanceof n3&&502===o.response.status&&!n6.getState().loaded&&void 0!==a&&Date.now()-a<18e4?r(af(e,!0)):(k(`Failed to fetch new session information: ${e}`),r(af(e)))})})}function ap(e){return e instanceof n3&&(401===e.response.status||403===e.response.status)}function af(e,t=!1){return n6.getState().loaded||n6.setState({loaded:!1,session:null,error:e instanceof Error?e:Error(String(e)),initializing:t},!0),n6.getState()}function ah(){return"development"===window.spaEnv||"true"===localStorage.getItem("openmrs:devtools")}n6.subscribe(e=>{e.loaded&&e.session&&at(e.session)});let ag={"webservices.rest":"2.24.0",fhir2:"1.0.0-SNAPSHOT"};function ay(){rg("@openmrs/esm-api",nJ),ar()}let av="import-map-override:",ab="import-map-overrides-disabled",aw="import-map-overrides:change",ax=!1,aE=null,aD=null;async function aS(){return aD??(aD=a_().then(({map:e,complete:t})=>(t||(aD=null),e))),aD}async function a_(){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:aC(t),complete:r}}function aC(e){let t={imports:{}};for(let r of e)r?.imports&&Object.assign(t.imports,r.imports);return t}function ak(){let e={};try{let t=aN();for(let r=0;r<localStorage.length;r++){let n=localStorage.key(r);if(n?.startsWith(av)){let r=n.slice(av.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 aP(){let e=await aS();return ax?aC([e,aE??ak()]):e}async function aR(){return aS()}async function aT(){return ax?aC([await aS(),ak()]):aS()}function a$(e){if(!ax)return{imports:{}};if(e){let e={};for(let t=0;t<localStorage.length;t++){let r=localStorage.key(t);if(r?.startsWith(av)){let t=localStorage.getItem(r);t&&(e[r.slice(av.length)]=t)}}return{imports:e}}return ak()}function aN(){if(!ax)return[];try{let e=localStorage.getItem(ab);if(e){let t=JSON.parse(e);if(Array.isArray(t))return t}}catch{}return[]}function aO(e){return!!ax&&aN().includes(e)}function aI(e,t){if(!ax)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{localStorage.setItem(av+e,t),window.dispatchEvent(new CustomEvent(aw))}catch(e){console.warn("[import-maps] Failed to write import-map override to localStorage",e)}}function aA(e){if(!ax)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{localStorage.removeItem(av+e);let t=aN().filter(t=>t!==e);t.length>0?localStorage.setItem(ab,JSON.stringify(t)):localStorage.removeItem(ab),window.dispatchEvent(new CustomEvent(aw))}catch(e){console.warn("[import-maps] Failed to update import-map overrides in localStorage",e)}}function aM(){if(!ax)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(av)&&e.push(r)}e.forEach(e=>localStorage.removeItem(e)),localStorage.removeItem(ab),window.dispatchEvent(new CustomEvent(aw))}catch(e){console.warn("[import-maps] Failed to clear import-map overrides from localStorage",e)}}function aj(e){if(!ax)return void console.warn("[Security] Import map overrides are disabled in production mode.");try{let t=aN().filter(t=>t!==e);t.length>0?localStorage.setItem(ab,JSON.stringify(t)):localStorage.removeItem(ab),window.dispatchEvent(new CustomEvent(aw))}catch(e){console.warn("[import-maps] Failed to update import-map overrides in localStorage",e)}}let aL=!1;function aF(){!aL&&(aL=!0,(ax="development"===window.spaEnv)&&(aE=ak()))}function aB(e){return e.replace(/[\/\-@]/g,"_")}async function aV(e,t="./start",n){var a;let o,i=!n?.maxLoadingTime||n.maxLoadingTime<=0?6e5:n.maxLoadingTime;await Promise.race([aU(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=aB(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 aU(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=aB(e);if(!window[r]){let r=t??await aW();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 a$().imports;try{return await function(e){var t;let r=(t=window)[aH]??(t[aH]=new Map),n=r.get(e);if(n)return n;if(document.head.querySelector(`script[src="${e}"]`))return console.warn(`Script at ${e} already loaded. Not loading it again.`),Promise.resolve();let a=document.createElement("script");a.src=e,a.type="text/javascript",a.async=!0;let o=new Promise((t,n)=>{let o=setTimeout(()=>{console.error(`The script at ${e} did not load within 5 seconds. This may indicate an issue with the imports in the script's entry-point file or with the script's bundler configuration.`)},5e3);function i(){clearTimeout(o),a.removeEventListener("load",s),a.removeEventListener("error",l)}function s(){i(),t()}function l(t){i(),r.delete(e),a.remove();let o=`Failed to load script from ${e}`;console.error(o,t),n(t.message??o)}a.addEventListener("load",s),a.addEventListener("error",l),document.head.appendChild(a)});return r.set(e,o),o}(n)}catch(e){return a&&x({kind:"error",title:nB("scriptLoadingFailed","Error: Script failed to load"),description:nB("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:nB("resetOverrides","Reset overrides"),onActionButtonClick(){aM(),window.location.reload()}}),Promise.reject(e)}}return Promise.resolve()}async function aW(){return aP()}let aH=Symbol.for("__openmrs_script_loading");function az(e){return!!e&&"object"==typeof e&&!(Object.hasOwn(e,"pages")&&(!e.pages||!Array.isArray(e.pages))||Object.hasOwn(e,"extensions")&&(!e.extensions||!Array.isArray(e.extensions))||Object.hasOwn(e,"modals")&&(!e.modals||!Array.isArray(e.modals))||Object.hasOwn(e,"workspaces2")&&(!e.workspaces2||!Array.isArray(e.workspaces2))||Object.hasOwn(e,"workspaceWindows2")&&(!e.workspaceWindows2||!Array.isArray(e.workspaceWindows2))||Object.hasOwn(e,"workspaceGroups2")&&(!e.workspaceGroups2||!Array.isArray(e.workspaceGroups2)))}function aK(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&&az(t))}let aG="openmrs-routes:",aZ="openmrs-routes:change",aY=!1,aq=null,aJ=null;async function aX(){return aJ??(aJ=aQ().then(({map:e,complete:t})=>(t||(aJ=null),e))),aJ}async function aQ(){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&&aK(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:a0(t),complete:r}}function a0(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 a1(){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(aG)){let e=localStorage.getItem(r);e&&t.push({moduleName:r.slice(aG.length),raw:e})}}for(let r of(await Promise.allSettled(t.map(async({moduleName:e,raw:t})=>{let r=JSON.parse(t);if(az(r))return{moduleName:e,routes:r};if("string"==typeof r&&r.startsWith("http")){let t=await fetch(r),n=await t.json();if(az(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 a4(){let e=await aX();return aY?a0([e,aq??await a1()]):e}async function a2(){return aX()}async function a3(){return aY?a0([await aX(),await a1()]):aX()}function a6(){if(!aY)return{};let e={};try{for(let t=0;t<localStorage.length;t++){let r=localStorage.key(t);if(r?.startsWith(aG)){let t=localStorage.getItem(r);t&&(e[r.slice(aG.length)]=t)}}}catch(e){console.warn("[route-maps] Failed to read route overrides from localStorage",e)}return e}function a5(e,t){if(!aY)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{if("string"==typeof t)if(t.startsWith("http"))localStorage.setItem(aG+e,JSON.stringify(t));else{let r=JSON.parse(t);if(!az(r))return void console.error(`The supplied routes for ${e} is not a valid OpenmrsAppRoutes object`,t);localStorage.setItem(aG+e,JSON.stringify(r))}else if(t instanceof URL)localStorage.setItem(aG+e,JSON.stringify(t.toString()));else{if(!az(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(aG+e,JSON.stringify(t))}window.dispatchEvent(new CustomEvent(aZ))}catch(e){console.warn("[route-maps] Failed to write route override to localStorage",e)}}function a9(e){if(!aY)return void console.warn("[Security] Route overrides are disabled outside development mode.");try{localStorage.removeItem(aG+e),window.dispatchEvent(new CustomEvent(aZ))}catch(e){console.warn("[route-maps] Failed to remove route override from localStorage",e)}}function a8(){if(!aY)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(aG)&&e.push(r)}e.forEach(e=>localStorage.removeItem(e)),window.dispatchEvent(new CustomEvent(aZ))}catch(e){console.warn("[route-maps] Failed to clear route overrides from localStorage",e)}}let a7=null;function oe(){return a7||(a7=(aY="development"===window.spaEnv)?a1().then(e=>{aq=e}):Promise.resolve())}let ot=`${nQ}/attachment`;function or(e,t){return n2(`${ot}/${e}`,{signal:t.signal})}function on(e,t,r,n){return n2(oa(e,t,n),{signal:r.signal})}function oa(e,t,r){return r?`${ot}?patient=${e}&encounter=${r}`:`${ot}?patient=${e}&includeEncounterless=${t}`}async function oo(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)),n2(`${ot}`,{method:"POST",body:n})}function oi(e,t){return n2(`${ot}/${e}`,{method:"DELETE",signal:t.signal})}async function os(e,t){return e?(await n2(`${n0}/Patient/${e}`,t)).data:null}function ol(e,t){let r=new CustomEvent(`openmrs:${e}`,{detail:t??void 0,cancelable:!0,bubbles:!0});return window.dispatchEvent(r)}function ou(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 oc(e){return{uuid:e.uuid,display:e.display}}function od(e=null,t=null){let r=new URLSearchParams;e&&r.set("tag",e),t&&r.set("q",t);let n=r.toString();return n2(`${nQ}/location${n?"?"+n:""}`).then(e=>e.data.results.map(oc))}function om(e){return{uuid:e.uuid,display:e.display,name:e.name}}let op=`${nQ}/visittype`;function of(e=op){return n2(e).then(e=>e.data.results.map(om))}var oh=((J={}).NEWVISIT="startVisit",J.EDITVISIT="editVisit",J.LOADING="loadingVisit",J),og=((X={}).NOTSTARTED="notStarted",X.ONGOING="ongoing",X);let oy="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))",ov=function(){try{return JSON.parse(sessionStorage.getItem("openmrs:visitStoreState")||"null")}catch(e){return null}}()||{patientUuid:null,manuallySetVisitUuid:null};function ob(){return W("visit",ov)}function ow(e,t){ob().setState({patientUuid:e,manuallySetVisitUuid:t})}function ox(e,t){return n2(`${nQ}/visit`,{signal:t.signal,method:"POST",headers:{"Content-type":"application/json"},body:e})}function oE(e,t,r){return n2(`${nQ}/visit/${e}`,{signal:r.signal,method:"POST",headers:{"Content-type":"application/json"},body:t})}function oD(e,t,r){return n2(`${nQ}/visit?patient=${e}&v=${r??oy}`,{signal:t.signal,method:"GET",headers:{"Content-type":"application/json"}})}ob().subscribe(e=>{var t;t=e,sessionStorage.setItem("openmrs:visitStoreState",JSON.stringify(t))});class oS{static get version(){return"1.4.0"}static toString(){return"JavaScript Expression Parser (JSEP) v"+oS.version}static addUnaryOp(e){return oS.max_unop_len=Math.max(e.length,oS.max_unop_len),oS.unary_ops[e]=1,oS}static addBinaryOp(e,t,r){return oS.max_binop_len=Math.max(e.length,oS.max_binop_len),oS.binary_ops[e]=t,r?oS.right_associative.add(e):oS.right_associative.delete(e),oS}static addIdentifierChar(e){return oS.additional_identifier_chars.add(e),oS}static addLiteral(e,t){return oS.literals[e]=t,oS}static removeUnaryOp(e){return delete oS.unary_ops[e],e.length===oS.max_unop_len&&(oS.max_unop_len=oS.getMaxKeyLen(oS.unary_ops)),oS}static removeAllUnaryOps(){return oS.unary_ops={},oS.max_unop_len=0,oS}static removeIdentifierChar(e){return oS.additional_identifier_chars.delete(e),oS}static removeBinaryOp(e){return delete oS.binary_ops[e],e.length===oS.max_binop_len&&(oS.max_binop_len=oS.getMaxKeyLen(oS.binary_ops)),oS.right_associative.delete(e),oS}static removeAllBinaryOps(){return oS.binary_ops={},oS.max_binop_len=0,oS}static removeLiteral(e){return delete oS.literals[e],oS}static removeAllLiterals(){return oS.literals={},oS}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 oS(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 oS.binary_ops[e]||0}static isIdentifierStart(e){return e>=65&&e<=90||e>=97&&e<=122||e>=128&&!oS.binary_ops[String.fromCharCode(e)]||oS.additional_identifier_chars.has(String.fromCharCode(e))}static isIdentifierPart(e){return oS.isIdentifierStart(e)||oS.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(oS.hooks[e]){let r={context:this,node:t};return oS.hooks.run(e,r),r.node}return t}searchHook(e){if(oS.hooks[e]){let t={context:this};return oS.hooks[e].find(function(e){return e.call(t.context,t),t.node}),t.node}}gobbleSpaces(){let e=this.code;for(;e===oS.SPACE_CODE||e===oS.TAB_CODE||e===oS.LF_CODE||e===oS.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:oS.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)===oS.SEMCOL_CODE||r===oS.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,oS.max_binop_len),t=e.length;for(;t>0;){if(oS.binary_ops.hasOwnProperty(e)&&(!oS.isIdentifierStart(this.code)||this.index+e.length<this.expr.length&&!oS.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:oS.binaryPrecedence(t),right_a:oS.right_associative.has(t)},(i=this.gobbleToken())||this.throwError("Expected expression after "+t),n=[o,a,i];t=this.gobbleBinaryOp();){if(0===(r=oS.binaryPrecedence(t))){this.index-=t.length;break}a={value:t,prec:r,right_a:oS.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:oS.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:oS.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,oS.isDecimalDigit(e)||e===oS.PERIOD_CODE)return this.gobbleNumericLiteral();if(e===oS.SQUOTE_CODE||e===oS.DQUOTE_CODE)n=this.gobbleStringLiteral();else if(e===oS.OBRACK_CODE)n=this.gobbleArray();else{for(r=(t=this.expr.substr(this.index,oS.max_unop_len)).length;r>0;){if(oS.unary_ops.hasOwnProperty(t)&&(!oS.isIdentifierStart(this.code)||this.index+t.length<this.expr.length&&!oS.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:oS.UNARY_EXP,operator:t,argument:e,prefix:!0})}t=t.substr(0,--r)}oS.isIdentifierStart(e)?(n=this.gobbleIdentifier(),oS.literals.hasOwnProperty(n.name)?n={type:oS.LITERAL,value:oS.literals[n.name],raw:n.name}:n.name===oS.this_str&&(n={type:oS.THIS_EXP})):e===oS.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===oS.PERIOD_CODE||t===oS.OBRACK_CODE||t===oS.OPAREN_CODE||t===oS.QUMARK_CODE;){let r;if(t===oS.QUMARK_CODE){if(this.expr.charCodeAt(this.index+1)!==oS.PERIOD_CODE)break;r=!0,this.index+=2,this.gobbleSpaces(),t=this.code}this.index++,t===oS.OBRACK_CODE?((e={type:oS.MEMBER_EXP,computed:!0,object:e,property:this.gobbleExpression()}).property||this.throwError('Unexpected "'+this.char+'"'),this.gobbleSpaces(),(t=this.code)!==oS.CBRACK_CODE&&this.throwError("Unclosed ["),this.index++):t===oS.OPAREN_CODE?e={type:oS.CALL_EXP,arguments:this.gobbleArguments(oS.CPAREN_CODE),callee:e}:(t===oS.PERIOD_CODE||r)&&(r&&this.index--,this.gobbleSpaces(),e={type:oS.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(;oS.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);if(this.code===oS.PERIOD_CODE)for(e+=this.expr.charAt(this.index++);oS.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++));oS.isDecimalDigit(this.code);)e+=this.expr.charAt(this.index++);oS.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+e+this.char+")")}return r=this.code,oS.isIdentifierStart(r)?this.throwError("Variable names cannot start with a number ("+e+this.char+")"):(r===oS.PERIOD_CODE||1===e.length&&e.charCodeAt(0)===oS.PERIOD_CODE)&&this.throwError("Unexpected period"),{type:oS.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:oS.LITERAL,value:e,raw:this.expr.substring(t,this.index)}}gobbleIdentifier(){let e=this.code,t=this.index;for(oS.isIdentifierStart(e)?this.index++:this.throwError("Unexpected "+this.char);this.index<this.expr.length;)if(e=this.code,oS.isIdentifierPart(e))this.index++;else break;return{type:oS.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===oS.CPAREN_CODE&&n&&n>=t.length&&this.throwError("Unexpected token "+String.fromCharCode(e));break}if(a===oS.COMMA_CODE){if(this.index++,++n!==t.length){if(e===oS.CPAREN_CODE)this.throwError("Unexpected token ,");else if(e===oS.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!==oS.COMPOUND||this.throwError("Expected comma"),t.push(e)}}return r||this.throwError("Expected "+String.fromCharCode(e)),t}gobbleGroup(){this.index++;let e=this.gobbleExpressions(oS.CPAREN_CODE);if(this.code===oS.CPAREN_CODE)return(this.index++,1===e.length)?e[0]:!!e.length&&{type:oS.SEQUENCE_EXP,expressions:e};this.throwError("Unclosed (")}gobbleArray(){return this.index++,{type:oS.ARRAY_EXP,elements:this.gobbleArguments(oS.CBRACK_CODE)}}}Object.assign(oS,{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)})}}(oS),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"}),oS.max_unop_len=oS.getMaxKeyLen(oS.unary_ops),oS.max_binop_len=oS.getMaxKeyLen(oS.binary_ops);let o_=e=>new oS(e).parse(),oC=Object.getOwnPropertyNames(class{});Object.getOwnPropertyNames(oS).filter(e=>!oC.includes(e)&&void 0===o_[e]).forEach(e=>{o_[e]=oS[e]}),o_.Jsep=oS,o_.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 ok="ArrowFunctionExpression",oP={Array,Boolean,Symbol,Infinity,NaN,Math,Number,BigInt,String,RegExp,JSON,isFinite,isNaN,parseFloat,parseInt,decodeURI,encodeURI,encodeURIComponent,Object:{__proto__:void 0,assign:Object.assign.bind(null),fromEntries:Object.fromEntries.bind(null),hasOwn:Object.hasOwn.bind(null),keys:Object.keys.bind(null),is:Object.is.bind(null),values:Object.values.bind(null)}},oR={...oP,Promise};function oT(e,t={}){return oM(e,t,oF)}async function o$(e,t={}){return oj(e,t,oF)}function oN(e,t={}){return oM(e,t,oB)}function oO(e,t={}){return oj(e,t,oB)}function oI(e,t={}){return oM(e,t,oV)}function oA(e,t={}){return oj(e,t,oV)}function oM(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=oK(t,oP),a=oU("string"==typeof e?o_(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 oj(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=oK(t,oR);return Promise.resolve(oU("string"==typeof e?o_(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 oL(e){return o_(e)}function oF(e){return"string"==typeof e||"number"==typeof e||"boolean"==typeof e||null==e||e instanceof Date}function oB(e){return"boolean"==typeof e}function oV(e){return"number"==typeof e}function oU(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=oU(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 oU(v.left,b)&&oU(v.right,b);case"||":return oU(v.left,b)||oU(v.right,b);case"??":return oU(v.left,b)??oU(v.right,b)}let w=oU(v.left,b),x=oU(v.right,b);switch(v.operator){case"+":return w+x;case"-":return w-x;case"*":return w*x;case"/":return w/x;case"%":return w%x;case"**":return w**x;case"==":return w==x;case"===":return w===x;case"!=":return w!=x;case"!==":return w!==x;case">":return w>x;case">=":return w>=x;case"<":return w<x;case"<=":return w<=x;case"in":return w in x;default:throw`Expression evaluator does not support operator '${v.operator}' operator`}case"ConditionalExpression":return r=e,n=t,oU(r.test,n)?oU(r.consequent,n):oU(r.alternate,n);case"CallExpression":return oY(oH(e,t));case"ArrowFunctionExpression":let E;return a=e,o=t,E=a.params?.map(e=>{if("Identifier"===e.type)return e.name;throw`Cannot handle parameter of type ${e.type}`})??[],(function(...e){if(e.length<E.length)throw`Required argument(s) ${E.slice(e.length,-1).join(", ")} were not provided`;let t=Object.fromEntries(E.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 oU(a.body,o.addVariables(t))}).bind(null);case"MemberExpression":return oY(oz(e,t));case"ArrayExpression":return i=e,s=t,i.elements?.map(oq(s));case"SequenceExpression":let D;return l=e,u=t,(D=l.expressions.map(oq(u)))[D.length-1];case"NewExpression":var S=e,_=t;if(S.callee&&"Identifier"===S.callee.type){let e=S.arguments?.map(oq(_));switch(S.callee.name){case"Date":return new Date(...e);case"RegExp":return new RegExp(...e);default:throw`Cannot instantiate object of type ${S.callee.name}`}}if(S.callee)throw"new must be called with either Date or RegExp";throw'Could not handle "new" without a specified class';case"Literal":return e.value;case"Identifier":return c=e,d=t,(oJ(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(oq(p))??[],(k=m.quasis?.map(oq(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 oW(e,t){switch(e.type){case"Literal":return e.value;case"Identifier":return e.name;case"MemberExpression":return oW(e.property,t);default:throw`VisitExpressionName does not support expression of type '${e.type}'`}}function oH(e,t){let r=oZ(e.callee,t);if(r===oG||e.optional&&null==r)return oG;let n=e.arguments?.map(oq(t));if(r){if("function"!=typeof r)throw`${o0(e.callee)} is not a function`}else throw`No function named ${o0(e.callee)} is defined in this context`;return r(...n)}function oz(e,t){let r=oZ(e.object,t);if(r===oG||e.optional&&null==r)return oG;if(null===r)throw TypeError(`TypeError: cannot read properties of null (reading '${oQ(e.property,t)}')`);if(void 0===r)switch(e.object.type){case"Identifier":{let r=oW(e.object,t);throw ReferenceError(`ReferenceError: ${r} is not defined`)}case"MemberExpression":throw TypeError(`TypeError: cannot read properties of undefined (reading '${oQ(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}(oU(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);oJ(n),function(e,t){if(oX.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 oK(e,t){let r={variables:{...e},globals:{...t},addVariables(e){return this.variables={...this.variables,...e},this}};return r.addVariables.bind(r),r}o_.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:ok,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=ok,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)})}}),o_.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"}})}}),o_.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)})}}),o_.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")}})}}),o_.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 :")}})}}),o_.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})}}),o_.addBinaryOp("in",7),o_.addBinaryOp("??",1);let oG=Symbol("optional chain short-circuited");function oZ(e,t){switch(e.type){case"MemberExpression":return oz(e,t);case"CallExpression":return oH(e,t);default:return oU(e,t)}}function oY(e){return e===oG?void 0:e}function oq(e){return function(t){return null===t?null:oU(t,e)}}function oJ(e){if("__proto__"===e||"prototype"===e||"constructor"===e)throw{type:"Illegal property access",message:`Cannot access the ${e} property of objects`}}let oX=new Set(["toString","valueOf","hasOwnProperty"]);function oQ(e,t){try{return oW(e,t)}catch{return"<computed>"}}function o0(e){return e?"MemberExpression"===e.type?e.property?.name:e.name:null}function o1(e){if("string"!=typeof e&&("object"!=typeof e||!e||!("type"in e)))throw`Unknown expression type ${e}. Expressions must either be a string or pre-compiled string.`;let t={globals:{...oR},boundNames:new Set,variables:new Set};return o4("string"==typeof e?o_(e):e,t),[...t.variables]}function o4(e,t){switch(e.type){case"UnaryExpression":return r=e,n=t,void o4(r.argument,n);case"BinaryExpression":return a=e,o=t,void(o4(a.left,o),o4(a.right,o));case"ConditionalExpression":return i=e,s=t,void(o4(i.consequent,s),o4(i.test,s),o4(i.alternate,s));case"CallExpression":return l=e,u=t,void(o4(l.callee,u),l.arguments?.map(o2(u)));case"ArrowFunctionExpression":var r,n,a,o,i,s,l,u,c,d,m,p,f,h,g,y,v,b,w,x,E=e,D=t;let S=new Set(D.boundNames);for(let e of E.params??[])e?.type==="Identifier"&&S.add(e.name);o4(E.body,{...D,boundNames:S});return;case"MemberExpression":return c=e,d=t,void(o4(c.object,d),c.computed&&o4(c.property,d));case"ArrayExpression":return m=e,p=t,void m.elements?.map(o2(p));case"SequenceExpression":return f=e,h=t,void f.expressions?.map(o2(h));case"NewExpression":return g=e,y=t,void g.arguments?.map(o2(y));case"Literal":case"TemplateElement":return;case"Identifier":return v=e,b=t,void(v.name in b.globals||b.boundNames.has(v.name)||b.variables.add(v.name));case"TemplateLiteral":return w=e,x=t,void(w.expressions?.map(o2(x)),w.quasis?.map(o2(x)));default:throw`Expression evaluator does not support expression of type '${e.type}'`}}function o2(e){return function(t){return null===t?null:o4(t,e)}}let o3=W("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 o6(e,t,r){o3.setState(n=>({flags:{...n.flags,[e]:{enabled:n.flags[e]?.enabled??!1,label:t,description:r}}}))}function o5(){let e=o3.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 o9(e){return o3.getState().flags[e].enabled}function o8(e,t){o3.subscribe(r=>{t(r.flags[e].enabled)})}function o7(e,t){o3.setState(r=>({flags:{...r.flags,[e]:{...r.flags[e],enabled:t}}}))}o3.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 ie=e6(function(e,t,r){eY(e,t,r)});let it=B("extensionsInternal",{slots:{},extensions:{}}),ir=B("extensionRenderings",{renderings:new Map}),ia=()=>W("extensionsInternal",{slots:{},extensions:{}}),io=()=>W("extensionRenderings",{renderings:new Map});function ii(e){let t=it.getState(),r=e(t);r!==t&&it.setState(r)}let is=null,il=null;function iu(){let e=ir.getState();return is&&e===il||(is=new Map(e.renderings),il=e,function(e){for(let t of(iw.clear(),e.values()))iE(t,1);ix=!0}(is)),is}function ic(e){il={renderings:e},ir.setState(il,!0)}function id(e){let t=iu();t.has(e.renderingId)||(t.set(e.renderingId,e),iE(e,1),ic(t))}function im(e){let t=iu(),r=t.get(e);r&&(t.delete(e),iE(r,-1),ic(t))}let ip=()=>W("extensions",{slots:{}}),ih=0,ig=new Set;function iy(e){ih++;try{return e()}finally{if(0==--ih&&ig.size>0){let e=Array.from(ig);for(let t of(ig.clear(),e))iv(t)}}}function iv(e){try{e()}catch(t){console.error(`The extension system's '${e.name}' recomputation failed`,t)}}function ib(e){ih>0?ig.add(e):iv(e)}let iw=new Map,ix=!1;function iE(e,t){let r=JSON.stringify([e.slotName,e.extensionId,e.slotModuleName,e.extensionModuleName]),n=iw.get(r);if(!n){if(t<0)return;iw.set(r,{count:1,record:{slotModuleName:e.slotModuleName,extensionModuleName:e.extensionModuleName,slotName:e.slotName,extensionId:e.extensionId}}),ix=!0;return}n.count+=t,n.count<1&&(iw.delete(r),ix=!0)}function iD(){var e,t;if(iu(),!ix)return;ix=!1;let r=Array.from(iw.values(),({record:e})=>e);r.sort(iS),e=tX.getState().mountedExtensions,t=r,e.length===t.length&&e.every((e,r)=>0===iS(e,t[r]))||tX.setState({mountedExtensions:r})}function iS(e,t){return i_(e.slotName,t.slotName)||i_(e.extensionId,t.extensionId)||i_(e.slotModuleName,t.slotModuleName)||i_(e.extensionModuleName,t.extensionModuleName)}function i_(e,t){return e===t?0:e<t?-1:1}iD(),ir.subscribe(()=>ib(iD));let iC=ia(),ik=ip(),iP=t0(),iR=t2(),iT=new Set,i$=!1;function iN(e){if(null===e)iT=null;else if(null!==iT)for(let t of e)iT.add(t);ib(iO)}function iO(){if(!i$){i$=!0;try{for(let e=1;;e++){let t=iT;if(null!==t&&0===t.size)return;iT=new Set;try{!function(e,t,r,n,a,o=null){let i=ik.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}=t4(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}=iC.getState(),i=new Set(n),s=[...t,...r].filter(e=>!i.has(e)),l=iW(a),u=iW(t),c=new Map(s.map(e=>[e,function(e,t,r,n){let a=t.get(e);if(void 0!==a)return a;{if(void 0!==r)return 1e3+r;let t=n.get(e);return void 0!==t?2e3+t:3e3}}(e,l,o[iM(e)]?.order,u)]));return s.sort((e,t)=>c.get(e)-c.get(t))}(r,t.slots[e].attachedIds),s=[];for(let l of i){let{config:i}=t3(n,e,l),u=t6(r,e,l),c=u?ie({},i,u):i,d=iM(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||!aa(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&&e8(d.candidateExtensions,p)?s[n]=d:(s[n]={moduleName:c.moduleName,candidateExtensions:p},l=!0)}(l||Object.keys(i).length!==Object.keys(s).length)&&ik.setState({slots:s})}(iC.getState(),iP.getState(),iR.getState(),o3.getState(),n6.getState(),t)}catch(e){throw iT=null===t||null===iT?null:new Set([...t,...iT]),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{i$=!1}}}function iI(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 iA(e,t){return{moduleName:t,name:e,attachedIds:[]}}function iM(e){let[t]=e.split("#");return t}function ij(e,t){let r=iM(t);return e.extensions[r]}function iL(e){return ij(iC.getState(),e)}iC.subscribe((e,t)=>{iN(e.extensions!==t.extensions?null:iI(e.slots,t.slots))}),iP.subscribe((e,t)=>{iN(iI(e.slots,t.slots))}),iR.subscribe((e,t)=>{iN(iI(e.configs,t.configs))}),o3.subscribe(()=>iN(null)),n6.subscribe(()=>iN(null)),iN(null);let iF=e=>ii(t=>({...t,extensions:{...t.extensions,[e.name]:{...e}}}));function iB(e,t){ii(r=>{let n=r.slots[e];return n?{...r,slots:{...r.slots,[e]:{...n,attachedIds:[...n.attachedIds,t]}}}:{...r,slots:{...r.slots,[e]:{...iA(e),attachedIds:[t]}}}})}function iV(e,t){ii(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 iU(e){ii(t=>{let r=t.slots[e];return r?{...t,slots:{...t.slots,[e]:{...r,attachedIds:[]}}}:t})}function iW(e){let t=new Map;return e.forEach((e,r)=>{t.has(e)||t.set(e,r)}),t}function iH(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!!oN(o,a)}catch(t){return console.error(`Error while evaluating expression '${o}' for ${e.id}`+(n?` in ${n}`:""),t),!1}})}(iz(e),t,n6.getState().session,e)}function iz(e){return ik.getState().slots[e]?.candidateExtensions??[]}let iK=(e,t)=>iC.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=iA(t,e);return{...r,slots:{...r.slots,[t]:{...a}}}}),iG=()=>{iT=null,ii(()=>({slots:{},extensions:{}})),io().setState({renderings:new Map}),ik.setState({slots:{}})},iZ=B("left-nav",{slotName:null,basePath:window.spaBase,mode:"normal"});function iY({name:e,basePath:t,mode:r,componentContext:n,state:a}){iZ.setState({slotName:e,basePath:t,mode:r??"normal",componentContext:n,state:a})}function iq(e){iZ.getState().slotName===e&&iZ.setState(iZ.getInitialState(),!0)}let iJ=B("modalRegistry",{modals:{}});function iX(e){iJ.setState(t=>(t.modals[e.name]=e,t))}function iQ(e){let t=iJ.getState().modals[e];if(!t){let r=iL(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.`),iX(t))}return t}let i0=B("workspace2",{registeredGroupsByName:{},registeredWindowsByName:{},registeredWorkspacesByName:{},openedGroup:null,openedWindows:[],isMostRecentlyOpenedWindowHidden:!1});function i1(e){let{registeredWorkspacesByName:t,registeredWindowsByName:r}=i0.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 i4(e){let{registeredGroupsByName:t,registeredWindowsByName:r}=i0.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 i2(e){let{openedWindows:t}=i0.getState();return t.findIndex(t=>t.openedWorkspaces.find(t=>t.workspaceName===e))}function i3(e,t){if(0==t.length)return;let{registeredGroupsByName:r}=i0.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}}i0.setState({registeredGroupsByName:n})}function i6(e,t){if(0==t.length)return;let{registeredWindowsByName:r}=i0.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}i0.setState({registeredWindowsByName:n})}function i5(e,t){if(0==t.length)return;let{registeredWorkspacesByName:r}=i0.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}i0.setState({registeredWorkspacesByName:n})}let i9=0,i8=null,i7={bootstrap:15e3,mount:15e3,unmount:15e3};function se(e,t){if(e.timeouts)return e;let r=e.name??"parcel",n=Object.fromEntries(Object.keys(i7).filter(t=>e[t]).map(n=>{var a,o;let i,s;return[n,(a=e[n],o=i7[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 st(e,t){var r,n;let a,o,i,s,l,u=await (i8??(i8=new Promise((e,t)=>{(0,r3.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),r3.mountRootParcel))),i8),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=>se(e,r)):se(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 sr(){return sn}function sn(e,t){let r,n=st(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 sa(e,t,r,n,a=e=>e,o={}){let i=iM(n),s=iL(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=i9++,f=`${t}/${n}-${p}`;e.dataset.extensionRenderingId=f;let h=e=>{try{im(f)}catch(t){console.error(e,t)}};try{id({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 st(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 so=r(5399),si=r.n(so);let ss=(0,so.createContext)({moduleName:"",featureName:""});var sl=r(3338);function su({to:e,templateParams:t,onBeforeNavigate:r,children:n,...a}){return(0,so.useEffect)(()=>{a.href&&console.warn(`ConfigurableLink does not support the href prop. Use the 'to' prop instead. The provided href value is '${a.href}'`),a.onClick&&console.warn(`ConfigurableLink does not support the onClick prop. Use the 'onBeforeNavigate' prop instead. The 'to' prop of the offending link is ${e}`)},[]),(0,sl.jsx)("a",{onClick:n=>{0===n.button&&!n.ctrlKey&&!n.shiftKey&&!n.altKey&&!n.metaKey&&(n.preventDefault(),r?.(n),nW({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:nV(e,t),...a,children:n})}let sc=({state:e,children:t,...r})=>{let{extension:n}=(0,so.useContext)(ss),a=(0,so.useRef)(null),o=(0,so.useRef)(Promise.resolve()),i=(0,so.useRef)(!1),s=(0,so.useRef)(!1),l=(0,so.useRef)(e),u=(0,so.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,so.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,so.useCallback)(t=>{t&&!a.current&&!s.current&&n?.extensionSlotName&&n.extensionSlotModuleName&&(s.current=!0,sa(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,so.useEffect)(()=>(i.current=!1,()=>{i.current=!0,u(a.current)}),[]),(0,so.useEffect)(()=>{l.current=e,a.current&&c(a.current,e)},[e]),n?(0,sl.jsx)("div",{ref:d,"data-extension-id":n?.extensionId,style:{position:"relative"},...r}):null};function sd(e){let t=(0,so.useRef)(e);return T(t.current,e)||(t.current=e),t.current}function sm(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 sp=e=>e;function sf(e,t=sp,r){let n=(0,so.useCallback)(t=>e.subscribe(t),[e]),a=(0,so.useCallback)(()=>t(e.getState()),[e,t]),o=(0,so.useSyncExternalStore)(n,a,a),i=(0,so.useMemo)(()=>r?sm(e,r):null,[e,r]);return(0,so.useMemo)(()=>i?{...o,...i}:o,[o,i])}function sh(e,t){return sf(e,sp,t)}function sg(e){return function(t){let r=(0,so.useCallback)(t=>e.subscribe(t),[]),n=(0,so.useCallback)(()=>e.getState(),[]),a=(0,so.useSyncExternalStore)(r,n,n),o=(0,so.useMemo)(()=>t?sm(e,t):null,[t]);return(0,so.useMemo)(()=>o?{...a,...o}:a,[a,o])}}let sy=[];Object.freeze(sy);let sv={candidateExtensions:sy};Object.freeze(sv);let sb=e=>{let t=(0,so.useCallback)(t=>t.slots?.[e]??sv,[e]);return sf(ip(),t)},sw=e=>e.session;function sx(e,t){let{candidateExtensions:r}=sb(e),n=sf(n6,sw),a=sd(t);return(0,so.useMemo)(()=>iH(e,a),[e,a,n,r])}function sE(e,t){let{moduleName:r}=(0,so.useContext)(ss);if(!r)throw Error("ComponentContext has not been provided. This should come from @openmrs/esm-react-utils.");return(0,so.useEffect)(()=>{iK(r,e)},[r,e]),{extensions:sx(e,t),extensionSlotName:e,extensionSlotModuleName:r}}function sD(e){return e}function sS({name:e,extensionSlotName:t,select:r=sD,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,so.useRef)(null),{extensions:u,extensionSlotModuleName:c}=sE(s,a),d=(0,so.useMemo)(()=>r(u),[r,u]),m=(0,so.useMemo)(()=>{if("function"==typeof n&&!si().isValidElement(n))return d.map(e=>n(e,a))},[n,d]);return(0,sl.jsx)("div",{ref:l,"data-extension-slot-name":s,"data-extension-slot-module-name":c,style:{...o,position:"relative"},...i,children:s&&d?.map((e,t)=>(0,sl.jsx)(ss.Provider,{value:{moduleName:c,featureName:"",extension:{extensionId:e.id,extensionSlotName:s,extensionSlotModuleName:c,extensionMeta:e.meta}},children:m?.[t]??("function"!=typeof n?n:null)??(0,sl.jsx)(sc,{state:a})},e.id))})}var s_=r(6442),sC=r.n(s_),sk=r(4229),sP=r.n(sk),sR=r(7807),sT=r(1619),s$=r.n(sT),sN=r(3432);let sO={strictMode:!0,throwErrorsToConsole:!0,disableTranslations:!1},sI=new Map;(0,sN.initCache)(sI);let sA={errorRetryCount:3,fetcher:n2,focusThrottleInterval:18e5,revalidateIfStale:!0,revalidateOnFocus:!1,revalidateOnReconnect:!1,refreshInterval:0,shouldRetryOnError:e=>{if(e instanceof n3){let t=e.response.status;return!!(t>=500)||401===t||403===t||429===t}return!0},provider:()=>sI};function sM(e){if("object"!=typeof e||"string"!=typeof e.featureName||"string"!=typeof e.moduleName)throw Error("Invalid options");let t=Object.assign({},sO,e),r={...sA,...t.swrConfig};return function(e){var n,a,o,i,s;return o=a=class extends(n=si().Component){componentDidCatch(e,r){r&&r.componentStack&&(e.extra=Object.assign(e.extra||{},{componentStack:r.componentStack})),t.throwErrorsToConsole&&setTimeout(()=>{throw e}),this.setState({caughtError:e,caughtErrorInfo:r})}render(){if(this.state.caughtError)return(0,sl.jsx)("div",{children:"An error has occurred. Please try reloading the page."});{let n=(0,sl.jsx)(so.Suspense,{fallback:null,children:(0,sl.jsx)(sT.SWRConfig,{value:r,children:(0,sl.jsx)(ss.Provider,{value:this.state.config,children:t.disableTranslations?(0,sl.jsx)(e,{...this.props}):(0,sl.jsx)(sR.I18nextProvider,{i18n:window.i18next,defaultNS:this.state.config.extension?`${this.state.config.moduleName}___${this.state.config.extension.extensionSlotName}___${this.state.config.extension.extensionId}`:this.state.config.moduleName,children:(0,sl.jsx)(e,{...this.props})})})})});return t.strictMode&&si().StrictMode?(0,sl.jsx)(si().StrictMode,{children:n}):n}}constructor(e){super(e),this.state={caughtError:null,caughtErrorInfo:null,config:{moduleName:t.moduleName,featureName:t.featureName,extension:e._extensionContext}}}},i="displayName",s=`OpenmrsReactComponent(${t.featureName})`,i in o?Object.defineProperty(o,i,{value:s,enumerable:!0,configurable:!0,writable:!0}):o[i]=s,a}}function sj(e,t){return sP()({React:si(),ReactDOMClient:sC(),rootComponent:sM(t)(e)})}function sL(e,t){return()=>e().then(({default:e})=>sj(e,t))}function sF(e,t){return()=>Promise.resolve(sj(e,t))}let sB=sL,sV=I()(()=>({}));U("openmrs-app-context",sV);let sU={};function sW(e,t=e=>e){let r=sV.getState();return e in r?Object.freeze(Object.assign({},t?t(r[e]):r[e])):null}function sH(e,t){sV.setState(r=>(e in r||(r[e]={}),r[e]=t(r[e]),Object.assign({},r)))}function sz(e){return null===e?null:Object.freeze(Object.assign({},e))}let sK=new Map;function sG(e,t){let r=(0,so.useRef)(t??{}),n=(0,so.useRef)(t=>sH(e,t)),a=(0,so.useRef)(Symbol());return(0,so.useEffect)(()=>{let r=t??{},n=a.current;return null===sW(e)?!function(e,t=sU){sV.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===sU?{}: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.`),sH(e,()=>r)),sK.set(e,n),()=>{sK.get(e)===n&&(sV.setState(t=>(e in t&&delete t[e],t)),sK.delete(e))}},[e]),(0,so.useEffect)(()=>{let n=t??{};T(r.current,n)||(sH(e,()=>n),r.current=n)},[t]),n.current}function sZ({namespace:e,value:t}){return sG(e,t),null}let sY=({children:e,value:t,fallback:r})=>t?(0,sl.jsx)(sl.Fragment,{children:e}):r?(0,sl.jsx)(sl.Fragment,{children:r}):null;function sq(){let e=(0,so.useRef)(null);return(!e.current||e.current.signal.aborted)&&(e.current=new AbortController),(0,so.useEffect)(()=>{let t=e.current;return()=>t?.abort()},[]),e.current}function sJ(e,t=e=>e??{}){let[r,n]=(0,so.useState)(()=>{if(sX(e))return;let r=sW(e);if(null!==r)return t?t(r):r});return(0,so.useEffect)(()=>{if(sX(e))throw Error(`The namespace supplied to useAppContext must be a non-empty string, but was "${e}".`)},[e]),(0,so.useEffect)(()=>{var r;let a;return(r=e=>{if(null==e)return void n(void 0);let r=t?t(e):e;n(e=>T(e,r)?e:r)})(sz(a=sW(e))),sV.subscribe(t=>{let n=e in t?t[e]:null;n!==a&&(a=n,r(sz(n)))})},[e,t]),r}function sX(e){return"string"!=typeof e||0===e.trim().length}function sQ(e){let t=sx(e);return(0,so.useMemo)(()=>t.map(e=>e.id),[t])}function s0(e){return sb(e).candidateExtensions}function s1(e,t,r){let{data:n,error:a,mutate:o,isLoading:i,isValidating:s}=s$()(e?oa(e,t,r):null,n2);return(0,so.useMemo)(()=>({isLoading:i,data:n?.data.results??[],error:a,mutate:o,isValidating:s}),[n,a,i,s,o])}function s4(e){(0,so.useEffect)(()=>{if(e){let e=window.getComputedStyle(document.body).overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=e}}},[e])}let s2={},s3=`No ComponentContext has been provided. This should come from "openmrsComponentDecorator".
16
+ Usually this is already applied when using "getAsyncLifecycle" or "getSyncLifecycle".`;function s6(e,t,r){let n=s2[e];if(n)return n;let a=new Promise(e=>{let n=r(t.getState());if(n)return void e(n);let a=t.subscribe(t=>{let n=r(t);n&&(a(),e(n))})});return s2[e]=a,a.then(()=>{s2[e]===a&&delete s2[e]}),a}function s5(e){let{moduleName:t,extension:r}=(0,so.useContext)(ss),n=e?.externalModuleName??t;if(!n&&!r)throw Error(s3);let a=function(e){let t=(0,so.useMemo)(()=>tQ(e),[e]),r=function(e){let[t,r]=(0,so.useState)(()=>{let t=e.getState();return t.loaded&&t.config?t.config:null});return(0,so.useEffect)(()=>e?.subscribe(e=>{e.loaded&&e.config&&r(e.config)}),[e]),t}(t);if(!r)throw s6(e,t,e=>e.loaded?e.config:null);return r}(n),o=function(e){let t=(0,so.useMemo)(t2,[]),r=function(e,t){let[r,n]=(0,so.useState)(t?()=>{let r=t3(e.getState(),t.extensionSlotName,t.extensionId);if(r.loaded&&r.config)return r.config}:null);return(0,so.useEffect)(()=>{if(t)return e.subscribe(e=>{let a=t3(e,t.extensionSlotName,t.extensionId);a.loaded&&a.config&&!e8(a.config,r)&&n(a.config)})},[e,t,r]),r}(t,e);if(!r&&e)throw s6(`${e.extensionSlotName}-${e.extensionId}`,t,t=>{let r=t3(t,e.extensionSlotName,e.extensionId);return r.loaded?r.config:null});return r||{}}(r);return(0,so.useMemo)(()=>e?.externalModuleName&&n===e.externalModuleName?{...a}:{...a,...o},[n,e?.externalModuleName,a,o])}let s9=sx;function s8(e,t=300){let[r,n]=(0,so.useState)(e);return(0,so.useEffect)(()=>{let r=setTimeout(()=>{n(e)},t);return()=>{clearTimeout(r)}},[e,t]),r}var s7=r(3660),le=r.n(s7);let lt=`custom:${[["admissionDecisionConcept","ref"],["admissionEncounterType","ref"],["admissionForm","ref"],["atFacilityVisitType","ref"],["bedAssignmentEncounterType","ref"],["cancelADTRequestEncounterType","ref"],["checkInClerkEncounterRole","ref"],["checkInEncounterType","ref"],["clinicianEncounterRole","ref"],["conceptSourcesForDiagnosisSearch","ref"],["consultEncounterType","ref"],["consultFreeTextCommentsConcept","ref"],["denyAdmissionConcept","ref"],["diagnosisMetadata","ref"],["diagnosisSets","ref"],["dischargeForm","ref"],["dispositionDescriptor","ref"],["dispositions","ref"],["emrApiConceptSource","ref"],["exitFromInpatientEncounterType","ref"],["extraPatientIdentifierTypes","ref"],["fullPrivilegeLevel","ref"],["highPrivilegeLevel","ref"],["identifierTypesToSearch","ref"],["inpatientNoteEncounterType","ref"],["lastViewedPatientSizeLimit","ref"],["metadataSourceName","ref"],["motherChildRelationshipType","ref"],["narrowerThanConceptMapType","ref"],["nonDiagnosisConceptSets","ref"],["orderingProviderEncounterRole","ref"],["patientDiedConcept","ref"],["personImageDirectory","ref"],["primaryIdentifierType","ref"],["sameAsConceptMapType","ref"],["suppressedDiagnosisConcepts","ref"],["supportsAdmissionLocationTag","(uuid,display,name,links)"],["supportsLoginLocationTag","(uuid,display,name,links)"],["supportsTransferLocationTag","(uuid,display,name,links)"],["supportsVisitsLocationTag","(uuid,display,name,links)"],["telephoneAttributeType","ref"],["testPatientPersonAttributeType","ref"],["transferForm","ref"],["transferRequestEncounterType","ref"],["transferWithinHospitalEncounterType","ref"],["unknownCauseOfDeathConcept","ref"],["unknownLocation","ref"],["unknownPatientPersonAttributeType","ref"],["unknownProvider","ref"],["visitAssignmentHandlerAdjustEncounterTimeOfDayIfNecessary","ref"],["visitExpireHours","ref"],["visitNoteEncounterType","ref"]].map(([e,t])=>`${e}:${t}`).join(",")}`;function lr(){let e=`${nQ}/emrapi/configuration?v=${lt}`,t=le()(e,n2);return(0,so.useMemo)(()=>({emrConfiguration:t.data?.data,isLoadingEmrConfiguration:t.isLoading,mutateEmrConfiguration:t.mutate,errorFetchingEmrConfiguration:t.error}),[t])}function ln(){return(0,so.useContext)(ss).extension}let la=sg(ia());function lo(e){let t=sx(e);return(0,so.useMemo)(()=>Object.fromEntries(t.map(e=>[e.name,e.meta])),[t])}let li=sg(ip());function ls(e){let{flags:t}=sf(o3);return t[e]?.enabled??!1}function ll(){let[,e]=(0,so.useState)(0);return(0,so.useCallback)(()=>{e(e=>e+1)},[])}function lu(e,t,r={}){return ld(e,t,lc,r)}let lc={getPaginatedUrl:(e,t,r)=>{if(!e)return null;{let n=new URL(n4(e.toString()),window.location.toString());return n.searchParams.set("limit",""+t),n.searchParams.set("startIndex",""+r),n.searchParams.set("totalCount","true"),n.toString()}},getNextUrl:e=>{let t=e?.links?.find(e=>"next"==e.rel)?.uri;if(!t)return null;{let e=new URL(t);return e.host=window.location.host,e.protocol=window.location.protocol,e.toString()}},getTotalCount:e=>e?.totalCount??NaN,getCurrentPageSize:e=>e?.results?.length??NaN,getData:e=>e?.results};function ld(e,t,r,n={}){let{getPaginatedUrl:a,getTotalCount:o,getCurrentPageSize:i,getData:s}=r,{immutable:l,swrConfig:u}=n,c=n.fetcher??n2,[d,m]=(0,so.useState)(1),p=(0,so.useRef)(NaN),f=(0,so.useRef)(NaN),h=(0,so.useRef)(d),g=(0,so.useRef)(!1),y=(0,so.useRef)(!1),v=e?.toString()??"",[b,w]=(0,so.useState)(v);v!==b&&(w(v),m(1),h.current=1,p.current=NaN,f.current=NaN,g.current=!1,y.current=!1);let x=(d-1)*t,E=(0,so.useMemo)(()=>a(e,t,x),[e,t,x]),{data:D,...S}=(l?le():s$())(E,c,u);D?.data&&(p.current=o(D?.data),f.current=i(D?.data),g.current=!0);let _=Math.ceil(p.current/t),C=(0,so.useCallback)(e=>{if(!Number.isInteger(e)||e<1)return void console.warn(`useServerPagination: ignoring goTo(${e}); page must be a positive integer.`);let r=Math.ceil(p.current/t);!g.current||Number.isNaN(r)||e<=r?(h.current=e,m(e)):console.warn("Invalid attempt to go to out of bounds page: "+e)},[t]);(0,so.useEffect)(()=>{if(!g.current)return;if(Number.isNaN(p.current)){y.current||(y.current=!0,console.warn(`useServerPagination: ${v} returned no total count, so out-of-range pages cannot be detected.`));return}let e=Math.max(1,Math.ceil(p.current/t));d>e&&(console.warn(`Invalid attempt to go to out of bounds page: ${d}; returning to page ${e}.`),h.current=e,m(e))},[d,t,v,D]);let k=(0,so.useCallback)(()=>{C(h.current+1)},[C]),P=(0,so.useCallback)(()=>{C(h.current-1)},[C]);return{data:s(D?.data),totalPages:_,totalCount:p.current,currentPage:d,currentPageSize:f.current,paginated:_>1,showNextButton:d<_,showPreviousButton:d>1,goTo:C,goToNext:k,goToPrevious:P,...S}}function lm(e,t,r={}){return ld(e,t,lp(),r)}function lp(){return{getPaginatedUrl:(e,t,r)=>{if(!e)return null;{let n=new URL(n4(e.toString()),window.location.toString());return n.searchParams.set("_count",""+t),n.searchParams.set("_getpagesoffset",""+r),n.toString()}},getNextUrl:e=>{let t=e?.link?.find(e=>"next"==e.relation)?.url;if(!t)return null;{let e=new URL(t);return e.host=window.location.host,e.protocol=window.location.protocol,e.toString()}},getTotalCount:e=>e?.total??NaN,getCurrentPageSize:e=>e?.entry?.length??NaN,getData:e=>e?.entry?.map(e=>e.resource)}}var lf=r(682),lh=r.n(lf);function lg(e,t={}){return ly(e,lc,t)}function ly(e,t,r={}){let{swrInfiniteConfig:n,immutable:a}=r,{getNextUrl:o,getTotalCount:i,getData:s}=t,l=r.fetcher??n2,u=(0,so.useCallback)((r,n)=>0==r?e?.toString()??null:t.getNextUrl(n.data),[e]),{data:c,size:d,setSize:m,...p}=lh()(u,l,{...n,...a?{revalidateIfStale:!1,revalidateOnFocus:!1,revalidateOnReconnect:!1}:{}}),f=o(c?.[c.length-1].data),h=i(c?.[0]?.data);return{data:c?.flatMap(e=>s(e.data)),totalCount:h,hasMore:null!=f,loadMore:()=>{m((c?.length??0)+1)},nextUri:f,...p}}function lv(e,t={}){return lb(e,lc,t)}function lb(e,t,r={}){let n=ly(e,t,r),{hasMore:a,error:o,data:i,loadMore:s,isLoading:l,nextUri:u}=n;return((0,so.useEffect)(()=>{a&&!o&&s()},[a,u]),r.partialData)?n:{...n,data:a||o?void 0:i,isLoading:l||a}}function lw(e,t={}){return lb(e,lp(),t)}function lx(e,t={}){return ly(e,lp(),t)}function lE(){let e="tablet";return document.body.classList.forEach(t=>{switch(t){case"omrs-breakpoint-lt-tablet":e="phone";break;case"omrs-breakpoint-gt-small-desktop":e="large-desktop";break;case"omrs-breakpoint-gt-tablet":e="small-desktop"}}),e}function lD(){let[e,t]=(0,so.useState)(lE);return(0,so.useEffect)(()=>{let e=()=>{t(lE())};return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),e}let lS=e=>"small-desktop"===e||"large-desktop"===e;function l_(e){let t=(0,so.useContext)(ss);(0,so.useEffect)(()=>(t&&t.moduleName&&(e.componentContext=t),iY(e),()=>{iq(e.name)}),[t,e])}function lC(){return sf(iZ)}let lk=[];function lP(e=null,t=null){let r=new URLSearchParams;e&&r.set("tag",e),t&&r.set("q",t);let n=r.toString(),{data:a}=lv(`${nQ}/location${n?"?"+n:""}`,{immutable:!0});return a??lk}function lR(e,t=!0){let r=(0,so.useRef)(null);return(0,so.useEffect)(()=>{let n=n=>{t&&r.current&&n.target&&n.target instanceof Node&&(r.current.contains(n.target)||e(n))};return window.addEventListener("mousedown",n),window.addEventListener("touchstart",n),()=>{window.removeEventListener("mousedown",n),window.removeEventListener("touchstart",n)}},[e,t]),r}function lT(e){let t=(0,so.useRef)(null);return(0,so.useEffect)(()=>{let r=new IntersectionObserver(t=>{for(let r of t)if(r.isIntersecting)return void e()},{threshold:1});return t.current&&r.observe(t.current),()=>{t.current&&r.unobserve(t.current)}},[t.current,e]),t}function l$(e,t={}){let{abortController:r,fetchInit:n,url:a,swrConfig:o}=t,i=sq(),s=(0,so.useMemo)(()=>n?.signal??r?.signal??i.signal,[r?.signal,n?.signal,i.signal]),l=(0,so.useCallback)(e=>n2(function(e,t){if(t)return"function"==typeof t?t(e):t;if("string"==typeof e)return e;throw Error(`When using useOpenmrsSWR with a key that is not a string, you must provide a url() function that converts the key to a valid url. The key for this hook is ${e}.`)}(e,a),{...n,signal:s}),[s,n,a]);return s$()(e,l,o)}function lN(e=[],t=10){let[r,n]=(0,so.useState)(1),a=(0,so.useMemo)(()=>"number"==typeof t&&t>0?Math.max(1,Math.ceil(e.length/t)):1,[e.length,t]);r>a&&n(a);let o=Math.min(Math.max(1,r),a),i=(0,so.useMemo)(()=>{let r=(o-1)*t,n=(o+0)*t;return e.slice(r,n)},[e,o,t]),s=(0,so.useCallback)(e=>{!Number.isInteger(e)||e<1?console.warn(`usePagination: ignoring goTo(${e}); page must be a positive integer.`):n(e)},[]),l=(0,so.useCallback)(()=>{n(e=>e+1)},[]),u=(0,so.useCallback)(()=>{n(e=>Math.max(1,e-1))},[]);return(0,so.useMemo)(()=>({results:i,totalPages:a,currentPage:o,paginated:e.length>t,showNextButton:o<a,showPreviousButton:o>1,goTo:s,goToNext:l,goToPrevious:u}),[i,a,e.length,t,o,s,l,u])}function lO(e,t,r,n){return{pageSizes:(0,so.useMemo)(()=>{let r=Math.ceil(t/e);return isNaN(r)&&(r=0),[...Array(r).keys()].map(t=>(t+1)*e)},[e,t]),pageItemsCount:(0,so.useMemo)(()=>e>t?t:e*r>t?e*(r-1)+n:e*r,[e,t,r,n])}}function lI(){let e=/\/patient\/([a-zA-Z0-9\-]+)\/?/.exec(location.pathname);return e&&e[1]}function lA(e){let[t,r]=(0,so.useState)(e??lI()),{data:n,error:a,isValidating:o}=s$()(t?["patient",t]:null,()=>os(t,{}));return(0,so.useEffect)(()=>{let e=()=>{let e=lI();e!==t&&r(e)};return window.addEventListener("single-spa:routing-event",e),()=>window.removeEventListener("single-spa:routing-event",e)},[t]),(0,so.useMemo)(()=>({isLoading:o&&!a&&!n,patient:n,patientUuid:t,error:a}),[o,a,n,t])}function lM(){let e=`${nQ}/metadatamapping/termmapping?v=custom:(metadataUuid)&code=emr.primaryIdentifierType`,{data:t,error:r,isLoading:n}=s$()(e,n2);return(0,so.useMemo)(()=>({primaryIdentifierCode:t?.data?.results[0]?.metadataUuid,isLoading:n,error:r}),[t,r,n])}function lj(e,t,r,n){let a=e?.slotName===t&&e.slotModuleName===r?e.components:null,o=new Map;for(let e of n)o.set(e,a?.get(e)??function(e,t,r){let n=iM(r),a=e=>e.extensions[n]?.meta,o=({state:n})=>{let o=sf(ia(),a),i=(0,so.useMemo)(()=>({moduleName:t,featureName:"",extension:{extensionId:r,extensionSlotName:e,extensionSlotModuleName:t,extensionMeta:o}}),[o]);return(0,sl.jsx)(ss.Provider,{value:i,children:(0,sl.jsx)(sc,{state:n})})};return o.displayName=`RenderableExtension(${r})`,o}(t,r,e));return{slotName:t,slotModuleName:r,components:o}}function lL(e){let{extensions:t,extensionSlotModuleName:r}=sE(e),n=(0,so.useMemo)(()=>new Set(e?t.map(e=>e.id):[]),[e,t]),[a,o]=(0,so.useState)(()=>lj(null,e,r,n)),i=a;return a.slotName===e&&a.slotModuleName===r&&a.components.size===n.size&&[...n].every(e=>a.components.has(e))||o(i=lj(a,e,r,n)),(0,so.useMemo)(()=>e?t.flatMap(e=>{let t=i.components.get(e.id);return t?[t]:[]}):[],[e,t,i])}function lF(){let e=(0,so.useRef)(null),[t,r]=(0,so.useState)(null),n=null;if(!t){if(o){let e=ae().getState();e.loaded&&(n=e.session)}else o=new Promise(t=>{let r=({loaded:r,session:a})=>{r&&(t(a),n=a,e.current&&(e.current(),e.current=null))};r(ae().getState()),n||(e.current=ae().subscribe(r))});if(n)r(n);else throw o}(0,so.useEffect)(()=>(e.current||(e.current=ae().subscribe(({loaded:e,session:t})=>{e&&(n=t,r(t))})),()=>{e.current&&(e.current(),e.current=null)}),[]);let a=t||n;if(!a)if(o)throw console.warn("useSession is in an unexpected state. Attempting to recover."),o;else throw Error("useSession is in an invalid state.");return a}let lB=({privilege:e,fallback:t,children:r})=>{let[n,a]=(0,so.useState)(null);return((0,so.useEffect)(()=>{let e=ae(),t=e.subscribe(({loaded:e,session:t})=>{a(e?t?.user??null:null)}),{loaded:r,session:n}=e.getState();return r&&a(n?.user??null),t},[]),n&&aa(e,n))?(0,sl.jsx)(sl.Fragment,{children:r}):t?(0,sl.jsx)(sl.Fragment,{children:t}):null};var lV=r(222),lU=r.n(lV),lW=r(5602);let lH=new Map;function lz(){for(let e of Array.from(lH.values()))e()}let lK={setVisitContext:(e,t)=>null==t?{manuallySetVisitUuid:null}:{manuallySetVisitUuid:t.uuid,patientUuid:t.patient?.uuid}};function lG(e){let t=(0,so.useId)();return(0,so.useEffect)(()=>{if(e)return lH.set(t,e),()=>{lH.delete(t)}},[t,e]),{...sh(ob(),lK),mutateVisit:lz}}function lZ(e,t=oy){let r=(0,so.useRef)(void 0),{patientUuid:n,manuallySetVisitUuid:a,setVisitContext:o}=lG((0,so.useCallback)(()=>r.current?.(),[])),i=e&&n==e?a:null,s=`?patient=${e}&v=${t}&includeInactive=false`,l=`/${i}?v=${t}`,{data:u,error:c,mutate:d,isValidating:m}=s$()(e?`${nQ}/visit${s}`:null,n2),{data:p,error:f,mutate:h,isValidating:g}=s$()(e&&i?`${nQ}/visit${l}`:null,n2),y=(0,so.useMemo)(()=>u?.data.results.find(e=>null===e.stopDatetime)??null,[u]),v=(0,so.useMemo)(()=>i&&p?p.data:null,[p,i]),b=(0,so.useRef)(null);(0,so.useEffect)(()=>{!m&&y&&n===e&&null===a&&o(y),g||(b.current&&v&&b.current.uuid===v.uuid&&!b.current.stopDatetime&&v.stopDatetime&&o(null),b.current=v)},[v,a,y,m,g,n]);let w=(0,so.useCallback)(()=>{d(),h()},[d,h]);(0,so.useEffect)(()=>{r.current=w},[w]);let x=!!(!u||i&&!p),E=!!(i?f:c);return{error:c||f,mutate:w,isValidating:m||g,activeVisit:y,currentVisit:v,currentVisitIsRetrospective:!!i,isLoading:x&&!E}}lU().extend(lW);let lY=[];function lq(){let{data:e}=le()(op,of);return e??lY}let lJ=new Map;async function lX(e,t){let r=t.indexOf("#"),n=r>=0,a=n?t.substring(0,r):e,o=n?t.substring(r+1):t,i=await aV(a);return i&&Object.hasOwn(i,o)&&"function"==typeof i[o]?l0(a,i).then(()=>i[o]()):(i?i&&Object.hasOwn(i,o)?console.warn(`The export ${t}, defined in ${e}'s routes.json, is not a function`):console.warn(`${a} does not define a component called "${o}", referenced in ${e}'s routes.json. This cannot be loaded.`):console.warn(`Unknown app ${a} for ${t} defined in ${e}'s routes.json`),lQ)}let lQ={bootstrap:()=>Promise.resolve(),mount:()=>Promise.resolve(),unmount:()=>Promise.resolve()};async function l0(e,t){if(e in lJ)await lJ[e];else{let r=t??await aV(e);await (lJ[e]=new Promise((t,n)=>{if(Object.hasOwn(r,"startupApp")){let a=r.startupApp;if("function"==typeof a)return Promise.resolve(a()).then(()=>{rv(e),t(null)}).catch(n)}rv(e),t(null)}))}}function l1(e,t){let r=t.name;if(!r)return void console.error(`An extension definition in ${e} is missing an name and thus cannot be
17
17
  registered. To fix this, ensure that you define the "name" field inside the
18
18
  extension definition.`,t);t.slots&&t.slot&&console.warn(`The extension ${r} from ${e} declares both a 'slots' property and
19
19
  a 'slot' property. Only the 'slots' property will be honored.`);let n=t.slots?t.slots:t.slot?[t.slot]:[];if(!t.component)return void console.error(`The extension ${r} from ${e} is missing a 'component' entry and thus cannot be registered.
@@ -36,4 +36,4 @@ To fix this, ensure that you define the "component" field inside the page defini
36
36
  * {
37
37
  overscroll-behavior: contain;
38
38
  }
39
- }`.trim(),document.head.prepend(n),o=HTMLElement.prototype.focus,HTMLElement.prototype.focus=function(e){let t=((e=document)=>e.activeElement)(),r=null!=t&&yV(t);o.call(this,{...e,preventScroll:!0}),e&&e.preventScroll||yK(this,r)},i=c3(yz(document,"touchstart",t=>{let n=dA(t);e=fH(n)?n:fz(n,!0),r=!1;let a=n.ownerDocument.defaultView.getSelection();a&&!a.isCollapsed&&a.containsNode(n,!0)&&(r=!0),t.composedPath().some(e=>e instanceof HTMLInputElement&&"range"===e.type)&&(r=!0),"selectionStart"in n&&"selectionEnd"in n&&n.selectionStart<n.selectionEnd&&n.ownerDocument.activeElement===n&&(r=!0)},{passive:!1,capture:!0}),yz(document,"touchmove",t=>{if(2!==t.touches.length&&!r){if(!e||e===document.documentElement||e===document.body)return void t.preventDefault();e.scrollHeight===e.clientHeight&&e.scrollWidth===e.clientWidth&&t.preventDefault()}},{passive:!1,capture:!0}),yz(document,"blur",e=>{let t=dA(e),r=e.relatedTarget;if(r&&yV(r))r.focus({preventScroll:!0}),yK(r,yV(t));else if(!r){let e=t.parentElement?.closest("[tabindex]");e?.focus({preventScroll:!0})}},!0)),()=>{t(),i(),n.remove(),HTMLElement.prototype.focus=o}):c3((s=window.innerWidth-document.documentElement.clientWidth)>0&&("scrollbarGutter"in document.documentElement.style?yH(document.documentElement,"scrollbarGutter","stable"):yH(document.documentElement,"paddingRight",`${s}px`)),yH(document.documentElement,"overflow","hidden"))),()=>{0==--yW&&u()}}},[t])}({isDisabled:o||!t.isOpen}),(0,so.useEffect)(()=>{if(t.isOpen&&n.current)if(o){var e,r,i=a?.current??n.current;let t=yh[yh.length-1];return t&&!t.visibleNodes.has(i)?(t.visibleNodes.add(i),()=>{t.visibleNodes.delete(i)}):void 0}else{let t,o,i,s,l,u,c,d,m,p,f;return e=[a?.current??n.current],o=(r={shouldUseInert:!0})instanceof(t=dO(e?.[0])).Element?{root:r}:r,i=o?.root??document.body,s=o?.shouldUseInert&&yp,l=new Set(e),u=new Set,c=(e,r)=>{s&&e instanceof t.HTMLElement?e.inert=r:r?e.setAttribute("aria-hidden","true"):(e.removeAttribute("aria-hidden"),e instanceof t.HTMLElement&&(e.inert=!1))},d=e=>{for(let t of e.querySelectorAll("[data-live-announcer], [data-react-aria-top-layer]"))l.add(t);let t=e=>{if(u.has(e)||l.has(e)||e.parentElement&&u.has(e.parentElement)&&"row"!==e.parentElement.getAttribute("role"))return NodeFilter.FILTER_REJECT;for(let t of l)if(dI(e,t))return NodeFilter.FILTER_SKIP;return NodeFilter.FILTER_ACCEPT},r=h5(dN(e),e,NodeFilter.SHOW_ELEMENT,{acceptNode:t}),n=t(e);if(n===NodeFilter.FILTER_ACCEPT&&m(e),n!==NodeFilter.FILTER_REJECT){let e=r.nextNode();for(;null!=e;)m(e),e=r.nextNode()}},m=e=>{let r=yf.get(e)??0;(s&&e instanceof t.HTMLElement?e.inert:"true"===e.getAttribute("aria-hidden"))&&0===r||(0===r&&c(e,!0),u.add(e),yf.set(e,r+1))},yh.length&&yh[yh.length-1].disconnect(),d(i),(p=new MutationObserver(e=>{for(let r of e)if("childList"===r.type&&r.target.isConnected&&![...l,...u].some(e=>dI(e,r.target)))for(let e of r.addedNodes){var t;(e instanceof HTMLElement||e instanceof SVGElement)&&("true"===(t=e).dataset.liveAnnouncer||void 0!==t.dataset.reactAriaTopLayer)?l.add(e):e instanceof Element&&d(e)}})).observe(i,{childList:!0,subtree:!0}),f={visibleNodes:l,hiddenNodes:u,observe(){p.observe(i,{childList:!0,subtree:!0})},disconnect(){p.disconnect()}},yh.push(f),()=>{for(let e of(p.disconnect(),u)){let t=yf.get(e);null!=t&&(1===t?(c(e,!1),yf.delete(e)):yf.set(e,t-1))}f===yh[yh.length-1]?(yh.pop(),yh.length&&yh[yh.length-1].observe()):yh.splice(yh.indexOf(f),1)}}},[o,t.isOpen,n,a]),{popoverProps:dd(d,p),arrowProps:f,underlayProps:m,placement:h,triggerAnchorPoint:g}}({...n,offset:null!=(a=n.offset)?a:8,arrowSize:s,groupRef:m?d:c},e),y=n.popoverRef,v=yq(y,!!g)||n.isEntering||!1,b=df({...n,defaultClassName:"react-aria-Popover",values:{trigger:n.trigger||null,placement:g,isEntering:v,isExiting:t}}),w=!n.isNonModal||"SubmenuTrigger"===n.trigger,[x,E]=(0,so.useState)(!1);c6(()=>{y.current&&E(w&&!y.current.querySelector("[role=dialog]"))},[y,w]),(0,so.useEffect)(()=>{var e;let t,r;x&&y.current&&!y.current.contains(document.activeElement)&&(r=((e=document)=>e.activeElement)(t=dN(e=y.current)),"virtual"===yQ?my(()=>{((e=document)=>e.activeElement)(t)===r&&e.isConnected&&dT(e)}):dT(e))},[x,y]);let D={...p.style,...b.style},S=si().createElement("div",{...dd(dR(n),p),...b,role:x?"dialog":void 0,tabIndex:x?-1:void 0,"aria-label":n["aria-label"],"aria-labelledby":n["aria-labelledby"],ref:y,slot:n.slot||void 0,style:D,dir:n.dir,"data-trigger":n.trigger,"data-placement":g,"data-entering":v||void 0,"data-exiting":t||void 0},!n.isNonModal&&si().createElement(yY,{onDismiss:e.close}),si().createElement(ym.Provider,{value:{...h,placement:g,ref:i}},b.children),si().createElement(yY,{onDismiss:e.close}));return m?si().createElement(yr,{...n,shouldContainFocus:x,isExiting:t,portalContainer:null!=(o=null!=r?r:null==d?void 0:d.current)?o:void 0},S):si().createElement(yr,{...n,shouldContainFocus:x,isExiting:t,portalContainer:r},!n.isNonModal&&e.isOpen&&si().createElement("div",{"data-testid":"underlay",...f,style:{position:"fixed",inset:0}}),si().createElement("div",{ref:c,style:{display:"contents"}},si().createElement(va.Provider,{value:c},S)))}function vs(e){return e?.start!=null&&null!=e.end}let vl=(0,so.createContext)(null),vu=(0,so.createContext)(null),vc=(0,so.createContext)(null),vd=(0,so.createContext)(null),vm=(0,so.forwardRef)(function(e,t){var r,n;[e,t]=dg(e,t,vl);let{validationBehavior:a}=dh(yu)||{},o=null!=(n=null!=(r=e.validationBehavior)?r:a)?n:"native",i=function(e){let t=vr(e),[r,n]=hL(e.value,e.defaultValue||null,e.onChange),[a]=(0,so.useState)(r),o=r||e.placeholderValue||null,[i,s]=gK(o,e.granularity),l=null!=r?r.toDate(s??"UTC"):null,u="hour"===i||"minute"===i||"second"===i,c=e.shouldCloseOnSelect??!0,[d,m]=(0,so.useState)(null),[p,f]=(0,so.useState)(null);if(r&&(d=r,"hour"in r&&(p=r)),o&&!(i in o))throw Error("Invalid granularity "+i+" for value "+o.toString());let h=r?.calendar.identifier==="gregory"&&"BC"===r.era,g=(0,so.useMemo)(()=>({granularity:i,timeZone:s,hideTimeZone:e.hideTimeZone,hourCycle:e.hourCycle,shouldForceLeadingZeros:e.shouldForceLeadingZeros,showEra:h}),[i,e.hourCycle,e.shouldForceLeadingZeros,s,e.hideTimeZone,h]),{minValue:y,maxValue:v,isDateUnavailable:b}=e,w=(0,so.useMemo)(()=>gB(r,y,v,b,g),[r,y,v,b,g]),x=gO({...e,value:r,builtinValidation:w}),E=x.displayValidation.isInvalid,D=e.validationState||(E?"invalid":null),S=(e,t)=>{n("timeZone"in t?t.set(fc(e)):fd(e,t)),m(null),f(null),x.commitValidation()};return{...x,value:r,defaultValue:e.defaultValue??a,setValue:n,dateValue:d,timeValue:p,setDateValue:r=>{let a="function"==typeof c?c():c;u?p||a?S(r,p||gH(e.defaultValue||e.placeholderValue)):m(r):(n(r),x.commitValidation()),a&&t.setOpen(!1)},setTimeValue:e=>{d&&e?S(d,e):f(e)},granularity:i,hasTime:u,...t,setOpen(n){!n&&!r&&d&&u&&S(d,p||gH(e.defaultValue||e.placeholderValue)),t.setOpen(n)},validationState:D,isInvalid:E,formatValue:(e,t)=>l?new pb(e,gW(t,g)).format(l):"",getDateFormatter:(e,t)=>new pb(e,gW({},{...g,...t}))}}({...e,validationBehavior:o}),s=(0,so.useRef)(null),[l,u]=dy(!e["aria-label"]&&!e["aria-labelledby"]),{groupProps:c,labelProps:d,fieldProps:m,buttonProps:p,dialogProps:f,calendarProps:h,descriptionProps:g,errorMessageProps:y,...v}=function(e,t,r){var n;let a=dl(),o=dl(),i=dl(),s=pI((n=gy)&&n.__esModule?n.default:n,"@react-aria/datepicker"),{isInvalid:l,validationErrors:u,validationDetails:c}=t.displayValidation,{labelProps:d,fieldProps:m,descriptionProps:p,errorMessageProps:f}=gw({...e,labelElementType:"span",isInvalid:l,errorMessage:e.errorMessage||u}),h=gv(t,r),g=m["aria-labelledby"]||m.id,{locale:y}=pm(),v=t.formatValue(y,{month:"long"}),b=fJ(v?s.format("selectedDateDescription",{date:v}):""),w=[b["aria-describedby"],m["aria-describedby"]].filter(Boolean).join(" ")||void 0,x=dR(e),E=(0,so.useMemo)(()=>gm(r),[r]),D=(0,so.useRef)(!1),{focusWithinProps:S}=mZ({...e,isDisabled:t.isOpen,onBlurWithin:t=>{dI(document.getElementById(o),t.relatedTarget)||(D.current=!1,e.onBlur?.(t),e.onFocusChange?.(!1))},onFocusWithin:t=>{D.current||(D.current=!0,e.onFocus?.(t),e.onFocusChange?.(!0))}});return{groupProps:dd(x,h,m,b,S,{role:"group","aria-disabled":e.isDisabled||null,"aria-labelledby":g,"aria-describedby":w,onKeyDown(r){!t.isOpen&&e.onKeyDown&&e.onKeyDown(r)},onKeyUp(r){!t.isOpen&&e.onKeyUp&&e.onKeyUp(r)}}),labelProps:{...d,onClick:()=>{E.focusFirst()}},fieldProps:{...m,id:i,[gS]:"presentation","aria-describedby":w,value:t.value,defaultValue:t.defaultValue,onChange:t.setValue,placeholderValue:e.placeholderValue,hideTimeZone:e.hideTimeZone,hourCycle:e.hourCycle,shouldForceLeadingZeros:e.shouldForceLeadingZeros,granularity:e.granularity,isDisabled:e.isDisabled,isReadOnly:e.isReadOnly,isRequired:e.isRequired,validationBehavior:e.validationBehavior,[gN]:t,autoFocus:e.autoFocus,name:e.name,form:e.form},descriptionProps:p,errorMessageProps:f,buttonProps:{...b,id:a,"aria-haspopup":"dialog","aria-label":s.format("calendar"),"aria-labelledby":`${a} ${g}`,"aria-describedby":w,"aria-expanded":t.isOpen,isDisabled:e.isDisabled||e.isReadOnly,onPress:()=>t.setOpen(!0)},dialogProps:{id:o,"aria-labelledby":`${a} ${g}`},calendarProps:{autoFocus:!0,value:t.dateValue,onChange:t.setDateValue,minValue:e.minValue,maxValue:e.maxValue,isDisabled:e.isDisabled,isReadOnly:e.isReadOnly,isDateUnavailable:e.isDateUnavailable,defaultFocusedValue:t.dateValue?void 0:e.placeholderValue,isInvalid:t.isInvalid,errorMessage:"function"==typeof e.errorMessage?e.errorMessage(t.displayValidation):e.errorMessage||t.displayValidation.validationErrors.join(" "),firstDayOfWeek:e.firstDayOfWeek,pageBehavior:e.pageBehavior},isInvalid:l,validationErrors:u,validationDetails:c}}({...dv(e),label:u,validationBehavior:o},i,s),[b,w]=(0,so.useState)(null),x=(0,so.useCallback)(()=>{s.current&&w(s.current.offsetWidth+"px")},[]);yA({ref:s,onResize:x});let{focusProps:E,isFocused:D,isFocusVisible:S}=mY({within:!0}),_=df({...e,values:{state:i,isFocusWithin:D,isFocusVisible:S,isDisabled:e.isDisabled||!1,isInvalid:i.isInvalid,isOpen:i.isOpen},defaultClassName:"react-aria-DatePicker"}),C=dR(e);return delete C.id,si().createElement(dp,{values:[[vc,i],[h4,{...c,ref:s,isInvalid:i.isInvalid}],[g4,m],[m3,{...p,isPressed:i.isOpen}],[yc,{...d,ref:l,elementType:"span"}],[hH,h],[ya,i],[vn,{trigger:"DatePicker",triggerRef:s,placement:"bottom start",style:{"--trigger-width":b}}],[yn,f],[m9,{slots:{description:g,errorMessage:y}}],[yi,v]]},si().createElement("div",{...E,...C,..._,ref:t,slot:e.slot||void 0,"data-focus-within":D||void 0,"data-invalid":i.isInvalid||void 0,"data-focus-visible":S||void 0,"data-disabled":e.isDisabled||void 0,"data-open":i.isOpen||void 0}))}),vp=(0,so.forwardRef)(function(e,t){var r,n;[e,t]=dg(e,t,vu);let{validationBehavior:a}=dh(yu)||{},o=null!=(n=null!=(r=e.validationBehavior)?r:a)?n:"native",i=function(e){let t=vr(e),[r,n]=hL(e.value,e.defaultValue||null,e.onChange),[a]=(0,so.useState)(r),[o,i]=(0,so.useState)(()=>r||{start:null,end:null});null==r&&o.start&&o.end&&i(o={start:null,end:null});let s=r||o,l=e=>{i(s=e||{start:null,end:null}),vs(s)?n(s):n(null)},[u,c]=gK(s?.start||s?.end||e.placeholderValue||null,e.granularity),d="hour"===u||"minute"===u||"second"===u,m=e.shouldCloseOnSelect??!0,[p,f]=(0,so.useState)(null),[h,g]=(0,so.useState)(null);s&&vs(s)&&(p=s,"hour"in s.start&&(h=s));let y=(e,t)=>{l({start:"timeZone"in t.start?t.start.set(fc(e.start)):fd(e.start,t.start),end:"timeZone"in t.end?t.end.set(fc(e.end)):fd(e.end,t.end)}),f(null),g(null),C.commitValidation()},v=r=>{let n="function"==typeof m?m():m;d?vs(r)&&(n||h?.start&&h?.end)?y(r,{start:h?.start||gH(e.placeholderValue),end:h?.end||gH(e.placeholderValue)}):f(r):vs(r)?(l(r),C.commitValidation()):f(r),n&&t.setOpen(!1)},b=e=>{vs(p)&&vs(e)?y(p,e):g(e)},w=s?.start?.calendar.identifier==="gregory"&&"BC"===s.start.era||s?.end?.calendar.identifier==="gregory"&&"BC"===s.end.era,x=(0,so.useMemo)(()=>({granularity:u,timeZone:c,hideTimeZone:e.hideTimeZone,hourCycle:e.hourCycle,shouldForceLeadingZeros:e.shouldForceLeadingZeros,showEra:w}),[u,e.hourCycle,e.shouldForceLeadingZeros,c,e.hideTimeZone,w]),{minValue:E,maxValue:D,isDateUnavailable:S}=e,_=(0,so.useMemo)(()=>{var e;let t;return e=s,t=gj(gB(e?.start??null,E,D,S,x),gB(e?.end??null,E,D,S,x)),e?.end!=null&&null!=e.start&&0>e.end.compare(e.start)&&(t=gj(t,{isInvalid:!0,validationErrors:[(pP.getGlobalDictionaryForPackage("@react-stately/datepicker")||gL).getStringForLocale("rangeReversed",gF())],validationDetails:{...gP,rangeUnderflow:!0,rangeOverflow:!0,valid:!1}})),t},[s,E,D,S,x]),C=gO({...e,value:r,name:(0,so.useMemo)(()=>[e.startName,e.endName].filter(e=>null!=e),[e.startName,e.endName]),builtinValidation:_}),k=C.displayValidation.isInvalid,P=e.validationState||(k?"invalid":null);return{...C,value:s,defaultValue:e.defaultValue??a,setValue:l,dateRange:p,timeRange:h,granularity:u,hasTime:d,setDate(e,t){"start"===e?v({start:t,end:p?.end??null}):v({start:p?.start??null,end:t})},setTime(e,t){"start"===e?b({start:t,end:h?.end??null}):b({start:h?.start??null,end:t})},setDateTime(e,t){"start"===e?l({start:t,end:s?.end??null}):l({start:s?.start??null,end:t})},setDateRange:v,setTimeRange:b,...t,setOpen(r){!r&&!(s?.start&&s?.end)&&vs(p)&&d&&y(p,{start:h?.start||gH(e.placeholderValue),end:h?.end||gH(e.placeholderValue)}),t.setOpen(r)},validationState:P,isInvalid:k,formatValue(t,r){let n;if(!s||!s.start||!s.end)return null;let a="timeZone"in s.start?s.start.timeZone:void 0,o=e.granularity||(s.start&&"minute"in s.start?"minute":"day"),i="timeZone"in s.end?s.end.timeZone:void 0,l=e.granularity||(s.end&&"minute"in s.end?"minute":"day"),u=gW(r,{granularity:o,timeZone:a,hideTimeZone:e.hideTimeZone,hourCycle:e.hourCycle,showEra:"gregory"===s.start.calendar.identifier&&"BC"===s.start.era||"gregory"===s.end.calendar.identifier&&"BC"===s.end.era}),c=s.start.toDate(a||"UTC"),d=s.end.toDate(i||"UTC"),m=new pb(t,u);if(a===i&&o===l&&0!==s.start.compare(s.end)){try{let e=m.formatRangeToParts(c,d),t=-1;for(let r=0;r<e.length;r++){let n=e[r];if("shared"===n.source&&"literal"===n.type)t=r;else if("endRange"===n.source)break}let r="",n="";for(let a=0;a<e.length;a++)a<t?r+=e[a].value:a>t&&(n+=e[a].value);return{start:r,end:n}}catch{}n=m}else n=new pb(t,gW(r,{granularity:l,timeZone:i,hideTimeZone:e.hideTimeZone,hourCycle:e.hourCycle}));return{start:m.format(c),end:n.format(d)}},getDateFormatter:(e,t)=>new pb(e,gW({},{...x,...t}))}}({...e,validationBehavior:o}),s=(0,so.useRef)(null),[l,u]=dy(!e["aria-label"]&&!e["aria-labelledby"]),{groupProps:c,labelProps:d,startFieldProps:m,endFieldProps:p,buttonProps:f,dialogProps:h,calendarProps:g,descriptionProps:y,errorMessageProps:v,...b}=function(e,t,r){var n;let a=pI((n=gy)&&n.__esModule?n.default:n,"@react-aria/datepicker"),{isInvalid:o,validationErrors:i,validationDetails:s}=t.displayValidation,{labelProps:l,fieldProps:u,descriptionProps:c,errorMessageProps:d}=gw({...e,labelElementType:"span",isInvalid:o,errorMessage:e.errorMessage||i}),m=u["aria-labelledby"]||u.id,{locale:p}=pm(),f=t.formatValue(p,{month:"long"}),h=fJ(f?a.format("selectedRangeDescription",{startDate:f.start,endDate:f.end}):""),g={"aria-label":a.format("startDate"),"aria-labelledby":m},y={"aria-label":a.format("endDate"),"aria-labelledby":m},v=dl(),b=dl(),w=gv(t,r),x=[h["aria-describedby"],u["aria-describedby"]].filter(Boolean).join(" ")||void 0,E=(0,so.useMemo)(()=>gm(r,{accept:e=>e.id!==v}),[r,v]),D={[g_]:E,[gS]:"presentation","aria-describedby":x,placeholderValue:e.placeholderValue,hideTimeZone:e.hideTimeZone,hourCycle:e.hourCycle,granularity:e.granularity,shouldForceLeadingZeros:e.shouldForceLeadingZeros,isDisabled:e.isDisabled,isReadOnly:e.isReadOnly,isRequired:e.isRequired,validationBehavior:e.validationBehavior},S=dR(e),_=(0,so.useRef)(!1),{focusWithinProps:C}=mZ({...e,isDisabled:t.isOpen,onBlurWithin:t=>{dI(document.getElementById(b),t.relatedTarget)||(_.current=!1,e.onBlur?.(t),e.onFocusChange?.(!1))},onFocusWithin:t=>{_.current||(_.current=!0,e.onFocus?.(t),e.onFocusChange?.(!0))}}),k=(0,so.useRef)(gT),P=(0,so.useRef)(gT);return{groupProps:dd(S,w,u,h,C,{role:"group","aria-disabled":e.isDisabled||null,"aria-describedby":x,onKeyDown(r){!t.isOpen&&e.onKeyDown&&e.onKeyDown(r)},onKeyUp(r){!t.isOpen&&e.onKeyUp&&e.onKeyUp(r)}}),labelProps:{...l,onClick:()=>{E.focusFirst()}},buttonProps:{...h,id:v,"aria-haspopup":"dialog","aria-label":a.format("calendar"),"aria-labelledby":`${v} ${m}`,"aria-describedby":x,"aria-expanded":t.isOpen,isDisabled:e.isDisabled||e.isReadOnly,onPress:()=>t.setOpen(!0)},dialogProps:{id:b,"aria-labelledby":`${v} ${m}`},startFieldProps:{...g,...D,value:t.value?.start??null,defaultValue:t.defaultValue?.start,onChange:e=>t.setDateTime("start",e),autoFocus:e.autoFocus,name:e.startName,form:e.form,[gN]:{realtimeValidation:t.realtimeValidation,displayValidation:t.displayValidation,updateValidation(e){k.current=e,t.updateValidation(gj(e,P.current))},resetValidation:t.resetValidation,commitValidation:t.commitValidation}},endFieldProps:{...y,...D,value:t.value?.end??null,defaultValue:t.defaultValue?.end,onChange:e=>t.setDateTime("end",e),name:e.endName,form:e.form,[gN]:{realtimeValidation:t.realtimeValidation,displayValidation:t.displayValidation,updateValidation(e){P.current=e,t.updateValidation(gj(k.current,e))},resetValidation:t.resetValidation,commitValidation:t.commitValidation}},descriptionProps:c,errorMessageProps:d,calendarProps:{autoFocus:!0,value:t.dateRange?.start&&t.dateRange.end?t.dateRange:null,onChange:t.setDateRange,minValue:e.minValue,maxValue:e.maxValue,isDisabled:e.isDisabled,isReadOnly:e.isReadOnly,isDateUnavailable:e.isDateUnavailable,allowsNonContiguousRanges:e.allowsNonContiguousRanges,defaultFocusedValue:t.dateRange?void 0:e.placeholderValue,isInvalid:t.isInvalid,errorMessage:"function"==typeof e.errorMessage?e.errorMessage(t.displayValidation):e.errorMessage||t.displayValidation.validationErrors.join(" "),firstDayOfWeek:e.firstDayOfWeek,pageBehavior:e.pageBehavior},isInvalid:o,validationErrors:i,validationDetails:s}}({...dv(e),label:u,validationBehavior:o},i,s),[w,x]=(0,so.useState)(null),E=(0,so.useCallback)(()=>{s.current&&x(s.current.offsetWidth+"px")},[]);yA({ref:s,onResize:E});let{focusProps:D,isFocused:S,isFocusVisible:_}=mY({within:!0}),C=df({...e,values:{state:i,isFocusWithin:S,isFocusVisible:_,isDisabled:e.isDisabled||!1,isInvalid:i.isInvalid,isOpen:i.isOpen},defaultClassName:"react-aria-DateRangePicker"}),k=dR(e);return delete k.id,si().createElement(dp,{values:[[vd,i],[h4,{...c,ref:s,isInvalid:i.isInvalid}],[m3,{...f,isPressed:i.isOpen}],[yc,{...d,ref:l,elementType:"span"}],[hz,g],[ya,i],[vn,{trigger:"DateRangePicker",triggerRef:s,placement:"bottom start",style:{"--trigger-width":w}}],[yn,h],[g4,{slots:{start:m,end:p}}],[m9,{slots:{description:y,errorMessage:v}}],[yi,b]]},si().createElement("div",{...D,...k,...C,ref:t,slot:e.slot||void 0,"data-focus-within":S||void 0,"data-invalid":i.isInvalid||void 0,"data-focus-visible":_||void 0,"data-disabled":e.isDisabled||void 0,"data-open":i.isOpen||void 0}))});function vf(e){return si().createElement(pd,e)}function vh(e,t,r=!1){if(null==e)return r?e:void 0;if("string"==typeof e&&!e)return r?null:void 0;if(e instanceof p8||e instanceof fe||e instanceof ft)return t?fm(e,t):e;{let r=lU()(e).toDate(),n=new p8(r.getFullYear(),r.getMonth()+1,r.getDate());return t?fm(n,t):n}}function vg(e){if(e)return e.toDate(fS())}function vy(e){if("string"==typeof e&&0!==e.trim().length)try{return new Intl.Locale(e.replace(/[_@]/g,"-")).toString()}catch{return}}function vv(e){let t=e??"",r=vy(t);if(!r)return t;try{return new Intl.DisplayNames([r],{type:"language"}).of(r)??t}catch{return t}}function vb(){let e=window.i18next.language,t=vy(e)??e;return"ht"===t&&(t="fr-HT"),t}if("u">typeof navigator){let e=navigator;ee=Array.isArray(e.languages)?e.languages[0]:e.language}else if("u">typeof process){let e=process.env;ee=e.LC_ALL||e.LC_MESSAGES||e.LANG||e.LANGUAGE}var vw=function(e){e=(e=e.replace(/_/g,"-")).replace(/[.:][\w-]*$/,"");try{return new Intl.Locale(e).baseName}catch{return"en-US"}}(ee||"en-US"),vx=class extends Date{invalid=null;isValid(){return!Number.isNaN(this.valueOf())}},vE={};for(let e=1;e<100;e++)vE[(e<=9?"0":"")+e]=e+(e>51?1900:2e3);var vD={arab:1632,arabext:1776,bali:6992,beng:2534,deva:2406,fullwide:65296,gujr:2790,khmr:6112,knda:3302,laoo:3792,limb:6470,mlym:3430,mong:6160,mymr:4160,orya:2918,tamldec:3046,telu:3174,thai:3664,tibt:3872},vS="[1234567890一二三四五六七八九〇\\d]",v_={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,"0":0,"1":1,"2":2,"3":3,"4":4,"5":5,"6":6,"7":7,"8":8,"9":9,〇:0,一:1,二:2,三:3,四:4,五:5,六:6,七:7,八:8,九:9},vC={},vk={"Eastern Daylight Time":-240,"Eastern Standard Time":-300,"Central Daylight Time":-300,"Central Standard Time":-360,"Mountain Daylight Time":-360,"Mountain Standard Time":-420,"Pacific Daylight Time":-420,"Pacific Standard Time":-480,"Coordinated Universal Time":0,ACDT:630,ACST:570,ACT:480,ADT:-180,AEDT:660,AEST:600,AFT:270,AKDT:-480,AKST:-540,AMST:-180,AMT:-240,ART:-180,AST:180,AWDT:540,AWST:480,AZOST:-60,AZT:240,BDT:360,BIOT:360,BIT:-720,BOT:-240,BRST:-120,BRT:-180,BTT:360,CAT:120,CCT:390,CDT:-300,CEDT:120,CEST:120,CET:60,CHADT:825,CHAST:765,CHOT:480,ChST:600,CHUT:600,CIST:-480,CIT:480,CKT:-600,CLST:-180,CLT:-240,COST:-240,COT:-300,CST:-360,CT:480,CVT:-60,CXT:420,DAVT:420,DDUT:600,DFT:60,EASST:-300,EAST:-360,EAT:180,ECT:-300,EDT:-240,EEDT:180,EEST:180,EET:120,EGST:0,EGT:-60,EIT:540,EST:-300,FET:180,FJT:720,FKST:-180,FKT:-240,FNT:-120,GALT:-360,GAMT:-540,GET:240,GFT:-180,GILT:720,GIT:-540,GMT:0,GST:-120,GYT:-240,HADT:-540,HAEC:120,HAST:-600,HKT:480,HMT:300,HOVT:420,HST:-600,IBST:0,ICT:420,IDT:180,IOT:180,IRDT:270,IRKT:480,IRST:210,IST:120,JST:540,KGT:360,KOST:660,KRAT:420,KST:540,LHST:630,LINT:840,MAGT:720,MART:-510,MAWT:300,MDT:-360,MET:60,MEST:120,MHT:720,MIST:660,MIT:-510,MMT:390,MSK:180,MST:-420,MUT:240,MVT:300,MYT:480,NCT:660,NDT:-90,NFT:660,NPT:345,NST:-150,NT:-150,NUT:-660,NZDT:780,NZST:720,OMST:360,ORAT:300,PDT:-420,PET:-300,PETT:720,PGT:600,PHOT:780,PKT:300,PMDT:-120,PMST:-180,PONT:660,PST:-480,PYST:-180,PYT:-240,RET:240,ROTT:-180,SAKT:660,SAMT:240,SAST:120,SBT:660,SCT:240,SGT:480,SLST:330,SRET:660,SRT:-180,SST:480,SYOT:180,TAHT:-600,THA:420,TFT:300,TJT:300,TKT:780,TLT:540,TMT:300,TOT:780,TVT:720,UCT:0,ULAT:480,USZ1:120,UTC:0,UYST:-120,UYT:-180,UZT:300,VET:-240,VLAT:600,VOLT:240,VOST:360,VUT:660,WAKT:720,WAST:120,WAT:60,WEDT:60,WEST:60,WET:0,WIT:420,WST:480,YAKT:540,YEKT:300},vP={zone:vk,year:vE,meridiem:{am:0,pm:12,"a.m.":0,"p.m.":12},month:{january:1,jan:1,february:2,feb:2,march:3,mar:3,april:4,apr:4,may:5,june:6,jun:6,july:7,jul:7,august:8,aug:8,september:9,sep:9,october:10,oct:10,november:11,nov:11,december:12,dec:12},dayname:{sunday:0,sun:0,monday:1,mon:1,tuesday:2,tue:2,wednesday:3,wed:3,thursday:4,thu:4,friday:5,fri:5,saturday:6,sat:6},digit:{}},vR={MONTHNAME:"january|february|march|april|may|june|july|august|september|october|november|december|jan\\.?|feb\\.?|mar\\.?|apr\\.?|may\\.?|jun\\.?|jul\\.?|aug\\.?|sep\\.?|oct\\.?|nov\\.?|dec\\.?",DAYNAME:"sunday|monday|tuesday|wednesday|thursday|friday|saturday|sun\\.?|mon\\.?|tue\\.?|wed\\.?|thu\\.?|fri\\.?|sat\\.?",ZONE:"\\(?(?:"+Object.keys(vk).join("|")+")\\)?",MERIDIEM:"am|pm|a.m.|p.m.",ORDINAL:"st|nd|rd|th|\\.",YEAR:"\\d{4}|\\d{2}",YEAR2:"\\d{2}",YEAR4:"\\d{4}",YEAR6:"-\\d{6}|\\+?\\d{5,6}",MONTH:"1[0-2]|0?[1-9]",MONTH2:"1[0-2]|0[1-9]",DAY:"3[01]|[12]\\d|0?[1-9]",DAY2:"3[01]|[12]\\d|0[1-9]",OFFSET:"(?:GMT)?[\xb1−+-](?:[01]\\d[0-5]\\d|[01]\\d:[0-5]\\d|[01]?\\d)",H24:"[01]\\d|2[0-3]",H12:"0?[1-9]|1[012]",MIN:"[0-5]\\d",SEC:"[0-5]\\d|60",MS:"\\d{9}|\\d{6}|\\d{1,3}",GAP:"[\\s/.,-]{1,}"},vT={...vR,YEAR:"*{4}|*{2}",YEAR4:"*{4}",YEAR6:"-*{6}|\\+?*{5,6}",MONTH:"*{1,2}",MONTH2:"*{2}",DAY:"*{1,2}",DAY2:"*{2}",OFFSET:"(?:GMT)?[\xb1−+-](?:*{4}|*{2}:*{2}|*{1,2})",H24:"*{2}",H12:"*{1,2}",MIN:"*{2}",SEC:"*{2}",MS:"*{9}|*{6}|*{3}"},v$={},vN=class e{locale;lookups;vars;numberingSystem;baseName;dateOptions;static factory(t=vw){return v$[t.toLowerCase()]||(v$[t.toLowerCase()]=new e(t)),v$[t.toLowerCase()]}constructor(e=vw){this.locale=e,this.lookups={...vP},this.vars={...vR};let t=new Intl.NumberFormat(this.locale);this.numberingSystem=t.resolvedOptions().numberingSystem,this.dateOptions=new Intl.DateTimeFormat(this.locale).resolvedOptions(),this.baseName=new Intl.Locale(this.locale).baseName,this.build()}toInt(e){if("number"==typeof e)return e;if("string"!=typeof e)return;if("latn"===this.numberingSystem&&!this.baseName.startsWith("zh")){let t=parseInt(e,10);if(!isNaN(t))return t}let t="";for(let r=0;r<e.length;r++)t+=String(this.lookups.digit[e[r]]);return parseInt(t,10)}millisecondToInt(e){if("number"==typeof e)return e;if("string"!=typeof e)return;let t=e.slice(0,3);return 1===t.length?100*this.toInt(t):2===t.length?10*this.toInt(t):this.toInt(t)}monthNameToInt(e){if("string"!=typeof e)return;let t=e.toLocaleLowerCase(this.locale).replace(/\.$/,"");return this.lookups.month[t]||12}h12ToInt(e,t){if("string"!=typeof e)return;let r=this.lookups.meridiem[t?.toLowerCase()]||0,n=this.toInt(e);return n<12&&12===r&&(n+=12),12===n&&0===r&&(n=0),n}zoneToOffset(e){if("string"==typeof e)return e=e.replace(/[^a-z\s]/gi,""),this.lookups.zone[e]}offsetToMinutes(e){if("string"!=typeof e)return;let t=e.match(/^(?:GMT)?([±−+-])(..?):?(..)?$/);if(t){let[,e,r,n]=t;return("-"===e||"−"===e?-1:1)*(60*this.toInt(r)+this.toInt(n||0))}return 0}build(){"latn"===this.dateOptions.numberingSystem?this.lookups.digit=v_:this.buildNumbers(),/^en/i.test(this.locale)||(this.buildMonthNames(),this.buildDaynames(),/zh/i.test(this.locale)||this.buildMeridiems())}buildNumbers(){let{group:e,lookup:t}=function(e){if(vC[e])return vC[e];if("fullwide"===e||"hanidec"===e)return{group:vS,lookup:{...v_}};let t=vD[e];if(!t)return{group:"\\d",lookup:{...v_}};let r=String.fromCharCode(t),n=String.fromCharCode(t+9),a={};for(let e=0;e<10;e++)a[String.fromCharCode(t+e)]=e;return vC[e]={group:`[${r}-${n}]`,lookup:a},vC[e]}(this.numberingSystem);for(let r in this.lookups.digit=t,vT)vT.hasOwnProperty(r)&&(this.vars[r]=vT[r].replace(/\*/g,e))}buildMonthNames(){let e={},t={};if(/^fi/i.test(this.locale))"tammi|helmi|maalis|huhti|touko|kes\xe4|hein\xe4|elo|syys|loka|marras|joulu".split("|").forEach((r,n)=>{["","k","kuu","kuuta"].forEach((a,o)=>{e[r+a+(o<2?"\\.?":"")]=!0,t[r+a]=n+1})});else{let r=[],n=e=>"month"===e.type;for(let e=0;e<12;e++)r.push(new Date(2017,e,1));for(let a of["full","long","medium"]){let o=Intl.DateTimeFormat(this.locale,{dateStyle:a});for(let i=0;i<12;i++){let s=o.formatToParts(r[i]).find(n).value.toLocaleLowerCase(this.locale);/^\d+$/.test(s)||(/^ko/i.test(this.locale)&&(s+="월"),"medium"===a?(s=s.replace(/\.$/,""),e[`${s}\\.?`]=!0):e[s]=!0,t[s]=i+1)}}let a=Intl.DateTimeFormat(this.locale,{month:"short"});for(let o=0;o<12;o++){let i=a.formatToParts(r[o]).find(n).value.toLocaleLowerCase(this.locale);i=i.replace(/\.$/,""),e[`${i}\\.?`]=!0,t[i]=o+1}}this.vars.MONTHNAME=Object.keys(e).join("|"),this.lookups.month=t}buildDaynames(){let e=[],t=e=>"weekday"===e.type;for(let t=0;t<7;t++)e.push(new Date(2017,0,t+1));let r=[],n={};for(let a of["long","short"]){let o=Intl.DateTimeFormat(this.locale,{weekday:a});for(let i=0;i<7;i++){let s=o.formatToParts(e[i]).find(t).value.toLocaleLowerCase(this.locale);"short"===a?(s=s.replace(/\.$/,""),r.push(`${s}\\.?`)):r.push(s),n[s]=i}}this.vars.DAYNAME=r.join("|"),this.lookups.dayname=n}buildMeridiems(){let e=[new Date(2017,0,1),new Date(2017,0,1,23,0,0)],t=e=>"dayPeriod"===e.type,r=[],n={},a=Intl.DateTimeFormat(this.locale,{timeStyle:"long"});for(let o=0;o<2;o++){let i=a.formatToParts(e[o]).find(t);if(!i)return;let s=i.value.toLocaleLowerCase(this.locale);r.push(s),n[s]=12*o}this.vars.MERIDIEM=r.join("|"),this.lookups.meridiem=n}compile(e){return RegExp(e.replace(/_([A-Z0-9]+)_/g,(e,t)=>{if(!this.vars[t])throw Error(`Template string contains invalid variable _${t}_`);return this.vars[t]}),"i")}},vO=["ee-TG","en-AS","en-CA","en-FM","en-GH","en-GU","en-KE","en-KY","en-MH","en-MP","en-US","en-VI","en-WS","jp-JP","sm-AS","sm-SM"],vI={y:"year",M:"month",d:"day",w:"week",h:"hour",m:"minute",s:"second",ms:"millisecond"},vA=()=>new Date;function vM(e){return function(t){let r={};for(let n=0,a=e.length;n<a;n++){let a=e[n];a&&(r[a]=t[n])}return r}}var vj=class{doneChecker;fallback;patterns;formatter;constructor({doneChecker:e,fallback:t,patterns:r,formatter:n}){this.doneChecker=e,this.fallback=t,this.patterns=r,this.formatter=n}attempt(e){if("string"!=typeof e)return this.fallback(e);let t=e.trim(),r={},n=!1;for(let e of this.patterns){let a=t.match(e.regex);if(!a)continue;n=!0;let o=e.handler(a);if(o){for(let[e,t]of Object.entries(o))e in r||void 0===t||(r[e]=t);if(t=(t=t.slice(0,a.index)+t.slice(a.index+a[0].length+1)).trim(),this.doneChecker(r,t))break}}return n?this.formatter(r):this.fallback(e)}},vL=["year","month","day","hour","minute","second","millisecond","offset"],vF={};function vB(e,t){return""===t||/^\s+$/.test(t)||"year"in e&&("month"in e||"monthname"in e)&&"day"in e&&"hour"in e&&"minute"in e&&"second"in e&&"millisecond"in e&&("zone"in e||"offset"in e)}var vV=[[/([^\d.]+)(\d{1,2})\.(\d{2})\.(\d{2})(\D|$)/,"$1$2:$3:$4$5"],[/([^\d.]+)(\d{1,2})\.(\d{2})(\D|$)/,"$1$2:$3$4"]],vU={ar:[[/ /g," "]],bn:[[/,/g,""]],zh:[[/早上\s*([\d:]+)/,"$1am"],[/凌晨\s*([\d:]+)/,"$1am"],[/上午\s*([\d:]+)/,"$1am"],[/下午\s*([\d:]+)/,"$1pm"],[/晚上\s*([\d:]+)/,"$1pm"]],he:[[/ב/gi,""]],de:[[/ um /g," "]],pt:[[/\sde /gi," "]],es:[[/\sde /gi," "]],da:[[/\sden /gi," "],...vV],ru:[[/ г\./g,""]],th:[[/\s*นาฬิกา\s*/i,":"],[/\s*นาที\s*/i,":"],[/\s*วินาที\s*/i," "]],ko:[[/\s*시\s*/,":"],[/\s*분\s*/,":"],[/\s*초\s*/,""],[/(오전|오후)\s*([\d:]+)/,"$2$1"],[/(\d{4})\. (\d{1,2})\. (\d{1,2})\./,"$1-$2-$3"]],fi:vV,id:vV,fr:[[/(\d{2}) h /,"$1:"],[/(\d{2}) min /,"$1:"],[/(\d{2}) s /,"$1"]]};function vW(e,t=vw){let r=function(e){if(!vF[e]){var t,r;let n,a,o=vN.factory(e);vF[e]=new vj({doneChecker:vB,fallback:(t=e,function(e){let r=String(e).slice(0,50);return""===r&&(r="(empty string)"),{invalid:`Unable to parse "${r}" with locale "${t}"`}}),patterns:(n=[{name:"timestampWithOffset",regex:o.compile("^(_YEAR4_)-(_MONTH_)-(_DAY_)[T ](_H24_):(_MIN_):(_SEC_)(?:.(_MS_))? ?(_OFFSET_|Z)?$"),handler:vM(["","year","month","day","hour","minute","second","millisecond","offset"])},{name:"timestampWithZone",regex:o.compile("^(_YEAR4_)-(_MONTH_)-(_DAY_)[T ](_H24_):(_MIN_):(_SEC_)(?:.(_MS_))?\\s*(_ZONE_)$"),handler:vM(["","year","month","day","hour","minute","second","millisecond","zone"])},{name:"timestampWithOffsetAndZone",regex:o.compile("^(_YEAR4_)-(_MONTH_)-(_DAY_)[T ](_H24_):(_MIN_):(_SEC_)(?:.(_MS_))? (_OFFSET_|Z)\\s*(_ZONE_)$"),handler:vM(["","year","month","day","hour","minute","second","millisecond","offset"])},{name:"chinese",regex:o.compile(`^(${vS}{2,4})\\s*\u5E74\\s*(${vS}{1,2})\\s*\u6708\\s*(${vS}{1,2})\\s*\u65E5$`),handler:vM(["","year","month","day"])},{name:"korean",regex:o.compile("^(_YEAR_)년\\s*(_MONTH_)월\\s*(_DAY_)일$"),handler:vM(["","year","month","day"])},{name:"twitter",regex:/^(?:sun|mon|tue|wed|thu|fri|sat) (jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec) (\d{2}) (\d{2}):(\d{2}):(\d{2}) ([+-]\d{4}) (\d{4})$/i,handler:vM(["","monthname","day","hour","minute","second","offset","year"])},{name:"today",regex:/^(now|today|tomorrow|yesterday)$/i,handler:function(e){let t=vA(),r=e[1].toLowerCase();switch(r){case"tomorrow":t.setUTCDate(t.getUTCDate()+1);break;case"yesterday":t.setUTCDate(t.getUTCDate()-1)}let n={year:t.getUTCFullYear(),month:t.getUTCMonth()+1,day:t.getUTCDate()};return"now"===r&&(n.hour=t.getUTCHours(),n.minute=t.getUTCMinutes(),n.second=t.getUTCSeconds(),n.millisecond=t.getUTCMilliseconds()),console.log("today=>",r,n),n}},{name:"ago",regex:/^(\+|-|in|) ?([\d.]+) ?(years?|months?|weeks?|days?|hours?|minutes?|seconds?|milliseconds?|ms|s|m|h|w|d|M|y)( ago)?$/i,handler:function([,e,t,r,n]){t=parseFloat(t),"week"===(r=r.length<=2?vI[r]:(r=r.replace(/s$/,"")).toLowerCase())&&(r="day",t*=7),("-"===e||n)&&(t*=-1);let a=vA();return"millisecond"===r?a.setUTCMilliseconds(a.getUTCMilliseconds()+t):"second"===r?a.setUTCSeconds(a.getUTCSeconds()+t):"minute"===r?a.setUTCMinutes(a.getUTCMinutes()+t):"hour"===r?a.setUTCHours(a.getUTCHours()+t):"day"===r?a.setUTCDate(a.getUTCDate()+t):"month"===r?a.setUTCMonth(a.getUTCMonth()+t):"year"===r&&a.setUTCFullYear(a.getUTCFullYear()+t),{year:a.getUTCFullYear(),month:a.getUTCMonth()+1,day:a.getUTCDate(),hour:a.getUTCHours(),minute:a.getUTCMinutes(),second:a.getUTCSeconds(),millisecond:a.getUTCMilliseconds()}}},{name:"atSeconds",regex:/^@(\d+)$/,handler:function(e){let t=new Date(1e3*parseInt(e[1],10));return{year:t.getUTCFullYear(),month:t.getUTCMonth()+1,day:t.getUTCDate(),hour:t.getUTCHours(),minute:t.getUTCMinutes(),second:t.getUTCSeconds()}}},{name:"microsoftJson",regex:/^\/Date\((\d+)([+-]\d{4})?\)\/$/,handler:function(e){let t=new Date(parseInt(e[1],10));return{year:t.getUTCFullYear(),month:t.getUTCMonth()+1,day:t.getUTCDate(),hour:t.getUTCHours(),minute:t.getUTCMinutes(),second:t.getUTCSeconds(),millisecond:t.getUTCMilliseconds(),offset:e[2]}}},{name:"full24",regex:o.compile("(?:^|[\\sT])(_H24_):(_MIN_):(_SEC_)(?:\\.(_MS_))?(Z)?$"),handler:vM(["","hour","minute","second","millisecond","zone"])},{name:"zone24",regex:o.compile("(_H24_):(_MIN_):(_SEC_)(?:\\.(_MS_))?[\\s\\[(]*(_ZONE_)?[\\s\\])]*$"),handler:vM(["","hour","minute","second","millisecond","zone"])},{name:"hms12",regex:o.compile("(_H12_):(_MIN_):(_SEC_)\\s*(_MERIDIEM_)"),handler:vM(["","hour","minute","second","meridiem"])},{name:"hms24",regex:o.compile("(_H24_):(_MIN_):(_SEC_)(?:\\.(_MS_))?"),handler:vM(["","hour","minute","second","millisecond"])},{name:"hm12",regex:o.compile("(_H12_):(_MIN_)\\s*(_MERIDIEM_)"),handler:vM(["","hour","minute","meridiem"])},{name:"hm24",regex:o.compile("(_H24_):(_MIN_)"),handler:vM(["","hour","minute"])},{name:"h12",regex:o.compile("(_H12_)\\s*(_MERIDIEM_)"),handler:vM(["","hour","meridiem"])},{name:"8digit",regex:/^((?:19|20)\d{2})(\d{2})(\d{2})$/,handler:vM(["","year","month","day"])},{name:"yearMonthnameDay",regex:o.compile("(_YEAR4_)[\\s.-]+(_MONTHNAME_)[\\s,.-]+(_DAY_)(_ORDINAL_)?"),handler:vM(["","year","monthname","day"])},{name:"dayMonthnameYear",regex:o.compile("(_DAY_)(_ORDINAL_)?[\\s.-]*(_MONTHNAME_)[\\s,.-]+(_YEAR_)"),handler:vM(["","day","","monthname","year"])},{name:"monthnameDayYear",regex:o.compile("(_MONTHNAME_)[\\s.-]*(_DAY_)(_ORDINAL_)?[\\s,.-]+(_YEAR_)"),handler:vM(["","monthname","day","","year"])},{name:"dayMonthname",regex:o.compile("\\b(_DAY_)(_ORDINAL_)?[\\s.-]*(_MONTHNAME_)\\b"),handler:vM(["","day","","monthname"])},{name:"monthnameDay",regex:o.compile("\\b(_MONTHNAME_)[\\s.-]*(_DAY_)(_ORDINAL_)?\\b"),handler:vM(["","monthname","day"])},{name:"hmsNoMeridiem",regex:o.compile("\\b(_H12_|_H24_):(_MIN_):(_SEC_)\\b"),handler:vM(["","hour","minute","second"])},{name:"hmNoMeridiem",regex:o.compile("\\b(_H12_|_H24_):(_MIN_)\\b"),handler:vM(["","hour","minute"])},{name:"ymd",regex:o.compile("(_YEAR4_)([.-])(_MONTH_)\\2+(_DAY_)"),handler:vM(["","year","","month","day"])},{name:"mdy",regex:o.compile("(_MONTH_)([/-])(_DAY_)\\2(_YEAR_)"),handler:vM(["","month","","day","year"])},{name:"dmy",regex:o.compile("(_DAY_)(?:_ORDINAL_)?[./\\s-]+(_MONTH_)[./\\s-]+(_YEAR_)"),handler:vM(["","day","month","year"])},{name:"yearLoose",regex:o.compile("_YEAR4_"),handler:vM(["year"])},{name:"dayMonthnameLoose",regex:o.compile("(_DAY_)[\\s.]*(_MONTHNAME_)"),handler:vM(["","day","monthname"])},{name:"monthnameDayLoose",regex:o.compile("(_MONTHNAME_)[\\s.]*(_DAY_)"),handler:vM(["","monthname","day"])},{name:"monthname",regex:o.compile("_MONTHNAME_"),handler:vM(["monthname"])},{name:"year4",regex:o.compile("_YEAR4_"),handler:vM(["year"])},{name:"md",regex:o.compile("(_MONTH_)[/-](_DAY_)"),handler:vM(["","month","day"])},{name:"dm",regex:o.compile("(_DAY_)(?:_ORDINAL_)?[./\\s-]+(_MONTH_)"),handler:vM(["","day","month"])},{name:"day",regex:o.compile("_DAY_"),handler:vM(["day"])},{name:"year2",regex:o.compile("_YEAR2_"),handler:vM(["year"])},{name:"onlyZone",regex:o.compile("_ZONE_"),handler:vM(["zone"])}],a=o.baseName.slice(0,5),vO.includes(a)?n:n.filter(e=>!["mdy","md"].includes(e.name))),formatter:(r=o,function(e){let t={};for(let[n,a]of Object.entries(e))if("monthname"===n){if(a){let e=r.monthNameToInt(a);void 0!==e&&(t.month=e)}}else if("hour"===n&&e.meridiem){let n=r.h12ToInt(a,e.meridiem);void 0!==n&&(t.hour=n)}else if("zone"===n){if(a){let e=r.zoneToOffset(a);void 0!==e&&(t.offset=e)}}else if("offset"===n){let e=r.offsetToMinutes(a);void 0!==e&&(t.offset=e)}else if("millisecond"===n){let e=r.millisecondToInt(a);"number"==typeof e&&(t.millisecond=e)}else if(vL.includes(n)){let e=r.toInt(a);"number"==typeof e&&(t[n]=e)}return t.year<100&&(t.year=vE[t.year]),t.year&&"buddhist"===r.dateOptions.calendar&&(t.year-=543),t})})}return vF[e]}(t),n=function(e,t){let r=vU[t.slice(0,2).toLowerCase()];if(!r)return e;for(let[t,n]of r)e=e.replace(t,n);return e}(e,t);return r.attempt(n)}function vH(e){e.month&&e.day&&void 0===e.year&&(e.year=new Date().getFullYear()),60===e.second&&(e.second=59);let t=new vx(e.year,e.month-1,e.day,e.hour||0,e.minute||0,e.second||0,e.millisecond||0);return"number"==typeof e.offset?new vx(t.valueOf()-60*e.offset*1e3):t}function vz(e,t=vw){let r=vW(e,t),n=r.invalid?new vx(NaN):vH(r);return n.isValid()||(n.invalid=`Unable to parse date "${e}"`),n}function vK(e,t=vw){return e instanceof Date?new vx(e.valueOf()):"number"==typeof e?new vx(e):vz(e,t)}Date.fromString=vx.fromString=vz,Date.fromAny=vx.fromAny=vK,"u">typeof window&&(window.anyDateParser={fromString:vz,fromAny:vK,fromObject:vH,attempt:vW});var vG=r(4397),vZ=r(7657),vY=r(254);function vq(e,t){var r=function(e,t){if(!t.has(e))throw TypeError("attempted to get private field on non-instance");return t.get(e)}(e,t);return r.get?r.get.call(e):r.value}lU().extend(lW),lU().extend(vZ),lU().extend(vG);let vJ="YYYY-MM-DDTHH:mm:ss.SSSZZ",vX=/^(\d{4})(?:-(\d{2})(?:-(\d{2}))?)?$/;function vQ(e,t){let r=vX.exec(e);if(!r)return vW(e,t);let n=Number(r[1]),a=void 0===r[2]?void 0:Number(r[2]),o=void 0===r[3]?void 0:Number(r[3]),i=new Date(0);return(i.setUTCFullYear(n,(a??1)-1,o??1),i.getUTCFullYear()!==n||i.getUTCMonth()!==(a??1)-1||i.getUTCDate()!==(o??1))?{invalid:`Invalid ISO calendar date '${e}'`}:{year:n,...void 0!==a&&{month:a},...void 0!==o&&{day:o}}}function v0(e){return null!=e&&28===e.trim().length&&"T"===(e=e.trim())[10]&&":"===e[13]&&":"===e[16]&&"."===e[19]&&("+"===e[23]||"-"===e[23])&&lU()(e,vJ).isValid()}function v1(e){return lU()(e).isToday()}function v4(e){return v0(e)?lU()(e,vJ).toDate():null}function v2(e,t=!1){let r=lU()(e);return t&&(r=r.utc()),r.format(vJ)}function v3(e){return lU()(e).toDate()}var v6=new WeakMap;let v5=new class{register(e,t){vq(this,v6).set(e,t)}getCalendar(e){if(!e)return;if(e.calendar)return e.calendar;if(e.region){let t=`${e.language}-${e.region}`;if(vq(this,v6).has(t))return vq(this,v6).get(t)}if(e.language&&vq(this,v6).has(e.language))return vq(this,v6).get(e.language);let t=new Intl.DateTimeFormat(e.toString()).resolvedOptions().calendar;return vq(this,v6).set(`${e.language}${e.region?`-${e.region}`:""}`,t),t}constructor(){!function(e,t,r){if(t.has(e))throw TypeError("Cannot initialize the same private elements twice on an object");t.set(e,r)}(this,v6,{writable:!0,value:new Map})}};function v9(e,t){v5.register(e,t)}function v8(e){let t=e??vb();return v5.getCalendar(t instanceof Intl.Locale?t:new Intl.Locale(t))}let v7={mode:"standard",time:"for today",day:!0,month:!0,year:!0,noToday:!1};function be(e,t={}){let r=vQ(e,vb());if(r.invalid)return console.warn(`Could not parse invalid date '${e}'`),null;!(0,vY.A)(r.day)&&(0,vY.A)(r.month)&&(r=Object.assign({},tV(r,"day"),{month:r.day})),r.month&&(r.month-=1),r.day&&(r=Object.assign({},tV(r,"day"),{date:r.day}));let n=lU()().set(r).toDate();return(0,vY.A)(r.year)&&(t.year=!1),(0,vY.A)(r.month)&&(t.month=!1),(0,vY.A)(r.date)&&(t.day=!1),bt(n,t)}function bt(e,t){let r,n=t?.locale??vb(),a=new Intl.Locale(n),{calendar:o,mode:i,time:s,day:l,month:u,year:c,noToday:d,numberingSystem:m}={...v7,...{noToday:"am"===a.language},...t},p={calendar:o??v8(a),year:c?"numeric":void 0,month:u?"short":void 0,day:l?"2-digit":void 0,numberingSystem:m},f=lU()(e).isToday();if(f&&!d)r=(r=new Intl.RelativeTimeFormat(n,{numeric:"auto"}).format(0,"day"))[0].toLocaleUpperCase(n)+r.slice(1);else{"en"===a.language&&(n="en-GB");let t=new Intl.DateTimeFormat(n,p).formatToParts(e);("en"===a.language||"am"===a.language)&&"standard"==i&&c&&l&&(t=t.map(br("-"))),"wide"==i&&(t=t.map(br(" — "))),"ethiopic"===p.calendar&&(t=t.filter((e,t,r)=>"era"!==e.type&&("literal"!==e.type||!(t<r.length-1)||"era"!==r[t+1].type))),r=t.map(e=>e.value).join("")}return(!0===s||f&&"for today"===s)&&(r+=`, ${bn(e)}`),r}let br=e=>(t,r,n)=>"literal"!==t.type||" "!==t.value||r<n.length-1&&"era"===n[r+1].type?t:{type:"literal",value:e};function bn(e){return e.toLocaleTimeString(vb(),{hour:"2-digit",minute:"2-digit"})}function ba(e,t){return bt(e,{...t,time:!0})}function bo(e,t){let r=v8("string"==typeof t?new Intl.Locale(t):t);return r?fm(e,hR(r)):e}function bi(e,t){return new Intl.DurationFormat(vb(),t).format(e)}function bs(e,t){if(null==e)return null;if("string"==typeof e){let r=vQ(e,vb());return r.invalid?(console.warn(`Could not interpret '${e}' as a date`),null):(r.day&&!r.month&&(r={...tV(r,"day"),...{month:r.day}}),r.month&&(r.month-=1),r.day&&(r={...tV(r,"day"),...{date:r.day}}),lU()(t).set(r))}return lU()(e)}let bl=["years","months","days","hours","minutes","seconds"],bu={second:"seconds",minute:"minutes",hour:"hours",day:"days",month:"months",year:"years"},bc={seconds:45,minutes:45,hours:22,days:26,months:11,years:1/0};function bd(e,t=lU()(),r){let n,a=lU()(t),o=bs(e,a);if(null==o)return null;if("string"==typeof r){let e=bu[r]??r;return{[e]:a.diff(o,e)}}let{thresholds:i,largestUnit:s,smallestUnit:l}=r??{};if(void 0!==s||void 0!==l){let e,t=l?bu[l]??l:void 0;return e="auto"===s||void 0===s?function(e,t,r){let n=bl.indexOf(r);for(let a=0;a<bl.length;a++){let o=bl[a];if(t.diff(e,o)>0)return a<=n?o:r}return r}(o,a,t??"seconds"):bu[s]??s,function(e,t,r,n){let a=bl.indexOf(r),o=bl.indexOf(n),i=bl.slice(a,o+1),s={},l=e;for(let e of i){let r=t.diff(l,e);s[e]=r,l=l.add(r,e)}return s}(o,a,e,t??e)}let u=(n=function(e){let t={...bc};if(e)for(let[r,n]of Object.entries(e))void 0!==n&&(t[bu[r]??r]=n);return t}(i),a.diff(o,"seconds")<n.seconds?"seconds":a.diff(o,"minutes")<n.minutes?"minutes":a.diff(o,"hours")<n.hours?"hours":a.diff(o,"days")<n.days?"days":a.diff(o,"months")<n.months?"months":"years");return{[u]:a.diff(o,u)}}let bm={style:"short",localeMatcher:"lookup"};function bp(e,t=lU()(),r){let n=bd(e,t,r);return null==n?null:bi(n,"object"==typeof r&&r.formatOptions?{...bm,...r.formatOptions}:bm)}let bf=(0,so.createContext)(null);function bh(){let e=s5({externalModuleName:"@openmrs/esm-styleguide"}).preferredDateLocale,t=(0,so.useMemo)(()=>{let t=vb();return e[t]&&(t=e[t]),t},[window.i18next.language]),r=(0,so.useMemo)(()=>{let e=v8(t);return void 0!==e?hR(e):void 0},[t]),n=(0,so.useMemo)(()=>new Intl.Locale(t,{calendar:r?.identifier}),[t,r]),a=(0,so.useMemo)(()=>r?fm(fw(fS()),r):fw(fS()),[r]);return{calendar:r,intlLocale:n,today_:a}}let bg=new p8(1793,1,1);var by={};function bv(){return"u">typeof window&&window.InputEvent&&"function"==typeof InputEvent.prototype.getTargetRanges}function bb(e={}){let{locale:t}=pm();return(0,so.useMemo)(()=>new(0,gJ.K)(t,e),[t,e])}by={"ar-AE":{decrease:e=>`\u{62E}\u{641}\u{636} ${e.fieldLabel}`,increase:e=>`\u{632}\u{64A}\u{627}\u{62F}\u{629} ${e.fieldLabel}`,numberField:"حقل رقمي"},"bg-BG":{decrease:e=>`\u{41D}\u{430}\u{43C}\u{430}\u{43B}\u{44F}\u{432}\u{430}\u{43D}\u{435} ${e.fieldLabel}`,increase:e=>`\u{423}\u{441}\u{438}\u{43B}\u{432}\u{430}\u{43D}\u{435} ${e.fieldLabel}`,numberField:"Номер на полето"},"cs-CZ":{decrease:e=>`Sn\xed\u{17E}it ${e.fieldLabel}`,increase:e=>`Zv\xfd\u{161}it ${e.fieldLabel}`,numberField:"Č\xedseln\xe9 pole"},"da-DK":{decrease:e=>`Reducer ${e.fieldLabel}`,increase:e=>`\xd8g ${e.fieldLabel}`,numberField:"Talfelt"},"de-DE":{decrease:e=>`${e.fieldLabel} verringern`,increase:e=>`${e.fieldLabel} erh\xf6hen`,numberField:"Nummernfeld"},"el-GR":{decrease:e=>`\u{39C}\u{3B5}\u{3AF}\u{3C9}\u{3C3}\u{3B7} ${e.fieldLabel}`,increase:e=>`\u{391}\u{3CD}\u{3BE}\u{3B7}\u{3C3}\u{3B7} ${e.fieldLabel}`,numberField:"Πεδίο αριθμού"},"en-US":{decrease:e=>`Decrease ${e.fieldLabel}`,increase:e=>`Increase ${e.fieldLabel}`,numberField:"Number field"},"es-ES":{decrease:e=>`Reducir ${e.fieldLabel}`,increase:e=>`Aumentar ${e.fieldLabel}`,numberField:"Campo de n\xfamero"},"et-EE":{decrease:e=>`V\xe4henda ${e.fieldLabel}`,increase:e=>`Suurenda ${e.fieldLabel}`,numberField:"Numbri v\xe4li"},"fi-FI":{decrease:e=>`V\xe4henn\xe4 ${e.fieldLabel}`,increase:e=>`Lis\xe4\xe4 ${e.fieldLabel}`,numberField:"Numerokentt\xe4"},"fr-FR":{decrease:e=>`Diminuer ${e.fieldLabel}`,increase:e=>`Augmenter ${e.fieldLabel}`,numberField:"Champ de nombre"},"he-IL":{decrease:e=>`\u{5D4}\u{5E7}\u{5D8}\u{5DF} ${e.fieldLabel}`,increase:e=>`\u{5D4}\u{5D2}\u{5D3}\u{5DC} ${e.fieldLabel}`,numberField:"שדה מספר"},"hr-HR":{decrease:e=>`Smanji ${e.fieldLabel}`,increase:e=>`Pove\u{107}aj ${e.fieldLabel}`,numberField:"Polje broja"},"hu-HU":{decrease:e=>`${e.fieldLabel} cs\xf6kkent\xe9se`,increase:e=>`${e.fieldLabel} n\xf6vel\xe9se`,numberField:"Sz\xe1mmező"},"it-IT":{decrease:e=>`Riduci ${e.fieldLabel}`,increase:e=>`Aumenta ${e.fieldLabel}`,numberField:"Campo numero"},"ja-JP":{decrease:e=>`${e.fieldLabel}\u{3092}\u{7E2E}\u{5C0F}`,increase:e=>`${e.fieldLabel}\u{3092}\u{62E1}\u{5927}`,numberField:"数値フィールド"},"ko-KR":{decrease:e=>`${e.fieldLabel} \u{AC10}\u{C18C}`,increase:e=>`${e.fieldLabel} \u{C99D}\u{AC00}`,numberField:"번호 필드"},"lt-LT":{decrease:e=>`Suma\u{17E}inti ${e.fieldLabel}`,increase:e=>`Padidinti ${e.fieldLabel}`,numberField:"Numerio laukas"},"lv-LV":{decrease:e=>`Samazin\u{101}\u{161}ana ${e.fieldLabel}`,increase:e=>`Palielin\u{101}\u{161}ana ${e.fieldLabel}`,numberField:"Skaitļu lauks"},"nb-NO":{decrease:e=>`Reduser ${e.fieldLabel}`,increase:e=>`\xd8k ${e.fieldLabel}`,numberField:"Tallfelt"},"nl-NL":{decrease:e=>`${e.fieldLabel} verlagen`,increase:e=>`${e.fieldLabel} verhogen`,numberField:"Getalveld"},"pl-PL":{decrease:e=>`Zmniejsz ${e.fieldLabel}`,increase:e=>`Zwi\u{119}ksz ${e.fieldLabel}`,numberField:"Pole numeru"},"pt-BR":{decrease:e=>`Diminuir ${e.fieldLabel}`,increase:e=>`Aumentar ${e.fieldLabel}`,numberField:"Campo de n\xfamero"},"pt-PT":{decrease:e=>`Diminuir ${e.fieldLabel}`,increase:e=>`Aumentar ${e.fieldLabel}`,numberField:"Campo num\xe9rico"},"ro-RO":{decrease:e=>`Sc\u{103}dere ${e.fieldLabel}`,increase:e=>`Cre\u{219}tere ${e.fieldLabel}`,numberField:"C\xe2mp numeric"},"ru-RU":{decrease:e=>`\u{423}\u{43C}\u{435}\u{43D}\u{44C}\u{448}\u{435}\u{43D}\u{438}\u{435} ${e.fieldLabel}`,increase:e=>`\u{423}\u{432}\u{435}\u{43B}\u{438}\u{447}\u{435}\u{43D}\u{438}\u{435} ${e.fieldLabel}`,numberField:"Числовое поле"},"sk-SK":{decrease:e=>`Zn\xed\u{17E}i\u{165} ${e.fieldLabel}`,increase:e=>`Zv\xfd\u{161}i\u{165} ${e.fieldLabel}`,numberField:"Č\xedseln\xe9 pole"},"sl-SI":{decrease:e=>`Upadati ${e.fieldLabel}`,increase:e=>`Pove\u{10D}ajte ${e.fieldLabel}`,numberField:"Številčno polje"},"sr-SP":{decrease:e=>`Smanji ${e.fieldLabel}`,increase:e=>`Pove\u{107}aj ${e.fieldLabel}`,numberField:"Polje broja"},"sv-SE":{decrease:e=>`Minska ${e.fieldLabel}`,increase:e=>`\xd6ka ${e.fieldLabel}`,numberField:"Nummerf\xe4lt"},"tr-TR":{decrease:e=>`${e.fieldLabel} azalt`,increase:e=>`${e.fieldLabel} artt\u{131}r`,numberField:"Sayı alanı"},"uk-UA":{decrease:e=>`\u{417}\u{43C}\u{435}\u{43D}\u{448}\u{438}\u{442}\u{438} ${e.fieldLabel}`,increase:e=>`\u{417}\u{431}\u{456}\u{43B}\u{44C}\u{448}\u{438}\u{442}\u{438} ${e.fieldLabel}`,numberField:"Поле номера"},"zh-CN":{decrease:e=>`\u{964D}\u{4F4E} ${e.fieldLabel}`,increase:e=>`\u{63D0}\u{9AD8} ${e.fieldLabel}`,numberField:"数字字段"},"zh-TW":{decrease:e=>`\u{7E2E}\u{5C0F} ${e.fieldLabel}`,increase:e=>`\u{653E}\u{5927} ${e.fieldLabel}`,numberField:"數字欄位"}};var bw={};bw={"ar-AE":{Empty:"فارغ"},"bg-BG":{Empty:"Изпразни"},"cs-CZ":{Empty:"Pr\xe1zdn\xe9"},"da-DK":{Empty:"Tom"},"de-DE":{Empty:"Leer"},"el-GR":{Empty:"Άδειο"},"en-US":{Empty:"Empty"},"es-ES":{Empty:"Vac\xedo"},"et-EE":{Empty:"T\xfchjenda"},"fi-FI":{Empty:"Tyhj\xe4"},"fr-FR":{Empty:"Vide"},"he-IL":{Empty:"ריק"},"hr-HR":{Empty:"Prazno"},"hu-HU":{Empty:"\xdcres"},"it-IT":{Empty:"Vuoto"},"ja-JP":{Empty:"空"},"ko-KR":{Empty:"비어 있음"},"lt-LT":{Empty:"Tuščias"},"lv-LV":{Empty:"Tukšs"},"nb-NO":{Empty:"Tom"},"nl-NL":{Empty:"Leeg"},"pl-PL":{Empty:"Pusty"},"pt-BR":{Empty:"Vazio"},"pt-PT":{Empty:"Vazio"},"ro-RO":{Empty:"Gol"},"ru-RU":{Empty:"Не заполнено"},"sk-SK":{Empty:"Pr\xe1zdne"},"sl-SI":{Empty:"Prazen"},"sr-SP":{Empty:"Prazno"},"sv-SE":{Empty:"Tomt"},"tr-TR":{Empty:"Boş"},"uk-UA":{Empty:"Пусто"},"zh-CN":{Empty:"空"},"zh-TW":{Empty:"空白"}};let bx=()=>{};function bE(e){var t;let r=(0,so.useRef)(void 0),{value:n,textValue:a,minValue:o,maxValue:i,isDisabled:s,isReadOnly:l,isRequired:u,onIncrement:c,onIncrementPage:d,onDecrement:m,onDecrementPage:p,onDecrementToMin:f,onIncrementToMax:h}=e,g=pI((t=bw)&&t.__esModule?t.default:t,"@react-aria/spinbutton"),y=(0,so.useRef)(!1),v=(0,so.useCallback)(()=>{clearTimeout(r.current),y.current=!1},[]),b=mO(()=>{v()});(0,so.useEffect)(()=>()=>b(),[]);let w=(0,so.useRef)(!1),x=()=>{w.current=!0},E=()=>{w.current=!1},D=""===a?g.format("Empty"):(a||`${n}`).replace("-","−");(0,so.useEffect)(()=>{w.current&&(pp&&pp.clear("assertive"),pf(D,"assertive"))},[D]);let S=(0,so.useCallback)(()=>{v()},[v]),_=mO(c??bx),C=mO(m??bx),k=mO(()=>{(void 0===i||isNaN(i)||void 0===n||isNaN(n)||n<i)&&(_(),P(60))}),P=mO(e=>{b(),y.current=!0,r.current=window.setTimeout(k,e)}),R=mO(()=>{(void 0===o||isNaN(o)||void 0===n||isNaN(n)||n>o)&&(C(),T(60))}),T=mO(e=>{b(),y.current=!0,r.current=window.setTimeout(R,e)}),$=e=>{e.preventDefault()},{addGlobalListener:N,removeAllGlobalListeners:O}=mI(),I=(0,so.useRef)(!1),[A,M]=(0,so.useState)(null);(0,so.useEffect)(()=>{"touch"===A?P(600):A&&P(400)},[A]);let[j,L]=(0,so.useState)(null);return(0,so.useEffect)(()=>{"touch"===j?T(600):j&&T(400)},[j]),{spinButtonProps:{role:"spinbutton","aria-valuenow":void 0===n||isNaN(n)?void 0:n,"aria-valuetext":D,"aria-valuemin":o,"aria-valuemax":i,"aria-disabled":s||void 0,"aria-readonly":l||void 0,"aria-required":u||void 0,onKeyDown:e=>{if(!e.ctrlKey&&!e.metaKey&&!e.shiftKey&&!e.altKey&&!l&&!e.nativeEvent.isComposing)switch(e.key){case"PageUp":if(d){e.preventDefault(),d?.();break}case"ArrowUp":case"Up":c&&(e.preventDefault(),c?.());break;case"PageDown":if(p){e.preventDefault(),p?.();break}case"ArrowDown":case"Down":m&&(e.preventDefault(),m?.());break;case"Home":f&&(e.preventDefault(),f?.());break;case"End":h&&(e.preventDefault(),h?.())}},onFocus:x,onBlur:E},incrementButtonProps:{onPressStart:e=>{v(),"touch"!==e.pointerType?(c?.(),M("mouse")):(N(window,"pointercancel",S,{capture:!0}),I.current=!1,M("touch")),N(window,"contextmenu",$)},onPressUp:e=>{v(),"touch"===e.pointerType&&(I.current=!0),O(),M(null)},onPressEnd:e=>{v(),"touch"===e.pointerType&&!y.current&&I.current&&c?.(),I.current=!1,M(null)},onFocus:x,onBlur:E},decrementButtonProps:{onPressStart:e=>{v(),"touch"!==e.pointerType?(m?.(),L("mouse")):(N(window,"pointercancel",S,{capture:!0}),I.current=!1,L("touch"))},onPressUp:e=>{v(),"touch"===e.pointerType&&(I.current=!0),O(),L(null)},onPressEnd:e=>{v(),"touch"===e.pointerType&&!y.current&&I.current&&m?.(),I.current=!1,L(null)},onFocus:x,onBlur:E}}}let bD=null;var bS=r(2103);function b_(e,t,r){let n="+"===e?t+r:t-r;if(t%1!=0||r%1!=0){let a=t.toString().split("."),o=r.toString().split("."),i=Math.pow(10,Math.max(a[1]&&a[1].length||0,o[1]&&o[1].length||0));t=Math.round(t*i),r=Math.round(r*i),n=("+"===e?t+r:t-r)/i}return n}let bC=(0,so.createContext)(null),bk=(0,so.createContext)(null),bP=(0,so.forwardRef)(function(e,t){var r,n;[e,t]=dg(e,t,bC);let{validationBehavior:a}=dh(yu)||{},o=null!=(n=null!=(r=e.validationBehavior)?r:a)?n:"native",{locale:i}=pm(),s=function(e){let{minValue:t,maxValue:r,step:n,formatOptions:a,value:o,defaultValue:i=NaN,onChange:s,locale:l,isDisabled:u,isReadOnly:c,commitBehavior:d="snap"}=e;null===o&&(o=NaN);let m=(0,so.useCallback)(e=>void 0===n||isNaN(n)?yg(e,t,r):yv(e,t,r,n),[n,t,r]);void 0===o||isNaN(o)||"snap"!==d||(o=m(o)),isNaN(i)||"snap"!==d||(i=m(i));let[p,f]=hL(o,isNaN(i)?NaN:i,s),[h]=(0,so.useState)(p),[g,y]=(0,so.useState)(()=>isNaN(p)?"":new(0,gJ.K)(l,a).format(p)),v=(0,so.useMemo)(()=>new(0,bS.d)(l,a),[l,a]),b=(0,so.useMemo)(()=>v.getNumberingSystem(g),[v,g]),w=(0,so.useMemo)(()=>new(0,gJ.K)(l,{...a,numberingSystem:b}),[l,a,b]),x=(0,so.useMemo)(()=>w.resolvedOptions(),[w]),E=(0,so.useCallback)(e=>isNaN(e)||null===e?"":w.format(e),[w]),D=gO({...e,value:p}),S=void 0===n||isNaN(n)?1:n;"percent"===x.style&&(void 0===n||isNaN(n))&&(S=.01);let[_,C]=(0,so.useState)(p),[k,P]=(0,so.useState)(l),[R,T]=(0,so.useState)(a);Object.is(p,_)&&l===k&&a===R||(y(E(p)),C(p),P(l),T(a));let $=(0,so.useMemo)(()=>v.parse(g),[v,g]),N=(e,n=0)=>{if(isNaN($))return yv(isNaN(n)?0:n,t,r,S);{let n=yv($,t,r,S);return"+"===e&&n>$||"-"===e&&n<$?n:yv(b_(e,$,S),t,r,S)}},O=(0,so.useMemo)(()=>!u&&!c&&(isNaN($)||void 0===r||isNaN(r)||yv($,t,r,S)>$||b_("+",$,S)<=r),[u,c,t,r,S,$]),I=(0,so.useMemo)(()=>!u&&!c&&(isNaN($)||void 0===t||isNaN(t)||yv($,t,r,S)<$||b_("-",$,S)>=t),[u,c,t,r,S,$]);return{...D,validate:e=>v.isValidPartialNumber(e,t,r),increment:()=>{let e=N("+",t);e===p&&y(E(e)),f(e),D.commitValidation()},incrementToMax:()=>{null!=r&&(f(yv(r,t,r,S)),D.commitValidation())},decrement:()=>{let e=N("-",r);e===p&&y(E(e)),f(e),D.commitValidation()},decrementToMin:()=>{null!=t&&(f(t),D.commitValidation())},canIncrement:O,canDecrement:I,minValue:t,maxValue:r,numberValue:$,defaultNumberValue:isNaN(i)?h:i,setNumberValue:f,setInputValue:y,inputValue:g,commit:e=>{let t=void 0===e?g:e,r=$;if(void 0!==e&&(r=v.parse(t)),!t.length){f(NaN),y(void 0===o?"":E(p));return}if(isNaN(r))return void y(E(p));let n="snap"===d?m(r):r,a=(n=v.parse(E(n)))!==p;f(n),y(E(void 0===o?n:p)),a&&D.commitValidation()}}}({...e,locale:i,validationBehavior:o}),l=(0,so.useRef)(null),[u,c]=dy(!e["aria-label"]&&!e["aria-labelledby"]),{labelProps:d,groupProps:m,inputProps:p,incrementButtonProps:f,decrementButtonProps:h,descriptionProps:g,errorMessageProps:y,...v}=function(e,t,r){var n,a,o,i,s,l,u,c,d;let m,{id:p,decrementAriaLabel:f,incrementAriaLabel:h,isDisabled:g,isReadOnly:y,isRequired:v,minValue:b,maxValue:w,autoFocus:x,label:E,formatOptions:D,onBlur:S=()=>{},onFocus:_,onFocusChange:C,onKeyDown:k,onKeyUp:P,description:R,errorMessage:T,isWheelDisabled:$,...N}=e,{increment:O,incrementToMax:I,decrement:A,decrementToMin:M,numberValue:j,inputValue:L,commit:F,commitValidation:B}=t,V=pI((n=by)&&n.__esModule?n.default:n,"@react-aria/numberfield"),U=(0,so.useCallback)(()=>{let e=r.current?.value??"";(0,mA.flushSync)(()=>{F()}),r.current?.value!==e&&pf(r.current?.value??"","assertive")},[F,r]),W=dl(p),{focusProps:H}=mb({onBlur(){U()}}),z=bb(D),K=(0,so.useMemo)(()=>z.resolvedOptions(),[z]),G=bb({...D,currencySign:void 0}),Z=(0,so.useMemo)(()=>isNaN(j)?"":G.format(j),[G,j]),{spinButtonProps:Y,incrementButtonProps:q,decrementButtonProps:J}=bE({isDisabled:g,isReadOnly:y,isRequired:v,maxValue:w,minValue:b,onIncrement:O,onIncrementToMax:I,onDecrement:A,onDecrementToMin:M,value:j,textValue:Z}),[X,Q]=(0,so.useState)(!1),{focusWithinProps:ee}=mZ({isDisabled:g,onFocusWithinChange:Q});!function(e,t){let{onScroll:r,isDisabled:n}=e,a=(0,so.useCallback)(e=>{!e.ctrlKey&&(e.preventDefault(),e.stopPropagation(),r&&r({deltaX:e.deltaX,deltaY:e.deltaY}))},[r]);fW(t,"wheel",n?void 0:a)}({onScroll:(0,so.useCallback)(e=>{!(Math.abs(e.deltaY)<=Math.abs(e.deltaX))&&(e.deltaY>0?O():e.deltaY<0&&A())},[A,O]),isDisabled:$||g||y||!X},r);let et=(K.maximumFractionDigits??0)>0,er=void 0===t.minValue||isNaN(t.minValue)||t.minValue<0,en="numeric";dQ()?er?en="text":et&&(en="decimal"):d3()&&(er?en="numeric":et&&(en="decimal"));let ea=dR(e),eo=(0,so.useCallback)(e=>{e.nativeEvent.isComposing||("Enter"===e.key?((0,mA.flushSync)(()=>{F()}),B()):e.continuePropagation())},[F,B]),{isInvalid:ei,validationErrors:es,validationDetails:el}=t.displayValidation,{labelProps:eu,inputProps:ec,descriptionProps:ed,errorMessageProps:em}=function(e,t,r){let n=mO(e=>{let n=r.current;if(!n)return;let a=null;switch(e.inputType){case"historyUndo":case"historyRedo":case"insertLineBreak":return;case"deleteContent":case"deleteByCut":case"deleteByDrag":a=n.value.slice(0,n.selectionStart)+n.value.slice(n.selectionEnd);break;case"deleteContentForward":a=n.selectionEnd===n.selectionStart?n.value.slice(0,n.selectionStart)+n.value.slice(n.selectionEnd+1):n.value.slice(0,n.selectionStart)+n.value.slice(n.selectionEnd);break;case"deleteContentBackward":a=n.selectionEnd===n.selectionStart?n.value.slice(0,n.selectionStart-1)+n.value.slice(n.selectionStart):n.value.slice(0,n.selectionStart)+n.value.slice(n.selectionEnd);break;case"deleteSoftLineBackward":case"deleteHardLineBackward":a=n.value.slice(n.selectionStart);break;default:null!=e.data&&(a=n.value.slice(0,n.selectionStart)+e.data+n.value.slice(n.selectionEnd))}null!=a&&t.validate(a)||e.preventDefault()});(0,so.useEffect)(()=>{if(!bv()||!r.current)return;let e=r.current;return e.addEventListener("beforeinput",n,!1),()=>{e.removeEventListener("beforeinput",n,!1)}},[r]);let a=bv()?null:e=>{let r=dA(e).value.slice(0,dA(e).selectionStart)+e.data+dA(e).value.slice(dA(e).selectionEnd);t.validate(r)||e.preventDefault()},{labelProps:o,inputProps:i,descriptionProps:s,errorMessageProps:l,...u}=function(e,t){let{inputElementType:r="input",isDisabled:n=!1,isRequired:a=!1,isReadOnly:o=!1,type:i="text",validationBehavior:s="aria"}=e,[l,u]=hL(e.value,e.defaultValue||"",e.onChange),{focusableProps:c}=mD(e,t),d=gO({...e,value:l}),{isInvalid:m,validationErrors:p,validationDetails:f}=d.displayValidation,{labelProps:h,fieldProps:g,descriptionProps:y,errorMessageProps:v}=gw({...e,isInvalid:m,errorMessage:e.errorMessage||p}),b=dR(e,{labelable:!0}),w={type:i,pattern:e.pattern},[x]=(0,so.useState)(l);return gx(t,e.defaultValue??x,u),gE(e,d,t),{labelProps:h,inputProps:dd(b,"input"===r?w:void 0,{disabled:n,readOnly:o,required:a&&"native"===s,"aria-required":a&&"aria"===s||void 0,"aria-invalid":m||void 0,"aria-errormessage":e["aria-errormessage"],"aria-activedescendant":e["aria-activedescendant"],"aria-autocomplete":e["aria-autocomplete"],"aria-haspopup":e["aria-haspopup"],"aria-controls":e["aria-controls"],value:l,onChange:e=>u(dA(e).value),autoComplete:e.autoComplete,autoCapitalize:e.autoCapitalize,maxLength:e.maxLength,minLength:e.minLength,name:e.name,form:e.form,placeholder:e.placeholder,inputMode:e.inputMode,autoCorrect:e.autoCorrect,spellCheck:e.spellCheck,[parseInt(si().version,10)>=17?"enterKeyHint":"enterkeyhint"]:e.enterKeyHint,onCopy:e.onCopy,onCut:e.onCut,onPaste:e.onPaste,onCompositionEnd:e.onCompositionEnd,onCompositionStart:e.onCompositionStart,onCompositionUpdate:e.onCompositionUpdate,onSelect:e.onSelect,onBeforeInput:e.onBeforeInput,onInput:e.onInput,...c,...g}),descriptionProps:y,errorMessageProps:v,isInvalid:m,validationErrors:p,validationDetails:f}}(e,r),c=(0,so.useRef)(null);return{inputProps:dd(i,{onBeforeInput:a,onCompositionStart(){let{value:e,selectionStart:t,selectionEnd:n}=r.current;c.current={value:e,selectionStart:t,selectionEnd:n}},onCompositionEnd(){if(r.current&&!t.validate(r.current.value)){let{value:e,selectionStart:n,selectionEnd:a}=c.current;r.current.value=e,r.current.setSelectionRange(n,a),t.setInputValue(e)}}}),labelProps:o,descriptionProps:s,errorMessageProps:l,...u}}({...N,...ea,name:void 0,form:void 0,label:E,autoFocus:x,isDisabled:g,isReadOnly:y,isRequired:v,validate:void 0,[gN]:t,value:L,defaultValue:"!",autoComplete:"off","aria-label":e["aria-label"]||void 0,"aria-labelledby":e["aria-labelledby"]||void 0,id:W,type:"text",inputMode:en,onChange:e=>{t.validate(e)&&t.setInputValue(e)},onBlur:S,onFocus:_,onFocusChange:C,onKeyDown:(0,so.useMemo)(()=>c3(eo,k),[eo,k]),onKeyUp:P,onPaste:t=>{e.onPaste?.(t);let r=dA(t);r&&(r.selectionEnd??-1)-(r.selectionStart??0)===r.value.length&&(t.preventDefault(),F(t.clipboardData?.getData?.("text/plain")?.trim()??""))},description:R,errorMessage:T},t,r);gx(r,t.defaultNumberValue,t.setNumberValue),a=t,o=e.validationBehavior,i=e.commitBehavior,s=r,l=t.minValue,u=t.maxValue,c=e.step,d=t.numberValue,c6(()=>{let e=s.current;if("validate"!==i||a.realtimeValidation.isInvalid||!e||e.disabled||(!bD&&"u">typeof document&&((bD=document.createElement("input")).type="number"),!bD))return;bD.min=null==l||isNaN(l)?"":String(l),bD.max=null==u||isNaN(u)?"":String(u),bD.step=null==c||isNaN(c)?"":String(c),bD.value=null==d||isNaN(d)?"":String(d);let t=e.validity.valid&&bD.validity.valid,r=e.validationMessage||bD.validationMessage,n={isInvalid:!t,validationErrors:r?[r]:[],validationDetails:{badInput:e.validity.badInput,customError:e.validity.customError,patternMismatch:e.validity.patternMismatch,rangeOverflow:bD.validity.rangeOverflow,rangeUnderflow:bD.validity.rangeUnderflow,stepMismatch:bD.validity.stepMismatch,tooLong:e.validity.tooLong,tooShort:e.validity.tooShort,typeMismatch:e.validity.typeMismatch,valueMissing:e.validity.valueMissing,valid:t}};a.updateValidation(n),"native"!==o||bD.validity.valid||e.setCustomValidity(bD.validationMessage)});let ep=dd(Y,H,ec,{role:null,"aria-roledescription":d1()?null:V.format("numberField"),"aria-valuemax":null,"aria-valuemin":null,"aria-valuenow":null,"aria-valuetext":null,autoCorrect:"off",spellCheck:"false"});"native"===e.validationBehavior&&(ep["aria-required"]=void 0);let ef=e=>{((e=document)=>e.activeElement)()!==r.current&&("mouse"===e.pointerType?r.current?.focus():e.target.focus())},eh=e["aria-label"]||("string"==typeof e.label?e.label:"");eh||(m=null!=e.label?eu.id:e["aria-labelledby"]);let eg=dl(),ey=dl(),ev=dd(q,{"aria-label":h||V.format("increase",{fieldLabel:eh}).trim(),id:m&&!h?eg:null,"aria-labelledby":m&&!h?`${eg} ${m}`:null,"aria-controls":W,excludeFromTabOrder:!0,preventFocusOnPress:!0,allowFocusWhenDisabled:!0,isDisabled:!t.canIncrement,onPressStart:ef}),eb=dd(J,{"aria-label":f||V.format("decrease",{fieldLabel:eh}).trim(),id:m&&!f?ey:null,"aria-labelledby":m&&!f?`${ey} ${m}`:null,"aria-controls":W,excludeFromTabOrder:!0,preventFocusOnPress:!0,allowFocusWhenDisabled:!0,isDisabled:!t.canDecrement,onPressStart:ef});return{groupProps:{...ee,role:"group","aria-disabled":g,"aria-invalid":ei?"true":void 0},labelProps:eu,inputProps:ep,incrementButtonProps:ev,decrementButtonProps:eb,errorMessageProps:em,descriptionProps:ed,isInvalid:ei,validationErrors:es,validationDetails:el}}({...dv(e),label:c,validationBehavior:o},s,l),b=df({...e,values:{state:s,isDisabled:e.isDisabled||!1,isInvalid:v.isInvalid||!1,isRequired:e.isRequired||!1},defaultClassName:"react-aria-NumberField"}),w=dR(e);return delete w.id,si().createElement(dp,{values:[[bk,s],[h4,m],[h3,{...p,ref:l}],[yc,{...d,ref:u}],[m3,{slots:{increment:f,decrement:h}}],[m9,{slots:{description:g,errorMessage:y}}],[yi,v]]},si().createElement("div",{...w,...b,ref:t,slot:e.slot||void 0,"data-disabled":e.isDisabled||void 0,"data-required":e.isRequired||void 0,"data-invalid":v.isInvalid||void 0}),e.name&&si().createElement("input",{type:"hidden",name:e.name,value:isNaN(s.numberValue)?"":s.numberValue}))});function bR(e,t){return Number.parseInt(bt(e,{calendar:t.calendar,locale:t.baseName,day:!1,month:!1,noToday:!0,numberingSystem:"latn"}))}let bT=(0,so.forwardRef)(function(e,t){let{className:r}=e,n=(0,so.useContext)(hK),a=(0,so.useContext)(hG),o=n??a,i=(0,so.useContext)(bf),s=fS(),l=bt(o.visibleRange.start.toDate(s),{calendar:i.calendar,locale:i.baseName,day:!1,year:!1,noToday:!0}),u=bR(o.visibleRange.start.toDate(s),i),c=o.maxValue?bR(o.maxValue.toDate(s),i):void 0,d=o.minValue?bR(o.minValue.toDate(s),i):void 0,m=(0,so.useCallback)(e=>{o.setFocusedDate(o.focusedDate.cycle("year",e-o.focusedDate.year))},[]);return o&&(0,sl.jsxs)("span",{ref:t,className:r,children:[(0,sl.jsx)("span",{children:l}),(0,sl.jsxs)(bP,{formatOptions:{useGrouping:!1},maxValue:c,minValue:d,onChange:m,value:u,children:[(0,sl.jsx)(h6,{}),(0,sl.jsxs)(h2,{children:[(0,sl.jsx)(m6,{slot:"increment",children:(0,sl.jsx)(uT,{size:8})}),(0,sl.jsx)(m6,{slot:"decrement",children:(0,sl.jsx)(uk,{size:8})})]})]})]})}),b$="-esm-patient-chart__datepicker-module__inputGroup___gBam-",bN="-esm-patient-chart__datepicker-module__inputSegment___wIJDZ",bO="-esm-patient-chart__datepicker-module__dateInputWrapper___LiY68",bI="-esm-patient-chart__datepicker-module__invalidText___A4cv4",bA="-esm-patient-chart__datepicker-module__flatButton___HcpME",bM="-esm-patient-chart__datepicker-module__flatButtonMd___eFpyF",bj="-esm-patient-chart__datepicker-module__flatButtonSm___tsawR",bL="-esm-patient-chart__datepicker-module__flatButtonLg___4HG5y";function bF({children:e}){let t=(0,so.useContext)(vc),r=(0,so.useContext)(vd),n=t??r,a=lR(()=>n?.close());return(0,sl.jsx)(yo,{className:"-esm-patient-chart__datepicker-module__dialog___DaqYi",ref:a,children:e})}let bB=(0,so.forwardRef)(function({variant:e,today_:t,minDate:r,maxDate:n},a){let o="range"===e;return(0,sl.jsx)(vo,{ref:a,className:"-esm-patient-chart__datepicker-module__popover___nAPzC",placement:"bottom start",offset:1,isNonModal:!0,children:(0,sl.jsx)(bF,{children:(0,sl.jsxs)(o?hY:hZ,{...o?{minValue:r,maxValue:n,className:"cds--date-picker__calendar"}:{},children:[(0,sl.jsxs)("header",{className:"-esm-patient-chart__datepicker-module__header___rPv3L",children:[(0,sl.jsx)(m6,{className:ue()(bA,bM),slot:"previous",children:(0,sl.jsx)(uj,{size:16})}),(0,sl.jsx)(bT,{className:"-esm-patient-chart__datepicker-module__monthYear___Rw4qE"}),(0,sl.jsx)(m6,{className:ue()(bA,bM),slot:"next",children:(0,sl.jsx)(uL,{size:16})})]}),(0,sl.jsx)(hJ,{className:"-esm-patient-chart__datepicker-module__calendarGrid___yKV-n",children:e=>(0,sl.jsx)(h1,{className:ue()("cds--date-picker__day",{"-esm-patient-chart__datepicker-module__today___KzMTn":0===t.compare(e)}),date:e},e.toString())})]})})})}),bV=(0,so.forwardRef)(function(e,t){let r=(0,so.useContext)(vc),[n,a]=dg({slot:e.slot},t,g4),{locale:o}=pm(),i=g1({...n,locale:o,createCalendar:hR}),s=(0,so.useRef)(null),{fieldProps:l,inputProps:u}=gC({...n,inputRef:s},i,a),c=(0,so.useCallback)(()=>{i.isDisabled||r.toggle()},[]);return(0,sl.jsxs)(dp,{values:[[g2,i],[h3,{...u,ref:s}],[h4,{...l,ref:a,isInvalid:i.isInvalid}]],children:[(0,sl.jsx)(h2,{...e,id:e.id,ref:t,slot:e.slot||void 0,className:e.className,isDisabled:i.isDisabled,isInvalid:i.isInvalid,onClick:c,children:i.segments.map((t,r)=>(0,so.cloneElement)(e.children(t),{key:r}))}),(0,sl.jsx)(h6,{})]})}),bU=(0,so.forwardRef)(function(e,t){let r=(0,so.useContext)(vc),n=(0,so.useContext)(vd);return(r??n).isInvalid?(0,sl.jsx)(cz,{ref:t,size:16,...e}):(0,sl.jsx)(uC,{ref:t,size:16,...e})});class bW{constructor(e,t){this.locale=e,this.dictionary=t}of(e){return this.dictionary.getStringForLocale(e,this.locale)}}let bH=new Map,bz=(0,so.forwardRef)(function({segment:e,...t},r){let n=(0,so.useContext)(g2),a=c1(r),{segmentProps:o}=function(e,t,r){let n,a,o,i,s=(0,so.useRef)(""),{locale:l,direction:u}=pm(),c=function(){var e;let{locale:t}=pm(),r=pO((e=gy)&&e.__esModule?e.default:e,"@react-aria/datepicker");return(0,so.useMemo)(()=>{try{return new Intl.DisplayNames(t,{type:"dateTimeField"})}catch{return new bW(t,r)}},[t,r])}(),{ariaLabel:d,ariaLabelledBy:m,ariaDescribedBy:p,focusManager:f}=gD.get(t),h=e.isPlaceholder?"":e.text,g=(0,so.useMemo)(()=>t.dateFormatter.resolvedOptions(),[t.dateFormatter]),y=pS({month:"long",timeZone:g.timeZone}),v=pS({hour:"numeric",hour12:g.hour12,timeZone:g.timeZone});if("month"!==e.type||e.isPlaceholder)"hour"!==e.type||e.isPlaceholder||(h=v.format(t.dateValue));else{let e=y.format(t.dateValue);h=e!==h?`${h} \u{2013} ${e}`:e}let{spinButtonProps:b}=bE({value:e.value??void 0,textValue:h,minValue:e.minValue,maxValue:e.maxValue,isDisabled:t.isDisabled,isReadOnly:t.isReadOnly||!e.isEditable,isRequired:t.isRequired,onIncrement:()=>{s.current="",t.increment(e.type)},onDecrement:()=>{s.current="",t.decrement(e.type)},onIncrementPage:()=>{s.current="",t.incrementPage(e.type)},onDecrementPage:()=>{s.current="",t.decrementPage(e.type)},onIncrementToMax:()=>{s.current="",t.incrementToMax(e.type)},onDecrementToMin:()=>{s.current="",t.decrementToMin(e.type)}}),w=(0,so.useMemo)(()=>new(0,bS.d)(l,{maximumFractionDigits:0}),[l]),x=()=>{if(e.text===e.placeholder&&f.focusPrevious(),!w.isValidPartialNumber(e.text)||t.isReadOnly||e.isPlaceholder)("dayPeriod"===e.type||"era"===e.type)&&t.clearSegment(e.type);else{let r=e.text.slice(0,-1),n=w.parse(r);0===(r=0===n?"":r).length||0===n?t.clearSegment(e.type):t.setSegment(e.type,n),s.current=r}},{startsWith:E}=(n=function(e){let{locale:t}=pm(),r=t+(e?Object.entries(e).sort((e,t)=>e[0]<t[0]?-1:1).join():"");if(bH.has(r))return bH.get(r);let n=new Intl.Collator(t,e);return bH.set(r,n),n}({usage:"search",sensitivity:"base"}),a=(0,so.useCallback)((e,t)=>0===t.length||(e=e.normalize("NFC"),t=t.normalize("NFC"),0===n.compare(e.slice(0,t.length),t)),[n]),o=(0,so.useCallback)((e,t)=>0===t.length||(e=e.normalize("NFC"),t=t.normalize("NFC"),0===n.compare(e.slice(-t.length),t)),[n]),i=(0,so.useCallback)((e,t)=>{if(0===t.length)return!0;e=e.normalize("NFC");let r=0,a=(t=t.normalize("NFC")).length;for(;r+a<=e.length;r++){let o=e.slice(r,r+a);if(0===n.compare(t,o))return!0}return!1},[n]),(0,so.useMemo)(()=>({startsWith:a,endsWith:o,contains:i}),[a,o,i])),D=pS({hour:"numeric",hour12:!0}),S=(0,so.useMemo)(()=>{let e=new Date;return e.setHours(0),D.formatToParts(e).find(e=>"dayPeriod"===e.type).value},[D]),_=(0,so.useMemo)(()=>{let e=new Date;return e.setHours(12),D.formatToParts(e).find(e=>"dayPeriod"===e.type).value},[D]),C=pS({year:"numeric",era:"narrow",timeZone:"UTC"}),k=(0,so.useMemo)(()=>{if("era"!==e.type)return[];let r=fm(new p8(1,1,1),t.calendar),n=t.calendar.getEras().map(e=>{let t=r.set({year:1,month:1,day:1,era:e}).toDate("UTC");return{era:e,formatted:C.formatToParts(t).find(e=>"era"===e.type).value}}),a=function(e){e.sort();let t=e[0],r=e[e.length-1];for(let e=0;e<t.length;e++)if(t[e]!==r[e])return e;return 0}(n.map(e=>e.formatted));if(a)for(let e of n)e.formatted=e.formatted.slice(a);return n},[C,t.calendar,e.type]),P=r=>{if(t.isDisabled||t.isReadOnly)return;let n=s.current+r;switch(e.type){case"dayPeriod":if(E(S,r))t.setSegment("dayPeriod",0);else if(E(_,r))t.setSegment("dayPeriod",1);else break;f.focusNext();break;case"era":{let e=k.find(e=>E(e.formatted,r));e&&(t.setSegment("era",e.era),f.focusNext());break}case"day":case"hour":case"minute":case"second":case"month":case"year":{if(!w.isValidPartialNumber(n))return;let a=w.parse(n),o=a;if(void 0!==e.maxValue&&a>e.maxValue&&(o=w.parse(r)),isNaN(a))return;t.setSegment(e.type,o),void 0!==e.maxValue&&(Number(a+"0")>e.maxValue||n.length>=String(e.maxValue).length)?(s.current="",f.focusNext()):s.current=n}}};fW((0,so.useRef)("u">typeof document?document:null),"selectionchange",()=>{let e=window.getSelection();e?.anchorNode&&dI(r.current,e?.anchorNode)&&e.collapse(r.current)});let R=(0,so.useRef)("");fW(r,"beforeinput",n=>{if(r.current)switch(n.preventDefault(),n.inputType){case"deleteContentBackward":case"deleteContentForward":w.isValidPartialNumber(e.text)&&!t.isReadOnly&&x();break;case"insertCompositionText":R.current=r.current.textContent,r.current.textContent=r.current.textContent;break;default:null!=n.data&&P(n.data)}}),fW(r,"input",e=>{let{inputType:t,data:n}=e;"insertCompositionText"===t&&(r.current&&(r.current.textContent=R.current),null!=n&&(E(S,n)||E(_,n))&&P(n))}),c6(()=>{let e=r.current;return()=>{((e=document)=>e.activeElement)()===e&&(f.focusPrevious()||f.focusNext())}},[r,f]);let T=d1()||"timeZoneName"===e.type?{role:"textbox","aria-valuemax":null,"aria-valuemin":null,"aria-valuetext":null,"aria-valuenow":null}:{};e===(0,so.useMemo)(()=>t.segments.find(e=>e.isEditable),[t.segments])||t.isInvalid||(p=void 0);let $=dl(),N=!t.isDisabled&&!t.isReadOnly&&e.isEditable,O="literal"===e.type?"":c.of(e.type),I=fL({"aria-label":`${O}${d?`, ${d}`:""}${m?", ":""}`,"aria-labelledby":m});if("literal"===e.type)return{segmentProps:{"aria-hidden":!0}};let A={caretColor:"transparent"};if("rtl"===u){A.unicodeBidi="embed";let t=g[e.type];("numeric"===t||"2-digit"===t)&&(A.direction="ltr")}return{segmentProps:dd(b,I,{id:$,...T,"aria-invalid":t.isInvalid?"true":void 0,"aria-describedby":p,"aria-readonly":t.isReadOnly||!e.isEditable?"true":void 0,"data-placeholder":e.isPlaceholder||void 0,contentEditable:N,suppressContentEditableWarning:N,spellCheck:N?"false":void 0,autoCorrect:N?"off":void 0,[parseInt(si().version,10)>=17?"enterKeyHint":"enterkeyhint"]:N?"next":void 0,inputMode:t.isDisabled||"dayPeriod"===e.type||"era"===e.type||!N?void 0:"numeric",tabIndex:t.isDisabled?void 0:0,onKeyDown:e=>{if("a"===e.key&&(dX()?e.metaKey:e.ctrlKey)&&e.preventDefault(),!e.ctrlKey&&!e.metaKey&&!e.shiftKey&&!e.altKey)switch(e.key){case"Backspace":case"Delete":e.preventDefault(),e.stopPropagation(),x()}},onFocus:()=>{s.current="",r.current&&fZ(r.current,{containingElement:fz(r.current)});let e=window.getSelection();e?.collapse(r.current)},style:A,onPointerDown(e){e.stopPropagation()},onMouseDown(e){e.stopPropagation()}})}}(e,n,a),{focusProps:i,isFocused:s,isFocusVisible:l}=mY(),{hoverProps:u,isHovered:c}=m0({...t,isDisabled:n.isDisabled||"literal"===e.type}),d=function(e){let{className:t,style:r,children:n,defaultClassName:a,defaultChildren:o,defaultStyle:i,values:s}=e;return(0,so.useMemo)(()=>{let e,l,u;return e="function"==typeof t?t({...s,defaultClassName:a}):t,l="function"==typeof r?r({...s,defaultStyle:i||{}}):r,u="function"==typeof n?n({...s,defaultChildren:o}):null==n?o:n,{className:e??a,style:l||i?{...i,...l}:void 0,children:u??o,"data-rac":""}},[t,r,n,a,o,i,s])}({...t,values:{...e,isReadOnly:!e.isEditable,isInvalid:n.isInvalid,isDisabled:n.isDisabled,isHovered:c,isFocused:s,isFocusVisible:l},defaultChildren:e.text}),m=(0,so.useCallback)(e=>{e.stopPropagation()},[]);return(0,sl.jsx)("span",{...dd(dR(t),o,i,u),...d,ref:a,style:o.style,"data-placeholder":e.isPlaceholder||void 0,"data-invalid":n.isInvalid||void 0,"data-readonly":!e.isEditable||void 0,"data-disabled":n.isDisabled||void 0,"data-type":e.type,"data-hovered":c||void 0,"data-focused":s||void 0,"data-focus-visible":l||void 0,onClick:m})}),bK={short:!1,size:"md"},bG=(0,so.forwardRef)(function(e,t){let{className:r,defaultValue:n,isDisabled:a,invalid:o,invalidText:i,isInvalid:s,label:l,labelText:u,light:c,maxDate:d,minDate:m,onChange:p,onChangeRaw:f,short:h,size:g,value:y,...v}={...bK,...e},{calendar:b,intlLocale:w,today_:x}=bh(),E=(0,so.useId)(),D=!!(u??l),S=(0,so.useMemo)(()=>vh(n,b),[n,b]),_=(0,so.useMemo)(()=>vh(y,b,!0),[y,b]),C=(0,so.useMemo)(()=>vh(d,b),[d,b]),k=(0,so.useMemo)(()=>vh(m??bg,b),[m,b]),P=(0,so.useMemo)(()=>o||s,[o,s]),R=(0,so.useMemo)(()=>(f&&p&&console.error("An OpenmrsDatePicker component was created with both onChange and onChangeRaw handlers defined. Only onChangeRaw will be used."),f??(e=>p?.(vg(e)))),[f,p]);return(0,sl.jsx)(vf,{locale:w.toString(),children:(0,sl.jsx)("div",{className:ue()("cds--form-item",r),children:(0,sl.jsx)(dp,{values:[[bf,w]],children:(0,sl.jsxs)(vm,{className:ue()("cds--date-picker","cds--date-picker--single",{"cds--date-picker--short":h,"cds--date-picker--light":c}),defaultValue:S,isDisabled:a,isInvalid:P,maxValue:C,minValue:k,value:_,shouldForceLeadingZeros:"en"===w.language||void 0,...v,onChange:R,children:[(0,sl.jsxs)("div",{className:"cds--date-picker-container",children:[D&&(0,sl.jsx)(yd,{className:ue()("cds--label",{"cds--label--disabled":a}),htmlFor:E,children:u??l}),(0,sl.jsxs)(h2,{className:b$,children:[(0,sl.jsx)(bV,{id:D?E:void 0,ref:t,className:ue()("cds--date-picker-input__wrapper","-esm-patient-chart__datepicker-module__inputWrapper___uKdT1",{"-esm-patient-chart__datepicker-module__inputWrapperSm___0RXJc":"sm"===g,"-esm-patient-chart__datepicker-module__inputWrapperMd___4Vff1":"md"===g||!g||0===g.length,"-esm-patient-chart__datepicker-module__inputWrapperLg___VCRm5":"lg"===g}),children:e=>"era"!==e.type?(0,sl.jsx)(bz,{className:bN,segment:e}):(0,sl.jsx)(si().Fragment,{})}),(0,sl.jsx)(m6,{className:ue()(bA,{[bj]:"sm"===g,[bM]:"md"===g||!g||0===g.length,[bL]:"lg"===g}),children:(0,sl.jsx)(bU,{})})]}),(0,sl.jsx)(ys,{className:bI,children:i})]}),(0,sl.jsx)(bB,{variant:"single",today_:x})]})})})})}),bZ=(0,so.forwardRef)(function({className:e,defaultValue:t,invalid:r,invalidText:n,isDisabled:a,isInvalid:o,label:i,labelText:s,light:l,maxDate:u,minDate:c,onChange:d,onChangeRaw:m,size:p="md",value:f,...h},g){let{calendar:y,intlLocale:v,today_:b}=bh(),w=(0,so.useId)(),x=!!(s??i),E=(0,so.useMemo)(()=>{if(f)return{start:vh(f[0],y,!1),end:vh(f[1],y,!1)}},[f,y]),D=(0,so.useMemo)(()=>{if(t)return{start:vh(t[0],y,!1),end:vh(t[1],y,!1)}},[t,y]),S=(0,so.useMemo)(()=>vh(c??bg,y,!0),[c,y]),_=(0,so.useMemo)(()=>vh(u,y,!0),[u,y]),C=(0,so.useMemo)(()=>r||o,[r,o]),k=(0,so.useMemo)(()=>(m&&d&&console.error("An OpenmrsDateRangePicker component was created with both onChange and onChangeRaw handlers defined. Only onChangeRaw will be used."),m??(e=>d?.([vg(e.start),vg(e.end)]))),[m,d]);return(0,sl.jsx)(vf,{locale:v.toString(),children:(0,sl.jsx)("div",{className:ue()("cds--form-item",e),children:(0,sl.jsx)(dp,{values:[[bf,v]],children:(0,sl.jsx)(vp,{id:x?w:void 0,className:ue()("cds--date-picker",{"cds--date-picker--light":l,"cds--date-picker--disabled":a}),isInvalid:C,shouldForceLeadingZeros:"en"===v.language||void 0,maxValue:_,minValue:S,value:E,defaultValue:D,ref:g,isDisabled:a,...h,onChange:k,children:(0,sl.jsxs)("div",{className:"cds--date-picker-container",children:[x&&(0,sl.jsx)(yd,{className:ue()("cds--label",{"cds--label--disabled":a}),htmlFor:w,children:s??i}),(0,sl.jsxs)(h2,{className:b$,children:[(0,sl.jsxs)("div",{className:ue()("-esm-patient-chart__datepicker-module__inputsWrapper___xXRQI",{"-esm-patient-chart__datepicker-module__inputsWrapperSm___nL+b6":"sm"===p,"-esm-patient-chart__datepicker-module__inputsWrapperMd___Kgcps":"md"===p||!p||0===p.length,"-esm-patient-chart__datepicker-module__inputsWrapperLg___raaSN":"lg"===p}),children:[(0,sl.jsx)(g6,{className:ue()("cds--date-picker-input__wrapper","-esm-patient-chart__datepicker-module__startInput___cWw-5",bO),slot:"start",children:e=>(0,sl.jsx)(bz,{className:bN,segment:e})}),(0,sl.jsx)("div",{className:"-esm-patient-chart__datepicker-module__separator___Ddb4g",children:(0,sl.jsx)("span",{"aria-hidden":"true","data-readonly":!0,children:"–"})}),(0,sl.jsx)(g6,{className:ue()("cds--date-picker-input__wrapper","-esm-patient-chart__datepicker-module__endInput___xdYOl",bO),slot:"end",children:e=>(0,sl.jsx)(bz,{className:bN,segment:e})})]}),(0,sl.jsx)(m6,{className:ue()(bA,{[bj]:"sm"===p,[bM]:"md"===p||!p||0===p.length,[bL]:"lg"===p}),children:(0,sl.jsx)(bU,{})})]}),(0,sl.jsx)(ys,{className:bI,children:n}),(0,sl.jsx)(bB,{variant:"range",today_:b,minDate:S,maxDate:_})]})})})})})}),bY=si().createContext(null);function bq(e){let{children:t}=e,r=(0,so.useContext)(bY),[n,a]=(0,so.useState)(0),o=(0,so.useMemo)(()=>({parent:r,modalCount:n,addModal(){a(e=>e+1),r&&r.addModal()},removeModal(){a(e=>e-1),r&&r.removeModal()}}),[r,n]);return si().createElement(bY.Provider,{value:o},t)}function bJ(e){let t,{modalProviderProps:r}={modalProviderProps:{"aria-hidden":!!(t=(0,so.useContext)(bY))&&t.modalCount>0||void 0}};return si().createElement("div",{"data-overlay-container":!0,...e,...r})}function bX(e){return si().createElement(bq,null,si().createElement(bJ,e))}function bQ(e){let t=da(),{portalContainer:r=t?null:document.body,...n}=e,{getContainer:a}=ye();if(!e.portalContainer&&a&&(r=a()),si().useEffect(()=>{if(r?.closest("[data-overlay-container]"))throw Error("An OverlayContainer must not be inside another container. Please change the portalContainer prop.")},[r]),!r)return null;let o=si().createElement(bX,n);return mM().createPortal(o,r)}let b0=si().createContext(null),b1=si().forwardRef(function(e,t){let{children:r,...n}=e,a=c1(t),o={...n,ref:a};return si().createElement(b0.Provider,{value:o},r)}),b4={},b2=0,b3=!1,b6=null,b5=null;function b9(e={}){let{delay:t=1500,closeDelay:r=500}=e,{isOpen:n,open:a,close:o}=vr(e),i=(0,so.useMemo)(()=>`${++b2}`,[]),s=(0,so.useRef)(null),l=(0,so.useRef)(o),u=()=>{b4[i]=m},c=()=>{for(let e in b4)e!==i&&(b4[e](!0),delete b4[e])},d=()=>{s.current&&clearTimeout(s.current),s.current=null,c(),u(),b3=!0,a(),b6&&(clearTimeout(b6),b6=null),b5&&(clearTimeout(b5),b5=null)},m=e=>{e||r<=0?(s.current&&clearTimeout(s.current),s.current=null,l.current()):s.current||(s.current=setTimeout(()=>{s.current=null,l.current()},r)),b6&&(clearTimeout(b6),b6=null),b3&&(b5&&clearTimeout(b5),b5=setTimeout(()=>{delete b4[i],b5=null,b3=!1},Math.max(500,r)))};return(0,so.useEffect)(()=>{l.current=o},[o]),(0,so.useEffect)(()=>()=>{s.current&&clearTimeout(s.current),b4[i]&&delete b4[i]},[i]),{isOpen:n,open:e=>{e||!(t>0)||s.current?d():(c(),u(),n||b3?n||d():(b6&&clearTimeout(b6),b6=setTimeout(()=>{b6=null,b3=!0,d()},t)))},close:m}}let b8=(0,so.createContext)(null),b7=(0,so.createContext)(null);function we(e){let t=b9(e),r=(0,so.useRef)(null),{triggerProps:n,tooltipProps:a}=function(e,t,r){let{isDisabled:n,trigger:a,shouldCloseOnPress:o=!0}=e,i=dl(),s=(0,so.useRef)(!1),l=(0,so.useRef)(!1),u=()=>{(s.current||l.current)&&t.open(l.current)},c=e=>{s.current||l.current||t.close(e)};(0,so.useEffect)(()=>{let e=e=>{r&&r.current&&"Escape"===e.key&&(e.stopPropagation(),t.close(!0))};if(t.isOpen)return document.addEventListener("keydown",e,!0),()=>{document.removeEventListener("keydown",e,!0)}},[r,t]);let d=()=>{o&&(l.current=!1,s.current=!1,c(!0))},{hoverProps:m}=m0({isDisabled:n,onHoverStart:()=>{"focus"!==a&&("pointer"===d8?s.current=!0:s.current=!1,u())},onHoverEnd:()=>{"focus"!==a&&(l.current=!1,s.current=!1,c())}}),{focusableProps:p}=mD({isDisabled:n,onFocus:()=>{mm()&&(l.current=!0,u())},onBlur:()=>{l.current=!1,s.current=!1,c(!0)}},r);return{triggerProps:{"aria-describedby":t.isOpen?i:void 0,...dd(p,m,{onPointerDown:d,onKeyDown:d}),tabIndex:void 0},tooltipProps:{id:i}}}(e,t,r);return si().createElement(dp,{values:[[b8,t],[b7,{...a,triggerRef:r}]]},si().createElement(b1,{...n,ref:r},e.children))}let wt=(0,so.forwardRef)(function({UNSTABLE_portalContainer:e,...t},r){[t,r]=dg(t,r,b7);let n=(0,so.useContext)(b8),a=b9(t),o=null==t.isOpen&&null==t.defaultOpen&&n?n:a,i=yJ(r,o.isOpen)||t.isExiting||!1;return o.isOpen||i?si().createElement(bQ,{portalContainer:e},si().createElement(wr,{...t,tooltipRef:r,isExiting:i})):null});function wr(e){let t=(0,so.useContext)(b8),r=(0,so.useRef)(null),[n,a]=(0,so.useState)(0);c6(()=>{r.current&&t.isOpen&&a(r.current.getBoundingClientRect().width)},[t.isOpen,r]);let{overlayProps:o,arrowProps:i,placement:s}=yj({placement:e.placement||"top",targetRef:e.triggerRef,overlayRef:e.tooltipRef,offset:e.offset,crossOffset:e.crossOffset,isOpen:t.isOpen,arrowSize:n,arrowBoundaryOffset:e.arrowBoundaryOffset,shouldFlip:e.shouldFlip,onClose:()=>t.close(!0)}),l=yq(e.tooltipRef,!!s)||e.isEntering||!1,u=df({...e,defaultClassName:"react-aria-Tooltip",values:{placement:s,isEntering:l,isExiting:e.isExiting,state:t}}),{tooltipProps:c}=function(e,t){let r=dR(e,{labelable:!0}),{hoverProps:n}=m0({onHoverStart:()=>t?.open(!0),onHoverEnd:()=>t?.close()});return{tooltipProps:dd(r,n,{role:"tooltip"})}}(e=dd(e,o),t);return si().createElement("div",{...c,ref:e.tooltipRef,...u,style:{...o.style,...u.style},"data-placement":null!=s?s:void 0,"data-entering":l||void 0,"data-exiting":e.isExiting||void 0},si().createElement(ym.Provider,{value:{...i,placement:s,ref:r}},u.children))}let wn=({diagnoses:e,showCertainty:t=!1})=>{let{diagnosisTags:r}=s5({externalModuleName:"@openmrs/esm-styleguide"});return(0,sl.jsx)("div",{className:"-esm-patient-chart__diagnosis-tags-module__container___1iigI",children:e.map(e=>{let n=t&&"PROVISIONAL"===e.certainty,a=1===e.rank?r?.primaryColor??"blue":r?.secondaryColor??"gray";return(0,sl.jsx)(wa,{color:a,isProvisional:n,name:e.display},e.uuid)})})};function wa({color:e,isProvisional:t,name:r}){let[n,a]=(0,so.useState)(!1),[o,i]=(0,so.useState)(!1),[s,l]=(0,so.useState)(!1),u=s||o,c=(0,so.useRef)(null);(0,so.useLayoutEffect)(()=>{let e=c.current;if(!e)return;let t=()=>{let t=e.scrollWidth>e.clientWidth;l(t),t||a(!1)};t();let r=new ResizeObserver(t);return r.observe(e),()=>r.disconnect()},[r,t,u]);let d=ue()("cds--tag","cds--tag--md","cds--layout--size-md",`cds--tag--${e}`,"-esm-patient-chart__diagnosis-tags-module__diagnosisTag___mQ28X"),m=(0,sl.jsxs)(sl.Fragment,{children:[t&&(0,sl.jsxs)(sl.Fragment,{children:[(0,sl.jsx)("span",{"aria-hidden":"true",className:"-esm-patient-chart__diagnosis-tags-module__provisionalMark___S+J53",children:"?"}),(0,sl.jsxs)("span",{className:"cds--visually-hidden",children:[nB("provisional","Provisional")," "]})]}),(0,sl.jsx)("span",{ref:c,className:"cds--tag__label",children:r})]});return u?(0,sl.jsxs)(we,{delay:0,closeDelay:150,isOpen:n,onOpenChange:a,children:[(0,sl.jsx)(m6,{className:d,"data-testid":"diagnosis-tag",onFocusChange:i,onPress:()=>a(!0),children:m}),(0,sl.jsx)(wt,{className:"-esm-patient-chart__diagnosis-tags-module__tagTooltip___50O3+",placement:"bottom",offset:4,containerPadding:8,children:r})]}):(0,sl.jsx)("span",{className:d,"data-testid":"diagnosis-tag",children:m})}let wo={action:"-esm-patient-chart__empty-card-module__action___oG778",content:"-esm-patient-chart__empty-card-module__content___YUXvR",desktopHeading:"-esm-patient-chart__empty-card-module__desktopHeading___EljiH",tabletHeading:"-esm-patient-chart__empty-card-module__tabletHeading___8mc7w",tile:"-esm-patient-chart__empty-card-module__tile___3-rRO"},wi=({width:e="64",height:t="64"})=>(0,sl.jsx)("svg",{width:e,height:t,viewBox:"0 0 64 64",children:(0,sl.jsx)("use",{href:"#omrs-empty-data-illustration"})}),ws=e=>{let t="tablet"===lD(),r=e.launchForm;return(0,sl.jsx)(uo.Layer,{className:wo.layer,children:(0,sl.jsxs)(uo.Tile,{className:wo.tile,children:[(0,sl.jsx)("div",{className:t?wo.tabletHeading:wo.desktopHeading,children:(0,sl.jsx)("h4",{children:e.headerTitle})}),(0,sl.jsx)(wi,{}),(0,sl.jsx)("p",{className:wo.content,children:nB("emptyStateText","There are no {{displayText}} to display",{displayText:e.displayText})}),(0,sl.jsx)("p",{className:wo.action,children:r&&(0,sl.jsx)(uo.Button,{onClick:()=>r(),kind:"ghost",size:t?"lg":"sm",children:nB("recordNewEntry","Record {{ displayText }}",{displayText:e.displayText})})})]})})},wl=({error:e,headerTitle:t})=>{let r="tablet"===lD();return(0,sl.jsx)(uo.Layer,{children:(0,sl.jsxs)(uo.Tile,{className:"-esm-patient-chart__error-state-module__tile___mzWLn",children:[(0,sl.jsx)("div",{className:r?"-esm-patient-chart__error-state-module__tabletHeading___l7Cpn":"-esm-patient-chart__error-state-module__desktopHeading___p57fl",children:(0,sl.jsx)("h4",{children:t})}),(0,sl.jsxs)("p",{className:"-esm-patient-chart__error-state-module__errorMessage___0fU6v",children:[nB("error","Error")," ",`${e?.response?.status}: `,e?.response?.statusText]}),(0,sl.jsx)("p",{className:"-esm-patient-chart__error-state-module__errorCopy___xkVog",children:nB("errorCopy")})]})})},wu=wl,wc=si().forwardRef((e,t)=>{let{slotName:r,basePath:n,componentContext:a,state:o}=lC(),i=window.location??{pathname:""},s=sx(r??"");return e.isChildOfHeader&&r&&s.length>0?(0,sl.jsxs)(uo.SideNav,{"aria-label":nB("leftNavigation","Left navigation"),className:"-esm-patient-chart__left-nav-module__leftNav___czP9T",expanded:!0,isFixedNav:!0,ref:t,...e,children:[(0,sl.jsx)(sS,{name:"global-nav-menu-slot"}),r?(0,sl.jsx)(sY,{value:a,fallback:(0,sl.jsx)(sS,{name:r,state:{basePath:n,currentPath:i,...o}}),children:(0,sl.jsx)(ss.Provider,{value:a,children:(0,sl.jsx)(sS,{name:r,state:{basePath:n,currentPath:i,...o}})})}):null]}):null}),wd=({selectedLocationUuid:e,defaultLocationUuid:t,locationTag:r,locationsPerRequest:n=50,onChange:a})=>{let[o,i]=(0,so.useState)(""),s=(0,so.useId)(),{location:l}=function(e){let t=e?`/ws/fhir2/R4/Location?_id=${e}`:null,{data:r,error:n,isLoading:a}=le()(t,n2,{shouldRetryOnError:e=>!!e?.response?.status&&e.response.status>=500});return(0,so.useMemo)(()=>({location:r?.data?.entry?r.data.entry[0]:null,error:t?n:null,isLoading:!!t&&a}),[r,a,n,t])}(t),{locations:u,isLoading:c,hasMore:d,loadingNewData:m,error:p,setPage:f}=function(e,t=0,r=""){let n=s8(r),{data:a,isLoading:o,isValidating:i,setSize:s,error:l}=lh()(function(r,a){if(a){let e=a.data?.link?.find(e=>"next"===e.relation);if(!e)return null;let t=new URL(e.url);return t.origin===window.location.origin?e.url:new URL(`${t.pathname}${t.search?`?${t.search}`:""}`,window.location.origin).toString()}let o=`${n0}/Location?`,i=new URLSearchParams;return i.append("_summary","data"),t&&i.append("_count",""+t),r&&i.append("_getpagesoffset",""+r*t),e&&i.append("_tag",e),"string"==typeof n&&""!==n&&i.append("name:contains",n),o+i.toString()},n2);return(0,so.useMemo)(()=>({locations:a?.length?a?.flatMap(e=>e?.data?.entry??[]):[],isLoading:o,totalResults:a?.[0]?.data?.total,hasMore:!!a?.length&&a?.[a.length-1]?.data?.link?.some(e=>"next"===e.relation),loadingNewData:i,error:l||null,setPage:s}),[o,a,i,s,l])}(r,n,o),h=(0,so.useMemo)(()=>l&&!o&&t?[l,...u.filter(({resource:e})=>e.id!==t)]:u??[],[l,u,t,o]),g=(0,so.useCallback)(e=>{a(),i(e.trim())},[a]),y=lT((0,so.useCallback)(()=>{!m&&d&&f(e=>e+1)},[m,d,f])),v=d?Math.max(0,Math.floor(h.length-n/2)):-1;return(0,sl.jsxs)(sl.Fragment,{children:[(0,sl.jsx)(uo.Search,{"aria-describedby":p?`${s}-error`:void 0,labelText:nB("searchForLocation"),id:s,placeholder:nB("searchForLocation"),onChange:e=>g(e.target.value),size:"lg"}),p&&(0,sl.jsx)("div",{className:"-esm-patient-chart__location-picker-module__errorNotification___NfvTe",id:`${s}-error`,children:(0,sl.jsx)(uo.InlineNotification,{kind:"error",subtitle:nB("errorLoadingLoginLocations","Unable to load login locations. Please try again or contact support if the problem persists."),title:nB("error","Error")})}),(0,sl.jsx)("div",{className:"-esm-patient-chart__location-picker-module__searchResults___agplm",children:c?(0,sl.jsx)("div",{className:"-esm-patient-chart__location-picker-module__loadingContainer___EHghS",children:Array.from({length:5}).map((e,t)=>(0,sl.jsx)(uo.RadioButtonSkeleton,{className:"-esm-patient-chart__location-picker-module__radioButtonSkeleton___up5rH",role:"progressbar"},t))}):(0,sl.jsxs)(sl.Fragment,{children:[(0,sl.jsx)("div",{className:"-esm-patient-chart__location-picker-module__locationResultsContainer___06YOS",children:h.length>0?(0,sl.jsx)(uo.RadioButtonGroup,{name:"loginLocations",onChange:e=>{a(e?.toString())},orientation:"vertical",valueSelected:e,children:h.map((e,t)=>(0,sl.jsx)(uo.RadioButton,{className:"-esm-patient-chart__location-picker-module__locationRadioButton___yKif7",id:e.resource.id,labelText:(0,sl.jsx)("span",{ref:t===v?y:null,children:e.resource.name}),name:e.resource.name,value:e.resource.id},e.resource.id))}):(0,sl.jsx)("div",{className:"-esm-patient-chart__location-picker-module__emptyState___cPWp8",children:(0,sl.jsx)("p",{className:"-esm-patient-chart__location-picker-module__locationNotFound___b14++",children:nB("noResultsToDisplay")})})}),m&&(0,sl.jsx)("div",{className:"-esm-patient-chart__location-picker-module__loadingIcon___GVlrq",children:(0,sl.jsx)(uo.InlineLoading,{description:nB("loading")})})]})})]})},wm=B("modalState",{modalContainer:null,modalStack:[]}),wp=0;async function wf(e,t,r={}){let n=iQ(t),a=null;if(e){if(!n)throw Error(`No modal named '${t}' has been registered.`);let{load:o}=n,i=await o(),s=wp++;a=await st({...i,name:`${t}-${s}`},{...r,domElement:e})}else k(`Failed to launch modal. Please notify your administrator. Modal name: ${t}`);return a}function wh(e){return"TO_BE_DELETED"===e.state||"DELETED"===e.state}function wg(e,t){t?.unmount&&(t.unmountPromise?.catch(()=>{}),t.unmount().catch(t=>{console.error(`The modal '${e}' failed to unmount`,t)}))}function wy(e){return e.find(e=>!wh(e))}function wv(e,t){e.container&&(e.container.style.visibility=t?"unset":"hidden")}let wb=window.getComputedStyle(document.body).overflow;function ww({modalStack:e,modalContainer:t}){if(t)if(e.length){t.style.visibility||(addEventListener("keydown",wE),document.body.style.overflow="hidden",t.style.visibility="unset");let r=wy(e);e.forEach(e=>{switch(e.state){case"NEW":{let r=function({size:e}){let t=document.createElement("div");return t.className=`cds--modal-container cds--modal-container--${e}`,t.setAttribute("role","dialog"),t.setAttribute("tabindex","-1"),t.setAttribute("aria-modal","true"),t}({size:e.props?.size??"md"});e.container=r,e.state="MOUNTING",wf(r,e.modalName,e.props).then(n=>{wh(e)?wg(e.modalName,n):n?(e.parcel=n,t.prepend(r),wv(e,wy(wm.getState().modalStack)===e),n.mountPromise.then(()=>{wh(e)||(e.state="MOUNTED")},t=>{k(t),e.parcel=null,wx(e)})):wx(e)},t=>{k(t),wx(e)});break}case"MOUNTING":case"MOUNTED":wv(e,e===r);break;case"TO_BE_DELETED":e.state="DELETED",e.onClose(),wg(e.modalName,e.parcel),e.container?.remove(),setTimeout(()=>{let t=wm.getState();wm.setState({...t,modalStack:t.modalStack.filter(t=>t!==e)})},0)}})}else t.style.removeProperty("visibility"),document.body.style.overflow=wb,removeEventListener("keydown",wE)}function wx(e){if(wh(e))return;e.state="TO_BE_DELETED";let t=wm.getState();wm.setState({...t,modalStack:[...t.modalStack]})}function wE(e){"Escape"===e.key&&function(){let[e]=wm.getState().modalStack;e&&wx(e)}()}function wD(e){wm.subscribe(ww),wm.setState({...wm.getState(),modalContainer:e})}function wS(e,t={},r=()=>{}){let n=()=>{let e=wm.getState().modalStack.find(e=>e.onClose===r);e&&wx(e)};if(iQ(e)){var a;let o,i;a={state:"NEW",onClose:r,modalName:e,props:{close:n,...t}},i=[a,...(o=wm.getState()).modalStack],wm.setState({...o,modalStack:i})}else k(`Failed to launch modal. Please notify your administrator. Modal name: "${e}"`);return n}var w_=r(5992);let wC=({notification:e})=>{let{description:t,action:r,kind:n,critical:a,title:o,onAction:i}=e;return(0,sl.jsx)(uo.ActionableNotification,{actionButtonLabel:r,kind:n||"info",lowContrast:a,subtitle:t,title:o||"",inline:!0,onActionButtonClick:i})},wk=({subject:e})=>{let[t,r]=(0,so.useState)([]);return(0,so.useEffect)(()=>{let t=e.subscribe(e=>r(t=>[...t.filter(t=>t.description!==e.description||t.action!==e.action||t.kind!==e.kind||t.title!==e.title),e]));return()=>t.unsubscribe()},[e]),(0,sl.jsx)(sl.Fragment,{children:t.map(e=>(0,sl.jsx)(wC,{notification:e},e.id))})},wP=({notification:e})=>{let{actionButtonLabel:t,onActionButtonClick:r=()=>{},subtitle:n,kind:a,title:o,critical:i,progressActionLabel:s,id:l,...u}=e,[c,d]=(0,so.useState)(t);return(0,sl.jsx)(uo.ActionableNotification,{kind:a||"info",actionButtonLabel:c,ariaLabel:nB("closesActionableNotification","Closes actionable notification"),onActionButtonClick:()=>{r(),s&&d(s)},statusIconDescription:nB("actionableNotification","Actionable notification"),subtitle:n,title:o,lowContrast:i,inline:!0,...u})},wR=({subject:e})=>{let[t,r]=(0,so.useState)([]);return(0,so.useEffect)(()=>{let t=e.subscribe(e=>r(t=>[...t.filter(t=>t.subtitle!==e.subtitle||t.actionButtonLabel!==e.actionButtonLabel||t.onActionButtonClick!==e.onActionButtonClick||t.kind!==e.kind||t.title!==e.title),e]));return()=>t.unsubscribe()},[e]),(0,sl.jsx)(sl.Fragment,{children:t.map(e=>(0,sl.jsx)(wP,{notification:e},e.id))})};class wT{subscribe(e){return this.listeners.add(e),{unsubscribe:()=>{this.listeners.delete(e)}}}next(e){for(let t of[...this.listeners])t(e)}constructor(){!function(e,t,r){t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r}(this,"listeners",new Set)}}let w$=new wT,wN=0,wO=new wT,wI=0;function wA(e){e&&(0,s_.createRoot)(e).render((0,sl.jsx)(wk,{subject:w$}))}function wM(e){var t;e&&("string"==typeof(t=e.description)?t.trim().length>0:"object"==typeof t&&(t instanceof Error||!(0,w_.A)(t)))?(e.description instanceof Error&&(e.description=e.description.toLocaleString()),setTimeout(()=>{w$.next({...e,id:wN++})},0)):console.error("showNotification must be called with an object having a 'description' property that is a non-empty string or object")}function wj(e){e&&(0,s_.createRoot)(e).render((0,sl.jsx)(wR,{subject:wO}))}function wL(e){var t;e&&("string"==typeof(t=e.actionButtonLabel)?t.trim().length>0:"object"==typeof t&&!(0,w_.A)(t))?setTimeout(()=>{wO.next({...e,id:wI++})},0):console.error("showActionableNotification must be called with an actionButtonLabel that is a non-empty string")}let wF=["NORMAL","HIGH","CRITICALLY_HIGH","OFF_SCALE_HIGH","LOW","CRITICALLY_LOW","OFF_SCALE_LOW"],wB=["critically_low","critically_high","high","low","normal","off_scale_low","off_scale_high"],wV={container:"-esm-patient-chart__numeric-observation-module__container___gS0Wg",card:"-esm-patient-chart__numeric-observation-module__card___w0fF5","abnormal-value":"-esm-patient-chart__numeric-observation-module__abnormal-value___xuX3W","critical-value":"-esm-patient-chart__numeric-observation-module__critical-value___Jynsn",cell:"-esm-patient-chart__numeric-observation-module__cell___tMhBJ","critically-high":"-esm-patient-chart__numeric-observation-module__critically-high___3L2wx","critically-low":"-esm-patient-chart__numeric-observation-module__critically-low___XP+HX",high:"-esm-patient-chart__numeric-observation-module__high___JV9do",low:"-esm-patient-chart__numeric-observation-module__low___-uDKD","label-container":"-esm-patient-chart__numeric-observation-module__label-container___vTf2y","value-container":"-esm-patient-chart__numeric-observation-module__value-container___xTUIC",label:"-esm-patient-chart__numeric-observation-module__label___-pfmb",value:"-esm-patient-chart__numeric-observation-module__value___1A4zt",units:"-esm-patient-chart__numeric-observation-module__units___SzvX+","pad-right":"-esm-patient-chart__numeric-observation-module__pad-right___ND9XL","off-scale-low":"-esm-patient-chart__numeric-observation-module__off-scale-low___gFAv9","off-scale-high":"-esm-patient-chart__numeric-observation-module__off-scale-high___aSEmX",arrow:"-esm-patient-chart__numeric-observation-module__arrow___9bvsX"},wU=({value:e,unit:t,label:r,interpretation:n,referenceRange:a,conceptUuid:o,variant:i="card",patientUuid:s})=>{let l=(0,so.useId)(),{referenceRange:u,isLoading:c}=function(e,t){let r=null;e&&(r=t?`${nQ}/conceptreferencerange/?patient=${t}&concept=${e}&v=full`:`${nQ}/conceptreferencerange/?concept=${e}&v=full`);let{data:n,error:a,isLoading:o}=le()(r,n2),i=n?.data?.results?.[0];return{referenceRange:i?{hiNormal:i.hiNormal??null,hiAbsolute:i.hiAbsolute??null,hiCritical:i.hiCritical??null,lowNormal:i.lowNormal??null,lowAbsolute:i.lowAbsolute??null,lowCritical:i.lowCritical??null}:void 0,error:a,isLoading:o}}(a||n?void 0:o,s),d=a??u,m=(0,so.useMemo)(()=>{if(n)return n?"--"===n?"normal":wF.includes(n)?n.toLowerCase():wB.includes(n)?n:"normal":void 0;if(d&&!c){if(!d||null==e||""===e)return"normal";let t="string"==typeof e?Number.parseFloat(e):e;return Number.isNaN(t)?"normal":null!==d.hiAbsolute&&void 0!==d.hiAbsolute&&t>d.hiAbsolute?"off_scale_high":null!==d.hiCritical&&void 0!==d.hiCritical&&t>=d.hiCritical?"critically_high":null!==d.hiNormal&&void 0!==d.hiNormal&&t>d.hiNormal?"high":null!==d.lowAbsolute&&void 0!==d.lowAbsolute&&t<d.lowAbsolute?"off_scale_low":null!==d.lowCritical&&void 0!==d.lowCritical&&t<=d.lowCritical?"critically_low":null!==d.lowNormal&&void 0!==d.lowNormal&&t<d.lowNormal?"low":"normal"}return"normal"},[n,d,e,c])??"normal",p="critically_low"===m||"critically_high"===m||"off_scale_low"===m||"off_scale_high"===m,f="normal"!==m,h=r?`omrs-numeric-obs-label-${r.replaceAll(/\s+/g,"-").toLowerCase()}-${l}`:void 0,g=`omrs-numeric-obs-value-${l}`,y=`omrs-numeric-obs-unit-${l}`,v=null!=e&&""!==e,b=v?e:nB("notAvailable","Not available"),w=ue()({[wV["critically-low"]]:"critically_low"===m||"off_scale_low"===m,[wV["critically-high"]]:"critically_high"===m||"off_scale_high"===m,[wV.low]:"low"===m,[wV.high]:"high"===m,[wV["off-scale-low"]]:"off_scale_low"===m,[wV["off-scale-high"]]:"off_scale_high"===m}),x=ue()({[wV.container]:!0,[wV.card]:!0,[wV["critical-value"]]:p,[wV["abnormal-value"]]:f&&!p}),E=ue()({[wV.cell]:!0,[w]:!0});return"cell"===i?(0,sl.jsxs)("div",{className:E,children:[b,v&&t?` ${t}`:""]}):(0,sl.jsxs)("section",{className:x,"data-testid":"numeric-observation-card",children:[r&&(0,sl.jsxs)("div",{className:wV["label-container"],children:[(0,sl.jsx)("span",{id:h,className:wV.label,children:r}),f&&(0,sl.jsx)("span",{className:wV[m.replace("_","-")],title:nB("abnormalValue","Abnormal value")})]}),(0,sl.jsxs)("div",{className:wV["value-container"],children:[(0,sl.jsx)("span",{id:g,"aria-labelledby":h&&y?`${h} ${y}`:h||y||void 0,className:wV.value,children:b}),v&&t&&(0,sl.jsx)("span",{id:y,className:wV.units,children:t})]})]})},wW="-esm-patient-chart__page-header-module__pageHeader___6TOjO",wH=e=>{if("children"in e){let{children:t,className:r,...n}=e;return(0,sl.jsx)("div",{className:ue()(wW,r),...n,children:t})}{let{title:t,illustration:r,className:n,...a}=e;return(0,sl.jsx)("div",{className:ue()(wW,n),...a,children:(0,sl.jsx)(wz,{title:t,illustration:r})})}},wz=({title:e,illustration:t,className:r})=>{let[n,a]=(0,so.useState)(null);return(0,so.useEffect)(()=>{rD("@openmrs/esm-styleguide").then(e=>{a(e)})},[]),(0,sl.jsxs)("div",{className:ue()("-esm-patient-chart__page-header-module__pageHeaderContent___mCImT",r),children:[t,(0,sl.jsxs)("div",{className:"-esm-patient-chart__page-header-module__pageLabels___kqDS+",children:[n?.implementationName&&(0,sl.jsx)("p",{children:nB(n.implementationName)}),(0,sl.jsx)("h1",{className:"-esm-patient-chart__page-header-module__pageName___SbZBC",children:e})]})]})},wK=({totalItems:e,pageSize:t,onPageNumberChange:r,pageNumber:n,dashboardLinkUrl:a,currentItems:o,dashboardLinkLabel:i})=>{let{pageSizes:s,pageItemsCount:l}=lO(t,e,n,o),u="tablet"===lD(),c=nB("paginationItemsCount","{{pageItemsCount}} / {{totalItems}} items",{totalItems:e,pageItemsCount:l});return(0,sl.jsx)(sl.Fragment,{children:e>0&&(0,sl.jsxs)("div",{className:ue()({"-esm-patient-chart__pagination-module__tablet___82gj1":u,"-esm-patient-chart__pagination-module__desktop___6yI8e":!u}),children:[(0,sl.jsxs)("div",{children:[c,a&&(0,sl.jsx)(su,{to:a,className:"-esm-patient-chart__pagination-module__configurableLink___oIqma",children:i??nB("seeAll","See all")})]}),(0,sl.jsx)(uo.Pagination,{className:"-esm-patient-chart__pagination-module__pagination___A-Lcg",page:n,pageSize:t,pageSizes:s,totalItems:e,onChange:r,pageRangeText:(e,t)=>nB("paginationOfPages","of {{count}} pages",{count:t}),size:u?"lg":"sm"})]})})};function wG(e){return wY(wJ(e,"usual","official"))}function wZ(e){return wG(e)}function wY(e){var t;let r;return e?e.text??(r=(t=e).given??[],(t.family?r.concat(t.family):r).join(" ")):""}function wq(e){return wY(e)}function wJ(e,...t){for(let r of(0==t.length&&(t=["usual"]),t)){let t=e.name?.find(e=>{var t,n;return t=e,n=r,t.use?t.use===n:"usual"===n});if(t)return t}}function wX(e,t=lU()()){let r=lU()(t),n=bs(e,r);if(null==n)return null;let a=r.diff(n,"hours"),o=r.diff(n,"days"),i=r.diff(n,"weeks"),s=r.diff(n,"months"),l=r.diff(n,"years"),u={};if(a<2)u.minutes=r.diff(n,"minutes");else if(o<2)u.hours=a;else if(i<4)u.days=o;else if(l<1){let e=r.subtract(i,"weeks").diff(n,"days");u.weeks=i,u.days=e}else if(l<2){let e=r.subtract(s,"months").diff(n,"days");u.months=s,u.days=e}else if(l<18){let e=r.subtract(l,"year").diff(n,"months");u.years=l,u.months=e}else u.years=l;return u}function wQ(e,t=lU()()){let r=wX(e,t);if(null==r)return null;let n={style:"short",localeMatcher:"lookup"};return"minutes"in r&&0===r.minutes&&(n.minutesDisplay="always"),bi(r,n)}let w0={container:"-esm-patient-chart__patient-banner-patient-info-module__container___iC32K",activePatientContainer:"-esm-patient-chart__patient-banner-patient-info-module__activePatientContainer___OoDPd",patientBanner:"-esm-patient-chart__patient-banner-patient-info-module__patientBanner___swajU",patientName:"-esm-patient-chart__patient-banner-patient-info-module__patientName___+2+Xi",patientAvatar:"-esm-patient-chart__patient-banner-patient-info-module__patientAvatar___Rdf75",patientAvatarButton:"-esm-patient-chart__patient-banner-patient-info-module__patientAvatarButton___A1q8c",patientInfo:"-esm-patient-chart__patient-banner-patient-info-module__patientInfo___L-cOQ",demographics:"-esm-patient-chart__patient-banner-patient-info-module__demographics___IDhb0",row:"-esm-patient-chart__patient-banner-patient-info-module__row___TP7gU",flexRow:"-esm-patient-chart__patient-banner-patient-info-module__flexRow___vNMt2",tagsSlot:"-esm-patient-chart__patient-banner-patient-info-module__tagsSlot___0Dvjn",identifiers:"-esm-patient-chart__patient-banner-patient-info-module__identifiers___d3GTJ",identifier:"-esm-patient-chart__patient-banner-patient-info-module__identifier___kc6eq",primaryIdentifier:"-esm-patient-chart__patient-banner-patient-info-module__primaryIdentifier___ZxRUU",secondaryIdentifier:"-esm-patient-chart__patient-banner-patient-info-module__secondaryIdentifier___eQh8x",value:"-esm-patient-chart__patient-banner-patient-info-module__value___CoAOR",tag:"-esm-patient-chart__patient-banner-patient-info-module__tag___InccN",gender:"-esm-patient-chart__patient-banner-patient-info-module__gender___vfinx",separator:"-esm-patient-chart__patient-banner-patient-info-module__separator___3OIBl",tooltipPadding:"-esm-patient-chart__patient-banner-patient-info-module__tooltipPadding___hBqWG",tooltipSmallText:"-esm-patient-chart__patient-banner-patient-info-module__tooltipSmallText___bPnkq",actionsButtonText:"-esm-patient-chart__patient-banner-patient-info-module__actionsButtonText___VNvm7"};function w1({showIdentifierLabel:e,type:t,value:r}){return(0,sl.jsx)("span",{className:w0.primaryIdentifier,children:(0,sl.jsxs)(uo.Tag,{className:w0.tag,type:"gray",children:[e&&t?.text&&(0,sl.jsxs)("span",{className:w0.label,children:[t.text,": "]}),(0,sl.jsx)("span",{className:w0.value,children:r})]})})}function w4({showIdentifierLabel:e,type:t,value:r}){return(0,sl.jsxs)(uo.FormLabel,{className:w0.secondaryIdentifier,id:`patient-banner-identifier-${r}`,children:[e&&(0,sl.jsxs)("span",{className:w0.label,children:[t?.text,": "]}),(0,sl.jsx)("span",{className:w0.value,children:r})]})}function w2({identifiers:e,showIdentifierLabel:t}){let{excludePatientIdentifierCodeTypes:r}=s5(),{primaryIdentifierCode:n}=lM(),a=e?.filter(e=>{let t=e.type?.coding?.[0]?.code;return t&&!r?.uuids.includes(t)})??[];return(0,sl.jsx)(sl.Fragment,{children:a?.length?a.map(({value:e,type:r},o)=>(0,sl.jsxs)(si().Fragment,{children:[(0,sl.jsx)("span",{className:w0.identifier,children:r?.coding?.[0]?.code===n?(0,sl.jsx)(w1,{showIdentifierLabel:t,type:r,value:e}):(0,sl.jsx)(w4,{showIdentifierLabel:t,type:r,value:e})}),o<a.length-1&&(0,sl.jsx)("span",{className:w0.separator,children:"\xb7"})]},e)):""})}let w3={Female:uq,Male:uJ,Other:uX,Unknown:uQ},w6=({gender:e})=>{let t=w3[e];return t?(0,sl.jsx)(t,{fill:"#525252"}):null},w5={male:"Male",female:"Female",other:"Other",unknown:"Unknown"};function w9({patient:e,renderedFrom:t}){var r;let n,a,o=wG(e),i=e?.gender&&(a=w5[n=(r=e.gender).toLowerCase()]??"Unknown",{displayText:nB(n,r),iconKey:a}),s=(0,so.useMemo)(()=>({patientUuid:e.id,patient:e,renderedFrom:t}),[e.id,e,t]);return(0,sl.jsxs)("div",{className:w0.patientInfo,children:[(0,sl.jsx)("div",{className:ue()(w0.row,w0.patientNameRow),children:(0,sl.jsxs)("div",{className:w0.flexRow,children:[(0,sl.jsx)("span",{className:w0.patientName,children:o}),i&&(0,sl.jsxs)("div",{className:w0.gender,children:[(0,sl.jsx)(w6,{gender:i.iconKey}),(0,sl.jsx)("span",{children:i.displayText})]}),(0,sl.jsx)(sS,{className:w0.tagsSlot,name:"patient-banner-tags-slot",state:s})]})}),(0,sl.jsxs)("div",{className:w0.demographics,children:[e.birthDate&&(0,sl.jsxs)(sl.Fragment,{children:[(0,sl.jsx)("span",{children:wQ(e.birthDate)}),(0,sl.jsx)("span",{className:w0.separator,children:"\xb7"}),(0,sl.jsx)("span",{children:be(e.birthDate,{time:!1,noToday:!0})}),(0,sl.jsx)("span",{className:w0.separator,children:"\xb7"})]}),(0,sl.jsx)(w2,{identifiers:e.identifier,showIdentifierLabel:!0}),(0,sl.jsx)(sS,{className:w0.extensionSlot,name:"patient-banner-bottom-slot",state:s})]})]})}var w8=r(8282);function w7({patient:e,patientUuid:t,actionsSlotName:r,additionalActionsSlotState:n}){let[a,o]=(0,so.useState)(!1),{extensions:i}=sE(r),s="tablet"===lD(),l=lR(()=>o(!1),a),u=(0,so.useRef)(null),c=(0,so.useRef)(null),d=(0,so.useId)(),m=`patient-actions-menu-trigger-${d}`,p=`patient-actions-menu-${d}`,f=(0,so.useCallback)(()=>o(e=>!e),[]),h=(0,so.useCallback)(()=>{o(!1),u.current?.focus()},[]),g=(0,so.useCallback)(e=>{if("Escape"===e.key&&a){e.stopPropagation(),h();return}if(("ArrowDown"===e.key||"ArrowUp"===e.key)&&a){e.preventDefault();let t=c.current?.querySelectorAll('[role="menuitem"]:not([disabled])');if(!t?.length)return;let r=document.activeElement?.closest?.('[role="menuitem"]')??document.activeElement,n=Array.from(t).indexOf(r);if(-1===n)return void t["ArrowDown"===e.key?0:t.length-1]?.focus();let a=n+("ArrowDown"===e.key?1:-1),o=a<0?t.length-1:a>=t.length?0:a;t[o]?.focus()}},[h,a]);(0,so.useEffect)(()=>{if(a&&c.current){let e=c.current.querySelector('[role="menuitem"]:not([disabled])');e?.focus()}},[a]);let y=(0,so.useMemo)(()=>({patientUuid:t,patient:e,closeMenu:h,...n}),[t,e,h,n]);return 0===i.length?null:(0,sl.jsx)("div",{className:"-esm-patient-chart__patient-banner-actions-menu-module__overflowMenuContainer___FbFcO",children:(0,sl.jsxs)("div",{"data-overflow-menu":!0,className:ue()("cds--overflow-menu",ul),ref:l,children:[(0,sl.jsxs)("button",{className:ue()("cds--btn","cds--btn--ghost","cds--overflow-menu__trigger",{"cds--overflow-menu--open":a},ud),"aria-controls":p,"aria-expanded":a,"aria-haspopup":"true",id:m,onClick:f,onKeyDown:g,ref:u,children:[(0,sl.jsx)("span",{className:"-esm-patient-chart__patient-banner-actions-menu-module__actionsButtonText___hk4xW",children:nB("actions","Actions")})," ",(0,sl.jsx)(w8.CH,{size:16,style:{marginLeft:"0.5rem",fill:"#78A9FF"}})]}),(0,sl.jsxs)("div",{className:ue()("cds--overflow-menu-options","cds--overflow-menu--flip",uu,{[uc]:a}),"aria-labelledby":m,"data-floating-menu-direction":"bottom",id:p,onKeyDown:g,ref:c,role:"menu",tabIndex:-1,children:[(0,sl.jsx)("ul",{className:ue()("cds--overflow-menu-options__content",{"cds--overflow-menu-options--lg":s}),children:(0,sl.jsx)(sS,{name:r,state:y},r)}),(0,sl.jsx)("span",{})]})]})})}var xe=r(5570),xt=r.n(xe);function xr(e){let{patientPhotoConceptUuid:t}=s5({externalModuleName:"@openmrs/esm-styleguide"}),r=t?`${nQ}/obs?patient=${e}&concept=${t}&v=full`:null,{data:n,error:a,isLoading:o}=s$()(e?r:null,n2),i=n?.data?.results[0];return{data:i?{dateTime:i?.obsDatetime,imageSrc:i?.value?.links?.uri}:null,error:a,isLoading:o}}let xn=({width:e=56,height:t=56,"aria-label":r})=>{let{t:n}=(0,sR.useTranslation)();return(0,sl.jsxs)("svg",{"aria-label":r??n("patientPhotoPlaceholder","Patient photo placeholder"),width:e,height:t,fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,sl.jsx)("path",{fill:"#ffffff",d:"M0 0h56v56H0z"}),(0,sl.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m36.75 20.134-.884-.884L19.25 35.866l.884.884 1.25-1.25H34.25a1.252 1.252 0 0 0 1.25-1.25V21.384l1.25-1.25Zm-2.5 14.116H22.634l4.87-4.87 1.487 1.486a1.25 1.25 0 0 0 1.768 0l.991-.991 2.5 2.498v1.877Zm0-3.645-1.616-1.616a1.25 1.25 0 0 0-1.768 0l-.991.991-1.486-1.486 5.861-5.86v7.971Zm-12.5 1.145v-1.875l3.125-3.123.858.859.885-.885-.86-.86a1.25 1.25 0 0 0-1.767 0l-2.241 2.242V21.75h10V20.5h-10c-.69 0-1.25.56-1.25 1.25v10h1.25Z",fill:"#8D8D8D"})]})},xa="-esm-patient-chart__patient-photo-module__avatar___thboZ";function xo({patientUuid:e,patientName:t,alt:r}){let{data:n,isLoading:a}=xr(e),[o,i]=(0,so.useState)(null),[s,l]=(0,so.useState)(!1),u=(0,so.useMemo)(()=>xt().generate(e),[e]);(0,so.useEffect)(()=>{if(n?.imageSrc){let e=new URL(n.imageSrc,window.location.origin).pathname;l(!0);let t=!1,r=new Image;return r.onload=()=>{t||(i(e),l(!1))},r.onerror=()=>{t||(i(null),l(!1))},r.src=e,()=>{t=!0}}i(null),l(!1)},[n?.imageSrc]);let c=(0,so.useMemo)(()=>r||(o?nB("patientPhotoAlt","Profile photo of {{patientName}}",{patientName:t}):nB("patientAvatarAlt","Avatar for {{patientName}}",{patientName:t})),[r,o,t]);return a||s?(0,sl.jsx)(uo.SkeletonIcon,{className:"-esm-patient-chart__patient-photo-module__skeleton___WWtyX","data-testid":"skeleton-icon"}):n?.imageSrc&&!o?(0,sl.jsx)(xn,{"aria-label":nB("patientPhotoPlaceholder","Photo placeholder for {{patientName}}",{patientName:t})}):o?(0,sl.jsx)("div",{"aria-label":c,children:(0,sl.jsx)("img",{className:xa,src:o,alt:c,title:t})}):(0,sl.jsx)("div",{"aria-label":c,children:(0,sl.jsx)("div",{className:xa,title:t,style:{backgroundImage:u.toDataUrl(),backgroundRepeat:"no-repeat",backgroundSize:"cover"},children:(0,sl.jsx)("span",{className:"-esm-patient-chart__patient-photo-module__initials___xLeEF",children:function(e,t=3){return e.split(/\s+/).filter(Boolean).slice(0,t).map(e=>e[0]).join("")}(t)})})})}let xi=["omrs-pict-appointments","omrs-pict-assessment-1","omrs-pict-assessment-2","omrs-pict-blood-bank","omrs-pict-cardiology","omrs-pict-cohorts","omrs-pict-concept-dictionary","omrs-pict-ct-scan","omrs-pict-data-entry","omrs-pict-dentistry","omrs-pict-digital-trust","omrs-pict-emergency-department","omrs-pict-facility","omrs-pict-geriatrics","omrs-pict-gynaecology","omrs-pict-in-patient","omrs-pict-laboratory","omrs-pict-labs-2","omrs-pict-metadata-export","omrs-pict-obstetrics","omrs-pict-patient-documents","omrs-pict-patient-search","omrs-pict-patients","omrs-pict-payments-desk","omrs-pict-pharmacy","omrs-pict-pharmacy-2","omrs-pict-registration","omrs-pict-reports","omrs-pict-service-queues","omrs-pict-stock-management","omrs-pict-system-administration","omrs-pict-transfer","omrs-pict-triage","omrs-pict-x-ray"],xs=(0,so.memo)((0,so.forwardRef)(function(e,t){return(0,sl.jsx)(xz,{ref:t,pictogram:"omrs-pict-appointments",pictogramProps:e})})),xl=xs,xu=(0,so.memo)((0,so.forwardRef)(function(e,t){return(0,sl.jsx)(xz,{ref:t,pictogram:"omrs-pict-assessment-1",pictogramProps:e})})),xc=(0,so.memo)((0,so.forwardRef)(function(e,t){return(0,sl.jsx)(xz,{ref:t,pictogram:"omrs-pict-assessment-2",pictogramProps:e})})),xd=(0,so.memo)((0,so.forwardRef)(function(e,t){return(0,sl.jsx)(xz,{ref:t,pictogram:"omrs-pict-blood-bank",pictogramProps:e})})),xm=(0,so.memo)((0,so.forwardRef)(function(e,t){return(0,sl.jsx)(xz,{ref:t,pictogram:"omrs-pict-cardiology",pictogramProps:e})})),xp=(0,so.memo)((0,so.forwardRef)(function(e,t){return(0,sl.jsx)(xz,{ref:t,pictogram:"omrs-pict-cohorts",pictogramProps:e})})),xf=(0,so.memo)((0,so.forwardRef)(function(e,t){return(0,sl.jsx)(xz,{ref:t,pictogram:"omrs-pict-concept-dictionary",pictogramProps:e})})),xh=(0,so.memo)((0,so.forwardRef)(function(e,t){return(0,sl.jsx)(xz,{ref:t,pictogram:"omrs-pict-ct-scan",pictogramProps:e})})),xg=(0,so.memo)((0,so.forwardRef)(function(e,t){return(0,sl.jsx)(xz,{ref:t,pictogram:"omrs-pict-data-entry",pictogramProps:e})})),xy=(0,so.memo)((0,so.forwardRef)(function(e,t){return(0,sl.jsx)(xz,{ref:t,pictogram:"omrs-pict-dentistry",pictogramProps:e})})),xv=(0,so.memo)((0,so.forwardRef)(function(e,t){return(0,sl.jsx)(xz,{ref:t,pictogram:"omrs-pict-digital-trust",pictogramProps:e})})),xb=(0,so.memo)((0,so.forwardRef)(function(e,t){return(0,sl.jsx)(xz,{ref:t,pictogram:"omrs-pict-emergency-department",pictogramProps:e})})),xw=(0,so.memo)((0,so.forwardRef)(function(e,t){return(0,sl.jsx)(xz,{ref:t,pictogram:"omrs-pict-facility",pictogramProps:e})})),xx=(0,so.memo)((0,so.forwardRef)(function(e,t){return(0,sl.jsx)(xz,{ref:t,pictogram:"omrs-pict-geriatrics",pictogramProps:e})})),xE=(0,so.memo)((0,so.forwardRef)(function(e,t){return(0,sl.jsx)(xz,{ref:t,pictogram:"omrs-pict-gynaecology",pictogramProps:e})})),xD=(0,so.memo)((0,so.forwardRef)(function(e,t){return(0,sl.jsx)(xz,{ref:t,pictogram:"omrs-pict-in-patient",pictogramProps:e})})),xS=(0,so.memo)((0,so.forwardRef)(function(e,t){return(0,sl.jsx)(xz,{ref:t,pictogram:"omrs-pict-laboratory",pictogramProps:e})})),x_=(0,so.memo)((0,so.forwardRef)(function(e,t){return(0,sl.jsx)(xz,{ref:t,pictogram:"omrs-pict-labs-2",pictogramProps:e})})),xC=(0,so.memo)((0,so.forwardRef)(function(e,t){return(0,sl.jsx)(xz,{ref:t,pictogram:"omrs-pict-metadata-export",pictogramProps:e})})),xk=(0,so.memo)((0,so.forwardRef)(function(e,t){return(0,sl.jsx)(xz,{ref:t,pictogram:"omrs-pict-obstetrics",pictogramProps:e})})),xP=(0,so.memo)((0,so.forwardRef)(function(e,t){return(0,sl.jsx)(xz,{ref:t,pictogram:"omrs-pict-patient-documents",pictogramProps:e})})),xR=(0,so.memo)((0,so.forwardRef)(function(e,t){return(0,sl.jsx)(xz,{ref:t,pictogram:"omrs-pict-patient-search",pictogramProps:e})})),xT=(0,so.memo)((0,so.forwardRef)(function(e,t){return(0,sl.jsx)(xz,{ref:t,pictogram:"omrs-pict-patients",pictogramProps:e})})),x$=(0,so.memo)((0,so.forwardRef)(function(e,t){return(0,sl.jsx)(xz,{ref:t,pictogram:"omrs-pict-payments-desk",pictogramProps:e})})),xN=(0,so.memo)((0,so.forwardRef)(function(e,t){return(0,sl.jsx)(xz,{ref:t,pictogram:"omrs-pict-pharmacy",pictogramProps:e})})),xO=(0,so.memo)((0,so.forwardRef)(function(e,t){return(0,sl.jsx)(xz,{ref:t,pictogram:"omrs-pict-pharmacy-2",pictogramProps:e})})),xI=(0,so.memo)((0,so.forwardRef)(function(e,t){return(0,sl.jsx)(xz,{ref:t,pictogram:"omrs-pict-registration",pictogramProps:e})})),xA=(0,so.memo)((0,so.forwardRef)(function(e,t){return(0,sl.jsx)(xz,{ref:t,pictogram:"omrs-pict-reports",pictogramProps:e})})),xM=(0,so.memo)((0,so.forwardRef)(function(e,t){return(0,sl.jsx)(xz,{ref:t,pictogram:"omrs-pict-service-queues",pictogramProps:e})})),xj=(0,so.memo)((0,so.forwardRef)(function(e,t){return(0,sl.jsx)(xz,{ref:t,pictogram:"omrs-pict-stock-management",pictogramProps:e})})),xL=(0,so.memo)((0,so.forwardRef)(function(e,t){return(0,sl.jsx)(xz,{ref:t,pictogram:"omrs-pict-system-administration",pictogramProps:e})})),xF=(0,so.memo)((0,so.forwardRef)(function(e,t){return(0,sl.jsx)(xz,{ref:t,pictogram:"omrs-pict-transfer",pictogramProps:e})})),xB=(0,so.memo)((0,so.forwardRef)(function(e,t){return(0,sl.jsx)(xz,{ref:t,pictogram:"omrs-pict-triage",pictogramProps:e})})),xV=(0,so.memo)((0,so.forwardRef)(function(e,t){return(0,sl.jsx)(xz,{ref:t,pictogram:"omrs-pict-x-ray",pictogramProps:e})})),xU=xw,xW=xT,xH=(0,so.memo)((0,so.forwardRef)(function({pictogram:e,fallback:t,...r},n){let a=(0,so.useRef)(document.getElementById(e));return(0,so.useEffect)(()=>{let t=document.getElementById("omrs-svgs-container"),r=new MutationObserver(t=>{for(let r of t)"childList"===r.type&&(a.current=document.getElementById(e))});return t&&r.observe(t,{childList:!0}),()=>r.disconnect()},[e]),(0,sl.jsx)(sY,{value:a.current,fallback:t,children:(0,sl.jsx)(xz,{ref:n,pictogram:e,pictogramProps:r})})})),xz=(0,so.memo)((0,so.forwardRef)(function({pictogram:e,pictogramProps:t},r){let{className:n,size:a}=Object.assign({},{size:92},t);return(a<=26||a>144)&&(console.error(`Invalid size '${a}' specified for ${e}. Defaulting to 92.`),a=92),(0,sl.jsx)("svg",{ref:r,className:ue()("-esm-patient-chart__pictograms-module__pictogram___ooPKM",n),height:a,width:a,children:(0,sl.jsx)("use",{href:`#${e}`})})})),xK=({children:e})=>"tablet"===lD()?(0,sl.jsx)(uo.Layer,{children:e}):(0,sl.jsx)(sl.Fragment,{children:e}),xG=({snackbar:e,closeSnackbar:t})=>{let{actionButtonLabel:r="",kind:n="success",onActionButtonClick:a=()=>{},isLowContrast:o="error"!==n,progressActionLabel:i,subtitle:s="",timeoutInMs:l=5e3,autoClose:u="error"!==n,title:c,id:d,...m}=e,[p,f]=(0,so.useState)(r),[h,g]=(0,so.useState)(!0),[y,v]=(0,so.useState)(!1),b=(0,so.useCallback)(()=>{setTimeout(t,250)},[t]),w=(0,so.useCallback)(()=>{v(!0),b()},[b]);return(0,so.useEffect)(()=>{if(u){let e=setTimeout(w,l);return()=>clearTimeout(e)}},[l,u,w]),(0,so.useEffect)(()=>{g(!1),window.setTimeout(()=>{g(!0)},0)},[]),(0,sl.jsx)(uo.ActionableNotification,{actionButtonLabel:p,"aria-label":nB("closeSnackbar","Close snackbar"),className:ue()("-esm-patient-chart__snackbar-module__slideIn___senVE",{"-esm-patient-chart__snackbar-module__animated___8eltL":h,"-esm-patient-chart__snackbar-module__slideOut___BIIXm":y}),kind:n,lowContrast:o,onActionButtonClick:()=>{a(),w(),i&&f(i)},onClose:b,statusIconDescription:nB("snackbarNotification","Snackbar notification"),subtitle:s,title:c,...m})},xZ=({subject:e})=>{let[t,r]=(0,so.useState)([]),n=(0,so.useCallback)(e=>{r(t=>t.filter(t=>t!==e))},[]);return(0,so.useEffect)(()=>{let t=e.subscribe(e=>r(t=>[...t.filter(t=>t.subtitle!==e.subtitle||t.actionButtonLabel!==e.actionButtonLabel||t.onActionButtonClick!==e.onActionButtonClick||t.kind!==e.kind||t.title!==e.title),e]));return()=>t.unsubscribe()},[e]),(0,sl.jsx)(sl.Fragment,{children:t.map(e=>(0,sl.jsx)(xG,{snackbar:e,closeSnackbar:()=>n(e)},e.id))})},xY=new wT,xq=0;function xJ(e){e&&(0,s_.createRoot)(e).render((0,sl.jsx)(xZ,{subject:xY}))}function xX(e){var t;e&&"string"==typeof(t=e.title)&&t.trim().length>0?setTimeout(()=>{xY.next({...e,id:xq++})},0):console.error("showSnackbar must be called with an object having a 'title' property that is a non-empty string")}let xQ=({toast:e,closeToast:t})=>{let{description:r,kind:n,critical:a,title:o,actionButtonLabel:i,onActionButtonClick:s=()=>{}}=e,l=(0,so.useCallback)(()=>{s(),t()},[t,s]);return(0,sl.jsx)("div",{children:(0,sl.jsx)(uo.ActionableNotification,{actionButtonLabel:i,kind:n||"info",lowContrast:a,subtitle:r,title:o||"",onActionButtonClick:l,onClose:t})})},x0=({subject:e})=>{let[t,r]=(0,so.useState)([]),n=(0,so.useCallback)(e=>{r(t=>t.filter(t=>t!==e))},[]);return(0,so.useEffect)(()=>{let t=e.subscribe(e=>r(t=>[...t.filter(t=>t.description!==e.description||t.kind!==e.kind||t.title!==e.title||t.actionButtonLabel!==e.actionButtonLabel||t.onActionButtonClick!==e.onActionButtonClick),e]));return()=>t.unsubscribe()},[e]),(0,sl.jsx)(sl.Fragment,{children:t.map(e=>(0,sl.jsx)(xQ,{toast:e,closeToast:()=>n(e)},e.id))})},x1=new wT,x4=0;function x2(e){e&&(0,s_.createRoot)(e).render((0,sl.jsx)(x0,{subject:x1}))}function x3(e){var t;e&&("string"==typeof(t=e.description)?t.trim().length>0:"object"==typeof t&&!(0,w_.A)(t))?setTimeout(()=>{x1.next({...e,id:x4++})},0):console.error("showToast must be called with an object having a 'description' property that is a non-empty string or object")}let x6="u">typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),x5=new Uint8Array(16),x9=[];for(let e=0;e<256;++e)x9.push((e+256).toString(16).slice(1));let x8=function(e,t,r){if(x6&&!t&&!e)return x6();let n=(e=e||{}).random??e.rng?.()??function(){if(!c){if("u"<typeof crypto||!crypto.getRandomValues)throw Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");c=crypto.getRandomValues.bind(crypto)}return c(x5)}();if(n.length<16)throw Error("Random bytes length must be >= 16");if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,t){if((r=r||0)<0||r+16>t.length)throw RangeError(`UUID byte range ${r}:${r+15} is out of buffer bounds`);for(let e=0;e<16;++e)t[r+e]=n[e];return t}return function(e,t=0){return(x9[e[t+0]]+x9[e[t+1]]+x9[e[t+2]]+x9[e[t+3]]+"-"+x9[e[t+4]]+x9[e[t+5]]+"-"+x9[e[t+6]]+x9[e[t+7]]+"-"+x9[e[t+8]]+x9[e[t+9]]+"-"+x9[e[t+10]]+x9[e[t+11]]+x9[e[t+12]]+x9[e[t+13]]+x9[e[t+14]]+x9[e[t+15]]).toLowerCase()}(n)};async function x7(e,t){let{openedGroup:r}=i0.getState();if(r){if(r.groupName===e&&Er(r.props,t))return!0;else if(!await Eo({reason:"CLOSE_WORKSPACE_GROUP",explicit:!1}))return!1}return i0.setState(r=>({...r,openedGroup:{groupName:e,props:t},openedWindows:[]})),!0}async function Ee(e){let{openedGroup:t,openedWindows:r}=i0.getState();if(t){if(r.length>0&&!(e||await Eo({reason:"CLOSE_WORKSPACE_GROUP",explicit:!0})))return!1;i0.setState(e=>({...e,openedGroup:null,openedWindows:[]}))}return!0}async function Et(e,t=null,r=null,n=null){let a=i0.getState();if(!a.registeredWorkspacesByName[e])throw Error(`Unable to launch workspace ${e}. Workspace is not registered`);let o=i1(e);if(!o)throw Error(`Unable to launch workspace ${e}. Workspace is not registered to a workspace window`);let{openedGroup:i}=a,{name:s}=o,l=i4(s);if(!l)throw Error(`Unable to launch workspace ${e}. Workspace window ${o.name} is not registered to a workspace group`);let u=i2(e);if(i&&(i.groupName!==l.name||!Er(i.props,n)))return!!await Eo({reason:"CLOSE_WORKSPACE_GROUP",explicit:!0})&&(i0.setState({...a,openedGroup:{groupName:l.name,props:n},openedWindows:[{windowName:s,openedWorkspaces:[Eg(e,t)],props:r,maximized:!1}],isMostRecentlyOpenedWindowHidden:!1}),!0);if(u>=0){let n=a.openedWindows[u],o=a.openedGroup?.props??{},i=a.isMostRecentlyOpenedWindowHidden,{openedWorkspaces:c}=n;if(Er(n.props,r)){let d=c.find(t=>t.workspaceName===e);return d&&Er(d.props,t)?((i||u!==a.openedWindows.length-1)&&i0.setState(Ed.restoreWindow(a,s)),!0):!!await Eo({reason:"CLOSE_WORKSPACE",explicit:!1,windowName:s,workspaceName:e})&&(i0.setState({...a,openedGroup:{groupName:l.name,props:a?.openedGroup?.props??o},openedWindows:[...a.openedWindows.filter((e,t)=>t!==u),{windowName:s,openedWorkspaces:[Eg(e,t)],props:n?.props??r,maximized:!1}],isMostRecentlyOpenedWindowHidden:!1}),!0)}return!!await Eo({reason:"CLOSE_WINDOW",explicit:!1,windowName:s})&&(i0.setState({...a,openedGroup:{groupName:l.name,props:o??a?.openedGroup?.props},openedWindows:[...a.openedWindows.filter((e,t)=>t!==u),{windowName:s,openedWorkspaces:[Eg(e,t)],props:r,maximized:!1}],isMostRecentlyOpenedWindowHidden:!1}),!0)}return"closable"!=l.persistence?(i0.setState({...a,openedGroup:{groupName:l.name,props:n??a?.openedGroup?.props??null},openedWindows:[...a.openedWindows,{windowName:s,openedWorkspaces:[Eg(e,t)],props:r,maximized:!1}],isMostRecentlyOpenedWindowHidden:!1}),!0):!!await Eo({reason:"CLOSE_OTHER_WINDOWS",explicit:!1,windowNameToSpare:o.name})&&(i0.setState({...a,openedGroup:{groupName:l.name,props:n??a?.openedGroup?.props??null},openedWindows:[{windowName:s,openedWorkspaces:[Eg(e,t)],props:r,maximized:!1}],isMostRecentlyOpenedWindowHidden:!1}),!0)}function Er(e,t){return null==e||null==t||T(e,t)}function En(e,t){let r=[];for(let n=e.openedWorkspaces.length-1;n>=0;n--){let a=e.openedWorkspaces[n];if(a.hasUnsavedChanges&&r.push(a),t&&a.workspaceName===t)break}return r}function Ea(e){return 0===e.length?Promise.resolve(!0):new Promise(t=>{let r=wS("workspace2-close-prompt",{size:"sm",onConfirm:()=>{r(),t(!0)},onCancel:()=>{r(),t(!1)},affectedWorkspaceTitles:e.map(e=>e.title??"")})})}function Eo(e){let{openedWindows:t}=i0.getState(),r=[];switch(e.reason){case"CLOSE_WORKSPACE_GROUP":r=t.flatMap(e=>En(e));break;case"CLOSE_WINDOW":{let n=t.find(t=>t.windowName===e.windowName);if(!n)throw Error(`Window ${e.windowName} not found in opened windows.`);r=En(n);break}case"CLOSE_WORKSPACE":{let n=t.find(t=>t.windowName===e.windowName);if(!n)throw Error(`Window ${e.windowName} not found in opened windows.`);r=En(n,e.workspaceName);break}case"CLOSE_OTHER_WINDOWS":r=t.filter(t=>t.windowName!==e.windowNameToSpare).flatMap(e=>En(e))}return Ea(r)}function Ei(e,t){return Ea(En(e,t))}function Es(e,t){let r=e.openedWorkspaces.findIndex(e=>e.workspaceName===t);return r<0?e:0===r?null:{...e,openedWorkspaces:e.openedWorkspaces.slice(0,r)}}function El(e,t,r,n){let{registeredWorkspacesByName:a}=i0.getState(),o=a[r];if(!o)throw Error(`No workspace named "${r}" registered`);let i=a[t];if(!i)throw Error(`No workspace named "${t}" registered`);if(i.window!==o.window)throw Error(`Child workspace ${r} does not belong to the same workspace window as parent workspace ${t}`);if(o.window!==e.windowName)throw Error(`Cannot open child workspace ${r} as window ${o.window} is not opened`);let{openedWorkspaces:s}=e,l=s.findIndex(e=>e.workspaceName===t);if(-1===l)throw Error(`Cannot open child workspace ${r} from parent workspace ${t} as the parent is not opened within the workspace window`);let u=s.slice(0,l+1);return{...e,openedWorkspaces:[...u,Eg(r,n)]}}function Eu(e,t,r){let n=e.openedWorkspaces.findIndex(e=>e.uuid===t);if(n<0)return e;let a=e.openedWorkspaces[n];if(Object.keys(r).every(e=>a[e]===r[e]))return e;let o=[...e.openedWorkspaces];return o[n]={...a,...r},{...e,openedWorkspaces:o}}function Ec(e,t,r){let n=e.openedWindows.findIndex(e=>e.openedWorkspaces.some(e=>e.uuid===t));if(n<0)return e;let a=e.openedWindows[n],o=Eu(a,t,r);if(o===a)return e;let i=[...e.openedWindows];return i[n]=o,{...e,openedWindows:i}}let Ed={setWindowMaximized(e,t,r){let n=e.openedWindows.findIndex(e=>e.windowName===t),a=[...e.openedWindows],o={...a[n],maximized:r};return a[n]=o,{...e,openedWindows:a}},hideWindow:e=>({...e,isMostRecentlyOpenedWindowHidden:!0}),restoreWindow(e,t){let r=e.openedWindows.findIndex(e=>e.windowName===t),n=e.openedWindows[r],a=[...e.openedWindows.filter((e,t)=>t!==r),n];return{...e,openedWindows:a,isMostRecentlyOpenedWindowHidden:!1}},closeWorkspace(e,t){let r=e.openedWindows.findIndex(e=>e.openedWorkspaces.some(e=>e.workspaceName===t));if(r<0)return e;let n=Es(e.openedWindows[r],t),a=[...e.openedWindows],o=e.isMostRecentlyOpenedWindowHidden;if(null===n){let t=r===e.openedWindows.length-1;a.splice(r,1),t&&a.length>0&&(o=!1)}else a[r]=n;return{...e,openedWindows:a,isMostRecentlyOpenedWindowHidden:o}},openChildWorkspace(e,t,r,n){let a=e.registeredWorkspacesByName[r];if(!a)throw Error(`No workspace named "${r}" registered`);let o=e.openedWindows.findIndex(e=>e.windowName===a.window);if(-1==o)throw Error(`Cannot open child workspace ${r} as window ${a.window} is not opened`);let i=[...e.openedWindows];return i[o]=El(e.openedWindows[o],t,r,n),{...e,openedWindows:i}},setHasUnsavedChanges:(e,t,r)=>Ec(e,t,{hasUnsavedChanges:r}),setWorkspaceTitle:(e,t,r)=>Ec(e,t,{title:r})};function Em(){return sh(i0,Ed)}let Ep=()=>(0,so.useContext)(sk.SingleSpaContext),Ef=()=>Object.keys(i0.getState().registeredWorkspacesByName);function Eh(e,t,r){let n=e.openedWorkspaces[e.openedWorkspaces.length-1];return(n?t[n.workspaceName]?.width:void 0)??r[e.windowName]?.width??"narrow"}function Eg(e,t){return{workspaceName:e,props:t??{},hasUnsavedChanges:!1,uuid:x8()}}function Ey(e,t,r){let n=i0.getState().registeredWorkspacesByName[e];return n?{windowName:n.window,openedWorkspaces:[Eg(e,t)],props:r??null,maximized:!1}:null}let Ev=({title:e,children:t,hasUnsavedChanges:r=!1})=>{let{setHasUnsavedChanges:n,setWorkspaceTitle:a}=Ep();return(0,so.useEffect)(()=>{n(r??!1)},[r,n]),(0,so.useEffect)(()=>{a(e)},[e,a]),(0,sl.jsx)(sl.Fragment,{children:t})};function Eb(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 Ew(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Eb(Object(r),!0).forEach(function(t){EE(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Eb(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function Ex(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function EE(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function ED(e){return(ED=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function ES(e,t){return(ES=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function E_(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}var EC=function(e){var t=so.Component;if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");i.prototype=Object.create(t&&t.prototype,{constructor:{value:i,writable:!0,configurable:!0}}),t&&ES(i,t);var r,n,a,o=(r=function(){if("u"<typeof Reflect||!Reflect.construct||Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}(),function(){var e,t=ED(i);e=r?Reflect.construct(t,arguments,ED(this).constructor):t.apply(this,arguments);if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw TypeError("Derived constructors may only return object or undefined");return E_(this)});function i(e){var t;if(function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,i),EE(E_(t=o.call(this,e)),"handleRef",function(e){t.el=e}),EE(E_(t),"addThingToDo",function(e,r){t.state.hasError&&"unmount"!==e||(t.nextThingToDo=(t.nextThingToDo||Promise.resolve()).then(function(){if(!t.unmounted||"unmount"===e)return r.apply(void 0,arguments)}).catch(function(r){throw t.nextThingToDo=Promise.resolve(),t.setState({hasError:!0}),r&&r.message&&(r.message="During '".concat(e,"', parcel threw an error: ").concat(r.message)),t.props.handleError?t.props.handleError(r):setTimeout(function(){throw r}),r}))}),EE(E_(t),"getParcelProps",function(){var e=Ew(Ew({},t.props),{},{domElement:t.el});return delete e.mountParcel,delete e.config,delete e.wrapWith,delete e.wrapStyle,delete e.appendTo,delete e.handleError,delete e.parcelDidMount,e}),t.state={hasError:!1},!e.config)throw Error("single-spa-react's Parcel component requires the 'config' prop to either be a parcel config or a loading function that returns a promise. See https://github.com/single-spa/single-spa-react");return t}return n=[{key:"componentDidMount",value:function(){var e=this;this.unmounted=!1,this.addThingToDo("mount",function(){var t,r=e.props.mountParcel||e.mountParcel;if(!r)throw Error("\n <Parcel /> was not passed a mountParcel prop, nor is it rendered where mountParcel is within the React context.\n If you are using <Parcel /> within a module that is not a single-spa application, you will need to import mountRootParcel from single-spa and pass it into <Parcel /> as a mountParcel prop \n ");return e.el?t=e.el:(e.createdDomElement=t=document.createElement(e.props.wrapWith),Object.keys(e.props.wrapStyle).forEach(function(r){t.style[r]=e.props.wrapStyle[r]}),e.props.appendTo.appendChild(t)),e.parcel=r(e.props.config,Ew({domElement:t},e.getParcelProps())),e.parcel.mountPromise.then(e.props.parcelDidMount),e.parcel.mountPromise})}},{key:"componentDidUpdate",value:function(){var e=this;this.addThingToDo("update",function(){if(e.parcel&&e.parcel.update)return e.parcel.update(e.getParcelProps())})}},{key:"componentWillUnmount",value:function(){var e=this;this.addThingToDo("unmount",function(){if(e.parcel&&"MOUNTED"===e.parcel.getStatus())return e.parcel.unmount()}),this.createdDomElement&&this.createdDomElement.parentNode.removeChild(this.createdDomElement),this.unmounted=!0}},{key:"render",value:function(){var e=this;if(this.props.appendTo)return sk.SingleSpaContext&&sk.SingleSpaContext.Consumer?so.createElement(sk.SingleSpaContext.Consumer,null,function(t){return e.mountParcel=t?t.mountParcel:null,null}):null;var t=sk.SingleSpaContext&&sk.SingleSpaContext.Consumer?so.createElement(sk.SingleSpaContext.Consumer,null,function(t){return e.mountParcel=t?t.mountParcel:null,null}):void 0;return so.createElement(this.props.wrapWith,{ref:this.handleRef,style:this.props.wrapStyle,className:this.props.wrapClassName},t)}}],Ex(i.prototype,n),a&&Ex(i,a),i}();EE(EC,"defaultProps",{wrapWith:"div",wrapStyle:{},parcelDidMount:function(){}});var Ek=r(8742);let EP=si().forwardRef(function({children:e,size:t=16,...r},n){return 16===t||"16"===t||"16px"===t?si().createElement(Ek.A,{width:t,height:t,ref:n,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 16 16",fill:"currentColor",...r},et||(et=si().createElement("path",{d:"M2 9L2 10 5.3 10 1 14.3 1.7 15 6 10.7 6 14 7 14 7 9zM14 7L14 6 10.7 6 15 1.7 14.3 1 10 5.3 10 2 9 2 9 7z"})),e):si().createElement(Ek.A,{width:t,height:t,ref:n,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",fill:"currentColor",...r},er||(er=si().createElement("path",{d:"M4 18L4 20 10.586 20 2 28.582 3.414 30 12 21.414 12 28 14 28 14 18 4 18zM30 3.416L28.592 2 20 10.586 20 4 18 4 18 14 28 14 28 12 21.414 12 30 3.416z"})),e)});var ER=r(4240),ET=r(8622);let E$={workspaceOuterContainer:"-esm-patient-chart__workspace2-module__workspaceOuterContainer___jaqGm",narrowWorkspace:"-esm-patient-chart__workspace2-module__narrowWorkspace___o1wsL",widerWorkspace:"-esm-patient-chart__workspace2-module__widerWorkspace___gdEOi",extraWideWorkspace:"-esm-patient-chart__workspace2-module__extraWideWorkspace___U9xlJ",workspaceMiddleContainer:"-esm-patient-chart__workspace2-module__workspaceMiddleContainer___0AdtX",maximized:"-esm-patient-chart__workspace2-module__maximized___aKCbE",hidden:"-esm-patient-chart__workspace2-module__hidden___n1US5",workspaceInnerContainer:"-esm-patient-chart__workspace2-module__workspaceInnerContainer___1g+qk",workspaceSpacer:"-esm-patient-chart__workspace2-module__workspaceSpacer___P2T9y",loader:"-esm-patient-chart__workspace2-module__loader___fCfzZ",hiddenExtraWorkspace:"-esm-patient-chart__workspace2-module__hiddenExtraWorkspace___hvPSi",header:"-esm-patient-chart__workspace2-module__header___MXXx9",headerButtons:"-esm-patient-chart__workspace2-module__headerButtons___sJdnC",workspaceContent:"-esm-patient-chart__workspace2-module__workspaceContent___6NuXT",overlayHeaderSpacer:"-esm-patient-chart__workspace2-module__overlayHeaderSpacer___PLO6T",isActionMenuOpened:"-esm-patient-chart__workspace2-module__isActionMenuOpened___X3Vj6",showActionMenu:"-esm-patient-chart__workspace2-module__showActionMenu___HSun1",marginWorkspaceContent:"-esm-patient-chart__workspace2-module__marginWorkspaceContent___DCfWz",workspaceContainerWithActionMenu:"-esm-patient-chart__workspace2-module__workspaceContainerWithActionMenu___G9MdI",workspaceFixedContainer:"-esm-patient-chart__workspace2-module__workspaceFixedContainer___uIldI",workspaceContainerWithoutActionMenu:"-esm-patient-chart__workspace2-module__workspaceContainerWithoutActionMenu___lBudZ"},EN=e=>e.registeredWorkspacesByName,EO=({lifeCycle:e,openedWorkspace:t,openedWindow:r,groupProps:n,actions:a,renderChrome:o,isRootWorkspace:i,isLeafWorkspace:s,showActionMenu:l})=>{let u=(0,so.useMemo)(()=>t&&{closeWorkspace:async(e={})=>{let{closeWindow:n=!1,discardUnsavedChanges:o=!1}=e;return n?!!(o||await a.promptForClosingWorkspaces())&&(a.closeWorkspace(r.openedWorkspaces[0].workspaceName),!0):!!(o||await a.promptForClosingWorkspaces(t.workspaceName))&&(a.closeWorkspace(t.workspaceName),!0)},launchChildWorkspace:async(e,n)=>{let o=t.workspaceName,{openedWorkspaces:i}=r,s=i.findIndex(e=>e.workspaceName===o);-1===s||s!==i.length-1&&i.slice(s+1).some(e=>e.hasUnsavedChanges)&&!await a.promptForClosingWorkspaces(i[s+1].workspaceName)||a.openChildWorkspace(o,e,n||{})},setWorkspaceTitle:e=>a.setWorkspaceTitle(t.uuid,e),setHasUnsavedChanges:e=>a.setHasUnsavedChanges(t.uuid,e),workspaceName:t.workspaceName,workspaceProps:t.props,windowProps:r.props,groupProps:n,workspaceMeta:i0.getState().registeredWorkspacesByName[t.workspaceName]?.meta??{},isRootWorkspace:i,isLeafWorkspace:s,windowName:r.windowName,showActionMenu:l},[t,r,n,a,i,s,l]),c=!o&&!s,d=(0,so.useMemo)(()=>e?(0,sl.jsx)(EC,{config:e,mountParcel:sn,wrapWith:"div",wrapClassName:ue()(E$.workspaceContent,{[E$.hiddenExtraWorkspace]:c}),...u},t.workspaceName):null===e?(0,sl.jsx)("div",{className:ue()(E$.workspaceContent,{[E$.hiddenExtraWorkspace]:c}),children:(0,sl.jsx)(uo.InlineNotification,{kind:"error",title:nB("error"),subtitle:nB("somethingWentWrongTryReloading"),hideCloseButton:!0})}):null,[e,t.workspaceName,u,c]);return o?(0,sl.jsx)("div",{children:(0,sl.jsx)(EI,{openedWorkspace:t,openedWindow:r,isRootWorkspace:i,showActionMenu:l,closeWindow:()=>u.closeWorkspace({closeWindow:!0}),children:d})}):d??(0,sl.jsx)(uo.InlineLoading,{className:ue()(E$.loader,{[E$.hiddenExtraWorkspace]:c}),description:`${nB("loading")}`})},EI=({openedWorkspace:e,openedWindow:t,isRootWorkspace:r,showActionMenu:n,closeWindow:a,children:o})=>{let i=lD(),{openedGroup:s,openedWindows:l,registeredWindowsByName:u,registeredWorkspacesByName:c,registeredGroupsByName:d,isMostRecentlyOpenedWindowHidden:m,setWindowMaximized:p,hideWindow:f}=Em(),h=t.windowName,{maximized:g}=t,y=e.title??"",v=u[h],b=Eh(t,c,u),w=v?.icon,x=v?.canMaximize,E=!!s&&d[s.groupName]?.persistence==="closable",D=!!w&&!E,S=l.findIndex(e=>e.windowName===h)<l.length-1||m,_=Object.values(u).some(e=>e.group===s?.groupName&&void 0!==e.icon);return(0,sl.jsxs)("div",{className:ue()(E$.workspaceOuterContainer,{[E$.narrowWorkspace]:"narrow"===b,[E$.widerWorkspace]:"wider"===b,[E$.extraWideWorkspace]:"extra-wide"===b,[E$.isActionMenuOpened]:_}),children:[(0,sl.jsx)("div",{className:ue()(E$.workspaceSpacer,{[E$.hidden]:S})}),(0,sl.jsx)("div",{className:ue()(E$.workspaceMiddleContainer,{[E$.maximized]:g,[E$.hidden]:S,[E$.isRootWorkspace]:r,[E$.showActionMenu]:n}),children:(0,sl.jsx)("div",{className:ue()(E$.workspaceInnerContainer,{[E$.maximized]:g,[E$.hidden]:S,[E$.isRootWorkspace]:r}),children:o?(0,sl.jsxs)(sl.Fragment,{children:[(0,sl.jsxs)(uo.Header,{"aria-label":nB("workspaceHeader"),className:E$.header,children:[(0,sl.jsx)(uo.HeaderName,{prefix:"",children:y}),(0,sl.jsx)("div",{className:E$.overlayHeaderSpacer}),(0,sl.jsx)(uo.HeaderGlobalBar,{className:E$.headerButtons,children:lS(i)?(0,sl.jsxs)(sl.Fragment,{children:[(x||g)&&(0,sl.jsx)(uo.HeaderGlobalAction,{"aria-label":g?nB("minimize"):nB("maximize"),onClick:()=>p(h,!g),children:g?(0,sl.jsx)(EP,{}):(0,sl.jsx)(ER.hz,{})}),D&&(0,sl.jsx)(uo.HeaderGlobalAction,{"aria-label":nB("hide"),onClick:()=>f(),children:(0,sl.jsx)(uE,{})}),!E&&(0,sl.jsx)(uo.HeaderGlobalAction,{"aria-label":nB("close"),onClick:a,children:(0,sl.jsx)(uB,{})})]}):(0,sl.jsxs)(sl.Fragment,{children:[D&&(0,sl.jsx)(uo.HeaderGlobalAction,{"aria-label":nB("hide"),onClick:()=>f(),children:(0,sl.jsx)(ET.d3,{})}),(0,sl.jsx)(uo.HeaderGlobalAction,{"aria-label":nB("close"),onClick:()=>{E?Ee():a()},children:(0,sl.jsx)(uB,{})})]})})]}),o]}):(0,sl.jsx)(uo.InlineLoading,{className:E$.loader,description:`${nB("loading")} ...`})})})]})},EA=({openedWindow:e,groupProps:t,actions:r,renderChrome:n,showActionMenu:a})=>{let{openedWorkspaces:o}=e,[i,s]=(0,so.useState)({}),l=sf(i0,EN),u=(0,so.useRef)(new Set);return(0,so.useEffect)(()=>{let e=!1;return Promise.all(o.map(async t=>{let r=l[t.workspaceName];if(!r)return null;let{moduleName:n,component:a}=r;try{return[t.uuid,await lX(n,a)]}catch(r){return e||u.current.has(t.uuid)||(u.current.add(t.uuid),k(r)),[t.uuid,null]}})).then(t=>{e||s(Object.fromEntries(t.filter(e=>null!=e)))},k),()=>{e=!0}},[o,l]),(0,sl.jsx)(sl.Fragment,{children:o.map((s,l)=>(0,sl.jsx)(EO,{openedWorkspace:s,openedWindow:e,groupProps:t,actions:r,renderChrome:n,lifeCycle:i[s.uuid],isRootWorkspace:0===l,isLeafWorkspace:l===o.length-1,showActionMenu:a},s.uuid))})},EM=e=>e.registeredWorkspacesByName,Ej=({name:e,workspaceProps:t,windowProps:r,groupProps:n,onWindowChanged:a})=>{let o=sf(i0,EM),i=sf(i0,t=>{let r=t.registeredWorkspacesByName[e]?.window;return r?t.registeredWindowsByName[r]:void 0}),s={name:e,workspaceProps:t,windowProps:r,groupProps:n},l=(0,so.useRef)(),u=(0,so.useRef)(null);if(!l.current){let a=Ey(e,t,r);l.current=V({openedWindow:a,groupProps:n??null}),a&&(u.current=s)}let c=l.current;(0,so.useEffect)(()=>{let a=u.current;if(a&&a.name===e&&T(a.workspaceProps,t)&&T(a.windowProps,r)&&T(a.groupProps,n))return;let o=Ey(e,t,r);c.setState({openedWindow:o,groupProps:n??null},!0),u.current=o?s:null},[e,t,r,n,o,c]);let d=(0,so.useMemo)(()=>(function(e){function t(t){e.setState(e=>{if(!e.openedWindow)return e;let r=t(e.openedWindow);return r===e.openedWindow?e:{...e,openedWindow:r}})}return{closeWorkspace(e){t(t=>Es(t,e))},openChildWorkspace(e,r,n){t(t=>El(t,e,r,n))},setWorkspaceTitle(e,r){t(t=>Eu(t,e,{title:r}))},setHasUnsavedChanges(e,r){t(t=>Eu(t,e,{hasUnsavedChanges:r}))},promptForClosingWorkspaces(t){let{openedWindow:r}=e.getState();return r?Ei(r,t):Promise.resolve(!0)}}})(c),[c]),{openedWindow:m,groupProps:p}=sf(c),f=m?.openedWorkspaces[m.openedWorkspaces.length-1],h=f?.workspaceName??null,g=f?.title??"",y=m?.openedWorkspaces.some(e=>e.hasUnsavedChanges)??!1,v=i?.width??"narrow",b=(0,so.useRef)(a);return(0,so.useEffect)(()=>{b.current=a}),(0,so.useEffect)(()=>{b.current?.({workspaceName:h,windowWidth:v,title:g,hasUnsavedChanges:y})},[h,v,g,y]),(0,sl.jsx)("div",{className:"-esm-patient-chart__exported-workspace-module__exportedWorkspace___3vwoL",children:m?(0,sl.jsx)(EA,{openedWindow:m,groupProps:p,actions:d,renderChrome:!1,showActionMenu:!1}):null})},EL="-esm-patient-chart__action-menu-button2-module__container___pahg-",EF="-esm-patient-chart__action-menu-button2-module__elementContainer___PzOdc",EB="-esm-patient-chart__action-menu-button2-module__active___4O4Bs",EV="-esm-patient-chart__action-menu-button2-module__focused___+k5kD";function EU({getIcon:e,hasUnsavedChanges:t,tagContent:r}){return(0,sl.jsxs)(sl.Fragment,{children:[e({size:16}),t?(0,sl.jsx)("span",{className:"-esm-patient-chart__action-menu-button2-module__interruptedTag___mS2yr",children:"!"}):(0,sl.jsx)("span",{className:"-esm-patient-chart__action-menu-button2-module__countTag___rb5CW",children:r})]})}let EW=({icon:e,label:t,tagContent:r,workspaceToLaunch:n,onBeforeWorkspaceLaunch:a,hidden:o,disabled:i})=>{let s=lD(),{openedWindows:l,restoreWindow:u,hideWindow:c,isMostRecentlyOpenedWindowHidden:d}=Em(),{extension:m}=(0,so.useContext)(ss),p=l.findIndex(e=>e.windowName===m?.extensionId),f=l[p],h=null!=f,g=h&&(p<l.length-1||d),y=h&&!g,v=f?.openedWorkspaces.some(e=>e.hasUnsavedChanges)??!1,b=async()=>{if(h)g?u(f.windowName):c();else if(await (a?.()??!0)){let{workspaceName:e,workspaceProps:t,windowProps:r}=n;Et(e,t,r)}};return o?.(l)?null:"tablet"===s||"phone"===s?(0,sl.jsxs)(uo.Button,{className:ue()(EL,{[EB]:h&&!y,[EV]:y}),iconDescription:t,kind:"ghost",onClick:b,role:"button",tabIndex:0,size:"md",disabled:i?.(l),children:[(0,sl.jsx)("span",{className:EF,children:(0,sl.jsx)(EU,{hasUnsavedChanges:v,getIcon:e,tagContent:r})}),(0,sl.jsx)("span",{children:t})]}):(0,sl.jsx)(uo.IconButton,{align:"left","aria-label":t,className:ue()(EL,{[EB]:h&&!y,[EV]:y}),enterDelayMs:300,kind:"ghost",label:t,onClick:b,size:"md",disabled:i?.(l),children:(0,sl.jsx)("div",{className:EF,children:(0,sl.jsx)(EU,{hasUnsavedChanges:v,getIcon:e,tagContent:r})})})};function EH({showContactDetails:e,toggleContactDetails:t,className:r}){return(0,sl.jsx)(uo.Button,{className:r,iconDescription:"Toggle contact details",kind:"ghost",onClick:t,renderIcon:e?uF:uM,children:e?nB("showLess","Show less"):nB("showMore","Show more")})}let Ez={contactDetails:"-esm-patient-chart__patient-banner-contact-details-module__contactDetails___rhdjA",deceased:"-esm-patient-chart__patient-banner-contact-details-module__deceased___K4NPg",heading:"-esm-patient-chart__patient-banner-contact-details-module__heading___zj6Zt",row:"-esm-patient-chart__patient-banner-contact-details-module__row___+Bx+P",col:"-esm-patient-chart__patient-banner-contact-details-module__col___0H31P",relationship:"-esm-patient-chart__patient-banner-contact-details-module__relationship___CZmay"},EK=({patientUuid:e})=>{let{cohorts:t=[],isLoading:r}=function(e){let t=e?`${nQ}/cohortm/cohortmember?patient=${e}&v=custom:(uuid,patient:ref,cohort:(uuid,name,startDate,endDate))`:null,{data:r,isLoading:n}=s$()(t,n2),a=r?.data?.results.map(e=>({uuid:e.cohort.uuid,name:e.cohort.name,startDate:e.cohort.startDate,endDate:e.cohort.endDate}));return(0,so.useMemo)(()=>({cohorts:a,isLoading:n}),[n,a])}(e);return(0,sl.jsxs)(sl.Fragment,{children:[(0,sl.jsxs)("p",{className:Ez.heading,children:[nB("patientLists","Patient Lists")," (",t?.length??0,")"]}),r?(0,sl.jsx)(uo.InlineLoading,{description:`${nB("loading","Loading")} ...`,role:"progressbar"}):(0,sl.jsxs)("ul",{children:[(()=>{if(t?.length>0){let e=t.sort((e,t)=>v3(e?.startDate).getTime()-v3(t?.startDate).getTime()).slice(0,3);return e?.map(e=>(0,sl.jsx)("li",{children:(0,sl.jsx)(su,{to:`${window.spaBase}/home/patient-lists/${e.uuid}`,children:e.name},e.uuid)},e.uuid))}return(0,sl.jsx)("li",{children:"--"})})(),t.length>3&&(0,sl.jsx)("li",{className:Ez.link,children:(0,sl.jsx)(su,{to:`${window.spaBase}/home/patient-lists`,children:nB("seeMoreLists","See {{count}} more lists",{count:t?.length-3})})})]})]})},EG=({patientId:e})=>{let{patient:t,isLoading:r}=lA(e),n=t?.address?.find(e=>"home"===e.use),a=e=>e.split("#")[1];return r?(0,sl.jsx)(uo.InlineLoading,{description:`${nB("loading","Loading")} ...`,role:"progressbar"}):(0,sl.jsxs)(sl.Fragment,{children:[(0,sl.jsx)("p",{className:Ez.heading,children:nB("address","Address")}),(0,sl.jsx)("ul",{children:n?Object.entries(n).filter(([e])=>"id"!==e&&"use"!==e).map(([e,t])=>"extension"===e?n.extension?.[0]?.extension?.map((t,r)=>(0,sl.jsxs)("li",{children:[nB(a(t.url),a(t.url)),": ",t.valueString]},`address-${e}-${r}`)):(0,sl.jsxs)("li",{children:[nB(e,e),": ",t]},`address-${e}`)):(0,sl.jsx)("li",{children:"--"})})]})},EZ=({patientUuid:e})=>{let{isLoading:t,contactAttributes:r}=(e=>{let{contactAttributeTypes:t=[]}=s5({externalModuleName:"@openmrs/esm-patient-banner-app"}),{attributes:r,error:n,isLoading:a}=(e=>{let{data:t,error:r,isLoading:n}=le()(`${nQ}/patient/${e}?v=custom:(uuid,display,identifiers:(identifier,uuid,preferred,location:(uuid,name),identifierType:(uuid,name,format,formatDescription,validator)),person:(uuid,display,gender,birthdate,dead,age,deathDate,birthdateEstimated,causeOfDeath,preferredName:(uuid,preferred,givenName,middleName,familyName),attributes,preferredAddress:(uuid,preferred,address1,address2,cityVillage,longitude,stateProvince,latitude,country,postalCode,countyDistrict,address3,address4,address5,address6,address7)))`,n2);return{isLoading:n,attributes:t?.data.person.attributes??[],error:r}})(e);return{contactAttributes:(0,so.useMemo)(()=>r.filter(({attributeType:e})=>t?.some(t=>e.uuid===t)),[r,t]),isLoading:a,error:n}})(e),n=(0,so.useMemo)(()=>r?[...r?.map(e=>[e.attributeType.display?nB(e.attributeType.display,e.attributeType.display):"",e.value])]:[],[r]);return(0,sl.jsxs)(sl.Fragment,{children:[(0,sl.jsx)("p",{className:Ez.heading,children:nB("contactDetails","Contact Details")}),t?(0,sl.jsx)(uo.InlineLoading,{description:`${nB("loading","Loading")} ...`,role:"progressbar"}):(0,sl.jsx)("ul",{children:n.length?n.map(([e,t],r)=>(0,sl.jsxs)("li",{children:[e,": ",t]},`${e}-${t}-${r}`)):(0,sl.jsx)("li",{children:"--"})})]})},EY=({patientId:e})=>{let{data:t,isLoading:r}=function(e){let t=`${nQ}/relationship?v=custom:(display,uuid,personA:(age,display,birthdate,uuid),personB:(age,display,birthdate,uuid),relationshipType:(uuid,display,description,aIsToB,bIsToA))&person=${e}`,{data:r,error:n,isLoading:a,isValidating:o}=s$()(e?t:null,n2),i=r?.data?.results?.length?function(e,t){let r=[];for(let n of t)e===n.personA.uuid?r.push({uuid:`${n.uuid}`,display:n.personB.display,relativeAge:n.personB.age,relativeUuid:n.personB.uuid,relationshipType:n.relationshipType.bIsToA}):r.push({uuid:`${n.uuid}`,display:n.personA.display,relativeAge:n.personA.age,relativeUuid:n.personA.uuid,relationshipType:n.relationshipType.aIsToB});return r}(e,r.data.results):null;return{data:r?i:null,error:n,isLoading:a,isValidating:o}}(e);return(0,sl.jsxs)(sl.Fragment,{children:[(0,sl.jsx)("p",{className:Ez.heading,children:nB("relationships","Relationships")}),r?(0,sl.jsx)(uo.InlineLoading,{description:`${nB("loading","Loading")} ...`,role:"progressbar"}):(0,sl.jsx)("ul",{children:t&&t.length>0?(0,sl.jsx)(sl.Fragment,{children:t.map(e=>(0,sl.jsxs)("li",{className:Ez.relationship,children:[(0,sl.jsx)("div",{children:(0,sl.jsx)(su,{to:`${window.spaBase}/patient/${e.relativeUuid}/chart`,children:e.display})}),(0,sl.jsx)("div",{children:e.relationshipType}),(0,sl.jsx)("div",{children:`${e.relativeAge?e.relativeAge:"--"} ${e.relativeAge?1===e.relativeAge?nB("yearAbbreviation","yr"):nB("yearsAbbreviation","yrs"):""}`})]},e.uuid))}):(0,sl.jsx)("li",{children:"--"})})]})};function Eq({patientId:e,deceased:t}){return(0,sl.jsxs)("div",{className:ue()(Ez.contactDetails,{[Ez.deceased]:t}),children:[(0,sl.jsxs)("div",{className:Ez.row,children:[(0,sl.jsx)("div",{className:Ez.col,children:(0,sl.jsx)(EG,{patientId:e})}),(0,sl.jsx)("div",{className:Ez.col,children:(0,sl.jsx)(EZ,{patientUuid:e})})]}),(0,sl.jsxs)("div",{className:Ez.row,children:[(0,sl.jsx)("div",{className:Ez.col,children:(0,sl.jsx)(EY,{patientId:e})}),(0,sl.jsx)("div",{className:Ez.col,children:(0,sl.jsx)(EK,{patientUuid:e})})]})]})}function EJ(e){let t=document.querySelector("template#loading-spinner");if(t){let r=t.content.cloneNode(!0),n=Array.prototype.map.call(r.childNodes,e=>e);return e.appendChild(r),()=>n.forEach(e=>e.remove())}return()=>{}}let EX="-esm-patient-chart__action-menu2-module__container___5s3CM";function EQ({workspaceGroup:e,groupProps:t}){let r=lD(),{persistence:n}=e;return(0,sl.jsx)("aside",{className:"-esm-patient-chart__action-menu2-module__sideRail___qwAz4",children:(0,sl.jsxs)("div",{className:EX,children:["closable"==n&&lS(r)&&(0,sl.jsx)(uo.IconButton,{align:"left",onClick:()=>Ee(),label:nB("close"),kind:"ghost",children:(0,sl.jsx)(uB,{})}),(0,sl.jsx)(ss.Provider,{value:{moduleName:e.moduleName,featureName:e.name},children:(0,sl.jsx)(sS,{className:EX,name:e.name,state:{groupProps:t}})})]})})}function E0(e){let t=new URL(e,window.location.origin).pathname,r=new URL(window.getOpenmrsSpaBase?.()??"/",window.location.origin).pathname,n=r.endsWith("/")?r.slice(0,-1):r,a=null;return n?n===t?a="/":t.startsWith(`${n}/`)&&(a=t.slice(n.length)):a=t,{full:t,spaRelative:a}}function E1(e){e&&(0,s_.createRoot)(e).render((0,sl.jsx)(E4,{}))}function E4(){let{openedGroup:e,openedWindows:t,registeredGroupsByName:r,registeredWindowsByName:n}=Em();if((0,so.useEffect)(()=>ou("before-page-changed",t=>{let{newPage:n,cancelNavigation:a,oldUrl:o,newUrl:i}=t;if(!e)return;if(n)return void a(Ee().then(e=>!e));let s=r[e.groupName],l=s?.scopePattern;l&&function(e,t,r){try{let n=new RegExp(e),a=E0(t),o=E0(r);if(null===a.spaRelative||null===o.spaRelative)return!0;let i=n.exec(a.spaRelative),s=n.exec(o.spaRelative);if(i&&s||(i=n.exec(a.full),s=n.exec(o.full)),!i||!s)return!0;if(i.length>1)return!i.slice(1).every((e,t)=>e===s[t+1]);return!1}catch{return!0}}(l,o,i)&&a(Ee().then(e=>!e))}),[e,r]),!e)return null;let a=r[e.groupName],o=t.some(e=>e.maximized),{name:i}=a,s=Object.values(n).filter(e=>e.group===i&&void 0!==e.icon).sort((e,t)=>(e.order??Number.MAX_VALUE)-(t.order??Number.MAX_VALUE)).length>0;return(0,sl.jsxs)("div",{className:ue()("-esm-patient-chart__workspace-windows-and-menu-module__workspaceWindowsAndMenuContainer___gN2f4",{"-esm-patient-chart__workspace-windows-and-menu-module__overlay___fqI+X":a.overlay,"-esm-patient-chart__workspace-windows-and-menu-module__hasMaximizedWindow___J7wBw":o}),children:[(0,sl.jsx)("div",{className:"-esm-patient-chart__workspace-windows-and-menu-module__workspaceWindowsContainer___zpk7G",children:t.map(t=>(0,sl.jsx)(E2,{openedWindow:t,groupProps:e.props,showActionMenu:s},t.windowName))}),s&&(0,sl.jsx)(EQ,{workspaceGroup:a,groupProps:e.props})]})}function E2({openedWindow:e,groupProps:t,showActionMenu:r}){let{windowName:n}=e,a=(0,so.useMemo)(()=>({closeWorkspace(e){i0.setState(t=>Ed.closeWorkspace(t,e))},openChildWorkspace(e,t,r){i0.setState(n=>Ed.openChildWorkspace(n,e,t,r))},setWorkspaceTitle(e,t){i0.setState(r=>Ed.setWorkspaceTitle(r,e,t))},setHasUnsavedChanges(e,t){i0.setState(r=>Ed.setHasUnsavedChanges(r,e,t))},promptForClosingWorkspaces(e){let t=i0.getState().openedWindows.find(e=>e.windowName===n);return t?Ei(t,e):Promise.resolve(!0)}}),[n]);return(0,sl.jsx)(EA,{openedWindow:e,groupProps:t,actions:a,renderChrome:!0,showActionMenu:r})}function E3(e,t,r){if(null==e)return r;let n=vy(e);if(!n)return console.warn(`matchLocale: invalid requested locale tag: ${JSON.stringify(e)}`),r;let a=[];for(let e of t){let t=vy(e);if(!t){console.warn(`matchLocale: skipping invalid available locale tag: ${JSON.stringify(e)}`);continue}a.push({canonical:t,original:e})}let o=n;for(;o;){let e=a.find(e=>e.canonical===o);if(e)return e.original;let t=o+"-",r=a.find(e=>e.canonical.startsWith(t));if(r)return r.original;if("ht"===o){o="fr-HT";continue}let n=o.lastIndexOf("-");if(-1===n)break;let i=(o=o.slice(0,n)).lastIndexOf("-");-1!==i&&o.length-i==2&&(o=o.slice(0,i))}return r}function E6(e=window.localStorage){try{return e.getItem("test"),!0}catch{return!1}}function E5(e){return!!e&&e.constructor===Object}var E9=r(7229);function E8(e){let[t,r,n]=e.split(".");return`${t}.${r}.${n}`}function E7(e,t){return E9(function(e){let t=e.indexOf("-");if(t>=0){let r=E8(e.slice(0,t)),n=e.slice(t+1);return`${r}-${n}`}return E8(e)}(t),e,{includePrerelease:!0})}async function De(e,t={}){let r,{shouldRetry:n,getDelay:a,onError:o}=t;n=n??(e=>e<=5),a=a??(e=>(function(e,t=!1){return 1e3*Math.pow(2,t?e+1:e)})(e));let i=0;do try{return await Dt(a(i)),await e()}catch(e){o?.(e,i),r=e}while(n(i++));throw r}async function Dt(e){if(!(e<=0))return new Promise(t=>setTimeout(t,e))}function Dr(e,t,r,n){}function Dn(e){}function Da(e){return Promise.resolve([])}function Do(e){return Promise.resolve([])}function Di(e){return Promise.resolve({success:!1,result:void 0,error:"No service worker has been registered. Offline-related features have been removed from the framework."})}function Ds(e){return()=>{}}function Dl(){return!0}},8007(e,t,r){"use strict";r.d(t,{A:()=>n});let n=function(e,t,r){var n=-1,a=e.length;t<0&&(t=-t>a?0:a+t),(r=r>a?a:r)<0&&(r+=a),a=t>r?0:r-t>>>0,t>>>=0;for(var o=Array(a);++n<a;)o[n]=e[n+t];return o}},5992(e,t,r){"use strict";r.d(t,{A:()=>m});var n=r(3264),a=r(616),o=r(6770),i=r(6956),s=r(1475),l=r(1917),u=r(1140),c=r(480),d=Object.prototype.hasOwnProperty;let m=function(e){if(null==e)return!0;if((0,s.A)(e)&&((0,i.A)(e)||"string"==typeof e||"function"==typeof e.splice||(0,l.A)(e)||(0,c.A)(e)||(0,o.A)(e)))return!e.length;var t=(0,a.A)(e);if("[object Map]"==t||"[object Set]"==t)return!e.size;if((0,u.A)(e))return!(0,n.A)(e).length;for(var r in e)if(d.call(e,r))return!1;return!0}},254(e,t,r){"use strict";r.d(t,{A:()=>n});let n=function(e){return null==e}}}]);
39
+ }`.trim(),document.head.prepend(n),o=HTMLElement.prototype.focus,HTMLElement.prototype.focus=function(e){let t=((e=document)=>e.activeElement)(),r=null!=t&&yV(t);o.call(this,{...e,preventScroll:!0}),e&&e.preventScroll||yK(this,r)},i=c3(yz(document,"touchstart",t=>{let n=dA(t);e=fH(n)?n:fz(n,!0),r=!1;let a=n.ownerDocument.defaultView.getSelection();a&&!a.isCollapsed&&a.containsNode(n,!0)&&(r=!0),t.composedPath().some(e=>e instanceof HTMLInputElement&&"range"===e.type)&&(r=!0),"selectionStart"in n&&"selectionEnd"in n&&n.selectionStart<n.selectionEnd&&n.ownerDocument.activeElement===n&&(r=!0)},{passive:!1,capture:!0}),yz(document,"touchmove",t=>{if(2!==t.touches.length&&!r){if(!e||e===document.documentElement||e===document.body)return void t.preventDefault();e.scrollHeight===e.clientHeight&&e.scrollWidth===e.clientWidth&&t.preventDefault()}},{passive:!1,capture:!0}),yz(document,"blur",e=>{let t=dA(e),r=e.relatedTarget;if(r&&yV(r))r.focus({preventScroll:!0}),yK(r,yV(t));else if(!r){let e=t.parentElement?.closest("[tabindex]");e?.focus({preventScroll:!0})}},!0)),()=>{t(),i(),n.remove(),HTMLElement.prototype.focus=o}):c3((s=window.innerWidth-document.documentElement.clientWidth)>0&&("scrollbarGutter"in document.documentElement.style?yH(document.documentElement,"scrollbarGutter","stable"):yH(document.documentElement,"paddingRight",`${s}px`)),yH(document.documentElement,"overflow","hidden"))),()=>{0==--yW&&u()}}},[t])}({isDisabled:o||!t.isOpen}),(0,so.useEffect)(()=>{if(t.isOpen&&n.current)if(o){var e,r,i=a?.current??n.current;let t=yh[yh.length-1];return t&&!t.visibleNodes.has(i)?(t.visibleNodes.add(i),()=>{t.visibleNodes.delete(i)}):void 0}else{let t,o,i,s,l,u,c,d,m,p,f;return e=[a?.current??n.current],o=(r={shouldUseInert:!0})instanceof(t=dO(e?.[0])).Element?{root:r}:r,i=o?.root??document.body,s=o?.shouldUseInert&&yp,l=new Set(e),u=new Set,c=(e,r)=>{s&&e instanceof t.HTMLElement?e.inert=r:r?e.setAttribute("aria-hidden","true"):(e.removeAttribute("aria-hidden"),e instanceof t.HTMLElement&&(e.inert=!1))},d=e=>{for(let t of e.querySelectorAll("[data-live-announcer], [data-react-aria-top-layer]"))l.add(t);let t=e=>{if(u.has(e)||l.has(e)||e.parentElement&&u.has(e.parentElement)&&"row"!==e.parentElement.getAttribute("role"))return NodeFilter.FILTER_REJECT;for(let t of l)if(dI(e,t))return NodeFilter.FILTER_SKIP;return NodeFilter.FILTER_ACCEPT},r=h5(dN(e),e,NodeFilter.SHOW_ELEMENT,{acceptNode:t}),n=t(e);if(n===NodeFilter.FILTER_ACCEPT&&m(e),n!==NodeFilter.FILTER_REJECT){let e=r.nextNode();for(;null!=e;)m(e),e=r.nextNode()}},m=e=>{let r=yf.get(e)??0;(s&&e instanceof t.HTMLElement?e.inert:"true"===e.getAttribute("aria-hidden"))&&0===r||(0===r&&c(e,!0),u.add(e),yf.set(e,r+1))},yh.length&&yh[yh.length-1].disconnect(),d(i),(p=new MutationObserver(e=>{for(let r of e)if("childList"===r.type&&r.target.isConnected&&![...l,...u].some(e=>dI(e,r.target)))for(let e of r.addedNodes){var t;(e instanceof HTMLElement||e instanceof SVGElement)&&("true"===(t=e).dataset.liveAnnouncer||void 0!==t.dataset.reactAriaTopLayer)?l.add(e):e instanceof Element&&d(e)}})).observe(i,{childList:!0,subtree:!0}),f={visibleNodes:l,hiddenNodes:u,observe(){p.observe(i,{childList:!0,subtree:!0})},disconnect(){p.disconnect()}},yh.push(f),()=>{for(let e of(p.disconnect(),u)){let t=yf.get(e);null!=t&&(1===t?(c(e,!1),yf.delete(e)):yf.set(e,t-1))}f===yh[yh.length-1]?(yh.pop(),yh.length&&yh[yh.length-1].observe()):yh.splice(yh.indexOf(f),1)}}},[o,t.isOpen,n,a]),{popoverProps:dd(d,p),arrowProps:f,underlayProps:m,placement:h,triggerAnchorPoint:g}}({...n,offset:null!=(a=n.offset)?a:8,arrowSize:s,groupRef:m?d:c},e),y=n.popoverRef,v=yq(y,!!g)||n.isEntering||!1,b=df({...n,defaultClassName:"react-aria-Popover",values:{trigger:n.trigger||null,placement:g,isEntering:v,isExiting:t}}),w=!n.isNonModal||"SubmenuTrigger"===n.trigger,[x,E]=(0,so.useState)(!1);c6(()=>{y.current&&E(w&&!y.current.querySelector("[role=dialog]"))},[y,w]),(0,so.useEffect)(()=>{var e;let t,r;x&&y.current&&!y.current.contains(document.activeElement)&&(r=((e=document)=>e.activeElement)(t=dN(e=y.current)),"virtual"===yQ?my(()=>{((e=document)=>e.activeElement)(t)===r&&e.isConnected&&dT(e)}):dT(e))},[x,y]);let D={...p.style,...b.style},S=si().createElement("div",{...dd(dR(n),p),...b,role:x?"dialog":void 0,tabIndex:x?-1:void 0,"aria-label":n["aria-label"],"aria-labelledby":n["aria-labelledby"],ref:y,slot:n.slot||void 0,style:D,dir:n.dir,"data-trigger":n.trigger,"data-placement":g,"data-entering":v||void 0,"data-exiting":t||void 0},!n.isNonModal&&si().createElement(yY,{onDismiss:e.close}),si().createElement(ym.Provider,{value:{...h,placement:g,ref:i}},b.children),si().createElement(yY,{onDismiss:e.close}));return m?si().createElement(yr,{...n,shouldContainFocus:x,isExiting:t,portalContainer:null!=(o=null!=r?r:null==d?void 0:d.current)?o:void 0},S):si().createElement(yr,{...n,shouldContainFocus:x,isExiting:t,portalContainer:r},!n.isNonModal&&e.isOpen&&si().createElement("div",{"data-testid":"underlay",...f,style:{position:"fixed",inset:0}}),si().createElement("div",{ref:c,style:{display:"contents"}},si().createElement(va.Provider,{value:c},S)))}function vs(e){return e?.start!=null&&null!=e.end}let vl=(0,so.createContext)(null),vu=(0,so.createContext)(null),vc=(0,so.createContext)(null),vd=(0,so.createContext)(null),vm=(0,so.forwardRef)(function(e,t){var r,n;[e,t]=dg(e,t,vl);let{validationBehavior:a}=dh(yu)||{},o=null!=(n=null!=(r=e.validationBehavior)?r:a)?n:"native",i=function(e){let t=vr(e),[r,n]=hL(e.value,e.defaultValue||null,e.onChange),[a]=(0,so.useState)(r),o=r||e.placeholderValue||null,[i,s]=gK(o,e.granularity),l=null!=r?r.toDate(s??"UTC"):null,u="hour"===i||"minute"===i||"second"===i,c=e.shouldCloseOnSelect??!0,[d,m]=(0,so.useState)(null),[p,f]=(0,so.useState)(null);if(r&&(d=r,"hour"in r&&(p=r)),o&&!(i in o))throw Error("Invalid granularity "+i+" for value "+o.toString());let h=r?.calendar.identifier==="gregory"&&"BC"===r.era,g=(0,so.useMemo)(()=>({granularity:i,timeZone:s,hideTimeZone:e.hideTimeZone,hourCycle:e.hourCycle,shouldForceLeadingZeros:e.shouldForceLeadingZeros,showEra:h}),[i,e.hourCycle,e.shouldForceLeadingZeros,s,e.hideTimeZone,h]),{minValue:y,maxValue:v,isDateUnavailable:b}=e,w=(0,so.useMemo)(()=>gB(r,y,v,b,g),[r,y,v,b,g]),x=gO({...e,value:r,builtinValidation:w}),E=x.displayValidation.isInvalid,D=e.validationState||(E?"invalid":null),S=(e,t)=>{n("timeZone"in t?t.set(fc(e)):fd(e,t)),m(null),f(null),x.commitValidation()};return{...x,value:r,defaultValue:e.defaultValue??a,setValue:n,dateValue:d,timeValue:p,setDateValue:r=>{let a="function"==typeof c?c():c;u?p||a?S(r,p||gH(e.defaultValue||e.placeholderValue)):m(r):(n(r),x.commitValidation()),a&&t.setOpen(!1)},setTimeValue:e=>{d&&e?S(d,e):f(e)},granularity:i,hasTime:u,...t,setOpen(n){!n&&!r&&d&&u&&S(d,p||gH(e.defaultValue||e.placeholderValue)),t.setOpen(n)},validationState:D,isInvalid:E,formatValue:(e,t)=>l?new pb(e,gW(t,g)).format(l):"",getDateFormatter:(e,t)=>new pb(e,gW({},{...g,...t}))}}({...e,validationBehavior:o}),s=(0,so.useRef)(null),[l,u]=dy(!e["aria-label"]&&!e["aria-labelledby"]),{groupProps:c,labelProps:d,fieldProps:m,buttonProps:p,dialogProps:f,calendarProps:h,descriptionProps:g,errorMessageProps:y,...v}=function(e,t,r){var n;let a=dl(),o=dl(),i=dl(),s=pI((n=gy)&&n.__esModule?n.default:n,"@react-aria/datepicker"),{isInvalid:l,validationErrors:u,validationDetails:c}=t.displayValidation,{labelProps:d,fieldProps:m,descriptionProps:p,errorMessageProps:f}=gw({...e,labelElementType:"span",isInvalid:l,errorMessage:e.errorMessage||u}),h=gv(t,r),g=m["aria-labelledby"]||m.id,{locale:y}=pm(),v=t.formatValue(y,{month:"long"}),b=fJ(v?s.format("selectedDateDescription",{date:v}):""),w=[b["aria-describedby"],m["aria-describedby"]].filter(Boolean).join(" ")||void 0,x=dR(e),E=(0,so.useMemo)(()=>gm(r),[r]),D=(0,so.useRef)(!1),{focusWithinProps:S}=mZ({...e,isDisabled:t.isOpen,onBlurWithin:t=>{dI(document.getElementById(o),t.relatedTarget)||(D.current=!1,e.onBlur?.(t),e.onFocusChange?.(!1))},onFocusWithin:t=>{D.current||(D.current=!0,e.onFocus?.(t),e.onFocusChange?.(!0))}});return{groupProps:dd(x,h,m,b,S,{role:"group","aria-disabled":e.isDisabled||null,"aria-labelledby":g,"aria-describedby":w,onKeyDown(r){!t.isOpen&&e.onKeyDown&&e.onKeyDown(r)},onKeyUp(r){!t.isOpen&&e.onKeyUp&&e.onKeyUp(r)}}),labelProps:{...d,onClick:()=>{E.focusFirst()}},fieldProps:{...m,id:i,[gS]:"presentation","aria-describedby":w,value:t.value,defaultValue:t.defaultValue,onChange:t.setValue,placeholderValue:e.placeholderValue,hideTimeZone:e.hideTimeZone,hourCycle:e.hourCycle,shouldForceLeadingZeros:e.shouldForceLeadingZeros,granularity:e.granularity,isDisabled:e.isDisabled,isReadOnly:e.isReadOnly,isRequired:e.isRequired,validationBehavior:e.validationBehavior,[gN]:t,autoFocus:e.autoFocus,name:e.name,form:e.form},descriptionProps:p,errorMessageProps:f,buttonProps:{...b,id:a,"aria-haspopup":"dialog","aria-label":s.format("calendar"),"aria-labelledby":`${a} ${g}`,"aria-describedby":w,"aria-expanded":t.isOpen,isDisabled:e.isDisabled||e.isReadOnly,onPress:()=>t.setOpen(!0)},dialogProps:{id:o,"aria-labelledby":`${a} ${g}`},calendarProps:{autoFocus:!0,value:t.dateValue,onChange:t.setDateValue,minValue:e.minValue,maxValue:e.maxValue,isDisabled:e.isDisabled,isReadOnly:e.isReadOnly,isDateUnavailable:e.isDateUnavailable,defaultFocusedValue:t.dateValue?void 0:e.placeholderValue,isInvalid:t.isInvalid,errorMessage:"function"==typeof e.errorMessage?e.errorMessage(t.displayValidation):e.errorMessage||t.displayValidation.validationErrors.join(" "),firstDayOfWeek:e.firstDayOfWeek,pageBehavior:e.pageBehavior},isInvalid:l,validationErrors:u,validationDetails:c}}({...dv(e),label:u,validationBehavior:o},i,s),[b,w]=(0,so.useState)(null),x=(0,so.useCallback)(()=>{s.current&&w(s.current.offsetWidth+"px")},[]);yA({ref:s,onResize:x});let{focusProps:E,isFocused:D,isFocusVisible:S}=mY({within:!0}),_=df({...e,values:{state:i,isFocusWithin:D,isFocusVisible:S,isDisabled:e.isDisabled||!1,isInvalid:i.isInvalid,isOpen:i.isOpen},defaultClassName:"react-aria-DatePicker"}),C=dR(e);return delete C.id,si().createElement(dp,{values:[[vc,i],[h4,{...c,ref:s,isInvalid:i.isInvalid}],[g4,m],[m3,{...p,isPressed:i.isOpen}],[yc,{...d,ref:l,elementType:"span"}],[hH,h],[ya,i],[vn,{trigger:"DatePicker",triggerRef:s,placement:"bottom start",style:{"--trigger-width":b}}],[yn,f],[m9,{slots:{description:g,errorMessage:y}}],[yi,v]]},si().createElement("div",{...E,...C,..._,ref:t,slot:e.slot||void 0,"data-focus-within":D||void 0,"data-invalid":i.isInvalid||void 0,"data-focus-visible":S||void 0,"data-disabled":e.isDisabled||void 0,"data-open":i.isOpen||void 0}))}),vp=(0,so.forwardRef)(function(e,t){var r,n;[e,t]=dg(e,t,vu);let{validationBehavior:a}=dh(yu)||{},o=null!=(n=null!=(r=e.validationBehavior)?r:a)?n:"native",i=function(e){let t=vr(e),[r,n]=hL(e.value,e.defaultValue||null,e.onChange),[a]=(0,so.useState)(r),[o,i]=(0,so.useState)(()=>r||{start:null,end:null});null==r&&o.start&&o.end&&i(o={start:null,end:null});let s=r||o,l=e=>{i(s=e||{start:null,end:null}),vs(s)?n(s):n(null)},[u,c]=gK(s?.start||s?.end||e.placeholderValue||null,e.granularity),d="hour"===u||"minute"===u||"second"===u,m=e.shouldCloseOnSelect??!0,[p,f]=(0,so.useState)(null),[h,g]=(0,so.useState)(null);s&&vs(s)&&(p=s,"hour"in s.start&&(h=s));let y=(e,t)=>{l({start:"timeZone"in t.start?t.start.set(fc(e.start)):fd(e.start,t.start),end:"timeZone"in t.end?t.end.set(fc(e.end)):fd(e.end,t.end)}),f(null),g(null),C.commitValidation()},v=r=>{let n="function"==typeof m?m():m;d?vs(r)&&(n||h?.start&&h?.end)?y(r,{start:h?.start||gH(e.placeholderValue),end:h?.end||gH(e.placeholderValue)}):f(r):vs(r)?(l(r),C.commitValidation()):f(r),n&&t.setOpen(!1)},b=e=>{vs(p)&&vs(e)?y(p,e):g(e)},w=s?.start?.calendar.identifier==="gregory"&&"BC"===s.start.era||s?.end?.calendar.identifier==="gregory"&&"BC"===s.end.era,x=(0,so.useMemo)(()=>({granularity:u,timeZone:c,hideTimeZone:e.hideTimeZone,hourCycle:e.hourCycle,shouldForceLeadingZeros:e.shouldForceLeadingZeros,showEra:w}),[u,e.hourCycle,e.shouldForceLeadingZeros,c,e.hideTimeZone,w]),{minValue:E,maxValue:D,isDateUnavailable:S}=e,_=(0,so.useMemo)(()=>{var e;let t;return e=s,t=gj(gB(e?.start??null,E,D,S,x),gB(e?.end??null,E,D,S,x)),e?.end!=null&&null!=e.start&&0>e.end.compare(e.start)&&(t=gj(t,{isInvalid:!0,validationErrors:[(pP.getGlobalDictionaryForPackage("@react-stately/datepicker")||gL).getStringForLocale("rangeReversed",gF())],validationDetails:{...gP,rangeUnderflow:!0,rangeOverflow:!0,valid:!1}})),t},[s,E,D,S,x]),C=gO({...e,value:r,name:(0,so.useMemo)(()=>[e.startName,e.endName].filter(e=>null!=e),[e.startName,e.endName]),builtinValidation:_}),k=C.displayValidation.isInvalid,P=e.validationState||(k?"invalid":null);return{...C,value:s,defaultValue:e.defaultValue??a,setValue:l,dateRange:p,timeRange:h,granularity:u,hasTime:d,setDate(e,t){"start"===e?v({start:t,end:p?.end??null}):v({start:p?.start??null,end:t})},setTime(e,t){"start"===e?b({start:t,end:h?.end??null}):b({start:h?.start??null,end:t})},setDateTime(e,t){"start"===e?l({start:t,end:s?.end??null}):l({start:s?.start??null,end:t})},setDateRange:v,setTimeRange:b,...t,setOpen(r){!r&&!(s?.start&&s?.end)&&vs(p)&&d&&y(p,{start:h?.start||gH(e.placeholderValue),end:h?.end||gH(e.placeholderValue)}),t.setOpen(r)},validationState:P,isInvalid:k,formatValue(t,r){let n;if(!s||!s.start||!s.end)return null;let a="timeZone"in s.start?s.start.timeZone:void 0,o=e.granularity||(s.start&&"minute"in s.start?"minute":"day"),i="timeZone"in s.end?s.end.timeZone:void 0,l=e.granularity||(s.end&&"minute"in s.end?"minute":"day"),u=gW(r,{granularity:o,timeZone:a,hideTimeZone:e.hideTimeZone,hourCycle:e.hourCycle,showEra:"gregory"===s.start.calendar.identifier&&"BC"===s.start.era||"gregory"===s.end.calendar.identifier&&"BC"===s.end.era}),c=s.start.toDate(a||"UTC"),d=s.end.toDate(i||"UTC"),m=new pb(t,u);if(a===i&&o===l&&0!==s.start.compare(s.end)){try{let e=m.formatRangeToParts(c,d),t=-1;for(let r=0;r<e.length;r++){let n=e[r];if("shared"===n.source&&"literal"===n.type)t=r;else if("endRange"===n.source)break}let r="",n="";for(let a=0;a<e.length;a++)a<t?r+=e[a].value:a>t&&(n+=e[a].value);return{start:r,end:n}}catch{}n=m}else n=new pb(t,gW(r,{granularity:l,timeZone:i,hideTimeZone:e.hideTimeZone,hourCycle:e.hourCycle}));return{start:m.format(c),end:n.format(d)}},getDateFormatter:(e,t)=>new pb(e,gW({},{...x,...t}))}}({...e,validationBehavior:o}),s=(0,so.useRef)(null),[l,u]=dy(!e["aria-label"]&&!e["aria-labelledby"]),{groupProps:c,labelProps:d,startFieldProps:m,endFieldProps:p,buttonProps:f,dialogProps:h,calendarProps:g,descriptionProps:y,errorMessageProps:v,...b}=function(e,t,r){var n;let a=pI((n=gy)&&n.__esModule?n.default:n,"@react-aria/datepicker"),{isInvalid:o,validationErrors:i,validationDetails:s}=t.displayValidation,{labelProps:l,fieldProps:u,descriptionProps:c,errorMessageProps:d}=gw({...e,labelElementType:"span",isInvalid:o,errorMessage:e.errorMessage||i}),m=u["aria-labelledby"]||u.id,{locale:p}=pm(),f=t.formatValue(p,{month:"long"}),h=fJ(f?a.format("selectedRangeDescription",{startDate:f.start,endDate:f.end}):""),g={"aria-label":a.format("startDate"),"aria-labelledby":m},y={"aria-label":a.format("endDate"),"aria-labelledby":m},v=dl(),b=dl(),w=gv(t,r),x=[h["aria-describedby"],u["aria-describedby"]].filter(Boolean).join(" ")||void 0,E=(0,so.useMemo)(()=>gm(r,{accept:e=>e.id!==v}),[r,v]),D={[g_]:E,[gS]:"presentation","aria-describedby":x,placeholderValue:e.placeholderValue,hideTimeZone:e.hideTimeZone,hourCycle:e.hourCycle,granularity:e.granularity,shouldForceLeadingZeros:e.shouldForceLeadingZeros,isDisabled:e.isDisabled,isReadOnly:e.isReadOnly,isRequired:e.isRequired,validationBehavior:e.validationBehavior},S=dR(e),_=(0,so.useRef)(!1),{focusWithinProps:C}=mZ({...e,isDisabled:t.isOpen,onBlurWithin:t=>{dI(document.getElementById(b),t.relatedTarget)||(_.current=!1,e.onBlur?.(t),e.onFocusChange?.(!1))},onFocusWithin:t=>{_.current||(_.current=!0,e.onFocus?.(t),e.onFocusChange?.(!0))}}),k=(0,so.useRef)(gT),P=(0,so.useRef)(gT);return{groupProps:dd(S,w,u,h,C,{role:"group","aria-disabled":e.isDisabled||null,"aria-describedby":x,onKeyDown(r){!t.isOpen&&e.onKeyDown&&e.onKeyDown(r)},onKeyUp(r){!t.isOpen&&e.onKeyUp&&e.onKeyUp(r)}}),labelProps:{...l,onClick:()=>{E.focusFirst()}},buttonProps:{...h,id:v,"aria-haspopup":"dialog","aria-label":a.format("calendar"),"aria-labelledby":`${v} ${m}`,"aria-describedby":x,"aria-expanded":t.isOpen,isDisabled:e.isDisabled||e.isReadOnly,onPress:()=>t.setOpen(!0)},dialogProps:{id:b,"aria-labelledby":`${v} ${m}`},startFieldProps:{...g,...D,value:t.value?.start??null,defaultValue:t.defaultValue?.start,onChange:e=>t.setDateTime("start",e),autoFocus:e.autoFocus,name:e.startName,form:e.form,[gN]:{realtimeValidation:t.realtimeValidation,displayValidation:t.displayValidation,updateValidation(e){k.current=e,t.updateValidation(gj(e,P.current))},resetValidation:t.resetValidation,commitValidation:t.commitValidation}},endFieldProps:{...y,...D,value:t.value?.end??null,defaultValue:t.defaultValue?.end,onChange:e=>t.setDateTime("end",e),name:e.endName,form:e.form,[gN]:{realtimeValidation:t.realtimeValidation,displayValidation:t.displayValidation,updateValidation(e){P.current=e,t.updateValidation(gj(k.current,e))},resetValidation:t.resetValidation,commitValidation:t.commitValidation}},descriptionProps:c,errorMessageProps:d,calendarProps:{autoFocus:!0,value:t.dateRange?.start&&t.dateRange.end?t.dateRange:null,onChange:t.setDateRange,minValue:e.minValue,maxValue:e.maxValue,isDisabled:e.isDisabled,isReadOnly:e.isReadOnly,isDateUnavailable:e.isDateUnavailable,allowsNonContiguousRanges:e.allowsNonContiguousRanges,defaultFocusedValue:t.dateRange?void 0:e.placeholderValue,isInvalid:t.isInvalid,errorMessage:"function"==typeof e.errorMessage?e.errorMessage(t.displayValidation):e.errorMessage||t.displayValidation.validationErrors.join(" "),firstDayOfWeek:e.firstDayOfWeek,pageBehavior:e.pageBehavior},isInvalid:o,validationErrors:i,validationDetails:s}}({...dv(e),label:u,validationBehavior:o},i,s),[w,x]=(0,so.useState)(null),E=(0,so.useCallback)(()=>{s.current&&x(s.current.offsetWidth+"px")},[]);yA({ref:s,onResize:E});let{focusProps:D,isFocused:S,isFocusVisible:_}=mY({within:!0}),C=df({...e,values:{state:i,isFocusWithin:S,isFocusVisible:_,isDisabled:e.isDisabled||!1,isInvalid:i.isInvalid,isOpen:i.isOpen},defaultClassName:"react-aria-DateRangePicker"}),k=dR(e);return delete k.id,si().createElement(dp,{values:[[vd,i],[h4,{...c,ref:s,isInvalid:i.isInvalid}],[m3,{...f,isPressed:i.isOpen}],[yc,{...d,ref:l,elementType:"span"}],[hz,g],[ya,i],[vn,{trigger:"DateRangePicker",triggerRef:s,placement:"bottom start",style:{"--trigger-width":w}}],[yn,h],[g4,{slots:{start:m,end:p}}],[m9,{slots:{description:y,errorMessage:v}}],[yi,b]]},si().createElement("div",{...D,...k,...C,ref:t,slot:e.slot||void 0,"data-focus-within":S||void 0,"data-invalid":i.isInvalid||void 0,"data-focus-visible":_||void 0,"data-disabled":e.isDisabled||void 0,"data-open":i.isOpen||void 0}))});function vf(e){return si().createElement(pd,e)}function vh(e,t,r=!1){if(null==e)return r?e:void 0;if("string"==typeof e&&!e)return r?null:void 0;if(e instanceof p8||e instanceof fe||e instanceof ft)return t?fm(e,t):e;{let r=lU()(e).toDate(),n=new p8(r.getFullYear(),r.getMonth()+1,r.getDate());return t?fm(n,t):n}}function vg(e){if(e)return e.toDate(fS())}function vy(e){if("string"==typeof e&&0!==e.trim().length)try{return new Intl.Locale(e.replace(/[_@]/g,"-")).toString()}catch{return}}function vv(e){let t=e??"",r=vy(t);if(!r)return t;try{return new Intl.DisplayNames([r],{type:"language"}).of(r)??t}catch{return t}}function vb(){let e=window.i18next.language,t=vy(e)??e;return"ht"===t&&(t="fr-HT"),t}if("u">typeof navigator){let e=navigator;ee=Array.isArray(e.languages)?e.languages[0]:e.language}else if("u">typeof process){let e=process.env;ee=e.LC_ALL||e.LC_MESSAGES||e.LANG||e.LANGUAGE}var vw=function(e){e=(e=e.replace(/_/g,"-")).replace(/[.:][\w-]*$/,"");try{return new Intl.Locale(e).baseName}catch{return"en-US"}}(ee||"en-US"),vx=class extends Date{invalid=null;isValid(){return!Number.isNaN(this.valueOf())}},vE={};for(let e=1;e<100;e++)vE[(e<=9?"0":"")+e]=e+(e>51?1900:2e3);var vD={arab:1632,arabext:1776,bali:6992,beng:2534,deva:2406,fullwide:65296,gujr:2790,khmr:6112,knda:3302,laoo:3792,limb:6470,mlym:3430,mong:6160,mymr:4160,orya:2918,tamldec:3046,telu:3174,thai:3664,tibt:3872},vS="[1234567890一二三四五六七八九〇\\d]",v_={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,"0":0,"1":1,"2":2,"3":3,"4":4,"5":5,"6":6,"7":7,"8":8,"9":9,〇:0,一:1,二:2,三:3,四:4,五:5,六:6,七:7,八:8,九:9},vC={},vk={"Eastern Daylight Time":-240,"Eastern Standard Time":-300,"Central Daylight Time":-300,"Central Standard Time":-360,"Mountain Daylight Time":-360,"Mountain Standard Time":-420,"Pacific Daylight Time":-420,"Pacific Standard Time":-480,"Coordinated Universal Time":0,ACDT:630,ACST:570,ACT:480,ADT:-180,AEDT:660,AEST:600,AFT:270,AKDT:-480,AKST:-540,AMST:-180,AMT:-240,ART:-180,AST:180,AWDT:540,AWST:480,AZOST:-60,AZT:240,BDT:360,BIOT:360,BIT:-720,BOT:-240,BRST:-120,BRT:-180,BTT:360,CAT:120,CCT:390,CDT:-300,CEDT:120,CEST:120,CET:60,CHADT:825,CHAST:765,CHOT:480,ChST:600,CHUT:600,CIST:-480,CIT:480,CKT:-600,CLST:-180,CLT:-240,COST:-240,COT:-300,CST:-360,CT:480,CVT:-60,CXT:420,DAVT:420,DDUT:600,DFT:60,EASST:-300,EAST:-360,EAT:180,ECT:-300,EDT:-240,EEDT:180,EEST:180,EET:120,EGST:0,EGT:-60,EIT:540,EST:-300,FET:180,FJT:720,FKST:-180,FKT:-240,FNT:-120,GALT:-360,GAMT:-540,GET:240,GFT:-180,GILT:720,GIT:-540,GMT:0,GST:-120,GYT:-240,HADT:-540,HAEC:120,HAST:-600,HKT:480,HMT:300,HOVT:420,HST:-600,IBST:0,ICT:420,IDT:180,IOT:180,IRDT:270,IRKT:480,IRST:210,IST:120,JST:540,KGT:360,KOST:660,KRAT:420,KST:540,LHST:630,LINT:840,MAGT:720,MART:-510,MAWT:300,MDT:-360,MET:60,MEST:120,MHT:720,MIST:660,MIT:-510,MMT:390,MSK:180,MST:-420,MUT:240,MVT:300,MYT:480,NCT:660,NDT:-90,NFT:660,NPT:345,NST:-150,NT:-150,NUT:-660,NZDT:780,NZST:720,OMST:360,ORAT:300,PDT:-420,PET:-300,PETT:720,PGT:600,PHOT:780,PKT:300,PMDT:-120,PMST:-180,PONT:660,PST:-480,PYST:-180,PYT:-240,RET:240,ROTT:-180,SAKT:660,SAMT:240,SAST:120,SBT:660,SCT:240,SGT:480,SLST:330,SRET:660,SRT:-180,SST:480,SYOT:180,TAHT:-600,THA:420,TFT:300,TJT:300,TKT:780,TLT:540,TMT:300,TOT:780,TVT:720,UCT:0,ULAT:480,USZ1:120,UTC:0,UYST:-120,UYT:-180,UZT:300,VET:-240,VLAT:600,VOLT:240,VOST:360,VUT:660,WAKT:720,WAST:120,WAT:60,WEDT:60,WEST:60,WET:0,WIT:420,WST:480,YAKT:540,YEKT:300},vP={zone:vk,year:vE,meridiem:{am:0,pm:12,"a.m.":0,"p.m.":12},month:{january:1,jan:1,february:2,feb:2,march:3,mar:3,april:4,apr:4,may:5,june:6,jun:6,july:7,jul:7,august:8,aug:8,september:9,sep:9,october:10,oct:10,november:11,nov:11,december:12,dec:12},dayname:{sunday:0,sun:0,monday:1,mon:1,tuesday:2,tue:2,wednesday:3,wed:3,thursday:4,thu:4,friday:5,fri:5,saturday:6,sat:6},digit:{}},vR={MONTHNAME:"january|february|march|april|may|june|july|august|september|october|november|december|jan\\.?|feb\\.?|mar\\.?|apr\\.?|may\\.?|jun\\.?|jul\\.?|aug\\.?|sep\\.?|oct\\.?|nov\\.?|dec\\.?",DAYNAME:"sunday|monday|tuesday|wednesday|thursday|friday|saturday|sun\\.?|mon\\.?|tue\\.?|wed\\.?|thu\\.?|fri\\.?|sat\\.?",ZONE:"\\(?(?:"+Object.keys(vk).join("|")+")\\)?",MERIDIEM:"am|pm|a.m.|p.m.",ORDINAL:"st|nd|rd|th|\\.",YEAR:"\\d{4}|\\d{2}",YEAR2:"\\d{2}",YEAR4:"\\d{4}",YEAR6:"-\\d{6}|\\+?\\d{5,6}",MONTH:"1[0-2]|0?[1-9]",MONTH2:"1[0-2]|0[1-9]",DAY:"3[01]|[12]\\d|0?[1-9]",DAY2:"3[01]|[12]\\d|0[1-9]",OFFSET:"(?:GMT)?[\xb1−+-](?:[01]\\d[0-5]\\d|[01]\\d:[0-5]\\d|[01]?\\d)",H24:"[01]\\d|2[0-3]",H12:"0?[1-9]|1[012]",MIN:"[0-5]\\d",SEC:"[0-5]\\d|60",MS:"\\d{9}|\\d{6}|\\d{1,3}",GAP:"[\\s/.,-]{1,}"},vT={...vR,YEAR:"*{4}|*{2}",YEAR4:"*{4}",YEAR6:"-*{6}|\\+?*{5,6}",MONTH:"*{1,2}",MONTH2:"*{2}",DAY:"*{1,2}",DAY2:"*{2}",OFFSET:"(?:GMT)?[\xb1−+-](?:*{4}|*{2}:*{2}|*{1,2})",H24:"*{2}",H12:"*{1,2}",MIN:"*{2}",SEC:"*{2}",MS:"*{9}|*{6}|*{3}"},v$={},vN=class e{locale;lookups;vars;numberingSystem;baseName;dateOptions;static factory(t=vw){return v$[t.toLowerCase()]||(v$[t.toLowerCase()]=new e(t)),v$[t.toLowerCase()]}constructor(e=vw){this.locale=e,this.lookups={...vP},this.vars={...vR};let t=new Intl.NumberFormat(this.locale);this.numberingSystem=t.resolvedOptions().numberingSystem,this.dateOptions=new Intl.DateTimeFormat(this.locale).resolvedOptions(),this.baseName=new Intl.Locale(this.locale).baseName,this.build()}toInt(e){if("number"==typeof e)return e;if("string"!=typeof e)return;if("latn"===this.numberingSystem&&!this.baseName.startsWith("zh")){let t=parseInt(e,10);if(!isNaN(t))return t}let t="";for(let r=0;r<e.length;r++)t+=String(this.lookups.digit[e[r]]);return parseInt(t,10)}millisecondToInt(e){if("number"==typeof e)return e;if("string"!=typeof e)return;let t=e.slice(0,3);return 1===t.length?100*this.toInt(t):2===t.length?10*this.toInt(t):this.toInt(t)}monthNameToInt(e){if("string"!=typeof e)return;let t=e.toLocaleLowerCase(this.locale).replace(/\.$/,"");return this.lookups.month[t]||12}h12ToInt(e,t){if("string"!=typeof e)return;let r=this.lookups.meridiem[t?.toLowerCase()]||0,n=this.toInt(e);return n<12&&12===r&&(n+=12),12===n&&0===r&&(n=0),n}zoneToOffset(e){if("string"==typeof e)return e=e.replace(/[^a-z\s]/gi,""),this.lookups.zone[e]}offsetToMinutes(e){if("string"!=typeof e)return;let t=e.match(/^(?:GMT)?([±−+-])(..?):?(..)?$/);if(t){let[,e,r,n]=t;return("-"===e||"−"===e?-1:1)*(60*this.toInt(r)+this.toInt(n||0))}return 0}build(){"latn"===this.dateOptions.numberingSystem?this.lookups.digit=v_:this.buildNumbers(),/^en/i.test(this.locale)||(this.buildMonthNames(),this.buildDaynames(),/zh/i.test(this.locale)||this.buildMeridiems())}buildNumbers(){let{group:e,lookup:t}=function(e){if(vC[e])return vC[e];if("fullwide"===e||"hanidec"===e)return{group:vS,lookup:{...v_}};let t=vD[e];if(!t)return{group:"\\d",lookup:{...v_}};let r=String.fromCharCode(t),n=String.fromCharCode(t+9),a={};for(let e=0;e<10;e++)a[String.fromCharCode(t+e)]=e;return vC[e]={group:`[${r}-${n}]`,lookup:a},vC[e]}(this.numberingSystem);for(let r in this.lookups.digit=t,vT)vT.hasOwnProperty(r)&&(this.vars[r]=vT[r].replace(/\*/g,e))}buildMonthNames(){let e={},t={};if(/^fi/i.test(this.locale))"tammi|helmi|maalis|huhti|touko|kes\xe4|hein\xe4|elo|syys|loka|marras|joulu".split("|").forEach((r,n)=>{["","k","kuu","kuuta"].forEach((a,o)=>{e[r+a+(o<2?"\\.?":"")]=!0,t[r+a]=n+1})});else{let r=[],n=e=>"month"===e.type;for(let e=0;e<12;e++)r.push(new Date(2017,e,1));for(let a of["full","long","medium"]){let o=Intl.DateTimeFormat(this.locale,{dateStyle:a});for(let i=0;i<12;i++){let s=o.formatToParts(r[i]).find(n).value.toLocaleLowerCase(this.locale);/^\d+$/.test(s)||(/^ko/i.test(this.locale)&&(s+="월"),"medium"===a?(s=s.replace(/\.$/,""),e[`${s}\\.?`]=!0):e[s]=!0,t[s]=i+1)}}let a=Intl.DateTimeFormat(this.locale,{month:"short"});for(let o=0;o<12;o++){let i=a.formatToParts(r[o]).find(n).value.toLocaleLowerCase(this.locale);i=i.replace(/\.$/,""),e[`${i}\\.?`]=!0,t[i]=o+1}}this.vars.MONTHNAME=Object.keys(e).join("|"),this.lookups.month=t}buildDaynames(){let e=[],t=e=>"weekday"===e.type;for(let t=0;t<7;t++)e.push(new Date(2017,0,t+1));let r=[],n={};for(let a of["long","short"]){let o=Intl.DateTimeFormat(this.locale,{weekday:a});for(let i=0;i<7;i++){let s=o.formatToParts(e[i]).find(t).value.toLocaleLowerCase(this.locale);"short"===a?(s=s.replace(/\.$/,""),r.push(`${s}\\.?`)):r.push(s),n[s]=i}}this.vars.DAYNAME=r.join("|"),this.lookups.dayname=n}buildMeridiems(){let e=[new Date(2017,0,1),new Date(2017,0,1,23,0,0)],t=e=>"dayPeriod"===e.type,r=[],n={},a=Intl.DateTimeFormat(this.locale,{timeStyle:"long"});for(let o=0;o<2;o++){let i=a.formatToParts(e[o]).find(t);if(!i)return;let s=i.value.toLocaleLowerCase(this.locale);r.push(s),n[s]=12*o}this.vars.MERIDIEM=r.join("|"),this.lookups.meridiem=n}compile(e){return RegExp(e.replace(/_([A-Z0-9]+)_/g,(e,t)=>{if(!this.vars[t])throw Error(`Template string contains invalid variable _${t}_`);return this.vars[t]}),"i")}},vO=["ee-TG","en-AS","en-CA","en-FM","en-GH","en-GU","en-KE","en-KY","en-MH","en-MP","en-US","en-VI","en-WS","jp-JP","sm-AS","sm-SM"],vI={y:"year",M:"month",d:"day",w:"week",h:"hour",m:"minute",s:"second",ms:"millisecond"},vA=()=>new Date;function vM(e){return function(t){let r={};for(let n=0,a=e.length;n<a;n++){let a=e[n];a&&(r[a]=t[n])}return r}}var vj=class{doneChecker;fallback;patterns;formatter;constructor({doneChecker:e,fallback:t,patterns:r,formatter:n}){this.doneChecker=e,this.fallback=t,this.patterns=r,this.formatter=n}attempt(e){if("string"!=typeof e)return this.fallback(e);let t=e.trim(),r={},n=!1;for(let e of this.patterns){let a=t.match(e.regex);if(!a)continue;n=!0;let o=e.handler(a);if(o){for(let[e,t]of Object.entries(o))e in r||void 0===t||(r[e]=t);if(t=(t=t.slice(0,a.index)+t.slice(a.index+a[0].length+1)).trim(),this.doneChecker(r,t))break}}return n?this.formatter(r):this.fallback(e)}},vL=["year","month","day","hour","minute","second","millisecond","offset"],vF={};function vB(e,t){return""===t||/^\s+$/.test(t)||"year"in e&&("month"in e||"monthname"in e)&&"day"in e&&"hour"in e&&"minute"in e&&"second"in e&&"millisecond"in e&&("zone"in e||"offset"in e)}var vV=[[/([^\d.]+)(\d{1,2})\.(\d{2})\.(\d{2})(\D|$)/,"$1$2:$3:$4$5"],[/([^\d.]+)(\d{1,2})\.(\d{2})(\D|$)/,"$1$2:$3$4"]],vU={ar:[[/ /g," "]],bn:[[/,/g,""]],zh:[[/早上\s*([\d:]+)/,"$1am"],[/凌晨\s*([\d:]+)/,"$1am"],[/上午\s*([\d:]+)/,"$1am"],[/下午\s*([\d:]+)/,"$1pm"],[/晚上\s*([\d:]+)/,"$1pm"]],he:[[/ב/gi,""]],de:[[/ um /g," "]],pt:[[/\sde /gi," "]],es:[[/\sde /gi," "]],da:[[/\sden /gi," "],...vV],ru:[[/ г\./g,""]],th:[[/\s*นาฬิกา\s*/i,":"],[/\s*นาที\s*/i,":"],[/\s*วินาที\s*/i," "]],ko:[[/\s*시\s*/,":"],[/\s*분\s*/,":"],[/\s*초\s*/,""],[/(오전|오후)\s*([\d:]+)/,"$2$1"],[/(\d{4})\. (\d{1,2})\. (\d{1,2})\./,"$1-$2-$3"]],fi:vV,id:vV,fr:[[/(\d{2}) h /,"$1:"],[/(\d{2}) min /,"$1:"],[/(\d{2}) s /,"$1"]]};function vW(e,t=vw){let r=function(e){if(!vF[e]){var t,r;let n,a,o=vN.factory(e);vF[e]=new vj({doneChecker:vB,fallback:(t=e,function(e){let r=String(e).slice(0,50);return""===r&&(r="(empty string)"),{invalid:`Unable to parse "${r}" with locale "${t}"`}}),patterns:(n=[{name:"timestampWithOffset",regex:o.compile("^(_YEAR4_)-(_MONTH_)-(_DAY_)[T ](_H24_):(_MIN_):(_SEC_)(?:.(_MS_))? ?(_OFFSET_|Z)?$"),handler:vM(["","year","month","day","hour","minute","second","millisecond","offset"])},{name:"timestampWithZone",regex:o.compile("^(_YEAR4_)-(_MONTH_)-(_DAY_)[T ](_H24_):(_MIN_):(_SEC_)(?:.(_MS_))?\\s*(_ZONE_)$"),handler:vM(["","year","month","day","hour","minute","second","millisecond","zone"])},{name:"timestampWithOffsetAndZone",regex:o.compile("^(_YEAR4_)-(_MONTH_)-(_DAY_)[T ](_H24_):(_MIN_):(_SEC_)(?:.(_MS_))? (_OFFSET_|Z)\\s*(_ZONE_)$"),handler:vM(["","year","month","day","hour","minute","second","millisecond","offset"])},{name:"chinese",regex:o.compile(`^(${vS}{2,4})\\s*\u5E74\\s*(${vS}{1,2})\\s*\u6708\\s*(${vS}{1,2})\\s*\u65E5$`),handler:vM(["","year","month","day"])},{name:"korean",regex:o.compile("^(_YEAR_)년\\s*(_MONTH_)월\\s*(_DAY_)일$"),handler:vM(["","year","month","day"])},{name:"twitter",regex:/^(?:sun|mon|tue|wed|thu|fri|sat) (jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec) (\d{2}) (\d{2}):(\d{2}):(\d{2}) ([+-]\d{4}) (\d{4})$/i,handler:vM(["","monthname","day","hour","minute","second","offset","year"])},{name:"today",regex:/^(now|today|tomorrow|yesterday)$/i,handler:function(e){let t=vA(),r=e[1].toLowerCase();switch(r){case"tomorrow":t.setUTCDate(t.getUTCDate()+1);break;case"yesterday":t.setUTCDate(t.getUTCDate()-1)}let n={year:t.getUTCFullYear(),month:t.getUTCMonth()+1,day:t.getUTCDate()};return"now"===r&&(n.hour=t.getUTCHours(),n.minute=t.getUTCMinutes(),n.second=t.getUTCSeconds(),n.millisecond=t.getUTCMilliseconds()),console.log("today=>",r,n),n}},{name:"ago",regex:/^(\+|-|in|) ?([\d.]+) ?(years?|months?|weeks?|days?|hours?|minutes?|seconds?|milliseconds?|ms|s|m|h|w|d|M|y)( ago)?$/i,handler:function([,e,t,r,n]){t=parseFloat(t),"week"===(r=r.length<=2?vI[r]:(r=r.replace(/s$/,"")).toLowerCase())&&(r="day",t*=7),("-"===e||n)&&(t*=-1);let a=vA();return"millisecond"===r?a.setUTCMilliseconds(a.getUTCMilliseconds()+t):"second"===r?a.setUTCSeconds(a.getUTCSeconds()+t):"minute"===r?a.setUTCMinutes(a.getUTCMinutes()+t):"hour"===r?a.setUTCHours(a.getUTCHours()+t):"day"===r?a.setUTCDate(a.getUTCDate()+t):"month"===r?a.setUTCMonth(a.getUTCMonth()+t):"year"===r&&a.setUTCFullYear(a.getUTCFullYear()+t),{year:a.getUTCFullYear(),month:a.getUTCMonth()+1,day:a.getUTCDate(),hour:a.getUTCHours(),minute:a.getUTCMinutes(),second:a.getUTCSeconds(),millisecond:a.getUTCMilliseconds()}}},{name:"atSeconds",regex:/^@(\d+)$/,handler:function(e){let t=new Date(1e3*parseInt(e[1],10));return{year:t.getUTCFullYear(),month:t.getUTCMonth()+1,day:t.getUTCDate(),hour:t.getUTCHours(),minute:t.getUTCMinutes(),second:t.getUTCSeconds()}}},{name:"microsoftJson",regex:/^\/Date\((\d+)([+-]\d{4})?\)\/$/,handler:function(e){let t=new Date(parseInt(e[1],10));return{year:t.getUTCFullYear(),month:t.getUTCMonth()+1,day:t.getUTCDate(),hour:t.getUTCHours(),minute:t.getUTCMinutes(),second:t.getUTCSeconds(),millisecond:t.getUTCMilliseconds(),offset:e[2]}}},{name:"full24",regex:o.compile("(?:^|[\\sT])(_H24_):(_MIN_):(_SEC_)(?:\\.(_MS_))?(Z)?$"),handler:vM(["","hour","minute","second","millisecond","zone"])},{name:"zone24",regex:o.compile("(_H24_):(_MIN_):(_SEC_)(?:\\.(_MS_))?[\\s\\[(]*(_ZONE_)?[\\s\\])]*$"),handler:vM(["","hour","minute","second","millisecond","zone"])},{name:"hms12",regex:o.compile("(_H12_):(_MIN_):(_SEC_)\\s*(_MERIDIEM_)"),handler:vM(["","hour","minute","second","meridiem"])},{name:"hms24",regex:o.compile("(_H24_):(_MIN_):(_SEC_)(?:\\.(_MS_))?"),handler:vM(["","hour","minute","second","millisecond"])},{name:"hm12",regex:o.compile("(_H12_):(_MIN_)\\s*(_MERIDIEM_)"),handler:vM(["","hour","minute","meridiem"])},{name:"hm24",regex:o.compile("(_H24_):(_MIN_)"),handler:vM(["","hour","minute"])},{name:"h12",regex:o.compile("(_H12_)\\s*(_MERIDIEM_)"),handler:vM(["","hour","meridiem"])},{name:"8digit",regex:/^((?:19|20)\d{2})(\d{2})(\d{2})$/,handler:vM(["","year","month","day"])},{name:"yearMonthnameDay",regex:o.compile("(_YEAR4_)[\\s.-]+(_MONTHNAME_)[\\s,.-]+(_DAY_)(_ORDINAL_)?"),handler:vM(["","year","monthname","day"])},{name:"dayMonthnameYear",regex:o.compile("(_DAY_)(_ORDINAL_)?[\\s.-]*(_MONTHNAME_)[\\s,.-]+(_YEAR_)"),handler:vM(["","day","","monthname","year"])},{name:"monthnameDayYear",regex:o.compile("(_MONTHNAME_)[\\s.-]*(_DAY_)(_ORDINAL_)?[\\s,.-]+(_YEAR_)"),handler:vM(["","monthname","day","","year"])},{name:"dayMonthname",regex:o.compile("\\b(_DAY_)(_ORDINAL_)?[\\s.-]*(_MONTHNAME_)\\b"),handler:vM(["","day","","monthname"])},{name:"monthnameDay",regex:o.compile("\\b(_MONTHNAME_)[\\s.-]*(_DAY_)(_ORDINAL_)?\\b"),handler:vM(["","monthname","day"])},{name:"hmsNoMeridiem",regex:o.compile("\\b(_H12_|_H24_):(_MIN_):(_SEC_)\\b"),handler:vM(["","hour","minute","second"])},{name:"hmNoMeridiem",regex:o.compile("\\b(_H12_|_H24_):(_MIN_)\\b"),handler:vM(["","hour","minute"])},{name:"ymd",regex:o.compile("(_YEAR4_)([.-])(_MONTH_)\\2+(_DAY_)"),handler:vM(["","year","","month","day"])},{name:"mdy",regex:o.compile("(_MONTH_)([/-])(_DAY_)\\2(_YEAR_)"),handler:vM(["","month","","day","year"])},{name:"dmy",regex:o.compile("(_DAY_)(?:_ORDINAL_)?[./\\s-]+(_MONTH_)[./\\s-]+(_YEAR_)"),handler:vM(["","day","month","year"])},{name:"yearLoose",regex:o.compile("_YEAR4_"),handler:vM(["year"])},{name:"dayMonthnameLoose",regex:o.compile("(_DAY_)[\\s.]*(_MONTHNAME_)"),handler:vM(["","day","monthname"])},{name:"monthnameDayLoose",regex:o.compile("(_MONTHNAME_)[\\s.]*(_DAY_)"),handler:vM(["","monthname","day"])},{name:"monthname",regex:o.compile("_MONTHNAME_"),handler:vM(["monthname"])},{name:"year4",regex:o.compile("_YEAR4_"),handler:vM(["year"])},{name:"md",regex:o.compile("(_MONTH_)[/-](_DAY_)"),handler:vM(["","month","day"])},{name:"dm",regex:o.compile("(_DAY_)(?:_ORDINAL_)?[./\\s-]+(_MONTH_)"),handler:vM(["","day","month"])},{name:"day",regex:o.compile("_DAY_"),handler:vM(["day"])},{name:"year2",regex:o.compile("_YEAR2_"),handler:vM(["year"])},{name:"onlyZone",regex:o.compile("_ZONE_"),handler:vM(["zone"])}],a=o.baseName.slice(0,5),vO.includes(a)?n:n.filter(e=>!["mdy","md"].includes(e.name))),formatter:(r=o,function(e){let t={};for(let[n,a]of Object.entries(e))if("monthname"===n){if(a){let e=r.monthNameToInt(a);void 0!==e&&(t.month=e)}}else if("hour"===n&&e.meridiem){let n=r.h12ToInt(a,e.meridiem);void 0!==n&&(t.hour=n)}else if("zone"===n){if(a){let e=r.zoneToOffset(a);void 0!==e&&(t.offset=e)}}else if("offset"===n){let e=r.offsetToMinutes(a);void 0!==e&&(t.offset=e)}else if("millisecond"===n){let e=r.millisecondToInt(a);"number"==typeof e&&(t.millisecond=e)}else if(vL.includes(n)){let e=r.toInt(a);"number"==typeof e&&(t[n]=e)}return t.year<100&&(t.year=vE[t.year]),t.year&&"buddhist"===r.dateOptions.calendar&&(t.year-=543),t})})}return vF[e]}(t),n=function(e,t){let r=vU[t.slice(0,2).toLowerCase()];if(!r)return e;for(let[t,n]of r)e=e.replace(t,n);return e}(e,t);return r.attempt(n)}function vH(e){e.month&&e.day&&void 0===e.year&&(e.year=new Date().getFullYear()),60===e.second&&(e.second=59);let t=new vx(e.year,e.month-1,e.day,e.hour||0,e.minute||0,e.second||0,e.millisecond||0);return"number"==typeof e.offset?new vx(t.valueOf()-60*e.offset*1e3):t}function vz(e,t=vw){let r=vW(e,t),n=r.invalid?new vx(NaN):vH(r);return n.isValid()||(n.invalid=`Unable to parse date "${e}"`),n}function vK(e,t=vw){return e instanceof Date?new vx(e.valueOf()):"number"==typeof e?new vx(e):vz(e,t)}Date.fromString=vx.fromString=vz,Date.fromAny=vx.fromAny=vK,"u">typeof window&&(window.anyDateParser={fromString:vz,fromAny:vK,fromObject:vH,attempt:vW});var vG=r(4397),vZ=r(7657),vY=r(254);function vq(e,t){var r=function(e,t){if(!t.has(e))throw TypeError("attempted to get private field on non-instance");return t.get(e)}(e,t);return r.get?r.get.call(e):r.value}lU().extend(lW),lU().extend(vZ),lU().extend(vG);let vJ="YYYY-MM-DDTHH:mm:ss.SSSZZ",vX=/^(\d{4})(?:-(\d{2})(?:-(\d{2}))?)?$/;function vQ(e,t){let r=vX.exec(e);if(!r)return vW(e,t);let n=Number(r[1]),a=void 0===r[2]?void 0:Number(r[2]),o=void 0===r[3]?void 0:Number(r[3]),i=new Date(0);return(i.setUTCFullYear(n,(a??1)-1,o??1),i.getUTCFullYear()!==n||i.getUTCMonth()!==(a??1)-1||i.getUTCDate()!==(o??1))?{invalid:`Invalid ISO calendar date '${e}'`}:{year:n,...void 0!==a&&{month:a},...void 0!==o&&{day:o}}}function v0(e){return null!=e&&28===e.trim().length&&"T"===(e=e.trim())[10]&&":"===e[13]&&":"===e[16]&&"."===e[19]&&("+"===e[23]||"-"===e[23])&&lU()(e,vJ).isValid()}function v1(e){return lU()(e).isToday()}function v4(e){return v0(e)?lU()(e,vJ).toDate():null}function v2(e,t=!1){let r=lU()(e);return t&&(r=r.utc()),r.format(vJ)}function v3(e){return lU()(e).toDate()}var v6=new WeakMap;let v5=new class{register(e,t){vq(this,v6).set(e,t)}getCalendar(e){if(!e)return;if(e.calendar)return e.calendar;if(e.region){let t=`${e.language}-${e.region}`;if(vq(this,v6).has(t))return vq(this,v6).get(t)}if(e.language&&vq(this,v6).has(e.language))return vq(this,v6).get(e.language);let t=new Intl.DateTimeFormat(e.toString()).resolvedOptions().calendar;return vq(this,v6).set(`${e.language}${e.region?`-${e.region}`:""}`,t),t}constructor(){!function(e,t,r){if(t.has(e))throw TypeError("Cannot initialize the same private elements twice on an object");t.set(e,r)}(this,v6,{writable:!0,value:new Map})}};function v9(e,t){v5.register(e,t)}function v8(e){let t=e??vb();return v5.getCalendar(t instanceof Intl.Locale?t:new Intl.Locale(t))}let v7={mode:"standard",time:"for today",day:!0,month:!0,year:!0,noToday:!1};function be(e,t={}){let r=vQ(e,vb());if(r.invalid)return console.warn(`Could not parse invalid date '${e}'`),null;!(0,vY.A)(r.day)&&(0,vY.A)(r.month)&&(r=Object.assign({},tV(r,"day"),{month:r.day})),r.month&&(r.month-=1),r.day&&(r=Object.assign({},tV(r,"day"),{date:r.day}));let n=lU()().set(r).toDate();return(0,vY.A)(r.year)&&(t.year=!1),(0,vY.A)(r.month)&&(t.month=!1),(0,vY.A)(r.date)&&(t.day=!1),bt(n,t)}function bt(e,t){let r,n=t?.locale??vb(),a=new Intl.Locale(n),{calendar:o,mode:i,time:s,day:l,month:u,year:c,noToday:d,numberingSystem:m}={...v7,...{noToday:"am"===a.language},...t},p={calendar:o??v8(a),year:c?"numeric":void 0,month:u?"short":void 0,day:l?"2-digit":void 0,numberingSystem:m},f=lU()(e).isToday();if(f&&!d)r=(r=new Intl.RelativeTimeFormat(n,{numeric:"auto"}).format(0,"day"))[0].toLocaleUpperCase(n)+r.slice(1);else{"en"===a.language&&(n="en-GB");let t=new Intl.DateTimeFormat(n,p).formatToParts(e);("en"===a.language||"am"===a.language)&&"standard"==i&&c&&l&&(t=t.map(br("-"))),"wide"==i&&(t=t.map(br(" — "))),"ethiopic"===p.calendar&&(t=t.filter((e,t,r)=>"era"!==e.type&&("literal"!==e.type||!(t<r.length-1)||"era"!==r[t+1].type))),r=t.map(e=>e.value).join("")}return(!0===s||f&&"for today"===s)&&(r+=`, ${bn(e)}`),r}let br=e=>(t,r,n)=>"literal"!==t.type||" "!==t.value||r<n.length-1&&"era"===n[r+1].type?t:{type:"literal",value:e};function bn(e){return e.toLocaleTimeString(vb(),{hour:"2-digit",minute:"2-digit"})}function ba(e,t){return bt(e,{...t,time:!0})}function bo(e,t){let r=v8("string"==typeof t?new Intl.Locale(t):t);return r?fm(e,hR(r)):e}function bi(e,t){return new Intl.DurationFormat(vb(),t).format(e)}function bs(e,t){if(null==e)return null;if("string"==typeof e){let r=vQ(e,vb());return r.invalid?(console.warn(`Could not interpret '${e}' as a date`),null):(r.day&&!r.month&&(r={...tV(r,"day"),...{month:r.day}}),r.month&&(r.month-=1),r.day&&(r={...tV(r,"day"),...{date:r.day}}),lU()(t).set(r))}return lU()(e)}let bl=["years","months","days","hours","minutes","seconds"],bu={second:"seconds",minute:"minutes",hour:"hours",day:"days",month:"months",year:"years"},bc={seconds:45,minutes:45,hours:22,days:26,months:11,years:1/0};function bd(e,t=lU()(),r){let n,a=lU()(t),o=bs(e,a);if(null==o)return null;if("string"==typeof r){let e=bu[r]??r;return{[e]:a.diff(o,e)}}let{thresholds:i,largestUnit:s,smallestUnit:l}=r??{};if(void 0!==s||void 0!==l){let e,t=l?bu[l]??l:void 0;return e="auto"===s||void 0===s?function(e,t,r){let n=bl.indexOf(r);for(let a=0;a<bl.length;a++){let o=bl[a];if(t.diff(e,o)>0)return a<=n?o:r}return r}(o,a,t??"seconds"):bu[s]??s,function(e,t,r,n){let a=bl.indexOf(r),o=bl.indexOf(n),i=bl.slice(a,o+1),s={},l=e;for(let e of i){let r=t.diff(l,e);s[e]=r,l=l.add(r,e)}return s}(o,a,e,t??e)}let u=(n=function(e){let t={...bc};if(e)for(let[r,n]of Object.entries(e))void 0!==n&&(t[bu[r]??r]=n);return t}(i),a.diff(o,"seconds")<n.seconds?"seconds":a.diff(o,"minutes")<n.minutes?"minutes":a.diff(o,"hours")<n.hours?"hours":a.diff(o,"days")<n.days?"days":a.diff(o,"months")<n.months?"months":"years");return{[u]:a.diff(o,u)}}let bm={style:"short",localeMatcher:"lookup"};function bp(e,t=lU()(),r){let n=bd(e,t,r);return null==n?null:bi(n,"object"==typeof r&&r.formatOptions?{...bm,...r.formatOptions}:bm)}let bf=(0,so.createContext)(null);function bh(){let e=s5({externalModuleName:"@openmrs/esm-styleguide"}).preferredDateLocale,t=(0,so.useMemo)(()=>{let t=vb();return e[t]&&(t=e[t]),t},[window.i18next.language]),r=(0,so.useMemo)(()=>{let e=v8(t);return void 0!==e?hR(e):void 0},[t]),n=(0,so.useMemo)(()=>new Intl.Locale(t,{calendar:r?.identifier}),[t,r]),a=(0,so.useMemo)(()=>r?fm(fw(fS()),r):fw(fS()),[r]);return{calendar:r,intlLocale:n,today_:a}}let bg=new p8(1793,1,1);var by={};function bv(){return"u">typeof window&&window.InputEvent&&"function"==typeof InputEvent.prototype.getTargetRanges}function bb(e={}){let{locale:t}=pm();return(0,so.useMemo)(()=>new(0,gJ.K)(t,e),[t,e])}by={"ar-AE":{decrease:e=>`\u{62E}\u{641}\u{636} ${e.fieldLabel}`,increase:e=>`\u{632}\u{64A}\u{627}\u{62F}\u{629} ${e.fieldLabel}`,numberField:"حقل رقمي"},"bg-BG":{decrease:e=>`\u{41D}\u{430}\u{43C}\u{430}\u{43B}\u{44F}\u{432}\u{430}\u{43D}\u{435} ${e.fieldLabel}`,increase:e=>`\u{423}\u{441}\u{438}\u{43B}\u{432}\u{430}\u{43D}\u{435} ${e.fieldLabel}`,numberField:"Номер на полето"},"cs-CZ":{decrease:e=>`Sn\xed\u{17E}it ${e.fieldLabel}`,increase:e=>`Zv\xfd\u{161}it ${e.fieldLabel}`,numberField:"Č\xedseln\xe9 pole"},"da-DK":{decrease:e=>`Reducer ${e.fieldLabel}`,increase:e=>`\xd8g ${e.fieldLabel}`,numberField:"Talfelt"},"de-DE":{decrease:e=>`${e.fieldLabel} verringern`,increase:e=>`${e.fieldLabel} erh\xf6hen`,numberField:"Nummernfeld"},"el-GR":{decrease:e=>`\u{39C}\u{3B5}\u{3AF}\u{3C9}\u{3C3}\u{3B7} ${e.fieldLabel}`,increase:e=>`\u{391}\u{3CD}\u{3BE}\u{3B7}\u{3C3}\u{3B7} ${e.fieldLabel}`,numberField:"Πεδίο αριθμού"},"en-US":{decrease:e=>`Decrease ${e.fieldLabel}`,increase:e=>`Increase ${e.fieldLabel}`,numberField:"Number field"},"es-ES":{decrease:e=>`Reducir ${e.fieldLabel}`,increase:e=>`Aumentar ${e.fieldLabel}`,numberField:"Campo de n\xfamero"},"et-EE":{decrease:e=>`V\xe4henda ${e.fieldLabel}`,increase:e=>`Suurenda ${e.fieldLabel}`,numberField:"Numbri v\xe4li"},"fi-FI":{decrease:e=>`V\xe4henn\xe4 ${e.fieldLabel}`,increase:e=>`Lis\xe4\xe4 ${e.fieldLabel}`,numberField:"Numerokentt\xe4"},"fr-FR":{decrease:e=>`Diminuer ${e.fieldLabel}`,increase:e=>`Augmenter ${e.fieldLabel}`,numberField:"Champ de nombre"},"he-IL":{decrease:e=>`\u{5D4}\u{5E7}\u{5D8}\u{5DF} ${e.fieldLabel}`,increase:e=>`\u{5D4}\u{5D2}\u{5D3}\u{5DC} ${e.fieldLabel}`,numberField:"שדה מספר"},"hr-HR":{decrease:e=>`Smanji ${e.fieldLabel}`,increase:e=>`Pove\u{107}aj ${e.fieldLabel}`,numberField:"Polje broja"},"hu-HU":{decrease:e=>`${e.fieldLabel} cs\xf6kkent\xe9se`,increase:e=>`${e.fieldLabel} n\xf6vel\xe9se`,numberField:"Sz\xe1mmező"},"it-IT":{decrease:e=>`Riduci ${e.fieldLabel}`,increase:e=>`Aumenta ${e.fieldLabel}`,numberField:"Campo numero"},"ja-JP":{decrease:e=>`${e.fieldLabel}\u{3092}\u{7E2E}\u{5C0F}`,increase:e=>`${e.fieldLabel}\u{3092}\u{62E1}\u{5927}`,numberField:"数値フィールド"},"ko-KR":{decrease:e=>`${e.fieldLabel} \u{AC10}\u{C18C}`,increase:e=>`${e.fieldLabel} \u{C99D}\u{AC00}`,numberField:"번호 필드"},"lt-LT":{decrease:e=>`Suma\u{17E}inti ${e.fieldLabel}`,increase:e=>`Padidinti ${e.fieldLabel}`,numberField:"Numerio laukas"},"lv-LV":{decrease:e=>`Samazin\u{101}\u{161}ana ${e.fieldLabel}`,increase:e=>`Palielin\u{101}\u{161}ana ${e.fieldLabel}`,numberField:"Skaitļu lauks"},"nb-NO":{decrease:e=>`Reduser ${e.fieldLabel}`,increase:e=>`\xd8k ${e.fieldLabel}`,numberField:"Tallfelt"},"nl-NL":{decrease:e=>`${e.fieldLabel} verlagen`,increase:e=>`${e.fieldLabel} verhogen`,numberField:"Getalveld"},"pl-PL":{decrease:e=>`Zmniejsz ${e.fieldLabel}`,increase:e=>`Zwi\u{119}ksz ${e.fieldLabel}`,numberField:"Pole numeru"},"pt-BR":{decrease:e=>`Diminuir ${e.fieldLabel}`,increase:e=>`Aumentar ${e.fieldLabel}`,numberField:"Campo de n\xfamero"},"pt-PT":{decrease:e=>`Diminuir ${e.fieldLabel}`,increase:e=>`Aumentar ${e.fieldLabel}`,numberField:"Campo num\xe9rico"},"ro-RO":{decrease:e=>`Sc\u{103}dere ${e.fieldLabel}`,increase:e=>`Cre\u{219}tere ${e.fieldLabel}`,numberField:"C\xe2mp numeric"},"ru-RU":{decrease:e=>`\u{423}\u{43C}\u{435}\u{43D}\u{44C}\u{448}\u{435}\u{43D}\u{438}\u{435} ${e.fieldLabel}`,increase:e=>`\u{423}\u{432}\u{435}\u{43B}\u{438}\u{447}\u{435}\u{43D}\u{438}\u{435} ${e.fieldLabel}`,numberField:"Числовое поле"},"sk-SK":{decrease:e=>`Zn\xed\u{17E}i\u{165} ${e.fieldLabel}`,increase:e=>`Zv\xfd\u{161}i\u{165} ${e.fieldLabel}`,numberField:"Č\xedseln\xe9 pole"},"sl-SI":{decrease:e=>`Upadati ${e.fieldLabel}`,increase:e=>`Pove\u{10D}ajte ${e.fieldLabel}`,numberField:"Številčno polje"},"sr-SP":{decrease:e=>`Smanji ${e.fieldLabel}`,increase:e=>`Pove\u{107}aj ${e.fieldLabel}`,numberField:"Polje broja"},"sv-SE":{decrease:e=>`Minska ${e.fieldLabel}`,increase:e=>`\xd6ka ${e.fieldLabel}`,numberField:"Nummerf\xe4lt"},"tr-TR":{decrease:e=>`${e.fieldLabel} azalt`,increase:e=>`${e.fieldLabel} artt\u{131}r`,numberField:"Sayı alanı"},"uk-UA":{decrease:e=>`\u{417}\u{43C}\u{435}\u{43D}\u{448}\u{438}\u{442}\u{438} ${e.fieldLabel}`,increase:e=>`\u{417}\u{431}\u{456}\u{43B}\u{44C}\u{448}\u{438}\u{442}\u{438} ${e.fieldLabel}`,numberField:"Поле номера"},"zh-CN":{decrease:e=>`\u{964D}\u{4F4E} ${e.fieldLabel}`,increase:e=>`\u{63D0}\u{9AD8} ${e.fieldLabel}`,numberField:"数字字段"},"zh-TW":{decrease:e=>`\u{7E2E}\u{5C0F} ${e.fieldLabel}`,increase:e=>`\u{653E}\u{5927} ${e.fieldLabel}`,numberField:"數字欄位"}};var bw={};bw={"ar-AE":{Empty:"فارغ"},"bg-BG":{Empty:"Изпразни"},"cs-CZ":{Empty:"Pr\xe1zdn\xe9"},"da-DK":{Empty:"Tom"},"de-DE":{Empty:"Leer"},"el-GR":{Empty:"Άδειο"},"en-US":{Empty:"Empty"},"es-ES":{Empty:"Vac\xedo"},"et-EE":{Empty:"T\xfchjenda"},"fi-FI":{Empty:"Tyhj\xe4"},"fr-FR":{Empty:"Vide"},"he-IL":{Empty:"ריק"},"hr-HR":{Empty:"Prazno"},"hu-HU":{Empty:"\xdcres"},"it-IT":{Empty:"Vuoto"},"ja-JP":{Empty:"空"},"ko-KR":{Empty:"비어 있음"},"lt-LT":{Empty:"Tuščias"},"lv-LV":{Empty:"Tukšs"},"nb-NO":{Empty:"Tom"},"nl-NL":{Empty:"Leeg"},"pl-PL":{Empty:"Pusty"},"pt-BR":{Empty:"Vazio"},"pt-PT":{Empty:"Vazio"},"ro-RO":{Empty:"Gol"},"ru-RU":{Empty:"Не заполнено"},"sk-SK":{Empty:"Pr\xe1zdne"},"sl-SI":{Empty:"Prazen"},"sr-SP":{Empty:"Prazno"},"sv-SE":{Empty:"Tomt"},"tr-TR":{Empty:"Boş"},"uk-UA":{Empty:"Пусто"},"zh-CN":{Empty:"空"},"zh-TW":{Empty:"空白"}};let bx=()=>{};function bE(e){var t;let r=(0,so.useRef)(void 0),{value:n,textValue:a,minValue:o,maxValue:i,isDisabled:s,isReadOnly:l,isRequired:u,onIncrement:c,onIncrementPage:d,onDecrement:m,onDecrementPage:p,onDecrementToMin:f,onIncrementToMax:h}=e,g=pI((t=bw)&&t.__esModule?t.default:t,"@react-aria/spinbutton"),y=(0,so.useRef)(!1),v=(0,so.useCallback)(()=>{clearTimeout(r.current),y.current=!1},[]),b=mO(()=>{v()});(0,so.useEffect)(()=>()=>b(),[]);let w=(0,so.useRef)(!1),x=()=>{w.current=!0},E=()=>{w.current=!1},D=""===a?g.format("Empty"):(a||`${n}`).replace("-","−");(0,so.useEffect)(()=>{w.current&&(pp&&pp.clear("assertive"),pf(D,"assertive"))},[D]);let S=(0,so.useCallback)(()=>{v()},[v]),_=mO(c??bx),C=mO(m??bx),k=mO(()=>{(void 0===i||isNaN(i)||void 0===n||isNaN(n)||n<i)&&(_(),P(60))}),P=mO(e=>{b(),y.current=!0,r.current=window.setTimeout(k,e)}),R=mO(()=>{(void 0===o||isNaN(o)||void 0===n||isNaN(n)||n>o)&&(C(),T(60))}),T=mO(e=>{b(),y.current=!0,r.current=window.setTimeout(R,e)}),$=e=>{e.preventDefault()},{addGlobalListener:N,removeAllGlobalListeners:O}=mI(),I=(0,so.useRef)(!1),[A,M]=(0,so.useState)(null);(0,so.useEffect)(()=>{"touch"===A?P(600):A&&P(400)},[A]);let[j,L]=(0,so.useState)(null);return(0,so.useEffect)(()=>{"touch"===j?T(600):j&&T(400)},[j]),{spinButtonProps:{role:"spinbutton","aria-valuenow":void 0===n||isNaN(n)?void 0:n,"aria-valuetext":D,"aria-valuemin":o,"aria-valuemax":i,"aria-disabled":s||void 0,"aria-readonly":l||void 0,"aria-required":u||void 0,onKeyDown:e=>{if(!e.ctrlKey&&!e.metaKey&&!e.shiftKey&&!e.altKey&&!l&&!e.nativeEvent.isComposing)switch(e.key){case"PageUp":if(d){e.preventDefault(),d?.();break}case"ArrowUp":case"Up":c&&(e.preventDefault(),c?.());break;case"PageDown":if(p){e.preventDefault(),p?.();break}case"ArrowDown":case"Down":m&&(e.preventDefault(),m?.());break;case"Home":f&&(e.preventDefault(),f?.());break;case"End":h&&(e.preventDefault(),h?.())}},onFocus:x,onBlur:E},incrementButtonProps:{onPressStart:e=>{v(),"touch"!==e.pointerType?(c?.(),M("mouse")):(N(window,"pointercancel",S,{capture:!0}),I.current=!1,M("touch")),N(window,"contextmenu",$)},onPressUp:e=>{v(),"touch"===e.pointerType&&(I.current=!0),O(),M(null)},onPressEnd:e=>{v(),"touch"===e.pointerType&&!y.current&&I.current&&c?.(),I.current=!1,M(null)},onFocus:x,onBlur:E},decrementButtonProps:{onPressStart:e=>{v(),"touch"!==e.pointerType?(m?.(),L("mouse")):(N(window,"pointercancel",S,{capture:!0}),I.current=!1,L("touch"))},onPressUp:e=>{v(),"touch"===e.pointerType&&(I.current=!0),O(),L(null)},onPressEnd:e=>{v(),"touch"===e.pointerType&&!y.current&&I.current&&m?.(),I.current=!1,L(null)},onFocus:x,onBlur:E}}}let bD=null;var bS=r(2103);function b_(e,t,r){let n="+"===e?t+r:t-r;if(t%1!=0||r%1!=0){let a=t.toString().split("."),o=r.toString().split("."),i=Math.pow(10,Math.max(a[1]&&a[1].length||0,o[1]&&o[1].length||0));t=Math.round(t*i),r=Math.round(r*i),n=("+"===e?t+r:t-r)/i}return n}let bC=(0,so.createContext)(null),bk=(0,so.createContext)(null),bP=(0,so.forwardRef)(function(e,t){var r,n;[e,t]=dg(e,t,bC);let{validationBehavior:a}=dh(yu)||{},o=null!=(n=null!=(r=e.validationBehavior)?r:a)?n:"native",{locale:i}=pm(),s=function(e){let{minValue:t,maxValue:r,step:n,formatOptions:a,value:o,defaultValue:i=NaN,onChange:s,locale:l,isDisabled:u,isReadOnly:c,commitBehavior:d="snap"}=e;null===o&&(o=NaN);let m=(0,so.useCallback)(e=>void 0===n||isNaN(n)?yg(e,t,r):yv(e,t,r,n),[n,t,r]);void 0===o||isNaN(o)||"snap"!==d||(o=m(o)),isNaN(i)||"snap"!==d||(i=m(i));let[p,f]=hL(o,isNaN(i)?NaN:i,s),[h]=(0,so.useState)(p),[g,y]=(0,so.useState)(()=>isNaN(p)?"":new(0,gJ.K)(l,a).format(p)),v=(0,so.useMemo)(()=>new(0,bS.d)(l,a),[l,a]),b=(0,so.useMemo)(()=>v.getNumberingSystem(g),[v,g]),w=(0,so.useMemo)(()=>new(0,gJ.K)(l,{...a,numberingSystem:b}),[l,a,b]),x=(0,so.useMemo)(()=>w.resolvedOptions(),[w]),E=(0,so.useCallback)(e=>isNaN(e)||null===e?"":w.format(e),[w]),D=gO({...e,value:p}),S=void 0===n||isNaN(n)?1:n;"percent"===x.style&&(void 0===n||isNaN(n))&&(S=.01);let[_,C]=(0,so.useState)(p),[k,P]=(0,so.useState)(l),[R,T]=(0,so.useState)(a);Object.is(p,_)&&l===k&&a===R||(y(E(p)),C(p),P(l),T(a));let $=(0,so.useMemo)(()=>v.parse(g),[v,g]),N=(e,n=0)=>{if(isNaN($))return yv(isNaN(n)?0:n,t,r,S);{let n=yv($,t,r,S);return"+"===e&&n>$||"-"===e&&n<$?n:yv(b_(e,$,S),t,r,S)}},O=(0,so.useMemo)(()=>!u&&!c&&(isNaN($)||void 0===r||isNaN(r)||yv($,t,r,S)>$||b_("+",$,S)<=r),[u,c,t,r,S,$]),I=(0,so.useMemo)(()=>!u&&!c&&(isNaN($)||void 0===t||isNaN(t)||yv($,t,r,S)<$||b_("-",$,S)>=t),[u,c,t,r,S,$]);return{...D,validate:e=>v.isValidPartialNumber(e,t,r),increment:()=>{let e=N("+",t);e===p&&y(E(e)),f(e),D.commitValidation()},incrementToMax:()=>{null!=r&&(f(yv(r,t,r,S)),D.commitValidation())},decrement:()=>{let e=N("-",r);e===p&&y(E(e)),f(e),D.commitValidation()},decrementToMin:()=>{null!=t&&(f(t),D.commitValidation())},canIncrement:O,canDecrement:I,minValue:t,maxValue:r,numberValue:$,defaultNumberValue:isNaN(i)?h:i,setNumberValue:f,setInputValue:y,inputValue:g,commit:e=>{let t=void 0===e?g:e,r=$;if(void 0!==e&&(r=v.parse(t)),!t.length){f(NaN),y(void 0===o?"":E(p));return}if(isNaN(r))return void y(E(p));let n="snap"===d?m(r):r,a=(n=v.parse(E(n)))!==p;f(n),y(E(void 0===o?n:p)),a&&D.commitValidation()}}}({...e,locale:i,validationBehavior:o}),l=(0,so.useRef)(null),[u,c]=dy(!e["aria-label"]&&!e["aria-labelledby"]),{labelProps:d,groupProps:m,inputProps:p,incrementButtonProps:f,decrementButtonProps:h,descriptionProps:g,errorMessageProps:y,...v}=function(e,t,r){var n,a,o,i,s,l,u,c,d;let m,{id:p,decrementAriaLabel:f,incrementAriaLabel:h,isDisabled:g,isReadOnly:y,isRequired:v,minValue:b,maxValue:w,autoFocus:x,label:E,formatOptions:D,onBlur:S=()=>{},onFocus:_,onFocusChange:C,onKeyDown:k,onKeyUp:P,description:R,errorMessage:T,isWheelDisabled:$,...N}=e,{increment:O,incrementToMax:I,decrement:A,decrementToMin:M,numberValue:j,inputValue:L,commit:F,commitValidation:B}=t,V=pI((n=by)&&n.__esModule?n.default:n,"@react-aria/numberfield"),U=(0,so.useCallback)(()=>{let e=r.current?.value??"";(0,mA.flushSync)(()=>{F()}),r.current?.value!==e&&pf(r.current?.value??"","assertive")},[F,r]),W=dl(p),{focusProps:H}=mb({onBlur(){U()}}),z=bb(D),K=(0,so.useMemo)(()=>z.resolvedOptions(),[z]),G=bb({...D,currencySign:void 0}),Z=(0,so.useMemo)(()=>isNaN(j)?"":G.format(j),[G,j]),{spinButtonProps:Y,incrementButtonProps:q,decrementButtonProps:J}=bE({isDisabled:g,isReadOnly:y,isRequired:v,maxValue:w,minValue:b,onIncrement:O,onIncrementToMax:I,onDecrement:A,onDecrementToMin:M,value:j,textValue:Z}),[X,Q]=(0,so.useState)(!1),{focusWithinProps:ee}=mZ({isDisabled:g,onFocusWithinChange:Q});!function(e,t){let{onScroll:r,isDisabled:n}=e,a=(0,so.useCallback)(e=>{!e.ctrlKey&&(e.preventDefault(),e.stopPropagation(),r&&r({deltaX:e.deltaX,deltaY:e.deltaY}))},[r]);fW(t,"wheel",n?void 0:a)}({onScroll:(0,so.useCallback)(e=>{!(Math.abs(e.deltaY)<=Math.abs(e.deltaX))&&(e.deltaY>0?O():e.deltaY<0&&A())},[A,O]),isDisabled:$||g||y||!X},r);let et=(K.maximumFractionDigits??0)>0,er=void 0===t.minValue||isNaN(t.minValue)||t.minValue<0,en="numeric";dQ()?er?en="text":et&&(en="decimal"):d3()&&(er?en="numeric":et&&(en="decimal"));let ea=dR(e),eo=(0,so.useCallback)(e=>{e.nativeEvent.isComposing||("Enter"===e.key?((0,mA.flushSync)(()=>{F()}),B()):e.continuePropagation())},[F,B]),{isInvalid:ei,validationErrors:es,validationDetails:el}=t.displayValidation,{labelProps:eu,inputProps:ec,descriptionProps:ed,errorMessageProps:em}=function(e,t,r){let n=mO(e=>{let n=r.current;if(!n)return;let a=null;switch(e.inputType){case"historyUndo":case"historyRedo":case"insertLineBreak":return;case"deleteContent":case"deleteByCut":case"deleteByDrag":a=n.value.slice(0,n.selectionStart)+n.value.slice(n.selectionEnd);break;case"deleteContentForward":a=n.selectionEnd===n.selectionStart?n.value.slice(0,n.selectionStart)+n.value.slice(n.selectionEnd+1):n.value.slice(0,n.selectionStart)+n.value.slice(n.selectionEnd);break;case"deleteContentBackward":a=n.selectionEnd===n.selectionStart?n.value.slice(0,n.selectionStart-1)+n.value.slice(n.selectionStart):n.value.slice(0,n.selectionStart)+n.value.slice(n.selectionEnd);break;case"deleteSoftLineBackward":case"deleteHardLineBackward":a=n.value.slice(n.selectionStart);break;default:null!=e.data&&(a=n.value.slice(0,n.selectionStart)+e.data+n.value.slice(n.selectionEnd))}null!=a&&t.validate(a)||e.preventDefault()});(0,so.useEffect)(()=>{if(!bv()||!r.current)return;let e=r.current;return e.addEventListener("beforeinput",n,!1),()=>{e.removeEventListener("beforeinput",n,!1)}},[r]);let a=bv()?null:e=>{let r=dA(e).value.slice(0,dA(e).selectionStart)+e.data+dA(e).value.slice(dA(e).selectionEnd);t.validate(r)||e.preventDefault()},{labelProps:o,inputProps:i,descriptionProps:s,errorMessageProps:l,...u}=function(e,t){let{inputElementType:r="input",isDisabled:n=!1,isRequired:a=!1,isReadOnly:o=!1,type:i="text",validationBehavior:s="aria"}=e,[l,u]=hL(e.value,e.defaultValue||"",e.onChange),{focusableProps:c}=mD(e,t),d=gO({...e,value:l}),{isInvalid:m,validationErrors:p,validationDetails:f}=d.displayValidation,{labelProps:h,fieldProps:g,descriptionProps:y,errorMessageProps:v}=gw({...e,isInvalid:m,errorMessage:e.errorMessage||p}),b=dR(e,{labelable:!0}),w={type:i,pattern:e.pattern},[x]=(0,so.useState)(l);return gx(t,e.defaultValue??x,u),gE(e,d,t),{labelProps:h,inputProps:dd(b,"input"===r?w:void 0,{disabled:n,readOnly:o,required:a&&"native"===s,"aria-required":a&&"aria"===s||void 0,"aria-invalid":m||void 0,"aria-errormessage":e["aria-errormessage"],"aria-activedescendant":e["aria-activedescendant"],"aria-autocomplete":e["aria-autocomplete"],"aria-haspopup":e["aria-haspopup"],"aria-controls":e["aria-controls"],value:l,onChange:e=>u(dA(e).value),autoComplete:e.autoComplete,autoCapitalize:e.autoCapitalize,maxLength:e.maxLength,minLength:e.minLength,name:e.name,form:e.form,placeholder:e.placeholder,inputMode:e.inputMode,autoCorrect:e.autoCorrect,spellCheck:e.spellCheck,[parseInt(si().version,10)>=17?"enterKeyHint":"enterkeyhint"]:e.enterKeyHint,onCopy:e.onCopy,onCut:e.onCut,onPaste:e.onPaste,onCompositionEnd:e.onCompositionEnd,onCompositionStart:e.onCompositionStart,onCompositionUpdate:e.onCompositionUpdate,onSelect:e.onSelect,onBeforeInput:e.onBeforeInput,onInput:e.onInput,...c,...g}),descriptionProps:y,errorMessageProps:v,isInvalid:m,validationErrors:p,validationDetails:f}}(e,r),c=(0,so.useRef)(null);return{inputProps:dd(i,{onBeforeInput:a,onCompositionStart(){let{value:e,selectionStart:t,selectionEnd:n}=r.current;c.current={value:e,selectionStart:t,selectionEnd:n}},onCompositionEnd(){if(r.current&&!t.validate(r.current.value)){let{value:e,selectionStart:n,selectionEnd:a}=c.current;r.current.value=e,r.current.setSelectionRange(n,a),t.setInputValue(e)}}}),labelProps:o,descriptionProps:s,errorMessageProps:l,...u}}({...N,...ea,name:void 0,form:void 0,label:E,autoFocus:x,isDisabled:g,isReadOnly:y,isRequired:v,validate:void 0,[gN]:t,value:L,defaultValue:"!",autoComplete:"off","aria-label":e["aria-label"]||void 0,"aria-labelledby":e["aria-labelledby"]||void 0,id:W,type:"text",inputMode:en,onChange:e=>{t.validate(e)&&t.setInputValue(e)},onBlur:S,onFocus:_,onFocusChange:C,onKeyDown:(0,so.useMemo)(()=>c3(eo,k),[eo,k]),onKeyUp:P,onPaste:t=>{e.onPaste?.(t);let r=dA(t);r&&(r.selectionEnd??-1)-(r.selectionStart??0)===r.value.length&&(t.preventDefault(),F(t.clipboardData?.getData?.("text/plain")?.trim()??""))},description:R,errorMessage:T},t,r);gx(r,t.defaultNumberValue,t.setNumberValue),a=t,o=e.validationBehavior,i=e.commitBehavior,s=r,l=t.minValue,u=t.maxValue,c=e.step,d=t.numberValue,c6(()=>{let e=s.current;if("validate"!==i||a.realtimeValidation.isInvalid||!e||e.disabled||(!bD&&"u">typeof document&&((bD=document.createElement("input")).type="number"),!bD))return;bD.min=null==l||isNaN(l)?"":String(l),bD.max=null==u||isNaN(u)?"":String(u),bD.step=null==c||isNaN(c)?"":String(c),bD.value=null==d||isNaN(d)?"":String(d);let t=e.validity.valid&&bD.validity.valid,r=e.validationMessage||bD.validationMessage,n={isInvalid:!t,validationErrors:r?[r]:[],validationDetails:{badInput:e.validity.badInput,customError:e.validity.customError,patternMismatch:e.validity.patternMismatch,rangeOverflow:bD.validity.rangeOverflow,rangeUnderflow:bD.validity.rangeUnderflow,stepMismatch:bD.validity.stepMismatch,tooLong:e.validity.tooLong,tooShort:e.validity.tooShort,typeMismatch:e.validity.typeMismatch,valueMissing:e.validity.valueMissing,valid:t}};a.updateValidation(n),"native"!==o||bD.validity.valid||e.setCustomValidity(bD.validationMessage)});let ep=dd(Y,H,ec,{role:null,"aria-roledescription":d1()?null:V.format("numberField"),"aria-valuemax":null,"aria-valuemin":null,"aria-valuenow":null,"aria-valuetext":null,autoCorrect:"off",spellCheck:"false"});"native"===e.validationBehavior&&(ep["aria-required"]=void 0);let ef=e=>{((e=document)=>e.activeElement)()!==r.current&&("mouse"===e.pointerType?r.current?.focus():e.target.focus())},eh=e["aria-label"]||("string"==typeof e.label?e.label:"");eh||(m=null!=e.label?eu.id:e["aria-labelledby"]);let eg=dl(),ey=dl(),ev=dd(q,{"aria-label":h||V.format("increase",{fieldLabel:eh}).trim(),id:m&&!h?eg:null,"aria-labelledby":m&&!h?`${eg} ${m}`:null,"aria-controls":W,excludeFromTabOrder:!0,preventFocusOnPress:!0,allowFocusWhenDisabled:!0,isDisabled:!t.canIncrement,onPressStart:ef}),eb=dd(J,{"aria-label":f||V.format("decrease",{fieldLabel:eh}).trim(),id:m&&!f?ey:null,"aria-labelledby":m&&!f?`${ey} ${m}`:null,"aria-controls":W,excludeFromTabOrder:!0,preventFocusOnPress:!0,allowFocusWhenDisabled:!0,isDisabled:!t.canDecrement,onPressStart:ef});return{groupProps:{...ee,role:"group","aria-disabled":g,"aria-invalid":ei?"true":void 0},labelProps:eu,inputProps:ep,incrementButtonProps:ev,decrementButtonProps:eb,errorMessageProps:em,descriptionProps:ed,isInvalid:ei,validationErrors:es,validationDetails:el}}({...dv(e),label:c,validationBehavior:o},s,l),b=df({...e,values:{state:s,isDisabled:e.isDisabled||!1,isInvalid:v.isInvalid||!1,isRequired:e.isRequired||!1},defaultClassName:"react-aria-NumberField"}),w=dR(e);return delete w.id,si().createElement(dp,{values:[[bk,s],[h4,m],[h3,{...p,ref:l}],[yc,{...d,ref:u}],[m3,{slots:{increment:f,decrement:h}}],[m9,{slots:{description:g,errorMessage:y}}],[yi,v]]},si().createElement("div",{...w,...b,ref:t,slot:e.slot||void 0,"data-disabled":e.isDisabled||void 0,"data-required":e.isRequired||void 0,"data-invalid":v.isInvalid||void 0}),e.name&&si().createElement("input",{type:"hidden",name:e.name,value:isNaN(s.numberValue)?"":s.numberValue}))});function bR(e,t){return Number.parseInt(bt(e,{calendar:t.calendar,locale:t.baseName,day:!1,month:!1,noToday:!0,numberingSystem:"latn"}))}let bT=(0,so.forwardRef)(function(e,t){let{className:r}=e,n=(0,so.useContext)(hK),a=(0,so.useContext)(hG),o=n??a,i=(0,so.useContext)(bf),s=fS(),l=bt(o.visibleRange.start.toDate(s),{calendar:i.calendar,locale:i.baseName,day:!1,year:!1,noToday:!0}),u=bR(o.visibleRange.start.toDate(s),i),c=o.maxValue?bR(o.maxValue.toDate(s),i):void 0,d=o.minValue?bR(o.minValue.toDate(s),i):void 0,m=(0,so.useCallback)(e=>{o.setFocusedDate(o.focusedDate.cycle("year",e-o.focusedDate.year))},[]);return o&&(0,sl.jsxs)("span",{ref:t,className:r,children:[(0,sl.jsx)("span",{children:l}),(0,sl.jsxs)(bP,{formatOptions:{useGrouping:!1},maxValue:c,minValue:d,onChange:m,value:u,children:[(0,sl.jsx)(h6,{}),(0,sl.jsxs)(h2,{children:[(0,sl.jsx)(m6,{slot:"increment",children:(0,sl.jsx)(uT,{size:8})}),(0,sl.jsx)(m6,{slot:"decrement",children:(0,sl.jsx)(uk,{size:8})})]})]})]})}),b$="-esm-patient-chart__datepicker-module__inputGroup___gBam-",bN="-esm-patient-chart__datepicker-module__inputSegment___wIJDZ",bO="-esm-patient-chart__datepicker-module__dateInputWrapper___LiY68",bI="-esm-patient-chart__datepicker-module__invalidText___A4cv4",bA="-esm-patient-chart__datepicker-module__flatButton___HcpME",bM="-esm-patient-chart__datepicker-module__flatButtonMd___eFpyF",bj="-esm-patient-chart__datepicker-module__flatButtonSm___tsawR",bL="-esm-patient-chart__datepicker-module__flatButtonLg___4HG5y";function bF({children:e}){let t=(0,so.useContext)(vc),r=(0,so.useContext)(vd),n=t??r,a=lR(()=>n?.close());return(0,sl.jsx)(yo,{className:"-esm-patient-chart__datepicker-module__dialog___DaqYi",ref:a,children:e})}let bB=(0,so.forwardRef)(function({variant:e,today_:t,minDate:r,maxDate:n},a){let o="range"===e;return(0,sl.jsx)(vo,{ref:a,className:"-esm-patient-chart__datepicker-module__popover___nAPzC",placement:"bottom start",offset:1,isNonModal:!0,children:(0,sl.jsx)(bF,{children:(0,sl.jsxs)(o?hY:hZ,{...o?{minValue:r,maxValue:n,className:"cds--date-picker__calendar"}:{},children:[(0,sl.jsxs)("header",{className:"-esm-patient-chart__datepicker-module__header___rPv3L",children:[(0,sl.jsx)(m6,{className:ue()(bA,bM),slot:"previous",children:(0,sl.jsx)(uj,{size:16})}),(0,sl.jsx)(bT,{className:"-esm-patient-chart__datepicker-module__monthYear___Rw4qE"}),(0,sl.jsx)(m6,{className:ue()(bA,bM),slot:"next",children:(0,sl.jsx)(uL,{size:16})})]}),(0,sl.jsx)(hJ,{className:"-esm-patient-chart__datepicker-module__calendarGrid___yKV-n",children:e=>(0,sl.jsx)(h1,{className:ue()("cds--date-picker__day",{"-esm-patient-chart__datepicker-module__today___KzMTn":0===t.compare(e)}),date:e},e.toString())})]})})})}),bV=(0,so.forwardRef)(function(e,t){let r=(0,so.useContext)(vc),[n,a]=dg({slot:e.slot},t,g4),{locale:o}=pm(),i=g1({...n,locale:o,createCalendar:hR}),s=(0,so.useRef)(null),{fieldProps:l,inputProps:u}=gC({...n,inputRef:s},i,a),c=(0,so.useCallback)(()=>{i.isDisabled||r.toggle()},[]);return(0,sl.jsxs)(dp,{values:[[g2,i],[h3,{...u,ref:s}],[h4,{...l,ref:a,isInvalid:i.isInvalid}]],children:[(0,sl.jsx)(h2,{...e,id:e.id,ref:t,slot:e.slot||void 0,className:e.className,isDisabled:i.isDisabled,isInvalid:i.isInvalid,onClick:c,children:i.segments.map((t,r)=>(0,so.cloneElement)(e.children(t),{key:r}))}),(0,sl.jsx)(h6,{})]})}),bU=(0,so.forwardRef)(function(e,t){let r=(0,so.useContext)(vc),n=(0,so.useContext)(vd);return(r??n).isInvalid?(0,sl.jsx)(cz,{ref:t,size:16,...e}):(0,sl.jsx)(uC,{ref:t,size:16,...e})});class bW{constructor(e,t){this.locale=e,this.dictionary=t}of(e){return this.dictionary.getStringForLocale(e,this.locale)}}let bH=new Map,bz=(0,so.forwardRef)(function({segment:e,...t},r){let n=(0,so.useContext)(g2),a=c1(r),{segmentProps:o}=function(e,t,r){let n,a,o,i,s=(0,so.useRef)(""),{locale:l,direction:u}=pm(),c=function(){var e;let{locale:t}=pm(),r=pO((e=gy)&&e.__esModule?e.default:e,"@react-aria/datepicker");return(0,so.useMemo)(()=>{try{return new Intl.DisplayNames(t,{type:"dateTimeField"})}catch{return new bW(t,r)}},[t,r])}(),{ariaLabel:d,ariaLabelledBy:m,ariaDescribedBy:p,focusManager:f}=gD.get(t),h=e.isPlaceholder?"":e.text,g=(0,so.useMemo)(()=>t.dateFormatter.resolvedOptions(),[t.dateFormatter]),y=pS({month:"long",timeZone:g.timeZone}),v=pS({hour:"numeric",hour12:g.hour12,timeZone:g.timeZone});if("month"!==e.type||e.isPlaceholder)"hour"!==e.type||e.isPlaceholder||(h=v.format(t.dateValue));else{let e=y.format(t.dateValue);h=e!==h?`${h} \u{2013} ${e}`:e}let{spinButtonProps:b}=bE({value:e.value??void 0,textValue:h,minValue:e.minValue,maxValue:e.maxValue,isDisabled:t.isDisabled,isReadOnly:t.isReadOnly||!e.isEditable,isRequired:t.isRequired,onIncrement:()=>{s.current="",t.increment(e.type)},onDecrement:()=>{s.current="",t.decrement(e.type)},onIncrementPage:()=>{s.current="",t.incrementPage(e.type)},onDecrementPage:()=>{s.current="",t.decrementPage(e.type)},onIncrementToMax:()=>{s.current="",t.incrementToMax(e.type)},onDecrementToMin:()=>{s.current="",t.decrementToMin(e.type)}}),w=(0,so.useMemo)(()=>new(0,bS.d)(l,{maximumFractionDigits:0}),[l]),x=()=>{if(e.text===e.placeholder&&f.focusPrevious(),!w.isValidPartialNumber(e.text)||t.isReadOnly||e.isPlaceholder)("dayPeriod"===e.type||"era"===e.type)&&t.clearSegment(e.type);else{let r=e.text.slice(0,-1),n=w.parse(r);0===(r=0===n?"":r).length||0===n?t.clearSegment(e.type):t.setSegment(e.type,n),s.current=r}},{startsWith:E}=(n=function(e){let{locale:t}=pm(),r=t+(e?Object.entries(e).sort((e,t)=>e[0]<t[0]?-1:1).join():"");if(bH.has(r))return bH.get(r);let n=new Intl.Collator(t,e);return bH.set(r,n),n}({usage:"search",sensitivity:"base"}),a=(0,so.useCallback)((e,t)=>0===t.length||(e=e.normalize("NFC"),t=t.normalize("NFC"),0===n.compare(e.slice(0,t.length),t)),[n]),o=(0,so.useCallback)((e,t)=>0===t.length||(e=e.normalize("NFC"),t=t.normalize("NFC"),0===n.compare(e.slice(-t.length),t)),[n]),i=(0,so.useCallback)((e,t)=>{if(0===t.length)return!0;e=e.normalize("NFC");let r=0,a=(t=t.normalize("NFC")).length;for(;r+a<=e.length;r++){let o=e.slice(r,r+a);if(0===n.compare(t,o))return!0}return!1},[n]),(0,so.useMemo)(()=>({startsWith:a,endsWith:o,contains:i}),[a,o,i])),D=pS({hour:"numeric",hour12:!0}),S=(0,so.useMemo)(()=>{let e=new Date;return e.setHours(0),D.formatToParts(e).find(e=>"dayPeriod"===e.type).value},[D]),_=(0,so.useMemo)(()=>{let e=new Date;return e.setHours(12),D.formatToParts(e).find(e=>"dayPeriod"===e.type).value},[D]),C=pS({year:"numeric",era:"narrow",timeZone:"UTC"}),k=(0,so.useMemo)(()=>{if("era"!==e.type)return[];let r=fm(new p8(1,1,1),t.calendar),n=t.calendar.getEras().map(e=>{let t=r.set({year:1,month:1,day:1,era:e}).toDate("UTC");return{era:e,formatted:C.formatToParts(t).find(e=>"era"===e.type).value}}),a=function(e){e.sort();let t=e[0],r=e[e.length-1];for(let e=0;e<t.length;e++)if(t[e]!==r[e])return e;return 0}(n.map(e=>e.formatted));if(a)for(let e of n)e.formatted=e.formatted.slice(a);return n},[C,t.calendar,e.type]),P=r=>{if(t.isDisabled||t.isReadOnly)return;let n=s.current+r;switch(e.type){case"dayPeriod":if(E(S,r))t.setSegment("dayPeriod",0);else if(E(_,r))t.setSegment("dayPeriod",1);else break;f.focusNext();break;case"era":{let e=k.find(e=>E(e.formatted,r));e&&(t.setSegment("era",e.era),f.focusNext());break}case"day":case"hour":case"minute":case"second":case"month":case"year":{if(!w.isValidPartialNumber(n))return;let a=w.parse(n),o=a;if(void 0!==e.maxValue&&a>e.maxValue&&(o=w.parse(r)),isNaN(a))return;t.setSegment(e.type,o),void 0!==e.maxValue&&(Number(a+"0")>e.maxValue||n.length>=String(e.maxValue).length)?(s.current="",f.focusNext()):s.current=n}}};fW((0,so.useRef)("u">typeof document?document:null),"selectionchange",()=>{let e=window.getSelection();e?.anchorNode&&dI(r.current,e?.anchorNode)&&e.collapse(r.current)});let R=(0,so.useRef)("");fW(r,"beforeinput",n=>{if(r.current)switch(n.preventDefault(),n.inputType){case"deleteContentBackward":case"deleteContentForward":w.isValidPartialNumber(e.text)&&!t.isReadOnly&&x();break;case"insertCompositionText":R.current=r.current.textContent,r.current.textContent=r.current.textContent;break;default:null!=n.data&&P(n.data)}}),fW(r,"input",e=>{let{inputType:t,data:n}=e;"insertCompositionText"===t&&(r.current&&(r.current.textContent=R.current),null!=n&&(E(S,n)||E(_,n))&&P(n))}),c6(()=>{let e=r.current;return()=>{((e=document)=>e.activeElement)()===e&&(f.focusPrevious()||f.focusNext())}},[r,f]);let T=d1()||"timeZoneName"===e.type?{role:"textbox","aria-valuemax":null,"aria-valuemin":null,"aria-valuetext":null,"aria-valuenow":null}:{};e===(0,so.useMemo)(()=>t.segments.find(e=>e.isEditable),[t.segments])||t.isInvalid||(p=void 0);let $=dl(),N=!t.isDisabled&&!t.isReadOnly&&e.isEditable,O="literal"===e.type?"":c.of(e.type),I=fL({"aria-label":`${O}${d?`, ${d}`:""}${m?", ":""}`,"aria-labelledby":m});if("literal"===e.type)return{segmentProps:{"aria-hidden":!0}};let A={caretColor:"transparent"};if("rtl"===u){A.unicodeBidi="embed";let t=g[e.type];("numeric"===t||"2-digit"===t)&&(A.direction="ltr")}return{segmentProps:dd(b,I,{id:$,...T,"aria-invalid":t.isInvalid?"true":void 0,"aria-describedby":p,"aria-readonly":t.isReadOnly||!e.isEditable?"true":void 0,"data-placeholder":e.isPlaceholder||void 0,contentEditable:N,suppressContentEditableWarning:N,spellCheck:N?"false":void 0,autoCorrect:N?"off":void 0,[parseInt(si().version,10)>=17?"enterKeyHint":"enterkeyhint"]:N?"next":void 0,inputMode:t.isDisabled||"dayPeriod"===e.type||"era"===e.type||!N?void 0:"numeric",tabIndex:t.isDisabled?void 0:0,onKeyDown:e=>{if("a"===e.key&&(dX()?e.metaKey:e.ctrlKey)&&e.preventDefault(),!e.ctrlKey&&!e.metaKey&&!e.shiftKey&&!e.altKey)switch(e.key){case"Backspace":case"Delete":e.preventDefault(),e.stopPropagation(),x()}},onFocus:()=>{s.current="",r.current&&fZ(r.current,{containingElement:fz(r.current)});let e=window.getSelection();e?.collapse(r.current)},style:A,onPointerDown(e){e.stopPropagation()},onMouseDown(e){e.stopPropagation()}})}}(e,n,a),{focusProps:i,isFocused:s,isFocusVisible:l}=mY(),{hoverProps:u,isHovered:c}=m0({...t,isDisabled:n.isDisabled||"literal"===e.type}),d=function(e){let{className:t,style:r,children:n,defaultClassName:a,defaultChildren:o,defaultStyle:i,values:s}=e;return(0,so.useMemo)(()=>{let e,l,u;return e="function"==typeof t?t({...s,defaultClassName:a}):t,l="function"==typeof r?r({...s,defaultStyle:i||{}}):r,u="function"==typeof n?n({...s,defaultChildren:o}):null==n?o:n,{className:e??a,style:l||i?{...i,...l}:void 0,children:u??o,"data-rac":""}},[t,r,n,a,o,i,s])}({...t,values:{...e,isReadOnly:!e.isEditable,isInvalid:n.isInvalid,isDisabled:n.isDisabled,isHovered:c,isFocused:s,isFocusVisible:l},defaultChildren:e.text}),m=(0,so.useCallback)(e=>{e.stopPropagation()},[]);return(0,sl.jsx)("span",{...dd(dR(t),o,i,u),...d,ref:a,style:o.style,"data-placeholder":e.isPlaceholder||void 0,"data-invalid":n.isInvalid||void 0,"data-readonly":!e.isEditable||void 0,"data-disabled":n.isDisabled||void 0,"data-type":e.type,"data-hovered":c||void 0,"data-focused":s||void 0,"data-focus-visible":l||void 0,onClick:m})}),bK={short:!1,size:"md"},bG=(0,so.forwardRef)(function(e,t){let{className:r,defaultValue:n,isDisabled:a,invalid:o,invalidText:i,isInvalid:s,label:l,labelText:u,light:c,maxDate:d,minDate:m,onChange:p,onChangeRaw:f,short:h,size:g,value:y,...v}={...bK,...e},{calendar:b,intlLocale:w,today_:x}=bh(),E=(0,so.useId)(),D=!!(u??l),S=(0,so.useMemo)(()=>vh(n,b),[n,b]),_=(0,so.useMemo)(()=>vh(y,b,!0),[y,b]),C=(0,so.useMemo)(()=>vh(d,b),[d,b]),k=(0,so.useMemo)(()=>vh(m??bg,b),[m,b]),P=(0,so.useMemo)(()=>o||s,[o,s]),R=(0,so.useMemo)(()=>(f&&p&&console.error("An OpenmrsDatePicker component was created with both onChange and onChangeRaw handlers defined. Only onChangeRaw will be used."),f??(e=>p?.(vg(e)))),[f,p]);return(0,sl.jsx)(vf,{locale:w.toString(),children:(0,sl.jsx)("div",{className:ue()("cds--form-item",r),children:(0,sl.jsx)(dp,{values:[[bf,w]],children:(0,sl.jsxs)(vm,{className:ue()("cds--date-picker","cds--date-picker--single",{"cds--date-picker--short":h,"cds--date-picker--light":c}),defaultValue:S,isDisabled:a,isInvalid:P,maxValue:C,minValue:k,value:_,shouldForceLeadingZeros:"en"===w.language||void 0,...v,onChange:R,children:[(0,sl.jsxs)("div",{className:"cds--date-picker-container",children:[D&&(0,sl.jsx)(yd,{className:ue()("cds--label",{"cds--label--disabled":a}),htmlFor:E,children:u??l}),(0,sl.jsxs)(h2,{className:b$,children:[(0,sl.jsx)(bV,{id:D?E:void 0,ref:t,className:ue()("cds--date-picker-input__wrapper","-esm-patient-chart__datepicker-module__inputWrapper___uKdT1",{"-esm-patient-chart__datepicker-module__inputWrapperSm___0RXJc":"sm"===g,"-esm-patient-chart__datepicker-module__inputWrapperMd___4Vff1":"md"===g||!g||0===g.length,"-esm-patient-chart__datepicker-module__inputWrapperLg___VCRm5":"lg"===g}),children:e=>"era"!==e.type?(0,sl.jsx)(bz,{className:bN,segment:e}):(0,sl.jsx)(si().Fragment,{})}),(0,sl.jsx)(m6,{className:ue()(bA,{[bj]:"sm"===g,[bM]:"md"===g||!g||0===g.length,[bL]:"lg"===g}),children:(0,sl.jsx)(bU,{})})]}),(0,sl.jsx)(ys,{className:bI,children:i})]}),(0,sl.jsx)(bB,{variant:"single",today_:x})]})})})})}),bZ=(0,so.forwardRef)(function({className:e,defaultValue:t,invalid:r,invalidText:n,isDisabled:a,isInvalid:o,label:i,labelText:s,light:l,maxDate:u,minDate:c,onChange:d,onChangeRaw:m,size:p="md",value:f,...h},g){let{calendar:y,intlLocale:v,today_:b}=bh(),w=(0,so.useId)(),x=!!(s??i),E=(0,so.useMemo)(()=>{if(f)return{start:vh(f[0],y,!1),end:vh(f[1],y,!1)}},[f,y]),D=(0,so.useMemo)(()=>{if(t)return{start:vh(t[0],y,!1),end:vh(t[1],y,!1)}},[t,y]),S=(0,so.useMemo)(()=>vh(c??bg,y,!0),[c,y]),_=(0,so.useMemo)(()=>vh(u,y,!0),[u,y]),C=(0,so.useMemo)(()=>r||o,[r,o]),k=(0,so.useMemo)(()=>(m&&d&&console.error("An OpenmrsDateRangePicker component was created with both onChange and onChangeRaw handlers defined. Only onChangeRaw will be used."),m??(e=>d?.([vg(e.start),vg(e.end)]))),[m,d]);return(0,sl.jsx)(vf,{locale:v.toString(),children:(0,sl.jsx)("div",{className:ue()("cds--form-item",e),children:(0,sl.jsx)(dp,{values:[[bf,v]],children:(0,sl.jsx)(vp,{id:x?w:void 0,className:ue()("cds--date-picker",{"cds--date-picker--light":l,"cds--date-picker--disabled":a}),isInvalid:C,shouldForceLeadingZeros:"en"===v.language||void 0,maxValue:_,minValue:S,value:E,defaultValue:D,ref:g,isDisabled:a,...h,onChange:k,children:(0,sl.jsxs)("div",{className:"cds--date-picker-container",children:[x&&(0,sl.jsx)(yd,{className:ue()("cds--label",{"cds--label--disabled":a}),htmlFor:w,children:s??i}),(0,sl.jsxs)(h2,{className:b$,children:[(0,sl.jsxs)("div",{className:ue()("-esm-patient-chart__datepicker-module__inputsWrapper___xXRQI",{"-esm-patient-chart__datepicker-module__inputsWrapperSm___nL+b6":"sm"===p,"-esm-patient-chart__datepicker-module__inputsWrapperMd___Kgcps":"md"===p||!p||0===p.length,"-esm-patient-chart__datepicker-module__inputsWrapperLg___raaSN":"lg"===p}),children:[(0,sl.jsx)(g6,{className:ue()("cds--date-picker-input__wrapper","-esm-patient-chart__datepicker-module__startInput___cWw-5",bO),slot:"start",children:e=>(0,sl.jsx)(bz,{className:bN,segment:e})}),(0,sl.jsx)("div",{className:"-esm-patient-chart__datepicker-module__separator___Ddb4g",children:(0,sl.jsx)("span",{"aria-hidden":"true","data-readonly":!0,children:"–"})}),(0,sl.jsx)(g6,{className:ue()("cds--date-picker-input__wrapper","-esm-patient-chart__datepicker-module__endInput___xdYOl",bO),slot:"end",children:e=>(0,sl.jsx)(bz,{className:bN,segment:e})})]}),(0,sl.jsx)(m6,{className:ue()(bA,{[bj]:"sm"===p,[bM]:"md"===p||!p||0===p.length,[bL]:"lg"===p}),children:(0,sl.jsx)(bU,{})})]}),(0,sl.jsx)(ys,{className:bI,children:n}),(0,sl.jsx)(bB,{variant:"range",today_:b,minDate:S,maxDate:_})]})})})})})}),bY=si().createContext(null);function bq(e){let{children:t}=e,r=(0,so.useContext)(bY),[n,a]=(0,so.useState)(0),o=(0,so.useMemo)(()=>({parent:r,modalCount:n,addModal(){a(e=>e+1),r&&r.addModal()},removeModal(){a(e=>e-1),r&&r.removeModal()}}),[r,n]);return si().createElement(bY.Provider,{value:o},t)}function bJ(e){let t,{modalProviderProps:r}={modalProviderProps:{"aria-hidden":!!(t=(0,so.useContext)(bY))&&t.modalCount>0||void 0}};return si().createElement("div",{"data-overlay-container":!0,...e,...r})}function bX(e){return si().createElement(bq,null,si().createElement(bJ,e))}function bQ(e){let t=da(),{portalContainer:r=t?null:document.body,...n}=e,{getContainer:a}=ye();if(!e.portalContainer&&a&&(r=a()),si().useEffect(()=>{if(r?.closest("[data-overlay-container]"))throw Error("An OverlayContainer must not be inside another container. Please change the portalContainer prop.")},[r]),!r)return null;let o=si().createElement(bX,n);return mM().createPortal(o,r)}let b0=si().createContext(null),b1=si().forwardRef(function(e,t){let{children:r,...n}=e,a=c1(t),o={...n,ref:a};return si().createElement(b0.Provider,{value:o},r)}),b4={},b2=0,b3=!1,b6=null,b5=null;function b9(e={}){let{delay:t=1500,closeDelay:r=500}=e,{isOpen:n,open:a,close:o}=vr(e),i=(0,so.useMemo)(()=>`${++b2}`,[]),s=(0,so.useRef)(null),l=(0,so.useRef)(o),u=()=>{b4[i]=m},c=()=>{for(let e in b4)e!==i&&(b4[e](!0),delete b4[e])},d=()=>{s.current&&clearTimeout(s.current),s.current=null,c(),u(),b3=!0,a(),b6&&(clearTimeout(b6),b6=null),b5&&(clearTimeout(b5),b5=null)},m=e=>{e||r<=0?(s.current&&clearTimeout(s.current),s.current=null,l.current()):s.current||(s.current=setTimeout(()=>{s.current=null,l.current()},r)),b6&&(clearTimeout(b6),b6=null),b3&&(b5&&clearTimeout(b5),b5=setTimeout(()=>{delete b4[i],b5=null,b3=!1},Math.max(500,r)))};return(0,so.useEffect)(()=>{l.current=o},[o]),(0,so.useEffect)(()=>()=>{s.current&&clearTimeout(s.current),b4[i]&&delete b4[i]},[i]),{isOpen:n,open:e=>{e||!(t>0)||s.current?d():(c(),u(),n||b3?n||d():(b6&&clearTimeout(b6),b6=setTimeout(()=>{b6=null,b3=!0,d()},t)))},close:m}}let b8=(0,so.createContext)(null),b7=(0,so.createContext)(null);function we(e){let t=b9(e),r=(0,so.useRef)(null),{triggerProps:n,tooltipProps:a}=function(e,t,r){let{isDisabled:n,trigger:a,shouldCloseOnPress:o=!0}=e,i=dl(),s=(0,so.useRef)(!1),l=(0,so.useRef)(!1),u=()=>{(s.current||l.current)&&t.open(l.current)},c=e=>{s.current||l.current||t.close(e)};(0,so.useEffect)(()=>{let e=e=>{r&&r.current&&"Escape"===e.key&&(e.stopPropagation(),t.close(!0))};if(t.isOpen)return document.addEventListener("keydown",e,!0),()=>{document.removeEventListener("keydown",e,!0)}},[r,t]);let d=()=>{o&&(l.current=!1,s.current=!1,c(!0))},{hoverProps:m}=m0({isDisabled:n,onHoverStart:()=>{"focus"!==a&&("pointer"===d8?s.current=!0:s.current=!1,u())},onHoverEnd:()=>{"focus"!==a&&(l.current=!1,s.current=!1,c())}}),{focusableProps:p}=mD({isDisabled:n,onFocus:()=>{mm()&&(l.current=!0,u())},onBlur:()=>{l.current=!1,s.current=!1,c(!0)}},r);return{triggerProps:{"aria-describedby":t.isOpen?i:void 0,...dd(p,m,{onPointerDown:d,onKeyDown:d}),tabIndex:void 0},tooltipProps:{id:i}}}(e,t,r);return si().createElement(dp,{values:[[b8,t],[b7,{...a,triggerRef:r}]]},si().createElement(b1,{...n,ref:r},e.children))}let wt=(0,so.forwardRef)(function({UNSTABLE_portalContainer:e,...t},r){[t,r]=dg(t,r,b7);let n=(0,so.useContext)(b8),a=b9(t),o=null==t.isOpen&&null==t.defaultOpen&&n?n:a,i=yJ(r,o.isOpen)||t.isExiting||!1;return o.isOpen||i?si().createElement(bQ,{portalContainer:e},si().createElement(wr,{...t,tooltipRef:r,isExiting:i})):null});function wr(e){let t=(0,so.useContext)(b8),r=(0,so.useRef)(null),[n,a]=(0,so.useState)(0);c6(()=>{r.current&&t.isOpen&&a(r.current.getBoundingClientRect().width)},[t.isOpen,r]);let{overlayProps:o,arrowProps:i,placement:s}=yj({placement:e.placement||"top",targetRef:e.triggerRef,overlayRef:e.tooltipRef,offset:e.offset,crossOffset:e.crossOffset,isOpen:t.isOpen,arrowSize:n,arrowBoundaryOffset:e.arrowBoundaryOffset,shouldFlip:e.shouldFlip,onClose:()=>t.close(!0)}),l=yq(e.tooltipRef,!!s)||e.isEntering||!1,u=df({...e,defaultClassName:"react-aria-Tooltip",values:{placement:s,isEntering:l,isExiting:e.isExiting,state:t}}),{tooltipProps:c}=function(e,t){let r=dR(e,{labelable:!0}),{hoverProps:n}=m0({onHoverStart:()=>t?.open(!0),onHoverEnd:()=>t?.close()});return{tooltipProps:dd(r,n,{role:"tooltip"})}}(e=dd(e,o),t);return si().createElement("div",{...c,ref:e.tooltipRef,...u,style:{...o.style,...u.style},"data-placement":null!=s?s:void 0,"data-entering":l||void 0,"data-exiting":e.isExiting||void 0},si().createElement(ym.Provider,{value:{...i,placement:s,ref:r}},u.children))}let wn=({diagnoses:e,showCertainty:t=!1})=>{let{diagnosisTags:r}=s5({externalModuleName:"@openmrs/esm-styleguide"});return(0,sl.jsx)("div",{className:"-esm-patient-chart__diagnosis-tags-module__container___1iigI",children:e.map(e=>{let n=t&&"PROVISIONAL"===e.certainty,a=1===e.rank?r?.primaryColor??"blue":r?.secondaryColor??"gray";return(0,sl.jsx)(wa,{color:a,isProvisional:n,name:e.display},e.uuid)})})};function wa({color:e,isProvisional:t,name:r}){let[n,a]=(0,so.useState)(!1),[o,i]=(0,so.useState)(!1),[s,l]=(0,so.useState)(!1),u=s||o,c=(0,so.useRef)(null);(0,so.useLayoutEffect)(()=>{let e=c.current;if(!e)return;let t=()=>{let t=e.scrollWidth>e.clientWidth;l(t),t||a(!1)};t();let r=new ResizeObserver(t);return r.observe(e),()=>r.disconnect()},[r,t,u]);let d=ue()("cds--tag","cds--tag--md","cds--layout--size-md",`cds--tag--${e}`,"-esm-patient-chart__diagnosis-tags-module__diagnosisTag___mQ28X"),m=(0,sl.jsxs)(sl.Fragment,{children:[t&&(0,sl.jsxs)(sl.Fragment,{children:[(0,sl.jsx)("span",{"aria-hidden":"true",className:"-esm-patient-chart__diagnosis-tags-module__provisionalMark___S+J53",children:"?"}),(0,sl.jsxs)("span",{className:"cds--visually-hidden",children:[nB("provisional","Provisional")," "]})]}),(0,sl.jsx)("span",{ref:c,className:"cds--tag__label",children:r})]});return u?(0,sl.jsxs)(we,{delay:0,closeDelay:150,isOpen:n,onOpenChange:a,children:[(0,sl.jsx)(m6,{className:d,"data-testid":"diagnosis-tag",onFocusChange:i,onPress:()=>a(!0),children:m}),(0,sl.jsx)(wt,{className:"-esm-patient-chart__diagnosis-tags-module__tagTooltip___50O3+",placement:"bottom",offset:4,containerPadding:8,children:r})]}):(0,sl.jsx)("span",{className:d,"data-testid":"diagnosis-tag",children:m})}let wo={action:"-esm-patient-chart__empty-card-module__action___oG778",content:"-esm-patient-chart__empty-card-module__content___YUXvR",desktopHeading:"-esm-patient-chart__empty-card-module__desktopHeading___EljiH",tabletHeading:"-esm-patient-chart__empty-card-module__tabletHeading___8mc7w",tile:"-esm-patient-chart__empty-card-module__tile___3-rRO"},wi=({width:e="64",height:t="64"})=>(0,sl.jsx)("svg",{width:e,height:t,viewBox:"0 0 64 64",children:(0,sl.jsx)("use",{href:"#omrs-empty-data-illustration"})}),ws=e=>{let t="tablet"===lD(),r=e.launchForm;return(0,sl.jsx)(uo.Layer,{className:wo.layer,children:(0,sl.jsxs)(uo.Tile,{className:wo.tile,children:[(0,sl.jsx)("div",{className:t?wo.tabletHeading:wo.desktopHeading,children:(0,sl.jsx)("h4",{children:e.headerTitle})}),(0,sl.jsx)(wi,{}),(0,sl.jsx)("p",{className:wo.content,children:nB("emptyStateText","There are no {{displayText}} to display",{displayText:e.displayText})}),(0,sl.jsx)("p",{className:wo.action,children:r&&(0,sl.jsx)(uo.Button,{onClick:()=>r(),kind:"ghost",size:t?"lg":"sm",children:nB("recordNewEntry","Record {{ displayText }}",{displayText:e.displayText})})})]})})},wl=({error:e,headerTitle:t})=>{let r="tablet"===lD();return(0,sl.jsx)(uo.Layer,{children:(0,sl.jsxs)(uo.Tile,{className:"-esm-patient-chart__error-state-module__tile___mzWLn",children:[(0,sl.jsx)("div",{className:r?"-esm-patient-chart__error-state-module__tabletHeading___l7Cpn":"-esm-patient-chart__error-state-module__desktopHeading___p57fl",children:(0,sl.jsx)("h4",{children:t})}),(0,sl.jsxs)("p",{className:"-esm-patient-chart__error-state-module__errorMessage___0fU6v",children:[nB("error","Error")," ",`${e?.response?.status}: `,e?.response?.statusText]}),(0,sl.jsx)("p",{className:"-esm-patient-chart__error-state-module__errorCopy___xkVog",children:nB("errorCopy")})]})})},wu=wl,wc=si().forwardRef((e,t)=>{let{slotName:r,basePath:n,componentContext:a,state:o}=lC(),i=window.location??{pathname:""},s=sx(r??"");return e.isChildOfHeader&&r&&s.length>0?(0,sl.jsxs)(uo.SideNav,{"aria-label":nB("leftNavigation","Left navigation"),className:"-esm-patient-chart__left-nav-module__leftNav___czP9T",expanded:!0,isFixedNav:!0,ref:t,...e,children:[(0,sl.jsx)(sS,{name:"global-nav-menu-slot"}),r?(0,sl.jsx)(sY,{value:a,fallback:(0,sl.jsx)(sS,{name:r,state:{basePath:n,currentPath:i,...o}}),children:(0,sl.jsx)(ss.Provider,{value:a,children:(0,sl.jsx)(sS,{name:r,state:{basePath:n,currentPath:i,...o}})})}):null]}):null}),wd=({selectedLocationUuid:e,defaultLocationUuid:t,locationTag:r,locationsPerRequest:n=50,onChange:a})=>{let[o,i]=(0,so.useState)(""),s=(0,so.useId)(),{location:l}=function(e){let t=e?`/ws/fhir2/R4/Location?_id=${e}`:null,{data:r,error:n,isLoading:a}=le()(t,n2,{shouldRetryOnError:e=>!!e?.response?.status&&e.response.status>=500});return(0,so.useMemo)(()=>({location:r?.data?.entry?r.data.entry[0]:null,error:t?n:null,isLoading:!!t&&a}),[r,a,n,t])}(t),{locations:u,isLoading:c,hasMore:d,loadingNewData:m,error:p,setPage:f}=function(e,t=0,r=""){let n=s8(r),{data:a,isLoading:o,isValidating:i,setSize:s,error:l}=lh()(function(r,a){if(a){let e=a.data?.link?.find(e=>"next"===e.relation);if(!e)return null;let t=new URL(e.url);return t.origin===window.location.origin?e.url:new URL(`${t.pathname}${t.search?`?${t.search}`:""}`,window.location.origin).toString()}let o=`${n0}/Location?`,i=new URLSearchParams;return i.append("_summary","data"),t&&i.append("_count",""+t),r&&i.append("_getpagesoffset",""+r*t),e&&i.append("_tag",e),"string"==typeof n&&""!==n&&i.append("name:contains",n),o+i.toString()},n2);return(0,so.useMemo)(()=>({locations:a?.length?a?.flatMap(e=>e?.data?.entry??[]):[],isLoading:o,totalResults:a?.[0]?.data?.total,hasMore:!!a?.length&&a?.[a.length-1]?.data?.link?.some(e=>"next"===e.relation),loadingNewData:i,error:l||null,setPage:s}),[o,a,i,s,l])}(r,n,o),h=(0,so.useMemo)(()=>l&&!o&&t?[l,...u.filter(({resource:e})=>e.id!==t)]:u??[],[l,u,t,o]),g=(0,so.useCallback)(e=>{a(),i(e.trim())},[a]),y=lT((0,so.useCallback)(()=>{!m&&d&&f(e=>e+1)},[m,d,f])),v=d?Math.max(0,Math.floor(h.length-n/2)):-1;return(0,sl.jsxs)(sl.Fragment,{children:[(0,sl.jsx)(uo.Search,{"aria-describedby":p?`${s}-error`:void 0,labelText:nB("searchForLocation"),id:s,placeholder:nB("searchForLocation"),onChange:e=>g(e.target.value),size:"lg"}),p&&(0,sl.jsx)("div",{className:"-esm-patient-chart__location-picker-module__errorNotification___NfvTe",id:`${s}-error`,children:(0,sl.jsx)(uo.InlineNotification,{kind:"error",subtitle:nB("errorLoadingLoginLocations","Unable to load login locations. Please try again or contact support if the problem persists."),title:nB("error","Error")})}),(0,sl.jsx)("div",{className:"-esm-patient-chart__location-picker-module__searchResults___agplm",children:c?(0,sl.jsx)("div",{className:"-esm-patient-chart__location-picker-module__loadingContainer___EHghS",children:Array.from({length:5}).map((e,t)=>(0,sl.jsx)(uo.RadioButtonSkeleton,{className:"-esm-patient-chart__location-picker-module__radioButtonSkeleton___up5rH",role:"progressbar"},t))}):(0,sl.jsxs)(sl.Fragment,{children:[(0,sl.jsx)("div",{className:"-esm-patient-chart__location-picker-module__locationResultsContainer___06YOS",children:h.length>0?(0,sl.jsx)(uo.RadioButtonGroup,{name:"loginLocations",onChange:e=>{a(e?.toString())},orientation:"vertical",valueSelected:e,children:h.map((e,t)=>(0,sl.jsx)(uo.RadioButton,{className:"-esm-patient-chart__location-picker-module__locationRadioButton___yKif7",id:e.resource.id,labelText:(0,sl.jsx)("span",{ref:t===v?y:null,children:e.resource.name}),name:e.resource.name,value:e.resource.id},e.resource.id))}):(0,sl.jsx)("div",{className:"-esm-patient-chart__location-picker-module__emptyState___cPWp8",children:(0,sl.jsx)("p",{className:"-esm-patient-chart__location-picker-module__locationNotFound___b14++",children:nB("noResultsToDisplay")})})}),m&&(0,sl.jsx)("div",{className:"-esm-patient-chart__location-picker-module__loadingIcon___GVlrq",children:(0,sl.jsx)(uo.InlineLoading,{description:nB("loading")})})]})})]})},wm=B("modalState",{modalContainer:null,modalStack:[]}),wp=0;async function wf(e,t,r={}){let n=iQ(t),a=null;if(e){if(!n)throw Error(`No modal named '${t}' has been registered.`);let{load:o}=n,i=await o(),s=wp++;a=await st({...i,name:`${t}-${s}`},{...r,domElement:e})}else k(`Failed to launch modal. Please notify your administrator. Modal name: ${t}`);return a}function wh(e){return"TO_BE_DELETED"===e.state||"DELETED"===e.state}function wg(e,t){t?.unmount&&(t.unmountPromise?.catch(()=>{}),t.unmount().catch(t=>{console.error(`The modal '${e}' failed to unmount`,t)}))}function wy(e){return e.find(e=>!wh(e))}function wv(e,t){e.container&&(e.container.style.visibility=t?"unset":"hidden")}let wb=window.getComputedStyle(document.body).overflow;function ww({modalStack:e,modalContainer:t}){if(t)if(e.length){t.style.visibility||(addEventListener("keydown",wE),document.body.style.overflow="hidden",t.style.visibility="unset");let r=wy(e);e.forEach(e=>{switch(e.state){case"NEW":{let r=function({size:e}){let t=document.createElement("div");return t.className=`cds--modal-container cds--modal-container--${e}`,t.setAttribute("role","dialog"),t.setAttribute("tabindex","-1"),t.setAttribute("aria-modal","true"),t}({size:e.props?.size??"md"});e.container=r,e.state="MOUNTING",wf(r,e.modalName,e.props).then(n=>{wh(e)?wg(e.modalName,n):n?(e.parcel=n,t.prepend(r),wv(e,wy(wm.getState().modalStack)===e),n.mountPromise.then(()=>{wh(e)||(e.state="MOUNTED")},t=>{k(t),e.parcel=null,wx(e)})):wx(e)},t=>{k(t),wx(e)});break}case"MOUNTING":case"MOUNTED":wv(e,e===r);break;case"TO_BE_DELETED":e.state="DELETED",e.onClose(),wg(e.modalName,e.parcel),e.container?.remove(),setTimeout(()=>{let t=wm.getState();wm.setState({...t,modalStack:t.modalStack.filter(t=>t!==e)})},0)}})}else t.style.removeProperty("visibility"),document.body.style.overflow=wb,removeEventListener("keydown",wE)}function wx(e){if(wh(e))return;e.state="TO_BE_DELETED";let t=wm.getState();wm.setState({...t,modalStack:[...t.modalStack]})}function wE(e){"Escape"===e.key&&function(){let[e]=wm.getState().modalStack;e&&wx(e)}()}function wD(e){wm.subscribe(ww),wm.setState({...wm.getState(),modalContainer:e})}function wS(e,t={},r=()=>{}){let n=()=>{let e=wm.getState().modalStack.find(e=>e.onClose===r);e&&wx(e)};if(iQ(e)){var a;let o,i;a={state:"NEW",onClose:r,modalName:e,props:{close:n,...t}},i=[a,...(o=wm.getState()).modalStack],wm.setState({...o,modalStack:i})}else k(`Failed to launch modal. Please notify your administrator. Modal name: "${e}"`);return n}var w_=r(5992);let wC=({notification:e})=>{let{description:t,action:r,kind:n,critical:a,title:o,onAction:i}=e;return(0,sl.jsx)(uo.ActionableNotification,{actionButtonLabel:r,kind:n||"info",lowContrast:a,subtitle:t,title:o||"",inline:!0,onActionButtonClick:i})},wk=({subject:e})=>{let[t,r]=(0,so.useState)([]);return(0,so.useEffect)(()=>{let t=e.subscribe(e=>r(t=>[...t.filter(t=>t.description!==e.description||t.action!==e.action||t.kind!==e.kind||t.title!==e.title),e]));return()=>t.unsubscribe()},[e]),(0,sl.jsx)(sl.Fragment,{children:t.map(e=>(0,sl.jsx)(wC,{notification:e},e.id))})},wP=({notification:e})=>{let{actionButtonLabel:t,onActionButtonClick:r=()=>{},subtitle:n,kind:a,title:o,critical:i,progressActionLabel:s,id:l,...u}=e,[c,d]=(0,so.useState)(t);return(0,sl.jsx)(uo.ActionableNotification,{kind:a||"info",actionButtonLabel:c,"aria-label":nB("closesActionableNotification","Closes actionable notification"),onActionButtonClick:()=>{r(),s&&d(s)},statusIconDescription:nB("actionableNotification","Actionable notification"),subtitle:n,title:o,lowContrast:i,inline:!0,...u})},wR=({subject:e})=>{let[t,r]=(0,so.useState)([]);return(0,so.useEffect)(()=>{let t=e.subscribe(e=>r(t=>[...t.filter(t=>t.subtitle!==e.subtitle||t.actionButtonLabel!==e.actionButtonLabel||t.onActionButtonClick!==e.onActionButtonClick||t.kind!==e.kind||t.title!==e.title),e]));return()=>t.unsubscribe()},[e]),(0,sl.jsx)(sl.Fragment,{children:t.map(e=>(0,sl.jsx)(wP,{notification:e},e.id))})};class wT{subscribe(e){return this.listeners.add(e),{unsubscribe:()=>{this.listeners.delete(e)}}}next(e){for(let t of[...this.listeners])t(e)}constructor(){!function(e,t,r){t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r}(this,"listeners",new Set)}}let w$=new wT,wN=0,wO=new wT,wI=0;function wA(e){e&&(0,s_.createRoot)(e).render((0,sl.jsx)(wk,{subject:w$}))}function wM(e){var t;e&&("string"==typeof(t=e.description)?t.trim().length>0:"object"==typeof t&&(t instanceof Error||!(0,w_.A)(t)))?(e.description instanceof Error&&(e.description=e.description.toLocaleString()),setTimeout(()=>{w$.next({...e,id:wN++})},0)):console.error("showNotification must be called with an object having a 'description' property that is a non-empty string or object")}function wj(e){e&&(0,s_.createRoot)(e).render((0,sl.jsx)(wR,{subject:wO}))}function wL(e){var t;e&&("string"==typeof(t=e.actionButtonLabel)?t.trim().length>0:"object"==typeof t&&!(0,w_.A)(t))?setTimeout(()=>{wO.next({...e,id:wI++})},0):console.error("showActionableNotification must be called with an actionButtonLabel that is a non-empty string")}let wF=["NORMAL","HIGH","CRITICALLY_HIGH","OFF_SCALE_HIGH","LOW","CRITICALLY_LOW","OFF_SCALE_LOW"],wB=["critically_low","critically_high","high","low","normal","off_scale_low","off_scale_high"],wV={container:"-esm-patient-chart__numeric-observation-module__container___gS0Wg",card:"-esm-patient-chart__numeric-observation-module__card___w0fF5","abnormal-value":"-esm-patient-chart__numeric-observation-module__abnormal-value___xuX3W","critical-value":"-esm-patient-chart__numeric-observation-module__critical-value___Jynsn",cell:"-esm-patient-chart__numeric-observation-module__cell___tMhBJ","critically-high":"-esm-patient-chart__numeric-observation-module__critically-high___3L2wx","critically-low":"-esm-patient-chart__numeric-observation-module__critically-low___XP+HX",high:"-esm-patient-chart__numeric-observation-module__high___JV9do",low:"-esm-patient-chart__numeric-observation-module__low___-uDKD","label-container":"-esm-patient-chart__numeric-observation-module__label-container___vTf2y","value-container":"-esm-patient-chart__numeric-observation-module__value-container___xTUIC",label:"-esm-patient-chart__numeric-observation-module__label___-pfmb",value:"-esm-patient-chart__numeric-observation-module__value___1A4zt",units:"-esm-patient-chart__numeric-observation-module__units___SzvX+","pad-right":"-esm-patient-chart__numeric-observation-module__pad-right___ND9XL","off-scale-low":"-esm-patient-chart__numeric-observation-module__off-scale-low___gFAv9","off-scale-high":"-esm-patient-chart__numeric-observation-module__off-scale-high___aSEmX",arrow:"-esm-patient-chart__numeric-observation-module__arrow___9bvsX"},wU=({value:e,unit:t,label:r,interpretation:n,referenceRange:a,conceptUuid:o,variant:i="card",patientUuid:s})=>{let l=(0,so.useId)(),{referenceRange:u,isLoading:c}=function(e,t){let r=null;e&&(r=t?`${nQ}/conceptreferencerange/?patient=${t}&concept=${e}&v=full`:`${nQ}/conceptreferencerange/?concept=${e}&v=full`);let{data:n,error:a,isLoading:o}=le()(r,n2),i=n?.data?.results?.[0];return{referenceRange:i?{hiNormal:i.hiNormal??null,hiAbsolute:i.hiAbsolute??null,hiCritical:i.hiCritical??null,lowNormal:i.lowNormal??null,lowAbsolute:i.lowAbsolute??null,lowCritical:i.lowCritical??null}:void 0,error:a,isLoading:o}}(a||n?void 0:o,s),d=a??u,m=(0,so.useMemo)(()=>{if(n)return n?"--"===n?"normal":wF.includes(n)?n.toLowerCase():wB.includes(n)?n:"normal":void 0;if(d&&!c){if(!d||null==e||""===e)return"normal";let t="string"==typeof e?Number.parseFloat(e):e;return Number.isNaN(t)?"normal":null!==d.hiAbsolute&&void 0!==d.hiAbsolute&&t>d.hiAbsolute?"off_scale_high":null!==d.hiCritical&&void 0!==d.hiCritical&&t>=d.hiCritical?"critically_high":null!==d.hiNormal&&void 0!==d.hiNormal&&t>d.hiNormal?"high":null!==d.lowAbsolute&&void 0!==d.lowAbsolute&&t<d.lowAbsolute?"off_scale_low":null!==d.lowCritical&&void 0!==d.lowCritical&&t<=d.lowCritical?"critically_low":null!==d.lowNormal&&void 0!==d.lowNormal&&t<d.lowNormal?"low":"normal"}return"normal"},[n,d,e,c])??"normal",p="critically_low"===m||"critically_high"===m||"off_scale_low"===m||"off_scale_high"===m,f="normal"!==m,h=r?`omrs-numeric-obs-label-${r.replaceAll(/\s+/g,"-").toLowerCase()}-${l}`:void 0,g=`omrs-numeric-obs-value-${l}`,y=`omrs-numeric-obs-unit-${l}`,v=null!=e&&""!==e,b=v?e:nB("notAvailable","Not available"),w=ue()({[wV["critically-low"]]:"critically_low"===m||"off_scale_low"===m,[wV["critically-high"]]:"critically_high"===m||"off_scale_high"===m,[wV.low]:"low"===m,[wV.high]:"high"===m,[wV["off-scale-low"]]:"off_scale_low"===m,[wV["off-scale-high"]]:"off_scale_high"===m}),x=ue()({[wV.container]:!0,[wV.card]:!0,[wV["critical-value"]]:p,[wV["abnormal-value"]]:f&&!p}),E=ue()({[wV.cell]:!0,[w]:!0});return"cell"===i?(0,sl.jsxs)("div",{className:E,children:[b,v&&t?` ${t}`:""]}):(0,sl.jsxs)("section",{className:x,"data-testid":"numeric-observation-card",children:[r&&(0,sl.jsxs)("div",{className:wV["label-container"],children:[(0,sl.jsx)("span",{id:h,className:wV.label,children:r}),f&&(0,sl.jsx)("span",{className:wV[m.replace("_","-")],title:nB("abnormalValue","Abnormal value")})]}),(0,sl.jsxs)("div",{className:wV["value-container"],children:[(0,sl.jsx)("span",{id:g,"aria-labelledby":h&&y?`${h} ${y}`:h||y||void 0,className:wV.value,children:b}),v&&t&&(0,sl.jsx)("span",{id:y,className:wV.units,children:t})]})]})},wW="-esm-patient-chart__page-header-module__pageHeader___6TOjO",wH=e=>{if("children"in e){let{children:t,className:r,...n}=e;return(0,sl.jsx)("div",{className:ue()(wW,r),...n,children:t})}{let{title:t,illustration:r,className:n,...a}=e;return(0,sl.jsx)("div",{className:ue()(wW,n),...a,children:(0,sl.jsx)(wz,{title:t,illustration:r})})}},wz=({title:e,illustration:t,className:r})=>{let[n,a]=(0,so.useState)(null);return(0,so.useEffect)(()=>{rD("@openmrs/esm-styleguide").then(e=>{a(e)})},[]),(0,sl.jsxs)("div",{className:ue()("-esm-patient-chart__page-header-module__pageHeaderContent___mCImT",r),children:[t,(0,sl.jsxs)("div",{className:"-esm-patient-chart__page-header-module__pageLabels___kqDS+",children:[n?.implementationName&&(0,sl.jsx)("p",{children:nB(n.implementationName)}),(0,sl.jsx)("h1",{className:"-esm-patient-chart__page-header-module__pageName___SbZBC",children:e})]})]})},wK=({totalItems:e,pageSize:t,onPageNumberChange:r,pageNumber:n,dashboardLinkUrl:a,currentItems:o,dashboardLinkLabel:i})=>{let{pageSizes:s,pageItemsCount:l}=lO(t,e,n,o),u="tablet"===lD(),c=nB("paginationItemsCount","{{pageItemsCount}} / {{totalItems}} items",{totalItems:e,pageItemsCount:l});return(0,sl.jsx)(sl.Fragment,{children:e>0&&(0,sl.jsxs)("div",{className:ue()({"-esm-patient-chart__pagination-module__tablet___82gj1":u,"-esm-patient-chart__pagination-module__desktop___6yI8e":!u}),children:[(0,sl.jsxs)("div",{children:[c,a&&(0,sl.jsx)(su,{to:a,className:"-esm-patient-chart__pagination-module__configurableLink___oIqma",children:i??nB("seeAll","See all")})]}),(0,sl.jsx)(uo.Pagination,{className:"-esm-patient-chart__pagination-module__pagination___A-Lcg",page:n,pageSize:t,pageSizes:s,totalItems:e,onChange:r,pageRangeText:(e,t)=>nB("paginationOfPages","of {{count}} pages",{count:t}),size:u?"lg":"sm"})]})})};function wG(e){return wY(wJ(e,"usual","official"))}function wZ(e){return wG(e)}function wY(e){var t;let r;return e?e.text??(r=(t=e).given??[],(t.family?r.concat(t.family):r).join(" ")):""}function wq(e){return wY(e)}function wJ(e,...t){for(let r of(0==t.length&&(t=["usual"]),t)){let t=e.name?.find(e=>{var t,n;return t=e,n=r,t.use?t.use===n:"usual"===n});if(t)return t}}function wX(e,t=lU()()){let r=lU()(t),n=bs(e,r);if(null==n)return null;let a=r.diff(n,"hours"),o=r.diff(n,"days"),i=r.diff(n,"weeks"),s=r.diff(n,"months"),l=r.diff(n,"years"),u={};if(a<2)u.minutes=r.diff(n,"minutes");else if(o<2)u.hours=a;else if(i<4)u.days=o;else if(l<1){let e=r.subtract(i,"weeks").diff(n,"days");u.weeks=i,u.days=e}else if(l<2){let e=r.subtract(s,"months").diff(n,"days");u.months=s,u.days=e}else if(l<18){let e=r.subtract(l,"year").diff(n,"months");u.years=l,u.months=e}else u.years=l;return u}function wQ(e,t=lU()()){let r=wX(e,t);if(null==r)return null;let n={style:"short",localeMatcher:"lookup"};return"minutes"in r&&0===r.minutes&&(n.minutesDisplay="always"),bi(r,n)}let w0={container:"-esm-patient-chart__patient-banner-patient-info-module__container___iC32K",activePatientContainer:"-esm-patient-chart__patient-banner-patient-info-module__activePatientContainer___OoDPd",patientBanner:"-esm-patient-chart__patient-banner-patient-info-module__patientBanner___swajU",patientName:"-esm-patient-chart__patient-banner-patient-info-module__patientName___+2+Xi",patientAvatar:"-esm-patient-chart__patient-banner-patient-info-module__patientAvatar___Rdf75",patientAvatarButton:"-esm-patient-chart__patient-banner-patient-info-module__patientAvatarButton___A1q8c",patientInfo:"-esm-patient-chart__patient-banner-patient-info-module__patientInfo___L-cOQ",demographics:"-esm-patient-chart__patient-banner-patient-info-module__demographics___IDhb0",row:"-esm-patient-chart__patient-banner-patient-info-module__row___TP7gU",flexRow:"-esm-patient-chart__patient-banner-patient-info-module__flexRow___vNMt2",tagsSlot:"-esm-patient-chart__patient-banner-patient-info-module__tagsSlot___0Dvjn",identifiers:"-esm-patient-chart__patient-banner-patient-info-module__identifiers___d3GTJ",identifier:"-esm-patient-chart__patient-banner-patient-info-module__identifier___kc6eq",primaryIdentifier:"-esm-patient-chart__patient-banner-patient-info-module__primaryIdentifier___ZxRUU",secondaryIdentifier:"-esm-patient-chart__patient-banner-patient-info-module__secondaryIdentifier___eQh8x",value:"-esm-patient-chart__patient-banner-patient-info-module__value___CoAOR",tag:"-esm-patient-chart__patient-banner-patient-info-module__tag___InccN",gender:"-esm-patient-chart__patient-banner-patient-info-module__gender___vfinx",separator:"-esm-patient-chart__patient-banner-patient-info-module__separator___3OIBl",tooltipPadding:"-esm-patient-chart__patient-banner-patient-info-module__tooltipPadding___hBqWG",tooltipSmallText:"-esm-patient-chart__patient-banner-patient-info-module__tooltipSmallText___bPnkq",actionsButtonText:"-esm-patient-chart__patient-banner-patient-info-module__actionsButtonText___VNvm7"};function w1({showIdentifierLabel:e,type:t,value:r}){return(0,sl.jsx)("span",{className:w0.primaryIdentifier,children:(0,sl.jsxs)(uo.Tag,{className:w0.tag,type:"gray",children:[e&&t?.text&&(0,sl.jsxs)("span",{className:w0.label,children:[t.text,": "]}),(0,sl.jsx)("span",{className:w0.value,children:r})]})})}function w4({showIdentifierLabel:e,type:t,value:r}){return(0,sl.jsxs)(uo.FormLabel,{className:w0.secondaryIdentifier,id:`patient-banner-identifier-${r}`,children:[e&&(0,sl.jsxs)("span",{className:w0.label,children:[t?.text,": "]}),(0,sl.jsx)("span",{className:w0.value,children:r})]})}function w2({identifiers:e,showIdentifierLabel:t}){let{excludePatientIdentifierCodeTypes:r}=s5(),{primaryIdentifierCode:n}=lM(),a=e?.filter(e=>{let t=e.type?.coding?.[0]?.code;return t&&!r?.uuids.includes(t)})??[];return(0,sl.jsx)(sl.Fragment,{children:a?.length?a.map(({value:e,type:r},o)=>(0,sl.jsxs)(si().Fragment,{children:[(0,sl.jsx)("span",{className:w0.identifier,children:r?.coding?.[0]?.code===n?(0,sl.jsx)(w1,{showIdentifierLabel:t,type:r,value:e}):(0,sl.jsx)(w4,{showIdentifierLabel:t,type:r,value:e})}),o<a.length-1&&(0,sl.jsx)("span",{className:w0.separator,children:"\xb7"})]},e)):""})}let w3={Female:uq,Male:uJ,Other:uX,Unknown:uQ},w6=({gender:e})=>{let t=w3[e];return t?(0,sl.jsx)(t,{fill:"#525252"}):null},w5={male:"Male",female:"Female",other:"Other",unknown:"Unknown"};function w9({patient:e,renderedFrom:t}){var r;let n,a,o=wG(e),i=e?.gender&&(a=w5[n=(r=e.gender).toLowerCase()]??"Unknown",{displayText:nB(n,r),iconKey:a}),s=(0,so.useMemo)(()=>({patientUuid:e.id,patient:e,renderedFrom:t}),[e.id,e,t]);return(0,sl.jsxs)("div",{className:w0.patientInfo,children:[(0,sl.jsx)("div",{className:ue()(w0.row,w0.patientNameRow),children:(0,sl.jsxs)("div",{className:w0.flexRow,children:[(0,sl.jsx)("span",{className:w0.patientName,children:o}),i&&(0,sl.jsxs)("div",{className:w0.gender,children:[(0,sl.jsx)(w6,{gender:i.iconKey}),(0,sl.jsx)("span",{children:i.displayText})]}),(0,sl.jsx)(sS,{className:w0.tagsSlot,name:"patient-banner-tags-slot",state:s})]})}),(0,sl.jsxs)("div",{className:w0.demographics,children:[e.birthDate&&(0,sl.jsxs)(sl.Fragment,{children:[(0,sl.jsx)("span",{children:wQ(e.birthDate)}),(0,sl.jsx)("span",{className:w0.separator,children:"\xb7"}),(0,sl.jsx)("span",{children:be(e.birthDate,{time:!1,noToday:!0})}),(0,sl.jsx)("span",{className:w0.separator,children:"\xb7"})]}),(0,sl.jsx)(w2,{identifiers:e.identifier,showIdentifierLabel:!0}),(0,sl.jsx)(sS,{className:w0.extensionSlot,name:"patient-banner-bottom-slot",state:s})]})]})}var w8=r(8282);function w7({patient:e,patientUuid:t,actionsSlotName:r,additionalActionsSlotState:n}){let[a,o]=(0,so.useState)(!1),{extensions:i}=sE(r),s="tablet"===lD(),l=lR(()=>o(!1),a),u=(0,so.useRef)(null),c=(0,so.useRef)(null),d=(0,so.useId)(),m=`patient-actions-menu-trigger-${d}`,p=`patient-actions-menu-${d}`,f=(0,so.useCallback)(()=>o(e=>!e),[]),h=(0,so.useCallback)(()=>{o(!1),u.current?.focus()},[]),g=(0,so.useCallback)(e=>{if("Escape"===e.key&&a){e.stopPropagation(),h();return}if(("ArrowDown"===e.key||"ArrowUp"===e.key)&&a){e.preventDefault();let t=c.current?.querySelectorAll('[role="menuitem"]:not([disabled])');if(!t?.length)return;let r=document.activeElement?.closest?.('[role="menuitem"]')??document.activeElement,n=Array.from(t).indexOf(r);if(-1===n)return void t["ArrowDown"===e.key?0:t.length-1]?.focus();let a=n+("ArrowDown"===e.key?1:-1),o=a<0?t.length-1:a>=t.length?0:a;t[o]?.focus()}},[h,a]);(0,so.useEffect)(()=>{if(a&&c.current){let e=c.current.querySelector('[role="menuitem"]:not([disabled])');e?.focus()}},[a]);let y=(0,so.useMemo)(()=>({patientUuid:t,patient:e,closeMenu:h,...n}),[t,e,h,n]);return 0===i.length?null:(0,sl.jsx)("div",{className:"-esm-patient-chart__patient-banner-actions-menu-module__overflowMenuContainer___FbFcO",children:(0,sl.jsxs)("div",{"data-overflow-menu":!0,className:ue()("cds--overflow-menu",ul),ref:l,children:[(0,sl.jsxs)("button",{className:ue()("cds--btn","cds--btn--ghost","cds--overflow-menu__trigger",{"cds--overflow-menu--open":a},ud),"aria-controls":p,"aria-expanded":a,"aria-haspopup":"true",id:m,onClick:f,onKeyDown:g,ref:u,children:[(0,sl.jsx)("span",{className:"-esm-patient-chart__patient-banner-actions-menu-module__actionsButtonText___hk4xW",children:nB("actions","Actions")})," ",(0,sl.jsx)(w8.CH,{size:16,style:{marginLeft:"0.5rem",fill:"#78A9FF"}})]}),(0,sl.jsxs)("div",{className:ue()("cds--overflow-menu-options","cds--overflow-menu--flip",uu,{[uc]:a}),"aria-labelledby":m,"data-floating-menu-direction":"bottom",id:p,onKeyDown:g,ref:c,role:"menu",tabIndex:-1,children:[(0,sl.jsx)("ul",{className:ue()("cds--overflow-menu-options__content",{"cds--overflow-menu-options--lg":s}),children:(0,sl.jsx)(sS,{name:r,state:y},r)}),(0,sl.jsx)("span",{})]})]})})}var xe=r(5570),xt=r.n(xe);function xr(e){let{patientPhotoConceptUuid:t}=s5({externalModuleName:"@openmrs/esm-styleguide"}),r=t?`${nQ}/obs?patient=${e}&concept=${t}&v=full`:null,{data:n,error:a,isLoading:o}=s$()(e?r:null,n2),i=n?.data?.results[0];return{data:i?{dateTime:i?.obsDatetime,imageSrc:i?.value?.links?.uri}:null,error:a,isLoading:o}}let xn=({width:e=56,height:t=56,"aria-label":r})=>{let{t:n}=(0,sR.useTranslation)();return(0,sl.jsxs)("svg",{"aria-label":r??n("patientPhotoPlaceholder","Patient photo placeholder"),width:e,height:t,fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,sl.jsx)("path",{fill:"#ffffff",d:"M0 0h56v56H0z"}),(0,sl.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m36.75 20.134-.884-.884L19.25 35.866l.884.884 1.25-1.25H34.25a1.252 1.252 0 0 0 1.25-1.25V21.384l1.25-1.25Zm-2.5 14.116H22.634l4.87-4.87 1.487 1.486a1.25 1.25 0 0 0 1.768 0l.991-.991 2.5 2.498v1.877Zm0-3.645-1.616-1.616a1.25 1.25 0 0 0-1.768 0l-.991.991-1.486-1.486 5.861-5.86v7.971Zm-12.5 1.145v-1.875l3.125-3.123.858.859.885-.885-.86-.86a1.25 1.25 0 0 0-1.767 0l-2.241 2.242V21.75h10V20.5h-10c-.69 0-1.25.56-1.25 1.25v10h1.25Z",fill:"#8D8D8D"})]})},xa="-esm-patient-chart__patient-photo-module__avatar___thboZ";function xo({patientUuid:e,patientName:t,alt:r}){let{data:n,isLoading:a}=xr(e),[o,i]=(0,so.useState)(null),[s,l]=(0,so.useState)(!1),u=(0,so.useMemo)(()=>xt().generate(e),[e]);(0,so.useEffect)(()=>{if(n?.imageSrc){let e=new URL(n.imageSrc,window.location.origin).pathname;l(!0);let t=!1,r=new Image;return r.onload=()=>{t||(i(e),l(!1))},r.onerror=()=>{t||(i(null),l(!1))},r.src=e,()=>{t=!0}}i(null),l(!1)},[n?.imageSrc]);let c=(0,so.useMemo)(()=>r||(o?nB("patientPhotoAlt","Profile photo of {{patientName}}",{patientName:t}):nB("patientAvatarAlt","Avatar for {{patientName}}",{patientName:t})),[r,o,t]);return a||s?(0,sl.jsx)(uo.SkeletonIcon,{className:"-esm-patient-chart__patient-photo-module__skeleton___WWtyX","data-testid":"skeleton-icon"}):n?.imageSrc&&!o?(0,sl.jsx)(xn,{"aria-label":nB("patientPhotoPlaceholder","Photo placeholder for {{patientName}}",{patientName:t})}):o?(0,sl.jsx)("div",{"aria-label":c,children:(0,sl.jsx)("img",{className:xa,src:o,alt:c,title:t})}):(0,sl.jsx)("div",{"aria-label":c,children:(0,sl.jsx)("div",{className:xa,title:t,style:{backgroundImage:u.toDataUrl(),backgroundRepeat:"no-repeat",backgroundSize:"cover"},children:(0,sl.jsx)("span",{className:"-esm-patient-chart__patient-photo-module__initials___xLeEF",children:function(e,t=3){return e.split(/\s+/).filter(Boolean).slice(0,t).map(e=>e[0]).join("")}(t)})})})}let xi=["omrs-pict-appointments","omrs-pict-assessment-1","omrs-pict-assessment-2","omrs-pict-blood-bank","omrs-pict-cardiology","omrs-pict-cohorts","omrs-pict-concept-dictionary","omrs-pict-ct-scan","omrs-pict-data-entry","omrs-pict-dentistry","omrs-pict-digital-trust","omrs-pict-emergency-department","omrs-pict-facility","omrs-pict-geriatrics","omrs-pict-gynaecology","omrs-pict-in-patient","omrs-pict-laboratory","omrs-pict-labs-2","omrs-pict-metadata-export","omrs-pict-obstetrics","omrs-pict-patient-documents","omrs-pict-patient-search","omrs-pict-patients","omrs-pict-payments-desk","omrs-pict-pharmacy","omrs-pict-pharmacy-2","omrs-pict-registration","omrs-pict-reports","omrs-pict-service-queues","omrs-pict-stock-management","omrs-pict-system-administration","omrs-pict-transfer","omrs-pict-triage","omrs-pict-x-ray"],xs=(0,so.memo)((0,so.forwardRef)(function(e,t){return(0,sl.jsx)(xz,{ref:t,pictogram:"omrs-pict-appointments",pictogramProps:e})})),xl=xs,xu=(0,so.memo)((0,so.forwardRef)(function(e,t){return(0,sl.jsx)(xz,{ref:t,pictogram:"omrs-pict-assessment-1",pictogramProps:e})})),xc=(0,so.memo)((0,so.forwardRef)(function(e,t){return(0,sl.jsx)(xz,{ref:t,pictogram:"omrs-pict-assessment-2",pictogramProps:e})})),xd=(0,so.memo)((0,so.forwardRef)(function(e,t){return(0,sl.jsx)(xz,{ref:t,pictogram:"omrs-pict-blood-bank",pictogramProps:e})})),xm=(0,so.memo)((0,so.forwardRef)(function(e,t){return(0,sl.jsx)(xz,{ref:t,pictogram:"omrs-pict-cardiology",pictogramProps:e})})),xp=(0,so.memo)((0,so.forwardRef)(function(e,t){return(0,sl.jsx)(xz,{ref:t,pictogram:"omrs-pict-cohorts",pictogramProps:e})})),xf=(0,so.memo)((0,so.forwardRef)(function(e,t){return(0,sl.jsx)(xz,{ref:t,pictogram:"omrs-pict-concept-dictionary",pictogramProps:e})})),xh=(0,so.memo)((0,so.forwardRef)(function(e,t){return(0,sl.jsx)(xz,{ref:t,pictogram:"omrs-pict-ct-scan",pictogramProps:e})})),xg=(0,so.memo)((0,so.forwardRef)(function(e,t){return(0,sl.jsx)(xz,{ref:t,pictogram:"omrs-pict-data-entry",pictogramProps:e})})),xy=(0,so.memo)((0,so.forwardRef)(function(e,t){return(0,sl.jsx)(xz,{ref:t,pictogram:"omrs-pict-dentistry",pictogramProps:e})})),xv=(0,so.memo)((0,so.forwardRef)(function(e,t){return(0,sl.jsx)(xz,{ref:t,pictogram:"omrs-pict-digital-trust",pictogramProps:e})})),xb=(0,so.memo)((0,so.forwardRef)(function(e,t){return(0,sl.jsx)(xz,{ref:t,pictogram:"omrs-pict-emergency-department",pictogramProps:e})})),xw=(0,so.memo)((0,so.forwardRef)(function(e,t){return(0,sl.jsx)(xz,{ref:t,pictogram:"omrs-pict-facility",pictogramProps:e})})),xx=(0,so.memo)((0,so.forwardRef)(function(e,t){return(0,sl.jsx)(xz,{ref:t,pictogram:"omrs-pict-geriatrics",pictogramProps:e})})),xE=(0,so.memo)((0,so.forwardRef)(function(e,t){return(0,sl.jsx)(xz,{ref:t,pictogram:"omrs-pict-gynaecology",pictogramProps:e})})),xD=(0,so.memo)((0,so.forwardRef)(function(e,t){return(0,sl.jsx)(xz,{ref:t,pictogram:"omrs-pict-in-patient",pictogramProps:e})})),xS=(0,so.memo)((0,so.forwardRef)(function(e,t){return(0,sl.jsx)(xz,{ref:t,pictogram:"omrs-pict-laboratory",pictogramProps:e})})),x_=(0,so.memo)((0,so.forwardRef)(function(e,t){return(0,sl.jsx)(xz,{ref:t,pictogram:"omrs-pict-labs-2",pictogramProps:e})})),xC=(0,so.memo)((0,so.forwardRef)(function(e,t){return(0,sl.jsx)(xz,{ref:t,pictogram:"omrs-pict-metadata-export",pictogramProps:e})})),xk=(0,so.memo)((0,so.forwardRef)(function(e,t){return(0,sl.jsx)(xz,{ref:t,pictogram:"omrs-pict-obstetrics",pictogramProps:e})})),xP=(0,so.memo)((0,so.forwardRef)(function(e,t){return(0,sl.jsx)(xz,{ref:t,pictogram:"omrs-pict-patient-documents",pictogramProps:e})})),xR=(0,so.memo)((0,so.forwardRef)(function(e,t){return(0,sl.jsx)(xz,{ref:t,pictogram:"omrs-pict-patient-search",pictogramProps:e})})),xT=(0,so.memo)((0,so.forwardRef)(function(e,t){return(0,sl.jsx)(xz,{ref:t,pictogram:"omrs-pict-patients",pictogramProps:e})})),x$=(0,so.memo)((0,so.forwardRef)(function(e,t){return(0,sl.jsx)(xz,{ref:t,pictogram:"omrs-pict-payments-desk",pictogramProps:e})})),xN=(0,so.memo)((0,so.forwardRef)(function(e,t){return(0,sl.jsx)(xz,{ref:t,pictogram:"omrs-pict-pharmacy",pictogramProps:e})})),xO=(0,so.memo)((0,so.forwardRef)(function(e,t){return(0,sl.jsx)(xz,{ref:t,pictogram:"omrs-pict-pharmacy-2",pictogramProps:e})})),xI=(0,so.memo)((0,so.forwardRef)(function(e,t){return(0,sl.jsx)(xz,{ref:t,pictogram:"omrs-pict-registration",pictogramProps:e})})),xA=(0,so.memo)((0,so.forwardRef)(function(e,t){return(0,sl.jsx)(xz,{ref:t,pictogram:"omrs-pict-reports",pictogramProps:e})})),xM=(0,so.memo)((0,so.forwardRef)(function(e,t){return(0,sl.jsx)(xz,{ref:t,pictogram:"omrs-pict-service-queues",pictogramProps:e})})),xj=(0,so.memo)((0,so.forwardRef)(function(e,t){return(0,sl.jsx)(xz,{ref:t,pictogram:"omrs-pict-stock-management",pictogramProps:e})})),xL=(0,so.memo)((0,so.forwardRef)(function(e,t){return(0,sl.jsx)(xz,{ref:t,pictogram:"omrs-pict-system-administration",pictogramProps:e})})),xF=(0,so.memo)((0,so.forwardRef)(function(e,t){return(0,sl.jsx)(xz,{ref:t,pictogram:"omrs-pict-transfer",pictogramProps:e})})),xB=(0,so.memo)((0,so.forwardRef)(function(e,t){return(0,sl.jsx)(xz,{ref:t,pictogram:"omrs-pict-triage",pictogramProps:e})})),xV=(0,so.memo)((0,so.forwardRef)(function(e,t){return(0,sl.jsx)(xz,{ref:t,pictogram:"omrs-pict-x-ray",pictogramProps:e})})),xU=xw,xW=xT,xH=(0,so.memo)((0,so.forwardRef)(function({pictogram:e,fallback:t,...r},n){let a=(0,so.useRef)(document.getElementById(e));return(0,so.useEffect)(()=>{let t=document.getElementById("omrs-svgs-container"),r=new MutationObserver(t=>{for(let r of t)"childList"===r.type&&(a.current=document.getElementById(e))});return t&&r.observe(t,{childList:!0}),()=>r.disconnect()},[e]),(0,sl.jsx)(sY,{value:a.current,fallback:t,children:(0,sl.jsx)(xz,{ref:n,pictogram:e,pictogramProps:r})})})),xz=(0,so.memo)((0,so.forwardRef)(function({pictogram:e,pictogramProps:t},r){let{className:n,size:a}=Object.assign({},{size:92},t);return(a<=26||a>144)&&(console.error(`Invalid size '${a}' specified for ${e}. Defaulting to 92.`),a=92),(0,sl.jsx)("svg",{ref:r,className:ue()("-esm-patient-chart__pictograms-module__pictogram___ooPKM",n),height:a,width:a,children:(0,sl.jsx)("use",{href:`#${e}`})})})),xK=({children:e})=>"tablet"===lD()?(0,sl.jsx)(uo.Layer,{children:e}):(0,sl.jsx)(sl.Fragment,{children:e}),xG=({snackbar:e,closeSnackbar:t})=>{let{actionButtonLabel:r="",kind:n="success",onActionButtonClick:a=()=>{},isLowContrast:o="error"!==n,progressActionLabel:i,subtitle:s="",timeoutInMs:l=5e3,autoClose:u="error"!==n,title:c,id:d,...m}=e,[p,f]=(0,so.useState)(r),[h,g]=(0,so.useState)(!0),[y,v]=(0,so.useState)(!1),b=(0,so.useCallback)(()=>{setTimeout(t,250)},[t]),w=(0,so.useCallback)(()=>{v(!0),b()},[b]);return(0,so.useEffect)(()=>{if(u){let e=setTimeout(w,l);return()=>clearTimeout(e)}},[l,u,w]),(0,so.useEffect)(()=>{g(!1),window.setTimeout(()=>{g(!0)},0)},[]),(0,sl.jsx)(uo.ActionableNotification,{actionButtonLabel:p,"aria-label":nB("closeSnackbar","Close snackbar"),className:ue()("-esm-patient-chart__snackbar-module__slideIn___senVE",{"-esm-patient-chart__snackbar-module__animated___8eltL":h,"-esm-patient-chart__snackbar-module__slideOut___BIIXm":y}),kind:n,lowContrast:o,onActionButtonClick:()=>{a(),w(),i&&f(i)},onClose:b,statusIconDescription:nB("snackbarNotification","Snackbar notification"),subtitle:s,title:c,...m})},xZ=({subject:e})=>{let[t,r]=(0,so.useState)([]),n=(0,so.useCallback)(e=>{r(t=>t.filter(t=>t!==e))},[]);return(0,so.useEffect)(()=>{let t=e.subscribe(e=>r(t=>[...t.filter(t=>t.subtitle!==e.subtitle||t.actionButtonLabel!==e.actionButtonLabel||t.onActionButtonClick!==e.onActionButtonClick||t.kind!==e.kind||t.title!==e.title),e]));return()=>t.unsubscribe()},[e]),(0,sl.jsx)(sl.Fragment,{children:t.map(e=>(0,sl.jsx)(xG,{snackbar:e,closeSnackbar:()=>n(e)},e.id))})},xY=new wT,xq=0;function xJ(e){e&&(0,s_.createRoot)(e).render((0,sl.jsx)(xZ,{subject:xY}))}function xX(e){var t;e&&"string"==typeof(t=e.title)&&t.trim().length>0?setTimeout(()=>{xY.next({...e,id:xq++})},0):console.error("showSnackbar must be called with an object having a 'title' property that is a non-empty string")}let xQ=({toast:e,closeToast:t})=>{let{description:r,kind:n,critical:a,title:o,actionButtonLabel:i,onActionButtonClick:s=()=>{}}=e,l=(0,so.useCallback)(()=>{s(),t()},[t,s]);return(0,sl.jsx)("div",{children:(0,sl.jsx)(uo.ActionableNotification,{actionButtonLabel:i,kind:n||"info",lowContrast:a,subtitle:r,title:o||"",onActionButtonClick:l,onClose:t})})},x0=({subject:e})=>{let[t,r]=(0,so.useState)([]),n=(0,so.useCallback)(e=>{r(t=>t.filter(t=>t!==e))},[]);return(0,so.useEffect)(()=>{let t=e.subscribe(e=>r(t=>[...t.filter(t=>t.description!==e.description||t.kind!==e.kind||t.title!==e.title||t.actionButtonLabel!==e.actionButtonLabel||t.onActionButtonClick!==e.onActionButtonClick),e]));return()=>t.unsubscribe()},[e]),(0,sl.jsx)(sl.Fragment,{children:t.map(e=>(0,sl.jsx)(xQ,{toast:e,closeToast:()=>n(e)},e.id))})},x1=new wT,x4=0;function x2(e){e&&(0,s_.createRoot)(e).render((0,sl.jsx)(x0,{subject:x1}))}function x3(e){var t;e&&("string"==typeof(t=e.description)?t.trim().length>0:"object"==typeof t&&!(0,w_.A)(t))?setTimeout(()=>{x1.next({...e,id:x4++})},0):console.error("showToast must be called with an object having a 'description' property that is a non-empty string or object")}let x6="u">typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),x5=new Uint8Array(16),x9=[];for(let e=0;e<256;++e)x9.push((e+256).toString(16).slice(1));let x8=function(e,t,r){if(x6&&!t&&!e)return x6();let n=(e=e||{}).random??e.rng?.()??function(){if(!c){if("u"<typeof crypto||!crypto.getRandomValues)throw Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");c=crypto.getRandomValues.bind(crypto)}return c(x5)}();if(n.length<16)throw Error("Random bytes length must be >= 16");if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,t){if((r=r||0)<0||r+16>t.length)throw RangeError(`UUID byte range ${r}:${r+15} is out of buffer bounds`);for(let e=0;e<16;++e)t[r+e]=n[e];return t}return function(e,t=0){return(x9[e[t+0]]+x9[e[t+1]]+x9[e[t+2]]+x9[e[t+3]]+"-"+x9[e[t+4]]+x9[e[t+5]]+"-"+x9[e[t+6]]+x9[e[t+7]]+"-"+x9[e[t+8]]+x9[e[t+9]]+"-"+x9[e[t+10]]+x9[e[t+11]]+x9[e[t+12]]+x9[e[t+13]]+x9[e[t+14]]+x9[e[t+15]]).toLowerCase()}(n)};async function x7(e,t){let{openedGroup:r}=i0.getState();if(r){if(r.groupName===e&&Er(r.props,t))return!0;else if(!await Eo({reason:"CLOSE_WORKSPACE_GROUP",explicit:!1}))return!1}return i0.setState(r=>({...r,openedGroup:{groupName:e,props:t},openedWindows:[]})),!0}async function Ee(e){let{openedGroup:t,openedWindows:r}=i0.getState();if(t){if(r.length>0&&!(e||await Eo({reason:"CLOSE_WORKSPACE_GROUP",explicit:!0})))return!1;i0.setState(e=>({...e,openedGroup:null,openedWindows:[]}))}return!0}async function Et(e,t=null,r=null,n=null){let a=i0.getState();if(!a.registeredWorkspacesByName[e])throw Error(`Unable to launch workspace ${e}. Workspace is not registered`);let o=i1(e);if(!o)throw Error(`Unable to launch workspace ${e}. Workspace is not registered to a workspace window`);let{openedGroup:i}=a,{name:s}=o,l=i4(s);if(!l)throw Error(`Unable to launch workspace ${e}. Workspace window ${o.name} is not registered to a workspace group`);let u=i2(e);if(i&&(i.groupName!==l.name||!Er(i.props,n)))return!!await Eo({reason:"CLOSE_WORKSPACE_GROUP",explicit:!0})&&(i0.setState({...a,openedGroup:{groupName:l.name,props:n},openedWindows:[{windowName:s,openedWorkspaces:[Eg(e,t)],props:r,maximized:!1}],isMostRecentlyOpenedWindowHidden:!1}),!0);if(u>=0){let n=a.openedWindows[u],o=a.openedGroup?.props??{},i=a.isMostRecentlyOpenedWindowHidden,{openedWorkspaces:c}=n;if(Er(n.props,r)){let d=c.find(t=>t.workspaceName===e);return d&&Er(d.props,t)?((i||u!==a.openedWindows.length-1)&&i0.setState(Ed.restoreWindow(a,s)),!0):!!await Eo({reason:"CLOSE_WORKSPACE",explicit:!1,windowName:s,workspaceName:e})&&(i0.setState({...a,openedGroup:{groupName:l.name,props:a?.openedGroup?.props??o},openedWindows:[...a.openedWindows.filter((e,t)=>t!==u),{windowName:s,openedWorkspaces:[Eg(e,t)],props:n?.props??r,maximized:!1}],isMostRecentlyOpenedWindowHidden:!1}),!0)}return!!await Eo({reason:"CLOSE_WINDOW",explicit:!1,windowName:s})&&(i0.setState({...a,openedGroup:{groupName:l.name,props:o??a?.openedGroup?.props},openedWindows:[...a.openedWindows.filter((e,t)=>t!==u),{windowName:s,openedWorkspaces:[Eg(e,t)],props:r,maximized:!1}],isMostRecentlyOpenedWindowHidden:!1}),!0)}return"closable"!=l.persistence?(i0.setState({...a,openedGroup:{groupName:l.name,props:n??a?.openedGroup?.props??null},openedWindows:[...a.openedWindows,{windowName:s,openedWorkspaces:[Eg(e,t)],props:r,maximized:!1}],isMostRecentlyOpenedWindowHidden:!1}),!0):!!await Eo({reason:"CLOSE_OTHER_WINDOWS",explicit:!1,windowNameToSpare:o.name})&&(i0.setState({...a,openedGroup:{groupName:l.name,props:n??a?.openedGroup?.props??null},openedWindows:[{windowName:s,openedWorkspaces:[Eg(e,t)],props:r,maximized:!1}],isMostRecentlyOpenedWindowHidden:!1}),!0)}function Er(e,t){return null==e||null==t||T(e,t)}function En(e,t){let r=[];for(let n=e.openedWorkspaces.length-1;n>=0;n--){let a=e.openedWorkspaces[n];if(a.hasUnsavedChanges&&r.push(a),t&&a.workspaceName===t)break}return r}function Ea(e){return 0===e.length?Promise.resolve(!0):new Promise(t=>{let r=wS("workspace2-close-prompt",{size:"sm",onConfirm:()=>{r(),t(!0)},onCancel:()=>{r(),t(!1)},affectedWorkspaceTitles:e.map(e=>e.title??"")})})}function Eo(e){let{openedWindows:t}=i0.getState(),r=[];switch(e.reason){case"CLOSE_WORKSPACE_GROUP":r=t.flatMap(e=>En(e));break;case"CLOSE_WINDOW":{let n=t.find(t=>t.windowName===e.windowName);if(!n)throw Error(`Window ${e.windowName} not found in opened windows.`);r=En(n);break}case"CLOSE_WORKSPACE":{let n=t.find(t=>t.windowName===e.windowName);if(!n)throw Error(`Window ${e.windowName} not found in opened windows.`);r=En(n,e.workspaceName);break}case"CLOSE_OTHER_WINDOWS":r=t.filter(t=>t.windowName!==e.windowNameToSpare).flatMap(e=>En(e))}return Ea(r)}function Ei(e,t){return Ea(En(e,t))}function Es(e,t){let r=e.openedWorkspaces.findIndex(e=>e.workspaceName===t);return r<0?e:0===r?null:{...e,openedWorkspaces:e.openedWorkspaces.slice(0,r)}}function El(e,t,r,n){let{registeredWorkspacesByName:a}=i0.getState(),o=a[r];if(!o)throw Error(`No workspace named "${r}" registered`);let i=a[t];if(!i)throw Error(`No workspace named "${t}" registered`);if(i.window!==o.window)throw Error(`Child workspace ${r} does not belong to the same workspace window as parent workspace ${t}`);if(o.window!==e.windowName)throw Error(`Cannot open child workspace ${r} as window ${o.window} is not opened`);let{openedWorkspaces:s}=e,l=s.findIndex(e=>e.workspaceName===t);if(-1===l)throw Error(`Cannot open child workspace ${r} from parent workspace ${t} as the parent is not opened within the workspace window`);let u=s.slice(0,l+1);return{...e,openedWorkspaces:[...u,Eg(r,n)]}}function Eu(e,t,r){let n=e.openedWorkspaces.findIndex(e=>e.uuid===t);if(n<0)return e;let a=e.openedWorkspaces[n];if(Object.keys(r).every(e=>a[e]===r[e]))return e;let o=[...e.openedWorkspaces];return o[n]={...a,...r},{...e,openedWorkspaces:o}}function Ec(e,t,r){let n=e.openedWindows.findIndex(e=>e.openedWorkspaces.some(e=>e.uuid===t));if(n<0)return e;let a=e.openedWindows[n],o=Eu(a,t,r);if(o===a)return e;let i=[...e.openedWindows];return i[n]=o,{...e,openedWindows:i}}let Ed={setWindowMaximized(e,t,r){let n=e.openedWindows.findIndex(e=>e.windowName===t),a=[...e.openedWindows],o={...a[n],maximized:r};return a[n]=o,{...e,openedWindows:a}},hideWindow:e=>({...e,isMostRecentlyOpenedWindowHidden:!0}),restoreWindow(e,t){let r=e.openedWindows.findIndex(e=>e.windowName===t),n=e.openedWindows[r],a=[...e.openedWindows.filter((e,t)=>t!==r),n];return{...e,openedWindows:a,isMostRecentlyOpenedWindowHidden:!1}},closeWorkspace(e,t){let r=e.openedWindows.findIndex(e=>e.openedWorkspaces.some(e=>e.workspaceName===t));if(r<0)return e;let n=Es(e.openedWindows[r],t),a=[...e.openedWindows],o=e.isMostRecentlyOpenedWindowHidden;if(null===n){let t=r===e.openedWindows.length-1;a.splice(r,1),t&&a.length>0&&(o=!1)}else a[r]=n;return{...e,openedWindows:a,isMostRecentlyOpenedWindowHidden:o}},openChildWorkspace(e,t,r,n){let a=e.registeredWorkspacesByName[r];if(!a)throw Error(`No workspace named "${r}" registered`);let o=e.openedWindows.findIndex(e=>e.windowName===a.window);if(-1==o)throw Error(`Cannot open child workspace ${r} as window ${a.window} is not opened`);let i=[...e.openedWindows];return i[o]=El(e.openedWindows[o],t,r,n),{...e,openedWindows:i}},setHasUnsavedChanges:(e,t,r)=>Ec(e,t,{hasUnsavedChanges:r}),setWorkspaceTitle:(e,t,r)=>Ec(e,t,{title:r})};function Em(){return sh(i0,Ed)}let Ep=()=>(0,so.useContext)(sk.SingleSpaContext),Ef=()=>Object.keys(i0.getState().registeredWorkspacesByName);function Eh(e,t,r){let n=e.openedWorkspaces[e.openedWorkspaces.length-1];return(n?t[n.workspaceName]?.width:void 0)??r[e.windowName]?.width??"narrow"}function Eg(e,t){return{workspaceName:e,props:t??{},hasUnsavedChanges:!1,uuid:x8()}}function Ey(e,t,r){let n=i0.getState().registeredWorkspacesByName[e];return n?{windowName:n.window,openedWorkspaces:[Eg(e,t)],props:r??null,maximized:!1}:null}let Ev=({title:e,children:t,hasUnsavedChanges:r=!1})=>{let{setHasUnsavedChanges:n,setWorkspaceTitle:a}=Ep();return(0,so.useEffect)(()=>{n(r??!1)},[r,n]),(0,so.useEffect)(()=>{a(e)},[e,a]),(0,sl.jsx)(sl.Fragment,{children:t})};function Eb(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 Ew(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Eb(Object(r),!0).forEach(function(t){EE(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Eb(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function Ex(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function EE(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function ED(e){return(ED=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function ES(e,t){return(ES=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function E_(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}var EC=function(e){var t=so.Component;if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");i.prototype=Object.create(t&&t.prototype,{constructor:{value:i,writable:!0,configurable:!0}}),t&&ES(i,t);var r,n,a,o=(r=function(){if("u"<typeof Reflect||!Reflect.construct||Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}(),function(){var e,t=ED(i);e=r?Reflect.construct(t,arguments,ED(this).constructor):t.apply(this,arguments);if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw TypeError("Derived constructors may only return object or undefined");return E_(this)});function i(e){var t;if(function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,i),EE(E_(t=o.call(this,e)),"handleRef",function(e){t.el=e}),EE(E_(t),"addThingToDo",function(e,r){t.state.hasError&&"unmount"!==e||(t.nextThingToDo=(t.nextThingToDo||Promise.resolve()).then(function(){if(!t.unmounted||"unmount"===e)return r.apply(void 0,arguments)}).catch(function(r){throw t.nextThingToDo=Promise.resolve(),t.setState({hasError:!0}),r&&r.message&&(r.message="During '".concat(e,"', parcel threw an error: ").concat(r.message)),t.props.handleError?t.props.handleError(r):setTimeout(function(){throw r}),r}))}),EE(E_(t),"getParcelProps",function(){var e=Ew(Ew({},t.props),{},{domElement:t.el});return delete e.mountParcel,delete e.config,delete e.wrapWith,delete e.wrapStyle,delete e.appendTo,delete e.handleError,delete e.parcelDidMount,e}),t.state={hasError:!1},!e.config)throw Error("single-spa-react's Parcel component requires the 'config' prop to either be a parcel config or a loading function that returns a promise. See https://github.com/single-spa/single-spa-react");return t}return n=[{key:"componentDidMount",value:function(){var e=this;this.unmounted=!1,this.addThingToDo("mount",function(){var t,r=e.props.mountParcel||e.mountParcel;if(!r)throw Error("\n <Parcel /> was not passed a mountParcel prop, nor is it rendered where mountParcel is within the React context.\n If you are using <Parcel /> within a module that is not a single-spa application, you will need to import mountRootParcel from single-spa and pass it into <Parcel /> as a mountParcel prop \n ");return e.el?t=e.el:(e.createdDomElement=t=document.createElement(e.props.wrapWith),Object.keys(e.props.wrapStyle).forEach(function(r){t.style[r]=e.props.wrapStyle[r]}),e.props.appendTo.appendChild(t)),e.parcel=r(e.props.config,Ew({domElement:t},e.getParcelProps())),e.parcel.mountPromise.then(e.props.parcelDidMount),e.parcel.mountPromise})}},{key:"componentDidUpdate",value:function(){var e=this;this.addThingToDo("update",function(){if(e.parcel&&e.parcel.update)return e.parcel.update(e.getParcelProps())})}},{key:"componentWillUnmount",value:function(){var e=this;this.addThingToDo("unmount",function(){if(e.parcel&&"MOUNTED"===e.parcel.getStatus())return e.parcel.unmount()}),this.createdDomElement&&this.createdDomElement.parentNode.removeChild(this.createdDomElement),this.unmounted=!0}},{key:"render",value:function(){var e=this;if(this.props.appendTo)return sk.SingleSpaContext&&sk.SingleSpaContext.Consumer?so.createElement(sk.SingleSpaContext.Consumer,null,function(t){return e.mountParcel=t?t.mountParcel:null,null}):null;var t=sk.SingleSpaContext&&sk.SingleSpaContext.Consumer?so.createElement(sk.SingleSpaContext.Consumer,null,function(t){return e.mountParcel=t?t.mountParcel:null,null}):void 0;return so.createElement(this.props.wrapWith,{ref:this.handleRef,style:this.props.wrapStyle,className:this.props.wrapClassName},t)}}],Ex(i.prototype,n),a&&Ex(i,a),i}();EE(EC,"defaultProps",{wrapWith:"div",wrapStyle:{},parcelDidMount:function(){}});var Ek=r(8742);let EP=si().forwardRef(function({children:e,size:t=16,...r},n){return 16===t||"16"===t||"16px"===t?si().createElement(Ek.A,{width:t,height:t,ref:n,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 16 16",fill:"currentColor",...r},et||(et=si().createElement("path",{d:"M2 9L2 10 5.3 10 1 14.3 1.7 15 6 10.7 6 14 7 14 7 9zM14 7L14 6 10.7 6 15 1.7 14.3 1 10 5.3 10 2 9 2 9 7z"})),e):si().createElement(Ek.A,{width:t,height:t,ref:n,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",fill:"currentColor",...r},er||(er=si().createElement("path",{d:"M4 18L4 20 10.586 20 2 28.582 3.414 30 12 21.414 12 28 14 28 14 18 4 18zM30 3.416L28.592 2 20 10.586 20 4 18 4 18 14 28 14 28 12 21.414 12 30 3.416z"})),e)});var ER=r(4240),ET=r(8622);let E$={workspaceOuterContainer:"-esm-patient-chart__workspace2-module__workspaceOuterContainer___jaqGm",narrowWorkspace:"-esm-patient-chart__workspace2-module__narrowWorkspace___o1wsL",widerWorkspace:"-esm-patient-chart__workspace2-module__widerWorkspace___gdEOi",extraWideWorkspace:"-esm-patient-chart__workspace2-module__extraWideWorkspace___U9xlJ",workspaceMiddleContainer:"-esm-patient-chart__workspace2-module__workspaceMiddleContainer___0AdtX",maximized:"-esm-patient-chart__workspace2-module__maximized___aKCbE",hidden:"-esm-patient-chart__workspace2-module__hidden___n1US5",workspaceInnerContainer:"-esm-patient-chart__workspace2-module__workspaceInnerContainer___1g+qk",workspaceSpacer:"-esm-patient-chart__workspace2-module__workspaceSpacer___P2T9y",loader:"-esm-patient-chart__workspace2-module__loader___fCfzZ",hiddenExtraWorkspace:"-esm-patient-chart__workspace2-module__hiddenExtraWorkspace___hvPSi",header:"-esm-patient-chart__workspace2-module__header___MXXx9",headerButtons:"-esm-patient-chart__workspace2-module__headerButtons___sJdnC",workspaceContent:"-esm-patient-chart__workspace2-module__workspaceContent___6NuXT",overlayHeaderSpacer:"-esm-patient-chart__workspace2-module__overlayHeaderSpacer___PLO6T",isActionMenuOpened:"-esm-patient-chart__workspace2-module__isActionMenuOpened___X3Vj6",showActionMenu:"-esm-patient-chart__workspace2-module__showActionMenu___HSun1",marginWorkspaceContent:"-esm-patient-chart__workspace2-module__marginWorkspaceContent___DCfWz",workspaceContainerWithActionMenu:"-esm-patient-chart__workspace2-module__workspaceContainerWithActionMenu___G9MdI",workspaceFixedContainer:"-esm-patient-chart__workspace2-module__workspaceFixedContainer___uIldI",workspaceContainerWithoutActionMenu:"-esm-patient-chart__workspace2-module__workspaceContainerWithoutActionMenu___lBudZ"},EN=e=>e.registeredWorkspacesByName,EO=({lifeCycle:e,openedWorkspace:t,openedWindow:r,groupProps:n,actions:a,renderChrome:o,isRootWorkspace:i,isLeafWorkspace:s,showActionMenu:l})=>{let u=(0,so.useMemo)(()=>t&&{closeWorkspace:async(e={})=>{let{closeWindow:n=!1,discardUnsavedChanges:o=!1}=e;return n?!!(o||await a.promptForClosingWorkspaces())&&(a.closeWorkspace(r.openedWorkspaces[0].workspaceName),!0):!!(o||await a.promptForClosingWorkspaces(t.workspaceName))&&(a.closeWorkspace(t.workspaceName),!0)},launchChildWorkspace:async(e,n)=>{let o=t.workspaceName,{openedWorkspaces:i}=r,s=i.findIndex(e=>e.workspaceName===o);-1===s||s!==i.length-1&&i.slice(s+1).some(e=>e.hasUnsavedChanges)&&!await a.promptForClosingWorkspaces(i[s+1].workspaceName)||a.openChildWorkspace(o,e,n||{})},setWorkspaceTitle:e=>a.setWorkspaceTitle(t.uuid,e),setHasUnsavedChanges:e=>a.setHasUnsavedChanges(t.uuid,e),workspaceName:t.workspaceName,workspaceProps:t.props,windowProps:r.props,groupProps:n,workspaceMeta:i0.getState().registeredWorkspacesByName[t.workspaceName]?.meta??{},isRootWorkspace:i,isLeafWorkspace:s,windowName:r.windowName,showActionMenu:l},[t,r,n,a,i,s,l]),c=!o&&!s,d=(0,so.useMemo)(()=>e?(0,sl.jsx)(EC,{config:e,mountParcel:sn,wrapWith:"div",wrapClassName:ue()(E$.workspaceContent,{[E$.hiddenExtraWorkspace]:c}),...u},t.workspaceName):null===e?(0,sl.jsx)("div",{className:ue()(E$.workspaceContent,{[E$.hiddenExtraWorkspace]:c}),children:(0,sl.jsx)(uo.InlineNotification,{kind:"error",title:nB("error"),subtitle:nB("somethingWentWrongTryReloading"),hideCloseButton:!0})}):null,[e,t.workspaceName,u,c]);return o?(0,sl.jsx)("div",{children:(0,sl.jsx)(EI,{openedWorkspace:t,openedWindow:r,isRootWorkspace:i,showActionMenu:l,closeWindow:()=>u.closeWorkspace({closeWindow:!0}),children:d})}):d??(0,sl.jsx)(uo.InlineLoading,{className:ue()(E$.loader,{[E$.hiddenExtraWorkspace]:c}),description:`${nB("loading")}`})},EI=({openedWorkspace:e,openedWindow:t,isRootWorkspace:r,showActionMenu:n,closeWindow:a,children:o})=>{let i=lD(),{openedGroup:s,openedWindows:l,registeredWindowsByName:u,registeredWorkspacesByName:c,registeredGroupsByName:d,isMostRecentlyOpenedWindowHidden:m,setWindowMaximized:p,hideWindow:f}=Em(),h=t.windowName,{maximized:g}=t,y=e.title??"",v=u[h],b=Eh(t,c,u),w=v?.icon,x=v?.canMaximize,E=!!s&&d[s.groupName]?.persistence==="closable",D=!!w&&!E,S=l.findIndex(e=>e.windowName===h)<l.length-1||m,_=Object.values(u).some(e=>e.group===s?.groupName&&void 0!==e.icon);return(0,sl.jsxs)("div",{className:ue()(E$.workspaceOuterContainer,{[E$.narrowWorkspace]:"narrow"===b,[E$.widerWorkspace]:"wider"===b,[E$.extraWideWorkspace]:"extra-wide"===b,[E$.isActionMenuOpened]:_}),children:[(0,sl.jsx)("div",{className:ue()(E$.workspaceSpacer,{[E$.hidden]:S})}),(0,sl.jsx)("div",{className:ue()(E$.workspaceMiddleContainer,{[E$.maximized]:g,[E$.hidden]:S,[E$.isRootWorkspace]:r,[E$.showActionMenu]:n}),children:(0,sl.jsx)("div",{className:ue()(E$.workspaceInnerContainer,{[E$.maximized]:g,[E$.hidden]:S,[E$.isRootWorkspace]:r}),children:o?(0,sl.jsxs)(sl.Fragment,{children:[(0,sl.jsxs)(uo.Header,{"aria-label":nB("workspaceHeader"),className:E$.header,children:[(0,sl.jsx)(uo.HeaderName,{prefix:"",children:y}),(0,sl.jsx)("div",{className:E$.overlayHeaderSpacer}),(0,sl.jsx)(uo.HeaderGlobalBar,{className:E$.headerButtons,children:lS(i)?(0,sl.jsxs)(sl.Fragment,{children:[(x||g)&&(0,sl.jsx)(uo.HeaderGlobalAction,{"aria-label":g?nB("minimize"):nB("maximize"),onClick:()=>p(h,!g),children:g?(0,sl.jsx)(EP,{}):(0,sl.jsx)(ER.hz,{})}),D&&(0,sl.jsx)(uo.HeaderGlobalAction,{"aria-label":nB("hide"),onClick:()=>f(),children:(0,sl.jsx)(uE,{})}),!E&&(0,sl.jsx)(uo.HeaderGlobalAction,{"aria-label":nB("close"),onClick:a,children:(0,sl.jsx)(uB,{})})]}):(0,sl.jsxs)(sl.Fragment,{children:[D&&(0,sl.jsx)(uo.HeaderGlobalAction,{"aria-label":nB("hide"),onClick:()=>f(),children:(0,sl.jsx)(ET.d3,{})}),(0,sl.jsx)(uo.HeaderGlobalAction,{"aria-label":nB("close"),onClick:()=>{E?Ee():a()},children:(0,sl.jsx)(uB,{})})]})})]}),o]}):(0,sl.jsx)(uo.InlineLoading,{className:E$.loader,description:`${nB("loading")} ...`})})})]})},EA=({openedWindow:e,groupProps:t,actions:r,renderChrome:n,showActionMenu:a})=>{let{openedWorkspaces:o}=e,[i,s]=(0,so.useState)({}),l=sf(i0,EN),u=(0,so.useRef)(new Set);return(0,so.useEffect)(()=>{let e=!1;return Promise.all(o.map(async t=>{let r=l[t.workspaceName];if(!r)return null;let{moduleName:n,component:a}=r;try{return[t.uuid,await lX(n,a)]}catch(r){return e||u.current.has(t.uuid)||(u.current.add(t.uuid),k(r)),[t.uuid,null]}})).then(t=>{e||s(Object.fromEntries(t.filter(e=>null!=e)))},k),()=>{e=!0}},[o,l]),(0,sl.jsx)(sl.Fragment,{children:o.map((s,l)=>(0,sl.jsx)(EO,{openedWorkspace:s,openedWindow:e,groupProps:t,actions:r,renderChrome:n,lifeCycle:i[s.uuid],isRootWorkspace:0===l,isLeafWorkspace:l===o.length-1,showActionMenu:a},s.uuid))})},EM=e=>e.registeredWorkspacesByName,Ej=({name:e,workspaceProps:t,windowProps:r,groupProps:n,onWindowChanged:a})=>{let o=sf(i0,EM),i=sf(i0,t=>{let r=t.registeredWorkspacesByName[e]?.window;return r?t.registeredWindowsByName[r]:void 0}),s={name:e,workspaceProps:t,windowProps:r,groupProps:n},l=(0,so.useRef)(null),u=(0,so.useRef)(null);if(!l.current){let a=Ey(e,t,r);l.current=V({openedWindow:a,groupProps:n??null}),a&&(u.current=s)}let c=l.current;(0,so.useEffect)(()=>{let a=u.current;if(a&&a.name===e&&T(a.workspaceProps,t)&&T(a.windowProps,r)&&T(a.groupProps,n))return;let o=Ey(e,t,r);c.setState({openedWindow:o,groupProps:n??null},!0),u.current=o?s:null},[e,t,r,n,o,c]);let d=(0,so.useMemo)(()=>(function(e){function t(t){e.setState(e=>{if(!e.openedWindow)return e;let r=t(e.openedWindow);return r===e.openedWindow?e:{...e,openedWindow:r}})}return{closeWorkspace(e){t(t=>Es(t,e))},openChildWorkspace(e,r,n){t(t=>El(t,e,r,n))},setWorkspaceTitle(e,r){t(t=>Eu(t,e,{title:r}))},setHasUnsavedChanges(e,r){t(t=>Eu(t,e,{hasUnsavedChanges:r}))},promptForClosingWorkspaces(t){let{openedWindow:r}=e.getState();return r?Ei(r,t):Promise.resolve(!0)}}})(c),[c]),{openedWindow:m,groupProps:p}=sf(c),f=m?.openedWorkspaces[m.openedWorkspaces.length-1],h=f?.workspaceName??null,g=f?.title??"",y=m?.openedWorkspaces.some(e=>e.hasUnsavedChanges)??!1,v=i?.width??"narrow",b=(0,so.useRef)(a);return(0,so.useEffect)(()=>{b.current=a}),(0,so.useEffect)(()=>{b.current?.({workspaceName:h,windowWidth:v,title:g,hasUnsavedChanges:y})},[h,v,g,y]),(0,sl.jsx)("div",{className:"-esm-patient-chart__exported-workspace-module__exportedWorkspace___3vwoL",children:m?(0,sl.jsx)(EA,{openedWindow:m,groupProps:p,actions:d,renderChrome:!1,showActionMenu:!1}):null})},EL="-esm-patient-chart__action-menu-button2-module__container___pahg-",EF="-esm-patient-chart__action-menu-button2-module__elementContainer___PzOdc",EB="-esm-patient-chart__action-menu-button2-module__active___4O4Bs",EV="-esm-patient-chart__action-menu-button2-module__focused___+k5kD";function EU({getIcon:e,hasUnsavedChanges:t,tagContent:r}){return(0,sl.jsxs)(sl.Fragment,{children:[e({size:16}),t?(0,sl.jsx)("span",{className:"-esm-patient-chart__action-menu-button2-module__interruptedTag___mS2yr",children:"!"}):(0,sl.jsx)("span",{className:"-esm-patient-chart__action-menu-button2-module__countTag___rb5CW",children:r})]})}let EW=({icon:e,label:t,tagContent:r,workspaceToLaunch:n,onBeforeWorkspaceLaunch:a,hidden:o,disabled:i})=>{let s=lD(),{openedWindows:l,restoreWindow:u,hideWindow:c,isMostRecentlyOpenedWindowHidden:d}=Em(),{extension:m}=(0,so.useContext)(ss),p=l.findIndex(e=>e.windowName===m?.extensionId),f=l[p],h=null!=f,g=h&&(p<l.length-1||d),y=h&&!g,v=f?.openedWorkspaces.some(e=>e.hasUnsavedChanges)??!1,b=async()=>{if(h)g?u(f.windowName):c();else if(await (a?.()??!0)){let{workspaceName:e,workspaceProps:t,windowProps:r}=n;Et(e,t,r)}};return o?.(l)?null:"tablet"===s||"phone"===s?(0,sl.jsxs)(uo.Button,{className:ue()(EL,{[EB]:h&&!y,[EV]:y}),iconDescription:t,kind:"ghost",onClick:b,role:"button",tabIndex:0,size:"md",disabled:i?.(l),children:[(0,sl.jsx)("span",{className:EF,children:(0,sl.jsx)(EU,{hasUnsavedChanges:v,getIcon:e,tagContent:r})}),(0,sl.jsx)("span",{children:t})]}):(0,sl.jsx)(uo.IconButton,{align:"left","aria-label":t,className:ue()(EL,{[EB]:h&&!y,[EV]:y}),enterDelayMs:300,kind:"ghost",label:t,onClick:b,size:"md",disabled:i?.(l),children:(0,sl.jsx)("div",{className:EF,children:(0,sl.jsx)(EU,{hasUnsavedChanges:v,getIcon:e,tagContent:r})})})};function EH({showContactDetails:e,toggleContactDetails:t,className:r}){return(0,sl.jsx)(uo.Button,{className:r,iconDescription:"Toggle contact details",kind:"ghost",onClick:t,renderIcon:e?uF:uM,children:e?nB("showLess","Show less"):nB("showMore","Show more")})}let Ez={contactDetails:"-esm-patient-chart__patient-banner-contact-details-module__contactDetails___rhdjA",deceased:"-esm-patient-chart__patient-banner-contact-details-module__deceased___K4NPg",heading:"-esm-patient-chart__patient-banner-contact-details-module__heading___zj6Zt",row:"-esm-patient-chart__patient-banner-contact-details-module__row___+Bx+P",col:"-esm-patient-chart__patient-banner-contact-details-module__col___0H31P",relationship:"-esm-patient-chart__patient-banner-contact-details-module__relationship___CZmay"},EK=({patientUuid:e})=>{let{cohorts:t=[],isLoading:r}=function(e){let t=e?`${nQ}/cohortm/cohortmember?patient=${e}&v=custom:(uuid,patient:ref,cohort:(uuid,name,startDate,endDate))`:null,{data:r,isLoading:n}=s$()(t,n2),a=r?.data?.results.map(e=>({uuid:e.cohort.uuid,name:e.cohort.name,startDate:e.cohort.startDate,endDate:e.cohort.endDate}));return(0,so.useMemo)(()=>({cohorts:a,isLoading:n}),[n,a])}(e);return(0,sl.jsxs)(sl.Fragment,{children:[(0,sl.jsxs)("p",{className:Ez.heading,children:[nB("patientLists","Patient Lists")," (",t?.length??0,")"]}),r?(0,sl.jsx)(uo.InlineLoading,{description:`${nB("loading","Loading")} ...`,role:"progressbar"}):(0,sl.jsxs)("ul",{children:[(()=>{if(t?.length>0){let e=t.sort((e,t)=>v3(e?.startDate).getTime()-v3(t?.startDate).getTime()).slice(0,3);return e?.map(e=>(0,sl.jsx)("li",{children:(0,sl.jsx)(su,{to:`${window.spaBase}/home/patient-lists/${e.uuid}`,children:e.name},e.uuid)},e.uuid))}return(0,sl.jsx)("li",{children:"--"})})(),t.length>3&&(0,sl.jsx)("li",{className:Ez.link,children:(0,sl.jsx)(su,{to:`${window.spaBase}/home/patient-lists`,children:nB("seeMoreLists","See {{count}} more lists",{count:t?.length-3})})})]})]})},EG=({patientId:e})=>{let{patient:t,isLoading:r}=lA(e),n=t?.address?.find(e=>"home"===e.use),a=e=>e.split("#")[1];return r?(0,sl.jsx)(uo.InlineLoading,{description:`${nB("loading","Loading")} ...`,role:"progressbar"}):(0,sl.jsxs)(sl.Fragment,{children:[(0,sl.jsx)("p",{className:Ez.heading,children:nB("address","Address")}),(0,sl.jsx)("ul",{children:n?Object.entries(n).filter(([e])=>"id"!==e&&"use"!==e).map(([e,t])=>"extension"===e?n.extension?.[0]?.extension?.map((t,r)=>(0,sl.jsxs)("li",{children:[nB(a(t.url),a(t.url)),": ",t.valueString]},`address-${e}-${r}`)):(0,sl.jsxs)("li",{children:[nB(e,e),": ",t]},`address-${e}`)):(0,sl.jsx)("li",{children:"--"})})]})},EZ=({patientUuid:e})=>{let{isLoading:t,contactAttributes:r}=(e=>{let{contactAttributeTypes:t=[]}=s5({externalModuleName:"@openmrs/esm-patient-banner-app"}),{attributes:r,error:n,isLoading:a}=(e=>{let{data:t,error:r,isLoading:n}=le()(`${nQ}/patient/${e}?v=custom:(uuid,display,identifiers:(identifier,uuid,preferred,location:(uuid,name),identifierType:(uuid,name,format,formatDescription,validator)),person:(uuid,display,gender,birthdate,dead,age,deathDate,birthdateEstimated,causeOfDeath,preferredName:(uuid,preferred,givenName,middleName,familyName),attributes,preferredAddress:(uuid,preferred,address1,address2,cityVillage,longitude,stateProvince,latitude,country,postalCode,countyDistrict,address3,address4,address5,address6,address7)))`,n2);return{isLoading:n,attributes:t?.data.person.attributes??[],error:r}})(e);return{contactAttributes:(0,so.useMemo)(()=>r.filter(({attributeType:e})=>t?.some(t=>e.uuid===t)),[r,t]),isLoading:a,error:n}})(e),n=(0,so.useMemo)(()=>r?[...r?.map(e=>[e.attributeType.display?nB(e.attributeType.display,e.attributeType.display):"",e.value])]:[],[r]);return(0,sl.jsxs)(sl.Fragment,{children:[(0,sl.jsx)("p",{className:Ez.heading,children:nB("contactDetails","Contact Details")}),t?(0,sl.jsx)(uo.InlineLoading,{description:`${nB("loading","Loading")} ...`,role:"progressbar"}):(0,sl.jsx)("ul",{children:n.length?n.map(([e,t],r)=>(0,sl.jsxs)("li",{children:[e,": ",t]},`${e}-${t}-${r}`)):(0,sl.jsx)("li",{children:"--"})})]})},EY=({patientId:e})=>{let{data:t,isLoading:r}=function(e){let t=`${nQ}/relationship?v=custom:(display,uuid,personA:(age,display,birthdate,uuid),personB:(age,display,birthdate,uuid),relationshipType:(uuid,display,description,aIsToB,bIsToA))&person=${e}`,{data:r,error:n,isLoading:a,isValidating:o}=s$()(e?t:null,n2),i=r?.data?.results?.length?function(e,t){let r=[];for(let n of t)e===n.personA.uuid?r.push({uuid:`${n.uuid}`,display:n.personB.display,relativeAge:n.personB.age,relativeUuid:n.personB.uuid,relationshipType:n.relationshipType.bIsToA}):r.push({uuid:`${n.uuid}`,display:n.personA.display,relativeAge:n.personA.age,relativeUuid:n.personA.uuid,relationshipType:n.relationshipType.aIsToB});return r}(e,r.data.results):null;return{data:r?i:null,error:n,isLoading:a,isValidating:o}}(e);return(0,sl.jsxs)(sl.Fragment,{children:[(0,sl.jsx)("p",{className:Ez.heading,children:nB("relationships","Relationships")}),r?(0,sl.jsx)(uo.InlineLoading,{description:`${nB("loading","Loading")} ...`,role:"progressbar"}):(0,sl.jsx)("ul",{children:t&&t.length>0?(0,sl.jsx)(sl.Fragment,{children:t.map(e=>(0,sl.jsxs)("li",{className:Ez.relationship,children:[(0,sl.jsx)("div",{children:(0,sl.jsx)(su,{to:`${window.spaBase}/patient/${e.relativeUuid}/chart`,children:e.display})}),(0,sl.jsx)("div",{children:e.relationshipType}),(0,sl.jsx)("div",{children:`${e.relativeAge?e.relativeAge:"--"} ${e.relativeAge?1===e.relativeAge?nB("yearAbbreviation","yr"):nB("yearsAbbreviation","yrs"):""}`})]},e.uuid))}):(0,sl.jsx)("li",{children:"--"})})]})};function Eq({patientId:e,deceased:t}){return(0,sl.jsxs)("div",{className:ue()(Ez.contactDetails,{[Ez.deceased]:t}),children:[(0,sl.jsxs)("div",{className:Ez.row,children:[(0,sl.jsx)("div",{className:Ez.col,children:(0,sl.jsx)(EG,{patientId:e})}),(0,sl.jsx)("div",{className:Ez.col,children:(0,sl.jsx)(EZ,{patientUuid:e})})]}),(0,sl.jsxs)("div",{className:Ez.row,children:[(0,sl.jsx)("div",{className:Ez.col,children:(0,sl.jsx)(EY,{patientId:e})}),(0,sl.jsx)("div",{className:Ez.col,children:(0,sl.jsx)(EK,{patientUuid:e})})]})]})}function EJ(e){let t=document.querySelector("template#loading-spinner");if(t){let r=t.content.cloneNode(!0),n=Array.prototype.map.call(r.childNodes,e=>e);return e.appendChild(r),()=>n.forEach(e=>e.remove())}return()=>{}}let EX="-esm-patient-chart__action-menu2-module__container___5s3CM";function EQ({workspaceGroup:e,groupProps:t}){let r=lD(),{persistence:n}=e;return(0,sl.jsx)("aside",{className:"-esm-patient-chart__action-menu2-module__sideRail___qwAz4",children:(0,sl.jsxs)("div",{className:EX,children:["closable"==n&&lS(r)&&(0,sl.jsx)(uo.IconButton,{align:"left",onClick:()=>Ee(),label:nB("close"),kind:"ghost",children:(0,sl.jsx)(uB,{})}),(0,sl.jsx)(ss.Provider,{value:{moduleName:e.moduleName,featureName:e.name},children:(0,sl.jsx)(sS,{className:EX,name:e.name,state:{groupProps:t}})})]})})}function E0(e){let t=new URL(e,window.location.origin).pathname,r=new URL(window.getOpenmrsSpaBase?.()??"/",window.location.origin).pathname,n=r.endsWith("/")?r.slice(0,-1):r,a=null;return n?n===t?a="/":t.startsWith(`${n}/`)&&(a=t.slice(n.length)):a=t,{full:t,spaRelative:a}}function E1(e){e&&(0,s_.createRoot)(e).render((0,sl.jsx)(E4,{}))}function E4(){let{openedGroup:e,openedWindows:t,registeredGroupsByName:r,registeredWindowsByName:n}=Em();if((0,so.useEffect)(()=>ou("before-page-changed",t=>{let{newPage:n,cancelNavigation:a,oldUrl:o,newUrl:i}=t;if(!e)return;if(n)return void a(Ee().then(e=>!e));let s=r[e.groupName],l=s?.scopePattern;l&&function(e,t,r){try{let n=new RegExp(e),a=E0(t),o=E0(r);if(null===a.spaRelative||null===o.spaRelative)return!0;let i=n.exec(a.spaRelative),s=n.exec(o.spaRelative);if(i&&s||(i=n.exec(a.full),s=n.exec(o.full)),!i||!s)return!0;if(i.length>1)return!i.slice(1).every((e,t)=>e===s[t+1]);return!1}catch{return!0}}(l,o,i)&&a(Ee().then(e=>!e))}),[e,r]),!e)return null;let a=r[e.groupName],o=t.some(e=>e.maximized),{name:i}=a,s=Object.values(n).filter(e=>e.group===i&&void 0!==e.icon).sort((e,t)=>(e.order??Number.MAX_VALUE)-(t.order??Number.MAX_VALUE)).length>0;return(0,sl.jsxs)("div",{className:ue()("-esm-patient-chart__workspace-windows-and-menu-module__workspaceWindowsAndMenuContainer___gN2f4",{"-esm-patient-chart__workspace-windows-and-menu-module__overlay___fqI+X":a.overlay,"-esm-patient-chart__workspace-windows-and-menu-module__hasMaximizedWindow___J7wBw":o}),children:[(0,sl.jsx)("div",{className:"-esm-patient-chart__workspace-windows-and-menu-module__workspaceWindowsContainer___zpk7G",children:t.map(t=>(0,sl.jsx)(E2,{openedWindow:t,groupProps:e.props,showActionMenu:s},t.windowName))}),s&&(0,sl.jsx)(EQ,{workspaceGroup:a,groupProps:e.props})]})}function E2({openedWindow:e,groupProps:t,showActionMenu:r}){let{windowName:n}=e,a=(0,so.useMemo)(()=>({closeWorkspace(e){i0.setState(t=>Ed.closeWorkspace(t,e))},openChildWorkspace(e,t,r){i0.setState(n=>Ed.openChildWorkspace(n,e,t,r))},setWorkspaceTitle(e,t){i0.setState(r=>Ed.setWorkspaceTitle(r,e,t))},setHasUnsavedChanges(e,t){i0.setState(r=>Ed.setHasUnsavedChanges(r,e,t))},promptForClosingWorkspaces(e){let t=i0.getState().openedWindows.find(e=>e.windowName===n);return t?Ei(t,e):Promise.resolve(!0)}}),[n]);return(0,sl.jsx)(EA,{openedWindow:e,groupProps:t,actions:a,renderChrome:!0,showActionMenu:r})}function E3(e,t,r){if(null==e)return r;let n=vy(e);if(!n)return console.warn(`matchLocale: invalid requested locale tag: ${JSON.stringify(e)}`),r;let a=[];for(let e of t){let t=vy(e);if(!t){console.warn(`matchLocale: skipping invalid available locale tag: ${JSON.stringify(e)}`);continue}a.push({canonical:t,original:e})}let o=n;for(;o;){let e=a.find(e=>e.canonical===o);if(e)return e.original;let t=o+"-",r=a.find(e=>e.canonical.startsWith(t));if(r)return r.original;if("ht"===o){o="fr-HT";continue}let n=o.lastIndexOf("-");if(-1===n)break;let i=(o=o.slice(0,n)).lastIndexOf("-");-1!==i&&o.length-i==2&&(o=o.slice(0,i))}return r}function E6(e=window.localStorage){try{return e.getItem("test"),!0}catch{return!1}}function E5(e){return!!e&&e.constructor===Object}var E9=r(7229);function E8(e){let[t,r,n]=e.split(".");return`${t}.${r}.${n}`}function E7(e,t){return E9(function(e){let t=e.indexOf("-");if(t>=0){let r=E8(e.slice(0,t)),n=e.slice(t+1);return`${r}-${n}`}return E8(e)}(t),e,{includePrerelease:!0})}async function De(e,t={}){let r,{shouldRetry:n,getDelay:a,onError:o}=t;n=n??(e=>e<=5),a=a??(e=>(function(e,t=!1){return 1e3*Math.pow(2,t?e+1:e)})(e));let i=0;do try{return await Dt(a(i)),await e()}catch(e){o?.(e,i),r=e}while(n(i++));throw r}async function Dt(e){if(!(e<=0))return new Promise(t=>setTimeout(t,e))}function Dr(e,t,r,n){}function Dn(e){}function Da(e){return Promise.resolve([])}function Do(e){return Promise.resolve([])}function Di(e){return Promise.resolve({success:!1,result:void 0,error:"No service worker has been registered. Offline-related features have been removed from the framework."})}function Ds(e){return()=>{}}function Dl(){return!0}},8007(e,t,r){"use strict";r.d(t,{A:()=>n});let n=function(e,t,r){var n=-1,a=e.length;t<0&&(t=-t>a?0:a+t),(r=r>a?a:r)<0&&(r+=a),a=t>r?0:r-t>>>0,t>>>=0;for(var o=Array(a);++n<a;)o[n]=e[n+t];return o}},5992(e,t,r){"use strict";r.d(t,{A:()=>m});var n=r(3264),a=r(616),o=r(6770),i=r(6956),s=r(1475),l=r(1917),u=r(1140),c=r(480),d=Object.prototype.hasOwnProperty;let m=function(e){if(null==e)return!0;if((0,s.A)(e)&&((0,i.A)(e)||"string"==typeof e||"function"==typeof e.splice||(0,l.A)(e)||(0,c.A)(e)||(0,o.A)(e)))return!e.length;var t=(0,a.A)(e);if("[object Map]"==t||"[object Set]"==t)return!e.size;if((0,u.A)(e))return!(0,n.A)(e).length;for(var r in e)if(d.call(e,r))return!1;return!0}},254(e,t,r){"use strict";r.d(t,{A:()=>n});let n=function(e){return null==e}}}]);